@kachingappz/bundles-js 1.1.8 → 1.1.10
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/bundles-js.iife.js +39 -7
- package/dist/index.d.ts +31 -7
- package/dist/index.js +237 -94
- package/dist/kaching-bundle-component/index.d.ts +31 -7
- package/dist/kaching-bundle-component/index.js +288 -156
- package/dist/react/index.cjs +39 -7
- package/dist/react/index.d.ts +31 -7
- package/dist/react/index.js +277 -148
- package/package.json +3 -3
|
@@ -105,16 +105,16 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
105
105
|
return Array.from(new Set(i)).slice(0, c);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
}, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1,
|
|
108
|
+
}, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, includeProductTabFields: l = !1, productSubtitleMetafield: u = "descriptors.subtitle", useExternalMetafieldNamespace: d = !1, batchSize: f = 250, onBatchError: m, variantImageTransform: v = {
|
|
109
109
|
maxWidth: 200,
|
|
110
110
|
maxHeight: 200
|
|
111
111
|
} }) => {
|
|
112
112
|
if (!r.length) return [];
|
|
113
|
-
let
|
|
113
|
+
let y = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), b = s({
|
|
114
114
|
country: t,
|
|
115
115
|
language: n
|
|
116
|
-
}),
|
|
117
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${
|
|
116
|
+
}), x = `
|
|
117
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${b} {
|
|
118
118
|
shop {
|
|
119
119
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
120
120
|
value
|
|
@@ -177,6 +177,10 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
177
177
|
subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
|
|
178
178
|
value
|
|
179
179
|
}
|
|
180
|
+
category @include(if: $includeProductTabFields) {
|
|
181
|
+
id
|
|
182
|
+
}
|
|
183
|
+
tags @include(if: $includeProductTabFields)
|
|
180
184
|
requiresSellingPlan
|
|
181
185
|
sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
|
|
182
186
|
nodes {
|
|
@@ -184,6 +188,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
184
188
|
nodes {
|
|
185
189
|
id
|
|
186
190
|
name
|
|
191
|
+
recurringDeliveries
|
|
187
192
|
priceAdjustments {
|
|
188
193
|
adjustmentValue {
|
|
189
194
|
__typename
|
|
@@ -209,43 +214,63 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
|
-
`,
|
|
213
|
-
for (let e = 0; e <
|
|
214
|
-
let
|
|
215
|
-
let
|
|
216
|
-
productGIDs:
|
|
217
|
+
`, S = d ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", C = u.indexOf("."), w = u.slice(0, C), T = u.slice(C + 1), E = [], D = Math.min(f, 250);
|
|
218
|
+
for (let e = 0; e < y.length; e += D) E.push(y.slice(e, e + D));
|
|
219
|
+
let O = 1, k = async (n) => {
|
|
220
|
+
let [r, s] = await Promise.all([e.query(x, { variables: {
|
|
221
|
+
productGIDs: n,
|
|
217
222
|
includeSellingPlans: i,
|
|
218
223
|
includeAvailableQuantity: a,
|
|
219
224
|
includeProductRating: o,
|
|
220
225
|
includeProductSubtitle: c,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
includeProductTabFields: l,
|
|
227
|
+
subtitleNamespace: w,
|
|
228
|
+
subtitleKey: T,
|
|
229
|
+
metafieldNamespace: S,
|
|
230
|
+
variantImageTransform: v
|
|
231
|
+
} }), l ? h(e, t, n) : null]);
|
|
232
|
+
return r.shop.currencyRateConstant && (O = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), s ? { nodes: r.nodes.map((e) => e && {
|
|
233
|
+
...e,
|
|
234
|
+
productType: s.get(e.id)
|
|
235
|
+
}) } : r;
|
|
236
|
+
}, A;
|
|
237
|
+
if (m) {
|
|
238
|
+
let e = await Promise.allSettled(E.map(k));
|
|
239
|
+
for (let t of e) t.status === "rejected" && m(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
|
|
240
|
+
A = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
|
|
241
|
+
} else A = (await Promise.all(E.map(k))).flatMap((e) => e.nodes);
|
|
242
|
+
let j = A.filter((e) => e != null);
|
|
243
|
+
if (m) {
|
|
244
|
+
let t = await Promise.allSettled(j.map(async (t) => _(await g(e, t, {
|
|
236
245
|
includeSellingPlans: i,
|
|
237
246
|
includeAvailableQuantity: a,
|
|
238
|
-
variantImageTransform:
|
|
239
|
-
},
|
|
240
|
-
for (let e of t) e.status === "fulfilled" ? n.push(e.value) :
|
|
247
|
+
variantImageTransform: v
|
|
248
|
+
}, b), e.shopifyDomain, O))), n = [];
|
|
249
|
+
for (let e of t) e.status === "fulfilled" ? n.push(e.value) : m(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
|
|
241
250
|
return n;
|
|
242
251
|
}
|
|
243
|
-
return (await Promise.all(
|
|
252
|
+
return (await Promise.all(j.map((t) => g(e, t, {
|
|
244
253
|
includeSellingPlans: i,
|
|
245
254
|
includeAvailableQuantity: a,
|
|
246
|
-
variantImageTransform:
|
|
247
|
-
},
|
|
248
|
-
}, h = async (e, t, n
|
|
255
|
+
variantImageTransform: v
|
|
256
|
+
}, b)))).map((t) => _(t, e.shopifyDomain, O));
|
|
257
|
+
}, h = async (e, t, n) => {
|
|
258
|
+
try {
|
|
259
|
+
let r = await e.query(`
|
|
260
|
+
query FetchProductTypes($productGIDs: [ID!]!) ${s({ country: t })} {
|
|
261
|
+
nodes(ids: $productGIDs) {
|
|
262
|
+
... on Product {
|
|
263
|
+
id
|
|
264
|
+
productType
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
`, { variables: { productGIDs: n } });
|
|
269
|
+
return new Map(r.nodes.filter((e) => e != null).map((e) => [e.id, e.productType]));
|
|
270
|
+
} catch (e) {
|
|
271
|
+
return console.error(e), null;
|
|
272
|
+
}
|
|
273
|
+
}, g = async (e, t, n, r = "") => {
|
|
249
274
|
if (t.variants.nodes.length < 250) return t;
|
|
250
275
|
let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
|
|
251
276
|
let c = !0, l = null;
|
|
@@ -281,7 +306,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
281
306
|
}
|
|
282
307
|
};
|
|
283
308
|
return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
|
|
284
|
-
},
|
|
309
|
+
}, _ = (e, t, n) => {
|
|
285
310
|
let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
|
|
286
311
|
id: Number(t.id.split("/").pop()),
|
|
287
312
|
availableForSale: t.availableForSale,
|
|
@@ -319,7 +344,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
319
344
|
defaultName: e.name,
|
|
320
345
|
name: e.name,
|
|
321
346
|
position: t + 1,
|
|
322
|
-
optionValues:
|
|
347
|
+
optionValues: b(n, t, r)
|
|
323
348
|
};
|
|
324
349
|
}), a = (e) => {
|
|
325
350
|
let t = e.priceAdjustments[0];
|
|
@@ -343,6 +368,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
343
368
|
}, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
|
|
344
369
|
id: Number(e.id.split("/").pop()),
|
|
345
370
|
name: e.name,
|
|
371
|
+
recurringDeliveries: e.recurringDeliveries,
|
|
346
372
|
priceAdjustment: a(e)
|
|
347
373
|
}))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
|
|
348
374
|
return {
|
|
@@ -366,27 +392,45 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
366
392
|
text3: e.metafield3?.value || null,
|
|
367
393
|
text4: e.metafield4?.value || null
|
|
368
394
|
},
|
|
369
|
-
rating:
|
|
370
|
-
subtitle: e.subtitle?.value || null
|
|
395
|
+
rating: v(e.reviewsRating, e.reviewsRatingCount),
|
|
396
|
+
subtitle: e.subtitle?.value || null,
|
|
397
|
+
productType: e.productType || null,
|
|
398
|
+
categoryGid: e.category?.id ?? null,
|
|
399
|
+
tags: e.tags ?? []
|
|
371
400
|
};
|
|
372
|
-
},
|
|
401
|
+
}, v = (e, t) => {
|
|
373
402
|
if (!e) return null;
|
|
374
|
-
let n =
|
|
403
|
+
let n = y(e.value);
|
|
375
404
|
if (n === null) return null;
|
|
376
405
|
let r = Number(t?.value);
|
|
377
406
|
return {
|
|
378
407
|
value: n,
|
|
379
408
|
count: Number.isInteger(r) && r > 0 ? r : null
|
|
380
409
|
};
|
|
381
|
-
},
|
|
410
|
+
}, y = (e) => {
|
|
382
411
|
try {
|
|
383
412
|
let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
|
|
384
413
|
return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
|
|
385
414
|
} catch {
|
|
386
415
|
return null;
|
|
387
416
|
}
|
|
388
|
-
},
|
|
389
|
-
|
|
417
|
+
}, b = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0);
|
|
418
|
+
[
|
|
419
|
+
"primaryBackground",
|
|
420
|
+
"secondaryBackground",
|
|
421
|
+
"primaryText",
|
|
422
|
+
"secondaryText",
|
|
423
|
+
"border",
|
|
424
|
+
"overlay",
|
|
425
|
+
"primaryAccent",
|
|
426
|
+
"primaryAccentText",
|
|
427
|
+
"badgeBackground",
|
|
428
|
+
"badgeText",
|
|
429
|
+
"error"
|
|
430
|
+
].map((e) => `brand_${e}`);
|
|
431
|
+
// ../bundles-storefront-api/dist/fetchGlobalConfig.js
|
|
432
|
+
var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
|
|
433
|
+
let a = i ? `${x}--kaching_bundles` : "$app:kaching_bundles", o = i ? x : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
|
|
390
434
|
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
|
|
391
435
|
localization {
|
|
392
436
|
country {
|
|
@@ -417,7 +461,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
417
461
|
} }), h = l === d ? u : e(l, {
|
|
418
462
|
language: n,
|
|
419
463
|
country: r
|
|
420
|
-
}), g = f ?
|
|
464
|
+
}), g = f ? C(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
|
|
421
465
|
return {
|
|
422
466
|
shopifyDomain: p.host,
|
|
423
467
|
moneyFormat: h,
|
|
@@ -478,7 +522,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
478
522
|
featureFlags: v,
|
|
479
523
|
brandColors: _?.brand_colors ?? null
|
|
480
524
|
};
|
|
481
|
-
},
|
|
525
|
+
}, C = (e) => JSON.parse(e).amount / 1e6, w = async (e, t, n = 200) => {
|
|
482
526
|
let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
|
|
483
527
|
if (r.length === 0) return [];
|
|
484
528
|
let i = [];
|
|
@@ -490,77 +534,103 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
490
534
|
gid: e.id,
|
|
491
535
|
url: e.image.url
|
|
492
536
|
}] : []);
|
|
493
|
-
},
|
|
494
|
-
...
|
|
495
|
-
|
|
496
|
-
|
|
537
|
+
}, T = 100, E = async (e, { dealBlock: t, country: n, language: r }) => {
|
|
538
|
+
let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === d.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
|
|
539
|
+
if (i.length === 0) return [];
|
|
540
|
+
let a = s({
|
|
541
|
+
country: n,
|
|
542
|
+
language: r
|
|
543
|
+
}), o = await e.query(`
|
|
544
|
+
query FetchMixAndMatchCollectionProductGIDs($collectionGIDs: [ID!]!) ${a} {
|
|
545
|
+
nodes(ids: $collectionGIDs) {
|
|
546
|
+
... on Collection {
|
|
547
|
+
id
|
|
548
|
+
products(first: ${T}) {
|
|
549
|
+
nodes {
|
|
550
|
+
id
|
|
551
|
+
variants(first: 1) {
|
|
552
|
+
nodes {
|
|
553
|
+
requiresComponents
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
`, { variables: { collectionGIDs: i } });
|
|
562
|
+
return [...new Set(o.nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes).filter((e) => !e.variants.nodes.some((e) => e.requiresComponents)).map((e) => e.id))];
|
|
563
|
+
}, D = (e) => [
|
|
497
564
|
...O(e),
|
|
498
565
|
...k(e),
|
|
499
566
|
...A(e),
|
|
500
567
|
...j(e),
|
|
501
568
|
...M(e),
|
|
569
|
+
...N(e),
|
|
570
|
+
...P(e),
|
|
502
571
|
...ee(e),
|
|
503
572
|
...te(e),
|
|
504
573
|
...ne(e),
|
|
505
574
|
...re(e),
|
|
506
|
-
...ie(e)
|
|
507
|
-
|
|
575
|
+
...ie(e),
|
|
576
|
+
...ae(e)
|
|
577
|
+
].filter((e) => e != null && !e.includes("placeholder")), O = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), k = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), A = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), j = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), M = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), N = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
|
|
508
578
|
let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
|
|
509
579
|
return [...e, ...n];
|
|
510
|
-
}, []) : [],
|
|
580
|
+
}, []) : [], P = (e) => {
|
|
511
581
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
512
582
|
let t = e.collectionBreaks.mediaImageGID;
|
|
513
583
|
return t ? [t] : [];
|
|
514
|
-
},
|
|
584
|
+
}, ee = (e) => e.progressiveGifts ? [
|
|
515
585
|
...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
|
|
516
586
|
e.progressiveGifts.style?.lockedMediaImageGID,
|
|
517
587
|
e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
|
|
518
|
-
].filter((e) => e != null) : [],
|
|
588
|
+
].filter((e) => e != null) : [], te = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ne = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), re = (e) => {
|
|
519
589
|
let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
|
|
520
590
|
return n ? [...t, n] : t;
|
|
521
|
-
},
|
|
522
|
-
let
|
|
523
|
-
...oe(e),
|
|
591
|
+
}, ie = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), ae = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], oe = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
|
|
592
|
+
let n = [
|
|
524
593
|
...se(e),
|
|
525
594
|
...ce(e),
|
|
526
595
|
...le(e),
|
|
527
596
|
...ue(e),
|
|
528
|
-
...
|
|
529
|
-
...
|
|
530
|
-
...F(e)
|
|
597
|
+
...de(e),
|
|
598
|
+
...fe(e, t),
|
|
599
|
+
...F(e),
|
|
600
|
+
...I(e)
|
|
531
601
|
];
|
|
532
|
-
return Array.from(new Set(
|
|
533
|
-
},
|
|
602
|
+
return Array.from(new Set(n.filter((e) => e != null)));
|
|
603
|
+
}, se = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), ce = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), le = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], ue = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), de = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), fe = (e, t) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), F = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), I = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), L = class extends Error {
|
|
534
604
|
constructor({ status: e, operationName: t, graphqlErrors: n }) {
|
|
535
605
|
let r = n.length ? `: ${n.join("; ")}` : "";
|
|
536
606
|
super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
|
|
537
607
|
}
|
|
538
|
-
},
|
|
608
|
+
}, R = async (e, t) => {
|
|
539
609
|
let n = await e.text();
|
|
540
610
|
if (!n) throw Error("Empty graphql response");
|
|
541
611
|
let r;
|
|
542
612
|
try {
|
|
543
613
|
r = JSON.parse(n);
|
|
544
614
|
} catch (n) {
|
|
545
|
-
throw e.ok ? n : new
|
|
615
|
+
throw e.ok ? n : new L({
|
|
546
616
|
status: e.status,
|
|
547
617
|
operationName: t,
|
|
548
618
|
graphqlErrors: []
|
|
549
619
|
});
|
|
550
620
|
}
|
|
551
|
-
if (!e.ok || r.data === null || r.data === void 0) throw new
|
|
621
|
+
if (!e.ok || r.data === null || r.data === void 0) throw new L({
|
|
552
622
|
status: e.status,
|
|
553
623
|
operationName: t,
|
|
554
624
|
graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
|
|
555
625
|
});
|
|
556
626
|
return r.data;
|
|
557
|
-
},
|
|
627
|
+
}, z = class {
|
|
558
628
|
constructor(e, t) {
|
|
559
629
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
|
|
560
630
|
}
|
|
561
631
|
async query(e, t) {
|
|
562
632
|
let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
|
|
563
|
-
return i && (r += `?operation_name=${i}`),
|
|
633
|
+
return i && (r += `?operation_name=${i}`), R(await fetch(r, {
|
|
564
634
|
method: "POST",
|
|
565
635
|
headers: {
|
|
566
636
|
"Content-Type": "application/json",
|
|
@@ -572,7 +642,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
572
642
|
})
|
|
573
643
|
}), i);
|
|
574
644
|
}
|
|
575
|
-
},
|
|
645
|
+
}, B = (e, t) => {
|
|
576
646
|
let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
|
|
577
647
|
for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
|
|
578
648
|
let i = e.filter((e) => e.blockVisibility === "selected-collections");
|
|
@@ -582,7 +652,23 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
582
652
|
let o = e.filter((e) => e.blockVisibility === "all-products");
|
|
583
653
|
for (let e of o) n.push(e);
|
|
584
654
|
return n;
|
|
585
|
-
}
|
|
655
|
+
};
|
|
656
|
+
[
|
|
657
|
+
"primaryBackground",
|
|
658
|
+
"secondaryBackground",
|
|
659
|
+
"primaryText",
|
|
660
|
+
"secondaryText",
|
|
661
|
+
"border",
|
|
662
|
+
"overlay",
|
|
663
|
+
"primaryAccent",
|
|
664
|
+
"primaryAccentText",
|
|
665
|
+
"badgeBackground",
|
|
666
|
+
"badgeText",
|
|
667
|
+
"error"
|
|
668
|
+
].map((e) => `brand_${e}`);
|
|
669
|
+
var V = /* @__PURE__ */ function(e) {
|
|
670
|
+
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
671
|
+
}({}), pe = async (e, t, { country: n, language: r }) => {
|
|
586
672
|
let i = t.collectionBreaks;
|
|
587
673
|
if (!t.collectionBreaksEnabled || !i) return;
|
|
588
674
|
let a;
|
|
@@ -607,8 +693,8 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
607
693
|
productIds: a.map((e) => Number(e.split("/").pop())),
|
|
608
694
|
useExternalMetafieldNamespace: !0
|
|
609
695
|
}), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
|
|
610
|
-
return o = o.filter((e) => e.availableForSale && (!s ||
|
|
611
|
-
},
|
|
696
|
+
return o = o.filter((e) => e.availableForSale && (!s || B([t], e).length > 0)), o;
|
|
697
|
+
}, me = ({ language: e, dealBlockId: t }) => {
|
|
612
698
|
let n = {
|
|
613
699
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
614
700
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
@@ -635,13 +721,13 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
635
721
|
"system.numbers_only": "Only numbers are allowed.",
|
|
636
722
|
"system.personalisation_required_alert": "Please add personalisation for every item to continue.",
|
|
637
723
|
"system.gifts_required_alert": "Please choose your free gifts"
|
|
638
|
-
}, r = e ?
|
|
724
|
+
}, r = e ? he(e) : void 0;
|
|
639
725
|
return {
|
|
640
726
|
...n,
|
|
641
727
|
...r?.system,
|
|
642
728
|
...r?.dealBlocks[t]
|
|
643
729
|
};
|
|
644
|
-
},
|
|
730
|
+
}, he = (e) => {
|
|
645
731
|
if (typeof document > "u") return;
|
|
646
732
|
let t = document.querySelector("script#kaching-bundles-translations");
|
|
647
733
|
if (!t?.textContent) return;
|
|
@@ -651,19 +737,19 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
651
737
|
} catch {
|
|
652
738
|
return;
|
|
653
739
|
}
|
|
654
|
-
let r =
|
|
655
|
-
return n.find((e) =>
|
|
656
|
-
},
|
|
740
|
+
let r = H(e);
|
|
741
|
+
return n.find((e) => H(e.locale) === r)?.translations;
|
|
742
|
+
}, H = (e) => e.toLowerCase().replace(/_/g, "-"), ge = "2026-07", U = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
|
|
657
743
|
try {
|
|
658
|
-
let o = [Number(t.split("/").pop())], s = new
|
|
744
|
+
let o = [Number(t.split("/").pop())], s = new xe(e);
|
|
659
745
|
i ||= s.i18n?.country, a ||= s.i18n?.language;
|
|
660
|
-
let l = await
|
|
746
|
+
let l = await S(s, {
|
|
661
747
|
language: a,
|
|
662
748
|
country: i,
|
|
663
749
|
useExternalMetafieldNamespace: !0
|
|
664
750
|
});
|
|
665
751
|
s.shopifyDomain = l.shopifyDomain;
|
|
666
|
-
let u = l.storefrontAccessToken ? new
|
|
752
|
+
let u = l.storefrontAccessToken ? new z(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
|
|
667
753
|
country: i,
|
|
668
754
|
language: a,
|
|
669
755
|
productIds: o,
|
|
@@ -673,38 +759,77 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
673
759
|
useMetaobjects: l.featureFlags.storefront_metaobjects
|
|
674
760
|
})]), p = d[0];
|
|
675
761
|
if (!p) return null;
|
|
676
|
-
let h =
|
|
762
|
+
let h = B(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
|
|
677
763
|
if (!_) return null;
|
|
678
|
-
let v =
|
|
764
|
+
let v = oe(_, { includeMixAndMatchSwapProducts: !1 }), y = _e(u, _, {
|
|
765
|
+
otherProductGIDs: v,
|
|
766
|
+
country: i,
|
|
767
|
+
language: a
|
|
768
|
+
}), [b, x, C] = await Promise.all([
|
|
679
769
|
m(u, {
|
|
680
770
|
country: i,
|
|
681
771
|
language: a,
|
|
682
|
-
productIds:
|
|
772
|
+
productIds: v,
|
|
683
773
|
useExternalMetafieldNamespace: !0
|
|
684
774
|
}),
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
country: i,
|
|
688
|
-
language: a
|
|
689
|
-
}),
|
|
690
|
-
V({
|
|
775
|
+
w(u, D(_), 300),
|
|
776
|
+
me({
|
|
691
777
|
language: a,
|
|
692
778
|
dealBlockId: _.id
|
|
693
779
|
})
|
|
694
780
|
]);
|
|
695
781
|
return {
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
782
|
+
data: {
|
|
783
|
+
config: l,
|
|
784
|
+
dealBlock: _,
|
|
785
|
+
product: p,
|
|
786
|
+
otherProducts: b,
|
|
787
|
+
mediaImages: x,
|
|
788
|
+
translations: C
|
|
789
|
+
},
|
|
790
|
+
modalProducts: y
|
|
703
791
|
};
|
|
704
792
|
} catch (e) {
|
|
705
793
|
return console.error(e), null;
|
|
706
794
|
}
|
|
707
|
-
},
|
|
795
|
+
}, _e = async (e, t, n) => {
|
|
796
|
+
let [r, i] = await Promise.all([ve(e, t, n), be(e, t, n)]);
|
|
797
|
+
return {
|
|
798
|
+
mixAndMatchSwapProducts: r,
|
|
799
|
+
collectionBreaksProducts: i
|
|
800
|
+
};
|
|
801
|
+
}, ve = async (e, t, { otherProductGIDs: n, country: r, language: i }) => {
|
|
802
|
+
try {
|
|
803
|
+
let a = [];
|
|
804
|
+
try {
|
|
805
|
+
a = await E(e, {
|
|
806
|
+
dealBlock: t,
|
|
807
|
+
country: r,
|
|
808
|
+
language: i
|
|
809
|
+
});
|
|
810
|
+
} catch (e) {
|
|
811
|
+
console.error(e);
|
|
812
|
+
}
|
|
813
|
+
let o = new Set(n), s = [.../* @__PURE__ */ new Set([...ye(t), ...a])].filter((e) => !o.has(e));
|
|
814
|
+
return s.length ? await m(e, {
|
|
815
|
+
country: r,
|
|
816
|
+
language: i,
|
|
817
|
+
productIds: s,
|
|
818
|
+
useExternalMetafieldNamespace: !0
|
|
819
|
+
}) : [];
|
|
820
|
+
} catch (e) {
|
|
821
|
+
return console.error(e), [];
|
|
822
|
+
}
|
|
823
|
+
}, ye = (e) => e.dealBars.flatMap((e) => e.dealBarType === V.MixAndMatch ? e.bundleProducts.flatMap((e) => (e.selectedProducts ?? []).map((e) => e.id)) : []), be = async (e, t, { country: n, language: r }) => {
|
|
824
|
+
try {
|
|
825
|
+
return await pe(e, t, {
|
|
826
|
+
country: n,
|
|
827
|
+
language: r
|
|
828
|
+
}) ?? [];
|
|
829
|
+
} catch (e) {
|
|
830
|
+
return console.error(e), [];
|
|
831
|
+
}
|
|
832
|
+
}, xe = class {
|
|
708
833
|
constructor(e) {
|
|
709
834
|
this.storefront = e, this.shopifyDomain = "";
|
|
710
835
|
}
|
|
@@ -717,7 +842,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
717
842
|
}
|
|
718
843
|
if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
|
|
719
844
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
720
|
-
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${
|
|
845
|
+
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ge}/graphql.json`, {
|
|
721
846
|
body: JSON.stringify({
|
|
722
847
|
query: e,
|
|
723
848
|
variables: t?.variables
|
|
@@ -747,62 +872,46 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
747
872
|
get i18n() {
|
|
748
873
|
if ("i18n" in this.storefront) return this.storefront.i18n;
|
|
749
874
|
}
|
|
750
|
-
},
|
|
875
|
+
}, W = "kaching-bundles-block", G = 1e4, K = "/kaching-bundles-block.js", Se = "https://bundles-integrations-dev.kachingappz.dev/kaching-bundles-block.js", Ce = "https://bundles-integrations.kachingappz.app/kaching-bundles-block.js", q = /* @__PURE__ */ new WeakSet(), J = async (e) => {
|
|
751
876
|
let t = e.document;
|
|
752
|
-
if (!e.customElements.get(
|
|
753
|
-
if (
|
|
754
|
-
|
|
877
|
+
if (!e.customElements.get(W)) {
|
|
878
|
+
if (q.has(t)) return Z(e, W);
|
|
879
|
+
q.add(t);
|
|
755
880
|
try {
|
|
756
|
-
await
|
|
881
|
+
await Te(e);
|
|
757
882
|
} catch (e) {
|
|
758
|
-
throw
|
|
883
|
+
throw q.delete(t), e;
|
|
759
884
|
}
|
|
760
885
|
}
|
|
761
|
-
},
|
|
762
|
-
let t = e.document, n =
|
|
763
|
-
if (t.querySelector(`script[src="${n}"]`)) return
|
|
764
|
-
let r =
|
|
765
|
-
if (r && await
|
|
886
|
+
}, we = () => typeof window < "u" && window.__KACHING_DEV__ !== void 0, Y = () => we() ? Se : Ce, Te = async (e) => {
|
|
887
|
+
let t = e.document, n = Y();
|
|
888
|
+
if (t.querySelector(`script[src="${n}"]`)) return Z(e, W);
|
|
889
|
+
let r = Ee(t);
|
|
890
|
+
if (r && await Oe(t, r)) return Z(e, W);
|
|
766
891
|
let i = t.createElement("script");
|
|
767
|
-
return i.src = n, await
|
|
768
|
-
},
|
|
769
|
-
let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${
|
|
770
|
-
return Array.from(t, (e) => e.href).find(
|
|
771
|
-
},
|
|
892
|
+
return i.src = n, await X(t, i), Z(e, W);
|
|
893
|
+
}, Ee = (e) => {
|
|
894
|
+
let t = e.querySelectorAll(`link[rel="modulepreload"][href$="${K}"]`);
|
|
895
|
+
return Array.from(t, (e) => e.href).find(De);
|
|
896
|
+
}, De = (e) => {
|
|
772
897
|
try {
|
|
773
|
-
return new URL(e).pathname.endsWith(
|
|
898
|
+
return new URL(e).pathname.endsWith(K);
|
|
774
899
|
} catch {
|
|
775
900
|
return !1;
|
|
776
901
|
}
|
|
777
|
-
},
|
|
902
|
+
}, Oe = async (e, t) => {
|
|
778
903
|
let n = e.createElement("script");
|
|
779
904
|
n.type = "module", n.setAttribute("crossorigin", "anonymous"), n.src = t;
|
|
780
905
|
try {
|
|
781
|
-
return await
|
|
906
|
+
return await X(e, n), !0;
|
|
782
907
|
} catch {
|
|
783
908
|
return n.remove(), !1;
|
|
784
909
|
}
|
|
785
|
-
},
|
|
910
|
+
}, X = (e, t) => new Promise((n, r) => {
|
|
786
911
|
t.onload = () => n(), t.onerror = () => r(/* @__PURE__ */ Error("Failed to load script")), e.head.appendChild(t);
|
|
787
|
-
}),
|
|
788
|
-
e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${
|
|
789
|
-
})
|
|
790
|
-
[
|
|
791
|
-
"primaryBackground",
|
|
792
|
-
"secondaryBackground",
|
|
793
|
-
"primaryText",
|
|
794
|
-
"secondaryText",
|
|
795
|
-
"border",
|
|
796
|
-
"overlay",
|
|
797
|
-
"primaryAccent",
|
|
798
|
-
"primaryAccentText",
|
|
799
|
-
"badgeBackground",
|
|
800
|
-
"badgeText",
|
|
801
|
-
"error"
|
|
802
|
-
].map((e) => `brand_${e}`);
|
|
803
|
-
var $ = /* @__PURE__ */ function(e) {
|
|
804
|
-
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
805
|
-
}({}), be = {
|
|
912
|
+
}), Z = (e, t) => new Promise((n, r) => {
|
|
913
|
+
e.customElements.get(t) ? n() : Promise.race([e.customElements.whenDefined(t), new Promise((e, n) => setTimeout(() => n(/* @__PURE__ */ Error(`Custom element "${t}" failed to register within ${G}ms`)), G))]).then(() => n()).catch(r);
|
|
914
|
+
}), Q = {
|
|
806
915
|
config: {
|
|
807
916
|
shopifyDomain: "",
|
|
808
917
|
moneyFormat: "${{amount}}",
|
|
@@ -1052,7 +1161,7 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1052
1161
|
dealBars: [
|
|
1053
1162
|
{
|
|
1054
1163
|
id: "single",
|
|
1055
|
-
dealBarType:
|
|
1164
|
+
dealBarType: V.QuantityBreak,
|
|
1056
1165
|
quantitySelector: !1,
|
|
1057
1166
|
title: "Single",
|
|
1058
1167
|
subtitle: "Standard price",
|
|
@@ -1077,7 +1186,7 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1077
1186
|
},
|
|
1078
1187
|
{
|
|
1079
1188
|
id: "duo",
|
|
1080
|
-
dealBarType:
|
|
1189
|
+
dealBarType: V.QuantityBreak,
|
|
1081
1190
|
quantitySelector: !1,
|
|
1082
1191
|
title: "Duo",
|
|
1083
1192
|
subtitle: "You save 20%",
|
|
@@ -1102,7 +1211,7 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1102
1211
|
},
|
|
1103
1212
|
{
|
|
1104
1213
|
id: "trio",
|
|
1105
|
-
dealBarType:
|
|
1214
|
+
dealBarType: V.QuantityBreak,
|
|
1106
1215
|
quantitySelector: !1,
|
|
1107
1216
|
title: "Trio",
|
|
1108
1217
|
subtitle: "You save 25%",
|
|
@@ -1198,10 +1307,29 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1198
1307
|
isNativeBundle: !1
|
|
1199
1308
|
},
|
|
1200
1309
|
otherProducts: [],
|
|
1310
|
+
mixAndMatchSwapProducts: [],
|
|
1201
1311
|
mediaImages: [],
|
|
1202
1312
|
collectionBreaksProducts: [],
|
|
1203
1313
|
translations: {}
|
|
1204
|
-
},
|
|
1314
|
+
}, ke = async (e, t) => {
|
|
1315
|
+
try {
|
|
1316
|
+
let n = await U(e, t);
|
|
1317
|
+
if (!n) return null;
|
|
1318
|
+
let { config: r, dealBlock: i, product: a, otherProducts: o, mediaImages: s, translations: c } = n.data, { mixAndMatchSwapProducts: l, collectionBreaksProducts: u } = await n.modalProducts;
|
|
1319
|
+
return {
|
|
1320
|
+
config: r,
|
|
1321
|
+
dealBlock: i,
|
|
1322
|
+
product: a,
|
|
1323
|
+
otherProducts: o,
|
|
1324
|
+
mixAndMatchSwapProducts: l,
|
|
1325
|
+
mediaImages: s,
|
|
1326
|
+
collectionBreaksProducts: u,
|
|
1327
|
+
translations: c
|
|
1328
|
+
};
|
|
1329
|
+
} catch (e) {
|
|
1330
|
+
return console.error(e), null;
|
|
1331
|
+
}
|
|
1332
|
+
}, Ae = class extends HTMLElement {
|
|
1205
1333
|
constructor(...e) {
|
|
1206
1334
|
super(...e), this.innerElement = null, this.handleItemsChanged = null, this.initializeId = 0;
|
|
1207
1335
|
}
|
|
@@ -1219,13 +1347,13 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1219
1347
|
async initialize() {
|
|
1220
1348
|
let e = ++this.initializeId;
|
|
1221
1349
|
if (this.cleanup(), this.hasAttribute("demo")) {
|
|
1222
|
-
if (await
|
|
1223
|
-
this.renderInnerElement(
|
|
1350
|
+
if (await J(window), e !== this.initializeId) return;
|
|
1351
|
+
$(this.renderInnerElement(Q), Q);
|
|
1224
1352
|
return;
|
|
1225
1353
|
}
|
|
1226
1354
|
let t = this.getAttribute("shop-domain"), n = this.getAttribute("storefront-token"), r = this.getAttribute("product-id");
|
|
1227
1355
|
if (!t || !n || !r) return;
|
|
1228
|
-
let [i] = await Promise.all([
|
|
1356
|
+
let [i] = await Promise.all([U({
|
|
1229
1357
|
shopifyDomain: t,
|
|
1230
1358
|
storefrontAccessToken: n
|
|
1231
1359
|
}, {
|
|
@@ -1234,29 +1362,31 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1234
1362
|
abTestVariantId: this.getAttribute("ab-test-variant-id") ?? void 0,
|
|
1235
1363
|
country: this.getAttribute("country")?.toUpperCase() ?? void 0,
|
|
1236
1364
|
language: this.getAttribute("language")?.toUpperCase() ?? void 0
|
|
1237
|
-
}),
|
|
1238
|
-
i
|
|
1365
|
+
}), J(window)]);
|
|
1366
|
+
if (!i || e !== this.initializeId) return;
|
|
1367
|
+
let a = this.renderInnerElement(i.data), o = await i.modalProducts;
|
|
1368
|
+
e === this.initializeId && this.innerElement === a && $(a, o);
|
|
1239
1369
|
}
|
|
1240
1370
|
renderInnerElement(e) {
|
|
1241
|
-
let { config: t, dealBlock: n, product: r, otherProducts: i, mediaImages: a,
|
|
1242
|
-
this.innerElement = document.createElement("kaching-bundles-block"), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(t)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute("media-images", JSON.stringify(a ?? [])), this.innerElement.setAttribute("product", JSON.stringify(r)), this.innerElement.setAttribute("other-products", JSON.stringify(i ?? [])), this.innerElement.setAttribute("
|
|
1243
|
-
let
|
|
1244
|
-
this.innerElement.setAttribute("current-variant-id", String(
|
|
1245
|
-
let
|
|
1246
|
-
if (this.innerElement !==
|
|
1247
|
-
let e =
|
|
1371
|
+
let { config: t, dealBlock: n, product: r, otherProducts: i, mediaImages: a, translations: o } = e;
|
|
1372
|
+
this.innerElement = document.createElement("kaching-bundles-block"), this.innerElement.setAttribute("deal-block-id", n.id), this.innerElement.setAttribute("config", JSON.stringify(t)), this.innerElement.setAttribute("deal-block", JSON.stringify(n)), this.innerElement.setAttribute("media-images", JSON.stringify(a ?? [])), this.innerElement.setAttribute("product", JSON.stringify(r)), this.innerElement.setAttribute("other-products", JSON.stringify(i ?? [])), this.innerElement.setAttribute("translations", JSON.stringify(o ?? {}));
|
|
1373
|
+
let s = this.getAttribute("selected-variant-id");
|
|
1374
|
+
this.innerElement.setAttribute("current-variant-id", String(s ? s.split("/").pop() : r.variants[0].id)), this.hasAttribute("compact") && this.innerElement.setAttribute("compact", "");
|
|
1375
|
+
let c = this.innerElement, l = () => {
|
|
1376
|
+
if (this.innerElement !== c) return;
|
|
1377
|
+
let e = c.items();
|
|
1248
1378
|
e && this.dispatchEvent(new CustomEvent("items-changed", {
|
|
1249
1379
|
detail: { items: e },
|
|
1250
1380
|
bubbles: !0
|
|
1251
1381
|
}));
|
|
1252
1382
|
};
|
|
1253
1383
|
this.handleItemsChanged = (e) => {
|
|
1254
|
-
e.stopPropagation(),
|
|
1384
|
+
e.stopPropagation(), l();
|
|
1255
1385
|
};
|
|
1256
|
-
let
|
|
1257
|
-
|
|
1258
|
-
this.innerElement ===
|
|
1259
|
-
}, { once: !0 }), this.appendChild(
|
|
1386
|
+
let u = this.handleItemsChanged;
|
|
1387
|
+
return c.addEventListener("kaching-bundles-block-loaded", () => {
|
|
1388
|
+
this.innerElement === c && (c.addEventListener("items-changed", u), this.dispatchEvent(new CustomEvent("loaded", { bubbles: !0 })));
|
|
1389
|
+
}, { once: !0 }), this.appendChild(c), c;
|
|
1260
1390
|
}
|
|
1261
1391
|
cleanup() {
|
|
1262
1392
|
this.handleItemsChanged && this.innerElement && (this.innerElement.removeEventListener("items-changed", this.handleItemsChanged), this.handleItemsChanged = null), this.innerElement &&= (this.innerElement.remove(), null);
|
|
@@ -1270,6 +1400,8 @@ var $ = /* @__PURE__ */ function(e) {
|
|
|
1270
1400
|
disconnectedCallback() {
|
|
1271
1401
|
this.cleanup(), this.initializeId++;
|
|
1272
1402
|
}
|
|
1403
|
+
}, $ = (e, { mixAndMatchSwapProducts: t, collectionBreaksProducts: n }) => {
|
|
1404
|
+
t.length && e.setAttribute("mix-and-match-swap-products", JSON.stringify(t)), e.setAttribute("collection-breaks-products", JSON.stringify(n));
|
|
1273
1405
|
};
|
|
1274
|
-
customElements.define("kaching-bundle-component",
|
|
1275
|
-
export {
|
|
1406
|
+
customElements.define("kaching-bundle-component", Ae);
|
|
1407
|
+
export { ke as fetchKachingBundlesData };
|