labelFormatUtils-QBH7I42E.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import {
  2. _,
  3. x
  4. } from "./chunk-3HCJD762.js";
  5. import {
  6. L,
  7. S,
  8. m
  9. } from "./chunk-TV3CFJQR.js";
  10. import {
  11. ie
  12. } from "./chunk-CRGY2SDS.js";
  13. import {
  14. n
  15. } from "./chunk-4T5ZGMEN.js";
  16. import "./chunk-5UVJ64RB.js";
  17. import "./chunk-ETGAZ7LF.js";
  18. import "./chunk-75U5LM2V.js";
  19. import "./chunk-RMDDCMKS.js";
  20. import "./chunk-VCH45Q2I.js";
  21. import "./chunk-HZRKBTHJ.js";
  22. import "./chunk-6T6G6LCQ.js";
  23. import "./chunk-YEJL5NEF.js";
  24. import "./chunk-PQFTYGF5.js";
  25. import "./chunk-2Z2TG5CU.js";
  26. import "./chunk-6KZ2LTDA.js";
  27. import "./chunk-U2XHEJM7.js";
  28. import "./chunk-SQOPWYIT.js";
  29. import "./chunk-V6P2MAQQ.js";
  30. import {
  31. s2 as s,
  32. s3 as s2
  33. } from "./chunk-E5O6P5I2.js";
  34. import "./chunk-SPWQ3AWG.js";
  35. import "./chunk-2TIUKVZN.js";
  36. import {
  37. t
  38. } from "./chunk-YXWMMD76.js";
  39. import "./chunk-S5KM4IGW.js";
  40. // node_modules/@arcgis/core/layers/support/labelFormatUtils.js
  41. var c = s.getLogger("esri.layers.support.labelFormatUtils");
  42. var f = { type: "simple", evaluate: () => null };
  43. var p = { getAttribute: (e, r) => e.field(r) };
  44. async function m2(r, a, n2) {
  45. if (!r || !r.symbol)
  46. return f;
  47. const o = r.where, i = x(r), m3 = o ? await import("./WhereClause-32BDBNIA.js") : null;
  48. let g;
  49. if ("arcade" === i.type) {
  50. const r2 = await n(i.expression, n2, a);
  51. if (t(r2))
  52. return f;
  53. g = { type: "arcade", evaluate(t2) {
  54. try {
  55. const e = r2.evaluate({ $feature: "attributes" in t2 ? r2.repurposeFeature(t2) : t2 });
  56. if (null != e)
  57. return e.toString();
  58. } catch (a2) {
  59. c.error(new s2("arcade-expression-error", "Encountered an error when evaluating label expression for feature", { feature: t2, expression: i }));
  60. }
  61. return null;
  62. }, needsHydrationToEvaluate: () => null == _(i.expression) };
  63. } else
  64. g = { type: "simple", evaluate: (e) => i.expression.replace(/{[^}]*}/g, (r2) => {
  65. const t2 = r2.slice(1, -1), n3 = a.get(t2);
  66. if (!n3)
  67. return r2;
  68. let o2 = null;
  69. if ("attributes" in e) {
  70. e && e.attributes && (o2 = e.attributes[n3.name]);
  71. } else
  72. o2 = e.field(n3.name);
  73. return null == o2 ? "" : d(o2, n3);
  74. }) };
  75. if (o) {
  76. let r2;
  77. try {
  78. r2 = m3.WhereClause.create(o, a);
  79. } catch (y) {
  80. return c.error(new s2("bad-where-clause", "Encountered an error when evaluating where clause, ignoring", { where: o, error: y })), f;
  81. }
  82. const t2 = g.evaluate;
  83. g.evaluate = (a2) => {
  84. const n3 = "attributes" in a2 ? void 0 : p;
  85. try {
  86. if (r2.testFeature(a2, n3))
  87. return t2(a2);
  88. } catch (y) {
  89. c.error(new s2("bad-where-clause", "Encountered an error when evaluating where clause for feature", { where: o, feature: a2, error: y }));
  90. }
  91. return null;
  92. };
  93. }
  94. return g;
  95. }
  96. function d(e, r) {
  97. if (null == e)
  98. return "";
  99. const t2 = r.domain;
  100. if (t2) {
  101. if ("codedValue" === t2.type || "coded-value" === t2.type) {
  102. const r2 = e;
  103. for (const e2 of t2.codedValues)
  104. if (e2.code === r2)
  105. return e2.name;
  106. } else if ("range" === t2.type) {
  107. const r2 = +e, a = "range" in t2 ? t2.range[0] : t2.minValue, n2 = "range" in t2 ? t2.range[1] : t2.maxValue;
  108. if (a <= r2 && r2 <= n2)
  109. return t2.name;
  110. }
  111. }
  112. let l = e;
  113. return "date" === r.type || "esriFieldTypeDate" === r.type ? l = L(l, S("short-date")) : ie(r) && (l = m(+l)), l || "";
  114. }
  115. export {
  116. m2 as createLabelFunction,
  117. d as formatField
  118. };
  119. //# sourceMappingURL=labelFormatUtils-QBH7I42E.js.map