@kachingappz/bundles-js 1.1.2 → 1.1.3

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