import{_ as w}from"./DUQr9DrG.js";import{_ as A,a as C,b as S,c as M,d as k}from"./SSa1aSx8.js";import{_ as B}from"./CpvritYQ.js";import{_ as F}from"./G7u0egV4.js";import{d as j,p as R,J as T,j as f,k as U,a as D,f as o,w as E,g as n,F as V,o as N,e as a,l as P,n as v,i as $}from"./JQJBiNWj.js";import z from"./D42GNhrT.js";import{h as G}from"./CH1bAkoS.js";import{a as J}from"./GUUfolGj.js";import{u as O}from"./f6QOa6wf.js";import"./BwwR4PPN.js";import"./B6O9xiO5.js";import"./HM4z-iuB.js";import"./DqVYbxj5.js";import"./CxkaGOlL.js";import"./BgAkS4D_.js";import"./DKM0wLqG.js";import"./yKVtex9U.js";import"./CbtPaznW.js";import"./Dc_YXEFz.js";import"./DmwTwIPt.js";import"./B-La3K3C.js";import"./F98GHXdS.js";import"./DvBDpJyt.js";import"./FcRkkR--.js";import"./Dk4pWsnS.js";import"./BSHuRY0P.js";import"./BBDFeM-T.js";import"./BuR5k2Xw.js";import"./ClVEEBFD.js";import"./2JTb7YQn.js";import"./CJYlvWEf.js";import"./CeWG_dyW.js";import"./CDSORL4U.js";import"./3oa0FK2h.js";import"./gxHWKiUc.js";import"./Dm5UwSfy.js";import"./4FMzYxPj.js";import"./BWs0r_ue.js";import"./D8TjaAl-.js";import"./BoTzJngr.js";import"./qAEGbaa4.js";import"./BnQEpK3N.js";import"./DncddsCV.js";import"./BweM3Zv8.js";import"./DPeK_S5k.js";import"./CeGk6Fsr.js";import"./D1rKqwCM.js";import"./BAmc1GPw.js";import"./CYDRfonM.js";import"./DMxbovom.js";import"./DBWLnasn.js";import"./RO0fiRDZ.js";import"./Cr9ZZaT-.js";import"./DNRi6U01.js";import"./BYfmWBgX.js";import"./vkXHPWu2.js";import"./CASPyZT-.js";import"./CfLdzzlL.js";import"./CjLYEAc3.js";import"./BTchAptP.js";import"./CuNuZBQO.js";import"./CL7Msd7o.js";const q={class:"sm:hidden sticky bottom-2"},H={class:"flex flex-wrap gap-3 -mx-4 -mb-4 p-4 sm:sticky sm:bottom-0 bg-white border-t items-center justify-between"},I={class:"flex flex-wrap max-sm:flex-1 gap-3 items-center"},K={class:"max-sm:hidden"},Q={class:"flex flex-wrap max-sm:w-full gap-3 items-center"},so=j({__name:"nova-licenca",setup(W){const p=R(),s=T({}),r=f(),l=f(null);O(l),U(r,e=>{e?(s.substituta=e,s.idLicencaSubstituta=e.id):(s.substituta=void 0,s.idLicencaSubstituta=void 0)});function b(e){if(!e.valid)return;const i={...s};Object.keys(e.states).forEach(m=>{const t=e.states[m].value;t!==void 0&&(typeof t=="object"&&t!==null&&Array.isArray(t)?i[m]=t.map(c=>c.id):i[m]=t)}),$.meioAmbiente.licenca.createLicenca(i).then(()=>{p.add({severity:"success",summary:"Sucesso",detail:"Licença criada com sucesso!",life:5e3}),v("/meio-ambiente/licencas/")}).catch(m=>{var t;p.add({severity:"error",summary:"Erro",detail:((t=m.data)==null?void 0:t.message)||m.message,life:5e3})})}const x=G(J);return(e,i)=>{const m=w,t=A,c=C,h=S,y=M,g=k,_=B,u=F,L=z;return N(),D(V,null,[o(m,{title:"Licença - Adicionar"}),o(L,{ref_key:"formRef",ref:l,class:"space-y-8","initial-values":n(s),resolver:n(x),onSubmit:b},{default:E(()=>[o(t),o(c),o(h),o(y),o(g,{modelValue:n(r),"onUpdate:modelValue":i[0]||(i[0]=d=>P(r)?r.value=d:null)},null,8,["modelValue"]),a("div",q,[o(_)]),a("div",H,[a("div",I,[a("div",K,[o(_)])]),a("div",Q,[o(u,{mode:"cancel",class:"max-sm:w-full",onClick:i[1]||(i[1]=d=>("navigateTo"in e?e.navigateTo:n(v))("/meio-ambiente/licencas"))}),o(u,{mode:"save",class:"max-sm:w-full",type:"submit"})])])]),_:1},8,["initial-values","resolver"])],64)}}});export{so as default};
