import{$ as e,C as t,G as n,S as r,Wt as i,_ as a,dt as o,g as s,h as c,u as l,vt as u,z as d,zt as f}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{n as p}from"./vue-i18n-C4HYJWrq.js";import{J as m,Mn as h,W as g,Z as _,tt as v}from"./main-CVDkKXbu.js";import{t as y}from"./payment-BJf_N1nO.js";var b={class:`flex justify-between w-full`},x={class:`p-4 sm:p-6`},S={class:`z-0 flex justify-end p-4 border-t border-gray-200 border-solid`},C={__name:`PaymentModeModal`,setup(C){let w=v(),T=y(),{t:E}=p(),D=o(!1),O=h(c(()=>({currentPaymentMode:{name:{required:g.withMessage(E(`validation.required`),_),minLength:g.withMessage(E(`validation.name_min_length`,{count:3}),m(3))}}})),c(()=>T)),k=c(()=>w.active&&w.componentName===`PaymentModeModal`);async function A(){if(O.value.currentPaymentMode.$touch(),O.value.currentPaymentMode.$invalid)return!0;try{let e=T.currentPaymentMode.id?T.updatePaymentMode:T.addPaymentMode;D.value=!0,await e(T.currentPaymentMode),D.value=!1,w.refreshData&&w.refreshData(),j()}catch{return D.value=!1,!0}}function j(){w.closeModal(),setTimeout(()=>{O.value.$reset(),T.currentPaymentMode={id:``,name:null}})}return(o,c)=>{let p=n(`BaseIcon`),m=n(`BaseInput`),h=n(`BaseInputGroup`),g=n(`BaseButton`),_=n(`BaseModal`);return d(),a(_,{show:k.value,onClose:j},{header:e(()=>[s(`div`,b,[r(i(u(w).title)+` `,1),t(p,{name:`XMarkIcon`,class:`w-6 h-6 text-gray-500 cursor-pointer`,onClick:j})])]),default:e(()=>[s(`form`,{action:``,onSubmit:l(A,[`prevent`])},[s(`div`,x,[t(h,{label:o.$t(`settings.payment_modes.mode_name`),error:u(O).currentPaymentMode.name.$error&&u(O).currentPaymentMode.name.$errors[0].$message,required:``},{default:e(()=>[t(m,{modelValue:u(T).currentPaymentMode.name,"onUpdate:modelValue":c[0]||=e=>u(T).currentPaymentMode.name=e,invalid:u(O).currentPaymentMode.name.$error,onInput:c[1]||=e=>u(O).currentPaymentMode.name.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`label`,`error`])]),s(`div`,S,[t(g,{variant:`primary-outline`,class:`mr-3`,type:`button`,onClick:j},{default:e(()=>[r(i(o.$t(`general.cancel`)),1)]),_:1}),t(g,{loading:D.value,disabled:D.value,variant:`primary`,type:`submit`},{left:e(e=>[t(p,{name:`ArrowDownOnSquareIcon`,class:f(e.class)},null,8,[`class`])]),default:e(()=>[r(` `+i(u(T).currentPaymentMode.id?o.$t(`general.update`):o.$t(`general.save`)),1)]),_:1},8,[`loading`,`disabled`])])],32)]),_:1},8,[`show`])}}};export{C as t};