@best-bundles/bundle-ui 0.0.19 → 0.0.20
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/adapters/LiquidAdapter.d.ts.map +1 -1
- package/dist/components/BundleBuilderDrawer.d.ts.map +1 -1
- package/dist/context/BundleProvider.d.ts.map +1 -1
- package/dist/index.js +699 -689
- package/dist/index.js.map +1 -1
- package/dist/liquid/bundle-ui.iife.js +14 -14
- package/dist/liquid/bundle-ui.iife.js.map +1 -1
- package/dist/stories/BundleUI.stories.d.ts.map +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.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_vl21a_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_vl21a_14{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;pointer-events:none;z-index:50}._celebrationChip_vl21a_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_vl21a_1 2.8s cubic-bezier(.16,1,.3,1) forwards;filter:saturate(1.05)}@keyframes _bbCelebrationPop_vl21a_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_vl21a_74{opacity:1}._backdropClosed_vl21a_78{opacity:0}._panel_vl21a_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_vl21a_102{animation:_bbSlideInFromRight_vl21a_1 var(--bb-drawer-transition-duration, .22s) ease forwards}._panelClosed_vl21a_106{animation:_bbSlideOutToRight_vl21a_1 var(--bb-drawer-transition-duration, .22s) ease forwards}@keyframes _bbSlideInFromRight_vl21a_1{0%{transform:translate(110%)}to{transform:translate(0)}}@keyframes _bbSlideOutToRight_vl21a_1{0%{transform:translate(0)}to{transform:translate(110%)}}@media(prefers-reduced-motion:reduce){._backdrop_vl21a_1{transition:none}._celebrationChip_vl21a_23,._panelOpen_vl21a_102,._panelClosed_vl21a_106{animation:none}}._header_vl21a_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_vl21a_154{position:relative;min-width:0;display:flex;justify-content:center;align-items:center}._title_vl21a_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_vl21a_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_vl21a_171:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._searchIconButton_vl21a_171:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._headerTitleWrap_vl21a_193{transition:opacity .18s ease,transform .22s ease}._headerSearchWrap_vl21a_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_vl21a_209 ._headerTitleWrap_vl21a_193{opacity:0;transform:translateY(2px);pointer-events:none}._headerSearchOpen_vl21a_209 ._headerSearchWrap_vl21a_197{opacity:1;transform:translateY(0);pointer-events:auto}._searchBar_vl21a_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_vl21a_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_vl21a_233::-webkit-search-cancel-button,._searchInput_vl21a_233::-webkit-search-decoration,._searchInput_vl21a_233::-webkit-search-results-button,._searchInput_vl21a_233::-webkit-search-results-decoration{-webkit-appearance:none;-moz-appearance:none;appearance:none}._searchClearButton_vl21a_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_vl21a_254:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._searchClearButton_vl21a_254:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._closeButton_vl21a_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_vl21a_276:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._closeButton_vl21a_276:disabled{opacity:.6;cursor:not-allowed}._closeButton_vl21a_276:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}@media(prefers-reduced-motion:reduce){._headerTitleWrap_vl21a_193,._headerSearchWrap_vl21a_197{transition:none}}._body_vl21a_309{padding:var(--bb-body-padding, 8px 16px);overflow:auto}._muted_vl21a_314{color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65));margin:0 0 12px}._error_vl21a_319{color:var(--bb-error-color, #b91c1c);margin:0 0 12px}._variants_vl21a_324{margin-top:4px}._variantList_vl21a_328{list-style:none;padding:0;margin:0;display:grid;gap:10px}._variantRow_vl21a_336{display:grid;grid-template-columns:1fr auto;gap:0px;align-items:stretch;padding:5px}._variantLeft_vl21a_344{min-width:0;display:flex;gap:12px;align-items:center}._addToBundleButton_vl21a_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_vl21a_351:hover{background:var(--bb-cta-bg-hover, #1d4ed8)}._addToBundleButton_vl21a_351:disabled{opacity:.6;cursor:not-allowed}._addToBundleButton_vl21a_351:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._variantThumb_vl21a_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_vl21a_389{width:100%;height:100%;object-fit:cover;display:block}._variantThumbFallback_vl21a_396{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-weight:800;color:var(--bb-text-color, #111827)}._variantInfo_vl21a_406{min-width:0}._variantName_vl21a_410{font-size:14px;font-weight:600;margin-bottom:2px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._variantMeta_vl21a_419{font-size:12px;color:var(--bb-muted-color, rgba(17, 24, 39, .6));overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._variantPriceRow_vl21a_427{display:flex;align-items:baseline;gap:8px;margin-top:4px}._variantCompareAt_vl21a_434{font-size:12px;color:var(--bb-muted-color, rgba(17, 24, 39, .6));text-decoration:line-through}._variantPrice_vl21a_427{font-size:13px;font-weight:800}._qtyControls_vl21a_445{display:inline-flex;align-items:center;gap:6px}._qtyButton_vl21a_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_vl21a_451:hover{background:var(--bb-control-bg-hover, rgba(17, 24, 39, .04))}._qtyButton_vl21a_451:disabled{opacity:.6;cursor:not-allowed}._qtyButton_vl21a_451:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._qtyValue_vl21a_476{min-width:18px;text-align:center;font-variant-numeric:tabular-nums;font-weight:700}._footer_vl21a_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}._poweredBy_vl21a_490{font-size:10px;color:var(rgba(17, 24, 39, .6));text-align:center;margin-top:10px}._poweredBy_vl21a_490 a{color:inherit;text-decoration:none}._boxSummaryWindow_vl21a_502{margin-bottom:6px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;padding-bottom:6px;scrollbar-width:none;-ms-overflow-style:none}._boxSummaryWindow_vl21a_502::-webkit-scrollbar{display:none}._boxSummaryRow_vl21a_519{--bb-box-gap: 10px;display:flex;align-items:flex-start;gap:var(--bb-box-gap);width:100%}._boxSlot_vl21a_527{flex:0 0 calc((100% - (4 * var(--bb-box-gap))) / 5);display:flex;flex-direction:column;align-items:stretch;gap:6px}._boxItem_vl21a_535{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_vl21a_547{cursor:pointer}._boxItemClickable_vl21a_547:focus-visible{outline:2px solid var(--bb-focus-ring, #2563eb);outline-offset:2px}._boxThresholdLabel_vl21a_556{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_vl21a_567{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_vl21a_573{border:1px solid var(--bb-border-color, rgba(17, 24, 39, .08));background:var(--bb-surface-bg, #ffffff);overflow:hidden}._boxItemThreshold_vl21a_579{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_vl21a_587{font-size:12px;font-weight:800;text-align:center;line-height:1.1;padding:6px}._boxItemPlus_vl21a_595{font-size:22px;font-weight:700;opacity:.5;line-height:1}._boxItemImage_vl21a_602{width:100%;height:100%;object-fit:cover;display:block}._boxItemFallback_vl21a_609{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}._ctaButtonGroup_vl21a_620{display:flex;gap:8px;width:100%;transition:gap .3s cubic-bezier(.4,0,.2,1)}._ctaButtonGroupAnimating_vl21a_627{gap:0}._cta_vl21a_620{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}._ctaSecondary_vl21a_643{width:100%;border:2px solid var(--bb-cta-bg, #2563eb);background:transparent;color:var(--bb-cta-bg, #2563eb);font:inherit;font-weight:700;padding:10px 14px;border-radius:12px;cursor:pointer}._ctaDualLeft_vl21a_655{width:100%;border:2px solid var(--bb-cta-bg, #2563eb);background:transparent;color:var(--bb-cta-bg, #2563eb);font:inherit;font-weight:700;padding:10px 14px;border-radius:12px;cursor:pointer;transition:border-radius .3s cubic-bezier(.4,0,.2,1),background .3s cubic-bezier(.4,0,.2,1),color .3s cubic-bezier(.4,0,.2,1),border-right-width .3s cubic-bezier(.4,0,.2,1),opacity .3s cubic-bezier(.4,0,.2,1)}._ctaDualLeftAnimating_vl21a_673{border-top-right-radius:0;border-bottom-right-radius:0;border-right-width:0;background:var(--bb-cta-bg, #2563eb);opacity:.6;color:var(--bb-cta-text, #ffffff)}._ctaDualLeftAnimating_vl21a_673>span{opacity:0}._ctaDualRight_vl21a_686{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;transition:border-radius .3s cubic-bezier(.4,0,.2,1),border-left-width .3s cubic-bezier(.4,0,.2,1),opacity .3s cubic-bezier(.4,0,.2,1)}._ctaDualRightAnimating_vl21a_702{border-top-left-radius:0;border-bottom-left-radius:0;border-left-width:0;opacity:.6}._ctaDualRightAnimating_vl21a_702>span{opacity:0}._ctaTotals_vl21a_713{display:flex;justify-content:space-between;align-items:baseline;gap:10px;font-variant-numeric:tabular-nums}._ctaDiscountBadge_vl21a_721{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_vl21a_735{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_vl21a_748{max-height:40px;opacity:1;transform:translateY(0);margin-bottom:8px}._ctaTotalsStrike_vl21a_755{opacity:.85;text-decoration:line-through;font-weight:700;color:var(--bb-muted-strong-color, rgba(17, 24, 39, .65))}._ctaTotalsPrice_vl21a_762{font-weight:900;color:var(--bb-text-color, #111827)}@media(prefers-reduced-motion:reduce){._ctaTotalsWrap_vl21a_735{transition:none}}._cta_vl21a_620:hover{background:var(--bb-cta-bg-hover, #1d4ed8)}._cta_vl21a_620:disabled{opacity:.6;cursor:not-allowed}._cta_vl21a_620:focus-visible{outline:2px solid var(--bb-cta-focus-ring, var(--bb-text-color, #111827));outline-offset:2px}._ctaSecondary_vl21a_643:hover{background:var(--bb-cta-bg, #2563eb);color:var(--bb-cta-text, #ffffff)}._ctaSecondary_vl21a_643:disabled{opacity:.6;cursor:not-allowed}._ctaSecondary_vl21a_643:focus-visible{outline:2px solid var(--bb-cta-focus-ring, var(--bb-text-color, #111827));outline-offset:2px}._ctaDualLeft_vl21a_655:hover{background:var(--bb-cta-bg, #2563eb);color:var(--bb-cta-text, #ffffff)}._ctaDualLeft_vl21a_655:disabled{opacity:.6;cursor:not-allowed}._ctaDualLeft_vl21a_655:focus-visible{outline:2px solid var(--bb-cta-focus-ring, var(--bb-text-color, #111827));outline-offset:2px}._ctaDualRight_vl21a_686:hover{background:var(--bb-cta-bg-hover, #1d4ed8)}._ctaDualRight_vl21a_686:disabled{opacity:.6;cursor:not-allowed}._ctaDualRight_vl21a_686:focus-visible{outline:2px solid var(--bb-cta-focus-ring, var(--bb-text-color, #111827));outline-offset:2px}._helperText_vl21a_831{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_vl21a_1{padding:0;justify-content:stretch}._panel_vl21a_82{width:100%;height:100%;border-radius:0}}')),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
-
import { jsx as h, jsxs as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
2
|
+
import { jsx as h, jsxs as O, Fragment as mt } from "react/jsx-runtime";
|
|
3
|
+
import qe, { useState as P, useRef as L, useEffect as $, useCallback as ue, useMemo as T, createContext as pt, useContext as vt, forwardRef as lt, createElement as Ge } from "react";
|
|
4
|
+
const Fe = {
|
|
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
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
10
|
+
async function bt(i) {
|
|
11
|
+
const e = new URL("/api/public/bundle-config", i.apiBaseUrl);
|
|
12
|
+
e.searchParams.set("shop", i.shop);
|
|
13
|
+
const r = await (await fetch(e, {
|
|
14
14
|
method: "GET",
|
|
15
15
|
signal: i.signal,
|
|
16
16
|
headers: { "Content-Type": "application/json" }
|
|
17
17
|
})).json().catch(() => null);
|
|
18
|
-
return !
|
|
18
|
+
return !r || typeof r != "object" ? { ok: !1, error: "Invalid response." } : r;
|
|
19
19
|
}
|
|
20
|
-
const
|
|
21
|
-
function
|
|
20
|
+
const at = "bb_anonymous_user_id";
|
|
21
|
+
function Ae() {
|
|
22
22
|
if (typeof window > "u" || typeof localStorage > "u")
|
|
23
23
|
return `bb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
24
24
|
try {
|
|
25
|
-
const i = localStorage.getItem(
|
|
25
|
+
const i = localStorage.getItem(at);
|
|
26
26
|
if (i && typeof i == "string" && i.length > 0)
|
|
27
27
|
return i;
|
|
28
|
-
let
|
|
28
|
+
let e;
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
|
|
30
|
+
const t = globalThis.crypto;
|
|
31
|
+
if (t != null && t.randomUUID)
|
|
32
|
+
e = t.randomUUID();
|
|
33
33
|
else
|
|
34
34
|
throw new Error("crypto.randomUUID not available");
|
|
35
35
|
} catch {
|
|
36
|
-
|
|
36
|
+
e = `bb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
37
37
|
}
|
|
38
|
-
return localStorage.setItem(
|
|
38
|
+
return localStorage.setItem(at, e), e;
|
|
39
39
|
} catch {
|
|
40
40
|
return `bb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
43
|
+
async function Re(i, e, t) {
|
|
44
44
|
if (!(typeof window > "u"))
|
|
45
45
|
try {
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
46
|
+
const r = new URL(i, window.location.origin);
|
|
47
|
+
r.searchParams.set("shop", e);
|
|
48
|
+
const a = await fetch(r, {
|
|
49
49
|
method: "POST",
|
|
50
50
|
headers: {
|
|
51
51
|
"Content-Type": "application/json"
|
|
52
52
|
},
|
|
53
|
-
body: JSON.stringify(
|
|
53
|
+
body: JSON.stringify(t),
|
|
54
54
|
// Don't wait for response - fire and forget
|
|
55
55
|
keepalive: !0
|
|
56
56
|
});
|
|
57
|
-
|
|
58
|
-
`[Bundle Analytics] Event tracking failed with status ${
|
|
59
|
-
await
|
|
57
|
+
a.ok || console.warn(
|
|
58
|
+
`[Bundle Analytics] Event tracking failed with status ${a.status}:`,
|
|
59
|
+
await a.text().catch(() => "Unable to read response")
|
|
60
60
|
);
|
|
61
|
-
} catch (
|
|
62
|
-
console.warn("[Bundle Analytics] Failed to track event:",
|
|
61
|
+
} catch (r) {
|
|
62
|
+
console.warn("[Bundle Analytics] Failed to track event:", r);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
const
|
|
66
|
-
function
|
|
65
|
+
const ut = pt(null);
|
|
66
|
+
function yt() {
|
|
67
67
|
try {
|
|
68
68
|
const i = globalThis.crypto;
|
|
69
69
|
if (i != null && i.randomUUID) return i.randomUUID();
|
|
@@ -71,49 +71,49 @@ function ve() {
|
|
|
71
71
|
}
|
|
72
72
|
return `bb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 10)}`;
|
|
73
73
|
}
|
|
74
|
-
function
|
|
74
|
+
function it(i) {
|
|
75
75
|
return Number.isFinite(i) ? Math.max(0, Math.floor(i)) : 0;
|
|
76
76
|
}
|
|
77
77
|
function rr(i) {
|
|
78
78
|
const {
|
|
79
|
-
apiBaseUrl:
|
|
80
|
-
shop:
|
|
81
|
-
cartAdapter:
|
|
82
|
-
configHandle:
|
|
79
|
+
apiBaseUrl: e,
|
|
80
|
+
shop: t,
|
|
81
|
+
cartAdapter: r,
|
|
82
|
+
configHandle: a = "default",
|
|
83
83
|
initialData: n,
|
|
84
84
|
configFetcher: l,
|
|
85
85
|
analyticsEndpoint: c,
|
|
86
86
|
children: m
|
|
87
|
-
} = i, w = c ?? `${
|
|
87
|
+
} = i, w = c ?? `${e}/api/public/bundle-analytics`, [k, F] = P(!1), [x, X] = P(!n), [V, Z] = P(!1), [z, M] = P(null), [A, W] = P((n == null ? void 0 : n.currencyCode) ?? null), [g, he] = P((n == null ? void 0 : n.config) ?? null), [se, _e] = P(
|
|
88
88
|
(n == null ? void 0 : n.eligibleVariants) ?? []
|
|
89
|
-
), [
|
|
89
|
+
), [fe, Ne] = P(
|
|
90
90
|
() => ({ selections: {}, order: [] })
|
|
91
|
-
),
|
|
92
|
-
|
|
91
|
+
), Te = L(null);
|
|
92
|
+
$(() => {
|
|
93
93
|
var D;
|
|
94
94
|
if (n) return;
|
|
95
|
-
(D =
|
|
95
|
+
(D = Te.current) == null || D.abort();
|
|
96
96
|
const f = new AbortController();
|
|
97
|
-
|
|
98
|
-
const C = l ??
|
|
99
|
-
return
|
|
97
|
+
Te.current = f;
|
|
98
|
+
const C = l ?? bt;
|
|
99
|
+
return X(!0), M(null), C({ apiBaseUrl: e, shop: t, signal: f.signal }).then((y) => {
|
|
100
100
|
if (!y.ok) {
|
|
101
|
-
|
|
101
|
+
M(y.error || "Failed to load bundle config."), he(null), _e([]), W(null);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
W(y.currencyCode ?? null), he(y.config), _e(y.eligibleVariants ?? []);
|
|
105
105
|
}).catch((y) => {
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
}).finally(() =>
|
|
109
|
-
}, [
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
106
|
+
const ne = y instanceof Error ? y.message : "Failed to load bundle config.";
|
|
107
|
+
M(ne), he(null), _e([]), W(null);
|
|
108
|
+
}).finally(() => X(!1)), () => f.abort();
|
|
109
|
+
}, [e, t, n, l]);
|
|
110
|
+
const Me = ue(() => {
|
|
111
|
+
if (F(!0), w)
|
|
112
112
|
try {
|
|
113
|
-
const f =
|
|
114
|
-
|
|
113
|
+
const f = Ae();
|
|
114
|
+
Re(w, t, {
|
|
115
115
|
eventType: "DRAWER_OPENED",
|
|
116
|
-
shop:
|
|
116
|
+
shop: t,
|
|
117
117
|
anonymousUserId: f,
|
|
118
118
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
119
119
|
}).catch((C) => {
|
|
@@ -122,14 +122,14 @@ function rr(i) {
|
|
|
122
122
|
} catch (f) {
|
|
123
123
|
console.warn("[Bundle Analytics] Error in open() callback:", f);
|
|
124
124
|
}
|
|
125
|
-
}, [w,
|
|
126
|
-
|
|
125
|
+
}, [w, t]), me = ue(() => F(!1), []), Pe = ue(() => {
|
|
126
|
+
F((f) => {
|
|
127
127
|
if (!f && w)
|
|
128
128
|
try {
|
|
129
|
-
const C =
|
|
130
|
-
|
|
129
|
+
const C = Ae();
|
|
130
|
+
Re(w, t, {
|
|
131
131
|
eventType: "DRAWER_OPENED",
|
|
132
|
-
shop:
|
|
132
|
+
shop: t,
|
|
133
133
|
anonymousUserId: C,
|
|
134
134
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
135
135
|
}).catch((D) => {
|
|
@@ -140,385 +140,390 @@ function rr(i) {
|
|
|
140
140
|
}
|
|
141
141
|
return !f;
|
|
142
142
|
});
|
|
143
|
-
}, [w,
|
|
143
|
+
}, [w, t]), Oe = T(() => {
|
|
144
144
|
const f = Number((g == null ? void 0 : g.maxBundleSize) ?? NaN), C = Number.isFinite(f) ? Math.floor(f) : 100;
|
|
145
145
|
return Math.max(2, Math.min(100, C));
|
|
146
|
-
}, [g == null ? void 0 : g.maxBundleSize]),
|
|
147
|
-
if (!
|
|
146
|
+
}, [g == null ? void 0 : g.maxBundleSize]), pe = T(() => new Set(se.map((f) => f.id)), [se]), J = ue((f, C) => {
|
|
147
|
+
if (!pe.has(f))
|
|
148
148
|
return;
|
|
149
|
-
const D =
|
|
150
|
-
|
|
151
|
-
const
|
|
149
|
+
const D = it(C);
|
|
150
|
+
Ne((y) => {
|
|
151
|
+
const ne = y.selections[f] ?? 0, q = D - ne, G = Object.values(y.selections).reduce((E, Y) => E + (Y || 0), 0), B = q > 0 ? Math.min(q, Math.max(0, Oe - G)) : q, re = ne + B;
|
|
152
152
|
let Q;
|
|
153
|
-
if (
|
|
154
|
-
const { [f]:
|
|
153
|
+
if (re <= 0) {
|
|
154
|
+
const { [f]: E, ...Y } = y.selections;
|
|
155
155
|
Q = Y;
|
|
156
|
-
} else
|
|
157
|
-
let
|
|
156
|
+
} else ne === re ? Q = y.selections : Q = { ...y.selections, [f]: re };
|
|
157
|
+
let ae = y.order;
|
|
158
158
|
if (B > 0)
|
|
159
|
-
|
|
159
|
+
ae = [...y.order, ...Array.from({ length: B }, () => f)];
|
|
160
160
|
else if (B < 0) {
|
|
161
|
-
let
|
|
161
|
+
let E = -B;
|
|
162
162
|
const Y = [];
|
|
163
|
-
for (let
|
|
164
|
-
const
|
|
165
|
-
if (
|
|
166
|
-
|
|
163
|
+
for (let N = y.order.length - 1; N >= 0; N--) {
|
|
164
|
+
const R = y.order[N];
|
|
165
|
+
if (R === f && E > 0) {
|
|
166
|
+
E--;
|
|
167
167
|
continue;
|
|
168
168
|
}
|
|
169
|
-
Y.push(
|
|
169
|
+
Y.push(R);
|
|
170
170
|
}
|
|
171
|
-
Y.reverse(),
|
|
171
|
+
Y.reverse(), ae = Y;
|
|
172
172
|
}
|
|
173
|
-
if (Q === y.selections &&
|
|
173
|
+
if (Q === y.selections && ae === y.order) return y;
|
|
174
174
|
if (w)
|
|
175
175
|
try {
|
|
176
|
-
const
|
|
177
|
-
|
|
176
|
+
const E = Ae();
|
|
177
|
+
Re(w, t, {
|
|
178
178
|
eventType: "VARIANT_SELECTION_CHANGED",
|
|
179
|
-
shop:
|
|
180
|
-
anonymousUserId:
|
|
179
|
+
shop: t,
|
|
180
|
+
anonymousUserId: E,
|
|
181
181
|
before: { ...y.selections },
|
|
182
182
|
after: { ...Q },
|
|
183
183
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
184
184
|
});
|
|
185
185
|
} catch {
|
|
186
186
|
}
|
|
187
|
-
return { selections: Q, order:
|
|
187
|
+
return { selections: Q, order: ae };
|
|
188
188
|
});
|
|
189
|
-
}, [
|
|
189
|
+
}, [Oe, pe, w, t]), ve = ue(() => Ne({ selections: {}, order: [] }), []), K = fe.selections, Ie = fe.order, ce = T(() => Object.values(K).reduce((f, C) => f + (C || 0), 0), [K]), ee = T(() => {
|
|
190
190
|
const f = (g == null ? void 0 : g.rules) ?? [], C = f.length ? Math.min(...f.map((D) => D.minBundleSize)) : 2;
|
|
191
191
|
return Number.isFinite(C) && C > 0 ? C : 2;
|
|
192
|
-
}, [g]),
|
|
193
|
-
var
|
|
194
|
-
if (!
|
|
195
|
-
const C =
|
|
196
|
-
merchandiseId:
|
|
197
|
-
quantity:
|
|
192
|
+
}, [g]), we = T(() => !(x || V || z || !(g != null && g.isActive) || ce < ee), [ce, g == null ? void 0 : g.isActive, z, x, ee, V]), le = ue(async (f) => {
|
|
193
|
+
var R, ge;
|
|
194
|
+
if (!we || !g) return;
|
|
195
|
+
const C = yt(), D = (g.title ?? "").trim().slice(0, 255), y = Object.entries(K).map(([b, be]) => ({ merchandiseId: b, quantity: it(be) })).filter((b) => b.quantity > 0).filter((b) => pe.has(b.merchandiseId)).map((b) => ({
|
|
196
|
+
merchandiseId: b.merchandiseId,
|
|
197
|
+
quantity: b.quantity,
|
|
198
198
|
attributes: [
|
|
199
|
-
{ key:
|
|
200
|
-
{ key:
|
|
201
|
-
{ key:
|
|
202
|
-
...D ? [{ key:
|
|
199
|
+
{ key: Fe.bundleId, value: C },
|
|
200
|
+
{ key: Fe.bundleConfig, value: a },
|
|
201
|
+
{ key: Fe.bundleSource, value: "bundle_builder" },
|
|
202
|
+
...D ? [{ key: Fe.bundleTitle, value: D }] : []
|
|
203
203
|
]
|
|
204
204
|
}));
|
|
205
205
|
if (!y.length) return;
|
|
206
|
-
const
|
|
206
|
+
const ne = new Map(se.map((b) => [b.id, b]));
|
|
207
207
|
let q = 0;
|
|
208
|
-
for (const [
|
|
209
|
-
const
|
|
210
|
-
if (
|
|
211
|
-
const
|
|
212
|
-
Number.isFinite(
|
|
208
|
+
for (const [b, be] of Object.entries(K)) {
|
|
209
|
+
const xe = be ?? 0;
|
|
210
|
+
if (xe <= 0) continue;
|
|
211
|
+
const ie = ne.get(b), ke = Number(ie == null ? void 0 : ie.price);
|
|
212
|
+
Number.isFinite(ke) && (q += ke * xe);
|
|
213
213
|
}
|
|
214
214
|
q = Math.round(q * 100) / 100;
|
|
215
|
-
const G = [...g.rules ?? []].sort((
|
|
215
|
+
const G = [...g.rules ?? []].sort((b, be) => b.minBundleSize - be.minBundleSize);
|
|
216
216
|
let B = null;
|
|
217
|
-
for (const
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
return Number.isFinite(
|
|
222
|
-
})() : null, Q =
|
|
223
|
-
|
|
217
|
+
for (const b of G)
|
|
218
|
+
ce >= b.minBundleSize && (B = b);
|
|
219
|
+
const re = B ? (() => {
|
|
220
|
+
const b = Number.parseFloat(B.discountPercent);
|
|
221
|
+
return Number.isFinite(b) && b > 0 ? b : null;
|
|
222
|
+
})() : null, Q = re ? Math.round(q * (1 - re / 100) * 100) / 100 : q, ae = q - Q, E = y.map((b) => b.merchandiseId), Y = (B == null ? void 0 : B.handle) ?? "", N = ((R = B == null ? void 0 : B.label) == null ? void 0 : R.trim()) || "";
|
|
223
|
+
Z(!0);
|
|
224
224
|
try {
|
|
225
|
-
if (await
|
|
225
|
+
if (f != null && f.checkout ? await r.linesAddForCheckout(y) : await r.linesAdd(y), w)
|
|
226
226
|
try {
|
|
227
|
-
const
|
|
228
|
-
|
|
227
|
+
const b = Ae();
|
|
228
|
+
Re(w, t, {
|
|
229
229
|
eventType: "BUNDLE_ADDED_TO_BASKET",
|
|
230
|
-
shop:
|
|
231
|
-
anonymousUserId:
|
|
230
|
+
shop: t,
|
|
231
|
+
anonymousUserId: b,
|
|
232
232
|
bundleId: C,
|
|
233
|
-
productVariantIds:
|
|
233
|
+
productVariantIds: E,
|
|
234
234
|
grossPrice: q,
|
|
235
235
|
discountedPrice: Q,
|
|
236
|
-
currency:
|
|
236
|
+
currency: A ?? void 0,
|
|
237
237
|
discountThresholdIdentifier: Y,
|
|
238
|
-
discountLabel:
|
|
239
|
-
discountPercentage:
|
|
240
|
-
discountedAmount:
|
|
238
|
+
discountLabel: N,
|
|
239
|
+
discountPercentage: re,
|
|
240
|
+
discountedAmount: ae,
|
|
241
241
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
242
242
|
});
|
|
243
243
|
} catch {
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
ve(), me(), (ge = f == null ? void 0 : f.onComplete) == null || ge.call(f);
|
|
246
246
|
} finally {
|
|
247
|
-
|
|
247
|
+
Z(!1);
|
|
248
248
|
}
|
|
249
249
|
}, [
|
|
250
|
-
|
|
251
|
-
a,
|
|
252
|
-
vt,
|
|
253
|
-
pt,
|
|
254
|
-
g,
|
|
250
|
+
we,
|
|
255
251
|
r,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
252
|
+
ve,
|
|
253
|
+
me,
|
|
254
|
+
g,
|
|
255
|
+
a,
|
|
256
|
+
A,
|
|
257
|
+
K,
|
|
258
|
+
pe,
|
|
259
|
+
se,
|
|
260
|
+
ce,
|
|
261
261
|
w,
|
|
262
|
-
|
|
263
|
-
]),
|
|
264
|
-
await
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
262
|
+
t
|
|
263
|
+
]), Ce = ue(async () => {
|
|
264
|
+
await le(
|
|
265
|
+
{
|
|
266
|
+
onComplete: () => {
|
|
267
|
+
var f;
|
|
268
|
+
(f = r.openCartUI) == null || f.call(r);
|
|
269
|
+
}
|
|
268
270
|
}
|
|
269
271
|
);
|
|
270
|
-
}, [
|
|
271
|
-
await
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
(
|
|
272
|
+
}, [le, r]), te = ue(async () => {
|
|
273
|
+
await le(
|
|
274
|
+
{
|
|
275
|
+
checkout: !0,
|
|
276
|
+
onComplete: () => {
|
|
277
|
+
var f;
|
|
278
|
+
(f = r.navigateToCheckout) == null || f.call(r);
|
|
279
|
+
}
|
|
275
280
|
}
|
|
276
281
|
);
|
|
277
|
-
}, [
|
|
282
|
+
}, [le, r]), Ee = T(
|
|
278
283
|
() => ({
|
|
279
|
-
isOpen:
|
|
280
|
-
open:
|
|
281
|
-
close:
|
|
282
|
-
toggle:
|
|
284
|
+
isOpen: k,
|
|
285
|
+
open: Me,
|
|
286
|
+
close: me,
|
|
287
|
+
toggle: Pe,
|
|
283
288
|
loading: x,
|
|
284
|
-
submitting:
|
|
285
|
-
error:
|
|
286
|
-
currencyCode:
|
|
289
|
+
submitting: V,
|
|
290
|
+
error: z,
|
|
291
|
+
currencyCode: A,
|
|
287
292
|
config: g,
|
|
288
|
-
eligibleVariants:
|
|
289
|
-
selections:
|
|
290
|
-
selectionOrder:
|
|
291
|
-
setQuantity:
|
|
292
|
-
clearSelections:
|
|
293
|
-
bundleSize:
|
|
294
|
-
minRequired:
|
|
295
|
-
canSubmit:
|
|
296
|
-
submit:
|
|
297
|
-
submitAndCheckout:
|
|
293
|
+
eligibleVariants: se,
|
|
294
|
+
selections: K,
|
|
295
|
+
selectionOrder: Ie,
|
|
296
|
+
setQuantity: J,
|
|
297
|
+
clearSelections: ve,
|
|
298
|
+
bundleSize: ce,
|
|
299
|
+
minRequired: ee,
|
|
300
|
+
canSubmit: we,
|
|
301
|
+
submit: Ce,
|
|
302
|
+
submitAndCheckout: te
|
|
298
303
|
}),
|
|
299
304
|
[
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
305
|
+
k,
|
|
306
|
+
Me,
|
|
307
|
+
me,
|
|
308
|
+
Pe,
|
|
304
309
|
x,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
310
|
+
V,
|
|
311
|
+
z,
|
|
312
|
+
A,
|
|
308
313
|
g,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
314
|
+
se,
|
|
315
|
+
K,
|
|
316
|
+
Ie,
|
|
317
|
+
J,
|
|
318
|
+
ve,
|
|
319
|
+
ce,
|
|
320
|
+
ee,
|
|
321
|
+
we,
|
|
322
|
+
Ce,
|
|
323
|
+
te
|
|
319
324
|
]
|
|
320
325
|
);
|
|
321
|
-
return /* @__PURE__ */ h(
|
|
326
|
+
return /* @__PURE__ */ h(ut.Provider, { value: Ee, children: m });
|
|
322
327
|
}
|
|
323
|
-
function
|
|
324
|
-
const i =
|
|
328
|
+
function Qe() {
|
|
329
|
+
const i = vt(ut);
|
|
325
330
|
if (!i)
|
|
326
331
|
throw new Error("useBundleBuilder must be used within <BundleProvider />");
|
|
327
332
|
return i;
|
|
328
333
|
}
|
|
329
334
|
function ar() {
|
|
330
|
-
const { isOpen: i, open:
|
|
331
|
-
return { isOpen: i, open:
|
|
335
|
+
const { isOpen: i, open: e, close: t, toggle: r } = Qe();
|
|
336
|
+
return { isOpen: i, open: e, close: t, toggle: r };
|
|
332
337
|
}
|
|
333
|
-
const
|
|
334
|
-
button:
|
|
338
|
+
const _t = "_button_18rtl_1", wt = {
|
|
339
|
+
button: _t
|
|
335
340
|
};
|
|
336
341
|
function ir(i) {
|
|
337
|
-
const { toggle:
|
|
342
|
+
const { toggle: e } = Qe();
|
|
338
343
|
return /* @__PURE__ */ h(
|
|
339
344
|
"button",
|
|
340
345
|
{
|
|
341
346
|
type: "button",
|
|
342
|
-
onClick:
|
|
343
|
-
className: [
|
|
347
|
+
onClick: e,
|
|
348
|
+
className: [wt.button, i.className].filter(Boolean).join(" "),
|
|
344
349
|
children: i.children ?? "Build a bundle"
|
|
345
350
|
}
|
|
346
351
|
);
|
|
347
352
|
}
|
|
348
|
-
var
|
|
349
|
-
function
|
|
350
|
-
if (
|
|
351
|
-
|
|
353
|
+
var We, ot;
|
|
354
|
+
function gt() {
|
|
355
|
+
if (ot) return We;
|
|
356
|
+
ot = 1;
|
|
352
357
|
var i = {
|
|
353
|
-
linear: function(t,
|
|
354
|
-
var n =
|
|
355
|
-
return n *
|
|
358
|
+
linear: function(e, t, r, a) {
|
|
359
|
+
var n = r - t;
|
|
360
|
+
return n * e / a + t;
|
|
356
361
|
},
|
|
357
|
-
easeInQuad: function(t,
|
|
358
|
-
var n =
|
|
359
|
-
return n * (
|
|
362
|
+
easeInQuad: function(e, t, r, a) {
|
|
363
|
+
var n = r - t;
|
|
364
|
+
return n * (e /= a) * e + t;
|
|
360
365
|
},
|
|
361
|
-
easeOutQuad: function(t,
|
|
362
|
-
var n =
|
|
363
|
-
return -n * (
|
|
366
|
+
easeOutQuad: function(e, t, r, a) {
|
|
367
|
+
var n = r - t;
|
|
368
|
+
return -n * (e /= a) * (e - 2) + t;
|
|
364
369
|
},
|
|
365
|
-
easeInOutQuad: function(t,
|
|
366
|
-
var n =
|
|
367
|
-
return (
|
|
370
|
+
easeInOutQuad: function(e, t, r, a) {
|
|
371
|
+
var n = r - t;
|
|
372
|
+
return (e /= a / 2) < 1 ? n / 2 * e * e + t : -n / 2 * (--e * (e - 2) - 1) + t;
|
|
368
373
|
},
|
|
369
|
-
easeInCubic: function(t,
|
|
370
|
-
var n =
|
|
371
|
-
return n * (
|
|
374
|
+
easeInCubic: function(e, t, r, a) {
|
|
375
|
+
var n = r - t;
|
|
376
|
+
return n * (e /= a) * e * e + t;
|
|
372
377
|
},
|
|
373
|
-
easeOutCubic: function(t,
|
|
374
|
-
var n =
|
|
375
|
-
return n * ((
|
|
378
|
+
easeOutCubic: function(e, t, r, a) {
|
|
379
|
+
var n = r - t;
|
|
380
|
+
return n * ((e = e / a - 1) * e * e + 1) + t;
|
|
376
381
|
},
|
|
377
|
-
easeInOutCubic: function(t,
|
|
378
|
-
var n =
|
|
379
|
-
return (
|
|
382
|
+
easeInOutCubic: function(e, t, r, a) {
|
|
383
|
+
var n = r - t;
|
|
384
|
+
return (e /= a / 2) < 1 ? n / 2 * e * e * e + t : n / 2 * ((e -= 2) * e * e + 2) + t;
|
|
380
385
|
},
|
|
381
|
-
easeInQuart: function(t,
|
|
382
|
-
var n =
|
|
383
|
-
return n * (
|
|
386
|
+
easeInQuart: function(e, t, r, a) {
|
|
387
|
+
var n = r - t;
|
|
388
|
+
return n * (e /= a) * e * e * e + t;
|
|
384
389
|
},
|
|
385
|
-
easeOutQuart: function(t,
|
|
386
|
-
var n =
|
|
387
|
-
return -n * ((
|
|
390
|
+
easeOutQuart: function(e, t, r, a) {
|
|
391
|
+
var n = r - t;
|
|
392
|
+
return -n * ((e = e / a - 1) * e * e * e - 1) + t;
|
|
388
393
|
},
|
|
389
|
-
easeInOutQuart: function(t,
|
|
390
|
-
var n =
|
|
391
|
-
return (
|
|
394
|
+
easeInOutQuart: function(e, t, r, a) {
|
|
395
|
+
var n = r - t;
|
|
396
|
+
return (e /= a / 2) < 1 ? n / 2 * e * e * e * e + t : -n / 2 * ((e -= 2) * e * e * e - 2) + t;
|
|
392
397
|
},
|
|
393
|
-
easeInQuint: function(t,
|
|
394
|
-
var n =
|
|
395
|
-
return n * (
|
|
398
|
+
easeInQuint: function(e, t, r, a) {
|
|
399
|
+
var n = r - t;
|
|
400
|
+
return n * (e /= a) * e * e * e * e + t;
|
|
396
401
|
},
|
|
397
|
-
easeOutQuint: function(t,
|
|
398
|
-
var n =
|
|
399
|
-
return n * ((
|
|
402
|
+
easeOutQuint: function(e, t, r, a) {
|
|
403
|
+
var n = r - t;
|
|
404
|
+
return n * ((e = e / a - 1) * e * e * e * e + 1) + t;
|
|
400
405
|
},
|
|
401
|
-
easeInOutQuint: function(t,
|
|
402
|
-
var n =
|
|
403
|
-
return (
|
|
406
|
+
easeInOutQuint: function(e, t, r, a) {
|
|
407
|
+
var n = r - t;
|
|
408
|
+
return (e /= a / 2) < 1 ? n / 2 * e * e * e * e * e + t : n / 2 * ((e -= 2) * e * e * e * e + 2) + t;
|
|
404
409
|
},
|
|
405
|
-
easeInSine: function(t,
|
|
406
|
-
var n =
|
|
407
|
-
return -n * Math.cos(
|
|
410
|
+
easeInSine: function(e, t, r, a) {
|
|
411
|
+
var n = r - t;
|
|
412
|
+
return -n * Math.cos(e / a * (Math.PI / 2)) + n + t;
|
|
408
413
|
},
|
|
409
|
-
easeOutSine: function(t,
|
|
410
|
-
var n =
|
|
411
|
-
return n * Math.sin(
|
|
414
|
+
easeOutSine: function(e, t, r, a) {
|
|
415
|
+
var n = r - t;
|
|
416
|
+
return n * Math.sin(e / a * (Math.PI / 2)) + t;
|
|
412
417
|
},
|
|
413
|
-
easeInOutSine: function(t,
|
|
414
|
-
var n =
|
|
415
|
-
return -n / 2 * (Math.cos(Math.PI *
|
|
418
|
+
easeInOutSine: function(e, t, r, a) {
|
|
419
|
+
var n = r - t;
|
|
420
|
+
return -n / 2 * (Math.cos(Math.PI * e / a) - 1) + t;
|
|
416
421
|
},
|
|
417
|
-
easeInExpo: function(t,
|
|
418
|
-
var n =
|
|
419
|
-
return
|
|
422
|
+
easeInExpo: function(e, t, r, a) {
|
|
423
|
+
var n = r - t;
|
|
424
|
+
return e == 0 ? t : n * Math.pow(2, 10 * (e / a - 1)) + t;
|
|
420
425
|
},
|
|
421
|
-
easeOutExpo: function(t,
|
|
422
|
-
var n =
|
|
423
|
-
return
|
|
426
|
+
easeOutExpo: function(e, t, r, a) {
|
|
427
|
+
var n = r - t;
|
|
428
|
+
return e == a ? t + n : n * (-Math.pow(2, -10 * e / a) + 1) + t;
|
|
424
429
|
},
|
|
425
|
-
easeInOutExpo: function(t,
|
|
426
|
-
var n =
|
|
427
|
-
return
|
|
430
|
+
easeInOutExpo: function(e, t, r, a) {
|
|
431
|
+
var n = r - t;
|
|
432
|
+
return e === 0 ? t : e === a ? t + n : (e /= a / 2) < 1 ? n / 2 * Math.pow(2, 10 * (e - 1)) + t : n / 2 * (-Math.pow(2, -10 * --e) + 2) + t;
|
|
428
433
|
},
|
|
429
|
-
easeInCirc: function(t,
|
|
430
|
-
var n =
|
|
431
|
-
return -n * (Math.sqrt(1 - (
|
|
434
|
+
easeInCirc: function(e, t, r, a) {
|
|
435
|
+
var n = r - t;
|
|
436
|
+
return -n * (Math.sqrt(1 - (e /= a) * e) - 1) + t;
|
|
432
437
|
},
|
|
433
|
-
easeOutCirc: function(t,
|
|
434
|
-
var n =
|
|
435
|
-
return n * Math.sqrt(1 - (
|
|
438
|
+
easeOutCirc: function(e, t, r, a) {
|
|
439
|
+
var n = r - t;
|
|
440
|
+
return n * Math.sqrt(1 - (e = e / a - 1) * e) + t;
|
|
436
441
|
},
|
|
437
|
-
easeInOutCirc: function(t,
|
|
438
|
-
var n =
|
|
439
|
-
return (
|
|
442
|
+
easeInOutCirc: function(e, t, r, a) {
|
|
443
|
+
var n = r - t;
|
|
444
|
+
return (e /= a / 2) < 1 ? -n / 2 * (Math.sqrt(1 - e * e) - 1) + t : n / 2 * (Math.sqrt(1 - (e -= 2) * e) + 1) + t;
|
|
440
445
|
},
|
|
441
|
-
easeInElastic: function(t,
|
|
442
|
-
var n =
|
|
443
|
-
return m = 1.70158, c = 0, l = n,
|
|
446
|
+
easeInElastic: function(e, t, r, a) {
|
|
447
|
+
var n = r - t, l, c, m;
|
|
448
|
+
return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= a) === 1 ? t + n : (c || (c = a * 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 * a - m) * (2 * Math.PI) / c)) + t);
|
|
444
449
|
},
|
|
445
|
-
easeOutElastic: function(t,
|
|
446
|
-
var n =
|
|
447
|
-
return m = 1.70158, c = 0, l = n,
|
|
450
|
+
easeOutElastic: function(e, t, r, a) {
|
|
451
|
+
var n = r - t, l, c, m;
|
|
452
|
+
return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= a) === 1 ? t + n : (c || (c = a * 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 * a - m) * (2 * Math.PI) / c) + n + t);
|
|
448
453
|
},
|
|
449
|
-
easeInOutElastic: function(t,
|
|
450
|
-
var n =
|
|
451
|
-
return m = 1.70158, c = 0, l = n,
|
|
454
|
+
easeInOutElastic: function(e, t, r, a) {
|
|
455
|
+
var n = r - t, l, c, m;
|
|
456
|
+
return m = 1.70158, c = 0, l = n, e === 0 ? t : (e /= a / 2) === 2 ? t + n : (c || (c = a * (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 * a - m) * (2 * Math.PI) / c)) + t : l * Math.pow(2, -10 * (e -= 1)) * Math.sin((e * a - m) * (2 * Math.PI) / c) * 0.5 + n + t);
|
|
452
457
|
},
|
|
453
|
-
easeInBack: function(t,
|
|
454
|
-
var l =
|
|
455
|
-
return n === void 0 && (n = 1.70158), l * (
|
|
458
|
+
easeInBack: function(e, t, r, a, n) {
|
|
459
|
+
var l = r - t;
|
|
460
|
+
return n === void 0 && (n = 1.70158), l * (e /= a) * e * ((n + 1) * e - n) + t;
|
|
456
461
|
},
|
|
457
|
-
easeOutBack: function(t,
|
|
458
|
-
var l =
|
|
459
|
-
return n === void 0 && (n = 1.70158), l * ((
|
|
462
|
+
easeOutBack: function(e, t, r, a, n) {
|
|
463
|
+
var l = r - t;
|
|
464
|
+
return n === void 0 && (n = 1.70158), l * ((e = e / a - 1) * e * ((n + 1) * e + n) + 1) + t;
|
|
460
465
|
},
|
|
461
|
-
easeInOutBack: function(t,
|
|
462
|
-
var l =
|
|
463
|
-
return n === void 0 && (n = 1.70158), (
|
|
466
|
+
easeInOutBack: function(e, t, r, a, n) {
|
|
467
|
+
var l = r - t;
|
|
468
|
+
return n === void 0 && (n = 1.70158), (e /= a / 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;
|
|
464
469
|
},
|
|
465
|
-
easeInBounce: function(t,
|
|
466
|
-
var n =
|
|
467
|
-
return l = i.easeOutBounce(
|
|
470
|
+
easeInBounce: function(e, t, r, a) {
|
|
471
|
+
var n = r - t, l;
|
|
472
|
+
return l = i.easeOutBounce(a - e, 0, n, a), n - l + t;
|
|
468
473
|
},
|
|
469
|
-
easeOutBounce: function(t,
|
|
470
|
-
var n =
|
|
471
|
-
return (
|
|
474
|
+
easeOutBounce: function(e, t, r, a) {
|
|
475
|
+
var n = r - t;
|
|
476
|
+
return (e /= a) < 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;
|
|
472
477
|
},
|
|
473
|
-
easeInOutBounce: function(t,
|
|
474
|
-
var n =
|
|
475
|
-
return
|
|
478
|
+
easeInOutBounce: function(e, t, r, a) {
|
|
479
|
+
var n = r - t, l;
|
|
480
|
+
return e < a / 2 ? (l = i.easeInBounce(e * 2, 0, n, a), l * 0.5 + t) : (l = i.easeOutBounce(e * 2 - a, 0, n, a), l * 0.5 + n * 0.5 + t);
|
|
476
481
|
}
|
|
477
482
|
};
|
|
478
|
-
return
|
|
483
|
+
return We = i, We;
|
|
479
484
|
}
|
|
480
|
-
var
|
|
481
|
-
function
|
|
485
|
+
var xt = gt();
|
|
486
|
+
function It(i) {
|
|
482
487
|
return i * Math.PI / 180;
|
|
483
488
|
}
|
|
484
|
-
function
|
|
485
|
-
return i + Math.random() * (
|
|
489
|
+
function U(i, e) {
|
|
490
|
+
return i + Math.random() * (e - i);
|
|
486
491
|
}
|
|
487
|
-
function
|
|
488
|
-
return Math.floor(i + Math.random() * (
|
|
492
|
+
function Ct(i, e) {
|
|
493
|
+
return Math.floor(i + Math.random() * (e - i + 1));
|
|
489
494
|
}
|
|
490
|
-
var
|
|
495
|
+
var Se;
|
|
491
496
|
(function(i) {
|
|
492
497
|
i[i.Circle = 0] = "Circle", i[i.Square = 1] = "Square", i[i.Strip = 2] = "Strip";
|
|
493
|
-
})(
|
|
494
|
-
var
|
|
498
|
+
})(Se || (Se = {}));
|
|
499
|
+
var de;
|
|
495
500
|
(function(i) {
|
|
496
501
|
i[i.Positive = 1] = "Positive", i[i.Negative = -1] = "Negative";
|
|
497
|
-
})(
|
|
498
|
-
const
|
|
499
|
-
class
|
|
500
|
-
constructor(t,
|
|
501
|
-
this.getOptions =
|
|
502
|
+
})(de || (de = {}));
|
|
503
|
+
const Bt = 1e3 / 60;
|
|
504
|
+
class St {
|
|
505
|
+
constructor(e, t, r, a) {
|
|
506
|
+
this.getOptions = t;
|
|
502
507
|
const { colors: n, initialVelocityX: l, initialVelocityY: c } = this.getOptions();
|
|
503
|
-
this.context =
|
|
508
|
+
this.context = e, this.x = r, this.y = a, this.w = U(5, 20), this.h = U(5, 20), this.radius = U(5, 10), this.vx = typeof l == "number" ? U(-l, l) : U(l.min, l.max), this.vy = typeof c == "number" ? U(-c, 0) : U(c.min, c.max), this.shape = Ct(0, 2), this.angle = It(U(0, 360)), this.angularSpin = U(-0.2, 0.2), this.color = n[Math.floor(Math.random() * n.length)], this.rotateY = U(0, 1), this.rotationDirection = U(0, 1) ? de.Positive : de.Negative;
|
|
504
509
|
}
|
|
505
|
-
update(
|
|
506
|
-
const { gravity:
|
|
507
|
-
this.x += this.vx * c, this.y += this.vy * c, this.vy +=
|
|
510
|
+
update(e) {
|
|
511
|
+
const { gravity: t, wind: r, friction: a, opacity: n, drawShape: l } = this.getOptions(), c = e / Bt;
|
|
512
|
+
this.x += this.vx * c, this.y += this.vy * c, this.vy += t * c, this.vx += r * c, this.vx *= a ** c, this.vy *= a ** c, this.rotateY >= 1 && this.rotationDirection === de.Positive ? this.rotationDirection = de.Negative : this.rotateY <= -1 && this.rotationDirection === de.Negative && (this.rotationDirection = de.Positive);
|
|
508
513
|
const m = 0.1 * this.rotationDirection * c;
|
|
509
514
|
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")
|
|
510
515
|
l.call(this, this.context);
|
|
511
516
|
else
|
|
512
517
|
switch (this.shape) {
|
|
513
|
-
case
|
|
518
|
+
case Se.Circle: {
|
|
514
519
|
this.context.beginPath(), this.context.arc(0, 0, this.radius, 0, 2 * Math.PI), this.context.fill();
|
|
515
520
|
break;
|
|
516
521
|
}
|
|
517
|
-
case
|
|
522
|
+
case Se.Square: {
|
|
518
523
|
this.context.fillRect(-this.w / 2, -this.h / 2, this.w, this.h);
|
|
519
524
|
break;
|
|
520
525
|
}
|
|
521
|
-
case
|
|
526
|
+
case Se.Strip: {
|
|
522
527
|
this.context.fillRect(-this.w / 6, -this.h / 2, this.w / 3, this.h);
|
|
523
528
|
break;
|
|
524
529
|
}
|
|
@@ -526,39 +531,39 @@ class Be {
|
|
|
526
531
|
this.context.closePath(), this.context.restore();
|
|
527
532
|
}
|
|
528
533
|
}
|
|
529
|
-
class
|
|
530
|
-
constructor(
|
|
531
|
-
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 = (
|
|
532
|
-
this.particles.splice(
|
|
534
|
+
class Nt {
|
|
535
|
+
constructor(e, t) {
|
|
536
|
+
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 = (a) => {
|
|
537
|
+
this.particles.splice(a, 1);
|
|
533
538
|
}, this.getParticle = () => {
|
|
534
|
-
const
|
|
535
|
-
return new
|
|
536
|
-
}, this.animate = (
|
|
537
|
-
const { canvas: n, context: l, particlesGenerated: c, lastNumberOfPieces: m } = this, { run: w, recycle:
|
|
539
|
+
const a = U(this.x, this.w + this.x), n = U(this.y, this.h + this.y);
|
|
540
|
+
return new St(this.context, this.getOptions, a, n);
|
|
541
|
+
}, this.animate = (a) => {
|
|
542
|
+
const { canvas: n, context: l, particlesGenerated: c, lastNumberOfPieces: m } = this, { run: w, recycle: k, numberOfPieces: F, debug: x, tweenFunction: X, tweenDuration: V } = this.getOptions();
|
|
538
543
|
if (!w)
|
|
539
544
|
return !1;
|
|
540
|
-
const
|
|
541
|
-
if (
|
|
542
|
-
m !==
|
|
543
|
-
const
|
|
544
|
-
for (let
|
|
545
|
+
const Z = this.particles.length, z = k ? Z : c;
|
|
546
|
+
if (z < F) {
|
|
547
|
+
m !== F && (this.tweenProgress = 0, this.tweenFrom = z, this.lastNumberOfPieces = F), this.tweenProgress = Math.min(V, Math.max(0, this.tweenProgress + a));
|
|
548
|
+
const M = X(this.tweenProgress, this.tweenFrom, F, V), A = Math.round(M - z);
|
|
549
|
+
for (let W = 0; W < A; W++)
|
|
545
550
|
this.particles.push(this.getParticle());
|
|
546
|
-
this.particlesGenerated +=
|
|
551
|
+
this.particlesGenerated += A;
|
|
547
552
|
}
|
|
548
|
-
x && (l.font = "12px sans-serif", l.fillStyle = "#333", l.textAlign = "right", l.fillText(`Particles: ${
|
|
549
|
-
for (let
|
|
550
|
-
const
|
|
551
|
-
|
|
553
|
+
x && (l.font = "12px sans-serif", l.fillStyle = "#333", l.textAlign = "right", l.fillText(`Particles: ${Z}`, n.width - 10, n.height - 20));
|
|
554
|
+
for (let M = this.particles.length - 1; M >= 0; M--) {
|
|
555
|
+
const A = this.particles[M];
|
|
556
|
+
A.update(a), (A.y > n.height || A.y < -100 || A.x > n.width + 100 || A.x < -100) && (k && z <= F ? this.particles[M] = this.getParticle() : this.removeParticleAt(M));
|
|
552
557
|
}
|
|
553
|
-
return
|
|
554
|
-
}, this.canvas =
|
|
555
|
-
const
|
|
556
|
-
if (!
|
|
558
|
+
return Z > 0 || z < F;
|
|
559
|
+
}, this.canvas = e;
|
|
560
|
+
const r = this.canvas.getContext("2d");
|
|
561
|
+
if (!r)
|
|
557
562
|
throw new Error("Could not get canvas context");
|
|
558
|
-
this.context =
|
|
563
|
+
this.context = r, this.getOptions = t;
|
|
559
564
|
}
|
|
560
565
|
}
|
|
561
|
-
const
|
|
566
|
+
const Ye = {
|
|
562
567
|
width: typeof window < "u" ? window.innerWidth : 300,
|
|
563
568
|
height: typeof window < "u" ? window.innerHeight : 200,
|
|
564
569
|
numberOfPieces: 200,
|
|
@@ -588,14 +593,14 @@ const Gt = {
|
|
|
588
593
|
],
|
|
589
594
|
opacity: 1,
|
|
590
595
|
debug: !1,
|
|
591
|
-
tweenFunction:
|
|
596
|
+
tweenFunction: xt.easeInOutQuad,
|
|
592
597
|
tweenDuration: 5e3,
|
|
593
598
|
recycle: !0,
|
|
594
599
|
run: !0
|
|
595
600
|
};
|
|
596
|
-
class
|
|
597
|
-
constructor(
|
|
598
|
-
this.lastFrameTime = 0, this.setOptionsWithDefaults = (
|
|
601
|
+
class Tt {
|
|
602
|
+
constructor(e, t) {
|
|
603
|
+
this.lastFrameTime = 0, this.setOptionsWithDefaults = (a) => {
|
|
599
604
|
const n = {
|
|
600
605
|
confettiSource: {
|
|
601
606
|
x: 0,
|
|
@@ -606,55 +611,55 @@ class Ne {
|
|
|
606
611
|
};
|
|
607
612
|
this._options = {
|
|
608
613
|
...n,
|
|
609
|
-
...
|
|
610
|
-
...
|
|
611
|
-
}, Object.assign(this,
|
|
612
|
-
}, this.update = (
|
|
613
|
-
const { options: { run: n, onConfettiComplete: l, frameRate: c }, canvas: m, context: w } = this,
|
|
614
|
-
if (c &&
|
|
614
|
+
...Ye,
|
|
615
|
+
...a
|
|
616
|
+
}, Object.assign(this, a.confettiSource);
|
|
617
|
+
}, this.update = (a = 0) => {
|
|
618
|
+
const { options: { run: n, onConfettiComplete: l, frameRate: c }, canvas: m, context: w } = this, k = Math.min(a - this.lastFrameTime, 50);
|
|
619
|
+
if (c && k < 1e3 / c) {
|
|
615
620
|
this.rafId = requestAnimationFrame(this.update);
|
|
616
621
|
return;
|
|
617
622
|
}
|
|
618
|
-
this.lastFrameTime =
|
|
623
|
+
this.lastFrameTime = a - (c ? k % c : 0), n && (w.fillStyle = "white", w.clearRect(0, 0, m.width, m.height)), this.generator.animate(k) ? this.rafId = requestAnimationFrame(this.update) : (l && typeof l == "function" && this.generator.particlesGenerated > 0 && l.call(this, this), this._options.run = !1);
|
|
619
624
|
}, this.reset = () => {
|
|
620
625
|
this.generator && this.generator.particlesGenerated > 0 && (this.generator.particlesGenerated = 0, this.generator.particles = [], this.generator.lastNumberOfPieces = 0);
|
|
621
626
|
}, this.stop = () => {
|
|
622
627
|
this.options = { run: !1 }, this.rafId && (cancelAnimationFrame(this.rafId), this.rafId = void 0);
|
|
623
|
-
}, this.canvas =
|
|
624
|
-
const
|
|
625
|
-
if (!
|
|
628
|
+
}, this.canvas = e;
|
|
629
|
+
const r = this.canvas.getContext("2d");
|
|
630
|
+
if (!r)
|
|
626
631
|
throw new Error("Could not get canvas context");
|
|
627
|
-
this.context =
|
|
632
|
+
this.context = r, this.generator = new Nt(this.canvas, () => this.options), this.options = t, this.update();
|
|
628
633
|
}
|
|
629
634
|
get options() {
|
|
630
635
|
return this._options;
|
|
631
636
|
}
|
|
632
|
-
set options(
|
|
633
|
-
var
|
|
634
|
-
const
|
|
635
|
-
this.setOptionsWithDefaults(
|
|
637
|
+
set options(e) {
|
|
638
|
+
var a, n;
|
|
639
|
+
const t = (a = this._options) == null ? void 0 : a.run, r = (n = this._options) == null ? void 0 : n.recycle;
|
|
640
|
+
this.setOptionsWithDefaults(e), this.generator && (Object.assign(this.generator, this.options.confettiSource), typeof e.recycle == "boolean" && e.recycle && r === !1 && (this.generator.lastNumberOfPieces = this.generator.particles.length)), typeof e.run == "boolean" && e.run && t === !1 && this.update();
|
|
636
641
|
}
|
|
637
642
|
}
|
|
638
|
-
const
|
|
639
|
-
class
|
|
640
|
-
constructor(
|
|
641
|
-
super(
|
|
643
|
+
const Mt = qe.createRef();
|
|
644
|
+
class Ke extends qe.Component {
|
|
645
|
+
constructor(e) {
|
|
646
|
+
super(e), this.canvas = qe.createRef(), this.canvas = e.canvasRef || Mt;
|
|
642
647
|
}
|
|
643
648
|
componentDidMount() {
|
|
644
649
|
if (this.canvas.current) {
|
|
645
|
-
const
|
|
646
|
-
this.confetti = new
|
|
650
|
+
const e = je(this.props)[0];
|
|
651
|
+
this.confetti = new Tt(this.canvas.current, e);
|
|
647
652
|
}
|
|
648
653
|
}
|
|
649
654
|
componentDidUpdate() {
|
|
650
|
-
const
|
|
651
|
-
this.confetti && (this.confetti.options =
|
|
655
|
+
const e = je(this.props)[0];
|
|
656
|
+
this.confetti && (this.confetti.options = e);
|
|
652
657
|
}
|
|
653
658
|
componentWillUnmount() {
|
|
654
659
|
this.confetti && this.confetti.stop(), this.confetti = void 0;
|
|
655
660
|
}
|
|
656
661
|
render() {
|
|
657
|
-
const [
|
|
662
|
+
const [e, t] = je(this.props), r = {
|
|
658
663
|
zIndex: 2,
|
|
659
664
|
position: "absolute",
|
|
660
665
|
pointerEvents: "none",
|
|
@@ -662,18 +667,18 @@ class Qt extends Ft.Component {
|
|
|
662
667
|
left: 0,
|
|
663
668
|
bottom: 0,
|
|
664
669
|
right: 0,
|
|
665
|
-
...
|
|
670
|
+
...t.style
|
|
666
671
|
};
|
|
667
|
-
return h("canvas", { width:
|
|
672
|
+
return h("canvas", { width: e.width, height: e.height, ref: this.canvas, ...t, style: r });
|
|
668
673
|
}
|
|
669
674
|
}
|
|
670
|
-
|
|
671
|
-
...
|
|
675
|
+
Ke.defaultProps = {
|
|
676
|
+
...Ye
|
|
672
677
|
};
|
|
673
|
-
|
|
674
|
-
function
|
|
675
|
-
const
|
|
676
|
-
...Object.keys(
|
|
678
|
+
Ke.displayName = "ReactConfetti";
|
|
679
|
+
function je(i) {
|
|
680
|
+
const e = {}, t = {}, r = {}, a = [
|
|
681
|
+
...Object.keys(Ye),
|
|
677
682
|
"confettiSource",
|
|
678
683
|
"drawShape",
|
|
679
684
|
"onConfettiComplete",
|
|
@@ -681,26 +686,26 @@ function zt(i) {
|
|
|
681
686
|
], n = ["canvasRef"];
|
|
682
687
|
for (const l in i) {
|
|
683
688
|
const c = i[l];
|
|
684
|
-
|
|
689
|
+
a.includes(l) ? e[l] = c : n.includes(l) ? n[l] = c : r[l] = c;
|
|
685
690
|
}
|
|
686
|
-
return [
|
|
691
|
+
return [e, r, t];
|
|
687
692
|
}
|
|
688
|
-
const
|
|
693
|
+
const Pt = qe.forwardRef((i, e) => h(Ke, { canvasRef: e, ...i }));
|
|
689
694
|
/**
|
|
690
695
|
* @license lucide-react v0.515.0 - ISC
|
|
691
696
|
*
|
|
692
697
|
* This source code is licensed under the ISC license.
|
|
693
698
|
* See the LICENSE file in the root directory of this source tree.
|
|
694
699
|
*/
|
|
695
|
-
const
|
|
700
|
+
const Ot = (i) => i.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), kt = (i) => i.replace(
|
|
696
701
|
/^([A-Z])|[\s-_]+(\w)/g,
|
|
697
|
-
(
|
|
698
|
-
),
|
|
699
|
-
const
|
|
700
|
-
return
|
|
701
|
-
},
|
|
702
|
-
for (const
|
|
703
|
-
if (
|
|
702
|
+
(e, t, r) => r ? r.toUpperCase() : t.toLowerCase()
|
|
703
|
+
), st = (i) => {
|
|
704
|
+
const e = kt(i);
|
|
705
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
706
|
+
}, dt = (...i) => i.filter((e, t, r) => !!e && e.trim() !== "" && r.indexOf(e) === t).join(" ").trim(), Ft = (i) => {
|
|
707
|
+
for (const e in i)
|
|
708
|
+
if (e.startsWith("aria-") || e === "role" || e === "title")
|
|
704
709
|
return !0;
|
|
705
710
|
};
|
|
706
711
|
/**
|
|
@@ -709,7 +714,7 @@ const Pe = (i) => i.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Oe = (
|
|
|
709
714
|
* This source code is licensed under the ISC license.
|
|
710
715
|
* See the LICENSE file in the root directory of this source tree.
|
|
711
716
|
*/
|
|
712
|
-
var
|
|
717
|
+
var At = {
|
|
713
718
|
xmlns: "http://www.w3.org/2000/svg",
|
|
714
719
|
width: 24,
|
|
715
720
|
height: 24,
|
|
@@ -726,31 +731,31 @@ var Ae = {
|
|
|
726
731
|
* This source code is licensed under the ISC license.
|
|
727
732
|
* See the LICENSE file in the root directory of this source tree.
|
|
728
733
|
*/
|
|
729
|
-
const
|
|
734
|
+
const Rt = lt(
|
|
730
735
|
({
|
|
731
736
|
color: i = "currentColor",
|
|
732
|
-
size:
|
|
733
|
-
strokeWidth:
|
|
734
|
-
absoluteStrokeWidth:
|
|
735
|
-
className:
|
|
737
|
+
size: e = 24,
|
|
738
|
+
strokeWidth: t = 2,
|
|
739
|
+
absoluteStrokeWidth: r,
|
|
740
|
+
className: a = "",
|
|
736
741
|
children: n,
|
|
737
742
|
iconNode: l,
|
|
738
743
|
...c
|
|
739
|
-
}, m) =>
|
|
744
|
+
}, m) => Ge(
|
|
740
745
|
"svg",
|
|
741
746
|
{
|
|
742
747
|
ref: m,
|
|
743
|
-
...
|
|
744
|
-
width:
|
|
745
|
-
height:
|
|
748
|
+
...At,
|
|
749
|
+
width: e,
|
|
750
|
+
height: e,
|
|
746
751
|
stroke: i,
|
|
747
|
-
strokeWidth:
|
|
748
|
-
className:
|
|
749
|
-
...!n && !
|
|
752
|
+
strokeWidth: r ? Number(t) * 24 / Number(e) : t,
|
|
753
|
+
className: dt("lucide", a),
|
|
754
|
+
...!n && !Ft(c) && { "aria-hidden": "true" },
|
|
750
755
|
...c
|
|
751
756
|
},
|
|
752
757
|
[
|
|
753
|
-
...l.map(([w,
|
|
758
|
+
...l.map(([w, k]) => Ge(w, k)),
|
|
754
759
|
...Array.isArray(n) ? n : [n]
|
|
755
760
|
]
|
|
756
761
|
)
|
|
@@ -761,20 +766,20 @@ const Re = se(
|
|
|
761
766
|
* This source code is licensed under the ISC license.
|
|
762
767
|
* See the LICENSE file in the root directory of this source tree.
|
|
763
768
|
*/
|
|
764
|
-
const
|
|
765
|
-
const
|
|
766
|
-
({ className:
|
|
769
|
+
const Dt = (i, e) => {
|
|
770
|
+
const t = lt(
|
|
771
|
+
({ className: r, ...a }, n) => Ge(Rt, {
|
|
767
772
|
ref: n,
|
|
768
|
-
iconNode:
|
|
769
|
-
className:
|
|
770
|
-
`lucide-${
|
|
773
|
+
iconNode: e,
|
|
774
|
+
className: dt(
|
|
775
|
+
`lucide-${Ot(st(i))}`,
|
|
771
776
|
`lucide-${i}`,
|
|
772
|
-
|
|
777
|
+
r
|
|
773
778
|
),
|
|
774
|
-
...
|
|
779
|
+
...a
|
|
775
780
|
})
|
|
776
781
|
);
|
|
777
|
-
return
|
|
782
|
+
return t.displayName = st(i), t;
|
|
778
783
|
};
|
|
779
784
|
/**
|
|
780
785
|
* @license lucide-react v0.515.0 - ISC
|
|
@@ -782,105 +787,105 @@ const Fe = (i, t) => {
|
|
|
782
787
|
* This source code is licensed under the ISC license.
|
|
783
788
|
* See the LICENSE file in the root directory of this source tree.
|
|
784
789
|
*/
|
|
785
|
-
const
|
|
790
|
+
const qt = [
|
|
786
791
|
["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
|
|
787
792
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
|
|
788
|
-
],
|
|
789
|
-
backdrop:
|
|
790
|
-
celebrationOverlay:
|
|
791
|
-
celebrationChip:
|
|
792
|
-
backdropOpen:
|
|
793
|
-
backdropClosed:
|
|
794
|
-
panel:
|
|
795
|
-
panelOpen:
|
|
796
|
-
panelClosed:
|
|
797
|
-
header:
|
|
798
|
-
headerCenter:
|
|
799
|
-
title:
|
|
800
|
-
searchIconButton:
|
|
801
|
-
headerTitleWrap:
|
|
802
|
-
headerSearchWrap:
|
|
803
|
-
headerSearchOpen:
|
|
804
|
-
searchBar:
|
|
793
|
+
], Et = Dt("search", qt), Lt = "_backdrop_vl21a_1", $t = "_celebrationOverlay_vl21a_14", Ut = "_celebrationChip_vl21a_23", zt = "_backdropOpen_vl21a_74", Wt = "_backdropClosed_vl21a_78", jt = "_panel_vl21a_82", Vt = "_panelOpen_vl21a_102", Gt = "_panelClosed_vl21a_106", Qt = "_header_vl21a_145", Yt = "_headerCenter_vl21a_154", Kt = "_title_vl21a_162", Ht = "_searchIconButton_vl21a_171", Xt = "_headerTitleWrap_vl21a_193", Zt = "_headerSearchWrap_vl21a_197", Jt = "_headerSearchOpen_vl21a_209", en = "_searchBar_vl21a_221", tn = "_searchInput_vl21a_233", nn = "_searchClearButton_vl21a_254", rn = "_closeButton_vl21a_276", an = "_body_vl21a_309", on = "_muted_vl21a_314", sn = "_error_vl21a_319", cn = "_variants_vl21a_324", ln = "_variantList_vl21a_328", un = "_variantRow_vl21a_336", dn = "_variantLeft_vl21a_344", hn = "_addToBundleButton_vl21a_351", fn = "_variantThumb_vl21a_379", mn = "_variantThumbImg_vl21a_389", pn = "_variantThumbFallback_vl21a_396", vn = "_variantInfo_vl21a_406", bn = "_variantName_vl21a_410", yn = "_variantMeta_vl21a_419", _n = "_variantPriceRow_vl21a_427", wn = "_variantCompareAt_vl21a_434", gn = "_variantPrice_vl21a_427", xn = "_qtyControls_vl21a_445", In = "_qtyButton_vl21a_451", Cn = "_qtyValue_vl21a_476", Bn = "_footer_vl21a_483", Sn = "_poweredBy_vl21a_490", Nn = "_boxSummaryWindow_vl21a_502", Tn = "_boxSummaryRow_vl21a_519", Mn = "_boxSlot_vl21a_527", Pn = "_boxItem_vl21a_535", On = "_boxItemClickable_vl21a_547", kn = "_boxThresholdLabel_vl21a_556", Fn = "_boxItemPlaceholder_vl21a_567", An = "_boxItemFilled_vl21a_573", Rn = "_boxItemThreshold_vl21a_579", Dn = "_boxItemDiscountText_vl21a_587", qn = "_boxItemPlus_vl21a_595", En = "_boxItemImage_vl21a_602", Ln = "_boxItemFallback_vl21a_609", $n = "_ctaButtonGroup_vl21a_620", Un = "_ctaButtonGroupAnimating_vl21a_627", zn = "_cta_vl21a_620", Wn = "_ctaDualLeft_vl21a_655", jn = "_ctaDualLeftAnimating_vl21a_673", Vn = "_ctaDualRight_vl21a_686", Gn = "_ctaDualRightAnimating_vl21a_702", Qn = "_ctaTotals_vl21a_713", Yn = "_ctaDiscountBadge_vl21a_721", Kn = "_ctaTotalsWrap_vl21a_735", Hn = "_ctaTotalsWrapVisible_vl21a_748", Xn = "_ctaTotalsStrike_vl21a_755", Zn = "_ctaTotalsPrice_vl21a_762", u = {
|
|
794
|
+
backdrop: Lt,
|
|
795
|
+
celebrationOverlay: $t,
|
|
796
|
+
celebrationChip: Ut,
|
|
797
|
+
backdropOpen: zt,
|
|
798
|
+
backdropClosed: Wt,
|
|
799
|
+
panel: jt,
|
|
800
|
+
panelOpen: Vt,
|
|
801
|
+
panelClosed: Gt,
|
|
802
|
+
header: Qt,
|
|
803
|
+
headerCenter: Yt,
|
|
804
|
+
title: Kt,
|
|
805
|
+
searchIconButton: Ht,
|
|
806
|
+
headerTitleWrap: Xt,
|
|
807
|
+
headerSearchWrap: Zt,
|
|
808
|
+
headerSearchOpen: Jt,
|
|
809
|
+
searchBar: en,
|
|
805
810
|
searchInput: tn,
|
|
806
|
-
searchClearButton:
|
|
807
|
-
closeButton:
|
|
808
|
-
body:
|
|
809
|
-
muted:
|
|
810
|
-
error:
|
|
811
|
-
variants:
|
|
812
|
-
variantList:
|
|
813
|
-
variantRow:
|
|
814
|
-
variantLeft:
|
|
815
|
-
addToBundleButton:
|
|
816
|
-
variantThumb:
|
|
817
|
-
variantThumbImg:
|
|
818
|
-
variantThumbFallback:
|
|
819
|
-
variantInfo:
|
|
811
|
+
searchClearButton: nn,
|
|
812
|
+
closeButton: rn,
|
|
813
|
+
body: an,
|
|
814
|
+
muted: on,
|
|
815
|
+
error: sn,
|
|
816
|
+
variants: cn,
|
|
817
|
+
variantList: ln,
|
|
818
|
+
variantRow: un,
|
|
819
|
+
variantLeft: dn,
|
|
820
|
+
addToBundleButton: hn,
|
|
821
|
+
variantThumb: fn,
|
|
822
|
+
variantThumbImg: mn,
|
|
823
|
+
variantThumbFallback: pn,
|
|
824
|
+
variantInfo: vn,
|
|
820
825
|
variantName: bn,
|
|
821
|
-
variantMeta:
|
|
826
|
+
variantMeta: yn,
|
|
822
827
|
variantPriceRow: _n,
|
|
823
|
-
variantCompareAt:
|
|
824
|
-
variantPrice:
|
|
825
|
-
qtyControls:
|
|
826
|
-
qtyButton:
|
|
827
|
-
qtyValue:
|
|
828
|
-
footer:
|
|
829
|
-
poweredBy:
|
|
830
|
-
boxSummaryWindow:
|
|
831
|
-
boxSummaryRow:
|
|
832
|
-
boxSlot:
|
|
833
|
-
boxItem:
|
|
834
|
-
boxItemClickable:
|
|
835
|
-
boxThresholdLabel:
|
|
836
|
-
boxItemPlaceholder:
|
|
828
|
+
variantCompareAt: wn,
|
|
829
|
+
variantPrice: gn,
|
|
830
|
+
qtyControls: xn,
|
|
831
|
+
qtyButton: In,
|
|
832
|
+
qtyValue: Cn,
|
|
833
|
+
footer: Bn,
|
|
834
|
+
poweredBy: Sn,
|
|
835
|
+
boxSummaryWindow: Nn,
|
|
836
|
+
boxSummaryRow: Tn,
|
|
837
|
+
boxSlot: Mn,
|
|
838
|
+
boxItem: Pn,
|
|
839
|
+
boxItemClickable: On,
|
|
840
|
+
boxThresholdLabel: kn,
|
|
841
|
+
boxItemPlaceholder: Fn,
|
|
837
842
|
boxItemFilled: An,
|
|
838
843
|
boxItemThreshold: Rn,
|
|
839
|
-
boxItemDiscountText:
|
|
840
|
-
boxItemPlus:
|
|
841
|
-
boxItemImage:
|
|
842
|
-
boxItemFallback:
|
|
843
|
-
ctaButtonGroup:
|
|
844
|
-
ctaButtonGroupAnimating:
|
|
845
|
-
cta:
|
|
846
|
-
ctaDualLeft:
|
|
847
|
-
ctaDualLeftAnimating:
|
|
844
|
+
boxItemDiscountText: Dn,
|
|
845
|
+
boxItemPlus: qn,
|
|
846
|
+
boxItemImage: En,
|
|
847
|
+
boxItemFallback: Ln,
|
|
848
|
+
ctaButtonGroup: $n,
|
|
849
|
+
ctaButtonGroupAnimating: Un,
|
|
850
|
+
cta: zn,
|
|
851
|
+
ctaDualLeft: Wn,
|
|
852
|
+
ctaDualLeftAnimating: jn,
|
|
848
853
|
ctaDualRight: Vn,
|
|
849
|
-
ctaDualRightAnimating:
|
|
850
|
-
ctaTotals:
|
|
851
|
-
ctaDiscountBadge:
|
|
852
|
-
ctaTotalsWrap:
|
|
853
|
-
ctaTotalsWrapVisible:
|
|
854
|
-
ctaTotalsStrike:
|
|
855
|
-
ctaTotalsPrice:
|
|
854
|
+
ctaDualRightAnimating: Gn,
|
|
855
|
+
ctaTotals: Qn,
|
|
856
|
+
ctaDiscountBadge: Yn,
|
|
857
|
+
ctaTotalsWrap: Kn,
|
|
858
|
+
ctaTotalsWrapVisible: Hn,
|
|
859
|
+
ctaTotalsStrike: Xn,
|
|
860
|
+
ctaTotalsPrice: Zn
|
|
856
861
|
};
|
|
857
862
|
function or(i) {
|
|
858
|
-
var
|
|
863
|
+
var rt;
|
|
859
864
|
const {
|
|
860
|
-
isOpen:
|
|
861
|
-
close:
|
|
862
|
-
loading:
|
|
863
|
-
submitting:
|
|
865
|
+
isOpen: e,
|
|
866
|
+
close: t,
|
|
867
|
+
loading: r,
|
|
868
|
+
submitting: a,
|
|
864
869
|
error: n,
|
|
865
870
|
currencyCode: l,
|
|
866
871
|
config: c,
|
|
867
872
|
eligibleVariants: m,
|
|
868
873
|
selections: w,
|
|
869
|
-
selectionOrder:
|
|
870
|
-
setQuantity:
|
|
874
|
+
selectionOrder: k,
|
|
875
|
+
setQuantity: F,
|
|
871
876
|
bundleSize: x,
|
|
872
|
-
minRequired:
|
|
873
|
-
canSubmit:
|
|
874
|
-
submit:
|
|
875
|
-
submitAndCheckout:
|
|
876
|
-
} =
|
|
877
|
+
minRequired: X,
|
|
878
|
+
canSubmit: V,
|
|
879
|
+
submit: Z,
|
|
880
|
+
submitAndCheckout: z
|
|
881
|
+
} = Qe(), [M, A] = P(!1), [W, g] = P(""), he = L(null), se = L(null), _e = L(null), [fe, Ne] = P(() => typeof window > "u" ? { width: 0, height: 0 } : { width: window.innerWidth, height: window.innerHeight }), [Te, Me] = P(0), [me, Pe] = P(null), [Oe, pe] = P(!1), J = L(null), ve = L(x), K = 7e3, [Ie, ce] = P(0), [ee, we] = P(null), [le, Ce] = P(!1), te = L(null), Ee = 2800, f = (o) => {
|
|
877
882
|
const s = Number.parseFloat(o);
|
|
878
883
|
return Number.isFinite(s) ? String(Math.round(s)) : o;
|
|
879
884
|
}, C = (o) => {
|
|
880
885
|
const s = (o ?? []).filter((d) => {
|
|
881
886
|
var I, _;
|
|
882
|
-
const
|
|
883
|
-
return !(!
|
|
887
|
+
const v = (I = d == null ? void 0 : d.name) == null ? void 0 : I.trim(), p = (_ = d == null ? void 0 : d.value) == null ? void 0 : _.trim();
|
|
888
|
+
return !(!v || !p || v.toLowerCase() === "title");
|
|
884
889
|
});
|
|
885
890
|
return s.length ? s.map((d) => `${d.name}: ${d.value}`).join(" · ") : null;
|
|
886
891
|
}, D = (o) => {
|
|
@@ -889,7 +894,7 @@ function or(i) {
|
|
|
889
894
|
}, y = (o) => {
|
|
890
895
|
const s = D(o), d = C(o.selectedOptions);
|
|
891
896
|
return [s, d].filter(Boolean).join(" — ");
|
|
892
|
-
}, [
|
|
897
|
+
}, [ne, q] = P(e), G = L(null), B = (o) => {
|
|
893
898
|
const s = Number(o);
|
|
894
899
|
if (!Number.isFinite(s)) return o;
|
|
895
900
|
if (l)
|
|
@@ -898,173 +903,173 @@ function or(i) {
|
|
|
898
903
|
} catch {
|
|
899
904
|
}
|
|
900
905
|
return `$${s.toFixed(2)}`;
|
|
901
|
-
},
|
|
906
|
+
}, re = ((rt = c == null ? void 0 : c.title) == null ? void 0 : rt.trim()) || "Build your bundle", Q = T(() => {
|
|
902
907
|
const o = Number((c == null ? void 0 : c.maxBundleSize) ?? NaN), s = Number.isFinite(o) ? Math.floor(o) : 100;
|
|
903
908
|
return Math.max(2, Math.min(100, s));
|
|
904
|
-
}, [c == null ? void 0 : c.maxBundleSize]),
|
|
905
|
-
const o =
|
|
906
|
-
if (!o) return
|
|
907
|
-
const s = o.split(/\s+/).filter(Boolean), d = (
|
|
909
|
+
}, [c == null ? void 0 : c.maxBundleSize]), ae = x >= Q, E = T(() => [...m].sort((o, s) => o.displayName.localeCompare(s.displayName)), [m]), Y = T(() => {
|
|
910
|
+
const o = W.trim().toLowerCase();
|
|
911
|
+
if (!o) return E;
|
|
912
|
+
const s = o.split(/\s+/).filter(Boolean), d = (v) => {
|
|
908
913
|
var _;
|
|
909
914
|
const p = [];
|
|
910
|
-
p.push(
|
|
911
|
-
for (const
|
|
912
|
-
p.push(
|
|
915
|
+
p.push(v.displayName), (_ = v.product) != null && _.title && p.push(v.product.title);
|
|
916
|
+
for (const S of v.selectedOptions ?? [])
|
|
917
|
+
p.push(S.name), p.push(S.value);
|
|
913
918
|
const I = p.join(" ").toLowerCase();
|
|
914
|
-
return s.every((
|
|
919
|
+
return s.every((S) => I.includes(S));
|
|
915
920
|
};
|
|
916
|
-
return
|
|
917
|
-
}, [
|
|
921
|
+
return E.filter(d);
|
|
922
|
+
}, [W, E]), N = T(() => [...(c == null ? void 0 : c.rules) ?? []].sort((o, s) => o.minBundleSize - s.minBundleSize), [c == null ? void 0 : c.rules]), R = T(() => Math.max(0, X - x), [x, X]), ge = T(() => {
|
|
918
923
|
let o = null;
|
|
919
|
-
for (const s of
|
|
924
|
+
for (const s of N)
|
|
920
925
|
x >= s.minBundleSize && (o = s);
|
|
921
926
|
return o;
|
|
922
|
-
}, [x,
|
|
923
|
-
if (!
|
|
924
|
-
const o = Number.parseFloat(
|
|
927
|
+
}, [x, N]), b = T(() => {
|
|
928
|
+
if (!ge) return null;
|
|
929
|
+
const o = Number.parseFloat(ge.discountPercent);
|
|
925
930
|
return !Number.isFinite(o) || o <= 0 ? null : o;
|
|
926
|
-
}, [
|
|
927
|
-
const o =
|
|
931
|
+
}, [ge]), be = T(() => {
|
|
932
|
+
const o = N[0];
|
|
928
933
|
if (!o) return null;
|
|
929
934
|
const s = Number.parseFloat(o.discountPercent);
|
|
930
935
|
return !Number.isFinite(s) || s <= 0 ? null : s;
|
|
931
|
-
}, [
|
|
936
|
+
}, [N]), xe = b ?? be, ie = T(() => {
|
|
932
937
|
const o = new Map(m.map((d) => [d.id, d]));
|
|
933
938
|
let s = 0;
|
|
934
|
-
for (const [d,
|
|
935
|
-
const p =
|
|
939
|
+
for (const [d, v] of Object.entries(w)) {
|
|
940
|
+
const p = v ?? 0;
|
|
936
941
|
if (p <= 0) continue;
|
|
937
942
|
const I = o.get(d), _ = Number(I == null ? void 0 : I.price);
|
|
938
943
|
Number.isFinite(_) && (s += _ * p);
|
|
939
944
|
}
|
|
940
945
|
return Math.round(s * 100) / 100;
|
|
941
|
-
}, [m, w]),
|
|
942
|
-
if (!
|
|
943
|
-
const o =
|
|
946
|
+
}, [m, w]), ke = T(() => {
|
|
947
|
+
if (!b) return ie;
|
|
948
|
+
const o = ie * (1 - b / 100);
|
|
944
949
|
return Math.round(o * 100) / 100;
|
|
945
|
-
}, [
|
|
950
|
+
}, [b, ie]), He = T(() => N.length ? Math.max(...N.map((o) => o.minBundleSize)) : 0, [N]), Le = T(() => {
|
|
946
951
|
const o = new Map(m.map((s) => [s.id, s]));
|
|
947
|
-
return
|
|
948
|
-
}, [m,
|
|
952
|
+
return k.map((s) => o.get(s)).filter((s) => !!s);
|
|
953
|
+
}, [m, k]), ht = T(() => {
|
|
949
954
|
var s;
|
|
950
955
|
const o = /* @__PURE__ */ new Map();
|
|
951
|
-
for (const d of
|
|
952
|
-
const
|
|
953
|
-
o.set(
|
|
956
|
+
for (const d of N) {
|
|
957
|
+
const v = Math.max(0, d.minBundleSize - 1);
|
|
958
|
+
o.set(v, {
|
|
954
959
|
discountPercent: d.discountPercent,
|
|
955
960
|
minBundleSize: d.minBundleSize,
|
|
956
961
|
label: ((s = d.label) == null ? void 0 : s.trim()) || `Buy ${d.minBundleSize}+`
|
|
957
962
|
});
|
|
958
963
|
}
|
|
959
964
|
return o;
|
|
960
|
-
}, [
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
+
}, [N]), ft = T(() => Math.max(He || X, Le.length), [Le.length, He, X]), [$e, Xe] = P(!0), Ze = L(R);
|
|
966
|
+
$(() => {
|
|
967
|
+
{
|
|
968
|
+
const o = Ze.current > 0;
|
|
969
|
+
Xe(!(o && R === 0));
|
|
965
970
|
}
|
|
966
|
-
|
|
967
|
-
}, [
|
|
968
|
-
const
|
|
969
|
-
const s =
|
|
971
|
+
Ze.current = R;
|
|
972
|
+
}, [R, c == null ? void 0 : c.ctaButtonMode]);
|
|
973
|
+
const Ue = L(null), Je = L(null), et = L(null), tt = L(x), nt = (o) => {
|
|
974
|
+
const s = Je.current;
|
|
970
975
|
if (!s) return;
|
|
971
976
|
const d = s.querySelector(`[data-variant-row="${o}"]`);
|
|
972
977
|
if (!d) return;
|
|
973
|
-
const
|
|
974
|
-
if (p.top >=
|
|
975
|
-
const
|
|
976
|
-
s.scrollTo({ top:
|
|
978
|
+
const v = s.getBoundingClientRect(), p = d.getBoundingClientRect(), I = 8;
|
|
979
|
+
if (p.top >= v.top + I && p.bottom <= v.bottom - I) return;
|
|
980
|
+
const S = Math.max(0, s.scrollHeight - s.clientHeight), j = p.top - v.top + p.height / 2, H = s.scrollTop + j - s.clientHeight / 2, oe = Math.min(S, Math.max(0, H));
|
|
981
|
+
s.scrollTo({ top: oe, behavior: "smooth" });
|
|
977
982
|
};
|
|
978
|
-
return
|
|
979
|
-
if (!
|
|
983
|
+
return $(() => {
|
|
984
|
+
if (!e) return;
|
|
980
985
|
const o = (s) => {
|
|
981
|
-
s.key === "Escape" &&
|
|
986
|
+
s.key === "Escape" && t();
|
|
982
987
|
};
|
|
983
988
|
return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
|
|
984
|
-
}, [
|
|
989
|
+
}, [t, e]), $(() => {
|
|
985
990
|
if (typeof window > "u") return;
|
|
986
|
-
const o = () =>
|
|
991
|
+
const o = () => Ne({ width: window.innerWidth, height: window.innerHeight });
|
|
987
992
|
return o(), window.addEventListener("resize", o), () => window.removeEventListener("resize", o);
|
|
988
|
-
}, []),
|
|
989
|
-
if (G.current != null && (window.clearTimeout(G.current), G.current = null),
|
|
993
|
+
}, []), $(() => {
|
|
994
|
+
if (G.current != null && (window.clearTimeout(G.current), G.current = null), e) {
|
|
990
995
|
q(!0);
|
|
991
996
|
return;
|
|
992
997
|
}
|
|
993
998
|
G.current = window.setTimeout(() => {
|
|
994
999
|
q(!1), G.current = null;
|
|
995
1000
|
}, 220);
|
|
996
|
-
}, [
|
|
1001
|
+
}, [e]), $(() => () => {
|
|
997
1002
|
G.current != null && window.clearTimeout(G.current);
|
|
998
|
-
}, []),
|
|
999
|
-
|
|
1000
|
-
}, []),
|
|
1001
|
-
|
|
1002
|
-
}, []),
|
|
1003
|
-
if (!
|
|
1003
|
+
}, []), $(() => () => {
|
|
1004
|
+
J.current != null && window.clearTimeout(J.current);
|
|
1005
|
+
}, []), $(() => () => {
|
|
1006
|
+
te.current != null && window.clearTimeout(te.current);
|
|
1007
|
+
}, []), $(() => {
|
|
1008
|
+
if (!e || !M) return;
|
|
1004
1009
|
const o = requestAnimationFrame(() => {
|
|
1005
1010
|
var s;
|
|
1006
|
-
return (s =
|
|
1011
|
+
return (s = he.current) == null ? void 0 : s.focus();
|
|
1007
1012
|
});
|
|
1008
1013
|
return () => cancelAnimationFrame(o);
|
|
1009
|
-
}, [
|
|
1010
|
-
const o =
|
|
1011
|
-
if (
|
|
1012
|
-
const s =
|
|
1014
|
+
}, [e, M]), $(() => {
|
|
1015
|
+
const o = tt.current;
|
|
1016
|
+
if (tt.current = x, x <= o) return;
|
|
1017
|
+
const s = et.current;
|
|
1013
1018
|
if (!s) return;
|
|
1014
|
-
const d =
|
|
1019
|
+
const d = N.some((_) => _.minBundleSize === x), v = N.find((_) => _.minBundleSize > x), p = v && d ? v.minBundleSize - 1 : v ? null : x - 1;
|
|
1015
1020
|
if (p == null || p < 0) return;
|
|
1016
1021
|
const I = requestAnimationFrame(() => {
|
|
1017
1022
|
const _ = s.querySelector(`[data-box-slot="${p}"]`);
|
|
1018
1023
|
if (!_) return;
|
|
1019
|
-
const
|
|
1020
|
-
if (
|
|
1021
|
-
const
|
|
1022
|
-
s.scrollTo({ left:
|
|
1024
|
+
const S = s.getBoundingClientRect(), H = _.getBoundingClientRect().right - S.right;
|
|
1025
|
+
if (H <= 1) return;
|
|
1026
|
+
const oe = Math.max(0, s.scrollWidth - s.clientWidth), ye = Math.min(oe, Math.max(0, s.scrollLeft + H));
|
|
1027
|
+
s.scrollTo({ left: ye, behavior: "smooth" });
|
|
1023
1028
|
});
|
|
1024
1029
|
return () => cancelAnimationFrame(I);
|
|
1025
|
-
}, [x,
|
|
1026
|
-
if (!
|
|
1027
|
-
const o =
|
|
1028
|
-
if (
|
|
1029
|
-
const s =
|
|
1030
|
-
s && (
|
|
1031
|
-
|
|
1032
|
-
},
|
|
1033
|
-
}, [x,
|
|
1034
|
-
if (!
|
|
1030
|
+
}, [x, N]), $(() => {
|
|
1031
|
+
if (!e) return;
|
|
1032
|
+
const o = ve.current;
|
|
1033
|
+
if (ve.current = x, x <= o) return;
|
|
1034
|
+
const s = N.find((d) => d.minBundleSize === x);
|
|
1035
|
+
s && (we(`You received a ${f(s.discountPercent)}% discount!`), ce((d) => d + 1), Ce(!0), te.current != null && window.clearTimeout(te.current), te.current = window.setTimeout(() => {
|
|
1036
|
+
Ce(!1), te.current = null;
|
|
1037
|
+
}, Ee));
|
|
1038
|
+
}, [x, e, N]), $(() => {
|
|
1039
|
+
if (!e || !le || !ee) return;
|
|
1035
1040
|
const o = requestAnimationFrame(() => {
|
|
1036
|
-
var
|
|
1037
|
-
const s =
|
|
1041
|
+
var S;
|
|
1042
|
+
const s = _e.current, d = s == null ? void 0 : s.getBoundingClientRect(), v = (S = Ue.current) == null ? void 0 : S.getBoundingClientRect(), p = d ? d.left + d.width / 2 : v ? v.left + v.width / 2 : window.innerWidth / 2, I = d ? d.top + d.height / 2 : v ? v.top + v.height / 2 : window.innerHeight / 2, _ = {
|
|
1038
1043
|
x: p - 2,
|
|
1039
1044
|
y: I - 2,
|
|
1040
1045
|
w: 4,
|
|
1041
1046
|
h: 4
|
|
1042
1047
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
},
|
|
1048
|
+
Pe(_), Me((j) => j + 1), pe(!0), J.current != null && window.clearTimeout(J.current), J.current = window.setTimeout(() => {
|
|
1049
|
+
pe(!1), J.current = null;
|
|
1050
|
+
}, K);
|
|
1046
1051
|
});
|
|
1047
1052
|
return () => cancelAnimationFrame(o);
|
|
1048
|
-
}, [
|
|
1053
|
+
}, [Ie, ee, K, le, e]), $(() => {
|
|
1049
1054
|
var o;
|
|
1050
|
-
|
|
1051
|
-
}, [
|
|
1055
|
+
e && ((o = Ue.current) == null || o.focus());
|
|
1056
|
+
}, [e]), ne ? /* @__PURE__ */ O(
|
|
1052
1057
|
"div",
|
|
1053
1058
|
{
|
|
1054
1059
|
role: "dialog",
|
|
1055
1060
|
"aria-modal": "true",
|
|
1056
1061
|
"aria-label": "Bundle builder",
|
|
1057
|
-
className: [u.backdrop,
|
|
1062
|
+
className: [u.backdrop, e ? u.backdropOpen : u.backdropClosed, i.className].filter(Boolean).join(" "),
|
|
1058
1063
|
onMouseDown: (o) => {
|
|
1059
|
-
o.target === o.currentTarget &&
|
|
1064
|
+
o.target === o.currentTarget && t();
|
|
1060
1065
|
},
|
|
1061
1066
|
children: [
|
|
1062
|
-
|
|
1063
|
-
|
|
1067
|
+
Oe && me && fe.width > 0 && fe.height > 0 ? /* @__PURE__ */ h(
|
|
1068
|
+
Pt,
|
|
1064
1069
|
{
|
|
1065
|
-
width:
|
|
1066
|
-
height:
|
|
1067
|
-
confettiSource:
|
|
1070
|
+
width: fe.width,
|
|
1071
|
+
height: fe.height,
|
|
1072
|
+
confettiSource: me,
|
|
1068
1073
|
colors: [
|
|
1069
1074
|
"#2563eb",
|
|
1070
1075
|
// blue-600
|
|
@@ -1087,42 +1092,42 @@ function or(i) {
|
|
|
1087
1092
|
initialVelocityX: { min: -6, max: 6 },
|
|
1088
1093
|
style: { position: "fixed", inset: 0, pointerEvents: "none", zIndex: 2147483646 }
|
|
1089
1094
|
},
|
|
1090
|
-
|
|
1095
|
+
Te
|
|
1091
1096
|
) : null,
|
|
1092
|
-
/* @__PURE__ */
|
|
1093
|
-
|
|
1094
|
-
/* @__PURE__ */
|
|
1097
|
+
/* @__PURE__ */ O("aside", { ref: Ue, className: [u.panel, e ? u.panelOpen : u.panelClosed].filter(Boolean).join(" "), tabIndex: -1, children: [
|
|
1098
|
+
le && ee ? /* @__PURE__ */ h("div", { className: u.celebrationOverlay, "aria-hidden": "true", children: /* @__PURE__ */ h("div", { ref: _e, className: u.celebrationChip, children: ee }, Ie) }) : null,
|
|
1099
|
+
/* @__PURE__ */ O("header", { className: [u.header, M ? u.headerSearchOpen : null].filter(Boolean).join(" "), children: [
|
|
1095
1100
|
/* @__PURE__ */ h(
|
|
1096
1101
|
"button",
|
|
1097
1102
|
{
|
|
1098
1103
|
type: "button",
|
|
1099
1104
|
className: u.searchIconButton,
|
|
1100
|
-
"aria-label":
|
|
1101
|
-
"aria-expanded":
|
|
1105
|
+
"aria-label": M ? "Search (expanded)" : "Search",
|
|
1106
|
+
"aria-expanded": M,
|
|
1102
1107
|
onClick: () => {
|
|
1103
|
-
|
|
1108
|
+
A(!0);
|
|
1104
1109
|
},
|
|
1105
|
-
children: /* @__PURE__ */ h(
|
|
1110
|
+
children: /* @__PURE__ */ h(Et, { size: 18, "aria-hidden": "true" })
|
|
1106
1111
|
}
|
|
1107
1112
|
),
|
|
1108
|
-
/* @__PURE__ */
|
|
1109
|
-
/* @__PURE__ */ h("div", { className: u.headerTitleWrap, "aria-hidden":
|
|
1110
|
-
/* @__PURE__ */ h("div", { className: u.headerSearchWrap, "aria-hidden": !
|
|
1113
|
+
/* @__PURE__ */ O("div", { className: u.headerCenter, children: [
|
|
1114
|
+
/* @__PURE__ */ h("div", { className: u.headerTitleWrap, "aria-hidden": M, children: /* @__PURE__ */ h("h2", { className: u.title, children: re }) }),
|
|
1115
|
+
/* @__PURE__ */ h("div", { className: u.headerSearchWrap, "aria-hidden": !M, children: /* @__PURE__ */ O("div", { className: u.searchBar, children: [
|
|
1111
1116
|
/* @__PURE__ */ h(
|
|
1112
1117
|
"input",
|
|
1113
1118
|
{
|
|
1114
|
-
ref:
|
|
1119
|
+
ref: he,
|
|
1115
1120
|
className: u.searchInput,
|
|
1116
1121
|
type: "search",
|
|
1117
|
-
value:
|
|
1122
|
+
value: W,
|
|
1118
1123
|
placeholder: "Search",
|
|
1119
1124
|
onChange: (o) => g(o.target.value),
|
|
1120
1125
|
onBlur: () => {
|
|
1121
|
-
|
|
1126
|
+
W.trim() === "" && A(!1);
|
|
1122
1127
|
}
|
|
1123
1128
|
}
|
|
1124
1129
|
),
|
|
1125
|
-
|
|
1130
|
+
W.trim() ? /* @__PURE__ */ h(
|
|
1126
1131
|
"button",
|
|
1127
1132
|
{
|
|
1128
1133
|
type: "button",
|
|
@@ -1132,7 +1137,7 @@ function or(i) {
|
|
|
1132
1137
|
},
|
|
1133
1138
|
onClick: () => {
|
|
1134
1139
|
var o;
|
|
1135
|
-
g(""), (o =
|
|
1140
|
+
g(""), (o = he.current) == null || o.focus();
|
|
1136
1141
|
},
|
|
1137
1142
|
"aria-label": "Clear search",
|
|
1138
1143
|
children: "Clear"
|
|
@@ -1140,18 +1145,18 @@ function or(i) {
|
|
|
1140
1145
|
) : null
|
|
1141
1146
|
] }) })
|
|
1142
1147
|
] }),
|
|
1143
|
-
/* @__PURE__ */ h("button", { type: "button", onClick:
|
|
1148
|
+
/* @__PURE__ */ h("button", { type: "button", onClick: t, disabled: a, className: u.closeButton, "aria-label": "Close", children: "×" })
|
|
1144
1149
|
] }),
|
|
1145
|
-
/* @__PURE__ */
|
|
1146
|
-
|
|
1150
|
+
/* @__PURE__ */ O("div", { className: u.body, ref: Je, children: [
|
|
1151
|
+
r ? /* @__PURE__ */ h("p", { className: u.muted, children: "Loading…" }) : null,
|
|
1147
1152
|
n ? /* @__PURE__ */ h("p", { className: u.error, children: n }) : null,
|
|
1148
|
-
!
|
|
1153
|
+
!r && c && !c.isActive ? /* @__PURE__ */ h("p", { className: u.error, children: "Bundles are not active." }) : null,
|
|
1149
1154
|
/* @__PURE__ */ h("div", { className: u.variants, children: /* @__PURE__ */ h("ul", { className: u.variantList, children: Y.map((o) => {
|
|
1150
|
-
var
|
|
1151
|
-
const s = w[o.id] ?? 0, d = D(o),
|
|
1152
|
-
return /* @__PURE__ */
|
|
1153
|
-
/* @__PURE__ */
|
|
1154
|
-
/* @__PURE__ */ h("div", { className: u.variantThumb, "aria-hidden": "true", children: (
|
|
1155
|
+
var H, oe, ye, Be;
|
|
1156
|
+
const s = w[o.id] ?? 0, d = D(o), v = C(o.selectedOptions), p = y(o), I = xe, _ = Number(o.price), S = I != null && Number.isFinite(I) && I > 0 && Number.isFinite(_), j = S ? Math.round(_ * (1 - I / 100) * 100) / 100 : null;
|
|
1157
|
+
return /* @__PURE__ */ O("li", { className: u.variantRow, "data-variant-row": o.id, children: [
|
|
1158
|
+
/* @__PURE__ */ O("div", { className: u.variantLeft, children: [
|
|
1159
|
+
/* @__PURE__ */ h("div", { className: u.variantThumb, "aria-hidden": "true", children: (H = o.image) != null && H.url ? /* @__PURE__ */ h(
|
|
1155
1160
|
"img",
|
|
1156
1161
|
{
|
|
1157
1162
|
className: u.variantThumbImg,
|
|
@@ -1159,12 +1164,12 @@ function or(i) {
|
|
|
1159
1164
|
alt: o.image.altText ?? p,
|
|
1160
1165
|
loading: "lazy"
|
|
1161
1166
|
}
|
|
1162
|
-
) : /* @__PURE__ */ h("div", { className: u.variantThumbFallback, children: ((
|
|
1163
|
-
/* @__PURE__ */
|
|
1167
|
+
) : /* @__PURE__ */ h("div", { className: u.variantThumbFallback, children: ((Be = (ye = (oe = o.product) == null ? void 0 : oe.title) == null ? void 0 : ye.slice(0, 1)) == null ? void 0 : Be.toUpperCase()) ?? "•" }) }),
|
|
1168
|
+
/* @__PURE__ */ O("div", { className: u.variantInfo, children: [
|
|
1164
1169
|
/* @__PURE__ */ h("div", { className: u.variantName, children: d }),
|
|
1165
|
-
|
|
1166
|
-
/* @__PURE__ */
|
|
1167
|
-
|
|
1170
|
+
v ? /* @__PURE__ */ h("div", { className: u.variantMeta, children: v }) : null,
|
|
1171
|
+
/* @__PURE__ */ O("div", { className: u.variantPriceRow, children: [
|
|
1172
|
+
S ? /* @__PURE__ */ h("span", { className: u.variantCompareAt, children: B(Number.isFinite(_) ? _.toFixed(2) : o.price) }) : null,
|
|
1168
1173
|
/* @__PURE__ */ h("span", { className: u.variantPrice, children: B(
|
|
1169
1174
|
j != null ? j.toFixed(2) : Number.isFinite(_) ? _.toFixed(2) : o.price
|
|
1170
1175
|
) })
|
|
@@ -1175,19 +1180,19 @@ function or(i) {
|
|
|
1175
1180
|
"button",
|
|
1176
1181
|
{
|
|
1177
1182
|
type: "button",
|
|
1178
|
-
onClick: () =>
|
|
1179
|
-
disabled:
|
|
1183
|
+
onClick: () => F(o.id, 1),
|
|
1184
|
+
disabled: a || ae,
|
|
1180
1185
|
className: u.addToBundleButton,
|
|
1181
1186
|
"aria-label": `Add ${p} to bundle`,
|
|
1182
1187
|
children: "Add"
|
|
1183
1188
|
}
|
|
1184
|
-
) : /* @__PURE__ */
|
|
1189
|
+
) : /* @__PURE__ */ O("div", { className: u.qtyControls, children: [
|
|
1185
1190
|
/* @__PURE__ */ h(
|
|
1186
1191
|
"button",
|
|
1187
1192
|
{
|
|
1188
1193
|
type: "button",
|
|
1189
|
-
onClick: () =>
|
|
1190
|
-
disabled:
|
|
1194
|
+
onClick: () => F(o.id, s - 1),
|
|
1195
|
+
disabled: a || s <= 0,
|
|
1191
1196
|
className: u.qtyButton,
|
|
1192
1197
|
"aria-label": `Decrease ${p}`,
|
|
1193
1198
|
children: "−"
|
|
@@ -1198,8 +1203,8 @@ function or(i) {
|
|
|
1198
1203
|
"button",
|
|
1199
1204
|
{
|
|
1200
1205
|
type: "button",
|
|
1201
|
-
onClick: () =>
|
|
1202
|
-
disabled:
|
|
1206
|
+
onClick: () => F(o.id, s + 1),
|
|
1207
|
+
disabled: a || ae,
|
|
1203
1208
|
className: u.qtyButton,
|
|
1204
1209
|
"aria-label": `Increase ${p}`,
|
|
1205
1210
|
children: "+"
|
|
@@ -1209,11 +1214,11 @@ function or(i) {
|
|
|
1209
1214
|
] }, o.id);
|
|
1210
1215
|
}) }) })
|
|
1211
1216
|
] }),
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */ h("div", { className: u.boxSummaryWindow, ref:
|
|
1214
|
-
var
|
|
1215
|
-
const d =
|
|
1216
|
-
return /* @__PURE__ */
|
|
1217
|
+
/* @__PURE__ */ O("footer", { className: u.footer, ref: se, children: [
|
|
1218
|
+
/* @__PURE__ */ h("div", { className: u.boxSummaryWindow, ref: et, children: /* @__PURE__ */ h("div", { className: u.boxSummaryRow, "aria-label": "Bundle box summary", children: Array.from({ length: ft }).map((o, s) => {
|
|
1219
|
+
var H, oe, ye, Be;
|
|
1220
|
+
const d = Le[s], v = ht.get(s), p = !!d, I = !!v, _ = I && !p, S = v ? `${v.discountPercent}% off` : null, j = p ? d.displayName : `Slot ${s + 1}`;
|
|
1221
|
+
return /* @__PURE__ */ O("div", { "data-box-slot": s, className: u.boxSlot, children: [
|
|
1217
1222
|
/* @__PURE__ */ h(
|
|
1218
1223
|
"div",
|
|
1219
1224
|
{
|
|
@@ -1225,13 +1230,13 @@ function or(i) {
|
|
|
1225
1230
|
].filter(Boolean).join(" "),
|
|
1226
1231
|
role: p ? "button" : void 0,
|
|
1227
1232
|
tabIndex: p ? 0 : void 0,
|
|
1228
|
-
onClick: p ? () =>
|
|
1229
|
-
onKeyDown: p ? (
|
|
1230
|
-
(
|
|
1233
|
+
onClick: p ? () => nt(d.id) : void 0,
|
|
1234
|
+
onKeyDown: p ? (ze) => {
|
|
1235
|
+
(ze.key === "Enter" || ze.key === " ") && (ze.preventDefault(), nt(d.id));
|
|
1231
1236
|
} : void 0,
|
|
1232
|
-
"aria-label": _ &&
|
|
1233
|
-
title: _ &&
|
|
1234
|
-
children: p ? (
|
|
1237
|
+
"aria-label": _ && S ? `${j}. Unlocks ${S}.` : j,
|
|
1238
|
+
title: _ && S ? `${j} • Unlocks ${S}` : j,
|
|
1239
|
+
children: p ? (H = d.image) != null && H.url ? /* @__PURE__ */ h(
|
|
1235
1240
|
"img",
|
|
1236
1241
|
{
|
|
1237
1242
|
className: u.boxItemImage,
|
|
@@ -1239,56 +1244,53 @@ function or(i) {
|
|
|
1239
1244
|
alt: d.image.altText ?? d.displayName,
|
|
1240
1245
|
loading: "lazy"
|
|
1241
1246
|
}
|
|
1242
|
-
) : /* @__PURE__ */ h("div", { className: u.boxItemFallback, "aria-hidden": "true", children: ((
|
|
1247
|
+
) : /* @__PURE__ */ h("div", { className: u.boxItemFallback, "aria-hidden": "true", children: ((Be = (ye = (oe = d.product) == null ? void 0 : oe.title) == null ? void 0 : ye.slice(0, 1)) == null ? void 0 : Be.toUpperCase()) ?? "•" }) : _ && S ? /* @__PURE__ */ h("div", { className: u.boxItemDiscountText, children: S }) : /* @__PURE__ */ h("div", { className: u.boxItemPlus, "aria-hidden": "true", children: "+" })
|
|
1243
1248
|
}
|
|
1244
1249
|
),
|
|
1245
|
-
I ? /* @__PURE__ */ h("div", { className: u.boxThresholdLabel, children:
|
|
1250
|
+
I ? /* @__PURE__ */ h("div", { className: u.boxThresholdLabel, children: v.label }) : null
|
|
1246
1251
|
] }, s);
|
|
1247
1252
|
}) }) }),
|
|
1248
1253
|
/* @__PURE__ */ h(
|
|
1249
1254
|
"div",
|
|
1250
1255
|
{
|
|
1251
|
-
className: [u.ctaTotalsWrap,
|
|
1252
|
-
"aria-hidden":
|
|
1253
|
-
children: /* @__PURE__ */
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
+
className: [u.ctaTotalsWrap, R <= 0 ? u.ctaTotalsWrapVisible : null].filter(Boolean).join(" "),
|
|
1257
|
+
"aria-hidden": R > 0,
|
|
1258
|
+
children: /* @__PURE__ */ O("div", { className: u.ctaTotals, "aria-label": "Totals", children: [
|
|
1259
|
+
xe ? /* @__PURE__ */ O("span", { className: u.ctaDiscountBadge, children: [
|
|
1260
|
+
xe,
|
|
1256
1261
|
"% Discount"
|
|
1257
1262
|
] }) : /* @__PURE__ */ h("span", {}),
|
|
1258
|
-
/* @__PURE__ */ h("span", { children:
|
|
1259
|
-
/* @__PURE__ */ h("span", { className: u.ctaTotalsStrike, children: B(
|
|
1263
|
+
/* @__PURE__ */ h("span", { children: b ? /* @__PURE__ */ O(mt, { children: [
|
|
1264
|
+
/* @__PURE__ */ h("span", { className: u.ctaTotalsStrike, children: B(ie.toFixed(2)) }),
|
|
1260
1265
|
" ",
|
|
1261
|
-
/* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: B(
|
|
1262
|
-
] }) : /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: B(
|
|
1266
|
+
/* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: B(ke.toFixed(2)) })
|
|
1267
|
+
] }) : /* @__PURE__ */ h("span", { className: u.ctaTotalsPrice, children: B(ie.toFixed(2)) }) })
|
|
1263
1268
|
] })
|
|
1264
1269
|
}
|
|
1265
1270
|
),
|
|
1266
|
-
(
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
"button",
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
"button",
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
] }) : o === "checkout" ? /* @__PURE__ */ h("button", { type: "button", onClick: L, disabled: !E, className: u.cta, children: r ? "Processing…" : S > 0 ? `Add ${S} more product${S === 1 ? "" : "s"}` : "Checkout" }) : /* @__PURE__ */ h("button", { type: "button", onClick: H, disabled: !E, className: u.cta, children: r ? "Adding…" : S > 0 ? `Add ${S} more product${S === 1 ? "" : "s"}` : "Add to Basket" });
|
|
1290
|
-
})(),
|
|
1291
|
-
/* @__PURE__ */ k("div", { className: u.poweredBy, children: [
|
|
1271
|
+
R > 0 ? /* @__PURE__ */ h("button", { type: "button", onClick: Z, disabled: !V, className: u.cta, children: a ? "Adding…" : `Add ${R} more product${R === 1 ? "" : "s"}` }) : /* @__PURE__ */ O("div", { className: `${u.ctaButtonGroup} ${$e ? u.ctaButtonGroupAnimating : ""}`, children: [
|
|
1272
|
+
/* @__PURE__ */ h(
|
|
1273
|
+
"button",
|
|
1274
|
+
{
|
|
1275
|
+
type: "button",
|
|
1276
|
+
onClick: Z,
|
|
1277
|
+
disabled: !V,
|
|
1278
|
+
className: `${u.ctaDualLeft} ${$e ? u.ctaDualLeftAnimating : ""}`,
|
|
1279
|
+
children: /* @__PURE__ */ h("span", { children: a ? "Adding…" : "Add to Basket" })
|
|
1280
|
+
}
|
|
1281
|
+
),
|
|
1282
|
+
/* @__PURE__ */ h(
|
|
1283
|
+
"button",
|
|
1284
|
+
{
|
|
1285
|
+
type: "button",
|
|
1286
|
+
onClick: z,
|
|
1287
|
+
disabled: !V,
|
|
1288
|
+
className: `${u.ctaDualRight} ${$e ? u.ctaDualRightAnimating : ""}`,
|
|
1289
|
+
children: /* @__PURE__ */ h("span", { children: a ? "Processing…" : "Checkout" })
|
|
1290
|
+
}
|
|
1291
|
+
)
|
|
1292
|
+
] }),
|
|
1293
|
+
/* @__PURE__ */ O("div", { className: u.poweredBy, children: [
|
|
1292
1294
|
"powered by ",
|
|
1293
1295
|
/* @__PURE__ */ h("a", { href: "https://apps.shopify.com/best-bundles", target: "_blank", rel: "noopener noreferrer", children: " BestBundles" })
|
|
1294
1296
|
] })
|
|
@@ -1298,30 +1300,30 @@ function or(i) {
|
|
|
1298
1300
|
}
|
|
1299
1301
|
) : null;
|
|
1300
1302
|
}
|
|
1301
|
-
function
|
|
1303
|
+
function Ve(i) {
|
|
1302
1304
|
if (i != null && i.length)
|
|
1303
|
-
return i.reduce((
|
|
1305
|
+
return i.reduce((e, t) => (t != null && t.key && (e[t.key] = t.value ?? ""), e), {});
|
|
1304
1306
|
}
|
|
1305
|
-
function
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1307
|
+
function ct(i) {
|
|
1308
|
+
const e = /\/(\d+)$/.exec(i);
|
|
1309
|
+
return e ? e[1] : i;
|
|
1308
1310
|
}
|
|
1309
1311
|
function Jn() {
|
|
1310
1312
|
var i;
|
|
1311
1313
|
return ((i = window == null ? void 0 : window.routes) == null ? void 0 : i.cart_url) || "/cart";
|
|
1312
1314
|
}
|
|
1313
|
-
async function
|
|
1315
|
+
async function er() {
|
|
1314
1316
|
try {
|
|
1315
|
-
const i = Jn(),
|
|
1316
|
-
if (!
|
|
1317
|
-
const
|
|
1318
|
-
if (!
|
|
1319
|
-
const
|
|
1320
|
-
for (const c of
|
|
1321
|
-
const m =
|
|
1317
|
+
const i = Jn(), e = encodeURIComponent("cart-drawer,cart-icon-bubble,cart-live-region-text"), t = await fetch(`${i}?sections=${e}`, { method: "GET" });
|
|
1318
|
+
if (!t.ok) return;
|
|
1319
|
+
const r = await t.json().catch(() => null);
|
|
1320
|
+
if (!r) return;
|
|
1321
|
+
const a = ["cart-drawer", "cart-icon-bubble", "cart-live-region-text"];
|
|
1322
|
+
for (const c of a) {
|
|
1323
|
+
const m = r[c];
|
|
1322
1324
|
if (!m) continue;
|
|
1323
|
-
const w = new DOMParser().parseFromString(m, "text/html"),
|
|
1324
|
-
|
|
1325
|
+
const w = new DOMParser().parseFromString(m, "text/html"), k = w.getElementById(c) || w.querySelector(c), F = document.getElementById(c) || document.querySelector(c);
|
|
1326
|
+
F && k && F.replaceWith(k);
|
|
1325
1327
|
}
|
|
1326
1328
|
const n = document.querySelector("cart-drawer");
|
|
1327
1329
|
if (n && typeof n.open == "function") {
|
|
@@ -1334,46 +1336,54 @@ async function tr() {
|
|
|
1334
1336
|
} catch {
|
|
1335
1337
|
}
|
|
1336
1338
|
}
|
|
1337
|
-
async function
|
|
1338
|
-
const
|
|
1339
|
+
async function De(i, e) {
|
|
1340
|
+
const t = await fetch(i, {
|
|
1339
1341
|
method: "POST",
|
|
1340
1342
|
headers: {
|
|
1341
1343
|
Accept: "application/json",
|
|
1342
1344
|
"Content-Type": "application/json"
|
|
1343
1345
|
},
|
|
1344
|
-
body: JSON.stringify(
|
|
1346
|
+
body: JSON.stringify(e)
|
|
1345
1347
|
});
|
|
1346
|
-
if (!
|
|
1347
|
-
const
|
|
1348
|
-
throw new Error(
|
|
1348
|
+
if (!t.ok) {
|
|
1349
|
+
const r = await t.text().catch(() => "");
|
|
1350
|
+
throw new Error(r || `Cart request failed: ${t.status}`);
|
|
1349
1351
|
}
|
|
1350
|
-
return
|
|
1352
|
+
return t.json().catch(() => null);
|
|
1351
1353
|
}
|
|
1352
1354
|
function sr() {
|
|
1353
1355
|
return {
|
|
1354
1356
|
async linesAdd(i) {
|
|
1355
|
-
const
|
|
1356
|
-
id:
|
|
1357
|
-
quantity:
|
|
1358
|
-
properties:
|
|
1357
|
+
const e = i.map((t) => ({
|
|
1358
|
+
id: ct(t.merchandiseId),
|
|
1359
|
+
quantity: t.quantity,
|
|
1360
|
+
properties: Ve(t.attributes)
|
|
1361
|
+
}));
|
|
1362
|
+
await De("/cart/add.js", { items: e });
|
|
1363
|
+
},
|
|
1364
|
+
async linesAddForCheckout(i) {
|
|
1365
|
+
const e = i.map((t) => ({
|
|
1366
|
+
id: ct(t.merchandiseId),
|
|
1367
|
+
quantity: t.quantity,
|
|
1368
|
+
properties: Ve(t.attributes)
|
|
1359
1369
|
}));
|
|
1360
|
-
await
|
|
1370
|
+
await De("/cart/add.js", { items: e });
|
|
1361
1371
|
},
|
|
1362
1372
|
async linesUpdate(i) {
|
|
1363
|
-
for (const
|
|
1364
|
-
await
|
|
1365
|
-
id:
|
|
1366
|
-
quantity:
|
|
1367
|
-
properties:
|
|
1373
|
+
for (const e of i)
|
|
1374
|
+
await De("/cart/change.js", {
|
|
1375
|
+
id: e.id,
|
|
1376
|
+
quantity: e.quantity,
|
|
1377
|
+
properties: Ve(e.attributes)
|
|
1368
1378
|
});
|
|
1369
1379
|
},
|
|
1370
1380
|
async linesRemove(i) {
|
|
1371
|
-
for (const
|
|
1372
|
-
await
|
|
1381
|
+
for (const e of i)
|
|
1382
|
+
await De("/cart/change.js", { id: e, quantity: 0 });
|
|
1373
1383
|
},
|
|
1374
1384
|
openCartUI() {
|
|
1375
1385
|
window.setTimeout(() => {
|
|
1376
|
-
|
|
1386
|
+
er();
|
|
1377
1387
|
}, 0);
|
|
1378
1388
|
},
|
|
1379
1389
|
navigateToCheckout() {
|
|
@@ -1384,10 +1394,10 @@ function sr() {
|
|
|
1384
1394
|
export {
|
|
1385
1395
|
or as BundleBuilderDrawer,
|
|
1386
1396
|
ir as BundleButton,
|
|
1387
|
-
|
|
1397
|
+
Fe as BundleLineAttributeKeys,
|
|
1388
1398
|
rr as BundleProvider,
|
|
1389
1399
|
sr as createLiquidCartAdapter,
|
|
1390
|
-
|
|
1400
|
+
Qe as useBundleBuilder,
|
|
1391
1401
|
ar as useBundleBuilderDrawer
|
|
1392
1402
|
};
|
|
1393
1403
|
//# sourceMappingURL=index.js.map
|