@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
1 lines • 27.3 kB
JavaScript
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[309],{13043:(e,t,i)=>{function r(e,t){if(e&&t)for(const i of e.children)if(i.localName in t){const e=t[i.localName];if("function"==typeof e){const t=e(i);t&&r(i,t)}else r(i,e)}}function*s(e,t){for(const i of e.children)if(i.localName in t){const e=t[i.localName];"function"==typeof e?yield e(i):yield*s(i,e)}}i.d(t,{i:()=>s,p:()=>r})},20309:(e,t,i)=>{i.r(t),i.d(t,{default:()=>fe});var r,s=i(90237),l=i(78888),o=i(4576),n=i(5503),a=i(49186),c=i(4718),u=i(92071),p=i(93637),d=i(74887),m=i(36708),h=i(84952),y=i(10107),f=(i(44208),i(53966),i(36005)),g=i(40608),w=i(43937),v=i(5443),M=i(4146),x=i(47314),S=i(63074),I=i(16131),L=i(8303),T=i(54310),A=i(25036),_=i(33446),C=i(87045),P=i(65509),b=i(83703),E=i(25482);i(87811);let O=r=class extends E.A{constructor(e){super(e),this.fullExtent=null,this.id=null,this.tileInfo=null}clone(){const e=new r;return this.hasOwnProperty("fullExtent")&&(e.fullExtent=this.fullExtent?.clone()??null),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("tileInfo")&&(e.tileInfo=this.tileInfo?.clone()??null),e}};(0,s._)([(0,y.MZ)({type:v.A,json:{read:{source:"fullExtent"}}})],O.prototype,"fullExtent",void 0),(0,s._)([(0,y.MZ)({type:String,json:{read:{source:"id"}}})],O.prototype,"id",void 0),(0,s._)([(0,y.MZ)({type:C.A,json:{read:{source:"tileInfo"}}})],O.prototype,"tileInfo",void 0),O=r=(0,s._)([(0,g.$)("esri.layers.support.TileMatrixSet")],O);const R=O;var F;let Z=F=class extends E.A{constructor(e){super(e),this.id=null,this.title=null,this.description=null,this.legendUrl=null}clone(){const e=new F;return this.hasOwnProperty("description")&&(e.description=this.description),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("isDefault")&&(e.isDefault=this.isDefault),this.hasOwnProperty("keywords")&&(e.keywords=this.keywords&&this.keywords.slice()),this.hasOwnProperty("legendUrl")&&(e.legendUrl=this.legendUrl),this.hasOwnProperty("title")&&(e.title=this.title),e}};(0,s._)([(0,y.MZ)({json:{read:{source:"id"}}})],Z.prototype,"id",void 0),(0,s._)([(0,y.MZ)({json:{read:{source:"title"}}})],Z.prototype,"title",void 0),(0,s._)([(0,y.MZ)({json:{read:{source:"abstract"}}})],Z.prototype,"description",void 0),(0,s._)([(0,y.MZ)({json:{read:{source:"legendUrl"}}})],Z.prototype,"legendUrl",void 0),(0,s._)([(0,y.MZ)({json:{read:{source:"isDefault"}}})],Z.prototype,"isDefault",void 0),(0,s._)([(0,y.MZ)({json:{read:{source:"keywords"}}})],Z.prototype,"keywords",void 0),Z=F=(0,s._)([(0,g.$)("esri.layers.support.WMTSStyle")],Z);const V=Z;var U;let j=U=class extends E.A{constructor(e){super(e),this.description=null,this.fullExtent=null,this.fullExtents=null,this.id=null,this.imageFormats=null,this.layer=null,this.parent=null,this.styles=null,this.title=null,this.tileMatrixSetId=null,this.tileMatrixSets=null}readFullExtent(e,t){return(e=t.fullExtent)?v.A.fromJSON(e):null}readFullExtents(e,t){return t.fullExtents?.length?t.fullExtents.map((e=>v.A.fromJSON(e))):t.tileMatrixSets?.map((e=>v.A.fromJSON(e.fullExtent))).filter((e=>e))??[]}get imageFormat(){let e=this._get("imageFormat");return e||(e=this.imageFormats?.length?this.imageFormats[0]:""),e}set imageFormat(e){const t=this.imageFormats;e&&(e.includes("image/")||t&&!t.includes(e))&&(e.includes("image/")||(e="image/"+e),t&&!t.includes(e))?console.error("The layer doesn't support the format of "+e):this._set("imageFormat",e)}get styleId(){let e=this._get("styleId");return e||(e=this.styles?.at(0)?.id??""),e}set styleId(e){this._set("styleId",e)}get tileMatrixSet(){return this.tileMatrixSets?.find((({id:e})=>e===this.tileMatrixSetId))??null}clone(){const e=new U;return this.hasOwnProperty("description")&&(e.description=this.description),this.hasOwnProperty("imageFormats")&&(e.imageFormats=this.imageFormats?.slice()??null),this.hasOwnProperty("imageFormat")&&(e.imageFormat=this.imageFormat),this.hasOwnProperty("fullExtent")&&(e.fullExtent=this.fullExtent?.clone()),this.hasOwnProperty("id")&&(e.id=this.id),this.hasOwnProperty("layer")&&(e.layer=this.layer),this.hasOwnProperty("styleId")&&(e.styleId=this.styleId),this.hasOwnProperty("styles")&&(e.styles=this.styles?.clone()),this.hasOwnProperty("tileMatrixSetId")&&(e.tileMatrixSetId=this.tileMatrixSetId),this.hasOwnProperty("tileMatrixSets")&&(e.tileMatrixSets=this.tileMatrixSets?.clone()),this.hasOwnProperty("title")&&(e.title=this.title),e}};(0,s._)([(0,y.MZ)()],j.prototype,"description",void 0),(0,s._)([(0,y.MZ)({type:v.A})],j.prototype,"fullExtent",void 0),(0,s._)([(0,f.w)("fullExtent",["fullExtent"])],j.prototype,"readFullExtent",null),(0,s._)([(0,y.MZ)({readOnly:!0})],j.prototype,"fullExtents",void 0),(0,s._)([(0,f.w)("fullExtents",["fullExtents","tileMatrixSets"])],j.prototype,"readFullExtents",null),(0,s._)([(0,y.MZ)()],j.prototype,"id",void 0),(0,s._)([(0,y.MZ)()],j.prototype,"imageFormat",null),(0,s._)([(0,y.MZ)({json:{read:{source:"formats"}}})],j.prototype,"imageFormats",void 0),(0,s._)([(0,y.MZ)()],j.prototype,"layer",void 0),(0,s._)([(0,y.MZ)()],j.prototype,"parent",void 0),(0,s._)([(0,y.MZ)()],j.prototype,"styleId",null),(0,s._)([(0,y.MZ)({type:n.A.ofType(V),json:{read:{source:"styles"}}})],j.prototype,"styles",void 0),(0,s._)([(0,y.MZ)({json:{write:{ignoreOrigin:!0}}})],j.prototype,"title",void 0),(0,s._)([(0,y.MZ)()],j.prototype,"tileMatrixSetId",void 0),(0,s._)([(0,y.MZ)({readOnly:!0})],j.prototype,"tileMatrixSet",null),(0,s._)([(0,y.MZ)({type:n.A.ofType(R),json:{read:{source:"tileMatrixSets"}}})],j.prototype,"tileMatrixSets",void 0),j=U=(0,s._)([(0,g.$)("esri.layers.support.WMTSSublayer")],j);var N=i(73941),k=i(86738),D=i(22530),W=i(38458),B=i(13043),K=i(91806);const $=90.71428571428571;function H(e){const t=e.replaceAll(/ows:/gi,"");return(new DOMParser).parseFromString(t,"text/xml")}function J(e){if(!G("Contents",e.documentElement))throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid","the wmts get capabilities response is not compliant")}function q(e){return e.nodeType===Node.ELEMENT_NODE}function G(e,t){for(let i=0;i<t.childNodes.length;i++){const r=t.childNodes[i];if(q(r)&&r.nodeName===e)return r}return null}function z(e,t){const i=[];for(let r=0;r<t.childNodes.length;r++){const s=t.childNodes[r];q(s)&&s.nodeName===e&&i.push(s)}return i}function Q(e,t){const i=[];for(let r=0;r<t.childNodes.length;r++){const s=t.childNodes[r];q(s)&&s.nodeName===e&&i.push(s)}return i.map((e=>e.textContent)).filter(o.Ru)}function X(e,t){return e.split(">").forEach((e=>{t&&(t=G(e,t))})),t&&t.textContent}function Y(e,t,i,r){let s;return Array.prototype.slice.call(r.childNodes).some((r=>{if(r.nodeName.includes(e)){const e=G(t,r),l=e?.textContent;if(l===i||i.split(":")&&i.split(":")[1]===l)return s=r,!0}return!1})),s}function ee(e,t,i,r,s){const l=X("Abstract",t),o=Q("Format",t);return{id:e,fullExtent:ie(t),fullExtents:re(t),description:l,formats:o,styles:se(t,r),title:X("Title",t),tileMatrixSets:le(s,t,i)}}function te(e,t){const i=[],r=e.layerMap?.get(t);if(!r)return null;const s=z("ResourceURL",r),l=z("Dimension",r);let o,n,a,c;return l.length&&(o=X("Identifier",l[0]),n=Q("Default",l[0])||Q("Value",l[0])),l.length>1&&(a=X("Identifier",l[1]),c=Q("Default",l[1])||Q("Value",l[1])),e.dimensionMap.set(t,{dimensions:n,dimensions2:c}),s.forEach((e=>{let t=e.getAttribute("template");if("tile"===e.getAttribute("resourceType")){if(o&&n.length)if(t.includes("{"+o+"}"))t=t.replace("{"+o+"}","{dimensionValue}");else{const e=t.toLowerCase().indexOf("{"+o.toLowerCase()+"}");e>-1&&(t=t.slice(0,e)+"{dimensionValue}"+t.slice(e+o.length+2))}if(a&&c.length)if(t.includes("{"+a+"}"))t=t.replace("{"+a+"}","{dimensionValue2}");else{const e=t.toLowerCase().indexOf("{"+a.toLowerCase()+"}");e>-1&&(t=t.slice(0,e)+"{dimensionValue2}"+t.slice(e+a.length+2))}i.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),i}function ie(e){const t=G("WGS84BoundingBox",e),i=t?X("LowerCorner",t).split(" "):["-180","-90"],r=t?X("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(i[0]),ymin:parseFloat(i[1]),xmax:parseFloat(r[0]),ymax:parseFloat(r[1]),spatialReference:{wkid:4326}}}function re(e){const t=[];return(0,B.p)(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const i=e.getAttribute("crs").toLowerCase(),r=oe(i),s=i.includes("epsg")&&(0,W.m)(r.wkid);let l,o,n,a;(0,B.p)(e,{LowerCorner:e=>{[l,o]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),s&&([l,o]=[o,l])},UpperCorner:e=>{[n,a]=e.textContent.split(" ").map((e=>Number.parseFloat(e))),s&&([n,a]=[a,n])}}),t.push({xmin:l,ymin:o,xmax:n,ymax:a,spatialReference:r})}}),t}function se(e,t){return z("Style",e).map((e=>{const i=G("LegendURL",e),r=G("Keywords",e),s=r?Q("Keyword",r):[];let l=i?.getAttribute("xlink:href");return t&&(l=l?.replace(/^http:/i,"https:")),{abstract:X("Abstract",e),id:X("Identifier",e),isDefault:"true"===e.getAttribute("isDefault"),keywords:s,legendUrl:l,title:X("Title",e)}}))}function le(e,t,i){return z("TileMatrixSetLink",t).map((t=>function(e,t,i){const r=G("TileMatrixSet",t).textContent,s=Q("TileMatrix",t),l=i.find((e=>{const t=G("Identifier",e),i=t?.textContent;return!!(i===r||r.split(":")&&r.split(":")[1]===i)})),o=G("TileMatrixSetLimits",t),n=o&&z("TileMatrixLimits",o),a=new Map;if(n?.length)for(const e of n){const t=G("TileMatrix",e).textContent,i=+G("MinTileRow",e).textContent,r=+G("MaxTileRow",e).textContent,s=+G("MinTileCol",e).textContent,l=+G("MaxTileCol",e).textContent;a.set(t,{minCol:s,maxCol:l,minRow:i,maxRow:r})}const c=X("SupportedCRS",l).toLowerCase(),u=function(e,t){return ne(G("TileMatrix",e),t)}(l,c),p=u.spatialReference,d=G("TileMatrix",l),m=[parseInt(X("TileWidth",d),10),parseInt(X("TileHeight",d),10)],h=[];s.length?s.forEach(((e,t)=>{const i=Y("TileMatrix","Identifier",e,l);h.push(pe(i,c,t,r,a))})):z("TileMatrix",l).forEach(((e,t)=>{h.push(pe(e,c,t,r,a))}));const y=function(e,t,i,r,s){const l=G("BoundingBox",t);let o,n,a,c,u,p;if(l&&(o=X("LowerCorner",l).split(" "),n=X("UpperCorner",l).split(" ")),o&&o.length>1&&n&&n.length>1)a=parseFloat(o[0]),u=parseFloat(o[1]),c=parseFloat(n[0]),p=parseFloat(n[1]);else{const e=G("TileMatrix",t),l=parseInt(X("MatrixWidth",e),10),o=parseInt(X("MatrixHeight",e),10);a=i.x,p=i.y,c=a+l*r[0]*s.resolution,u=p-o*r[1]*s.resolution}return function(e,t,i){return"1.0.0"===e&&(0,W.m)(t.wkid)&&!(i.spatialReference.isGeographic&&i.x<-90&&i.y>=-90)}(e,i.spatialReference,i)?new v.A(u,a,p,c,i.spatialReference):new v.A(a,u,c,p,i.spatialReference)}(e,l,u,m,h[0]).toJSON(),f=new C.A({dpi:96,spatialReference:p,size:m,origin:u,lods:h}).toJSON();return{id:r,fullExtent:y,tileInfo:f}}(e,t,i)))}function oe(e){e=e.toLowerCase();let t=parseInt(e.split(":").pop(),10);900913!==t&&3857!==t||(t=102100);const i=function(e){return e.includes("crs84")||e.includes("crs:84")?ae.CRS84:e.includes("crs83")||e.includes("crs:83")?ae.CRS83:e.includes("crs27")||e.includes("crs:27")?ae.CRS27:null}(e);return null!=i&&(t=i),{wkid:t}}function ne(e,t){const i=oe(t),[r,s]=X("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),l=t.includes("epsg")&&(0,W.m)(i.wkid);return new k.A(l?{x:s,y:r,spatialReference:i}:{x:r,y:s,spatialReference:i})}var ae,ce,ue;function pe(e,t,i,r,s){const l=oe(t),o=X("Identifier",e);let n=parseFloat(X("ScaleDenominator",e));const a=de(l.wkid,n,r);n*=96/$;const c=+X("MatrixWidth",e),u=+X("MatrixHeight",e),{maxCol:p=c-1,maxRow:d=u-1,minCol:m=0,minRow:h=0}=s.get(o)??{},{x:y,y:f}=ne(e,t);return new K.A({cols:[m,p],level:i,levelValue:o,origin:[y,f],scale:n,resolution:a,rows:[h,d]})}function de(e,t,i){let r;return r=D.A.hasOwnProperty(""+e)?D.A.values[D.A[e]]:"default028mm"===i?6370997*Math.PI/180:(0,N.y7)(e).metersPerDegree,7*t/25e3/r}(ce=ae||(ae={}))[ce.CRS84=4326]="CRS84",ce[ce.CRS83=4269]="CRS83",ce[ce.CRS27=4267]="CRS27";const me={"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":""},he=new Set(["version","service","request","layer","style","format","tilematrixset","tilematrix","tilerow","tilecol"]);let ye=ue=class extends((0,S.dM)((0,T.J)((0,A.j)((0,I.q)((0,L.A)((0,u.P)(M.A))))))){constructor(...e){super(...e),this.activeLayer=null,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([(0,m.wB)((()=>this.activeLayer),((e,t)=>{t&&!this.sublayers?.includes(t)&&(t.layer=null,t.parent=null),e&&(e.layer=this,e.parent=this)}),m.OH),(0,m.on)((()=>this.sublayers),"after-add",(({item:e})=>{e.layer=this,e.parent=this}),m.OH),(0,m.on)((()=>this.sublayers),"after-remove",(({item:e})=>{e.layer=null,e.parent=null}),m.OH),(0,m.wB)((()=>this.sublayers),((e,t)=>{if(t)for(const e of t)e.layer=null,e.parent=null;if(e)for(const t of e)t.layer=this,t.parent=this}),m.OH)])}normalizeCtorArgs(e,t){return"string"==typeof e?{url:e,...t}:e}load(e){return this.addResolvingPromise(this.loadFromPortal({supportedTypes:["WMTS"]},e).catch(d.QP).then((()=>this._fetchService(e))).catch((e=>{throw(0,d.QP)(e),new a.A("wmtslayer:unsupported-service-data","Invalid response from the WMTS service.",{error:e})}))),Promise.resolve(this)}readActiveLayerFromService(e,t,i){this.activeLayer||(this.activeLayer=new j);let r=t.layers.find((e=>e.id===this.activeLayer.id));return r||(r=t.layers[0]),this.activeLayer.read(r,i),this.activeLayer}readActiveLayerFromItemOrWebDoc(e,t){const{templateUrl:i,wmtsInfo:r}=t,s=i?this._getLowerCasedUrlParams(i):null,l=r?.layerIdentifier;let o=null;const n=r?.tileMatrixSet;n&&(Array.isArray(n)?n.length&&(o=n[0]):o=n);const a=s?.format,c=s?.style;return new j({id:l,imageFormat:a,styleId:c,tileMatrixSetId:o})}writeActiveLayer(e,t,i,r){const s=this.activeLayer;t.templateUrl=this.getUrlTemplate(s.id,s.tileMatrixSetId,s.imageFormat,s.styleId);const l=(0,p.wc)("tileMatrixSet.tileInfo",s);t.tileInfo=l?l.toJSON(r):null,t.wmtsInfo={...t.wmtsInfo,layerIdentifier:s.id,tileMatrixSet:s.tileMatrixSetId}}readCustomParameters(e,t){const i=t.wmtsInfo;return i?this._mergeParams(i.customParameters,i.url):null}get fullExtents(){return this.activeLayer.fullExtents}readServiceMode(e,t){return t.templateUrl.includes("?")?"KVP":"RESTful"}readSublayersFromService(e,t,i){return function(e,t){return e.map((e=>{const i=new j;return i.read(e,t),i}))}(t.layers,i)}get supportedSpatialReferences(){return this.activeLayer.tileMatrixSets?.map((e=>e.tileInfo?.spatialReference)).toArray().filter(o.Ru)??[]}get tilemapCache(){const e=this.activeLayer?.tileMatrixSet?.tileInfo;return e?new P.A(e):void 0}get title(){return this.activeLayer?.title??"Layer"}set title(e){this._overrideIfSome("title",e)}get url(){return this._get("url")}set url(e){e&&e.endsWith("/")?this._set("url",e.slice(0,-1)):this._set("url",e)}createWebTileLayer(e){const t=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId),i=this._getTileMatrixSetById(e.tileMatrixSetId),r=i?.tileInfo,s=e.fullExtent,l=new b.x({layerIdentifier:e.id,tileMatrixSet:e.tileMatrixSetId,url:this.url});return this.customLayerParameters&&(l.customLayerParameters=this.customLayerParameters),this.customParameters&&(l.customParameters=this.customParameters),new x.default({fullExtent:s,urlTemplate:t,tileInfo:r,wmtsInfo:l})}async fetchTile(e,t,i,r={}){const{signal:s}=r,o=this.getTileUrl(e,t,i),{data:n}=await(0,l.A)(o,{responseType:"image",signal:s});return n}async fetchImageBitmapTile(e,t,i,r={}){const{signal:s}=r;if(this.fetchTile!==ue.prototype.fetchTile){const l=await this.fetchTile(e,t,i,r);return(0,_.C)(l,e,t,i,s)}const o=this.getTileUrl(e,t,i),{data:n}=await(0,l.A)(o,{responseType:"blob",signal:s});return(0,_.C)(n,e,t,i,s)}findSublayerById(e){return this.sublayers?.find((t=>t.id===e))}getTileUrl(e,t,i){const r=this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId),s=r?.tileInfo?.lods[e],l=s?s.levelValue||`${s.level}`:`${e}`;let o=this.resourceInfo?"":function(e,t,i,r,s,l,o,n){const a=function(e,t,i){const r=te(e,t),s=r?.filter((e=>e.format===i));return(s?.length?s:r)??[]}(e,t,r);if(!(a?.length>0))return"";const{dimensionMap:c}=e,u=c.get(t).dimensions?.[0],p=c.get(t).dimensions2?.[0];return a[o%a.length].template.replaceAll(/\{Style\}/gi,s??"").replaceAll(/\{TileMatrixSet\}/gi,i??"").replaceAll(/\{TileMatrix\}/gi,l).replaceAll(/\{TileRow\}/gi,""+o).replaceAll(/\{TileCol\}/gi,""+n).replaceAll(/\{dimensionValue\}/gi,u).replaceAll(/\{dimensionValue2\}/gi,p)}({dimensionMap:this.dimensionMap,layerMap:this.layerMap},this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId,l,t,i);return o||(o=this.getUrlTemplate(this.activeLayer.id,this.activeLayer.tileMatrixSetId,this.activeLayer.imageFormat,this.activeLayer.styleId).replaceAll(/\{level\}/gi,l).replaceAll(/\{row\}/gi,`${t}`).replaceAll(/\{col\}/gi,`${i}`)),o=this._appendCustomLayerParameters(o),o}getUrlTemplate(e,t,i,r){if(!this.resourceInfo){const i=function(e,t,i,r){const{dimensionMap:s}=e,l=te(e,t);let o="";if(l&&l.length>0){const e=s.get(t).dimensions?.[0],n=s.get(t).dimensions2?.[0];o=l[0].template,o.endsWith(".xxx")&&(o=o.slice(0,-4)),o=o.replaceAll(/\{Style\}/gi,r),o=o.replaceAll(/\{TileMatrixSet\}/gi,i),o=o.replaceAll(/\{TileMatrix\}/gi,"{level}"),o=o.replaceAll(/\{TileRow\}/gi,"{row}"),o=o.replaceAll(/\{TileCol\}/gi,"{col}"),o=o.replaceAll(/\{dimensionValue\}/gi,e),o=o.replaceAll(/\{dimensionValue2\}/gi,n)}return o}({dimensionMap:this.dimensionMap,layerMap:this.layerMap},e,t,r);if(i)return i}if("KVP"===this.serviceMode)return this.url+"?SERVICE=WMTS&VERSION="+this.version+"&REQUEST=GetTile&LAYER="+e+"&STYLE="+r+"&FORMAT="+i+"&TILEMATRIXSET="+t+"&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";if("RESTful"===this.serviceMode){let s="";return me[i.toLowerCase()]&&(s=me[i.toLowerCase()]),this.url+e+"/"+r+"/"+t+"/{level}/{row}/{col}"+s}return""}async _fetchService(e){if(this.resourceInfo)return"KVP"!==this.resourceInfo.serviceMode||this.url.includes("?")||(this.url+="?"),function(e){for(const t of e.layers)for(const e of t.tileMatrixSets??[]){const{tileInfo:t}=e;if(t&&96!==t.dpi){for(const i of t.lods??[])i.scale=96*i.scale/t.dpi,i.resolution=de(t.spatialReference?.wkid,i.scale*$/96,e.id);t.dpi=96}}}(this.resourceInfo),void this.read(this.resourceInfo,{origin:"service"});let t=null;try{const{data:i}=await this._getCapabilities(this.serviceMode,e);t=H(i),J(t)}catch{const i="KVP"===this.serviceMode?"RESTful":"KVP";try{const{data:r}=await this._getCapabilities(i,e);t=H(r),J(t),this.serviceMode=i}catch(e){throw new a.A("wmtslayer:unsupported-service-data","Services does not support RESTful or KVP service modes.",{error:e})}}const{serviceMode:i,url:r}=this,s=function(e,t){const i=e.documentElement,r=new Map,s=new Map,l=G("Contents",i);if(!l)throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid","Can't retrieve xml capabilities element");const o=G("OperationsMetadata",i),n=o?.querySelector("[name='GetTile']"),c=n?.getElementsByTagName("Get"),u=c&&Array.prototype.slice.call(c),p=t.url?.indexOf("https"),d=void 0!==p&&p>-1;let m,h,y=t.serviceMode,f=t?.url;if(u?.length&&u.some((e=>{const t=G("Constraint",e);return!t||Y("AllowedValues","Value",y,t)?(f=e.attributes[0].nodeValue,!0):(!t||Y("AllowedValues","Value","RESTful",t)||Y("AllowedValues","Value","REST",t)?h=e.attributes[0].nodeValue:t&&!Y("AllowedValues","Value","KVP",t)||(m=e.attributes[0].nodeValue),!1)})),!f)if(h)f=h,y="RESTful";else if(m)f=m,y="KVP";else{const e=G("ServiceMetadataURL",i);f=e?.getAttribute("xlink:href")}const g=f.indexOf("1.0.0/");-1===g&&"RESTful"===y?f+="/":g>-1&&(f=f.slice(0,g)),"KVP"===y&&(f+=g>-1?"":"?"),d&&(f=f.replace(/^http:/i,"https:"));const w=X("ServiceIdentification>ServiceTypeVersion",i),v=X("ServiceIdentification>AccessConstraints",i),M=v&&/^none$/i.test(v)?null:v,x=z("Layer",l),S=z("TileMatrixSet",l),I=x.map((e=>{const t=X("Identifier",e);return r.set(t,e),ee(t,e,S,d,w)}));return{copyright:M,dimensionMap:s,layerMap:r,layers:I,serviceMode:y,tileUrl:f}}(t,{serviceMode:i,url:r});this.read(s,{origin:"service"})}async _getCapabilities(e,t){const i=this._getCapabilitiesUrl(e);return await(0,l.A)(i,{...t,responseType:"text"})}_getTileMatrixSetById(e){const t=this.findSublayerById(this.activeLayer.id);return t?.tileMatrixSets?.find((({id:t})=>t===e))}_appendCustomParameters(e){return this._appendParameters(e,this.customParameters)}_appendCustomLayerParameters(e){return this._appendParameters(e,{...(0,c.o8)(this.customParameters),...this.customLayerParameters})}_appendParameters(e,t){const i=(0,h.An)(e),r={...i.query,...t},s=(0,h.x0)(r);return""===s?i.path:`${i.path}?${s}`}_getCapabilitiesUrl(e){this.url=(0,h.An)(this.url).path;let t=this.url;switch(e){case"KVP":t+=`?request=GetCapabilities&service=WMTS&version=${this.version}`;break;case"RESTful":{const e=`/${this.version}/WMTSCapabilities.xml`,i=new RegExp(e,"i");t=t.replace(i,""),t+=e;break}}return this._appendCustomParameters(t)}_getLowerCasedUrlParams(e){if(!e)return null;const t=(0,h.An)(e).query;if(!t)return null;const i={};return Object.keys(t).forEach((e=>{i[e.toLowerCase()]=t[e]})),i}_mergeParams(e,t){const i=this._getLowerCasedUrlParams(t);if(i){const t=Object.keys(i);t.length&&(e=e?(0,c.o8)(e):{},t.forEach((t=>{e.hasOwnProperty(t)||he.has(t)||(e[t]=i[t])})))}return e}};(0,s._)([(0,y.MZ)()],ye.prototype,"dimensionMap",void 0),(0,s._)([(0,y.MZ)()],ye.prototype,"layerMap",void 0),(0,s._)([(0,y.MZ)({type:j,json:{origins:{"web-document":{write:{ignoreOrigin:!0}}}}})],ye.prototype,"activeLayer",void 0),(0,s._)([(0,f.w)("service","activeLayer",["layers"])],ye.prototype,"readActiveLayerFromService",null),(0,s._)([(0,f.w)(["web-document","portal-item"],"activeLayer",["wmtsInfo"])],ye.prototype,"readActiveLayerFromItemOrWebDoc",null),(0,s._)([(0,w.K)(["web-document","portal-item"],"activeLayer",{templateUrl:{type:String},tileInfo:{type:C.A},"wmtsInfo.layerIdentifier":{type:String},"wmtsInfo.tileMatrixSet":{type:String}})],ye.prototype,"writeActiveLayer",null),(0,s._)([(0,y.MZ)({type:String,value:"",json:{write:!0}})],ye.prototype,"copyright",void 0),(0,s._)([(0,y.MZ)({type:["show","hide"]})],ye.prototype,"listMode",void 0),(0,s._)([(0,y.MZ)({json:{read:!0,write:!0}})],ye.prototype,"blendMode",void 0),(0,s._)([(0,y.MZ)({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"}}}}})],ye.prototype,"customParameters",void 0),(0,s._)([(0,f.w)(["portal-item","web-document"],"customParameters")],ye.prototype,"readCustomParameters",null),(0,s._)([(0,y.MZ)({json:{origins:{"web-document":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}},"portal-item":{read:{source:"wmtsInfo.customLayerParameters"},write:{target:"wmtsInfo.customLayerParameters"}}}}})],ye.prototype,"customLayerParameters",void 0),(0,s._)([(0,y.MZ)({type:v.A,json:{write:{ignoreOrigin:!0},origins:{"web-document":{read:{source:"fullExtent"}},"portal-item":{read:{source:"fullExtent"}}}}})],ye.prototype,"fullExtent",void 0),(0,s._)([(0,y.MZ)({readOnly:!0})],ye.prototype,"fullExtents",null),(0,s._)([(0,y.MZ)({type:["WebTiledLayer"]})],ye.prototype,"operationalLayerType",void 0),(0,s._)([(0,y.MZ)()],ye.prototype,"resourceInfo",void 0),(0,s._)([(0,y.MZ)()],ye.prototype,"serviceMode",void 0),(0,s._)([(0,f.w)(["portal-item","web-document"],"serviceMode",["templateUrl"])],ye.prototype,"readServiceMode",null),(0,s._)([(0,y.MZ)({type:n.A.ofType(j)})],ye.prototype,"sublayers",void 0),(0,s._)([(0,f.w)("service","sublayers",["layers"])],ye.prototype,"readSublayersFromService",null),(0,s._)([(0,y.MZ)({readOnly:!0})],ye.prototype,"supportedSpatialReferences",null),(0,s._)([(0,y.MZ)({readOnly:!0})],ye.prototype,"tilemapCache",null),(0,s._)([(0,y.MZ)({json:{read:{source:"title"}}})],ye.prototype,"title",null),(0,s._)([(0,y.MZ)({json:{read:!1},readOnly:!0,value:"wmts"})],ye.prototype,"type",void 0),(0,s._)([(0,y.MZ)({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"}}}}})],ye.prototype,"url",null),(0,s._)([(0,y.MZ)()],ye.prototype,"version",void 0),ye=ue=(0,s._)([(0,g.$)("esri.layers.WMTSLayer")],ye);const fe=ye},38458:(e,t,i)=>{i.d(t,{m:()=>s});const r=[[3819,3819],[3821,3824],[3889,3889],[3906,3906],[4001,4025],[4027,4036],[4039,4047],[4052,4055],[4074,4075],[4080,4081],[4120,4176],[4178,4185],[4188,4216],[4218,4289],[4291,4304],[4306,4319],[4322,4326],[4463,4463],[4470,4470],[4475,4475],[4483,4483],[4490,4490],[4555,4558],[4600,4646],[4657,4765],[4801,4811],[4813,4821],[4823,4824],[4901,4904],[5013,5013],[5132,5132],[5228,5229],[5233,5233],[5246,5246],[5252,5252],[5264,5264],[5324,5340],[5354,5354],[5360,5360],[5365,5365],[5370,5373],[5381,5381],[5393,5393],[5451,5451],[5464,5464],[5467,5467],[5489,5489],[5524,5524],[5527,5527],[5546,5546],[2044,2045],[2081,2083],[2085,2086],[2093,2093],[2096,2098],[2105,2132],[2169,2170],[2176,2180],[2193,2193],[2200,2200],[2206,2212],[2319,2319],[2320,2462],[2523,2549],[2551,2735],[2738,2758],[2935,2941],[2953,2953],[3006,3030],[3034,3035],[3038,3051],[3058,3059],[3068,3068],[3114,3118],[3126,3138],[3150,3151],[3300,3301],[3328,3335],[3346,3346],[3350,3352],[3366,3366],[3389,3390],[3416,3417],[3833,3841],[3844,3850],[3854,3854],[3873,3885],[3907,3910],[4026,4026],[4037,4038],[4417,4417],[4434,4434],[4491,4554],[4839,4839],[5048,5048],[5105,5130],[5253,5259],[5269,5275],[5343,5349],[5479,5482],[5518,5519],[5520,5520],[20004,20032],[20064,20092],[21413,21423],[21473,21483],[21896,21899],[22171,22177],[22181,22187],[22191,22197],[25884,25884],[27205,27232],[27391,27398],[27492,27492],[28402,28432],[28462,28492],[30161,30179],[30800,30800],[31251,31259],[31275,31279],[31281,31290],[31466,31700]];function s(e){return null!=e&&r.some((([t,i])=>e>=t&&e<=i))}},65509:(e,t,i)=>{i.d(t,{A:()=>l});var r=i(49186),s=i(74887);class l{constructor(e,t=0,i=e.lods[e.lods.length-1].level){this.tileInfo=e,this.minLOD=t,this.maxLOD=i,e.lodAt(t)||(this.minLOD=e.lods[0].level),e.lodAt(i)||(this.maxLOD=e.lods[e.lods.length-1].level)}get effectiveMinLOD(){return this.minLOD??this.tileInfo.lods[0].level}get effectiveMaxLOD(){return this.maxLOD??this.tileInfo.lods[this.tileInfo.lods.length-1].level}getAvailability(e,t,i){const r=this.tileInfo?.lodAt(e);return!r||e<this.minLOD||e>this.maxLOD?"unavailable":r.cols&&r.rows?i>=r.cols[0]&&i<=r.cols[1]&&t>=r.rows[0]&&t<=r.rows[1]?"unknown":"unavailable":"unknown"}async fetchAvailability(e,t,i,l){await(0,s.NO)(l);const o=this.getAvailability(e,t,i);if("unavailable"===o)throw new r.A("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:i});return o}async fetchAvailabilityUpsample(e,t,i,r,l){await(0,s.NO)(l),r.level=e,r.row=t,r.col=i;const o=this.tileInfo;return o.updateTileInfo(r),this.fetchAvailability(e,t,i,l).catch((e=>{if((0,s.zf)(e))throw e;if(o.upsampleTile(r))return this.fetchAvailabilityUpsample(r.level,r.row,r.col,r,l);throw e}))}}}}]);