WMTSLayer-ZV2ZIJNI.js 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. import {
  2. o as o3
  3. } from "./chunk-ELA7HWPA.js";
  4. import {
  5. o as o2
  6. } from "./chunk-YINMVLPI.js";
  7. import {
  8. U,
  9. a,
  10. l as l2
  11. } from "./chunk-TJV6ODRM.js";
  12. import {
  13. p as p2,
  14. x
  15. } from "./chunk-JF6B6S7W.js";
  16. import {
  17. j as j3
  18. } from "./chunk-YLEVJ6UV.js";
  19. import "./chunk-U2WD23Z5.js";
  20. import {
  21. v
  22. } from "./chunk-JUWKPBLS.js";
  23. import {
  24. c
  25. } from "./chunk-WLSB4F4I.js";
  26. import "./chunk-GLSWDDR3.js";
  27. import {
  28. O as O2
  29. } from "./chunk-MIQGEDET.js";
  30. import "./chunk-DUEMJ5XS.js";
  31. import "./chunk-VRLXUHP2.js";
  32. import "./chunk-3LVSQLWJ.js";
  33. import "./chunk-4ONPMX2F.js";
  34. import "./chunk-CRGY2SDS.js";
  35. import "./chunk-4T5ZGMEN.js";
  36. import {
  37. p
  38. } from "./chunk-GN35O2ZO.js";
  39. import {
  40. n as n2
  41. } from "./chunk-XTVKPAWY.js";
  42. import "./chunk-3OSQ6GXO.js";
  43. import "./chunk-3WQOA5CB.js";
  44. import {
  45. t as t2
  46. } from "./chunk-PLWDAYK7.js";
  47. import "./chunk-FZQZIM7U.js";
  48. import "./chunk-CZBRZ6SU.js";
  49. import "./chunk-VGWC3IKZ.js";
  50. import "./chunk-2H5MD622.js";
  51. import {
  52. s as s2
  53. } from "./chunk-3RSFVUKZ.js";
  54. import "./chunk-UVVU4UUO.js";
  55. import "./chunk-P3XKUGLS.js";
  56. import "./chunk-2ZSOO377.js";
  57. import "./chunk-YUA3AHKR.js";
  58. import "./chunk-LU5IJZB4.js";
  59. import "./chunk-7IBV2TRE.js";
  60. import "./chunk-ZLNEXZAN.js";
  61. import "./chunk-5UVJ64RB.js";
  62. import "./chunk-SFEFRQCL.js";
  63. import {
  64. b
  65. } from "./chunk-DXVOOCG4.js";
  66. import "./chunk-3GZSQU56.js";
  67. import "./chunk-ZYRIJWLX.js";
  68. import "./chunk-RYY6632W.js";
  69. import "./chunk-DW42UVIT.js";
  70. import "./chunk-YAEIHDJH.js";
  71. import "./chunk-TJNOJH33.js";
  72. import "./chunk-OSHI574D.js";
  73. import "./chunk-ETGAZ7LF.js";
  74. import "./chunk-75U5LM2V.js";
  75. import "./chunk-RMDDCMKS.js";
  76. import "./chunk-VCH45Q2I.js";
  77. import {
  78. j
  79. } from "./chunk-LBW34VZ2.js";
  80. import "./chunk-GSSTTHIT.js";
  81. import "./chunk-YFSLJIO4.js";
  82. import "./chunk-IM3LVQXV.js";
  83. import "./chunk-55RWC67C.js";
  84. import "./chunk-HZRKBTHJ.js";
  85. import {
  86. U as U2
  87. } from "./chunk-DVUG3KID.js";
  88. import "./chunk-FWSQEIAR.js";
  89. import {
  90. I,
  91. j as j2
  92. } from "./chunk-VEGAOVMY.js";
  93. import {
  94. o,
  95. w as w2,
  96. w2 as w3
  97. } from "./chunk-6T6G6LCQ.js";
  98. import "./chunk-YEJL5NEF.js";
  99. import {
  100. r as r2,
  101. r2 as r3
  102. } from "./chunk-PQFTYGF5.js";
  103. import {
  104. e,
  105. l3 as l,
  106. n5 as n,
  107. y3 as y2
  108. } from "./chunk-2Z2TG5CU.js";
  109. import "./chunk-6KZ2LTDA.js";
  110. import "./chunk-U2XHEJM7.js";
  111. import "./chunk-SQOPWYIT.js";
  112. import {
  113. O,
  114. w
  115. } from "./chunk-V6P2MAQQ.js";
  116. import {
  117. s3 as s
  118. } from "./chunk-E5O6P5I2.js";
  119. import {
  120. t,
  121. y
  122. } from "./chunk-SPWQ3AWG.js";
  123. import "./chunk-2TIUKVZN.js";
  124. import {
  125. r
  126. } from "./chunk-YXWMMD76.js";
  127. import "./chunk-S5KM4IGW.js";
  128. // node_modules/@arcgis/core/layers/support/TileInfoTilemapCache.js
  129. var l3 = class {
  130. constructor(i2, l5 = 0, a2 = i2.lods.length - 1) {
  131. this.tileInfo = i2, this.minLOD = l5, this.maxLOD = a2;
  132. }
  133. getAvailability(i2, l5, a2) {
  134. var _a;
  135. const t3 = (_a = this.tileInfo) == null ? void 0 : _a.lodAt(i2);
  136. 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";
  137. }
  138. async fetchAvailability(l5, a2, t3, e2) {
  139. return await O(e2), this.getAvailability(l5, a2, t3);
  140. }
  141. async fetchAvailabilityUpsample(l5, a2, t3, e2, s3) {
  142. await O(s3), e2.level = l5, e2.row = a2, e2.col = t3;
  143. const o5 = this.tileInfo;
  144. for (o5.updateTileInfo(e2); ; ) {
  145. const i2 = this.getAvailability(e2.level, e2.row, e2.col);
  146. if ("unavailable" !== i2)
  147. return i2;
  148. if (!o5.upsampleTile(e2))
  149. return "unavailable";
  150. }
  151. }
  152. };
  153. // node_modules/@arcgis/core/layers/support/TileMatrixSet.js
  154. var l4;
  155. var n3 = l4 = class extends l {
  156. constructor(t3) {
  157. super(t3), this.fullExtent = null, this.id = null, this.tileInfo = null;
  158. }
  159. clone() {
  160. const t3 = new l4();
  161. 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;
  162. }
  163. };
  164. e([y2({ type: w3, json: { read: { source: "fullExtent" } } })], n3.prototype, "fullExtent", void 0), e([y2({ type: String, json: { read: { source: "id" } } })], n3.prototype, "id", void 0), e([y2({ type: j3, json: { read: { source: "tileInfo" } } })], n3.prototype, "tileInfo", void 0), n3 = l4 = e([n("esri.layer.support.TileMatrixSet")], n3);
  165. var p3 = n3;
  166. // node_modules/@arcgis/core/layers/support/WMTSStyle.js
  167. var o4;
  168. var i = o4 = class extends l {
  169. constructor(r4) {
  170. super(r4), this.id = null, this.title = null, this.description = null, this.legendUrl = null;
  171. }
  172. clone() {
  173. const r4 = new o4();
  174. 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;
  175. }
  176. };
  177. e([y2({ json: { read: { source: "id" } } })], i.prototype, "id", void 0), e([y2({ json: { read: { source: "title" } } })], i.prototype, "title", void 0), e([y2({ json: { read: { source: "abstract" } } })], i.prototype, "description", void 0), e([y2({ json: { read: { source: "legendUrl" } } })], i.prototype, "legendUrl", void 0), e([y2({ json: { read: { source: "isDefault" } } })], i.prototype, "isDefault", void 0), e([y2({ json: { read: { source: "keywords" } } })], i.prototype, "keywords", void 0), i = o4 = e([n("esri.layer.support.WMTSStyle")], i);
  178. var p4 = i;
  179. // node_modules/@arcgis/core/layers/support/WMTSSublayer.js
  180. var p5;
  181. var m = p5 = class extends l {
  182. constructor(t3) {
  183. 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;
  184. }
  185. get description() {
  186. return this._get("description");
  187. }
  188. set description(t3) {
  189. this._set("description", t3);
  190. }
  191. readFullExtent(t3, e2) {
  192. return (t3 = e2.fullExtent) ? w3.fromJSON(t3) : null;
  193. }
  194. readFullExtents(t3, e2) {
  195. var _a, _b, _c;
  196. return ((_a = e2.fullExtents) == null ? void 0 : _a.length) ? e2.fullExtents.map((t4) => w3.fromJSON(t4)) : (_c = (_b = e2.tileMatrixSets) == null ? void 0 : _b.map((t4) => w3.fromJSON(t4.fullExtent)).filter((t4) => t4)) != null ? _c : [];
  197. }
  198. get imageFormat() {
  199. let t3 = this._get("imageFormat");
  200. return t3 || (t3 = this.imageFormats && this.imageFormats.length ? this.imageFormats[0] : ""), t3;
  201. }
  202. set imageFormat(t3) {
  203. const e2 = this.imageFormats;
  204. 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);
  205. }
  206. get styleId() {
  207. var _a;
  208. let t3 = this._get("styleId");
  209. return t3 || (t3 = ((_a = this.styles) == null ? void 0 : _a.length) ? this.styles.getItemAt(0).id : ""), t3;
  210. }
  211. set styleId(t3) {
  212. this._set("styleId", t3);
  213. }
  214. get title() {
  215. return this._get("title");
  216. }
  217. set title(t3) {
  218. this._set("title", t3);
  219. }
  220. get tileMatrixSet() {
  221. return this.tileMatrixSets ? this.tileMatrixSets.find((t3) => t3.id === this.tileMatrixSetId) : null;
  222. }
  223. clone() {
  224. var _a;
  225. const t3 = new p5();
  226. 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 = (_a = this.tileMatrixSets) == null ? void 0 : _a.clone()), this.hasOwnProperty("title") && (t3.title = this.title), t3;
  227. }
  228. };
  229. e([y2()], m.prototype, "description", null), e([y2()], m.prototype, "fullExtent", void 0), e([o("fullExtent", ["fullExtent"])], m.prototype, "readFullExtent", null), e([y2({ readOnly: true })], m.prototype, "fullExtents", void 0), e([o("fullExtents", ["fullExtents", "tileMatrixSets"])], m.prototype, "readFullExtents", null), e([y2()], m.prototype, "imageFormat", null), e([y2({ json: { read: { source: "formats" } } })], m.prototype, "imageFormats", void 0), e([y2()], m.prototype, "id", void 0), e([y2()], m.prototype, "layer", void 0), e([y2()], m.prototype, "styleId", null), e([y2({ type: j.ofType(p4), json: { read: { source: "styles" } } })], m.prototype, "styles", void 0), e([y2({ value: null, json: { write: { ignoreOrigin: true } } })], m.prototype, "title", null), e([y2()], m.prototype, "tileMatrixSetId", void 0), e([y2({ readOnly: true })], m.prototype, "tileMatrixSet", null), e([y2({ type: j.ofType(p3), json: { read: { source: "tileMatrixSets" } } })], m.prototype, "tileMatrixSets", void 0), m = p5 = e([n("esri.layers.support.WMTSSublayer")], m);
  230. var u = m;
  231. // node_modules/@arcgis/core/layers/support/wmtsUtils.js
  232. var c2 = 90.71428571428571;
  233. function u2(t3) {
  234. const n4 = t3.replace(/ows:/gi, "");
  235. if (!m2("Contents", new DOMParser().parseFromString(n4, "text/xml").documentElement))
  236. throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid", "the wmts get capabilities response is not compliant", { text: t3 });
  237. }
  238. function p6(t3, n4) {
  239. var _a, _b;
  240. t3 = t3.replace(/ows:/gi, "");
  241. const i2 = new DOMParser().parseFromString(t3, "text/xml").documentElement, r4 = /* @__PURE__ */ new Map(), o5 = /* @__PURE__ */ new Map(), l5 = m2("Contents", i2);
  242. if (!l5)
  243. throw new s("wmtslayer:wmts-capabilities-xml-is-not-valid");
  244. const s3 = (_a = m2("OperationsMetadata", i2)) == null ? void 0 : _a.querySelector("[name='GetTile']"), a2 = s3 == null ? void 0 : s3.getElementsByTagName("Get"), c3 = a2 && Array.prototype.slice.call(a2), u3 = (_b = n4.url) == null ? void 0 : _b.indexOf("https"), p7 = void 0 !== u3 && u3 > -1;
  245. let f2, d2, x3 = n4.serviceMode, M2 = n4 == null ? void 0 : n4.url;
  246. if (c3 && c3.length && c3.some((e2) => {
  247. const t4 = m2("Constraint", e2);
  248. return !t4 || w4("AllowedValues", "Value", x3, t4) ? (M2 = e2.attributes[0].nodeValue, true) : (!t4 || w4("AllowedValues", "Value", "RESTful", t4) || w4("AllowedValues", "Value", "REST", t4) ? d2 = e2.attributes[0].nodeValue : t4 && !w4("AllowedValues", "Value", "KVP", t4) || (f2 = e2.attributes[0].nodeValue), false);
  249. }), !M2)
  250. if (d2)
  251. M2 = d2, x3 = "RESTful";
  252. else if (f2)
  253. M2 = f2, x3 = "KVP";
  254. else {
  255. const e2 = m2("ServiceMetadataURL", i2);
  256. M2 = e2 == null ? void 0 : e2.getAttribute("xlink:href");
  257. }
  258. const T2 = M2.indexOf("1.0.0/");
  259. -1 === T2 && "RESTful" === x3 ? M2 += "/" : T2 > -1 && (M2 = M2.substring(0, T2)), "KVP" === x3 && (M2 += T2 > -1 ? "" : "?"), p7 && (M2 = M2.replace(/^http:/i, "https:"));
  260. const y4 = h("ServiceIdentification>ServiceTypeVersion", i2), R2 = h("ServiceIdentification>AccessConstraints", i2), S2 = R2 && /^none$/i.test(R2) ? null : R2, V3 = g("Layer", l5), b3 = g("TileMatrixSet", l5), E2 = V3.map((e2) => {
  261. const t4 = h("Identifier", e2);
  262. return r4.set(t4, e2), C(t4, e2, b3, p7, y4);
  263. });
  264. return { copyright: S2, dimensionMap: o5, layerMap: r4, layers: E2, serviceMode: x3, tileUrl: M2 };
  265. }
  266. function f(e2) {
  267. return e2.layers.forEach((e3) => {
  268. var _a;
  269. (_a = e3.tileMatrixSets) == null ? void 0 : _a.forEach((e4) => {
  270. var _a2;
  271. const t3 = e4.tileInfo;
  272. t3 && 96 !== t3.dpi && ((_a2 = t3.lods) == null ? void 0 : _a2.forEach((n4) => {
  273. var _a3;
  274. n4.scale = 96 * n4.scale / t3.dpi, n4.resolution = U3((_a3 = t3.spatialReference) == null ? void 0 : _a3.wkid, n4.scale * c2 / 96, e4.id);
  275. }), t3.dpi = 96);
  276. });
  277. }), e2;
  278. }
  279. function d(e2) {
  280. return e2.nodeType === Node.ELEMENT_NODE;
  281. }
  282. function m2(e2, t3) {
  283. for (let n4 = 0; n4 < t3.childNodes.length; n4++) {
  284. const i2 = t3.childNodes[n4];
  285. if (d(i2) && i2.nodeName === e2)
  286. return i2;
  287. }
  288. return null;
  289. }
  290. function g(e2, t3) {
  291. const n4 = [];
  292. for (let i2 = 0; i2 < t3.childNodes.length; i2++) {
  293. const r4 = t3.childNodes[i2];
  294. d(r4) && r4.nodeName === e2 && n4.push(r4);
  295. }
  296. return n4;
  297. }
  298. function x2(e2, n4) {
  299. const i2 = [];
  300. for (let t3 = 0; t3 < n4.childNodes.length; t3++) {
  301. const r4 = n4.childNodes[t3];
  302. d(r4) && r4.nodeName === e2 && i2.push(r4);
  303. }
  304. return i2.map((e3) => e3.textContent).filter(r);
  305. }
  306. function h(e2, t3) {
  307. return e2.split(">").forEach((e3) => {
  308. t3 && (t3 = m2(e3, t3));
  309. }), t3 && t3.textContent;
  310. }
  311. function w4(e2, t3, n4, i2) {
  312. let r4;
  313. return Array.prototype.slice.call(i2.childNodes).some((i3) => {
  314. if (i3.nodeName.includes(e2)) {
  315. const e3 = m2(t3, i3), o5 = e3 && e3.textContent;
  316. if (o5 === n4 || n4.split(":") && n4.split(":")[1] === o5)
  317. return r4 = i3, true;
  318. }
  319. return false;
  320. }), r4;
  321. }
  322. function C(e2, t3, n4, i2, r4) {
  323. const o5 = h("Abstract", t3), l5 = x2("Format", t3);
  324. return { id: e2, fullExtent: S(t3), fullExtents: V(t3), description: o5, formats: l5, styles: b2(t3, i2), title: h("Title", t3), tileMatrixSets: E(r4, t3, n4) };
  325. }
  326. function M(e2, t3) {
  327. var _a;
  328. const n4 = [], i2 = (_a = e2.layerMap) == null ? void 0 : _a.get(t3);
  329. if (!i2)
  330. return null;
  331. const r4 = g("ResourceURL", i2), o5 = g("Dimension", i2);
  332. let l5, s3, a2, c3;
  333. return o5.length && (l5 = h("Identifier", o5[0]), s3 = x2("Default", o5[0]) || x2("Value", o5[0])), o5.length > 1 && (a2 = h("Identifier", o5[1]), c3 = x2("Default", o5[1]) || x2("Value", o5[1])), e2.dimensionMap.set(t3, { dimensions: s3, dimensions2: c3 }), r4.forEach((e3) => {
  334. let t4 = e3.getAttribute("template");
  335. if ("tile" === e3.getAttribute("resourceType")) {
  336. if (l5 && s3.length)
  337. if (t4.includes("{" + l5 + "}"))
  338. t4 = t4.replace("{" + l5 + "}", "{dimensionValue}");
  339. else {
  340. const e4 = t4.toLowerCase().indexOf("{" + l5.toLowerCase() + "}");
  341. e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue}" + t4.substring(e4 + l5.length + 2));
  342. }
  343. if (a2 && c3.length)
  344. if (t4.includes("{" + a2 + "}"))
  345. t4 = t4.replace("{" + a2 + "}", "{dimensionValue2}");
  346. else {
  347. const e4 = t4.toLowerCase().indexOf("{" + a2.toLowerCase() + "}");
  348. e4 > -1 && (t4 = t4.substring(0, e4) + "{dimensionValue2}" + t4.substring(e4 + a2.length + 2));
  349. }
  350. n4.push({ template: t4, format: e3.getAttribute("format"), resourceType: "tile" });
  351. }
  352. }), n4;
  353. }
  354. function T(e2, t3, n4, i2, r4, o5, l5, s3) {
  355. var _a, _b;
  356. const a2 = y3(e2, t3, i2);
  357. if (!((a2 == null ? void 0 : a2.length) > 0))
  358. return "";
  359. const { dimensionMap: c3 } = e2, u3 = (_a = c3.get(t3).dimensions) == null ? void 0 : _a[0], p7 = (_b = c3.get(t3).dimensions2) == null ? void 0 : _b[0];
  360. return a2[l5 % a2.length].template.replace(/\{Style\}/gi, r4 != null ? r4 : "").replace(/\{TileMatrixSet\}/gi, n4 != null ? n4 : "").replace(/\{TileMatrix\}/gi, o5).replace(/\{TileRow\}/gi, "" + l5).replace(/\{TileCol\}/gi, "" + s3).replace(/\{dimensionValue\}/gi, u3).replace(/\{dimensionValue2\}/gi, p7);
  361. }
  362. function y3(e2, t3, n4) {
  363. var _a;
  364. const i2 = M(e2, t3), r4 = i2 == null ? void 0 : i2.filter((e3) => e3.format === n4);
  365. return (_a = (r4 == null ? void 0 : r4.length) ? r4 : i2) != null ? _a : [];
  366. }
  367. function R(e2, t3, n4, i2) {
  368. const { dimensionMap: r4 } = e2, o5 = M(e2, t3);
  369. let l5 = "";
  370. if (o5 && o5.length > 0) {
  371. const e3 = r4.get(t3).dimensions && r4.get(t3).dimensions[0], s3 = r4.get(t3).dimensions2 && r4.get(t3).dimensions2[0];
  372. 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, s3);
  373. }
  374. return l5;
  375. }
  376. function S(e2) {
  377. const t3 = m2("WGS84BoundingBox", e2), n4 = t3 ? h("LowerCorner", t3).split(" ") : ["-180", "-90"], i2 = t3 ? h("UpperCorner", t3).split(" ") : ["180", "90"];
  378. return { xmin: parseFloat(n4[0]), ymin: parseFloat(n4[1]), xmax: parseFloat(i2[0]), ymax: parseFloat(i2[1]), spatialReference: { wkid: 4326 } };
  379. }
  380. function V(e2) {
  381. const t3 = [];
  382. return o2(e2, { BoundingBox: (e3) => {
  383. if (!e3.getAttribute("crs"))
  384. return;
  385. const n4 = e3.getAttribute("crs").toLowerCase(), i2 = I2(n4), r4 = n4.includes("epsg") && o3(i2.wkid);
  386. let o5, a2, c3, u3;
  387. o2(e3, { LowerCorner: (e4) => {
  388. [o5, a2] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([o5, a2] = [a2, o5]);
  389. }, UpperCorner: (e4) => {
  390. [c3, u3] = e4.textContent.split(" ").map((e5) => Number.parseFloat(e5)), r4 && ([c3, u3] = [u3, c3]);
  391. } }), t3.push({ xmin: o5, ymin: a2, xmax: c3, ymax: u3, spatialReference: i2 });
  392. } }), t3;
  393. }
  394. function b2(e2, t3) {
  395. return g("Style", e2).map((e3) => {
  396. const n4 = m2("LegendURL", e3), i2 = m2("Keywords", e3), r4 = i2 ? x2("Keyword", i2) : [];
  397. let o5 = n4 && n4.getAttribute("xlink:href");
  398. t3 && (o5 = o5 && o5.replace(/^http:/i, "https:"));
  399. return { abstract: h("Abstract", e3), id: h("Identifier", e3), isDefault: "true" === e3.getAttribute("isDefault"), keywords: r4, legendUrl: o5, title: h("Title", e3) };
  400. });
  401. }
  402. function E(e2, t3, n4) {
  403. return g("TileMatrixSetLink", t3).map((t4) => L(e2, t4, n4));
  404. }
  405. function L(e2, t3, n4) {
  406. const i2 = m2("TileMatrixSet", t3).textContent, r4 = x2("TileMatrix", t3), o5 = n4.find((e3) => {
  407. const t4 = m2("Identifier", e3), n5 = t4 && t4.textContent;
  408. return !!(n5 === i2 || i2.split(":") && i2.split(":")[1] === n5);
  409. }), l5 = m2("TileMatrixSetLimits", t3), s3 = l5 && g("TileMatrixLimits", l5), c3 = /* @__PURE__ */ new Map();
  410. if (s3 == null ? void 0 : s3.length)
  411. for (const a2 of s3) {
  412. const e3 = m2("TileMatrix", a2).textContent, t4 = +m2("MinTileRow", a2).textContent, n5 = +m2("MaxTileRow", a2).textContent, i3 = +m2("MinTileCol", a2).textContent, r5 = +m2("MaxTileCol", a2).textContent;
  413. c3.set(e3, { minCol: i3, maxCol: r5, minRow: t4, maxRow: n5 });
  414. }
  415. const u3 = h("SupportedCRS", o5).toLowerCase(), p7 = N(o5, u3), f2 = p7.spatialReference, d2 = m2("TileMatrix", o5), C2 = [parseInt(h("TileWidth", d2), 10), parseInt(h("TileHeight", d2), 10)], M2 = [];
  416. if (r4.length)
  417. r4.forEach((e3, t4) => {
  418. const n5 = w4("TileMatrix", "Identifier", e3, o5);
  419. M2.push(D(n5, u3, t4, i2, c3));
  420. });
  421. else {
  422. g("TileMatrix", o5).forEach((e3, t4) => {
  423. M2.push(D(e3, u3, t4, i2, c3));
  424. });
  425. }
  426. const T2 = v2(e2, o5, p7, C2, M2[0]).toJSON(), y4 = new j3({ dpi: 96, spatialReference: f2, size: C2, origin: p7, lods: M2 }).toJSON();
  427. return { id: i2, fullExtent: T2, tileInfo: y4 };
  428. }
  429. function I2(e2) {
  430. e2 = e2.toLowerCase();
  431. let n4 = parseInt(e2.split(":").pop(), 10);
  432. 900913 !== n4 && 3857 !== n4 || (n4 = 102100);
  433. const i2 = k(e2);
  434. return r(i2) && (n4 = i2), { wkid: n4 };
  435. }
  436. function N(e2, t3) {
  437. return A(m2("TileMatrix", e2), t3);
  438. }
  439. function A(e2, t3) {
  440. const n4 = I2(t3), [r4, o5] = h("TopLeftCorner", e2).split(" ").map((e3) => parseFloat(e3)), s3 = t3.includes("epsg") && o3(n4.wkid);
  441. return new w2(s3 ? { x: o5, y: r4, spatialReference: n4 } : { x: r4, y: o5, spatialReference: n4 });
  442. }
  443. function v2(e2, t3, i2, r4, o5) {
  444. const l5 = m2("BoundingBox", t3);
  445. let s3, a2, c3, u3, p7, f2;
  446. if (l5 && (s3 = h("LowerCorner", l5).split(" "), a2 = h("UpperCorner", l5).split(" ")), s3 && s3.length > 1 && a2 && a2.length > 1)
  447. c3 = parseFloat(s3[0]), p7 = parseFloat(s3[1]), u3 = parseFloat(a2[0]), f2 = parseFloat(a2[1]);
  448. else {
  449. const e3 = m2("TileMatrix", t3), n4 = parseInt(h("MatrixWidth", e3), 10), l6 = parseInt(h("MatrixHeight", e3), 10);
  450. c3 = i2.x, f2 = i2.y, u3 = c3 + n4 * r4[0] * o5.resolution, p7 = f2 - l6 * r4[1] * o5.resolution;
  451. }
  452. return F(e2, i2.spatialReference, i2) ? new w3(p7, c3, f2, u3, i2.spatialReference) : new w3(c3, p7, u3, f2, i2.spatialReference);
  453. }
  454. function F(e2, t3, n4) {
  455. return "1.0.0" === e2 && o3(t3.wkid) && !(n4.spatialReference.isGeographic && n4.x < -90 && n4.y >= -90);
  456. }
  457. var O3;
  458. function k(e2) {
  459. return e2.includes("crs84") || e2.includes("crs:84") ? O3.CRS84 : e2.includes("crs83") || e2.includes("crs:83") ? O3.CRS83 : e2.includes("crs27") || e2.includes("crs:27") ? O3.CRS27 : null;
  460. }
  461. function D(e2, t3, n4, i2, r4) {
  462. var _a;
  463. const o5 = I2(t3), l5 = h("Identifier", e2);
  464. let s3 = parseFloat(h("ScaleDenominator", e2));
  465. const a2 = U3(o5.wkid, s3, i2);
  466. s3 *= 96 / c2;
  467. const u3 = +h("MatrixWidth", e2), p7 = +h("MatrixHeight", e2), { maxCol: f2 = u3 - 1, maxRow: d2 = p7 - 1, minCol: m3 = 0, minRow: g2 = 0 } = (_a = r4.get(l5)) != null ? _a : {}, { x: x3, y: w5 } = A(e2, t3);
  468. return { cols: [m3, f2], level: n4, levelValue: l5, origin: [x3, w5], scale: s3, resolution: a2, rows: [g2, d2] };
  469. }
  470. function U3(e2, t3, n4) {
  471. let i2;
  472. return i2 = r3.hasOwnProperty("" + e2) ? r3.values[r3[e2]] : "default028mm" === n4 ? 6370997 * Math.PI / 180 : s2(e2).metersPerDegree, 7 * t3 / 25e3 / i2;
  473. }
  474. !function(e2) {
  475. e2[e2.CRS84 = 4326] = "CRS84", e2[e2.CRS83 = 4269] = "CRS83", e2[e2.CRS27 = 4267] = "CRS27";
  476. }(O3 || (O3 = {}));
  477. // node_modules/@arcgis/core/layers/WMTSLayer.js
  478. var W = { "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": "" };
  479. var A2 = /* @__PURE__ */ new Set(["version", "service", "request", "layer", "style", "format", "tilematrixset", "tilematrix", "tilerow", "tilecol"]);
  480. var F2 = class extends n2(p(t2(c(v(O2(b)))))) {
  481. constructor(...e2) {
  482. super(...e2), 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.addHandles([l2(() => this.activeLayer, (e3, t3) => {
  483. t3 && (t3.layer = null), e3 && (e3.layer = this);
  484. }, U), a(() => this.sublayers, "after-add", ({ item: e3 }) => {
  485. e3.layer = this;
  486. }, U), a(() => this.sublayers, "after-remove", ({ item: e3 }) => {
  487. e3.layer = null;
  488. }, U), l2(() => this.sublayers, (e3, t3) => {
  489. if (t3)
  490. for (const r4 of t3)
  491. r4.layer = null;
  492. if (e3)
  493. for (const r4 of e3)
  494. r4.layer = this;
  495. }, U)]);
  496. }
  497. normalizeCtorArgs(e2, t3) {
  498. return "string" == typeof e2 ? { url: e2, ...t3 } : e2;
  499. }
  500. load(e2) {
  501. if ("KVP" === this.serviceMode || "RESTful" === this.serviceMode)
  502. return this.addResolvingPromise(this.loadFromPortal({ supportedTypes: ["WMTS"] }, e2).catch(w).then(() => this._fetchService(e2)).catch((e3) => {
  503. throw w(e3), new s("wmtslayer:unsupported-service-data", "Invalid response from the WMTS service.", { error: e3 });
  504. })), Promise.resolve(this);
  505. console.error("WMTS mode could only be 'KVP' or 'RESTful'");
  506. }
  507. get activeLayer() {
  508. return this._get("activeLayer");
  509. }
  510. set activeLayer(e2) {
  511. this._set("activeLayer", e2);
  512. }
  513. readActiveLayerFromService(e2, t3, r4) {
  514. this.activeLayer || (this.activeLayer = new u());
  515. let i2 = t3.layers.find((e3) => e3.id === this.activeLayer.id);
  516. return i2 || (i2 = t3.layers[0]), this.activeLayer.read(i2, r4), this.activeLayer;
  517. }
  518. readActiveLayerFromItemOrWebDoc(e2, t3) {
  519. const { templateUrl: r4, wmtsInfo: i2 } = t3, s3 = r4 ? this._getLowerCasedUrlParams(r4) : null, a2 = i2 == null ? void 0 : i2.layerIdentifier;
  520. let o5 = null;
  521. const l5 = i2 == null ? void 0 : i2.tileMatrixSet;
  522. l5 && (Array.isArray(l5) ? l5.length && (o5 = l5[0]) : o5 = l5);
  523. const n4 = s3 == null ? void 0 : s3.format, m3 = s3 == null ? void 0 : s3.style;
  524. return new u({ id: a2, imageFormat: n4, styleId: m3, tileMatrixSetId: o5 });
  525. }
  526. writeActiveLayer(e2, t3, r4, i2) {
  527. const s3 = this.activeLayer;
  528. t3.templateUrl = this.getUrlTemplate(s3.id, s3.tileMatrixSetId, s3.imageFormat, s3.styleId);
  529. const a2 = t("tileMatrixSet.tileInfo", s3);
  530. t3.tileInfo = a2 ? a2.toJSON(i2) : null, t3.wmtsInfo = { ...t3.wmtsInfo, layerIdentifier: s3.id, tileMatrixSet: s3.tileMatrixSetId };
  531. }
  532. readCustomParameters(e2, t3) {
  533. const r4 = t3.wmtsInfo;
  534. return r4 ? this._mergeParams(r4.customParameters, r4.url) : null;
  535. }
  536. get fullExtents() {
  537. return this.activeLayer.fullExtents;
  538. }
  539. readServiceMode(e2, t3) {
  540. return t3.templateUrl.includes("?") ? "KVP" : "RESTful";
  541. }
  542. readSublayersFromService(e2, t3, r4) {
  543. return V2(t3.layers, r4);
  544. }
  545. get supportedSpatialReferences() {
  546. var _a, _b;
  547. return (_b = (_a = this.activeLayer.tileMatrixSets) == null ? void 0 : _a.map((e2) => {
  548. var _a2;
  549. return (_a2 = e2.tileInfo) == null ? void 0 : _a2.spatialReference;
  550. }).toArray().filter(r)) != null ? _b : [];
  551. }
  552. get tilemapCache() {
  553. var _a, _b;
  554. const e2 = (_b = (_a = this.activeLayer) == null ? void 0 : _a.tileMatrixSet) == null ? void 0 : _b.tileInfo;
  555. return e2 ? new l3(e2) : void 0;
  556. }
  557. get title() {
  558. var _a, _b;
  559. return (_b = (_a = this.activeLayer) == null ? void 0 : _a.title) != null ? _b : "Layer";
  560. }
  561. set title(e2) {
  562. this._overrideIfSome("title", e2);
  563. }
  564. get url() {
  565. return this._get("url");
  566. }
  567. set url(e2) {
  568. e2 && "/" === e2.substr(-1) ? this._set("url", e2.slice(0, -1)) : this._set("url", e2);
  569. }
  570. createWebTileLayer(e2) {
  571. var _a;
  572. const t3 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId), r4 = (_a = this._getTileMatrixSetById(e2.tileMatrixSetId)) == null ? void 0 : _a.tileInfo, i2 = e2.fullExtent, s3 = new p2({ layerIdentifier: e2.id, tileMatrixSet: e2.tileMatrixSetId, url: this.url });
  573. return this.customLayerParameters && (s3.customLayerParameters = this.customLayerParameters), this.customParameters && (s3.customParameters = this.customParameters), new x({ fullExtent: i2, urlTemplate: t3, tileInfo: r4, wmtsInfo: s3 });
  574. }
  575. fetchTile(e2, r4, i2) {
  576. const s3 = this.getTileUrl(e2, r4, i2);
  577. return U2(s3, { responseType: "image" }).then((e3) => e3.data);
  578. }
  579. async fetchImageBitmapTile(e2, r4, i2) {
  580. const s3 = this.getTileUrl(e2, r4, i2), { data: a2 } = await U2(s3, { responseType: "blob" });
  581. return createImageBitmap(a2);
  582. }
  583. findSublayerById(e2) {
  584. var _a;
  585. return (_a = this.sublayers) == null ? void 0 : _a.find((t3) => t3.id === e2);
  586. }
  587. getTileUrl(e2, t3, r4) {
  588. var _a, _b;
  589. const i2 = (_b = (_a = this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId)) == null ? void 0 : _a.tileInfo) == null ? void 0 : _b.lods[e2], s3 = i2 ? i2.levelValue ? i2.levelValue : `${i2.level}` : `${e2}`;
  590. let a2 = this.resourceInfo ? "" : T({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId, s3, t3, r4);
  591. if (!a2) {
  592. a2 = this.getUrlTemplate(this.activeLayer.id, this.activeLayer.tileMatrixSetId, this.activeLayer.imageFormat, this.activeLayer.styleId).replace(/\{level\}/gi, s3).replace(/\{row\}/gi, `${t3}`).replace(/\{col\}/gi, `${r4}`);
  593. }
  594. return a2 = this._appendCustomLayerParameters(a2), a2;
  595. }
  596. getUrlTemplate(e2, t3, r4, i2) {
  597. if (!this.resourceInfo) {
  598. const r5 = R({ dimensionMap: this.dimensionMap, layerMap: this.layerMap }, e2, t3, i2);
  599. if (r5)
  600. return r5;
  601. }
  602. if ("KVP" === this.serviceMode)
  603. return this.url + "?SERVICE=WMTS&VERSION=" + this.version + "&REQUEST=GetTile&LAYER=" + e2 + "&STYLE=" + i2 + "&FORMAT=" + r4 + "&TILEMATRIXSET=" + t3 + "&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";
  604. if ("RESTful" === this.serviceMode) {
  605. let s3 = "";
  606. return W[r4.toLowerCase()] && (s3 = W[r4.toLowerCase()]), this.url + e2 + "/" + i2 + "/" + t3 + "/{level}/{row}/{col}" + s3;
  607. }
  608. return "";
  609. }
  610. async _fetchService(e2) {
  611. let t3;
  612. if (this.resourceInfo)
  613. "KVP" === this.resourceInfo.serviceMode && (this.url += this.url.includes("?") ? "" : "?"), t3 = { ssl: false, data: this.resourceInfo };
  614. else
  615. try {
  616. t3 = await this._getCapabilities(this.serviceMode, e2), u2(t3.data);
  617. } catch {
  618. const s3 = "KVP" === this.serviceMode ? "RESTful" : "KVP";
  619. try {
  620. t3 = await this._getCapabilities(s3, e2), u2(t3.data), this.serviceMode = s3;
  621. } catch (r4) {
  622. throw new s("wmtslayer:unsupported-service-data", "Services does not support RESTful or KVP service modes.", { error: r4 });
  623. }
  624. }
  625. this.resourceInfo ? t3.data = f(t3.data) : t3.data = p6(t3.data, { serviceMode: this.serviceMode, url: this.url }), t3.data && this.read(t3.data, { origin: "service" });
  626. }
  627. async _getCapabilities(e2, r4) {
  628. const i2 = this._getCapabilitiesUrl(e2);
  629. return await U2(i2, { ...r4, responseType: "text" });
  630. }
  631. _getTileMatrixSetById(e2) {
  632. var _a, _b;
  633. const t3 = (_b = (_a = this.findSublayerById(this.activeLayer.id)) == null ? void 0 : _a.tileMatrixSets) == null ? void 0 : _b.find((t4) => t4.id === e2);
  634. return t3;
  635. }
  636. _appendCustomParameters(e2) {
  637. return this._appendParameters(e2, this.customParameters);
  638. }
  639. _appendCustomLayerParameters(e2) {
  640. return this._appendParameters(e2, { ...y(this.customParameters), ...this.customLayerParameters });
  641. }
  642. _appendParameters(e2, t3) {
  643. const r4 = j2(e2), i2 = { ...r4.query, ...t3 }, s3 = I(i2);
  644. return "" === s3 ? r4.path : `${r4.path}?${s3}`;
  645. }
  646. _getCapabilitiesUrl(e2) {
  647. this.url = this.url.split("?")[0];
  648. const t3 = "KVP" === e2 ? `${this.url}?request=GetCapabilities&service=WMTS&version=${this.version}` : `${this.url}/${this.version}/WMTSCapabilities.xml`;
  649. return this._appendCustomParameters(t3);
  650. }
  651. _getLowerCasedUrlParams(e2) {
  652. if (!e2)
  653. return null;
  654. const t3 = j2(e2).query;
  655. if (!t3)
  656. return null;
  657. const r4 = {};
  658. return Object.keys(t3).forEach((e3) => {
  659. r4[e3.toLowerCase()] = t3[e3];
  660. }), r4;
  661. }
  662. _mergeParams(e2, t3) {
  663. const r4 = this._getLowerCasedUrlParams(t3);
  664. if (r4) {
  665. const t4 = Object.keys(r4);
  666. t4.length && (e2 = e2 ? y(e2) : {}, t4.forEach((t5) => {
  667. e2.hasOwnProperty(t5) || A2.has(t5) || (e2[t5] = r4[t5]);
  668. }));
  669. }
  670. return e2;
  671. }
  672. };
  673. function V2(e2, t3) {
  674. return e2.map((e3) => {
  675. const r4 = new u();
  676. return r4.read(e3, t3), r4;
  677. });
  678. }
  679. e([y2()], F2.prototype, "dimensionMap", void 0), e([y2()], F2.prototype, "layerMap", void 0), e([y2({ type: u, json: { origins: { "web-document": { write: { ignoreOrigin: true } } } } })], F2.prototype, "activeLayer", null), e([o("service", "activeLayer", ["layers"])], F2.prototype, "readActiveLayerFromService", null), e([o(["web-document", "portal-item"], "activeLayer", ["wmtsInfo"])], F2.prototype, "readActiveLayerFromItemOrWebDoc", null), e([r2(["web-document", "portal-item"], "activeLayer", { templateUrl: { type: String }, tileInfo: { type: j3 }, "wmtsInfo.layerIdentifier": { type: String }, "wmtsInfo.tileMatrixSet": { type: String } })], F2.prototype, "writeActiveLayer", null), e([y2({ type: String, value: "", json: { write: true } })], F2.prototype, "copyright", void 0), e([y2({ type: ["show", "hide"] })], F2.prototype, "listMode", void 0), e([y2({ json: { read: true, write: true } })], F2.prototype, "blendMode", void 0), e([y2({ 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" } } } } })], F2.prototype, "customParameters", void 0), e([o(["portal-item", "web-document"], "customParameters")], F2.prototype, "readCustomParameters", null), e([y2({ json: { origins: { "web-document": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } }, "portal-item": { read: { source: "wmtsInfo.customLayerParameters" }, write: { target: "wmtsInfo.customLayerParameters" } } } } })], F2.prototype, "customLayerParameters", void 0), e([y2({ type: w3, json: { write: { ignoreOrigin: true }, origins: { "web-document": { read: { source: "fullExtent" } }, "portal-item": { read: { source: "fullExtent" } } } } })], F2.prototype, "fullExtent", void 0), e([y2({ readOnly: true })], F2.prototype, "fullExtents", null), e([y2({ type: ["WebTiledLayer"] })], F2.prototype, "operationalLayerType", void 0), e([y2()], F2.prototype, "resourceInfo", void 0), e([y2()], F2.prototype, "serviceMode", void 0), e([o(["portal-item", "web-document"], "serviceMode", ["templateUrl"])], F2.prototype, "readServiceMode", null), e([y2({ type: j.ofType(u) })], F2.prototype, "sublayers", void 0), e([o("service", "sublayers", ["layers"])], F2.prototype, "readSublayersFromService", null), e([y2({ readOnly: true })], F2.prototype, "supportedSpatialReferences", null), e([y2({ readOnly: true })], F2.prototype, "tilemapCache", null), e([y2({ json: { read: { source: "title" } } })], F2.prototype, "title", null), e([y2({ json: { read: false }, readOnly: true, value: "wmts" })], F2.prototype, "type", void 0), e([y2({ 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" } } } } })], F2.prototype, "url", null), e([y2()], F2.prototype, "version", void 0), F2 = e([n("esri.layers.WMTSLayer")], F2);
  680. var $ = F2;
  681. export {
  682. $ as default
  683. };
  684. //# sourceMappingURL=WMTSLayer-ZV2ZIJNI.js.map