@kachingappz/bundles-js 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,46 +1,46 @@
1
1
  const U = (t, e) => {
2
- const s = [], n = t.filter(
3
- (l) => l.blockVisibility === "selected-products"
2
+ const s = [], l = t.filter(
3
+ (i) => i.blockVisibility === "selected-products"
4
4
  );
5
- for (const l of n)
6
- l.selectedProductIds.map(Number).includes(e.id) && s.push(l);
7
- const i = t.filter(
8
- (l) => l.blockVisibility === "selected-collections"
5
+ for (const i of l)
6
+ i.selectedProductIds.map(Number).includes(e.id) && s.push(i);
7
+ const n = t.filter(
8
+ (i) => i.blockVisibility === "selected-collections"
9
9
  );
10
- for (const l of i)
10
+ for (const i of n)
11
11
  e.collectionIds.some(
12
- (m) => l.selectedCollectionIds.map(Number).includes(m)
13
- ) && s.push(l);
12
+ (m) => i.selectedCollectionIds.map(Number).includes(m)
13
+ ) && s.push(i);
14
14
  const r = t.filter(
15
- (l) => l.blockVisibility === "excluded-products"
15
+ (i) => i.blockVisibility === "excluded-products"
16
16
  );
17
- for (const l of r)
18
- !l.excludedProductIds.map(Number).includes(e.id) && !(l.excludedCollectionIds || []).some(
17
+ for (const i of r)
18
+ !i.excludedProductIds.map(Number).includes(e.id) && !(i.excludedCollectionIds || []).some(
19
19
  (m) => e.collectionIds.includes(m)
20
- ) && s.push(l);
20
+ ) && s.push(i);
21
21
  const o = t.filter(
22
- (l) => l.blockVisibility === "all-products"
22
+ (i) => i.blockVisibility === "all-products"
23
23
  );
24
- for (const l of o)
25
- s.push(l);
24
+ for (const i of o)
25
+ s.push(i);
26
26
  return s;
27
27
  }, L = (t, { language: e, country: s }) => {
28
28
  var y, h;
29
- const n = V(e, s), i = new Intl.NumberFormat(n, {
29
+ const l = V(e, s), n = new Intl.NumberFormat(l, {
30
30
  style: "currency",
31
31
  currency: t,
32
32
  currencyDisplay: "narrowSymbol"
33
- }).formatToParts(123456789e-2), r = (y = i.find((f) => f.type === "decimal")) == null ? void 0 : y.value, o = F(
34
- (h = i.find((f) => f.type === "group")) == null ? void 0 : h.value
35
- ), l = i.some((f) => f.type === "fraction"), m = R(
33
+ }).formatToParts(123456789e-2), r = (y = n.find((f) => f.type === "decimal")) == null ? void 0 : y.value, o = F(
34
+ (h = n.find((f) => f.type === "group")) == null ? void 0 : h.value
35
+ ), i = n.some((f) => f.type === "fraction"), m = R(
36
36
  o,
37
37
  r,
38
- l
39
- ), d = i.findIndex(C), u = i.findLastIndex(C);
38
+ i
39
+ ), d = n.findIndex(C), u = n.findLastIndex(C);
40
40
  return [
41
- ...i.slice(0, d).map(x),
41
+ ...n.slice(0, d).map(x),
42
42
  m,
43
- ...i.slice(u + 1).map(x)
43
+ ...n.slice(u + 1).map(x)
44
44
  ].join("");
45
45
  }, x = (t) => O(t.value), O = (t) => t.replace(/\s/g, " "), C = (t) => t.type === "integer" || t.type === "group" || t.type === "decimal" || t.type === "fraction", V = (t, e) => t && e ? `${t}-${e.toUpperCase()}` : t || (e ? e.toUpperCase() : "en"), F = (t) => t === void 0 ? void 0 : O(t).replace(/’/g, "'"), R = (t, e, s) => e === "," && t === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : e === "," && t === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : e === "." && t === " " ? "{{amount_with_period_and_space_separator}}" : e === "." && t === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
46
46
  country: t,
@@ -54,8 +54,8 @@ const U = (t, e) => {
54
54
  }) => s ? J(
55
55
  t
56
56
  ) : Q(t), Q = async (t, e) => {
57
- var n;
58
- const s = (n = (await t.query(
57
+ var l;
58
+ const s = (l = (await t.query(
59
59
  `
60
60
  query FetchDealBlocks($metafieldNamespace: String!) {
61
61
  shop {
@@ -70,11 +70,11 @@ const U = (t, e) => {
70
70
  metafieldNamespace: "app--2935586817--kaching_bundles"
71
71
  }
72
72
  }
73
- )).shop.metafield) == null ? void 0 : n.value;
73
+ )).shop.metafield) == null ? void 0 : l.value;
74
74
  return s ? JSON.parse(s) : [];
75
75
  }, J = async (t, e) => {
76
- const s = "app--2935586817--deal_block", n = [];
77
- let i = null;
76
+ const s = "app--2935586817--deal_block", l = [];
77
+ let n = null;
78
78
  for (; ; ) {
79
79
  const r = await t.query(
80
80
  `
@@ -96,39 +96,39 @@ const U = (t, e) => {
96
96
  {
97
97
  variables: {
98
98
  type: s,
99
- cursor: i
99
+ cursor: n
100
100
  }
101
101
  }
102
102
  );
103
103
  for (const o of r.metaobjects.nodes) {
104
- const l = o.fields.find(
104
+ const i = o.fields.find(
105
105
  (m) => m.key === "settings"
106
106
  );
107
- l != null && l.value && n.push(JSON.parse(l.value));
107
+ i != null && i.value && l.push(JSON.parse(i.value));
108
108
  }
109
109
  if (!r.metaobjects.pageInfo.hasNextPage)
110
110
  break;
111
- i = r.metaobjects.pageInfo.endCursor;
111
+ n = r.metaobjects.pageInfo.endCursor;
112
112
  }
113
- return n;
113
+ return l;
114
114
  }, N = async (t, {
115
115
  country: e,
116
116
  language: s,
117
- blockVisibility: n,
118
- excludedProductGIDs: i,
117
+ blockVisibility: l,
118
+ excludedProductGIDs: n,
119
119
  selectedProductGIDs: r,
120
120
  selectedCollectionGIDs: o,
121
- limit: l = 1e3
121
+ limit: i = 1e3
122
122
  }) => {
123
- switch (n) {
123
+ switch (l) {
124
124
  case "selected-products":
125
- return r.slice(0, l);
125
+ return r.slice(0, i);
126
126
  case "all-products":
127
127
  case "excluded-products": {
128
128
  const m = w({ country: e, language: s });
129
129
  let d = [], u = null;
130
- for (; d.length < l; ) {
131
- const y = Math.min(l - d.length, 250), h = await t.query(
130
+ for (; d.length < i; ) {
131
+ const y = Math.min(i - d.length, 250), h = await t.query(
132
132
  `
133
133
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
134
134
  products(first: $limit, after: $cursor) {
@@ -152,8 +152,8 @@ const U = (t, e) => {
152
152
  if (d.push(...h.products.nodes.map((f) => f.id)), !h.products.pageInfo.hasNextPage) break;
153
153
  u = h.products.pageInfo.endCursor;
154
154
  }
155
- if (n === "excluded-products") {
156
- const y = new Set(i);
155
+ if (l === "excluded-products") {
156
+ const y = new Set(n);
157
157
  d = d.filter((h) => !y.has(h));
158
158
  }
159
159
  return d;
@@ -176,13 +176,13 @@ const U = (t, e) => {
176
176
  {
177
177
  variables: {
178
178
  collectionGIDs: o,
179
- limit: Math.min(l, 250)
179
+ limit: Math.min(i, 250)
180
180
  }
181
181
  }
182
182
  )).nodes.filter((u) => u !== null).flatMap(
183
183
  (u) => u.products.nodes.map((y) => y.id)
184
184
  );
185
- return Array.from(new Set(d)).slice(0, l);
185
+ return Array.from(new Set(d)).slice(0, i);
186
186
  }
187
187
  }
188
188
  }, j = `
@@ -231,16 +231,16 @@ const U = (t, e) => {
231
231
  `, D = async (t, {
232
232
  country: e,
233
233
  language: s,
234
- productIds: n,
235
- includeSellingPlans: i = !0,
234
+ productIds: l,
235
+ includeSellingPlans: n = !0,
236
236
  includeAvailableQuantity: r = !0,
237
237
  useExternalMetafieldNamespace: o = !1,
238
- batchSize: l = 250,
238
+ batchSize: i = 250,
239
239
  onBatchError: m
240
240
  }) => {
241
- if (!n.length)
241
+ if (!l.length)
242
242
  return [];
243
- const d = n.map((c) => typeof c == "string" && c.startsWith("gid://") ? c : `gid://shopify/Product/${c}`), u = w({ country: e, language: s }), y = `
243
+ const d = l.map((c) => typeof c == "string" && c.startsWith("gid://") ? c : `gid://shopify/Product/${c}`), u = w({ country: e, language: s }), y = `
244
244
  query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${u} {
245
245
  shop {
246
246
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
@@ -327,7 +327,7 @@ const U = (t, e) => {
327
327
  }
328
328
  }
329
329
  }
330
- `, h = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(l, 250);
330
+ `, h = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(i, 250);
331
331
  for (let c = 0; c < d.length; c += v)
332
332
  f.push(d.slice(c, c + v));
333
333
  let a = 1;
@@ -335,7 +335,7 @@ const U = (t, e) => {
335
335
  const b = await t.query(y, {
336
336
  variables: {
337
337
  productGIDs: c,
338
- includeSellingPlans: i,
338
+ includeSellingPlans: n,
339
339
  includeAvailableQuantity: r,
340
340
  metafieldNamespace: h
341
341
  }
@@ -361,7 +361,7 @@ const U = (t, e) => {
361
361
  const P = await G(
362
362
  t,
363
363
  I,
364
- { includeSellingPlans: i, includeAvailableQuantity: r },
364
+ { includeSellingPlans: n, includeAvailableQuantity: r },
365
365
  u
366
366
  );
367
367
  return B(
@@ -383,7 +383,7 @@ const U = (t, e) => {
383
383
  t,
384
384
  c,
385
385
  {
386
- includeSellingPlans: i,
386
+ includeSellingPlans: n,
387
387
  includeAvailableQuantity: r
388
388
  },
389
389
  u
@@ -392,15 +392,15 @@ const U = (t, e) => {
392
392
  )).map(
393
393
  (c) => B(c, t.shopifyDomain, a)
394
394
  );
395
- }, G = async (t, e, s, n = "") => {
395
+ }, G = async (t, e, s, l = "") => {
396
396
  if (e.variants.nodes.length < 250)
397
397
  return e;
398
- const i = /* @__PURE__ */ new Set(), r = [], o = [], l = async (m) => {
398
+ const n = /* @__PURE__ */ new Set(), r = [], o = [], i = async (m) => {
399
399
  let d = !0, u = null;
400
400
  for (; d; ) {
401
401
  const y = await t.query(
402
402
  `
403
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${n} {
403
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
404
404
  product(id: $productGID) {
405
405
  variants(first: 250, after: $cursor, reverse: $reverse) {
406
406
  nodes {
@@ -424,22 +424,22 @@ const U = (t, e) => {
424
424
  }
425
425
  ), { nodes: h, pageInfo: f } = y.product.variants;
426
426
  for (const v of h) {
427
- if (i.has(v.id)) {
427
+ if (n.has(v.id)) {
428
428
  d = !1;
429
429
  break;
430
430
  }
431
- i.add(v.id), m ? o.push(v) : r.push(v);
431
+ n.add(v.id), m ? o.push(v) : r.push(v);
432
432
  }
433
433
  f.hasNextPage || (d = !1), u = f.endCursor;
434
434
  }
435
435
  };
436
436
  return await Promise.all([
437
- l(!1),
438
- l(!0)
437
+ i(!1),
438
+ i(!0)
439
439
  ]), e.variants.nodes = [...r, ...o.reverse()], e;
440
440
  }, B = (t, e, s) => {
441
441
  var d, u, y, h, f, v;
442
- const n = t.variants.nodes.map(
442
+ const l = t.variants.nodes.map(
443
443
  ({ unitPriceMeasurement: a, ...p }) => {
444
444
  var g, _;
445
445
  return {
@@ -473,7 +473,7 @@ const U = (t, e) => {
473
473
  } : null
474
474
  };
475
475
  }
476
- ), i = t.options.map((a, p) => {
476
+ ), n = t.options.map((a, p) => {
477
477
  const g = a.optionValues.map((_) => {
478
478
  var c, b, I, P;
479
479
  return {
@@ -490,7 +490,7 @@ const U = (t, e) => {
490
490
  defaultName: a.name,
491
491
  name: a.name,
492
492
  position: p + 1,
493
- optionValues: H(g, p, n)
493
+ optionValues: H(g, p, l)
494
494
  };
495
495
  }), r = (a) => {
496
496
  const p = a.priceAdjustments[0];
@@ -518,7 +518,7 @@ const U = (t, e) => {
518
518
  `Unknown price adjustment type: ${g.__typename}`
519
519
  );
520
520
  }
521
- }, o = (a) => s === 1 ? Number(a) * 100 : Math.round(Number(a) * 100 * s), l = ((d = t.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
521
+ }, o = (a) => s === 1 ? Number(a) * 100 : Math.round(Number(a) * 100 * s), i = ((d = t.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
522
522
  (a) => a.sellingPlans.nodes.map((p) => ({
523
523
  id: Number(p.id.split("/").pop()),
524
524
  name: p.name,
@@ -538,13 +538,13 @@ const U = (t, e) => {
538
538
  collectionIds: t.collections.nodes.map(
539
539
  (a) => Number(a.id.split("/").pop())
540
540
  ),
541
- options: i,
541
+ options: n,
542
542
  selectedVariantId: Number(
543
543
  t.variants.nodes[0].id.split("/").pop()
544
544
  ),
545
- variants: n,
545
+ variants: l,
546
546
  requiresSellingPlan: t.requiresSellingPlan,
547
- sellingPlans: l,
547
+ sellingPlans: i,
548
548
  isNativeBundle: m,
549
549
  metafields: {
550
550
  text: ((y = t.metafield) == null ? void 0 : y.value) || null,
@@ -553,17 +553,17 @@ const U = (t, e) => {
553
553
  text4: ((v = t.metafield4) == null ? void 0 : v.value) || null
554
554
  }
555
555
  };
556
- }, H = (t, e, s) => t.filter((n) => s.filter(
557
- (i) => i.options[e] === n.name
556
+ }, H = (t, e, s) => t.filter((l) => s.filter(
557
+ (n) => n.options[e] === l.name
558
558
  ).length > 0), T = "app--2935586817", X = async (t, {
559
559
  language: e,
560
560
  country: s,
561
- useExternalMetafieldNamespace: n
561
+ useExternalMetafieldNamespace: l
562
562
  }) => {
563
- const i = `${T}--kaching_bundles`, r = T, o = w({ country: s }), {
563
+ const n = `${T}--kaching_bundles`, r = T, o = w({ country: s }), {
564
564
  localization: {
565
565
  country: {
566
- currency: { isoCode: l }
566
+ currency: { isoCode: i }
567
567
  }
568
568
  },
569
569
  shop: {
@@ -602,11 +602,11 @@ const U = (t, e) => {
602
602
  `,
603
603
  {
604
604
  variables: {
605
- metafieldNamespace: i,
605
+ metafieldNamespace: n,
606
606
  settingsNamespace: r
607
607
  }
608
608
  }
609
- ), f = l === d ? m : L(l, { language: e, country: s }), v = u ? W(u.value) : 1, a = h ? JSON.parse(h.value) : null, p = (a == null ? void 0 : a.feature_flags) ?? {}, g = (a == null ? void 0 : a.custom_selectors) ?? {};
609
+ ), f = i === d ? m : L(i, { language: e, country: s }), v = u ? W(u.value) : 1, a = h ? JSON.parse(h.value) : null, p = (a == null ? void 0 : a.feature_flags) ?? {}, g = (a == null ? void 0 : a.custom_selectors) ?? {};
610
610
  return {
611
611
  shopifyDomain: y.host,
612
612
  moneyFormat: f,
@@ -667,7 +667,7 @@ const U = (t, e) => {
667
667
  featureFlags: p,
668
668
  brandColors: (a == null ? void 0 : a.brand_colors) ?? null
669
669
  };
670
- }, W = (t) => JSON.parse(t).amount / 1e6, K = async (t, e, s = 200) => (e = e.filter(Boolean).filter((n) => !n.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
670
+ }, W = (t) => JSON.parse(t).amount / 1e6, K = async (t, e, s = 200) => (e = e.filter(Boolean).filter((l) => !l.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
671
671
  `
672
672
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
673
673
  nodes(ids: $mediaImageIds) {
@@ -686,9 +686,9 @@ const U = (t, e) => {
686
686
  size: s
687
687
  }
688
688
  }
689
- )).nodes.filter(Boolean).map((n) => ({
690
- gid: n.id,
691
- url: n.image.url
689
+ )).nodes.filter(Boolean).map((l) => ({
690
+ gid: l.id,
691
+ url: l.image.url
692
692
  })));
693
693
  var S = /* @__PURE__ */ ((t) => (t.QuantityBreak = "quantity-break", t.Bxgy = "bxgy", t.Bundle = "bundle", t.MixAndMatch = "mix-and-match", t.Sku = "sku", t))(S || {});
694
694
  const Y = (t) => [
@@ -714,29 +714,29 @@ const Y = (t) => [
714
714
  ).reduce((e, s) => e.concat(s), []).filter((e) => e != null), se = (t) => t.dealBars.flatMap(
715
715
  ({ multipleGiftsSelectors: e }) => (e || []).map((s) => s.mediaImageGID)
716
716
  ).filter((e) => e != null), ae = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((s) => s.mediaImageGID)).reduce((e, s) => e.concat(s), []).filter((e) => e != null), ne = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, s) => {
717
- const n = s.images.map((i) => i.mediaImageGID).filter((i) => i != null);
718
- return [...e, ...n];
717
+ const l = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
718
+ return [...e, ...l];
719
719
  }, []) : [], le = (t) => {
720
720
  if (!t.collectionBreaksEnabled || !t.collectionBreaks)
721
721
  return [];
722
722
  const e = t.collectionBreaks.mediaImageGID;
723
723
  return e ? [e] : [];
724
724
  }, ie = (t) => {
725
- var e, s, n;
725
+ var e, s, l;
726
726
  return t.progressiveGifts ? [
727
- ...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((i) => i.mediaImageGID)) || [],
727
+ ...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((n) => n.mediaImageGID)) || [],
728
728
  (s = t.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
729
- (n = t.progressiveGifts.dealBarStyle) == null ? void 0 : n.lockedMediaImageGID
730
- ].filter((i) => i != null) : [];
729
+ (l = t.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
730
+ ].filter((n) => n != null) : [];
731
731
  }, re = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), oe = (t) => t.dealBars.map((e) => {
732
732
  var s;
733
733
  return (s = e.productPersonalisation) == null ? void 0 : s.mediaImageGID;
734
734
  }).filter((e) => e != null), ce = (t) => {
735
- var n, i;
735
+ var l, n;
736
736
  const e = t.dealBars.map((r) => {
737
737
  var o;
738
738
  return (o = r.highlights) == null ? void 0 : o.customIconGID;
739
- }).filter((r) => r != null), s = (i = (n = t.subscriptions) == null ? void 0 : n.highlights) == null ? void 0 : i.customIconGID;
739
+ }).filter((r) => r != null), s = (n = (l = t.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : n.customIconGID;
740
740
  return s ? [...e, s] : e;
741
741
  }, ue = (t) => (t.badges || []).flatMap(
742
742
  (e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []
@@ -756,7 +756,7 @@ const Y = (t) => [
756
756
  ({ freeGifts: e }) => e ? e.map((s) => s.productGID) : []
757
757
  ).filter((e) => e != null), fe = (t) => t.dealBars.flatMap(
758
758
  ({ multipleGiftsSelectors: e }) => e ? e.flatMap(
759
- (s) => s.products ? s.products.map((n) => n.id) : []
759
+ (s) => s.products ? s.products.map((l) => l.id) : []
760
760
  ) : []
761
761
  ).filter((e) => e != null), he = (t) => {
762
762
  var e;
@@ -765,10 +765,10 @@ const Y = (t) => [
765
765
  ({ bundleProducts: e }) => e ? e.map((s) => s.productGID) : []
766
766
  ).filter((e) => e != null).filter((e) => e !== "default"), be = (t) => t.dealBars.filter((e) => e.dealBarType === S.MixAndMatch).flatMap(
767
767
  ({ bundleProducts: e }) => e ? e.flatMap((s) => {
768
- var n;
768
+ var l;
769
769
  return [
770
770
  s.productGID,
771
- ...((n = s.selectedProducts) == null ? void 0 : n.map((i) => i.id)) ?? []
771
+ ...((l = s.selectedProducts) == null ? void 0 : l.map((n) => n.id)) ?? []
772
772
  ];
773
773
  }) : []
774
774
  ).filter((e) => e != null).filter((e) => e !== "default"), ve = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), _e = (t) => t.dealBars.filter((e) => e.dealBarType === S.Sku).flatMap(({ productGID: e }) => e ? [e] : []);
@@ -777,12 +777,12 @@ class Ie {
777
777
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = e;
778
778
  }
779
779
  async query(e, s) {
780
- var l;
781
- const n = (s == null ? void 0 : s.variables) ?? {};
782
- let i = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
- const r = (l = e.match(/query\s+(\w+)/)) == null ? void 0 : l[1];
784
- r && (i += `?operation_name=${r}`);
785
- const o = await (await fetch(i, {
780
+ var i;
781
+ const l = (s == null ? void 0 : s.variables) ?? {};
782
+ let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
+ const r = (i = e.match(/query\s+(\w+)/)) == null ? void 0 : i[1];
784
+ r && (n += `?operation_name=${r}`);
785
+ const o = await (await fetch(n, {
786
786
  method: "POST",
787
787
  headers: {
788
788
  "Content-Type": "application/json",
@@ -790,7 +790,7 @@ class Ie {
790
790
  },
791
791
  body: JSON.stringify({
792
792
  query: e,
793
- variables: n
793
+ variables: l
794
794
  })
795
795
  })).text();
796
796
  if (!o)
@@ -798,45 +798,45 @@ class Ie {
798
798
  return JSON.parse(o).data;
799
799
  }
800
800
  }
801
- const Pe = async (t, e, { country: s, language: n }) => {
802
- const i = e.collectionBreaks;
803
- if (!e.collectionBreaksEnabled || !i) return;
801
+ const Pe = async (t, e, { country: s, language: l }) => {
802
+ const n = e.collectionBreaks;
803
+ if (!e.collectionBreaksEnabled || !n) return;
804
804
  let r;
805
- i.visibility === "deal-products" ? r = await N(t, {
805
+ n.visibility === "deal-products" ? r = await N(t, {
806
806
  country: s,
807
- language: n,
807
+ language: l,
808
808
  blockVisibility: e.blockVisibility,
809
809
  excludedProductGIDs: (e.excludedProductIds || []).map(
810
- (l) => `gid://shopify/Product/${l}`
810
+ (i) => `gid://shopify/Product/${i}`
811
811
  ),
812
812
  selectedProductGIDs: (e.selectedProductIds || []).map(
813
- (l) => `gid://shopify/Product/${l}`
813
+ (i) => `gid://shopify/Product/${i}`
814
814
  ),
815
815
  selectedCollectionGIDs: (e.selectedCollectionIds || []).map(
816
- (l) => `gid://shopify/Collection/${l}`
816
+ (i) => `gid://shopify/Collection/${i}`
817
817
  )
818
818
  }) : r = await N(t, {
819
819
  country: s,
820
- language: n,
821
- blockVisibility: i.visibility,
822
- excludedProductGIDs: (i.excludedProducts || []).map(
823
- ({ id: l }) => l
820
+ language: l,
821
+ blockVisibility: n.visibility,
822
+ excludedProductGIDs: (n.excludedProducts || []).map(
823
+ ({ id: i }) => i
824
824
  ),
825
- selectedProductGIDs: (i.selectedProducts || []).map(
826
- ({ id: l }) => l
825
+ selectedProductGIDs: (n.selectedProducts || []).map(
826
+ ({ id: i }) => i
827
827
  ),
828
- selectedCollectionGIDs: (i.selectedCollections || []).map(
829
- ({ id: l }) => l
828
+ selectedCollectionGIDs: (n.selectedCollections || []).map(
829
+ ({ id: i }) => i
830
830
  )
831
831
  });
832
832
  let o = await D(t, {
833
833
  country: s,
834
- language: n,
835
- productIds: r.map((l) => Number(l.split("/").pop())),
834
+ language: l,
835
+ productIds: r.map((i) => Number(i.split("/").pop())),
836
836
  useExternalMetafieldNamespace: !0
837
837
  });
838
838
  return o = o.filter(
839
- (l) => l.availableForSale
839
+ (i) => i.availableForSale
840
840
  ), o;
841
841
  }, Se = () => ({
842
842
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
@@ -866,16 +866,16 @@ const Pe = async (t, e, { country: s, language: n }) => {
866
866
  }), ke = "2026-07", we = async (t, {
867
867
  productId: e,
868
868
  dealBlockId: s,
869
- country: n = void 0,
870
- language: i = void 0
869
+ country: l = void 0,
870
+ language: n = void 0
871
871
  }) => {
872
872
  var r, o;
873
873
  try {
874
- const l = [Number(e.split("/").pop())], m = new Ee(t);
875
- n = n || ((r = m.i18n) == null ? void 0 : r.country), i = i || ((o = m.i18n) == null ? void 0 : o.language);
874
+ const i = [Number(e.split("/").pop())], m = new Ee(t);
875
+ l = l || ((r = m.i18n) == null ? void 0 : r.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
876
876
  const d = await X(m, {
877
- language: i,
878
- country: n,
877
+ language: n,
878
+ country: l,
879
879
  useExternalMetafieldNamespace: !0
880
880
  });
881
881
  m.shopifyDomain = d.shopifyDomain;
@@ -884,9 +884,9 @@ const Pe = async (t, e, { country: s, language: n }) => {
884
884
  d.storefrontAccessToken
885
885
  ) : m, [y, h] = await Promise.all([
886
886
  D(u, {
887
- country: n,
888
- language: i,
889
- productIds: l,
887
+ country: l,
888
+ language: n,
889
+ productIds: i,
890
890
  useExternalMetafieldNamespace: !0
891
891
  }),
892
892
  z(u, {
@@ -904,15 +904,15 @@ const Pe = async (t, e, { country: s, language: n }) => {
904
904
  return null;
905
905
  const p = Y(a), g = me(a), [_, c, b, I] = await Promise.all([
906
906
  D(u, {
907
- country: n,
908
- language: i,
907
+ country: l,
908
+ language: n,
909
909
  productIds: g,
910
910
  useExternalMetafieldNamespace: !0
911
911
  }),
912
912
  K(u, p, 300),
913
913
  Pe(u, a, {
914
- country: n,
915
- language: i
914
+ country: l,
915
+ language: n
916
916
  }),
917
917
  Se()
918
918
  ]);
@@ -925,8 +925,8 @@ const Pe = async (t, e, { country: s, language: n }) => {
925
925
  collectionBreaksProducts: b ?? [],
926
926
  translations: I
927
927
  };
928
- } catch (l) {
929
- return console.error(l), null;
928
+ } catch (i) {
929
+ return console.error(i), null;
930
930
  }
931
931
  };
932
932
  class Ee {
@@ -934,8 +934,18 @@ class Ee {
934
934
  this.storefront = e, this.shopifyDomain = "";
935
935
  }
936
936
  async query(e, s) {
937
+ var l;
937
938
  if ("query" in this.storefront && "i18n" in this.storefront)
938
939
  return await this.storefront.query(e, s);
940
+ if ("graphql" in this.storefront) {
941
+ const n = await this.storefront.graphql(e, s);
942
+ if ((l = n.errors) != null && l.length)
943
+ throw new Error(
944
+ n.errors.map((r) => r.message).join(`
945
+ `)
946
+ );
947
+ return n.data;
948
+ }
939
949
  if ("request" in this.storefront)
940
950
  return (await this.storefront.request(e, s)).data;
941
951
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
@@ -989,18 +999,18 @@ const E = "kaching-bundles-block", M = 1e4, Ae = "https://bundles-integrations-d
989
999
  }
990
1000
  }, $e = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", xe = () => $e() ? Ae : De, Ce = (t) => {
991
1001
  const e = t.document;
992
- return new Promise((s, n) => {
993
- const i = xe();
1002
+ return new Promise((s, l) => {
1003
+ const n = xe();
994
1004
  if (e.querySelector(
995
- `script[src="${i}"]`
1005
+ `script[src="${n}"]`
996
1006
  )) {
997
- $(t, E).then(s).catch(n);
1007
+ $(t, E).then(s).catch(l);
998
1008
  return;
999
1009
  }
1000
1010
  const o = e.createElement("script");
1001
- o.src = i, o.onload = () => $(t, E).then(s).catch(n), o.onerror = () => n(new Error("Failed to load script")), e.head.appendChild(o);
1011
+ o.src = n, o.onload = () => $(t, E).then(s).catch(l), o.onerror = () => l(new Error("Failed to load script")), e.head.appendChild(o);
1002
1012
  });
1003
- }, $ = (t, e) => new Promise((s, n) => {
1013
+ }, $ = (t, e) => new Promise((s, l) => {
1004
1014
  if (t.customElements.get(e)) {
1005
1015
  s();
1006
1016
  return;
@@ -1008,7 +1018,7 @@ const E = "kaching-bundles-block", M = 1e4, Ae = "https://bundles-integrations-d
1008
1018
  Promise.race([
1009
1019
  t.customElements.whenDefined(e),
1010
1020
  new Promise(
1011
- (i, r) => setTimeout(
1021
+ (n, r) => setTimeout(
1012
1022
  () => r(
1013
1023
  new Error(
1014
1024
  `Custom element "${e}" failed to register within ${M}ms`
@@ -1017,7 +1027,7 @@ const E = "kaching-bundles-block", M = 1e4, Ae = "https://bundles-integrations-d
1017
1027
  M
1018
1028
  )
1019
1029
  )
1020
- ]).then(() => s()).catch(n);
1030
+ ]).then(() => s()).catch(l);
1021
1031
  });
1022
1032
  var k = /* @__PURE__ */ ((t) => (t.QuantityBreak = "quantity-break", t.Bxgy = "bxgy", t.Bundle = "bundle", t.MixAndMatch = "mix-and-match", t.Sku = "sku", t))(k || {});
1023
1033
  const Ne = {
@@ -1303,26 +1313,26 @@ class Me extends HTMLElement {
1303
1313
  await this.initialize();
1304
1314
  }
1305
1315
  async initialize() {
1306
- var o, l;
1316
+ var o, i;
1307
1317
  const e = ++this.initializeId;
1308
1318
  if (this.cleanup(), this.hasAttribute("demo")) {
1309
1319
  if (await q(window), e !== this.initializeId) return;
1310
1320
  this.renderInnerElement(Te);
1311
1321
  return;
1312
1322
  }
1313
- const s = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), i = this.getAttribute("product-id");
1314
- if (!s || !n || !i) return;
1323
+ const s = this.getAttribute("shop-domain"), l = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
1324
+ if (!s || !l || !n) return;
1315
1325
  const [r] = await Promise.all([
1316
1326
  we(
1317
1327
  {
1318
1328
  shopifyDomain: s,
1319
- storefrontAccessToken: n
1329
+ storefrontAccessToken: l
1320
1330
  },
1321
1331
  {
1322
- productId: i,
1332
+ productId: n,
1323
1333
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1324
1334
  country: ((o = this.getAttribute("country")) == null ? void 0 : o.toUpperCase()) ?? void 0,
1325
- language: ((l = this.getAttribute("language")) == null ? void 0 : l.toUpperCase()) ?? void 0
1335
+ language: ((i = this.getAttribute("language")) == null ? void 0 : i.toUpperCase()) ?? void 0
1326
1336
  }
1327
1337
  ),
1328
1338
  q(window)
@@ -1332,24 +1342,24 @@ class Me extends HTMLElement {
1332
1342
  renderInnerElement(e) {
1333
1343
  const {
1334
1344
  config: s,
1335
- dealBlock: n,
1336
- product: i,
1345
+ dealBlock: l,
1346
+ product: n,
1337
1347
  otherProducts: r,
1338
1348
  mediaImages: o,
1339
- collectionBreaksProducts: l,
1349
+ collectionBreaksProducts: i,
1340
1350
  translations: m
1341
1351
  } = e;
1342
1352
  this.innerElement = document.createElement(
1343
1353
  "kaching-bundles-block"
1344
- ), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute(
1354
+ ), this.innerElement.setAttribute("deal-block-id", l.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(l)), this.innerElement.setAttribute(
1345
1355
  "media-images",
1346
1356
  JSON.stringify(o ?? [])
1347
- ), this.innerElement.setAttribute("product", JSON.stringify(i)), this.innerElement.setAttribute(
1357
+ ), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
1348
1358
  "other-products",
1349
1359
  JSON.stringify(r ?? [])
1350
1360
  ), this.innerElement.setAttribute(
1351
1361
  "collection-breaks-products",
1352
- JSON.stringify(l ?? [])
1362
+ JSON.stringify(i ?? [])
1353
1363
  ), this.innerElement.setAttribute(
1354
1364
  "translations",
1355
1365
  JSON.stringify(m ?? {})
@@ -1357,7 +1367,7 @@ class Me extends HTMLElement {
1357
1367
  const d = this.getAttribute("selected-variant-id");
1358
1368
  this.innerElement.setAttribute(
1359
1369
  "current-variant-id",
1360
- String(d ? d.split("/").pop() : i.variants[0].id)
1370
+ String(d ? d.split("/").pop() : n.variants[0].id)
1361
1371
  ), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1362
1372
  const u = this.innerElement, y = () => {
1363
1373
  if (this.innerElement !== u) return;
@@ -1387,10 +1397,10 @@ class Me extends HTMLElement {
1387
1397
  this.handleItemsChanged
1388
1398
  ), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
1389
1399
  }
1390
- attributeChangedCallback(e, s, n) {
1391
- s !== n && this.isConnected && (e === "product-id" || e === "country" || e === "language" ? this.initialize() : e === "selected-variant-id" && this.innerElement && n && this.innerElement.setAttribute(
1400
+ attributeChangedCallback(e, s, l) {
1401
+ s !== l && this.isConnected && (e === "product-id" || e === "country" || e === "language" ? this.initialize() : e === "selected-variant-id" && this.innerElement && l && this.innerElement.setAttribute(
1392
1402
  "current-variant-id",
1393
- n.includes("/") ? String(n.split("/").pop()) : n
1403
+ l.includes("/") ? String(l.split("/").pop()) : l
1394
1404
  ));
1395
1405
  }
1396
1406
  items() {