import{F as C,ai as x,aD as L,P as d,Q as P,_ as c,e,R as o,T,W as b,a0 as r,a1 as m,a2 as p,r as I}from"./vendor-Di1tOLi3.js";import"./index-BrdDZgk2.js";import{a as N}from"./index-Cbaw7bIg.js";import{u as W}from"./useLoyaltyBalance-BMuXdk3n.js";const $={key:0},D={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=I(!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)}L(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(),P("div",$,[T("p",D,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})):b("",!0)]))}}});export{F as default};
//# sourceMappingURL=payment-processing-loyalty-CBIKAHNI.js.map
