@kachingappz/bundles-js 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -1
- package/dist/bundles-js.iife.js +12 -11
- package/dist/index.d.ts +20 -2
- package/dist/index.js +150 -140
- package/dist/kaching-bundle-component/index.d.ts +20 -2
- package/dist/kaching-bundle-component/index.js +165 -155
- package/dist/react/index.cjs +12 -11
- package/dist/react/index.d.ts +20 -2
- package/dist/react/index.js +376 -355
- package/package.json +5 -3
package/dist/react/index.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as B, useState as R, useEffect as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as F } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as B, useState as R, useEffect as D, useLayoutEffect as L } from "react";
|
|
3
|
+
const J = (e, t) => {
|
|
4
4
|
const a = [], l = e.filter(
|
|
5
|
-
(
|
|
5
|
+
(r) => r.blockVisibility === "selected-products"
|
|
6
6
|
);
|
|
7
|
-
for (const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
(
|
|
7
|
+
for (const r of l)
|
|
8
|
+
r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
|
|
9
|
+
const s = e.filter(
|
|
10
|
+
(r) => r.blockVisibility === "selected-collections"
|
|
11
11
|
);
|
|
12
|
-
for (const
|
|
12
|
+
for (const r of s)
|
|
13
13
|
t.collectionIds.some(
|
|
14
|
-
(m) =>
|
|
15
|
-
) && a.push(
|
|
14
|
+
(m) => r.selectedCollectionIds.map(Number).includes(m)
|
|
15
|
+
) && a.push(r);
|
|
16
16
|
const i = e.filter(
|
|
17
|
-
(
|
|
17
|
+
(r) => r.blockVisibility === "excluded-products"
|
|
18
18
|
);
|
|
19
|
-
for (const
|
|
20
|
-
!
|
|
19
|
+
for (const r of i)
|
|
20
|
+
!r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
|
|
21
21
|
(m) => t.collectionIds.includes(m)
|
|
22
|
-
) && a.push(
|
|
22
|
+
) && a.push(r);
|
|
23
23
|
const o = e.filter(
|
|
24
|
-
(
|
|
24
|
+
(r) => r.blockVisibility === "all-products"
|
|
25
25
|
);
|
|
26
|
-
for (const
|
|
27
|
-
a.push(
|
|
26
|
+
for (const r of o)
|
|
27
|
+
a.push(r);
|
|
28
28
|
return a;
|
|
29
|
-
},
|
|
30
|
-
var
|
|
31
|
-
const l =
|
|
29
|
+
}, z = (e, { language: t, country: a }) => {
|
|
30
|
+
var f, g;
|
|
31
|
+
const l = Q(t, a), s = new Intl.NumberFormat(l, {
|
|
32
32
|
style: "currency",
|
|
33
33
|
currency: e,
|
|
34
34
|
currencyDisplay: "narrowSymbol"
|
|
35
|
-
}).formatToParts(123456789e-2), i = (
|
|
36
|
-
(
|
|
37
|
-
),
|
|
35
|
+
}).formatToParts(123456789e-2), i = (f = s.find((y) => y.type === "decimal")) == null ? void 0 : f.value, o = H(
|
|
36
|
+
(g = s.find((y) => y.type === "group")) == null ? void 0 : g.value
|
|
37
|
+
), r = s.some((y) => y.type === "fraction"), m = K(
|
|
38
38
|
o,
|
|
39
39
|
i,
|
|
40
|
-
|
|
41
|
-
),
|
|
40
|
+
r
|
|
41
|
+
), d = s.findIndex(C), c = s.findLastIndex(C);
|
|
42
42
|
return [
|
|
43
|
-
...
|
|
43
|
+
...s.slice(0, d).map(E),
|
|
44
44
|
m,
|
|
45
|
-
...
|
|
45
|
+
...s.slice(c + 1).map(E)
|
|
46
46
|
].join("");
|
|
47
|
-
},
|
|
47
|
+
}, E = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", Q = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), H = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), K = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
|
|
48
48
|
country: e,
|
|
49
49
|
language: t
|
|
50
50
|
}) => {
|
|
51
51
|
const a = [];
|
|
52
52
|
return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
|
|
53
|
-
},
|
|
53
|
+
}, W = async (e, {
|
|
54
54
|
useExternalMetafieldNamespace: t,
|
|
55
55
|
useMetaobjects: a
|
|
56
|
-
}) => a ?
|
|
56
|
+
}) => a ? Y(
|
|
57
57
|
e
|
|
58
|
-
) :
|
|
58
|
+
) : X(e), X = async (e, t) => {
|
|
59
59
|
var l;
|
|
60
60
|
const a = (l = (await e.query(
|
|
61
61
|
`
|
|
@@ -74,9 +74,9 @@ const L = (e, t) => {
|
|
|
74
74
|
}
|
|
75
75
|
)).shop.metafield) == null ? void 0 : l.value;
|
|
76
76
|
return a ? JSON.parse(a) : [];
|
|
77
|
-
},
|
|
77
|
+
}, Y = async (e, t) => {
|
|
78
78
|
const a = "app--2935586817--deal_block", l = [];
|
|
79
|
-
let
|
|
79
|
+
let s = null;
|
|
80
80
|
for (; ; ) {
|
|
81
81
|
const i = await e.query(
|
|
82
82
|
`
|
|
@@ -98,39 +98,39 @@ const L = (e, t) => {
|
|
|
98
98
|
{
|
|
99
99
|
variables: {
|
|
100
100
|
type: a,
|
|
101
|
-
cursor:
|
|
101
|
+
cursor: s
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
);
|
|
105
105
|
for (const o of i.metaobjects.nodes) {
|
|
106
|
-
const
|
|
106
|
+
const r = o.fields.find(
|
|
107
107
|
(m) => m.key === "settings"
|
|
108
108
|
);
|
|
109
|
-
|
|
109
|
+
r != null && r.value && l.push(JSON.parse(r.value));
|
|
110
110
|
}
|
|
111
111
|
if (!i.metaobjects.pageInfo.hasNextPage)
|
|
112
112
|
break;
|
|
113
|
-
|
|
113
|
+
s = i.metaobjects.pageInfo.endCursor;
|
|
114
114
|
}
|
|
115
115
|
return l;
|
|
116
|
-
},
|
|
116
|
+
}, M = async (e, {
|
|
117
117
|
country: t,
|
|
118
118
|
language: a,
|
|
119
119
|
blockVisibility: l,
|
|
120
|
-
excludedProductGIDs:
|
|
120
|
+
excludedProductGIDs: s,
|
|
121
121
|
selectedProductGIDs: i,
|
|
122
122
|
selectedCollectionGIDs: o,
|
|
123
|
-
limit:
|
|
123
|
+
limit: r = 1e3
|
|
124
124
|
}) => {
|
|
125
125
|
switch (l) {
|
|
126
126
|
case "selected-products":
|
|
127
|
-
return i.slice(0,
|
|
127
|
+
return i.slice(0, r);
|
|
128
128
|
case "all-products":
|
|
129
129
|
case "excluded-products": {
|
|
130
130
|
const m = w({ country: t, language: a });
|
|
131
|
-
let
|
|
132
|
-
for (;
|
|
133
|
-
const
|
|
131
|
+
let d = [], c = null;
|
|
132
|
+
for (; d.length < r; ) {
|
|
133
|
+
const f = Math.min(r - d.length, 250), g = await e.query(
|
|
134
134
|
`
|
|
135
135
|
query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
|
|
136
136
|
products(first: $limit, after: $cursor) {
|
|
@@ -146,22 +146,22 @@ const L = (e, t) => {
|
|
|
146
146
|
`,
|
|
147
147
|
{
|
|
148
148
|
variables: {
|
|
149
|
-
limit:
|
|
150
|
-
cursor:
|
|
149
|
+
limit: f,
|
|
150
|
+
cursor: c
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
);
|
|
154
|
-
if (
|
|
155
|
-
|
|
154
|
+
if (d.push(...g.products.nodes.map((y) => y.id)), !g.products.pageInfo.hasNextPage) break;
|
|
155
|
+
c = g.products.pageInfo.endCursor;
|
|
156
156
|
}
|
|
157
157
|
if (l === "excluded-products") {
|
|
158
|
-
const
|
|
159
|
-
|
|
158
|
+
const f = new Set(s);
|
|
159
|
+
d = d.filter((g) => !f.has(g));
|
|
160
160
|
}
|
|
161
|
-
return
|
|
161
|
+
return d;
|
|
162
162
|
}
|
|
163
163
|
case "selected-collections": {
|
|
164
|
-
const m = w({ country: t, language: a }),
|
|
164
|
+
const m = w({ country: t, language: a }), d = (await e.query(
|
|
165
165
|
`
|
|
166
166
|
query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
|
|
167
167
|
nodes(ids: $collectionGIDs) {
|
|
@@ -178,16 +178,16 @@ const L = (e, t) => {
|
|
|
178
178
|
{
|
|
179
179
|
variables: {
|
|
180
180
|
collectionGIDs: o,
|
|
181
|
-
limit: Math.min(
|
|
181
|
+
limit: Math.min(r, 250)
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
|
-
)).nodes.filter((
|
|
185
|
-
(
|
|
184
|
+
)).nodes.filter((c) => c !== null).flatMap(
|
|
185
|
+
(c) => c.products.nodes.map((f) => f.id)
|
|
186
186
|
);
|
|
187
|
-
return Array.from(new Set(
|
|
187
|
+
return Array.from(new Set(d)).slice(0, r);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
},
|
|
190
|
+
}, U = `
|
|
191
191
|
id
|
|
192
192
|
availableForSale
|
|
193
193
|
price {
|
|
@@ -230,20 +230,20 @@ const L = (e, t) => {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
quantityAvailable @include(if: $includeAvailableQuantity)
|
|
233
|
-
`,
|
|
233
|
+
`, A = async (e, {
|
|
234
234
|
country: t,
|
|
235
235
|
language: a,
|
|
236
236
|
productIds: l,
|
|
237
|
-
includeSellingPlans:
|
|
237
|
+
includeSellingPlans: s = !0,
|
|
238
238
|
includeAvailableQuantity: i = !0,
|
|
239
239
|
useExternalMetafieldNamespace: o = !1,
|
|
240
|
-
batchSize:
|
|
240
|
+
batchSize: r = 250,
|
|
241
241
|
onBatchError: m
|
|
242
242
|
}) => {
|
|
243
243
|
if (!l.length)
|
|
244
244
|
return [];
|
|
245
|
-
const
|
|
246
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${
|
|
245
|
+
const d = l.map((u) => typeof u == "string" && u.startsWith("gid://") ? u : `gid://shopify/Product/${u}`), c = w({ country: t, language: a }), f = `
|
|
246
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${c} {
|
|
247
247
|
shop {
|
|
248
248
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
249
249
|
value
|
|
@@ -277,7 +277,7 @@ const L = (e, t) => {
|
|
|
277
277
|
}
|
|
278
278
|
variants(first: 250) {
|
|
279
279
|
nodes {
|
|
280
|
-
${
|
|
280
|
+
${U}
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
collections(first: 50) {
|
|
@@ -329,24 +329,24 @@ const L = (e, t) => {
|
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
}
|
|
332
|
-
`,
|
|
333
|
-
for (let u = 0; u <
|
|
334
|
-
|
|
335
|
-
let
|
|
336
|
-
const
|
|
337
|
-
const v = await e.query(
|
|
332
|
+
`, g = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = [], h = Math.min(r, 250);
|
|
333
|
+
for (let u = 0; u < d.length; u += h)
|
|
334
|
+
y.push(d.slice(u, u + h));
|
|
335
|
+
let n = 1;
|
|
336
|
+
const p = async (u) => {
|
|
337
|
+
const v = await e.query(f, {
|
|
338
338
|
variables: {
|
|
339
339
|
productGIDs: u,
|
|
340
|
-
includeSellingPlans:
|
|
340
|
+
includeSellingPlans: s,
|
|
341
341
|
includeAvailableQuantity: i,
|
|
342
|
-
metafieldNamespace:
|
|
342
|
+
metafieldNamespace: g
|
|
343
343
|
}
|
|
344
344
|
});
|
|
345
|
-
return v.shop.currencyRateConstant && (
|
|
345
|
+
return v.shop.currencyRateConstant && (n = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
|
|
346
346
|
};
|
|
347
347
|
let b;
|
|
348
348
|
if (m) {
|
|
349
|
-
const u = await Promise.allSettled(
|
|
349
|
+
const u = await Promise.allSettled(y.map(p));
|
|
350
350
|
for (const v of u)
|
|
351
351
|
v.status === "rejected" && m(
|
|
352
352
|
v.reason instanceof Error ? v.reason : new Error(String(v.reason))
|
|
@@ -355,21 +355,21 @@ const L = (e, t) => {
|
|
|
355
355
|
(v) => v.status === "fulfilled"
|
|
356
356
|
).flatMap((v) => v.value.nodes);
|
|
357
357
|
} else
|
|
358
|
-
b = (await Promise.all(
|
|
358
|
+
b = (await Promise.all(y.map(p))).flatMap((u) => u.nodes);
|
|
359
359
|
const _ = b.filter((u) => u != null);
|
|
360
360
|
if (m) {
|
|
361
361
|
const u = await Promise.allSettled(
|
|
362
362
|
_.map(async (I) => {
|
|
363
|
-
const P = await
|
|
363
|
+
const P = await T(
|
|
364
364
|
e,
|
|
365
365
|
I,
|
|
366
|
-
{ includeSellingPlans:
|
|
367
|
-
|
|
366
|
+
{ includeSellingPlans: s, includeAvailableQuantity: i },
|
|
367
|
+
c
|
|
368
368
|
);
|
|
369
|
-
return
|
|
369
|
+
return q(
|
|
370
370
|
P,
|
|
371
371
|
e.shopifyDomain,
|
|
372
|
-
|
|
372
|
+
n
|
|
373
373
|
);
|
|
374
374
|
})
|
|
375
375
|
), v = [];
|
|
@@ -381,32 +381,32 @@ const L = (e, t) => {
|
|
|
381
381
|
}
|
|
382
382
|
return (await Promise.all(
|
|
383
383
|
_.map(
|
|
384
|
-
(u) =>
|
|
384
|
+
(u) => T(
|
|
385
385
|
e,
|
|
386
386
|
u,
|
|
387
387
|
{
|
|
388
|
-
includeSellingPlans:
|
|
388
|
+
includeSellingPlans: s,
|
|
389
389
|
includeAvailableQuantity: i
|
|
390
390
|
},
|
|
391
|
-
|
|
391
|
+
c
|
|
392
392
|
)
|
|
393
393
|
)
|
|
394
394
|
)).map(
|
|
395
|
-
(u) =>
|
|
395
|
+
(u) => q(u, e.shopifyDomain, n)
|
|
396
396
|
);
|
|
397
|
-
},
|
|
397
|
+
}, T = async (e, t, a, l = "") => {
|
|
398
398
|
if (t.variants.nodes.length < 250)
|
|
399
399
|
return t;
|
|
400
|
-
const
|
|
401
|
-
let
|
|
402
|
-
for (;
|
|
403
|
-
const
|
|
400
|
+
const s = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
|
|
401
|
+
let d = !0, c = null;
|
|
402
|
+
for (; d; ) {
|
|
403
|
+
const f = await e.query(
|
|
404
404
|
`
|
|
405
405
|
query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
|
|
406
406
|
product(id: $productGID) {
|
|
407
407
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
408
408
|
nodes {
|
|
409
|
-
${
|
|
409
|
+
${U}
|
|
410
410
|
}
|
|
411
411
|
pageInfo {
|
|
412
412
|
endCursor
|
|
@@ -419,64 +419,64 @@ const L = (e, t) => {
|
|
|
419
419
|
{
|
|
420
420
|
variables: {
|
|
421
421
|
productGID: t.id,
|
|
422
|
-
cursor:
|
|
422
|
+
cursor: c,
|
|
423
423
|
reverse: m,
|
|
424
424
|
...a
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
), { nodes:
|
|
428
|
-
for (const h of
|
|
429
|
-
if (
|
|
430
|
-
|
|
427
|
+
), { nodes: g, pageInfo: y } = f.product.variants;
|
|
428
|
+
for (const h of g) {
|
|
429
|
+
if (s.has(h.id)) {
|
|
430
|
+
d = !1;
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
433
|
-
|
|
433
|
+
s.add(h.id), m ? o.push(h) : i.push(h);
|
|
434
434
|
}
|
|
435
|
-
|
|
435
|
+
y.hasNextPage || (d = !1), c = y.endCursor;
|
|
436
436
|
}
|
|
437
437
|
};
|
|
438
438
|
return await Promise.all([
|
|
439
|
-
|
|
440
|
-
|
|
439
|
+
r(!1),
|
|
440
|
+
r(!0)
|
|
441
441
|
]), t.variants.nodes = [...i, ...o.reverse()], t;
|
|
442
|
-
},
|
|
443
|
-
var c,
|
|
442
|
+
}, q = (e, t, a) => {
|
|
443
|
+
var d, c, f, g, y, h;
|
|
444
444
|
const l = e.variants.nodes.map(
|
|
445
|
-
({ unitPriceMeasurement:
|
|
445
|
+
({ unitPriceMeasurement: n, ...p }) => {
|
|
446
446
|
var b, _;
|
|
447
447
|
return {
|
|
448
|
-
id: Number(
|
|
449
|
-
availableForSale:
|
|
450
|
-
price: Math.round(Number(
|
|
451
|
-
compareAtPrice:
|
|
452
|
-
options:
|
|
453
|
-
imageId:
|
|
454
|
-
image: ((b =
|
|
455
|
-
sellingPlans: ((_ =
|
|
448
|
+
id: Number(p.id.split("/").pop()),
|
|
449
|
+
availableForSale: p.availableForSale,
|
|
450
|
+
price: Math.round(Number(p.price.amount) * 100),
|
|
451
|
+
compareAtPrice: p.compareAtPrice ? Math.round(Number(p.compareAtPrice.amount) * 100) : null,
|
|
452
|
+
options: p.selectedOptions.map((u) => u.value),
|
|
453
|
+
imageId: p.image ? Number(p.image.id.split("/").pop()) : null,
|
|
454
|
+
image: ((b = p.image) == null ? void 0 : b.url) || null,
|
|
455
|
+
sellingPlans: ((_ = p.sellingPlanAllocations) == null ? void 0 : _.nodes.map((u) => ({
|
|
456
456
|
id: Number(u.sellingPlan.id.split("/").pop()),
|
|
457
|
-
price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(
|
|
457
|
+
price: u.priceAdjustments.length > 0 ? Math.round(Number(u.priceAdjustments[0].price.amount) * 100) : Math.round(Number(p.price.amount) * 100),
|
|
458
458
|
compareAtPrice: u.priceAdjustments.length > 0 ? Math.round(
|
|
459
459
|
Number(u.priceAdjustments[0].compareAtPrice.amount) * 100
|
|
460
|
-
) : Math.round(Number(
|
|
460
|
+
) : Math.round(Number(p.price.amount) * 100),
|
|
461
461
|
perDeliveryPrice: u.priceAdjustments.length > 0 ? Math.round(
|
|
462
462
|
Number(u.priceAdjustments[0].perDeliveryPrice.amount) * 100
|
|
463
|
-
) : Math.round(Number(
|
|
463
|
+
) : Math.round(Number(p.price.amount) * 100)
|
|
464
464
|
}))) || [],
|
|
465
465
|
inventoryManagement: null,
|
|
466
466
|
// Storefront API does not return inventory management, only available in liquid
|
|
467
467
|
inventoryPolicy: null,
|
|
468
468
|
// Storefront API does not return inventory policy, only available in liquid
|
|
469
|
-
inventoryQuantity:
|
|
470
|
-
unitPriceMeasurement:
|
|
471
|
-
quantityValue:
|
|
472
|
-
quantityUnit:
|
|
473
|
-
referenceValue:
|
|
474
|
-
referenceUnit:
|
|
469
|
+
inventoryQuantity: p.quantityAvailable ?? null,
|
|
470
|
+
unitPriceMeasurement: n != null && n.quantityUnit && (n != null && n.referenceUnit) ? {
|
|
471
|
+
quantityValue: n.quantityValue,
|
|
472
|
+
quantityUnit: n.quantityUnit.toLowerCase(),
|
|
473
|
+
referenceValue: n.referenceValue,
|
|
474
|
+
referenceUnit: n.referenceUnit.toLowerCase()
|
|
475
475
|
} : null
|
|
476
476
|
};
|
|
477
477
|
}
|
|
478
|
-
),
|
|
479
|
-
const b =
|
|
478
|
+
), s = e.options.map((n, p) => {
|
|
479
|
+
const b = n.optionValues.map((_) => {
|
|
480
480
|
var u, v, I, P;
|
|
481
481
|
return {
|
|
482
482
|
id: Number(_.id.split("/").pop()),
|
|
@@ -489,16 +489,16 @@ const L = (e, t) => {
|
|
|
489
489
|
};
|
|
490
490
|
});
|
|
491
491
|
return {
|
|
492
|
-
defaultName:
|
|
493
|
-
name:
|
|
494
|
-
position:
|
|
495
|
-
optionValues:
|
|
492
|
+
defaultName: n.name,
|
|
493
|
+
name: n.name,
|
|
494
|
+
position: p + 1,
|
|
495
|
+
optionValues: Z(b, p, l)
|
|
496
496
|
};
|
|
497
|
-
}), i = (
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
497
|
+
}), i = (n) => {
|
|
498
|
+
const p = n.priceAdjustments[0];
|
|
499
|
+
if (!p)
|
|
500
500
|
return null;
|
|
501
|
-
const b =
|
|
501
|
+
const b = p.adjustmentValue;
|
|
502
502
|
switch (b.__typename) {
|
|
503
503
|
case "SellingPlanPercentagePriceAdjustment":
|
|
504
504
|
return {
|
|
@@ -520,14 +520,14 @@ const L = (e, t) => {
|
|
|
520
520
|
`Unknown price adjustment type: ${b.__typename}`
|
|
521
521
|
);
|
|
522
522
|
}
|
|
523
|
-
}, o = (
|
|
524
|
-
(
|
|
525
|
-
id: Number(
|
|
526
|
-
name:
|
|
527
|
-
priceAdjustment: i(
|
|
523
|
+
}, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a), r = ((d = e.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
|
|
524
|
+
(n) => n.sellingPlans.nodes.map((p) => ({
|
|
525
|
+
id: Number(p.id.split("/").pop()),
|
|
526
|
+
name: p.name,
|
|
527
|
+
priceAdjustment: i(p)
|
|
528
528
|
}))
|
|
529
529
|
)) || [], m = e.variants.nodes.some(
|
|
530
|
-
(
|
|
530
|
+
(n) => n.requiresComponents
|
|
531
531
|
);
|
|
532
532
|
return {
|
|
533
533
|
id: Number(e.id.split("/").pop()),
|
|
@@ -536,44 +536,44 @@ const L = (e, t) => {
|
|
|
536
536
|
availableForSale: e.availableForSale,
|
|
537
537
|
createdAt: e.createdAt,
|
|
538
538
|
title: e.title,
|
|
539
|
-
image: ((
|
|
539
|
+
image: ((c = e.featuredImage) == null ? void 0 : c.url) || null,
|
|
540
540
|
collectionIds: e.collections.nodes.map(
|
|
541
|
-
(
|
|
541
|
+
(n) => Number(n.id.split("/").pop())
|
|
542
542
|
),
|
|
543
|
-
options:
|
|
543
|
+
options: s,
|
|
544
544
|
selectedVariantId: Number(
|
|
545
545
|
e.variants.nodes[0].id.split("/").pop()
|
|
546
546
|
),
|
|
547
547
|
variants: l,
|
|
548
548
|
requiresSellingPlan: e.requiresSellingPlan,
|
|
549
|
-
sellingPlans:
|
|
549
|
+
sellingPlans: r,
|
|
550
550
|
isNativeBundle: m,
|
|
551
551
|
metafields: {
|
|
552
|
-
text: ((
|
|
553
|
-
text2: ((
|
|
554
|
-
text3: ((
|
|
552
|
+
text: ((f = e.metafield) == null ? void 0 : f.value) || null,
|
|
553
|
+
text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
|
|
554
|
+
text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
|
|
555
555
|
text4: ((h = e.metafield4) == null ? void 0 : h.value) || null
|
|
556
556
|
}
|
|
557
557
|
};
|
|
558
|
-
},
|
|
559
|
-
(
|
|
560
|
-
).length > 0), j = "app--2935586817",
|
|
558
|
+
}, Z = (e, t, a) => e.filter((l) => a.filter(
|
|
559
|
+
(s) => s.options[t] === l.name
|
|
560
|
+
).length > 0), j = "app--2935586817", ee = async (e, {
|
|
561
561
|
language: t,
|
|
562
562
|
country: a,
|
|
563
563
|
useExternalMetafieldNamespace: l
|
|
564
564
|
}) => {
|
|
565
|
-
const
|
|
565
|
+
const s = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
|
|
566
566
|
localization: {
|
|
567
567
|
country: {
|
|
568
|
-
currency: { isoCode:
|
|
568
|
+
currency: { isoCode: r }
|
|
569
569
|
}
|
|
570
570
|
},
|
|
571
571
|
shop: {
|
|
572
572
|
moneyFormat: m,
|
|
573
|
-
paymentSettings: { currencyCode:
|
|
574
|
-
currencyRateConstant:
|
|
575
|
-
primaryDomain:
|
|
576
|
-
settingsMetafield:
|
|
573
|
+
paymentSettings: { currencyCode: d },
|
|
574
|
+
currencyRateConstant: c,
|
|
575
|
+
primaryDomain: f,
|
|
576
|
+
settingsMetafield: g
|
|
577
577
|
}
|
|
578
578
|
} = await e.query(
|
|
579
579
|
`
|
|
@@ -604,30 +604,30 @@ const L = (e, t) => {
|
|
|
604
604
|
`,
|
|
605
605
|
{
|
|
606
606
|
variables: {
|
|
607
|
-
metafieldNamespace:
|
|
607
|
+
metafieldNamespace: s,
|
|
608
608
|
settingsNamespace: i
|
|
609
609
|
}
|
|
610
610
|
}
|
|
611
|
-
),
|
|
611
|
+
), y = r === d ? m : z(r, { language: t, country: a }), h = c ? te(c.value) : 1, n = g ? JSON.parse(g.value) : null, p = (n == null ? void 0 : n.feature_flags) ?? {}, b = (n == null ? void 0 : n.custom_selectors) ?? {};
|
|
612
612
|
return {
|
|
613
|
-
shopifyDomain:
|
|
614
|
-
moneyFormat:
|
|
613
|
+
shopifyDomain: f.host,
|
|
614
|
+
moneyFormat: y,
|
|
615
615
|
locale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
616
616
|
liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
|
|
617
617
|
country: a ?? "US",
|
|
618
618
|
currencyRate: h,
|
|
619
619
|
marketId: 0,
|
|
620
620
|
productId: null,
|
|
621
|
-
storefrontAccessToken: (
|
|
622
|
-
includeSellingPlans: (
|
|
623
|
-
includeAvailableQuantity: (
|
|
624
|
-
customApiHost: (
|
|
625
|
-
keepQuantityInput: (
|
|
626
|
-
ignoreDeselect: (
|
|
627
|
-
ignoreUnitPrice: (
|
|
628
|
-
requireCustomerLogin: (
|
|
629
|
-
abTestsRunning: (
|
|
630
|
-
webPixel: (
|
|
621
|
+
storefrontAccessToken: (n == null ? void 0 : n.storefront_access_token) ?? null,
|
|
622
|
+
includeSellingPlans: (n == null ? void 0 : n.include_selling_plans) ?? !1,
|
|
623
|
+
includeAvailableQuantity: (n == null ? void 0 : n.include_available_quantity) ?? !1,
|
|
624
|
+
customApiHost: (n == null ? void 0 : n.custom_api_host) ?? null,
|
|
625
|
+
keepQuantityInput: (n == null ? void 0 : n.keep_quantity_input) ?? !1,
|
|
626
|
+
ignoreDeselect: (n == null ? void 0 : n.ignore_deselect) ?? !1,
|
|
627
|
+
ignoreUnitPrice: (n == null ? void 0 : n.ignore_unit_price) ?? !1,
|
|
628
|
+
requireCustomerLogin: (n == null ? void 0 : n.require_customer_login) ?? !1,
|
|
629
|
+
abTestsRunning: (n == null ? void 0 : n.ab_tests_running) ?? !1,
|
|
630
|
+
webPixel: (n == null ? void 0 : n.web_pixel) ?? !1,
|
|
631
631
|
b2bCustomer: !1,
|
|
632
632
|
isLoggedIn: !1,
|
|
633
633
|
preview: !1,
|
|
@@ -665,11 +665,11 @@ const L = (e, t) => {
|
|
|
665
665
|
price: b.price ?? null,
|
|
666
666
|
priceCompare: b.price_compare ?? null
|
|
667
667
|
},
|
|
668
|
-
shopCustomStyles: (
|
|
669
|
-
featureFlags:
|
|
670
|
-
brandColors: (
|
|
668
|
+
shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
|
|
669
|
+
featureFlags: p,
|
|
670
|
+
brandColors: (n == null ? void 0 : n.brand_colors) ?? null
|
|
671
671
|
};
|
|
672
|
-
},
|
|
672
|
+
}, te = (e) => JSON.parse(e).amount / 1e6, ae = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
|
|
673
673
|
`
|
|
674
674
|
query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
|
|
675
675
|
nodes(ids: $mediaImageIds) {
|
|
@@ -693,10 +693,9 @@ const L = (e, t) => {
|
|
|
693
693
|
url: l.image.url
|
|
694
694
|
})));
|
|
695
695
|
var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
|
|
696
|
-
const
|
|
697
|
-
...se(e),
|
|
698
|
-
...le(e),
|
|
696
|
+
const se = (e) => [
|
|
699
697
|
...ne(e),
|
|
698
|
+
...le(e),
|
|
700
699
|
...re(e),
|
|
701
700
|
...ie(e),
|
|
702
701
|
...oe(e),
|
|
@@ -706,85 +705,86 @@ const ae = (e) => [
|
|
|
706
705
|
...me(e),
|
|
707
706
|
...pe(e),
|
|
708
707
|
...fe(e),
|
|
709
|
-
...ye(e)
|
|
710
|
-
|
|
708
|
+
...ye(e),
|
|
709
|
+
...ge(e)
|
|
710
|
+
].filter((t) => t != null && !t.includes("placeholder")), ne = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
|
|
711
711
|
(t) => t.dealBarType === k.Bundle ? t.bundleProducts.map(
|
|
712
712
|
(a) => a.mediaImageGID
|
|
713
713
|
) : []
|
|
714
|
-
).filter((t) => t != null),
|
|
714
|
+
).filter((t) => t != null), re = (e) => e.dealBars.map(
|
|
715
715
|
({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
716
|
-
).reduce((t, a) => t.concat(a), []).filter((t) => t != null),
|
|
716
|
+
).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ie = (e) => e.dealBars.flatMap(
|
|
717
717
|
({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
|
|
718
|
-
).filter((t) => t != null),
|
|
719
|
-
const l = a.images.map((
|
|
718
|
+
).filter((t) => t != null), oe = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ce = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
|
|
719
|
+
const l = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
|
|
720
720
|
return [...t, ...l];
|
|
721
|
-
}, []) : [],
|
|
721
|
+
}, []) : [], ue = (e) => {
|
|
722
722
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks)
|
|
723
723
|
return [];
|
|
724
724
|
const t = e.collectionBreaks.mediaImageGID;
|
|
725
725
|
return t ? [t] : [];
|
|
726
|
-
},
|
|
726
|
+
}, de = (e) => {
|
|
727
727
|
var t, a, l;
|
|
728
728
|
return e.progressiveGifts ? [
|
|
729
|
-
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((
|
|
729
|
+
...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
|
|
730
730
|
(a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
|
|
731
731
|
(l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
|
|
732
|
-
].filter((
|
|
733
|
-
},
|
|
732
|
+
].filter((s) => s != null) : [];
|
|
733
|
+
}, me = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), pe = (e) => e.dealBars.map((t) => {
|
|
734
734
|
var a;
|
|
735
735
|
return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
|
|
736
|
-
}).filter((t) => t != null),
|
|
737
|
-
var l,
|
|
736
|
+
}).filter((t) => t != null), fe = (e) => {
|
|
737
|
+
var l, s;
|
|
738
738
|
const t = e.dealBars.map((i) => {
|
|
739
739
|
var o;
|
|
740
740
|
return (o = i.highlights) == null ? void 0 : o.customIconGID;
|
|
741
|
-
}).filter((i) => i != null), a = (
|
|
741
|
+
}).filter((i) => i != null), a = (s = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : s.customIconGID;
|
|
742
742
|
return a ? [...t, a] : t;
|
|
743
|
-
},
|
|
743
|
+
}, ye = (e) => (e.badges || []).flatMap(
|
|
744
744
|
(t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
|
|
745
|
-
),
|
|
745
|
+
), ge = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
|
|
746
746
|
const t = [
|
|
747
|
-
...he(e),
|
|
748
747
|
...be(e),
|
|
749
748
|
...ve(e),
|
|
750
749
|
..._e(e),
|
|
751
750
|
...Ie(e),
|
|
752
751
|
...Pe(e),
|
|
753
752
|
...Se(e),
|
|
754
|
-
...ke(e)
|
|
753
|
+
...ke(e),
|
|
754
|
+
...we(e)
|
|
755
755
|
];
|
|
756
756
|
return Array.from(new Set(t.filter((a) => a != null)));
|
|
757
|
-
},
|
|
757
|
+
}, be = (e) => e.dealBars.flatMap(
|
|
758
758
|
({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
|
|
759
|
-
).filter((t) => t != null),
|
|
759
|
+
).filter((t) => t != null), ve = (e) => e.dealBars.flatMap(
|
|
760
760
|
({ multipleGiftsSelectors: t }) => t ? t.flatMap(
|
|
761
761
|
(a) => a.products ? a.products.map((l) => l.id) : []
|
|
762
762
|
) : []
|
|
763
|
-
).filter((t) => t != null),
|
|
763
|
+
).filter((t) => t != null), _e = (e) => {
|
|
764
764
|
var t;
|
|
765
765
|
return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
|
|
766
|
-
},
|
|
766
|
+
}, Ie = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), Pe = (e) => e.dealBars.filter((t) => t.dealBarType === k.Bundle).flatMap(
|
|
767
767
|
({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
|
|
768
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
768
|
+
).filter((t) => t != null).filter((t) => t !== "default"), Se = (e) => e.dealBars.filter((t) => t.dealBarType === k.MixAndMatch).flatMap(
|
|
769
769
|
({ bundleProducts: t }) => t ? t.flatMap((a) => {
|
|
770
770
|
var l;
|
|
771
771
|
return [
|
|
772
772
|
a.productGID,
|
|
773
|
-
...((l = a.selectedProducts) == null ? void 0 : l.map((
|
|
773
|
+
...((l = a.selectedProducts) == null ? void 0 : l.map((s) => s.id)) ?? []
|
|
774
774
|
];
|
|
775
775
|
}) : []
|
|
776
|
-
).filter((t) => t != null).filter((t) => t !== "default"),
|
|
777
|
-
class
|
|
776
|
+
).filter((t) => t != null).filter((t) => t !== "default"), ke = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), we = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
|
|
777
|
+
class $e {
|
|
778
778
|
constructor(t, a) {
|
|
779
779
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
|
|
780
780
|
}
|
|
781
781
|
async query(t, a) {
|
|
782
|
-
var
|
|
782
|
+
var r;
|
|
783
783
|
const l = (a == null ? void 0 : a.variables) ?? {};
|
|
784
|
-
let
|
|
785
|
-
const i = (
|
|
786
|
-
i && (
|
|
787
|
-
const o = await (await fetch(
|
|
784
|
+
let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
|
|
785
|
+
const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
|
|
786
|
+
i && (s += `?operation_name=${i}`);
|
|
787
|
+
const o = await (await fetch(s, {
|
|
788
788
|
method: "POST",
|
|
789
789
|
headers: {
|
|
790
790
|
"Content-Type": "application/json",
|
|
@@ -800,47 +800,47 @@ class we {
|
|
|
800
800
|
return JSON.parse(o).data;
|
|
801
801
|
}
|
|
802
802
|
}
|
|
803
|
-
const
|
|
804
|
-
const
|
|
805
|
-
if (!t.collectionBreaksEnabled || !
|
|
803
|
+
const Ne = async (e, t, { country: a, language: l }) => {
|
|
804
|
+
const s = t.collectionBreaks;
|
|
805
|
+
if (!t.collectionBreaksEnabled || !s) return;
|
|
806
806
|
let i;
|
|
807
|
-
|
|
807
|
+
s.visibility === "deal-products" ? i = await M(e, {
|
|
808
808
|
country: a,
|
|
809
809
|
language: l,
|
|
810
810
|
blockVisibility: t.blockVisibility,
|
|
811
811
|
excludedProductGIDs: (t.excludedProductIds || []).map(
|
|
812
|
-
(
|
|
812
|
+
(r) => `gid://shopify/Product/${r}`
|
|
813
813
|
),
|
|
814
814
|
selectedProductGIDs: (t.selectedProductIds || []).map(
|
|
815
|
-
(
|
|
815
|
+
(r) => `gid://shopify/Product/${r}`
|
|
816
816
|
),
|
|
817
817
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
|
|
818
|
-
(
|
|
818
|
+
(r) => `gid://shopify/Collection/${r}`
|
|
819
819
|
)
|
|
820
|
-
}) : i = await
|
|
820
|
+
}) : i = await M(e, {
|
|
821
821
|
country: a,
|
|
822
822
|
language: l,
|
|
823
|
-
blockVisibility:
|
|
824
|
-
excludedProductGIDs: (
|
|
825
|
-
({ id:
|
|
823
|
+
blockVisibility: s.visibility,
|
|
824
|
+
excludedProductGIDs: (s.excludedProducts || []).map(
|
|
825
|
+
({ id: r }) => r
|
|
826
826
|
),
|
|
827
|
-
selectedProductGIDs: (
|
|
828
|
-
({ id:
|
|
827
|
+
selectedProductGIDs: (s.selectedProducts || []).map(
|
|
828
|
+
({ id: r }) => r
|
|
829
829
|
),
|
|
830
|
-
selectedCollectionGIDs: (
|
|
831
|
-
({ id:
|
|
830
|
+
selectedCollectionGIDs: (s.selectedCollections || []).map(
|
|
831
|
+
({ id: r }) => r
|
|
832
832
|
)
|
|
833
833
|
});
|
|
834
|
-
let o = await
|
|
834
|
+
let o = await A(e, {
|
|
835
835
|
country: a,
|
|
836
836
|
language: l,
|
|
837
|
-
productIds: i.map((
|
|
837
|
+
productIds: i.map((r) => Number(r.split("/").pop())),
|
|
838
838
|
useExternalMetafieldNamespace: !0
|
|
839
839
|
});
|
|
840
840
|
return o = o.filter(
|
|
841
|
-
(
|
|
841
|
+
(r) => r.availableForSale
|
|
842
842
|
), o;
|
|
843
|
-
},
|
|
843
|
+
}, De = () => ({
|
|
844
844
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
845
845
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
846
846
|
"system.unavailable_option_value": "Unavailable",
|
|
@@ -865,84 +865,94 @@ const $e = async (e, t, { country: a, language: l }) => {
|
|
|
865
865
|
"system.letters_only": "Only letters are allowed.",
|
|
866
866
|
"system.numbers_only": "Only numbers are allowed.",
|
|
867
867
|
"system.personalisation_required_alert": "Please add personalisation for every item to continue."
|
|
868
|
-
}),
|
|
868
|
+
}), Ae = "2026-07", xe = async (e, {
|
|
869
869
|
productId: t,
|
|
870
870
|
dealBlockId: a,
|
|
871
871
|
country: l = void 0,
|
|
872
|
-
language:
|
|
872
|
+
language: s = void 0
|
|
873
873
|
}) => {
|
|
874
874
|
var i, o;
|
|
875
875
|
try {
|
|
876
|
-
const
|
|
877
|
-
l = l || ((i = m.i18n) == null ? void 0 : i.country),
|
|
878
|
-
const
|
|
879
|
-
language:
|
|
876
|
+
const r = [Number(t.split("/").pop())], m = new Ge(e);
|
|
877
|
+
l = l || ((i = m.i18n) == null ? void 0 : i.country), s = s || ((o = m.i18n) == null ? void 0 : o.language);
|
|
878
|
+
const d = await ee(m, {
|
|
879
|
+
language: s,
|
|
880
880
|
country: l,
|
|
881
881
|
useExternalMetafieldNamespace: !0
|
|
882
882
|
});
|
|
883
|
-
m.shopifyDomain =
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
) : m, [
|
|
888
|
-
|
|
883
|
+
m.shopifyDomain = d.shopifyDomain;
|
|
884
|
+
const c = d.storefrontAccessToken ? new $e(
|
|
885
|
+
d.shopifyDomain,
|
|
886
|
+
d.storefrontAccessToken
|
|
887
|
+
) : m, [f, g] = await Promise.all([
|
|
888
|
+
A(c, {
|
|
889
889
|
country: l,
|
|
890
|
-
language:
|
|
891
|
-
productIds:
|
|
890
|
+
language: s,
|
|
891
|
+
productIds: r,
|
|
892
892
|
useExternalMetafieldNamespace: !0
|
|
893
893
|
}),
|
|
894
|
-
|
|
894
|
+
W(c, {
|
|
895
895
|
useExternalMetafieldNamespace: !0,
|
|
896
|
-
useMetaobjects:
|
|
896
|
+
useMetaobjects: d.featureFlags.storefront_metaobjects
|
|
897
897
|
})
|
|
898
|
-
]),
|
|
899
|
-
if (!
|
|
898
|
+
]), y = f[0];
|
|
899
|
+
if (!y)
|
|
900
900
|
return null;
|
|
901
|
-
const h =
|
|
902
|
-
let
|
|
903
|
-
if (a ? (
|
|
901
|
+
const h = J(g, y);
|
|
902
|
+
let n;
|
|
903
|
+
if (a ? (n = h.find(
|
|
904
904
|
(P) => P.id === a || P.nanoId === a
|
|
905
|
-
),
|
|
905
|
+
), n || (n = h[0])) : n = h[0], !n)
|
|
906
906
|
return null;
|
|
907
|
-
const
|
|
908
|
-
|
|
907
|
+
const p = se(n), b = he(n), [_, u, v, I] = await Promise.all([
|
|
908
|
+
A(c, {
|
|
909
909
|
country: l,
|
|
910
|
-
language:
|
|
910
|
+
language: s,
|
|
911
911
|
productIds: b,
|
|
912
912
|
useExternalMetafieldNamespace: !0
|
|
913
913
|
}),
|
|
914
|
-
|
|
915
|
-
|
|
914
|
+
ae(c, p, 300),
|
|
915
|
+
Ne(c, n, {
|
|
916
916
|
country: l,
|
|
917
|
-
language:
|
|
917
|
+
language: s
|
|
918
918
|
}),
|
|
919
|
-
|
|
919
|
+
De()
|
|
920
920
|
]);
|
|
921
921
|
return {
|
|
922
|
-
product:
|
|
923
|
-
dealBlock:
|
|
924
|
-
config:
|
|
922
|
+
product: y,
|
|
923
|
+
dealBlock: n,
|
|
924
|
+
config: d,
|
|
925
925
|
otherProducts: _,
|
|
926
926
|
mediaImages: u,
|
|
927
927
|
collectionBreaksProducts: v ?? [],
|
|
928
928
|
translations: I
|
|
929
929
|
};
|
|
930
|
-
} catch (
|
|
931
|
-
return console.error(
|
|
930
|
+
} catch (r) {
|
|
931
|
+
return console.error(r), null;
|
|
932
932
|
}
|
|
933
933
|
};
|
|
934
|
-
class
|
|
934
|
+
class Ge {
|
|
935
935
|
constructor(t) {
|
|
936
936
|
this.storefront = t, this.shopifyDomain = "";
|
|
937
937
|
}
|
|
938
938
|
async query(t, a) {
|
|
939
|
+
var l;
|
|
939
940
|
if ("query" in this.storefront && "i18n" in this.storefront)
|
|
940
941
|
return await this.storefront.query(t, a);
|
|
942
|
+
if ("graphql" in this.storefront) {
|
|
943
|
+
const s = await this.storefront.graphql(t, a);
|
|
944
|
+
if ((l = s.errors) != null && l.length)
|
|
945
|
+
throw new Error(
|
|
946
|
+
s.errors.map((i) => i.message).join(`
|
|
947
|
+
`)
|
|
948
|
+
);
|
|
949
|
+
return s.data;
|
|
950
|
+
}
|
|
941
951
|
if ("request" in this.storefront)
|
|
942
952
|
return (await this.storefront.request(t, a)).data;
|
|
943
953
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
944
|
-
const
|
|
945
|
-
`https://${this.storefront.shopifyDomain}/api/${
|
|
954
|
+
const s = await fetch(
|
|
955
|
+
`https://${this.storefront.shopifyDomain}/api/${Ae}/graphql.json`,
|
|
946
956
|
{
|
|
947
957
|
body: JSON.stringify({
|
|
948
958
|
query: t,
|
|
@@ -955,11 +965,11 @@ class xe {
|
|
|
955
965
|
method: "POST"
|
|
956
966
|
}
|
|
957
967
|
);
|
|
958
|
-
if (!
|
|
959
|
-
throw new Error(
|
|
960
|
-
return (await
|
|
968
|
+
if (!s.ok)
|
|
969
|
+
throw new Error(s.statusText);
|
|
970
|
+
return (await s.json()).data;
|
|
961
971
|
} else {
|
|
962
|
-
const
|
|
972
|
+
const s = await fetch(this.storefront.getStorefrontApiUrl(), {
|
|
963
973
|
body: JSON.stringify({
|
|
964
974
|
query: t,
|
|
965
975
|
variables: a == null ? void 0 : a.variables
|
|
@@ -967,9 +977,9 @@ class xe {
|
|
|
967
977
|
headers: this.storefront.getPublicTokenHeaders(),
|
|
968
978
|
method: "POST"
|
|
969
979
|
});
|
|
970
|
-
if (!
|
|
971
|
-
throw new Error(
|
|
972
|
-
return (await
|
|
980
|
+
if (!s.ok)
|
|
981
|
+
throw new Error(s.statusText);
|
|
982
|
+
return (await s.json()).data;
|
|
973
983
|
}
|
|
974
984
|
}
|
|
975
985
|
get i18n() {
|
|
@@ -977,32 +987,32 @@ class xe {
|
|
|
977
987
|
return this.storefront.i18n;
|
|
978
988
|
}
|
|
979
989
|
}
|
|
980
|
-
const
|
|
990
|
+
const Xe = xe, $ = "kaching-bundles-block", O = 1e4, Be = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ee = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ce = async (e) => {
|
|
981
991
|
const t = e.document;
|
|
982
992
|
if (!e.customElements.get($)) {
|
|
983
993
|
if (N.has(t))
|
|
984
|
-
return
|
|
994
|
+
return x(e, $);
|
|
985
995
|
N.add(t);
|
|
986
996
|
try {
|
|
987
|
-
await
|
|
997
|
+
await qe(e);
|
|
988
998
|
} catch (a) {
|
|
989
999
|
throw N.delete(t), a;
|
|
990
1000
|
}
|
|
991
1001
|
}
|
|
992
|
-
},
|
|
1002
|
+
}, Me = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Te = () => Me() ? Be : Ee, qe = (e) => {
|
|
993
1003
|
const t = e.document;
|
|
994
1004
|
return new Promise((a, l) => {
|
|
995
|
-
const
|
|
1005
|
+
const s = Te();
|
|
996
1006
|
if (t.querySelector(
|
|
997
|
-
`script[src="${
|
|
1007
|
+
`script[src="${s}"]`
|
|
998
1008
|
)) {
|
|
999
|
-
|
|
1009
|
+
x(e, $).then(a).catch(l);
|
|
1000
1010
|
return;
|
|
1001
1011
|
}
|
|
1002
1012
|
const o = t.createElement("script");
|
|
1003
|
-
o.src =
|
|
1013
|
+
o.src = s, o.onload = () => x(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
|
|
1004
1014
|
});
|
|
1005
|
-
},
|
|
1015
|
+
}, x = (e, t) => new Promise((a, l) => {
|
|
1006
1016
|
if (e.customElements.get(t)) {
|
|
1007
1017
|
a();
|
|
1008
1018
|
return;
|
|
@@ -1010,35 +1020,35 @@ const Qe = Ae, $ = "kaching-bundles-block", U = 1e4, Ge = "https://bundles-integ
|
|
|
1010
1020
|
Promise.race([
|
|
1011
1021
|
e.customElements.whenDefined(t),
|
|
1012
1022
|
new Promise(
|
|
1013
|
-
(
|
|
1023
|
+
(s, i) => setTimeout(
|
|
1014
1024
|
() => i(
|
|
1015
1025
|
new Error(
|
|
1016
|
-
`Custom element "${t}" failed to register within ${
|
|
1026
|
+
`Custom element "${t}" failed to register within ${O}ms`
|
|
1017
1027
|
)
|
|
1018
1028
|
),
|
|
1019
|
-
|
|
1029
|
+
O
|
|
1020
1030
|
)
|
|
1021
1031
|
)
|
|
1022
1032
|
]).then(() => a()).catch(l);
|
|
1023
1033
|
});
|
|
1024
|
-
var
|
|
1025
|
-
const S = "a-f\\d",
|
|
1026
|
-
function
|
|
1027
|
-
if (typeof e != "string" ||
|
|
1034
|
+
var G = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(G || {});
|
|
1035
|
+
const S = "a-f\\d", je = `#?[${S}]{3}[${S}]?`, Oe = `#?[${S}]{6}([${S}]{2})?`, Ve = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${je}$|^${Oe}$`, "i");
|
|
1036
|
+
function Fe(e, t = {}) {
|
|
1037
|
+
if (typeof e != "string" || Ve.test(e) || !Ue.test(e))
|
|
1028
1038
|
throw new TypeError("Expected a valid hex string");
|
|
1029
1039
|
e = e.replace(/^#/, "");
|
|
1030
1040
|
let a = 1;
|
|
1031
1041
|
e.length === 8 && (a = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (a = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
|
|
1032
|
-
const l = Number.parseInt(e, 16),
|
|
1042
|
+
const l = Number.parseInt(e, 16), s = l >> 16, i = l >> 8 & 255, o = l & 255, r = typeof t.alpha == "number" ? t.alpha : a;
|
|
1033
1043
|
if (t.format === "array")
|
|
1034
|
-
return [
|
|
1044
|
+
return [s, i, o, r];
|
|
1035
1045
|
if (t.format === "css") {
|
|
1036
|
-
const m =
|
|
1037
|
-
return `rgb(${
|
|
1046
|
+
const m = r === 1 ? "" : ` / ${Number((r * 100).toFixed(2))}%`;
|
|
1047
|
+
return `rgb(${s} ${i} ${o}${m})`;
|
|
1038
1048
|
}
|
|
1039
|
-
return { red:
|
|
1049
|
+
return { red: s, green: i, blue: o, alpha: r };
|
|
1040
1050
|
}
|
|
1041
|
-
const
|
|
1051
|
+
const Re = ({ price: e }) => ({
|
|
1042
1052
|
id: 123,
|
|
1043
1053
|
handle: "123",
|
|
1044
1054
|
url: null,
|
|
@@ -1073,7 +1083,7 @@ const Fe = ({ price: e }) => ({
|
|
|
1073
1083
|
text4: null
|
|
1074
1084
|
},
|
|
1075
1085
|
isNativeBundle: !1
|
|
1076
|
-
}),
|
|
1086
|
+
}), Le = () => ({
|
|
1077
1087
|
shopifyDomain: "",
|
|
1078
1088
|
moneyFormat: "${{amount_with_comma_separator}}",
|
|
1079
1089
|
locale: "en",
|
|
@@ -1129,7 +1139,7 @@ const Fe = ({ price: e }) => ({
|
|
|
1129
1139
|
},
|
|
1130
1140
|
shopCustomStyles: "",
|
|
1131
1141
|
featureFlags: {}
|
|
1132
|
-
}),
|
|
1142
|
+
}), Je = ({
|
|
1133
1143
|
color: e,
|
|
1134
1144
|
cornerRadius: t
|
|
1135
1145
|
}) => {
|
|
@@ -1183,7 +1193,7 @@ const Fe = ({ price: e }) => ({
|
|
|
1183
1193
|
dealBars: [
|
|
1184
1194
|
{
|
|
1185
1195
|
id: "PfFU",
|
|
1186
|
-
dealBarType:
|
|
1196
|
+
dealBarType: G.QuantityBreak,
|
|
1187
1197
|
title: "1 pack",
|
|
1188
1198
|
subtitle: "Standard price",
|
|
1189
1199
|
label: "",
|
|
@@ -1203,7 +1213,7 @@ const Fe = ({ price: e }) => ({
|
|
|
1203
1213
|
},
|
|
1204
1214
|
{
|
|
1205
1215
|
id: "1f-9",
|
|
1206
|
-
dealBarType:
|
|
1216
|
+
dealBarType: G.QuantityBreak,
|
|
1207
1217
|
title: "2 pack",
|
|
1208
1218
|
subtitle: "You save {{saved_percentage}}",
|
|
1209
1219
|
label: "SAVE {{saved_total}}",
|
|
@@ -1393,84 +1403,95 @@ const Fe = ({ price: e }) => ({
|
|
|
1393
1403
|
imageSize: 48,
|
|
1394
1404
|
imageCornerRadius: 6
|
|
1395
1405
|
};
|
|
1396
|
-
return e !== void 0 && (a.colors.border = { ...
|
|
1397
|
-
},
|
|
1406
|
+
return e !== void 0 && (a.colors.border = { ...Fe(e), alpha: 1 }), a;
|
|
1407
|
+
}, Ye = ({
|
|
1398
1408
|
data: e,
|
|
1399
1409
|
selectedVariantId: t,
|
|
1400
1410
|
preview: a,
|
|
1401
1411
|
onLinesChange: l,
|
|
1402
|
-
targetWindow:
|
|
1412
|
+
targetWindow: s
|
|
1403
1413
|
}) => {
|
|
1404
|
-
const i = B(null), [o,
|
|
1405
|
-
|
|
1414
|
+
const i = B(null), [o, r] = R(!1), m = B(!1);
|
|
1415
|
+
D(() => {
|
|
1406
1416
|
if (!i.current || o) return;
|
|
1407
1417
|
(async () => {
|
|
1408
|
-
await
|
|
1418
|
+
await Ce(s ?? window), r(!0);
|
|
1409
1419
|
})();
|
|
1410
|
-
}, [o,
|
|
1420
|
+
}, [o, s]), D(() => {
|
|
1411
1421
|
const c = i.current;
|
|
1412
1422
|
if (!o || !c) return;
|
|
1413
|
-
const
|
|
1414
|
-
const y = c.items().map((
|
|
1415
|
-
merchandiseId: `gid://shopify/ProductVariant/${
|
|
1416
|
-
quantity:
|
|
1417
|
-
attributes: Object.entries(
|
|
1418
|
-
key:
|
|
1419
|
-
value: String(
|
|
1423
|
+
const f = () => {
|
|
1424
|
+
const y = c.items().map((h) => ({
|
|
1425
|
+
merchandiseId: `gid://shopify/ProductVariant/${h.id}`,
|
|
1426
|
+
quantity: h.quantity,
|
|
1427
|
+
attributes: Object.entries(h.properties).map(([n, p]) => ({
|
|
1428
|
+
key: n,
|
|
1429
|
+
value: String(p)
|
|
1420
1430
|
})),
|
|
1421
|
-
sellingPlanId:
|
|
1431
|
+
sellingPlanId: h.selling_plan ? `gid://shopify/SellingPlan/${h.selling_plan}` : void 0
|
|
1422
1432
|
}));
|
|
1423
1433
|
l == null || l(y);
|
|
1424
1434
|
};
|
|
1425
|
-
return m.current || (typeof c.items == "function" ?
|
|
1426
|
-
c.removeEventListener("kaching-bundles-block-loaded",
|
|
1435
|
+
return m.current || (typeof c.items == "function" ? f() : c.addEventListener("kaching-bundles-block-loaded", f), m.current = !0), c.addEventListener("variants-changed", f), () => {
|
|
1436
|
+
c.removeEventListener("kaching-bundles-block-loaded", f), c.removeEventListener("variants-changed", f);
|
|
1427
1437
|
};
|
|
1428
|
-
}, [o, l])
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
"
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1438
|
+
}, [o, l]);
|
|
1439
|
+
const d = e ? Qe(e, t) : a ? He(a) : null;
|
|
1440
|
+
return ze(() => {
|
|
1441
|
+
const c = i.current;
|
|
1442
|
+
if (!(!c || !d))
|
|
1443
|
+
for (const [f, g] of Object.entries(d.jsonAttributes))
|
|
1444
|
+
c.getAttribute(f) !== g && c.setAttribute(f, g);
|
|
1445
|
+
}), d ? /* @__PURE__ */ F(
|
|
1446
|
+
"kaching-bundles-block",
|
|
1447
|
+
{
|
|
1448
|
+
ref: i,
|
|
1449
|
+
"deal-block-id": d.dealBlockId,
|
|
1450
|
+
...d.jsonAttributes,
|
|
1451
|
+
"current-variant-id": d.currentVariantId
|
|
1452
|
+
}
|
|
1453
|
+
) : null;
|
|
1454
|
+
}, ze = typeof window > "u" ? D : L, Qe = ({
|
|
1455
|
+
config: e,
|
|
1456
|
+
dealBlock: t,
|
|
1457
|
+
product: a,
|
|
1458
|
+
otherProducts: l,
|
|
1459
|
+
mediaImages: s,
|
|
1460
|
+
collectionBreaksProducts: i,
|
|
1461
|
+
translations: o
|
|
1462
|
+
}, r) => ({
|
|
1463
|
+
dealBlockId: t.id,
|
|
1464
|
+
currentVariantId: r ? r.split("/").pop() : String(a.variants[0].id),
|
|
1465
|
+
jsonAttributes: {
|
|
1466
|
+
config: JSON.stringify(e),
|
|
1467
|
+
"deal-block": JSON.stringify(t),
|
|
1468
|
+
"media-images": JSON.stringify(s),
|
|
1469
|
+
product: JSON.stringify(a),
|
|
1470
|
+
"other-products": JSON.stringify(l),
|
|
1471
|
+
"collection-breaks-products": JSON.stringify(i),
|
|
1472
|
+
translations: JSON.stringify(o)
|
|
1473
|
+
}
|
|
1474
|
+
}), He = ({
|
|
1475
|
+
cornerRadius: e,
|
|
1476
|
+
color: t,
|
|
1477
|
+
price: a
|
|
1478
|
+
}) => {
|
|
1479
|
+
const l = Re({ price: a }), s = Le(), i = Je({ color: t, cornerRadius: e });
|
|
1480
|
+
return {
|
|
1481
|
+
dealBlockId: i.id,
|
|
1482
|
+
currentVariantId: String(l.variants[0].id),
|
|
1483
|
+
jsonAttributes: {
|
|
1484
|
+
config: JSON.stringify(s),
|
|
1485
|
+
"deal-block": JSON.stringify(i),
|
|
1486
|
+
"media-images": JSON.stringify([]),
|
|
1487
|
+
product: JSON.stringify(l),
|
|
1488
|
+
"other-products": JSON.stringify([]),
|
|
1489
|
+
"collection-breaks-products": JSON.stringify([]),
|
|
1490
|
+
translations: JSON.stringify({})
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1472
1493
|
};
|
|
1473
1494
|
export {
|
|
1474
|
-
|
|
1475
|
-
|
|
1495
|
+
Ye as KachingBundle,
|
|
1496
|
+
Xe as fetchKachingBundlesData
|
|
1476
1497
|
};
|