UNPKG

@doegis/core

Version:

DOE GIS API

1 lines 89.1 kB
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8915],{13867:(e,t,i)=>{i.d(t,{Z:()=>r});var s=i(69801);class r{constructor(e,t){this._storage=new s.WJ,this._storage.maxSize=e,t&&this._storage.registerRemoveFunc("",t)}put(e,t,i){this._storage.put(e,t,i,1)}pop(e){return this._storage.pop(e)}get(e){return this._storage.get(e)}clear(){this._storage.clearAll()}destroy(){this._storage.destroy()}get maxSize(){return this._storage.maxSize}set maxSize(e){this._storage.maxSize=e}}},16306:(e,t,i)=>{i.d(t,{aX:()=>S});var s=i(68773),r=i(20102),n=i(92604),a=i(70586),o=i(38913),l=i(58901),c=i(73913),u=i(8744),h=i(40488),f=(i(66577),i(3172)),d=i(33955),p=i(11282),m=i(17452);async function y(e,t,i){const s="string"==typeof e?(0,m.mN)(e):e,r=t[0].spatialReference,n=(0,d.Ji)(t[0]),a={...i,query:{...s.query,f:"json",sr:r.wkid?r.wkid:JSON.stringify(r),geometries:JSON.stringify((l=t,{geometryType:(0,d.Ji)(l[0]),geometries:l.map((e=>e.toJSON()))}))}},{data:o}=await(0,f.default)(s.path+"/simplify",a);var l;return function(e,t,i){const s=(0,d.q9)(t);return e.map((e=>{const t=s.fromJSON(e);return t.spatialReference=i,t}))}(o.geometries,n,r)}const g=n.Z.getLogger("esri.geometry.support.normalizeUtils");function x(e){return"polygon"===e[0].type}function I(e){return"polyline"===e[0].type}function b(e,t,i){if(t){const t=function(e,t){if(!(e instanceof l.Z||e instanceof o.Z)){const e="straightLineDensify: the input geometry is neither polyline nor polygon";throw g.error(e),new r.Z(e)}const i=(0,c.x3)(e),s=[];for(const e of i){const i=[];s.push(i),i.push([e[0][0],e[0][1]]);for(let s=0;s<e.length-1;s++){const r=e[s][0],n=e[s][1],a=e[s+1][0],o=e[s+1][1],l=Math.sqrt((a-r)*(a-r)+(o-n)*(o-n)),c=(o-n)/l,u=(a-r)/l,h=l/t;if(h>1){for(let e=1;e<=h-1;e++){const s=e*t,a=u*s+r,o=c*s+n;i.push([a,o])}const e=(l+Math.floor(h-1)*t)/2,s=u*e+r,a=c*e+n;i.push([s,a])}i.push([a,o])}}return function(e){return"polygon"===e.type}(e)?new o.Z({rings:s,spatialReference:e.spatialReference}):new l.Z({paths:s,spatialReference:e.spatialReference})}(e,1e6);e=(0,h.Sx)(t,!0)}return i&&(e=(0,c.Sy)(e,i)),e}function w(e,t,i){if(Array.isArray(e)){const s=e[0];if(s>t){const i=(0,c.XZ)(s,t);e[0]=s+i*(-2*t)}else if(s<i){const t=(0,c.XZ)(s,i);e[0]=s+t*(-2*i)}}else{const s=e.x;if(s>t){const i=(0,c.XZ)(s,t);e=e.clone().offset(i*(-2*t),0)}else if(s<i){const t=(0,c.XZ)(s,i);e=e.clone().offset(t*(-2*i),0)}}return e}function _(e,t){let i=-1;for(let s=0;s<t.cutIndexes.length;s++){const r=t.cutIndexes[s],n=t.geometries[s],a=(0,c.x3)(n);for(let e=0;e<a.length;e++){const t=a[e];t.some((i=>{if(i[0]<180)return!0;{let i=0;for(let e=0;e<t.length;e++){const s=t[e][0];i=s>i?s:i}i=Number(i.toFixed(9));const s=-360*(0,c.XZ)(i,180);for(let i=0;i<t.length;i++){const t=n.getPoint(e,i);n.setPoint(e,i,t.clone().offset(s,0))}return!0}}))}if(r===i){if(x(e))for(const t of(0,c.x3)(n))e[r]=e[r].addRing(t);else if(I(e))for(const t of(0,c.x3)(n))e[r]=e[r].addPath(t)}else i=r,e[r]=n}return e}async function S(e,t,i){if(!Array.isArray(e))return S([e],t);t&&"string"!=typeof t&&g.warn("normalizeCentralMeridian()","The url object is deprecated, use the url string instead");const r="string"==typeof t?t:t?.url??s.Z.geometryServiceUrl;let n,m,x,I,R,v,C,T,k=0;const F=[],P=[];for(const t of e)if((0,a.Wi)(t))P.push(t);else if(n||(n=t.spatialReference,m=(0,u.C5)(n),x=n.isWebMercator,v=x?102100:4326,I=c.UZ[v].maxX,R=c.UZ[v].minX,C=c.UZ[v].plus180Line,T=c.UZ[v].minus180Line),m)if("mesh"===t.type)P.push(t);else if("point"===t.type)P.push(w(t.clone(),I,R));else if("multipoint"===t.type){const e=t.clone();e.points=e.points.map((e=>w(e,I,R))),P.push(e)}else if("extent"===t.type){const e=t.clone()._normalize(!1,!1,m);P.push(e.rings?new o.Z(e):e)}else if(t.extent){const e=t.extent,i=(0,c.XZ)(e.xmin,R)*(2*I);let s=0===i?t.clone():(0,c.Sy)(t.clone(),i);e.offset(i,0),e.intersects(C)&&e.xmax!==I?(k=e.xmax>k?e.xmax:k,s=b(s,x),F.push(s),P.push("cut")):e.intersects(T)&&e.xmin!==R?(k=e.xmax*(2*I)>k?e.xmax*(2*I):k,s=b(s,x,360),F.push(s),P.push("cut")):P.push(s)}else P.push(t.clone());else P.push(t);let M=(0,c.XZ)(k,I),O=-90;const D=M,B=new l.Z;for(;M>0;){const e=360*M-180;B.addPath([[e,O],[e,-1*O]]),O*=-1,M--}if(F.length>0&&D>0){const t=_(F,await async function(e,t,i,s){const r=(0,p.en)(e),n=t[0].spatialReference,a={...s,query:{...r.query,f:"json",sr:JSON.stringify(n),target:JSON.stringify({geometryType:(0,d.Ji)(t[0]),geometries:t}),cutter:JSON.stringify(i)}},o=await(0,f.default)(r.path+"/cut",a),{cutIndexes:l,geometries:c=[]}=o.data;return{cutIndexes:l,geometries:c.map((e=>{const t=(0,d.im)(e);return t.spatialReference=n,t}))}}(r,F,B,i)),s=[],n=[];for(let i=0;i<P.length;i++){const r=P[i];if("cut"!==r)n.push(r);else{const r=t.shift(),o=e[i];(0,a.pC)(o)&&"polygon"===o.type&&o.rings&&o.rings.length>1&&r.rings.length>=o.rings.length?(s.push(r),n.push("simplify")):n.push(x?(0,h.$)(r):r)}}if(!s.length)return n;const o=await y(r,s,i),l=[];for(let e=0;e<n.length;e++){const t=n[e];"simplify"!==t?l.push(t):l.push(x?(0,h.$)(o.shift()):o.shift())}return l}const Z=[];for(let e=0;e<P.length;e++){const t=P[e];if("cut"!==t)Z.push(t);else{const e=F.shift();Z.push(!0===x?(0,h.$)(e):e)}}return Z}},73913:(e,t,i)=>{i.d(t,{Sy:()=>l,UZ:()=>a,XZ:()=>o,x3:()=>c});var s=i(58901),r=i(82971),n=i(33955);const a={102100:{maxX:20037508.342788905,minX:-20037508.342788905,plus180Line:new s.Z({paths:[[[20037508.342788905,-20037508.342788905],[20037508.342788905,20037508.342788905]]],spatialReference:r.Z.WebMercator}),minus180Line:new s.Z({paths:[[[-20037508.342788905,-20037508.342788905],[-20037508.342788905,20037508.342788905]]],spatialReference:r.Z.WebMercator})},4326:{maxX:180,minX:-180,plus180Line:new s.Z({paths:[[[180,-180],[180,180]]],spatialReference:r.Z.WGS84}),minus180Line:new s.Z({paths:[[[-180,-180],[-180,180]]],spatialReference:r.Z.WGS84})}};function o(e,t){return Math.ceil((e-t)/(2*t))}function l(e,t){const i=c(e);for(const e of i)for(const i of e)i[0]+=t;return e}function c(e){return(0,n.oU)(e)?e.rings:e.paths}},92045:(e,t,i)=>{i.r(t),i.d(t,{default:()=>lt});var s=i(43697),r=i(51773),n=i(30030),a=i(20102),o=i(92604),l=i(70586),c=i(16453),u=i(95330),h=i(17445),f=i(5600),d=i(75215),p=(i(67676),i(36030)),m=i(71715),y=i(52011),g=i(87085),x=i(17287),I=i(71612),b=i(17017),w=(i(66577),i(3172)),_=i(8744),S=i(66677),R=i(21506),v=i(35956),C=i(29876),T=i(40297),k=i(88281),F=i(11145),P=i(96674),M=i(609),O=i(39450),D=i(36679),B=i(99815),Z=i(73506),z=i(94139);const J=new Map,N=new class{constructor(e=15e3,t=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=e,this._interval=Math.min(e,t)}decreaseRefCount(e,t){const i=e+"/"+t,s=this._cachedBlocks;if(s.has(i)){const e=s.get(i);return e.refCount--,e.refCount<=0&&(s.delete(i),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const i=e+"/"+t,s=this._cachedBlocks;if(s.has(i)){const e=s.get(i);return e.ts=Date.now(),e.refCount++,s.delete(i),s.set(i,e),e.block}return null}putBlock(e,t,i,s){const r=this._cachedBlocks,n=e+"/"+t;if(r.has(n)){const e=r.get(n);e.ts=Date.now(),e.refCount++}else r.set(n,{block:i,ts:Date.now(),refCount:1,controller:s});this._trim(),this._updateTimer()}deleteBlock(e,t){const i=this._cachedBlocks,s=e+"/"+t;i.has(s)&&i.delete(s)}updateMaxSize(e){this._size=e,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const e=this._cachedBlocks;this._timer=setInterval((()=>{const t=Array.from(e),i=Date.now();for(let s=0;s<t.length&&t[s][1].ts<=i-this._duration;s++)e.delete(t[s][0]);0===e.size&&this._clearTimer()}),this._interval)}_trim(){const e=this._cachedBlocks;if(-1===this._size||this._size>=e.size)return;const t=Array.from(e);for(let i=0;i<t.length-this._size;i++)e.delete(t[i][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}};function W(e,t){return null==t?e:`${e}?sliceId=${t}`}function E(e,t,i){const s=J.get(e);if(!s)return null==t?N.decreaseRefCount(e,i):0;if(null==t||null==s[t])return N.decreaseRefCount(e,i);const r=s[t]?.cache,n=r?.get(i);if(r&&n){if(n.refCount--,0===n.refCount){r.delete(i);for(let e=0;e<s.length;e++)s[e]?.cache.delete(i);n.controller&&n.controller.abort()}return n.refCount}return 0}function H(e,t,i){const s=J.get(e);if(!s)return null==t?N.getBlock(e,i):null;if(null==t||null==s[t]){for(let e=0;e<s.length;e++){const t=s[e]?.cache.get(i);if(t)return t.refCount++,t.block}return N.getBlock(e,i)}const r=s[t]?.cache.get(i);if(r)return r.refCount++,r.block;for(let e=0;e<s.length;e++){if(e===t||!s[e])continue;const r=s[e]?.cache,n=r?.get(i);if(r&&n)return n.refCount++,r.set(i,n),n.block}return null}function A(e,t,i,s,r=null){const n=J.get(e);if(!n)return void(null==t&&N.putBlock(e,i,s,r));if(null==t||null==n[t])return void N.putBlock(e,i,s,r);const a={refCount:1,block:s,isResolved:!1,isRejected:!1,controller:r};s.then((()=>a.isResolved=!0)).catch((()=>a.isRejected=!0)),n[t]?.cache.set(i,a)}function L(e,t,i){const s=J.get(e);s?null!=t&&null!=s[t]?s[t]?.cache.delete(i):N.deleteBlock(e,i):null==t&&N.deleteBlock(e,i)}var q=i(81578),j=i(75993),G=i(55914),U=i(80676),$=i(6570);let V=class extends((0,M.v)(P.wq)){constructor(){super(...arguments),this.rasterJobHandler=null,this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}async init(){const e=(0,Z.zD)();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e&&e.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:F.Z.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=(0,Z.ut)(e.spatialReference);return(0,l.pC)(t)&&e.extent.width>=t/2}set url(e){this._set("url",(0,S.Nm)(e,o.Z.getLogger(this.declaredClass)))}async open(e){throw new a.Z("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,s={}){const r=s.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,r);return this.fetchPixels(n,r.size[0],r.size[1],s)}async identify(e,t={}){e=(0,d.TJ)(z.Z,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:s}=t,{rasterInfo:r}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:a}=r;let{transposedVariableName:o}=t;const c=(0,l.pC)(a)&&n&&(null!=s||(0,B.WU)(i));c&&!o&&(o=(0,l.pC)(i)&&i.length>0?i[0].variableName??void 0:a.variables[0].name,t={...t,transposedVariableName:o}),t=this._getRequestOptionsWithSliceId(t);const{spatialReference:u,extent:h}=r,{datumTransformation:f}=t;let p=(0,Z.nF)(e,u,f);if(!h.intersects(p))return{location:p,value:null};if((0,l.pC)(r.transform)){const e=r.transform.inverseTransform(p);if(!r.nativeExtent.intersects(e))return{location:e,value:null};p=e}let m=0;const y=(0,l.pC)(o)&&(0,l.pC)(a)&&r.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(y)return e.identify(p,t);const{pixelSize:i}=r,s=3,n=i.x*s/2,a=i.y*s/2,o=new $.Z({xmin:p.x-n,xmax:p.x+n,ymin:p.y-a,ymax:p.y+a,spatialReference:u}),c={interpolation:"nearest"},{pixelBlock:h}=await e.fetchPixels(o,s,s,c),{pixelBlock:f}=await this.fetchPixels(o,s,s,c);if((0,l.Wi)(h))return{location:p,value:null};const d=Math.floor(s*s*.5),m=!h.mask||h.mask[d]?h.pixels.map((e=>e[d])):null;let g;return(0,l.pC)(f)&&(g=!f.mask||f.mask[d]?f.pixels.map((e=>e[d])):void 0),{location:p,value:m,processedValue:g,pyramidLevel:0}}if(!y)if(t.srcResolution)m=(0,Z.kr)(t.srcResolution,r,this.ioConfig.sampling).pyramidLevel;else if(m=await this.computeBestPyramidLevelForLocation(e,t),null==m)return{location:p,value:null};const g=this.identifyPixelLocation(p,m,null,y);if(null===g)return{location:p,value:null};const{row:x,col:I,rowOffset:b,colOffset:w,blockWidth:_}=g,S=o??(0,l.Wg)(t.sliceId),R=W(this.url,S),v=`${m}/${x}/${I}`;let C=H(R,null,v);(0,l.Wi)(C)&&(C=this.fetchRawTile(m,x,I,t),A(R,null,v,C));const T=await C;if((0,l.Wi)(T)||!T.pixels?.length)return{location:p,value:null};const k=b*_+w;return this._processIdentifyResult(T,{srcLocation:p,position:k,pyramidLevel:m,useTransposedTile:!!y,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,s={}){if(e=(0,Z.kZ)(e),(s=this._getRequestOptionsWithSliceId(s)).requestRawData)return this._fetchPixels(e,t,i,s);const r=(0,Z.ut)(e.spatialReference),n=(0,Z.Hq)(e);if((0,l.Wi)(r)||0===n||1===n&&this._isGlobalWrappableSource)return this._fetchPixels(e,t,i,s);if(n>=3)return{extent:e,pixelBlock:null};const a=[],{xmin:o,xmax:c}=e,u=Math.round(r/(c-o)*t),h=u-Math.round((r/2-o)/(c-o)*t);let f=0;const d=[];for(let l=0;l<=n;l++){const p=new $.Z({xmin:0===l?o:-r/2,xmax:l===n?c-r*l:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),m=0===l?u-h:l===n?t-f:u;f+=m,d.push(m);const y=s.disableWrapAround&&l>0?null:this._fetchPixels(p,m,i,s);a.push(y)}const p=(await Promise.all(a)).map((e=>e?.pixelBlock));let m=null;const y={width:t,height:i};return m=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:d},s)).pixelBlock:(0,G.us)(p,y,{blockWidths:d}),{extent:e,srcExtent:(0,Z.tB)(e,this.rasterInfo.spatialReference,s.datumTransformation),pixelBlock:m}}async fetchRawPixels(e,t,i,s={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const r=await this._fetchRawTiles(e,t,i,s),{nativeExtent:n,nativePixelSize:a,storageInfo:o}=this.rasterInfo,c=2**e,u=a.x*c,h=a.y*c,f=new $.Z({xmin:n.xmin+u*t.x,xmax:n.xmin+u*(t.x+i.width-1),ymin:n.ymax-h*(t.y+i.height-1),ymax:n.ymax-h*t.y,spatialReference:n.spatialReference});if(!r)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:d,mosaicSize:p}=r;if(1===d.length&&(0,l.pC)(d[0])&&d[0].width===i.width&&d[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:r.pixelBlocks[0]};const m=e>0?o.pyramidBlockWidth:o.blockWidth,y=e>0?o.pyramidBlockHeight:o.blockHeight,g={x:t.x%m,y:t.y%y};let x;return x=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:p,destDimension:i,clipOffset:g,clipSize:i,coefs:null,sampleSpacing:null,interpolation:s.interpolation,alignmentInfo:null,blockWidths:null},s)).pixelBlock:(0,G.us)(d,p,{clipOffset:g,clipSize:i}),{extent:f,srcExtent:f,pixelBlock:x}}fetchRawTile(e,t,i,s){throw new a.Z("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return(0,Z.tB)(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?(0,j.J)(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,t,i=0){const{customFetchParameters:s}=this.ioConfig,{range:r,query:n,headers:a}=t;i=i??t.retryCount??this.ioConfig.retryCount;const o=r?{Range:`bytes=${r.from}-${r.to}`}:null;try{return await(0,w.default)(e,{...t,query:{...n,...s},headers:{...a,...o}})}catch(s){if(i>0)return i--,this.request(e,t,i);throw s}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return(0,l.Wi)(t)||(0,l.Wi)(e)||0===e.length?null:(0,B.gk)(e,t)}getTileExtentFromTileInfo(e,t,i,s){const r=(0,l.s3)(s.lodAt(e));return this.getTileExtent({x:r.resolution,y:r.resolution},t,i,s.origin,s.spatialReference,s.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:s}=this.rasterInfo;if(!e.tileInfo){const r=[],n=e.maximumPyramidLevel||0;let a=Math.max(s.x,s.y),o=1/.0254*96*a;for(let e=0;e<=n;e++)r.push(new O.Z({level:n-e,resolution:a,scale:o})),a*=2,o*=2;const l=new z.Z({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new F.Z({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,s){const{width:r,height:n,nativeExtent:a,pixelSize:o,spatialReference:l}=e,c=new z.Z({x:a.xmin,y:a.ymax,spatialReference:l});null==s&&(s=Math.max(0,Math.round(Math.log(Math.max(r,n))/Math.LN2-8)));const u=this.computeBlockBoundary(a,512,512,{x:a.xmin,y:a.ymax},[o],s);e.storageInfo=new D.Z({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:s,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,s,r,n=0,a=2){if(1===r.length&&n>0){r=[...r];let{x:e,y:t}=r[0];for(let i=0;i<n;i++)e*=a,t*=a,r.push({x:e,y:t})}const o=[],{x:l,y:c}=s;for(let s=0;s<r.length;s++){const{x:n,y:a}=r[s];o.push({minCol:Math.floor((e.xmin-l+.1*n)/t/n),maxCol:Math.floor((e.xmax-l-.1*n)/t/n),minRow:Math.floor((c-e.ymax+.1*a)/i/a),maxRow:Math.floor((c-e.ymin-.1*a)/i/a)})}return o}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:s}=this.rasterInfo.storageInfo;if(0===e)return t;if((0,l.pC)(i)&&i.length)return i[e-1];const r=s**e;return{x:t.x*r,y:t.y*r}}identifyPixelLocation(e,t,i,s){const{spatialReference:r,nativeExtent:n,storageInfo:a}=this.rasterInfo,{maximumPyramidLevel:o,origin:c,transposeInfo:u}=a,h=s&&(0,l.pC)(u)?u.tileSize[0]:a.blockWidth,f=s&&(0,l.pC)(u)?u.tileSize[1]:a.blockHeight,d=(0,Z.nF)(e,r,i);if(!n.intersects(d))return null;if(t<0||t>o)return null;const p=this.getPyramidPixelSize(t),{x:m,y}=p,g=(c.y-d.y)/y/f,x=(d.x-c.x)/m/h,I=Math.min(f-1,Math.floor((g-Math.floor(g))*f)),b=Math.min(h-1,Math.floor((x-Math.floor(x))*h));return{pyramidLevel:t,row:Math.floor(g),col:Math.floor(x),rowOffset:I,colOffset:b,blockWidth:h,srcLocation:d}}getTileExtent(e,t,i,s,r,n){const[a,o]=n,l=s.x+i*a*e.x,c=l+a*e.x,u=s.y-t*o*e.y,h=u-o*e.y;return new $.Z({xmin:l,xmax:c,ymin:h,ymax:u,spatialReference:r})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const s=this.rasterInfo.storageInfo.blockBoundary[e];return!s||s.maxRow<t||s.maxCol<i||s.minRow>t||s.minCol>i}async _fetchPixels(e,t,i,s={}){let r=(0,Z.Hq)(e);if(r>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,s),{pyramidLevel:a,pyramidResolution:o,srcResolution:c,srcExtent:u,srcWidth:h,srcHeight:f}=n;if(0===h||0===f)return{extent:e,srcExtent:u,pixelBlock:null};const d=(0,l.Wg)(this.rasterInfo.transform),p="gcs-shift"===d?.type,m=(0,l.pC)((0,Z.ut)(e.spatialReference));!p&&m||(r=(0,Z.Hq)(n.srcExtent,p));const y=this.rasterInfo.storageInfo,g={x:Math.floor((u.xmin-y.origin.x)/o.x+.1),y:Math.floor((y.origin.y-u.ymax)/o.y+.1)},x=await this._fetchRawTiles(a,g,{width:h,height:f,wrapCount:r},s);if(!x)return{extent:e,srcExtent:u,pixelBlock:null};const I=a>0?y.pyramidBlockWidth:y.blockWidth,b=a>0?y.pyramidBlockHeight:y.blockHeight,w=I===h&&b===f&&g.x%I==0&&g.y%b==0,_=new z.Z({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),S=!e.spatialReference.equals(this.rasterInfo.spatialReference),{datumTransformation:R}=s;if(!S&&w&&1===x.pixelBlocks.length&&I===t&&b===i&&c.x===_.x&&c.y===_.y)return{extent:e,srcExtent:u,pixelBlock:x.pixelBlocks[0]};const v=m&&(0,l.pC)((0,Z.ut)(u.spatialReference)),C=s.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");C&&!this.rasterJobHandler&&await(0,Z.zD)();const T=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:_.toJSON(),datumTransformation:R,rasterTransform:d,hasWrapAround:r>0||v,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:C},s):(0,Z.Qp)({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:_,datumTransformation:R,rasterTransform:d,hasWrapAround:r>0||v,isAdaptive:!1,includeGCSGrid:C});let k;const F=!s.requestRawData,P={rows:T.spacing[0],cols:T.spacing[1]},M=(0,l.Wg)(this._getRasterTileAlignmentInfo(a,x.extent.xmin)),{pixelBlocks:O,mosaicSize:D,isPartiallyFilled:B}=x;let J=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:O,srcMosaicSize:D,destDimension:F?{width:t,height:i}:null,coefs:F?T.coefficients:null,sampleSpacing:F?P:null,projectDirections:C,gcsGrid:C?T.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:s.interpolation,alignmentInfo:M,blockWidths:null},s);({pixelBlock:k,localNorthDirections:J}=e)}else{const e=(0,G.us)(O,D,{alignmentInfo:M});k=F?(0,G.Uk)(e,{width:t,height:i},T.coefficients,P,s.interpolation):e,C&&T.gcsGrid&&(J=(0,G.Qh)({width:t,height:i},T.gcsGrid),k=(0,U.xQ)(k,this.rasterInfo.dataType,J))}return s.requestRawData||C?{srcExtent:u,pixelBlock:k,transformGrid:T,localNorthDirections:J,extent:e,isPartiallyFilled:B}:{srcExtent:u,extent:e,pixelBlock:k}}async _fetchRawTiles(e,t,i,s){const{origin:r,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:a,blockHeight:o}=this.getBlockWidthHeight(e);let{x:c,y:u}=t,{width:h,height:f,wrapCount:d}=i;const p=this._getRasterTileAlignmentInfo(e,0);s.buffer&&(c-=s.buffer.cols,u-=s.buffer.rows,h+=2*s.buffer.cols,f+=2*s.buffer.rows);let m=0,y=0,g=0;d&&(0,l.pC)(p)&&(({worldColumnCountFromOrigin:y,originColumnOffset:g,rightPadding:m}=p),y*p.blockWidth-m>=c+h&&(m=0));const x=Math.floor(c/a),I=Math.floor(u/o),b=Math.floor((c+h+m-1)/a),w=Math.floor((u+f+m-1)/o),_=n[e];if(!_)return null;const{minRow:S,minCol:R,maxCol:v,maxRow:C}=_;if(0===d&&(w<S||b<R||I>C||x>v))return null;const T=new Array;let k=!1;const F=null==this.ioConfig.allowPartialFill?s.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=I;t<=w;t++)for(let i=x;i<=b;i++){let r=i;if(!s.disableWrapAround&&d&&(0,l.pC)(p)&&y<=i&&(r=i-y-g),t>=S&&r>=R&&C>=t&&v>=r){const i=this._fetchRawTile(e,t,r,s);F?T.push(new Promise((e=>{i.then((t=>e(t))).catch((()=>{k=!0,e(null)}))}))):T.push(i)}else T.push(Promise.resolve(null))}if(0===T.length)return null;const P=await Promise.all(T),M={height:(w-I+1)*o,width:(b-x+1)*a},{spatialReference:O}=this.rasterInfo,D=this.getPyramidPixelSize(e),{x:B,y:Z}=D;return{extent:new $.Z({xmin:r.x+x*a*B,xmax:r.x+(b+1)*a*B,ymin:r.y-(w+1)*o*Z,ymax:r.y-I*o*Z,spatialReference:O}),pixelBlocks:P,mosaicSize:M,isPartiallyFilled:k}}_fetchRawTile(e,t,i,s){const r=this.rasterInfo.storageInfo.blockBoundary[e];if(!r)return Promise.resolve(null);const{minRow:n,minCol:a,maxCol:o,maxRow:c}=r;if(t<n||i<a||t>c||i>o)return Promise.resolve(null);const h=W(this.url,s.sliceId),f=`${e}/${t}/${i}`;let d=H(h,s.registryId,f);if((0,l.Wi)(d)){const r=new AbortController;d=this.fetchRawTile(e,t,i,{...s,signal:r.signal}),A(h,s.registryId,f,d,r),d.catch((()=>L(h,s.registryId,f)))}return s.signal&&(0,u.fu)(s,(()=>{E(h,s.registryId,f)})),d}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if((2!==t||"vector-magdir"!==i)&&"vector-uv"!==i||2!==e?.length||!e[0]?.length)return null;const s=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[r,n]=e,a=[],o=[];for(let e=0;e<s;e++){const[t,i]=(0,U.Tg)([r[e],n[e]]);a.push(t),o.push(i)}return[a,o]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlighmentInfo&&(this._rasterTileAlighmentInfo=(0,Z.P_)(this.rasterInfo)),(0,l.Wi)(this._rasterTileAlighmentInfo.pyramidsInfo)?null:{startX:t,halfWorldWidth:this._rasterTileAlighmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlighmentInfo.hasGCSSShiftTransform,...this._rasterTileAlighmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,s={}){const r={datumTransformation:s.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0};s.srcResolution&&(r.srcResolution=s.srcResolution,this._updateSourceDataInfo(e,r));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:a,srcHeight:o,pyramidLevel:l}=r,c=a/t,u=o/i,h=l<n&&c*u>=16,f=l===n&&this._requireTooManySrcTiles(a,o,t,i);if(h||f||0===a||0===o){const a=new z.Z({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let o=(0,Z.VO)(a,this.rasterInfo.spatialReference,e,r.datumTransformation);const f=!o||s.srcResolution&&o.x+o.y<s.srcResolution.x+s.srcResolution.y;if(h&&s.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,u))/Math.LN2)-1;if(n-l+3>=e){const t=2**e;o={x:s.srcResolution.x*t,y:s.srcResolution.y*t}}}o&&(r.srcResolution=o,this._updateSourceDataInfo(e,r))}return this._requireTooManySrcTiles(r.srcWidth,r.srcHeight,t,i)&&(r.srcWidth=0,r.srcHeight=0),r}_requireTooManySrcTiles(e,t,i,s){const{tileInfo:r}=this.rasterInfo.storageInfo;return Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1])>=256||e/i>8||t/s>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const i=this.rasterInfo.spatialReference,{srcResolution:s,datumTransformation:r}=t,{pyramidLevel:n,pyramidResolution:a,excessiveReading:o}=(0,Z.kr)(s,this.rasterInfo,this.ioConfig.sampling);if(o)return;let c=t.srcExtent||(0,Z.tB)(e,i,r);if(null==c)return;const u=(0,l.Wg)(this.rasterInfo.transform);u&&(c=u.inverseTransform(c)),t.srcExtent=c;const h=Math.ceil((c.xmax-c.xmin)/a.x-.1),f=Math.ceil((c.ymax-c.ymin)/a.y-.1);t.pyramidLevel=n,t.pyramidResolution=a,t.srcWidth=h,t.srcHeight=f}_getRequestOptionsWithSliceId(e){return(0,l.pC)(this.rasterInfo.multidimensionalInfo)&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:s,pyramidLevel:r,useTransposedTile:n}=t,a=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[s])return{location:i,value:null};const{multidimensionalInfo:o}=this.rasterInfo;if((0,l.Wi)(o)||!n){const t=e.pixels.map((e=>e[s])),n={location:i,value:t,pyramidLevel:r},a=this._computeMagDirValues(t.map((e=>[e])));return a?.length&&(n.magdirValue=a.map((e=>e[0]))),n}let c=e.pixels.map((e=>e.slice(s*a,s*a+a))),u=this._computeMagDirValues(c);const{requestSomeSlices:h,identifyOptions:f}=t;let d=(0,B.MO)(o,f.transposedVariableName);if(h){const e=(0,B.Ur)(d,(0,l.Wg)(f.multidimensionalDefinition),(0,l.Wg)(f.timeExtent));c=c.map((t=>e.map((e=>t[e])))),u=u?.map((t=>e.map((e=>t[e])))),d=e.map((e=>d[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,m={pixels:c,pixelType:e.pixelType};let y;return(0,l.pC)(p)&&((0,q.A)(m,p),y=m.mask),{location:i,value:null,dataSeries:d.map(((e,t)=>{const i={value:0===y?.[t]?null:c.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new v.Z({...e,isSlice:!0})))};return u?.length&&(i.magdirValue=[u[0][t],u[1][t]]),i})),pyramidLevel:r}}};(0,s._)([(0,f.Cb)()],V.prototype,"_rasterTileAlighmentInfo",void 0),(0,s._)([(0,f.Cb)({readOnly:!0})],V.prototype,"_isGlobalWrappableSource",null),(0,s._)([(0,f.Cb)(R.HQ)],V.prototype,"url",null),(0,s._)([(0,f.Cb)({type:String,json:{write:!0}})],V.prototype,"datasetName",void 0),(0,s._)([(0,f.Cb)({type:String,json:{write:!0}})],V.prototype,"datasetFormat",void 0),(0,s._)([(0,f.Cb)()],V.prototype,"hasUniqueSourceStorageInfo",void 0),(0,s._)([(0,f.Cb)()],V.prototype,"rasterInfo",void 0),(0,s._)([(0,f.Cb)()],V.prototype,"ioConfig",void 0),(0,s._)([(0,f.Cb)()],V.prototype,"sourceJSON",void 0),V=(0,s._)([(0,y.j)("esri.layers.support.rasterDatasets.BaseRaster")],V);const X=V;let Y=class extends X{constructor(){super(...arguments),this.datasetFormat="Function",this.tileType="Raster",this.rasterFunction=null}async open(e){await this.init();const{rasterFunction:t}=this;this.primaryRasters?.rasters?.length?t.sourceRasters=this.primaryRasters.rasters:this.primaryRasters=t.getPrimaryRasters();const{rasters:i,rasterIds:s}=this.primaryRasters,r=i.map((t=>t.rasterInfo?void 0:t.open(e)));await Promise.all(r);const n=i.map((({rasterInfo:e})=>e)),o=t.bind({rasterInfos:n,rasterIds:s});if(!o.success||0===n.length)throw new a.Z("raster-function:open",`cannot bind the function: ${o.error??""}`);await this.syncJobHandler();const l=n[0];this.hasUniqueSourceStorageInfo=1===n.length||n.slice(1).every((e=>this._hasSameStorageInfo(e,l))),this.set("sourceJSON",i[0].sourceJSON),this.set("rasterInfo",t.rasterInfo)}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async fetchPixels(e,t,i,s={}){const{rasters:r,rasterIds:n}=this.primaryRasters,a=r.map((r=>r.fetchPixels(e,t,i,s))),o=await Promise.all(a),c=o.map((e=>e.pixelBlock));if(s.skipRasterFunction||c.every((e=>(0,l.Wi)(e))))return o[0];const u=o.find((e=>(0,l.pC)(e.pixelBlock)))?.extent??e,h=this.rasterJobHandler?await this.rasterJobHandler.process({extent:u,primaryPixelBlocks:c,primaryRasterIds:n}):this.rasterFunction.process({extent:u,primaryPixelBlocks:c,primaryRasterIds:n});return{...o[0],pixelBlock:h}}_hasSameStorageInfo(e,t){const{storageInfo:i,pixelSize:s,spatialReference:r,extent:n}=e,{storageInfo:a,pixelSize:o,spatialReference:l,extent:c}=t;return s.x===o.x&&s.y===o.y&&r.equals(l)&&n.equals(c)&&i.blockHeight===a.blockHeight&&i.blockWidth===a.blockWidth&&i.maximumPyramidLevel===a.maximumPyramidLevel}};(0,s._)([(0,f.Cb)({type:String,json:{write:!0}})],Y.prototype,"datasetFormat",void 0),(0,s._)([(0,f.Cb)()],Y.prototype,"tileType",void 0),(0,s._)([(0,f.Cb)()],Y.prototype,"rasterFunction",void 0),(0,s._)([(0,f.Cb)()],Y.prototype,"primaryRasters",void 0),Y=(0,s._)([(0,y.j)("esri.layers.support.rasterDatasets.FunctionRaster")],Y);const K=Y;var Q=i(98722),ee=i(67058),te=i(72758),ie=i(23808),se=i(82971);const re=o.Z.getLogger("esri.layers.mixins.ImageryTileMixin"),ne=e=>{let t=class extends e{constructor(...e){super(...e),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterFunction=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===e[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}get tileInfo(){return this.rasterInfo?.storageInfo.tileInfo}set url(e){this._set("url",(0,S.Nm)(e,re))}set renderer(e){this._set("renderer",e),this.updateRenderer()}async convertVectorFieldData(e,t){if((0,l.Wi)(e)||!this.rasterInfo)return null;const i=this._rasterJobHandler.instance,s=this.rasterInfo.dataType;return i?i.convertVectorFieldData({pixelBlock:e,dataType:s},t):(0,U.KC)(e,s)}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):(0,ie.GE)(e.meshType,e.simulationSettings,e.flowData,(0,l.pC)(t.signal)?t.signal:(new AbortController).signal)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.rasterInfo??{};if((0,l.Wi)(t))return e;let i=e.multidimensionalDefinition||this.multidimensionalDefinition;!(0,l.Wi)(i)&&i.length||(i=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const s=e.timeExtent||this.timeExtent;if((0,l.pC)(i)&&(0,l.pC)(s)&&((0,l.pC)(s.start)||(0,l.pC)(s.end))){i=i.map((e=>e.clone()));const r=t.variables.find((({name:e})=>e===i[0].variableName))?.dimensions?.find((({name:e})=>"StdTime"===e)),n=i.find((({dimensionName:e})=>"StdTime"===e));if(!r||!n)return{...e,multidimensionalDefinition:null};const{start:a,end:o}=s,c=(0,l.Wi)(a)?null:a.getTime(),u=(0,l.Wi)(o)?null:o.getTime(),h=c??u,f=u??c;if((0,l.pC)(r.values)){const e=r.values.filter((e=>{if(Array.isArray(e)){if(h===f)return e[0]<=h&&e[1]>=h;const t=e[0]<=h&&e[1]>h||e[0]<f&&e[1]>=f,i=e[0]>=h&&e[1]<=f||e[0]<h&&e[1]>f;return t||i}return h===f?e===h:e>=h&&e<=f}));if(e.length){const t=e.sort(((e,t)=>h===f?(e[0]??e)-(t[0]??t):Math.abs((e[1]??e)-f)-Math.abs((t[1]??t)-f)))[0];n.values=[t]}else i=null}else if(r.hasRegularIntervals&&r.extent){const[e,t]=r.extent;h>t||f<e?i=null:n.values=h===f?[h]:[Math.max(e,h),Math.min(t,f)]}}return(0,l.pC)(i)&&(0,B.nb)(i,this.multidimensionalSubset)?{...e,multidimensionalDefinition:null}:{...e,multidimensionalDefinition:i}}async updateRasterFunction(){if("imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const e=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&e&&this._set("rasterFunction",T.Z.fromJSON(e)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let e,t=this.raster,i=!1;"Function"===t.datasetFormat?(e=t.primaryRasters.rasters,t=e[0],i=!0):e=[t];const{rasterFunction:s}=this;if(s){const i={raster:t};e.length>1&&e.forEach((e=>i[e.url]=e));const r=(0,Q.Ue)(s.rasterFunctionDefinition??s.toJSON(),i),n=new K({rasterFunction:r});n.rasterJobHandler=this._rasterJobHandler.instance,await n.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=n}else this.raster=t,this._cachedRasterFunctionJson=null;if(this._cachedRendererJson=null,!i&&!s)return;const{bandIds:r}=this,{bandCount:n}=this.raster.rasterInfo,a=r?.length?r.some((e=>e>=n)):n>=3;r&&(a||"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:e,symbolizer:t}=this;if(!e||!t)return;const{rasterInfo:i}=this.raster,s=(0,B.WY)(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name,r=(0,ee.ol)({...this.renderer.toJSON(),variableName:s});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(r))return;const n=this._rasterJobHandler.instance;n&&(t.rasterInfo=(0,ee.FI)(i,s),t.rendererJSON=r,t.bind(),await n.updateSymbolizer(t),this._cachedRendererJson=r)}async applyRenderer(e,t){const i=e&&e.pixelBlock;if(!((0,l.pC)(i)&&i.pixels&&i.pixels.length>0))return null;let s;await this.updateRenderer();const r=this._rasterJobHandler.instance,n=this.bandIds??[];return s=r?await r.symbolize({...e,simpleStretchParams:t,bandIds:n}):this.symbolizer.symbolize({...e,simpleStretchParams:t,bandIds:n}),s}getTileUrl(e,t,i){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${i}`:""}getCompatibleTileInfo(e,t,i=!1){if(!this.loaded||(0,l.Wi)(t))return null;if(i&&e.equals(this.spatialReference))return this.tileInfo;const s=(0,_.C5)(e);return F.Z.create({size:256,spatialReference:e,origin:s?{x:s.origin[0],y:s.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,t,s,r={}){if(i(this),r.requestAsImageElement){const i=this.getTileUrl(e,t,s);return(0,w.default)(i,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:r.signal}).then((e=>e.data))}const{rasterInfo:n}=this;if((0,l.pC)(n.multidimensionalInfo)&&(r=this.normalizeRasterFetchOptions(r),(0,l.Wi)(r.multidimensionalDefinition))){const i=r.tileInfo||n.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(e,t,s,i),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer.type&&(r={...r,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,t,s,r)}async fetchPixels(e,t,i,s={}){return(0,l.pC)(this.rasterInfo.multidimensionalInfo)&&(s=this.normalizeRasterFetchOptions(s),(0,l.Wi)(s.multidimensionalDefinition))?{extent:e,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),this.raster.fetchPixels(e,t,i,s))}async identify(e,t={}){const{raster:i,rasterInfo:s}=this;if((0,l.pC)(s.multidimensionalInfo)&&(!s.hasMultidimensionalTranspose||!((0,B.WU)(t.multidimensionalDefinition)||t.transposedVariableName||t.timeExtent))&&(t=this.normalizeRasterFetchOptions(t),(0,l.Wi)(t.multidimensionalDefinition)))return{location:e,value:null};const r=this.multidimensionalSubset?.areaOfInterest;if(r&&!r.contains(e))throw new a.Z("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return i.identify(e,t)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const e=this.rasterInfo?.multidimensionalInfo;if((0,l.Wi)(e)||"standard-time"!==this.rasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,i=t?.[0]?.variableName;return e.variables.some((e=>e.name===i&&(!t?.[0].dimensionName||e.dimensions.some((e=>"StdTime"===e.name)))))}getStandardTimeValue(e){return new Date(24*(e-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(e){const t=e??this.rasterInfo?.multidimensionalInfo;return(0,B.jj)(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=(0,B.Tj)(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new k.Z;return this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{i(this),this._rasterJobHandler.instance=e,this.raster.rasterJobHandler=e,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){i(this);const{raster:e}=this,t=(0,ee.In)(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){i(this);const{rasterInfo:t}=this.raster;!this.bandIds&&t.bandCount>1&&(this.bandIds=(0,ee.YD)(t));const s=(0,B.WY)(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name;if(!this.renderer||"override"===e){const e=(0,ee.Ob)(t,{bandIds:this.bandIds,variableName:s});"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===e.type&&((t.statistics?.[0].max??0)>1e24||(t.statistics?.[0].min??0)<-1e24)&&(e.dynamicRangeAdjustment=!0,e.statistics=null,"none"===e.stretchType&&(e.stretchType="min-max")),this.renderer=e}const r=(0,ee.ol)({...this.renderer.toJSON(),variableName:s}),n=(0,ee.FI)(t,s);this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=n):this.symbolizer=new te.Z({rendererJSON:r,rasterInfo:n});const a=this.symbolizer.bind();if(a.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if((0,l.pC)(e))if("raster-colormap"!==t.type)this._configDefaultRenderer("override");else{const e=(0,ee.Ob)(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,i=t.statistics?.length;!t.dynamicRangeAdjustment&&i&&e&&i!==e&&this._configDefaultRenderer("override")}}}else re.warn("imagery-tile-mixin",a.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}};function i(e){if(!e.raster||!e.rasterInfo)throw new a.Z("imagery-tile","no raster")}return(0,s._)([(0,f.Cb)()],t.prototype,"_cachedRendererJson",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"_cachedRasterFunctionJson",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"_compatibleFullExtent",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"_isConstructedFromFunctionRaster",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"_rasterJobHandler",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"bandIds",void 0),(0,s._)([(0,f.Cb)({json:{origins:{service:{read:{source:"copyrightText"}}}}})],t.prototype,"copyright",void 0),(0,s._)([(0,f.Cb)({json:{read:!1}})],t.prototype,"fullExtent",null),(0,s._)([(0,f.Cb)()],t.prototype,"interpolation",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"ioConfig",void 0),(0,s._)([(0,f.Cb)({type:[v.Z],json:{write:!0}})],t.prototype,"multidimensionalDefinition",null),(0,s._)([(0,f.Cb)({type:C.Z,json:{write:!0}})],t.prototype,"multidimensionalSubset",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"raster",void 0),(0,s._)([(0,f.Cb)({type:T.Z})],t.prototype,"rasterFunction",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"rasterInfo",void 0),(0,s._)([(0,f.Cb)()],t.prototype,"sourceJSON",void 0),(0,s._)([(0,f.Cb)({readOnly:!0,type:se.Z,json:{read:!1}})],t.prototype,"spatialReference",void 0),(0,s._)([(0,f.Cb)({json:{read:!1}})],t.prototype,"tileInfo",null),(0,s._)([(0,f.Cb)(R.HQ)],t.prototype,"url",null),(0,s._)([(0,f.Cb)({types:n.dr})],t.prototype,"renderer",null),(0,s._)([(0,f.Cb)()],t.prototype,"symbolizer",void 0),t=(0,s._)([(0,y.j)("esri.layers.ImageryTileMixin")],t),t};var ae=i(38009),oe=i(16859),le=i(34760),ce=i(72965),ue=i(28294),he=i(1231),fe=i(69608),de=i(48526),pe=i(20095);function me(e){const t=e.fields,i=e.records,s=t.some((e=>"oid"===e.name.toLowerCase()))?"OBJECTID":"OID",r=[{name:s,type:"esriFieldTypeOID",alias:"OID"}].concat(t.map((e=>({name:e.name,type:"esriFieldType"+e.typeName,alias:e.name})))),n=r.map((e=>e.name)),a=[];let o=0,l=0;return i.forEach((e=>{const t={};for(t[s]=o++,l=1;l<n.length;l++)t[n[l]]=e[l-1];a.push({attributes:t})})),{displayFieldName:"",fields:r,features:a}}class ye{static get supportedVersions(){return[5]}static parse(e){const t=new DataView(e),i=3&t.getUint8(0);if(3!==i)return{header:{version:i},recordSet:null};const s=t.getUint32(4,!0),r=t.getUint16(8,!0),n=t.getUint16(10,!0),a={version:i,recordCount:s,headerByteCount:r,recordByteCount:n};let o=32;const l=[],c=[];let u;if(3===i){for(;13!==t.getUint8(o);)u=String.fromCharCode(t.getUint8(o+11)).trim(),l.push({name:(0,pe.f)(new Uint8Array(e,o,11)),type:u,typeName:["String","Date","Double","Boolean","String","Integer"][["C","D","F","L","M","N"].indexOf(u)],length:t.getUint8(o+16)}),o+=32;if(o+=1,l.length>0)for(;c.length<s&&e.byteLength-o>n;){const i=[];32===t.getUint8(o)?(o+=1,l.forEach((t=>{if("C"===t.type)i.push((0,pe.f)(new Uint8Array(e,o,t.length)).trim());else if("N"===t.type)i.push(parseInt(String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim(),10));else if("F"===t.type)i.push(parseFloat(String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim()));else if("D"===t.type){const s=String.fromCharCode.apply(null,new Uint8Array(e,o,t.length)).trim();i.push(new Date(parseInt(s.substring(0,4),10),parseInt(s.substring(4,6),10)-1,parseInt(s.substring(6,8),10)))}o+=t.length})),c.push(i)):o+=n}}return{header:a,fields:l,records:c,recordSet:me({fields:l,records:c})}}}var ge=i(87521),xe=i(74889);const Ie=new Map;Ie.set("int16","esriFieldTypeSmallInteger"),Ie.set("int32","esriFieldTypeInteger"),Ie.set("int64","esriFieldTypeInteger"),Ie.set("float32","esriFieldTypeSingle"),Ie.set("float64","esriFieldTypeDouble"),Ie.set("text","esriFieldTypeString");let be=class extends X{constructor(){super(...arguments),this.storageInfo=null,this.datasetFormat="CRF"}async open(e){await this.init();const{data:t}=await this.request(this.url+"/conf.json",{signal:e?.signal});if(!this._validateHeader(t))throw new a.Z("cloudraster:open","Invalid or unsupported conf.json.");this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const{storageInfo:i,rasterInfo:s}=this._parseHeader(t);if("thematic"===s.dataType){const e=await this._fetchAuxiliaryInformation();s.attributeTable=e}this._set("storageInfo",i),this._set("rasterInfo",s),this.ioConfig.retryCount=this.ioConfig.retryCount||0}async fetchRawTile(e,t,i,s={}){const{transposeInfo:r}=this.rasterInfo.storageInfo,{transposedVariableName:n}=s,a=!(!r||!n),o=a?0:this.rasterInfo.storageInfo.maximumPyramidLevel-e;if(o<0)return null;const l=this._buildCacheFilePath(o,t,i,s.multidimensionalDefinition,n),c=this._getIndexRecordFromBundle(t,i,a),u=await this.request(l,{range:{from:0,to:this.storageInfo.headerSize-1},responseType:"array-buffer",signal:s.signal});if(!u)return null;const h=new Uint8Array(u.data),f=this._getTileEndAndContentType(h,c);if(0===f.recordSize)return null;const d=await this.request(l,{range:{from:f.position,to:f.position+f.recordSize},responseType:"array-buffer",signal:s.signal});if(!d)return null;const[p,m]=this._getTileSize(a);return this.decodePixelBlock(d.data,{width:p,height:m,planes:null,pixelType:null,returnInterleaved:a})}_validateHeader(e){return e&&"RasterInfo"===e.type&&!["origin","extent","geodataXform","LODInfos","blockWidth","blockHeight","bandCount","pixelType","pixelSizeX","pixelSizeY","format","packetSize"].some((t=>!e[t]))}_parseHeader(e){const t=["u1","u2","u4","u8","s8","u16","s16","u32","s32","f32","f64"][e.pixelType],{bandCount:i,histograms:s,colormap:r,blockWidth:n,blockHeight:a,firstPyramidLevel:o,maximumPyramidLevel:l}=e,c=e.statistics&&e.statistics.map((e=>({min:e.min,max:e.max,avg:e.mean,stddev:e.standardDeviation,median:e.median,mode:e.mode}))),u=e.extent.spatialReference,h=e.geodataXform?.spatialReference,f=new se.Z(u?.wkid||u?.wkt?u:h);let d=new $.Z({xmin:e.extent.xmin,ymin:e.extent.ymin,xmax:e.extent.xmax,ymax:e.extent.ymax,spatialReference:f});const p=new z.Z({x:e.pixelSizeX,y:e.pixelSizeY,spatialReference:f}),m=Math.round((d.xmax-d.xmin)/p.x),y=Math.round((d.ymax-d.ymin)/p.y),g=this._parseTransform(e.geodataXform),x=g?d:null;g&&(d=g.forwardTransform(d),p.x=(d.xmax-d.xmin)/m,p.y=(d.ymax-d.ymin)/y);const I=e.properties??{},b=e.format.toLowerCase().replace("cache/",""),w=new z.Z(e.origin.x,e.origin.y,f);let _,S,R,v;if(r&&r.colors)for(_=[],S=0;S<r.colors.length;S++)R=r.colors[S],v=r.values?r.values[S]:S,_.push([v,255&R,R<<16>>>24,R<<8>>>24,R>>>24]);const C=e.LODInfos,T=[];for(S=0;S<C.levels.length;S++)T.push(new O.Z({level:C.levels[S],resolution:C.resolutions[S],scale:96/.0254*C.resolutions[S]}));const k=new F.Z({dpi:96,lods:T,format:b,origin:w,size:[n,a],spatialReference:f}),P={recordSize:8,packetSize:e.packetSize,headerSize:e.packetSize*e.packetSize*8+64},M=[{maxCol:Math.ceil(m/n)-1,maxRow:Math.ceil(y/a)-1,minCol:0,minRow:0}];let B=2;if(l>0)for(S=0;S<l;S++)M.push({maxCol:Math.ceil(m/B/n)-1,maxRow:Math.ceil(y/B/a)-1,minCol:0,minRow:0}),B*=2;const Z=e.mdInfo;let J=null;if(Z&&I._yxs){const e=I._yxs;J={packetSize:e.PacketSize,tileSize:[e.TileXSize,e.TileYSize]}}return{storageInfo:P,rasterInfo:new de.Z({width:m,height:y,pixelType:t,bandCount:i,extent:d,nativeExtent:x,transform:g,spatialReference:f,pixelSize:p,keyProperties:I,statistics:c,histograms:s,multidimensionalInfo:Z,colormap:_,storageInfo:new D.Z({blockWidth:n,blockHeight:a,pyramidBlockWidth:n,pyramidBlockHeight:a,origin:w,tileInfo:k,transposeInfo:J,firstPyramidLevel:o,maximumPyramidLevel:l,blockBoundary:M})})}}_parseTransform(e){if(!(0,ge.j)(e))throw new a.Z("cloudraster:open","the data contains unsupported geodata transform types");const t=(0,ge.c)(e);if("identity"===t.type)return null;if("polynomial"!==t.type||!t.forwardCoefficients?.length||!t.inverseCoefficients?.length)throw new a.Z("cloudraster:open","the data contains unsupported geodata transforms - both forward and inverse coefficients are required currently");return t}async _fetchAuxiliaryInformation(e){const t=this.request(this.url+"/conf.vat.json",{signal:e}).then((e=>e.data)).catch((()=>null)),i=this.request(this.url+"/conf.vat.dbf",{responseType:"array-buffer",signal:e}).then((e=>e.data)).catch((()=>null)),s=await Promise.all([t,i]);let r;if(s[0]){let e=s[0].fields;const t=s[0].values;if(e&&t){e=e.map((e=>({type:"OID"===e.name?"esriFieldTypeOID":Ie.get(e.type),name:e.name,alias:e.alias||e.name})));const i=t.map((e=>({attributes:e})));e&&t&&(r={fields:e,features:i})}}return!r&&s[1]&&(r=ye.parse(s[1]).recordSet),xe.Z.fromJSON(r)}_buildCacheFilePath(e,t,i,s,r){const n=this._getPackageSize(!!r),a=Math.floor(t/n)*n,o=Math.floor(i/n)*n,c="R"+this._toHexString4(a)+"C"+this._toHexString4(o);let u="L";u+=e>=10?e.toString():"0"+e.toString();const{multidimensionalInfo:h}=this.rasterInfo,f=s?.[0];if((0,l.Wi)(h)||!f)return`${this.url}/_alllayers/${u}/${c}.bundle`;let d="_yxs";if(!r){d=h.variables.find((e=>e.name===f.variableName)).dimensions[0].values.indexOf(f.values[0]).toString(16);const e=4-d.length;for(let t=0;t<e;t++)d="0"+d;d="S"+d}const p=this._getVariableFolderName(r||f.variableName);return`${this.url}/_alllayers/${p}/${d}/${u}/${c}.bundle`}_getPackageSize(e=!1){const{transposeInfo:t}=this.rasterInfo.storageInfo;return e&&(0,l.pC)(t)?t.packetSize??0:this.storageInfo.packetSize}_getTileSize(e=!1){const{storageInfo:t}=this.rasterInfo,{transposeInfo:i}=t;return e&&(0,l.pC)(i)?i.tileSize:t.tileInfo.size}_getVariableFolderName(e){return""===(e=e.trim())?"_v":e.replace(/[\{|\}\-]/g,"_").replace("\\*","_v")}_getIndexRecordFromBundle(e,t,i=!1){const s=this._getPackageSize(i),r=s*(e%s)+t%s;if(r<0)throw new Error("Invalid level / row / col");return 20+r*this.storageInfo.recordSize+44}_getTileEndAndContentType(e,t){const i=e.subarray(t,t+8);let s,r=0;for(s=0;s<5;s++)r|=(255&i[s])<<8*s;const n=0xffffffffff&r;for(r=0,s=5;s<8;s++)r|=(255&i[s])<<8*(s-5);return{position:n,recordSize:0xffffffffff&r}}_toHexString4(e){let t=e.toString(16);if(4!==t.length){let e=4-t.length;for(;e-- >0;)t="0"+t}return t}};(0,s._)([(0,f.Cb)({readOnly:!0})],be.prototype,"storageInfo",void 0),(0,s._)([(0,f.Cb)({type:String,json:{write:!0}})],be.prototype,"datasetFormat",void 0),be=(0,s._)([(0,y.j)("esri.layers.support.rasterDatasets.CloudRaster")],be);const we=be;var _e=i(80442),Se=i(15612);let Re=class extends X{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.data=null}async open(e){await this.init();const t=this.data,{pixelBlock:i,statistics:s,histograms:r,name:n,keyProperties:a,nativeExtent:o,transform:l}=this.data,{width:c,height:u,pixelType:h}=i,f=t.extent??new $.Z({xmin:-.5,ymin:.5,xmax:c-.5,ymax:u-.5,spatialReference:new se.Z({wkid:3857})}),d=t.isPseudoSpatialReference??!t.extent,p={x:f.width/c,y:f.height/u},m=new de.Z({width:c,height:u,pixelTyp