1const p="algolia:recent-hit:";const D="Algolia_LastHitMetadata",A="Algolia_QueryID",S="Algolia_ObjectID",_="Algolia_IndexName",h="Algolia_Handle",g={log:[],info:[],warn:[],error:[]},N=(e,t)=>{if(typeof console>"u")return;let o=console.log;if(e==="info"&&typeof console.info=="function")o=console.info;else if(e==="warn"&&typeof console.warn=="function")o=console.warn;else if(e==="error"&&typeof console.error=="function")o=console.error;else if(typeof console.log!="function")return;typeof t.details<"u"?o(t.message,t.details):o(t.message)},l=(e,t,o)=>{const n=g[e]?e:"log",r={message:t,details:o};g[n].push(r)},w=(e="all")=>{(e==="all"?["log","info","warn","error"]:[e]).forEach(o=>{const n=g[o];!n||!n.length||n.forEach(r=>{N(o,r)})})};typeof window<"u"&&(window.__printAlgoliaStorageLogs=w);const L=()=>typeof window>"u"?null:window,x=()=>{var n,r,i;const e=L(),t=(n=e==null?void 0:e.algoliaShopify)==null?void 0:n.config,o=(i=(r=e==null?void 0:e.algoliaShopify)==null?void 0:r.instantsearch)==null?void 0:i.indexName;return o||(t!=null&&t.indexName?t.indexName:t!=null&&t.index_prefix?`${t.index_prefix}products`:"")},c=e=>{if(typeof window>"u")return null;try{return e==="local"?window.localStorage:window.sessionStorage}catch(t){return l("error",`Unable to access ${e}Storage`,t),null}},I=(e,t,o)=>{if(!e)return null;try{const n=JSON.parse(e);return!(n!=null&&n.timestamp)||Date.now()-n.timestamp>6e5?(t==null||t.removeItem(o),null):n}catch(n){return l("error","Failed to parse Algolia hit metadata",n),t==null||t.removeItem(o),null}},b=e=>{const t=c("session"),o=c("local"),n=I((t==null?void 0:t.getItem(e))??null,t,e);return n||I((o==null?void 0:o.getItem(e))??null,o,e)},m=(e,t)=>{const o=JSON.stringify(t),n=c("session"),r=c("local");try{n==null||n.setItem(e,o)}catch(i){l("error","Unable to write sessionStorage record",i)}try{r==null||r.setItem(e,o)}catch(i){l("error","Unable to write localStorage record",i)}},j=e=>{const t=c("local"),o=c("session");[t,o].filter(r=>!!r).forEach(r=>{try{r.setItem(A,e.queryID),r.setItem(S,e.objectID),r.setItem(_,e.indexName),r.setItem(h,e.handle)}catch(i){l("error","Unable to write Algolia global metadata",i)}})},d=e=>e?b(`${p}${e}`):null,y=e=>{if(e!=null&&e.handle)try{const t={...e,timestamp:Date.now()};m(`${p}${e.handle}`,t),m(D,t),j(t),l("log","[Algolia][Store] Stored hit metadata for conversion",{handle:e.handle,objectID:e.objectID,queryID:e.queryID,indexName:e.indexName,position:e.position??null})}catch(t){l("error","Failed to persist Algolia hit metadata",t)}},q=e=>{if(!e)return null;const t=d(e);return t!=null&&t.objectID&&(t!=null&&t.queryID)&&(t!=null&&t.indexName)?(l("log","[Algolia][Store] Retrieved hit metadata for handle",{handle:e,queryID:t.queryID,indexName:t.indexName,objectID:t.objectID,position:t.position??null}),t):null},E=()=>{const e=b(D);return e!=null&&e.objectID&&(e!=null&&e.queryID)&&(e!=null&&e.indexName)?(l("log","[Algolia][Store] Retrieved latest hit metadata",e),e):null},O=()=>{var n,r,i,s;if(typeof window>"u")return null;const e=window,t=!!(e!=null&&e.__ALGOLIA_INSIGHTS_INITIALIZED__);if(typeof(e==null?void 0:e.aa)=="function")return t?e.aa:(l("warn","[Algolia][Store] Insights script loaded but not initialized yet"),null);const o=((r=(n=e==null?void 0:e.algoliaShopify)==null?void 0:n.externals)==null?void 0:r.insightsClient)||((s=(i=e==null?void 0:e.algoliaShopify)==null?void 0:i.externals)==null?void 0:s.insights);return typeof o=="function"?o:(l("warn","[Algolia][Store] Insights client not yet available"),null)},u={queryID:["algolia_query_id","queryID","queryId","aa-query-id"],objectID:["algolia_object_id","objectID","objectId","aa-object-id"],indexName:["algolia_index_name","indexName"],position:["algolia_position","position"]},f=(e,t)=>{for(const o of t){const n=e.get(o);if(n&&n.trim()!=="")return n}return null},R=e=>{if(!e||typeof window>"u")return!1;try{const t=new URLSearchParams(window.location.search),o=f(t,u.queryID),n=f(t,u.objectID),r=f(t,u.indexName)||x(),i=f(t,u.position),s=i&&!Number.isNaN(Number(i))?Number(i):null;if(!o||!n||!r)return!1;const a=d(e);return a&&a.objectID===String(n)&&a.queryID===o?!1:(y({handle:e,objectID:String(n),queryID:o,indexName:r,position:typeof s=="number"&&Number.isFinite(s)?s:null}),!0)}catch(t){return l("error","Failed to persist Algolia metadata from URL params",t),!1}},G=e=>{var s,a;const t=e.handle;if(!t)return!1;const o=e.objectID?String(e.objectID):"",n=((s=e.indexName)==null?void 0:s.trim())??"";if(!o||!n)return!1;const r=d(t);if(r!=null&&r.queryID&&r.objectID===o)return!1;const i=((a=e.queryID)==null?void 0:a.trim())||(r==null?void 0:r.queryID)||"";return y({handle:t,objectID:o,indexName:n,queryID:i,position:typeof e.position=="number"?e.position:(r==null?void 0:r.position)??null}),!0};
1export{R as a,x as b,G as c,q as d,E as e,O as g,y as p};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.