import { _n, rn } from "./chunk-P24XEEHY.js"; import "./chunk-SAJAEMIJ.js"; import { t as t2 } from "./chunk-U2WD23Z5.js"; import "./chunk-VGWC3IKZ.js"; import { R, c as c2, f, u as u2, w as w3 } from "./chunk-2H5MD622.js"; import { $ } from "./chunk-3RSFVUKZ.js"; import { b } from "./chunk-2ZSOO377.js"; import "./chunk-ZLNEXZAN.js"; import "./chunk-RYY6632W.js"; import "./chunk-DW42UVIT.js"; import "./chunk-YAEIHDJH.js"; import "./chunk-TJNOJH33.js"; import "./chunk-OSHI574D.js"; import "./chunk-ETGAZ7LF.js"; import "./chunk-75U5LM2V.js"; import "./chunk-RMDDCMKS.js"; import { m2 as m, u } from "./chunk-VCH45Q2I.js"; import "./chunk-GSSTTHIT.js"; import "./chunk-HZRKBTHJ.js"; import "./chunk-DVUG3KID.js"; import "./chunk-FWSQEIAR.js"; import "./chunk-VEGAOVMY.js"; import { M, w as w2 } from "./chunk-6T6G6LCQ.js"; import "./chunk-YEJL5NEF.js"; import "./chunk-PQFTYGF5.js"; import "./chunk-2Z2TG5CU.js"; import "./chunk-6KZ2LTDA.js"; import "./chunk-U2XHEJM7.js"; import "./chunk-SQOPWYIT.js"; import { E, w, y } from "./chunk-V6P2MAQQ.js"; import { s2 as s, s3 as s2 } from "./chunk-E5O6P5I2.js"; import "./chunk-SPWQ3AWG.js"; import "./chunk-2TIUKVZN.js"; import { c, i, r, t } from "./chunk-YXWMMD76.js"; import "./chunk-S5KM4IGW.js"; // node_modules/@arcgis/core/layers/support/ElevationSampler.js var m2 = s.getLogger("esri.layers.support.ElevationSampler"); var c3 = class { queryElevation(e2) { return h(e2.clone(), this); } on() { return g; } projectIfRequired(e2, t4) { return f2(e2, t4); } }; var u3 = class extends c3 { constructor(e2, t4, n) { super(), this.tile = e2, this.noDataValue = n; const o = e2.tile.extent; this.extent = f(o, t4.spatialReference), this.extent.zmin = e2.zmin, this.extent.zmax = e2.zmax, this._aaExtent = o; const a = $(t4.spatialReference), r2 = t4.lodAt(e2.tile.level).resolution * a; this.demResolution = { min: r2, max: r2 }; } get spatialReference() { return this.extent.spatialReference; } contains(e2) { const n = this.projectIfRequired(e2, this.spatialReference); return !t(n) && this.containsAt(n.x, n.y); } containsAt(e2, t4) { return w3(this._aaExtent, e2, t4); } elevationAt(e2, t4) { if (!this.containsAt(e2, t4)) { const n = this.extent, s4 = `${n.xmin}, ${n.ymin}, ${n.xmax}, ${n.ymax}`; return m2.warn("#elevationAt()", `Point used to sample elevation (${e2}, ${t4}) is outside of the sampler extent (${s4})`), this.noDataValue; } return i(this.tile.sample(e2, t4), this.noDataValue); } }; var p = class extends c3 { constructor(e2, t4, n) { let s4; super(), "number" == typeof t4 ? (this.noDataValue = t4, s4 = null) : (s4 = t4, this.noDataValue = n), this.samplers = s4 ? e2.map((e3) => new u3(e3, s4, this.noDataValue)) : e2; const o = this.samplers[0]; if (o) { this.extent = o.extent.clone(); const { min: e3, max: t5 } = o.demResolution; this.demResolution = { min: e3, max: t5 }; for (let n2 = 1; n2 < this.samplers.length; n2++) { const e4 = this.samplers[n2]; this.extent.union(e4.extent), this.demResolution.min = Math.min(this.demResolution.min, e4.demResolution.min), this.demResolution.max = Math.max(this.demResolution.max, e4.demResolution.max); } } else this.extent = f(u2(), s4.spatialReference), this.demResolution = { min: 0, max: 0 }; } get spatialReference() { return this.extent.spatialReference; } elevationAt(e2, t4) { for (const n of this.samplers) if (n.containsAt(e2, t4)) return n.elevationAt(e2, t4); return m2.warn("#elevationAt()", `Point used to sample elevation (${e2}, ${t4}) is outside of the sampler`), this.noDataValue; } }; function h(e2, t4) { const n = f2(e2, t4.spatialReference); if (!n) return null; switch (e2.type) { case "point": x(e2, n, t4); break; case "polyline": R2(e2, n, t4); break; case "multipoint": d(e2, n, t4); } return e2; } function f2(e2, n) { if (t(e2)) return null; const s4 = e2.spatialReference; if (s4.equals(n)) return e2; const i2 = M(e2, n); return i2 || m2.error(`Cannot project geometry spatial reference (wkid:${s4.wkid}) to elevation sampler spatial reference (wkid:${n.wkid})`), i2; } function x(e2, t4, n) { e2.z = n.elevationAt(t4.x, t4.y); } function R2(e2, t4, n) { y2.spatialReference = t4.spatialReference; const s4 = e2.hasM && !e2.hasZ; for (let i2 = 0; i2 < e2.paths.length; i2++) { const o = e2.paths[i2], a = t4.paths[i2]; for (let e3 = 0; e3 < o.length; e3++) { const t5 = o[e3], i3 = a[e3]; y2.x = i3[0], y2.y = i3[1], s4 && (t5[3] = t5[2]), t5[2] = n.elevationAt(y2.x, y2.y); } } e2.hasZ = true; } function d(e2, t4, n) { y2.spatialReference = t4.spatialReference; const s4 = e2.hasM && !e2.hasZ; for (let i2 = 0; i2 < e2.points.length; i2++) { const o = e2.points[i2], a = t4.points[i2]; y2.x = a[0], y2.y = a[1], s4 && (o[3] = o[2]), o[2] = n.elevationAt(y2.x, y2.y); } e2.hasZ = true; } var y2 = new w2(); var g = { remove() { } }; // node_modules/@arcgis/core/layers/support/ElevationSamplerData.js var t3 = class { constructor({ values: t4, width: h2, height: i2, noDataValue: s4 }, a) { this.pixelData = t4, this.width = h2, this.height = i2, this.safeWidth = 0.99999999 * (h2 - 1), this.noDataValue = s4, this.dx = (h2 - 1) / (a[2] - a[0]), this.dy = (h2 - 1) / (a[3] - a[1]), this.x0 = a[0], this.y1 = a[3]; } }; // node_modules/@arcgis/core/layers/support/ElevationTile.js var e = class { constructor(a, e2 = null) { if (this.tile = a, this.zmin = 0, this.zmax = 0, r(e2) && r(a)) { const t4 = a.extent; this._samplerData = new t3(e2, t4), this.zmin = e2.minValue, this.zmax = e2.maxValue; } } sample(t4, i2) { if (t(this._samplerData)) return; const { safeWidth: e2, width: r2, pixelData: o, noDataValue: n, dx: l, dy: m3, y1: h2, x0: f3 } = this._samplerData, p2 = s3(m3 * (h2 - i2), 0, e2), u4 = s3(l * (t4 - f3), 0, e2), c4 = Math.floor(p2), x3 = Math.floor(u4), D = c4 * r2 + x3, d2 = D + r2, z = o[D], y3 = o[d2], V = o[D + 1], _2 = o[d2 + 1]; if (z !== n && y3 !== n && V !== n && _2 !== n) { const t5 = u4 - x3, a = z + (V - z) * t5; return a + (y3 + (_2 - y3) * t5 - a) * (p2 - c4); } } }; function s3(t4, a, i2) { return t4 < a ? a : t4 > i2 ? i2 : t4; } // node_modules/@arcgis/core/layers/support/ElevationQuery.js var g2 = class { async queryAll(e2, i2, s4) { if (!(e2 = s4 && s4.ignoreInvisibleLayers ? e2.filter((e3) => e3.visible) : e2.slice()).length) throw new s2("elevation-query:invalid-layer", "Elevation queries require at least one elevation layer to fetch tiles from"); const n = x2.fromGeometry(i2); let o = false; s4 && s4.returnSampleInfo || (o = true); const l = { ...A, ...s4, returnSampleInfo: true }, a = await this.query(e2[e2.length - 1], n, l), r2 = await this._queryAllContinue(e2, a, l); return r2.geometry = r2.geometry.export(), o && delete r2.sampleInfo, r2; } async query(e2, i2, s4) { if (!e2) throw new s2("elevation-query:invalid-layer", "Elevation queries require an elevation layer to fetch tiles from"); if (!i2 || !(i2 instanceof x2) && "point" !== i2.type && "multipoint" !== i2.type && "polyline" !== i2.type) throw new s2("elevation-query:invalid-geometry", "Only point, polyline and multipoint geometries can be used to query elevation"); const n = { ...A, ...s4 }, o = new R3(e2, i2.spatialReference, n), l = n.signal; return await e2.load({ signal: l }), await this._createGeometryDescriptor(o, i2, l), await this._selectTiles(o, l), await this._populateElevationTiles(o, l), this._sampleGeometryWithElevation(o), this._createQueryResult(o, l); } async createSampler(e2, i2, s4) { if (!e2) throw new s2("elevation-query:invalid-layer", "Elevation queries require an elevation layer to fetch tiles from"); if (!i2 || "extent" !== i2.type) throw new s2("elevation-query:invalid-extent", "Invalid or undefined extent"); const n = { ...A, ...s4 }; return this._createSampler(e2, i2, n); } async createSamplerAll(e2, i2, s4) { if (!(e2 = s4 && s4.ignoreInvisibleLayers ? e2.filter((e3) => e3.visible) : e2.slice()).length) throw new s2("elevation-query:invalid-layer", "Elevation queries require at least one elevation layer to fetch tiles from"); if (!i2 || "extent" !== i2.type) throw new s2("elevation-query:invalid-extent", "Invalid or undefined extent"); const n = { ...A, ...s4, returnSampleInfo: true }, o = await this._createSampler(e2[e2.length - 1], i2, n); return this._createSamplerAllContinue(e2, i2, o, n); } async _createSampler(e2, t4, i2, s4) { const n = i2.signal; await e2.load({ signal: n }); const o = t4.spatialReference, l = e2.tileInfo.spatialReference; o.equals(l) || (await _n([{ source: o, dest: l }], { signal: n }), t4 = rn(t4, l)); const a = new q(e2, t4, i2, s4); return await this._selectTiles(a, n), await this._populateElevationTiles(a, n), new p(a.elevationTiles, a.layer.tileInfo, a.options.noDataValue); } async _createSamplerAllContinue(e2, t4, i2, s4) { if (e2.pop(), !e2.length) return i2; const n = i2.samplers.map((e3) => c2(e3.extent)), o = await this._createSampler(e2[e2.length - 1], t4, s4, n); if (0 === o.samplers.length) return i2; const l = i2.samplers.concat(o.samplers), a = new p(l, s4.noDataValue); return this._createSamplerAllContinue(e2, t4, a, s4); } async _queryAllContinue(e2, t4, s4) { const n = e2.pop(), o = t4.geometry.coordinates, l = t4.sampleInfo; c(l); const a = [], r2 = []; for (let i2 = 0; i2 < o.length; i2++) { const t5 = l[i2]; t5.demResolution >= 0 ? t5.source || (t5.source = n) : e2.length && (a.push(o[i2]), r2.push(i2)); } if (!e2.length || 0 === a.length) return t4; const c4 = t4.geometry.clone(a), u4 = await this.query(e2[e2.length - 1], c4, s4), h2 = u4.sampleInfo; if (!h2) throw new Error("no sampleInfo"); return r2.forEach((e3, t5) => { o[e3].z = u4.geometry.coordinates[t5].z, l[e3].demResolution = h2[t5].demResolution; }), this._queryAllContinue(e2, t4, s4); } async _createQueryResult(e2, t4) { const s4 = await e2.geometry.project(e2.outSpatialReference, t4); c(s4); const n = { geometry: s4.export(), noDataValue: e2.options.noDataValue }; return e2.options.returnSampleInfo && (n.sampleInfo = this._extractSampleInfo(e2)), e2.geometry.coordinates.forEach((e3) => { e3.tile = null, e3.elevationTile = null; }), n; } async _createGeometryDescriptor(e2, i2, s4) { let n; const o = e2.layer.tileInfo.spatialReference; if (i2 instanceof x2 ? n = await i2.project(o, s4) : (await _n([{ source: i2.spatialReference, dest: o }], { signal: s4 }), n = rn(i2, o)), !n) throw new s2("elevation-query:spatial-reference-mismatch", `Cannot query elevation in '${i2.spatialReference.wkid}' on an elevation service in '${o.wkid}'`); e2.geometry = x2.fromGeometry(n); } async _selectTiles(e2, i2) { const s4 = e2.options.demResolution; if ("geometry" === e2.type && this._preselectOutsideLayerExtent(e2), "number" == typeof s4) this._selectTilesClosestResolution(e2); else if ("finest-contiguous" === s4) await this._selectTilesFinestContiguous(e2, i2); else { if ("auto" !== s4) throw new s2("elevation-query:invalid-dem-resolution", `Invalid dem resolution value '${s4}', expected a number, "finest-contiguous" or "auto"`); await this._selectTilesAuto(e2, i2); } } _preselectOutsideLayerExtent(e2) { if (t(e2.layer.fullExtent)) return; const t4 = new e(null); t4.sample = () => e2.options.noDataValue, e2.outsideExtentTile = t4; const i2 = e2.layer.fullExtent; e2.geometry.coordinates.forEach((e3) => { const s4 = e3.x, n = e3.y; (s4 < i2.xmin || s4 > i2.xmax || n < i2.ymin || n > i2.ymax) && (e3.elevationTile = t4); }); } _selectTilesClosestResolution(e2) { const t4 = e2.layer.tileInfo, i2 = this._findNearestDemResolutionLODIndex(t4, e2.options.demResolution); e2.selectTilesAtLOD(i2); } _findNearestDemResolutionLODIndex(e2, t4) { const i2 = t4 / $(e2.spatialReference); let s4 = e2.lods[0], n = 0; for (let o = 1; o < e2.lods.length; o++) { const t5 = e2.lods[o]; Math.abs(t5.resolution - i2) < Math.abs(s4.resolution - i2) && (s4 = t5, n = o); } return n; } async _selectTilesFinestContiguous(e2, t4) { const i2 = I(e2.layer.tileInfo, e2.options.minDemResolution); await this._selectTilesFinestContiguousAt(e2, i2, t4); } async _selectTilesFinestContiguousAt(e2, i2, s4) { const n = e2.layer; if (e2.selectTilesAtLOD(i2), i2 < 0) return; const a = n.tilemapCache, r2 = e2.getTilesToFetch(); try { if (a) await y(Promise.all(r2.map((e3) => a.fetchAvailability(e3.level, e3.row, e3.col, { signal: s4 }))), s4); else if (await this._populateElevationTiles(e2, s4), !e2.allElevationTilesFetched()) throw e2.clearElevationTiles(), new s2("elevation-query:has-unavailable-tiles"); } catch (c4) { w(c4), await this._selectTilesFinestContiguousAt(e2, i2 - 1, s4); } } async _populateElevationTiles(e2, t4) { const i2 = e2.getTilesToFetch(), s4 = {}, l = e2.options.cache, r2 = e2.options.noDataValue, c4 = i2.map(async (i3) => { if (null == i3.id) return; const o = `${e2.layer.uid}:${i3.id}:${r2}`, a = r(l) ? l.get(o) : null, c5 = r(a) ? a : await e2.layer.fetchTile(i3.level, i3.row, i3.col, { noDataValue: r2, signal: t4 }); r(l) && l.put(o, c5), s4[i3.id] = new e(i3, c5); }); await y(E(c4), t4), e2.populateElevationTiles(s4); } async _selectTilesAuto(t4, i2) { this._selectTilesAutoFinest(t4), this._reduceTilesForMaximumRequests(t4); const s4 = t4.layer.tilemapCache; if (!s4) return this._selectTilesAutoPrefetchUpsample(t4, i2); const n = t4.getTilesToFetch(), a = {}, r2 = n.map(async (t5) => { const n2 = new t2(null, 0, 0, 0, u2()), o = await b(s4.fetchAvailabilityUpsample(t5.level, t5.row, t5.col, n2, { signal: i2 })); false !== o.ok ? null != t5.id && (a[t5.id] = n2) : w(o.error); }); await y(Promise.all(r2), i2), t4.remapTiles(a); } _reduceTilesForMaximumRequests(e2) { const t4 = e2.layer.tileInfo; let i2 = 0; const s4 = {}, n = (e3) => { null != e3.id && (e3.id in s4 ? s4[e3.id]++ : (s4[e3.id] = 1, i2++)); }, o = (e3) => { if (null == e3.id) return; const t5 = s4[e3.id]; 1 === t5 ? (delete s4[e3.id], i2--) : s4[e3.id] = t5 - 1; }; e2.forEachTileToFetch(n, o); let l = true; for (; l && (l = false, e2.forEachTileToFetch((s5) => { i2 <= e2.options.maximumAutoTileRequests || (o(s5), t4.upsampleTile(s5) && (l = true), n(s5)); }, o), l); ) ; } _selectTilesAutoFinest(e2) { const t4 = I(e2.layer.tileInfo, e2.options.minDemResolution); e2.selectTilesAtLOD(t4, e2.options.maximumAutoTileRequests); } async _selectTilesAutoPrefetchUpsample(e2, t4) { const i2 = e2.layer.tileInfo; await this._populateElevationTiles(e2, t4); let s4 = false; e2.forEachTileToFetch((e3, t5) => { i2.upsampleTile(e3) ? s4 = true : t5(); }), s4 && await this._selectTilesAutoPrefetchUpsample(e2, t4); } _sampleGeometryWithElevation(e2) { e2.geometry.coordinates.forEach((t4) => { const i2 = t4.elevationTile; let s4 = e2.options.noDataValue; if (i2) { const e3 = i2.sample(t4.x, t4.y); r(e3) ? s4 = e3 : t4.elevationTile = null; } t4.z = s4; }); } _extractSampleInfo(e2) { const t4 = e2.layer.tileInfo, i2 = $(t4.spatialReference); return e2.geometry.coordinates.map((s4) => { let n = -1; if (s4.elevationTile && s4.elevationTile !== e2.outsideExtentTile) { n = t4.lodAt(s4.elevationTile.tile.level).resolution * i2; } return { demResolution: n }; }); } }; var x2 = class { export() { return this._exporter(this.coordinates, this.spatialReference); } clone(e2) { const t4 = new x2(); return t4.geometry = this.geometry, t4.spatialReference = this.spatialReference, t4.coordinates = e2 || this.coordinates.map((e3) => e3.clone()), t4._exporter = this._exporter, t4; } async project(e2, t4) { if (this.spatialReference.equals(e2)) return this.clone(); await _n([{ source: this.spatialReference, dest: e2 }], { signal: t4 }); const i2 = new u({ spatialReference: this.spatialReference, points: this.coordinates.map((e3) => [e3.x, e3.y]) }), s4 = rn(i2, e2); if (!s4) return null; const n = this.coordinates.map((e3, t5) => { const i3 = e3.clone(), n2 = s4.points[t5]; return i3.x = n2[0], i3.y = n2[1], i3; }), o = this.clone(n); return o.spatialReference = e2, o; } static fromGeometry(e2) { const t4 = new x2(); if (t4.geometry = e2, t4.spatialReference = e2.spatialReference, e2 instanceof x2) t4.coordinates = e2.coordinates.map((e3) => e3.clone()), t4._exporter = (t5, i2) => { const s4 = e2.clone(t5); return s4.spatialReference = i2, s4; }; else switch (e2.type) { case "point": { const i2 = e2, { hasZ: s4, hasM: n } = i2; t4.coordinates = s4 && n ? [new _(i2.x, i2.y, i2.z, i2.m)] : s4 ? [new _(i2.x, i2.y, i2.z)] : n ? [new _(i2.x, i2.y, null, i2.m)] : [new _(i2.x, i2.y)], t4._exporter = (t5, i3) => e2.hasM ? new w2(t5[0].x, t5[0].y, t5[0].z, t5[0].m, i3) : new w2(t5[0].x, t5[0].y, t5[0].z, i3); break; } case "multipoint": { const i2 = e2, { hasZ: s4, hasM: n } = i2; t4.coordinates = s4 && n ? i2.points.map((e3) => new _(e3[0], e3[1], e3[2], e3[3])) : s4 ? i2.points.map((e3) => new _(e3[0], e3[1], e3[2])) : n ? i2.points.map((e3) => new _(e3[0], e3[1], null, e3[2])) : i2.points.map((e3) => new _(e3[0], e3[1])), t4._exporter = (t5, i3) => e2.hasM ? new u({ points: t5.map((e3) => [e3.x, e3.y, e3.z, e3.m]), hasZ: true, hasM: true, spatiaReference: i3 }) : new u(t5.map((e3) => [e3.x, e3.y, e3.z]), i3); break; } case "polyline": { const i2 = e2, s4 = [], n = [], { hasZ: o, hasM: l } = e2; let a = 0; for (const e3 of i2.paths) if (n.push([a, a + e3.length]), a += e3.length, o && l) for (const t5 of e3) s4.push(new _(t5[0], t5[1], t5[2], t5[3])); else if (o) for (const t5 of e3) s4.push(new _(t5[0], t5[1], t5[2])); else if (l) for (const t5 of e3) s4.push(new _(t5[0], t5[1], null, t5[2])); else for (const t5 of e3) s4.push(new _(t5[0], t5[1])); t4.coordinates = s4, t4._exporter = (t5, i3) => { const s5 = e2.hasM ? t5.map((e3) => [e3.x, e3.y, e3.z, e3.m]) : t5.map((e3) => [e3.x, e3.y, e3.z]), o2 = n.map((e3) => s5.slice(e3[0], e3[1])); return new m({ paths: o2, hasM: e2.hasM, hasZ: true, spatialReference: i3 }); }; break; } } return t4; } }; var _ = class { constructor(e2, t4, i2 = null, s4 = null, n = null, o = null) { this.x = e2, this.y = t4, this.z = i2, this.m = s4, this.tile = n, this.elevationTile = o; } clone() { return new _(this.x, this.y, this.z, this.m); } }; var E2 = class { constructor(e2, t4) { this.layer = e2, this.options = t4; } }; var R3 = class extends E2 { constructor(e2, t4, i2) { super(e2, i2), this.outSpatialReference = t4, this.type = "geometry"; } selectTilesAtLOD(e2) { if (e2 < 0) this.geometry.coordinates.forEach((e3) => { e3.tile = null; }); else { const t4 = this.layer.tileInfo, i2 = t4.lods[e2].level; this.geometry.coordinates.forEach((e3) => { e3.tile = t4.tileAt(i2, e3.x, e3.y); }); } } allElevationTilesFetched() { return !this.geometry.coordinates.some((e2) => !e2.elevationTile); } clearElevationTiles() { for (const e2 of this.geometry.coordinates) e2.elevationTile !== this.outsideExtentTile && (e2.elevationTile = null); } populateElevationTiles(e2) { var _a; for (const t4 of this.geometry.coordinates) !t4.elevationTile && ((_a = t4.tile) == null ? void 0 : _a.id) && (t4.elevationTile = e2[t4.tile.id]); } remapTiles(e2) { var _a; for (const t4 of this.geometry.coordinates) { const i2 = (_a = t4.tile) == null ? void 0 : _a.id; t4.tile = i2 ? e2[i2] : null; } } getTilesToFetch() { var _a; const e2 = {}, t4 = []; for (const i2 of this.geometry.coordinates) { const s4 = i2.tile; if (!s4) continue; const n = (_a = i2.tile) == null ? void 0 : _a.id; i2.elevationTile || !n || e2[n] || (e2[n] = s4, t4.push(s4)); } return t4; } forEachTileToFetch(e2) { for (const t4 of this.geometry.coordinates) t4.tile && !t4.elevationTile && e2(t4.tile, () => { t4.tile = null; }); } }; var q = class extends E2 { constructor(e2, t4, i2, s4) { super(e2, i2), this.type = "extent", this.elevationTiles = [], this._candidateTiles = [], this._fetchedCandidates = /* @__PURE__ */ new Set(), this.extent = t4.intersection(e2.fullExtent), this.maskExtents = s4; } selectTilesAtLOD(e2, t4) { const i2 = this._maximumLodForRequests(t4), s4 = Math.min(i2, e2); s4 < 0 ? this._candidateTiles.length = 0 : this._selectCandidateTilesCoveringExtentAt(s4); } _maximumLodForRequests(e2) { const t4 = this.layer.tileInfo; if (!e2) return t4.lods.length - 1; const i2 = this.extent; if (t(i2)) return -1; for (let s4 = t4.lods.length - 1; s4 >= 0; s4--) { const n = t4.lods[s4], o = n.resolution * t4.size[0], l = n.resolution * t4.size[1]; if (Math.ceil(i2.width / o) * Math.ceil(i2.height / l) <= e2) return s4; } return -1; } allElevationTilesFetched() { return this._candidateTiles.length === this.elevationTiles.length; } clearElevationTiles() { this.elevationTiles.length = 0, this._fetchedCandidates.clear(); } populateElevationTiles(e2) { for (const t4 of this._candidateTiles) { const i2 = t4.id && e2[t4.id]; i2 && (this._fetchedCandidates.add(t4), this.elevationTiles.push(i2)); } } remapTiles(e2) { this._candidateTiles = this._uniqueNonOverlappingTiles(this._candidateTiles.map((t4) => e2[t4.id])); } getTilesToFetch() { return this._candidateTiles; } forEachTileToFetch(e2, t4) { const i2 = this._candidateTiles; this._candidateTiles = [], i2.forEach((i3) => { if (this._fetchedCandidates.has(i3)) return void (t4 && t4(i3)); let s4 = false; e2(i3, () => s4 = true), s4 ? t4 && t4(i3) : this._candidateTiles.push(i3); }), this._candidateTiles = this._uniqueNonOverlappingTiles(this._candidateTiles, t4); } _uniqueNonOverlappingTiles(e2, t4) { const i2 = {}, s4 = []; for (const o of e2) { const e3 = o.id; e3 && !i2[e3] ? (i2[e3] = o, s4.push(o)) : t4 && t4(o); } const n = s4.sort((e3, t5) => e3.level - t5.level); return n.filter((e3, i3) => { for (let s5 = 0; s5 < i3; s5++) { const i4 = n[s5].extent; if (i4 && e3.extent && R(i4, e3.extent)) return t4 && t4(e3), false; } return true; }); } _selectCandidateTilesCoveringExtentAt(e2) { this._candidateTiles.length = 0; const t4 = this.extent; if (t(t4)) return; const i2 = this.layer.tileInfo, n = i2.lods[e2], o = i2.tileAt(n.level, t4.xmin, t4.ymin), l = o.extent; if (t(l)) return; const a = n.resolution * i2.size[0], r2 = n.resolution * i2.size[1], c4 = Math.ceil((t4.xmax - l[0]) / a), u4 = Math.ceil((t4.ymax - l[1]) / r2); for (let s4 = 0; s4 < u4; s4++) for (let e3 = 0; e3 < c4; e3++) { const t5 = new t2(null, o.level, o.row - s4, o.col + e3); i2.updateTileInfo(t5), this._tileIsMasked(t5) || this._candidateTiles.push(t5); } } _tileIsMasked(e2) { return !!this.maskExtents && this.maskExtents.some((t4) => e2.extent && R(t4, e2.extent)); } }; function I(e2, t4 = 0) { let i2 = e2.lods.length - 1; if (t4 > 0) { const s4 = t4 / $(e2.spatialReference), n = e2.lods.findIndex((e3) => e3.resolution < s4); 0 === n ? i2 = 0 : n > 0 && (i2 = n - 1); } return i2; } var A = { maximumAutoTileRequests: 20, noDataValue: 0, returnSampleInfo: false, demResolution: "auto", minDemResolution: 0 }; export { g2 as ElevationQuery, x2 as GeometryDescriptor, I as getFinestLodIndex }; //# sourceMappingURL=ElevationQuery-PFI6RXXM.js.map