@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.
package/dist/index.js CHANGED
@@ -1,61 +1,61 @@
1
- const q = (e, t) => {
2
- const a = [], l = e.filter(
3
- (r) => r.blockVisibility === "selected-products"
1
+ const T = (e, t) => {
2
+ const a = [], n = e.filter(
3
+ (i) => i.blockVisibility === "selected-products"
4
4
  );
5
- for (const r of l)
6
- r.selectedProductIds.map(Number).includes(t.id) && a.push(r);
7
- const n = e.filter(
8
- (r) => r.blockVisibility === "selected-collections"
5
+ for (const i of n)
6
+ i.selectedProductIds.map(Number).includes(t.id) && a.push(i);
7
+ const s = e.filter(
8
+ (i) => i.blockVisibility === "selected-collections"
9
9
  );
10
- for (const r of n)
10
+ for (const i of s)
11
11
  t.collectionIds.some(
12
- (d) => r.selectedCollectionIds.map(Number).includes(d)
13
- ) && a.push(r);
14
- const o = e.filter(
15
- (r) => r.blockVisibility === "excluded-products"
12
+ (d) => i.selectedCollectionIds.map(Number).includes(d)
13
+ ) && a.push(i);
14
+ const l = e.filter(
15
+ (i) => i.blockVisibility === "excluded-products"
16
16
  );
17
- for (const r of o)
18
- !r.excludedProductIds.map(Number).includes(t.id) && !(r.excludedCollectionIds || []).some(
17
+ for (const i of l)
18
+ !i.excludedProductIds.map(Number).includes(t.id) && !(i.excludedCollectionIds || []).some(
19
19
  (d) => t.collectionIds.includes(d)
20
- ) && a.push(r);
20
+ ) && a.push(i);
21
21
  const u = e.filter(
22
- (r) => r.blockVisibility === "all-products"
22
+ (i) => i.blockVisibility === "all-products"
23
23
  );
24
- for (const r of u)
25
- a.push(r);
24
+ for (const i of u)
25
+ a.push(i);
26
26
  return a;
27
- }, j = (e, { language: t, country: a }) => {
28
- var b, g;
29
- const l = B(t, a), n = new Intl.NumberFormat(l, {
27
+ }, E = (e, { language: t, country: a }) => {
28
+ var f, h;
29
+ const n = O(t, a), s = new Intl.NumberFormat(n, {
30
30
  style: "currency",
31
31
  currency: e,
32
32
  currencyDisplay: "narrowSymbol"
33
- }).formatToParts(123456789e-2), o = (b = n.find((f) => f.type === "decimal")) == null ? void 0 : b.value, u = E(
34
- (g = n.find((f) => f.type === "group")) == null ? void 0 : g.value
35
- ), r = n.some((f) => f.type === "fraction"), d = T(
33
+ }).formatToParts(123456789e-2), l = (f = s.find((y) => y.type === "decimal")) == null ? void 0 : f.value, u = F(
34
+ (h = s.find((y) => y.type === "group")) == null ? void 0 : h.value
35
+ ), i = s.some((y) => y.type === "fraction"), d = U(
36
36
  u,
37
- o,
38
- r
39
- ), m = n.findIndex(N), p = n.findLastIndex(N);
37
+ l,
38
+ i
39
+ ), c = s.findIndex(N), p = s.findLastIndex(N);
40
40
  return [
41
- ...n.slice(0, m).map(D),
41
+ ...s.slice(0, c).map(D),
42
42
  d,
43
- ...n.slice(p + 1).map(D)
43
+ ...s.slice(p + 1).map(D)
44
44
  ].join("");
45
- }, D = (e) => M(e.value), M = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", B = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), E = (e) => e === void 0 ? void 0 : M(e).replace(/’/g, "'"), T = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
45
+ }, D = (e) => C(e.value), C = (e) => e.replace(/\s/g, " "), N = (e) => e.type === "integer" || e.type === "group" || e.type === "decimal" || e.type === "fraction", O = (e, t) => e && t ? `${e}-${t.toUpperCase()}` : e || (t ? t.toUpperCase() : "en"), F = (e) => e === void 0 ? void 0 : C(e).replace(/’/g, "'"), U = (e, t, a) => t === "," && e === "." ? a ? "{{amount_with_comma_separator}}" : "{{amount_no_decimals_with_comma_separator}}" : t === "," && e === " " ? a ? "{{amount_with_space_separator}}" : "{{amount_no_decimals_with_space_separator}}" : t === "." && e === " " ? "{{amount_with_period_and_space_separator}}" : t === "." && e === "'" ? "{{amount_with_apostrophe_separator}}" : a ? "{{amount}}" : "{{amount_no_decimals}}", w = ({
46
46
  country: e,
47
47
  language: t
48
48
  }) => {
49
49
  const a = [];
50
50
  return e && a.push(`country: ${e}`), t && a.push(`language: ${t}`), a.length > 0 ? `@inContext(${a.join(", ")})` : "";
51
- }, F = async (e, {
51
+ }, V = async (e, {
52
52
  useExternalMetafieldNamespace: t,
53
53
  useMetaobjects: a
54
- }) => a ? U(
54
+ }) => a ? R(
55
55
  e
56
- ) : O(e), O = async (e, t) => {
57
- var l;
58
- const a = (l = (await e.query(
56
+ ) : L(e), L = async (e, t) => {
57
+ var n;
58
+ const a = (n = (await e.query(
59
59
  `
60
60
  query FetchDealBlocks($metafieldNamespace: String!) {
61
61
  shop {
@@ -70,13 +70,13 @@ const q = (e, t) => {
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 : n.value;
74
74
  return a ? JSON.parse(a) : [];
75
- }, U = async (e, t) => {
76
- const a = "app--2935586817--deal_block", l = [];
77
- let n = null;
75
+ }, R = async (e, t) => {
76
+ const a = "app--2935586817--deal_block", n = [];
77
+ let s = null;
78
78
  for (; ; ) {
79
- const o = await e.query(
79
+ const l = await e.query(
80
80
  `
81
81
  query FetchDealBlockMetaobjects($type: String!, $cursor: String) {
82
82
  metaobjects(type: $type, first: 250, after: $cursor) {
@@ -96,39 +96,39 @@ const q = (e, t) => {
96
96
  {
97
97
  variables: {
98
98
  type: a,
99
- cursor: n
99
+ cursor: s
100
100
  }
101
101
  }
102
102
  );
103
- for (const u of o.metaobjects.nodes) {
104
- const r = u.fields.find(
103
+ for (const u of l.metaobjects.nodes) {
104
+ const i = u.fields.find(
105
105
  (d) => d.key === "settings"
106
106
  );
107
- r != null && r.value && l.push(JSON.parse(r.value));
107
+ i != null && i.value && n.push(JSON.parse(i.value));
108
108
  }
109
- if (!o.metaobjects.pageInfo.hasNextPage)
109
+ if (!l.metaobjects.pageInfo.hasNextPage)
110
110
  break;
111
- n = o.metaobjects.pageInfo.endCursor;
111
+ s = l.metaobjects.pageInfo.endCursor;
112
112
  }
113
- return l;
113
+ return n;
114
114
  }, k = async (e, {
115
115
  country: t,
116
116
  language: a,
117
- blockVisibility: l,
118
- excludedProductGIDs: n,
119
- selectedProductGIDs: o,
117
+ blockVisibility: n,
118
+ excludedProductGIDs: s,
119
+ selectedProductGIDs: l,
120
120
  selectedCollectionGIDs: u,
121
- limit: r = 1e3
121
+ limit: i = 1e3
122
122
  }) => {
123
- switch (l) {
123
+ switch (n) {
124
124
  case "selected-products":
125
- return o.slice(0, r);
125
+ return l.slice(0, i);
126
126
  case "all-products":
127
127
  case "excluded-products": {
128
128
  const d = w({ country: t, language: a });
129
- let m = [], p = null;
130
- for (; m.length < r; ) {
131
- const b = Math.min(r - m.length, 250), g = await e.query(
129
+ let c = [], p = null;
130
+ for (; c.length < i; ) {
131
+ const f = Math.min(i - c.length, 250), h = await e.query(
132
132
  `
133
133
  query FetchProductGIDs($limit: Int!, $cursor: String) ${d} {
134
134
  products(first: $limit, after: $cursor) {
@@ -144,22 +144,22 @@ const q = (e, t) => {
144
144
  `,
145
145
  {
146
146
  variables: {
147
- limit: b,
147
+ limit: f,
148
148
  cursor: p
149
149
  }
150
150
  }
151
151
  );
152
- if (m.push(...g.products.nodes.map((f) => f.id)), !g.products.pageInfo.hasNextPage) break;
153
- p = g.products.pageInfo.endCursor;
152
+ if (c.push(...h.products.nodes.map((y) => y.id)), !h.products.pageInfo.hasNextPage) break;
153
+ p = h.products.pageInfo.endCursor;
154
154
  }
155
- if (l === "excluded-products") {
156
- const b = new Set(n);
157
- m = m.filter((g) => !b.has(g));
155
+ if (n === "excluded-products") {
156
+ const f = new Set(s);
157
+ c = c.filter((h) => !f.has(h));
158
158
  }
159
- return m;
159
+ return c;
160
160
  }
161
161
  case "selected-collections": {
162
- const d = w({ country: t, language: a }), m = (await e.query(
162
+ const d = w({ country: t, language: a }), c = (await e.query(
163
163
  `
164
164
  query FetchCollectionProductGIDs($collectionGIDs: [ID!]!, $limit: Int!) ${d} {
165
165
  nodes(ids: $collectionGIDs) {
@@ -176,16 +176,16 @@ const q = (e, t) => {
176
176
  {
177
177
  variables: {
178
178
  collectionGIDs: u,
179
- limit: Math.min(r, 250)
179
+ limit: Math.min(i, 250)
180
180
  }
181
181
  }
182
182
  )).nodes.filter((p) => p !== null).flatMap(
183
- (p) => p.products.nodes.map((b) => b.id)
183
+ (p) => p.products.nodes.map((f) => f.id)
184
184
  );
185
- return Array.from(new Set(m)).slice(0, r);
185
+ return Array.from(new Set(c)).slice(0, i);
186
186
  }
187
187
  }
188
- }, C = `
188
+ }, j = `
189
189
  id
190
190
  availableForSale
191
191
  price {
@@ -200,7 +200,7 @@ const q = (e, t) => {
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
@@ -231,17 +231,18 @@ const q = (e, t) => {
231
231
  `, S = async (e, {
232
232
  country: t,
233
233
  language: a,
234
- productIds: l,
235
- includeSellingPlans: n = !0,
236
- includeAvailableQuantity: o = !0,
234
+ productIds: n,
235
+ includeSellingPlans: s = !0,
236
+ includeAvailableQuantity: l = !0,
237
237
  useExternalMetafieldNamespace: u = !1,
238
- batchSize: r = 250,
239
- onBatchError: d
238
+ batchSize: i = 250,
239
+ onBatchError: d,
240
+ variantImageTransform: c = { maxWidth: 200, maxHeight: 200 }
240
241
  }) => {
241
- if (!l.length)
242
+ if (!n.length)
242
243
  return [];
243
- const m = l.map((i) => typeof i == "string" && i.startsWith("gid://") ? i : `gid://shopify/Product/${i}`), p = w({ country: t, language: a }), b = `
244
- query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!) ${p} {
244
+ const p = n.map((m) => typeof m == "string" && m.startsWith("gid://") ? m : `gid://shopify/Product/${m}`), f = w({ country: t, language: a }), h = `
245
+ query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${f} {
245
246
  shop {
246
247
  currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
247
248
  value
@@ -275,7 +276,7 @@ const q = (e, t) => {
275
276
  }
276
277
  variants(first: 250) {
277
278
  nodes {
278
- ${C}
279
+ ${j}
279
280
  }
280
281
  }
281
282
  collections(first: 50) {
@@ -327,84 +328,90 @@ const q = (e, t) => {
327
328
  }
328
329
  }
329
330
  }
330
- `, g = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", f = [], v = Math.min(r, 250);
331
- for (let i = 0; i < m.length; i += v)
332
- f.push(m.slice(i, i + v));
333
- let s = 1;
334
- const c = async (i) => {
335
- const h = await e.query(b, {
331
+ `, y = u ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", v = [], r = Math.min(i, 250);
332
+ for (let m = 0; m < p.length; m += r)
333
+ v.push(p.slice(m, m + r));
334
+ let o = 1;
335
+ const g = async (m) => {
336
+ const b = await e.query(h, {
336
337
  variables: {
337
- productGIDs: i,
338
- includeSellingPlans: n,
339
- includeAvailableQuantity: o,
340
- metafieldNamespace: g
338
+ productGIDs: m,
339
+ includeSellingPlans: s,
340
+ includeAvailableQuantity: l,
341
+ metafieldNamespace: y,
342
+ variantImageTransform: c
341
343
  }
342
344
  });
343
- return h.shop.currencyRateConstant && (s = JSON.parse(h.shop.currencyRateConstant.value).amount / 1e6), h;
345
+ return b.shop.currencyRateConstant && (o = JSON.parse(b.shop.currencyRateConstant.value).amount / 1e6), b;
344
346
  };
345
- let y;
347
+ let _;
346
348
  if (d) {
347
- const i = await Promise.allSettled(f.map(c));
348
- for (const h of i)
349
- h.status === "rejected" && d(
350
- h.reason instanceof Error ? h.reason : new Error(String(h.reason))
349
+ const m = await Promise.allSettled(v.map(g));
350
+ for (const b of m)
351
+ b.status === "rejected" && d(
352
+ b.reason instanceof Error ? b.reason : new Error(String(b.reason))
351
353
  );
352
- y = i.filter(
353
- (h) => h.status === "fulfilled"
354
- ).flatMap((h) => h.value.nodes);
354
+ _ = m.filter(
355
+ (b) => b.status === "fulfilled"
356
+ ).flatMap((b) => b.value.nodes);
355
357
  } else
356
- y = (await Promise.all(f.map(c))).flatMap((i) => i.nodes);
357
- const _ = y.filter((i) => i != null);
358
+ _ = (await Promise.all(v.map(g))).flatMap((m) => m.nodes);
359
+ const I = _.filter((m) => m != null);
358
360
  if (d) {
359
- const i = await Promise.allSettled(
360
- _.map(async (I) => {
361
- const P = await G(
361
+ const m = await Promise.allSettled(
362
+ I.map(async (P) => {
363
+ const B = await x(
362
364
  e,
363
- I,
364
- { includeSellingPlans: n, includeAvailableQuantity: o },
365
- p
366
- );
367
- return x(
368
365
  P,
366
+ {
367
+ includeSellingPlans: s,
368
+ includeAvailableQuantity: l,
369
+ variantImageTransform: c
370
+ },
371
+ f
372
+ );
373
+ return A(
374
+ B,
369
375
  e.shopifyDomain,
370
- s
376
+ o
371
377
  );
372
378
  })
373
- ), h = [];
374
- for (const I of i)
375
- I.status === "fulfilled" ? h.push(I.value) : d(
376
- I.reason instanceof Error ? I.reason : new Error(String(I.reason))
379
+ ), b = [];
380
+ for (const P of m)
381
+ P.status === "fulfilled" ? b.push(P.value) : d(
382
+ P.reason instanceof Error ? P.reason : new Error(String(P.reason))
377
383
  );
378
- return h;
384
+ return b;
379
385
  }
380
386
  return (await Promise.all(
381
- _.map(
382
- (i) => G(
387
+ I.map(
388
+ (m) => x(
383
389
  e,
384
- i,
390
+ m,
385
391
  {
386
- includeSellingPlans: n,
387
- includeAvailableQuantity: o
392
+ includeSellingPlans: s,
393
+ includeAvailableQuantity: l,
394
+ variantImageTransform: c
388
395
  },
389
- p
396
+ f
390
397
  )
391
398
  )
392
399
  )).map(
393
- (i) => x(i, e.shopifyDomain, s)
400
+ (m) => A(m, e.shopifyDomain, o)
394
401
  );
395
- }, G = async (e, t, a, l = "") => {
402
+ }, x = async (e, t, a, n = "") => {
396
403
  if (t.variants.nodes.length < 250)
397
404
  return t;
398
- const n = /* @__PURE__ */ new Set(), o = [], u = [], r = async (d) => {
399
- let m = !0, p = null;
400
- for (; m; ) {
401
- const b = await e.query(
405
+ const s = /* @__PURE__ */ new Set(), l = [], u = [], i = async (d) => {
406
+ let c = !0, p = null;
407
+ for (; c; ) {
408
+ const f = 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) ${n} {
404
411
  product(id: $productGID) {
405
412
  variants(first: 250, after: $cursor, reverse: $reverse) {
406
413
  nodes {
407
- ${C}
414
+ ${j}
408
415
  }
409
416
  pageInfo {
410
417
  endCursor
@@ -422,110 +429,110 @@ const q = (e, t) => {
422
429
  ...a
423
430
  }
424
431
  }
425
- ), { nodes: g, pageInfo: f } = b.product.variants;
426
- for (const v of g) {
427
- if (n.has(v.id)) {
428
- m = !1;
432
+ ), { nodes: h, pageInfo: y } = f.product.variants;
433
+ for (const v of h) {
434
+ if (s.has(v.id)) {
435
+ c = !1;
429
436
  break;
430
437
  }
431
- n.add(v.id), d ? u.push(v) : o.push(v);
438
+ s.add(v.id), d ? u.push(v) : l.push(v);
432
439
  }
433
- f.hasNextPage || (m = !1), p = f.endCursor;
440
+ y.hasNextPage || (c = !1), p = y.endCursor;
434
441
  }
435
442
  };
436
443
  return await Promise.all([
437
- r(!1),
438
- r(!0)
439
- ]), t.variants.nodes = [...o, ...u.reverse()], t;
440
- }, x = (e, t, a) => {
441
- var m, p, b, g, f, v;
442
- const l = e.variants.nodes.map(
443
- ({ unitPriceMeasurement: s, ...c }) => {
444
- var y, _;
444
+ i(!1),
445
+ i(!0)
446
+ ]), t.variants.nodes = [...l, ...u.reverse()], t;
447
+ }, A = (e, t, a) => {
448
+ var c, p, f, h, y, v;
449
+ const n = e.variants.nodes.map(
450
+ ({ unitPriceMeasurement: r, ...o }) => {
451
+ var g, _;
445
452
  return {
446
- id: Number(c.id.split("/").pop()),
447
- availableForSale: c.availableForSale,
448
- price: Math.round(Number(c.price.amount) * 100),
449
- compareAtPrice: c.compareAtPrice ? Math.round(Number(c.compareAtPrice.amount) * 100) : null,
450
- options: c.selectedOptions.map((i) => i.value),
451
- imageId: c.image ? Number(c.image.id.split("/").pop()) : null,
452
- image: ((y = c.image) == null ? void 0 : y.url) || null,
453
- sellingPlans: ((_ = c.sellingPlanAllocations) == null ? void 0 : _.nodes.map((i) => ({
454
- id: Number(i.sellingPlan.id.split("/").pop()),
455
- price: i.priceAdjustments.length > 0 ? Math.round(Number(i.priceAdjustments[0].price.amount) * 100) : Math.round(Number(c.price.amount) * 100),
456
- compareAtPrice: i.priceAdjustments.length > 0 ? Math.round(
457
- Number(i.priceAdjustments[0].compareAtPrice.amount) * 100
458
- ) : Math.round(Number(c.price.amount) * 100),
459
- perDeliveryPrice: i.priceAdjustments.length > 0 ? Math.round(
460
- Number(i.priceAdjustments[0].perDeliveryPrice.amount) * 100
461
- ) : Math.round(Number(c.price.amount) * 100)
453
+ id: Number(o.id.split("/").pop()),
454
+ availableForSale: o.availableForSale,
455
+ price: Math.round(Number(o.price.amount) * 100),
456
+ compareAtPrice: o.compareAtPrice ? Math.round(Number(o.compareAtPrice.amount) * 100) : null,
457
+ options: o.selectedOptions.map((I) => I.value),
458
+ imageId: o.image ? Number(o.image.id.split("/").pop()) : null,
459
+ image: ((g = o.image) == null ? void 0 : g.url) || null,
460
+ sellingPlans: ((_ = o.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(o.price.amount) * 100),
463
+ compareAtPrice: I.priceAdjustments.length > 0 ? Math.round(
464
+ Number(I.priceAdjustments[0].compareAtPrice.amount) * 100
465
+ ) : Math.round(Number(o.price.amount) * 100),
466
+ perDeliveryPrice: I.priceAdjustments.length > 0 ? Math.round(
467
+ Number(I.priceAdjustments[0].perDeliveryPrice.amount) * 100
468
+ ) : Math.round(Number(o.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: c.quantityAvailable ?? null,
468
- unitPriceMeasurement: s != null && s.quantityUnit && (s != null && s.referenceUnit) ? {
469
- quantityValue: s.quantityValue,
470
- quantityUnit: s.quantityUnit.toLowerCase(),
471
- referenceValue: s.referenceValue,
472
- referenceUnit: s.referenceUnit.toLowerCase()
474
+ inventoryQuantity: o.quantityAvailable ?? null,
475
+ unitPriceMeasurement: r != null && r.quantityUnit && (r != null && r.referenceUnit) ? {
476
+ quantityValue: r.quantityValue,
477
+ quantityUnit: r.quantityUnit.toLowerCase(),
478
+ referenceValue: r.referenceValue,
479
+ referenceUnit: r.referenceUnit.toLowerCase()
473
480
  } : null
474
481
  };
475
482
  }
476
- ), n = e.options.map((s, c) => {
477
- const y = s.optionValues.map((_) => {
478
- var i, h, I, P;
483
+ ), s = e.options.map((r, o) => {
484
+ const g = r.optionValues.map((_) => {
485
+ var I, m, 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: ((i = _.swatch) == null ? void 0 : i.color) || null,
485
- image: ((P = (I = (h = _.swatch) == null ? void 0 : h.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 = (m = _.swatch) == null ? void 0 : m.image) == null ? void 0 : b.previewImage) == null ? void 0 : P.url) || null
486
493
  }
487
494
  };
488
495
  });
489
496
  return {
490
- defaultName: s.name,
491
- name: s.name,
492
- position: c + 1,
493
- optionValues: V(y, c, l)
497
+ defaultName: r.name,
498
+ name: r.name,
499
+ position: o + 1,
500
+ optionValues: Q(g, o, n)
494
501
  };
495
- }), o = (s) => {
496
- const c = s.priceAdjustments[0];
497
- if (!c)
502
+ }), l = (r) => {
503
+ const o = r.priceAdjustments[0];
504
+ if (!o)
498
505
  return null;
499
- const y = c.adjustmentValue;
500
- switch (y.__typename) {
506
+ const g = o.adjustmentValue;
507
+ switch (g.__typename) {
501
508
  case "SellingPlanPercentagePriceAdjustment":
502
509
  return {
503
510
  type: "percentage",
504
- value: y.adjustmentPercentage
511
+ value: g.adjustmentPercentage
505
512
  };
506
513
  case "SellingPlanFixedAmountPriceAdjustment":
507
514
  return {
508
515
  type: "fixed_amount",
509
- value: u(y.adjustmentAmount.amount)
516
+ value: u(g.adjustmentAmount.amount)
510
517
  };
511
518
  case "SellingPlanFixedPriceAdjustment":
512
519
  return {
513
520
  type: "price",
514
- value: u(y.price.amount)
521
+ value: u(g.price.amount)
515
522
  };
516
523
  default:
517
524
  throw new Error(
518
- `Unknown price adjustment type: ${y.__typename}`
525
+ `Unknown price adjustment type: ${g.__typename}`
519
526
  );
520
527
  }
521
- }, u = (s) => a === 1 ? Number(s) * 100 : Math.round(Number(s) * 100 * a), r = ((m = e.sellingPlanGroups) == null ? void 0 : m.nodes.flatMap(
522
- (s) => s.sellingPlans.nodes.map((c) => ({
523
- id: Number(c.id.split("/").pop()),
524
- name: c.name,
525
- priceAdjustment: o(c)
528
+ }, u = (r) => a === 1 ? Number(r) * 100 : Math.round(Number(r) * 100 * a), i = ((c = e.sellingPlanGroups) == null ? void 0 : c.nodes.flatMap(
529
+ (r) => r.sellingPlans.nodes.map((o) => ({
530
+ id: Number(o.id.split("/").pop()),
531
+ name: o.name,
532
+ priceAdjustment: l(o)
526
533
  }))
527
534
  )) || [], d = e.variants.nodes.some(
528
- (s) => s.requiresComponents
535
+ (r) => r.requiresComponents
529
536
  );
530
537
  return {
531
538
  id: Number(e.id.split("/").pop()),
@@ -536,42 +543,42 @@ const q = (e, t) => {
536
543
  title: e.title,
537
544
  image: ((p = e.featuredImage) == null ? void 0 : p.url) || null,
538
545
  collectionIds: e.collections.nodes.map(
539
- (s) => Number(s.id.split("/").pop())
546
+ (r) => Number(r.id.split("/").pop())
540
547
  ),
541
- options: n,
548
+ options: s,
542
549
  selectedVariantId: Number(
543
550
  e.variants.nodes[0].id.split("/").pop()
544
551
  ),
545
- variants: l,
552
+ variants: n,
546
553
  requiresSellingPlan: e.requiresSellingPlan,
547
- sellingPlans: r,
554
+ sellingPlans: i,
548
555
  isNativeBundle: d,
549
556
  metafields: {
550
- text: ((b = e.metafield) == null ? void 0 : b.value) || null,
551
- text2: ((g = e.metafield2) == null ? void 0 : g.value) || null,
552
- text3: ((f = e.metafield3) == null ? void 0 : f.value) || null,
557
+ text: ((f = e.metafield) == null ? void 0 : f.value) || null,
558
+ text2: ((h = e.metafield2) == null ? void 0 : h.value) || null,
559
+ text3: ((y = e.metafield3) == null ? void 0 : y.value) || null,
553
560
  text4: ((v = e.metafield4) == null ? void 0 : v.value) || null
554
561
  }
555
562
  };
556
- }, V = (e, t, a) => e.filter((l) => a.filter(
557
- (n) => n.options[t] === l.name
558
- ).length > 0), A = "app--2935586817", R = async (e, {
563
+ }, Q = (e, t, a) => e.filter((n) => a.filter(
564
+ (s) => s.options[t] === n.name
565
+ ).length > 0), G = "app--2935586817", H = async (e, {
559
566
  language: t,
560
567
  country: a,
561
- useExternalMetafieldNamespace: l
568
+ useExternalMetafieldNamespace: n
562
569
  }) => {
563
- const n = `${A}--kaching_bundles`, o = A, u = w({ country: a }), {
570
+ const s = `${G}--kaching_bundles`, l = G, u = w({ country: a }), {
564
571
  localization: {
565
572
  country: {
566
- currency: { isoCode: r }
573
+ currency: { isoCode: i }
567
574
  }
568
575
  },
569
576
  shop: {
570
577
  moneyFormat: d,
571
- paymentSettings: { currencyCode: m },
578
+ paymentSettings: { currencyCode: c },
572
579
  currencyRateConstant: p,
573
- primaryDomain: b,
574
- settingsMetafield: g
580
+ primaryDomain: f,
581
+ settingsMetafield: h
575
582
  }
576
583
  } = await e.query(
577
584
  `
@@ -602,30 +609,30 @@ const q = (e, t) => {
602
609
  `,
603
610
  {
604
611
  variables: {
605
- metafieldNamespace: n,
606
- settingsNamespace: o
612
+ metafieldNamespace: s,
613
+ settingsNamespace: l
607
614
  }
608
615
  }
609
- ), f = r === m ? d : j(r, { language: t, country: a }), v = p ? Q(p.value) : 1, s = g ? JSON.parse(g.value) : null, c = (s == null ? void 0 : s.feature_flags) ?? {}, y = (s == null ? void 0 : s.custom_selectors) ?? {};
616
+ ), y = i === c ? d : E(i, { language: t, country: a }), v = p ? J(p.value) : 1, r = h ? JSON.parse(h.value) : null, o = (r == null ? void 0 : r.feature_flags) ?? {}, g = (r == null ? void 0 : r.custom_selectors) ?? {};
610
617
  return {
611
- shopifyDomain: b.host,
612
- moneyFormat: f,
618
+ shopifyDomain: f.host,
619
+ moneyFormat: y,
613
620
  locale: (t == null ? void 0 : t.toLowerCase()) || "en",
614
621
  liquidLocale: (t == null ? void 0 : t.toLowerCase()) || "en",
615
622
  country: a ?? "US",
616
623
  currencyRate: v,
617
624
  marketId: 0,
618
625
  productId: null,
619
- storefrontAccessToken: (s == null ? void 0 : s.storefront_access_token) ?? null,
620
- includeSellingPlans: (s == null ? void 0 : s.include_selling_plans) ?? !1,
621
- includeAvailableQuantity: (s == null ? void 0 : s.include_available_quantity) ?? !1,
622
- customApiHost: (s == null ? void 0 : s.custom_api_host) ?? null,
623
- keepQuantityInput: (s == null ? void 0 : s.keep_quantity_input) ?? !1,
624
- ignoreDeselect: (s == null ? void 0 : s.ignore_deselect) ?? !1,
625
- ignoreUnitPrice: (s == null ? void 0 : s.ignore_unit_price) ?? !1,
626
- requireCustomerLogin: (s == null ? void 0 : s.require_customer_login) ?? !1,
627
- abTestsRunning: (s == null ? void 0 : s.ab_tests_running) ?? !1,
628
- webPixel: (s == null ? void 0 : s.web_pixel) ?? !1,
626
+ storefrontAccessToken: (r == null ? void 0 : r.storefront_access_token) ?? null,
627
+ includeSellingPlans: (r == null ? void 0 : r.include_selling_plans) ?? !1,
628
+ includeAvailableQuantity: (r == null ? void 0 : r.include_available_quantity) ?? !1,
629
+ customApiHost: (r == null ? void 0 : r.custom_api_host) ?? null,
630
+ keepQuantityInput: (r == null ? void 0 : r.keep_quantity_input) ?? !1,
631
+ ignoreDeselect: (r == null ? void 0 : r.ignore_deselect) ?? !1,
632
+ ignoreUnitPrice: (r == null ? void 0 : r.ignore_unit_price) ?? !1,
633
+ requireCustomerLogin: (r == null ? void 0 : r.require_customer_login) ?? !1,
634
+ abTestsRunning: (r == null ? void 0 : r.ab_tests_running) ?? !1,
635
+ webPixel: (r == null ? void 0 : r.web_pixel) ?? !1,
629
636
  b2bCustomer: !1,
630
637
  isLoggedIn: !1,
631
638
  preview: !1,
@@ -657,44 +664,55 @@ const q = (e, t) => {
657
664
  "system.numbers_only": "Only numbers are allowed."
658
665
  },
659
666
  customSelectors: {
660
- quantity: y.quantity ?? null,
661
- addToCartButton: y.add_to_cart_button ?? null,
662
- variantPicker: y.variant_picker ?? null,
663
- price: y.price ?? null,
664
- priceCompare: y.price_compare ?? null
667
+ quantity: g.quantity ?? null,
668
+ addToCartButton: g.add_to_cart_button ?? null,
669
+ variantPicker: g.variant_picker ?? null,
670
+ price: g.price ?? null,
671
+ priceCompare: g.price_compare ?? null
665
672
  },
666
- shopCustomStyles: (s == null ? void 0 : s.shop_custom_styles) ?? "",
667
- featureFlags: c,
668
- brandColors: (s == null ? void 0 : s.brand_colors) ?? null
673
+ shopCustomStyles: (r == null ? void 0 : r.shop_custom_styles) ?? "",
674
+ featureFlags: o,
675
+ brandColors: (r == null ? void 0 : r.brand_colors) ?? null
669
676
  };
670
- }, Q = (e) => JSON.parse(e).amount / 1e6, L = async (e, t, a = 200) => (t = t.filter(Boolean).filter((l) => !l.startsWith("placeholder")), t.length === 0 ? [] : (await e.query(
671
- `
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
+ }, J = (e) => JSON.parse(e).amount / 1e6, z = async (e, t, a = 200) => {
678
+ const n = [
679
+ ...new Set(
680
+ t.filter(Boolean).filter((l) => !l.startsWith("placeholder"))
681
+ )
682
+ ];
683
+ if (n.length === 0) return [];
684
+ const s = [];
685
+ for (let l = 0; l < n.length; l += 250)
686
+ s.push(n.slice(l, l + 250));
687
+ return (await Promise.all(
688
+ s.map(
689
+ (l) => 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: l,
705
+ size: a
706
+ }
680
707
  }
681
- }
682
- `,
683
- {
684
- variables: {
685
- mediaImageIds: t,
686
- size: a
687
- }
688
- }
689
- )).nodes.filter(Boolean).map((l) => ({
690
- gid: l.id,
691
- url: l.image.url
692
- })));
708
+ )
709
+ )
710
+ )).flatMap((l) => l.nodes).flatMap(
711
+ (l) => l != null && l.image ? [{ gid: l.id, url: l.image.url }] : []
712
+ );
713
+ };
693
714
  var $ = /* @__PURE__ */ ((e) => (e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e))($ || {});
694
- const H = (e) => [
695
- ...J(e),
696
- ...z(e),
697
- ...W(e),
715
+ const W = (e) => [
698
716
  ...X(e),
699
717
  ...K(e),
700
718
  ...Y(e),
@@ -703,86 +721,123 @@ const H = (e) => [
703
721
  ...te(e),
704
722
  ...ae(e),
705
723
  ...se(e),
724
+ ...re(e),
706
725
  ...ne(e),
707
- ...re(e)
708
- ].filter((t) => t != null && !t.includes("placeholder")), J = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), z = (e) => e.dealBars.flatMap(
726
+ ...ie(e),
727
+ ...le(e),
728
+ ...oe(e)
729
+ ].filter((t) => t != null && !t.includes("placeholder")), X = (e) => e.dealBars.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), K = (e) => e.dealBars.flatMap(
709
730
  (t) => t.dealBarType === $.Bundle ? t.bundleProducts.map(
710
731
  (a) => a.mediaImageGID
711
732
  ) : []
712
- ).filter((t) => t != null), W = (e) => e.dealBars.map(
733
+ ).filter((t) => t != null), Y = (e) => e.dealBars.map(
713
734
  ({ freeGifts: t }) => (t || []).map((a) => a.mediaImageGID)
714
- ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), X = (e) => e.dealBars.flatMap(
735
+ ).reduce((t, a) => t.concat(a), []).filter((t) => t != null), Z = (e) => e.dealBars.flatMap(
715
736
  ({ multipleGiftsSelectors: t }) => (t || []).map((a) => a.mediaImageGID)
716
- ).filter((t) => t != null), K = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), Y = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
717
- const l = a.images.map((n) => n.mediaImageGID).filter((n) => n != null);
718
- return [...t, ...l];
719
- }, []) : [], Z = (e) => {
737
+ ).filter((t) => t != null), ee = (e) => e.dealBars.map(({ upsells: t }) => (t || []).map((a) => a.mediaImageGID)).reduce((t, a) => t.concat(a), []).filter((t) => t != null), te = (e) => e.swatchOptions ? e.swatchOptions.reduce((t, a) => {
738
+ const n = a.images.map((s) => s.mediaImageGID).filter((s) => s != null);
739
+ return [...t, ...n];
740
+ }, []) : [], ae = (e) => {
720
741
  if (!e.collectionBreaksEnabled || !e.collectionBreaks)
721
742
  return [];
722
743
  const t = e.collectionBreaks.mediaImageGID;
723
744
  return t ? [t] : [];
724
- }, ee = (e) => {
725
- var t, a, l;
745
+ }, se = (e) => {
746
+ var t, a, n;
726
747
  return e.progressiveGifts ? [
727
- ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((n) => n.mediaImageGID)) || [],
748
+ ...((t = e.progressiveGifts.gifts) == null ? void 0 : t.map((s) => s.mediaImageGID)) || [],
728
749
  (a = e.progressiveGifts.style) == null ? void 0 : a.lockedMediaImageGID,
729
- (l = e.progressiveGifts.dealBarStyle) == null ? void 0 : l.lockedMediaImageGID
730
- ].filter((n) => n != null) : [];
731
- }, te = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ae = (e) => e.dealBars.map((t) => {
750
+ (n = e.progressiveGifts.dealBarStyle) == null ? void 0 : n.lockedMediaImageGID
751
+ ].filter((s) => s != null) : [];
752
+ }, re = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((t) => [t.mediaImageGID, t.badgeImageGID]).filter((t) => t != null), ne = (e) => e.dealBars.map((t) => {
732
753
  var a;
733
754
  return (a = t.productPersonalisation) == null ? void 0 : a.mediaImageGID;
734
- }).filter((t) => t != null), se = (e) => {
735
- var l, n;
736
- const t = e.dealBars.map((o) => {
755
+ }).filter((t) => t != null), ie = (e) => {
756
+ var n, s;
757
+ const t = e.dealBars.map((l) => {
737
758
  var u;
738
- return (u = o.highlights) == null ? void 0 : u.customIconGID;
739
- }).filter((o) => o != null), a = (n = (l = e.subscriptions) == null ? void 0 : l.highlights) == null ? void 0 : n.customIconGID;
759
+ return (u = l.highlights) == null ? void 0 : u.customIconGID;
760
+ }).filter((l) => l != null), a = (s = (n = e.subscriptions) == null ? void 0 : n.highlights) == null ? void 0 : s.customIconGID;
740
761
  return a ? [...t, a] : t;
741
- }, ne = (e) => (e.badges || []).flatMap(
762
+ }, le = (e) => (e.badges || []).flatMap(
742
763
  (t) => t.badgeType === "custom" && t.imageGID ? [t.imageGID] : []
743
- ), re = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], le = (e) => {
764
+ ), oe = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], ce = (e) => {
744
765
  const t = [
745
- ...ie(e),
746
- ...oe(e),
747
- ...ce(e),
748
766
  ...ue(e),
749
767
  ...de(e),
750
768
  ...me(e),
751
769
  ...pe(e),
752
- ...fe(e)
770
+ ...fe(e),
771
+ ...ye(e),
772
+ ...ge(e),
773
+ ...he(e)
753
774
  ];
754
775
  return Array.from(new Set(t.filter((a) => a != null)));
755
- }, ie = (e) => e.dealBars.flatMap(
776
+ }, ue = (e) => e.dealBars.flatMap(
756
777
  ({ freeGifts: t }) => t ? t.map((a) => a.productGID) : []
757
- ).filter((t) => t != null), oe = (e) => e.dealBars.flatMap(
778
+ ).filter((t) => t != null), de = (e) => e.dealBars.flatMap(
758
779
  ({ multipleGiftsSelectors: t }) => t ? t.flatMap(
759
- (a) => a.products ? a.products.map((l) => l.id) : []
780
+ (a) => a.products ? a.products.map((n) => n.id) : []
760
781
  ) : []
761
- ).filter((t) => t != null), ce = (e) => {
782
+ ).filter((t) => t != null), me = (e) => {
762
783
  var t;
763
784
  return e.progressiveGiftsEnabled ? ((t = e.progressiveGifts) == null ? void 0 : t.gifts.map((a) => a.productGID).filter((a) => a != null)) || [] : [];
764
- }, ue = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), de = (e) => e.dealBars.filter((t) => t.dealBarType === $.Bundle).flatMap(
785
+ }, pe = (e) => e.dealBars.flatMap(({ upsells: t }) => t ? t.map((a) => a.productGID) : []).filter((t) => t != null), fe = (e) => e.dealBars.filter((t) => t.dealBarType === $.Bundle).flatMap(
765
786
  ({ bundleProducts: t }) => t ? t.map((a) => a.productGID) : []
766
- ).filter((t) => t != null).filter((t) => t !== "default"), me = (e) => e.dealBars.filter((t) => t.dealBarType === $.MixAndMatch).flatMap(
787
+ ).filter((t) => t != null).filter((t) => t !== "default"), ye = (e) => e.dealBars.filter((t) => t.dealBarType === $.MixAndMatch).flatMap(
767
788
  ({ bundleProducts: t }) => t ? t.flatMap((a) => {
768
- var l;
789
+ var n;
769
790
  return [
770
791
  a.productGID,
771
- ...((l = a.selectedProducts) == null ? void 0 : l.map((n) => n.id)) ?? []
792
+ ...((n = a.selectedProducts) == null ? void 0 : n.map((s) => s.id)) ?? []
772
793
  ];
773
794
  }) : []
774
- ).filter((t) => t != null).filter((t) => t !== "default"), pe = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), fe = (e) => e.dealBars.filter((t) => t.dealBarType === $.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
775
- class ye {
795
+ ).filter((t) => t != null).filter((t) => t !== "default"), ge = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((t) => t.productGID).filter((t) => t != null), he = (e) => e.dealBars.filter((t) => t.dealBarType === $.Sku).flatMap(({ productGID: t }) => t ? [t] : []);
796
+ class q extends Error {
797
+ constructor({
798
+ status: t,
799
+ operationName: a,
800
+ graphqlErrors: n
801
+ }) {
802
+ const s = n.length ? `: ${n.join("; ")}` : "";
803
+ super(
804
+ `Storefront API ${a ?? "query"} failed (HTTP ${t})${s}`
805
+ ), this.name = "StorefrontApiError", this.status = t, this.operationName = a, this.graphqlErrors = n;
806
+ }
807
+ }
808
+ const be = async (e, t) => {
809
+ const a = await e.text();
810
+ if (!a)
811
+ throw new Error("Empty graphql response");
812
+ let n;
813
+ try {
814
+ n = JSON.parse(a);
815
+ } catch (s) {
816
+ throw e.ok ? s : new q({
817
+ status: e.status,
818
+ operationName: t,
819
+ graphqlErrors: []
820
+ });
821
+ }
822
+ if (!e.ok || n.data === null || n.data === void 0)
823
+ throw new q({
824
+ status: e.status,
825
+ operationName: t,
826
+ graphqlErrors: (n.errors ?? []).map(({ message: s }) => s).filter(Boolean)
827
+ });
828
+ return n.data;
829
+ };
830
+ class ve {
776
831
  constructor(t, a) {
777
832
  this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = a, this.shopifyDomain = t;
778
833
  }
779
834
  async query(t, a) {
780
- var r;
781
- const l = (a == null ? void 0 : a.variables) ?? {};
782
- let n = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
783
- const o = (r = t.match(/query\s+(\w+)/)) == null ? void 0 : r[1];
784
- o && (n += `?operation_name=${o}`);
785
- const u = await (await fetch(n, {
835
+ var i;
836
+ const n = (a == null ? void 0 : a.variables) ?? {};
837
+ let s = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`;
838
+ const l = (i = t.match(/query\s+(\w+)/)) == null ? void 0 : i[1];
839
+ l && (s += `?operation_name=${l}`);
840
+ const u = await fetch(s, {
786
841
  method: "POST",
787
842
  headers: {
788
843
  "Content-Type": "application/json",
@@ -790,167 +845,190 @@ class ye {
790
845
  },
791
846
  body: JSON.stringify({
792
847
  query: t,
793
- variables: l
848
+ variables: n
794
849
  })
795
- })).text();
796
- if (!u)
797
- throw new Error("Empty graphql response");
798
- return JSON.parse(u).data;
850
+ });
851
+ return be(u, l);
799
852
  }
800
853
  }
801
- const ge = async (e, t, { country: a, language: l }) => {
802
- const n = t.collectionBreaks;
803
- if (!t.collectionBreaksEnabled || !n) return;
804
- let o;
805
- n.visibility === "deal-products" ? o = await k(e, {
854
+ const Ie = async (e, t, { country: a, language: n }) => {
855
+ const s = t.collectionBreaks;
856
+ if (!t.collectionBreaksEnabled || !s) return;
857
+ let l;
858
+ s.visibility === "deal-products" ? l = await k(e, {
806
859
  country: a,
807
- language: l,
860
+ language: n,
808
861
  blockVisibility: t.blockVisibility,
809
862
  excludedProductGIDs: (t.excludedProductIds || []).map(
810
- (r) => `gid://shopify/Product/${r}`
863
+ (i) => `gid://shopify/Product/${i}`
811
864
  ),
812
865
  selectedProductGIDs: (t.selectedProductIds || []).map(
813
- (r) => `gid://shopify/Product/${r}`
866
+ (i) => `gid://shopify/Product/${i}`
814
867
  ),
815
868
  selectedCollectionGIDs: (t.selectedCollectionIds || []).map(
816
- (r) => `gid://shopify/Collection/${r}`
869
+ (i) => `gid://shopify/Collection/${i}`
817
870
  )
818
- }) : o = await k(e, {
871
+ }) : l = await k(e, {
819
872
  country: a,
820
- language: l,
821
- blockVisibility: n.visibility,
822
- excludedProductGIDs: (n.excludedProducts || []).map(
823
- ({ id: r }) => r
873
+ language: n,
874
+ blockVisibility: s.visibility,
875
+ excludedProductGIDs: (s.excludedProducts || []).map(
876
+ ({ id: i }) => i
824
877
  ),
825
- selectedProductGIDs: (n.selectedProducts || []).map(
826
- ({ id: r }) => r
878
+ selectedProductGIDs: (s.selectedProducts || []).map(
879
+ ({ id: i }) => i
827
880
  ),
828
- selectedCollectionGIDs: (n.selectedCollections || []).map(
829
- ({ id: r }) => r
881
+ selectedCollectionGIDs: (s.selectedCollections || []).map(
882
+ ({ id: i }) => i
830
883
  )
831
884
  });
832
885
  let u = await S(e, {
833
886
  country: a,
834
- language: l,
835
- productIds: o.map((r) => Number(r.split("/").pop())),
887
+ language: n,
888
+ productIds: l.map((i) => Number(i.split("/").pop())),
836
889
  useExternalMetafieldNamespace: !0
837
890
  });
838
891
  return u = u.filter(
839
- (r) => r.availableForSale
892
+ (i) => i.availableForSale
840
893
  ), u;
841
- }, he = () => ({
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
- }), be = "2026-07", _e = async (e, {
894
+ }, _e = ({
895
+ language: e,
896
+ dealBlockId: t
897
+ }) => {
898
+ const a = {
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
+ }, n = e ? Pe(e) : void 0;
924
+ return {
925
+ ...a,
926
+ ...n == null ? void 0 : n.system,
927
+ ...n == null ? void 0 : n.dealBlocks[t]
928
+ };
929
+ }, Pe = (e) => {
930
+ var s;
931
+ if (typeof document > "u") return;
932
+ const t = document.querySelector("script#kaching-bundles-translations");
933
+ if (!(t != null && t.textContent)) return;
934
+ let a;
935
+ try {
936
+ a = JSON.parse(t.textContent);
937
+ } catch {
938
+ return;
939
+ }
940
+ const n = M(e);
941
+ return (s = a.find(
942
+ (l) => M(l.locale) === n
943
+ )) == null ? void 0 : s.translations;
944
+ }, M = (e) => e.toLowerCase().replace(/_/g, "-"), $e = "2026-07", Se = async (e, {
867
945
  productId: t,
868
946
  dealBlockId: a,
869
- country: l = void 0,
870
- language: n = void 0
947
+ country: n = void 0,
948
+ language: s = void 0
871
949
  }) => {
872
- var o, u;
950
+ var l, u;
873
951
  try {
874
- const r = [Number(t.split("/").pop())], d = new ve(e);
875
- l = l || ((o = d.i18n) == null ? void 0 : o.country), n = n || ((u = d.i18n) == null ? void 0 : u.language);
876
- const m = await R(d, {
877
- language: n,
878
- country: l,
952
+ const i = [Number(t.split("/").pop())], d = new we(e);
953
+ n = n || ((l = d.i18n) == null ? void 0 : l.country), s = s || ((u = d.i18n) == null ? void 0 : u.language);
954
+ const c = await H(d, {
955
+ language: s,
956
+ country: n,
879
957
  useExternalMetafieldNamespace: !0
880
958
  });
881
- d.shopifyDomain = m.shopifyDomain;
882
- const p = m.storefrontAccessToken ? new ye(
883
- m.shopifyDomain,
884
- m.storefrontAccessToken
885
- ) : d, [b, g] = await Promise.all([
959
+ d.shopifyDomain = c.shopifyDomain;
960
+ const p = c.storefrontAccessToken ? new ve(
961
+ c.shopifyDomain,
962
+ c.storefrontAccessToken
963
+ ) : d, [f, h] = await Promise.all([
886
964
  S(p, {
887
- country: l,
888
- language: n,
889
- productIds: r,
965
+ country: n,
966
+ language: s,
967
+ productIds: i,
890
968
  useExternalMetafieldNamespace: !0
891
969
  }),
892
- F(p, {
970
+ V(p, {
893
971
  useExternalMetafieldNamespace: !0,
894
- useMetaobjects: m.featureFlags.storefront_metaobjects
972
+ useMetaobjects: c.featureFlags.storefront_metaobjects
895
973
  })
896
- ]), f = b[0];
897
- if (!f)
974
+ ]), y = f[0];
975
+ if (!y)
898
976
  return null;
899
- const v = q(g, f);
900
- let s;
901
- if (a ? (s = v.find(
977
+ const v = T(h, y);
978
+ let r;
979
+ if (a ? (r = v.find(
902
980
  (P) => P.id === a || P.nanoId === a
903
- ), s || (s = v[0])) : s = v[0], !s)
981
+ ), r || (r = v[0])) : r = v[0], !r)
904
982
  return null;
905
- const c = H(s), y = le(s), [_, i, h, I] = await Promise.all([
983
+ const o = W(r), g = ce(r), [_, I, m, b] = await Promise.all([
906
984
  S(p, {
907
- country: l,
908
- language: n,
909
- productIds: y,
985
+ country: n,
986
+ language: s,
987
+ productIds: g,
910
988
  useExternalMetafieldNamespace: !0
911
989
  }),
912
- L(p, c, 300),
913
- ge(p, s, {
914
- country: l,
915
- language: n
990
+ z(p, o, 300),
991
+ Ie(p, r, {
992
+ country: n,
993
+ language: s
916
994
  }),
917
- he()
995
+ _e({ language: s, dealBlockId: r.id })
918
996
  ]);
919
997
  return {
920
- product: f,
921
- dealBlock: s,
922
- config: m,
998
+ product: y,
999
+ dealBlock: r,
1000
+ config: c,
923
1001
  otherProducts: _,
924
- mediaImages: i,
925
- collectionBreaksProducts: h ?? [],
926
- translations: I
1002
+ mediaImages: I,
1003
+ collectionBreaksProducts: m ?? [],
1004
+ translations: b
927
1005
  };
928
- } catch (r) {
929
- return console.error(r), null;
1006
+ } catch (i) {
1007
+ return console.error(i), null;
930
1008
  }
931
1009
  };
932
- class ve {
1010
+ class we {
933
1011
  constructor(t) {
934
1012
  this.storefront = t, this.shopifyDomain = "";
935
1013
  }
936
1014
  async query(t, a) {
937
- var l;
1015
+ var n;
938
1016
  if ("query" in this.storefront && "i18n" in this.storefront)
939
1017
  return await this.storefront.query(t, a);
940
1018
  if ("graphql" in this.storefront) {
941
- const n = await this.storefront.graphql(t, a);
942
- if ((l = n.errors) != null && l.length)
1019
+ const s = await this.storefront.graphql(t, a);
1020
+ if ((n = s.errors) != null && n.length)
943
1021
  throw new Error(
944
- n.errors.map((o) => o.message).join(`
1022
+ s.errors.map((l) => l.message).join(`
945
1023
  `)
946
1024
  );
947
- return n.data;
1025
+ return s.data;
948
1026
  }
949
1027
  if ("request" in this.storefront)
950
1028
  return (await this.storefront.request(t, a)).data;
951
1029
  if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
952
- const n = await fetch(
953
- `https://${this.storefront.shopifyDomain}/api/${be}/graphql.json`,
1030
+ const s = await fetch(
1031
+ `https://${this.storefront.shopifyDomain}/api/${$e}/graphql.json`,
954
1032
  {
955
1033
  body: JSON.stringify({
956
1034
  query: t,
@@ -963,11 +1041,11 @@ class ve {
963
1041
  method: "POST"
964
1042
  }
965
1043
  );
966
- if (!n.ok)
967
- throw new Error(n.statusText);
968
- return (await n.json()).data;
1044
+ if (!s.ok)
1045
+ throw new Error(s.statusText);
1046
+ return (await s.json()).data;
969
1047
  } else {
970
- const n = await fetch(this.storefront.getStorefrontApiUrl(), {
1048
+ const s = await fetch(this.storefront.getStorefrontApiUrl(), {
971
1049
  body: JSON.stringify({
972
1050
  query: t,
973
1051
  variables: a == null ? void 0 : a.variables
@@ -975,9 +1053,9 @@ class ve {
975
1053
  headers: this.storefront.getPublicTokenHeaders(),
976
1054
  method: "POST"
977
1055
  });
978
- if (!n.ok)
979
- throw new Error(n.statusText);
980
- return (await n.json()).data;
1056
+ if (!s.ok)
1057
+ throw new Error(s.statusText);
1058
+ return (await s.json()).data;
981
1059
  }
982
1060
  }
983
1061
  get i18n() {
@@ -986,5 +1064,5 @@ class ve {
986
1064
  }
987
1065
  }
988
1066
  export {
989
- _e as fetchKachingBundlesData
1067
+ Se as fetchKachingBundlesData
990
1068
  };