@nosto/search-js 3.24.1 → 3.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/{AutocompletePageProvider-CJb7OEAr.js → AutocompletePageProvider-BP5rBIA9.js} +3 -3
  2. package/dist/{AutocompletePageProvider-CFcim_G9.cjs → AutocompletePageProvider-DCKnj8pR.cjs} +1 -1
  3. package/dist/{CategoryPageProvider-BGqhQtdT.js → CategoryPageProvider-AVXodPE4.js} +2 -2
  4. package/dist/{CategoryPageProvider-C2nqTdZ8.cjs → CategoryPageProvider-BKJBzstK.cjs} +1 -1
  5. package/dist/{ErrorBoundary-DTRm_60r.js → ErrorBoundary-BgL4oJs4.js} +1 -1
  6. package/dist/ErrorBoundary-BuK47tWy.cjs +1 -0
  7. package/dist/InfiniteScrollWithObserver-CxHK-Vzv.cjs +1 -0
  8. package/dist/{InfiniteScrollWithObserver-aOddKvLF.js → InfiniteScrollWithObserver-D0hbwNoK.js} +2 -2
  9. package/dist/{SerpPageProvider-D5cD0ttm.cjs → SerpPageProvider-BkFNjOHz.cjs} +1 -1
  10. package/dist/{SerpPageProvider-wkZs_QWn.js → SerpPageProvider-DotM1MdN.js} +2 -2
  11. package/dist/baseConfig-Bw9xRShf.cjs +1 -0
  12. package/dist/{baseConfig-BU6c9mCI.js → baseConfig-CE2qzlEt.js} +2 -2
  13. package/dist/core/core.cjs.js +1 -1
  14. package/dist/core/core.es.js +1 -1
  15. package/dist/preact/autocomplete/autocomplete.cjs.js +1 -1
  16. package/dist/preact/autocomplete/autocomplete.es.js +1 -1
  17. package/dist/preact/category/category.cjs.js +1 -1
  18. package/dist/preact/category/category.es.js +1 -1
  19. package/dist/preact/common/common.cjs.js +1 -1
  20. package/dist/preact/common/common.es.js +4 -4
  21. package/dist/preact/hooks/hooks.cjs.js +1 -1
  22. package/dist/preact/hooks/hooks.es.js +5 -5
  23. package/dist/preact/inject/inject.cjs.js +1 -1
  24. package/dist/preact/inject/inject.es.js +9 -10
  25. package/dist/preact/legacy/legacy.cjs.js +1 -1
  26. package/dist/preact/legacy/legacy.es.js +3 -3
  27. package/dist/preact/serp/serp.cjs.js +1 -1
  28. package/dist/preact/serp/serp.es.js +2 -2
  29. package/dist/search-BXRj3vpd.cjs +1 -0
  30. package/dist/search-CUKuaCNR.js +156 -0
  31. package/dist/storage-BQdl3oEs.cjs +1 -0
  32. package/dist/storage-KGxdBTgd.js +119 -0
  33. package/dist/unique-Dm62pFFG.cjs +1 -0
  34. package/dist/{unique-Cv2g464w.js → unique-GK46uURP.js} +1 -1
  35. package/dist/{useActions-DoZCMPfW.js → useActions-B50noHCX.js} +3 -3
  36. package/dist/useActions-CG4NaniG.cjs +1 -0
  37. package/dist/useHistory-D6Q9vxsY.cjs +1 -0
  38. package/dist/{useHistory-BJo9WE5S.js → useHistory-DY4IMiA8.js} +2 -2
  39. package/dist/{useLoadMore-DfdmCB8L.cjs → useLoadMore-EOcCFqU8.cjs} +1 -1
  40. package/dist/{useLoadMore-DQb45K2a.js → useLoadMore-QY3ve8Xg.js} +1 -1
  41. package/dist/utils/src/createInMemoryStorage.d.ts +5 -0
  42. package/dist/utils/utils.cjs.js +1 -1
  43. package/dist/utils/utils.d.ts +1 -0
  44. package/dist/utils/utils.es.js +26 -20
  45. package/package.json +14 -10
  46. package/dist/ErrorBoundary-CKn3Ecpu.cjs +0 -1
  47. package/dist/InfiniteScrollWithObserver-3Mj6PB5H.cjs +0 -1
  48. package/dist/baseConfig-DDoRk8Lk.cjs +0 -1
  49. package/dist/logger-Boh_C6Bz.cjs +0 -1
  50. package/dist/logger-_fg_Za9y.js +0 -42
  51. package/dist/search-DItu5YCc.cjs +0 -1
  52. package/dist/search-xLgL6P5R.js +0 -187
  53. package/dist/unique-BXXNictB.cjs +0 -1
  54. package/dist/useActions-B6FFW8xI.cjs +0 -1
  55. package/dist/useHistory-D_TgfzXK.cjs +0 -1
@@ -1,7 +1,7 @@
1
1
  import { u as o } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { c as i, S as n, C as s } from "./useActions-DoZCMPfW.js";
3
- import { d as u, u as m, S as c } from "./baseConfig-BU6c9mCI.js";
4
- import { g as f } from "./useHistory-BJo9WE5S.js";
2
+ import { c as i, S as n, C as s } from "./useActions-B50noHCX.js";
3
+ import { d as u, u as m, S as c } from "./baseConfig-CE2qzlEt.js";
4
+ import { g as f } from "./useHistory-DY4IMiA8.js";
5
5
  import { useEffect as l } from "preact/hooks";
6
6
  const p = {
7
7
  ...u,
@@ -1 +1 @@
1
- "use strict";const o=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-B6FFW8xI.cjs"),u=require("./baseConfig-DDoRk8Lk.cjs"),s=require("./useHistory-D_TgfzXK.cjs"),a=require("preact/hooks"),l={...u.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function n(e={}){return{pageType:"autocomplete",...l,...e}}function m({config:e,store:i,children:c}){const t=i??r.createStore();return u.useCheckClientScript(),a.useEffect(()=>{t.updateState({historyItems:s.getSavedHistory()})},[t]),o.u(r.ConfigContext,{value:n(e),children:o.u(r.StoreContext,{value:t,children:[o.u(u.StoreActionsListener,{}),c]})})}exports.AutocompletePageProvider=m;exports.makeAutocompleteConfig=n;
1
+ "use strict";const o=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-CG4NaniG.cjs"),u=require("./baseConfig-Bw9xRShf.cjs"),s=require("./useHistory-D6Q9vxsY.cjs"),a=require("preact/hooks"),l={...u.defaultBaseConfig,memoryCache:!1,historyEnabled:!0,historySize:5,debounceDelay:500,minQueryLength:2};function n(e={}){return{pageType:"autocomplete",...l,...e}}function m({config:e,store:i,children:c}){const t=i??r.createStore();return u.useCheckClientScript(),a.useEffect(()=>{t.updateState({historyItems:s.getSavedHistory()})},[t]),o.u(r.ConfigContext,{value:n(e),children:o.u(r.StoreContext,{value:t,children:[o.u(u.StoreActionsListener,{}),c]})})}exports.AutocompletePageProvider=m;exports.makeAutocompleteConfig=n;
@@ -1,6 +1,6 @@
1
1
  import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { c as n, S as s, C as i } from "./useActions-DoZCMPfW.js";
3
- import { d as c, u as C, S as f } from "./baseConfig-BU6c9mCI.js";
2
+ import { c as n, S as s, C as i } from "./useActions-B50noHCX.js";
3
+ import { d as c, u as C, S as f } from "./baseConfig-CE2qzlEt.js";
4
4
  const l = {
5
5
  ...c,
6
6
  persistentSearchCache: !1,
@@ -1 +1 @@
1
- "use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-B6FFW8xI.cjs"),o=require("./baseConfig-DDoRk8Lk.cjs"),s={...o.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function n(e){return{pageType:"category",...s,...e}}function u({config:e,store:a,children:i}){const c=a??r.createStore();return o.useCheckClientScript(),t.u(r.ConfigContext,{value:n(e),children:t.u(r.StoreContext,{value:c,children:[t.u(o.StoreActionsListener,{}),i]})})}exports.CategoryPageProvider=u;exports.makeCategoryConfig=n;
1
+ "use strict";const t=require("./jsxRuntime.module-B3sGoTIU.cjs"),r=require("./useActions-CG4NaniG.cjs"),o=require("./baseConfig-Bw9xRShf.cjs"),s={...o.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function n(e){return{pageType:"category",...s,...e}}function u({config:e,store:a,children:i}){const c=a??r.createStore();return o.useCheckClientScript(),t.u(r.ConfigContext,{value:n(e),children:t.u(r.StoreContext,{value:c,children:[t.u(o.StoreActionsListener,{}),i]})})}exports.CategoryPageProvider=u;exports.makeCategoryConfig=n;
@@ -1,5 +1,5 @@
1
1
  import { u as t } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { l as m } from "./logger-_fg_Za9y.js";
2
+ import { l as m } from "./storage-KGxdBTgd.js";
3
3
  import { Fragment as n } from "preact";
4
4
  import { useErrorBoundary as u } from "preact/hooks";
5
5
  function p({ children: o }) {
@@ -0,0 +1 @@
1
+ "use strict";const e=require("./jsxRuntime.module-B3sGoTIU.cjs"),u=require("./storage-BQdl3oEs.cjs"),n=require("preact"),t=require("preact/hooks");function s({children:o}){const[r]=t.useErrorBoundary();return r&&u.logger.error("Error caught in ErrorBoundary",r),e.u(n.Fragment,{children:o})}exports.ErrorBoundary=s;
@@ -0,0 +1 @@
1
+ "use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-EOcCFqU8.cjs"),N=require("./storage-BQdl3oEs.cjs"),x=require("./pick-rYi1lc2m.cjs"),u=require("preact"),h=require("preact/hooks");function E(e,r){const t=r.products?.total??0,o=e.products?.from??0,n=e.products?.size??0;return t>0&&t>o+n}function A(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function M(e,r){for(var t in r)e[t]=r[t];return e}function f(e,r){for(var t in e)if(t!=="__source"&&!(t in r))return!0;for(var o in r)if(o!=="__source"&&e[o]!==r[o])return!0;return!1}function m(e,r){this.props=e,this.context=r}function U(e,r){function t(n){var s=this.props.ref,i=s==n.ref;return!i&&s&&(s.call?s(null):s.current=null),r?!r(this.props,n)||!i:f(this.props,n)}function o(n){return this.shouldComponentUpdate=t,u.createElement(e,n)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o}(m.prototype=new u.Component).isPureReactComponent=!0,m.prototype.shouldComponentUpdate=function(e,r){return f(this.props,e)||f(this.state,r)};var y=u.options.__b;u.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),y&&y(e)};var q=u.options.__e;u.options.__e=function(e,r,t,o){if(e.then){for(var n,s=r;s=s.__;)if((n=s.__c)&&n.__c)return r.__e==null&&(r.__e=t.__e,r.__k=t.__k),n.__c(e,r)}q(e,r,t,o)};var b=u.options.unmount;function P(e,r,t){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=M({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return P(o,r,t)})),e}function R(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return R(o,r,t)}),e.__c&&e.__c.__P===r&&(e.__e&&t.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=t)),e}function p(){this.__u=0,this.o=null,this.__b=null}function S(e){var r=e.__.__c;return r&&r.__a&&r.__a(e)}function c(){this.i=null,this.l=null}u.options.unmount=function(e){var r=e.__c;r&&r.__R&&r.__R(),r&&32&e.__u&&(e.type=null),b&&b(e)},(p.prototype=new u.Component).__c=function(e,r){var t=r.__c,o=this;o.o==null&&(o.o=[]),o.o.push(t);var n=S(o.__v),s=!1,i=function(){s||(s=!0,t.__R=null,n?n(_):_())};t.__R=i;var _=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=R(l,l.__c.__P,l.__c.__O)}var a;for(o.setState({__a:o.__b=null});a=o.o.pop();)a.forceUpdate()}};o.__u++||32&r.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},p.prototype.componentWillUnmount=function(){this.o=[]},p.prototype.render=function(e,r){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=P(this.__b,t,o.__O=o.__P)}this.__b=null}var n=r.__a&&u.createElement(u.Fragment,null,e.fallback);return n&&(n.__u&=-33),[u.createElement(u.Fragment,null,r.__a?null:e.children),n]};var g=function(e,r,t){if(++t[1]===t[0]&&e.l.delete(r),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(c.prototype=new u.Component).__a=function(e){var r=this,t=S(r.__v),o=r.l.get(e);return o[0]++,function(n){var s=function(){r.props.revealOrder?(o.push(n),g(r,e,o)):n()};t?t(s):s()}},c.prototype.render=function(e){this.i=null,this.l=new Map;var r=u.toChildArray(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&r.reverse();for(var t=r.length;t--;)this.l.set(r[t],this.i=[1,0,this.i]);return e.children},c.prototype.componentDidUpdate=c.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(r,t){g(e,t,r)})};var I=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,j=/[A-Z0-9]/g,F=typeof document<"u",H=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};u.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(u.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})});var k=u.options.event;function L(){}function z(){return this.cancelBubble}function B(){return this.defaultPrevented}u.options.event=function(e){return k&&(e=k(e)),e.persist=L,e.isPropagationStopped=z,e.isDefaultPrevented=B,e.nativeEvent=e};var D={enumerable:!1,configurable:!0,get:function(){return this.class}},O=u.options.vnode;u.options.vnode=function(e){typeof e.type=="string"&&function(r){var t=r.props,o=r.type,n={},s=o.indexOf("-")===-1;for(var i in t){var _=t[i];if(!(i==="value"&&"defaultValue"in t&&_==null||F&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var l=i.toLowerCase();i==="defaultValue"&&"value"in t&&t.value==null?i="value":i==="download"&&_===!0?_="":l==="translate"&&_==="no"?_=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?i="ondblclick":l!=="onchange"||o!=="input"&&o!=="textarea"||H(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":V.test(i)&&(i=l):l=i="oninput":s&&W.test(i)?i=i.replace(j,"-$&").toLowerCase():_===null&&(_=void 0),l==="oninput"&&n[i=l]&&(i="oninputCapture"),n[i]=_}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.value.indexOf(a.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.multiple?n.defaultValue.indexOf(a.props.value)!=-1:n.defaultValue==a.props.value})),t.class&&!t.className?(n.class=t.class,Object.defineProperty(n,"className",D)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=I,O&&O(e)};var C=u.options.__r;u.options.__r=function(e){C&&C(e),e.__c};var w=u.options.diffed;u.options.diffed=function(e){w&&w(e);var r=e.props,t=e.__e;t!=null&&e.type==="textarea"&&"value"in r&&r.value!==t.value&&(t.value=r.value==null?"":r.value)};function T({children:e,pageSize:r,observerOptions:t}){const o=h.useRef(null),{query:n,response:s}=d.useNostoAppState(_=>x.pick(_,"query","response")),{loadMore:i}=d.useLoadMore(r);return h.useEffect(()=>{let _,l;return E(n,s)&&(_=o.current,l=new IntersectionObserver(a=>{a[0]?.isIntersecting&&i()},t),_&&l.observe(_)),()=>{_&&l.unobserve(_)}},[s]),v.u(u.Fragment,{children:[e,v.u("div",{ref:o,style:{height:"1px"}})]})}const $=U(T,N.isEqual);exports.InfiniteScrollWithObserver=$;exports.hasMoreResults=E;exports.intersectionObserverSupported=A;
@@ -1,6 +1,6 @@
1
1
  import { u as y } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { a as x, u as U } from "./useLoadMore-DQb45K2a.js";
3
- import { i as I } from "./logger-_fg_Za9y.js";
2
+ import { a as x, u as U } from "./useLoadMore-QY3ve8Xg.js";
3
+ import { i as I } from "./storage-KGxdBTgd.js";
4
4
  import { p as A } from "./pick-DReBictn.js";
5
5
  import { Component as c, options as l, createElement as v, Fragment as d, toChildArray as h } from "preact";
6
6
  import { useRef as M, useEffect as W } from "preact/hooks";
@@ -1 +1 @@
1
- "use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-B6FFW8xI.cjs"),n=require("./baseConfig-DDoRk8Lk.cjs"),s={...n.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function o(e={}){return{pageType:"search",...s,...e}}function u({config:e,store:i,children:a}){const c=i??t.createStore();return n.useCheckClientScript(),r.u(t.ConfigContext,{value:o(e),children:r.u(t.StoreContext,{value:c,children:[r.u(n.StoreActionsListener,{}),a]})})}exports.SearchPageProvider=u;exports.makeSerpConfig=o;
1
+ "use strict";const r=require("./jsxRuntime.module-B3sGoTIU.cjs"),t=require("./useActions-CG4NaniG.cjs"),n=require("./baseConfig-Bw9xRShf.cjs"),s={...n.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function o(e={}){return{pageType:"search",...s,...e}}function u({config:e,store:i,children:a}){const c=i??t.createStore();return n.useCheckClientScript(),r.u(t.ConfigContext,{value:o(e),children:r.u(t.StoreContext,{value:c,children:[r.u(n.StoreActionsListener,{}),a]})})}exports.SearchPageProvider=u;exports.makeSerpConfig=o;
@@ -1,6 +1,6 @@
1
1
  import { u as r } from "./jsxRuntime.module-Bzuv3cXw.js";
2
- import { c as n, S as s, C as c } from "./useActions-DoZCMPfW.js";
3
- import { d as i, u as f, S } from "./baseConfig-BU6c9mCI.js";
2
+ import { c as n, S as s, C as c } from "./useActions-B50noHCX.js";
3
+ import { d as i, u as f, S } from "./baseConfig-CE2qzlEt.js";
4
4
  const l = {
5
5
  ...i,
6
6
  persistentSearchCache: !1,
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./useActions-CG4NaniG.cjs"),n=require("./eventBusSubscribe-oONOUGH8.cjs"),f=require("./index.es-Dp6Iaxz3.cjs"),b=require("./storage-BQdl3oEs.cjs"),d=require("preact/hooks");function S(){const{pageType:e}=c.useConfig(),{newSearch:i,updateSearch:u,replaceFilter:o,toggleProductFilter:a}=c.useActions();return n.useEventBusSubscribe({event:"actions/newSearch",callback:({query:t,options:r,targetStore:s})=>{e===s&&i(t,r)}}),n.useEventBusSubscribe({event:"actions/updateSearch",callback:({query:t,options:r,targetStore:s})=>{e===s&&u(t,r)}}),n.useEventBusSubscribe({event:"actions/replaceFilter",callback:({field:t,value:r,targetStore:s})=>{e===s&&o(t,r)}}),n.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:({field:t,value:r,active:s,targetStore:l})=>{e===l&&a(t,r,s)}}),null}function g(){d.useEffect(()=>{const e=window.setTimeout(()=>{b.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);f.s(()=>{window.clearTimeout(e)})},[])}const p={defaultCurrency:"EUR",queryModifications:e=>e};exports.StoreActionsListener=S;exports.defaultBaseConfig=p;exports.useCheckClientScript=g;
@@ -1,7 +1,7 @@
1
- import { b as l, h as f } from "./useActions-DoZCMPfW.js";
1
+ import { b as l, h as f } from "./useActions-B50noHCX.js";
2
2
  import { u as c } from "./eventBusSubscribe-CzlS132j.js";
3
3
  import { s as p } from "./index.es-XNBESE3P.js";
4
- import { l as d } from "./logger-_fg_Za9y.js";
4
+ import { l as d } from "./storage-KGxdBTgd.js";
5
5
  import { useEffect as m } from "preact/hooks";
6
6
  function k() {
7
7
  const { pageType: e } = l(), { newSearch: n, updateSearch: i, replaceFilter: a, toggleProductFilter: s } = f();
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.es-Dp6Iaxz3.cjs"),o=require("../search-DItu5YCc.cjs");async function i(r,a,t=1){await e.C(a,void 0,t),await(await new Promise(e.s)).recordSearchAddToCart(r,a)}exports.search=o.search;exports.addToCart=i;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../index.es-Dp6Iaxz3.cjs"),o=require("../search-BXRj3vpd.cjs");async function i(r,a,t=1){await e.C(a,void 0,t),await(await new Promise(e.s)).recordSearchAddToCart(r,a)}exports.search=o.search;exports.addToCart=i;
@@ -1,5 +1,5 @@
1
1
  import { C as t, s as i } from "../index.es-XNBESE3P.js";
2
- import { s as p } from "../search-xLgL6P5R.js";
2
+ import { s as p } from "../search-CUKuaCNR.js";
3
3
  async function c(o, a, r = 1) {
4
4
  await t(a, void 0, r), await (await new Promise(i)).recordSearchAddToCart(o, a);
5
5
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-CFcim_G9.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),i=require("../../index.es-Dp6Iaxz3.cjs"),a=require("../../BaseElement-CIHACCWd.cjs"),m=require("preact/hooks"),p=require("../../cl-B00bZ7jc.cjs");function d({children:t,hit:e,as:o,componentProps:n}){const r=m.useCallback(()=>{e&&"productId"in e&&i.s(c=>c.recordSearchClick("autocomplete",e))},[e]);return u.u(a.BaseElement,{onClick:r,as:o,componentProps:n,className:"ns-autocomplete-element",children:t})}function P({children:t,class:e,onSubmit:o}){return u.u("div",{className:p.cl("ns-autocomplete-element",e),onClick:o,onKeyDown:n=>{n.key==="Enter"&&o()},children:t})}function f({as:t,componentProps:e,onSearchInput:o,children:n}){const r={...e,onInput:l=>{o(l.target)}},c=t??"input";return t||(r.type="search"),u.u(c,{...r,children:n})}exports.AutocompletePageProvider=s.AutocompletePageProvider;exports.AutocompleteElement=d;exports.HistoryElement=P;exports.SearchInput=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../AutocompletePageProvider-DCKnj8pR.cjs"),u=require("../../jsxRuntime.module-B3sGoTIU.cjs"),i=require("../../index.es-Dp6Iaxz3.cjs"),a=require("../../BaseElement-CIHACCWd.cjs"),m=require("preact/hooks"),p=require("../../cl-B00bZ7jc.cjs");function d({children:t,hit:e,as:o,componentProps:n}){const r=m.useCallback(()=>{e&&"productId"in e&&i.s(c=>c.recordSearchClick("autocomplete",e))},[e]);return u.u(a.BaseElement,{onClick:r,as:o,componentProps:n,className:"ns-autocomplete-element",children:t})}function P({children:t,class:e,onSubmit:o}){return u.u("div",{className:p.cl("ns-autocomplete-element",e),onClick:o,onKeyDown:n=>{n.key==="Enter"&&o()},children:t})}function f({as:t,componentProps:e,onSearchInput:o,children:n}){const r={...e,onInput:l=>{o(l.target)}},c=t??"input";return t||(r.type="search"),u.u(c,{...r,children:n})}exports.AutocompletePageProvider=s.AutocompletePageProvider;exports.AutocompleteElement=d;exports.HistoryElement=P;exports.SearchInput=f;
@@ -1,4 +1,4 @@
1
- import { A as g } from "../../AutocompletePageProvider-CJb7OEAr.js";
1
+ import { A as g } from "../../AutocompletePageProvider-BP5rBIA9.js";
2
2
  import { u as m } from "../../jsxRuntime.module-Bzuv3cXw.js";
3
3
  import { s } from "../../index.es-XNBESE3P.js";
4
4
  import { B as a } from "../../BaseElement-DD_4UwDm.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../CategoryPageProvider-C2nqTdZ8.cjs");exports.CategoryPageProvider=e.CategoryPageProvider;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../CategoryPageProvider-BKJBzstK.cjs");exports.CategoryPageProvider=e.CategoryPageProvider;
@@ -1,4 +1,4 @@
1
- import { C as o } from "../../CategoryPageProvider-BGqhQtdT.js";
1
+ import { C as o } from "../../CategoryPageProvider-AVXodPE4.js";
2
2
  export {
3
3
  o as CategoryPageProvider
4
4
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-CKn3Ecpu.cjs"),g=require("../../isBot-CM2hS03W.cjs"),o=require("../../jsxRuntime.module-B3sGoTIU.cjs"),u=require("../../useLoadMore-DfdmCB8L.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-3Mj6PB5H.cjs"),C=require("preact"),e=require("../../useActions-B6FFW8xI.cjs");function q({pageSize:t}){const{loadMore:r}=u.useLoadMore(t);return o.u("button",{onClick:r,children:"More results"})}function s({children:t,loadMoreComponent:r,pageSize:i}){const{loading:c,query:l,response:a}=u.useNostoAppState(f=>p.pick(f,"loading","query","response")),d=!c&&n.hasMoreResults(l,a);return o.u(C.Fragment,{children:[t,d&&(r?o.u(r,{pageSize:i}):o.u(q,{pageSize:i}))]})}const y=!g.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:s;exports.ErrorBoundary=S.ErrorBoundary;exports.StoreContext=e.StoreContext;exports.createExtendableStore=e.createExtendableStore;exports.createStore=e.createStore;exports.defaultState=e.defaultState;exports.useAutocompleteConfig=e.useAutocompleteConfig;exports.useCategoryConfig=e.useCategoryConfig;exports.useConfig=e.useConfig;exports.useSerpConfig=e.useSerpConfig;exports.InfiniteScroll=y;exports.InfiniteScrollWithLink=s;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../../ErrorBoundary-BuK47tWy.cjs"),g=require("../../isBot-CM2hS03W.cjs"),o=require("../../jsxRuntime.module-B3sGoTIU.cjs"),u=require("../../useLoadMore-EOcCFqU8.cjs"),p=require("../../pick-rYi1lc2m.cjs"),n=require("../../InfiniteScrollWithObserver-CxHK-Vzv.cjs"),C=require("preact"),e=require("../../useActions-CG4NaniG.cjs");function q({pageSize:t}){const{loadMore:r}=u.useLoadMore(t);return o.u("button",{onClick:r,children:"More results"})}function s({children:t,loadMoreComponent:r,pageSize:i}){const{loading:c,query:l,response:a}=u.useNostoAppState(f=>p.pick(f,"loading","query","response")),d=!c&&n.hasMoreResults(l,a);return o.u(C.Fragment,{children:[t,d&&(r?o.u(r,{pageSize:i}):o.u(q,{pageSize:i}))]})}const y=!g.isBot()&&n.intersectionObserverSupported()?n.InfiniteScrollWithObserver:s;exports.ErrorBoundary=S.ErrorBoundary;exports.StoreContext=e.StoreContext;exports.createExtendableStore=e.createExtendableStore;exports.createStore=e.createStore;exports.defaultState=e.defaultState;exports.useAutocompleteConfig=e.useAutocompleteConfig;exports.useCategoryConfig=e.useCategoryConfig;exports.useConfig=e.useConfig;exports.useSerpConfig=e.useSerpConfig;exports.InfiniteScroll=y;exports.InfiniteScrollWithLink=s;
@@ -1,11 +1,11 @@
1
- import { E as v } from "../../ErrorBoundary-DTRm_60r.js";
1
+ import { E as v } from "../../ErrorBoundary-BgL4oJs4.js";
2
2
  import { i as f } from "../../isBot-0jVC54QA.js";
3
3
  import { u as e } from "../../jsxRuntime.module-Bzuv3cXw.js";
4
- import { u as p, a as c } from "../../useLoadMore-DQb45K2a.js";
4
+ import { u as p, a as c } from "../../useLoadMore-QY3ve8Xg.js";
5
5
  import { p as l } from "../../pick-DReBictn.js";
6
- import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-aOddKvLF.js";
6
+ import { h as m, i as d, I as S } from "../../InfiniteScrollWithObserver-D0hbwNoK.js";
7
7
  import { Fragment as g } from "preact";
8
- import { S as B, g as O, c as W, f as F, a as N, d as R, b as j, e as w } from "../../useActions-DoZCMPfW.js";
8
+ import { S as B, g as O, c as W, f as F, a as N, d as R, b as j, e as w } from "../../useActions-B50noHCX.js";
9
9
  function C({ pageSize: r }) {
10
10
  const { loadMore: o } = p(r);
11
11
  return /* @__PURE__ */ e("button", { onClick: o, children: "More results" });
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../useActions-B6FFW8xI.cjs"),q=require("../../logger-Boh_C6Bz.cjs"),h=require("../../useLoadMore-DfdmCB8L.cjs"),L=require("../../eventBusSubscribe-oONOUGH8.cjs"),l=require("preact/hooks"),M=require("../../useHistory-D_TgfzXK.cjs"),z=require("../../index.es-Dp6Iaxz3.cjs"),O=require("../../eventBusDispatch-BKQcSHAB.cjs"),F=require("../../parseNumber-FsZ8w61u.cjs");function X(e){const s=h.useNostoAppState(t=>t.response);return e&&Array.isArray(e)||e&&q.isPlainObject(e)?e:s}function E(e,s){const t=e.data?.filter(f=>f.selected).length??0,{active:o}={active:t>0,...s},[n,c]=l.useState(o),{toggleProductFilter:u}=A.useActions(),a=l.useCallback(()=>{c(!n)},[n]);return L.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{c(!1)}}),{active:n,selectedFiltersCount:t,toggleActive:a,toggleProductFilter:u}}function j(){const{loading:e,facets:s}=h.useNostoAppState(t=>({loading:t.loading,facets:t.response?.products?.facets??[]}));return{loading:e,facets:s}}function V(e,s){const t=s-e;return!isNaN(t)&&t>0?new Array(s-e).fill(void 0).map((o,n)=>n+e):[]}function B(e){const{query:s,products:t}=h.useNostoAppState(o=>({query:o.query,products:o.response.products}));return l.useMemo(()=>{if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const o=s.products?.from??0,n=e?.width??1/0,c=Math.max(Math.floor(n-1)/2,1),u=t.size>0?Math.floor(o/t.size)+1:1,a=t.size>0?Math.ceil(t.total/t.size):0,f=y=>y>=u-c&&y<=u+c,r=o+1,i=Math.min(o+t.total,t.total),d={from:o,page:u,current:!0},p=y=>({from:(y-1)*t.size,page:y,current:y===u}),S=u>1?p(u-1):void 0,v=u<a?p(u+1):void 0,m=u-c-1>1?p(1):void 0,g=u+c+1<a?p(a):void 0,b=V(1,a+1).filter(f).map(p);return!m&&b[0]?.page===2&&b.unshift(p(1)),!g&&b[b.length-1]?.page===a-1&&b.push(p(a)),{totalPages:a,resultsFrom:r,resultsTo:i,current:d,prev:S,next:v,first:m,last:g,pages:b}},[s,t,e?.width])}function D(){const[e,s]=l.useState([]),[t,o]=l.useState([]);return l.useEffect(()=>{z.s(async n=>{const{products:c,segments:u}=await n.getSearchSessionParams();s(u??[]),o(c?.personalizationBoost??[])})},[]),{segments:e,boost:t}}function $(){const{facets:e}=h.useNostoAppState(r=>({facets:r.response.products?.facets??[]})),{replaceFilter:s,toggleProductFilter:t}=A.useActions(),o=l.useCallback(r=>{const i=e?.find(d=>d.type==="stats"&&d.field===r);if(i&&"min"in i&&"max"in i)return i},[e]),n=l.useCallback(r=>e?.find(i=>i.field===r)?.name??r,[e]),c=l.useCallback(r=>"field"in r&&(r.value instanceof Array||r.range instanceof Array),[]),u=l.useCallback(r=>({...r,range:r.range?.map(i=>({gt:i.gt?Number(i.gt):i.gt,gte:i.gte?Number(i.gte):i.gte,lt:i.lt?Number(i.lt):i.lt,lte:i.lte?Number(i.lte):i.lte}))}),[]),a=l.useCallback(r=>(r.value??[]).map(d=>({value:d,field:r.field,name:n(r.field),filter:u(r),remove:()=>{t(r.field,d,!1)}})),[u,n,t]),f=l.useCallback(r=>(r.range??[]).map(d=>{const p=d.gte??d.gt??o(r.field)?.min,S=d.lte??d.lt??o(r.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:r.field,name:n(r.field),filter:u(r),remove:()=>{s(r.field,void 0)}}}).filter(Boolean),[u,o,n,s]);return{selectFilters:c,toValueFilter:a,toRangeFilter:f}}function T(){const{filter:e}=h.useNostoAppState(a=>({filter:a.query.products?.filter??[]})),{updateSearch:s}=A.useActions(),{selectFilters:t,toValueFilter:o,toRangeFilter:n}=$(),c=l.useMemo(()=>e?e.filter(t).flatMap(a=>"value"in a?o(a):"range"in a?n(a):[]).filter(Boolean):[],[e,t,n,o]),u=l.useCallback(()=>{s({products:{filter:[]}}),O.dispatchNostoEvent({event:"events/removeAllFilters",params:null})},[s]);return{filters:c,removeAll:u}}function x(e){const{replaceFilter:s}=A.useActions(),{query:t,products:o}=h.useNostoAppState(g=>({query:g.query,products:g.response.products})),n=o?.facets?.find(g=>g.id===e),c=t.products?.filter?.find(g=>g.field===n?.field),[u,a]=U(c),f=n&&"min"in n?Math.floor(n.min??0):0,r=n&&"max"in n?Math.ceil(n.max??0):0,i=l.useMemo(()=>[u??f,a??r],[u,a,f,r]),d=u!==void 0||a!==void 0,[p,S]=l.useState(d),v=l.useCallback(()=>{S(g=>!g)},[]),m=l.useCallback(([g,b])=>{if(!n)return;const y=_(g,b,f,r);s(n.field,y)},[f,r,s,n]);return L.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{S(!1)}}),n?{min:f,max:r,range:i,updateRange:m,active:p,toggleActive:v}:H}const H={min:0,max:0,range:[0,0],active:!1,toggleActive:()=>{},updateRange:()=>{}};function U(e){const s=e?.range?.[0];return typeof s=="object"&&("gte"in s||"lte"in s)?[F.parseNumber(s.gte),F.parseNumber(s.lte)]:[void 0,void 0]}function _(e,s,t,o){const n=e!==void 0?Math.floor(e):void 0,c=s!==void 0?Math.ceil(s):void 0,u=n!==void 0,a=c!==void 0;if((t===n||!u)&&(o===c||!a))return;const f={};return u&&n!==t&&(f.gte=n.toString()),a&&c!==o&&(f.lte=c.toString()),Object.keys(f).length>0?f:void 0}function I(e,s){const{min:t,max:o,range:n,updateRange:c}=x(e),{filters:u}=T(),a=l.useMemo(()=>{const d=u.find(m=>m?.filter?.range);let p=null;if(d){const m=d.filter.range?.[0];p=[F.parseNumber(m?.gte),F.parseNumber(m?.lte)]}const S=[];let v=Math.floor(t/s)*s;for(;v<o;){const m=v+s,g=p&&p[0]===v&&p[1]===m;S.push({min:v,max:m,selected:g}),v=m}return S},[u,t,o,s]),f=l.useCallback(d=>{c([d,n[1]])},[n,c]),r=l.useCallback(d=>{c([n[0],d])},[n,c]),i=t!==n[0]||o!==n[1];return{min:t,max:o,range:n,updateRange:c,ranges:a,handleMinChange:f,handleMaxChange:r,isSelected:i}}function K(){const{products:e,keywords:s,popularSearches:t,categories:o}=h.useNostoAppState(n=>({products:n.response.products??w,keywords:n.response.keywords??w,popularSearches:n.response.popularSearches??w,categories:n.response.categories??w}));return{products:e,keywords:s,popularSearches:t,categories:o}}const w={hits:[],total:0};function Z(){const e=h.useNostoAppState(t=>t.query.products?.filter);return l.useMemo(()=>e?e.reduce((t,o)=>t+(Array.isArray(o.value)?o.value.length:1),0):0,[e])}const G=5*60*1e3,N=new Map;function J(e){const[s,t]=l.useState({product:null,loading:!0,error:null});return l.useEffect(()=>{if(!e){t({product:null,loading:!1,error:"Product handle is required"});return}t(n=>({...n,loading:!0,error:null}));const o=Y(e);if(o){t({product:o,loading:!1,error:null});return}W(e).then(n=>{ee(e,n),t({product:n,loading:!1,error:null})}).catch(n=>{t({product:null,loading:!1,error:n.message||"Failed to fetch product"})})},[e]),s}function Q(e){const s=window.Shopify?.routes?.root;return s?new URL(`${s}products/${e}`,window.location.href):e}async function W(e){const s=await fetch(Q(`/products/${e}.js`));if(!s.ok)throw new Error(`Failed to fetch product: ${s.status} ${s.statusText}`);return s.json()}function Y(e){const s=N.get(e);return s?Date.now()-s.created>G?(N.delete(e),null):s.product:null}function ee(e,s){N.set(e,{product:s,created:Date.now()})}function k(e){return e&&!Number.isNaN(e)?e:0}function te(e,s){const{from:t,size:o,total:n}=h.useNostoAppState(r=>({from:k(r.query.products?.from??0),size:k(r.response?.products?.size??s),total:k(r.response?.products?.total??0)})),{updateSearch:c}=A.useActions(),u=t+o,a=l.useMemo(()=>[...e].reverse().filter(r=>r<n),[e,n]),f=l.useCallback(r=>{c({products:{size:F.parseNumber(r)}})},[c]);return{from:t,to:u,total:n,size:o,sizeOptions:a,handleSizeChange:f}}function se(e,s){return e.length!==s.length?!1:e.every(t=>s.find(o=>t.field===o.field&&t.order===o.order))}function ne(e){const s=h.useNostoAppState(c=>c.query),{updateSearch:t}=A.useActions(),o=e.find(c=>se(c.value.sort,s.products?.sort||[]))?.id??e[0]?.id,n=l.useCallback(c=>{const u=e.find(a=>a.id===c);u&&t({products:{sort:u.value.sort}})},[e,t]);return{activeSort:o,setSort:n}}const C=window.SpeechRecognition||window.webkitSpeechRecognition,P=!!(C&&typeof C=="function");function oe(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function re({language:e="en-US",interimResults:s=!1,onResult:t,onError:o}={}){const[n,c]=l.useState(!1),u=l.useRef(null),a=l.useCallback(()=>{const r=new C;r.lang=e,r.interimResults=s,r.onstart=()=>c(!0),t&&(r.onresult=i=>{const{transcript:d}=i.results?.[0]?.[0];t(d)}),o&&(r.onerror=i=>o(i.error)),r.onend=()=>c(!1),u.current=r,r.start()},[e,s,o,t]),f=l.useCallback(()=>{u.current?.stop()},[u]);return{listening:n,startListening:a,stopListening:f}}const ce=P?re:oe;function ue(e,s){if(!e.length||!s.length)return[];const t=s.reduce((o,n)=>(o[n]={},o),{});return e.forEach(o=>{o.customFields?.forEach(({key:n,value:c})=>{const u=n.toLowerCase();s.includes(u)&&(t[u][c]=t[u][c]||[],t[u][c].push(o))})}),Object.entries(t).filter(o=>Object.keys(o[1]).length).map(([o,n])=>({field:o,options:Object.entries(n).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function ie(e,s){return e.length?e.map(({field:t,options:o})=>({field:t,options:o.map(n=>{const c=!n.skus?.some(a=>Object.entries(s).every(([f,r])=>f===t?!0:a.customFields?.find(d=>d.key.toLowerCase()===f)?.value===r)),u=s[t]===n.value;return{...n,unavailable:c,selected:u}})})):[]}const R=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function ae(e){if(R.includes(e))return 1e3+R.indexOf(e);const s=parseFloat(e);return isNaN(s)?e:s}function le(e,s){return[...s].sort((t,o)=>{const[n,c]=[t.value,o.value].map(ae);return n<c?-1:1})}function de(e=[],s=[]){const[t,o]=l.useState({}),n=l.useMemo(()=>ue(e,s).map(({field:r,options:i})=>({field:r,options:le(r,i)})),[e,s]),c=l.useMemo(()=>ie(n,t),[n,t]),u=l.useCallback((f,r)=>{o(i=>{const d={...i};return d[f]===r?delete d[f]:d[f]=r,d})},[]),a=l.useMemo(()=>Object.keys(t).filter(i=>t[i]).length===0?[]:c.filter(({field:i})=>t[i]).map(({field:i,options:d})=>{const p=t[i];return d.find(v=>v.value===p)?.skus??[]}).reduce((i,d)=>i.filter(p=>d.includes(p))),[c,t]);return{swatches:c,toggleOption:u,matchedSkus:a}}exports.useActions=A.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.addToHistory=M.addToHistory;exports.getSavedHistory=M.getSavedHistory;exports.useHistory=M.useHistory;exports.speechToTextSupported=P;exports.useDecoratedSearchResults=X;exports.useFacet=E;exports.useFacets=j;exports.usePagination=B;exports.usePersonalization=D;exports.useProductFilters=T;exports.useRange=x;exports.useRangeSelector=I;exports.useResponse=K;exports.useSelectedFiltersCount=Z;exports.useShopifyProduct=J;exports.useSizeOptions=te;exports.useSort=ne;exports.useSpeechToText=ce;exports.useSwatches=de;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../useActions-CG4NaniG.cjs"),q=require("../../storage-BQdl3oEs.cjs"),h=require("../../useLoadMore-EOcCFqU8.cjs"),L=require("../../eventBusSubscribe-oONOUGH8.cjs"),l=require("preact/hooks"),M=require("../../useHistory-D6Q9vxsY.cjs"),z=require("../../index.es-Dp6Iaxz3.cjs"),O=require("../../eventBusDispatch-BKQcSHAB.cjs"),F=require("../../parseNumber-FsZ8w61u.cjs");function X(e){const s=h.useNostoAppState(t=>t.response);return e&&Array.isArray(e)||e&&q.isPlainObject(e)?e:s}function E(e,s){const t=e.data?.filter(f=>f.selected).length??0,{active:o}={active:t>0,...s},[n,c]=l.useState(o),{toggleProductFilter:u}=A.useActions(),i=l.useCallback(()=>{c(!n)},[n]);return L.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{c(!1)}}),{active:n,selectedFiltersCount:t,toggleActive:i,toggleProductFilter:u}}function j(){const{loading:e,facets:s}=h.useNostoAppState(t=>({loading:t.loading,facets:t.response?.products?.facets??[]}));return{loading:e,facets:s}}function V(e,s){const t=s-e;return!isNaN(t)&&t>0?new Array(s-e).fill(void 0).map((o,n)=>n+e):[]}function B(e){const{query:s,products:t}=h.useNostoAppState(o=>({query:o.query,products:o.response.products}));return l.useMemo(()=>{if(!t)return{totalPages:0,resultsFrom:0,resultsTo:0,pages:[]};const o=s.products?.from??0,n=e?.width??1/0,c=Math.max(Math.floor(n-1)/2,1),u=t.size>0?Math.floor(o/t.size)+1:1,i=t.size>0?Math.ceil(t.total/t.size):0,f=y=>y>=u-c&&y<=u+c,r=o+1,a=Math.min(o+t.total,t.total),d={from:o,page:u,current:!0},p=y=>({from:(y-1)*t.size,page:y,current:y===u}),S=u>1?p(u-1):void 0,v=u<i?p(u+1):void 0,m=u-c-1>1?p(1):void 0,g=u+c+1<i?p(i):void 0,b=V(1,i+1).filter(f).map(p);return!m&&b[0]?.page===2&&b.unshift(p(1)),!g&&b[b.length-1]?.page===i-1&&b.push(p(i)),{totalPages:i,resultsFrom:r,resultsTo:a,current:d,prev:S,next:v,first:m,last:g,pages:b}},[s,t,e?.width])}function D(){const[e,s]=l.useState([]),[t,o]=l.useState([]);return l.useEffect(()=>{z.s(async n=>{const{products:c,segments:u}=await n.getSearchSessionParams();s(u??[]),o(c?.personalizationBoost??[])})},[]),{segments:e,boost:t}}function $(){const{facets:e}=h.useNostoAppState(r=>({facets:r.response.products?.facets??[]})),{replaceFilter:s,toggleProductFilter:t}=A.useActions(),o=l.useCallback(r=>{const a=e?.find(d=>d.type==="stats"&&d.field===r);if(a&&"min"in a&&"max"in a)return a},[e]),n=l.useCallback(r=>e?.find(a=>a.field===r)?.name??r,[e]),c=l.useCallback(r=>"field"in r&&(r.value instanceof Array||r.range instanceof Array),[]),u=l.useCallback(r=>({...r,range:r.range?.map(a=>({gt:a.gt?Number(a.gt):a.gt,gte:a.gte?Number(a.gte):a.gte,lt:a.lt?Number(a.lt):a.lt,lte:a.lte?Number(a.lte):a.lte}))}),[]),i=l.useCallback(r=>(r.value??[]).map(d=>({value:d,field:r.field,name:n(r.field),filter:u(r),remove:()=>{t(r.field,d,!1)}})),[u,n,t]),f=l.useCallback(r=>(r.range??[]).map(d=>{const p=d.gte??d.gt??o(r.field)?.min,S=d.lte??d.lt??o(r.field)?.max;if(p!==void 0&&S!==void 0)return{value:`${p} - ${S}`,field:r.field,name:n(r.field),filter:u(r),remove:()=>{s(r.field,void 0)}}}).filter(Boolean),[u,o,n,s]);return{selectFilters:c,toValueFilter:i,toRangeFilter:f}}function T(){const{filter:e}=h.useNostoAppState(i=>({filter:i.query.products?.filter??[]})),{updateSearch:s}=A.useActions(),{selectFilters:t,toValueFilter:o,toRangeFilter:n}=$(),c=l.useMemo(()=>e?e.filter(t).flatMap(i=>"value"in i?o(i):"range"in i?n(i):[]).filter(Boolean):[],[e,t,n,o]),u=l.useCallback(()=>{s({products:{filter:[]}}),O.dispatchNostoEvent({event:"events/removeAllFilters",params:null})},[s]);return{filters:c,removeAll:u}}function x(e){const{replaceFilter:s}=A.useActions(),{query:t,products:o}=h.useNostoAppState(g=>({query:g.query,products:g.response.products})),n=o?.facets?.find(g=>g.id===e),c=t.products?.filter?.find(g=>g.field===n?.field),[u,i]=U(c),f=n&&"min"in n?Math.floor(n.min??0):0,r=n&&"max"in n?Math.ceil(n.max??0):0,a=l.useMemo(()=>[u??f,i??r],[u,i,f,r]),d=u!==void 0||i!==void 0,[p,S]=l.useState(d),v=l.useCallback(()=>{S(g=>!g)},[]),m=l.useCallback(([g,b])=>{if(!n)return;const y=_(g,b,f,r);s(n.field,y)},[f,r,s,n]);return L.useEventBusSubscribe({event:"events/removeAllFilters",callback:()=>{S(!1)}}),n?{min:f,max:r,range:a,updateRange:m,active:p,toggleActive:v}:H}const H={min:0,max:0,range:[0,0],active:!1,toggleActive:()=>{},updateRange:()=>{}};function U(e){const s=e?.range?.[0];return typeof s=="object"&&("gte"in s||"lte"in s)?[F.parseNumber(s.gte),F.parseNumber(s.lte)]:[void 0,void 0]}function _(e,s,t,o){const n=e!==void 0?Math.floor(e):void 0,c=s!==void 0?Math.ceil(s):void 0,u=n!==void 0,i=c!==void 0;if((t===n||!u)&&(o===c||!i))return;const f={};return u&&n!==t&&(f.gte=n.toString()),i&&c!==o&&(f.lte=c.toString()),Object.keys(f).length>0?f:void 0}function I(e,s){const{min:t,max:o,range:n,updateRange:c}=x(e),{filters:u}=T(),i=l.useMemo(()=>{const d=u.find(m=>m?.filter?.range);let p=null;if(d){const m=d.filter.range?.[0];p=[F.parseNumber(m?.gte),F.parseNumber(m?.lte)]}const S=[];let v=Math.floor(t/s)*s;for(;v<o;){const m=v+s,g=p&&p[0]===v&&p[1]===m;S.push({min:v,max:m,selected:g}),v=m}return S},[u,t,o,s]),f=l.useCallback(d=>{c([d,n[1]])},[n,c]),r=l.useCallback(d=>{c([n[0],d])},[n,c]),a=t!==n[0]||o!==n[1];return{min:t,max:o,range:n,updateRange:c,ranges:i,handleMinChange:f,handleMaxChange:r,isSelected:a}}function K(){const{products:e,keywords:s,popularSearches:t,categories:o}=h.useNostoAppState(n=>({products:n.response.products??w,keywords:n.response.keywords??w,popularSearches:n.response.popularSearches??w,categories:n.response.categories??w}));return{products:e,keywords:s,popularSearches:t,categories:o}}const w={hits:[],total:0};function Z(){const e=h.useNostoAppState(t=>t.query.products?.filter);return l.useMemo(()=>e?e.reduce((t,o)=>t+(Array.isArray(o.value)?o.value.length:1),0):0,[e])}const G=5*60*1e3,N=new Map;function J(e){const[s,t]=l.useState({product:null,loading:!0,error:null});return l.useEffect(()=>{if(!e){t({product:null,loading:!1,error:"Product handle is required"});return}t(n=>({...n,loading:!0,error:null}));const o=Y(e);if(o){t({product:o,loading:!1,error:null});return}W(e).then(n=>{ee(e,n),t({product:n,loading:!1,error:null})}).catch(n=>{t({product:null,loading:!1,error:n.message||"Failed to fetch product"})})},[e]),s}function Q(e){const s=window.Shopify?.routes?.root;return s?new URL(`${s}products/${e}`,window.location.href):e}async function W(e){const s=await fetch(Q(`/products/${e}.js`));if(!s.ok)throw new Error(`Failed to fetch product: ${s.status} ${s.statusText}`);return s.json()}function Y(e){const s=N.get(e);return s?Date.now()-s.created>G?(N.delete(e),null):s.product:null}function ee(e,s){N.set(e,{product:s,created:Date.now()})}function k(e){return e&&!Number.isNaN(e)?e:0}function te(e,s){const{from:t,size:o,total:n}=h.useNostoAppState(r=>({from:k(r.query.products?.from??0),size:k(r.response?.products?.size??s),total:k(r.response?.products?.total??0)})),{updateSearch:c}=A.useActions(),u=t+o,i=l.useMemo(()=>[...e].reverse().filter(r=>r<n),[e,n]),f=l.useCallback(r=>{c({products:{size:F.parseNumber(r)}})},[c]);return{from:t,to:u,total:n,size:o,sizeOptions:i,handleSizeChange:f}}function se(e,s){return e.length!==s.length?!1:e.every(t=>s.find(o=>t.field===o.field&&t.order===o.order))}function ne(e){const s=h.useNostoAppState(c=>c.query),{updateSearch:t}=A.useActions(),o=e.find(c=>se(c.value.sort,s.products?.sort||[]))?.id??e[0]?.id,n=l.useCallback(c=>{const u=e.find(i=>i.id===c);u&&t({products:{sort:u.value.sort}})},[e,t]);return{activeSort:o,setSort:n}}const C=window.SpeechRecognition||window.webkitSpeechRecognition,P=!!(C&&typeof C=="function");function oe(){return{listening:!1,startListening:()=>{},stopListening:()=>{}}}function re({language:e="en-US",interimResults:s=!1,onResult:t,onError:o}={}){const[n,c]=l.useState(!1),u=l.useRef(null),i=l.useCallback(()=>{const r=new C;r.lang=e,r.interimResults=s,r.onstart=()=>c(!0),t&&(r.onresult=a=>{const{transcript:d}=a.results?.[0]?.[0];t(d)}),o&&(r.onerror=a=>o(a.error)),r.onend=()=>c(!1),u.current=r,r.start()},[e,s,o,t]),f=l.useCallback(()=>{u.current?.stop()},[u]);return{listening:n,startListening:i,stopListening:f}}const ce=P?re:oe;function ue(e,s){if(!e.length||!s.length)return[];const t=s.reduce((o,n)=>(o[n]={},o),{});return e.forEach(o=>{o.customFields?.forEach(({key:n,value:c})=>{const u=n.toLowerCase();s.includes(u)&&(t[u][c]=t[u][c]||[],t[u][c].push(o))})}),Object.entries(t).filter(o=>Object.keys(o[1]).length).map(([o,n])=>({field:o,options:Object.entries(n).map(([c,u])=>({value:c,skus:u,unavailable:!1,selected:!1}))}))}function ae(e,s){return e.length?e.map(({field:t,options:o})=>({field:t,options:o.map(n=>{const c=!n.skus?.some(i=>Object.entries(s).every(([f,r])=>f===t?!0:i.customFields?.find(d=>d.key.toLowerCase()===f)?.value===r)),u=s[t]===n.value;return{...n,unavailable:c,selected:u}})})):[]}const R=["4XS","3XS","2XS","XXS","XS","S","M","L","XL","XXL","2XL","XXXL","3XL","4XL"];function ie(e){if(R.includes(e))return 1e3+R.indexOf(e);const s=parseFloat(e);return isNaN(s)?e:s}function le(e,s){return[...s].sort((t,o)=>{const[n,c]=[t.value,o.value].map(ie);return n<c?-1:1})}function de(e=[],s=[]){const[t,o]=l.useState({}),n=l.useMemo(()=>ue(e,s).map(({field:r,options:a})=>({field:r,options:le(r,a)})),[e,s]),c=l.useMemo(()=>ae(n,t),[n,t]),u=l.useCallback((f,r)=>{o(a=>{const d={...a};return d[f]===r?delete d[f]:d[f]=r,d})},[]),i=l.useMemo(()=>Object.keys(t).filter(a=>t[a]).length===0?[]:c.filter(({field:a})=>t[a]).map(({field:a,options:d})=>{const p=t[a];return d.find(v=>v.value===p)?.skus??[]}).reduce((a,d)=>a.filter(p=>d.includes(p))),[c,t]);return{swatches:c,toggleOption:u,matchedSkus:i}}exports.useActions=A.useActions;exports.useLoadMore=h.useLoadMore;exports.useNostoAppState=h.useNostoAppState;exports.addToHistory=M.addToHistory;exports.getSavedHistory=M.getSavedHistory;exports.useHistory=M.useHistory;exports.speechToTextSupported=P;exports.useDecoratedSearchResults=X;exports.useFacet=E;exports.useFacets=j;exports.usePagination=B;exports.usePersonalization=D;exports.useProductFilters=T;exports.useRange=x;exports.useRangeSelector=I;exports.useResponse=K;exports.useSelectedFiltersCount=Z;exports.useShopifyProduct=J;exports.useSizeOptions=te;exports.useSort=ne;exports.useSpeechToText=ce;exports.useSwatches=de;
@@ -1,10 +1,10 @@
1
- import { h as A } from "../../useActions-DoZCMPfW.js";
2
- import { a as X } from "../../logger-_fg_Za9y.js";
3
- import { a as S } from "../../useLoadMore-DQb45K2a.js";
4
- import { u as Le } from "../../useLoadMore-DQb45K2a.js";
1
+ import { h as A } from "../../useActions-B50noHCX.js";
2
+ import { a as X } from "../../storage-KGxdBTgd.js";
3
+ import { a as S } from "../../useLoadMore-QY3ve8Xg.js";
4
+ import { u as Le } from "../../useLoadMore-QY3ve8Xg.js";
5
5
  import { u as P } from "../../eventBusSubscribe-CzlS132j.js";
6
6
  import { useState as b, useCallback as p, useMemo as y, useEffect as k, useRef as z } from "preact/hooks";
7
- import { a as Me, g as Te, u as Ne } from "../../useHistory-BJo9WE5S.js";
7
+ import { a as Me, g as Te, u as Ne } from "../../useHistory-DY4IMiA8.js";
8
8
  import { s as C } from "../../index.es-XNBESE3P.js";
9
9
  import { d as O } from "../../eventBusDispatch-DPR2Vwd4.js";
10
10
  import { p as R } from "../../parseNumber-QA48nJLp.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-CFcim_G9.cjs"),T=require("../../CategoryPageProvider-C2nqTdZ8.cjs"),h=require("../../useActions-B6FFW8xI.cjs"),I=require("../../SerpPageProvider-D5cD0ttm.cjs"),d=require("../../jsxRuntime.module-B3sGoTIU.cjs"),g=require("../../ErrorBoundary-CKn3Ecpu.cjs"),b=require("../../disableNativeAutocomplete-DI6zaZII.cjs"),P=require("../../unique-BXXNictB.cjs"),C=require("preact"),N=require("../../logger-Boh_C6Bz.cjs"),p=require("../../search-DItu5YCc.cjs");function O(e){let n;return t=>{n&&clearTimeout(n),n=setTimeout(t,e)}}function q(e){return Array.from(document.querySelectorAll(e))}function R(e){const n=[];let t=e.parentNode;for(;t&&t!==document&&t instanceof Element;)n.push(t),t=t.parentNode;return n}function E([e,n],t){const o=r=>{const s=r.target;s instanceof HTMLElement&&e&&s!==e&&s!==n&&!R(s).includes(e)&&t()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function A(e,n){e.tabIndex=0,e.addEventListener("blur",n)}function S(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function H({selector:e,timeout:n=500}){return new Promise(t=>{const o=q(e);if(o.length>0)return t(o);const r=new MutationObserver(()=>{const i=q(e);i.length>0&&(r.disconnect(),clearTimeout(s),t(i))}),s=setTimeout(()=>{r.disconnect(),N.logger.warn(`Timed out (${n}) while waiting for element ${e}`),t([])},n);r.observe(document.body,{childList:!0,subtree:!0})})}function x(e,n,t){n.style.display="none";const o=(()=>{if(e.parentElement&&e.parentElement.classList.contains("nosto-autocomplete-wrapper"))return e.parentElement;const a=document.createElement("div");return a.className="nosto-autocomplete-wrapper",e.parentNode?.insertBefore(a,e.nextSibling),a.appendChild(e),a})(),r=S(t),s=r&&document.querySelector(r.selector);if(s){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(n),r.position==="first"?s.prepend(a):s.appendChild(a)}else o.appendChild(n);const i={index:-1,onChangeListeners:[]},c=(a,u)=>{const f=a.length;f===0&&(u=-1),i.index=u>=0?u%f:f-1,i.onChangeListeners.forEach(D=>D())},l=()=>{i.index=-1,i.onChangeListeners.forEach(a=>a())},m=()=>i.index;return{element:n,hide:()=>{n.style.display="none",l()},show:()=>{n.style.display="inherit"},isOpen:()=>n.style.display!=="none",goDown:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u+1)},goUp:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u-1)},highlight:c,highlightedIndex:m,submitHighlightedItem:a=>{Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{i.onChangeListeners.push(a)}}}function $(e,n){const t=document.createElement("div");return t.className="nosto-autocomplete-dropdown",{...x(e,t,n),element:t}}const y="nosto:search-js:history";function v(e,n,t){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...x(e,o,n),element:o,add:s=>{const c=(p.getLocalStorageItem(y)??[]).filter(l=>l!==s).slice(t?-t:0);c.push(s),p.setLocalStorageItem(y,c)},get:()=>(p.getLocalStorageItem(y)??[]).reverse().filter(i=>!!i)}}async function F(e,{config:n,dropdown:t,history:o,renderHistory:r,store:s}){const{historyEnabled:i,minQueryLength:c}=n;if(e.length<c&&i&&r&&!o.isOpen()){o.show();return}if(e.length<c)return;t.hide();const l=s.getState()?.query?.query;l&&l!==e&&await h.newSearch({config:n,store:s},{query:e}),t.show()}async function k(e,n){const{config:t,renderHistory:o,history:r}=n,{historyEnabled:s,minQueryLength:i}=t;if(!o||e.length>=i||!s||r.isOpen())return;const c=j(n);r.onHighlightChange(()=>{c(o,r.element)}),r.show();const l=P.measure("renderHistory");c(o,r.element),l()}async function Q(e,{config:n,dropdown:t,history:o,store:r,debouncer:s}){const{minQueryLength:i,historyEnabled:c}=n;if(e.length<i&&!c){t.hide(),o.hide();return}if(e.length<i&&c){t.hide(),o.show();return}o.hide(),s(async()=>{h.newSearch({config:n,store:r},{query:e}),t.show()})}function M(e,n,t){const{config:o,debouncer:r}=t;if(r(()=>{}),e.length>=o.minQueryLength)return L(n,t.dropdown,t.history);if(o.historyEnabled)return L(n,t.history,t.dropdown)}function L(e,n,t){if(!n.isOpen()&&e==="ArrowDown"){n.show(),t.hide();return}if(e==="Escape"&&n.hide(),!!n.isOpen()){if(e==="ArrowDown")n.goDown();else if(e==="ArrowUp")n.goUp();else if(e==="Enter"){const o=n.highlightedIndex();return o>=0&&n.submitHighlightedItem(o),n.hide(),o>=0}}}function U(e,{config:n,dropdown:t,history:o,onNavigateToSearch:r,store:s}){t.hide(),o.hide(),!(e.length<n.minQueryLength)&&(o.add(e),s.updateState({historyItems:o.get()}),r?.({query:e}))}async function K(e,n){const{inputCssSelector:t,timeout:o}=e,r=S(t).selector,s=await H({selector:r,timeout:o});if(s.length===0)throw new Error(`No elements found for selector: ${r}`);s.forEach(i=>{_(i,e,n)})}async function _(e,n,t){const{config:o,dropdownCssSelector:r}=n,s=$(e,r),i=v(e,r,o.historySize),c={...n,input:e,dropdown:s,history:i,store:t,debouncer:O(o.debounceDelay)};G(c),e.setAttribute("data-nosto-element","search-input"),t.updateState({historyItems:i.get()}),b.disableNativeAutocomplete(e),t.onInit(()=>{z(c)}),b.bindInput(e,{onInput:l=>Q(l,c),onFocus:l=>k(l,c),onClick:l=>F(l,c),onSubmit:l=>U(l,c),onKeyDown:(l,m)=>M(l,m,c)}),A(i.element,i.hide),A(s.element,s.hide),E([i.element,e],i.hide),E([s.element,e],s.hide)}function z(e){const{dropdown:n,renderAutocomplete:t}=e;if(!t)return;const o=j(e);n.onHighlightChange(()=>{o(t,n.element)});const r=P.measure("renderAutocomplete");o(t,n.element),r()}async function G(e){const{input:n,renderSpeechToText:t,config:o,store:r}=e;if(!t)return;const s="ns-autocomplete-voice-position";if(!!n.parentElement?.querySelector(`.${s}`))return;const c=document.createElement("div");c.className=s,n.insertAdjacentElement("afterend",c);const l=await t();C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:o,store:r,children:l})}),c)}function j(e){const{config:n,store:t}=e;return(o,r)=>C.render(d.u(g.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:n,store:t,children:o()})}),r)}async function B({cssSelector:e,timeout:n,renderComponent:t}){const o=S(e).selector,r=await H({selector:o,timeout:n??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&N.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),C.render(t(),r[0])}async function J(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(T.CategoryPageProvider,{store:n,config:e.config,children:o})})})}async function V(e,n){const{render:t}=e,o=await t();B({...e,renderComponent:()=>d.u(g.ErrorBoundary,{children:d.u(I.SearchPageProvider,{store:n,config:e.config,children:o})})})}async function W({autocomplete:e,category:n,serp:t}){const o={};if(e){const r=h.createStore({query:e.query});await K({...e,config:w.makeAutocompleteConfig(e.config)},r),o.autocomplete={store:r}}if(n){const r=h.createStore({query:n.query});await J({...n,config:T.makeCategoryConfig(n.config)},r),o.category={store:r}}if(t){const r=h.createStore({query:t.query});await V({...t,config:I.makeSerpConfig(t.config)},r),o.serp={store:r}}return o}exports.init=W;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("../../AutocompletePageProvider-DCKnj8pR.cjs"),T=require("../../CategoryPageProvider-BKJBzstK.cjs"),h=require("../../useActions-CG4NaniG.cjs"),I=require("../../SerpPageProvider-BkFNjOHz.cjs"),d=require("../../jsxRuntime.module-B3sGoTIU.cjs"),f=require("../../ErrorBoundary-BuK47tWy.cjs"),b=require("../../disableNativeAutocomplete-DI6zaZII.cjs"),P=require("../../unique-Dm62pFFG.cjs"),C=require("preact"),g=require("../../storage-BQdl3oEs.cjs");function D(e){let n;return t=>{n&&clearTimeout(n),n=setTimeout(t,e)}}function E(e){return Array.from(document.querySelectorAll(e))}function O(e){const n=[];let t=e.parentNode;for(;t&&t!==document&&t instanceof Element;)n.push(t),t=t.parentNode;return n}function q([e,n],t){const o=r=>{const s=r.target;s instanceof HTMLElement&&e&&s!==e&&s!==n&&!O(s).includes(e)&&t()};return document.addEventListener("click",o),{destroy:()=>{document.removeEventListener("click",o)}}}function A(e,n){e.tabIndex=0,e.addEventListener("blur",n)}function S(e){return typeof e=="string"?{selector:e,position:"last"}:{position:"last",...e}}function N({selector:e,timeout:n=500}){return new Promise(t=>{const o=E(e);if(o.length>0)return t(o);const r=new MutationObserver(()=>{const i=E(e);i.length>0&&(r.disconnect(),clearTimeout(s),t(i))}),s=setTimeout(()=>{r.disconnect(),g.logger.warn(`Timed out (${n}) while waiting for element ${e}`),t([])},n);r.observe(document.body,{childList:!0,subtree:!0})})}function H(e,n,t){n.style.display="none";const o=(()=>{if(e.parentElement&&e.parentElement.classList.contains("nosto-autocomplete-wrapper"))return e.parentElement;const a=document.createElement("div");return a.className="nosto-autocomplete-wrapper",e.parentNode?.insertBefore(a,e.nextSibling),a.appendChild(e),a})(),r=S(t),s=r&&document.querySelector(r.selector);if(s){const a=document.createElement("form");a.className="nosto-dropdown-form",a.appendChild(n),r.position==="first"?s.prepend(a):s.appendChild(a)}else o.appendChild(n);const i={index:-1,onChangeListeners:[]},c=(a,u)=>{const p=a.length;p===0&&(u=-1),i.index=u>=0?u%p:p-1,i.onChangeListeners.forEach(B=>B())},l=()=>{i.index=-1,i.onChangeListeners.forEach(a=>a())},m=()=>i.index;return{element:n,hide:()=>{n.style.display="none",l()},show:()=>{n.style.display="inherit"},isOpen:()=>n.style.display!=="none",goDown:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u+1)},goUp:()=>{const a=Array.from(n.getElementsByClassName("ns-autocomplete-element")),u=m();c(a,u-1)},highlight:c,highlightedIndex:m,submitHighlightedItem:a=>{Array.from(n.querySelectorAll(".ns-autocomplete-element"))[a]?.click()},onHighlightChange:a=>{i.onChangeListeners.push(a)}}}function R(e,n){const t=document.createElement("div");return t.className="nosto-autocomplete-dropdown",{...H(e,t,n),element:t}}const y="nosto:search-js:history";function $(e,n,t){const o=document.createElement("div");return o.className="nosto-autocomplete-history",{...H(e,o,n),element:o,add:s=>{const c=(g.getLocalStorageItem(y)??[]).filter(l=>l!==s).slice(t?-t:0);c.push(s),g.setLocalStorageItem(y,c)},get:()=>(g.getLocalStorageItem(y)??[]).reverse().filter(i=>!!i)}}async function v(e,{config:n,dropdown:t,history:o,renderHistory:r,store:s}){const{historyEnabled:i,minQueryLength:c}=n;if(e.length<c&&i&&r&&!o.isOpen()){o.show();return}if(e.length<c)return;t.hide();const l=s.getState()?.query?.query;l&&l!==e&&await h.newSearch({config:n,store:s},{query:e}),t.show()}async function F(e,n){const{config:t,renderHistory:o,history:r}=n,{historyEnabled:s,minQueryLength:i}=t;if(!o||e.length>=i||!s||r.isOpen())return;const c=x(n);r.onHighlightChange(()=>{c(o,r.element)}),r.show();const l=P.measure("renderHistory");c(o,r.element),l()}async function k(e,{config:n,dropdown:t,history:o,store:r,debouncer:s}){const{minQueryLength:i,historyEnabled:c}=n;if(e.length<i&&!c){t.hide(),o.hide();return}if(e.length<i&&c){t.hide(),o.show();return}o.hide(),s(async()=>{h.newSearch({config:n,store:r},{query:e}),t.show()})}function Q(e,n,t){const{config:o,debouncer:r}=t;if(r(()=>{}),e.length>=o.minQueryLength)return L(n,t.dropdown,t.history);if(o.historyEnabled)return L(n,t.history,t.dropdown)}function L(e,n,t){if(!n.isOpen()&&e==="ArrowDown"){n.show(),t.hide();return}if(e==="Escape"&&n.hide(),!!n.isOpen()){if(e==="ArrowDown")n.goDown();else if(e==="ArrowUp")n.goUp();else if(e==="Enter"){const o=n.highlightedIndex();return o>=0&&n.submitHighlightedItem(o),n.hide(),o>=0}}}function M(e,{config:n,dropdown:t,history:o,onNavigateToSearch:r,store:s}){t.hide(),o.hide(),!(e.length<n.minQueryLength)&&(o.add(e),s.updateState({historyItems:o.get()}),r?.({query:e}))}async function U(e,n){const{inputCssSelector:t,timeout:o}=e,r=S(t).selector,s=await N({selector:r,timeout:o});if(s.length===0)throw new Error(`No elements found for selector: ${r}`);s.forEach(i=>{K(i,e,n)})}async function K(e,n,t){const{config:o,dropdownCssSelector:r}=n,s=R(e,r),i=$(e,r,o.historySize),c={...n,input:e,dropdown:s,history:i,store:t,debouncer:D(o.debounceDelay)};z(c),e.setAttribute("data-nosto-element","search-input"),t.updateState({historyItems:i.get()}),b.disableNativeAutocomplete(e),t.onInit(()=>{_(c)}),b.bindInput(e,{onInput:l=>k(l,c),onFocus:l=>F(l,c),onClick:l=>v(l,c),onSubmit:l=>M(l,c),onKeyDown:(l,m)=>Q(l,m,c)}),A(i.element,i.hide),A(s.element,s.hide),q([i.element,e],i.hide),q([s.element,e],s.hide)}function _(e){const{dropdown:n,renderAutocomplete:t}=e;if(!t)return;const o=x(e);n.onHighlightChange(()=>{o(t,n.element)});const r=P.measure("renderAutocomplete");o(t,n.element),r()}async function z(e){const{input:n,renderSpeechToText:t,config:o,store:r}=e;if(!t)return;const s="ns-autocomplete-voice-position";if(!!n.parentElement?.querySelector(`.${s}`))return;const c=document.createElement("div");c.className=s,n.insertAdjacentElement("afterend",c);const l=await t();C.render(d.u(f.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:o,store:r,children:l})}),c)}function x(e){const{config:n,store:t}=e;return(o,r)=>C.render(d.u(f.ErrorBoundary,{children:d.u(w.AutocompletePageProvider,{config:n,store:t,children:o()})}),r)}async function j({cssSelector:e,timeout:n,renderComponent:t}){const o=S(e).selector,r=await N({selector:o,timeout:n??100});if(r.length===0)throw new Error(`No elements found for selector: ${o}`);r.length>1&&g.logger.warn(`Multiple (${r.length}) elements found for selector: ${o}`),C.render(t(),r[0])}async function G(e,n){const{render:t}=e,o=await t();j({...e,renderComponent:()=>d.u(f.ErrorBoundary,{children:d.u(T.CategoryPageProvider,{store:n,config:e.config,children:o})})})}async function J(e,n){const{render:t}=e,o=await t();j({...e,renderComponent:()=>d.u(f.ErrorBoundary,{children:d.u(I.SearchPageProvider,{store:n,config:e.config,children:o})})})}async function V({autocomplete:e,category:n,serp:t}){const o={};if(e){const r=h.createStore({query:e.query});await U({...e,config:w.makeAutocompleteConfig(e.config)},r),o.autocomplete={store:r}}if(n){const r=h.createStore({query:n.query});await G({...n,config:T.makeCategoryConfig(n.config)},r),o.category={store:r}}if(t){const r=h.createStore({query:t.query});await J({...t,config:I.makeSerpConfig(t.config)},r),o.serp={store:r}}return o}exports.init=V;
@@ -1,14 +1,13 @@
1
- import { A as L, m as j } from "../../AutocompletePageProvider-CJb7OEAr.js";
2
- import { C as O, m as R } from "../../CategoryPageProvider-BGqhQtdT.js";
3
- import { n as T, c as p } from "../../useActions-DoZCMPfW.js";
4
- import { S as $, m as F } from "../../SerpPageProvider-wkZs_QWn.js";
1
+ import { A as L, m as j } from "../../AutocompletePageProvider-BP5rBIA9.js";
2
+ import { C as O, m as R } from "../../CategoryPageProvider-AVXodPE4.js";
3
+ import { n as T, c as p } from "../../useActions-B50noHCX.js";
4
+ import { S as $, m as F } from "../../SerpPageProvider-DotM1MdN.js";
5
5
  import { u as d } from "../../jsxRuntime.module-Bzuv3cXw.js";
6
- import { E as h } from "../../ErrorBoundary-DTRm_60r.js";
6
+ import { E as h } from "../../ErrorBoundary-BgL4oJs4.js";
7
7
  import { d as k, b as B } from "../../disableNativeAutocomplete-Bkta_WR2.js";
8
- import { a as I } from "../../unique-Cv2g464w.js";
8
+ import { a as I } from "../../unique-GK46uURP.js";
9
9
  import { render as y } from "preact";
10
- import { l as q } from "../../logger-_fg_Za9y.js";
11
- import { g as w, a as Q } from "../../search-xLgL6P5R.js";
10
+ import { l as q, g as w, s as Q } from "../../storage-KGxdBTgd.js";
12
11
  function U(e) {
13
12
  let n;
14
13
  return (t) => {
@@ -288,7 +287,7 @@ async function ne(e, n) {
288
287
  renderComponent: () => /* @__PURE__ */ d(h, { children: /* @__PURE__ */ d($, { store: n, config: e.config, children: o }) })
289
288
  });
290
289
  }
291
- async function he({ autocomplete: e, category: n, serp: t }) {
290
+ async function ue({ autocomplete: e, category: n, serp: t }) {
292
291
  const o = {};
293
292
  if (e) {
294
293
  const r = p({ query: e.query });
@@ -323,5 +322,5 @@ async function he({ autocomplete: e, category: n, serp: t }) {
323
322
  return o;
324
323
  }
325
324
  export {
326
- he as init
325
+ ue as init
327
326
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-B6FFW8xI.cjs"),r=require("../../InfiniteScrollWithObserver-3Mj6PB5H.cjs"),t=require("../../useLoadMore-DfdmCB8L.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../useActions-CG4NaniG.cjs"),r=require("../../InfiniteScrollWithObserver-CxHK-Vzv.cjs"),t=require("../../useLoadMore-EOcCFqU8.cjs");exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;exports.getNextPageQuery=t.getNextPageQuery;
@@ -1,6 +1,6 @@
1
- import { n as t, u as a } from "../../useActions-DoZCMPfW.js";
2
- import { I as s, i } from "../../InfiniteScrollWithObserver-aOddKvLF.js";
3
- import { g as p } from "../../useLoadMore-DQb45K2a.js";
1
+ import { n as t, u as a } from "../../useActions-B50noHCX.js";
2
+ import { I as s, i } from "../../InfiniteScrollWithObserver-D0hbwNoK.js";
3
+ import { g as p } from "../../useLoadMore-QY3ve8Xg.js";
4
4
  export {
5
5
  s as InfiniteScrollWithObserver,
6
6
  p as getNextPageQuery,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-B6FFW8xI.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-D5cD0ttm.cjs"),P="nosto:search-js:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../../jsxRuntime.module-B3sGoTIU.cjs"),l=require("../../index.es-Dp6Iaxz3.cjs"),u=require("../../BaseElement-CIHACCWd.cjs"),S=require("../../useActions-CG4NaniG.cjs"),d=require("preact/hooks"),g=require("../../SerpPageProvider-BkFNjOHz.cjs"),P="nosto:search-js:scrollPos";function m(){window.sessionStorage.setItem(P,window.scrollY.toString())}function p({children:s,hit:e,componentProps:t,as:n}){const{pageType:o}=S.useConfig(),r=o==="autocomplete"?void 0:o==="search"?"serp":o,c=d.useCallback(()=>{e&&r&&l.s(i=>i.recordSearchClick(r,e)),m()},[e,r]);return a.u(u.BaseElement,{as:n,onClick:c,componentProps:t,children:s})}exports.SearchPageProvider=g.SearchPageProvider;exports.SerpElement=p;
@@ -1,9 +1,9 @@
1
1
  import { u as i } from "../../jsxRuntime.module-Bzuv3cXw.js";
2
2
  import { s as l } from "../../index.es-XNBESE3P.js";
3
3
  import { B as m } from "../../BaseElement-DD_4UwDm.js";
4
- import { b as p } from "../../useActions-DoZCMPfW.js";
4
+ import { b as p } from "../../useActions-B50noHCX.js";
5
5
  import { useCallback as f } from "preact/hooks";
6
- import { S as h } from "../../SerpPageProvider-wkZs_QWn.js";
6
+ import { S as h } from "../../SerpPageProvider-DotM1MdN.js";
7
7
  const S = "nosto:search-js:scrollPos";
8
8
  function g() {
9
9
  window.sessionStorage.setItem(S, window.scrollY.toString());
@@ -0,0 +1 @@
1
+ "use strict";const g=require("./index.es-Dp6Iaxz3.cjs"),o=require("./storage-BQdl3oEs.cjs");async function y(t,{hitDecorators:e,...n},s){const r=await s(t,n);if(!r.products?.hits?.length||!e?.length)return r;const c=i=>e.reduce((u,a)=>a(u),i);return{...r,products:{...r.products,hits:r.products.hits.map(c)}}}const h="nosto:search-js:cache",m=60*1e3;function S(t,e){o.setSessionStorageItem(h,{query:t,result:e,created:Date.now()})}function C(t){const e=o.getSessionStorageItem(h);if(!e||!R(e))return null;const n=l(e.query);return!o.isEqual(l(t),n)||Date.now()-e.created>m?null:e.result}function l(t){const e={...t,time:void 0,products:{...t.products,size:void 0}};return JSON.parse(JSON.stringify(e))}function R(t){return typeof t=="object"&&t!==null&&"query"in t&&"result"in t&&"created"in t}async function b(t,{usePersistentCache:e,...n},s){if(!e)return s(t,n);const r=await k(t,n,s);return S(t,r),r}async function k(t,e,n){const{from:s=0,size:r=0}=t.products||{},c=C(t);if(!c)return await n(t,e);const i=c?.products?.size??0,u=c?.products?.hits??[];if(r===i)return c;if(r<i)return{...c,products:{...c.products,size:r,hits:u.slice(0,r),total:c.products?.total||0}};const a=r-u.length,p=s>0?s+1:r-a,w={...t,products:{...t.products,from:p,size:a}},f=await n(w,e);return{...c,products:{...c.products,size:r,hits:[...c.products?.hits||[],...f.products?.hits||[]],total:f.products?.total||0}}}const T=3e4,d=new Map;function z(t,e){const n=d.get(t);if(!n)return;const s=Date.now()-n.created>T,r=o.isEqual(e,n.query);if(s||!r){d.delete(t);return}return n.result}function E(t,e,n){d.set(t,{query:e,result:n,created:Date.now()})}async function _(t,e,n){if(!e.useMemoryCache)return n(t,e);const s=JSON.stringify(t),r=z(s,t);if(r)return r;const c=await n(t,e);return E(s,t,c),c}async function N(t,e,n){if(!e.redirect)return n(t,e);const s=await n(t,e);if(s.keywords?.hits?.length){const r=s.keywords.hits.find(c=>c.keyword===t.query&&c._redirect);r&&r._redirect&&(window.location.href=r._redirect)}return s}function W(t){return new Promise(e=>setTimeout(e,t))}async function D(t,{maxRetries:e=0,retryInterval:n=0,...s},r){let c=0;for(;;)try{return await r(t,s)}catch(i){if(c>=e)throw i;if(!M(i))throw o.logger.info("Skipping retry logic for",i),i;c++,await W(n)}}function M(t){return!t||typeof t!="object"?!1:!("status"in t)||O(t.status)}function O(t){return typeof t=="number"&&(t<400||t>=500)}async function j(t,e={}){const n=await new Promise(g.s);return J(n.search,D,N,_,b,y)(t,e)}function J(t,...e){return e.reduce((n,s)=>(r,c)=>s(r,c,n),t)}exports.search=j;
@@ -0,0 +1,156 @@
1
+ import { s as m } from "./index.es-XNBESE3P.js";
2
+ import { d as g, b as y, i as l, l as S } from "./storage-KGxdBTgd.js";
3
+ async function C(t, { hitDecorators: e, ...n }, s) {
4
+ const r = await s(t, n);
5
+ if (!r.products?.hits?.length || !e?.length)
6
+ return r;
7
+ const c = (o) => e.reduce((i, a) => a(i), o);
8
+ return {
9
+ ...r,
10
+ products: {
11
+ ...r.products,
12
+ hits: r.products.hits.map(c)
13
+ }
14
+ };
15
+ }
16
+ const h = "nosto:search-js:cache", R = 60 * 1e3;
17
+ function b(t, e) {
18
+ g(h, { query: t, result: e, created: Date.now() });
19
+ }
20
+ function k(t) {
21
+ const e = y(h);
22
+ if (!e || !T(e))
23
+ return null;
24
+ const n = d(e.query);
25
+ return !l(d(t), n) || Date.now() - e.created > R ? null : e.result;
26
+ }
27
+ function d(t) {
28
+ const e = {
29
+ ...t,
30
+ time: void 0,
31
+ products: {
32
+ ...t.products,
33
+ size: void 0
34
+ }
35
+ };
36
+ return JSON.parse(JSON.stringify(e));
37
+ }
38
+ function T(t) {
39
+ return typeof t == "object" && t !== null && "query" in t && "result" in t && "created" in t;
40
+ }
41
+ async function z(t, { usePersistentCache: e, ...n }, s) {
42
+ if (!e)
43
+ return s(t, n);
44
+ const r = await E(t, n, s);
45
+ return b(t, r), r;
46
+ }
47
+ async function E(t, e, n) {
48
+ const { from: s = 0, size: r = 0 } = t.products || {}, c = k(t);
49
+ if (!c)
50
+ return await n(t, e);
51
+ const o = c?.products?.size ?? 0, i = c?.products?.hits ?? [];
52
+ if (r === o)
53
+ return c;
54
+ if (r < o)
55
+ return {
56
+ ...c,
57
+ products: {
58
+ ...c.products,
59
+ size: r,
60
+ hits: i.slice(0, r),
61
+ total: c.products?.total || 0
62
+ }
63
+ };
64
+ const a = r - i.length, p = s > 0 ? s + 1 : r - a, w = {
65
+ ...t,
66
+ products: {
67
+ ...t.products,
68
+ from: p,
69
+ size: a
70
+ }
71
+ }, f = await n(w, e);
72
+ return {
73
+ ...c,
74
+ products: {
75
+ ...c.products,
76
+ size: r,
77
+ hits: [...c.products?.hits || [], ...f.products?.hits || []],
78
+ total: f.products?.total || 0
79
+ }
80
+ };
81
+ }
82
+ const N = 3e4, u = /* @__PURE__ */ new Map();
83
+ function W(t, e) {
84
+ const n = u.get(t);
85
+ if (!n) return;
86
+ const s = Date.now() - n.created > N, r = l(e, n.query);
87
+ if (s || !r) {
88
+ u.delete(t);
89
+ return;
90
+ }
91
+ return n.result;
92
+ }
93
+ function _(t, e, n) {
94
+ u.set(t, {
95
+ query: e,
96
+ result: n,
97
+ created: Date.now()
98
+ });
99
+ }
100
+ async function D(t, e, n) {
101
+ if (!e.useMemoryCache)
102
+ return n(t, e);
103
+ const s = JSON.stringify(t), r = W(s, t);
104
+ if (r) return r;
105
+ const c = await n(t, e);
106
+ return _(s, t, c), c;
107
+ }
108
+ async function M(t, e, n) {
109
+ if (!e.redirect)
110
+ return n(t, e);
111
+ const s = await n(t, e);
112
+ if (s.keywords?.hits?.length) {
113
+ const r = s.keywords.hits.find((c) => c.keyword === t.query && c._redirect);
114
+ r && r._redirect && (window.location.href = r._redirect);
115
+ }
116
+ return s;
117
+ }
118
+ function O(t) {
119
+ return new Promise((e) => setTimeout(e, t));
120
+ }
121
+ async function j(t, { maxRetries: e = 0, retryInterval: n = 0, ...s }, r) {
122
+ let c = 0;
123
+ for (; ; )
124
+ try {
125
+ return await r(t, s);
126
+ } catch (o) {
127
+ if (c >= e)
128
+ throw o;
129
+ if (!J(o))
130
+ throw S.info("Skipping retry logic for", o), o;
131
+ c++, await O(n);
132
+ }
133
+ }
134
+ function J(t) {
135
+ return !t || typeof t != "object" ? !1 : !("status" in t) || V(t.status);
136
+ }
137
+ function V(t) {
138
+ return typeof t == "number" && (t < 400 || t >= 500);
139
+ }
140
+ async function K(t, e = {}) {
141
+ const n = await new Promise(m);
142
+ return x(
143
+ n.search,
144
+ j,
145
+ M,
146
+ D,
147
+ z,
148
+ C
149
+ )(t, e);
150
+ }
151
+ function x(t, ...e) {
152
+ return e.reduce((n, s) => (r, c) => s(r, c, n), t);
153
+ }
154
+ export {
155
+ K as s
156
+ };
@@ -0,0 +1 @@
1
+ "use strict";const I=require("./index.es-Dp6Iaxz3.cjs"),u=e=>String(e)==="[object Object]";function c(e){if(!u(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!u(r)||!r.hasOwnProperty("isPrototypeOf"))}function g(e,t){if(e===t)return!0;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(Array.isArray(e)&&Array.isArray(t))return e.length!==t.length?!1:e.every((r,n)=>g(r,t[n]));if(c(e)&&c(t)){const r=Object.entries(e);return r.length!==Object.keys(t).length?!1:r.every(([n,y])=>g(y,t[n]))}return!1}function l(){const e=new Map;return{getItem(t){return e.get(t)??null},setItem(t,r){e.set(t,r)},removeItem(t){e.delete(t)},clear(){e.clear()},key(t){return Array.from(e.keys())[t]??null},get length(){return e.size}}}function a(e){return(...t)=>{I.s(r=>{(r.internal.context.mode.isPreview()?console[e]:r.internal.logger[e])(...t)})}}const i={debug:a("debug"),info:a("info"),warn:a("warn"),error:a("error")};function f(e,t,r){try{const n=JSON.stringify(t);r.setItem(e,n)}catch(n){i.warn(n)}}function m(e,t){try{const r=t.getItem(e);if(r)return JSON.parse(r)}catch(r){i.warn(r)}}function S(e,t){try{t.removeItem(e)}catch(r){i.warn(r)}}let o,s;try{o=window.localStorage,s=window.sessionStorage}catch(e){i.warn(e),o=l(),s=l()}function w(e,t){f(e,t,o)}function h(e,t){f(e,t,s)}function O(e){return m(e,o)}function d(e){return m(e,s)}function v(e){S(e,o)}function j(e){S(e,s)}exports.getLocalStorageItem=O;exports.getSessionStorageItem=d;exports.isEqual=g;exports.isPlainObject=c;exports.logger=i;exports.removeLocalStorageItem=v;exports.removeSessionStorageItem=j;exports.setLocalStorageItem=w;exports.setSessionStorageItem=h;
@@ -0,0 +1,119 @@
1
+ import { s as I } from "./index.es-XNBESE3P.js";
2
+ const c = (e) => String(e) === "[object Object]";
3
+ function g(e) {
4
+ if (!c(e))
5
+ return !1;
6
+ const t = e.constructor;
7
+ if (t === void 0)
8
+ return !0;
9
+ const r = t.prototype;
10
+ return !(!c(r) || !r.hasOwnProperty("isPrototypeOf"));
11
+ }
12
+ function u(e, t) {
13
+ if (e === t)
14
+ return !0;
15
+ if (e instanceof Date && t instanceof Date)
16
+ return e.getTime() === t.getTime();
17
+ if (Array.isArray(e) && Array.isArray(t))
18
+ return e.length !== t.length ? !1 : e.every((r, n) => u(r, t[n]));
19
+ if (g(e) && g(t)) {
20
+ const r = Object.entries(e);
21
+ return r.length !== Object.keys(t).length ? !1 : r.every(([n, S]) => u(S, t[n]));
22
+ }
23
+ return !1;
24
+ }
25
+ function f() {
26
+ const e = /* @__PURE__ */ new Map();
27
+ return {
28
+ getItem(t) {
29
+ return e.get(t) ?? null;
30
+ },
31
+ setItem(t, r) {
32
+ e.set(t, r);
33
+ },
34
+ removeItem(t) {
35
+ e.delete(t);
36
+ },
37
+ clear() {
38
+ e.clear();
39
+ },
40
+ key(t) {
41
+ return Array.from(e.keys())[t] ?? null;
42
+ },
43
+ get length() {
44
+ return e.size;
45
+ }
46
+ };
47
+ }
48
+ function a(e) {
49
+ return (...t) => {
50
+ I((r) => {
51
+ (r.internal.context.mode.isPreview() ? console[e] : r.internal.logger[e])(...t);
52
+ });
53
+ };
54
+ }
55
+ const i = {
56
+ debug: a("debug"),
57
+ info: a("info"),
58
+ warn: a("warn"),
59
+ error: a("error")
60
+ };
61
+ function l(e, t, r) {
62
+ try {
63
+ const n = JSON.stringify(t);
64
+ r.setItem(e, n);
65
+ } catch (n) {
66
+ i.warn(n);
67
+ }
68
+ }
69
+ function m(e, t) {
70
+ try {
71
+ const r = t.getItem(e);
72
+ if (r)
73
+ return JSON.parse(r);
74
+ } catch (r) {
75
+ i.warn(r);
76
+ }
77
+ }
78
+ function y(e, t) {
79
+ try {
80
+ t.removeItem(e);
81
+ } catch (r) {
82
+ i.warn(r);
83
+ }
84
+ }
85
+ let o, s;
86
+ try {
87
+ o = window.localStorage, s = window.sessionStorage;
88
+ } catch (e) {
89
+ i.warn(e), o = f(), s = f();
90
+ }
91
+ function h(e, t) {
92
+ l(e, t, o);
93
+ }
94
+ function d(e, t) {
95
+ l(e, t, s);
96
+ }
97
+ function p(e) {
98
+ return m(e, o);
99
+ }
100
+ function O(e) {
101
+ return m(e, s);
102
+ }
103
+ function v(e) {
104
+ y(e, o);
105
+ }
106
+ function j(e) {
107
+ y(e, s);
108
+ }
109
+ export {
110
+ g as a,
111
+ O as b,
112
+ j as c,
113
+ d,
114
+ p as g,
115
+ u as i,
116
+ i as l,
117
+ v as r,
118
+ h as s
119
+ };
@@ -0,0 +1 @@
1
+ "use strict";const u=require("./storage-BQdl3oEs.cjs");function s(...e){return i(...e)}function i(...e){return e.reduce((r,n)=>c(r,n))}function c(e,r){return u.isPlainObject(e)&&u.isPlainObject(r)?Object.entries(r).reduce((n,[t,o])=>(n[t]=c(n[t],o),n),{...e}):u.isPlainObject(e)?e:r}function f(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,n)=>r.concat(n),[])}const a="nosto.search.";function d(e){const r=`${a}${e}`;window.performance?.mark(`${r}.start`)}function m(e){const r=`${a}${e}`;window.performance?.mark(`${r}.end`),window.performance?.measure(r,`${r}.start`,`${r}.end`)}function l(e){return d(e),()=>m(e)}function $(e){return Array.from(new Set(e))}exports.deepMerge=s;exports.deepMergePlain=i;exports.measure=l;exports.mergeArrays=f;exports.unique=$;
@@ -1,4 +1,4 @@
1
- import { a as u } from "./logger-_fg_Za9y.js";
1
+ import { a as u } from "./storage-KGxdBTgd.js";
2
2
  function d(...r) {
3
3
  return c(...r);
4
4
  }
@@ -1,8 +1,8 @@
1
1
  import { createContext as S } from "preact";
2
2
  import { useContext as k, useMemo as I, useCallback as d } from "preact/hooks";
3
- import { b as w, u as M, a as f, d as h, m as E } from "./unique-Cv2g464w.js";
4
- import { i as b, l as A } from "./logger-_fg_Za9y.js";
5
- import { s as U } from "./search-xLgL6P5R.js";
3
+ import { b as w, u as M, a as f, d as h, m as E } from "./unique-GK46uURP.js";
4
+ import { i as b, l as A } from "./storage-KGxdBTgd.js";
5
+ import { s as U } from "./search-CUKuaCNR.js";
6
6
  const q = S(null);
7
7
  function p() {
8
8
  const e = k(q);
@@ -0,0 +1 @@
1
+ "use strict";const w=require("preact"),f=require("preact/hooks"),u=require("./unique-Dm62pFFG.cjs"),C=require("./storage-BQdl3oEs.cjs"),E=require("./search-BXRj3vpd.cjs"),k=w.createContext(null);function p(){const e=f.useContext(k);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function A(){const e=p();if(e.pageType!=="search")throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");return e}function I(){const e=p();if(e.pageType!=="category")throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");return e}function U(){const e=p();if(e.pageType!=="autocomplete")throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");return e}function b(e,r={}){const t=new Map;let n=u.deepMergePlain(e,r??{});const i=u.deepMergePlain(e,r);function c(l){n=l(n);for(const g of t.values())g(n)}function s(l){c(g=>({...g,...l}))}function a(){return n}function o(){return structuredClone(i)}function d(l,g){let m=l(n);t.set(g,M=>{const y=l(M);C.isEqual(y,m)||(m=y,g(y))})}function T(l){d(g=>g.initialized,g=>{g&&l()})}function q(l){t.delete(l)}return{updateState:s,getState:a,getInitialState:o,onChange:d,onInit:T,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function P(e={}){return b(v,e)}const F=w.createContext(P());function Q(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:z,...r.products},...r.keywords?{keywords:{...r.keywords,fields:u.unique([...K,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const z=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],K=["keyword","_redirect"];async function S(e,r,t){const n=u.measure("newSearch"),i=e.config.pageType,c=i==="search"?"serp":i,s=u.deepMerge(e.store.getInitialState().query,r),a=u.deepMerge(e.config.search,t,{track:c,redirect:i!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,a),e.store.updateState({query:s,loading:!0,initialized:!0});const o=e.config.queryModifications({...s,products:{...s.products,filter:u.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},i);try{const d=await E.search(Q(e.config.pageType,o),a);e.store.updateState({response:d,loading:!1})}catch(d){C.logger.error("Search action failed",d),e.config.onSearchError?.(d,o,a,i)}n()}async function h(e,r,t){const n=u.measure("updateSearch"),i=u.deepMerge(e.store.getState().query,{products:{from:0}},r);await S(e,i,t),n()}async function N(e,r,t){const n=u.measure("replaceFilter"),i=e.store.getState().query.products?.filter,c=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await h(e,{products:{filter:[...i?.filter(s=>s.field!==r)??[],...c]}}),n()}async function x(e,r,t,n){const i=u.measure("toggleProductFilter"),c=e.store.getState().query.products?.filter,s=c?.find(o=>o.value instanceof Array&&o.field===r),a=s?.value?{...s,value:[...s.value.filter(o=>!C.isEqual(o,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await h(e,{products:{filter:[...c?.filter(o=>o!==s)??[],...a?.value?.length?[a]:[]]}}),i()}function B(){const e=p(),r=f.useContext(F),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((a,o)=>S(t,a,o),[t]),i=f.useCallback((a,o)=>h(t,a,o),[t]),c=f.useCallback((a,o,d)=>x(t,a,o,d),[t]),s=f.useCallback((a,o)=>N(t,a,o),[t]);return{newSearch:n,updateSearch:i,toggleProductFilter:c,replaceFilter:s}}exports.ConfigContext=k;exports.StoreContext=F;exports.createExtendableStore=b;exports.createStore=P;exports.defaultState=v;exports.newSearch=S;exports.updateSearch=h;exports.useActions=B;exports.useAutocompleteConfig=U;exports.useCategoryConfig=I;exports.useConfig=p;exports.useSerpConfig=A;
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./useActions-CG4NaniG.cjs"),o=require("./storage-BQdl3oEs.cjs"),i=require("preact/hooks"),s="nosto:search-js:history";function u({value:e,historySize:t,store:r}){const l=(o.getLocalStorageItem(s)??[]).filter(y=>y!==e).concat(e),n=t?l.slice(-t):[];o.setLocalStorageItem(s,n),r.updateState({historyItems:n.reverse()})}function d(){return(o.getLocalStorageItem(s)??[]).slice().reverse().filter(t=>!!t)}function g(){const e=i.useContext(a.StoreContext),{historySize:t}=a.useAutocompleteConfig();return{addQuery:i.useCallback(c=>{u({value:c,historySize:t,store:e})},[t,e])}}exports.addToHistory=u;exports.getSavedHistory=d;exports.useHistory=g;
@@ -1,5 +1,5 @@
1
- import { S as l, a as m } from "./useActions-DoZCMPfW.js";
2
- import { g as c, a as u } from "./search-xLgL6P5R.js";
1
+ import { S as l, a as m } from "./useActions-B50noHCX.js";
2
+ import { g as c, s as u } from "./storage-KGxdBTgd.js";
3
3
  import { useContext as y, useCallback as f } from "preact/hooks";
4
4
  const e = "nosto:search-js:history";
5
5
  function g({ value: o, historySize: t, store: s }) {
@@ -1 +1 @@
1
- "use strict";const n=require("./useActions-B6FFW8xI.cjs"),r=require("preact/hooks"),i=require("./isBot-CM2hS03W.cjs");function c(e=f){const t=r.useContext(n.StoreContext),[o,s]=r.useState(e(t.getState()));return t.onChange(e,s),r.useEffect(()=>()=>t.clearOnChange(s),[t]),o}const f=e=>e;function a({from:e,size:t,pageSize:o}){return i.isBot()?{products:{from:e+o}}:{products:{size:t+o}}}function d(e=24){const{from:t,size:o}=c(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:s}=n.useActions();return{loadMore:r.useCallback(async()=>{await s(a({from:t,size:o,pageSize:e}))},[t,o,e,s])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
1
+ "use strict";const n=require("./useActions-CG4NaniG.cjs"),r=require("preact/hooks"),i=require("./isBot-CM2hS03W.cjs");function c(e=f){const t=r.useContext(n.StoreContext),[o,s]=r.useState(e(t.getState()));return t.onChange(e,s),r.useEffect(()=>()=>t.clearOnChange(s),[t]),o}const f=e=>e;function a({from:e,size:t,pageSize:o}){return i.isBot()?{products:{from:e+o}}:{products:{size:t+o}}}function d(e=24){const{from:t,size:o}=c(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:s}=n.useActions();return{loadMore:r.useCallback(async()=>{await s(a({from:t,size:o,pageSize:e}))},[t,o,e,s])}}exports.getNextPageQuery=a;exports.useLoadMore=d;exports.useNostoAppState=c;
@@ -1,4 +1,4 @@
1
- import { S as n, h as u } from "./useActions-DoZCMPfW.js";
1
+ import { S as n, h as u } from "./useActions-B50noHCX.js";
2
2
  import { useContext as a, useState as c, useEffect as i, useCallback as f } from "preact/hooks";
3
3
  import { i as m } from "./isBot-0jVC54QA.js";
4
4
  function l(t = p) {
@@ -0,0 +1,5 @@
1
+ /**
2
+ * In-memory implementation of the Storage interface.
3
+ * Used as a fallback when localStorage or sessionStorage is unavailable.
4
+ */
5
+ export declare function createInMemoryStorage(): Storage;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../disableNativeAutocomplete-DI6zaZII.cjs"),t=require("../cl-B00bZ7jc.cjs"),e=require("../unique-BXXNictB.cjs"),u=require("../isBot-CM2hS03W.cjs"),r=require("../logger-Boh_C6Bz.cjs"),s=require("../parseNumber-FsZ8w61u.cjs"),o=require("../pick-rYi1lc2m.cjs");exports.bindInput=i.bindInput;exports.disableNativeAutocomplete=i.disableNativeAutocomplete;exports.cl=t.cl;exports.deepMerge=e.deepMerge;exports.measure=e.measure;exports.mergeArrays=e.mergeArrays;exports.unique=e.unique;exports.isBot=u.isBot;exports.isEqual=r.isEqual;exports.isPlainObject=r.isPlainObject;exports.logger=r.logger;exports.parseNumber=s.parseNumber;exports.pick=o.pick;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../disableNativeAutocomplete-DI6zaZII.cjs"),o=require("../cl-B00bZ7jc.cjs"),t=require("../unique-Dm62pFFG.cjs"),s=require("../isBot-CM2hS03W.cjs"),e=require("../storage-BQdl3oEs.cjs"),i=require("../parseNumber-FsZ8w61u.cjs"),a=require("../pick-rYi1lc2m.cjs");exports.bindInput=r.bindInput;exports.disableNativeAutocomplete=r.disableNativeAutocomplete;exports.cl=o.cl;exports.deepMerge=t.deepMerge;exports.measure=t.measure;exports.mergeArrays=t.mergeArrays;exports.unique=t.unique;exports.isBot=s.isBot;exports.getLocalStorageItem=e.getLocalStorageItem;exports.getSessionStorageItem=e.getSessionStorageItem;exports.isEqual=e.isEqual;exports.isPlainObject=e.isPlainObject;exports.logger=e.logger;exports.removeLocalStorageItem=e.removeLocalStorageItem;exports.removeSessionStorageItem=e.removeSessionStorageItem;exports.setLocalStorageItem=e.setLocalStorageItem;exports.setSessionStorageItem=e.setSessionStorageItem;exports.parseNumber=i.parseNumber;exports.pick=a.pick;
@@ -12,5 +12,6 @@ export { parseNumber } from './src/parseNumber';
12
12
  export { measure } from './src/performance';
13
13
  export { pick } from './src/pick';
14
14
  export type { Simplify } from './src/simplify';
15
+ export { getLocalStorageItem, getSessionStorageItem, removeLocalStorageItem, removeSessionStorageItem, setLocalStorageItem, setSessionStorageItem } from './src/storage';
15
16
  export type { Unfreeze } from './src/types';
16
17
  export { unique } from './src/unique';
@@ -1,22 +1,28 @@
1
- import { b as r, d as s } from "../disableNativeAutocomplete-Bkta_WR2.js";
2
- import { c as p } from "../cl-CcykAxZN.js";
3
- import { d as m, a as i, m as u, u as f } from "../unique-Cv2g464w.js";
4
- import { i as x } from "../isBot-0jVC54QA.js";
5
- import { i as c, a as d, l as g } from "../logger-_fg_Za9y.js";
6
- import { p as q } from "../parseNumber-QA48nJLp.js";
7
- import { p as N } from "../pick-DReBictn.js";
1
+ import { b as s, d as o } from "../disableNativeAutocomplete-Bkta_WR2.js";
2
+ import { c as t } from "../cl-CcykAxZN.js";
3
+ import { d as i, a as p, m as g, u as l } from "../unique-GK46uURP.js";
4
+ import { i as S } from "../isBot-0jVC54QA.js";
5
+ import { g as f, b as n, i as x, a as I, l as b, r as d, c as v, s as L, d as q } from "../storage-KGxdBTgd.js";
6
+ import { p as N } from "../parseNumber-QA48nJLp.js";
7
+ import { p as k } from "../pick-DReBictn.js";
8
8
  export {
9
- r as bindInput,
10
- p as cl,
11
- m as deepMerge,
12
- s as disableNativeAutocomplete,
13
- x as isBot,
14
- c as isEqual,
15
- d as isPlainObject,
16
- g as logger,
17
- i as measure,
18
- u as mergeArrays,
19
- q as parseNumber,
20
- N as pick,
21
- f as unique
9
+ s as bindInput,
10
+ t as cl,
11
+ i as deepMerge,
12
+ o as disableNativeAutocomplete,
13
+ f as getLocalStorageItem,
14
+ n as getSessionStorageItem,
15
+ S as isBot,
16
+ x as isEqual,
17
+ I as isPlainObject,
18
+ b as logger,
19
+ p as measure,
20
+ g as mergeArrays,
21
+ N as parseNumber,
22
+ k as pick,
23
+ d as removeLocalStorageItem,
24
+ v as removeSessionStorageItem,
25
+ L as setLocalStorageItem,
26
+ q as setSessionStorageItem,
27
+ l as unique
22
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nosto/search-js",
3
- "version": "3.24.1",
3
+ "version": "3.24.4",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "files": [
@@ -97,14 +97,14 @@
97
97
  "prepare": "husky"
98
98
  },
99
99
  "devDependencies": {
100
- "@commitlint/cli": "^20.1.0",
101
- "@commitlint/config-conventional": "^20.0.0",
100
+ "@commitlint/cli": "^20.2.0",
101
+ "@commitlint/config-conventional": "^20.2.0",
102
102
  "@nosto/nosto-js": "^2.9.3",
103
103
  "@testing-library/dom": "^10.4.1",
104
104
  "@types/dom-speech-recognition": "^0.0.7",
105
105
  "@types/eslint-config-prettier": "^6.11.3",
106
- "@types/node": "^24.10.0",
107
- "@vitest/coverage-v8": "^4.0.8",
106
+ "@types/node": "^24.10.1",
107
+ "@vitest/coverage-v8": "^4.0.15",
108
108
  "concurrently": "^9.2.1",
109
109
  "copyfiles": "^2.4.1",
110
110
  "eslint": "^9.39.1",
@@ -117,16 +117,20 @@
117
117
  "eslint-plugin-unused-imports": "^4.3.0",
118
118
  "husky": "^9.1.7",
119
119
  "isbot": "^5.1.32",
120
- "jsdom": "^27.2.0",
121
- "prettier": "^3.6.2",
122
- "typedoc": "^0.28.14",
120
+ "jsdom": "^27.3.0",
121
+ "prettier": "^3.7.4",
122
+ "typedoc": "^0.28.15",
123
123
  "typescript": "^5.9.3",
124
- "typescript-eslint": "^8.46.4",
125
- "vite": "^7.2.2",
124
+ "typescript-eslint": "^8.48.1",
125
+ "vite": "^7.2.7",
126
126
  "vite-plugin-dts": "^4.5.4",
127
127
  "vitest": "^4.0.7"
128
128
  },
129
129
  "publishConfig": {
130
130
  "access": "public"
131
+ },
132
+ "repository": {
133
+ "type": "git",
134
+ "url": "git+https://github.com/Nosto/search-js.git"
131
135
  }
132
136
  }
@@ -1 +0,0 @@
1
- "use strict";const e=require("./jsxRuntime.module-B3sGoTIU.cjs"),u=require("./logger-Boh_C6Bz.cjs"),n=require("preact"),t=require("preact/hooks");function s({children:o}){const[r]=t.useErrorBoundary();return r&&u.logger.error("Error caught in ErrorBoundary",r),e.u(n.Fragment,{children:o})}exports.ErrorBoundary=s;
@@ -1 +0,0 @@
1
- "use strict";const v=require("./jsxRuntime.module-B3sGoTIU.cjs"),d=require("./useLoadMore-DfdmCB8L.cjs"),N=require("./logger-Boh_C6Bz.cjs"),x=require("./pick-rYi1lc2m.cjs"),u=require("preact"),h=require("preact/hooks");function E(e,r){const t=r.products?.total??0,o=e.products?.from??0,n=e.products?.size??0;return t>0&&t>o+n}function A(){return!!(window.IntersectionObserver&&window.IntersectionObserverEntry&&"intersectionRatio"in window.IntersectionObserverEntry.prototype)}function M(e,r){for(var t in r)e[t]=r[t];return e}function f(e,r){for(var t in e)if(t!=="__source"&&!(t in r))return!0;for(var o in r)if(o!=="__source"&&e[o]!==r[o])return!0;return!1}function m(e,r){this.props=e,this.context=r}function U(e,r){function t(n){var s=this.props.ref,i=s==n.ref;return!i&&s&&(s.call?s(null):s.current=null),r?!r(this.props,n)||!i:f(this.props,n)}function o(n){return this.shouldComponentUpdate=t,u.createElement(e,n)}return o.displayName="Memo("+(e.displayName||e.name)+")",o.prototype.isReactComponent=!0,o.__f=!0,o}(m.prototype=new u.Component).isPureReactComponent=!0,m.prototype.shouldComponentUpdate=function(e,r){return f(this.props,e)||f(this.state,r)};var y=u.options.__b;u.options.__b=function(e){e.type&&e.type.__f&&e.ref&&(e.props.ref=e.ref,e.ref=null),y&&y(e)};var q=u.options.__e;u.options.__e=function(e,r,t,o){if(e.then){for(var n,s=r;s=s.__;)if((n=s.__c)&&n.__c)return r.__e==null&&(r.__e=t.__e,r.__k=t.__k),n.__c(e,r)}q(e,r,t,o)};var b=u.options.unmount;function P(e,r,t){return e&&(e.__c&&e.__c.__H&&(e.__c.__H.__.forEach(function(o){typeof o.__c=="function"&&o.__c()}),e.__c.__H=null),(e=M({},e)).__c!=null&&(e.__c.__P===t&&(e.__c.__P=r),e.__c=null),e.__k=e.__k&&e.__k.map(function(o){return P(o,r,t)})),e}function R(e,r,t){return e&&t&&(e.__v=null,e.__k=e.__k&&e.__k.map(function(o){return R(o,r,t)}),e.__c&&e.__c.__P===r&&(e.__e&&t.appendChild(e.__e),e.__c.__e=!0,e.__c.__P=t)),e}function p(){this.__u=0,this.o=null,this.__b=null}function S(e){var r=e.__.__c;return r&&r.__a&&r.__a(e)}function c(){this.i=null,this.l=null}u.options.unmount=function(e){var r=e.__c;r&&r.__R&&r.__R(),r&&32&e.__u&&(e.type=null),b&&b(e)},(p.prototype=new u.Component).__c=function(e,r){var t=r.__c,o=this;o.o==null&&(o.o=[]),o.o.push(t);var n=S(o.__v),s=!1,i=function(){s||(s=!0,t.__R=null,n?n(_):_())};t.__R=i;var _=function(){if(!--o.__u){if(o.state.__a){var l=o.state.__a;o.__v.__k[0]=R(l,l.__c.__P,l.__c.__O)}var a;for(o.setState({__a:o.__b=null});a=o.o.pop();)a.forceUpdate()}};o.__u++||32&r.__u||o.setState({__a:o.__b=o.__v.__k[0]}),e.then(i,i)},p.prototype.componentWillUnmount=function(){this.o=[]},p.prototype.render=function(e,r){if(this.__b){if(this.__v.__k){var t=document.createElement("div"),o=this.__v.__k[0].__c;this.__v.__k[0]=P(this.__b,t,o.__O=o.__P)}this.__b=null}var n=r.__a&&u.createElement(u.Fragment,null,e.fallback);return n&&(n.__u&=-33),[u.createElement(u.Fragment,null,r.__a?null:e.children),n]};var g=function(e,r,t){if(++t[1]===t[0]&&e.l.delete(r),e.props.revealOrder&&(e.props.revealOrder[0]!=="t"||!e.l.size))for(t=e.i;t;){for(;t.length>3;)t.pop()();if(t[1]<t[0])break;e.i=t=t[2]}};(c.prototype=new u.Component).__a=function(e){var r=this,t=S(r.__v),o=r.l.get(e);return o[0]++,function(n){var s=function(){r.props.revealOrder?(o.push(n),g(r,e,o)):n()};t?t(s):s()}},c.prototype.render=function(e){this.i=null,this.l=new Map;var r=u.toChildArray(e.children);e.revealOrder&&e.revealOrder[0]==="b"&&r.reverse();for(var t=r.length;t--;)this.l.set(r[t],this.i=[1,0,this.i]);return e.children},c.prototype.componentDidUpdate=c.prototype.componentDidMount=function(){var e=this;this.l.forEach(function(r,t){g(e,t,r)})};var I=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.element")||60103,W=/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/,V=/^on(Ani|Tra|Tou|BeforeInp|Compo)/,j=/[A-Z0-9]/g,F=typeof document<"u",H=function(e){return(typeof Symbol<"u"&&typeof Symbol()=="symbol"?/fil|che|rad/:/fil|che|ra/).test(e)};u.Component.prototype.isReactComponent={},["componentWillMount","componentWillReceiveProps","componentWillUpdate"].forEach(function(e){Object.defineProperty(u.Component.prototype,e,{configurable:!0,get:function(){return this["UNSAFE_"+e]},set:function(r){Object.defineProperty(this,e,{configurable:!0,writable:!0,value:r})}})});var k=u.options.event;function L(){}function z(){return this.cancelBubble}function B(){return this.defaultPrevented}u.options.event=function(e){return k&&(e=k(e)),e.persist=L,e.isPropagationStopped=z,e.isDefaultPrevented=B,e.nativeEvent=e};var D={enumerable:!1,configurable:!0,get:function(){return this.class}},O=u.options.vnode;u.options.vnode=function(e){typeof e.type=="string"&&function(r){var t=r.props,o=r.type,n={},s=o.indexOf("-")===-1;for(var i in t){var _=t[i];if(!(i==="value"&&"defaultValue"in t&&_==null||F&&i==="children"&&o==="noscript"||i==="class"||i==="className")){var l=i.toLowerCase();i==="defaultValue"&&"value"in t&&t.value==null?i="value":i==="download"&&_===!0?_="":l==="translate"&&_==="no"?_=!1:l[0]==="o"&&l[1]==="n"?l==="ondoubleclick"?i="ondblclick":l!=="onchange"||o!=="input"&&o!=="textarea"||H(t.type)?l==="onfocus"?i="onfocusin":l==="onblur"?i="onfocusout":V.test(i)&&(i=l):l=i="oninput":s&&W.test(i)?i=i.replace(j,"-$&").toLowerCase():_===null&&(_=void 0),l==="oninput"&&n[i=l]&&(i="oninputCapture"),n[i]=_}}o=="select"&&n.multiple&&Array.isArray(n.value)&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.value.indexOf(a.props.value)!=-1})),o=="select"&&n.defaultValue!=null&&(n.value=u.toChildArray(t.children).forEach(function(a){a.props.selected=n.multiple?n.defaultValue.indexOf(a.props.value)!=-1:n.defaultValue==a.props.value})),t.class&&!t.className?(n.class=t.class,Object.defineProperty(n,"className",D)):(t.className&&!t.class||t.class&&t.className)&&(n.class=n.className=t.className),r.props=n}(e),e.$$typeof=I,O&&O(e)};var C=u.options.__r;u.options.__r=function(e){C&&C(e),e.__c};var w=u.options.diffed;u.options.diffed=function(e){w&&w(e);var r=e.props,t=e.__e;t!=null&&e.type==="textarea"&&"value"in r&&r.value!==t.value&&(t.value=r.value==null?"":r.value)};function T({children:e,pageSize:r,observerOptions:t}){const o=h.useRef(null),{query:n,response:s}=d.useNostoAppState(_=>x.pick(_,"query","response")),{loadMore:i}=d.useLoadMore(r);return h.useEffect(()=>{let _,l;return E(n,s)&&(_=o.current,l=new IntersectionObserver(a=>{a[0]?.isIntersecting&&i()},t),_&&l.observe(_)),()=>{_&&l.unobserve(_)}},[s]),v.u(u.Fragment,{children:[e,v.u("div",{ref:o,style:{height:"1px"}})]})}const $=U(T,N.isEqual);exports.InfiniteScrollWithObserver=$;exports.hasMoreResults=E;exports.intersectionObserverSupported=A;
@@ -1 +0,0 @@
1
- "use strict";const c=require("./useActions-B6FFW8xI.cjs"),s=require("./eventBusSubscribe-oONOUGH8.cjs"),f=require("./index.es-Dp6Iaxz3.cjs"),b=require("./logger-Boh_C6Bz.cjs"),d=require("preact/hooks");function S(){const{pageType:e}=c.useConfig(),{newSearch:i,updateSearch:u,replaceFilter:o,toggleProductFilter:a}=c.useActions();return s.useEventBusSubscribe({event:"actions/newSearch",callback:({query:t,options:r,targetStore:n})=>{e===n&&i(t,r)}}),s.useEventBusSubscribe({event:"actions/updateSearch",callback:({query:t,options:r,targetStore:n})=>{e===n&&u(t,r)}}),s.useEventBusSubscribe({event:"actions/replaceFilter",callback:({field:t,value:r,targetStore:n})=>{e===n&&o(t,r)}}),s.useEventBusSubscribe({event:"actions/toggleProductFilter",callback:({field:t,value:r,active:n,targetStore:l})=>{e===l&&a(t,r,n)}}),null}function g(){d.useEffect(()=>{const e=window.setTimeout(()=>{b.logger.error("Nosto client script has not loaded after 3 seconds.")},3e3);f.s(()=>{window.clearTimeout(e)})},[])}const p={defaultCurrency:"EUR",queryModifications:e=>e};exports.StoreActionsListener=S;exports.defaultBaseConfig=p;exports.useCheckClientScript=g;
@@ -1 +0,0 @@
1
- "use strict";const f=require("./index.es-Dp6Iaxz3.cjs"),c=e=>String(e)==="[object Object]";function o(e){if(!c(e))return!1;const r=e.constructor;if(r===void 0)return!0;const t=r.prototype;return!(!c(t)||!t.hasOwnProperty("isPrototypeOf"))}function s(e,r){if(e===r)return!0;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();if(Array.isArray(e)&&Array.isArray(r))return e.length!==r.length?!1:e.every((t,n)=>s(t,r[n]));if(o(e)&&o(r)){const t=Object.entries(e);return t.length!==Object.keys(r).length?!1:t.every(([n,u])=>s(u,r[n]))}return!1}function i(e){return(...r)=>{f.s(t=>{(t.internal.context.mode.isPreview()?console[e]:t.internal.logger[e])(...r)})}}const g={debug:i("debug"),info:i("info"),warn:i("warn"),error:i("error")};exports.isEqual=s;exports.isPlainObject=o;exports.logger=g;
@@ -1,42 +0,0 @@
1
- import { s as u } from "./index.es-XNBESE3P.js";
2
- const i = (r) => String(r) === "[object Object]";
3
- function s(r) {
4
- if (!i(r))
5
- return !1;
6
- const e = r.constructor;
7
- if (e === void 0)
8
- return !0;
9
- const t = e.prototype;
10
- return !(!i(t) || !t.hasOwnProperty("isPrototypeOf"));
11
- }
12
- function f(r, e) {
13
- if (r === e)
14
- return !0;
15
- if (r instanceof Date && e instanceof Date)
16
- return r.getTime() === e.getTime();
17
- if (Array.isArray(r) && Array.isArray(e))
18
- return r.length !== e.length ? !1 : r.every((t, n) => f(t, e[n]));
19
- if (s(r) && s(e)) {
20
- const t = Object.entries(r);
21
- return t.length !== Object.keys(e).length ? !1 : t.every(([n, c]) => f(c, e[n]));
22
- }
23
- return !1;
24
- }
25
- function o(r) {
26
- return (...e) => {
27
- u((t) => {
28
- (t.internal.context.mode.isPreview() ? console[r] : t.internal.logger[r])(...e);
29
- });
30
- };
31
- }
32
- const a = {
33
- debug: o("debug"),
34
- info: o("info"),
35
- warn: o("warn"),
36
- error: o("error")
37
- };
38
- export {
39
- s as a,
40
- f as i,
41
- a as l
42
- };
@@ -1 +0,0 @@
1
- "use strict";const m=require("./index.es-Dp6Iaxz3.cjs"),i=require("./logger-Boh_C6Bz.cjs");async function y(t,{hitDecorators:e,...r},c){const n=await c(t,r);if(!n.products?.hits?.length||!e?.length)return n;const o=s=>e.reduce((a,u)=>u(a),s);return{...n,products:{...n.products,hits:n.products.hits.map(o)}}}function h(t,e,r){const c=JSON.stringify(e);try{r.setItem(t,c)}catch(n){i.logger.warn(n)}}function g(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function I(t,e){h(t,e,localStorage)}function C(t,e){h(t,e,sessionStorage)}function R(t){return g(t,localStorage)}function b(t){return g(t,sessionStorage)}const p="nosto:search-js:cache",k=60*1e3;function N(t,e){C(p,{query:t,result:e,created:Date.now()})}function T(t){const e=b(p);if(!e||!z(e))return null;const r=d(e.query);return!i.isEqual(d(t),r)||Date.now()-e.created>k?null:e.result}function d(t){const e={...t,time:void 0,products:{...t.products,size:void 0}};return JSON.parse(JSON.stringify(e))}function z(t){return typeof t=="object"&&t!==null&&"query"in t&&"result"in t&&"created"in t}async function E(t,{usePersistentCache:e,...r},c){if(!e)return c(t,r);const n=await L(t,r,c);return N(t,n),n}async function L(t,e,r){const{from:c=0,size:n=0}=t.products||{},o=T(t);if(!o)return await r(t,e);const s=o?.products?.size??0,a=o?.products?.hits??[];if(n===s)return o;if(n<s)return{...o,products:{...o.products,size:n,hits:a.slice(0,n),total:o.products?.total||0}};const u=n-a.length,S=c>0?c+1:n-u,w={...t,products:{...t.products,from:S,size:u}},l=await r(w,e);return{...o,products:{...o.products,size:n,hits:[...o.products?.hits||[],...l.products?.hits||[]],total:l.products?.total||0}}}const O=3e4,f=new Map;function _(t,e){const r=f.get(t);if(!r)return;const c=Date.now()-r.created>O,n=i.isEqual(e,r.query);if(c||!n){f.delete(t);return}return r.result}function J(t,e,r){f.set(t,{query:e,result:r,created:Date.now()})}async function W(t,e,r){if(!e.useMemoryCache)return r(t,e);const c=JSON.stringify(t),n=_(c,t);if(n)return n;const o=await r(t,e);return J(c,t,o),o}async function D(t,e,r){if(!e.redirect)return r(t,e);const c=await r(t,e);if(c.keywords?.hits?.length){const n=c.keywords.hits.find(o=>o.keyword===t.query&&o._redirect);n&&n._redirect&&(window.location.href=n._redirect)}return c}function M(t){return new Promise(e=>setTimeout(e,t))}async function V(t,{maxRetries:e=0,retryInterval:r=0,...c},n){let o=0;for(;;)try{return await n(t,c)}catch(s){if(o>=e)throw s;if(!j(s))throw i.logger.info("Skipping retry logic for",s),s;o++,await M(r)}}function j(t){return!t||typeof t!="object"?!1:!("status"in t)||x(t.status)}function x(t){return typeof t=="number"&&(t<400||t>=500)}async function A(t,e={}){const r=await new Promise(m.s);return K(r.search,V,D,W,E,y)(t,e)}function K(t,...e){return e.reduce((r,c)=>(n,o)=>c(n,o,r),t)}exports.getLocalStorageItem=R;exports.search=A;exports.setLocalStorageItem=I;
@@ -1,187 +0,0 @@
1
- import { s as y } from "./index.es-XNBESE3P.js";
2
- import { l as f, i as h } from "./logger-_fg_Za9y.js";
3
- async function C(t, { hitDecorators: e, ...r }, c) {
4
- const n = await c(t, r);
5
- if (!n.products?.hits?.length || !e?.length)
6
- return n;
7
- const s = (o) => e.reduce((i, a) => a(i), o);
8
- return {
9
- ...n,
10
- products: {
11
- ...n.products,
12
- hits: n.products.hits.map(s)
13
- }
14
- };
15
- }
16
- function p(t, e, r) {
17
- const c = JSON.stringify(e);
18
- try {
19
- r.setItem(t, c);
20
- } catch (n) {
21
- f.warn(n);
22
- }
23
- }
24
- function g(t, e) {
25
- try {
26
- const r = e.getItem(t);
27
- if (r)
28
- return JSON.parse(r);
29
- } catch (r) {
30
- f.warn(r);
31
- }
32
- }
33
- function P(t, e) {
34
- p(t, e, localStorage);
35
- }
36
- function R(t, e) {
37
- p(t, e, sessionStorage);
38
- }
39
- function G(t) {
40
- return g(t, localStorage);
41
- }
42
- function I(t) {
43
- return g(t, sessionStorage);
44
- }
45
- const m = "nosto:search-js:cache", b = 60 * 1e3;
46
- function k(t, e) {
47
- R(m, { query: t, result: e, created: Date.now() });
48
- }
49
- function N(t) {
50
- const e = I(m);
51
- if (!e || !T(e))
52
- return null;
53
- const r = d(e.query);
54
- return !h(d(t), r) || Date.now() - e.created > b ? null : e.result;
55
- }
56
- function d(t) {
57
- const e = {
58
- ...t,
59
- time: void 0,
60
- products: {
61
- ...t.products,
62
- size: void 0
63
- }
64
- };
65
- return JSON.parse(JSON.stringify(e));
66
- }
67
- function T(t) {
68
- return typeof t == "object" && t !== null && "query" in t && "result" in t && "created" in t;
69
- }
70
- async function z(t, { usePersistentCache: e, ...r }, c) {
71
- if (!e)
72
- return c(t, r);
73
- const n = await O(t, r, c);
74
- return k(t, n), n;
75
- }
76
- async function O(t, e, r) {
77
- const { from: c = 0, size: n = 0 } = t.products || {}, s = N(t);
78
- if (!s)
79
- return await r(t, e);
80
- const o = s?.products?.size ?? 0, i = s?.products?.hits ?? [];
81
- if (n === o)
82
- return s;
83
- if (n < o)
84
- return {
85
- ...s,
86
- products: {
87
- ...s.products,
88
- size: n,
89
- hits: i.slice(0, n),
90
- total: s.products?.total || 0
91
- }
92
- };
93
- const a = n - i.length, w = c > 0 ? c + 1 : n - a, S = {
94
- ...t,
95
- products: {
96
- ...t.products,
97
- from: w,
98
- size: a
99
- }
100
- }, l = await r(S, e);
101
- return {
102
- ...s,
103
- products: {
104
- ...s.products,
105
- size: n,
106
- hits: [...s.products?.hits || [], ...l.products?.hits || []],
107
- total: l.products?.total || 0
108
- }
109
- };
110
- }
111
- const E = 3e4, u = /* @__PURE__ */ new Map();
112
- function J(t, e) {
113
- const r = u.get(t);
114
- if (!r) return;
115
- const c = Date.now() - r.created > E, n = h(e, r.query);
116
- if (c || !n) {
117
- u.delete(t);
118
- return;
119
- }
120
- return r.result;
121
- }
122
- function W(t, e, r) {
123
- u.set(t, {
124
- query: e,
125
- result: r,
126
- created: Date.now()
127
- });
128
- }
129
- async function _(t, e, r) {
130
- if (!e.useMemoryCache)
131
- return r(t, e);
132
- const c = JSON.stringify(t), n = J(c, t);
133
- if (n) return n;
134
- const s = await r(t, e);
135
- return W(c, t, s), s;
136
- }
137
- async function D(t, e, r) {
138
- if (!e.redirect)
139
- return r(t, e);
140
- const c = await r(t, e);
141
- if (c.keywords?.hits?.length) {
142
- const n = c.keywords.hits.find((s) => s.keyword === t.query && s._redirect);
143
- n && n._redirect && (window.location.href = n._redirect);
144
- }
145
- return c;
146
- }
147
- function L(t) {
148
- return new Promise((e) => setTimeout(e, t));
149
- }
150
- async function M(t, { maxRetries: e = 0, retryInterval: r = 0, ...c }, n) {
151
- let s = 0;
152
- for (; ; )
153
- try {
154
- return await n(t, c);
155
- } catch (o) {
156
- if (s >= e)
157
- throw o;
158
- if (!V(o))
159
- throw f.info("Skipping retry logic for", o), o;
160
- s++, await L(r);
161
- }
162
- }
163
- function V(t) {
164
- return !t || typeof t != "object" ? !1 : !("status" in t) || j(t.status);
165
- }
166
- function j(t) {
167
- return typeof t == "number" && (t < 400 || t >= 500);
168
- }
169
- async function H(t, e = {}) {
170
- const r = await new Promise(y);
171
- return x(
172
- r.search,
173
- M,
174
- D,
175
- _,
176
- z,
177
- C
178
- )(t, e);
179
- }
180
- function x(t, ...e) {
181
- return e.reduce((r, c) => (n, s) => c(n, s, r), t);
182
- }
183
- export {
184
- P as a,
185
- G as g,
186
- H as s
187
- };
@@ -1 +0,0 @@
1
- "use strict";const u=require("./logger-Boh_C6Bz.cjs");function f(...e){return i(...e)}function i(...e){return e.reduce((r,n)=>c(r,n))}function c(e,r){return u.isPlainObject(e)&&u.isPlainObject(r)?Object.entries(r).reduce((n,[t,o])=>(n[t]=c(n[t],o),n),{...e}):u.isPlainObject(e)?e:r}function s(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,n)=>r.concat(n),[])}const a="nosto.search.";function d(e){const r=`${a}${e}`;window.performance?.mark(`${r}.start`)}function l(e){const r=`${a}${e}`;window.performance?.mark(`${r}.end`),window.performance?.measure(r,`${r}.start`,`${r}.end`)}function m(e){return d(e),()=>l(e)}function $(e){return Array.from(new Set(e))}exports.deepMerge=f;exports.deepMergePlain=i;exports.measure=m;exports.mergeArrays=s;exports.unique=$;
@@ -1 +0,0 @@
1
- "use strict";const w=require("preact"),f=require("preact/hooks"),u=require("./unique-BXXNictB.cjs"),C=require("./logger-Boh_C6Bz.cjs"),E=require("./search-DItu5YCc.cjs"),k=w.createContext(null);function p(){const e=f.useContext(k);if(!e)throw new Error("useConfig must be used within a ConfigProvider");return e}function A(){const e=p();if(e.pageType!=="search")throw new Error("useSerpConfig must be used within a NostoSearchPageProvider");return e}function I(){const e=p();if(e.pageType!=="category")throw new Error("useCategoryConfig must be used within a NostoCategoryPageProvider");return e}function U(){const e=p();if(e.pageType!=="autocomplete")throw new Error("useAutocompleteConfig must be used within a NostoAutocompletePageProvider");return e}function b(e,r={}){const t=new Map;let n=u.deepMergePlain(e,r??{});const a=u.deepMergePlain(e,r);function c(l){n=l(n);for(const g of t.values())g(n)}function s(l){c(g=>({...g,...l}))}function i(){return n}function o(){return structuredClone(a)}function d(l,g){let m=l(n);t.set(g,M=>{const y=l(M);C.isEqual(y,m)||(m=y,g(y))})}function T(l){d(g=>g.initialized,g=>{g&&l()})}function q(l){t.delete(l)}return{updateState:s,getState:i,getInitialState:o,onChange:d,onInit:T,clearOnChange:q}}const v={loading:!0,query:{},response:{},initialized:!1};function P(e={}){return b(v,e)}const F=w.createContext(P());function Q(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:z,...r.products},...r.keywords?{keywords:{...r.keywords,fields:u.unique([...K,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const z=["productId","url","name","imageUrl","imageHash","thumbUrl","description","brand","variantId","availability","price","priceText","categoryIds","categories","customFields.key","customFields.value","priceCurrencyCode","datePublished","listPrice","unitPricingBaseMeasure","unitPricingUnit","unitPricingMeasure","googleCategory","gtin","ageGroup","gender","condition","alternateImageUrls","ratingValue","reviewCount","inventoryLevel","skus.id","skus.name","skus.price","skus.listPrice","skus.priceText","skus.url","skus.imageUrl","skus.inventoryLevel","skus.customFields.key","skus.customFields.value","skus.availability","pid","onDiscount","extra.key","extra.value","saleable","available","tags1","tags2","tags3"],K=["keyword","_redirect"];async function S(e,r,t){const n=u.measure("newSearch"),a=e.config.pageType,c=a==="search"?"serp":a,s=u.deepMerge(e.store.getInitialState().query,r),i=u.deepMerge(e.config.search,t,{track:c,redirect:a!=="autocomplete",isKeyword:!!t?.isKeyword,usePersistentCache:e.config.pageType!=="autocomplete"&&e.config.persistentSearchCache,useMemoryCache:e.config.pageType==="autocomplete"&&e.config.memoryCache});e.config.onBeforeSearch?.(e,i),e.store.updateState({query:s,loading:!0,initialized:!0});const o=e.config.queryModifications({...s,products:{...s.products,filter:u.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},a);try{const d=await E.search(Q(e.config.pageType,o),i);e.store.updateState({response:d,loading:!1})}catch(d){C.logger.error("Search action failed",d),e.config.onSearchError?.(d,o,i,a)}n()}async function h(e,r,t){const n=u.measure("updateSearch"),a=u.deepMerge(e.store.getState().query,{products:{from:0}},r);await S(e,a,t),n()}async function N(e,r,t){const n=u.measure("replaceFilter"),a=e.store.getState().query.products?.filter,c=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await h(e,{products:{filter:[...a?.filter(s=>s.field!==r)??[],...c]}}),n()}async function x(e,r,t,n){const a=u.measure("toggleProductFilter"),c=e.store.getState().query.products?.filter,s=c?.find(o=>o.value instanceof Array&&o.field===r),i=s?.value?{...s,value:[...s.value.filter(o=>!C.isEqual(o,t)),...n?[t]:[]]}:n?{field:r,value:[t]}:void 0;await h(e,{products:{filter:[...c?.filter(o=>o!==s)??[],...i?.value?.length?[i]:[]]}}),a()}function B(){const e=p(),r=f.useContext(F),t=f.useMemo(()=>({config:e,store:r}),[e,r]),n=f.useCallback((i,o)=>S(t,i,o),[t]),a=f.useCallback((i,o)=>h(t,i,o),[t]),c=f.useCallback((i,o,d)=>x(t,i,o,d),[t]),s=f.useCallback((i,o)=>N(t,i,o),[t]);return{newSearch:n,updateSearch:a,toggleProductFilter:c,replaceFilter:s}}exports.ConfigContext=k;exports.StoreContext=F;exports.createExtendableStore=b;exports.createStore=P;exports.defaultState=v;exports.newSearch=S;exports.updateSearch=h;exports.useActions=B;exports.useAutocompleteConfig=U;exports.useCategoryConfig=I;exports.useConfig=p;exports.useSerpConfig=A;
@@ -1 +0,0 @@
1
- "use strict";const a=require("./useActions-B6FFW8xI.cjs"),o=require("./search-DItu5YCc.cjs"),i=require("preact/hooks"),s="nosto:search-js:history";function u({value:e,historySize:t,store:r}){const l=(o.getLocalStorageItem(s)??[]).filter(y=>y!==e).concat(e),n=t?l.slice(-t):[];o.setLocalStorageItem(s,n),r.updateState({historyItems:n.reverse()})}function d(){return(o.getLocalStorageItem(s)??[]).slice().reverse().filter(t=>!!t)}function g(){const e=i.useContext(a.StoreContext),{historySize:t}=a.useAutocompleteConfig();return{addQuery:i.useCallback(c=>{u({value:c,historySize:t,store:e})},[t,e])}}exports.addToHistory=u;exports.getSavedHistory=d;exports.useHistory=g;