import{Q as st,U as Bt,W as Ct,X as CA,Y as Qt,Z as Et,_ as V,$ as ct,a0 as OA,a1 as ft,a2 as uA,a3 as lt,a4 as ht,a5 as ue,a6 as de,a7 as ut,a8 as dt,a9 as wt,aa as Dt,ab as yt,ac as mt,s as pt,ad as kt,ae as Gt,af as we,ag as De,ah as ye,ai as Ft,aj as St}from"./openlayers-J9qS6Th1.js";import{i as Ye}from"./pako-Xa-UToif.js";const Rt="modulepreload",xt=function(o){return"/"+o},me={},gA=function(A,e,t){let r=Promise.resolve();if(e&&e.length>0){let B=function(I){return Promise.all(I.map(n=>Promise.resolve(n).then(i=>({status:"fulfilled",value:i}),i=>({status:"rejected",reason:i}))))};document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),w=s?.nonce||s?.getAttribute("nonce");r=B(e.map(I=>{if(I=xt(I),I in me)return;me[I]=!0;const n=I.endsWith(".css"),i=n?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${I}"]${i}`))return;const E=document.createElement("link");if(E.rel=n?"stylesheet":Rt,n||(E.as="script"),E.crossOrigin="",E.href=I,w&&E.setAttribute("nonce",w),document.head.appendChild(E),n)return new Promise((C,g)=>{E.addEventListener("load",C),E.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${I}`)))})}))}function a(B){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=B,window.dispatchEvent(s),!s.defaultPrevented)throw B}return r.then(B=>{for(const s of B||[])s.status==="rejected"&&a(s.reason);return A().catch(a)})};function pe(o,A){const e=`
    attribute vec2 ${OA.TEXTURE_COORD};
    uniform mat4 ${V.TILE_TRANSFORM};
    uniform float ${V.TEXTURE_PIXEL_WIDTH};
    uniform float ${V.TEXTURE_PIXEL_HEIGHT};
    uniform float ${V.TEXTURE_RESOLUTION};
    uniform float ${V.TEXTURE_ORIGIN_X};
    uniform float ${V.TEXTURE_ORIGIN_Y};
    uniform float ${V.DEPTH};

    varying vec2 v_textureCoord;
    varying vec2 v_mapCoord;

    void main() {
      v_textureCoord = ${OA.TEXTURE_COORD};
      v_mapCoord = vec2(
        ${V.TEXTURE_ORIGIN_X} + ${V.TEXTURE_RESOLUTION} * ${V.TEXTURE_PIXEL_WIDTH} * v_textureCoord[0],
        ${V.TEXTURE_ORIGIN_Y} - ${V.TEXTURE_RESOLUTION} * ${V.TEXTURE_PIXEL_HEIGHT} * v_textureCoord[1]
      );
      gl_Position = ${V.TILE_TRANSFORM} * vec4(${OA.TEXTURE_COORD}, ${V.DEPTH}, 1.0);
    }
  `,t={...Qt(),bandCount:A},r=[];if(o.color!==void 0){const i=CA(t,o.color,ft);r.push(`color = ${i};`)}if(o.contrast!==void 0){const i=CA(t,o.contrast,uA);r.push(`color.rgb = clamp((${i} + 1.0) * color.rgb - (${i} / 2.0), vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}if(o.exposure!==void 0){const i=CA(t,o.exposure,uA);r.push(`color.rgb = clamp((${i} + 1.0) * color.rgb, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}if(o.saturation!==void 0){const i=CA(t,o.saturation,uA);r.push(`
      float saturation = ${i} + 1.0;
      float sr = (1.0 - saturation) * 0.2126;
      float sg = (1.0 - saturation) * 0.7152;
      float sb = (1.0 - saturation) * 0.0722;
      mat3 saturationMatrix = mat3(
        sr + saturation, sr, sr,
        sg, sg + saturation, sg,
        sb, sb, sb + saturation
      );
      color.rgb = clamp(saturationMatrix * color.rgb, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));
    `)}if(o.gamma!==void 0){const i=CA(t,o.gamma,uA);r.push(`color.rgb = pow(color.rgb, vec3(1.0 / ${i}));`)}if(o.brightness!==void 0){const i=CA(t,o.brightness,uA);r.push(`color.rgb = clamp(color.rgb + ${i}, vec3(0.0, 0.0, 0.0), vec3(1.0, 1.0, 1.0));`)}const a={},B=Object.keys(t.variables).length;if(B>1&&!o.variables)throw new Error(`Missing variables in style (expected ${t.variables})`);for(let i=0;i<B;++i){const E=t.variables[Object.keys(t.variables)[i]];if(!(E.name in o.variables))throw new Error(`Missing '${E.name}' in style variables`);const C=Et(E.name);a[C]=function(){let g=o.variables[E.name];return typeof g=="string"&&(g=lt(g)),g!==void 0?g:-9999999}}const s=Object.keys(a).map(function(i){return`uniform float ${i};`}),w=Math.ceil(A/4);s.push(`uniform sampler2D ${V.TILE_TEXTURE_ARRAY}[${w}];`),t.paletteTextures&&s.push(`uniform sampler2D ${ct}[${t.paletteTextures.length}];`);const I=Object.keys(t.functions).map(function(i){return t.functions[i]}),n=`
    #ifdef GL_FRAGMENT_PRECISION_HIGH
    precision highp float;
    #else
    precision mediump float;
    #endif

    varying vec2 v_textureCoord;
    varying vec2 v_mapCoord;
    uniform vec4 ${V.RENDER_EXTENT};
    uniform float ${V.TRANSITION_ALPHA};
    uniform float ${V.TEXTURE_PIXEL_WIDTH};
    uniform float ${V.TEXTURE_PIXEL_HEIGHT};
    uniform float ${V.RESOLUTION};
    uniform float ${V.ZOOM};

    ${s.join(`
`)}

    ${I.join(`
`)}

    void main() {
      if (
        v_mapCoord[0] < ${V.RENDER_EXTENT}[0] ||
        v_mapCoord[1] < ${V.RENDER_EXTENT}[1] ||
        v_mapCoord[0] > ${V.RENDER_EXTENT}[2] ||
        v_mapCoord[1] > ${V.RENDER_EXTENT}[3]
      ) {
        discard;
      }

      vec4 color = texture2D(${V.TILE_TEXTURE_ARRAY}[0],  v_textureCoord);

      ${r.join(`
`)}

      gl_FragColor = color;
      gl_FragColor.rgb *= gl_FragColor.a;
      gl_FragColor *= ${V.TRANSITION_ALPHA};
    }`;return{vertexShader:e,fragmentShader:n,uniforms:a,paletteTextures:t.paletteTextures}}class He extends st{constructor(A){A=A?Object.assign({},A):{};const e=A.style||{};delete A.style,super(A),this.sources_=A.sources,this.renderedSource_=null,this.renderedResolution_=NaN,this.style_=e,this.styleVariables_=this.style_.variables||{},this.handleSourceUpdate_(),this.addChangeListener(Bt.SOURCE,this.handleSourceUpdate_)}getSources(A,e){const t=this.getSource();return this.sources_?typeof this.sources_=="function"?this.sources_(A,e):this.sources_:t?[t]:[]}getRenderSource(){return this.renderedSource_||this.getSource()}getSourceState(){const A=this.getRenderSource();return A?A.getState():"undefined"}handleSourceUpdate_(){this.hasRenderer()&&this.getRenderer().clearCache();const A=this.getSource();if(A)if(A.getState()==="loading"){const e=()=>{A.getState()==="ready"&&(A.removeEventListener("change",e),this.setStyle(this.style_))};A.addEventListener("change",e)}else this.setStyle(this.style_)}getSourceBandCount_(){const A=Number.MAX_SAFE_INTEGER,e=this.getSources([-A,-A,A,A],A);return e&&e.length&&"bandCount"in e[0]?e[0].bandCount:4}createRenderer(){const A=pe(this.style_,this.getSourceBandCount_());return new Ct(this,{vertexShader:A.vertexShader,fragmentShader:A.fragmentShader,uniforms:A.uniforms,cacheSize:this.getCacheSize(),paletteTextures:A.paletteTextures})}renderSources(A,e){const t=this.getRenderer();let r;for(let a=0,B=e.length;a<B;++a)this.renderedSource_=e[a],t.prepareFrame(A)&&(r=t.renderFrame(A));return r}render(A,e){this.rendered=!0;const t=A.viewState,r=this.getSources(A.extent,t.resolution);let a=!0;for(let s=0,w=r.length;s<w;++s){const I=r[s],n=I.getState();if(n=="loading"){const i=()=>{I.getState()=="ready"&&(I.removeEventListener("change",i),this.changed())};I.addEventListener("change",i)}a=a&&n=="ready"}const B=this.renderSources(A,r);if(this.getRenderer().renderComplete&&a)return this.renderedResolution_=t.resolution,B;if(this.renderedResolution_>.5*t.resolution){const s=this.getSources(A.extent,this.renderedResolution_).filter(w=>!r.includes(w));if(s.length>0)return this.renderSources(A,s)}return B}setStyle(A){if(this.styleVariables_=A.variables||{},this.style_=A,this.hasRenderer()){const e=pe(this.style_,this.getSourceBandCount_());this.getRenderer().reset({vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,uniforms:e.uniforms,paletteTextures:e.paletteTextures}),this.changed()}}updateStyleVariables(A){Object.assign(this.styleVariables_,A),this.changed()}}He.prototype.dispose;const Zr=Object.freeze(Object.defineProperty({__proto__:null,default:He},Symbol.toStringTag,{value:"Module"}));function j(o){return(A,...e)=>Ut(o,A,e)}function lA(o,A){return j(Ke(o,A).get)}const{apply:Ut,getOwnPropertyDescriptor:Ke,getPrototypeOf:ae,ownKeys:Lt}=Reflect,{iterator:pA,toStringTag:vt}=Symbol,Mt=Object,{create:ge,defineProperty:bt}=Mt,Nt=Array,qt=Nt.prototype,Oe=qt[pA],Jt=j(Oe),Ve=ArrayBuffer,Tt=Ve.prototype;lA(Tt,"byteLength");const ke=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null;ke&&lA(ke.prototype,"byteLength");const _e=ae(Uint8Array);_e.from;const z=_e.prototype;z[pA];j(z.keys);j(z.values);j(z.entries);j(z.set);j(z.reverse);j(z.fill);j(z.copyWithin);j(z.sort);j(z.slice);j(z.subarray);lA(z,"buffer");lA(z,"byteOffset");lA(z,"length");lA(z,vt);const Yt=Uint8Array,Pe=Uint16Array,Ie=Uint32Array,Ht=Float32Array,mA=ae([][pA]()),Xe=j(mA.next),Kt=j((function*(){})().next),Ot=ae(mA),Vt=DataView.prototype,_t=j(Vt.getUint16),se=WeakMap,je=se.prototype,ze=j(je.get),Pt=j(je.set),We=new se,Xt=ge(null,{next:{value:function(){const A=ze(We,this);return Xe(A)}},[pA]:{value:function(){return this}}});function jt(o){if(o[pA]===Oe&&mA.next===Xe)return o;const A=ge(Xt);return Pt(We,A,Jt(o)),A}const zt=new se,Wt=ge(Ot,{next:{value:function(){const A=ze(zt,this);return Kt(A)},writable:!0,configurable:!0}});for(const o of Lt(mA))o!=="next"&&bt(Wt,o,Ke(mA,o));const Ze=new Ve(4),Zt=new Ht(Ze),$t=new Ie(Ze),tA=new Pe(512),iA=new Yt(512);for(let o=0;o<256;++o){const A=o-127;A<-24?(tA[o]=0,tA[o|256]=32768,iA[o]=24,iA[o|256]=24):A<-14?(tA[o]=1024>>-A-14,tA[o|256]=1024>>-A-14|32768,iA[o]=-A-1,iA[o|256]=-A-1):A<=15?(tA[o]=A+15<<10,tA[o|256]=A+15<<10|32768,iA[o]=13,iA[o|256]=13):A<128?(tA[o]=31744,tA[o|256]=64512,iA[o]=24,iA[o|256]=24):(tA[o]=31744,tA[o|256]=64512,iA[o]=13,iA[o|256]=13)}const Be=new Ie(2048);for(let o=1;o<1024;++o){let A=o<<13,e=0;for(;(A&8388608)===0;)A<<=1,e-=8388608;A&=-8388609,e+=947912704,Be[o]=A|e}for(let o=1024;o<2048;++o)Be[o]=939524096+(o-1024<<13);const hA=new Ie(64);for(let o=1;o<31;++o)hA[o]=o<<23;hA[31]=1199570944;hA[32]=2147483648;for(let o=33;o<63;++o)hA[o]=2147483648+(o-32<<23);hA[63]=3347054592;const $e=new Pe(64);for(let o=1;o<64;++o)o!==32&&($e[o]=1024);function Ai(o){const A=o>>10;return $t[0]=Be[$e[A]+(o&1023)]+hA[A],Zt[0]}function At(o,A,...e){return Ai(_t(o,A,...jt(e)))}var $r=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ce(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}var GA={exports:{}},Ge;function ei(){if(Ge)return GA.exports;Ge=1;function o(A,e,t){const r=t&&t.debug||!1;r&&console.log("[xml-utils] getting "+e+" in "+A);const a=typeof A=="object"?A.outer:A,B=a.slice(0,a.indexOf(">")+1),s=['"',"'"];for(let w=0;w<s.length;w++){const I=s[w],n=e+"\\="+I+"([^"+I+"]*)"+I;r&&console.log("[xml-utils] pattern:",n);const E=new RegExp(n).exec(B);if(r&&console.log("[xml-utils] match:",E),E)return E[1]}}return GA.exports=o,GA.exports.default=o,GA.exports}var ti=ei();const VA=Ce(ti);var FA={exports:{}},SA={exports:{}},RA={exports:{}},Fe;function ii(){if(Fe)return RA.exports;Fe=1;function o(A,e,t){const a=new RegExp(e).exec(A.slice(t));return a?t+a.index:-1}return RA.exports=o,RA.exports.default=o,RA.exports}var xA={exports:{}},Se;function ri(){if(Se)return xA.exports;Se=1;function o(A,e,t){const a=new RegExp(e).exec(A.slice(t));return a?t+a.index+a[0].length-1:-1}return xA.exports=o,xA.exports.default=o,xA.exports}var UA={exports:{}},Re;function ni(){if(Re)return UA.exports;Re=1;function o(A,e){const t=new RegExp(e,"g"),r=A.match(t);return r?r.length:0}return UA.exports=o,UA.exports.default=o,UA.exports}var xe;function oi(){if(xe)return SA.exports;xe=1;const o=ii(),A=ri(),e=ni();function t(r,a,B){const s=B&&B.debug||!1,w=!(B&&typeof B.nested===!1),I=B&&B.startIndex||0;s&&console.log("[xml-utils] starting findTagByName with",a," and ",B);const n=o(r,`<${a}[ 
>/]`,I);if(s&&console.log("[xml-utils] start:",n),n===-1)return;const i=r.slice(n+a.length);let E=A(i,"^[^<]*[ /]>",0);const C=E!==-1&&i[E-1]==="/";if(s&&console.log("[xml-utils] selfClosing:",C),C===!1)if(w){let c=0,l=1,u=0;for(;(E=A(i,"[ /]"+a+">",c))!==-1;){const y=i.substring(c,E+1);if(l+=e(y,"<"+a+`[ 
	>]`),u+=e(y,"</"+a+">"),u>=l)break;c=E}}else E=A(i,"[ /]"+a+">",0);const g=n+a.length+E+1;if(s&&console.log("[xml-utils] end:",g),g===-1)return;const h=r.slice(n,g);let Q;return C?Q=null:Q=h.slice(h.indexOf(">")+1,h.lastIndexOf("<")),{inner:Q,outer:h,start:n,end:g}}return SA.exports=t,SA.exports.default=t,SA.exports}var Ue;function ai(){if(Ue)return FA.exports;Ue=1;const o=oi();function A(e,t,r){const a=[],B=r&&r.debug||!1,s=r&&typeof r.nested=="boolean"?r.nested:!0;let w=r&&r.startIndex||0,I;for(;I=o(e,t,{debug:B,startIndex:w});)s?w=I.start+1+t.length:w=I.end,a.push(I);return B&&console.log("findTagsByName found",a.length,"tags"),a}return FA.exports=A,FA.exports.default=A,FA.exports}var gi=ai();const Ii=Ce(gi),DA={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},rA={};for(const o in DA)DA.hasOwnProperty(o)&&(rA[DA[o]]=parseInt(o,10));const si=[rA.BitsPerSample,rA.ExtraSamples,rA.SampleFormat,rA.StripByteCounts,rA.StripOffsets,rA.StripRowCounts,rA.TileByteCounts,rA.TileOffsets,rA.SubIFDs],_A={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},T={};for(const o in _A)_A.hasOwnProperty(o)&&(T[_A[o]]=parseInt(o,10));const Z={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},Bi={Unspecified:0},Ci={AddCompression:1},PA={None:0,Deflate:1,Zstandard:2},Qi={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"};function Ei(o,A){const{width:e,height:t}=o,r=new Uint8Array(e*t*3);let a;for(let B=0,s=0;B<o.length;++B,s+=3)a=256-o[B]/A*256,r[s]=a,r[s+1]=a,r[s+2]=a;return r}function ci(o,A){const{width:e,height:t}=o,r=new Uint8Array(e*t*3);let a;for(let B=0,s=0;B<o.length;++B,s+=3)a=o[B]/A*256,r[s]=a,r[s+1]=a,r[s+2]=a;return r}function fi(o,A){const{width:e,height:t}=o,r=new Uint8Array(e*t*3),a=A.length/3,B=A.length/3*2;for(let s=0,w=0;s<o.length;++s,w+=3){const I=o[s];r[w]=A[I]/65536*256,r[w+1]=A[I+a]/65536*256,r[w+2]=A[I+B]/65536*256}return r}function li(o){const{width:A,height:e}=o,t=new Uint8Array(A*e*3);for(let r=0,a=0;r<o.length;r+=4,a+=3){const B=o[r],s=o[r+1],w=o[r+2],I=o[r+3];t[a]=255*((255-B)/256)*((255-I)/256),t[a+1]=255*((255-s)/256)*((255-I)/256),t[a+2]=255*((255-w)/256)*((255-I)/256)}return t}function hi(o){const{width:A,height:e}=o,t=new Uint8ClampedArray(A*e*3);for(let r=0,a=0;r<o.length;r+=3,a+=3){const B=o[r],s=o[r+1],w=o[r+2];t[a]=B+1.402*(w-128),t[a+1]=B-.34414*(s-128)-.71414*(w-128),t[a+2]=B+1.772*(s-128)}return t}const ui=.95047,di=1,wi=1.08883;function Di(o){const{width:A,height:e}=o,t=new Uint8Array(A*e*3);for(let r=0,a=0;r<o.length;r+=3,a+=3){const B=o[r+0],s=o[r+1]<<24>>24,w=o[r+2]<<24>>24;let I=(B+16)/116,n=s/500+I,i=I-w/200,E,C,g;n=ui*(n*n*n>.008856?n*n*n:(n-16/116)/7.787),I=di*(I*I*I>.008856?I*I*I:(I-16/116)/7.787),i=wi*(i*i*i>.008856?i*i*i:(i-16/116)/7.787),E=n*3.2406+I*-1.5372+i*-.4986,C=n*-.9689+I*1.8758+i*.0415,g=n*.0557+I*-.204+i*1.057,E=E>.0031308?1.055*E**(1/2.4)-.055:12.92*E,C=C>.0031308?1.055*C**(1/2.4)-.055:12.92*C,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,t[a]=Math.max(0,Math.min(1,E))*255,t[a+1]=Math.max(0,Math.min(1,C))*255,t[a+2]=Math.max(0,Math.min(1,g))*255}return t}const et=new Map;function IA(o,A){Array.isArray(o)||(o=[o]),o.forEach(e=>et.set(e,A))}async function tt(o){const A=et.get(o.Compression);if(!A)throw new Error(`Unknown compression method identifier: ${o.Compression}`);const e=await A();return new e(o)}IA([void 0,1],()=>gA(()=>Promise.resolve().then(()=>mr),void 0).then(o=>o.default));IA(5,()=>gA(()=>Promise.resolve().then(()=>Sr),void 0).then(o=>o.default));IA(6,()=>{throw new Error("old style JPEG compression is not supported.")});IA(7,()=>gA(()=>Promise.resolve().then(()=>vr),void 0).then(o=>o.default));IA([8,32946],()=>gA(()=>Promise.resolve().then(()=>br),void 0).then(o=>o.default));IA(32773,()=>gA(()=>Promise.resolve().then(()=>qr),void 0).then(o=>o.default));IA(34887,()=>gA(()=>Promise.resolve().then(()=>Or),void 0).then(async o=>(await o.zstd.init(),o)).then(o=>o.default));IA(50001,()=>gA(()=>Promise.resolve().then(()=>_r),void 0).then(o=>o.default));function HA(o,A,e,t=1){return new(Object.getPrototypeOf(o)).constructor(A*e*t)}function yi(o,A,e,t,r){const a=A/t,B=e/r;return o.map(s=>{const w=HA(s,t,r);for(let I=0;I<r;++I){const n=Math.min(Math.round(B*I),e-1);for(let i=0;i<t;++i){const E=Math.min(Math.round(a*i),A-1),C=s[n*A+E];w[I*t+i]=C}}return w})}function cA(o,A,e){return(1-e)*o+e*A}function mi(o,A,e,t,r){const a=A/t,B=e/r;return o.map(s=>{const w=HA(s,t,r);for(let I=0;I<r;++I){const n=B*I,i=Math.floor(n),E=Math.min(Math.ceil(n),e-1);for(let C=0;C<t;++C){const g=a*C,h=g%1,Q=Math.floor(g),c=Math.min(Math.ceil(g),A-1),l=s[i*A+Q],u=s[i*A+c],y=s[E*A+Q],m=s[E*A+c],f=cA(cA(l,u,h),cA(y,m,h),n%1);w[I*t+C]=f}}return w})}function pi(o,A,e,t,r,a="nearest"){switch(a.toLowerCase()){case"nearest":return yi(o,A,e,t,r);case"bilinear":case"linear":return mi(o,A,e,t,r);default:throw new Error(`Unsupported resampling method: '${a}'`)}}function ki(o,A,e,t,r,a){const B=A/t,s=e/r,w=HA(o,t,r,a);for(let I=0;I<r;++I){const n=Math.min(Math.round(s*I),e-1);for(let i=0;i<t;++i){const E=Math.min(Math.round(B*i),A-1);for(let C=0;C<a;++C){const g=o[n*A*a+E*a+C];w[I*t*a+i*a+C]=g}}}return w}function Gi(o,A,e,t,r,a){const B=A/t,s=e/r,w=HA(o,t,r,a);for(let I=0;I<r;++I){const n=s*I,i=Math.floor(n),E=Math.min(Math.ceil(n),e-1);for(let C=0;C<t;++C){const g=B*C,h=g%1,Q=Math.floor(g),c=Math.min(Math.ceil(g),A-1);for(let l=0;l<a;++l){const u=o[i*A*a+Q*a+l],y=o[i*A*a+c*a+l],m=o[E*A*a+Q*a+l],f=o[E*A*a+c*a+l],D=cA(cA(u,y,h),cA(m,f,h),n%1);w[I*t*a+C*a+l]=D}}}return w}function Fi(o,A,e,t,r,a,B="nearest"){switch(B.toLowerCase()){case"nearest":return ki(o,A,e,t,r,a);case"bilinear":case"linear":return Gi(o,A,e,t,r,a);default:throw new Error(`Unsupported resampling method: '${B}'`)}}function Si(o,A,e){let t=0;for(let r=A;r<e;++r)t+=o[r];return t}function ee(o,A,e){switch(o){case 1:if(A<=8)return new Uint8Array(e);if(A<=16)return new Uint16Array(e);if(A<=32)return new Uint32Array(e);break;case 2:if(A===8)return new Int8Array(e);if(A===16)return new Int16Array(e);if(A===32)return new Int32Array(e);break;case 3:switch(A){case 16:case 32:return new Float32Array(e);case 64:return new Float64Array(e)}break}throw Error("Unsupported data format/bitsPerSample")}function Ri(o,A){return(o===1||o===2)&&A<=32&&A%8===0?!1:!(o===3&&(A===16||A===32||A===64))}function xi(o,A,e,t,r,a,B){const s=new DataView(o),w=e===2?B*a:B*a*t,I=e===2?1:t,n=ee(A,r,w),i=parseInt("1".repeat(r),2);if(A===1){let E;e===1?E=t*r:E=r;let C=a*E;(C&7)!==0&&(C=C+7&-8);for(let g=0;g<B;++g){const h=g*C;for(let Q=0;Q<a;++Q){const c=h+Q*I*r;for(let l=0;l<I;++l){const u=c+l*r,y=(g*a+Q)*I+l,m=Math.floor(u/8),f=u%8;if(f+r<=8)n[y]=s.getUint8(m)>>8-r-f&i;else if(f+r<=16)n[y]=s.getUint16(m)>>16-r-f&i;else if(f+r<=24){const D=s.getUint16(m)<<8|s.getUint8(m+2);n[y]=D>>24-r-f&i}else n[y]=s.getUint32(m)>>32-r-f&i}}}}return n.buffer}class it{constructor(A,e,t,r,a,B){this.fileDirectory=A,this.geoKeys=e,this.dataView=t,this.littleEndian=r,this.tiles=a?{}:null,this.isTiled=!A.StripOffsets;const s=A.PlanarConfiguration;if(this.planarConfiguration=typeof s>"u"?1:s,this.planarConfiguration!==1&&this.planarConfiguration!==2)throw new Error("Invalid planar configuration.");this.source=B}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return typeof this.fileDirectory.SamplesPerPixel<"u"?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:typeof this.fileDirectory.RowsPerStrip<"u"?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(A){return this.isTiled||(A+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-A*this.getTileHeight()}getBytesPerPixel(){let A=0;for(let e=0;e<this.fileDirectory.BitsPerSample.length;++e)A+=this.getSampleByteSize(e);return A}getSampleByteSize(A){if(A>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${A} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[A]/8)}getReaderForSample(A){const e=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[A]:1,t=this.fileDirectory.BitsPerSample[A];switch(e){case 1:if(t<=8)return DataView.prototype.getUint8;if(t<=16)return DataView.prototype.getUint16;if(t<=32)return DataView.prototype.getUint32;break;case 2:if(t<=8)return DataView.prototype.getInt8;if(t<=16)return DataView.prototype.getInt16;if(t<=32)return DataView.prototype.getInt32;break;case 3:switch(t){case 16:return function(r,a){return At(this,r,a)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(A=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[A]:1}getBitsPerSample(A=0){return this.fileDirectory.BitsPerSample[A]}getArrayForSample(A,e){const t=this.getSampleFormat(A),r=this.getBitsPerSample(A);return ee(t,r,e)}async getTileOrStrip(A,e,t,r,a){const B=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight());let w;const{tiles:I}=this;this.planarConfiguration===1?w=e*B+A:this.planarConfiguration===2&&(w=t*B*s+e*B+A);let n,i;this.isTiled?(n=this.fileDirectory.TileOffsets[w],i=this.fileDirectory.TileByteCounts[w]):(n=this.fileDirectory.StripOffsets[w],i=this.fileDirectory.StripByteCounts[w]);const E=(await this.source.fetch([{offset:n,length:i}],a))[0];let C;return I===null||!I[w]?(C=(async()=>{let g=await r.decode(this.fileDirectory,E);const h=this.getSampleFormat(),Q=this.getBitsPerSample();return Ri(h,Q)&&(g=xi(g,h,this.planarConfiguration,this.getSamplesPerPixel(),Q,this.getTileWidth(),this.getBlockHeight(e))),g})(),I!==null&&(I[w]=C)):C=I[w],{x:A,y:e,sample:t,data:await C}}async _readRaster(A,e,t,r,a,B,s,w,I){const n=this.getTileWidth(),i=this.getTileHeight(),E=this.getWidth(),C=this.getHeight(),g=Math.max(Math.floor(A[0]/n),0),h=Math.min(Math.ceil(A[2]/n),Math.ceil(E/n)),Q=Math.max(Math.floor(A[1]/i),0),c=Math.min(Math.ceil(A[3]/i),Math.ceil(C/i)),l=A[2]-A[0];let u=this.getBytesPerPixel();const y=[],m=[];for(let d=0;d<e.length;++d)this.planarConfiguration===1?y.push(Si(this.fileDirectory.BitsPerSample,0,e[d])/8):y.push(0),m.push(this.getReaderForSample(e[d]));const f=[],{littleEndian:D}=this;for(let d=Q;d<c;++d)for(let G=g;G<h;++G){let R;this.planarConfiguration===1&&(R=this.getTileOrStrip(G,d,0,a,I));for(let F=0;F<e.length;++F){const x=F,S=e[F];this.planarConfiguration===2&&(u=this.getSampleByteSize(S),R=this.getTileOrStrip(G,d,S,a,I));const Y=R.then(k=>{const p=k.data,M=new DataView(p),U=this.getBlockHeight(k.y),v=k.y*i,N=k.x*n,b=v+U,K=(k.x+1)*n,_=m[x],L=Math.min(U,U-(b-A[3]),C-v),J=Math.min(n,n-(K-A[2]),E-N);for(let q=Math.max(0,A[1]-v);q<L;++q)for(let H=Math.max(0,A[0]-N);H<J;++H){const O=(q*n+H)*u,P=_.call(M,O+y[x],D);let X;r?(X=(q+v-A[1])*l*e.length+(H+N-A[0])*e.length+x,t[X]=P):(X=(q+v-A[1])*l+H+N-A[0],t[x][X]=P)}});f.push(Y)}}if(await Promise.all(f),B&&A[2]-A[0]!==B||s&&A[3]-A[1]!==s){let d;return r?d=Fi(t,A[2]-A[0],A[3]-A[1],B,s,e.length,w):d=pi(t,A[2]-A[0],A[3]-A[1],B,s,w),d.width=B,d.height=s,d}return t.width=B||A[2]-A[0],t.height=s||A[3]-A[1],t}async readRasters({window:A,samples:e=[],interleave:t,pool:r=null,width:a,height:B,resampleMethod:s,fillValue:w,signal:I}={}){const n=A||[0,0,this.getWidth(),this.getHeight()];if(n[0]>n[2]||n[1]>n[3])throw new Error("Invalid subsets");const i=n[2]-n[0],E=n[3]-n[1],C=i*E,g=this.getSamplesPerPixel();if(!e||!e.length)for(let l=0;l<g;++l)e.push(l);else for(let l=0;l<e.length;++l)if(e[l]>=g)return Promise.reject(new RangeError(`Invalid sample index '${e[l]}'.`));let h;if(t){const l=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,u=Math.max.apply(null,this.fileDirectory.BitsPerSample);h=ee(l,u,C*e.length),w&&h.fill(w)}else{h=[];for(let l=0;l<e.length;++l){const u=this.getArrayForSample(e[l],C);Array.isArray(w)&&l<w.length?u.fill(w[l]):w&&!Array.isArray(w)&&u.fill(w),h.push(u)}}const Q=r||await tt(this.fileDirectory);return await this._readRaster(n,e,h,t,Q,a,B,s,I)}async readRGB({window:A,interleave:e=!0,pool:t=null,width:r,height:a,resampleMethod:B,enableAlpha:s=!1,signal:w}={}){const I=A||[0,0,this.getWidth(),this.getHeight()];if(I[0]>I[2]||I[1]>I[3])throw new Error("Invalid subsets");const n=this.fileDirectory.PhotometricInterpretation;if(n===Z.RGB){let c=[0,1,2];if(this.fileDirectory.ExtraSamples!==Bi.Unspecified&&s){c=[];for(let l=0;l<this.fileDirectory.BitsPerSample.length;l+=1)c.push(l)}return this.readRasters({window:A,interleave:e,samples:c,pool:t,width:r,height:a,resampleMethod:B,signal:w})}let i;switch(n){case Z.WhiteIsZero:case Z.BlackIsZero:case Z.Palette:i=[0];break;case Z.CMYK:i=[0,1,2,3];break;case Z.YCbCr:case Z.CIELab:i=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const E={window:I,interleave:!0,samples:i,pool:t,width:r,height:a,resampleMethod:B,signal:w},{fileDirectory:C}=this,g=await this.readRasters(E),h=2**this.fileDirectory.BitsPerSample[0];let Q;switch(n){case Z.WhiteIsZero:Q=Ei(g,h);break;case Z.BlackIsZero:Q=ci(g,h);break;case Z.Palette:Q=fi(g,C.ColorMap);break;case Z.CMYK:Q=li(g);break;case Z.YCbCr:Q=hi(g);break;case Z.CIELab:Q=Di(g);break;default:throw new Error("Unsupported photometric interpretation.")}if(!e){const c=new Uint8Array(Q.length/3),l=new Uint8Array(Q.length/3),u=new Uint8Array(Q.length/3);for(let y=0,m=0;y<Q.length;y+=3,++m)c[m]=Q[y],l[m]=Q[y+1],u[m]=Q[y+2];Q=[c,l,u]}return Q.width=g.width,Q.height=g.height,Q}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const A=[];for(let e=0;e<this.fileDirectory.ModelTiepoint.length;e+=6)A.push({i:this.fileDirectory.ModelTiepoint[e],j:this.fileDirectory.ModelTiepoint[e+1],k:this.fileDirectory.ModelTiepoint[e+2],x:this.fileDirectory.ModelTiepoint[e+3],y:this.fileDirectory.ModelTiepoint[e+4],z:this.fileDirectory.ModelTiepoint[e+5]});return A}getGDALMetadata(A=null){const e={};if(!this.fileDirectory.GDAL_METADATA)return null;const t=this.fileDirectory.GDAL_METADATA;let r=Ii(t,"Item");A===null?r=r.filter(a=>VA(a,"sample")===void 0):r=r.filter(a=>Number(VA(a,"sample"))===A);for(let a=0;a<r.length;++a){const B=r[a];e[VA(B,"name")]=B.inner}return e}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const A=this.fileDirectory.GDAL_NODATA;return Number(A.substring(0,A.length-1))}getOrigin(){const A=this.fileDirectory.ModelTiepoint,e=this.fileDirectory.ModelTransformation;if(A&&A.length===6)return[A[3],A[4],A[5]];if(e)return[e[3],e[7],e[11]];throw new Error("The image does not have an affine transformation.")}getResolution(A=null){const e=this.fileDirectory.ModelPixelScale,t=this.fileDirectory.ModelTransformation;if(e)return[e[0],-e[1],e[2]];if(t)return t[1]===0&&t[4]===0?[t[0],-t[5],t[10]]:[Math.sqrt(t[0]*t[0]+t[4]*t[4]),-Math.sqrt(t[1]*t[1]+t[5]*t[5]),t[10]];if(A){const[r,a,B]=A.getResolution();return[r*A.getWidth()/this.getWidth(),a*A.getHeight()/this.getHeight(),B*A.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.geoKeys.GTRasterTypeGeoKey===1}getBoundingBox(A=!1){const e=this.getHeight(),t=this.getWidth();if(this.fileDirectory.ModelTransformation&&!A){const[r,a,B,s,w,I,n,i]=this.fileDirectory.ModelTransformation,C=[[0,0],[0,e],[t,0],[t,e]].map(([Q,c])=>[s+r*Q+a*c,i+w*Q+I*c]),g=C.map(Q=>Q[0]),h=C.map(Q=>Q[1]);return[Math.min(...g),Math.min(...h),Math.max(...g),Math.max(...h)]}else{const r=this.getOrigin(),a=this.getResolution(),B=r[0],s=r[1],w=B+a[0]*t,I=s+a[1]*e;return[Math.min(B,w),Math.min(s,I),Math.max(B,w),Math.max(s,I)]}}}class Ui{constructor(A){this._dataView=new DataView(A)}get buffer(){return this._dataView.buffer}getUint64(A,e){const t=this.getUint32(A,e),r=this.getUint32(A+4,e);let a;if(e){if(a=t+2**32*r,!Number.isSafeInteger(a))throw new Error(`${a} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return a}if(a=2**32*t+r,!Number.isSafeInteger(a))throw new Error(`${a} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return a}getInt64(A,e){let t=0;const r=(this._dataView.getUint8(A+(e?7:0))&128)>0;let a=!0;for(let B=0;B<8;B++){let s=this._dataView.getUint8(A+(e?B:7-B));r&&(a?s!==0&&(s=~(s-1)&255,a=!1):s=~s&255),t+=s*256**B}return r&&(t=-t),t}getUint8(A,e){return this._dataView.getUint8(A,e)}getInt8(A,e){return this._dataView.getInt8(A,e)}getUint16(A,e){return this._dataView.getUint16(A,e)}getInt16(A,e){return this._dataView.getInt16(A,e)}getUint32(A,e){return this._dataView.getUint32(A,e)}getInt32(A,e){return this._dataView.getInt32(A,e)}getFloat16(A,e){return At(this._dataView,A,e)}getFloat32(A,e){return this._dataView.getFloat32(A,e)}getFloat64(A,e){return this._dataView.getFloat64(A,e)}}class Li{constructor(A,e,t,r){this._dataView=new DataView(A),this._sliceOffset=e,this._littleEndian=t,this._bigTiff=r}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(A,e){return this.sliceOffset<=A&&this.sliceTop>=A+e}readUint8(A){return this._dataView.getUint8(A-this._sliceOffset,this._littleEndian)}readInt8(A){return this._dataView.getInt8(A-this._sliceOffset,this._littleEndian)}readUint16(A){return this._dataView.getUint16(A-this._sliceOffset,this._littleEndian)}readInt16(A){return this._dataView.getInt16(A-this._sliceOffset,this._littleEndian)}readUint32(A){return this._dataView.getUint32(A-this._sliceOffset,this._littleEndian)}readInt32(A){return this._dataView.getInt32(A-this._sliceOffset,this._littleEndian)}readFloat32(A){return this._dataView.getFloat32(A-this._sliceOffset,this._littleEndian)}readFloat64(A){return this._dataView.getFloat64(A-this._sliceOffset,this._littleEndian)}readUint64(A){const e=this.readUint32(A),t=this.readUint32(A+4);let r;if(this._littleEndian){if(r=e+2**32*t,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}if(r=2**32*e+t,!Number.isSafeInteger(r))throw new Error(`${r} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return r}readInt64(A){let e=0;const t=(this._dataView.getUint8(A+(this._littleEndian?7:0))&128)>0;let r=!0;for(let a=0;a<8;a++){let B=this._dataView.getUint8(A+(this._littleEndian?a:7-a));t&&(r?B!==0&&(B=~(B-1)&255,r=!1):B=~B&255),e+=B*256**a}return t&&(e=-e),e}readOffset(A){return this._bigTiff?this.readUint64(A):this.readUint32(A)}}const vi=typeof navigator<"u"&&navigator.hardwareConcurrency||2;class Mi{constructor(A=vi,e){this.workers=null,this._awaitingDecoder=null,this.size=A,this.messageId=0,A&&(this._awaitingDecoder=e?Promise.resolve(e):new Promise(t=>{gA(()=>Promise.resolve().then(()=>jr),void 0).then(r=>{t(r.create)})}),this._awaitingDecoder.then(t=>{this._awaitingDecoder=null,this.workers=[];for(let r=0;r<A;r++)this.workers.push({worker:t(),idle:!0})}))}async decode(A,e){return this._awaitingDecoder&&await this._awaitingDecoder,this.size===0?tt(A).then(t=>t.decode(A,e)):new Promise(t=>{const r=this.workers.find(s=>s.idle)||this.workers[Math.floor(Math.random()*this.size)];r.idle=!1;const a=this.messageId++,B=s=>{s.data.id===a&&(r.idle=!0,t(s.data.decoded),r.worker.removeEventListener("message",B))};r.worker.addEventListener("message",B),r.worker.postMessage({fileDirectory:A,buffer:e,id:a},[e])})}destroy(){this.workers&&(this.workers.forEach(A=>{A.worker.terminate()}),this.workers=null)}}const Le=`\r
\r
`;function rt(o){if(typeof Object.fromEntries<"u")return Object.fromEntries(o);const A={};for(const[e,t]of o)A[e.toLowerCase()]=t;return A}function bi(o){const A=o.split(`\r
`).map(e=>{const t=e.split(":").map(r=>r.trim());return t[0]=t[0].toLowerCase(),t});return rt(A)}function Ni(o){const[A,...e]=o.split(";").map(r=>r.trim()),t=e.map(r=>r.split("="));return{type:A,params:rt(t)}}function te(o){let A,e,t;return o&&([,A,e,t]=o.match(/bytes (\d+)-(\d+)\/(\d+)/),A=parseInt(A,10),e=parseInt(e,10),t=parseInt(t,10)),{start:A,end:e,total:t}}function qi(o,A){let e=null;const t=new TextDecoder("ascii"),r=[],a=`--${A}`,B=`${a}--`;for(let s=0;s<10;++s)t.decode(new Uint8Array(o,s,a.length))===a&&(e=s);if(e===null)throw new Error("Could not find initial boundary");for(;e<o.byteLength;){const s=t.decode(new Uint8Array(o,e,Math.min(a.length+1024,o.byteLength-e)));if(s.length===0||s.startsWith(B))break;if(!s.startsWith(a))throw new Error("Part does not start with boundary");const w=s.substr(a.length+2);if(w.length===0)break;const I=w.indexOf(Le),n=bi(w.substr(0,I)),{start:i,end:E,total:C}=te(n["content-range"]),g=e+a.length+I+Le.length,h=parseInt(E,10)+1-parseInt(i,10);r.push({headers:n,data:o.slice(g,g+h),offset:i,length:h,fileSize:C}),e=g+h+4}return r}class Qe{async fetch(A,e=void 0){return Promise.all(A.map(t=>this.fetchSlice(t,e)))}async fetchSlice(A){throw new Error(`fetching of slice ${A} not possible, not implemented`)}get fileSize(){return null}async close(){}}class Ji extends Map{constructor(A={}){if(super(),!(A.maxSize&&A.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof A.maxAge=="number"&&A.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=A.maxSize,this.maxAge=A.maxAge||Number.POSITIVE_INFINITY,this.onEviction=A.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(A){if(typeof this.onEviction=="function")for(const[e,t]of A)this.onEviction(e,t.value)}_deleteIfExpired(A,e){return typeof e.expiry=="number"&&e.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(A,e.value),this.delete(A)):!1}_getOrDeleteIfExpired(A,e){if(this._deleteIfExpired(A,e)===!1)return e.value}_getItemValue(A,e){return e.expiry?this._getOrDeleteIfExpired(A,e):e.value}_peek(A,e){const t=e.get(A);return this._getItemValue(A,t)}_set(A,e){this.cache.set(A,e),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(A,e){this.oldCache.delete(A),this._set(A,e)}*_entriesAscending(){for(const A of this.oldCache){const[e,t]=A;this.cache.has(e)||this._deleteIfExpired(e,t)===!1&&(yield A)}for(const A of this.cache){const[e,t]=A;this._deleteIfExpired(e,t)===!1&&(yield A)}}get(A){if(this.cache.has(A)){const e=this.cache.get(A);return this._getItemValue(A,e)}if(this.oldCache.has(A)){const e=this.oldCache.get(A);if(this._deleteIfExpired(A,e)===!1)return this._moveToRecent(A,e),e.value}}set(A,e,{maxAge:t=this.maxAge}={}){const r=typeof t=="number"&&t!==Number.POSITIVE_INFINITY?Date.now()+t:void 0;return this.cache.has(A)?this.cache.set(A,{value:e,expiry:r}):this._set(A,{value:e,expiry:r}),this}has(A){return this.cache.has(A)?!this._deleteIfExpired(A,this.cache.get(A)):this.oldCache.has(A)?!this._deleteIfExpired(A,this.oldCache.get(A)):!1}peek(A){if(this.cache.has(A))return this._peek(A,this.cache);if(this.oldCache.has(A))return this._peek(A,this.oldCache)}delete(A){const e=this.cache.delete(A);return e&&this._size--,this.oldCache.delete(A)||e}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(A){if(!(A&&A>0))throw new TypeError("`maxSize` must be a number greater than 0");const e=[...this._entriesAscending()],t=e.length-A;t<0?(this.cache=new Map(e),this.oldCache=new Map,this._size=e.length):(t>0&&this._emitEvictions(e.slice(0,t)),this.oldCache=new Map(e.slice(t)),this.cache=new Map,this._size=0),this.maxSize=A}*keys(){for(const[A]of this)yield A}*values(){for(const[,A]of this)yield A}*[Symbol.iterator](){for(const A of this.cache){const[e,t]=A;this._deleteIfExpired(e,t)===!1&&(yield[e,t.value])}for(const A of this.oldCache){const[e,t]=A;this.cache.has(e)||this._deleteIfExpired(e,t)===!1&&(yield[e,t.value])}}*entriesDescending(){let A=[...this.cache];for(let e=A.length-1;e>=0;--e){const t=A[e],[r,a]=t;this._deleteIfExpired(r,a)===!1&&(yield[r,a.value])}A=[...this.oldCache];for(let e=A.length-1;e>=0;--e){const t=A[e],[r,a]=t;this.cache.has(r)||this._deleteIfExpired(r,a)===!1&&(yield[r,a.value])}}*entriesAscending(){for(const[A,e]of this._entriesAscending())yield[A,e.value]}get size(){if(!this._size)return this.oldCache.size;let A=0;for(const e of this.oldCache.keys())this.cache.has(e)||A++;return Math.min(this._size+A,this.maxSize)}entries(){return this.entriesAscending()}forEach(A,e=this){for(const[t,r]of this.entriesAscending())A.call(e,r,t,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}async function Ti(o){return new Promise(A=>setTimeout(A,o))}function Yi(o,A){const e=Array.isArray(o)?o:Array.from(o),t=Array.isArray(A)?A:Array.from(A);return e.map((r,a)=>[r,t[a]])}class fA extends Error{constructor(A){super(A),Error.captureStackTrace&&Error.captureStackTrace(this,fA),this.name="AbortError"}}class Hi extends Error{constructor(A,e){super(e),this.errors=A,this.message=e,this.name="AggregateError"}}const Ki=Hi;class Oi{constructor(A,e,t=null){this.offset=A,this.length=e,this.data=t}get top(){return this.offset+this.length}}class ve{constructor(A,e,t){this.offset=A,this.length=e,this.blockIds=t}}class Vi extends Qe{constructor(A,{blockSize:e=65536,cacheSize:t=100}={}){super(),this.source=A,this.blockSize=e,this.blockCache=new Ji({maxSize:t,onEviction:(r,a)=>{this.evictedBlocks.set(r,a)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(A,e){const t=[],r=[],a=[];this.evictedBlocks.clear();for(const{offset:E,length:C}of A){let g=E+C;const{fileSize:h}=this;h!==null&&(g=Math.min(g,h));const Q=Math.floor(E/this.blockSize)*this.blockSize;for(let c=Q;c<g;c+=this.blockSize){const l=Math.floor(c/this.blockSize);!this.blockCache.has(l)&&!this.blockRequests.has(l)&&(this.blockIdsToFetch.add(l),r.push(l)),this.blockRequests.has(l)&&t.push(this.blockRequests.get(l)),a.push(l)}}await Ti(),this.fetchBlocks(e);const B=[];for(const E of r)this.blockRequests.has(E)&&B.push(this.blockRequests.get(E));await Promise.allSettled(t),await Promise.allSettled(B);const s=[],w=a.filter(E=>this.abortedBlockIds.has(E)||!this.blockCache.has(E));if(w.forEach(E=>this.blockIdsToFetch.add(E)),w.length>0&&e&&!e.aborted){this.fetchBlocks(null);for(const E of w){const C=this.blockRequests.get(E);if(!C)throw new Error(`Block ${E} is not in the block requests`);s.push(C)}await Promise.allSettled(s)}if(e&&e.aborted)throw new fA("Request was aborted");const I=a.map(E=>this.blockCache.get(E)||this.evictedBlocks.get(E)),n=I.filter(E=>!E);if(n.length)throw new Ki(n,"Request failed");const i=new Map(Yi(a,I));return this.readSliceData(A,i)}fetchBlocks(A){if(this.blockIdsToFetch.size>0){const e=this.groupBlocks(this.blockIdsToFetch),t=this.source.fetch(e,A);for(let r=0;r<e.length;++r){const a=e[r];for(const B of a.blockIds)this.blockRequests.set(B,(async()=>{try{const s=(await t)[r],w=B*this.blockSize,I=w-s.offset,n=Math.min(I+this.blockSize,s.data.byteLength),i=s.data.slice(I,n),E=new Oi(w,i.byteLength,i,B);this.blockCache.set(B,E),this.abortedBlockIds.delete(B)}catch(s){if(s.name==="AbortError")s.signal=A,this.blockCache.delete(B),this.abortedBlockIds.add(B);else throw s}finally{this.blockRequests.delete(B)}})())}this.blockIdsToFetch.clear()}}groupBlocks(A){const e=Array.from(A).sort((B,s)=>B-s);if(e.length===0)return[];let t=[],r=null;const a=[];for(const B of e)r===null||r+1===B?(t.push(B),r=B):(a.push(new ve(t[0]*this.blockSize,t.length*this.blockSize,t)),t=[B],r=B);return a.push(new ve(t[0]*this.blockSize,t.length*this.blockSize,t)),a}readSliceData(A,e){return A.map(t=>{let r=t.offset+t.length;this.fileSize!==null&&(r=Math.min(this.fileSize,r));const a=Math.floor(t.offset/this.blockSize),B=Math.floor(r/this.blockSize),s=new ArrayBuffer(t.length),w=new Uint8Array(s);for(let I=a;I<=B;++I){const n=e.get(I),i=n.offset-t.offset,E=n.top-r;let C=0,g=0,h;i<0?C=-i:i>0&&(g=i),E<0?h=n.length-C:h=r-n.offset-C;const Q=new Uint8Array(n.data,C,h);w.set(Q,g)}return s})}}class Ee{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(A){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}}class ce{constructor(A){this.url=A}async request({headers:A,signal:e}={}){throw new Error("request is not implemented")}}class _i extends Ee{constructor(A){super(),this.response=A}get status(){return this.response.status}getHeader(A){return this.response.headers.get(A)}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}}class Pi extends ce{constructor(A,e){super(A),this.credentials=e}async request({headers:A,signal:e}={}){const t=await fetch(this.url,{headers:A,credentials:this.credentials,signal:e});return new _i(t)}}class Xi extends Ee{constructor(A,e){super(),this.xhr=A,this.data=e}get status(){return this.xhr.status}getHeader(A){return this.xhr.getResponseHeader(A)}async getData(){return this.data}}class ji extends ce{constructRequest(A,e){return new Promise((t,r)=>{const a=new XMLHttpRequest;a.open("GET",this.url),a.responseType="arraybuffer";for(const[B,s]of Object.entries(A))a.setRequestHeader(B,s);a.onload=()=>{const B=a.response;t(new Xi(a,B))},a.onerror=r,a.onabort=()=>r(new fA("Request aborted")),a.send(),e&&(e.aborted&&a.abort(),e.addEventListener("abort",()=>a.abort()))})}async request({headers:A,signal:e}={}){return await this.constructRequest(A,e)}}const XA={};class zi extends Ee{constructor(A,e){super(),this.response=A,this.dataPromise=e}get status(){return this.response.statusCode}getHeader(A){return this.response.headers[A]}async getData(){return await this.dataPromise}}class Wi extends ce{constructor(A){super(A),this.parsedUrl=XA.parse(this.url),this.httpApi=(this.parsedUrl.protocol==="http:",XA)}constructRequest(A,e){return new Promise((t,r)=>{const a=this.httpApi.get({...this.parsedUrl,headers:A},B=>{const s=new Promise(w=>{const I=[];B.on("data",n=>{I.push(n)}),B.on("end",()=>{const n=Buffer.concat(I).buffer;w(n)}),B.on("error",r)});t(new zi(B,s))});a.on("error",r),e&&(e.aborted&&a.destroy(new fA("Request aborted")),e.addEventListener("abort",()=>a.destroy(new fA("Request aborted"))))})}async request({headers:A,signal:e}={}){return await this.constructRequest(A,e)}}class fe extends Qe{constructor(A,e,t,r){super(),this.client=A,this.headers=e,this.maxRanges=t,this.allowFullFile=r,this._fileSize=null}async fetch(A,e){return this.maxRanges>=A.length?this.fetchSlices(A,e):(this.maxRanges>0&&A.length>1,Promise.all(A.map(t=>this.fetchSlice(t,e))))}async fetchSlices(A,e){const t=await this.client.request({headers:{...this.headers,Range:`bytes=${A.map(({offset:r,length:a})=>`${r}-${r+a}`).join(",")}`},signal:e});if(t.ok)if(t.status===206){const{type:r,params:a}=Ni(t.getHeader("content-type"));if(r==="multipart/byteranges"){const i=qi(await t.getData(),a.boundary);return this._fileSize=i[0].fileSize||null,i}const B=await t.getData(),{start:s,end:w,total:I}=te(t.getHeader("content-range"));this._fileSize=I||null;const n=[{data:B,offset:s,length:w-s}];if(A.length>1){const i=await Promise.all(A.slice(1).map(E=>this.fetchSlice(E,e)));return n.concat(i)}return n}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const r=await t.getData();return this._fileSize=r.byteLength,[{data:r,offset:0,length:r.byteLength}]}else throw new Error("Error fetching data.")}async fetchSlice(A,e){const{offset:t,length:r}=A,a=await this.client.request({headers:{...this.headers,Range:`bytes=${t}-${t+r}`},signal:e});if(a.ok)if(a.status===206){const B=await a.getData(),{total:s}=te(a.getHeader("content-range"));return this._fileSize=s||null,{data:B,offset:t,length:r}}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const B=await a.getData();return this._fileSize=B.byteLength,{data:B,offset:0,length:B.byteLength}}else throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}}function le(o,{blockSize:A,cacheSize:e}){return A===null?o:new Vi(o,{blockSize:A,cacheSize:e})}function Zi(o,{headers:A={},credentials:e,maxRanges:t=0,allowFullFile:r=!1,...a}={}){const B=new Pi(o,e),s=new fe(B,A,t,r);return le(s,a)}function $i(o,{headers:A={},maxRanges:e=0,allowFullFile:t=!1,...r}={}){const a=new ji(o),B=new fe(a,A,e,t);return le(B,r)}function Ar(o,{headers:A={},maxRanges:e=0,allowFullFile:t=!1,...r}={}){const a=new Wi(o),B=new fe(a,A,e,t);return le(B,r)}function ie(o,{forceXHR:A=!1,...e}={}){return typeof fetch=="function"&&!A?Zi(o,e):typeof XMLHttpRequest<"u"?$i(o,e):Ar(o,e)}class er extends Qe{constructor(A){super(),this.file=A}async fetchSlice(A,e){return new Promise((t,r)=>{const a=this.file.slice(A.offset,A.offset+A.length),B=new FileReader;B.onload=s=>t(s.target.result),B.onerror=r,B.onabort=r,B.readAsArrayBuffer(a),e&&e.addEventListener("abort",()=>B.abort())})}}function tr(o){return new er(o)}function ir(o,A){let e=o.length-A,t=0;do{for(let r=A;r>0;r--)o[t+A]+=o[t],t++;e-=A}while(e>0)}function rr(o,A,e){let t=0,r=o.length;const a=r/e;for(;r>A;){for(let s=A;s>0;--s)o[t+A]+=o[t],++t;r-=A}const B=o.slice();for(let s=0;s<a;++s)for(let w=0;w<e;++w)o[e*s+w]=B[(e-w-1)*a+s]}function nr(o,A,e,t,r,a){if(A===1)return o;for(let w=0;w<r.length;++w){if(r[w]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(r[w]!==r[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const B=r[0]/8,s=a===2?1:r.length;for(let w=0;w<t&&!(w*s*e*B>=o.byteLength);++w){let I;if(A===2){switch(r[0]){case 8:I=new Uint8Array(o,w*s*e*B,s*e*B);break;case 16:I=new Uint16Array(o,w*s*e*B,s*e*B/2);break;case 32:I=new Uint32Array(o,w*s*e*B,s*e*B/4);break;default:throw new Error(`Predictor 2 not allowed with ${r[0]} bits per sample.`)}ir(I,s)}else A===3&&(I=new Uint8Array(o,w*s*e*B,s*e*B),rr(I,s,B))}return o}class BA{async decode(A,e){const t=await this.decodeBlock(e),r=A.Predictor||1;if(r!==1){const a=!A.StripOffsets,B=a?A.TileWidth:A.ImageWidth,s=a?A.TileLength:A.RowsPerStrip||A.ImageLength;return nr(t,r,B,s,A.BitsPerSample,A.PlanarConfiguration)}return t}}function re(o){switch(o){case T.BYTE:case T.ASCII:case T.SBYTE:case T.UNDEFINED:return 1;case T.SHORT:case T.SSHORT:return 2;case T.LONG:case T.SLONG:case T.FLOAT:case T.IFD:return 4;case T.RATIONAL:case T.SRATIONAL:case T.DOUBLE:case T.LONG8:case T.SLONG8:case T.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${o}`)}}function or(o){const A=o.GeoKeyDirectory;if(!A)return null;const e={};for(let t=4;t<=A[3]*4;t+=4){const r=Qi[A[t]],a=A[t+1]?DA[A[t+1]]:null,B=A[t+2],s=A[t+3];let w=null;if(!a)w=s;else{if(w=o[a],typeof w>"u"||w===null)throw new Error(`Could not get value of geoKey '${r}'.`);typeof w=="string"?w=w.substring(s,s+B-1):w.subarray&&(w=w.subarray(s,s+B),B===1&&(w=w[0]))}e[r]=w}return e}function QA(o,A,e,t){let r=null,a=null;const B=re(A);switch(A){case T.BYTE:case T.ASCII:case T.UNDEFINED:r=new Uint8Array(e),a=o.readUint8;break;case T.SBYTE:r=new Int8Array(e),a=o.readInt8;break;case T.SHORT:r=new Uint16Array(e),a=o.readUint16;break;case T.SSHORT:r=new Int16Array(e),a=o.readInt16;break;case T.LONG:case T.IFD:r=new Uint32Array(e),a=o.readUint32;break;case T.SLONG:r=new Int32Array(e),a=o.readInt32;break;case T.LONG8:case T.IFD8:r=new Array(e),a=o.readUint64;break;case T.SLONG8:r=new Array(e),a=o.readInt64;break;case T.RATIONAL:r=new Uint32Array(e*2),a=o.readUint32;break;case T.SRATIONAL:r=new Int32Array(e*2),a=o.readInt32;break;case T.FLOAT:r=new Float32Array(e),a=o.readFloat32;break;case T.DOUBLE:r=new Float64Array(e),a=o.readFloat64;break;default:throw new RangeError(`Invalid field type: ${A}`)}if(A===T.RATIONAL||A===T.SRATIONAL)for(let s=0;s<e;s+=2)r[s]=a.call(o,t+s*B),r[s+1]=a.call(o,t+(s*B+4));else for(let s=0;s<e;++s)r[s]=a.call(o,t+s*B);return A===T.ASCII?new TextDecoder("utf-8").decode(r):r}class ar{constructor(A,e,t){this.fileDirectory=A,this.geoKeyDirectory=e,this.nextIFDByteOffset=t}}class LA extends Error{constructor(A){super(`No image at index ${A}`),this.index=A}}class nt{async readRasters(A={}){const{window:e,width:t,height:r}=A;let{resX:a,resY:B,bbox:s}=A;const w=await this.getImage();let I=w;const n=await this.getImageCount(),i=w.getBoundingBox();if(e&&s)throw new Error('Both "bbox" and "window" passed.');if(t||r){if(e){const[g,h]=w.getOrigin(),[Q,c]=w.getResolution();s=[g+e[0]*Q,h+e[1]*c,g+e[2]*Q,h+e[3]*c]}const C=s||i;if(t){if(a)throw new Error("Both width and resX passed");a=(C[2]-C[0])/t}if(r){if(B)throw new Error("Both width and resY passed");B=(C[3]-C[1])/r}}if(a||B){const C=[];for(let g=0;g<n;++g){const h=await this.getImage(g),{SubfileType:Q,NewSubfileType:c}=h.fileDirectory;(g===0||Q===2||c&1)&&C.push(h)}C.sort((g,h)=>g.getWidth()-h.getWidth());for(let g=0;g<C.length;++g){const h=C[g],Q=(i[2]-i[0])/h.getWidth(),c=(i[3]-i[1])/h.getHeight();if(I=h,a&&a>Q||B&&B>c)break}}let E=e;if(s){const[C,g]=w.getOrigin(),[h,Q]=I.getResolution(w);E=[Math.round((s[0]-C)/h),Math.round((s[1]-g)/Q),Math.round((s[2]-C)/h),Math.round((s[3]-g)/Q)],E=[Math.min(E[0],E[2]),Math.min(E[1],E[3]),Math.max(E[0],E[2]),Math.max(E[1],E[3])]}return I.readRasters({...A,window:E})}}let YA=class ot extends nt{constructor(A,e,t,r,a={}){super(),this.source=A,this.littleEndian=e,this.bigTiff=t,this.firstIFDOffset=r,this.cache=a.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(A,e){const t=this.bigTiff?4048:1024;return new Li((await this.source.fetch([{offset:A,length:typeof e<"u"?e:t}]))[0],A,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(A){const e=this.bigTiff?20:12,t=this.bigTiff?8:2;let r=await this.getSlice(A);const a=this.bigTiff?r.readUint64(A):r.readUint16(A),B=a*e+(this.bigTiff?16:6);r.covers(A,B)||(r=await this.getSlice(A,B));const s={};let w=A+(this.bigTiff?8:2);for(let i=0;i<a;w+=e,++i){const E=r.readUint16(w),C=r.readUint16(w+2),g=this.bigTiff?r.readUint64(w+4):r.readUint32(w+4);let h,Q;const c=re(C),l=w+(this.bigTiff?12:8);if(c*g<=(this.bigTiff?8:4))h=QA(r,C,g,l);else{const u=r.readOffset(l),y=re(C)*g;if(r.covers(u,y))h=QA(r,C,g,u);else{const m=await this.getSlice(u,y);h=QA(m,C,g,u)}}g===1&&si.indexOf(E)===-1&&!(C===T.RATIONAL||C===T.SRATIONAL)?Q=h[0]:Q=h,s[DA[E]]=Q}const I=or(s),n=r.readOffset(A+t+e*a);return new ar(s,I,n)}async requestIFD(A){if(this.ifdRequests[A])return this.ifdRequests[A];if(A===0)return this.ifdRequests[A]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[A];if(!this.ifdRequests[A-1])try{this.ifdRequests[A-1]=this.requestIFD(A-1)}catch(e){throw e instanceof LA?new LA(A):e}return this.ifdRequests[A]=(async()=>{const e=await this.ifdRequests[A-1];if(e.nextIFDByteOffset===0)throw new LA(A);return this.parseFileDirectoryAt(e.nextIFDByteOffset)})(),this.ifdRequests[A]}async getImage(A=0){const e=await this.requestIFD(A);return new it(e.fileDirectory,e.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let A=0,e=!0;for(;e;)try{await this.requestIFD(A),++A}catch(t){if(t instanceof LA)e=!1;else throw t}return A}async getGhostValues(){const A=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const e="GDAL_STRUCTURAL_METADATA_SIZE=",t=e.length+100;let r=await this.getSlice(A,t);if(e===QA(r,T.ASCII,e.length,A)){const B=QA(r,T.ASCII,t,A).split(`
`)[0],s=Number(B.split("=")[1].split(" ")[0])+B.length;s>t&&(r=await this.getSlice(A,s));const w=QA(r,T.ASCII,s,A);this.ghostValues={},w.split(`
`).filter(I=>I.length>0).map(I=>I.split("=")).forEach(([I,n])=>{this.ghostValues[I]=n})}return this.ghostValues}static async fromSource(A,e,t){const r=(await A.fetch([{offset:0,length:1024}],t))[0],a=new Ui(r),B=a.getUint16(0,0);let s;if(B===18761)s=!0;else if(B===19789)s=!1;else throw new TypeError("Invalid byte order value.");const w=a.getUint16(2,s);let I;if(w===42)I=!1;else if(w===43){if(I=!0,a.getUint16(4,s)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const n=I?a.getUint64(8,s):a.getUint32(4,s);return new ot(A,s,I,n,e)}close(){return typeof this.source.close=="function"?this.source.close():!1}};class gr extends nt{constructor(A,e){super(),this.mainFile=A,this.overviewFiles=e,this.imageFiles=[A].concat(e),this.fileDirectoriesPerFile=null,this.fileDirectoriesPerFileParsing=null,this.imageCount=null}async parseFileDirectoriesPerFile(){const A=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map(e=>e.parseFileDirectoryAt(e.firstIFDOffset)));return this.fileDirectoriesPerFile=await Promise.all(A),this.fileDirectoriesPerFile}async getImage(A=0){await this.getImageCount(),await this.parseFileDirectoriesPerFile();let e=0,t=0;for(let r=0;r<this.imageFiles.length;r++){const a=this.imageFiles[r];for(let B=0;B<this.imageCounts[r];B++){if(A===e){const s=await a.requestIFD(t);return new it(s.fileDirectory,s.geoKeyDirectory,a.dataView,a.littleEndian,a.cache,a.source)}e++,t++}t=0}throw new RangeError("Invalid image index")}async getImageCount(){if(this.imageCount!==null)return this.imageCount;const A=[this.mainFile.getImageCount()].concat(this.overviewFiles.map(e=>e.getImageCount()));return this.imageCounts=await Promise.all(A),this.imageCount=this.imageCounts.reduce((e,t)=>e+t,0),this.imageCount}}async function Ir(o,A={},e){return YA.fromSource(ie(o,A),e)}async function sr(o,A){return YA.fromSource(tr(o),A)}async function Br(o,A=[],e={},t){const r=await YA.fromSource(ie(o,e),t),a=await Promise.all(A.map(B=>YA.fromSource(ie(B,e))));return new gr(r,a)}function Cr(o){return((o.fileDirectory.NewSubfileType||0)&4)===4}function Qr(o,A){if(!o)return!1;if(o===!0)return!0;if(A.getSamplesPerPixel()!==3)return!1;const e=A.fileDirectory.PhotometricInterpretation,t=Z;return e===t.CMYK||e===t.YCbCr||e===t.CIELab||e===t.ICCLab}const Me="STATISTICS_MAXIMUM",be="STATISTICS_MINIMUM",jA=256;let zA;function Er(){return zA||(zA=new Mi),zA}function cr(o){try{return o.getBoundingBox(!0)}catch{return[0,0,o.getWidth(),o.getHeight()]}}function fr(o){try{return o.getOrigin().slice(0,2)}catch{return[0,o.getHeight()]}}function lr(o,A){try{return o.getResolution(A)}catch{return[A.getWidth()/o.getWidth(),A.getHeight()/o.getHeight()]}}function hr(o){const A=o.geoKeys;if(!A)return null;if(A.ProjectedCSTypeGeoKey&&A.ProjectedCSTypeGeoKey!==32767){const e="EPSG:"+A.ProjectedCSTypeGeoKey;let t=we(e);if(!t){const r=De(A.ProjLinearUnitsGeoKey);r&&(t=new ye({code:e,units:r}))}return t}if(A.GeographicTypeGeoKey&&A.GeographicTypeGeoKey!==32767){const e="EPSG:"+A.GeographicTypeGeoKey;let t=we(e);if(!t){const r=De(A.GeogAngularUnitsGeoKey);r&&(t=new ye({code:e,units:r}))}return t}return null}function ur(o){return o.getImageCount().then(function(A){const e=new Array(A);for(let t=0;t<A;++t)e[t]=o.getImage(t);return Promise.all(e)})}function dr(o,A){let e;return o.blob?e=sr(o.blob):o.overviews?e=Br(o.url,o.overviews,A):e=Ir(o.url,A),e.then(ur)}function wA(o,A,e,t,r){if(Array.isArray(o)){const a=o.length;if(!Array.isArray(A)||a!=A.length){const B=new Error(t);throw r(B),B}for(let B=0;B<a;++B)wA(o[B],A[B],e,t,r);return}if(A=A,Math.abs(o-A)>e*o)throw new Error(t)}function wr(o){return o instanceof Int8Array?-128:o instanceof Int16Array?-32768:o instanceof Int32Array?-2147483648:o instanceof Float32Array?12e-39:0}function Dr(o){return o instanceof Int8Array?127:o instanceof Uint8Array||o instanceof Uint8ClampedArray?255:o instanceof Int16Array?32767:o instanceof Uint16Array?65535:o instanceof Int32Array?2147483647:o instanceof Uint32Array?4294967295:o instanceof Float32Array?34e37:255}class at extends ht{constructor(A){super({state:"loading",tileGrid:null,projection:A.projection||null,transition:A.transition,interpolate:A.interpolate!==!1,wrapX:A.wrapX}),this.sourceInfo_=A.sources;const e=this.sourceInfo_.length;this.sourceOptions_=A.sourceOptions,this.sourceImagery_=new Array(e),this.sourceMasks_=new Array(e),this.resolutionFactors_=new Array(e),this.samplesPerPixel_,this.nodataValues_,this.metadata_,this.normalize_=A.normalize!==!1,this.addAlpha_=!1,this.error_=null,this.convertToRGB_=A.convertToRGB||!1,this.setKey(this.sourceInfo_.map(a=>a.url).join(","));const t=this,r=new Array(e);for(let a=0;a<e;++a)r[a]=dr(this.sourceInfo_[a],this.sourceOptions_);Promise.all(r).then(function(a){t.configure_(a)}).catch(function(a){ue(a),t.error_=a,t.setState("error")})}getError(){return this.error_}determineProjection(A){const e=A[0];for(let t=e.length-1;t>=0;--t){const r=e[t],a=hr(r);if(a){this.projection=a;break}}}determineTransformMatrix(A){const e=A[0];for(let t=e.length-1;t>=0;--t){const a=e[t].fileDirectory.ModelTransformation;if(a){const[B,s,w,I,n,i,E,C]=a,g=de(de([1/Math.sqrt(B*B+n*n),0,0,-1/Math.sqrt(s*s+i*i),I,C],[B,n,s,i,0,0]),[1,0,0,1,-I,-C]);this.transformMatrix=g,this.addAlpha_=!0;break}}}configure_(A){let e,t,r,a,B;const s=new Array(A.length),w=new Array(A.length),I=new Array(A.length);let n=0;const i=A.length;for(let Q=0;Q<i;++Q){const c=[],l=[];A[Q].forEach(G=>{Cr(G)?l.push(G):c.push(G)});const u=c.length;if(l.length>0&&l.length!==u)throw new Error(`Expected one mask per image found ${l.length} masks and ${u} images`);let y,m;const f=new Array(u),D=new Array(u),d=new Array(u);w[Q]=new Array(u),I[Q]=new Array(u);for(let G=0;G<u;++G){const R=c[G],F=R.getGDALNoData();I[Q][G]=R.getGDALMetadata(0),w[Q][G]=F;const x=this.sourceInfo_[Q].bands;s[Q]=x?x.length:R.getSamplesPerPixel();const S=u-(G+1);y||(y=cr(R)),m||(m=fr(R));const Y=lr(R,c[0]);d[S]=Y[0];const k=[R.getTileWidth(),R.getTileHeight()];k[0]!==k[1]&&k[1]<jA&&(k[0]=jA,k[1]=jA),f[S]=k;const p=Y[0]/Math.abs(Y[1]);D[S]=[k[0],k[1]/p]}if(e?kt(e,y,e):e=y,!t)t=m;else{const G=`Origin mismatch for source ${Q}, got [${m}] but expected [${t}]`;wA(t,m,0,G,this.viewRejector)}if(!B)B=d,this.resolutionFactors_[Q]=1;else{B.length-n>d.length&&(n=B.length-d.length);const G=B[B.length-1]/d[d.length-1];this.resolutionFactors_[Q]=G;const R=d.map(x=>x*=G),F=`Resolution mismatch for source ${Q}, got [${R}] but expected [${B}]`;wA(B.slice(n,B.length),R,.02,F,this.viewRejector)}r?wA(r.slice(n,r.length),D,.01,`Tile size mismatch for source ${Q}`,this.viewRejector):r=D,a?wA(a.slice(n,a.length),f,0,`Tile size mismatch for source ${Q}`,this.viewRejector):a=f,this.sourceImagery_[Q]=c.reverse(),this.sourceMasks_[Q]=l.reverse()}for(let Q=0,c=this.sourceImagery_.length;Q<c;++Q){const l=this.sourceImagery_[Q];for(;l.length<B.length;)l.unshift(void 0)}this.getProjection()||this.determineProjection(A),this.determineTransformMatrix(A),this.samplesPerPixel_=s,this.nodataValues_=w,this.metadata_=I;A:for(let Q=0;Q<i;++Q){if(this.sourceInfo_[Q].nodata!==void 0){this.addAlpha_=!0;break}if(this.sourceMasks_[Q].length){this.addAlpha_=!0;break}const c=w[Q],l=this.sourceInfo_[Q].bands;if(l){for(let u=0;u<l.length;++u)if(c[l[u]-1]!==null){this.addAlpha_=!0;break A}continue}for(let u=0;u<c.length;++u)if(c[u]!==null){this.addAlpha_=!0;break A}}let E=this.addAlpha_?1:0;for(let Q=0;Q<i;++Q)E+=s[Q];this.bandCount=E;const C=new ut({extent:e,minZoom:n,origin:t,resolutions:B,tileSizes:r});this.tileGrid=C,this.setTileSizes(a),this.setLoader(this.loadTile_.bind(this)),this.setState("ready");const g=1;B.length===2?B=[B[0],B[1],B[1]/2]:B.length===1&&(B=[B[0]*2,B[0],B[0]/2]);let h=e;if(this.transformMatrix){const Q=dt(wt(),this.transformMatrix.slice()),c=Ft(l=>St(Q,l));h=Dt(e,c)}this.viewResolver({showFullExtent:!0,projection:this.projection,resolutions:B,center:mt(pt(h),this.projection),extent:yt(h,this.projection),zoom:g})}loadTile_(A,e,t,r){const a=this.getTileSize(A),B=this.sourceImagery_.length,s=new Array(B*2),w=this.nodataValues_,I=this.sourceInfo_,n=Er();for(let i=0;i<B;++i){const E=I[i],C=this.resolutionFactors_[i],g=[Math.round(e*(a[0]*C)),Math.round(t*(a[1]*C)),Math.round((e+1)*(a[0]*C)),Math.round((t+1)*(a[1]*C))],h=this.sourceImagery_[i][A];let Q;E.bands&&(Q=E.bands.map(function(m){return m-1}));let c;"nodata"in E&&E.nodata!==null?c=E.nodata:Q?c=Q.map(function(m){return w[i][m]}):c=w[i];const l={window:g,width:a[0],height:a[1],samples:Q,fillValue:c,pool:n,interleave:!1,signal:r.signal};Qr(this.convertToRGB_,h)?s[i]=h.readRGB(l):s[i]=h.readRasters(l);const u=B+i,y=this.sourceMasks_[i][A];if(!y){s[u]=Promise.resolve(null);continue}s[u]=y.readRasters({window:g,width:a[0],height:a[1],samples:[0],pool:n,interleave:!1})}return Promise.all(s).then(this.composeTile_.bind(this,a)).catch(function(i){throw ue(i),i})}composeTile_(A,e){const t=this.metadata_,r=this.sourceInfo_,a=this.sourceImagery_.length,B=this.bandCount,s=this.samplesPerPixel_,w=this.nodataValues_,I=this.normalize_,n=this.addAlpha_,i=A[0]*A[1],E=i*B;let C;I?C=new Uint8Array(E):C=new Float32Array(E);let g=0;for(let h=0;h<i;++h){let Q=n;for(let c=0;c<a;++c){const l=r[c];let u=l.min,y=l.max,m,f;if(I){const D=t[c][0];u===void 0&&(D&&be in D?u=parseFloat(D[be]):u=wr(e[c][0])),y===void 0&&(D&&Me in D?y=parseFloat(D[Me]):y=Dr(e[c][0])),m=255/(y-u),f=-u*m}for(let D=0;D<s[c];++D){const d=e[c][D][h];let G;if(I?G=Gt(m*d+f,0,255):G=d,!n)C[g]=G;else{let R=l.nodata;if(R===void 0){let x;l.bands?x=l.bands[D]-1:x=D,R=w[c][x]}const F=isNaN(R);(!F&&d!==R||F&&!isNaN(d))&&(Q=!1,C[g]=G)}g++}if(!Q){const D=a+c,d=e[D];d&&!d[0][h]&&(Q=!0)}}n&&(Q||(C[g]=255),g++)}return C}}at.prototype.getView;const An=Object.freeze(Object.defineProperty({__proto__:null,default:at},Symbol.toStringTag,{value:"Module"}));class yr extends BA{decodeBlock(A){return A}}const mr=Object.freeze(Object.defineProperty({__proto__:null,default:yr},Symbol.toStringTag,{value:"Module"})),Ne=9,WA=256,ne=257,pr=12;function kr(o,A,e){const t=A%8,r=Math.floor(A/8),a=8-t,B=A+e-(r+1)*8;let s=8*(r+2)-(A+e);const w=(r+2)*8-A;if(s=Math.max(0,s),r>=o.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),ne;let I=o[r]&2**(8-t)-1;I<<=e-a;let n=I;if(r+1<o.length){let i=o[r+1]>>>s;i<<=Math.max(0,e-w),n+=i}if(B>8&&r+2<o.length){const i=(r+3)*8-(A+e),E=o[r+2]>>>i;n+=E}return n}function ZA(o,A){for(let e=A.length-1;e>=0;e--)o.push(A[e]);return o}function Gr(o){const A=new Uint16Array(4093),e=new Uint8Array(4093);for(let g=0;g<=257;g++)A[g]=4096,e[g]=g;let t=258,r=Ne,a=0;function B(){t=258,r=Ne}function s(g){const h=kr(g,a,r);return a+=r,h}function w(g,h){return e[t]=h,A[t]=g,t++,t-1}function I(g){const h=[];for(let Q=g;Q!==4096;Q=A[Q])h.push(e[Q]);return h}const n=[];B();const i=new Uint8Array(o);let E=s(i),C;for(;E!==ne;){if(E===WA){for(B(),E=s(i);E===WA;)E=s(i);if(E===ne)break;if(E>WA)throw new Error(`corrupted code at scanline ${E}`);{const g=I(E);ZA(n,g),C=E}}else if(E<t){const g=I(E);ZA(n,g),w(C,g[g.length-1]),C=E}else{const g=I(C);if(!g)throw new Error(`Bogus entry. Not in dictionary, ${C} / ${t}, position: ${a}`);ZA(n,g),n.push(g[g.length-1]),w(C,g[g.length-1]),C=E}t+1>=2**r&&(r===pr?C=void 0:r++),E=s(i)}return new Uint8Array(n)}class Fr extends BA{decodeBlock(A){return Gr(A).buffer}}const Sr=Object.freeze(Object.defineProperty({__proto__:null,default:Fr},Symbol.toStringTag,{value:"Module"})),yA=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),vA=4017,MA=799,bA=3406,NA=2276,qA=1567,JA=3784,EA=5793,TA=2896;function qe(o,A){let e=0;const t=[];let r=16;for(;r>0&&!o[r-1];)--r;t.push({children:[],index:0});let a=t[0],B;for(let s=0;s<r;s++){for(let w=0;w<o[s];w++){for(a=t.pop(),a.children[a.index]=A[e];a.index>0;)a=t.pop();for(a.index++,t.push(a);t.length<=s;)t.push(B={children:[],index:0}),a.children[a.index]=B.children,a=B;e++}s+1<r&&(t.push(B={children:[],index:0}),a.children[a.index]=B.children,a=B)}return t[0].children}function Rr(o,A,e,t,r,a,B,s,w){const{mcusPerLine:I,progressive:n}=e,i=A;let E=A,C=0,g=0;function h(){if(g>0)return g--,C>>g&1;if(C=o[E++],C===255){const L=o[E++];if(L)throw new Error(`unexpected marker: ${(C<<8|L).toString(16)}`)}return g=7,C>>>7}function Q(L){let J=L,q;for(;(q=h())!==null;){if(J=J[q],typeof J=="number")return J;if(typeof J!="object")throw new Error("invalid huffman sequence")}return null}function c(L){let J=L,q=0;for(;J>0;){const H=h();if(H===null)return;q=q<<1|H,--J}return q}function l(L){const J=c(L);return J>=1<<L-1?J:J+(-1<<L)+1}function u(L,J){const q=Q(L.huffmanTableDC),H=q===0?0:l(q);L.pred+=H,J[0]=L.pred;let O=1;for(;O<64;){const P=Q(L.huffmanTableAC),X=P&15,$=P>>4;if(X===0){if($<15)break;O+=16}else{O+=$;const W=yA[O];J[W]=l(X),O++}}}function y(L,J){const q=Q(L.huffmanTableDC),H=q===0?0:l(q)<<w;L.pred+=H,J[0]=L.pred}function m(L,J){J[0]|=h()<<w}let f=0;function D(L,J){if(f>0){f--;return}let q=a;const H=B;for(;q<=H;){const O=Q(L.huffmanTableAC),P=O&15,X=O>>4;if(P===0){if(X<15){f=c(X)+(1<<X)-1;break}q+=16}else{q+=X;const $=yA[q];J[$]=l(P)*(1<<w),q++}}}let d=0,G;function R(L,J){let q=a;const H=B;let O=0;for(;q<=H;){const P=yA[q],X=J[P]<0?-1:1;switch(d){case 0:{const $=Q(L.huffmanTableAC),W=$&15;if(O=$>>4,W===0)O<15?(f=c(O)+(1<<O),d=4):(O=16,d=1);else{if(W!==1)throw new Error("invalid ACn encoding");G=l(W),d=O?2:3}continue}case 1:case 2:J[P]?J[P]+=(h()<<w)*X:(O--,O===0&&(d=d===2?3:0));break;case 3:J[P]?J[P]+=(h()<<w)*X:(J[P]=G<<w,d=0);break;case 4:J[P]&&(J[P]+=(h()<<w)*X);break}q++}d===4&&(f--,f===0&&(d=0))}function F(L,J,q,H,O){const P=q/I|0,X=q%I,$=P*L.v+H,W=X*L.h+O;J(L,L.blocks[$][W])}function x(L,J,q){const H=q/L.blocksPerLine|0,O=q%L.blocksPerLine;J(L,L.blocks[H][O])}const S=t.length;let Y,k,p,M,U,v;n?a===0?v=s===0?y:m:v=s===0?D:R:v=u;let N=0,b,K;S===1?K=t[0].blocksPerLine*t[0].blocksPerColumn:K=I*e.mcusPerColumn;const _=r||K;for(;N<K;){for(k=0;k<S;k++)t[k].pred=0;if(f=0,S===1)for(Y=t[0],U=0;U<_;U++)x(Y,v,N),N++;else for(U=0;U<_;U++){for(k=0;k<S;k++){Y=t[k];const{h:L,v:J}=Y;for(p=0;p<J;p++)for(M=0;M<L;M++)F(Y,v,N,p,M)}if(N++,N===K)break}if(g=0,b=o[E]<<8|o[E+1],b<65280)throw new Error("marker was not found");if(b>=65488&&b<=65495)E+=2;else break}return E-i}function xr(o,A){const e=[],{blocksPerLine:t,blocksPerColumn:r}=A,a=t<<3,B=new Int32Array(64),s=new Uint8Array(64);function w(I,n,i){const E=A.quantizationTable;let C,g,h,Q,c,l,u,y,m;const f=i;let D;for(D=0;D<64;D++)f[D]=I[D]*E[D];for(D=0;D<8;++D){const d=8*D;if(f[1+d]===0&&f[2+d]===0&&f[3+d]===0&&f[4+d]===0&&f[5+d]===0&&f[6+d]===0&&f[7+d]===0){m=EA*f[0+d]+512>>10,f[0+d]=m,f[1+d]=m,f[2+d]=m,f[3+d]=m,f[4+d]=m,f[5+d]=m,f[6+d]=m,f[7+d]=m;continue}C=EA*f[0+d]+128>>8,g=EA*f[4+d]+128>>8,h=f[2+d],Q=f[6+d],c=TA*(f[1+d]-f[7+d])+128>>8,y=TA*(f[1+d]+f[7+d])+128>>8,l=f[3+d]<<4,u=f[5+d]<<4,m=C-g+1>>1,C=C+g+1>>1,g=m,m=h*JA+Q*qA+128>>8,h=h*qA-Q*JA+128>>8,Q=m,m=c-u+1>>1,c=c+u+1>>1,u=m,m=y+l+1>>1,l=y-l+1>>1,y=m,m=C-Q+1>>1,C=C+Q+1>>1,Q=m,m=g-h+1>>1,g=g+h+1>>1,h=m,m=c*NA+y*bA+2048>>12,c=c*bA-y*NA+2048>>12,y=m,m=l*MA+u*vA+2048>>12,l=l*vA-u*MA+2048>>12,u=m,f[0+d]=C+y,f[7+d]=C-y,f[1+d]=g+u,f[6+d]=g-u,f[2+d]=h+l,f[5+d]=h-l,f[3+d]=Q+c,f[4+d]=Q-c}for(D=0;D<8;++D){const d=D;if(f[8+d]===0&&f[16+d]===0&&f[24+d]===0&&f[32+d]===0&&f[40+d]===0&&f[48+d]===0&&f[56+d]===0){m=EA*i[D+0]+8192>>14,f[0+d]=m,f[8+d]=m,f[16+d]=m,f[24+d]=m,f[32+d]=m,f[40+d]=m,f[48+d]=m,f[56+d]=m;continue}C=EA*f[0+d]+2048>>12,g=EA*f[32+d]+2048>>12,h=f[16+d],Q=f[48+d],c=TA*(f[8+d]-f[56+d])+2048>>12,y=TA*(f[8+d]+f[56+d])+2048>>12,l=f[24+d],u=f[40+d],m=C-g+1>>1,C=C+g+1>>1,g=m,m=h*JA+Q*qA+2048>>12,h=h*qA-Q*JA+2048>>12,Q=m,m=c-u+1>>1,c=c+u+1>>1,u=m,m=y+l+1>>1,l=y-l+1>>1,y=m,m=C-Q+1>>1,C=C+Q+1>>1,Q=m,m=g-h+1>>1,g=g+h+1>>1,h=m,m=c*NA+y*bA+2048>>12,c=c*bA-y*NA+2048>>12,y=m,m=l*MA+u*vA+2048>>12,l=l*vA-u*MA+2048>>12,u=m,f[0+d]=C+y,f[56+d]=C-y,f[8+d]=g+u,f[48+d]=g-u,f[16+d]=h+l,f[40+d]=h-l,f[24+d]=Q+c,f[32+d]=Q-c}for(D=0;D<64;++D){const d=128+(f[D]+8>>4);d<0?n[D]=0:d>255?n[D]=255:n[D]=d}}for(let I=0;I<r;I++){const n=I<<3;for(let i=0;i<8;i++)e.push(new Uint8Array(a));for(let i=0;i<t;i++){w(A.blocks[I][i],s,B);let E=0;const C=i<<3;for(let g=0;g<8;g++){const h=e[n+g];for(let Q=0;Q<8;Q++)h[C+Q]=s[E++]}}}return e}class Ur{constructor(){this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}resetFrames(){this.frames=[]}parse(A){let e=0;function t(){const s=A[e]<<8|A[e+1];return e+=2,s}function r(){const s=t(),w=A.subarray(e,e+s-2);return e+=w.length,w}function a(s){let w=0,I=0,n,i;for(i in s.components)s.components.hasOwnProperty(i)&&(n=s.components[i],w<n.h&&(w=n.h),I<n.v&&(I=n.v));const E=Math.ceil(s.samplesPerLine/8/w),C=Math.ceil(s.scanLines/8/I);for(i in s.components)if(s.components.hasOwnProperty(i)){n=s.components[i];const g=Math.ceil(Math.ceil(s.samplesPerLine/8)*n.h/w),h=Math.ceil(Math.ceil(s.scanLines/8)*n.v/I),Q=E*n.h,c=C*n.v,l=[];for(let u=0;u<c;u++){const y=[];for(let m=0;m<Q;m++)y.push(new Int32Array(64));l.push(y)}n.blocksPerLine=g,n.blocksPerColumn=h,n.blocks=l}s.maxH=w,s.maxV=I,s.mcusPerLine=E,s.mcusPerColumn=C}let B=t();if(B!==65496)throw new Error("SOI not found");for(B=t();B!==65497;){switch(B){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{const s=r();B===65504&&s[0]===74&&s[1]===70&&s[2]===73&&s[3]===70&&s[4]===0&&(this.jfif={version:{major:s[5],minor:s[6]},densityUnits:s[7],xDensity:s[8]<<8|s[9],yDensity:s[10]<<8|s[11],thumbWidth:s[12],thumbHeight:s[13],thumbData:s.subarray(14,14+3*s[12]*s[13])}),B===65518&&s[0]===65&&s[1]===100&&s[2]===111&&s[3]===98&&s[4]===101&&s[5]===0&&(this.adobe={version:s[6],flags0:s[7]<<8|s[8],flags1:s[9]<<8|s[10],transformCode:s[11]});break}case 65499:{const w=t()+e-2;for(;e<w;){const I=A[e++],n=new Int32Array(64);if(I>>4===0)for(let i=0;i<64;i++){const E=yA[i];n[E]=A[e++]}else if(I>>4===1)for(let i=0;i<64;i++){const E=yA[i];n[E]=t()}else throw new Error("DQT: invalid table spec");this.quantizationTables[I&15]=n}break}case 65472:case 65473:case 65474:{t();const s={extended:B===65473,progressive:B===65474,precision:A[e++],scanLines:t(),samplesPerLine:t(),components:{},componentsOrder:[]},w=A[e++];let I;for(let n=0;n<w;n++){I=A[e];const i=A[e+1]>>4,E=A[e+1]&15,C=A[e+2];s.componentsOrder.push(I),s.components[I]={h:i,v:E,quantizationIdx:C},e+=3}a(s),this.frames.push(s);break}case 65476:{const s=t();for(let w=2;w<s;){const I=A[e++],n=new Uint8Array(16);let i=0;for(let C=0;C<16;C++,e++)n[C]=A[e],i+=n[C];const E=new Uint8Array(i);for(let C=0;C<i;C++,e++)E[C]=A[e];w+=17+i,I>>4===0?this.huffmanTablesDC[I&15]=qe(n,E):this.huffmanTablesAC[I&15]=qe(n,E)}break}case 65501:t(),this.resetInterval=t();break;case 65498:{t();const s=A[e++],w=[],I=this.frames[0];for(let g=0;g<s;g++){const h=I.components[A[e++]],Q=A[e++];h.huffmanTableDC=this.huffmanTablesDC[Q>>4],h.huffmanTableAC=this.huffmanTablesAC[Q&15],w.push(h)}const n=A[e++],i=A[e++],E=A[e++],C=Rr(A,e,I,w,this.resetInterval,n,i,E>>4,E&15);e+=C;break}case 65535:A[e]!==255&&e--;break;default:if(A[e-3]===255&&A[e-2]>=192&&A[e-2]<=254){e-=3;break}throw new Error(`unknown JPEG marker ${B.toString(16)}`)}B=t()}}getResult(){const{frames:A}=this;if(this.frames.length===0)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let n=0;n<this.frames.length;n++){const i=this.frames[n].components;for(const E of Object.keys(i))i[E].quantizationTable=this.quantizationTables[i[E].quantizationIdx],delete i[E].quantizationIdx}const e=A[0],{components:t,componentsOrder:r}=e,a=[],B=e.samplesPerLine,s=e.scanLines;for(let n=0;n<r.length;n++){const i=t[r[n]];a.push({lines:xr(e,i),scaleX:i.h/e.maxH,scaleY:i.v/e.maxV})}const w=new Uint8Array(B*s*a.length);let I=0;for(let n=0;n<s;++n)for(let i=0;i<B;++i)for(let E=0;E<a.length;++E){const C=a[E];w[I]=C.lines[0|n*C.scaleY][0|i*C.scaleX],++I}return w}}class Lr extends BA{constructor(A){super(),this.reader=new Ur,A.JPEGTables&&this.reader.parse(A.JPEGTables)}decodeBlock(A){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(A)),this.reader.getResult().buffer}}const vr=Object.freeze(Object.defineProperty({__proto__:null,default:Lr},Symbol.toStringTag,{value:"Module"}));class Mr extends BA{decodeBlock(A){return Ye(new Uint8Array(A)).buffer}}const br=Object.freeze(Object.defineProperty({__proto__:null,default:Mr},Symbol.toStringTag,{value:"Module"}));class Nr extends BA{decodeBlock(A){const e=new DataView(A),t=[];for(let r=0;r<A.byteLength;++r){let a=e.getInt8(r);if(a<0){const B=e.getUint8(r+1);a=-a;for(let s=0;s<=a;++s)t.push(B);r+=1}else{for(let B=0;B<=a;++B)t.push(e.getUint8(r+B+1));r+=a+1}}return new Uint8Array(t).buffer}}const qr=Object.freeze(Object.defineProperty({__proto__:null,default:Nr},Symbol.toStringTag,{value:"Module"}));var $A={exports:{}},Je;function Jr(){return Je||(Je=1,(function(o){/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */(function(){var A=(function(){var a={};a.defaultNoDataValue=-34027999387901484e22,a.decode=function(i,E){E=E||{};var C=E.encodedMaskData||E.encodedMaskData===null,g=I(i,E.inputOffset||0,C),h=E.noDataValue!==null?E.noDataValue:a.defaultNoDataValue,Q=B(g,E.pixelType||Float32Array,E.encodedMaskData,h,E.returnMask),c={width:g.width,height:g.height,pixelData:Q.resultPixels,minValue:Q.minValue,maxValue:g.pixels.maxValue,noDataValue:h};return Q.resultMask&&(c.maskData=Q.resultMask),E.returnEncodedMask&&g.mask&&(c.encodedMaskData=g.mask.bitset?g.mask.bitset:null),E.returnFileInfo&&(c.fileInfo=s(g),E.computeUsedBitDepths&&(c.fileInfo.bitDepths=w(g))),c};var B=function(i,E,C,g,h){var Q=0,c=i.pixels.numBlocksX,l=i.pixels.numBlocksY,u=Math.floor(i.width/c),y=Math.floor(i.height/l),m=2*i.maxZError,f=Number.MAX_VALUE,D;C=C||(i.mask?i.mask.bitset:null);var d,G;d=new E(i.width*i.height),h&&C&&(G=new Uint8Array(i.width*i.height));for(var R=new Float32Array(u*y),F,x,S=0;S<=l;S++){var Y=S!==l?y:i.height%l;if(Y!==0)for(var k=0;k<=c;k++){var p=k!==c?u:i.width%c;if(p!==0){var M=S*i.width*y+k*u,U=i.width-p,v=i.pixels.blocks[Q],N,b,K;v.encoding<2?(v.encoding===0?N=v.rawData:(n(v.stuffedData,v.bitsPerPixel,v.numValidPixels,v.offset,m,R,i.pixels.maxValue),N=R),b=0):v.encoding===2?K=0:K=v.offset;var _;if(C)for(x=0;x<Y;x++){for(M&7&&(_=C[M>>3],_<<=M&7),F=0;F<p;F++)M&7||(_=C[M>>3]),_&128?(G&&(G[M]=1),D=v.encoding<2?N[b++]:K,f=f>D?D:f,d[M++]=D):(G&&(G[M]=0),d[M++]=g),_<<=1;M+=U}else if(v.encoding<2)for(x=0;x<Y;x++){for(F=0;F<p;F++)D=N[b++],f=f>D?D:f,d[M++]=D;M+=U}else for(f=f>K?K:f,x=0;x<Y;x++){for(F=0;F<p;F++)d[M++]=K;M+=U}if(v.encoding===1&&b!==v.numValidPixels)throw"Block and Mask do not match";Q++}}}return{resultPixels:d,resultMask:G,minValue:f}},s=function(i){return{fileIdentifierString:i.fileIdentifierString,fileVersion:i.fileVersion,imageType:i.imageType,height:i.height,width:i.width,maxZError:i.maxZError,eofOffset:i.eofOffset,mask:i.mask?{numBlocksX:i.mask.numBlocksX,numBlocksY:i.mask.numBlocksY,numBytes:i.mask.numBytes,maxValue:i.mask.maxValue}:null,pixels:{numBlocksX:i.pixels.numBlocksX,numBlocksY:i.pixels.numBlocksY,numBytes:i.pixels.numBytes,maxValue:i.pixels.maxValue,noDataValue:i.noDataValue}}},w=function(i){for(var E=i.pixels.numBlocksX*i.pixels.numBlocksY,C={},g=0;g<E;g++){var h=i.pixels.blocks[g];h.encoding===0?C.float32=!0:h.encoding===1?C[h.bitsPerPixel]=!0:C[0]=!0}return Object.keys(C)},I=function(i,E,C){var g={},h=new Uint8Array(i,E,10);if(g.fileIdentifierString=String.fromCharCode.apply(null,h),g.fileIdentifierString.trim()!=="CntZImage")throw"Unexpected file identifier string: "+g.fileIdentifierString;E+=10;var Q=new DataView(i,E,24);if(g.fileVersion=Q.getInt32(0,!0),g.imageType=Q.getInt32(4,!0),g.height=Q.getUint32(8,!0),g.width=Q.getUint32(12,!0),g.maxZError=Q.getFloat64(16,!0),E+=24,!C)if(Q=new DataView(i,E,16),g.mask={},g.mask.numBlocksY=Q.getUint32(0,!0),g.mask.numBlocksX=Q.getUint32(4,!0),g.mask.numBytes=Q.getUint32(8,!0),g.mask.maxValue=Q.getFloat32(12,!0),E+=16,g.mask.numBytes>0){var c=new Uint8Array(Math.ceil(g.width*g.height/8));Q=new DataView(i,E,g.mask.numBytes);var l=Q.getInt16(0,!0),u=2,y=0;do{if(l>0)for(;l--;)c[y++]=Q.getUint8(u++);else{var m=Q.getUint8(u++);for(l=-l;l--;)c[y++]=m}l=Q.getInt16(u,!0),u+=2}while(u<g.mask.numBytes);if(l!==-32768||y<c.length)throw"Unexpected end of mask RLE encoding";g.mask.bitset=c,E+=g.mask.numBytes}else(g.mask.numBytes|g.mask.numBlocksY|g.mask.maxValue)===0&&(g.mask.bitset=new Uint8Array(Math.ceil(g.width*g.height/8)));Q=new DataView(i,E,16),g.pixels={},g.pixels.numBlocksY=Q.getUint32(0,!0),g.pixels.numBlocksX=Q.getUint32(4,!0),g.pixels.numBytes=Q.getUint32(8,!0),g.pixels.maxValue=Q.getFloat32(12,!0),E+=16;var f=g.pixels.numBlocksX,D=g.pixels.numBlocksY,d=f+(g.width%f>0?1:0),G=D+(g.height%D>0?1:0);g.pixels.blocks=new Array(d*G);for(var R=0,F=0;F<G;F++)for(var x=0;x<d;x++){var S=0,Y=i.byteLength-E;Q=new DataView(i,E,Math.min(10,Y));var k={};g.pixels.blocks[R++]=k;var p=Q.getUint8(0);if(S++,k.encoding=p&63,k.encoding>3)throw"Invalid block encoding ("+k.encoding+")";if(k.encoding===2){E++;continue}if(p!==0&&p!==2){if(p>>=6,k.offsetType=p,p===2)k.offset=Q.getInt8(1),S++;else if(p===1)k.offset=Q.getInt16(1,!0),S+=2;else if(p===0)k.offset=Q.getFloat32(1,!0),S+=4;else throw"Invalid block offset type";if(k.encoding===1)if(p=Q.getUint8(S),S++,k.bitsPerPixel=p&63,p>>=6,k.numValidPixelsType=p,p===2)k.numValidPixels=Q.getUint8(S),S++;else if(p===1)k.numValidPixels=Q.getUint16(S,!0),S+=2;else if(p===0)k.numValidPixels=Q.getUint32(S,!0),S+=4;else throw"Invalid valid pixel count type"}if(E+=S,k.encoding!==3){var M,U;if(k.encoding===0){var v=(g.pixels.numBytes-1)/4;if(v!==Math.floor(v))throw"uncompressed block has invalid length";M=new ArrayBuffer(v*4),U=new Uint8Array(M),U.set(new Uint8Array(i,E,v*4));var N=new Float32Array(M);k.rawData=N,E+=v*4}else if(k.encoding===1){var b=Math.ceil(k.numValidPixels*k.bitsPerPixel/8),K=Math.ceil(b/4);M=new ArrayBuffer(K*4),U=new Uint8Array(M),U.set(new Uint8Array(i,E,b)),k.stuffedData=new Uint32Array(M),E+=b}}}return g.eofOffset=E,g},n=function(i,E,C,g,h,Q,c){var l=(1<<E)-1,u=0,y,m=0,f,D,d=Math.ceil((c-g)/h),G=i.length*4-Math.ceil(E*C/8);for(i[i.length-1]<<=8*G,y=0;y<C;y++){if(m===0&&(D=i[u++],m=32),m>=E)f=D>>>m-E&l,m-=E;else{var R=E-m;f=(D&l)<<R&l,D=i[u++],m=32-R,f+=D>>>m}Q[y]=f<d?g+f*h:c}return Q};return a})(),e=(function(){var a={unstuff:function(I,n,i,E,C,g,h,Q){var c=(1<<i)-1,l=0,u,y=0,m,f,D,d,G=I.length*4-Math.ceil(i*E/8);if(I[I.length-1]<<=8*G,C)for(u=0;u<E;u++)y===0&&(f=I[l++],y=32),y>=i?(m=f>>>y-i&c,y-=i):(D=i-y,m=(f&c)<<D&c,f=I[l++],y=32-D,m+=f>>>y),n[u]=C[m];else for(d=Math.ceil((Q-g)/h),u=0;u<E;u++)y===0&&(f=I[l++],y=32),y>=i?(m=f>>>y-i&c,y-=i):(D=i-y,m=(f&c)<<D&c,f=I[l++],y=32-D,m+=f>>>y),n[u]=m<d?g+m*h:Q},unstuffLUT:function(I,n,i,E,C,g){var h=(1<<n)-1,Q=0,c=0,l=0,u=0,y=0,m,f=[],D=I.length*4-Math.ceil(n*i/8);I[I.length-1]<<=8*D;var d=Math.ceil((g-E)/C);for(c=0;c<i;c++)u===0&&(m=I[Q++],u=32),u>=n?(y=m>>>u-n&h,u-=n):(l=n-u,y=(m&h)<<l&h,m=I[Q++],u=32-l,y+=m>>>u),f[c]=y<d?E+y*C:g;return f.unshift(E),f},unstuff2:function(I,n,i,E,C,g,h,Q){var c=(1<<i)-1,l=0,u,y=0,m=0,f,D,d;if(C)for(u=0;u<E;u++)y===0&&(D=I[l++],y=32,m=0),y>=i?(f=D>>>m&c,y-=i,m+=i):(d=i-y,f=D>>>m&c,D=I[l++],y=32-d,f|=(D&(1<<d)-1)<<i-d,m=d),n[u]=C[f];else{var G=Math.ceil((Q-g)/h);for(u=0;u<E;u++)y===0&&(D=I[l++],y=32,m=0),y>=i?(f=D>>>m&c,y-=i,m+=i):(d=i-y,f=D>>>m&c,D=I[l++],y=32-d,f|=(D&(1<<d)-1)<<i-d,m=d),n[u]=f<G?g+f*h:Q}return n},unstuffLUT2:function(I,n,i,E,C,g){var h=(1<<n)-1,Q=0,c=0,l=0,u=0,y=0,m=0,f,D=[],d=Math.ceil((g-E)/C);for(c=0;c<i;c++)u===0&&(f=I[Q++],u=32,m=0),u>=n?(y=f>>>m&h,u-=n,m+=n):(l=n-u,y=f>>>m&h,f=I[Q++],u=32-l,y|=(f&(1<<l)-1)<<n-l,m=l),D[c]=y<d?E+y*C:g;return D.unshift(E),D},originalUnstuff:function(I,n,i,E){var C=(1<<i)-1,g=0,h,Q=0,c,l,u,y=I.length*4-Math.ceil(i*E/8);for(I[I.length-1]<<=8*y,h=0;h<E;h++)Q===0&&(l=I[g++],Q=32),Q>=i?(c=l>>>Q-i&C,Q-=i):(u=i-Q,c=(l&C)<<u&C,l=I[g++],Q=32-u,c+=l>>>Q),n[h]=c;return n},originalUnstuff2:function(I,n,i,E){var C=(1<<i)-1,g=0,h,Q=0,c=0,l,u,y;for(h=0;h<E;h++)Q===0&&(u=I[g++],Q=32,c=0),Q>=i?(l=u>>>c&C,Q-=i,c+=i):(y=i-Q,l=u>>>c&C,u=I[g++],Q=32-y,l|=(u&(1<<y)-1)<<i-y,c=y),n[h]=l;return n}},B={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(I){for(var n=65535,i=65535,E=I.length,C=Math.floor(E/2),g=0;C;){var h=C>=359?359:C;C-=h;do n+=I[g++]<<8,i+=n+=I[g++];while(--h);n=(n&65535)+(n>>>16),i=(i&65535)+(i>>>16)}return E&1&&(i+=n+=I[g]<<8),n=(n&65535)+(n>>>16),i=(i&65535)+(i>>>16),(i<<16|n)>>>0},readHeaderInfo:function(I,n){var i=n.ptr,E=new Uint8Array(I,i,6),C={};if(C.fileIdentifierString=String.fromCharCode.apply(null,E),C.fileIdentifierString.lastIndexOf("Lerc2",0)!==0)throw"Unexpected file identifier string (expect Lerc2 ): "+C.fileIdentifierString;i+=6;var g=new DataView(I,i,8),h=g.getInt32(0,!0);C.fileVersion=h,i+=4,h>=3&&(C.checksum=g.getUint32(4,!0),i+=4),g=new DataView(I,i,12),C.height=g.getUint32(0,!0),C.width=g.getUint32(4,!0),i+=8,h>=4?(C.numDims=g.getUint32(8,!0),i+=4):C.numDims=1,g=new DataView(I,i,40),C.numValidPixel=g.getUint32(0,!0),C.microBlockSize=g.getInt32(4,!0),C.blobSize=g.getInt32(8,!0),C.imageType=g.getInt32(12,!0),C.maxZError=g.getFloat64(16,!0),C.zMin=g.getFloat64(24,!0),C.zMax=g.getFloat64(32,!0),i+=40,n.headerInfo=C,n.ptr=i;var Q,c;if(h>=3&&(c=h>=4?52:48,Q=this.computeChecksumFletcher32(new Uint8Array(I,i-c,C.blobSize-14)),Q!==C.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(I,n){var i=n.headerInfo,E=this.getDataTypeArray(i.imageType),C=i.numDims*this.getDataTypeSize(i.imageType),g=this.readSubArray(I,n.ptr,E,C),h=this.readSubArray(I,n.ptr+C,E,C);n.ptr+=2*C;var Q,c=!0;for(Q=0;Q<i.numDims;Q++)if(g[Q]!==h[Q]){c=!1;break}return i.minValues=g,i.maxValues=h,c},readSubArray:function(I,n,i,E){var C;if(i===Uint8Array)C=new Uint8Array(I,n,E);else{var g=new ArrayBuffer(E),h=new Uint8Array(g);h.set(new Uint8Array(I,n,E)),C=new i(g)}return C},readMask:function(I,n){var i=n.ptr,E=n.headerInfo,C=E.width*E.height,g=E.numValidPixel,h=new DataView(I,i,4),Q={};if(Q.numBytes=h.getUint32(0,!0),i+=4,(g===0||C===g)&&Q.numBytes!==0)throw"invalid mask";var c,l;if(g===0)c=new Uint8Array(Math.ceil(C/8)),Q.bitset=c,l=new Uint8Array(C),n.pixels.resultMask=l,i+=Q.numBytes;else if(Q.numBytes>0){c=new Uint8Array(Math.ceil(C/8)),h=new DataView(I,i,Q.numBytes);var u=h.getInt16(0,!0),y=2,m=0,f=0;do{if(u>0)for(;u--;)c[m++]=h.getUint8(y++);else for(f=h.getUint8(y++),u=-u;u--;)c[m++]=f;u=h.getInt16(y,!0),y+=2}while(y<Q.numBytes);if(u!==-32768||m<c.length)throw"Unexpected end of mask RLE encoding";l=new Uint8Array(C);var D=0,d=0;for(d=0;d<C;d++)d&7?(D=c[d>>3],D<<=d&7):D=c[d>>3],D&128&&(l[d]=1);n.pixels.resultMask=l,Q.bitset=c,i+=Q.numBytes}return n.ptr=i,n.mask=Q,!0},readDataOneSweep:function(I,n,i,E){var C=n.ptr,g=n.headerInfo,h=g.numDims,Q=g.width*g.height,c=g.imageType,l=g.numValidPixel*B.getDataTypeSize(c)*h,u,y=n.pixels.resultMask;if(i===Uint8Array)u=new Uint8Array(I,C,l);else{var m=new ArrayBuffer(l),f=new Uint8Array(m);f.set(new Uint8Array(I,C,l)),u=new i(m)}if(u.length===Q*h)E?n.pixels.resultPixels=B.swapDimensionOrder(u,Q,h,i,!0):n.pixels.resultPixels=u;else{n.pixels.resultPixels=new i(Q*h);var D=0,d=0,G=0,R=0;if(h>1){if(E){for(d=0;d<Q;d++)if(y[d])for(R=d,G=0;G<h;G++,R+=Q)n.pixels.resultPixels[R]=u[D++]}else for(d=0;d<Q;d++)if(y[d])for(R=d*h,G=0;G<h;G++)n.pixels.resultPixels[R+G]=u[D++]}else for(d=0;d<Q;d++)y[d]&&(n.pixels.resultPixels[d]=u[D++])}return C+=l,n.ptr=C,!0},readHuffmanTree:function(I,n){var i=this.HUFFMAN_LUT_BITS_MAX,E=new DataView(I,n.ptr,16);n.ptr+=16;var C=E.getInt32(0,!0);if(C<2)throw"unsupported Huffman version";var g=E.getInt32(4,!0),h=E.getInt32(8,!0),Q=E.getInt32(12,!0);if(h>=Q)return!1;var c=new Uint32Array(Q-h);B.decodeBits(I,n,c);var l=[],u,y,m,f;for(u=h;u<Q;u++)y=u-(u<g?0:g),l[y]={first:c[u-h],second:null};var D=I.byteLength-n.ptr,d=Math.ceil(D/4),G=new ArrayBuffer(d*4),R=new Uint8Array(G);R.set(new Uint8Array(I,n.ptr,D));var F=new Uint32Array(G),x=0,S,Y=0;for(S=F[0],u=h;u<Q;u++)y=u-(u<g?0:g),f=l[y].first,f>0&&(l[y].second=S<<x>>>32-f,32-x>=f?(x+=f,x===32&&(x=0,Y++,S=F[Y])):(x+=f-32,Y++,S=F[Y],l[y].second|=S>>>32-x));var k=0,p=0,M=new s;for(u=0;u<l.length;u++)l[u]!==void 0&&(k=Math.max(k,l[u].first));k>=i?p=i:p=k;var U=[],v,N,b,K,_,L;for(u=h;u<Q;u++)if(y=u-(u<g?0:g),f=l[y].first,f>0)if(v=[f,y],f<=p)for(N=l[y].second<<p-f,b=1<<p-f,m=0;m<b;m++)U[N|m]=v;else for(N=l[y].second,L=M,K=f-1;K>=0;K--)_=N>>>K&1,_?(L.right||(L.right=new s),L=L.right):(L.left||(L.left=new s),L=L.left),K===0&&!L.val&&(L.val=v[1]);return{decodeLut:U,numBitsLUTQick:p,numBitsLUT:k,tree:M,stuffedData:F,srcPtr:Y,bitPos:x}},readHuffman:function(I,n,i,E){var C=n.headerInfo,g=C.numDims,h=n.headerInfo.height,Q=n.headerInfo.width,c=Q*h,l=this.readHuffmanTree(I,n),u=l.decodeLut,y=l.tree,m=l.stuffedData,f=l.srcPtr,D=l.bitPos,d=l.numBitsLUTQick,G=l.numBitsLUT,R=n.headerInfo.imageType===0?128:0,F,x,S,Y=n.pixels.resultMask,k,p,M,U,v,N,b,K=0;D>0&&(f++,D=0);var _=m[f],L=n.encodeMode===1,J=new i(c*g),q=J,H;if(g<2||L){for(H=0;H<g;H++)if(g>1&&(q=new i(J.buffer,c*H,c),K=0),n.headerInfo.numValidPixel===Q*h)for(N=0,U=0;U<h;U++)for(v=0;v<Q;v++,N++){if(x=0,k=_<<D>>>32-d,p=k,32-D<d&&(k|=m[f+1]>>>64-D-d,p=k),u[p])x=u[p][1],D+=u[p][0];else for(k=_<<D>>>32-G,p=k,32-D<G&&(k|=m[f+1]>>>64-D-G,p=k),F=y,b=0;b<G;b++)if(M=k>>>G-b-1&1,F=M?F.right:F.left,!(F.left||F.right)){x=F.val,D=D+b+1;break}D>=32&&(D-=32,f++,_=m[f]),S=x-R,L?(v>0?S+=K:U>0?S+=q[N-Q]:S+=K,S&=255,q[N]=S,K=S):q[N]=S}else for(N=0,U=0;U<h;U++)for(v=0;v<Q;v++,N++)if(Y[N]){if(x=0,k=_<<D>>>32-d,p=k,32-D<d&&(k|=m[f+1]>>>64-D-d,p=k),u[p])x=u[p][1],D+=u[p][0];else for(k=_<<D>>>32-G,p=k,32-D<G&&(k|=m[f+1]>>>64-D-G,p=k),F=y,b=0;b<G;b++)if(M=k>>>G-b-1&1,F=M?F.right:F.left,!(F.left||F.right)){x=F.val,D=D+b+1;break}D>=32&&(D-=32,f++,_=m[f]),S=x-R,L?(v>0&&Y[N-1]?S+=K:U>0&&Y[N-Q]?S+=q[N-Q]:S+=K,S&=255,q[N]=S,K=S):q[N]=S}}else for(N=0,U=0;U<h;U++)for(v=0;v<Q;v++)if(N=U*Q+v,!Y||Y[N])for(H=0;H<g;H++,N+=c){if(x=0,k=_<<D>>>32-d,p=k,32-D<d&&(k|=m[f+1]>>>64-D-d,p=k),u[p])x=u[p][1],D+=u[p][0];else for(k=_<<D>>>32-G,p=k,32-D<G&&(k|=m[f+1]>>>64-D-G,p=k),F=y,b=0;b<G;b++)if(M=k>>>G-b-1&1,F=M?F.right:F.left,!(F.left||F.right)){x=F.val,D=D+b+1;break}D>=32&&(D-=32,f++,_=m[f]),S=x-R,q[N]=S}n.ptr=n.ptr+(f+1)*4+(D>0?4:0),n.pixels.resultPixels=J,g>1&&!E&&(n.pixels.resultPixels=B.swapDimensionOrder(J,c,g,i))},decodeBits:function(I,n,i,E,C){{var g=n.headerInfo,h=g.fileVersion,Q=0,c=I.byteLength-n.ptr>=5?5:I.byteLength-n.ptr,l=new DataView(I,n.ptr,c),u=l.getUint8(0);Q++;var y=u>>6,m=y===0?4:3-y,f=(u&32)>0,D=u&31,d=0;if(m===1)d=l.getUint8(Q),Q++;else if(m===2)d=l.getUint16(Q,!0),Q+=2;else if(m===4)d=l.getUint32(Q,!0),Q+=4;else throw"Invalid valid pixel count type";var G=2*g.maxZError,R,F,x,S,Y,k,p,M,U,v=g.numDims>1?g.maxValues[C]:g.zMax;if(f){for(n.counter.lut++,M=l.getUint8(Q),Q++,S=Math.ceil((M-1)*D/8),Y=Math.ceil(S/4),F=new ArrayBuffer(Y*4),x=new Uint8Array(F),n.ptr+=Q,x.set(new Uint8Array(I,n.ptr,S)),p=new Uint32Array(F),n.ptr+=S,U=0;M-1>>>U;)U++;S=Math.ceil(d*U/8),Y=Math.ceil(S/4),F=new ArrayBuffer(Y*4),x=new Uint8Array(F),x.set(new Uint8Array(I,n.ptr,S)),R=new Uint32Array(F),n.ptr+=S,h>=3?k=a.unstuffLUT2(p,D,M-1,E,G,v):k=a.unstuffLUT(p,D,M-1,E,G,v),h>=3?a.unstuff2(R,i,U,d,k):a.unstuff(R,i,U,d,k)}else n.counter.bitstuffer++,U=D,n.ptr+=Q,U>0&&(S=Math.ceil(d*U/8),Y=Math.ceil(S/4),F=new ArrayBuffer(Y*4),x=new Uint8Array(F),x.set(new Uint8Array(I,n.ptr,S)),R=new Uint32Array(F),n.ptr+=S,h>=3?E==null?a.originalUnstuff2(R,i,U,d):a.unstuff2(R,i,U,d,!1,E,G,v):E==null?a.originalUnstuff(R,i,U,d):a.unstuff(R,i,U,d,!1,E,G,v))}},readTiles:function(I,n,i,E){var C=n.headerInfo,g=C.width,h=C.height,Q=g*h,c=C.microBlockSize,l=C.imageType,u=B.getDataTypeSize(l),y=Math.ceil(g/c),m=Math.ceil(h/c);n.pixels.numBlocksY=m,n.pixels.numBlocksX=y,n.pixels.ptr=0;var f=0,D=0,d=0,G=0,R=0,F=0,x=0,S=0,Y=0,k=0,p=0,M=0,U=0,v=0,N=0,b=0,K,_,L,J,q,H,O=new i(c*c),P=h%c||c,X=g%c||c,$,W,kA=C.numDims,sA,eA=n.pixels.resultMask,AA=n.pixels.resultPixels,It=C.fileVersion,he=It>=5?14:15,oA,KA=C.zMax,aA;for(d=0;d<m;d++)for(R=d!==m-1?c:P,G=0;G<y;G++)for(F=G!==y-1?c:X,p=d*g*c+G*c,M=g-F,sA=0;sA<kA;sA++){if(kA>1?(aA=AA,p=d*g*c+G*c,AA=new i(n.pixels.resultPixels.buffer,Q*sA*u,Q),KA=C.maxValues[sA]):aA=null,x=I.byteLength-n.ptr,K=new DataView(I,n.ptr,Math.min(10,x)),_={},b=0,S=K.getUint8(0),b++,oA=C.fileVersion>=5?S&4:0,Y=S>>6&255,k=S>>2&he,k!==(G*c>>3&he)||oA&&sA===0)throw"integrity issue";if(H=S&3,H>3)throw n.ptr+=b,"Invalid block encoding ("+H+")";if(H===2){if(oA)if(eA)for(f=0;f<R;f++)for(D=0;D<F;D++)eA[p]&&(AA[p]=aA[p]),p++;else for(f=0;f<R;f++)for(D=0;D<F;D++)AA[p]=aA[p],p++;n.counter.constant++,n.ptr+=b;continue}else if(H===0){if(oA)throw"integrity issue";if(n.counter.uncompressed++,n.ptr+=b,U=R*F*u,v=I.byteLength-n.ptr,U=U<v?U:v,L=new ArrayBuffer(U%u===0?U:U+u-U%u),J=new Uint8Array(L),J.set(new Uint8Array(I,n.ptr,U)),q=new i(L),N=0,eA)for(f=0;f<R;f++){for(D=0;D<F;D++)eA[p]&&(AA[p]=q[N++]),p++;p+=M}else for(f=0;f<R;f++){for(D=0;D<F;D++)AA[p++]=q[N++];p+=M}n.ptr+=N*u}else if($=B.getDataTypeUsed(oA&&l<6?4:l,Y),W=B.getOnePixel(_,b,$,K),b+=B.getDataTypeSize($),H===3)if(n.ptr+=b,n.counter.constantoffset++,eA)for(f=0;f<R;f++){for(D=0;D<F;D++)eA[p]&&(AA[p]=oA?Math.min(KA,aA[p]+W):W),p++;p+=M}else for(f=0;f<R;f++){for(D=0;D<F;D++)AA[p]=oA?Math.min(KA,aA[p]+W):W,p++;p+=M}else if(n.ptr+=b,B.decodeBits(I,n,O,W,sA),b=0,oA)if(eA)for(f=0;f<R;f++){for(D=0;D<F;D++)eA[p]&&(AA[p]=O[b++]+aA[p]),p++;p+=M}else for(f=0;f<R;f++){for(D=0;D<F;D++)AA[p]=O[b++]+aA[p],p++;p+=M}else if(eA)for(f=0;f<R;f++){for(D=0;D<F;D++)eA[p]&&(AA[p]=O[b++]),p++;p+=M}else for(f=0;f<R;f++){for(D=0;D<F;D++)AA[p++]=O[b++];p+=M}}kA>1&&!E&&(n.pixels.resultPixels=B.swapDimensionOrder(n.pixels.resultPixels,Q,kA,i))},formatFileInfo:function(I){return{fileIdentifierString:I.headerInfo.fileIdentifierString,fileVersion:I.headerInfo.fileVersion,imageType:I.headerInfo.imageType,height:I.headerInfo.height,width:I.headerInfo.width,numValidPixel:I.headerInfo.numValidPixel,microBlockSize:I.headerInfo.microBlockSize,blobSize:I.headerInfo.blobSize,maxZError:I.headerInfo.maxZError,pixelType:B.getPixelType(I.headerInfo.imageType),eofOffset:I.eofOffset,mask:I.mask?{numBytes:I.mask.numBytes}:null,pixels:{numBlocksX:I.pixels.numBlocksX,numBlocksY:I.pixels.numBlocksY,maxValue:I.headerInfo.zMax,minValue:I.headerInfo.zMin,noDataValue:I.noDataValue}}},constructConstantSurface:function(I,n){var i=I.headerInfo.zMax,E=I.headerInfo.zMin,C=I.headerInfo.maxValues,g=I.headerInfo.numDims,h=I.headerInfo.height*I.headerInfo.width,Q=0,c=0,l=0,u=I.pixels.resultMask,y=I.pixels.resultPixels;if(u)if(g>1){if(n)for(Q=0;Q<g;Q++)for(l=Q*h,i=C[Q],c=0;c<h;c++)u[c]&&(y[l+c]=i);else for(c=0;c<h;c++)if(u[c])for(l=c*g,Q=0;Q<g;Q++)y[l+g]=C[Q]}else for(c=0;c<h;c++)u[c]&&(y[c]=i);else if(g>1&&E!==i)if(n)for(Q=0;Q<g;Q++)for(l=Q*h,i=C[Q],c=0;c<h;c++)y[l+c]=i;else for(c=0;c<h;c++)for(l=c*g,Q=0;Q<g;Q++)y[l+Q]=C[Q];else for(c=0;c<h*g;c++)y[c]=i},getDataTypeArray:function(I){var n;switch(I){case 0:n=Int8Array;break;case 1:n=Uint8Array;break;case 2:n=Int16Array;break;case 3:n=Uint16Array;break;case 4:n=Int32Array;break;case 5:n=Uint32Array;break;case 6:n=Float32Array;break;case 7:n=Float64Array;break;default:n=Float32Array}return n},getPixelType:function(I){var n;switch(I){case 0:n="S8";break;case 1:n="U8";break;case 2:n="S16";break;case 3:n="U16";break;case 4:n="S32";break;case 5:n="U32";break;case 6:n="F32";break;case 7:n="F64";break;default:n="F32"}return n},isValidPixelValue:function(I,n){if(n==null)return!1;var i;switch(I){case 0:i=n>=-128&&n<=127;break;case 1:i=n>=0&&n<=255;break;case 2:i=n>=-32768&&n<=32767;break;case 3:i=n>=0&&n<=65536;break;case 4:i=n>=-2147483648&&n<=2147483647;break;case 5:i=n>=0&&n<=4294967296;break;case 6:i=n>=-34027999387901484e22&&n<=34027999387901484e22;break;case 7:i=n>=-17976931348623157e292&&n<=17976931348623157e292;break;default:i=!1}return i},getDataTypeSize:function(I){var n=0;switch(I){case 0:case 1:n=1;break;case 2:case 3:n=2;break;case 4:case 5:case 6:n=4;break;case 7:n=8;break;default:n=I}return n},getDataTypeUsed:function(I,n){var i=I;switch(I){case 2:case 4:i=I-n;break;case 3:case 5:i=I-2*n;break;case 6:n===0?i=I:n===1?i=2:i=1;break;case 7:n===0?i=I:i=I-2*n+1;break;default:i=I;break}return i},getOnePixel:function(I,n,i,E){var C=0;switch(i){case 0:C=E.getInt8(n);break;case 1:C=E.getUint8(n);break;case 2:C=E.getInt16(n,!0);break;case 3:C=E.getUint16(n,!0);break;case 4:C=E.getInt32(n,!0);break;case 5:C=E.getUInt32(n,!0);break;case 6:C=E.getFloat32(n,!0);break;case 7:C=E.getFloat64(n,!0);break;default:throw"the decoder does not understand this pixel type"}return C},swapDimensionOrder:function(I,n,i,E,C){var g=0,h=0,Q=0,c=0,l=I;if(i>1)if(l=new E(n*i),C)for(g=0;g<n;g++)for(c=g,Q=0;Q<i;Q++,c+=n)l[c]=I[h++];else for(g=0;g<n;g++)for(c=g,Q=0;Q<i;Q++,c+=n)l[h++]=I[c];return l}},s=function(I,n,i){this.val=I,this.left=n,this.right=i},w={decode:function(I,n){n=n||{};var i=n.noDataValue,E=0,C={};if(C.ptr=n.inputOffset||0,C.pixels={},!!B.readHeaderInfo(I,C)){var g=C.headerInfo,h=g.fileVersion,Q=B.getDataTypeArray(g.imageType);if(h>5)throw"unsupported lerc version 2."+h;B.readMask(I,C),g.numValidPixel!==g.width*g.height&&!C.pixels.resultMask&&(C.pixels.resultMask=n.maskData);var c=g.width*g.height;C.pixels.resultPixels=new Q(c*g.numDims),C.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l=!n.returnPixelInterleavedDims;if(g.numValidPixel!==0)if(g.zMax===g.zMin)B.constructConstantSurface(C,l);else if(h>=4&&B.checkMinMaxRanges(I,C))B.constructConstantSurface(C,l);else{var u=new DataView(I,C.ptr,2),y=u.getUint8(0);if(C.ptr++,y)B.readDataOneSweep(I,C,Q,l);else if(h>1&&g.imageType<=1&&Math.abs(g.maxZError-.5)<1e-5){var m=u.getUint8(1);if(C.ptr++,C.encodeMode=m,m>2||h<4&&m>1)throw"Invalid Huffman flag "+m;m?B.readHuffman(I,C,Q,l):B.readTiles(I,C,Q,l)}else B.readTiles(I,C,Q,l)}C.eofOffset=C.ptr;var f;n.inputOffset?(f=C.headerInfo.blobSize+n.inputOffset-C.ptr,Math.abs(f)>=1&&(C.eofOffset=n.inputOffset+C.headerInfo.blobSize)):(f=C.headerInfo.blobSize-C.ptr,Math.abs(f)>=1&&(C.eofOffset=C.headerInfo.blobSize));var D={width:g.width,height:g.height,pixelData:C.pixels.resultPixels,minValue:g.zMin,maxValue:g.zMax,validPixelCount:g.numValidPixel,dimCount:g.numDims,dimStats:{minValues:g.minValues,maxValues:g.maxValues},maskData:C.pixels.resultMask};if(C.pixels.resultMask&&B.isValidPixelValue(g.imageType,i)){var d=C.pixels.resultMask;for(E=0;E<c;E++)d[E]||(D.pixelData[E]=i);D.noDataValue=i}return C.noDataValue=i,n.returnFileInfo&&(D.fileInfo=B.formatFileInfo(C)),D}},getBandCount:function(I){var n=0,i=0,E={};for(E.ptr=0,E.pixels={};i<I.byteLength-58;)B.readHeaderInfo(I,E),i+=E.headerInfo.blobSize,n++,E.ptr=i;return n}};return w})(),t=(function(){var a=new ArrayBuffer(4),B=new Uint8Array(a),s=new Uint32Array(a);return s[0]=1,B[0]===1})(),r={decode:function(a,B){if(!t)throw"Big endian system is not supported.";B=B||{};var s=B.inputOffset||0,w=new Uint8Array(a,s,10),I=String.fromCharCode.apply(null,w),n,i;if(I.trim()==="CntZImage")n=A,i=1;else if(I.substring(0,5)==="Lerc2")n=e,i=2;else throw"Unexpected file identifier string: "+I;for(var E=0,C=a.byteLength-10,g,h=[],Q,c,l={width:0,height:0,pixels:[],pixelType:B.pixelType,mask:null,statistics:[]},u=0;s<C;){var y=n.decode(a,{inputOffset:s,encodedMaskData:g,maskData:c,returnMask:E===0,returnEncodedMask:E===0,returnFileInfo:!0,returnPixelInterleavedDims:B.returnPixelInterleavedDims,pixelType:B.pixelType||null,noDataValue:B.noDataValue||null});s=y.fileInfo.eofOffset,c=y.maskData,E===0&&(g=y.encodedMaskData,l.width=y.width,l.height=y.height,l.dimCount=y.dimCount||1,l.pixelType=y.pixelType||y.fileInfo.pixelType,l.mask=c),i>1&&(c&&h.push(c),y.fileInfo.mask&&y.fileInfo.mask.numBytes>0&&u++),E++,l.pixels.push(y.pixelData),l.statistics.push({minValue:y.minValue,maxValue:y.maxValue,noDataValue:y.noDataValue,dimStats:y.dimStats})}var m,f,D;if(i>1&&u>1){for(D=l.width*l.height,l.bandMasks=h,c=new Uint8Array(D),c.set(h[0]),m=1;m<h.length;m++)for(Q=h[m],f=0;f<D;f++)c[f]=c[f]&Q[f];l.maskData=c}return l}};o.exports?o.exports=r:this.Lerc=r})()})($A)),$A.exports}var Tr=Jr();const Yr=Ce(Tr);let dA,nA,oe;const Ae={env:{emscripten_notify_memory_growth:function(o){oe=new Uint8Array(nA.exports.memory.buffer)}}};class Hr{init(){return dA||(typeof fetch<"u"?dA=fetch("data:application/wasm;base64,"+Te).then(A=>A.arrayBuffer()).then(A=>WebAssembly.instantiate(A,Ae)).then(this._init):dA=WebAssembly.instantiate(Buffer.from(Te,"base64"),Ae).then(this._init),dA)}_init(A){nA=A.instance,Ae.env.emscripten_notify_memory_growth(0)}decode(A,e=0){if(!nA)throw new Error("ZSTDDecoder: Await .init() before decoding.");const t=A.byteLength,r=nA.exports.malloc(t);oe.set(A,r),e=e||Number(nA.exports.ZSTD_findDecompressedSize(r,t));const a=nA.exports.malloc(e),B=nA.exports.ZSTD_decompress(a,e,r,t),s=oe.slice(a,a+B);return nA.exports.free(r),nA.exports.free(a),s}}const Te="[encoded data, 38976 characters]",gt=new Hr;class Kr extends BA{constructor(A){super(),this.planarConfiguration=typeof A.PlanarConfiguration<"u"?A.PlanarConfiguration:1,this.samplesPerPixel=typeof A.SamplesPerPixel<"u"?A.SamplesPerPixel:1,this.addCompression=A.LercParameters[Ci.AddCompression]}decodeBlock(A){switch(this.addCompression){case PA.None:break;case PA.Deflate:A=Ye(new Uint8Array(A)).buffer;break;case PA.Zstandard:A=gt.decode(new Uint8Array(A)).buffer;break;default:throw new Error(`Unsupported LERC additional compression method identifier: ${this.addCompression}`)}return Yr.decode(A,{returnPixelInterleavedDims:this.planarConfiguration===1}).pixels[0].buffer}}const Or=Object.freeze(Object.defineProperty({__proto__:null,default:Kr,zstd:gt},Symbol.toStringTag,{value:"Module"}));class Vr extends BA{constructor(){if(super(),typeof createImageBitmap>"u")throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if(typeof document>"u"&&typeof OffscreenCanvas>"u")throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(A,e){const t=new Blob([e]),r=await createImageBitmap(t);let a;typeof document<"u"?(a=document.createElement("canvas"),a.width=r.width,a.height=r.height):a=new OffscreenCanvas(r.width,r.height);const B=a.getContext("2d");return B.drawImage(r,0,0),B.getImageData(0,0,r.width,r.height).data.buffer}}const _r=Object.freeze(Object.defineProperty({__proto__:null,default:Vr},Symbol.toStringTag,{value:"Module"})),Pr=typeof Worker<"u"?Worker:void 0;function Xr(){const o='function A(A,e,t,i,r,I,g){try{var n=A[I](g),a=n.value}catch(A){return void t(A)}n.done?e(a):Promise.resolve(a).then(i,r)}function e(e){return function(){var t=this,i=arguments;return new Promise((function(r,I){var g=e.apply(t,i);function n(e){A(g,r,I,n,a,"next",e)}function a(e){A(g,r,I,n,a,"throw",e)}n(void 0)}))}}function t(A){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(A){return typeof A}:function(A){return A&&"function"==typeof Symbol&&A.constructor===Symbol&&A!==Symbol.prototype?"symbol":typeof A},t(A)}var i={exports:{}};!function(A){var e=function(A){var e,i=Object.prototype,r=i.hasOwnProperty,I="function"==typeof Symbol?Symbol:{},g=I.iterator||"@@iterator",n=I.asyncIterator||"@@asyncIterator",a=I.toStringTag||"@@toStringTag";function o(A,e,t){return Object.defineProperty(A,e,{value:t,enumerable:!0,configurable:!0,writable:!0}),A[e]}try{o({},"")}catch(A){o=function(A,e,t){return A[e]=t}}function B(A,e,t,i){var r=e&&e.prototype instanceof h?e:h,I=Object.create(r.prototype),g=new S(i||[]);return I._invoke=function(A,e,t){var i=Q;return function(r,I){if(i===s)throw new Error("Generator is already running");if(i===f){if("throw"===r)throw I;return R()}for(t.method=r,t.arg=I;;){var g=t.delegate;if(g){var n=m(g,t);if(n){if(n===c)continue;return n}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if(i===Q)throw i=f,t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);i=s;var a=C(A,e,t);if("normal"===a.type){if(i=t.done?f:E,a.arg===c)continue;return{value:a.arg,done:t.done}}"throw"===a.type&&(i=f,t.method="throw",t.arg=a.arg)}}}(A,t,g),I}function C(A,e,t){try{return{type:"normal",arg:A.call(e,t)}}catch(A){return{type:"throw",arg:A}}}A.wrap=B;var Q="suspendedStart",E="suspendedYield",s="executing",f="completed",c={};function h(){}function l(){}function u(){}var w={};o(w,g,(function(){return this}));var d=Object.getPrototypeOf,D=d&&d(d(v([])));D&&D!==i&&r.call(D,g)&&(w=D);var y=u.prototype=h.prototype=Object.create(w);function k(A){["next","throw","return"].forEach((function(e){o(A,e,(function(A){return this._invoke(e,A)}))}))}function p(A,e){function i(I,g,n,a){var o=C(A[I],A,g);if("throw"!==o.type){var B=o.arg,Q=B.value;return Q&&"object"===t(Q)&&r.call(Q,"__await")?e.resolve(Q.__await).then((function(A){i("next",A,n,a)}),(function(A){i("throw",A,n,a)})):e.resolve(Q).then((function(A){B.value=A,n(B)}),(function(A){return i("throw",A,n,a)}))}a(o.arg)}var I;this._invoke=function(A,t){function r(){return new e((function(e,r){i(A,t,e,r)}))}return I=I?I.then(r,r):r()}}function m(A,t){var i=A.iterator[t.method];if(i===e){if(t.delegate=null,"throw"===t.method){if(A.iterator.return&&(t.method="return",t.arg=e,m(A,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a \'throw\' method")}return c}var r=C(i,A.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,c;var I=r.arg;return I?I.done?(t[A.resultName]=I.value,t.next=A.nextLoc,"return"!==t.method&&(t.method="next",t.arg=e),t.delegate=null,c):I:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function G(A){var e={tryLoc:A[0]};1 in A&&(e.catchLoc=A[1]),2 in A&&(e.finallyLoc=A[2],e.afterLoc=A[3]),this.tryEntries.push(e)}function F(A){var e=A.completion||{};e.type="normal",delete e.arg,A.completion=e}function S(A){this.tryEntries=[{tryLoc:"root"}],A.forEach(G,this),this.reset(!0)}function v(A){if(A){var t=A[g];if(t)return t.call(A);if("function"==typeof A.next)return A;if(!isNaN(A.length)){var i=-1,I=function t(){for(;++i<A.length;)if(r.call(A,i))return t.value=A[i],t.done=!1,t;return t.value=e,t.done=!0,t};return I.next=I}}return{next:R}}function R(){return{value:e,done:!0}}return l.prototype=u,o(y,"constructor",u),o(u,"constructor",l),l.displayName=o(u,a,"GeneratorFunction"),A.isGeneratorFunction=function(A){var e="function"==typeof A&&A.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},A.mark=function(A){return Object.setPrototypeOf?Object.setPrototypeOf(A,u):(A.__proto__=u,o(A,a,"GeneratorFunction")),A.prototype=Object.create(y),A},A.awrap=function(A){return{__await:A}},k(p.prototype),o(p.prototype,n,(function(){return this})),A.AsyncIterator=p,A.async=function(e,t,i,r,I){void 0===I&&(I=Promise);var g=new p(B(e,t,i,r),I);return A.isGeneratorFunction(t)?g:g.next().then((function(A){return A.done?A.value:g.next()}))},k(y),o(y,a,"Generator"),o(y,g,(function(){return this})),o(y,"toString",(function(){return"[object Generator]"})),A.keys=function(A){var e=[];for(var t in A)e.push(t);return e.reverse(),function t(){for(;e.length;){var i=e.pop();if(i in A)return t.value=i,t.done=!1,t}return t.done=!0,t}},A.values=v,S.prototype={constructor:S,reset:function(A){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(F),!A)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=e)},stop:function(){this.done=!0;var A=this.tryEntries[0].completion;if("throw"===A.type)throw A.arg;return this.rval},dispatchException:function(A){if(this.done)throw A;var t=this;function i(i,r){return n.type="throw",n.arg=A,t.next=i,r&&(t.method="next",t.arg=e),!!r}for(var I=this.tryEntries.length-1;I>=0;--I){var g=this.tryEntries[I],n=g.completion;if("root"===g.tryLoc)return i("end");if(g.tryLoc<=this.prev){var a=r.call(g,"catchLoc"),o=r.call(g,"finallyLoc");if(a&&o){if(this.prev<g.catchLoc)return i(g.catchLoc,!0);if(this.prev<g.finallyLoc)return i(g.finallyLoc)}else if(a){if(this.prev<g.catchLoc)return i(g.catchLoc,!0)}else{if(!o)throw new Error("try statement without catch or finally");if(this.prev<g.finallyLoc)return i(g.finallyLoc)}}}},abrupt:function(A,e){for(var t=this.tryEntries.length-1;t>=0;--t){var i=this.tryEntries[t];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var I=i;break}}I&&("break"===A||"continue"===A)&&I.tryLoc<=e&&e<=I.finallyLoc&&(I=null);var g=I?I.completion:{};return g.type=A,g.arg=e,I?(this.method="next",this.next=I.finallyLoc,c):this.complete(g)},complete:function(A,e){if("throw"===A.type)throw A.arg;return"break"===A.type||"continue"===A.type?this.next=A.arg:"return"===A.type?(this.rval=this.arg=A.arg,this.method="return",this.next="end"):"normal"===A.type&&e&&(this.next=e),c},finish:function(A){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.finallyLoc===A)return this.complete(t.completion,t.afterLoc),F(t),c}},catch:function(A){for(var e=this.tryEntries.length-1;e>=0;--e){var t=this.tryEntries[e];if(t.tryLoc===A){var i=t.completion;if("throw"===i.type){var r=i.arg;F(t)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(A,t,i){return this.delegate={iterator:v(A),resultName:t,nextLoc:i},"next"===this.method&&(this.arg=e),c}},A}(A.exports);try{regeneratorRuntime=e}catch(A){"object"===("undefined"==typeof globalThis?"undefined":t(globalThis))?globalThis.regeneratorRuntime=e:Function("r","regeneratorRuntime = r")(e)}}(i);var r=i.exports,I=new Map;function g(A,e){Array.isArray(A)||(A=[A]),A.forEach((function(A){return I.set(A,e)}))}function n(A){return a.apply(this,arguments)}function a(){return(a=e(r.mark((function A(e){var t,i;return r.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:if(t=I.get(e.Compression)){A.next=3;break}throw new Error("Unknown compression method identifier: ".concat(e.Compression));case 3:return A.next=5,t();case 5:return i=A.sent,A.abrupt("return",new i(e));case 7:case"end":return A.stop()}}),A)})))).apply(this,arguments)}g([void 0,1],(function(){return Promise.resolve().then((function(){return y})).then((function(A){return A.default}))})),g(5,(function(){return Promise.resolve().then((function(){return F})).then((function(A){return A.default}))})),g(6,(function(){throw new Error("old style JPEG compression is not supported.")})),g(7,(function(){return Promise.resolve().then((function(){return N})).then((function(A){return A.default}))})),g([8,32946],(function(){return Promise.resolve().then((function(){return OA})).then((function(A){return A.default}))})),g(32773,(function(){return Promise.resolve().then((function(){return _A})).then((function(A){return A.default}))})),g(34887,(function(){return Promise.resolve().then((function(){return le})).then(function(){var A=e(r.mark((function A(e){return r.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,e.zstd.init();case 2:return A.abrupt("return",e);case 3:case"end":return A.stop()}}),A)})));return function(e){return A.apply(this,arguments)}}()).then((function(A){return A.default}))})),g(50001,(function(){return Promise.resolve().then((function(){return de})).then((function(A){return A.default}))}));var o=globalThis;function B(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}function C(A,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(A,i.key,i)}}function Q(A,e,t){return e&&C(A.prototype,e),t&&C(A,t),A}function E(A,e){return E=Object.setPrototypeOf||function(A,e){return A.__proto__=e,A},E(A,e)}function s(A,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");A.prototype=Object.create(e&&e.prototype,{constructor:{value:A,writable:!0,configurable:!0}}),e&&E(A,e)}function f(A,e){if(e&&("object"===t(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(A){if(void 0===A)throw new ReferenceError("this hasn\'t been initialised - super() hasn\'t been called");return A}(A)}function c(A){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(A){return A.__proto__||Object.getPrototypeOf(A)},c(A)}function h(A,e){var t=A.length-e,i=0;do{for(var r=e;r>0;r--)A[i+e]+=A[i],i++;t-=e}while(t>0)}function l(A,e,t){for(var i=0,r=A.length,I=r/t;r>e;){for(var g=e;g>0;--g)A[i+e]+=A[i],++i;r-=e}for(var n=A.slice(),a=0;a<I;++a)for(var o=0;o<t;++o)A[t*a+o]=n[(t-o-1)*I+a]}function u(A,e,t,i,r,I){if(!e||1===e)return A;for(var g=0;g<r.length;++g){if(r[g]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(r[g]!==r[0])throw new Error("When decoding with predictor, all samples must have the same size.")}for(var n=r[0]/8,a=2===I?1:r.length,o=0;o<i&&!(o*a*t*n>=A.byteLength);++o){var B=void 0;if(2===e){switch(r[0]){case 8:B=new Uint8Array(A,o*a*t*n,a*t*n);break;case 16:B=new Uint16Array(A,o*a*t*n,a*t*n/2);break;case 32:B=new Uint32Array(A,o*a*t*n,a*t*n/4);break;default:throw new Error("Predictor 2 not allowed with ".concat(r[0]," bits per sample."))}h(B,a)}else 3===e&&l(B=new Uint8Array(A,o*a*t*n,a*t*n),a,n)}return A}o.addEventListener("message",function(){var A=e(r.mark((function A(e){var t,i,I,g,a,B;return r.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return t=e.data,i=t.id,I=t.fileDirectory,g=t.buffer,A.next=3,n(I);case 3:return a=A.sent,A.next=6,a.decode(I,g);case 6:B=A.sent,o.postMessage({decoded:B,id:i},[B]);case 8:case"end":return A.stop()}}),A)})));return function(e){return A.apply(this,arguments)}}());var w=function(){function A(){B(this,A)}var t;return Q(A,[{key:"decode",value:(t=e(r.mark((function A(e,t){var i,I,g,n,a;return r.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return A.next=2,this.decodeBlock(t);case 2:if(i=A.sent,1===(I=e.Predictor||1)){A.next=9;break}return g=!e.StripOffsets,n=g?e.TileWidth:e.ImageWidth,a=g?e.TileLength:e.RowsPerStrip||e.ImageLength,A.abrupt("return",u(i,I,n,a,e.BitsPerSample,e.PlanarConfiguration));case 9:return A.abrupt("return",i);case 10:case"end":return A.stop()}}),A,this)}))),function(A,e){return t.apply(this,arguments)})}]),A}();function d(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var D=function(A){s(t,w);var e=d(t);function t(){return B(this,t),e.apply(this,arguments)}return Q(t,[{key:"decodeBlock",value:function(A){return A}}]),t}(),y=Object.freeze({__proto__:null,default:D});function k(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}function p(A,e){for(var t=e.length-1;t>=0;t--)A.push(e[t]);return A}function m(A){for(var e=new Uint16Array(4093),t=new Uint8Array(4093),i=0;i<=257;i++)e[i]=4096,t[i]=i;var r=258,I=9,g=0;function n(){r=258,I=9}function a(A){var e=function(A,e,t){var i=e%8,r=Math.floor(e/8),I=8-i,g=e+t-8*(r+1),n=8*(r+2)-(e+t),a=8*(r+2)-e;if(n=Math.max(0,n),r>=A.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;var o=A[r]&Math.pow(2,8-i)-1,B=o<<=t-I;if(r+1<A.length){var C=A[r+1]>>>n;B+=C<<=Math.max(0,t-a)}if(g>8&&r+2<A.length){var Q=8*(r+3)-(e+t);B+=A[r+2]>>>Q}return B}(A,g,I);return g+=I,e}function o(A,i){return t[r]=i,e[r]=A,++r-1}function B(A){for(var i=[],r=A;4096!==r;r=e[r])i.push(t[r]);return i}var C=[];n();for(var Q,E=new Uint8Array(A),s=a(E);257!==s;){if(256===s){for(n(),s=a(E);256===s;)s=a(E);if(257===s)break;if(s>256)throw new Error("corrupted code at scanline ".concat(s));p(C,B(s)),Q=s}else if(s<r){var f=B(s);p(C,f),o(Q,f[f.length-1]),Q=s}else{var c=B(Q);if(!c)throw new Error("Bogus entry. Not in dictionary, ".concat(Q," / ").concat(r,", position: ").concat(g));p(C,c),C.push(c[c.length-1]),o(Q,c[c.length-1]),Q=s}r+1>=Math.pow(2,I)&&(12===I?Q=void 0:I++),s=a(E)}return new Uint8Array(C)}var G=function(A){s(t,w);var e=k(t);function t(){return B(this,t),e.apply(this,arguments)}return Q(t,[{key:"decodeBlock",value:function(A){return m(A).buffer}}]),t}(),F=Object.freeze({__proto__:null,default:G});function S(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var v=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function R(A,e){for(var t=0,i=[],r=16;r>0&&!A[r-1];)--r;i.push({children:[],index:0});for(var I,g=i[0],n=0;n<r;n++){for(var a=0;a<A[n];a++){for((g=i.pop()).children[g.index]=e[t];g.index>0;)g=i.pop();for(g.index++,i.push(g);i.length<=n;)i.push(I={children:[],index:0}),g.children[g.index]=I.children,g=I;t++}n+1<r&&(i.push(I={children:[],index:0}),g.children[g.index]=I.children,g=I)}return i[0].children}function U(A,e,i,r,I,g,n,a,o){var B=i.mcusPerLine,C=i.progressive,Q=e,E=e,s=0,f=0;function c(){if(f>0)return f--,s>>f&1;if(255===(s=A[E++])){var e=A[E++];if(e)throw new Error("unexpected marker: ".concat((s<<8|e).toString(16)))}return f=7,s>>>7}function h(A){for(var e,i=A;null!==(e=c());){if("number"==typeof(i=i[e]))return i;if("object"!==t(i))throw new Error("invalid huffman sequence")}return null}function l(A){for(var e=A,t=0;e>0;){var i=c();if(null===i)return;t=t<<1|i,--e}return t}function u(A){var e=l(A);return e>=1<<A-1?e:e+(-1<<A)+1}var w=0;var d,D=0;function y(A,e,t,i,r){var I=t%B,g=(t/B|0)*A.v+i,n=I*A.h+r;e(A,A.blocks[g][n])}function k(A,e,t){var i=t/A.blocksPerLine|0,r=t%A.blocksPerLine;e(A,A.blocks[i][r])}var p,m,G,F,S,R,U=r.length;R=C?0===g?0===a?function(A,e){var t=h(A.huffmanTableDC),i=0===t?0:u(t)<<o;A.pred+=i,e[0]=A.pred}:function(A,e){e[0]|=c()<<o}:0===a?function(A,e){if(w>0)w--;else for(var t=g,i=n;t<=i;){var r=h(A.huffmanTableAC),I=15&r,a=r>>4;if(0===I){if(a<15){w=l(a)+(1<<a)-1;break}t+=16}else e[v[t+=a]]=u(I)*(1<<o),t++}}:function(A,e){for(var t=g,i=n,r=0;t<=i;){var I=v[t],a=e[I]<0?-1:1;switch(D){case 0:var B=h(A.huffmanTableAC),C=15&B;if(r=B>>4,0===C)r<15?(w=l(r)+(1<<r),D=4):(r=16,D=1);else{if(1!==C)throw new Error("invalid ACn encoding");d=u(C),D=r?2:3}continue;case 1:case 2:e[I]?e[I]+=(c()<<o)*a:0==--r&&(D=2===D?3:0);break;case 3:e[I]?e[I]+=(c()<<o)*a:(e[I]=d<<o,D=0);break;case 4:e[I]&&(e[I]+=(c()<<o)*a)}t++}4===D&&0==--w&&(D=0)}:function(A,e){var t=h(A.huffmanTableDC),i=0===t?0:u(t);A.pred+=i,e[0]=A.pred;for(var r=1;r<64;){var I=h(A.huffmanTableAC),g=15&I,n=I>>4;if(0===g){if(n<15)break;r+=16}else e[v[r+=n]]=u(g),r++}};var L,b,M=0;b=1===U?r[0].blocksPerLine*r[0].blocksPerColumn:B*i.mcusPerColumn;for(var N=I||b;M<b;){for(m=0;m<U;m++)r[m].pred=0;if(w=0,1===U)for(p=r[0],S=0;S<N;S++)k(p,R,M),M++;else for(S=0;S<N;S++){for(m=0;m<U;m++){var x=p=r[m],J=x.h,q=x.v;for(G=0;G<q;G++)for(F=0;F<J;F++)y(p,R,M,G,F)}if(++M===b)break}if(f=0,(L=A[E]<<8|A[E+1])<65280)throw new Error("marker was not found");if(!(L>=65488&&L<=65495))break;E+=2}return E-Q}function L(A,e){var t=[],i=e.blocksPerLine,r=e.blocksPerColumn,I=i<<3,g=new Int32Array(64),n=new Uint8Array(64);function a(A,t,i){var r,I,g,n,a,o,B,C,Q,E,s=e.quantizationTable,f=i;for(E=0;E<64;E++)f[E]=A[E]*s[E];for(E=0;E<8;++E){var c=8*E;0!==f[1+c]||0!==f[2+c]||0!==f[3+c]||0!==f[4+c]||0!==f[5+c]||0!==f[6+c]||0!==f[7+c]?(r=5793*f[0+c]+128>>8,I=5793*f[4+c]+128>>8,g=f[2+c],n=f[6+c],a=2896*(f[1+c]-f[7+c])+128>>8,C=2896*(f[1+c]+f[7+c])+128>>8,o=f[3+c]<<4,Q=r-I+1>>1,r=r+I+1>>1,I=Q,Q=3784*g+1567*n+128>>8,g=1567*g-3784*n+128>>8,n=Q,Q=a-(B=f[5+c]<<4)+1>>1,a=a+B+1>>1,B=Q,Q=C+o+1>>1,o=C-o+1>>1,C=Q,Q=r-n+1>>1,r=r+n+1>>1,n=Q,Q=I-g+1>>1,I=I+g+1>>1,g=Q,Q=2276*a+3406*C+2048>>12,a=3406*a-2276*C+2048>>12,C=Q,Q=799*o+4017*B+2048>>12,o=4017*o-799*B+2048>>12,B=Q,f[0+c]=r+C,f[7+c]=r-C,f[1+c]=I+B,f[6+c]=I-B,f[2+c]=g+o,f[5+c]=g-o,f[3+c]=n+a,f[4+c]=n-a):(Q=5793*f[0+c]+512>>10,f[0+c]=Q,f[1+c]=Q,f[2+c]=Q,f[3+c]=Q,f[4+c]=Q,f[5+c]=Q,f[6+c]=Q,f[7+c]=Q)}for(E=0;E<8;++E){var h=E;0!==f[8+h]||0!==f[16+h]||0!==f[24+h]||0!==f[32+h]||0!==f[40+h]||0!==f[48+h]||0!==f[56+h]?(r=5793*f[0+h]+2048>>12,I=5793*f[32+h]+2048>>12,g=f[16+h],n=f[48+h],a=2896*(f[8+h]-f[56+h])+2048>>12,C=2896*(f[8+h]+f[56+h])+2048>>12,o=f[24+h],Q=r-I+1>>1,r=r+I+1>>1,I=Q,Q=3784*g+1567*n+2048>>12,g=1567*g-3784*n+2048>>12,n=Q,Q=a-(B=f[40+h])+1>>1,a=a+B+1>>1,B=Q,Q=C+o+1>>1,o=C-o+1>>1,C=Q,Q=r-n+1>>1,r=r+n+1>>1,n=Q,Q=I-g+1>>1,I=I+g+1>>1,g=Q,Q=2276*a+3406*C+2048>>12,a=3406*a-2276*C+2048>>12,C=Q,Q=799*o+4017*B+2048>>12,o=4017*o-799*B+2048>>12,B=Q,f[0+h]=r+C,f[56+h]=r-C,f[8+h]=I+B,f[48+h]=I-B,f[16+h]=g+o,f[40+h]=g-o,f[24+h]=n+a,f[32+h]=n-a):(Q=5793*i[E+0]+8192>>14,f[0+h]=Q,f[8+h]=Q,f[16+h]=Q,f[24+h]=Q,f[32+h]=Q,f[40+h]=Q,f[48+h]=Q,f[56+h]=Q)}for(E=0;E<64;++E){var l=128+(f[E]+8>>4);t[E]=l<0?0:l>255?255:l}}for(var o=0;o<r;o++){for(var B=o<<3,C=0;C<8;C++)t.push(new Uint8Array(I));for(var Q=0;Q<i;Q++){a(e.blocks[o][Q],n,g);for(var E=0,s=Q<<3,f=0;f<8;f++)for(var c=t[B+f],h=0;h<8;h++)c[s+h]=n[E++]}}return t}var b=function(){function A(){B(this,A),this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}return Q(A,[{key:"resetFrames",value:function(){this.frames=[]}},{key:"parse",value:function(A){var e=0;function t(){var t=A[e]<<8|A[e+1];return e+=2,t}function i(A){var e,t,i=0,r=0;for(t in A.components)A.components.hasOwnProperty(t)&&(i<(e=A.components[t]).h&&(i=e.h),r<e.v&&(r=e.v));var I=Math.ceil(A.samplesPerLine/8/i),g=Math.ceil(A.scanLines/8/r);for(t in A.components)if(A.components.hasOwnProperty(t)){e=A.components[t];for(var n=Math.ceil(Math.ceil(A.samplesPerLine/8)*e.h/i),a=Math.ceil(Math.ceil(A.scanLines/8)*e.v/r),o=I*e.h,B=g*e.v,C=[],Q=0;Q<B;Q++){for(var E=[],s=0;s<o;s++)E.push(new Int32Array(64));C.push(E)}e.blocksPerLine=n,e.blocksPerColumn=a,e.blocks=C}A.maxH=i,A.maxV=r,A.mcusPerLine=I,A.mcusPerColumn=g}var r,I,g=t();if(65496!==g)throw new Error("SOI not found");for(g=t();65497!==g;){switch(g){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var n=(r=void 0,I=void 0,r=t(),I=A.subarray(e,e+r-2),e+=I.length,I);65504===g&&74===n[0]&&70===n[1]&&73===n[2]&&70===n[3]&&0===n[4]&&(this.jfif={version:{major:n[5],minor:n[6]},densityUnits:n[7],xDensity:n[8]<<8|n[9],yDensity:n[10]<<8|n[11],thumbWidth:n[12],thumbHeight:n[13],thumbData:n.subarray(14,14+3*n[12]*n[13])}),65518===g&&65===n[0]&&100===n[1]&&111===n[2]&&98===n[3]&&101===n[4]&&0===n[5]&&(this.adobe={version:n[6],flags0:n[7]<<8|n[8],flags1:n[9]<<8|n[10],transformCode:n[11]});break;case 65499:for(var a=t()+e-2;e<a;){var o=A[e++],B=new Int32Array(64);if(o>>4==0)for(var C=0;C<64;C++){B[v[C]]=A[e++]}else{if(o>>4!=1)throw new Error("DQT: invalid table spec");for(var Q=0;Q<64;Q++){B[v[Q]]=t()}}this.quantizationTables[15&o]=B}break;case 65472:case 65473:case 65474:t();for(var E={extended:65473===g,progressive:65474===g,precision:A[e++],scanLines:t(),samplesPerLine:t(),components:{},componentsOrder:[]},s=A[e++],f=void 0,c=0;c<s;c++){f=A[e];var h=A[e+1]>>4,l=15&A[e+1],u=A[e+2];E.componentsOrder.push(f),E.components[f]={h:h,v:l,quantizationIdx:u},e+=3}i(E),this.frames.push(E);break;case 65476:for(var w=t(),d=2;d<w;){for(var D=A[e++],y=new Uint8Array(16),k=0,p=0;p<16;p++,e++)y[p]=A[e],k+=y[p];for(var m=new Uint8Array(k),G=0;G<k;G++,e++)m[G]=A[e];d+=17+k,D>>4==0?this.huffmanTablesDC[15&D]=R(y,m):this.huffmanTablesAC[15&D]=R(y,m)}break;case 65501:t(),this.resetInterval=t();break;case 65498:t();for(var F=A[e++],S=[],L=this.frames[0],b=0;b<F;b++){var M=L.components[A[e++]],N=A[e++];M.huffmanTableDC=this.huffmanTablesDC[N>>4],M.huffmanTableAC=this.huffmanTablesAC[15&N],S.push(M)}var x=A[e++],J=A[e++],q=A[e++],Y=U(A,e,L,S,this.resetInterval,x,J,q>>4,15&q);e+=Y;break;case 65535:255!==A[e]&&e--;break;default:if(255===A[e-3]&&A[e-2]>=192&&A[e-2]<=254){e-=3;break}throw new Error("unknown JPEG marker ".concat(g.toString(16)))}g=t()}}},{key:"getResult",value:function(){var A=this.frames;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(var e=0;e<this.frames.length;e++)for(var t=this.frames[e].components,i=0,r=Object.keys(t);i<r.length;i++){var I=r[i];t[I].quantizationTable=this.quantizationTables[t[I].quantizationIdx],delete t[I].quantizationIdx}for(var g=A[0],n=g.components,a=g.componentsOrder,o=[],B=g.samplesPerLine,C=g.scanLines,Q=0;Q<a.length;Q++){var E=n[a[Q]];o.push({lines:L(0,E),scaleX:E.h/g.maxH,scaleY:E.v/g.maxV})}for(var s=new Uint8Array(B*C*o.length),f=0,c=0;c<C;++c)for(var h=0;h<B;++h)for(var l=0;l<o.length;++l){var u=o[l];s[f]=u.lines[0|c*u.scaleY][0|h*u.scaleX],++f}return s}}]),A}(),M=function(A){s(t,w);var e=S(t);function t(A){var i;return B(this,t),(i=e.call(this)).reader=new b,A.JPEGTables&&i.reader.parse(A.JPEGTables),i}return Q(t,[{key:"decodeBlock",value:function(A){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(A)),this.reader.getResult().buffer}}]),t}(),N=Object.freeze({__proto__:null,default:M});function x(A){for(var e=A.length;--e>=0;)A[e]=0}x(new Array(576)),x(new Array(60)),x(new Array(512)),x(new Array(256)),x(new Array(29)),x(new Array(30));var J=function(A,e,t,i){for(var r=65535&A|0,I=A>>>16&65535|0,g=0;0!==t;){t-=g=t>2e3?2e3:t;do{I=I+(r=r+e[i++]|0)|0}while(--g);r%=65521,I%=65521}return r|I<<16|0},q=new Uint32Array(function(){for(var A,e=[],t=0;t<256;t++){A=t;for(var i=0;i<8;i++)A=1&A?3988292384^A>>>1:A>>>1;e[t]=A}return e}()),Y=function(A,e,t,i){var r=q,I=i+t;A^=-1;for(var g=i;g<I;g++)A=A>>>8^r[255&(A^e[g])];return-1^A},K={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},H={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},O=function(A,e){return Object.prototype.hasOwnProperty.call(A,e)},P=function(A){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!==t(i))throw new TypeError(i+"must be non-object");for(var r in i)O(i,r)&&(A[r]=i[r])}}return A},T=function(A){for(var e=0,t=0,i=A.length;t<i;t++)e+=A[t].length;for(var r=new Uint8Array(e),I=0,g=0,n=A.length;I<n;I++){var a=A[I];r.set(a,g),g+=a.length}return r},V=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(A){V=!1}for(var _=new Uint8Array(256),X=0;X<256;X++)_[X]=X>=252?6:X>=248?5:X>=240?4:X>=224?3:X>=192?2:1;_[254]=_[254]=1;var Z=function(A){if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(A);var e,t,i,r,I,g=A.length,n=0;for(r=0;r<g;r++)55296==(64512&(t=A.charCodeAt(r)))&&r+1<g&&56320==(64512&(i=A.charCodeAt(r+1)))&&(t=65536+(t-55296<<10)+(i-56320),r++),n+=t<128?1:t<2048?2:t<65536?3:4;for(e=new Uint8Array(n),I=0,r=0;I<n;r++)55296==(64512&(t=A.charCodeAt(r)))&&r+1<g&&56320==(64512&(i=A.charCodeAt(r+1)))&&(t=65536+(t-55296<<10)+(i-56320),r++),t<128?e[I++]=t:t<2048?(e[I++]=192|t>>>6,e[I++]=128|63&t):t<65536?(e[I++]=224|t>>>12,e[I++]=128|t>>>6&63,e[I++]=128|63&t):(e[I++]=240|t>>>18,e[I++]=128|t>>>12&63,e[I++]=128|t>>>6&63,e[I++]=128|63&t);return e},j=function(A,e){var t,i,r=e||A.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(A.subarray(0,e));var I=new Array(2*r);for(i=0,t=0;t<r;){var g=A[t++];if(g<128)I[i++]=g;else{var n=_[g];if(n>4)I[i++]=65533,t+=n-1;else{for(g&=2===n?31:3===n?15:7;n>1&&t<r;)g=g<<6|63&A[t++],n--;n>1?I[i++]=65533:g<65536?I[i++]=g:(g-=65536,I[i++]=55296|g>>10&1023,I[i++]=56320|1023&g)}}}return function(A,e){if(e<65534&&A.subarray&&V)return String.fromCharCode.apply(null,A.length===e?A:A.subarray(0,e));for(var t="",i=0;i<e;i++)t+=String.fromCharCode(A[i]);return t}(I,i)},W=function(A,e){(e=e||A.length)>A.length&&(e=A.length);for(var t=e-1;t>=0&&128==(192&A[t]);)t--;return t<0||0===t?e:t+_[A[t]]>e?t:e};var z=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},$=function(A,e){var t,i,r,I,g,n,a,o,B,C,Q,E,s,f,c,h,l,u,w,d,D,y,k,p,m=A.state;t=A.next_in,k=A.input,i=t+(A.avail_in-5),r=A.next_out,p=A.output,I=r-(e-A.avail_out),g=r+(A.avail_out-257),n=m.dmax,a=m.wsize,o=m.whave,B=m.wnext,C=m.window,Q=m.hold,E=m.bits,s=m.lencode,f=m.distcode,c=(1<<m.lenbits)-1,h=(1<<m.distbits)-1;A:do{E<15&&(Q+=k[t++]<<E,E+=8,Q+=k[t++]<<E,E+=8),l=s[Q&c];e:for(;;){if(Q>>>=u=l>>>24,E-=u,0===(u=l>>>16&255))p[r++]=65535&l;else{if(!(16&u)){if(0==(64&u)){l=s[(65535&l)+(Q&(1<<u)-1)];continue e}if(32&u){m.mode=12;break A}A.msg="invalid literal/length code",m.mode=30;break A}w=65535&l,(u&=15)&&(E<u&&(Q+=k[t++]<<E,E+=8),w+=Q&(1<<u)-1,Q>>>=u,E-=u),E<15&&(Q+=k[t++]<<E,E+=8,Q+=k[t++]<<E,E+=8),l=f[Q&h];t:for(;;){if(Q>>>=u=l>>>24,E-=u,!(16&(u=l>>>16&255))){if(0==(64&u)){l=f[(65535&l)+(Q&(1<<u)-1)];continue t}A.msg="invalid distance code",m.mode=30;break A}if(d=65535&l,E<(u&=15)&&(Q+=k[t++]<<E,(E+=8)<u&&(Q+=k[t++]<<E,E+=8)),(d+=Q&(1<<u)-1)>n){A.msg="invalid distance too far back",m.mode=30;break A}if(Q>>>=u,E-=u,d>(u=r-I)){if((u=d-u)>o&&m.sane){A.msg="invalid distance too far back",m.mode=30;break A}if(D=0,y=C,0===B){if(D+=a-u,u<w){w-=u;do{p[r++]=C[D++]}while(--u);D=r-d,y=p}}else if(B<u){if(D+=a+B-u,(u-=B)<w){w-=u;do{p[r++]=C[D++]}while(--u);if(D=0,B<w){w-=u=B;do{p[r++]=C[D++]}while(--u);D=r-d,y=p}}}else if(D+=B-u,u<w){w-=u;do{p[r++]=C[D++]}while(--u);D=r-d,y=p}for(;w>2;)p[r++]=y[D++],p[r++]=y[D++],p[r++]=y[D++],w-=3;w&&(p[r++]=y[D++],w>1&&(p[r++]=y[D++]))}else{D=r-d;do{p[r++]=p[D++],p[r++]=p[D++],p[r++]=p[D++],w-=3}while(w>2);w&&(p[r++]=p[D++],w>1&&(p[r++]=p[D++]))}break}}break}}while(t<i&&r<g);t-=w=E>>3,Q&=(1<<(E-=w<<3))-1,A.next_in=t,A.next_out=r,A.avail_in=t<i?i-t+5:5-(t-i),A.avail_out=r<g?g-r+257:257-(r-g),m.hold=Q,m.bits=E},AA=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),eA=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),tA=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),iA=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),rA=function(A,e,t,i,r,I,g,n){var a,o,B,C,Q,E,s,f,c,h=n.bits,l=0,u=0,w=0,d=0,D=0,y=0,k=0,p=0,m=0,G=0,F=null,S=0,v=new Uint16Array(16),R=new Uint16Array(16),U=null,L=0;for(l=0;l<=15;l++)v[l]=0;for(u=0;u<i;u++)v[e[t+u]]++;for(D=h,d=15;d>=1&&0===v[d];d--);if(D>d&&(D=d),0===d)return r[I++]=20971520,r[I++]=20971520,n.bits=1,0;for(w=1;w<d&&0===v[w];w++);for(D<w&&(D=w),p=1,l=1;l<=15;l++)if(p<<=1,(p-=v[l])<0)return-1;if(p>0&&(0===A||1!==d))return-1;for(R[1]=0,l=1;l<15;l++)R[l+1]=R[l]+v[l];for(u=0;u<i;u++)0!==e[t+u]&&(g[R[e[t+u]]++]=u);if(0===A?(F=U=g,E=19):1===A?(F=AA,S-=257,U=eA,L-=257,E=256):(F=tA,U=iA,E=-1),G=0,u=0,l=w,Q=I,y=D,k=0,B=-1,C=(m=1<<D)-1,1===A&&m>852||2===A&&m>592)return 1;for(;;){s=l-k,g[u]<E?(f=0,c=g[u]):g[u]>E?(f=U[L+g[u]],c=F[S+g[u]]):(f=96,c=0),a=1<<l-k,w=o=1<<y;do{r[Q+(G>>k)+(o-=a)]=s<<24|f<<16|c|0}while(0!==o);for(a=1<<l-1;G&a;)a>>=1;if(0!==a?(G&=a-1,G+=a):G=0,u++,0==--v[l]){if(l===d)break;l=e[t+g[u]]}if(l>D&&(G&C)!==B){for(0===k&&(k=D),Q+=w,p=1<<(y=l-k);y+k<d&&!((p-=v[y+k])<=0);)y++,p<<=1;if(m+=1<<y,1===A&&m>852||2===A&&m>592)return 1;r[B=G&C]=D<<24|y<<16|Q-I|0}}return 0!==G&&(r[Q+G]=l-k<<24|64<<16|0),n.bits=D,0},IA=H.Z_FINISH,gA=H.Z_BLOCK,nA=H.Z_TREES,aA=H.Z_OK,oA=H.Z_STREAM_END,BA=H.Z_NEED_DICT,CA=H.Z_STREAM_ERROR,QA=H.Z_DATA_ERROR,EA=H.Z_MEM_ERROR,sA=H.Z_BUF_ERROR,fA=H.Z_DEFLATED,cA=function(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)};function hA(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var lA,uA,wA=function(A){if(!A||!A.state)return CA;var e=A.state;return A.total_in=A.total_out=e.total=0,A.msg="",e.wrap&&(A.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,aA},dA=function(A){if(!A||!A.state)return CA;var e=A.state;return e.wsize=0,e.whave=0,e.wnext=0,wA(A)},DA=function(A,e){var t;if(!A||!A.state)return CA;var i=A.state;return e<0?(t=0,e=-e):(t=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?CA:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=t,i.wbits=e,dA(A))},yA=function(A,e){if(!A)return CA;var t=new hA;A.state=t,t.window=null;var i=DA(A,e);return i!==aA&&(A.state=null),i},kA=!0,pA=function(A){if(kA){lA=new Int32Array(512),uA=new Int32Array(32);for(var e=0;e<144;)A.lens[e++]=8;for(;e<256;)A.lens[e++]=9;for(;e<280;)A.lens[e++]=7;for(;e<288;)A.lens[e++]=8;for(rA(1,A.lens,0,288,lA,0,A.work,{bits:9}),e=0;e<32;)A.lens[e++]=5;rA(2,A.lens,0,32,uA,0,A.work,{bits:5}),kA=!1}A.lencode=lA,A.lenbits=9,A.distcode=uA,A.distbits=5},mA=function(A,e,t,i){var r,I=A.state;return null===I.window&&(I.wsize=1<<I.wbits,I.wnext=0,I.whave=0,I.window=new Uint8Array(I.wsize)),i>=I.wsize?(I.window.set(e.subarray(t-I.wsize,t),0),I.wnext=0,I.whave=I.wsize):((r=I.wsize-I.wnext)>i&&(r=i),I.window.set(e.subarray(t-i,t-i+r),I.wnext),(i-=r)?(I.window.set(e.subarray(t-i,t),0),I.wnext=i,I.whave=I.wsize):(I.wnext+=r,I.wnext===I.wsize&&(I.wnext=0),I.whave<I.wsize&&(I.whave+=r))),0},GA={inflateReset:dA,inflateReset2:DA,inflateResetKeep:wA,inflateInit:function(A){return yA(A,15)},inflateInit2:yA,inflate:function(A,e){var t,i,r,I,g,n,a,o,B,C,Q,E,s,f,c,h,l,u,w,d,D,y,k,p,m=0,G=new Uint8Array(4),F=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!A||!A.state||!A.output||!A.input&&0!==A.avail_in)return CA;12===(t=A.state).mode&&(t.mode=13),g=A.next_out,r=A.output,a=A.avail_out,I=A.next_in,i=A.input,n=A.avail_in,o=t.hold,B=t.bits,C=n,Q=a,y=aA;A:for(;;)switch(t.mode){case 1:if(0===t.wrap){t.mode=13;break}for(;B<16;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(2&t.wrap&&35615===o){t.check=0,G[0]=255&o,G[1]=o>>>8&255,t.check=Y(t.check,G,2,0),o=0,B=0,t.mode=2;break}if(t.flags=0,t.head&&(t.head.done=!1),!(1&t.wrap)||(((255&o)<<8)+(o>>8))%31){A.msg="incorrect header check",t.mode=30;break}if((15&o)!==fA){A.msg="unknown compression method",t.mode=30;break}if(B-=4,D=8+(15&(o>>>=4)),0===t.wbits)t.wbits=D;else if(D>t.wbits){A.msg="invalid window size",t.mode=30;break}t.dmax=1<<t.wbits,A.adler=t.check=1,t.mode=512&o?10:12,o=0,B=0;break;case 2:for(;B<16;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(t.flags=o,(255&t.flags)!==fA){A.msg="unknown compression method",t.mode=30;break}if(57344&t.flags){A.msg="unknown header flags set",t.mode=30;break}t.head&&(t.head.text=o>>8&1),512&t.flags&&(G[0]=255&o,G[1]=o>>>8&255,t.check=Y(t.check,G,2,0)),o=0,B=0,t.mode=3;case 3:for(;B<32;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.head&&(t.head.time=o),512&t.flags&&(G[0]=255&o,G[1]=o>>>8&255,G[2]=o>>>16&255,G[3]=o>>>24&255,t.check=Y(t.check,G,4,0)),o=0,B=0,t.mode=4;case 4:for(;B<16;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.head&&(t.head.xflags=255&o,t.head.os=o>>8),512&t.flags&&(G[0]=255&o,G[1]=o>>>8&255,t.check=Y(t.check,G,2,0)),o=0,B=0,t.mode=5;case 5:if(1024&t.flags){for(;B<16;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.length=o,t.head&&(t.head.extra_len=o),512&t.flags&&(G[0]=255&o,G[1]=o>>>8&255,t.check=Y(t.check,G,2,0)),o=0,B=0}else t.head&&(t.head.extra=null);t.mode=6;case 6:if(1024&t.flags&&((E=t.length)>n&&(E=n),E&&(t.head&&(D=t.head.extra_len-t.length,t.head.extra||(t.head.extra=new Uint8Array(t.head.extra_len)),t.head.extra.set(i.subarray(I,I+E),D)),512&t.flags&&(t.check=Y(t.check,i,E,I)),n-=E,I+=E,t.length-=E),t.length))break A;t.length=0,t.mode=7;case 7:if(2048&t.flags){if(0===n)break A;E=0;do{D=i[I+E++],t.head&&D&&t.length<65536&&(t.head.name+=String.fromCharCode(D))}while(D&&E<n);if(512&t.flags&&(t.check=Y(t.check,i,E,I)),n-=E,I+=E,D)break A}else t.head&&(t.head.name=null);t.length=0,t.mode=8;case 8:if(4096&t.flags){if(0===n)break A;E=0;do{D=i[I+E++],t.head&&D&&t.length<65536&&(t.head.comment+=String.fromCharCode(D))}while(D&&E<n);if(512&t.flags&&(t.check=Y(t.check,i,E,I)),n-=E,I+=E,D)break A}else t.head&&(t.head.comment=null);t.mode=9;case 9:if(512&t.flags){for(;B<16;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(o!==(65535&t.check)){A.msg="header crc mismatch",t.mode=30;break}o=0,B=0}t.head&&(t.head.hcrc=t.flags>>9&1,t.head.done=!0),A.adler=t.check=0,t.mode=12;break;case 10:for(;B<32;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}A.adler=t.check=cA(o),o=0,B=0,t.mode=11;case 11:if(0===t.havedict)return A.next_out=g,A.avail_out=a,A.next_in=I,A.avail_in=n,t.hold=o,t.bits=B,BA;A.adler=t.check=1,t.mode=12;case 12:if(e===gA||e===nA)break A;case 13:if(t.last){o>>>=7&B,B-=7&B,t.mode=27;break}for(;B<3;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}switch(t.last=1&o,B-=1,3&(o>>>=1)){case 0:t.mode=14;break;case 1:if(pA(t),t.mode=20,e===nA){o>>>=2,B-=2;break A}break;case 2:t.mode=17;break;case 3:A.msg="invalid block type",t.mode=30}o>>>=2,B-=2;break;case 14:for(o>>>=7&B,B-=7&B;B<32;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if((65535&o)!=(o>>>16^65535)){A.msg="invalid stored block lengths",t.mode=30;break}if(t.length=65535&o,o=0,B=0,t.mode=15,e===nA)break A;case 15:t.mode=16;case 16:if(E=t.length){if(E>n&&(E=n),E>a&&(E=a),0===E)break A;r.set(i.subarray(I,I+E),g),n-=E,I+=E,a-=E,g+=E,t.length-=E;break}t.mode=12;break;case 17:for(;B<14;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(t.nlen=257+(31&o),o>>>=5,B-=5,t.ndist=1+(31&o),o>>>=5,B-=5,t.ncode=4+(15&o),o>>>=4,B-=4,t.nlen>286||t.ndist>30){A.msg="too many length or distance symbols",t.mode=30;break}t.have=0,t.mode=18;case 18:for(;t.have<t.ncode;){for(;B<3;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.lens[F[t.have++]]=7&o,o>>>=3,B-=3}for(;t.have<19;)t.lens[F[t.have++]]=0;if(t.lencode=t.lendyn,t.lenbits=7,k={bits:t.lenbits},y=rA(0,t.lens,0,19,t.lencode,0,t.work,k),t.lenbits=k.bits,y){A.msg="invalid code lengths set",t.mode=30;break}t.have=0,t.mode=19;case 19:for(;t.have<t.nlen+t.ndist;){for(;h=(m=t.lencode[o&(1<<t.lenbits)-1])>>>16&255,l=65535&m,!((c=m>>>24)<=B);){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(l<16)o>>>=c,B-=c,t.lens[t.have++]=l;else{if(16===l){for(p=c+2;B<p;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(o>>>=c,B-=c,0===t.have){A.msg="invalid bit length repeat",t.mode=30;break}D=t.lens[t.have-1],E=3+(3&o),o>>>=2,B-=2}else if(17===l){for(p=c+3;B<p;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}B-=c,D=0,E=3+(7&(o>>>=c)),o>>>=3,B-=3}else{for(p=c+7;B<p;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}B-=c,D=0,E=11+(127&(o>>>=c)),o>>>=7,B-=7}if(t.have+E>t.nlen+t.ndist){A.msg="invalid bit length repeat",t.mode=30;break}for(;E--;)t.lens[t.have++]=D}}if(30===t.mode)break;if(0===t.lens[256]){A.msg="invalid code -- missing end-of-block",t.mode=30;break}if(t.lenbits=9,k={bits:t.lenbits},y=rA(1,t.lens,0,t.nlen,t.lencode,0,t.work,k),t.lenbits=k.bits,y){A.msg="invalid literal/lengths set",t.mode=30;break}if(t.distbits=6,t.distcode=t.distdyn,k={bits:t.distbits},y=rA(2,t.lens,t.nlen,t.ndist,t.distcode,0,t.work,k),t.distbits=k.bits,y){A.msg="invalid distances set",t.mode=30;break}if(t.mode=20,e===nA)break A;case 20:t.mode=21;case 21:if(n>=6&&a>=258){A.next_out=g,A.avail_out=a,A.next_in=I,A.avail_in=n,t.hold=o,t.bits=B,$(A,Q),g=A.next_out,r=A.output,a=A.avail_out,I=A.next_in,i=A.input,n=A.avail_in,o=t.hold,B=t.bits,12===t.mode&&(t.back=-1);break}for(t.back=0;h=(m=t.lencode[o&(1<<t.lenbits)-1])>>>16&255,l=65535&m,!((c=m>>>24)<=B);){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(h&&0==(240&h)){for(u=c,w=h,d=l;h=(m=t.lencode[d+((o&(1<<u+w)-1)>>u)])>>>16&255,l=65535&m,!(u+(c=m>>>24)<=B);){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}o>>>=u,B-=u,t.back+=u}if(o>>>=c,B-=c,t.back+=c,t.length=l,0===h){t.mode=26;break}if(32&h){t.back=-1,t.mode=12;break}if(64&h){A.msg="invalid literal/length code",t.mode=30;break}t.extra=15&h,t.mode=22;case 22:if(t.extra){for(p=t.extra;B<p;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.length+=o&(1<<t.extra)-1,o>>>=t.extra,B-=t.extra,t.back+=t.extra}t.was=t.length,t.mode=23;case 23:for(;h=(m=t.distcode[o&(1<<t.distbits)-1])>>>16&255,l=65535&m,!((c=m>>>24)<=B);){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(0==(240&h)){for(u=c,w=h,d=l;h=(m=t.distcode[d+((o&(1<<u+w)-1)>>u)])>>>16&255,l=65535&m,!(u+(c=m>>>24)<=B);){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}o>>>=u,B-=u,t.back+=u}if(o>>>=c,B-=c,t.back+=c,64&h){A.msg="invalid distance code",t.mode=30;break}t.offset=l,t.extra=15&h,t.mode=24;case 24:if(t.extra){for(p=t.extra;B<p;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}t.offset+=o&(1<<t.extra)-1,o>>>=t.extra,B-=t.extra,t.back+=t.extra}if(t.offset>t.dmax){A.msg="invalid distance too far back",t.mode=30;break}t.mode=25;case 25:if(0===a)break A;if(E=Q-a,t.offset>E){if((E=t.offset-E)>t.whave&&t.sane){A.msg="invalid distance too far back",t.mode=30;break}E>t.wnext?(E-=t.wnext,s=t.wsize-E):s=t.wnext-E,E>t.length&&(E=t.length),f=t.window}else f=r,s=g-t.offset,E=t.length;E>a&&(E=a),a-=E,t.length-=E;do{r[g++]=f[s++]}while(--E);0===t.length&&(t.mode=21);break;case 26:if(0===a)break A;r[g++]=t.length,a--,t.mode=21;break;case 27:if(t.wrap){for(;B<32;){if(0===n)break A;n--,o|=i[I++]<<B,B+=8}if(Q-=a,A.total_out+=Q,t.total+=Q,Q&&(A.adler=t.check=t.flags?Y(t.check,r,Q,g-Q):J(t.check,r,Q,g-Q)),Q=a,(t.flags?o:cA(o))!==t.check){A.msg="incorrect data check",t.mode=30;break}o=0,B=0}t.mode=28;case 28:if(t.wrap&&t.flags){for(;B<32;){if(0===n)break A;n--,o+=i[I++]<<B,B+=8}if(o!==(4294967295&t.total)){A.msg="incorrect length check",t.mode=30;break}o=0,B=0}t.mode=29;case 29:y=oA;break A;case 30:y=QA;break A;case 31:return EA;default:return CA}return A.next_out=g,A.avail_out=a,A.next_in=I,A.avail_in=n,t.hold=o,t.bits=B,(t.wsize||Q!==A.avail_out&&t.mode<30&&(t.mode<27||e!==IA))&&mA(A,A.output,A.next_out,Q-A.avail_out),C-=A.avail_in,Q-=A.avail_out,A.total_in+=C,A.total_out+=Q,t.total+=Q,t.wrap&&Q&&(A.adler=t.check=t.flags?Y(t.check,r,Q,A.next_out-Q):J(t.check,r,Q,A.next_out-Q)),A.data_type=t.bits+(t.last?64:0)+(12===t.mode?128:0)+(20===t.mode||15===t.mode?256:0),(0===C&&0===Q||e===IA)&&y===aA&&(y=sA),y},inflateEnd:function(A){if(!A||!A.state)return CA;var e=A.state;return e.window&&(e.window=null),A.state=null,aA},inflateGetHeader:function(A,e){if(!A||!A.state)return CA;var t=A.state;return 0==(2&t.wrap)?CA:(t.head=e,e.done=!1,aA)},inflateSetDictionary:function(A,e){var t,i=e.length;return A&&A.state?0!==(t=A.state).wrap&&11!==t.mode?CA:11===t.mode&&J(1,e,i,0)!==t.check?QA:mA(A,e,i,i)?(t.mode=31,EA):(t.havedict=1,aA):CA},inflateInfo:"pako inflate (from Nodeca project)"};var FA=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},SA=Object.prototype.toString,vA=H.Z_NO_FLUSH,RA=H.Z_FINISH,UA=H.Z_OK,LA=H.Z_STREAM_END,bA=H.Z_NEED_DICT,MA=H.Z_STREAM_ERROR,NA=H.Z_DATA_ERROR,xA=H.Z_MEM_ERROR;function JA(A){this.options=P({chunkSize:65536,windowBits:15,to:""},A||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||A&&A.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new z,this.strm.avail_out=0;var t=GA.inflateInit2(this.strm,e.windowBits);if(t!==UA)throw new Error(K[t]);if(this.header=new FA,GA.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Z(e.dictionary):"[object ArrayBuffer]"===SA.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(t=GA.inflateSetDictionary(this.strm,e.dictionary))!==UA))throw new Error(K[t])}function qA(A,e){var t=new JA(e);if(t.push(A),t.err)throw t.msg||K[t.err];return t.result}JA.prototype.push=function(A,e){var t,i,r,I=this.strm,g=this.options.chunkSize,n=this.options.dictionary;if(this.ended)return!1;for(i=e===~~e?e:!0===e?RA:vA,"[object ArrayBuffer]"===SA.call(A)?I.input=new Uint8Array(A):I.input=A,I.next_in=0,I.avail_in=I.input.length;;){for(0===I.avail_out&&(I.output=new Uint8Array(g),I.next_out=0,I.avail_out=g),(t=GA.inflate(I,i))===bA&&n&&((t=GA.inflateSetDictionary(I,n))===UA?t=GA.inflate(I,i):t===NA&&(t=bA));I.avail_in>0&&t===LA&&I.state.wrap>0&&0!==A[I.next_in];)GA.inflateReset(I),t=GA.inflate(I,i);switch(t){case MA:case NA:case bA:case xA:return this.onEnd(t),this.ended=!0,!1}if(r=I.avail_out,I.next_out&&(0===I.avail_out||t===LA))if("string"===this.options.to){var a=W(I.output,I.next_out),o=I.next_out-a,B=j(I.output,a);I.next_out=o,I.avail_out=g-o,o&&I.output.set(I.output.subarray(a,a+o),0),this.onData(B)}else this.onData(I.output.length===I.next_out?I.output:I.output.subarray(0,I.next_out));if(t!==UA||0!==r){if(t===LA)return t=GA.inflateEnd(this.strm),this.onEnd(t),this.ended=!0,!0;if(0===I.avail_in)break}}return!0},JA.prototype.onData=function(A){this.chunks.push(A)},JA.prototype.onEnd=function(A){A===UA&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=T(this.chunks)),this.chunks=[],this.err=A,this.msg=this.strm.msg};var YA={Inflate:JA,inflate:qA,inflateRaw:function(A,e){return(e=e||{}).raw=!0,qA(A,e)},ungzip:qA,constants:H}.inflate;function KA(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var HA=function(A){s(t,w);var e=KA(t);function t(){return B(this,t),e.apply(this,arguments)}return Q(t,[{key:"decodeBlock",value:function(A){return YA(new Uint8Array(A)).buffer}}]),t}(),OA=Object.freeze({__proto__:null,default:HA});function PA(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var TA,VA=function(A){s(t,w);var e=PA(t);function t(){return B(this,t),e.apply(this,arguments)}return Q(t,[{key:"decodeBlock",value:function(A){for(var e=new DataView(A),t=[],i=0;i<A.byteLength;++i){var r=e.getInt8(i);if(r<0){var I=e.getUint8(i+1);r=-r;for(var g=0;g<=r;++g)t.push(I);i+=1}else{for(var n=0;n<=r;++n)t.push(e.getUint8(i+n+1));i+=r+1}}return new Uint8Array(t).buffer}}]),t}(),_A=Object.freeze({__proto__:null,default:VA}),XA={exports:{}};TA=XA,\n/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */\nfunction(){var A,e,t,i,r,I,g,n,a,o,B,C,Q,E,s,f,c=(A={defaultNoDataValue:-34027999387901484e22,decode:function(I,g){var n=(g=g||{}).encodedMaskData||null===g.encodedMaskData,a=r(I,g.inputOffset||0,n),o=null!==g.noDataValue?g.noDataValue:A.defaultNoDataValue,B=e(a,g.pixelType||Float32Array,g.encodedMaskData,o,g.returnMask),C={width:a.width,height:a.height,pixelData:B.resultPixels,minValue:B.minValue,maxValue:a.pixels.maxValue,noDataValue:o};return B.resultMask&&(C.maskData=B.resultMask),g.returnEncodedMask&&a.mask&&(C.encodedMaskData=a.mask.bitset?a.mask.bitset:null),g.returnFileInfo&&(C.fileInfo=t(a),g.computeUsedBitDepths&&(C.fileInfo.bitDepths=i(a))),C}},e=function(A,e,t,i,r){var g,n,a,o=0,B=A.pixels.numBlocksX,C=A.pixels.numBlocksY,Q=Math.floor(A.width/B),E=Math.floor(A.height/C),s=2*A.maxZError,f=Number.MAX_VALUE;t=t||(A.mask?A.mask.bitset:null),n=new e(A.width*A.height),r&&t&&(a=new Uint8Array(A.width*A.height));for(var c,h,l=new Float32Array(Q*E),u=0;u<=C;u++){var w=u!==C?E:A.height%C;if(0!==w)for(var d=0;d<=B;d++){var D=d!==B?Q:A.width%B;if(0!==D){var y,k,p,m,G=u*A.width*E+d*Q,F=A.width-D,S=A.pixels.blocks[o];if(S.encoding<2?(0===S.encoding?y=S.rawData:(I(S.stuffedData,S.bitsPerPixel,S.numValidPixels,S.offset,s,l,A.pixels.maxValue),y=l),k=0):p=2===S.encoding?0:S.offset,t)for(h=0;h<w;h++){for(7&G&&(m=t[G>>3],m<<=7&G),c=0;c<D;c++)7&G||(m=t[G>>3]),128&m?(a&&(a[G]=1),f=f>(g=S.encoding<2?y[k++]:p)?g:f,n[G++]=g):(a&&(a[G]=0),n[G++]=i),m<<=1;G+=F}else if(S.encoding<2)for(h=0;h<w;h++){for(c=0;c<D;c++)f=f>(g=y[k++])?g:f,n[G++]=g;G+=F}else for(f=f>p?p:f,h=0;h<w;h++){for(c=0;c<D;c++)n[G++]=p;G+=F}if(1===S.encoding&&k!==S.numValidPixels)throw"Block and Mask do not match";o++}}}return{resultPixels:n,resultMask:a,minValue:f}},t=function(A){return{fileIdentifierString:A.fileIdentifierString,fileVersion:A.fileVersion,imageType:A.imageType,height:A.height,width:A.width,maxZError:A.maxZError,eofOffset:A.eofOffset,mask:A.mask?{numBlocksX:A.mask.numBlocksX,numBlocksY:A.mask.numBlocksY,numBytes:A.mask.numBytes,maxValue:A.mask.maxValue}:null,pixels:{numBlocksX:A.pixels.numBlocksX,numBlocksY:A.pixels.numBlocksY,numBytes:A.pixels.numBytes,maxValue:A.pixels.maxValue,noDataValue:A.noDataValue}}},i=function(A){for(var e=A.pixels.numBlocksX*A.pixels.numBlocksY,t={},i=0;i<e;i++){var r=A.pixels.blocks[i];0===r.encoding?t.float32=!0:1===r.encoding?t[r.bitsPerPixel]=!0:t[0]=!0}return Object.keys(t)},r=function(A,e,t){var i={},r=new Uint8Array(A,e,10);if(i.fileIdentifierString=String.fromCharCode.apply(null,r),"CntZImage"!==i.fileIdentifierString.trim())throw"Unexpected file identifier string: "+i.fileIdentifierString;e+=10;var I=new DataView(A,e,24);if(i.fileVersion=I.getInt32(0,!0),i.imageType=I.getInt32(4,!0),i.height=I.getUint32(8,!0),i.width=I.getUint32(12,!0),i.maxZError=I.getFloat64(16,!0),e+=24,!t)if(I=new DataView(A,e,16),i.mask={},i.mask.numBlocksY=I.getUint32(0,!0),i.mask.numBlocksX=I.getUint32(4,!0),i.mask.numBytes=I.getUint32(8,!0),i.mask.maxValue=I.getFloat32(12,!0),e+=16,i.mask.numBytes>0){var g=new Uint8Array(Math.ceil(i.width*i.height/8)),n=(I=new DataView(A,e,i.mask.numBytes)).getInt16(0,!0),a=2,o=0;do{if(n>0)for(;n--;)g[o++]=I.getUint8(a++);else{var B=I.getUint8(a++);for(n=-n;n--;)g[o++]=B}n=I.getInt16(a,!0),a+=2}while(a<i.mask.numBytes);if(-32768!==n||o<g.length)throw"Unexpected end of mask RLE encoding";i.mask.bitset=g,e+=i.mask.numBytes}else 0==(i.mask.numBytes|i.mask.numBlocksY|i.mask.maxValue)&&(i.mask.bitset=new Uint8Array(Math.ceil(i.width*i.height/8)));I=new DataView(A,e,16),i.pixels={},i.pixels.numBlocksY=I.getUint32(0,!0),i.pixels.numBlocksX=I.getUint32(4,!0),i.pixels.numBytes=I.getUint32(8,!0),i.pixels.maxValue=I.getFloat32(12,!0),e+=16;var C=i.pixels.numBlocksX,Q=i.pixels.numBlocksY,E=C+(i.width%C>0?1:0),s=Q+(i.height%Q>0?1:0);i.pixels.blocks=new Array(E*s);for(var f=0,c=0;c<s;c++)for(var h=0;h<E;h++){var l=0,u=A.byteLength-e;I=new DataView(A,e,Math.min(10,u));var w={};i.pixels.blocks[f++]=w;var d=I.getUint8(0);if(l++,w.encoding=63&d,w.encoding>3)throw"Invalid block encoding ("+w.encoding+")";if(2!==w.encoding){if(0!==d&&2!==d){if(d>>=6,w.offsetType=d,2===d)w.offset=I.getInt8(1),l++;else if(1===d)w.offset=I.getInt16(1,!0),l+=2;else{if(0!==d)throw"Invalid block offset type";w.offset=I.getFloat32(1,!0),l+=4}if(1===w.encoding)if(d=I.getUint8(l),l++,w.bitsPerPixel=63&d,d>>=6,w.numValidPixelsType=d,2===d)w.numValidPixels=I.getUint8(l),l++;else if(1===d)w.numValidPixels=I.getUint16(l,!0),l+=2;else{if(0!==d)throw"Invalid valid pixel count type";w.numValidPixels=I.getUint32(l,!0),l+=4}}var D;if(e+=l,3!==w.encoding)if(0===w.encoding){var y=(i.pixels.numBytes-1)/4;if(y!==Math.floor(y))throw"uncompressed block has invalid length";D=new ArrayBuffer(4*y),new Uint8Array(D).set(new Uint8Array(A,e,4*y));var k=new Float32Array(D);w.rawData=k,e+=4*y}else if(1===w.encoding){var p=Math.ceil(w.numValidPixels*w.bitsPerPixel/8),m=Math.ceil(p/4);D=new ArrayBuffer(4*m),new Uint8Array(D).set(new Uint8Array(A,e,p)),w.stuffedData=new Uint32Array(D),e+=p}}else e++}return i.eofOffset=e,i},I=function(A,e,t,i,r,I,g){var n,a,o,B=(1<<e)-1,C=0,Q=0,E=Math.ceil((g-i)/r),s=4*A.length-Math.ceil(e*t/8);for(A[A.length-1]<<=8*s,n=0;n<t;n++){if(0===Q&&(o=A[C++],Q=32),Q>=e)a=o>>>Q-e&B,Q-=e;else{var f=e-Q;a=(o&B)<<f&B,a+=(o=A[C++])>>>(Q=32-f)}I[n]=a<E?i+a*r:g}return I},A),h=(g=function(A,e,t,i,r,I,g,n){var a,o,B,C,Q,E=(1<<t)-1,s=0,f=0,c=4*A.length-Math.ceil(t*i/8);if(A[A.length-1]<<=8*c,r)for(a=0;a<i;a++)0===f&&(B=A[s++],f=32),f>=t?(o=B>>>f-t&E,f-=t):(o=(B&E)<<(C=t-f)&E,o+=(B=A[s++])>>>(f=32-C)),e[a]=r[o];else for(Q=Math.ceil((n-I)/g),a=0;a<i;a++)0===f&&(B=A[s++],f=32),f>=t?(o=B>>>f-t&E,f-=t):(o=(B&E)<<(C=t-f)&E,o+=(B=A[s++])>>>(f=32-C)),e[a]=o<Q?I+o*g:n},n=function(A,e,t,i,r,I){var g,n=(1<<e)-1,a=0,o=0,B=0,C=0,Q=0,E=[],s=4*A.length-Math.ceil(e*t/8);A[A.length-1]<<=8*s;var f=Math.ceil((I-i)/r);for(o=0;o<t;o++)0===C&&(g=A[a++],C=32),C>=e?(Q=g>>>C-e&n,C-=e):(Q=(g&n)<<(B=e-C)&n,Q+=(g=A[a++])>>>(C=32-B)),E[o]=Q<f?i+Q*r:I;return E.unshift(i),E},a=function(A,e,t,i,r,I,g,n){var a,o,B,C,Q=(1<<t)-1,E=0,s=0,f=0;if(r)for(a=0;a<i;a++)0===s&&(B=A[E++],s=32,f=0),s>=t?(o=B>>>f&Q,s-=t,f+=t):(o=B>>>f&Q,s=32-(C=t-s),o|=((B=A[E++])&(1<<C)-1)<<t-C,f=C),e[a]=r[o];else{var c=Math.ceil((n-I)/g);for(a=0;a<i;a++)0===s&&(B=A[E++],s=32,f=0),s>=t?(o=B>>>f&Q,s-=t,f+=t):(o=B>>>f&Q,s=32-(C=t-s),o|=((B=A[E++])&(1<<C)-1)<<t-C,f=C),e[a]=o<c?I+o*g:n}return e},o=function(A,e,t,i,r,I){var g,n=(1<<e)-1,a=0,o=0,B=0,C=0,Q=0,E=0,s=[],f=Math.ceil((I-i)/r);for(o=0;o<t;o++)0===C&&(g=A[a++],C=32,E=0),C>=e?(Q=g>>>E&n,C-=e,E+=e):(Q=g>>>E&n,C=32-(B=e-C),Q|=((g=A[a++])&(1<<B)-1)<<e-B,E=B),s[o]=Q<f?i+Q*r:I;return s.unshift(i),s},B=function(A,e,t,i){var r,I,g,n,a=(1<<t)-1,o=0,B=0,C=4*A.length-Math.ceil(t*i/8);for(A[A.length-1]<<=8*C,r=0;r<i;r++)0===B&&(g=A[o++],B=32),B>=t?(I=g>>>B-t&a,B-=t):(I=(g&a)<<(n=t-B)&a,I+=(g=A[o++])>>>(B=32-n)),e[r]=I;return e},C=function(A,e,t,i){var r,I,g,n,a=(1<<t)-1,o=0,B=0,C=0;for(r=0;r<i;r++)0===B&&(g=A[o++],B=32,C=0),B>=t?(I=g>>>C&a,B-=t,C+=t):(I=g>>>C&a,B=32-(n=t-B),I|=((g=A[o++])&(1<<n)-1)<<t-n,C=n),e[r]=I;return e},Q={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(A){for(var e=65535,t=65535,i=A.length,r=Math.floor(i/2),I=0;r;){var g=r>=359?359:r;r-=g;do{e+=A[I++]<<8,t+=e+=A[I++]}while(--g);e=(65535&e)+(e>>>16),t=(65535&t)+(t>>>16)}return 1&i&&(t+=e+=A[I]<<8),((t=(65535&t)+(t>>>16))<<16|(e=(65535&e)+(e>>>16)))>>>0},readHeaderInfo:function(A,e){var t=e.ptr,i=new Uint8Array(A,t,6),r={};if(r.fileIdentifierString=String.fromCharCode.apply(null,i),0!==r.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+r.fileIdentifierString;t+=6;var I,g=new DataView(A,t,8),n=g.getInt32(0,!0);if(r.fileVersion=n,t+=4,n>=3&&(r.checksum=g.getUint32(4,!0),t+=4),g=new DataView(A,t,12),r.height=g.getUint32(0,!0),r.width=g.getUint32(4,!0),t+=8,n>=4?(r.numDims=g.getUint32(8,!0),t+=4):r.numDims=1,g=new DataView(A,t,40),r.numValidPixel=g.getUint32(0,!0),r.microBlockSize=g.getInt32(4,!0),r.blobSize=g.getInt32(8,!0),r.imageType=g.getInt32(12,!0),r.maxZError=g.getFloat64(16,!0),r.zMin=g.getFloat64(24,!0),r.zMax=g.getFloat64(32,!0),t+=40,e.headerInfo=r,e.ptr=t,n>=3&&(I=n>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(A,t-I,r.blobSize-14))!==r.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(A,e){var t=e.headerInfo,i=this.getDataTypeArray(t.imageType),r=t.numDims*this.getDataTypeSize(t.imageType),I=this.readSubArray(A,e.ptr,i,r),g=this.readSubArray(A,e.ptr+r,i,r);e.ptr+=2*r;var n,a=!0;for(n=0;n<t.numDims;n++)if(I[n]!==g[n]){a=!1;break}return t.minValues=I,t.maxValues=g,a},readSubArray:function(A,e,t,i){var r;if(t===Uint8Array)r=new Uint8Array(A,e,i);else{var I=new ArrayBuffer(i);new Uint8Array(I).set(new Uint8Array(A,e,i)),r=new t(I)}return r},readMask:function(A,e){var t,i,r=e.ptr,I=e.headerInfo,g=I.width*I.height,n=I.numValidPixel,a=new DataView(A,r,4),o={};if(o.numBytes=a.getUint32(0,!0),r+=4,(0===n||g===n)&&0!==o.numBytes)throw"invalid mask";if(0===n)t=new Uint8Array(Math.ceil(g/8)),o.bitset=t,i=new Uint8Array(g),e.pixels.resultMask=i,r+=o.numBytes;else if(o.numBytes>0){t=new Uint8Array(Math.ceil(g/8));var B=(a=new DataView(A,r,o.numBytes)).getInt16(0,!0),C=2,Q=0,E=0;do{if(B>0)for(;B--;)t[Q++]=a.getUint8(C++);else for(E=a.getUint8(C++),B=-B;B--;)t[Q++]=E;B=a.getInt16(C,!0),C+=2}while(C<o.numBytes);if(-32768!==B||Q<t.length)throw"Unexpected end of mask RLE encoding";i=new Uint8Array(g);var s=0,f=0;for(f=0;f<g;f++)7&f?(s=t[f>>3],s<<=7&f):s=t[f>>3],128&s&&(i[f]=1);e.pixels.resultMask=i,o.bitset=t,r+=o.numBytes}return e.ptr=r,e.mask=o,!0},readDataOneSweep:function(A,e,t,i){var r,I=e.ptr,g=e.headerInfo,n=g.numDims,a=g.width*g.height,o=g.imageType,B=g.numValidPixel*Q.getDataTypeSize(o)*n,C=e.pixels.resultMask;if(t===Uint8Array)r=new Uint8Array(A,I,B);else{var E=new ArrayBuffer(B);new Uint8Array(E).set(new Uint8Array(A,I,B)),r=new t(E)}if(r.length===a*n)e.pixels.resultPixels=i?Q.swapDimensionOrder(r,a,n,t,!0):r;else{e.pixels.resultPixels=new t(a*n);var s=0,f=0,c=0,h=0;if(n>1){if(i){for(f=0;f<a;f++)if(C[f])for(h=f,c=0;c<n;c++,h+=a)e.pixels.resultPixels[h]=r[s++]}else for(f=0;f<a;f++)if(C[f])for(h=f*n,c=0;c<n;c++)e.pixels.resultPixels[h+c]=r[s++]}else for(f=0;f<a;f++)C[f]&&(e.pixels.resultPixels[f]=r[s++])}return I+=B,e.ptr=I,!0},readHuffmanTree:function(A,e){var t=this.HUFFMAN_LUT_BITS_MAX,i=new DataView(A,e.ptr,16);if(e.ptr+=16,i.getInt32(0,!0)<2)throw"unsupported Huffman version";var r=i.getInt32(4,!0),I=i.getInt32(8,!0),g=i.getInt32(12,!0);if(I>=g)return!1;var n=new Uint32Array(g-I);Q.decodeBits(A,e,n);var a,o,B,C,s=[];for(a=I;a<g;a++)s[o=a-(a<r?0:r)]={first:n[a-I],second:null};var f=A.byteLength-e.ptr,c=Math.ceil(f/4),h=new ArrayBuffer(4*c);new Uint8Array(h).set(new Uint8Array(A,e.ptr,f));var l,u=new Uint32Array(h),w=0,d=0;for(l=u[0],a=I;a<g;a++)(C=s[o=a-(a<r?0:r)].first)>0&&(s[o].second=l<<w>>>32-C,32-w>=C?32===(w+=C)&&(w=0,l=u[++d]):(w+=C-32,l=u[++d],s[o].second|=l>>>32-w));var D=0,y=0,k=new E;for(a=0;a<s.length;a++)void 0!==s[a]&&(D=Math.max(D,s[a].first));y=D>=t?t:D;var p,m,G,F,S,v=[];for(a=I;a<g;a++)if((C=s[o=a-(a<r?0:r)].first)>0)if(p=[C,o],C<=y)for(m=s[o].second<<y-C,G=1<<y-C,B=0;B<G;B++)v[m|B]=p;else for(m=s[o].second,S=k,F=C-1;F>=0;F--)m>>>F&1?(S.right||(S.right=new E),S=S.right):(S.left||(S.left=new E),S=S.left),0!==F||S.val||(S.val=p[1]);return{decodeLut:v,numBitsLUTQick:y,numBitsLUT:D,tree:k,stuffedData:u,srcPtr:d,bitPos:w}},readHuffman:function(A,e,t,i){var r,I,g,n,a,o,B,C,E,s=e.headerInfo.numDims,f=e.headerInfo.height,c=e.headerInfo.width,h=c*f,l=this.readHuffmanTree(A,e),u=l.decodeLut,w=l.tree,d=l.stuffedData,D=l.srcPtr,y=l.bitPos,k=l.numBitsLUTQick,p=l.numBitsLUT,m=0===e.headerInfo.imageType?128:0,G=e.pixels.resultMask,F=0;y>0&&(D++,y=0);var S,v=d[D],R=1===e.encodeMode,U=new t(h*s),L=U;if(s<2||R){for(S=0;S<s;S++)if(s>1&&(L=new t(U.buffer,h*S,h),F=0),e.headerInfo.numValidPixel===c*f)for(C=0,o=0;o<f;o++)for(B=0;B<c;B++,C++){if(I=0,a=n=v<<y>>>32-k,32-y<k&&(a=n|=d[D+1]>>>64-y-k),u[a])I=u[a][1],y+=u[a][0];else for(a=n=v<<y>>>32-p,32-y<p&&(a=n|=d[D+1]>>>64-y-p),r=w,E=0;E<p;E++)if(!(r=n>>>p-E-1&1?r.right:r.left).left&&!r.right){I=r.val,y=y+E+1;break}y>=32&&(y-=32,v=d[++D]),g=I-m,R?(g+=B>0?F:o>0?L[C-c]:F,g&=255,L[C]=g,F=g):L[C]=g}else for(C=0,o=0;o<f;o++)for(B=0;B<c;B++,C++)if(G[C]){if(I=0,a=n=v<<y>>>32-k,32-y<k&&(a=n|=d[D+1]>>>64-y-k),u[a])I=u[a][1],y+=u[a][0];else for(a=n=v<<y>>>32-p,32-y<p&&(a=n|=d[D+1]>>>64-y-p),r=w,E=0;E<p;E++)if(!(r=n>>>p-E-1&1?r.right:r.left).left&&!r.right){I=r.val,y=y+E+1;break}y>=32&&(y-=32,v=d[++D]),g=I-m,R?(B>0&&G[C-1]?g+=F:o>0&&G[C-c]?g+=L[C-c]:g+=F,g&=255,L[C]=g,F=g):L[C]=g}}else for(C=0,o=0;o<f;o++)for(B=0;B<c;B++)if(C=o*c+B,!G||G[C])for(S=0;S<s;S++,C+=h){if(I=0,a=n=v<<y>>>32-k,32-y<k&&(a=n|=d[D+1]>>>64-y-k),u[a])I=u[a][1],y+=u[a][0];else for(a=n=v<<y>>>32-p,32-y<p&&(a=n|=d[D+1]>>>64-y-p),r=w,E=0;E<p;E++)if(!(r=n>>>p-E-1&1?r.right:r.left).left&&!r.right){I=r.val,y=y+E+1;break}y>=32&&(y-=32,v=d[++D]),g=I-m,L[C]=g}e.ptr=e.ptr+4*(D+1)+(y>0?4:0),e.pixels.resultPixels=U,s>1&&!i&&(e.pixels.resultPixels=Q.swapDimensionOrder(U,h,s,t))},decodeBits:function(A,e,t,i,r){var I=e.headerInfo,Q=I.fileVersion,E=0,s=A.byteLength-e.ptr>=5?5:A.byteLength-e.ptr,f=new DataView(A,e.ptr,s),c=f.getUint8(0);E++;var h=c>>6,l=0===h?4:3-h,u=(32&c)>0,w=31&c,d=0;if(1===l)d=f.getUint8(E),E++;else if(2===l)d=f.getUint16(E,!0),E+=2;else{if(4!==l)throw"Invalid valid pixel count type";d=f.getUint32(E,!0),E+=4}var D,y,k,p,m,G,F,S,v,R=2*I.maxZError,U=I.numDims>1?I.maxValues[r]:I.zMax;if(u){for(e.counter.lut++,S=f.getUint8(E),E++,p=Math.ceil((S-1)*w/8),m=Math.ceil(p/4),y=new ArrayBuffer(4*m),k=new Uint8Array(y),e.ptr+=E,k.set(new Uint8Array(A,e.ptr,p)),F=new Uint32Array(y),e.ptr+=p,v=0;S-1>>>v;)v++;p=Math.ceil(d*v/8),m=Math.ceil(p/4),y=new ArrayBuffer(4*m),(k=new Uint8Array(y)).set(new Uint8Array(A,e.ptr,p)),D=new Uint32Array(y),e.ptr+=p,G=Q>=3?o(F,w,S-1,i,R,U):n(F,w,S-1,i,R,U),Q>=3?a(D,t,v,d,G):g(D,t,v,d,G)}else e.counter.bitstuffer++,v=w,e.ptr+=E,v>0&&(p=Math.ceil(d*v/8),m=Math.ceil(p/4),y=new ArrayBuffer(4*m),(k=new Uint8Array(y)).set(new Uint8Array(A,e.ptr,p)),D=new Uint32Array(y),e.ptr+=p,Q>=3?null==i?C(D,t,v,d):a(D,t,v,d,!1,i,R,U):null==i?B(D,t,v,d):g(D,t,v,d,!1,i,R,U))},readTiles:function(A,e,t,i){var r=e.headerInfo,I=r.width,g=r.height,n=I*g,a=r.microBlockSize,o=r.imageType,B=Q.getDataTypeSize(o),C=Math.ceil(I/a),E=Math.ceil(g/a);e.pixels.numBlocksY=E,e.pixels.numBlocksX=C,e.pixels.ptr=0;var s,f,c,h,l,u,w,d,D,y,k=0,p=0,m=0,G=0,F=0,S=0,v=0,R=0,U=0,L=0,b=0,M=0,N=0,x=0,J=0,q=new t(a*a),Y=g%a||a,K=I%a||a,H=r.numDims,O=e.pixels.resultMask,P=e.pixels.resultPixels,T=r.fileVersion>=5?14:15,V=r.zMax;for(m=0;m<E;m++)for(F=m!==E-1?a:Y,G=0;G<C;G++)for(L=m*I*a+G*a,b=I-(S=G!==C-1?a:K),d=0;d<H;d++){if(H>1?(y=P,L=m*I*a+G*a,P=new t(e.pixels.resultPixels.buffer,n*d*B,n),V=r.maxValues[d]):y=null,v=A.byteLength-e.ptr,f={},J=0,R=(s=new DataView(A,e.ptr,Math.min(10,v))).getUint8(0),J++,D=r.fileVersion>=5?4&R:0,U=R>>6&255,(R>>2&T)!=(G*a>>3&T))throw"integrity issue";if(D&&0===d)throw"integrity issue";if((l=3&R)>3)throw e.ptr+=J,"Invalid block encoding ("+l+")";if(2!==l)if(0===l){if(D)throw"integrity issue";if(e.counter.uncompressed++,e.ptr+=J,M=(M=F*S*B)<(N=A.byteLength-e.ptr)?M:N,c=new ArrayBuffer(M%B==0?M:M+B-M%B),new Uint8Array(c).set(new Uint8Array(A,e.ptr,M)),h=new t(c),x=0,O)for(k=0;k<F;k++){for(p=0;p<S;p++)O[L]&&(P[L]=h[x++]),L++;L+=b}else for(k=0;k<F;k++){for(p=0;p<S;p++)P[L++]=h[x++];L+=b}e.ptr+=x*B}else if(u=Q.getDataTypeUsed(D&&o<6?4:o,U),w=Q.getOnePixel(f,J,u,s),J+=Q.getDataTypeSize(u),3===l)if(e.ptr+=J,e.counter.constantoffset++,O)for(k=0;k<F;k++){for(p=0;p<S;p++)O[L]&&(P[L]=D?Math.min(V,y[L]+w):w),L++;L+=b}else for(k=0;k<F;k++){for(p=0;p<S;p++)P[L]=D?Math.min(V,y[L]+w):w,L++;L+=b}else if(e.ptr+=J,Q.decodeBits(A,e,q,w,d),J=0,D)if(O)for(k=0;k<F;k++){for(p=0;p<S;p++)O[L]&&(P[L]=q[J++]+y[L]),L++;L+=b}else for(k=0;k<F;k++){for(p=0;p<S;p++)P[L]=q[J++]+y[L],L++;L+=b}else if(O)for(k=0;k<F;k++){for(p=0;p<S;p++)O[L]&&(P[L]=q[J++]),L++;L+=b}else for(k=0;k<F;k++){for(p=0;p<S;p++)P[L++]=q[J++];L+=b}else{if(D)if(O)for(k=0;k<F;k++)for(p=0;p<S;p++)O[L]&&(P[L]=y[L]),L++;else for(k=0;k<F;k++)for(p=0;p<S;p++)P[L]=y[L],L++;e.counter.constant++,e.ptr+=J}}H>1&&!i&&(e.pixels.resultPixels=Q.swapDimensionOrder(e.pixels.resultPixels,n,H,t))},formatFileInfo:function(A){return{fileIdentifierString:A.headerInfo.fileIdentifierString,fileVersion:A.headerInfo.fileVersion,imageType:A.headerInfo.imageType,height:A.headerInfo.height,width:A.headerInfo.width,numValidPixel:A.headerInfo.numValidPixel,microBlockSize:A.headerInfo.microBlockSize,blobSize:A.headerInfo.blobSize,maxZError:A.headerInfo.maxZError,pixelType:Q.getPixelType(A.headerInfo.imageType),eofOffset:A.eofOffset,mask:A.mask?{numBytes:A.mask.numBytes}:null,pixels:{numBlocksX:A.pixels.numBlocksX,numBlocksY:A.pixels.numBlocksY,maxValue:A.headerInfo.zMax,minValue:A.headerInfo.zMin,noDataValue:A.noDataValue}}},constructConstantSurface:function(A,e){var t=A.headerInfo.zMax,i=A.headerInfo.zMin,r=A.headerInfo.maxValues,I=A.headerInfo.numDims,g=A.headerInfo.height*A.headerInfo.width,n=0,a=0,o=0,B=A.pixels.resultMask,C=A.pixels.resultPixels;if(B)if(I>1){if(e)for(n=0;n<I;n++)for(o=n*g,t=r[n],a=0;a<g;a++)B[a]&&(C[o+a]=t);else for(a=0;a<g;a++)if(B[a])for(o=a*I,n=0;n<I;n++)C[o+I]=r[n]}else for(a=0;a<g;a++)B[a]&&(C[a]=t);else if(I>1&&i!==t)if(e)for(n=0;n<I;n++)for(o=n*g,t=r[n],a=0;a<g;a++)C[o+a]=t;else for(a=0;a<g;a++)for(o=a*I,n=0;n<I;n++)C[o+n]=r[n];else for(a=0;a<g*I;a++)C[a]=t},getDataTypeArray:function(A){var e;switch(A){case 0:e=Int8Array;break;case 1:e=Uint8Array;break;case 2:e=Int16Array;break;case 3:e=Uint16Array;break;case 4:e=Int32Array;break;case 5:e=Uint32Array;break;case 6:default:e=Float32Array;break;case 7:e=Float64Array}return e},getPixelType:function(A){var e;switch(A){case 0:e="S8";break;case 1:e="U8";break;case 2:e="S16";break;case 3:e="U16";break;case 4:e="S32";break;case 5:e="U32";break;case 6:default:e="F32";break;case 7:e="F64"}return e},isValidPixelValue:function(A,e){if(null==e)return!1;var t;switch(A){case 0:t=e>=-128&&e<=127;break;case 1:t=e>=0&&e<=255;break;case 2:t=e>=-32768&&e<=32767;break;case 3:t=e>=0&&e<=65536;break;case 4:t=e>=-2147483648&&e<=2147483647;break;case 5:t=e>=0&&e<=4294967296;break;case 6:t=e>=-34027999387901484e22&&e<=34027999387901484e22;break;case 7:t=e>=-17976931348623157e292&&e<=17976931348623157e292;break;default:t=!1}return t},getDataTypeSize:function(A){var e=0;switch(A){case 0:case 1:e=1;break;case 2:case 3:e=2;break;case 4:case 5:case 6:e=4;break;case 7:e=8;break;default:e=A}return e},getDataTypeUsed:function(A,e){var t=A;switch(A){case 2:case 4:t=A-e;break;case 3:case 5:t=A-2*e;break;case 6:t=0===e?A:1===e?2:1;break;case 7:t=0===e?A:A-2*e+1;break;default:t=A}return t},getOnePixel:function(A,e,t,i){var r=0;switch(t){case 0:r=i.getInt8(e);break;case 1:r=i.getUint8(e);break;case 2:r=i.getInt16(e,!0);break;case 3:r=i.getUint16(e,!0);break;case 4:r=i.getInt32(e,!0);break;case 5:r=i.getUInt32(e,!0);break;case 6:r=i.getFloat32(e,!0);break;case 7:r=i.getFloat64(e,!0);break;default:throw"the decoder does not understand this pixel type"}return r},swapDimensionOrder:function(A,e,t,i,r){var I=0,g=0,n=0,a=0,o=A;if(t>1)if(o=new i(e*t),r)for(I=0;I<e;I++)for(a=I,n=0;n<t;n++,a+=e)o[a]=A[g++];else for(I=0;I<e;I++)for(a=I,n=0;n<t;n++,a+=e)o[g++]=A[a];return o}},E=function(A,e,t){this.val=A,this.left=e,this.right=t},{decode:function(A,e){var t=(e=e||{}).noDataValue,i=0,r={};r.ptr=e.inputOffset||0,r.pixels={},Q.readHeaderInfo(A,r);var I=r.headerInfo,g=I.fileVersion,n=Q.getDataTypeArray(I.imageType);if(g>5)throw"unsupported lerc version 2."+g;Q.readMask(A,r),I.numValidPixel===I.width*I.height||r.pixels.resultMask||(r.pixels.resultMask=e.maskData);var a=I.width*I.height;r.pixels.resultPixels=new n(a*I.numDims),r.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var o,B=!e.returnPixelInterleavedDims;if(0!==I.numValidPixel)if(I.zMax===I.zMin)Q.constructConstantSurface(r,B);else if(g>=4&&Q.checkMinMaxRanges(A,r))Q.constructConstantSurface(r,B);else{var C=new DataView(A,r.ptr,2),E=C.getUint8(0);if(r.ptr++,E)Q.readDataOneSweep(A,r,n,B);else if(g>1&&I.imageType<=1&&Math.abs(I.maxZError-.5)<1e-5){var s=C.getUint8(1);if(r.ptr++,r.encodeMode=s,s>2||g<4&&s>1)throw"Invalid Huffman flag "+s;s?Q.readHuffman(A,r,n,B):Q.readTiles(A,r,n,B)}else Q.readTiles(A,r,n,B)}r.eofOffset=r.ptr,e.inputOffset?(o=r.headerInfo.blobSize+e.inputOffset-r.ptr,Math.abs(o)>=1&&(r.eofOffset=e.inputOffset+r.headerInfo.blobSize)):(o=r.headerInfo.blobSize-r.ptr,Math.abs(o)>=1&&(r.eofOffset=r.headerInfo.blobSize));var f={width:I.width,height:I.height,pixelData:r.pixels.resultPixels,minValue:I.zMin,maxValue:I.zMax,validPixelCount:I.numValidPixel,dimCount:I.numDims,dimStats:{minValues:I.minValues,maxValues:I.maxValues},maskData:r.pixels.resultMask};if(r.pixels.resultMask&&Q.isValidPixelValue(I.imageType,t)){var c=r.pixels.resultMask;for(i=0;i<a;i++)c[i]||(f.pixelData[i]=t);f.noDataValue=t}return r.noDataValue=t,e.returnFileInfo&&(f.fileInfo=Q.formatFileInfo(r)),f},getBandCount:function(A){for(var e=0,t=0,i={ptr:0,pixels:{}};t<A.byteLength-58;)Q.readHeaderInfo(A,i),t+=i.headerInfo.blobSize,e++,i.ptr=t;return e}}),l=(s=new ArrayBuffer(4),f=new Uint8Array(s),new Uint32Array(s)[0]=1,1===f[0]),u={decode:function(A,e){if(!l)throw"Big endian system is not supported.";var t,i,r=(e=e||{}).inputOffset||0,I=new Uint8Array(A,r,10),g=String.fromCharCode.apply(null,I);if("CntZImage"===g.trim())t=c,i=1;else{if("Lerc2"!==g.substring(0,5))throw"Unexpected file identifier string: "+g;t=h,i=2}for(var n,a,o,B,C,Q,E=0,s=A.byteLength-10,f=[],u={width:0,height:0,pixels:[],pixelType:e.pixelType,mask:null,statistics:[]},w=0;r<s;){var d=t.decode(A,{inputOffset:r,encodedMaskData:n,maskData:o,returnMask:0===E,returnEncodedMask:0===E,returnFileInfo:!0,returnPixelInterleavedDims:e.returnPixelInterleavedDims,pixelType:e.pixelType||null,noDataValue:e.noDataValue||null});r=d.fileInfo.eofOffset,o=d.maskData,0===E&&(n=d.encodedMaskData,u.width=d.width,u.height=d.height,u.dimCount=d.dimCount||1,u.pixelType=d.pixelType||d.fileInfo.pixelType,u.mask=o),i>1&&(o&&f.push(o),d.fileInfo.mask&&d.fileInfo.mask.numBytes>0&&w++),E++,u.pixels.push(d.pixelData),u.statistics.push({minValue:d.minValue,maxValue:d.maxValue,noDataValue:d.noDataValue,dimStats:d.dimStats})}if(i>1&&w>1){for(Q=u.width*u.height,u.bandMasks=f,(o=new Uint8Array(Q)).set(f[0]),B=1;B<f.length;B++)for(a=f[B],C=0;C<Q;C++)o[C]=o[C]&a[C];u.maskData=o}return u}};TA.exports?TA.exports=u:this.Lerc=u}();var ZA,jA,WA,zA=XA.exports,$A={env:{emscripten_notify_memory_growth:function(A){WA=new Uint8Array(jA.exports.memory.buffer)}}},Ae=function(){function A(){B(this,A)}return Q(A,[{key:"init",value:function(){return ZA||(ZA="undefined"!=typeof fetch?fetch("data:application/wasm;base64,"+ee).then((function(A){return A.arrayBuffer()})).then((function(A){return WebAssembly.instantiate(A,$A)})).then(this._init):WebAssembly.instantiate(Buffer.from(ee,"base64"),$A).then(this._init))}},{key:"_init",value:function(A){jA=A.instance,$A.env.emscripten_notify_memory_growth(0)}},{key:"decode",value:function(A){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!jA)throw new Error("ZSTDDecoder: Await .init() before decoding.");var t=A.byteLength,i=jA.exports.malloc(t);WA.set(A,i),e=e||Number(jA.exports.ZSTD_findDecompressedSize(i,t));var r=jA.exports.malloc(e),I=jA.exports.ZSTD_decompress(r,e,i,t),g=WA.slice(r,r+I);return jA.exports.free(i),jA.exports.free(r),g}}]),A}(),ee="[encoded data, 38976 characters]",te={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},ie={};for(var re in te)te.hasOwnProperty(re)&&(ie[te[re]]=parseInt(re,10));ie.BitsPerSample,ie.ExtraSamples,ie.SampleFormat,ie.StripByteCounts,ie.StripOffsets,ie.StripRowCounts,ie.TileByteCounts,ie.TileOffsets,ie.SubIFDs;var Ie={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},ge={};for(var ne in Ie)Ie.hasOwnProperty(ne)&&(ge[Ie[ne]]=parseInt(ne,10));var ae=1,oe=0,Be=1,Ce=2,Qe={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},Ee={};for(var se in Qe)Qe.hasOwnProperty(se)&&(Ee[Qe[se]]=parseInt(se,10));function fe(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var ce=new Ae,he=function(A){s(t,w);var e=fe(t);function t(A){var i;return B(this,t),(i=e.call(this)).planarConfiguration=void 0!==A.PlanarConfiguration?A.PlanarConfiguration:1,i.samplesPerPixel=void 0!==A.SamplesPerPixel?A.SamplesPerPixel:1,i.addCompression=A.LercParameters[ae],i}return Q(t,[{key:"decodeBlock",value:function(A){switch(this.addCompression){case oe:break;case Be:A=YA(new Uint8Array(A)).buffer;break;case Ce:A=ce.decode(new Uint8Array(A)).buffer;break;default:throw new Error("Unsupported LERC additional compression method identifier: ".concat(this.addCompression))}return zA.decode(A,{returnPixelInterleavedDims:1===this.planarConfiguration}).pixels[0].buffer}}]),t}(),le=Object.freeze({__proto__:null,zstd:ce,default:he});function ue(A){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(A){return!1}}();return function(){var t,i=c(A);if(e){var r=c(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return f(this,t)}}var we=function(A){s(I,w);var t,i=ue(I);function I(){var A;if(B(this,I),A=i.call(this),"undefined"==typeof createImageBitmap)throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if("undefined"==typeof document&&"undefined"==typeof OffscreenCanvas)throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");return A}return Q(I,[{key:"decode",value:(t=e(r.mark((function A(e,t){var i,I,g,n;return r.wrap((function(A){for(;;)switch(A.prev=A.next){case 0:return i=new Blob([t]),A.next=3,createImageBitmap(i);case 3:return I=A.sent,"undefined"!=typeof document?((g=document.createElement("canvas")).width=I.width,g.height=I.height):g=new OffscreenCanvas(I.width,I.height),(n=g.getContext("2d")).drawImage(I,0,0),A.abrupt("return",n.getImageData(0,0,I.width,I.height).data.buffer);case 8:case"end":return A.stop()}}),A)}))),function(A,e){return t.apply(this,arguments)})}]),I}(),de=Object.freeze({__proto__:null,default:we});';return new Pr(typeof Buffer<"u"?"data:application/javascript;base64,"+Buffer.from(o,"binary").toString("base64"):URL.createObjectURL(new Blob([o],{type:"application/javascript"})))}const jr=Object.freeze(Object.defineProperty({__proto__:null,create:Xr},Symbol.toStringTag,{value:"Module"}));export{An as G,Zr as W,gA as _,$r as c,Ce as g};
//# sourceMappingURL=geotiff-BaoeLn6q.js.map
