chunk-UI53XRRK.js 117 KB

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