chunk-DRPR56GA.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. import {
  2. i
  3. } from "./chunk-LX2NI53X.js";
  4. import {
  5. w as w2
  6. } from "./chunk-56OWH4DC.js";
  7. import {
  8. v
  9. } from "./chunk-7B57NUGF.js";
  10. import {
  11. n as n2
  12. } from "./chunk-I4RYNNL6.js";
  13. import {
  14. L,
  15. b as b2,
  16. h,
  17. m,
  18. y as y2
  19. } from "./chunk-SZFMKPVM.js";
  20. import {
  21. f as f2,
  22. j as j2
  23. } from "./chunk-GLSWDDR3.js";
  24. import {
  25. b
  26. } from "./chunk-2ZSOO377.js";
  27. import {
  28. x as x2
  29. } from "./chunk-YUA3AHKR.js";
  30. import {
  31. j as j3
  32. } from "./chunk-LU5IJZB4.js";
  33. import {
  34. U
  35. } from "./chunk-DVUG3KID.js";
  36. import {
  37. j
  38. } from "./chunk-VEGAOVMY.js";
  39. import {
  40. o,
  41. w2 as w
  42. } from "./chunk-6T6G6LCQ.js";
  43. import {
  44. k2 as k,
  45. r as r2
  46. } from "./chunk-PQFTYGF5.js";
  47. import {
  48. e,
  49. n5 as n,
  50. y3 as y
  51. } from "./chunk-2Z2TG5CU.js";
  52. import {
  53. E,
  54. f,
  55. x
  56. } from "./chunk-V6P2MAQQ.js";
  57. import {
  58. s2 as s,
  59. s3 as s2
  60. } from "./chunk-E5O6P5I2.js";
  61. import {
  62. r
  63. } from "./chunk-YXWMMD76.js";
  64. // node_modules/@arcgis/core/layers/support/I3SIndexInfo.js
  65. async function n3(n5, t, s3, a2, i2, d) {
  66. let l = null;
  67. if (r(s3)) {
  68. const o2 = `${n5}/nodepages/`, t2 = o2 + Math.floor(s3.rootIndex / s3.nodesPerPage);
  69. try {
  70. return { type: "page", rootPage: (await U(t2, { query: { f: "json", token: a2 }, responseType: "json", signal: d })).data, rootIndex: s3.rootIndex, pageSize: s3.nodesPerPage, lodMetric: s3.lodSelectionMetricType, urlPrefix: o2 };
  71. } catch (f3) {
  72. r(i2) && i2.warn("#fetchIndexInfo()", "Failed to load root node page. Falling back to node documents.", t2, f3), l = f3;
  73. }
  74. }
  75. if (!t)
  76. return null;
  77. const p = `${n5}/nodes/`, c = p + (t && t.split("/").pop());
  78. try {
  79. return { type: "node", rootNode: (await U(c, { query: { f: "json", token: a2 }, responseType: "json", signal: d })).data, urlPrefix: p };
  80. } catch (f3) {
  81. throw new s2("sceneservice:root-node-missing", "Root node missing.", { pageError: l, nodeError: f3, url: c });
  82. }
  83. }
  84. // node_modules/@arcgis/core/webdoc/support/saveUtils.js
  85. async function a(r3, o2, a2) {
  86. if (!o2 || !o2.resources)
  87. return;
  88. const h2 = o2.portalItem === r3.portalItem ? new Set(r3.paths) : /* @__PURE__ */ new Set();
  89. r3.paths.length = 0, r3.portalItem = o2.portalItem;
  90. const i2 = new Set(o2.resources.toKeep.map((r4) => r4.resource.path)), m2 = /* @__PURE__ */ new Set(), f3 = [];
  91. i2.forEach((e2) => {
  92. h2.delete(e2), r3.paths.push(e2);
  93. });
  94. for (const e2 of o2.resources.toUpdate)
  95. if (h2.delete(e2.resource.path), i2.has(e2.resource.path) || m2.has(e2.resource.path)) {
  96. const { resource: o3, content: s3, finish: t, error: u2 } = e2, h3 = w2(o3, n2());
  97. r3.paths.push(h3.path), f3.push(n4({ resource: h3, content: s3, compress: e2.compress, finish: t, error: u2 }, a2));
  98. } else
  99. r3.paths.push(e2.resource.path), f3.push(u(e2, a2)), m2.add(e2.resource.path);
  100. for (const e2 of o2.resources.toAdd)
  101. f3.push(n4(e2, a2)), r3.paths.push(e2.resource.path);
  102. if (h2.forEach((r4) => {
  103. const e2 = o2.portalItem.resourceFromPath(r4);
  104. f3.push(e2.portalItem.removeResource(e2).catch(() => {
  105. }));
  106. }), 0 === f3.length)
  107. return;
  108. const l = await E(f3);
  109. f(a2);
  110. const d = l.filter((r4) => "error" in r4).map((r4) => r4.error);
  111. if (d.length > 0)
  112. throw new s2("save:resources", "Failed to save one or more resources", { errors: d });
  113. }
  114. async function n4(e2, s3) {
  115. const t = { ...r(s3) ? s3 : {}, compress: e2.compress }, c = await b(e2.resource.portalItem.addResource(e2.resource, e2.content, t));
  116. if (true !== c.ok)
  117. throw e2.error && e2.error(c.error), c.error;
  118. e2.finish && e2.finish(e2.resource);
  119. }
  120. async function u(e2, o2) {
  121. const s3 = await b(e2.resource.update(e2.content, o2));
  122. if (true !== s3.ok)
  123. throw e2.error(s3.error), s3.error;
  124. e2.finish(e2.resource);
  125. }
  126. // node_modules/@arcgis/core/layers/mixins/SceneService.js
  127. var R = "esri.layers.mixins.SceneService";
  128. var A = s.getLogger(R);
  129. var N = (o2) => {
  130. let N2 = class extends o2 {
  131. constructor() {
  132. super(...arguments), this.spatialReference = null, this.fullExtent = null, this.heightModelInfo = null, this.minScale = 0, this.maxScale = 0, this.version = { major: Number.NaN, minor: Number.NaN, versionString: "" }, this.copyright = null, this.sublayerTitleMode = "item-title", this.title = null, this.layerId = null, this.indexInfo = null, this._debouncedSaveOperations = x(async (e2, t, r3) => {
  133. switch (e2) {
  134. case L2.SAVE:
  135. return this._save(t);
  136. case L2.SAVE_AS:
  137. return this._saveAs(r3, t);
  138. }
  139. });
  140. }
  141. readSpatialReference(e2, t) {
  142. return this._readSpatialReference(t);
  143. }
  144. _readSpatialReference(e2) {
  145. if (null != e2.spatialReference)
  146. return k.fromJSON(e2.spatialReference);
  147. {
  148. const t = e2.store, r3 = t.indexCRS || t.geographicCRS, o3 = r3 && parseInt(r3.substring(r3.lastIndexOf("/") + 1, r3.length), 10);
  149. return null != o3 ? new k(o3) : null;
  150. }
  151. }
  152. readFullExtent(e2, t, r3) {
  153. if (null != e2 && "object" == typeof e2) {
  154. const o4 = null == e2.spatialReference ? { ...e2, spatialReference: this._readSpatialReference(t) } : e2;
  155. return w.fromJSON(o4, r3);
  156. }
  157. const o3 = t.store, i2 = this._readSpatialReference(t);
  158. return null == i2 || null == o3 || null == o3.extent || !Array.isArray(o3.extent) || o3.extent.some((e3) => e3 < U2) ? null : new w({ xmin: o3.extent[0], ymin: o3.extent[1], xmax: o3.extent[2], ymax: o3.extent[3], spatialReference: i2 });
  159. }
  160. parseVersionString(e2) {
  161. const t = { major: Number.NaN, minor: Number.NaN, versionString: e2 }, r3 = e2.split(".");
  162. return r3.length >= 2 && (t.major = parseInt(r3[0], 10), t.minor = parseInt(r3[1], 10)), t;
  163. }
  164. readVersion(e2, t) {
  165. const r3 = t.store, o3 = null != r3.version ? r3.version.toString() : "";
  166. return this.parseVersionString(o3);
  167. }
  168. readTitlePortalItem(e2) {
  169. return "item-title" !== this.sublayerTitleMode ? void 0 : e2;
  170. }
  171. readTitleService(e2, t) {
  172. const r3 = this.portalItem && this.portalItem.title;
  173. if ("item-title" === this.sublayerTitleMode)
  174. return y2(this.url, t.name);
  175. let o3 = t.name;
  176. if (!o3 && this.url) {
  177. const e3 = m(this.url);
  178. r(e3) && (o3 = e3.title);
  179. }
  180. return "item-title-and-service-name" === this.sublayerTitleMode && r3 && (o3 = r3 + " - " + o3), h(o3);
  181. }
  182. set url(e2) {
  183. const t = L({ layer: this, url: e2, nonStandardUrlAllowed: false, logger: A });
  184. this._set("url", t.url), null != t.layerId && this._set("layerId", t.layerId);
  185. }
  186. writeUrl(e2, t, r3, o3) {
  187. b2(this, e2, "layers", t, o3);
  188. }
  189. get parsedUrl() {
  190. const e2 = this._get("url"), t = j(e2);
  191. return null != this.layerId && (t.path = `${t.path}/layers/${this.layerId}`), t;
  192. }
  193. async _fetchIndexAndUpdateExtent(e2, t) {
  194. this.indexInfo = n3(this.parsedUrl.path, this.rootNode, e2, this.apiKey, A, t), null == this.fullExtent || this.fullExtent.hasZ || this._updateExtent(await this.indexInfo);
  195. }
  196. _updateExtent(e2) {
  197. var _a, _b, _c;
  198. if ("page" === (e2 == null ? void 0 : e2.type)) {
  199. const t = e2.rootIndex % e2.pageSize, o3 = (_b = (_a = e2.rootPage) == null ? void 0 : _a.nodes) == null ? void 0 : _b[t];
  200. if (null == o3 || null == o3.obb || null == o3.obb.center || null == o3.obb.halfSize)
  201. throw new s2("sceneservice:invalid-node-page", "Invalid node page.");
  202. if (o3.obb.center[0] < U2 || null == this.fullExtent || this.fullExtent.hasZ)
  203. return;
  204. const i2 = o3.obb.halfSize, s3 = o3.obb.center[2], a2 = Math.sqrt(i2[0] * i2[0] + i2[1] * i2[1] + i2[2] * i2[2]);
  205. this.fullExtent.zmin = s3 - a2, this.fullExtent.zmax = s3 + a2;
  206. } else if ("node" === (e2 == null ? void 0 : e2.type)) {
  207. const t = (_c = e2.rootNode) == null ? void 0 : _c.mbs;
  208. if (!Array.isArray(t) || 4 !== t.length || t[0] < U2)
  209. return;
  210. const r3 = t[2], o3 = t[3], { fullExtent: i2 } = this;
  211. i2 && (i2.zmin = r3 - o3, i2.zmax = r3 + o3);
  212. }
  213. }
  214. async _fetchService(e2) {
  215. if (null == this.url)
  216. throw new s2("sceneservice:url-not-set", "Scene service can not be loaded without valid portal item or url");
  217. if (null == this.layerId && /SceneServer\/*$/i.test(this.url)) {
  218. const t = await this._fetchFirstLayerId(e2);
  219. null != t && (this.layerId = t);
  220. }
  221. return this._fetchServiceLayer(e2);
  222. }
  223. async _fetchFirstLayerId(e2) {
  224. const r3 = await U(this.url, { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 });
  225. if (r3.data && Array.isArray(r3.data.layers) && r3.data.layers.length > 0)
  226. return r3.data.layers[0].id;
  227. }
  228. async _fetchServiceLayer(e2) {
  229. var _a, _b;
  230. const r3 = await U((_b = (_a = this.parsedUrl) == null ? void 0 : _a.path) != null ? _b : "", { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 });
  231. r3.ssl && (this.url = this.url.replace(/^http:/i, "https:"));
  232. let o3 = false;
  233. if (r3.data.layerType && "Voxel" === r3.data.layerType && (o3 = true), o3)
  234. return this._fetchVoxelServiceLayer();
  235. const i2 = r3.data;
  236. this.read(i2, { origin: "service", url: this.parsedUrl }), this.validateLayer(i2);
  237. }
  238. async _fetchVoxelServiceLayer(e2) {
  239. var _a;
  240. const r3 = (await U(((_a = this.parsedUrl) == null ? void 0 : _a.path) + "/layer", { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 })).data;
  241. this.read(r3, { origin: "service", url: this.parsedUrl }), this.validateLayer(r3);
  242. }
  243. async _ensureLoadBeforeSave() {
  244. await this.load(), "beforeSave" in this && "function" == typeof this.beforeSave && await this.beforeSave();
  245. }
  246. validateLayer(e2) {
  247. }
  248. _updateTypeKeywords(e2, t, r3) {
  249. e2.typeKeywords || (e2.typeKeywords = []);
  250. const o3 = t.getTypeKeywords();
  251. for (const i2 of o3)
  252. e2.typeKeywords.push(i2);
  253. e2.typeKeywords && (e2.typeKeywords = e2.typeKeywords.filter((e3, t2, r4) => r4.indexOf(e3) === t2), r3 === T.newItem && (e2.typeKeywords = e2.typeKeywords.filter((e3) => "Hosted Service" !== e3)));
  254. }
  255. async _saveAs(e2, t) {
  256. var _a, _b, _c;
  257. const o3 = { ...K, ...t };
  258. let i2 = x2.from(e2);
  259. i2 || (A.error("_saveAs(): requires a portal item parameter"), await Promise.reject(new s2("sceneservice:portal-item-required", "_saveAs() requires a portal item to save to"))), i2.id && (i2 = i2.clone(), i2.id = null);
  260. const s3 = i2.portal || j3.getDefault();
  261. await this._ensureLoadBeforeSave(), i2.type = O, i2.portal = s3;
  262. const a2 = { origin: "portal-item", url: null, messages: [], portal: s3, portalItem: i2, writtenProperties: [], blockedRelativeUrls: [], resources: { toAdd: [], toUpdate: [], toKeep: [], pendingOperations: [] } }, n5 = { layers: [this.write({}, a2)] };
  263. return await Promise.all((_b = (_a = a2.resources) == null ? void 0 : _a.pendingOperations) != null ? _b : []), await this._validateAgainstJSONSchema(n5, a2, o3), i2.url = this.url, i2.title || (i2.title = this.title), this._updateTypeKeywords(i2, o3, T.newItem), await s3._signIn(), await ((_c = s3.user) == null ? void 0 : _c.addItem({ item: i2, folder: o3 && o3.folder, data: n5 })), await a(this.resourceReferences, a2, null), this.portalItem = i2, i(a2), a2.portalItem = i2, i2;
  264. }
  265. async _save(e2) {
  266. var _a, _b;
  267. const t = { ...K, ...e2 };
  268. if (!this.portalItem)
  269. throw A.error("_save(): requires the .portalItem property to be set"), new s2("sceneservice:portal-item-not-set", "Portal item to save to has not been set on this SceneService");
  270. if (this.portalItem.type !== O)
  271. throw A.error("_save(): Non-matching portal item type. Got " + this.portalItem.type + ", expected " + O), new s2("sceneservice:portal-item-wrong-type", `Portal item needs to have type "${O}"`);
  272. await this._ensureLoadBeforeSave();
  273. const o3 = { origin: "portal-item", url: this.portalItem.itemUrl && j(this.portalItem.itemUrl), messages: [], portal: this.portalItem.portal || j3.getDefault(), portalItem: this.portalItem, writtenProperties: [], blockedRelativeUrls: [], resources: { toAdd: [], toUpdate: [], toKeep: [], pendingOperations: [] } }, i2 = { layers: [this.write({}, o3)] };
  274. return await Promise.all((_b = (_a = o3.resources) == null ? void 0 : _a.pendingOperations) != null ? _b : []), await this._validateAgainstJSONSchema(i2, o3, t), this.portalItem.url = this.url, this.portalItem.title || (this.portalItem.title = this.title), this._updateTypeKeywords(this.portalItem, t, T.existingItem), await this.portalItem.update({ data: i2 }), await a(this.resourceReferences, o3, null), i(o3), this.portalItem;
  275. }
  276. async _validateAgainstJSONSchema(e2, t, o3) {
  277. var _a, _b, _c, _d, _e;
  278. let i2 = (_b = (_a = t.messages) == null ? void 0 : _a.filter((e3) => "error" === e3.type).map((e3) => new s2(e3.name, e3.message, e3.details))) != null ? _b : [];
  279. if (o3 && ((_c = o3.validationOptions) == null ? void 0 : _c.ignoreUnsupported) && (i2 = i2.filter((e3) => "layer:unsupported" !== e3.name && "symbol:unsupported" !== e3.name && "symbol-layer:unsupported" !== e3.name && "property:unsupported" !== e3.name && "url:unsupported" !== e3.name && "scenemodification:unsupported" !== e3.name)), ((_d = o3.validationOptions) == null ? void 0 : _d.enabled) || E2) {
  280. const t2 = (await import("./schemaValidator-BC4XAPTF.js")).validate(e2, o3.portalItemLayerType);
  281. if (t2.length > 0) {
  282. const e3 = `Layer item did not validate:
  283. ${t2.join("\n")}`;
  284. if (A.error(`_validateAgainstJSONSchema(): ${e3}`), "throw" === ((_e = o3.validationOptions) == null ? void 0 : _e.failPolicy)) {
  285. const e4 = t2.map((e5) => new s2("sceneservice:schema-validation", e5)).concat(i2);
  286. throw new s2("sceneservice-validate:error", "Failed to save layer item due to schema validation, see `details.errors`.", { combined: e4 });
  287. }
  288. }
  289. }
  290. if (i2.length > 0)
  291. throw new s2("sceneservice:save", "Failed to save SceneService due to unsupported or invalid content. See 'details.errors' for more detailed information", { errors: i2 });
  292. }
  293. };
  294. return e([y(j2)], N2.prototype, "id", void 0), e([y({ type: k })], N2.prototype, "spatialReference", void 0), e([o("spatialReference", ["spatialReference", "store.indexCRS", "store.geographicCRS"])], N2.prototype, "readSpatialReference", null), e([y({ type: w })], N2.prototype, "fullExtent", void 0), e([o("fullExtent", ["fullExtent", "store.extent", "spatialReference", "store.indexCRS", "store.geographicCRS"])], N2.prototype, "readFullExtent", null), e([y({ readOnly: true, type: v })], N2.prototype, "heightModelInfo", void 0), e([y({ type: Number, json: { name: "layerDefinition.minScale", write: true, origins: { service: { read: { source: "minScale" }, write: false } } } })], N2.prototype, "minScale", void 0), e([y({ type: Number, json: { name: "layerDefinition.maxScale", write: true, origins: { service: { read: { source: "maxScale" }, write: false } } } })], N2.prototype, "maxScale", void 0), e([y({ readOnly: true })], N2.prototype, "version", void 0), e([o("version", ["store.version"])], N2.prototype, "readVersion", null), e([y({ type: String, json: { read: { source: "copyrightText" } } })], N2.prototype, "copyright", void 0), e([y({ type: String, json: { read: false } })], N2.prototype, "sublayerTitleMode", void 0), e([y({ type: String })], N2.prototype, "title", void 0), e([o("portal-item", "title")], N2.prototype, "readTitlePortalItem", null), e([o("service", "title", ["name"])], N2.prototype, "readTitleService", null), e([y({ type: Number, json: { origins: { service: { read: { source: "id" } }, "portal-item": { write: { target: "id", isRequired: true, ignoreOrigin: true }, read: false } } } })], N2.prototype, "layerId", void 0), e([y(f2)], N2.prototype, "url", null), e([r2("url")], N2.prototype, "writeUrl", null), e([y()], N2.prototype, "parsedUrl", null), e([y({ readOnly: true })], N2.prototype, "store", void 0), e([y({ type: String, readOnly: true, json: { read: { source: "store.rootNode" } } })], N2.prototype, "rootNode", void 0), N2 = e([n(R)], N2), N2;
  295. };
  296. var U2 = -1e38;
  297. var E2 = false;
  298. var T;
  299. !function(e2) {
  300. e2[e2.existingItem = 0] = "existingItem", e2[e2.newItem = 1] = "newItem";
  301. }(T || (T = {}));
  302. var O = "Scene Service";
  303. var K = { getTypeKeywords: () => [], portalItemLayerType: "unknown", validationOptions: { enabled: true, ignoreUnsupported: false, failPolicy: "throw" } };
  304. var L2;
  305. !function(e2) {
  306. e2[e2.SAVE = 0] = "SAVE", e2[e2.SAVE_AS = 1] = "SAVE_AS";
  307. }(L2 || (L2 = {}));
  308. export {
  309. n3 as n,
  310. N,
  311. L2 as L
  312. };
  313. //# sourceMappingURL=chunk-DRPR56GA.js.map