import { s as s3 } from "./chunk-JXDT22MC.js"; import { E, y as y2, z } from "./chunk-KRGXT5PV.js"; import { i } from "./chunk-DUH52ME3.js"; import { p as p2 } from "./chunk-BFKFNCQC.js"; import { o as o2 } from "./chunk-OJUMXZ6B.js"; import { d, g, m } from "./chunk-SZFMKPVM.js"; import { a } from "./chunk-RDMCXRET.js"; import { v } from "./chunk-2DSTZVND.js"; import { c } from "./chunk-VXKIGGM4.js"; import { f } from "./chunk-KG45D2XL.js"; import { O } from "./chunk-JYRZQPQI.js"; import { p } from "./chunk-UMJCSYX5.js"; import { n as n2 } from "./chunk-UA6W42KP.js"; import { t } from "./chunk-2L5METUC.js"; import { b } from "./chunk-O43KLDSX.js"; import { U } from "./chunk-5DMBXPN2.js"; import { I, Q, j } from "./chunk-VEGAOVMY.js"; import { o } from "./chunk-CXCDYJ5R.js"; import { s as s2 } from "./chunk-GAOW3WRZ.js"; import { k2 as k, r as r2 } from "./chunk-QCKFNSN2.js"; import { e, n5 as n, y3 as y } from "./chunk-6SOHRC7T.js"; import { w } from "./chunk-V6P2MAQQ.js"; import { s3 as s } from "./chunk-E5O6P5I2.js"; import { r } from "./chunk-YXWMMD76.js"; // node_modules/@arcgis/core/layers/TileLayer.js var M = ["Canvas/World_Dark_Gray_Base", "Canvas/World_Dark_Gray_Reference", "Canvas/World_Light_Gray_Base", "Canvas/World_Light_Gray_Reference", "Elevation/World_Hillshade", "Elevation/World_Hillshade_Dark", "Ocean/World_Ocean_Base", "Ocean/World_Ocean_Reference", "Ocean_Basemap", "Reference/World_Boundaries_and_Places", "Reference/World_Boundaries_and_Places_Alternate", "Reference/World_Transportation", "World_Imagery", "World_Street_Map", "World_Topo_Map"]; var W = class extends n2(E(t(c(v(s3(y2(p2(O(a(p(i(o2(b))))))))))))) { constructor(...e2) { super(...e2), this.listMode = "show", this.isReference = null, this.operationalLayerType = "ArcGISTiledMapServiceLayer", this.resampling = true, this.sourceJSON = null, this.spatialReference = null, this.path = null, this.sublayers = null, this.type = "tile", this.url = null; } normalizeCtorArgs(e2, r3) { return "string" == typeof e2 ? { url: e2, ...r3 } : e2; } load(e2) { const r3 = r(e2) ? e2.signal : null; return this.addResolvingPromise(this.loadFromPortal({ supportedTypes: ["Map Service"] }, e2).catch(w).then(() => this._fetchService(r3))), Promise.resolve(this); } get attributionDataUrl() { var _a; const e2 = (_a = this.parsedUrl) == null ? void 0 : _a.path.toLowerCase(); return e2 ? this._getDefaultAttribution(this._getMapName(e2)) : null; } readSpatialReference(e2, r3) { return (e2 = e2 || r3.tileInfo && r3.tileInfo.spatialReference) && k.fromJSON(e2); } writeSublayers(e2, r3, t2, s4) { if (!this.loaded || !e2) return; const i2 = e2.slice().reverse().flatten(({ sublayers: e3 }) => e3 && e3.toArray().reverse()).toArray(), o3 = [], a2 = { writeSublayerStructure: false, ...s4 }; i2.forEach((e3) => { const r4 = e3.write({}, a2); o3.push(r4); }); o3.some((e3) => Object.keys(e3).length > 1) && (r3.layers = o3); } get tileServers() { return this._getDefaultTileServers(this.parsedUrl.path); } castTileServers(e2) { return Array.isArray(e2) ? e2.map((e3) => j(e3).path) : null; } fetchTile(e2, t2, s4, i2 = {}) { const { signal: o3 } = i2, a2 = this.getTileUrl(e2, t2, s4), l = { responseType: "image", signal: o3, query: { ...this.refreshParameters } }; return U(a2, l).then((e3) => e3.data); } async fetchImageBitmapTile(e2, t2, s4, i2 = {}) { const { signal: o3 } = i2, a2 = this.getTileUrl(e2, t2, s4), l = { responseType: "blob", signal: o3, query: { ...this.refreshParameters } }, n3 = await U(a2, l); return createImageBitmap(n3.data); } getTileUrl(e2, r3, t2) { const s4 = !this.tilemapCache && this.supportsBlankTile, i2 = I({ ...this.parsedUrl.query, blankTile: !s4 && null, ...this.customParameters, token: this.apiKey }), o3 = this.tileServers; return `${o3 && o3.length ? o3[r3 % o3.length] : this.parsedUrl.path}/tile/${e2}/${r3}/${t2}${i2 ? "?" + i2 : ""}`; } _fetchService(e2) { return new Promise((s4, o3) => { if (this.sourceJSON) { if (null != this.sourceJSON.bandCount && null != this.sourceJSON.pixelSizeX) throw new s("tile-layer:unsupported-url", "use ImageryTileLayer to open a tiled image service"); return void s4({ data: this.sourceJSON }); } if (!this.parsedUrl) throw new s("tile-layer:undefined-url", "layer's url is not defined"); const a2 = m(this.parsedUrl.path); if (r(a2) && "ImageServer" === a2.serverType) throw new s("tile-layer:unsupported-url", "use ImageryTileLayer to open a tiled image service"); U(this.parsedUrl.path, { query: { f: "json", ...this.parsedUrl.query, ...this.customParameters, token: this.apiKey }, responseType: "json", signal: e2 }).then(s4, o3); }).then((r3) => { if (r3.ssl && (this.url = this.url.replace(/^http:/i, "https:")), this.sourceJSON = r3.data, this.read(r3.data, { origin: "service", url: this.parsedUrl }), 10.1 === this.version && !g(this.url)) return this._fetchServerVersion(this.url, e2).then((e3) => { this.read({ currentVersion: e3 }); }).catch(() => { }); }); } _fetchServerVersion(e2, s4) { if (!d(e2)) return Promise.reject(); const i2 = e2.replace(/(.*\/rest)\/.*/i, "$1") + "/info"; return U(i2, { query: { f: "json", ...this.customParameters, token: this.apiKey }, responseType: "json", signal: s4 }).then((e3) => { if (e3.data && e3.data.currentVersion) return e3.data.currentVersion; throw new s("tile-layer:version-not-available"); }); } _getMapName(e2) { const r3 = e2.match(/^(?:https?:)?\/\/(server\.arcgisonline\.com|services\.arcgisonline\.com|ibasemaps-api\.arcgis\.com)\/arcgis\/rest\/services\/([^\/]+(\/[^\/]+)*)\/mapserver/i); return r3 && r3[2]; } _getDefaultAttribution(e2) { if (!e2) return; let r3; e2 = e2.toLowerCase(); for (let t2 = 0, s4 = M.length; t2 < s4; t2++) if (r3 = M[t2], r3.toLowerCase().includes(e2)) return Q("//static.arcgis.com/attribution/" + r3); } _getDefaultTileServers(e2) { const r3 = -1 !== e2.search(/^(?:https?:)?\/\/server\.arcgisonline\.com/i), t2 = -1 !== e2.search(/^(?:https?:)?\/\/services\.arcgisonline\.com/i); return r3 || t2 ? [e2, e2.replace(r3 ? /server\.arcgisonline/i : /services\.arcgisonline/i, r3 ? "services.arcgisonline" : "server.arcgisonline")] : []; } get hasOverriddenFetchTile() { return !this.fetchTile.__isDefault__; } }; e([y({ readOnly: true })], W.prototype, "attributionDataUrl", null), e([y({ type: ["show", "hide", "hide-children"] })], W.prototype, "listMode", void 0), e([y({ json: { read: true, write: true } })], W.prototype, "blendMode", void 0), e([y({ type: Boolean, json: { read: false, write: { enabled: true, overridePolicy: () => ({ enabled: false }) } } })], W.prototype, "isReference", void 0), e([y({ readOnly: true, type: ["ArcGISTiledMapServiceLayer"] })], W.prototype, "operationalLayerType", void 0), e([y({ type: Boolean })], W.prototype, "resampling", void 0), e([y()], W.prototype, "sourceJSON", void 0), e([y({ type: k })], W.prototype, "spatialReference", void 0), e([o("spatialReference", ["spatialReference", "tileInfo"])], W.prototype, "readSpatialReference", null), e([y({ type: String, json: { origins: { "web-scene": { read: true, write: true } }, read: false } })], W.prototype, "path", void 0), e([y({ readOnly: true })], W.prototype, "sublayers", void 0), e([r2("sublayers", { layers: { type: [z] } })], W.prototype, "writeSublayers", null), e([y({ json: { read: false, write: false } })], W.prototype, "popupEnabled", void 0), e([y()], W.prototype, "tileServers", null), e([s2("tileServers")], W.prototype, "castTileServers", null), e([y({ readOnly: true, json: { read: false } })], W.prototype, "type", void 0), e([y(f)], W.prototype, "url", void 0), W = e([n("esri.layers.TileLayer")], W), W.prototype.fetchTile.__isDefault__ = true; var B = W; export { B }; //# sourceMappingURL=chunk-EMNQ2YPK.js.map