@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/index.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
const
|
|
2
|
-
const a = [],
|
|
3
|
-
(
|
|
1
|
+
const T = (e, t) => {
|
|
2
|
+
const a = [], n = e.filter(
|
|
3
|
+
(i) => i.blockVisibility === "selected-products"
|
|
4
4
|
);
|
|
5
|
-
for (const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
(
|
|
5
|
+
for (const i of n)
|
|
6
|
+
i.selectedProductIds.map(Number).includes(t.id) && a.push(i);
|
|
7
|
+
const s = e.filter(
|
|
8
|
+
(i) => i.blockVisibility === "selected-collections"
|
|
9
9
|
);
|
|
10
|
-
for (const
|
|
10
|
+
for (const i of s)
|
|
11
11
|
t.collectionIds.some(
|
|
12
|
-
(d) =>
|
|
13
|
-
) && a.push(
|
|
14
|
-
const
|
|
15
|
-
(
|
|
12
|
+
(d) => i.selectedCollectionIds.map(Number).includes(d)
|
|
13
|
+
) && a.push(i);
|
|
14
|
+
const l = e.filter(
|
|
15
|
+
(i) => i.blockVisibility === "excluded-products"
|
|
16
16
|
);
|
|
17
|
-
for (const
|
|
18
|
-
!
|
|
17
|
+
for (const i of l)
|
|
18
|
+
!i.excludedProductIds.map(Number).includes(t.id) && !(i.excludedCollectionIds || []).some(
|
|
19
19
|
(d) => t.collectionIds.includes(d)
|
|
20
|
-
) && a.push(
|
|
20
|
+
) && a.push(i);
|
|
21
21
|
const u = e.filter(
|
|
22
|
-
(
|
|
22
|
+
(i) => i.blockVisibility === "all-products"
|
|
23
23
|
);
|
|
24
|
-
for (const
|
|
25
|
-
a.push(
|
|
24
|
+
for (const i of u)
|
|
25
|
+
a.push(i);
|
|
26
26
|
return a;
|
|
27
|
-
},
|
|
28
|
-
var
|
|
29
|
-
const
|
|
27
|
+
}, E = (e, { language: t, country: a }) => {
|
|
28
|
+
var f, h;
|
|
29
|
+
const n = O(t, a), s = new Intl.NumberFormat(n, {
|
|
30
30
|
style: "currency",
|
|
31
31
|
currency: e,
|
|
32
32
|
currencyDisplay: "narrowSymbol"
|
|
33
|
-
}).formatToParts(123456789e-2),
|
|
34
|
-
(
|
|
35
|
-
),
|
|
33
|
+
}).formatToParts(123456789e-2), l = (f = s.find((y) => y.type === "decimal")) == null ? void 0 : f.value, u = F(
|
|
34
|
+
(h = s.find((y) => y.type === "group")) == null ? void 0 : h.value
|
|
35
|
+
), i = s.some((y) => y.type === "fraction"), d = U(
|
|
36
36
|
u,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
37
|
+
l,
|
|
38
|
+
i
|
|
39
|
+
), c = s.findIndex(N), p = s.findLastIndex(N);
|
|
40
40
|
return [
|
|
41
|
-
...
|
|
41
|
+
...s.slice(0, c).map(D),
|
|
42
42
|
d,
|
|
43
|
-
...
|
|
43
|
+
...s.slice(p + 1).map(D)
|
|
44
44
|
].join("");
|
|
45
|
-
}, D = (e) => M(e.value), M = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction",
|
|
45
|
+
}, D = (e) => M(e.value), M = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", O = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), F = (e) => e === void 0 ? void 0 : M(e).replace(/’/g, "'"), U = (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 = ({
|
|
46
46
|
country: e,
|
|
47
47
|
language: t
|
|
48
48
|
}) => {
|
|
49
49
|
const a = [];
|
|
50
50
|
return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
|
|
51
|
-
},
|
|
51
|
+
}, V = async (e, {
|
|
52
52
|
useExternalMetafieldNamespace: t,
|
|
53
53
|
useMetaobjects: a
|
|
54
|
-
}) => a ?
|
|
54
|
+
}) => a ? R(
|
|
55
55
|
e
|
|
56
|
-
) :
|
|
57
|
-
var
|
|
58
|
-
const a = (
|
|
56
|
+
) : L(e), L = async (e, t) => {
|
|
57
|
+
var n;
|
|
58
|
+
const a = (n = (await e.query(
|
|
59
59
|
`
|
|
60
60
|
query FetchDealBlocks($metafieldNamespace: String!) {
|
|
61
61
|
shop {
|
|
@@ -70,13 +70,13 @@ const q = (e, t) => {
|
|
|
70
70
|
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
)).shop.metafield) == null ? void 0 :
|
|
73
|
+
)).shop.metafield) == null ? void 0 : n.value;
|
|
74
74
|
return a ? JSON.parse(a) : [];
|
|
75
|
-
},
|
|
76
|
-
const a = "app--2935586817--deal_block",
|
|
77
|
-
let
|
|
75
|
+
}, R = async (e, t) => {
|
|
76
|
+
const a = "app--2935586817--deal_block", n = [];
|
|
77
|
+
let s = null;
|
|
78
78
|
for (; ; ) {
|
|
79
|
-
const
|
|
79
|
+
const l = await e.query(
|
|
80
80
|
`
|
|
81
81
|
query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
|
|
82
82
|
metaobjects(type: $type, first: 250, after: $cursor) {
|
|
@@ -96,39 +96,39 @@ const q = (e, t) => {
|
|
|
96
96
|
{
|
|
97
97
|
variables: {
|
|
98
98
|
type: a,
|
|
99
|
-
cursor:
|
|
99
|
+
cursor: s
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
|
-
for (const u of
|
|
104
|
-
const
|
|
103
|
+
for (const u of l.metaobjects.nodes) {
|
|
104
|
+
const i = u.fields.find(
|
|
105
105
|
(d) => d.key === "settings"
|
|
106
106
|
);
|
|
107
|
-
|
|
107
|
+
i != null && i.value && n.push(JSON.parse(i.value));
|
|
108
108
|
}
|
|
109
|
-
if (!
|
|
109
|
+
if (!l.metaobjects.pageInfo.hasNextPage)
|
|
110
110
|
break;
|
|
111
|
-
|
|
111
|
+
s = l.metaobjects.pageInfo.endCursor;
|
|
112
112
|
}
|
|
113
|
-
return
|
|
113
|
+
return n;
|
|
114
114
|
}, k = async (e, {
|
|
115
115
|
country: t,
|
|
116
116
|
language: a,
|
|
117
|
-
blockVisibility:
|
|
118
|
-
excludedProductGIDs:
|
|
119
|
-
selectedProductGIDs:
|
|
117
|
+
blockVisibility: n,
|
|
118
|
+
excludedProductGIDs: s,
|
|
119
|
+
selectedProductGIDs: l,
|
|
120
120
|
selectedCollectionGIDs: u,
|
|
121
|
-
limit:
|
|
121
|
+
limit: i = 1e3
|
|
122
122
|
}) => {
|
|
123
|
-
switch (
|
|
123
|
+
switch (n) {
|
|
124
124
|
case "selected-products":
|
|
125
|
-
return
|
|
125
|
+
return l.slice(0, i);
|
|
126
126
|
case "all-products":
|
|
127
127
|
case "excluded-products": {
|
|
128
128
|
const d = w({ country: t, language: a });
|
|
129
|
-
let
|
|
130
|
-
for (;
|
|
131
|
-
const
|
|
129
|
+
let c = [], p = null;
|
|
130
|
+
for (; c.length < i; ) {
|
|
131
|
+
const f = Math.min(i - c.length, 250), h = await e.query(
|
|
132
132
|
`
|
|
133
133
|
query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
|
|
134
134
|
products(first: $limit, after: $cursor) {
|
|
@@ -144,22 +144,22 @@ const q = (e, t) => {
|
|
|
144
144
|
`,
|
|
145
145
|
{
|
|
146
146
|
variables: {
|
|
147
|
-
limit:
|
|
147
|
+
limit: f,
|
|
148
148
|
cursor: p
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
);
|
|
152
|
-
if (
|
|
153
|
-
p =
|
|
152
|
+
if (c.push(...h.products.nodes.map((y) => y.id)), !h.products.pageInfo.hasNextPage) break;
|
|
153
|
+
p = h.products.pageInfo.endCursor;
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
155
|
+
if (n === "excluded-products") {
|
|
156
|
+
const f = new Set(s);
|
|
157
|
+
c = c.filter((h) => !f.has(h));
|
|
158
158
|
}
|
|
159
|
-
return
|
|
159
|
+
return c;
|
|
160
160
|
}
|
|
161
161
|
case "selected-collections": {
|
|
162
|
-
const d = w({ country: t, language: a }),
|
|
162
|
+
const d = w({ country: t, language: a }), c = (await e.query(
|
|
163
163
|
`
|
|
164
164
|
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
|
|
165
165
|
nodes(ids: $collectionGIDs) {
|
|
@@ -176,16 +176,16 @@ const q = (e, t) => {
|
|
|
176
176
|
{
|
|
177
177
|
variables: {
|
|
178
178
|
collectionGIDs: u,
|
|
179
|
-
limit: Math.min(
|
|
179
|
+
limit: Math.min(i, 250)
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
)).nodes.filter((p) => p !== null).flatMap(
|
|
183
|
-
(p) => p.products.nodes.map((
|
|
183
|
+
(p) => p.products.nodes.map((f) => f.id)
|
|
184
184
|
);
|
|
185
|
-
return Array.from(new Set(
|
|
185
|
+
return Array.from(new Set(c)).slice(0, i);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
},
|
|
188
|
+
}, j = `
|
|
189
189
|
id
|
|
190
190
|
availableForSale
|
|
191
191
|
price {
|
|
@@ -200,7 +200,7 @@ const q = (e, t) => {
|
|
|
200
200
|
}
|
|
201
201
|
image {
|
|
202
202
|
id
|
|
203
|
-
url(transform:
|
|
203
|
+
url(transform: $variantImageTransform)
|
|
204
204
|
}
|
|
205
205
|
unitPriceMeasurement {
|
|
206
206
|
quantityUnit
|
|
@@ -231,17 +231,18 @@ const q = (e, t) => {
|
|
|
231
231
|
`, S = async (e, {
|
|
232
232
|
country: t,
|
|
233
233
|
language: a,
|
|
234
|
-
productIds:
|
|
235
|
-
includeSellingPlans:
|
|
236
|
-
includeAvailableQuantity:
|
|
234
|
+
productIds: n,
|
|
235
|
+
includeSellingPlans: s = !0,
|
|
236
|
+
includeAvailableQuantity: l = !0,
|
|
237
237
|
useExternalMetafieldNamespace: u = !1,
|
|
238
|
-
batchSize:
|
|
239
|
-
onBatchError: d
|
|
238
|
+
batchSize: i = 250,
|
|
239
|
+
onBatchError: d,
|
|
240
|
+
variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
|
|
240
241
|
}) => {
|
|
241
|
-
if (!
|
|
242
|
+
if (!n.length)
|
|
242
243
|
return [];
|
|
243
|
-
const
|
|
244
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String
|
|
244
|
+
const p = n.map((m) => typeof m == "string" && m.startsWith("gid://") ? m : `gid://shopify/Product/${m}`), f = w({ country: t, language: a }), h = `
|
|
245
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${f} {
|
|
245
246
|
shop {
|
|
246
247
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
247
248
|
value
|
|
@@ -275,7 +276,7 @@ const q = (e, t) => {
|
|
|
275
276
|
}
|
|
276
277
|
variants(first: 250) {
|
|
277
278
|
nodes {
|
|
278
|
-
${
|
|
279
|
+
${j}
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
collections(first: 50) {
|
|
@@ -327,84 +328,90 @@ const q = (e, t) => {
|
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
|
-
`,
|
|
331
|
-
for (let
|
|
332
|
-
|
|
333
|
-
let
|
|
334
|
-
const
|
|
335
|
-
const
|
|
331
|
+
`, y = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = [], r = Math.min(i, 250);
|
|
332
|
+
for (let m = 0; m < p.length; m += r)
|
|
333
|
+
v.push(p.slice(m, m + r));
|
|
334
|
+
let o = 1;
|
|
335
|
+
const g = async (m) => {
|
|
336
|
+
const b = await e.query(h, {
|
|
336
337
|
variables: {
|
|
337
|
-
productGIDs:
|
|
338
|
-
includeSellingPlans:
|
|
339
|
-
includeAvailableQuantity:
|
|
340
|
-
metafieldNamespace:
|
|
338
|
+
productGIDs: m,
|
|
339
|
+
includeSellingPlans: s,
|
|
340
|
+
includeAvailableQuantity: l,
|
|
341
|
+
metafieldNamespace: y,
|
|
342
|
+
variantImageTransform: c
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
|
-
return
|
|
345
|
+
return b.shop.currencyRateConstant && (o = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
|
|
344
346
|
};
|
|
345
|
-
let
|
|
347
|
+
let _;
|
|
346
348
|
if (d) {
|
|
347
|
-
const
|
|
348
|
-
for (const
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
const m = await Promise.allSettled(v.map(g));
|
|
350
|
+
for (const b of m)
|
|
351
|
+
b.status === "rejected" && d(
|
|
352
|
+
b.reason instanceof Error ? b.reason : new Error(String(b.reason))
|
|
351
353
|
);
|
|
352
|
-
|
|
353
|
-
(
|
|
354
|
-
).flatMap((
|
|
354
|
+
_ = m.filter(
|
|
355
|
+
(b) => b.status === "fulfilled"
|
|
356
|
+
).flatMap((b) => b.value.nodes);
|
|
355
357
|
} else
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
+
_ = (await Promise.all(v.map(g))).flatMap((m) => m.nodes);
|
|
359
|
+
const I = _.filter((m) => m != null);
|
|
358
360
|
if (d) {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
const
|
|
361
|
+
const m = await Promise.allSettled(
|
|
362
|
+
I.map(async (P) => {
|
|
363
|
+
const B = await x(
|
|
362
364
|
e,
|
|
363
|
-
I,
|
|
364
|
-
{ includeSellingPlans: l, includeAvailableQuantity: o },
|
|
365
|
-
p
|
|
366
|
-
);
|
|
367
|
-
return x(
|
|
368
365
|
P,
|
|
366
|
+
{
|
|
367
|
+
includeSellingPlans: s,
|
|
368
|
+
includeAvailableQuantity: l,
|
|
369
|
+
variantImageTransform: c
|
|
370
|
+
},
|
|
371
|
+
f
|
|
372
|
+
);
|
|
373
|
+
return A(
|
|
374
|
+
B,
|
|
369
375
|
e.shopifyDomain,
|
|
370
|
-
|
|
376
|
+
o
|
|
371
377
|
);
|
|
372
378
|
})
|
|
373
|
-
),
|
|
374
|
-
for (const
|
|
375
|
-
|
|
376
|
-
|
|
379
|
+
), b = [];
|
|
380
|
+
for (const P of m)
|
|
381
|
+
P.status === "fulfilled" ? b.push(P.value) : d(
|
|
382
|
+
P.reason instanceof Error ? P.reason : new Error(String(P.reason))
|
|
377
383
|
);
|
|
378
|
-
return
|
|
384
|
+
return b;
|
|
379
385
|
}
|
|
380
386
|
return (await Promise.all(
|
|
381
|
-
|
|
382
|
-
(
|
|
387
|
+
I.map(
|
|
388
|
+
(m) => x(
|
|
383
389
|
e,
|
|
384
|
-
|
|
390
|
+
m,
|
|
385
391
|
{
|
|
386
|
-
includeSellingPlans:
|
|
387
|
-
includeAvailableQuantity:
|
|
392
|
+
includeSellingPlans: s,
|
|
393
|
+
includeAvailableQuantity: l,
|
|
394
|
+
variantImageTransform: c
|
|
388
395
|
},
|
|
389
|
-
|
|
396
|
+
f
|
|
390
397
|
)
|
|
391
398
|
)
|
|
392
399
|
)).map(
|
|
393
|
-
(
|
|
400
|
+
(m) => A(m, e.shopifyDomain, o)
|
|
394
401
|
);
|
|
395
|
-
},
|
|
402
|
+
}, x = async (e, t, a, n = "") => {
|
|
396
403
|
if (t.variants.nodes.length < 250)
|
|
397
404
|
return t;
|
|
398
|
-
const
|
|
399
|
-
let
|
|
400
|
-
for (;
|
|
401
|
-
const
|
|
405
|
+
const s = /* @__PURE__ */ new Set(), l = [], u = [], i = async (d) => {
|
|
406
|
+
let c = !0, p = null;
|
|
407
|
+
for (; c; ) {
|
|
408
|
+
const f = await e.query(
|
|
402
409
|
`
|
|
403
|
-
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean
|
|
410
|
+
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${n} {
|
|
404
411
|
product(id: $productGID) {
|
|
405
412
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
406
413
|
nodes {
|
|
407
|
-
${
|
|
414
|
+
${j}
|
|
408
415
|
}
|
|
409
416
|
pageInfo {
|
|
410
417
|
endCursor
|
|
@@ -422,110 +429,110 @@ const q = (e, t) => {
|
|
|
422
429
|
...a
|
|
423
430
|
}
|
|
424
431
|
}
|
|
425
|
-
), { nodes:
|
|
426
|
-
for (const v of
|
|
427
|
-
if (
|
|
428
|
-
|
|
432
|
+
), { nodes: h, pageInfo: y } = f.product.variants;
|
|
433
|
+
for (const v of h) {
|
|
434
|
+
if (s.has(v.id)) {
|
|
435
|
+
c = !1;
|
|
429
436
|
break;
|
|
430
437
|
}
|
|
431
|
-
|
|
438
|
+
s.add(v.id), d ? u.push(v) : l.push(v);
|
|
432
439
|
}
|
|
433
|
-
|
|
440
|
+
y.hasNextPage || (c = !1), p = y.endCursor;
|
|
434
441
|
}
|
|
435
442
|
};
|
|
436
443
|
return await Promise.all([
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
]), t.variants.nodes = [...
|
|
440
|
-
},
|
|
441
|
-
var
|
|
442
|
-
const
|
|
443
|
-
({ unitPriceMeasurement:
|
|
444
|
-
var
|
|
444
|
+
i(!1),
|
|
445
|
+
i(!0)
|
|
446
|
+
]), t.variants.nodes = [...l, ...u.reverse()], t;
|
|
447
|
+
}, A = (e, t, a) => {
|
|
448
|
+
var c, p, f, h, y, v;
|
|
449
|
+
const n = e.variants.nodes.map(
|
|
450
|
+
({ unitPriceMeasurement: r, ...o }) => {
|
|
451
|
+
var g, _;
|
|
445
452
|
return {
|
|
446
|
-
id: Number(
|
|
447
|
-
availableForSale:
|
|
448
|
-
price: Math.round(Number(
|
|
449
|
-
compareAtPrice:
|
|
450
|
-
options:
|
|
451
|
-
imageId:
|
|
452
|
-
image: ((
|
|
453
|
-
sellingPlans: ((_ =
|
|
454
|
-
id: Number(
|
|
455
|
-
price:
|
|
456
|
-
compareAtPrice:
|
|
457
|
-
Number(
|
|
458
|
-
) : Math.round(Number(
|
|
459
|
-
perDeliveryPrice:
|
|
460
|
-
Number(
|
|
461
|
-
) : Math.round(Number(
|
|
453
|
+
id: Number(o.id.split("/").pop()),
|
|
454
|
+
availableForSale: o.availableForSale,
|
|
455
|
+
price: Math.round(Number(o.price.amount) * 100),
|
|
456
|
+
compareAtPrice: o.compareAtPrice ? Math.round(Number(o.compareAtPrice.amount) * 100) : null,
|
|
457
|
+
options: o.selectedOptions.map((I) => I.value),
|
|
458
|
+
imageId: o.image ? Number(o.image.id.split("/").pop()) : null,
|
|
459
|
+
image: ((g = o.image) == null ? void 0 : g.url) || null,
|
|
460
|
+
sellingPlans: ((_ = o.sellingPlanAllocations) == null ? void 0 : _.nodes.map((I) => ({
|
|
461
|
+
id: Number(I.sellingPlan.id.split("/").pop()),
|
|
462
|
+
price: I.priceAdjustments.length > 0 ? Math.round(Number(I.priceAdjustments[0].price.amount) * 100) : Math.round(Number(o.price.amount) * 100),
|
|
463
|
+
compareAtPrice: I.priceAdjustments.length > 0 ? Math.round(
|
|
464
|
+
Number(I.priceAdjustments[0].compareAtPrice.amount) * 100
|
|
465
|
+
) : Math.round(Number(o.price.amount) * 100),
|
|
466
|
+
perDeliveryPrice: I.priceAdjustments.length > 0 ? Math.round(
|
|
467
|
+
Number(I.priceAdjustments[0].perDeliveryPrice.amount) * 100
|
|
468
|
+
) : Math.round(Number(o.price.amount) * 100)
|
|
462
469
|
}))) || [],
|
|
463
470
|
inventoryManagement: null,
|
|
464
471
|
// Storefront API does not return inventory management, only available in liquid
|
|
465
472
|
inventoryPolicy: null,
|
|
466
473
|
// Storefront API does not return inventory policy, only available in liquid
|
|
467
|
-
inventoryQuantity:
|
|
468
|
-
unitPriceMeasurement:
|
|
469
|
-
quantityValue:
|
|
470
|
-
quantityUnit:
|
|
471
|
-
referenceValue:
|
|
472
|
-
referenceUnit:
|
|
474
|
+
inventoryQuantity: o.quantityAvailable ?? null,
|
|
475
|
+
unitPriceMeasurement: r != null && r.quantityUnit && (r != null && r.referenceUnit) ? {
|
|
476
|
+
quantityValue: r.quantityValue,
|
|
477
|
+
quantityUnit: r.quantityUnit.toLowerCase(),
|
|
478
|
+
referenceValue: r.referenceValue,
|
|
479
|
+
referenceUnit: r.referenceUnit.toLowerCase()
|
|
473
480
|
} : null
|
|
474
481
|
};
|
|
475
482
|
}
|
|
476
|
-
),
|
|
477
|
-
const
|
|
478
|
-
var
|
|
483
|
+
), s = e.options.map((r, o) => {
|
|
484
|
+
const g = r.optionValues.map((_) => {
|
|
485
|
+
var I, m, b, P;
|
|
479
486
|
return {
|
|
480
487
|
id: Number(_.id.split("/").pop()),
|
|
481
488
|
defaultName: _.name,
|
|
482
489
|
name: _.name,
|
|
483
490
|
swatch: {
|
|
484
|
-
color: ((
|
|
485
|
-
image: ((P = (
|
|
491
|
+
color: ((I = _.swatch) == null ? void 0 : I.color) || null,
|
|
492
|
+
image: ((P = (b = (m = _.swatch) == null ? void 0 : m.image) == null ? void 0 : b.previewImage) == null ? void 0 : P.url) || null
|
|
486
493
|
}
|
|
487
494
|
};
|
|
488
495
|
});
|
|
489
496
|
return {
|
|
490
|
-
defaultName:
|
|
491
|
-
name:
|
|
492
|
-
position:
|
|
493
|
-
optionValues:
|
|
497
|
+
defaultName: r.name,
|
|
498
|
+
name: r.name,
|
|
499
|
+
position: o + 1,
|
|
500
|
+
optionValues: Q(g, o, n)
|
|
494
501
|
};
|
|
495
|
-
}),
|
|
496
|
-
const
|
|
497
|
-
if (!
|
|
502
|
+
}), l = (r) => {
|
|
503
|
+
const o = r.priceAdjustments[0];
|
|
504
|
+
if (!o)
|
|
498
505
|
return null;
|
|
499
|
-
const
|
|
500
|
-
switch (
|
|
506
|
+
const g = o.adjustmentValue;
|
|
507
|
+
switch (g.__typename) {
|
|
501
508
|
case "SellingPlanPercentagePriceAdjustment":
|
|
502
509
|
return {
|
|
503
510
|
type: "percentage",
|
|
504
|
-
value:
|
|
511
|
+
value: g.adjustmentPercentage
|
|
505
512
|
};
|
|
506
513
|
case "SellingPlanFixedAmountPriceAdjustment":
|
|
507
514
|
return {
|
|
508
515
|
type: "fixed_amount",
|
|
509
|
-
value: u(
|
|
516
|
+
value: u(g.adjustmentAmount.amount)
|
|
510
517
|
};
|
|
511
518
|
case "SellingPlanFixedPriceAdjustment":
|
|
512
519
|
return {
|
|
513
520
|
type: "price",
|
|
514
|
-
value: u(
|
|
521
|
+
value: u(g.price.amount)
|
|
515
522
|
};
|
|
516
523
|
default:
|
|
517
524
|
throw new Error(
|
|
518
|
-
`Unknown price adjustment type: ${
|
|
525
|
+
`Unknown price adjustment type: ${g.__typename}`
|
|
519
526
|
);
|
|
520
527
|
}
|
|
521
|
-
}, u = (
|
|
522
|
-
(
|
|
523
|
-
id: Number(
|
|
524
|
-
name:
|
|
525
|
-
priceAdjustment: o
|
|
528
|
+
}, u = (r) => a === 1 ? Number(r) * 100 : Math.round(Number(r) * 100 * a), i = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
|
|
529
|
+
(r) => r.sellingPlans.nodes.map((o) => ({
|
|
530
|
+
id: Number(o.id.split("/").pop()),
|
|
531
|
+
name: o.name,
|
|
532
|
+
priceAdjustment: l(o)
|
|
526
533
|
}))
|
|
527
534
|
)) || [], d = e.variants.nodes.some(
|
|
528
|
-
(
|
|
535
|
+
(r) => r.requiresComponents
|
|
529
536
|
);
|
|
530
537
|
return {
|
|
531
538
|
id: Number(e.id.split("/").pop()),
|
|
@@ -536,42 +543,42 @@ const q = (e, t) => {
|
|
|
536
543
|
title: e.title,
|
|
537
544
|
image: ((p = e.featuredImage) == null ? void 0 : p.url) || null,
|
|
538
545
|
collectionIds: e.collections.nodes.map(
|
|
539
|
-
(
|
|
546
|
+
(r) => Number(r.id.split("/").pop())
|
|
540
547
|
),
|
|
541
|
-
options:
|
|
548
|
+
options: s,
|
|
542
549
|
selectedVariantId: Number(
|
|
543
550
|
e.variants.nodes[0].id.split("/").pop()
|
|
544
551
|
),
|
|
545
|
-
variants:
|
|
552
|
+
variants: n,
|
|
546
553
|
requiresSellingPlan: e.requiresSellingPlan,
|
|
547
|
-
sellingPlans:
|
|
554
|
+
sellingPlans: i,
|
|
548
555
|
isNativeBundle: d,
|
|
549
556
|
metafields: {
|
|
550
|
-
text: ((
|
|
551
|
-
text2: ((
|
|
552
|
-
text3: ((
|
|
557
|
+
text: ((f = e.metafield) == null ? void 0 : f.value) || null,
|
|
558
|
+
text2: ((h = e.metafield2) == null ? void 0 : h.value) || null,
|
|
559
|
+
text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
|
|
553
560
|
text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
|
|
554
561
|
}
|
|
555
562
|
};
|
|
556
|
-
},
|
|
557
|
-
(
|
|
558
|
-
).length > 0),
|
|
563
|
+
}, Q = (e, t, a) => e.filter((n) => a.filter(
|
|
564
|
+
(s) => s.options[t] === n.name
|
|
565
|
+
).length > 0), G = "app--2935586817", H = async (e, {
|
|
559
566
|
language: t,
|
|
560
567
|
country: a,
|
|
561
|
-
useExternalMetafieldNamespace:
|
|
568
|
+
useExternalMetafieldNamespace: n
|
|
562
569
|
}) => {
|
|
563
|
-
const
|
|
570
|
+
const s = `${G}--kaching_bundles`, l = G, u = w({ country: a }), {
|
|
564
571
|
localization: {
|
|
565
572
|
country: {
|
|
566
|
-
currency: { isoCode:
|
|
573
|
+
currency: { isoCode: i }
|
|
567
574
|
}
|
|
568
575
|
},
|
|
569
576
|
shop: {
|
|
570
577
|
moneyFormat: d,
|
|
571
|
-
paymentSettings: { currencyCode:
|
|
578
|
+
paymentSettings: { currencyCode: c },
|
|
572
579
|
currencyRateConstant: p,
|
|
573
|
-
primaryDomain:
|
|
574
|
-
settingsMetafield:
|
|
580
|
+
primaryDomain: f,
|
|
581
|
+
settingsMetafield: h
|
|
575
582
|
}
|
|
576
583
|
} = await e.query(
|
|
577
584
|
`
|
|
@@ -602,30 +609,30 @@ const q = (e, t) => {
|
|
|
602
609
|
`,
|
|
603
610
|
{
|
|
604
611
|
variables: {
|
|
605
|
-
metafieldNamespace:
|
|
606
|
-
settingsNamespace:
|
|
612
|
+
metafieldNamespace: s,
|
|
613
|
+
settingsNamespace: l
|
|
607
614
|
}
|
|
608
615
|
}
|
|
609
|
-
),
|
|
616
|
+
), y = i === c ? d : E(i, { language: t, country: a }), v = p ? J(p.value) : 1, r = h ? JSON.parse(h.value) : null, o = (r == null ? void 0 : r.feature_flags) ?? {}, g = (r == null ? void 0 : r.custom_selectors) ?? {};
|
|
610
617
|
return {
|
|
611
|
-
shopifyDomain:
|
|
612
|
-
moneyFormat:
|
|
618
|
+
shopifyDomain: f.host,
|
|
619
|
+
moneyFormat: y,
|
|
613
620
|
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
614
621
|
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
615
622
|
country: a ?? "US",
|
|
616
623
|
currencyRate: v,
|
|
617
624
|
marketId: 0,
|
|
618
625
|
productId: null,
|
|
619
|
-
storefrontAccessToken: (
|
|
620
|
-
includeSellingPlans: (
|
|
621
|
-
includeAvailableQuantity: (
|
|
622
|
-
customApiHost: (
|
|
623
|
-
keepQuantityInput: (
|
|
624
|
-
ignoreDeselect: (
|
|
625
|
-
ignoreUnitPrice: (
|
|
626
|
-
requireCustomerLogin: (
|
|
627
|
-
abTestsRunning: (
|
|
628
|
-
webPixel: (
|
|
626
|
+
storefrontAccessToken: (r == null ? void 0 : r.storefront_access_token) ?? null,
|
|
627
|
+
includeSellingPlans: (r == null ? void 0 : r.include_selling_plans) ?? !1,
|
|
628
|
+
includeAvailableQuantity: (r == null ? void 0 : r.include_available_quantity) ?? !1,
|
|
629
|
+
customApiHost: (r == null ? void 0 : r.custom_api_host) ?? null,
|
|
630
|
+
keepQuantityInput: (r == null ? void 0 : r.keep_quantity_input) ?? !1,
|
|
631
|
+
ignoreDeselect: (r == null ? void 0 : r.ignore_deselect) ?? !1,
|
|
632
|
+
ignoreUnitPrice: (r == null ? void 0 : r.ignore_unit_price) ?? !1,
|
|
633
|
+
requireCustomerLogin: (r == null ? void 0 : r.require_customer_login) ?? !1,
|
|
634
|
+
abTestsRunning: (r == null ? void 0 : r.ab_tests_running) ?? !1,
|
|
635
|
+
webPixel: (r == null ? void 0 : r.web_pixel) ?? !1,
|
|
629
636
|
b2bCustomer: !1,
|
|
630
637
|
isLoggedIn: !1,
|
|
631
638
|
preview: !1,
|
|
@@ -657,44 +664,56 @@ const q = (e, t) => {
|
|
|
657
664
|
"system.numbers_only": "Only numbers are allowed."
|
|
658
665
|
},
|
|
659
666
|
customSelectors: {
|
|
660
|
-
quantity:
|
|
661
|
-
addToCartButton:
|
|
662
|
-
variantPicker:
|
|
663
|
-
price:
|
|
664
|
-
priceCompare:
|
|
667
|
+
quantity: g.quantity ?? null,
|
|
668
|
+
addToCartButton: g.add_to_cart_button ?? null,
|
|
669
|
+
variantPicker: g.variant_picker ?? null,
|
|
670
|
+
price: g.price ?? null,
|
|
671
|
+
priceCompare: g.price_compare ?? null
|
|
665
672
|
},
|
|
666
|
-
shopCustomStyles: (
|
|
667
|
-
featureFlags:
|
|
668
|
-
brandColors: (
|
|
673
|
+
shopCustomStyles: (r == null ? void 0 : r.shop_custom_styles) ?? "",
|
|
674
|
+
featureFlags: o,
|
|
675
|
+
brandColors: (r == null ? void 0 : r.brand_colors) ?? null
|
|
669
676
|
};
|
|
670
|
-
},
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
}, J = (e) => JSON.parse(e).amount / 1e6, z = async (e, t, a = 200) => {
|
|
678
|
+
const n = [
|
|
679
|
+
...new Set(
|
|
680
|
+
t.filter(Boolean).filter((l) => !l.startsWith("placeholder"))
|
|
681
|
+
)
|
|
682
|
+
];
|
|
683
|
+
if (n.length === 0) return [];
|
|
684
|
+
const s = [];
|
|
685
|
+
for (let l = 0; l < n.length; l += 250)
|
|
686
|
+
s.push(n.slice(l, l + 250));
|
|
687
|
+
return (await Promise.all(
|
|
688
|
+
s.map(
|
|
689
|
+
(l) => e.query(
|
|
690
|
+
`
|
|
691
|
+
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
692
|
+
nodes(ids: $mediaImageIds) {
|
|
693
|
+
... on MediaImage {
|
|
694
|
+
id
|
|
695
|
+
image {
|
|
696
|
+
url(transform: { maxWidth: $size, maxHeight: $size })
|
|
697
|
+
}
|
|
698
|
+
}
|
|
678
699
|
}
|
|
679
700
|
}
|
|
701
|
+
`,
|
|
702
|
+
{
|
|
703
|
+
variables: {
|
|
704
|
+
mediaImageIds: l,
|
|
705
|
+
size: a
|
|
706
|
+
}
|
|
680
707
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
{
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
}
|
|
689
|
-
)).nodes.filter(Boolean).map((r) => ({
|
|
690
|
-
gid: r.id,
|
|
691
|
-
url: r.image.url
|
|
692
|
-
})));
|
|
708
|
+
)
|
|
709
|
+
)
|
|
710
|
+
)).flatMap((l) => l.nodes).filter(Boolean).map((l) => ({
|
|
711
|
+
gid: l.id,
|
|
712
|
+
url: l.image.url
|
|
713
|
+
}));
|
|
714
|
+
};
|
|
693
715
|
var $ = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))($ || {});
|
|
694
|
-
const
|
|
695
|
-
...J(e),
|
|
696
|
-
...z(e),
|
|
697
|
-
...W(e),
|
|
716
|
+
const W = (e) => [
|
|
698
717
|
...X(e),
|
|
699
718
|
...K(e),
|
|
700
719
|
...Y(e),
|
|
@@ -703,86 +722,123 @@ const H = (e) => [
|
|
|
703
722
|
...te(e),
|
|
704
723
|
...ae(e),
|
|
705
724
|
...se(e),
|
|
725
|
+
...re(e),
|
|
706
726
|
...ne(e),
|
|
707
|
-
...
|
|
708
|
-
|
|
727
|
+
...ie(e),
|
|
728
|
+
...le(e),
|
|
729
|
+
...oe(e)
|
|
730
|
+
].filter((t) => t != null && !t.includes("placeholder")), X = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), K = (e) => e.dealBars.flatMap(
|
|
709
731
|
(t) => t.dealBarType === $.Bundle ? t.bundleProducts.map(
|
|
710
732
|
(a) => a.mediaImageGID
|
|
711
733
|
) : []
|
|
712
|
-
).filter((t) => t != null),
|
|
734
|
+
).filter((t) => t != null), Y = (e) => e.dealBars.map(
|
|
713
735
|
({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
714
|
-
).reduce((t, a) => t.concat(a), []).filter((t) => t != null),
|
|
736
|
+
).reduce((t, a) => t.concat(a), []).filter((t) => t != null), Z = (e) => e.dealBars.flatMap(
|
|
715
737
|
({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
716
|
-
).filter((t) => t != null),
|
|
717
|
-
const
|
|
718
|
-
return [...t, ...
|
|
719
|
-
}, []) : [],
|
|
738
|
+
).filter((t) => t != null), ee = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), te = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
|
|
739
|
+
const n = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
|
|
740
|
+
return [...t, ...n];
|
|
741
|
+
}, []) : [], ae = (e) => {
|
|
720
742
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
721
743
|
return [];
|
|
722
744
|
const t = e.collectionBreaks.mediaImageGID;
|
|
723
745
|
return t ? [t] : [];
|
|
724
|
-
},
|
|
725
|
-
var t, a,
|
|
746
|
+
}, se = (e) => {
|
|
747
|
+
var t, a, n;
|
|
726
748
|
return e.progressiveGifts ? [
|
|
727
|
-
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((
|
|
749
|
+
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
|
|
728
750
|
(a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
|
|
729
|
-
(
|
|
730
|
-
].filter((
|
|
731
|
-
},
|
|
751
|
+
(n = e.progressiveGifts.dealBarStyle) == null ? void 0 : n.lockedMediaImageGID
|
|
752
|
+
].filter((s) => s != null) : [];
|
|
753
|
+
}, re = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ne = (e) => e.dealBars.map((t) => {
|
|
732
754
|
var a;
|
|
733
755
|
return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
|
|
734
|
-
}).filter((t) => t != null),
|
|
735
|
-
var
|
|
736
|
-
const t = e.dealBars.map((
|
|
756
|
+
}).filter((t) => t != null), ie = (e) => {
|
|
757
|
+
var n, s;
|
|
758
|
+
const t = e.dealBars.map((l) => {
|
|
737
759
|
var u;
|
|
738
|
-
return (u =
|
|
739
|
-
}).filter((
|
|
760
|
+
return (u = l.highlights) == null ? void 0 : u.customIconGID;
|
|
761
|
+
}).filter((l) => l != null), a = (s = (n = e.subscriptions) == null ? void 0 : n.highlights) == null ? void 0 : s.customIconGID;
|
|
740
762
|
return a ? [...t, a] : t;
|
|
741
|
-
},
|
|
763
|
+
}, le = (e) => (e.badges || []).flatMap(
|
|
742
764
|
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
743
|
-
),
|
|
765
|
+
), oe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ce = (e) => {
|
|
744
766
|
const t = [
|
|
745
|
-
...ie(e),
|
|
746
|
-
...oe(e),
|
|
747
|
-
...ce(e),
|
|
748
767
|
...ue(e),
|
|
749
768
|
...de(e),
|
|
750
769
|
...me(e),
|
|
751
770
|
...pe(e),
|
|
752
|
-
...fe(e)
|
|
771
|
+
...fe(e),
|
|
772
|
+
...ye(e),
|
|
773
|
+
...ge(e),
|
|
774
|
+
...he(e)
|
|
753
775
|
];
|
|
754
776
|
return Array.from(new Set(t.filter((a) => a != null)));
|
|
755
|
-
},
|
|
777
|
+
}, ue = (e) => e.dealBars.flatMap(
|
|
756
778
|
({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
|
|
757
|
-
).filter((t) => t != null),
|
|
779
|
+
).filter((t) => t != null), de = (e) => e.dealBars.flatMap(
|
|
758
780
|
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
759
|
-
(a) => a.products ? a.products.map((
|
|
781
|
+
(a) => a.products ? a.products.map((n) => n.id) : []
|
|
760
782
|
) : []
|
|
761
|
-
).filter((t) => t != null),
|
|
783
|
+
).filter((t) => t != null), me = (e) => {
|
|
762
784
|
var t;
|
|
763
785
|
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
|
|
764
|
-
},
|
|
786
|
+
}, pe = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), fe = (e) => e.dealBars.filter((t) => t.dealBarType === $.Bundle).flatMap(
|
|
765
787
|
({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
|
|
766
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
788
|
+
).filter((t) => t != null).filter((t) => t !== "default"), ye = (e) => e.dealBars.filter((t) => t.dealBarType === $.MixAndMatch).flatMap(
|
|
767
789
|
({ bundleProducts: t }) => t ? t.flatMap((a) => {
|
|
768
|
-
var
|
|
790
|
+
var n;
|
|
769
791
|
return [
|
|
770
792
|
a.productGID,
|
|
771
|
-
...((
|
|
793
|
+
...((n = a.selectedProducts) == null ? void 0 : n.map((s) => s.id)) ?? []
|
|
772
794
|
];
|
|
773
795
|
}) : []
|
|
774
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
775
|
-
class
|
|
796
|
+
).filter((t) => t != null).filter((t) => t !== "default"), ge = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), he = (e) => e.dealBars.filter((t) => t.dealBarType === $.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
|
|
797
|
+
class q extends Error {
|
|
798
|
+
constructor({
|
|
799
|
+
status: t,
|
|
800
|
+
operationName: a,
|
|
801
|
+
graphqlErrors: n
|
|
802
|
+
}) {
|
|
803
|
+
const s = n.length ? `: ${n.join("; ")}` : "";
|
|
804
|
+
super(
|
|
805
|
+
`Storefront API ${a ?? "query"} failed (HTTP ${t})${s}`
|
|
806
|
+
), this.name = "StorefrontApiError", this.status = t, this.operationName = a, this.graphqlErrors = n;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const be = async (e, t) => {
|
|
810
|
+
const a = await e.text();
|
|
811
|
+
if (!a)
|
|
812
|
+
throw new Error("Empty graphql response");
|
|
813
|
+
let n;
|
|
814
|
+
try {
|
|
815
|
+
n = JSON.parse(a);
|
|
816
|
+
} catch (s) {
|
|
817
|
+
throw e.ok ? s : new q({
|
|
818
|
+
status: e.status,
|
|
819
|
+
operationName: t,
|
|
820
|
+
graphqlErrors: []
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
if (!e.ok || n.data === null || n.data === void 0)
|
|
824
|
+
throw new q({
|
|
825
|
+
status: e.status,
|
|
826
|
+
operationName: t,
|
|
827
|
+
graphqlErrors: (n.errors ?? []).map(({ message: s }) => s).filter(Boolean)
|
|
828
|
+
});
|
|
829
|
+
return n.data;
|
|
830
|
+
};
|
|
831
|
+
class ve {
|
|
776
832
|
constructor(t, a) {
|
|
777
833
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
|
|
778
834
|
}
|
|
779
835
|
async query(t, a) {
|
|
780
|
-
var
|
|
781
|
-
const
|
|
782
|
-
let
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const u = await
|
|
836
|
+
var i;
|
|
837
|
+
const n = (a == null ? void 0 : a.variables) ?? {};
|
|
838
|
+
let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
839
|
+
const l = (i = t.match(/query\s+(\w+)/)) == null ? void 0 : i[1];
|
|
840
|
+
l && (s += `?operation_name=${l}`);
|
|
841
|
+
const u = await fetch(s, {
|
|
786
842
|
method: "POST",
|
|
787
843
|
headers: {
|
|
788
844
|
"Content-Type": "application/json",
|
|
@@ -790,157 +846,190 @@ class ye {
|
|
|
790
846
|
},
|
|
791
847
|
body: JSON.stringify({
|
|
792
848
|
query: t,
|
|
793
|
-
variables:
|
|
849
|
+
variables: n
|
|
794
850
|
})
|
|
795
|
-
})
|
|
796
|
-
|
|
797
|
-
throw new Error("Empty graphql response");
|
|
798
|
-
return JSON.parse(u).data;
|
|
851
|
+
});
|
|
852
|
+
return be(u, l);
|
|
799
853
|
}
|
|
800
854
|
}
|
|
801
|
-
const
|
|
802
|
-
const
|
|
803
|
-
if (!t.collectionBreaksEnabled || !
|
|
804
|
-
let
|
|
805
|
-
|
|
855
|
+
const Ie = async (e, t, { country: a, language: n }) => {
|
|
856
|
+
const s = t.collectionBreaks;
|
|
857
|
+
if (!t.collectionBreaksEnabled || !s) return;
|
|
858
|
+
let l;
|
|
859
|
+
s.visibility === "deal-products" ? l = await k(e, {
|
|
806
860
|
country: a,
|
|
807
|
-
language:
|
|
861
|
+
language: n,
|
|
808
862
|
blockVisibility: t.blockVisibility,
|
|
809
863
|
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
810
|
-
(
|
|
864
|
+
(i) => `gid://shopify/Product/${i}`
|
|
811
865
|
),
|
|
812
866
|
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
813
|
-
(
|
|
867
|
+
(i) => `gid://shopify/Product/${i}`
|
|
814
868
|
),
|
|
815
869
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
816
|
-
(
|
|
870
|
+
(i) => `gid://shopify/Collection/${i}`
|
|
817
871
|
)
|
|
818
|
-
}) :
|
|
872
|
+
}) : l = await k(e, {
|
|
819
873
|
country: a,
|
|
820
|
-
language:
|
|
821
|
-
blockVisibility:
|
|
822
|
-
excludedProductGIDs: (
|
|
823
|
-
({ id:
|
|
874
|
+
language: n,
|
|
875
|
+
blockVisibility: s.visibility,
|
|
876
|
+
excludedProductGIDs: (s.excludedProducts || []).map(
|
|
877
|
+
({ id: i }) => i
|
|
824
878
|
),
|
|
825
|
-
selectedProductGIDs: (
|
|
826
|
-
({ id:
|
|
879
|
+
selectedProductGIDs: (s.selectedProducts || []).map(
|
|
880
|
+
({ id: i }) => i
|
|
827
881
|
),
|
|
828
|
-
selectedCollectionGIDs: (
|
|
829
|
-
({ id:
|
|
882
|
+
selectedCollectionGIDs: (s.selectedCollections || []).map(
|
|
883
|
+
({ id: i }) => i
|
|
830
884
|
)
|
|
831
885
|
});
|
|
832
886
|
let u = await S(e, {
|
|
833
887
|
country: a,
|
|
834
|
-
language:
|
|
835
|
-
productIds:
|
|
888
|
+
language: n,
|
|
889
|
+
productIds: l.map((i) => Number(i.split("/").pop())),
|
|
836
890
|
useExternalMetafieldNamespace: !0
|
|
837
891
|
});
|
|
838
892
|
return u = u.filter(
|
|
839
|
-
(
|
|
893
|
+
(i) => i.availableForSale
|
|
840
894
|
), u;
|
|
841
|
-
},
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
895
|
+
}, _e = ({
|
|
896
|
+
language: e,
|
|
897
|
+
dealBlockId: t
|
|
898
|
+
}) => {
|
|
899
|
+
const a = {
|
|
900
|
+
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
901
|
+
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
902
|
+
"system.unavailable_option_value": "Unavailable",
|
|
903
|
+
"system.confirm": "Confirm",
|
|
904
|
+
"system.cancel": "Cancel",
|
|
905
|
+
"system.free": "FREE",
|
|
906
|
+
"system.search": "Search",
|
|
907
|
+
"system.quantity": "Quantity",
|
|
908
|
+
"system.subscription_plan": "Subscription plan",
|
|
909
|
+
"system.remove": "Remove",
|
|
910
|
+
"system.sort_by": "Sort by",
|
|
911
|
+
"system.sort_relevance": "Relevance",
|
|
912
|
+
"system.sort_newest_first": "Newest first",
|
|
913
|
+
"system.sort_price_low_to_high": "Price: Low → High",
|
|
914
|
+
"system.sort_price_high_to_low": "Price: High → Low",
|
|
915
|
+
"system.no_results_found": "No results found",
|
|
916
|
+
"system.no_results_description": "We can't find any item matching your search.",
|
|
917
|
+
"system.clear_search": "Clear search",
|
|
918
|
+
"system.no_products_available": "No products available",
|
|
919
|
+
"system.original_price": "Original price:",
|
|
920
|
+
"system.price": "Price:",
|
|
921
|
+
"system.letters_only": "Only letters are allowed.",
|
|
922
|
+
"system.numbers_only": "Only numbers are allowed.",
|
|
923
|
+
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
924
|
+
}, n = e ? Pe(e) : void 0;
|
|
925
|
+
return {
|
|
926
|
+
...a,
|
|
927
|
+
...n == null ? void 0 : n.system,
|
|
928
|
+
...n == null ? void 0 : n.dealBlocks[t]
|
|
929
|
+
};
|
|
930
|
+
}, Pe = (e) => {
|
|
931
|
+
var s;
|
|
932
|
+
if (typeof document > "u") return;
|
|
933
|
+
const t = document.querySelector("script#kaching-bundles-translations");
|
|
934
|
+
if (!(t != null && t.textContent)) return;
|
|
935
|
+
let a;
|
|
936
|
+
try {
|
|
937
|
+
a = JSON.parse(t.textContent);
|
|
938
|
+
} catch {
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
const n = C(e);
|
|
942
|
+
return (s = a.find(
|
|
943
|
+
(l) => C(l.locale) === n
|
|
944
|
+
)) == null ? void 0 : s.translations;
|
|
945
|
+
}, C = (e) => e.toLowerCase().replace(/_/g, "-"), $e = "2026-07", Se = async (e, {
|
|
867
946
|
productId: t,
|
|
868
947
|
dealBlockId: a,
|
|
869
|
-
country:
|
|
870
|
-
language:
|
|
948
|
+
country: n = void 0,
|
|
949
|
+
language: s = void 0
|
|
871
950
|
}) => {
|
|
872
|
-
var
|
|
951
|
+
var l, u;
|
|
873
952
|
try {
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
const
|
|
877
|
-
language:
|
|
878
|
-
country:
|
|
953
|
+
const i = [Number(t.split("/").pop())], d = new we(e);
|
|
954
|
+
n = n || ((l = d.i18n) == null ? void 0 : l.country), s = s || ((u = d.i18n) == null ? void 0 : u.language);
|
|
955
|
+
const c = await H(d, {
|
|
956
|
+
language: s,
|
|
957
|
+
country: n,
|
|
879
958
|
useExternalMetafieldNamespace: !0
|
|
880
959
|
});
|
|
881
|
-
d.shopifyDomain =
|
|
882
|
-
const p =
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
) : d, [
|
|
960
|
+
d.shopifyDomain = c.shopifyDomain;
|
|
961
|
+
const p = c.storefrontAccessToken ? new ve(
|
|
962
|
+
c.shopifyDomain,
|
|
963
|
+
c.storefrontAccessToken
|
|
964
|
+
) : d, [f, h] = await Promise.all([
|
|
886
965
|
S(p, {
|
|
887
|
-
country:
|
|
888
|
-
language:
|
|
889
|
-
productIds:
|
|
966
|
+
country: n,
|
|
967
|
+
language: s,
|
|
968
|
+
productIds: i,
|
|
890
969
|
useExternalMetafieldNamespace: !0
|
|
891
970
|
}),
|
|
892
|
-
|
|
971
|
+
V(p, {
|
|
893
972
|
useExternalMetafieldNamespace: !0,
|
|
894
|
-
useMetaobjects:
|
|
973
|
+
useMetaobjects: c.featureFlags.storefront_metaobjects
|
|
895
974
|
})
|
|
896
|
-
]),
|
|
897
|
-
if (!
|
|
975
|
+
]), y = f[0];
|
|
976
|
+
if (!y)
|
|
898
977
|
return null;
|
|
899
|
-
const v =
|
|
900
|
-
let
|
|
901
|
-
if (a ? (
|
|
978
|
+
const v = T(h, y);
|
|
979
|
+
let r;
|
|
980
|
+
if (a ? (r = v.find(
|
|
902
981
|
(P) => P.id === a || P.nanoId === a
|
|
903
|
-
),
|
|
982
|
+
), r || (r = v[0])) : r = v[0], !r)
|
|
904
983
|
return null;
|
|
905
|
-
const
|
|
984
|
+
const o = W(r), g = ce(r), [_, I, m, b] = await Promise.all([
|
|
906
985
|
S(p, {
|
|
907
|
-
country:
|
|
908
|
-
language:
|
|
909
|
-
productIds:
|
|
986
|
+
country: n,
|
|
987
|
+
language: s,
|
|
988
|
+
productIds: g,
|
|
910
989
|
useExternalMetafieldNamespace: !0
|
|
911
990
|
}),
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
country:
|
|
915
|
-
language:
|
|
991
|
+
z(p, o, 300),
|
|
992
|
+
Ie(p, r, {
|
|
993
|
+
country: n,
|
|
994
|
+
language: s
|
|
916
995
|
}),
|
|
917
|
-
|
|
996
|
+
_e({ language: s, dealBlockId: r.id })
|
|
918
997
|
]);
|
|
919
998
|
return {
|
|
920
|
-
product:
|
|
921
|
-
dealBlock:
|
|
922
|
-
config:
|
|
999
|
+
product: y,
|
|
1000
|
+
dealBlock: r,
|
|
1001
|
+
config: c,
|
|
923
1002
|
otherProducts: _,
|
|
924
|
-
mediaImages:
|
|
925
|
-
collectionBreaksProducts:
|
|
926
|
-
translations:
|
|
1003
|
+
mediaImages: I,
|
|
1004
|
+
collectionBreaksProducts: m ?? [],
|
|
1005
|
+
translations: b
|
|
927
1006
|
};
|
|
928
|
-
} catch (
|
|
929
|
-
return console.error(
|
|
1007
|
+
} catch (i) {
|
|
1008
|
+
return console.error(i), null;
|
|
930
1009
|
}
|
|
931
1010
|
};
|
|
932
|
-
class
|
|
1011
|
+
class we {
|
|
933
1012
|
constructor(t) {
|
|
934
1013
|
this.storefront = t, this.shopifyDomain = "";
|
|
935
1014
|
}
|
|
936
1015
|
async query(t, a) {
|
|
1016
|
+
var n;
|
|
937
1017
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
938
1018
|
return await this.storefront.query(t, a);
|
|
1019
|
+
if ("graphql" in this.storefront) {
|
|
1020
|
+
const s = await this.storefront.graphql(t, a);
|
|
1021
|
+
if ((n = s.errors) != null && n.length)
|
|
1022
|
+
throw new Error(
|
|
1023
|
+
s.errors.map((l) => l.message).join(`
|
|
1024
|
+
`)
|
|
1025
|
+
);
|
|
1026
|
+
return s.data;
|
|
1027
|
+
}
|
|
939
1028
|
if ("request" in this.storefront)
|
|
940
1029
|
return (await this.storefront.request(t, a)).data;
|
|
941
1030
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
942
|
-
const
|
|
943
|
-
`https://${this.storefront.shopifyDomain}/api/${
|
|
1031
|
+
const s = await fetch(
|
|
1032
|
+
`https://${this.storefront.shopifyDomain}/api/${$e}/graphql.json`,
|
|
944
1033
|
{
|
|
945
1034
|
body: JSON.stringify({
|
|
946
1035
|
query: t,
|
|
@@ -953,11 +1042,11 @@ class ve {
|
|
|
953
1042
|
method: "POST"
|
|
954
1043
|
}
|
|
955
1044
|
);
|
|
956
|
-
if (!
|
|
957
|
-
throw new Error(
|
|
958
|
-
return (await
|
|
1045
|
+
if (!s.ok)
|
|
1046
|
+
throw new Error(s.statusText);
|
|
1047
|
+
return (await s.json()).data;
|
|
959
1048
|
} else {
|
|
960
|
-
const
|
|
1049
|
+
const s = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
961
1050
|
body: JSON.stringify({
|
|
962
1051
|
query: t,
|
|
963
1052
|
variables: a == null ? void 0 : a.variables
|
|
@@ -965,9 +1054,9 @@ class ve {
|
|
|
965
1054
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
966
1055
|
method: "POST"
|
|
967
1056
|
});
|
|
968
|
-
if (!
|
|
969
|
-
throw new Error(
|
|
970
|
-
return (await
|
|
1057
|
+
if (!s.ok)
|
|
1058
|
+
throw new Error(s.statusText);
|
|
1059
|
+
return (await s.json()).data;
|
|
971
1060
|
}
|
|
972
1061
|
}
|
|
973
1062
|
get i18n() {
|
|
@@ -976,5 +1065,5 @@ class ve {
|
|
|
976
1065
|
}
|
|
977
1066
|
}
|
|
978
1067
|
export {
|
|
979
|
-
|
|
1068
|
+
Se as fetchKachingBundlesData
|
|
980
1069
|
};
|