chunk-YYN5W6FL.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import {
  2. d as d2
  3. } from "./chunk-R5LRKX5A.js";
  4. import {
  5. ne
  6. } from "./chunk-FYNVVMWY.js";
  7. import {
  8. C,
  9. O,
  10. _,
  11. ee,
  12. ke,
  13. t,
  14. w,
  15. z
  16. } from "./chunk-25BNEBXZ.js";
  17. import {
  18. d
  19. } from "./chunk-2Z6LERTI.js";
  20. import {
  21. j2 as j,
  22. p
  23. } from "./chunk-ECW2QABR.js";
  24. import {
  25. e,
  26. r
  27. } from "./chunk-GZT4BVFP.js";
  28. // node_modules/@arcgis/core/arcade/ArcadePortal.js
  29. var s = class extends d2 {
  30. constructor(t2) {
  31. super(), this.immutable = false, this.setField("url", t2), this.immutable = true;
  32. }
  33. };
  34. // node_modules/@arcgis/core/arcade/Feature.js
  35. var d3 = class {
  36. constructor() {
  37. this.arcadeDeclaredClass = "esri.arcade.Feature", this._optimizedGeomDefinition = null, this._geometry = null, this.attributes = null, this._layer = null, this._datesfixed = true, this.immutable = true, this._datefields = null, this.immutable = true;
  38. }
  39. static createFromGraphic(t2) {
  40. const e2 = new d3();
  41. return e2._geometry = r(t2.geometry) ? t2.geometry : null, t2.attributes === void 0 || t2.attributes === null ? e2.attributes = {} : e2.attributes = t2.attributes, t2._sourceLayer ? (e2._layer = t2._sourceLayer, e2._datesfixed = false) : t2._layer ? (e2._layer = t2._layer, e2._datesfixed = false) : t2.layer && "fields" in t2.layer ? (e2._layer = t2.layer, e2._datesfixed = false) : t2.sourceLayer && "fields" in t2.sourceLayer && (e2._layer = t2.sourceLayer, e2._datesfixed = false), e2;
  42. }
  43. static createFromArcadeFeature(t2) {
  44. const e2 = new d3();
  45. return e2._datesfixed = t2._datesfixed, e2.attributes = t2.attributes, e2._geometry = t2._geometry, e2._optimizedGeomDefinition = t2._optimizedGeomDefinition, t2._layer && (e2._layer = t2._layer), e2;
  46. }
  47. static createFromOptimisedFeature(t2, e2, i) {
  48. const s2 = new d3();
  49. return s2._geometry = t2.geometry ? { geometry: t2.geometry } : null, s2._optimizedGeomDefinition = i, s2.attributes = t2.attributes || {}, s2._layer = e2, s2._datesfixed = false, s2;
  50. }
  51. static createFromArcadeDictionary(e2) {
  52. const i = new d3();
  53. return i.attributes = e2.field("attributes"), i.attributes !== null && i.attributes instanceof d2 ? (i.attributes = i.attributes.attributes, i.attributes === null && (i.attributes = {})) : i.attributes = {}, i._geometry = e2.field("geometry"), i._geometry !== null && (i._geometry instanceof d2 ? i._geometry = d3.parseGeometryFromDictionary(i._geometry) : i._geometry instanceof p || (i._geometry = null)), i;
  54. }
  55. static createFromGraphicLikeObject(t2, e2, i = null) {
  56. const s2 = new d3();
  57. return e2 === null && (e2 = {}), s2.attributes = e2, s2._geometry = r(t2) ? t2 : null, s2._layer = i, s2._layer && (s2._datesfixed = false), s2;
  58. }
  59. repurposeFromGraphicLikeObject(t2, e2, i = null) {
  60. e2 === null && (e2 = {}), this.attributes = e2, this._geometry = t2 || null, this._layer = i, this._layer ? this._datesfixed = false : this._datesfixed = true;
  61. }
  62. castToText() {
  63. let t2 = "";
  64. this._datesfixed === false && this._fixDates();
  65. for (const o in this.attributes) {
  66. t2 !== "" && (t2 += ",");
  67. const n = this.attributes[o];
  68. n == null ? t2 += JSON.stringify(o) + ":null" : _(n) || O(n) || w(n) ? t2 += JSON.stringify(o) + ":" + JSON.stringify(n) : n instanceof p || n instanceof t || n instanceof Array ? t2 += JSON.stringify(o) + ":" + ee(n) : n instanceof Date ? t2 += JSON.stringify(o) + ":" + JSON.stringify(n) : n !== null && typeof n == "object" && n.castToText !== void 0 && (t2 += JSON.stringify(o) + ":" + n.castToText());
  69. }
  70. return '{"geometry":' + (this.geometry() === null ? "null" : ee(this.geometry())) + ',"attributes":{' + t2 + "}}";
  71. }
  72. _fixDates() {
  73. if (this._datefields !== null)
  74. return this._datefields.length > 0 && this._fixDateFields(this._datefields), void (this._datesfixed = true);
  75. const t2 = [];
  76. for (let e2 = 0; e2 < this._layer.fields.length; e2++) {
  77. const i = this._layer.fields[e2];
  78. i.type !== "date" && i.type !== "esriFieldTypeDate" || t2.push(i.name);
  79. }
  80. this._datefields = t2, t2.length > 0 && this._fixDateFields(t2), this._datesfixed = true;
  81. }
  82. _fixDateFields(t2) {
  83. this.attributes = { ...this.attributes };
  84. for (let e2 = 0; e2 < t2.length; e2++) {
  85. let i = this.attributes[t2[e2]];
  86. if (i === null)
  87. ;
  88. else if (i === void 0) {
  89. for (const s2 in this.attributes)
  90. if (s2.toLowerCase() === t2[e2].toLowerCase()) {
  91. i = this.attributes[s2], i !== null && (i instanceof Date || (this.attributes[s2] = new Date(i)));
  92. break;
  93. }
  94. } else
  95. i instanceof Date || (this.attributes[t2[e2]] = new Date(i));
  96. }
  97. }
  98. geometry() {
  99. return this._geometry === null || this._geometry instanceof p || (this._optimizedGeomDefinition ? (this._geometry = e(d(ne(this._geometry, this._optimizedGeomDefinition.geometryType, this._optimizedGeomDefinition.hasZ, this._optimizedGeomDefinition.hasM))), this._geometry.spatialReference = this._optimizedGeomDefinition.spatialReference) : this._geometry = e(d(this._geometry))), this._geometry;
  100. }
  101. field(t2) {
  102. this._datesfixed === false && this._fixDates();
  103. const e2 = this.attributes[t2];
  104. if (e2 !== void 0)
  105. return e2;
  106. const i = t2.toLowerCase();
  107. for (const s2 in this.attributes)
  108. if (s2.toLowerCase() === i)
  109. return this.attributes[s2];
  110. if (this._hasFieldDefinition(i))
  111. return null;
  112. throw new Error("Field not Found : " + t2);
  113. }
  114. _hasFieldDefinition(t2) {
  115. if (this._layer === null)
  116. return false;
  117. for (let e2 = 0; e2 < this._layer.fields.length; e2++) {
  118. if (this._layer.fields[e2].name.toLowerCase() === t2)
  119. return true;
  120. }
  121. return false;
  122. }
  123. setField(t2, e2) {
  124. if (this.immutable)
  125. throw new Error("Feature is Immutable");
  126. if (C(e2) === false)
  127. throw new Error("Illegal Value Assignment to Feature");
  128. const i = t2.toLowerCase();
  129. if (this.attributes[t2] === void 0) {
  130. for (const t3 in this.attributes)
  131. if (t3.toLowerCase() === i)
  132. return void (this.attributes[t3] = e2);
  133. this.attributes[t2] = e2;
  134. } else
  135. this.attributes[t2] = e2;
  136. }
  137. hasField(t2) {
  138. const e2 = t2.toLowerCase();
  139. if (this.attributes[t2] !== void 0)
  140. return true;
  141. for (const i in this.attributes)
  142. if (i.toLowerCase() === e2)
  143. return true;
  144. return !!this._hasFieldDefinition(e2);
  145. }
  146. keys() {
  147. let t2 = [];
  148. const e2 = {};
  149. for (const i in this.attributes)
  150. t2.push(i), e2[i.toLowerCase()] = 1;
  151. if (this._layer !== null)
  152. for (let i = 0; i < this._layer.fields.length; i++) {
  153. const s2 = this._layer.fields[i];
  154. e2[s2.name.toLowerCase()] !== 1 && t2.push(s2.name);
  155. }
  156. return t2 = t2.sort(), t2;
  157. }
  158. static parseGeometryFromDictionary(t2) {
  159. const e2 = d3._convertDictionaryToJson(t2, true);
  160. return e2.hasm !== void 0 && (e2.hasM = e2.hasm, delete e2.hasm), e2.hasz !== void 0 && (e2.hasZ = e2.hasz, delete e2.hasz), e2.spatialreference !== void 0 && (e2.spatialReference = e2.spatialreference, delete e2.spatialreference), e2.rings !== void 0 && (e2.rings = this._fixPathArrays(e2.rings, e2.hasZ === true, e2.hasZ === true)), e2.paths !== void 0 && (e2.paths = this._fixPathArrays(e2.paths, e2.hasZ === true, e2.hasM === true)), e2.points !== void 0 && (e2.points = this._fixPointArrays(e2.points, e2.hasZ === true, e2.hasM === true)), d(e2);
  161. }
  162. static _fixPathArrays(t2, i, s2) {
  163. const r2 = [];
  164. if (t2 instanceof Array)
  165. for (let e2 = 0; e2 < t2.length; e2++)
  166. r2.push(this._fixPointArrays(t2[e2], i, s2));
  167. else if (t2 instanceof t)
  168. for (let e2 = 0; e2 < t2.length(); e2++)
  169. r2.push(this._fixPointArrays(t2.get(e2), i, s2));
  170. return r2;
  171. }
  172. static _fixPointArrays(t2, i, s2) {
  173. const r2 = [];
  174. if (t2 instanceof Array)
  175. for (let a = 0; a < t2.length; a++) {
  176. const o = t2[a];
  177. o instanceof j ? i && s2 ? r2.push([o.x, o.y, o.z, o.m]) : i ? r2.push([o.x, o.y, o.z]) : s2 ? r2.push([o.x, o.y, o.m]) : r2.push([o.x, o.y]) : o instanceof t ? r2.push(o.toArray()) : r2.push(o);
  178. }
  179. else if (t2 instanceof t)
  180. for (let a = 0; a < t2.length(); a++) {
  181. const o = t2.get(a);
  182. o instanceof j ? i && s2 ? r2.push([o.x, o.y, o.z, o.m]) : i ? r2.push([o.x, o.y, o.z]) : s2 ? r2.push([o.x, o.y, o.m]) : r2.push([o.x, o.y]) : o instanceof t ? r2.push(o.toArray()) : r2.push(o);
  183. }
  184. return r2;
  185. }
  186. static _convertDictionaryToJson(e2, i = false) {
  187. const s2 = {};
  188. for (const r2 in e2.attributes) {
  189. let a = e2.attributes[r2];
  190. a instanceof d2 && (a = d3._convertDictionaryToJson(a)), i ? s2[r2.toLowerCase()] = a : s2[r2] = a;
  191. }
  192. return s2;
  193. }
  194. static parseAttributesFromDictionary(t2) {
  195. const e2 = {};
  196. for (const i in t2.attributes) {
  197. const s2 = t2.attributes[i];
  198. if (!C(s2))
  199. throw new Error("Illegal Argument");
  200. e2[i] = s2;
  201. }
  202. return e2;
  203. }
  204. static fromJson(t2) {
  205. let e2 = null;
  206. t2.geometry !== null && t2.geometry !== void 0 && (e2 = d(t2.geometry));
  207. const a = {};
  208. if (t2.attributes !== null && t2.attributes !== void 0)
  209. for (const o in t2.attributes) {
  210. const e3 = t2.attributes[o];
  211. if (e3 === null)
  212. a[o] = e3;
  213. else {
  214. if (!(w(e3) || O(e3) || _(e3) || z(e3)))
  215. throw new Error("Illegal Argument");
  216. a[o] = e3;
  217. }
  218. }
  219. return d3.createFromGraphicLikeObject(e2, a, null);
  220. }
  221. fullSchema() {
  222. return this._layer;
  223. }
  224. gdbVersion() {
  225. if (this._layer === null)
  226. return "";
  227. const t2 = this._layer.gdbVersion;
  228. return t2 === void 0 ? "" : t2 === "" && this._layer.capabilities && this._layer.capabilities.isVersioned ? "SDE.DEFAULT" : t2;
  229. }
  230. castAsJson(t2) {
  231. const e2 = { attributes: {}, geometry: t2?.keepGeometryType === true ? this.geometry() : this.geometry().toJSON() };
  232. for (const i in this.attributes) {
  233. const s2 = this.attributes[i];
  234. s2 !== void 0 && (e2.attributes[i] = ke(s2, t2));
  235. }
  236. return e2;
  237. }
  238. async castAsJsonAsync(t2 = null, e2) {
  239. return this.castAsJson(e2);
  240. }
  241. };
  242. export {
  243. s,
  244. d3 as d
  245. };
  246. //# sourceMappingURL=chunk-YYN5W6FL.js.map