{"version":3,"file":"static/js/493.29da64a7.chunk.js","mappings":"qNAMA,MAmEA,EAnE2BA,IAA+B,IAA9B,UAACC,EAAS,YAAEC,GAAYF,EAClD,MAAMG,GAAOC,EAAAA,EAAAA,KACPC,GAA2BC,EAAAA,EAAAA,QAAO,MAClCC,EAAYL,EAyDlB,OAvDAM,EAAAA,EAAAA,YAAU,KAER,MAAMC,EAAeC,IACnBC,aACAA,oCAIIC,GAASC,EAAAA,EAAAA,GAAa,CAC1BC,UAAWT,EAAyBU,QACpCC,YAAab,EAAKc,cAAc,CAACC,GAAI,qCACrCC,aAAa,EACbC,WAAUA,IACD,CACL,CACEC,SAAU,eACVC,kBAAmBC,IAAA,IAAC,KAACC,GAAKD,EAAA,OAAKC,EAAKC,OACpCC,SAAQC,GAAW,IAAV,MAACC,GAAMD,EACd,OAAOE,EAAAA,EAAAA,GAAkB,CACvBpB,eACAqB,QAAS,CACP,CACEvB,UAAWA,EACXwB,OAAQ,CACNH,QACAI,YAA2B,cAAd/B,EAA4B,EAAI,QAMvDgC,UAAW,CACTT,KAAIU,GAAU,IAAT,KAACV,GAAKU,EACT,OAAOV,EAAKC,UAMtBU,SAAQC,GAAW,IAAV,MAACC,GAAMD,EACd,GAAIC,EAAMT,MAAO,CAEfU,OAAOC,UAAUC,oBAAoBC,UAAUJ,EAAMT,OACrD,MAAMc,EAAiB,GAAGzC,IAAYoC,EAAMT,MAAQ,UAAUS,EAAMT,MAAMe,WAAW,IAAK,OAAS,KACnGC,OAAOC,SAASC,QAAQJ,OAM9B,MAAO,KACL9B,EAAOmC,aAER,KAGDC,EAAAA,EAAAA,KAAA,OAAKC,MAAM,+BAA8BC,UACvCF,EAAAA,EAAAA,KAAA,OAAKG,IAAK9C,Q,iECjED,SAASD,IACpB,IAAID,EAAOiD,EAAAA,WAAiBC,EAAAA,IAE5B,OADAC,EAAAA,EAAAA,IAAqBnD,GACdA","sources":["Blocks/AutocompleteSearch/index.js","../node_modules/react-intl/lib/src/components/useIntl.js"],"sourcesContent":["import {useIntl} from 'react-intl';\nimport {useEffect, useRef} from 'react';\nimport '@algolia/autocomplete-theme-classic';\nimport {autocomplete, getAlgoliaResults} from '@algolia/autocomplete-js';\nimport algoliasearch from \"algoliasearch/lite\";\n\nconst AutocompleteSearch = ({searchUrl, searchIndex}) => {\n const intl = useIntl();\n const autocompleteContainerRef = useRef(null);\n const indexName = searchIndex;\n\n useEffect(() => {\n // Initialize Algolia client\n const searchClient = algoliasearch(\n process.env.REACT_APP_ALGOLIA_APP_ID,\n process.env.REACT_APP_ALGOLIA_API_KEY\n );\n\n // Initialize Autocomplete\n const search = autocomplete({\n container: autocompleteContainerRef.current,\n placeholder: intl.formatMessage({id: 'Algolia.Autocomplete.Placeholder'}),\n openOnFocus: true,\n getSources() {\n return [\n {\n sourceId: 'destinations',\n getItemInputValue: ({item}) => item.title,\n getItems({query}) {\n return getAlgoliaResults({\n searchClient,\n queries: [\n {\n indexName: indexName,\n params: {\n query,\n hitsPerPage: searchUrl === '/programs' ? 8 : 5,\n },\n },\n ],\n });\n },\n templates: {\n item({item}) {\n return item.title;\n },\n },\n },\n ];\n },\n onSubmit({state}) {\n if (state.query) {\n // eslint-disable-next-line no-undef\n Drupal.behaviors.view_search_results.pushEvent(state.query);\n const searchQueryUrl = `${searchUrl}${state.query ? `?query=${state.query.replaceAll(' ', '_')}` : ''}`;\n window.location.replace(searchQueryUrl)\n }\n\n },\n });\n\n return () => {\n search.destroy();\n };\n }, []);\n\n return (\n <div class=\"autocomplete-search--wrapper\">\n <div ref={autocompleteContainerRef}/>\n </div>\n )\n}\n\nexport default AutocompleteSearch;\n","import * as React from 'react';\nimport { Context } from './injectIntl';\nimport { invariantIntlContext } from '../utils';\nexport default function useIntl() {\n var intl = React.useContext(Context);\n invariantIntlContext(intl);\n return intl;\n}\n"],"names":["_ref","searchUrl","searchIndex","intl","useIntl","autocompleteContainerRef","useRef","indexName","useEffect","searchClient","algoliasearch","process","search","autocomplete","container","current","placeholder","formatMessage","id","openOnFocus","getSources","sourceId","getItemInputValue","_ref2","item","title","getItems","_ref3","query","getAlgoliaResults","queries","params","hitsPerPage","templates","_ref4","onSubmit","_ref5","state","Drupal","behaviors","view_search_results","pushEvent","searchQueryUrl","replaceAll","window","location","replace","destroy","_jsx","class","children","ref","React","Context","invariantIntlContext"],"sourceRoot":""}