@kachingappz/bundles-js 1.1.10 → 1.2.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,22 +1,78 @@
1
- // ../bundles-storefront-api/dist/buildMarketMoneyFormat.js
2
- var e = (e, { language: n, country: s }) => {
3
- let c = i(n, s), l = new Intl.NumberFormat(c, {
1
+ [
2
+ "primaryBackground",
3
+ "secondaryBackground",
4
+ "primaryText",
5
+ "secondaryText",
6
+ "border",
7
+ "overlay",
8
+ "primaryAccent",
9
+ "primaryAccentText",
10
+ "badgeBackground",
11
+ "badgeText",
12
+ "error"
13
+ ].map((e) => `brand_${e}`);
14
+ var e = /* @__PURE__ */ function(e) {
15
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
16
+ }({}), t = (e, t) => e.selectedVariants?.find((e) => e.productId === t)?.variantIds, n = (e, n) => t(e, n) !== void 0, r = (e, n, r) => t(e, n)?.includes(r) ?? !0, i = (e, t) => n(e, t.id) ? t.variants.filter((n) => r(e, t.id, n.id)).map((e) => e.id) : void 0, a = (e, t) => {
17
+ if (!t) return e;
18
+ let n = e.variants.filter((e) => t.includes(e.id)), r = e.options.map((e, t) => ({
19
+ ...e,
20
+ optionValues: e.optionValues.filter((e) => n.some((n) => n.options[t] === e.name))
21
+ })), i = n.some((t) => t.id === e.selectedVariantId) ? e.selectedVariantId : n[0]?.id ?? e.selectedVariantId;
22
+ return {
23
+ ...e,
24
+ variants: n,
25
+ options: r,
26
+ selectedVariantId: i
27
+ };
28
+ }, o = (e, t) => s(e) ? c(e, t, l(e)) : t, s = (e) => !!e.selectedVariants?.length, c = (e, t, n) => t.flatMap((t) => {
29
+ let r = i(e, t);
30
+ if (!r) return [t];
31
+ let o = a(t, [...r, ...t.variants.map((e) => e.id).filter((e) => n.has(e))]);
32
+ return o.variants.length ? [o] : [];
33
+ }), l = (e) => new Set([
34
+ ...e.dealBars.flatMap(u),
35
+ ...(e.progressiveGifts?.gifts ?? []).flatMap((e) => e.variantGIDs ?? []),
36
+ ...(e.checkboxUpsells?.upsells ?? []).flatMap((e) => e.variantGIDs ?? [])
37
+ ].map(f)), u = (e) => [
38
+ ...e.freeGifts.flatMap((e) => e.variantGIDs ?? []),
39
+ ...e.upsells.flatMap((e) => e.variantGIDs ?? []),
40
+ ...(e.multipleGiftsSelectors ?? []).flatMap((e) => e.products.flatMap((e) => e.variantGIDs ?? [])),
41
+ ...d(e)
42
+ ], d = (t) => {
43
+ switch (t.dealBarType) {
44
+ case e.Bundle: return t.bundleProducts.flatMap((e) => e.productGID === "default" ? [] : e.variantGIDs ?? []);
45
+ case e.MixAndMatch: return t.bundleProducts.flatMap((e) => [...e.productGID === "default" ? [] : e.variantGIDs ?? [], ...(e.selectedProducts ?? []).flatMap((e) => e.variantGIDs ?? [])]);
46
+ default: return [];
47
+ }
48
+ }, f = (e) => Number(e.split("/").pop()), p = (e, n, i) => {
49
+ let a = (e) => i !== void 0 && r(e, n.id, i), o = e.filter((e) => t(e, n.id)?.some((e) => n.variants.some((t) => t.id === e))), s = o.filter(a), c = [...s], l = o.filter((e) => !s.includes(e)), u = e.filter((e) => e.blockVisibility === "selected-products");
50
+ for (let e of u) e.selectedProductIds.map(Number).includes(n.id) && c.push(e);
51
+ let d = e.filter((e) => e.blockVisibility === "selected-collections");
52
+ for (let e of d) n.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && c.push(e);
53
+ let f = e.filter((e) => e.blockVisibility === "excluded-products");
54
+ for (let e of f) !e.excludedProductIds.map(Number).includes(n.id) && !(e.excludedCollectionIds || []).some((e) => n.collectionIds.includes(e)) && c.push(e);
55
+ let p = e.filter((e) => e.blockVisibility === "all-products");
56
+ for (let e of p) c.push(e);
57
+ return i === void 0 ? c : [...c, ...l];
58
+ }, m = (e, { language: t, country: n }) => {
59
+ let r = v(t, n), i = new Intl.NumberFormat(r, {
4
60
  style: "currency",
5
61
  currency: e,
6
62
  currencyDisplay: "narrowSymbol"
7
- }).formatToParts(1234567.89), u = l.find((e) => e.type === "decimal")?.value, d = o(a(l.find((e) => e.type === "group")?.value), u, l.some((e) => e.type === "fraction")), f = l.findIndex(r), p = l.findLastIndex(r);
63
+ }).formatToParts(1234567.89), a = i.find((e) => e.type === "decimal")?.value, o = b(y(i.find((e) => e.type === "group")?.value), a, i.some((e) => e.type === "fraction")), s = i.findIndex(_), c = i.findLastIndex(_);
8
64
  return [
9
- ...l.slice(0, f).map(t),
10
- d,
11
- ...l.slice(p + 1).map(t)
65
+ ...i.slice(0, s).map(h),
66
+ o,
67
+ ...i.slice(c + 1).map(h)
12
68
  ].join("");
13
- }, t = (e) => n(e.value), n = (e) => e.replace(/\s/g, " "), r = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", i = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), a = (e) => e === void 0 ? void 0 : n(e).replace(/’/g, "'"), o = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", s = ({ country: e, language: t }) => {
69
+ }, h = (e) => g(e.value), g = (e) => e.replace(/\s/g, " "), _ = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", v = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), y = (e) => e === void 0 ? void 0 : g(e).replace(/’/g, "'"), b = (e, t, n) => t === "," && e === "." ? n ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? n ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : n ? "{{amount}}" : "{{amount_no_decimals}}", x = ({ country: e, language: t }) => {
14
70
  let n = [];
15
71
  return e && n.push(`country: ${e}`), t && n.push(`language: ${t}`), n.length > 0 ? `@inContext(${n.join(", ")})` : "";
16
- }, c = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? u(e, t) : l(e, t), l = async (e, t) => {
72
+ }, S = async (e, { useExternalMetafieldNamespace: t, useMetaobjects: n }) => n ? w(e, t) : C(e, t), C = async (e, t) => {
17
73
  let n = (await e.query("\n query FetchDealBlocks($metafieldNamespace: String!) {\n shop {\n metafield(namespace: $metafieldNamespace, key: \"deal_blocks\") {\n value\n }\n }\n }\n ", { variables: { metafieldNamespace: t ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles" } })).shop.metafield?.value;
18
74
  return n ? JSON.parse(n) : [];
19
- }, u = async (e, t) => {
75
+ }, w = async (e, t) => {
20
76
  let n = t ? "app--2935586817--deal_block" : "$app:deal_block", r = [], i = null;
21
77
  for (;;) {
22
78
  let t = await e.query("\n query FetchDealBlockMetaobjects($type: String!, $cursor: String) {\n metaobjects(type: $type, first: 250, after: $cursor) {\n nodes {\n fields {\n key\n value\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ", { variables: {
@@ -45,19 +101,19 @@ var e = (e, { language: n, country: s }) => {
45
101
  "badgeText",
46
102
  "error"
47
103
  ].map((e) => `brand_${e}`);
48
- var d = /* @__PURE__ */ function(e) {
104
+ var T = /* @__PURE__ */ function(e) {
49
105
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
50
- }({}), f = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: c = 1e3 }) => {
106
+ }({}), E = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
51
107
  switch (r) {
52
- case "selected-products": return a.slice(0, c);
108
+ case "selected-products": return a.slice(0, s);
53
109
  case "all-products":
54
110
  case "excluded-products": {
55
- let a = s({
111
+ let a = x({
56
112
  country: t,
57
113
  language: n
58
- }), o = [], l = null;
59
- for (; o.length < c;) {
60
- let t = Math.min(c - o.length, 250), n = await e.query(`
114
+ }), o = [], c = null;
115
+ for (; o.length < s;) {
116
+ let t = Math.min(s - o.length, 250), n = await e.query(`
61
117
  query FetchProductGIDs($limit: Int!, $cursor: String) ${a} {
62
118
  products(first: $limit, after: $cursor) {
63
119
  nodes {
@@ -71,10 +127,10 @@ var d = /* @__PURE__ */ function(e) {
71
127
  }
72
128
  `, { variables: {
73
129
  limit: t,
74
- cursor: l
130
+ cursor: c
75
131
  } });
76
132
  if (o.push(...n.products.nodes.map((e) => e.id)), !n.products.pageInfo.hasNextPage) break;
77
- l = n.products.pageInfo.endCursor;
133
+ c = n.products.pageInfo.endCursor;
78
134
  }
79
135
  if (r === "excluded-products") {
80
136
  let e = new Set(i);
@@ -83,7 +139,7 @@ var d = /* @__PURE__ */ function(e) {
83
139
  return o;
84
140
  }
85
141
  case "selected-collections": {
86
- let r = s({
142
+ let r = x({
87
143
  country: t,
88
144
  language: n
89
145
  }), i = (await e.query(`
@@ -100,21 +156,21 @@ var d = /* @__PURE__ */ function(e) {
100
156
  }
101
157
  `, { variables: {
102
158
  collectionGIDs: o,
103
- limit: Math.min(c, 250)
159
+ limit: Math.min(s, 250)
104
160
  } })).nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes.map((e) => e.id));
105
- return Array.from(new Set(i)).slice(0, c);
161
+ return Array.from(new Set(i)).slice(0, s);
106
162
  }
107
163
  }
108
- }, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, includeProductTabFields: l = !1, productSubtitleMetafield: u = "descriptors.subtitle", useExternalMetafieldNamespace: d = !1, batchSize: f = 250, onBatchError: m, variantImageTransform: v = {
164
+ }, D = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", O = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: s = !1, includeProductTabFields: c = !1, productSubtitleMetafield: l = "descriptors.subtitle", useExternalMetafieldNamespace: u = !1, batchSize: d = 250, onBatchError: f, variantImageTransform: p = {
109
165
  maxWidth: 200,
110
166
  maxHeight: 200
111
167
  } }) => {
112
168
  if (!r.length) return [];
113
- let y = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), b = s({
169
+ let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = x({
114
170
  country: t,
115
171
  language: n
116
- }), x = `
117
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${b} {
172
+ }), g = `
173
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
118
174
  shop {
119
175
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
120
176
  value
@@ -148,7 +204,7 @@ var d = /* @__PURE__ */ function(e) {
148
204
  }
149
205
  variants(first: 250) {
150
206
  nodes {
151
- ${p}
207
+ ${D}
152
208
  }
153
209
  }
154
210
  collections(first: 50) {
@@ -214,50 +270,50 @@ var d = /* @__PURE__ */ function(e) {
214
270
  }
215
271
  }
216
272
  }
217
- `, S = d ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", C = u.indexOf("."), w = u.slice(0, C), T = u.slice(C + 1), E = [], D = Math.min(f, 250);
218
- for (let e = 0; e < y.length; e += D) E.push(y.slice(e, e + D));
219
- let O = 1, k = async (n) => {
220
- let [r, s] = await Promise.all([e.query(x, { variables: {
273
+ `, _ = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = l.indexOf("."), y = l.slice(0, v), b = l.slice(v + 1), S = [], C = Math.min(d, 250);
274
+ for (let e = 0; e < m.length; e += C) S.push(m.slice(e, e + C));
275
+ let w = 1, T = async (n) => {
276
+ let [r, l] = await Promise.all([e.query(g, { variables: {
221
277
  productGIDs: n,
222
278
  includeSellingPlans: i,
223
279
  includeAvailableQuantity: a,
224
280
  includeProductRating: o,
225
- includeProductSubtitle: c,
226
- includeProductTabFields: l,
227
- subtitleNamespace: w,
228
- subtitleKey: T,
229
- metafieldNamespace: S,
230
- variantImageTransform: v
231
- } }), l ? h(e, t, n) : null]);
232
- return r.shop.currencyRateConstant && (O = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), s ? { nodes: r.nodes.map((e) => e && {
281
+ includeProductSubtitle: s,
282
+ includeProductTabFields: c,
283
+ subtitleNamespace: y,
284
+ subtitleKey: b,
285
+ metafieldNamespace: _,
286
+ variantImageTransform: p
287
+ } }), c ? ee(e, t, n) : null]);
288
+ return r.shop.currencyRateConstant && (w = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), l ? { nodes: r.nodes.map((e) => e && {
233
289
  ...e,
234
- productType: s.get(e.id)
290
+ productType: l.get(e.id)
235
291
  }) } : r;
236
- }, A;
237
- if (m) {
238
- let e = await Promise.allSettled(E.map(k));
239
- for (let t of e) t.status === "rejected" && m(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
240
- A = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
241
- } else A = (await Promise.all(E.map(k))).flatMap((e) => e.nodes);
242
- let j = A.filter((e) => e != null);
243
- if (m) {
244
- let t = await Promise.allSettled(j.map(async (t) => _(await g(e, t, {
292
+ }, E;
293
+ if (f) {
294
+ let e = await Promise.allSettled(S.map(T));
295
+ for (let t of e) t.status === "rejected" && f(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
296
+ E = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
297
+ } else E = (await Promise.all(S.map(T))).flatMap((e) => e.nodes);
298
+ let O = E.filter((e) => e != null);
299
+ if (f) {
300
+ let t = await Promise.allSettled(O.map(async (t) => A(await k(e, t, {
245
301
  includeSellingPlans: i,
246
302
  includeAvailableQuantity: a,
247
- variantImageTransform: v
248
- }, b), e.shopifyDomain, O))), n = [];
249
- for (let e of t) e.status === "fulfilled" ? n.push(e.value) : m(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
303
+ variantImageTransform: p
304
+ }, h), e.shopifyDomain, w))), n = [];
305
+ for (let e of t) e.status === "fulfilled" ? n.push(e.value) : f(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
250
306
  return n;
251
307
  }
252
- return (await Promise.all(j.map((t) => g(e, t, {
308
+ return (await Promise.all(O.map((t) => k(e, t, {
253
309
  includeSellingPlans: i,
254
310
  includeAvailableQuantity: a,
255
- variantImageTransform: v
256
- }, b)))).map((t) => _(t, e.shopifyDomain, O));
257
- }, h = async (e, t, n) => {
311
+ variantImageTransform: p
312
+ }, h)))).map((t) => A(t, e.shopifyDomain, w));
313
+ }, ee = async (e, t, n) => {
258
314
  try {
259
315
  let r = await e.query(`
260
- query FetchProductTypes($productGIDs: [ID!]!) ${s({ country: t })} {
316
+ query FetchProductTypes($productGIDs: [ID!]!) ${x({ country: t })} {
261
317
  nodes(ids: $productGIDs) {
262
318
  ... on Product {
263
319
  id
@@ -270,7 +326,7 @@ var d = /* @__PURE__ */ function(e) {
270
326
  } catch (e) {
271
327
  return console.error(e), null;
272
328
  }
273
- }, g = async (e, t, n, r = "") => {
329
+ }, k = async (e, t, n, r = "") => {
274
330
  if (t.variants.nodes.length < 250) return t;
275
331
  let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
276
332
  let c = !0, l = null;
@@ -280,7 +336,7 @@ var d = /* @__PURE__ */ function(e) {
280
336
  product(id: $productGID) {
281
337
  variants(first: 250, after: $cursor, reverse: $reverse) {
282
338
  nodes {
283
- ${p}
339
+ ${D}
284
340
  }
285
341
  pageInfo {
286
342
  endCursor
@@ -306,7 +362,7 @@ var d = /* @__PURE__ */ function(e) {
306
362
  }
307
363
  };
308
364
  return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
309
- }, _ = (e, t, n) => {
365
+ }, A = (e, t, n) => {
310
366
  let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
311
367
  id: Number(t.id.split("/").pop()),
312
368
  availableForSale: t.availableForSale,
@@ -344,7 +400,7 @@ var d = /* @__PURE__ */ function(e) {
344
400
  defaultName: e.name,
345
401
  name: e.name,
346
402
  position: t + 1,
347
- optionValues: b(n, t, r)
403
+ optionValues: re(n, t, r)
348
404
  };
349
405
  }), a = (e) => {
350
406
  let t = e.priceAdjustments[0];
@@ -392,46 +448,31 @@ var d = /* @__PURE__ */ function(e) {
392
448
  text3: e.metafield3?.value || null,
393
449
  text4: e.metafield4?.value || null
394
450
  },
395
- rating: v(e.reviewsRating, e.reviewsRatingCount),
451
+ rating: te(e.reviewsRating, e.reviewsRatingCount),
396
452
  subtitle: e.subtitle?.value || null,
397
453
  productType: e.productType || null,
398
454
  categoryGid: e.category?.id ?? null,
399
455
  tags: e.tags ?? []
400
456
  };
401
- }, v = (e, t) => {
457
+ }, te = (e, t) => {
402
458
  if (!e) return null;
403
- let n = y(e.value);
459
+ let n = ne(e.value);
404
460
  if (n === null) return null;
405
461
  let r = Number(t?.value);
406
462
  return {
407
463
  value: n,
408
464
  count: Number.isInteger(r) && r > 0 ? r : null
409
465
  };
410
- }, y = (e) => {
466
+ }, ne = (e) => {
411
467
  try {
412
468
  let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
413
469
  return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
414
470
  } catch {
415
471
  return null;
416
472
  }
417
- }, b = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0);
418
- [
419
- "primaryBackground",
420
- "secondaryBackground",
421
- "primaryText",
422
- "secondaryText",
423
- "border",
424
- "overlay",
425
- "primaryAccent",
426
- "primaryAccentText",
427
- "badgeBackground",
428
- "badgeText",
429
- "error"
430
- ].map((e) => `brand_${e}`);
431
- // ../bundles-storefront-api/dist/fetchGlobalConfig.js
432
- var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
433
- let a = i ? `${x}--kaching_bundles` : "$app:kaching_bundles", o = i ? x : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
434
- query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
473
+ }, re = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), j = "app--2935586817", M = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
474
+ let i = r ? `${j}--kaching_bundles` : "$app:kaching_bundles", a = r ? j : "$app", o = x({ country: n }), { localization: { country: { currency: { isoCode: s } } }, shop: { moneyFormat: c, paymentSettings: { currencyCode: l }, currencyRateConstant: u, primaryDomain: d, settingsMetafield: f } } = await e.query(`
475
+ query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
435
476
  localization {
436
477
  country {
437
478
  currency {
@@ -456,31 +497,31 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
456
497
  }
457
498
  }
458
499
  `, { variables: {
459
- metafieldNamespace: a,
460
- settingsNamespace: o
461
- } }), h = l === d ? u : e(l, {
462
- language: n,
463
- country: r
464
- }), g = f ? C(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
500
+ metafieldNamespace: i,
501
+ settingsNamespace: a
502
+ } }), p = s === l ? c : m(s, {
503
+ language: t,
504
+ country: n
505
+ }), h = u ? N(u.value) : 1, g = f ? JSON.parse(f.value) : null, _ = g?.feature_flags ?? {}, v = g?.custom_selectors ?? {};
465
506
  return {
466
- shopifyDomain: p.host,
467
- moneyFormat: h,
468
- locale: n?.toLowerCase() || "en",
469
- liquidLocale: n?.toLowerCase() || "en",
470
- country: r ?? "US",
471
- currencyRate: g,
507
+ shopifyDomain: d.host,
508
+ moneyFormat: p,
509
+ locale: t?.toLowerCase() || "en",
510
+ liquidLocale: t?.toLowerCase() || "en",
511
+ country: n ?? "US",
512
+ currencyRate: h,
472
513
  marketId: 0,
473
514
  productId: null,
474
- storefrontAccessToken: _?.storefront_access_token ?? null,
475
- includeSellingPlans: _?.include_selling_plans ?? !1,
476
- includeAvailableQuantity: _?.include_available_quantity ?? !1,
477
- customApiHost: _?.custom_api_host ?? null,
478
- keepQuantityInput: _?.keep_quantity_input ?? !1,
479
- ignoreDeselect: _?.ignore_deselect ?? !1,
480
- ignoreUnitPrice: _?.ignore_unit_price ?? !1,
481
- requireCustomerLogin: _?.require_customer_login ?? !1,
482
- abTestsRunning: _?.ab_tests_running ?? !1,
483
- webPixel: _?.web_pixel ?? !1,
515
+ storefrontAccessToken: g?.storefront_access_token ?? null,
516
+ includeSellingPlans: g?.include_selling_plans ?? !1,
517
+ includeAvailableQuantity: g?.include_available_quantity ?? !1,
518
+ customApiHost: g?.custom_api_host ?? null,
519
+ keepQuantityInput: g?.keep_quantity_input ?? !1,
520
+ ignoreDeselect: g?.ignore_deselect ?? !1,
521
+ ignoreUnitPrice: g?.ignore_unit_price ?? !1,
522
+ requireCustomerLogin: g?.require_customer_login ?? !1,
523
+ abTestsRunning: g?.ab_tests_running ?? !1,
524
+ webPixel: g?.web_pixel ?? !1,
484
525
  b2bCustomer: !1,
485
526
  isLoggedIn: !1,
486
527
  preview: !1,
@@ -512,17 +553,17 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
512
553
  "system.numbers_only": "Only numbers are allowed."
513
554
  },
514
555
  customSelectors: {
515
- quantity: y.quantity ?? null,
516
- addToCartButton: y.add_to_cart_button ?? null,
517
- variantPicker: y.variant_picker ?? null,
518
- price: y.price ?? null,
519
- priceCompare: y.price_compare ?? null
556
+ quantity: v.quantity ?? null,
557
+ addToCartButton: v.add_to_cart_button ?? null,
558
+ variantPicker: v.variant_picker ?? null,
559
+ price: v.price ?? null,
560
+ priceCompare: v.price_compare ?? null
520
561
  },
521
- shopCustomStyles: _?.shop_custom_styles ?? "",
522
- featureFlags: v,
523
- brandColors: _?.brand_colors ?? null
562
+ shopCustomStyles: g?.shop_custom_styles ?? "",
563
+ featureFlags: _,
564
+ brandColors: g?.brand_colors ?? null
524
565
  };
525
- }, C = (e) => JSON.parse(e).amount / 1e6, w = async (e, t, n = 200) => {
566
+ }, N = (e) => JSON.parse(e).amount / 1e6, P = async (e, t, n = 200) => {
526
567
  let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
527
568
  if (r.length === 0) return [];
528
569
  let i = [];
@@ -534,10 +575,10 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
534
575
  gid: e.id,
535
576
  url: e.image.url
536
577
  }] : []);
537
- }, T = 100, E = async (e, { dealBlock: t, country: n, language: r }) => {
538
- let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === d.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
578
+ }, F = 100, I = async (e, { dealBlock: t, country: n, language: r }) => {
579
+ let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === T.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
539
580
  if (i.length === 0) return [];
540
- let a = s({
581
+ let a = x({
541
582
  country: n,
542
583
  language: r
543
584
  }), o = await e.query(`
@@ -545,7 +586,7 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
545
586
  nodes(ids: $collectionGIDs) {
546
587
  ... on Collection {
547
588
  id
548
- products(first: ${T}) {
589
+ products(first: ${F}) {
549
590
  nodes {
550
591
  id
551
592
  variants(first: 1) {
@@ -560,77 +601,77 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
560
601
  }
561
602
  `, { variables: { collectionGIDs: i } });
562
603
  return [...new Set(o.nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes).filter((e) => !e.variants.nodes.some((e) => e.requiresComponents)).map((e) => e.id))];
563
- }, D = (e) => [
564
- ...O(e),
565
- ...k(e),
566
- ...A(e),
567
- ...j(e),
568
- ...M(e),
569
- ...N(e),
570
- ...ee(e),
571
- ...te(e),
572
- ...P(e),
573
- ...F(e),
574
- ...I(e),
575
- ...L(e),
576
- ...R(e)
577
- ].filter((e) => e != null && !e.includes("placeholder")), O = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), k = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), A = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), j = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), M = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), N = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
604
+ }, L = (e) => [
605
+ ...R(e),
606
+ ...z(e),
607
+ ...B(e),
608
+ ...V(e),
609
+ ...H(e),
610
+ ...U(e),
611
+ ...W(e),
612
+ ...G(e),
613
+ ...K(e),
614
+ ...q(e),
615
+ ...J(e),
616
+ ...Y(e),
617
+ ...X(e)
618
+ ].filter((e) => e != null && !e.includes("placeholder")), R = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), z = (e) => e.dealBars.flatMap((e) => e.dealBarType === T.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), B = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), V = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), H = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), U = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
578
619
  let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
579
620
  return [...e, ...n];
580
- }, []) : [], ee = (e) => {
621
+ }, []) : [], W = (e) => {
581
622
  if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
582
623
  let t = e.collectionBreaks.mediaImageGID;
583
624
  return t ? [t] : [];
584
- }, te = (e) => e.progressiveGifts ? [
625
+ }, G = (e) => e.progressiveGifts ? [
585
626
  ...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
586
627
  e.progressiveGifts.style?.lockedMediaImageGID,
587
628
  e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
588
- ].filter((e) => e != null) : [], P = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), F = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), I = (e) => {
629
+ ].filter((e) => e != null) : [], K = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), q = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), J = (e) => {
589
630
  let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
590
631
  return n ? [...t, n] : t;
591
- }, L = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), R = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], z = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
632
+ }, Y = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), X = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ie = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
592
633
  let n = [
593
- ...B(e),
594
- ...V(e),
595
- ...H(e),
596
- ...U(e),
597
- ...W(e),
598
- ...G(e, t),
599
- ...K(e),
600
- ...q(e)
634
+ ...ae(e),
635
+ ...oe(e),
636
+ ...se(e),
637
+ ...ce(e),
638
+ ...le(e),
639
+ ...ue(e, t),
640
+ ...de(e),
641
+ ...fe(e)
601
642
  ];
602
643
  return Array.from(new Set(n.filter((e) => e != null)));
603
- }, B = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), V = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), H = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], U = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), W = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), G = (e, t) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), K = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), q = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), J = class extends Error {
644
+ }, ae = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), oe = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), se = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], ce = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), le = (e) => e.dealBars.filter((e) => e.dealBarType === T.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), ue = (e, t) => e.dealBars.filter((e) => e.dealBarType === T.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), de = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), fe = (e) => e.dealBars.filter((e) => e.dealBarType === T.Sku).flatMap(({ productGID: e }) => e ? [e] : []), Z = class extends Error {
604
645
  constructor({ status: e, operationName: t, graphqlErrors: n }) {
605
646
  let r = n.length ? `: ${n.join("; ")}` : "";
606
647
  super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
607
648
  }
608
- }, Y = async (e, t) => {
649
+ }, pe = async (e, t) => {
609
650
  let n = await e.text();
610
651
  if (!n) throw Error("Empty graphql response");
611
652
  let r;
612
653
  try {
613
654
  r = JSON.parse(n);
614
655
  } catch (n) {
615
- throw e.ok ? n : new J({
656
+ throw e.ok ? n : new Z({
616
657
  status: e.status,
617
658
  operationName: t,
618
659
  graphqlErrors: []
619
660
  });
620
661
  }
621
- if (!e.ok || r.data === null || r.data === void 0) throw new J({
662
+ if (!e.ok || r.data === null || r.data === void 0) throw new Z({
622
663
  status: e.status,
623
664
  operationName: t,
624
665
  graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
625
666
  });
626
667
  return r.data;
627
- }, X = class {
668
+ }, me = class {
628
669
  constructor(e, t) {
629
670
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
630
671
  }
631
672
  async query(e, t) {
632
673
  let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
633
- return i && (r += `?operation_name=${i}`), Y(await fetch(r, {
674
+ return i && (r += `?operation_name=${i}`), pe(await fetch(r, {
634
675
  method: "POST",
635
676
  headers: {
636
677
  "Content-Type": "application/json",
@@ -642,16 +683,6 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
642
683
  })
643
684
  }), i);
644
685
  }
645
- }, Z = (e, t) => {
646
- let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
647
- for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
648
- let i = e.filter((e) => e.blockVisibility === "selected-collections");
649
- for (let e of i) t.collectionIds.some((t) => e.selectedCollectionIds.map(Number).includes(t)) && n.push(e);
650
- let a = e.filter((e) => e.blockVisibility === "excluded-products");
651
- for (let e of a) !e.excludedProductIds.map(Number).includes(t.id) && !(e.excludedCollectionIds || []).some((e) => t.collectionIds.includes(e)) && n.push(e);
652
- let o = e.filter((e) => e.blockVisibility === "all-products");
653
- for (let e of o) n.push(e);
654
- return n;
655
686
  };
656
687
  [
657
688
  "primaryBackground",
@@ -666,20 +697,20 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
666
697
  "badgeText",
667
698
  "error"
668
699
  ].map((e) => `brand_${e}`);
669
- var ne = /* @__PURE__ */ function(e) {
700
+ var he = /* @__PURE__ */ function(e) {
670
701
  return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
671
- }({}), re = async (e, t, { country: n, language: r }) => {
702
+ }({}), ge = async (e, t, { country: n, language: r }) => {
672
703
  let i = t.collectionBreaks;
673
704
  if (!t.collectionBreaksEnabled || !i) return;
674
705
  let a;
675
- a = i.visibility === "deal-products" ? await f(e, {
706
+ a = i.visibility === "deal-products" ? await E(e, {
676
707
  country: n,
677
708
  language: r,
678
709
  blockVisibility: t.blockVisibility,
679
710
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
680
711
  selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
681
712
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
682
- }) : await f(e, {
713
+ }) : await E(e, {
683
714
  country: n,
684
715
  language: r,
685
716
  blockVisibility: i.visibility,
@@ -687,14 +718,14 @@ var ne = /* @__PURE__ */ function(e) {
687
718
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
688
719
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
689
720
  });
690
- let o = await m(e, {
721
+ let o = await O(e, {
691
722
  country: n,
692
723
  language: r,
693
724
  productIds: a.map((e) => Number(e.split("/").pop())),
694
725
  useExternalMetafieldNamespace: !0
695
726
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
696
- return o = o.filter((e) => e.availableForSale && (!s || Z([t], e).length > 0)), o;
697
- }, ie = ({ language: e, dealBlockId: t }) => {
727
+ return o = o.filter((e) => e.availableForSale && (!s || p([t], e).length > 0)), o;
728
+ }, _e = ({ language: e, dealBlockId: t }) => {
698
729
  let n = {
699
730
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
700
731
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -721,13 +752,13 @@ var ne = /* @__PURE__ */ function(e) {
721
752
  "system.numbers_only": "Only numbers are allowed.",
722
753
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
723
754
  "system.gifts_required_alert": "Please choose your free gifts"
724
- }, r = e ? ae(e) : void 0;
755
+ }, r = e ? ve(e) : void 0;
725
756
  return {
726
757
  ...n,
727
758
  ...r?.system,
728
759
  ...r?.dealBlocks[t]
729
760
  };
730
- }, ae = (e) => {
761
+ }, ve = (e) => {
731
762
  if (typeof document > "u") return;
732
763
  let t = document.querySelector("script#kaching-bundles-translations");
733
764
  if (!t?.textContent) return;
@@ -739,41 +770,41 @@ var ne = /* @__PURE__ */ function(e) {
739
770
  }
740
771
  let r = Q(e);
741
772
  return n.find((e) => Q(e.locale) === r)?.translations;
742
- }, Q = (e) => e.toLowerCase().replace(/_/g, "-"), oe = "2026-07", $ = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
773
+ }, Q = (e) => e.toLowerCase().replace(/_/g, "-"), ye = "2026-07", be = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
743
774
  try {
744
- let o = [Number(t.split("/").pop())], s = new de(e);
745
- i ||= s.i18n?.country, a ||= s.i18n?.language;
746
- let l = await S(s, {
775
+ let s = [Number(t.split("/").pop())], c = new we(e);
776
+ i ||= c.i18n?.country, a ||= c.i18n?.language;
777
+ let l = await M(c, {
747
778
  language: a,
748
779
  country: i,
749
780
  useExternalMetafieldNamespace: !0
750
781
  });
751
- s.shopifyDomain = l.shopifyDomain;
752
- let u = l.storefrontAccessToken ? new X(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
782
+ c.shopifyDomain = l.shopifyDomain;
783
+ let u = l.storefrontAccessToken ? new me(l.shopifyDomain, l.storefrontAccessToken) : c, [d, f] = await Promise.all([O(u, {
753
784
  country: i,
754
785
  language: a,
755
- productIds: o,
786
+ productIds: s,
756
787
  useExternalMetafieldNamespace: !0
757
- }), c(u, {
788
+ }), S(u, {
758
789
  useExternalMetafieldNamespace: !0,
759
790
  useMetaobjects: l.featureFlags.storefront_metaobjects
760
- })]), p = d[0];
761
- if (!p) return null;
762
- let h = Z(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
791
+ })]), m = d[0];
792
+ if (!m) return null;
793
+ let h = p(f, m), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
763
794
  if (!_) return null;
764
- let v = z(_, { includeMixAndMatchSwapProducts: !1 }), y = se(u, _, {
795
+ let v = ie(_, { includeMixAndMatchSwapProducts: !1 }), y = $(u, _, {
765
796
  otherProductGIDs: v,
766
797
  country: i,
767
798
  language: a
768
799
  }), [b, x, C] = await Promise.all([
769
- m(u, {
800
+ O(u, {
770
801
  country: i,
771
802
  language: a,
772
803
  productIds: v,
773
804
  useExternalMetafieldNamespace: !0
774
805
  }),
775
- w(u, D(_), 300),
776
- ie({
806
+ P(u, L(_), 300),
807
+ _e({
777
808
  language: a,
778
809
  dealBlockId: _.id
779
810
  })
@@ -782,8 +813,8 @@ var ne = /* @__PURE__ */ function(e) {
782
813
  data: {
783
814
  config: l,
784
815
  dealBlock: _,
785
- product: p,
786
- otherProducts: b,
816
+ product: m,
817
+ otherProducts: o(_, b),
787
818
  mediaImages: x,
788
819
  translations: C
789
820
  },
@@ -792,17 +823,17 @@ var ne = /* @__PURE__ */ function(e) {
792
823
  } catch (e) {
793
824
  return console.error(e), null;
794
825
  }
795
- }, se = async (e, t, n) => {
796
- let [r, i] = await Promise.all([ce(e, t, n), ue(e, t, n)]);
826
+ }, $ = async (e, t, n) => {
827
+ let [r, i] = await Promise.all([xe(e, t, n), Ce(e, t, n)]);
797
828
  return {
798
829
  mixAndMatchSwapProducts: r,
799
830
  collectionBreaksProducts: i
800
831
  };
801
- }, ce = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
832
+ }, xe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
802
833
  try {
803
834
  let a = [];
804
835
  try {
805
- a = await E(e, {
836
+ a = await I(e, {
806
837
  dealBlock: t,
807
838
  country: r,
808
839
  language: i
@@ -810,26 +841,26 @@ var ne = /* @__PURE__ */ function(e) {
810
841
  } catch (e) {
811
842
  console.error(e);
812
843
  }
813
- let o = new Set(n), s = [.../* @__PURE__ */ new Set([...le(t), ...a])].filter((e) => !o.has(e));
814
- return s.length ? await m(e, {
844
+ let s = new Set(n), c = [.../* @__PURE__ */ new Set([...Se(t), ...a])].filter((e) => !s.has(e));
845
+ return c.length ? o(t, await O(e, {
815
846
  country: r,
816
847
  language: i,
817
- productIds: s,
848
+ productIds: c,
818
849
  useExternalMetafieldNamespace: !0
819
- }) : [];
850
+ })) : [];
820
851
  } catch (e) {
821
852
  return console.error(e), [];
822
853
  }
823
- }, le = (e) => e.dealBars.flatMap((e) => e.dealBarType === ne.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), ue = async (e, t, { country: n, language: r }) => {
854
+ }, Se = (e) => e.dealBars.flatMap((e) => e.dealBarType === he.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), Ce = async (e, t, { country: n, language: r }) => {
824
855
  try {
825
- return await re(e, t, {
856
+ return await ge(e, t, {
826
857
  country: n,
827
858
  language: r
828
859
  }) ?? [];
829
860
  } catch (e) {
830
861
  return console.error(e), [];
831
862
  }
832
- }, de = class {
863
+ }, we = class {
833
864
  constructor(e) {
834
865
  this.storefront = e, this.shopifyDomain = "";
835
866
  }
@@ -842,7 +873,7 @@ var ne = /* @__PURE__ */ function(e) {
842
873
  }
843
874
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
844
875
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
845
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${oe}/graphql.json`, {
876
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ye}/graphql.json`, {
846
877
  body: JSON.stringify({
847
878
  query: e,
848
879
  variables: t?.variables
@@ -872,9 +903,9 @@ var ne = /* @__PURE__ */ function(e) {
872
903
  get i18n() {
873
904
  if ("i18n" in this.storefront) return this.storefront.i18n;
874
905
  }
875
- }, fe = async (e, t) => {
906
+ }, Te = async (e, t) => {
876
907
  try {
877
- let n = await $(e, t);
908
+ let n = await be(e, t);
878
909
  if (!n) return null;
879
910
  let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
880
911
  return {
@@ -891,4 +922,4 @@ var ne = /* @__PURE__ */ function(e) {
891
922
  return console.error(e), null;
892
923
  }
893
924
  };
894
- export { fe as fetchKachingBundlesData };
925
+ export { Te as fetchKachingBundlesData };