var d=(c,p,a)=>new Promise((m,r)=>{var l=o=>{try{s(a.next(o))}catch(n){r(n)}},u=o=>{try{s(a.throw(o))}catch(n){r(n)}},s=o=>o.done?m(o.value):Promise.resolve(o.value).then(l,u);s((a=a.apply(c,p)).next())});import{bi as i,b6 as e}from"./bootstrap-Bqxdt4iG.js";import{u as g}from"./useEntityForm-CMwp7TbN.js";import{a1 as y,ai as b,aj as x,a9 as P}from"../jse/index-index-BUJ_4tQs.js";const k=y({__name:"warehouse-form",props:{warehouse:{default:null},mode:{}},emits:["cancel","submit"],setup(c,{expose:p,emit:a}){const m=c,r=a,l={code:"",name:"",address:"",postcode:"",city:"",state:"",country:"MALAYSIA"},u=[{component:"Input",componentProps:{"data-testid":"warehouse-form-code-input",id:"warehouse-form-code-input",placeholder:e("page.warehouses.form.codePlaceholder"),maxlength:3},fieldName:"code",label:e("page.warehouses.form.code"),rules:i().regex(/^\d{3}$/,"Warehouse code must be exactly 3 digits (e.g. 001, 002)")},{component:"Input",componentProps:{"data-testid":"warehouse-form-name-input",placeholder:e("page.warehouses.form.namePlaceholder"),maxlength:100},fieldName:"name",label:e("page.warehouses.form.name"),rules:i().min(1,e("page.warehouses.form.nameRequired")).max(100,e("page.warehouses.form.nameMaxLength",{max:100}))},{component:"Textarea",componentProps:{"data-testid":"warehouse-form-address-input",placeholder:e("page.warehouses.form.addressPlaceholder"),maxlength:200,autoSize:{minRows:2}},fieldName:"address",label:e("page.warehouses.form.address")},{component:"Input",componentProps:{"data-testid":"warehouse-form-postcode-input",placeholder:e("page.warehouses.form.postcodePlaceholder"),maxlength:10},fieldName:"postcode",label:e("page.warehouses.form.postcode")},{component:"Input",componentProps:{"data-testid":"warehouse-form-city-input",placeholder:e("page.warehouses.form.cityPlaceholder"),maxlength:50},fieldName:"city",label:e("page.warehouses.form.city")},{component:"Input",componentProps:{"data-testid":"warehouse-form-state-input",placeholder:e("page.warehouses.form.statePlaceholder"),maxlength:50},fieldName:"state",label:e("page.warehouses.form.state")},{component:"Input",componentProps:{"data-testid":"warehouse-form-country-input",placeholder:e("page.warehouses.form.countryPlaceholder"),maxlength:100},fieldName:"country",label:e("page.warehouses.form.country"),rules:"required"}],{Form:s,focus:o,isDirty:n,resetForm:h,submitForm:f,watchEntity:w}=g({emptyValues:l,firstInputId:"warehouse-form-code-input",schema:u,wrapperClass:"grid-cols-1"});return w(()=>m.warehouse,()=>m.mode),p({cancel:()=>{r("cancel")},focus:o,isDirty:n,resetForm:h,submit:()=>d(null,null,function*(){const t=yield f();t&&(t.country&&(t.country=String(t.country).toUpperCase()),r("submit",t))})}),(t,_)=>(x(),b(P(s)))}});export{k as _};
