UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

1 lines • 27.3 kB
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[309],{20309:(e,t,r)=>{r.r(t),r.d(t,{default:()=>fe});var i,s=r(90237),l=r(78888),o=r(4576),n=r(5503),a=r(49186),c=r(4718),u=r(92071),p=r(93637),d=r(74887),h=r(36708),m=r(84952),y=r(10107),f=(r(44208),r(53966),r(36005)),g=r(40608),w=r(43937),x=r(5443),M=r(4146),v=r(47314),S=r(63074),I=r(16131),L=r(8303),T=r(54310),A=r(25036),_=r(33446),P=r(87045),C=r(65509),b=r(83703),E=r(25482);r(87811);let O=i=class extends E.A{constructor(e){super(e),this.fullExtent=null,this.id=null,this.tileInfo=null}clone(){const e=new i;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:x.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:P.A,json:{read:{source:"tileInfo"}}})],O.prototype,"tileInfo",void 0),O=i=(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 U=Z;var V;let j=V=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)?x.A.fromJSON(e):null}readFullExtents(e,t){return t.fullExtents?.length?t.fullExtents.map((e=>x.A.fromJSON(e))):t.tileMatrixSets?.map((e=>x.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 V;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:x.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(U),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=V=(0,s._)([(0,g.$)("esri.layers.support.WMTSSublayer")],j);const N=j;var k=r(73941),D=r(86738),W=r(22530),B=r(38458),K=r(13043),$=r(91806);const H=90.71428571428571;function J(e){const t=e.replaceAll(/ows:/gi,"");if(!G("Contents",(new DOMParser).parseFromString(t,"text/xml").documentElement))throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid","the wmts get capabilities response is not compliant",{text:e})}function q(e){return e.nodeType===Node.ELEMENT_NODE}function G(e,t){for(let r=0;r<t.childNodes.length;r++){const i=t.childNodes[r];if(q(i)&&i.nodeName===e)return i}return null}function z(e,t){const r=[];for(let i=0;i<t.childNodes.length;i++){const s=t.childNodes[i];q(s)&&s.nodeName===e&&r.push(s)}return r}function Q(e,t){const r=[];for(let i=0;i<t.childNodes.length;i++){const s=t.childNodes[i];q(s)&&s.nodeName===e&&r.push(s)}return r.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,r,i){let s;return Array.prototype.slice.call(i.childNodes).some((i=>{if(i.nodeName.includes(e)){const e=G(t,i),l=e?.textContent;if(l===r||r.split(":")&&r.split(":")[1]===l)return s=i,!0}return!1})),s}function ee(e,t,r,i,s){const l=X("Abstract",t),o=Q("Format",t);return{id:e,fullExtent:re(t),fullExtents:ie(t),description:l,formats:o,styles:se(t,i),title:X("Title",t),tileMatrixSets:le(s,t,r)}}function te(e,t){const r=[],i=e.layerMap?.get(t);if(!i)return null;const s=z("ResourceURL",i),l=z("Dimension",i);let o,n,a,c;return l.length&&(o=X("Identifier",l[0]),n=Q("Default",l[0])),l.length>1&&(a=X("Identifier",l[1]),c=Q("Default",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))}r.push({template:t,format:e.getAttribute("format"),resourceType:"tile"})}})),r}function re(e){const t=G("WGS84BoundingBox",e),r=t?X("LowerCorner",t).split(" "):["-180","-90"],i=t?X("UpperCorner",t).split(" "):["180","90"];return{xmin:parseFloat(r[0]),ymin:parseFloat(r[1]),xmax:parseFloat(i[0]),ymax:parseFloat(i[1]),spatialReference:{wkid:4326}}}function ie(e){const t=[];return(0,K.p)(e,{BoundingBox:e=>{if(!e.getAttribute("crs"))return;const r=e.getAttribute("crs").toLowerCase(),i=oe(r),s=r.includes("epsg")&&(0,B.m)(i.wkid);let l,o,n,a;(0,K.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:i})}}),t}function se(e,t){return z("Style",e).map((e=>{const r=G("LegendURL",e),i=G("Keywords",e),s=i?Q("Keyword",i):[];let l=r?.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,r){return z("TileMatrixSetLink",t).map((t=>function(e,t,r){const i=G("TileMatrixSet",t).textContent,s=Q("TileMatrix",t),l=r.find((e=>{const t=G("Identifier",e),r=t?.textContent;return!!(r===i||i.split(":")&&i.split(":")[1]===r)})),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,r=+G("MinTileRow",e).textContent,i=+G("MaxTileRow",e).textContent,s=+G("MinTileCol",e).textContent,l=+G("MaxTileCol",e).textContent;a.set(t,{minCol:s,maxCol:l,minRow:r,maxRow:i})}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),h=[parseInt(X("TileWidth",d),10),parseInt(X("TileHeight",d),10)],m=[];s.length?s.forEach(((e,t)=>{const r=Y("TileMatrix","Identifier",e,l);m.push(pe(r,c,t,i,a))})):z("TileMatrix",l).forEach(((e,t)=>{m.push(pe(e,c,t,i,a))}));const y=function(e,t,r,i,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=r.x,p=r.y,c=a+l*i[0]*s.resolution,u=p-o*i[1]*s.resolution}return function(e,t,r){return"1.0.0"===e&&(0,B.m)(t.wkid)&&!(r.spatialReference.isGeographic&&r.x<-90&&r.y>=-90)}(e,r.spatialReference,r)?new x.A(u,a,p,c,r.spatialReference):new x.A(a,u,c,p,r.spatialReference)}(e,l,u,h,m[0]).toJSON(),f=new P.A({dpi:96,spatialReference:p,size:h,origin:u,lods:m}).toJSON();return{id:i,fullExtent:y,tileInfo:f}}(e,t,r)))}function oe(e){e=e.toLowerCase();let t=parseInt(e.split(":").pop(),10);900913!==t&&3857!==t||(t=102100);const r=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!=r&&(t=r),{wkid:t}}function ne(e,t){const r=oe(t),[i,s]=X("TopLeftCorner",e).split(" ").map((e=>parseFloat(e))),l=t.includes("epsg")&&(0,B.m)(r.wkid);return new D.A(l?{x:s,y:i,spatialReference:r}:{x:i,y:s,spatialReference:r})}var ae,ce,ue;function pe(e,t,r,i,s){const l=oe(t),o=X("Identifier",e);let n=parseFloat(X("ScaleDenominator",e));const a=de(l.wkid,n,i);n*=96/H;const c=+X("MatrixWidth",e),u=+X("MatrixHeight",e),{maxCol:p=c-1,maxRow:d=u-1,minCol:h=0,minRow:m=0}=s.get(o)??{},{x:y,y:f}=ne(e,t);return new $.A({cols:[h,p],level:r,levelValue:o,origin:[y,f],scale:n,resolution:a,rows:[m,d]})}function de(e,t,r){let i;return i=W.A.hasOwnProperty(""+e)?W.A.values[W.A[e]]:"default028mm"===r?6370997*Math.PI/180:(0,k.y7)(e).metersPerDegree,7*t/25e3/i}(ce=ae||(ae={}))[ce.CRS84=4326]="CRS84",ce[ce.CRS83=4269]="CRS83",ce[ce.CRS27=4267]="CRS27";const he={"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":""},me=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,h.wB)((()=>this.activeLayer),((e,t)=>{t&&!this.sublayers?.includes(t)&&(t.layer=null,t.parent=null),e&&(e.layer=this,e.parent=this)}),h.OH),(0,h.on)((()=>this.sublayers),"after-add",(({item:e})=>{e.layer=this,e.parent=this}),h.OH),(0,h.on)((()=>this.sublayers),"after-remove",(({item:e})=>{e.layer=null,e.parent=null}),h.OH),(0,h.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}),h.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,r){this.activeLayer||(this.activeLayer=new N);let i=t.layers.find((e=>e.id===this.activeLayer.id));return i||(i=t.layers[0]),this.activeLayer.read(i,r),this.activeLayer}readActiveLayerFromItemOrWebDoc(e,t){const{templateUrl:r,wmtsInfo:i}=t,s=r?this._getLowerCasedUrlParams(r):null,l=i?.layerIdentifier;let o=null;const n=i?.tileMatrixSet;n&&(Array.isArray(n)?n.length&&(o=n[0]):o=n);const a=s?.format,c=s?.style;return new N({id:l,imageFormat:a,styleId:c,tileMatrixSetId:o})}writeActiveLayer(e,t,r,i){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(i):null,t.wmtsInfo={...t.wmtsInfo,layerIdentifier:s.id,tileMatrixSet:s.tileMatrixSetId}}readCustomParameters(e,t){const r=t.wmtsInfo;return r?this._mergeParams(r.customParameters,r.url):null}get fullExtents(){return this.activeLayer.fullExtents}readServiceMode(e,t){return t.templateUrl.includes("?")?"KVP":"RESTful"}readSublayersFromService(e,t,r){return function(e,t){return e.map((e=>{const r=new N;return r.read(e,t),r}))}(t.layers,r)}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 C.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),r=this._getTileMatrixSetById(e.tileMatrixSetId),i=r?.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 v.default({fullExtent:s,urlTemplate:t,tileInfo:i,wmtsInfo:l})}async fetchTile(e,t,r,i={}){const{signal:s}=i,o=this.getTileUrl(e,t,r),{data:n}=await(0,l.A)(o,{responseType:"image",signal:s});return n}async fetchImageBitmapTile(e,t,r,i={}){const{signal:s}=i;if(this.fetchTile!==ue.prototype.fetchTile){const l=await this.fetchTile(e,t,r,i);return(0,_.C)(l,e,t,r,s)}const o=this.getTileUrl(e,t,r),{data:n}=await(0,l.A)(o,{responseType:"blob",signal:s});return(0,_.C)(n,e,t,r,s)}findSublayerById(e){return this.sublayers?.find((t=>t.id===e))}getTileUrl(e,t,r){const i=this._getTileMatrixSetById(this.activeLayer.tileMatrixSetId),s=i?.tileInfo?.lods[e],l=s?s.levelValue||`${s.level}`:`${e}`;let o=this.resourceInfo?"":function(e,t,r,i,s,l,o,n){const a=function(e,t,r){const i=te(e,t),s=i?.filter((e=>e.format===r));return(s?.length?s:i)??[]}(e,t,i);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,r??"").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,r);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,`${r}`)),o=this._appendCustomLayerParameters(o),o}getUrlTemplate(e,t,r,i){if(!this.resourceInfo){const r=function(e,t,r,i){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,i),o=o.replaceAll(/\{TileMatrixSet\}/gi,r),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,i);if(r)return r}if("KVP"===this.serviceMode)return this.url+"?SERVICE=WMTS&VERSION="+this.version+"&REQUEST=GetTile&LAYER="+e+"&STYLE="+i+"&FORMAT="+r+"&TILEMATRIXSET="+t+"&TILEMATRIX={level}&TILEROW={row}&TILECOL={col}";if("RESTful"===this.serviceMode){let s="";return he[r.toLowerCase()]&&(s=he[r.toLowerCase()]),this.url+e+"/"+i+"/"+t+"/{level}/{row}/{col}"+s}return""}async _fetchService(e){let t;if(this.resourceInfo)"KVP"===this.resourceInfo.serviceMode&&(this.url+=this.url.includes("?")?"":"?"),t={ssl:!1,data:this.resourceInfo};else try{t=await this._getCapabilities(this.serviceMode,e),J(t.data)}catch{const r="KVP"===this.serviceMode?"RESTful":"KVP";try{t=await this._getCapabilities(r,e),J(t.data),this.serviceMode=r}catch(e){throw new a.A("wmtslayer:unsupported-service-data","Services does not support RESTful or KVP service modes.",{error:e})}}this.resourceInfo?t.data=function(e){return e.layers.forEach((e=>{e.tileMatrixSets?.forEach((e=>{const t=e.tileInfo;t&&96!==t.dpi&&(t.lods?.forEach((r=>{r.scale=96*r.scale/t.dpi,r.resolution=de(t.spatialReference?.wkid,r.scale*H/96,e.id)})),t.dpi=96)}))})),e}(t.data):t.data=function(e,t){e=e.replaceAll(/ows:/gi,"");const r=(new DOMParser).parseFromString(e,"text/xml").documentElement,i=new Map,s=new Map,l=G("Contents",r);if(!l)throw new a.A("wmtslayer:wmts-capabilities-xml-is-not-valid");const o=G("OperationsMetadata",r),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 h,m,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)?m=e.attributes[0].nodeValue:t&&!Y("AllowedValues","Value","KVP",t)||(h=e.attributes[0].nodeValue),!1)})),!f)if(m)f=m,y="RESTful";else if(h)f=h,y="KVP";else{const e=G("ServiceMetadataURL",r);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",r),x=X("ServiceIdentification>AccessConstraints",r),M=x&&/^none$/i.test(x)?null:x,v=z("Layer",l),S=z("TileMatrixSet",l),I=v.map((e=>{const t=X("Identifier",e);return i.set(t,e),ee(t,e,S,d,w)}));return{copyright:M,dimensionMap:s,layerMap:i,layers:I,serviceMode:y,tileUrl:f}}(t.data,{serviceMode:this.serviceMode,url:this.url}),t.data&&this.read(t.data,{origin:"service"})}async _getCapabilities(e,t){const r=this._getCapabilitiesUrl(e);return await(0,l.A)(r,{...t,responseType:"text"})}_getTileMatrixSetById(e){const t=this.findSublayerById(this.activeLayer.id),r=t?.tileMatrixSets?.find((t=>t.id===e));return r}_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 r=(0,m.An)(e),i={...r.query,...t},s=(0,m.x0)(i);return""===s?r.path:`${r.path}?${s}`}_getCapabilitiesUrl(e){this.url=(0,m.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`,r=new RegExp(e,"i");t=t.replace(r,""),t+=e;break}}return this._appendCustomParameters(t)}_getLowerCasedUrlParams(e){if(!e)return null;const t=(0,m.An)(e).query;if(!t)return null;const r={};return Object.keys(t).forEach((e=>{r[e.toLowerCase()]=t[e]})),r}_mergeParams(e,t){const r=this._getLowerCasedUrlParams(t);if(r){const t=Object.keys(r);t.length&&(e=e?(0,c.o8)(e):{},t.forEach((t=>{e.hasOwnProperty(t)||me.has(t)||(e[t]=r[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:N,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:P.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:x.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(N)})],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,r)=>{r.d(t,{m:()=>s});const i=[[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&&i.some((([t,r])=>e>=t&&e<=r))}},13043:(e,t,r)=>{function i(e,t){if(e&&t)for(const r of e.children)if(r.localName in t){const e=t[r.localName];if("function"==typeof e){const t=e(r);t&&i(r,t)}else i(r,e)}}function*s(e,t){for(const r of e.children)if(r.localName in t){const e=t[r.localName];"function"==typeof e?yield e(r):yield*s(r,e)}}r.d(t,{i:()=>s,p:()=>i})},65509:(e,t,r)=>{r.d(t,{A:()=>l});var i=r(49186),s=r(74887);class l{constructor(e,t=0,r=e.lods[e.lods.length-1].level){this.tileInfo=e,this.minLOD=t,this.maxLOD=r,e.lodAt(t)||(this.minLOD=e.lods[0].level),e.lodAt(r)||(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,r){const i=this.tileInfo?.lodAt(e);return!i||e<this.minLOD||e>this.maxLOD?"unavailable":i.cols&&i.rows?r>=i.cols[0]&&r<=i.cols[1]&&t>=i.rows[0]&&t<=i.rows[1]?"unknown":"unavailable":"unknown"}async fetchAvailability(e,t,r,l){await(0,s.NO)(l);const o=this.getAvailability(e,t,r);if("unavailable"===o)throw new i.A("tile-map:tile-unavailable","Tile is not available",{level:e,row:t,col:r});return o}async fetchAvailabilityUpsample(e,t,r,i,l){await(0,s.NO)(l),i.level=e,i.row=t,i.col=r;const o=this.tileInfo;return o.updateTileInfo(i),this.fetchAvailability(e,t,r,l).catch((e=>{if((0,s.zf)(e))throw e;if(o.upsampleTile(i))return this.fetchAvailabilityUpsample(i.level,i.row,i.col,i,l);throw e}))}}}}]);