{"version":3,"file":"index.production.js","sources":["../../../autocomplete-shared/dist/esm/debounce.js","../../../autocomplete-shared/dist/esm/isEqual.js","../../../autocomplete-shared/dist/esm/noop.js","../../src/createClickedEvent.ts","../../src/createSearchInsightsApi.ts","../../src/isModernInsightsClient.ts","../../src/createViewedEvents.ts","../../src/isAlgoliaInsightsHit.ts","../../src/createAlgoliaInsightsPlugin.ts","../../../autocomplete-shared/dist/esm/safelyRunOnBrowser.js","../../../autocomplete-shared/dist/esm/createRef.js"],"sourcesContent":["export function debounce(fn, time) {\n var timerId = undefined;\n return function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n if (timerId) {\n clearTimeout(timerId);\n }\n timerId = setTimeout(function () {\n return fn.apply(void 0, args);\n }, time);\n };\n}","function isPrimitive(obj) {\n return obj !== Object(obj);\n}\nexport function isEqual(first, second) {\n if (first === second) {\n return true;\n }\n if (isPrimitive(first) || isPrimitive(second) || typeof first === 'function' || typeof second === 'function') {\n return first === second;\n }\n if (Object.keys(first).length !== Object.keys(second).length) {\n return false;\n }\n for (var _i = 0, _Object$keys = Object.keys(first); _i < _Object$keys.length; _i++) {\n var key = _Object$keys[_i];\n if (!(key in second)) {\n return false;\n }\n if (!isEqual(first[key], second[key])) {\n return false;\n }\n }\n return true;\n}","export var noop = function noop() {};","import type {\n AlgoliaInsightsHit,\n ClickedObjectIDsAfterSearchParams,\n InsightsParamsWithItems,\n} from './types';\n\ntype CreateClickedEventParams = {\n item: AlgoliaInsightsHit;\n items: AlgoliaInsightsHit[];\n};\n\nexport function createClickedEvent({\n item,\n items,\n}: CreateClickedEventParams): Omit<\n InsightsParamsWithItems,\n 'eventName'\n> & { algoliaSource?: string[] } {\n return {\n index: item.__autocomplete_indexName,\n items: [item],\n positions: [1 + items.findIndex((x) => x.objectID === item.objectID)],\n queryID: item.__autocomplete_queryID,\n algoliaSource: ['autocomplete'],\n };\n}\n","import type { InsightsMethodMap } from 'search-insights';\n\nimport { isModernInsightsClient } from './isModernInsightsClient';\nimport {\n AlgoliaInsightsHit,\n ClickedFiltersParams,\n ClickedObjectIDsAfterSearchParams,\n ClickedObjectIDsParams,\n ConvertedFiltersParams,\n ConvertedObjectIDsAfterSearchParams,\n ConvertedObjectIDsParams,\n InsightsClient,\n InsightsClientMethod,\n InsightsParamsWithItems,\n ViewedFiltersParams,\n ViewedObjectIDsParams,\n} from './types';\n\nfunction chunk(\n item: TItem,\n chunkSize: number = 20\n): TItem[] {\n const chunks: TItem[] = [];\n for (let i = 0; i < item.objectIDs.length; i += chunkSize) {\n chunks.push({\n ...item,\n objectIDs: item.objectIDs.slice(i, i + chunkSize),\n });\n }\n return chunks;\n}\n\nfunction mapToInsightsParamsApi<\n TInsightsParamsType extends {\n items: AlgoliaInsightsHit[];\n objectIDs?: string[];\n }\n>(params: TInsightsParamsType[]) {\n return params.map(({ items, ...param }) => ({\n ...param,\n objectIDs: items?.map(({ objectID }) => objectID) || param.objectIDs,\n }));\n}\n\nexport function createSearchInsightsApi(searchInsights: InsightsClient) {\n const canSendHeaders = isModernInsightsClient(searchInsights);\n\n function sendToInsights(\n method: InsightsClientMethod,\n payloads: InsightsMethodMap[TInsightsMethod],\n items?: AlgoliaInsightsHit[]\n ) {\n if (canSendHeaders && typeof items !== 'undefined') {\n const { appId, apiKey } = items[0].__autocomplete_algoliaCredentials;\n const headers = {\n 'X-Algolia-Application-Id': appId,\n 'X-Algolia-API-Key': apiKey,\n };\n\n searchInsights(method, ...payloads, { headers });\n } else {\n searchInsights(method, ...payloads);\n }\n }\n\n return {\n /**\n * Initializes Insights with Algolia credentials.\n */\n init(appId: string, apiKey: string) {\n searchInsights('init', { appId, apiKey });\n },\n /**\n * Sets the user token to attach to events.\n */\n setUserToken(userToken: string) {\n searchInsights('setUserToken', userToken);\n },\n /**\n * Sends click events to capture a query and its clicked items and positions.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids-after-search/\n */\n clickedObjectIDsAfterSearch(\n ...params: Array<\n InsightsParamsWithItems\n >\n ) {\n if (params.length > 0) {\n sendToInsights(\n 'clickedObjectIDsAfterSearch',\n mapToInsightsParamsApi(params),\n params[0].items\n );\n }\n },\n /**\n * Sends click events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-object-ids/\n */\n clickedObjectIDs(\n ...params: Array>\n ) {\n if (params.length > 0) {\n sendToInsights(\n 'clickedObjectIDs',\n mapToInsightsParamsApi(params),\n params[0].items\n );\n }\n },\n /**\n * Sends click events to capture the filters a user clicks on.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/clicked-filters/\n */\n clickedFilters(...params: ClickedFiltersParams[]) {\n if (params.length > 0) {\n searchInsights('clickedFilters', ...params);\n }\n },\n /**\n * Sends conversion events to capture a query and its clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids-after-search/\n */\n convertedObjectIDsAfterSearch(\n ...params: Array<\n InsightsParamsWithItems\n >\n ) {\n if (params.length > 0) {\n sendToInsights(\n 'convertedObjectIDsAfterSearch',\n mapToInsightsParamsApi(params),\n params[0].items\n );\n }\n },\n /**\n * Sends conversion events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-object-ids/\n */\n convertedObjectIDs(\n ...params: Array>\n ) {\n if (params.length > 0) {\n sendToInsights(\n 'convertedObjectIDs',\n mapToInsightsParamsApi(params),\n params[0].items\n );\n }\n },\n /**\n * Sends conversion events to capture the filters a user uses when converting.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/converted-filters/\n */\n convertedFilters(...params: ConvertedFiltersParams[]) {\n if (params.length > 0) {\n searchInsights('convertedFilters', ...params);\n }\n },\n /**\n * Sends view events to capture clicked items.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/viewed-object-ids/\n */\n viewedObjectIDs(\n ...params: Array>\n ) {\n if (params.length > 0) {\n params\n .reduce<\n Array<{\n items?: AlgoliaInsightsHit[];\n payload: ViewedObjectIDsParams;\n }>\n >(\n (acc, { items, ...param }) => [\n ...acc,\n ...chunk({\n ...param,\n objectIDs:\n items?.map(({ objectID }) => objectID) || param.objectIDs,\n }).map((payload) => {\n return { items, payload };\n }),\n ],\n []\n )\n .forEach(({ items, payload }) =>\n sendToInsights('viewedObjectIDs', [payload], items)\n );\n }\n },\n /**\n * Sends view events to capture the filters a user uses when viewing.\n *\n * @link https://www.algolia.com/doc/api-reference/api-methods/viewed-filters/\n */\n viewedFilters(...params: ViewedFiltersParams[]) {\n if (params.length > 0) {\n searchInsights('viewedFilters', ...params);\n }\n },\n };\n}\n","import type { InsightsClient } from './types';\n\n/**\n * Determines if a given insights `client` supports the optional call to `init`\n * and the ability to set credentials via extra parameters when sending events.\n */\nexport function isModernInsightsClient(client: InsightsClient): boolean {\n const [major, minor] = (client.version || '').split('.').map(Number);\n\n /* eslint-disable @typescript-eslint/camelcase */\n const v3 = major >= 3;\n const v2_4 = major === 2 && minor >= 4;\n const v1_10 = major === 1 && minor >= 10;\n\n return v3 || v2_4 || v1_10;\n /* eslint-enable @typescript-eslint/camelcase */\n}\n","import {\n AlgoliaInsightsHit,\n InsightsParamsWithItems,\n ViewedObjectIDsParams,\n} from './types';\n\ntype CreateViewedEventsParams = {\n items: AlgoliaInsightsHit[];\n};\n\nexport function createViewedEvents({\n items,\n}: CreateViewedEventsParams): Array<\n Omit, 'eventName'>\n> {\n const itemsByIndexName = items.reduce>(\n (acc, current) => {\n acc[current.__autocomplete_indexName] = (\n acc[current.__autocomplete_indexName] ?? []\n ).concat(current);\n\n return acc;\n },\n {}\n );\n\n return Object.keys(itemsByIndexName).map((indexName) => {\n const items = itemsByIndexName[indexName];\n\n return {\n index: indexName,\n items,\n algoliaSource: ['autocomplete'],\n };\n });\n}\n","import { AlgoliaInsightsHit } from './types';\n\nexport function isAlgoliaInsightsHit(hit: any): hit is AlgoliaInsightsHit {\n return (\n hit.objectID && hit.__autocomplete_indexName && hit.__autocomplete_queryID\n );\n}\n","import {\n AutocompleteState,\n AutocompletePlugin,\n createRef,\n debounce,\n isEqual,\n noop,\n safelyRunOnBrowser,\n} from '@algolia/autocomplete-shared';\n\nimport { createClickedEvent } from './createClickedEvent';\nimport { createSearchInsightsApi } from './createSearchInsightsApi';\nimport { createViewedEvents } from './createViewedEvents';\nimport { isAlgoliaInsightsHit } from './isAlgoliaInsightsHit';\nimport {\n AlgoliaInsightsHit,\n AutocompleteInsightsApi,\n InsightsClient,\n OnActiveParams,\n OnItemsChangeParams,\n OnSelectParams,\n} from './types';\n\nconst VIEW_EVENT_DELAY = 400;\nconst ALGOLIA_INSIGHTS_VERSION = '2.6.0';\nconst ALGOLIA_INSIGHTS_SRC = `https://cdn.jsdelivr.net/npm/search-insights@${ALGOLIA_INSIGHTS_VERSION}/dist/search-insights.min.js`;\n\ntype SendViewedObjectIDsParams = {\n onItemsChange(params: OnItemsChangeParams): void;\n items: AlgoliaInsightsHit[];\n insights: AutocompleteInsightsApi;\n state: AutocompleteState;\n};\n\nconst sendViewedObjectIDs = debounce(\n ({ onItemsChange, items, insights, state }) => {\n onItemsChange({\n insights,\n insightsEvents: createViewedEvents({ items }).map((event) => ({\n eventName: 'Items Viewed',\n ...event,\n })),\n state,\n });\n },\n VIEW_EVENT_DELAY\n);\n\nexport type CreateAlgoliaInsightsPluginParams = {\n /**\n * The initialized Search Insights client.\n *\n * @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-plugin-algolia-insights/createAlgoliaInsightsPlugin/#param-insightsclient\n */\n insightsClient?: InsightsClient;\n /**\n * Hook to send an Insights event when the items change.\n *\n * By default, it sends a `viewedObjectIDs` event.\n *\n * In as-you-type experiences, items change as the user types. This hook is debounced every 400ms to reflect actual items that users notice and avoid generating too many events for items matching \"in progress\" queries.\n *\n * @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-plugin-algolia-insights/createAlgoliaInsightsPlugin/#param-onitemschange\n */\n onItemsChange?(params: OnItemsChangeParams): void;\n /**\n * Hook to send an Insights event when an item is selected.\n *\n * By default, it sends a clickedObjectIDsAfterSearch event.\n *\n * @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-plugin-algolia-insights/createAlgoliaInsightsPlugin/#param-onselect\n */\n onSelect?(params: OnSelectParams): void;\n /**\n * Hook to send an Insights event when an item is active.\n *\n * By default, it doesn't send any events.\n *\n * @link https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-plugin-algolia-insights/createAlgoliaInsightsPlugin/#param-onactive\n */\n onActive?(params: OnActiveParams): void;\n};\n\nexport function createAlgoliaInsightsPlugin(\n options: CreateAlgoliaInsightsPluginParams\n): AutocompletePlugin {\n const {\n insightsClient: providedInsightsClient,\n onItemsChange,\n onSelect: onSelectEvent,\n onActive: onActiveEvent,\n } = getOptions(options);\n let insightsClient = providedInsightsClient as InsightsClient;\n\n if (!providedInsightsClient) {\n safelyRunOnBrowser(({ window }) => {\n const pointer = window.AlgoliaAnalyticsObject || 'aa';\n\n if (typeof pointer === 'string') {\n insightsClient = window[pointer];\n }\n\n if (!insightsClient) {\n window.AlgoliaAnalyticsObject = pointer;\n\n if (!window[pointer]) {\n window[pointer] = (...args: any[]) => {\n if (!window[pointer].queue) {\n window[pointer].queue = [];\n }\n\n window[pointer].queue.push(args);\n };\n }\n\n window[pointer].version = ALGOLIA_INSIGHTS_VERSION;\n\n insightsClient = window[pointer];\n\n loadInsights(window);\n }\n });\n }\n\n const insights = createSearchInsightsApi(insightsClient);\n const previousItems = createRef([]);\n\n const debouncedOnStateChange = debounce<{\n state: AutocompleteState;\n }>(({ state }) => {\n if (!state.isOpen) {\n return;\n }\n\n const items = state.collections\n .reduce((acc, current) => {\n return [...acc, ...current.items];\n }, [])\n .filter(isAlgoliaInsightsHit);\n\n if (\n !isEqual(\n previousItems.current.map((x) => x.objectID),\n items.map((x) => x.objectID)\n )\n ) {\n previousItems.current = items;\n\n if (items.length > 0) {\n sendViewedObjectIDs({ onItemsChange, items, insights, state });\n }\n }\n }, 0);\n\n return {\n name: 'aa.algoliaInsightsPlugin',\n subscribe({ setContext, onSelect, onActive }) {\n insightsClient('addAlgoliaAgent', 'insights-plugin');\n\n setContext({\n algoliaInsightsPlugin: {\n __algoliaSearchParameters: {\n clickAnalytics: true,\n },\n insights,\n },\n });\n\n onSelect(({ item, state, event }) => {\n if (!isAlgoliaInsightsHit(item)) {\n return;\n }\n\n onSelectEvent({\n state: state as AutocompleteState,\n event,\n insights,\n item,\n insightsEvents: [\n {\n eventName: 'Item Selected',\n ...createClickedEvent({ item, items: previousItems.current }),\n },\n ],\n });\n });\n\n onActive(({ item, state, event }) => {\n if (!isAlgoliaInsightsHit(item)) {\n return;\n }\n\n onActiveEvent({\n state: state as AutocompleteState,\n event,\n insights,\n item,\n insightsEvents: [\n {\n eventName: 'Item Active',\n ...createClickedEvent({ item, items: previousItems.current }),\n },\n ],\n });\n });\n },\n onStateChange({ state }) {\n debouncedOnStateChange({ state: state as AutocompleteState });\n },\n __autocomplete_pluginOptions: options,\n };\n}\n\nfunction getOptions(options: CreateAlgoliaInsightsPluginParams) {\n return {\n onItemsChange({ insights, insightsEvents }: OnItemsChangeParams) {\n insights.viewedObjectIDs(\n ...insightsEvents.map((event) => ({\n ...event,\n algoliaSource: [\n ...(event.algoliaSource || []),\n 'autocomplete-internal',\n ],\n }))\n );\n },\n onSelect({ insights, insightsEvents }: OnSelectParams) {\n insights.clickedObjectIDsAfterSearch(\n ...insightsEvents.map((event) => ({\n ...event,\n algoliaSource: [\n ...(event.algoliaSource || []),\n 'autocomplete-internal',\n ],\n }))\n );\n },\n onActive: noop,\n ...options,\n };\n}\n\nfunction loadInsights(environment: typeof window) {\n const errorMessage = `[Autocomplete]: Could not load search-insights.js. Please load it manually following https://alg.li/insights-autocomplete`;\n\n try {\n const script = environment.document.createElement('script');\n script.async = true;\n script.src = ALGOLIA_INSIGHTS_SRC;\n\n script.onerror = () => {\n // eslint-disable-next-line no-console\n console.error(errorMessage);\n };\n\n document.body.appendChild(script);\n } catch (cause) {\n // eslint-disable-next-line no-console\n console.error(errorMessage);\n }\n}\n","/**\n * Safely runs code meant for browser environments only.\n */\nexport function safelyRunOnBrowser(callback) {\n if (typeof window !== 'undefined') {\n return callback({\n window: window\n });\n }\n return undefined;\n}","export function createRef(initialValue) {\n return {\n current: initialValue\n };\n}"],"names":["debounce","fn","time","timerId","undefined","_len","arguments","length","args","Array","_key","clearTimeout","setTimeout","apply","isPrimitive","obj","Object","isEqual","first","second","keys","_i","_Object$keys","key","noop","createClickedEvent","_ref","item","items","index","__autocomplete_indexName","positions","findIndex","x","objectID","queryID","__autocomplete_queryID","algoliaSource","chunk","chunkSize","chunks","i","objectIDs","push","_objectSpread","slice","mapToInsightsParamsApi","params","map","param","_objectWithoutProperties","_excluded","_ref2","createSearchInsightsApi","searchInsights","_split$map2","major","minor","canSendHeaders","_slicedToArray","version","split","Number","sendToInsights","method","payloads","_items$0$__autocomple","__autocomplete_algoliaCredentials","headers","appId","apiKey","concat","_toConsumableArray","init","setUserToken","userToken","clickedObjectIDsAfterSearch","clickedObjectIDs","_len2","_key2","clickedFilters","_len3","_key3","convertedObjectIDsAfterSearch","_len4","_key4","convertedObjectIDs","_len5","_key5","convertedFilters","_len6","_key6","viewedObjectIDs","_len7","_key7","reduce","acc","_ref3","_excluded2","_ref4","payload","forEach","_ref5","viewedFilters","_len8","_key8","createViewedEvents","itemsByIndexName","current","_acc$current$__autoco","indexName","isAlgoliaInsightsHit","hit","ALGOLIA_INSIGHTS_VERSION","ALGOLIA_INSIGHTS_SRC","sendViewedObjectIDs","onItemsChange","insights","state","insightsEvents","event","eventName","options","_getOptions","_ref8","onSelect","_ref9","onActive","getOptions","providedInsightsClient","insightsClient","onSelectEvent","onActiveEvent","callback","window","safelyRunOnBrowser","pointer","AlgoliaAnalyticsObject","queue","environment","errorMessage","script","document","createElement","async","src","onerror","console","error","body","appendChild","cause","loadInsights","previousItems","debouncedOnStateChange","isOpen","collections","filter","name","subscribe","setContext","algoliaInsightsPlugin","__algoliaSearchParameters","clickAnalytics","_ref6","onStateChange","_ref7","__autocomplete_pluginOptions"],"mappings":";mhGAAO,SAASA,EAASC,EAAIC,GAC3B,IAAIC,OAAUC,EACd,OAAO,WACL,IAAK,IAAIC,EAAOC,UAAUC,OAAQC,EAAO,IAAIC,MAAMJ,GAAOK,EAAO,EAAGA,EAAOL,EAAMK,IAC/EF,EAAKE,GAAQJ,UAAUI,GAErBP,GACFQ,aAAaR,GAEfA,EAAUS,YAAW,WACnB,OAAOX,EAAGY,WAAM,EAAQL,KACvBN,ICXP,SAASY,EAAYC,GACnB,OAAOA,IAAQC,OAAOD,GAEjB,SAASE,EAAQC,EAAOC,GAC7B,GAAID,IAAUC,EACZ,OAAO,EAET,GAAIL,EAAYI,IAAUJ,EAAYK,IAA4B,mBAAVD,GAA0C,mBAAXC,EACrF,OAAOD,IAAUC,EAEnB,GAAIH,OAAOI,KAAKF,GAAOX,SAAWS,OAAOI,KAAKD,GAAQZ,OACpD,OAAO,EAET,IAAK,IAAIc,EAAK,EAAGC,EAAeN,OAAOI,KAAKF,GAAQG,EAAKC,EAAaf,OAAQc,IAAM,CAClF,IAAIE,EAAMD,EAAaD,GACvB,KAAME,KAAOJ,GACX,OAAO,EAET,IAAKF,EAAQC,EAAMK,GAAMJ,EAAOI,IAC9B,OAAO,EAGX,OAAO,ECtBF,IAAIC,EAAO,aCWX,SAASC,EAAkBC,GAMD,IAL/BC,EAAID,EAAJC,KACAC,EAAKF,EAALE,MAKA,MAAO,CACLC,MAAOF,EAAKG,yBACZF,MAAO,CAACD,GACRI,UAAW,CAAC,EAAIH,EAAMI,WAAU,SAACC,GAAC,OAAKA,EAAEC,WAAaP,EAAKO,aAC3DC,QAASR,EAAKS,uBACdC,cAAe,CAAC,6CCLpB,SAASC,EACPX,GAIA,IAFS,IADTY,EAAiBjC,UAAAC,OAAA,QAAAH,IAAAE,UAAA,GAAAA,UAAA,GAAG,GAEdkC,EAAkB,GACfC,EAAI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