chunk-4T5ZGMEN.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import {
  2. k2 as k
  3. } from "./chunk-PQFTYGF5.js";
  4. import {
  5. s2 as s,
  6. s3 as s2
  7. } from "./chunk-E5O6P5I2.js";
  8. import {
  9. r
  10. } from "./chunk-YXWMMD76.js";
  11. // node_modules/@arcgis/core/support/arcadeOnDemand.js
  12. var s3 = s.getLogger("esri.support.arcadeOnDemand");
  13. var c;
  14. function i() {
  15. return c || (c = (async () => {
  16. const e = await import("./arcadeUtils-Y4XBISY2.js");
  17. return { arcade: e.arcade, arcadeUtils: e, Dictionary: e.Dictionary, Feature: e.arcadeFeature };
  18. })()), c;
  19. }
  20. var n = (e, r2, t) => p.create(e, r2, t, null, ["$feature"]);
  21. var o = (e, r2, t) => p.create(e, r2, t, null, ["$feature", "$view"]);
  22. var u = (e, r2, t, a) => p.create(e, r2, t, a, ["$feature", "$view"]);
  23. var p = class {
  24. constructor(e, r2, t, a, s4, c2, i2, n2) {
  25. this.script = e, this.evaluate = s4;
  26. const o2 = Array.isArray(i2) ? i2 : i2.fields;
  27. this.fields = o2, this._syntaxTree = a, this._arcade = r2, this._arcadeDictionary = t, this._arcadeFeature = c2, this._spatialReference = n2, this._referencesGeometry = r2.scriptTouchesGeometry(this._syntaxTree), this._referencesScale = this._arcade.referencesMember(this._syntaxTree, "scale");
  28. }
  29. static async create(r2, c2, n2, o2, l, u2) {
  30. const { arcade: d, Feature: m, Dictionary: f } = await i(), y = k.fromJSON(c2);
  31. let h = null;
  32. try {
  33. h = d.parseScript(r2, u2);
  34. } catch (R) {
  35. return s3.error(new s2("arcade-bad-expression", "Failed to parse arcade script", { script: r2, error: R })), null;
  36. }
  37. const _ = l.reduce((e, r3) => ({ ...e, [r3]: null }), {});
  38. let w = null;
  39. r(o2) && (w = new f(o2), w.immutable = true, _.$config = null);
  40. const F = d.scriptUsesGeometryEngine(h), g = F && d.enableGeometrySupport(), S = d.scriptUsesFeatureSet(h) && d.enableFeatureSetSupport(), b = d.scriptIsAsync(h), x = b && d.enableAsyncSupport(), $ = { vars: _, spatialReference: y, useAsync: !!x };
  41. await Promise.all([g, S, x]);
  42. const v = /* @__PURE__ */ new Set();
  43. await d.loadDependentModules(v, h, null, b, F);
  44. const D = new f();
  45. D.immutable = false, D.setField("scale", 0);
  46. const j = d.compileScript(h, $), G = (e) => ("$view" in e && e.$view && (D.setField("scale", e.$view.scale), e.$view = D), w && (e.$config = w), j({ vars: e, spatialReference: y }));
  47. return new p(r2, d, f, h, G, new m(), n2, y);
  48. }
  49. repurposeFeature(e) {
  50. return e.geometry && !e.geometry.spatialReference && (e.geometry.spatialReference = this._spatialReference), this._arcadeFeature.repurposeFromGraphicLikeObject(e.geometry, e.attributes, { fields: this.fields }), this._arcadeFeature;
  51. }
  52. createDictionary() {
  53. return new this._arcadeDictionary();
  54. }
  55. referencesMember(e) {
  56. return this._arcade.referencesMember(this._syntaxTree, e);
  57. }
  58. referencesFunction(e) {
  59. return this._arcade.referencesFunction(this._syntaxTree, e);
  60. }
  61. referencesGeometry() {
  62. return this._referencesGeometry;
  63. }
  64. referencesScale() {
  65. return this._referencesScale;
  66. }
  67. extractFieldLiterals() {
  68. return this._arcade.extractExpectedFieldLiterals(this._syntaxTree);
  69. }
  70. };
  71. export {
  72. i,
  73. n,
  74. o,
  75. u,
  76. p
  77. };
  78. //# sourceMappingURL=chunk-4T5ZGMEN.js.map