/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{property as l,subclass as t}from"../../core/accessorSupport/decorators.js";import s from"./BuildingNumericFilterViewModel.js";import{findFieldInfoByModelName as i}from"./support/buildingLayerUtils.js";import{getValueFromFilters as r}from"./support/filterUtils.js";import{getDomainInfo as o}from"./support/validation.js";const a="bldglevel";let n=class extends s{constructor(e){super(e),this._levelFieldName=null,this._parseValueFromFilter=e=>{const l=new RegExp(`${this._levelFieldName}\\s*=\\s*(\\d+)`,"gi"),t=new RegExp(`${this._levelFieldName}\\s*<\\s*(\\d+)`,"gi");for(const{filterMode:s,filterExpression:i}of e.filterBlocks?.items??[]){if(null==i)continue;let e=null;if("solid"===s.type?e=l.exec(i):"x-ray"===s.type&&(e=t.exec(i)),e)return parseInt(e[1],10)}return null}}get filterExpressions(){return this.enabled&&this._levelFieldName?{xRay:`${this._levelFieldName} < ${this.value}`,solid:`${this._levelFieldName} = ${this.value}`}:{solid:null,xRay:null}}get _firstValue(){const e=this.allowedValues;return e.length>0?e[0]:0}_setup(){const e=[];this.layers.forEach(l=>{const t=i(l,a);null!=t&&(this._levelFieldName=t.fieldName,e.push(t))}),this._domainInfo=o(e);const l=this._valueBeforeReady;this._set("state","ready"),this._valueBeforeReady=null;const t=l??r(this.layers,this._parseValueFromFilter);null!=t?this.select(t):(this.enabled=!1,this.value=this._firstValue)}};e([l({readOnly:!0})],n.prototype,"filterExpressions",null),e([l()],n.prototype,"_levelFieldName",void 0),e([l({readOnly:!0})],n.prototype,"_firstValue",null),n=e([t("esri.widgets.BuildingExplorer.BuildingLevel")],n);const u=n;export{u as default};
