@kachingappz/bundles-js 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,61 @@
1
- const U = (t, e) => {
2
- const s = [], l = t.filter(
3
- (i) => i.blockVisibility === "selected-products"
1
+ const F = (e, t) => {
2
+ const s = [], a = e.filter(
3
+ (r) => r.blockVisibility === "selected-products"
4
4
  );
5
- for (const i of l)
6
- i.selectedProductIds.map(Number).includes(e.id) && s.push(i);
7
- const n = t.filter(
8
- (i) => i.blockVisibility === "selected-collections"
5
+ for (const r of a)
6
+ r.selectedProductIds.map(Number).includes(t.id) && s.push(r);
7
+ const n = e.filter(
8
+ (r) => r.blockVisibility === "selected-collections"
9
9
  );
10
- for (const i of n)
11
- e.collectionIds.some(
12
- (m) => i.selectedCollectionIds.map(Number).includes(m)
13
- ) && s.push(i);
14
- const r = t.filter(
15
- (i) => i.blockVisibility === "excluded-products"
10
+ for (const r of n)
11
+ t.collectionIds.some(
12
+ (m) => r.selectedCollectionIds.map(Number).includes(m)
13
+ ) && s.push(r);
14
+ const i = e.filter(
15
+ (r) => r.blockVisibility === "excluded-products"
16
16
  );
17
- for (const i of r)
18
- !i.excludedProductIds.map(Number).includes(e.id) && !(i.excludedCollectionIds || []).some(
19
- (m) => e.collectionIds.includes(m)
20
- ) && s.push(i);
21
- const o = t.filter(
22
- (i) => i.blockVisibility === "all-products"
17
+ for (const r of i)
18
+ !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
19
+ (m) => t.collectionIds.includes(m)
20
+ ) && s.push(r);
21
+ const o = e.filter(
22
+ (r) => r.blockVisibility === "all-products"
23
23
  );
24
- for (const i of o)
25
- s.push(i);
24
+ for (const r of o)
25
+ s.push(r);
26
26
  return s;
27
- }, L = (t, { language: e, country: s }) => {
28
- var y, h;
29
- const l = V(e, s), n = new Intl.NumberFormat(l, {
27
+ }, z = (e, { language: t, country: s }) => {
28
+ var h, g;
29
+ const a = R(t, s), n = new Intl.NumberFormat(a, {
30
30
  style: "currency",
31
- currency: t,
31
+ currency: e,
32
32
  currencyDisplay: "narrowSymbol"
33
- }).formatToParts(123456789e-2), r = (y = n.find((f) => f.type === "decimal")) == null ? void 0 : y.value, o = F(
34
- (h = n.find((f) => f.type === "group")) == null ? void 0 : h.value
35
- ), i = n.some((f) => f.type === "fraction"), m = R(
33
+ }).formatToParts(123456789e-2), i = (h = n.find((f) => f.type === "decimal")) == null ? void 0 : h.value, o = Q(
34
+ (g = n.find((f) => f.type === "group")) == null ? void 0 : g.value
35
+ ), r = n.some((f) => f.type === "fraction"), m = J(
36
36
  o,
37
- r,
38
- i
39
- ), d = n.findIndex(C), u = n.findLastIndex(C);
37
+ i,
38
+ r
39
+ ), c = n.findIndex(C), u = n.findLastIndex(C);
40
40
  return [
41
- ...n.slice(0, d).map(x),
41
+ ...n.slice(0, c).map(x),
42
42
  m,
43
43
  ...n.slice(u + 1).map(x)
44
44
  ].join("");
45
- }, x = (t) => O(t.value), O = (t) => t.replace(/\s/g, " "), C = (t) => t.type === "integer" || t.type === "group" || t.type === "decimal" || t.type === "fraction", V = (t, e) => t && e ? `${t}-${e.toUpperCase()}` : t || (e ? e.toUpperCase() : "en"), F = (t) => t === void 0 ? void 0 : O(t).replace(/’/g, "'"), R = (t, e, s) => e === "," && t === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : e === "," && t === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : e === "." && t === " " ? "{{amount_with_period_and_space_separator}}" : e === "." && t === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
46
- country: t,
47
- language: e
45
+ }, x = (e) => L(e.value), L = (e) => e.replace(/\s/g, " "), C = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", R = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), Q = (e) => e === void 0 ? void 0 : L(e).replace(/’/g, "'"), J = (e, t, s) => t === "," && e === "." ? s ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? s ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : s ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
46
+ country: e,
47
+ language: t
48
48
  }) => {
49
49
  const s = [];
50
- return t && s.push(`country: ${t}`), e && s.push(`language: ${e}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
51
- }, z = async (t, {
52
- useExternalMetafieldNamespace: e,
50
+ return e && s.push(`country: ${e}`), t && s.push(`language: ${t}`), s.length > 0 ? `@inContext(${s.join(", ")})` : "";
51
+ }, H = async (e, {
52
+ useExternalMetafieldNamespace: t,
53
53
  useMetaobjects: s
54
- }) => s ? J(
55
- t
56
- ) : Q(t), Q = async (t, e) => {
57
- var l;
58
- const s = (l = (await t.query(
54
+ }) => s ? W(
55
+ e
56
+ ) : X(e), X = async (e, t) => {
57
+ var a;
58
+ const s = (a = (await e.query(
59
59
  `
60
60
  query FetchDealBlocks($metafieldNamespace: String!) {
61
61
  shop {
@@ -70,13 +70,13 @@ const U = (t, e) => {
70
70
  metafieldNamespace: "app--2935586817--kaching_bundles"
71
71
  }
72
72
  }
73
- )).shop.metafield) == null ? void 0 : l.value;
73
+ )).shop.metafield) == null ? void 0 : a.value;
74
74
  return s ? JSON.parse(s) : [];
75
- }, J = async (t, e) => {
76
- const s = "app--2935586817--deal_block", l = [];
75
+ }, W = async (e, t) => {
76
+ const s = "app--2935586817--deal_block", a = [];
77
77
  let n = null;
78
78
  for (; ; ) {
79
- const r = await t.query(
79
+ const i = await e.query(
80
80
  `
81
81
  query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
82
82
  metaobjects(type: $type, first: 250, after: $cursor) {
@@ -100,35 +100,35 @@ const U = (t, e) => {
100
100
  }
101
101
  }
102
102
  );
103
- for (const o of r.metaobjects.nodes) {
104
- const i = o.fields.find(
103
+ for (const o of i.metaobjects.nodes) {
104
+ const r = o.fields.find(
105
105
  (m) => m.key === "settings"
106
106
  );
107
- i != null && i.value && l.push(JSON.parse(i.value));
107
+ r != null && r.value && a.push(JSON.parse(r.value));
108
108
  }
109
- if (!r.metaobjects.pageInfo.hasNextPage)
109
+ if (!i.metaobjects.pageInfo.hasNextPage)
110
110
  break;
111
- n = r.metaobjects.pageInfo.endCursor;
111
+ n = i.metaobjects.pageInfo.endCursor;
112
112
  }
113
- return l;
114
- }, N = async (t, {
115
- country: e,
113
+ return a;
114
+ }, N = async (e, {
115
+ country: t,
116
116
  language: s,
117
- blockVisibility: l,
117
+ blockVisibility: a,
118
118
  excludedProductGIDs: n,
119
- selectedProductGIDs: r,
119
+ selectedProductGIDs: i,
120
120
  selectedCollectionGIDs: o,
121
- limit: i = 1e3
121
+ limit: r = 1e3
122
122
  }) => {
123
- switch (l) {
123
+ switch (a) {
124
124
  case "selected-products":
125
- return r.slice(0, i);
125
+ return i.slice(0, r);
126
126
  case "all-products":
127
127
  case "excluded-products": {
128
- const m = w({ country: e, language: s });
129
- let d = [], u = null;
130
- for (; d.length < i; ) {
131
- const y = Math.min(i - d.length, 250), h = await t.query(
128
+ const m = w({ country: t, language: s });
129
+ let c = [], u = null;
130
+ for (; c.length < r; ) {
131
+ const h = Math.min(r - c.length, 250), g = await e.query(
132
132
  `
133
133
  query FetchProductGIDs($limit: Int!, $cursor: String) ${m} {
134
134
  products(first: $limit, after: $cursor) {
@@ -144,22 +144,22 @@ const U = (t, e) => {
144
144
  `,
145
145
  {
146
146
  variables: {
147
- limit: y,
147
+ limit: h,
148
148
  cursor: u
149
149
  }
150
150
  }
151
151
  );
152
- if (d.push(...h.products.nodes.map((f) => f.id)), !h.products.pageInfo.hasNextPage) break;
153
- u = h.products.pageInfo.endCursor;
152
+ if (c.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
153
+ u = g.products.pageInfo.endCursor;
154
154
  }
155
- if (l === "excluded-products") {
156
- const y = new Set(n);
157
- d = d.filter((h) => !y.has(h));
155
+ if (a === "excluded-products") {
156
+ const h = new Set(n);
157
+ c = c.filter((g) => !h.has(g));
158
158
  }
159
- return d;
159
+ return c;
160
160
  }
161
161
  case "selected-collections": {
162
- const m = w({ country: e, language: s }), d = (await t.query(
162
+ const m = w({ country: t, language: s }), c = (await e.query(
163
163
  `
164
164
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${m} {
165
165
  nodes(ids: $collectionGIDs) {
@@ -176,16 +176,16 @@ const U = (t, e) => {
176
176
  {
177
177
  variables: {
178
178
  collectionGIDs: o,
179
- limit: Math.min(i, 250)
179
+ limit: Math.min(r, 250)
180
180
  }
181
181
  }
182
182
  )).nodes.filter((u) => u !== null).flatMap(
183
- (u) => u.products.nodes.map((y) => y.id)
183
+ (u) => u.products.nodes.map((h) => h.id)
184
184
  );
185
- return Array.from(new Set(d)).slice(0, i);
185
+ return Array.from(new Set(c)).slice(0, r);
186
186
  }
187
187
  }
188
- }, j = `
188
+ }, U = `
189
189
  id
190
190
  availableForSale
191
191
  price {
@@ -200,7 +200,7 @@ const U = (t, e) => {
200
200
  }
201
201
  image {
202
202
  id
203
- url(transform: { maxWidth: 200, maxHeight: 200 })
203
+ url(transform: $variantImageTransform)
204
204
  }
205
205
  unitPriceMeasurement {
206
206
  quantityUnit
@@ -228,20 +228,21 @@ const U = (t, e) => {
228
228
  }
229
229
  }
230
230
  quantityAvailable @include(if: $includeAvailableQuantity)
231
- `, D = async (t, {
232
- country: e,
231
+ `, $ = async (e, {
232
+ country: t,
233
233
  language: s,
234
- productIds: l,
234
+ productIds: a,
235
235
  includeSellingPlans: n = !0,
236
- includeAvailableQuantity: r = !0,
236
+ includeAvailableQuantity: i = !0,
237
237
  useExternalMetafieldNamespace: o = !1,
238
- batchSize: i = 250,
239
- onBatchError: m
238
+ batchSize: r = 250,
239
+ onBatchError: m,
240
+ variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
240
241
  }) => {
241
- if (!l.length)
242
+ if (!a.length)
242
243
  return [];
243
- const d = l.map((c) => typeof c == "string" && c.startsWith("gid://") ? c : `gid://shopify/Product/${c}`), u = w({ country: e, language: s }), y = `
244
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${u} {
244
+ const u = a.map((p) => typeof p == "string" && p.startsWith("gid://") ? p : `gid://shopify/Product/${p}`), h = w({ country: t, language: s }), g = `
245
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
245
246
  shop {
246
247
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
247
248
  value
@@ -275,7 +276,7 @@ const U = (t, e) => {
275
276
  }
276
277
  variants(first: 250) {
277
278
  nodes {
278
- ${j}
279
+ ${U}
279
280
  }
280
281
  }
281
282
  collections(first: 50) {
@@ -327,84 +328,90 @@ const U = (t, e) => {
327
328
  }
328
329
  }
329
330
  }
330
- `, h = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(i, 250);
331
- for (let c = 0; c < d.length; c += v)
332
- f.push(d.slice(c, c + v));
333
- let a = 1;
334
- const p = async (c) => {
335
- const b = await t.query(y, {
331
+ `, f = o ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = [], l = Math.min(r, 250);
332
+ for (let p = 0; p < u.length; p += l)
333
+ v.push(u.slice(p, p + l));
334
+ let d = 1;
335
+ const y = async (p) => {
336
+ const b = await e.query(g, {
336
337
  variables: {
337
- productGIDs: c,
338
+ productGIDs: p,
338
339
  includeSellingPlans: n,
339
- includeAvailableQuantity: r,
340
- metafieldNamespace: h
340
+ includeAvailableQuantity: i,
341
+ metafieldNamespace: f,
342
+ variantImageTransform: c
341
343
  }
342
344
  });
343
- return b.shop.currencyRateConstant && (a = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
345
+ return b.shop.currencyRateConstant && (d = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
344
346
  };
345
- let g;
347
+ let _;
346
348
  if (m) {
347
- const c = await Promise.allSettled(f.map(p));
348
- for (const b of c)
349
+ const p = await Promise.allSettled(v.map(y));
350
+ for (const b of p)
349
351
  b.status === "rejected" && m(
350
352
  b.reason instanceof Error ? b.reason : new Error(String(b.reason))
351
353
  );
352
- g = c.filter(
354
+ _ = p.filter(
353
355
  (b) => b.status === "fulfilled"
354
356
  ).flatMap((b) => b.value.nodes);
355
357
  } else
356
- g = (await Promise.all(f.map(p))).flatMap((c) => c.nodes);
357
- const _ = g.filter((c) => c != null);
358
+ _ = (await Promise.all(v.map(y))).flatMap((p) => p.nodes);
359
+ const I = _.filter((p) => p != null);
358
360
  if (m) {
359
- const c = await Promise.allSettled(
360
- _.map(async (I) => {
361
- const P = await G(
362
- t,
363
- I,
364
- { includeSellingPlans: n, includeAvailableQuantity: r },
365
- u
366
- );
367
- return B(
361
+ const p = await Promise.allSettled(
362
+ I.map(async (P) => {
363
+ const V = await G(
364
+ e,
368
365
  P,
369
- t.shopifyDomain,
370
- a
366
+ {
367
+ includeSellingPlans: n,
368
+ includeAvailableQuantity: i,
369
+ variantImageTransform: c
370
+ },
371
+ h
372
+ );
373
+ return T(
374
+ V,
375
+ e.shopifyDomain,
376
+ d
371
377
  );
372
378
  })
373
379
  ), b = [];
374
- for (const I of c)
375
- I.status === "fulfilled" ? b.push(I.value) : m(
376
- I.reason instanceof Error ? I.reason : new Error(String(I.reason))
380
+ for (const P of p)
381
+ P.status === "fulfilled" ? b.push(P.value) : m(
382
+ P.reason instanceof Error ? P.reason : new Error(String(P.reason))
377
383
  );
378
384
  return b;
379
385
  }
380
386
  return (await Promise.all(
381
- _.map(
382
- (c) => G(
383
- t,
384
- c,
387
+ I.map(
388
+ (p) => G(
389
+ e,
390
+ p,
385
391
  {
386
392
  includeSellingPlans: n,
387
- includeAvailableQuantity: r
393
+ includeAvailableQuantity: i,
394
+ variantImageTransform: c
388
395
  },
389
- u
396
+ h
390
397
  )
391
398
  )
392
399
  )).map(
393
- (c) => B(c, t.shopifyDomain, a)
400
+ (p) => T(p, e.shopifyDomain, d)
394
401
  );
395
- }, G = async (t, e, s, l = "") => {
396
- if (e.variants.nodes.length < 250)
397
- return e;
398
- const n = /* @__PURE__ */ new Set(), r = [], o = [], i = async (m) => {
399
- let d = !0, u = null;
400
- for (; d; ) {
401
- const y = await t.query(
402
+ }, G = async (e, t, s, a = "") => {
403
+ if (t.variants.nodes.length < 250)
404
+ return t;
405
+ const n = /* @__PURE__ */ new Set(), i = [], o = [], r = async (m) => {
406
+ let c = !0, u = null;
407
+ for (; c; ) {
408
+ const h = await e.query(
402
409
  `
403
- query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!) ${l} {
410
+ query($productGID: ID!, $cursor: String, $reverse: Boolean, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $variantImageTransform: ImageTransformInput) ${a} {
404
411
  product(id: $productGID) {
405
412
  variants(first: 250, after: $cursor, reverse: $reverse) {
406
413
  nodes {
407
- ${j}
414
+ ${U}
408
415
  }
409
416
  pageInfo {
410
417
  endCursor
@@ -416,164 +423,164 @@ const U = (t, e) => {
416
423
  `,
417
424
  {
418
425
  variables: {
419
- productGID: e.id,
426
+ productGID: t.id,
420
427
  cursor: u,
421
428
  reverse: m,
422
429
  ...s
423
430
  }
424
431
  }
425
- ), { nodes: h, pageInfo: f } = y.product.variants;
426
- for (const v of h) {
432
+ ), { nodes: g, pageInfo: f } = h.product.variants;
433
+ for (const v of g) {
427
434
  if (n.has(v.id)) {
428
- d = !1;
435
+ c = !1;
429
436
  break;
430
437
  }
431
- n.add(v.id), m ? o.push(v) : r.push(v);
438
+ n.add(v.id), m ? o.push(v) : i.push(v);
432
439
  }
433
- f.hasNextPage || (d = !1), u = f.endCursor;
440
+ f.hasNextPage || (c = !1), u = f.endCursor;
434
441
  }
435
442
  };
436
443
  return await Promise.all([
437
- i(!1),
438
- i(!0)
439
- ]), e.variants.nodes = [...r, ...o.reverse()], e;
440
- }, B = (t, e, s) => {
441
- var d, u, y, h, f, v;
442
- const l = t.variants.nodes.map(
443
- ({ unitPriceMeasurement: a, ...p }) => {
444
- var g, _;
444
+ r(!1),
445
+ r(!0)
446
+ ]), t.variants.nodes = [...i, ...o.reverse()], t;
447
+ }, T = (e, t, s) => {
448
+ var c, u, h, g, f, v;
449
+ const a = e.variants.nodes.map(
450
+ ({ unitPriceMeasurement: l, ...d }) => {
451
+ var y, _;
445
452
  return {
446
- id: Number(p.id.split("/").pop()),
447
- availableForSale: p.availableForSale,
448
- price: Math.round(Number(p.price.amount) * 100),
449
- compareAtPrice: p.compareAtPrice ? Math.round(Number(p.compareAtPrice.amount) * 100) : null,
450
- options: p.selectedOptions.map((c) => c.value),
451
- imageId: p.image ? Number(p.image.id.split("/").pop()) : null,
452
- image: ((g = p.image) == null ? void 0 : g.url) || null,
453
- sellingPlans: ((_ = p.sellingPlanAllocations) == null ? void 0 : _.nodes.map((c) => ({
454
- id: Number(c.sellingPlan.id.split("/").pop()),
455
- price: c.priceAdjustments.length > 0 ? Math.round(Number(c.priceAdjustments[0].price.amount) * 100) : Math.round(Number(p.price.amount) * 100),
456
- compareAtPrice: c.priceAdjustments.length > 0 ? Math.round(
457
- Number(c.priceAdjustments[0].compareAtPrice.amount) * 100
458
- ) : Math.round(Number(p.price.amount) * 100),
459
- perDeliveryPrice: c.priceAdjustments.length > 0 ? Math.round(
460
- Number(c.priceAdjustments[0].perDeliveryPrice.amount) * 100
461
- ) : Math.round(Number(p.price.amount) * 100)
453
+ id: Number(d.id.split("/").pop()),
454
+ availableForSale: d.availableForSale,
455
+ price: Math.round(Number(d.price.amount) * 100),
456
+ compareAtPrice: d.compareAtPrice ? Math.round(Number(d.compareAtPrice.amount) * 100) : null,
457
+ options: d.selectedOptions.map((I) => I.value),
458
+ imageId: d.image ? Number(d.image.id.split("/").pop()) : null,
459
+ image: ((y = d.image) == null ? void 0 : y.url) || null,
460
+ sellingPlans: ((_ = d.sellingPlanAllocations) == null ? void 0 : _.nodes.map((I) => ({
461
+ id: Number(I.sellingPlan.id.split("/").pop()),
462
+ price: I.priceAdjustments.length > 0 ? Math.round(Number(I.priceAdjustments[0].price.amount) * 100) : Math.round(Number(d.price.amount) * 100),
463
+ compareAtPrice: I.priceAdjustments.length > 0 ? Math.round(
464
+ Number(I.priceAdjustments[0].compareAtPrice.amount) * 100
465
+ ) : Math.round(Number(d.price.amount) * 100),
466
+ perDeliveryPrice: I.priceAdjustments.length > 0 ? Math.round(
467
+ Number(I.priceAdjustments[0].perDeliveryPrice.amount) * 100
468
+ ) : Math.round(Number(d.price.amount) * 100)
462
469
  }))) || [],
463
470
  inventoryManagement: null,
464
471
  // Storefront API does not return inventory management, only available in liquid
465
472
  inventoryPolicy: null,
466
473
  // Storefront API does not return inventory policy, only available in liquid
467
- inventoryQuantity: p.quantityAvailable ?? null,
468
- unitPriceMeasurement: a != null && a.quantityUnit && (a != null && a.referenceUnit) ? {
469
- quantityValue: a.quantityValue,
470
- quantityUnit: a.quantityUnit.toLowerCase(),
471
- referenceValue: a.referenceValue,
472
- referenceUnit: a.referenceUnit.toLowerCase()
474
+ inventoryQuantity: d.quantityAvailable ?? null,
475
+ unitPriceMeasurement: l != null && l.quantityUnit && (l != null && l.referenceUnit) ? {
476
+ quantityValue: l.quantityValue,
477
+ quantityUnit: l.quantityUnit.toLowerCase(),
478
+ referenceValue: l.referenceValue,
479
+ referenceUnit: l.referenceUnit.toLowerCase()
473
480
  } : null
474
481
  };
475
482
  }
476
- ), n = t.options.map((a, p) => {
477
- const g = a.optionValues.map((_) => {
478
- var c, b, I, P;
483
+ ), n = e.options.map((l, d) => {
484
+ const y = l.optionValues.map((_) => {
485
+ var I, p, b, P;
479
486
  return {
480
487
  id: Number(_.id.split("/").pop()),
481
488
  defaultName: _.name,
482
489
  name: _.name,
483
490
  swatch: {
484
- color: ((c = _.swatch) == null ? void 0 : c.color) || null,
485
- image: ((P = (I = (b = _.swatch) == null ? void 0 : b.image) == null ? void 0 : I.previewImage) == null ? void 0 : P.url) || null
491
+ color: ((I = _.swatch) == null ? void 0 : I.color) || null,
492
+ image: ((P = (b = (p = _.swatch) == null ? void 0 : p.image) == null ? void 0 : b.previewImage) == null ? void 0 : P.url) || null
486
493
  }
487
494
  };
488
495
  });
489
496
  return {
490
- defaultName: a.name,
491
- name: a.name,
492
- position: p + 1,
493
- optionValues: H(g, p, l)
497
+ defaultName: l.name,
498
+ name: l.name,
499
+ position: d + 1,
500
+ optionValues: K(y, d, a)
494
501
  };
495
- }), r = (a) => {
496
- const p = a.priceAdjustments[0];
497
- if (!p)
502
+ }), i = (l) => {
503
+ const d = l.priceAdjustments[0];
504
+ if (!d)
498
505
  return null;
499
- const g = p.adjustmentValue;
500
- switch (g.__typename) {
506
+ const y = d.adjustmentValue;
507
+ switch (y.__typename) {
501
508
  case "SellingPlanPercentagePriceAdjustment":
502
509
  return {
503
510
  type: "percentage",
504
- value: g.adjustmentPercentage
511
+ value: y.adjustmentPercentage
505
512
  };
506
513
  case "SellingPlanFixedAmountPriceAdjustment":
507
514
  return {
508
515
  type: "fixed_amount",
509
- value: o(g.adjustmentAmount.amount)
516
+ value: o(y.adjustmentAmount.amount)
510
517
  };
511
518
  case "SellingPlanFixedPriceAdjustment":
512
519
  return {
513
520
  type: "price",
514
- value: o(g.price.amount)
521
+ value: o(y.price.amount)
515
522
  };
516
523
  default:
517
524
  throw new Error(
518
- `Unknown price adjustment type: ${g.__typename}`
525
+ `Unknown price adjustment type: ${y.__typename}`
519
526
  );
520
527
  }
521
- }, o = (a) => s === 1 ? Number(a) * 100 : Math.round(Number(a) * 100 * s), i = ((d = t.sellingPlanGroups) == null ? void 0 : d.nodes.flatMap(
522
- (a) => a.sellingPlans.nodes.map((p) => ({
523
- id: Number(p.id.split("/").pop()),
524
- name: p.name,
525
- priceAdjustment: r(p)
528
+ }, o = (l) => s === 1 ? Number(l) * 100 : Math.round(Number(l) * 100 * s), r = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
529
+ (l) => l.sellingPlans.nodes.map((d) => ({
530
+ id: Number(d.id.split("/").pop()),
531
+ name: d.name,
532
+ priceAdjustment: i(d)
526
533
  }))
527
- )) || [], m = t.variants.nodes.some(
528
- (a) => a.requiresComponents
534
+ )) || [], m = e.variants.nodes.some(
535
+ (l) => l.requiresComponents
529
536
  );
530
537
  return {
531
- id: Number(t.id.split("/").pop()),
532
- handle: t.handle,
533
- url: t.onlineStoreUrl || `https://${e}/products/${t.handle}`,
534
- availableForSale: t.availableForSale,
535
- createdAt: t.createdAt,
536
- title: t.title,
537
- image: ((u = t.featuredImage) == null ? void 0 : u.url) || null,
538
- collectionIds: t.collections.nodes.map(
539
- (a) => Number(a.id.split("/").pop())
538
+ id: Number(e.id.split("/").pop()),
539
+ handle: e.handle,
540
+ url: e.onlineStoreUrl || `https://${t}/products/${e.handle}`,
541
+ availableForSale: e.availableForSale,
542
+ createdAt: e.createdAt,
543
+ title: e.title,
544
+ image: ((u = e.featuredImage) == null ? void 0 : u.url) || null,
545
+ collectionIds: e.collections.nodes.map(
546
+ (l) => Number(l.id.split("/").pop())
540
547
  ),
541
548
  options: n,
542
549
  selectedVariantId: Number(
543
- t.variants.nodes[0].id.split("/").pop()
550
+ e.variants.nodes[0].id.split("/").pop()
544
551
  ),
545
- variants: l,
546
- requiresSellingPlan: t.requiresSellingPlan,
547
- sellingPlans: i,
552
+ variants: a,
553
+ requiresSellingPlan: e.requiresSellingPlan,
554
+ sellingPlans: r,
548
555
  isNativeBundle: m,
549
556
  metafields: {
550
- text: ((y = t.metafield) == null ? void 0 : y.value) || null,
551
- text2: ((h = t.metafield2) == null ? void 0 : h.value) || null,
552
- text3: ((f = t.metafield3) == null ? void 0 : f.value) || null,
553
- text4: ((v = t.metafield4) == null ? void 0 : v.value) || null
557
+ text: ((h = e.metafield) == null ? void 0 : h.value) || null,
558
+ text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
559
+ text3: ((f = e.metafield3) == null ? void 0 : f.value) || null,
560
+ text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
554
561
  }
555
562
  };
556
- }, H = (t, e, s) => t.filter((l) => s.filter(
557
- (n) => n.options[e] === l.name
558
- ).length > 0), T = "app--2935586817", X = async (t, {
559
- language: e,
563
+ }, K = (e, t, s) => e.filter((a) => s.filter(
564
+ (n) => n.options[t] === a.name
565
+ ).length > 0), B = "app--2935586817", Y = async (e, {
566
+ language: t,
560
567
  country: s,
561
- useExternalMetafieldNamespace: l
568
+ useExternalMetafieldNamespace: a
562
569
  }) => {
563
- const n = `${T}--kaching_bundles`, r = T, o = w({ country: s }), {
570
+ const n = `${B}--kaching_bundles`, i = B, o = w({ country: s }), {
564
571
  localization: {
565
572
  country: {
566
- currency: { isoCode: i }
573
+ currency: { isoCode: r }
567
574
  }
568
575
  },
569
576
  shop: {
570
577
  moneyFormat: m,
571
- paymentSettings: { currencyCode: d },
578
+ paymentSettings: { currencyCode: c },
572
579
  currencyRateConstant: u,
573
- primaryDomain: y,
574
- settingsMetafield: h
580
+ primaryDomain: h,
581
+ settingsMetafield: g
575
582
  }
576
- } = await t.query(
583
+ } = await e.query(
577
584
  `
578
585
  query config($metafieldNamespace: String!, $settingsNamespace: String!) ${o} {
579
586
  localization {
@@ -603,29 +610,29 @@ const U = (t, e) => {
603
610
  {
604
611
  variables: {
605
612
  metafieldNamespace: n,
606
- settingsNamespace: r
613
+ settingsNamespace: i
607
614
  }
608
615
  }
609
- ), f = i === d ? m : L(i, { language: e, country: s }), v = u ? W(u.value) : 1, a = h ? JSON.parse(h.value) : null, p = (a == null ? void 0 : a.feature_flags) ?? {}, g = (a == null ? void 0 : a.custom_selectors) ?? {};
616
+ ), f = r === c ? m : z(r, { language: t, country: s }), v = u ? Z(u.value) : 1, l = g ? JSON.parse(g.value) : null, d = (l == null ? void 0 : l.feature_flags) ?? {}, y = (l == null ? void 0 : l.custom_selectors) ?? {};
610
617
  return {
611
- shopifyDomain: y.host,
618
+ shopifyDomain: h.host,
612
619
  moneyFormat: f,
613
- locale: (e == null ? void 0 : e.toLowerCase()) || "en",
614
- liquidLocale: (e == null ? void 0 : e.toLowerCase()) || "en",
620
+ locale: (t == null ? void 0 : t.toLowerCase()) || "en",
621
+ liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
615
622
  country: s ?? "US",
616
623
  currencyRate: v,
617
624
  marketId: 0,
618
625
  productId: null,
619
- storefrontAccessToken: (a == null ? void 0 : a.storefront_access_token) ?? null,
620
- includeSellingPlans: (a == null ? void 0 : a.include_selling_plans) ?? !1,
621
- includeAvailableQuantity: (a == null ? void 0 : a.include_available_quantity) ?? !1,
622
- customApiHost: (a == null ? void 0 : a.custom_api_host) ?? null,
623
- keepQuantityInput: (a == null ? void 0 : a.keep_quantity_input) ?? !1,
624
- ignoreDeselect: (a == null ? void 0 : a.ignore_deselect) ?? !1,
625
- ignoreUnitPrice: (a == null ? void 0 : a.ignore_unit_price) ?? !1,
626
- requireCustomerLogin: (a == null ? void 0 : a.require_customer_login) ?? !1,
627
- abTestsRunning: (a == null ? void 0 : a.ab_tests_running) ?? !1,
628
- webPixel: (a == null ? void 0 : a.web_pixel) ?? !1,
626
+ storefrontAccessToken: (l == null ? void 0 : l.storefront_access_token) ?? null,
627
+ includeSellingPlans: (l == null ? void 0 : l.include_selling_plans) ?? !1,
628
+ includeAvailableQuantity: (l == null ? void 0 : l.include_available_quantity) ?? !1,
629
+ customApiHost: (l == null ? void 0 : l.custom_api_host) ?? null,
630
+ keepQuantityInput: (l == null ? void 0 : l.keep_quantity_input) ?? !1,
631
+ ignoreDeselect: (l == null ? void 0 : l.ignore_deselect) ?? !1,
632
+ ignoreUnitPrice: (l == null ? void 0 : l.ignore_unit_price) ?? !1,
633
+ requireCustomerLogin: (l == null ? void 0 : l.require_customer_login) ?? !1,
634
+ abTestsRunning: (l == null ? void 0 : l.ab_tests_running) ?? !1,
635
+ webPixel: (l == null ? void 0 : l.web_pixel) ?? !1,
629
636
  b2bCustomer: !1,
630
637
  isLoggedIn: !1,
631
638
  preview: !1,
@@ -657,303 +664,374 @@ const U = (t, e) => {
657
664
  "system.numbers_only": "Only numbers are allowed."
658
665
  },
659
666
  customSelectors: {
660
- quantity: g.quantity ?? null,
661
- addToCartButton: g.add_to_cart_button ?? null,
662
- variantPicker: g.variant_picker ?? null,
663
- price: g.price ?? null,
664
- priceCompare: g.price_compare ?? null
667
+ quantity: y.quantity ?? null,
668
+ addToCartButton: y.add_to_cart_button ?? null,
669
+ variantPicker: y.variant_picker ?? null,
670
+ price: y.price ?? null,
671
+ priceCompare: y.price_compare ?? null
665
672
  },
666
- shopCustomStyles: (a == null ? void 0 : a.shop_custom_styles) ?? "",
667
- featureFlags: p,
668
- brandColors: (a == null ? void 0 : a.brand_colors) ?? null
673
+ shopCustomStyles: (l == null ? void 0 : l.shop_custom_styles) ?? "",
674
+ featureFlags: d,
675
+ brandColors: (l == null ? void 0 : l.brand_colors) ?? null
669
676
  };
670
- }, W = (t) => JSON.parse(t).amount / 1e6, K = async (t, e, s = 200) => (e = e.filter(Boolean).filter((l) => !l.startsWith("placeholder")), e.length === 0 ? [] : (await t.query(
671
- `
672
- query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
673
- nodes(ids: $mediaImageIds) {
674
- ... on MediaImage {
675
- id
676
- image {
677
- url(transform: { maxWidth: $size, maxHeight: $size })
677
+ }, Z = (e) => JSON.parse(e).amount / 1e6, ee = async (e, t, s = 200) => {
678
+ const a = [
679
+ ...new Set(
680
+ t.filter(Boolean).filter((i) => !i.startsWith("placeholder"))
681
+ )
682
+ ];
683
+ if (a.length === 0) return [];
684
+ const n = [];
685
+ for (let i = 0; i < a.length; i += 250)
686
+ n.push(a.slice(i, i + 250));
687
+ return (await Promise.all(
688
+ n.map(
689
+ (i) => e.query(
690
+ `
691
+ query FetchMediaImages($mediaImageIds: [ID!]!, $size: Int!) {
692
+ nodes(ids: $mediaImageIds) {
693
+ ... on MediaImage {
694
+ id
695
+ image {
696
+ url(transform: { maxWidth: $size, maxHeight: $size })
697
+ }
698
+ }
678
699
  }
679
700
  }
701
+ `,
702
+ {
703
+ variables: {
704
+ mediaImageIds: i,
705
+ size: s
706
+ }
680
707
  }
681
- }
682
- `,
683
- {
684
- variables: {
685
- mediaImageIds: e,
686
- size: s
687
- }
688
- }
689
- )).nodes.filter(Boolean).map((l) => ({
690
- gid: l.id,
691
- url: l.image.url
692
- })));
693
- var S = /* @__PURE__ */ ((t) => (t.QuantityBreak = "quantity-break", t.Bxgy = "bxgy", t.Bundle = "bundle", t.MixAndMatch = "mix-and-match", t.Sku = "sku", t))(S || {});
694
- const Y = (t) => [
695
- ...Z(t),
696
- ...ee(t),
697
- ...te(t),
698
- ...se(t),
699
- ...ae(t),
700
- ...ne(t),
701
- ...le(t),
702
- ...ie(t),
703
- ...re(t),
704
- ...oe(t),
705
- ...ce(t),
706
- ...ue(t),
707
- ...de(t)
708
- ].filter((e) => e != null && !e.includes("placeholder")), Z = (t) => t.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ee = (t) => t.dealBars.flatMap(
709
- (e) => e.dealBarType === S.Bundle ? e.bundleProducts.map(
708
+ )
709
+ )
710
+ )).flatMap((i) => i.nodes).flatMap(
711
+ (i) => i != null && i.image ? [{ gid: i.id, url: i.image.url }] : []
712
+ );
713
+ };
714
+ var S = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(S || {});
715
+ const te = (e) => [
716
+ ...se(e),
717
+ ...ae(e),
718
+ ...ne(e),
719
+ ...le(e),
720
+ ...re(e),
721
+ ...ie(e),
722
+ ...oe(e),
723
+ ...ce(e),
724
+ ...ue(e),
725
+ ...de(e),
726
+ ...me(e),
727
+ ...pe(e),
728
+ ...fe(e)
729
+ ].filter((t) => t != null && !t.includes("placeholder")), se = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.flatMap(
730
+ (t) => t.dealBarType === S.Bundle ? t.bundleProducts.map(
710
731
  (s) => s.mediaImageGID
711
732
  ) : []
712
- ).filter((e) => e != null), te = (t) => t.dealBars.map(
713
- ({ freeGifts: e }) => (e || []).map((s) => s.mediaImageGID)
714
- ).reduce((e, s) => e.concat(s), []).filter((e) => e != null), se = (t) => t.dealBars.flatMap(
715
- ({ multipleGiftsSelectors: e }) => (e || []).map((s) => s.mediaImageGID)
716
- ).filter((e) => e != null), ae = (t) => t.dealBars.map(({ upsells: e }) => (e || []).map((s) => s.mediaImageGID)).reduce((e, s) => e.concat(s), []).filter((e) => e != null), ne = (t) => t.swatchOptions ? t.swatchOptions.reduce((e, s) => {
717
- const l = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
718
- return [...e, ...l];
719
- }, []) : [], le = (t) => {
720
- if (!t.collectionBreaksEnabled || !t.collectionBreaks)
733
+ ).filter((t) => t != null), ne = (e) => e.dealBars.map(
734
+ ({ freeGifts: t }) => (t || []).map((s) => s.mediaImageGID)
735
+ ).reduce((t, s) => t.concat(s), []).filter((t) => t != null), le = (e) => e.dealBars.flatMap(
736
+ ({ multipleGiftsSelectors: t }) => (t || []).map((s) => s.mediaImageGID)
737
+ ).filter((t) => t != null), re = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((s) => s.mediaImageGID)).reduce((t, s) => t.concat(s), []).filter((t) => t != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, s) => {
738
+ const a = s.images.map((n) => n.mediaImageGID).filter((n) => n != null);
739
+ return [...t, ...a];
740
+ }, []) : [], oe = (e) => {
741
+ if (!e.collectionBreaksEnabled || !e.collectionBreaks)
721
742
  return [];
722
- const e = t.collectionBreaks.mediaImageGID;
723
- return e ? [e] : [];
724
- }, ie = (t) => {
725
- var e, s, l;
726
- return t.progressiveGifts ? [
727
- ...((e = t.progressiveGifts.gifts) == null ? void 0 : e.map((n) => n.mediaImageGID)) || [],
728
- (s = t.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
729
- (l = t.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
743
+ const t = e.collectionBreaks.mediaImageGID;
744
+ return t ? [t] : [];
745
+ }, ce = (e) => {
746
+ var t, s, a;
747
+ return e.progressiveGifts ? [
748
+ ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
749
+ (s = e.progressiveGifts.style) == null ? void 0 : s.lockedMediaImageGID,
750
+ (a = e.progressiveGifts.dealBarStyle) == null ? void 0 : a.lockedMediaImageGID
730
751
  ].filter((n) => n != null) : [];
731
- }, re = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), oe = (t) => t.dealBars.map((e) => {
752
+ }, ue = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), de = (e) => e.dealBars.map((t) => {
732
753
  var s;
733
- return (s = e.productPersonalisation) == null ? void 0 : s.mediaImageGID;
734
- }).filter((e) => e != null), ce = (t) => {
735
- var l, n;
736
- const e = t.dealBars.map((r) => {
754
+ return (s = t.productPersonalisation) == null ? void 0 : s.mediaImageGID;
755
+ }).filter((t) => t != null), me = (e) => {
756
+ var a, n;
757
+ const t = e.dealBars.map((i) => {
737
758
  var o;
738
- return (o = r.highlights) == null ? void 0 : o.customIconGID;
739
- }).filter((r) => r != null), s = (n = (l = t.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : n.customIconGID;
740
- return s ? [...e, s] : e;
741
- }, ue = (t) => (t.badges || []).flatMap(
742
- (e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []
743
- ), de = (t) => !t.savingsSummaryEnabled || !t.savingsSummary ? [] : t.savingsSummary.customIconGID ? [t.savingsSummary.customIconGID] : [], me = (t) => {
744
- const e = [
745
- ...pe(t),
746
- ...fe(t),
747
- ...he(t),
748
- ...ge(t),
749
- ...ye(t),
750
- ...be(t),
751
- ...ve(t),
752
- ..._e(t)
759
+ return (o = i.highlights) == null ? void 0 : o.customIconGID;
760
+ }).filter((i) => i != null), s = (n = (a = e.subscriptions) == null ? void 0 : a.highlights) == null ? void 0 : n.customIconGID;
761
+ return s ? [...t, s] : t;
762
+ }, pe = (e) => (e.badges || []).flatMap(
763
+ (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
764
+ ), fe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], he = (e) => {
765
+ const t = [
766
+ ...ge(e),
767
+ ...ye(e),
768
+ ...be(e),
769
+ ...ve(e),
770
+ ...Ie(e),
771
+ ..._e(e),
772
+ ...Pe(e),
773
+ ...Se(e)
753
774
  ];
754
- return Array.from(new Set(e.filter((s) => s != null)));
755
- }, pe = (t) => t.dealBars.flatMap(
756
- ({ freeGifts: e }) => e ? e.map((s) => s.productGID) : []
757
- ).filter((e) => e != null), fe = (t) => t.dealBars.flatMap(
758
- ({ multipleGiftsSelectors: e }) => e ? e.flatMap(
759
- (s) => s.products ? s.products.map((l) => l.id) : []
775
+ return Array.from(new Set(t.filter((s) => s != null)));
776
+ }, ge = (e) => e.dealBars.flatMap(
777
+ ({ freeGifts: t }) => t ? t.map((s) => s.productGID) : []
778
+ ).filter((t) => t != null), ye = (e) => e.dealBars.flatMap(
779
+ ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
780
+ (s) => s.products ? s.products.map((a) => a.id) : []
760
781
  ) : []
761
- ).filter((e) => e != null), he = (t) => {
762
- var e;
763
- return t.progressiveGiftsEnabled ? ((e = t.progressiveGifts) == null ? void 0 : e.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
764
- }, ge = (t) => t.dealBars.flatMap(({ upsells: e }) => e ? e.map((s) => s.productGID) : []).filter((e) => e != null), ye = (t) => t.dealBars.filter((e) => e.dealBarType === S.Bundle).flatMap(
765
- ({ bundleProducts: e }) => e ? e.map((s) => s.productGID) : []
766
- ).filter((e) => e != null).filter((e) => e !== "default"), be = (t) => t.dealBars.filter((e) => e.dealBarType === S.MixAndMatch).flatMap(
767
- ({ bundleProducts: e }) => e ? e.flatMap((s) => {
768
- var l;
782
+ ).filter((t) => t != null), be = (e) => {
783
+ var t;
784
+ return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((s) => s.productGID).filter((s) => s != null)) || [] : [];
785
+ }, ve = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((s) => s.productGID) : []).filter((t) => t != null), Ie = (e) => e.dealBars.filter((t) => t.dealBarType === S.Bundle).flatMap(
786
+ ({ bundleProducts: t }) => t ? t.map((s) => s.productGID) : []
787
+ ).filter((t) => t != null).filter((t) => t !== "default"), _e = (e) => e.dealBars.filter((t) => t.dealBarType === S.MixAndMatch).flatMap(
788
+ ({ bundleProducts: t }) => t ? t.flatMap((s) => {
789
+ var a;
769
790
  return [
770
791
  s.productGID,
771
- ...((l = s.selectedProducts) == null ? void 0 : l.map((n) => n.id)) ?? []
792
+ ...((a = s.selectedProducts) == null ? void 0 : a.map((n) => n.id)) ?? []
772
793
  ];
773
794
  }) : []
774
- ).filter((e) => e != null).filter((e) => e !== "default"), ve = (t) => !t.checkboxUpsellsEnabled || !t.checkboxUpsells ? [] : t.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), _e = (t) => t.dealBars.filter((e) => e.dealBarType === S.Sku).flatMap(({ productGID: e }) => e ? [e] : []);
775
- class Ie {
776
- constructor(e, s) {
777
- this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = e;
795
+ ).filter((t) => t != null).filter((t) => t !== "default"), Pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), Se = (e) => e.dealBars.filter((t) => t.dealBarType === S.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
796
+ class M extends Error {
797
+ constructor({
798
+ status: t,
799
+ operationName: s,
800
+ graphqlErrors: a
801
+ }) {
802
+ const n = a.length ? `: ${a.join("; ")}` : "";
803
+ super(
804
+ `Storefront API ${s ?? "query"} failed (HTTP ${t})${n}`
805
+ ), this.name = "StorefrontApiError", this.status = t, this.operationName = s, this.graphqlErrors = a;
806
+ }
807
+ }
808
+ const ke = async (e, t) => {
809
+ const s = await e.text();
810
+ if (!s)
811
+ throw new Error("Empty graphql response");
812
+ let a;
813
+ try {
814
+ a = JSON.parse(s);
815
+ } catch (n) {
816
+ throw e.ok ? n : new M({
817
+ status: e.status,
818
+ operationName: t,
819
+ graphqlErrors: []
820
+ });
778
821
  }
779
- async query(e, s) {
780
- var i;
781
- const l = (s == null ? void 0 : s.variables) ?? {};
822
+ if (!e.ok || a.data === null || a.data === void 0)
823
+ throw new M({
824
+ status: e.status,
825
+ operationName: t,
826
+ graphqlErrors: (a.errors ?? []).map(({ message: n }) => n).filter(Boolean)
827
+ });
828
+ return a.data;
829
+ };
830
+ class we {
831
+ constructor(t, s) {
832
+ this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = s, this.shopifyDomain = t;
833
+ }
834
+ async query(t, s) {
835
+ var r;
836
+ const a = (s == null ? void 0 : s.variables) ?? {};
782
837
  let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
- const r = (i = e.match(/query\s+(\w+)/)) == null ? void 0 : i[1];
784
- r && (n += `?operation_name=${r}`);
785
- const o = await (await fetch(n, {
838
+ const i = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
839
+ i && (n += `?operation_name=${i}`);
840
+ const o = await fetch(n, {
786
841
  method: "POST",
787
842
  headers: {
788
843
  "Content-Type": "application/json",
789
844
  "X-Shopify-Storefront-Access-Token": this.storefrontAccessToken
790
845
  },
791
846
  body: JSON.stringify({
792
- query: e,
793
- variables: l
847
+ query: t,
848
+ variables: a
794
849
  })
795
- })).text();
796
- if (!o)
797
- throw new Error("Empty graphql response");
798
- return JSON.parse(o).data;
850
+ });
851
+ return ke(o, i);
799
852
  }
800
853
  }
801
- const Pe = async (t, e, { country: s, language: l }) => {
802
- const n = e.collectionBreaks;
803
- if (!e.collectionBreaksEnabled || !n) return;
804
- let r;
805
- n.visibility === "deal-products" ? r = await N(t, {
854
+ const Ee = async (e, t, { country: s, language: a }) => {
855
+ const n = t.collectionBreaks;
856
+ if (!t.collectionBreaksEnabled || !n) return;
857
+ let i;
858
+ n.visibility === "deal-products" ? i = await N(e, {
806
859
  country: s,
807
- language: l,
808
- blockVisibility: e.blockVisibility,
809
- excludedProductGIDs: (e.excludedProductIds || []).map(
810
- (i) => `gid://shopify/Product/${i}`
860
+ language: a,
861
+ blockVisibility: t.blockVisibility,
862
+ excludedProductGIDs: (t.excludedProductIds || []).map(
863
+ (r) => `gid://shopify/Product/${r}`
811
864
  ),
812
- selectedProductGIDs: (e.selectedProductIds || []).map(
813
- (i) => `gid://shopify/Product/${i}`
865
+ selectedProductGIDs: (t.selectedProductIds || []).map(
866
+ (r) => `gid://shopify/Product/${r}`
814
867
  ),
815
- selectedCollectionGIDs: (e.selectedCollectionIds || []).map(
816
- (i) => `gid://shopify/Collection/${i}`
868
+ selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
869
+ (r) => `gid://shopify/Collection/${r}`
817
870
  )
818
- }) : r = await N(t, {
871
+ }) : i = await N(e, {
819
872
  country: s,
820
- language: l,
873
+ language: a,
821
874
  blockVisibility: n.visibility,
822
875
  excludedProductGIDs: (n.excludedProducts || []).map(
823
- ({ id: i }) => i
876
+ ({ id: r }) => r
824
877
  ),
825
878
  selectedProductGIDs: (n.selectedProducts || []).map(
826
- ({ id: i }) => i
879
+ ({ id: r }) => r
827
880
  ),
828
881
  selectedCollectionGIDs: (n.selectedCollections || []).map(
829
- ({ id: i }) => i
882
+ ({ id: r }) => r
830
883
  )
831
884
  });
832
- let o = await D(t, {
885
+ let o = await $(e, {
833
886
  country: s,
834
- language: l,
835
- productIds: r.map((i) => Number(i.split("/").pop())),
887
+ language: a,
888
+ productIds: i.map((r) => Number(r.split("/").pop())),
836
889
  useExternalMetafieldNamespace: !0
837
890
  });
838
891
  return o = o.filter(
839
- (i) => i.availableForSale
892
+ (r) => r.availableForSale
840
893
  ), o;
841
- }, Se = () => ({
842
- "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
843
- "system.invalid_variant": "Sorry, this is not currently available.",
844
- "system.unavailable_option_value": "Unavailable",
845
- "system.confirm": "Confirm",
846
- "system.cancel": "Cancel",
847
- "system.free": "FREE",
848
- "system.search": "Search",
849
- "system.quantity": "Quantity",
850
- "system.subscription_plan": "Subscription plan",
851
- "system.remove": "Remove",
852
- "system.sort_by": "Sort by",
853
- "system.sort_relevance": "Relevance",
854
- "system.sort_newest_first": "Newest first",
855
- "system.sort_price_low_to_high": "Price: Low → High",
856
- "system.sort_price_high_to_low": "Price: High → Low",
857
- "system.no_results_found": "No results found",
858
- "system.no_results_description": "We can't find any item matching your search.",
859
- "system.clear_search": "Clear search",
860
- "system.no_products_available": "No products available",
861
- "system.original_price": "Original price:",
862
- "system.price": "Price:",
863
- "system.letters_only": "Only letters are allowed.",
864
- "system.numbers_only": "Only numbers are allowed.",
865
- "system.personalisation_required_alert": "Please add personalisation for every item to continue."
866
- }), ke = "2026-07", we = async (t, {
867
- productId: e,
894
+ }, Ae = ({
895
+ language: e,
896
+ dealBlockId: t
897
+ }) => {
898
+ const s = {
899
+ "system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
900
+ "system.invalid_variant": "Sorry, this is not currently available.",
901
+ "system.unavailable_option_value": "Unavailable",
902
+ "system.confirm": "Confirm",
903
+ "system.cancel": "Cancel",
904
+ "system.free": "FREE",
905
+ "system.search": "Search",
906
+ "system.quantity": "Quantity",
907
+ "system.subscription_plan": "Subscription plan",
908
+ "system.remove": "Remove",
909
+ "system.sort_by": "Sort by",
910
+ "system.sort_relevance": "Relevance",
911
+ "system.sort_newest_first": "Newest first",
912
+ "system.sort_price_low_to_high": "Price: Low → High",
913
+ "system.sort_price_high_to_low": "Price: High → Low",
914
+ "system.no_results_found": "No results found",
915
+ "system.no_results_description": "We can't find any item matching your search.",
916
+ "system.clear_search": "Clear search",
917
+ "system.no_products_available": "No products available",
918
+ "system.original_price": "Original price:",
919
+ "system.price": "Price:",
920
+ "system.letters_only": "Only letters are allowed.",
921
+ "system.numbers_only": "Only numbers are allowed.",
922
+ "system.personalisation_required_alert": "Please add personalisation for every item to continue."
923
+ }, a = e ? $e(e) : void 0;
924
+ return {
925
+ ...s,
926
+ ...a == null ? void 0 : a.system,
927
+ ...a == null ? void 0 : a.dealBlocks[t]
928
+ };
929
+ }, $e = (e) => {
930
+ var n;
931
+ if (typeof document > "u") return;
932
+ const t = document.querySelector("script#kaching-bundles-translations");
933
+ if (!(t != null && t.textContent)) return;
934
+ let s;
935
+ try {
936
+ s = JSON.parse(t.textContent);
937
+ } catch {
938
+ return;
939
+ }
940
+ const a = q(e);
941
+ return (n = s.find(
942
+ (i) => q(i.locale) === a
943
+ )) == null ? void 0 : n.translations;
944
+ }, q = (e) => e.toLowerCase().replace(/_/g, "-"), De = "2026-07", xe = async (e, {
945
+ productId: t,
868
946
  dealBlockId: s,
869
- country: l = void 0,
947
+ country: a = void 0,
870
948
  language: n = void 0
871
949
  }) => {
872
- var r, o;
950
+ var i, o;
873
951
  try {
874
- const i = [Number(e.split("/").pop())], m = new Ee(t);
875
- l = l || ((r = m.i18n) == null ? void 0 : r.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
876
- const d = await X(m, {
952
+ const r = [Number(t.split("/").pop())], m = new Ce(e);
953
+ a = a || ((i = m.i18n) == null ? void 0 : i.country), n = n || ((o = m.i18n) == null ? void 0 : o.language);
954
+ const c = await Y(m, {
877
955
  language: n,
878
- country: l,
956
+ country: a,
879
957
  useExternalMetafieldNamespace: !0
880
958
  });
881
- m.shopifyDomain = d.shopifyDomain;
882
- const u = d.storefrontAccessToken ? new Ie(
883
- d.shopifyDomain,
884
- d.storefrontAccessToken
885
- ) : m, [y, h] = await Promise.all([
886
- D(u, {
887
- country: l,
959
+ m.shopifyDomain = c.shopifyDomain;
960
+ const u = c.storefrontAccessToken ? new we(
961
+ c.shopifyDomain,
962
+ c.storefrontAccessToken
963
+ ) : m, [h, g] = await Promise.all([
964
+ $(u, {
965
+ country: a,
888
966
  language: n,
889
- productIds: i,
967
+ productIds: r,
890
968
  useExternalMetafieldNamespace: !0
891
969
  }),
892
- z(u, {
970
+ H(u, {
893
971
  useExternalMetafieldNamespace: !0,
894
- useMetaobjects: d.featureFlags.storefront_metaobjects
972
+ useMetaobjects: c.featureFlags.storefront_metaobjects
895
973
  })
896
- ]), f = y[0];
974
+ ]), f = h[0];
897
975
  if (!f)
898
976
  return null;
899
- const v = U(h, f);
900
- let a;
901
- if (s ? (a = v.find(
977
+ const v = F(g, f);
978
+ let l;
979
+ if (s ? (l = v.find(
902
980
  (P) => P.id === s || P.nanoId === s
903
- ), a || (a = v[0])) : a = v[0], !a)
981
+ ), l || (l = v[0])) : l = v[0], !l)
904
982
  return null;
905
- const p = Y(a), g = me(a), [_, c, b, I] = await Promise.all([
906
- D(u, {
907
- country: l,
983
+ const d = te(l), y = he(l), [_, I, p, b] = await Promise.all([
984
+ $(u, {
985
+ country: a,
908
986
  language: n,
909
- productIds: g,
987
+ productIds: y,
910
988
  useExternalMetafieldNamespace: !0
911
989
  }),
912
- K(u, p, 300),
913
- Pe(u, a, {
914
- country: l,
990
+ ee(u, d, 300),
991
+ Ee(u, l, {
992
+ country: a,
915
993
  language: n
916
994
  }),
917
- Se()
995
+ Ae({ language: n, dealBlockId: l.id })
918
996
  ]);
919
997
  return {
920
998
  product: f,
921
- dealBlock: a,
922
- config: d,
999
+ dealBlock: l,
1000
+ config: c,
923
1001
  otherProducts: _,
924
- mediaImages: c,
925
- collectionBreaksProducts: b ?? [],
926
- translations: I
1002
+ mediaImages: I,
1003
+ collectionBreaksProducts: p ?? [],
1004
+ translations: b
927
1005
  };
928
- } catch (i) {
929
- return console.error(i), null;
1006
+ } catch (r) {
1007
+ return console.error(r), null;
930
1008
  }
931
1009
  };
932
- class Ee {
933
- constructor(e) {
934
- this.storefront = e, this.shopifyDomain = "";
1010
+ class Ce {
1011
+ constructor(t) {
1012
+ this.storefront = t, this.shopifyDomain = "";
935
1013
  }
936
- async query(e, s) {
937
- var l;
1014
+ async query(t, s) {
1015
+ var a;
938
1016
  if ("query" in this.storefront && "i18n" in this.storefront)
939
- return await this.storefront.query(e, s);
1017
+ return await this.storefront.query(t, s);
940
1018
  if ("graphql" in this.storefront) {
941
- const n = await this.storefront.graphql(e, s);
942
- if ((l = n.errors) != null && l.length)
1019
+ const n = await this.storefront.graphql(t, s);
1020
+ if ((a = n.errors) != null && a.length)
943
1021
  throw new Error(
944
- n.errors.map((r) => r.message).join(`
1022
+ n.errors.map((i) => i.message).join(`
945
1023
  `)
946
1024
  );
947
1025
  return n.data;
948
1026
  }
949
1027
  if ("request" in this.storefront)
950
- return (await this.storefront.request(e, s)).data;
1028
+ return (await this.storefront.request(t, s)).data;
951
1029
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
952
1030
  const n = await fetch(
953
- `https://${this.storefront.shopifyDomain}/api/${ke}/graphql.json`,
1031
+ `https://${this.storefront.shopifyDomain}/api/${De}/graphql.json`,
954
1032
  {
955
1033
  body: JSON.stringify({
956
- query: e,
1034
+ query: t,
957
1035
  variables: s == null ? void 0 : s.variables
958
1036
  }),
959
1037
  headers: {
@@ -969,7 +1047,7 @@ class Ee {
969
1047
  } else {
970
1048
  const n = await fetch(this.storefront.getStorefrontApiUrl(), {
971
1049
  body: JSON.stringify({
972
- query: e,
1050
+ query: t,
973
1051
  variables: s == null ? void 0 : s.variables
974
1052
  }),
975
1053
  headers: this.storefront.getPublicTokenHeaders(),
@@ -985,52 +1063,52 @@ class Ee {
985
1063
  return this.storefront.i18n;
986
1064
  }
987
1065
  }
988
- const E = "kaching-bundles-block", M = 1e4, Ae = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", De = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", A = /* @__PURE__ */ new WeakSet(), q = async (t) => {
989
- const e = t.document;
990
- if (!t.customElements.get(E)) {
991
- if (A.has(e))
992
- return $(t, E);
993
- A.add(e);
1066
+ const E = "kaching-bundles-block", O = 1e4, Ne = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ge = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", A = /* @__PURE__ */ new WeakSet(), j = async (e) => {
1067
+ const t = e.document;
1068
+ if (!e.customElements.get(E)) {
1069
+ if (A.has(t))
1070
+ return D(e, E);
1071
+ A.add(t);
994
1072
  try {
995
- await Ce(t);
1073
+ await Me(e);
996
1074
  } catch (s) {
997
- throw A.delete(e), s;
1075
+ throw A.delete(t), s;
998
1076
  }
999
1077
  }
1000
- }, $e = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", xe = () => $e() ? Ae : De, Ce = (t) => {
1001
- const e = t.document;
1002
- return new Promise((s, l) => {
1003
- const n = xe();
1004
- if (e.querySelector(
1078
+ }, Te = () => typeof window < "u" && typeof window.__KACHING_DEV__ < "u", Be = () => Te() ? Ne : Ge, Me = (e) => {
1079
+ const t = e.document;
1080
+ return new Promise((s, a) => {
1081
+ const n = Be();
1082
+ if (t.querySelector(
1005
1083
  `script[src="${n}"]`
1006
1084
  )) {
1007
- $(t, E).then(s).catch(l);
1085
+ D(e, E).then(s).catch(a);
1008
1086
  return;
1009
1087
  }
1010
- const o = e.createElement("script");
1011
- o.src = n, o.onload = () => $(t, E).then(s).catch(l), o.onerror = () => l(new Error("Failed to load script")), e.head.appendChild(o);
1088
+ const o = t.createElement("script");
1089
+ o.src = n, o.onload = () => D(e, E).then(s).catch(a), o.onerror = () => a(new Error("Failed to load script")), t.head.appendChild(o);
1012
1090
  });
1013
- }, $ = (t, e) => new Promise((s, l) => {
1014
- if (t.customElements.get(e)) {
1091
+ }, D = (e, t) => new Promise((s, a) => {
1092
+ if (e.customElements.get(t)) {
1015
1093
  s();
1016
1094
  return;
1017
1095
  }
1018
1096
  Promise.race([
1019
- t.customElements.whenDefined(e),
1097
+ e.customElements.whenDefined(t),
1020
1098
  new Promise(
1021
- (n, r) => setTimeout(
1022
- () => r(
1099
+ (n, i) => setTimeout(
1100
+ () => i(
1023
1101
  new Error(
1024
- `Custom element "${e}" failed to register within ${M}ms`
1102
+ `Custom element "${t}" failed to register within ${O}ms`
1025
1103
  )
1026
1104
  ),
1027
- M
1105
+ O
1028
1106
  )
1029
1107
  )
1030
- ]).then(() => s()).catch(l);
1108
+ ]).then(() => s()).catch(a);
1031
1109
  });
1032
- var k = /* @__PURE__ */ ((t) => (t.QuantityBreak = "quantity-break", t.Bxgy = "bxgy", t.Bundle = "bundle", t.MixAndMatch = "mix-and-match", t.Sku = "sku", t))(k || {});
1033
- const Ne = {
1110
+ var k = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))(k || {});
1111
+ const qe = {
1034
1112
  id: 1,
1035
1113
  handle: "example-product",
1036
1114
  url: null,
@@ -1060,7 +1138,7 @@ const Ne = {
1060
1138
  requiresSellingPlan: !1,
1061
1139
  sellingPlans: [],
1062
1140
  isNativeBundle: !1
1063
- }, Ge = {
1141
+ }, Oe = {
1064
1142
  id: "example",
1065
1143
  nanoId: "example",
1066
1144
  blockName: "Bundle",
@@ -1150,7 +1228,8 @@ const Ne = {
1150
1228
  productPersonalisation: null,
1151
1229
  highlights: null,
1152
1230
  sellingPlanEnabled: !1,
1153
- sellingPlanGid: null
1231
+ sellingPlanGid: null,
1232
+ subscriptionMode: "customer-choice"
1154
1233
  },
1155
1234
  {
1156
1235
  id: "duo",
@@ -1174,7 +1253,8 @@ const Ne = {
1174
1253
  productPersonalisation: null,
1175
1254
  highlights: null,
1176
1255
  sellingPlanEnabled: !1,
1177
- sellingPlanGid: null
1256
+ sellingPlanGid: null,
1257
+ subscriptionMode: "customer-choice"
1178
1258
  },
1179
1259
  {
1180
1260
  id: "trio",
@@ -1198,7 +1278,8 @@ const Ne = {
1198
1278
  productPersonalisation: null,
1199
1279
  highlights: null,
1200
1280
  sellingPlanEnabled: !1,
1201
- sellingPlanGid: null
1281
+ sellingPlanGid: null,
1282
+ subscriptionMode: "customer-choice"
1202
1283
  }
1203
1284
  ],
1204
1285
  badgesEnabled: !0,
@@ -1236,7 +1317,7 @@ const Ne = {
1236
1317
  customStyles: "",
1237
1318
  lowStockAlertEnabled: !1,
1238
1319
  lowStockAlert: null
1239
- }, Be = {
1320
+ }, je = {
1240
1321
  shopifyDomain: "",
1241
1322
  moneyFormat: "${{amount}}",
1242
1323
  locale: "en",
@@ -1293,16 +1374,16 @@ const Ne = {
1293
1374
  },
1294
1375
  featureFlags: {},
1295
1376
  shopCustomStyles: ""
1296
- }, Te = {
1297
- config: Be,
1298
- dealBlock: Ge,
1299
- product: Ne,
1377
+ }, Le = {
1378
+ config: je,
1379
+ dealBlock: Oe,
1380
+ product: qe,
1300
1381
  otherProducts: [],
1301
1382
  mediaImages: [],
1302
1383
  collectionBreaksProducts: [],
1303
1384
  translations: {}
1304
1385
  };
1305
- class Me extends HTMLElement {
1386
+ class Ue extends HTMLElement {
1306
1387
  constructor() {
1307
1388
  super(...arguments), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
1308
1389
  }
@@ -1313,63 +1394,63 @@ class Me extends HTMLElement {
1313
1394
  await this.initialize();
1314
1395
  }
1315
1396
  async initialize() {
1316
- var o, i;
1317
- const e = ++this.initializeId;
1397
+ var o, r;
1398
+ const t = ++this.initializeId;
1318
1399
  if (this.cleanup(), this.hasAttribute("demo")) {
1319
- if (await q(window), e !== this.initializeId) return;
1320
- this.renderInnerElement(Te);
1400
+ if (await j(window), t !== this.initializeId) return;
1401
+ this.renderInnerElement(Le);
1321
1402
  return;
1322
1403
  }
1323
- const s = this.getAttribute("shop-domain"), l = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
1324
- if (!s || !l || !n) return;
1325
- const [r] = await Promise.all([
1326
- we(
1404
+ const s = this.getAttribute("shop-domain"), a = this.getAttribute("storefront-token"), n = this.getAttribute("product-id");
1405
+ if (!s || !a || !n) return;
1406
+ const [i] = await Promise.all([
1407
+ xe(
1327
1408
  {
1328
1409
  shopifyDomain: s,
1329
- storefrontAccessToken: l
1410
+ storefrontAccessToken: a
1330
1411
  },
1331
1412
  {
1332
1413
  productId: n,
1333
1414
  dealBlockId: this.getAttribute("deal-block-id") ?? void 0,
1334
1415
  country: ((o = this.getAttribute("country")) == null ? void 0 : o.toUpperCase()) ?? void 0,
1335
- language: ((i = this.getAttribute("language")) == null ? void 0 : i.toUpperCase()) ?? void 0
1416
+ language: ((r = this.getAttribute("language")) == null ? void 0 : r.toUpperCase()) ?? void 0
1336
1417
  }
1337
1418
  ),
1338
- q(window)
1419
+ j(window)
1339
1420
  ]);
1340
- !r || e !== this.initializeId || this.renderInnerElement(r);
1421
+ !i || t !== this.initializeId || this.renderInnerElement(i);
1341
1422
  }
1342
- renderInnerElement(e) {
1423
+ renderInnerElement(t) {
1343
1424
  const {
1344
1425
  config: s,
1345
- dealBlock: l,
1426
+ dealBlock: a,
1346
1427
  product: n,
1347
- otherProducts: r,
1428
+ otherProducts: i,
1348
1429
  mediaImages: o,
1349
- collectionBreaksProducts: i,
1430
+ collectionBreaksProducts: r,
1350
1431
  translations: m
1351
- } = e;
1432
+ } = t;
1352
1433
  this.innerElement = document.createElement(
1353
1434
  "kaching-bundles-block"
1354
- ), this.innerElement.setAttribute("deal-block-id", l.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(l)), this.innerElement.setAttribute(
1435
+ ), this.innerElement.setAttribute("deal-block-id", a.id), this.innerElement.setAttribute("config", JSON.stringify(s)), this.innerElement.setAttribute("deal-block", JSON.stringify(a)), this.innerElement.setAttribute(
1355
1436
  "media-images",
1356
1437
  JSON.stringify(o ?? [])
1357
1438
  ), this.innerElement.setAttribute("product", JSON.stringify(n)), this.innerElement.setAttribute(
1358
1439
  "other-products",
1359
- JSON.stringify(r ?? [])
1440
+ JSON.stringify(i ?? [])
1360
1441
  ), this.innerElement.setAttribute(
1361
1442
  "collection-breaks-products",
1362
- JSON.stringify(i ?? [])
1443
+ JSON.stringify(r ?? [])
1363
1444
  ), this.innerElement.setAttribute(
1364
1445
  "translations",
1365
1446
  JSON.stringify(m ?? {})
1366
1447
  );
1367
- const d = this.getAttribute("selected-variant-id");
1448
+ const c = this.getAttribute("selected-variant-id");
1368
1449
  this.innerElement.setAttribute(
1369
1450
  "current-variant-id",
1370
- String(d ? d.split("/").pop() : n.variants[0].id)
1451
+ String(c ? c.split("/").pop() : n.variants[0].id)
1371
1452
  ), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
1372
- const u = this.innerElement, y = () => {
1453
+ const u = this.innerElement, h = () => {
1373
1454
  if (this.innerElement !== u) return;
1374
1455
  const f = u.items();
1375
1456
  f && this.dispatchEvent(
@@ -1380,13 +1461,13 @@ class Me extends HTMLElement {
1380
1461
  );
1381
1462
  };
1382
1463
  this.handleItemsChanged = (f) => {
1383
- f.stopPropagation(), y();
1464
+ f.stopPropagation(), h();
1384
1465
  };
1385
- const h = this.handleItemsChanged;
1466
+ const g = this.handleItemsChanged;
1386
1467
  u.addEventListener(
1387
1468
  "kaching-bundles-block-loaded",
1388
1469
  () => {
1389
- this.innerElement === u && (u.addEventListener("items-changed", h), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1470
+ this.innerElement === u && (u.addEventListener("items-changed", g), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
1390
1471
  },
1391
1472
  { once: !0 }
1392
1473
  ), this.appendChild(this.innerElement);
@@ -1397,10 +1478,10 @@ class Me extends HTMLElement {
1397
1478
  this.handleItemsChanged
1398
1479
  ), this.handleItemsChanged = null), this.innerElement && (this.innerElement.remove(), this.innerElement = null);
1399
1480
  }
1400
- attributeChangedCallback(e, s, l) {
1401
- s !== l && this.isConnected && (e === "product-id" || e === "country" || e === "language" ? this.initialize() : e === "selected-variant-id" && this.innerElement && l && this.innerElement.setAttribute(
1481
+ attributeChangedCallback(t, s, a) {
1482
+ s !== a && this.isConnected && (t === "product-id" || t === "country" || t === "language" ? this.initialize() : t === "selected-variant-id" && this.innerElement && a && this.innerElement.setAttribute(
1402
1483
  "current-variant-id",
1403
- l.includes("/") ? String(l.split("/").pop()) : l
1484
+ a.includes("/") ? String(a.split("/").pop()) : a
1404
1485
  ));
1405
1486
  }
1406
1487
  items() {
@@ -1410,7 +1491,7 @@ class Me extends HTMLElement {
1410
1491
  this.cleanup(), this.initializeId++;
1411
1492
  }
1412
1493
  }
1413
- customElements.define("kaching-bundle-component", Me);
1494
+ customElements.define("kaching-bundle-component", Ue);
1414
1495
  export {
1415
- we as fetchKachingBundlesData
1496
+ xe as fetchKachingBundlesData
1416
1497
  };