@nosto/search-js 3.1.0 → 3.1.2

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 (39) hide show
  1. package/dist/BaseElement-Ds4INJSy.cjs +1 -0
  2. package/dist/BaseElement-fZSwbg09.js +17 -0
  3. package/dist/InfiniteScrollWithObserver-CQV1s264.js +205 -0
  4. package/dist/InfiniteScrollWithObserver-DwzgJMlG.cjs +1 -0
  5. package/dist/core/core.cjs.js +1 -1
  6. package/dist/core/core.es.js +6 -6
  7. package/dist/currencies/currencies.cjs.js +1 -1
  8. package/dist/currencies/currencies.es.js +32 -32
  9. package/dist/preact/autocomplete.cjs.js +1 -1
  10. package/dist/preact/autocomplete.es.js +1 -1
  11. package/dist/preact/common.cjs.js +1 -1
  12. package/dist/preact/common.es.js +3 -3
  13. package/dist/preact/hooks.cjs.js +1 -1
  14. package/dist/preact/hooks.es.js +259 -299
  15. package/dist/preact/legacy.cjs.js +1 -1
  16. package/dist/preact/legacy.es.js +2 -2
  17. package/dist/preact/serp.cjs.js +1 -1
  18. package/dist/preact/serp.es.js +1 -1
  19. package/dist/preact/src/components/InfiniteScroll/InfiniteScroll.d.ts +1 -2
  20. package/dist/preact/src/components/InfiniteScroll/InfiniteScrollWithObserver.d.ts +3 -2
  21. package/dist/search-DweKaGAI.js +162 -0
  22. package/dist/search-sG5OjNAe.cjs +1 -0
  23. package/dist/thumbnails/thumbnails.cjs.js +1 -1
  24. package/dist/thumbnails/thumbnails.es.js +26 -27
  25. package/dist/{unique-Blp-K9zG.cjs → unique-C8Ij1UVz.cjs} +1 -1
  26. package/dist/{unique-m1TIDWdl.js → unique-DnsrXjFL.js} +26 -28
  27. package/dist/useLoadMore-Cflxq0FH.cjs +1 -0
  28. package/dist/useLoadMore-D9uu2DBj.js +198 -0
  29. package/dist/utils/utils.cjs.js +1 -1
  30. package/dist/utils/utils.es.js +24 -24
  31. package/package.json +11 -11
  32. package/dist/BaseElement-B0hSjDTT.cjs +0 -1
  33. package/dist/BaseElement-IyqEeIiJ.js +0 -18
  34. package/dist/InfiniteScrollWithObserver-C1NKm8WG.cjs +0 -1
  35. package/dist/InfiniteScrollWithObserver-C4YMu07G.js +0 -37
  36. package/dist/search-Bhebxu8K.cjs +0 -1
  37. package/dist/search-BrR80UbS.js +0 -164
  38. package/dist/useLoadMore-CeqFdxt1.cjs +0 -1
  39. package/dist/useLoadMore-Der8Cglb.js +0 -204
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../useLoadMore-CeqFdxt1.cjs"),r=require("../InfiniteScrollWithObserver-C1NKm8WG.cjs");exports.getNextPageQuery=e.getNextPageQuery;exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../useLoadMore-Cflxq0FH.cjs"),r=require("../InfiniteScrollWithObserver-DwzgJMlG.cjs");exports.getNextPageQuery=e.getNextPageQuery;exports.newSearch=e.newSearch;exports.updateSearch=e.updateSearch;exports.InfiniteScrollWithObserver=r.InfiniteScrollWithObserver;exports.intersectionObserverSupported=r.intersectionObserverSupported;
@@ -1,5 +1,5 @@
1
- import { g as t, n as a, u as s } from "../useLoadMore-Der8Cglb.js";
2
- import { I as i, i as n } from "../InfiniteScrollWithObserver-C4YMu07G.js";
1
+ import { g as t, n as a, u as s } from "../useLoadMore-D9uu2DBj.js";
2
+ import { I as i, i as n } from "../InfiniteScrollWithObserver-CQV1s264.js";
3
3
  export {
4
4
  i as InfiniteScrollWithObserver,
5
5
  t as getNextPageQuery,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../jsxRuntime.module-B3sGoTIU.cjs"),S=require("../index.es-DlUp67LT.cjs"),r=require("../configContext-BR7w4VlU.cjs"),g=require("preact/hooks"),f=require("../BaseElement-B0hSjDTT.cjs"),i=require("../baseConfig-BFFqFSg5.cjs"),C="nosto:search:scrollPos";function p(){window.sessionStorage.setItem(C,window.scrollY.toString())}function d({children:e,hit:o,componentProps:t,as:n}){const{pageType:s}=r.useConfig(),c=s==="autocomplete"?void 0:s==="search"?"serp":s,l=g.useCallback(()=>{o&&c&&S.s(u=>u.recordSearchClick(c,o)),p()},[o,c]);return a.u(f.BaseElement,{as:n,onClick:l,componentProps:t,children:e})}const m={...i.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function h(e={}){return{pageType:"search",...m,...e}}function P({config:e,store:o,children:t}){const n=o??r.createStore();return i.useCheckClientScript(),a.u(r.ConfigContext,{value:h(e),children:a.u(r.StoreContext,{value:n,children:t})})}exports.SearchPageProvider=P;exports.SerpElement=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../jsxRuntime.module-B3sGoTIU.cjs"),S=require("../index.es-DlUp67LT.cjs"),r=require("../configContext-BR7w4VlU.cjs"),g=require("preact/hooks"),f=require("../BaseElement-Ds4INJSy.cjs"),i=require("../baseConfig-BFFqFSg5.cjs"),C="nosto:search:scrollPos";function p(){window.sessionStorage.setItem(C,window.scrollY.toString())}function d({children:e,hit:o,componentProps:t,as:n}){const{pageType:s}=r.useConfig(),c=s==="autocomplete"?void 0:s==="search"?"serp":s,l=g.useCallback(()=>{o&&c&&S.s(u=>u.recordSearchClick(c,o)),p()},[o,c]);return a.u(f.BaseElement,{as:n,onClick:l,componentProps:t,children:e})}const m={...i.defaultBaseConfig,persistentSearchCache:!1,preservePageScroll:!1};function h(e={}){return{pageType:"search",...m,...e}}function P({config:e,store:o,children:t}){const n=o??r.createStore();return i.useCheckClientScript(),a.u(r.ConfigContext,{value:h(e),children:a.u(r.StoreContext,{value:n,children:t})})}exports.SearchPageProvider=P;exports.SerpElement=d;
@@ -2,7 +2,7 @@ import { u as n } from "../jsxRuntime.module-Bzuv3cXw.js";
2
2
  import { s as l } from "../index.es-B8mbAxS4.js";
3
3
  import { u as f, c as p, S as u, C as m } from "../configContext-GuZOIX3o.js";
4
4
  import { useCallback as S } from "preact/hooks";
5
- import { B as C } from "../BaseElement-IyqEeIiJ.js";
5
+ import { B as C } from "../BaseElement-fZSwbg09.js";
6
6
  import { d as g, u as d } from "../baseConfig-Bafl02NY.js";
7
7
  const h = "nosto:search:scrollPos";
8
8
  function k() {
@@ -1,5 +1,4 @@
1
1
  import { ComponentChildren, ComponentType } from 'preact';
2
- import { InfiniteScrollWithObserver } from './InfiniteScrollWithObserver';
3
2
  /**
4
3
  * Infinite scroll component props
5
4
  * @param children - The children to render
@@ -55,4 +54,4 @@ export interface InfiniteScrollProps {
55
54
  * ```
56
55
  * @group Components
57
56
  */
58
- export declare const InfiniteScroll: typeof InfiniteScrollWithObserver;
57
+ export declare const InfiniteScroll: ({ children, pageSize, observerOptions }: InfiniteScrollProps) => import("preact").JSX.Element;
@@ -1,7 +1,8 @@
1
- import { JSX } from 'preact';
2
1
  import { InfiniteScrollProps } from './InfiniteScroll';
2
+ declare function BaseInfiniteScrollWithObserver({ children, pageSize, observerOptions }: InfiniteScrollProps): import("preact").JSX.Element;
3
3
  /**
4
4
  * Infinite scroll component that loads more results when user scrolls to the end of the page.
5
5
  * @group Components
6
6
  */
7
- export declare function InfiniteScrollWithObserver({ children, pageSize, observerOptions }: InfiniteScrollProps): JSX.Element;
7
+ export declare const InfiniteScrollWithObserver: typeof BaseInfiniteScrollWithObserver;
8
+ export {};
@@ -0,0 +1,162 @@
1
+ import { s as S } from "./index.es-B8mbAxS4.js";
2
+ import { l as f, i as h } from "./logger-DVwg4Wor.js";
3
+ async function w(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 y(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 C(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 R(t, e) {
34
+ y(t, e, sessionStorage);
35
+ }
36
+ function b(t) {
37
+ return C(t, sessionStorage);
38
+ }
39
+ const p = "nosto:search-js:cache", N = 60 * 1e3;
40
+ function T(t, e) {
41
+ R(p, { query: t, result: e, created: Date.now() });
42
+ }
43
+ function z(t) {
44
+ const e = b(p);
45
+ if (!e || !O(e))
46
+ return null;
47
+ const r = d(e.query);
48
+ return !h(d(t), r) || Date.now() - e.created > N ? null : e.result;
49
+ }
50
+ function d(t) {
51
+ const e = {
52
+ ...t,
53
+ time: void 0,
54
+ products: {
55
+ ...t.products,
56
+ size: void 0
57
+ }
58
+ };
59
+ return JSON.parse(JSON.stringify(e));
60
+ }
61
+ function O(t) {
62
+ return typeof t == "object" && t !== null && "query" in t && "result" in t && "created" in t;
63
+ }
64
+ async function E(t, { usePersistentCache: e, ...r }, c) {
65
+ if (!e)
66
+ return c(t, r);
67
+ const n = await J(t, r, c);
68
+ return T(t, n), n;
69
+ }
70
+ async function J(t, e, r) {
71
+ const { from: c = 0, size: n = 0 } = t.products || {}, s = z(t);
72
+ if (!s)
73
+ return await r(t, e);
74
+ const o = s?.products?.size ?? 0, i = s?.products?.hits ?? [];
75
+ if (n === o)
76
+ return s;
77
+ if (n < o)
78
+ return {
79
+ ...s,
80
+ products: {
81
+ ...s.products,
82
+ size: n,
83
+ hits: i.slice(0, n),
84
+ total: s.products?.total || 0
85
+ }
86
+ };
87
+ const a = n - i.length, g = c > 0 ? c + 1 : n - a, m = {
88
+ ...t,
89
+ products: {
90
+ ...t.products,
91
+ from: g,
92
+ size: a
93
+ }
94
+ }, l = await r(m, e);
95
+ return {
96
+ ...s,
97
+ products: {
98
+ ...s.products,
99
+ size: n,
100
+ hits: [...s.products?.hits || [], ...l.products?.hits || []],
101
+ total: l.products?.total || 0
102
+ }
103
+ };
104
+ }
105
+ const k = 3e4, u = /* @__PURE__ */ new Map();
106
+ function D(t, e) {
107
+ const r = u.get(t);
108
+ if (!r) return;
109
+ const c = Date.now() - r.created > k, n = h(e, r.query);
110
+ if (c || !n) {
111
+ u.delete(t);
112
+ return;
113
+ }
114
+ return r.result;
115
+ }
116
+ function I(t, e, r) {
117
+ u.set(t, {
118
+ query: e,
119
+ result: r,
120
+ created: Date.now()
121
+ });
122
+ }
123
+ async function M(t, e, r) {
124
+ if (!e.useMemoryCache)
125
+ return r(t, e);
126
+ const c = JSON.stringify(t), n = D(c, t);
127
+ if (n) return n;
128
+ const s = await r(t, e);
129
+ return I(c, t, s), s;
130
+ }
131
+ function V(t) {
132
+ return new Promise((e) => setTimeout(e, t));
133
+ }
134
+ async function W(t, { maxRetries: e = 0, retryInterval: r = 0, ...c }, n) {
135
+ let s = 0;
136
+ for (; ; )
137
+ try {
138
+ return await n(t, c);
139
+ } catch (o) {
140
+ if (s >= e)
141
+ throw o;
142
+ if (!j(o))
143
+ throw f.info("Skipping retry logic for", o), o;
144
+ s++, await V(r);
145
+ }
146
+ }
147
+ function j(t) {
148
+ return !t || typeof t != "object" ? !1 : !("status" in t) || x(t.status);
149
+ }
150
+ function x(t) {
151
+ return typeof t == "number" && (t < 400 || t >= 500);
152
+ }
153
+ async function P(t, e = {}) {
154
+ const r = await new Promise(S);
155
+ return A(r.search, W, M, E, w)(t, e);
156
+ }
157
+ function A(t, ...e) {
158
+ return e.reduce((r, c) => (n, s) => c(n, s, r), t);
159
+ }
160
+ export {
161
+ P as s
162
+ };
@@ -0,0 +1 @@
1
+ "use strict";const S=require("./index.es-DlUp67LT.cjs"),i=require("./logger-BcHMZObS.cjs");async function w(t,{hitDecorators:e,...r},c){const n=await c(t,r);if(!n.products?.hits?.length||!e?.length)return n;const s=o=>e.reduce((u,a)=>a(u),o);return{...n,products:{...n.products,hits:n.products.hits.map(s)}}}function m(t,e,r){const c=JSON.stringify(e);try{r.setItem(t,c)}catch(n){i.logger.warn(n)}}function y(t,e){try{const r=e.getItem(t);if(r)return JSON.parse(r)}catch(r){i.logger.warn(r)}}function C(t,e){m(t,e,sessionStorage)}function R(t){return y(t,sessionStorage)}const h="nosto:search-js:cache",b=60*1e3;function N(t,e){C(h,{query:t,result:e,created:Date.now()})}function T(t){const e=R(h);if(!e||!z(e))return null;const r=d(e.query);return!i.isEqual(d(t),r)||Date.now()-e.created>b?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 O(t,r,c);return N(t,n),n}async function O(t,e,r){const{from:c=0,size:n=0}=t.products||{},s=T(t);if(!s)return await r(t,e);const o=s?.products?.size??0,u=s?.products?.hits??[];if(n===o)return s;if(n<o)return{...s,products:{...s.products,size:n,hits:u.slice(0,n),total:s.products?.total||0}};const a=n-u.length,p=c>0?c+1:n-a,g={...t,products:{...t.products,from:p,size:a}},l=await r(g,e);return{...s,products:{...s.products,size:n,hits:[...s.products?.hits||[],...l.products?.hits||[]],total:l.products?.total||0}}}const J=3e4,f=new Map;function k(t,e){const r=f.get(t);if(!r)return;const c=Date.now()-r.created>J,n=i.isEqual(e,r.query);if(c||!n){f.delete(t);return}return r.result}function D(t,e,r){f.set(t,{query:e,result:r,created:Date.now()})}async function I(t,e,r){if(!e.useMemoryCache)return r(t,e);const c=JSON.stringify(t),n=k(c,t);if(n)return n;const s=await r(t,e);return D(c,t,s),s}function M(t){return new Promise(e=>setTimeout(e,t))}async function V(t,{maxRetries:e=0,retryInterval:r=0,...c},n){let s=0;for(;;)try{return await n(t,c)}catch(o){if(s>=e)throw o;if(!W(o))throw i.logger.info("Skipping retry logic for",o),o;s++,await M(r)}}function W(t){return!t||typeof t!="object"?!1:!("status"in t)||j(t.status)}function j(t){return typeof t=="number"&&(t<400||t>=500)}async function _(t,e={}){const r=await new Promise(S.s);return x(r.search,V,I,E,w)(t,e)}function x(t,...e){return e.reduce((r,c)=>(n,s)=>c(n,s,r),t)}exports.search=_;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../index.es-DlUp67LT.cjs");function s({size:e,productId:a,hash:c}){const u=p.i();if(!u)throw new Error("Client script settings are not yet available");return`https://${u.thumbnailHost}/${u.account}/${e}/${a}/${c}/A`}function l({size:e}){function a(i,r){if(r)return s({size:e,productId:i,hash:r})}function c(i,r){if(r)return r.map(t=>({...t,imageUrl:a(i,t.imageHash)??t.imageUrl}))}function u(i,r,t){if(!t)return r;if(r)return t.map(n=>s({size:e,productId:i,hash:n}))}return function(r){const t=r.productId;return t?{...r,imageUrl:a(t,r.imageHash)??r.imageUrl,thumbUrl:a(t,r.thumbHash)??r.thumbUrl,skus:c(t,r.skus),alternateImageUrls:u(t,r.alternateImageUrls,r.alternateImageHashes)}:r}}const g=/cdn\.shopify\.com/,m={1:"170x170",2:"100x100",3:"90x70",4:"50x50",5:"30x30",6:"100x140",7:"200x200",8:"400x400",9:"750x750"};function U(e){return e in m}function f({size:e,fallback:a=c=>c}){if(e==="orig")return a;const c=m[e]||e;function u(n){return n?new URL(n).hostname.match(g):!1}function i(n){return n?u(n)?n.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/,`_${c}$1`):n:""}function r(n){if(n)return n.map(o=>({...o,imageUrl:i(o.imageUrl)}))}function t(n){if(n)return n.map(o=>i(o))}return function(o){return u(o.imageUrl)?{...o,imageUrl:i(o.imageUrl),thumbUrl:i(o.thumbUrl),skus:r(o.skus),alternateImageUrls:t(o.alternateImageUrls)}:a(o)}}function d(){var e;return(e=window.Nosto)==null?void 0:e.shopifyScript}function b({size:e}){const a=l({size:e});return d()&&U(e)?f({size:e,fallback:a}):a}exports.generateThumbnailUrl=s;exports.nostoThumbnailDecorator=l;exports.shopifyThumbnailDecorator=f;exports.thumbnailDecorator=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("../index.es-DlUp67LT.cjs");function s({size:n,productId:a,hash:c}){const u=p.i();if(!u)throw new Error("Client script settings are not yet available");return`https://${u.thumbnailHost}/${u.account}/${n}/${a}/${c}/A`}function l({size:n}){function a(i,r){if(r)return s({size:n,productId:i,hash:r})}function c(i,r){if(r)return r.map(t=>({...t,imageUrl:a(i,t.imageHash)??t.imageUrl}))}function u(i,r,t){if(!t)return r;if(r)return t.map(e=>s({size:n,productId:i,hash:e}))}return function(r){const t=r.productId;return t?{...r,imageUrl:a(t,r.imageHash)??r.imageUrl,thumbUrl:a(t,r.thumbHash)??r.thumbUrl,skus:c(t,r.skus),alternateImageUrls:u(t,r.alternateImageUrls,r.alternateImageHashes)}:r}}const g=/cdn\.shopify\.com/,m={1:"170x170",2:"100x100",3:"90x70",4:"50x50",5:"30x30",6:"100x140",7:"200x200",8:"400x400",9:"750x750"};function U(n){return n in m}function f({size:n,fallback:a=c=>c}){if(n==="orig")return a;const c=m[n]||n;function u(e){return e?new URL(e).hostname.match(g):!1}function i(e){return e?u(e)?e.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/,`_${c}$1`):e:""}function r(e){if(e)return e.map(o=>({...o,imageUrl:i(o.imageUrl)}))}function t(e){if(e)return e.map(o=>i(o))}return function(o){return u(o.imageUrl)?{...o,imageUrl:i(o.imageUrl),thumbUrl:i(o.thumbUrl),skus:r(o.skus),alternateImageUrls:t(o.alternateImageUrls)}:a(o)}}function d(){return window.Nosto?.shopifyScript}function b({size:n}){const a=l({size:n});return d()&&U(n)?f({size:n,fallback:a}):a}exports.generateThumbnailUrl=s;exports.nostoThumbnailDecorator=l;exports.shopifyThumbnailDecorator=f;exports.thumbnailDecorator=b;
@@ -1,15 +1,15 @@
1
1
  import { i as m } from "../index.es-B8mbAxS4.js";
2
- function s({ size: n, productId: a, hash: c }) {
2
+ function s({ size: e, productId: a, hash: c }) {
3
3
  const i = m();
4
4
  if (!i)
5
5
  throw new Error("Client script settings are not yet available");
6
- return `https://${i.thumbnailHost}/${i.account}/${n}/${a}/${c}/A`;
6
+ return `https://${i.thumbnailHost}/${i.account}/${e}/${a}/${c}/A`;
7
7
  }
8
- function l({ size: n }) {
8
+ function l({ size: e }) {
9
9
  function a(u, r) {
10
10
  if (r)
11
11
  return s({
12
- size: n,
12
+ size: e,
13
13
  productId: u,
14
14
  hash: r
15
15
  });
@@ -26,10 +26,10 @@ function l({ size: n }) {
26
26
  return r;
27
27
  if (r)
28
28
  return t.map(
29
- (e) => s({
30
- size: n,
29
+ (n) => s({
30
+ size: e,
31
31
  productId: u,
32
- hash: e
32
+ hash: n
33
33
  })
34
34
  );
35
35
  }
@@ -55,29 +55,29 @@ const p = /cdn\.shopify\.com/, f = {
55
55
  8: "400x400",
56
56
  9: "750x750"
57
57
  };
58
- function g(n) {
59
- return n in f;
58
+ function g(e) {
59
+ return e in f;
60
60
  }
61
- function U({ size: n, fallback: a = (c) => c }) {
62
- if (n === "orig")
61
+ function U({ size: e, fallback: a = (c) => c }) {
62
+ if (e === "orig")
63
63
  return a;
64
- const c = f[n] || n;
65
- function i(e) {
66
- return e ? new URL(e).hostname.match(p) : !1;
64
+ const c = f[e] || e;
65
+ function i(n) {
66
+ return n ? new URL(n).hostname.match(p) : !1;
67
67
  }
68
- function u(e) {
69
- return e ? i(e) ? e.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/, `_${c}$1`) : e : "";
68
+ function u(n) {
69
+ return n ? i(n) ? n.replace(/(\.jpg|\.png|\.jpeg|\.gif|\.webp)/, `_${c}$1`) : n : "";
70
70
  }
71
- function r(e) {
72
- if (e)
73
- return e.map((o) => ({
71
+ function r(n) {
72
+ if (n)
73
+ return n.map((o) => ({
74
74
  ...o,
75
75
  imageUrl: u(o.imageUrl)
76
76
  }));
77
77
  }
78
- function t(e) {
79
- if (e)
80
- return e.map((o) => u(o));
78
+ function t(n) {
79
+ if (n)
80
+ return n.map((o) => u(o));
81
81
  }
82
82
  return function(o) {
83
83
  return i(o.imageUrl) ? {
@@ -90,12 +90,11 @@ function U({ size: n, fallback: a = (c) => c }) {
90
90
  };
91
91
  }
92
92
  function d() {
93
- var n;
94
- return (n = window.Nosto) == null ? void 0 : n.shopifyScript;
93
+ return window.Nosto?.shopifyScript;
95
94
  }
96
- function x({ size: n }) {
97
- const a = l({ size: n });
98
- return d() && g(n) ? U({ size: n, fallback: a }) : a;
95
+ function x({ size: e }) {
96
+ const a = l({ size: e });
97
+ return d() && g(e) ? U({ size: e, fallback: a }) : a;
99
98
  }
100
99
  export {
101
100
  s as generateThumbnailUrl,
@@ -1 +1 @@
1
- "use strict";var s=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/",i=/bot|crawl|http|lighthouse|scan|search|spider/i,t;function c(){if(t instanceof RegExp)return t;try{t=new RegExp(s,"i")}catch{t=i}return t}function d(e){return!!e&&c().test(e)}function u(){return d(navigator.userAgent)}function l(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,a)=>r.concat(a),[])}const n="nosto.search.";function p(e){var a;const r=`${n}${e}`;(a=window.performance)==null||a.mark(`${r}.start`)}function m(e){var a,o;const r=`${n}${e}`;(a=window.performance)==null||a.mark(`${r}.end`),(o=window.performance)==null||o.measure(r,`${r}.start`,`${r}.end`)}function h(e){return p(e),()=>m(e)}function w(e){return Array.from(new Set(e))}exports.isBot=u;exports.measure=h;exports.mergeArrays=l;exports.unique=w;
1
+ "use strict";var n=" daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/",s=/bot|crawl|http|lighthouse|scan|search|spider/i,a;function i(){if(a instanceof RegExp)return a;try{a=new RegExp(n,"i")}catch{a=s}return a}function c(e){return!!e&&i().test(e)}function d(){return c(navigator.userAgent)}function u(...e){if(!e.every(r=>r==null))return e.filter(r=>Array.isArray(r)).reduce((r,o)=>r.concat(o),[])}const t="nosto.search.";function l(e){const r=`${t}${e}`;window.performance?.mark(`${r}.start`)}function p(e){const r=`${t}${e}`;window.performance?.mark(`${r}.end`),window.performance?.measure(r,`${r}.start`,`${r}.end`)}function m(e){return l(e),()=>p(e)}function h(e){return Array.from(new Set(e))}exports.isBot=d;exports.measure=m;exports.mergeArrays=u;exports.unique=h;
@@ -1,44 +1,42 @@
1
- var s = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/", i = /bot|crawl|http|lighthouse|scan|search|spider/i, t;
2
- function c() {
3
- if (t instanceof RegExp)
4
- return t;
1
+ var n = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|(?<!cam)scan|@[a-z][\\w-]+\\.|\\(\\)|\\.com\\b|\\btime/|\\||^<|^[\\w \\.\\-\\(?:\\):%]+(?:/v?\\d+(?:\\.\\d+)?(?:\\.\\d{1,10})*?)?(?:,|$)|^[^ ]{50,}$|^\\d+\\b|^\\w*search\\b|^\\w+/[\\w\\(\\)]*$|^active|^ad muncher|^amaya|^avsdevicesdk/|^biglotron|^bot|^bw/|^clamav[ /]|^client/|^cobweb/|^custom|^ddg[_-]android|^discourse|^dispatch/\\d|^downcast/|^duckduckgo|^email|^facebook|^getright/|^gozilla/|^hobbit|^hotzonu|^hwcdn/|^igetter/|^jeode/|^jetty/|^jigsaw|^microsoft bits|^movabletype|^mozilla/\\d\\.\\d\\s[\\w\\.-]+$|^mozilla/\\d\\.\\d\\s\\(compatible;?(?:\\s\\w+\\/\\d+\\.\\d+)?\\)$|^navermailapp|^netsurf|^offline|^openai/|^owler|^php|^postman|^python|^rank|^read|^reed|^rest|^rss|^snapchat|^space bison|^svn|^swcd |^taringa|^thumbor/|^track|^w3c|^webbandit/|^webcopier|^wget|^whatsapp|^wordpress|^xenu link sleuth|^yahoo|^yandex|^zdm/\\d|^zoom marketplace/|^{{.*}}$|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|grab|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|onetrust|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|xtate/", s = /bot|crawl|http|lighthouse|scan|search|spider/i, a;
2
+ function i() {
3
+ if (a instanceof RegExp)
4
+ return a;
5
5
  try {
6
- t = new RegExp(s, "i");
6
+ a = new RegExp(n, "i");
7
7
  } catch {
8
- t = i;
8
+ a = s;
9
9
  }
10
- return t;
10
+ return a;
11
11
  }
12
- function d(e) {
13
- return !!e && c().test(e);
12
+ function c(e) {
13
+ return !!e && i().test(e);
14
14
  }
15
- function u() {
16
- return d(navigator.userAgent);
15
+ function p() {
16
+ return c(navigator.userAgent);
17
17
  }
18
- function m(...e) {
18
+ function u(...e) {
19
19
  if (!e.every((r) => r == null))
20
- return e.filter((r) => Array.isArray(r)).reduce((r, a) => r.concat(a), []);
20
+ return e.filter((r) => Array.isArray(r)).reduce((r, o) => r.concat(o), []);
21
+ }
22
+ const t = "nosto.search.";
23
+ function d(e) {
24
+ const r = `${t}${e}`;
25
+ window.performance?.mark(`${r}.start`);
21
26
  }
22
- const n = "nosto.search.";
23
27
  function l(e) {
24
- var a;
25
- const r = `${n}${e}`;
26
- (a = window.performance) == null || a.mark(`${r}.start`);
28
+ const r = `${t}${e}`;
29
+ window.performance?.mark(`${r}.end`), window.performance?.measure(r, `${r}.start`, `${r}.end`);
27
30
  }
28
- function p(e) {
29
- var a, o;
30
- const r = `${n}${e}`;
31
- (a = window.performance) == null || a.mark(`${r}.end`), (o = window.performance) == null || o.measure(r, `${r}.start`, `${r}.end`);
31
+ function m(e) {
32
+ return d(e), () => l(e);
32
33
  }
33
34
  function h(e) {
34
- return l(e), () => p(e);
35
- }
36
- function w(e) {
37
35
  return Array.from(new Set(e));
38
36
  }
39
37
  export {
40
- h as a,
41
- u as i,
42
- m,
43
- w as u
38
+ m as a,
39
+ p as i,
40
+ u as m,
41
+ h as u
44
42
  };
@@ -0,0 +1 @@
1
+ "use strict";const p=require("./configContext-BR7w4VlU.cjs"),n=require("preact/hooks"),C=require("./search-sG5OjNAe.cjs"),l=require("./unique-C8Ij1UVz.cjs"),f=require("./deepMerge-lDscDfII.cjs"),h=require("./logger-BcHMZObS.cjs");function w(e,r){return{...r,products:{facets:e==="autocomplete"?void 0:["*"],fields:b,...r.products},...r.keywords?{keywords:{...r.keywords,fields:l.unique([...v,...r.keywords.fields??[]]),highlight:r.keywords.highlight??{preTag:"<strong>",postTag:"</strong>"}}}:{}}}const b=["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"],v=["keyword","_redirect"];async function y(e,r,t){const o=l.measure("newSearch"),a=e.config.pageType,u=a==="search"?"serp":a,c=f.deepMerge(e.store.getInitialState().query,r),i=f.deepMerge(e.config.search,t,{track:u,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:c,loading:!0,initialized:!0});const s=e.config.queryModifications({...c,products:{...c.products,filter:l.mergeArrays(e.store.getInitialState().query?.products?.filter,r.products?.filter)}},a);try{const d=await C.search(w(e.config.pageType,s),i);e.store.updateState({response:d,loading:!1})}catch(d){h.logger.error("Search action failed",d),e.config.onSearchError?.(d,s,i,a)}o()}async function g(e,r,t){const o=l.measure("updateSearch"),a=f.deepMerge(e.store.getState().query,{products:{from:0}},r);await y(e,a,t),o()}function k(e=F){const r=n.useContext(p.StoreContext),[t,o]=n.useState(e(r.getState()));return r.onChange(e,o),n.useEffect(()=>()=>r.clearOnChange(o),[r]),t}const F=e=>e;async function P(e,r,t){const o=l.measure("replaceFilter"),a=e.store.getState().query.products?.filter,u=t!==void 0?[{field:r,[typeof t=="object"?"range":"value"]:[t]}]:[];await g(e,{products:{filter:[...a?.filter(c=>c.field!==r)??[],...u]}}),o()}async function M(e,r,t,o){const a=l.measure("toggleProductFilter"),u=e.store.getState().query.products?.filter,c=u?.find(s=>s.value instanceof Array&&s.field===r),i=c?.value?{...c,value:[...c.value.filter(s=>!h.isEqual(s,t)),...o?[t]:[]]}:o?{field:r,value:[t]}:void 0;await g(e,{products:{filter:[...u?.filter(s=>s!==c)??[],...i?.value?.length?[i]:[]]}}),a()}function m(){const e=p.useConfig(),r=n.useContext(p.StoreContext),t=n.useMemo(()=>({config:e,store:r}),[e,r]),o=n.useCallback((i,s)=>y(t,i,s),[t]),a=n.useCallback((i,s)=>g(t,i,s),[t]),u=n.useCallback((i,s,d)=>M(t,i,s,d),[t]),c=n.useCallback((i,s)=>P(t,i,s),[t]);return{newSearch:o,updateSearch:a,toggleProductFilter:u,replaceFilter:c}}function S({from:e,size:r,pageSize:t}){return l.isBot()?{products:{from:e+t}}:{products:{size:r+t}}}function q(e=24){const{from:r,size:t}=k(u=>({from:u.query.products?.from??0,size:u.query.products?.size??0})),{updateSearch:o}=m();return{loadMore:n.useCallback(async()=>{await o(S({from:r,size:t,pageSize:e}))},[r,t,e,o])}}exports.getNextPageQuery=S;exports.newSearch=y;exports.updateSearch=g;exports.useActions=m;exports.useLoadMore=q;exports.useNostoAppState=k;
@@ -0,0 +1,198 @@
1
+ import { S as f, u as h } from "./configContext-GuZOIX3o.js";
2
+ import { useContext as y, useState as k, useEffect as S, useMemo as w, useCallback as l } from "preact/hooks";
3
+ import { s as C } from "./search-DweKaGAI.js";
4
+ import { u as v, a as d, m as F, i as b } from "./unique-DnsrXjFL.js";
5
+ import { d as g } from "./deepMerge-CZwCJzEe.js";
6
+ import { l as P, i as M } from "./logger-DVwg4Wor.js";
7
+ function T(e, r) {
8
+ return {
9
+ ...r,
10
+ products: {
11
+ facets: e === "autocomplete" ? void 0 : ["*"],
12
+ fields: I,
13
+ ...r.products
14
+ },
15
+ ...r.keywords ? {
16
+ keywords: {
17
+ ...r.keywords,
18
+ fields: v([...q, ...r.keywords.fields ?? []]),
19
+ highlight: r.keywords.highlight ?? {
20
+ preTag: "<strong>",
21
+ postTag: "</strong>"
22
+ }
23
+ }
24
+ } : {}
25
+ };
26
+ }
27
+ const I = [
28
+ "productId",
29
+ "url",
30
+ "name",
31
+ "imageUrl",
32
+ "imageHash",
33
+ "thumbUrl",
34
+ "description",
35
+ "brand",
36
+ "variantId",
37
+ "availability",
38
+ "price",
39
+ "priceText",
40
+ "categoryIds",
41
+ "categories",
42
+ "customFields.key",
43
+ "customFields.value",
44
+ "priceCurrencyCode",
45
+ "datePublished",
46
+ "listPrice",
47
+ "unitPricingBaseMeasure",
48
+ "unitPricingUnit",
49
+ "unitPricingMeasure",
50
+ "googleCategory",
51
+ "gtin",
52
+ "ageGroup",
53
+ "gender",
54
+ "condition",
55
+ "alternateImageUrls",
56
+ "ratingValue",
57
+ "reviewCount",
58
+ "inventoryLevel",
59
+ "skus.id",
60
+ "skus.name",
61
+ "skus.price",
62
+ "skus.listPrice",
63
+ "skus.priceText",
64
+ "skus.url",
65
+ "skus.imageUrl",
66
+ "skus.inventoryLevel",
67
+ "skus.customFields.key",
68
+ "skus.customFields.value",
69
+ "skus.availability",
70
+ "pid",
71
+ "onDiscount",
72
+ "extra.key",
73
+ "extra.value",
74
+ "saleable",
75
+ "available",
76
+ "tags1",
77
+ "tags2",
78
+ "tags3"
79
+ ], q = ["keyword", "_redirect"];
80
+ async function m(e, r, t) {
81
+ const a = d("newSearch"), o = e.config.pageType, n = o === "search" ? "serp" : o, c = g(e.store.getInitialState().query, r), i = g(e.config.search, t, {
82
+ track: n,
83
+ redirect: o !== "autocomplete",
84
+ isKeyword: !!t?.isKeyword,
85
+ usePersistentCache: e.config.pageType !== "autocomplete" && e.config.persistentSearchCache,
86
+ useMemoryCache: e.config.pageType === "autocomplete" && e.config.memoryCache
87
+ });
88
+ e.config.onBeforeSearch?.(e, i), e.store.updateState({
89
+ query: c,
90
+ loading: !0,
91
+ initialized: !0
92
+ });
93
+ const s = e.config.queryModifications(
94
+ {
95
+ ...c,
96
+ products: {
97
+ ...c.products,
98
+ // Apply filter merging to avoid overwriting base filters
99
+ filter: F(e.store.getInitialState().query?.products?.filter, r.products?.filter)
100
+ }
101
+ },
102
+ o
103
+ );
104
+ try {
105
+ const u = await C(T(e.config.pageType, s), i);
106
+ e.store.updateState({
107
+ response: u,
108
+ loading: !1
109
+ });
110
+ } catch (u) {
111
+ P.error("Search action failed", u), e.config.onSearchError?.(u, s, i, o);
112
+ }
113
+ a();
114
+ }
115
+ async function p(e, r, t) {
116
+ const a = d("updateSearch"), o = g(e.store.getState().query, { products: { from: 0 } }, r);
117
+ await m(e, o, t), a();
118
+ }
119
+ function Q(e = U) {
120
+ const r = y(f), [t, a] = k(e(r.getState()));
121
+ return r.onChange(e, a), S(() => () => r.clearOnChange(a), [r]), t;
122
+ }
123
+ const U = (e) => e;
124
+ async function A(e, r, t) {
125
+ const a = d("replaceFilter"), o = e.store.getState().query.products?.filter, n = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
126
+ await p(e, {
127
+ products: {
128
+ filter: [...o?.filter((c) => c.field !== r) ?? [], ...n]
129
+ }
130
+ }), a();
131
+ }
132
+ async function z(e, r, t, a) {
133
+ const o = d("toggleProductFilter"), n = e.store.getState().query.products?.filter, c = n?.find((s) => s.value instanceof Array && s.field === r), i = c?.value ? {
134
+ ...c,
135
+ value: [...c.value.filter((s) => !M(s, t)), ...a ? [t] : []]
136
+ } : a ? {
137
+ field: r,
138
+ value: [t]
139
+ } : void 0;
140
+ await p(e, {
141
+ products: {
142
+ filter: [...n?.filter((s) => s !== c) ?? [], ...i?.value?.length ? [i] : []]
143
+ }
144
+ }), o();
145
+ }
146
+ function B() {
147
+ const e = h(), r = y(f), t = w(
148
+ () => ({
149
+ config: e,
150
+ store: r
151
+ }),
152
+ [e, r]
153
+ ), a = l(
154
+ (i, s) => m(t, i, s),
155
+ [t]
156
+ ), o = l(
157
+ (i, s) => p(t, i, s),
158
+ [t]
159
+ ), n = l(
160
+ (i, s, u) => z(t, i, s, u),
161
+ [t]
162
+ ), c = l(
163
+ (i, s) => A(t, i, s),
164
+ [t]
165
+ );
166
+ return {
167
+ newSearch: a,
168
+ updateSearch: o,
169
+ toggleProductFilter: n,
170
+ replaceFilter: c
171
+ };
172
+ }
173
+ function E({ from: e, size: r, pageSize: t }) {
174
+ return b() ? {
175
+ products: { from: e + t }
176
+ } : {
177
+ products: { size: r + t }
178
+ };
179
+ }
180
+ function G(e = 24) {
181
+ const { from: r, size: t } = Q((n) => ({
182
+ from: n.query.products?.from ?? 0,
183
+ size: n.query.products?.size ?? 0
184
+ })), { updateSearch: a } = B();
185
+ return {
186
+ loadMore: l(async () => {
187
+ await a(E({ from: r, size: t, pageSize: e }));
188
+ }, [r, t, e, a])
189
+ };
190
+ }
191
+ export {
192
+ G as a,
193
+ Q as b,
194
+ B as c,
195
+ E as g,
196
+ m as n,
197
+ p as u
198
+ };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../deepMerge-lDscDfII.cjs"),c=require("../unique-Blp-K9zG.cjs"),a=require("../logger-BcHMZObS.cjs"),b=require("../parseNumber-FsZ8w61u.cjs"),A=require("../pick-rYi1lc2m.cjs");function E(i){i.setAttribute("autocomplete","off")}function n(i,{onClick:d,onFocus:o,onInput:t,onKeyDown:s,onSubmit:r},{form:f=i.form??void 0,nativeSubmit:p}={}){const q=[];function u(e,l,v){e.addEventListener(l,v),q.push(()=>e.removeEventListener(l,v))}return(s||r)&&u(i,"keydown",e=>{s==null||s(i.value,e.key),s&&(e.key==="ArrowDown"||e.key==="ArrowUp")?e.preventDefault():r&&e.key==="Enter"&&(i.value!==""&&!e.repeat&&r(i.value),p||e.preventDefault())}),r&&f&&(u(f,"submit",e=>{p||e.preventDefault(),r(i.value)}),f.querySelectorAll("[type=submit]").forEach(e=>{u(e,"click",l=>{p||l.preventDefault(),r(i.value)})})),d&&u(i,"click",()=>d(i.value)),o&&u(i,"focus",()=>o(i.value)),t&&u(i,"input",()=>t(i.value)),{destroy(){q.forEach(e=>e())}}}exports.deepMerge=k.deepMerge;exports.isBot=c.isBot;exports.measure=c.measure;exports.mergeArrays=c.mergeArrays;exports.unique=c.unique;exports.isEqual=a.isEqual;exports.isPlainObject=a.isPlainObject;exports.logger=a.logger;exports.parseNumber=b.parseNumber;exports.pick=A.pick;exports.bindInput=n;exports.disableNativeAutocomplete=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("../deepMerge-lDscDfII.cjs"),l=require("../unique-C8Ij1UVz.cjs"),o=require("../logger-BcHMZObS.cjs"),y=require("../parseNumber-FsZ8w61u.cjs"),k=require("../pick-rYi1lc2m.cjs");function b(i){i.setAttribute("autocomplete","off")}function A(i,{onClick:a,onFocus:d,onInput:n,onKeyDown:c,onSubmit:r},{form:f=i.form??void 0,nativeSubmit:p}={}){const t=[];function u(e,s,q){e.addEventListener(s,q),t.push(()=>e.removeEventListener(s,q))}return(c||r)&&u(i,"keydown",e=>{c?.(i.value,e.key),c&&(e.key==="ArrowDown"||e.key==="ArrowUp")?e.preventDefault():r&&e.key==="Enter"&&(i.value!==""&&!e.repeat&&r(i.value),p||e.preventDefault())}),r&&f&&(u(f,"submit",e=>{p||e.preventDefault(),r(i.value)}),f.querySelectorAll("[type=submit]").forEach(e=>{u(e,"click",s=>{p||s.preventDefault(),r(i.value)})})),a&&u(i,"click",()=>a(i.value)),d&&u(i,"focus",()=>d(i.value)),n&&u(i,"input",()=>n(i.value)),{destroy(){t.forEach(e=>e())}}}exports.deepMerge=v.deepMerge;exports.isBot=l.isBot;exports.measure=l.measure;exports.mergeArrays=l.mergeArrays;exports.unique=l.unique;exports.isEqual=o.isEqual;exports.isPlainObject=o.isPlainObject;exports.logger=o.logger;exports.parseNumber=y.parseNumber;exports.pick=k.pick;exports.bindInput=A;exports.disableNativeAutocomplete=b;