@nosto/nosto-react 0.4.3 → 1.0.0

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.
package/dist/index.es.js CHANGED
@@ -1,619 +1,927 @@
1
- import React, { createContext, useContext, useEffect, useRef, useMemo, isValidElement, useState } from "react";
2
- import { createRoot } from "react-dom/client";
3
- const NostoContext = createContext({
1
+ import B, { createContext as Rt, useContext as ht, useEffect as te, useRef as pe, useMemo as Et, isValidElement as Ct, useState as bt } from "react";
2
+ import { createRoot as _t } from "react-dom/client";
3
+ const qe = Rt({
4
4
  account: "",
5
5
  currentVariation: "",
6
6
  pageType: "",
7
7
  responseMode: "HTML",
8
- clientScriptLoaded: false,
9
- useRenderCampaigns: () => {
10
- return {
11
- renderCampaigns: () => {
12
- },
13
- pageTypeUpdated: false
14
- };
15
- }
8
+ clientScriptLoaded: !1,
9
+ useRenderCampaigns: () => ({
10
+ renderCampaigns: () => {
11
+ },
12
+ pageTypeUpdated: !1
13
+ })
16
14
  });
17
- function useNostoContext() {
18
- const context = useContext(NostoContext);
19
- if (!context) {
15
+ function x() {
16
+ const n = ht(qe);
17
+ if (!n)
20
18
  throw new Error("No nosto context found");
21
- }
22
- return context;
23
- }
24
- const isObject = (v) => String(v) === "[object Object]";
25
- function isPlainObject(value) {
26
- if (!isObject(value))
27
- return false;
28
- const constructor = value.constructor;
29
- if (constructor === void 0)
30
- return true;
31
- const prototype = constructor.prototype;
32
- if (!isObject(prototype))
33
- return false;
34
- if (!prototype.hasOwnProperty("isPrototypeOf")) {
35
- return false;
36
- }
37
- return true;
38
- }
39
- function deepCompare(a, b) {
40
- if (a === b) {
41
- return true;
42
- }
43
- if (a instanceof Date && b instanceof Date) {
44
- return a.getTime() === b.getTime();
45
- }
46
- if (a instanceof Array && b instanceof Array) {
47
- if (a.length !== b.length) {
48
- return false;
49
- }
50
- return a.every((v, i) => deepCompare(v, b[i]));
51
- }
52
- if (isPlainObject(a) && isPlainObject(b)) {
53
- const entriesA = Object.entries(a);
54
- if (entriesA.length !== Object.keys(b).length) {
55
- return false;
56
- }
57
- return entriesA.every(([k2, v]) => deepCompare(v, b[k2]));
58
- }
59
- return false;
19
+ return n;
60
20
  }
61
- function useDeepCompareEffect(callback, dependencies) {
62
- return useEffect(callback, useDeepCompareMemoize(dependencies));
21
+ const We = (n) => String(n) === "[object Object]";
22
+ function Ve(n) {
23
+ if (!We(n))
24
+ return !1;
25
+ const o = n.constructor;
26
+ if (o === void 0)
27
+ return !0;
28
+ const a = o.prototype;
29
+ return !(!We(a) || !a.hasOwnProperty("isPrototypeOf"));
63
30
  }
64
- function useDeepCompareMemoize(value) {
65
- const ref = useRef(value);
66
- const signalRef = useRef(0);
67
- if (!deepCompare(value, ref.current)) {
68
- ref.current = value;
69
- signalRef.current += 1;
31
+ function me(n, o) {
32
+ if (n === o)
33
+ return !0;
34
+ if (n instanceof Date && o instanceof Date)
35
+ return n.getTime() === o.getTime();
36
+ if (n instanceof Array && o instanceof Array)
37
+ return n.length !== o.length ? !1 : n.every((a, u) => me(a, o[u]));
38
+ if (Ve(n) && Ve(o)) {
39
+ const a = Object.entries(n);
40
+ return a.length !== Object.keys(o).length ? !1 : a.every(([u, d]) => me(d, o[u]));
70
41
  }
71
- return useMemo(() => ref.current, [signalRef.current]);
42
+ return !1;
72
43
  }
73
- function useNostoApi(cb, deps, flags) {
74
- const { clientScriptLoaded, currentVariation, responseMode } = useNostoContext();
75
- const useEffectFn = (flags == null ? void 0 : flags.deep) ? useDeepCompareEffect : useEffect;
76
- useEffectFn(() => {
77
- if (clientScriptLoaded) {
78
- window.nostojs((api) => {
79
- api.defaultSession().setVariation(currentVariation).setResponseMode(responseMode);
80
- cb(api);
81
- });
82
- }
83
- }, [clientScriptLoaded, currentVariation, responseMode, ...deps != null ? deps : []]);
44
+ function Be(n, o) {
45
+ return te(n, wt(o));
84
46
  }
85
- var jsxRuntime = { exports: {} };
86
- var reactJsxRuntime_production_min = {};
87
- /**
88
- * @license React
89
- * react-jsx-runtime.production.min.js
90
- *
91
- * Copyright (c) Facebook, Inc. and its affiliates.
92
- *
93
- * This source code is licensed under the MIT license found in the
94
- * LICENSE file in the root directory of this source tree.
95
- */
96
- var f = React, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
97
- function q(c, a, g) {
98
- var b, d = {}, e = null, h = null;
99
- void 0 !== g && (e = "" + g);
100
- void 0 !== a.key && (e = "" + a.key);
101
- void 0 !== a.ref && (h = a.ref);
102
- for (b in a)
103
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
104
- if (c && c.defaultProps)
105
- for (b in a = c.defaultProps, a)
106
- void 0 === d[b] && (d[b] = a[b]);
107
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
47
+ function wt(n) {
48
+ const o = pe(n), a = pe(0);
49
+ return me(n, o.current) || (o.current = n, a.current += 1), Et(() => o.current, [a.current]);
108
50
  }
109
- reactJsxRuntime_production_min.Fragment = l;
110
- reactJsxRuntime_production_min.jsx = q;
111
- reactJsxRuntime_production_min.jsxs = q;
112
- {
113
- jsxRuntime.exports = reactJsxRuntime_production_min;
51
+ function N(n, o, a) {
52
+ const { clientScriptLoaded: u, currentVariation: d, responseMode: c } = x();
53
+ (a != null && a.deep ? Be : te)(() => {
54
+ u && window.nostojs((m) => {
55
+ m.defaultSession().setVariation(d).setResponseMode(c), n(m);
56
+ });
57
+ }, [u, d, c, ...o ?? []]);
114
58
  }
115
- const jsx = jsxRuntime.exports.jsx;
116
- const jsxs = jsxRuntime.exports.jsxs;
117
- const Fragment = jsxRuntime.exports.Fragment;
118
- function Nosto404(props) {
119
- const {
120
- recommendationComponent,
121
- useRenderCampaigns
122
- } = useNostoContext();
59
+ function kt(n) {
123
60
  const {
124
- renderCampaigns,
125
- pageTypeUpdated
126
- } = useRenderCampaigns("404");
127
- useNostoApi(async (api) => {
128
- const data = await api.defaultSession().viewNotFound().setPlacements(props.placements || api.placements.getPlacements()).load();
129
- renderCampaigns(data, api);
130
- }, [recommendationComponent, pageTypeUpdated]);
131
- return /* @__PURE__ */ jsx(Fragment, {
132
- children: /* @__PURE__ */ jsx("div", {
133
- className: "nosto_page_type",
134
- style: {
135
- display: "none"
136
- },
137
- children: "notfound"
138
- })
139
- });
61
+ recommendationComponent: o,
62
+ useRenderCampaigns: a
63
+ } = x(), {
64
+ renderCampaigns: u,
65
+ pageTypeUpdated: d
66
+ } = a("404");
67
+ return N(async (c) => {
68
+ const i = await c.defaultSession().viewNotFound().setPlacements(n.placements || c.placements.getPlacements()).load();
69
+ u(i, c);
70
+ }, [o, d]), null;
140
71
  }
141
- function NostoOther(props) {
142
- const {
143
- recommendationComponent,
144
- useRenderCampaigns
145
- } = useNostoContext();
72
+ function Dt(n) {
146
73
  const {
147
- renderCampaigns,
148
- pageTypeUpdated
149
- } = useRenderCampaigns("other");
150
- useNostoApi(async (api) => {
151
- const data = await api.defaultSession().viewOther().setPlacements(props.placements || api.placements.getPlacements()).load();
152
- renderCampaigns(data, api);
153
- }, [recommendationComponent, pageTypeUpdated]);
154
- return /* @__PURE__ */ jsx(Fragment, {
155
- children: /* @__PURE__ */ jsx("div", {
156
- className: "nosto_page_type",
157
- style: {
158
- display: "none"
159
- },
160
- children: "other"
161
- })
162
- });
74
+ recommendationComponent: o,
75
+ useRenderCampaigns: a
76
+ } = x(), {
77
+ renderCampaigns: u,
78
+ pageTypeUpdated: d
79
+ } = a("other");
80
+ return N(async (c) => {
81
+ const i = await c.defaultSession().viewOther().setPlacements(n.placements || c.placements.getPlacements()).load();
82
+ u(i, c);
83
+ }, [o, d]), null;
163
84
  }
164
- function NostoCheckout(props) {
85
+ function Ft(n) {
165
86
  const {
166
- recommendationComponent,
167
- useRenderCampaigns
168
- } = useNostoContext();
169
- const {
170
- renderCampaigns,
171
- pageTypeUpdated
172
- } = useRenderCampaigns("checkout");
173
- useNostoApi(async (api) => {
174
- const data = await api.defaultSession().viewCart().setPlacements(props.placements || api.placements.getPlacements()).load();
175
- renderCampaigns(data, api);
176
- }, [recommendationComponent, pageTypeUpdated]);
177
- return /* @__PURE__ */ jsx(Fragment, {
178
- children: /* @__PURE__ */ jsx("div", {
179
- className: "nosto_page_type",
180
- style: {
181
- display: "none"
182
- },
183
- children: "cart"
184
- })
185
- });
87
+ recommendationComponent: o,
88
+ useRenderCampaigns: a
89
+ } = x(), {
90
+ renderCampaigns: u,
91
+ pageTypeUpdated: d
92
+ } = a("checkout");
93
+ return N(async (c) => {
94
+ const i = await c.defaultSession().viewCart().setPlacements(n.placements || c.placements.getPlacements()).load();
95
+ u(i, c);
96
+ }, [o, d]), null;
186
97
  }
187
- function NostoProduct(props) {
188
- const {
189
- product,
190
- tagging,
191
- placements
192
- } = props;
98
+ function Nt(n) {
193
99
  const {
194
- recommendationComponent,
195
- useRenderCampaigns
196
- } = useNostoContext();
197
- const {
198
- renderCampaigns,
199
- pageTypeUpdated
200
- } = useRenderCampaigns("product");
201
- useNostoApi(async (api) => {
202
- const data = await api.defaultSession().viewProduct(product).setPlacements(placements || api.placements.getPlacements()).load();
203
- renderCampaigns(data, api);
204
- }, [product, recommendationComponent, pageTypeUpdated], {
205
- deep: true
206
- });
207
- return /* @__PURE__ */ jsxs(Fragment, {
208
- children: [/* @__PURE__ */ jsx("div", {
209
- className: "nosto_page_type",
210
- style: {
211
- display: "none"
212
- },
213
- children: "product"
214
- }), /* @__PURE__ */ jsxs("div", {
215
- className: "nosto_product",
216
- style: {
217
- display: "none"
218
- },
219
- children: [(tagging == null ? void 0 : tagging.variationId) && /* @__PURE__ */ jsx("span", {
220
- className: "variation_id",
221
- children: tagging.variationId
222
- }), product && /* @__PURE__ */ jsx("span", {
223
- className: "product_id",
224
- children: product
225
- }), (tagging == null ? void 0 : tagging.name) && /* @__PURE__ */ jsx("span", {
226
- className: "name",
227
- children: tagging.name
228
- }), (tagging == null ? void 0 : tagging.url) && /* @__PURE__ */ jsx("span", {
229
- className: "url",
230
- children: tagging.url.toString()
231
- }), (tagging == null ? void 0 : tagging.imageUrl) && /* @__PURE__ */ jsx("span", {
232
- className: "image_url",
233
- children: tagging.imageUrl.toString()
234
- }), (tagging == null ? void 0 : tagging.availability) && /* @__PURE__ */ jsx("span", {
235
- className: "availability",
236
- children: tagging.availability
237
- }), (tagging == null ? void 0 : tagging.price) && /* @__PURE__ */ jsx("span", {
238
- className: "price",
239
- children: tagging.price
240
- }), (tagging == null ? void 0 : tagging.listPrice) && /* @__PURE__ */ jsx("span", {
241
- className: "list_price",
242
- children: tagging.listPrice
243
- }), (tagging == null ? void 0 : tagging.priceCurrencyCode) && /* @__PURE__ */ jsx("span", {
244
- className: "price_currency_code",
245
- children: tagging.priceCurrencyCode
246
- }), (tagging == null ? void 0 : tagging.brand) && /* @__PURE__ */ jsx("span", {
247
- className: "brand",
248
- children: tagging.brand
249
- }), (tagging == null ? void 0 : tagging.description) && /* @__PURE__ */ jsx("span", {
250
- className: "description",
251
- children: tagging.description
252
- }), (tagging == null ? void 0 : tagging.googleCategory) && /* @__PURE__ */ jsx("span", {
253
- className: "description",
254
- children: tagging.googleCategory
255
- }), (tagging == null ? void 0 : tagging.condition) && /* @__PURE__ */ jsx("span", {
256
- className: "condition",
257
- children: tagging.condition
258
- }), (tagging == null ? void 0 : tagging.gender) && /* @__PURE__ */ jsx("span", {
259
- className: "gender",
260
- children: tagging.gender
261
- }), (tagging == null ? void 0 : tagging.ageGroup) && /* @__PURE__ */ jsx("span", {
262
- className: "age_group",
263
- children: tagging.ageGroup
264
- }), (tagging == null ? void 0 : tagging.gtin) && /* @__PURE__ */ jsx("span", {
265
- className: "gtin",
266
- children: tagging.gtin
267
- }), (tagging == null ? void 0 : tagging.category) && (tagging == null ? void 0 : tagging.category.map((category, index) => /* @__PURE__ */ jsx("span", {
268
- className: "category",
269
- children: category
270
- }, index))), (tagging == null ? void 0 : tagging.tags1) && tagging.tags1.map((tag, index) => /* @__PURE__ */ jsx("span", {
271
- className: "tag1",
272
- children: tag
273
- }, index)), (tagging == null ? void 0 : tagging.tags2) && tagging.tags2.map((tag, index) => /* @__PURE__ */ jsx("span", {
274
- className: "tag2",
275
- children: tag
276
- }, index)), (tagging == null ? void 0 : tagging.tags3) && tagging.tags3.map((tag, index) => /* @__PURE__ */ jsx("span", {
277
- className: "tag3",
278
- children: tag
279
- }, index)), (tagging == null ? void 0 : tagging.ratingValue) && /* @__PURE__ */ jsx("span", {
280
- className: "rating_value",
281
- children: tagging.ratingValue
282
- }), (tagging == null ? void 0 : tagging.reviewCount) && /* @__PURE__ */ jsx("span", {
283
- className: "review_count",
284
- children: tagging.reviewCount
285
- }), (tagging == null ? void 0 : tagging.alternateImageUrls) && tagging.alternateImageUrls.map((url, index) => /* @__PURE__ */ jsx("span", {
286
- className: "alternate_image_url",
287
- children: url.toString()
288
- }, index)), (tagging == null ? void 0 : tagging.customFields) && Object.keys(tagging.customFields).map((field, index) => tagging.customFields && tagging.customFields[field] && /* @__PURE__ */ jsx("span", {
289
- className: field,
290
- children: tagging.customFields[field]
291
- }, index)), (tagging == null ? void 0 : tagging.skus) && tagging.skus.map((sku, index) => /* @__PURE__ */ jsxs("span", {
292
- className: "nosto_sku",
293
- children: [(sku == null ? void 0 : sku.id) && /* @__PURE__ */ jsx("span", {
294
- className: "product_id",
295
- children: sku.id
296
- }), (sku == null ? void 0 : sku.name) && /* @__PURE__ */ jsx("span", {
297
- className: "name",
298
- children: sku.name
299
- }), (sku == null ? void 0 : sku.price) && /* @__PURE__ */ jsx("span", {
300
- className: "price",
301
- children: sku.price
302
- }), (sku == null ? void 0 : sku.listPrice) && /* @__PURE__ */ jsx("span", {
303
- className: "list_price",
304
- children: sku.listPrice
305
- }), (sku == null ? void 0 : sku.url) && /* @__PURE__ */ jsx("span", {
306
- className: "url",
307
- children: sku.url.toString()
308
- }), (sku == null ? void 0 : sku.imageUrl) && /* @__PURE__ */ jsx("span", {
309
- className: "image_url",
310
- children: sku.imageUrl.toString()
311
- }), (sku == null ? void 0 : sku.gtin) && /* @__PURE__ */ jsx("span", {
312
- className: "gtin",
313
- children: sku.gtin
314
- }), (sku == null ? void 0 : sku.availability) && /* @__PURE__ */ jsx("span", {
315
- className: "availability",
316
- children: sku.availability
317
- }), (sku == null ? void 0 : sku.customFields) && Object.keys(sku.customFields).map((field, index2) => sku.customFields && sku.customFields[field] && /* @__PURE__ */ jsx("span", {
318
- className: field,
319
- children: sku.customFields[field]
320
- }, index2))]
321
- }, index))]
322
- })]
323
- });
100
+ product: o,
101
+ tagging: a,
102
+ placements: u
103
+ } = n, {
104
+ recommendationComponent: d,
105
+ useRenderCampaigns: c
106
+ } = x(), {
107
+ renderCampaigns: i,
108
+ pageTypeUpdated: m
109
+ } = c("product");
110
+ return N(async (v) => {
111
+ const O = await v.defaultSession().viewProduct(a ?? o).setPlacements(u || v.placements.getPlacements()).load();
112
+ i(O, v);
113
+ }, [o, d, m], {
114
+ deep: !0
115
+ }), null;
324
116
  }
325
- function NostoCategory(props) {
326
- const {
327
- category,
328
- placements
329
- } = props;
330
- const {
331
- recommendationComponent,
332
- useRenderCampaigns
333
- } = useNostoContext();
117
+ function Lt(n) {
334
118
  const {
335
- renderCampaigns,
336
- pageTypeUpdated
337
- } = useRenderCampaigns("home");
338
- useNostoApi(async (api) => {
339
- const data = await api.defaultSession().viewCategory(category).setPlacements(placements || api.placements.getPlacements()).load();
340
- renderCampaigns(data, api);
341
- }, [category, recommendationComponent, pageTypeUpdated]);
342
- return /* @__PURE__ */ jsxs(Fragment, {
343
- children: [/* @__PURE__ */ jsx("div", {
344
- className: "nosto_page_type",
345
- style: {
346
- display: "none"
347
- },
348
- children: "category"
349
- }), /* @__PURE__ */ jsx("div", {
350
- className: "nosto_category",
351
- style: {
352
- display: "none"
353
- },
354
- children: category
355
- })]
356
- });
119
+ category: o,
120
+ placements: a
121
+ } = n, {
122
+ recommendationComponent: u,
123
+ useRenderCampaigns: d
124
+ } = x(), {
125
+ renderCampaigns: c,
126
+ pageTypeUpdated: i
127
+ } = d("home");
128
+ return N(async (m) => {
129
+ const v = await m.defaultSession().viewCategory(o).setPlacements(a || m.placements.getPlacements()).load();
130
+ c(v, m);
131
+ }, [o, u, i]), null;
357
132
  }
358
- function NostoSearch(props) {
359
- const {
360
- query,
361
- placements
362
- } = props;
363
- const {
364
- recommendationComponent,
365
- useRenderCampaigns
366
- } = useNostoContext();
133
+ function It(n) {
367
134
  const {
368
- renderCampaigns,
369
- pageTypeUpdated
370
- } = useRenderCampaigns("search");
371
- useNostoApi(async (api) => {
372
- const data = await api.defaultSession().viewSearch(query).setPlacements(placements || api.placements.getPlacements()).load();
373
- renderCampaigns(data, api);
374
- }, [query, recommendationComponent, pageTypeUpdated]);
375
- return /* @__PURE__ */ jsxs(Fragment, {
376
- children: [/* @__PURE__ */ jsx("div", {
377
- className: "nosto_page_type",
378
- style: {
379
- display: "none"
380
- },
381
- children: "search"
382
- }), /* @__PURE__ */ jsx("div", {
383
- className: "nosto_search",
384
- style: {
385
- display: "none"
386
- },
387
- children: query
388
- })]
389
- });
135
+ query: o,
136
+ placements: a
137
+ } = n, {
138
+ recommendationComponent: u,
139
+ useRenderCampaigns: d
140
+ } = x(), {
141
+ renderCampaigns: c,
142
+ pageTypeUpdated: i
143
+ } = d("search");
144
+ return N(async (m) => {
145
+ const v = await m.defaultSession().viewSearch(o).setPlacements(a || m.placements.getPlacements()).load();
146
+ c(v, m);
147
+ }, [o, u, i]), null;
390
148
  }
391
- function snakeize(obj) {
392
- if (!obj || typeof obj !== "object") {
393
- return obj;
394
- }
395
- if (isDate(obj) || isRegex(obj)) {
396
- return obj;
397
- }
398
- if (Array.isArray(obj)) {
399
- return obj.map(snakeize);
400
- }
401
- return Object.keys(obj).reduce((acc, key) => {
402
- const camel = key[0].toLowerCase() + key.slice(1).replace(/([A-Z]+)/g, (_, x) => {
403
- return "_" + x.toLowerCase();
404
- });
405
- acc[camel] = snakeize(obj[key]);
406
- return acc;
149
+ function H(n) {
150
+ return !n || typeof n != "object" || Tt(n) || St(n) ? n : Array.isArray(n) ? n.map(H) : Object.keys(n).reduce((o, a) => {
151
+ const u = a[0].toLowerCase() + a.slice(1).replace(/([A-Z]+)/g, (d, c) => "_" + c.toLowerCase());
152
+ return o[u] = H(n[a]), o;
407
153
  }, {});
408
154
  }
409
- function isDate(obj) {
410
- return Object.prototype.toString.call(obj) === "[object Date]";
155
+ function Tt(n) {
156
+ return Object.prototype.toString.call(n) === "[object Date]";
411
157
  }
412
- function isRegex(obj) {
413
- return Object.prototype.toString.call(obj) === "[object RegExp]";
158
+ function St(n) {
159
+ return Object.prototype.toString.call(n) === "[object RegExp]";
414
160
  }
415
- function NostoOrder(props) {
161
+ function $t(n) {
416
162
  const {
417
- order,
418
- placements
419
- } = props;
420
- const {
421
- recommendationComponent,
422
- useRenderCampaigns
423
- } = useNostoContext();
424
- const {
425
- renderCampaigns,
426
- pageTypeUpdated
427
- } = useRenderCampaigns("order");
428
- useNostoApi(async (api) => {
429
- const data = await api.defaultSession().addOrder(snakeize(order)).setPlacements(placements || api.placements.getPlacements()).load();
430
- renderCampaigns(data, api);
431
- }, [recommendationComponent, pageTypeUpdated]);
432
- return /* @__PURE__ */ jsxs(Fragment, {
433
- children: [/* @__PURE__ */ jsx("div", {
434
- className: "nosto_page_type",
435
- style: {
436
- display: "none"
437
- },
438
- children: "order"
439
- }), /* @__PURE__ */ jsx("div", {
440
- className: "nosto_order",
441
- style: {
442
- display: "none"
443
- },
444
- children: order.purchase.number
445
- })]
446
- });
163
+ order: o,
164
+ placements: a
165
+ } = n, {
166
+ recommendationComponent: u,
167
+ useRenderCampaigns: d
168
+ } = x(), {
169
+ renderCampaigns: c,
170
+ pageTypeUpdated: i
171
+ } = d("order");
172
+ return N(async (m) => {
173
+ const v = await m.defaultSession().addOrder(H(o)).setPlacements(a || m.placements.getPlacements()).load();
174
+ c(v, m);
175
+ }, [u, i]), null;
447
176
  }
448
- function NostoHome(props) {
177
+ function Ut(n) {
449
178
  const {
450
- recommendationComponent,
451
- useRenderCampaigns
452
- } = useNostoContext();
453
- const {
454
- renderCampaigns,
455
- pageTypeUpdated
456
- } = useRenderCampaigns("home");
457
- useNostoApi(async (api) => {
458
- const data = await api.defaultSession().viewFrontPage().setPlacements(props.placements || api.placements.getPlacements()).load();
459
- renderCampaigns(data, api);
460
- }, [recommendationComponent, pageTypeUpdated]);
461
- return /* @__PURE__ */ jsx(Fragment, {
462
- children: /* @__PURE__ */ jsx("div", {
463
- className: "nosto_page_type",
464
- style: {
465
- display: "none"
466
- },
467
- children: "front"
468
- })
469
- });
179
+ recommendationComponent: o,
180
+ useRenderCampaigns: a
181
+ } = x(), {
182
+ renderCampaigns: u,
183
+ pageTypeUpdated: d
184
+ } = a("home");
185
+ return N(async (c) => {
186
+ const i = await c.defaultSession().viewFrontPage().setPlacements(n.placements || c.placements.getPlacements()).load();
187
+ u(i, c);
188
+ }, [o, d]), null;
189
+ }
190
+ var ve = { exports: {} }, M = {};
191
+ /**
192
+ * @license React
193
+ * react-jsx-runtime.production.min.js
194
+ *
195
+ * Copyright (c) Facebook, Inc. and its affiliates.
196
+ *
197
+ * This source code is licensed under the MIT license found in the
198
+ * LICENSE file in the root directory of this source tree.
199
+ */
200
+ var Ye;
201
+ function Pt() {
202
+ if (Ye)
203
+ return M;
204
+ Ye = 1;
205
+ var n = B, o = Symbol.for("react.element"), a = Symbol.for("react.fragment"), u = Object.prototype.hasOwnProperty, d = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
206
+ function i(m, v, O) {
207
+ var C, w = {}, A = null, F = null;
208
+ O !== void 0 && (A = "" + O), v.key !== void 0 && (A = "" + v.key), v.ref !== void 0 && (F = v.ref);
209
+ for (C in v)
210
+ u.call(v, C) && !c.hasOwnProperty(C) && (w[C] = v[C]);
211
+ if (m && m.defaultProps)
212
+ for (C in v = m.defaultProps, v)
213
+ w[C] === void 0 && (w[C] = v[C]);
214
+ return { $$typeof: o, type: m, key: A, ref: F, props: w, _owner: d.current };
215
+ }
216
+ return M.Fragment = a, M.jsx = i, M.jsxs = i, M;
217
+ }
218
+ var q = {};
219
+ /**
220
+ * @license React
221
+ * react-jsx-runtime.development.js
222
+ *
223
+ * Copyright (c) Facebook, Inc. and its affiliates.
224
+ *
225
+ * This source code is licensed under the MIT license found in the
226
+ * LICENSE file in the root directory of this source tree.
227
+ */
228
+ var Me;
229
+ function Ot() {
230
+ return Me || (Me = 1, process.env.NODE_ENV !== "production" && function() {
231
+ var n = B, o = Symbol.for("react.element"), a = Symbol.for("react.portal"), u = Symbol.for("react.fragment"), d = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), i = Symbol.for("react.provider"), m = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), O = Symbol.for("react.suspense"), C = Symbol.for("react.suspense_list"), w = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), F = Symbol.for("react.offscreen"), J = Symbol.iterator, ne = "@@iterator";
232
+ function j(e) {
233
+ if (e === null || typeof e != "object")
234
+ return null;
235
+ var t = J && e[J] || e[ne];
236
+ return typeof t == "function" ? t : null;
237
+ }
238
+ var _ = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
239
+ function h(e) {
240
+ {
241
+ for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++)
242
+ r[s - 1] = arguments[s];
243
+ y("error", e, r);
244
+ }
245
+ }
246
+ function y(e, t, r) {
247
+ {
248
+ var s = _.ReactDebugCurrentFrame, p = s.getStackAddendum();
249
+ p !== "" && (t += "%s", r = r.concat([p]));
250
+ var g = r.map(function(f) {
251
+ return String(f);
252
+ });
253
+ g.unshift("Warning: " + t), Function.prototype.apply.call(console[e], console, g);
254
+ }
255
+ }
256
+ var T = !1, S = !1, L = !1, I = !1, oe = !1, z;
257
+ z = Symbol.for("react.module.reference");
258
+ function G(e) {
259
+ return !!(typeof e == "string" || typeof e == "function" || e === u || e === c || oe || e === d || e === O || e === C || I || e === F || T || S || L || typeof e == "object" && e !== null && (e.$$typeof === A || e.$$typeof === w || e.$$typeof === i || e.$$typeof === m || e.$$typeof === v || // This needs to include all possible module reference object
260
+ // types supported by any Flight configuration anywhere since
261
+ // we don't know which Flight build this will end up being used
262
+ // with.
263
+ e.$$typeof === z || e.getModuleId !== void 0));
264
+ }
265
+ function ge(e, t, r) {
266
+ var s = e.displayName;
267
+ if (s)
268
+ return s;
269
+ var p = t.displayName || t.name || "";
270
+ return p !== "" ? r + "(" + p + ")" : r;
271
+ }
272
+ function ye(e) {
273
+ return e.displayName || "Context";
274
+ }
275
+ function k(e) {
276
+ if (e == null)
277
+ return null;
278
+ if (typeof e.tag == "number" && h("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
279
+ return e.displayName || e.name || null;
280
+ if (typeof e == "string")
281
+ return e;
282
+ switch (e) {
283
+ case u:
284
+ return "Fragment";
285
+ case a:
286
+ return "Portal";
287
+ case c:
288
+ return "Profiler";
289
+ case d:
290
+ return "StrictMode";
291
+ case O:
292
+ return "Suspense";
293
+ case C:
294
+ return "SuspenseList";
295
+ }
296
+ if (typeof e == "object")
297
+ switch (e.$$typeof) {
298
+ case m:
299
+ var t = e;
300
+ return ye(t) + ".Consumer";
301
+ case i:
302
+ var r = e;
303
+ return ye(r._context) + ".Provider";
304
+ case v:
305
+ return ge(e, e.render, "ForwardRef");
306
+ case w:
307
+ var s = e.displayName || null;
308
+ return s !== null ? s : k(e.type) || "Memo";
309
+ case A: {
310
+ var p = e, g = p._payload, f = p._init;
311
+ try {
312
+ return k(f(g));
313
+ } catch {
314
+ return null;
315
+ }
316
+ }
317
+ }
318
+ return null;
319
+ }
320
+ var $ = Object.assign, V = 0, Re, he, Ee, Ce, be, _e, we;
321
+ function Te() {
322
+ }
323
+ Te.__reactDisabledLog = !0;
324
+ function Je() {
325
+ {
326
+ if (V === 0) {
327
+ Re = console.log, he = console.info, Ee = console.warn, Ce = console.error, be = console.group, _e = console.groupCollapsed, we = console.groupEnd;
328
+ var e = {
329
+ configurable: !0,
330
+ enumerable: !0,
331
+ value: Te,
332
+ writable: !0
333
+ };
334
+ Object.defineProperties(console, {
335
+ info: e,
336
+ log: e,
337
+ warn: e,
338
+ error: e,
339
+ group: e,
340
+ groupCollapsed: e,
341
+ groupEnd: e
342
+ });
343
+ }
344
+ V++;
345
+ }
346
+ }
347
+ function ze() {
348
+ {
349
+ if (V--, V === 0) {
350
+ var e = {
351
+ configurable: !0,
352
+ enumerable: !0,
353
+ writable: !0
354
+ };
355
+ Object.defineProperties(console, {
356
+ log: $({}, e, {
357
+ value: Re
358
+ }),
359
+ info: $({}, e, {
360
+ value: he
361
+ }),
362
+ warn: $({}, e, {
363
+ value: Ee
364
+ }),
365
+ error: $({}, e, {
366
+ value: Ce
367
+ }),
368
+ group: $({}, e, {
369
+ value: be
370
+ }),
371
+ groupCollapsed: $({}, e, {
372
+ value: _e
373
+ }),
374
+ groupEnd: $({}, e, {
375
+ value: we
376
+ })
377
+ });
378
+ }
379
+ V < 0 && h("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
380
+ }
381
+ }
382
+ var ae = _.ReactCurrentDispatcher, se;
383
+ function K(e, t, r) {
384
+ {
385
+ if (se === void 0)
386
+ try {
387
+ throw Error();
388
+ } catch (p) {
389
+ var s = p.stack.trim().match(/\n( *(at )?)/);
390
+ se = s && s[1] || "";
391
+ }
392
+ return `
393
+ ` + se + e;
394
+ }
395
+ }
396
+ var ie = !1, X;
397
+ {
398
+ var Ge = typeof WeakMap == "function" ? WeakMap : Map;
399
+ X = new Ge();
400
+ }
401
+ function Se(e, t) {
402
+ if (!e || ie)
403
+ return "";
404
+ {
405
+ var r = X.get(e);
406
+ if (r !== void 0)
407
+ return r;
408
+ }
409
+ var s;
410
+ ie = !0;
411
+ var p = Error.prepareStackTrace;
412
+ Error.prepareStackTrace = void 0;
413
+ var g;
414
+ g = ae.current, ae.current = null, Je();
415
+ try {
416
+ if (t) {
417
+ var f = function() {
418
+ throw Error();
419
+ };
420
+ if (Object.defineProperty(f.prototype, "props", {
421
+ set: function() {
422
+ throw Error();
423
+ }
424
+ }), typeof Reflect == "object" && Reflect.construct) {
425
+ try {
426
+ Reflect.construct(f, []);
427
+ } catch (D) {
428
+ s = D;
429
+ }
430
+ Reflect.construct(e, [], f);
431
+ } else {
432
+ try {
433
+ f.call();
434
+ } catch (D) {
435
+ s = D;
436
+ }
437
+ e.call(f.prototype);
438
+ }
439
+ } else {
440
+ try {
441
+ throw Error();
442
+ } catch (D) {
443
+ s = D;
444
+ }
445
+ e();
446
+ }
447
+ } catch (D) {
448
+ if (D && s && typeof D.stack == "string") {
449
+ for (var l = D.stack.split(`
450
+ `), b = s.stack.split(`
451
+ `), R = l.length - 1, E = b.length - 1; R >= 1 && E >= 0 && l[R] !== b[E]; )
452
+ E--;
453
+ for (; R >= 1 && E >= 0; R--, E--)
454
+ if (l[R] !== b[E]) {
455
+ if (R !== 1 || E !== 1)
456
+ do
457
+ if (R--, E--, E < 0 || l[R] !== b[E]) {
458
+ var P = `
459
+ ` + l[R].replace(" at new ", " at ");
460
+ return e.displayName && P.includes("<anonymous>") && (P = P.replace("<anonymous>", e.displayName)), typeof e == "function" && X.set(e, P), P;
461
+ }
462
+ while (R >= 1 && E >= 0);
463
+ break;
464
+ }
465
+ }
466
+ } finally {
467
+ ie = !1, ae.current = g, ze(), Error.prepareStackTrace = p;
468
+ }
469
+ var W = e ? e.displayName || e.name : "", Ue = W ? K(W) : "";
470
+ return typeof e == "function" && X.set(e, Ue), Ue;
471
+ }
472
+ function Ke(e, t, r) {
473
+ return Se(e, !1);
474
+ }
475
+ function Xe(e) {
476
+ var t = e.prototype;
477
+ return !!(t && t.isReactComponent);
478
+ }
479
+ function Z(e, t, r) {
480
+ if (e == null)
481
+ return "";
482
+ if (typeof e == "function")
483
+ return Se(e, Xe(e));
484
+ if (typeof e == "string")
485
+ return K(e);
486
+ switch (e) {
487
+ case O:
488
+ return K("Suspense");
489
+ case C:
490
+ return K("SuspenseList");
491
+ }
492
+ if (typeof e == "object")
493
+ switch (e.$$typeof) {
494
+ case v:
495
+ return Ke(e.render);
496
+ case w:
497
+ return Z(e.type, t, r);
498
+ case A: {
499
+ var s = e, p = s._payload, g = s._init;
500
+ try {
501
+ return Z(g(p), t, r);
502
+ } catch {
503
+ }
504
+ }
505
+ }
506
+ return "";
507
+ }
508
+ var Q = Object.prototype.hasOwnProperty, Pe = {}, Oe = _.ReactDebugCurrentFrame;
509
+ function ee(e) {
510
+ if (e) {
511
+ var t = e._owner, r = Z(e.type, e._source, t ? t.type : null);
512
+ Oe.setExtraStackFrame(r);
513
+ } else
514
+ Oe.setExtraStackFrame(null);
515
+ }
516
+ function Ze(e, t, r, s, p) {
517
+ {
518
+ var g = Function.call.bind(Q);
519
+ for (var f in e)
520
+ if (g(e, f)) {
521
+ var l = void 0;
522
+ try {
523
+ if (typeof e[f] != "function") {
524
+ var b = Error((s || "React class") + ": " + r + " type `" + f + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[f] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
525
+ throw b.name = "Invariant Violation", b;
526
+ }
527
+ l = e[f](t, f, s, r, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
528
+ } catch (R) {
529
+ l = R;
530
+ }
531
+ l && !(l instanceof Error) && (ee(p), h("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", s || "React class", r, f, typeof l), ee(null)), l instanceof Error && !(l.message in Pe) && (Pe[l.message] = !0, ee(p), h("Failed %s type: %s", r, l.message), ee(null));
532
+ }
533
+ }
534
+ }
535
+ var Qe = Array.isArray;
536
+ function ce(e) {
537
+ return Qe(e);
538
+ }
539
+ function et(e) {
540
+ {
541
+ var t = typeof Symbol == "function" && Symbol.toStringTag, r = t && e[Symbol.toStringTag] || e.constructor.name || "Object";
542
+ return r;
543
+ }
544
+ }
545
+ function tt(e) {
546
+ try {
547
+ return je(e), !1;
548
+ } catch {
549
+ return !0;
550
+ }
551
+ }
552
+ function je(e) {
553
+ return "" + e;
554
+ }
555
+ function xe(e) {
556
+ if (tt(e))
557
+ return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", et(e)), je(e);
558
+ }
559
+ var Y = _.ReactCurrentOwner, rt = {
560
+ key: !0,
561
+ ref: !0,
562
+ __self: !0,
563
+ __source: !0
564
+ }, Ae, ke, ue;
565
+ ue = {};
566
+ function nt(e) {
567
+ if (Q.call(e, "ref")) {
568
+ var t = Object.getOwnPropertyDescriptor(e, "ref").get;
569
+ if (t && t.isReactWarning)
570
+ return !1;
571
+ }
572
+ return e.ref !== void 0;
573
+ }
574
+ function ot(e) {
575
+ if (Q.call(e, "key")) {
576
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
577
+ if (t && t.isReactWarning)
578
+ return !1;
579
+ }
580
+ return e.key !== void 0;
581
+ }
582
+ function at(e, t) {
583
+ if (typeof e.ref == "string" && Y.current && t && Y.current.stateNode !== t) {
584
+ var r = k(Y.current.type);
585
+ ue[r] || (h('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', k(Y.current.type), e.ref), ue[r] = !0);
586
+ }
587
+ }
588
+ function st(e, t) {
589
+ {
590
+ var r = function() {
591
+ Ae || (Ae = !0, h("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
592
+ };
593
+ r.isReactWarning = !0, Object.defineProperty(e, "key", {
594
+ get: r,
595
+ configurable: !0
596
+ });
597
+ }
598
+ }
599
+ function it(e, t) {
600
+ {
601
+ var r = function() {
602
+ ke || (ke = !0, h("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", t));
603
+ };
604
+ r.isReactWarning = !0, Object.defineProperty(e, "ref", {
605
+ get: r,
606
+ configurable: !0
607
+ });
608
+ }
609
+ }
610
+ var ct = function(e, t, r, s, p, g, f) {
611
+ var l = {
612
+ // This tag allows us to uniquely identify this as a React Element
613
+ $$typeof: o,
614
+ // Built-in properties that belong on the element
615
+ type: e,
616
+ key: t,
617
+ ref: r,
618
+ props: f,
619
+ // Record the component responsible for creating this element.
620
+ _owner: g
621
+ };
622
+ return l._store = {}, Object.defineProperty(l._store, "validated", {
623
+ configurable: !1,
624
+ enumerable: !1,
625
+ writable: !0,
626
+ value: !1
627
+ }), Object.defineProperty(l, "_self", {
628
+ configurable: !1,
629
+ enumerable: !1,
630
+ writable: !1,
631
+ value: s
632
+ }), Object.defineProperty(l, "_source", {
633
+ configurable: !1,
634
+ enumerable: !1,
635
+ writable: !1,
636
+ value: p
637
+ }), Object.freeze && (Object.freeze(l.props), Object.freeze(l)), l;
638
+ };
639
+ function ut(e, t, r, s, p) {
640
+ {
641
+ var g, f = {}, l = null, b = null;
642
+ r !== void 0 && (xe(r), l = "" + r), ot(t) && (xe(t.key), l = "" + t.key), nt(t) && (b = t.ref, at(t, p));
643
+ for (g in t)
644
+ Q.call(t, g) && !rt.hasOwnProperty(g) && (f[g] = t[g]);
645
+ if (e && e.defaultProps) {
646
+ var R = e.defaultProps;
647
+ for (g in R)
648
+ f[g] === void 0 && (f[g] = R[g]);
649
+ }
650
+ if (l || b) {
651
+ var E = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
652
+ l && st(f, E), b && it(f, E);
653
+ }
654
+ return ct(e, l, b, p, s, Y.current, f);
655
+ }
656
+ }
657
+ var le = _.ReactCurrentOwner, De = _.ReactDebugCurrentFrame;
658
+ function U(e) {
659
+ if (e) {
660
+ var t = e._owner, r = Z(e.type, e._source, t ? t.type : null);
661
+ De.setExtraStackFrame(r);
662
+ } else
663
+ De.setExtraStackFrame(null);
664
+ }
665
+ var fe;
666
+ fe = !1;
667
+ function de(e) {
668
+ return typeof e == "object" && e !== null && e.$$typeof === o;
669
+ }
670
+ function Fe() {
671
+ {
672
+ if (le.current) {
673
+ var e = k(le.current.type);
674
+ if (e)
675
+ return `
676
+
677
+ Check the render method of \`` + e + "`.";
678
+ }
679
+ return "";
680
+ }
681
+ }
682
+ function lt(e) {
683
+ return "";
684
+ }
685
+ var Ne = {};
686
+ function ft(e) {
687
+ {
688
+ var t = Fe();
689
+ if (!t) {
690
+ var r = typeof e == "string" ? e : e.displayName || e.name;
691
+ r && (t = `
692
+
693
+ Check the top-level render call using <` + r + ">.");
694
+ }
695
+ return t;
696
+ }
697
+ }
698
+ function Le(e, t) {
699
+ {
700
+ if (!e._store || e._store.validated || e.key != null)
701
+ return;
702
+ e._store.validated = !0;
703
+ var r = ft(t);
704
+ if (Ne[r])
705
+ return;
706
+ Ne[r] = !0;
707
+ var s = "";
708
+ e && e._owner && e._owner !== le.current && (s = " It was passed a child from " + k(e._owner.type) + "."), U(e), h('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', r, s), U(null);
709
+ }
710
+ }
711
+ function Ie(e, t) {
712
+ {
713
+ if (typeof e != "object")
714
+ return;
715
+ if (ce(e))
716
+ for (var r = 0; r < e.length; r++) {
717
+ var s = e[r];
718
+ de(s) && Le(s, t);
719
+ }
720
+ else if (de(e))
721
+ e._store && (e._store.validated = !0);
722
+ else if (e) {
723
+ var p = j(e);
724
+ if (typeof p == "function" && p !== e.entries)
725
+ for (var g = p.call(e), f; !(f = g.next()).done; )
726
+ de(f.value) && Le(f.value, t);
727
+ }
728
+ }
729
+ }
730
+ function dt(e) {
731
+ {
732
+ var t = e.type;
733
+ if (t == null || typeof t == "string")
734
+ return;
735
+ var r;
736
+ if (typeof t == "function")
737
+ r = t.propTypes;
738
+ else if (typeof t == "object" && (t.$$typeof === v || // Note: Memo only checks outer props here.
739
+ // Inner props are checked in the reconciler.
740
+ t.$$typeof === w))
741
+ r = t.propTypes;
742
+ else
743
+ return;
744
+ if (r) {
745
+ var s = k(t);
746
+ Ze(r, e.props, "prop", s, e);
747
+ } else if (t.PropTypes !== void 0 && !fe) {
748
+ fe = !0;
749
+ var p = k(t);
750
+ h("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", p || "Unknown");
751
+ }
752
+ typeof t.getDefaultProps == "function" && !t.getDefaultProps.isReactClassApproved && h("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
753
+ }
754
+ }
755
+ function pt(e) {
756
+ {
757
+ for (var t = Object.keys(e.props), r = 0; r < t.length; r++) {
758
+ var s = t[r];
759
+ if (s !== "children" && s !== "key") {
760
+ U(e), h("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", s), U(null);
761
+ break;
762
+ }
763
+ }
764
+ e.ref !== null && (U(e), h("Invalid attribute `ref` supplied to `React.Fragment`."), U(null));
765
+ }
766
+ }
767
+ function $e(e, t, r, s, p, g) {
768
+ {
769
+ var f = G(e);
770
+ if (!f) {
771
+ var l = "";
772
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (l += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
773
+ var b = lt();
774
+ b ? l += b : l += Fe();
775
+ var R;
776
+ e === null ? R = "null" : ce(e) ? R = "array" : e !== void 0 && e.$$typeof === o ? (R = "<" + (k(e.type) || "Unknown") + " />", l = " Did you accidentally export a JSX literal instead of a component?") : R = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", R, l);
777
+ }
778
+ var E = ut(e, t, r, p, g);
779
+ if (E == null)
780
+ return E;
781
+ if (f) {
782
+ var P = t.children;
783
+ if (P !== void 0)
784
+ if (s)
785
+ if (ce(P)) {
786
+ for (var W = 0; W < P.length; W++)
787
+ Ie(P[W], e);
788
+ Object.freeze && Object.freeze(P);
789
+ } else
790
+ h("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
791
+ else
792
+ Ie(P, e);
793
+ }
794
+ return e === u ? pt(E) : dt(E), E;
795
+ }
796
+ }
797
+ function mt(e, t, r) {
798
+ return $e(e, t, r, !0);
799
+ }
800
+ function vt(e, t, r) {
801
+ return $e(e, t, r, !1);
802
+ }
803
+ var gt = vt, yt = mt;
804
+ q.Fragment = u, q.jsx = gt, q.jsxs = yt;
805
+ }()), q;
470
806
  }
471
- function NostoPlacement(props) {
807
+ process.env.NODE_ENV === "production" ? ve.exports = Pt() : ve.exports = Ot();
808
+ var He = ve.exports;
809
+ const re = He.jsx, jt = He.Fragment;
810
+ function Wt(n) {
472
811
  const {
473
- id,
474
- pageType
475
- } = props;
476
- return /* @__PURE__ */ jsx("div", {
812
+ id: o,
813
+ pageType: a
814
+ } = n;
815
+ return /* @__PURE__ */ re("div", {
477
816
  className: "nosto_element",
478
- id
479
- }, id + (pageType || ""));
817
+ id: o
818
+ }, o + (a || ""));
480
819
  }
481
- function NostoProvider(props) {
820
+ function Vt(n) {
482
821
  const {
483
- account,
484
- multiCurrency = false,
485
- host,
486
- children,
487
- recommendationComponent,
488
- shopifyMarkets
489
- } = props;
490
- const [clientScriptLoadedState, setClientScriptLoadedState] = React.useState(false);
491
- const clientScriptLoaded = React.useMemo(() => clientScriptLoadedState, [clientScriptLoadedState]);
492
- const currentVariation = multiCurrency ? props.currentVariation : "";
493
- const responseMode = isValidElement(recommendationComponent) ? "JSON_ORIGINAL" : "HTML";
494
- function RecommendationComponentWrapper(props2) {
495
- return React.cloneElement(recommendationComponent, {
496
- nostoRecommendation: props2.nostoRecommendation
822
+ account: o,
823
+ multiCurrency: a = !1,
824
+ host: u,
825
+ children: d,
826
+ recommendationComponent: c,
827
+ shopifyMarkets: i
828
+ } = n, [m, v] = B.useState(!1), O = B.useMemo(() => m, [m]), C = a ? n.currentVariation : "", w = Ct(c) ? "JSON_ORIGINAL" : "HTML";
829
+ function A(j) {
830
+ return B.cloneElement(c, {
831
+ // eslint-disable-next-line react/prop-types
832
+ nostoRecommendation: j.nostoRecommendation
497
833
  });
498
834
  }
499
- const [pageType, setPageType] = useState("");
500
- function useRenderCampaigns(type = "") {
501
- const placementRefs = useRef({});
502
- useEffect(() => {
503
- if (pageType !== type) {
504
- setPageType(type);
505
- }
835
+ const [F, J] = bt("");
836
+ function ne(j = "") {
837
+ const _ = pe({});
838
+ te(() => {
839
+ F !== j && J(j);
506
840
  }, []);
507
- const pageTypeUpdated = type === pageType;
508
- function renderCampaigns(data, api) {
509
- if (responseMode == "HTML") {
510
- api.placements.injectCampaigns(data.recommendations);
511
- } else {
512
- const recommendations = data.campaigns.recommendations;
513
- for (const key in recommendations) {
514
- const recommendation = recommendations[key];
515
- const placementSelector = "#" + key;
516
- const placement = () => document.querySelector(placementSelector);
517
- if (placement()) {
518
- if (!placementRefs.current[key])
519
- placementRefs.current[key] = createRoot(placement());
520
- const root = placementRefs.current[key];
521
- root.render(/* @__PURE__ */ jsx(RecommendationComponentWrapper, {
522
- nostoRecommendation: recommendation
523
- }));
524
- }
841
+ const h = j === F;
842
+ function y(T, S) {
843
+ if (w == "HTML")
844
+ S.placements.injectCampaigns(T.recommendations);
845
+ else {
846
+ const L = T.campaigns.recommendations;
847
+ for (const I in L) {
848
+ const oe = L[I], z = "#" + I, G = () => document.querySelector(z);
849
+ G() && (_.current[I] || (_.current[I] = _t(G())), _.current[I].render(/* @__PURE__ */ re(A, {
850
+ nostoRecommendation: oe
851
+ })));
525
852
  }
526
853
  }
527
854
  }
528
855
  return {
529
- renderCampaigns,
530
- pageTypeUpdated
856
+ renderCampaigns: y,
857
+ pageTypeUpdated: h
531
858
  };
532
859
  }
533
- useEffect(() => {
534
- var _a, _b, _c;
535
- if (!window.nostojs) {
536
- window.nostojs = (cb) => {
537
- (window.nostojs.q = window.nostojs.q || []).push(cb);
538
- };
539
- window.nostojs((api) => api.setAutoLoad(false));
540
- }
541
- if (!document.querySelectorAll("[nosto-client-script]").length && !shopifyMarkets) {
542
- const script = document.createElement("script");
543
- script.type = "text/javascript";
544
- script.src = "//" + (host || "connect.nosto.com") + "/include/" + account;
545
- script.async = true;
546
- script.setAttribute("nosto-client-script", "");
547
- script.onload = () => {
548
- var _a2;
549
- if (typeof jest !== "undefined") {
550
- (_a2 = window.nosto) == null ? void 0 : _a2.reload({
860
+ return te(() => {
861
+ var j, _, h;
862
+ if (window.nostojs || (window.nostojs = (y) => {
863
+ (window.nostojs.q = window.nostojs.q || []).push(y);
864
+ }, window.nostojs((y) => y.setAutoLoad(!1))), !document.querySelectorAll("[nosto-client-script]").length && !i) {
865
+ const y = document.createElement("script");
866
+ y.type = "text/javascript", y.src = "//" + (u || "connect.nosto.com") + "/include/" + o, y.async = !0, y.setAttribute("nosto-client-script", ""), y.onload = () => {
867
+ var T;
868
+ typeof jest < "u" && ((T = window.nosto) == null || T.reload({
869
+ site: "localhost"
870
+ })), v(!0);
871
+ }, document.body.appendChild(y);
872
+ }
873
+ if (i) {
874
+ const y = document.querySelector("[nosto-client-script]"), T = document.querySelector("#nosto-sandbox");
875
+ if (!y || (y == null ? void 0 : y.getAttribute("nosto-language")) !== (i == null ? void 0 : i.language) || (y == null ? void 0 : y.getAttribute("nosto-market-id")) !== (i == null ? void 0 : i.marketId)) {
876
+ m && v(!1), (j = y == null ? void 0 : y.parentNode) == null || j.removeChild(y), (_ = T == null ? void 0 : T.parentNode) == null || _.removeChild(T);
877
+ const S = document.createElement("script");
878
+ S.type = "text/javascript", S.src = "//" + (u || "connect.nosto.com") + `/script/shopify/market/nosto.js?merchant=${o}&market=${i.marketId || ""}&locale=${((h = i == null ? void 0 : i.language) == null ? void 0 : h.toLowerCase()) || ""}`, S.async = !0, S.setAttribute("nosto-client-script", ""), S.setAttribute("nosto-language", (i == null ? void 0 : i.language) || ""), S.setAttribute("nosto-market-id", String(i == null ? void 0 : i.marketId)), S.onload = () => {
879
+ var L;
880
+ typeof jest < "u" && ((L = window.nosto) == null || L.reload({
551
881
  site: "localhost"
552
- });
553
- }
554
- setClientScriptLoadedState(true);
555
- };
556
- document.body.appendChild(script);
557
- }
558
- if (shopifyMarkets) {
559
- const existingScript = document.querySelector("[nosto-client-script]");
560
- const nostoSandbox = document.querySelector("#nosto-sandbox");
561
- if (!existingScript || (existingScript == null ? void 0 : existingScript.getAttribute("nosto-language")) !== (shopifyMarkets == null ? void 0 : shopifyMarkets.language) || (existingScript == null ? void 0 : existingScript.getAttribute("nosto-market-id")) !== (shopifyMarkets == null ? void 0 : shopifyMarkets.marketId)) {
562
- if (clientScriptLoadedState) {
563
- setClientScriptLoadedState(false);
564
- }
565
- (_a = existingScript == null ? void 0 : existingScript.parentNode) == null ? void 0 : _a.removeChild(existingScript);
566
- (_b = nostoSandbox == null ? void 0 : nostoSandbox.parentNode) == null ? void 0 : _b.removeChild(nostoSandbox);
567
- const script = document.createElement("script");
568
- script.type = "text/javascript";
569
- script.src = "//" + (host || "connect.nosto.com") + `/script/shopify/market/nosto.js?merchant=${account}&market=${shopifyMarkets.marketId || ""}&locale=${((_c = shopifyMarkets == null ? void 0 : shopifyMarkets.language) == null ? void 0 : _c.toLowerCase()) || ""}`;
570
- script.async = true;
571
- script.setAttribute("nosto-client-script", "");
572
- script.setAttribute("nosto-language", (shopifyMarkets == null ? void 0 : shopifyMarkets.language) || "");
573
- script.setAttribute("nosto-market-id", String(shopifyMarkets == null ? void 0 : shopifyMarkets.marketId));
574
- script.onload = () => {
575
- var _a2;
576
- if (typeof jest !== "undefined") {
577
- (_a2 = window.nosto) == null ? void 0 : _a2.reload({
578
- site: "localhost"
579
- });
580
- }
581
- setClientScriptLoadedState(true);
582
- };
583
- document.body.appendChild(script);
882
+ })), v(!0);
883
+ }, document.body.appendChild(S);
584
884
  }
585
885
  }
586
- }, [clientScriptLoadedState, shopifyMarkets]);
587
- return /* @__PURE__ */ jsx(NostoContext.Provider, {
886
+ }, [m, i]), /* @__PURE__ */ re(qe.Provider, {
588
887
  value: {
589
- account,
590
- clientScriptLoaded,
591
- currentVariation,
592
- responseMode,
593
- recommendationComponent,
594
- useRenderCampaigns,
595
- pageType
888
+ account: o,
889
+ clientScriptLoaded: O,
890
+ currentVariation: C,
891
+ responseMode: w,
892
+ recommendationComponent: c,
893
+ useRenderCampaigns: ne,
894
+ pageType: F
596
895
  },
597
- children
896
+ children: d
598
897
  });
599
898
  }
600
- function NostoSession(props) {
899
+ function Yt(n) {
601
900
  const {
602
- cart,
603
- customer
604
- } = props;
605
- const {
606
- clientScriptLoaded
607
- } = useNostoContext();
608
- useDeepCompareEffect(() => {
609
- const currentCart = cart ? snakeize(cart) : void 0;
610
- const currentCustomer = customer ? snakeize(customer) : void 0;
611
- if (clientScriptLoaded) {
612
- window.nostojs((api) => {
613
- api.defaultSession().setResponseMode("HTML").setCart(currentCart).setCustomer(currentCustomer).viewOther().load();
614
- });
615
- }
616
- }, [clientScriptLoaded, cart, customer]);
617
- return /* @__PURE__ */ jsx(Fragment, {});
901
+ cart: o,
902
+ customer: a
903
+ } = n ?? {}, {
904
+ clientScriptLoaded: u
905
+ } = x();
906
+ return Be(() => {
907
+ const d = o ? H(o) : void 0, c = a ? H(a) : void 0;
908
+ u && window.nostojs((i) => {
909
+ i.defaultSession().setResponseMode("HTML").setCart(d).setCustomer(c).viewOther().load();
910
+ });
911
+ }, [u, o, a]), /* @__PURE__ */ re(jt, {});
618
912
  }
619
- export { Nosto404, NostoCategory, NostoCheckout, NostoContext, NostoHome, NostoOrder, NostoOther, NostoPlacement, NostoProduct, NostoProvider, NostoSearch, NostoSession, useNostoContext };
913
+ export {
914
+ kt as Nosto404,
915
+ Lt as NostoCategory,
916
+ Ft as NostoCheckout,
917
+ qe as NostoContext,
918
+ Ut as NostoHome,
919
+ $t as NostoOrder,
920
+ Dt as NostoOther,
921
+ Wt as NostoPlacement,
922
+ Nt as NostoProduct,
923
+ Vt as NostoProvider,
924
+ It as NostoSearch,
925
+ Yt as NostoSession,
926
+ x as useNostoContext
927
+ };