@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.
@@ -2,47 +2,47 @@ import { jsx as F } from "react/jsx-runtime";
2
2
  import { useRef as B, useState as R, useEffect as D, useLayoutEffect as L } from "react";
3
3
  const J = (e, t) => {
4
4
  const a = [], l = e.filter(
5
- (n) => n.blockVisibility === "selected-products"
5
+ (r) => r.blockVisibility === "selected-products"
6
6
  );
7
- for (const n of l)
8
- n.selectedProductIds.map(Number).includes(t.id) && a.push(n);
9
- const r = e.filter(
10
- (n) => n.blockVisibility === "selected-collections"
7
+ for (const r of l)
8
+ r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
9
+ const s = e.filter(
10
+ (r) => r.blockVisibility === "selected-collections"
11
11
  );
12
- for (const n of r)
12
+ for (const r of s)
13
13
  t.collectionIds.some(
14
- (m) => n.selectedCollectionIds.map(Number).includes(m)
15
- ) && a.push(n);
14
+ (m) => r.selectedCollectionIds.map(Number).includes(m)
15
+ ) && a.push(r);
16
16
  const i = e.filter(
17
- (n) => n.blockVisibility === "excluded-products"
17
+ (r) => r.blockVisibility === "excluded-products"
18
18
  );
19
- for (const n of i)
20
- !n.excludedProductIds.map(Number).includes(t.id) && !(n.excludedCollectionIds || []).some(
19
+ for (const r of i)
20
+ !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
21
21
  (m) => t.collectionIds.includes(m)
22
- ) && a.push(n);
22
+ ) && a.push(r);
23
23
  const o = e.filter(
24
- (n) => n.blockVisibility === "all-products"
24
+ (r) => r.blockVisibility === "all-products"
25
25
  );
26
- for (const n of o)
27
- a.push(n);
26
+ for (const r of o)
27
+ a.push(r);
28
28
  return a;
29
29
  }, z = (e, { language: t, country: a }) => {
30
30
  var f, g;
31
- const l = Q(t, a), r = new Intl.NumberFormat(l, {
31
+ const l = Q(t, a), s = new Intl.NumberFormat(l, {
32
32
  style: "currency",
33
33
  currency: e,
34
34
  currencyDisplay: "narrowSymbol"
35
- }).formatToParts(123456789e-2), i = (f = r.find((y) => y.type === "decimal")) == null ? void 0 : f.value, o = H(
36
- (g = r.find((y) => y.type === "group")) == null ? void 0 : g.value
37
- ), n = r.some((y) => y.type === "fraction"), m = K(
35
+ }).formatToParts(123456789e-2), i = (f = s.find((y) => y.type === "decimal")) == null ? void 0 : f.value, o = H(
36
+ (g = s.find((y) => y.type === "group")) == null ? void 0 : g.value
37
+ ), r = s.some((y) => y.type === "fraction"), m = K(
38
38
  o,
39
39
  i,
40
- n
41
- ), d = r.findIndex(C), c = r.findLastIndex(C);
40
+ r
41
+ ), d = s.findIndex(C), c = s.findLastIndex(C);
42
42
  return [
43
- ...r.slice(0, d).map(E),
43
+ ...s.slice(0, d).map(E),
44
44
  m,
45
- ...r.slice(c + 1).map(E)
45
+ ...s.slice(c + 1).map(E)
46
46
  ].join("");
47
47
  }, E = (e) => V(e.value), V = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", Q = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), H = (e) => e === void 0 ? void 0 : V(e).replace(/’/g, "'"), K = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
48
48
  country: e,
@@ -76,7 +76,7 @@ const J = (e, t) => {
76
76
  return a ? JSON.parse(a) : [];
77
77
  }, Y = async (e, t) => {
78
78
  const a = "app--2935586817--deal_block", l = [];
79
- let r = null;
79
+ let s = null;
80
80
  for (; ; ) {
81
81
  const i = await e.query(
82
82
  `
@@ -98,39 +98,39 @@ const J = (e, t) => {
98
98
  {
99
99
  variables: {
100
100
  type: a,
101
- cursor: r
101
+ cursor: s
102
102
  }
103
103
  }
104
104
  );
105
105
  for (const o of i.metaobjects.nodes) {
106
- const n = o.fields.find(
106
+ const r = o.fields.find(
107
107
  (m) => m.key === "settings"
108
108
  );
109
- n != null && n.value && l.push(JSON.parse(n.value));
109
+ r != null && r.value && l.push(JSON.parse(r.value));
110
110
  }
111
111
  if (!i.metaobjects.pageInfo.hasNextPage)
112
112
  break;
113
- r = i.metaobjects.pageInfo.endCursor;
113
+ s = i.metaobjects.pageInfo.endCursor;
114
114
  }
115
115
  return l;
116
116
  }, M = async (e, {
117
117
  country: t,
118
118
  language: a,
119
119
  blockVisibility: l,
120
- excludedProductGIDs: r,
120
+ excludedProductGIDs: s,
121
121
  selectedProductGIDs: i,
122
122
  selectedCollectionGIDs: o,
123
- limit: n = 1e3
123
+ limit: r = 1e3
124
124
  }) => {
125
125
  switch (l) {
126
126
  case "selected-products":
127
- return i.slice(0, n);
127
+ return i.slice(0, r);
128
128
  case "all-products":
129
129
  case "excluded-products": {
130
130
  const m = w({ country: t, language: a });
131
131
  let d = [], c = null;
132
- for (; d.length < n; ) {
133
- const f = Math.min(n - d.length, 250), g = await e.query(
132
+ for (; d.length < r; ) {
133
+ const f = Math.min(r - d.length, 250), g = await e.query(
134
134
  `
135
135
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
136
136
  products(first: $limit, after: $cursor) {
@@ -155,7 +155,7 @@ const J = (e, t) => {
155
155
  c = g.products.pageInfo.endCursor;
156
156
  }
157
157
  if (l === "excluded-products") {
158
- const f = new Set(r);
158
+ const f = new Set(s);
159
159
  d = d.filter((g) => !f.has(g));
160
160
  }
161
161
  return d;
@@ -178,13 +178,13 @@ const J = (e, t) => {
178
178
  {
179
179
  variables: {
180
180
  collectionGIDs: o,
181
- limit: Math.min(n, 250)
181
+ limit: Math.min(r, 250)
182
182
  }
183
183
  }
184
184
  )).nodes.filter((c) => c !== null).flatMap(
185
185
  (c) => c.products.nodes.map((f) => f.id)
186
186
  );
187
- return Array.from(new Set(d)).slice(0, n);
187
+ return Array.from(new Set(d)).slice(0, r);
188
188
  }
189
189
  }
190
190
  }, U = `
@@ -234,10 +234,10 @@ const J = (e, t) => {
234
234
  country: t,
235
235
  language: a,
236
236
  productIds: l,
237
- includeSellingPlans: r = !0,
237
+ includeSellingPlans: s = !0,
238
238
  includeAvailableQuantity: i = !0,
239
239
  useExternalMetafieldNamespace: o = !1,
240
- batchSize: n = 250,
240
+ batchSize: r = 250,
241
241
  onBatchError: m
242
242
  }) => {
243
243
  if (!l.length)
@@ -329,20 +329,20 @@ const J = (e, t) => {
329
329
  }
330
330
  }
331
331
  }
332
- `, g = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = [], h = Math.min(n, 250);
332
+ `, g = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = [], h = Math.min(r, 250);
333
333
  for (let u = 0; u < d.length; u += h)
334
334
  y.push(d.slice(u, u + h));
335
- let s = 1;
335
+ let n = 1;
336
336
  const p = async (u) => {
337
337
  const v = await e.query(f, {
338
338
  variables: {
339
339
  productGIDs: u,
340
- includeSellingPlans: r,
340
+ includeSellingPlans: s,
341
341
  includeAvailableQuantity: i,
342
342
  metafieldNamespace: g
343
343
  }
344
344
  });
345
- return v.shop.currencyRateConstant && (s = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
345
+ return v.shop.currencyRateConstant && (n = JSON.parse(v.shop.currencyRateConstant.value).amount / 1e6), v;
346
346
  };
347
347
  let b;
348
348
  if (m) {
@@ -363,13 +363,13 @@ const J = (e, t) => {
363
363
  const P = await T(
364
364
  e,
365
365
  I,
366
- { includeSellingPlans: r, includeAvailableQuantity: i },
366
+ { includeSellingPlans: s, includeAvailableQuantity: i },
367
367
  c
368
368
  );
369
369
  return q(
370
370
  P,
371
371
  e.shopifyDomain,
372
- s
372
+ n
373
373
  );
374
374
  })
375
375
  ), v = [];
@@ -385,19 +385,19 @@ const J = (e, t) => {
385
385
  e,
386
386
  u,
387
387
  {
388
- includeSellingPlans: r,
388
+ includeSellingPlans: s,
389
389
  includeAvailableQuantity: i
390
390
  },
391
391
  c
392
392
  )
393
393
  )
394
394
  )).map(
395
- (u) => q(u, e.shopifyDomain, s)
395
+ (u) => q(u, e.shopifyDomain, n)
396
396
  );
397
397
  }, T = async (e, t, a, l = "") => {
398
398
  if (t.variants.nodes.length < 250)
399
399
  return t;
400
- const r = /* @__PURE__ */ new Set(), i = [], o = [], n = async (m) => {
400
+ const s = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
401
401
  let d = !0, c = null;
402
402
  for (; d; ) {
403
403
  const f = await e.query(
@@ -426,23 +426,23 @@ const J = (e, t) => {
426
426
  }
427
427
  ), { nodes: g, pageInfo: y } = f.product.variants;
428
428
  for (const h of g) {
429
- if (r.has(h.id)) {
429
+ if (s.has(h.id)) {
430
430
  d = !1;
431
431
  break;
432
432
  }
433
- r.add(h.id), m ? o.push(h) : i.push(h);
433
+ s.add(h.id), m ? o.push(h) : i.push(h);
434
434
  }
435
435
  y.hasNextPage || (d = !1), c = y.endCursor;
436
436
  }
437
437
  };
438
438
  return await Promise.all([
439
- n(!1),
440
- n(!0)
439
+ r(!1),
440
+ r(!0)
441
441
  ]), t.variants.nodes = [...i, ...o.reverse()], t;
442
442
  }, q = (e, t, a) => {
443
443
  var d, c, f, g, y, h;
444
444
  const l = e.variants.nodes.map(
445
- ({ unitPriceMeasurement: s, ...p }) => {
445
+ ({ unitPriceMeasurement: n, ...p }) => {
446
446
  var b, _;
447
447
  return {
448
448
  id: Number(p.id.split("/").pop()),
@@ -467,16 +467,16 @@ const J = (e, t) => {
467
467
  inventoryPolicy: null,
468
468
  // Storefront API does not return inventory policy, only available in liquid
469
469
  inventoryQuantity: p.quantityAvailable ?? null,
470
- unitPriceMeasurement: s != null && s.quantityUnit && (s != null && s.referenceUnit) ? {
471
- quantityValue: s.quantityValue,
472
- quantityUnit: s.quantityUnit.toLowerCase(),
473
- referenceValue: s.referenceValue,
474
- referenceUnit: s.referenceUnit.toLowerCase()
470
+ unitPriceMeasurement: n != null && n.quantityUnit && (n != null && n.referenceUnit) ? {
471
+ quantityValue: n.quantityValue,
472
+ quantityUnit: n.quantityUnit.toLowerCase(),
473
+ referenceValue: n.referenceValue,
474
+ referenceUnit: n.referenceUnit.toLowerCase()
475
475
  } : null
476
476
  };
477
477
  }
478
- ), r = e.options.map((s, p) => {
479
- const b = s.optionValues.map((_) => {
478
+ ), s = e.options.map((n, p) => {
479
+ const b = n.optionValues.map((_) => {
480
480
  var u, v, I, P;
481
481
  return {
482
482
  id: Number(_.id.split("/").pop()),
@@ -489,13 +489,13 @@ const J = (e, t) => {
489
489
  };
490
490
  });
491
491
  return {
492
- defaultName: s.name,
493
- name: s.name,
492
+ defaultName: n.name,
493
+ name: n.name,
494
494
  position: p + 1,
495
495
  optionValues: Z(b, p, l)
496
496
  };
497
- }), i = (s) => {
498
- const p = s.priceAdjustments[0];
497
+ }), i = (n) => {
498
+ const p = n.priceAdjustments[0];
499
499
  if (!p)
500
500
  return null;
501
501
  const b = p.adjustmentValue;
@@ -520,14 +520,14 @@ const J = (e, t) => {
520
520
  `Unknown price adjustment type: ${b.__typename}`
521
521
  );
522
522
  }
523
- }, o = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), n = ((d = e.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
524
- (s) => s.sellingPlans.nodes.map((p) => ({
523
+ }, o = (n) => a === 1 ? Number(n) * 100 : Math.round(Number(n) * 100 * a), r = ((d = e.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
524
+ (n) => n.sellingPlans.nodes.map((p) => ({
525
525
  id: Number(p.id.split("/").pop()),
526
526
  name: p.name,
527
527
  priceAdjustment: i(p)
528
528
  }))
529
529
  )) || [], m = e.variants.nodes.some(
530
- (s) => s.requiresComponents
530
+ (n) => n.requiresComponents
531
531
  );
532
532
  return {
533
533
  id: Number(e.id.split("/").pop()),
@@ -538,15 +538,15 @@ const J = (e, t) => {
538
538
  title: e.title,
539
539
  image: ((c = e.featuredImage) == null ? void 0 : c.url) || null,
540
540
  collectionIds: e.collections.nodes.map(
541
- (s) => Number(s.id.split("/").pop())
541
+ (n) => Number(n.id.split("/").pop())
542
542
  ),
543
- options: r,
543
+ options: s,
544
544
  selectedVariantId: Number(
545
545
  e.variants.nodes[0].id.split("/").pop()
546
546
  ),
547
547
  variants: l,
548
548
  requiresSellingPlan: e.requiresSellingPlan,
549
- sellingPlans: n,
549
+ sellingPlans: r,
550
550
  isNativeBundle: m,
551
551
  metafields: {
552
552
  text: ((f = e.metafield) == null ? void 0 : f.value) || null,
@@ -556,16 +556,16 @@ const J = (e, t) => {
556
556
  }
557
557
  };
558
558
  }, Z = (e, t, a) => e.filter((l) => a.filter(
559
- (r) => r.options[t] === l.name
560
- ).length > 0), O = "app--2935586817", ee = async (e, {
559
+ (s) => s.options[t] === l.name
560
+ ).length > 0), j = "app--2935586817", ee = async (e, {
561
561
  language: t,
562
562
  country: a,
563
563
  useExternalMetafieldNamespace: l
564
564
  }) => {
565
- const r = `${O}--kaching_bundles`, i = O, o = w({ country: a }), {
565
+ const s = `${j}--kaching_bundles`, i = j, o = w({ country: a }), {
566
566
  localization: {
567
567
  country: {
568
- currency: { isoCode: n }
568
+ currency: { isoCode: r }
569
569
  }
570
570
  },
571
571
  shop: {
@@ -604,11 +604,11 @@ const J = (e, t) => {
604
604
  `,
605
605
  {
606
606
  variables: {
607
- metafieldNamespace: r,
607
+ metafieldNamespace: s,
608
608
  settingsNamespace: i
609
609
  }
610
610
  }
611
- ), y = n === d ? m : z(n, { language: t, country: a }), h = c ? te(c.value) : 1, s = g ? JSON.parse(g.value) : null, p = (s == null ? void 0 : s.feature_flags) ?? {}, b = (s == null ? void 0 : s.custom_selectors) ?? {};
611
+ ), y = r === d ? m : z(r, { language: t, country: a }), h = c ? te(c.value) : 1, n = g ? JSON.parse(g.value) : null, p = (n == null ? void 0 : n.feature_flags) ?? {}, b = (n == null ? void 0 : n.custom_selectors) ?? {};
612
612
  return {
613
613
  shopifyDomain: f.host,
614
614
  moneyFormat: y,
@@ -618,16 +618,16 @@ const J = (e, t) => {
618
618
  currencyRate: h,
619
619
  marketId: 0,
620
620
  productId: null,
621
- storefrontAccessToken: (s == null ? void 0 : s.storefront_access_token) ?? null,
622
- includeSellingPlans: (s == null ? void 0 : s.include_selling_plans) ?? !1,
623
- includeAvailableQuantity: (s == null ? void 0 : s.include_available_quantity) ?? !1,
624
- customApiHost: (s == null ? void 0 : s.custom_api_host) ?? null,
625
- keepQuantityInput: (s == null ? void 0 : s.keep_quantity_input) ?? !1,
626
- ignoreDeselect: (s == null ? void 0 : s.ignore_deselect) ?? !1,
627
- ignoreUnitPrice: (s == null ? void 0 : s.ignore_unit_price) ?? !1,
628
- requireCustomerLogin: (s == null ? void 0 : s.require_customer_login) ?? !1,
629
- abTestsRunning: (s == null ? void 0 : s.ab_tests_running) ?? !1,
630
- webPixel: (s == null ? void 0 : s.web_pixel) ?? !1,
621
+ storefrontAccessToken: (n == null ? void 0 : n.storefront_access_token) ?? null,
622
+ includeSellingPlans: (n == null ? void 0 : n.include_selling_plans) ?? !1,
623
+ includeAvailableQuantity: (n == null ? void 0 : n.include_available_quantity) ?? !1,
624
+ customApiHost: (n == null ? void 0 : n.custom_api_host) ?? null,
625
+ keepQuantityInput: (n == null ? void 0 : n.keep_quantity_input) ?? !1,
626
+ ignoreDeselect: (n == null ? void 0 : n.ignore_deselect) ?? !1,
627
+ ignoreUnitPrice: (n == null ? void 0 : n.ignore_unit_price) ?? !1,
628
+ requireCustomerLogin: (n == null ? void 0 : n.require_customer_login) ?? !1,
629
+ abTestsRunning: (n == null ? void 0 : n.ab_tests_running) ?? !1,
630
+ webPixel: (n == null ? void 0 : n.web_pixel) ?? !1,
631
631
  b2bCustomer: !1,
632
632
  isLoggedIn: !1,
633
633
  preview: !1,
@@ -665,9 +665,9 @@ const J = (e, t) => {
665
665
  price: b.price ?? null,
666
666
  priceCompare: b.price_compare ?? null
667
667
  },
668
- shopCustomStyles: (s == null ? void 0 : s.shop_custom_styles) ?? "",
668
+ shopCustomStyles: (n == null ? void 0 : n.shop_custom_styles) ?? "",
669
669
  featureFlags: p,
670
- brandColors: (s == null ? void 0 : s.brand_colors) ?? null
670
+ brandColors: (n == null ? void 0 : n.brand_colors) ?? null
671
671
  };
672
672
  }, te = (e) => JSON.parse(e).amount / 1e6, ae = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
673
673
  `
@@ -694,8 +694,8 @@ const J = (e, t) => {
694
694
  })));
695
695
  var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
696
696
  const se = (e) => [
697
- ...le(e),
698
697
  ...ne(e),
698
+ ...le(e),
699
699
  ...re(e),
700
700
  ...ie(e),
701
701
  ...oe(e),
@@ -707,7 +707,7 @@ const se = (e) => [
707
707
  ...fe(e),
708
708
  ...ye(e),
709
709
  ...ge(e)
710
- ].filter((t) => t != null && !t.includes("placeholder")), le = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ne = (e) => e.dealBars.flatMap(
710
+ ].filter((t) => t != null && !t.includes("placeholder")), ne = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
711
711
  (t) => t.dealBarType === k.Bundle ? t.bundleProducts.map(
712
712
  (a) => a.mediaImageGID
713
713
  ) : []
@@ -716,7 +716,7 @@ const se = (e) => [
716
716
  ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ie = (e) => e.dealBars.flatMap(
717
717
  ({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
718
718
  ).filter((t) => t != null), oe = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), ce = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
719
- const l = a.images.map((r) => r.mediaImageGID).filter((r) => r != null);
719
+ const l = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
720
720
  return [...t, ...l];
721
721
  }, []) : [], ue = (e) => {
722
722
  if (!e.collectionBreaksEnabled || !e.collectionBreaks)
@@ -726,19 +726,19 @@ const se = (e) => [
726
726
  }, de = (e) => {
727
727
  var t, a, l;
728
728
  return e.progressiveGifts ? [
729
- ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((r) => r.mediaImageGID)) || [],
729
+ ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
730
730
  (a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
731
731
  (l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
732
- ].filter((r) => r != null) : [];
732
+ ].filter((s) => s != null) : [];
733
733
  }, me = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), pe = (e) => e.dealBars.map((t) => {
734
734
  var a;
735
735
  return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
736
736
  }).filter((t) => t != null), fe = (e) => {
737
- var l, r;
737
+ var l, s;
738
738
  const t = e.dealBars.map((i) => {
739
739
  var o;
740
740
  return (o = i.highlights) == null ? void 0 : o.customIconGID;
741
- }).filter((i) => i != null), a = (r = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : r.customIconGID;
741
+ }).filter((i) => i != null), a = (s = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : s.customIconGID;
742
742
  return a ? [...t, a] : t;
743
743
  }, ye = (e) => (e.badges || []).flatMap(
744
744
  (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
@@ -770,7 +770,7 @@ const se = (e) => [
770
770
  var l;
771
771
  return [
772
772
  a.productGID,
773
- ...((l = a.selectedProducts) == null ? void 0 : l.map((r) => r.id)) ?? []
773
+ ...((l = a.selectedProducts) == null ? void 0 : l.map((s) => s.id)) ?? []
774
774
  ];
775
775
  }) : []
776
776
  ).filter((t) => t != null).filter((t) => t !== "default"), ke = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), we = (e) => e.dealBars.filter((t) => t.dealBarType === k.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
@@ -779,12 +779,12 @@ class $e {
779
779
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
780
780
  }
781
781
  async query(t, a) {
782
- var n;
782
+ var r;
783
783
  const l = (a == null ? void 0 : a.variables) ?? {};
784
- let r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
785
- const i = (n = t.match(/query\s+(\w+)/)) == null ? void 0 : n[1];
786
- i && (r += `?operation_name=${i}`);
787
- const o = await (await fetch(r, {
784
+ let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
785
+ const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
786
+ i && (s += `?operation_name=${i}`);
787
+ const o = await (await fetch(s, {
788
788
  method: "POST",
789
789
  headers: {
790
790
  "Content-Type": "application/json",
@@ -801,44 +801,44 @@ class $e {
801
801
  }
802
802
  }
803
803
  const Ne = async (e, t, { country: a, language: l }) => {
804
- const r = t.collectionBreaks;
805
- if (!t.collectionBreaksEnabled || !r) return;
804
+ const s = t.collectionBreaks;
805
+ if (!t.collectionBreaksEnabled || !s) return;
806
806
  let i;
807
- r.visibility === "deal-products" ? i = await M(e, {
807
+ s.visibility === "deal-products" ? i = await M(e, {
808
808
  country: a,
809
809
  language: l,
810
810
  blockVisibility: t.blockVisibility,
811
811
  excludedProductGIDs: (t.excludedProductIds || []).map(
812
- (n) => `gid://shopify/Product/${n}`
812
+ (r) => `gid://shopify/Product/${r}`
813
813
  ),
814
814
  selectedProductGIDs: (t.selectedProductIds || []).map(
815
- (n) => `gid://shopify/Product/${n}`
815
+ (r) => `gid://shopify/Product/${r}`
816
816
  ),
817
817
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
818
- (n) => `gid://shopify/Collection/${n}`
818
+ (r) => `gid://shopify/Collection/${r}`
819
819
  )
820
820
  }) : i = await M(e, {
821
821
  country: a,
822
822
  language: l,
823
- blockVisibility: r.visibility,
824
- excludedProductGIDs: (r.excludedProducts || []).map(
825
- ({ id: n }) => n
823
+ blockVisibility: s.visibility,
824
+ excludedProductGIDs: (s.excludedProducts || []).map(
825
+ ({ id: r }) => r
826
826
  ),
827
- selectedProductGIDs: (r.selectedProducts || []).map(
828
- ({ id: n }) => n
827
+ selectedProductGIDs: (s.selectedProducts || []).map(
828
+ ({ id: r }) => r
829
829
  ),
830
- selectedCollectionGIDs: (r.selectedCollections || []).map(
831
- ({ id: n }) => n
830
+ selectedCollectionGIDs: (s.selectedCollections || []).map(
831
+ ({ id: r }) => r
832
832
  )
833
833
  });
834
834
  let o = await A(e, {
835
835
  country: a,
836
836
  language: l,
837
- productIds: i.map((n) => Number(n.split("/").pop())),
837
+ productIds: i.map((r) => Number(r.split("/").pop())),
838
838
  useExternalMetafieldNamespace: !0
839
839
  });
840
840
  return o = o.filter(
841
- (n) => n.availableForSale
841
+ (r) => r.availableForSale
842
842
  ), o;
843
843
  }, De = () => ({
844
844
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
@@ -869,14 +869,14 @@ const Ne = async (e, t, { country: a, language: l }) => {
869
869
  productId: t,
870
870
  dealBlockId: a,
871
871
  country: l = void 0,
872
- language: r = void 0
872
+ language: s = void 0
873
873
  }) => {
874
874
  var i, o;
875
875
  try {
876
- const n = [Number(t.split("/").pop())], m = new Ge(e);
877
- l = l || ((i = m.i18n) == null ? void 0 : i.country), r = r || ((o = m.i18n) == null ? void 0 : o.language);
876
+ const r = [Number(t.split("/").pop())], m = new Ge(e);
877
+ l = l || ((i = m.i18n) == null ? void 0 : i.country), s = s || ((o = m.i18n) == null ? void 0 : o.language);
878
878
  const d = await ee(m, {
879
- language: r,
879
+ language: s,
880
880
  country: l,
881
881
  useExternalMetafieldNamespace: !0
882
882
  });
@@ -887,8 +887,8 @@ const Ne = async (e, t, { country: a, language: l }) => {
887
887
  ) : m, [f, g] = await Promise.all([
888
888
  A(c, {
889
889
  country: l,
890
- language: r,
891
- productIds: n,
890
+ language: s,
891
+ productIds: r,
892
892
  useExternalMetafieldNamespace: !0
893
893
  }),
894
894
  W(c, {
@@ -899,36 +899,36 @@ const Ne = async (e, t, { country: a, language: l }) => {
899
899
  if (!y)
900
900
  return null;
901
901
  const h = J(g, y);
902
- let s;
903
- if (a ? (s = h.find(
902
+ let n;
903
+ if (a ? (n = h.find(
904
904
  (P) => P.id === a || P.nanoId === a
905
- ), s || (s = h[0])) : s = h[0], !s)
905
+ ), n || (n = h[0])) : n = h[0], !n)
906
906
  return null;
907
- const p = se(s), b = he(s), [_, u, v, I] = await Promise.all([
907
+ const p = se(n), b = he(n), [_, u, v, I] = await Promise.all([
908
908
  A(c, {
909
909
  country: l,
910
- language: r,
910
+ language: s,
911
911
  productIds: b,
912
912
  useExternalMetafieldNamespace: !0
913
913
  }),
914
914
  ae(c, p, 300),
915
- Ne(c, s, {
915
+ Ne(c, n, {
916
916
  country: l,
917
- language: r
917
+ language: s
918
918
  }),
919
919
  De()
920
920
  ]);
921
921
  return {
922
922
  product: y,
923
- dealBlock: s,
923
+ dealBlock: n,
924
924
  config: d,
925
925
  otherProducts: _,
926
926
  mediaImages: u,
927
927
  collectionBreaksProducts: v ?? [],
928
928
  translations: I
929
929
  };
930
- } catch (n) {
931
- return console.error(n), null;
930
+ } catch (r) {
931
+ return console.error(r), null;
932
932
  }
933
933
  };
934
934
  class Ge {
@@ -936,12 +936,22 @@ class Ge {
936
936
  this.storefront = t, this.shopifyDomain = "";
937
937
  }
938
938
  async query(t, a) {
939
+ var l;
939
940
  if ("query" in this.storefront && "i18n" in this.storefront)
940
941
  return await this.storefront.query(t, a);
942
+ if ("graphql" in this.storefront) {
943
+ const s = await this.storefront.graphql(t, a);
944
+ if ((l = s.errors) != null && l.length)
945
+ throw new Error(
946
+ s.errors.map((i) => i.message).join(`
947
+ `)
948
+ );
949
+ return s.data;
950
+ }
941
951
  if ("request" in this.storefront)
942
952
  return (await this.storefront.request(t, a)).data;
943
953
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
944
- const l = await fetch(
954
+ const s = await fetch(
945
955
  `https://${this.storefront.shopifyDomain}/api/${Ae}/graphql.json`,
946
956
  {
947
957
  body: JSON.stringify({
@@ -955,11 +965,11 @@ class Ge {
955
965
  method: "POST"
956
966
  }
957
967
  );
958
- if (!l.ok)
959
- throw new Error(l.statusText);
960
- return (await l.json()).data;
968
+ if (!s.ok)
969
+ throw new Error(s.statusText);
970
+ return (await s.json()).data;
961
971
  } else {
962
- const l = await fetch(this.storefront.getStorefrontApiUrl(), {
972
+ const s = await fetch(this.storefront.getStorefrontApiUrl(), {
963
973
  body: JSON.stringify({
964
974
  query: t,
965
975
  variables: a == null ? void 0 : a.variables
@@ -967,9 +977,9 @@ class Ge {
967
977
  headers: this.storefront.getPublicTokenHeaders(),
968
978
  method: "POST"
969
979
  });
970
- if (!l.ok)
971
- throw new Error(l.statusText);
972
- return (await l.json()).data;
980
+ if (!s.ok)
981
+ throw new Error(s.statusText);
982
+ return (await s.json()).data;
973
983
  }
974
984
  }
975
985
  get i18n() {
@@ -977,7 +987,7 @@ class Ge {
977
987
  return this.storefront.i18n;
978
988
  }
979
989
  }
980
- const Xe = xe, $ = "kaching-bundles-block", j = 1e4, Be = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ee = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ce = async (e) => {
990
+ const Xe = xe, $ = "kaching-bundles-block", O = 1e4, Be = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ee = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", N = /* @__PURE__ */ new WeakSet(), Ce = async (e) => {
981
991
  const t = e.document;
982
992
  if (!e.customElements.get($)) {
983
993
  if (N.has(t))
@@ -992,15 +1002,15 @@ const Xe = xe, $ = "kaching-bundles-block", j = 1e4, Be = "https://bundles-integ
992
1002
  }, Me = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Te = () => Me() ? Be : Ee, qe = (e) => {
993
1003
  const t = e.document;
994
1004
  return new Promise((a, l) => {
995
- const r = Te();
1005
+ const s = Te();
996
1006
  if (t.querySelector(
997
- `script[src="${r}"]`
1007
+ `script[src="${s}"]`
998
1008
  )) {
999
1009
  x(e, $).then(a).catch(l);
1000
1010
  return;
1001
1011
  }
1002
1012
  const o = t.createElement("script");
1003
- o.src = r, o.onload = () => x(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1013
+ o.src = s, o.onload = () => x(e, $).then(a).catch(l), o.onerror = () => l(new Error("Failed to load script")), t.head.appendChild(o);
1004
1014
  });
1005
1015
  }, x = (e, t) => new Promise((a, l) => {
1006
1016
  if (e.customElements.get(t)) {
@@ -1010,33 +1020,33 @@ const Xe = xe, $ = "kaching-bundles-block", j = 1e4, Be = "https://bundles-integ
1010
1020
  Promise.race([
1011
1021
  e.customElements.whenDefined(t),
1012
1022
  new Promise(
1013
- (r, i) => setTimeout(
1023
+ (s, i) => setTimeout(
1014
1024
  () => i(
1015
1025
  new Error(
1016
- `Custom element "${t}" failed to register within ${j}ms`
1026
+ `Custom element "${t}" failed to register within ${O}ms`
1017
1027
  )
1018
1028
  ),
1019
- j
1029
+ O
1020
1030
  )
1021
1031
  )
1022
1032
  ]).then(() => a()).catch(l);
1023
1033
  });
1024
1034
  var G = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(G || {});
1025
- const S = "a-f\\d", Oe = `#?[${S}]{3}[${S}]?`, je = `#?[${S}]{6}([${S}]{2})?`, Ve = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${Oe}$|^${je}$`, "i");
1035
+ const S = "a-f\\d", je = `#?[${S}]{3}[${S}]?`, Oe = `#?[${S}]{6}([${S}]{2})?`, Ve = new RegExp(`[^#${S}]`, "gi"), Ue = new RegExp(`^${je}$|^${Oe}$`, "i");
1026
1036
  function Fe(e, t = {}) {
1027
1037
  if (typeof e != "string" || Ve.test(e) || !Ue.test(e))
1028
1038
  throw new TypeError("Expected a valid hex string");
1029
1039
  e = e.replace(/^#/, "");
1030
1040
  let a = 1;
1031
1041
  e.length === 8 && (a = Number.parseInt(e.slice(6, 8), 16) / 255, e = e.slice(0, 6)), e.length === 4 && (a = Number.parseInt(e.slice(3, 4).repeat(2), 16) / 255, e = e.slice(0, 3)), e.length === 3 && (e = e[0] + e[0] + e[1] + e[1] + e[2] + e[2]);
1032
- const l = Number.parseInt(e, 16), r = l >> 16, i = l >> 8 & 255, o = l & 255, n = typeof t.alpha == "number" ? t.alpha : a;
1042
+ const l = Number.parseInt(e, 16), s = l >> 16, i = l >> 8 & 255, o = l & 255, r = typeof t.alpha == "number" ? t.alpha : a;
1033
1043
  if (t.format === "array")
1034
- return [r, i, o, n];
1044
+ return [s, i, o, r];
1035
1045
  if (t.format === "css") {
1036
- const m = n === 1 ? "" : ` / ${Number((n * 100).toFixed(2))}%`;
1037
- return `rgb(${r} ${i} ${o}${m})`;
1046
+ const m = r === 1 ? "" : ` / ${Number((r * 100).toFixed(2))}%`;
1047
+ return `rgb(${s} ${i} ${o}${m})`;
1038
1048
  }
1039
- return { red: r, green: i, blue: o, alpha: n };
1049
+ return { red: s, green: i, blue: o, alpha: r };
1040
1050
  }
1041
1051
  const Re = ({ price: e }) => ({
1042
1052
  id: 123,
@@ -1399,23 +1409,23 @@ const Re = ({ price: e }) => ({
1399
1409
  selectedVariantId: t,
1400
1410
  preview: a,
1401
1411
  onLinesChange: l,
1402
- targetWindow: r
1412
+ targetWindow: s
1403
1413
  }) => {
1404
- const i = B(null), [o, n] = R(!1), m = B(!1);
1414
+ const i = B(null), [o, r] = R(!1), m = B(!1);
1405
1415
  D(() => {
1406
1416
  if (!i.current || o) return;
1407
1417
  (async () => {
1408
- await Ce(r ?? window), n(!0);
1418
+ await Ce(s ?? window), r(!0);
1409
1419
  })();
1410
- }, [o, r]), D(() => {
1420
+ }, [o, s]), D(() => {
1411
1421
  const c = i.current;
1412
1422
  if (!o || !c) return;
1413
1423
  const f = () => {
1414
1424
  const y = c.items().map((h) => ({
1415
1425
  merchandiseId: `gid://shopify/ProductVariant/${h.id}`,
1416
1426
  quantity: h.quantity,
1417
- attributes: Object.entries(h.properties).map(([s, p]) => ({
1418
- key: s,
1427
+ attributes: Object.entries(h.properties).map(([n, p]) => ({
1428
+ key: n,
1419
1429
  value: String(p)
1420
1430
  })),
1421
1431
  sellingPlanId: h.selling_plan ? `gid://shopify/SellingPlan/${h.selling_plan}` : void 0
@@ -1446,16 +1456,16 @@ const Re = ({ price: e }) => ({
1446
1456
  dealBlock: t,
1447
1457
  product: a,
1448
1458
  otherProducts: l,
1449
- mediaImages: r,
1459
+ mediaImages: s,
1450
1460
  collectionBreaksProducts: i,
1451
1461
  translations: o
1452
- }, n) => ({
1462
+ }, r) => ({
1453
1463
  dealBlockId: t.id,
1454
- currentVariantId: n ? n.split("/").pop() : String(a.variants[0].id),
1464
+ currentVariantId: r ? r.split("/").pop() : String(a.variants[0].id),
1455
1465
  jsonAttributes: {
1456
1466
  config: JSON.stringify(e),
1457
1467
  "deal-block": JSON.stringify(t),
1458
- "media-images": JSON.stringify(r),
1468
+ "media-images": JSON.stringify(s),
1459
1469
  product: JSON.stringify(a),
1460
1470
  "other-products": JSON.stringify(l),
1461
1471
  "collection-breaks-products": JSON.stringify(i),
@@ -1466,12 +1476,12 @@ const Re = ({ price: e }) => ({
1466
1476
  color: t,
1467
1477
  price: a
1468
1478
  }) => {
1469
- const l = Re({ price: a }), r = Le(), i = Je({ color: t, cornerRadius: e });
1479
+ const l = Re({ price: a }), s = Le(), i = Je({ color: t, cornerRadius: e });
1470
1480
  return {
1471
1481
  dealBlockId: i.id,
1472
1482
  currentVariantId: String(l.variants[0].id),
1473
1483
  jsonAttributes: {
1474
- config: JSON.stringify(r),
1484
+ config: JSON.stringify(s),
1475
1485
  "deal-block": JSON.stringify(i),
1476
1486
  "media-images": JSON.stringify([]),
1477
1487
  product: JSON.stringify(l),