1import{C as o}from"./events-Dm1k7AS7.js";document.addEventListener("alpine:init",()=>{Alpine.data("bundleTransform",n=>({sizes:n.sizes||[],activeSize:(n.sizes||[]).find(e=>e.handle===n.currentHandle)||n.sizes?.[0]||null,requiredItem:n.requiredItem||null,selected:{},isSubmitting:!1,isInViewport:!0,init(){const e=new URL(window.location.href);e.searchParams.has("variant")&&(e.searchParams.delete("variant"),history.replaceState({},"",e)),requestAnimationFrame(()=>{const t=new IntersectionObserver(([i])=>{this.isInViewport=i.isIntersecting},{threshold:0});t.observe(this.$el),this.$cleanup(()=>t.disconnect())})},_syncUrl(e){const t=new URLSearchParams(location.search);t.delete("variant");const i=t.toString();history.replaceState({},"",e.url+(i?"?"+i:"")+location.hash)},get bundleSize(){return this.activeSize?.size??n.bundleSize},get bundleVariantGid(){return this.activeSize?.variantGid??n.bundleVariantGid},get bundleTitle(){return this.activeSize?.title??n.bundleTitle},get bundlePrice(){return this.activeSize?.price??0},get compareAtPrice(){return this.activeSize?.comparePrice??0},get hasSavings(){return this.compareAtPrice>this.bundlePrice},get savings(){return this.compareAtPrice-this.bundlePrice},get totalSelected(){return Object.values(this.selected).reduce((e,t)=>e+t.quantity,0)},get remaining(){return this.bundleSize-this.totalSelected},get isComplete(){return this.totalSelected===this.bundleSize},get atLimit(){return this.totalSelected>=this.bundleSize},get selectedList(){return Object.entries(this.selected).map(([e,t])=>({variantId:e,...t}))},get allPips(){return Array.from({length:this.bundleSize},(e,t)=>t)},get emptySlots(){return Array.from({length:Math.max(0,this.bundleSize-this.totalSelected)},(e,t)=>t)},get sidebarSubtitle(){return this.totalSelected===0?`Choose ${this.bundleSize} varieties to continue`:this.remaining>0?`${this.remaining} more slot${this.remaining>1?"s":""} to go`:"Ready to add!"},get mobileCountText(){return this.isComplete?"Bundle ready!":`${this.totalSelected} of ${this.bundleSize} selected`},formatMoney(e){if(window.NSMoney)return window.NSMoney.format(e);const t=n.moneyFormat||"${{amount}}",i=e/100,s=i.toFixed(2),r=Math.floor(i).toString();return t.replace("{{amount}}",s).replace("{{amount_no_decimals}}",r).replace("{{amount_with_comma_separator}}",s.replace(".",",")).replace("{{amount_no_decimals_with_comma_separator}}",r).replace("{{amount_with_apostrophe_separator}}",s.replace(".","'")).replace("{{amount_no_decimals_with_apostrophe_separator}}",r)},selectSize(e){this.activeSize=e,this.selected={},this._syncUrl(e)},isSelected(e){return!!this.selected[String(e)]},getQuantity(e){return this.selected[String(e)]?.quantity||0},toggleItem(e,t,i){const s=String(e);if(this.selected[s]){const r={...this.selected};delete r[s],this.selected=r}else{if(this.atLimit)return;this.selected={...this.selected,[s]:{title:t,quantity:1,imageSrc:i||""}}}},removeItem(e){const t=String(e),i={...this.selected};delete i[t],this.selected=i},increment(e){const t=String(e);!this.selected[t]||this.atLimit||(this.selected={...this.selected,[t]:{...this.selected[t],quantity:this.selected[t].quantity+1}})},decrement(e){const t=String(e);if(!this.selected[t])return;const i=this.selected[t].quantity-1;if(i<=0){const s={...this.selected};delete s[t],this.selected=s}else this.selected={...this.selected,[t]:{...this.selected[t],quantity:i}}},async addToCart(){if(!(!this.isComplete||this.isSubmitting)){this.isSubmitting=!0;try{const e=`ns-bundle-${Date.now()}`,t={};for(const a of this.selectedList)t[parseInt(a.variantId)]=a.quantity;const i=this.selectedList.map(a=>({t:a.title,q:a.quantity,img:a.imageSrc||""}));this.requiredItem&&i.unshift({t:this.requiredItem.title,q:1,img:this.requiredItem.imageSrc||""});const s=JSON.stringify(i),d=[{id:parseInt(this.bundleVariantGid.split("/").pop()),quantity:1,properties:{_bundle_id:e,_bundle_components:JSON.stringify(t),_components_display:s}}],l=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:d})});if(!l.ok)throw new Error(await l.text());const c=await l.json();document.dispatchEvent(new CustomEvent(o.ADD,{detail:c})),this.selected={}}catch{window.dispatchEvent(new CustomEvent(o.ERROR,{detail:{message:"Failed to add bundle to cart. Please try again."}}))}finally{this.isSubmitting=!1}}}}))});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.