import{_ as j}from"./BaseForm.vue_vue_type_script_setup_true_lang-BnxGTisD.js";import{d as z,H as A,P as G,I as H,r as O,W as P,w as W,f as C,h as F,v as e,i as l,c as s,x as U,V as q,y as E,G as J}from"./index-C5GbdPxY.js";import{u as K}from"./onlineMenu-DknFNqGk.js";import{u as Q}from"./form-B2je8iBR.js";import{a as c,V as B}from"./VAvatar-RkAR0u0e.js";import{c as X,V as Y,a as Z}from"./VCard-DptrO3GI.js";import{V as k}from"./VTextField-DxEUpn3-.js";import{V as $}from"./VSelect-vtfYszIh.js";import{V as L}from"./VCheckbox-rNAD_QU_.js";const ee={class:"d-flex align-center"},ue=z({__name:"Form",props:{item:{},action:{}},setup(M){var V,p,v,g,h,w,x;const m=M,{t:u}=A(),{user:_}=G(),{getFormMeta:N,update:S,store:T}=K(),D=H(),a=Q({name:((V=m.item)==null?void 0:V.name)||{},slug:(p=m.item)==null?void 0:p.slug,menu_id:(g=(v=m.item)==null?void 0:v.menu)==null?void 0:g.id,branch_id:_!=null&&_.assigned_to_branch?_.branch_id:(w=(h=m.item)==null?void 0:h.branch)==null?void 0:w.id,is_active:((x=m.item)==null?void 0:x.is_active)||!1}),d=O({branches:[],menus:[]}),I=async()=>{!a.loading.value&&await a.submit(()=>{var r;return m.action=="create"?T(a.state):S((r=m.item)==null?void 0:r.id,a.state)})&&await D.push({name:"admin.online_menus.index"})};P(()=>{f(),a.state.branch_id&&f(a.state.branch_id)}),W(()=>a.state.branch_id,r=>{a.state.menu_id=null,d.value.menus=[],f(r)});const f=async r=>{try{const n=(await N(r)).data.body;d.value.branches=n.branches||d.value.branches,r&&(d.value.menus=n.menus)}catch{}};return(r,n)=>{const R=j;return F(),C(R,{action:r.action,"has-multiple-language":"",loading:e(a).loading.value,resource:"online_menus",onSubmit:I},{default:l(({currentLanguage:b})=>[s(B,null,{default:l(()=>[s(c,{cols:"12"},{default:l(()=>[s(X,null,{default:l(()=>[s(Y,{class:"d-flex justify-space-between align-center mb-2"},{default:l(()=>[U("div",ee,[s(q,{class:"me-2",icon:"tabler-info-circle",size:"20"}),U("span",null,E(e(u)("menu::online_menus.form.cards.online_menu_information")),1)])]),_:1}),s(Z,null,{default:l(()=>[s(B,null,{default:l(()=>{var y;return[s(c,{cols:"12",md:"6"},{default:l(()=>{var t,o;return[s(k,{modelValue:e(a).state.name[b.id],"onUpdate:modelValue":i=>e(a).state.name[b.id]=i,error:!!((t=e(a).errors.value)!=null&&t[`name.${b.id}`]),"error-messages":(o=e(a).errors.value)==null?void 0:o[`name.${b.id}`],label:e(u)("menu::attributes.online_menus.name")+` ( ${b.name} )`},null,8,["modelValue","onUpdate:modelValue","error","error-messages","label"])]}),_:2},1024),r.action=="create"&&!((y=e(_))!=null&&y.assigned_to_branch)?(F(),C(c,{key:0,cols:"12",md:"6"},{default:l(()=>{var t,o;return[s($,{modelValue:e(a).state.branch_id,"onUpdate:modelValue":n[0]||(n[0]=i=>e(a).state.branch_id=i),error:!!((t=e(a).errors.value)!=null&&t.branch_id),"error-messages":(o=e(a).errors.value)==null?void 0:o.branch_id,"item-title":"name","item-value":"id",items:e(d).branches,label:e(u)("menu::attributes.online_menus.branch_id")},null,8,["modelValue","error","error-messages","items","label"])]}),_:1})):J("",!0),s(c,{cols:"12",md:"6"},{default:l(()=>{var t,o;return[s(k,{modelValue:e(a).state.slug,"onUpdate:modelValue":n[1]||(n[1]=i=>e(a).state.slug=i),error:!!((t=e(a).errors.value)!=null&&t.slug),"error-messages":(o=e(a).errors.value)==null?void 0:o.slug,label:e(u)("menu::attributes.online_menus.slug")},null,8,["modelValue","error","error-messages","label"])]}),_:1}),s(c,{cols:"12",md:"6"},{default:l(()=>{var t,o;return[s($,{modelValue:e(a).state.menu_id,"onUpdate:modelValue":n[2]||(n[2]=i=>e(a).state.menu_id=i),error:!!((t=e(a).errors.value)!=null&&t.menu_id),"error-messages":(o=e(a).errors.value)==null?void 0:o.menu_id,"item-title":"name","item-value":"id",items:e(d).menus,label:e(u)("menu::attributes.online_menus.menu_id")},null,8,["modelValue","error","error-messages","items","label"])]}),_:1}),s(c,{cols:"12"},{default:l(()=>[s(L,{modelValue:e(a).state.is_active,"onUpdate:modelValue":n[3]||(n[3]=t=>e(a).state.is_active=t),label:e(u)("menu::attributes.online_menus.is_active")},null,8,["modelValue","label"])]),_:1})]}),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:2},1024)]),_:1},8,["action","loading"])}}});export{ue as _};
