@kachingappz/bundles-js 1.1.9 → 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
- ...P(e),
571
- ...F(e),
572
- ...I(e),
573
- ...L(e),
604
+ }, L = (e) => [
574
605
  ...R(e),
575
606
  ...z(e),
576
- ...B(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) => {
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
- }, []) : [], P = (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
- }, F = (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) : [], I = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), L = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), R = (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
- }, z = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), B = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], V = (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
- ...H(e),
594
- ...U(e),
595
- ...W(e),
596
- ...G(e),
597
- ...K(e),
598
- ...q(e, t),
599
- ...J(e),
600
- ...Y(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
- }, H = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), U = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), W = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], G = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), K = (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"), q = (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"), J = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), Y = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), X = 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
- }, Z = 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 X({
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 X({
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
- }, ee = 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}`), Z(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,28 +683,34 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
642
683
  })
643
684
  }), i);
644
685
  }
645
- }, Q = (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
- }, te = async (e, t, { country: n, language: r }) => {
686
+ };
687
+ [
688
+ "primaryBackground",
689
+ "secondaryBackground",
690
+ "primaryText",
691
+ "secondaryText",
692
+ "border",
693
+ "overlay",
694
+ "primaryAccent",
695
+ "primaryAccentText",
696
+ "badgeBackground",
697
+ "badgeText",
698
+ "error"
699
+ ].map((e) => `brand_${e}`);
700
+ var he = /* @__PURE__ */ function(e) {
701
+ return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
702
+ }({}), ge = async (e, t, { country: n, language: r }) => {
656
703
  let i = t.collectionBreaks;
657
704
  if (!t.collectionBreaksEnabled || !i) return;
658
705
  let a;
659
- a = i.visibility === "deal-products" ? await f(e, {
706
+ a = i.visibility === "deal-products" ? await E(e, {
660
707
  country: n,
661
708
  language: r,
662
709
  blockVisibility: t.blockVisibility,
663
710
  excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
664
711
  selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
665
712
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
666
- }) : await f(e, {
713
+ }) : await E(e, {
667
714
  country: n,
668
715
  language: r,
669
716
  blockVisibility: i.visibility,
@@ -671,14 +718,14 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
671
718
  selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
672
719
  selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
673
720
  });
674
- let o = await m(e, {
721
+ let o = await O(e, {
675
722
  country: n,
676
723
  language: r,
677
724
  productIds: a.map((e) => Number(e.split("/").pop())),
678
725
  useExternalMetafieldNamespace: !0
679
726
  }), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
680
- return o = o.filter((e) => e.availableForSale && (!s || Q([t], e).length > 0)), o;
681
- }, ne = ({ 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 }) => {
682
729
  let n = {
683
730
  "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
684
731
  "system.invalid_variant": "Sorry, this is not currently available.",
@@ -705,13 +752,13 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
705
752
  "system.numbers_only": "Only numbers are allowed.",
706
753
  "system.personalisation_required_alert": "Please add personalisation for every item to continue.",
707
754
  "system.gifts_required_alert": "Please choose your free gifts"
708
- }, r = e ? re(e) : void 0;
755
+ }, r = e ? ve(e) : void 0;
709
756
  return {
710
757
  ...n,
711
758
  ...r?.system,
712
759
  ...r?.dealBlocks[t]
713
760
  };
714
- }, re = (e) => {
761
+ }, ve = (e) => {
715
762
  if (typeof document > "u") return;
716
763
  let t = document.querySelector("script#kaching-bundles-translations");
717
764
  if (!t?.textContent) return;
@@ -721,72 +768,99 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
721
768
  } catch {
722
769
  return;
723
770
  }
724
- let r = $(e);
725
- return n.find((e) => $(e.locale) === r)?.translations;
726
- }, $ = (e) => e.toLowerCase().replace(/_/g, "-"), ie = "2026-07", ae = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
771
+ let r = Q(e);
772
+ return n.find((e) => Q(e.locale) === r)?.translations;
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 }) => {
727
774
  try {
728
- let o = [Number(t.split("/").pop())], s = new oe(e);
729
- i ||= s.i18n?.country, a ||= s.i18n?.language;
730
- 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, {
731
778
  language: a,
732
779
  country: i,
733
780
  useExternalMetafieldNamespace: !0
734
781
  });
735
- s.shopifyDomain = l.shopifyDomain;
736
- let u = l.storefrontAccessToken ? new ee(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, {
737
784
  country: i,
738
785
  language: a,
739
- productIds: o,
786
+ productIds: s,
740
787
  useExternalMetafieldNamespace: !0
741
- }), c(u, {
788
+ }), S(u, {
742
789
  useExternalMetafieldNamespace: !0,
743
790
  useMetaobjects: l.featureFlags.storefront_metaobjects
744
- })]), p = d[0];
745
- if (!p) return null;
746
- let h = Q(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];
747
794
  if (!_) return null;
748
- let v = D(_), [y, b, x, C] = await Promise.all([
749
- (async () => {
750
- let e = [];
751
- try {
752
- e = await E(u, {
753
- dealBlock: _,
754
- country: i,
755
- language: a
756
- });
757
- } catch (e) {
758
- console.error(e);
759
- }
760
- return m(u, {
761
- country: i,
762
- language: a,
763
- productIds: [.../* @__PURE__ */ new Set([...V(_), ...e])],
764
- useExternalMetafieldNamespace: !0
765
- });
766
- })(),
767
- w(u, v, 300),
768
- te(u, _, {
795
+ let v = ie(_, { includeMixAndMatchSwapProducts: !1 }), y = $(u, _, {
796
+ otherProductGIDs: v,
797
+ country: i,
798
+ language: a
799
+ }), [b, x, C] = await Promise.all([
800
+ O(u, {
769
801
  country: i,
770
- language: a
802
+ language: a,
803
+ productIds: v,
804
+ useExternalMetafieldNamespace: !0
771
805
  }),
772
- ne({
806
+ P(u, L(_), 300),
807
+ _e({
773
808
  language: a,
774
809
  dealBlockId: _.id
775
810
  })
776
811
  ]);
777
812
  return {
778
- product: p,
779
- dealBlock: _,
780
- config: l,
781
- otherProducts: y,
782
- mediaImages: b,
783
- collectionBreaksProducts: x ?? [],
784
- translations: C
813
+ data: {
814
+ config: l,
815
+ dealBlock: _,
816
+ product: m,
817
+ otherProducts: o(_, b),
818
+ mediaImages: x,
819
+ translations: C
820
+ },
821
+ modalProducts: y
785
822
  };
786
823
  } catch (e) {
787
824
  return console.error(e), null;
788
825
  }
789
- }, oe = class {
826
+ }, $ = async (e, t, n) => {
827
+ let [r, i] = await Promise.all([xe(e, t, n), Ce(e, t, n)]);
828
+ return {
829
+ mixAndMatchSwapProducts: r,
830
+ collectionBreaksProducts: i
831
+ };
832
+ }, xe = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
833
+ try {
834
+ let a = [];
835
+ try {
836
+ a = await I(e, {
837
+ dealBlock: t,
838
+ country: r,
839
+ language: i
840
+ });
841
+ } catch (e) {
842
+ console.error(e);
843
+ }
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, {
846
+ country: r,
847
+ language: i,
848
+ productIds: c,
849
+ useExternalMetafieldNamespace: !0
850
+ })) : [];
851
+ } catch (e) {
852
+ return console.error(e), [];
853
+ }
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 }) => {
855
+ try {
856
+ return await ge(e, t, {
857
+ country: n,
858
+ language: r
859
+ }) ?? [];
860
+ } catch (e) {
861
+ return console.error(e), [];
862
+ }
863
+ }, we = class {
790
864
  constructor(e) {
791
865
  this.storefront = e, this.shopifyDomain = "";
792
866
  }
@@ -799,7 +873,7 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
799
873
  }
800
874
  if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
801
875
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
802
- let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ie}/graphql.json`, {
876
+ let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ye}/graphql.json`, {
803
877
  body: JSON.stringify({
804
878
  query: e,
805
879
  variables: t?.variables
@@ -829,5 +903,23 @@ var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalM
829
903
  get i18n() {
830
904
  if ("i18n" in this.storefront) return this.storefront.i18n;
831
905
  }
906
+ }, Te = async (e, t) => {
907
+ try {
908
+ let n = await be(e, t);
909
+ if (!n) return null;
910
+ let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
911
+ return {
912
+ config: r,
913
+ dealBlock: i,
914
+ product: a,
915
+ otherProducts: o,
916
+ mixAndMatchSwapProducts: l,
917
+ mediaImages: s,
918
+ collectionBreaksProducts: u,
919
+ translations: c
920
+ };
921
+ } catch (e) {
922
+ return console.error(e), null;
923
+ }
832
924
  };
833
- export { ae as fetchKachingBundlesData };
925
+ export { Te as fetchKachingBundlesData };