@nosto/search-js 1.6.0 → 1.7.1

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.
@@ -1,225 +1,147 @@
1
- import { toChildArray as X, createContext as L, options as B } from "preact";
1
+ import { options as U, createContext as W, Fragment as G, toChildArray as oe } from "preact";
2
+ import { useContext as E, useState as I, useEffect as x, useMemo as z, useCallback as w, useRef as se } from "preact/hooks";
3
+ import { s as ie } from "../search-B0-bVNMy.js";
2
4
  import { s as q } from "../index.es-B8mbAxS4.js";
3
- import { useContext as E, useEffect as O, useMemo as b, useCallback as v, useState as _ } from "preact/hooks";
4
- import { s as Z } from "../search-B0-bVNMy.js";
5
- function ee(e) {
6
- return e.type === "input";
7
- }
8
- function te(e) {
9
- return !!e && typeof e == "object" && "type" in e && "props" in e;
10
- }
11
- function V(e, t = { depth: 0 }) {
12
- const { children: r } = e;
13
- return X(r).map((n) => {
14
- if (!te(n))
15
- return n;
16
- const o = e.updateElement(n, t);
17
- return o === null ? null : (o.props = {
18
- ...o.props,
19
- children: V({ ...e, children: o.props.children }, { depth: t.depth + 1 })
20
- }, o);
21
- });
22
- }
23
- function $e({ children: e, onSearchInput: t }) {
24
- return V({
25
- children: e,
26
- updateElement: (r) => (!ee(r) || r.props.type !== "search" || (r.props = {
27
- ...r.props,
28
- onInput: (n) => {
29
- n.target instanceof HTMLInputElement && t(n.target);
30
- }
31
- }), r)
32
- });
5
+ var ce = " daum[ /]| deusu/| yadirectfetcher|(?:^|[^g])news(?!sapphire)|(?<! (?:channel/|google/))google(?!(app|/google| pixel))|(?<! cu)bots?(?:\\b|_)|(?<!(?:lib))http|(?<![hg]m)score|@[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/|^{{.*}}$|adscanner/|analyzer|archive|ask jeeves/teoma|audit|bit\\.ly/|bluecoat drtr|browsex|burpcollaborator|capture|catch|check\\b|checker|chrome-lighthouse|chromeframe|classifier|cloudflare|convertify|cookiehubscan|crawl|cypress/|dareboost|datanyze|dejaclick|detect|dmbrowser|download|evc-batch/|exaleadcloudview|feed|firephp|functionize|gomezagent|headless|httrack|hubspot marketing grader|hydra|ibisbrowser|infrawatch|insight|inspect|iplabel|ips-agent|java(?!;)|jsjcw_scanner|library|linkcheck|mail\\.ru/|manager|measure|neustar wpm|node|nutch|offbyone|optimize|pageburst|pagespeed|parser|perl|phantomjs|pingdom|powermarks|preview|proxy|ptst[ /]\\d|retriever|rexx;|rigor|rss\\b|scanner\\.|scrape|server|sogou|sparkler/|speedcurve|spider|splash|statuscake|supercleaner|synapse|synthetic|tools|torrent|transcoder|url|validator|virtuoso|wappalyzer|webglance|webkit2png|whatcms/|zgrab", ae = /bot|crawl|http|lighthouse|scan|search|spider/i, F;
6
+ function ue() {
7
+ if (F instanceof RegExp)
8
+ return F;
9
+ try {
10
+ F = new RegExp(ce, "i");
11
+ } catch {
12
+ F = ae;
13
+ }
14
+ return F;
33
15
  }
34
- const R = L(null), G = () => {
35
- const e = E(R);
36
- if (!e)
37
- throw new Error("useConfig must be used within a ConfigProvider");
38
- return e;
39
- }, re = "nosto:search:scrollPos";
40
- function ne() {
41
- window.sessionStorage.setItem(re, window.scrollY.toString());
16
+ function le(e) {
17
+ return !!e && ue().test(e);
42
18
  }
43
- function je({ children: e, hit: t, onClick: r }) {
44
- const { pageType: n } = G(), o = n === "autocomplete" ? void 0 : n;
45
- return V({
46
- children: e,
47
- updateElement: (u, i) => (i.depth > 0 || (u.props = {
48
- ...u.props,
49
- onClick: (s) => {
50
- t && o && q((l) => l.recordSearchClick(o, t)), ne(), typeof r == "function" && r(s);
51
- }
52
- }), u)
53
- });
19
+ function J() {
20
+ return le(navigator.userAgent);
54
21
  }
55
- var oe = 0;
56
- function k(e, t, r, n, o, u) {
57
- t || (t = {});
58
- var i, s, l = t;
59
- if ("ref" in l) for (s in l = {}, t) s == "ref" ? i = t[s] : l[s] = t[s];
60
- var c = { type: e, props: l, key: r, ref: i, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --oe, __i: -1, __u: 0, __source: o, __self: u };
61
- if (typeof e == "function" && (i = e.defaultProps)) for (s in i) l[s] === void 0 && (l[s] = i[s]);
62
- return B.vnode && B.vnode(c), c;
63
- }
64
- function $() {
65
- O(() => {
66
- const e = window.setTimeout(() => {
67
- console.error("Nosto client script has not loaded after 3 seconds.");
68
- }, 3e3);
69
- q(() => {
70
- window.clearTimeout(e);
71
- });
72
- }, []);
22
+ var de = 0;
23
+ function S(e, r, t, n, o, c) {
24
+ r || (r = {});
25
+ var s, i, l = r;
26
+ if ("ref" in l) for (i in l = {}, r) i == "ref" ? s = r[i] : l[i] = r[i];
27
+ var a = { type: e, props: l, key: t, ref: s, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --de, __i: -1, __u: 0, __source: o, __self: c };
28
+ if (typeof e == "function" && (s = e.defaultProps)) for (i in s) l[i] === void 0 && (l[i] = s[i]);
29
+ return U.vnode && U.vnode(a), a;
73
30
  }
74
- const K = (e) => String(e) === "[object Object]";
31
+ const Q = (e) => String(e) === "[object Object]";
75
32
  function P(e) {
76
- if (!K(e))
33
+ if (!Q(e))
77
34
  return !1;
78
- const t = e.constructor;
79
- if (t === void 0)
35
+ const r = e.constructor;
36
+ if (r === void 0)
80
37
  return !0;
81
- const r = t.prototype;
82
- return !(!K(r) || !r.hasOwnProperty("isPrototypeOf"));
38
+ const t = r.prototype;
39
+ return !(!Q(t) || !t.hasOwnProperty("isPrototypeOf"));
83
40
  }
84
- function z(...e) {
85
- return e.reduce((t, r) => j(t, r));
41
+ function j(...e) {
42
+ return e.reduce((r, t) => $(r, t));
86
43
  }
87
- function Q(...e) {
88
- return e.reduce((t, r) => j(t, r));
44
+ function K(...e) {
45
+ return e.reduce((r, t) => $(r, t));
89
46
  }
90
- function j(e, t) {
91
- return P(e) && P(t) ? Object.entries(t).reduce(
92
- (r, [n, o]) => (r[n] = j(r[n], o), r),
47
+ function $(e, r) {
48
+ return P(e) && P(r) ? Object.entries(r).reduce(
49
+ (t, [n, o]) => (t[n] = $(t[n], o), t),
93
50
  { ...e }
94
- ) : P(e) ? e : t;
51
+ ) : P(e) ? e : r;
95
52
  }
96
- function A(e, t) {
97
- if (e === t)
53
+ function M(e, r) {
54
+ if (e === r)
98
55
  return !0;
99
- if (e instanceof Date && t instanceof Date)
100
- return e.getTime() === t.getTime();
101
- if (Array.isArray(e) && Array.isArray(t))
102
- return e.length !== t.length ? !1 : e.every((r, n) => A(r, t[n]));
103
- if (P(e) && P(t)) {
104
- const r = Object.entries(e);
105
- return r.length !== Object.keys(t).length ? !1 : r.every(([n, o]) => A(o, t[n]));
56
+ if (e instanceof Date && r instanceof Date)
57
+ return e.getTime() === r.getTime();
58
+ if (Array.isArray(e) && Array.isArray(r))
59
+ return e.length !== r.length ? !1 : e.every((t, n) => M(t, r[n]));
60
+ if (P(e) && P(r)) {
61
+ const t = Object.entries(e);
62
+ return t.length !== Object.keys(r).length ? !1 : t.every(([n, o]) => M(o, r[n]));
106
63
  }
107
64
  return !1;
108
65
  }
109
- function se(e, t = {}) {
110
- const r = /* @__PURE__ */ new Map();
111
- let n = Q(e, t ?? {});
112
- const o = Q(e, t);
113
- function u(a) {
114
- n = a(n);
115
- for (const d of r.values())
116
- d(n);
66
+ function fe(e, r = {}) {
67
+ const t = /* @__PURE__ */ new Map();
68
+ let n = K(e, r ?? {});
69
+ const o = K(e, r);
70
+ function c(u) {
71
+ n = u(n);
72
+ for (const f of t.values())
73
+ f(n);
117
74
  }
118
- function i(a) {
119
- u((d) => ({ ...d, ...a }));
75
+ function s(u) {
76
+ c((f) => ({ ...f, ...u }));
120
77
  }
121
- function s() {
78
+ function i() {
122
79
  return n;
123
80
  }
124
81
  function l() {
125
82
  return structuredClone(o);
126
83
  }
127
- function c(a, d) {
84
+ function a(u, f) {
128
85
  let m;
129
- r.set(d, (g) => {
130
- const h = a(g);
131
- A(h, m) || (m = h, d(h));
86
+ t.set(f, (p) => {
87
+ const h = u(p);
88
+ M(h, m) || (m = h, f(h));
132
89
  });
133
90
  }
134
- function f(a) {
135
- r.delete(a);
91
+ function d(u) {
92
+ t.delete(u);
136
93
  }
137
94
  return {
138
- updateState: i,
139
- getState: s,
95
+ updateState: s,
96
+ getState: i,
140
97
  getInitialState: l,
141
- onChange: c,
142
- clearOnChange: f
98
+ onChange: a,
99
+ clearOnChange: d
143
100
  };
144
101
  }
145
- const ie = {
102
+ const pe = {
146
103
  loading: !0,
147
- query: {
148
- query: ""
149
- },
150
- response: {
151
- query: ""
152
- },
104
+ query: {},
105
+ response: {},
153
106
  initialized: !1
154
107
  };
155
- function I(e = {}) {
156
- return se(ie, e);
157
- }
158
- const M = L(I()), D = {
159
- defaultCurrency: "EUR",
160
- queryModifications: (e) => e
161
- }, ce = {
162
- ...D
163
- };
164
- function ue(e) {
165
- return {
166
- pageType: "autocomplete",
167
- ...ce,
168
- ...e
169
- };
170
- }
171
- function De({ config: e, store: t, children: r }) {
172
- const n = t ?? I();
173
- return $(), /* @__PURE__ */ k(R, { value: ue(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
174
- }
175
- const ae = {
176
- ...D,
177
- persistentSearchCache: !1,
178
- preservePageScroll: !1
179
- };
180
- function le(e) {
181
- return {
182
- pageType: "category",
183
- ...ae,
184
- ...e
185
- };
186
- }
187
- function Ue({ config: e, store: t, children: r }) {
188
- const n = t ?? I();
189
- return $(), /* @__PURE__ */ k(R, { value: le(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
108
+ function _(e = {}) {
109
+ return fe(pe, e);
110
+ }
111
+ const A = W(_());
112
+ function y(e = ge) {
113
+ const r = E(A), [t, n] = I(e(r.getState()));
114
+ return r.onChange(e, n), x(() => () => r.clearOnChange(n), [r]), t;
115
+ }
116
+ const ge = (e) => e;
117
+ function Y(e, ...r) {
118
+ return r.reduce(
119
+ (t, n) => (t[n] = e[n], t),
120
+ {}
121
+ );
190
122
  }
191
- const fe = {
192
- ...D,
193
- persistentSearchCache: !1,
194
- preservePageScroll: !1
123
+ const N = W(null), X = () => {
124
+ const e = E(N);
125
+ if (!e)
126
+ throw new Error("useConfig must be used within a ConfigProvider");
127
+ return e;
195
128
  };
196
- function de(e = {}) {
197
- return {
198
- pageType: "serp",
199
- ...fe,
200
- ...e
201
- };
202
- }
203
- function Be({ config: e, store: t, children: r }) {
204
- const n = t ?? I();
205
- return $(), /* @__PURE__ */ k(R, { value: de(e), children: /* @__PURE__ */ k(M, { value: n, children: r }) });
206
- }
207
- function ge(e) {
129
+ function me(e) {
208
130
  return Array.from(new Set(e));
209
131
  }
210
- function pe(e, t) {
132
+ function he(e, r) {
211
133
  return {
212
- ...t,
134
+ ...r,
213
135
  products: {
214
136
  facets: e === "autocomplete" ? void 0 : ["*"],
215
- fields: me,
216
- ...t.products
137
+ fields: ye,
138
+ ...r.products
217
139
  },
218
- ...t.keywords ? {
140
+ ...r.keywords ? {
219
141
  keywords: {
220
- ...t.keywords,
221
- fields: ge([...he, ...t.keywords.fields ?? []]),
222
- highlight: t.keywords.highlight ?? {
142
+ ...r.keywords,
143
+ fields: me([...ve, ...r.keywords.fields ?? []]),
144
+ highlight: r.keywords.highlight ?? {
223
145
  preTag: "<strong>",
224
146
  postTag: "</strong>"
225
147
  }
@@ -227,7 +149,7 @@ function pe(e, t) {
227
149
  } : {}
228
150
  };
229
151
  }
230
- const me = [
152
+ const ye = [
231
153
  "productId",
232
154
  "url",
233
155
  "name",
@@ -279,62 +201,62 @@ const me = [
279
201
  "tags1",
280
202
  "tags2",
281
203
  "tags3"
282
- ], he = ["keyword", "_redirect"];
283
- function ye(...e) {
284
- if (!e.every((t) => t == null))
285
- return e.filter((t) => Array.isArray(t)).reduce((t, r) => t.concat(r), []);
204
+ ], ve = ["keyword", "_redirect"];
205
+ function we(...e) {
206
+ if (!e.every((r) => r == null))
207
+ return e.filter((r) => Array.isArray(r)).reduce((r, t) => r.concat(t), []);
286
208
  }
287
- const J = "nosto.search.";
209
+ const Z = "nosto.search.";
288
210
  function Se(e) {
289
- var r;
290
- const t = `${J}${e}`;
291
- (r = window.performance) == null || r.mark(`${t}.start`);
211
+ var t;
212
+ const r = `${Z}${e}`;
213
+ (t = window.performance) == null || t.mark(`${r}.start`);
292
214
  }
293
- function ve(e) {
294
- var r, n;
295
- const t = `${J}${e}`;
296
- (r = window.performance) == null || r.mark(`${t}.end`), (n = window.performance) == null || n.measure(t, `${t}.start`, `${t}.end`);
215
+ function be(e) {
216
+ var t, n;
217
+ const r = `${Z}${e}`;
218
+ (t = window.performance) == null || t.mark(`${r}.end`), (n = window.performance) == null || n.measure(r, `${r}.start`, `${r}.end`);
297
219
  }
298
220
  function T(e) {
299
- return Se(e), () => ve(e);
221
+ return Se(e), () => be(e);
300
222
  }
301
- function Ce(e, t, r) {
302
- const n = JSON.stringify(t);
223
+ function ke(e, r, t) {
224
+ const n = JSON.stringify(r);
303
225
  try {
304
- console.info("Setting storage", e, n), r.setItem(e, n);
226
+ console.info("Setting storage", e, n), t.setItem(e, n);
305
227
  } catch (o) {
306
228
  console.warn(o);
307
229
  }
308
230
  }
309
- function we(e, t) {
231
+ function Ce(e, r) {
310
232
  try {
311
- const r = t.getItem(e);
312
- if (r)
313
- return JSON.parse(r);
314
- } catch (r) {
315
- console.warn(r);
233
+ const t = r.getItem(e);
234
+ if (t)
235
+ return JSON.parse(t);
236
+ } catch (t) {
237
+ console.warn(t);
316
238
  }
317
239
  }
318
- function Pe(e, t) {
319
- Ce(e, t, sessionStorage);
240
+ function Pe(e, r) {
241
+ ke(e, r, sessionStorage);
320
242
  }
321
- function ke(e) {
322
- return we(e, sessionStorage);
243
+ function Fe(e) {
244
+ return Ce(e, sessionStorage);
323
245
  }
324
- const Y = "nosto:search:searchResult";
325
- function Fe(e, t, r) {
246
+ const ee = "nosto:search:searchResult";
247
+ function Me(e, r, t) {
326
248
  if (!e)
327
249
  return;
328
- Pe(Y, { query: t, result: r });
250
+ Pe(ee, { query: r, result: t });
329
251
  }
330
- function Ae(e, t) {
252
+ function ze(e, r) {
331
253
  if (!e)
332
254
  return null;
333
- const r = ke(Y);
334
- if (!r || !be(r))
255
+ const t = Fe(ee);
256
+ if (!t || !Ae(t))
335
257
  return null;
336
- const n = H(r.query);
337
- return A(H(t), n) ? r.result : null;
258
+ const n = H(t.query);
259
+ return M(H(r), n) ? t.result : null;
338
260
  }
339
261
  function H(e) {
340
262
  return {
@@ -350,295 +272,450 @@ function H(e) {
350
272
  sessionParams: e.sessionParams
351
273
  };
352
274
  }
353
- function be(e) {
275
+ function Ae(e) {
354
276
  return typeof e == "object" && e !== null && "query" in e && "result" in e;
355
277
  }
356
- async function W(e, t, r) {
357
- var c, f, a;
358
- const n = T("newSearch"), o = e.config.pageType, u = z(e.store.getInitialState().query, t), i = z(e.config.search, r, {
278
+ async function te(e, r, t) {
279
+ var a, d, u;
280
+ const n = T("newSearch"), o = e.config.pageType, c = j(e.store.getInitialState().query, r), s = j(e.config.search, t, {
359
281
  track: o,
360
282
  redirect: o !== "autocomplete",
361
- isKeyword: !!(r != null && r.isKeyword)
283
+ isKeyword: !!(t != null && t.isKeyword)
362
284
  });
363
285
  e.store.updateState({
364
- query: u,
286
+ query: c,
365
287
  loading: !0,
366
288
  initialized: !0
367
289
  });
368
- const s = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
290
+ const i = o !== "autocomplete" && e.config.persistentSearchCache, l = e.config.queryModifications(
369
291
  {
370
- ...u,
292
+ ...c,
371
293
  products: {
372
- ...u.products,
294
+ ...c.products,
373
295
  // Apply filter merging to avoid overwriting base filters
374
- filter: ye((f = (c = e.store.getInitialState().query) == null ? void 0 : c.products) == null ? void 0 : f.filter, (a = t.products) == null ? void 0 : a.filter)
296
+ filter: we((d = (a = e.store.getInitialState().query) == null ? void 0 : a.products) == null ? void 0 : d.filter, (u = r.products) == null ? void 0 : u.filter)
375
297
  }
376
298
  },
377
299
  o
378
300
  );
379
301
  try {
380
- let d;
381
- const m = Ae(s, l);
302
+ let f;
303
+ const m = ze(i, l);
382
304
  if (m)
383
- d = m;
305
+ f = m;
384
306
  else {
385
- const g = pe(o, l);
386
- d = await Z(g, i), Fe(s, l, d);
307
+ const p = he(o, l);
308
+ f = await ie(p, s), Me(i, l, f);
387
309
  }
388
310
  e.store.updateState({
389
- response: d,
311
+ response: f,
390
312
  loading: !1
391
313
  });
392
- } catch (d) {
393
- console.error("Search action failed", d);
314
+ } catch (f) {
315
+ console.error("Search action failed", f);
394
316
  }
395
317
  n();
396
318
  }
397
- async function U(e, t, r) {
398
- const n = T("updateSearch"), o = z(e.store.getState().query, { products: { from: 0 } }, t);
399
- await W(e, o, r), n();
319
+ async function V(e, r, t) {
320
+ const n = T("updateSearch"), o = j(e.store.getState().query, { products: { from: 0 } }, r);
321
+ await te(e, o, t), n();
400
322
  }
401
- async function Me(e, t, r) {
402
- var i;
403
- const n = T("replaceFilter"), o = (i = e.store.getState().query.products) == null ? void 0 : i.filter, u = r !== void 0 ? [{ field: t, [typeof r == "object" ? "range" : "value"]: [r] }] : [];
404
- await U(e, {
323
+ async function Ie(e, r, t) {
324
+ var s;
325
+ const n = T("replaceFilter"), o = (s = e.store.getState().query.products) == null ? void 0 : s.filter, c = t !== void 0 ? [{ field: r, [typeof t == "object" ? "range" : "value"]: [t] }] : [];
326
+ await V(e, {
405
327
  products: {
406
- filter: [...(o == null ? void 0 : o.filter((s) => s.field !== t)) ?? [], ...u]
328
+ filter: [...(o == null ? void 0 : o.filter((i) => i.field !== r)) ?? [], ...c]
407
329
  }
408
330
  }), n();
409
331
  }
410
- async function _e(e, t, r, n) {
411
- var l, c;
412
- const o = T("toggleProductFilter"), u = (l = e.store.getState().query.products) == null ? void 0 : l.filter, i = u == null ? void 0 : u.find((f) => f.value instanceof Array && f.field === t), s = i != null && i.value ? {
413
- ...i,
414
- value: [...i.value.filter((f) => !A(f, r)), ...n ? [r] : []]
332
+ async function Re(e, r, t, n) {
333
+ var l, a;
334
+ const o = T("toggleProductFilter"), c = (l = e.store.getState().query.products) == null ? void 0 : l.filter, s = c == null ? void 0 : c.find((d) => d.value instanceof Array && d.field === r), i = s != null && s.value ? {
335
+ ...s,
336
+ value: [...s.value.filter((d) => !M(d, t)), ...n ? [t] : []]
415
337
  } : n ? {
416
- field: t,
417
- value: [r]
338
+ field: r,
339
+ value: [t]
418
340
  } : void 0;
419
- await U(e, {
341
+ await V(e, {
420
342
  products: {
421
- filter: [...(u == null ? void 0 : u.filter((f) => f !== i)) ?? [], ...(c = s == null ? void 0 : s.value) != null && c.length ? [s] : []]
343
+ filter: [...(c == null ? void 0 : c.filter((d) => d !== s)) ?? [], ...(a = i == null ? void 0 : i.value) != null && a.length ? [i] : []]
422
344
  }
423
345
  }), o();
424
346
  }
425
- function F() {
426
- const e = G(), t = E(M), r = b(
347
+ function C() {
348
+ const e = X(), r = E(A), t = z(
427
349
  () => ({
428
350
  config: e,
429
- store: t
351
+ store: r
430
352
  }),
431
- [e, t]
432
- ), n = v(
433
- (s, l) => W(r, s, l),
434
- [r]
435
- ), o = v(
436
- (s, l) => U(r, s, l),
437
- [r]
438
- ), u = v(
439
- (s, l, c) => _e(r, s, l, c),
440
- [r]
441
- ), i = v(
442
- (s, l) => Me(r, s, l),
443
- [r]
353
+ [e, r]
354
+ ), n = w(
355
+ (i, l) => te(t, i, l),
356
+ [t]
357
+ ), o = w(
358
+ (i, l) => V(t, i, l),
359
+ [t]
360
+ ), c = w(
361
+ (i, l, a) => Re(t, i, l, a),
362
+ [t]
363
+ ), s = w(
364
+ (i, l) => Ie(t, i, l),
365
+ [t]
444
366
  );
445
367
  return {
446
368
  newSearch: n,
447
369
  updateSearch: o,
448
- toggleProductFilter: u,
449
- replaceFilter: i
370
+ toggleProductFilter: c,
371
+ replaceFilter: s
372
+ };
373
+ }
374
+ function xe({ from: e, size: r, pageSize: t }) {
375
+ return J() ? {
376
+ products: { from: e + t }
377
+ } : {
378
+ products: { size: r + t }
379
+ };
380
+ }
381
+ function re(e = 24) {
382
+ const { from: r, size: t } = y((c) => {
383
+ var s, i;
384
+ return {
385
+ from: ((s = c.query.products) == null ? void 0 : s.from) ?? 0,
386
+ size: ((i = c.query.products) == null ? void 0 : i.size) ?? 0
387
+ };
388
+ }), { updateSearch: n } = C();
389
+ return {
390
+ loadMore: w(async () => {
391
+ await n(xe({ from: r, size: t, pageSize: e }));
392
+ }, [r, t, e, n])
450
393
  };
451
394
  }
452
- function C(e = Ne) {
453
- const t = E(M), [r, n] = _(e(t.getState()));
454
- return t.onChange(e, n), O(() => () => t.clearOnChange(n), [t]), r;
395
+ function _e({ pageSize: e }) {
396
+ const { loadMore: r } = re(e);
397
+ return /* @__PURE__ */ S("button", { onClick: r, children: "More results" });
398
+ }
399
+ function ne(e, r) {
400
+ var c, s, i;
401
+ const t = ((c = r.products) == null ? void 0 : c.total) ?? 0, n = ((s = e.products) == null ? void 0 : s.from) ?? 0, o = ((i = e.products) == null ? void 0 : i.size) ?? 0;
402
+ return t > 0 && t > n + o;
403
+ }
404
+ function Ne() {
405
+ return !!(window.IntersectionObserver && window.IntersectionObserverEntry && "intersectionRatio" in window.IntersectionObserverEntry.prototype);
406
+ }
407
+ function Te({ children: e, loadMoreComponent: r, pageSize: t }) {
408
+ const { loading: n, query: o, response: c } = y((i) => Y(i, "loading", "query", "response")), s = !n && ne(o, c);
409
+ return /* @__PURE__ */ S(G, { children: [
410
+ e,
411
+ s && (r ? /* @__PURE__ */ S(r, { pageSize: t }) : /* @__PURE__ */ S(_e, { pageSize: t }))
412
+ ] });
413
+ }
414
+ function Oe({ children: e, pageSize: r }) {
415
+ const t = se(null), { query: n, response: o } = y((s) => Y(s, "query", "response")), { loadMore: c } = re(r);
416
+ return x(() => {
417
+ let s, i;
418
+ return ne(n, o) && (s = t.current, i = new IntersectionObserver((l) => {
419
+ const a = l[0];
420
+ a != null && a.isIntersecting && c();
421
+ }), s && i.observe(s)), () => {
422
+ s && i.unobserve(s);
423
+ };
424
+ }, [o]), /* @__PURE__ */ S(G, { children: [
425
+ e,
426
+ /* @__PURE__ */ S("div", { ref: t, style: { height: "1px" } })
427
+ ] });
428
+ }
429
+ const tt = !J() && Ne() ? Oe : Te;
430
+ function je(e) {
431
+ return e.type === "input";
432
+ }
433
+ function Ee(e) {
434
+ return !!e && typeof e == "object" && "type" in e && "props" in e;
435
+ }
436
+ function B(e, r = { depth: 0 }) {
437
+ const { children: t } = e;
438
+ return oe(t).map((n) => {
439
+ if (!Ee(n))
440
+ return n;
441
+ const o = e.updateElement(n, r);
442
+ return o === null ? null : (o.props = {
443
+ ...o.props,
444
+ children: B({ ...e, children: o.props.children }, { depth: r.depth + 1 })
445
+ }, o);
446
+ });
447
+ }
448
+ function rt({ children: e, onSearchInput: r }) {
449
+ return B({
450
+ children: e,
451
+ updateElement: (t) => (!je(t) || t.props.type !== "search" || (t.props = {
452
+ ...t.props,
453
+ onInput: (n) => {
454
+ n.target instanceof HTMLInputElement && r(n.target);
455
+ }
456
+ }), t)
457
+ });
458
+ }
459
+ const qe = "nosto:search:scrollPos";
460
+ function $e() {
461
+ window.sessionStorage.setItem(qe, window.scrollY.toString());
455
462
  }
456
- const Ne = (e) => e;
457
- function Ke(e) {
458
- const t = C((r) => r.response);
459
- return e && Array.isArray(e) || e && P(e) ? e : t;
463
+ function nt({ children: e, hit: r, onClick: t }) {
464
+ const { pageType: n } = X(), o = n === "autocomplete" ? void 0 : n;
465
+ return B({
466
+ children: e,
467
+ updateElement: (c, s) => (s.depth > 0 || (c.props = {
468
+ ...c.props,
469
+ onClick: (i) => {
470
+ r && o && q((l) => l.recordSearchClick(o, r)), $e(), typeof t == "function" && t(i);
471
+ }
472
+ }), c)
473
+ });
460
474
  }
461
- function Qe(e) {
462
- var i;
463
- const t = ((i = e.data) == null ? void 0 : i.filter((s) => s.selected).length) ?? 0, [r, n] = _(t > 0), { toggleProductFilter: o } = F();
475
+ function D() {
476
+ x(() => {
477
+ const e = window.setTimeout(() => {
478
+ console.error("Nosto client script has not loaded after 3 seconds.");
479
+ }, 3e3);
480
+ q(() => {
481
+ window.clearTimeout(e);
482
+ });
483
+ }, []);
484
+ }
485
+ const L = {
486
+ defaultCurrency: "EUR",
487
+ queryModifications: (e) => e
488
+ }, Ve = {
489
+ ...L
490
+ };
491
+ function Be(e) {
492
+ return {
493
+ pageType: "autocomplete",
494
+ ...Ve,
495
+ ...e
496
+ };
497
+ }
498
+ function ot({ config: e, store: r, children: t }) {
499
+ const n = r ?? _();
500
+ return D(), /* @__PURE__ */ S(N, { value: Be(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
501
+ }
502
+ const De = {
503
+ ...L,
504
+ persistentSearchCache: !1,
505
+ preservePageScroll: !1
506
+ };
507
+ function Le(e) {
508
+ return {
509
+ pageType: "category",
510
+ ...De,
511
+ ...e
512
+ };
513
+ }
514
+ function st({ config: e, store: r, children: t }) {
515
+ const n = r ?? _();
516
+ return D(), /* @__PURE__ */ S(N, { value: Le(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
517
+ }
518
+ const Ue = {
519
+ ...L,
520
+ persistentSearchCache: !1,
521
+ preservePageScroll: !1
522
+ };
523
+ function Qe(e = {}) {
524
+ return {
525
+ pageType: "serp",
526
+ ...Ue,
527
+ ...e
528
+ };
529
+ }
530
+ function it({ config: e, store: r, children: t }) {
531
+ const n = r ?? _();
532
+ return D(), /* @__PURE__ */ S(N, { value: Qe(e), children: /* @__PURE__ */ S(A, { value: n, children: t }) });
533
+ }
534
+ function ct(e) {
535
+ const r = y((t) => t.response);
536
+ return e && Array.isArray(e) || e && P(e) ? e : r;
537
+ }
538
+ function at(e) {
539
+ var s;
540
+ const r = ((s = e.data) == null ? void 0 : s.filter((i) => i.selected).length) ?? 0, [t, n] = I(r > 0), { toggleProductFilter: o } = C();
464
541
  return {
465
542
  /** Active value */
466
- active: r,
543
+ active: t,
467
544
  /** Selected filters count */
468
- selectedFiltersCount: t,
545
+ selectedFiltersCount: r,
469
546
  /** Toggle active function */
470
547
  toggleActive: () => {
471
- n(!r);
548
+ n(!t);
472
549
  },
473
550
  /** Toggle product filter function */
474
551
  toggleProductFilter: o
475
552
  };
476
553
  }
477
- function He() {
478
- const { loading: e, facets: t } = C((r) => {
554
+ function ut() {
555
+ const { loading: e, facets: r } = y((t) => {
479
556
  var n, o;
480
557
  return {
481
- loading: r.loading,
482
- facets: ((o = (n = r.response) == null ? void 0 : n.products) == null ? void 0 : o.facets) ?? []
558
+ loading: t.loading,
559
+ facets: ((o = (n = t.response) == null ? void 0 : n.products) == null ? void 0 : o.facets) ?? []
483
560
  };
484
561
  });
485
562
  return {
486
563
  /** Loading state */
487
564
  loading: e,
488
565
  /** Array of facets*/
489
- facets: t
566
+ facets: r
490
567
  };
491
568
  }
492
- function Re(e, t) {
493
- const r = t - e;
494
- return !isNaN(r) && r > 0 ? new Array(t - e).fill(void 0).map((n, o) => o + e) : [];
569
+ function Ke(e, r) {
570
+ const t = r - e;
571
+ return !isNaN(t) && t > 0 ? new Array(r - e).fill(void 0).map((n, o) => o + e) : [];
495
572
  }
496
- function Le(e) {
497
- const { query: t, products: r } = C((n) => ({
573
+ function lt(e) {
574
+ const { query: r, products: t } = y((n) => ({
498
575
  query: n.query,
499
576
  products: n.response.products
500
577
  }));
501
- return b(() => {
502
- var w;
503
- if (!r)
578
+ return z(() => {
579
+ var k;
580
+ if (!t)
504
581
  return {
505
582
  totalPages: 0,
506
583
  resultsFrom: 0,
507
584
  resultsTo: 0,
508
585
  pages: []
509
586
  };
510
- const n = ((w = t.products) == null ? void 0 : w.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, u = Math.max(Math.floor(o - 1) / 2, 1), i = r.size > 0 ? Math.floor(n / r.size) + 1 : 1, s = r.size > 0 ? Math.ceil(r.total / r.size) : 0, l = (S) => S >= i - u && S <= i + u, c = n + 1, f = Math.min(n + r.total, r.total), a = {
587
+ const n = ((k = r.products) == null ? void 0 : k.from) ?? 0, o = (e == null ? void 0 : e.width) ?? 1 / 0, c = Math.max(Math.floor(o - 1) / 2, 1), s = t.size > 0 ? Math.floor(n / t.size) + 1 : 1, i = t.size > 0 ? Math.ceil(t.total / t.size) : 0, l = (b) => b >= s - c && b <= s + c, a = n + 1, d = Math.min(n + t.total, t.total), u = {
511
588
  from: n,
512
- page: i,
589
+ page: s,
513
590
  current: !0
514
- }, d = (S) => ({
515
- from: (S - 1) * r.size,
516
- page: S,
517
- current: S === i
518
- }), m = i > 1 ? d(i - 1) : void 0, g = i < s ? d(i + 1) : void 0, h = u === 1 / 0 || i - u - 1 > 1 ? d(1) : void 0, p = u === 1 / 0 || i + u + 1 < s ? d(s) : void 0, y = Re(1, s + 1).filter(l).map(d);
591
+ }, f = (b) => ({
592
+ from: (b - 1) * t.size,
593
+ page: b,
594
+ current: b === s
595
+ }), m = s > 1 ? f(s - 1) : void 0, p = s < i ? f(s + 1) : void 0, h = c === 1 / 0 || s - c - 1 > 1 ? f(1) : void 0, g = c === 1 / 0 || s + c + 1 < i ? f(i) : void 0, v = Ke(1, i + 1).filter(l).map(f);
519
596
  return {
520
- totalPages: s,
521
- resultsFrom: c,
522
- resultsTo: f,
523
- current: a,
597
+ totalPages: i,
598
+ resultsFrom: a,
599
+ resultsTo: d,
600
+ current: u,
524
601
  prev: m,
525
- next: g,
602
+ next: p,
526
603
  first: h,
527
- last: p,
528
- pages: y
604
+ last: g,
605
+ pages: v
529
606
  };
530
- }, [t, r, e == null ? void 0 : e.width]);
607
+ }, [r, t, e == null ? void 0 : e.width]);
531
608
  }
532
- function Ge() {
533
- const [e, t] = _([]), [r, n] = _([]);
534
- return O(() => {
609
+ function dt() {
610
+ const [e, r] = I([]), [t, n] = I([]);
611
+ return x(() => {
535
612
  q(async (o) => {
536
- const { products: u, segments: i } = await o.getSearchSessionParams();
537
- t(i ?? []), n((u == null ? void 0 : u.personalizationBoost) ?? []);
613
+ const { products: c, segments: s } = await o.getSearchSessionParams();
614
+ r(s ?? []), n((c == null ? void 0 : c.personalizationBoost) ?? []);
538
615
  });
539
616
  }, []), {
540
617
  segments: e,
541
- boost: r
618
+ boost: t
542
619
  };
543
620
  }
544
- function Ie() {
545
- const { facets: e } = C((c) => {
546
- var f;
621
+ function He() {
622
+ const { facets: e } = y((a) => {
623
+ var d;
547
624
  return {
548
- facets: ((f = c.response.products) == null ? void 0 : f.facets) ?? []
625
+ facets: ((d = a.response.products) == null ? void 0 : d.facets) ?? []
549
626
  };
550
- }), { replaceFilter: t, toggleProductFilter: r } = F(), n = v(
551
- (c) => {
552
- const f = e == null ? void 0 : e.find((a) => a.type === "stats" && a.field === c);
553
- if (f && "min" in f && "max" in f)
554
- return f;
627
+ }), { replaceFilter: r, toggleProductFilter: t } = C(), n = w(
628
+ (a) => {
629
+ const d = e == null ? void 0 : e.find((u) => u.type === "stats" && u.field === a);
630
+ if (d && "min" in d && "max" in d)
631
+ return d;
555
632
  },
556
633
  [e]
557
- ), o = v(
558
- (c) => {
559
- var f;
560
- return ((f = e == null ? void 0 : e.find((a) => a.field === c)) == null ? void 0 : f.name) ?? c;
634
+ ), o = w(
635
+ (a) => {
636
+ var d;
637
+ return ((d = e == null ? void 0 : e.find((u) => u.field === a)) == null ? void 0 : d.name) ?? a;
561
638
  },
562
639
  [e]
563
- ), u = v((c) => "field" in c && (c.value instanceof Array || c.range instanceof Array), []), i = v((c) => {
564
- var f;
640
+ ), c = w((a) => "field" in a && (a.value instanceof Array || a.range instanceof Array), []), s = w((a) => {
641
+ var d;
565
642
  return {
566
- ...c,
567
- range: (f = c.range) == null ? void 0 : f.map((a) => ({
568
- gt: a.gt ? Number(a.gt) : a.gt,
569
- gte: a.gte ? Number(a.gte) : a.gte,
570
- lt: a.lt ? Number(a.lt) : a.lt,
571
- lte: a.lte ? Number(a.lte) : a.lte
643
+ ...a,
644
+ range: (d = a.range) == null ? void 0 : d.map((u) => ({
645
+ gt: u.gt ? Number(u.gt) : u.gt,
646
+ gte: u.gte ? Number(u.gte) : u.gte,
647
+ lt: u.lt ? Number(u.lt) : u.lt,
648
+ lte: u.lte ? Number(u.lte) : u.lte
572
649
  }))
573
650
  };
574
- }, []), s = v(
575
- (c) => (c.value ?? []).map((a) => ({
576
- value: a,
577
- field: c.field,
578
- name: o(c.field),
579
- filter: i(c),
651
+ }, []), i = w(
652
+ (a) => (a.value ?? []).map((u) => ({
653
+ value: u,
654
+ field: a.field,
655
+ name: o(a.field),
656
+ filter: s(a),
580
657
  remove: () => {
581
- r(c.field, a, !1);
658
+ t(a.field, u, !1);
582
659
  }
583
660
  })),
584
- [i, o, r]
585
- ), l = v(
586
- (c) => (c.range ?? []).map((a) => {
587
- var g, h;
588
- const d = a.gte ?? a.gt ?? ((g = n(c.field)) == null ? void 0 : g.min), m = a.lte ?? a.lt ?? ((h = n(c.field)) == null ? void 0 : h.max);
589
- if (d !== void 0 && m !== void 0)
661
+ [s, o, t]
662
+ ), l = w(
663
+ (a) => (a.range ?? []).map((u) => {
664
+ var p, h;
665
+ const f = u.gte ?? u.gt ?? ((p = n(a.field)) == null ? void 0 : p.min), m = u.lte ?? u.lt ?? ((h = n(a.field)) == null ? void 0 : h.max);
666
+ if (f !== void 0 && m !== void 0)
590
667
  return {
591
- value: `${d} - ${m}`,
592
- field: c.field,
593
- name: o(c.field),
594
- filter: i(c),
668
+ value: `${f} - ${m}`,
669
+ field: a.field,
670
+ name: o(a.field),
671
+ filter: s(a),
595
672
  remove: () => {
596
- t(c.field, void 0);
673
+ r(a.field, void 0);
597
674
  }
598
675
  };
599
676
  }).filter(Boolean),
600
- [i, n, o, t]
677
+ [s, n, o, r]
601
678
  );
602
679
  return {
603
- selectFilters: u,
604
- toValueFilter: s,
680
+ selectFilters: c,
681
+ toValueFilter: i,
605
682
  toRangeFilter: l
606
683
  };
607
684
  }
608
- function Te() {
609
- const { filter: e } = C((s) => {
685
+ function We() {
686
+ const { filter: e } = y((i) => {
610
687
  var l;
611
688
  return {
612
- filter: ((l = s.query.products) == null ? void 0 : l.filter) ?? []
689
+ filter: ((l = i.query.products) == null ? void 0 : l.filter) ?? []
613
690
  };
614
- }), { updateSearch: t } = F(), { selectFilters: r, toValueFilter: n, toRangeFilter: o } = Ie(), u = b(() => e ? e.filter(r).flatMap((s) => "value" in s ? n(s) : "range" in s ? o(s) : []).filter(Boolean) : [], [e, r, o, n]), i = v(() => {
615
- t({
691
+ }), { updateSearch: r } = C(), { selectFilters: t, toValueFilter: n, toRangeFilter: o } = He(), c = z(() => e ? e.filter(t).flatMap((i) => "value" in i ? n(i) : "range" in i ? o(i) : []).filter(Boolean) : [], [e, t, o, n]), s = w(() => {
692
+ r({
616
693
  products: {
617
694
  filter: []
618
695
  }
619
696
  });
620
- }, [t]);
697
+ }, [r]);
621
698
  return {
622
699
  /** Selected filters array. */
623
- filters: u,
700
+ filters: c,
624
701
  /** Should remove all selected filters. */
625
- removeAll: i
702
+ removeAll: s
626
703
  };
627
704
  }
628
- function N(e) {
705
+ function R(e) {
629
706
  if (typeof e == "number")
630
707
  return e;
631
708
  if (typeof e != "string")
632
709
  return;
633
- const t = Number(e);
634
- return isNaN(t) ? void 0 : t;
635
- }
636
- function xe(e) {
637
- var a, d, m;
638
- const { replaceFilter: t } = F(), { query: r, products: n } = C((g) => ({
639
- query: g.query,
640
- products: g.response.products
641
- })), o = (a = n == null ? void 0 : n.facets) == null ? void 0 : a.find((g) => g.id === e);
710
+ const r = Number(e);
711
+ return isNaN(r) ? void 0 : r;
712
+ }
713
+ function Ge(e) {
714
+ var u, f, m;
715
+ const { replaceFilter: r } = C(), { query: t, products: n } = y((p) => ({
716
+ query: p.query,
717
+ products: p.response.products
718
+ })), o = (u = n == null ? void 0 : n.facets) == null ? void 0 : u.find((p) => p.id === e);
642
719
  if (!o)
643
720
  return {
644
721
  min: 0,
@@ -647,140 +724,140 @@ function xe(e) {
647
724
  updateRange: () => {
648
725
  }
649
726
  };
650
- const u = (m = (d = r.products) == null ? void 0 : d.filter) == null ? void 0 : m.find((g) => g.field === o.field), i = u != null && u.range ? u.range[0] : void 0, s = typeof i == "object" && ("gte" in i || "lte" in i) ? [N(i.gte), N(i.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, c = "max" in o ? Math.ceil(o.max) : 0, f = ([g, h]) => {
651
- const p = g !== void 0 ? Math.floor(g) : void 0, y = h !== void 0 ? Math.ceil(h) : void 0, w = p !== void 0, S = y !== void 0;
652
- (l === p || !w) && (c === y || !S) ? t(o.field, void 0) : (l === p || !w) && S ? t(o.field, {
653
- lte: y.toString()
654
- }) : (c === y || !S) && w ? t(o.field, {
655
- gte: p.toString()
656
- }) : w && S && t(o.field, {
657
- gte: p.toString(),
658
- lte: y.toString()
727
+ const c = (m = (f = t.products) == null ? void 0 : f.filter) == null ? void 0 : m.find((p) => p.field === o.field), s = c != null && c.range ? c.range[0] : void 0, i = typeof s == "object" && ("gte" in s || "lte" in s) ? [R(s.gte), R(s.lte)] : [void 0, void 0], l = "min" in o ? Math.floor(o.min) : 0, a = "max" in o ? Math.ceil(o.max) : 0, d = ([p, h]) => {
728
+ const g = p !== void 0 ? Math.floor(p) : void 0, v = h !== void 0 ? Math.ceil(h) : void 0, k = g !== void 0, b = v !== void 0;
729
+ (l === g || !k) && (a === v || !b) ? r(o.field, void 0) : (l === g || !k) && b ? r(o.field, {
730
+ lte: v.toString()
731
+ }) : (a === v || !b) && k ? r(o.field, {
732
+ gte: g.toString()
733
+ }) : k && b && r(o.field, {
734
+ gte: g.toString(),
735
+ lte: v.toString()
659
736
  });
660
737
  };
661
738
  return {
662
739
  /** Min value */
663
740
  min: l,
664
741
  /** Max value */
665
- max: c,
742
+ max: a,
666
743
  /** Range value */
667
- range: [s[0] ?? l, s[1] ?? c],
744
+ range: [i[0] ?? l, i[1] ?? a],
668
745
  /** Update range function */
669
- updateRange: f
746
+ updateRange: d
670
747
  };
671
748
  }
672
- function Je(e, t) {
673
- const { min: r, max: n, range: o, updateRange: u } = xe(e), { filters: i } = Te(), s = b(() => {
749
+ function ft(e, r) {
750
+ const { min: t, max: n, range: o, updateRange: c } = Ge(e), { filters: s } = We(), i = z(() => {
674
751
  var h;
675
- const a = i.find((p) => {
676
- var y;
677
- return (y = p == null ? void 0 : p.filter) == null ? void 0 : y.range;
752
+ const u = s.find((g) => {
753
+ var v;
754
+ return (v = g == null ? void 0 : g.filter) == null ? void 0 : v.range;
678
755
  });
679
- let d = null;
680
- if (a) {
681
- const p = (h = a.filter.range) == null ? void 0 : h[0];
682
- d = [N(p == null ? void 0 : p.gte), N(p == null ? void 0 : p.lte)];
756
+ let f = null;
757
+ if (u) {
758
+ const g = (h = u.filter.range) == null ? void 0 : h[0];
759
+ f = [R(g == null ? void 0 : g.gte), R(g == null ? void 0 : g.lte)];
683
760
  }
684
761
  const m = [];
685
- let g = Math.floor(r / t) * t;
686
- for (; g < n; ) {
687
- const p = g + t, y = d && d[0] === g && d[1] === p;
762
+ let p = Math.floor(t / r) * r;
763
+ for (; p < n; ) {
764
+ const g = p + r, v = f && f[0] === p && f[1] === g;
688
765
  m.push({
689
- min: g,
690
- max: p,
691
- selected: y
692
- }), g = p;
766
+ min: p,
767
+ max: g,
768
+ selected: v
769
+ }), p = g;
693
770
  }
694
771
  return m;
695
- }, [i, r, n, t]), l = (a) => {
696
- u([a, o[1]]);
697
- }, c = (a) => {
698
- u([o[0], a]);
699
- }, f = r !== o[0] || n !== o[1];
772
+ }, [s, t, n, r]), l = (u) => {
773
+ c([u, o[1]]);
774
+ }, a = (u) => {
775
+ c([o[0], u]);
776
+ }, d = t !== o[0] || n !== o[1];
700
777
  return {
701
778
  /** Minimum value */
702
- min: r,
779
+ min: t,
703
780
  /** Maximum value */
704
781
  max: n,
705
782
  /** Range value */
706
783
  range: o,
707
784
  /** Update range function */
708
- updateRange: u,
785
+ updateRange: c,
709
786
  /** Ranges */
710
- ranges: s,
787
+ ranges: i,
711
788
  /** Handle min change */
712
789
  handleMinChange: l,
713
790
  /** Handle max change */
714
- handleMaxChange: c,
791
+ handleMaxChange: a,
715
792
  /** Is selected */
716
- isSelected: f
793
+ isSelected: d
717
794
  };
718
795
  }
719
- function Ye() {
720
- const { products: e, keywords: t } = C((r) => r.response);
796
+ function pt() {
797
+ const { products: e, keywords: r } = y((t) => t.response);
721
798
  return {
722
799
  /** Array of products */
723
800
  products: e ?? { hits: [], total: 0 },
724
801
  /** Array of keywords */
725
- keywords: t ?? { hits: [], total: 0 }
802
+ keywords: r ?? { hits: [], total: 0 }
726
803
  };
727
804
  }
728
- function We() {
729
- const e = C((r) => {
805
+ function gt() {
806
+ const e = y((t) => {
730
807
  var n;
731
- return (n = r.query.products) == null ? void 0 : n.filter;
808
+ return (n = t.query.products) == null ? void 0 : n.filter;
732
809
  });
733
- return b(() => e ? e.reduce((r, n) => r + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
810
+ return z(() => e ? e.reduce((t, n) => t + (Array.isArray(n.value) ? n.value.length : 1), 0) : 0, [e]);
734
811
  }
735
- function x(e) {
812
+ function O(e) {
736
813
  return e && !Number.isNaN(e) ? e : 0;
737
814
  }
738
- function Xe(e, t) {
739
- const { from: r, size: n, total: o } = C((c) => {
740
- var f, a, d, m, g;
815
+ function mt(e, r) {
816
+ const { from: t, size: n, total: o } = y((a) => {
817
+ var d, u, f, m, p;
741
818
  return {
742
- from: x(((f = c.query.products) == null ? void 0 : f.from) ?? 0),
743
- size: x(((d = (a = c.response) == null ? void 0 : a.products) == null ? void 0 : d.size) ?? 0),
744
- total: x(((g = (m = c.response) == null ? void 0 : m.products) == null ? void 0 : g.total) ?? 0)
819
+ from: O(((d = a.query.products) == null ? void 0 : d.from) ?? 0),
820
+ size: O(((f = (u = a.response) == null ? void 0 : u.products) == null ? void 0 : f.size) ?? 0),
821
+ total: O(((p = (m = a.response) == null ? void 0 : m.products) == null ? void 0 : p.total) ?? 0)
745
822
  };
746
- }), { updateSearch: u } = F(), i = r + n, s = [...e].reverse().filter((c) => c + t < o);
823
+ }), { updateSearch: c } = C(), s = t + n, i = [...e].reverse().filter((a) => a + r < o);
747
824
  return {
748
825
  /** from value */
749
- from: r,
826
+ from: t,
750
827
  /** to value */
751
- to: i,
828
+ to: s,
752
829
  /** total value */
753
830
  total: o,
754
831
  /** size value */
755
832
  size: n,
756
833
  /** Array of size options */
757
- sizeOptions: s,
834
+ sizeOptions: i,
758
835
  /** Should be called when size is changed */
759
- handleSizeChange: (c) => {
760
- u({
836
+ handleSizeChange: (a) => {
837
+ c({
761
838
  products: {
762
- size: c
839
+ size: a
763
840
  }
764
841
  });
765
842
  }
766
843
  };
767
844
  }
768
- function ze(e, t) {
769
- return e.length !== t.length ? !1 : e.every((r) => t.find((n) => r.field === n.field && r.order === n.order));
845
+ function Je(e, r) {
846
+ return e.length !== r.length ? !1 : e.every((t) => r.find((n) => t.field === n.field && t.order === n.order));
770
847
  }
771
- function Ze(e) {
772
- var u, i;
773
- const t = C((s) => s.query), { updateSearch: r } = F();
848
+ function ht(e) {
849
+ var c, s;
850
+ const r = y((i) => i.query), { updateSearch: t } = C();
774
851
  return {
775
852
  /** Active sort */
776
- activeSort: ((u = e.find((s) => {
853
+ activeSort: ((c = e.find((i) => {
777
854
  var l;
778
- return ze(s.value.sort, ((l = t.products) == null ? void 0 : l.sort) || []);
779
- })) == null ? void 0 : u.id) ?? ((i = e[0]) == null ? void 0 : i.id),
855
+ return Je(i.value.sort, ((l = r.products) == null ? void 0 : l.sort) || []);
856
+ })) == null ? void 0 : c.id) ?? ((s = e[0]) == null ? void 0 : s.id),
780
857
  /** Set sort function */
781
- setSort: (s) => {
782
- const l = e.find((c) => c.id === s);
783
- l && r({
858
+ setSort: (i) => {
859
+ const l = e.find((a) => a.id === i);
860
+ l && t({
784
861
  products: {
785
862
  sort: l.value.sort
786
863
  }
@@ -789,27 +866,29 @@ function Ze(e) {
789
866
  };
790
867
  }
791
868
  export {
792
- De as AutocompletePageProvider,
793
- Ue as CategoryPageProvider,
794
- $e as SearchInput,
795
- Be as SearchPageProvider,
796
- je as SerpElement,
797
- M as StoreContext,
798
- se as createExtendableStore,
799
- I as createStore,
800
- ie as defaultState,
801
- F as useActions,
802
- Ke as useDecoratedSearchResults,
803
- Qe as useFacet,
804
- He as useFacets,
805
- C as useNostoAppState,
806
- Le as usePagination,
807
- Ge as usePersonalization,
808
- Te as useProductFilters,
809
- xe as useRange,
810
- Je as useRangeSelector,
811
- Ye as useResponse,
812
- We as useSelectedFiltersCount,
813
- Xe as useSizeOptions,
814
- Ze as useSort
869
+ ot as AutocompletePageProvider,
870
+ st as CategoryPageProvider,
871
+ tt as InfiniteScroll,
872
+ rt as SearchInput,
873
+ it as SearchPageProvider,
874
+ nt as SerpElement,
875
+ A as StoreContext,
876
+ fe as createExtendableStore,
877
+ _ as createStore,
878
+ pe as defaultState,
879
+ C as useActions,
880
+ ct as useDecoratedSearchResults,
881
+ at as useFacet,
882
+ ut as useFacets,
883
+ re as useLoadMore,
884
+ y as useNostoAppState,
885
+ lt as usePagination,
886
+ dt as usePersonalization,
887
+ We as useProductFilters,
888
+ Ge as useRange,
889
+ ft as useRangeSelector,
890
+ pt as useResponse,
891
+ gt as useSelectedFiltersCount,
892
+ mt as useSizeOptions,
893
+ ht as useSort
815
894
  };