1import{f as lt,r as A,i as D,o as a,c as i,a as e,M as bt,V as _t,z as G,m as y,j as s,d as it,t as d,n as m,b as F,J as xt,F as k,l as nt,w as yt,p as gt,e as Ct}from"./yOJj5uNE.js";import kt from"./DMzx58iQ.js";import{_ as At}from"./D6Y0ded2.js";import{u as Pt}from"./Dzz9IoB7.js";import{u as wt}from"./VSNg6JR7.js";import{u as St,C as g}from"./B8AKEWP8.js";import{_ as Dt}from"./DlAUqK2U.js";import"./C3y0uq1L.js";import"./SNJcfoqu.js";import"./BBgs8E4c.js";import"./DB9citPR.js";import"./CPuWFeW3.js";import"./266f0qLN.js";import"./DwHmOvlT.js";import"./CU1OwxUW.js";import"./BV650Hjl.js";import"./C-8QKdr8.js";import"./Y7zkWUCV.js";import"./DJIia-oI.js";import"./CpDLhqCw.js";import"./CYwy5q5M.js";import"./DN5B0QRB.js";const Rt={class:"flex items-center justify-between w-[216px]"},Et=["disabled"],Vt=["disabled"],$t=["disabled"],It=lt({__name:"QuantitySelector",props:{modelValue:{type:Number,default:0},max:{type:Number,default:0},setMaxCount:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},cstmInput:{type:String}},emits:["update:modelValue"],setup(f,{emit:N}){const o=f,C=N,l=A(o.modelValue),r=()=>{let _=l.value;o.setMaxCount&&o.max>0&&_>o.max&&(_=o.max),_<0&&(_=0),l.value=_,C("update:modelValue",_)},W=()=>{o.disabled||(l.value++,r())},Y=()=>{!o.disabled&&l.value>0&&(l.value--,r())};return D(()=>o.modelValue,_=>{l.value=_}),(_,P)=>(a(),i("div",Rt,[e("button",{onClick:P[0]||(P[0]=R=>Y()),disabled:f.disabled},"-",8,Et),bt(e("input",{type:"number","onUpdate:modelValue":P[1]||(P[1]=R=>l.value=R),onInput:r,disabled:f.disabled,class:G(["w-full text-center bg-white",f.cstmInput])},null,42,Vt),[[_t,l.value,void 0,{number:!0}]]),e("button",{onClick:P[2]||(P[2]=R=>W()),disabled:f.disabled},"+",8,$t)]))}}),p=f=>(gt("data-v-3cc58f8b"),f=f(),Ct(),f),Mt={class:"h-fit bg-gray-100 p-6"},Tt=p(()=>e("h2",{class:"text-lg font-bold mb-8"},"Order Summary",-1)),Ft={key:0,class:"px-3 py-2 mb-2 bg-white"},Gt={class:"flex items-center"},Nt={class:"ml-auto text-xs text-cstm-dark-72"},Wt={key:0,class:"ml-2"},Yt={key:0,class:"flex items-center mt-2"},Lt={class:"w-[216px]"},Bt={class:"flex justify-between space-x-1 mt-2 text-xs"},jt=["onClick","disabled"],Ot=["disabled"],zt={key:1,class:"mb-2 px-3 py-2 bg-white"},Ut=p(()=>e("p",{class:"font-semibold"},"Voucher",-1)),qt={key:0,class:"mt-2"},Jt={class:"flex flex-wrap items-center text-sm space-x-1"},Qt=p(()=>e("p",{class:"text-xs text-cstm-dark-72"},"Applied Vouchers:",-1)),Ht={class:"mr-3"},Kt=["onClick"],Xt={key:2,class:"mb-2 px-3 py-2 bg-white"},Zt=p(()=>e("p",{class:"font-semibold"},"Gift Card",-1)),te={key:0,class:"mt-2"},ee={class:"flex flex-wrap items-center text-sm space-x-1"},se=p(()=>e("p",{class:"text-xs text-cstm-dark-72"},"Applied Gift Card:",-1)),oe={class:"bg-white text-brand-primary px-2 py-1 border rounded-full text-xxs relative flex items-center"},ae={class:"mr-3"},ie={class:"grid grid-cols-2 gap-y-2 mb-4 text-sm"},ne=p(()=>e("p",null,"Subtotal",-1)),le={class:"text-right font-semibold"},re=p(()=>e("p",null,"Voucher Discount",-1)),ue={class:"text-right text-red-500 font-semibold"},de=p(()=>e("p",null,"Delivery Discount",-1)),ce={class:"text-right text-red-500 font-semibold"},me=p(()=>e("p",null,"Gift Card Discount",-1)),pe={class:"text-right text-red-500 font-semibold"},ve=p(()=>e("p",null,"Points Applied",-1)),fe={class:"text-right text-red-500 font-semibold"},he=p(()=>e("p",null,"Points to Earn",-1)),be={class:"text-right font-semibold"},_e=p(()=>e("p",null,"Delivery Fee",-1)),xe={class:"text-right font-semibold"},ye=p(()=>e("p",{class:"pt-2.5 font-semibold"},"TOTAL",-1)),ge={class:"text-right font-bold"},Ce={key:0,class:"text-red-500 text-sm mb-4"},ke=lt({__name:"CheckoutSummary",props:{item:{},form:{},deliveryFee:{},cartId:{},cartType:{},availablePoints:{},availableStoreCredits:{},pointsToEarn:{},appliedVouchers:{},gcApplied:{}},emits:["select-voucher","select-gift-card","place-order","update:form","refetch-computations","validate-order","remove-voucher","remove-giftcard"],setup(f,{emit:N}){const o=f,C=N,{currencyFormatter:l}=Pt(),{addToast:r}=wt(),{applyPoints:W,removePoints:Y,applyStoreCredits:_,removeStoreCredits:P}=St(),R=A(!1),n=A(0),E=A(!1),L=A(0),V=A(null),B=A(null);A(!1);const j=y(()=>o.cartId),h=y(()=>o.availablePoints),rt=y(()=>o.availableStoreCredits),x=y(()=>parseInt(o.cartType)),M=y(()=>x.value!=g.GIFT_CARD&&x.value!=g.REWARD),O=y(()=>{var t;return x.value==g.REWARD&&h.value<((t=o.item)==null?void 0:t.netAmount)}),z=y(()=>{var t;return((t=o.item)==null?void 0:t.netAmount)-h.value}),c=y(()=>{var t;return Math.min(h.value,((t=o.item)==null?void 0:t.netAmount)||0)}),$=y(()=>{var t;return Math.min(rt.value,((t=o.item)==null?void 0:t.netAmount)||0)}),w=t=>
1t.toLocaleString(),ut=async t=>{C("remove-voucher",t)},dt=async t=>{C("remove-giftcard",t)},ct=t=>{if(o.availablePoints===0){r({title:"You have no available points to apply",status:"info",duration:3e3});return}n.value=Math.min(Math.floor(c.value*t/100),c.value),V.value=t};D(n,t=>{var u,v;if(t>c.value)n.value=c.value,V.value=100,r({title:`Maximum allowed points is ${w(c.value)}`,status:"info",duration:3e3});else if(t<((u=o.item)==null?void 0:u.netAmount)&&x.value===g.REWARD)r({title:`You need at least ${w((v=o.item)==null?void 0:v.netAmount)} points to complete this transaction`,status:"warning",duration:3e3});else{const S=[25,50,75,100].reduce((T,I)=>Math.abs(I-t/c.value*100)<Math.abs(T-t/c.value*100)?I:T);V.value=S}});const mt=async()=>{var t,u;if(o.availablePoints===0){r({title:"You have no available points to apply",status:"info",duration:3e3});return}if(x.value===g.REWARD&&n.value<((t=o.item)==null?void 0:t.netAmount)){r({title:`You need at least ${w((u=o.item)==null?void 0:u.netAmount)} points to complete this transaction`,status:"warning",duration:3e3});return}try{E.value?(await Y(j.value),E.value=!1,n.value=0,V.value=null,r({title:"Points removed successfully",status:"success",duration:3e3})):(await W(j.value,n.value,c.value),E.value=!0,r({title:`${n.value} points applied successfully`,status:"success",duration:3e3})),C("refetch-computations")}catch(v){console.error("Error toggling points:",v),r({title:"Failed to apply/remove points. Please try again.",status:"error",duration:5e3})}},pt=async()=>{if(x.value==g.REWARD&&n.value==0){r({title:"Points ",status:"error",duration:5e3});return}if(x.value==g.REWARD&&O.value){r({title:`Insufficient points. You need ${w(z.value)} more points to complete this transaction.`,status:"error",duration:5e3});return}C("place-order")};function vt(){C("select-voucher")}function ft(){C("select-gift-card")}return D(n,t=>{var u,v;t>c.value?(n.value=c.value,r({title:`Maximum allowed points is ${w(c.value)}`,status:"info",duration:3e3})):t<((u=o.item)==null?void 0:u.netAmount)&&x.value===g.REWARD&&r({title:`You need at least ${w((v=o.item)==null?void 0:v.netAmount)} points to complete this transaction`,status:"warning",duration:3e3})}),D(L,t=>{if(t>$.value)L.value=$.value,B.value=100,r({title:`Maximum allowed store credit is ${l($.value)}`,status:"info",duration:3e3});else{const u=[25,50,75,100].reduce((v,S)=>Math.abs(S-t/$.value*100)<Math.abs(v-t/$.value*100)?S:v);B.value=u}}),D(()=>o.availableStoreCredits,t=>{t===0&&(L.value=0,R.value=!1)}),D(()=>o.availablePoints,t=>{t===0&&(n.value=0,E.value=!1)}),(t,u)=>{var I,U,q,J,Q,H,K,X,Z,tt,et,st,ot,at;const v=It,S=kt,T=At;return a(),i("div",Mt,[Tt,s(M)?(a(),i("div",Ft,[e("div",Gt,[e("p",{class:G(["font-semibold text-sm",{"text-xs text-cstm-dark-72 font-normal uppercase":s(h)!=0}])}," Points ",2),e("p",Nt,[it(" AVAILABLE: "),e("span",{class:G(["",s(n)>0?"line-through":""])},d(s(h))+" PTS ",3),s(n)>0?(a(),i("span",Wt,d(s(h)-s(n))+" PTS ",1)):m("",!0)])]),s(h)!=0?(a(),i("div",Yt,[e("div",Lt,[F(v,{modelValue:s(n),"onUpdate:modelValue":u[0]||(u[0]=b=>xt(n)?n.value=b:null),max:s(c),disabled:s(h)===0||s(c)===0},null,8,["modelValue","max","disabled"]),e("div",Bt,[(a(),i(k,null,nt([25,50,75,100],b=>e("button",{key:b,onClick:ht=>ct(b),class:G(["px-3.5 py-0.5",s(V)===b?"bg-brand-primary text-white":"text-cstm-dark-72 bg-cstm-dark-8"]),disabled:s(h)===0||s(c)===0},d(b)+"% ",11,jt)),64))])]),e("button",{onClick:mt,class:"ml-auto text-sm underline",disabled:s(h)===0||s(n)===0},d(s(E)?"REMOVE":"APPLY"),9,Ot)])):m("",!0)])):m("",!0),s(M)?(a(),i("div",zt,[e("div",{class:"flex justify-between items-center text-sm"},[Ut,e("button",{onClick:vt,class:"underline"},"SELECT")]),((I=t.appliedVouchers)==null?void 0:I.length)>0?(a(),i("div",qt,[e("div",Jt,[Qt,(a(!0),i(k,null,nt(t.appliedVouchers,b=>(a(),i("div",{key:b.id,class:"bg-white text-brand-primary px-2 py-1 border rounded-full text-xxs relative flex items-center"},[e("p",Ht,d(b.name),1),e("button",{onClick:ht=>ut(b.id),class:"absolute bottom-0 right-0.5 text-cstm-dark-72 rounded-full hover:bg-cstm-dark-8 p-0.5 transition-colors"},[F(S,{name:"heroicons:x-mark",class:"w-3 h-3"})],8,Kt)]))),128))])])):m("",!0)])):m("",!0),s(M)?(a(),i("div",Xt,[e("div",{class:"flex justify-between items-center text-sm"},[Zt,e("button",{onClick:ft,class:"underline"}," SELECT ")]),t.gcApplied?(a(),i("div",te,[e("div",ee,[se,e("div",oe,[e("p",ae,d((U=t.gcApplied)==null?void 0:U.gift_card_no),1),e("button",{onClick:u[1]||(u[1]=b=>dt(t.gcApplied.id)),class:"absolute bottom-0 right-0.5 text-cstm-dark-72 rounded-full hover:bg-cstm-dark-8 p-0.5 transition-colors"},[F(S,{name:"heroicons:x-mark",class:"w-3 h-3"})])])])])):m("",!0)])):m("",!0),e("div",ie,[ne,e("p",le,d(s(l)((q=t.item)==null?void 0:q.subtotalAmount)),1),(J=t.item)!=null&&J.voucherDiscountAmount?(
1a(),i(k,{key:0},[re,e("p",ue," - "+d(s(l)((Q=t.item)==null?void 0:Q.voucherDiscountAmount)),1)],64)):m("",!0),(H=t.item)!=null&&H.shippingDiscountAmount?(a(),i(k,{key:1},[de,e("p",ce," - "+d(s(l)((K=t.item)==null?void 0:K.shippingDiscountAmount)),1)],64)):m("",!0),(X=t.item)!=null&&X.usedGiftCard?(a(),i(k,{key:2},[me,e("p",pe," - "+d(s(l)((Z=t.item)==null?void 0:Z.usedGiftCard)),1)],64)):m("",!0),(tt=t.item)!=null&&tt.usedPoint?(a(),i(k,{key:3},[ve,e("p",fe," - "+d(s(l)((et=t.item)==null?void 0:et.usedPoint)),1)],64)):m("",!0),he,e("p",be,d(((st=t.item)==null?void 0:st.earnedPoint)||0)+" pts ",1),s(M)?(a(),i(k,{key:4},[_e,e("p",xe,d(s(l)(((ot=t.item)==null?void 0:ot.deliveryFee)||0)),1),ye,e("p",ge,d(s(l)((at=t.item)==null?void 0:at.amountDue)),1)],64)):m("",!0)]),s(h)?(a(),i(k,{key:3},[s(x)==s(g).REWARD&&s(O)?(a(),i("div",Ce," Insufficient points to complete the transaction. You need "+d(w(s(z)))+" more points. ",1)):m("",!0)],64)):m("",!0),F(T,{class:"mb-4",block:"",onClick:pt},{default:yt(()=>[it(" PAY NOW ")]),_:1})])}}}),Ue=Dt(ke,[["__scopeId","data-v-3cc58f8b"]]);export{Ue 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.