/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{generateUUID as t}from"../../../core/uuid.js";import n from"../../../layers/support/BuildingFilterBlock.js";import r from"../../../layers/support/BuildingFilterModeSolid.js";import i from"../../../layers/support/BuildingFilterModeXRay.js";const o="__BUILDING_EXPLORER_FILTER__";function e(){return`${t()}${o}`}function l(t){const n="string"==typeof t?t:t.id;return!!n&&n.includes(o)}function f(t,n){for(const r of t.items)for(const t of r.filters.items){if(!l(t))continue;const r=n(t);if(null!=r)return r}return null}function s(t,n){t.forEach(t=>{const r=t.filters.filter(t=>!l(t));null!=n&&r.push(n),u(t.filters,r)||(t.filters=r);const i=t.filters.find(t=>l(t));t.activeFilterId=null!=i?i.id:null})}function u(t,n){const r=n.length;if(null==t||t.length!==r)return!1;for(let i=0;i<r;++i){const r=n.at(i).toJSON(),o=t.at(i).toJSON();if(r.id="",o.id="",JSON.stringify(r)!==JSON.stringify(o))return!1}return!0}function c(t){const r=p(t);return r?new n({filterExpression:r,filterMode:new i}):null}function d(t){const i=p(t);return i?new n({filterExpression:i,filterMode:new r}):null}function p(t){return t.filter(t=>!!t).map(t=>`(${t})`).join(" AND ")}export{e as generateFilterId,d as getFilterBlockSolid,c as getFilterBlockXRay,f as getValueFromFilters,l as isBuildingExplorerFilter,s as setFilterOnLayers};
