import { o as o2 } from "./chunk-FEH5F4VW.js"; import { o as o3 } from "./chunk-JARMALQK.js"; import { p, x } from "./chunk-UYUDNSNC.js"; import { u } from "./chunk-NE3ESGA6.js"; import { U, l as l2 } from "./chunk-YIS6BAC3.js"; import { v } from "./chunk-KHA63LLS.js"; import { c } from "./chunk-FGKNEJKJ.js"; import "./chunk-PSV473TI.js"; import { O } from "./chunk-I3OBGWNS.js"; import "./chunk-FONIFA5N.js"; import "./chunk-EG5OI4V4.js"; import "./chunk-65BYCSII.js"; import "./chunk-WZQZRKNH.js"; import "./chunk-LRDX4TO7.js"; import "./chunk-6A4U74YA.js"; import { S } from "./chunk-RBZL6SRZ.js"; import { n as n2 } from "./chunk-CYI7KFYB.js"; import { a } from "./chunk-5LXROFTA.js"; import "./chunk-GJXW4HL5.js"; import "./chunk-WJW5DUN6.js"; import { t as t2 } from "./chunk-W72F6AS3.js"; import "./chunk-PJ7ZQ4VD.js"; import "./chunk-WDLTDV2L.js"; import "./chunk-TERAW6FT.js"; import "./chunk-N2663GRX.js"; import { u as u2 } from "./chunk-O4FY3ITT.js"; import "./chunk-WEMIK25H.js"; import { b } from "./chunk-4DDBH2K5.js"; import "./chunk-7N4X6GF3.js"; import "./chunk-JXW4QTJA.js"; import "./chunk-UXF37FQ4.js"; import "./chunk-ZOEK6QHJ.js"; import "./chunk-XNLG7T2T.js"; import "./chunk-IR4PV7VK.js"; import "./chunk-2Z6LERTI.js"; import "./chunk-OWVBLVP3.js"; import "./chunk-EGZW6HC3.js"; import "./chunk-4NKD334K.js"; import "./chunk-65K7LC56.js"; import "./chunk-ATPLLI5W.js"; import "./chunk-WJ3OEUD3.js"; import "./chunk-MXB2XLKV.js"; import "./chunk-XH7RUGVZ.js"; import "./chunk-TBBTRX4O.js"; import "./chunk-YBSUITLL.js"; import { j as j2 } from "./chunk-ALDCDSPV.js"; import "./chunk-DT6EAZQ5.js"; import "./chunk-HNOZUNJ4.js"; import { U as U2 } from "./chunk-VNFRAYHO.js"; import "./chunk-R5IG2D6H.js"; import { I, j as j3 } from "./chunk-VBRY5KJM.js"; import "./chunk-PDKDCAAD.js"; import { M2 as M, j2 as j, o } from "./chunk-ECW2QABR.js"; import "./chunk-GCDJLKH4.js"; import { r as r2, r2 as r3 } from "./chunk-MRJEICT6.js"; import { d, e, l3 as l, n2 as n } from "./chunk-Y3WMVFTW.js"; import "./chunk-SAS7RONY.js"; import "./chunk-WSRBH7BF.js"; import "./chunk-IHXECKQQ.js"; import { q, w } from "./chunk-ULGDPLM2.js"; import { s3 as s } from "./chunk-EMJ4ZSM2.js"; import { m, t } from "./chunk-IKP3YN53.js"; import { r } from "./chunk-GZT4BVFP.js"; import "./chunk-A5ICIBVI.js"; // node_modules/@arcgis/core/layers/support/TileInfoTilemapCache.js var l3 = class { constructor(i2, l5 = 0, a2 = i2.lods.length - 1) { this.tileInfo = i2, this.minLOD = l5, this.maxLOD = a2; } getAvailability(i2, l5, a2) { const t3 = this.tileInfo.lodAt(i2); return !t3 || i2 < this.minLOD || i2 > this.maxLOD ? "unavailable" : t3.cols && t3.rows ? a2 >= t3.cols[0] && a2 <= t3.cols[1] && l5 >= t3.rows[0] && l5 <= t3.rows[1] ? "available" : "unavailable" : "available"; } async fetchAvailability(l5, a2, t3, e2) { return await q(e2), this.getAvailability(l5, a2, t3); } async fetchAvailabilityUpsample(l5, a2, t3, e2, s2) { await q(s2), e2.level = l5, e2.row = a2, e2.col = t3; const o5 = this.tileInfo; for (o5.updateTileInfo(e2); ; ) { const i2 = this.getAvailability(e2.level, e2.row, e2.col); if (i2 !== "unavailable") return i2; if (!o5.upsampleTile(e2)) return "unavailable"; } } }; // node_modules/@arcgis/core/layers/support/TileMatrixSet.js var l4; var n3 = l4 = class extends l { constructor(t3) { super(t3), this.fullExtent = null, this.id = null, this.tileInfo = null; } clone() { const t3 = new l4(); return this.hasOwnProperty("fullExtent") && (t3.fullExtent = this.fullExtent && this.fullExtent.clone()), this.hasOwnProperty("id") && (t3.id = this.id), this.hasOwnProperty("tileInfo") && (t3.tileInfo = this.tileInfo && this.tileInfo.clone()), t3; } }; e([d({ type: M, json: { read: { source: "fullExtent" } } })], n3.prototype, "fullExtent", void 0), e([d({ type: String, json: { read: { source: "id" } } })], n3.prototype, "id", void 0), e([d({ type: S, json: { read: { source: "tileInfo" } } })], n3.prototype, "tileInfo", void 0), n3 = l4 = e([n("esri.layer.support.TileMatrixSet")], n3); var p2 = n3; // node_modules/@arcgis/core/layers/support/WMTSStyle.js var o4; var i = o4 = class extends l { constructor(r4) { super(r4), this.id = null, this.title = null, this.description = null, this.legendUrl = null; } clone() { const r4 = new o4(); return this.hasOwnProperty("description") && (r4.description = this.description), this.hasOwnProperty("id") && (r4.id = this.id), this.hasOwnProperty("isDefault") && (r4.isDefault = this.isDefault), this.hasOwnProperty("keywords") && (r4.keywords = this.keywords && this.keywords.slice()), this.hasOwnProperty("legendUrl") && (r4.legendUrl = this.legendUrl), this.hasOwnProperty("title") && (r4.title = this.title), r4; } }; e([d({ json: { read: { source: "id" } } })], i.prototype, "id", void 0), e([d({ json: { read: { source: "title" } } })], i.prototype, "title", void 0), e([d({ json: { read: { source: "abstract" } } })], i.prototype, "description", void 0), e([d({ json: { read: { source: "legendUrl" } } })], i.prototype, "legendUrl", void 0), e([d({ json: { read: { source: "isDefault" } } })], i.prototype, "isDefault", void 0), e([d({ json: { read: { source: "keywords" } } })], i.prototype, "keywords", void 0), i = o4 = e([n("esri.layer.support.WMTSStyle")], i); var p3 = i; // node_modules/@arcgis/core/layers/support/WMTSSublayer.js var p4; var h = p4 = class extends l { constructor(t3) { super(t3), this.fullExtent = null, this.fullExtents = null, this.imageFormats = null, this.id = null, this.layer = null, this.styles = null, this.tileMatrixSetId = null, this.tileMatrixSets = null; } get description() { return this._get("description"); } set description(t3) { this._set("description", t3); } readFullExtent(t3, e2) { return (t3 = e2.fullExtent) ? M.fromJSON(t3) : null; } readFullExtents(t3, e2) { return e2.fullExtents?.length ? e2.fullExtents.map((t4) => M.fromJSON(t4)) : e2.tileMatrixSets.map((t4) => M.fromJSON(t4.fullExtent)).filter((t4) => t4); } get imageFormat() { let t3 = this._get("imageFormat"); return t3 || (t3 = this.imageFormats && this.imageFormats.length ? this.imageFormats[0] : ""), t3; } set imageFormat(t3) { const e2 = this.imageFormats; t3 && (t3.includes("image/") || e2 && !e2.includes(t3)) && (t3.includes("image/") || (t3 = "image/" + t3), e2 && !e2.includes(t3)) ? console.error("The layer doesn't support the format of " + t3) : this._set("imageFormat", t3); } get styleId() { let t3 = this._get("styleId"); return t3 || (t3 = this.styles && this.styles.length ? this.styles.getItemAt(0).id : ""), t3; } set styleId(t3) { this._set("styleId", t3); } get title() { return this._get("title"); } set title(t3) { this._set("title", t3); } get tileMatrixSet() { return this.tileMatrixSets ? this.tileMatrixSets.find((t3) => t3.id === this.tileMatrixSetId) : null; } clone() { const t3 = new p4(); return this.hasOwnProperty("description") && (t3.description = this.description), this.hasOwnProperty("imageFormats") && (t3.imageFormats = this.imageFormats && this.imageFormats.slice()), this.hasOwnProperty("imageFormat") && (t3.imageFormat = this.imageFormat), this.hasOwnProperty("fullExtent") && (t3.fullExtent = this.fullExtent && this.fullExtent.clone()), this.hasOwnProperty("id") && (t3.id = this.id), this.hasOwnProperty("layer") && (t3.layer = this.layer), this.hasOwnProperty("styleId") && (t3.styleId = this.styleId), this.hasOwnProperty("styles") && (t3.styles = this.styles && this.styles.clone()), this.hasOwnProperty("tileMatrixSetId") && (t3.tileMatrixSetId = this.tileMatrixSetId), this.hasOwnProperty("tileMatrixSets") && (t3.tileMatrixSets = this.tileMatrixSets.clone()), this.hasOwnProperty("title") && (t3.title = this.title), t3; } }; e([d()], h.prototype, "description", null), e([d()], h.prototype, "fullExtent", void 0), e([o("fullExtent", ["fullExtent"])], h.prototype, "readFullExtent", null), e([d({ readOnly: true })], h.prototype, "fullExtents", void 0), e([o("fullExtents", ["fullExtents", "tileMatrixSets"])], h.prototype, "readFullExtents", null), e([d()], h.prototype, "imageFormat", null), e([d({ json: { read: { source: "formats" } } })], h.prototype, "imageFormats", void 0), e([d()], h.prototype, "id", void 0), e([d()], h.prototype, "layer", void 0), e([d()], h.prototype, "styleId", null), e([d({ type: j2.ofType(p3), json: { read: { source: "styles" } } })], h.prototype, "styles", void 0), e([d({ value: null, json: { write: { ignoreOrigin: true } } })], h.prototype, "title", null), e([d()], h.prototype, "tileMatrixSetId", void 0), e([d({ readOnly: true })], h.prototype, "tileMatrixSet", null), e([d({ type: j2.ofType(p2), json: { read: { source: "tileMatrixSets" } } })], h.prototype, "tileMatrixSets", void 0), h = p4 = e([n("esri.layers.support.WMTSSublayer")], h); var m2 = h; // node_modules/@arcgis/core/layers/support/wmtsUtils.js var c2 = 90.71428571428571; function u3(t3) { const n4 = t3.replace(/ows:/gi, ""); if (!m3("Contents", new DOMParser().parseFromString(n4, "text/xml").documentElement)) throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid", "the wmts get capabilities response is not compliant", { text: t3 }); } function p5(t3, n4) { t3 = t3.replace(/ows:/gi, ""); const i2 = new DOMParser().parseFromString(t3, "text/xml").documentElement, r4 = new Map(), o5 = new Map(), l5 = m3("Contents", i2); if (!l5) throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid"); const s2 = m3("OperationsMetadata", i2)?.querySelector("[name='GetTile']"), a2 = s2?.getElementsByTagName("Get"), c3 = a2 && Array.prototype.slice.call(a2), u4 = n4?.url?.indexOf("https") > -1; let p6, f2, d3 = n4.serviceMode, x3 = n4 && n4.url; if (c3 && c3.length && c3.some((e2) => { const t4 = m3("Constraint", e2); return !t4 || w2("AllowedValues", "Value", d3, t4) ? (x3 = e2.attributes[0].nodeValue, true) : (!t4 || w2("AllowedValues", "Value", "RESTful", t4) || w2("AllowedValues", "Value", "REST", t4) ? f2 = e2.attributes[0].nodeValue : t4 && !w2("AllowedValues", "Value", "KVP", t4) || (p6 = e2.attributes[0].nodeValue), false); }), !x3) if (f2) x3 = f2, d3 = "RESTful"; else if (p6) x3 = p6, d3 = "KVP"; else { const e2 = m3("ServiceMetadataURL", i2); x3 = e2 && e2.getAttribute("xlink:href"); } const M3 = x3.indexOf("1.0.0/"); M3 === -1 && d3 === "RESTful" ? x3 += "/" : M3 > -1 && (x3 = x3.substring(0, M3)), d3 === "KVP" && (x3 += M3 > -1 ? "" : "?"), u4 && (x3 = x3.replace(/^http:/i, "https:")); const T2 = h2("ServiceIdentification>ServiceTypeVersion", i2), y2 = h2("ServiceIdentification>AccessConstraints", i2), S3 = /^none$/i.test(y2) ? null : y2, R2 = g("Layer", l5), V3 = g("TileMatrixSet", l5), b3 = R2.map((e2) => { const t4 = h2("Identifier", e2); return r4.set(t4, e2), C(t4, e2, V3, u4, T2); }); return { copyright: S3, dimensionMap: o5, layerMap: r4, layers: b3, serviceMode: d3, tileUrl: x3 }; } function f(e2) { return e2.layers.forEach((e3) => { e3.tileMatrixSets.forEach((e4) => { const t3 = e4.tileInfo; t3.dpi !== 96 && (t3.lods.forEach((n4) => { n4.scale = 96 * n4.scale / t3.dpi, n4.resolution = U3(t3.spatialReference.wkid, n4.scale * c2 / 96, e4.id); }), t3.dpi = 96); }); }), e2; } function d2(e2) { return e2.nodeType === Node.ELEMENT_NODE; } function m3(e2, t3) { for (let n4 = 0; n4 < t3.childNodes.length; n4++) { const i2 = t3.childNodes[n4]; if (d2(i2) && i2.nodeName === e2) return i2; } return null; } function g(e2, t3) { const n4 = []; for (let i2 = 0; i2 < t3.childNodes.length; i2++) { const r4 = t3.childNodes[i2]; d2(r4) && r4.nodeName === e2 && n4.push(r4); } return n4; } function x2(e2, t3) { const n4 = []; for (let i2 = 0; i2 < t3.childNodes.length; i2++) { const r4 = t3.childNodes[i2]; d2(r4) && r4.nodeName === e2 && n4.push(r4); } return n4.map((e3) => e3.textContent); } function h2(e2, t3) { return e2.split(">").forEach((e3) => { t3 && (t3 = m3(e3, t3)); }), t3 && t3.textContent; } function w2(e2, t3, n4, i2) { let r4; return Array.prototype.slice.call(i2.childNodes).some((i3) => { if (i3.nodeName.includes(e2)) { const e3 = m3(t3, i3), o5 = e3 && e3.textContent; if (o5 === n4 || n4.split(":") && n4.split(":")[1] === o5) return r4 = i3, true; } return false; }), r4; } function C(e2, t3, n4, i2, r4) { const o5 = h2("Abstract", t3), l5 = x2("Format", t3); return { id: e2, fullExtent: R(t3), fullExtents: V(t3), description: o5, formats: l5, styles: b2(t3, i2), title: h2("Title", t3), tileMatrixSets: E(r4, t3, n4) }; } function M2(e2, t3) { const n4 = [], i2 = e2.layerMap?.get(t3); if (!i2) return; const r4 = g("ResourceURL", i2), o5 = g("Dimension", i2); let l5, s2, a2, c3; return o5.length && (l5 = h2("Identifier", o5[0]), s2 = x2("Default", o5[0]) || x2("Value", o5[0])), o5.length > 1 && (a2 = h2("Identifier", o5[1]), c3 = x2("Default", o5[1]) || x2("Value", o5[1])), e2.dimensionMap.set(t3, { dimensions: s2, dimensions2: c3 }), r4.forEach((e3) => { let t4 = e3.getAttribute("template"); if (e3.getAttribute("resourceType") === "tile") { if (l5 && s2.length) if (t4.includes("{" + l5 + "}")) t4 = t4.replace("{" + l5 + "}", "{dimensionValue}"); else { const e4 = t4.toLowerCase().indexOf("{" + l5.toLowerCase() + "}"); e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue}" + t4.substring(e4 + l5.length + 2)); } if (a2 && c3.length) if (t4.includes("{" + a2 + "}")) t4 = t4.replace("{" + a2 + "}", "{dimensionValue2}"); else { const e4 = t4.toLowerCase().indexOf("{" + a2.toLowerCase() + "}"); e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue2}" + t4.substring(e4 + a2.length + 2)); } n4.push({ template: t4, format: e3.getAttribute("format"), resourceType: "tile" }); } }), n4; } function T(e2, t3, n4, i2, r4, o5, l5, s2) { const a2 = y(e2, t3, i2); if (!(a2?.length > 0)) return ""; const { dimensionMap: c3 } = e2, u4 = c3.get(t3).dimensions?.[0], p6 = c3.get(t3).dimensions2?.[0]; return a2[l5 % a2.length].template.replace(/\{Style\}/gi, r4).replace(/\{TileMatrixSet\}/gi, n4).replace(/\{TileMatrix\}/gi, o5).replace(/\{TileRow\}/gi, "" + l5).replace(/\{TileCol\}/gi, "" + s2).replace(/\{dimensionValue\}/gi, u4).replace(/\{dimensionValue2\}/gi, p6); } function y(e2, t3, n4) { const i2 = M2(e2, t3), r4 = i2.filter((e3) => e3.format === n4); return r4.length ? r4 : i2; } function S2(e2, t3, n4, i2) { const { dimensionMap: r4 } = e2, o5 = M2(e2, t3); let l5 = ""; if (o5 && o5.length > 0) { const e3 = r4.get(t3).dimensions && r4.get(t3).dimensions[0], s2 = r4.get(t3).dimensions2 && r4.get(t3).dimensions2[0]; l5 = o5[0].template, l5.indexOf(".xxx") === l5.length - 4 && (l5 = l5.slice(0, l5.length - 4)), l5 = l5.replace(/\{Style\}/gi, i2), l5 = l5.replace(/\{TileMatrixSet\}/gi, n4), l5 = l5.replace(/\{TileMatrix\}/gi, "{level}"), l5 = l5.replace(/\{TileRow\}/gi, "{row}"), l5 = l5.replace(/\{TileCol\}/gi, "{col}"), l5 = l5.replace(/\{dimensionValue\}/gi, e3), l5 = l5.replace(/\{dimensionValue2\}/gi, s2); } return l5; } function R(e2) { const t3 = m3("WGS84BoundingBox", e2), n4 = t3 ? h2("LowerCorner", t3).split(" ") : ["-180", "-90"], i2 = t3 ? h2("UpperCorner", t3).split(" ") : ["180", "90"]; return { xmin: parseFloat(n4[0]), ymin: parseFloat(n4[1]), xmax: parseFloat(i2[0]), ymax: parseFloat(i2[1]), spatialReference: { wkid: 4326 } }; } function V(e2) { const t3 = []; return o2(e2, { BoundingBox: (e3) => { if (!e3.getAttribute("crs")) return; const n4 = e3.getAttribute("crs").toLowerCase(), i2 = I2(n4), r4 = n4.includes("epsg") && o3(i2.wkid); let o5, a2, c3, u4; o2(e3, { LowerCorner: (e4) => { [o5, a2] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([o5, a2] = [a2, o5]); }, UpperCorner: (e4) => { [c3, u4] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([c3, u4] = [u4, c3]); } }), t3.push({ xmin: o5, ymin: a2, xmax: c3, ymax: u4, spatialReference: i2 }); } }), t3; } function b2(e2, t3) { return g("Style", e2).map((e3) => { const n4 = m3("LegendURL", e3), i2 = m3("Keywords", e3), r4 = i2 && x2("Keyword", i2); let o5 = n4 && n4.getAttribute("xlink:href"); t3 && (o5 = o5 && o5.replace(/^http:/i, "https:")); return { abstract: h2("Abstract", e3), id: h2("Identifier", e3), isDefault: e3.getAttribute("isDefault") === "true", keywords: r4, legendUrl: o5, title: h2("Title", e3) }; }); } function E(e2, t3, n4) { return g("TileMatrixSetLink", t3).map((t4) => L(e2, t4, n4)); } function L(e2, t3, n4) { const i2 = m3("TileMatrixSet", t3).textContent, r4 = x2("TileMatrix", t3), o5 = n4.find((e3) => { const t4 = m3("Identifier", e3), n5 = t4 && t4.textContent; return !!(n5 === i2 || i2.split(":") && i2.split(":")[1] === n5); }), l5 = m3("TileMatrixSetLimits", t3), s2 = l5 && g("TileMatrixLimits", l5), c3 = new Map(); if (s2?.length) for (const a2 of s2) { const e3 = m3("TileMatrix", a2).textContent, t4 = +m3("MinTileRow", a2).textContent, n5 = +m3("MaxTileRow", a2).textContent, i3 = +m3("MinTileCol", a2).textContent, r5 = +m3("MaxTileCol", a2).textContent; c3.set(e3, { minCol: i3, maxCol: r5, minRow: t4, maxRow: n5 }); } const u4 = h2("SupportedCRS", o5).toLowerCase(), p6 = N(o5, u4), f2 = p6.spatialReference, d3 = m3("TileMatrix", o5), C2 = [parseInt(h2("TileWidth", d3), 10), parseInt(h2("TileHeight", d3), 10)], M3 = []; if (r4.length) r4.forEach((e3, t4) => { const n5 = w2("TileMatrix", "Identifier", e3, o5); M3.push(D(n5, u4, t4, i2, c3)); }); else { g("TileMatrix", o5).forEach((e3, t4) => { M3.push(D(e3, u4, t4, i2, c3)); }); } const T2 = F(e2, o5, p6, C2, M3[0]).toJSON(), y2 = new S({ dpi: 96, spatialReference: f2, size: C2, origin: p6, lods: M3 }).toJSON(); return { id: i2, fullExtent: T2, tileInfo: y2 }; } function I2(e2) { e2 = e2.toLowerCase(); let n4 = parseInt(e2.split(":").pop(), 10); n4 !== 900913 && n4 !== 3857 || (n4 = 102100); const i2 = k(e2); return r(i2) && (n4 = i2), { wkid: n4 }; } function N(e2, t3) { return A(m3("TileMatrix", e2), t3); } function A(e2, t3) { const n4 = I2(t3), [r4, o5] = h2("TopLeftCorner", e2).split(" ").map((e3) => parseFloat(e3)), s2 = t3.includes("epsg") && o3(n4.wkid); return new j(s2 ? { x: o5, y: r4, spatialReference: n4 } : { x: r4, y: o5, spatialReference: n4 }); } function F(e2, t3, i2, r4, o5) { const l5 = m3("BoundingBox", t3); let s2, a2, c3, u4, p6, f2; if (l5 && (s2 = h2("LowerCorner", l5).split(" "), a2 = h2("UpperCorner", l5).split(" ")), s2 && s2.length > 1 && a2 && a2.length > 1) c3 = parseFloat(s2[0]), p6 = parseFloat(s2[1]), u4 = parseFloat(a2[0]), f2 = parseFloat(a2[1]); else { const e3 = m3("TileMatrix", t3), n4 = parseInt(h2("MatrixWidth", e3), 10), l6 = parseInt(h2("MatrixHeight", e3), 10); c3 = i2.x, f2 = i2.y, u4 = c3 + n4 * r4[0] * o5.resolution, p6 = f2 - l6 * r4[1] * o5.resolution; } return v2(e2, i2.spatialReference) ? new M(p6, c3, f2, u4, i2.spatialReference) : new M(c3, p6, u4, f2, i2.spatialReference); } function v2(e2, t3) { return e2 === "1.0.0" && o3(t3.wkid); } var O2; function k(e2) { return e2.includes("crs84") || e2.includes("crs:84") ? O2.CRS84 : e2.includes("crs83") || e2.includes("crs:83") ? O2.CRS83 : e2.includes("crs27") || e2.includes("crs:27") ? O2.CRS27 : null; } function D(e2, t3, n4, i2, r4) { const o5 = I2(t3), l5 = h2("Identifier", e2); let s2 = parseFloat(h2("ScaleDenominator", e2)); const a2 = U3(o5.wkid, s2, i2); s2 *= 96 / c2; const u4 = +h2("MatrixWidth", e2), p6 = +h2("MatrixHeight", e2), { maxCol: f2 = u4 - 1, maxRow: d3 = p6 - 1, minCol: m4 = 0, minRow: g2 = 0 } = r4.get(l5) ?? {}, { x: x3, y: w3 } = A(e2, t3); return { cols: [m4, f2], level: n4, levelValue: l5, origin: [x3, w3], scale: s2, resolution: a2, rows: [g2, d3] }; } function U3(e2, t3, n4) { let i2; return i2 = r3.hasOwnProperty("" + e2) ? r3.values[r3[e2]] : n4 === "default028mm" ? 6370997 * Math.PI / 180 : u2(e2).metersPerDegree, 7 * t3 / 25e3 / i2; } !function(e2) { e2[e2.CRS84 = 4326] = "CRS84", e2[e2.CRS83 = 4269] = "CRS83", e2[e2.CRS27 = 4267] = "CRS27"; }(O2 || (O2 = {})); // node_modules/@arcgis/core/layers/WMTSLayer.js var O3 = { "image/png": ".png", "image/png8": ".png", "image/png24": ".png", "image/png32": ".png", "image/jpg": ".jpg", "image/jpeg": ".jpeg", "image/gif": ".gif", "image/bmp": ".bmp", "image/tiff": ".tif", "image/jpgpng": "", "image/jpegpng": "", "image/unknown": "" }; var W = new Set(["version", "service", "request", "layer", "style", "format", "tilematrixset", "tilematrix", "tilerow", "tilecol"]); var A2 = class extends a(n2(t2(c(v(O(b)))))) { constructor(...e2) { super(...e2), this._sublayersHandles = new u(), this.copyright = "", this.customParameters = null, this.customLayerParameters = null, this.fullExtent = null, this.operationalLayerType = "WebTiledLayer", this.resourceInfo = null, this.serviceMode = "RESTful", this.sublayers = null, this.type = "wmts", this.version = "1.0.0", this.own([l2(() => this.activeLayer, (e3, t3) => { t3 && (t3.layer = null), e3 && (e3.layer = this); }, U), l2(() => this.sublayers, (e3, t3) => { t3 && (t3.forEach((e4) => { e4.layer = null; }), this._sublayersHandles.removeAll(), this._sublayersHandles = null), e3 && (e3.forEach((e4) => { e4.layer = this; }), this._sublayersHandles || (this._sublayersHandles = new u()), this._sublayersHandles.add([e3.on("after-add", ({ item: e4 }) => { e4.layer = this; }), e3.on("after-remove", ({ item: e4 }) => { e4.layer = null; })])); }, U)]); } normalizeCtorArgs(e2, t3) { return typeof e2 == "string" ? { url: e2, ...t3 } : e2; } load(e2) { if (this.serviceMode === "KVP" || this.serviceMode === "RESTful") return this.addResolvingPromise(this.loadFromPortal({ supportedTypes: ["WMTS"] }, e2).catch(w).then(() => this._fetchService(e2)).catch((e3) => { throw w(e3), new s("wmtslayer:unsupported-service-data", "Invalid response from the WMTS service.", { error: e3 }); })), Promise.resolve(this); console.error("WMTS mode could only be 'KVP' or 'RESTful'"); } get activeLayer() { return this._get("activeLayer"); } set activeLayer(e2) { this._set("activeLayer", e2); } readActiveLayerFromService(e2, t3, r4) { this.activeLayer || (this.activeLayer = new m2()); let i2 = t3.layers.find((e3) => e3.id === this.activeLayer.id); return i2 || (i2 = t3.layers[0]), this.activeLayer.read(i2, r4), this.activeLayer; } readActiveLayerFromItemOrWebDoc(e2, t3) { const { templateUrl: r4, wmtsInfo: i2 } = t3, s2 = r4 ? this._getLowerCasedUrlParams(r4) : null, a2 = i2?.layerIdentifier; let o5 = null; const l5 = i2?.tileMatrixSet; l5 && (Array.isArray(l5) ? l5.length && (o5 = l5[0]) : o5 = l5); const n4 = s2?.format, m4 = s2?.style; return new m2({ id: a2, imageFormat: n4, styleId: m4, tileMatrixSetId: o5 }); } writeActiveLayer(e2, t3, r4, i2) { const s2 = this.activeLayer; t3.templateUrl = this.getUrlTemplate(s2.id, s2.tileMatrixSetId, s2.imageFormat, s2.styleId); const a2 = t("tileMatrixSet.tileInfo", s2); t3.tileInfo = a2 ? a2.toJSON(i2) : null, t3.wmtsInfo = { ...t3.wmtsInfo, layerIdentifier: s2.id, tileMatrixSet: s2.tileMatrixSetId }; } readCustomParameters(e2, t3) { const r4 = t3.wmtsInfo; return r4 ? this._mergeParams(r4.customParameters, r4.url) : null; } get fullExtents() { return this.activeLayer.fullExtents; } readServiceMode(e2, t3) { return t3.templateUrl.includes("?") ? "KVP" : "RESTful"; } readSublayersFromService(e2, t3, r4) { return F2(t3.layers, r4); } get supportedSpatialReferences() { return this.activeLayer.tileMatrixSets.map((e2) => e2.tileInfo.spatialReference).toArray(); } get tilemapCache() { const e2 = this.activeLayer?.tileMatrixSet?.tileInfo; return new l3(e2); } get title() { return this.activeLayer?.title ?? "Layer"; } set title(e2) { e2 ? this._override("title", e2) : this._clearOverride("title"); } get url() { return this._get("url"); } set url(e2) { e2 && e2.substr(-1) === "/" ? this._set("url", e2.slice(0, -1)) : this._set("url", e2); } createWebTileLayer(e2) { const t3 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId), r4 = this._getTileMatrixSetById(e2.tileMatrixSetId).tileInfo, i2 = e2.fullExtent, s2 = new p({ layerIdentifier: e2.id, tileMatrixSet: e2.tileMatrixSetId, url: this.url }); return this.customLayerParameters && (s2.customLayerParameters = this.customLayerParameters), this.customParameters && (s2.customParameters = this.customParameters), new x({ fullExtent: i2, urlTemplate: t3, tileInfo: r4, wmtsInfo: s2 }); } fetchTile(e2, r4, i2) { const s2 = this.getTileUrl(e2, r4, i2); return U2(s2, { responseType: "image" }).then((e3) => e3.data); } findSublayerById(e2) { return this.sublayers.find((t3) => t3.id === e2); } getTileUrl(e2, t3, r4) { const i2 = this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId).tileInfo.lods[e2], s2 = i2 ? i2.levelValue ? i2.levelValue : `${i2.level}` : `${e2}`; let a2 = this.resourceInfo ? "" : T({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId, s2, t3, r4); if (!a2) { a2 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId).replace(/\{level\}/gi, s2).replace(/\{row\}/gi, `${t3}`).replace(/\{col\}/gi, `${r4}`); } return a2 = this._appendCustomLayerParameters(a2), a2; } getUrlTemplate(e2, t3, r4, i2) { if (!this.resourceInfo) { const r5 = S2({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, e2, t3, i2); if (r5) return r5; } if (this.serviceMode === "KVP") return this.url + "?SERVICE=WMTS&VERSION=" + this.version + "&REQUEST=GetTile&LAYER=" + e2 + "&STYLE=" + i2 + "&FORMAT=" + r4 + "&TILEMATRIXSET=" + t3 + "&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}"; if (this.serviceMode === "RESTful") { let s2 = ""; return O3[r4.toLowerCase()] && (s2 = O3[r4.toLowerCase()]), this.url + e2 + "/" + i2 + "/" + t3 + "/{level}/{row}/{col}" + s2; } return ""; } async _fetchService(e2) { let t3; if (this.resourceInfo) this.resourceInfo.serviceMode === "KVP" && (this.url += this.url.includes("?") ? "" : "?"), t3 = { ssl: false, data: this.resourceInfo }; else try { t3 = await this._getCapabilities(this.serviceMode, e2), u3(t3.data); } catch { const s2 = this.serviceMode === "KVP" ? "RESTful" : "KVP"; try { t3 = await this._getCapabilities(s2, e2), u3(t3.data), this.serviceMode = s2; } catch (r4) { throw new s("wmtslayer:unsupported-service-data", "Services does not support RESTful or KVP service modes.", { error: r4 }); } } this.resourceInfo ? t3.data = f(t3.data) : t3.data = p5(t3.data, { serviceMode: this.serviceMode, url: this.url }), t3.data && this.read(t3.data, { origin: "service" }); } async _getCapabilities(e2, r4) { const i2 = this._getCapabilitiesUrl(e2); return await U2(i2, { ...r4, responseType: "text" }); } _getTileMatrixSetById(e2) { return this.findSublayerById(this.activeLayer.id).tileMatrixSets.find((t3) => t3.id === e2); } _appendCustomParameters(e2) { return this._appendParameters(e2, this.customParameters); } _appendCustomLayerParameters(e2) { return this._appendParameters(e2, { ...m(this.customParameters), ...this.customLayerParameters }); } _appendParameters(e2, t3) { const r4 = j3(e2), i2 = { ...r4.query, ...t3 }, s2 = I(i2); return s2 === "" ? r4.path : `${r4.path}?${s2}`; } _getCapabilitiesUrl(e2) { this.url = this.url.split("?")[0]; const t3 = e2 === "KVP" ? `${this.url}?request=GetCapabilities&service=WMTS&version=${this.version}` : `${this.url}/${this.version}/WMTSCapabilities.xml`; return this._appendCustomParameters(t3); } _getLowerCasedUrlParams(e2) { if (!e2) return null; const t3 = j3(e2).query; if (!t3) return null; const r4 = {}; return Object.keys(t3).forEach((e3) => { r4[e3.toLowerCase()] = t3[e3]; }), r4; } _mergeParams(e2, t3) { const r4 = this._getLowerCasedUrlParams(t3); if (r4) { const t4 = Object.keys(r4); t4.length && (e2 = e2 ? m(e2) : {}, t4.forEach((t5) => { e2.hasOwnProperty(t5) || W.has(t5) || (e2[t5] = r4[t5]); })); } return e2; } }; function F2(e2, t3) { return e2.map((e3) => { const r4 = new m2(); return r4.read(e3, t3), r4; }); } e([d()], A2.prototype, "dimensionMap", void 0), e([d()], A2.prototype, "layerMap", void 0), e([d({ type: m2, json: { origins: { "web-document": { write: { ignoreOrigin: true } } } } })], A2.prototype, "activeLayer", null), e([o("service", "activeLayer", ["layers"])], A2.prototype, "readActiveLayerFromService", null), e([o(["web-document", "portal-item"], "activeLayer", ["wmtsInfo"])], A2.prototype, "readActiveLayerFromItemOrWebDoc", null), e([r2(["web-document", "portal-item"], "activeLayer", { templateUrl: { type: String }, tileInfo: { type: S }, "wmtsInfo.layerIdentifier": { type: String }, "wmtsInfo.tileMatrixSet": { type: String } })], A2.prototype, "writeActiveLayer", null), e([d({ type: String, value: "", json: { write: true } })], A2.prototype, "copyright", void 0), e([d({ type: ["show", "hide"] })], A2.prototype, "listMode", void 0), e([d({ json: { read: true, write: true } })], A2.prototype, "blendMode", void 0), e([d({ json: { origins: { "web-document": { read: { source: ["wmtsInfo.customParameters", "wmtsInfo.url"] }, write: { target: "wmtsInfo.customParameters" } }, "portal-item": { read: { source: ["wmtsInfo.customParameters", "wmtsInfo.url"] }, write: { target: "wmtsInfo.customParameters" } } } } })], A2.prototype, "customParameters", void 0), e([o(["portal-item", "web-document"], "customParameters")], A2.prototype, "readCustomParameters", null), e([d({ json: { origins: { "web-document": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } }, "portal-item": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } } } } })], A2.prototype, "customLayerParameters", void 0), e([d({ type: M, json: { write: { ignoreOrigin: true }, origins: { "web-document": { read: { source: "fullExtent" } }, "portal-item": { read: { source: "fullExtent" } } } } })], A2.prototype, "fullExtent", void 0), e([d({ readOnly: true })], A2.prototype, "fullExtents", null), e([d({ type: ["WebTiledLayer"] })], A2.prototype, "operationalLayerType", void 0), e([d()], A2.prototype, "resourceInfo", void 0), e([d()], A2.prototype, "serviceMode", void 0), e([o(["portal-item", "web-document"], "serviceMode", ["templateUrl"])], A2.prototype, "readServiceMode", null), e([d({ type: j2.ofType(m2) })], A2.prototype, "sublayers", void 0), e([o("service", "sublayers", ["layers"])], A2.prototype, "readSublayersFromService", null), e([d({ readOnly: true })], A2.prototype, "supportedSpatialReferences", null), e([d({ readOnly: true })], A2.prototype, "tilemapCache", null), e([d({ json: { read: { source: "title" } } })], A2.prototype, "title", null), e([d({ json: { read: false }, readOnly: true, value: "wmts" })], A2.prototype, "type", void 0), e([d({ json: { origins: { service: { read: { source: "tileUrl" } }, "web-document": { read: { source: "wmtsInfo.url" }, write: { target: "wmtsInfo.url" } }, "portal-item": { read: { source: "wmtsInfo.url" }, write: { target: "wmtsInfo.url" } } } } })], A2.prototype, "url", null), e([d()], A2.prototype, "version", void 0), A2 = e([n("esri.layers.WMTSLayer")], A2); var V2 = A2; export { V2 as default }; //# sourceMappingURL=WMTSLayer-S4MQFUPQ.js.map