import{_ as B}from"./gxHWKiUc.js";import{_ as C}from"./D7IyRfqO.js";import M from"./DPeK_S5k.js";import R from"./BBDFeM-T.js";import x from"./CJYlvWEf.js";import{A as y}from"./Bli8EQqv.js";import{U as K}from"./CRodc3LN.js";import{d as N,O as D,P as j,c as P,k as L,a as _,o as m,f as o,E as u,w as i,g as s,F as h,b as S,i as T}from"./JQJBiNWj.js";import{u as $}from"./DncddsCV.js";const z=N({__name:"RedundantFilters",props:{tipoAtivo:{},splitTipoParent:{type:Boolean,default:()=>{}},showTipoElemento:{type:Boolean,default:!0}},async setup(p){let c,b;const k=D(),V=([c,b]=j(()=>k.getEmpresaSelecionada()),c=await c,b(),c),f=$();async function F(e){return await T.rodovias.getByEmpresa(V.sigla,e)}const U=P(()=>{var e,n,l,a,d;return(d=(a=(l=(n=(e=f.value)==null?void 0:e.fields)==null?void 0:n.rodovia)==null?void 0:l.states)==null?void 0:a.value)==null?void 0:d.length});function A(e){return T.ativos.findTiposElementos({subsistema:p.tipoAtivo,isParent:typeof p.splitTipoParent=="boolean"?p.splitTipoParent:void 0,...e,sort:["descricao,asc"]})}function I(e){return T.ativos.findTiposElementos({subsistema:p.tipoAtivo,isParent:typeof p.splitTipoParent=="boolean"?!p.splitTipoParent:void 0,idTipoElementoPai:r.value,...e,sort:["descricao,asc"]})}const r=P(()=>{var e,n,l,a;return(a=(l=(n=(e=f.value)==null?void 0:e.fields)==null?void 0:n.idTipoElementoPai)==null?void 0:l.states)==null?void 0:a.value});return L(r,(e,n)=>{if(n!==void 0)try{f.value.setFieldValue("idTipoElemento",null)}catch{}}),(e,n)=>{var E,w;const l=x,a=B,d=C,O=R,g=M;return m(),_(h,null,[o(a,{name:"search",label:"Localizar:"},{default:i(()=>[o(l,{type:"search",fluid:""})]),_:1}),o(a,{name:"rodovia",label:"Rodovia:"},{default:i(()=>[o(d,{id:"rodovia",name:"rodovia","paginated-data-key":"rodovias","async-fn":F,"option-label":t=>t.descricao+"/"+t.uf,"option-value":"id","show-clear":"","show-toggle-all":!1},null,8,["option-label"])]),_:1}),s(U)?(m(),_(h,{key:0},[o(a,{name:"kmInicial",label:"Km inicial:"},{default:i(t=>[o(l,{id:"km-inicial",modelValue:t.value,"onUpdate:modelValue":v=>t.value=v,type:"text",placeholder:"KM inicial"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),o(a,{name:"kmFinal",label:"Km final:"},{default:i(t=>[o(l,{id:"km-final",modelValue:t.value,"onUpdate:modelValue":v=>t.value=v,type:"text",placeholder:"KM final"},null,8,["modelValue","onUpdate:modelValue"])]),_:1}),o(a,{name:"uf",label:"UF:"},{default:i(()=>[o(O,{id:"uf",name:"uf",options:s(K),"option-label":"nome","option-value":"sigla",placeholder:"Selecione...","show-clear":"","show-toggle-all":!1,filter:""},null,8,["options"])]),_:1})],64)):u("",!0),o(a,{name:"sentido",label:"Sentido:"},{default:i(()=>[o(g,{id:"sentido",name:"sentido",options:s(y).TIPO_SENTIDO,"option-label":"label","option-value":"value",placeholder:"Selecione...","show-clear":"","show-toggle-all":!1,filter:""},null,8,["options"])]),_:1}),o(a,{name:"direcao",label:"Direção:"},{default:i(()=>[o(g,{id:"direcao",name:"direcao",options:s(y).TIPO_DIRECAO,"option-label":"label","option-value":"value",placeholder:"Selecione...","show-clear":"","show-toggle-all":!1,filter:""},null,8,["options"])]),_:1}),e.showTipoElemento?(m(),_(h,{key:1},[e.splitTipoParent?(m(),S(a,{key:0,name:"idTipoElementoPai",label:"Tipo:"},{default:i(()=>[o(d,{id:"tipo-elemento",name:"idTipoElementoPai","paginated-data-key":"tiposElementosPai","option-label":"descricao","option-value":"id","async-fn":A,"show-clear":"","show-toggle-all":!1})]),_:1})):u("",!0),!e.splitTipoParent||e.splitTipoParent&&((E=s(r))!=null&&E.length)?(m(),S(a,{key:1,name:"idTipoElemento",label:e.splitTipoParent&&((w=s(r))!=null&&w.length)?"Subtipo:":"Tipo:"},{default:i(()=>{var t;return[o(d,{id:"tipo-elemento",name:"idTipoElemento","paginated-data-key":"tiposElementos","option-label":"descricao","option-value":"id",placeholder:e.splitTipoParent&&!((t=s(r))!=null&&t.length)?"Selecione o tipo elemento":void 0,"async-fn":I,"show-clear":"",watch:()=>[s(r)],"show-toggle-all":!1},null,8,["placeholder","watch"])]}),_:1},8,["label"])):u("",!0)],64)):u("",!0)],64)}}}),ee=Object.assign(z,{__name:"AtivosElementoRedundantFilters"});export{ee as _};
