PageSourceSearch

https://www.aep.com/static-content/7a41ff4a15f8a3445f554b858e5cf45…/static/chunks/27920.9da6851770b96906.js

js aep.com collected 2026-10-09 16:49:05 UTC 92,892 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[27920],{27920:function(e,t,i){i.r(t),i.d(t,{constructAssociationMetaDataFeatureSetFromUrl:function(){return es},constructFeatureSet:function(){return et},constructFeatureSetFromPortalItem:function(){return ec},constructFeatureSetFromRelationship:function(){return en},constructFeatureSetFromUrl:function(){return ee},convertToFeatureSet:function(){return eh},createFeatureSetCollectionFromMap:function(){return eo},createFeatureSetCollectionFromService:function(){return ed},initialiseMetaDataCache:function(){return X}});var r=i(63895);class a{constructor(){this.declaredRootClass="esri.arcade.featureSetCollection",this._layerById={},this._layerByName={}}add(e,t,i){this._layerById[t]=i,this._layerByName[e]=i}async featureSetByName(e,t=!0,i=["*"]){return void 0===this._layerByName[e]?null:this._layerByName[e]}async featureSetById(e,t=!0,i=["*"]){return void 0===this._layerById[e]?null:this._layerById[e]}castToText(e=!1){return"object, FeatureSetCollection"}}var s=i(77689),n=i(89686),l=i(27568),u=i(21035),o=i(68631),d=i(20994),h=i(79921),c=i(73346),f=i(47045),p=i(16067),_=i(42442),y=i(72640),g=i(71943),m=i(84976);class w{constructor(){this.field="",this.tofieldname="",this.typeofstat="MIN",this.workingexpr=null}clone(){let e=new w;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(e,t,i,r){let a=new w;a.field=e;let s=m.default.create(t,{fieldsIndex:i,timeZone:r}),n=function(e){if("function"===e.parseTree.type){if(0===e.parseTree.args.value.length)return{name:e.parseTree.name,expr:null};if(e.parseTree.args.value.length>1)throw new g.eS(g.f.MissingStatisticParameters);let t=m.default.create((0,y.XF)(e.parseTree.args.value[0],_.Bj.Standardised,e.parameters),{fieldsIndex:e.fieldsIndex,timeZone:e.timeZone,currentUser:e.currentUser});return{name:e.parseTree.name,expr:t}}return null}(s);if(null===n)throw new g.eS(g.f.UnsupportedSqlFunction,{function:""});let l=n.name.toUpperCase().trim();if("MIN"===l){if(a.typeofstat="MIN",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"min"})}else if("MAX"===l){if(a.typeofstat="MAX",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"max"})}else if("COUNT"===l)a.typeofstat="COUNT",a.workingexpr=n.expr;else if("STDEV"===l){if(a.typeofstat="STDDEV",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"stdev"})}else if("SUM"===l){if(a.typeofstat="SUM",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"sum"})}else if("MEAN"===l){if(a.typeofstat="AVG",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:l})}else if("AVG"===l){if(a.typeofstat="AVG",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"avg"})}else{if("VAR"!==l)throw new g.eS(g.f.UnsupportedSqlFunction,{function:l});if(a.typeofstat="VAR",a.workingexpr=n.expr,null===s)throw new g.eS(g.f.InvalidFunctionParameters,{function:"var"})}return a}toStatisticsName(){switch(this.typeofstat.toUpperCase()){case"MIN":return"min";case"MAX":return"max";case"SUM":return"sum";case"COUNT":default:return"count";case"VAR":return"var";case"STDDEV":return"stddev";case"AVG":return"avg"}}}var F=i(72115),S=i(46834),I=i(13160),b=i(30935),C=i(21468),R=i(93271),T=i(31476),v=i(93);let D=new u.x(["MIN","MAX","VAR","STDDEV","COUNT","SUM","AVG"],[["VARIANCE","VAR"],["AVERAGE","AVG"],["MEAN","AVG"],["STDEV","STDDEV"]]);class k extends c.Z{constructor(e){super(e),this._decodedStatsfield=[],this._decodedGroupbyfield=[],this._candosimplegroupby=!0,this.phsyicalgroupbyfields=[],this.objectIdField="ROW__ID",this._internalObjectIdField="ROW__ID",this._adaptedFields=[],this.declaredClass="esri.arcade.featureset.actions.Aggregate",this._uniqueIds=1,this._maxQuery=10,this._maxProcessing=10,this._parent=e.parentfeatureset,this._config=e}isTable(){return!0}async _getSet(e){if(null===this._wset){let t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return _.dj.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;let t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){let e={},t=!1,i=1,r=this._parent?this._parent.getFieldsIndex():new v.Z([]);for(this.objectIdField="ROW__ID",this.globalIdField="";!1===t;){let e=!1;for(let t=0;t<this._config.groupbyfields.length;t++)if(this._config.groupbyfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}if(!1===e){for(let t=0;t<this._config.statsfields.length;t++)if(this._config.statsfields[t].name.toLowerCase()===this.objectIdField.toLowerCase()){e=!0;break}}!1===e?t=!0:(this.objectIdField="ROW__ID"+i.toString(),i++)}for(let e of this._config.statsfields){let t=new w;
1t.field=e.name,t.tofieldname=e.name,t.workingexpr=e.expression instanceof m.default?e.expression:m.default.create(e.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),t.typeofstat=D.lookup(e.statistic)??"COUNT",this._decodedStatsfield.push(t)}for(let e of(this._decodedGroupbyfield=[],this._config.groupbyfields)){let t={name:e.name,singlefield:null,tofieldname:e.name,expression:e.expression instanceof m.default?e.expression:m.default.create(e.expression,{fieldsIndex:r,timeZone:this.dateFieldsTimeZoneDefaultUTC}),sqlType:null};this._decodedGroupbyfield.push(t)}if(null!==this._parent){for(let t of(this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="",this._parent.fields))e[t.name.toUpperCase()]=1;this.types=null,this.subtypes=null,this.subtypeField=""}else this.geometryType=_.Qk.point,this.typeIdField="",this.types=null,this.subtypes=null,this.subtypeField="",this.spatialReference=new R.Z({wkid:4326});this.fields=[];let a=new w;for(let t of(a.field=this._nextUniqueName(e),a.tofieldname=this.objectIdField,a.workingexpr=m.default.create(this._parent.objectIdField,{fieldsIndex:this._parent.getFieldsIndex(),timeZone:this.dateFieldsTimeZoneDefaultUTC}),a.typeofstat="MIN",this._decodedStatsfield.push(a),this._decodedGroupbyfield)){let i=new T.Z;if(t.name=this._nextUniqueName(e),i.name=t.tofieldname,i.alias=i.name,(0,y.y5)(t.expression)){let e=this._parent.getField((0,y.zR)(t.expression,_.Bj.Standardised));if(!e)throw new h.EN(h.H9.AggregationFieldNotFound);t.name=e.name,t.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),i.type=e.type,t.sqlType=e.type}else{i.type=this._convertToEsriFieldType((0,y.DT)(t.expression,this._parent.fields));let e=new T.Z;e.name=t.name,e.alias=e.name,this.phsyicalgroupbyfields.push(t.name),this._adaptedFields.push(new o.yN(e,t.expression)),this._candosimplegroupby=!1,t.sqlType=i.type}this.fields.push(i)}if(this._adaptedFields.length>0)for(let e of this._parent.fields)this._adaptedFields.push(new o.$X(e));for(let t=0;t<this._decodedStatsfield.length;t++){let i=new T.Z,r=null,a=this._decodedStatsfield[t];a.field=this._nextUniqueName(e),a.tofieldname===this.objectIdField&&(this._internalObjectIdField=a.field),i.name=a.tofieldname,i.alias=i.name;let s=null!==a.workingexpr&&(0,y.y5)(a.workingexpr)?(0,y.zR)(a.workingexpr,_.Bj.Standardised):"";switch(this._decodedStatsfield[t].typeofstat){case"SUM":case"MIN":case"MAX":if(""!==s){if(!(r=this._parent.getField(s)))throw new h.EN(h.H9.AggregationFieldNotFound);i.type=r.type}else i.type="double";break;case"COUNT":i.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==s&&!(r=this._parent.getField(s)))throw new h.EN(h.H9.AggregationFieldNotFound);i.type="double"}this.fields.push(i)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,i,r){-1!==t&&this._featureCache[t];let a=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,a)?(await this._expandPagedSet(e,a,0,0,r),this._getFeatures(e,t,i,r)):"success"}async _getFilteredSet(e,t,i,r,a){if(""!==e)return new f.Z([],[],!0,null);let s=null,l={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==i){for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===(0,y.hq)(i,this._decodedStatsfield[e].tofieldname)){l.nowhereclause=!0,i=null;break}}if(null!==r){l.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===r.scanForField(this._decodedStatsfield[e].tofieldname)){r=null,l.ordered=!1;break}if(null!==r){for(let e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===r.scanForField(e.tofieldname)){r=null,l.ordered=!1;break}}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;i&&(e=this._reformulateWhereClauseWithoutGroupByFields(i));let t=null;r&&(t=this._reformulateOrderClauseWithoutGroupByFields(r));let n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(a),s=!0===l.nowhereclause?new f.Z(n._candidates.slice().concat(n._known.slice()),[],!0===l.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new f.Z(n._candidates.slice(),n._known.slice(),!0===l.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition))}let u=this._parent;if(this._adaptedFields.length>0&&(u=new o.Xx({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===l.nowhereclause)s=new f.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new d.Z({parentfeatureset:u,orderbyclause:new p.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=u;if(null!==i){let t=null;i&&(t=this._reformulateWhereClauseWithoutGroupByFields(i)),e=new n.Z({parentfeatureset:e,whereclause:t})}s=new f.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new d.Z({parentfeatureset:e,orderbyclause:new p.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return s}_reformulateWhereClauseWithoutStatsFields(e){for(let t of this._decodedStatsfield)e=(0,y.bB)(e,t.tofieldname,(0,y.zR)(t.workingexpr,_.Bj.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(let t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=(0,y.bB)(e,t.tofieldname,(0,y.zR)(t.expression,_.Bj.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){let t=[];for(let e of this._decodedGroupbyfield)e.tofieldname!==e.name&&t.push({field:e.tofieldname,newfield:e.name});return t.length>0?e.replaceFields(t):e}_clonePageDefinition(e){return null===e?null:!0===e.aggregatefeaturesetpagedefinition?{aggregatefeaturesetpagedefinition:!0,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,internal:e.internal}:this._parent._clonePageDefinition(e)}async _refineSetBlock(e,t,i){return!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery)?(await this._expandPagedSet(e,this._maxQuery,0,0,i),this._refineSetBlock(e,t,i)):(this._checkCancelled(i),e._candidates.length,this._refineKnowns(e,t),e._candidates.length,e._candidates.length,e)}_expandPagedSet(e,t,i,r,a){return this._expandPagedSetFeatureSet(e,t,i,r,a)}async _getPhysicalPage(e,t,i){if(!0===e.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(e,e.pagesDefinition.resultRecordCount,i,[]);let r=await this._getAgregagtePhysicalPage(e,t,i);for(let e of r){let t={geometry:e.geometry,attributes:{}},i={};for(let t in e.attributes)i[t.toLowerCase()]=e.attributes[t];for(let e of this._decodedGroupbyfield)t.attributes[e.tofieldname]=i[e.name.toLowerCase()];for(let e of this._decodedStatsfield)t.attributes[e.tofieldname]=i[e.field.toLowerCase()];this._featureCache[t.attributes[this.objectIdField]]=new l.Z(t)}return r.length}_sequentialGetPhysicalItem(e,t,i,r){return new Promise((a,s)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(i)),!0===e.pagesDefinition.internal.fullyResolved||0===t?a(r.length):this._nextAggregateItem(e,t,i,r,s=>{null===s?a(r.length):(t-=1,a(this._sequentialGetPhysicalItem(e,t,i,r)))},s)})}_nextAggregateItem(e,t,i,r,a,n){try{(0,s.a0)(e.pagesDefinition.internal.iterator.next()).then(s=>{if(null===s){if(null!==e.pagesDefinition.internal.workingItem){let t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);r.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,a(null)}else e.pagesDefinition.internal.fullyResolved=!0,a(null)}else{let l=this._generateAggregateHash(s);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[s],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){let i=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return r.push(i),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(i.attributes[this.objectIdField]),t-=1,e.pagesDefinition.internal.workingItem={features:[s],id:l},void a(i)}e.pagesDefinition.internal.workingItem.features.push(s)}this._nextAggregateItem(e,t,i,r,a,n)}},n)}catch(e){n(e)}}_calculateFieldStat(e,t,i){let r=[];for(let i of e.features)if(null!==t.workingexpr){let e=t.workingexpr.calculateValue(i);null!==e&&(e instanceof I.u||e instanceof C.n?r.push(e.toNumber()):e instanceof b.H?r.push(e.toMilliseconds()):r.push(e))}else r.push(null);i.attributes[t.tofieldname]=(0,S.U)(t.typeofstat,[r])}_calculateAndAppendAggregateItem(e){let t={attributes:{},geometry:null};for(let i of this._decodedGroupbyfield){let r=i.singlefield?e.features[0].attributes[i.singlefield]:m.default.convertValueToStorageFormat(i.expression.calculateValue(e.features[0]),i.sqlType);t.attributes[i.tofieldname]=r}for(let i of this._decodedStatsfield)this._calculateFieldStat(e,i,t);let i=[];for(let r=0;r<this._decodedStatsfield.length;r++)i.push(this._calculateFieldStat(e,this._decodedStatsfield[r],t));return this._featureCache[t.attributes[this.objectIdField]]=new l.Z({attributes:t.attributes,geometry:t.geometry}),t}_generateAggregateHash(e){let t="";for(let i of this._decodedGroupbyfield){let r=i.singlefield?e.attributes[i.singlefield]:i.expression.calculateValue(e);t+=null==r?":":":"+r.toString()}return(0,F.F)(t,F.M.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){c.Z._featuresetFunctions.groupby=function(e,t){return new k({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}var N=i(7390),x=i(50188),L=i(84114),A=i(74667),E=i(73691),P=i(44960),Z=i(78177),O=i(80032),j=i(91229),B=i(78532),G=i(29126),U=i(93722),q=i(5829),M=i(92806);class W extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerDynamic",this._removeGeometry=!1,this._overrideFields=null,this.formulaCredential=null,this._pageJustIds=!1,this._requestStandardised=!1,this._useDefinitionExpression=!0,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return _.tI}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){let t=this.urlQueryPath+","+(0,_.hd)(e.toJSON());return(0,F.F)(t,F.M.String)}async loadImpl(){return!0===this._layer.loaded||await this._layer.load(),this._initialiseFeatureSet(),this}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,null!==this._overrideFields){if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{let e=[],t=[];for(let i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(let r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}}if(this._layer.source&&this._layer.source.sourceJSON){let e=this._layer.source.sourceJSON.currentVersion;
1!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=_.Bj.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=_.Bj.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=_.Bj.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=_.Bj.Standardised))}for(let e of(this.objectIdField=this._layer.objectIdField,this.fields))"global-id"===e.type&&(this.globalIdField=e.name);this.subtypeField=this._layer.subtypeField??"",this.subtypes=this._layer.subtypes,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}_isInFeatureSet(){return _.dj.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();let t=new q.Z;this.datesInUnknownTimezone&&(t.timeReferenceUnknownClient=!0),t.where=e.replace("OBJECTID",this._layer.objectIdField);try{return await this._layer.queryObjectIds(t),!0}catch(e){return!1}}_canUsePagination(){return!(!this._layer.capabilities||!this._layer.capabilities.query||!0!==this._layer.capabilities.query.supportsPagination)}_cacheableFeatureSetSourceKey(){return this._layer.url}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion||"SDE.DEFAULT":""}nativeCapabilities(){return{title:this._layer.title??"",source:this,canQueryRelated:!0,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:this._requestStandardised}}_createQuery(){let e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,this.datesInUnknownTimezone&&(e.timeReferenceUnknownClient=!0),this._requestStandardised&&(e.sqlFormat="standard"),this._useDefinitionExpression?"subtype-group"===this._layer.type&&(e.where=this._layer.definitionExpression):e.where=null,e}executeQuery(e,t){let i="execute"===t?this._layer.queryFeatures.bind(this._layer):"executeForCount"===t?this._layer.queryFeatureCount.bind(this._layer):this._layer.queryObjectIds.bind(this._layer),r=null;if(this.recentlyUsedQueries){let t=this.convertQueryToLruCacheKey(e);null===(r=this.recentlyUsedQueries.getFromCache(t))&&(r=i(e),this.recentlyUsedQueries.addToCache(t,r),r=r.catch(e=>{throw this.recentlyUsedQueries?.removeFromCache(t),e}))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===r&&(r=i(e)),r}async _getFilteredSet(e,t,i,r,a){let s=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e)return new f.Z([],[],!0,null);if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,i,r,a);let n="",l=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=r.constructClause(),l=!0);let u=this._createQuery();u.where=(0,O._$)(u.where,null===i?null===t?"1=1":"":(0,y.zR)(i,s)),u.spatialRelationship=this._makeRelationshipEnum(e),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null,u.geometry=null===t?null:t,u.relationParameter=this._makeRelationshipParam(e);let o=await this.executeQuery(u,"executeForIds");return null===o&&(o=[]),this._checkCancelled(a),new f.Z([],o,l,null)}_expandPagedSet(e,t,i,r,a){return this._expandPagedSetFeatureSet(e,t,i,r,a)}async _getFilteredSetUsingPaging(e,t,i,r,a){let s="",n=!1;null!==r&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(s=r.constructClause(),n=!0);let l=await this.databaseType(),u=null===i?null===t?"1=1":"":(0,y.zR)(i,l),o=this._maxQueryRate(),d=this._layer.capabilities?.query.maxRecordCount;null!=d&&d<o&&(o=d);let h=null;if(!0===this._pageJustIds)h=new f.Z([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:s,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let i=!0;!0===this._removeGeometry&&(i=!1);let r=this._overrideFields??this._fieldsIncludingObjectId(["*"]);h=new f.Z([],["GETPAGES"],n,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:r.join(","),resultRecordCount:o,resultOffset:0,geometry:null===t?null:t,where:u,orderByFields:s,returnGeometry:i,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(h,o,0,1,a),h}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,spatialRel:e.spatialRel,relationParam:e.relationParam,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupBy
1FieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){let r=e.pagesDefinition.internal.lastRetrieved,a=e.pagesDefinition.internal.lastPage,s=this._createQuery();s.spatialRelationship=e.pagesDefinition.spatialRel,s.relationParameter=e.pagesDefinition.relationParam,s.outFields=e.pagesDefinition.outFields.split(","),s.num=e.pagesDefinition.resultRecordCount,s.start=e.pagesDefinition.internal.lastPage,s.geometry=e.pagesDefinition.geometry,s.where=(0,O._$)(s.where,e.pagesDefinition.where),s.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,s.returnGeometry=e.pagesDefinition.returnGeometry,s.outSpatialReference=this.spatialReference;let n=await this.executeQuery(s,"execute");if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return"done";let l=this._layer.objectIdField;for(let t=0;t<n.features.length;t++)e.pagesDefinition.internal.set[r+t]=n.features[t].attributes[l];if(!1===this._pageJustIds)for(let e=0;e<n.features.length;e++)this._featureCache[n.features[e].attributes[l]]=n.features[e];return(void 0===n.exceededTransferLimit&&n.features.length!==e.pagesDefinition.resultRecordCount||!1===n.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+n.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];let t=e.slice();if(t.includes("*"))return t;let i=!1;for(let e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFeatures(e,t,i,r){let a=[];if(-1!==t&&void 0===this._featureCache[t]&&a.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,r),this._getFeatures(e,t,i,r);let s=0;for(let r=e._lastFetchedIndex;r<e._known.length;r++){if(e._lastFetchedIndex+=1,s++,void 0===this._featureCache[e._known[r]]){let i=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){let t=this._layer._mode;if(void 0!==t._featureMap[e._known[r]]){let a=t._featureMap[e._known[r]];null!==a&&(i=!0,this._featureCache[e._known[r]]=a)}}if(!1===i&&(e._known[r]!==t&&a.push(e._known[r]),a.length>=this._maxProcessingRate()-1))break}if(s>=i&&0===a.length)break}if(0===a.length)return"success";let n=this._createQuery();n.objectIds=a,n.outFields=this._overrideFields??this._fieldsIncludingObjectId(["*"]),n.returnGeometry=!0,!0===this._removeGeometry&&(n.returnGeometry=!1),n.outSpatialReference=this.spatialReference;let l=await this.executeQuery(n,"execute");if(this._checkCancelled(r),void 0!==l.error)throw new h.EN(h.H9.RequestFailed,{reason:l.error});let u=this._layer.objectIdField;for(let e=0;e<l.features.length;e++)this._featureCache[l.features[e].attributes[u]]=l.features[e];return"success"}async _getDistinctPages(e,t,i,r,a,s,n,l,u){await this._ensureLoaded();let o=await this.databaseType(),d=i.parseTree.column,c=this._layer.fields??[];for(let e=0;e<c.length;e++)if(c[e].name.toLowerCase()===d.toLowerCase()){d=c[e].name;break}let f=this._createQuery();f.where=(0,O._$)(f.where,null===s?null===a?"1=1":"":(0,y.zR)(s,o)),f.spatialRelationship=this._makeRelationshipEnum(r),f.relationParameter=this._makeRelationshipParam(r),f.geometry=null===a?null:a,f.returnDistinctValues=!0,f.returnGeometry=!1,f.outFields=[d];let p=await this.executeQuery(f,"execute");if(this._checkCancelled(u),!p.hasOwnProperty("features"))throw new h.EN(h.H9.InvalidStatResponse);let _=!1;for(let e=0;e<c.length;e++)if(c[e].name===d){"date"===c[e].type&&(_=!0);break}for(let e=0;e<p.features.length;e++){if(_){let t=p.features[e].attributes[d];null!==t?l.push(new Date(t)):l.push(t)}else l.push(p.features[e].attributes[d]);if(l.length>=n)break}return 0===p.features.length?l:p.features.length===this._layer.capabilities?.query.maxRecordCount&&l.length<n?{calculated:!0,result:await this._getDistinctPages(e+p.features.length,t,i,r,a,s,n,l,u)}:l}async _distinctStat(e,t,i,r,a,s,n){return{calculated:!0,result:await this._getDistinctPages(0,e,t,i,r,a,s,[],n)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,i,r){let a=await this.databaseType();if(this.isTable()&&i&&null!==t&&""!==t)return{calculated:!0,result:0};let s=this._createQuery();return s.where=(0,O._$)(s.where,null===r?null===i?"1=1":"":(0,y.zR)(r,a)),s.spatialRelationship=this._makeRelationshipEnum(t),s.relationParameter=this._makeRelationshipParam(t),s.geometry=null===i?null:i,s.returnGeometry=!1,{calculated:!0,result:await this.executeQuery(s,"executeForCount")}}async _stats(e,t,i,r,a,s,n){await this._ensureLoaded();
1let l=this._layer.capabilities?.query,u=!!l?.supportsSqlExpression,o=!!l?.supportsStatistics,d=!!l?.supportsDistinct;if("count"===e)return d?this._countstat(e,i,r,a):{calculated:!1};if(!1===o||!1===(0,y.y5)(t)&&!1===u||!1===t.isStandardized)return""!==i||null!==a?{calculated:!1}:this._manualStat(e,t,s,n);if("distinct"===e)return!1===d?""!==i||null!==a?{calculated:!1}:this._manualStat(e,t,s,n):this._distinctStat(e,t,i,r,a,s,n);let c=await this.databaseType();if(this.isTable()&&r&&null!==i&&""!==i)return{calculated:!0,result:null};let f=this._createQuery();f.where=(0,O._$)(f.where,null===a?null===r?"1=1":"":(0,y.zR)(a,c)),f.spatialRelationship=this._makeRelationshipEnum(i),f.relationParameter=this._makeRelationshipParam(i),f.geometry=null===r?null:r;let p=new M.Z;p.statisticType=(0,P.g3)(e),p.onStatisticField=(0,y.zR)(t,c),p.outStatisticFieldName="ARCADE_STAT_RESULT",f.returnGeometry=!1;let _="ARCADE_STAT_RESULT";f.outStatistics=[p];let g=await this.executeQuery(f,"execute");if(!g.hasOwnProperty("features")||0===g.features.length)throw new h.EN(h.H9.InvalidStatResponse);let m=!1,w=g.fields??[];for(let e=0;e<w.length;e++)if("ARCADE_STAT_RESULT"===w[e].name.toUpperCase()){_=w[e].name,"date"===w[e].type&&(m=!0);break}if(m){let e=g.features[0].attributes[_];return null!==e&&(e=new Date(g.features[0].attributes[_])),{calculated:!0,result:e}}return{calculated:!0,result:g.features[0].attributes[_]}}_stat(e,t,i,r,a,s,n){return this._stats(e,t,i,r,a,s,n)}async _canDoAggregates(e,t){await this._ensureLoaded();let i=!1,r=this._layer.capabilities?.query,a=!0===r?.supportsSqlExpression;
1if(null!=r&&!0===r.supportsStatistics&&!0===r.supportsOrderBy&&(i=!0),i)for(let e=0;e<t.length-1;e++)(!1===t[e].workingexpr?.isStandardized||!1===(0,y.y5)(t[e].workingexpr)&&!1===a)&&(i=!1);return!1!==i}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,s,n){await this._ensureLoaded();let l=await this.databaseType(),u=null;if(!this._layer.capabilities.query.supportsPaginationOnAggregatedQueries){let t=this.getFieldsIndex();u={keyFields:e.map((e,i)=>({name:t.normalizeFieldName(e)??e,asc:null==s||1===s._directions[i]}))}}let o="",d=!1;null!=s&&!0===this._layer.capabilities?.query?.supportsOrderBy&&(null==u||(0,Z.P$)(e,0,e.length,s._fields,0,Math.min(s._fields.length,e.length),(e,t)=>e.toLowerCase()===t.toLowerCase()))&&(o=s.constructClause(),d=!0),""===o&&(o=e.join(","));let h=[];for(let e=0;e<t.length;e++){let i=new M.Z;i.onStatisticField=null!==t[e].workingexpr?(0,y.zR)(t[e].workingexpr,l):"",i.outStatisticFieldName=t[e].field,i.statisticType=t[e].toStatisticsName(),h.push(i)}let c=this._maxQueryRate(),p=this._layer.capabilities?.query.maxRecordCount;null!=p&&p<c&&(c=p);let _=null===a?null===r?"1=1":"":(0,y.zR)(a,l);return new f.Z([],["GETPAGES"],d,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(i),relationParam:this._makeRelationshipParam(i),outFields:["*"],useOIDpagination:!1,generatedOid:n,resultRecordCount:c,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:h,geometry:null===r?null:r,where:_,orderByFields:o,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1,keysetPagination:u}})}async _getAgregagtePhysicalPage(e,t,i){let r=e.pagesDefinition.where;if(!0===e.pagesDefinition.useOIDpagination&&(r=(0,O._$)(r,e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString())),null!=e.pagesDefinition.internal.keysetPagination?.clause){if(!this._layer.capabilities.query.supportsOrderBy)throw new h.EN(h.H9.NotImplemented);r=(0,O._$)(r,(0,y.zR)(e.pagesDefinition.internal.keysetPagination.clause,await this.databaseType()))}let a=e.pagesDefinition.internal.lastRetrieved,s=e.pagesDefinition.internal.lastPage,n=this._createQuery();if(n.where=(0,O._$)(n.where,r),n.spatialRelationship=e.pagesDefinition.spatialRel,n.relationParameter=e.pagesDefinition.relationParam,n.outFields=e.pagesDefinition.outFields,n.outStatistics=e.pagesDefinition.outStatistics,n.geometry=e.pagesDefinition.geometry,n.groupByFieldsForStatistics=e.pagesDefinition.groupByFieldsForStatistics,n.num=e.pagesDefinition.resultRecordCount,n.start=e.pagesDefinition.internal.lastPage,n.returnGeometry=e.pagesDefinition.returnGeometry,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,this.isTable()&&n.geometry&&n.spatialRelationship)return[];let u=await this.executeQuery(n,"execute");if(this._checkCancelled(i),!u.hasOwnProperty("features"))throw new h.EN(h.H9.InvalidStatResponse);let o=[];if(e.pagesDefinition.internal.lastPage!==s)return[];u.features.length>0&&void 0===u.features[0].attributes[e.pagesDefinition.generatedOid]&&(e.pagesDefinition.generatedOid=e.pagesDefinition.generatedOid.toLowerCase());for(let t=0;t<u.features.length;t++)e.pagesDefinition.internal.set[a+t]=u.features[t].attributes[e.pagesDefinition.generatedOid];for(let e=0;e<u.features.length;e++)o.push(new l.Z({attributes:u.features[e].attributes,geometry:null}));return e.pagesDefinition.internal.keysetPagination?0!==u.features.length&&u.exceededTransferLimit?function(e,t){null==e.clause&&(e.clause=function(e){if(0===e.length)throw new h.EN(h.H9.NeverReach);let t=[];for(let i=0;i<e.length;i++){let r=e[i],a=[`"${r.name.replaceAll('"','""')}" ${r.asc?">":"<"} @last_${i}`];for(let t=0;t<i;t++){let i=e[t];a.push(`"${i.name.replaceAll('"','""')}" = @last_${t}`)}t.push(a.join(" AND "))}let i=t.join(" OR ");return m.default.create(i)}(e.keyFields));for(let i=0;i<e.keyFields.length;i++){let r=e.keyFields[i].name;e.clause.parameters[`last_${i}`]=t.attributes[r]}}(e.pagesDefinition.internal.keysetPagination,o.at(-1)):e.pagesDefinition.internal.fullyResolved=!0:!0===e.pagesDefinition.useOIDpagination?0===u.features.length?e.pagesDefinition.internal.fullyResolved=!0:e.pagesDefinition.internal.lastMaxId=u.features[u.features.length-1].attributes[e.pagesDefinition.generatedOid]:(void 0===u.exceededTransferLimit&&u.features.length!==e.pagesDefinition.resultRecordCount||!1===u.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=a+u.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,o}static create(e,t,i,r,a){return new W({layer:new G.default({url:e,outFields:null===t?["*"]:t}),spatialReference:i,lrucache:r,interceptor:a})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON?.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return(0,_.US)(this._layer.parsedUrl.path)}async queryAttachments(e,t,i,r,a){let s=this._layer;if(function(e){let t=e.capabilities;return t?.data.supportsAttachment&&t?.operations.supportsQueryAttachments}(s)){let n={objectIds:[e],returnMetadata:a};(t&&t>0||i&&i>0)&&(n.size=[t&&t>0?t:0,i&&i>0?i:t+1]),r&&r.length>0&&(n.attachmentTypes=r),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:s,query:n,method:"attachments"});let l=await s.queryAttachments(new U.Z(n)),u=[];return l&&l[e]&&l[e].forEach(t=>{let i=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString(),r=null;a&&t.exifInfo&&(r=E.Z.convertJsonToArcade(t.exifInfo,"system",!0)),u.push(new A.Z(t.id,t.name,t.contentType,t.size,i,r,t.keywords??null))}),u}return[]}async queryRelatedFeatures(e){let t={f:"json",relationshipId:e.relationshipId.toString(),definitionExpression:e.where,outFields:e.outFields?.join(","),returnGeometry:e.returnGeometry.toString()};void 0!==e.resultOffset&&null!==e.resultOffset&&(t.resultOffset=e.resultOffset.toString()),void 0!==e.resultRecordCount&&null!==e.resultRecordCount&&(t.resultRecordCount=e.resultRecordCount.toString()),e.orderByFields&&(t.orderByFields=e.orderByFields.join(",")),e.objectIds&&e.objectIds.length>0&&(t.objectIds=e.objectIds.join(",")),e.outSpatialReference&&(t.outSR=(0,B.B9)(e.outSpatialReference)),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:t,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});let i=await (0,r.Z)(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:t});if(i.data){let e={},t=i.data;if(t?.relatedRecordGroups){let i=t.spatialReference;for(let r of t.relatedRecordGroups){let a=r.objectId,s=[];for(let e of r.relatedRecords){e.geometry&&(e.geometry.spatialReference=i);let t=new l.Z({geometry:e.geometry?(0,j.im)(e.geometry):null,attributes:e.attributes});s.push(t)}e[a]={features:s,exceededTransferLimit:!0===t.exceededTransferLimit}}}return e}throw new h.EN(h.H9.InvalidRequest)}async getFeatureByObjectId(e,t){let i=this._createQuery();i.outFields=t,i.returnGeometry=!1,i.outSpatialReference=this.spatialReference,i.where=(0,O._$)(i.where,this.objectIdField+"="+e.toString()),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:i,method:"execute"});let r=await this._layer.queryFeatures(i);return 1===r.features.length?r.features[0]:null}async getIdentityUser(){await this.load();let e=L.id?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();let e=L.id?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let t=this._layer.url,i=t.toLowerCase().indexOf("/rest/services");if(t=i>-1?t.slice(0,i):t){t+="/rest/info";try{let e=await (0,r.Z)(t,{query:{f:"json"}}),i="";return e.data?.owningSystemUrl&&(i=e.data.owningSystemUrl),i}catch(e){}}return""}getDataSourceFeatureSet(){let e=new W({layer:this._layer,spatialReference:this.spatialReference??void 0,outFields:this._overrideFields??void 0,includeGeometry:!this._removeGeometry,lrucache:this.recentlyUsedQueries??void 0,interceptor:this.featureSetQueryInterceptor??void 0});return e._useDefinitionExpression=!1,e}get preferredTimeZone(){return this._layer.preferredTimeZone??null}get dateFieldsTimeZone(){return this._layer.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone??!1}get editFieldsInfo(){return this._layer.editFieldsInfo??null}get timeInfo(){return this._layer.timeInfo??null}async getFeatureSetInfo(){if(this.fsetInfo)return this.fsetInfo;let e=null,t="serviceItemId"in this._layer?this._layer.serviceItemId:null,i=this._layer.parsedUrl?.path??null;if(i){let a=await (0,r.Z)(i,{responseType:"json",query:{f:"json"}});e=a?.data?.name??null,t=a?.data?.serviceItemId??null}let a=this._layer.title&&null!==(this._layer.parent??null);return this.featureSetInfo={layerId:this._layer.layerId,layerName:""===e?null:e,itemId:""===t?null:t,serviceLayer
1Url:""===i?null:i,webMapLayerId:a?this._layer.id??null:null,webMapLayerTitle:a?this._layer.title??null:null,className:null,objectClassId:null},this.fsetInfo}}var Q=i(92475),V=i(71939);class $ extends c.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerRelated",this._findObjectId=-1,this._requestStandardised=!1,this._removeGeometry=!1,this._overrideFields=null,this.featureObjectId=null,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,this._findObjectId=e.objectId,this.featureObjectId=e.objectId,this.relationship=e.relationship,this._relatedLayer=e.relatedLayer,void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return _.tI}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return await Promise.all([this._layer.load(),this._relatedLayer?.load()]),this._initialiseFeatureSet(),this}nativeCapabilities(){return this._relatedLayer.nativeCapabilities()}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._relatedLayer.geometryType,this.fields=this._relatedLayer.fields.slice(),this.hasZ=this._relatedLayer.hasZ,this.hasM=this._relatedLayer.hasM,null!==this._overrideFields){if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{let e=[],t=[];for(let i of this.fields)if("oid"===i.type)e.push(i),t.push(i.name);else for(let r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}}let e=this._layer.nativeCapabilities();e&&(this._databaseType=e.databaseType,this._requestStandardised=e.requestStandardised),this.objectIdField=this._relatedLayer.objectIdField,this.globalIdField=this._relatedLayer.globalIdField,this.hasM=this._relatedLayer.supportsM,this.hasZ=this._relatedLayer.supportsZ,this.typeIdField=this._relatedLayer.typeIdField,this.types=this._relatedLayer.types,this.subtypeField=this._relatedLayer.subtypeField,this.subtypes=this._relatedLayer.subtypes}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return _.dj.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(e){let t={};for(let i of this.fields)t[i.name]=e.attributes[i.name];return new l.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}async _getFilteredSet(e,t,i,r,a){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e)return new f.Z([],[],!0,null);let s=this._layer.nativeCapabilities();if(!1===s.canQueryRelated)return new f.Z([],[],!0,null);if(s.capabilities?.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,i,r,a);let n="",l=!1;null!==r&&!0===s.capabilities?.queryRelated.supportsOrderBy&&(n=r.constructClause(),l=!0);let u=new V.default;u.objectIds=[this._findObjectId];let o=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]);u.outFields=o,u.relationshipId=this.relationship.id,u.where="1=1";let d=!0;!0===this._removeGeometry&&(d=!1),u.returnGeometry=d,this._requestStandardised&&(u.sqlFormat="standard"),u.outSpatialReference=this.spatialReference,u.orderByFields=""!==n?n.split(","):null;let h=await s.source.queryRelatedFeatures(u);this._checkCancelled(a);let c=h[this._findObjectId]?h[this._findObjectId].features:[],p=[];for(let e=0;e<c.length;e++)this._featureCache[c[e].attributes[this._relatedLayer.objectIdField]]=c[e],p.push(c[e].attributes[this._relatedLayer.objectIdField]);let _=t&&null!==e&&""!==e,y=null!=i;return new f.Z(_||y?p:[],_||y?[]:p,l,null)}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];let t=e.slice();if(t.includes("*"))return t;let i=!1;for(let e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){i=!0;break}return!1===i&&t.push(this.objectIdField),t}async _getFilteredSetUsingPaging(e,t,i,r,a){let s="",n=!1,l=this._layer.nativeCapabilities();null!==r&&!0===l.capabilities?.queryRelated.supportsOrderBy&&(s=r.constructClause(),n=!0),await this.databaseType();let u=this._maxQueryRate(),o=l.capabilities?.query.maxRecordCount;null!=o&&o<u&&(u=o);let d=t&&null!==e&&""!==e,h=null!=i,c=null,p=!0;!0===this._removeGeometry&&(p=!1);let _=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map(e=>e.name):["*"]);return c=new f.Z(d||h?["GETPAGES"]:[],d||h?[]:["GETPAGES"],n,{outFields:_.join(","),resultRecordCount:u,resultOffset:0,objectIds:[this._findObjectId],where:"1=1",orderByFields:s,returnGeometry:p,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(c,u,0,0,a),c}_expandPagedSet(e,t,i,r,a){return this._expandPagedSetFeatureSet(e,t,i,r,a)}_clonePageDefinition(e){return null===e?null:!0!==e.groupbypage?{groupbypage:!1,outFields:e.outFields,resultRecordCount:e.resultRecordCount,resultOffset:e.resultOffset,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}:{groupbypage:!0,outFields:e.outFields,resultRecordCount:e.resultRecordCount,useOIDpagination:e.useOIDpagination,generatedOid:e.generatedOid,groupBy
1FieldsForStatistics:e.groupByFieldsForStatistics,resultOffset:e.resultOffset,outStatistics:e.outStatistics,geometry:e.geometry,where:e.where,objectIds:e.objectIds,orderByFields:e.orderByFields,returnGeometry:e.returnGeometry,returnIdsOnly:e.returnIdsOnly,internal:e.internal}}async _getPhysicalPage(e,t,i){let r=e.pagesDefinition.internal.lastRetrieved,a=e.pagesDefinition.internal.lastPage,s=this._layer.nativeCapabilities(),n=new V.default;!0===this._requestStandardised&&(n.sqlFormat="standard"),n.relationshipId=this.relationship.id,n.objectIds=e.pagesDefinition.objectIds,n.resultOffset=e.pagesDefinition.internal.lastPage,n.resultRecordCount=e.pagesDefinition.resultRecordCount,n.outFields=e.pagesDefinition.outFields.split(","),n.where=e.pagesDefinition.where,n.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,n.returnGeometry=e.pagesDefinition.returnGeometry,n.outSpatialReference=this.spatialReference;let l=await s.source.queryRelatedFeatures(n);if(this._checkCancelled(i),e.pagesDefinition.internal.lastPage!==a)return 0;let u=l[this._findObjectId]?l[this._findObjectId].features:[];for(let t=0;t<u.length;t++)e.pagesDefinition.internal.set[r+t]=u[t].attributes[this._relatedLayer.objectIdField];for(let e=0;e<u.length;e++)this._featureCache[u[e].attributes[this._relatedLayer.objectIdField]]=u[e];let o=!l[this._findObjectId]||!1===l[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&o&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=r+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,t,i,r){let a=[];-1!==t&&void 0===this._featureCache[t]&&a.push(t);let s=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,s))return await this._expandPagedSet(e,s,0,0,r),this._getFeatures(e,t,i,r);let n=0;for(let r=e._lastFetchedIndex;r<e._known.length&&(++n<=i&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[r]&&void 0===this._featureCache[e._known[r]]&&(e._known[r]!==t&&a.push(e._known[r]),a.length>i)))&&!(n>=i&&0===a.length);r++);if(0===a.length)return"success";throw new h.EN(h.H9.MissingFeatures)}async _refineSetBlock(e,t,i){return e}async _stat(e,t,i,r,a,s,n){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,i,r,a){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,i,r,a){return this._relatedLayer.queryAttachments(e,t,i,r,a)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeZone(){return this._relatedLayer?.preferredTimeZone??null}get dateFieldsTimeZone(){return this._relatedLayer?.dateFieldsTimeZone??null}get datesInUnknownTimezone(){return this._relatedLayer?.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer?.editFieldsInfo??null}get timeInfo(){return this._relatedLayer?.timeInfo??null}async getFeatureSetInfo(){return this.fsetInfo??this._layer.featureSetInfo}}var J=i(69837),z=i(81133),K=i(19660),H=i(37758);function X(){null===J.Z.applicationCache&&(J.Z.applicationCache=new J.Z)}async function Y(e,t,i){if(J.Z.applicationCache){let i=J.Z.applicationCache.getLayerInfo(e);if(i){let r=await i;return new G.default({url:e,outFields:t,sourceJSON:r})}let r=new G.default({url:e,outFields:t}),a=(async()=>(await r.load(),r.sourceJSON))();if(J.Z.applicationCache){J.Z.applicationCache.setLayerInfo(e,a);try{return await a,r}catch(t){throw J.Z.applicationCache.clearLayerInfo(e),t}}return await a,r}if(null!=i){let r=i.getCachedLayerMetadata(e);if(r){let i=await r;return new G.default({url:e,outFields:t,sourceJSON:i})}let a=new G.default({url:e,outFields:t}),s=(async()=>(await a.load(),a.sourceJSON))();i.setCachedLayerMetadata(e,s);try{return await s,a}catch(t){throw i.removeCachedLayerMetadata(e,s),t}}
1return new G.default({url:e,outFields:t})}async function ee(e,t,i,r,a,s=null){return et(await Y(e,["*"],a),t,i,r,a,s)}function et(e,t=null,i=null,r=!0,a=null,s=null){switch(e.type){case"catalog-footprint":return et(e.parent,t,i,r,a,s);case"subtype-sublayer":{let n=et(e.parent,t,i,r,a,s);return n.filter(m.default.create(e.parent.subtypeField+"="+e.subtypeCode.toString(),{fieldsIndex:e.parent.fieldsIndex,timeZone:n.dateFieldsTimeZoneDefaultUTC}))}case"csv":case"geojson":case"knowledge-graph-sublayer":case"wfs":return new Q.Z({layer:e,spatialReference:t,outFields:i,includeGeometry:r,lrucache:a,interceptor:s});case"catalog":case"feature":case"oriented-imagery":case"subtype-group":{let n={layer:e,spatialReference:t,outFields:i,includeGeometry:r,lrucache:a,interceptor:s};return!e.url&&e.source?new Q.Z(n):new W(n)}default:throw Error(`Unsupported layer type: ${e.type}`)}}async function ei(e){if(null!==J.Z.applicationCache){let t=J.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}let t=(async()=>{let t=await (0,r.Z)(e,{responseType:"json",query:{f:"json"}});return t.data?t.data:null})();if(null!==J.Z.applicationCache){J.Z.applicationCache.setLayerInfo(e,t);try{return await t}catch(t){throw J.Z.applicationCache.clearLayerInfo(e),t}}return t}async function er(e,t){let i="QUERYDATAELEMTS:"+t.toString()+":"+e;if(null!==J.Z.applicationCache){let e=J.Z.applicationCache.getLayerInfo(i);if(null!==e)return e}let a=(async()=>{let i=await (0,r.Z)(e+"/queryDataElements",{method:"post",responseType:"json",query:{layers:JSON.stringify([t.toString()]),f:"json"}});if(i.data){let e=i.data;if(e.layerDataElements?.[0])return e.layerDataElements[0]}throw new h.EN(h.H9.DataElementsNotFound)})();if(null!==J.Z.applicationCache){J.Z.applicationCache.setLayerInfo(i,a);try{return await a}catch(e){throw J.Z.applicationCache.clearLayerInfo(i),e}}return a}async function ea(e,t){if(null!==J.Z.applicationCache){let t=J.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}if(null!=t){let i=t.getCachedServiceMetadata(e);if(null!=i)return i}let i=(async()=>{let t=await (0,r.Z)(e,{responseType:"json",query:{f:"json"}});if(t.data){let e=t.data;return e.layers||(e.layers=[]),e.tables||(e.tables=[]),e}return{layers:[],tables:[]}})();if(null!==J.Z.applicationCache){J.Z.applicationCache.setLayerInfo(e,i);try{return await i}catch(t){throw J.Z.applicationCache.clearLayerInfo(e),t}}if(null!=t){t.setCachedServiceMetadata(e,i);try{return await i}catch(r){throw t.removeCachedServiceMetadata(e,i),r}}return i}async function es(e,t,i){let r={metadata:null,networkId:-1,unVersion:3,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map,queryelem:null,layerNameLkp:{},lkp:null},a=await ea(e,null);if(r.metadata=a,void 0!==a.controllerDatasetLayers?.utilityNetworkLayerId&&null!==a.controllerDatasetLayers.utilityNetworkLayerId){if(a.layers)for(let e of a.layers)r.layerNameLkp[e.id]=e.name;if(a.tables)for(let e of a.tables)r.layerNameLkp[e.id]=e.name;let s=a.controllerDatasetLayers.utilityNetworkLayerId;r.networkId=s;let n=await er(e,s);if(n){for(let e of(r.queryelem=n,r.queryelem?.dataElement&&void 0!==r.queryelem.dataElement.schemaGeneration&&(r.unVersion=r.queryelem.dataElement.schemaGeneration),r.lkp={},r.queryelem.dataElement.domainNetworks||(r.queryelem.dataElement.domainNetworks=[]),r.queryelem.dataElement.domainNetworks)){for(let t of e.edgeSources??[]){let e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}for(let t of e.junctionSources??[]){let e={layerId:t.layerId,sourceId:t.sourceId,className:r.layerNameLkp[t.layerId]??null};r.layerIdLookup.set(e.layerId,e),r.sourceIdLookup.set(e.sourceId,e),e.className&&(r.lkp[e.className]=e)}}if(r.queryelem.dataElement.terminalConfigurations)for(let e of r.queryelem.dataElement.terminalConfigurations)for(let t of e.terminals)r.terminals.push({terminalId:t.terminalId,terminalName:t.terminalName});let a=await ei(e+"/"+s);if(void 0!==a.systemLayers?.associationsTableId&&null!==a.systemLayers.associationsTableId){let s=null;if(i&&r.unVersion<8){let i=[];r.unVersion>=4&&(i.push("STATUS"),i.push("PERCENTALONG")),s=await ee(e+"/"+a.systemLayers.associationsTableId,t,["OBJECTID","FROMNETWORKSOURCEID","TONETWORKSOURCEID","FROMGLOBALID","TOGLOBALID","TOTERMINALID","FROMTERMINALID","ASSOCIATIONTYPE","ISCONTENTVISIBLE","GLOBALID",...i],!1,null,null),await s.load(),r.unVersion>=4&&(s=s.filter(m.default.create("STATUS NOT IN (1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, 33, 34, 35, 36, 37, 38, 39, 41, 42, 43, 44, 45, 46, 47, 49, 50, 51, 52, 53, 54, 55, 57, 58, 59, 60, 61, 62, 63)",{fieldsIndex:s.getFieldsIndex(),timeZone:s.dateFieldsTimeZoneDefaultUTC})),await s.load())}return{lkp:r.lkp,associations:s,unVersion:r.unVersion,terminals:r.terminals,layerIdLookup:r.layerIdLookup,sourceIdLookup:r.sourceIdLookup}}}}return{associations:null,unVersion:r.unVersion,lkp:null,terminals:[],layerIdLookup:new Map,sourceIdLookup:new Map}}async function en(e,t,i,r=null,a=null,s=!0,n=null,l=null){let u=e.serviceUrl();return u?(u="/"===u.charAt(u.length-1)?u+t.relatedTableId.toString():u+"/"+t.relatedTableId.toString(),new $({layer:e,relatedLayer:await ee(u,r,a,s,n,l),relationship:t,objectId:i,spatialReference:r,outFields:a,includeGeometry:s,lrucache:n,interceptor:l})):null}n.Z.registerAction(),k.registerAction(),d.Z.registerAction(),N.Z.registerAction(),x.Z.registerAction();class el extends a{constructor(e,t=null,i=null,r=null){super(),this._map=e,this._overrideSpatialReference=t,this._lrucache=i,this._interceptor=r,this._instantLayers=[]}_makeAndAddFeatureSet(e,t=!0,i=null){let r=et(e,this._overrideSpatialReference,null===i?["*"]:i,t,this._lrucache,this._interceptor);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(i)}),r}async featureSetByName(e,t=!0,i=null){if(z.Z.isLoadable(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetByName(e,t,i);null===i&&(i=["*"]);let r=JSON.stringify(i=(i=i.slice()).sort());for(let i=0;i<this._instantLayers.length;i++){let a=this._instantLayers[i];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[i].featureset}let a=this._map.allLayers.find(t=>(0,_.yJ)(t)&&t.title===e);if(null!=a)return this._makeAndAddFeatureSet(a,t,i);if(this._map.allTables){let r=this._map.allTables.find(t=>(0,_.yJ)(t)&&t.title===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,i)}return null}async featureSetById(e,t=!0,i=["*"]){if(z.Z.isLoadable(this._map)&&!this._map.loaded)return await this._map.load(),this.featureSetById(e,t,i);null===i&&(i=["*"]);let r=JSON.stringify(i=(i=i.slice()).sort());for(let i=0;i<this._instantLayers.length;i++){let a=this._instantLayers[i];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[i].featureset}let a=this._map.allLayers.find(t=>(0,_.yJ)(t)&&t.id===e);if(a)return this._makeAndAddFeatureSet(a,t,i);if(this._map.allTables){let r=this._map.allTables.find(t=>(0,_.yJ)(t)&&t.id===e);if(null!=r)return this._makeAndAddFeatureSet(r,t,i)}return null}}class eu extends a{constructor(e,t=null,i=null,r=null){super(),this._url=e,this._overrideSpatialReference=t,this._lrucache=i,this._interceptor=r,this.metadata=null,this._instantLayers=[]}get url(){return this._url}_makeAndAddFeatureSet(e,t=!0,i=null){let r=et(e,this._overrideSpatialReference,null===i?["*"]:i,t,this._lrucache);return this._instantLayers.push({featureset:r,opitem:e,includeGeometry:t,outFields:JSON.stringify(i)}),r}async _loadMetaData(){let e=await ea(this._url,this._lrucache);return this.metadata=e,e}load(){return this._loadMetaData()}clone(){return new eu(this._url,this._overrideSpatialReference,this._lrucache,this._interceptor)}async featureSetByName(e,t=!0,i=null){null===i&&(i=["*"]);let r=JSON.stringify(i=(i=i.slice()).sort());for(let i=0;i<this._instantLayers.length;i++){let a=this._instantLayers[i];if(a.opitem.title===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[i].featureset}let a=await this._loadMetaData(),s=null;for(let t of a.layers??[])t.name===e&&(s=t);if(!s)for(let t of a.tables??[])t.name===e&&(s=t);if(s){let e=await Y(this._url+"/"+s.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,i)}return null}async featureSetById(e,t=!0,i=["*"]){null===i&&(i=["*"]);let r=JSON.stringify(i=(i=i.slice()).sort());e=null!=e?e.toString():"";for(let i=0;i<this._instantLayers.length;i++){let a=this._instantLayers[i];if(a.opitem.id===e&&a.includeGeometry===t&&a.outFields===r)return this._instantLayers[i].featureset}let a=await this._loadMetaData(),s=null;for(let t of a.layers??[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);if(!s)for(let t of a.tables??[])null!==t.id&&void 0!==t.id&&t.id.toString()===e&&(s=t);if(s){let e=await Y(this._url+"/"+s.id,["*"],this._lrucache);return this._makeAndAddFeatureSet(e,t,i)}return null}}function eo(e,t,i=null,r=null){return new el(e,t,i,r)}function ed(e,t,i=null,r=null){return new eu(e,t,i,r)}function eh(e,t,i,r,a){if(null===e)return null;if((0,s.m)(e)){switch(t){case"datasource":return e.getDataSourceFeatureSet();case"parent":return e;case"root":return e.getRootFeatureSet()}return null}if(e instanceof K.Z&&(0,_.FJ)(e)){switch(t){case"datasource":return et(e,a,"outFields"in e?e.outFields:null,!0,i,r).getDataSourceFeatureSet();case"parent":case"root":return et(e,a,"outFields"in e?e.outFields:null,!0,i,r)}return null}if((0,s.$)(e))switch(t){case"datasource":return et(e.parent,a,e.parent.outFields,!0,i,r).getDataSourceFeatureSet();case"parent":case"root":return et(e,a,e.parent.outFields,!0,i,r)}return null}async function ec(e,t,i,r,a,s,n,l=null){if(J.Z.applicationCache){let u=J.Z.applicationCache.getLayerInfo(e+":"+s.url);if(u)return ef(await u,t,i,r,a,n,l)}if(null!=n){let u=n.getCachedPortalItem(s.url,e);if(null!=u)return await ef(await u,t,i,r,a,n,l)}let u=new H.default({id:e,portal:s}).load();J.Z.applicationCache?J.Z.applicationCache.setLayerInfo(e+":"+s.url,u):null!=n&&n.setCachedPortalItem(s.url,e,u);try{return await ef(await u,t,i,r,a,n,l)}catch(t){throw J.Z.applicationCache&&J.Z.applicationCache.clearLayerInfo(e+":"+s.url),null!=n&&n.removeCachedPortalItem(s.url,e,u),t}}async function ef(e,t,i,r,a,s,n){let l;if("Feature Service"===e.type||"Map Service"===e.type)l=await Y((0,_.US)(e.url??"")+"/"+t,["*"],s);else{if(t)throw Error(`layerId=${t} provided for ${e.type} item`);if(null!=s){let t=s.getCachedPortalItemLayer(e.portal.url,e.id);if(null!=t)l=await t;else{let t=K.Z.fromPortalItem(e);s.setCachedPortalItemLayer(e.portal.url,e.id,t);try{l=await t}catch(i){throw s.removeCachedPortalItemLayer(e.portal.url,e.id,t),i}}}else l=await K.Z.fromPortalItem(e)}return et(l,i,r,a,s,n)}},68631:function(e,t,i){i.d(t,{$X:function(){return _},QP:function(){return y},TO:function(){return g},Xx:function(){return w},yN:function(){return m}});var r=i(27568),a=i(80370),s=i(79921),n=i(73346),l=i(47045),u=i(42442),o=i(72640),d=i(4509),h=i(71943),c=i(84976),f=i(93271);class p{constructor(e){this.field=e,this.sqlRewritable=!1}postInitialization(e,t){}}class _ extends p{constructor(e){super(e),this.sqlRewritable=!0}extractValue(e){return e.attributes[this.field.name]}rewriteSql(e){return{rewritten:this.sqlRewritable,where:e}}}class y extends p{constructor(e,t,i){super((0,u.JW)(e)),this.originalField=e,this.sqlRewritable=!0,this.field.name=t,this.field.alias=i}rewriteSql(e,t){return{rewritten:this.sqlRewritable,where:(0,o.bB)(e,this.field.name,this.originalField.name,t.getFieldsIndex())}}extractValue(e){return e.attributes[this.originalField.name]}}class g extends p{constructor(e,t,i){for(let r in super(e),this.codefield=t,this.lkp=i,this.reverseLkp={},i)this.reverseLkp[i[r]]=r;this.sqlRewritable=!0}static{this.BADNESS="_!!!_BAD_LKP_!!!!"}rewriteSql(e,t){let i=this.evaluateNodeToWhereClause(e.parseTree,u.Bj.Standardised,this.field.name,this.co
1defield instanceof c.default?(0,o.zR)(this.codefield,u.Bj.Standardised):this.codefield,e.parameters);return i.includes(g.BADNESS)?{rewritten:!1,where:e}:{rewritten:this.sqlRewritable,where:c.default.create(i,{fieldsIndex:t._parent.getFieldsIndex(),timeZone:t.dateFieldsTimeZoneDefaultUTC})}}evaluateNodeToWhereClause(e,t,i=null,r=null,a){let s,n,l,d;switch(e.type){case"interval":return(0,o.TE)(this.evaluateNodeToWhereClause(e.value,t,i,r,a),e.qualifier,e.op);case"case-expression":{let r=" CASE ";"simple"===e.format&&(r+=this.evaluateNodeToWhereClause(e.operand,t,i,g.BADNESS,a));for(let s=0;s<e.clauses.length;s++)r+=" WHEN "+this.evaluateNodeToWhereClause(e.clauses[s].operand,t,i,g.BADNESS,a)+" THEN "+this.evaluateNodeToWhereClause(e.clauses[s].value,t,i,g.BADNESS,a);return null!==e.else&&(r+=" ELSE "+this.evaluateNodeToWhereClause(e.else,t,i,g.BADNESS,a)),r+=" END "}case"parameter":{let i=a[e.value.toLowerCase()];if("string"==typeof i)return"'"+i.toString().replaceAll("'","''")+"'";if((0,u.J_)(i)||(0,u.T4)(i))return(0,o.vn)(i,t);if((0,u._U)(i))return(0,o.wF)(i,t);if((0,u.NP)(i))return(0,o.mA)(i,t);if((0,u.$A)(i))return(0,o.av)(i,t);if(Array.isArray(i)){let e=[];for(let r=0;r<i.length;r++)"string"==typeof i[r]?e.push("'"+i[r].toString().replaceAll("'","''")+"'"):(0,u.J_)(i[r])||(0,u.T4)(i[r])?e.push((0,o.vn)(i[r],t)):(0,u._U)(i[r])?e.push((0,o.wF)(i[r],t)):(0,u.NP)(i[r])?e.push((0,o.mA)(i[r],t)):(0,u.$A)(i[r])?e.push((0,o.av)(i[r],t)):e.push(i[r].toString());return e}return i.toString()}case"expression-list":for(let s of(n=[],e.value))n.push(this.evaluateNodeToWhereClause(s,t,i,r,a));return n;case"unary-expression":return" ( NOT "+this.evaluateNodeToWhereClause(e.expr,t,i,g.BADNESS,a)+" ) ";case"binary-expression":switch(e.operator){case"AND":return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" AND "+this.evaluateNodeToWhereClause(e.right,t,i,r,a)+") ";case"OR":return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" OR "+this.evaluateNodeToWhereClause(e.right,t,i,r,a)+") ";case"IS":if("null"!==e.right.type)throw new h.eS(h.f.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IS NULL )";case"ISNOT":if("null"!==e.right.type)throw new h.eS(h.f.UnsupportedIsRhs);return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IS NOT NULL )";case"IN":if(s=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){let s=[],n=!0;for(let t of e.right.value){if("string"!==t.type||void 0===this.lkp[t.value]){n=!1;break}s.push(this.lkp[t.value].toString())}if(n)return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IN ("+s.join(",")+")) "}return s=this.evaluateNodeToWhereClause(e.right,t,i,r,a)," ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IN ("+s.join(",")+")) "}return Array.isArray(d=this.evaluateNodeToWhereClause(e.right,t,i,r,a))?" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IN ("+d.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" IN ("+d+")) ";case"NOT IN":if(s=[],"expression-list"===e.right.type){if("column-reference"===e.left.type&&e.left.column.toUpperCase()===this.field.name.toUpperCase()){let s=[],n=!0;for(let t of e.right.value){if("string"!==t.type||void 0===this.lkp[t.value]){n=!1;break}s.push(this.lkp[t.value].toString())}if(n)return" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" NOT IN ("+s.join(",")+")) "}return s=this.evaluateNodeToWhereClause(e.right,t,i,r,a)," ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" NOT IN ("+s.join(",")+")) "}return Array.isArray(d=this.evaluateNodeToWhereClause(e.right,t,i,r,a))?" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" NOT IN ("+d.join(",")+")) ":" ("+this.evaluateNodeToWhereClause(e.left,t,i,r,a)+" NOT IN ("+d+")) ";case"BETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"NOTBETWEEN":return l=this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)," ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" NOT BETWEEN "+l[0]+" AND "+l[1]+" ) ";case"LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" LIKE "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+") ";case"NOT LIKE":return""!==e.escape?" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+" ESCAPE '"+e.escape+"') ":" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" NOT LIKE "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+") ";case"<>":case"=":if("column-reference"===e.left.type&&"string"===e.right.type){if(e.left.column.toUpperCase()===this.field.name.toUpperCase()&&void 0!==this.lkp[e.right.value.toString()])return" ("+r+" "+e.operator+" "+this.lkp[e.right.value.toString()].toString()+") "}else if("column-reference"===e.right.type&&"string"===e.left.type&&e.right.column.toUpperCase()===this.field.name.toUpperCase())return" ("+this.lkp[e.right.value.toString()].toString()+" "+e.operator+" "+r+") ";return" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+") ";case"<":case">":case">=":case"<=":case"*":case"-":case"+":case"/":case"||":return" ("+this.evaluateNodeToWhereClause(e.left,t,i,g.BADNESS,a)+" "+e.operator+" "+this.evaluateNodeToWhereClause(e.right,t,i,g.BADNESS,a)+") "}case"null":return"null";case"boolean":return!0===e.value?"1":"0";case"string":return"'"+e.value.toString().replaceAll("'","''")+"'";case"timestamp":return`timestamp '${e.value}'`;case"date":return`date '${e.value}'`;case"time":return`time '${e.value}'`;case"number":return e.value.toString();case"current-time":return(0,o.vR)(e.mode,t);case"current-user":return"CURRENT_USER";case"column-reference":return i&&i.toLowerCase()===e.column.toLowerCase()?"("+r+")":(0,o.tj)(e.column);case"data-type":return e.value;case"function":{let r=this.evaluateNodeToWhereClause(e.args,t,i,g.BADNESS,a);return(0,o.fz)(e.name,r,t)}}throw new h.eS(h.f.UnsupportedSyntax,{node:e.type})}
1extractValue(e){return this.codefield instanceof c.default?this.reverseLkp[c.default.convertValueToStorageFormat(this.codefield.calculateValueCompiled(e))]:this.reverseLkp[e.attributes[this.codefield]]}}class m extends p{constructor(e,t){super(e),this._sql=t}rewriteSql(e,t){return{rewritten:!0,where:(0,o.bB)(e,this.field.name,(0,o.zR)(this._sql,u.Bj.Standardised),t.getFieldsIndex())}}extractValue(e){return c.default.convertValueToStorageFormat(this._sql.calculateValueCompiled(e),this.field.type)}}class w extends n.Z{static findField(e,t){for(let i of e)if(i.name.toLowerCase()===t.toString().toLowerCase())return i;return null}constructor(e){super(e),this._calcFunc=null,this.declaredClass="esri.arcade.featureset.actions.Adapted",this.adaptedFields=[],this._extraFilter=null,this._extraFilter=e.extraFilter,this._parent=e.parentfeatureset,this._maxProcessing=30,this.adaptedFields=e.adaptedFields}_initialiseFeatureSet(){for(let e of(null!==this._parent?(this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types):(this.spatialReference=new f.Z({wkid:4326}),this.objectIdField="",this.globalIdField="",this.geometryType=u.Qk.point,this.typeIdField="",this.types=null,this.subtypeField=null,this.subtypes=null),this.fields=[],this.adaptedFields))e.postInitialization(this,this._parent),this.fields.push(e.field)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=null;return t=this._extraFilter?await this._getFilteredSet("",null,null,null,e):await this._parent?._getSet(e),this._checkCancelled(e),(0,d.O3)(t),this._wset=new l.Z(t._candidates.slice(),t._known.slice(),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}async _getFeatures(e,t,i,s){let n=[];-1!==t&&void 0===this._featureCache[t]&&n.push(t);let u=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,u))return await this._expandPagedSet(e,u,0,0,s),this._getFeatures(e,t,i,s);let o=0;for(let r=e._lastFetchedIndex;r<e._known.length&&(++o<=i&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[r]]&&(e._known[r]!==t&&n.push(e._known[r]),n.length>=u)));r++);if(0===n.length)return"success";e=new l.Z([],n,e._ordered,null);let d=Math.min(n.length,i);await this._parent?._getFeatures(e,-1,d,s),this._checkCancelled(s);let h=[];for(let e=0;e<d;e++){let t=this._parent?._featureFromCache(n[e]);void 0!==t&&h.push({geometry:t.geometry,attributes:t.attributes,id:n[e]})}for(let e of h){let t=[];for(let i of this.adaptedFields)t[i.field.name]=i.extractValue(e);this._featureCache[e.id]=new r.Z({attributes:t,geometry:(0,a.r1)(e.geometry)})}return"success"}async _fetchAndRefineFeatures(){throw new s.EN(s.H9.NeverReach)}async _getFilteredSet(e,t,i,r,a){let s=!1,n=this._reformulateWithoutAdaptions(i);s=n.cannot,i=n.where;let u=!1;if(null!==r){u=!0;let e=[];for(let t of this.adaptedFields)if(!(t instanceof _)&&!0===r.scanForField(t.field.name)){if(!(t instanceof y)){r=null,u=!1;break}e.push({field:t.field.name,newfield:t.originalField.name})}r&&e.length>0&&(r=r.replaceFields(e))}null!==i?null!==this._extraFilter&&(i=(0,o.$e)(this._extraFilter,i)):i=this._extraFilter,await this._ensureLoaded();let d=await this._parent._getFilteredSet(e,t,i,r,a);return this._checkCancelled(a),!0===s?new l.Z(d._candidates.slice().concat(d._known.slice()),[],!0===u&&d._ordered,this._clonePageDefinition(d.pagesDefinition)):new l.Z(d._candidates.slice(),d._known.slice(),!0===u&&d._ordered,this._clonePageDefinition(d.pagesDefinition))}_reformulateWithoutAdaptions(e){let t={cannot:!1,where:e};if(null!==e){for(let i of this.adaptedFields)if(!0===(0,o.hq)(e,i.field.name)){let r=i.rewriteSql(e,this);if(!0!==r.rewritten){t.cannot=!0,t.where=null;break}t.where=r.where}}return t}async _stat(e,t,i,r,a,s,n){let l=!1,u=this._reformulateWithoutAdaptions(t);if(l=u.cannot,t=u.where,u=this._reformulateWithoutAdaptions(a),l=l||u.cannot,null!==(a=u.where)?null!==this._extraFilter&&(a=(0,o.$e)(this._extraFilter,a)):a=this._extraFilter,!0===l)return null===a&&""===i&&null===r?this._manualStat(e,t,s,n):{calculated:!1};let d=await this._parent._stat(e,t,i,r,a,s,n);return!1===d.calculated?null===a&&""===i&&null===r?this._manualStat(e,t,s,n):{calculated:!1}:d}async _canDoAggregates(e,t,i,r,a){if(null===this._parent)return!1;for(let t=0;t<e.length;t++)for(let i of this.adaptedFields)if(e[t].toLowerCase()===i.field.name.toLowerCase()&&!(i instanceof _))return!1;let s=[];for(let e=0;e<t.length;e++){let i=t[e];if(null!==i.workingexpr){let e=this._reformulateWithoutAdaptions(i.workingexpr);if(e.cannot)return!1;let t=i.clone();t.workingexpr=e.where,s.push(t)}else s.push(i)}let n=this._reformulateWithoutAdaptions(a);return!n.cannot&&(null!==(a=n.where)?null!==this._extraFilter&&(a=(0,o.$e)(this._extraFilter,a)):a=this._extraFilter,this._parent._canDoAggregates(e,s,i,r,a))}async _getAggregatePagesDataSourceDefinition(e,t,i,r,a,n,l){if(null===this._parent)throw new s.EN(s.H9.NeverReach);let u=[];for(let e=0;e<t.length;e++){let i=t[e];if(null!==i.workingexpr){let e=this._reformulateWithoutAdaptions(i.workingexpr);if(e.cannot)throw new s.EN(s.H9.NeverReach);let t=i.clone();t.workingexpr=e.where,u.push(t)}else u.push(i)}let d=this._reformulateWithoutAdaptions(a);if(d.cannot)throw new s.EN(s.H9.NeverReach);return null!==(a=d.where)?null!==this._extraFilter&&(a=(0,o.$e)(this._extraFilter,a)):a=this._extraFilter,this._parent._getAggregatePagesDataSourceDefinition(e,u,i,r,a,n,l)}}},89686:function(e,t,i){i.d(t,{Z:function(){return h}});var r=i(79921),a=i(73346),s=i(47045),n=i(42442),l=i(72640),u=i(4580),o=i(84976),d=i(93271);class h extends a.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.actions.AttributeFilter",this._maxProcessing=1e3,this._parent=e.parentfeatureset,e.whereclause instanceof o.default?(this._whereclause=e.whereclause,this._whereClauseFunction=null):(this._whereClauseFunction=e.whereclause,this._whereclause=null)}_initialiseFeatureSet(){null!==this._parent?(this.fields=this._parent.fields.slice(),this.geometryType=this._parent.geometryType,this.objectIdField=this._parent.objectIdField,this.globalIdField=this._parent.globalIdField,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField=this._parent.typeIdField,this.types=this._parent.types,this.subtypeField=this._parent.subtypeField,this.subtypes=this._parent.subtypes):(this.fields=[],this.typeIdField="",this.subtypeField="",this.objectIdField="",this.globalIdField="",this.spatialReference=new d.Z({wkid:4326}),this.geometryType=n.Qk.point)}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._parent._getFilteredSet("",null,this._whereclause,null,e);return this._checkCancelled(e),null!==this._whereClauseFunction?this._wset=new s.Z(t._candidates.slice().concat(t._known.slice()),[],t._ordered,this._clonePageDefinition(t.pagesDefinition)):this._wset=new s.Z(t._candidates.slice(),t._known.slice(),t._ordered,this._clonePageDefinition(t.pagesDefinition)),this._wset}return this._wset}_isInFeatureSet(e){let t=this._parent?._isInFeatureSet(e);return t===n.dj.NotInFeatureSet?t:void 0===(t=this._idstates[e])?n.dj.Unknown:t}_getFeature(e,t,i){return this._parent._getFeature(e,t,i)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){return this._parent._featureFromCache(e)}
1executeWhereClause(e){return this._whereclause?.testFeature(e)??!1}async executeWhereClauseDeferred(e){if(null!==this._whereClauseFunction){let t=this._whereClauseFunction(e);return(0,u.y8)(t),t}return this.executeWhereClause(e)}async _fetchAndRefineFeatures(e,t,i){let r=new s.Z([],e,!1,null),a=Math.min(t,e.length);if(await this._parent?._getFeatures(r,-1,a,i),this._checkCancelled(i),null==this._whereClauseFunction){for(let t=0;t<a;t++){let i=this._parent?._featureFromCache(e[t]);!0===this.executeWhereClause(i)?this._idstates[e[t]]=n.dj.InFeatureSet:this._idstates[e[t]]=n.dj.NotInFeatureSet}return"success"}let l=[];for(let t=0;t<a;t++){let i=this._parent?._featureFromCache(e[t]);l.push(await this.executeWhereClauseDeferred(i))}for(let i=0;i<t;i++)!0===l[i]?this._idstates[e[i]]=n.dj.InFeatureSet:this._idstates[e[i]]=n.dj.NotInFeatureSet;return"success"}async _getFilteredSet(e,t,i,r,a){null!==this._whereClauseFunction||(null!==i?null!==this._whereclause&&(i=(0,l.$e)(this._whereclause,i)):i=this._whereclause),await this._ensureLoaded();let n=await this._parent._getFilteredSet(e,t,i,r,a);return this._checkCancelled(a),null!==this._whereClauseFunction?new s.Z(n._candidates.slice().concat(n._known.slice()),[],n._ordered,this._clonePageDefinition(n.pagesDefinition)):new s.Z(n._candidates.slice(),n._known.slice(),n._ordered,this._clonePageDefinition(n.pagesDefinition))}async _stat(e,t,i,r,a,s,n){if(null!==this._whereClauseFunction)return null===a&&""===i&&null===r?this._manualStat(e,t,s,n):{calculated:!1};let u=this._whereclause;null!==a&&null!==this._whereclause&&(u=(0,l.$e)(this._whereclause,a));let o=await this._parent._stat(e,t,i,r,u,s,n);return!1===o.calculated?null===a&&""===i&&null===r?this._manualStat(e,t,s,n):{calculated:!1}:o}async _canDoAggregates(e,t,i,r,a){return null===this._whereClauseFunction&&(null!==a?null!==this._whereclause&&(a=(0,l.$e)(this._whereclause,a)):a=this._whereclause,null!==this._parent&&this._parent._canDoAggregates(e,t,i,r,a))}async _getAggregatePagesDataSourceDefinition(e,t,i,a,s,n,u){if(null===this._parent)throw new r.EN(r.H9.NeverReach);return null!==s?null!==this._whereclause&&(s=(0,l.$e)(this._whereclause,s)):s=this._whereclause,this._parent._getAggregatePagesDataSourceDefinition(e,t,i,a,s,n,u)}static registerAction(){a.Z._featuresetFunctions.filter=function(e){if("function"==typeof e)return new h({parentfeatureset:this,whereclause:e});let t=null;return e instanceof o.default&&(t=e),new h({parentfeatureset:this,whereclause:t})}}getFieldsIndex(){return this._parent.getFieldsIndex()}}},20994:function(e,t,i){i.d(t,{Z:function(){return u}});var r=i(77689),a=i(79921),s=i(73346),n=i(47045),l=i(16067);class u extends s.Z{constructor(e){super(e),this._orderbyclause=null,this.declaredClass="esri.arcade.featureset.actions.OrderBy",this._maxProcessing=100,this._orderbyclause=e.orderbyclause,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._getFilteredSet("",null,null,this._orderbyclause,e);return this._checkCancelled(e),this._wset=t,this._wset}return this._wset}async manualOrderSet(e,t){let i=await this.getIdColumnDictionary(e,[],-1,t);this._orderbyclause?.order(i);let r=new n.Z([],[],!0,null);for(let e=0;e<i.length;e++)r._known.push(i[e].id);return r}async getIdColumnDictionary(e,t,i,a){if(i<e._known.length-1){let s=this._maxQueryRate();if("GETPAGES"===e._known[i+1])return await (0,r.a0)(this._parent._expandPagedSet(e,s,0,0,a)),this.getIdColumnDictionary(e,t,i,a);let n=i+1,l=[];for(;n<e._known.length&&"GETPAGES"!==e._known[n];)l.push(e._known[n]),n++;i+=l.length;let u=await (0,r.a0)(this._parent._getFeatureBatch(l,a));for(let e of(this._checkCancelled(a),u))t.push({id:e.attributes[this.objectIdField],feature:e});return this.getIdColumnDictionary(e,t,i,a)}return e._candidates.length>0?(await (0,r.a0)(this._refineSetBlock(e,this._maxProcessingRate(),a)),this._checkCancelled(a),this.getIdColumnDictionary(e,t,i,a)):t}_isInFeatureSet(e){return this._parent._isInFeatureSet(e)}_getFeatures(e,t,i,r){return this._parent._getFeatures(e,t,i,r)}_featureFromCache(e){if(void 0===this._featureCache[e]){let t=this._parent._featureFromCache(e);if(void 0===t)return;return null===t?null:(this._featureCache[e]=t,t)}return this._featureCache[e]}async _fetchAndRefineFeatures(){throw new a.EN(a.H9.NeverReach)}async _getFilteredSet(e,t,i,r,a){await this._ensureLoaded();let s=await this._parent._getFilteredSet(e,t,i,null===r?this._orderbyclause:r,a);this._checkCancelled(a);let l=new n.Z(s._candidates.slice(),s._known.slice(),s._ordered,this._clonePageDefinition(s.pagesDefinition)),u=!0;if(s._candidates.length>0&&(u=!1),!1===l._ordered){let e=await this.manualOrderSet(l,a);return!1===u&&(null===t&&null===i||(e=new n.Z(e._candidates.slice().concat(e._known.slice()),[],e._ordered,this._clonePageDefinition(e.pagesDefinition)))),e}return l}static registerAction(){s.Z._featuresetFunctions.orderBy=function(e){return""===e?this:new u({parentfeatureset:this,orderbyclause:new l.Z(e)})}}getFieldsIndex(){return this._parent.getFieldsIndex()}}},50188:function(e,t,i){i.d(t,{Z:function(){return l}});var r=i(79921),a=i(73346),s=i(47045),n=i(42442);class l extends a.Z{constructor(e){super(e),this._topnum=0,this.declaredClass="esri.arcade.featureset.actions.Top",this._countedin=0,this._maxProcessing=100,this._topnum=e.topnum,this._parent=e.parentfeatureset}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._parent._getSet(e);return this._wset=new s.Z(t._candidates.slice(),t._known.slice(),!1,this._clonePageDefinition(t.pagesDefinition)),this._setKnownLe
1ngth(this._wset)>this._topnum&&(this._wset._known=this._wset._known.slice(0,this._topnum)),this._setKnownLength(this._wset)>=this._topnum&&(this._wset._candidates=[]),this._wset}return this._wset}_setKnownLength(e){return e._known.length>0&&"GETPAGES"===e._known[e._known.length-1]?e._known.length-1:e._known.length}_isInFeatureSet(e){let t=this._parent._isInFeatureSet(e);if(t===n.dj.NotInFeatureSet)return t;let i=this._idstates[e];return i===n.dj.InFeatureSet||i===n.dj.NotInFeatureSet?i:t===n.dj.InFeatureSet&&void 0===i?this._countedin<this._topnum?(this._idstates[e]=n.dj.InFeatureSet,this._countedin++,n.dj.InFeatureSet):(this._idstates[e]=n.dj.NotInFeatureSet,n.dj.NotInFeatureSet):n.dj.Unknown}async _expandPagedSet(e,t,i,a,s){if(null===this._parent)throw new r.EN(r.H9.NotImplemented);if(t>this._topnum&&(t=this._topnum),this._countedin>=this._topnum&&e.pagesDefinition.internal.set.length<=e.pagesDefinition.resultOffset){let t=e._known.length;return t>0&&"GETPAGES"===e._known[t-1]&&(e._known.length=t-1),(t=e._candidates.length)>0&&"GETPAGES"===e._candidates[t-1]&&(e._candidates.length=t-1),"success"}let n=await this._parent._expandPagedSet(e,t,i,a,s);return this._setKnownLength(e)>this._topnum&&(e._known.length=this._topnum),this._setKnownLength(e)>=this._topnum&&(e._candidates.length=0),n}async _getFeatures(e,t,i,r){let a=[],n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,n))return await this._expandPagedSet(e,n,0,0,r),this._getFeatures(e,t,i,r);-1!==t&&void 0===this._featureCache[t]&&a.push(t);let l=0;for(let r=e._lastFetchedIndex;r<e._known.length&&(++l<=i&&(e._lastFetchedIndex+=1),!(void 0===this._featureCache[e._known[r]]&&(e._known[r]!==t&&a.push(e._known[r]),a.length>n)));r++);if(0===a.length)return"success";let u=new s.Z([],a,!1,null),o=Math.min(a.length,i);await this._parent._getFeatures(u,-1,o,r);for(let e=0;e<o;e++){let t=this._parent._featureFromCache(a[e]);void 0!==t&&(this._featureCache[a[e]]=t)}return"success"}async _getFilteredSet(e,t,i,r,a){await this._ensureLoaded();let n=await this._getSet(a);return new s.Z(n._candidates.slice().concat(n._known.slice()),[],!1,this._clonePageDefinition(n.pagesDefinition))}_refineKnowns(e,t){let i=0,r=null,a=[];for(let s=0;s<e._candidates.length;s++){let l=this._isInFeatureSet(e._candidates[s]);if(l===n.dj.InFeatureSet){if(e._known.push(e._candidates[s]),i+=1,null===r?r={start:s,end:s}:r.end===s-1?r.end=s:(a.push(r),r={start:s,end:s}),e._known.length>=this._topnum)break}else if(l===n.dj.NotInFeatureSet)null===r?r={start:s,end:s}:r.end===s-1?r.end=s:(a.push(r),r={start:s,end:s}),i+=1;else if(l===n.dj.Unknown)break;if(i>=t)break}null!==r&&a.push(r);for(let t=a.length-1;t>=0;t--)e._candidates.splice(a[t].start,a[t].end-a[t].start+1);this._setKnownLength(e)>this._topnum&&(e._known=e._known.slice(0,this._topnum)),this._setKnownLength(e)>=this._topnum&&(e._candidates=[])}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}static registerAction(){a.Z._featuresetFunctions.top=function(e){return new l({parentfeatureset:this,topnum:e})}}getFieldsIndex(){return this._parent.getFieldsIndex()}}},92475:function(e,t,i){i.d(t,{Z:function(){return p}});var r=i(27568),a=i(79921),s=i(73346),n=i(47045),l=i(42442),u=i(72640),o=i(80032),d=i(18914),h=i(29126),c=i(43746),f=i(31476);class p extends s.Z{constructor(e){super(e),this.declaredClass="esri.arcade.featureset.sources.FeatureLayerMemory",this._removeGeometry=!1,this._overrideFields=null,this._forceIsTable=!1,e.spatialReference&&(this.spatialReference=e.spatialReference),this._transparent=!0,this._maxProcessing=1e3,this._layer=e.layer,this._wset=null,!0===e.isTable&&(this._forceIsTable=!0),void 0!==e.outFields&&(this._overrideFields=e.outFields),void 0!==e.includeGeometry&&(this._removeGeometry=!1===e.includeGeometry)}_maxQueryRate(){return l.tI}end(){return this._layer}optimisePagingFeatureQueries(){}async loadImpl(){return!0===this._layer.loaded||await this._layer.load(),this._initialiseFeatureSet(),this}get gdbVersion(){return""}_initialiseFeatureSet(){if(null==this.spatialReference&&(this.spatialReference=this._layer.spatialReference),this.geometryType=this._layer.geometryType??"",this.fields=this._layer.fields.slice(),null!==this._overrideFields){if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{let e=[],t=[];for(let i of this.fields)if("oid"===i.type||this._layer.objectIdField===i.name)e.push(i),t.push(i.name);else for(let r of this._overrideFields)if(r.toLowerCase()===i.name.toLowerCase()){e.push(i),t.push(i.name);break}this.fields=e,this._overrideFields=t}}for(let e of(this.objectIdField=this._layer.objectIdField,this.fields))"global-id"===e.type&&(this.globalIdField=e.name);this._databaseType=l.Bj.Standardised,this.hasZ=!0===this._layer?.capabilities?.data?.supportsZ,this.hasM=!0===this._layer?.capabilities?.data?.supportsM,this.subtypeField=("subtypeField"in this._layer?this._layer.subtypeField:null)??"",this.subtypes="subtypes"in this._layer?this._layer.subtypes:null,this.typeIdField=("typeIdField"in this._layer?this._layer.typeIdField:null)??"",this.types="types"in this._layer?this._layer.types:null}isTable(){return this._forceIsTable||"isTable"in this._layer&&this._layer.isTable||"table"===this._layer.type||!this._layer.geometryType}_isInFeatureSet(){return l.dj.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();let t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_createQuery(){let e=this._layer.createQuery();return e.returnZ=this.hasZ,e.returnM=this.hasM,e.outFields=this._overrideFields??["*"],e.returnGeometry=!this._removeGeometry,e}
1_changeFeature(e){let t={};for(let i of this.fields)t[i.name]=e.attributes[i.name];return new r.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}async _getFilteredSet(e,t,i,r,a){let s="",d=!1;if(null!==r&&(s=r.constructClause(),d=!0),this.isTable()&&t&&null!==e&&""!==e)return new n.Z([],[],!0,null);let h=this._createQuery();h.where=(0,o._$)(h.where,null===i?null===t?"1=1":"":(0,u.zR)(i,l.Bj.Standardised)),h.spatialRelationship=this._makeRelationshipEnum(e),h.outSpatialReference=this.spatialReference,h.orderByFields=""!==s?s.split(","):null,h.geometry=null===t?null:t,h.relationParameter=this._makeRelationshipParam(e);let c=await this._layer.queryFeatures(h);if(null===c)return new n.Z([],[],d,null);this._checkCancelled(a);let f=[];return c.features.forEach(e=>{let t=e.attributes[this._layer.objectIdField];f.push(t),this._featureCache[t]=this._changeFeature(e)}),new n.Z([],f,d,null)}_makeRelationshipEnum(e){if(e.includes("esriSpatialRelRelation"))return"relation";switch(e){case"esriSpatialRelRelation":return"relation";case"esriSpatialRelIntersects":return"intersects";case"esriSpatialRelContains":return"contains";case"esriSpatialRelOverlaps":return"overlaps";case"esriSpatialRelWithin":return"within";case"esriSpatialRelTouches":return"touches";case"esriSpatialRelCrosses":return"crosses";case"esriSpatialRelEnvelopeIntersects":return"envelope-intersects"}return e}_makeRelationshipParam(e){return e.includes("esriSpatialRelRelation")?e.split(":")[1]:""}async _queryAllFeatures(){if(this._wset)return this._wset;if(await this._ensureLoaded(),this._layer.source&&this._layer.source.items){let e=[];return this._layer.source.items.forEach(t=>{let i=t.attributes[this._layer.objectIdField];e.push(i),this._featureCache[i]=this._changeFeature(t)}),this._wset=new n.Z([],e,!1,null),this._wset}let e=this._createQuery();e.where="1=1";let t=await this._layer.queryFeatures(e),i=[];return t.features.forEach(e=>{let t=e.attributes[this._layer.objectIdField];i.push(t),this._featureCache[t]=this._changeFeature(e)}),this._wset=new n.Z([],i,!1,null),this._wset}async _getFeatures(e,t,i){let r=[];-1!==t&&void 0===this._featureCache[t]&&r.push(t);for(let a=e._lastFetchedIndex;a<e._known.length&&(e._lastFetchedIndex+=1,!(void 0===this._featureCache[e._known[a]]&&(e._known[a]!==t&&r.push(e._known[a]),r.length>i)));a++);if(0===r.length)return"success";throw new a.EN(a.H9.MissingFeatures)}async _refineSetBlock(e){return e}async _stat(){return{calculated:!1}}async _canDoAggregates(){return!1}relationshipMetaData(){return[]}static _cloneAttr(e){let t={};for(let i in e)t[i]=e[i];return t}nativeCapabilities(){return{title:this._layer.title??"",canQueryRelated:!1,source:this,capabilities:this._layer.capabilities,databaseType:this._databaseType,requestStandardised:!0}}static create(e,t){let i=e.layerDefinition.objectIdField,r=e.layerDefinition.typeIdField??"",a=[];if(e.layerDefinition.types)for(let t of e.layerDefinition.types)a.push(c.Z.fromJSON(t));let s=e.layerDefinition.geometryType;void 0===s&&(s=e.featureSet.geometryType||"");let n=e.featureSet.features,l=t.toJSON();if(!i){let t=!1;for(let r of e.layerDefinition.fields)if("oid"===r.type||"esriFieldTypeOID"===r.type){i=r.name,t=!0;break}if(!1===t){let t="FID",r=!0,a=0;for(;r;){let i=!0;for(let r of e.layerDefinition.fields)if(r.name===t){i=!1;break}!0===i?r=!1:(a++,t="FID"+a.toString())}e.layerDefinition.fields.push({type:"esriFieldTypeOID",name:t,alias:t});let s=[];for(let i=0;i<n.length;i++)s.push({geometry:e.featureSet.features[i].geometry,attributes:e.featureSet.features[i].attributes?this._cloneAttr(e.featureSet.features[i].attributes):{}}),s[i].attributes[t]=i;n=s,i=t}}let u=[];for(let t of e.layerDefinition.fields)t instanceof f.Z?u.push(t):u.push(f.Z.fromJSON(t));let o=s;switch(o||(o=""),o){case"esriGeometryPoint":o="point";break;case"esriGeometryPolyline":o="polyline";break;case"esriGeometryPolygon":o="polygon";break;case"esriGeometryEnvelope":o="extent";break;case"esriGeometryMultipoint":o="multipoint";break;case"":case"esriGeometryNull":o="esriGeometryNull"}if("esriGeometryNull"!==o)for(let e of n)e.geometry&&e.geometry instanceof d.Z==!1&&(e.geometry.type=o,void 0===e.geometry.spatialReference&&(e.geometry.spatialReference=l));else for(let e of n)e.geometry&&(e.geometry=null);let _={outFields:["*"],source:n,fields:u,hasZ:!0===e?.layerDefinition?.hasZ||!0===e?.featureSet?.hasZ,hasM:!0===e?.layerDefinition?.hasM||!0===e?.featureSet?.hasM,types:a,typeIdField:r,objectIdField:i,spatialReference:t},y="esriGeometryNull"===o||null===o;y||(_.geometryType=o);let g=new h.default(_);return e?.layerDefinition?.subtypeField&&e?.layerDefinition?.subtypes&&g.read({subtypes:e.layerDefinition.subtypes,subtypeField:e.layerDefinition.subtypeField}),new p({layer:g,spatialReference:t,isTable:y})}async queryAttachments(){return[]}async getFeatureByObjectId(e){let t=this._createQuery();t.where=this.objectIdField+"="+e.toString();let i=await this._layer.queryFeatures(t);return 1===i.features.length?i.features[0]:null}async getOwningSystemUrl(){return""}async getIdentityUser(){return""}get preferredTimeZone(){return"preferredTimeZone"in this._layer?this._layer.preferredTimeZone:null}get dateFieldsTimeZone(){return"dateFieldsTimeZone"in this._layer?this._layer.dateFieldsTimeZone:null}get datesInUnknownTimezone(){return"datesInUnknownTimezone"in this._layer&&this._layer.datesInUnknownTimezone}get editFieldsInfo(){return"editFieldsInfo"in this._layer?this._layer.editFieldsInfo:null}get timeInfo(){return this._layer?.timeInfo}async getFeatureSetInfo(){let e=this._layer.title&&this._layer.parent;return this.fsetInfo??{layerId:null,layerName:null,itemId:null,serviceLayer
1Url:null,webMapLayerId:e?this._layer.id??null:null,webMapLayerTitle:e?this._layer.title??null:null,className:null,objectClassId:null}}}},16067:function(e,t,i){function r(e,t){return e===t?0:null===e?-1:null===t?1:e<t?-1:1}i.d(t,{Z:function(){return a}});class a{constructor(e){let t=e.split(",");this._fields=[],this._directions=[];for(let e=0;e<t.length;e++){let i=t[e].match(/\S+/g);this._fields.push(i[0]),2===i.length?"asc"===i[1].toLowerCase()?this._directions.push(1):this._directions.push(0):this._directions.push(1)}}constructClause(){let e="";for(let t=0;t<this._fields.length;t++)0!==t&&(e+=","),e+=this._fields[t],1===this._directions[t]?e+=" ASC":e+=" DESC";return e}order(e){e.sort((e,t)=>{for(let i=0;i<this._fields.length;i++){let a=this.featureValue(e.feature,this._fields[i],i),s=this.featureValue(t.feature,this._fields[i],i),n=0;if(0!==(n=1===this._directions[i]?r(a,s):-1*r(a,s)))return n}return 0})}scanForField(e){for(let t=0;t<this._fields.length;t++)if(this._fields[t].toLowerCase().trim()===e.toLowerCase().trim())return!0;return!1}replaceFields(e){let t="";for(let i=0;i<this._fields.length;i++){0!==i&&(t+=",");let r=this._fields[i];for(let t of e)if(r.toLowerCase()===t.field.toLowerCase()){r=t.newfield;break}t+=r,1===this._directions[i]?t+=" ASC":t+=" DESC"}return new a(t)}featureValue(e,t,i){let r=e.attributes[t];if(void 0!==r)return r;for(let r in e.attributes)if(t.toLowerCase()===r.toLowerCase())return this._fields[i]=r,e.attributes[r];return null}}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.