var h=(m,i,s)=>new Promise((l,r)=>{var d=t=>{try{c(s.next(t))}catch(n){r(n)}},a=t=>{try{c(s.throw(t))}catch(n){r(n)}},c=t=>t.done?l(t.value):Promise.resolve(t.value).then(d,a);c((s=s.apply(m,i)).next())});import{u as S}from"./useEntityForm-CMwp7TbN.js";import{b6 as e}from"./bootstrap-Bqxdt4iG.js";import{a as u}from"./stock-outs-C0w9Kwsh.js";import{u as N}from"./warehouses-BnkLPhlE.js";import{a1 as y,L as P,E as I,ai as C,aj as F,a9 as R}from"../jse/index-index-BUJ_4tQs.js";const q=y({__name:"stock-out-form",props:{stockOut:{default:null},mode:{}},emits:["cancel","submit"],setup(m,{expose:i,emit:s}){const l=m,r=s,d=N(),a=P([]);h(null,null,function*(){try{a.value=yield d.fetchOptions()}catch(o){console.error("Failed to load warehouse options:",o),a.value=[]}});const t={warehouseId:"",destinationWarehouseId:null,type:u.SALES,consignmentNote:"",transporter:"",plateNumber:"",remark:""},n=I(()=>[{component:"Select",componentProps:{"data-testid":"stock-out-form-warehouse-select",id:"stock-out-form-warehouse-select",options:a.value,placeholder:e("page.stockOuts.form.warehousePlaceholder"),showSearch:!0,filterOption:(o,p)=>p.label.toLowerCase().includes(o.toLowerCase())},fieldName:"warehouseId",label:e("page.stockOuts.table.warehouse"),rules:"selectRequired"},{component:"Select",componentProps:{options:[{label:e("page.stockOuts.orderType.sales"),value:u.SALES},{label:e("page.stockOuts.orderType.transfer"),value:u.TRANSFER}],placeholder:e("page.stockOuts.form.typePlaceholder")},fieldName:"type",label:e("page.stockOuts.table.type"),rules:"selectRequired"},{component:"Select",componentProps:{options:a.value,placeholder:e("page.stockOuts.form.destinationWarehousePlaceholder"),showSearch:!0,filterOption:(o,p)=>p.label.toLowerCase().includes(o.toLowerCase())},dependencies:{show:o=>o.type===u.TRANSFER,triggerFields:["type"]},fieldName:"destinationWarehouseId",label:e("page.stockOuts.table.destinationWarehouse"),rules:"selectRequired"},{component:"Input",componentProps:{"data-testid":"stock-out-form-consignment-note-input",placeholder:e("page.stockOuts.form.consignmentNotePlaceholder")},fieldName:"consignmentNote",label:e("page.stockOuts.form.consignmentNote")},{component:"Input",componentProps:{"data-testid":"stock-out-form-transporter-input",placeholder:e("page.stockOuts.form.transporterPlaceholder")},fieldName:"transporter",label:e("page.stockOuts.form.transporter")},{component:"Input",componentProps:{"data-testid":"stock-out-form-plate-number-input",placeholder:e("page.stockOuts.form.plateNumberPlaceholder")},fieldName:"plateNumber",label:e("page.stockOuts.form.plateNumber")},{component:"Textarea",componentProps:{"data-testid":"stock-out-form-remark-input",placeholder:e("page.stockOuts.form.remarkPlaceholder"),autoSize:{minRows:2}},fieldName:"remark",label:e("page.stockOuts.form.remark")}]),{Form:f,focus:k,isDirty:b,resetForm:O,submitForm:g,watchEntity:w}=S({emptyValues:t,firstInputId:"stock-out-form-warehouse-select",schema:n,wrapperClass:"grid-cols-1"});return w(()=>l.stockOut,()=>l.mode),i({cancel:()=>{r("cancel")},focus:k,isDirty:b,resetForm:O,submit:()=>h(null,null,function*(){const o=yield g();o&&r("submit",o)})}),(o,p)=>(F(),C(R(f)))}});export{q as _};
