var g=(d,f,n)=>new Promise((u,c)=>{var i=r=>{try{s(n.next(r))}catch(l){c(l)}},a=r=>{try{s(n.throw(r))}catch(l){c(l)}},s=r=>r.done?u(r.value):Promise.resolve(r.value).then(i,a);s((n=n.apply(d,f)).next())});import{u as S}from"./useCreateDrawer-JEzOVO6Z.js";import{b6 as t,cc as k}from"./bootstrap-Bqxdt4iG.js";import{u as _}from"./data-refresh-BZ1_-6mk.js";import{u as x}from"./inventories-FA5wVZqN.js";import{_ as b}from"./inventory-form.vue_vue_type_script_setup_true_lang-B7Mk7j6o.js";import"./index-nmF6dqm7.js";import{a1 as h,L as v,ai as w,aj as y,ak as I,p as o,a9 as p}from"../jse/index-index-BUJ_4tQs.js";const $=h({__name:"inventory-create-drawer",emits:["success"],setup(d,{emit:f}){const n=f,u=x(),c=_(),i=v(""),a=v(""),{Drawer:s,formRef:r,handleSubmit:l}=S({createApi:e=>g(null,null,function*(){return u.create(e)}),invalidateData:()=>c.invalidateInventories(),title:t("page.inventories.drawer.createTitle"),processOpenData:e=>{e!=null&&e.defaultCustomerId&&(i.value=e.defaultCustomerId),e!=null&&e.defaultOriginalSku&&(a.value=e.defaultOriginalSku)},onSuccess:e=>{n("success",e)},onClosed:()=>{i.value="",a.value=""}}),C=e=>{var m;k.confirm({title:t("page.inventories.form.confirmCreateTitle"),content:o("div",{},[o("p",{style:"font-weight: bold; color: #faad14; margin-bottom: 8px;"},t("page.inventories.form.confirmCreateWarning")),o("ul",{style:{listStyleType:"disc",paddingLeft:"25px"}},[o("li",null,t("page.inventories.form.confirmCreateMultiWarehouse",{count:((m=e.warehouseIds)==null?void 0:m.length)||0})),e.originalSku?null:o("li",{style:"color: #faad14; font-weight: bold;"},t("page.inventories.form.confirmCreateSkuMissing"))].filter(Boolean)),o("p",{style:"margin-top: 16px;"},t("page.inventories.form.confirmCreateProceed"))]),okText:t("page.inventories.form.confirmCreateOk"),cancelText:t("page.inventories.form.confirmCreateCancel"),onOk(){l(e)}})};return(e,m)=>(y(),w(p(s),{class:"w-[700px]","confirm-text":p(t)("page.table.button.create"),"cancel-text":p(t)("page.table.button.cancel")},{default:I(()=>[o(b,{ref_key:"formRef",ref:r,mode:"create","default-customer-id":i.value,"default-original-sku":a.value,onSubmit:C},null,8,["default-customer-id","default-original-sku"])]),_:1},8,["confirm-text","cancel-text"]))}});export{$ as _};
