{"version":3,"file":"Ci2fwdWe.js","sources":["../../../../constants/statesOfAddressSystem.ts","../../../../types/mapServices.ts","../../../../store/addressSystem/address-system.constants.ts","../../../../services/storage/constants.ts","../../../../services/storage/index.ts","../../../../api/modules/delivery/types.ts","../../../../store/addressSystem/address-system.ts"],"sourcesContent":["import type {\n StateDialogAddressSystem,\n StateDialogContent,\n StateMenuAddressSystem,\n StateOfMap,\n} from '@/types/address-system'\n\n// Generic для заведения состояний констант\ntype GeneralStates = { [key: string]: T }\n\n/**\n * Состояния меню адресной системы\n */\nexport const STATE_MENU_ADDRESS_SYSTEM: GeneralStates =\n {\n SUGGESTIONS: 'suggestions',\n SELECTED: 'selected',\n ERROR: 'error',\n DEFAULT: 'default',\n LOADING: 'loading',\n NOT_DELIVERY: 'not-delivery',\n NOT_GEO: 'not-geo',\n }\n\n/**\n * Состояния ДО адрессной системы\n */\nexport const STATE_DIALOG_ADDRESS_SYSTEM: GeneralStates =\n {\n LOADING: 'loading',\n ERROR: 'error',\n READY: 'ready',\n }\n\n/**\n * Состояния ДО адрессной системы\n */\nexport const STATE_CONTENT_ADDRESS_SYSTEM: GeneralStates = {\n NEW: 'new',\n SELECT: 'select',\n REDIRECT: 'redirect',\n}\n\n/**\n * Состояния карты\n */\nexport const STATE_OF_MAP: GeneralStates = {\n loading: 'pending',\n loaded: 'loaded',\n error: 'error',\n}\n\nexport const BALLOON_TEXT = {\n outsideDelivery: 'Вне зоны доставки',\n addressNotFound: 'Не удалось определить адрес',\n determineAddress: 'Определите адрес доставки',\n default: '',\n}\n","import { PointProperties } from '@/api/modules/delivery/types'\n\nexport interface AutocompleteSuggestion {\n value: string | null\n}\n\nexport interface AutocompleteService {\n getSuggestions: (query: string) => Promise[]>\n}\n\n// Состояния поиска адреса\nexport enum StateGeoAddress {\n LOADING,\n READY,\n}\n\n// Состояние карты\nexport type StateOfMap = 'pending' | 'loading' | 'loaded' | 'error'\n\nexport interface StatesContainer {\n [key: string]: StateOfMap\n}\n\n// Типы объектов карт\nexport enum TypesEntity {\n HOTSPOT = 'hotspot',\n FEATURE = 'feature',\n MARKER = 'marker',\n}\n\n// Типы провайдера\nexport enum TypesProvider {\n YANDEX = 'Yandex',\n GOOGLE = 'Google',\n}\n\nexport interface IGoogleCoords {\n lat: number\n lng: number\n}\n\nexport type EmitDataOfMap = {\n type: TypesEntity\n coords: IGoogleCoords\n point?: PointProperties\n}\n\nexport interface GoogleClickEvent {\n domEvent: MouseEvent\n ei: string\n latLng: google.maps.LatLng\n pixel: string\n}\n\nexport const enum TypeMaps {\n DELIVERY = 'DELIVERY',\n ADDRESS_SYSTEM = 'ADDRESS_SYSTEM',\n}\n","import {\n STATE_CONTENT_ADDRESS_SYSTEM,\n STATE_DIALOG_ADDRESS_SYSTEM,\n STATE_MENU_ADDRESS_SYSTEM,\n} from '@/constants/statesOfAddressSystem'\n\nimport { AddressSystemState } from '@/store/addressSystem/address-system.types'\n\nimport { DeliveryMethods } from '@/api/modules/basket/types'\nimport { StateGeoAddress } from '@/types/mapServices'\n\nexport const DEFAULT_STATE_ADDRESS_SYSTEM: AddressSystemState = {\n isVisibleAddressSystemDialog: false,\n stateDialog: STATE_DIALOG_ADDRESS_SYSTEM.LOADING,\n prevContentDialog: STATE_CONTENT_ADDRESS_SYSTEM.NEW,\n contentDialog: STATE_CONTENT_ADDRESS_SYSTEM.NEW,\n stateMenu: STATE_MENU_ADDRESS_SYSTEM.DEFAULT,\n selectedAddress: {\n address: null,\n coordinates: null,\n },\n isLoadingWidget: true,\n deliveryWidget: {\n delivery_method: DeliveryMethods.COURIER,\n },\n deliveryBasket: {\n delivery_method: DeliveryMethods.COURIER,\n },\n areas: [],\n points: [],\n deliveryAddress: {\n address: {\n place: null,\n address: null,\n },\n details: null,\n state: StateGeoAddress.READY,\n coordinates: [0, 0],\n },\n isLoadingAreas: false,\n}\n","export const STORAGE_ERROR = {\n get: (key: string) => `Ошибка при чтении хранилища по ключу ${key}`,\n set: (key: string) => `Ошибка при записи в хранилище по ключу ${key}`,\n remove: (key: string) => `Ошибка при удалении из хранилища по ключу ${key}`,\n}\n\nexport const STORAGE_KEY = {\n addressSystem: {\n deliveryAddress: 'address-system:delivery-address',\n deliveryWidget: 'address-system:delivery-widget',\n },\n}\n","import { STORAGE_ERROR } from '@/services/storage/constants'\n\nclass StorageService {\n get(key: string): T | null {\n try {\n const value = localStorage.getItem(key)\n\n return value ? JSON.parse(value) : null\n } catch (error) {\n console.error(STORAGE_ERROR.get(key), error)\n\n return null\n }\n }\n\n set(key: string, value: any) {\n try {\n localStorage.setItem(key, JSON.stringify(value))\n } catch (error) {\n console.error(STORAGE_ERROR.set(key), error)\n }\n }\n\n remove(key: string) {\n try {\n localStorage.removeItem(key)\n } catch (error) {\n console.error(STORAGE_ERROR.remove(key), error)\n }\n }\n}\n\nexport const storage = new StorageService()\n","// eslint-disable-next-line simple-import-sort/imports\nimport { FeatureCollection, Point, Polygon, Position } from 'geojson'\n\nimport { NewProduct, NewProductTag } from '@/types/api/api-v4/product'\nimport { Factoid } from '@/types/main'\n\nexport type OldAreaFeatureCollection = FeatureCollection<\n Polygon,\n OldAreaProperties\n>\n\nexport type PointFeatureCollection = FeatureCollection\n\nexport type LatLng = [lat: number, lng: number, alt?: number]\n\ninterface OldAreaProperties {\n description: string\n stroke: string\n id: number\n fill: string\n currency: string\n min_price: number\n free_delivery_from: number\n delivery_time: number\n cooking_time: number\n costs: Cost[]\n}\n\n/* Slug delivery */\n\nexport interface TemplatePage {\n area_delivery_time: number\n area_minimal_order: string\n title: string\n marketing_text: string\n seo_text: string\n seo_h1: string\n show_filters: boolean\n products: NewProduct[]\n tags: NewProductTag[]\n categories: TemplateCategories[]\n factoid: Factoid\n seo_title: string\n seo_description: string\n seo_keywords: string\n}\n\nexport interface TemplateCategories {\n name: string\n slug: string\n}\n\n/* Page model */\n\nexport interface DeliveryPage {\n title: string\n page_title: string | null\n howto_phone_order: string\n seo: DeliverySeo\n howto_site_order: string\n notice_text: string | null\n factoid_title: string | null\n factoid_text: string | null\n additives: Additives[]\n point_filters: PointFilter[]\n breadcrumbs: Breadcrumb[]\n coordinates: [lat: number, lng: number]\n}\n\nexport interface DeliverySeo {\n seo_description: string | undefined\n seo_title: string | undefined\n seo_keywords: string | undefined\n}\n\nexport interface Additives {\n url: string\n description: string\n title: string\n}\n\nexport interface PointFilter {\n name: string\n slug: string\n enabled: boolean\n show: boolean\n}\n\nexport interface Breadcrumb {\n text: string\n href: string\n}\n\n/* V4 Types */\n\n/* Areas model */\n\nexport interface AreasData {\n areas: AreaProperties[]\n points: PointProperties[]\n}\n\nexport interface AreaProperties {\n id: string | number | undefined\n polygon: number[][][] | Position[][]\n properties: PolygonProperties\n}\n\nexport interface PointProperties {\n address: string\n cafe: boolean\n cooking_time: number\n coordinates: LatLng\n how_to_find: string\n id: number\n is_open: boolean\n slug: string\n tags: Tag[]\n working_hours: WorkingHours[]\n distance?: number\n city_domain_prefix?: string\n allow_redirect?: boolean\n}\n\nexport interface WorkingHours {\n start: string\n end: string\n label: string\n is_working: boolean\n}\n\nexport interface ModifiedWorkingHours extends WorkingHours {\n isCurrent?: boolean\n}\n\nexport interface PolygonProperties {\n cooking_time: number\n costs: Cost[]\n delivery_time: number\n free_delivery_from: number\n min_price: number\n stroke: string\n}\n\nexport interface Cost {\n amount_from: number\n amount_to: number\n cost: number\n}\n\nexport interface Tag {\n name: string\n slug: string\n show: boolean\n}\n\nexport interface DragCoordinates {\n lower_left: LatLng\n upper_right: LatLng\n}\n\nexport const TypeAddressSystemAreas = 'address-system'\n\nexport type PayloadAddressSystemAreas =\n | typeof TypeAddressSystemAreas\n | undefined\n","import { defineStore } from 'pinia'\n\nimport { StoreId } from '@/store'\nimport { DEFAULT_STATE_ADDRESS_SYSTEM } from '@/store/addressSystem/address-system.constants'\nimport type {\n AddressSystemState,\n SelectedAddress,\n} from '@/store/addressSystem/address-system.types'\nimport { useCityStore } from '@/store/city/city'\nimport type {\n DeliveryDataAddress,\n PlacesSearch,\n} from '@/store/delivery/delivery.types'\nimport { useUserStore } from '@/store/user/user'\n\nimport { storage } from '@/services/storage'\nimport { STORAGE_KEY } from '@/services/storage/constants'\n\nimport { SetDeliveryMethodPayload } from '@/api/modules/basket/types'\nimport { TypeAddressSystemAreas } from '@/api/modules/delivery/types'\nimport { Success } from '@/api/results'\nimport type {\n StateDialogAddressSystem,\n StateDialogContent,\n StateMenuAddressSystem,\n} from '@/types/address-system'\nimport { StateGeoAddress } from '@/types/mapServices'\n\nimport type { AreasData, DragCoordinates } from '@/api/modules/delivery/types'\n\nexport const useAddressSystem = defineStore(StoreId.ADDRESS_SYSTEM, {\n state: (): AddressSystemState => DEFAULT_STATE_ADDRESS_SYSTEM,\n actions: {\n changeVisibleAddressSystemDialog(state: boolean) {\n this.$state.isVisibleAddressSystemDialog = state\n },\n changeStateDialog(state: StateDialogAddressSystem) {\n this.$state.stateDialog = state\n },\n changeContentDialog(state: StateDialogContent) {\n this.$state.prevContentDialog = this.$state.contentDialog\n this.$state.contentDialog = state\n },\n changeStateMenu(state: StateMenuAddressSystem) {\n this.$state.stateMenu = state\n },\n setSelectedAddress(selectedAddress: SelectedAddress) {\n this.$state.selectedAddress = selectedAddress\n },\n setLoadingWidget(loading: boolean) {\n this.$state.isLoadingWidget = loading\n },\n setDeliveryWidget(payload: SetDeliveryMethodPayload) {\n const { isAuthenticated } = useUserStore()\n\n this.$state.deliveryWidget = { ...payload }\n\n if (!isAuthenticated) {\n storage.set(STORAGE_KEY.addressSystem.deliveryWidget, payload)\n }\n },\n changeDeliveryBasket(payload: SetDeliveryMethodPayload) {\n this.$state.deliveryBasket = payload\n },\n setAreasData(areasData: AreasData | null) {\n if (!areasData) return\n\n this.points = areasData.points\n this.areas = areasData.areas\n },\n setDeliveryAddress(deliveryDataAddress: DeliveryDataAddress) {\n this.deliveryAddress = deliveryDataAddress\n },\n setDeliveryAddressState(state: StateGeoAddress) {\n this.deliveryAddress.state = state\n },\n resetDeliveryAddress(place: PlacesSearch | null = null) {\n this.deliveryAddress = {\n address: {\n place,\n address: null,\n },\n details: null,\n state: StateGeoAddress.READY,\n coordinates: [0, 0],\n }\n },\n async updateAreas(bounds: DragCoordinates) {\n this.changeLoadingAreas()\n\n // Получаем полигоны в области bounds карты\n await this.setAreasByCoords(bounds)\n\n this.changeLoadingAreas()\n },\n async setAreasByCoords(coords: DragCoordinates) {\n const { cityInfo } = useCityStore()\n const { $apiService } = useNuxtApp()\n\n if (!cityInfo.domain_prefix) return\n\n const result = await $apiService.delivery.fetchAreasByCoordinates(\n coords,\n {\n type: TypeAddressSystemAreas,\n domain_prefix: cityInfo.domain_prefix,\n },\n )\n\n if (!(result instanceof Success)) return\n\n this.setAreasData(result.data)\n },\n\n changeLoadingAreas() {\n this.isLoadingAreas = !this.isLoadingAreas\n },\n },\n getters: {\n // Точки ресторанов \"Самовывоз\"\n pickupPoints: ({ points }) => {\n if (points.length === 0) return points\n\n return points.filter((point) => point.pickup)\n },\n\n // Точки ресторанов \"В ресторане\"\n hallPoints: ({ points }) => {\n if (points.length === 0) return points\n\n return points.filter((point) => point.hall)\n },\n },\n})\n"],"names":["STATE_MENU_ADDRESS_SYSTEM","STATE_DIALOG_ADDRESS_SYSTEM","STATE_CONTENT_ADDRESS_SYSTEM","STATE_OF_MAP","BALLOON_TEXT","StateGeoAddress","StateGeoAddress2","TypesEntity","TypesProvider","TypeMaps","DEFAULT_STATE_ADDRESS_SYSTEM","DeliveryMethods","STORAGE_ERROR","key","STORAGE_KEY","StorageService","value","error","storage","TypeAddressSystemAreas","useAddressSystem","defineStore","StoreId","state","selectedAddress","loading","payload","isAuthenticated","useUserStore","areasData","deliveryDataAddress","place","bounds","coords","cityInfo","useCityStore","$apiService","useNuxtApp","result","Success","points","point"],"mappings":";;uaAaO,MAAMA,EACX,CACE,YAAa,cACb,SAAU,WACV,MAAO,QACP,QAAS,UACT,QAAS,UACT,aAAc,eACd,QAAS,SACX,EAKWC,EACX,CACE,QAAS,UACT,MAAO,QACP,MAAO,OACT,EAKWC,EAA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