1import{d as x}from"./chunk--chunk-QYJY6RNA.vbt.js";var w=class{constructor(t,o){this.el=t;try{this.tiers=JSON.parse(t.getAttribute("data-tiers")||"[]")}catch(r){this.tiers=[]}this.track=t.querySelector("[data-progress-track]"),this.progress=t.querySelector("[data-progress]"),this.nodes=Array.from(t.querySelectorAll("[data-tier]")),this.remaining=t.querySelectorAll("[data-remaining]"),this.reward=t.querySelectorAll("[data-reward]"),this.completeReward=t.querySelectorAll("[data-complete-reward]"),this.noItems=t.querySelector("[data-tierbar-no-items]"),this.progressMsg=t.querySelector("[data-tierbar-progress]"),this.progressFreeship=t.querySelector("[data-tierbar-progress-freeship]"),this.complete=t.querySelector("[data-tierbar-complete]"),this.attachListeners()}attachListeners(){let t=()=>x(this,null,function*(){try{let r=yield(yield fetch("/cart.js")).json(),g=new Set((r.items||[]).map(h=>h.product_id)),n=(r.items||[]).some(h=>h.selling_plan_allocation&&h.selling_plan_allocation.selling_plan);this.update(r.items_subtotal_price,r.item_count,g,n)}catch(o){}});document.addEventListener("ajaxcart refresh",t),t()}isNumeric(t){return t.trigger==="subtotal"||t.trigger==="quantity"}isReached(t,o,r,g){switch(t.trigger){case"any":return r>=1;case"product":return t.product_id!=null&&g.has(t.product_id);case"quantity":return r>=t.threshold;default:return o>=t.threshold}}formatMoney(t){return(t/100).toLocaleString("en-US",{style:"currency",currency:"USD"})}update(t,o,r,g){let n=this.tiers.map(e=>g&&e.freeship?Object.assign({},e,{threshold:0}):e),h=n.length;if(!h)return;r||(r=new Set);let s=-1;n.forEach((e,i)=>{this.isReached(e,t,o,r)&&(s=i)}),this.nodes.forEach((e,i)=>{let l=i<=s,d=e.querySelector("[data-tier-circle]"),m=e.querySelector("[data-tier-check]");d&&(d.classList.toggle("bg-blue-light",l),d.classList.toggle("text-cream",l),d.classList.toggle("bg-cream2",!l)),m&&m.classList.toggle("hidden",!l)});let p=h-1,y=e=>p<=0?100:e/p*100,c;if(p===0){let e=n[0];if(!this.isNumeric(e))c=s===0?100:0;else if(e.threshold>0){let i=e.trigger==="quantity"?o:t;c=Math.max(0,Math.min(100,i/e.threshold*100))}else c=100}else if(s===-1)c=0;else if(s>=p)c=100;else{let e=n[s+1];if(!this.isNumeric(e))c=y(s);else{let i=n[s],l=this.isNumeric(i)&&i.trigger===e.trigger?i.threshold:0,d=e.trigger==="quantity"?o:t,m=e.threshold-l,S=m>0?(d-l)/m:1;S=Math.max(0,Math.min(1,S)),c=y(s)+S*(y(s+1)-y(s))}}if(this.progress){let e;c<=0?e="0":c>=100?e="100%":e="calc(var(--tier-node-inset) + (100% - var(--tier-node-inset) * 2) * "+c+" / 100)",this.progress.style.width=e}this.track&&this.track.setAttribute("aria-valuenow",Math.round(c));let a=(e,i)=>{e&&(e.style.display=i?"":"none")};if(o===0){a(this.noItems,!0),a(this.progressMsg,!1),a(this.progressFreeship,!1),a(this.complete,!1);return}if(s>=p){a(this.noItems,!1),a(this.progressMsg,!1),a(this.progressFreeship,!1),a(this.complete,!0);let e=n[h-1].reward;this.completeReward.forEach(i=>i.textContent=e);return}let q=n.some(e=>e.freeship&&this.isReached(e,t,o,r));a(this.noItems,!1),a(this.progressMsg,!q),a(this.progressFreeship,q),a(this.complete,!1);let b=s===-1?0:s+1,f=n[b],u;switch(f.trigger){case"any":u="an item";break;case"product":u=f.product_title||"the featured item";break;case"quantity":{let e=Math.max(0,f.threshold-o);u=e+(e===1?" more item":" more items");break}default:u=this.formatMoney(Math.max(0,f.threshold-t))}this.remaining.forEach(e=>e.textContent=u),this.reward.forEach(e=>e.textContent=f.reward)}},_=w;export{_ as default};
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.