import{F as C,ag as x,r as L,aN as P,P as d,Q as N,_ as c,e,R as o,T,W as b,a0 as r,a1 as m,a2 as p}from"./vendor-DYYUXsKb.js";import"./index-BjgfEvRF.js";import{a as I}from"./index-CkxY7VIr.js";import{u as W}from"./useLoyaltyBalance-GK8ZOoLc.js";const $={key:0},M={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 I({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(),N("div",$,[T("p",M,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-PuELM8Th.js.map
