import{J as C,B as N,k as $,L as c,M as b,N as z,aX as j,S as L,T as U,r as i,o as B,l as g,w as l,h as y,i as x,t as v,u as e,f as o,m as D,j as G,U as E}from"./vendor.d12b5734.js";import{q as X,c as J,u as A,k as F}from"./main.465728e1.js";const H={class:"flex justify-between w-full"},K=["onSubmit"],O={class:"p-4 sm:p-6"},P={class:"z-0 flex justify-end p-4 border-t border-solid border--200 border-modal-bg"},Z={setup(Q){const a=X(),u=J();A(),F();const{t:p,tm:R}=C();let d=N(!1);const h=$(()=>({currentTaxType:{name:{required:c.withMessage(p("validation.required"),b),minLength:c.withMessage(p("validation.name_min_length",{count:3}),z(3))},percent:{required:c.withMessage(p("validation.required"),b),between:c.withMessage(p("validation.enter_valid_tax_rate"),j(0,100))},description:{maxLength:c.withMessage(p("validation.description_maxlength",{count:255}),L(255))}}})),r=U(h,$(()=>a));async function w(){if(r.value.currentTaxType.$touch(),r.value.currentTaxType.$invalid)return!0;try{const s=a.isEdit?a.updateTaxType:a.addTaxType;d.value=!0;let t=await s(a.currentTaxType);d.value=!1,u.refreshData&&u.refreshData(t.data.data),m()}catch{return d.value=!1,!0}}function m(){u.closeModal(),setTimeout(()=>{a.resetCurrentTaxType(),r.value.$reset()},300)}return(s,t)=>{const f=i("BaseIcon"),V=i("BaseInput"),T=i("BaseInputGroup"),M=i("BaseMoney"),I=i("BaseTextarea"),S=i("BaseSwitch"),k=i("BaseInputGrid"),_=i("BaseButton"),q=i("BaseModal");return B(),g(q,{show:e(u).active&&e(u).componentName==="TaxTypeModal",onClose:m},{header:l(()=>[y("div",H,[x(v(e(u).title)+" ",1),o(f,{name:"XIcon",class:"h-6 w-6 text-gray-500 cursor-pointer",onClick:m})])]),default:l(()=>[y("form",{action:"",onSubmit:E(w,["prevent"])},[y("div",O,[o(k,{layout:"one-column"},{default:l(()=>[o(T,{label:s.$t("tax_types.name"),variant:"horizontal",error:e(r).currentTaxType.name.$error&&e(r).currentTaxType.name.$errors[0].$message,required:""},{default:l(()=>[o(V,{modelValue:e(a).currentTaxType.name,"onUpdate:modelValue":t[0]||(t[0]=n=>e(a).currentTaxType.name=n),invalid:e(r).currentTaxType.name.$error,type:"text",onInput:t[1]||(t[1]=n=>e(r).currentTaxType.name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),o(T,{label:s.$t("tax_types.percent"),variant:"horizontal",error:e(r).currentTaxType.percent.$error&&e(r).currentTaxType.percent.$errors[0].$message,required:""},{default:l(()=>[o(M,{modelValue:e(a).currentTaxType.percent,"onUpdate:modelValue":t[2]||(t[2]=n=>e(a).currentTaxType.percent=n),currency:{decimal:".",thousands:",",symbol:"% ",precision:2,masked:!1},invalid:e(r).currentTaxType.percent.$error,class:"relative w-full focus:border focus:border-solid focus:border-primary",onInput:t[3]||(t[3]=n=>e(r).currentTaxType.percent.$touch())},null,8,["modelValue","currency","invalid"])]),_:1},8,["label","error"]),o(T,{label:s.$t("tax_types.description"),error:e(r).currentTaxType.description.$error&&e(r).currentTaxType.description.$errors[0].$message,variant:"horizontal"},{default:l(()=>[o(I,{modelValue:e(a).currentTaxType.description,"onUpdate:modelValue":t[4]||(t[4]=n=>e(a).currentTaxType.description=n),invalid:e(r).currentTaxType.description.$error,rows:"4",cols:"50",onInput:t[5]||(t[5]=n=>e(r).currentTaxType.description.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"]),o(T,{label:s.$t("tax_types.compound_tax"),variant:"horizontal",class:"flex flex-row-reverse"},{default:l(()=>[o(S,{modelValue:e(a).currentTaxType.compound_tax,"onUpdate:modelValue":t[6]||(t[6]=n=>e(a).currentTaxType.compound_tax=n),class:"flex items-center"},null,8,["modelValue"])]),_:1},8,["label"])]),_:1})]),y("div",P,[o(_,{class:"mr-3 text-sm",variant:"primary-outline",type:"button",onClick:m},{default:l(()=>[x(v(s.$t("general.cancel")),1)]),_:1}),o(_,{loading:e(d),disabled:e(d),variant:"primary",type:"submit"},{left:l(n=>[e(d)?G("",!0):(B(),g(f,{key:0,name:"SaveIcon",class:D(n.class)},null,8,["class"]))]),default:l(()=>[x(" "+v(e(a).isEdit?s.$t("general.update"):s.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],40,K)]),_:1},8,["show"])}}};export{Z as _};
