function __vite__mapDeps(indexes) {
  if (!__vite__mapDeps.viteFileDeps) {
    __vite__mapDeps.viteFileDeps = ["./DapPlxPc.js","./HiZVHV0m.js","./DlAUqK2U.js"]
  }
  return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
}
import{W as U,E as B,d as Y,t as q,u as G,s as J,w as X,l as oo,r as p,I as eo,o as n,c,a as s,v as k,x as o,aZ as to,z as g,C as L,A as l,k as P,y as f,a0 as no,F as so,B as ao,T as ro,U as co,a3 as lo,ak as io,a4 as uo,M as mo,Z as po}from"./HiZVHV0m.js";import{_ as fo}from"./SA49jxuS.js";import{_ as _o}from"./i17-DgYL.js";const yo=["promotion-discount-added"],ko=()=>{const{pushError:i,pushSuccess:d}=U(),{consumeCartErrors:C}=B();return{codeErrorsNotification:()=>{const a=C();a&&Object.keys(a).forEach(_=>{yo.includes(a[_].messageKey)?d(a[_].message):i(a[_].message)})}}},Co=ro(()=>co(()=>import("./DapPlxPc.js"),__vite__mapDeps([0,1,2]),import.meta.url).then(i=>i.default||i)),vo={class:"mb-4"},ho={class:"flex gap-3"},bo={key:0},go={key:1},wo={key:2},xo={key:0},Po={role:"list",class:"text-sm pl-0"},Eo=["onClick"],No=Y({__name:"CheckoutPromotionCode",props:{hidePromotionCodes:{type:Boolean,default:!1}},async setup(i){let d,C;const E=i,{cartAlertLink:a}=q().configuration.value,{apiClient:_}=G(),{appliedPromotionCodes:I,addPromotionCode:N,removeItem:S,consumeCartErrors:T,refreshCart:$}=B(),{codeErrorsNotification:F}=ko(),{log:V}=po(),{load:D,translate:K}=J(),{data:j}=([d,C]=X(()=>oo(()=>D([{key:"frontend.cart.promoCode.placeholder"},{key:"frontend.cart.promoCode.submit"},{key:"frontend.cart.promoCode.success"},{key:"frontend.cart.promoCode.failure"},{key:"frontend.cart.promoCode.failureLink"},{key:"frontend.cart.promoCode.noInput"},{key:"frontend.cart.promoCode.topLabel"}]),"$80RxZr5Q60")),d=await d,C(),d),r=K(j),v=p(!1),u=p(null),h=p(!1),w=p({}),z=async t=>{try{w.value=await _.invoke("readCms post /cms/{id}",{id:t})}catch(e){V.error("[monari][checkoutPromotionCode][loadCmsPageByIds]: "+e.message)}},A=async()=>{if(u.value=null,h.value=!1,y.value.length<3){h.value=!0;return}await N(y.value),await $();const t=T(),e=p(!1);t&&Object.keys(t).forEach(x=>{const b=t[x];b.level<=0&&b.messageKey.startsWith("promotion-discount-added")&&(e.value=!0)}),u.value=e.value,y.value=""},M=t=>{S(t),F()},O=eo(()=>I.value.length>0),y=p("");return(t,e)=>{const x=fo,b=_o,Z=Co,H=lo,R=io,W=uo,Q=mo;return n(),c("div",null,[s("div",vo,[s("div",ho,[k(x,{name:"promoCode",placeholder:o(r)({key:"frontend.cart.promoCode.placeholder",fallback:"Promotion code"}),value:o(y),onInput:e[0]||(e[0]=m=>y.value=m.target.value),onKeyup:to(A,["enter"])},null,8,["placeholder","value"]),k(b,{onClick:A},{default:g(()=>[L(l(o(r)({key:"frontend.cart.promoCode.submit",fallback:"Add"})),1)]),_:1})])]),s("div",null,[k(no,{"enter-active-class":"transition ease-out duration-300 transform","enter-from-class":"opacity-0","enter-to-class":"opacity-100","leave-active-class":"transition ease-in duration-300 transform","leave-from-class":"opacity-100","leave-to-class":"opacity-0"},{default:g(()=>[typeof("unref"in t?t.unref:o(o))(o(u))=="boolean"||o(h)?(n(),P(Z,{key:0,class:"mb-4 w-full",type:o(u)?"success":"error"},{default:g(()=>[o(u)===!0?(n(),c("span",bo,l(o(r)({key:"frontend.cart.promoCode.success",fallback:"The code has been successfully applied to your order."})),1)):f("",!0),o(u)===!1?(n(),c("span",go,[L(l(o(r)({key:"frontend.cart.promoCode.failure",fallback:"This promotion code could not be found or is invalid. You can find more information"}))+" ",1),s("button",{class:"link-underline link-underline-colored",onClick:e[1]||(e[1]=m=>{v.value=!0,z(o(a))})},l(o(r)({key:"frontend.cart.promoCode.failureLink",fallback:"here."})),1)])):o(h)?(n(),c("span",wo,l(o(r)({key:"frontend.cart.promoCode.noInput",fallback:"Enter a promotion code."})),1)):f("",!0)]),_:1},8,["type"])):f("",!0)]),_:1}),o(v)?(n(),P(W,{key:0,class:"[&_.modal]:lg:min-w-[500px]",show:o(v),onClose:e[2]||(e[2]=()=>v.value=!1)},{default:g(()=>[o(w).sections?f("",!0):(n(),P(H,{key:0,class:"mx-auto mb-8",type:"small"})),k(R,{content:o(w)},null,8,["content"])]),_:1},8,["show"])):f("",!0)]),o(O)&&!E.hidePromotionCodes?(n(),c("div",xo,[s("div",null,l(o(r)({key:"frontend.cart.promoCode.topLabel",fallback:"Promotion code"}))+":",1),s("ul",Po,[(n(!0),c(so,null,ao(o(I),m=>(n(),c("li",{key:m.id,class:"flex justify-between text-gray-600 border-b py-4"},[s("span",null,l(m.label),1),s("button",{class:"text-brand-dark",type:"button",onClick:Io=>M(m)},[k(Q,{icon:"fa-light fa-xmark",class:"!h-5"})],8,Eo)]))),128))])])):f("",!0)])}}});export{No as _,ko as u};
