import { i } from "./chunk-LX2NI53X.js"; import { w as w2 } from "./chunk-56OWH4DC.js"; import { v } from "./chunk-7B57NUGF.js"; import { n as n2 } from "./chunk-I4RYNNL6.js"; import { L, b as b2, h, m, y as y2 } from "./chunk-SZFMKPVM.js"; import { f as f2, j as j2 } from "./chunk-GLSWDDR3.js"; import { b } from "./chunk-2ZSOO377.js"; import { x as x2 } from "./chunk-YUA3AHKR.js"; import { j as j3 } from "./chunk-LU5IJZB4.js"; import { U } from "./chunk-DVUG3KID.js"; import { j } from "./chunk-VEGAOVMY.js"; import { o, w2 as w } from "./chunk-6T6G6LCQ.js"; import { k2 as k, r as r2 } from "./chunk-PQFTYGF5.js"; import { e, n5 as n, y3 as y } from "./chunk-2Z2TG5CU.js"; import { E, f, x } from "./chunk-V6P2MAQQ.js"; import { s2 as s, s3 as s2 } from "./chunk-E5O6P5I2.js"; import { r } from "./chunk-YXWMMD76.js"; // node_modules/@arcgis/core/layers/support/I3SIndexInfo.js async function n3(n5, t, s3, a2, i2, d) { let l = null; if (r(s3)) { const o2 = `${n5}/nodepages/`, t2 = o2 + Math.floor(s3.rootIndex / s3.nodesPerPage); try { 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 }; } catch (f3) { r(i2) && i2.warn("#fetchIndexInfo()", "Failed to load root node page. Falling back to node documents.", t2, f3), l = f3; } } if (!t) return null; const p = `${n5}/nodes/`, c = p + (t && t.split("/").pop()); try { return { type: "node", rootNode: (await U(c, { query: { f: "json", token: a2 }, responseType: "json", signal: d })).data, urlPrefix: p }; } catch (f3) { throw new s2("sceneservice:root-node-missing", "Root node missing.", { pageError: l, nodeError: f3, url: c }); } } // node_modules/@arcgis/core/webdoc/support/saveUtils.js async function a(r3, o2, a2) { if (!o2 || !o2.resources) return; const h2 = o2.portalItem === r3.portalItem ? new Set(r3.paths) : /* @__PURE__ */ new Set(); r3.paths.length = 0, r3.portalItem = o2.portalItem; const i2 = new Set(o2.resources.toKeep.map((r4) => r4.resource.path)), m2 = /* @__PURE__ */ new Set(), f3 = []; i2.forEach((e2) => { h2.delete(e2), r3.paths.push(e2); }); for (const e2 of o2.resources.toUpdate) if (h2.delete(e2.resource.path), i2.has(e2.resource.path) || m2.has(e2.resource.path)) { const { resource: o3, content: s3, finish: t, error: u2 } = e2, h3 = w2(o3, n2()); r3.paths.push(h3.path), f3.push(n4({ resource: h3, content: s3, compress: e2.compress, finish: t, error: u2 }, a2)); } else r3.paths.push(e2.resource.path), f3.push(u(e2, a2)), m2.add(e2.resource.path); for (const e2 of o2.resources.toAdd) f3.push(n4(e2, a2)), r3.paths.push(e2.resource.path); if (h2.forEach((r4) => { const e2 = o2.portalItem.resourceFromPath(r4); f3.push(e2.portalItem.removeResource(e2).catch(() => { })); }), 0 === f3.length) return; const l = await E(f3); f(a2); const d = l.filter((r4) => "error" in r4).map((r4) => r4.error); if (d.length > 0) throw new s2("save:resources", "Failed to save one or more resources", { errors: d }); } async function n4(e2, s3) { const t = { ...r(s3) ? s3 : {}, compress: e2.compress }, c = await b(e2.resource.portalItem.addResource(e2.resource, e2.content, t)); if (true !== c.ok) throw e2.error && e2.error(c.error), c.error; e2.finish && e2.finish(e2.resource); } async function u(e2, o2) { const s3 = await b(e2.resource.update(e2.content, o2)); if (true !== s3.ok) throw e2.error(s3.error), s3.error; e2.finish(e2.resource); } // node_modules/@arcgis/core/layers/mixins/SceneService.js var R = "esri.layers.mixins.SceneService"; var A = s.getLogger(R); var N = (o2) => { let N2 = class extends o2 { constructor() { 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) => { switch (e2) { case L2.SAVE: return this._save(t); case L2.SAVE_AS: return this._saveAs(r3, t); } }); } readSpatialReference(e2, t) { return this._readSpatialReference(t); } _readSpatialReference(e2) { if (null != e2.spatialReference) return k.fromJSON(e2.spatialReference); { const t = e2.store, r3 = t.indexCRS || t.geographicCRS, o3 = r3 && parseInt(r3.substring(r3.lastIndexOf("/") + 1, r3.length), 10); return null != o3 ? new k(o3) : null; } } readFullExtent(e2, t, r3) { if (null != e2 && "object" == typeof e2) { const o4 = null == e2.spatialReference ? { ...e2, spatialReference: this._readSpatialReference(t) } : e2; return w.fromJSON(o4, r3); } const o3 = t.store, i2 = this._readSpatialReference(t); 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 }); } parseVersionString(e2) { const t = { major: Number.NaN, minor: Number.NaN, versionString: e2 }, r3 = e2.split("."); return r3.length >= 2 && (t.major = parseInt(r3[0], 10), t.minor = parseInt(r3[1], 10)), t; } readVersion(e2, t) { const r3 = t.store, o3 = null != r3.version ? r3.version.toString() : ""; return this.parseVersionString(o3); } readTitlePortalItem(e2) { return "item-title" !== this.sublayerTitleMode ? void 0 : e2; } readTitleService(e2, t) { const r3 = this.portalItem && this.portalItem.title; if ("item-title" === this.sublayerTitleMode) return y2(this.url, t.name); let o3 = t.name; if (!o3 && this.url) { const e3 = m(this.url); r(e3) && (o3 = e3.title); } return "item-title-and-service-name" === this.sublayerTitleMode && r3 && (o3 = r3 + " - " + o3), h(o3); } set url(e2) { const t = L({ layer: this, url: e2, nonStandardUrlAllowed: false, logger: A }); this._set("url", t.url), null != t.layerId && this._set("layerId", t.layerId); } writeUrl(e2, t, r3, o3) { b2(this, e2, "layers", t, o3); } get parsedUrl() { const e2 = this._get("url"), t = j(e2); return null != this.layerId && (t.path = `${t.path}/layers/${this.layerId}`), t; } async _fetchIndexAndUpdateExtent(e2, t) { this.indexInfo = n3(this.parsedUrl.path, this.rootNode, e2, this.apiKey, A, t), null == this.fullExtent || this.fullExtent.hasZ || this._updateExtent(await this.indexInfo); } _updateExtent(e2) { var _a, _b, _c; if ("page" === (e2 == null ? void 0 : e2.type)) { const t = e2.rootIndex % e2.pageSize, o3 = (_b = (_a = e2.rootPage) == null ? void 0 : _a.nodes) == null ? void 0 : _b[t]; if (null == o3 || null == o3.obb || null == o3.obb.center || null == o3.obb.halfSize) throw new s2("sceneservice:invalid-node-page", "Invalid node page."); if (o3.obb.center[0] < U2 || null == this.fullExtent || this.fullExtent.hasZ) return; 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]); this.fullExtent.zmin = s3 - a2, this.fullExtent.zmax = s3 + a2; } else if ("node" === (e2 == null ? void 0 : e2.type)) { const t = (_c = e2.rootNode) == null ? void 0 : _c.mbs; if (!Array.isArray(t) || 4 !== t.length || t[0] < U2) return; const r3 = t[2], o3 = t[3], { fullExtent: i2 } = this; i2 && (i2.zmin = r3 - o3, i2.zmax = r3 + o3); } } async _fetchService(e2) { if (null == this.url) throw new s2("sceneservice:url-not-set", "Scene service can not be loaded without valid portal item or url"); if (null == this.layerId && /SceneServer\/*$/i.test(this.url)) { const t = await this._fetchFirstLayerId(e2); null != t && (this.layerId = t); } return this._fetchServiceLayer(e2); } async _fetchFirstLayerId(e2) { const r3 = await U(this.url, { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 }); if (r3.data && Array.isArray(r3.data.layers) && r3.data.layers.length > 0) return r3.data.layers[0].id; } async _fetchServiceLayer(e2) { var _a, _b; 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 }); r3.ssl && (this.url = this.url.replace(/^http:/i, "https:")); let o3 = false; if (r3.data.layerType && "Voxel" === r3.data.layerType && (o3 = true), o3) return this._fetchVoxelServiceLayer(); const i2 = r3.data; this.read(i2, { origin: "service", url: this.parsedUrl }), this.validateLayer(i2); } async _fetchVoxelServiceLayer(e2) { var _a; const r3 = (await U(((_a = this.parsedUrl) == null ? void 0 : _a.path) + "/layer", { query: { f: "json", token: this.apiKey }, responseType: "json", signal: e2 })).data; this.read(r3, { origin: "service", url: this.parsedUrl }), this.validateLayer(r3); } async _ensureLoadBeforeSave() { await this.load(), "beforeSave" in this && "function" == typeof this.beforeSave && await this.beforeSave(); } validateLayer(e2) { } _updateTypeKeywords(e2, t, r3) { e2.typeKeywords || (e2.typeKeywords = []); const o3 = t.getTypeKeywords(); for (const i2 of o3) e2.typeKeywords.push(i2); 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))); } async _saveAs(e2, t) { var _a, _b, _c; const o3 = { ...K, ...t }; let i2 = x2.from(e2); 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); const s3 = i2.portal || j3.getDefault(); await this._ensureLoadBeforeSave(), i2.type = O, i2.portal = s3; const a2 = { origin: "portal-item", url: null, messages: [], portal: s3, portalItem: i2, writtenProperties: [], blockedRelativeUrls: [], resources: { toAdd: [], toUpdate: [], toKeep: [], pendingOperations: [] } }, n5 = { layers: [this.write({}, a2)] }; 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; } async _save(e2) { var _a, _b; const t = { ...K, ...e2 }; if (!this.portalItem) 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"); if (this.portalItem.type !== O) 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}"`); await this._ensureLoadBeforeSave(); 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)] }; 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; } async _validateAgainstJSONSchema(e2, t, o3) { var _a, _b, _c, _d, _e; 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 : []; 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) { const t2 = (await import("./schemaValidator-BC4XAPTF.js")).validate(e2, o3.portalItemLayerType); if (t2.length > 0) { const e3 = `Layer item did not validate: ${t2.join("\n")}`; if (A.error(`_validateAgainstJSONSchema(): ${e3}`), "throw" === ((_e = o3.validationOptions) == null ? void 0 : _e.failPolicy)) { const e4 = t2.map((e5) => new s2("sceneservice:schema-validation", e5)).concat(i2); throw new s2("sceneservice-validate:error", "Failed to save layer item due to schema validation, see `details.errors`.", { combined: e4 }); } } } if (i2.length > 0) throw new s2("sceneservice:save", "Failed to save SceneService due to unsupported or invalid content. See 'details.errors' for more detailed information", { errors: i2 }); } }; 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; }; var U2 = -1e38; var E2 = false; var T; !function(e2) { e2[e2.existingItem = 0] = "existingItem", e2[e2.newItem = 1] = "newItem"; }(T || (T = {})); var O = "Scene Service"; var K = { getTypeKeywords: () => [], portalItemLayerType: "unknown", validationOptions: { enabled: true, ignoreUnsupported: false, failPolicy: "throw" } }; var L2; !function(e2) { e2[e2.SAVE = 0] = "SAVE", e2[e2.SAVE_AS = 1] = "SAVE_AS"; }(L2 || (L2 = {})); export { n3 as n, N, L2 as L }; //# sourceMappingURL=chunk-DRPR56GA.js.map