chunk-22GTG6HL.js 116 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491
  1. import {
  2. n as n6,
  3. x as x2
  4. } from "./chunk-UFOCENZS.js";
  5. import {
  6. E,
  7. T,
  8. a as a2,
  9. a2 as a3,
  10. c as c2,
  11. f,
  12. f2,
  13. h,
  14. h2,
  15. i as i2,
  16. k as k3,
  17. l,
  18. n as n5,
  19. o,
  20. s as s3,
  21. t as t2,
  22. u
  23. } from "./chunk-6KWY7SN7.js";
  24. import {
  25. e
  26. } from "./chunk-L5OAV75Q.js";
  27. import {
  28. d as d2
  29. } from "./chunk-R5LRKX5A.js";
  30. import {
  31. n as n4,
  32. s as s2
  33. } from "./chunk-4JM5IOYA.js";
  34. import {
  35. m
  36. } from "./chunk-ETWBEEKL.js";
  37. import {
  38. c
  39. } from "./chunk-PJ6KSXOD.js";
  40. import {
  41. s
  42. } from "./chunk-MTFA4FTA.js";
  43. import {
  44. Ke
  45. } from "./chunk-6NQ3AA2U.js";
  46. import {
  47. d as d5
  48. } from "./chunk-Z64YKYHD.js";
  49. import {
  50. x
  51. } from "./chunk-2VFJVI2I.js";
  52. import {
  53. d as d4
  54. } from "./chunk-GS2NUWMB.js";
  55. import {
  56. a
  57. } from "./chunk-54AOZV5X.js";
  58. import {
  59. se
  60. } from "./chunk-FYNVVMWY.js";
  61. import {
  62. D,
  63. F,
  64. S,
  65. Te,
  66. b,
  67. i2 as i,
  68. n,
  69. t3 as t
  70. } from "./chunk-25BNEBXZ.js";
  71. import {
  72. n as n3
  73. } from "./chunk-KN7TOKVN.js";
  74. import {
  75. g
  76. } from "./chunk-RZFGRBD7.js";
  77. import {
  78. b as b2,
  79. m as m2
  80. } from "./chunk-UD63WBG3.js";
  81. import {
  82. d as d3
  83. } from "./chunk-KMAHKQ2G.js";
  84. import {
  85. y
  86. } from "./chunk-BJHM4JNS.js";
  87. import {
  88. d
  89. } from "./chunk-2Z6LERTI.js";
  90. import {
  91. b as b3
  92. } from "./chunk-EGZW6HC3.js";
  93. import {
  94. B
  95. } from "./chunk-4NKD334K.js";
  96. import {
  97. U
  98. } from "./chunk-VNFRAYHO.js";
  99. import {
  100. n as n2
  101. } from "./chunk-R5IG2D6H.js";
  102. import {
  103. p
  104. } from "./chunk-ECW2QABR.js";
  105. import {
  106. k2
  107. } from "./chunk-MRJEICT6.js";
  108. import {
  109. k
  110. } from "./chunk-ULGDPLM2.js";
  111. // node_modules/@arcgis/core/arcade/featureSetCollection.js
  112. var e2 = class {
  113. constructor() {
  114. this.declaredRootClass = "esri.arcade.featureSetCollection", this._layerById = {}, this._layerByName = {};
  115. }
  116. add(e4, t4, a5) {
  117. this._layerById[t4] = a5, this._layerByName[e4] = a5;
  118. }
  119. async featureSetByName(e4, t4 = true, a5 = ["*"]) {
  120. return this._layerByName[e4] === void 0 ? null : this._layerByName[e4];
  121. }
  122. async featureSetById(e4, t4 = true, a5 = ["*"]) {
  123. return this._layerById[e4] === void 0 ? null : this._layerById[e4];
  124. }
  125. castToText() {
  126. return "object, FeatureSetCollection";
  127. }
  128. };
  129. // node_modules/@arcgis/core/arcade/featureset/actions/AttributeFilter.js
  130. var h3 = class extends k3 {
  131. constructor(e4) {
  132. super(e4), this.declaredClass = "esri.arcade.featureset.actions.AttributeFilter", this._maxProcessing = 1e3, this._parent = e4.parentfeatureset, e4.whereclause instanceof m ? (this._whereclause = e4.whereclause, this._whereClauseFunction = null) : (this._whereClauseFunction = e4.whereclause, this._whereclause = null);
  133. }
  134. _initialiseFeatureSet() {
  135. this._parent !== null ? (this.fields = this._parent.fields.slice(0), 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.fields = [], this.typeIdField = "", this.objectIdField = "", this.globalIdField = "", this.spatialReference = new k2({ wkid: 4326 }), this.geometryType = S.point);
  136. }
  137. async _getSet(e4) {
  138. if (this._wset === null) {
  139. await this._ensureLoaded();
  140. const s6 = await this._parent._getFilteredSet("", null, this._whereclause, null, e4);
  141. return this._checkCancelled(e4), this._whereClauseFunction !== null ? this._wset = new t2(s6._candidates.slice(0).concat(s6._known.slice(0)), [], s6._ordered, this._clonePageDefinition(s6.pagesDefinition)) : this._wset = new t2(s6._candidates.slice(0), s6._known.slice(0), s6._ordered, this._clonePageDefinition(s6.pagesDefinition)), this._wset;
  142. }
  143. return this._wset;
  144. }
  145. _isInFeatureSet(e4) {
  146. let t4 = this._parent._isInFeatureSet(e4);
  147. return t4 === i.NotInFeatureSet ? t4 : (t4 = this._idstates[e4], t4 === void 0 ? i.Unknown : t4);
  148. }
  149. _getFeature(e4, t4, s6) {
  150. return this._parent._getFeature(e4, t4, s6);
  151. }
  152. _getFeatures(e4, t4, s6, i3) {
  153. return this._parent._getFeatures(e4, t4, s6, i3);
  154. }
  155. _featureFromCache(e4) {
  156. return this._parent._featureFromCache(e4);
  157. }
  158. executeWhereClause(e4) {
  159. return this._whereclause.testFeature(e4);
  160. }
  161. async executeWhereClauseDeferred(e4) {
  162. if (this._whereClauseFunction !== null) {
  163. const t4 = this._whereClauseFunction(e4);
  164. return k(t4), t4;
  165. }
  166. return this.executeWhereClause(e4);
  167. }
  168. async _fetchAndRefineFeatures(e4, s6, r) {
  169. const n9 = new t2([], e4, false, null), a5 = Math.min(s6, e4.length);
  170. if (await this._parent._getFeatures(n9, -1, a5, r), this._checkCancelled(r), this._whereClauseFunction == null) {
  171. for (let t4 = 0; t4 < a5; t4++) {
  172. const s7 = this._parent._featureFromCache(e4[t4]);
  173. this.executeWhereClause(s7) === true ? this._idstates[e4[t4]] = i.InFeatureSet : this._idstates[e4[t4]] = i.NotInFeatureSet;
  174. }
  175. return "success";
  176. }
  177. const l2 = [];
  178. for (let t4 = 0; t4 < a5; t4++) {
  179. const s7 = this._parent._featureFromCache(e4[t4]);
  180. l2.push(await this.executeWhereClauseDeferred(s7));
  181. }
  182. for (let t4 = 0; t4 < s6; t4++)
  183. l2[t4] === true ? this._idstates[e4[t4]] = i.InFeatureSet : this._idstates[e4[t4]] = i.NotInFeatureSet;
  184. return "success";
  185. }
  186. async _getFilteredSet(e4, s6, i3, n9, a5) {
  187. this._whereClauseFunction !== null || (i3 !== null ? this._whereclause !== null && (i3 = o(this._whereclause, i3)) : i3 = this._whereclause), await this._ensureLoaded();
  188. const l2 = await this._parent._getFilteredSet(e4, s6, i3, n9, a5);
  189. let h4;
  190. return this._checkCancelled(a5), h4 = this._whereClauseFunction !== null ? new t2(l2._candidates.slice(0).concat(l2._known.slice(0)), [], l2._ordered, this._clonePageDefinition(l2.pagesDefinition)) : new t2(l2._candidates.slice(0), l2._known.slice(0), l2._ordered, this._clonePageDefinition(l2.pagesDefinition)), h4;
  191. }
  192. async _stat(e4, t4, s6, i3, n9, a5, l2) {
  193. if (this._whereClauseFunction !== null)
  194. return n9 === null && s6 === "" && i3 === null ? this._manualStat(e4, t4, a5, l2) : { calculated: false };
  195. let h4 = this._whereclause;
  196. n9 !== null && this._whereclause !== null && (h4 = o(this._whereclause, n9));
  197. const u2 = await this._parent._stat(e4, t4, s6, i3, h4, a5, l2);
  198. return u2.calculated === false ? n9 === null && s6 === "" && i3 === null ? this._manualStat(e4, t4, a5, l2) : { calculated: false } : u2;
  199. }
  200. async _canDoAggregates(e4, t4, s6, i3, n9) {
  201. return this._whereClauseFunction === null && (n9 !== null ? this._whereclause !== null && (n9 = o(this._whereclause, n9)) : n9 = this._whereclause, this._parent !== null && this._parent._canDoAggregates(e4, t4, s6, i3, n9));
  202. }
  203. async _getAggregatePagesDataSourceDefinition(e4, t4, s6, i3, n9, a5, l2) {
  204. if (this._parent === null)
  205. throw new Error("Should never be called");
  206. return n9 !== null ? this._whereclause !== null && (n9 = o(this._whereclause, n9)) : n9 = this._whereclause, this._parent._getAggregatePagesDataSourceDefinition(e4, t4, s6, i3, n9, a5, l2);
  207. }
  208. static registerAction() {
  209. k3._featuresetFunctions.filter = function(e4) {
  210. if (typeof e4 == "function")
  211. return new h3({ parentfeatureset: this, whereclause: e4 });
  212. let t4 = null;
  213. return e4 instanceof m && (t4 = e4), new h3({ parentfeatureset: this, whereclause: t4 });
  214. };
  215. }
  216. };
  217. // node_modules/@arcgis/core/arcade/featureset/actions/Adapted.js
  218. var N = class {
  219. constructor(e4) {
  220. this.field = e4, this.sqlRewritable = false;
  221. }
  222. postInitialization(e4, t4) {
  223. }
  224. };
  225. var S2 = class extends N {
  226. constructor(e4) {
  227. super(e4), this.sqlRewritable = true;
  228. }
  229. extractValue(e4) {
  230. return e4.attributes[this.field.name];
  231. }
  232. rewriteSql(e4) {
  233. return { rewritten: this.sqlRewritable, where: e4 };
  234. }
  235. };
  236. var w = class extends N {
  237. constructor(e4, t4, r) {
  238. super(n(e4)), this.originalField = e4, this.sqlRewritable = true, this.field.name = t4, this.field.alias = r;
  239. }
  240. rewriteSql(e4, t4) {
  241. return { rewritten: this.sqlRewritable, where: s3(e4, this.field.name, this.originalField.name, t4.getFieldsIndex()) };
  242. }
  243. extractValue(e4) {
  244. return e4.attributes[this.originalField.name];
  245. }
  246. };
  247. var m3 = class extends N {
  248. constructor(e4, t4, r) {
  249. super(e4), this.codefield = t4, this.lkp = r, this.reverseLkp = {};
  250. for (const s6 in r)
  251. this.reverseLkp[r[s6]] = s6;
  252. this.sqlRewritable = true;
  253. }
  254. rewriteSql(e4, t4) {
  255. const r = this.evaluateNodeToWhereClause(e4.parseTree, t.Standardised, this.field.name, this.codefield instanceof m ? n5(this.codefield, t.Standardised) : this.codefield, e4.parameters);
  256. return r.includes(m3.BADNESS) ? { rewritten: false, where: e4 } : { rewritten: this.sqlRewritable, where: m.create(r, t4._parent.getFieldsIndex()) };
  257. }
  258. evaluateNodeToWhereClause(e4, t4, r = null, s6 = null, a5) {
  259. let i3, l2, n9, o2;
  260. switch (e4.type) {
  261. case "interval":
  262. return T(this.evaluateNodeToWhereClause(e4.value, t4, r, s6, a5), e4.qualifier, e4.op);
  263. case "case-expression": {
  264. let s7 = " CASE ";
  265. e4.format === "simple" && (s7 += this.evaluateNodeToWhereClause(e4.operand, t4, r, m3.BADNESS, a5));
  266. for (let i4 = 0; i4 < e4.clauses.length; i4++)
  267. s7 += " WHEN " + this.evaluateNodeToWhereClause(e4.clauses[i4].operand, t4, r, m3.BADNESS, a5) + " THEN " + this.evaluateNodeToWhereClause(e4.clauses[i4].value, t4, r, m3.BADNESS, a5);
  268. return e4.else !== null && (s7 += " ELSE " + this.evaluateNodeToWhereClause(e4.else, t4, r, m3.BADNESS, a5)), s7 += " END ", s7;
  269. }
  270. case "parameter": {
  271. const r2 = a5[e4.value.toLowerCase()];
  272. if (typeof r2 == "string") {
  273. return "'" + a5[e4.value.toLowerCase()].toString().replace(/'/g, "''") + "'";
  274. }
  275. if (r2 instanceof Date)
  276. return i2(r2, t4);
  277. if (r2 instanceof Array) {
  278. const e5 = [];
  279. for (let s7 = 0; s7 < r2.length; s7++)
  280. typeof r2[s7] == "string" ? e5.push("'" + r2[s7].toString().replace(/'/g, "''") + "'") : r2[s7] instanceof Date ? e5.push(i2(r2[s7], t4)) : e5.push(r2[s7].toString());
  281. return e5;
  282. }
  283. return r2.toString();
  284. }
  285. case "expression-list":
  286. l2 = [];
  287. for (const i4 of e4.value)
  288. l2.push(this.evaluateNodeToWhereClause(i4, t4, r, s6, a5));
  289. return l2;
  290. case "unary-expression":
  291. return " ( NOT " + this.evaluateNodeToWhereClause(e4.expr, t4, r, m3.BADNESS, a5) + " ) ";
  292. case "binary-expression":
  293. switch (e4.operator) {
  294. case "AND":
  295. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " AND " + this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5) + ") ";
  296. case "OR":
  297. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " OR " + this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5) + ") ";
  298. case "IS":
  299. if (e4.right.type !== "null")
  300. throw new Error("Unsupported RHS for IS");
  301. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IS NULL )";
  302. case "ISNOT":
  303. if (e4.right.type !== "null")
  304. throw new Error("Unsupported RHS for IS");
  305. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IS NOT NULL )";
  306. case "IN":
  307. if (i3 = [], e4.right.type === "expression-list") {
  308. if (e4.left.type === "column-reference" && e4.left.column.toUpperCase() === this.field.name.toUpperCase()) {
  309. const i4 = [];
  310. let l3 = true;
  311. for (const t5 of e4.right.value) {
  312. if (t5.type !== "string") {
  313. l3 = false;
  314. break;
  315. }
  316. if (this.lkp[t5.value] === void 0) {
  317. l3 = false;
  318. break;
  319. }
  320. i4.push(this.lkp[t5.value].toString());
  321. }
  322. if (l3)
  323. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IN (" + i4.join(",") + ")) ";
  324. }
  325. return i3 = this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5), " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IN (" + i3.join(",") + ")) ";
  326. }
  327. return o2 = this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5), o2 instanceof Array ? " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IN (" + o2.join(",") + ")) " : " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " IN (" + o2 + ")) ";
  328. case "NOT IN":
  329. if (i3 = [], e4.right.type === "expression-list") {
  330. if (e4.left.type === "column-reference" && e4.left.column.toUpperCase() === this.field.name.toUpperCase()) {
  331. const i4 = [];
  332. let l3 = true;
  333. for (const t5 of e4.right.value) {
  334. if (t5.type !== "string") {
  335. l3 = false;
  336. break;
  337. }
  338. if (this.lkp[t5.value] === void 0) {
  339. l3 = false;
  340. break;
  341. }
  342. i4.push(this.lkp[t5.value].toString());
  343. }
  344. if (l3)
  345. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " NOT IN (" + i4.join(",") + ")) ";
  346. }
  347. return i3 = this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5), " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " NOT IN (" + i3.join(",") + ")) ";
  348. }
  349. return o2 = this.evaluateNodeToWhereClause(e4.right, t4, r, s6, a5), o2 instanceof Array ? " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " NOT IN (" + o2.join(",") + ")) " : " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, s6, a5) + " NOT IN (" + o2 + ")) ";
  350. case "BETWEEN":
  351. return n9 = this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5), " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " BETWEEN " + n9[0] + " AND " + n9[1] + " ) ";
  352. case "NOTBETWEEN":
  353. return n9 = this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5), " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " NOT BETWEEN " + n9[0] + " AND " + n9[1] + " ) ";
  354. case "LIKE":
  355. return e4.escape !== "" ? " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " LIKE " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + " ESCAPE '" + e4.escape + "') " : " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " LIKE " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + ") ";
  356. case "NOT LIKE":
  357. return e4.escape !== "" ? " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " NOT LIKE " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + " ESCAPE '" + e4.escape + "') " : " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " NOT LIKE " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + ") ";
  358. case "<>":
  359. case "=":
  360. if (e4.left.type === "column-reference" && e4.right.type === "string") {
  361. if (e4.left.column.toUpperCase() === this.field.name.toUpperCase() && this.lkp[e4.right.value.toString()] !== void 0)
  362. return " (" + s6 + " " + e4.operator + " " + this.lkp[e4.right.value.toString()].toString() + ") ";
  363. } else if (e4.right.type === "column-reference" && e4.left.type === "string" && e4.right.column.toUpperCase() === this.field.name.toUpperCase())
  364. return " (" + this.lkp[e4.right.value.toString()].toString() + " " + e4.operator + " " + s6 + ") ";
  365. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " " + e4.operator + " " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + ") ";
  366. case "<":
  367. case ">":
  368. case ">=":
  369. case "<=":
  370. case "*":
  371. case "-":
  372. case "+":
  373. case "/":
  374. return " (" + this.evaluateNodeToWhereClause(e4.left, t4, r, m3.BADNESS, a5) + " " + e4.operator + " " + this.evaluateNodeToWhereClause(e4.right, t4, r, m3.BADNESS, a5) + ") ";
  375. }
  376. case "null":
  377. return "null";
  378. case "boolean":
  379. return e4.value === true ? "1" : "0";
  380. case "string":
  381. return "'" + e4.value.toString().replace(/'/g, "''") + "'";
  382. case "timestamp":
  383. case "date":
  384. return i2(e4.value, t4);
  385. case "number":
  386. return e4.value.toString();
  387. case "current-time":
  388. return u(e4.mode === "date", t4);
  389. case "column-reference":
  390. return r && r.toLowerCase() === e4.column.toLowerCase() ? "(" + s6 + ")" : e4.column;
  391. case "function": {
  392. const s7 = this.evaluateNodeToWhereClause(e4.args, t4, r, m3.BADNESS, a5);
  393. return l(e4.name, s7, t4);
  394. }
  395. }
  396. throw new Error("Unsupported sql syntax " + e4.type);
  397. }
  398. extractValue(e4) {
  399. return this.codefield instanceof m ? this.reverseLkp[this.codefield.calculateValueCompiled(e4)] : this.reverseLkp[e4.attributes[this.codefield]];
  400. }
  401. };
  402. m3.BADNESS = "_!!!_BAD_LKP_!!!!";
  403. var v = class extends N {
  404. constructor(e4, t4) {
  405. super(e4), this.sql = t4;
  406. }
  407. rewriteSql(e4, t4) {
  408. return { rewritten: true, where: s3(e4, this.field.name, n5(this.sql, t.Standardised), t4.getFieldsIndex()) };
  409. }
  410. extractValue(e4) {
  411. return this.sql.calculateValueCompiled(e4);
  412. }
  413. };
  414. var C = class extends k3 {
  415. constructor(e4) {
  416. super(e4), this._calcFunc = null, this.declaredClass = "esri.arcade.featureset.actions.Adapted", this.adaptedFields = null, this._extraFilter = null, this._extraFilter = e4.extraFilter, this._parent = e4.parentfeatureset, this._maxProcessing = 30, this.adaptedFields = e4.adaptedFields;
  417. }
  418. static findField(e4, t4) {
  419. for (const r of e4)
  420. if (r.name.toLowerCase() === t4.toString().toLowerCase())
  421. return r;
  422. return null;
  423. }
  424. _initialiseFeatureSet() {
  425. this._parent !== null ? (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 k2({ wkid: 4326 }), this.objectIdField = "", this.globalIdField = "", this.geometryType = S.point, this.typeIdField = "", this.types = null), this.fields = [];
  426. for (const e4 of this.adaptedFields)
  427. e4.postInitialization(this, this._parent), this.fields.push(e4.field);
  428. }
  429. async _getSet(e4) {
  430. if (this._wset === null) {
  431. await this._ensureLoaded();
  432. let t4 = null;
  433. return t4 = this._extraFilter ? await this._getFilteredSet("", null, null, null, e4) : await this._parent._getSet(e4), this._checkCancelled(e4), this._wset = new t2(t4._candidates.slice(0), t4._known.slice(0), t4._ordered, this._clonePageDefinition(t4.pagesDefinition)), this._wset;
  434. }
  435. return this._wset;
  436. }
  437. _isInFeatureSet(e4) {
  438. return this._parent._isInFeatureSet(e4);
  439. }
  440. async _getFeatures(r, a5, i3, l2) {
  441. const n9 = [];
  442. a5 !== -1 && this._featureCache[a5] === void 0 && n9.push(a5);
  443. const o2 = this._maxQueryRate();
  444. if (this._checkIfNeedToExpandKnownPage(r, o2) === true)
  445. return await this._expandPagedSet(r, o2, 0, 0, l2), this._getFeatures(r, a5, i3, l2);
  446. let h4 = 0;
  447. for (let e4 = r._lastFetchedIndex; e4 < r._known.length && (h4++, h4 <= i3 && (r._lastFetchedIndex += 1), !(this._featureCache[r._known[e4]] === void 0 && (r._known[e4] !== a5 && n9.push(r._known[e4]), n9.length >= o2))); e4++)
  448. ;
  449. if (n9.length === 0)
  450. return "success";
  451. r = new t2([], n9, r._ordered, null);
  452. const u2 = Math.min(n9.length, i3);
  453. await this._parent._getFeatures(r, -1, u2, l2), this._checkCancelled(l2);
  454. const c3 = [];
  455. for (let e4 = 0; e4 < u2; e4++) {
  456. const t4 = this._parent._featureFromCache(n9[e4]);
  457. t4 !== void 0 && c3.push({ geometry: t4.geometry, attributes: t4.attributes, id: n9[e4] });
  458. }
  459. for (const s6 of c3) {
  460. const r2 = [];
  461. for (const e4 of this.adaptedFields)
  462. r2[e4.field.name] = e4.extractValue(s6);
  463. this._featureCache[s6.id] = new g({ attributes: r2, geometry: c(s6.geometry) });
  464. }
  465. return "success";
  466. }
  467. async _fetchAndRefineFeatures() {
  468. throw new Error("Fetch and Refine should not be called in this featureset");
  469. }
  470. async _getFilteredSet(e4, t4, r, a5, i3) {
  471. let l2 = false;
  472. const n9 = this._reformulateWithoutAdaptions(r);
  473. l2 = n9.cannot, r = n9.where;
  474. let o2 = false;
  475. if (a5 !== null) {
  476. o2 = true;
  477. const e5 = [];
  478. for (const t5 of this.adaptedFields)
  479. if (!(t5 instanceof S2) && a5.scanForField(t5.field.name) === true) {
  480. if (!(t5 instanceof w)) {
  481. a5 = null, o2 = false;
  482. break;
  483. }
  484. e5.push({ field: t5.field.name, newfield: t5.originalField.name });
  485. }
  486. a5 && e5.length > 0 && (a5 = a5.replaceFields(e5));
  487. }
  488. r !== null ? this._extraFilter !== null && (r = o(this._extraFilter, r)) : r = this._extraFilter, await this._ensureLoaded();
  489. const h4 = await this._parent._getFilteredSet(e4, t4, r, a5, i3);
  490. let u2;
  491. return this._checkCancelled(i3), u2 = l2 === true ? new t2(h4._candidates.slice(0).concat(h4._known.slice(0)), [], o2 === true && h4._ordered, this._clonePageDefinition(h4.pagesDefinition)) : new t2(h4._candidates.slice(0), h4._known.slice(0), o2 === true && h4._ordered, this._clonePageDefinition(h4.pagesDefinition)), u2;
  492. }
  493. _reformulateWithoutAdaptions(e4) {
  494. const t4 = { cannot: false, where: e4 };
  495. if (e4 !== null) {
  496. for (const r of this.adaptedFields)
  497. if (h(e4, r.field.name) === true) {
  498. const s6 = r.rewriteSql(e4, this);
  499. if (s6.rewritten !== true) {
  500. t4.cannot = true, t4.where = null;
  501. break;
  502. }
  503. t4.where = s6.where;
  504. }
  505. }
  506. return t4;
  507. }
  508. async _stat(e4, t4, r, s6, a5, i3, l2) {
  509. let n9 = false, o2 = this._reformulateWithoutAdaptions(t4);
  510. if (n9 = o2.cannot, t4 = o2.where, o2 = this._reformulateWithoutAdaptions(a5), n9 = n9 || o2.cannot, (a5 = o2.where) !== null ? this._extraFilter !== null && (a5 = o(this._extraFilter, a5)) : a5 = this._extraFilter, n9 === true)
  511. return a5 === null && r === "" && s6 === null ? this._manualStat(e4, t4, i3, l2) : { calculated: false };
  512. const h4 = await this._parent._stat(e4, t4, r, s6, a5, i3, l2);
  513. return h4.calculated === false ? a5 === null && r === "" && s6 === null ? this._manualStat(e4, t4, i3, l2) : { calculated: false } : h4;
  514. }
  515. async _canDoAggregates(e4, t4, r, s6, a5) {
  516. if (this._parent === null)
  517. return false;
  518. for (let n9 = 0; n9 < e4.length; n9++)
  519. for (const t5 of this.adaptedFields)
  520. if (e4[n9].toLowerCase() === t5.field.name.toLowerCase() && !(t5 instanceof S2))
  521. return false;
  522. const i3 = [];
  523. for (let n9 = 0; n9 < t4.length; n9++) {
  524. const e5 = t4[n9];
  525. if (e5.workingexpr !== null) {
  526. const t5 = this._reformulateWithoutAdaptions(e5.workingexpr);
  527. if (t5.cannot)
  528. return false;
  529. const r2 = e5.clone();
  530. r2.workingexpr = t5.where, i3.push(r2);
  531. } else
  532. i3.push(e5);
  533. }
  534. const l2 = this._reformulateWithoutAdaptions(a5);
  535. return !l2.cannot && ((a5 = l2.where) !== null ? this._extraFilter !== null && (a5 = o(this._extraFilter, a5)) : a5 = this._extraFilter, this._parent._canDoAggregates(e4, i3, r, s6, a5));
  536. }
  537. async _getAggregatePagesDataSourceDefinition(e4, t4, r, s6, a5, i3, l2) {
  538. if (this._parent === null)
  539. throw new Error("Should never be called");
  540. const n9 = [];
  541. for (let h4 = 0; h4 < t4.length; h4++) {
  542. const e5 = t4[h4];
  543. if (e5.workingexpr !== null) {
  544. const t5 = this._reformulateWithoutAdaptions(e5.workingexpr);
  545. if (t5.cannot)
  546. throw new Error("Should never be called");
  547. const r2 = e5.clone();
  548. r2.workingexpr = t5.where, n9.push(r2);
  549. } else
  550. n9.push(e5);
  551. }
  552. const o2 = this._reformulateWithoutAdaptions(a5);
  553. if (o2.cannot)
  554. throw new Error("Should never be called");
  555. return (a5 = o2.where) !== null ? this._extraFilter !== null && (a5 = o(this._extraFilter, a5)) : a5 = this._extraFilter, this._parent._getAggregatePagesDataSourceDefinition(e4, n9, r, s6, a5, i3, l2);
  556. }
  557. };
  558. // node_modules/@arcgis/core/arcade/featureset/support/OrderbyClause.js
  559. function t3(t4, e4) {
  560. return t4 === e4 ? 0 : t4 === null ? -1 : e4 === null ? 1 : t4 < e4 ? -1 : 1;
  561. }
  562. var e3 = class {
  563. constructor(t4) {
  564. const e4 = t4.split(",");
  565. this._fields = [], this._directions = [];
  566. for (let s6 = 0; s6 < e4.length; s6++) {
  567. const t5 = e4[s6].match(/\S+/g);
  568. this._fields.push(t5[0]), t5.length === 2 ? t5[1].toLowerCase() === "asc" ? this._directions.push(1) : this._directions.push(0) : this._directions.push(1);
  569. }
  570. }
  571. constructClause() {
  572. let t4 = "";
  573. for (let e4 = 0; e4 < this._fields.length; e4++)
  574. e4 !== 0 && (t4 += ","), t4 += this._fields[e4], this._directions[e4] === 1 ? t4 += " ASC" : t4 += " DESC";
  575. return t4;
  576. }
  577. order(e4) {
  578. e4.sort((e5, s6) => {
  579. for (let i3 = 0; i3 < this._fields.length; i3++) {
  580. const r = this.featureValue(e5.feature, this._fields[i3], i3), l2 = this.featureValue(s6.feature, this._fields[i3], i3);
  581. let o2 = 0;
  582. if (o2 = this._directions[i3] === 1 ? t3(r, l2) : -1 * t3(r, l2), o2 !== 0)
  583. return o2;
  584. }
  585. return 0;
  586. });
  587. }
  588. scanForField(t4) {
  589. for (let e4 = 0; e4 < this._fields.length; e4++)
  590. if (this._fields[e4].toLowerCase().trim() === t4.toLowerCase().trim())
  591. return true;
  592. return false;
  593. }
  594. replaceFields(t4) {
  595. let s6 = "";
  596. for (let e4 = 0; e4 < this._fields.length; e4++) {
  597. e4 !== 0 && (s6 += ",");
  598. let i3 = this._fields[e4];
  599. for (const e5 of t4)
  600. if (i3.toLowerCase() === e5.field.toLowerCase()) {
  601. i3 = e5.newfield;
  602. break;
  603. }
  604. s6 += i3, this._directions[e4] === 1 ? s6 += " ASC" : s6 += " DESC";
  605. }
  606. return new e3(s6);
  607. }
  608. featureValue(t4, e4, s6) {
  609. const i3 = t4.attributes[e4];
  610. if (i3 !== void 0)
  611. return i3;
  612. for (const r in t4.attributes)
  613. if (e4.toLowerCase() === r.toLowerCase())
  614. return this._fields[s6] = r, t4.attributes[r];
  615. return null;
  616. }
  617. };
  618. // node_modules/@arcgis/core/arcade/featureset/actions/OrderBy.js
  619. var s4 = class extends k3 {
  620. constructor(e4) {
  621. super(e4), this._orderbyclause = null, this.declaredClass = "esri.arcade.featureset.actions.OrderBy", this._maxProcessing = 100, this._orderbyclause = e4.orderbyclause, this._parent = e4.parentfeatureset;
  622. }
  623. async _getSet(e4) {
  624. if (this._wset === null) {
  625. await this._ensureLoaded();
  626. const t4 = await this._getFilteredSet("", null, null, this._orderbyclause, e4);
  627. return this._checkCancelled(e4), this._wset = t4, this._wset;
  628. }
  629. return this._wset;
  630. }
  631. async manualOrderSet(e4, t4) {
  632. const r = await this.getIdColumnDictionary(e4, [], -1, t4);
  633. this._orderbyclause.order(r);
  634. const s6 = new t2([], [], true, null);
  635. for (let n9 = 0; n9 < r.length; n9++)
  636. s6._known.push(r[n9].id);
  637. return s6;
  638. }
  639. async getIdColumnDictionary(t4, n9, r, s6) {
  640. if (r < t4._known.length - 1) {
  641. const i3 = this._maxQueryRate();
  642. if (t4._known[r + 1] === "GETPAGES")
  643. return await Te(this._parent._expandPagedSet(t4, i3, 0, 0, s6)), this.getIdColumnDictionary(t4, n9, r, s6);
  644. let a5 = r + 1;
  645. const o2 = [];
  646. for (; a5 < t4._known.length && t4._known[a5] !== "GETPAGES"; )
  647. o2.push(t4._known[a5]), a5++;
  648. r += o2.length;
  649. const c3 = await Te(this._parent._getFeatureBatch(o2, s6));
  650. this._checkCancelled(s6);
  651. for (const e4 of c3)
  652. n9.push({ id: e4.attributes[this.objectIdField], feature: e4 });
  653. return this.getIdColumnDictionary(t4, n9, r, s6);
  654. }
  655. return t4._candidates.length > 0 ? (await Te(this._refineSetBlock(t4, this._maxProcessingRate(), s6)), this._checkCancelled(s6), this.getIdColumnDictionary(t4, n9, r, s6)) : n9;
  656. }
  657. _isInFeatureSet(e4) {
  658. return this._parent._isInFeatureSet(e4);
  659. }
  660. _getFeatures(e4, t4, n9, r) {
  661. return this._parent._getFeatures(e4, t4, n9, r);
  662. }
  663. _featureFromCache(e4) {
  664. if (this._featureCache[e4] === void 0) {
  665. const t4 = this._parent._featureFromCache(e4);
  666. if (t4 === void 0)
  667. return;
  668. return t4 === null ? null : (this._featureCache[e4] = t4, t4);
  669. }
  670. return this._featureCache[e4];
  671. }
  672. async _fetchAndRefineFeatures() {
  673. throw new Error("Fetch and Refine should not be called in this featureset");
  674. }
  675. async _getFilteredSet(e4, t4, r, s6, i3) {
  676. await this._ensureLoaded();
  677. const a5 = await this._parent._getFilteredSet(e4, t4, r, s6 === null ? this._orderbyclause : s6, i3);
  678. this._checkCancelled(i3);
  679. const o2 = new t2(a5._candidates.slice(0), a5._known.slice(0), a5._ordered, this._clonePageDefinition(a5.pagesDefinition));
  680. let c3 = true;
  681. if (a5._candidates.length > 0 && (c3 = false), o2._ordered === false) {
  682. let e5 = await this.manualOrderSet(o2, i3);
  683. return c3 === false && (t4 === null && r === null || (e5 = new t2(e5._candidates.slice(0).concat(e5._known.slice(0)), [], e5._ordered, this._clonePageDefinition(e5.pagesDefinition)))), e5;
  684. }
  685. return o2;
  686. }
  687. static registerAction() {
  688. k3._featuresetFunctions.orderBy = function(e4) {
  689. return e4 === "" ? this : new s4({ parentfeatureset: this, orderbyclause: new e3(e4) });
  690. };
  691. }
  692. };
  693. // node_modules/@arcgis/core/arcade/featureset/support/StatsField.js
  694. function a4(a5) {
  695. if (a5.parseTree.type === "function") {
  696. if (a5.parseTree.args.value.length === 0)
  697. return { name: a5.parseTree.name, expr: null };
  698. if (a5.parseTree.args.value.length > 1)
  699. throw new Error("Statistic does not have 1 or 0 Parameters");
  700. const n9 = m.create(a3(a5.parseTree.args.value[0], t.Standardised, a5.parameters), a5.fieldsIndex);
  701. return { name: a5.parseTree.name, expr: n9 };
  702. }
  703. return null;
  704. }
  705. var n7 = class {
  706. clone() {
  707. const e4 = new n7();
  708. return e4.field = this.field, e4.tofieldname = this.tofieldname, e4.typeofstat = this.typeofstat, e4.workingexpr = this.workingexpr, e4;
  709. }
  710. static parseStatField(e4, r, i3) {
  711. const s6 = new n7();
  712. s6.field = e4;
  713. const o2 = m.create(r, i3), l2 = a4(o2);
  714. if (l2 === null)
  715. throw new Error("Invalid Statistic Function");
  716. const p2 = l2.name.toUpperCase().trim();
  717. if (p2 === "MIN") {
  718. if (s6.typeofstat = "MIN", s6.workingexpr = l2.expr, o2 === null)
  719. throw new Error("Invalid Statistic Function Parameters");
  720. } else if (p2 === "MAX") {
  721. if (s6.typeofstat = "MAX", s6.workingexpr = l2.expr, o2 === null)
  722. throw new Error("Invalid Statistic Function Parameters");
  723. } else if (p2 === "COUNT")
  724. s6.typeofstat = "COUNT", s6.workingexpr = l2.expr;
  725. else if (p2 === "STDEV") {
  726. if (s6.typeofstat = "STDDEV", s6.workingexpr = l2.expr, o2 === null)
  727. throw new Error("Invalid Statistic Function Parameters");
  728. } else if (p2 === "SUM") {
  729. if (s6.typeofstat = "SUM", s6.workingexpr = l2.expr, o2 === null)
  730. throw new Error("Invalid Statistic Function Parameters");
  731. } else if (p2 === "MEAN") {
  732. if (s6.typeofstat = "AVG", s6.workingexpr = l2.expr, o2 === null)
  733. throw new Error("Invalid Statistic Function Parameters");
  734. } else if (p2 === "AVG") {
  735. if (s6.typeofstat = "AVG", s6.workingexpr = l2.expr, o2 === null)
  736. throw new Error("Invalid Statistic Function Parameters");
  737. } else {
  738. if (p2 !== "VAR")
  739. throw new Error("Invalid Statistic Function");
  740. if (s6.typeofstat = "VAR", s6.workingexpr = l2.expr, o2 === null)
  741. throw new Error("Invalid Statistic Function Parameters");
  742. }
  743. return s6;
  744. }
  745. toStatisticsName() {
  746. switch (this.typeofstat.toUpperCase()) {
  747. case "MIN":
  748. return "min";
  749. case "MAX":
  750. return "max";
  751. case "SUM":
  752. return "sum";
  753. case "COUNT":
  754. default:
  755. return "count";
  756. case "VAR":
  757. return "var";
  758. case "STDDEV":
  759. return "stddev";
  760. case "AVG":
  761. return "avg";
  762. }
  763. }
  764. };
  765. // node_modules/@arcgis/core/arcade/featureset/actions/GroupBy.js
  766. function D2(e4) {
  767. if (!e4)
  768. return "COUNT";
  769. switch (e4.toLowerCase()) {
  770. case "max":
  771. return "MAX";
  772. case "var":
  773. case "variance":
  774. return "VAR";
  775. case "avg":
  776. case "average":
  777. case "mean":
  778. return "AVG";
  779. case "min":
  780. return "MIN";
  781. case "sum":
  782. return "SUM";
  783. case "stdev":
  784. case "stddev":
  785. return "STDDEV";
  786. case "count":
  787. return "COUNT";
  788. }
  789. return "COUNT";
  790. }
  791. var A = class extends k3 {
  792. constructor(e4) {
  793. super(e4), this._decodedStatsfield = [], this._decodedGroupbyfield = [], this._candosimplegroupby = true, 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 = e4.parentfeatureset, this._config = e4;
  794. }
  795. isTable() {
  796. return true;
  797. }
  798. async _getSet(e4) {
  799. if (this._wset === null) {
  800. const t4 = await this._getFilteredSet("", null, null, null, e4);
  801. return this._wset = t4, this._wset;
  802. }
  803. return this._wset;
  804. }
  805. _isInFeatureSet() {
  806. return i.InFeatureSet;
  807. }
  808. _nextUniqueName(e4) {
  809. for (; e4["T" + this._uniqueIds.toString()] === 1; )
  810. this._uniqueIds++;
  811. const t4 = "T" + this._uniqueIds.toString();
  812. return e4[t4] = 1, t4;
  813. }
  814. _convertToEsriFieldType(e4) {
  815. return e4;
  816. }
  817. _initialiseFeatureSet() {
  818. const e4 = {};
  819. let t4 = false, n9 = 1;
  820. const r = this._parent ? this._parent.getFieldsIndex() : new d3([]);
  821. for (this.objectIdField = "ROW__ID", this.globalIdField = ""; t4 === false; ) {
  822. let e5 = false;
  823. for (let t5 = 0; t5 < this._config.groupbyfields.length; t5++)
  824. if (this._config.groupbyfields[t5].name.toLowerCase() === this.objectIdField.toLowerCase()) {
  825. e5 = true;
  826. break;
  827. }
  828. if (e5 === false) {
  829. for (let t5 = 0; t5 < this._config.statsfields.length; t5++)
  830. if (this._config.statsfields[t5].name.toLowerCase() === this.objectIdField.toLowerCase()) {
  831. e5 = true;
  832. break;
  833. }
  834. }
  835. e5 === false ? t4 = true : (this.objectIdField = "ROW__ID" + n9.toString(), n9++);
  836. }
  837. for (const i3 of this._config.statsfields) {
  838. const e5 = new n7();
  839. e5.field = i3.name, e5.tofieldname = i3.name, e5.workingexpr = i3.expression instanceof m ? i3.expression : m.create(i3.expression, r), e5.typeofstat = D2(i3.statistic), this._decodedStatsfield.push(e5);
  840. }
  841. this._decodedGroupbyfield = [];
  842. for (const i3 of this._config.groupbyfields) {
  843. const e5 = { name: i3.name, singlefield: null, tofieldname: i3.name, expression: i3.expression instanceof m ? i3.expression : m.create(i3.expression, r) };
  844. this._decodedGroupbyfield.push(e5);
  845. }
  846. if (this._parent !== null) {
  847. this.geometryType = this._parent.geometryType, this.spatialReference = this._parent.spatialReference, this.hasM = this._parent.hasM, this.hasZ = this._parent.hasZ, this.typeIdField = "";
  848. for (const t5 of this._parent.fields)
  849. e4[t5.name.toUpperCase()] = 1;
  850. this.types = null;
  851. } else
  852. this.geometryType = S.point, this.typeIdField = "", this.types = null, this.spatialReference = new k2({ wkid: 4326 });
  853. this.fields = [];
  854. const a5 = new n7();
  855. a5.field = this._nextUniqueName(e4), a5.tofieldname = this.objectIdField, a5.workingexpr = m.create(this._parent.objectIdField, this._parent.getFieldsIndex()), a5.typeofstat = "MIN", this._decodedStatsfield.push(a5);
  856. for (const s6 of this._decodedGroupbyfield) {
  857. const t5 = new y();
  858. if (s6.name = this._nextUniqueName(e4), t5.name = s6.tofieldname, t5.alias = t5.name, E(s6.expression)) {
  859. const e5 = this._parent.getField(n5(s6.expression, t.Standardised));
  860. if (!e5)
  861. throw new Error("Field is not present for Aggregation");
  862. s6.name = e5.name, s6.singlefield = e5.name, this.phsyicalgroupbyfields.push(e5.name), t5.type = e5.type;
  863. } else {
  864. t5.type = this._convertToEsriFieldType(f(s6.expression, this._parent.fields));
  865. const e5 = new y();
  866. e5.name = s6.name, e5.alias = e5.name, this.phsyicalgroupbyfields.push(s6.name), this._adaptedFields.push(new v(e5, s6.expression)), this._candosimplegroupby = false;
  867. }
  868. this.fields.push(t5);
  869. }
  870. if (this._adaptedFields.length > 0)
  871. for (const i3 of this._parent.fields)
  872. this._adaptedFields.push(new S2(i3));
  873. for (let i3 = 0; i3 < this._decodedStatsfield.length; i3++) {
  874. const t5 = new y();
  875. let s6 = null;
  876. const n10 = this._decodedStatsfield[i3];
  877. n10.field = this._nextUniqueName(e4), n10.tofieldname === this.objectIdField && (this._internalObjectIdField = n10.field), t5.name = n10.tofieldname, t5.alias = t5.name;
  878. const r2 = n10.workingexpr !== null && E(n10.workingexpr) ? n5(n10.workingexpr, t.Standardised) : "";
  879. switch (this._decodedStatsfield[i3].typeofstat) {
  880. case "SUM":
  881. if (r2 !== "") {
  882. if (s6 = this._parent.getField(r2), !s6)
  883. throw new Error("Field is not present for Aggregation");
  884. t5.type = s6.type;
  885. } else
  886. t5.type = "double";
  887. break;
  888. case "MIN":
  889. case "MAX":
  890. if (r2 !== "") {
  891. if (s6 = this._parent.getField(r2), !s6)
  892. throw new Error("Field is not present for Aggregation");
  893. t5.type = s6.type;
  894. } else
  895. t5.type = "double";
  896. break;
  897. case "COUNT":
  898. t5.type = "integer";
  899. break;
  900. case "STDDEV":
  901. case "VAR":
  902. case "AVG":
  903. if (r2 !== "" && (s6 = this._parent.getField(r2), !s6))
  904. throw new Error("Field is not present for Aggregation");
  905. t5.type = "double";
  906. }
  907. this.fields.push(t5);
  908. }
  909. }
  910. async _canDoAggregates() {
  911. return false;
  912. }
  913. async _getFeatures(e4, t4, i3, s6) {
  914. t4 !== -1 && this._featureCache[t4];
  915. const n9 = this._maxQuery;
  916. return this._checkIfNeedToExpandKnownPage(e4, n9) === true ? (await this._expandPagedSet(e4, n9, 0, 0, s6), this._getFeatures(e4, t4, i3, s6)) : "success";
  917. }
  918. async _getFilteredSet(e4, t4, i3, s6, l2) {
  919. if (e4 !== "")
  920. return new t2([], [], true, null);
  921. let u2 = null;
  922. const f3 = { ordered: false, nowhereclause: false };
  923. if (await this._ensureLoaded(), i3 !== null) {
  924. for (let n9 = 0; n9 < this._decodedStatsfield.length; n9++)
  925. if (h(i3, this._decodedStatsfield[n9].tofieldname) === true) {
  926. f3.nowhereclause = true, i3 = null;
  927. break;
  928. }
  929. }
  930. if (s6 !== null) {
  931. f3.ordered = true;
  932. for (let e5 = 0; e5 < this._decodedStatsfield.length; e5++)
  933. if (s6.scanForField(this._decodedStatsfield[e5].tofieldname) === true) {
  934. s6 = null, f3.ordered = false;
  935. break;
  936. }
  937. if (s6 !== null) {
  938. for (const e5 of this._decodedGroupbyfield)
  939. if (e5.singlefield === null && s6.scanForField(e5.tofieldname) === true) {
  940. s6 = null, f3.ordered = false;
  941. break;
  942. }
  943. }
  944. }
  945. if (this._candosimplegroupby !== false && await this._parent._canDoAggregates(this.phsyicalgroupbyfields, this._decodedStatsfield, "", null, null)) {
  946. let e5 = null;
  947. i3 && (e5 = this._reformulateWhereClauseWithoutGroupByFields(i3));
  948. let t5 = null;
  949. s6 && (t5 = this._reformulateOrderClauseWithoutGroupByFields(s6));
  950. const n9 = await this._parent._getAggregatePagesDataSourceDefinition(this.phsyicalgroupbyfields, this._decodedStatsfield, "", null, e5, t5, this._internalObjectIdField);
  951. return this._checkCancelled(l2), u2 = f3.nowhereclause === true ? new t2(n9._candidates.slice(0).concat(n9._known.slice(0)), [], f3.ordered === true && n9._ordered, this._clonePageDefinition(n9.pagesDefinition)) : new t2(n9._candidates.slice(0), n9._known.slice(0), f3.ordered === true && n9._ordered, this._clonePageDefinition(n9.pagesDefinition)), u2;
  952. }
  953. let c3 = this._parent;
  954. if (this._adaptedFields.length > 0 && (c3 = new C({ parentfeatureset: this._parent, adaptedFields: this._adaptedFields, extraFilter: null })), f3.nowhereclause === true)
  955. u2 = new t2(["GETPAGES"], [], false, { aggregatefeaturesetpagedefinition: true, resultOffset: 0, resultRecordCount: this._maxQuery, internal: { fullyResolved: false, workingItem: null, type: "manual", iterator: null, set: [], subfeatureset: new s4({ parentfeatureset: c3, orderbyclause: new e3(this.phsyicalgroupbyfields.join(",") + "," + this._parent.objectIdField + " ASC") }) } });
  956. else {
  957. let e5 = c3;
  958. if (i3 !== null) {
  959. let t5 = null;
  960. i3 && (t5 = this._reformulateWhereClauseWithoutGroupByFields(i3)), e5 = new h3({ parentfeatureset: e5, whereclause: t5 });
  961. }
  962. u2 = new t2(["GETPAGES"], [], false, { aggregatefeaturesetpagedefinition: true, resultOffset: 0, resultRecordCount: this._maxQuery, internal: { fullyResolved: false, workingItem: null, type: "manual", iterator: null, set: [], subfeatureset: new s4({ parentfeatureset: e5, orderbyclause: new e3(this.phsyicalgroupbyfields.join(",") + "," + this._parent.objectIdField + " ASC") }) } });
  963. }
  964. return u2;
  965. }
  966. _reformulateWhereClauseWithoutStatsFields(e4) {
  967. for (const t4 of this._decodedStatsfield)
  968. e4 = s3(e4, t4.tofieldname, n5(t4.workingexpr, t.Standardised), this._parent.getFieldsIndex());
  969. return e4;
  970. }
  971. _reformulateWhereClauseWithoutGroupByFields(e4) {
  972. for (const t4 of this._decodedGroupbyfield)
  973. t4.tofieldname !== t4.name && (e4 = s3(e4, t4.tofieldname, n5(t4.expression, t.Standardised), this._parent.getFieldsIndex()));
  974. return e4;
  975. }
  976. _reformulateOrderClauseWithoutGroupByFields(e4) {
  977. const t4 = [];
  978. for (const i3 of this._decodedGroupbyfield)
  979. i3.tofieldname !== i3.name && t4.push({ field: i3.tofieldname, newfield: i3.name });
  980. return t4.length > 0 ? e4.replaceFields(t4) : e4;
  981. }
  982. _clonePageDefinition(e4) {
  983. return e4 === null ? null : e4.aggregatefeaturesetpagedefinition === true ? { aggregatefeaturesetpagedefinition: true, resultRecordCount: e4.resultRecordCount, resultOffset: e4.resultOffset, internal: e4.internal } : this._parent._clonePageDefinition(e4);
  984. }
  985. async _refineSetBlock(e4, t4, i3) {
  986. if (this._checkIfNeedToExpandCandidatePage(e4, this._maxQuery) === true)
  987. return await this._expandPagedSet(e4, this._maxQuery, 0, 0, i3), this._refineSetBlock(e4, t4, i3);
  988. this._checkCancelled(i3);
  989. const s6 = e4._candidates.length;
  990. this._refineKnowns(e4, t4);
  991. e4._candidates.length;
  992. return e4._candidates.length, e4;
  993. }
  994. _expandPagedSet(e4, t4, i3, s6, n9) {
  995. return this._expandPagedSetFeatureSet(e4, t4, i3, s6, n9);
  996. }
  997. async _getPhysicalPage(t4, i3, s6) {
  998. if (t4.pagesDefinition.aggregatefeaturesetpagedefinition === true)
  999. return this._sequentialGetPhysicalItem(t4, t4.pagesDefinition.resultRecordCount, s6, []);
  1000. const n9 = await this._getAgregagtePhysicalPage(t4, i3, s6);
  1001. for (const r of n9) {
  1002. const t5 = { geometry: r.geometry, attributes: {} };
  1003. for (const e4 of this._decodedGroupbyfield)
  1004. t5.attributes[e4.tofieldname] = r.attributes[e4.name];
  1005. for (const e4 of this._decodedStatsfield)
  1006. t5.attributes[e4.tofieldname] = r.attributes[e4.field];
  1007. this._featureCache[t5.attributes[this.objectIdField]] = new g(t5);
  1008. }
  1009. return n9.length;
  1010. }
  1011. _sequentialGetPhysicalItem(e4, t4, i3, s6) {
  1012. return new Promise((n9, r) => {
  1013. e4.pagesDefinition.internal.iterator === null && (e4.pagesDefinition.internal.iterator = e4.pagesDefinition.internal.subfeatureset.iterator(i3)), e4.pagesDefinition.internal.fullyResolved === true || t4 === 0 ? n9(s6.length) : this._nextAggregateItem(e4, t4, i3, s6, (r2) => {
  1014. r2 === null ? n9(s6.length) : (t4 -= 1, n9(this._sequentialGetPhysicalItem(e4, t4, i3, s6)));
  1015. }, r);
  1016. });
  1017. }
  1018. _nextAggregateItem(e4, i3, s6, n9, r, a5) {
  1019. try {
  1020. Te(e4.pagesDefinition.internal.iterator.next()).then((t4) => {
  1021. if (t4 === null)
  1022. if (e4.pagesDefinition.internal.workingItem !== null) {
  1023. const t5 = this._calculateAndAppendAggregateItem(e4.pagesDefinition.internal.workingItem);
  1024. n9.push(t5), e4.pagesDefinition.internal.workingItem = null, e4.pagesDefinition.internal.set.push(t5.attributes[this.objectIdField]), e4.pagesDefinition.internal.fullyResolved = true, r(null);
  1025. } else
  1026. e4.pagesDefinition.internal.fullyResolved = true, r(null);
  1027. else {
  1028. const l2 = this._generateAggregateHash(t4);
  1029. if (e4.pagesDefinition.internal.workingItem === null)
  1030. e4.pagesDefinition.internal.workingItem = { features: [t4], id: l2 };
  1031. else {
  1032. if (l2 !== e4.pagesDefinition.internal.workingItem.id) {
  1033. const s7 = this._calculateAndAppendAggregateItem(e4.pagesDefinition.internal.workingItem);
  1034. return n9.push(s7), e4.pagesDefinition.internal.workingItem = null, e4.pagesDefinition.internal.set.push(s7.attributes[this.objectIdField]), i3 -= 1, e4.pagesDefinition.internal.workingItem = { features: [t4], id: l2 }, void r(s7);
  1035. }
  1036. e4.pagesDefinition.internal.workingItem.features.push(t4);
  1037. }
  1038. this._nextAggregateItem(e4, i3, s6, n9, r, a5);
  1039. }
  1040. }, a5);
  1041. } catch (l2) {
  1042. a5(l2);
  1043. }
  1044. }
  1045. _calculateFieldStat(e4, t4, i3) {
  1046. const s6 = [];
  1047. for (let n9 = 0; n9 < e4.features.length; n9++)
  1048. if (t4.workingexpr !== null) {
  1049. const i4 = t4.workingexpr.calculateValue(e4.features[n9]);
  1050. i4 !== null && s6.push(i4);
  1051. } else
  1052. s6.push(null);
  1053. switch (t4.typeofstat) {
  1054. case "MIN":
  1055. i3.attributes[t4.tofieldname] = f2("min", s6, -1);
  1056. break;
  1057. case "MAX":
  1058. i3.attributes[t4.tofieldname] = f2("max", s6, -1);
  1059. break;
  1060. case "SUM":
  1061. i3.attributes[t4.tofieldname] = f2("sum", s6, -1);
  1062. break;
  1063. case "COUNT":
  1064. i3.attributes[t4.tofieldname] = s6.length;
  1065. break;
  1066. case "VAR":
  1067. i3.attributes[t4.tofieldname] = f2("var", s6, -1);
  1068. break;
  1069. case "STDDEV":
  1070. i3.attributes[t4.tofieldname] = f2("stddev", s6, -1);
  1071. break;
  1072. case "AVG":
  1073. i3.attributes[t4.tofieldname] = f2("avg", s6, -1);
  1074. }
  1075. return true;
  1076. }
  1077. _calculateAndAppendAggregateItem(t4) {
  1078. const i3 = { attributes: {}, geometry: null };
  1079. for (const e4 of this._decodedGroupbyfield) {
  1080. const s7 = e4.singlefield ? t4.features[0].attributes[e4.singlefield] : e4.expression.calculateValue(t4.features[0]);
  1081. i3.attributes[e4.tofieldname] = s7;
  1082. }
  1083. for (const e4 of this._decodedStatsfield)
  1084. this._calculateFieldStat(t4, e4, i3);
  1085. const s6 = [];
  1086. for (let e4 = 0; e4 < this._decodedStatsfield.length; e4++)
  1087. s6.push(this._calculateFieldStat(t4, this._decodedStatsfield[e4], i3));
  1088. return this._featureCache[i3.attributes[this.objectIdField]] = new g({ attributes: i3.attributes, geometry: i3.geometry }), i3;
  1089. }
  1090. _generateAggregateHash(e4) {
  1091. let t4 = "";
  1092. for (const i3 of this._decodedGroupbyfield) {
  1093. const s6 = i3.singlefield ? e4.attributes[i3.singlefield] : i3.expression.calculateValue(e4);
  1094. t4 += s6 == null ? ":" : ":" + s6.toString();
  1095. }
  1096. return x2(t4, n6.String);
  1097. }
  1098. async _stat() {
  1099. return { calculated: false };
  1100. }
  1101. async getFeatureByObjectId() {
  1102. return null;
  1103. }
  1104. static registerAction() {
  1105. k3._featuresetFunctions.groupby = function(e4, t4) {
  1106. return new A({ parentfeatureset: this, groupbyfields: e4, statsfields: t4 });
  1107. };
  1108. }
  1109. };
  1110. // node_modules/@arcgis/core/arcade/featureset/actions/Top.js
  1111. var s5 = class extends k3 {
  1112. constructor(t4) {
  1113. super(t4), this._topnum = 0, this.declaredClass = "esri.arcade.featureset.actions.Top", this._countedin = 0, this._maxProcessing = 100, this._topnum = t4.topnum, this._parent = t4.parentfeatureset;
  1114. }
  1115. async _getSet(t4) {
  1116. if (this._wset === null) {
  1117. await this._ensureLoaded();
  1118. const n9 = await this._parent._getSet(t4);
  1119. return this._wset = new t2(n9._candidates.slice(0), n9._known.slice(0), false, this._clonePageDefinition(n9.pagesDefinition)), this._setKnownLength(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;
  1120. }
  1121. return this._wset;
  1122. }
  1123. _setKnownLength(t4) {
  1124. return t4._known.length > 0 && t4._known[t4._known.length - 1] === "GETPAGES" ? t4._known.length - 1 : t4._known.length;
  1125. }
  1126. _isInFeatureSet(t4) {
  1127. const e4 = this._parent._isInFeatureSet(t4);
  1128. if (e4 === i.NotInFeatureSet)
  1129. return e4;
  1130. const s6 = this._idstates[t4];
  1131. return s6 === i.InFeatureSet || s6 === i.NotInFeatureSet ? s6 : e4 === i.InFeatureSet && s6 === void 0 ? this._countedin < this._topnum ? (this._idstates[t4] = i.InFeatureSet, this._countedin++, i.InFeatureSet) : (this._idstates[t4] = i.NotInFeatureSet, i.NotInFeatureSet) : i.Unknown;
  1132. }
  1133. async _expandPagedSet(t4, e4, n9, s6, i3) {
  1134. if (this._parent === null)
  1135. throw new Error("Parent Paging not implemented");
  1136. if (e4 > this._topnum && (e4 = this._topnum), this._countedin >= this._topnum && t4.pagesDefinition.internal.set.length <= t4.pagesDefinition.resultOffset) {
  1137. let e5 = t4._known.length;
  1138. return e5 > 0 && t4._known[e5 - 1] === "GETPAGES" && (t4._known.length = e5 - 1), e5 = t4._candidates.length, e5 > 0 && t4._candidates[e5 - 1] === "GETPAGES" && (t4._candidates.length = e5 - 1), "success";
  1139. }
  1140. const a5 = await this._parent._expandPagedSet(t4, e4, n9, s6, i3);
  1141. return this._setKnownLength(t4) > this._topnum && (t4._known.length = this._topnum), this._setKnownLength(t4) >= this._topnum && (t4._candidates.length = 0), a5;
  1142. }
  1143. async _getFeatures(t4, n9, s6, i3) {
  1144. const a5 = [], o2 = this._maxQueryRate();
  1145. if (this._checkIfNeedToExpandKnownPage(t4, o2) === true)
  1146. return await this._expandPagedSet(t4, o2, 0, 0, i3), this._getFeatures(t4, n9, s6, i3);
  1147. n9 !== -1 && this._featureCache[n9] === void 0 && a5.push(n9);
  1148. let r = 0;
  1149. for (let e4 = t4._lastFetchedIndex; e4 < t4._known.length && (r++, r <= s6 && (t4._lastFetchedIndex += 1), !(this._featureCache[t4._known[e4]] === void 0 && (t4._known[e4] !== n9 && a5.push(t4._known[e4]), a5.length > o2))); e4++)
  1150. ;
  1151. if (a5.length === 0)
  1152. return "success";
  1153. const _2 = new t2([], a5, false, null), h4 = Math.min(a5.length, s6);
  1154. await this._parent._getFeatures(_2, -1, h4, i3);
  1155. for (let e4 = 0; e4 < h4; e4++) {
  1156. const t5 = this._parent._featureFromCache(a5[e4]);
  1157. t5 !== void 0 && (this._featureCache[a5[e4]] = t5);
  1158. }
  1159. return "success";
  1160. }
  1161. async _getFilteredSet(t4, n9, s6, i3, a5) {
  1162. await this._ensureLoaded();
  1163. const o2 = await this._getSet(a5);
  1164. return new t2(o2._candidates.slice(0).concat(o2._known.slice(0)), [], false, this._clonePageDefinition(o2.pagesDefinition));
  1165. }
  1166. _refineKnowns(t4, e4) {
  1167. let s6 = 0, i3 = null;
  1168. const a5 = [];
  1169. for (let o2 = 0; o2 < t4._candidates.length; o2++) {
  1170. const r = this._isInFeatureSet(t4._candidates[o2]);
  1171. if (r === i.InFeatureSet) {
  1172. if (t4._known.push(t4._candidates[o2]), s6 += 1, i3 === null ? i3 = { start: o2, end: o2 } : i3.end === o2 - 1 ? i3.end = o2 : (a5.push(i3), i3 = { start: o2, end: o2 }), t4._known.length >= this._topnum)
  1173. break;
  1174. } else if (r === i.NotInFeatureSet)
  1175. i3 === null ? i3 = { start: o2, end: o2 } : i3.end === o2 - 1 ? i3.end = o2 : (a5.push(i3), i3 = { start: o2, end: o2 }), s6 += 1;
  1176. else if (r === i.Unknown)
  1177. break;
  1178. if (s6 >= e4)
  1179. break;
  1180. }
  1181. i3 !== null && a5.push(i3);
  1182. for (let n9 = a5.length - 1; n9 >= 0; n9--)
  1183. t4._candidates.splice(a5[n9].start, a5[n9].end - a5[n9].start + 1);
  1184. this._setKnownLength(t4) > this._topnum && (t4._known = t4._known.slice(0, this._topnum)), this._setKnownLength(t4) >= this._topnum && (t4._candidates = []);
  1185. }
  1186. async _stat() {
  1187. return { calculated: false };
  1188. }
  1189. async _canDoAggregates() {
  1190. return false;
  1191. }
  1192. static registerAction() {
  1193. k3._featuresetFunctions.top = function(t4) {
  1194. return new s5({ parentfeatureset: this, topnum: t4 });
  1195. };
  1196. }
  1197. };
  1198. // node_modules/@arcgis/core/arcade/featureset/sources/FeatureLayerDynamic.js
  1199. var P = class extends k3 {
  1200. constructor(e4) {
  1201. super(e4), this.declaredClass = "esri.arcade.featureset.sources.FeatureLayerDynamic", this._removeGeometry = false, this._overrideFields = null, this.formulaCredential = null, this._pageJustIds = false, this._requestStandardised = false, this._useDefinitionExpression = true, e4.spatialReference && (this.spatialReference = e4.spatialReference), this._transparent = true, this._maxProcessing = 1e3, this._layer = e4.layer, this._wset = null, e4.outFields !== void 0 && (this._overrideFields = e4.outFields), e4.includeGeometry !== void 0 && (this._removeGeometry = e4.includeGeometry === false);
  1202. }
  1203. _maxQueryRate() {
  1204. return F;
  1205. }
  1206. end() {
  1207. return this._layer;
  1208. }
  1209. optimisePagingFeatureQueries(e4) {
  1210. this._pageJustIds = e4;
  1211. }
  1212. convertQueryToLruCacheKey(e4) {
  1213. const t4 = D(e4.toJSON());
  1214. return x2(t4, n6.String);
  1215. }
  1216. async loadImpl() {
  1217. return this._layer.loaded === true ? (this._initialiseFeatureSet(), this) : (await this._layer.load(), this._initialiseFeatureSet(), this);
  1218. }
  1219. _initialiseFeatureSet() {
  1220. if (this.spatialReference == null && (this.spatialReference = this._layer.spatialReference), this.geometryType = this._layer.geometryType, this.fields = this._layer.fields.slice(0), this._layer.outFields)
  1221. if (this._layer.outFields.length === 1 && this._layer.outFields[0] === "*")
  1222. ;
  1223. else {
  1224. const e4 = [];
  1225. for (const t4 of this.fields)
  1226. if (t4.type === "oid")
  1227. e4.push(t4);
  1228. else
  1229. for (const i3 of this._layer.outFields)
  1230. if (i3.toLowerCase() === t4.name.toLowerCase()) {
  1231. e4.push(t4);
  1232. break;
  1233. }
  1234. this.fields = e4;
  1235. }
  1236. else
  1237. ;
  1238. if (this._overrideFields !== null)
  1239. if (this._overrideFields.length === 1 && this._overrideFields[0] === "*")
  1240. this._overrideFields = null;
  1241. else {
  1242. const e4 = [], t4 = [];
  1243. for (const i3 of this.fields)
  1244. if (i3.type === "oid")
  1245. e4.push(i3), t4.push(i3.name);
  1246. else
  1247. for (const r of this._overrideFields)
  1248. if (r.toLowerCase() === i3.name.toLowerCase()) {
  1249. e4.push(i3), t4.push(i3.name);
  1250. break;
  1251. }
  1252. this.fields = e4, this._overrideFields = t4;
  1253. }
  1254. if (this._layer.source && this._layer.source.sourceJSON) {
  1255. const e4 = this._layer.source.sourceJSON.currentVersion;
  1256. this._layer.source.sourceJSON.useStandardizedQueries === true ? (this._databaseType = t.StandardisedNoInterval, e4 != null && e4 >= 10.61 && (this._databaseType = t.Standardised)) : e4 != null && (e4 >= 10.5 && (this._databaseType = t.StandardisedNoInterval, this._requestStandardised = true), e4 >= 10.61 && (this._databaseType = t.Standardised));
  1257. }
  1258. this.objectIdField = this._layer.objectIdField;
  1259. for (const e4 of this.fields)
  1260. e4.type === "global-id" && (this.globalIdField = e4.name);
  1261. this.hasM = this._layer.supportsM, this.hasZ = this._layer.supportsZ, this.typeIdField = this._layer.typeIdField, this.types = this._layer.types;
  1262. }
  1263. _isInFeatureSet() {
  1264. return i.InFeatureSet;
  1265. }
  1266. async _refineSetBlock(e4) {
  1267. return e4;
  1268. }
  1269. _candidateIdTransform(e4) {
  1270. return e4;
  1271. }
  1272. async _getSet(e4) {
  1273. if (this._wset === null) {
  1274. await this._ensureLoaded();
  1275. const t4 = await this._getFilteredSet("", null, null, null, e4);
  1276. return this._wset = t4, t4;
  1277. }
  1278. return this._wset;
  1279. }
  1280. async _runDatabaseProbe(e4) {
  1281. await this._ensureLoaded();
  1282. const t4 = new b2();
  1283. t4.where = e4.replace("OBJECTID", this._layer.objectIdField);
  1284. try {
  1285. return await this._layer.queryObjectIds(t4), true;
  1286. } catch (i3) {
  1287. return false;
  1288. }
  1289. }
  1290. _canUsePagination() {
  1291. return !(!this._layer.capabilities || !this._layer.capabilities.query || this._layer.capabilities.query.supportsPagination !== true);
  1292. }
  1293. _cacheableFeatureSetSourceKey() {
  1294. return this._layer.url;
  1295. }
  1296. pbfSupportedForQuery(e4) {
  1297. return !e4.outStatistics && this._layer && this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsFormatPBF === true && this._layer.capabilities.query.supportsQuantizationEditMode === true;
  1298. }
  1299. async queryPBF(e4) {
  1300. e4.quantizationParameters = { mode: "edit" };
  1301. const t4 = await d4(this._layer.parsedUrl, e4, new a({}));
  1302. return x.fromJSON(se(t4.data)).unquantize();
  1303. }
  1304. get gdbVersion() {
  1305. return this._layer && this._layer.capabilities && this._layer.capabilities.data && this._layer.capabilities.data.isVersioned ? this._layer.gdbVersion ? this._layer.gdbVersion : "SDE.DEFAULT" : "";
  1306. }
  1307. nativeCapabilities() {
  1308. return { title: this._layer.title, source: this, canQueryRelated: true, capabilities: this._layer.capabilities, databaseType: this._databaseType, requestStandardised: this._requestStandardised };
  1309. }
  1310. executeQuery(e4, t4) {
  1311. const i3 = t4 === "execute" ? s : t4 === "executeForCount" ? n4 : s2, r = t4 === "execute" && this.pbfSupportedForQuery(e4);
  1312. let s6 = null;
  1313. if (this.recentlyUsedQueries) {
  1314. const t5 = this.convertQueryToLruCacheKey(e4);
  1315. s6 = this.recentlyUsedQueries.getFromCache(t5), s6 === null && (s6 = r !== true ? i3(this._layer.parsedUrl.path, e4) : this.queryPBF(e4), this.recentlyUsedQueries.addToCache(t5, s6), s6 = s6.catch((e5) => {
  1316. throw this.recentlyUsedQueries.removeFromCache(t5), e5;
  1317. }));
  1318. }
  1319. return this.featureSetQueryInterceptor && this.featureSetQueryInterceptor.preLayerQueryCallback({ layer: this._layer, query: e4, method: t4 }), s6 === null && (s6 = r !== true ? i3(this._layer.parsedUrl.path, e4) : this.queryPBF(e4)), s6;
  1320. }
  1321. async _getFilteredSet(e4, t4, i3, r, a5) {
  1322. const n9 = await this.databaseType();
  1323. if (this.isTable() && t4 && e4 !== null && e4 !== "") {
  1324. return new t2([], [], true, null);
  1325. }
  1326. if (this._canUsePagination())
  1327. return this._getFilteredSetUsingPaging(e4, t4, i3, r, a5);
  1328. let l2 = "", o2 = false;
  1329. r !== null && this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsOrderBy === true && (l2 = r.constructClause(), o2 = true);
  1330. const u2 = new b2();
  1331. u2.where = i3 === null ? t4 === null ? "1=1" : "" : n5(i3, n9), this._requestStandardised && (u2.sqlFormat = "standard"), u2.spatialRelationship = this._makeRelationshipEnum(e4), u2.outSpatialReference = this.spatialReference, u2.orderByFields = l2 !== "" ? l2.split(",") : null, u2.geometry = t4 === null ? null : t4, u2.relationParameter = this._makeRelationshipParam(e4);
  1332. let h4 = await this.executeQuery(u2, "executeForIds");
  1333. h4 === null && (h4 = []), this._checkCancelled(a5);
  1334. return new t2([], h4, o2, null);
  1335. }
  1336. _expandPagedSet(e4, t4, i3, r, s6) {
  1337. return this._expandPagedSetFeatureSet(e4, t4, i3, r, s6);
  1338. }
  1339. async _getFilteredSetUsingPaging(e4, t4, i3, r, a5) {
  1340. let n9 = "", l2 = false;
  1341. r !== null && this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsOrderBy === true && (n9 = r.constructClause(), l2 = true);
  1342. const o2 = await this.databaseType();
  1343. let u2 = i3 === null ? t4 === null ? "1=1" : "" : n5(i3, o2);
  1344. this._layer.definitionExpression && this._useDefinitionExpression && (u2 = u2 !== "" ? "((" + this._layer.definitionExpression + ") AND (" + u2 + "))" : this._layer.definitionExpression);
  1345. let h4 = this._maxQueryRate();
  1346. const c3 = this._layer.capabilities.query.maxRecordCount;
  1347. c3 !== void 0 && c3 < h4 && (h4 = c3);
  1348. let p2 = null;
  1349. if (this._pageJustIds === true)
  1350. p2 = new t2([], ["GETPAGES"], l2, { spatialRel: this._makeRelationshipEnum(e4), relationParam: this._makeRelationshipParam(e4), outFields: this._layer.objectIdField, resultRecordCount: h4, resultOffset: 0, geometry: t4 === null ? null : t4, where: u2, orderByFields: n9, returnGeometry: false, returnIdsOnly: "false", internal: { set: [], lastRetrieved: 0, lastPage: 0, fullyResolved: false } });
  1351. else {
  1352. let i4 = true;
  1353. this._removeGeometry === true && (i4 = false);
  1354. const r2 = this._overrideFields !== null ? this._overrideFields : this._fieldsIncludingObjectId(this._layer.outFields ? this._layer.outFields : ["*"]);
  1355. p2 = new t2([], ["GETPAGES"], l2, { spatialRel: this._makeRelationshipEnum(e4), relationParam: this._makeRelationshipParam(e4), outFields: r2.join(","), resultRecordCount: h4, resultOffset: 0, geometry: t4 === null ? null : t4, where: u2, orderByFields: n9, returnGeometry: i4, returnIdsOnly: "false", internal: { set: [], lastRetrieved: 0, lastPage: 0, fullyResolved: false } });
  1356. }
  1357. return await this._expandPagedSet(p2, h4, 0, 1, a5), p2;
  1358. }
  1359. _clonePageDefinition(e4) {
  1360. return e4 === null ? null : e4.groupbypage !== true ? { groupbypage: false, spatialRel: e4.spatialRel, relationParam: e4.relationParam, outFields: e4.outFields, resultRecordCount: e4.resultRecordCount, resultOffset: e4.resultOffset, geometry: e4.geometry, where: e4.where, orderByFields: e4.orderByFields, returnGeometry: e4.returnGeometry, returnIdsOnly: e4.returnIdsOnly, internal: e4.internal } : { groupbypage: true, spatialRel: e4.spatialRel, relationParam: e4.relationParam, outFields: e4.outFields, resultRecordCount: e4.resultRecordCount, useOIDpagination: e4.useOIDpagination, generatedOid: e4.generatedOid, groupByFieldsForStatistics: e4.groupByFieldsForStatistics, resultOffset: e4.resultOffset, outStatistics: e4.outStatistics, geometry: e4.geometry, where: e4.where, orderByFields: e4.orderByFields, returnGeometry: e4.returnGeometry, returnIdsOnly: e4.returnIdsOnly, internal: e4.internal };
  1361. }
  1362. async _getPhysicalPage(e4, t4, i3) {
  1363. const r = e4.pagesDefinition.internal.lastRetrieved, s6 = r, a5 = e4.pagesDefinition.internal.lastPage, n9 = new b2();
  1364. this._requestStandardised && (n9.sqlFormat = "standard"), n9.spatialRelationship = e4.pagesDefinition.spatialRel, n9.relationParameter = e4.pagesDefinition.relationParam, n9.outFields = e4.pagesDefinition.outFields.split(","), n9.num = e4.pagesDefinition.resultRecordCount, n9.start = e4.pagesDefinition.internal.lastPage, n9.geometry = e4.pagesDefinition.geometry, n9.where = e4.pagesDefinition.where, n9.orderByFields = e4.pagesDefinition.orderByFields !== "" ? e4.pagesDefinition.orderByFields.split(",") : null, n9.returnGeometry = e4.pagesDefinition.returnGeometry, n9.outSpatialReference = this.spatialReference;
  1365. const l2 = await this.executeQuery(n9, "execute");
  1366. if (this._checkCancelled(i3), e4.pagesDefinition.internal.lastPage !== a5)
  1367. return "done";
  1368. for (let o2 = 0; o2 < l2.features.length; o2++)
  1369. e4.pagesDefinition.internal.set[s6 + o2] = l2.features[o2].attributes[this._layer.objectIdField];
  1370. if (this._pageJustIds === false)
  1371. for (let o2 = 0; o2 < l2.features.length; o2++)
  1372. this._featureCache[l2.features[o2].attributes[this._layer.objectIdField]] = l2.features[o2];
  1373. return (l2.exceededTransferLimit === void 0 && l2.features.length !== e4.pagesDefinition.resultRecordCount || l2.exceededTransferLimit === false) && (e4.pagesDefinition.internal.fullyResolved = true), e4.pagesDefinition.internal.lastRetrieved = r + l2.features.length, e4.pagesDefinition.internal.lastPage += e4.pagesDefinition.resultRecordCount, "done";
  1374. }
  1375. _fieldsIncludingObjectId(e4) {
  1376. if (e4 === null)
  1377. return [this.objectIdField];
  1378. const t4 = e4.slice(0);
  1379. if (t4.includes("*"))
  1380. return t4;
  1381. let i3 = false;
  1382. for (const r of t4)
  1383. if (r.toUpperCase() === this.objectIdField.toUpperCase()) {
  1384. i3 = true;
  1385. break;
  1386. }
  1387. return i3 === false && t4.push(this.objectIdField), t4;
  1388. }
  1389. async _getFeatures(e4, t4, i3, r) {
  1390. const s6 = [];
  1391. if (t4 !== -1 && this._featureCache[t4] === void 0 && s6.push(t4), this._checkIfNeedToExpandKnownPage(e4, this._maxProcessingRate()) === true)
  1392. return await this._expandPagedSet(e4, this._maxProcessingRate(), 0, 0, r), this._getFeatures(e4, t4, i3, r);
  1393. let a5 = 0;
  1394. for (let o2 = e4._lastFetchedIndex; o2 < e4._known.length; o2++) {
  1395. if (e4._lastFetchedIndex += 1, a5++, this._featureCache[e4._known[o2]] === void 0) {
  1396. let i4 = false;
  1397. if (this._layer._mode !== null && this._layer._mode !== void 0) {
  1398. const t5 = this._layer._mode;
  1399. if (t5._featureMap[e4._known[o2]] !== void 0) {
  1400. const r2 = t5._featureMap[e4._known[o2]];
  1401. r2 !== null && (i4 = true, this._featureCache[e4._known[o2]] = r2);
  1402. }
  1403. }
  1404. if (i4 === false && (e4._known[o2] !== t4 && s6.push(e4._known[o2]), s6.length >= this._maxProcessingRate() - 1))
  1405. break;
  1406. }
  1407. if (a5 >= i3 && s6.length === 0)
  1408. break;
  1409. }
  1410. if (s6.length === 0)
  1411. return "success";
  1412. const n9 = new b2();
  1413. this._requestStandardised && (n9.sqlFormat = "standard"), n9.objectIds = s6, n9.outFields = this._overrideFields !== null ? this._overrideFields : this._fieldsIncludingObjectId(this._layer.outFields ? this._layer.outFields : ["*"]), n9.returnGeometry = true, this._removeGeometry === true && (n9.returnGeometry = false), n9.outSpatialReference = this.spatialReference;
  1414. const l2 = await this.executeQuery(n9, "execute");
  1415. if (this._checkCancelled(r), l2.error !== void 0)
  1416. throw new Error(l2.error);
  1417. for (let o2 = 0; o2 < l2.features.length; o2++)
  1418. this._featureCache[l2.features[o2].attributes[this._layer.objectIdField]] = l2.features[o2];
  1419. return "success";
  1420. }
  1421. async _getDistinctPages(e4, t4, i3, r, s6, a5, n9, l2, o2) {
  1422. await this._ensureLoaded();
  1423. const u2 = await this.databaseType();
  1424. let h4 = i3.parseTree.column;
  1425. for (let d6 = 0; d6 < this._layer.fields.length; d6++)
  1426. if (this._layer.fields[d6].name.toLowerCase() === h4.toLowerCase()) {
  1427. h4 = this._layer.fields[d6].name;
  1428. break;
  1429. }
  1430. const c3 = new b2();
  1431. this._requestStandardised && (c3.sqlFormat = "standard");
  1432. let p2 = a5 === null ? s6 === null ? "1=1" : "" : n5(a5, u2);
  1433. this._layer.definitionExpression && this._useDefinitionExpression && (p2 = p2 !== "" ? "((" + this._layer.definitionExpression + ") AND (" + p2 + "))" : this._layer.definitionExpression), c3.where = p2, c3.spatialRelationship = this._makeRelationshipEnum(r), c3.relationParameter = this._makeRelationshipParam(r), c3.geometry = s6 === null ? null : s6, c3.returnDistinctValues = true, c3.returnGeometry = false, c3.outFields = [h4];
  1434. const y3 = await this.executeQuery(c3, "execute");
  1435. if (this._checkCancelled(o2), !y3.hasOwnProperty("features"))
  1436. throw new Error("Unnexected Result querying statistics from layer");
  1437. let f3 = false;
  1438. for (let d6 = 0; d6 < this._layer.fields.length; d6++)
  1439. if (this._layer.fields[d6].name === h4) {
  1440. this._layer.fields[d6].type === "date" && (f3 = true);
  1441. break;
  1442. }
  1443. for (let d6 = 0; d6 < y3.features.length; d6++) {
  1444. if (f3) {
  1445. const e5 = y3.features[d6].attributes[h4];
  1446. e5 !== null ? l2.push(new Date(e5)) : l2.push(e5);
  1447. } else
  1448. l2.push(y3.features[d6].attributes[h4]);
  1449. if (l2.length >= n9)
  1450. break;
  1451. }
  1452. if (y3.features.length === 0)
  1453. return l2;
  1454. if (y3.features.length === this._layer.capabilities.query.maxRecordCount && l2.length < n9) {
  1455. return { calculated: true, result: await this._getDistinctPages(e4 + y3.features.length, t4, i3, r, s6, a5, n9, l2, o2) };
  1456. }
  1457. return l2;
  1458. }
  1459. async _distinctStat(e4, t4, i3, r, s6, a5, n9) {
  1460. return { calculated: true, result: await this._getDistinctPages(0, e4, t4, i3, r, s6, a5, [], n9) };
  1461. }
  1462. isTable() {
  1463. return this._layer.isTable || this._layer.geometryType === null || this._layer.type === "table" || this._layer.geometryType === "";
  1464. }
  1465. async _countstat(e4, t4, i3, r) {
  1466. const s6 = await this.databaseType(), a5 = new b2();
  1467. if (this._requestStandardised && (a5.sqlFormat = "standard"), this.isTable() && i3 && t4 !== null && t4 !== "")
  1468. return { calculated: true, result: 0 };
  1469. let n9 = r === null ? i3 === null ? "1=1" : "" : n5(r, s6);
  1470. this._layer.definitionExpression && this._useDefinitionExpression && (n9 = n9 !== "" ? "((" + this._layer.definitionExpression + ") AND (" + n9 + "))" : this._layer.definitionExpression), a5.where = n9, a5.where = n9, a5.spatialRelationship = this._makeRelationshipEnum(t4), a5.relationParameter = this._makeRelationshipParam(t4), a5.geometry = i3 === null ? null : i3, a5.returnGeometry = false;
  1471. return { calculated: true, result: await this.executeQuery(a5, "executeForCount") };
  1472. }
  1473. async _stats(e4, t4, i3, r, s6, a5, n9) {
  1474. await this._ensureLoaded();
  1475. const l2 = this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsSqlExpression === true, o2 = this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsStatistics === true, u2 = this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsDistinct === true;
  1476. if (e4 === "count")
  1477. return u2 ? this._countstat(e4, i3, r, s6) : { calculated: false };
  1478. if (o2 === false || E(t4) === false && l2 === false || t4.isStandardized === false)
  1479. return i3 !== "" || s6 !== null ? { calculated: false } : this._manualStat(e4, t4, a5, n9);
  1480. if (e4 === "distinct")
  1481. return u2 === false ? i3 !== "" || s6 !== null ? { calculated: false } : this._manualStat(e4, t4, a5, n9) : this._distinctStat(e4, t4, i3, r, s6, a5, n9);
  1482. const p2 = await this.databaseType();
  1483. if (this.isTable() && r && i3 !== null && i3 !== "")
  1484. return { calculated: true, result: null };
  1485. const y3 = new b2();
  1486. this._requestStandardised && (y3.sqlFormat = "standard");
  1487. let f3 = s6 === null ? r === null ? "1=1" : "" : n5(s6, p2);
  1488. this._layer.definitionExpression && this._useDefinitionExpression && (f3 = f3 !== "" ? "((" + this._layer.definitionExpression + ") AND (" + f3 + "))" : this._layer.definitionExpression), y3.where = f3, y3.spatialRelationship = this._makeRelationshipEnum(i3), y3.relationParameter = this._makeRelationshipParam(i3), y3.geometry = r === null ? null : r;
  1489. const _2 = new m2();
  1490. _2.statisticType = h2(e4), _2.onStatisticField = n5(t4, p2), _2.outStatisticFieldName = "ARCADE_STAT_RESULT", y3.returnGeometry = false;
  1491. let m4 = "ARCADE_STAT_RESULT";
  1492. y3.outStatistics = [_2];
  1493. const g3 = await this.executeQuery(y3, "execute");
  1494. if (!g3.hasOwnProperty("features") || g3.features.length === 0)
  1495. throw new Error("Unnexected Result querying statistics from layer");
  1496. let F3 = false;
  1497. for (let d6 = 0; d6 < g3.fields.length; d6++)
  1498. if (g3.fields[d6].name.toUpperCase() === "ARCADE_STAT_RESULT") {
  1499. m4 = g3.fields[d6].name, g3.fields[d6].type === "date" && (F3 = true);
  1500. break;
  1501. }
  1502. if (F3) {
  1503. let e5 = g3.features[0].attributes[m4];
  1504. return e5 !== null && (e5 = new Date(g3.features[0].attributes[m4])), { calculated: true, result: e5 };
  1505. }
  1506. return { calculated: true, result: g3.features[0].attributes[m4] };
  1507. }
  1508. _stat(e4, t4, i3, r, s6, a5, n9) {
  1509. return this._stats(e4, t4, i3, r, s6, a5, n9);
  1510. }
  1511. async _canDoAggregates(e4, t4) {
  1512. await this._ensureLoaded();
  1513. let i3 = false;
  1514. const r = this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsSqlExpression === true;
  1515. if (this._layer.capabilities !== void 0 && this._layer.capabilities.query !== null && this._layer.capabilities.query.supportsStatistics === true && this._layer.capabilities.query.supportsOrderBy === true && (i3 = true), i3)
  1516. for (let s6 = 0; s6 < t4.length - 1; s6++)
  1517. t4[s6].workingexpr !== null && (t4[s6].workingexpr.isStandardized === false || E(t4[s6].workingexpr) === false && r === false) && (i3 = false);
  1518. return i3 !== false;
  1519. }
  1520. _makeRelationshipEnum(e4) {
  1521. if (e4.includes("esriSpatialRelRelation"))
  1522. return "relation";
  1523. switch (e4) {
  1524. case "esriSpatialRelRelation":
  1525. return "relation";
  1526. case "esriSpatialRelIntersects":
  1527. return "intersects";
  1528. case "esriSpatialRelContains":
  1529. return "contains";
  1530. case "esriSpatialRelOverlaps":
  1531. return "overlaps";
  1532. case "esriSpatialRelWithin":
  1533. return "within";
  1534. case "esriSpatialRelTouches":
  1535. return "touches";
  1536. case "esriSpatialRelCrosses":
  1537. return "crosses";
  1538. case "esriSpatialRelEnvelopeIntersects":
  1539. return "envelope-intersects";
  1540. }
  1541. return e4;
  1542. }
  1543. _makeRelationshipParam(e4) {
  1544. return e4.includes("esriSpatialRelRelation") ? e4.split(":")[1] : "";
  1545. }
  1546. async _getAggregatePagesDataSourceDefinition(e4, t4, i3, r, a5, n9, l2) {
  1547. await this._ensureLoaded();
  1548. const o2 = await this.databaseType();
  1549. let u2 = "", h4 = false, c3 = false;
  1550. n9 !== null && this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsOrderBy === true && (u2 = n9.constructClause(), c3 = true), this._layer.capabilities && this._layer.capabilities.query && this._layer.capabilities.query.supportsPagination === false && (c3 = false, h4 = true, u2 = this._layer.objectIdField);
  1551. const p2 = [];
  1552. for (let s6 = 0; s6 < t4.length; s6++) {
  1553. const e5 = new m2();
  1554. e5.onStatisticField = t4[s6].workingexpr !== null ? n5(t4[s6].workingexpr, o2) : "", e5.outStatisticFieldName = t4[s6].field, e5.statisticType = t4[s6].toStatisticsName(), p2.push(e5);
  1555. }
  1556. u2 === "" && (u2 = e4.join(","));
  1557. let y3 = this._maxQueryRate();
  1558. const f3 = this._layer.capabilities.query.maxRecordCount;
  1559. f3 !== void 0 && f3 < y3 && (y3 = f3);
  1560. let _2 = a5 === null ? r === null ? "1=1" : "" : n5(a5, o2);
  1561. this._layer.definitionExpression && this._useDefinitionExpression && (_2 = _2 !== "" ? "((" + this._layer.definitionExpression + ") AND (" + _2 + "))" : this._layer.definitionExpression);
  1562. return new t2([], ["GETPAGES"], c3, { groupbypage: true, spatialRel: this._makeRelationshipEnum(i3), relationParam: this._makeRelationshipParam(i3), outFields: ["*"], useOIDpagination: h4, generatedOid: l2, resultRecordCount: y3, resultOffset: 0, groupByFieldsForStatistics: e4, outStatistics: p2, geometry: r === null ? null : r, where: _2, orderByFields: u2, returnGeometry: false, returnIdsOnly: false, internal: { lastMaxId: -1, set: [], lastRetrieved: 0, lastPage: 0, fullyResolved: false } });
  1563. }
  1564. async _getAgregagtePhysicalPage(t4, i3, r) {
  1565. let s6 = t4.pagesDefinition.where;
  1566. t4.pagesDefinition.useOIDpagination === true && (s6 = s6 !== "" ? "(" + s6 + ") AND (" + t4.pagesDefinition.generatedOid + ">" + t4.pagesDefinition.internal.lastMaxId.toString() + ")" : t4.pagesDefinition.generatedOid + ">" + t4.pagesDefinition.internal.lastMaxId.toString());
  1567. const a5 = t4.pagesDefinition.internal.lastRetrieved, n9 = a5, l2 = t4.pagesDefinition.internal.lastPage, o2 = new b2();
  1568. if (this._requestStandardised && (o2.sqlFormat = "standard"), o2.where = s6, o2.spatialRelationship = t4.pagesDefinition.spatialRel, o2.relationParameter = t4.pagesDefinition.relationParam, o2.outFields = t4.pagesDefinition.outFields, o2.outStatistics = t4.pagesDefinition.outStatistics, o2.geometry = t4.pagesDefinition.geometry, o2.groupByFieldsForStatistics = t4.pagesDefinition.groupByFieldsForStatistics, o2.num = t4.pagesDefinition.resultRecordCount, o2.start = t4.pagesDefinition.internal.lastPage, o2.returnGeometry = t4.pagesDefinition.returnGeometry, o2.orderByFields = t4.pagesDefinition.orderByFields !== "" ? t4.pagesDefinition.orderByFields.split(",") : null, this.isTable() && o2.geometry && o2.spatialRelationship)
  1569. return [];
  1570. const u2 = await this.executeQuery(o2, "execute");
  1571. if (this._checkCancelled(r), !u2.hasOwnProperty("features"))
  1572. throw new Error("Unnexected Result querying aggregates from layer");
  1573. const d6 = [];
  1574. if (t4.pagesDefinition.internal.lastPage !== l2)
  1575. return [];
  1576. for (let e4 = 0; e4 < u2.features.length; e4++)
  1577. t4.pagesDefinition.internal.set[n9 + e4] = u2.features[e4].attributes[t4.pagesDefinition.generatedOid];
  1578. for (let h4 = 0; h4 < u2.features.length; h4++)
  1579. d6.push(new g({ attributes: u2.features[h4].attributes, geometry: null }));
  1580. return t4.pagesDefinition.useOIDpagination === true ? u2.features.length === 0 ? t4.pagesDefinition.internal.fullyResolved = true : t4.pagesDefinition.internal.lastMaxId = u2.features[u2.features.length - 1].attributes[t4.pagesDefinition.generatedOid] : (u2.exceededTransferLimit === void 0 && u2.features.length !== t4.pagesDefinition.resultRecordCount || u2.exceededTransferLimit === false) && (t4.pagesDefinition.internal.fullyResolved = true), t4.pagesDefinition.internal.lastRetrieved = a5 + u2.features.length, t4.pagesDefinition.internal.lastPage += t4.pagesDefinition.resultRecordCount, d6;
  1581. }
  1582. static create(e4, t4, i3, r, s6) {
  1583. const a5 = new Ke({ url: e4, outFields: t4 === null ? ["*"] : t4 });
  1584. return new P({ layer: a5, spatialReference: i3, lrucache: r, interceptor: s6 });
  1585. }
  1586. relationshipMetaData() {
  1587. return this._layer && this._layer.source && this._layer.source.sourceJSON && this._layer.source.sourceJSON.relationships ? this._layer.source.sourceJSON.relationships : [];
  1588. }
  1589. serviceUrl() {
  1590. return b(this._layer.parsedUrl.path);
  1591. }
  1592. async queryAttachments(e4, t4, r, s6, a5) {
  1593. if (this._layer.capabilities.data.supportsAttachment && this._layer.capabilities.operations.supportsQueryAttachments) {
  1594. const n9 = { objectIds: [e4], returnMetadata: a5 };
  1595. (t4 && t4 > 0 || r && r > 0) && (n9.size = [t4 && t4 > 0 ? t4 : 0, r && r > 0 ? r : t4 + 1]), s6 && s6.length > 0 && (n9.attachmentTypes = s6), this.featureSetQueryInterceptor && this.featureSetQueryInterceptor.preLayerQueryCallback({ layer: this._layer, query: n9, method: "attachments" });
  1596. const l2 = await this._layer.queryAttachments(n9), o2 = [];
  1597. return l2 && l2[e4] && l2[e4].forEach((t5) => {
  1598. const r2 = this._layer.parsedUrl.path + "/" + e4.toString() + "/attachments/" + t5.id.toString();
  1599. let s7 = null;
  1600. a5 && t5.exifInfo && (s7 = d2.convertJsonToArcade(t5.exifInfo, true)), o2.push(new e(t5.id, t5.name, t5.contentType, t5.size, r2, s7));
  1601. }), o2;
  1602. }
  1603. return [];
  1604. }
  1605. async queryRelatedFeatures(i3) {
  1606. const r = { f: "json", relationshipId: i3.relationshipId.toString(), definitionExpression: i3.where, outFields: i3.outFields.join(","), returnGeometry: i3.returnGeometry.toString() };
  1607. i3.resultOffset !== void 0 && i3.resultOffset !== null && (r.resultOffset = i3.resultOffset.toString()), i3.resultRecordCount !== void 0 && i3.resultRecordCount !== null && (r.resultRecordCount = i3.resultRecordCount.toString()), i3.orderByFields && (r.orderByFields = i3.orderByFields.join(",")), i3.objectIds.length > 0 && (r.objectIds = i3.objectIds.join(",")), i3.outSpatialReference && (r.outSR = JSON.stringify(i3.outSpatialReference.toJSON())), this.featureSetQueryInterceptor && this.featureSetQueryInterceptor.preRequestCallback({ layer: this._layer, queryPayload: r, method: "relatedrecords", url: this._layer.parsedUrl.path + "/queryRelatedRecords" });
  1608. const s6 = await U(this._layer.parsedUrl.path + "/queryRelatedRecords", { responseType: "json", query: r });
  1609. if (s6.data) {
  1610. const t4 = {}, i4 = s6.data;
  1611. if (i4 && i4.relatedRecordGroups) {
  1612. const r2 = i4.spatialReference;
  1613. for (const s7 of i4.relatedRecordGroups) {
  1614. const a5 = s7.objectId, n9 = [];
  1615. for (const t5 of s7.relatedRecords) {
  1616. t5.geometry && (t5.geometry.spatialReference = r2);
  1617. const i5 = new g({ geometry: t5.geometry ? d(t5.geometry) : null, attributes: t5.attributes });
  1618. n9.push(i5);
  1619. }
  1620. t4[a5] = { features: n9, exceededTransferLimit: i4.exceededTransferLimit === true };
  1621. }
  1622. }
  1623. return t4;
  1624. }
  1625. throw new Error("Invalid Request");
  1626. }
  1627. async getFeatureByObjectId(e4, t4) {
  1628. const i3 = new b2();
  1629. i3.outFields = t4, i3.returnGeometry = false, i3.outSpatialReference = this.spatialReference, i3.where = this.objectIdField + "=" + e4.toString(), this.featureSetQueryInterceptor && this.featureSetQueryInterceptor.preLayerQueryCallback({ layer: this._layer, query: i3, method: "execute" });
  1630. const r = await s(this._layer.parsedUrl.path, i3);
  1631. return r.features.length === 1 ? r.features[0] : null;
  1632. }
  1633. async getIdentityUser() {
  1634. await this.load();
  1635. const e4 = n2?.findCredential(this._layer.url);
  1636. return e4 ? e4.userId : null;
  1637. }
  1638. async getOwningSystemUrl() {
  1639. await this.load();
  1640. const e4 = n2?.findServerInfo(this._layer.url);
  1641. if (e4)
  1642. return e4.owningSystemUrl;
  1643. let i3 = this._layer.url;
  1644. const r = i3.toLowerCase().indexOf("/rest/services");
  1645. if (i3 = r > -1 ? i3.substring(0, r) : i3, i3) {
  1646. i3 += "/rest/info";
  1647. try {
  1648. const e5 = await U(i3, { query: { f: "json" } });
  1649. let r2 = "";
  1650. return e5.data && e5.data.owningSystemUrl && (r2 = e5.data.owningSystemUrl), r2;
  1651. } catch (s6) {
  1652. return "";
  1653. }
  1654. }
  1655. return "";
  1656. }
  1657. getDataSourceFeatureSet() {
  1658. const e4 = new P({ layer: this._layer, spatialReference: this.spatialReference, outFields: this._overrideFields, includeGeometry: !this._removeGeometry, lrucache: this.recentlyUsedQueries, interceptor: this.featureSetQueryInterceptor });
  1659. return e4._useDefinitionExpression = false, e4;
  1660. }
  1661. };
  1662. // node_modules/@arcgis/core/arcade/featureset/sources/FeatureLayerMemory.js
  1663. var y2 = class extends k3 {
  1664. constructor(e4) {
  1665. super(e4), this.declaredClass = "esri.arcade.featureset.sources.FeatureLayerMemory", this._removeGeometry = false, this._overrideFields = null, this._forceIsTable = false, e4.spatialReference && (this.spatialReference = e4.spatialReference), this._transparent = true, this._maxProcessing = 1e3, this._layer = e4.layer, this._wset = null, e4.isTable === true && (this._forceIsTable = true), e4.outFields !== void 0 && (this._overrideFields = e4.outFields), e4.includeGeometry !== void 0 && (this._removeGeometry = e4.includeGeometry === false);
  1666. }
  1667. _maxQueryRate() {
  1668. return F;
  1669. }
  1670. end() {
  1671. return this._layer;
  1672. }
  1673. optimisePagingFeatureQueries() {
  1674. }
  1675. async loadImpl() {
  1676. return this._layer.loaded === true ? (this._initialiseFeatureSet(), this) : (await this._layer.load(), this._initialiseFeatureSet(), this);
  1677. }
  1678. get gdbVersion() {
  1679. return "";
  1680. }
  1681. _initialiseFeatureSet() {
  1682. if (this.spatialReference == null && (this.spatialReference = this._layer.spatialReference), this.geometryType = this._layer.geometryType, this.fields = this._layer.fields.slice(0), this._layer.outFields)
  1683. if (this._layer.outFields.length === 1 && this._layer.outFields[0] === "*")
  1684. ;
  1685. else {
  1686. const e4 = [];
  1687. for (const t4 of this.fields)
  1688. if (t4.type === "oid")
  1689. e4.push(t4);
  1690. else
  1691. for (const s6 of this._layer.outFields)
  1692. if (s6.toLowerCase() === t4.name.toLowerCase()) {
  1693. e4.push(t4);
  1694. break;
  1695. }
  1696. this.fields = e4;
  1697. }
  1698. else
  1699. ;
  1700. if (this._overrideFields !== null)
  1701. if (this._overrideFields.length === 1 && this._overrideFields[0] === "*")
  1702. this._overrideFields = null;
  1703. else {
  1704. const e4 = [], t4 = [];
  1705. for (const s6 of this.fields)
  1706. if (s6.type === "oid")
  1707. e4.push(s6), t4.push(s6.name);
  1708. else
  1709. for (const r of this._overrideFields)
  1710. if (r.toLowerCase() === s6.name.toLowerCase()) {
  1711. e4.push(s6), t4.push(s6.name);
  1712. break;
  1713. }
  1714. this.fields = e4, this._overrideFields = t4;
  1715. }
  1716. this.objectIdField = this._layer.objectIdField;
  1717. for (const e4 of this.fields)
  1718. e4.type === "global-id" && (this.globalIdField = e4.name);
  1719. this.hasM = this._layer.supportsM, this.hasZ = this._layer.supportsZ, this._databaseType = t.Standardised, this.typeIdField = this._layer.typeIdField, this.types = this._layer.types;
  1720. }
  1721. isTable() {
  1722. return this._forceIsTable || this._layer.isTable || this._layer.type === "table" || !this._layer.geometryType;
  1723. }
  1724. _isInFeatureSet() {
  1725. return i.InFeatureSet;
  1726. }
  1727. _candidateIdTransform(e4) {
  1728. return e4;
  1729. }
  1730. async _getSet(e4) {
  1731. if (this._wset === null) {
  1732. await this._ensureLoaded();
  1733. const t4 = await this._getFilteredSet("", null, null, null, e4);
  1734. return this._wset = t4, t4;
  1735. }
  1736. return this._wset;
  1737. }
  1738. _changeFeature(t4) {
  1739. const s6 = {};
  1740. for (const e4 of this.fields)
  1741. s6[e4.name] = t4.attributes[e4.name];
  1742. return new g({ geometry: this._removeGeometry === true ? null : t4.geometry, attributes: s6 });
  1743. }
  1744. async _getFilteredSet(e4, t4, r, a5, n9) {
  1745. let o2 = "", u2 = false;
  1746. if (a5 !== null && (o2 = a5.constructClause(), u2 = true), this.isTable() && t4 && e4 !== null && e4 !== "") {
  1747. return new t2([], [], true, null);
  1748. }
  1749. const h4 = new b2();
  1750. h4.where = r === null ? t4 === null ? "1=1" : "" : n5(r, t.Standardised), h4.spatialRelationship = this._makeRelationshipEnum(e4), h4.outSpatialReference = this.spatialReference, h4.orderByFields = o2 !== "" ? o2.split(",") : null, h4.geometry = t4 === null ? null : t4, h4.returnGeometry = true, h4.relationParameter = this._makeRelationshipParam(e4);
  1751. const y3 = await this._layer.queryFeatures(h4);
  1752. if (y3 === null)
  1753. return new t2([], [], u2, null);
  1754. this._checkCancelled(n9);
  1755. const d6 = [];
  1756. y3.features.forEach((e5) => {
  1757. const t5 = e5.attributes[this._layer.objectIdField];
  1758. d6.push(t5), this._featureCache[t5] = this._changeFeature(e5);
  1759. });
  1760. return new t2([], d6, u2, null);
  1761. }
  1762. _makeRelationshipEnum(e4) {
  1763. if (e4.includes("esriSpatialRelRelation"))
  1764. return "relation";
  1765. switch (e4) {
  1766. case "esriSpatialRelRelation":
  1767. return "relation";
  1768. case "esriSpatialRelIntersects":
  1769. return "intersects";
  1770. case "esriSpatialRelContains":
  1771. return "contains";
  1772. case "esriSpatialRelOverlaps":
  1773. return "overlaps";
  1774. case "esriSpatialRelWithin":
  1775. return "within";
  1776. case "esriSpatialRelTouches":
  1777. return "touches";
  1778. case "esriSpatialRelCrosses":
  1779. return "crosses";
  1780. case "esriSpatialRelEnvelopeIntersects":
  1781. return "envelope-intersects";
  1782. }
  1783. return e4;
  1784. }
  1785. _makeRelationshipParam(e4) {
  1786. return e4.includes("esriSpatialRelRelation") ? e4.split(":")[1] : "";
  1787. }
  1788. async _queryAllFeatures() {
  1789. if (this._wset)
  1790. return this._wset;
  1791. const e4 = new b2();
  1792. if (e4.where = "1=1", await this._ensureLoaded(), this._layer.source && this._layer.source.items) {
  1793. const e5 = [];
  1794. return this._layer.source.items.forEach((t5) => {
  1795. const s6 = t5.attributes[this._layer.objectIdField];
  1796. e5.push(s6), this._featureCache[s6] = this._changeFeature(t5);
  1797. }), this._wset = new t2([], e5, false, null), this._wset;
  1798. }
  1799. const t4 = await this._layer.queryFeatures(e4), r = [];
  1800. return t4.features.forEach((e5) => {
  1801. const t5 = e5.attributes[this._layer.objectIdField];
  1802. r.push(t5), this._featureCache[t5] = this._changeFeature(e5);
  1803. }), this._wset = new t2([], r, false, null), this._wset;
  1804. }
  1805. async _getFeatures(e4, t4, s6) {
  1806. const r = [];
  1807. t4 !== -1 && this._featureCache[t4] === void 0 && r.push(t4);
  1808. for (let i3 = e4._lastFetchedIndex; i3 < e4._known.length && (e4._lastFetchedIndex += 1, !(this._featureCache[e4._known[i3]] === void 0 && (e4._known[i3] !== t4 && r.push(e4._known[i3]), r.length > s6))); i3++)
  1809. ;
  1810. if (r.length === 0)
  1811. return "success";
  1812. throw new Error("Unaccounted for Features. Not in Feature Collection");
  1813. }
  1814. async _refineSetBlock(e4) {
  1815. return e4;
  1816. }
  1817. async _stat() {
  1818. return { calculated: false };
  1819. }
  1820. async _canDoAggregates() {
  1821. return false;
  1822. }
  1823. relationshipMetaData() {
  1824. return [];
  1825. }
  1826. static _cloneAttr(e4) {
  1827. const t4 = {};
  1828. for (const s6 in e4)
  1829. t4[s6] = e4[s6];
  1830. return t4;
  1831. }
  1832. nativeCapabilities() {
  1833. return { title: this._layer.title, canQueryRelated: false, source: this, capabilities: this._layer.capabilities, databaseType: this._databaseType, requestStandardised: true };
  1834. }
  1835. static create(e4, t4) {
  1836. let s6 = e4.layerDefinition.objectIdField;
  1837. const r = e4.layerDefinition.typeIdField ? e4.layerDefinition.typeIdField : "", i3 = [];
  1838. if (e4.layerDefinition.types)
  1839. for (const n9 of e4.layerDefinition.types)
  1840. i3.push(n3.fromJSON(n9));
  1841. let a5 = e4.layerDefinition.geometryType;
  1842. a5 === void 0 && (a5 = e4.featureSet.geometryType || "");
  1843. let l2 = e4.featureSet.features;
  1844. const c3 = t4.toJSON();
  1845. if (s6 === "" || s6 === void 0) {
  1846. let t5 = false;
  1847. for (const r2 of e4.layerDefinition.fields)
  1848. if (r2.type === "oid" || r2.type === "esriFieldTypeOID") {
  1849. s6 = r2.name, t5 = true;
  1850. break;
  1851. }
  1852. if (t5 === false) {
  1853. let t6 = "FID", r2 = true, i4 = 0;
  1854. for (; r2; ) {
  1855. let s7 = true;
  1856. for (const r3 of e4.layerDefinition.fields)
  1857. if (r3.name === t6) {
  1858. s7 = false;
  1859. break;
  1860. }
  1861. s7 === true ? r2 = false : (i4++, t6 = "FID" + i4.toString());
  1862. }
  1863. e4.layerDefinition.fields.push({ type: "esriFieldTypeOID", name: t6, alias: t6 });
  1864. const a6 = [];
  1865. for (let s7 = 0; s7 < l2.length; s7++)
  1866. a6.push({ geometry: e4.featureSet.features[s7].geometry, attributes: e4.featureSet.features[s7].attributes ? this._cloneAttr(e4.featureSet.features[s7].attributes) : {} }), a6[s7].attributes[t6] = s7;
  1867. l2 = a6, s6 = t6;
  1868. }
  1869. }
  1870. const d6 = [];
  1871. for (const n9 of e4.layerDefinition.fields)
  1872. n9 instanceof y ? d6.push(n9) : d6.push(y.fromJSON(n9));
  1873. let f3 = a5;
  1874. switch (f3) {
  1875. case "esriGeometryPoint":
  1876. f3 = "point";
  1877. break;
  1878. case "esriGeometryPolyline":
  1879. f3 = "polyline";
  1880. break;
  1881. case "esriGeometryPolygon":
  1882. f3 = "polygon";
  1883. break;
  1884. case "esriGeometryExtent":
  1885. f3 = "extent";
  1886. break;
  1887. case "esriGeometryMultipoint":
  1888. f3 = "multipoint";
  1889. }
  1890. for (const o2 of l2)
  1891. o2.geometry && o2.geometry instanceof p == false && (o2.geometry.type = f3, o2.geometry.spatialReference === void 0 && (o2.geometry.spatialReference = c3));
  1892. const p2 = { outFields: ["*"], source: l2, fields: d6, types: i3, typeIdField: r, objectIdField: s6, spatialReference: t4 };
  1893. p2.geometryType = f3 || "point";
  1894. const _2 = new Ke(p2);
  1895. return new y2({ layer: _2, spatialReference: t4, isTable: f3 === null || f3 === "" });
  1896. }
  1897. async queryAttachments() {
  1898. return [];
  1899. }
  1900. async getFeatureByObjectId(e4) {
  1901. const t4 = new b2();
  1902. t4.where = this.objectIdField + "=" + e4.toString();
  1903. const s6 = await this._layer.queryFeatures(t4);
  1904. return s6.features.length === 1 ? s6.features[0] : null;
  1905. }
  1906. async getOwningSystemUrl() {
  1907. return "";
  1908. }
  1909. async getIdentityUser() {
  1910. return "";
  1911. }
  1912. };
  1913. // node_modules/@arcgis/core/arcade/featureset/sources/FeatureLayerRelated.js
  1914. var n8 = class extends k3 {
  1915. constructor(e4) {
  1916. super(e4), this.declaredClass = "esri.arcade.featureset.sources.FeatureLayerRelated", this._findObjectId = -1, this._requestStandardised = false, this._removeGeometry = false, this._overrideFields = null, this.featureObjectId = null, this.relatedLayer = null, this.relationship = null, e4.spatialReference && (this.spatialReference = e4.spatialReference), this._transparent = true, this._maxProcessing = 1e3, this._layer = e4.layer, this._wset = null, this._findObjectId = e4.objectId, this.featureObjectId = e4.objectId, this.relationship = e4.relationship, this.relatedLayer = e4.relatedLayer, e4.outFields !== void 0 && (this._overrideFields = e4.outFields), e4.includeGeometry !== void 0 && (this._removeGeometry = e4.includeGeometry === false);
  1917. }
  1918. _maxQueryRate() {
  1919. return F;
  1920. }
  1921. end() {
  1922. return this._layer;
  1923. }
  1924. optimisePagingFeatureQueries() {
  1925. }
  1926. async loadImpl() {
  1927. return await Promise.all([this._layer.load(), this.relatedLayer.load()]), this._initialiseFeatureSet(), this;
  1928. }
  1929. nativeCapabilities() {
  1930. return this.relatedLayer.nativeCapabilities();
  1931. }
  1932. _initialiseFeatureSet() {
  1933. if (this.spatialReference == null && (this.spatialReference = this._layer.spatialReference), this.geometryType = this.relatedLayer.geometryType, this.fields = this.relatedLayer.fields.slice(0), this._overrideFields !== null)
  1934. if (this._overrideFields.length === 1 && this._overrideFields[0] === "*")
  1935. this._overrideFields = null;
  1936. else {
  1937. const e5 = [], t4 = [];
  1938. for (const i3 of this.fields)
  1939. if (i3.type === "oid")
  1940. e5.push(i3), t4.push(i3.name);
  1941. else
  1942. for (const r of this._overrideFields)
  1943. if (r.toLowerCase() === i3.name.toLowerCase()) {
  1944. e5.push(i3), t4.push(i3.name);
  1945. break;
  1946. }
  1947. this.fields = e5, this._overrideFields = t4;
  1948. }
  1949. const e4 = this._layer.nativeCapabilities();
  1950. e4 && (this._databaseType = e4.databaseType, this._requestStandardised = e4.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;
  1951. }
  1952. async databaseType() {
  1953. return await this.relatedLayer.databaseType(), this._databaseType = this.relatedLayer._databaseType, this._databaseType;
  1954. }
  1955. isTable() {
  1956. return this.relatedLayer.isTable();
  1957. }
  1958. _isInFeatureSet() {
  1959. return i.InFeatureSet;
  1960. }
  1961. _candidateIdTransform(e4) {
  1962. return e4;
  1963. }
  1964. async _getSet(e4) {
  1965. if (this._wset === null) {
  1966. await this._ensureLoaded();
  1967. const t4 = await this._getFilteredSet("", null, null, null, e4);
  1968. return this._wset = t4, t4;
  1969. }
  1970. return this._wset;
  1971. }
  1972. _changeFeature(t4) {
  1973. const i3 = {};
  1974. for (const e4 of this.fields)
  1975. i3[e4.name] = t4.attributes[e4.name];
  1976. return new g({ geometry: this._removeGeometry === true ? null : t4.geometry, attributes: i3 });
  1977. }
  1978. async _getFilteredSet(e4, t4, r, s6, n9) {
  1979. if (await this.databaseType(), this.isTable() && t4 && e4 !== null && e4 !== "") {
  1980. return new t2([], [], true, null);
  1981. }
  1982. const l2 = this._layer.nativeCapabilities();
  1983. if (l2.canQueryRelated === false) {
  1984. return new t2([], [], true, null);
  1985. }
  1986. if (l2.capabilities.queryRelated && l2.capabilities.queryRelated.supportsPagination)
  1987. return this._getFilteredSetUsingPaging(e4, t4, r, s6, n9);
  1988. let d6 = "", o2 = false;
  1989. s6 !== null && l2.capabilities && l2.capabilities.queryRelated && l2.capabilities.queryRelated.supportsOrderBy === true && (d6 = s6.constructClause(), o2 = true);
  1990. const u2 = new d5();
  1991. u2.objectIds = [this._findObjectId];
  1992. const h4 = this._overrideFields !== null ? this._overrideFields : this._fieldsIncludingObjectId(this.relatedLayer.fields ? this.relatedLayer.fields.map((e5) => e5.name) : ["*"]);
  1993. u2.outFields = h4, u2.relationshipId = this.relationship.id, u2.where = "1=1";
  1994. let c3 = true;
  1995. this._removeGeometry === true && (c3 = false), u2.returnGeometry = c3, this._requestStandardised && (u2.sqlFormat = "standard"), u2.outSpatialReference = this.spatialReference, u2.orderByFields = d6 !== "" ? d6.split(",") : null;
  1996. const y3 = await l2.source.queryRelatedFeatures(u2);
  1997. this._checkCancelled(n9);
  1998. const p2 = y3[this._findObjectId] ? y3[this._findObjectId].features : [], f3 = [];
  1999. for (let i3 = 0; i3 < p2.length; i3++)
  2000. this._featureCache[p2[i3].attributes[this.relatedLayer.objectIdField]] = p2[i3], f3.push(p2[i3].attributes[this.relatedLayer.objectIdField]);
  2001. const g3 = t4 && e4 !== null && e4 !== "", _2 = r != null;
  2002. return new t2(g3 || _2 ? f3 : [], g3 || _2 ? [] : f3, o2, null);
  2003. }
  2004. _fieldsIncludingObjectId(e4) {
  2005. if (e4 === null)
  2006. return [this.objectIdField];
  2007. const t4 = e4.slice(0);
  2008. if (t4.includes("*"))
  2009. return t4;
  2010. let i3 = false;
  2011. for (const r of t4)
  2012. if (r.toUpperCase() === this.objectIdField.toUpperCase()) {
  2013. i3 = true;
  2014. break;
  2015. }
  2016. return i3 === false && t4.push(this.objectIdField), t4;
  2017. }
  2018. async _getFilteredSetUsingPaging(e4, t4, r, s6, a5) {
  2019. let n9 = "", l2 = false;
  2020. const d6 = this._layer.nativeCapabilities();
  2021. s6 !== null && d6 && d6.capabilities.queryRelated && d6.capabilities.queryRelated.supportsOrderBy === true && (n9 = s6.constructClause(), l2 = true), await this.databaseType();
  2022. const o2 = "1=1";
  2023. let u2 = this._maxQueryRate();
  2024. const h4 = d6.capabilities.query.maxRecordCount;
  2025. h4 !== void 0 && h4 < u2 && (u2 = h4);
  2026. const c3 = t4 && e4 !== null && e4 !== "", y3 = r != null;
  2027. let p2 = null, f3 = true;
  2028. this._removeGeometry === true && (f3 = false);
  2029. const g3 = this._overrideFields !== null ? this._overrideFields : this._fieldsIncludingObjectId(this.relatedLayer.fields ? this.relatedLayer.fields.map((e5) => e5.name) : ["*"]);
  2030. return p2 = new t2(c3 || y3 ? ["GETPAGES"] : [], c3 || y3 ? [] : ["GETPAGES"], l2, { outFields: g3.join(","), resultRecordCount: u2, resultOffset: 0, objectIds: [this._findObjectId], where: o2, orderByFields: n9, returnGeometry: f3, returnIdsOnly: "false", internal: { set: [], lastRetrieved: 0, lastPage: 0, fullyResolved: false } }), await this._expandPagedSet(p2, u2, 0, 0, a5), p2;
  2031. }
  2032. _expandPagedSet(e4, t4, i3, r, s6) {
  2033. return this._expandPagedSetFeatureSet(e4, t4, i3, r, s6);
  2034. }
  2035. _clonePageDefinition(e4) {
  2036. return e4 === null ? null : e4.groupbypage !== true ? { groupbypage: false, outFields: e4.outFields, resultRecordCount: e4.resultRecordCount, resultOffset: e4.resultOffset, where: e4.where, objectIds: e4.objectIds, orderByFields: e4.orderByFields, returnGeometry: e4.returnGeometry, returnIdsOnly: e4.returnIdsOnly, internal: e4.internal } : { groupbypage: true, outFields: e4.outFields, resultRecordCount: e4.resultRecordCount, useOIDpagination: e4.useOIDpagination, generatedOid: e4.generatedOid, groupByFieldsForStatistics: e4.groupByFieldsForStatistics, resultOffset: e4.resultOffset, outStatistics: e4.outStatistics, geometry: e4.geometry, where: e4.where, objectIds: e4.objectIds, orderByFields: e4.orderByFields, returnGeometry: e4.returnGeometry, returnIdsOnly: e4.returnIdsOnly, internal: e4.internal };
  2037. }
  2038. async _getPhysicalPage(e4, t4, i3) {
  2039. const r = e4.pagesDefinition.internal.lastRetrieved, s6 = r, n9 = e4.pagesDefinition.internal.lastPage, l2 = this._layer.nativeCapabilities(), d6 = new d5();
  2040. this._requestStandardised === true && (d6.sqlFormat = "standard"), d6.relationshipId = this.relationship.id, d6.objectIds = e4.pagesDefinition.objectIds, d6.resultOffset = e4.pagesDefinition.internal.lastPage, d6.resultRecordCount = e4.pagesDefinition.resultRecordCount, d6.outFields = e4.pagesDefinition.outFields.split(","), d6.where = e4.pagesDefinition.where, d6.orderByFields = e4.pagesDefinition.orderByFields !== "" ? e4.pagesDefinition.orderByFields.split(",") : null, d6.returnGeometry = e4.pagesDefinition.returnGeometry, d6.outSpatialReference = this.spatialReference;
  2041. const o2 = await l2.source.queryRelatedFeatures(d6);
  2042. if (this._checkCancelled(i3), e4.pagesDefinition.internal.lastPage !== n9)
  2043. return 0;
  2044. const u2 = o2[this._findObjectId] ? o2[this._findObjectId].features : [];
  2045. for (let a5 = 0; a5 < u2.length; a5++)
  2046. e4.pagesDefinition.internal.set[s6 + a5] = u2[a5].attributes[this.relatedLayer.objectIdField];
  2047. for (let a5 = 0; a5 < u2.length; a5++)
  2048. this._featureCache[u2[a5].attributes[this.relatedLayer.objectIdField]] = u2[a5];
  2049. const h4 = !o2[this._findObjectId] || o2[this._findObjectId].exceededTransferLimit === false;
  2050. return u2.length !== e4.pagesDefinition.resultRecordCount && h4 && (e4.pagesDefinition.internal.fullyResolved = true), e4.pagesDefinition.internal.lastRetrieved = r + u2.length, e4.pagesDefinition.internal.lastPage += e4.pagesDefinition.resultRecordCount, u2.length;
  2051. }
  2052. async _getFeatures(e4, t4, i3, r) {
  2053. const s6 = [];
  2054. t4 !== -1 && this._featureCache[t4] === void 0 && s6.push(t4);
  2055. const a5 = this._maxQueryRate();
  2056. if (this._checkIfNeedToExpandKnownPage(e4, a5) === true)
  2057. return await this._expandPagedSet(e4, a5, 0, 0, r), this._getFeatures(e4, t4, i3, r);
  2058. let n9 = 0;
  2059. for (let l2 = e4._lastFetchedIndex; l2 < e4._known.length && (n9++, n9 <= i3 && (e4._lastFetchedIndex += 1), !(e4._known[l2] !== "GETPAGES" && this._featureCache[e4._known[l2]] === void 0 && (e4._known[l2] !== t4 && s6.push(e4._known[l2]), s6.length > i3))) && !(n9 >= i3 && s6.length === 0); l2++)
  2060. ;
  2061. if (s6.length === 0)
  2062. return "success";
  2063. throw new Error("Unaccounted for Features. Not in Feature Collection");
  2064. }
  2065. async _refineSetBlock(e4, t4, i3) {
  2066. return e4;
  2067. }
  2068. async _stat(e4, t4, i3, r, s6, a5, n9) {
  2069. return { calculated: false };
  2070. }
  2071. get gdbVersion() {
  2072. return this.relatedLayer.gdbVersion;
  2073. }
  2074. async _canDoAggregates(e4, t4, i3, r, s6) {
  2075. return false;
  2076. }
  2077. relationshipMetaData() {
  2078. return this.relatedLayer.relationshipMetaData();
  2079. }
  2080. serviceUrl() {
  2081. return this.relatedLayer.serviceUrl();
  2082. }
  2083. queryAttachments(e4, t4, i3, r, s6) {
  2084. return this.relatedLayer.queryAttachments(e4, t4, i3, r, s6);
  2085. }
  2086. getFeatureByObjectId(e4, t4) {
  2087. return this.relatedLayer.getFeatureByObjectId(e4, t4);
  2088. }
  2089. getOwningSystemUrl() {
  2090. return this.relatedLayer.getOwningSystemUrl();
  2091. }
  2092. getIdentityUser() {
  2093. return this.relatedLayer.getIdentityUser();
  2094. }
  2095. getDataSourceFeatureSet() {
  2096. return this.relatedLayer;
  2097. }
  2098. };
  2099. // node_modules/@arcgis/core/arcade/featureSetUtils.js
  2100. function _() {
  2101. a2.applicationCache === null && (a2.applicationCache = new a2());
  2102. }
  2103. async function w2(e4, t4) {
  2104. if (a2.applicationCache) {
  2105. const r = a2.applicationCache.getLayerInfo(e4);
  2106. if (r) {
  2107. const a5 = await r;
  2108. return new Ke({ url: e4, outFields: t4, sourceJSON: a5 });
  2109. }
  2110. const n9 = new Ke({ url: e4, outFields: t4 }), i3 = (async () => (await n9.load(), n9.sourceJSON))();
  2111. if (a2.applicationCache) {
  2112. a2.applicationCache.setLayerInfo(e4, i3);
  2113. try {
  2114. return await i3, n9;
  2115. } catch (a5) {
  2116. throw a2.applicationCache.clearLayerInfo(e4), a5;
  2117. }
  2118. }
  2119. return await i3, n9;
  2120. }
  2121. return new Ke({ url: e4, outFields: t4 });
  2122. }
  2123. async function I(e4, t4, a5, r, n9, i3 = null) {
  2124. return S3(await w2(e4, ["*"]), t4, a5, r, n9, i3);
  2125. }
  2126. function S3(e4, t4 = null, a5 = null, r = true, n9 = null, i3 = null) {
  2127. return e4._hasMemorySource() === true ? new y2({ layer: e4, spatialReference: t4, outFields: a5, includeGeometry: r, lrucache: n9, interceptor: i3 }) : new P({ layer: e4, spatialReference: t4, outFields: a5, includeGeometry: r, lrucache: n9, interceptor: i3 });
  2128. }
  2129. async function N2(e4) {
  2130. if (a2.applicationCache !== null) {
  2131. const t4 = a2.applicationCache.getLayerInfo(e4);
  2132. if (t4 !== null)
  2133. return t4;
  2134. }
  2135. const a5 = (async () => {
  2136. const a6 = await U(e4, { responseType: "json", query: { f: "json" } });
  2137. return a6.data ? a6.data : null;
  2138. })();
  2139. if (a2.applicationCache !== null) {
  2140. a2.applicationCache.setLayerInfo(e4, a5);
  2141. try {
  2142. return await a5;
  2143. } catch (r) {
  2144. throw a2.applicationCache.clearLayerInfo(e4), r;
  2145. }
  2146. }
  2147. return a5;
  2148. }
  2149. async function F2(e4, a5) {
  2150. const r = "QUERYDATAELEMTS:" + a5.toString() + ":" + e4;
  2151. if (a2.applicationCache !== null) {
  2152. const e5 = a2.applicationCache.getLayerInfo(r);
  2153. if (e5 !== null)
  2154. return e5;
  2155. }
  2156. const n9 = (async () => {
  2157. const r2 = await U(e4 + "/queryDataElements", { method: "post", responseType: "json", query: { layers: JSON.stringify([a5.toString()]), f: "json" } });
  2158. if (r2.data) {
  2159. const e5 = r2.data;
  2160. if (e5.layerDataElements && e5.layerDataElements[0])
  2161. return e5.layerDataElements[0];
  2162. }
  2163. throw new Error("Not Found");
  2164. })();
  2165. if (a2.applicationCache !== null) {
  2166. a2.applicationCache.setLayerInfo(r, n9);
  2167. try {
  2168. return await n9;
  2169. } catch (i3) {
  2170. throw a2.applicationCache.clearLayerInfo(r), i3;
  2171. }
  2172. }
  2173. return n9;
  2174. }
  2175. async function T2(e4) {
  2176. if (a2.applicationCache !== null) {
  2177. const t4 = a2.applicationCache.getLayerInfo(e4);
  2178. if (t4 !== null)
  2179. return t4;
  2180. }
  2181. const a5 = (async () => {
  2182. const a6 = await U(e4, { responseType: "json", query: { f: "json" } });
  2183. if (a6.data) {
  2184. const e5 = a6.data;
  2185. return e5.layers || (e5.layers = []), e5.tables || (e5.tables = []), e5;
  2186. }
  2187. return { layers: [], tables: [] };
  2188. })();
  2189. if (a2.applicationCache !== null) {
  2190. a2.applicationCache.setLayerInfo(e4, a5);
  2191. try {
  2192. return await a5;
  2193. } catch (r) {
  2194. throw a2.applicationCache.clearLayerInfo(e4), r;
  2195. }
  2196. }
  2197. return a5;
  2198. }
  2199. async function g2(e4, t4) {
  2200. const a5 = { metadata: null, networkId: -1, unVersion: 3, terminals: [], queryelem: null, layerNameLkp: {}, lkp: null }, r = await T2(e4);
  2201. if (a5.metadata = r, r.controllerDatasetLayers && r.controllerDatasetLayers.utilityNetworkLayerId !== void 0 && r.controllerDatasetLayers.utilityNetworkLayerId !== null) {
  2202. if (r.layers)
  2203. for (const e5 of r.layers)
  2204. a5.layerNameLkp[e5.id] = e5.name;
  2205. if (r.tables)
  2206. for (const e5 of r.tables)
  2207. a5.layerNameLkp[e5.id] = e5.name;
  2208. const n9 = r.controllerDatasetLayers.utilityNetworkLayerId;
  2209. a5.networkId = n9;
  2210. const i3 = await F2(e4, n9);
  2211. if (i3) {
  2212. a5.queryelem = i3, a5.queryelem && a5.queryelem.dataElement && a5.queryelem.dataElement.schemaGeneration !== void 0 && (a5.unVersion = a5.queryelem.dataElement.schemaGeneration), a5.lkp = {}, a5.queryelem.dataElement.domainNetworks || (a5.queryelem.dataElement.domainNetworks = []);
  2213. for (const e5 of a5.queryelem.dataElement.domainNetworks) {
  2214. for (const t5 of e5.edgeSources ? e5.edgeSources : []) {
  2215. const e6 = { layerId: t5.layerId, sourceId: t5.sourceId, className: a5.layerNameLkp[t5.layerId] ? a5.layerNameLkp[t5.layerId] : null };
  2216. e6.className && (a5.lkp[e6.className] = e6);
  2217. }
  2218. for (const t5 of e5.junctionSources ? e5.junctionSources : []) {
  2219. const e6 = { layerId: t5.layerId, sourceId: t5.sourceId, className: a5.layerNameLkp[t5.layerId] ? a5.layerNameLkp[t5.layerId] : null };
  2220. e6.className && (a5.lkp[e6.className] = e6);
  2221. }
  2222. }
  2223. if (a5.queryelem.dataElement.terminalConfigurations)
  2224. for (const e5 of a5.queryelem.dataElement.terminalConfigurations)
  2225. for (const t5 of e5.terminals)
  2226. a5.terminals.push({ terminalId: t5.terminalId, terminalName: t5.terminalName });
  2227. const r2 = await N2(e4 + "/" + n9);
  2228. if (r2.systemLayers && r2.systemLayers.associationsTableId !== void 0 && r2.systemLayers.associationsTableId !== null) {
  2229. const n10 = [];
  2230. a5.unVersion >= 4 && (n10.push("STATUS"), n10.push("PERCENTALONG"));
  2231. let i4 = await I(e4 + "/" + r2.systemLayers.associationsTableId.toString(), t4, ["OBJECTID", "FROMNETWORKSOURCEID", "TONETWORKSOURCEID", "FROMGLOBALID", "TOGLOBALID", "TOTERMINALID", "FROMTERMINALID", "ASSOCIATIONTYPE", "ISCONTENTVISIBLE", "GLOBALID", ...n10], false, null, null);
  2232. return await i4.load(), a5.unVersion >= 4 && (i4 = i4.filter(m.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)", i4.getFieldsIndex())), await i4.load()), { lkp: a5.lkp, associations: i4, unVersion: a5.unVersion, terminals: a5.terminals };
  2233. }
  2234. return { associations: null, unVersion: a5.unVersion, lkp: null, terminals: [] };
  2235. }
  2236. return { associations: null, unVersion: a5.unVersion, lkp: null, terminals: [] };
  2237. }
  2238. return { associations: null, unVersion: a5.unVersion, lkp: null, terminals: [] };
  2239. }
  2240. async function A2(e4, t4, a5, r = null, n9 = null, i3 = true, s6 = null, l2 = null) {
  2241. let o2 = e4.serviceUrl();
  2242. if (!o2)
  2243. return null;
  2244. o2 = o2.charAt(o2.length - 1) === "/" ? o2 + t4.relatedTableId.toString() : o2 + "/" + t4.relatedTableId.toString();
  2245. const u2 = await I(o2, r, n9, i3, s6, l2);
  2246. return new n8({ layer: e4, relatedLayer: u2, relationship: t4, objectId: a5, spatialReference: r, outFields: n9, includeGeometry: i3, lrucache: s6, interceptor: l2 });
  2247. }
  2248. h3.registerAction(), A.registerAction(), s4.registerAction(), c2.registerAction(), s5.registerAction();
  2249. var C2 = class extends e2 {
  2250. constructor(e4, t4 = null, a5 = null, r = null) {
  2251. super(), this._map = e4, this._overridespref = t4, this.lrucache = a5, this.interceptor = r, this._instantLayers = [];
  2252. }
  2253. _makeAndAddFeatureSet(e4, t4 = true, a5 = null) {
  2254. const r = S3(e4, this._overridespref, a5 === null ? ["*"] : a5, t4, this.lrucache, this.interceptor);
  2255. return this._instantLayers.push({ featureset: r, opitem: e4, includeGeometry: t4, outFields: JSON.stringify(a5) }), r;
  2256. }
  2257. async featureSetByName(e4, t4 = true, a5 = null) {
  2258. if (this._map.loaded !== void 0 && this._map.load !== void 0 && this._map.loaded === false)
  2259. return await this._map.load(), this.featureSetByName(e4, t4, a5);
  2260. a5 === null && (a5 = ["*"]), a5 = (a5 = a5.slice(0)).sort();
  2261. const r = JSON.stringify(a5);
  2262. for (let i3 = 0; i3 < this._instantLayers.length; i3++) {
  2263. const a6 = this._instantLayers[i3];
  2264. if (a6.opitem.title === e4 && a6.includeGeometry === t4 && a6.outFields === r)
  2265. return this._instantLayers[i3].featureset;
  2266. }
  2267. const n9 = this._map.allLayers.find((t5) => t5 instanceof Ke && t5.title === e4);
  2268. if (n9)
  2269. return this._makeAndAddFeatureSet(n9, t4, a5);
  2270. if (this._map.tables) {
  2271. const r2 = this._map.tables.find((t5) => !!(t5.title && t5.title === e4 || t5.title && t5.title === e4));
  2272. if (r2) {
  2273. if (r2 instanceof Ke)
  2274. return this._makeAndAddFeatureSet(r2, t4, a5);
  2275. if (r2._materializedTable)
  2276. ;
  2277. else {
  2278. const e5 = r2.outFields ? r2 : { ...r2, outFields: ["*"] };
  2279. r2._materializedTable = new Ke(e5);
  2280. }
  2281. return await r2._materializedTable.load(), this._makeAndAddFeatureSet(r2._materializedTable, t4, a5);
  2282. }
  2283. }
  2284. return null;
  2285. }
  2286. async featureSetById(e4, t4 = true, a5 = ["*"]) {
  2287. if (this._map.loaded !== void 0 && this._map.load !== void 0 && this._map.loaded === false)
  2288. return await this._map.load(), this.featureSetById(e4, t4, a5);
  2289. a5 === null && (a5 = ["*"]), a5 = (a5 = a5.slice(0)).sort();
  2290. const r = JSON.stringify(a5);
  2291. for (let i3 = 0; i3 < this._instantLayers.length; i3++) {
  2292. const a6 = this._instantLayers[i3];
  2293. if (a6.opitem.id === e4 && a6.includeGeometry === t4 && a6.outFields === r)
  2294. return this._instantLayers[i3].featureset;
  2295. }
  2296. const n9 = this._map.allLayers.find((t5) => t5 instanceof Ke && t5.id === e4);
  2297. if (n9)
  2298. return this._makeAndAddFeatureSet(n9, t4, a5);
  2299. if (this._map.tables) {
  2300. const r2 = this._map.tables.find((t5) => t5.id === e4);
  2301. if (r2) {
  2302. if (r2 instanceof Ke)
  2303. return this._makeAndAddFeatureSet(r2, t4, a5);
  2304. if (r2._materializedTable)
  2305. ;
  2306. else {
  2307. const e5 = { ...r2, outFields: ["*"] };
  2308. r2._materializedTable = new Ke(e5);
  2309. }
  2310. return await r2._materializedTable.load(), this._makeAndAddFeatureSet(r2._materializedTable, t4, a5);
  2311. }
  2312. }
  2313. return null;
  2314. }
  2315. };
  2316. var k4 = class extends e2 {
  2317. constructor(e4, t4 = null, a5 = null, r = null) {
  2318. super(), this._url = e4, this._overridespref = t4, this.lrucache = a5, this.interceptor = r, this.metadata = null, this._instantLayers = [];
  2319. }
  2320. get url() {
  2321. return this._url;
  2322. }
  2323. _makeAndAddFeatureSet(e4, t4 = true, a5 = null) {
  2324. const r = S3(e4, this._overridespref, a5 === null ? ["*"] : a5, t4, this.lrucache);
  2325. return this._instantLayers.push({ featureset: r, opitem: e4, includeGeometry: t4, outFields: JSON.stringify(a5) }), r;
  2326. }
  2327. async _loadMetaData() {
  2328. const e4 = await T2(this._url);
  2329. return this.metadata = e4, e4;
  2330. }
  2331. load() {
  2332. return this._loadMetaData();
  2333. }
  2334. clone() {
  2335. return new k4(this._url, this._overridespref, this.lrucache, this.interceptor);
  2336. }
  2337. async featureSetByName(e4, t4 = true, a5 = null) {
  2338. a5 === null && (a5 = ["*"]), a5 = (a5 = a5.slice(0)).sort();
  2339. const r = JSON.stringify(a5);
  2340. for (let s6 = 0; s6 < this._instantLayers.length; s6++) {
  2341. const a6 = this._instantLayers[s6];
  2342. if (a6.opitem.title === e4 && a6.includeGeometry === t4 && a6.outFields === r)
  2343. return this._instantLayers[s6].featureset;
  2344. }
  2345. const n9 = await this._loadMetaData();
  2346. let i3 = null;
  2347. for (const s6 of n9.layers ? n9.layers : [])
  2348. s6.name === e4 && (i3 = s6);
  2349. if (!i3)
  2350. for (const s6 of n9.tables ? n9.tables : [])
  2351. s6.name === e4 && (i3 = s6);
  2352. if (i3) {
  2353. const e5 = await w2(this._url + "/" + i3.id, ["*"]);
  2354. return this._makeAndAddFeatureSet(e5, t4, a5);
  2355. }
  2356. return null;
  2357. }
  2358. async featureSetById(e4, t4 = true, a5 = ["*"]) {
  2359. a5 === null && (a5 = ["*"]), a5 = (a5 = a5.slice(0)).sort();
  2360. const r = JSON.stringify(a5);
  2361. e4 = e4 != null ? e4.toString() : "";
  2362. for (let s6 = 0; s6 < this._instantLayers.length; s6++) {
  2363. const a6 = this._instantLayers[s6];
  2364. if (a6.opitem.id === e4 && a6.includeGeometry === t4 && a6.outFields === r)
  2365. return this._instantLayers[s6].featureset;
  2366. }
  2367. const n9 = await this._loadMetaData();
  2368. let i3 = null;
  2369. for (const s6 of n9.layers ? n9.layers : [])
  2370. s6.id !== null && s6.id !== void 0 && s6.id.toString() === e4 && (i3 = s6);
  2371. if (!i3)
  2372. for (const s6 of n9.tables ? n9.tables : [])
  2373. s6.id !== null && s6.id !== void 0 && s6.id.toString() === e4 && (i3 = s6);
  2374. if (i3) {
  2375. const e5 = await w2(this._url + "/" + i3.id, ["*"]);
  2376. return this._makeAndAddFeatureSet(e5, t4, a5);
  2377. }
  2378. return null;
  2379. }
  2380. };
  2381. function j(e4, t4, a5 = null, r = null) {
  2382. return new C2(e4, t4, a5, r);
  2383. }
  2384. function O(e4, t4, a5 = null, r = null) {
  2385. return new k4(e4, t4, a5, r);
  2386. }
  2387. function E2(e4, t4) {
  2388. if (e4 === null)
  2389. return t4;
  2390. return new B({ url: e4.field("url") });
  2391. }
  2392. async function b4(a5, r, n9) {
  2393. if (!n2.findCredential(a5.restUrl))
  2394. return null;
  2395. if (a5.loadStatus === "loaded" && r === "" && a5.user && a5.user.sourceJSON && n9 === false)
  2396. return a5.user.sourceJSON;
  2397. if (r === "") {
  2398. const e4 = await U(a5.restUrl + "/community/self", { responseType: "json", query: { f: "json", ...n9 === false ? {} : { returnUserLicenseTypeExtensions: true } } });
  2399. if (e4.data) {
  2400. const t4 = e4.data;
  2401. if (t4 && t4.username)
  2402. return t4;
  2403. }
  2404. return null;
  2405. }
  2406. const i3 = await U(a5.restUrl + "/community/users/" + r, { responseType: "json", query: { f: "json" } });
  2407. if (i3.data) {
  2408. const e4 = i3.data;
  2409. return e4.error ? null : e4;
  2410. }
  2411. return null;
  2412. }
  2413. function D3(e4, t4, a5, r, n9) {
  2414. if (e4 === null)
  2415. return null;
  2416. if (e4 instanceof Ke) {
  2417. switch (t4) {
  2418. case "datasource":
  2419. return S3(e4, n9, e4.outFields, true, a5, r).getDataSourceFeatureSet();
  2420. case "parent":
  2421. case "root":
  2422. return S3(e4, n9, e4.outFields, true, a5, r);
  2423. }
  2424. return null;
  2425. }
  2426. if (e4 instanceof k3)
  2427. switch (t4) {
  2428. case "datasource":
  2429. return e4.getDataSourceFeatureSet();
  2430. case "parent":
  2431. return e4;
  2432. case "root":
  2433. return e4.getRootFeatureSet();
  2434. }
  2435. return null;
  2436. }
  2437. async function q(e4, t4, a5, r, n9, i3, s6, l2 = null) {
  2438. if (a2.applicationCache) {
  2439. const o3 = a2.applicationCache.getLayerInfo(e4 + ":" + i3.url);
  2440. if (o3) {
  2441. const e5 = await o3;
  2442. return S3(new Ke({ url: b(e5.url) + "/" + t4, outFields: ["*"] }), a5, r, n9, s6, l2);
  2443. }
  2444. }
  2445. const o2 = new b3({ id: e4, portal: i3 }).load();
  2446. a2.applicationCache && a2.applicationCache.setLayerInfo(e4 + ":" + i3.url, o2);
  2447. try {
  2448. const e5 = await o2;
  2449. return S3(new Ke({ url: b(e5.url) + "/" + t4, outFields: ["*"] }), a5, r, n9, s6, l2);
  2450. } catch (u2) {
  2451. throw a2.applicationCache && a2.applicationCache.clearLayerInfo(e4 + ":" + i3.url), u2;
  2452. }
  2453. }
  2454. export {
  2455. e2 as e,
  2456. h3 as h,
  2457. S2 as S,
  2458. w,
  2459. m3 as m,
  2460. v,
  2461. C,
  2462. e3 as e2,
  2463. s4 as s,
  2464. s5 as s2,
  2465. y2 as y,
  2466. _,
  2467. I,
  2468. S3 as S2,
  2469. g2 as g,
  2470. A2 as A,
  2471. j,
  2472. O,
  2473. E2 as E,
  2474. b4 as b,
  2475. D3 as D,
  2476. q
  2477. };
  2478. //# sourceMappingURL=chunk-22GTG6HL.js.map