{"ast":null,"code":"import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { jsxs as _jsxs } from \"react/jsx-runtime\";\n\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }\n\nfunction _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }\n\nimport cn from 'classnames';\nimport MapContainer from 'components/mapContainer/MapContainer';\nimport { useIsDesktop } from 'hooks/useIsDevice';\nimport { useState } from 'react';\nimport SliceIntro from 'slices/SliceIntro/SliceIntro';\nimport TabsSlice from 'slices/TabsSlice/TabsSlice';\nimport styles from './CityMapSlice.module.scss';\nimport HousesList, { HouseItem } from './HousesList';\n\nconst DesktopMapSlice = ({\n  houses,\n  searchPlaceholder,\n  loadMoreCities\n}) => {\n  // TODO highlightCity => highlightHouse\n  const {\n    0: highlightCity,\n    1: setHighlightCity\n  } = useState('');\n\n  const handleMouseEvent = (type, slug) => {\n    setHighlightCity(type == 'mouseover' ? slug : '');\n  };\n\n  return /*#__PURE__*/_jsxs(\"div\", {\n    className: cn(styles.tabsContainer),\n    children: [/*#__PURE__*/_jsx(\"div\", {\n      className: cn(styles.listContainer),\n      children: /*#__PURE__*/_jsx(HousesList, {\n        houses: houses,\n        handleMouseEvent: handleMouseEvent,\n        highlightCity: highlightCity,\n        placeholder: searchPlaceholder,\n        loadMore: loadMoreCities\n      })\n    }), /*#__PURE__*/_jsx(\"div\", {\n      className: cn(styles.mapContainer),\n      children: /*#__PURE__*/_jsx(MapContainer, {\n        houses: houses,\n        handleMouseEvent: handleMouseEvent,\n        highlightCity: highlightCity\n      })\n    })]\n  });\n};\n\nconst MobileMapSlice = ({\n  houses,\n  searchPlaceholder,\n  loadMoreCities\n}) => {\n  const {\n    0: highlightHouse,\n    1: setHighlightHouse\n  } = useState(null);\n\n  const handleMouseEvent = (type, slug) => {\n    if (type == 'click') {\n      setHighlightHouse(highlightHouse == slug ? null : slug);\n    }\n\n    if (type == 'mapClick') {\n      setHighlightHouse(null);\n    }\n  };\n\n  return /*#__PURE__*/_jsx(TabsSlice, {\n    tabs: [{\n      label: 'Nos habitations',\n      key: 'list',\n      render: () => /*#__PURE__*/_jsx(\"div\", {\n        className: cn(styles.listContainer),\n        children: /*#__PURE__*/_jsx(HousesList, {\n          houses: houses,\n          placeholder: searchPlaceholder,\n          loadMore: loadMoreCities\n        })\n      }, 'list')\n    }, {\n      label: 'Carte',\n      key: 'map',\n      render: () => /*#__PURE__*/_jsx(\"div\", {\n        className: cn(styles.mapContainer),\n        children: /*#__PURE__*/_jsx(MapContainer, {\n          houses: houses,\n          handleMouseEvent: handleMouseEvent,\n          highlightHouse: highlightHouse,\n          centerOn: highlightHouse,\n          overlayKey: highlightHouse,\n          overlay: highlightHouse && /*#__PURE__*/_jsx(HouseItem, {\n            className: cn(styles.houseItem),\n            light: true,\n            house: houses.filter(house => house.slug == highlightHouse)[0],\n            onClose: () => setHighlightHouse(null)\n          })\n        })\n      }, 'map')\n    }]\n  });\n};\n\nconst CityMapSlice = props => {\n  const {\n    id,\n    introText\n  } = props,\n        rest = _objectWithoutProperties(props, [\"id\", \"introText\"]);\n\n  const isDesktop = useIsDesktop();\n  return /*#__PURE__*/_jsxs(\"section\", {\n    id: id,\n    className: cn(styles.mapSlice),\n    children: [isDesktop && /*#__PURE__*/_jsx(SliceIntro, {\n      text: introText,\n      left: true\n    }), isDesktop ? /*#__PURE__*/_jsx(DesktopMapSlice, _objectSpread({}, rest)) : /*#__PURE__*/_jsx(MobileMapSlice, _objectSpread({}, rest))]\n  });\n};\n\nexport default CityMapSlice;","map":null,"metadata":{},"sourceType":"module"}