/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["../../chunks/_rollupPluginBabelHelpers","../../chunks/tslib.es6","../../core/maybe","../../core/accessorSupport/decorators/property","../../core/arrayUtils","../../core/has","../../core/accessorSupport/ensureType","../../core/accessorSupport/decorators/subclass","./BuildingNumericFilterViewModel","./support/buildingLayerUtils","./support/filterUtils","./support/validation"],(function(e,l,t,s,r,i,o,a,n,u,p,c){"use strict";const d="bldglevel";let _=function(l){function s(){var e;return(e=l.apply(this,arguments)||this)._levelFieldName=null,e._parseValueFromFilter=l=>{const s=new RegExp(`${e._levelFieldName}\\s*=\\s*(\\d+)`,"gi"),r=new RegExp(`${e._levelFieldName}\\s*<\\s*(\\d+)`,"gi");for(const{filterMode:e,filterExpression:i}of l.filterBlocks.items){let l=null;if("solid"===e.type?l=s.exec(i):"x-ray"===e.type&&(l=r.exec(i)),t.isSome(l))return parseInt(l[1],10)}return null},e}return e._inheritsLoose(s,l),s.prototype._setup=function(){const e=[];this.layers.forEach((l=>{const s=u.findFieldInfoByModelName(l,d);t.isSome(s)&&(this._levelFieldName=s.fieldName,e.push(s))})),this._domainInfo=c.getDomainInfo(e);const l=this._valueBeforeReady;this._set("state","ready"),this._valueBeforeReady=null;const s=null!=l?l:p.getValueFromFilters(this.layers,this._parseValueFromFilter);t.isSome(s)?this.select(s):(this.enabled=!1,this.value=this._firstValue)},e._createClass(s,[{key:"filterExpressions",get:function(){return this.enabled&&this._levelFieldName?{xRay:`${this._levelFieldName} < ${this.value}`,solid:`${this._levelFieldName} = ${this.value}`}:{solid:null,xRay:null}}},{key:"_firstValue",get:function(){const e=this.allowedValues;return e.length>0?e[0]:0}}]),s}(n);l.__decorate([s.property({readOnly:!0})],_.prototype,"filterExpressions",null),l.__decorate([s.property()],_.prototype,"_levelFieldName",void 0),l.__decorate([s.property({readOnly:!0})],_.prototype,"_firstValue",null),_=l.__decorate([a.subclass("esri.widgets.BuildingExplorer.BuildingLevel")],_);return _}));
