@kachingappz/bundles-js 1.1.0 → 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/dist/bundles-js.iife.js +24 -24
- package/dist/index.d.ts +8 -9
- package/dist/index.js +479 -400
- package/dist/kaching-bundle-component/index.d.ts +8 -9
- package/dist/kaching-bundle-component/index.js +615 -536
- package/dist/react/index.cjs +26 -26
- package/dist/react/index.d.ts +8 -9
- package/dist/react/index.js +450 -371
- package/package.json +5 -5
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
(
|
|
1
|
+
const F = (e, t) => {
|
|
2
|
+
const a = [], s = e.filter(
|
|
3
|
+
(r) => r.blockVisibility === "selected-products"
|
|
4
4
|
);
|
|
5
|
-
for (const
|
|
6
|
-
|
|
7
|
-
const n =
|
|
8
|
-
(
|
|
5
|
+
for (const r of s)
|
|
6
|
+
r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
|
|
7
|
+
const n = e.filter(
|
|
8
|
+
(r) => r.blockVisibility === "selected-collections"
|
|
9
9
|
);
|
|
10
|
-
for (const
|
|
11
|
-
|
|
12
|
-
(m) =>
|
|
13
|
-
) &&
|
|
14
|
-
const
|
|
15
|
-
(
|
|
10
|
+
for (const r of n)
|
|
11
|
+
t.collectionIds.some(
|
|
12
|
+
(m) => r.selectedCollectionIds.map(Number).includes(m)
|
|
13
|
+
) && a.push(r);
|
|
14
|
+
const i = e.filter(
|
|
15
|
+
(r) => r.blockVisibility === "excluded-products"
|
|
16
16
|
);
|
|
17
|
-
for (const
|
|
18
|
-
!
|
|
19
|
-
(m) =>
|
|
20
|
-
) &&
|
|
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
|
+
) && a.push(r);
|
|
21
|
+
const o = e.filter(
|
|
22
|
+
(r) => r.blockVisibility === "all-products"
|
|
23
23
|
);
|
|
24
|
-
for (const
|
|
25
|
-
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
var
|
|
29
|
-
const
|
|
24
|
+
for (const r of o)
|
|
25
|
+
a.push(r);
|
|
26
|
+
return a;
|
|
27
|
+
}, z = (e, { language: t, country: a }) => {
|
|
28
|
+
var h, g;
|
|
29
|
+
const s = R(t, a), n = new Intl.NumberFormat(s, {
|
|
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, 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
|
+
country: e,
|
|
47
|
+
language: t
|
|
48
48
|
}) => {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
51
|
-
},
|
|
52
|
-
useExternalMetafieldNamespace:
|
|
53
|
-
useMetaobjects:
|
|
54
|
-
}) =>
|
|
55
|
-
|
|
56
|
-
) :
|
|
57
|
-
var
|
|
58
|
-
const
|
|
49
|
+
const a = [];
|
|
50
|
+
return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
|
|
51
|
+
}, H = async (e, {
|
|
52
|
+
useExternalMetafieldNamespace: t,
|
|
53
|
+
useMetaobjects: a
|
|
54
|
+
}) => a ? W(
|
|
55
|
+
e
|
|
56
|
+
) : X(e), X = async (e, t) => {
|
|
57
|
+
var s;
|
|
58
|
+
const a = (s = (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 :
|
|
74
|
-
return
|
|
75
|
-
},
|
|
76
|
-
const
|
|
73
|
+
)).shop.metafield) == null ? void 0 : s.value;
|
|
74
|
+
return a ? JSON.parse(a) : [];
|
|
75
|
+
}, W = async (e, t) => {
|
|
76
|
+
const a = "app--2935586817--deal_block", s = [];
|
|
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) {
|
|
@@ -95,40 +95,40 @@ const U = (t, e) => {
|
|
|
95
95
|
`,
|
|
96
96
|
{
|
|
97
97
|
variables: {
|
|
98
|
-
type:
|
|
98
|
+
type: a,
|
|
99
99
|
cursor: n
|
|
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 && s.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:
|
|
116
|
-
language:
|
|
117
|
-
blockVisibility:
|
|
113
|
+
return s;
|
|
114
|
+
}, N = async (e, {
|
|
115
|
+
country: t,
|
|
116
|
+
language: a,
|
|
117
|
+
blockVisibility: s,
|
|
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 (s) {
|
|
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: a });
|
|
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 (s === "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: a }), 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:
|
|
233
|
-
language:
|
|
234
|
-
productIds:
|
|
231
|
+
`, $ = async (e, {
|
|
232
|
+
country: t,
|
|
233
|
+
language: a,
|
|
234
|
+
productIds: s,
|
|
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 (!s.length)
|
|
242
243
|
return [];
|
|
243
|
-
const
|
|
244
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String
|
|
244
|
+
const u = s.map((p) => typeof p == "string" && p.startsWith("gid://") ? p : `gid://shopify/Product/${p}`), h = w({ country: t, language: a }), 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 (t,
|
|
396
|
-
if (
|
|
397
|
-
return
|
|
398
|
-
const n = /* @__PURE__ */ new Set(),
|
|
399
|
-
let
|
|
400
|
-
for (;
|
|
401
|
-
const
|
|
402
|
+
}, G = async (e, t, a, s = "") => {
|
|
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) ${s} {
|
|
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
|
+
...a
|
|
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, a) => {
|
|
448
|
+
var c, u, h, g, f, v;
|
|
449
|
+
const s = 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, s)
|
|
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) => a === 1 ? Number(l) * 100 : Math.round(Number(l) * 100 * a), 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: s,
|
|
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:
|
|
560
|
-
country:
|
|
561
|
-
useExternalMetafieldNamespace:
|
|
563
|
+
}, K = (e, t, a) => e.filter((s) => a.filter(
|
|
564
|
+
(n) => n.options[t] === s.name
|
|
565
|
+
).length > 0), B = "app--2935586817", Y = async (e, {
|
|
566
|
+
language: t,
|
|
567
|
+
country: a,
|
|
568
|
+
useExternalMetafieldNamespace: s
|
|
562
569
|
}) => {
|
|
563
|
-
const n = `${
|
|
570
|
+
const n = `${B}--kaching_bundles`, i = B, o = w({ country: a }), {
|
|
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: a }), 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: (
|
|
615
|
-
country:
|
|
620
|
+
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
621
|
+
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
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: (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,304 +664,376 @@ 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, a = 200) => {
|
|
678
|
+
const s = [
|
|
679
|
+
...new Set(
|
|
680
|
+
t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
|
|
681
|
+
)
|
|
682
|
+
];
|
|
683
|
+
if (s.length === 0) return [];
|
|
684
|
+
const n = [];
|
|
685
|
+
for (let i = 0; i < s.length; i += 250)
|
|
686
|
+
n.push(s.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: a
|
|
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
|
-
|
|
705
|
-
|
|
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(
|
|
710
|
-
(s) => s.mediaImageGID
|
|
708
|
+
)
|
|
709
|
+
)
|
|
710
|
+
)).flatMap((i) => i.nodes).filter(Boolean).map((i) => ({
|
|
711
|
+
gid: i.id,
|
|
712
|
+
url: i.image.url
|
|
713
|
+
}));
|
|
714
|
+
};
|
|
715
|
+
var S = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(S || {});
|
|
716
|
+
const te = (e) => [
|
|
717
|
+
...ae(e),
|
|
718
|
+
...se(e),
|
|
719
|
+
...ne(e),
|
|
720
|
+
...le(e),
|
|
721
|
+
...re(e),
|
|
722
|
+
...ie(e),
|
|
723
|
+
...oe(e),
|
|
724
|
+
...ce(e),
|
|
725
|
+
...ue(e),
|
|
726
|
+
...de(e),
|
|
727
|
+
...me(e),
|
|
728
|
+
...pe(e),
|
|
729
|
+
...fe(e)
|
|
730
|
+
].filter((t) => t != null && !t.includes("placeholder")), ae = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), se = (e) => e.dealBars.flatMap(
|
|
731
|
+
(t) => t.dealBarType === S.Bundle ? t.bundleProducts.map(
|
|
732
|
+
(a) => a.mediaImageGID
|
|
711
733
|
) : []
|
|
712
|
-
).filter((
|
|
713
|
-
({ freeGifts:
|
|
714
|
-
).reduce((
|
|
715
|
-
({ multipleGiftsSelectors:
|
|
716
|
-
).filter((
|
|
717
|
-
const
|
|
718
|
-
return [...
|
|
719
|
-
}, []) : [],
|
|
720
|
-
if (!
|
|
734
|
+
).filter((t) => t != null), ne = (e) => e.dealBars.map(
|
|
735
|
+
({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
736
|
+
).reduce((t, a) => t.concat(a), []).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
|
|
737
|
+
({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
738
|
+
).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
|
|
739
|
+
const s = a.images.map((n) => n.mediaImageGID).filter((n) => n != null);
|
|
740
|
+
return [...t, ...s];
|
|
741
|
+
}, []) : [], oe = (e) => {
|
|
742
|
+
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
721
743
|
return [];
|
|
722
|
-
const
|
|
723
|
-
return
|
|
724
|
-
},
|
|
725
|
-
var
|
|
726
|
-
return
|
|
727
|
-
...((
|
|
728
|
-
(
|
|
729
|
-
(
|
|
744
|
+
const t = e.collectionBreaks.mediaImageGID;
|
|
745
|
+
return t ? [t] : [];
|
|
746
|
+
}, ce = (e) => {
|
|
747
|
+
var t, a, s;
|
|
748
|
+
return e.progressiveGifts ? [
|
|
749
|
+
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
|
|
750
|
+
(a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
|
|
751
|
+
(s = e.progressiveGifts.dealBarStyle) == null ? void 0 : s.lockedMediaImageGID
|
|
730
752
|
].filter((n) => n != null) : [];
|
|
731
|
-
},
|
|
732
|
-
var
|
|
733
|
-
return (
|
|
734
|
-
}).filter((
|
|
735
|
-
var
|
|
736
|
-
const
|
|
753
|
+
}, 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) => {
|
|
754
|
+
var a;
|
|
755
|
+
return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
|
|
756
|
+
}).filter((t) => t != null), me = (e) => {
|
|
757
|
+
var s, n;
|
|
758
|
+
const t = e.dealBars.map((i) => {
|
|
737
759
|
var o;
|
|
738
|
-
return (o =
|
|
739
|
-
}).filter((
|
|
740
|
-
return
|
|
741
|
-
},
|
|
742
|
-
(
|
|
743
|
-
),
|
|
744
|
-
const
|
|
745
|
-
...
|
|
746
|
-
...
|
|
747
|
-
...
|
|
748
|
-
...
|
|
749
|
-
...
|
|
750
|
-
...
|
|
751
|
-
...
|
|
752
|
-
...
|
|
760
|
+
return (o = i.highlights) == null ? void 0 : o.customIconGID;
|
|
761
|
+
}).filter((i) => i != null), a = (n = (s = e.subscriptions) == null ? void 0 : s.highlights) == null ? void 0 : n.customIconGID;
|
|
762
|
+
return a ? [...t, a] : t;
|
|
763
|
+
}, pe = (e) => (e.badges || []).flatMap(
|
|
764
|
+
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
765
|
+
), fe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
|
|
766
|
+
const t = [
|
|
767
|
+
...ge(e),
|
|
768
|
+
...ye(e),
|
|
769
|
+
...be(e),
|
|
770
|
+
...ve(e),
|
|
771
|
+
...Ie(e),
|
|
772
|
+
..._e(e),
|
|
773
|
+
...Pe(e),
|
|
774
|
+
...Se(e)
|
|
753
775
|
];
|
|
754
|
-
return Array.from(new Set(
|
|
755
|
-
},
|
|
756
|
-
({ freeGifts:
|
|
757
|
-
).filter((
|
|
758
|
-
({ multipleGiftsSelectors:
|
|
759
|
-
(
|
|
776
|
+
return Array.from(new Set(t.filter((a) => a != null)));
|
|
777
|
+
}, ge = (e) => e.dealBars.flatMap(
|
|
778
|
+
({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
|
|
779
|
+
).filter((t) => t != null), ye = (e) => e.dealBars.flatMap(
|
|
780
|
+
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
781
|
+
(a) => a.products ? a.products.map((s) => s.id) : []
|
|
760
782
|
) : []
|
|
761
|
-
).filter((
|
|
762
|
-
var
|
|
763
|
-
return
|
|
764
|
-
},
|
|
765
|
-
({ bundleProducts:
|
|
766
|
-
).filter((
|
|
767
|
-
({ bundleProducts:
|
|
768
|
-
var
|
|
783
|
+
).filter((t) => t != null), be = (e) => {
|
|
784
|
+
var t;
|
|
785
|
+
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
|
|
786
|
+
}, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === S.Bundle).flatMap(
|
|
787
|
+
({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
|
|
788
|
+
).filter((t) => t != null).filter((t) => t !== "default"), _e = (e) => e.dealBars.filter((t) => t.dealBarType === S.MixAndMatch).flatMap(
|
|
789
|
+
({ bundleProducts: t }) => t ? t.flatMap((a) => {
|
|
790
|
+
var s;
|
|
769
791
|
return [
|
|
770
|
-
|
|
771
|
-
...((
|
|
792
|
+
a.productGID,
|
|
793
|
+
...((s = a.selectedProducts) == null ? void 0 : s.map((n) => n.id)) ?? []
|
|
772
794
|
];
|
|
773
795
|
}) : []
|
|
774
|
-
).filter((
|
|
775
|
-
class
|
|
776
|
-
constructor(
|
|
777
|
-
|
|
796
|
+
).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] : []);
|
|
797
|
+
class M extends Error {
|
|
798
|
+
constructor({
|
|
799
|
+
status: t,
|
|
800
|
+
operationName: a,
|
|
801
|
+
graphqlErrors: s
|
|
802
|
+
}) {
|
|
803
|
+
const n = s.length ? `: ${s.join("; ")}` : "";
|
|
804
|
+
super(
|
|
805
|
+
`Storefront API ${a ?? "query"} failed (HTTP ${t})${n}`
|
|
806
|
+
), this.name = "StorefrontApiError", this.status = t, this.operationName = a, this.graphqlErrors = s;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
const ke = async (e, t) => {
|
|
810
|
+
const a = await e.text();
|
|
811
|
+
if (!a)
|
|
812
|
+
throw new Error("Empty graphql response");
|
|
813
|
+
let s;
|
|
814
|
+
try {
|
|
815
|
+
s = JSON.parse(a);
|
|
816
|
+
} catch (n) {
|
|
817
|
+
throw e.ok ? n : new M({
|
|
818
|
+
status: e.status,
|
|
819
|
+
operationName: t,
|
|
820
|
+
graphqlErrors: []
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
if (!e.ok || s.data === null || s.data === void 0)
|
|
824
|
+
throw new M({
|
|
825
|
+
status: e.status,
|
|
826
|
+
operationName: t,
|
|
827
|
+
graphqlErrors: (s.errors ?? []).map(({ message: n }) => n).filter(Boolean)
|
|
828
|
+
});
|
|
829
|
+
return s.data;
|
|
830
|
+
};
|
|
831
|
+
class we {
|
|
832
|
+
constructor(t, a) {
|
|
833
|
+
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
|
|
778
834
|
}
|
|
779
|
-
async query(
|
|
780
|
-
var
|
|
781
|
-
const
|
|
835
|
+
async query(t, a) {
|
|
836
|
+
var r;
|
|
837
|
+
const s = (a == null ? void 0 : a.variables) ?? {};
|
|
782
838
|
let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const o = await
|
|
839
|
+
const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
|
|
840
|
+
i && (n += `?operation_name=${i}`);
|
|
841
|
+
const o = await fetch(n, {
|
|
786
842
|
method: "POST",
|
|
787
843
|
headers: {
|
|
788
844
|
"Content-Type": "application/json",
|
|
789
845
|
"X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
|
|
790
846
|
},
|
|
791
847
|
body: JSON.stringify({
|
|
792
|
-
query:
|
|
793
|
-
variables:
|
|
848
|
+
query: t,
|
|
849
|
+
variables: s
|
|
794
850
|
})
|
|
795
|
-
})
|
|
796
|
-
|
|
797
|
-
throw new Error("Empty graphql response");
|
|
798
|
-
return JSON.parse(o).data;
|
|
851
|
+
});
|
|
852
|
+
return ke(o, i);
|
|
799
853
|
}
|
|
800
854
|
}
|
|
801
|
-
const
|
|
802
|
-
const n =
|
|
803
|
-
if (!
|
|
804
|
-
let
|
|
805
|
-
n.visibility === "deal-products" ?
|
|
806
|
-
country:
|
|
807
|
-
language:
|
|
808
|
-
blockVisibility:
|
|
809
|
-
excludedProductGIDs: (
|
|
810
|
-
(
|
|
855
|
+
const Ee = async (e, t, { country: a, language: s }) => {
|
|
856
|
+
const n = t.collectionBreaks;
|
|
857
|
+
if (!t.collectionBreaksEnabled || !n) return;
|
|
858
|
+
let i;
|
|
859
|
+
n.visibility === "deal-products" ? i = await N(e, {
|
|
860
|
+
country: a,
|
|
861
|
+
language: s,
|
|
862
|
+
blockVisibility: t.blockVisibility,
|
|
863
|
+
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
864
|
+
(r) => `gid://shopify/Product/${r}`
|
|
811
865
|
),
|
|
812
|
-
selectedProductGIDs: (
|
|
813
|
-
(
|
|
866
|
+
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
867
|
+
(r) => `gid://shopify/Product/${r}`
|
|
814
868
|
),
|
|
815
|
-
selectedCollectionGIDs: (
|
|
816
|
-
(
|
|
869
|
+
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
870
|
+
(r) => `gid://shopify/Collection/${r}`
|
|
817
871
|
)
|
|
818
|
-
}) :
|
|
819
|
-
country:
|
|
820
|
-
language:
|
|
872
|
+
}) : i = await N(e, {
|
|
873
|
+
country: a,
|
|
874
|
+
language: s,
|
|
821
875
|
blockVisibility: n.visibility,
|
|
822
876
|
excludedProductGIDs: (n.excludedProducts || []).map(
|
|
823
|
-
({ id:
|
|
877
|
+
({ id: r }) => r
|
|
824
878
|
),
|
|
825
879
|
selectedProductGIDs: (n.selectedProducts || []).map(
|
|
826
|
-
({ id:
|
|
880
|
+
({ id: r }) => r
|
|
827
881
|
),
|
|
828
882
|
selectedCollectionGIDs: (n.selectedCollections || []).map(
|
|
829
|
-
({ id:
|
|
883
|
+
({ id: r }) => r
|
|
830
884
|
)
|
|
831
885
|
});
|
|
832
|
-
let o = await
|
|
833
|
-
country:
|
|
834
|
-
language:
|
|
835
|
-
productIds:
|
|
886
|
+
let o = await $(e, {
|
|
887
|
+
country: a,
|
|
888
|
+
language: s,
|
|
889
|
+
productIds: i.map((r) => Number(r.split("/").pop())),
|
|
836
890
|
useExternalMetafieldNamespace: !0
|
|
837
891
|
});
|
|
838
892
|
return o = o.filter(
|
|
839
|
-
(
|
|
893
|
+
(r) => r.availableForSale
|
|
840
894
|
), 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
|
-
|
|
868
|
-
|
|
869
|
-
|
|
895
|
+
}, Ae = ({
|
|
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
|
+
}, s = e ? $e(e) : void 0;
|
|
925
|
+
return {
|
|
926
|
+
...a,
|
|
927
|
+
...s == null ? void 0 : s.system,
|
|
928
|
+
...s == null ? void 0 : s.dealBlocks[t]
|
|
929
|
+
};
|
|
930
|
+
}, $e = (e) => {
|
|
931
|
+
var n;
|
|
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 s = q(e);
|
|
942
|
+
return (n = a.find(
|
|
943
|
+
(i) => q(i.locale) === s
|
|
944
|
+
)) == null ? void 0 : n.translations;
|
|
945
|
+
}, q = (e) => e.toLowerCase().replace(/_/g, "-"), De = "2026-07", xe = async (e, {
|
|
946
|
+
productId: t,
|
|
947
|
+
dealBlockId: a,
|
|
948
|
+
country: s = void 0,
|
|
870
949
|
language: n = void 0
|
|
871
950
|
}) => {
|
|
872
|
-
var
|
|
951
|
+
var i, o;
|
|
873
952
|
try {
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
const
|
|
953
|
+
const r = [Number(t.split("/").pop())], m = new Ce(e);
|
|
954
|
+
s = s || ((i = m.i18n) == null ? void 0 : i.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
|
|
955
|
+
const c = await Y(m, {
|
|
877
956
|
language: n,
|
|
878
|
-
country:
|
|
957
|
+
country: s,
|
|
879
958
|
useExternalMetafieldNamespace: !0
|
|
880
959
|
});
|
|
881
|
-
m.shopifyDomain =
|
|
882
|
-
const u =
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
) : m, [
|
|
886
|
-
|
|
887
|
-
country:
|
|
960
|
+
m.shopifyDomain = c.shopifyDomain;
|
|
961
|
+
const u = c.storefrontAccessToken ? new we(
|
|
962
|
+
c.shopifyDomain,
|
|
963
|
+
c.storefrontAccessToken
|
|
964
|
+
) : m, [h, g] = await Promise.all([
|
|
965
|
+
$(u, {
|
|
966
|
+
country: s,
|
|
888
967
|
language: n,
|
|
889
|
-
productIds:
|
|
968
|
+
productIds: r,
|
|
890
969
|
useExternalMetafieldNamespace: !0
|
|
891
970
|
}),
|
|
892
|
-
|
|
971
|
+
H(u, {
|
|
893
972
|
useExternalMetafieldNamespace: !0,
|
|
894
|
-
useMetaobjects:
|
|
973
|
+
useMetaobjects: c.featureFlags.storefront_metaobjects
|
|
895
974
|
})
|
|
896
|
-
]), f =
|
|
975
|
+
]), f = h[0];
|
|
897
976
|
if (!f)
|
|
898
977
|
return null;
|
|
899
|
-
const v =
|
|
900
|
-
let
|
|
901
|
-
if (
|
|
902
|
-
(P) => P.id ===
|
|
903
|
-
),
|
|
978
|
+
const v = F(g, f);
|
|
979
|
+
let l;
|
|
980
|
+
if (a ? (l = v.find(
|
|
981
|
+
(P) => P.id === a || P.nanoId === a
|
|
982
|
+
), l || (l = v[0])) : l = v[0], !l)
|
|
904
983
|
return null;
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
country:
|
|
984
|
+
const d = te(l), y = he(l), [_, I, p, b] = await Promise.all([
|
|
985
|
+
$(u, {
|
|
986
|
+
country: s,
|
|
908
987
|
language: n,
|
|
909
|
-
productIds:
|
|
988
|
+
productIds: y,
|
|
910
989
|
useExternalMetafieldNamespace: !0
|
|
911
990
|
}),
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
country:
|
|
991
|
+
ee(u, d, 300),
|
|
992
|
+
Ee(u, l, {
|
|
993
|
+
country: s,
|
|
915
994
|
language: n
|
|
916
995
|
}),
|
|
917
|
-
|
|
996
|
+
Ae({ language: n, dealBlockId: l.id })
|
|
918
997
|
]);
|
|
919
998
|
return {
|
|
920
999
|
product: f,
|
|
921
|
-
dealBlock:
|
|
922
|
-
config:
|
|
1000
|
+
dealBlock: l,
|
|
1001
|
+
config: c,
|
|
923
1002
|
otherProducts: _,
|
|
924
|
-
mediaImages:
|
|
925
|
-
collectionBreaksProducts:
|
|
926
|
-
translations:
|
|
1003
|
+
mediaImages: I,
|
|
1004
|
+
collectionBreaksProducts: p ?? [],
|
|
1005
|
+
translations: b
|
|
927
1006
|
};
|
|
928
|
-
} catch (
|
|
929
|
-
return console.error(
|
|
1007
|
+
} catch (r) {
|
|
1008
|
+
return console.error(r), null;
|
|
930
1009
|
}
|
|
931
1010
|
};
|
|
932
|
-
class
|
|
933
|
-
constructor(
|
|
934
|
-
this.storefront =
|
|
1011
|
+
class Ce {
|
|
1012
|
+
constructor(t) {
|
|
1013
|
+
this.storefront = t, this.shopifyDomain = "";
|
|
935
1014
|
}
|
|
936
|
-
async query(
|
|
937
|
-
var
|
|
1015
|
+
async query(t, a) {
|
|
1016
|
+
var s;
|
|
938
1017
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
939
|
-
return await this.storefront.query(
|
|
1018
|
+
return await this.storefront.query(t, a);
|
|
940
1019
|
if ("graphql" in this.storefront) {
|
|
941
|
-
const n = await this.storefront.graphql(
|
|
942
|
-
if ((
|
|
1020
|
+
const n = await this.storefront.graphql(t, a);
|
|
1021
|
+
if ((s = n.errors) != null && s.length)
|
|
943
1022
|
throw new Error(
|
|
944
|
-
n.errors.map((
|
|
1023
|
+
n.errors.map((i) => i.message).join(`
|
|
945
1024
|
`)
|
|
946
1025
|
);
|
|
947
1026
|
return n.data;
|
|
948
1027
|
}
|
|
949
1028
|
if ("request" in this.storefront)
|
|
950
|
-
return (await this.storefront.request(
|
|
1029
|
+
return (await this.storefront.request(t, a)).data;
|
|
951
1030
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
952
1031
|
const n = await fetch(
|
|
953
|
-
`https://${this.storefront.shopifyDomain}/api/${
|
|
1032
|
+
`https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
|
|
954
1033
|
{
|
|
955
1034
|
body: JSON.stringify({
|
|
956
|
-
query:
|
|
957
|
-
variables:
|
|
1035
|
+
query: t,
|
|
1036
|
+
variables: a == null ? void 0 : a.variables
|
|
958
1037
|
}),
|
|
959
1038
|
headers: {
|
|
960
1039
|
"Content-Type": "application/json",
|
|
@@ -969,8 +1048,8 @@ class Ee {
|
|
|
969
1048
|
} else {
|
|
970
1049
|
const n = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
971
1050
|
body: JSON.stringify({
|
|
972
|
-
query:
|
|
973
|
-
variables:
|
|
1051
|
+
query: t,
|
|
1052
|
+
variables: a == null ? void 0 : a.variables
|
|
974
1053
|
}),
|
|
975
1054
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
976
1055
|
method: "POST"
|
|
@@ -985,52 +1064,52 @@ class Ee {
|
|
|
985
1064
|
return this.storefront.i18n;
|
|
986
1065
|
}
|
|
987
1066
|
}
|
|
988
|
-
const E = "kaching-bundles-block",
|
|
989
|
-
const
|
|
990
|
-
if (!
|
|
991
|
-
if (A.has(
|
|
992
|
-
return
|
|
993
|
-
A.add(
|
|
1067
|
+
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) => {
|
|
1068
|
+
const t = e.document;
|
|
1069
|
+
if (!e.customElements.get(E)) {
|
|
1070
|
+
if (A.has(t))
|
|
1071
|
+
return D(e, E);
|
|
1072
|
+
A.add(t);
|
|
994
1073
|
try {
|
|
995
|
-
await
|
|
996
|
-
} catch (
|
|
997
|
-
throw A.delete(
|
|
1074
|
+
await Me(e);
|
|
1075
|
+
} catch (a) {
|
|
1076
|
+
throw A.delete(t), a;
|
|
998
1077
|
}
|
|
999
1078
|
}
|
|
1000
|
-
},
|
|
1001
|
-
const
|
|
1002
|
-
return new Promise((
|
|
1003
|
-
const n =
|
|
1004
|
-
if (
|
|
1079
|
+
}, Te = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Be = () => Te() ? Ne : Ge, Me = (e) => {
|
|
1080
|
+
const t = e.document;
|
|
1081
|
+
return new Promise((a, s) => {
|
|
1082
|
+
const n = Be();
|
|
1083
|
+
if (t.querySelector(
|
|
1005
1084
|
`script[src="${n}"]`
|
|
1006
1085
|
)) {
|
|
1007
|
-
|
|
1086
|
+
D(e, E).then(a).catch(s);
|
|
1008
1087
|
return;
|
|
1009
1088
|
}
|
|
1010
|
-
const o =
|
|
1011
|
-
o.src = n, o.onload = () =>
|
|
1089
|
+
const o = t.createElement("script");
|
|
1090
|
+
o.src = n, o.onload = () => D(e, E).then(a).catch(s), o.onerror = () => s(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1012
1091
|
});
|
|
1013
|
-
},
|
|
1014
|
-
if (
|
|
1015
|
-
|
|
1092
|
+
}, D = (e, t) => new Promise((a, s) => {
|
|
1093
|
+
if (e.customElements.get(t)) {
|
|
1094
|
+
a();
|
|
1016
1095
|
return;
|
|
1017
1096
|
}
|
|
1018
1097
|
Promise.race([
|
|
1019
|
-
|
|
1098
|
+
e.customElements.whenDefined(t),
|
|
1020
1099
|
new Promise(
|
|
1021
|
-
(n,
|
|
1022
|
-
() =>
|
|
1100
|
+
(n, i) => setTimeout(
|
|
1101
|
+
() => i(
|
|
1023
1102
|
new Error(
|
|
1024
|
-
`Custom element "${
|
|
1103
|
+
`Custom element "${t}" failed to register within ${O}ms`
|
|
1025
1104
|
)
|
|
1026
1105
|
),
|
|
1027
|
-
|
|
1106
|
+
O
|
|
1028
1107
|
)
|
|
1029
1108
|
)
|
|
1030
|
-
]).then(() =>
|
|
1109
|
+
]).then(() => a()).catch(s);
|
|
1031
1110
|
});
|
|
1032
|
-
var k = /* @__PURE__ */ ((
|
|
1033
|
-
const
|
|
1111
|
+
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
1112
|
+
const qe = {
|
|
1034
1113
|
id: 1,
|
|
1035
1114
|
handle: "example-product",
|
|
1036
1115
|
url: null,
|
|
@@ -1060,7 +1139,7 @@ const Ne = {
|
|
|
1060
1139
|
requiresSellingPlan: !1,
|
|
1061
1140
|
sellingPlans: [],
|
|
1062
1141
|
isNativeBundle: !1
|
|
1063
|
-
},
|
|
1142
|
+
}, Oe = {
|
|
1064
1143
|
id: "example",
|
|
1065
1144
|
nanoId: "example",
|
|
1066
1145
|
blockName: "Bundle",
|
|
@@ -1236,7 +1315,7 @@ const Ne = {
|
|
|
1236
1315
|
customStyles: "",
|
|
1237
1316
|
lowStockAlertEnabled: !1,
|
|
1238
1317
|
lowStockAlert: null
|
|
1239
|
-
},
|
|
1318
|
+
}, je = {
|
|
1240
1319
|
shopifyDomain: "",
|
|
1241
1320
|
moneyFormat: "${{amount}}",
|
|
1242
1321
|
locale: "en",
|
|
@@ -1293,16 +1372,16 @@ const Ne = {
|
|
|
1293
1372
|
},
|
|
1294
1373
|
featureFlags: {},
|
|
1295
1374
|
shopCustomStyles: ""
|
|
1296
|
-
},
|
|
1297
|
-
config:
|
|
1298
|
-
dealBlock:
|
|
1299
|
-
product:
|
|
1375
|
+
}, Le = {
|
|
1376
|
+
config: je,
|
|
1377
|
+
dealBlock: Oe,
|
|
1378
|
+
product: qe,
|
|
1300
1379
|
otherProducts: [],
|
|
1301
1380
|
mediaImages: [],
|
|
1302
1381
|
collectionBreaksProducts: [],
|
|
1303
1382
|
translations: {}
|
|
1304
1383
|
};
|
|
1305
|
-
class
|
|
1384
|
+
class Ue extends HTMLElement {
|
|
1306
1385
|
constructor() {
|
|
1307
1386
|
super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
|
|
1308
1387
|
}
|
|
@@ -1313,63 +1392,63 @@ class Me extends HTMLElement {
|
|
|
1313
1392
|
await this.initialize();
|
|
1314
1393
|
}
|
|
1315
1394
|
async initialize() {
|
|
1316
|
-
var o,
|
|
1317
|
-
const
|
|
1395
|
+
var o, r;
|
|
1396
|
+
const t = ++this.initializeId;
|
|
1318
1397
|
if (this.cleanup(), this.hasAttribute("demo")) {
|
|
1319
|
-
if (await
|
|
1320
|
-
this.renderInnerElement(
|
|
1398
|
+
if (await j(window), t !== this.initializeId) return;
|
|
1399
|
+
this.renderInnerElement(Le);
|
|
1321
1400
|
return;
|
|
1322
1401
|
}
|
|
1323
|
-
const
|
|
1324
|
-
if (!
|
|
1325
|
-
const [
|
|
1326
|
-
|
|
1402
|
+
const a = this.getAttribute("shop-domain"), s = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
|
|
1403
|
+
if (!a || !s || !n) return;
|
|
1404
|
+
const [i] = await Promise.all([
|
|
1405
|
+
xe(
|
|
1327
1406
|
{
|
|
1328
|
-
shopifyDomain:
|
|
1329
|
-
storefrontAccessToken:
|
|
1407
|
+
shopifyDomain: a,
|
|
1408
|
+
storefrontAccessToken: s
|
|
1330
1409
|
},
|
|
1331
1410
|
{
|
|
1332
1411
|
productId: n,
|
|
1333
1412
|
dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
|
|
1334
1413
|
country: ((o = this.getAttribute("country")) == null ? void 0 : o.toUpperCase()) ?? void 0,
|
|
1335
|
-
language: ((
|
|
1414
|
+
language: ((r = this.getAttribute("language")) == null ? void 0 : r.toUpperCase()) ?? void 0
|
|
1336
1415
|
}
|
|
1337
1416
|
),
|
|
1338
|
-
|
|
1417
|
+
j(window)
|
|
1339
1418
|
]);
|
|
1340
|
-
!
|
|
1419
|
+
!i || t !== this.initializeId || this.renderInnerElement(i);
|
|
1341
1420
|
}
|
|
1342
|
-
renderInnerElement(
|
|
1421
|
+
renderInnerElement(t) {
|
|
1343
1422
|
const {
|
|
1344
|
-
config:
|
|
1345
|
-
dealBlock:
|
|
1423
|
+
config: a,
|
|
1424
|
+
dealBlock: s,
|
|
1346
1425
|
product: n,
|
|
1347
|
-
otherProducts:
|
|
1426
|
+
otherProducts: i,
|
|
1348
1427
|
mediaImages: o,
|
|
1349
|
-
collectionBreaksProducts:
|
|
1428
|
+
collectionBreaksProducts: r,
|
|
1350
1429
|
translations: m
|
|
1351
|
-
} =
|
|
1430
|
+
} = t;
|
|
1352
1431
|
this.innerElement = document.createElement(
|
|
1353
1432
|
"kaching-bundles-block"
|
|
1354
|
-
), this.innerElement.setAttribute("deal-block-id",
|
|
1433
|
+
), this.innerElement.setAttribute("deal-block-id", s.id), this.innerElement.setAttribute("config", JSON.stringify(a)), this.innerElement.setAttribute("deal-block", JSON.stringify(s)), this.innerElement.setAttribute(
|
|
1355
1434
|
"media-images",
|
|
1356
1435
|
JSON.stringify(o ?? [])
|
|
1357
1436
|
), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
|
|
1358
1437
|
"other-products",
|
|
1359
|
-
JSON.stringify(
|
|
1438
|
+
JSON.stringify(i ?? [])
|
|
1360
1439
|
), this.innerElement.setAttribute(
|
|
1361
1440
|
"collection-breaks-products",
|
|
1362
|
-
JSON.stringify(
|
|
1441
|
+
JSON.stringify(r ?? [])
|
|
1363
1442
|
), this.innerElement.setAttribute(
|
|
1364
1443
|
"translations",
|
|
1365
1444
|
JSON.stringify(m ?? {})
|
|
1366
1445
|
);
|
|
1367
|
-
const
|
|
1446
|
+
const c = this.getAttribute("selected-variant-id");
|
|
1368
1447
|
this.innerElement.setAttribute(
|
|
1369
1448
|
"current-variant-id",
|
|
1370
|
-
String(
|
|
1449
|
+
String(c ? c.split("/").pop() : n.variants[0].id)
|
|
1371
1450
|
), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
|
|
1372
|
-
const u = this.innerElement,
|
|
1451
|
+
const u = this.innerElement, h = () => {
|
|
1373
1452
|
if (this.innerElement !== u) return;
|
|
1374
1453
|
const f = u.items();
|
|
1375
1454
|
f && this.dispatchEvent(
|
|
@@ -1380,13 +1459,13 @@ class Me extends HTMLElement {
|
|
|
1380
1459
|
);
|
|
1381
1460
|
};
|
|
1382
1461
|
this.handleItemsChanged = (f) => {
|
|
1383
|
-
f.stopPropagation(),
|
|
1462
|
+
f.stopPropagation(), h();
|
|
1384
1463
|
};
|
|
1385
|
-
const
|
|
1464
|
+
const g = this.handleItemsChanged;
|
|
1386
1465
|
u.addEventListener(
|
|
1387
1466
|
"kaching-bundles-block-loaded",
|
|
1388
1467
|
() => {
|
|
1389
|
-
this.innerElement === u && (u.addEventListener("items-changed",
|
|
1468
|
+
this.innerElement === u && (u.addEventListener("items-changed", g), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
|
|
1390
1469
|
},
|
|
1391
1470
|
{ once: !0 }
|
|
1392
1471
|
), this.appendChild(this.innerElement);
|
|
@@ -1397,10 +1476,10 @@ class Me extends HTMLElement {
|
|
|
1397
1476
|
this.handleItemsChanged
|
|
1398
1477
|
), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
|
|
1399
1478
|
}
|
|
1400
|
-
attributeChangedCallback(
|
|
1401
|
-
|
|
1479
|
+
attributeChangedCallback(t, a, s) {
|
|
1480
|
+
a !== s && this.isConnected && (t === "product-id" || t === "country" || t === "language" ? this.initialize() : t === "selected-variant-id" && this.innerElement && s && this.innerElement.setAttribute(
|
|
1402
1481
|
"current-variant-id",
|
|
1403
|
-
|
|
1482
|
+
s.includes("/") ? String(s.split("/").pop()) : s
|
|
1404
1483
|
));
|
|
1405
1484
|
}
|
|
1406
1485
|
items() {
|
|
@@ -1410,7 +1489,7 @@ class Me extends HTMLElement {
|
|
|
1410
1489
|
this.cleanup(), this.initializeId++;
|
|
1411
1490
|
}
|
|
1412
1491
|
}
|
|
1413
|
-
customElements.define("kaching-bundle-component",
|
|
1492
|
+
customElements.define("kaching-bundle-component", Ue);
|
|
1414
1493
|
export {
|
|
1415
|
-
|
|
1494
|
+
xe as fetchKachingBundlesData
|
|
1416
1495
|
};
|