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,MAAO,CAAE,SAAU,YACnB,IAAK,SAAC,GAAD,OAAS,EAAoB,CAA7B,GAGV,E","file":"/npm/@sector-labs/react-geocoder-autocomplete@1.1.1-sl.4/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@sector-labs/react-geocoder-autocomplete@1.1.1-sl.4/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import React, { useEffect, useRef, MutableRefObject } from \"react\";\nimport {\n  GeocoderAutocomplete,\n  LocationType,\n  SupportedLanguage,\n  GeoPosition,\n  CountyCode,\n  ByCountryCodeOptions,\n  ByCircleOptions,\n  ByRectOptions,\n  ByProximityOptions,\n} from \"@sector-labs/geocoder-autocomplete\";\n\nexport const GeoapifyApiKey = React.createContext<string>(\"\");\n\nexport const GeoapifyContext = (props: any) => {\n  return (\n    <GeoapifyApiKey.Provider value={props.apiKey}>\n      {props.children}\n    </GeoapifyApiKey.Provider>\n  );\n};\n\nexport interface GeoapifyGeocoderAutocompleteOptions {\n  value?: string;\n  type?: LocationType;\n  lang?: SupportedLanguage;\n  limit?: number;\n  placeholder?: string;\n  filterByCountryCode?: ByCountryCodeOptions;\n  filterByCircle?: ByCircleOptions;\n  filterByRect?: ByRectOptions;\n  biasByCountryCode?: ByCountryCodeOptions;\n  biasByCircle?: ByCircleOptions;\n  biasByRect?: ByRectOptions;\n  biasByProximity?: ByProximityOptions;\n  position?: GeoPosition;\n  countryCodes?: CountyCode[];\n\n  skipIcons?: boolean;\n  skipDetails?: boolean;\n\n  placeSelect: (value: any) => {};\n  suggestionsChange: (value: any) => {};\n  onFocus: (value: any) => {};\n  onBlur: (value: any) => {};\n}\n\nexport const GeoapifyGeocoderAutocomplete = ({\n  placeholder: placeholderValue,\n  type: typeValue,\n  lang: langValue,\n  limit: limitValue,\n  value: valueValue,\n  filterByCountryCode: filterByCountryCodeValue,\n  filterByCircle: filterByCircleValue,\n  filterByRect: filterByRectValue,\n  biasByCountryCode: biasByCountryCodeValue,\n  biasByCircle: biasByCircleValue,\n  biasByRect: biasByRectValue,\n  biasByProximity: biasByProximityValue,\n  position: positionValue,\n  countryCodes: countryCodesValue,\n  skipIcons: skipIconsValue,\n  skipDetails: skipDetailsValue,\n\n  placeSelect: placeSelectCallback,\n  suggestionsChange: suggestionsChangeCallback,\n  onFocus: onFocusCallback,\n  onBlur: onBlurCallback\n}: GeoapifyGeocoderAutocompleteOptions) => {\n  const apiKey = React.useContext<string>(GeoapifyApiKey);\n  let geocoderContainer: HTMLDivElement | null;\n  let initialized: boolean = false;\n  let geocoderAutocomplete: MutableRefObject<\n    GeocoderAutocomplete | undefined\n  > = useRef<GeocoderAutocomplete>();\n  const placeSelectCallbackRef: MutableRefObject<\n    ((value: any) => {}) | undefined\n  > = useRef<(value: any) => {}>();\n  const suggestionsChangeCallbackRef: MutableRefObject<\n    ((value: any) => {}) | undefined\n  > = useRef<(value: any) => {}>();\n  const onFocusCallbackRef: MutableRefObject<\n    ((value: any) => {}) | undefined\n  > = useRef<(value: any) => {}>();\n  const onBlurCallbackRef: MutableRefObject<\n    ((value: any) => {}) | undefined\n  > = useRef<(value: any) => {}>();\n\n  placeSelectCallbackRef.current = placeSelectCallback;\n  suggestionsChangeCallbackRef.current = suggestionsChangeCallback;\n  onFocusCallbackRef.current = onFocusCallback;\n  onBlurCallbackRef.current = onBlurCallback;\n\n  const onSelect = React.useCallback((value: any) => {\n    if (placeSelectCallbackRef.current) {\n      placeSelectCallbackRef.current(value);\n    }\n  }, []);\n\n  const onSuggestions = React.useCallback((value: any) => {\n    if (suggestionsChangeCallbackRef.current) {\n      suggestionsChangeCallbackRef.current(value);\n    }\n  }, []);\n\n  const onFocus = React.useCallback((value: any) => {\n    if (onFocusCallbackRef.current) {\n      onFocusCallbackRef.current(value);\n    }\n  }, []);\n\n  const onBlur = React.useCallback((value: any) => {\n    if (onBlurCallbackRef.current) {\n      onBlurCallbackRef.current(value);\n    }\n  }, []);\n\n\n  useEffect(() => {\n    if (initialized) {\n      if (geocoderAutocomplete.current) {\n        geocoderAutocomplete.current.off('select', onSelect);\n        geocoderAutocomplete.current.off('suggestions', onSuggestions);\n        geocoderAutocomplete.current.off('focus', onFocus);\n        geocoderAutocomplete.current.off('blur', onBlur);\n      }\n\n      return;\n    }\n\n    initialized = true;\n\n    geocoderAutocomplete.current = new GeocoderAutocomplete(\n      geocoderContainer as HTMLDivElement,\n      apiKey,\n      {\n        placeholder: placeholderValue || '',\n        skipDetails: skipDetailsValue,\n        skipIcons: skipIconsValue\n      }\n    );\n\n    geocoderAutocomplete.current.on('select', onSelect);\n    geocoderAutocomplete.current.on('suggestions', onSuggestions);\n    geocoderAutocomplete.current.on('focus', onFocus);\n    geocoderAutocomplete.current.on('blur', onBlur);\n  }, []);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.setType(typeValue as LocationType);\n    }\n  }, [typeValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.setLang(langValue as SupportedLanguage);\n    }\n  }, [langValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      console.warn(\n        \"WARNING! Obsolete function called. The  'position' input has been deprecated, please use the new 'biasByLocation' input instead!\"\n      );\n      geocoderAutocomplete.current.addBiasByProximity(\n        positionValue as GeoPosition\n      );\n    }\n  }, [positionValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      console.warn(\n        \"WARNING! Obsolete function called. The  'countryCodes' input has been deprecated, please use the new 'filterByCountryCode' input instead!\"\n      );\n      geocoderAutocomplete.current.addFilterByCountry(\n        countryCodesValue as CountyCode[]\n      );\n    }\n  }, [countryCodesValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.setLimit(limitValue as number);\n    }\n  }, [limitValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.setValue((valueValue as string) || '');\n    }\n  }, [valueValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addFilterByCountry(\n        filterByCountryCodeValue as ByCountryCodeOptions\n      );\n    }\n  }, [filterByCountryCodeValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addFilterByCircle(\n        filterByCircleValue as ByCircleOptions\n      );\n    }\n  }, [filterByCircleValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addFilterByRect(\n        filterByRectValue as ByRectOptions\n      );\n    }\n  }, [filterByRectValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addBiasByCountry(\n        biasByCountryCodeValue as ByCountryCodeOptions\n      );\n    }\n  }, [biasByCountryCodeValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addBiasByCircle(\n        biasByCircleValue as ByCircleOptions\n      );\n    }\n  }, [biasByCircleValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addBiasByRect(\n        biasByRectValue as ByRectOptions\n      );\n    }\n  }, [biasByRectValue]);\n\n  useEffect(() => {\n    if (geocoderAutocomplete.current) {\n      geocoderAutocomplete.current.addBiasByProximity(\n        biasByProximityValue as ByProximityOptions\n      );\n    }\n  }, [biasByProximityValue]);\n\n  return (\n    <div\n      className='geocoder-container'\n      style={{ position: 'relative' }}\n      ref={(el) => (geocoderContainer = el)}\n    ></div>\n  );\n};\n"]}