@kachingappz/bundles-js 1.1.2 → 1.1.4

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,64 @@
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
+ };
35
+ [
36
+ "primaryBackground",
37
+ "secondaryBackground",
38
+ "primaryText",
39
+ "secondaryText",
40
+ "border",
41
+ "overlay",
42
+ "primaryAccent",
43
+ "primaryAccentText",
44
+ "badgeBackground",
45
+ "badgeText",
46
+ "error"
47
+ ].map((e) => `brand_${e}`);
48
+ var d = /* @__PURE__ */ function(e) {
49
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
50
+ }({}), f = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: c = 1e3 }) => {
51
+ switch (r) {
52
+ case "selected-products": return a.slice(0, c);
53
+ case "all-products":
54
+ case "excluded-products": {
55
+ let a = s({
56
+ country: t,
57
+ language: n
58
+ }), o = [], l = null;
59
+ for (; o.length < c;) {
60
+ let t = Math.min(c - o.length, 250), n = await e.query(`
61
+ query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
134
62
  products(first: $limit, after: $cursor) {
135
63
  nodes {
136
64
  id
@@ -141,27 +69,25 @@ const T = (e, t) => {
141
69
  }
142
70
  }
143
71
  }
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} {
72
+ `, { variables: {
73
+ limit: t,
74
+ cursor: l
75
+ } });
76
+ if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
77
+ l = n.products.pageInfo.endCursor;
78
+ }
79
+ if (r === "excluded-products") {
80
+ let e = new Set(i);
81
+ o = o.filter((t) => !e.has(t));
82
+ }
83
+ return o;
84
+ }
85
+ case "selected-collections": {
86
+ let r = s({
87
+ country: t,
88
+ language: n
89
+ }), i = (await e.query(`
90
+ query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${r} {
165
91
  nodes(ids: $collectionGIDs) {
166
92
  ... on Collection {
167
93
  products(first: $limit) {
@@ -172,77 +98,23 @@ const T = (e, t) => {
172
98
  }
173
99
  }
174
100
  }
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} {
101
+ `, { variables: {
102
+ collectionGIDs: o,
103
+ limit: Math.min(c, 250)
104
+ } })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
105
+ return Array.from(new Set(i)).slice(0, c);
106
+ }
107
+ }
108
+ }, p = "\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", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: m = {
109
+ maxWidth: 200,
110
+ maxHeight: 200
111
+ } }) => {
112
+ if (!r.length) return [];
113
+ let _ = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), v = s({
114
+ country: t,
115
+ language: n
116
+ }), y = `
117
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${v} {
246
118
  shop {
247
119
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
248
120
  value
@@ -276,7 +148,7 @@ const T = (e, t) => {
276
148
  }
277
149
  variants(first: 250) {
278
150
  nodes {
279
- ${j}
151
+ ${p}
280
152
  }
281
153
  }
282
154
  collections(first: 50) {
@@ -296,6 +168,15 @@ const T = (e, t) => {
296
168
  metafield4: metafield(namespace: $metafieldNamespace, key: "text4") {
297
169
  value
298
170
  }
171
+ reviewsRating: metafield(namespace: "reviews", key: "rating") @include(if: $includeProductRating) {
172
+ value
173
+ }
174
+ reviewsRatingCount: metafield(namespace: "reviews", key: "rating_count") @include(if: $includeProductRating) {
175
+ value
176
+ }
177
+ subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
178
+ value
179
+ }
299
180
  requiresSellingPlan
300
181
  sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
301
182
  nodes {
@@ -328,90 +209,53 @@ const T = (e, t) => {
328
209
  }
329
210
  }
330
211
  }
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} {
212
+ `, b = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", x = l.indexOf("."), S = l.slice(0, x), C = l.slice(x + 1), w = [], T = Math.min(d, 250);
213
+ for (let e = 0; e < _.length; e += T) w.push(_.slice(e, e + T));
214
+ let E = 1, D = async (t) => {
215
+ let n = await e.query(y, { variables: {
216
+ productGIDs: t,
217
+ includeSellingPlans: i,
218
+ includeAvailableQuantity: a,
219
+ includeProductRating: o,
220
+ includeProductSubtitle: c,
221
+ subtitleNamespace: S,
222
+ subtitleKey: C,
223
+ metafieldNamespace: b,
224
+ variantImageTransform: m
225
+ } });
226
+ return n.shop.currencyRateConstant && (E = JSON.parse(n.shop.currencyRateConstant.value).amount / 1e6), n;
227
+ }, O;
228
+ if (f) {
229
+ let e = await Promise.allSettled(w.map(D));
230
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
231
+ O = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
232
+ } else O = (await Promise.all(w.map(D))).flatMap((e) => e.nodes);
233
+ let k = O.filter((e) => e != null);
234
+ if (f) {
235
+ let t = await Promise.allSettled(k.map(async (t) => g(await h(e, t, {
236
+ includeSellingPlans: i,
237
+ includeAvailableQuantity: a,
238
+ variantImageTransform: m
239
+ }, v), e.shopifyDomain, E))), n = [];
240
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
241
+ return n;
242
+ }
243
+ return (await Promise.all(k.map((t) => h(e, t, {
244
+ includeSellingPlans: i,
245
+ includeAvailableQuantity: a,
246
+ variantImageTransform: m
247
+ }, v)))).map((t) => g(t, e.shopifyDomain, E));
248
+ }, h = async (e, t, n, r = "") => {
249
+ if (t.variants.nodes.length < 250) return t;
250
+ let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
251
+ let c = !0, l = null;
252
+ for (; c;) {
253
+ let { nodes: u, pageInfo: d } = (await e.query(`
254
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${r} {
411
255
  product(id: $productGID) {
412
256
  variants(first: 250, after: $cursor, reverse: $reverse) {
413
257
  nodes {
414
- ${j}
258
+ ${p}
415
259
  }
416
260
  pageInfo {
417
261
  endCursor
@@ -420,169 +264,130 @@ const T = (e, t) => {
420
264
  }
421
265
  }
422
266
  }
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} {
267
+ `, { variables: {
268
+ productGID: t.id,
269
+ cursor: l,
270
+ reverse: s,
271
+ ...n
272
+ } })).product.variants;
273
+ for (let e of u) {
274
+ if (i.has(e.id)) {
275
+ c = !1;
276
+ break;
277
+ }
278
+ i.add(e.id), s ? o.push(e) : a.push(e);
279
+ }
280
+ d.hasNextPage || (c = !1), l = d.endCursor;
281
+ }
282
+ };
283
+ return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
284
+ }, g = (e, t, n) => {
285
+ let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
286
+ id: Number(t.id.split("/").pop()),
287
+ availableForSale: t.availableForSale,
288
+ price: Math.round(Number(t.price.amount) * 100),
289
+ compareAtPrice: t.compareAtPrice ? Math.round(Number(t.compareAtPrice.amount) * 100) : null,
290
+ options: t.selectedOptions.map((e) => e.value),
291
+ imageId: t.image ? Number(t.image.id.split("/").pop()) : null,
292
+ image: t.image?.url || null,
293
+ sellingPlans: t.sellingPlanAllocations?.nodes.map((e) => ({
294
+ id: Number(e.sellingPlan.id.split("/").pop()),
295
+ price: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].price.amount) * 100) : Math.round(Number(t.price.amount) * 100),
296
+ compareAtPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].compareAtPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100),
297
+ perDeliveryPrice: e.priceAdjustments.length > 0 ? Math.round(Number(e.priceAdjustments[0].perDeliveryPrice.amount) * 100) : Math.round(Number(t.price.amount) * 100)
298
+ })) || [],
299
+ inventoryManagement: null,
300
+ inventoryPolicy: null,
301
+ inventoryQuantity: t.quantityAvailable ?? null,
302
+ unitPriceMeasurement: e?.quantityUnit && e?.referenceUnit ? {
303
+ quantityValue: e.quantityValue,
304
+ quantityUnit: e.quantityUnit.toLowerCase(),
305
+ referenceValue: e.referenceValue,
306
+ referenceUnit: e.referenceUnit.toLowerCase()
307
+ } : null
308
+ })), i = e.options.map((e, t) => {
309
+ let n = e.optionValues.map((e) => ({
310
+ id: Number(e.id.split("/").pop()),
311
+ defaultName: e.name,
312
+ name: e.name,
313
+ swatch: {
314
+ color: e.swatch?.color || null,
315
+ image: e.swatch?.image?.previewImage?.url || null
316
+ }
317
+ }));
318
+ return {
319
+ defaultName: e.name,
320
+ name: e.name,
321
+ position: t + 1,
322
+ optionValues: y(n, t, r)
323
+ };
324
+ }), a = (e) => {
325
+ let t = e.priceAdjustments[0];
326
+ if (!t) return null;
327
+ let n = t.adjustmentValue;
328
+ switch (n.__typename) {
329
+ case "SellingPlanPercentagePriceAdjustment": return {
330
+ type: "percentage",
331
+ value: n.adjustmentPercentage
332
+ };
333
+ case "SellingPlanFixedAmountPriceAdjustment": return {
334
+ type: "fixed_amount",
335
+ value: o(n.adjustmentAmount.amount)
336
+ };
337
+ case "SellingPlanFixedPriceAdjustment": return {
338
+ type: "price",
339
+ value: o(n.price.amount)
340
+ };
341
+ default: throw Error(`Unknown price adjustment type: ${n.__typename}`);
342
+ }
343
+ }, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
344
+ id: Number(e.id.split("/").pop()),
345
+ name: e.name,
346
+ priceAdjustment: a(e)
347
+ }))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
348
+ return {
349
+ id: Number(e.id.split("/").pop()),
350
+ handle: e.handle,
351
+ url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
352
+ availableForSale: e.availableForSale,
353
+ createdAt: e.createdAt,
354
+ title: e.title,
355
+ image: e.featuredImage?.url || null,
356
+ collectionIds: e.collections.nodes.map((e) => Number(e.id.split("/").pop())),
357
+ options: i,
358
+ selectedVariantId: Number(e.variants.nodes[0].id.split("/").pop()),
359
+ variants: r,
360
+ requiresSellingPlan: e.requiresSellingPlan,
361
+ sellingPlans: s,
362
+ isNativeBundle: c,
363
+ metafields: {
364
+ text: e.metafield?.value || null,
365
+ text2: e.metafield2?.value || null,
366
+ text3: e.metafield3?.value || null,
367
+ text4: e.metafield4?.value || null
368
+ },
369
+ rating: _(e.reviewsRating, e.reviewsRatingCount),
370
+ subtitle: e.subtitle?.value || null
371
+ };
372
+ }, _ = (e, t) => {
373
+ if (!e) return null;
374
+ let n = v(e.value);
375
+ if (n === null) return null;
376
+ let r = Number(t?.value);
377
+ return {
378
+ value: n,
379
+ count: Number.isInteger(r) && r > 0 ? r : null
380
+ };
381
+ }, v = (e) => {
382
+ try {
383
+ let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
384
+ return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
385
+ } catch {
386
+ return null;
387
+ }
388
+ }, y = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), b = "app--2935586817", x = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
389
+ let a = i ? `${b}--kaching_bundles` : "$app:kaching_bundles", o = i ? b : "$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(`
390
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
586
391
  localization {
587
392
  country {
588
393
  currency {
@@ -606,463 +411,340 @@ const T = (e, t) => {
606
411
  }
607
412
  }
608
413
  }
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
- }
1009
- };
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
414
+ `, { variables: {
415
+ metafieldNamespace: a,
416
+ settingsNamespace: o
417
+ } }), h = l === d ? u : e(l, {
418
+ language: n,
419
+ country: r
420
+ }), g = f ? S(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
421
+ return {
422
+ shopifyDomain: p.host,
423
+ moneyFormat: h,
424
+ locale: n?.toLowerCase() || "en",
425
+ liquidLocale: n?.toLowerCase() || "en",
426
+ country: r ?? "US",
427
+ currencyRate: g,
428
+ marketId: 0,
429
+ productId: null,
430
+ storefrontAccessToken: _?.storefront_access_token ?? null,
431
+ includeSellingPlans: _?.include_selling_plans ?? !1,
432
+ includeAvailableQuantity: _?.include_available_quantity ?? !1,
433
+ customApiHost: _?.custom_api_host ?? null,
434
+ keepQuantityInput: _?.keep_quantity_input ?? !1,
435
+ ignoreDeselect: _?.ignore_deselect ?? !1,
436
+ ignoreUnitPrice: _?.ignore_unit_price ?? !1,
437
+ requireCustomerLogin: _?.require_customer_login ?? !1,
438
+ abTestsRunning: _?.ab_tests_running ?? !1,
439
+ webPixel: _?.web_pixel ?? !1,
440
+ b2bCustomer: !1,
441
+ isLoggedIn: !1,
442
+ preview: !1,
443
+ previewAlerts: !1,
444
+ previewScratchOff: !1,
445
+ defaultTranslations: {
446
+ "system.out_of_stock": "Out of stock",
447
+ "system.invalid_variant": "Invalid variant",
448
+ "system.unavailable_option_value": "Unavailable option value",
449
+ "system.confirm": "Confirm",
450
+ "system.cancel": "Cancel",
451
+ "system.free": "FREE",
452
+ "system.search": "Search",
453
+ "system.quantity": "Quantity",
454
+ "system.subscription_plan": "Subscription plan",
455
+ "system.remove": "Remove",
456
+ "system.sort_by": "Sort by",
457
+ "system.sort_relevance": "Relevance",
458
+ "system.sort_newest_first": "Newest first",
459
+ "system.sort_price_low_to_high": "Price: Low → High",
460
+ "system.sort_price_high_to_low": "Price: High → Low",
461
+ "system.no_results_found": "No results found",
462
+ "system.no_results_description": "We can't find any item matching your search.",
463
+ "system.clear_search": "Clear search",
464
+ "system.no_products_available": "No products available",
465
+ "system.original_price": "Original price:",
466
+ "system.price": "Price:",
467
+ "system.letters_only": "Only letters are allowed.",
468
+ "system.numbers_only": "Only numbers are allowed."
469
+ },
470
+ customSelectors: {
471
+ quantity: y.quantity ?? null,
472
+ addToCartButton: y.add_to_cart_button ?? null,
473
+ variantPicker: y.variant_picker ?? null,
474
+ price: y.price ?? null,
475
+ priceCompare: y.price_compare ?? null
476
+ },
477
+ shopCustomStyles: _?.shop_custom_styles ?? "",
478
+ featureFlags: v,
479
+ brandColors: _?.brand_colors ?? null
480
+ };
481
+ }, S = (e) => JSON.parse(e).amount / 1e6, C = async (e, t, n = 200) => {
482
+ let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
483
+ if (r.length === 0) return [];
484
+ let i = [];
485
+ for (let e = 0; e < r.length; e += 250) i.push(r.slice(e, e + 250));
486
+ 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: {
487
+ mediaImageIds: t,
488
+ size: n
489
+ } })))).flatMap((e) => e.nodes).flatMap((e) => e?.image ? [{
490
+ gid: e.id,
491
+ url: e.image.url
492
+ }] : []);
493
+ }, w = (e) => [
494
+ ...T(e),
495
+ ...E(e),
496
+ ...D(e),
497
+ ...O(e),
498
+ ...k(e),
499
+ ...A(e),
500
+ ...j(e),
501
+ ...ee(e),
502
+ ...M(e),
503
+ ...N(e),
504
+ ...P(e),
505
+ ...F(e),
506
+ ...I(e)
507
+ ].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 === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), D = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), O = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), k = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), A = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
508
+ let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
509
+ return [...e, ...n];
510
+ }, []) : [], j = (e) => {
511
+ if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
512
+ let t = e.collectionBreaks.mediaImageGID;
513
+ return t ? [t] : [];
514
+ }, ee = (e) => e.progressiveGifts ? [
515
+ ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
516
+ e.progressiveGifts.style?.lockedMediaImageGID,
517
+ e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
518
+ ].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) => {
519
+ let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
520
+ return n ? [...t, n] : t;
521
+ }, 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) => {
522
+ let t = [
523
+ ...R(e),
524
+ ...z(e),
525
+ ...B(e),
526
+ ...V(e),
527
+ ...H(e),
528
+ ...U(e),
529
+ ...W(e),
530
+ ...G(e)
531
+ ];
532
+ return Array.from(new Set(t.filter((e) => e != null)));
533
+ }, 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 === d.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 === d.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 === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), K = class extends Error {
534
+ constructor({ status: e, operationName: t, graphqlErrors: n }) {
535
+ let r = n.length ? `: ${n.join("; ")}` : "";
536
+ super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
537
+ }
538
+ }, q = async (e, t) => {
539
+ let n = await e.text();
540
+ if (!n) throw Error("Empty graphql response");
541
+ let r;
542
+ try {
543
+ r = JSON.parse(n);
544
+ } catch (n) {
545
+ throw e.ok ? n : new K({
546
+ status: e.status,
547
+ operationName: t,
548
+ graphqlErrors: []
549
+ });
550
+ }
551
+ if (!e.ok || r.data === null || r.data === void 0) throw new K({
552
+ status: e.status,
553
+ operationName: t,
554
+ graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
555
+ });
556
+ return r.data;
557
+ }, J = class {
558
+ constructor(e, t) {
559
+ this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
560
+ }
561
+ async query(e, t) {
562
+ let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
563
+ return i && (r += `?operation_name=${i}`), q(await fetch(r, {
564
+ method: "POST",
565
+ headers: {
566
+ "Content-Type": "application/json",
567
+ "X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
568
+ },
569
+ body: JSON.stringify({
570
+ query: e,
571
+ variables: n
572
+ })
573
+ }), i);
574
+ }
575
+ }, Y = (e, t) => {
576
+ let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
577
+ for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
578
+ let i = e.filter((e) => e.blockVisibility === "selected-collections");
579
+ for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
580
+ let a = e.filter((e) => e.blockVisibility === "excluded-products");
581
+ for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
582
+ let o = e.filter((e) => e.blockVisibility === "all-products");
583
+ for (let e of o) n.push(e);
584
+ return n;
585
+ }, X = async (e, t, { country: n, language: r }) => {
586
+ let i = t.collectionBreaks;
587
+ if (!t.collectionBreaksEnabled || !i) return;
588
+ let a;
589
+ a = i.visibility === "deal-products" ? await f(e, {
590
+ country: n,
591
+ language: r,
592
+ blockVisibility: t.blockVisibility,
593
+ excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
594
+ selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
595
+ selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
596
+ }) : await f(e, {
597
+ country: n,
598
+ language: r,
599
+ blockVisibility: i.visibility,
600
+ excludedProductGIDs: (i.excludedProducts || []).map(({ id: e }) => e),
601
+ selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
602
+ selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
603
+ });
604
+ let o = await m(e, {
605
+ country: n,
606
+ language: r,
607
+ productIds: a.map((e) => Number(e.split("/").pop())),
608
+ useExternalMetafieldNamespace: !0
609
+ });
610
+ return o = o.filter((e) => e.availableForSale), o;
611
+ }, Z = ({ language: e, dealBlockId: t }) => {
612
+ let n = {
613
+ "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
614
+ "system.invalid_variant": "Sorry, this is not currently available.",
615
+ "system.unavailable_option_value": "Unavailable",
616
+ "system.confirm": "Confirm",
617
+ "system.cancel": "Cancel",
618
+ "system.free": "FREE",
619
+ "system.search": "Search",
620
+ "system.quantity": "Quantity",
621
+ "system.subscription_plan": "Subscription plan",
622
+ "system.remove": "Remove",
623
+ "system.sort_by": "Sort by",
624
+ "system.sort_relevance": "Relevance",
625
+ "system.sort_newest_first": "Newest first",
626
+ "system.sort_price_low_to_high": "Price: Low → High",
627
+ "system.sort_price_high_to_low": "Price: High → Low",
628
+ "system.no_results_found": "No results found",
629
+ "system.no_results_description": "We can't find any item matching your search.",
630
+ "system.clear_search": "Clear search",
631
+ "system.no_products_available": "No products available",
632
+ "system.original_price": "Original price:",
633
+ "system.price": "Price:",
634
+ "system.letters_only": "Only letters are allowed.",
635
+ "system.numbers_only": "Only numbers are allowed.",
636
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue."
637
+ }, r = e ? Q(e) : void 0;
638
+ return {
639
+ ...n,
640
+ ...r?.system,
641
+ ...r?.dealBlocks[t]
642
+ };
643
+ }, Q = (e) => {
644
+ if (typeof document > "u") return;
645
+ let t = document.querySelector("script#kaching-bundles-translations");
646
+ if (!t?.textContent) return;
647
+ let n;
648
+ try {
649
+ n = JSON.parse(t.textContent);
650
+ } catch {
651
+ return;
652
+ }
653
+ let r = $(e);
654
+ return n.find((e) => $(e.locale) === r)?.translations;
655
+ }, $ = (e) => e.toLowerCase().replace(/_/g, "-"), te = "2026-07", ne = async (e, { productId: t, dealBlockId: n, country: r = void 0, language: i = void 0 }) => {
656
+ try {
657
+ let a = [Number(t.split("/").pop())], o = new re(e);
658
+ r ||= o.i18n?.country, i ||= o.i18n?.language;
659
+ let s = await x(o, {
660
+ language: i,
661
+ country: r,
662
+ useExternalMetafieldNamespace: !0
663
+ });
664
+ o.shopifyDomain = s.shopifyDomain;
665
+ let l = s.storefrontAccessToken ? new J(s.shopifyDomain, s.storefrontAccessToken) : o, [u, d] = await Promise.all([m(l, {
666
+ country: r,
667
+ language: i,
668
+ productIds: a,
669
+ useExternalMetafieldNamespace: !0
670
+ }), c(l, {
671
+ useExternalMetafieldNamespace: !0,
672
+ useMetaobjects: s.featureFlags.storefront_metaobjects
673
+ })]), f = u[0];
674
+ if (!f) return null;
675
+ let p = Y(d, f), h;
676
+ if (n ? (h = p.find((e) => e.id === n || e.nanoId === n), h ||= p[0]) : h = p[0], !h) return null;
677
+ let g = w(h), _ = L(h), [v, y, b, S] = await Promise.all([
678
+ m(l, {
679
+ country: r,
680
+ language: i,
681
+ productIds: _,
682
+ useExternalMetafieldNamespace: !0
683
+ }),
684
+ C(l, g, 300),
685
+ X(l, h, {
686
+ country: r,
687
+ language: i
688
+ }),
689
+ Z({
690
+ language: i,
691
+ dealBlockId: h.id
692
+ })
693
+ ]);
694
+ return {
695
+ product: f,
696
+ dealBlock: h,
697
+ config: s,
698
+ otherProducts: v,
699
+ mediaImages: y,
700
+ collectionBreaksProducts: b ?? [],
701
+ translations: S
702
+ };
703
+ } catch (e) {
704
+ return console.error(e), null;
705
+ }
706
+ }, re = class {
707
+ constructor(e) {
708
+ this.storefront = e, this.shopifyDomain = "";
709
+ }
710
+ async query(e, t) {
711
+ if ("query" in this.storefront && "i18n" in this.storefront) return await this.storefront.query(e, t);
712
+ if ("graphql" in this.storefront) {
713
+ let n = await this.storefront.graphql(e, t);
714
+ if (n.errors?.length) throw Error(n.errors.map((e) => e.message).join("\n"));
715
+ return n.data;
716
+ }
717
+ if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
718
+ if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
719
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${te}/graphql.json`, {
720
+ body: JSON.stringify({
721
+ query: e,
722
+ variables: t?.variables
723
+ }),
724
+ headers: {
725
+ "Content-Type": "application/json",
726
+ "X-Shopify-Storefront-Access-Token": this.storefront.storefrontAccessToken
727
+ },
728
+ method: "POST"
729
+ });
730
+ if (!n.ok) throw Error(n.statusText);
731
+ return (await n.json()).data;
732
+ }
733
+ {
734
+ let n = await fetch(this.storefront.getStorefrontApiUrl(), {
735
+ body: JSON.stringify({
736
+ query: e,
737
+ variables: t?.variables
738
+ }),
739
+ headers: this.storefront.getPublicTokenHeaders(),
740
+ method: "POST"
741
+ });
742
+ if (!n.ok) throw Error(n.statusText);
743
+ return (await n.json()).data;
744
+ }
745
+ }
746
+ get i18n() {
747
+ if ("i18n" in this.storefront) return this.storefront.i18n;
748
+ }
1068
749
  };
750
+ export { ne as fetchKachingBundlesData };