{"version":3,"file":"session-CRY01QjQ.js","sources":["../../../app/assets/javascripts/app/map/session.ts"],"sourcesContent":["\nimport Cookies from \"plugins/cookies-js/index\"\nimport Defaults from \"./defaults\"\n\n\n// TODO: is it possible to use local storage instead\nconst COOKIE_KEY_PREFIX = \"App.Map.Session\"\nconst KEYS = {\n lastZoom: \"lastZoom\",\n lastLatitude: \"lastLatitude\",\n lastLongitude: \"lastLongitude\",\n lastListingModalId: \"lastListingModalId\",\n}\n\nconst _getCookiePrefix = () => `${COOKIE_KEY_PREFIX}.${window.location.pathname}`\n\nconst getLastZoom = () => {\n let result = NaN\n if (Cookies.enabled){\n result = Number(Cookies.get(`${_getCookiePrefix()}.${KEYS.lastZoom}`))\n }\n if (isNaN(result)){\n result = Defaults.getDefaultZoom()\n }\n return result\n}\n\nconst setLastZoom = (zoomLevel: number) => {\n if (Cookies.enabled){\n Cookies.set(`${_getCookiePrefix()}.${KEYS.lastZoom}`, zoomLevel, {\n // expire in 1 day\n expires: 24 * 60 * 60,\n })\n }\n}\n\nconst getLastCoordinate = () => {\n let [latitude, longitude] = [NaN, NaN]\n if (Cookies.enabled){\n latitude = parseFloat(Cookies.get(`${_getCookiePrefix()}.${KEYS.lastLatitude}`))\n longitude = parseFloat(Cookies.get(`${_getCookiePrefix()}.${KEYS.lastLongitude}`))\n }\n if ([latitude, longitude].some(isNaN)){\n return Defaults.getDefaultCoordinate()\n }\n\n return [latitude, longitude]\n}\n\nconst setLastCoordinate = (latitude: number, longitude: number) => {\n if (Cookies.enabled){\n Cookies.set(`${_getCookiePrefix()}.${KEYS.lastLatitude}`, latitude, {\n // expire in 1 day\n expires: 24 * 60 * 60,\n })\n Cookies.set(`${_getCookiePrefix()}.${KEYS.lastLongitude}`, longitude, {\n // expire in 1 day\n expires: 24 * 60 * 60,\n })\n }\n}\n\nconst getLastListingModalId = () => {\n let result = NaN\n if (Cookies.enabled){\n result = Number(Cookies.get(`${_getCookiePrefix()}.${KEYS.lastListingModalId}`))\n }\n\n if (isNaN(result)) {\n return null\n }\n\n return result\n}\n\nconst setLastListingModalId = (lastListingModalId: number | string) => {\n if (Cookies.enabled){\n Cookies.set(`${_getCookiePrefix()}.${KEYS.lastListingModalId}`, lastListingModalId, {\n // expire in 5 min\n expires: 24 * 60 * 60,\n })\n }\n}\n\nconst removeLastListingModalId = () => {\n Cookies.expire(`${_getCookiePrefix()}.${KEYS.lastListingModalId}`)\n}\n\nexport default {\n getLastZoom,\n setLastZoom,\n getLastCoordinate,\n setLastCoordinate,\n getLastListingModalId,\n setLastListingModalId,\n removeLastListingModalId,\n}\n\n\n\n\n\n\n\n"],"names":["COOKIE_KEY_PREFIX","KEYS","_getCookiePrefix","getLastZoom","result","Cookies","Defaults","setLastZoom","zoomLevel","getLastCoordinate","latitude","longitude","setLastCoordinate","getLastListingModalId","setLastListingModalId","lastListingModalId","removeLastListingModalId","Map_Session"],"mappings":"mFAMA,MAAMA,EAAoB,kBACpBC,EAAO,CACX,SAAoB,WACpB,aAAoB,eACpB,cAAoB,gBACpB,mBAAoB,oBACtB,EAEMC,EAAmB,IAAM,GAAG,OAAAF,EAAiB,KAAI,cAAO,SAAS,UAEjEG,EAAc,IAAM,CACxB,IAAIC,EAAS,IACb,OAAIC,EAAQ,UACDD,EAAA,OAAOC,EAAQ,IAAI,GAAG,OAAAH,EAAkB,EAAA,KAAI,OAAAD,EAAK,SAAU,CAAC,GAEnE,MAAMG,CAAM,IACdA,EAASE,EAAS,eAAe,GAE5BF,CACT,EAEMG,EAAeC,GAAsB,CACrCH,EAAQ,SACFA,EAAA,IAAI,GAAG,OAAAH,EAAkB,EAAA,KAAI,OAAAD,EAAK,UAAYO,EAAW,CAE/D,QAAS,GAAK,GAAK,EAAA,CACpB,CAEL,EAEMC,EAAoB,IAAM,CAC9B,GAAI,CAACC,EAAUC,CAAS,EAAI,CAAC,IAAK,GAAG,EAKrC,OAJIN,EAAQ,UACCK,EAAA,WAAWL,EAAQ,IAAI,GAAG,OAAAH,EAAkB,EAAA,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