/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
function o(e){let n="calcite-mode-",t=`${n}light`,f=`${n}dark`;return e.classList.contains(f)?f:t}function l(e){return e.queryExpressions=[],e?.fLayerView?.filter?.where&&(e.fLayerView.filter.where=""),e?.fLayerView?.featureEffect?.filter?.where&&(e.fLayerView.featureEffect=null),e.categories.forEach(n=>{n.selected=!1}),e}function c(e,n){e.categories.get(n)?.nestedInfos?.forEach(r=>{let i=`${e.field} = '${r.legendElementInfo.value}'`,a=e.queryExpressions.indexOf(i);a!==-1&&e.queryExpressions.splice(a,1),r.selected=!1});let t=[],f=Array.from(e.categories).map(r=>r[1]);f.forEach(r=>{r.nestedInfos?.every(i=>!i.selected)&&r.nestedInfos?.forEach(i=>{t.push(`${e.field} = '${i.legendElementInfo.value}'`)})}),t.forEach(r=>{e.queryExpressions.includes(r)||e.queryExpressions.push(r)});let s=e.queryExpressions.join(" OR ");return f.every(r=>r.nestedInfos?.every(i=>!i.selected))?(e?.fLayerView?.filter?.where&&(e.fLayerView.filter.where=""),e?.fLayerView?.featureEffect?.filter?.where&&(e.fLayerView.featureEffect=null),e.queryExpressions=[]):(e?.fLayerView?.filter?.where&&(e.fLayerView.filter.where=s),e?.fLayerView?.featureEffect?.filter?.where&&(e.fLayerView.featureEffect.filter.where=s)),e}async function u(e,n,t){let f=e.fLayerView.createQuery();if(t)if(t.nestedInfos.every(s=>!s.selected)){let s=t.nestedInfos.map(r=>`${e.field} = '${r.legendElementInfo.value}'`).join(" OR ");f.where=s}else{let s=t.nestedInfos.filter(r=>r.selected).map(r=>`${e.field} = '${r.legendElementInfo.value}'`).join(" OR ");f.where=s}else{let s=e.queryExpressions.join(" OR ");f.where=s}try{let{extent:s}=await e.fLayerView.layer.queryExtent(f);await n.goTo(s)}catch{}}export{o as a,l as b,c,u as d};
