@kachingappz/bundles-js 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundles-js.iife.js +24 -24
- package/dist/index.d.ts +11 -13
- package/dist/index.js +478 -400
- package/dist/kaching-bundle-component/index.d.ts +11 -13
- package/dist/kaching-bundle-component/index.js +596 -515
- package/dist/react/index.cjs +26 -26
- package/dist/react/index.d.ts +11 -13
- package/dist/react/index.js +476 -398
- package/package.json +5 -5
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
const
|
|
2
|
-
const s = [],
|
|
3
|
-
(
|
|
1
|
+
const F = (e, t) => {
|
|
2
|
+
const s = [], a = e.filter(
|
|
3
|
+
(r) => r.blockVisibility === "selected-products"
|
|
4
4
|
);
|
|
5
|
-
for (const
|
|
6
|
-
|
|
7
|
-
const n =
|
|
8
|
-
(
|
|
5
|
+
for (const r of a)
|
|
6
|
+
r.selectedProductIds.map(Number).includes(t.id) && s.push(r);
|
|
7
|
+
const n = e.filter(
|
|
8
|
+
(r) => r.blockVisibility === "selected-collections"
|
|
9
9
|
);
|
|
10
|
-
for (const
|
|
11
|
-
|
|
12
|
-
(m) =>
|
|
13
|
-
) && s.push(
|
|
14
|
-
const
|
|
15
|
-
(
|
|
10
|
+
for (const r of n)
|
|
11
|
+
t.collectionIds.some(
|
|
12
|
+
(m) => r.selectedCollectionIds.map(Number).includes(m)
|
|
13
|
+
) && s.push(r);
|
|
14
|
+
const i = e.filter(
|
|
15
|
+
(r) => r.blockVisibility === "excluded-products"
|
|
16
16
|
);
|
|
17
|
-
for (const
|
|
18
|
-
!
|
|
19
|
-
(m) =>
|
|
20
|
-
) && s.push(
|
|
21
|
-
const o =
|
|
22
|
-
(
|
|
17
|
+
for (const r of i)
|
|
18
|
+
!r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
|
|
19
|
+
(m) => t.collectionIds.includes(m)
|
|
20
|
+
) && s.push(r);
|
|
21
|
+
const o = e.filter(
|
|
22
|
+
(r) => r.blockVisibility === "all-products"
|
|
23
23
|
);
|
|
24
|
-
for (const
|
|
25
|
-
s.push(
|
|
24
|
+
for (const r of o)
|
|
25
|
+
s.push(r);
|
|
26
26
|
return s;
|
|
27
|
-
},
|
|
28
|
-
var
|
|
29
|
-
const
|
|
27
|
+
}, z = (e, { language: t, country: s }) => {
|
|
28
|
+
var h, g;
|
|
29
|
+
const a = R(t, s), n = new Intl.NumberFormat(a, {
|
|
30
30
|
style: "currency",
|
|
31
|
-
currency:
|
|
31
|
+
currency: e,
|
|
32
32
|
currencyDisplay: "narrowSymbol"
|
|
33
|
-
}).formatToParts(123456789e-2),
|
|
34
|
-
(
|
|
35
|
-
),
|
|
33
|
+
}).formatToParts(123456789e-2), i = (h = n.find((f) => f.type === "decimal")) == null ? void 0 : h.value, o = Q(
|
|
34
|
+
(g = n.find((f) => f.type === "group")) == null ? void 0 : g.value
|
|
35
|
+
), r = n.some((f) => f.type === "fraction"), m = J(
|
|
36
36
|
o,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
37
|
+
i,
|
|
38
|
+
r
|
|
39
|
+
), c = n.findIndex(C), u = n.findLastIndex(C);
|
|
40
40
|
return [
|
|
41
|
-
...n.slice(0,
|
|
41
|
+
...n.slice(0, c).map(x),
|
|
42
42
|
m,
|
|
43
43
|
...n.slice(u + 1).map(x)
|
|
44
44
|
].join("");
|
|
45
|
-
}, x = (
|
|
46
|
-
country:
|
|
47
|
-
language:
|
|
45
|
+
}, x = (e) => L(e.value), L = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", R = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : L(e).replace(/’/g, "'"), J = (e, t, s) => t === "," && e === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
|
|
46
|
+
country: e,
|
|
47
|
+
language: t
|
|
48
48
|
}) => {
|
|
49
49
|
const s = [];
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
useExternalMetafieldNamespace:
|
|
50
|
+
return e && s.push(`country: ${e}`), t && s.push(`language: ${t}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
|
|
51
|
+
}, H = async (e, {
|
|
52
|
+
useExternalMetafieldNamespace: t,
|
|
53
53
|
useMetaobjects: s
|
|
54
|
-
}) => s ?
|
|
55
|
-
|
|
56
|
-
) :
|
|
57
|
-
var
|
|
58
|
-
const s = (
|
|
54
|
+
}) => s ? W(
|
|
55
|
+
e
|
|
56
|
+
) : X(e), X = async (e, t) => {
|
|
57
|
+
var a;
|
|
58
|
+
const s = (a = (await e.query(
|
|
59
59
|
`
|
|
60
60
|
query FetchDealBlocks($metafieldNamespace: String!) {
|
|
61
61
|
shop {
|
|
@@ -70,13 +70,13 @@ const U = (t, e) => {
|
|
|
70
70
|
metafieldNamespace: "app--2935586817--kaching_bundles"
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
)).shop.metafield) == null ? void 0 :
|
|
73
|
+
)).shop.metafield) == null ? void 0 : a.value;
|
|
74
74
|
return s ? JSON.parse(s) : [];
|
|
75
|
-
},
|
|
76
|
-
const s = "app--2935586817--deal_block",
|
|
75
|
+
}, W = async (e, t) => {
|
|
76
|
+
const s = "app--2935586817--deal_block", a = [];
|
|
77
77
|
let n = null;
|
|
78
78
|
for (; ; ) {
|
|
79
|
-
const
|
|
79
|
+
const i = await e.query(
|
|
80
80
|
`
|
|
81
81
|
query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
|
|
82
82
|
metaobjects(type: $type, first: 250, after: $cursor) {
|
|
@@ -100,35 +100,35 @@ const U = (t, e) => {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
);
|
|
103
|
-
for (const o of
|
|
104
|
-
const
|
|
103
|
+
for (const o of i.metaobjects.nodes) {
|
|
104
|
+
const r = o.fields.find(
|
|
105
105
|
(m) => m.key === "settings"
|
|
106
106
|
);
|
|
107
|
-
|
|
107
|
+
r != null && r.value && a.push(JSON.parse(r.value));
|
|
108
108
|
}
|
|
109
|
-
if (!
|
|
109
|
+
if (!i.metaobjects.pageInfo.hasNextPage)
|
|
110
110
|
break;
|
|
111
|
-
n =
|
|
111
|
+
n = i.metaobjects.pageInfo.endCursor;
|
|
112
112
|
}
|
|
113
|
-
return
|
|
114
|
-
}, N = async (
|
|
115
|
-
country:
|
|
113
|
+
return a;
|
|
114
|
+
}, N = async (e, {
|
|
115
|
+
country: t,
|
|
116
116
|
language: s,
|
|
117
|
-
blockVisibility:
|
|
117
|
+
blockVisibility: a,
|
|
118
118
|
excludedProductGIDs: n,
|
|
119
|
-
selectedProductGIDs:
|
|
119
|
+
selectedProductGIDs: i,
|
|
120
120
|
selectedCollectionGIDs: o,
|
|
121
|
-
limit:
|
|
121
|
+
limit: r = 1e3
|
|
122
122
|
}) => {
|
|
123
|
-
switch (
|
|
123
|
+
switch (a) {
|
|
124
124
|
case "selected-products":
|
|
125
|
-
return
|
|
125
|
+
return i.slice(0, r);
|
|
126
126
|
case "all-products":
|
|
127
127
|
case "excluded-products": {
|
|
128
|
-
const m = w({ country:
|
|
129
|
-
let
|
|
130
|
-
for (;
|
|
131
|
-
const
|
|
128
|
+
const m = w({ country: t, language: s });
|
|
129
|
+
let c = [], u = null;
|
|
130
|
+
for (; c.length < r; ) {
|
|
131
|
+
const h = Math.min(r - c.length, 250), g = await e.query(
|
|
132
132
|
`
|
|
133
133
|
query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
|
|
134
134
|
products(first: $limit, after: $cursor) {
|
|
@@ -144,22 +144,22 @@ const U = (t, e) => {
|
|
|
144
144
|
`,
|
|
145
145
|
{
|
|
146
146
|
variables: {
|
|
147
|
-
limit:
|
|
147
|
+
limit: h,
|
|
148
148
|
cursor: u
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
);
|
|
152
|
-
if (
|
|
153
|
-
u =
|
|
152
|
+
if (c.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
|
|
153
|
+
u = g.products.pageInfo.endCursor;
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
156
|
-
const
|
|
157
|
-
|
|
155
|
+
if (a === "excluded-products") {
|
|
156
|
+
const h = new Set(n);
|
|
157
|
+
c = c.filter((g) => !h.has(g));
|
|
158
158
|
}
|
|
159
|
-
return
|
|
159
|
+
return c;
|
|
160
160
|
}
|
|
161
161
|
case "selected-collections": {
|
|
162
|
-
const m = w({ country:
|
|
162
|
+
const m = w({ country: t, language: s }), c = (await e.query(
|
|
163
163
|
`
|
|
164
164
|
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
|
|
165
165
|
nodes(ids: $collectionGIDs) {
|
|
@@ -176,16 +176,16 @@ const U = (t, e) => {
|
|
|
176
176
|
{
|
|
177
177
|
variables: {
|
|
178
178
|
collectionGIDs: o,
|
|
179
|
-
limit: Math.min(
|
|
179
|
+
limit: Math.min(r, 250)
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
)).nodes.filter((u) => u !== null).flatMap(
|
|
183
|
-
(u) => u.products.nodes.map((
|
|
183
|
+
(u) => u.products.nodes.map((h) => h.id)
|
|
184
184
|
);
|
|
185
|
-
return Array.from(new Set(
|
|
185
|
+
return Array.from(new Set(c)).slice(0, r);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
},
|
|
188
|
+
}, U = `
|
|
189
189
|
id
|
|
190
190
|
availableForSale
|
|
191
191
|
price {
|
|
@@ -200,7 +200,7 @@ const U = (t, e) => {
|
|
|
200
200
|
}
|
|
201
201
|
image {
|
|
202
202
|
id
|
|
203
|
-
url(transform:
|
|
203
|
+
url(transform: $variantImageTransform)
|
|
204
204
|
}
|
|
205
205
|
unitPriceMeasurement {
|
|
206
206
|
quantityUnit
|
|
@@ -228,20 +228,21 @@ const U = (t, e) => {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
231
|
-
`,
|
|
232
|
-
country:
|
|
231
|
+
`, $ = async (e, {
|
|
232
|
+
country: t,
|
|
233
233
|
language: s,
|
|
234
|
-
productIds:
|
|
234
|
+
productIds: a,
|
|
235
235
|
includeSellingPlans: n = !0,
|
|
236
|
-
includeAvailableQuantity:
|
|
236
|
+
includeAvailableQuantity: i = !0,
|
|
237
237
|
useExternalMetafieldNamespace: o = !1,
|
|
238
|
-
batchSize:
|
|
239
|
-
onBatchError: m
|
|
238
|
+
batchSize: r = 250,
|
|
239
|
+
onBatchError: m,
|
|
240
|
+
variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
|
|
240
241
|
}) => {
|
|
241
|
-
if (!
|
|
242
|
+
if (!a.length)
|
|
242
243
|
return [];
|
|
243
|
-
const
|
|
244
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String
|
|
244
|
+
const u = a.map((p) => typeof p == "string" && p.startsWith("gid://") ? p : `gid://shopify/Product/${p}`), h = w({ country: t, language: s }), g = `
|
|
245
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
|
|
245
246
|
shop {
|
|
246
247
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
247
248
|
value
|
|
@@ -275,7 +276,7 @@ const U = (t, e) => {
|
|
|
275
276
|
}
|
|
276
277
|
variants(first: 250) {
|
|
277
278
|
nodes {
|
|
278
|
-
${
|
|
279
|
+
${U}
|
|
279
280
|
}
|
|
280
281
|
}
|
|
281
282
|
collections(first: 50) {
|
|
@@ -327,84 +328,90 @@ const U = (t, e) => {
|
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
}
|
|
330
|
-
`,
|
|
331
|
-
for (let
|
|
332
|
-
|
|
333
|
-
let
|
|
334
|
-
const
|
|
335
|
-
const b = await
|
|
331
|
+
`, f = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = [], l = Math.min(r, 250);
|
|
332
|
+
for (let p = 0; p < u.length; p += l)
|
|
333
|
+
v.push(u.slice(p, p + l));
|
|
334
|
+
let d = 1;
|
|
335
|
+
const y = async (p) => {
|
|
336
|
+
const b = await e.query(g, {
|
|
336
337
|
variables: {
|
|
337
|
-
productGIDs:
|
|
338
|
+
productGIDs: p,
|
|
338
339
|
includeSellingPlans: n,
|
|
339
|
-
includeAvailableQuantity:
|
|
340
|
-
metafieldNamespace:
|
|
340
|
+
includeAvailableQuantity: i,
|
|
341
|
+
metafieldNamespace: f,
|
|
342
|
+
variantImageTransform: c
|
|
341
343
|
}
|
|
342
344
|
});
|
|
343
|
-
return b.shop.currencyRateConstant && (
|
|
345
|
+
return b.shop.currencyRateConstant && (d = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
|
|
344
346
|
};
|
|
345
|
-
let
|
|
347
|
+
let _;
|
|
346
348
|
if (m) {
|
|
347
|
-
const
|
|
348
|
-
for (const b of
|
|
349
|
+
const p = await Promise.allSettled(v.map(y));
|
|
350
|
+
for (const b of p)
|
|
349
351
|
b.status === "rejected" && m(
|
|
350
352
|
b.reason instanceof Error ? b.reason : new Error(String(b.reason))
|
|
351
353
|
);
|
|
352
|
-
|
|
354
|
+
_ = p.filter(
|
|
353
355
|
(b) => b.status === "fulfilled"
|
|
354
356
|
).flatMap((b) => b.value.nodes);
|
|
355
357
|
} else
|
|
356
|
-
|
|
357
|
-
const
|
|
358
|
+
_ = (await Promise.all(v.map(y))).flatMap((p) => p.nodes);
|
|
359
|
+
const I = _.filter((p) => p != null);
|
|
358
360
|
if (m) {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
const
|
|
362
|
-
|
|
363
|
-
I,
|
|
364
|
-
{ includeSellingPlans: n, includeAvailableQuantity: r },
|
|
365
|
-
u
|
|
366
|
-
);
|
|
367
|
-
return B(
|
|
361
|
+
const p = await Promise.allSettled(
|
|
362
|
+
I.map(async (P) => {
|
|
363
|
+
const V = await G(
|
|
364
|
+
e,
|
|
368
365
|
P,
|
|
369
|
-
|
|
370
|
-
|
|
366
|
+
{
|
|
367
|
+
includeSellingPlans: n,
|
|
368
|
+
includeAvailableQuantity: i,
|
|
369
|
+
variantImageTransform: c
|
|
370
|
+
},
|
|
371
|
+
h
|
|
372
|
+
);
|
|
373
|
+
return T(
|
|
374
|
+
V,
|
|
375
|
+
e.shopifyDomain,
|
|
376
|
+
d
|
|
371
377
|
);
|
|
372
378
|
})
|
|
373
379
|
), b = [];
|
|
374
|
-
for (const
|
|
375
|
-
|
|
376
|
-
|
|
380
|
+
for (const P of p)
|
|
381
|
+
P.status === "fulfilled" ? b.push(P.value) : m(
|
|
382
|
+
P.reason instanceof Error ? P.reason : new Error(String(P.reason))
|
|
377
383
|
);
|
|
378
384
|
return b;
|
|
379
385
|
}
|
|
380
386
|
return (await Promise.all(
|
|
381
|
-
|
|
382
|
-
(
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
I.map(
|
|
388
|
+
(p) => G(
|
|
389
|
+
e,
|
|
390
|
+
p,
|
|
385
391
|
{
|
|
386
392
|
includeSellingPlans: n,
|
|
387
|
-
includeAvailableQuantity:
|
|
393
|
+
includeAvailableQuantity: i,
|
|
394
|
+
variantImageTransform: c
|
|
388
395
|
},
|
|
389
|
-
|
|
396
|
+
h
|
|
390
397
|
)
|
|
391
398
|
)
|
|
392
399
|
)).map(
|
|
393
|
-
(
|
|
400
|
+
(p) => T(p, e.shopifyDomain, d)
|
|
394
401
|
);
|
|
395
|
-
}, G = async (
|
|
396
|
-
if (
|
|
397
|
-
return
|
|
398
|
-
const n = /* @__PURE__ */ new Set(),
|
|
399
|
-
let
|
|
400
|
-
for (;
|
|
401
|
-
const
|
|
402
|
+
}, G = async (e, t, s, a = "") => {
|
|
403
|
+
if (t.variants.nodes.length < 250)
|
|
404
|
+
return t;
|
|
405
|
+
const n = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
|
|
406
|
+
let c = !0, u = null;
|
|
407
|
+
for (; c; ) {
|
|
408
|
+
const h = 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) ${a} {
|
|
404
411
|
product(id: $productGID) {
|
|
405
412
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
406
413
|
nodes {
|
|
407
|
-
${
|
|
414
|
+
${U}
|
|
408
415
|
}
|
|
409
416
|
pageInfo {
|
|
410
417
|
endCursor
|
|
@@ -416,164 +423,164 @@ const U = (t, e) => {
|
|
|
416
423
|
`,
|
|
417
424
|
{
|
|
418
425
|
variables: {
|
|
419
|
-
productGID:
|
|
426
|
+
productGID: t.id,
|
|
420
427
|
cursor: u,
|
|
421
428
|
reverse: m,
|
|
422
429
|
...s
|
|
423
430
|
}
|
|
424
431
|
}
|
|
425
|
-
), { nodes:
|
|
426
|
-
for (const v of
|
|
432
|
+
), { nodes: g, pageInfo: f } = h.product.variants;
|
|
433
|
+
for (const v of g) {
|
|
427
434
|
if (n.has(v.id)) {
|
|
428
|
-
|
|
435
|
+
c = !1;
|
|
429
436
|
break;
|
|
430
437
|
}
|
|
431
|
-
n.add(v.id), m ? o.push(v) :
|
|
438
|
+
n.add(v.id), m ? o.push(v) : i.push(v);
|
|
432
439
|
}
|
|
433
|
-
f.hasNextPage || (
|
|
440
|
+
f.hasNextPage || (c = !1), u = f.endCursor;
|
|
434
441
|
}
|
|
435
442
|
};
|
|
436
443
|
return await Promise.all([
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
]),
|
|
440
|
-
},
|
|
441
|
-
var
|
|
442
|
-
const
|
|
443
|
-
({ unitPriceMeasurement:
|
|
444
|
-
var
|
|
444
|
+
r(!1),
|
|
445
|
+
r(!0)
|
|
446
|
+
]), t.variants.nodes = [...i, ...o.reverse()], t;
|
|
447
|
+
}, T = (e, t, s) => {
|
|
448
|
+
var c, u, h, g, f, v;
|
|
449
|
+
const a = e.variants.nodes.map(
|
|
450
|
+
({ unitPriceMeasurement: l, ...d }) => {
|
|
451
|
+
var y, _;
|
|
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(d.id.split("/").pop()),
|
|
454
|
+
availableForSale: d.availableForSale,
|
|
455
|
+
price: Math.round(Number(d.price.amount) * 100),
|
|
456
|
+
compareAtPrice: d.compareAtPrice ? Math.round(Number(d.compareAtPrice.amount) * 100) : null,
|
|
457
|
+
options: d.selectedOptions.map((I) => I.value),
|
|
458
|
+
imageId: d.image ? Number(d.image.id.split("/").pop()) : null,
|
|
459
|
+
image: ((y = d.image) == null ? void 0 : y.url) || null,
|
|
460
|
+
sellingPlans: ((_ = d.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(d.price.amount) * 100),
|
|
463
|
+
compareAtPrice: I.priceAdjustments.length > 0 ? Math.round(
|
|
464
|
+
Number(I.priceAdjustments[0].compareAtPrice.amount) * 100
|
|
465
|
+
) : Math.round(Number(d.price.amount) * 100),
|
|
466
|
+
perDeliveryPrice: I.priceAdjustments.length > 0 ? Math.round(
|
|
467
|
+
Number(I.priceAdjustments[0].perDeliveryPrice.amount) * 100
|
|
468
|
+
) : Math.round(Number(d.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: d.quantityAvailable ?? null,
|
|
475
|
+
unitPriceMeasurement: l != null && l.quantityUnit && (l != null && l.referenceUnit) ? {
|
|
476
|
+
quantityValue: l.quantityValue,
|
|
477
|
+
quantityUnit: l.quantityUnit.toLowerCase(),
|
|
478
|
+
referenceValue: l.referenceValue,
|
|
479
|
+
referenceUnit: l.referenceUnit.toLowerCase()
|
|
473
480
|
} : null
|
|
474
481
|
};
|
|
475
482
|
}
|
|
476
|
-
), n =
|
|
477
|
-
const
|
|
478
|
-
var
|
|
483
|
+
), n = e.options.map((l, d) => {
|
|
484
|
+
const y = l.optionValues.map((_) => {
|
|
485
|
+
var I, p, 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 = (p = _.swatch) == null ? void 0 : p.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: l.name,
|
|
498
|
+
name: l.name,
|
|
499
|
+
position: d + 1,
|
|
500
|
+
optionValues: K(y, d, a)
|
|
494
501
|
};
|
|
495
|
-
}),
|
|
496
|
-
const
|
|
497
|
-
if (!
|
|
502
|
+
}), i = (l) => {
|
|
503
|
+
const d = l.priceAdjustments[0];
|
|
504
|
+
if (!d)
|
|
498
505
|
return null;
|
|
499
|
-
const
|
|
500
|
-
switch (
|
|
506
|
+
const y = d.adjustmentValue;
|
|
507
|
+
switch (y.__typename) {
|
|
501
508
|
case "SellingPlanPercentagePriceAdjustment":
|
|
502
509
|
return {
|
|
503
510
|
type: "percentage",
|
|
504
|
-
value:
|
|
511
|
+
value: y.adjustmentPercentage
|
|
505
512
|
};
|
|
506
513
|
case "SellingPlanFixedAmountPriceAdjustment":
|
|
507
514
|
return {
|
|
508
515
|
type: "fixed_amount",
|
|
509
|
-
value: o(
|
|
516
|
+
value: o(y.adjustmentAmount.amount)
|
|
510
517
|
};
|
|
511
518
|
case "SellingPlanFixedPriceAdjustment":
|
|
512
519
|
return {
|
|
513
520
|
type: "price",
|
|
514
|
-
value: o(
|
|
521
|
+
value: o(y.price.amount)
|
|
515
522
|
};
|
|
516
523
|
default:
|
|
517
524
|
throw new Error(
|
|
518
|
-
`Unknown price adjustment type: ${
|
|
525
|
+
`Unknown price adjustment type: ${y.__typename}`
|
|
519
526
|
);
|
|
520
527
|
}
|
|
521
|
-
}, o = (
|
|
522
|
-
(
|
|
523
|
-
id: Number(
|
|
524
|
-
name:
|
|
525
|
-
priceAdjustment:
|
|
528
|
+
}, o = (l) => s === 1 ? Number(l) * 100 : Math.round(Number(l) * 100 * s), r = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
|
|
529
|
+
(l) => l.sellingPlans.nodes.map((d) => ({
|
|
530
|
+
id: Number(d.id.split("/").pop()),
|
|
531
|
+
name: d.name,
|
|
532
|
+
priceAdjustment: i(d)
|
|
526
533
|
}))
|
|
527
|
-
)) || [], m =
|
|
528
|
-
(
|
|
534
|
+
)) || [], m = e.variants.nodes.some(
|
|
535
|
+
(l) => l.requiresComponents
|
|
529
536
|
);
|
|
530
537
|
return {
|
|
531
|
-
id: Number(
|
|
532
|
-
handle:
|
|
533
|
-
url:
|
|
534
|
-
availableForSale:
|
|
535
|
-
createdAt:
|
|
536
|
-
title:
|
|
537
|
-
image: ((u =
|
|
538
|
-
collectionIds:
|
|
539
|
-
(
|
|
538
|
+
id: Number(e.id.split("/").pop()),
|
|
539
|
+
handle: e.handle,
|
|
540
|
+
url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
|
|
541
|
+
availableForSale: e.availableForSale,
|
|
542
|
+
createdAt: e.createdAt,
|
|
543
|
+
title: e.title,
|
|
544
|
+
image: ((u = e.featuredImage) == null ? void 0 : u.url) || null,
|
|
545
|
+
collectionIds: e.collections.nodes.map(
|
|
546
|
+
(l) => Number(l.id.split("/").pop())
|
|
540
547
|
),
|
|
541
548
|
options: n,
|
|
542
549
|
selectedVariantId: Number(
|
|
543
|
-
|
|
550
|
+
e.variants.nodes[0].id.split("/").pop()
|
|
544
551
|
),
|
|
545
|
-
variants:
|
|
546
|
-
requiresSellingPlan:
|
|
547
|
-
sellingPlans:
|
|
552
|
+
variants: a,
|
|
553
|
+
requiresSellingPlan: e.requiresSellingPlan,
|
|
554
|
+
sellingPlans: r,
|
|
548
555
|
isNativeBundle: m,
|
|
549
556
|
metafields: {
|
|
550
|
-
text: ((
|
|
551
|
-
text2: ((
|
|
552
|
-
text3: ((f =
|
|
553
|
-
text4: ((v =
|
|
557
|
+
text: ((h = e.metafield) == null ? void 0 : h.value) || null,
|
|
558
|
+
text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
|
|
559
|
+
text3: ((f = e.metafield3) == null ? void 0 : f.value) || null,
|
|
560
|
+
text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
|
|
554
561
|
}
|
|
555
562
|
};
|
|
556
|
-
},
|
|
557
|
-
(n) => n.options[
|
|
558
|
-
).length > 0),
|
|
559
|
-
language:
|
|
563
|
+
}, K = (e, t, s) => e.filter((a) => s.filter(
|
|
564
|
+
(n) => n.options[t] === a.name
|
|
565
|
+
).length > 0), B = "app--2935586817", Y = async (e, {
|
|
566
|
+
language: t,
|
|
560
567
|
country: s,
|
|
561
|
-
useExternalMetafieldNamespace:
|
|
568
|
+
useExternalMetafieldNamespace: a
|
|
562
569
|
}) => {
|
|
563
|
-
const n = `${
|
|
570
|
+
const n = `${B}--kaching_bundles`, i = B, o = w({ country: s }), {
|
|
564
571
|
localization: {
|
|
565
572
|
country: {
|
|
566
|
-
currency: { isoCode:
|
|
573
|
+
currency: { isoCode: r }
|
|
567
574
|
}
|
|
568
575
|
},
|
|
569
576
|
shop: {
|
|
570
577
|
moneyFormat: m,
|
|
571
|
-
paymentSettings: { currencyCode:
|
|
578
|
+
paymentSettings: { currencyCode: c },
|
|
572
579
|
currencyRateConstant: u,
|
|
573
|
-
primaryDomain:
|
|
574
|
-
settingsMetafield:
|
|
580
|
+
primaryDomain: h,
|
|
581
|
+
settingsMetafield: g
|
|
575
582
|
}
|
|
576
|
-
} = await
|
|
583
|
+
} = await e.query(
|
|
577
584
|
`
|
|
578
585
|
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
|
|
579
586
|
localization {
|
|
@@ -603,29 +610,29 @@ const U = (t, e) => {
|
|
|
603
610
|
{
|
|
604
611
|
variables: {
|
|
605
612
|
metafieldNamespace: n,
|
|
606
|
-
settingsNamespace:
|
|
613
|
+
settingsNamespace: i
|
|
607
614
|
}
|
|
608
615
|
}
|
|
609
|
-
), f =
|
|
616
|
+
), f = r === c ? m : z(r, { language: t, country: s }), v = u ? Z(u.value) : 1, l = g ? JSON.parse(g.value) : null, d = (l == null ? void 0 : l.feature_flags) ?? {}, y = (l == null ? void 0 : l.custom_selectors) ?? {};
|
|
610
617
|
return {
|
|
611
|
-
shopifyDomain:
|
|
618
|
+
shopifyDomain: h.host,
|
|
612
619
|
moneyFormat: f,
|
|
613
|
-
locale: (
|
|
614
|
-
liquidLocale: (
|
|
620
|
+
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
621
|
+
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
615
622
|
country: s ?? "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: (l == null ? void 0 : l.storefront_access_token) ?? null,
|
|
627
|
+
includeSellingPlans: (l == null ? void 0 : l.include_selling_plans) ?? !1,
|
|
628
|
+
includeAvailableQuantity: (l == null ? void 0 : l.include_available_quantity) ?? !1,
|
|
629
|
+
customApiHost: (l == null ? void 0 : l.custom_api_host) ?? null,
|
|
630
|
+
keepQuantityInput: (l == null ? void 0 : l.keep_quantity_input) ?? !1,
|
|
631
|
+
ignoreDeselect: (l == null ? void 0 : l.ignore_deselect) ?? !1,
|
|
632
|
+
ignoreUnitPrice: (l == null ? void 0 : l.ignore_unit_price) ?? !1,
|
|
633
|
+
requireCustomerLogin: (l == null ? void 0 : l.require_customer_login) ?? !1,
|
|
634
|
+
abTestsRunning: (l == null ? void 0 : l.ab_tests_running) ?? !1,
|
|
635
|
+
webPixel: (l == null ? void 0 : l.web_pixel) ?? !1,
|
|
629
636
|
b2bCustomer: !1,
|
|
630
637
|
isLoggedIn: !1,
|
|
631
638
|
preview: !1,
|
|
@@ -657,303 +664,374 @@ const U = (t, e) => {
|
|
|
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: y.quantity ?? null,
|
|
668
|
+
addToCartButton: y.add_to_cart_button ?? null,
|
|
669
|
+
variantPicker: y.variant_picker ?? null,
|
|
670
|
+
price: y.price ?? null,
|
|
671
|
+
priceCompare: y.price_compare ?? null
|
|
665
672
|
},
|
|
666
|
-
shopCustomStyles: (
|
|
667
|
-
featureFlags:
|
|
668
|
-
brandColors: (
|
|
673
|
+
shopCustomStyles: (l == null ? void 0 : l.shop_custom_styles) ?? "",
|
|
674
|
+
featureFlags: d,
|
|
675
|
+
brandColors: (l == null ? void 0 : l.brand_colors) ?? null
|
|
669
676
|
};
|
|
670
|
-
},
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
677
|
+
}, Z = (e) => JSON.parse(e).amount / 1e6, ee = async (e, t, s = 200) => {
|
|
678
|
+
const a = [
|
|
679
|
+
...new Set(
|
|
680
|
+
t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
|
|
681
|
+
)
|
|
682
|
+
];
|
|
683
|
+
if (a.length === 0) return [];
|
|
684
|
+
const n = [];
|
|
685
|
+
for (let i = 0; i < a.length; i += 250)
|
|
686
|
+
n.push(a.slice(i, i + 250));
|
|
687
|
+
return (await Promise.all(
|
|
688
|
+
n.map(
|
|
689
|
+
(i) => 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: i,
|
|
705
|
+
size: s
|
|
706
|
+
}
|
|
680
707
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
...
|
|
696
|
-
...
|
|
697
|
-
...
|
|
698
|
-
...
|
|
699
|
-
...
|
|
700
|
-
...
|
|
701
|
-
...
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
...oe(t),
|
|
705
|
-
...ce(t),
|
|
706
|
-
...ue(t),
|
|
707
|
-
...de(t)
|
|
708
|
-
].filter((e) => e != null && !e.includes("placeholder")), Z = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ee = (t) => t.dealBars.flatMap(
|
|
709
|
-
(e) => e.dealBarType === S.Bundle ? e.bundleProducts.map(
|
|
708
|
+
)
|
|
709
|
+
)
|
|
710
|
+
)).flatMap((i) => i.nodes).flatMap(
|
|
711
|
+
(i) => i != null && i.image ? [{ gid: i.id, url: i.image.url }] : []
|
|
712
|
+
);
|
|
713
|
+
};
|
|
714
|
+
var S = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(S || {});
|
|
715
|
+
const te = (e) => [
|
|
716
|
+
...se(e),
|
|
717
|
+
...ae(e),
|
|
718
|
+
...ne(e),
|
|
719
|
+
...le(e),
|
|
720
|
+
...re(e),
|
|
721
|
+
...ie(e),
|
|
722
|
+
...oe(e),
|
|
723
|
+
...ce(e),
|
|
724
|
+
...ue(e),
|
|
725
|
+
...de(e),
|
|
726
|
+
...me(e),
|
|
727
|
+
...pe(e),
|
|
728
|
+
...fe(e)
|
|
729
|
+
].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.flatMap(
|
|
730
|
+
(t) => t.dealBarType === S.Bundle ? t.bundleProducts.map(
|
|
710
731
|
(s) => s.mediaImageGID
|
|
711
732
|
) : []
|
|
712
|
-
).filter((
|
|
713
|
-
({ freeGifts:
|
|
714
|
-
).reduce((
|
|
715
|
-
({ multipleGiftsSelectors:
|
|
716
|
-
).filter((
|
|
717
|
-
const
|
|
718
|
-
return [...
|
|
719
|
-
}, []) : [],
|
|
720
|
-
if (!
|
|
733
|
+
).filter((t) => t != null), ne = (e) => e.dealBars.map(
|
|
734
|
+
({ freeGifts: t }) => (t || []).map((s) => s.mediaImageGID)
|
|
735
|
+
).reduce((t, s) => t.concat(s), []).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
|
|
736
|
+
({ multipleGiftsSelectors: t }) => (t || []).map((s) => s.mediaImageGID)
|
|
737
|
+
).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((s) => s.mediaImageGID)).reduce((t, s) => t.concat(s), []).filter((t) => t != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, s) => {
|
|
738
|
+
const a = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
|
|
739
|
+
return [...t, ...a];
|
|
740
|
+
}, []) : [], oe = (e) => {
|
|
741
|
+
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
721
742
|
return [];
|
|
722
|
-
const
|
|
723
|
-
return
|
|
724
|
-
},
|
|
725
|
-
var
|
|
726
|
-
return
|
|
727
|
-
...((
|
|
728
|
-
(s =
|
|
729
|
-
(
|
|
743
|
+
const t = e.collectionBreaks.mediaImageGID;
|
|
744
|
+
return t ? [t] : [];
|
|
745
|
+
}, ce = (e) => {
|
|
746
|
+
var t, s, a;
|
|
747
|
+
return e.progressiveGifts ? [
|
|
748
|
+
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
|
|
749
|
+
(s = e.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
|
|
750
|
+
(a = e.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
|
|
730
751
|
].filter((n) => n != null) : [];
|
|
731
|
-
},
|
|
752
|
+
}, ue = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), de = (e) => e.dealBars.map((t) => {
|
|
732
753
|
var s;
|
|
733
|
-
return (s =
|
|
734
|
-
}).filter((
|
|
735
|
-
var
|
|
736
|
-
const
|
|
754
|
+
return (s = t.productPersonalisation) == null ? void 0 : s.mediaImageGID;
|
|
755
|
+
}).filter((t) => t != null), me = (e) => {
|
|
756
|
+
var a, n;
|
|
757
|
+
const t = e.dealBars.map((i) => {
|
|
737
758
|
var o;
|
|
738
|
-
return (o =
|
|
739
|
-
}).filter((
|
|
740
|
-
return s ? [...
|
|
741
|
-
},
|
|
742
|
-
(
|
|
743
|
-
),
|
|
744
|
-
const
|
|
745
|
-
...
|
|
746
|
-
...
|
|
747
|
-
...
|
|
748
|
-
...
|
|
749
|
-
...
|
|
750
|
-
...
|
|
751
|
-
...
|
|
752
|
-
...
|
|
759
|
+
return (o = i.highlights) == null ? void 0 : o.customIconGID;
|
|
760
|
+
}).filter((i) => i != null), s = (n = (a = e.subscriptions) == null ? void 0 : a.highlights) == null ? void 0 : n.customIconGID;
|
|
761
|
+
return s ? [...t, s] : t;
|
|
762
|
+
}, pe = (e) => (e.badges || []).flatMap(
|
|
763
|
+
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
764
|
+
), fe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
|
|
765
|
+
const t = [
|
|
766
|
+
...ge(e),
|
|
767
|
+
...ye(e),
|
|
768
|
+
...be(e),
|
|
769
|
+
...ve(e),
|
|
770
|
+
...Ie(e),
|
|
771
|
+
..._e(e),
|
|
772
|
+
...Pe(e),
|
|
773
|
+
...Se(e)
|
|
753
774
|
];
|
|
754
|
-
return Array.from(new Set(
|
|
755
|
-
},
|
|
756
|
-
({ freeGifts:
|
|
757
|
-
).filter((
|
|
758
|
-
({ multipleGiftsSelectors:
|
|
759
|
-
(s) => s.products ? s.products.map((
|
|
775
|
+
return Array.from(new Set(t.filter((s) => s != null)));
|
|
776
|
+
}, ge = (e) => e.dealBars.flatMap(
|
|
777
|
+
({ freeGifts: t }) => t ? t.map((s) => s.productGID) : []
|
|
778
|
+
).filter((t) => t != null), ye = (e) => e.dealBars.flatMap(
|
|
779
|
+
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
780
|
+
(s) => s.products ? s.products.map((a) => a.id) : []
|
|
760
781
|
) : []
|
|
761
|
-
).filter((
|
|
762
|
-
var
|
|
763
|
-
return
|
|
764
|
-
},
|
|
765
|
-
({ bundleProducts:
|
|
766
|
-
).filter((
|
|
767
|
-
({ bundleProducts:
|
|
768
|
-
var
|
|
782
|
+
).filter((t) => t != null), be = (e) => {
|
|
783
|
+
var t;
|
|
784
|
+
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
|
|
785
|
+
}, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((s) => s.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === S.Bundle).flatMap(
|
|
786
|
+
({ bundleProducts: t }) => t ? t.map((s) => s.productGID) : []
|
|
787
|
+
).filter((t) => t != null).filter((t) => t !== "default"), _e = (e) => e.dealBars.filter((t) => t.dealBarType === S.MixAndMatch).flatMap(
|
|
788
|
+
({ bundleProducts: t }) => t ? t.flatMap((s) => {
|
|
789
|
+
var a;
|
|
769
790
|
return [
|
|
770
791
|
s.productGID,
|
|
771
|
-
...((
|
|
792
|
+
...((a = s.selectedProducts) == null ? void 0 : a.map((n) => n.id)) ?? []
|
|
772
793
|
];
|
|
773
794
|
}) : []
|
|
774
|
-
).filter((
|
|
775
|
-
class
|
|
776
|
-
constructor(
|
|
777
|
-
|
|
795
|
+
).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), Se = (e) => e.dealBars.filter((t) => t.dealBarType === S.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
|
|
796
|
+
class M extends Error {
|
|
797
|
+
constructor({
|
|
798
|
+
status: t,
|
|
799
|
+
operationName: s,
|
|
800
|
+
graphqlErrors: a
|
|
801
|
+
}) {
|
|
802
|
+
const n = a.length ? `: ${a.join("; ")}` : "";
|
|
803
|
+
super(
|
|
804
|
+
`Storefront API ${s ?? "query"} failed (HTTP ${t})${n}`
|
|
805
|
+
), this.name = "StorefrontApiError", this.status = t, this.operationName = s, this.graphqlErrors = a;
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
const ke = async (e, t) => {
|
|
809
|
+
const s = await e.text();
|
|
810
|
+
if (!s)
|
|
811
|
+
throw new Error("Empty graphql response");
|
|
812
|
+
let a;
|
|
813
|
+
try {
|
|
814
|
+
a = JSON.parse(s);
|
|
815
|
+
} catch (n) {
|
|
816
|
+
throw e.ok ? n : new M({
|
|
817
|
+
status: e.status,
|
|
818
|
+
operationName: t,
|
|
819
|
+
graphqlErrors: []
|
|
820
|
+
});
|
|
778
821
|
}
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
822
|
+
if (!e.ok || a.data === null || a.data === void 0)
|
|
823
|
+
throw new M({
|
|
824
|
+
status: e.status,
|
|
825
|
+
operationName: t,
|
|
826
|
+
graphqlErrors: (a.errors ?? []).map(({ message: n }) => n).filter(Boolean)
|
|
827
|
+
});
|
|
828
|
+
return a.data;
|
|
829
|
+
};
|
|
830
|
+
class we {
|
|
831
|
+
constructor(t, s) {
|
|
832
|
+
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = t;
|
|
833
|
+
}
|
|
834
|
+
async query(t, s) {
|
|
835
|
+
var r;
|
|
836
|
+
const a = (s == null ? void 0 : s.variables) ?? {};
|
|
782
837
|
let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const o = await
|
|
838
|
+
const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
|
|
839
|
+
i && (n += `?operation_name=${i}`);
|
|
840
|
+
const o = await fetch(n, {
|
|
786
841
|
method: "POST",
|
|
787
842
|
headers: {
|
|
788
843
|
"Content-Type": "application/json",
|
|
789
844
|
"X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
|
|
790
845
|
},
|
|
791
846
|
body: JSON.stringify({
|
|
792
|
-
query:
|
|
793
|
-
variables:
|
|
847
|
+
query: t,
|
|
848
|
+
variables: a
|
|
794
849
|
})
|
|
795
|
-
})
|
|
796
|
-
|
|
797
|
-
throw new Error("Empty graphql response");
|
|
798
|
-
return JSON.parse(o).data;
|
|
850
|
+
});
|
|
851
|
+
return ke(o, i);
|
|
799
852
|
}
|
|
800
853
|
}
|
|
801
|
-
const
|
|
802
|
-
const n =
|
|
803
|
-
if (!
|
|
804
|
-
let
|
|
805
|
-
n.visibility === "deal-products" ?
|
|
854
|
+
const Ee = async (e, t, { country: s, language: a }) => {
|
|
855
|
+
const n = t.collectionBreaks;
|
|
856
|
+
if (!t.collectionBreaksEnabled || !n) return;
|
|
857
|
+
let i;
|
|
858
|
+
n.visibility === "deal-products" ? i = await N(e, {
|
|
806
859
|
country: s,
|
|
807
|
-
language:
|
|
808
|
-
blockVisibility:
|
|
809
|
-
excludedProductGIDs: (
|
|
810
|
-
(
|
|
860
|
+
language: a,
|
|
861
|
+
blockVisibility: t.blockVisibility,
|
|
862
|
+
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
863
|
+
(r) => `gid://shopify/Product/${r}`
|
|
811
864
|
),
|
|
812
|
-
selectedProductGIDs: (
|
|
813
|
-
(
|
|
865
|
+
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
866
|
+
(r) => `gid://shopify/Product/${r}`
|
|
814
867
|
),
|
|
815
|
-
selectedCollectionGIDs: (
|
|
816
|
-
(
|
|
868
|
+
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
869
|
+
(r) => `gid://shopify/Collection/${r}`
|
|
817
870
|
)
|
|
818
|
-
}) :
|
|
871
|
+
}) : i = await N(e, {
|
|
819
872
|
country: s,
|
|
820
|
-
language:
|
|
873
|
+
language: a,
|
|
821
874
|
blockVisibility: n.visibility,
|
|
822
875
|
excludedProductGIDs: (n.excludedProducts || []).map(
|
|
823
|
-
({ id:
|
|
876
|
+
({ id: r }) => r
|
|
824
877
|
),
|
|
825
878
|
selectedProductGIDs: (n.selectedProducts || []).map(
|
|
826
|
-
({ id:
|
|
879
|
+
({ id: r }) => r
|
|
827
880
|
),
|
|
828
881
|
selectedCollectionGIDs: (n.selectedCollections || []).map(
|
|
829
|
-
({ id:
|
|
882
|
+
({ id: r }) => r
|
|
830
883
|
)
|
|
831
884
|
});
|
|
832
|
-
let o = await
|
|
885
|
+
let o = await $(e, {
|
|
833
886
|
country: s,
|
|
834
|
-
language:
|
|
835
|
-
productIds:
|
|
887
|
+
language: a,
|
|
888
|
+
productIds: i.map((r) => Number(r.split("/").pop())),
|
|
836
889
|
useExternalMetafieldNamespace: !0
|
|
837
890
|
});
|
|
838
891
|
return o = o.filter(
|
|
839
|
-
(
|
|
892
|
+
(r) => r.availableForSale
|
|
840
893
|
), o;
|
|
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
|
-
|
|
867
|
-
|
|
894
|
+
}, Ae = ({
|
|
895
|
+
language: e,
|
|
896
|
+
dealBlockId: t
|
|
897
|
+
}) => {
|
|
898
|
+
const s = {
|
|
899
|
+
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
900
|
+
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
901
|
+
"system.unavailable_option_value": "Unavailable",
|
|
902
|
+
"system.confirm": "Confirm",
|
|
903
|
+
"system.cancel": "Cancel",
|
|
904
|
+
"system.free": "FREE",
|
|
905
|
+
"system.search": "Search",
|
|
906
|
+
"system.quantity": "Quantity",
|
|
907
|
+
"system.subscription_plan": "Subscription plan",
|
|
908
|
+
"system.remove": "Remove",
|
|
909
|
+
"system.sort_by": "Sort by",
|
|
910
|
+
"system.sort_relevance": "Relevance",
|
|
911
|
+
"system.sort_newest_first": "Newest first",
|
|
912
|
+
"system.sort_price_low_to_high": "Price: Low → High",
|
|
913
|
+
"system.sort_price_high_to_low": "Price: High → Low",
|
|
914
|
+
"system.no_results_found": "No results found",
|
|
915
|
+
"system.no_results_description": "We can't find any item matching your search.",
|
|
916
|
+
"system.clear_search": "Clear search",
|
|
917
|
+
"system.no_products_available": "No products available",
|
|
918
|
+
"system.original_price": "Original price:",
|
|
919
|
+
"system.price": "Price:",
|
|
920
|
+
"system.letters_only": "Only letters are allowed.",
|
|
921
|
+
"system.numbers_only": "Only numbers are allowed.",
|
|
922
|
+
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
923
|
+
}, a = e ? $e(e) : void 0;
|
|
924
|
+
return {
|
|
925
|
+
...s,
|
|
926
|
+
...a == null ? void 0 : a.system,
|
|
927
|
+
...a == null ? void 0 : a.dealBlocks[t]
|
|
928
|
+
};
|
|
929
|
+
}, $e = (e) => {
|
|
930
|
+
var n;
|
|
931
|
+
if (typeof document > "u") return;
|
|
932
|
+
const t = document.querySelector("script#kaching-bundles-translations");
|
|
933
|
+
if (!(t != null && t.textContent)) return;
|
|
934
|
+
let s;
|
|
935
|
+
try {
|
|
936
|
+
s = JSON.parse(t.textContent);
|
|
937
|
+
} catch {
|
|
938
|
+
return;
|
|
939
|
+
}
|
|
940
|
+
const a = q(e);
|
|
941
|
+
return (n = s.find(
|
|
942
|
+
(i) => q(i.locale) === a
|
|
943
|
+
)) == null ? void 0 : n.translations;
|
|
944
|
+
}, q = (e) => e.toLowerCase().replace(/_/g, "-"), De = "2026-07", xe = async (e, {
|
|
945
|
+
productId: t,
|
|
868
946
|
dealBlockId: s,
|
|
869
|
-
country:
|
|
947
|
+
country: a = void 0,
|
|
870
948
|
language: n = void 0
|
|
871
949
|
}) => {
|
|
872
|
-
var
|
|
950
|
+
var i, o;
|
|
873
951
|
try {
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
const
|
|
952
|
+
const r = [Number(t.split("/").pop())], m = new Ce(e);
|
|
953
|
+
a = a || ((i = m.i18n) == null ? void 0 : i.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
|
|
954
|
+
const c = await Y(m, {
|
|
877
955
|
language: n,
|
|
878
|
-
country:
|
|
956
|
+
country: a,
|
|
879
957
|
useExternalMetafieldNamespace: !0
|
|
880
958
|
});
|
|
881
|
-
m.shopifyDomain =
|
|
882
|
-
const u =
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
) : m, [
|
|
886
|
-
|
|
887
|
-
country:
|
|
959
|
+
m.shopifyDomain = c.shopifyDomain;
|
|
960
|
+
const u = c.storefrontAccessToken ? new we(
|
|
961
|
+
c.shopifyDomain,
|
|
962
|
+
c.storefrontAccessToken
|
|
963
|
+
) : m, [h, g] = await Promise.all([
|
|
964
|
+
$(u, {
|
|
965
|
+
country: a,
|
|
888
966
|
language: n,
|
|
889
|
-
productIds:
|
|
967
|
+
productIds: r,
|
|
890
968
|
useExternalMetafieldNamespace: !0
|
|
891
969
|
}),
|
|
892
|
-
|
|
970
|
+
H(u, {
|
|
893
971
|
useExternalMetafieldNamespace: !0,
|
|
894
|
-
useMetaobjects:
|
|
972
|
+
useMetaobjects: c.featureFlags.storefront_metaobjects
|
|
895
973
|
})
|
|
896
|
-
]), f =
|
|
974
|
+
]), f = h[0];
|
|
897
975
|
if (!f)
|
|
898
976
|
return null;
|
|
899
|
-
const v =
|
|
900
|
-
let
|
|
901
|
-
if (s ? (
|
|
977
|
+
const v = F(g, f);
|
|
978
|
+
let l;
|
|
979
|
+
if (s ? (l = v.find(
|
|
902
980
|
(P) => P.id === s || P.nanoId === s
|
|
903
|
-
),
|
|
981
|
+
), l || (l = v[0])) : l = v[0], !l)
|
|
904
982
|
return null;
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
country:
|
|
983
|
+
const d = te(l), y = he(l), [_, I, p, b] = await Promise.all([
|
|
984
|
+
$(u, {
|
|
985
|
+
country: a,
|
|
908
986
|
language: n,
|
|
909
|
-
productIds:
|
|
987
|
+
productIds: y,
|
|
910
988
|
useExternalMetafieldNamespace: !0
|
|
911
989
|
}),
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
country:
|
|
990
|
+
ee(u, d, 300),
|
|
991
|
+
Ee(u, l, {
|
|
992
|
+
country: a,
|
|
915
993
|
language: n
|
|
916
994
|
}),
|
|
917
|
-
|
|
995
|
+
Ae({ language: n, dealBlockId: l.id })
|
|
918
996
|
]);
|
|
919
997
|
return {
|
|
920
998
|
product: f,
|
|
921
|
-
dealBlock:
|
|
922
|
-
config:
|
|
999
|
+
dealBlock: l,
|
|
1000
|
+
config: c,
|
|
923
1001
|
otherProducts: _,
|
|
924
|
-
mediaImages:
|
|
925
|
-
collectionBreaksProducts:
|
|
926
|
-
translations:
|
|
1002
|
+
mediaImages: I,
|
|
1003
|
+
collectionBreaksProducts: p ?? [],
|
|
1004
|
+
translations: b
|
|
927
1005
|
};
|
|
928
|
-
} catch (
|
|
929
|
-
return console.error(
|
|
1006
|
+
} catch (r) {
|
|
1007
|
+
return console.error(r), null;
|
|
930
1008
|
}
|
|
931
1009
|
};
|
|
932
|
-
class
|
|
933
|
-
constructor(
|
|
934
|
-
this.storefront =
|
|
1010
|
+
class Ce {
|
|
1011
|
+
constructor(t) {
|
|
1012
|
+
this.storefront = t, this.shopifyDomain = "";
|
|
935
1013
|
}
|
|
936
|
-
async query(
|
|
937
|
-
var
|
|
1014
|
+
async query(t, s) {
|
|
1015
|
+
var a;
|
|
938
1016
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
939
|
-
return await this.storefront.query(
|
|
1017
|
+
return await this.storefront.query(t, s);
|
|
940
1018
|
if ("graphql" in this.storefront) {
|
|
941
|
-
const n = await this.storefront.graphql(
|
|
942
|
-
if ((
|
|
1019
|
+
const n = await this.storefront.graphql(t, s);
|
|
1020
|
+
if ((a = n.errors) != null && a.length)
|
|
943
1021
|
throw new Error(
|
|
944
|
-
n.errors.map((
|
|
1022
|
+
n.errors.map((i) => i.message).join(`
|
|
945
1023
|
`)
|
|
946
1024
|
);
|
|
947
1025
|
return n.data;
|
|
948
1026
|
}
|
|
949
1027
|
if ("request" in this.storefront)
|
|
950
|
-
return (await this.storefront.request(
|
|
1028
|
+
return (await this.storefront.request(t, s)).data;
|
|
951
1029
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
952
1030
|
const n = await fetch(
|
|
953
|
-
`https://${this.storefront.shopifyDomain}/api/${
|
|
1031
|
+
`https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
|
|
954
1032
|
{
|
|
955
1033
|
body: JSON.stringify({
|
|
956
|
-
query:
|
|
1034
|
+
query: t,
|
|
957
1035
|
variables: s == null ? void 0 : s.variables
|
|
958
1036
|
}),
|
|
959
1037
|
headers: {
|
|
@@ -969,7 +1047,7 @@ class Ee {
|
|
|
969
1047
|
} else {
|
|
970
1048
|
const n = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
971
1049
|
body: JSON.stringify({
|
|
972
|
-
query:
|
|
1050
|
+
query: t,
|
|
973
1051
|
variables: s == null ? void 0 : s.variables
|
|
974
1052
|
}),
|
|
975
1053
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
@@ -985,52 +1063,52 @@ class Ee {
|
|
|
985
1063
|
return this.storefront.i18n;
|
|
986
1064
|
}
|
|
987
1065
|
}
|
|
988
|
-
const E = "kaching-bundles-block",
|
|
989
|
-
const
|
|
990
|
-
if (!
|
|
991
|
-
if (A.has(
|
|
992
|
-
return
|
|
993
|
-
A.add(
|
|
1066
|
+
const E = "kaching-bundles-block", O = 1e4, Ne = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", A = /* @__PURE__ */ new WeakSet(), j = async (e) => {
|
|
1067
|
+
const t = e.document;
|
|
1068
|
+
if (!e.customElements.get(E)) {
|
|
1069
|
+
if (A.has(t))
|
|
1070
|
+
return D(e, E);
|
|
1071
|
+
A.add(t);
|
|
994
1072
|
try {
|
|
995
|
-
await
|
|
1073
|
+
await Me(e);
|
|
996
1074
|
} catch (s) {
|
|
997
|
-
throw A.delete(
|
|
1075
|
+
throw A.delete(t), s;
|
|
998
1076
|
}
|
|
999
1077
|
}
|
|
1000
|
-
},
|
|
1001
|
-
const
|
|
1002
|
-
return new Promise((s,
|
|
1003
|
-
const n =
|
|
1004
|
-
if (
|
|
1078
|
+
}, Te = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Be = () => Te() ? Ne : Ge, Me = (e) => {
|
|
1079
|
+
const t = e.document;
|
|
1080
|
+
return new Promise((s, a) => {
|
|
1081
|
+
const n = Be();
|
|
1082
|
+
if (t.querySelector(
|
|
1005
1083
|
`script[src="${n}"]`
|
|
1006
1084
|
)) {
|
|
1007
|
-
|
|
1085
|
+
D(e, E).then(s).catch(a);
|
|
1008
1086
|
return;
|
|
1009
1087
|
}
|
|
1010
|
-
const o =
|
|
1011
|
-
o.src = n, o.onload = () =>
|
|
1088
|
+
const o = t.createElement("script");
|
|
1089
|
+
o.src = n, o.onload = () => D(e, E).then(s).catch(a), o.onerror = () => a(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1012
1090
|
});
|
|
1013
|
-
},
|
|
1014
|
-
if (
|
|
1091
|
+
}, D = (e, t) => new Promise((s, a) => {
|
|
1092
|
+
if (e.customElements.get(t)) {
|
|
1015
1093
|
s();
|
|
1016
1094
|
return;
|
|
1017
1095
|
}
|
|
1018
1096
|
Promise.race([
|
|
1019
|
-
|
|
1097
|
+
e.customElements.whenDefined(t),
|
|
1020
1098
|
new Promise(
|
|
1021
|
-
(n,
|
|
1022
|
-
() =>
|
|
1099
|
+
(n, i) => setTimeout(
|
|
1100
|
+
() => i(
|
|
1023
1101
|
new Error(
|
|
1024
|
-
`Custom element "${
|
|
1102
|
+
`Custom element "${t}" failed to register within ${O}ms`
|
|
1025
1103
|
)
|
|
1026
1104
|
),
|
|
1027
|
-
|
|
1105
|
+
O
|
|
1028
1106
|
)
|
|
1029
1107
|
)
|
|
1030
|
-
]).then(() => s()).catch(
|
|
1108
|
+
]).then(() => s()).catch(a);
|
|
1031
1109
|
});
|
|
1032
|
-
var k = /* @__PURE__ */ ((
|
|
1033
|
-
const
|
|
1110
|
+
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
1111
|
+
const qe = {
|
|
1034
1112
|
id: 1,
|
|
1035
1113
|
handle: "example-product",
|
|
1036
1114
|
url: null,
|
|
@@ -1060,7 +1138,7 @@ const Ne = {
|
|
|
1060
1138
|
requiresSellingPlan: !1,
|
|
1061
1139
|
sellingPlans: [],
|
|
1062
1140
|
isNativeBundle: !1
|
|
1063
|
-
},
|
|
1141
|
+
}, Oe = {
|
|
1064
1142
|
id: "example",
|
|
1065
1143
|
nanoId: "example",
|
|
1066
1144
|
blockName: "Bundle",
|
|
@@ -1150,7 +1228,8 @@ const Ne = {
|
|
|
1150
1228
|
productPersonalisation: null,
|
|
1151
1229
|
highlights: null,
|
|
1152
1230
|
sellingPlanEnabled: !1,
|
|
1153
|
-
sellingPlanGid: null
|
|
1231
|
+
sellingPlanGid: null,
|
|
1232
|
+
subscriptionMode: "customer-choice"
|
|
1154
1233
|
},
|
|
1155
1234
|
{
|
|
1156
1235
|
id: "duo",
|
|
@@ -1174,7 +1253,8 @@ const Ne = {
|
|
|
1174
1253
|
productPersonalisation: null,
|
|
1175
1254
|
highlights: null,
|
|
1176
1255
|
sellingPlanEnabled: !1,
|
|
1177
|
-
sellingPlanGid: null
|
|
1256
|
+
sellingPlanGid: null,
|
|
1257
|
+
subscriptionMode: "customer-choice"
|
|
1178
1258
|
},
|
|
1179
1259
|
{
|
|
1180
1260
|
id: "trio",
|
|
@@ -1198,7 +1278,8 @@ const Ne = {
|
|
|
1198
1278
|
productPersonalisation: null,
|
|
1199
1279
|
highlights: null,
|
|
1200
1280
|
sellingPlanEnabled: !1,
|
|
1201
|
-
sellingPlanGid: null
|
|
1281
|
+
sellingPlanGid: null,
|
|
1282
|
+
subscriptionMode: "customer-choice"
|
|
1202
1283
|
}
|
|
1203
1284
|
],
|
|
1204
1285
|
badgesEnabled: !0,
|
|
@@ -1236,7 +1317,7 @@ const Ne = {
|
|
|
1236
1317
|
customStyles: "",
|
|
1237
1318
|
lowStockAlertEnabled: !1,
|
|
1238
1319
|
lowStockAlert: null
|
|
1239
|
-
},
|
|
1320
|
+
}, je = {
|
|
1240
1321
|
shopifyDomain: "",
|
|
1241
1322
|
moneyFormat: "${{amount}}",
|
|
1242
1323
|
locale: "en",
|
|
@@ -1293,16 +1374,16 @@ const Ne = {
|
|
|
1293
1374
|
},
|
|
1294
1375
|
featureFlags: {},
|
|
1295
1376
|
shopCustomStyles: ""
|
|
1296
|
-
},
|
|
1297
|
-
config:
|
|
1298
|
-
dealBlock:
|
|
1299
|
-
product:
|
|
1377
|
+
}, Le = {
|
|
1378
|
+
config: je,
|
|
1379
|
+
dealBlock: Oe,
|
|
1380
|
+
product: qe,
|
|
1300
1381
|
otherProducts: [],
|
|
1301
1382
|
mediaImages: [],
|
|
1302
1383
|
collectionBreaksProducts: [],
|
|
1303
1384
|
translations: {}
|
|
1304
1385
|
};
|
|
1305
|
-
class
|
|
1386
|
+
class Ue extends HTMLElement {
|
|
1306
1387
|
constructor() {
|
|
1307
1388
|
super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
|
|
1308
1389
|
}
|
|
@@ -1313,63 +1394,63 @@ class Me extends HTMLElement {
|
|
|
1313
1394
|
await this.initialize();
|
|
1314
1395
|
}
|
|
1315
1396
|
async initialize() {
|
|
1316
|
-
var o,
|
|
1317
|
-
const
|
|
1397
|
+
var o, r;
|
|
1398
|
+
const t = ++this.initializeId;
|
|
1318
1399
|
if (this.cleanup(), this.hasAttribute("demo")) {
|
|
1319
|
-
if (await
|
|
1320
|
-
this.renderInnerElement(
|
|
1400
|
+
if (await j(window), t !== this.initializeId) return;
|
|
1401
|
+
this.renderInnerElement(Le);
|
|
1321
1402
|
return;
|
|
1322
1403
|
}
|
|
1323
|
-
const s = this.getAttribute("shop-domain"),
|
|
1324
|
-
if (!s || !
|
|
1325
|
-
const [
|
|
1326
|
-
|
|
1404
|
+
const s = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
|
|
1405
|
+
if (!s || !a || !n) return;
|
|
1406
|
+
const [i] = await Promise.all([
|
|
1407
|
+
xe(
|
|
1327
1408
|
{
|
|
1328
1409
|
shopifyDomain: s,
|
|
1329
|
-
storefrontAccessToken:
|
|
1410
|
+
storefrontAccessToken: a
|
|
1330
1411
|
},
|
|
1331
1412
|
{
|
|
1332
1413
|
productId: n,
|
|
1333
1414
|
dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
|
|
1334
1415
|
country: ((o = this.getAttribute("country")) == null ? void 0 : o.toUpperCase()) ?? void 0,
|
|
1335
|
-
language: ((
|
|
1416
|
+
language: ((r = this.getAttribute("language")) == null ? void 0 : r.toUpperCase()) ?? void 0
|
|
1336
1417
|
}
|
|
1337
1418
|
),
|
|
1338
|
-
|
|
1419
|
+
j(window)
|
|
1339
1420
|
]);
|
|
1340
|
-
!
|
|
1421
|
+
!i || t !== this.initializeId || this.renderInnerElement(i);
|
|
1341
1422
|
}
|
|
1342
|
-
renderInnerElement(
|
|
1423
|
+
renderInnerElement(t) {
|
|
1343
1424
|
const {
|
|
1344
1425
|
config: s,
|
|
1345
|
-
dealBlock:
|
|
1426
|
+
dealBlock: a,
|
|
1346
1427
|
product: n,
|
|
1347
|
-
otherProducts:
|
|
1428
|
+
otherProducts: i,
|
|
1348
1429
|
mediaImages: o,
|
|
1349
|
-
collectionBreaksProducts:
|
|
1430
|
+
collectionBreaksProducts: r,
|
|
1350
1431
|
translations: m
|
|
1351
|
-
} =
|
|
1432
|
+
} = t;
|
|
1352
1433
|
this.innerElement = document.createElement(
|
|
1353
1434
|
"kaching-bundles-block"
|
|
1354
|
-
), this.innerElement.setAttribute("deal-block-id",
|
|
1435
|
+
), this.innerElement.setAttribute("deal-block-id", a.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(a)), this.innerElement.setAttribute(
|
|
1355
1436
|
"media-images",
|
|
1356
1437
|
JSON.stringify(o ?? [])
|
|
1357
1438
|
), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
|
|
1358
1439
|
"other-products",
|
|
1359
|
-
JSON.stringify(
|
|
1440
|
+
JSON.stringify(i ?? [])
|
|
1360
1441
|
), this.innerElement.setAttribute(
|
|
1361
1442
|
"collection-breaks-products",
|
|
1362
|
-
JSON.stringify(
|
|
1443
|
+
JSON.stringify(r ?? [])
|
|
1363
1444
|
), this.innerElement.setAttribute(
|
|
1364
1445
|
"translations",
|
|
1365
1446
|
JSON.stringify(m ?? {})
|
|
1366
1447
|
);
|
|
1367
|
-
const
|
|
1448
|
+
const c = this.getAttribute("selected-variant-id");
|
|
1368
1449
|
this.innerElement.setAttribute(
|
|
1369
1450
|
"current-variant-id",
|
|
1370
|
-
String(
|
|
1451
|
+
String(c ? c.split("/").pop() : n.variants[0].id)
|
|
1371
1452
|
), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
|
|
1372
|
-
const u = this.innerElement,
|
|
1453
|
+
const u = this.innerElement, h = () => {
|
|
1373
1454
|
if (this.innerElement !== u) return;
|
|
1374
1455
|
const f = u.items();
|
|
1375
1456
|
f && this.dispatchEvent(
|
|
@@ -1380,13 +1461,13 @@ class Me extends HTMLElement {
|
|
|
1380
1461
|
);
|
|
1381
1462
|
};
|
|
1382
1463
|
this.handleItemsChanged = (f) => {
|
|
1383
|
-
f.stopPropagation(),
|
|
1464
|
+
f.stopPropagation(), h();
|
|
1384
1465
|
};
|
|
1385
|
-
const
|
|
1466
|
+
const g = this.handleItemsChanged;
|
|
1386
1467
|
u.addEventListener(
|
|
1387
1468
|
"kaching-bundles-block-loaded",
|
|
1388
1469
|
() => {
|
|
1389
|
-
this.innerElement === u && (u.addEventListener("items-changed",
|
|
1470
|
+
this.innerElement === u && (u.addEventListener("items-changed", g), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
|
|
1390
1471
|
},
|
|
1391
1472
|
{ once: !0 }
|
|
1392
1473
|
), this.appendChild(this.innerElement);
|
|
@@ -1397,10 +1478,10 @@ class Me extends HTMLElement {
|
|
|
1397
1478
|
this.handleItemsChanged
|
|
1398
1479
|
), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
|
|
1399
1480
|
}
|
|
1400
|
-
attributeChangedCallback(
|
|
1401
|
-
s !==
|
|
1481
|
+
attributeChangedCallback(t, s, a) {
|
|
1482
|
+
s !== a && this.isConnected && (t === "product-id" || t === "country" || t === "language" ? this.initialize() : t === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
|
|
1402
1483
|
"current-variant-id",
|
|
1403
|
-
|
|
1484
|
+
a.includes("/") ? String(a.split("/").pop()) : a
|
|
1404
1485
|
));
|
|
1405
1486
|
}
|
|
1406
1487
|
items() {
|
|
@@ -1410,7 +1491,7 @@ class Me extends HTMLElement {
|
|
|
1410
1491
|
this.cleanup(), this.initializeId++;
|
|
1411
1492
|
}
|
|
1412
1493
|
}
|
|
1413
|
-
customElements.define("kaching-bundle-component",
|
|
1494
|
+
customElements.define("kaching-bundle-component", Ue);
|
|
1414
1495
|
export {
|
|
1415
|
-
|
|
1496
|
+
xe as fetchKachingBundlesData
|
|
1416
1497
|
};
|