Files
docs/node_modules/search-insights/dist/search-insights-browser.min.cjs

2 lines
16 KiB
JavaScript
Raw Permalink Normal View History

2025-08-27 14:05:33 +08:00
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var version="2.17.3";function extractAdditionalParams(e){return e.reduce(function(e,t){var n=e.events,e=e.additionalParams;return"index"in t?{additionalParams:e,events:n.concat([t])}:{events:n,additionalParams:t}},{events:[],additionalParams:void 0})}var supportsCookies=function(){try{return Boolean(navigator.cookieEnabled)}catch(e){return!1}},supportsSendBeacon=function(){try{return Boolean(navigator.sendBeacon)}catch(e){return!1}},supportsXMLHttpRequest=function(){try{return Boolean(XMLHttpRequest)}catch(e){return!1}},supportsNativeFetch=function(){try{return void 0!==fetch}catch(e){return!1}},LocalStorage=function(){};function ensureLocalStorage(){try{var e="__test_localStorage__";return globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),globalThis.localStorage}catch(e){}}LocalStorage.get=function(e){var t=null==(t=this.store)?void 0:t.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch(e){return null}},LocalStorage.set=function(t,e){var n;try{null!=(n=this.store)&&n.setItem(t,JSON.stringify(e))}catch(e){console.error("Unable to set "+t+" in localStorage, storage may be full.")}},LocalStorage.remove=function(e){var t;null!=(t=this.store)&&t.removeItem(e)},LocalStorage.store=ensureLocalStorage();var STORE="AlgoliaObjectQueryCache",LIMIT=5e3,FREE=1e3;function getCache(){var e;return null!=(e=LocalStorage.get(STORE))?e:{}}function setCache(e){LocalStorage.set(STORE,limited(e))}function limited(e){return Object.keys(e).length>LIMIT?purgeOldest(e):e}function purgeOldest(e){e=Object.entries(e).sort(function(e,t){e=e[1][1];return t[1][1]-e});return e.slice(0,e.length-FREE-1).reduce(function(e,t){var n=t[0],t=t[1];return Object.assign(Object.assign({},e),((e={})[n]=t,e))},{})}function makeKey(e,t){return e+"_"+t}function storeQueryForObject(e,t,n){var i=getCache();i[makeKey(e,t)]=[n,Date.now()],setCache(i)}function getQueryForObject(e,t){return getCache()[makeKey(e,t)]}function removeQueryForObjects(t,e){var n=getCache();e.forEach(function(e){delete n[makeKey(t,e)]}),setCache(n)}var isUndefined=function(e){return void 0===e},isNumber=function(e){return"number"==typeof e},isFunction=function(e){return"function"==typeof e},isPromise=function(e){return"function"==typeof(null==e?void 0:e.then)};function getFunctionalInterface(i){return function(e){for(var t=[],n=arguments.length-1;0<n--;)t[n]=arguments[n+1];if(e&&isFunction(i[e]))return i[e].apply(i,t);console.warn("The method `"+e+"` doesn't exist.")}}var DEFAULT_ALGOLIA_AGENTS=["insights-js ("+version+")","insights-js-browser-cjs ("+version+")"];function addAlgoliaAgent(e){-1===this._ua.indexOf(e)&&this._ua.push(e)}function getVersion(e){return isFunction(e)&&e(this.version),this.version}function __rest(e,t){var n={};for(r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function addQueryId(e){return e.map(function(i){var r,e;return!isValidEventForQueryIdLookup(i)||(r=[],e=null==(e=i.objectIDs)?void 0:e.map(function(e,t){var n=null==(n=i.objectData)?void 0:n[t];return null!=n&&n.queryID?n:((t=(null!=(t=getQueryForObject(i.index,e))?t:[])[0])&&r.push(e),Object.assign(Object.assign({},n),{queryID:t}))}),0===r.length)?i:Object.assign(Object.assign({},i),{objectData:e,objectIDsWithInferredQueryID:r})})}function isValidEventForQueryIdLookup(e){return!e.queryID&&"conversion"===e.eventType}function makeSendEvents(r){return function(e,t){var i=this;if(this._userHasOptedOut)return Promise.resolve(!1);if(!(!isUndefined(this._apiKey)&&!isUndefined(this._appId)||(null==(n=null==t?void 0:t.headers)?void 0:n["X-Algolia-Application-Id"])&&(null==(n=null==t?void 0:t.headers)?void 0:n["X-Algolia-API-Key"])))throw new Error("Before calling any methods on the analytics, you first need to call the 'init' function with appId and apiKey parameters or provide