import{_ as w}from"./DDV-HLQE.js";import{_ as A,a as C,b as S,c as M,d as k}from"./Cq3EsZzD.js";import{_ as B}from"./CWr_imfF.js";import{_ as F}from"./Brk5FU9k.js";import{d as j,p as R,K 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"./dVzHJMF1.js";import z from"./iZ-xiGRB.js";import{h as G}from"./CH1bAkoS.js";import{a as K}from"./CN3ObUS3.js";import{u as O}from"./D2P12BLM.js";import"./DhLu8RVk.js";import"./CWHHmK0V.js";import"./yXj_05M0.js";import"./Bhud8mbC.js";import"./tESAK1vk.js";import"./B79Hoqpc.js";import"./CX2DUt_P.js";import"./CL2jyiz8.js";import"./B-d7gz-d.js";import"./BSLzRQpY.js";import"./CNJ8Vm0G.js";import"./Bpf-t_rp.js";import"./yHxjwlra.js";import"./KG16xCEZ.js";import"./FcRkkR--.js";import"./DP0doleY.js";import"./BAtzogEJ.js";import"./C5Oc2f2M.js";import"./CBbadgK0.js";import"./a1m94JqE.js";import"./CM8mMzv6.js";import"./B7Hqpkvs.js";import"./DiwqsPB4.js";import"./KcBrPYTF.js";import"./r1Y5hC84.js";import"./BqnRxGiA.js";import"./cMkL48JQ.js";import"./DW2OqR52.js";import"./5WXaDlrT.js";import"./CELWndHG.js";import"./Bc99g-CG.js";import"./BSe03gVj.js";import"./BGFPOxrp.js";import"./CrEL4Vxb.js";import"./CYvl7uw_.js";import"./DYJY2RZG.js";import"./BuQ9u7Je.js";import"./BW5cYMVL.js";import"./Coj9p228.js";import"./C682XpkB.js";import"./DDpCYtr5.js";import"./C9UvFovT.js";import"./FaLtR_4n.js";import"./C9L2ikqF.js";import"./B3dHCiEQ.js";import"./BZjcnCH7.js";import"./B_Kqq5Cu.js";import"./B-6EeO4n.js";import"./CPg0DzIm.js";import"./BphmgIhx.js";import"./ClA_a7pZ.js";import"./G1F3Bacz.js";import"./CJ1p9Ehj.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"},J={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(K);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",J,[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};
