@kachingappz/bundles-js 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,48 +1,48 @@
1
1
  const q = (e, t) => {
2
- const a = [], r = e.filter(
3
- (n) => n.blockVisibility === "selected-products"
2
+ const a = [], l = e.filter(
3
+ (r) => r.blockVisibility === "selected-products"
4
4
  );
5
- for (const n of r)
6
- n.selectedProductIds.map(Number).includes(t.id) && a.push(n);
7
- const l = e.filter(
8
- (n) => n.blockVisibility === "selected-collections"
5
+ for (const r of l)
6
+ r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
7
+ const n = e.filter(
8
+ (r) => r.blockVisibility === "selected-collections"
9
9
  );
10
- for (const n of l)
10
+ for (const r of n)
11
11
  t.collectionIds.some(
12
- (d) => n.selectedCollectionIds.map(Number).includes(d)
13
- ) && a.push(n);
12
+ (d) => r.selectedCollectionIds.map(Number).includes(d)
13
+ ) && a.push(r);
14
14
  const o = e.filter(
15
- (n) => n.blockVisibility === "excluded-products"
15
+ (r) => r.blockVisibility === "excluded-products"
16
16
  );
17
- for (const n of o)
18
- !n.excludedProductIds.map(Number).includes(t.id) && !(n.excludedCollectionIds || []).some(
17
+ for (const r of o)
18
+ !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
19
19
  (d) => t.collectionIds.includes(d)
20
- ) && a.push(n);
20
+ ) && a.push(r);
21
21
  const u = e.filter(
22
- (n) => n.blockVisibility === "all-products"
22
+ (r) => r.blockVisibility === "all-products"
23
23
  );
24
- for (const n of u)
25
- a.push(n);
24
+ for (const r of u)
25
+ a.push(r);
26
26
  return a;
27
27
  }, j = (e, { language: t, country: a }) => {
28
28
  var b, g;
29
- const r = B(t, a), l = new Intl.NumberFormat(r, {
29
+ const l = B(t, a), n = new Intl.NumberFormat(l, {
30
30
  style: "currency",
31
31
  currency: e,
32
32
  currencyDisplay: "narrowSymbol"
33
- }).formatToParts(123456789e-2), o = (b = l.find((f) => f.type === "decimal")) == null ? void 0 : b.value, u = T(
34
- (g = l.find((f) => f.type === "group")) == null ? void 0 : g.value
35
- ), n = l.some((f) => f.type === "fraction"), d = E(
33
+ }).formatToParts(123456789e-2), o = (b = n.find((f) => f.type === "decimal")) == null ? void 0 : b.value, u = E(
34
+ (g = n.find((f) => f.type === "group")) == null ? void 0 : g.value
35
+ ), r = n.some((f) => f.type === "fraction"), d = T(
36
36
  u,
37
37
  o,
38
- n
39
- ), m = l.findIndex(N), p = l.findLastIndex(N);
38
+ r
39
+ ), m = n.findIndex(N), p = n.findLastIndex(N);
40
40
  return [
41
- ...l.slice(0, m).map(D),
41
+ ...n.slice(0, m).map(D),
42
42
  d,
43
- ...l.slice(p + 1).map(D)
43
+ ...n.slice(p + 1).map(D)
44
44
  ].join("");
45
- }, D = (e) => M(e.value), M = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", B = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), T = (e) => e === void 0 ? void 0 : M(e).replace(/’/g, "'"), E = (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 = ({
45
+ }, D = (e) => M(e.value), M = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", B = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), E = (e) => e === void 0 ? void 0 : M(e).replace(/’/g, "'"), T = (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
46
  country: e,
47
47
  language: t
48
48
  }) => {
@@ -54,8 +54,8 @@ const q = (e, t) => {
54
54
  }) => a ? U(
55
55
  e
56
56
  ) : O(e), O = async (e, t) => {
57
- var r;
58
- const a = (r = (await e.query(
57
+ var l;
58
+ const a = (l = (await e.query(
59
59
  `
60
60
  query FetchDealBlocks($metafieldNamespace: String!) {
61
61
  shop {
@@ -70,11 +70,11 @@ const q = (e, t) => {
70
70
  metafieldNamespace: "app--2935586817--kaching_bundles"
71
71
  }
72
72
  }
73
- )).shop.metafield) == null ? void 0 : r.value;
73
+ )).shop.metafield) == null ? void 0 : l.value;
74
74
  return a ? JSON.parse(a) : [];
75
75
  }, U = async (e, t) => {
76
- const a = "app--2935586817--deal_block", r = [];
77
- let l = null;
76
+ const a = "app--2935586817--deal_block", l = [];
77
+ let n = null;
78
78
  for (; ; ) {
79
79
  const o = await e.query(
80
80
  `
@@ -96,39 +96,39 @@ const q = (e, t) => {
96
96
  {
97
97
  variables: {
98
98
  type: a,
99
- cursor: l
99
+ cursor: n
100
100
  }
101
101
  }
102
102
  );
103
103
  for (const u of o.metaobjects.nodes) {
104
- const n = u.fields.find(
104
+ const r = u.fields.find(
105
105
  (d) => d.key === "settings"
106
106
  );
107
- n != null && n.value && r.push(JSON.parse(n.value));
107
+ r != null && r.value && l.push(JSON.parse(r.value));
108
108
  }
109
109
  if (!o.metaobjects.pageInfo.hasNextPage)
110
110
  break;
111
- l = o.metaobjects.pageInfo.endCursor;
111
+ n = o.metaobjects.pageInfo.endCursor;
112
112
  }
113
- return r;
113
+ return l;
114
114
  }, k = async (e, {
115
115
  country: t,
116
116
  language: a,
117
- blockVisibility: r,
118
- excludedProductGIDs: l,
117
+ blockVisibility: l,
118
+ excludedProductGIDs: n,
119
119
  selectedProductGIDs: o,
120
120
  selectedCollectionGIDs: u,
121
- limit: n = 1e3
121
+ limit: r = 1e3
122
122
  }) => {
123
- switch (r) {
123
+ switch (l) {
124
124
  case "selected-products":
125
- return o.slice(0, n);
125
+ return o.slice(0, r);
126
126
  case "all-products":
127
127
  case "excluded-products": {
128
128
  const d = w({ country: t, language: a });
129
129
  let m = [], p = null;
130
- for (; m.length < n; ) {
131
- const b = Math.min(n - m.length, 250), g = await e.query(
130
+ for (; m.length < r; ) {
131
+ const b = Math.min(r - m.length, 250), g = await e.query(
132
132
  `
133
133
  query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
134
134
  products(first: $limit, after: $cursor) {
@@ -152,8 +152,8 @@ const q = (e, t) => {
152
152
  if (m.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
153
153
  p = g.products.pageInfo.endCursor;
154
154
  }
155
- if (r === "excluded-products") {
156
- const b = new Set(l);
155
+ if (l === "excluded-products") {
156
+ const b = new Set(n);
157
157
  m = m.filter((g) => !b.has(g));
158
158
  }
159
159
  return m;
@@ -176,13 +176,13 @@ const q = (e, t) => {
176
176
  {
177
177
  variables: {
178
178
  collectionGIDs: u,
179
- limit: Math.min(n, 250)
179
+ limit: Math.min(r, 250)
180
180
  }
181
181
  }
182
182
  )).nodes.filter((p) => p !== null).flatMap(
183
183
  (p) => p.products.nodes.map((b) => b.id)
184
184
  );
185
- return Array.from(new Set(m)).slice(0, n);
185
+ return Array.from(new Set(m)).slice(0, r);
186
186
  }
187
187
  }
188
188
  }, C = `
@@ -231,16 +231,16 @@ const q = (e, t) => {
231
231
  `, S = async (e, {
232
232
  country: t,
233
233
  language: a,
234
- productIds: r,
235
- includeSellingPlans: l = !0,
234
+ productIds: l,
235
+ includeSellingPlans: n = !0,
236
236
  includeAvailableQuantity: o = !0,
237
237
  useExternalMetafieldNamespace: u = !1,
238
- batchSize: n = 250,
238
+ batchSize: r = 250,
239
239
  onBatchError: d
240
240
  }) => {
241
- if (!r.length)
241
+ if (!l.length)
242
242
  return [];
243
- const m = r.map((i) => typeof i == "string" && i.startsWith("gid://") ? i : `gid://shopify/Product/${i}`), p = w({ country: t, language: a }), b = `
243
+ const m = l.map((i) => typeof i == "string" && i.startsWith("gid://") ? i : `gid://shopify/Product/${i}`), p = w({ country: t, language: a }), b = `
244
244
  query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${p} {
245
245
  shop {
246
246
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
@@ -327,7 +327,7 @@ const q = (e, t) => {
327
327
  }
328
328
  }
329
329
  }
330
- `, g = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(n, 250);
330
+ `, g = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(r, 250);
331
331
  for (let i = 0; i < m.length; i += v)
332
332
  f.push(m.slice(i, i + v));
333
333
  let s = 1;
@@ -335,7 +335,7 @@ const q = (e, t) => {
335
335
  const h = await e.query(b, {
336
336
  variables: {
337
337
  productGIDs: i,
338
- includeSellingPlans: l,
338
+ includeSellingPlans: n,
339
339
  includeAvailableQuantity: o,
340
340
  metafieldNamespace: g
341
341
  }
@@ -361,7 +361,7 @@ const q = (e, t) => {
361
361
  const P = await G(
362
362
  e,
363
363
  I,
364
- { includeSellingPlans: l, includeAvailableQuantity: o },
364
+ { includeSellingPlans: n, includeAvailableQuantity: o },
365
365
  p
366
366
  );
367
367
  return x(
@@ -383,7 +383,7 @@ const q = (e, t) => {
383
383
  e,
384
384
  i,
385
385
  {
386
- includeSellingPlans: l,
386
+ includeSellingPlans: n,
387
387
  includeAvailableQuantity: o
388
388
  },
389
389
  p
@@ -392,15 +392,15 @@ const q = (e, t) => {
392
392
  )).map(
393
393
  (i) => x(i, e.shopifyDomain, s)
394
394
  );
395
- }, G = async (e, t, a, r = "") => {
395
+ }, G = async (e, t, a, l = "") => {
396
396
  if (t.variants.nodes.length < 250)
397
397
  return t;
398
- const l = /* @__PURE__ */ new Set(), o = [], u = [], n = async (d) => {
398
+ const n = /* @__PURE__ */ new Set(), o = [], u = [], r = async (d) => {
399
399
  let m = !0, p = null;
400
400
  for (; m; ) {
401
401
  const b = await e.query(
402
402
  `
403
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${r} {
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 q = (e, t) => {
424
424
  }
425
425
  ), { nodes: g, pageInfo: f } = b.product.variants;
426
426
  for (const v of g) {
427
- if (l.has(v.id)) {
427
+ if (n.has(v.id)) {
428
428
  m = !1;
429
429
  break;
430
430
  }
431
- l.add(v.id), d ? u.push(v) : o.push(v);
431
+ n.add(v.id), d ? u.push(v) : o.push(v);
432
432
  }
433
433
  f.hasNextPage || (m = !1), p = f.endCursor;
434
434
  }
435
435
  };
436
436
  return await Promise.all([
437
- n(!1),
438
- n(!0)
437
+ r(!1),
438
+ r(!0)
439
439
  ]), t.variants.nodes = [...o, ...u.reverse()], t;
440
440
  }, x = (e, t, a) => {
441
441
  var m, p, b, g, f, v;
442
- const r = e.variants.nodes.map(
442
+ const l = e.variants.nodes.map(
443
443
  ({ unitPriceMeasurement: s, ...c }) => {
444
444
  var y, _;
445
445
  return {
@@ -473,7 +473,7 @@ const q = (e, t) => {
473
473
  } : null
474
474
  };
475
475
  }
476
- ), l = e.options.map((s, c) => {
476
+ ), n = e.options.map((s, c) => {
477
477
  const y = s.optionValues.map((_) => {
478
478
  var i, h, I, P;
479
479
  return {
@@ -490,7 +490,7 @@ const q = (e, t) => {
490
490
  defaultName: s.name,
491
491
  name: s.name,
492
492
  position: c + 1,
493
- optionValues: V(y, c, r)
493
+ optionValues: V(y, c, l)
494
494
  };
495
495
  }), o = (s) => {
496
496
  const c = s.priceAdjustments[0];
@@ -518,7 +518,7 @@ const q = (e, t) => {
518
518
  `Unknown price adjustment type: ${y.__typename}`
519
519
  );
520
520
  }
521
- }, u = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), n = ((m = e.sellingPlanGroups) == null ? void 0 : m.nodes.flatMap(
521
+ }, u = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), r = ((m = e.sellingPlanGroups) == null ? void 0 : m.nodes.flatMap(
522
522
  (s) => s.sellingPlans.nodes.map((c) => ({
523
523
  id: Number(c.id.split("/").pop()),
524
524
  name: c.name,
@@ -538,13 +538,13 @@ const q = (e, t) => {
538
538
  collectionIds: e.collections.nodes.map(
539
539
  (s) => Number(s.id.split("/").pop())
540
540
  ),
541
- options: l,
541
+ options: n,
542
542
  selectedVariantId: Number(
543
543
  e.variants.nodes[0].id.split("/").pop()
544
544
  ),
545
- variants: r,
545
+ variants: l,
546
546
  requiresSellingPlan: e.requiresSellingPlan,
547
- sellingPlans: n,
547
+ sellingPlans: r,
548
548
  isNativeBundle: d,
549
549
  metafields: {
550
550
  text: ((b = e.metafield) == null ? void 0 : b.value) || null,
@@ -553,17 +553,17 @@ const q = (e, t) => {
553
553
  text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
554
554
  }
555
555
  };
556
- }, V = (e, t, a) => e.filter((r) => a.filter(
557
- (l) => l.options[t] === r.name
556
+ }, V = (e, t, a) => e.filter((l) => a.filter(
557
+ (n) => n.options[t] === l.name
558
558
  ).length > 0), A = "app--2935586817", R = async (e, {
559
559
  language: t,
560
560
  country: a,
561
- useExternalMetafieldNamespace: r
561
+ useExternalMetafieldNamespace: l
562
562
  }) => {
563
- const l = `${A}--kaching_bundles`, o = A, u = w({ country: a }), {
563
+ const n = `${A}--kaching_bundles`, o = A, u = w({ country: a }), {
564
564
  localization: {
565
565
  country: {
566
- currency: { isoCode: n }
566
+ currency: { isoCode: r }
567
567
  }
568
568
  },
569
569
  shop: {
@@ -602,11 +602,11 @@ const q = (e, t) => {
602
602
  `,
603
603
  {
604
604
  variables: {
605
- metafieldNamespace: l,
605
+ metafieldNamespace: n,
606
606
  settingsNamespace: o
607
607
  }
608
608
  }
609
- ), f = n === m ? d : j(n, { language: t, country: a }), v = p ? Q(p.value) : 1, s = g ? JSON.parse(g.value) : null, c = (s == null ? void 0 : s.feature_flags) ?? {}, y = (s == null ? void 0 : s.custom_selectors) ?? {};
609
+ ), f = r === m ? d : j(r, { language: t, country: a }), v = p ? Q(p.value) : 1, s = g ? JSON.parse(g.value) : null, c = (s == null ? void 0 : s.feature_flags) ?? {}, y = (s == null ? void 0 : s.custom_selectors) ?? {};
610
610
  return {
611
611
  shopifyDomain: b.host,
612
612
  moneyFormat: f,
@@ -667,7 +667,7 @@ const q = (e, t) => {
667
667
  featureFlags: c,
668
668
  brandColors: (s == null ? void 0 : s.brand_colors) ?? null
669
669
  };
670
- }, Q = (e) => JSON.parse(e).amount / 1e6, L = async (e, t, a = 200) => (t = t.filter(Boolean).filter((r) => !r.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
670
+ }, Q = (e) => JSON.parse(e).amount / 1e6, L = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
671
671
  `
672
672
  query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
673
673
  nodes(ids: $mediaImageIds) {
@@ -686,9 +686,9 @@ const q = (e, t) => {
686
686
  size: a
687
687
  }
688
688
  }
689
- )).nodes.filter(Boolean).map((r) => ({
690
- gid: r.id,
691
- url: r.image.url
689
+ )).nodes.filter(Boolean).map((l) => ({
690
+ gid: l.id,
691
+ url: l.image.url
692
692
  })));
693
693
  var $ = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))($ || {});
694
694
  const H = (e) => [
@@ -714,29 +714,29 @@ const H = (e) => [
714
714
  ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), X = (e) => e.dealBars.flatMap(
715
715
  ({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
716
716
  ).filter((t) => t != null), K = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), Y = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
717
- const r = a.images.map((l) => l.mediaImageGID).filter((l) => l != null);
718
- return [...t, ...r];
717
+ const l = a.images.map((n) => n.mediaImageGID).filter((n) => n != null);
718
+ return [...t, ...l];
719
719
  }, []) : [], Z = (e) => {
720
720
  if (!e.collectionBreaksEnabled || !e.collectionBreaks)
721
721
  return [];
722
722
  const t = e.collectionBreaks.mediaImageGID;
723
723
  return t ? [t] : [];
724
724
  }, ee = (e) => {
725
- var t, a, r;
725
+ var t, a, l;
726
726
  return e.progressiveGifts ? [
727
- ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((l) => l.mediaImageGID)) || [],
727
+ ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
728
728
  (a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
729
- (r = e.progressiveGifts.dealBarStyle) == null ? void 0 : r.lockedMediaImageGID
730
- ].filter((l) => l != null) : [];
729
+ (l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
730
+ ].filter((n) => n != null) : [];
731
731
  }, te = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.map((t) => {
732
732
  var a;
733
733
  return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
734
734
  }).filter((t) => t != null), se = (e) => {
735
- var r, l;
735
+ var l, n;
736
736
  const t = e.dealBars.map((o) => {
737
737
  var u;
738
738
  return (u = o.highlights) == null ? void 0 : u.customIconGID;
739
- }).filter((o) => o != null), a = (l = (r = e.subscriptions) == null ? void 0 : r.highlights) == null ? void 0 : l.customIconGID;
739
+ }).filter((o) => o != null), a = (n = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : n.customIconGID;
740
740
  return a ? [...t, a] : t;
741
741
  }, ne = (e) => (e.badges || []).flatMap(
742
742
  (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
@@ -756,7 +756,7 @@ const H = (e) => [
756
756
  ({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
757
757
  ).filter((t) => t != null), oe = (e) => e.dealBars.flatMap(
758
758
  ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
759
- (a) => a.products ? a.products.map((r) => r.id) : []
759
+ (a) => a.products ? a.products.map((l) => l.id) : []
760
760
  ) : []
761
761
  ).filter((t) => t != null), ce = (e) => {
762
762
  var t;
@@ -765,10 +765,10 @@ const H = (e) => [
765
765
  ({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
766
766
  ).filter((t) => t != null).filter((t) => t !== "default"), me = (e) => e.dealBars.filter((t) => t.dealBarType === $.MixAndMatch).flatMap(
767
767
  ({ bundleProducts: t }) => t ? t.flatMap((a) => {
768
- var r;
768
+ var l;
769
769
  return [
770
770
  a.productGID,
771
- ...((r = a.selectedProducts) == null ? void 0 : r.map((l) => l.id)) ?? []
771
+ ...((l = a.selectedProducts) == null ? void 0 : l.map((n) => n.id)) ?? []
772
772
  ];
773
773
  }) : []
774
774
  ).filter((t) => t != null).filter((t) => t !== "default"), pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), fe = (e) => e.dealBars.filter((t) => t.dealBarType === $.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
@@ -777,12 +777,12 @@ class ye {
777
777
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
778
778
  }
779
779
  async query(t, a) {
780
- var n;
781
- const r = (a == null ? void 0 : a.variables) ?? {};
782
- let l = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
- const o = (n = t.match(/query\s+(\w+)/)) == null ? void 0 : n[1];
784
- o && (l += `?operation_name=${o}`);
785
- const u = await (await fetch(l, {
780
+ var r;
781
+ const l = (a == null ? void 0 : a.variables) ?? {};
782
+ let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
+ const o = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
784
+ o && (n += `?operation_name=${o}`);
785
+ const u = await (await fetch(n, {
786
786
  method: "POST",
787
787
  headers: {
788
788
  "Content-Type": "application/json",
@@ -790,7 +790,7 @@ class ye {
790
790
  },
791
791
  body: JSON.stringify({
792
792
  query: t,
793
- variables: r
793
+ variables: l
794
794
  })
795
795
  })).text();
796
796
  if (!u)
@@ -798,45 +798,45 @@ class ye {
798
798
  return JSON.parse(u).data;
799
799
  }
800
800
  }
801
- const ge = async (e, t, { country: a, language: r }) => {
802
- const l = t.collectionBreaks;
803
- if (!t.collectionBreaksEnabled || !l) return;
801
+ const ge = async (e, t, { country: a, language: l }) => {
802
+ const n = t.collectionBreaks;
803
+ if (!t.collectionBreaksEnabled || !n) return;
804
804
  let o;
805
- l.visibility === "deal-products" ? o = await k(e, {
805
+ n.visibility === "deal-products" ? o = await k(e, {
806
806
  country: a,
807
- language: r,
807
+ language: l,
808
808
  blockVisibility: t.blockVisibility,
809
809
  excludedProductGIDs: (t.excludedProductIds || []).map(
810
- (n) => `gid://shopify/Product/${n}`
810
+ (r) => `gid://shopify/Product/${r}`
811
811
  ),
812
812
  selectedProductGIDs: (t.selectedProductIds || []).map(
813
- (n) => `gid://shopify/Product/${n}`
813
+ (r) => `gid://shopify/Product/${r}`
814
814
  ),
815
815
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
816
- (n) => `gid://shopify/Collection/${n}`
816
+ (r) => `gid://shopify/Collection/${r}`
817
817
  )
818
818
  }) : o = await k(e, {
819
819
  country: a,
820
- language: r,
821
- blockVisibility: l.visibility,
822
- excludedProductGIDs: (l.excludedProducts || []).map(
823
- ({ id: n }) => n
820
+ language: l,
821
+ blockVisibility: n.visibility,
822
+ excludedProductGIDs: (n.excludedProducts || []).map(
823
+ ({ id: r }) => r
824
824
  ),
825
- selectedProductGIDs: (l.selectedProducts || []).map(
826
- ({ id: n }) => n
825
+ selectedProductGIDs: (n.selectedProducts || []).map(
826
+ ({ id: r }) => r
827
827
  ),
828
- selectedCollectionGIDs: (l.selectedCollections || []).map(
829
- ({ id: n }) => n
828
+ selectedCollectionGIDs: (n.selectedCollections || []).map(
829
+ ({ id: r }) => r
830
830
  )
831
831
  });
832
832
  let u = await S(e, {
833
833
  country: a,
834
- language: r,
835
- productIds: o.map((n) => Number(n.split("/").pop())),
834
+ language: l,
835
+ productIds: o.map((r) => Number(r.split("/").pop())),
836
836
  useExternalMetafieldNamespace: !0
837
837
  });
838
838
  return u = u.filter(
839
- (n) => n.availableForSale
839
+ (r) => r.availableForSale
840
840
  ), u;
841
841
  }, he = () => ({
842
842
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
@@ -866,16 +866,16 @@ const ge = async (e, t, { country: a, language: r }) => {
866
866
  }), be = "2026-07", _e = async (e, {
867
867
  productId: t,
868
868
  dealBlockId: a,
869
- country: r = void 0,
870
- language: l = void 0
869
+ country: l = void 0,
870
+ language: n = void 0
871
871
  }) => {
872
872
  var o, u;
873
873
  try {
874
- const n = [Number(t.split("/").pop())], d = new ve(e);
875
- r = r || ((o = d.i18n) == null ? void 0 : o.country), l = l || ((u = d.i18n) == null ? void 0 : u.language);
874
+ const r = [Number(t.split("/").pop())], d = new ve(e);
875
+ l = l || ((o = d.i18n) == null ? void 0 : o.country), n = n || ((u = d.i18n) == null ? void 0 : u.language);
876
876
  const m = await R(d, {
877
- language: l,
878
- country: r,
877
+ language: n,
878
+ country: l,
879
879
  useExternalMetafieldNamespace: !0
880
880
  });
881
881
  d.shopifyDomain = m.shopifyDomain;
@@ -884,9 +884,9 @@ const ge = async (e, t, { country: a, language: r }) => {
884
884
  m.storefrontAccessToken
885
885
  ) : d, [b, g] = await Promise.all([
886
886
  S(p, {
887
- country: r,
888
- language: l,
889
- productIds: n,
887
+ country: l,
888
+ language: n,
889
+ productIds: r,
890
890
  useExternalMetafieldNamespace: !0
891
891
  }),
892
892
  F(p, {
@@ -904,15 +904,15 @@ const ge = async (e, t, { country: a, language: r }) => {
904
904
  return null;
905
905
  const c = H(s), y = le(s), [_, i, h, I] = await Promise.all([
906
906
  S(p, {
907
- country: r,
908
- language: l,
907
+ country: l,
908
+ language: n,
909
909
  productIds: y,
910
910
  useExternalMetafieldNamespace: !0
911
911
  }),
912
912
  L(p, c, 300),
913
913
  ge(p, s, {
914
- country: r,
915
- language: l
914
+ country: l,
915
+ language: n
916
916
  }),
917
917
  he()
918
918
  ]);
@@ -925,8 +925,8 @@ const ge = async (e, t, { country: a, language: r }) => {
925
925
  collectionBreaksProducts: h ?? [],
926
926
  translations: I
927
927
  };
928
- } catch (n) {
929
- return console.error(n), null;
928
+ } catch (r) {
929
+ return console.error(r), null;
930
930
  }
931
931
  };
932
932
  class ve {
@@ -934,12 +934,22 @@ class ve {
934
934
  this.storefront = t, this.shopifyDomain = "";
935
935
  }
936
936
  async query(t, a) {
937
+ var l;
937
938
  if ("query" in this.storefront && "i18n" in this.storefront)
938
939
  return await this.storefront.query(t, a);
940
+ if ("graphql" in this.storefront) {
941
+ const n = await this.storefront.graphql(t, a);
942
+ if ((l = n.errors) != null && l.length)
943
+ throw new Error(
944
+ n.errors.map((o) => o.message).join(`
945
+ `)
946
+ );
947
+ return n.data;
948
+ }
939
949
  if ("request" in this.storefront)
940
950
  return (await this.storefront.request(t, a)).data;
941
951
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
942
- const r = await fetch(
952
+ const n = await fetch(
943
953
  `https://${this.storefront.shopifyDomain}/api/${be}/graphql.json`,
944
954
  {
945
955
  body: JSON.stringify({
@@ -953,11 +963,11 @@ class ve {
953
963
  method: "POST"
954
964
  }
955
965
  );
956
- if (!r.ok)
957
- throw new Error(r.statusText);
958
- return (await r.json()).data;
966
+ if (!n.ok)
967
+ throw new Error(n.statusText);
968
+ return (await n.json()).data;
959
969
  } else {
960
- const r = await fetch(this.storefront.getStorefrontApiUrl(), {
970
+ const n = await fetch(this.storefront.getStorefrontApiUrl(), {
961
971
  body: JSON.stringify({
962
972
  query: t,
963
973
  variables: a == null ? void 0 : a.variables
@@ -965,9 +975,9 @@ class ve {
965
975
  headers: this.storefront.getPublicTokenHeaders(),
966
976
  method: "POST"
967
977
  });
968
- if (!r.ok)
969
- throw new Error(r.statusText);
970
- return (await r.json()).data;
978
+ if (!n.ok)
979
+ throw new Error(n.statusText);
980
+ return (await n.json()).data;
971
981
  }
972
982
  }
973
983
  get i18n() {