"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[33],{116:(e,a,s)=>{s.d(a,{a:()=>g,b:()=>p,c:()=>u,d:()=>m,e:()=>h});var t=s(0),n=s(2),r=s(72),i=s(3),l=s(73),c=s(31),o=s(136),d=s(36);function u(e){const a=e.split("/"),s=a[a.length-1];return parseInt(null!=s?s:"0",10)}function h(e,a){return e.replace(/\{(\w+)\}/g,((e,s)=>{var t;return String(null!==(t=a[s])&&void 0!==t?t:"")}))}function m(e,a,s){const n=h(e,a),i=n.match(/^(.*?)<([^>]+)>(.*)$/);if(!i)return(0,t.jsx)("span",{children:n});const[,l,c,o]=i;return(0,t.jsxs)("span",{children:[l,(0,t.jsx)("button",{type:"button",className:r.a.modalLink,onClick:s,children:c}),o]})}function g({cart:e,sectionProps:a}){var s,g;const[b,x]=(0,n.useState)(!1),_=(0,i.c)((e=>({cart:e.cart,pathname:e.pathname,cartStatus:e.cartStatus,changeCart:e.changeCart,config:e.config,selectedVariant:e.selectedVariant}))),j=null!==(s=_.cart)&&void 0!==s?s:e,v=(0,c.a)(null==j?void 0:j.currency),f=(0,n.useMemo)((()=>a.eligible_products?new Set(a.eligible_products.map((e=>u(e.id)))):new Set),[a.eligible_products]),{eligibleItems:N,eligibleCount:y}=(0,n.useMemo)((()=>{if(!(null==j?void 0:j.items))return{eligibleItems:[],eligibleCount:0};const e=j.items.filter((e=>!!f.has(e.product_id)&&!(0,o.b)(e))),a=e.reduce(((e,a)=>e+a.quantity),0);return{eligibleItems:e,eligibleCount:a}}),[null==j?void 0:j.items,f]);if(0===N.length||!j)return(0,t.jsx)(t.Fragment,{});const C=a.quantity_threshold,k=y>=C,w=Math.max(0,C-y),I=Math.min(100,y/C*100),L=N.reduce(((e,a)=>e+a.discounted_price*a.quantity),0)/100,M=N.reduce(((e,a)=>e+a.original_price*a.quantity),0)/100,S=(y>0?M/y:0)*C,q=S-(null!==(g=a.promotion_price)&&void 0!==g?g:0),V=S>0?Math.round(q/S*100):0,B=k?a.border_color_complete:a.border_color_in_progress,O=h(a.savings_message,{percentage:V,quantity:C});return(0,t.jsxs)("div",{className:r.a.groupContainer,style:{"--border-color":B},children:[(0,t.jsxs)("div",{className:r.a.header,children:[(0,t.jsx)("span",{className:r.a.statusLabel,children:k?a.complete_label:a.in_progress_label}),(0,t.jsx)("span",{className:r.a.promoName,children:a.short_name})]}),(0,t.jsx)("div",{className:r.a.progressMessage,children:k?(0,t.jsxs)("span",{className:r.a.completeMessage,children:[(0,t.jsx)(p,{}),(0,t.jsxs)("span",{children:["You're getting ",V,"% off (-",v(q),")"]})]}):m(a.in_progress_message,{remaining:w},(()=>x(!0)))}),(0,t.jsx)("div",{className:r.a.progressBarContainer,children:(0,t.jsx)("div",{className:r.a.progressBar,style:{width:`${I}%`}})}),(0,t.jsx)("ul",{className:r.a.itemsContainer,"aria-label":"Promotion items",children:N.map(((e,a)=>{var s;return(0,t.jsx)("li",{"aria-label":e.product_title,children:(0,t.jsx)(l.a,Object.assign({},e,{cartItemkKey:e.key,selectedVariantId:null===(s=_.selectedVariant)||void 0===s?void 0:s.variantId,pathname:_.pathname,line:a+1,flags:{moveToWishList:"disabled"},cartStatus:_.cartStatus,changeCart:_.changeCart,height:_.config.product_image_height,width:_.config.product_image_width,hostname:_.config.hostname,currency:j.currency,formatCurrency:v}))},e.key)}))}),(0,t.jsxs)("div",{className:r.a.footer,children:[(0,t.jsxs)("div",{className:r.a.subtotalRow,children:[(0,t.jsx)("span",{className:r.a.subtotalLabel,children:a.offer_subtotal_label}),(0,t.jsx)("span",{className:r.a.subtotalValue,children:v(L)})]}),(0,t.jsx)("div",{className:r.a.savingsRow,children:O})]}),a.eligible_modal_content&&(0,t.jsx)(d.a,{isOpen:b,onClose:()=>x(!1),children:(0,t.jsxs)("div",{className:r.a.modalContent,children:[(0,t.jsx)("h3",{children:a.short_name}),(0,t.jsx)("div",{dangerouslySetInnerHTML:{__html:a.eligible_modal_content}}),(0,t.jsx)("button",{type:"button",className:r.a.okBtn,onClick:()=>x(!1),children:"OK"})]})})]})}function p(){return(0,t.jsxs)("svg",{className:r.a.checkmarkIcon,width:"17",height:"17",viewBox:"0 0 17 17",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,t.jsx)("circle",{cx:"8.5",cy:"8.5",r:"8",fill:"currentColor"}),(0,t.jsx)("path",{d:"M5 8.5L7.5 11L12 6",stroke:"white",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}}}]);