@doegis/core
Version:
DOE GIS API
1 lines • 131 kB
JavaScript
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[5115],{28924:(e,t,r)=>{r.d(t,{Z:()=>s});class s{constructor(){this.declaredRootClass="esri.arcade.featureSetCollection",this._layerById={},this._layerByName={}}add(e,t,r){this._layerById[t]=r,this._layerByName[e]=r}async featureSetByName(e,t=!0,r=["*"]){return void 0===this._layerByName[e]?null:this._layerByName[e]}async featureSetById(e,t=!0,r=["*"]){return void 0===this._layerById[e]?null:this._layerById[e]}castToText(e=!1){return"object, FeatureSetCollection"}}},50954:(e,t,r)=>{r.r(t),r.d(t,{constructAssociationMetaDataFeatureSetFromUrl:()=>X,constructFeatureSet:()=>K,constructFeatureSetFromPortalItem:()=>ne,constructFeatureSetFromRelationship:()=>Y,constructFeatureSetFromUrl:()=>J,convertToFeatureSet:()=>ie,createFeatureSetCollectionFromMap:()=>re,createFeatureSetCollectionFromService:()=>se,initialiseMetaDataCache:()=>V});var s=r(3172),i=r(28924),n=r(84328),a=r(38171),l=r(61363),o=r(70409),u=r(85065),d=r(91136),c=r(90961),h=r(3823),p=r(90658),f=r(36515),y=r(95002),_=r(59987),g=r(41534);class m{constructor(){this.field="",this.tofieldname="",this.typeofstat="MIN",this.workingexpr=null}clone(){const e=new m;return e.field=this.field,e.tofieldname=this.tofieldname,e.typeofstat=this.typeofstat,e.workingexpr=this.workingexpr,e}static parseStatField(e,t,r){const s=new m;s.field=e;const i=g.WhereClause.create(t,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 _.eS(_.f.MissingStatisticParameters);const t=g.WhereClause.create((0,f.XF)(e.parseTree.args.value[0],p.Bj.Standardised,e.parameters),e.fieldsIndex);return{name:e.parseTree.name,expr:t}}return null}(i);if(null===n)throw new _.eS(_.f.UnsupportedSqlFunction,{function:""});const a=n.name.toUpperCase().trim();if("MIN"===a){if(s.typeofstat="MIN",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"min"})}else if("MAX"===a){if(s.typeofstat="MAX",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"max"})}else if("COUNT"===a)s.typeofstat="COUNT",s.workingexpr=n.expr;else if("STDEV"===a){if(s.typeofstat="STDDEV",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"stdev"})}else if("SUM"===a){if(s.typeofstat="SUM",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"sum"})}else if("MEAN"===a){if(s.typeofstat="AVG",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:a})}else if("AVG"===a){if(s.typeofstat="AVG",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"avg"})}else{if("VAR"!==a)throw new _.eS(_.f.UnsupportedSqlFunction,{function:a});if(s.typeofstat="VAR",s.workingexpr=n.expr,null===i)throw new _.eS(_.f.InvalidFunctionParameters,{function:"var"})}return s}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 w=r(44543),S=r(82971),b=r(1231),F=r(99514);function I(e){if(!e)return"COUNT";switch(e.toLowerCase()){case"max":return"MAX";case"var":case"variance":return"VAR";case"avg":case"average":case"mean":return"AVG";case"min":return"MIN";case"sum":return"SUM";case"stdev":case"stddev":return"STDDEV";case"count":return"COUNT"}return"COUNT"}class v extends d.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){const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,this._wset}return this._wset}_isInFeatureSet(){return p.dj.InFeatureSet}_nextUniqueName(e){for(;1===e["T"+this._uniqueIds.toString()];)this._uniqueIds++;const t="T"+this._uniqueIds.toString();return e[t]=1,t}_convertToEsriFieldType(e){return e}_initialiseFeatureSet(){const e={};let t=!1,r=1;const s=this._parent?this._parent.getFieldsIndex():new F.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"+r.toString(),r++)}for(const e of this._config.statsfields){const t=new m;t.field=e.name,t.tofieldname=e.name,t.workingexpr=e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,s),t.typeofstat=I(e.statistic),this._decodedStatsfield.push(t)}this._decodedGroupbyfield=[];for(const e of this._config.groupbyfields){const t={name:e.name,singlefield:null,tofieldname:e.name,expression:e.expression instanceof g.WhereClause?e.expression:g.WhereClause.create(e.expression,s)};this._decodedGroupbyfield.push(t)}if(null!==this._parent){this.geometryType=this._parent.geometryType,this.spatialReference=this._parent.spatialReference,this.hasM=this._parent.hasM,this.hasZ=this._parent.hasZ,this.typeIdField="";for(const t of this._parent.fields)e[t.name.toUpperCase()]=1;this.types=null}else this.geometryType=p.Qk.point,this.typeIdField="",this.types=null,this.spatialReference=new S.Z({wkid:4326});this.fields=[];const i=new m;i.field=this._nextUniqueName(e),i.tofieldname=this.objectIdField,i.workingexpr=g.WhereClause.create(this._parent.objectIdField,this._parent.getFieldsIndex()),i.typeofstat="MIN",this._decodedStatsfield.push(i);for(const t of this._decodedGroupbyfield){const r=new b.Z;if(t.name=this._nextUniqueName(e),r.name=t.tofieldname,r.alias=r.name,(0,f.y5)(t.expression)){const e=this._parent.getField((0,f.zR)(t.expression,p.Bj.Standardised));if(!e)throw new _.EN(_.H9.AggregationFieldNotFound);t.name=e.name,t.singlefield=e.name,this.phsyicalgroupbyfields.push(e.name),r.type=e.type}else{r.type=this._convertToEsriFieldType((0,f.DT)(t.expression,this._parent.fields));const e=new b.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}this.fields.push(r)}if(this._adaptedFields.length>0)for(const e of this._parent.fields)this._adaptedFields.push(new o.$X(e));for(let t=0;t<this._decodedStatsfield.length;t++){const r=new b.Z;let s=null;const i=this._decodedStatsfield[t];i.field=this._nextUniqueName(e),i.tofieldname===this.objectIdField&&(this._internalObjectIdField=i.field),r.name=i.tofieldname,r.alias=r.name;const n=null!==i.workingexpr&&(0,f.y5)(i.workingexpr)?(0,f.zR)(i.workingexpr,p.Bj.Standardised):"";switch(this._decodedStatsfield[t].typeofstat){case"SUM":if(""!==n){if(s=this._parent.getField(n),!s)throw new _.EN(_.H9.AggregationFieldNotFound);r.type=s.type}else r.type="double";break;case"MIN":case"MAX":if(""!==n){if(s=this._parent.getField(n),!s)throw new _.EN(_.H9.AggregationFieldNotFound);r.type=s.type}else r.type="double";break;case"COUNT":r.type="integer";break;case"STDDEV":case"VAR":case"AVG":if(""!==n&&(s=this._parent.getField(n),!s))throw new _.EN(_.H9.AggregationFieldNotFound);r.type="double"}this.fields.push(r)}}async _canDoAggregates(){return!1}async _getFeatures(e,t,r,s){-1!==t&&this._featureCache[t];const i=this._maxQuery;return!0===this._checkIfNeedToExpandKnownPage(e,i)?(await this._expandPagedSet(e,i,0,0,s),this._getFeatures(e,t,r,s)):"success"}async _getFilteredSet(e,t,r,s,i){if(""!==e)return new c.Z([],[],!0,null);let a=null;const l={ordered:!1,nowhereclause:!1};if(await this._ensureLoaded(),null!==r)for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===(0,f.hq)(r,this._decodedStatsfield[e].tofieldname)){l.nowhereclause=!0,r=null;break}if(null!==s){l.ordered=!0;for(let e=0;e<this._decodedStatsfield.length;e++)if(!0===s.scanForField(this._decodedStatsfield[e].tofieldname)){s=null,l.ordered=!1;break}if(null!==s)for(const e of this._decodedGroupbyfield)if(null===e.singlefield&&!0===s.scanForField(e.tofieldname)){s=null,l.ordered=!1;break}}if(!1!==this._candosimplegroupby&&await this._parent._canDoAggregates(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,null)){let e=null;r&&(e=this._reformulateWhereClauseWithoutGroupByFields(r));let t=null;s&&(t=this._reformulateOrderClauseWithoutGroupByFields(s));const n=await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields,this._decodedStatsfield,"",null,e,t,this._internalObjectIdField);return this._checkCancelled(i),a=!0===l.nowhereclause?new c.Z(n._candidates.slice(0).concat(n._known.slice(0)),[],!0===l.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)):new c.Z(n._candidates.slice(0),n._known.slice(0),!0===l.ordered&&n._ordered,this._clonePageDefinition(n.pagesDefinition)),a}let d=this._parent;if(this._adaptedFields.length>0&&(d=new o.Xx({parentfeatureset:this._parent,adaptedFields:this._adaptedFields,extraFilter:null})),!0===l.nowhereclause)a=new c.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new u.Z({parentfeatureset:d,orderbyclause:new h.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}});else{let e=d;if(null!==r){let t=null;r&&(t=this._reformulateWhereClauseWithoutGroupByFields(r)),e=new n.Z({parentfeatureset:e,whereclause:t})}a=new c.Z(["GETPAGES"],[],!1,{aggregatefeaturesetpagedefinition:!0,resultOffset:0,resultRecordCount:this._maxQuery,internal:{fullyResolved:!1,workingItem:null,type:"manual",iterator:null,set:[],subfeatureset:new u.Z({parentfeatureset:e,orderbyclause:new h.Z(this.phsyicalgroupbyfields.join(",")+","+this._parent.objectIdField+" ASC")})}})}return a}_reformulateWhereClauseWithoutStatsFields(e){for(const t of this._decodedStatsfield)e=(0,f.bB)(e,t.tofieldname,(0,f.zR)(t.workingexpr,p.Bj.Standardised),this._parent.getFieldsIndex());return e}_reformulateWhereClauseWithoutGroupByFields(e){for(const t of this._decodedGroupbyfield)t.tofieldname!==t.name&&(e=(0,f.bB)(e,t.tofieldname,(0,f.zR)(t.expression,p.Bj.Standardised),this._parent.getFieldsIndex()));return e}_reformulateOrderClauseWithoutGroupByFields(e){const t=[];for(const 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,r){return!0===this._checkIfNeedToExpandCandidatePage(e,this._maxQuery)?(await this._expandPagedSet(e,this._maxQuery,0,0,r),this._refineSetBlock(e,t,r)):(this._checkCancelled(r),e._candidates.length,this._refineKnowns(e,t),e._candidates.length,e._candidates.length,e)}_expandPagedSet(e,t,r,s,i){return this._expandPagedSetFeatureSet(e,t,r,s,i)}async _getPhysicalPage(e,t,r){if(!0===e.pagesDefinition.aggregatefeaturesetpagedefinition)return this._sequentialGetPhysicalItem(e,e.pagesDefinition.resultRecordCount,r,[]);const s=await this._getAgregagtePhysicalPage(e,t,r);for(const e of s){const t={geometry:e.geometry,attributes:{}};for(const r of this._decodedGroupbyfield)t.attributes[r.tofieldname]=e.attributes[r.name];for(const r of this._decodedStatsfield)t.attributes[r.tofieldname]=e.attributes[r.field];this._featureCache[t.attributes[this.objectIdField]]=new a.Z(t)}return s.length}_sequentialGetPhysicalItem(e,t,r,s){return new Promise(((i,n)=>{null===e.pagesDefinition.internal.iterator&&(e.pagesDefinition.internal.iterator=e.pagesDefinition.internal.subfeatureset.iterator(r)),!0===e.pagesDefinition.internal.fullyResolved||0===t?i(s.length):this._nextAggregateItem(e,t,r,s,(n=>{null===n?i(s.length):(t-=1,i(this._sequentialGetPhysicalItem(e,t,r,s)))}),n)}))}_nextAggregateItem(e,t,r,s,i,n){try{(0,l.W)(e.pagesDefinition.internal.iterator.next()).then((a=>{if(null===a)if(null!==e.pagesDefinition.internal.workingItem){const t=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);s.push(t),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(t.attributes[this.objectIdField]),e.pagesDefinition.internal.fullyResolved=!0,i(null)}else e.pagesDefinition.internal.fullyResolved=!0,i(null);else{const l=this._generateAggregateHash(a);if(null===e.pagesDefinition.internal.workingItem)e.pagesDefinition.internal.workingItem={features:[a],id:l};else{if(l!==e.pagesDefinition.internal.workingItem.id){const r=this._calculateAndAppendAggregateItem(e.pagesDefinition.internal.workingItem);return s.push(r),e.pagesDefinition.internal.workingItem=null,e.pagesDefinition.internal.set.push(r.attributes[this.objectIdField]),t-=1,e.pagesDefinition.internal.workingItem={features:[a],id:l},void i(r)}e.pagesDefinition.internal.workingItem.features.push(a)}this._nextAggregateItem(e,t,r,s,i,n)}}),n)}catch(e){n(e)}}_calculateFieldStat(e,t,r){const s=[];for(let r=0;r<e.features.length;r++)if(null!==t.workingexpr){const i=t.workingexpr.calculateValue(e.features[r]);null!==i&&s.push(i)}else s.push(null);switch(t.typeofstat){case"MIN":r.attributes[t.tofieldname]=(0,y.tj)("min",s,-1);break;case"MAX":r.attributes[t.tofieldname]=(0,y.tj)("max",s,-1);break;case"SUM":r.attributes[t.tofieldname]=(0,y.tj)("sum",s,-1);break;case"COUNT":r.attributes[t.tofieldname]=s.length;break;case"VAR":r.attributes[t.tofieldname]=(0,y.tj)("var",s,-1);break;case"STDDEV":r.attributes[t.tofieldname]=(0,y.tj)("stddev",s,-1);break;case"AVG":r.attributes[t.tofieldname]=(0,y.tj)("avg",s,-1)}return!0}_calculateAndAppendAggregateItem(e){const t={attributes:{},geometry:null};for(const r of this._decodedGroupbyfield){const s=r.singlefield?e.features[0].attributes[r.singlefield]:r.expression.calculateValue(e.features[0]);t.attributes[r.tofieldname]=s}for(const r of this._decodedStatsfield)this._calculateFieldStat(e,r,t);const r=[];for(let s=0;s<this._decodedStatsfield.length;s++)r.push(this._calculateFieldStat(e,this._decodedStatsfield[s],t));return this._featureCache[t.attributes[this.objectIdField]]=new a.Z({attributes:t.attributes,geometry:t.geometry}),t}_generateAggregateHash(e){let t="";for(const r of this._decodedGroupbyfield){const s=r.singlefield?e.attributes[r.singlefield]:r.expression.calculateValue(e);t+=null==s?":":":"+s.toString()}return(0,w.F)(t,w.M.String)}async _stat(){return{calculated:!1}}async getFeatureByObjectId(){return null}static registerAction(){d.Z._featuresetFunctions.groupby=function(e,t){return new v({parentfeatureset:this,groupbyfields:e,statsfields:t})}}}var C=r(53073),R=r(63991),T=r(80692),x=r(40330),D=r(33955),k=r(19238),N=r(98732),E=(r(20102),r(80442),r(92604),r(10158),r(4967)),A=(r(68773),r(67676),r(17452),r(67900),r(8744),r(34599)),L=r(74889),j=r(14165),O=(r(98326),r(56545),r(41818)),P=(r(66577),r(5396)),Z=r(75935),G=(r(16306),r(28141),r(78760)),U=r(58539),q=r(33586);class B extends d.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,this._cachedDateMetaData={},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 p.tI}end(){return this._layer}optimisePagingFeatureQueries(e){this._pageJustIds=e}get urlQueryPath(){return this._layer.parsedUrl.path||""}convertQueryToLruCacheKey(e){const t=this.urlQueryPath+","+(0,p.hd)(e.toJSON());return(0,w.F)(t,w.M.String)}async loadImpl(){return!0===this._layer.loaded?(this._initialiseFeatureSet(),this):(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(0),this._layer.outFields)if(1===this._layer.outFields.length&&"*"===this._layer.outFields[0]);else{const e=[];for(const t of this.fields)if("oid"===t.type)e.push(t);else for(const r of this._layer.outFields)if(r.toLowerCase()===t.name.toLowerCase()){e.push(t);break}this.fields=e}if(null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const s of this._overrideFields)if(s.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}if(this._layer.source&&this._layer.source.sourceJSON){const e=this._layer.source.sourceJSON.currentVersion;!0===this._layer.source.sourceJSON.useStandardizedQueries?(this._databaseType=p.Bj.StandardisedNoInterval,null!=e&&e>=10.61&&(this._databaseType=p.Bj.Standardised)):null!=e&&(e>=10.5&&(this._databaseType=p.Bj.StandardisedNoInterval,this._requestStandardised=!0),e>=10.61&&(this._databaseType=p.Bj.Standardised))}this.objectIdField=this._layer.objectIdField;for(const e of this.fields)"global-id"===e.type&&(this.globalIdField=e.name);this.hasM=this._layer.supportsM,this.hasZ=this._layer.supportsZ,this.typeIdField=this._layer.typeIdField??"",this.types=this._layer.types}_isInFeatureSet(){return p.dj.InFeatureSet}async _refineSetBlock(e){return e}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}async _runDatabaseProbe(e){await this._ensureLoaded();const t=new j.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}pbfSupportedForQuery(e){const t=this._layer?.capabilities?.query;return!e.outStatistics&&!0===t?.supportsFormatPBF&&!0===t?.supportsQuantizationEditMode}async queryPBF(e){e.quantizationParameters={mode:"edit"};const t=await(0,A.qp)(this._layer.parsedUrl,e,new G.J({}));return L.Z.fromJSON((0,N.cn)(t.data)).unquantize()}get gdbVersion(){return this._layer&&this._layer.capabilities&&this._layer.capabilities.data&&this._layer.capabilities.data.isVersioned?this._layer.gdbVersion?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}}executeQuery(e,t){const r="execute"===t?E.e:"executeForCount"===t?O.P:P.G,s="execute"===t&&this.pbfSupportedForQuery(e);let i=null;if(this.recentlyUsedQueries){const t=this.convertQueryToLruCacheKey(e);i=this.recentlyUsedQueries.getFromCache(t),null===i&&(i=!0!==s?r(this._layer.parsedUrl.path,e):this.queryPBF(e),this.recentlyUsedQueries.addToCache(t,i),i=i.catch((e=>{throw this.recentlyUsedQueries?.removeFromCache(t),e})))}return this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:e,method:t}),null===i&&(i=!0!==s?r(this._layer.parsedUrl.path,e):this.queryPBF(e)),i}async _getFilteredSet(e,t,r,s,i){const n=await this.databaseType();if(this.isTable()&&t&&null!==e&&""!==e)return new c.Z([],[],!0,null);if(this._canUsePagination())return this._getFilteredSetUsingPaging(e,t,r,s,i);let a="",l=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(a=s.constructClause(),l=!0);const o=new j.Z;this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.where=null===r?null===t?"1=1":"":(0,f.zR)(r,n),this._requestStandardised&&(o.sqlFormat="standard"),o.spatialRelationship=this._makeRelationshipEnum(e),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null,o.geometry=null===t?null:t,o.relationParameter=this._makeRelationshipParam(e);let u=await this.executeQuery(o,"executeForIds");return null===u&&(u=[]),this._checkCancelled(i),new c.Z([],u,l,null)}_expandPagedSet(e,t,r,s,i){return this._expandPagedSetFeatureSet(e,t,r,s,i)}async _getFilteredSetUsingPaging(e,t,r,s,i){let n="",a=!1;null!==s&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(n=s.constructClause(),a=!0);const l=await this.databaseType();let o=null===r?null===t?"1=1":"":(0,f.zR)(r,l);this._layer.definitionExpression&&this._useDefinitionExpression&&(o=""!==o?"(("+this._layer.definitionExpression+") AND ("+o+"))":this._layer.definitionExpression);let u=this._maxQueryRate();const d=this._layer.capabilities?.query.maxRecordCount;null!=d&&d<u&&(u=d);let h=null;if(!0===this._pageJustIds)h=new c.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:this._layer.objectIdField,resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:!1,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}});else{let r=!0;!0===this._removeGeometry&&(r=!1);const s=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]);h=new c.Z([],["GETPAGES"],a,{spatialRel:this._makeRelationshipEnum(e),relationParam:this._makeRelationshipParam(e),outFields:s.join(","),resultRecordCount:u,resultOffset:0,geometry:null===t?null:t,where:o,orderByFields:n,returnGeometry:r,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}return await this._expandPagedSet(h,u,0,1,i),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,groupByFieldsForStatistics: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,r){const s=e.pagesDefinition.internal.lastRetrieved,i=s,n=e.pagesDefinition.internal.lastPage,a=new j.Z;this._requestStandardised&&(a.sqlFormat="standard"),this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.spatialRelationship=e.pagesDefinition.spatialRel,a.relationParameter=e.pagesDefinition.relationParam,a.outFields=e.pagesDefinition.outFields.split(","),a.num=e.pagesDefinition.resultRecordCount,a.start=e.pagesDefinition.internal.lastPage,a.geometry=e.pagesDefinition.geometry,a.where=e.pagesDefinition.where,a.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,a.returnGeometry=e.pagesDefinition.returnGeometry,a.outSpatialReference=this.spatialReference;const l=await this.executeQuery(a,"execute");if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==n)return"done";const o=this._layer.objectIdField;for(let t=0;t<l.features.length;t++)e.pagesDefinition.internal.set[i+t]=l.features[t].attributes[o];if(!1===this._pageJustIds)for(let e=0;e<l.features.length;e++)this._featureCache[l.features[e].attributes[o]]=l.features[e];return(void 0===l.exceededTransferLimit&&l.features.length!==e.pagesDefinition.resultRecordCount||!1===l.exceededTransferLimit)&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=s+l.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,"done"}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}async _getFeatures(e,t,r,s){const i=[];if(-1!==t&&void 0===this._featureCache[t]&&i.push(t),!0===this._checkIfNeedToExpandKnownPage(e,this._maxProcessingRate()))return await this._expandPagedSet(e,this._maxProcessingRate(),0,0,s),this._getFeatures(e,t,r,s);let n=0;for(let s=e._lastFetchedIndex;s<e._known.length;s++){if(e._lastFetchedIndex+=1,n++,void 0===this._featureCache[e._known[s]]){let r=!1;if(null!==this._layer._mode&&void 0!==this._layer._mode){const t=this._layer._mode;if(void 0!==t._featureMap[e._known[s]]){const i=t._featureMap[e._known[s]];null!==i&&(r=!0,this._featureCache[e._known[s]]=i)}}if(!1===r&&(e._known[s]!==t&&i.push(e._known[s]),i.length>=this._maxProcessingRate()-1))break}if(n>=r&&0===i.length)break}if(0===i.length)return"success";const a=new j.Z;this._requestStandardised&&(a.sqlFormat="standard"),this.datesInUnknownTimezone&&(a.timeReferenceUnknownClient=!0),a.objectIds=i,a.outFields=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._layer.outFields?this._layer.outFields:["*"]),a.returnGeometry=!0,!0===this._removeGeometry&&(a.returnGeometry=!1),a.outSpatialReference=this.spatialReference;const l=await this.executeQuery(a,"execute");if(this._checkCancelled(s),void 0!==l.error)throw new _.EN(_.H9.RequestFailed,{reason:l.error});const o=this._layer.objectIdField;for(let e=0;e<l.features.length;e++)this._featureCache[l.features[e].attributes[o]]=l.features[e];return"success"}async _getDistinctPages(e,t,r,s,i,n,a,l,o){await this._ensureLoaded();const u=await this.databaseType();let d=r.parseTree.column;const c=this._layer.fields??[];for(let e=0;e<c.length;e++)if(c[e].name.toLowerCase()===d.toLowerCase()){d=c[e].name;break}const h=new j.Z;this._requestStandardised&&(h.sqlFormat="standard"),this.datesInUnknownTimezone&&(h.timeReferenceUnknownClient=!0);let p=null===n?null===i?"1=1":"":(0,f.zR)(n,u);this._layer.definitionExpression&&this._useDefinitionExpression&&(p=""!==p?"(("+this._layer.definitionExpression+") AND ("+p+"))":this._layer.definitionExpression),h.where=p,h.spatialRelationship=this._makeRelationshipEnum(s),h.relationParameter=this._makeRelationshipParam(s),h.geometry=null===i?null:i,h.returnDistinctValues=!0,h.returnGeometry=!1,h.outFields=[d];const y=await this.executeQuery(h,"execute");if(this._checkCancelled(o),!y.hasOwnProperty("features"))throw new _.EN(_.H9.InvalidStatResponse);let g=!1;for(let e=0;e<c.length;e++)if(c[e].name===d){"date"===c[e].type&&(g=!0);break}for(let e=0;e<y.features.length;e++){if(g){const t=y.features[e].attributes[d];null!==t?l.push(new Date(t)):l.push(t)}else l.push(y.features[e].attributes[d]);if(l.length>=a)break}return 0===y.features.length?l:y.features.length===this._layer.capabilities?.query.maxRecordCount&&l.length<a?{calculated:!0,result:await this._getDistinctPages(e+y.features.length,t,r,s,i,n,a,l,o)}:l}async _distinctStat(e,t,r,s,i,n,a){return{calculated:!0,result:await this._getDistinctPages(0,e,t,r,s,i,n,[],a)}}isTable(){return this._layer.isTable||null===this._layer.geometryType||"table"===this._layer.type||""===this._layer.geometryType||"esriGeometryNull"===this._layer.geometryType}async _countstat(e,t,r,s){const i=await this.databaseType(),n=new j.Z;if(this._requestStandardised&&(n.sqlFormat="standard"),this.isTable()&&r&&null!==t&&""!==t)return{calculated:!0,result:0};let a=null===s?null===r?"1=1":"":(0,f.zR)(s,i);return this._layer.definitionExpression&&this._useDefinitionExpression&&(a=""!==a?"(("+this._layer.definitionExpression+") AND ("+a+"))":this._layer.definitionExpression),n.where=a,this.datesInUnknownTimezone&&(n.timeReferenceUnknownClient=!0),n.where=a,n.spatialRelationship=this._makeRelationshipEnum(t),n.relationParameter=this._makeRelationshipParam(t),n.geometry=null===r?null:r,n.returnGeometry=!1,{calculated:!0,result:await this.executeQuery(n,"executeForCount")}}async _stats(e,t,r,s,i,n,a){await this._ensureLoaded();const l=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsSqlExpression,o=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsStatistics,u=this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsDistinct;if("count"===e)return u?this._countstat(e,r,s,i):{calculated:!1};if(!1===o||!1===(0,f.y5)(t)&&!1===l||!1===t.isStandardized)return""!==r||null!==i?{calculated:!1}:this._manualStat(e,t,n,a);if("distinct"===e)return!1===u?""!==r||null!==i?{calculated:!1}:this._manualStat(e,t,n,a):this._distinctStat(e,t,r,s,i,n,a);const d=await this.databaseType();if(this.isTable()&&s&&null!==r&&""!==r)return{calculated:!0,result:null};const c=new j.Z;this._requestStandardised&&(c.sqlFormat="standard");let h=null===i?null===s?"1=1":"":(0,f.zR)(i,d);this._layer.definitionExpression&&this._useDefinitionExpression&&(h=""!==h?"(("+this._layer.definitionExpression+") AND ("+h+"))":this._layer.definitionExpression),c.where=h,c.spatialRelationship=this._makeRelationshipEnum(r),c.relationParameter=this._makeRelationshipParam(r),c.geometry=null===s?null:s,this.datesInUnknownTimezone&&(c.timeReferenceUnknownClient=!0);const p=new U.Z;p.statisticType=(0,y.g3)(e),p.onStatisticField=(0,f.zR)(t,d),p.outStatisticFieldName="ARCADE_STAT_RESULT",c.returnGeometry=!1;let g="ARCADE_STAT_RESULT";c.outStatistics=[p];const m=await this.executeQuery(c,"execute");if(!m.hasOwnProperty("features")||0===m.features.length)throw new _.EN(_.H9.InvalidStatResponse);let w=!1;const S=m.fields??[];for(let e=0;e<S.length;e++)if("ARCADE_STAT_RESULT"===S[e].name.toUpperCase()){g=S[e].name,"date"===S[e].type&&(w=!0);break}if(w){let e=m.features[0].attributes[g];return null!==e&&(e=new Date(m.features[0].attributes[g])),{calculated:!0,result:e}}return{calculated:!0,result:m.features[0].attributes[g]}}_stat(e,t,r,s,i,n,a){return this._stats(e,t,r,s,i,n,a)}async _canDoAggregates(e,t){await this._ensureLoaded();let r=!1;const s=this._layer.capabilities?.query,i=!0===s?.supportsSqlExpression;if(null!=s&&!0===s.supportsStatistics&&!0===s.supportsOrderBy&&(r=!0),r)for(let e=0;e<t.length-1;e++)(!1===t[e].workingexpr?.isStandardized||!1===(0,f.y5)(t[e].workingexpr)&&!1===i)&&(r=!1);return!1!==r}_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,r,s,i,n,a){await this._ensureLoaded();const l=await this.databaseType();let o="",u=!1,d=!1;null!==n&&this._layer.capabilities&&this._layer.capabilities.query&&!0===this._layer.capabilities.query.supportsOrderBy&&(o=n.constructClause(),d=!0),this._layer.capabilities&&this._layer.capabilities.query&&!1===this._layer.capabilities.query.supportsPagination&&(d=!1,u=!0,o=this._layer.objectIdField);const h=[];for(let e=0;e<t.length;e++){const r=new U.Z;r.onStatisticField=null!==t[e].workingexpr?(0,f.zR)(t[e].workingexpr,l):"",r.outStatisticFieldName=t[e].field,r.statisticType=t[e].toStatisticsName(),h.push(r)}""===o&&(o=e.join(","));let p=this._maxQueryRate();const y=this._layer.capabilities?.query.maxRecordCount;null!=y&&y<p&&(p=y);let _=null===i?null===s?"1=1":"":(0,f.zR)(i,l);return this._layer.definitionExpression&&this._useDefinitionExpression&&(_=""!==_?"(("+this._layer.definitionExpression+") AND ("+_+"))":this._layer.definitionExpression),new c.Z([],["GETPAGES"],d,{groupbypage:!0,spatialRel:this._makeRelationshipEnum(r),relationParam:this._makeRelationshipParam(r),outFields:["*"],useOIDpagination:u,generatedOid:a,resultRecordCount:p,resultOffset:0,groupByFieldsForStatistics:e,outStatistics:h,geometry:null===s?null:s,where:_,orderByFields:o,returnGeometry:!1,returnIdsOnly:!1,internal:{lastMaxId:-1,set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}})}async _getAgregagtePhysicalPage(e,t,r){let s=e.pagesDefinition.where;!0===e.pagesDefinition.useOIDpagination&&(s=""!==s?"("+s+") AND ("+e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString()+")":e.pagesDefinition.generatedOid+">"+e.pagesDefinition.internal.lastMaxId.toString());const i=e.pagesDefinition.internal.lastRetrieved,n=i,l=e.pagesDefinition.internal.lastPage,o=new j.Z;if(this._requestStandardised&&(o.sqlFormat="standard"),o.where=s,o.spatialRelationship=e.pagesDefinition.spatialRel,o.relationParameter=e.pagesDefinition.relationParam,o.outFields=e.pagesDefinition.outFields,o.outStatistics=e.pagesDefinition.outStatistics,o.geometry=e.pagesDefinition.geometry,o.groupByFieldsForStatistics=e.pagesDefinition.groupByFieldsForStatistics,o.num=e.pagesDefinition.resultRecordCount,o.start=e.pagesDefinition.internal.lastPage,o.returnGeometry=e.pagesDefinition.returnGeometry,this.datesInUnknownTimezone&&(o.timeReferenceUnknownClient=!0),o.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,this.isTable()&&o.geometry&&o.spatialRelationship)return[];const u=await this.executeQuery(o,"execute");if(this._checkCancelled(r),!u.hasOwnProperty("features"))throw new _.EN(_.H9.InvalidStatResponse);const d=[];if(e.pagesDefinition.internal.lastPage!==l)return[];for(let t=0;t<u.features.length;t++)e.pagesDefinition.internal.set[n+t]=u.features[t].attributes[e.pagesDefinition.generatedOid];for(let e=0;e<u.features.length;e++)d.push(new a.Z({attributes:u.features[e].attributes,geometry:null}));return!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=i+u.features.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,d}static create(e,t,r,s,i){const n=new k.default({url:e,outFields:null===t?["*"]:t});return new B({layer:n,spatialReference:r,lrucache:s,interceptor:i})}relationshipMetaData(){return this._layer&&this._layer.source&&this._layer.source.sourceJSON&&this._layer.source.sourceJSON.relationships?this._layer.source.sourceJSON.relationships:[]}serviceUrl(){return(0,p.US)(this._layer.parsedUrl.path)}async queryAttachments(e,t,r,s,i){const n=this._layer.capabilities;if(n?.data.supportsAttachment&&n?.operations.supportsQueryAttachments){const n={objectIds:[e],returnMetadata:i};(t&&t>0||r&&r>0)&&(n.size=[t&&t>0?t:0,r&&r>0?r:t+1]),s&&s.length>0&&(n.attachmentTypes=s),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:n,method:"attachments"});const a=await this._layer.queryAttachments(n),l=[];return a&&a[e]&&a[e].forEach((t=>{const r=this._layer.parsedUrl.path+"/"+e.toString()+"/attachments/"+t.id.toString();let s=null;i&&t.exifInfo&&(s=q.Z.convertJsonToArcade(t.exifInfo,"system",!0)),l.push(new T.Z(t.id,t.name,t.contentType,t.size,r,s))})),l}return[]}async queryRelatedFeatures(e){const 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=JSON.stringify(e.outSpatialReference.toJSON())),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preRequestCallback({layer:this._layer,queryPayload:t,method:"relatedrecords",url:this._layer.parsedUrl.path+"/queryRelatedRecords"});const r=await(0,s.default)(this._layer.parsedUrl.path+"/queryRelatedRecords",{responseType:"json",query:t});if(r.data){const e={},t=r.data;if(t&&t.relatedRecordGroups){const r=t.spatialReference;for(const s of t.relatedRecordGroups){const i=s.objectId,n=[];for(const e of s.relatedRecords){e.geometry&&(e.geometry.spatialReference=r);const t=new a.Z({geometry:e.geometry?(0,D.im)(e.geometry):null,attributes:e.attributes});n.push(t)}e[i]={features:n,exceededTransferLimit:!0===t.exceededTransferLimit}}}return e}throw new _.EN(_.H9.InvalidRequest)}async getFeatureByObjectId(e,t){const r=new j.Z;r.outFields=t,r.returnGeometry=!1,r.outSpatialReference=this.spatialReference,r.where=this.objectIdField+"="+e.toString(),this.datesInUnknownTimezone&&(r.timeReferenceUnknownClient=!0),this.featureSetQueryInterceptor&&this.featureSetQueryInterceptor.preLayerQueryCallback({layer:this._layer,query:r,method:"execute"});const s=await(0,E.e)(this._layer.parsedUrl.path,r);return 1===s.features.length?s.features[0]:null}async getIdentityUser(){await this.load();const e=x.id?.findCredential(this._layer.url);return e?e.userId:null}async getOwningSystemUrl(){await this.load();const e=x.id?.findServerInfo(this._layer.url);if(e)return e.owningSystemUrl;let t=this._layer.url;const r=t.toLowerCase().indexOf("/rest/services");if(t=r>-1?t.substring(0,r):t,t){t+="/rest/info";try{const e=await(0,s.default)(t,{query:{f:"json"}});let r="";return e.data&&e.data.owningSystemUrl&&(r=e.data.owningSystemUrl),r}catch(e){return""}}return""}getDataSourceFeatureSet(){const e=new B({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 preferredTimeReference(){return void 0===this._cachedDateMetaData.preferredTimeReference&&(this._cachedDateMetaData.preferredTimeReference=this._layer?.preferredTimeReference?.toJSON()??null),this._cachedDateMetaData.preferredTimeReference}get dateFieldsTimeReference(){return void 0===this._cachedDateMetaData.dateFieldsTimeReference&&(this._cachedDateMetaData.dateFieldsTimeReference=this._layer?.dateFieldsTimeReference?.toJSON()??null),this._cachedDateMetaData.dateFieldsTimeReference}get datesInUnknownTimezone(){return this._layer.datesInUnknownTimezone}get editFieldsInfo(){return void 0===this._cachedDateMetaData.editFieldsInfo&&(this._cachedDateMetaData.editFieldsInfo=this._layer?.editFieldsInfo?.toJSON()??null),this._cachedDateMetaData.editFieldsInfo}get timeInfo(){return void 0===this._cachedDateMetaData.timeInfo&&(this._cachedDateMetaData.timeInfo=this._layer?.timeInfo?.toJSON()??null),this._cachedDateMetaData.timeInfo}}var M=r(17805);class W extends d.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 p.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(0),null!==this._overrideFields)if(1===this._overrideFields.length&&"*"===this._overrideFields[0])this._overrideFields=null;else{const e=[],t=[];for(const r of this.fields)if("oid"===r.type)e.push(r),t.push(r.name);else for(const s of this._overrideFields)if(s.toLowerCase()===r.name.toLowerCase()){e.push(r),t.push(r.name);break}this.fields=e,this._overrideFields=t}const 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}async databaseType(){return await this._relatedLayer.databaseType(),this._databaseType=this._relatedLayer._databaseType,this._databaseType}isTable(){return this._relatedLayer.isTable()}_isInFeatureSet(){return p.dj.InFeatureSet}_candidateIdTransform(e){return e}async _getSet(e){if(null===this._wset){await this._ensureLoaded();const t=await this._getFilteredSet("",null,null,null,e);return this._wset=t,t}return this._wset}_changeFeature(e){const t={};for(const r of this.fields)t[r.name]=e.attributes[r.name];return new a.Z({geometry:!0===this._removeGeometry?null:e.geometry,attributes:t})}async _getFilteredSet(e,t,r,s,i){if(await this.databaseType(),this.isTable()&&t&&null!==e&&""!==e)return new c.Z([],[],!0,null);const n=this._layer.nativeCapabilities();if(!1===n.canQueryRelated)return new c.Z([],[],!0,null);if(n.capabilities?.queryRelated&&n.capabilities.queryRelated.supportsPagination)return this._getFilteredSetUsingPaging(e,t,r,s,i);let a="",l=!1;null!==s&&n.capabilities&&n.capabilities.queryRelated&&!0===n.capabilities.queryRelated.supportsOrderBy&&(a=s.constructClause(),l=!0);const o=new Z.default;o.objectIds=[this._findObjectId];const u=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);o.outFields=u,o.relationshipId=this.relationship.id,o.where="1=1";let d=!0;!0===this._removeGeometry&&(d=!1),o.returnGeometry=d,this._requestStandardised&&(o.sqlFormat="standard"),o.outSpatialReference=this.spatialReference,o.orderByFields=""!==a?a.split(","):null;const h=await n.source.queryRelatedFeatures(o);this._checkCancelled(i);const p=h[this._findObjectId]?h[this._findObjectId].features:[],f=[];for(let e=0;e<p.length;e++)this._featureCache[p[e].attributes[this._relatedLayer.objectIdField]]=p[e],f.push(p[e].attributes[this._relatedLayer.objectIdField]);const y=t&&null!==e&&""!==e,_=null!=r;return new c.Z(y||_?f:[],y||_?[]:f,l,null)}_fieldsIncludingObjectId(e){if(null===e)return[this.objectIdField];const t=e.slice(0);if(t.includes("*"))return t;let r=!1;for(const e of t)if(e.toUpperCase()===this.objectIdField.toUpperCase()){r=!0;break}return!1===r&&t.push(this.objectIdField),t}async _getFilteredSetUsingPaging(e,t,r,s,i){let n="",a=!1;const l=this._layer.nativeCapabilities();null!==s&&l&&l.capabilities?.queryRelated&&!0===l.capabilities.queryRelated.supportsOrderBy&&(n=s.constructClause(),a=!0),await this.databaseType();let o=this._maxQueryRate();const u=l.capabilities?.query.maxRecordCount;null!=u&&u<o&&(o=u);const d=t&&null!==e&&""!==e,h=null!=r;let p=null,f=!0;!0===this._removeGeometry&&(f=!1);const y=null!==this._overrideFields?this._overrideFields:this._fieldsIncludingObjectId(this._relatedLayer.fields?this._relatedLayer.fields.map((e=>e.name)):["*"]);return p=new c.Z(d||h?["GETPAGES"]:[],d||h?[]:["GETPAGES"],a,{outFields:y.join(","),resultRecordCount:o,resultOffset:0,objectIds:[this._findObjectId],where:"1=1",orderByFields:n,returnGeometry:f,returnIdsOnly:"false",internal:{set:[],lastRetrieved:0,lastPage:0,fullyResolved:!1}}),await this._expandPagedSet(p,o,0,0,i),p}_expandPagedSet(e,t,r,s,i){return this._expandPagedSetFeatureSet(e,t,r,s,i)}_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,groupByFieldsForStatistics: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,r){const s=e.pagesDefinition.internal.lastRetrieved,i=s,n=e.pagesDefinition.internal.lastPage,a=this._layer.nativeCapabilities(),l=new Z.default;!0===this._requestStandardised&&(l.sqlFormat="standard"),l.relationshipId=this.relationship.id,l.objectIds=e.pagesDefinition.objectIds,l.resultOffset=e.pagesDefinition.internal.lastPage,l.resultRecordCount=e.pagesDefinition.resultRecordCount,l.outFields=e.pagesDefinition.outFields.split(","),l.where=e.pagesDefinition.where,l.orderByFields=""!==e.pagesDefinition.orderByFields?e.pagesDefinition.orderByFields.split(","):null,l.returnGeometry=e.pagesDefinition.returnGeometry,l.outSpatialReference=this.spatialReference;const o=await a.source.queryRelatedFeatures(l);if(this._checkCancelled(r),e.pagesDefinition.internal.lastPage!==n)return 0;const u=o[this._findObjectId]?o[this._findObjectId].features:[];for(let t=0;t<u.length;t++)e.pagesDefinition.internal.set[i+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];const d=!o[this._findObjectId]||!1===o[this._findObjectId].exceededTransferLimit;return u.length!==e.pagesDefinition.resultRecordCount&&d&&(e.pagesDefinition.internal.fullyResolved=!0),e.pagesDefinition.internal.lastRetrieved=s+u.length,e.pagesDefinition.internal.lastPage+=e.pagesDefinition.resultRecordCount,u.length}async _getFeatures(e,t,r,s){const i=[];-1!==t&&void 0===this._featureCache[t]&&i.push(t);const n=this._maxQueryRate();if(!0===this._checkIfNeedToExpandKnownPage(e,n))return await this._expandPagedSet(e,n,0,0,s),this._getFeatures(e,t,r,s);let a=0;for(let s=e._lastFetchedIndex;s<e._known.length&&(a++,a<=r&&(e._lastFetchedIndex+=1),!("GETPAGES"!==e._known[s]&&void 0===this._featureCache[e._known[s]]&&(e._known[s]!==t&&i.push(e._known[s]),i.length>r)))&&!(a>=r&&0===i.length);s++);if(0===i.length)return"success";throw new _.EN(_.H9.MissingFeatures)}async _refineSetBlock(e,t,r){return e}async _stat(e,t,r,s,i,n,a){return{calculated:!1}}get gdbVersion(){return this._relatedLayer.gdbVersion}async _canDoAggregates(e,t,r,s,i){return!1}relationshipMetaData(){return this._relatedLayer.relationshipMetaData()}serviceUrl(){return this._relatedLayer.serviceUrl()}queryAttachments(e,t,r,s,i){return this._relatedLayer.queryAttachments(e,t,r,s,i)}getFeatureByObjectId(e,t){return this._relatedLayer.getFeatureByObjectId(e,t)}getOwningSystemUrl(){return this._relatedLayer.getOwningSystemUrl()}getIdentityUser(){return this._relatedLayer.getIdentityUser()}getDataSourceFeatureSet(){return this._relatedLayer}get preferredTimeReference(){return this._relatedLayer?.preferredTimeReference??null}get dateFieldsTimeReference(){return this._relatedLayer?.dateFieldsTimeReference??null}get datesInUnknownTimezone(){return this._relatedLayer?.datesInUnknownTimezone}get editFieldsInfo(){return this._relatedLayer?.editFieldsInfo??null}get timeInfo(){return this._relatedLayer?.timeInfo??null}}var Q=r(48039),z=r(15235);function V(){null===Q.Z.applicationCache&&(Q.Z.applicationCache=new Q.Z)}async function H(e,t){if(Q.Z.applicationCache){const r=Q.Z.applicationCache.getLayerInfo(e);if(r){const s=await r;return new k.default({url:e,outFields:t,sourceJSON:s})}const s=new k.default({url:e,outFields:t}),i=(async()=>(await s.load(),s.sourceJSON))();if(Q.Z.applicationCache){Q.Z.applicationCache.setLayerInfo(e,i);try{return await i,s}catch(t){throw Q.Z.applicationCache.clearLayerInfo(e),t}}return await i,s}return new k.default({url:e,outFields:t})}async function J(e,t,r,s,i,n=null){return K(await H(e,["*"]),t,r,s,i,n)}function K(e,t=null,r=null,s=!0,i=null,n=null){const a={layer:e,spatialReference:t,outFields:r,includeGeometry:s,lrucache:i,interceptor:n};return!0===e._hasMemorySource()?new M.Z(a):new B(a)}async function $(e){if(null!==Q.Z.applicationCache){const t=Q.Z.applicationCache.getLayerInfo(e);if(null!==t)return t}const t=(async()=>{const t=await(0,s.default)(e,{responseType:"json",query:{f:"json"}});if(t.data){const e=t.data;return e.layers||(e.layers=[]),e.tables