@best-bundles/bundle-ui 0.0.5 → 0.0.6

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,191 +1,194 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('._button_18rtl_1{display:inline-flex;align-items:center;justify-content:center;gap:8px;font-family:var(--bb-font-family, inherit);border:1px solid var(--bb-button-border, rgba(0, 0, 0, .12));background:var(--bb-button-bg, #111827);color:var(--bb-button-text, #ffffff);font:inherit;line-height:1;padding:10px 14px;border-radius:var(--bb-button-radius, 10px);cursor:pointer;transition:transform .12s ease,background .12s ease,border-color .12s ease,opacity .12s ease}._button_18rtl_1:hover{background:var(--bb-button-bg-hover, #0b1220)}._button_18rtl_1:active{transform:translateY(1px)}._button_18rtl_1:disabled{opacity:.6;cursor:not-allowed}._button_18rtl_1:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._backdrop_jv9mc_1{position:fixed;top:0;right:0;bottom:0;left:0;z-index:var(--bb-backdrop-z-index, 9999);display:flex;justify-content:flex-end;background:var(--bb-backdrop-bg, rgba(0, 0, 0, .5));-webkit-backdrop-filter:blur(var(--bb-backdrop-blur, 2px));backdrop-filter:blur(var(--bb-backdrop-blur, 2px));padding:var(--bb-backdrop-padding, 12px);opacity:0;transition:opacity var(--bb-drawer-transition-duration, .22s) ease}._celebrationOverlay_jv9mc_14{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;pointer-events:none;z-index:50}._celebrationChip_jv9mc_23{font-family:var(--bb-font-family-body, "Cabin", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif);letter-spacing:.03em;font-size:18px;line-height:1;padding:12px 16px;border-radius:999px;color:#0b1b44;background:linear-gradient(180deg,#fff,#bae6fd);border:2px solid rgba(37,99,235,.28);box-shadow:0 18px 55px #0006,0 10px 28px #2563eb33,inset 0 1px #ffffffbf;transform-origin:50% 60%;will-change:transform,opacity,filter;animation:_bbCelebrationPop_jv9mc_1 2.8s cubic-bezier(.16,1,.3,1) forwards;filter:saturate(1.05)}@keyframes _bbCelebrationPop_jv9mc_1{0%{opacity:0;transform:translateY(10px) scale(.6);filter:blur(1px) saturate(1.1)}12%{opacity:1;transform:translateY(0) scale(1.12);filter:blur(0px) saturate(1.1)}22%{opacity:1;transform:translateY(0) scale(1)}80%{opacity:1;transform:translateY(0) scale(1)}to{opacity:0;transform:translateY(-10px) scale(.98)}}._backdropOpen_jv9mc_74{opacity:1}._backdropClosed_jv9mc_78{opacity:0}._panel_jv9mc_82{width:440px;max-width:100%;height:100%;background:var(--bb-surface-bg, #ffffff);color:var(--bb-text-color, #111827);font-family:var(--bb-font-family-body, "Cabin", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif);border-radius:var(--bb-panel-radius, 16px);box-shadow:0 20px 60px #00000059;display:grid;grid-template-rows:auto 1fr auto;overflow:hidden;outline:none;position:relative;top:unset;right:unset;bottom:unset;left:unset}._panelOpen_jv9mc_102{animation:_bbSlideInFromRight_jv9mc_1 var(--bb-drawer-transition-duration, .22s) ease forwards}._panelClosed_jv9mc_106{animation:_bbSlideOutToRight_jv9mc_1 var(--bb-drawer-transition-duration, .22s) ease forwards}@keyframes _bbSlideInFromRight_jv9mc_1{0%{transform:translate(110%)}to{transform:translate(0)}}@keyframes _bbSlideOutToRight_jv9mc_1{0%{transform:translate(0)}to{transform:translate(110%)}}@media(prefers-reduced-motion:reduce){._backdrop_jv9mc_1{transition:none}._celebrationChip_jv9mc_23,._panelOpen_jv9mc_102,._panelClosed_jv9mc_106{animation:none}}._header_jv9mc_145{display:grid;grid-template-columns:36px 1fr 36px;align-items:center;column-gap:12px;padding:var(--bb-header-padding, 16px 16px 12px 16px);border-bottom:1px solid var(--bb-border-color, rgba(17, 24, 39, .08))}._headerCenter_jv9mc_154{position:relative;min-width:0;display:flex;justify-content:center;align-items:center}._title_jv9mc_162{font-size:24px;margin:0;line-height:1.2;font-family:var(--bb-font-family-title, "Bebas Neue", "Cabin", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif);letter-spacing:.02em;color:var(--bb-title-color, var(--bb-text-color, #111827))}._searchIconButton_jv9mc_171{width:36px;height:36px;border-radius:10px;border:1px solid var(--bb-border-strong-color, rgba(17, 24, 39, .12));background:var(--bb-surface-bg, #ffffff);color:var(--bb-text-color, #111827);cursor:pointer;display:inline-flex;align-items:center;justify-content:center}._searchIconButton_jv9mc_171:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._searchIconButton_jv9mc_171:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._headerTitleWrap_jv9mc_193{transition:opacity .18s ease,transform .22s ease}._headerSearchWrap_jv9mc_197{position:absolute;top:0;right:0;bottom:0;left:0;display:flex;justify-content:center;align-items:center;pointer-events:none;opacity:0;transform:translateY(-2px);transition:opacity .18s ease,transform .22s ease}._headerSearchOpen_jv9mc_209 ._headerTitleWrap_jv9mc_193{opacity:0;transform:translateY(2px);pointer-events:none}._headerSearchOpen_jv9mc_209 ._headerSearchWrap_jv9mc_197{opacity:1;transform:translateY(0);pointer-events:auto}._searchBar_jv9mc_221{width:min(320px,100%);height:36px;display:flex;align-items:center;gap:8px;background:var(--bb-surface-bg, #ffffff);border:1px solid var(--bb-border-strong-color, rgba(17, 24, 39, .12));border-radius:10px;padding:0 8px}._searchInput_jv9mc_233{width:100%;border:none;outline:none;background:transparent;font:inherit;font-size:14px;min-width:0;height:100%;line-height:36px;padding:0}._searchInput_jv9mc_233::-webkit-search-cancel-button,._searchInput_jv9mc_233::-webkit-search-decoration,._searchInput_jv9mc_233::-webkit-search-results-button,._searchInput_jv9mc_233::-webkit-search-results-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}._searchClearButton_jv9mc_254{border:none;background:transparent;color:var(--bb-text-color, #111827);font:inherit;font-size:13px;font-weight:700;cursor:pointer;padding:6px;border-radius:10px;line-height:1}._searchClearButton_jv9mc_254:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._searchClearButton_jv9mc_254:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._closeButton_jv9mc_276{border:1px solid var(--bb-border-strong-color, rgba(17, 24, 39, .12));background:var(--bb-surface-bg, #ffffff);color:var(--bb-text-color, #111827);width:36px;height:36px;border-radius:10px;cursor:pointer;flex:0 0 auto}._closeButton_jv9mc_276:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._closeButton_jv9mc_276:disabled{opacity:.6;cursor:not-allowed}._closeButton_jv9mc_276:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}@media(prefers-reduced-motion:reduce){._headerTitleWrap_jv9mc_193,._headerSearchWrap_jv9mc_197{transition:none}}._body_jv9mc_309{padding:var(--bb-body-padding, 8px 16px);overflow:auto}._muted_jv9mc_314{color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65));margin:0 0 12px}._error_jv9mc_319{color:var(--bb-error-color, #b91c1c);margin:0 0 12px}._variants_jv9mc_324{margin-top:4px}._variantList_jv9mc_328{list-style:none;padding:0;margin:0;display:grid;gap:10px}._variantRow_jv9mc_336{display:grid;grid-template-columns:1fr auto;gap:0px;align-items:stretch;padding:5px}._variantLeft_jv9mc_344{min-width:0;display:flex;gap:12px;align-items:center}._addToBundleButton_jv9mc_351{height:100%;align-self:stretch;border-radius:12px;border:none;background:var(--bb-cta-bg, #91aae5);color:var(--bb-cta-text, #ffffff);font:inherit;font-weight:800;padding:0 16px;cursor:pointer;white-space:nowrap}._addToBundleButton_jv9mc_351:hover{background:var(--bb-cta-bg-hover, #1d4ed8)}._addToBundleButton_jv9mc_351:disabled{opacity:.6;cursor:not-allowed}._addToBundleButton_jv9mc_351:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._variantThumb_jv9mc_379{width:60px;height:60px;border-radius:12px;overflow:hidden;border:1px solid var(--bb-border-color, rgba(17, 24, 39, .08));background:var(--bb-surface-subtle-bg, rgba(17, 24, 39, .02));flex:0 0 auto}._variantThumbImg_jv9mc_389{width:100%;height:100%;object-fit:cover;display:block}._variantThumbFallback_jv9mc_396{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-weight:800;color:var(--bb-text-color, #111827)}._variantInfo_jv9mc_406{min-width:0}._variantName_jv9mc_410{font-size:14px;font-weight:600;margin-bottom:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._variantMeta_jv9mc_419{font-size:12px;color:var(--bb-muted-color, rgba(17, 24, 39, .6));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._variantPriceRow_jv9mc_427{display:flex;align-items:baseline;gap:8px;margin-top:4px}._variantCompareAt_jv9mc_434{font-size:12px;color:var(--bb-muted-color, rgba(17, 24, 39, .6));text-decoration:line-through}._variantPrice_jv9mc_427{font-size:13px;font-weight:800}._qtyControls_jv9mc_445{display:inline-flex;align-items:center;gap:6px}._qtyButton_jv9mc_451{width:34px;height:34px;border-radius:10px;border:1px solid var(--bb-border-strong-color, rgba(17, 24, 39, .12));background:var(--bb-surface-bg, #ffffff);cursor:pointer;line-height:1;font-size:16px}._qtyButton_jv9mc_451:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._qtyButton_jv9mc_451:disabled{opacity:.6;cursor:not-allowed}._qtyButton_jv9mc_451:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._qtyValue_jv9mc_476{min-width:18px;text-align:center;font-variant-numeric:tabular-nums;font-weight:700}._footer_jv9mc_483{padding:var(--bb-footer-padding, 12px 16px 16px 16px);border-top:1px solid var(--bb-border-color, rgba(17, 24, 39, .08));background:var(--bb-surface-bg, #ffffff);position:relative}._boxSummaryWindow_jv9mc_490{margin-bottom:6px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;padding-bottom:6px;scrollbar-width:none;-ms-overflow-style:none}._boxSummaryWindow_jv9mc_490::-webkit-scrollbar{display:none}._boxSummaryRow_jv9mc_507{--bb-box-gap: 10px;display:flex;align-items:flex-start;gap:var(--bb-box-gap);width:100%}._boxSlot_jv9mc_515{flex:0 0 calc((100% - (4 * var(--bb-box-gap))) / 5);display:flex;flex-direction:column;align-items:stretch;gap:6px}._boxItem_jv9mc_523{width:100%;aspect-ratio:1 / 1;border-radius:12px;position:relative;display:flex;align-items:center;justify-content:center;-webkit-user-select:none;user-select:none;box-sizing:border-box}._boxItemClickable_jv9mc_535{cursor:pointer}._boxItemClickable_jv9mc_535:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._boxThresholdLabel_jv9mc_544{font-size:11px;line-height:1.15;font-weight:700;color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65));text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}._boxItemPlaceholder_jv9mc_555{border:1px dashed var(--bb-border-strong-color, rgba(17, 24, 39, .18));background:var(--bb-surface-subtle-bg, rgba(17, 24, 39, .02));color:var(--bb-muted-color, rgba(17, 24, 39, .6))}._boxItemFilled_jv9mc_561{border:1px solid var(--bb-border-color, rgba(17, 24, 39, .08));background:var(--bb-surface-bg, #ffffff);overflow:hidden}._boxItemThreshold_jv9mc_567{border-style:solid;border-width:2px;border-color:var(--bb-tier-border, rgba(37, 99, 235, .55));background:linear-gradient(180deg,#2563eb1a,#2563eb08);color:var(--bb-tier-text, rgba(29, 78, 216, .95))}._boxItemDiscountText_jv9mc_575{font-size:12px;font-weight:800;text-align:center;line-height:1.1;padding:6px}._boxItemPlus_jv9mc_583{font-size:22px;font-weight:700;opacity:.5;line-height:1}._boxItemImage_jv9mc_590{width:100%;height:100%;object-fit:cover;display:block}._boxItemFallback_jv9mc_597{width:100%;height:100%;display:flex;align-items:center;justify-content:center;background:var(--bb-surface-subtle-bg, rgba(17, 24, 39, .04));color:var(--bb-text-color, #111827);font-weight:800}._cta_jv9mc_608{width:100%;border:1px solid var(--bb-cta-border, rgba(0, 0, 0, .12));background:var(--bb-cta-bg, #2563eb);color:var(--bb-cta-text, #ffffff);font:inherit;font-weight:700;padding:12px 14px;border-radius:12px;cursor:pointer}._ctaTotals_jv9mc_620{display:flex;justify-content:space-between;align-items:baseline;gap:10px;font-variant-numeric:tabular-nums}._ctaDiscountBadge_jv9mc_628{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;font-size:12px;font-weight:800;background:linear-gradient(180deg,#2563eb24,#2563eb0f);border:1px solid rgba(37,99,235,.3);color:#1d4ed8f2;white-space:nowrap}._ctaTotalsWrap_jv9mc_642{overflow:hidden;max-height:0;opacity:0;transform:translateY(4px);margin-bottom:0;transition:max-height .22s ease,opacity .16s ease,transform .22s ease,margin-bottom .22s ease}._ctaTotalsWrapVisible_jv9mc_655{max-height:40px;opacity:1;transform:translateY(0);margin-bottom:8px}._ctaTotalsStrike_jv9mc_662{opacity:.85;text-decoration:line-through;font-weight:700;color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65))}._ctaTotalsPrice_jv9mc_669{font-weight:900;color:var(--bb-text-color, #111827)}@media(prefers-reduced-motion:reduce){._ctaTotalsWrap_jv9mc_642{transition:none}}._cta_jv9mc_608:hover{background:var(--bb-cta-bg-hover, #1d4ed8)}._cta_jv9mc_608:disabled{opacity:.6;cursor:not-allowed}._cta_jv9mc_608:focus-visible{outline:2px solid var(--bb-cta-focus-ring, var(--bb-text-color, #111827));outline-offset:2px}._helperText_jv9mc_694{margin-top:8px;font-size:12px;color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65));text-align:center}@media(max-width:767px){._backdrop_jv9mc_1{padding:0;justify-content:stretch}._panel_jv9mc_82{width:100%;height:100%;border-radius:0}}')),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
- import { jsx as h, jsxs as P, Fragment as rt } from "react/jsx-runtime";
3
- import Ie, { useState as I, useRef as A, useEffect as D, useCallback as le, useMemo as B, createContext as it, useContext as ot, forwardRef as Ge, createElement as Fe } from "react";
4
- const Ce = {
2
+ import { jsx as h, jsxs as P, Fragment as ot } from "react/jsx-runtime";
3
+ import Se, { useState as B, useRef as L, useEffect as z, useCallback as ce, useMemo as I, createContext as st, useContext as ct, forwardRef as Je, createElement as De } from "react";
4
+ const Ne = {
5
5
  bundleId: "_bundle_id",
6
6
  bundleConfig: "_bundle_config",
7
7
  bundleSource: "_bundle_source",
8
8
  bundleTitle: "_bundle_title"
9
9
  };
10
- async function at(o) {
11
- const e = new URL("/api/public/bundle-config", o.apiBaseUrl);
12
- e.searchParams.set("shop", o.shop);
10
+ async function lt(a) {
11
+ const e = new URL("/api/public/bundle-config", a.apiBaseUrl);
12
+ e.searchParams.set("shop", a.shop);
13
13
  const i = await (await fetch(e, {
14
14
  method: "GET",
15
- signal: o.signal,
15
+ signal: a.signal,
16
16
  headers: { "Content-Type": "application/json" }
17
17
  })).json().catch(() => null);
18
18
  return !i || typeof i != "object" ? { ok: !1, error: "Invalid response." } : i;
19
19
  }
20
- const Ke = it(null);
21
- function st() {
20
+ const Ze = st(null);
21
+ function ut() {
22
22
  try {
23
- const o = globalThis.crypto;
24
- if (o != null && o.randomUUID) return o.randomUUID();
23
+ const a = globalThis.crypto;
24
+ if (a != null && a.randomUUID) return a.randomUUID();
25
25
  } catch {
26
26
  }
27
27
  return `bb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
28
28
  }
29
- function ze(o) {
30
- return Number.isFinite(o) ? Math.max(0, Math.floor(o)) : 0;
29
+ function Ge(a) {
30
+ return Number.isFinite(a) ? Math.max(0, Math.floor(a)) : 0;
31
31
  }
32
- function Wn(o) {
32
+ function $n(a) {
33
33
  const {
34
34
  apiBaseUrl: e,
35
35
  shop: t,
36
36
  cartAdapter: i,
37
37
  configHandle: r = "default",
38
38
  initialData: n,
39
- configFetcher: c,
40
- children: l
41
- } = o, [m, T] = I(!1), [C, S] = I(!n), [w, E] = I(!1), [$, V] = I(null), [N, M] = I((n == null ? void 0 : n.currencyCode) ?? null), [v, z] = I((n == null ? void 0 : n.config) ?? null), [ie, ue] = I(
39
+ configFetcher: l,
40
+ children: c
41
+ } = a, [m, N] = B(!1), [C, T] = B(!n), [y, $] = B(!1), [V, U] = B(null), [M, O] = B((n == null ? void 0 : n.currencyCode) ?? null), [f, Q] = B((n == null ? void 0 : n.config) ?? null), [ae, le] = B(
42
42
  (n == null ? void 0 : n.eligibleVariants) ?? []
43
- ), [de, Z] = I(
43
+ ), [ue, J] = B(
44
44
  () => ({ selections: {}, order: [] })
45
- ), ye = A(null);
46
- D(() => {
47
- var O;
45
+ ), ge = L(null);
46
+ z(() => {
47
+ var j;
48
48
  if (n) return;
49
- (O = ye.current) == null || O.abort();
50
- const x = new AbortController();
51
- ye.current = x;
52
- const j = c ?? at;
53
- return S(!0), V(null), j({ apiBaseUrl: e, shop: t, signal: x.signal }).then((b) => {
54
- if (!b.ok) {
55
- V(b.error || "Failed to load bundle config."), z(null), ue([]), M(null);
49
+ (j = ge.current) == null || j.abort();
50
+ const w = new AbortController();
51
+ ge.current = w;
52
+ const S = l ?? lt;
53
+ return T(!0), U(null), S({ apiBaseUrl: e, shop: t, signal: w.signal }).then((_) => {
54
+ if (!_.ok) {
55
+ U(_.error || "Failed to load bundle config."), Q(null), le([]), O(null);
56
56
  return;
57
57
  }
58
- M(b.currencyCode ?? null), z(b.config), ue(b.eligibleVariants ?? []);
59
- }).catch((b) => {
60
- const F = b instanceof Error ? b.message : "Failed to load bundle config.";
61
- V(F), z(null), ue([]), M(null);
62
- }).finally(() => S(!1)), () => x.abort();
63
- }, [e, t, n, c]);
64
- const we = le(() => T(!0), []), oe = le(() => T(!1), []), he = le(() => T((x) => !x), []), ge = le((x, j) => {
65
- const O = ze(j);
66
- Z((b) => {
67
- const F = b.selections[x] ?? 0, Y = O - F;
68
- let K;
69
- if (O <= 0) {
70
- const { [x]: me, ...H } = b.selections;
71
- K = H;
72
- } else F === O ? K = b.selections : K = { ...b.selections, [x]: O };
73
- let ce = b.order;
74
- if (Y > 0)
75
- ce = [...b.order, ...Array.from({ length: Y }, () => x)];
76
- else if (Y < 0) {
77
- let me = -Y;
78
- const H = [];
79
- for (let L = b.order.length - 1; L >= 0; L--) {
80
- const X = b.order[L];
81
- if (X === x && me > 0) {
82
- me--;
58
+ O(_.currencyCode ?? null), Q(_.config), le(_.eligibleVariants ?? []);
59
+ }).catch((_) => {
60
+ const F = _ instanceof Error ? _.message : "Failed to load bundle config.";
61
+ U(F), Q(null), le([]), O(null);
62
+ }).finally(() => T(!1)), () => w.abort();
63
+ }, [e, t, n, l]);
64
+ const xe = ce(() => N(!0), []), oe = ce(() => N(!1), []), de = ce(() => N((w) => !w), []), Ce = I(() => {
65
+ const w = Number((f == null ? void 0 : f.maxBundleSize) ?? NaN), S = Number.isFinite(w) ? Math.floor(w) : 100;
66
+ return Math.max(2, Math.min(100, S));
67
+ }, [f == null ? void 0 : f.maxBundleSize]), Ie = ce((w, S) => {
68
+ const j = Ge(S);
69
+ J((_) => {
70
+ const F = _.selections[w] ?? 0, K = j - F, Be = Object.values(_.selections).reduce((W, Y) => W + (Y || 0), 0), re = K > 0 ? Math.min(K, Math.max(0, Ce - Be)) : K, me = F + re;
71
+ let H;
72
+ if (me <= 0) {
73
+ const { [w]: W, ...Y } = _.selections;
74
+ H = Y;
75
+ } else F === me ? H = _.selections : H = { ..._.selections, [w]: me };
76
+ let A = _.order;
77
+ if (re > 0)
78
+ A = [..._.order, ...Array.from({ length: re }, () => w)];
79
+ else if (re < 0) {
80
+ let W = -re;
81
+ const Y = [];
82
+ for (let fe = _.order.length - 1; fe >= 0; fe--) {
83
+ const pe = _.order[fe];
84
+ if (pe === w && W > 0) {
85
+ W--;
83
86
  continue;
84
87
  }
85
- H.push(X);
88
+ Y.push(pe);
86
89
  }
87
- H.reverse(), ce = H;
90
+ Y.reverse(), A = Y;
88
91
  }
89
- return K === b.selections && ce === b.order ? b : { selections: K, order: ce };
92
+ return H === _.selections && A === _.order ? _ : { selections: H, order: A };
90
93
  });
91
- }, []), ae = le(() => Z({ selections: {}, order: [] }), []), U = de.selections, Q = de.order, ee = B(() => Object.values(U).reduce((x, j) => x + (j || 0), 0), [U]), te = B(() => {
92
- const x = (v == null ? void 0 : v.rules) ?? [], j = x.length ? Math.min(...x.map((O) => O.minBundleSize)) : 2;
93
- return Number.isFinite(j) && j > 0 ? j : 2;
94
- }, [v]), ne = B(() => !(C || w || $ || !(v != null && v.isActive) || ee < te), [ee, v == null ? void 0 : v.isActive, $, C, te, w]), xe = le(async () => {
95
- var b;
96
- if (!ne || !v) return;
97
- const x = st(), j = (v.title ?? "").trim().slice(0, 255), O = Object.entries(U).map(([F, Y]) => ({ merchandiseId: F, quantity: ze(Y) })).filter((F) => F.quantity > 0).map((F) => ({
94
+ }, [Ce]), Z = ce(() => J({ selections: {}, order: [] }), []), R = ue.selections, he = ue.order, ee = I(() => Object.values(R).reduce((w, S) => w + (S || 0), 0), [R]), te = I(() => {
95
+ const w = (f == null ? void 0 : f.rules) ?? [], S = w.length ? Math.min(...w.map((j) => j.minBundleSize)) : 2;
96
+ return Number.isFinite(S) && S > 0 ? S : 2;
97
+ }, [f]), se = I(() => !(C || y || V || !(f != null && f.isActive) || ee < te), [ee, f == null ? void 0 : f.isActive, V, C, te, y]), ne = ce(async () => {
98
+ var _;
99
+ if (!se || !f) return;
100
+ const w = ut(), S = (f.title ?? "").trim().slice(0, 255), j = Object.entries(R).map(([F, K]) => ({ merchandiseId: F, quantity: Ge(K) })).filter((F) => F.quantity > 0).map((F) => ({
98
101
  merchandiseId: F.merchandiseId,
99
102
  quantity: F.quantity,
100
103
  attributes: [
101
- { key: Ce.bundleId, value: x },
102
- { key: Ce.bundleConfig, value: r },
103
- { key: Ce.bundleSource, value: "bundle_builder" },
104
- ...j ? [{ key: Ce.bundleTitle, value: j }] : []
104
+ { key: Ne.bundleId, value: w },
105
+ { key: Ne.bundleConfig, value: r },
106
+ { key: Ne.bundleSource, value: "bundle_builder" },
107
+ ...S ? [{ key: Ne.bundleTitle, value: S }] : []
105
108
  ]
106
109
  }));
107
- if (O.length) {
108
- E(!0);
110
+ if (j.length) {
111
+ $(!0);
109
112
  try {
110
- await i.linesAdd(O), ae(), oe(), (b = i.openCartUI) == null || b.call(i);
113
+ await i.linesAdd(j), Z(), oe(), (_ = i.openCartUI) == null || _.call(i);
111
114
  } finally {
112
- E(!1);
115
+ $(!1);
113
116
  }
114
117
  }
115
- }, [ne, i, ae, oe, v, r, U]), se = B(
118
+ }, [se, i, Z, oe, f, r, R]), Te = I(
116
119
  () => ({
117
120
  isOpen: m,
118
- open: we,
121
+ open: xe,
119
122
  close: oe,
120
- toggle: he,
123
+ toggle: de,
121
124
  loading: C,
122
- submitting: w,
123
- error: $,
124
- currencyCode: N,
125
- config: v,
126
- eligibleVariants: ie,
127
- selections: U,
128
- selectionOrder: Q,
129
- setQuantity: ge,
130
- clearSelections: ae,
125
+ submitting: y,
126
+ error: V,
127
+ currencyCode: M,
128
+ config: f,
129
+ eligibleVariants: ae,
130
+ selections: R,
131
+ selectionOrder: he,
132
+ setQuantity: Ie,
133
+ clearSelections: Z,
131
134
  bundleSize: ee,
132
135
  minRequired: te,
133
- canSubmit: ne,
134
- submit: xe
136
+ canSubmit: se,
137
+ submit: ne
135
138
  }),
136
139
  [
137
140
  m,
138
- we,
141
+ xe,
139
142
  oe,
140
- he,
143
+ de,
141
144
  C,
142
- w,
143
- $,
144
- N,
145
- v,
146
- ie,
147
- U,
148
- Q,
149
- ge,
145
+ y,
146
+ V,
147
+ M,
148
+ f,
150
149
  ae,
150
+ R,
151
+ he,
152
+ Ie,
153
+ Z,
151
154
  ee,
152
155
  te,
153
- ne,
154
- xe
156
+ se,
157
+ ne
155
158
  ]
156
159
  );
157
- return /* @__PURE__ */ h(Ke.Provider, { value: se, children: l });
160
+ return /* @__PURE__ */ h(Ze.Provider, { value: Te, children: c });
158
161
  }
159
- function Re() {
160
- const o = ot(Ke);
161
- if (!o)
162
+ function Le() {
163
+ const a = ct(Ze);
164
+ if (!a)
162
165
  throw new Error("useBundleBuilder must be used within <BundleProvider />");
163
- return o;
166
+ return a;
164
167
  }
165
- function En() {
166
- const { isOpen: o, open: e, close: t, toggle: i } = Re();
167
- return { isOpen: o, open: e, close: t, toggle: i };
168
+ function Vn() {
169
+ const { isOpen: a, open: e, close: t, toggle: i } = Le();
170
+ return { isOpen: a, open: e, close: t, toggle: i };
168
171
  }
169
- const ct = "_button_18rtl_1", lt = {
170
- button: ct
172
+ const dt = "_button_18rtl_1", ht = {
173
+ button: dt
171
174
  };
172
- function $n(o) {
173
- const { toggle: e } = Re();
175
+ function Un(a) {
176
+ const { toggle: e } = Le();
174
177
  return /* @__PURE__ */ h(
175
178
  "button",
176
179
  {
177
180
  type: "button",
178
181
  onClick: e,
179
- className: [lt.button, o.className].filter(Boolean).join(" "),
180
- children: o.children ?? "Build a bundle"
182
+ className: [ht.button, a.className].filter(Boolean).join(" "),
183
+ children: a.children ?? "Build a bundle"
181
184
  }
182
185
  );
183
186
  }
184
- var Oe, Ue;
185
- function ut() {
186
- if (Ue) return Oe;
187
- Ue = 1;
188
- var o = {
187
+ var Re, Ke;
188
+ function mt() {
189
+ if (Ke) return Re;
190
+ Ke = 1;
191
+ var a = {
189
192
  linear: function(e, t, i, r) {
190
193
  var n = i - t;
191
194
  return n * e / r + t;
@@ -275,86 +278,86 @@ function ut() {
275
278
  return (e /= r / 2) < 1 ? -n / 2 * (Math.sqrt(1 - e * e) - 1) + t : n / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) + t;
276
279
  },
277
280
  easeInElastic: function(e, t, i, r) {
278
- var n = i - t, c, l, m;
279
- return m = 1.70158, l = 0, c = n, e === 0 ? t : (e /= r) === 1 ? t + n : (l || (l = r * 0.3), c < Math.abs(n) ? (c = n, m = l / 4) : m = l / (2 * Math.PI) * Math.asin(n / c), -(c * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / l)) + t);
281
+ var n = i - t, l, c, m;
282
+ return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= r) === 1 ? t + n : (c || (c = r * 0.3), l < Math.abs(n) ? (l = n, m = c / 4) : m = c / (2 * Math.PI) * Math.asin(n / l), -(l * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / c)) + t);
280
283
  },
281
284
  easeOutElastic: function(e, t, i, r) {
282
- var n = i - t, c, l, m;
283
- return m = 1.70158, l = 0, c = n, e === 0 ? t : (e /= r) === 1 ? t + n : (l || (l = r * 0.3), c < Math.abs(n) ? (c = n, m = l / 4) : m = l / (2 * Math.PI) * Math.asin(n / c), c * Math.pow(2, -10 * e) * Math.sin((e * r - m) * (2 * Math.PI) / l) + n + t);
285
+ var n = i - t, l, c, m;
286
+ return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= r) === 1 ? t + n : (c || (c = r * 0.3), l < Math.abs(n) ? (l = n, m = c / 4) : m = c / (2 * Math.PI) * Math.asin(n / l), l * Math.pow(2, -10 * e) * Math.sin((e * r - m) * (2 * Math.PI) / c) + n + t);
284
287
  },
285
288
  easeInOutElastic: function(e, t, i, r) {
286
- var n = i - t, c, l, m;
287
- return m = 1.70158, l = 0, c = n, e === 0 ? t : (e /= r / 2) === 2 ? t + n : (l || (l = r * (0.3 * 1.5)), c < Math.abs(n) ? (c = n, m = l / 4) : m = l / (2 * Math.PI) * Math.asin(n / c), e < 1 ? -0.5 * (c * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / l)) + t : c * Math.pow(2, -10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / l) * 0.5 + n + t);
289
+ var n = i - t, l, c, m;
290
+ return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= r / 2) === 2 ? t + n : (c || (c = r * (0.3 * 1.5)), l < Math.abs(n) ? (l = n, m = c / 4) : m = c / (2 * Math.PI) * Math.asin(n / l), e < 1 ? -0.5 * (l * Math.pow(2, 10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / c)) + t : l * Math.pow(2, -10 * (e -= 1)) * Math.sin((e * r - m) * (2 * Math.PI) / c) * 0.5 + n + t);
288
291
  },
289
292
  easeInBack: function(e, t, i, r, n) {
290
- var c = i - t;
291
- return n === void 0 && (n = 1.70158), c * (e /= r) * e * ((n + 1) * e - n) + t;
293
+ var l = i - t;
294
+ return n === void 0 && (n = 1.70158), l * (e /= r) * e * ((n + 1) * e - n) + t;
292
295
  },
293
296
  easeOutBack: function(e, t, i, r, n) {
294
- var c = i - t;
295
- return n === void 0 && (n = 1.70158), c * ((e = e / r - 1) * e * ((n + 1) * e + n) + 1) + t;
297
+ var l = i - t;
298
+ return n === void 0 && (n = 1.70158), l * ((e = e / r - 1) * e * ((n + 1) * e + n) + 1) + t;
296
299
  },
297
300
  easeInOutBack: function(e, t, i, r, n) {
298
- var c = i - t;
299
- return n === void 0 && (n = 1.70158), (e /= r / 2) < 1 ? c / 2 * (e * e * (((n *= 1.525) + 1) * e - n)) + t : c / 2 * ((e -= 2) * e * (((n *= 1.525) + 1) * e + n) + 2) + t;
301
+ var l = i - t;
302
+ return n === void 0 && (n = 1.70158), (e /= r / 2) < 1 ? l / 2 * (e * e * (((n *= 1.525) + 1) * e - n)) + t : l / 2 * ((e -= 2) * e * (((n *= 1.525) + 1) * e + n) + 2) + t;
300
303
  },
301
304
  easeInBounce: function(e, t, i, r) {
302
- var n = i - t, c;
303
- return c = o.easeOutBounce(r - e, 0, n, r), n - c + t;
305
+ var n = i - t, l;
306
+ return l = a.easeOutBounce(r - e, 0, n, r), n - l + t;
304
307
  },
305
308
  easeOutBounce: function(e, t, i, r) {
306
309
  var n = i - t;
307
310
  return (e /= r) < 1 / 2.75 ? n * (7.5625 * e * e) + t : e < 2 / 2.75 ? n * (7.5625 * (e -= 1.5 / 2.75) * e + 0.75) + t : e < 2.5 / 2.75 ? n * (7.5625 * (e -= 2.25 / 2.75) * e + 0.9375) + t : n * (7.5625 * (e -= 2.625 / 2.75) * e + 0.984375) + t;
308
311
  },
309
312
  easeInOutBounce: function(e, t, i, r) {
310
- var n = i - t, c;
311
- return e < r / 2 ? (c = o.easeInBounce(e * 2, 0, n, r), c * 0.5 + t) : (c = o.easeOutBounce(e * 2 - r, 0, n, r), c * 0.5 + n * 0.5 + t);
313
+ var n = i - t, l;
314
+ return e < r / 2 ? (l = a.easeInBounce(e * 2, 0, n, r), l * 0.5 + t) : (l = a.easeOutBounce(e * 2 - r, 0, n, r), l * 0.5 + n * 0.5 + t);
312
315
  }
313
316
  };
314
- return Oe = o, Oe;
317
+ return Re = a, Re;
315
318
  }
316
- var dt = ut();
317
- function ht(o) {
318
- return o * Math.PI / 180;
319
+ var ft = mt();
320
+ function pt(a) {
321
+ return a * Math.PI / 180;
319
322
  }
320
- function R(o, e) {
321
- return o + Math.random() * (e - o);
323
+ function q(a, e) {
324
+ return a + Math.random() * (e - a);
322
325
  }
323
- function mt(o, e) {
324
- return Math.floor(o + Math.random() * (e - o + 1));
326
+ function vt(a, e) {
327
+ return Math.floor(a + Math.random() * (e - a + 1));
325
328
  }
326
- var _e;
327
- (function(o) {
328
- o[o.Circle = 0] = "Circle", o[o.Square = 1] = "Square", o[o.Strip = 2] = "Strip";
329
- })(_e || (_e = {}));
330
- var J;
331
- (function(o) {
332
- o[o.Positive = 1] = "Positive", o[o.Negative = -1] = "Negative";
333
- })(J || (J = {}));
334
- const ft = 1e3 / 60;
335
- class pt {
329
+ var ye;
330
+ (function(a) {
331
+ a[a.Circle = 0] = "Circle", a[a.Square = 1] = "Square", a[a.Strip = 2] = "Strip";
332
+ })(ye || (ye = {}));
333
+ var X;
334
+ (function(a) {
335
+ a[a.Positive = 1] = "Positive", a[a.Negative = -1] = "Negative";
336
+ })(X || (X = {}));
337
+ const bt = 1e3 / 60;
338
+ class _t {
336
339
  constructor(e, t, i, r) {
337
340
  this.getOptions = t;
338
- const { colors: n, initialVelocityX: c, initialVelocityY: l } = this.getOptions();
339
- this.context = e, this.x = i, this.y = r, this.w = R(5, 20), this.h = R(5, 20), this.radius = R(5, 10), this.vx = typeof c == "number" ? R(-c, c) : R(c.min, c.max), this.vy = typeof l == "number" ? R(-l, 0) : R(l.min, l.max), this.shape = mt(0, 2), this.angle = ht(R(0, 360)), this.angularSpin = R(-0.2, 0.2), this.color = n[Math.floor(Math.random() * n.length)], this.rotateY = R(0, 1), this.rotationDirection = R(0, 1) ? J.Positive : J.Negative;
341
+ const { colors: n, initialVelocityX: l, initialVelocityY: c } = this.getOptions();
342
+ this.context = e, this.x = i, this.y = r, this.w = q(5, 20), this.h = q(5, 20), this.radius = q(5, 10), this.vx = typeof l == "number" ? q(-l, l) : q(l.min, l.max), this.vy = typeof c == "number" ? q(-c, 0) : q(c.min, c.max), this.shape = vt(0, 2), this.angle = pt(q(0, 360)), this.angularSpin = q(-0.2, 0.2), this.color = n[Math.floor(Math.random() * n.length)], this.rotateY = q(0, 1), this.rotationDirection = q(0, 1) ? X.Positive : X.Negative;
340
343
  }
341
344
  update(e) {
342
- const { gravity: t, wind: i, friction: r, opacity: n, drawShape: c } = this.getOptions(), l = e / ft;
343
- this.x += this.vx * l, this.y += this.vy * l, this.vy += t * l, this.vx += i * l, this.vx *= r ** l, this.vy *= r ** l, this.rotateY >= 1 && this.rotationDirection === J.Positive ? this.rotationDirection = J.Negative : this.rotateY <= -1 && this.rotationDirection === J.Negative && (this.rotationDirection = J.Positive);
344
- const m = 0.1 * this.rotationDirection * l;
345
- if (this.rotateY += m, this.angle += this.angularSpin, this.context.save(), this.context.translate(this.x, this.y), this.context.rotate(this.angle), this.context.scale(1, this.rotateY), this.context.rotate(this.angle), this.context.beginPath(), this.context.fillStyle = this.color, this.context.strokeStyle = this.color, this.context.globalAlpha = n, this.context.lineCap = "round", this.context.lineWidth = 2, c && typeof c == "function")
346
- c.call(this, this.context);
345
+ const { gravity: t, wind: i, friction: r, opacity: n, drawShape: l } = this.getOptions(), c = e / bt;
346
+ this.x += this.vx * c, this.y += this.vy * c, this.vy += t * c, this.vx += i * c, this.vx *= r ** c, this.vy *= r ** c, this.rotateY >= 1 && this.rotationDirection === X.Positive ? this.rotationDirection = X.Negative : this.rotateY <= -1 && this.rotationDirection === X.Negative && (this.rotationDirection = X.Positive);
347
+ const m = 0.1 * this.rotationDirection * c;
348
+ if (this.rotateY += m, this.angle += this.angularSpin, this.context.save(), this.context.translate(this.x, this.y), this.context.rotate(this.angle), this.context.scale(1, this.rotateY), this.context.rotate(this.angle), this.context.beginPath(), this.context.fillStyle = this.color, this.context.strokeStyle = this.color, this.context.globalAlpha = n, this.context.lineCap = "round", this.context.lineWidth = 2, l && typeof l == "function")
349
+ l.call(this, this.context);
347
350
  else
348
351
  switch (this.shape) {
349
- case _e.Circle: {
352
+ case ye.Circle: {
350
353
  this.context.beginPath(), this.context.arc(0, 0, this.radius, 0, 2 * Math.PI), this.context.fill();
351
354
  break;
352
355
  }
353
- case _e.Square: {
356
+ case ye.Square: {
354
357
  this.context.fillRect(-this.w / 2, -this.h / 2, this.w, this.h);
355
358
  break;
356
359
  }
357
- case _e.Strip: {
360
+ case ye.Strip: {
358
361
  this.context.fillRect(-this.w / 6, -this.h / 2, this.w / 3, this.h);
359
362
  break;
360
363
  }
@@ -362,31 +365,31 @@ class pt {
362
365
  this.context.closePath(), this.context.restore();
363
366
  }
364
367
  }
365
- class vt {
368
+ class wt {
366
369
  constructor(e, t) {
367
370
  this.x = 0, this.y = 0, this.w = 0, this.h = 0, this.lastNumberOfPieces = 0, this.tweenProgress = 0, this.tweenFrom = 0, this.particles = [], this.particlesGenerated = 0, this.removeParticleAt = (r) => {
368
371
  this.particles.splice(r, 1);
369
372
  }, this.getParticle = () => {
370
- const r = R(this.x, this.w + this.x), n = R(this.y, this.h + this.y);
371
- return new pt(this.context, this.getOptions, r, n);
373
+ const r = q(this.x, this.w + this.x), n = q(this.y, this.h + this.y);
374
+ return new _t(this.context, this.getOptions, r, n);
372
375
  }, this.animate = (r) => {
373
- const { canvas: n, context: c, particlesGenerated: l, lastNumberOfPieces: m } = this, { run: T, recycle: C, numberOfPieces: S, debug: w, tweenFunction: E, tweenDuration: $ } = this.getOptions();
374
- if (!T)
376
+ const { canvas: n, context: l, particlesGenerated: c, lastNumberOfPieces: m } = this, { run: N, recycle: C, numberOfPieces: T, debug: y, tweenFunction: $, tweenDuration: V } = this.getOptions();
377
+ if (!N)
375
378
  return !1;
376
- const V = this.particles.length, N = C ? V : l;
377
- if (N < S) {
378
- m !== S && (this.tweenProgress = 0, this.tweenFrom = N, this.lastNumberOfPieces = S), this.tweenProgress = Math.min($, Math.max(0, this.tweenProgress + r));
379
- const M = E(this.tweenProgress, this.tweenFrom, S, $), v = Math.round(M - N);
380
- for (let z = 0; z < v; z++)
379
+ const U = this.particles.length, M = C ? U : c;
380
+ if (M < T) {
381
+ m !== T && (this.tweenProgress = 0, this.tweenFrom = M, this.lastNumberOfPieces = T), this.tweenProgress = Math.min(V, Math.max(0, this.tweenProgress + r));
382
+ const O = $(this.tweenProgress, this.tweenFrom, T, V), f = Math.round(O - M);
383
+ for (let Q = 0; Q < f; Q++)
381
384
  this.particles.push(this.getParticle());
382
- this.particlesGenerated += v;
385
+ this.particlesGenerated += f;
383
386
  }
384
- w && (c.font = "12px sans-serif", c.fillStyle = "#333", c.textAlign = "right", c.fillText(`Particles: ${V}`, n.width - 10, n.height - 20));
385
- for (let M = this.particles.length - 1; M >= 0; M--) {
386
- const v = this.particles[M];
387
- v.update(r), (v.y > n.height || v.y < -100 || v.x > n.width + 100 || v.x < -100) && (C && N <= S ? this.particles[M] = this.getParticle() : this.removeParticleAt(M));
387
+ y && (l.font = "12px sans-serif", l.fillStyle = "#333", l.textAlign = "right", l.fillText(`Particles: ${U}`, n.width - 10, n.height - 20));
388
+ for (let O = this.particles.length - 1; O >= 0; O--) {
389
+ const f = this.particles[O];
390
+ f.update(r), (f.y > n.height || f.y < -100 || f.x > n.width + 100 || f.x < -100) && (C && M <= T ? this.particles[O] = this.getParticle() : this.removeParticleAt(O));
388
391
  }
389
- return V > 0 || N < S;
392
+ return U > 0 || M < T;
390
393
  }, this.canvas = e;
391
394
  const i = this.canvas.getContext("2d");
392
395
  if (!i)
@@ -394,7 +397,7 @@ class vt {
394
397
  this.context = i, this.getOptions = t;
395
398
  }
396
399
  }
397
- const qe = {
400
+ const ze = {
398
401
  width: typeof window < "u" ? window.innerWidth : 300,
399
402
  height: typeof window < "u" ? window.innerHeight : 200,
400
403
  numberOfPieces: 200,
@@ -424,12 +427,12 @@ const qe = {
424
427
  ],
425
428
  opacity: 1,
426
429
  debug: !1,
427
- tweenFunction: dt.easeInOutQuad,
430
+ tweenFunction: ft.easeInOutQuad,
428
431
  tweenDuration: 5e3,
429
432
  recycle: !0,
430
433
  run: !0
431
434
  };
432
- class bt {
435
+ class yt {
433
436
  constructor(e, t) {
434
437
  this.lastFrameTime = 0, this.setOptionsWithDefaults = (r) => {
435
438
  const n = {
@@ -442,16 +445,16 @@ class bt {
442
445
  };
443
446
  this._options = {
444
447
  ...n,
445
- ...qe,
448
+ ...ze,
446
449
  ...r
447
450
  }, Object.assign(this, r.confettiSource);
448
451
  }, this.update = (r = 0) => {
449
- const { options: { run: n, onConfettiComplete: c, frameRate: l }, canvas: m, context: T } = this, C = Math.min(r - this.lastFrameTime, 50);
450
- if (l && C < 1e3 / l) {
452
+ const { options: { run: n, onConfettiComplete: l, frameRate: c }, canvas: m, context: N } = this, C = Math.min(r - this.lastFrameTime, 50);
453
+ if (c && C < 1e3 / c) {
451
454
  this.rafId = requestAnimationFrame(this.update);
452
455
  return;
453
456
  }
454
- this.lastFrameTime = r - (l ? C % l : 0), n && (T.fillStyle = "white", T.clearRect(0, 0, m.width, m.height)), this.generator.animate(C) ? this.rafId = requestAnimationFrame(this.update) : (c && typeof c == "function" && this.generator.particlesGenerated > 0 && c.call(this, this), this._options.run = !1);
457
+ this.lastFrameTime = r - (c ? C % c : 0), n && (N.fillStyle = "white", N.clearRect(0, 0, m.width, m.height)), this.generator.animate(C) ? this.rafId = requestAnimationFrame(this.update) : (l && typeof l == "function" && this.generator.particlesGenerated > 0 && l.call(this, this), this._options.run = !1);
455
458
  }, this.reset = () => {
456
459
  this.generator && this.generator.particlesGenerated > 0 && (this.generator.particlesGenerated = 0, this.generator.particles = [], this.generator.lastNumberOfPieces = 0);
457
460
  }, this.stop = () => {
@@ -460,7 +463,7 @@ class bt {
460
463
  const i = this.canvas.getContext("2d");
461
464
  if (!i)
462
465
  throw new Error("Could not get canvas context");
463
- this.context = i, this.generator = new vt(this.canvas, () => this.options), this.options = t, this.update();
466
+ this.context = i, this.generator = new wt(this.canvas, () => this.options), this.options = t, this.update();
464
467
  }
465
468
  get options() {
466
469
  return this._options;
@@ -471,26 +474,26 @@ class bt {
471
474
  this.setOptionsWithDefaults(e), this.generator && (Object.assign(this.generator, this.options.confettiSource), typeof e.recycle == "boolean" && e.recycle && i === !1 && (this.generator.lastNumberOfPieces = this.generator.particles.length)), typeof e.run == "boolean" && e.run && t === !1 && this.update();
472
475
  }
473
476
  }
474
- const _t = Ie.createRef();
475
- class Ae extends Ie.Component {
477
+ const gt = Se.createRef();
478
+ class We extends Se.Component {
476
479
  constructor(e) {
477
- super(e), this.canvas = Ie.createRef(), this.canvas = e.canvasRef || _t;
480
+ super(e), this.canvas = Se.createRef(), this.canvas = e.canvasRef || gt;
478
481
  }
479
482
  componentDidMount() {
480
483
  if (this.canvas.current) {
481
- const e = Me(this.props)[0];
482
- this.confetti = new bt(this.canvas.current, e);
484
+ const e = qe(this.props)[0];
485
+ this.confetti = new yt(this.canvas.current, e);
483
486
  }
484
487
  }
485
488
  componentDidUpdate() {
486
- const e = Me(this.props)[0];
489
+ const e = qe(this.props)[0];
487
490
  this.confetti && (this.confetti.options = e);
488
491
  }
489
492
  componentWillUnmount() {
490
493
  this.confetti && this.confetti.stop(), this.confetti = void 0;
491
494
  }
492
495
  render() {
493
- const [e, t] = Me(this.props), i = {
496
+ const [e, t] = qe(this.props), i = {
494
497
  zIndex: 2,
495
498
  position: "absolute",
496
499
  pointerEvents: "none",
@@ -503,39 +506,39 @@ class Ae extends Ie.Component {
503
506
  return h("canvas", { width: e.width, height: e.height, ref: this.canvas, ...t, style: i });
504
507
  }
505
508
  }
506
- Ae.defaultProps = {
507
- ...qe
509
+ We.defaultProps = {
510
+ ...ze
508
511
  };
509
- Ae.displayName = "ReactConfetti";
510
- function Me(o) {
512
+ We.displayName = "ReactConfetti";
513
+ function qe(a) {
511
514
  const e = {}, t = {}, i = {}, r = [
512
- ...Object.keys(qe),
515
+ ...Object.keys(ze),
513
516
  "confettiSource",
514
517
  "drawShape",
515
518
  "onConfettiComplete",
516
519
  "frameRate"
517
520
  ], n = ["canvasRef"];
518
- for (const c in o) {
519
- const l = o[c];
520
- r.includes(c) ? e[c] = l : n.includes(c) ? n[c] = l : i[c] = l;
521
+ for (const l in a) {
522
+ const c = a[l];
523
+ r.includes(l) ? e[l] = c : n.includes(l) ? n[l] = c : i[l] = c;
521
524
  }
522
525
  return [e, i, t];
523
526
  }
524
- const yt = Ie.forwardRef((o, e) => h(Ae, { canvasRef: e, ...o }));
527
+ const xt = Se.forwardRef((a, e) => h(We, { canvasRef: e, ...a }));
525
528
  /**
526
529
  * @license lucide-react v0.515.0 - ISC
527
530
  *
528
531
  * This source code is licensed under the ISC license.
529
532
  * See the LICENSE file in the root directory of this source tree.
530
533
  */
531
- const wt = (o) => o.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), gt = (o) => o.replace(
534
+ const Ct = (a) => a.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), It = (a) => a.replace(
532
535
  /^([A-Z])|[\s-_]+(\w)/g,
533
536
  (e, t, i) => i ? i.toUpperCase() : t.toLowerCase()
534
- ), Qe = (o) => {
535
- const e = gt(o);
537
+ ), He = (a) => {
538
+ const e = It(a);
536
539
  return e.charAt(0).toUpperCase() + e.slice(1);
537
- }, He = (...o) => o.filter((e, t, i) => !!e && e.trim() !== "" && i.indexOf(e) === t).join(" ").trim(), xt = (o) => {
538
- for (const e in o)
540
+ }, et = (...a) => a.filter((e, t, i) => !!e && e.trim() !== "" && i.indexOf(e) === t).join(" ").trim(), Bt = (a) => {
541
+ for (const e in a)
539
542
  if (e.startsWith("aria-") || e === "role" || e === "title")
540
543
  return !0;
541
544
  };
@@ -545,7 +548,7 @@ const wt = (o) => o.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), gt = (
545
548
  * This source code is licensed under the ISC license.
546
549
  * See the LICENSE file in the root directory of this source tree.
547
550
  */
548
- var Ct = {
551
+ var Nt = {
549
552
  xmlns: "http://www.w3.org/2000/svg",
550
553
  width: 24,
551
554
  height: 24,
@@ -562,31 +565,31 @@ var Ct = {
562
565
  * This source code is licensed under the ISC license.
563
566
  * See the LICENSE file in the root directory of this source tree.
564
567
  */
565
- const It = Ge(
568
+ const St = Je(
566
569
  ({
567
- color: o = "currentColor",
570
+ color: a = "currentColor",
568
571
  size: e = 24,
569
572
  strokeWidth: t = 2,
570
573
  absoluteStrokeWidth: i,
571
574
  className: r = "",
572
575
  children: n,
573
- iconNode: c,
574
- ...l
575
- }, m) => Fe(
576
+ iconNode: l,
577
+ ...c
578
+ }, m) => De(
576
579
  "svg",
577
580
  {
578
581
  ref: m,
579
- ...Ct,
582
+ ...Nt,
580
583
  width: e,
581
584
  height: e,
582
- stroke: o,
585
+ stroke: a,
583
586
  strokeWidth: i ? Number(t) * 24 / Number(e) : t,
584
- className: He("lucide", r),
585
- ...!n && !xt(l) && { "aria-hidden": "true" },
586
- ...l
587
+ className: et("lucide", r),
588
+ ...!n && !Bt(c) && { "aria-hidden": "true" },
589
+ ...c
587
590
  },
588
591
  [
589
- ...c.map(([T, C]) => Fe(T, C)),
592
+ ...l.map(([N, C]) => De(N, C)),
590
593
  ...Array.isArray(n) ? n : [n]
591
594
  ]
592
595
  )
@@ -597,20 +600,20 @@ const It = Ge(
597
600
  * This source code is licensed under the ISC license.
598
601
  * See the LICENSE file in the root directory of this source tree.
599
602
  */
600
- const Tt = (o, e) => {
601
- const t = Ge(
602
- ({ className: i, ...r }, n) => Fe(It, {
603
+ const Tt = (a, e) => {
604
+ const t = Je(
605
+ ({ className: i, ...r }, n) => De(St, {
603
606
  ref: n,
604
607
  iconNode: e,
605
- className: He(
606
- `lucide-${wt(Qe(o))}`,
607
- `lucide-${o}`,
608
+ className: et(
609
+ `lucide-${Ct(He(a))}`,
610
+ `lucide-${a}`,
608
611
  i
609
612
  ),
610
613
  ...r
611
614
  })
612
615
  );
613
- return t.displayName = Qe(o), t;
616
+ return t.displayName = He(a), t;
614
617
  };
615
618
  /**
616
619
  * @license lucide-react v0.515.0 - ISC
@@ -618,267 +621,273 @@ const Tt = (o, e) => {
618
621
  * This source code is licensed under the ISC license.
619
622
  * See the LICENSE file in the root directory of this source tree.
620
623
  */
621
- const Bt = [
624
+ const Mt = [
622
625
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
623
626
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
624
- ], St = Tt("search", Bt), Nt = "_backdrop_jv9mc_1", jt = "_celebrationOverlay_jv9mc_14", Pt = "_celebrationChip_jv9mc_23", Ot = "_backdropOpen_jv9mc_74", Mt = "_backdropClosed_jv9mc_78", kt = "_panel_jv9mc_82", Ft = "_panelOpen_jv9mc_102", Rt = "_panelClosed_jv9mc_106", qt = "_header_jv9mc_145", At = "_headerCenter_jv9mc_154", Dt = "_title_jv9mc_162", Lt = "_searchIconButton_jv9mc_171", Wt = "_headerTitleWrap_jv9mc_193", Et = "_headerSearchWrap_jv9mc_197", $t = "_headerSearchOpen_jv9mc_209", Vt = "_searchBar_jv9mc_221", zt = "_searchInput_jv9mc_233", Ut = "_searchClearButton_jv9mc_254", Qt = "_closeButton_jv9mc_276", Yt = "_body_jv9mc_309", Gt = "_muted_jv9mc_314", Kt = "_error_jv9mc_319", Ht = "_variants_jv9mc_324", Xt = "_variantList_jv9mc_328", Jt = "_variantRow_jv9mc_336", Zt = "_variantLeft_jv9mc_344", en = "_addToBundleButton_jv9mc_351", tn = "_variantThumb_jv9mc_379", nn = "_variantThumbImg_jv9mc_389", rn = "_variantThumbFallback_jv9mc_396", on = "_variantInfo_jv9mc_406", an = "_variantName_jv9mc_410", sn = "_variantMeta_jv9mc_419", cn = "_variantPriceRow_jv9mc_427", ln = "_variantCompareAt_jv9mc_434", un = "_variantPrice_jv9mc_427", dn = "_qtyControls_jv9mc_445", hn = "_qtyButton_jv9mc_451", mn = "_qtyValue_jv9mc_476", fn = "_footer_jv9mc_483", pn = "_boxSummaryWindow_jv9mc_490", vn = "_boxSummaryRow_jv9mc_507", bn = "_boxSlot_jv9mc_515", _n = "_boxItem_jv9mc_523", yn = "_boxItemClickable_jv9mc_535", wn = "_boxThresholdLabel_jv9mc_544", gn = "_boxItemPlaceholder_jv9mc_555", xn = "_boxItemFilled_jv9mc_561", Cn = "_boxItemThreshold_jv9mc_567", In = "_boxItemDiscountText_jv9mc_575", Tn = "_boxItemPlus_jv9mc_583", Bn = "_boxItemImage_jv9mc_590", Sn = "_boxItemFallback_jv9mc_597", Nn = "_cta_jv9mc_608", jn = "_ctaTotals_jv9mc_620", Pn = "_ctaDiscountBadge_jv9mc_628", On = "_ctaTotalsWrap_jv9mc_642", Mn = "_ctaTotalsWrapVisible_jv9mc_655", kn = "_ctaTotalsStrike_jv9mc_662", Fn = "_ctaTotalsPrice_jv9mc_669", u = {
625
- backdrop: Nt,
626
- celebrationOverlay: jt,
627
- celebrationChip: Pt,
628
- backdropOpen: Ot,
629
- backdropClosed: Mt,
630
- panel: kt,
631
- panelOpen: Ft,
632
- panelClosed: Rt,
633
- header: qt,
634
- headerCenter: At,
635
- title: Dt,
636
- searchIconButton: Lt,
637
- headerTitleWrap: Wt,
638
- headerSearchWrap: Et,
639
- headerSearchOpen: $t,
640
- searchBar: Vt,
641
- searchInput: zt,
642
- searchClearButton: Ut,
643
- closeButton: Qt,
644
- body: Yt,
645
- muted: Gt,
646
- error: Kt,
647
- variants: Ht,
648
- variantList: Xt,
649
- variantRow: Jt,
650
- variantLeft: Zt,
651
- addToBundleButton: en,
652
- variantThumb: tn,
653
- variantThumbImg: nn,
654
- variantThumbFallback: rn,
655
- variantInfo: on,
656
- variantName: an,
657
- variantMeta: sn,
658
- variantPriceRow: cn,
659
- variantCompareAt: ln,
660
- variantPrice: un,
661
- qtyControls: dn,
662
- qtyButton: hn,
663
- qtyValue: mn,
664
- footer: fn,
665
- boxSummaryWindow: pn,
666
- boxSummaryRow: vn,
667
- boxSlot: bn,
668
- boxItem: _n,
669
- boxItemClickable: yn,
670
- boxThresholdLabel: wn,
671
- boxItemPlaceholder: gn,
672
- boxItemFilled: xn,
673
- boxItemThreshold: Cn,
674
- boxItemDiscountText: In,
627
+ ], jt = Tt("search", Mt), Pt = "_backdrop_jv9mc_1", Ot = "_celebrationOverlay_jv9mc_14", Ft = "_celebrationChip_jv9mc_23", kt = "_backdropOpen_jv9mc_74", Rt = "_backdropClosed_jv9mc_78", qt = "_panel_jv9mc_82", At = "_panelOpen_jv9mc_102", Dt = "_panelClosed_jv9mc_106", Lt = "_header_jv9mc_145", zt = "_headerCenter_jv9mc_154", Wt = "_title_jv9mc_162", Et = "_searchIconButton_jv9mc_171", $t = "_headerTitleWrap_jv9mc_193", Vt = "_headerSearchWrap_jv9mc_197", Ut = "_headerSearchOpen_jv9mc_209", Qt = "_searchBar_jv9mc_221", Yt = "_searchInput_jv9mc_233", Gt = "_searchClearButton_jv9mc_254", Kt = "_closeButton_jv9mc_276", Ht = "_body_jv9mc_309", Xt = "_muted_jv9mc_314", Jt = "_error_jv9mc_319", Zt = "_variants_jv9mc_324", en = "_variantList_jv9mc_328", tn = "_variantRow_jv9mc_336", nn = "_variantLeft_jv9mc_344", rn = "_addToBundleButton_jv9mc_351", an = "_variantThumb_jv9mc_379", on = "_variantThumbImg_jv9mc_389", sn = "_variantThumbFallback_jv9mc_396", cn = "_variantInfo_jv9mc_406", ln = "_variantName_jv9mc_410", un = "_variantMeta_jv9mc_419", dn = "_variantPriceRow_jv9mc_427", hn = "_variantCompareAt_jv9mc_434", mn = "_variantPrice_jv9mc_427", fn = "_qtyControls_jv9mc_445", pn = "_qtyButton_jv9mc_451", vn = "_qtyValue_jv9mc_476", bn = "_footer_jv9mc_483", _n = "_boxSummaryWindow_jv9mc_490", wn = "_boxSummaryRow_jv9mc_507", yn = "_boxSlot_jv9mc_515", gn = "_boxItem_jv9mc_523", xn = "_boxItemClickable_jv9mc_535", Cn = "_boxThresholdLabel_jv9mc_544", In = "_boxItemPlaceholder_jv9mc_555", Bn = "_boxItemFilled_jv9mc_561", Nn = "_boxItemThreshold_jv9mc_567", Sn = "_boxItemDiscountText_jv9mc_575", Tn = "_boxItemPlus_jv9mc_583", Mn = "_boxItemImage_jv9mc_590", jn = "_boxItemFallback_jv9mc_597", Pn = "_cta_jv9mc_608", On = "_ctaTotals_jv9mc_620", Fn = "_ctaDiscountBadge_jv9mc_628", kn = "_ctaTotalsWrap_jv9mc_642", Rn = "_ctaTotalsWrapVisible_jv9mc_655", qn = "_ctaTotalsStrike_jv9mc_662", An = "_ctaTotalsPrice_jv9mc_669", u = {
628
+ backdrop: Pt,
629
+ celebrationOverlay: Ot,
630
+ celebrationChip: Ft,
631
+ backdropOpen: kt,
632
+ backdropClosed: Rt,
633
+ panel: qt,
634
+ panelOpen: At,
635
+ panelClosed: Dt,
636
+ header: Lt,
637
+ headerCenter: zt,
638
+ title: Wt,
639
+ searchIconButton: Et,
640
+ headerTitleWrap: $t,
641
+ headerSearchWrap: Vt,
642
+ headerSearchOpen: Ut,
643
+ searchBar: Qt,
644
+ searchInput: Yt,
645
+ searchClearButton: Gt,
646
+ closeButton: Kt,
647
+ body: Ht,
648
+ muted: Xt,
649
+ error: Jt,
650
+ variants: Zt,
651
+ variantList: en,
652
+ variantRow: tn,
653
+ variantLeft: nn,
654
+ addToBundleButton: rn,
655
+ variantThumb: an,
656
+ variantThumbImg: on,
657
+ variantThumbFallback: sn,
658
+ variantInfo: cn,
659
+ variantName: ln,
660
+ variantMeta: un,
661
+ variantPriceRow: dn,
662
+ variantCompareAt: hn,
663
+ variantPrice: mn,
664
+ qtyControls: fn,
665
+ qtyButton: pn,
666
+ qtyValue: vn,
667
+ footer: bn,
668
+ boxSummaryWindow: _n,
669
+ boxSummaryRow: wn,
670
+ boxSlot: yn,
671
+ boxItem: gn,
672
+ boxItemClickable: xn,
673
+ boxThresholdLabel: Cn,
674
+ boxItemPlaceholder: In,
675
+ boxItemFilled: Bn,
676
+ boxItemThreshold: Nn,
677
+ boxItemDiscountText: Sn,
675
678
  boxItemPlus: Tn,
676
- boxItemImage: Bn,
677
- boxItemFallback: Sn,
678
- cta: Nn,
679
- ctaTotals: jn,
680
- ctaDiscountBadge: Pn,
681
- ctaTotalsWrap: On,
682
- ctaTotalsWrapVisible: Mn,
683
- ctaTotalsStrike: kn,
684
- ctaTotalsPrice: Fn
679
+ boxItemImage: Mn,
680
+ boxItemFallback: jn,
681
+ cta: Pn,
682
+ ctaTotals: On,
683
+ ctaDiscountBadge: Fn,
684
+ ctaTotalsWrap: kn,
685
+ ctaTotalsWrapVisible: Rn,
686
+ ctaTotalsStrike: qn,
687
+ ctaTotalsPrice: An
685
688
  };
686
- function Vn(o) {
687
- var Ve;
689
+ function Qn(a) {
690
+ var Ye;
688
691
  const {
689
692
  isOpen: e,
690
693
  close: t,
691
694
  loading: i,
692
695
  submitting: r,
693
696
  error: n,
694
- currencyCode: c,
695
- config: l,
697
+ currencyCode: l,
698
+ config: c,
696
699
  eligibleVariants: m,
697
- selections: T,
700
+ selections: N,
698
701
  selectionOrder: C,
699
- setQuantity: S,
700
- bundleSize: w,
701
- minRequired: E,
702
- canSubmit: $,
703
- submit: V
704
- } = Re(), [N, M] = I(!1), [v, z] = I(""), ie = A(null), ue = A(null), de = A(null), [Z, ye] = I(() => typeof window > "u" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }), [we, oe] = I(0), [he, ge] = I(null), [ae, U] = I(!1), Q = A(null), ee = A(w), te = 7e3, [ne, xe] = I(0), [se, x] = I(null), [j, O] = I(!1), b = A(null), F = 2800, Y = (a) => {
705
- const s = (a ?? []).filter((d) => {
706
- var y, _;
707
- const p = (y = d == null ? void 0 : d.name) == null ? void 0 : y.trim(), f = (_ = d == null ? void 0 : d.value) == null ? void 0 : _.trim();
708
- return !(!p || !f || p.toLowerCase() === "title");
702
+ setQuantity: T,
703
+ bundleSize: y,
704
+ minRequired: $,
705
+ canSubmit: V,
706
+ submit: U
707
+ } = Le(), [M, O] = B(!1), [f, Q] = B(""), ae = L(null), le = L(null), ue = L(null), [J, ge] = B(() => typeof window > "u" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }), [xe, oe] = B(0), [de, Ce] = B(null), [Ie, Z] = B(!1), R = L(null), he = L(y), ee = 7e3, [te, se] = B(0), [ne, Te] = B(null), [w, S] = B(!1), j = L(null), _ = 2800, F = (o) => {
708
+ const s = Number.parseFloat(o);
709
+ return Number.isFinite(s) ? String(Math.round(s)) : o;
710
+ }, K = (o) => {
711
+ const s = (o ?? []).filter((d) => {
712
+ var g, b;
713
+ const v = (g = d == null ? void 0 : d.name) == null ? void 0 : g.trim(), p = (b = d == null ? void 0 : d.value) == null ? void 0 : b.trim();
714
+ return !(!v || !p || v.toLowerCase() === "title");
709
715
  });
710
716
  return s.length ? s.map((d) => `${d.name}: ${d.value}`).join(" · ") : null;
711
- }, K = (a) => {
717
+ }, Be = (o) => {
712
718
  var s;
713
- return ((s = a.product) == null ? void 0 : s.title) ?? a.displayName ?? a.title;
714
- }, ce = (a) => {
715
- const s = K(a), d = Y(a.selectedOptions);
719
+ return ((s = o.product) == null ? void 0 : s.title) ?? o.displayName ?? o.title;
720
+ }, re = (o) => {
721
+ const s = Be(o), d = K(o.selectedOptions);
716
722
  return [s, d].filter(Boolean).join(" — ");
717
- }, [me, H] = I(e), L = A(null), X = (a) => {
718
- const s = Number(a);
719
- if (!Number.isFinite(s)) return a;
720
- if (c)
723
+ }, [me, H] = B(e), A = L(null), W = (o) => {
724
+ const s = Number(o);
725
+ if (!Number.isFinite(s)) return o;
726
+ if (l)
721
727
  try {
722
- return new Intl.NumberFormat(void 0, { style: "currency", currency: c }).format(s);
728
+ return new Intl.NumberFormat(void 0, { style: "currency", currency: l }).format(s);
723
729
  } catch {
724
730
  }
725
731
  return `$${s.toFixed(2)}`;
726
- }, Xe = ((Ve = l == null ? void 0 : l.title) == null ? void 0 : Ve.trim()) || "Build your bundle", Te = B(() => [...m].sort((a, s) => a.displayName.localeCompare(s.displayName)), [m]), Je = B(() => {
727
- const a = v.trim().toLowerCase();
728
- if (!a) return Te;
729
- const s = a.split(/\s+/).filter(Boolean), d = (p) => {
730
- var _;
731
- const f = [];
732
- f.push(p.displayName), (_ = p.product) != null && _.title && f.push(p.product.title);
733
- for (const g of p.selectedOptions ?? [])
734
- f.push(g.name), f.push(g.value);
735
- const y = f.join(" ").toLowerCase();
736
- return s.every((g) => y.includes(g));
732
+ }, Y = ((Ye = c == null ? void 0 : c.title) == null ? void 0 : Ye.trim()) || "Build your bundle", fe = I(() => {
733
+ const o = Number((c == null ? void 0 : c.maxBundleSize) ?? NaN), s = Number.isFinite(o) ? Math.floor(o) : 100;
734
+ return Math.max(2, Math.min(100, s));
735
+ }, [c == null ? void 0 : c.maxBundleSize]), pe = y >= fe, Me = I(() => [...m].sort((o, s) => o.displayName.localeCompare(s.displayName)), [m]), tt = I(() => {
736
+ const o = f.trim().toLowerCase();
737
+ if (!o) return Me;
738
+ const s = o.split(/\s+/).filter(Boolean), d = (v) => {
739
+ var b;
740
+ const p = [];
741
+ p.push(v.displayName), (b = v.product) != null && b.title && p.push(v.product.title);
742
+ for (const x of v.selectedOptions ?? [])
743
+ p.push(x.name), p.push(x.value);
744
+ const g = p.join(" ").toLowerCase();
745
+ return s.every((x) => g.includes(x));
737
746
  };
738
- return Te.filter(d);
739
- }, [v, Te]), k = B(() => [...(l == null ? void 0 : l.rules) ?? []].sort((a, s) => a.minBundleSize - s.minBundleSize), [l == null ? void 0 : l.rules]), fe = B(() => Math.max(0, E - w), [w, E]), Be = B(() => {
740
- let a = null;
747
+ return Me.filter(d);
748
+ }, [f, Me]), k = I(() => [...(c == null ? void 0 : c.rules) ?? []].sort((o, s) => o.minBundleSize - s.minBundleSize), [c == null ? void 0 : c.rules]), ve = I(() => Math.max(0, $ - y), [y, $]), je = I(() => {
749
+ let o = null;
741
750
  for (const s of k)
742
- w >= s.minBundleSize && (a = s);
743
- return a;
744
- }, [w, k]), pe = B(() => {
745
- if (!Be) return null;
746
- const a = Number.parseFloat(Be.discountPercent);
747
- return !Number.isFinite(a) || a <= 0 ? null : a;
748
- }, [Be]), Ze = B(() => {
749
- const a = k[0];
750
- if (!a) return null;
751
- const s = Number.parseFloat(a.discountPercent);
751
+ y >= s.minBundleSize && (o = s);
752
+ return o;
753
+ }, [y, k]), be = I(() => {
754
+ if (!je) return null;
755
+ const o = Number.parseFloat(je.discountPercent);
756
+ return !Number.isFinite(o) || o <= 0 ? null : o;
757
+ }, [je]), nt = I(() => {
758
+ const o = k[0];
759
+ if (!o) return null;
760
+ const s = Number.parseFloat(o.discountPercent);
752
761
  return !Number.isFinite(s) || s <= 0 ? null : s;
753
- }, [k]), Se = pe ?? Ze, ve = B(() => {
754
- const a = new Map(m.map((d) => [d.id, d]));
762
+ }, [k]), Pe = be ?? nt, _e = I(() => {
763
+ const o = new Map(m.map((d) => [d.id, d]));
755
764
  let s = 0;
756
- for (const [d, p] of Object.entries(T)) {
757
- const f = p ?? 0;
758
- if (f <= 0) continue;
759
- const y = a.get(d), _ = Number(y == null ? void 0 : y.price);
760
- Number.isFinite(_) && (s += _ * f);
765
+ for (const [d, v] of Object.entries(N)) {
766
+ const p = v ?? 0;
767
+ if (p <= 0) continue;
768
+ const g = o.get(d), b = Number(g == null ? void 0 : g.price);
769
+ Number.isFinite(b) && (s += b * p);
761
770
  }
762
771
  return Math.round(s * 100) / 100;
763
- }, [m, T]), et = B(() => {
764
- if (!pe) return ve;
765
- const a = ve * (1 - pe / 100);
766
- return Math.round(a * 100) / 100;
767
- }, [pe, ve]), De = B(() => k.length ? Math.max(...k.map((a) => a.minBundleSize)) : 0, [k]), Ne = B(() => {
768
- const a = new Map(m.map((s) => [s.id, s]));
769
- return C.map((s) => a.get(s)).filter((s) => !!s);
770
- }, [m, C]), tt = B(() => {
772
+ }, [m, N]), rt = I(() => {
773
+ if (!be) return _e;
774
+ const o = _e * (1 - be / 100);
775
+ return Math.round(o * 100) / 100;
776
+ }, [be, _e]), Ee = I(() => k.length ? Math.max(...k.map((o) => o.minBundleSize)) : 0, [k]), Oe = I(() => {
777
+ const o = new Map(m.map((s) => [s.id, s]));
778
+ return C.map((s) => o.get(s)).filter((s) => !!s);
779
+ }, [m, C]), it = I(() => {
771
780
  var s;
772
- const a = /* @__PURE__ */ new Map();
781
+ const o = /* @__PURE__ */ new Map();
773
782
  for (const d of k) {
774
- const p = Math.max(0, d.minBundleSize - 1);
775
- a.set(p, {
783
+ const v = Math.max(0, d.minBundleSize - 1);
784
+ o.set(v, {
776
785
  discountPercent: d.discountPercent,
777
786
  minBundleSize: d.minBundleSize,
778
787
  label: ((s = d.label) == null ? void 0 : s.trim()) || `Buy ${d.minBundleSize}+`
779
788
  });
780
789
  }
781
- return a;
782
- }, [k]), nt = B(() => Math.max(De || E, Ne.length), [Ne.length, De, E]), je = A(null), Le = A(null), We = A(null), Ee = A(w), $e = (a) => {
783
- const s = Le.current;
790
+ return o;
791
+ }, [k]), at = I(() => Math.max(Ee || $, Oe.length), [Oe.length, Ee, $]), Fe = L(null), $e = L(null), Ve = L(null), Ue = L(y), Qe = (o) => {
792
+ const s = $e.current;
784
793
  if (!s) return;
785
- const d = s.querySelector(`[data-variant-row="${a}"]`);
794
+ const d = s.querySelector(`[data-variant-row="${o}"]`);
786
795
  if (!d) return;
787
- const p = s.getBoundingClientRect(), f = d.getBoundingClientRect(), y = 8;
788
- if (f.top >= p.top + y && f.bottom <= p.bottom - y) return;
789
- const g = Math.max(0, s.scrollHeight - s.clientHeight), q = f.top - p.top + f.height / 2, W = s.scrollTop + q - s.clientHeight / 2, G = Math.min(g, Math.max(0, W));
796
+ const v = s.getBoundingClientRect(), p = d.getBoundingClientRect(), g = 8;
797
+ if (p.top >= v.top + g && p.bottom <= v.bottom - g) return;
798
+ const x = Math.max(0, s.scrollHeight - s.clientHeight), D = p.top - v.top + p.height / 2, E = s.scrollTop + D - s.clientHeight / 2, G = Math.min(x, Math.max(0, E));
790
799
  s.scrollTo({ top: G, behavior: "smooth" });
791
800
  };
792
- return D(() => {
801
+ return z(() => {
793
802
  if (!e) return;
794
- const a = (s) => {
803
+ const o = (s) => {
795
804
  s.key === "Escape" && t();
796
805
  };
797
- return window.addEventListener("keydown", a), () => window.removeEventListener("keydown", a);
798
- }, [t, e]), D(() => {
806
+ return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
807
+ }, [t, e]), z(() => {
799
808
  if (typeof window > "u") return;
800
- const a = () => ye({ width: window.innerWidth, height: window.innerHeight });
801
- return a(), window.addEventListener("resize", a), () => window.removeEventListener("resize", a);
802
- }, []), D(() => {
803
- if (L.current != null && (window.clearTimeout(L.current), L.current = null), e) {
809
+ const o = () => ge({ width: window.innerWidth, height: window.innerHeight });
810
+ return o(), window.addEventListener("resize", o), () => window.removeEventListener("resize", o);
811
+ }, []), z(() => {
812
+ if (A.current != null && (window.clearTimeout(A.current), A.current = null), e) {
804
813
  H(!0);
805
814
  return;
806
815
  }
807
- L.current = window.setTimeout(() => {
808
- H(!1), L.current = null;
816
+ A.current = window.setTimeout(() => {
817
+ H(!1), A.current = null;
809
818
  }, 220);
810
- }, [e]), D(() => () => {
811
- L.current != null && window.clearTimeout(L.current);
812
- }, []), D(() => () => {
813
- Q.current != null && window.clearTimeout(Q.current);
814
- }, []), D(() => () => {
815
- b.current != null && window.clearTimeout(b.current);
816
- }, []), D(() => {
817
- if (!e || !N) return;
818
- const a = requestAnimationFrame(() => {
819
+ }, [e]), z(() => () => {
820
+ A.current != null && window.clearTimeout(A.current);
821
+ }, []), z(() => () => {
822
+ R.current != null && window.clearTimeout(R.current);
823
+ }, []), z(() => () => {
824
+ j.current != null && window.clearTimeout(j.current);
825
+ }, []), z(() => {
826
+ if (!e || !M) return;
827
+ const o = requestAnimationFrame(() => {
819
828
  var s;
820
- return (s = ie.current) == null ? void 0 : s.focus();
829
+ return (s = ae.current) == null ? void 0 : s.focus();
821
830
  });
822
- return () => cancelAnimationFrame(a);
823
- }, [e, N]), D(() => {
824
- const a = Ee.current;
825
- if (Ee.current = w, w <= a) return;
826
- const s = We.current;
831
+ return () => cancelAnimationFrame(o);
832
+ }, [e, M]), z(() => {
833
+ const o = Ue.current;
834
+ if (Ue.current = y, y <= o) return;
835
+ const s = Ve.current;
827
836
  if (!s) return;
828
- const d = k.some((_) => _.minBundleSize === w), p = k.find((_) => _.minBundleSize > w), f = p && d ? p.minBundleSize - 1 : p ? null : w - 1;
829
- if (f == null || f < 0) return;
830
- const y = requestAnimationFrame(() => {
831
- const _ = s.querySelector(`[data-box-slot="${f}"]`);
832
- if (!_) return;
833
- const g = s.getBoundingClientRect(), W = _.getBoundingClientRect().right - g.right;
834
- if (W <= 1) return;
835
- const G = Math.max(0, s.scrollWidth - s.clientWidth), re = Math.min(G, Math.max(0, s.scrollLeft + W));
836
- s.scrollTo({ left: re, behavior: "smooth" });
837
+ const d = k.some((b) => b.minBundleSize === y), v = k.find((b) => b.minBundleSize > y), p = v && d ? v.minBundleSize - 1 : v ? null : y - 1;
838
+ if (p == null || p < 0) return;
839
+ const g = requestAnimationFrame(() => {
840
+ const b = s.querySelector(`[data-box-slot="${p}"]`);
841
+ if (!b) return;
842
+ const x = s.getBoundingClientRect(), E = b.getBoundingClientRect().right - x.right;
843
+ if (E <= 1) return;
844
+ const G = Math.max(0, s.scrollWidth - s.clientWidth), ie = Math.min(G, Math.max(0, s.scrollLeft + E));
845
+ s.scrollTo({ left: ie, behavior: "smooth" });
837
846
  });
838
- return () => cancelAnimationFrame(y);
839
- }, [w, k]), D(() => {
847
+ return () => cancelAnimationFrame(g);
848
+ }, [y, k]), z(() => {
840
849
  if (!e) return;
841
- const a = ee.current;
842
- if (ee.current = w, w <= a) return;
843
- const s = k.find((d) => d.minBundleSize === w);
844
- s && (x(`You received a ${s.discountPercent}% discount!`), xe((d) => d + 1), O(!0), b.current != null && window.clearTimeout(b.current), b.current = window.setTimeout(() => {
845
- O(!1), b.current = null;
846
- }, F));
847
- }, [w, e, k]), D(() => {
848
- if (!e || !j || !se) return;
849
- const a = requestAnimationFrame(() => {
850
- var g;
851
- const s = de.current, d = s == null ? void 0 : s.getBoundingClientRect(), p = (g = je.current) == null ? void 0 : g.getBoundingClientRect(), f = d ? d.left + d.width / 2 : p ? p.left + p.width / 2 : window.innerWidth / 2, y = d ? d.top + d.height / 2 : p ? p.top + p.height / 2 : window.innerHeight / 2, _ = {
852
- x: f - 2,
853
- y: y - 2,
850
+ const o = he.current;
851
+ if (he.current = y, y <= o) return;
852
+ const s = k.find((d) => d.minBundleSize === y);
853
+ s && (Te(`You received a ${F(s.discountPercent)}% discount!`), se((d) => d + 1), S(!0), j.current != null && window.clearTimeout(j.current), j.current = window.setTimeout(() => {
854
+ S(!1), j.current = null;
855
+ }, _));
856
+ }, [y, e, k]), z(() => {
857
+ if (!e || !w || !ne) return;
858
+ const o = requestAnimationFrame(() => {
859
+ var x;
860
+ const s = ue.current, d = s == null ? void 0 : s.getBoundingClientRect(), v = (x = Fe.current) == null ? void 0 : x.getBoundingClientRect(), p = d ? d.left + d.width / 2 : v ? v.left + v.width / 2 : window.innerWidth / 2, g = d ? d.top + d.height / 2 : v ? v.top + v.height / 2 : window.innerHeight / 2, b = {
861
+ x: p - 2,
862
+ y: g - 2,
854
863
  w: 4,
855
864
  h: 4
856
865
  };
857
- ge(_), oe((q) => q + 1), U(!0), Q.current != null && window.clearTimeout(Q.current), Q.current = window.setTimeout(() => {
858
- U(!1), Q.current = null;
859
- }, te);
866
+ Ce(b), oe((D) => D + 1), Z(!0), R.current != null && window.clearTimeout(R.current), R.current = window.setTimeout(() => {
867
+ Z(!1), R.current = null;
868
+ }, ee);
860
869
  });
861
- return () => cancelAnimationFrame(a);
862
- }, [ne, se, te, j, e]), D(() => {
863
- var a;
864
- e && ((a = je.current) == null || a.focus());
870
+ return () => cancelAnimationFrame(o);
871
+ }, [te, ne, ee, w, e]), z(() => {
872
+ var o;
873
+ e && ((o = Fe.current) == null || o.focus());
865
874
  }, [e]), me ? /* @__PURE__ */ P(
866
875
  "div",
867
876
  {
868
877
  role: "dialog",
869
878
  "aria-modal": "true",
870
879
  "aria-label": "Bundle builder",
871
- className: [u.backdrop, e ? u.backdropOpen : u.backdropClosed, o.className].filter(Boolean).join(" "),
872
- onMouseDown: (a) => {
873
- a.target === a.currentTarget && t();
880
+ className: [u.backdrop, e ? u.backdropOpen : u.backdropClosed, a.className].filter(Boolean).join(" "),
881
+ onMouseDown: (o) => {
882
+ o.target === o.currentTarget && t();
874
883
  },
875
884
  children: [
876
- ae && he && Z.width > 0 && Z.height > 0 ? /* @__PURE__ */ h(
877
- yt,
885
+ Ie && de && J.width > 0 && J.height > 0 ? /* @__PURE__ */ h(
886
+ xt,
878
887
  {
879
- width: Z.width,
880
- height: Z.height,
881
- confettiSource: he,
888
+ width: J.width,
889
+ height: J.height,
890
+ confettiSource: de,
882
891
  colors: [
883
892
  "#2563eb",
884
893
  // blue-600
@@ -901,52 +910,52 @@ function Vn(o) {
901
910
  initialVelocityX: { min: -6, max: 6 },
902
911
  style: { position: "fixed", inset: 0, pointerEvents: "none", zIndex: 2147483646 }
903
912
  },
904
- we
913
+ xe
905
914
  ) : null,
906
- /* @__PURE__ */ P("aside", { ref: je, className: [u.panel, e ? u.panelOpen : u.panelClosed].filter(Boolean).join(" "), tabIndex: -1, children: [
907
- j && se ? /* @__PURE__ */ h("div", { className: u.celebrationOverlay, "aria-hidden": "true", children: /* @__PURE__ */ h("div", { ref: de, className: u.celebrationChip, children: se }, ne) }) : null,
908
- /* @__PURE__ */ P("header", { className: [u.header, N ? u.headerSearchOpen : null].filter(Boolean).join(" "), children: [
915
+ /* @__PURE__ */ P("aside", { ref: Fe, className: [u.panel, e ? u.panelOpen : u.panelClosed].filter(Boolean).join(" "), tabIndex: -1, children: [
916
+ w && ne ? /* @__PURE__ */ h("div", { className: u.celebrationOverlay, "aria-hidden": "true", children: /* @__PURE__ */ h("div", { ref: ue, className: u.celebrationChip, children: ne }, te) }) : null,
917
+ /* @__PURE__ */ P("header", { className: [u.header, M ? u.headerSearchOpen : null].filter(Boolean).join(" "), children: [
909
918
  /* @__PURE__ */ h(
910
919
  "button",
911
920
  {
912
921
  type: "button",
913
922
  className: u.searchIconButton,
914
- "aria-label": N ? "Search (expanded)" : "Search",
915
- "aria-expanded": N,
923
+ "aria-label": M ? "Search (expanded)" : "Search",
924
+ "aria-expanded": M,
916
925
  onClick: () => {
917
- M(!0);
926
+ O(!0);
918
927
  },
919
- children: /* @__PURE__ */ h(St, { size: 18, "aria-hidden": "true" })
928
+ children: /* @__PURE__ */ h(jt, { size: 18, "aria-hidden": "true" })
920
929
  }
921
930
  ),
922
931
  /* @__PURE__ */ P("div", { className: u.headerCenter, children: [
923
- /* @__PURE__ */ h("div", { className: u.headerTitleWrap, "aria-hidden": N, children: /* @__PURE__ */ h("h2", { className: u.title, children: Xe }) }),
924
- /* @__PURE__ */ h("div", { className: u.headerSearchWrap, "aria-hidden": !N, children: /* @__PURE__ */ P("div", { className: u.searchBar, children: [
932
+ /* @__PURE__ */ h("div", { className: u.headerTitleWrap, "aria-hidden": M, children: /* @__PURE__ */ h("h2", { className: u.title, children: Y }) }),
933
+ /* @__PURE__ */ h("div", { className: u.headerSearchWrap, "aria-hidden": !M, children: /* @__PURE__ */ P("div", { className: u.searchBar, children: [
925
934
  /* @__PURE__ */ h(
926
935
  "input",
927
936
  {
928
- ref: ie,
937
+ ref: ae,
929
938
  className: u.searchInput,
930
939
  type: "search",
931
- value: v,
940
+ value: f,
932
941
  placeholder: "Search",
933
- onChange: (a) => z(a.target.value),
942
+ onChange: (o) => Q(o.target.value),
934
943
  onBlur: () => {
935
- v.trim() === "" && M(!1);
944
+ f.trim() === "" && O(!1);
936
945
  }
937
946
  }
938
947
  ),
939
- v.trim() ? /* @__PURE__ */ h(
948
+ f.trim() ? /* @__PURE__ */ h(
940
949
  "button",
941
950
  {
942
951
  type: "button",
943
952
  className: u.searchClearButton,
944
- onMouseDown: (a) => {
945
- a.preventDefault();
953
+ onMouseDown: (o) => {
954
+ o.preventDefault();
946
955
  },
947
956
  onClick: () => {
948
- var a;
949
- z(""), (a = ie.current) == null || a.focus();
957
+ var o;
958
+ Q(""), (o = ae.current) == null || o.focus();
950
959
  },
951
960
  "aria-label": "Clear search",
952
961
  children: "Clear"
@@ -956,31 +965,31 @@ function Vn(o) {
956
965
  ] }),
957
966
  /* @__PURE__ */ h("button", { type: "button", onClick: t, disabled: r, className: u.closeButton, "aria-label": "Close", children: "×" })
958
967
  ] }),
959
- /* @__PURE__ */ P("div", { className: u.body, ref: Le, children: [
968
+ /* @__PURE__ */ P("div", { className: u.body, ref: $e, children: [
960
969
  i ? /* @__PURE__ */ h("p", { className: u.muted, children: "Loading…" }) : null,
961
970
  n ? /* @__PURE__ */ h("p", { className: u.error, children: n }) : null,
962
- !i && l && !l.isActive ? /* @__PURE__ */ h("p", { className: u.error, children: "Bundles are not active." }) : null,
963
- /* @__PURE__ */ h("div", { className: u.variants, children: /* @__PURE__ */ h("ul", { className: u.variantList, children: Je.map((a) => {
964
- var W, G, re, be;
965
- const s = T[a.id] ?? 0, d = K(a), p = Y(a.selectedOptions), f = ce(a), y = Se, _ = Number(a.price), g = y != null && Number.isFinite(y) && y > 0 && Number.isFinite(_), q = g ? Math.round(_ * (1 - y / 100) * 100) / 100 : null;
966
- return /* @__PURE__ */ P("li", { className: u.variantRow, "data-variant-row": a.id, children: [
971
+ !i && c && !c.isActive ? /* @__PURE__ */ h("p", { className: u.error, children: "Bundles are not active." }) : null,
972
+ /* @__PURE__ */ h("div", { className: u.variants, children: /* @__PURE__ */ h("ul", { className: u.variantList, children: tt.map((o) => {
973
+ var E, G, ie, we;
974
+ const s = N[o.id] ?? 0, d = Be(o), v = K(o.selectedOptions), p = re(o), g = Pe, b = Number(o.price), x = g != null && Number.isFinite(g) && g > 0 && Number.isFinite(b), D = x ? Math.round(b * (1 - g / 100) * 100) / 100 : null;
975
+ return /* @__PURE__ */ P("li", { className: u.variantRow, "data-variant-row": o.id, children: [
967
976
  /* @__PURE__ */ P("div", { className: u.variantLeft, children: [
968
- /* @__PURE__ */ h("div", { className: u.variantThumb, "aria-hidden": "true", children: (W = a.image) != null && W.url ? /* @__PURE__ */ h(
977
+ /* @__PURE__ */ h("div", { className: u.variantThumb, "aria-hidden": "true", children: (E = o.image) != null && E.url ? /* @__PURE__ */ h(
969
978
  "img",
970
979
  {
971
980
  className: u.variantThumbImg,
972
- src: a.image.url,
973
- alt: a.image.altText ?? f,
981
+ src: o.image.url,
982
+ alt: o.image.altText ?? p,
974
983
  loading: "lazy"
975
984
  }
976
- ) : /* @__PURE__ */ h("div", { className: u.variantThumbFallback, children: ((be = (re = (G = a.product) == null ? void 0 : G.title) == null ? void 0 : re.slice(0, 1)) == null ? void 0 : be.toUpperCase()) ?? "•" }) }),
985
+ ) : /* @__PURE__ */ h("div", { className: u.variantThumbFallback, children: ((we = (ie = (G = o.product) == null ? void 0 : G.title) == null ? void 0 : ie.slice(0, 1)) == null ? void 0 : we.toUpperCase()) ?? "•" }) }),
977
986
  /* @__PURE__ */ P("div", { className: u.variantInfo, children: [
978
987
  /* @__PURE__ */ h("div", { className: u.variantName, children: d }),
979
- p ? /* @__PURE__ */ h("div", { className: u.variantMeta, children: p }) : null,
988
+ v ? /* @__PURE__ */ h("div", { className: u.variantMeta, children: v }) : null,
980
989
  /* @__PURE__ */ P("div", { className: u.variantPriceRow, children: [
981
- g ? /* @__PURE__ */ h("span", { className: u.variantCompareAt, children: X(Number.isFinite(_) ? _.toFixed(2) : a.price) }) : null,
982
- /* @__PURE__ */ h("span", { className: u.variantPrice, children: X(
983
- q != null ? q.toFixed(2) : Number.isFinite(_) ? _.toFixed(2) : a.price
990
+ x ? /* @__PURE__ */ h("span", { className: u.variantCompareAt, children: W(Number.isFinite(b) ? b.toFixed(2) : o.price) }) : null,
991
+ /* @__PURE__ */ h("span", { className: u.variantPrice, children: W(
992
+ D != null ? D.toFixed(2) : Number.isFinite(b) ? b.toFixed(2) : o.price
984
993
  ) })
985
994
  ] })
986
995
  ] })
@@ -989,10 +998,10 @@ function Vn(o) {
989
998
  "button",
990
999
  {
991
1000
  type: "button",
992
- onClick: () => S(a.id, 1),
993
- disabled: r,
1001
+ onClick: () => T(o.id, 1),
1002
+ disabled: r || pe,
994
1003
  className: u.addToBundleButton,
995
- "aria-label": `Add ${f} to bundle`,
1004
+ "aria-label": `Add ${p} to bundle`,
996
1005
  children: "Add"
997
1006
  }
998
1007
  ) : /* @__PURE__ */ P("div", { className: u.qtyControls, children: [
@@ -1000,10 +1009,10 @@ function Vn(o) {
1000
1009
  "button",
1001
1010
  {
1002
1011
  type: "button",
1003
- onClick: () => S(a.id, s - 1),
1012
+ onClick: () => T(o.id, s - 1),
1004
1013
  disabled: r || s <= 0,
1005
1014
  className: u.qtyButton,
1006
- "aria-label": `Decrease ${f}`,
1015
+ "aria-label": `Decrease ${p}`,
1007
1016
  children: "−"
1008
1017
  }
1009
1018
  ),
@@ -1012,40 +1021,40 @@ function Vn(o) {
1012
1021
  "button",
1013
1022
  {
1014
1023
  type: "button",
1015
- onClick: () => S(a.id, s + 1),
1016
- disabled: r,
1024
+ onClick: () => T(o.id, s + 1),
1025
+ disabled: r || pe,
1017
1026
  className: u.qtyButton,
1018
- "aria-label": `Increase ${f}`,
1027
+ "aria-label": `Increase ${p}`,
1019
1028
  children: "+"
1020
1029
  }
1021
1030
  )
1022
1031
  ] })
1023
- ] }, a.id);
1032
+ ] }, o.id);
1024
1033
  }) }) })
1025
1034
  ] }),
1026
- /* @__PURE__ */ P("footer", { className: u.footer, ref: ue, children: [
1027
- /* @__PURE__ */ h("div", { className: u.boxSummaryWindow, ref: We, children: /* @__PURE__ */ h("div", { className: u.boxSummaryRow, "aria-label": "Bundle box summary", children: Array.from({ length: nt }).map((a, s) => {
1028
- var W, G, re, be;
1029
- const d = Ne[s], p = tt.get(s), f = !!d, y = !!p, _ = y && !f, g = p ? `${p.discountPercent}% off` : null, q = f ? d.displayName : `Slot ${s + 1}`;
1035
+ /* @__PURE__ */ P("footer", { className: u.footer, ref: le, children: [
1036
+ /* @__PURE__ */ h("div", { className: u.boxSummaryWindow, ref: Ve, children: /* @__PURE__ */ h("div", { className: u.boxSummaryRow, "aria-label": "Bundle box summary", children: Array.from({ length: at }).map((o, s) => {
1037
+ var E, G, ie, we;
1038
+ const d = Oe[s], v = it.get(s), p = !!d, g = !!v, b = g && !p, x = v ? `${v.discountPercent}% off` : null, D = p ? d.displayName : `Slot ${s + 1}`;
1030
1039
  return /* @__PURE__ */ P("div", { "data-box-slot": s, className: u.boxSlot, children: [
1031
1040
  /* @__PURE__ */ h(
1032
1041
  "div",
1033
1042
  {
1034
1043
  className: [
1035
1044
  u.boxItem,
1036
- f ? u.boxItemFilled : u.boxItemPlaceholder,
1037
- y ? u.boxItemThreshold : null,
1038
- f ? u.boxItemClickable : null
1045
+ p ? u.boxItemFilled : u.boxItemPlaceholder,
1046
+ g ? u.boxItemThreshold : null,
1047
+ p ? u.boxItemClickable : null
1039
1048
  ].filter(Boolean).join(" "),
1040
- role: f ? "button" : void 0,
1041
- tabIndex: f ? 0 : void 0,
1042
- onClick: f ? () => $e(d.id) : void 0,
1043
- onKeyDown: f ? (Pe) => {
1044
- (Pe.key === "Enter" || Pe.key === " ") && (Pe.preventDefault(), $e(d.id));
1049
+ role: p ? "button" : void 0,
1050
+ tabIndex: p ? 0 : void 0,
1051
+ onClick: p ? () => Qe(d.id) : void 0,
1052
+ onKeyDown: p ? (ke) => {
1053
+ (ke.key === "Enter" || ke.key === " ") && (ke.preventDefault(), Qe(d.id));
1045
1054
  } : void 0,
1046
- "aria-label": _ && g ? `${q}. Unlocks ${g}.` : q,
1047
- title: _ && g ? `${q} • Unlocks ${g}` : q,
1048
- children: f ? (W = d.image) != null && W.url ? /* @__PURE__ */ h(
1055
+ "aria-label": b && x ? `${D}. Unlocks ${x}.` : D,
1056
+ title: b && x ? `${D} • Unlocks ${x}` : D,
1057
+ children: p ? (E = d.image) != null && E.url ? /* @__PURE__ */ h(
1049
1058
  "img",
1050
1059
  {
1051
1060
  className: u.boxItemImage,
@@ -1053,61 +1062,61 @@ function Vn(o) {
1053
1062
  alt: d.image.altText ?? d.displayName,
1054
1063
  loading: "lazy"
1055
1064
  }
1056
- ) : /* @__PURE__ */ h("div", { className: u.boxItemFallback, "aria-hidden": "true", children: ((be = (re = (G = d.product) == null ? void 0 : G.title) == null ? void 0 : re.slice(0, 1)) == null ? void 0 : be.toUpperCase()) ?? "•" }) : _ && g ? /* @__PURE__ */ h("div", { className: u.boxItemDiscountText, children: g }) : /* @__PURE__ */ h("div", { className: u.boxItemPlus, "aria-hidden": "true", children: "+" })
1065
+ ) : /* @__PURE__ */ h("div", { className: u.boxItemFallback, "aria-hidden": "true", children: ((we = (ie = (G = d.product) == null ? void 0 : G.title) == null ? void 0 : ie.slice(0, 1)) == null ? void 0 : we.toUpperCase()) ?? "•" }) : b && x ? /* @__PURE__ */ h("div", { className: u.boxItemDiscountText, children: x }) : /* @__PURE__ */ h("div", { className: u.boxItemPlus, "aria-hidden": "true", children: "+" })
1057
1066
  }
1058
1067
  ),
1059
- y ? /* @__PURE__ */ h("div", { className: u.boxThresholdLabel, children: p.label }) : null
1068
+ g ? /* @__PURE__ */ h("div", { className: u.boxThresholdLabel, children: v.label }) : null
1060
1069
  ] }, s);
1061
1070
  }) }) }),
1062
1071
  /* @__PURE__ */ h(
1063
1072
  "div",
1064
1073
  {
1065
- className: [u.ctaTotalsWrap, fe <= 0 ? u.ctaTotalsWrapVisible : null].filter(Boolean).join(" "),
1066
- "aria-hidden": fe > 0,
1074
+ className: [u.ctaTotalsWrap, ve <= 0 ? u.ctaTotalsWrapVisible : null].filter(Boolean).join(" "),
1075
+ "aria-hidden": ve > 0,
1067
1076
  children: /* @__PURE__ */ P("div", { className: u.ctaTotals, "aria-label": "Totals", children: [
1068
- Se ? /* @__PURE__ */ P("span", { className: u.ctaDiscountBadge, children: [
1069
- Se,
1077
+ Pe ? /* @__PURE__ */ P("span", { className: u.ctaDiscountBadge, children: [
1078
+ Pe,
1070
1079
  "% Discount"
1071
1080
  ] }) : /* @__PURE__ */ h("span", {}),
1072
- /* @__PURE__ */ h("span", { children: pe ? /* @__PURE__ */ P(rt, { children: [
1073
- /* @__PURE__ */ h("span", { className: u.ctaTotalsStrike, children: X(ve.toFixed(2)) }),
1081
+ /* @__PURE__ */ h("span", { children: be ? /* @__PURE__ */ P(ot, { children: [
1082
+ /* @__PURE__ */ h("span", { className: u.ctaTotalsStrike, children: W(_e.toFixed(2)) }),
1074
1083
  " ",
1075
- /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: X(et.toFixed(2)) })
1076
- ] }) : /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: X(ve.toFixed(2)) }) })
1084
+ /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: W(rt.toFixed(2)) })
1085
+ ] }) : /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: W(_e.toFixed(2)) }) })
1077
1086
  ] })
1078
1087
  }
1079
1088
  ),
1080
- /* @__PURE__ */ h("button", { type: "button", onClick: V, disabled: !$, className: u.cta, children: r ? "Adding…" : fe > 0 ? `Add ${fe} more product${fe === 1 ? "" : "s"}` : "Add to Basket" })
1089
+ /* @__PURE__ */ h("button", { type: "button", onClick: U, disabled: !V, className: u.cta, children: r ? "Adding…" : ve > 0 ? `Add ${ve} more product${ve === 1 ? "" : "s"}` : "Add to Basket" })
1081
1090
  ] })
1082
1091
  ] })
1083
1092
  ]
1084
1093
  }
1085
1094
  ) : null;
1086
1095
  }
1087
- function Ye(o) {
1088
- if (o != null && o.length)
1089
- return o.reduce((e, t) => (t != null && t.key && (e[t.key] = t.value ?? ""), e), {});
1096
+ function Xe(a) {
1097
+ if (a != null && a.length)
1098
+ return a.reduce((e, t) => (t != null && t.key && (e[t.key] = t.value ?? ""), e), {});
1090
1099
  }
1091
- function Rn(o) {
1092
- const e = /\/(\d+)$/.exec(o);
1093
- return e ? e[1] : o;
1100
+ function Dn(a) {
1101
+ const e = /\/(\d+)$/.exec(a);
1102
+ return e ? e[1] : a;
1094
1103
  }
1095
- function qn() {
1096
- var o;
1097
- return ((o = window == null ? void 0 : window.routes) == null ? void 0 : o.cart_url) || "/cart";
1104
+ function Ln() {
1105
+ var a;
1106
+ return ((a = window == null ? void 0 : window.routes) == null ? void 0 : a.cart_url) || "/cart";
1098
1107
  }
1099
- async function An() {
1108
+ async function zn() {
1100
1109
  try {
1101
- const o = qn(), e = encodeURIComponent("cart-drawer,cart-icon-bubble,cart-live-region-text"), t = await fetch(`${o}?sections=${e}`, { method: "GET" });
1110
+ const a = Ln(), e = encodeURIComponent("cart-drawer,cart-icon-bubble,cart-live-region-text"), t = await fetch(`${a}?sections=${e}`, { method: "GET" });
1102
1111
  if (!t.ok) return;
1103
1112
  const i = await t.json().catch(() => null);
1104
1113
  if (!i) return;
1105
1114
  const r = ["cart-drawer", "cart-icon-bubble", "cart-live-region-text"];
1106
- for (const l of r) {
1107
- const m = i[l];
1115
+ for (const c of r) {
1116
+ const m = i[c];
1108
1117
  if (!m) continue;
1109
- const T = new DOMParser().parseFromString(m, "text/html"), C = T.getElementById(l) || T.querySelector(l), S = document.getElementById(l) || document.querySelector(l);
1110
- S && C && S.replaceWith(C);
1118
+ const N = new DOMParser().parseFromString(m, "text/html"), C = N.getElementById(c) || N.querySelector(c), T = document.getElementById(c) || document.querySelector(c);
1119
+ T && C && T.replaceWith(C);
1111
1120
  }
1112
1121
  const n = document.querySelector("cart-drawer");
1113
1122
  if (n && typeof n.open == "function") {
@@ -1115,13 +1124,13 @@ async function An() {
1115
1124
  return;
1116
1125
  }
1117
1126
  document.body.classList.add("overflow-hidden");
1118
- const c = document.querySelector("cart-drawer") || document.querySelector("cart-notification");
1119
- c && (c.classList.contains("is-empty") && c.classList.remove("is-empty"), c.classList.add("active"));
1127
+ const l = document.querySelector("cart-drawer") || document.querySelector("cart-notification");
1128
+ l && (l.classList.contains("is-empty") && l.classList.remove("is-empty"), l.classList.add("active"));
1120
1129
  } catch {
1121
1130
  }
1122
1131
  }
1123
- async function ke(o, e) {
1124
- const t = await fetch(o, {
1132
+ async function Ae(a, e) {
1133
+ const t = await fetch(a, {
1125
1134
  method: "POST",
1126
1135
  headers: {
1127
1136
  Accept: "application/json",
@@ -1135,42 +1144,42 @@ async function ke(o, e) {
1135
1144
  }
1136
1145
  return t.json().catch(() => null);
1137
1146
  }
1138
- function zn() {
1147
+ function Yn() {
1139
1148
  return {
1140
- async linesAdd(o) {
1141
- const e = o.map((t) => ({
1142
- id: Rn(t.merchandiseId),
1149
+ async linesAdd(a) {
1150
+ const e = a.map((t) => ({
1151
+ id: Dn(t.merchandiseId),
1143
1152
  quantity: t.quantity,
1144
- properties: Ye(t.attributes)
1153
+ properties: Xe(t.attributes)
1145
1154
  }));
1146
- await ke("/cart/add.js", { items: e });
1155
+ await Ae("/cart/add.js", { items: e });
1147
1156
  },
1148
- async linesUpdate(o) {
1149
- for (const e of o)
1150
- await ke("/cart/change.js", {
1157
+ async linesUpdate(a) {
1158
+ for (const e of a)
1159
+ await Ae("/cart/change.js", {
1151
1160
  id: e.id,
1152
1161
  quantity: e.quantity,
1153
- properties: Ye(e.attributes)
1162
+ properties: Xe(e.attributes)
1154
1163
  });
1155
1164
  },
1156
- async linesRemove(o) {
1157
- for (const e of o)
1158
- await ke("/cart/change.js", { id: e, quantity: 0 });
1165
+ async linesRemove(a) {
1166
+ for (const e of a)
1167
+ await Ae("/cart/change.js", { id: e, quantity: 0 });
1159
1168
  },
1160
1169
  openCartUI() {
1161
1170
  window.setTimeout(() => {
1162
- An();
1171
+ zn();
1163
1172
  }, 0);
1164
1173
  }
1165
1174
  };
1166
1175
  }
1167
1176
  export {
1168
- Vn as BundleBuilderDrawer,
1169
- $n as BundleButton,
1170
- Ce as BundleLineAttributeKeys,
1171
- Wn as BundleProvider,
1172
- zn as createLiquidCartAdapter,
1173
- Re as useBundleBuilder,
1174
- En as useBundleBuilderDrawer
1177
+ Qn as BundleBuilderDrawer,
1178
+ Un as BundleButton,
1179
+ Ne as BundleLineAttributeKeys,
1180
+ $n as BundleProvider,
1181
+ Yn as createLiquidCartAdapter,
1182
+ Le as useBundleBuilder,
1183
+ Vn as useBundleBuilderDrawer
1175
1184
  };
1176
1185
  //# sourceMappingURL=index.js.map