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