arcadeAsyncRuntime-FS2QAHI6.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999
  1. import {
  2. B,
  3. C,
  4. M,
  5. N as N2,
  6. W,
  7. f,
  8. m,
  9. o,
  10. s as s3
  11. } from "./chunk-NS7TRIN4.js";
  12. import {
  13. dn
  14. } from "./chunk-FFRSXQUT.js";
  15. import {
  16. g
  17. } from "./chunk-WGHU7NSM.js";
  18. import "./chunk-KD6NQDSX.js";
  19. import "./chunk-DVIKBNBZ.js";
  20. import "./chunk-AXIWHIDY.js";
  21. import {
  22. J as J2
  23. } from "./chunk-PLCWBBQ4.js";
  24. import "./chunk-C3UFAVPF.js";
  25. import "./chunk-BJT4XIGU.js";
  26. import {
  27. A,
  28. D2 as D,
  29. E,
  30. F2 as F,
  31. J,
  32. K,
  33. N,
  34. Ne,
  35. P2 as P,
  36. Q,
  37. V,
  38. X,
  39. Y,
  40. Z,
  41. _,
  42. e,
  43. e2,
  44. j,
  45. k as k2,
  46. n,
  47. r,
  48. re,
  49. s2 as s,
  50. s3 as s2,
  51. se,
  52. t,
  53. u,
  54. w
  55. } from "./chunk-FT2BCPUP.js";
  56. import "./chunk-5JZ72JAQ.js";
  57. import "./chunk-OUUXJOLT.js";
  58. import "./chunk-NBKUI76A.js";
  59. import "./chunk-6334AFGG.js";
  60. import "./chunk-JKFWEHNK.js";
  61. import "./chunk-EDHROVWI.js";
  62. import "./chunk-3IRT3YKJ.js";
  63. import "./chunk-S6EFEKAU.js";
  64. import "./chunk-JGBXYDGB.js";
  65. import "./chunk-QEWF7QPH.js";
  66. import "./chunk-TV3CFJQR.js";
  67. import "./chunk-3RSFVUKZ.js";
  68. import "./chunk-HWSWTWZD.js";
  69. import "./chunk-5N7JLUJJ.js";
  70. import "./chunk-ZLNEXZAN.js";
  71. import "./chunk-5UVJ64RB.js";
  72. import "./chunk-ETGAZ7LF.js";
  73. import "./chunk-75U5LM2V.js";
  74. import "./chunk-RMDDCMKS.js";
  75. import "./chunk-VCH45Q2I.js";
  76. import "./chunk-HZRKBTHJ.js";
  77. import "./chunk-DVUG3KID.js";
  78. import "./chunk-FWSQEIAR.js";
  79. import "./chunk-VEGAOVMY.js";
  80. import {
  81. p
  82. } from "./chunk-6T6G6LCQ.js";
  83. import "./chunk-YEJL5NEF.js";
  84. import {
  85. k2 as k
  86. } from "./chunk-PQFTYGF5.js";
  87. import "./chunk-2Z2TG5CU.js";
  88. import "./chunk-6KZ2LTDA.js";
  89. import "./chunk-U2XHEJM7.js";
  90. import "./chunk-SQOPWYIT.js";
  91. import "./chunk-V6P2MAQQ.js";
  92. import "./chunk-E5O6P5I2.js";
  93. import "./chunk-SPWQ3AWG.js";
  94. import "./chunk-2TIUKVZN.js";
  95. import "./chunk-YXWMMD76.js";
  96. import "./chunk-S5KM4IGW.js";
  97. // node_modules/@arcgis/core/arcade/arcadeAsyncRuntime.js
  98. function q(e3) {
  99. return e3 && "function" == typeof e3.then;
  100. }
  101. var W2 = 100;
  102. async function V2(e3, t2) {
  103. const n2 = [];
  104. for (let r2 = 0; r2 < t2.arguments.length; r2++)
  105. n2.push(await J3(e3, t2.arguments[r2]));
  106. return n2;
  107. }
  108. async function _2(e3, t2, n2) {
  109. if (true === t2.preparsed)
  110. return n2(e3, null, t2.arguments);
  111. return n2(e3, t2, await V2(e3, t2));
  112. }
  113. var Y2 = class extends r {
  114. constructor(e3, t2) {
  115. super(), this.definition = null, this.context = null, this.definition = e3, this.context = t2;
  116. }
  117. createFunction(e3) {
  118. return (...t2) => {
  119. const n2 = { spatialReference: this.context.spatialReference, console: this.context.console, lrucache: this.context.lrucache, exports: this.context.exports, libraryResolver: this.context.libraryResolver, interceptor: this.context.interceptor, localScope: {}, depthCounter: { depth: e3.depthCounter + 1 }, globalScope: this.context.globalScope };
  120. if (n2.depthCounter.depth > 64)
  121. throw new t(e3, e.MaximumCallDepth, null);
  122. return Pe(this.definition, n2, t2, null);
  123. };
  124. }
  125. call(e3, t2) {
  126. return H(e3, t2, (n2, a, i) => {
  127. const l = { spatialReference: e3.spatialReference, services: e3.services, console: e3.console, libraryResolver: e3.libraryResolver, exports: e3.exports, lrucache: e3.lrucache, interceptor: e3.interceptor, localScope: {}, abortSignal: e3.abortSignal, globalScope: e3.globalScope, depthCounter: { depth: e3.depthCounter.depth + 1 } };
  128. if (l.depthCounter.depth > 64)
  129. throw new t(e3, e.MaximumCallDepth, t2);
  130. return Pe(this.definition, l, i, t2);
  131. });
  132. }
  133. marshalledCall(e3, t2, n2, r2) {
  134. return r2(e3, t2, async (o2, a, i) => {
  135. const l = { spatialReference: e3.spatialReference, globalScope: n2.globalScope, depthCounter: { depth: e3.depthCounter.depth + 1 }, libraryResolver: e3.libraryResolver, exports: e3.exports, console: e3.console, abortSignal: e3.abortSignal, lrucache: e3.lrucache, interceptor: e3.interceptor, localScope: {} };
  136. return i = i.map((t3) => !F(t3) || t3 instanceof s ? t3 : n(t3, e3, r2)), n(await Pe(this.definition, l, i, t2), n2, r2);
  137. });
  138. }
  139. };
  140. var z = class extends s2 {
  141. constructor(e3) {
  142. super(e3);
  143. }
  144. async global(e3) {
  145. const t2 = this.executingContext.globalScope[e3.toLowerCase()];
  146. if (t2.valueset || (t2.value = await J3(this.executingContext, t2.node), t2.valueset = true), F(t2.value) && !(t2.value instanceof s)) {
  147. const e4 = new s();
  148. e4.fn = t2.value, e4.parameterEvaluator = H, e4.context = this.executingContext, t2.value = e4;
  149. }
  150. return t2.value;
  151. }
  152. setGlobal(e3, t2) {
  153. if (F(t2))
  154. throw new t(null, e.AssignModuleFunction, null);
  155. this.executingContext.globalScope[e3.toLowerCase()] = { value: t2, valueset: true, node: null };
  156. }
  157. hasGlobal(e3) {
  158. return void 0 === this.executingContext.exports[e3] && (e3 = e3.toLowerCase()), void 0 !== this.executingContext.exports[e3];
  159. }
  160. async loadModule(e3) {
  161. let n2 = e3.spatialReference;
  162. null == n2 && (n2 = new k({ wkid: 102100 })), this.moduleScope = Ge({}, e3.customfunctions), this.executingContext = { spatialReference: n2, services: e3.services, libraryResolver: new s3(e3.libraryResolver._moduleSingletons, this.source.syntax.loadedModules), exports: {}, abortSignal: void 0 === e3.abortSignal || null === e3.abortSignal ? { aborted: false } : e3.abortSignal, globalScope: this.moduleScope, console: e3.console ? e3.console : Te, lrucache: e3.lrucache, interceptor: e3.interceptor, localScope: null, depthCounter: { depth: 1 } }, await J3(this.executingContext, this.source.syntax);
  163. }
  164. };
  165. async function H(e3, t2, n2) {
  166. if (true === t2.preparsed) {
  167. const r3 = n2(e3, null, t2.arguments);
  168. return q(r3), r3;
  169. }
  170. const r2 = n2(e3, t2, await V2(e3, t2));
  171. return q(r2), r2;
  172. }
  173. async function J3(e3, t2, n2) {
  174. if (t2.breakpoint && true !== n2) {
  175. const n3 = t2.breakpoint();
  176. return await n3, J3(e3, t2, true);
  177. }
  178. try {
  179. switch (t2 == null ? void 0 : t2.type) {
  180. case "VariableDeclarator":
  181. return await xe(e3, t2);
  182. case "ImportDeclaration":
  183. return await ve(e3, t2);
  184. case "ExportNamedDeclaration":
  185. return await be(e3, t2);
  186. case "VariableDeclaration":
  187. return await Se(e3, t2, 0);
  188. case "BlockStatement":
  189. case "Program":
  190. return await he(e3, t2);
  191. case "FunctionDeclaration":
  192. return await ye(e3, t2);
  193. case "ReturnStatement":
  194. return await ge(e3, t2);
  195. case "IfStatement":
  196. return await de(e3, t2);
  197. case "ExpressionStatement":
  198. return await we(e3, t2);
  199. case "UpdateExpression":
  200. return await ue(e3, t2);
  201. case "AssignmentExpression":
  202. return await pe(e3, t2);
  203. case "ForStatement":
  204. return await ne(e3, t2);
  205. case "WhileStatement":
  206. return await Z2(e3, t2);
  207. case "ForInStatement":
  208. return await ce(e3, t2);
  209. case "BreakStatement":
  210. return j;
  211. case "EmptyStatement":
  212. return k2;
  213. case "ContinueStatement":
  214. return A;
  215. case "TemplateElement":
  216. return await Le(e3, t2);
  217. case "TemplateLiteral":
  218. return await Ne2(e3, t2);
  219. case "Identifier":
  220. return await Me(e3, t2);
  221. case "MemberExpression":
  222. return await Ie(e3, t2);
  223. case "Literal":
  224. return t2.value;
  225. case "CallExpression":
  226. return await je(e3, t2);
  227. case "UnaryExpression":
  228. return await Fe(e3, t2);
  229. case "BinaryExpression":
  230. return await Re(e3, t2);
  231. case "LogicalExpression":
  232. return await Ae(e3, t2);
  233. case "ArrayExpression":
  234. return await Ce(e3, t2);
  235. case "ObjectExpression":
  236. return await Q2(e3, t2);
  237. case "Property":
  238. return await X2(e3, t2);
  239. default:
  240. throw new t(e3, e.Unrecognised, t2);
  241. }
  242. } catch (i) {
  243. throw u(e3, t2, i);
  244. }
  245. }
  246. async function Q2(e3, t2) {
  247. const a = [];
  248. for (let n2 = 0; n2 < t2.properties.length; n2++)
  249. a[n2] = await J3(e3, t2.properties[n2]);
  250. const i = {}, l = /* @__PURE__ */ new Map();
  251. for (let n2 = 0; n2 < a.length; n2++) {
  252. const s5 = a[n2];
  253. if (F(s5.value))
  254. throw new t(e3, e.NoFunctionInDictionary, t2);
  255. if (false === w(s5.key))
  256. throw new t(e3, e.KeyMustBeString, t2);
  257. let c = s5.key.toString();
  258. const u2 = c.toLowerCase();
  259. l.has(u2) ? c = l.get(u2) : l.set(u2, c), s5.value === k2 ? i[c] = null : i[c] = s5.value;
  260. }
  261. const s4 = new J2(i);
  262. return s4.immutable = false, s4;
  263. }
  264. async function X2(e3, t2) {
  265. const n2 = await J3(e3, t2.value);
  266. if ("Identifier" === t2.key.type)
  267. return { key: t2.key.name, value: n2 };
  268. return { key: await J3(e3, t2.key), value: n2 };
  269. }
  270. async function Z2(e3, t2) {
  271. const n2 = { testResult: true, lastAction: k2 };
  272. if (n2.testResult = await J3(e3, t2.test), false === n2.testResult)
  273. return k2;
  274. if (true !== n2.testResult)
  275. throw new t(e3, e.BooleanConditionRequired, t2);
  276. for (; true === n2.testResult && (n2.lastAction = await J3(e3, t2.body), n2.lastAction !== j) && !(n2.lastAction instanceof D); )
  277. if (n2.testResult = await J3(e3, t2.test), true !== n2.testResult && false !== n2.testResult)
  278. throw new t(e3, e.BooleanConditionRequired, t2);
  279. return n2.lastAction instanceof D ? n2.lastAction : k2;
  280. }
  281. async function $(e3, t2, n2) {
  282. const r2 = await J3(e3, t2.body);
  283. return n2.lastAction = r2, n2.lastAction === j || n2.lastAction instanceof D ? (n2.testResult = false, n2) : null !== t2.update ? (await J3(e3, t2.update), n2) : n2;
  284. }
  285. async function ee(e3, t2, n2) {
  286. var _a;
  287. if (null !== t2.test) {
  288. const a = await J3(e3, t2.test);
  289. if (true === ((_a = e3.abortSignal) == null ? void 0 : _a.aborted))
  290. throw new t(e3, e.Cancelled, t2);
  291. if (n2.testResult = a, false === n2.testResult)
  292. return n2;
  293. if (true !== n2.testResult)
  294. throw new t(e3, e.BooleanConditionRequired, t2);
  295. return $(e3, t2, n2);
  296. }
  297. return $(e3, t2, n2);
  298. }
  299. function te(e3, t2, n2, r2, o2, a) {
  300. try {
  301. ee(e3, t2, n2).then(() => {
  302. try {
  303. true === n2.testResult ? ++a > W2 ? (a = 0, setTimeout(() => {
  304. te(e3, t2, n2, r2, o2, a);
  305. }, 0)) : te(e3, t2, n2, r2, o2, a) : n2.lastAction instanceof D ? r2(n2.lastAction) : r2(k2);
  306. } catch (i) {
  307. o2(i);
  308. }
  309. }, (e4) => {
  310. o2(e4);
  311. });
  312. } catch (i) {
  313. o2(i);
  314. }
  315. }
  316. function ne(e3, t2) {
  317. try {
  318. return null !== t2.init ? J3(e3, t2.init).then(() => new Promise((n2, r2) => {
  319. te(e3, t2, { testResult: true, lastAction: k2 }, (e4) => {
  320. n2(e4);
  321. }, (e4) => {
  322. r2(e4);
  323. }, 0);
  324. })) : new Promise((n2, r2) => {
  325. te(e3, t2, { testResult: true, lastAction: k2 }, (e4) => {
  326. n2(e4);
  327. }, (e4) => {
  328. r2(e4);
  329. }, 0);
  330. });
  331. } catch (n2) {
  332. return Promise.reject(n2);
  333. }
  334. }
  335. function re2(e3, t2, n2, r2, o2, a, i, l, s4, c) {
  336. try {
  337. if (r2 <= a)
  338. return void l(k2);
  339. o2.value = "k" === i ? n2[a] : a, J3(e3, t2.body).then((u2) => {
  340. try {
  341. u2 instanceof D ? l(u2) : u2 === j ? l(k2) : ++c > W2 ? (c = 0, setTimeout(() => {
  342. re2(e3, t2, n2, r2, o2, a + 1, i, l, s4, c);
  343. }, 0)) : re2(e3, t2, n2, r2, o2, a + 1, i, l, s4, c);
  344. } catch (f2) {
  345. s4(f2);
  346. }
  347. }, (e4) => {
  348. s4(e4);
  349. });
  350. } catch (u2) {
  351. s4(u2);
  352. }
  353. }
  354. function oe(e3, t2, n2, r2, o2, a, i, l, s4) {
  355. try {
  356. if (n2.length() <= o2)
  357. return void i(k2);
  358. r2.value = "k" === a ? n2.get(o2) : o2, J3(e3, t2.body).then((c) => {
  359. c instanceof D ? i(c) : c === j ? i(k2) : ++s4 > W2 ? (s4 = 0, setTimeout(() => {
  360. oe(e3, t2, n2, r2, o2 + 1, a, i, l, s4);
  361. }, 0)) : oe(e3, t2, n2, r2, o2 + 1, a, i, l, s4);
  362. }, (e4) => {
  363. l(e4);
  364. });
  365. } catch (c) {
  366. l(c);
  367. }
  368. }
  369. function ae(e3, t2, n2, r2, o2, a) {
  370. try {
  371. if (void 0 === a && (a = "i"), 0 === n2.length)
  372. return void r2.resolve(k2);
  373. re2(e3, t2, n2, n2.length, o2, 0, a, (e4) => {
  374. r2.resolve(e4);
  375. }, (e4) => {
  376. r2.reject(e4);
  377. }, 0);
  378. } catch (i) {
  379. r2.reject(i);
  380. }
  381. }
  382. function ie(e3, t2, n2, r2, o2, a) {
  383. try {
  384. if (void 0 === a && (a = "i"), 0 === n2.length)
  385. return void r2.resolve(k2);
  386. oe(e3, t2, n2, o2, 0, a, (e4) => {
  387. r2.resolve(e4);
  388. }, (e4) => {
  389. r2.reject(e4);
  390. }, 0);
  391. } catch (i) {
  392. r2.reject(i);
  393. }
  394. }
  395. function le(e3, t2, n2, r2, o2) {
  396. try {
  397. ae(e3, t2, n2.keys(), r2, o2, "k");
  398. } catch (a) {
  399. r2.reject(a);
  400. }
  401. }
  402. function se2(e3, t2, n2, r2, o2, a, l, s4) {
  403. try {
  404. e3.next().then((c) => {
  405. try {
  406. if (null === c)
  407. a(k2);
  408. else {
  409. const u2 = g.createFromGraphicLikeObject(c.geometry, c.attributes, r2);
  410. u2._underlyingGraphic = c, o2.value = u2;
  411. J3(t2, n2.body).then((i) => {
  412. try {
  413. i === j ? a(k2) : i instanceof D ? a(i) : ++s4 > W2 ? (s4 = 0, setTimeout(() => {
  414. se2(e3, t2, n2, r2, o2, a, l, s4);
  415. }, 0)) : se2(e3, t2, n2, r2, o2, a, l, s4);
  416. } catch (c2) {
  417. l(c2);
  418. }
  419. }, (e4) => {
  420. l(e4);
  421. });
  422. }
  423. } catch (u2) {
  424. l(u2);
  425. }
  426. }, (e4) => {
  427. l(e4);
  428. });
  429. } catch (c) {
  430. l(c);
  431. }
  432. }
  433. async function ce(e3, t2) {
  434. return new Promise((a, i) => {
  435. J3(e3, t2.right).then((l) => {
  436. try {
  437. let s4 = null;
  438. s4 = "VariableDeclaration" === t2.left.type ? J3(e3, t2.left) : Promise.resolve(), s4.then(() => {
  439. try {
  440. let s5 = "";
  441. if ("VariableDeclaration" === t2.left.type) {
  442. const e4 = t2.left.declarations[0].id;
  443. "Identifier" === e4.type && (s5 = e4.name);
  444. } else
  445. "Identifier" === t2.left.type && (s5 = t2.left.name);
  446. if (!s5)
  447. throw new t(e3, e.InvalidIdentifier, t2);
  448. s5 = s5.toLowerCase();
  449. let c = null;
  450. if (null != e3.localScope && void 0 !== e3.localScope[s5] && (c = e3.localScope[s5]), null === c && void 0 !== e3.globalScope[s5] && (c = e3.globalScope[s5]), null === c)
  451. return void i(new t(e3, e.InvalidIdentifier, t2));
  452. Y(l) || w(l) ? ae(e3, t2, l, { reject: i, resolve: a }, c) : E(l) ? ie(e3, t2, l, { reject: i, resolve: a }, c) : l instanceof J2 || J(l) ? le(e3, t2, l, { reject: i, resolve: a }, c) : P(l) ? se2(l.iterator(e3.abortSignal), e3, t2, l, c, (e4) => {
  453. a(e4);
  454. }, (e4) => {
  455. i(e4);
  456. }, 0) : ae(e3, t2, [], { reject: i, resolve: a }, c);
  457. } catch (s5) {
  458. i(s5);
  459. }
  460. }, i);
  461. } catch (s4) {
  462. i(s4);
  463. }
  464. }, i);
  465. });
  466. }
  467. async function ue(e3, t2) {
  468. const a = t2.argument;
  469. if ("MemberExpression" === a.type) {
  470. const i2 = { t: null }, l2 = await J3(e3, a.object);
  471. let s4 = null;
  472. i2.t = l2, true === a.computed ? s4 = await J3(e3, a.property) : "Identifier" === a.property.type && (s4 = a.property.name);
  473. const c = i2.t;
  474. let u2;
  475. if (Y(c)) {
  476. if (!Z(s4))
  477. throw new t(e3, e.ArrayAccessorMustBeNumber, t2);
  478. if (s4 < 0 && (s4 = c.length + s4), s4 < 0 || s4 >= c.length)
  479. throw new t(e3, e.OutOfBounds, t2);
  480. u2 = re(c[s4]), c[s4] = "++" === t2.operator ? u2 + 1 : u2 - 1;
  481. } else if (c instanceof J2) {
  482. if (false === w(s4))
  483. throw new t(e3, e.KeyAccessorMustBeString, t2);
  484. if (true !== c.hasField(s4))
  485. throw new t(e3, e.FieldNotFound, t2, { key: s4 });
  486. u2 = re(c.field(s4)), c.setField(s4, "++" === t2.operator ? u2 + 1 : u2 - 1);
  487. } else if (c instanceof z) {
  488. if (false === w(s4))
  489. throw new t(e3, e.ModuleAccessorMustBeString, t2);
  490. if (true !== c.hasGlobal(s4))
  491. throw new t(e3, e.ModuleExportNotFound, t2);
  492. u2 = re(await c.global(s4)), c.setGlobal(s4, "++" === t2.operator ? u2 + 1 : u2 - 1);
  493. } else {
  494. if (!J(c))
  495. throw E(c) ? new t(e3, e.Immutable, t2) : new t(e3, e.InvalidParameter, t2);
  496. if (false === w(s4))
  497. throw new t(e3, e.KeyAccessorMustBeString, t2);
  498. if (true !== c.hasField(s4))
  499. throw new t(e3, e.FieldNotFound, t2, { key: s4 });
  500. u2 = re(c.field(s4)), c.setField(s4, "++" === t2.operator ? u2 + 1 : u2 - 1);
  501. }
  502. return false === t2.prefix ? u2 : "++" === t2.operator ? u2 + 1 : u2 - 1;
  503. }
  504. const i = "Identifier" === t2.argument.type ? t2.argument.name.toLowerCase() : "";
  505. if (!i)
  506. throw new t(e3, e.InvalidIdentifier, t2);
  507. let l;
  508. if (null != e3.localScope && void 0 !== e3.localScope[i])
  509. return l = re(e3.localScope[i].value), e3.localScope[i] = { value: "++" === t2.operator ? l + 1 : l - 1, valueset: true, node: t2 }, false === t2.prefix ? l : "++" === t2.operator ? l + 1 : l - 1;
  510. if (void 0 !== e3.globalScope[i])
  511. return l = re(e3.globalScope[i].value), e3.globalScope[i] = { value: "++" === t2.operator ? l + 1 : l - 1, valueset: true, node: t2 }, false === t2.prefix ? l : "++" === t2.operator ? l + 1 : l - 1;
  512. throw new t(e3, e.InvalidIdentifier, t2);
  513. }
  514. function fe(e3, t2, n2, a, i) {
  515. switch (t2) {
  516. case "=":
  517. return e3 === k2 ? null : e3;
  518. case "/=":
  519. return re(n2) / re(e3);
  520. case "*=":
  521. return re(n2) * re(e3);
  522. case "-=":
  523. return re(n2) - re(e3);
  524. case "+=":
  525. return w(n2) || w(e3) ? K(n2) + K(e3) : re(n2) + re(e3);
  526. case "%=":
  527. return re(n2) % re(e3);
  528. default:
  529. throw new t(i, e.UnsupportedOperator, a);
  530. }
  531. }
  532. async function pe(e3, t2) {
  533. const a = t2.left;
  534. if ("MemberExpression" === a.type) {
  535. const i2 = await J3(e3, t2.right), l = await J3(e3, a.object);
  536. let s4 = null;
  537. if (true === a.computed)
  538. s4 = await J3(e3, a.property);
  539. else {
  540. if ("Identifier" !== a.property.type)
  541. throw new t(e3, e.InvalidIdentifier, t2);
  542. s4 = a.property.name;
  543. }
  544. if (Y(l)) {
  545. if (!Z(s4))
  546. throw new t(e3, e.ArrayAccessorMustBeNumber, t2);
  547. if (s4 < 0 && (s4 = l.length + s4), s4 < 0 || s4 > l.length)
  548. throw new t(e3, e.OutOfBounds, t2);
  549. if (s4 === l.length) {
  550. if ("=" !== t2.operator)
  551. throw new t(e3, e.OutOfBounds, t2);
  552. l[s4] = fe(i2, t2.operator, l[s4], t2, e3);
  553. } else
  554. l[s4] = fe(i2, t2.operator, l[s4], t2, e3);
  555. } else if (l instanceof J2) {
  556. if (false === w(s4))
  557. throw new t(e3, e.KeyAccessorMustBeString, t2);
  558. if (true === l.hasField(s4))
  559. l.setField(s4, fe(i2, t2.operator, l.field(s4), t2, e3));
  560. else {
  561. if ("=" !== t2.operator)
  562. throw new t(e3, e.FieldNotFound, t2, { key: s4 });
  563. l.setField(s4, fe(i2, t2.operator, null, t2, e3));
  564. }
  565. } else if (l instanceof z) {
  566. if (false === w(s4))
  567. throw new t(e3, e.KeyAccessorMustBeString, t2);
  568. if (true !== l.hasGlobal(s4))
  569. throw new t(e3, e.ModuleExportNotFound, t2);
  570. l.setGlobal(s4, fe(i2, t2.operator, await l.global(s4), t2, e3));
  571. } else {
  572. if (!J(l))
  573. throw E(l) ? new t(e3, e.Immutable, t2) : new t(e3, e.InvalidParameter, t2);
  574. if (false === w(s4))
  575. throw new t(e3, e.KeyAccessorMustBeString, t2);
  576. if (true === l.hasField(s4))
  577. l.setField(s4, fe(i2, t2.operator, l.field(s4), t2, e3));
  578. else {
  579. if ("=" !== t2.operator)
  580. throw new t(e3, e.FieldNotFound, t2, { key: s4 });
  581. l.setField(s4, fe(i2, t2.operator, null, t2, e3));
  582. }
  583. }
  584. return k2;
  585. }
  586. const i = a.name.toLowerCase();
  587. if (null != e3.localScope && void 0 !== e3.localScope[i]) {
  588. const n2 = await J3(e3, t2.right);
  589. return e3.localScope[i] = { value: fe(n2, t2.operator, e3.localScope[i].value, t2, e3), valueset: true, node: t2.right }, k2;
  590. }
  591. if (void 0 !== e3.globalScope[i]) {
  592. const n2 = await J3(e3, t2.right);
  593. return e3.globalScope[i] = { value: fe(n2, t2.operator, e3.globalScope[i].value, t2, e3), valueset: true, node: t2.right }, k2;
  594. }
  595. throw new t(e3, e.InvalidIdentifier, t2);
  596. }
  597. async function we(e3, t2) {
  598. if ("AssignmentExpression" === t2.expression.type)
  599. return J3(e3, t2.expression);
  600. if ("CallExpression" === t2.expression.type) {
  601. const n3 = await J3(e3, t2.expression);
  602. return n3 === k2 ? k2 : new N(n3);
  603. }
  604. const n2 = await J3(e3, t2.expression);
  605. return n2 === k2 ? k2 : new N(n2);
  606. }
  607. async function de(e3, t2) {
  608. const n2 = await J3(e3, t2.test);
  609. if (true === n2)
  610. return J3(e3, t2.consequent);
  611. if (false === n2)
  612. return null !== t2.alternate ? J3(e3, t2.alternate) : k2;
  613. throw new t(e3, e.BooleanConditionRequired, t2);
  614. }
  615. async function he(e3, t2) {
  616. return me(e3, t2, 0);
  617. }
  618. async function me(e3, t2, n2) {
  619. if (n2 >= t2.body.length)
  620. return k2;
  621. const r2 = await J3(e3, t2.body[n2]);
  622. return r2 instanceof D || r2 === j || r2 === A || n2 === t2.body.length - 1 ? r2 : me(e3, t2, n2 + 1);
  623. }
  624. async function ge(e3, t2) {
  625. if (null === t2.argument)
  626. return new D(k2);
  627. const n2 = await J3(e3, t2.argument);
  628. return new D(n2);
  629. }
  630. async function ye(e3, t2) {
  631. const n2 = t2.id.name.toLowerCase();
  632. return e3.globalScope[n2] = { valueset: true, node: null, value: new Y2(t2, e3) }, k2;
  633. }
  634. async function ve(e3, t2) {
  635. var _a, _b;
  636. const n2 = t2.specifiers[0].local.name.toLowerCase(), r2 = e3.libraryResolver.loadLibrary(n2);
  637. let o2 = null;
  638. return ((_a = e3.libraryResolver._moduleSingletons) == null ? void 0 : _a.has(r2.uri)) ? o2 = e3.libraryResolver._moduleSingletons.get(r2.uri) : (o2 = new z(r2), await o2.loadModule(e3), (_b = e3.libraryResolver._moduleSingletons) == null ? void 0 : _b.set(r2.uri, o2)), e3.globalScope[n2] = { value: o2, valueset: true, node: t2 }, k2;
  639. }
  640. async function be(e3, t2) {
  641. if (await J3(e3, t2.declaration), "FunctionDeclaration" === t2.declaration.type)
  642. e3.exports[t2.declaration.id.name.toLowerCase()] = "function";
  643. else if ("VariableDeclaration" === t2.declaration.type)
  644. for (const n2 of t2.declaration.declarations)
  645. e3.exports[n2.id.name.toLowerCase()] = "variable";
  646. return k2;
  647. }
  648. async function Se(e3, t2, n2) {
  649. return n2 >= t2.declarations.length ? k2 : (await J3(e3, t2.declarations[n2]), n2 === t2.declarations.length - 1 || await Se(e3, t2, n2 + 1), k2);
  650. }
  651. async function xe(e3, t2) {
  652. let n2 = null;
  653. if (n2 = null === t2.init ? null : await J3(e3, t2.init), null !== e3.localScope) {
  654. if (n2 === k2 && (n2 = null), "Identifier" !== t2.id.type)
  655. throw new t(e3, e.InvalidIdentifier, t2);
  656. const a2 = t2.id.name.toLowerCase();
  657. return null != e3.localScope && (e3.localScope[a2] = { value: n2, valueset: true, node: t2.init }), k2;
  658. }
  659. if ("Identifier" !== t2.id.type)
  660. throw new t(e3, e.InvalidIdentifier, t2);
  661. const a = t2.id.name.toLowerCase();
  662. return n2 === k2 && (n2 = null), e3.globalScope[a] = { value: n2, valueset: true, node: t2.init }, k2;
  663. }
  664. async function Ie(e3, t2) {
  665. const a = await J3(e3, t2.object);
  666. if (null === a)
  667. throw new t(e3, e.MemberOfNull, t2);
  668. if (false === t2.computed) {
  669. if ("Identifier" === t2.property.type) {
  670. if (a instanceof J2 || J(a))
  671. return a.field(t2.property.name);
  672. if (a instanceof p)
  673. return W(a, t2.property.name, e3, t2);
  674. if (a instanceof z) {
  675. if (!a.hasGlobal(t2.property.name))
  676. throw new t(e3, e.InvalidIdentifier, t2);
  677. return a.global(t2.property.name);
  678. }
  679. throw new t(e3, e.InvalidMemberAccessKey, t2);
  680. }
  681. throw new t(e3, e.InvalidMemberAccessKey, t2);
  682. }
  683. let i = await J3(e3, t2.property);
  684. if (a instanceof J2 || J(a)) {
  685. if (w(i))
  686. return a.field(i);
  687. throw new t(e3, e.InvalidMemberAccessKey, t2);
  688. }
  689. if (a instanceof z) {
  690. if (w(i))
  691. return a.global(i);
  692. throw new t(e3, e.InvalidMemberAccessKey, t2);
  693. }
  694. if (a instanceof p) {
  695. if (w(i))
  696. return W(a, i, e3, t2);
  697. throw new t(e3, e.InvalidMemberAccessKey, t2);
  698. }
  699. if (Y(a)) {
  700. if (Z(i) && isFinite(i) && Math.floor(i) === i) {
  701. if (i < 0 && (i = a.length + i), i >= a.length || i < 0)
  702. throw new t(e3, e.OutOfBounds, t2);
  703. return a[i];
  704. }
  705. throw new t(e3, e.InvalidMemberAccessKey, t2);
  706. }
  707. if (E(a)) {
  708. if (Z(i) && isFinite(i) && Math.floor(i) === i) {
  709. if (i < 0 && (i = a.length() + i), i >= a.length() || i < 0)
  710. throw new t(e3, e.OutOfBounds, t2);
  711. return a.get(i);
  712. }
  713. throw new t(e3, e.InvalidMemberAccessKey, t2);
  714. }
  715. if (w(a)) {
  716. if (Z(i) && isFinite(i) && Math.floor(i) === i) {
  717. if (i < 0 && (i = a.length + i), i >= a.length || i < 0)
  718. throw new t(e3, e.OutOfBounds, t2);
  719. return a[i];
  720. }
  721. throw new t(e3, e.InvalidMemberAccessKey, t2);
  722. }
  723. throw new t(e3, e.InvalidMemberAccessKey, t2);
  724. }
  725. async function Fe(e3, t2) {
  726. const n2 = await J3(e3, t2.argument);
  727. if (_(n2)) {
  728. if ("!" === t2.operator)
  729. return !n2;
  730. if ("-" === t2.operator)
  731. return -1 * re(n2);
  732. if ("+" === t2.operator)
  733. return 1 * re(n2);
  734. if ("~" === t2.operator)
  735. return ~re(n2);
  736. throw new t(e3, e.UnsupportedUnaryOperator, t2);
  737. }
  738. if ("-" === t2.operator)
  739. return -1 * re(n2);
  740. if ("+" === t2.operator)
  741. return 1 * re(n2);
  742. if ("~" === t2.operator)
  743. return ~re(n2);
  744. throw new t(e3, e.UnsupportedUnaryOperator, t2);
  745. }
  746. async function Ce(e3, t2) {
  747. const n2 = [];
  748. for (let r2 = 0; r2 < t2.elements.length; r2++)
  749. n2.push(await J3(e3, t2.elements[r2]));
  750. for (let a = 0; a < n2.length; a++) {
  751. if (F(n2[a]))
  752. throw new t(e3, e.NoFunctionInArray, t2);
  753. n2[a] === k2 && (n2[a] = null);
  754. }
  755. return n2;
  756. }
  757. async function Re(e3, t2) {
  758. const n2 = [];
  759. n2[0] = await J3(e3, t2.left), n2[1] = await J3(e3, t2.right);
  760. const a = n2[0], i = n2[1];
  761. switch (t2.operator) {
  762. case "|":
  763. case "<<":
  764. case ">>":
  765. case ">>>":
  766. case "^":
  767. case "&":
  768. return Ne(re(a), re(i), t2.operator);
  769. case "==":
  770. return X(a, i);
  771. case "!=":
  772. return !X(a, i);
  773. case "<":
  774. case ">":
  775. case "<=":
  776. case ">=":
  777. return Q(a, i, t2.operator);
  778. case "+":
  779. return w(a) || w(i) ? K(a) + K(i) : re(a) + re(i);
  780. case "-":
  781. return re(a) - re(i);
  782. case "*":
  783. return re(a) * re(i);
  784. case "/":
  785. return re(a) / re(i);
  786. case "%":
  787. return re(a) % re(i);
  788. default:
  789. throw new t(e3, e.UnsupportedOperator, t2);
  790. }
  791. }
  792. async function Ae(e3, t2) {
  793. const n2 = await J3(e3, t2.left);
  794. let a = null;
  795. if (!_(n2))
  796. throw new t(e3, e.LogicalExpressionOnlyBoolean, t2);
  797. switch (t2.operator) {
  798. case "||":
  799. if (true === n2)
  800. return n2;
  801. if (a = await J3(e3, t2.right), _(a))
  802. return a;
  803. throw new t(e3, e.LogicExpressionOrAnd, t2);
  804. case "&&":
  805. if (false === n2)
  806. return n2;
  807. if (a = await J3(e3, t2.right), _(a))
  808. return a;
  809. throw new t(e3, e.LogicExpressionOrAnd, t2);
  810. default:
  811. throw new t(e3, e.LogicExpressionOrAnd, t2);
  812. }
  813. }
  814. async function Me(e3, t2) {
  815. const n2 = t2.name.toLowerCase();
  816. if (null != e3.localScope && void 0 !== e3.localScope[n2]) {
  817. const t3 = e3.localScope[n2];
  818. if (true === t3.valueset)
  819. return t3.value;
  820. if (null !== t3.d)
  821. return t3.d;
  822. t3.d = J3(e3, t3.node);
  823. const r2 = await t3.d;
  824. return t3.value = r2, t3.valueset = true, r2;
  825. }
  826. if (void 0 !== e3.globalScope[n2]) {
  827. const t3 = e3.globalScope[n2];
  828. if (true === t3.valueset)
  829. return t3.value;
  830. if (null !== t3.d)
  831. return t3.d;
  832. t3.d = J3(e3, t3.node);
  833. const r2 = await t3.d;
  834. return t3.value = r2, t3.valueset = true, r2;
  835. }
  836. throw new t(e3, e.InvalidIdentifier, t2);
  837. }
  838. async function je(e3, t2) {
  839. if ("MemberExpression" === t2.callee.type) {
  840. const n2 = await J3(e3, t2.callee.object);
  841. if (!(n2 instanceof z))
  842. throw new t(e3, e.FuncionNotFound, t2);
  843. const a = false === t2.callee.computed ? t2.callee.property.name : await J3(e3, t2.callee.property);
  844. if (!n2.hasGlobal(a))
  845. throw new t(e3, e.FuncionNotFound, t2);
  846. const i = await n2.global(a);
  847. if (!F(i))
  848. throw new t(e3, e.CallNonFunction, t2);
  849. return i.call(e3, t2);
  850. }
  851. if ("Identifier" !== t2.callee.type)
  852. throw new t(e3, e.FuncionNotFound, t2);
  853. if (null != e3.localScope && void 0 !== e3.localScope[t2.callee.name.toLowerCase()]) {
  854. const n2 = e3.localScope[t2.callee.name.toLowerCase()];
  855. if (F(n2.value))
  856. return n2.value.call(e3, t2);
  857. throw new t(e3, e.CallNonFunction, t2);
  858. }
  859. if (void 0 !== e3.globalScope[t2.callee.name.toLowerCase()]) {
  860. const n2 = e3.globalScope[t2.callee.name.toLowerCase()];
  861. if (F(n2.value))
  862. return n2.value.call(e3, t2);
  863. throw new t(e3, e.CallNonFunction, t2);
  864. }
  865. throw new t(e3, e.FuncionNotFound, t2);
  866. }
  867. async function Le(e3, t2) {
  868. return t2.value ? t2.value.cooked : "";
  869. }
  870. function ke(e3, t2, n2) {
  871. if (F(e3))
  872. throw new t(t2, e.NoFunctionInTemplateLiteral, n2);
  873. return e3;
  874. }
  875. async function Ne2(e3, t2) {
  876. const n2 = [];
  877. for (let a = 0; a < t2.expressions.length; a++) {
  878. const r3 = await J3(e3, t2.expressions[a]);
  879. n2[a] = K(r3);
  880. }
  881. let r2 = "", o2 = 0;
  882. for (const a of t2.quasis)
  883. if (r2 += a.value ? a.value.cooked : "", false === a.tail) {
  884. r2 += n2[o2] ? ke(n2[o2], e3, t2) : "", o2++;
  885. }
  886. return r2;
  887. }
  888. var Oe = {};
  889. async function Ee(e3, t2, n2, r2) {
  890. const o2 = await J3(e3, t2.arguments[n2]);
  891. if (X(o2, r2))
  892. return J3(e3, t2.arguments[n2 + 1]);
  893. const a = t2.arguments.length - n2;
  894. return 1 === a ? J3(e3, t2.arguments[n2]) : 2 === a ? null : 3 === a ? J3(e3, t2.arguments[n2 + 2]) : Ee(e3, t2, n2 + 2, r2);
  895. }
  896. async function Be(e3, t2, n2, a) {
  897. if (true === a)
  898. return J3(e3, t2.arguments[n2 + 1]);
  899. if (3 === t2.arguments.length - n2)
  900. return J3(e3, t2.arguments[n2 + 2]);
  901. const i = await J3(e3, t2.arguments[n2 + 2]);
  902. if (false === _(i))
  903. throw new t(e3, e.ModuleExportNotFound, t2.arguments[n2 + 2]);
  904. return Be(e3, t2, n2 + 2, i);
  905. }
  906. async function Pe(e3, t2, n2, a) {
  907. const i = e3.body;
  908. if (n2.length !== e3.params.length)
  909. throw new t(t2, e.WrongNumberOfParameters, null);
  910. for (let r2 = 0; r2 < n2.length; r2++) {
  911. const o2 = e3.params[r2];
  912. "Identifier" === o2.type && null != t2.localScope && (t2.localScope[o2.name.toLowerCase()] = { d: null, value: n2[r2], valueset: true, node: null });
  913. }
  914. const l = await J3(t2, i);
  915. if (l instanceof D)
  916. return l.value;
  917. if (l === j)
  918. throw new t(t2, e.UnexpectedToken, a);
  919. if (l === A)
  920. throw new t(t2, e.UnexpectedToken, a);
  921. return l instanceof N ? l.value : l;
  922. }
  923. M(Oe, _2), B(Oe, _2), N2(Oe, _2), C(Oe, _2), f(Oe, _2), dn({ functions: Oe, compiled: false, signatures: null, evaluateIdentifier: null, mode: "async", standardFunction: _2, standardFunctionAsync: H }), Oe.iif = async function(e3, t2) {
  924. V(null === t2.arguments ? [] : t2.arguments, 3, 3, e3, t2);
  925. const n2 = await J3(e3, t2.arguments[0]);
  926. if (false === _(n2))
  927. throw new t(e3, e.BooleanConditionRequired, t2);
  928. return J3(e3, n2 ? t2.arguments[1] : t2.arguments[2]);
  929. }, Oe.decode = async function(e3, t2) {
  930. if (t2.arguments.length < 2)
  931. throw new t(e3, e.WrongNumberOfParameters, t2);
  932. if (2 === t2.arguments.length)
  933. return J3(e3, t2.arguments[1]);
  934. if ((t2.arguments.length - 1) % 2 == 0)
  935. throw new t(e3, e.WrongNumberOfParameters, t2);
  936. return Ee(e3, t2, 1, await J3(e3, t2.arguments[0]));
  937. }, Oe.when = async function(e3, t2) {
  938. if (t2.arguments.length < 3)
  939. throw new t(e3, e.WrongNumberOfParameters, t2);
  940. if (t2.arguments.length % 2 == 0)
  941. throw new t(e3, e.WrongNumberOfParameters, t2);
  942. const n2 = await J3(e3, t2.arguments[0]);
  943. if (false === _(n2))
  944. throw new t(e3, e.BooleanConditionRequired, t2.arguments[0]);
  945. return Be(e3, t2, 0, n2);
  946. };
  947. var Ke = { fixSpatialReference: se, parseArguments: V2, standardFunction: _2, standardFunctionAsync: H, evaluateIdentifier: Me };
  948. for (const Ve in Oe)
  949. Oe[Ve] = { value: new e2(Oe[Ve]), valueset: true, node: null };
  950. var De = function() {
  951. };
  952. function Ge(e3, t2) {
  953. const r2 = new De();
  954. null == e3 && (e3 = {}), null == t2 && (t2 = {});
  955. const o2 = new J2({ newline: "\n", tab: " ", singlequote: "'", doublequote: '"', forwardslash: "/", backwardslash: "\\" });
  956. o2.immutable = false, r2.textformatting = { value: o2, valueset: true, node: null };
  957. for (const n2 in t2)
  958. r2[n2] = { value: new e2(t2[n2]), native: true, valueset: true, node: null };
  959. for (const n2 in e3)
  960. e3[n2] && "esri.Graphic" === e3[n2].declaredClass ? r2[n2] = { value: g.createFromGraphic(e3[n2]), valueset: true, node: null } : r2[n2] = { value: e3[n2], valueset: true, node: null };
  961. return r2;
  962. }
  963. function Te(e3) {
  964. console.log(e3);
  965. }
  966. De.prototype = Oe, De.prototype.infinity = { value: Number.POSITIVE_INFINITY, valueset: true, node: null }, De.prototype.pi = { value: Math.PI, valueset: true, node: null };
  967. var Ue = Ke;
  968. function qe(e3) {
  969. const t2 = { mode: "async", compiled: false, functions: {}, signatures: [], standardFunction: _2, standardFunctionAsync: H, evaluateIdentifier: Me };
  970. for (let n2 = 0; n2 < e3.length; n2++)
  971. e3[n2].registerFunctions(t2);
  972. for (const n2 in t2.functions)
  973. Oe[n2] = { value: new e2(t2.functions[n2]), valueset: true, node: null }, De.prototype[n2] = Oe[n2];
  974. for (let n2 = 0; n2 < t2.signatures.length; n2++)
  975. o(t2.signatures[n2], "async");
  976. }
  977. async function We(e3, n2) {
  978. let a = n2.spatialReference;
  979. null == a && (a = new k({ wkid: 102100 }));
  980. let i = null;
  981. e3.usesModules && (i = new s3(/* @__PURE__ */ new Map(), e3.loadedModules));
  982. const l = Ge(n2.vars, n2.customfunctions), s4 = { spatialReference: a, services: n2.services, exports: {}, libraryResolver: i, abortSignal: void 0 === n2.abortSignal || null === n2.abortSignal ? { aborted: false } : n2.abortSignal, globalScope: l, console: n2.console ? n2.console : Te, lrucache: n2.lrucache, interceptor: n2.interceptor, localScope: null, depthCounter: { depth: 1 } };
  983. let c = await J3(s4, e3);
  984. if (c instanceof D && (c = c.value), c instanceof N && (c = c.value), c === k2 && (c = null), c === j)
  985. throw new t(s4, e.IllegalResult, null);
  986. if (c === A)
  987. throw new t(s4, e.IllegalResult, null);
  988. if (F(c))
  989. throw new t(s4, e.IllegalResult, null);
  990. return c;
  991. }
  992. qe([m]);
  993. export {
  994. We as executeScript,
  995. qe as extend,
  996. Ue as functionHelper
  997. };
  998. //# sourceMappingURL=arcadeAsyncRuntime-FS2QAHI6.js.map