import{a as C}from"./chunk-NIMI3ZJM.js";import{a as j}from"./chunk-CYKGLVRV.js";import{i as A,l as S}from"./chunk-N7PC5CHF.js";import{f as c,z as b}from"./chunk-ZTKV4AIV.js";import{a as d}from"./chunk-5JDCLYZA.js";import{E as v,R as m,Z as f,na as y,u as p}from"./chunk-FWZCAEAJ.js";import{a as g,b as h}from"./chunk-CWTPBX7D.js";function x(e){let u=b("injectFilter"),i=y(S),s=y(A),a=Object.keys(e.controls),l=s.queryParamMap.pipe(d(),p(t=>a.reduce((r,n)=>h(g({},r),{[n]:t.getAll(n)}),{})),m(),f(1)),o=v(l,e.valueChanges),k=j(e),F=C([o],p(([t])=>t?a.reduce((r,n)=>r+(Array.isArray(t[n])?t[n].length:t[n]?1:0),0):0));return o.pipe(d(),m()).subscribe(t=>{u.info("filterFormValueChanges","Set query params",t),i.navigate([],{relativeTo:s,queryParamsHandling:"merge",queryParams:t})}),l.subscribe(t=>{for(let r in t){let n=t[r];Array.isArray(e.controls[r].value)?n.length>0&&e.controls[r].patchValue(R(e.controls[r].value,n),{emitEvent:!1,onlySelf:!0}):n[0]!==void 0&&c(n[0])!==e.controls[r].value&&e.controls[r].patchValue(c(n[0]),{emitEvent:!1,onlySelf:!0})}}),{form:e,valueChanges:o,valid:k,count:F}}function R(e,u){let i=new Set(e),s=new Set(u.map(c)),a=[...s].filter(o=>!i.has(o)),l=[...i].filter(o=>!s.has(o));return[...e.filter(o=>!l.includes(o)),...a]}export{x as a};
