@kachingappz/bundles-js 1.0.1 → 1.1.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.
- package/README.md +39 -1
- package/dist/bundles-js.iife.js +24 -23
- package/dist/index.d.ts +26 -11
- package/dist/index.js +484 -395
- package/dist/kaching-bundle-component/index.d.ts +26 -11
- package/dist/kaching-bundle-component/index.js +646 -557
- package/dist/react/index.cjs +26 -25
- package/dist/react/index.d.ts +26 -11
- package/dist/react/index.js +528 -439
- package/package.json +5 -5
package/dist/react/index.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as B, useState as
|
|
3
|
-
const
|
|
4
|
-
const a = [],
|
|
5
|
-
(
|
|
1
|
+
import { jsx as J } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as B, useState as z, useEffect as D, useLayoutEffect as Q } from "react";
|
|
3
|
+
const H = (e, t) => {
|
|
4
|
+
const a = [], r = e.filter(
|
|
5
|
+
(l) => l.blockVisibility === "selected-products"
|
|
6
6
|
);
|
|
7
|
-
for (const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
(
|
|
7
|
+
for (const l of r)
|
|
8
|
+
l.selectedProductIds.map(Number).includes(t.id) && a.push(l);
|
|
9
|
+
const s = e.filter(
|
|
10
|
+
(l) => l.blockVisibility === "selected-collections"
|
|
11
11
|
);
|
|
12
|
-
for (const
|
|
12
|
+
for (const l of s)
|
|
13
13
|
t.collectionIds.some(
|
|
14
|
-
(
|
|
15
|
-
) && a.push(
|
|
14
|
+
(d) => l.selectedCollectionIds.map(Number).includes(d)
|
|
15
|
+
) && a.push(l);
|
|
16
16
|
const i = e.filter(
|
|
17
|
-
(
|
|
17
|
+
(l) => l.blockVisibility === "excluded-products"
|
|
18
18
|
);
|
|
19
|
-
for (const
|
|
20
|
-
!
|
|
21
|
-
(
|
|
22
|
-
) && a.push(
|
|
19
|
+
for (const l of i)
|
|
20
|
+
!l.excludedProductIds.map(Number).includes(t.id) && !(l.excludedCollectionIds || []).some(
|
|
21
|
+
(d) => t.collectionIds.includes(d)
|
|
22
|
+
) && a.push(l);
|
|
23
23
|
const o = e.filter(
|
|
24
|
-
(
|
|
24
|
+
(l) => l.blockVisibility === "all-products"
|
|
25
25
|
);
|
|
26
|
-
for (const
|
|
27
|
-
a.push(
|
|
26
|
+
for (const l of o)
|
|
27
|
+
a.push(l);
|
|
28
28
|
return a;
|
|
29
|
-
},
|
|
30
|
-
var
|
|
31
|
-
const
|
|
29
|
+
}, K = (e, { language: t, country: a }) => {
|
|
30
|
+
var p, g;
|
|
31
|
+
const r = W(t, a), s = new Intl.NumberFormat(r, {
|
|
32
32
|
style: "currency",
|
|
33
33
|
currency: e,
|
|
34
34
|
currencyDisplay: "narrowSymbol"
|
|
35
|
-
}).formatToParts(123456789e-2), i = (
|
|
36
|
-
(g =
|
|
37
|
-
),
|
|
35
|
+
}).formatToParts(123456789e-2), i = (p = s.find((y) => y.type === "decimal")) == null ? void 0 : p.value, o = X(
|
|
36
|
+
(g = s.find((y) => y.type === "group")) == null ? void 0 : g.value
|
|
37
|
+
), l = s.some((y) => y.type === "fraction"), d = Y(
|
|
38
38
|
o,
|
|
39
39
|
i,
|
|
40
|
-
|
|
41
|
-
),
|
|
40
|
+
l
|
|
41
|
+
), u = s.findIndex(C), c = s.findLastIndex(C);
|
|
42
42
|
return [
|
|
43
|
-
...
|
|
44
|
-
|
|
45
|
-
...
|
|
43
|
+
...s.slice(0, u).map(G),
|
|
44
|
+
d,
|
|
45
|
+
...s.slice(c + 1).map(G)
|
|
46
46
|
].join("");
|
|
47
|
-
},
|
|
47
|
+
}, G = (e) => F(e.value), F = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", W = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), X = (e) => e === void 0 ? void 0 : F(e).replace(/’/g, "'"), Y = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
|
|
48
48
|
country: e,
|
|
49
49
|
language: t
|
|
50
50
|
}) => {
|
|
51
51
|
const a = [];
|
|
52
52
|
return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
|
|
53
|
-
},
|
|
53
|
+
}, Z = async (e, {
|
|
54
54
|
useExternalMetafieldNamespace: t,
|
|
55
55
|
useMetaobjects: a
|
|
56
|
-
}) => a ?
|
|
56
|
+
}) => a ? te(
|
|
57
57
|
e
|
|
58
|
-
) :
|
|
59
|
-
var
|
|
60
|
-
const a = (
|
|
58
|
+
) : ee(e), ee = async (e, t) => {
|
|
59
|
+
var r;
|
|
60
|
+
const a = (r = (await e.query(
|
|
61
61
|
`
|
|
62
62
|
query FetchDealBlocks($metafieldNamespace: String!) {
|
|
63
63
|
shop {
|
|
@@ -72,11 +72,11 @@ const J = (e, t) => {
|
|
|
72
72
|
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
)).shop.metafield) == null ? void 0 :
|
|
75
|
+
)).shop.metafield) == null ? void 0 : r.value;
|
|
76
76
|
return a ? JSON.parse(a) : [];
|
|
77
|
-
},
|
|
78
|
-
const a = "app--2935586817--deal_block",
|
|
79
|
-
let
|
|
77
|
+
}, te = async (e, t) => {
|
|
78
|
+
const a = "app--2935586817--deal_block", r = [];
|
|
79
|
+
let s = null;
|
|
80
80
|
for (; ; ) {
|
|
81
81
|
const i = await e.query(
|
|
82
82
|
`
|
|
@@ -98,41 +98,41 @@ const J = (e, t) => {
|
|
|
98
98
|
{
|
|
99
99
|
variables: {
|
|
100
100
|
type: a,
|
|
101
|
-
cursor:
|
|
101
|
+
cursor: s
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
for (const o of i.metaobjects.nodes) {
|
|
106
|
-
const
|
|
107
|
-
(
|
|
106
|
+
const l = o.fields.find(
|
|
107
|
+
(d) => d.key === "settings"
|
|
108
108
|
);
|
|
109
|
-
|
|
109
|
+
l != null && l.value && r.push(JSON.parse(l.value));
|
|
110
110
|
}
|
|
111
111
|
if (!i.metaobjects.pageInfo.hasNextPage)
|
|
112
112
|
break;
|
|
113
|
-
|
|
113
|
+
s = i.metaobjects.pageInfo.endCursor;
|
|
114
114
|
}
|
|
115
|
-
return
|
|
116
|
-
},
|
|
115
|
+
return r;
|
|
116
|
+
}, T = async (e, {
|
|
117
117
|
country: t,
|
|
118
118
|
language: a,
|
|
119
|
-
blockVisibility:
|
|
120
|
-
excludedProductGIDs:
|
|
119
|
+
blockVisibility: r,
|
|
120
|
+
excludedProductGIDs: s,
|
|
121
121
|
selectedProductGIDs: i,
|
|
122
122
|
selectedCollectionGIDs: o,
|
|
123
|
-
limit:
|
|
123
|
+
limit: l = 1e3
|
|
124
124
|
}) => {
|
|
125
|
-
switch (
|
|
125
|
+
switch (r) {
|
|
126
126
|
case "selected-products":
|
|
127
|
-
return i.slice(0,
|
|
127
|
+
return i.slice(0, l);
|
|
128
128
|
case "all-products":
|
|
129
129
|
case "excluded-products": {
|
|
130
|
-
const
|
|
131
|
-
let
|
|
132
|
-
for (;
|
|
133
|
-
const
|
|
130
|
+
const d = w({ country: t, language: a });
|
|
131
|
+
let u = [], c = null;
|
|
132
|
+
for (; u.length < l; ) {
|
|
133
|
+
const p = Math.min(l - u.length, 250), g = await e.query(
|
|
134
134
|
`
|
|
135
|
-
query FetchProductGIDs($limit: Int!, $cursor: String) ${
|
|
135
|
+
query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
|
|
136
136
|
products(first: $limit, after: $cursor) {
|
|
137
137
|
nodes {
|
|
138
138
|
id
|
|
@@ -146,24 +146,24 @@ const J = (e, t) => {
|
|
|
146
146
|
`,
|
|
147
147
|
{
|
|
148
148
|
variables: {
|
|
149
|
-
limit:
|
|
149
|
+
limit: p,
|
|
150
150
|
cursor: c
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
);
|
|
154
|
-
if (
|
|
154
|
+
if (u.push(...g.products.nodes.map((y) => y.id)), !g.products.pageInfo.hasNextPage) break;
|
|
155
155
|
c = g.products.pageInfo.endCursor;
|
|
156
156
|
}
|
|
157
|
-
if (
|
|
158
|
-
const
|
|
159
|
-
|
|
157
|
+
if (r === "excluded-products") {
|
|
158
|
+
const p = new Set(s);
|
|
159
|
+
u = u.filter((g) => !p.has(g));
|
|
160
160
|
}
|
|
161
|
-
return
|
|
161
|
+
return u;
|
|
162
162
|
}
|
|
163
163
|
case "selected-collections": {
|
|
164
|
-
const
|
|
164
|
+
const d = w({ country: t, language: a }), u = (await e.query(
|
|
165
165
|
`
|
|
166
|
-
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${
|
|
166
|
+
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
|
|
167
167
|
nodes(ids: $collectionGIDs) {
|
|
168
168
|
... on Collection {
|
|
169
169
|
products(first: $limit) {
|
|
@@ -178,16 +178,16 @@ const J = (e, t) => {
|
|
|
178
178
|
{
|
|
179
179
|
variables: {
|
|
180
180
|
collectionGIDs: o,
|
|
181
|
-
limit: Math.min(
|
|
181
|
+
limit: Math.min(l, 250)
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
)).nodes.filter((c) => c !== null).flatMap(
|
|
185
|
-
(c) => c.products.nodes.map((
|
|
185
|
+
(c) => c.products.nodes.map((p) => p.id)
|
|
186
186
|
);
|
|
187
|
-
return Array.from(new Set(
|
|
187
|
+
return Array.from(new Set(u)).slice(0, l);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
},
|
|
190
|
+
}, L = `
|
|
191
191
|
id
|
|
192
192
|
availableForSale
|
|
193
193
|
price {
|
|
@@ -202,7 +202,7 @@ const J = (e, t) => {
|
|
|
202
202
|
}
|
|
203
203
|
image {
|
|
204
204
|
id
|
|
205
|
-
url(transform:
|
|
205
|
+
url(transform: $variantImageTransform)
|
|
206
206
|
}
|
|
207
207
|
unitPriceMeasurement {
|
|
208
208
|
quantityUnit
|
|
@@ -233,17 +233,18 @@ const J = (e, t) => {
|
|
|
233
233
|
`, A = async (e, {
|
|
234
234
|
country: t,
|
|
235
235
|
language: a,
|
|
236
|
-
productIds:
|
|
237
|
-
includeSellingPlans:
|
|
236
|
+
productIds: r,
|
|
237
|
+
includeSellingPlans: s = !0,
|
|
238
238
|
includeAvailableQuantity: i = !0,
|
|
239
239
|
useExternalMetafieldNamespace: o = !1,
|
|
240
|
-
batchSize:
|
|
241
|
-
onBatchError:
|
|
240
|
+
batchSize: l = 250,
|
|
241
|
+
onBatchError: d,
|
|
242
|
+
variantImageTransform: u = { maxWidth: 200, maxHeight: 200 }
|
|
242
243
|
}) => {
|
|
243
|
-
if (!
|
|
244
|
+
if (!r.length)
|
|
244
245
|
return [];
|
|
245
|
-
const
|
|
246
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String
|
|
246
|
+
const c = r.map((f) => typeof f == "string" && f.startsWith("gid://") ? f : `gid://shopify/Product/${f}`), p = w({ country: t, language: a }), g = `
|
|
247
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${p} {
|
|
247
248
|
shop {
|
|
248
249
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
249
250
|
value
|
|
@@ -277,7 +278,7 @@ const J = (e, t) => {
|
|
|
277
278
|
}
|
|
278
279
|
variants(first: 250) {
|
|
279
280
|
nodes {
|
|
280
|
-
${
|
|
281
|
+
${L}
|
|
281
282
|
}
|
|
282
283
|
}
|
|
283
284
|
collections(first: 50) {
|
|
@@ -329,84 +330,90 @@ const J = (e, t) => {
|
|
|
329
330
|
}
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
|
-
`,
|
|
333
|
-
for (let
|
|
334
|
-
|
|
335
|
-
let
|
|
336
|
-
const
|
|
337
|
-
const v = await e.query(
|
|
333
|
+
`, y = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", h = [], n = Math.min(l, 250);
|
|
334
|
+
for (let f = 0; f < c.length; f += n)
|
|
335
|
+
h.push(c.slice(f, f + n));
|
|
336
|
+
let m = 1;
|
|
337
|
+
const b = async (f) => {
|
|
338
|
+
const v = await e.query(g, {
|
|
338
339
|
variables: {
|
|
339
|
-
productGIDs:
|
|
340
|
-
includeSellingPlans:
|
|
340
|
+
productGIDs: f,
|
|
341
|
+
includeSellingPlans: s,
|
|
341
342
|
includeAvailableQuantity: i,
|
|
342
|
-
metafieldNamespace:
|
|
343
|
+
metafieldNamespace: y,
|
|
344
|
+
variantImageTransform: u
|
|
343
345
|
}
|
|
344
346
|
});
|
|
345
|
-
return v.shop.currencyRateConstant && (
|
|
347
|
+
return v.shop.currencyRateConstant && (m = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
|
|
346
348
|
};
|
|
347
|
-
let
|
|
348
|
-
if (
|
|
349
|
-
const
|
|
350
|
-
for (const v of
|
|
351
|
-
v.status === "rejected" &&
|
|
349
|
+
let I;
|
|
350
|
+
if (d) {
|
|
351
|
+
const f = await Promise.allSettled(h.map(b));
|
|
352
|
+
for (const v of f)
|
|
353
|
+
v.status === "rejected" && d(
|
|
352
354
|
v.reason instanceof Error ? v.reason : new Error(String(v.reason))
|
|
353
355
|
);
|
|
354
|
-
|
|
356
|
+
I = f.filter(
|
|
355
357
|
(v) => v.status === "fulfilled"
|
|
356
358
|
).flatMap((v) => v.value.nodes);
|
|
357
359
|
} else
|
|
358
|
-
|
|
359
|
-
const _ =
|
|
360
|
-
if (
|
|
361
|
-
const
|
|
362
|
-
_.map(async (
|
|
363
|
-
const
|
|
360
|
+
I = (await Promise.all(h.map(b))).flatMap((f) => f.nodes);
|
|
361
|
+
const _ = I.filter((f) => f != null);
|
|
362
|
+
if (d) {
|
|
363
|
+
const f = await Promise.allSettled(
|
|
364
|
+
_.map(async (P) => {
|
|
365
|
+
const R = await q(
|
|
364
366
|
e,
|
|
365
|
-
I,
|
|
366
|
-
{ includeSellingPlans: r, includeAvailableQuantity: i },
|
|
367
|
-
c
|
|
368
|
-
);
|
|
369
|
-
return q(
|
|
370
367
|
P,
|
|
368
|
+
{
|
|
369
|
+
includeSellingPlans: s,
|
|
370
|
+
includeAvailableQuantity: i,
|
|
371
|
+
variantImageTransform: u
|
|
372
|
+
},
|
|
373
|
+
p
|
|
374
|
+
);
|
|
375
|
+
return M(
|
|
376
|
+
R,
|
|
371
377
|
e.shopifyDomain,
|
|
372
|
-
|
|
378
|
+
m
|
|
373
379
|
);
|
|
374
380
|
})
|
|
375
381
|
), v = [];
|
|
376
|
-
for (const
|
|
377
|
-
|
|
378
|
-
|
|
382
|
+
for (const P of f)
|
|
383
|
+
P.status === "fulfilled" ? v.push(P.value) : d(
|
|
384
|
+
P.reason instanceof Error ? P.reason : new Error(String(P.reason))
|
|
379
385
|
);
|
|
380
386
|
return v;
|
|
381
387
|
}
|
|
382
388
|
return (await Promise.all(
|
|
383
389
|
_.map(
|
|
384
|
-
(
|
|
390
|
+
(f) => q(
|
|
385
391
|
e,
|
|
386
|
-
|
|
392
|
+
f,
|
|
387
393
|
{
|
|
388
|
-
includeSellingPlans:
|
|
389
|
-
includeAvailableQuantity: i
|
|
394
|
+
includeSellingPlans: s,
|
|
395
|
+
includeAvailableQuantity: i,
|
|
396
|
+
variantImageTransform: u
|
|
390
397
|
},
|
|
391
|
-
|
|
398
|
+
p
|
|
392
399
|
)
|
|
393
400
|
)
|
|
394
401
|
)).map(
|
|
395
|
-
(
|
|
402
|
+
(f) => M(f, e.shopifyDomain, m)
|
|
396
403
|
);
|
|
397
|
-
},
|
|
404
|
+
}, q = async (e, t, a, r = "") => {
|
|
398
405
|
if (t.variants.nodes.length < 250)
|
|
399
406
|
return t;
|
|
400
|
-
const
|
|
401
|
-
let
|
|
402
|
-
for (;
|
|
403
|
-
const
|
|
407
|
+
const s = /* @__PURE__ */ new Set(), i = [], o = [], l = async (d) => {
|
|
408
|
+
let u = !0, c = null;
|
|
409
|
+
for (; u; ) {
|
|
410
|
+
const p = await e.query(
|
|
404
411
|
`
|
|
405
|
-
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean
|
|
412
|
+
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
|
|
406
413
|
product(id: $productGID) {
|
|
407
414
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
408
415
|
nodes {
|
|
409
|
-
${
|
|
416
|
+
${L}
|
|
410
417
|
}
|
|
411
418
|
pageInfo {
|
|
412
419
|
endCursor
|
|
@@ -420,85 +427,85 @@ const J = (e, t) => {
|
|
|
420
427
|
variables: {
|
|
421
428
|
productGID: t.id,
|
|
422
429
|
cursor: c,
|
|
423
|
-
reverse:
|
|
430
|
+
reverse: d,
|
|
424
431
|
...a
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
|
-
), { nodes: g, pageInfo: y } =
|
|
434
|
+
), { nodes: g, pageInfo: y } = p.product.variants;
|
|
428
435
|
for (const h of g) {
|
|
429
|
-
if (
|
|
430
|
-
|
|
436
|
+
if (s.has(h.id)) {
|
|
437
|
+
u = !1;
|
|
431
438
|
break;
|
|
432
439
|
}
|
|
433
|
-
|
|
440
|
+
s.add(h.id), d ? o.push(h) : i.push(h);
|
|
434
441
|
}
|
|
435
|
-
y.hasNextPage || (
|
|
442
|
+
y.hasNextPage || (u = !1), c = y.endCursor;
|
|
436
443
|
}
|
|
437
444
|
};
|
|
438
445
|
return await Promise.all([
|
|
439
|
-
|
|
440
|
-
|
|
446
|
+
l(!1),
|
|
447
|
+
l(!0)
|
|
441
448
|
]), t.variants.nodes = [...i, ...o.reverse()], t;
|
|
442
|
-
},
|
|
443
|
-
var
|
|
444
|
-
const
|
|
445
|
-
({ unitPriceMeasurement:
|
|
446
|
-
var b,
|
|
449
|
+
}, M = (e, t, a) => {
|
|
450
|
+
var u, c, p, g, y, h;
|
|
451
|
+
const r = e.variants.nodes.map(
|
|
452
|
+
({ unitPriceMeasurement: n, ...m }) => {
|
|
453
|
+
var b, I;
|
|
447
454
|
return {
|
|
448
|
-
id: Number(
|
|
449
|
-
availableForSale:
|
|
450
|
-
price: Math.round(Number(
|
|
451
|
-
compareAtPrice:
|
|
452
|
-
options:
|
|
453
|
-
imageId:
|
|
454
|
-
image: ((b =
|
|
455
|
-
sellingPlans: ((
|
|
456
|
-
id: Number(
|
|
457
|
-
price:
|
|
458
|
-
compareAtPrice:
|
|
459
|
-
Number(
|
|
460
|
-
) : Math.round(Number(
|
|
461
|
-
perDeliveryPrice:
|
|
462
|
-
Number(
|
|
463
|
-
) : Math.round(Number(
|
|
455
|
+
id: Number(m.id.split("/").pop()),
|
|
456
|
+
availableForSale: m.availableForSale,
|
|
457
|
+
price: Math.round(Number(m.price.amount) * 100),
|
|
458
|
+
compareAtPrice: m.compareAtPrice ? Math.round(Number(m.compareAtPrice.amount) * 100) : null,
|
|
459
|
+
options: m.selectedOptions.map((_) => _.value),
|
|
460
|
+
imageId: m.image ? Number(m.image.id.split("/").pop()) : null,
|
|
461
|
+
image: ((b = m.image) == null ? void 0 : b.url) || null,
|
|
462
|
+
sellingPlans: ((I = m.sellingPlanAllocations) == null ? void 0 : I.nodes.map((_) => ({
|
|
463
|
+
id: Number(_.sellingPlan.id.split("/").pop()),
|
|
464
|
+
price: _.priceAdjustments.length > 0 ? Math.round(Number(_.priceAdjustments[0].price.amount) * 100) : Math.round(Number(m.price.amount) * 100),
|
|
465
|
+
compareAtPrice: _.priceAdjustments.length > 0 ? Math.round(
|
|
466
|
+
Number(_.priceAdjustments[0].compareAtPrice.amount) * 100
|
|
467
|
+
) : Math.round(Number(m.price.amount) * 100),
|
|
468
|
+
perDeliveryPrice: _.priceAdjustments.length > 0 ? Math.round(
|
|
469
|
+
Number(_.priceAdjustments[0].perDeliveryPrice.amount) * 100
|
|
470
|
+
) : Math.round(Number(m.price.amount) * 100)
|
|
464
471
|
}))) || [],
|
|
465
472
|
inventoryManagement: null,
|
|
466
473
|
// Storefront API does not return inventory management, only available in liquid
|
|
467
474
|
inventoryPolicy: null,
|
|
468
475
|
// Storefront API does not return inventory policy, only available in liquid
|
|
469
|
-
inventoryQuantity:
|
|
470
|
-
unitPriceMeasurement:
|
|
471
|
-
quantityValue:
|
|
472
|
-
quantityUnit:
|
|
473
|
-
referenceValue:
|
|
474
|
-
referenceUnit:
|
|
476
|
+
inventoryQuantity: m.quantityAvailable ?? null,
|
|
477
|
+
unitPriceMeasurement: n != null && n.quantityUnit && (n != null && n.referenceUnit) ? {
|
|
478
|
+
quantityValue: n.quantityValue,
|
|
479
|
+
quantityUnit: n.quantityUnit.toLowerCase(),
|
|
480
|
+
referenceValue: n.referenceValue,
|
|
481
|
+
referenceUnit: n.referenceUnit.toLowerCase()
|
|
475
482
|
} : null
|
|
476
483
|
};
|
|
477
484
|
}
|
|
478
|
-
),
|
|
479
|
-
const b =
|
|
480
|
-
var
|
|
485
|
+
), s = e.options.map((n, m) => {
|
|
486
|
+
const b = n.optionValues.map((I) => {
|
|
487
|
+
var _, f, v, P;
|
|
481
488
|
return {
|
|
482
|
-
id: Number(
|
|
483
|
-
defaultName:
|
|
484
|
-
name:
|
|
489
|
+
id: Number(I.id.split("/").pop()),
|
|
490
|
+
defaultName: I.name,
|
|
491
|
+
name: I.name,
|
|
485
492
|
swatch: {
|
|
486
|
-
color: ((
|
|
487
|
-
image: ((P = (
|
|
493
|
+
color: ((_ = I.swatch) == null ? void 0 : _.color) || null,
|
|
494
|
+
image: ((P = (v = (f = I.swatch) == null ? void 0 : f.image) == null ? void 0 : v.previewImage) == null ? void 0 : P.url) || null
|
|
488
495
|
}
|
|
489
496
|
};
|
|
490
497
|
});
|
|
491
498
|
return {
|
|
492
|
-
defaultName:
|
|
493
|
-
name:
|
|
494
|
-
position:
|
|
495
|
-
optionValues:
|
|
499
|
+
defaultName: n.name,
|
|
500
|
+
name: n.name,
|
|
501
|
+
position: m + 1,
|
|
502
|
+
optionValues: ae(b, m, r)
|
|
496
503
|
};
|
|
497
|
-
}), i = (
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
504
|
+
}), i = (n) => {
|
|
505
|
+
const m = n.priceAdjustments[0];
|
|
506
|
+
if (!m)
|
|
500
507
|
return null;
|
|
501
|
-
const b =
|
|
508
|
+
const b = m.adjustmentValue;
|
|
502
509
|
switch (b.__typename) {
|
|
503
510
|
case "SellingPlanPercentagePriceAdjustment":
|
|
504
511
|
return {
|
|
@@ -520,14 +527,14 @@ const J = (e, t) => {
|
|
|
520
527
|
`Unknown price adjustment type: ${b.__typename}`
|
|
521
528
|
);
|
|
522
529
|
}
|
|
523
|
-
}, o = (
|
|
524
|
-
(
|
|
525
|
-
id: Number(
|
|
526
|
-
name:
|
|
527
|
-
priceAdjustment: i(
|
|
530
|
+
}, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a), l = ((u = e.sellingPlanGroups) == null ? void 0 : u.nodes.flatMap(
|
|
531
|
+
(n) => n.sellingPlans.nodes.map((m) => ({
|
|
532
|
+
id: Number(m.id.split("/").pop()),
|
|
533
|
+
name: m.name,
|
|
534
|
+
priceAdjustment: i(m)
|
|
528
535
|
}))
|
|
529
|
-
)) || [],
|
|
530
|
-
(
|
|
536
|
+
)) || [], d = e.variants.nodes.some(
|
|
537
|
+
(n) => n.requiresComponents
|
|
531
538
|
);
|
|
532
539
|
return {
|
|
533
540
|
id: Number(e.id.split("/").pop()),
|
|
@@ -538,41 +545,41 @@ const J = (e, t) => {
|
|
|
538
545
|
title: e.title,
|
|
539
546
|
image: ((c = e.featuredImage) == null ? void 0 : c.url) || null,
|
|
540
547
|
collectionIds: e.collections.nodes.map(
|
|
541
|
-
(
|
|
548
|
+
(n) => Number(n.id.split("/").pop())
|
|
542
549
|
),
|
|
543
|
-
options:
|
|
550
|
+
options: s,
|
|
544
551
|
selectedVariantId: Number(
|
|
545
552
|
e.variants.nodes[0].id.split("/").pop()
|
|
546
553
|
),
|
|
547
|
-
variants:
|
|
554
|
+
variants: r,
|
|
548
555
|
requiresSellingPlan: e.requiresSellingPlan,
|
|
549
|
-
sellingPlans:
|
|
550
|
-
isNativeBundle:
|
|
556
|
+
sellingPlans: l,
|
|
557
|
+
isNativeBundle: d,
|
|
551
558
|
metafields: {
|
|
552
|
-
text: ((
|
|
559
|
+
text: ((p = e.metafield) == null ? void 0 : p.value) || null,
|
|
553
560
|
text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
|
|
554
561
|
text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
|
|
555
562
|
text4: ((h = e.metafield4) == null ? void 0 : h.value) || null
|
|
556
563
|
}
|
|
557
564
|
};
|
|
558
|
-
},
|
|
559
|
-
(
|
|
560
|
-
).length > 0),
|
|
565
|
+
}, ae = (e, t, a) => e.filter((r) => a.filter(
|
|
566
|
+
(s) => s.options[t] === r.name
|
|
567
|
+
).length > 0), j = "app--2935586817", se = async (e, {
|
|
561
568
|
language: t,
|
|
562
569
|
country: a,
|
|
563
|
-
useExternalMetafieldNamespace:
|
|
570
|
+
useExternalMetafieldNamespace: r
|
|
564
571
|
}) => {
|
|
565
|
-
const
|
|
572
|
+
const s = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
|
|
566
573
|
localization: {
|
|
567
574
|
country: {
|
|
568
|
-
currency: { isoCode:
|
|
575
|
+
currency: { isoCode: l }
|
|
569
576
|
}
|
|
570
577
|
},
|
|
571
578
|
shop: {
|
|
572
|
-
moneyFormat:
|
|
573
|
-
paymentSettings: { currencyCode:
|
|
579
|
+
moneyFormat: d,
|
|
580
|
+
paymentSettings: { currencyCode: u },
|
|
574
581
|
currencyRateConstant: c,
|
|
575
|
-
primaryDomain:
|
|
582
|
+
primaryDomain: p,
|
|
576
583
|
settingsMetafield: g
|
|
577
584
|
}
|
|
578
585
|
} = await e.query(
|
|
@@ -604,13 +611,13 @@ const J = (e, t) => {
|
|
|
604
611
|
`,
|
|
605
612
|
{
|
|
606
613
|
variables: {
|
|
607
|
-
metafieldNamespace:
|
|
614
|
+
metafieldNamespace: s,
|
|
608
615
|
settingsNamespace: i
|
|
609
616
|
}
|
|
610
617
|
}
|
|
611
|
-
), y =
|
|
618
|
+
), y = l === u ? d : K(l, { language: t, country: a }), h = c ? re(c.value) : 1, n = g ? JSON.parse(g.value) : null, m = (n == null ? void 0 : n.feature_flags) ?? {}, b = (n == null ? void 0 : n.custom_selectors) ?? {};
|
|
612
619
|
return {
|
|
613
|
-
shopifyDomain:
|
|
620
|
+
shopifyDomain: p.host,
|
|
614
621
|
moneyFormat: y,
|
|
615
622
|
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
616
623
|
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
@@ -618,16 +625,16 @@ const J = (e, t) => {
|
|
|
618
625
|
currencyRate: h,
|
|
619
626
|
marketId: 0,
|
|
620
627
|
productId: null,
|
|
621
|
-
storefrontAccessToken: (
|
|
622
|
-
includeSellingPlans: (
|
|
623
|
-
includeAvailableQuantity: (
|
|
624
|
-
customApiHost: (
|
|
625
|
-
keepQuantityInput: (
|
|
626
|
-
ignoreDeselect: (
|
|
627
|
-
ignoreUnitPrice: (
|
|
628
|
-
requireCustomerLogin: (
|
|
629
|
-
abTestsRunning: (
|
|
630
|
-
webPixel: (
|
|
628
|
+
storefrontAccessToken: (n == null ? void 0 : n.storefront_access_token) ?? null,
|
|
629
|
+
includeSellingPlans: (n == null ? void 0 : n.include_selling_plans) ?? !1,
|
|
630
|
+
includeAvailableQuantity: (n == null ? void 0 : n.include_available_quantity) ?? !1,
|
|
631
|
+
customApiHost: (n == null ? void 0 : n.custom_api_host) ?? null,
|
|
632
|
+
keepQuantityInput: (n == null ? void 0 : n.keep_quantity_input) ?? !1,
|
|
633
|
+
ignoreDeselect: (n == null ? void 0 : n.ignore_deselect) ?? !1,
|
|
634
|
+
ignoreUnitPrice: (n == null ? void 0 : n.ignore_unit_price) ?? !1,
|
|
635
|
+
requireCustomerLogin: (n == null ? void 0 : n.require_customer_login) ?? !1,
|
|
636
|
+
abTestsRunning: (n == null ? void 0 : n.ab_tests_running) ?? !1,
|
|
637
|
+
webPixel: (n == null ? void 0 : n.web_pixel) ?? !1,
|
|
631
638
|
b2bCustomer: !1,
|
|
632
639
|
isLoggedIn: !1,
|
|
633
640
|
preview: !1,
|
|
@@ -665,38 +672,50 @@ const J = (e, t) => {
|
|
|
665
672
|
price: b.price ?? null,
|
|
666
673
|
priceCompare: b.price_compare ?? null
|
|
667
674
|
},
|
|
668
|
-
shopCustomStyles: (
|
|
669
|
-
featureFlags:
|
|
670
|
-
brandColors: (
|
|
675
|
+
shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
|
|
676
|
+
featureFlags: m,
|
|
677
|
+
brandColors: (n == null ? void 0 : n.brand_colors) ?? null
|
|
671
678
|
};
|
|
672
|
-
},
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
679
|
+
}, re = (e) => JSON.parse(e).amount / 1e6, ne = async (e, t, a = 200) => {
|
|
680
|
+
const r = [
|
|
681
|
+
...new Set(
|
|
682
|
+
t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
|
|
683
|
+
)
|
|
684
|
+
];
|
|
685
|
+
if (r.length === 0) return [];
|
|
686
|
+
const s = [];
|
|
687
|
+
for (let i = 0; i < r.length; i += 250)
|
|
688
|
+
s.push(r.slice(i, i + 250));
|
|
689
|
+
return (await Promise.all(
|
|
690
|
+
s.map(
|
|
691
|
+
(i) => e.query(
|
|
692
|
+
`
|
|
693
|
+
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
694
|
+
nodes(ids: $mediaImageIds) {
|
|
695
|
+
... on MediaImage {
|
|
696
|
+
id
|
|
697
|
+
image {
|
|
698
|
+
url(transform: { maxWidth: $size, maxHeight: $size })
|
|
699
|
+
}
|
|
700
|
+
}
|
|
680
701
|
}
|
|
681
702
|
}
|
|
703
|
+
`,
|
|
704
|
+
{
|
|
705
|
+
variables: {
|
|
706
|
+
mediaImageIds: i,
|
|
707
|
+
size: a
|
|
708
|
+
}
|
|
682
709
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
{
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
}
|
|
691
|
-
)).nodes.filter(Boolean).map((l) => ({
|
|
692
|
-
gid: l.id,
|
|
693
|
-
url: l.image.url
|
|
694
|
-
})));
|
|
710
|
+
)
|
|
711
|
+
)
|
|
712
|
+
)).flatMap((i) => i.nodes).filter(Boolean).map((i) => ({
|
|
713
|
+
gid: i.id,
|
|
714
|
+
url: i.image.url
|
|
715
|
+
}));
|
|
716
|
+
};
|
|
695
717
|
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
696
|
-
const
|
|
697
|
-
...le(e),
|
|
698
|
-
...ne(e),
|
|
699
|
-
...re(e),
|
|
718
|
+
const le = (e) => [
|
|
700
719
|
...ie(e),
|
|
701
720
|
...oe(e),
|
|
702
721
|
...ce(e),
|
|
@@ -705,86 +724,123 @@ const se = (e) => [
|
|
|
705
724
|
...me(e),
|
|
706
725
|
...pe(e),
|
|
707
726
|
...fe(e),
|
|
727
|
+
...ge(e),
|
|
708
728
|
...ye(e),
|
|
709
|
-
...
|
|
710
|
-
|
|
729
|
+
...he(e),
|
|
730
|
+
...be(e),
|
|
731
|
+
...ve(e)
|
|
732
|
+
].filter((t) => t != null && !t.includes("placeholder")), ie = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), oe = (e) => e.dealBars.flatMap(
|
|
711
733
|
(t) => t.dealBarType === k.Bundle ? t.bundleProducts.map(
|
|
712
734
|
(a) => a.mediaImageGID
|
|
713
735
|
) : []
|
|
714
|
-
).filter((t) => t != null),
|
|
736
|
+
).filter((t) => t != null), ce = (e) => e.dealBars.map(
|
|
715
737
|
({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
716
|
-
).reduce((t, a) => t.concat(a), []).filter((t) => t != null),
|
|
738
|
+
).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ue = (e) => e.dealBars.flatMap(
|
|
717
739
|
({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
718
|
-
).filter((t) => t != null),
|
|
719
|
-
const
|
|
720
|
-
return [...t, ...
|
|
721
|
-
}, []) : [],
|
|
740
|
+
).filter((t) => t != null), de = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), me = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
|
|
741
|
+
const r = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
|
|
742
|
+
return [...t, ...r];
|
|
743
|
+
}, []) : [], pe = (e) => {
|
|
722
744
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
723
745
|
return [];
|
|
724
746
|
const t = e.collectionBreaks.mediaImageGID;
|
|
725
747
|
return t ? [t] : [];
|
|
726
|
-
},
|
|
727
|
-
var t, a,
|
|
748
|
+
}, fe = (e) => {
|
|
749
|
+
var t, a, r;
|
|
728
750
|
return e.progressiveGifts ? [
|
|
729
|
-
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((
|
|
751
|
+
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
|
|
730
752
|
(a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
|
|
731
|
-
(
|
|
732
|
-
].filter((
|
|
733
|
-
},
|
|
753
|
+
(r = e.progressiveGifts.dealBarStyle) == null ? void 0 : r.lockedMediaImageGID
|
|
754
|
+
].filter((s) => s != null) : [];
|
|
755
|
+
}, ge = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ye = (e) => e.dealBars.map((t) => {
|
|
734
756
|
var a;
|
|
735
757
|
return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
|
|
736
|
-
}).filter((t) => t != null),
|
|
737
|
-
var
|
|
758
|
+
}).filter((t) => t != null), he = (e) => {
|
|
759
|
+
var r, s;
|
|
738
760
|
const t = e.dealBars.map((i) => {
|
|
739
761
|
var o;
|
|
740
762
|
return (o = i.highlights) == null ? void 0 : o.customIconGID;
|
|
741
|
-
}).filter((i) => i != null), a = (
|
|
763
|
+
}).filter((i) => i != null), a = (s = (r = e.subscriptions) == null ? void 0 : r.highlights) == null ? void 0 : s.customIconGID;
|
|
742
764
|
return a ? [...t, a] : t;
|
|
743
|
-
},
|
|
765
|
+
}, be = (e) => (e.badges || []).flatMap(
|
|
744
766
|
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
745
|
-
),
|
|
767
|
+
), ve = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], _e = (e) => {
|
|
746
768
|
const t = [
|
|
747
|
-
...be(e),
|
|
748
|
-
...ve(e),
|
|
749
|
-
..._e(e),
|
|
750
769
|
...Ie(e),
|
|
751
770
|
...Pe(e),
|
|
752
771
|
...Se(e),
|
|
753
772
|
...ke(e),
|
|
754
|
-
...we(e)
|
|
773
|
+
...we(e),
|
|
774
|
+
...$e(e),
|
|
775
|
+
...Ne(e),
|
|
776
|
+
...De(e)
|
|
755
777
|
];
|
|
756
778
|
return Array.from(new Set(t.filter((a) => a != null)));
|
|
757
|
-
},
|
|
779
|
+
}, Ie = (e) => e.dealBars.flatMap(
|
|
758
780
|
({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
|
|
759
|
-
).filter((t) => t != null),
|
|
781
|
+
).filter((t) => t != null), Pe = (e) => e.dealBars.flatMap(
|
|
760
782
|
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
761
|
-
(a) => a.products ? a.products.map((
|
|
783
|
+
(a) => a.products ? a.products.map((r) => r.id) : []
|
|
762
784
|
) : []
|
|
763
|
-
).filter((t) => t != null),
|
|
785
|
+
).filter((t) => t != null), Se = (e) => {
|
|
764
786
|
var t;
|
|
765
787
|
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
|
|
766
|
-
},
|
|
788
|
+
}, ke = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), we = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
|
|
767
789
|
({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
|
|
768
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
790
|
+
).filter((t) => t != null).filter((t) => t !== "default"), $e = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
|
|
769
791
|
({ bundleProducts: t }) => t ? t.flatMap((a) => {
|
|
770
|
-
var
|
|
792
|
+
var r;
|
|
771
793
|
return [
|
|
772
794
|
a.productGID,
|
|
773
|
-
...((
|
|
795
|
+
...((r = a.selectedProducts) == null ? void 0 : r.map((s) => s.id)) ?? []
|
|
774
796
|
];
|
|
775
797
|
}) : []
|
|
776
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
777
|
-
class
|
|
798
|
+
).filter((t) => t != null).filter((t) => t !== "default"), Ne = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), De = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
|
|
799
|
+
class O extends Error {
|
|
800
|
+
constructor({
|
|
801
|
+
status: t,
|
|
802
|
+
operationName: a,
|
|
803
|
+
graphqlErrors: r
|
|
804
|
+
}) {
|
|
805
|
+
const s = r.length ? `: ${r.join("; ")}` : "";
|
|
806
|
+
super(
|
|
807
|
+
`Storefront API ${a ?? "query"} failed (HTTP ${t})${s}`
|
|
808
|
+
), this.name = "StorefrontApiError", this.status = t, this.operationName = a, this.graphqlErrors = r;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const Ae = async (e, t) => {
|
|
812
|
+
const a = await e.text();
|
|
813
|
+
if (!a)
|
|
814
|
+
throw new Error("Empty graphql response");
|
|
815
|
+
let r;
|
|
816
|
+
try {
|
|
817
|
+
r = JSON.parse(a);
|
|
818
|
+
} catch (s) {
|
|
819
|
+
throw e.ok ? s : new O({
|
|
820
|
+
status: e.status,
|
|
821
|
+
operationName: t,
|
|
822
|
+
graphqlErrors: []
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
if (!e.ok || r.data === null || r.data === void 0)
|
|
826
|
+
throw new O({
|
|
827
|
+
status: e.status,
|
|
828
|
+
operationName: t,
|
|
829
|
+
graphqlErrors: (r.errors ?? []).map(({ message: s }) => s).filter(Boolean)
|
|
830
|
+
});
|
|
831
|
+
return r.data;
|
|
832
|
+
};
|
|
833
|
+
class xe {
|
|
778
834
|
constructor(t, a) {
|
|
779
835
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
|
|
780
836
|
}
|
|
781
837
|
async query(t, a) {
|
|
782
|
-
var
|
|
783
|
-
const
|
|
784
|
-
let
|
|
785
|
-
const i = (
|
|
786
|
-
i && (
|
|
787
|
-
const o = await
|
|
838
|
+
var l;
|
|
839
|
+
const r = (a == null ? void 0 : a.variables) ?? {};
|
|
840
|
+
let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
841
|
+
const i = (l = t.match(/query\s+(\w+)/)) == null ? void 0 : l[1];
|
|
842
|
+
i && (s += `?operation_name=${i}`);
|
|
843
|
+
const o = await fetch(s, {
|
|
788
844
|
method: "POST",
|
|
789
845
|
headers: {
|
|
790
846
|
"Content-Type": "application/json",
|
|
@@ -792,157 +848,190 @@ class $e {
|
|
|
792
848
|
},
|
|
793
849
|
body: JSON.stringify({
|
|
794
850
|
query: t,
|
|
795
|
-
variables:
|
|
851
|
+
variables: r
|
|
796
852
|
})
|
|
797
|
-
})
|
|
798
|
-
|
|
799
|
-
throw new Error("Empty graphql response");
|
|
800
|
-
return JSON.parse(o).data;
|
|
853
|
+
});
|
|
854
|
+
return Ae(o, i);
|
|
801
855
|
}
|
|
802
856
|
}
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
if (!t.collectionBreaksEnabled || !
|
|
857
|
+
const Ee = async (e, t, { country: a, language: r }) => {
|
|
858
|
+
const s = t.collectionBreaks;
|
|
859
|
+
if (!t.collectionBreaksEnabled || !s) return;
|
|
806
860
|
let i;
|
|
807
|
-
|
|
861
|
+
s.visibility === "deal-products" ? i = await T(e, {
|
|
808
862
|
country: a,
|
|
809
|
-
language:
|
|
863
|
+
language: r,
|
|
810
864
|
blockVisibility: t.blockVisibility,
|
|
811
865
|
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
812
|
-
(
|
|
866
|
+
(l) => `gid://shopify/Product/${l}`
|
|
813
867
|
),
|
|
814
868
|
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
815
|
-
(
|
|
869
|
+
(l) => `gid://shopify/Product/${l}`
|
|
816
870
|
),
|
|
817
871
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
818
|
-
(
|
|
872
|
+
(l) => `gid://shopify/Collection/${l}`
|
|
819
873
|
)
|
|
820
|
-
}) : i = await
|
|
874
|
+
}) : i = await T(e, {
|
|
821
875
|
country: a,
|
|
822
|
-
language:
|
|
823
|
-
blockVisibility:
|
|
824
|
-
excludedProductGIDs: (
|
|
825
|
-
({ id:
|
|
876
|
+
language: r,
|
|
877
|
+
blockVisibility: s.visibility,
|
|
878
|
+
excludedProductGIDs: (s.excludedProducts || []).map(
|
|
879
|
+
({ id: l }) => l
|
|
826
880
|
),
|
|
827
|
-
selectedProductGIDs: (
|
|
828
|
-
({ id:
|
|
881
|
+
selectedProductGIDs: (s.selectedProducts || []).map(
|
|
882
|
+
({ id: l }) => l
|
|
829
883
|
),
|
|
830
|
-
selectedCollectionGIDs: (
|
|
831
|
-
({ id:
|
|
884
|
+
selectedCollectionGIDs: (s.selectedCollections || []).map(
|
|
885
|
+
({ id: l }) => l
|
|
832
886
|
)
|
|
833
887
|
});
|
|
834
888
|
let o = await A(e, {
|
|
835
889
|
country: a,
|
|
836
|
-
language:
|
|
837
|
-
productIds: i.map((
|
|
890
|
+
language: r,
|
|
891
|
+
productIds: i.map((l) => Number(l.split("/").pop())),
|
|
838
892
|
useExternalMetafieldNamespace: !0
|
|
839
893
|
});
|
|
840
894
|
return o = o.filter(
|
|
841
|
-
(
|
|
895
|
+
(l) => l.availableForSale
|
|
842
896
|
), o;
|
|
843
|
-
},
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
897
|
+
}, Be = ({
|
|
898
|
+
language: e,
|
|
899
|
+
dealBlockId: t
|
|
900
|
+
}) => {
|
|
901
|
+
const a = {
|
|
902
|
+
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
903
|
+
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
904
|
+
"system.unavailable_option_value": "Unavailable",
|
|
905
|
+
"system.confirm": "Confirm",
|
|
906
|
+
"system.cancel": "Cancel",
|
|
907
|
+
"system.free": "FREE",
|
|
908
|
+
"system.search": "Search",
|
|
909
|
+
"system.quantity": "Quantity",
|
|
910
|
+
"system.subscription_plan": "Subscription plan",
|
|
911
|
+
"system.remove": "Remove",
|
|
912
|
+
"system.sort_by": "Sort by",
|
|
913
|
+
"system.sort_relevance": "Relevance",
|
|
914
|
+
"system.sort_newest_first": "Newest first",
|
|
915
|
+
"system.sort_price_low_to_high": "Price: Low → High",
|
|
916
|
+
"system.sort_price_high_to_low": "Price: High → Low",
|
|
917
|
+
"system.no_results_found": "No results found",
|
|
918
|
+
"system.no_results_description": "We can't find any item matching your search.",
|
|
919
|
+
"system.clear_search": "Clear search",
|
|
920
|
+
"system.no_products_available": "No products available",
|
|
921
|
+
"system.original_price": "Original price:",
|
|
922
|
+
"system.price": "Price:",
|
|
923
|
+
"system.letters_only": "Only letters are allowed.",
|
|
924
|
+
"system.numbers_only": "Only numbers are allowed.",
|
|
925
|
+
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
926
|
+
}, r = e ? Ge(e) : void 0;
|
|
927
|
+
return {
|
|
928
|
+
...a,
|
|
929
|
+
...r == null ? void 0 : r.system,
|
|
930
|
+
...r == null ? void 0 : r.dealBlocks[t]
|
|
931
|
+
};
|
|
932
|
+
}, Ge = (e) => {
|
|
933
|
+
var s;
|
|
934
|
+
if (typeof document > "u") return;
|
|
935
|
+
const t = document.querySelector("script#kaching-bundles-translations");
|
|
936
|
+
if (!(t != null && t.textContent)) return;
|
|
937
|
+
let a;
|
|
938
|
+
try {
|
|
939
|
+
a = JSON.parse(t.textContent);
|
|
940
|
+
} catch {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
const r = V(e);
|
|
944
|
+
return (s = a.find(
|
|
945
|
+
(i) => V(i.locale) === r
|
|
946
|
+
)) == null ? void 0 : s.translations;
|
|
947
|
+
}, V = (e) => e.toLowerCase().replace(/_/g, "-"), Ce = "2026-07", Te = async (e, {
|
|
869
948
|
productId: t,
|
|
870
949
|
dealBlockId: a,
|
|
871
|
-
country:
|
|
872
|
-
language:
|
|
950
|
+
country: r = void 0,
|
|
951
|
+
language: s = void 0
|
|
873
952
|
}) => {
|
|
874
953
|
var i, o;
|
|
875
954
|
try {
|
|
876
|
-
const
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
language:
|
|
880
|
-
country:
|
|
955
|
+
const l = [Number(t.split("/").pop())], d = new qe(e);
|
|
956
|
+
r = r || ((i = d.i18n) == null ? void 0 : i.country), s = s || ((o = d.i18n) == null ? void 0 : o.language);
|
|
957
|
+
const u = await se(d, {
|
|
958
|
+
language: s,
|
|
959
|
+
country: r,
|
|
881
960
|
useExternalMetafieldNamespace: !0
|
|
882
961
|
});
|
|
883
|
-
|
|
884
|
-
const c =
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
) :
|
|
962
|
+
d.shopifyDomain = u.shopifyDomain;
|
|
963
|
+
const c = u.storefrontAccessToken ? new xe(
|
|
964
|
+
u.shopifyDomain,
|
|
965
|
+
u.storefrontAccessToken
|
|
966
|
+
) : d, [p, g] = await Promise.all([
|
|
888
967
|
A(c, {
|
|
889
|
-
country:
|
|
890
|
-
language:
|
|
891
|
-
productIds:
|
|
968
|
+
country: r,
|
|
969
|
+
language: s,
|
|
970
|
+
productIds: l,
|
|
892
971
|
useExternalMetafieldNamespace: !0
|
|
893
972
|
}),
|
|
894
|
-
|
|
973
|
+
Z(c, {
|
|
895
974
|
useExternalMetafieldNamespace: !0,
|
|
896
|
-
useMetaobjects:
|
|
975
|
+
useMetaobjects: u.featureFlags.storefront_metaobjects
|
|
897
976
|
})
|
|
898
|
-
]), y =
|
|
977
|
+
]), y = p[0];
|
|
899
978
|
if (!y)
|
|
900
979
|
return null;
|
|
901
|
-
const h =
|
|
902
|
-
let
|
|
903
|
-
if (a ? (
|
|
980
|
+
const h = H(g, y);
|
|
981
|
+
let n;
|
|
982
|
+
if (a ? (n = h.find(
|
|
904
983
|
(P) => P.id === a || P.nanoId === a
|
|
905
|
-
),
|
|
984
|
+
), n || (n = h[0])) : n = h[0], !n)
|
|
906
985
|
return null;
|
|
907
|
-
const
|
|
986
|
+
const m = le(n), b = _e(n), [I, _, f, v] = await Promise.all([
|
|
908
987
|
A(c, {
|
|
909
|
-
country:
|
|
910
|
-
language:
|
|
988
|
+
country: r,
|
|
989
|
+
language: s,
|
|
911
990
|
productIds: b,
|
|
912
991
|
useExternalMetafieldNamespace: !0
|
|
913
992
|
}),
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
country:
|
|
917
|
-
language:
|
|
993
|
+
ne(c, m, 300),
|
|
994
|
+
Ee(c, n, {
|
|
995
|
+
country: r,
|
|
996
|
+
language: s
|
|
918
997
|
}),
|
|
919
|
-
|
|
998
|
+
Be({ language: s, dealBlockId: n.id })
|
|
920
999
|
]);
|
|
921
1000
|
return {
|
|
922
1001
|
product: y,
|
|
923
|
-
dealBlock:
|
|
924
|
-
config:
|
|
925
|
-
otherProducts:
|
|
926
|
-
mediaImages:
|
|
927
|
-
collectionBreaksProducts:
|
|
928
|
-
translations:
|
|
1002
|
+
dealBlock: n,
|
|
1003
|
+
config: u,
|
|
1004
|
+
otherProducts: I,
|
|
1005
|
+
mediaImages: _,
|
|
1006
|
+
collectionBreaksProducts: f ?? [],
|
|
1007
|
+
translations: v
|
|
929
1008
|
};
|
|
930
|
-
} catch (
|
|
931
|
-
return console.error(
|
|
1009
|
+
} catch (l) {
|
|
1010
|
+
return console.error(l), null;
|
|
932
1011
|
}
|
|
933
1012
|
};
|
|
934
|
-
class
|
|
1013
|
+
class qe {
|
|
935
1014
|
constructor(t) {
|
|
936
1015
|
this.storefront = t, this.shopifyDomain = "";
|
|
937
1016
|
}
|
|
938
1017
|
async query(t, a) {
|
|
1018
|
+
var r;
|
|
939
1019
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
940
1020
|
return await this.storefront.query(t, a);
|
|
1021
|
+
if ("graphql" in this.storefront) {
|
|
1022
|
+
const s = await this.storefront.graphql(t, a);
|
|
1023
|
+
if ((r = s.errors) != null && r.length)
|
|
1024
|
+
throw new Error(
|
|
1025
|
+
s.errors.map((i) => i.message).join(`
|
|
1026
|
+
`)
|
|
1027
|
+
);
|
|
1028
|
+
return s.data;
|
|
1029
|
+
}
|
|
941
1030
|
if ("request" in this.storefront)
|
|
942
1031
|
return (await this.storefront.request(t, a)).data;
|
|
943
1032
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
944
|
-
const
|
|
945
|
-
`https://${this.storefront.shopifyDomain}/api/${
|
|
1033
|
+
const s = await fetch(
|
|
1034
|
+
`https://${this.storefront.shopifyDomain}/api/${Ce}/graphql.json`,
|
|
946
1035
|
{
|
|
947
1036
|
body: JSON.stringify({
|
|
948
1037
|
query: t,
|
|
@@ -955,11 +1044,11 @@ class Ge {
|
|
|
955
1044
|
method: "POST"
|
|
956
1045
|
}
|
|
957
1046
|
);
|
|
958
|
-
if (!
|
|
959
|
-
throw new Error(
|
|
960
|
-
return (await
|
|
1047
|
+
if (!s.ok)
|
|
1048
|
+
throw new Error(s.statusText);
|
|
1049
|
+
return (await s.json()).data;
|
|
961
1050
|
} else {
|
|
962
|
-
const
|
|
1051
|
+
const s = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
963
1052
|
body: JSON.stringify({
|
|
964
1053
|
query: t,
|
|
965
1054
|
variables: a == null ? void 0 : a.variables
|
|
@@ -967,9 +1056,9 @@ class Ge {
|
|
|
967
1056
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
968
1057
|
method: "POST"
|
|
969
1058
|
});
|
|
970
|
-
if (!
|
|
971
|
-
throw new Error(
|
|
972
|
-
return (await
|
|
1059
|
+
if (!s.ok)
|
|
1060
|
+
throw new Error(s.statusText);
|
|
1061
|
+
return (await s.json()).data;
|
|
973
1062
|
}
|
|
974
1063
|
}
|
|
975
1064
|
get i18n() {
|
|
@@ -977,32 +1066,32 @@ class Ge {
|
|
|
977
1066
|
return this.storefront.i18n;
|
|
978
1067
|
}
|
|
979
1068
|
}
|
|
980
|
-
const
|
|
1069
|
+
const at = Te, $ = "kaching-bundles-block", U = 1e4, Me = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", je = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Oe = async (e) => {
|
|
981
1070
|
const t = e.document;
|
|
982
1071
|
if (!e.customElements.get($)) {
|
|
983
1072
|
if (N.has(t))
|
|
984
1073
|
return x(e, $);
|
|
985
1074
|
N.add(t);
|
|
986
1075
|
try {
|
|
987
|
-
await
|
|
1076
|
+
await Fe(e);
|
|
988
1077
|
} catch (a) {
|
|
989
1078
|
throw N.delete(t), a;
|
|
990
1079
|
}
|
|
991
1080
|
}
|
|
992
|
-
},
|
|
1081
|
+
}, Ve = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Ue = () => Ve() ? Me : je, Fe = (e) => {
|
|
993
1082
|
const t = e.document;
|
|
994
|
-
return new Promise((a,
|
|
995
|
-
const
|
|
1083
|
+
return new Promise((a, r) => {
|
|
1084
|
+
const s = Ue();
|
|
996
1085
|
if (t.querySelector(
|
|
997
|
-
`script[src="${
|
|
1086
|
+
`script[src="${s}"]`
|
|
998
1087
|
)) {
|
|
999
|
-
x(e, $).then(a).catch(
|
|
1088
|
+
x(e, $).then(a).catch(r);
|
|
1000
1089
|
return;
|
|
1001
1090
|
}
|
|
1002
1091
|
const o = t.createElement("script");
|
|
1003
|
-
o.src =
|
|
1092
|
+
o.src = s, o.onload = () => x(e, $).then(a).catch(r), o.onerror = () => r(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1004
1093
|
});
|
|
1005
|
-
}, x = (e, t) => new Promise((a,
|
|
1094
|
+
}, x = (e, t) => new Promise((a, r) => {
|
|
1006
1095
|
if (e.customElements.get(t)) {
|
|
1007
1096
|
a();
|
|
1008
1097
|
return;
|
|
@@ -1010,35 +1099,35 @@ const Xe = xe, $ = "kaching-bundles-block", j = 1e4, Be = "https://bundles-integ
|
|
|
1010
1099
|
Promise.race([
|
|
1011
1100
|
e.customElements.whenDefined(t),
|
|
1012
1101
|
new Promise(
|
|
1013
|
-
(
|
|
1102
|
+
(s, i) => setTimeout(
|
|
1014
1103
|
() => i(
|
|
1015
1104
|
new Error(
|
|
1016
|
-
`Custom element "${t}" failed to register within ${
|
|
1105
|
+
`Custom element "${t}" failed to register within ${U}ms`
|
|
1017
1106
|
)
|
|
1018
1107
|
),
|
|
1019
|
-
|
|
1108
|
+
U
|
|
1020
1109
|
)
|
|
1021
1110
|
)
|
|
1022
|
-
]).then(() => a()).catch(
|
|
1111
|
+
]).then(() => a()).catch(r);
|
|
1023
1112
|
});
|
|
1024
|
-
var
|
|
1025
|
-
const S = "a-f\\d",
|
|
1026
|
-
function
|
|
1027
|
-
if (typeof e != "string" ||
|
|
1113
|
+
var E = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(E || {});
|
|
1114
|
+
const S = "a-f\\d", Le = `#?[${S}]{3}[${S}]?`, Re = `#?[${S}]{6}([${S}]{2})?`, Je = new RegExp(`[^#${S}]`, "gi"), ze = new RegExp(`^${Le}$|^${Re}$`, "i");
|
|
1115
|
+
function Qe(e, t = {}) {
|
|
1116
|
+
if (typeof e != "string" || Je.test(e) || !ze.test(e))
|
|
1028
1117
|
throw new TypeError("Expected a valid hex string");
|
|
1029
1118
|
e = e.replace(/^#/, "");
|
|
1030
1119
|
let a = 1;
|
|
1031
1120
|
e.length === 8 && (a = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (a = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
|
|
1032
|
-
const
|
|
1121
|
+
const r = Number.parseInt(e, 16), s = r >> 16, i = r >> 8 & 255, o = r & 255, l = typeof t.alpha == "number" ? t.alpha : a;
|
|
1033
1122
|
if (t.format === "array")
|
|
1034
|
-
return [
|
|
1123
|
+
return [s, i, o, l];
|
|
1035
1124
|
if (t.format === "css") {
|
|
1036
|
-
const
|
|
1037
|
-
return `rgb(${
|
|
1125
|
+
const d = l === 1 ? "" : ` / ${Number((l * 100).toFixed(2))}%`;
|
|
1126
|
+
return `rgb(${s} ${i} ${o}${d})`;
|
|
1038
1127
|
}
|
|
1039
|
-
return { red:
|
|
1128
|
+
return { red: s, green: i, blue: o, alpha: l };
|
|
1040
1129
|
}
|
|
1041
|
-
const
|
|
1130
|
+
const He = ({ price: e }) => ({
|
|
1042
1131
|
id: 123,
|
|
1043
1132
|
handle: "123",
|
|
1044
1133
|
url: null,
|
|
@@ -1073,7 +1162,7 @@ const Re = ({ price: e }) => ({
|
|
|
1073
1162
|
text4: null
|
|
1074
1163
|
},
|
|
1075
1164
|
isNativeBundle: !1
|
|
1076
|
-
}),
|
|
1165
|
+
}), Ke = () => ({
|
|
1077
1166
|
shopifyDomain: "",
|
|
1078
1167
|
moneyFormat: "${{amount_with_comma_separator}}",
|
|
1079
1168
|
locale: "en",
|
|
@@ -1129,7 +1218,7 @@ const Re = ({ price: e }) => ({
|
|
|
1129
1218
|
},
|
|
1130
1219
|
shopCustomStyles: "",
|
|
1131
1220
|
featureFlags: {}
|
|
1132
|
-
}),
|
|
1221
|
+
}), We = ({
|
|
1133
1222
|
color: e,
|
|
1134
1223
|
cornerRadius: t
|
|
1135
1224
|
}) => {
|
|
@@ -1183,7 +1272,7 @@ const Re = ({ price: e }) => ({
|
|
|
1183
1272
|
dealBars: [
|
|
1184
1273
|
{
|
|
1185
1274
|
id: "PfFU",
|
|
1186
|
-
dealBarType:
|
|
1275
|
+
dealBarType: E.QuantityBreak,
|
|
1187
1276
|
title: "1 pack",
|
|
1188
1277
|
subtitle: "Standard price",
|
|
1189
1278
|
label: "",
|
|
@@ -1203,7 +1292,7 @@ const Re = ({ price: e }) => ({
|
|
|
1203
1292
|
},
|
|
1204
1293
|
{
|
|
1205
1294
|
id: "1f-9",
|
|
1206
|
-
dealBarType:
|
|
1295
|
+
dealBarType: E.QuantityBreak,
|
|
1207
1296
|
title: "2 pack",
|
|
1208
1297
|
subtitle: "You save {{saved_percentage}}",
|
|
1209
1298
|
label: "SAVE {{saved_total}}",
|
|
@@ -1393,88 +1482,88 @@ const Re = ({ price: e }) => ({
|
|
|
1393
1482
|
imageSize: 48,
|
|
1394
1483
|
imageCornerRadius: 6
|
|
1395
1484
|
};
|
|
1396
|
-
return e !== void 0 && (a.colors.border = { ...
|
|
1397
|
-
},
|
|
1485
|
+
return e !== void 0 && (a.colors.border = { ...Qe(e), alpha: 1 }), a;
|
|
1486
|
+
}, st = ({
|
|
1398
1487
|
data: e,
|
|
1399
1488
|
selectedVariantId: t,
|
|
1400
1489
|
preview: a,
|
|
1401
|
-
onLinesChange:
|
|
1402
|
-
targetWindow:
|
|
1490
|
+
onLinesChange: r,
|
|
1491
|
+
targetWindow: s
|
|
1403
1492
|
}) => {
|
|
1404
|
-
const i = B(null), [o,
|
|
1493
|
+
const i = B(null), [o, l] = z(!1), d = B(!1);
|
|
1405
1494
|
D(() => {
|
|
1406
1495
|
if (!i.current || o) return;
|
|
1407
1496
|
(async () => {
|
|
1408
|
-
await
|
|
1497
|
+
await Oe(s ?? window), l(!0);
|
|
1409
1498
|
})();
|
|
1410
|
-
}, [o,
|
|
1499
|
+
}, [o, s]), D(() => {
|
|
1411
1500
|
const c = i.current;
|
|
1412
1501
|
if (!o || !c) return;
|
|
1413
|
-
const
|
|
1502
|
+
const p = () => {
|
|
1414
1503
|
const y = c.items().map((h) => ({
|
|
1415
1504
|
merchandiseId: `gid://shopify/ProductVariant/${h.id}`,
|
|
1416
1505
|
quantity: h.quantity,
|
|
1417
|
-
attributes: Object.entries(h.properties).map(([
|
|
1418
|
-
key:
|
|
1419
|
-
value: String(
|
|
1506
|
+
attributes: Object.entries(h.properties).map(([n, m]) => ({
|
|
1507
|
+
key: n,
|
|
1508
|
+
value: String(m)
|
|
1420
1509
|
})),
|
|
1421
1510
|
sellingPlanId: h.selling_plan ? `gid://shopify/SellingPlan/${h.selling_plan}` : void 0
|
|
1422
1511
|
}));
|
|
1423
|
-
|
|
1512
|
+
r == null || r(y);
|
|
1424
1513
|
};
|
|
1425
|
-
return
|
|
1426
|
-
c.removeEventListener("kaching-bundles-block-loaded",
|
|
1514
|
+
return d.current || (typeof c.items == "function" ? p() : c.addEventListener("kaching-bundles-block-loaded", p), d.current = !0), c.addEventListener("variants-changed", p), () => {
|
|
1515
|
+
c.removeEventListener("kaching-bundles-block-loaded", p), c.removeEventListener("variants-changed", p);
|
|
1427
1516
|
};
|
|
1428
|
-
}, [o,
|
|
1429
|
-
const
|
|
1430
|
-
return
|
|
1517
|
+
}, [o, r]);
|
|
1518
|
+
const u = e ? Ye(e, t) : a ? Ze(a) : null;
|
|
1519
|
+
return Xe(() => {
|
|
1431
1520
|
const c = i.current;
|
|
1432
|
-
if (!(!c || !
|
|
1433
|
-
for (const [
|
|
1434
|
-
c.getAttribute(
|
|
1435
|
-
}),
|
|
1521
|
+
if (!(!c || !u))
|
|
1522
|
+
for (const [p, g] of Object.entries(u.jsonAttributes))
|
|
1523
|
+
c.getAttribute(p) !== g && c.setAttribute(p, g);
|
|
1524
|
+
}), u ? /* @__PURE__ */ J(
|
|
1436
1525
|
"kaching-bundles-block",
|
|
1437
1526
|
{
|
|
1438
1527
|
ref: i,
|
|
1439
|
-
"deal-block-id":
|
|
1440
|
-
...
|
|
1441
|
-
"current-variant-id":
|
|
1528
|
+
"deal-block-id": u.dealBlockId,
|
|
1529
|
+
...u.jsonAttributes,
|
|
1530
|
+
"current-variant-id": u.currentVariantId
|
|
1442
1531
|
}
|
|
1443
1532
|
) : null;
|
|
1444
|
-
},
|
|
1533
|
+
}, Xe = typeof window > "u" ? D : Q, Ye = ({
|
|
1445
1534
|
config: e,
|
|
1446
1535
|
dealBlock: t,
|
|
1447
1536
|
product: a,
|
|
1448
|
-
otherProducts:
|
|
1449
|
-
mediaImages:
|
|
1537
|
+
otherProducts: r,
|
|
1538
|
+
mediaImages: s,
|
|
1450
1539
|
collectionBreaksProducts: i,
|
|
1451
1540
|
translations: o
|
|
1452
|
-
},
|
|
1541
|
+
}, l) => ({
|
|
1453
1542
|
dealBlockId: t.id,
|
|
1454
|
-
currentVariantId:
|
|
1543
|
+
currentVariantId: l ? l.split("/").pop() : String(a.variants[0].id),
|
|
1455
1544
|
jsonAttributes: {
|
|
1456
1545
|
config: JSON.stringify(e),
|
|
1457
1546
|
"deal-block": JSON.stringify(t),
|
|
1458
|
-
"media-images": JSON.stringify(
|
|
1547
|
+
"media-images": JSON.stringify(s),
|
|
1459
1548
|
product: JSON.stringify(a),
|
|
1460
|
-
"other-products": JSON.stringify(
|
|
1549
|
+
"other-products": JSON.stringify(r),
|
|
1461
1550
|
"collection-breaks-products": JSON.stringify(i),
|
|
1462
1551
|
translations: JSON.stringify(o)
|
|
1463
1552
|
}
|
|
1464
|
-
}),
|
|
1553
|
+
}), Ze = ({
|
|
1465
1554
|
cornerRadius: e,
|
|
1466
1555
|
color: t,
|
|
1467
1556
|
price: a
|
|
1468
1557
|
}) => {
|
|
1469
|
-
const
|
|
1558
|
+
const r = He({ price: a }), s = Ke(), i = We({ color: t, cornerRadius: e });
|
|
1470
1559
|
return {
|
|
1471
1560
|
dealBlockId: i.id,
|
|
1472
|
-
currentVariantId: String(
|
|
1561
|
+
currentVariantId: String(r.variants[0].id),
|
|
1473
1562
|
jsonAttributes: {
|
|
1474
|
-
config: JSON.stringify(
|
|
1563
|
+
config: JSON.stringify(s),
|
|
1475
1564
|
"deal-block": JSON.stringify(i),
|
|
1476
1565
|
"media-images": JSON.stringify([]),
|
|
1477
|
-
product: JSON.stringify(
|
|
1566
|
+
product: JSON.stringify(r),
|
|
1478
1567
|
"other-products": JSON.stringify([]),
|
|
1479
1568
|
"collection-breaks-products": JSON.stringify([]),
|
|
1480
1569
|
translations: JSON.stringify({})
|
|
@@ -1482,6 +1571,6 @@ const Re = ({ price: e }) => ({
|
|
|
1482
1571
|
};
|
|
1483
1572
|
};
|
|
1484
1573
|
export {
|
|
1485
|
-
|
|
1486
|
-
|
|
1574
|
+
st as KachingBundle,
|
|
1575
|
+
at as fetchKachingBundlesData
|
|
1487
1576
|
};
|