import{J as S,B as V,k as h,L as g,M as C,N as k,T as N,r as i,o as b,l as B,w as r,h as c,i as p,t as f,u as e,f as l,m as j,j as x,U as q}from"./vendor.d12b5734.js";import{p as z,c as D}from"./main.465728e1.js";const L={class:"flex justify-between w-full"},T=["onSubmit"],E={class:"p-8 sm:p-6"},G={class:"z-0 flex justify-end p-4 border-t border-gray-200 border-solid border-modal-bg"},F={setup(J){const t=z(),a=D(),{t:v}=S();let s=V(!1);const $=h(()=>({name:{required:g.withMessage(v("validation.required"),C),minLength:g.withMessage(v("validation.name_min_length",{count:3}),k(3))}})),n=N($,h(()=>t.currentItemUnit));async function U(){if(n.value.$touch(),n.value.$invalid)return!0;try{const o=t.isItemUnitEdit?t.updateItemUnit:t.addItemUnit;s.value=!0,await o(t.currentItemUnit),a.refreshData&&a.refreshData(),u(),s.value=!1}catch{return s.value=!1,!0}}function u(){a.closeModal(),setTimeout(()=>{t.currentItemUnit={id:null,name:""},a.$reset(),n.value.$reset()},300)}return(o,m)=>{const _=i("BaseIcon"),y=i("BaseInput"),w=i("BaseInputGroup"),I=i("BaseButton"),M=i("BaseModal");return b(),B(M,{show:e(a).active&&e(a).componentName==="ItemUnitModal",onClose:u},{header:r(()=>[c("div",L,[p(f(e(a).title)+" ",1),l(_,{name:"XIcon",class:"w-6 h-6 text-gray-500 cursor-pointer",onClick:u})])]),default:r(()=>[c("form",{action:"",onSubmit:q(U,["prevent"])},[c("div",E,[l(w,{label:o.$t("settings.customization.items.unit_name"),error:e(n).name.$error&&e(n).name.$errors[0].$message,variant:"horizontal",required:""},{default:r(()=>[l(y,{modelValue:e(t).currentItemUnit.name,"onUpdate:modelValue":m[0]||(m[0]=d=>e(t).currentItemUnit.name=d),invalid:e(n).name.$error,type:"text",onInput:m[1]||(m[1]=d=>e(n).name.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["label","error"])]),c("div",G,[l(I,{type:"button",variant:"primary-outline",class:"mr-3 text-sm",onClick:u},{default:r(()=>[p(f(o.$t("general.cancel")),1)]),_:1}),l(I,{loading:e(s),disabled:e(s),variant:"primary",type:"submit"},{left:r(d=>[e(s)?x("",!0):(b(),B(_,{key:0,name:"SaveIcon",class:j(d.class)},null,8,["class"]))]),default:r(()=>[p(" "+f(e(t).isItemUnitEdit?o.$t("general.update"):o.$t("general.save")),1)]),_:1},8,["loading","disabled"])])],40,T)]),_:1},8,["show"])}}};export{F as _};
