@lime-bundles/widget 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +249 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +249 -42
- package/dist/index.js.map +1 -1
- package/dist/lime-bundle.global.js +199 -23
- package/dist/lime-bundle.global.js.map +1 -1
- package/docs/web-component.md +19 -0
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var LimeBundles=(()=>{var
|
|
1
|
+
"use strict";var LimeBundles=(()=>{var Y=Object.defineProperty;var He=Object.getOwnPropertyDescriptor;var $e=Object.getOwnPropertyNames;var We=Object.prototype.hasOwnProperty;var qe=(e,t)=>{for(var n in t)Y(e,n,{get:t[n],enumerable:!0})},Ne=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of $e(t))!We.call(e,r)&&r!==n&&Y(e,r,{get:()=>t[r],enumerable:!(i=He(t,r))||i.enumerable});return e};var ze=e=>Ne(Y({},"__esModule",{value:!0}),e);var zt={};qe(zt,{LimeBundleElement:()=>j});var ne=class extends Error{constructor(e){super(e.map(t=>t.message).join("; ")),this.errors=e,this.name="StorefrontApiError"}},je="2025-10";function K(e){let t=e.apiVersion??je,n=`https://${e.shopDomain}/api/${t}/graphql.json`;return{async query(i,r,a){let o={"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":e.accessToken};e.buyerIp&&(o["Shopify-Storefront-Buyer-IP"]=e.buyerIp);let d=await fetch(n,{method:"POST",headers:o,body:JSON.stringify({query:i,variables:r}),signal:a?.signal});if(!d.ok)throw new ne([{message:`Storefront API error: ${d.status} ${d.statusText}`}]);let l=await d.json();if(l.errors?.length)throw new ne(l.errors);return l.data}}}var se=`#graphql
|
|
2
2
|
query BundleMetaobject($id: ID!) {
|
|
3
3
|
metaobject(id: $id) {
|
|
4
4
|
id
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
`,
|
|
85
|
+
`,ce=`#graphql
|
|
86
86
|
query ShopCustomCss {
|
|
87
87
|
shop {
|
|
88
88
|
metafield(namespace: "$app", key: "custom_css") {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
`,
|
|
93
|
+
`,ue=`#graphql
|
|
94
94
|
query BundlesForProduct($handle: String!) {
|
|
95
95
|
product(handle: $handle) {
|
|
96
96
|
id
|
|
@@ -185,42 +185,42 @@
|
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
`,
|
|
188
|
+
`,pe=`#graphql
|
|
189
189
|
mutation CartCreate($input: CartInput!) {
|
|
190
190
|
cartCreate(input: $input) {
|
|
191
191
|
cart { id checkoutUrl }
|
|
192
192
|
userErrors { field message }
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
`,
|
|
195
|
+
`,be=`#graphql
|
|
196
196
|
mutation CartLinesAdd($cartId: ID!, $lines: [CartLineInput!]!) {
|
|
197
197
|
cartLinesAdd(cartId: $cartId, lines: $lines) {
|
|
198
198
|
cart { id checkoutUrl }
|
|
199
199
|
userErrors { field message }
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
|
-
`,D=class extends Error{constructor(e,t){super(e),this.reason=t,this.name="BundleParseError"}},M={header:{textColor:"#FFFFFF",headerStyle:"gradient",gradientStart:"#C62828",gradientEnd:"#AD1457",saveBadgeBgColor:"#FFFFFF",saveBadgeTextColor:"#AD1457",saveBadgeBorderColor:"#FFFFFF",saveBadgeBorderWidth:0,saveBadgeBorderRadius:8,countdownBgColor:"#FFF0F3",countdownTextColor:"#C62828"},layout:{backgroundColor:"#FFFFFF",borderColor:"#E5E5E5",borderWidth:1,borderRadius:12},productList:{textColor:"#1A1A1A",imageBorderWidth:0,imageBorderColor:"#E5E5E5",imageBorderRadius:8,variantBorderWidth:1,variantBorderColor:"#E5E5E5",variantBorderRadius:8,showPrice:!0,showCompareAtPrice:!0,showCountBubble:!0,countBubbleBgColor:"#1A1A1A",countBubbleTextColor:"#FFFFFF"},pricing:{showSaveBadge:!0,showComparePrice:!0,showPerUnitPrice:!0,showItemCount:!0,showCompareAtPrice:!0},cta:{ctaText:"Add to cart",primaryColor:"#1A1A1A",buttonTextColor:"#FFFFFF",borderWidth:0,borderColor:"#1A1A1A",borderRadius:12},savingsBar:{visible:!0,bgColor:"#EDFBF1",textColor:"#2DB554",borderWidth:0,borderColor:"#2DB554",borderRadius:8},countdown:{showCountdown:!0},popularBadge:{visible:!0,text:"Most Popular",bgColor:"#1A1A1A",textColor:"#FFFFFF",borderWidth:0,borderColor:"#1A1A1A",borderRadius:12},outOfStockBehavior:"show_greyed_out",showSearch:!0,pickerBgColor:"#FFFFFF",pickerTextColor:"#1A1A1A",pickerBorderWidth:0,pickerBorderColor:"#E5E5E5",pickerBorderRadius:16,pickerSearchBorderWidth:1,pickerSearchBorderColor:"#E5E5E5",pickerSearchBorderRadius:8,pickerProductBorderWidth:0,pickerProductBorderColor:"#E5E5E5",pickerProductBorderRadius:8,pickerShowCountBubble:!0,pickerCountBubbleBgColor:"#1A1A1A",pickerCountBubbleTextColor:"#FFFFFF",pickerAddBgColor:"#1A1A1A",pickerAddLabelColor:"#FFFFFF",pickerAddBorderWidth:0,pickerAddBorderColor:"#1A1A1A",pickerAddBorderRadius:8,pickerVariantBorderWidth:1,pickerVariantBorderColor:"#1A1A1A",pickerVariantBorderRadius:8,tierBorderColor:"#E5E5E5",tierBorderWidth:1,tierBorderRadius:12,tierSelectedBorderColor:"#1A1A1A",tierSelectedBorderWidth:2,defaultTier:"first"};function qe(e){if(!e||typeof e!="object")return M;let t=e;return{...M,...t,defaultTier:Ne(t.defaultTier),header:{...M.header,...t.header??{}},layout:{...M.layout,...t.layout??{}},productList:{...M.productList,...t.productList??{}},pricing:{...M.pricing,...t.pricing??{}},cta:{...M.cta,...t.cta??{}},savingsBar:{...M.savingsBar,...t.savingsBar??{}},countdown:{...M.countdown,...t.countdown??{}},popularBadge:{...M.popularBadge,...t.popularBadge??{}}}}function Ne(e){return e==="first"||e==="best_value"||typeof e=="number"&&Number.isInteger(e)&&e>=0?e:M.defaultTier}function ze(e){return{primaryColor:e.cta.primaryColor,backgroundColor:e.layout.backgroundColor,textColor:e.productList.textColor,borderColor:e.layout.borderColor,borderWidth:e.layout.borderWidth,buttonTextColor:e.cta.buttonTextColor,ctaBorderWidth:e.cta.borderWidth,ctaBorderColor:e.cta.borderColor,ctaBorderRadius:e.cta.borderRadius,savingsBarBgColor:e.savingsBar.bgColor,savingsBarTextColor:e.savingsBar.textColor,savingsBarBorderWidth:e.savingsBar.borderWidth,savingsBarBorderColor:e.savingsBar.borderColor,savingsBarBorderRadius:e.savingsBar.borderRadius,borderRadius:e.layout.borderRadius,headerTextColor:e.header.textColor,saveBadgeBgColor:e.header.saveBadgeBgColor,saveBadgeTextColor:e.header.saveBadgeTextColor,saveBadgeBorderColor:e.header.saveBadgeBorderColor,saveBadgeBorderWidth:e.header.saveBadgeBorderWidth,saveBadgeBorderRadius:e.header.saveBadgeBorderRadius,countdownBgColor:e.header.countdownBgColor,countdownTextColor:e.header.countdownTextColor,headerStyle:e.header.headerStyle,headerGradientStart:e.header.gradientStart,headerGradientEnd:e.header.gradientEnd,showSaveBadge:e.pricing.showSaveBadge,imageBorderWidth:e.productList.imageBorderWidth,imageBorderColor:e.productList.imageBorderColor,imageBorderRadius:e.productList.imageBorderRadius,variantBorderWidth:e.productList.variantBorderWidth,variantBorderColor:e.productList.variantBorderColor,variantBorderRadius:e.productList.variantBorderRadius,countBubbleBgColor:e.productList.countBubbleBgColor,countBubbleTextColor:e.productList.countBubbleTextColor,showProductPrice:e.productList.showPrice,showProductCompareAtPrice:e.productList.showCompareAtPrice,showCountBubble:e.productList.showCountBubble,showCountdown:e.countdown.showCountdown,ctaText:e.cta.ctaText,outOfStockBehavior:e.outOfStockBehavior,showComparePrice:e.pricing.showComparePrice,showPerUnitPrice:e.pricing.showPerUnitPrice,showItemCount:e.pricing.showItemCount,showCompareAtPrice:e.pricing.showCompareAtPrice,showMostPopular:e.popularBadge.visible,popularBadgeText:e.popularBadge.text,popularBadgeBgColor:e.popularBadge.bgColor,popularBadgeTextColor:e.popularBadge.textColor,popularBadgeBorderWidth:e.popularBadge.borderWidth,popularBadgeBorderColor:e.popularBadge.borderColor,popularBadgeBorderRadius:e.popularBadge.borderRadius,showSearch:e.showSearch,pickerBgColor:e.pickerBgColor,pickerTextColor:e.pickerTextColor,pickerBorderWidth:e.pickerBorderWidth,pickerBorderColor:e.pickerBorderColor,pickerBorderRadius:e.pickerBorderRadius,pickerSearchBorderWidth:e.pickerSearchBorderWidth,pickerSearchBorderColor:e.pickerSearchBorderColor,pickerSearchBorderRadius:e.pickerSearchBorderRadius,pickerProductBorderWidth:e.pickerProductBorderWidth,pickerProductBorderColor:e.pickerProductBorderColor,pickerProductBorderRadius:e.pickerProductBorderRadius,pickerShowCountBubble:e.pickerShowCountBubble,pickerCountBubbleBgColor:e.pickerCountBubbleBgColor,pickerCountBubbleTextColor:e.pickerCountBubbleTextColor,pickerAddBgColor:e.pickerAddBgColor,pickerAddLabelColor:e.pickerAddLabelColor,pickerAddBorderWidth:e.pickerAddBorderWidth,pickerAddBorderColor:e.pickerAddBorderColor,pickerAddBorderRadius:e.pickerAddBorderRadius,pickerVariantBorderWidth:e.pickerVariantBorderWidth,pickerVariantBorderColor:e.pickerVariantBorderColor,pickerVariantBorderRadius:e.pickerVariantBorderRadius,tierBorderColor:e.tierBorderColor,tierBorderWidth:e.tierBorderWidth,tierBorderRadius:e.tierBorderRadius,tierSelectedBorderColor:e.tierSelectedBorderColor,tierSelectedBorderWidth:e.tierSelectedBorderWidth,defaultTier:e.defaultTier,...e.popularBadge.tierIndex!==void 0&&{mostPopularTierIndex:e.popularBadge.tierIndex}}}var je={primaryColor:"--lb-primary-color",backgroundColor:"--lb-bg",textColor:"--lb-text",imageBorderWidth:"--lb-image-border-width",imageBorderColor:"--lb-image-border-color",imageBorderRadius:"--lb-image-border-radius",variantBorderWidth:"--lb-variant-border-width",variantBorderColor:"--lb-variant-border-color",variantBorderRadius:"--lb-variant-radius",countBubbleBgColor:"--lb-qty-badge-bg",countBubbleTextColor:"--lb-qty-badge-color",borderColor:"--lb-border",borderWidth:"--lb-border-width",buttonTextColor:"--lb-btn-text",borderRadius:"--lb-radius",headerTextColor:"--lb-header-text",saveBadgeBgColor:"--lb-save-badge-bg",saveBadgeTextColor:"--lb-save-badge-text",saveBadgeBorderColor:"--lb-save-badge-border-color",saveBadgeBorderWidth:"--lb-save-badge-border-width",saveBadgeBorderRadius:"--lb-save-badge-radius",countdownBgColor:"--lb-countdown-bg",countdownTextColor:"--lb-countdown-text",ctaBorderWidth:"--lb-cta-border-width",ctaBorderColor:"--lb-cta-border-color",ctaBorderRadius:"--lb-cta-radius",savingsBarBgColor:"--lb-savings-bar-bg",savingsBarTextColor:"--lb-savings-bar-text",savingsBarBorderWidth:"--lb-savings-bar-border-width",savingsBarBorderColor:"--lb-savings-bar-border-color",savingsBarBorderRadius:"--lb-savings-bar-radius",tierBorderColor:"--lb-tier-border-color",tierBorderWidth:"--lb-tier-border-width",tierBorderRadius:"--lb-tier-radius",tierSelectedBorderColor:"--lb-tier-selected-border-color",tierSelectedBorderWidth:"--lb-tier-selected-border-width",popularBadgeBgColor:"--lb-popular-badge-bg",popularBadgeTextColor:"--lb-popular-badge-text",popularBadgeBorderWidth:"--lb-popular-badge-border-width",popularBadgeBorderColor:"--lb-popular-badge-border-color",popularBadgeBorderRadius:"--lb-popular-badge-radius",headerGradientStart:"--lb-header-start",headerGradientEnd:"--lb-header-end",pickerBgColor:"--lb-picker-bg",pickerTextColor:"--lb-picker-text",pickerBorderWidth:"--lb-picker-border-width",pickerBorderColor:"--lb-picker-border-color",pickerBorderRadius:"--lb-picker-radius",pickerSearchBorderWidth:"--lb-picker-search-border-width",pickerSearchBorderColor:"--lb-picker-search-border-color",pickerSearchBorderRadius:"--lb-picker-search-radius",pickerProductBorderWidth:"--lb-picker-product-border-width",pickerProductBorderColor:"--lb-picker-product-border-color",pickerProductBorderRadius:"--lb-picker-product-radius",pickerCountBubbleBgColor:"--lb-picker-qty-badge-bg",pickerCountBubbleTextColor:"--lb-picker-qty-badge-color",pickerAddBgColor:"--lb-picker-add-bg",pickerAddLabelColor:"--lb-picker-add-label",pickerAddBorderWidth:"--lb-picker-add-border-width",pickerAddBorderColor:"--lb-picker-add-border-color",pickerAddBorderRadius:"--lb-picker-add-radius",pickerVariantBorderWidth:"--lb-picker-variant-border-width",pickerVariantBorderColor:"--lb-picker-variant-border-color",pickerVariantBorderRadius:"--lb-picker-variant-radius"},Ge=new Set(["borderRadius","borderWidth","saveBadgeBorderWidth","saveBadgeBorderRadius","tierBorderWidth","tierBorderRadius","tierSelectedBorderWidth","savingsBarBorderWidth","savingsBarBorderRadius","ctaBorderWidth","ctaBorderRadius","popularBadgeBorderWidth","popularBadgeBorderRadius","imageBorderWidth","imageBorderRadius","variantBorderWidth","variantBorderRadius","pickerBorderWidth","pickerBorderRadius","pickerSearchBorderWidth","pickerSearchBorderRadius","pickerProductBorderWidth","pickerProductBorderRadius","pickerAddBorderWidth","pickerAddBorderRadius","pickerVariantBorderWidth","pickerVariantBorderRadius"]);function pe(e,t){let n=ze(t);for(let[o,r]of Object.entries(je)){let a=n[o];if(a==null)continue;let i=Ge.has(o)?`${a}px`:String(a);e.style.setProperty(r,i)}e.style.setProperty("--lb-product-price-display",t.productList.showPrice?"block":"none"),e.style.setProperty("--lb-product-compare-display",t.productList.showCompareAtPrice?"inline":"none"),e.style.setProperty("--lb-qty-badge-display",t.productList.showCountBubble?"flex":"none"),e.style.setProperty("--lb-picker-qty-badge-display",t.pickerShowCountBubble?"flex":"none"),t.header.headerStyle==="solid"?e.style.setProperty("--lb-header-bg",t.header.gradientStart):e.style.setProperty("--lb-header-bg",`linear-gradient(135deg, ${t.header.gradientStart}, ${t.header.gradientEnd})`)}var Qe=new Set(["fixed","mix_match","volume"]),Ye=new Set(["active"]);function Y(e,t){try{return Xe(e,t)}catch(n){if(n instanceof D)return null;throw n}}function Xe(e,t){let n=new Map(t.map(f=>[f.key,f])),o=n.get("title")?.value??"Bundle",r=n.get("bundle_type")?.value,a=n.get("status")?.value;if(!r||!Qe.has(r))throw new D(`Invalid or missing bundle_type: ${r??"null"}`,"invalid_type");let i=r;if(!a||!Ye.has(a))throw new D(`Bundle is not active: status=${a??"null"}`,"inactive");let l=a,d=n.get("starts_at")?.value??null,c=n.get("ends_at")?.value??null,u=new Date;if(d){let f=new Date(d);if(Number.isNaN(f.getTime()))throw new D(`Invalid starts_at: ${d}`,"invalid_type");if(f>u)throw new D(`Bundle not yet started: starts_at=${d}`,"not_started")}if(c){let f=new Date(c);if(Number.isNaN(f.getTime()))throw new D(`Invalid ends_at: ${c}`,"invalid_type");if(f<u)throw new D(`Bundle has expired: ends_at=${c}`,"expired")}let p=Ke(n),C=Je(n),b=Ze(n),v={id:e,title:o,description:n.get("description")?.value||null,status:l,products:p,discountConfig:C,widgetConfig:b,startsAt:d,endsAt:c,discountLabel:n.get("discount_label")?.value??null,selectedVariantIds:et(n),productQuantities:re(n,"product_quantities"),variantQuantities:re(n,"variant_quantities"),abTestId:n.get("ab_test_id")?.value??null,abVariantB:tt(n)};switch(i){case"fixed":return{...v,bundleType:"fixed"};case"volume":return{...v,bundleType:"volume",volumeTiers:rt(n)};case"mix_match":return{...v,bundleType:"mix_match",minQuantity:ne(n,"min_quantity",{min:1}),maxQuantity:ne(n,"max_quantity",{min:1})}}}function Ke(e){let t=[],n=e.get("products");if(n?.reference&&"variants"in n.reference&&t.push(n.reference),n?.references?.nodes)for(let r of n.references.nodes)"variants"in r?t.push(r):"products"in r&&r.products?.nodes&&t.push(...r.products.nodes);let o=e.get("collection");if(o?.references?.nodes)for(let r of o.references.nodes)"products"in r&&r.products?.nodes&&t.push(...r.products.nodes);return t}function Je(e){return{discountType:e.get("discount_type")?.value??"percentage",discountValue:parseFloat(e.get("discount_value")?.value??"0"),allowStacking:e.get("allow_stacking")?.value==="true"}}function Ze(e){return qe(W(e,"widget_config"))}function et(e){let t=W(e,"selected_variant_ids");if(!Array.isArray(t))return null;let n=[];for(let o of t)Array.isArray(o)?n.push(o.filter(r=>typeof r=="string")):n.push([]);return n}function re(e,t){let n=W(e,t);if(!n||typeof n!="object"||Array.isArray(n))return{};let o={};for(let[r,a]of Object.entries(n)){let i=typeof a=="number"?a:Number(a);Number.isFinite(i)&&i>=0&&(o[r]=i)}return o}function tt(e){if(!e.get("ab_test_id")?.value)return null;let n={},o=e.get("ab_title")?.value;o&&(n.title=o);let r=e.get("ab_description")?.value;r&&(n.description=r);let a=e.get("ab_discount_type")?.value,i=e.get("ab_discount_value")?.value;if(a&&(a==="percentage"||a==="fixed_amount")&&i){let d=parseFloat(i);Number.isFinite(d)&&(n.discountConfig={discountType:a,discountValue:d,allowStacking:e.get("allow_stacking")?.value==="true"})}let l=W(e,"ab_volume_tiers");return Array.isArray(l)&&(n.volumeTiers=l.filter(d=>typeof d=="object"&&d!==null).map(d=>({minQuantity:Number(d.minQuantity??0),discountType:d.discountType??"percentage",discountValue:Number(d.discountValue??0),label:d.label??null}))),Object.keys(n).length===0?null:n}function rt(e){let t=W(e,"volume_tiers");return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null).map(n=>({minQuantity:Number(n.minQuantity??0),discountType:n.discountType??"percentage",discountValue:Number(n.discountValue??0),label:n.label??null})):[]}function W(e,t){let n=e.get(t)?.value;if(!n)return null;try{return JSON.parse(n)}catch{return null}}function ne(e,t,n={}){let o=e.get(t)?.value;if(!o)return null;let r=parseInt(o,10);return isNaN(r)||n.min!==void 0&&r<n.min?null:r}function be(e){let t=e.abVariantB;if(!t)return e;let n=t.title??e.title,o=t.description!==void 0?t.description:e.description,r=t.discountConfig??e.discountConfig;switch(e.bundleType){case"volume":return{...e,title:n,description:o,discountConfig:r,volumeTiers:t.volumeTiers??e.volumeTiers};case"mix_match":return{...e,title:n,description:o,discountConfig:r};case"fixed":return{...e,title:n,description:o,discountConfig:r}}}async function he(e,t){await fe(e,{shopDomain:e.shopDomain,eventType:"bundle_impression",bundleGid:t.bundleGid,bundleType:t.bundleType,productId:t.productId,abTestId:t.abTestId,abVariant:t.abVariant,occurredAt:new Date().toISOString()})}async function me(e,t){await fe(e,{shopDomain:e.shopDomain,eventType:"bundle_add_to_cart",...t,occurredAt:new Date().toISOString()})}function ge(e,t){if(typeof IntersectionObserver>"u")return t(),()=>{};let n=new IntersectionObserver(o=>{for(let r of o)r.isIntersecting&&(t(),n.unobserve(r.target))},{threshold:.5});return n.observe(e),()=>n.disconnect()}async function fe(e,t){let n=`${e.appUrl}/api/analytics`,o=JSON.stringify(t);try{(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:o})).ok||(await new Promise(a=>setTimeout(a,2e3)),await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:o}))}catch{try{typeof navigator<"u"&&navigator.sendBeacon&&navigator.sendBeacon(n,o)}catch{}}}var nt=!1;function ot(){if(nt)return!0;if(typeof window>"u")return!1;let e=window.Shopify;try{return e?.customerPrivacy?.analyticsProcessingAllowed?.()===!0}catch{return!1}}var oe="lb_session",it=720*60*60,at=720*60*60;function ve(e){return`__Host-_lb_ab_${e}`}async function xe(e,t,n,o){if(typeof document>"u")return null;let r=dt(o);if(r&&r.testId===n)return{variant:r.variant,testId:n,persisted:!0};if(!ot())return{variant:"A",testId:n,persisted:!1};let a=st(),i=ct(a,n);lt(o,n,i);try{fetch(`${e}/api/ab-assign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({shopDomain:t,testId:n,sessionId:a,variant:i})}).catch(()=>{})}catch{}return{variant:i,testId:n,persisted:!0}}function dt(e){if(typeof document>"u")return null;let n=`${ve(e)}=`,r=document.cookie.split(";").map(d=>d.trim()).find(d=>d.startsWith(n));if(!r)return null;let a=r.substring(n.length),[i,l]=a.split("|");return i!=="A"&&i!=="B"||!l?null:{testId:l,variant:i}}function lt(e,t,n){if(typeof document>"u")return;let o=ve(e),r=`${n}|${t}|${Date.now()}`;document.cookie=`${o}=${r}; Path=/; Max-Age=${at}; SameSite=Lax; Secure`}function st(){if(typeof document>"u")return ie();let t=document.cookie.split(";").map(o=>o.trim()).find(o=>o.startsWith(`${oe}=`))?.split("=")[1];if(t)return t;let n=ie();return document.cookie=`${oe}=${n}; path=/; max-age=${it}; SameSite=Lax; Secure`,n}function ie(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function ct(e,t){let n=e+":"+t,o=2166136261;for(let r=0;r<n.length;r++)o^=n.charCodeAt(r),o=Math.imul(o,16777619);return(o>>>0)%2===0?"A":"B"}var ae=1e4,ut=[[/@import/i,"@import rules"],[/@charset/i,"@charset declarations"],[/expression\s*\(/i,"CSS expressions"],[/-moz-binding/i,"-moz-binding"],[/-webkit-binding/i,"-webkit-binding"],[/behavior\s*:/i,"behavior property"]],pt=/^(https:|\/[^/]|\.\/|\.\.\/|#)/;function X(e){if(e.length>ae)return{ok:!1,error:`CSS exceeds ${ae.toLocaleString("en-US")} character limit`};let t=e.replace(/\/\*[\s\S]*?\*\//g,"");try{t=t.replace(/\\([0-9a-fA-F]{1,6})[ \t\n\f]?/g,(r,a)=>{let i=parseInt(a,16);return i<0||i>1114111?"\uFFFD":String.fromCodePoint(i)}),t=t.replace(/\\\r?\n/g,""),t=t.replace(/\\([^\n\r\f0-9a-fA-F])/g,"$1")}catch{return{ok:!1,error:"CSS contains invalid unicode escape sequences"}}t=t.replace(/</g,"").replace(/>/g,"");for(let[r,a]of ut)if(r.test(t))return{ok:!1,error:`CSS contains blocked pattern: ${a}`};let n=/url\s*\(\s*([\s\S]*?)\s*\)/gi,o;for(;(o=n.exec(t))!==null;){let r=o[1].trim();if((r.startsWith("'")||r.startsWith('"'))&&(r=r.slice(1)),(r.endsWith("'")||r.endsWith('"'))&&(r=r.slice(0,-1)),r=r.trim(),r&&!pt.test(r))return{ok:!1,error:"CSS url() values must use https:// or relative paths"}}return{ok:!0,css:t}}var bt="lb-custom-css-";function Ce(e,t){if(typeof document>"u"||!t)return!1;let n=X(t);if(!n.ok||!n.css.trim())return!1;let o=bt+ht(e),r=document.getElementById(o);return r||(r=document.createElement("style"),r.id=o,r.setAttribute("data-lime-bundles","custom-css"),document.head.appendChild(r)),r.textContent!==n.css&&(r.textContent=n.css),!0}function ht(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function R(e){if(e==null)return 0;let t=typeof e=="string"?parseFloat(e):e;return Number.isFinite(t)?Math.round(t*100):0}function k(e,t){try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e/100)}catch{return`${t} ${(e/100).toFixed(2)}`}}function ye(e,t){return Math.max(0,e-Math.floor(e*t/100))}function K(e,t=e.productQuantities,n=e.widgetConfig.pricing.showSaveBadge){let{discountType:o,discountValue:r}=e.discountConfig,a=[],i=0,l=0;for(let p of e.products){let C=p.variants.nodes.find(w=>w.availableForSale)??p.variants.nodes[0];if(!C)continue;let b=R(C.price.amount),v=t[p.id]??1,f=b*v,S=C.compareAtPrice?R(C.compareAtPrice.amount):null;if(a.push({unitCents:b,qty:v,lineCents:f,compareCents:S}),i+=f,o==="percentage"){let w=ye(b,r);l+=w*v}else l+=f}o==="fixed_amount"&&(l=Math.max(0,i-Math.round(r*100)));let d=Math.max(0,i-l),c=e.products[0]?.priceRange.minVariantPrice.currencyCode??"USD",u="";return n&&d>0&&(o==="percentage"&&r>0?u=`-${Math.round(r)}%`:o==="fixed_amount"&&r>0&&(u=`-${k(Math.round(r*100),c)}`)),{rows:a,totalCents:i,saleCents:l,savingsCents:d,headerBadge:u,currency:c}}function z(e,t){if(t.discountType==="percentage"){let n=Math.floor(e*t.discountValue/100);return Math.max(0,e-n)}return Math.max(0,e-Math.round(t.discountValue*100))}var P=152;function U(e,t={}){if(!e)return"";try{let n=new URL(e);return t.width!==void 0&&n.searchParams.set("width",String(t.width)),t.height!==void 0&&n.searchParams.set("height",String(t.height)),t.crop&&n.searchParams.set("crop",t.crop),n.toString()}catch{return e}}function we(e){if(!Number.isFinite(e)||e<=0)return"";let t=Math.floor(e/1e3),n=Math.floor(t/86400),o=Math.floor(t%86400/3600),r=Math.floor(t%3600/60),a=t%60,i=l=>String(l).padStart(2,"0");return n>0?`${n}d ${i(o)}h ${i(r)}m ${i(a)}s`:`${i(o)}h ${i(r)}m ${i(a)}s`}function O(e){let t=mt(e);if(t===null||t<=Date.now())return null;let n=t,o=document.createElement("div");o.className="lb-bundle-countdown",o.setAttribute("data-countdown","");let r=document.createElement("div");r.className="lb-bundle-countdown__label";let a=document.createElement("span");a.textContent="Ends in",r.appendChild(a),o.appendChild(r);let i=document.createElement("span");i.className="lb-bundle-countdown__timer",i.setAttribute("data-countdown-timer",""),o.appendChild(i);let l=null;function d(){let u=n-Date.now();if(u<=0){o.style.display="none",c();return}i.textContent=we(u)}function c(){l!==null&&(clearInterval(l),l=null)}return d(),l=setInterval(d,1e3),{el:o,stop:c}}function mt(e){let t=Date.parse(e);return Number.isFinite(t)?t:null}function s(e,t,n={}){let o=document.createElement(e);t&&(o.className=t);for(let[r,a]of Object.entries(n))o.setAttribute(r,a);return o}var gt=`
|
|
202
|
+
`,U=class extends Error{constructor(e,t){super(e),this.reason=t,this.name="BundleParseError"}},D={header:{textColor:"#FFFFFF",headerStyle:"gradient",gradientStart:"#C62828",gradientEnd:"#AD1457",saveBadgeBgColor:"#FFFFFF",saveBadgeTextColor:"#AD1457",saveBadgeBorderColor:"#FFFFFF",saveBadgeBorderWidth:0,saveBadgeBorderRadius:8,countdownBgColor:"#FFF0F3",countdownTextColor:"#C62828"},layout:{backgroundColor:"#FFFFFF",borderColor:"#E5E5E5",borderWidth:1,borderRadius:12},productList:{textColor:"#1A1A1A",imageBorderWidth:0,imageBorderColor:"#E5E5E5",imageBorderRadius:8,variantBorderWidth:1,variantBorderColor:"#E5E5E5",variantBorderRadius:8,showPrice:!0,showCompareAtPrice:!0,showCountBubble:!0,countBubbleBgColor:"#1A1A1A",countBubbleTextColor:"#FFFFFF"},pricing:{showSaveBadge:!0,showComparePrice:!0,showPerUnitPrice:!0,showItemCount:!0,showCompareAtPrice:!0},cta:{ctaText:"Add to cart",primaryColor:"#1A1A1A",buttonTextColor:"#FFFFFF",borderWidth:0,borderColor:"#1A1A1A",borderRadius:12},savingsBar:{visible:!0,bgColor:"#EDFBF1",textColor:"#2DB554",borderWidth:0,borderColor:"#2DB554",borderRadius:8},countdown:{showCountdown:!0},popularBadge:{visible:!0,text:"Most Popular",bgColor:"#1A1A1A",textColor:"#FFFFFF",borderWidth:0,borderColor:"#1A1A1A",borderRadius:12},outOfStockBehavior:"show_greyed_out",showSearch:!0,pickerBgColor:"#FFFFFF",pickerTextColor:"#1A1A1A",pickerBorderWidth:0,pickerBorderColor:"#E5E5E5",pickerBorderRadius:16,pickerSearchBorderWidth:1,pickerSearchBorderColor:"#E5E5E5",pickerSearchBorderRadius:8,pickerProductBorderWidth:0,pickerProductBorderColor:"#E5E5E5",pickerProductBorderRadius:8,pickerShowCountBubble:!0,pickerCountBubbleBgColor:"#1A1A1A",pickerCountBubbleTextColor:"#FFFFFF",pickerAddBgColor:"#1A1A1A",pickerAddLabelColor:"#FFFFFF",pickerAddBorderWidth:0,pickerAddBorderColor:"#1A1A1A",pickerAddBorderRadius:8,pickerVariantBorderWidth:1,pickerVariantBorderColor:"#1A1A1A",pickerVariantBorderRadius:8,tierBorderColor:"#E5E5E5",tierBorderWidth:1,tierBorderRadius:12,tierSelectedBorderColor:"#1A1A1A",tierSelectedBorderWidth:2,defaultTier:"first"};function Ge(e){if(!e||typeof e!="object")return D;let t=e;return{...D,...t,defaultTier:Qe(t.defaultTier),header:{...D.header,...t.header??{}},layout:{...D.layout,...t.layout??{}},productList:{...D.productList,...t.productList??{}},pricing:{...D.pricing,...t.pricing??{}},cta:{...D.cta,...t.cta??{}},savingsBar:{...D.savingsBar,...t.savingsBar??{}},countdown:{...D.countdown,...t.countdown??{}},popularBadge:{...D.popularBadge,...t.popularBadge??{}}}}function Qe(e){return e==="first"||e==="best_value"||typeof e=="number"&&Number.isInteger(e)&&e>=0?e:D.defaultTier}function Ye(e){return{primaryColor:e.cta.primaryColor,backgroundColor:e.layout.backgroundColor,textColor:e.productList.textColor,borderColor:e.layout.borderColor,borderWidth:e.layout.borderWidth,buttonTextColor:e.cta.buttonTextColor,ctaBorderWidth:e.cta.borderWidth,ctaBorderColor:e.cta.borderColor,ctaBorderRadius:e.cta.borderRadius,savingsBarBgColor:e.savingsBar.bgColor,savingsBarTextColor:e.savingsBar.textColor,savingsBarBorderWidth:e.savingsBar.borderWidth,savingsBarBorderColor:e.savingsBar.borderColor,savingsBarBorderRadius:e.savingsBar.borderRadius,borderRadius:e.layout.borderRadius,headerTextColor:e.header.textColor,saveBadgeBgColor:e.header.saveBadgeBgColor,saveBadgeTextColor:e.header.saveBadgeTextColor,saveBadgeBorderColor:e.header.saveBadgeBorderColor,saveBadgeBorderWidth:e.header.saveBadgeBorderWidth,saveBadgeBorderRadius:e.header.saveBadgeBorderRadius,countdownBgColor:e.header.countdownBgColor,countdownTextColor:e.header.countdownTextColor,headerStyle:e.header.headerStyle,headerGradientStart:e.header.gradientStart,headerGradientEnd:e.header.gradientEnd,showSaveBadge:e.pricing.showSaveBadge,imageBorderWidth:e.productList.imageBorderWidth,imageBorderColor:e.productList.imageBorderColor,imageBorderRadius:e.productList.imageBorderRadius,variantBorderWidth:e.productList.variantBorderWidth,variantBorderColor:e.productList.variantBorderColor,variantBorderRadius:e.productList.variantBorderRadius,countBubbleBgColor:e.productList.countBubbleBgColor,countBubbleTextColor:e.productList.countBubbleTextColor,showProductPrice:e.productList.showPrice,showProductCompareAtPrice:e.productList.showCompareAtPrice,showCountBubble:e.productList.showCountBubble,showCountdown:e.countdown.showCountdown,ctaText:e.cta.ctaText,outOfStockBehavior:e.outOfStockBehavior,showComparePrice:e.pricing.showComparePrice,showPerUnitPrice:e.pricing.showPerUnitPrice,showItemCount:e.pricing.showItemCount,showCompareAtPrice:e.pricing.showCompareAtPrice,showMostPopular:e.popularBadge.visible,popularBadgeText:e.popularBadge.text,popularBadgeBgColor:e.popularBadge.bgColor,popularBadgeTextColor:e.popularBadge.textColor,popularBadgeBorderWidth:e.popularBadge.borderWidth,popularBadgeBorderColor:e.popularBadge.borderColor,popularBadgeBorderRadius:e.popularBadge.borderRadius,showSearch:e.showSearch,pickerBgColor:e.pickerBgColor,pickerTextColor:e.pickerTextColor,pickerBorderWidth:e.pickerBorderWidth,pickerBorderColor:e.pickerBorderColor,pickerBorderRadius:e.pickerBorderRadius,pickerSearchBorderWidth:e.pickerSearchBorderWidth,pickerSearchBorderColor:e.pickerSearchBorderColor,pickerSearchBorderRadius:e.pickerSearchBorderRadius,pickerProductBorderWidth:e.pickerProductBorderWidth,pickerProductBorderColor:e.pickerProductBorderColor,pickerProductBorderRadius:e.pickerProductBorderRadius,pickerShowCountBubble:e.pickerShowCountBubble,pickerCountBubbleBgColor:e.pickerCountBubbleBgColor,pickerCountBubbleTextColor:e.pickerCountBubbleTextColor,pickerAddBgColor:e.pickerAddBgColor,pickerAddLabelColor:e.pickerAddLabelColor,pickerAddBorderWidth:e.pickerAddBorderWidth,pickerAddBorderColor:e.pickerAddBorderColor,pickerAddBorderRadius:e.pickerAddBorderRadius,pickerVariantBorderWidth:e.pickerVariantBorderWidth,pickerVariantBorderColor:e.pickerVariantBorderColor,pickerVariantBorderRadius:e.pickerVariantBorderRadius,tierBorderColor:e.tierBorderColor,tierBorderWidth:e.tierBorderWidth,tierBorderRadius:e.tierBorderRadius,tierSelectedBorderColor:e.tierSelectedBorderColor,tierSelectedBorderWidth:e.tierSelectedBorderWidth,defaultTier:e.defaultTier,...e.popularBadge.tierIndex!==void 0&&{mostPopularTierIndex:e.popularBadge.tierIndex}}}var Ke={primaryColor:"--lb-primary-color",backgroundColor:"--lb-bg",textColor:"--lb-text",imageBorderWidth:"--lb-image-border-width",imageBorderColor:"--lb-image-border-color",imageBorderRadius:"--lb-image-border-radius",variantBorderWidth:"--lb-variant-border-width",variantBorderColor:"--lb-variant-border-color",variantBorderRadius:"--lb-variant-radius",countBubbleBgColor:"--lb-qty-badge-bg",countBubbleTextColor:"--lb-qty-badge-color",borderColor:"--lb-border",borderWidth:"--lb-border-width",buttonTextColor:"--lb-btn-text",borderRadius:"--lb-radius",headerTextColor:"--lb-header-text",saveBadgeBgColor:"--lb-save-badge-bg",saveBadgeTextColor:"--lb-save-badge-text",saveBadgeBorderColor:"--lb-save-badge-border-color",saveBadgeBorderWidth:"--lb-save-badge-border-width",saveBadgeBorderRadius:"--lb-save-badge-radius",countdownBgColor:"--lb-countdown-bg",countdownTextColor:"--lb-countdown-text",ctaBorderWidth:"--lb-cta-border-width",ctaBorderColor:"--lb-cta-border-color",ctaBorderRadius:"--lb-cta-radius",savingsBarBgColor:"--lb-savings-bar-bg",savingsBarTextColor:"--lb-savings-bar-text",savingsBarBorderWidth:"--lb-savings-bar-border-width",savingsBarBorderColor:"--lb-savings-bar-border-color",savingsBarBorderRadius:"--lb-savings-bar-radius",tierBorderColor:"--lb-tier-border-color",tierBorderWidth:"--lb-tier-border-width",tierBorderRadius:"--lb-tier-radius",tierSelectedBorderColor:"--lb-tier-selected-border-color",tierSelectedBorderWidth:"--lb-tier-selected-border-width",popularBadgeBgColor:"--lb-popular-badge-bg",popularBadgeTextColor:"--lb-popular-badge-text",popularBadgeBorderWidth:"--lb-popular-badge-border-width",popularBadgeBorderColor:"--lb-popular-badge-border-color",popularBadgeBorderRadius:"--lb-popular-badge-radius",headerGradientStart:"--lb-header-start",headerGradientEnd:"--lb-header-end",pickerBgColor:"--lb-picker-bg",pickerTextColor:"--lb-picker-text",pickerBorderWidth:"--lb-picker-border-width",pickerBorderColor:"--lb-picker-border-color",pickerBorderRadius:"--lb-picker-radius",pickerSearchBorderWidth:"--lb-picker-search-border-width",pickerSearchBorderColor:"--lb-picker-search-border-color",pickerSearchBorderRadius:"--lb-picker-search-radius",pickerProductBorderWidth:"--lb-picker-product-border-width",pickerProductBorderColor:"--lb-picker-product-border-color",pickerProductBorderRadius:"--lb-picker-product-radius",pickerCountBubbleBgColor:"--lb-picker-qty-badge-bg",pickerCountBubbleTextColor:"--lb-picker-qty-badge-color",pickerAddBgColor:"--lb-picker-add-bg",pickerAddLabelColor:"--lb-picker-add-label",pickerAddBorderWidth:"--lb-picker-add-border-width",pickerAddBorderColor:"--lb-picker-add-border-color",pickerAddBorderRadius:"--lb-picker-add-radius",pickerVariantBorderWidth:"--lb-picker-variant-border-width",pickerVariantBorderColor:"--lb-picker-variant-border-color",pickerVariantBorderRadius:"--lb-picker-variant-radius"},Xe=new Set(["borderRadius","borderWidth","saveBadgeBorderWidth","saveBadgeBorderRadius","tierBorderWidth","tierBorderRadius","tierSelectedBorderWidth","savingsBarBorderWidth","savingsBarBorderRadius","ctaBorderWidth","ctaBorderRadius","popularBadgeBorderWidth","popularBadgeBorderRadius","imageBorderWidth","imageBorderRadius","variantBorderWidth","variantBorderRadius","pickerBorderWidth","pickerBorderRadius","pickerSearchBorderWidth","pickerSearchBorderRadius","pickerProductBorderWidth","pickerProductBorderRadius","pickerAddBorderWidth","pickerAddBorderRadius","pickerVariantBorderWidth","pickerVariantBorderRadius"]);function he(e,t){let n=Ye(t);for(let[i,r]of Object.entries(Ke)){let a=n[i];if(a==null)continue;let o=Xe.has(i)?`${a}px`:String(a);e.style.setProperty(r,o)}e.style.setProperty("--lb-product-price-display",t.productList.showPrice?"block":"none"),e.style.setProperty("--lb-product-compare-display",t.productList.showCompareAtPrice?"inline":"none"),e.style.setProperty("--lb-qty-badge-display",t.productList.showCountBubble?"flex":"none"),e.style.setProperty("--lb-picker-qty-badge-display",t.pickerShowCountBubble?"flex":"none"),t.header.headerStyle==="solid"?e.style.setProperty("--lb-header-bg",t.header.gradientStart):e.style.setProperty("--lb-header-bg",`linear-gradient(135deg, ${t.header.gradientStart}, ${t.header.gradientEnd})`)}var Je=new Set(["fixed","mix_match","volume"]),Ze=new Set(["active"]);function X(e,t){try{return et(e,t)}catch(n){if(n instanceof U)return null;throw n}}function et(e,t){let n=new Map(t.map(v=>[v.key,v])),i=n.get("title")?.value??"Bundle",r=n.get("bundle_type")?.value,a=n.get("status")?.value;if(!r||!Je.has(r))throw new U(`Invalid or missing bundle_type: ${r??"null"}`,"invalid_type");let o=r;if(!a||!Ze.has(a))throw new U(`Bundle is not active: status=${a??"null"}`,"inactive");let d=a,l=n.get("starts_at")?.value??null,u=n.get("ends_at")?.value??null,c=new Date;if(l){let v=new Date(l);if(Number.isNaN(v.getTime()))throw new U(`Invalid starts_at: ${l}`,"invalid_type");if(v>c)throw new U(`Bundle not yet started: starts_at=${l}`,"not_started")}if(u){let v=new Date(u);if(Number.isNaN(v.getTime()))throw new U(`Invalid ends_at: ${u}`,"invalid_type");if(v<c)throw new U(`Bundle has expired: ends_at=${u}`,"expired")}let p=tt(n),f=rt(n),h=nt(n),m={id:e,title:i,description:n.get("description")?.value||null,status:d,products:p,discountConfig:f,widgetConfig:h,startsAt:l,endsAt:u,discountLabel:n.get("discount_label")?.value??null,selectedVariantIds:it(n),productQuantities:ie(n,"product_quantities"),variantQuantities:ie(n,"variant_quantities"),abTestId:n.get("ab_test_id")?.value??null,abVariantB:ot(n)};switch(o){case"fixed":return{...m,bundleType:"fixed"};case"volume":return{...m,bundleType:"volume",volumeTiers:at(n)};case"mix_match":return{...m,bundleType:"mix_match",minQuantity:oe(n,"min_quantity",{min:1}),maxQuantity:oe(n,"max_quantity",{min:1})}}}function tt(e){let t=[],n=e.get("products");if(n?.reference&&"variants"in n.reference&&t.push(n.reference),n?.references?.nodes)for(let r of n.references.nodes)"variants"in r?t.push(r):"products"in r&&r.products?.nodes&&t.push(...r.products.nodes);let i=e.get("collection");if(i?.references?.nodes)for(let r of i.references.nodes)"products"in r&&r.products?.nodes&&t.push(...r.products.nodes);return t}function rt(e){return{discountType:e.get("discount_type")?.value??"percentage",discountValue:parseFloat(e.get("discount_value")?.value??"0"),allowStacking:e.get("allow_stacking")?.value==="true"}}function nt(e){return Ge(z(e,"widget_config"))}function it(e){let t=z(e,"selected_variant_ids");if(!Array.isArray(t))return null;let n=[];for(let i of t)Array.isArray(i)?n.push(i.filter(r=>typeof r=="string")):n.push([]);return n}function ie(e,t){let n=z(e,t);if(!n||typeof n!="object"||Array.isArray(n))return{};let i={};for(let[r,a]of Object.entries(n)){let o=typeof a=="number"?a:Number(a);Number.isFinite(o)&&o>=0&&(i[r]=o)}return i}function ot(e){if(!e.get("ab_test_id")?.value)return null;let n={},i=e.get("ab_title")?.value;i&&(n.title=i);let r=e.get("ab_description")?.value;r&&(n.description=r);let a=e.get("ab_discount_type")?.value,o=e.get("ab_discount_value")?.value;if(a&&(a==="percentage"||a==="fixed_amount")&&o){let l=parseFloat(o);Number.isFinite(l)&&(n.discountConfig={discountType:a,discountValue:l,allowStacking:e.get("allow_stacking")?.value==="true"})}let d=z(e,"ab_volume_tiers");return Array.isArray(d)&&(n.volumeTiers=d.filter(l=>typeof l=="object"&&l!==null).map(me)),Object.keys(n).length===0?null:n}function at(e){let t=z(e,"volume_tiers");return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null).map(me):[]}function me(e){let t=Number(e.minQuantity??0),n={minQuantity:Number.isFinite(t)&&t>=0?t:0};return typeof e.percentage=="number"&&Number.isFinite(e.percentage)&&(n.percentage=e.percentage),typeof e.amount=="number"&&Number.isFinite(e.amount)&&(n.amount=e.amount),n}function z(e,t){let n=e.get(t)?.value;if(!n)return null;try{return JSON.parse(n)}catch{return null}}function oe(e,t,n={}){let i=e.get(t)?.value;if(!i)return null;let r=parseInt(i,10);return isNaN(r)||n.min!==void 0&&r<n.min?null:r}function ge(e){let t=e.abVariantB;if(!t)return e;let n=t.title??e.title,i=t.description!==void 0?t.description:e.description,r=t.discountConfig??e.discountConfig;switch(e.bundleType){case"volume":return{...e,title:n,description:i,discountConfig:r,volumeTiers:t.volumeTiers??e.volumeTiers};case"mix_match":return{...e,title:n,description:i,discountConfig:r};case"fixed":return{...e,title:n,description:i,discountConfig:r}}}async function fe(e,t){await Ce(e,{shopDomain:e.shopDomain,eventType:"bundle_impression",bundleGid:t.bundleGid,bundleType:t.bundleType,productId:t.productId,abTestId:t.abTestId,abVariant:t.abVariant,occurredAt:new Date().toISOString()})}async function ve(e,t){await Ce(e,{shopDomain:e.shopDomain,eventType:"bundle_add_to_cart",...t,occurredAt:new Date().toISOString()})}function xe(e,t){if(typeof IntersectionObserver>"u")return t(),()=>{};let n=new IntersectionObserver(i=>{for(let r of i)r.isIntersecting&&(t(),n.unobserve(r.target))},{threshold:.5});return n.observe(e),()=>n.disconnect()}async function Ce(e,t){let n=`${e.appUrl}/api/analytics`,i=JSON.stringify(t);try{(await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:i})).ok||(await new Promise(a=>setTimeout(a,2e3)),await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:i}))}catch{try{typeof navigator<"u"&&navigator.sendBeacon&&navigator.sendBeacon(n,i)}catch{}}}var lt=!1;function dt(){if(lt)return!0;if(typeof window>"u")return!1;let e=window.Shopify;try{return e?.customerPrivacy?.analyticsProcessingAllowed?.()===!0}catch{return!1}}var ae="lb_session",st=720*60*60,ct=720*60*60;function ye(e){return`__Host-_lb_ab_${e}`}async function we(e,t,n,i){if(typeof document>"u")return null;let r=ut(i);if(r&&r.testId===n)return{variant:r.variant,testId:n,persisted:!0};if(!dt())return{variant:"A",testId:n,persisted:!1};let a=bt(),o=ht(a,n);pt(i,n,o);try{fetch(`${e}/api/ab-assign`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({shopDomain:t,testId:n,sessionId:a,variant:o})}).catch(()=>{})}catch{}return{variant:o,testId:n,persisted:!0}}function ut(e){if(typeof document>"u")return null;let n=`${ye(e)}=`,r=document.cookie.split(";").map(l=>l.trim()).find(l=>l.startsWith(n));if(!r)return null;let a=r.substring(n.length),[o,d]=a.split("|");return o!=="A"&&o!=="B"||!d?null:{testId:d,variant:o}}function pt(e,t,n){if(typeof document>"u")return;let i=ye(e),r=`${n}|${t}|${Date.now()}`;document.cookie=`${i}=${r}; Path=/; Max-Age=${ct}; SameSite=Lax; Secure`}function bt(){if(typeof document>"u")return le();let t=document.cookie.split(";").map(i=>i.trim()).find(i=>i.startsWith(`${ae}=`))?.split("=")[1];if(t)return t;let n=le();return document.cookie=`${ae}=${n}; path=/; max-age=${st}; SameSite=Lax; Secure`,n}function le(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function ht(e,t){let n=e+":"+t,i=2166136261;for(let r=0;r<n.length;r++)i^=n.charCodeAt(r),i=Math.imul(i,16777619);return(i>>>0)%2===0?"A":"B"}var de=1e4,mt=[[/@import/i,"@import rules"],[/@charset/i,"@charset declarations"],[/expression\s*\(/i,"CSS expressions"],[/-moz-binding/i,"-moz-binding"],[/-webkit-binding/i,"-webkit-binding"],[/behavior\s*:/i,"behavior property"]],gt=/^(https:|\/[^/]|\.\/|\.\.\/|#)/;function J(e){if(e.length>de)return{ok:!1,error:`CSS exceeds ${de.toLocaleString("en-US")} character limit`};let t=e.replace(/\/\*[\s\S]*?\*\//g,"");try{t=t.replace(/\\([0-9a-fA-F]{1,6})[ \t\n\f]?/g,(r,a)=>{let o=parseInt(a,16);return o<0||o>1114111?"\uFFFD":String.fromCodePoint(o)}),t=t.replace(/\\\r?\n/g,""),t=t.replace(/\\([^\n\r\f0-9a-fA-F])/g,"$1")}catch{return{ok:!1,error:"CSS contains invalid unicode escape sequences"}}t=t.replace(/</g,"").replace(/>/g,"");for(let[r,a]of mt)if(r.test(t))return{ok:!1,error:`CSS contains blocked pattern: ${a}`};let n=/url\s*\(\s*([\s\S]*?)\s*\)/gi,i;for(;(i=n.exec(t))!==null;){let r=i[1].trim();if((r.startsWith("'")||r.startsWith('"'))&&(r=r.slice(1)),(r.endsWith("'")||r.endsWith('"'))&&(r=r.slice(0,-1)),r=r.trim(),r&&!gt.test(r))return{ok:!1,error:"CSS url() values must use https:// or relative paths"}}return{ok:!0,css:t}}var ft="lb-custom-css-";function _e(e,t){if(typeof document>"u"||!t)return!1;let n=J(t);if(!n.ok||!n.css.trim())return!1;let i=ft+vt(e),r=document.getElementById(i);return r||(r=document.createElement("style"),r.id=i,r.setAttribute("data-lime-bundles","custom-css"),document.head.appendChild(r)),r.textContent!==n.css&&(r.textContent=n.css),!0}function vt(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}function P(e){if(e==null)return 0;let t=typeof e=="string"?parseFloat(e):e;return Number.isFinite(t)?Math.round(t*100):0}function _(e,t){try{return new Intl.NumberFormat(void 0,{style:"currency",currency:t}).format(e/100)}catch{return`${t} ${(e/100).toFixed(2)}`}}function Be(e,t){return Math.max(0,e-Math.floor(e*t/100))}function Z(e,t=e.productQuantities,n=e.widgetConfig.pricing.showSaveBadge){let{discountType:i,discountValue:r}=e.discountConfig,a=[],o=0,d=0;for(let p of e.products){let f=p.variants.nodes.find(C=>C.availableForSale)??p.variants.nodes[0];if(!f)continue;let h=P(f.price.amount),m=t[p.id]??1,v=h*m,A=f.compareAtPrice?P(f.compareAtPrice.amount):null;if(a.push({unitCents:h,qty:m,lineCents:v,compareCents:A}),o+=v,i==="percentage"){let C=Be(h,r);d+=C*m}else d+=v}i==="fixed_amount"&&(d=Math.max(0,o-Math.round(r*100)));let l=Math.max(0,o-d),u=e.products[0]?.priceRange.minVariantPrice.currencyCode??"USD",c="";return n&&l>0&&(i==="percentage"&&r>0?c=`-${Math.round(r)}%`:i==="fixed_amount"&&r>0&&(c=`-${_(Math.round(r*100),u)}`)),{rows:a,totalCents:o,saleCents:d,savingsCents:l,headerBadge:c,currency:u}}function Q(e,t){if(t.discountType==="percentage"){let n=Math.floor(e*t.discountValue/100);return Math.max(0,e-n)}return Math.max(0,e-Math.round(t.discountValue*100))}var L=152;function O(e,t={}){if(!e)return"";try{let n=new URL(e);return t.width!==void 0&&n.searchParams.set("width",String(t.width)),t.height!==void 0&&n.searchParams.set("height",String(t.height)),t.crop&&n.searchParams.set("crop",t.crop),n.toString()}catch{return e}}function ke(e){if(!Number.isFinite(e)||e<=0)return"";let t=Math.floor(e/1e3),n=Math.floor(t/86400),i=Math.floor(t%86400/3600),r=Math.floor(t%3600/60),a=t%60,o=d=>String(d).padStart(2,"0");return n>0?`${n}d ${o(i)}h ${o(r)}m ${o(a)}s`:`${o(i)}h ${o(r)}m ${o(a)}s`}function H(e){let t=xt(e);if(t===null||t<=Date.now())return null;let n=t,i=document.createElement("div");i.className="lb-bundle-countdown",i.setAttribute("data-countdown","");let r=document.createElement("div");r.className="lb-bundle-countdown__label";let a=document.createElement("span");a.textContent="Ends in",r.appendChild(a),i.appendChild(r);let o=document.createElement("span");o.className="lb-bundle-countdown__timer",o.setAttribute("data-countdown-timer",""),i.appendChild(o);let d=null;function l(){let c=n-Date.now();if(c<=0){i.style.display="none",u();return}o.textContent=ke(c)}function u(){d!==null&&(clearInterval(d),d=null)}return l(),d=setInterval(l,1e3),{el:i,stop:u}}function xt(e){let t=Date.parse(e);return Number.isFinite(t)?t:null}function $(e){let t=document.createElement("button");t.type="button",t.className="lb-bundle-cta",t.setAttribute("data-add-bundle","");let n=document.createElement("span");n.className="lb-cta-label",n.setAttribute("data-cta-label",""),n.textContent=e,t.appendChild(n);let i=document.createElement("span");return i.className="lb-cta-spinner",i.setAttribute("data-cta-spinner",""),i.setAttribute("aria-hidden","true"),i.innerHTML='<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"><path d="M12 2a10 10 0 0 1 10 10" /></svg>',t.appendChild(i),t}function ee(e,t){let n=e.querySelector("[data-cta-label]");n&&(n.textContent=t)}function s(e,t,n={}){let i=document.createElement(e);t&&(i.className=t);for(let[r,a]of Object.entries(n))i.setAttribute(r,a);return i}var Ct=`
|
|
203
203
|
<svg class="lb-bundle-placeholder-icon" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
|
|
204
204
|
<rect x="4" y="4" width="20" height="20" rx="3"></rect>
|
|
205
205
|
<line x1="4" y1="20" x2="24" y2="20"></line>
|
|
206
206
|
<circle cx="10" cy="12" r="2"></circle>
|
|
207
|
-
</svg>`;function
|
|
207
|
+
</svg>`;function Se(e,t,n,i){let r=t.widgetConfig,a=(C,k)=>{let S=t.variantQuantities[k];return S!==void 0?S:t.productQuantities[C]??1},o=[],d=0;if(t.products.forEach((C,k)=>{let S=yt(t,C,k);S.qty!==0&&(S.isOos&&(d++,r.outOfStockBehavior==="hide")||o.push(S))}),o.length===0)return;let l=t.products[0]?.priceRange.minVariantPrice.currencyCode??"USD",u=s("div","lb-fixed",{"data-discount-type":t.discountConfig.discountType,"data-discount-value":String(t.discountConfig.discountValue)}),c=wt(t,l);if(u.appendChild(c.el),r.countdown.showCountdown&&t.endsAt){let C=H(t.endsAt);C&&(u.appendChild(C.el),i?.(C.stop))}let p=s("div","lb-fixed__products"),f=[];o.forEach(C=>{let k=Bt(C,l,a,()=>{A()});f.push(k),p.appendChild(k.el)}),u.appendChild(p),u.appendChild(s("div","lb-bundle-divider"));let h=kt(t);u.appendChild(h.el);let m=r.savingsBar.visible?St():null;m&&u.appendChild(m.el);let v=Tt(t,d,()=>{let C=o.filter(k=>k.selected).map(k=>({merchandiseId:k.selected.id,quantity:k.qty,attributes:[{key:"_lime_bundle_gid",value:t.id},{key:"_lime_bundle_type",value:t.bundleType}]}));C.length!==0&&n(C)});u.appendChild(v),u.appendChild(s("p","lb-bundle-error",{"data-error":"","aria-live":"polite"})),u.appendChild(s("span","lb-visually-hidden",{"data-status":"","aria-live":"polite"})),e.appendChild(u),A();function A(){let C=o.reduce((b,B)=>{if(!B.selected)return b;let y=P(B.selected.price.amount);return b+y*B.qty},0),k=At(C,t.discountConfig,o),S=Math.max(0,C-k);h.update({totalCents:C,saleCents:k,savingsCents:S,currency:l}),m&&m.update({savingsCents:S,currency:l}),c.refresh(_t(t,C,k,l))}}function yt(e,t,n){let i=e.selectedVariantIds?.[n]??null,r=t.variants.nodes.filter(p=>p.availableForSale),a=i&&i.length>0?r.filter(p=>i.includes(p.id)):r,o=a.length===0,d=a[0]??null,l=e.productQuantities[t.id]??1,c=(d?e.variantQuantities[d.id]:void 0)??l;return{product:t,eligibleVariants:a,selected:d,qty:c,isOos:o}}function wt(e,t){let n=e.widgetConfig,i=s("div","lb-bundle-header"),r=s("div","lb-bundle-header__content"),a=s("h3","lb-bundle-title");if(a.textContent=e.title,r.appendChild(a),e.description){let l=s("p","lb-bundle-subtitle");l.textContent=e.description,r.appendChild(l)}i.appendChild(r);let o=s("span","lb-bundle-header__badge",{"data-header-badge":""});i.appendChild(o);let d=Z(e,e.productQuantities,n.pricing.showSaveBadge);return d.headerBadge?o.textContent=d.headerBadge:o.style.display="none",{el:i,refresh(l){if(!n.pricing.showSaveBadge){o.style.display="none";return}l?(o.textContent=l,o.style.display=""):o.style.display="none"}}}function _t(e,t,n,i){if(!e.widgetConfig.pricing.showSaveBadge)return"";let r=t-n;if(r<=0)return"";let a=e.discountConfig;return a.discountType==="percentage"&&a.discountValue>0?`-${Math.round(a.discountValue)}%`:a.discountType==="fixed_amount"&&a.discountValue>0?`-${_(Math.round(a.discountValue*100),i)}`:`-${_(r,i)}`}function Bt(e,t,n,i){let r=s("div",e.isOos?"lb-bundle-product-row lb-bundle-product-row--oos":"lb-bundle-product-row",{"data-product-id":e.product.id.replace(/^.*\//,""),...e.isOos?{"aria-disabled":"true"}:{}}),a=s("div","lb-bundle-thumbnail",{"data-thumbnail":""});if(e.product.featuredImage){let u=document.createElement("img");u.src=O(e.product.featuredImage.url,{width:L,height:L,crop:"center"}),u.alt=e.product.featuredImage.altText??e.product.title,u.width=L,u.height=L,u.loading="lazy",a.appendChild(u)}else a.insertAdjacentHTML("beforeend",Ct);let o=null;e.isOos||(o=s("span","lb-bundle-qty-badge",{"data-qty-badge":""}),o.textContent=String(e.qty),a.appendChild(o)),r.appendChild(a);let d=s("div","lb-bundle-product-info"),l=document.createElement("a");if(l.className="lb-bundle-product-name",l.href=`/products/${e.product.handle}`,l.textContent=e.product.title,d.appendChild(l),e.isOos){let u=s("span","lb-bundle-oos-label");u.textContent="Out of stock",d.appendChild(u)}else if(e.selected){let u=s("span","lb-bundle-product-prices"),c=s("span","lb-bundle-product-compare-price",{"data-product-compare-price":""}),p=s("span","lb-bundle-product-price",{"data-product-price":""});u.appendChild(c),u.appendChild(p),d.appendChild(u);let f=h=>{let m=P(h.price.amount);if(p.textContent=_(m,t),h.compareAtPrice){let v=P(h.compareAtPrice.amount);v>m?(c.textContent=_(v,t),c.removeAttribute("hidden")):c.setAttribute("hidden","")}else c.setAttribute("hidden","")};if(f(e.selected),e.eligibleVariants.length>1){let h=document.createElement("select");h.className="lb-bundle-variant-select",h.setAttribute("data-variant-select",""),h.setAttribute("aria-label",`Select variant for ${e.product.title}`),e.eligibleVariants.forEach(m=>{let v=document.createElement("option");v.value=m.id,v.textContent=m.title,m.id===e.selected?.id&&(v.selected=!0),h.appendChild(v)}),h.addEventListener("change",()=>{let m=e.eligibleVariants.find(v=>v.id===h.value);m&&(e.selected=m,e.qty=n(e.product.id,m.id),o&&(o.textContent=String(e.qty)),f(m),i())}),d.appendChild(h)}else if(e.eligibleVariants.length===1&&e.product.variants.nodes.length>1){let h=s("span","lb-bundle-variant-badge");h.textContent=e.eligibleVariants[0].title,d.appendChild(h)}}return r.appendChild(d),{el:r,state:e}}function kt(e){let t=s("div","lb-bundle-pricing"),n=s("span","lb-bundle-pricing__label");n.textContent="Bundle price",t.appendChild(n);let i=s("span","lb-bundle-pricing__prices"),r=s("span","lb-bundle-compare-price",{"data-compare-price":""});r.style.display="none",i.appendChild(r);let a=s("span","lb-bundle-sale-price",{"data-sale-price":""});return i.appendChild(a),t.appendChild(i),{el:t,update({totalCents:o,saleCents:d,savingsCents:l,currency:u}){a.textContent=_(d,u),e.widgetConfig.pricing.showCompareAtPrice&&l>0?(r.textContent=_(o,u),r.style.display=""):r.style.display="none"}}}function St(){let e=s("div","lb-bundle-savings-bar",{"data-savings-bar":""}),t=document.createElement("span");t.textContent="You save",e.appendChild(t);let n=s("span","",{"data-savings-amount":""});return e.appendChild(n),{el:e,update({savingsCents:i,currency:r}){if(i<=0){e.style.display="none";return}e.style.display="",n.textContent=_(i,r)}}}function Tt(e,t,n){let i=t>0?`${t} item${t===1?"":"s"} out of stock`:e.widgetConfig.cta.ctaText||"Add to cart",r=$(i);return t>0?r.disabled=!0:r.addEventListener("click",()=>{r.disabled||n()}),r}function At(e,t,n){if(t.discountType==="percentage"){let i=0;for(let r of n){if(!r.selected)continue;let a=P(r.selected.price.amount),o=Math.floor(a*t.discountValue/100),d=Math.max(0,a-o);i+=d*r.qty}return i}return Math.max(0,e-Math.round(t.discountValue*100))}var Ae=`
|
|
208
208
|
<svg class="lb-bundle-placeholder-icon" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
|
|
209
209
|
<rect x="4" y="4" width="20" height="20" rx="3"></rect>
|
|
210
210
|
<line x1="4" y1="20" x2="24" y2="20"></line>
|
|
211
211
|
<circle cx="10" cy="12" r="2"></circle>
|
|
212
|
-
</svg>`,
|
|
212
|
+
</svg>`,Ee=`
|
|
213
213
|
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
214
214
|
<line x1="9" y1="3" x2="9" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
215
215
|
<line x1="3" y1="9" x2="15" y2="9" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
216
|
-
</svg>`,
|
|
216
|
+
</svg>`,te=`
|
|
217
217
|
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
218
218
|
<line x1="5" y1="5" x2="15" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
219
219
|
<line x1="15" y1="5" x2="5" y2="15" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
220
|
-
</svg>`,
|
|
220
|
+
</svg>`,Et=`
|
|
221
221
|
<svg width="16" height="16" viewBox="0 0 20 20" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
222
222
|
<path d="M14.348 5.652a.5.5 0 0 0-.707 0L10 9.293 6.36 5.652a.5.5 0 1 0-.708.707L9.293 10l-3.641 3.641a.5.5 0 0 0 .708.707L10 10.707l3.641 3.641a.5.5 0 0 0 .707-.707L10.707 10l3.641-3.641a.5.5 0 0 0 0-.707z"/>
|
|
223
|
-
</svg>`;function Te(e,t,n,o){let r=t.widgetConfig,a=t.products[0]?.priceRange.minVariantPrice.currencyCode??"USD",i=t.minQuantity??1,l=t.maxQuantity??i,d=Mt(t,r.outOfStockBehavior);if(d.filter(m=>!m.isOos).length<i)return;let u=[],p=s("div","lb-mix-match",{"data-required-quantity":String(i),"data-max-quantity":String(l)}),C=St(t);if(p.appendChild(C),r.countdown.showCountdown&&t.endsAt){let m=O(t.endsAt);m&&(p.appendChild(m.el),o?.(m.stop))}let b=Tt(i);p.appendChild(b.el);let v=s("div","lb-mix-match__slots",{"data-selection-slots":""});p.appendChild(v),p.appendChild(s("div","lb-bundle-divider"));let f=Pt(r.pricing.showCompareAtPrice);p.appendChild(f.el);let S=r.savingsBar.visible?Rt():null;S&&p.appendChild(S.el);let w=s("div","lb-mix-match__price-placeholder",{"data-price-placeholder":""}),B=s("span","lb-mix-match__price-placeholder-text");B.textContent=`Select ${i} items to see price`,w.appendChild(B),p.appendChild(w);let h=Lt(t,d,a,{showSearch:r.showSearch,onAdd:(m,x)=>y(m,x),onRemove:(m,x)=>T(m,x),countFor:(m,x)=>u.filter(E=>E.productId===m&&E.variantId===x).length,isOverMax:()=>u.length>=l});p.appendChild(h.el);let _=document.createElement("button");_.type="button",_.className="lb-bundle-cta",_.setAttribute("data-add-bundle",""),_.disabled=!0,_.textContent=`Select ${i} items to unlock`,_.addEventListener("click",()=>{if(_.disabled)return;let m=u.map(x=>({merchandiseId:x.variantId,quantity:1,attributes:[{key:"_lime_bundle_gid",value:t.id},{key:"_lime_bundle_type",value:t.bundleType}]}));n(m)}),p.appendChild(_),p.appendChild(s("p","lb-bundle-error",{"data-error":"","aria-live":"polite"})),p.appendChild(s("span","lb-visually-hidden",{"data-status":"","aria-live":"polite"})),e.appendChild(p),H();function y(m,x){u.length>=l||(u.push({productId:m.id,productTitle:m.title,variantId:x.id,variantTitle:x.title,imageUrl:m.featuredImage?.url??null,priceCents:R(x.price.amount),compareCents:x.compareAtPrice?R(x.compareAtPrice.amount):null}),F())}function T(m,x){let E=u.findIndex(V=>V.productId===m&&V.variantId===x);E!==-1&&(u.splice(E,1),F())}function L(m){m<0||m>=u.length||(u.splice(m,1),F())}function F(){H(),b.update(u.length),f.update(u,t,a),S&&S.update(u,t,a),w.style.display=u.length===0?"":"none",h.refreshCounts(),g()}function H(){v.innerHTML="";let m=Math.max(i,u.length);for(let x=0;x<m;x++){let E=u[x];E?v.appendChild(Et(E,x,a,()=>L(x))):v.appendChild(At(x,()=>h.open()))}}function g(){let m=u.length;m<i?(_.disabled=!0,_.textContent=`Select ${i-m} more to unlock`):(_.disabled=!1,_.textContent=r.cta.ctaText||"Add to cart")}}function St(e){let t=e.widgetConfig,n=s("div","lb-bundle-header"),o=s("div","lb-bundle-header__content"),r=s("h3","lb-bundle-title");if(r.textContent=e.title,o.appendChild(r),n.appendChild(o),t.pricing.showSaveBadge){let{discountType:a,discountValue:i}=e.discountConfig,l=null;if(a==="percentage"&&i>0?l=`-${Math.round(i)}%`:a==="fixed_amount"&&i>0&&(l=`-${k(Math.round(i*100),e.products[0]?.priceRange.minVariantPrice.currencyCode??"USD")}`),l){let d=s("span","lb-bundle-header__badge");d.textContent=l,n.appendChild(d)}}return n}function Tt(e){let t=s("div","lb-mix-match__progress"),n=s("div","lb-mix-match__progress-labels"),o=s("span","lb-mix-match__progress-count",{"data-progress-count":""});o.textContent=`0 of ${e} selected`,n.appendChild(o);let r=s("span","lb-mix-match__progress-remaining",{"data-progress-remaining":""});r.textContent=`${e} more to go`,n.appendChild(r),t.appendChild(n);let a=s("div","lb-mix-match__progress-track",{role:"progressbar","aria-valuenow":"0","aria-valuemin":"0","aria-valuemax":String(e)}),i=s("div","lb-mix-match__progress-fill",{"data-progress-fill":""});i.style.width="0%",a.appendChild(i),t.appendChild(a);function l(d){let c=Math.min(100,d/e*100);o.textContent=`${d} of ${e} selected`,d>=e?r.textContent="Complete":r.textContent=`${e-d} more to go`,i.style.width=`${c}%`,a.setAttribute("aria-valuenow",String(Math.min(d,e)))}return{el:t,update:l}}function At(e,t){let n=s("div","lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--empty",{"data-slot":String(e+1),tabindex:"0",role:"button","aria-label":"Add a product to the bundle"}),o=s("div","lb-mix-match__empty-thumb");o.innerHTML=Se,n.appendChild(o);let r=s("span","lb-mix-match__empty-text");return r.textContent="Choose an item",n.appendChild(r),n.addEventListener("click",t),n.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}),n}function Et(e,t,n,o){let r=s("div","lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--filled",{"data-slot":String(t+1)}),a=s("div","lb-bundle-thumbnail",{"data-thumbnail":""});if(e.imageUrl){let p=document.createElement("img");p.src=U(e.imageUrl,{width:P,height:P,crop:"center"}),p.alt=e.productTitle,p.width=P,p.height=P,p.loading="lazy",a.appendChild(p)}else a.insertAdjacentHTML("beforeend",ke);r.appendChild(a);let i=s("div","lb-mix-match__filled-info"),l=s("span","lb-mix-match__filled-title");if(l.textContent=e.productTitle,i.appendChild(l),e.variantTitle&&e.variantTitle!=="Default Title"){let p=s("span","lb-mix-match__filled-variant");p.textContent=e.variantTitle,i.appendChild(p)}let d=s("span","lb-mix-match__filled-price");if(e.compareCents&&e.compareCents>e.priceCents){let p=s("span","lb-mix-match__filled-compare");p.textContent=k(e.compareCents,n),d.appendChild(p)}let c=document.createElement("span");c.textContent=k(e.priceCents,n),d.appendChild(c),i.appendChild(d),r.appendChild(i);let u=document.createElement("button");return u.type="button",u.className="lb-mix-match__slot-remove",u.setAttribute("aria-label",`Remove ${e.productTitle}`),u.innerHTML=J,u.addEventListener("click",p=>{p.stopPropagation(),o()}),r.appendChild(u),r}function Pt(e){let t=s("div","lb-bundle-pricing",{"data-pricing-section":""});t.style.display="none";let n=s("span","lb-bundle-pricing__label");n.textContent="Bundle price",t.appendChild(n);let o=s("span","lb-bundle-pricing__prices"),r=s("span","lb-bundle-compare-price",{"data-compare-price":""});e&&o.appendChild(r);let a=s("span","lb-bundle-sale-price",{"data-sale-price":""});o.appendChild(a),t.appendChild(o);function i(l,d,c){if(l.length===0){t.style.display="none";return}t.style.display="";let u=l.reduce((C,b)=>C+b.priceCents,0),p=z(u,d.discountConfig);e&&u>p?(r.textContent=k(u,c),r.style.display=""):r.style.display="none",a.textContent=k(p,c)}return{el:t,update:i}}function Rt(){let e=s("div","lb-bundle-savings-bar",{"data-savings-bar":""});e.style.display="none";let t=document.createElement("span");t.textContent="You save",e.appendChild(t);let n=s("span","",{"data-savings-amount":""});e.appendChild(n);function o(r,a,i){if(r.length===0){e.style.display="none";return}let l=r.reduce((u,p)=>u+p.priceCents,0),d=z(l,a.discountConfig),c=Math.max(0,l-d);if(c<=0){e.style.display="none";return}e.style.display="",n.textContent=k(c,i)}return{el:e,update:o}}function Lt(e,t,n,o){let r=s("div","lb-mix-match__modal-overlay",{"data-modal-overlay":"","data-bundle-gid":e.id});r.style.display="none";let a=s("div","lb-mix-match__modal",{role:"dialog","aria-modal":"true","aria-labelledby":`lb-modal-title-${Be(e.id)}`,tabindex:"-1"}),i=s("div","lb-mix-match__modal-header"),l=s("h4","lb-mix-match__modal-title",{id:`lb-modal-title-${Be(e.id)}`});l.textContent="Pick an item",i.appendChild(l);let d=document.createElement("button");d.type="button",d.className="lb-mix-match__modal-close",d.setAttribute("data-modal-close",""),d.setAttribute("aria-label","Close"),d.innerHTML=J,d.addEventListener("click",L),i.appendChild(d),a.appendChild(i);let c=null,u=null;if(o.showSearch){let g=s("div","lb-mix-match__modal-search");c=document.createElement("input"),c.type="text",c.className="lb-mix-match__modal-search-input",c.setAttribute("data-modal-search",""),c.setAttribute("role","searchbox"),c.setAttribute("aria-label","Search products"),c.setAttribute("placeholder","Search products"),c.autocomplete="off",c.addEventListener("input",()=>B()),g.appendChild(c),u=document.createElement("button"),u.type="button",u.className="lb-mix-match__modal-search-clear",u.setAttribute("data-modal-search-clear",""),u.setAttribute("aria-label","Clear search"),u.style.display="none",u.innerHTML=kt,u.addEventListener("click",()=>{c&&(c.value="",B(),c.focus())}),g.appendChild(u),a.appendChild(g)}let p=s("div","lb-mix-match__modal-list",{"data-modal-list":""});a.appendChild(p);let C=s("div","lb-mix-match__modal-empty",{"data-modal-empty":""});C.style.display="none";let b=document.createElement("p");b.textContent="No products match your search.",C.appendChild(b),a.appendChild(C);let v=s("span","lb-visually-hidden",{"data-modal-live":"","aria-live":"polite"});a.appendChild(v),r.appendChild(a);let f=!1,S=[];function w(){f||(f=!0,p.innerHTML="",t.forEach(g=>{let m=g.firstAvailableVariant??g.variants[0];if(!m)return;let x=s("div",g.isOos?"lb-mix-match__modal-product lb-mix-match__modal-product--sold-out":"lb-mix-match__modal-product",{"data-product-id":g.product.id.replace(/^.*\//,"")}),E=s("div","lb-mix-match__modal-product-thumb");if(g.product.featuredImage){let A=document.createElement("img");A.src=U(g.product.featuredImage.url,{width:P,height:P,crop:"center"}),A.alt=g.product.featuredImage.altText??g.product.title,A.width=P,A.height=P,A.loading="lazy",E.appendChild(A)}else E.insertAdjacentHTML("beforeend",ke);x.appendChild(E);let V=s("div","lb-mix-match__modal-product-info"),Z=s("span","lb-mix-match__modal-product-title");Z.textContent=g.product.title,V.appendChild(Z);let ee=s("span","lb-mix-match__modal-product-price");if(ee.textContent=k(R(m.price.amount),n),V.appendChild(ee),g.isOos){let A=s("span","lb-mix-match__modal-sold-out-label");A.textContent="Sold out",V.appendChild(A)}if(x.appendChild(V),g.isOos)S.push({el:x,product:g.product,variant:m,updateCount:()=>{}});else{let A=document.createElement("button");A.type="button",A.className="lb-mix-match__modal-add",A.setAttribute("aria-label",`Add ${g.product.title}`),A.innerHTML=Se;let $=s("span","lb-bundle-qty-badge");$.style.display="none",A.appendChild($),A.addEventListener("click",()=>{o.isOverMax()||o.onAdd(g.product,m)}),x.appendChild(A);let I=document.createElement("button");I.type="button",I.className="lb-mix-match__slot-remove",I.setAttribute("aria-label",`Remove one ${g.product.title}`),I.style.display="none",I.innerHTML=J,I.addEventListener("click",N=>{N.stopPropagation(),o.onRemove(g.product.id,m.id)}),x.appendChild(I),S.push({el:x,product:g.product,variant:m,updateCount:()=>{let N=o.countFor(g.product.id,m.id);N>0?($.textContent=String(N),$.style.display="",I.style.display=""):($.style.display="none",I.style.display="none")}})}p.appendChild(x)}),H())}function B(){if(!c)return;let g=c.value.trim().toLowerCase();u&&(u.style.display=g?"":"none");let m=0;S.forEach(x=>{let E=!g||x.product.title.toLowerCase().includes(g);x.el.style.display=E?"":"none",E&&m++}),C.style.display=m===0&&g?"":"none"}let h=null;function _(g){if(g.key==="Escape"){g.preventDefault(),L();return}g.key==="Tab"&&It(g,a)}let y=!1;function T(){y||o.isOverMax()||(y=!0,w(),h=r.getRootNode().activeElement,r.style.display="",r.classList.add("lb-mix-match__modal-overlay--open"),a.focus(),document.addEventListener("keydown",_),r.addEventListener("click",F))}function L(){y&&(y=!1,r.classList.remove("lb-mix-match__modal-overlay--open"),r.style.display="none",document.removeEventListener("keydown",_),r.removeEventListener("click",F),h instanceof HTMLElement&&h.focus())}function F(g){g.target===r&&L()}function H(){S.forEach(g=>g.updateCount())}return{el:r,open:T,close:L,refreshCounts:H}}function Mt(e,t){let n=[],o=new Set;for(let r of e.products){if(o.has(r.id))continue;o.add(r.id);let a=r.variants.nodes.filter(l=>l.availableForSale),i=a.length===0;i&&t==="hide"||n.push({product:r,variants:r.variants.nodes,firstAvailableVariant:a[0]??null,isOos:i})}return n}function It(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;let o=n[0],r=n[n.length-1],a=t.getRootNode().activeElement;e.shiftKey&&a===o?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),o.focus())}function Be(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Re(e,t,n,o){let r=t.widgetConfig,i=t.products[0]?.variants.nodes.find(h=>h.availableForSale);if(!i&&r.outOfStockBehavior==="hide")return;let l=i?R(i.price.amount):0,d=i?.price.currencyCode??"USD",c=t.volumeTiers.map((h,_)=>{let y;if(h.discountType==="fixed_amount"){let T=Math.round(h.discountValue*100);y=Math.max(0,l-T)}else{let T=Math.floor(l*h.discountValue/100);y=Math.max(0,l-T)}return{tier:h,index:_,qty:h.minQuantity,pricePerUnitCents:y,basePricePerUnitCents:l}}),u=Ut(c),p=r.defaultTier==="best_value"?u:0;typeof r.defaultTier=="number"&&(p=Pe(r.defaultTier,0,c.length-1));let C=r.popularBadge.tierIndex!==void 0?Pe(r.popularBadge.tierIndex,0,c.length-1):u,b=s("div","lb-volume");if(b.appendChild(Ft(t,c,p,d)),r.countdown.showCountdown&&t.endsAt){let h=O(t.endsAt);h&&(b.appendChild(h.el),o?.(h.stop))}let v=s("div","lb-volume__tiers",{role:"radiogroup","aria-label":"Quantity tiers","data-tier-group":""});c.forEach(h=>{let _=Vt(h,h.index===p,d,r.popularBadge.visible&&h.index===C?r.popularBadge.text:null,r.pricing.showComparePrice,r.pricing.showPerUnitPrice);_.addEventListener("click",()=>B(h.index)),_.addEventListener("keydown",y=>{if(y.key==="Enter"||y.key===" "){y.preventDefault(),B(h.index);return}if(y.key==="ArrowDown"||y.key==="ArrowRight"||y.key==="ArrowUp"||y.key==="ArrowLeft"){y.preventDefault();let T=y.key==="ArrowDown"||y.key==="ArrowRight"?1:-1,L=(h.index+T+c.length)%c.length;B(L),v.children[L]?.focus()}}),v.appendChild(_)}),b.appendChild(v),b.appendChild(s("div","lb-bundle-divider"));let f=Ae(c,p,d,r.pricing.showItemCount,r.pricing.showCompareAtPrice);b.appendChild(f);let S=r.savingsBar.visible?Ee(c,p,d):null;S&&b.appendChild(S);let w=Dt(t,()=>{if(!i)return;let h=c[p];h&&n([{merchandiseId:i.id,quantity:h.qty,attributes:[{key:"_lime_bundle_gid",value:t.id},{key:"_lime_bundle_type",value:t.bundleType}]}])});b.appendChild(w),b.appendChild(s("p","lb-bundle-error",{"data-error":"","aria-live":"polite"})),b.appendChild(s("span","lb-visually-hidden",{"data-status":"","aria-live":"polite"})),e.appendChild(b);function B(h){if(h===p||h<0||h>=c.length)return;p=h,Array.from(v.children).forEach((T,L)=>{T.setAttribute("aria-checked",String(L===h)),T.tabIndex=L===h?0:-1});let _=Ae(c,h,d,r.pricing.showItemCount,r.pricing.showCompareAtPrice);if(f.replaceWith(_),f=_,S){let T=Ee(c,h,d);S.replaceWith(T),S=T}let y=b.querySelector("[data-header-badge]");if(y){let T=Le(c[h],d);T?(y.textContent=T,y.style.display=""):y.style.display="none"}}}function Ft(e,t,n,o){let r=e.widgetConfig,a=s("div","lb-bundle-header"),i=s("div","lb-bundle-header__content"),l=s("h3","lb-bundle-title");if(l.textContent=e.title,i.appendChild(l),a.appendChild(i),r.pricing.showSaveBadge){let d=Le(t[n],o);if(d){let c=s("span","lb-bundle-header__badge",{"data-header-badge":""});c.textContent=d,a.appendChild(c)}}return a}function Vt(e,t,n,o,r,a){let i=s("div","lb-volume__tier",{role:"radio","aria-checked":String(t),tabindex:t?"0":"-1","data-tier-index":String(e.index),"data-tier-qty":String(e.qty)}),l=s("span","lb-volume__radio");l.appendChild(s("span","lb-volume__radio-dot")),i.appendChild(l);let d=s("span","lb-volume__tier-grid"),c=s("span","lb-volume__tier-label");c.textContent=`Buy ${e.qty}`,d.appendChild(c);let u=s("span","lb-volume__tier-price");if(r&&e.pricePerUnitCents<e.basePricePerUnitCents){let C=s("span","lb-volume__tier-compare");C.textContent=k(e.basePricePerUnitCents,n),u.appendChild(C)}if(a){let C=document.createElement("span");C.setAttribute("data-tier-price-each",""),C.textContent=k(e.pricePerUnitCents,n),u.appendChild(C);let b=s("span","lb-volume__tier-unit");b.textContent=" each",u.appendChild(b)}d.appendChild(u),i.appendChild(d);let p=s("span","lb-volume__tier-badge");return o?p.textContent=o:p.style.display="none",i.appendChild(p),i}function Ae(e,t,n,o,r){let a=e[t],i=a?a.pricePerUnitCents*a.qty:0,l=a?a.basePricePerUnitCents*a.qty:0,d=Math.max(0,l-i),c=s("div","lb-bundle-pricing"),u=s("span","lb-bundle-pricing__label",{"data-total-label":""});if(u.textContent="Total",o&&a){let b=document.createElement("span");b.setAttribute("data-item-count",""),b.textContent=` (${a.qty} item${a.qty===1?"":"s"})`,u.appendChild(b)}c.appendChild(u);let p=s("span","lb-bundle-pricing__prices");if(r&&d>0){let b=s("span","lb-bundle-compare-price",{"data-compare-price":""});b.textContent=k(l,n),p.appendChild(b)}let C=s("span","lb-bundle-sale-price",{"data-total-price":""});return C.textContent=k(i,n),p.appendChild(C),c.appendChild(p),c}function Ee(e,t,n){let o=e[t],r=o?o.pricePerUnitCents*o.qty:0,a=o?o.basePricePerUnitCents*o.qty:0,i=Math.max(0,a-r),l=s("div","lb-bundle-savings-bar",{"data-savings-bar":""});i<=0&&(l.style.display="none");let d=document.createElement("span");d.textContent="You save",l.appendChild(d);let c=s("span","",{"data-savings-amount":""});return c.textContent=k(i,n),l.appendChild(c),l}function Dt(e,t){let o=e.products[0]?.variants.nodes.some(a=>a.availableForSale),r=document.createElement("button");return r.type="button",r.className="lb-bundle-cta",r.setAttribute("data-add-bundle",""),o||(r.disabled=!0),r.textContent=o?e.widgetConfig.cta.ctaText||"Add to cart":"Sold out",r.addEventListener("click",()=>{r.disabled||t()}),r}function Le(e,t){if(!e)return null;let{tier:n}=e;return n.discountType==="fixed_amount"&&n.discountValue>0?`-${k(Math.round(n.discountValue*100),t)}`:n.discountType==="percentage"&&n.discountValue>0?`-${Math.round(n.discountValue)}%`:null}function Ut(e){let t=0,n=0;return e.forEach((o,r)=>{let a=o.basePricePerUnitCents-o.pricePerUnitCents;a>t&&(t=a,n=r)}),n}function Pe(e,t,n){return Math.max(t,Math.min(n,e))}var j=`/* Lime Bundles \u2014 shared base styles for all bundle widget types */
|
|
223
|
+
</svg>`;function Pe(e,t,n,i){let r=t.widgetConfig,a=t.products[0]?.priceRange.minVariantPrice.currencyCode??"USD",o=t.minQuantity??1,d=t.maxQuantity??o,l=Vt(t,r.outOfStockBehavior);if(l.filter(x=>!x.isOos).length<o)return;let c=[],p=s("div","lb-mix-match",{"data-required-quantity":String(o),"data-max-quantity":String(d)}),f=Pt(t);if(p.appendChild(f),r.countdown.showCountdown&&t.endsAt){let x=H(t.endsAt);x&&(p.appendChild(x.el),i?.(x.stop))}let h=Lt(o);p.appendChild(h.el);let m=s("div","lb-mix-match__slots",{"data-selection-slots":""});p.appendChild(m),p.appendChild(s("div","lb-bundle-divider"));let v=It(r.pricing.showCompareAtPrice);p.appendChild(v.el);let A=r.savingsBar.visible?Ft():null;A&&p.appendChild(A.el);let C=s("div","lb-mix-match__price-placeholder",{"data-price-placeholder":""}),k=s("span","lb-mix-match__price-placeholder-text");k.textContent=`Select ${o} items to see price`,C.appendChild(k),p.appendChild(C);let S=Dt(t,l,a,{showSearch:r.showSearch,onAdd:(x,w)=>T(x,w),onRemove:(x,w)=>M(x,w),countFor:(x,w)=>c.filter(F=>F.productId===x&&F.variantId===w).length,isOverMax:()=>c.length>=d});p.appendChild(S.el);let b=$(`Select ${o} items to unlock`);b.disabled=!0,b.addEventListener("click",()=>{if(b.disabled)return;let x=c.map(w=>({merchandiseId:w.variantId,quantity:1,attributes:[{key:"_lime_bundle_gid",value:t.id},{key:"_lime_bundle_type",value:t.bundleType}]}));n(x)}),p.appendChild(b),p.appendChild(s("p","lb-bundle-error",{"data-error":"","aria-live":"polite"})),p.appendChild(s("span","lb-visually-hidden",{"data-status":"","aria-live":"polite"})),e.appendChild(p);let B=l.find(x=>!x.isOos),y=B?.firstAvailableVariant??B?.variants[0];B&&y&&c.push({productId:B.product.id,productTitle:B.product.title,variantId:y.id,variantTitle:y.title,imageUrl:B.product.featuredImage?.url??null,priceCents:P(y.price.amount),compareCents:y.compareAtPrice?P(y.compareAtPrice.amount):null}),g();function T(x,w){c.length>=d||(c.push({productId:x.id,productTitle:x.title,variantId:w.id,variantTitle:w.title,imageUrl:x.featuredImage?.url??null,priceCents:P(w.price.amount),compareCents:w.compareAtPrice?P(w.compareAtPrice.amount):null}),g())}function M(x,w){let F=c.findIndex(q=>q.productId===x&&q.variantId===w);F!==-1&&(c.splice(F,1),g())}function W(x){x<0||x>=c.length||(c.splice(x,1),g())}function g(){R(),h.update(c.length),v.update(c,t,a),A&&A.update(c,t,a),C.style.display=c.length===0?"":"none",S.refreshCounts(),I()}function R(){m.innerHTML="";let x=Math.max(o,c.length);for(let w=0;w<x;w++){let F=c[w];F?m.appendChild(Rt(F,w,a,()=>W(w))):m.appendChild(Mt(w,()=>S.open()))}}function I(){let x=c.length;x<o?(b.disabled=!0,ee(b,`Select ${o-x} more to unlock`)):(b.disabled=!1,ee(b,r.cta.ctaText||"Add to cart"))}}function Pt(e){let t=e.widgetConfig,n=s("div","lb-bundle-header"),i=s("div","lb-bundle-header__content"),r=s("h3","lb-bundle-title");if(r.textContent=e.title,i.appendChild(r),n.appendChild(i),t.pricing.showSaveBadge){let{discountType:a,discountValue:o}=e.discountConfig,d=null;if(a==="percentage"&&o>0?d=`-${Math.round(o)}%`:a==="fixed_amount"&&o>0&&(d=`-${_(Math.round(o*100),e.products[0]?.priceRange.minVariantPrice.currencyCode??"USD")}`),d){let l=s("span","lb-bundle-header__badge");l.textContent=d,n.appendChild(l)}}return n}function Lt(e){let t=s("div","lb-mix-match__progress"),n=s("div","lb-mix-match__progress-labels"),i=s("span","lb-mix-match__progress-count",{"data-progress-count":""});i.textContent=`0 of ${e} selected`,n.appendChild(i);let r=s("span","lb-mix-match__progress-remaining",{"data-progress-remaining":""});r.textContent=`${e} more to go`,n.appendChild(r),t.appendChild(n);let a=s("div","lb-mix-match__progress-track",{role:"progressbar","aria-valuenow":"0","aria-valuemin":"0","aria-valuemax":String(e)}),o=s("div","lb-mix-match__progress-fill",{"data-progress-fill":""});o.style.width="0%",a.appendChild(o),t.appendChild(a);function d(l){let u=Math.min(100,l/e*100);i.textContent=`${l} of ${e} selected`,l>=e?r.textContent="Complete":r.textContent=`${e-l} more to go`,o.style.width=`${u}%`,a.setAttribute("aria-valuenow",String(Math.min(l,e)))}return{el:t,update:d}}function Mt(e,t){let n=s("div","lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--empty",{"data-slot":String(e+1),tabindex:"0",role:"button","aria-label":"Add a product to the bundle"}),i=s("div","lb-mix-match__empty-thumb");i.innerHTML=Ee,n.appendChild(i);let r=s("span","lb-mix-match__empty-text");return r.textContent="Choose an item",n.appendChild(r),n.addEventListener("click",t),n.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t())}),n}function Rt(e,t,n,i){let r=s("div","lb-bundle-product-row lb-mix-match__slot lb-mix-match__slot--filled",{"data-slot":String(t+1)}),a=s("div","lb-bundle-thumbnail",{"data-thumbnail":""});if(e.imageUrl){let p=document.createElement("img");p.src=O(e.imageUrl,{width:L,height:L,crop:"center"}),p.alt=e.productTitle,p.width=L,p.height=L,p.loading="lazy",a.appendChild(p)}else a.insertAdjacentHTML("beforeend",Ae);r.appendChild(a);let o=s("div","lb-mix-match__filled-info"),d=s("span","lb-mix-match__filled-title");if(d.textContent=e.productTitle,o.appendChild(d),e.variantTitle&&e.variantTitle!=="Default Title"){let p=s("span","lb-mix-match__filled-variant");p.textContent=e.variantTitle,o.appendChild(p)}let l=s("span","lb-mix-match__filled-price");if(e.compareCents&&e.compareCents>e.priceCents){let p=s("span","lb-mix-match__filled-compare");p.textContent=_(e.compareCents,n),l.appendChild(p)}let u=document.createElement("span");u.textContent=_(e.priceCents,n),l.appendChild(u),o.appendChild(l),r.appendChild(o);let c=document.createElement("button");return c.type="button",c.className="lb-mix-match__slot-remove",c.setAttribute("aria-label",`Remove ${e.productTitle}`),c.innerHTML=te,c.addEventListener("click",p=>{p.stopPropagation(),i()}),r.appendChild(c),r}function It(e){let t=s("div","lb-bundle-pricing",{"data-pricing-section":""});t.style.display="none";let n=s("span","lb-bundle-pricing__label");n.textContent="Bundle price",t.appendChild(n);let i=s("span","lb-bundle-pricing__prices"),r=s("span","lb-bundle-compare-price",{"data-compare-price":""});e&&i.appendChild(r);let a=s("span","lb-bundle-sale-price",{"data-sale-price":""});i.appendChild(a),t.appendChild(i);function o(d,l,u){if(d.length===0){t.style.display="none";return}t.style.display="";let c=d.reduce((f,h)=>f+h.priceCents,0),p=Q(c,l.discountConfig);e&&c>p?(r.textContent=_(c,u),r.style.display=""):r.style.display="none",a.textContent=_(p,u)}return{el:t,update:o}}function Ft(){let e=s("div","lb-bundle-savings-bar",{"data-savings-bar":""});e.style.display="none";let t=document.createElement("span");t.textContent="You save",e.appendChild(t);let n=s("span","",{"data-savings-amount":""});e.appendChild(n);function i(r,a,o){if(r.length===0){e.style.display="none";return}let d=r.reduce((c,p)=>c+p.priceCents,0),l=Q(d,a.discountConfig),u=Math.max(0,d-l);if(u<=0){e.style.display="none";return}e.style.display="",n.textContent=_(u,o)}return{el:e,update:i}}function Dt(e,t,n,i){let r=s("div","lb-mix-match__modal-overlay",{"data-modal-overlay":"","data-bundle-gid":e.id});r.style.display="none";let a=s("div","lb-mix-match__modal",{role:"dialog","aria-modal":"true","aria-labelledby":`lb-modal-title-${Te(e.id)}`,tabindex:"-1"}),o=s("div","lb-mix-match__modal-header"),d=s("h4","lb-mix-match__modal-title",{id:`lb-modal-title-${Te(e.id)}`});d.textContent="Pick an item",o.appendChild(d);let l=document.createElement("button");l.type="button",l.className="lb-mix-match__modal-close",l.setAttribute("data-modal-close",""),l.setAttribute("aria-label","Close"),l.innerHTML=te,l.addEventListener("click",T),o.appendChild(l),a.appendChild(o);let u=null,c=null;if(i.showSearch){let g=s("div","lb-mix-match__modal-search");u=document.createElement("input"),u.type="text",u.className="lb-mix-match__modal-search-input",u.setAttribute("data-modal-search",""),u.setAttribute("role","searchbox"),u.setAttribute("aria-label","Search products"),u.setAttribute("placeholder","Search products"),u.autocomplete="off",u.addEventListener("input",()=>k()),g.appendChild(u),c=document.createElement("button"),c.type="button",c.className="lb-mix-match__modal-search-clear",c.setAttribute("data-modal-search-clear",""),c.setAttribute("aria-label","Clear search"),c.style.display="none",c.innerHTML=Et,c.addEventListener("click",()=>{u&&(u.value="",k(),u.focus())}),g.appendChild(c),a.appendChild(g)}let p=s("div","lb-mix-match__modal-list",{"data-modal-list":""});a.appendChild(p);let f=s("div","lb-mix-match__modal-empty",{"data-modal-empty":""});f.style.display="none";let h=document.createElement("p");h.textContent="No products match your search.",f.appendChild(h),a.appendChild(f);let m=s("span","lb-visually-hidden",{"data-modal-live":"","aria-live":"polite"});a.appendChild(m),r.appendChild(a);let v=!1,A=[];function C(){v||(v=!0,p.innerHTML="",t.forEach(g=>{let R=g.firstAvailableVariant??g.variants[0];if(!R)return;let I=s("div",g.isOos?"lb-mix-match__modal-product lb-mix-match__modal-product--sold-out":"lb-mix-match__modal-product",{"data-product-id":g.product.id.replace(/^.*\//,"")}),x=s("div","lb-mix-match__modal-product-thumb");if(g.product.featuredImage){let E=document.createElement("img");E.src=O(g.product.featuredImage.url,{width:L,height:L,crop:"center"}),E.alt=g.product.featuredImage.altText??g.product.title,E.width=L,E.height=L,E.loading="lazy",x.appendChild(E)}else x.insertAdjacentHTML("beforeend",Ae);I.appendChild(x);let w=s("div","lb-mix-match__modal-product-info"),F=s("span","lb-mix-match__modal-product-title");F.textContent=g.product.title,w.appendChild(F);let q=s("span","lb-mix-match__modal-product-price");if(q.textContent=_(P(R.price.amount),n),w.appendChild(q),g.isOos){let E=s("span","lb-mix-match__modal-sold-out-label");E.textContent="Sold out",w.appendChild(E)}if(I.appendChild(w),g.isOos)A.push({el:I,product:g.product,variant:R,updateCount:()=>{}});else{let E=document.createElement("button");E.type="button",E.className="lb-mix-match__modal-add",E.setAttribute("aria-label",`Add ${g.product.title}`),E.innerHTML=Ee;let N=s("span","lb-bundle-qty-badge");N.style.display="none",E.appendChild(N),E.addEventListener("click",()=>{i.isOverMax()||i.onAdd(g.product,R)}),I.appendChild(E);let V=document.createElement("button");V.type="button",V.className="lb-mix-match__slot-remove",V.setAttribute("aria-label",`Remove one ${g.product.title}`),V.style.display="none",V.innerHTML=te,V.addEventListener("click",G=>{G.stopPropagation(),i.onRemove(g.product.id,R.id)}),I.appendChild(V),A.push({el:I,product:g.product,variant:R,updateCount:()=>{let G=i.countFor(g.product.id,R.id);G>0?(N.textContent=String(G),N.style.display="",V.style.display=""):(N.style.display="none",V.style.display="none")}})}p.appendChild(I)}),W())}function k(){if(!u)return;let g=u.value.trim().toLowerCase();c&&(c.style.display=g?"":"none");let R=0;A.forEach(I=>{let x=!g||I.product.title.toLowerCase().includes(g);I.el.style.display=x?"":"none",x&&R++}),f.style.display=R===0&&g?"":"none"}let S=null;function b(g){if(g.key==="Escape"){g.preventDefault(),T();return}g.key==="Tab"&&Ut(g,a)}let B=!1;function y(){B||i.isOverMax()||(B=!0,C(),S=r.getRootNode().activeElement,r.style.display="",r.classList.add("lb-mix-match__modal-overlay--open"),a.focus(),document.addEventListener("keydown",b),r.addEventListener("click",M))}function T(){B&&(B=!1,r.classList.remove("lb-mix-match__modal-overlay--open"),r.style.display="none",document.removeEventListener("keydown",b),r.removeEventListener("click",M),S instanceof HTMLElement&&S.focus())}function M(g){g.target===r&&T()}function W(){A.forEach(g=>g.updateCount())}return{el:r,open:y,close:T,refreshCounts:W}}function Vt(e,t){let n=[],i=new Set;for(let r of e.products){if(i.has(r.id))continue;i.add(r.id);let a=r.variants.nodes.filter(d=>d.availableForSale),o=a.length===0;o&&t==="hide"||n.push({product:r,variants:r.variants.nodes,firstAvailableVariant:a[0]??null,isOos:o})}return n}function Ut(e,t){let n=t.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(n.length===0)return;let i=n[0],r=n[n.length-1],a=t.getRootNode().activeElement;e.shiftKey&&a===i?(e.preventDefault(),r.focus()):!e.shiftKey&&a===r&&(e.preventDefault(),i.focus())}function Te(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Ie(e,t,n,i){let r=t.widgetConfig,o=t.products[0]?.variants.nodes.find(b=>b.availableForSale);if(!o&&r.outOfStockBehavior==="hide")return;let d=o?P(o.price.amount):0,l=o?.price.currencyCode??"USD",u=t.discountConfig.discountType,c=t.volumeTiers.map((b,B)=>{let y;if(u==="fixed_amount"){let T=Math.round((b.amount??0)*100);y=Math.max(0,d-T)}else{let T=b.percentage??0,M=Math.floor(d*T/100);y=Math.max(0,d-M)}return{tier:b,index:B,qty:b.minQuantity,pricePerUnitCents:y,basePricePerUnitCents:d}}),p=Wt(c),f=r.defaultTier==="best_value"?p:0;typeof r.defaultTier=="number"&&(f=Re(r.defaultTier,0,c.length-1));let h=r.popularBadge.tierIndex!==void 0?Re(r.popularBadge.tierIndex,0,c.length-1):p,m=s("div","lb-volume");if(m.appendChild(Ot(t,c,f,l,u)),r.countdown.showCountdown&&t.endsAt){let b=H(t.endsAt);b&&(m.appendChild(b.el),i?.(b.stop))}let v=s("div","lb-volume__tiers",{role:"radiogroup","aria-label":"Quantity tiers","data-tier-group":""});c.forEach(b=>{let B=Ht(b,b.index===f,l,r.popularBadge.visible&&b.index===h?r.popularBadge.text:null,r.pricing.showComparePrice,r.pricing.showPerUnitPrice);B.addEventListener("click",()=>S(b.index)),B.addEventListener("keydown",y=>{if(y.key==="Enter"||y.key===" "){y.preventDefault(),S(b.index);return}if(y.key==="ArrowDown"||y.key==="ArrowRight"||y.key==="ArrowUp"||y.key==="ArrowLeft"){y.preventDefault();let T=y.key==="ArrowDown"||y.key==="ArrowRight"?1:-1,M=(b.index+T+c.length)%c.length;S(M),v.children[M]?.focus()}}),v.appendChild(B)}),m.appendChild(v),m.appendChild(s("div","lb-bundle-divider"));let A=Le(c,f,l,r.pricing.showItemCount,r.pricing.showCompareAtPrice);m.appendChild(A);let C=r.savingsBar.visible?Me(c,f,l):null;C&&m.appendChild(C);let k=$t(t,()=>{if(!o)return;let b=c[f];b&&n([{merchandiseId:o.id,quantity:b.qty,attributes:[{key:"_lime_bundle_gid",value:t.id},{key:"_lime_bundle_type",value:t.bundleType}]}])});m.appendChild(k),m.appendChild(s("p","lb-bundle-error",{"data-error":"","aria-live":"polite"})),m.appendChild(s("span","lb-visually-hidden",{"data-status":"","aria-live":"polite"})),e.appendChild(m);function S(b){if(b===f||b<0||b>=c.length)return;f=b,Array.from(v.children).forEach((T,M)=>{T.setAttribute("aria-checked",String(M===b)),T.tabIndex=M===b?0:-1});let B=Le(c,b,l,r.pricing.showItemCount,r.pricing.showCompareAtPrice);if(A.replaceWith(B),A=B,C){let T=Me(c,b,l);C.replaceWith(T),C=T}let y=m.querySelector("[data-header-badge]");if(y){let T=Fe(c[b],l,u);T?(y.textContent=T,y.style.display=""):y.style.display="none"}}}function Ot(e,t,n,i,r){let a=e.widgetConfig,o=s("div","lb-bundle-header"),d=s("div","lb-bundle-header__content"),l=s("h3","lb-bundle-title");if(l.textContent=e.title,d.appendChild(l),o.appendChild(d),a.pricing.showSaveBadge){let u=Fe(t[n],i,r);if(u){let c=s("span","lb-bundle-header__badge",{"data-header-badge":""});c.textContent=u,o.appendChild(c)}}return o}function Ht(e,t,n,i,r,a){let o=s("div","lb-volume__tier",{role:"radio","aria-checked":String(t),tabindex:t?"0":"-1","data-tier-index":String(e.index),"data-tier-qty":String(e.qty)}),d=s("span","lb-volume__radio");d.appendChild(s("span","lb-volume__radio-dot")),o.appendChild(d);let l=s("span","lb-volume__tier-grid"),u=s("span","lb-volume__tier-label");u.textContent=`Buy ${e.qty}`,l.appendChild(u);let c=s("span","lb-volume__tier-price");if(r&&e.pricePerUnitCents<e.basePricePerUnitCents){let f=s("span","lb-volume__tier-compare");f.textContent=_(e.basePricePerUnitCents,n),c.appendChild(f)}if(a){let f=document.createElement("span");f.setAttribute("data-tier-price-each",""),f.textContent=_(e.pricePerUnitCents,n),c.appendChild(f);let h=s("span","lb-volume__tier-unit");h.textContent=" each",c.appendChild(h)}l.appendChild(c),o.appendChild(l);let p=s("span","lb-volume__tier-badge");return i?p.textContent=i:p.style.display="none",o.appendChild(p),o}function Le(e,t,n,i,r){let a=e[t],o=a?a.pricePerUnitCents*a.qty:0,d=a?a.basePricePerUnitCents*a.qty:0,l=Math.max(0,d-o),u=s("div","lb-bundle-pricing"),c=s("span","lb-bundle-pricing__label",{"data-total-label":""});if(c.textContent="Total",i&&a){let h=document.createElement("span");h.setAttribute("data-item-count",""),h.textContent=` (${a.qty} item${a.qty===1?"":"s"})`,c.appendChild(h)}u.appendChild(c);let p=s("span","lb-bundle-pricing__prices");if(r&&l>0){let h=s("span","lb-bundle-compare-price",{"data-compare-price":""});h.textContent=_(d,n),p.appendChild(h)}let f=s("span","lb-bundle-sale-price",{"data-total-price":""});return f.textContent=_(o,n),p.appendChild(f),u.appendChild(p),u}function Me(e,t,n){let i=e[t],r=i?i.pricePerUnitCents*i.qty:0,a=i?i.basePricePerUnitCents*i.qty:0,o=Math.max(0,a-r),d=s("div","lb-bundle-savings-bar",{"data-savings-bar":""});o<=0&&(d.style.display="none");let l=document.createElement("span");l.textContent="You save",d.appendChild(l);let u=s("span","",{"data-savings-amount":""});return u.textContent=_(o,n),d.appendChild(u),d}function $t(e,t){let i=e.products[0]?.variants.nodes.some(o=>o.availableForSale),r=i?e.widgetConfig.cta.ctaText||"Add to cart":"Sold out",a=$(r);return i||(a.disabled=!0),a.addEventListener("click",()=>{a.disabled||t()}),a}function Fe(e,t,n){if(!e)return null;let{tier:i}=e;if(n==="fixed_amount"){let r=i.amount??0;return r>0?`-${_(Math.round(r*100),t)}`:null}if(n==="percentage"){let r=i.percentage??0;return r>0?`-${Math.round(r)}%`:null}return null}function Wt(e){let t=0,n=0;return e.forEach((i,r)=>{let a=i.basePricePerUnitCents-i.pricePerUnitCents;a>t&&(t=a,n=r)}),n}function Re(e,t,n){return Math.max(t,Math.min(n,e))}var re=`/* Lime Bundles \u2014 shared base styles for all bundle widget types */
|
|
224
224
|
|
|
225
225
|
.lb-bundle-widget.lb-bundle-widget,
|
|
226
226
|
.lb-bundle-widget.lb-bundle-widget * {
|
|
@@ -241,6 +241,10 @@
|
|
|
241
241
|
border-radius: var(--lb-radius);
|
|
242
242
|
padding: var(--lb-widget-pad) var(--lb-widget-pad) 20px;
|
|
243
243
|
box-sizing: border-box;
|
|
244
|
+
/* Cap the widget at a comfortable reading width on desktop. Below
|
|
245
|
+
440px viewports the container is already narrower than the cap,
|
|
246
|
+
so the rule is inert on mobile. */
|
|
247
|
+
max-width: 440px;
|
|
244
248
|
}
|
|
245
249
|
|
|
246
250
|
/* Countdown timer bar \u2014 sits below the gradient header */
|
|
@@ -561,9 +565,16 @@
|
|
|
561
565
|
display: none;
|
|
562
566
|
}
|
|
563
567
|
|
|
564
|
-
/* CTA button
|
|
568
|
+
/* CTA button.
|
|
569
|
+
* Label and spinner share a single 1\xD71 grid cell so the button's intrinsic
|
|
570
|
+
* width/height stays fixed when swapping between them \u2014 no layout shift when
|
|
571
|
+
* entering the loading state. Visibility (not display) is used so the hidden
|
|
572
|
+
* child still contributes to the cell's min-content sizing. See the
|
|
573
|
+
* [data-loading="true"] rules below. */
|
|
565
574
|
.lb-bundle-cta {
|
|
566
|
-
display:
|
|
575
|
+
display: grid;
|
|
576
|
+
grid-template-rows: 1fr;
|
|
577
|
+
grid-template-columns: 1fr;
|
|
567
578
|
width: 100%;
|
|
568
579
|
padding: 16px;
|
|
569
580
|
border: var(--lb-cta-border-width) solid var(--lb-cta-border-color);
|
|
@@ -592,12 +603,51 @@
|
|
|
592
603
|
cursor: not-allowed;
|
|
593
604
|
}
|
|
594
605
|
|
|
606
|
+
/* Both the label and the spinner occupy grid cell (1, 1). Only one is
|
|
607
|
+
* visible at a time; the other keeps its box for sizing but is invisible. */
|
|
608
|
+
.lb-cta-label,
|
|
609
|
+
.lb-cta-spinner {
|
|
610
|
+
grid-row: 1;
|
|
611
|
+
grid-column: 1;
|
|
612
|
+
display: flex;
|
|
613
|
+
align-items: center;
|
|
614
|
+
justify-content: center;
|
|
615
|
+
min-width: 0;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.lb-cta-spinner {
|
|
619
|
+
visibility: hidden;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
.lb-cta-spinner svg {
|
|
623
|
+
width: 20px;
|
|
624
|
+
height: 20px;
|
|
625
|
+
animation: lb-cta-spin 0.8s linear infinite;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
@keyframes lb-cta-spin {
|
|
629
|
+
to { transform: rotate(360deg); }
|
|
630
|
+
}
|
|
631
|
+
|
|
595
632
|
.lb-bundle-cta[data-loading="true"] {
|
|
596
|
-
opacity: 0.7;
|
|
597
633
|
cursor: wait;
|
|
598
634
|
pointer-events: none;
|
|
599
635
|
}
|
|
600
636
|
|
|
637
|
+
.lb-bundle-cta[data-loading="true"] .lb-cta-label {
|
|
638
|
+
visibility: hidden;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.lb-bundle-cta[data-loading="true"] .lb-cta-spinner {
|
|
642
|
+
visibility: visible;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
@media (prefers-reduced-motion: reduce) {
|
|
646
|
+
.lb-cta-spinner svg {
|
|
647
|
+
animation-duration: 2.5s;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
601
651
|
/* Error message */
|
|
602
652
|
.lb-bundle-error {
|
|
603
653
|
font-size: 16px;
|
|
@@ -649,7 +699,7 @@
|
|
|
649
699
|
.lb-ab-pending {
|
|
650
700
|
visibility: hidden;
|
|
651
701
|
}
|
|
652
|
-
`,
|
|
702
|
+
`,De=`/* Lime Bundles \u2014 Fixed bundle styles */
|
|
653
703
|
|
|
654
704
|
.lb-fixed__products {
|
|
655
705
|
display: flex;
|
|
@@ -706,7 +756,7 @@
|
|
|
706
756
|
outline: 2px solid var(--lb-primary-color);
|
|
707
757
|
outline-offset: 2px;
|
|
708
758
|
}
|
|
709
|
-
`,
|
|
759
|
+
`,Ve=`/* Lime Bundles \u2014 Mix & Match styles */
|
|
710
760
|
|
|
711
761
|
/* === Progress Bar === */
|
|
712
762
|
.lb-mix-match__progress {
|
|
@@ -1192,7 +1242,7 @@
|
|
|
1192
1242
|
transition: none;
|
|
1193
1243
|
}
|
|
1194
1244
|
}
|
|
1195
|
-
`,
|
|
1245
|
+
`,Ue=`/* Lime Bundles \u2014 Volume / Quantity Breaks styles */
|
|
1196
1246
|
|
|
1197
1247
|
.lb-volume__tiers {
|
|
1198
1248
|
display: flex;
|
|
@@ -1302,12 +1352,138 @@
|
|
|
1302
1352
|
}
|
|
1303
1353
|
|
|
1304
1354
|
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1355
|
+
`,Oe=`/* Lime Bundles \u2014 web-component loading skeleton (not mirrored to theme assets) */
|
|
1356
|
+
|
|
1357
|
+
.lb-bundle-widget--loading {
|
|
1358
|
+
display: block;
|
|
1359
|
+
padding: var(--lb-widget-pad, 20px);
|
|
1360
|
+
border: 1px solid var(--lb-border, #E5E5E5);
|
|
1361
|
+
border-radius: var(--lb-radius, 12px);
|
|
1362
|
+
background: var(--lb-bg, #FFFFFF);
|
|
1363
|
+
/* Contain layout/paint so the skeleton doesn't influence ancestor
|
|
1364
|
+
layout once the real content swaps in. */
|
|
1365
|
+
contain: layout paint;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
.lb-bundle-widget--loading .lb-skeleton {
|
|
1369
|
+
background: linear-gradient(
|
|
1370
|
+
90deg,
|
|
1371
|
+
rgba(0, 0, 0, 0.06) 0%,
|
|
1372
|
+
rgba(0, 0, 0, 0.10) 50%,
|
|
1373
|
+
rgba(0, 0, 0, 0.06) 100%
|
|
1374
|
+
);
|
|
1375
|
+
background-size: 200% 100%;
|
|
1376
|
+
border-radius: 6px;
|
|
1377
|
+
animation: lb-skeleton-pulse 1.4s ease-in-out infinite;
|
|
1378
|
+
}
|
|
1379
|
+
|
|
1380
|
+
.lb-bundle-widget--loading .lb-skeleton--title {
|
|
1381
|
+
height: 28px;
|
|
1382
|
+
width: 60%;
|
|
1383
|
+
margin-bottom: 16px;
|
|
1384
|
+
}
|
|
1385
|
+
|
|
1386
|
+
.lb-bundle-widget--loading .lb-skeleton--products {
|
|
1387
|
+
display: grid;
|
|
1388
|
+
gap: 12px;
|
|
1389
|
+
margin-bottom: 16px;
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
.lb-bundle-widget--loading .lb-skeleton--row {
|
|
1393
|
+
display: grid;
|
|
1394
|
+
grid-template-columns: 56px 1fr 60px;
|
|
1395
|
+
gap: 12px;
|
|
1396
|
+
align-items: center;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
.lb-bundle-widget--loading .lb-skeleton--thumb {
|
|
1400
|
+
height: 56px;
|
|
1401
|
+
width: 56px;
|
|
1402
|
+
border-radius: 8px;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
.lb-bundle-widget--loading .lb-skeleton--line {
|
|
1406
|
+
height: 14px;
|
|
1407
|
+
border-radius: 4px;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
.lb-bundle-widget--loading .lb-skeleton--line + .lb-skeleton--line {
|
|
1411
|
+
margin-top: 8px;
|
|
1412
|
+
width: 70%;
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
.lb-bundle-widget--loading .lb-skeleton--price {
|
|
1416
|
+
height: 20px;
|
|
1417
|
+
width: 60px;
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
.lb-bundle-widget--loading .lb-skeleton--footer {
|
|
1421
|
+
margin-top: 16px;
|
|
1422
|
+
padding-top: 16px;
|
|
1423
|
+
border-top: 1px solid var(--lb-border, #E5E5E5);
|
|
1424
|
+
display: grid;
|
|
1425
|
+
grid-template-columns: 1fr auto;
|
|
1426
|
+
gap: 12px;
|
|
1427
|
+
align-items: center;
|
|
1428
|
+
}
|
|
1429
|
+
|
|
1430
|
+
.lb-bundle-widget--loading .lb-skeleton--total {
|
|
1431
|
+
height: 24px;
|
|
1432
|
+
width: 40%;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
.lb-bundle-widget--loading .lb-skeleton--cta {
|
|
1436
|
+
height: 44px;
|
|
1437
|
+
width: 140px;
|
|
1438
|
+
border-radius: var(--lb-cta-radius, 8px);
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
@keyframes lb-skeleton-pulse {
|
|
1442
|
+
0% { background-position: 0% 50%; }
|
|
1443
|
+
100% { background-position: -200% 50%; }
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1447
|
+
.lb-bundle-widget--loading .lb-skeleton {
|
|
1448
|
+
animation: none;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
`;var qt=e=>`lb_cart_id:${e}`;function Nt(e){if(e)return e.trim()||null;if(typeof document<"u"){let t=document.querySelector('meta[name="shopify:product-handle"]');if(t?.content)return t.content.trim()||null}if(typeof window<"u"){let t=window.location.pathname.match(/\/products\/([^/?#]+)/);if(t?.[1])return decodeURIComponent(t[1])}return null}var j=class extends HTMLElement{static observedAttributes=["shop-domain","storefront-token","bundle-gid","product-handle","app-url","analytics","locale"];shadow;bundles=[];abortController=null;impressionCleanups=[];renderCleanups=[];shopCustomCss=null;constructor(){super(),this.shadow=this.attachShadow({mode:"open"})}connectedCallback(){this.fetchBundle()}disconnectedCallback(){this.abortController?.abort(),this.teardownImpressions(),this.teardownRenderers()}teardownImpressions(){for(let t of this.impressionCleanups)t();this.impressionCleanups=[]}teardownRenderers(){for(let t of this.renderCleanups)t();this.renderCleanups=[]}attributeChangedCallback(t,n,i){n===i||!this.isConnected||(t==="bundle-gid"||t==="product-handle"||t==="shop-domain"||t==="storefront-token")&&this.shopDomain&&this.storefrontToken&&this.fetchBundle()}get shopDomain(){return this.getAttribute("shop-domain")??""}get storefrontToken(){return this.getAttribute("storefront-token")??""}get bundleGid(){return this.getAttribute("bundle-gid")??""}get productHandleAttr(){return this.getAttribute("product-handle")??""}get appUrl(){return this.getAttribute("app-url")??""}get analyticsEnabled(){return this.getAttribute("analytics")!=="false"}async fetchBundle(){if(!this.shopDomain||!this.storefrontToken){this.renderError("Missing required attributes: shop-domain, storefront-token");return}this.abortController?.abort();let t=new AbortController;this.abortController=t,this.renderLoading();let n=K({shopDomain:this.shopDomain,accessToken:this.storefrontToken});try{let i,r=!1;if(this.bundleGid)r=!0,i=this.fetchSingleBundle(n,t.signal);else{let d=Nt(this.productHandleAttr);if(!d){this.teardownImpressions(),this.renderError("No bundle-gid or product-handle provided, and the current URL doesn't match /products/<handle>.");return}i=this.fetchProductBundles(n,t.signal,d)}let a=n.query(ce,void 0,{signal:t.signal}).catch(()=>null);if(await i,t.signal.aborted)return;if(r&&this.bundles.length===0){this.teardownImpressions(),this.renderError("Bundle not found");return}let o=await a;if(o?.shop?.metafield?.value){_e(this.shopDomain,o.shop.metafield.value);let d=J(o.shop.metafield.value);d.ok&&(this.shopCustomCss=d.css)}await this.applyABVariants(),this.renderBundles()}catch(i){if(t.signal.aborted)return;this.bundles=[],this.teardownImpressions(),this.renderError(i instanceof Error?i.message:"Failed to load bundle")}}async applyABVariants(){if(!this.appUrl||this.bundles.length===0)return;let t=await Promise.all(this.bundles.map(async n=>{if(!n.abTestId||!n.abVariantB)return n;try{if((await we(this.appUrl,this.shopDomain,n.abTestId,n.id))?.variant==="B")return ge(n)}catch(i){console.warn(`[lime-bundle] A/B assignment failed for bundle ${n.id}; falling back to Variant A.`,i)}return n}));this.bundles=t}async fetchSingleBundle(t,n){let i=await t.query(se,{id:this.bundleGid},{signal:n});if(!i.metaobject){this.bundles=[];return}let r=X(i.metaobject.id,i.metaobject.fields);this.bundles=r?[r]:[]}async fetchProductBundles(t,n,i){let r=await t.query(ue,{handle:i},{signal:n});if(!r.product){this.bundles=[];return}let a=r.product.metafield?.references?.nodes??[],o=[];for(let d of a){let l=X(d.id,d.fields);l&&o.push(l)}this.bundles=o}handleAddToCart=async(t,n)=>{let i=new CustomEvent("lime-bundle:add-to-cart",{detail:{lines:n},bubbles:!0,composed:!0,cancelable:!0}),r=this.dispatchEvent(i);this.reportAddToCartEvent(t,n),r&&await this.defaultAddToCart(n)};async defaultAddToCart(t){if(typeof window>"u")return;let n=K({shopDomain:this.shopDomain,accessToken:this.storefrontToken}),i=window.localStorage,r=qt(this.shopDomain),a=i?.getItem(r)??null;try{let o=null;if(a){let l=(await n.query(be,{cartId:a,lines:t})).cartLinesAdd;l?.userErrors?.length?i?.removeItem(r):l?.cart&&(o=l.cart.checkoutUrl)}if(!o){let l=(await n.query(pe,{input:{lines:t}})).cartCreate;l?.cart&&(i?.setItem(r,l.cart.id),o=l.cart.checkoutUrl)}o?window.location.assign(o):this.dispatchEvent(new CustomEvent("lime-bundle:error",{detail:{message:"Cart creation failed",code:"CART_ERROR"},bubbles:!0,composed:!0}))}catch(o){this.dispatchEvent(new CustomEvent("lime-bundle:error",{detail:{message:o instanceof Error?o.message:"Cart mutation failed",code:"CART_ERROR"},bubbles:!0,composed:!0}))}}reportAddToCartEvent(t,n){if(!this.analyticsEnabled||!this.appUrl)return;let i=n.reduce((a,o)=>a+o.quantity,0),r=n.reduce((a,o)=>{let l=t.products.find(c=>c.variants.nodes.some(p=>p.id===o.merchandiseId))?.variants.nodes.find(c=>c.id===o.merchandiseId),u=l?parseFloat(l.price.amount):0;return a+u*o.quantity},0);ve({shopDomain:this.shopDomain,appUrl:this.appUrl},{bundleGid:t.id,bundleType:t.bundleType,productId:t.products[0]?.id??"",quantity:i,totalPrice:Math.round(r*100)/100})}renderBundles(){this.teardownImpressions(),this.teardownRenderers(),this.shadow.innerHTML="";let t=document.createElement("style");if(t.textContent=[re,De,Ve,Ue].join(`
|
|
1452
|
+
`),this.shadow.appendChild(t),this.shopCustomCss){let i=document.createElement("style");i.setAttribute("data-lime-bundles","shop-custom-css"),i.textContent=this.shopCustomCss,this.shadow.appendChild(i)}for(let i of this.bundles){let r=document.createElement("div");r.className="lb-bundle-widget",r.setAttribute("role","region"),r.setAttribute("aria-label",i.title),r.setAttribute("data-bundle-type",i.bundleType),r.setAttribute("data-bundle-gid",i.id),he(r,i.widgetConfig);let a=d=>this.handleAddToCart(i,d),o=d=>this.renderCleanups.push(d);switch(i.bundleType){case"fixed":Se(r,i,a,o);break;case"mix_match":Pe(r,i,a,o);break;case"volume":Ie(r,i,a,o);break}this.shadow.appendChild(r),this.setupImpressionFor(i,r)}let n=this.bundles[0];this.dispatchEvent(new CustomEvent("lime-bundle:loaded",{detail:{bundleCount:this.bundles.length,bundleTypes:this.bundles.map(i=>i.bundleType),bundleType:n?.bundleType,title:n?.title},bubbles:!0,composed:!0}))}setupImpressionFor(t,n){if(!this.analyticsEnabled||!this.appUrl)return;let i=xe(n,()=>{fe({shopDomain:this.shopDomain,appUrl:this.appUrl},{bundleGid:t.id,bundleType:t.bundleType})});this.impressionCleanups.push(i)}renderLoading(){this.shadow.innerHTML=`
|
|
1453
|
+
<style>${re}</style>
|
|
1454
|
+
<style>${Oe}</style>
|
|
1455
|
+
<div class="lb-bundle-widget lb-bundle-widget--loading" aria-busy="true" aria-label="Loading bundle">
|
|
1309
1456
|
<div class="lb-skeleton lb-skeleton--title"></div>
|
|
1310
|
-
<div class="lb-skeleton
|
|
1457
|
+
<div class="lb-skeleton--products">
|
|
1458
|
+
<div class="lb-skeleton--row">
|
|
1459
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
1460
|
+
<div>
|
|
1461
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1462
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1463
|
+
</div>
|
|
1464
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
1465
|
+
</div>
|
|
1466
|
+
<div class="lb-skeleton--row">
|
|
1467
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
1468
|
+
<div>
|
|
1469
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1470
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1471
|
+
</div>
|
|
1472
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
1473
|
+
</div>
|
|
1474
|
+
<div class="lb-skeleton--row">
|
|
1475
|
+
<div class="lb-skeleton lb-skeleton--thumb"></div>
|
|
1476
|
+
<div>
|
|
1477
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1478
|
+
<div class="lb-skeleton lb-skeleton--line"></div>
|
|
1479
|
+
</div>
|
|
1480
|
+
<div class="lb-skeleton lb-skeleton--price"></div>
|
|
1481
|
+
</div>
|
|
1482
|
+
</div>
|
|
1483
|
+
<div class="lb-skeleton--footer">
|
|
1484
|
+
<div class="lb-skeleton lb-skeleton--total"></div>
|
|
1485
|
+
<div class="lb-skeleton lb-skeleton--cta"></div>
|
|
1486
|
+
</div>
|
|
1311
1487
|
</div>
|
|
1312
|
-
`}renderError(t){this.shadow.innerHTML="",this.dispatchEvent(new CustomEvent("lime-bundle:error",{detail:{message:t,code:"LOAD_ERROR"},bubbles:!0,composed:!0}))}
|
|
1488
|
+
`}renderError(t){this.shadow.innerHTML="",this.dispatchEvent(new CustomEvent("lime-bundle:error",{detail:{message:t,code:"LOAD_ERROR"},bubbles:!0,composed:!0}))}};typeof customElements<"u"&&!customElements.get("lime-bundle")&&customElements.define("lime-bundle",j);return ze(zt);})();
|
|
1313
1489
|
//# sourceMappingURL=lime-bundle.global.js.map
|