import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{At as t,Ht as n}from"./vendor-react-N_fu9J_Y.js";import{Ot as r}from"./Storyblok-DGCBwXgG.js";import{t as i}from"./Button-CfyTBrFT.js";import"./Button-CpxzSFWT.js";import{h as a,r as o}from"./index-s_pEm3oX.js";import{t as s}from"./Accordion-by5YIl45.js";import{t as c}from"./useCheckoutPromotionCodeInput-BFfw3h6N.js";var l=e(n()),u=t(),d=()=>{let{checkout:e}=r(),[t,n]=(0,l.useState)(``),{onApplyCoupon:d,t:f,loading:p}=c(),m=e?.cart?.appliedPromotions?.filter(e=>e.redemptionType===`COUPON`),h=m?.reduce((e,t)=>e+t.rewards.reduce((e,t)=>e+(t.amount??0),0),0),g=()=>{let e=t.trim();e&&d(e)};return(0,u.jsx)(s,{name:`coupon`,tabRightLabelContent:h!=null&&h>0&&(0,u.jsxs)(`span`,{className:`text-[14px]`,children:[`-`,a({value:h})]}),title:(0,u.jsx)(`h1`,{className:`font-suisse-works text-[18px] md:text-[16px]`,children:f(`checkout.coupon`,`Coupon`)}),defaultOpen:!!m?.length,className:`px-0`,children:(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`label`,{className:`block text-[14px] mb-[4px]`,htmlFor:`promotionCode`,children:f(`checkout.ifcoupon`,`If you have a coupon, please fill it in here`)}),(0,u.jsxs)(`form`,{className:`flex gap-[8px]`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,u.jsx)(o,{name:`promotionCode`,type:`text`,required:!0,value:t,onChange:e=>n(e.target.value),disabled:p}),(0,u.jsx)(i,{disabled:p||!t.trim(),type:`submit`,classes:{buttonModifier:`!h-auto`},children:f(`checkout.apply`,`Apply`)})]})]})})};export{d as default};