import{F as C,ai as x,r as L,aE as P,P as d,Q as T,_ as c,e,R as o,T as b,W as I,a0 as r,a1 as m,a2 as p}from"./vendor-BmRNukEL.js";import"./index-CfcNWeCf.js";import{a as N}from"./index-B2olPSXy.js";import{u as W}from"./useLoyaltyBalance-DerjKQXO.js";const $={key:0},E={class:"md:py-3 md:text-left"},F=C({__name:"payment-processing-loyalty",props:{order:{}},emits:["success","fail"],setup(f,{emit:_}){const n=_,s=f,{t:B}=x(),l=L(!1),{fetchLoyaltyBalance:k,loading:g,currentBalance:i,resultBalance:a}=W();async function h(){l.value=!0;const{isSuccess:t,errorMessage:y=""}=await N({orderId:s.order.id,paymentId:s.order.inPayments[0].id});l.value=!1,t?n("success"):n("fail",y)}P(async()=>{await k(s.order.id)});async function v(){await h()}function V(){n("fail",B("loyalty.payment.loyalty.errors.insufficient_points",{currentBalance:i.value}))}return(t,y)=>{const u=d("VcButton"),w=d("VcLoaderWithText");return e(g)?(o(),c(w,{key:1})):(o(),T("div",$,[b("p",E,r(t.$t("loyalty.payment.loyalty.text",{currentBalance:e(i)})),1),e(a)!==null&&e(a)!==void 0&&e(a)>=0?(o(),c(u,{key:0,loading:l.value,onClick:v},{default:m(()=>[p(r(t.$t("loyalty.payment.loyalty.pay_now_button")),1)]),_:1},8,["loading"])):e(a)!==null&&e(a)!==void 0&&e(a)<0?(o(),c(u,{key:1,onClick:V},{default:m(()=>[p(r(t.$t("loyalty.payment.loyalty.pay_now_button")),1)]),_:1})):I("",!0)]))}}});export{F as default};
//# sourceMappingURL=payment-processing-loyalty-C6IKZHRU.js.map
