text: import{l as e,D as t,E as r,ag as i,K as o,L as n,m as a,t as s,s as l,h as f,X as u,al as c,bU as h,z as d,b as p,d as m}from"./p-ab028778.js";import{o as w}from"./p-098cc742.js";import{m as y}from"./p-49a8c628.js";var g;const C=e.getLogger("esri.layers.support.PixelBlock");let A=g=class extends n{constructor(e){super(e),this.width=null,this.height=null,this.pixelType="f32",this.validPixelCount=null,this.mask=null,this.maskIsAlpha=!1,this.pixels=null,this.statistics=null}static createEmptyBand(e,t){return new(g.getPixelArrayConstructor(e))(t)}static getPixelArrayConstructor(e){let t;switch(e){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;case"u32":t=Uint32Array;break;case"f32":t=Float32Array;break;case"f64":t=Float64Array;break;case"c64":case"c128":case"unknown":t=Float32Array}return t}castPixelType(e){if(!e)return"f32";let t=e.toLowerCase();return["u1","u2","u4"].indexOf(t)>-1?t="u8":-1===["unknown","u8","s8","u16","s16","u32","s32","f32","f64"].indexOf(t)&&(t="f32"),t}getPlaneCount(){return this.pixels&&this.pixels.length}addData(e){if(!e.pixels||e.pixels.length!==this.width*this.height)throw new a("pixelblock:invalid-or-missing-pixels","add data requires valid pixels array that has same length defined by pixel block width * height");this.pixels||(this.pixels=[]),this.statistics||(this.statistics=[]),this.pixels.push(e.pixels),this.statistics.push(e.statistics||{minValue:null,maxValue:null})}getAsRGBA(){const e=new ArrayBuffer(this.width*this.height*4);switch(this.pixelType){case"s8":case"s16":case"u16":case"s32":case"u32":case"f32":case"f64":this._fillFromNon8Bit(e);break;default:this._fillFrom8Bit(e)}return new Uint8ClampedArray(e)}getAsRGBAFloat(){const e=new Float32Array(this.width*this.height*4);return this._fillFrom32Bit(e),e}updateStatistics(){this.statistics=this.pixels.map((e=>this._calculateBandStatistics(e,this.mask)));const e=this.mask;let t=0;if(e)for(let r=0;r<e.length;r++)e[r]&&t++;else t=this.width*this.height;this.validPixelCount=t}clamp(e){if(!e||"f64"===e||"f32"===e)return;let t;switch(e){case"u8":t=[0,255];break;case"u16":t=[0,65535];break;case"u32":t=[0,4294967295];break;case"s8":t=[-128,127];break;case"s16":t=[-32768,32767];break;case"s32":t=[-2147483648,2147483647];break;default:t=[-34e38,34e38]}const[r,i]=t,o=this.pixels,n=this.width*this.height,a=o.length;let s,l,f;const u=[];for(let t=0;t<a;t++){f=g.createEmptyBand(e,n),s=o[t];for(let e=0;e<n;e++)l=s[e],f[e]=l>i?i:l<r?r:l;u.push(f)}this.pixels=u,this.pixelType=e}extractBands(e){if(s(e)||0===e.length||null==this.pixels||0===this.pixels.length)return this;const t=this.pixels.length,r=e.some((e=>e>=this.pixels.length)),i=t===e.length&&!e.some(((e,t)=>e!==t));return r||i?this:new g({pixelType:this.pixelType,width:this.width,height:this.height,mask:this.mask,validPixelCount:this.validPixelCount,maskIsAlpha:this.maskIsAlpha,pixels:e.map((e=>this.pixels[e])),statistics:this.statistics&&e.map((e=>this.statistics[e]))})}clone(){const e=new g({width:this.width,height:this.height,pixelType:this.pixelType,maskIsAlpha:this.maskIsAlpha,validPixelCount:this.validPixelCount});let t;this.mask&&(e.mask=this.mask instanceof Uint8Array?new Uint8Array(this.mask):this.mask.slice(0));const r=g.getPixelArrayConstructor(this.pixelType);if(this.pixels&&this.pixels.length>0){e.pixels=[];const i=this.pixels[0].slice;for(t=0;t<this.pixels.length;t++)e.pixels[t]=i?this.pixels[t].slice(0,this.pixels[t].length):new r(this.pixels[t])}if(this.statistics)for(e.statistics=[],t=0;t<this.statistics.length;t++)e.statistics[t]=l(this.statistics[t]);return e}_fillFrom8Bit(e){const{mask:t,maskIsAlpha:r,pixels:i}=this;if(!e||!i||!i.length)return void C.error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let o,n,a,s;o=n=a=i[0],i.length>=3?(n=i[1],a=i[2]):2===i.length&&(n=i[1]);const l=new Uint32Array(e),f=this.width*this.height;if(o.length===f)if(t&&t.length===f)if(r)for(s=0;s<f;s++)t[s]&&(l[s]=t[s]<<24|a[s]<<16|n[s]<<8|o[s]);else for(s=0;s<f;s++)t[s]&&(l[s]=255<<24|a[s]<<16|n[s]<<8|o[s]);else for(s=0;s<f;s++)l[s]=255<<24|a[s]<<16|n[s]<<8|o[s];else C.error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(e){const{pixels:t,mask:r,statistics:i}=this;if(!e||!t||!t.length)return void C.error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const o=this.pixelType;let n=1,a=0,s=1;if(i&&i.length>0)a=i.map((e=>e.minValue)).reduce(((e,t)=>Math.min(e,t))),s=i.map((e=>e.maxValue-e.minValue)).reduce(((e,t)=>Math.max(e,t))),n=255/s;else{let e=255;"s8"===o?(a=-128,e=127):"u16"===o?e=65535:"s16"===o?(a=-32768,e=32767):"u32"===o?e=4294967295:"s32"===o?(a=-2147483648,e=2147483647):"f32"===o?(a=-34e38,e=34e38):"f64"===o&&(a=-Number.MAX_VALUE,e=Number.MAX_VALUE),n=255/(e-a)}const l=new Uint32Array(e),f=this.width*this.height;let u,c,h,d,p;if(u=c=h=t[0],u.length!==f)return C.error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(t.length>=2)if(c=t[1],t.length>=3&&(h=t[2]),r&&r.length===f)for(d=0;d<f;d++)r[d]&&(l[d]=255<<24|(h[d]-a)*n<<16|(c[d]-a)*n<<8|(u[d]-a)*n);else for(d=0;d<f;d++)l[d]=255<<24|(h[d]-a)*n<<16|(c[d]-a)*n<<8|(u[d]-a)*n;else if(r&&r.length===f)for(d=0;d<f;d++)p=(u[d]-a)*n,r[d]&&(l[d]=255<<24|p<<16|p<<8|p);else for(d=0;d<f;d++)p=(u[d]-a)*n,l[d]=255<<24|p<<16|p<<8|p}_fillFrom32Bit(e){const{pixels:t,mask:r}=this;if(!e||!t||!t.length)return C.error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,o,n,a;i=o=n=t[0],t.length>=3?(o=t[1],n=t[2]):2===t.length&&(o=t[1]);const s=this.width*this.height;if(i.length!==s)return C.error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let l=0;if(r&&r.length===s)for(a=0;a<s;a++)e[l++]=i[a],e[l++]=o[a],e[l++]=n[a],e[l++]=1&r[a];else for(a=0;a<s;a++)e[l++]=i[a],e[l++]=o[a],e[l++]=n[a],e[l++]=1}_calculateBandStatistics(e,t){let r=1/0,i=-1/0;const o=e.length;let n,a=0;if(t)for(n=0;n<o;n++)t[n]&&(a=e[n],r=a<r?a:r,i=a>i?a:i);else for(n=0;n<o;n++)a=e[n],r=a<r?a:r,i=a>i?a:i;return{minValue:r,maxValue:i}}};t([r({json:{write:!0}})],A.prototype,"width",void 0),t([r({json:{write:!0}})],A.prototype,"height",void 0),t([r({json:{write:!0}})],A.prototype,"pixelType",void 0),t([i("pixelType")],A.prototype,"castPixelType",null),t([r({json:{write:!0}})],A.prototype,"validPixelCount",void 0),t([r({json:{write:!0}})],A.prototype,"mask",void 0),t([r({json:{write:!0}})],A.prototype,"maskIsAlpha",void 0),t([r({json:{write:!0}})],A.prototype,"pixels",void 0),t([r({json:{write:!0}})],A.prototype,"statistics",void 0),A=g=t([o("esri.layers.support.PixelBlock")],A);var v=A,T=w((function(e){var t,r;t=function(){function e(){this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=null}return e.prototype={ensureBuffer:function(e){var t=this.buffer,r=t?t.byteLength:0;if(e<r)return t;for(var i=512;i<e;)i<<=1;for(var o=new Uint8Array(i),n=0;n<r;++n)o[n]=t[n];return this.buffer=o},getByte:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(e){var t=this.pos;if(e){this.ensureBuffer(t+e);for(var r=t+e;!this.eof&&this.bufferLength<r;)this.readBlock();var i=this.bufferLength;r>i&&(r=i)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}return this.pos=r,this.buffer.subarray(t,r)},lookChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var e=this.pos;this.bufferLength<=e;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(e,t,r){for(var i=e+t;this.bufferLength<=i&&!this.eof;)this.readBlock();return new Stream(this.buffer,e,t,r)},skip:function(e){e||(e=1),this.pos+=e},reset:function(){this.pos=0}},e}(),void 0!==(r=function(){if(!self||!self.Uint32Array)return null;var e=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),r=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),i=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),o=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],n=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];function a(e){throw new Error(e)}function s(e){var r=0,i=e[r++],o=e[r++];-1!=i&&-1!=o||a("Invalid header in flate stream"),8!=(15&i)&&a("Unknown compression method in flate stream"),((i<<8)+o)%31!=0&&a("Bad FCHECK in flate stream"),32&o&&a("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=2,this.codeSize=0,this.codeBuf=0,t.call(this)}return(s.prototype=Object.create(t.prototype)).getBits=function(e){for(var t,r=this.codeSize,i=this.codeBuf,o=this.bytes,n=this.bytesPos;r<e;)void 0===(t=o[n++])&&a("Bad encoding in flate stream"),i|=t<<r,r+=8;return t=i&(1<<e)-1,this.codeBuf=i>>e,this.codeSize=r-=e,this.bytesPos=n,t},s.prototype.getCode=function(e){for(var t=e[0],r=e[1],i=this.codeSize,o=this.codeBuf,n=this.bytes,s=this.bytesPos;i<r;){var l;void 0===(l=n[s++])&&a("Bad encoding in flate stream"),o|=l<<i,i+=8}var f=t[o&(1<<r)-1],u=f>>16,c=65535&f;return(0==i||i<u||0==u)&&a("Bad encoding in flate stream"),this.codeBuf=o>>u,this.codeSize=i-u,this.bytesPos=s,c},s.prototype.generateHuffmanTable=function(e){for(var t=e.length,r=0,i=0;i<t;++i)e[i]>r&&(r=e[i]);for(var o=1<<r,n=new Uint32Array(o),a=1,s=0,l=2;a<=r;++a,s<<=1,l<<=1)for(var f=0;f<t;++f)if(e[f]==a){var u=0,c=s;for(i=0;i<a;++i)u=u<<1|1&c,c>>=1;for(i=u;i<o;i+=l)n[i]=a<<16|f;++s}return[n,r]},s.prototype.readBlock=function(){function t(e,t,r,i,o){for(var n=e.getBits(r)+i;n-- >0;)t[p++]=o}var s=this.getBits(3);if(1&s&&(this.eof=!0),0!=(s>>=1)){var l,f;if(1==s)l=o,f=n;else if(2==s){for(var u=this.getBits(5)+257,c=this.getBits(5)+1,h=this.getBits(4)+4,d=Array(e.length),p=0;p<h;)d[e[p++]]=this.getBits(3);for(var m=this.generateHuffmanTable(d),w=0,y=(p=0,u+c),g=new Array(y);p<y;){var C=this.getCode(m);16==C?t(this,g,2,3,w):17==C?t(this,g,3,3,w=0):18==C?t(this,g,7,11,w=0):g[p++]=w=C}l=this.generateHuffmanTable(g.slice(0,u)),f=this.generateHuffmanTable(g.slice(u,y))}else a("Unknown block type in flate stream");for(var A=(R=this.buffer)?R.length:0,v=this.bufferLength;;){var T=this.getCode(l);if(T<256)v+1>=A&&(A=(R=this.ensureBuffer(v+1)).length),R[v++]=T;else{if(256==T)return void(this.bufferLength=v);var k=(T=r[T-=257])>>16;k>0&&(k=this.getBits(k)),w=(65535&T)+k,T=this.getCode(f),(k=(T=i[T])>>16)>0&&(k=this.getBits(k));var S=(65535&T)+k;v+w>=A&&(A=(R=this.ensureBuffer(v+w)).length);for(var b=0;b<w;++b,++v)R[v]=R[v-S]}}}else{var M,E=this.bytes,G=this.bytesPos;void 0===(M=E[G++])&&a("Bad block header in flate stream");var D=M;void 0===(M=E[G++])&&a("Bad block header in flate stream"),D|=M<<8,void 0===(M=E[G++])&&a("Bad block header in flate stream");var x=M;void 0===(M=E[G++])&&a("Bad block header in flate stream"),(x|=M<<8)!=(65535&~D)&&a("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var I=this.bufferLength,R=this.ensureBuffer(I+D),P=I+D;this.bufferLength=P;for(var U=I;U<P;++U){if(void 0===(M=E[G++])){this.eof=!0;break}R[U]=M}this.bytesPos=G}},s}())&&(e.exports=r)}));class k{constructor(e){e&&(this.canvas=e.canvas,this.ctx=e.ctx||e.canvas&&e.canvas.getContext("2d"))}decode(e,t,r){if(!e||e.byteLength<10)throw new a("imagecanvasdecoder: decode","required a valid encoded data as input.");let{width:i,height:o,format:n}=t;const{applyJpegMask:s}=t;if(s&&(!i||!o))throw new a("imagecanvasdecoder: decode","image width and height are needed to apply jpeg mask directly to canvas");return f(((a,l)=>{let f=null;"jpg"===n&&s&&(f=k.getMask(e,t));const h=new Blob([new Uint8Array(e)],{type:"image/"+n=="jpg"?"jpeg":n}),d=URL.createObjectURL(h),p=new Image;let m;p.src=d,p.onload=()=>{if(URL.revokeObjectURL(d),u(r))return void l(c());i=p.width,o=p.height,this.canvas?(this.canvas.width===i&&this.canvas.height===o||(this.canvas.width=i,this.canvas.height=o),this.ctx.clearRect(0,0,i,o)):(this.canvas=document.createElement("canvas"),this.canvas.width=i,this.canvas.height=o,this.ctx=this.canvas.getContext("2d")),this.ctx.drawImage(p,0,0);const e=this.ctx.getImageData(0,0,i,o);let n;if(m=e.data,t.renderOnCanvas){if(f)for(n=0;n<f.length;n++)m[4*n+3]=f[n]?255:0;return this.ctx.putImageData(e,0,0),void a(null)}const s=i*o,h=new Uint8Array(s),w=new Uint8Array(s),y=new Uint8Array(s);if(f)for(n=0;n<s;n++)h[n]=m[4*n],w[n]=m[4*n+1],y[n]=m[4*n+2];else for(f=new Uint8Array(s),n=0;n<s;n++)h[n]=m[4*n],w[n]=m[4*n+1],y[n]=m[4*n+2],f[n]=m[4*n+3];a({width:i,height:o,pixels:[h,w,y],mask:f,pixelType:"u8"})},p.onerror=()=>{URL.revokeObjectURL(d),l("cannot load image")}}))}static getMask(e,t){let r=null;try{const i=new Uint8Array(e),o=Math.ceil(i.length/2);let n=0;const a=i.length-2;for(n=o;n<a&&(255!==i[n]||217!==i[n+1]);n++);if(n+=2,n<i.length-1){const e=new T(i.subarray(n)).getBytes();r=new Uint8Array(t.width*t.height);let o=0;for(let t=0;t<e.length;t++)for(let i=7;i>=0;i--)r[o++]=e[t]>>i&1}}catch(e){}return r}}var S=w((function(e){var t,r;t=function(){function e(e){this.message="JPEG error: "+e}return(e.prototype=new Error).name="JpegError",e.constructor=e,e}(),void 0!==(r=function(){if(!self||!self.Uint8ClampedArray)return null;var e=new Uint8Array([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]),r=4017,i=799,o=3406,n=2276,a=1567,s=3784,l=5793,f=2896;function u(){this.decodeTransform=null,this.colorTransform=-1}function c(e,t){for(var r,i,o=0,n=[],a=16;a>0&&!e[a-1];)a--;n.push({children:[],index:0});var s,l=n[0];for(r=0;r<a;r++){for(i=0;i<e[r];i++){for((l=n.pop()).children[l.index]=t[o];l.index>0;)l=n.pop();for(l.index++,n.push(l);n.length<=r;)n.push(s={children:[],index:0}),l.children[l.index]=s.children,l=s;o++}r+1<a&&(n.push(s={children:[],index:0}),l.children[l.index]=s.children,l=s)}return n[0].children}function h(e,t,r){return 64*((e.blocksPerLine+1)*t+r)}function d(r,i,o,n,a,s,l,f,u){var c=o.mcusPerLine,d=i,p=0,m=0;function y(){if(m>0)return m--,p>>m&1;if(255===(p=r[i++])){var e=r[i++];if(e)throw new t("unexpected marker "+(p<<8|e).toString(16))}return m=7,p>>>7}function g(e){for(var r=e;;){if("number"==typeof(r=r[y()]))return r;if("object"!=typeof r)throw new t("invalid huffman sequence")}}function C(e){for(var t=0;e>0;)t=t<<1|y(),e--;return t}function A(e){if(1===e)return 1===y()?1:-1;var t=C(e);return t>=1<<e-1?t:t+(-1<<e)+1}var v,T=0,k=0;function S(e,t,r,i,o){t(e,h(e,(r/c|0)*e.v+i,r%c*e.h+o))}function b(e,t,r){t(e,h(e,r/e.blocksPerLine|0,r%e.blocksPerLine))}var M,E,G,D,x,I,R=n.length;I=o.progressive?0===s?0===f?function(e,t){var r=g(e.huffmanTableDC),i=0===r?0:A(r)<<u;e.blockData[t]=e.pred+=i}:function(e,t){e.blockData[t]|=y()<<u}:0===f?function(t,r){if(T>0)T--;else for(var i=s,o=l;i<=o;){var n=g(t.huffmanTableAC),a=15&n,f=n>>4;if(0!==a){var c=e[i+=f];t.blockData[r+c]=A(a)*(1<<u),i++}else{if(f<15){T=C(f)+(1<<f)-1;break}i+=16}}}:function(r,i){for(var o,n,a=s,f=l,c=0;a<=f;){var h=e[a];switch(k){case 0:if(c=(n=g(r.huffmanTableAC))>>4,0==(o=15&n))c<15?(T=C(c)+(1<<c),k=4):(c=16,k=1);else{if(1!==o)throw new t("invalid ACn encoding");v=A(o),k=c?2:3}continue;case 1:case 2:r.blockData[i+h]?r.blockData[i+h]+=y()<<u:0==--c&&(k=2===k?3:0);break;case 3:r.blockData[i+h]?r.blockData[i+h]+=y()<<u:(r.blockData[i+h]=v<<u,k=0);break;case 4:r.blockData[i+h]&&(r.blockData[i+h]+=y()<<u)}a++}4===k&&0==--T&&(k=0)}:function(t,r){var i=g(t.huffmanTableDC),o=0===i?0:A(i);t.blockData[r]=t.pred+=o;for(var n=1;n<64;){var a=g(t.huffmanTableAC),s=15&a,l=a>>4;if(0!==s){var f=e[n+=l];t.blockData[r+f]=A(s),n++}else{if(l<15)break;n+=16}}};var P,U,B,O,L=0;for(U=1===R?n[0].blocksPerLine*n[0].blocksPerColumn:c*o.mcusPerColumn;L<U;){var _=a?Math.min(U-L,a):U;for(E=0;E<R;E++)n[E].pred=0;if(T=0,1===R)for(M=n[0],x=0;x<_;x++)b(M,I,L),L++;else for(x=0;x<_;x++){for(E=0;E<R;E++)for(B=(M=n[E]).h,O=M.v,G=0;G<O;G++)for(D=0;D<B;D++)S(M,I,L,G,D);L++}m=0,(P=w(r,i))&&P.invalid&&(console.log("decodeScan - unexpected MCU data, next marker is: "+P.invalid),i=P.offset);var N=P&&P.marker;if(!N||N<=65280)throw new t("marker was not found");if(!(N>=65488&&N<=65495))break;i+=2}return(P=w(r,i))&&P.invalid&&(console.log("decodeScan - unexpected Scan data, next marker is: "+P.invalid),i=P.offset),i-d}function p(e,u,c){var h,d,p,m,w,y,g,C,A,v,T,k,S,b,M,E,G,D=e.quantizationTable,x=e.blockData;if(!D)throw new t("missing required Quantization Table.");for(var I=0;I<64;I+=8)A=x[u+I],A*=D[I],0!=((v=x[u+I+1])|(T=x[u+I+2])|(k=x[u+I+3])|(S=x[u+I+4])|(b=x[u+I+5])|(M=x[u+I+6])|(E=x[u+I+7]))?(d=(h=(h=l*A+128>>8)+(d=l*(S*=D[I+4])+128>>8)+1>>1)-d,G=(p=T*=D[I+2])*s+(m=M*=D[I+6])*a+128>>8,p=p*a-m*s+128>>8,g=(w=(w=f*((v*=D[I+1])-(E*=D[I+7]))+128>>8)+(g=(b*=D[I+5])<<4)+1>>1)-g,y=(C=(C=f*(v+E)+128>>8)+(y=(k*=D[I+3])<<4)+1>>1)-y,m=(h=h+(m=G)+1>>1)-m,p=(d=d+p+1>>1)-p,G=w*n+C*o+2048>>12,w=w*o-C*n+2048>>12,C=G,G=y*i+g*r+2048>>12,y=y*r-g*i+2048>>12,g=G,c[I]=h+C,c[I+7]=h-C,c[I+1]=d+g,c[I+6]=d-g,c[I+2]=p+y,c[I+5]=p-y,c[I+3]=m+w,c[I+4]=m-w):(c[I]=G=l*A+512>>10,c[I+1]=G,c[I+2]=G,c[I+3]=G,c[I+4]=G,c[I+5]=G,c[I+6]=G,c[I+7]=G);for(var R=0;R<8;++R)A=c[R],0!=((v=c[R+8])|(T=c[R+16])|(k=c[R+24])|(S=c[R+32])|(b=c[R+40])|(M=c[R+48])|(E=c[R+56]))?(d=(h=4112+((h=l*A+2048>>12)+(d=l*S+2048>>12)+1>>1))-d,G=(p=T)*s+(m=M)*a+2048>>12,p=p*a-m*s+2048>>12,m=G,g=(w=(w=f*(v-E)+2048>>12)+(g=b)+1>>1)-g,y=(C=(C=f*(v+E)+2048>>12)+(y=k)+1>>1)-y,G=w*n+C*o+2048>>12,w=w*o-C*n+2048>>12,C=G,G=y*i+g*r+2048>>12,y=y*r-g*i+2048>>12,A=(A=(h=h+m+1>>1)+C)<16?0:A>=4080?255:A>>4,v=(v=(d=d+p+1>>1)+(g=G))<16?0:v>=4080?255:v>>4,T=(T=(p=d-p)+y)<16?0:T>=4080?255:T>>4,k=(k=(m=h-m)+w)<16?0:k>=4080?255:k>>4,S=(S=m-w)<16?0:S>=4080?255:S>>4,b=(b=p-y)<16?0:b>=4080?255:b>>4,M=(M=d-g)<16?0:M>=4080?255:M>>4,E=(E=h-C)<16?0:E>=4080?255:E>>4,x[u+R]=A,x[u+R+8]=v,x[u+R+16]=T,x[u+R+24]=k,x[u+R+32]=S,x[u+R+40]=b,x[u+R+48]=M,x[u+R+56]=E):(G=(G=l*A+8192>>14)<-2040?0:G>=2024?255:G+2056>>4,x[u+R]=G,x[u+R+8]=G,x[u+R+16]=G,x[u+R+24]=G,x[u+R+32]=G,x[u+R+40]=G,x[u+R+48]=G,x[u+R+56]=G)}function m(e,t){for(var r=t.blocksPerLine,i=t.blocksPerColumn,o=new Int16Array(64),n=0;n<i;n++)for(var a=0;a<r;a++)p(t,h(t,n,a),o);return t.blockData}function w(e,t,r){function i(t){return e[t]<<8|e[t+1]}var o=e.length-1,n=r<t?r:t;if(t>=o)return null;var a=i(t);if(a>=65472&&a<=65534)return{invalid:null,marker:a,offset:t};for(var s=i(n);!(s>=65472&&s<=65534);){if(++n>=o)return null;s=i(n)}return{invalid:a.toString(16),marker:s,offset:n}}return u.prototype={parse:function(r){function i(){var e=r[l]<<8|r[l+1];return l+=2,e}function o(){var e=i(),t=l+e-2,o=w(r,t,l);o&&o.invalid&&(console.log("readDataBlock - incorrect length, next marker is: "+o.invalid),t=o.offset);var n=r.subarray(l,t);return l+=n.length,n}function n(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),i=0;i<e.components.length;i++){L=e.components[i];var o=Math.ceil(Math.ceil(e.samplesPerLine/8)*L.h/e.maxH),n=Math.ceil(Math.ceil(e.scanLines/8)*L.v/e.maxV);L.blockData=new Int16Array(r*L.v*64*(t*L.h+1)),L.blocksPerLine=o,L.blocksPerColumn=n}e.mcusPerLine=t,e.mcusPerColumn=r}var a,s,l=0,f=null,u=null,h=[],p=[],y=[],g=i();if(65496!==g)throw new t("SOI not found");for(g=i();65497!==g;){var C,A,v;switch(g){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 T=o();65504===g&&74===T[0]&&70===T[1]&&73===T[2]&&70===T[3]&&0===T[4]&&(f={version:{major:T[5],minor:T[6]},densityUnits:T[7],xDensity:T[8]<<8|T[9],yDensity:T[10]<<8|T[11],thumbWidth:T[12],thumbHeight:T[13],thumbData:T.subarray(14,14+3*T[12]*T[13])}),65518===g&&65===T[0]&&100===T[1]&&111===T[2]&&98===T[3]&&101===T[4]&&(u={version:T[5]<<8|T[6],flags0:T[7]<<8|T[8],flags1:T[9]<<8|T[10],transformCode:T[11]});break;case 65499:for(var k=i()+l-2;l<k;){var S=r[l++],b=new Uint16Array(64);if(S>>4==0)for(A=0;A<64;A++)b[e[A]]=r[l++];else{if(S>>4!=1)throw new t("DQT - invalid table spec");for(A=0;A<64;A++)b[e[A]]=i()}h[15&S]=b}break;case 65472:case 65473:case 65474:if(a)throw new t("Only single frame JPEGs supported");i(),(a={}).extended=65473===g,a.progressive=65474===g,a.precision=r[l++],a.scanLines=i(),a.samplesPerLine=i(),a.components=[],a.componentIds={};var M,E=r[l++],G=0,D=0;for(C=0;C<E;C++){M=r[l];var x=r[l+1]>>4,I=15&r[l+1];G<x&&(G=x),D<I&&(D=I),v=a.components.push({h:x,v:I,quantizationId:r[l+2],quantizationTable:null}),a.componentIds[M]=v-1,l+=3}a.maxH=G,a.maxV=D,n(a);break;case 65476:var R=i();for(C=2;C<R;){var P=r[l++],U=new Uint8Array(16),B=0;for(A=0;A<16;A++,l++)B+=U[A]=r[l];var O=new Uint8Array(B);for(A=0;A<B;A++,l++)O[A]=r[l];C+=17+B,(P>>4==0?y:p)[15&P]=c(U,O)}break;case 65501:i(),s=i();break;case 65498:i();var L,_=r[l++],N=[];for(C=0;C<_;C++){var F=a.componentIds[r[l++]],V=r[l++];(L=a.components[F]).huffmanTableDC=y[V>>4],L.huffmanTableAC=p[15&V],N.push(L)}var j=r[l++],K=r[l++],H=r[l++],Y=d(r,l,a,N,s,j,K,H>>4,15&H);l+=Y;break;case 65535:255!==r[l]&&l--;break;default:if(255===r[l-3]&&r[l-2]>=192&&r[l-2]<=254){l-=3;break}throw new t("unknown marker "+g.toString(16))}g=i()}for(this.width=a.samplesPerLine,this.height=a.scanLines,this.jfif=f,this.eof=l,this.adobe=u,this.components=[],C=0;C<a.components.length;C++){var z=h[(L=a.components[C]).quantizationId];z&&(L.quantizationTable=z),this.components.push({output:m(0,L),scaleX:L.h/a.maxH,scaleY:L.v/a.maxV,blocksPerLine:L.blocksPerLine,blocksPerColumn:L.blocksPerColumn})}this.numComponents=this.components.length},_getLinearizedBlockData:function(e,t){var r,i,o,n,a,s,l,f,u,c,h,d=this.width/e,p=this.height/t,m=0,w=this.components.length,y=e*t*w,g=new Uint8ClampedArray(y),C=new Uint32Array(e),A=4294967288;for(l=0;l<w;l++){for(i=(r=this.components[l]).scaleX*d,o=r.scaleY*p,m=l,h=r.output,n=r.blocksPerLine+1<<3,a=0;a<e;a++)C[a]=((f=0|a*i)&A)<<3|7&f;for(s=0;s<t;s++)for(c=n*((f=0|s*o)&A)|(7&f)<<3,a=0;a<e;a++)g[m]=h[c+C[a]],m+=w}var v=this.decodeTransform;if(v)for(l=0;l<y;)for(f=0,u=0;f<w;f++,l++,u+=2)g[l]=(g[l]*v[u]>>8)+v[u+1];return g},_isColorConversionNeeded:function(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this.colorTransform:1===this.colorTransform},_convertYccToRgb:function(e){for(var t,r,i,o=0,n=e.length;o<n;o+=3)r=e[o+1],e[o]=(t=e[o])-179.456+1.402*(i=e[o+2]),e[o+1]=t+135.459-.344*r-.714*i,e[o+2]=t-226.816+1.772*r;return e},_convertYcckToRgb:function(e){for(var t,r,i,o,n=0,a=0,s=e.length;a<s;a+=4)e[n++]=(r=e[a+1])*(-660635669420364e-19*r+.000437130475926232*(i=e[a+2])-54080610064599e-18*(t=e[a])+.00048449797120281*(o=e[a+3])-.154362151871126)-122.67195406894+i*(-.000957964378445773*i+.000817076911346625*t-.00477271405408747*o+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*o+.48357088451265)+o*(-.000336197177618394*o+.484791561490776),e[n++]=107.268039397724+r*(219927104525741e-19*r-.000640992018297945*i+.000659397001245577*t+.000426105652938837*o-.176491792462875)+i*(-.000778269941513683*i+.00130872261408275*t+.000770482631801132*o-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*o+.25802910206845)+o*(-.000318913117588328*o-.213742400323665),e[n++]=r*(-.000570115196973677*r-263409051004589e-19*i+.0020741088115012*t-.00288260236853442*o+.814272968359295)-20.810012546947+i*(-153496057440975e-19*i-.000132689043961446*t+.000560833691242812*o-.195152027534049)+t*(.00174418132927582*t-.00255243321439347*o+.116935020465145)+o*(-.000343531996510555*o+.24165260232407);return e},_convertYcckToCmyk:function(e){for(var t,r,i,o=0,n=e.length;o<n;o+=4)r=e[o+1],e[o]=434.456-(t=e[o])-1.402*(i=e[o+2]),e[o+1]=119.541-t+.344*r+.714*i,e[o+2]=481.816-t-1.772*r;return e},_convertCmykToRgb:function(e){for(var t,r,i,o,n=0,a=1/255,s=0,l=e.length;s<l;s+=4)e[n++]=255+(t=e[s]*a)*(-4.387332384609988*t+54.48615194189176*(r=e[s+1]*a)+18.82290502165302*(i=e[s+2]*a)+212.25662451639585*(o=e[s+3]*a)-285.2331026137004)+r*(1.7149763477362134*r-5.6096736904047315*i-17.873870861415444*o-5.497006427196366)+i*(-2.5217340131683033*i-21.248923337353073*o+17.5119270841813)-o*(21.86122147463605*o+189.48180835922747),e[n++]=255+t*(8.841041422036149*t+60.118027045597366*r+6.871425592049007*i+31.159100130055922*o-79.2970844816548)+r*(-15.310361306967817*r+17.575251261109482*i+131.35250912493976*o-190.9453302588951)+i*(4.444339102852739*i+9.8632861493405*o-24.86741582555878)-o*(20.737325471181034*o+187.80453709719578),e[n++]=255+t*(.8842522430003296*t+8.078677503112928*r+30.89978309703729*i-.23883238689178934*o-14.183576799673286)+r*(10.49593273432072*r+63.02378494754052*i+50.606957656360734*o-112.23884253719248)+i*(.03296041114873217*i+115.60384449646641*o-193.58209356861505)-o*(22.33816807309886*o+180.12613974708367);return e},getData:function(e,r,i){if(this.numComponents>4)throw new t("Unsupported color mode");var o=this._getLinearizedBlockData(e,r);if(1===this.numComponents&&i){for(var n=o.length,a=new Uint8ClampedArray(3*n),s=0,l=0;l<n;l++){var f=o[l];a[s++]=f,a[s++]=f,a[s++]=f}return a}if(3===this.numComponents&&this._isColorConversionNeeded())return this._convertYccToRgb(o);if(4===this.numComponents){if(this._isColorConversionNeeded())return i?this._convertYcckToRgb(o):this._convertYcckToCmyk(o);if(i)return this._convertCmykToRgb(o)}return o}},u}())&&(e.exports=r)}));class b{static decode(e){const t=new Uint8Array(e),r=new S;r.parse(t);const{width:i,height:o,numComponents:n,eof:a}=r,s=r.getData(i,o,!0);let l;const f=i*o;let u=0,c=0,h=0;if(a<t.length-1){const e=new T(t.subarray(a)).getBytes();l=new Uint8Array(f);let r=0;for(u=0;u<e.length;u++)for(h=7;h>=0;h--)l[r++]=e[u]>>h&1}let d,p=null;if(1===n)p=[s,s,s];else{for(p=[],u=0;u<3;u++)d=new Uint8Array(f),p.push(d);for(h=0,c=0;c<f;c++)for(u=0;u<3;u++)p[u][c]=s[h++]}return{width:i,height:o,pixels:p,mask:l}}}const M=function(e,t){return Math.floor(e.byteLength/(t.width*t.height*E(t.pixelType)))},E=function(e){let t=1;switch(e){case Uint8Array:case Int8Array:t=1;break;case Uint16Array:case Int16Array:t=2;break;case Uint32Array:case Int32Array:case Float32Array:t=4;break;case Float64Array:t=8}return t},G=(()=>{const e=new ArrayBuffer(4),t=new Uint8Array(e);return new Uint32Array(e)[0]=1,1===t[0]})();function D(e,t){let r=0,i="",o=0,n=0;const a=e.length;for(;r<a;)n=e[r++],o=n>>4,o<8?o=1:15===o?(o=4,n=(7&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++]):14===o?(o=3,n=(15&n)<<12|(63&e[r++])<<6|63&e[r++]):(o=2,n=(31&n)<<6|63&e[r++]),(0!==n||t)&&(i+=String.fromCharCode(n));return i}function x(){const e=[];for(let t=0;t<=257;t++)e[t]=[t];return e}function I(e,t){for(let r=0;r<t.length;r++)e.push(t[r])}const R=new Set;R.add(511),R.add(1023),R.add(2047),R.add(4095),R.add(8191);const P=(()=>{const e=[];return e[254]="NEWSUBFILETYPE",e[255]="SUBFILETYPE",e[256]="IMAGEWIDTH",e[257]="IMAGELENGTH",e[258]="BITSPERSAMPLE",e[259]="COMPRESSION",e[262]="PHOTOMETRICINTERPRETATION",e[263]="THRESHHOLDING",e[264]="CELLWIDTH",e[265]="CELLLENGTH",e[266]="FILLORDER",e[269]="DOCUMENTNAME",e[270]="IMAGEDESCRIPTION",e[271]="MAKE",e[272]="MODEL",e[273]="STRIPOFFSETS",e[274]="ORIENTATION",e[277]="SAMPLESPERPIXEL",e[278]="ROWSPERSTRIP",e[279]="STRIPBYTECOUNTS",e[280]="MINSAMPLEVALUE",e[281]="MAXSAMPLEVALUE",e[282]="XRESOLUTION",e[283]="YRESOLUTION",e[284]="PLANARCONFIGURATION",e[285]="PAGENAME",e[286]="XPOSITION",e[287]="YPOSITION",e[288]="FREEOFFSETS",e[289]="FREEBYTECOUNTS",e[290]="GRAYRESPONSEUNIT",e[291]="GRAYRESPONSECURVE",e[292]="T4OPTIONS",e[293]="T6OPTIONS",e[296]="RESOLUTIONUNIT",e[297]="PAGENUMBER",e[300]="COLORRESPONSEUNIT",e[301]="TRANSFERFUNCTION",e[305]="SOFTWARE",e[306]="DATETIME",e[315]="ARTIST",e[316]="HOSTCOMPUTER",e[317]="PREDICTOR",e[318]="WHITEPOINT",e[319]="PRIMARYCHROMATICITIES",e[320]="COLORMAP",e[321]="HALFTONEHINTS",e[322]="TILEWIDTH",e[323]="TILELENGTH",e[324]="TILEOFFSETS",e[325]="TILEBYTECOUNTS",e[326]="BADFAXLINES",e[327]="CLEANFAXDATA",e[328]="CONSECUTIVEBADFAXLINES",e[330]="SUBIFD",e[332]="INKSET",e[333]="INKNAMES",e[334]="NUMBEROFINKS",e[336]="DOTRANGE",e[337]="TARGETPRINTER",e[338]="EXTRASAMPLES",e[339]="SAMPLEFORMAT",e[340]="SMINSAMPLEVALUE",e[341]="SMAXSAMPLEVALUE",e[342]="TRANSFERRANGE",e[347]="JPEGTABLES",e[512]="JPEGPROC",e[513]="JPEGIFOFFSET",e[514]="JPEGIFBYTECOUNT",e[515]="JPEGRESTARTINTERVAL",e[517]="JPEGLOSSLESSPREDICTORS",e[518]="JPEGPOINTTRANSFORM",e[519]="JPEGQTABLES",e[520]="JPEGDCTABLES",e[521]="JPEGACTABLES",e[529]="YCBCRCOEFFICIENTS",e[530]="YCBCRSUBSAMPLING",e[531]="YCBCRPOSITIONING",e[532]="REFERENCEBLACKWHITE",e[700]="XMP",e[33550]="GEOPIXELSCALE",e[33922]="GEOTIEPOINTS",e[33432]="COPYRIGHT",e[42112]="GDAL_METADATA",e[42113]="GDAL_NODATA",e[50844]="RPCCOEFFICIENT",e[34264]="GEOTRANSMATRIX",e[34735]="GEOKEYDIRECTORY",e[34736]="GEODOUBLEPARAMS",e[34737]="GEOASCIIPARAMS",e[34665]="EXIFIFD",e[34853]="GPSIFD",e[40965]="INTEROPERABILITYIFD",e})(),U=(()=>{const e=[].concat(P);return e[36864]="ExifVersion",e[40960]="FlashpixVersion",e[40961]="ColorSpace",e[42240]="Gamma",e[37121]="ComponentsConfiguration",e[37122]="CompressedBitsPerPixel",e[40962]="PixelXDimension",e[40963]="PixelYDimension",e[37500]="MakerNote",e[37510]="UserComment",e[40964]="RelatedSoundFile",e[36867]="DateTimeOriginal",e[36868]="DateTimeDigitized",e[36880]="OffsetTime",e[36881]="OffsetTimeOriginal",e[36882]="OffsetTimeDigitized",e[37520]="SubSecTime",e[37521]="SubSecTimeOriginal",e[37522]="SubSecTimeDigitized",e[37888]="Temperature",e[37889]="Humidity",e[37890]="Pressure",e[37891]="WaterDepth",e[37892]="Acceleration",e[37893]="CameraElevationAngle",e[42016]="ImageUniqueID",e[42032]="CameraOwnerName",e[42033]="BodySerialNumber",e[42034]="LensSpecification",e[42035]="LensMake",e[42036]="LensModel",e[42037]="LensSerialNumber",e[33434]="ExposureTime",e[33437]="FNumber",e[34850]="ExposureProgram",e[34852]="SpectralSensitivity",e[34855]="PhotographicSensitivity",e[34856]="OECF",e[34864]="SensitivityType",e[34865]="StandardOutputSensitivity",e[34866]="RecommendedExposureIndex",e[34867]="ISOSpeed",e[34868]="ISOSpeedLatitudeyyy",e[34869]="ISOSpeedLatitudezzz",e[37377]="ShutterSpeedValue",e[37378]="ApertureValue",e[37379]="BrightnessValue",e[37380]="ExposureBiasValue",e[37381]="MaxApertureValue",e[37382]="SubjectDistance",e[37383]="MeteringMode",e[37384]="LightSource",e[37385]="Flash",e[37386]="FocalLength",e[37396]="SubjectArea",e[41483]="FlashEnergy",e[41484]="SpatialFrequencyResponse",e[41486]="FocalPlaneXResolution",e[41487]="FocalPlaneYResolution",e[41488]="FocalPlaneResolutionUnit",e[41492]="SubjectLocation",e[41493]="ExposureIndex",e[41495]="SensingMethod",e[41728]="FileSource",e[41729]="SceneType",e[41730]="CFAPattern",e[41985]="CustomRendered",e[41986]="ExposureMode",e[41987]="WhiteBalance",e[41988]="DigitalZoomRatio",e[41989]="FocalLengthIn35mmFilm",e[41990]="SceneCaptureType",e[41991]="GainControl",e[41992]="Contrast",e[41993]="Saturation",e[41994]="Sharpness",e[41995]="DeviceSettingDescription",e[41996]="SubjectDistanceRange",e})(),B=(()=>{const e=[];return e[1024]="GTModelTypeGeoKey",e[1025]="GTRasterTypeGeoKey",e[1026]="GTCitationGeoKey",e[2048]="GeographicTypeGeoKey",e[2049]="GeogCitationGeoKey",e[2050]="GeogGeodeticDatumGeoKey",e[2051]="GeogPrimeMeridianGeoKey",e[2052]="GeogLinearUnitsGeoKey",e[2053]="GeogLinearUnitSizeGeoKey",e[2054]="GeogAngularUnitsGeoKey",e[2055]="GeogAngularUnitSizeGeoKey",e[2056]="GeogEllipsoidGeoKey",e[2057]="GeogSemiMajorAxisGeoKey",e[2058]="GeogSemiMinorAxisGeoKey",e[2059]="GeogInvFlatteningGeoKey",e[2061]="GeogPrimeMeridianLongGeoKey",e[2060]="GeogAzimuthUnitsGeoKey",e[3072]="ProjectedCSTypeGeoKey",e[3073]="PCSCitationGeoKey",e[3074]="ProjectionGeoKey",e[3075]="ProjCoordTransGeoKey",e[3076]="ProjLinearUnitsGeoKey",e[3077]="ProjLinearUnitSizeGeoKey",e[3078]="ProjStdParallel1GeoKey",e[3079]="ProjStdParallel2GeoKey",e[3080]="ProjNatOriginLongGeoKey",e[3081]="ProjNatOriginLatGeoKey",e[3082]="ProjFalseEastingGeoKey",e[3083]="ProjFalseNorthingGeoKey",e[3084]="ProjFalseOriginLongGeoKey",e[3085]="ProjFalseOriginLatGeoKey",e[3086]="ProjFalseOriginEastingGeoKey",e[3087]="ProjFalseOriginNorthingGeoKey",e[3088]="ProjCenterLongGeoKey",e[3090]="ProjCenterEastingGeoKey",e[3091]="ProjCenterNorthingGeoKey",e[3092]="ProjScaleAtNatOriginGeoKey",e[3093]="ProjScaleAtCenterGeoKey",e[3094]="ProjAzimuthAngleGeoKey",e[3095]="ProjStraightVertPoleLongGeoKey",e[4096]="VerticalCSTypeGeoKey",e[4097]="VerticalCitationGeoKey",e[4098]="VerticalDatumGeoKey",e[4099]="VerticalUnitsGeoKey",e})(),O=new Map;O.set("EXIFIFD",U),O.set("GPSIFD",["GPSVersionID","GPSLatitudeRef","GPSLatitude","GPSLongitudeRef","GPSLongitude","GPSAltitudeRef","GPSAltitude","GPSTimeStamp","GPSSatellites","GPSStatus","GPSMeasureMode","GPSDOP","GPSSpeedRef","GPSSpeed","GPSTrackRef","GPSTrack","GPSImgDirectionRef","GPSImgDirection","GPSMapDatum","GPSDestLatitudeRef","GPSDestLatitude","GPSDestLongitudeRef","GPSDestLongitude","GPSDestBearingRef","GPSDestBearing","GPSDestDistanceRef","GPSDestDistance","GPSProcessingMethod","GPSAreaInformation","GPSDateStamp","GPSDifferential","GPSHPositioningError"]);var L={TIFF_TAGS:P,ifdTags:O,GEO_KEYS:B,getTagName:function(e,t){let r=(t||P)[e];return void 0===r&&(r="unknown"+String(e)),r}};const _=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8];function N(e,t){let r="unknown";return 3===e?r="f32":1===e?1===t?r="u1":2===t?r="u2":4===t?r="u4":t<=8?r="u8":t<=16?r="u16":t<=32&&(r="u32"):2===e&&(t<=8?r="s8":t<=16?r="s16":t<=32&&(r="s32")),r}function F(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;default:t=Float32Array}return t}function V(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function j(e,t){const r=e.get(t);return r&&r.values}function K(e,t){const r=e.get(t);return r&&r.values[0]}function H(e,t,r,i=0,o=L.TIFF_TAGS,n=4){const a=8===n,s=a?W(new DataView(e,r,8),0,t):new DataView(e,r,2).getUint16(0,t),l=4+2*n,f=a?8:2,u=f+s*l;if(r+u>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:u};const c=r+u+4<=e.byteLength?q(new DataView(e,r+u,8===n?8:4),0,t,8===n):null,h=r+f,d=new Map;let p,m,w,y,g,C,A;for(let r=0;r<s;r++)m=new DataView(e,h+l*r,l),w=m.getUint16(0,t),g=m.getUint16(2,t),y=L.getTagName(w,o),2===n?(C=m.getUint16(4,t),A=m.getUint16(6,t)):4===n?(C=m.getUint32(4,t),A=m.getUint32(8,t)):8===n&&(C=q(m,4,t,!0),A=q(m,12,t,!0)),p={id:w,type:g,valueCount:C,valueOffset:A,values:null},z(e,t,p,i,!1,n),d.set(y,p);return{success:!0,ifd:d,nextIFD:c,requiredBufferSize:u}}const Y=function(e,t,r,i,o){const n=G===t,a=K(r,"BITSPERSAMPLE"),s=N(K(r,"SAMPLEFORMAT")||1,a),l=K(r,"COMPRESSION")||1,f=F(s);let u,c,h,d,p,m,w;if(1===l)h=e.slice(i,i+o),d=new Uint8Array(h);else if(8===l||32946===l)d=new Uint8Array(e,i,o),m=new T(d),w=m.getBytes(),h=new ArrayBuffer(w.length),d=new Uint8Array(h),d.set(w);else if(6===l){d=new Uint8Array(e,i,o);const t=new S;t.parse(d);const r=t.getData(t.width,t.height,!0);h=new ArrayBuffer(r.length),d=new Uint8Array(h),d.set(r)}else 5===l&&(d=function(e,t,r,i=!0){const o=function(e,t,r,i=!0){if(t%4!=0||r%4!=0){const o=new ArrayBuffer(4*Math.ceil(r/4)),n=new Uint8Array(o),a=new Uint8Array(e,t,r);if(i)for(let e=0;e<n.length;e+=4)n[e]=a[e+3],n[e+1]=a[e+2],n[e+2]=a[e+1],n[e+3]=a[e];else n.set(a);return new Uint32Array(n.buffer)}if(i){const i=new Uint8Array(e,t,r),o=new Uint8Array(i.length);for(let e=0;e<o.length;e+=4)o[e]=i[e+3],o[e+1]=i[e+2],o[e+2]=i[e+1],o[e+3]=i[e];return new Uint32Array(o.buffer)}return new Uint32Array(e,t,r/4)}(e,t,r,i);let n=9,a=x(),s=32,l=a.length,f=[],u=1,c=o[0],h=0;const d=o.length,p=8*(4*d-r),m=[];for(;null!=c;){if(s>=n)s-=n,h=c>>>32-n,c<<=n;else{h=c>>>32-s,c=o[u++];const e=n-s;s=32-e,h=(h<<e)+(c>>>s),c<<=e}if(257===h)break;if(256===h){n=9,a=x(),l=a.length,f=[];continue}const e=a[h];if(null==e){if(h>a.length)throw"data integrity issue: code does not exist on code page";f.push(f[0]),a[l++]=f.slice(),I(m,f)}else I(m,e),f.push(e[0]),f.length>1&&(a[l++]=f.slice()),f=e.slice();if(R.has(l)&&n++,0===s&&(c=o[u++],s=32),u>d||u===d&&s<=p)break}return new Uint8Array(m)}(e,i,o,t),h=d.buffer);if("u8"===s||"s8"===s||n)c=new f(h);else{switch(h=new ArrayBuffer(d.length),p=new Uint8Array(h),s){case"u16":case"s16":for(u=0;u<d.length;u+=2)p[u]=d[u+1],p[u+1]=d[u];break;case"u32":case"s32":case"f32":for(u=0;u<d.length;u+=4)p[u]=d[u+3],p[u+1]=d[u+2],p[u+2]=d[u+1],p[u+3]=d[u]}c=new f(h)}return c};function z(e,t,r,i=0,o=!1,n=4){if(r.values)return!0;const a=r.type,s=r.valueCount;let l=r.valueOffset,f=[];const u=_[a],c=8*u,h=s*u,d=s*_[a]*8;let p,m;const w=8===n?64:32;if(d>w&&h>(o?e.byteLength:e?e.byteLength-l+i:0))return r.offlineOffsetSize=[l,h],r.values=null,!1;if(d<=w)if(t||(l>>>=32-d),1===s)f=[l];else if(64===w){const e=l>>>0,t=Math.round((l-e)/4294967296);let r=e,i=32;for(m=1;m<=s;m++){const e=32-c*m%32;if(i<c){const o=r<<e>>>32-i;r=t,f.push(o+(t<<32-i>>>32-i)*Math.pow(2,c-i)),i-=32-(c-i)}else f.push(r<<e>>>32-c),i-=c;0===i&&(i=32,r=t)}}else for(m=1;m<=s;m++)f.push(l<<32-c*m>>>32-c);else{l-=i,o&&(l=0);for(let r=l;r<l+h;r+=u){switch(a){case 1:case 2:p=new DataView(e,r,1).getUint8(0);break;case 3:p=new DataView(e,r,2).getUint16(0,t);break;case 4:p=new DataView(e,r,4).getUint32(0,t);break;case 5:p=new DataView(e,r,4).getUint32(0,t)/new DataView(e,r+4,4).getUint32(0,t);break;case 6:p=new DataView(e,r,1).getInt8(0);break;case 7:p=new DataView(e,r,1).getUint8(0);break;case 8:p=new DataView(e,r,2).getInt16(0,t);break;case 9:p=new DataView(e,r,4).getInt32(0,t);break;case 10:p=new DataView(e,r,4).getInt32(0,t)/new DataView(e,r+4,4).getInt32(0,t);break;case 11:p=new DataView(e,r,4).getFloat32(0,t);break;case 12:p=new DataView(e,r,8).getFloat64(0,t);break;case 16:case 18:p=W(new DataView(e,r,8),0,t);break;case 17:p=X(new DataView(e,r,8),0,t);break;default:p=null}f.push(p)}}if(2===a){let e="";const t=f;for(f=[],m=0;m<t.length;m++)0===t[m]&&""!==e?(f.push(e),e=""):e+=String.fromCharCode(t[m]);""===e&&0!==f.length||f.push(e)}return r.values=f,!0}function J(e){const t=e[0],r=K(t,"TILEWIDTH"),i=K(t,"TILELENGTH"),o=K(t,"IMAGEWIDTH"),n=K(t,"IMAGELENGTH"),a=K(t,"BITSPERSAMPLE"),s=K(t,"SAMPLESPERPIXEL"),l=K(t,"SAMPLEFORMAT")||1,f=N(l,a),u=!!j(t,"PLANARCONFIGURATION")&&2===j(t,"PLANARCONFIGURATION")[0],c=j(t,"GDAL_NODATA");let h;null!=c&&("string"==typeof c[0]?(h=c.map((e=>parseFloat(e))),h.some((e=>isNaN(e)))&&(h=null)):"number"==typeof c[0]&&(h=c));const d=K(t,"COMPRESSION")||1;let p;switch(d){case 1:p="NONE";break;case 2:case 3:case 4:case 32771:p="CCITT";break;case 5:p="LZW";break;case 6:case 7:p="JPEG";break;case 32773:p="PACKBITS";break;case 8:case 32946:p="DEFLATE";break;case 34712:p="JPEG2000";break;default:p=String(d)}let m=!0,w="";1!==d&&5!==d&&6!==d&&8!==d&&32946!==d&&(m=!1,w+="unsupported tag compression "+d),l>3&&(m=!1,w+="unsupported tag sampleFormat "+l),a%8!=0&&(m=!1,w+="unsupported tag bitsPerSample "+a);const y=K(t,"GEOASCIIPARAMS");let g;if(y){const e=y.split("|").filter((e=>e.indexOf("ESRI PE String = ")>-1))[0],t=e?e.replace("ESRI PE String = ",""):"";g=0===t.indexOf("PROJCS")||0===t.indexOf("GEOGCS")?{wkid:null,wkt:t}:null}const C=j(t,"GEOTIEPOINTS"),A=j(t,"GEOPIXELSCALE"),v=j(t,"GEOTRANSMATRIX"),T=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let k,S,b=!1;if(T){b=2===K(T,"GTRasterTypeGeoKey");const e=K(T,"GTModelTypeGeoKey");if(2===e){const e=K(T,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(g={wkid:e})}else if(1===e){const e=K(T,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(g={wkid:e})}}if(A&&C&&C.length>=6?(k=[A[0],0,C[3]-C[0]*A[0],0,-Math.abs(A[1]),C[4]-C[1]*A[1]],b&&(k[2]-=.5*k[0]+.5*k[1],k[5]-=.5*k[3]+.5*k[4])):v&&16===v.length&&(k=[v[0],v[1],v[3],v[4],v[5],v[7]]),k){const e=[{x:0,y:n},{x:0,y:0},{x:o,y:n},{x:o,y:0}];let t,r=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let o=0;o<e.length;o++)t=V(e[o],k),r=t.x>r?r:t.x,a=t.x<a?a:t.x,i=t.y>i?i:t.y,s=t.y<s?s:t.y;S={xmin:r,xmax:a,ymin:i,ymax:s,spatialReference:g}}const M=e.filter((e=>1===K(e,"NEWSUBFILETYPE")));let E,G,D,x,I;M.length>0&&(E=Math.round(Math.log(o/K(M[0],"IMAGEWIDTH"))/Math.LN2),G=Math.round(Math.log(o/K(M[M.length-1],"IMAGEWIDTH"))/Math.LN2),D=K(M[M.length-1],"TILEWIDTH"),x=K(M[M.length-1],"TILEHEIGHT")),D=G>0?D||r:null,x=G>0?x||i:null,r&&(I=[{maxCol:Math.ceil(o/r)-1,maxRow:Math.ceil(n/i)-1,minRow:0,minCol:0}],M.forEach((e=>{I.push({maxCol:Math.ceil(K(e,"IMAGEWIDTH")/K(e,"TILEWIDTH"))-1,maxRow:Math.ceil(K(e,"IMAGELENGTH")/K(e,"TILELENGTH"))-1,minRow:0,minCol:0})})));const R=function(e){if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const r=new Map;let i,o,n,a,s;for(let e=0;e<t.length;e++)i=t[e],o=i.slice("<Item ".length,i.indexOf(">")),a=i.indexOf("sample="),a>-1&&(s=i.slice(a+'sample="'.length,i.indexOf('"',a+'sample="'.length))),a=i.indexOf("name="),a>-1&&(o=i.slice(a+'name="'.length,i.indexOf('"',a+'name="'.length))),o&&(n=i.slice(i.indexOf(">")+1,i.indexOf("</Item>")).trim(),null!=s?r.has(o)?r.get(o)[s]=n:r.set(o,[n]):r.set(o,n)),s=null;const l=r.get("STATISTICS_MINIMUM"),f=r.get("STATISTICS_MAXIMUM"),u=r.get("STATISTICS_MEAN"),c=r.get("STATISTICS_STDDEV");let h=null;if(l&&f){h=[];for(let e=0;e<l.length;e++)h.push({min:parseFloat(l[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const d=r.get("BandName"),p=r.get("WavelengthMin"),m=r.get("WavelengthMax");let w=null;if(d){w=[];for(let e=0;e<d.length;e++)w.push({BandName:d[e],WavelengthMin:p&&parseFloat(p[e]),WavelengthMax:m&&parseFloat(m[e])})}return{statistics:h,bandProperties:w,dataType:r.get("DataType"),rawMetadata:r}}(K(e[0],"GDAL_METADATA"));return{width:o,height:n,tileWidth:r,tileHeight:i,planes:s,isBSQ:u,pixelType:f,compression:p,noData:h,isSupported:m,message:w,extent:S,firstPyramidLevel:E,maximumPyramidLevel:G,pyramidBlockWidth:D,pyramidBlockHeight:x,tileBoundary:I,metadata:R}}function W(e,t,r){const i=e.getUint32(t,r),o=e.getUint32(t+4,r);return r?4294967296*o+i:4294967296*i+o}function X(e,t,r){let i=r?e.getInt32(t,r):e.getUint32(t,r),o=r?e.getUint32(t+4,r):e.getInt32(t+4,r);const n=(r?i:o)>=0?1:-1;return r?i*=n:o*=n,n*(r?4294967296*o+i:4294967296*i+o)}function q(e,t,r,i){return i?W(e,t,r):e.getUint32(t,r)}function Z(e){const t=new DataView(e,0,16),r=t.getUint16(0,!1);let i=null;if(18761===r)i=!0;else{if(19789!==r)throw"unexpected endianess byte";i=!1}const o=t.getUint16(2,i);if(42!==o&&43!==o)throw"unexpected tiff identifier";let n=4;const a=43===o;if(a){const e=t.getUint16(n,i);if(n+=2,8!==e)throw"unsupported bigtiff version";if(0!==t.getUint16(n,i))throw"unsupported bigtiff version";n+=2}return{littleEndian:i,isBigTiff:a,firstIFD:q(t,n,i,a)}}function Q(e,t,r,i=0,o=L.TIFF_TAGS,n=4){const a=H(e,t,r,i,o,n);let s;const l=a.ifd;if(l){if(L.ifdTags.forEach(((r,o)=>{l.has(o)&&(s=l.get(o),s.data=H(e,t,s.valueOffset-i,i,r).ifd)})),l.has("GEOKEYDIRECTORY")){s=l.get("GEOKEYDIRECTORY");const r=s.values;if(r&&r.length>4){const o=r[0]+"."+r[1]+"."+r[2];s.data=H(e,t,s.valueOffset+6-i,i,L.GEO_KEYS,2).ifd,s.data&&s.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[o]})}}if(l.has("XMP")){s=l.get("XMP");const e=s.values;"number"==typeof e[0]&&7===s.type&&(s.values=[D(new Uint8Array(e))])}}return a}function $(e,t){t=t||function(e){const{littleEndian:t,isBigTiff:r,firstIFD:i}=Z(e);let o=i;const n=[];do{const i=Q(e,t,o,0,L.TIFF_TAGS,r?8:4);if(!i.success)break;n.push(i.ifd),o=i.nextIFD}while(o>0);return{...J(n),littleEndian:t,isBigTiff:r,ifds:n}}(e);const{ifds:r,noData:i}=t;if(0===r.length)throw"no valid image file directory";let o,n;const a=r[0],s=i?i[0]:null;if(n=t.tileWidth?function(e,t,r){const i=j(r,"TILEOFFSETS");if(void 0===i)return null;const o=j(r,"TILEBYTECOUNTS"),n=t.tileWidth,a=t.tileHeight,{width:s,height:l,pixelType:f,isBSQ:u}=t,c=t.planes,h=s*l,d=j(r,"BITSPERSAMPLE")[0],p=F(f),m=[];for(let e=0;e<c;e++)m.push(new p(h));let w,y,g,C,A,v,T,k,S,b,M,E,G;const D=Math.ceil(s/n);if(d%8==0)for(w=0;w<i.length;w++)for(v=Math.floor(w/D)*a,T=w%D*n,k=v*s+T,g=Y(e,t.littleEndian,r,i[w],o[w]),b=0,S=k,E=Math.min(n,s-T),M=Math.min(a,l-v),y=0;y<c;y++)if(G=m[y],u)for(C=0;C<M;C++)for(S=k+C*s,b=n*a*y+C*n,A=0;A<E;A++,S++,b++)G[S]=g[b];else for(C=0;C<M;C++)for(S=k+C*s,b=C*n*c+y,A=0;A<E;A++,S++,b+=c)G[S]=g[b];return{width:s,height:l,pixelType:f,pixels:m}}(e,t,a):function(e,t,r){const i=G===t.littleEndian,o=j(r,"STRIPOFFSETS");if(void 0===o)return null;const{width:n,height:a,pixelType:s}=t,l=t.planes,f=n*a,u=j(r,"BITSPERSAMPLE")[0],c=F(s),h=new c(f*l),d=j(r,"STRIPBYTECOUNTS"),p=j(r,"ROWSPERSTRIP")[0],m=j(r,"COMPRESSION")?j(r,"COMPRESSION")[0]:1;let w,y,g,C,A,v,k,b,M,E,D,x=p;if(u%8==0)for(w=0;w<o.length;w++){if(A=w*(p*n)*l,x=(w+1)*p>a?a-w*p:p,"u8"===s||"s8"===s||i){if(8===m||32946===m)k=new Uint8Array(e,o[w],d[w]),E=new T(k),D=E.getBytes(),v=new ArrayBuffer(D.length),k=new Uint8Array(v),k.set(D),k.length!==x*n*l*u/8&&console.log("strip byte counts is different than expected");else if(6===m){k=new Uint8Array(e,o[w],d[w]);const t=new S;t.parse(k);const r=t.getData(t.width,t.height,!0);v=new ArrayBuffer(r.length),k=new Uint8Array(v),k.set(r)}else 1===m&&(d[w]!==x*n*l*u/8&&console.log("strip byte counts is different than expected"),v=e.slice(o[w],o[w]+d[w]));C=new c(v)}else{switch(6===m||8===m||32946===m?(k=new Uint8Array(e,o[w],d[w]),E=new T(k),k=E.getBytes(),v=new ArrayBuffer(k.length),b=new Uint8Array(v),k.length!==x*n*l*u/8&&console.log("strip byte counts is different than expected")):1===m&&(d[w]!==x*n*l*u/8&&console.log("strip byte counts is different than expected"),v=new ArrayBuffer(d[w]),k=new Uint8Array(e,o[w],d[w]),b=new Uint8Array(v)),s){case"u16":case"s16":for(g=0;g<k.length;g+=2)b[g]=k[g+1],b[g+1]=k[g];break;case"u32":case"s32":case"f32":for(g=0;g<k.length;g+=4)b[g]=k[g+3],b[g+1]=k[g+2],b[g+2]=k[g+1],b[g+3]=k[g]}C=new c(v)}h.set(C,A)}const I=[];if(1===l)I.push(h);else for(w=0;w<l;w++){for(M=new c(f),y=0;y<f;y++)M[y]=h[y*l+w];I.push(M)}return{width:n,height:a,pixelType:s,pixels:I}}(e,t,a),null!==s){if(n.mask=new Uint8Array(n.width*n.height),Math.abs(s)>1e24)for(o=0;o<n.width*n.height;o++)n.mask[o]=Math.abs((n.pixels[0][o]-s)/s)<1e-6?0:1;else for(o=0;o<n.width*n.height;o++)n.mask[o]=n.pixels[0][o]===s?0:1;n.noDataValue=s}return n}var ee=w((function(e){var t,r,i,o;t={unstuff:function(e,t,r,i,o,n,a,s){var l,f,u,c,h,d=(1<<r)-1,p=0,m=0,w=4*e.length-Math.ceil(r*i/8);if(e[e.length-1]<<=8*w,o)for(l=0;l<i;l++)0===m&&(u=e[p++],m=32),m>=r?(f=u>>>m-r&d,m-=r):(f=(u&d)<<(c=r-m)&d,f+=(u=e[p++])>>>(m=32-c)),t[l]=o[f];else for(h=Math.ceil((s-n)/a),l=0;l<i;l++)0===m&&(u=e[p++],m=32),m>=r?(f=u>>>m-r&d,m-=r):(f=(u&d)<<(c=r-m)&d,f+=(u=e[p++])>>>(m=32-c)),t[l]=f<h?n+f*a:s},unstuffLUT:function(e,t,r,i,o,n){var a,s=(1<<t)-1,l=0,f=0,u=0,c=0,h=0,d=[],p=4*e.length-Math.ceil(t*r/8);e[e.length-1]<<=8*p;var m=Math.ceil((n-i)/o);for(f=0;f<r;f++)0===c&&(a=e[l++],c=32),c>=t?(h=a>>>c-t&s,c-=t):(h=(a&s)<<(u=t-c)&s,h+=(a=e[l++])>>>(c=32-u)),d[f]=h<m?i+h*o:n;return d.unshift(i),d},unstuff2:function(e,t,r,i,o,n,a,s){var l,f,u,c,h=(1<<r)-1,d=0,p=0,m=0;if(o)for(l=0;l<i;l++)0===p&&(u=e[d++],p=32,m=0),p>=r?(f=u>>>m&h,p-=r,m+=r):(f=u>>>m&h,p=32-(c=r-p),f|=((u=e[d++])&(1<<c)-1)<<r-c,m=c),t[l]=o[f];else{var w=Math.ceil((s-n)/a);for(l=0;l<i;l++)0===p&&(u=e[d++],p=32,m=0),p>=r?(f=u>>>m&h,p-=r,m+=r):(f=u>>>m&h,p=32-(c=r-p),f|=((u=e[d++])&(1<<c)-1)<<r-c,m=c),t[l]=f<w?n+f*a:s}return t},unstuffLUT2:function(e,t,r,i,o,n){var a,s=(1<<t)-1,l=0,f=0,u=0,c=0,h=0,d=0,p=[],m=Math.ceil((n-i)/o);for(f=0;f<r;f++)0===c&&(a=e[l++],c=32,d=0),c>=t?(h=a>>>d&s,c-=t,d+=t):(h=a>>>d&s,c=32-(u=t-c),h|=((a=e[l++])&(1<<u)-1)<<t-u,d=u),p[f]=h<m?i+h*o:n;return p.unshift(i),p},originalUnstuff:function(e,t,r,i){var o,n,a,s,l=(1<<r)-1,f=0,u=0,c=4*e.length-Math.ceil(r*i/8);for(e[e.length-1]<<=8*c,o=0;o<i;o++)0===u&&(a=e[f++],u=32),u>=r?(n=a>>>u-r&l,u-=r):(n=(a&l)<<(s=r-u)&l,n+=(a=e[f++])>>>(u=32-s)),t[o]=n;return t},originalUnstuff2:function(e,t,r,i){var o,n,a,s,l=(1<<r)-1,f=0,u=0,c=0;for(o=0;o<i;o++)0===u&&(a=e[f++],u=32,c=0),u>=r?(n=a>>>c&l,u-=r,c+=r):(n=a>>>c&l,u=32-(s=r-u),n|=((a=e[f++])&(1<<s)-1)<<r-s,c=s),t[o]=n;return t}},r={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,r=65535,i=e.length,o=Math.floor(i/2),n=0;o;){var a=o>=359?359:o;o-=a;do{t+=e[n++]<<8,r+=t+=e[n++]}while(--a);t=(65535&t)+(t>>>16),r=(65535&r)+(r>>>16)}return 1&i&&(r+=t+=e[n]<<8),((r=(65535&r)+(r>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var r=t.ptr,i=new Uint8Array(e,r,6),o={};if(o.fileIdentifierString=String.fromCharCode.apply(null,i),0!==o.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+o.fileIdentifierString;r+=6;var n=new DataView(e,r,8),a=n.getInt32(0,!0);if(o.fileVersion=a,r+=4,a>=3&&(o.checksum=n.getUint32(4,!0),r+=4),n=new DataView(e,r,12),o.height=n.getUint32(0,!0),o.width=n.getUint32(4,!0),r+=8,a>=4?(o.numDims=n.getUint32(8,!0),r+=4):o.numDims=1,n=new DataView(e,r,40),o.numValidPixel=n.getUint32(0,!0),o.microBlockSize=n.getInt32(4,!0),o.blobSize=n.getInt32(8,!0),o.imageType=n.getInt32(12,!0),o.maxZError=n.getFloat64(16,!0),o.zMin=n.getFloat64(24,!0),o.zMax=n.getFloat64(32,!0),r+=40,t.headerInfo=o,t.ptr=r,a>=3&&this.computeChecksumFletcher32(new Uint8Array(e,r-(a>=4?52:48),o.blobSize-14))!==o.checksum)throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var r=t.headerInfo,i=this.getDataTypeArray(r.imageType),o=r.numDims*this.getDataTypeSize(r.imageType),n=this.readSubArray(e,t.ptr,i,o),a=this.readSubArray(e,t.ptr+o,i,o);t.ptr+=2*o;var s,l=!0;for(s=0;s<r.numDims;s++)if(n[s]!==a[s]){l=!1;break}return r.minValues=n,r.maxValues=a,l},readSubArray:function(e,t,r,i){var o;if(r===Uint8Array)o=new Uint8Array(e,t,i);else{var n=new ArrayBuffer(i);new Uint8Array(n).set(new Uint8Array(e,t,i)),o=new r(n)}return o},readMask:function(e,t){var r,i,o=t.ptr,n=t.headerInfo,a=n.width*n.height,s=n.numValidPixel,l=new DataView(e,o,4),f={};if(f.numBytes=l.getUint32(0,!0),o+=4,(0===s||a===s)&&0!==f.numBytes)throw"invalid mask";if(0===s)r=new Uint8Array(Math.ceil(a/8)),f.bitset=r,i=new Uint8Array(a),t.pixels.resultMask=i,o+=f.numBytes;else if(f.numBytes>0){r=new Uint8Array(Math.ceil(a/8));var u=(l=new DataView(e,o,f.numBytes)).getInt16(0,!0),c=2,h=0,d=0;do{if(u>0)for(;u--;)r[h++]=l.getUint8(c++);else for(d=l.getUint8(c++),u=-u;u--;)r[h++]=d;u=l.getInt16(c,!0),c+=2}while(c<f.numBytes);if(-32768!==u||h<r.length)throw"Unexpected end of mask RLE encoding";i=new Uint8Array(a);var p=0,m=0;for(m=0;m<a;m++)7&m?(p=r[m>>3],p<<=7&m):p=r[m>>3],128&p&&(i[m]=1);t.pixels.resultMask=i,f.bitset=r,o+=f.numBytes}return t.ptr=o,t.mask=f,!0},readDataOneSweep:function(e,t,i){var o,n=t.ptr,a=t.headerInfo,s=a.numDims,l=a.width*a.height,f=a.numValidPixel*r.getDataTypeSize(a.imageType)*s,u=t.pixels.resultMask;if(i===Uint8Array)o=new Uint8Array(e,n,f);else{var c=new ArrayBuffer(f);new Uint8Array(c).set(new Uint8Array(e,n,f)),o=new i(c)}if(o.length===l*s)t.pixels.resultPixels=o;else{t.pixels.resultPixels=new i(l*s);var h=0,d=0,p=0,m=0;if(s>1)for(p=0;p<s;p++)for(m=p*l,d=0;d<l;d++)u[d]&&(t.pixels.resultPixels[m+d]=o[h++]);else for(d=0;d<l;d++)u[d]&&(t.pixels.resultPixels[d]=o[h++])}return t.ptr=n+=f,!0},readHuffmanTree:function(e,t){var o=this.HUFFMAN_LUT_BITS_MAX,n=new DataView(e,t.ptr,16);if(t.ptr+=16,n.getInt32(0,!0)<2)throw"unsupported Huffman version";var a=n.getInt32(4,!0),s=n.getInt32(8,!0),l=n.getInt32(12,!0);if(s>=l)return!1;var f=new Uint32Array(l-s);r.decodeBits(e,t,f);var u,c,h,d,p=[];for(u=s;u<l;u++)p[c=u-(u<a?0:a)]={first:f[u-s],second:null};var m=e.byteLength-t.ptr,w=Math.ceil(m/4),y=new ArrayBuffer(4*w);new Uint8Array(y).set(new Uint8Array(e,t.ptr,m));var g,C=new Uint32Array(y),A=0,v=0;for(g=C[0],u=s;u<l;u++)(d=p[c=u-(u<a?0:a)].first)>0&&(p[c].second=g<<A>>>32-d,32-A>=d?32===(A+=d)&&(A=0,g=C[++v]):(g=C[++v],p[c].second|=g>>>32-(A+=d-32)));var T,k=0,S=new i;for(u=0;u<p.length;u++)void 0!==p[u]&&(k=Math.max(k,p[u].first));T=k>=o?o:k;var b,M,E,G,D,x=[];for(u=s;u<l;u++)if((d=p[c=u-(u<a?0:a)].first)>0)if(b=[d,c],d<=T)for(M=p[c].second<<T-d,E=1<<T-d,h=0;h<E;h++)x[M|h]=b;else for(M=p[c].second,D=S,G=d-1;G>=0;G--)M>>>G&1?(D.right||(D.right=new i),D=D.right):(D.left||(D.left=new i),D=D.left),0!==G||D.val||(D.val=b[1]);return{decodeLut:x,numBitsLUTQick:T,numBitsLUT:k,tree:S,stuffedData:C,srcPtr:v,bitPos:A}},readHuffman:function(e,t,r){var i,o,n,a,s,l,f,u,c,h=t.headerInfo,d=h.numDims,p=t.headerInfo.height,m=t.headerInfo.width,w=m*p,y=this.readHuffmanTree(e,t),g=y.decodeLut,C=y.tree,A=y.stuffedData,v=y.srcPtr,T=y.bitPos,k=y.numBitsLUTQick,S=y.numBitsLUT,b=0===t.headerInfo.imageType?128:0,M=t.pixels.resultMask,E=0;T>0&&(v++,T=0);var G,D=A[v],x=1===t.encodeMode,I=new r(w*d),R=I;for(G=0;G<h.numDims;G++){if(d>1&&(R=new r(I.buffer,w*G,w),E=0),t.headerInfo.numValidPixel===m*p)for(u=0,l=0;l<p;l++)for(f=0;f<m;f++,u++){if(o=0,s=a=D<<T>>>32-k,32-T<k&&(s=a|=A[v+1]>>>64-T-k),g[s])o=g[s][1],T+=g[s][0];else for(s=a=D<<T>>>32-S,32-T<S&&(s=a|=A[v+1]>>>64-T-S),i=C,c=0;c<S;c++)if(!(i=a>>>S-c-1&1?i.right:i.left).left&&!i.right){o=i.val,T=T+c+1;break}T>=32&&(T-=32,D=A[++v]),n=o-b,x?(n+=f>0?E:l>0?R[u-m]:E,R[u]=n&=255,E=n):R[u]=n}else for(u=0,l=0;l<p;l++)for(f=0;f<m;f++,u++)if(M[u]){if(o=0,s=a=D<<T>>>32-k,32-T<k&&(s=a|=A[v+1]>>>64-T-k),g[s])o=g[s][1],T+=g[s][0];else for(s=a=D<<T>>>32-S,32-T<S&&(s=a|=A[v+1]>>>64-T-S),i=C,c=0;c<S;c++)if(!(i=a>>>S-c-1&1?i.right:i.left).left&&!i.right){o=i.val,T=T+c+1;break}T>=32&&(T-=32,D=A[++v]),n=o-b,x?(n+=f>0&&M[u-1]?E:l>0&&M[u-m]?R[u-m]:E,R[u]=n&=255,E=n):R[u]=n}t.ptr=t.ptr+4*(v+1)+(T>0?4:0)}t.pixels.resultPixels=I},decodeBits:function(e,r,i,o,n){var a=r.headerInfo,s=a.fileVersion,l=0,f=new DataView(e,r.ptr,e.byteLength-r.ptr>=5?5:e.byteLength-r.ptr),u=f.getUint8(0);l++;var c=u>>6,h=0===c?4:3-c,d=(32&u)>0,p=31&u,m=0;if(1===h)m=f.getUint8(l),l++;else if(2===h)m=f.getUint16(l,!0),l+=2;else{if(4!==h)throw"Invalid valid pixel count type";m=f.getUint32(l,!0),l+=4}var w,y,g,C,A,v,T,k,S,b=2*a.maxZError,M=a.numDims>1?a.maxValues[n]:a.zMax;if(d){for(r.counter.lut++,k=f.getUint8(l),l++,C=Math.ceil((k-1)*p/8),A=Math.ceil(C/4),y=new ArrayBuffer(4*A),g=new Uint8Array(y),r.ptr+=l,g.set(new Uint8Array(e,r.ptr,C)),T=new Uint32Array(y),r.ptr+=C,S=0;k-1>>>S;)S++;C=Math.ceil(m*S/8),A=Math.ceil(C/4),y=new ArrayBuffer(4*A),(g=new Uint8Array(y)).set(new Uint8Array(e,r.ptr,C)),w=new Uint32Array(y),r.ptr+=C,v=s>=3?t.unstuffLUT2(T,p,k-1,o,b,M):t.unstuffLUT(T,p,k-1,o,b,M),s>=3?t.unstuff2(w,i,S,m,v):t.unstuff(w,i,S,m,v)}else r.counter.bitstuffer++,S=p,r.ptr+=l,S>0&&(C=Math.ceil(m*S/8),A=Math.ceil(C/4),y=new ArrayBuffer(4*A),(g=new Uint8Array(y)).set(new Uint8Array(e,r.ptr,C)),w=new Uint32Array(y),r.ptr+=C,s>=3?null==o?t.originalUnstuff2(w,i,S,m):t.unstuff2(w,i,S,m,!1,o,b,M):null==o?t.originalUnstuff(w,i,S,m):t.unstuff(w,i,S,m,!1,o,b,M))},readTiles:function(e,t,i){var o=t.headerInfo,n=o.width,a=o.height,s=o.microBlockSize,l=o.imageType,f=r.getDataTypeSize(l),u=Math.ceil(n/s),c=Math.ceil(a/s);t.pixels.numBlocksY=c,t.pixels.numBlocksX=u,t.pixels.ptr=0;var h,d,p,m,w,y,g,C,A,v,T=0,k=0,S=0,b=0,M=0,E=0,G=0,D=0,x=0,I=0,R=0,P=0,U=0,B=0,O=new i(s*s),L=a%s||s,_=n%s||s,N=o.numDims,F=t.pixels.resultMask,V=t.pixels.resultPixels,j=o.fileVersion>=5?14:15,K=o.zMax;for(S=0;S<c;S++)for(M=S!==c-1?s:L,b=0;b<u;b++)for(x=S*n*s+b*s,I=n-(E=b!==u-1?s:_),C=0;C<N;C++){if(N>1?(v=V,x=S*n*s+b*s,V=new i(t.pixels.resultPixels.buffer,n*a*C*f,n*a),K=o.maxValues[C]):v=null,d={},B=0,B++,D=(G=(h=new DataView(e,t.ptr,Math.min(10,e.byteLength-t.ptr))).getUint8(0))>>6&255,(G>>2&j)!=(b*s>>3&j))throw"integrity issue";if((A=o.fileVersion>=5?4&G:0)&&0===C)throw"integrity issue";if((w=3&G)>3)throw t.ptr+=B,"Invalid block encoding ("+w+")";if(2!==w)if(0===w){if(A)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=B,R=(R=M*E*f)<(P=e.byteLength-t.ptr)?R:P,p=new ArrayBuffer(R%f==0?R:R+f-R%f),new Uint8Array(p).set(new Uint8Array(e,t.ptr,R)),m=new i(p),U=0,F)for(T=0;T<M;T++){for(k=0;k<E;k++)F[x]&&(V[x]=m[U++]),x++;x+=I}else for(T=0;T<M;T++){for(k=0;k<E;k++)V[x++]=m[U++];x+=I}t.ptr+=U*f}else if(y=r.getDataTypeUsed(A&&l<6?4:l,D),g=r.getOnePixel(d,B,y,h),B+=r.getDataTypeSize(y),3===w)if(t.ptr+=B,t.counter.constantoffset++,F)for(T=0;T<M;T++){for(k=0;k<E;k++)F[x]&&(V[x]=A?Math.min(K,v[x]+g):g),x++;x+=I}else for(T=0;T<M;T++){for(k=0;k<E;k++)V[x]=A?Math.min(K,v[x]+g):g,x++;x+=I}else if(t.ptr+=B,r.decodeBits(e,t,O,g,C),B=0,A)if(F)for(T=0;T<M;T++){for(k=0;k<E;k++)F[x]&&(V[x]=O[B++]+v[x]),x++;x+=I}else for(T=0;T<M;T++){for(k=0;k<E;k++)V[x]=O[B++]+v[x],x++;x+=I}else if(F)for(T=0;T<M;T++){for(k=0;k<E;k++)F[x]&&(V[x]=O[B++]),x++;x+=I}else for(T=0;T<M;T++){for(k=0;k<E;k++)V[x++]=O[B++];x+=I}else{if(A)if(F)for(T=0;T<M;T++)for(k=0;k<E;k++)F[x]&&(V[x]=v[x]),x++;else for(T=0;T<M;T++)for(k=0;k<E;k++)V[x]=v[x],x++;t.counter.constant++,t.ptr+=B}}},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:r.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e){var t=e.headerInfo.zMax,r=e.headerInfo.numDims,i=e.headerInfo.height*e.headerInfo.width,o=0,n=0,a=0,s=e.pixels.resultMask,l=e.pixels.resultPixels;if(s)if(r>1)for(o=0;o<r;o++)for(a=o*i,t=e.headerInfo.maxValues[o],n=0;n<i;n++)s[n]&&(l[a+n]=t);else for(n=0;n<i;n++)s[n]&&(l[n]=t);else if(r>1)for(o=0;o<r;o++)for(a=o*i,t=e.headerInfo.maxValues[o],n=0;n<i;n++)l[a+n]=t;else for(n=0;n<i;n++)l[n]=t},getDataTypeArray:function(e){var t;switch(e){case 0:t=Int8Array;break;case 1:t=Uint8Array;break;case 2:t=Int16Array;break;case 3:t=Uint16Array;break;case 4:t=Int32Array;break;case 5:t=Uint32Array;break;case 6:t=Float32Array;break;case 7:t=Float64Array;break;default:t=Float32Array}return t},getPixelType:function(e){var t;switch(e){case 0:t="S8";break;case 1:t="U8";break;case 2:t="S16";break;case 3:t="U16";break;case 4:t="S32";break;case 5:t="U32";break;case 6:t="F32";break;case 7:t="F64";break;default:t="F32"}return t},isValidPixelValue:function(e,t){if(null==t)return!1;var r;switch(e){case 0:r=t>=-128&&t<=127;break;case 1:r=t>=0&&t<=255;break;case 2:r=t>=-32768&&t<=32767;break;case 3:r=t>=0&&t<=65536;break;case 4:r=t>=-2147483648&&t<=2147483647;break;case 5:r=t>=0&&t<=4294967296;break;case 6:r=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:r=t>=5e-324&&t<=17976931348623157e292;break;default:r=!1}return r},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var r=e;switch(e){case 2:case 4:r=e-t;break;case 3:case 5:r=e-2*t;break;case 6:r=0===t?e:1===t?2:1;break;case 7:r=0===t?e:e-2*t+1;break;default:r=e}return r},getOnePixel:function(e,t,r,i){var o=0;switch(r){case 0:o=i.getInt8(t);break;case 1:o=i.getUint8(t);break;case 2:o=i.getInt16(t,!0);break;case 3:o=i.getUint16(t,!0);break;case 4:o=i.getInt32(t,!0);break;case 5:o=i.getUInt32(t,!0);break;case 6:o=i.getFloat32(t,!0);break;case 7:o=i.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return o}},i=function(e,t,r){this.val=e,this.left=t,this.right=r},void 0!==(o={decode:function(e,t){var i=(t=t||{}).noDataValue,o=0,n={};if(n.ptr=t.inputOffset||0,n.pixels={},r.readHeaderInfo(e,n)){var a=n.headerInfo,s=a.fileVersion,l=r.getDataTypeArray(a.imageType);if(s>5)throw"unsupported lerc version 2."+s;r.readMask(e,n),a.numValidPixel===a.width*a.height||n.pixels.resultMask||(n.pixels.resultMask=t.maskData);var f,u=a.width*a.height;if(n.pixels.resultPixels=new l(u*a.numDims),n.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0},0!==a.numValidPixel)if(a.zMax===a.zMin)r.constructConstantSurface(n);else if(s>=4&&r.checkMinMaxRanges(e,n))r.constructConstantSurface(n);else{var c=new DataView(e,n.ptr,2),h=c.getUint8(0);if(n.ptr++,h)r.readDataOneSweep(e,n,l);else if(s>1&&a.imageType<=1&&Math.abs(a.maxZError-.5)<1e-5){var d=c.getUint8(1);if(n.ptr++,n.encodeMode=d,d>2||s<4&&d>1)throw"Invalid Huffman flag "+d;d?r.readHuffman(e,n,l):r.readTiles(e,n,l)}else r.readTiles(e,n,l)}n.eofOffset=n.ptr,t.inputOffset?(f=n.headerInfo.blobSize+t.inputOffset-n.ptr,Math.abs(f)>=1&&(n.eofOffset=t.inputOffset+n.headerInfo.blobSize)):(f=n.headerInfo.blobSize-n.ptr,Math.abs(f)>=1&&(n.eofOffset=n.headerInfo.blobSize));var p={width:a.width,height:a.height,pixelData:n.pixels.resultPixels,minValue:a.zMin,maxValue:a.zMax,validPixelCount:a.numValidPixel,dimCount:a.numDims,dimStats:{minValues:a.minValues,maxValues:a.maxValues},maskData:n.pixels.resultMask};if(n.pixels.resultMask&&r.isValidPixelValue(a.imageType,i)){var m=n.pixels.resultMask;for(o=0;o<u;o++)m[o]||(p.pixelData[o]=i);p.noDataValue=i}return n.noDataValue=i,t.returnFileInfo&&(p.fileInfo=r.formatFileInfo(n)),p}},getBandCount:function(e){for(var t=0,i=0,o={ptr:0,pixels:{}};i<e.byteLength-58;)r.readHeaderInfo(e,o),t++,o.ptr=i+=o.headerInfo.blobSize;return t}})&&(e.exports=o)})),te=function(e){var t,r,i;function o(e){var t,r,i,o,n,a,s,l,f,u,c,h;for(this.data=e,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},o=null;;){switch(t=this.readUInt32(),s=function(){var e,t;for(t=[],e=0;e<4;++e)t.push(String.fromCharCode(this.data[this.pos++]));return t}.call(this).join("")){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(t);break;case"fcTL":o&&this.animation.frames.push(o),this.pos+=4,o={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},i=this.readUInt16(),r=this.readUInt16()||100,o.delay=1e3*i/r,o.disposeOp=this.data[this.pos++],o.blendOp=this.data[this.pos++],o.data=[];break;case"IDAT":case"fdAT":for("fdAT"===s&&(this.pos+=4,t-=4),e=(null!=o?o.data:void 0)||this.imgData,u=0;0<=t?u<t:u>t;0<=t?++u:--u)e.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(t),(l=255-this.transparency.indexed.length)>0)for(c=0;0<=l?c<l:c>l;0<=l?++c:--c)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(t)[0];break;case 2:this.transparency.rgb=this.read(t)}break;case"tEXt":n=(f=this.read(t)).indexOf(0),a=String.fromCharCode.apply(String,f.slice(0,n)),this.text[a]=String.fromCharCode.apply(String,f.slice(n+1));break;case"IEND":return o&&this.animation.frames.push(o),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(h=this.colorType)||6===h,this.pixelBitlength=this.bits*(this.colors+(this.hasAlphaChannel?1:0)),this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=t}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(e,t,r){var i;return"function"==typeof t&&(r=t),(i=new XMLHttpRequest).open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){var e;return e=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=t?t.getContext:void 0)&&e.render(t),"function"==typeof r?r(e):void 0},i.send(null)},o.prototype.read=function(e){var t,r;for(r=[],t=0;0<=e?t<e:t>e;0<=e?++t:--t)r.push(this.data[this.pos++]);return r},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(e){var t,r,i,o,n,a,s,l,f,u,c,h,d,p,m,w,y,g,C,A,v,k;if(null==e&&(e=this.imgData),0===e.length)return new Uint8Array(0);for(e=(e=new T(e)).getBytes(),m=(c=this.pixelBitlength/8)*this.width,h=new Uint8Array(m*this.height),a=e.length,p=0,d=0,r=0;d<a;){switch(e[d++]){case 0:for(o=g=0;g<m;o=g+=1)h[r++]=e[d++];break;case 1:for(o=C=0;C<m;o=C+=1)t=e[d++],n=o<c?0:h[r-c],h[r++]=(t+n)%256;break;case 2:for(o=A=0;A<m;o=A+=1)t=e[d++],i=(o-o%c)/c,h[r++]=((w=p&&h[(p-1)*m+i*c+o%c])+t)%256;break;case 3:for(o=v=0;v<m;o=v+=1)t=e[d++],i=(o-o%c)/c,n=o<c?0:h[r-c],w=p&&h[(p-1)*m+i*c+o%c],h[r++]=(t+Math.floor((n+w)/2))%256;break;case 4:for(o=k=0;k<m;o=k+=1)t=e[d++],i=(o-o%c)/c,0===p?w=y=0:(w=h[(p-1)*m+i*c+o%c],y=i&&h[(p-1)*m+(i-1)*c+o%c]),s=(n=o<c?0:h[r-c])+w-y,l=Math.abs(s-n),f=Math.abs(s-w),u=Math.abs(s-y),h[r++]=(t+(l<=f&&l<=u?n:f<=u?w:y))%256;break;default:throw new Error("Invalid filter algorithm: "+e[d-1])}p++}return h},o.prototype.decodePalette=function(){var e,t,r,i,o,n,a,s,l;for(r=this.palette,n=this.transparency.indexed||[],o=new Uint8Array((n.length||0)+r.length),i=0,e=0,t=a=0,s=r.length;a<s;t=a+=3)o[i++]=r[t],o[i++]=r[t+1],o[i++]=r[t+2],o[i++]=null!=(l=n[e++])?l:255;return o},o.prototype.copyToImageData=function(e,t){var r,i,o,n,a,s,l,f,u,c,h;if(i=this.colors,u=null,r=this.hasAlphaChannel,this.palette.length&&(u=null!=(h=this._decodedPalette)?h:this._decodedPalette=this.decodePalette(),i=4,r=!0),f=(o=e.data||e).length,a=u||t,n=s=0,1===i)for(;n<f;)l=u?4*t[n/4]:s,c=a[l++],o[n++]=c,o[n++]=c,o[n++]=c,o[n++]=r?a[l++]:this.transparency.grayscale&&this.transparency.grayscale===c?0:255,s=l;else for(;n<f;)l=u?4*t[n/4]:s,o[n++]=a[l++],o[n++]=a[l++],o[n++]=a[l++],o[n++]=r?a[l++]:this.transparency.rgb&&this.transparency.rgb[1]===a[l-3]&&this.transparency.rgb[3]===a[l-2]&&this.transparency.rgb[5]===a[l-1]?0:255,s=l},o.prototype.decode=function(){var e;return e=new Uint8Array(this.width*this.height*4),this.copyToImageData(e,this.decodePixels()),e},r=e.document&&e.document.createElement("canvas"),i=r&&r.getContext("2d"),t=function(e){var t;return i.width=e.width,i.height=e.height,i.clearRect(0,0,e.width,e.height),i.putImageData(e,0,0),(t=new Image).src=r.toDataURL(),t},o.prototype.decodeFrames=function(e){var r,i,o,n,a,s,l,f;if(this.animation){for(f=[],i=a=0,s=(l=this.animation.frames).length;a<s;i=++a)o=e.createImageData((r=l[i]).width,r.height),n=this.decodePixels(new Uint8Array(r.data)),this.copyToImageData(o,n),r.imageData=o,f.push(r.image=t(o));return f}},o.prototype.renderFrame=function(e,t){var r,i,o;return r=(i=this.animation.frames)[t],o=i[t-1],0===t&&e.clearRect(0,0,this.width,this.height),1===(null!=o?o.disposeOp:void 0)?e.clearRect(o.xOffset,o.yOffset,o.width,o.height):2===(null!=o?o.disposeOp:void 0)&&e.putImageData(o.imageData,o.xOffset,o.yOffset),0===r.blendOp&&e.clearRect(r.xOffset,r.yOffset,r.width,r.height),e.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(e){var t,r,i,o,n,a,s=this;return r=0,o=(a=this.animation).numFrames,i=a.frames,n=a.numPlays,(t=function(){var a,l;if(a=r++%o,l=i[a],s.renderFrame(e,a),o>1&&r/o<n)return s.animation._timeout=setTimeout(t,l.delay)})()},o.prototype.stopAnimation=function(){var e;return clearTimeout(null!=(e=this.animation)?e._timeout:void 0)},o.prototype.render=function(e){var t,r;return e._png&&e._png.stopAnimation(),e._png=this,e.width=this.width,e.height=this.height,t=e.getContext("2d"),this.animation?(this.decodeFrames(t),this.animate(t)):(r=t.createImageData(this.width,this.height),this.copyToImageData(r,this.decodePixels()),t.putImageData(r,0,0))},o}(self);const re=new Set(["jpg","png","bmp","gif"]);function ie(e,t){if(!G)throw new a("rasterCoded:decode","lerc decoder is not supported on big endian platform");const{width:r,height:i,pixelType:o}=t,n=fe(o),s=n.pixelTypeCtor,l=null==t.noDataValue?n.noDataValue:t.noDataValue;let f,u,c=0,h=0;const d=e.byteLength-10;for(;h<d;){const t=y(e,{inputOffset:h,encodedMaskData:f,returnMask:0===c,returnEncodedMask:0===c,returnFileInfo:!0,pixelType:s,noDataValue:l});if(r&&i&&(t.width!==r||t.height!==i))throw new a("rasterCoded:decode","lerc decoded result has width or height different from specified in options");if(h=t.fileInfo.eofOffset,0===c&&(f=t.encodedMaskData,u=new v({width:t.width,height:t.height,pixels:[],pixelType:o,mask:t.maskData,statistics:[]})),c++,u.addData({pixels:t.pixelData,statistics:{minValue:t.minValue,maxValue:t.maxValue,noDataValue:t.noDataValue}}),d-h>10){const t=String.fromCharCode.apply(null,new Uint8Array(e,h,10));h=h+t.indexOf("CntZ")>-1?t.indexOf("CntZ"):0}}return u}function oe(e,t){if(!G)throw new a("rasterCoded:decode","lerc decoder is not supported on big endian platform");let r,i,o,n=0,s=0,l=0;const f=e.byteLength-10,u=[],{width:c,height:h}=t;for(;s<f;){var d;if(i=ee.decode(e,{inputOffset:s,maskData:r,returnFileInfo:!0}),c&&h&&(i.width!==c||i.height!==h))throw new a("rasterCoded:decode","lerc2 decoded result has width or height different from what's specified in options");if(s=i.fileInfo.eofOffset,0===n&&(l=i.fileInfo.numValidPixel,r=i.maskData,o=new v({width:i.width,height:i.height,pixels:[],pixelType:i.fileInfo.pixelType,mask:i.maskData,statistics:[]})),i.fileInfo.mask&&i.fileInfo.mask.numBytes>0&&u.push(i.maskData),i.dimCount>1&&(null==(d=i.pixelData)?void 0:d.length)===i.width*i.height*i.dimCount){var p,m,w,y;i.pixelData=i.pixelData.slice(-i.width*i.height);const e=null==(p=i.dimStats)||null==(m=p.minValues)?void 0:m[i.dimCount-1],t=null==(w=i.dimStats)||null==(y=w.maxValues)?void 0:y[i.dimCount-1];null!=e&&null!=t&&(i.minValue=e,i.maxValue=t)}if(n++,o.addData({pixels:i.pixelData,statistics:{minValue:i.minValue,maxValue:i.maxValue}}),f-s>10){const t=String.fromCharCode.apply(null,new Uint8Array(e,s,10));s+=t.indexOf("Lerc")>-1?t.indexOf("Lerc"):0}}let g=0,C=0,A=0;if(u.length>1){for(A=o.width*o.height,r=new Uint8Array(A),r.set(u[0]),g=1;g<u.length;g++){const e=u[g];for(C=0;C<A;C++)r[C]=r[C]&e[C]}for(l=0,C=0;C<A;C++)l+=r[C];o.mask=r}return o.validPixelCount=l,o}function ne(e){const t=$(e),r=new v({width:t.width,height:t.height,pixels:t.pixels,pixelType:t.pixelType.toLowerCase(),mask:t.mask,statistics:null});return r.updateStatistics(),r}function ae(e){const t=b.decode(e),r=new v({width:t.width,height:t.height,pixels:t.pixels,pixelType:"U8",mask:t.mask,statistics:null});return r.updateStatistics(),r}function se(e,t){const r=new Uint8Array(e),i=new te(r),{width:o,height:n}=t,a=o*n,s=i.decode();let l,f=0,u=0;const c=new Uint8Array(a);for(f=0;f<a;f++)c[f]=s[4*f+3];const h=new v({width:o,height:n,pixels:[],pixelType:"U8",mask:c,statistics:[]});for(f=0;f<3;f++){for(l=new Uint8Array(a),u=0;u<a;u++)l[u]=s[4*u+f];h.addData({pixels:l})}return h.updateStatistics(),h}function le(e){if(null==e)throw new a("rasterCodec:decode","parameter encodeddata is required.");const t=new Uint8Array(e,0,10);let r="";return 255===t[0]&&216===t[1]?r="jpg":137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]?r="png":67===t[0]&&110===t[1]&&116===t[2]&&90===t[3]&&73===t[4]&&109===t[5]&&97===t[6]&&103===t[7]&&101===t[8]&&32===t[9]?r="lerc":76===t[0]&&101===t[1]&&114===t[2]&&99===t[3]&&50===t[4]&&32===t[5]?r="lerc2":73===t[0]&&73===t[1]&&42===t[2]&&0===t[3]||77===t[0]&&77===t[1]&&0===t[2]&&42===t[3]?r="tiff":71===t[0]&&73===t[1]&&70===t[2]?r="gif":66===t[0]&&77===t[1]?r="bmp":String.fromCharCode.apply(null,t).toLowerCase().indexOf("error")>-1&&(r="error"),r}function fe(e){let t=null,r=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":r=Math.pow(2,8)-1,t=Uint8Array;break;case"u16":r=r||Math.pow(2,16)-1,t=Uint16Array;break;case"u32":r=r||Math.pow(2,32)-1,t=Uint32Array;break;case"s8":r=r||0-Math.pow(2,7),t=Int8Array;break;case"s16":r=r||0-Math.pow(2,15),t=Int16Array;break;case"s32":r=r||0-Math.pow(2,31),t=Int32Array;break;default:t=Float32Array}return{pixelTypeCtor:t,noDataValue:r}}function ue(e){let t=le(e);return"lerc2"===t?t="lerc":"error"===t&&(t=""),t}async function ce(e,t,r){if(null==e)throw new a("rasterCodec:decode","missing encodeddata parameter.");if(null==t||null==t.width||null==t.height)throw new a("rasterCodec:decode","requires width and height in options parameter.");let i,o,n=t.format&&t.format.toLowerCase();return"tiff"===n&&t.customOptions?function(e,t){const r=function(e,t){const{headerInfo:r,ifd:i}=t,o=Y(e,r.littleEndian,i,t.offset||0,t.size||e.byteLength),{pixelType:n,isBSQ:a,planes:s}=r,l=F(n),f=o.length/s;let u;const c=[];for(let e=0;e<s;e++){if(u=new l(f),a)u=o.slice(f*e,f*(e+1));else for(let t=0;t<f;t++)u[t]=o[t*s+e];c.push(u)}const h=K(i,"TILEWIDTH"),d=K(i,"TILELENGTH"),p=r.noData?r.noData[0]:null,m=r.metadata?r.metadata.statistics:null,w=m?m.map((e=>e.min)):null,y=m?m.map((e=>e.max)):null;let g,C;if(null!=p)if(g=new Uint8Array(f),Math.abs(p)>1e24)for(C=0;C<f;C++)g[C]=Math.abs((c[0][C]-p)/p)<1e-6?0:1;else for(C=0;C<f;C++)g[C]=c[0][C]===p?0:1;else w&&y&&t.applyMinMaxConstraint&&(g=function(e,t,r){if(!(e&&e.length>0&&t&&r))return null;let i,o,n;const a=e[0].length,s=e.length,l=new Uint8Array(a);for(let f=0;f<s;f++)if(i=e[f],o=t[f],n=r[f],0===f)for(let e=0;e<a;e++)l[e]=i[e]<o||i[e]>n?0:1;else for(let e=0;e<a;e++)l[e]&&(l[e]=i[e]<o||i[e]>n?0:1);return l}(c,w,y));return{pixelType:n,width:h,height:d,pixels:c,mask:g,noDataValue:p}}(e,t.customOptions),i=new v({width:r.width,height:r.height,pixels:r.pixels,pixelType:r.pixelType.toLowerCase(),mask:r.mask,statistics:null});return i.updateStatistics(),i}(e,t):((!n||"bsq"!==n&&"bip"!==n)&&(n=le(e)),t.useCanvas&&re.has(n)?o=await async function(e,t,r,i){const o=new k,n={applyJpegMask:!1,format:t,...r},a=await o.decode(e,n,i),s=new v(a);return s.updateStatistics(),s}(e,n,t,r):(i=function(e){let t=null;switch(e){case"lerc":t=ie;break;case"lerc2":t=oe;break;case"jpg":t=ae;break;case"png":t=se;break;case"bsq":case"bip":t=(t,r)=>function(e,t,r){const{pixelTypeCtor:i}=fe(t.pixelType),o=(0,class{static decode(e,t){const r=t.pixelType,i=[],o=t.width*t.height,n=M(e,t),{bandIds:a,format:s}=t,l=a&&a.length||M(e,t),f=e.byteLength-e.byteLength%(o*E(r)),u=new r(e,0,o*n);let c,h,d,p,m;if("bip"===s)for(c=0;c<l;c++){for(p=new r(o),m=a?a[c]:c,h=0;h<o;h++)p[h]=u[h*n+m];i.push(p)}else if("bsq"===s)for(c=0;c<l;c++)m=a?a[c]:c,i.push(u.subarray(m*o,(m+1)*o));return f<e.byteLength-1&&(d=function(e,t){if(8*e.byteLength<t)return null;const r=new Uint8Array(e,0,Math.ceil(t/8)),i=new Uint8Array(t);let o=0,n=0,a=0,s=0;for(a=0;a<r.length-1;a++)for(n=r[a],s=7;s>=0;s--)i[o++]=n>>s&1;for(s=7;o<t-1;)n=r[r.length-1],i[o++]=n>>s&1,s--;return i}(e.slice(f),o)),{pixels:i,mask:d}}}.decode)(e,{width:t.width,height:t.height,pixelType:i,format:r}),n=new v({width:t.width,height:t.height,pixels:o.pixels,pixelType:t.pixelType,mask:o.mask,statistics:null});return n.updateStatistics(),n}(t,r,e);break;case"tiff":t=ne;break;case"error":t=()=>{throw new a("rasterCodec:decode","input data contains error")};break;default:t=()=>{throw new a("rasterCodec:decode","unsupported raster format")}}return t}(n),t.isPoint&&((t={...t}).width++,t.height++),o=i(e,t),t.isPoint&&function(e,t=1){if(!e)return;const{pixels:r,width:i,height:o,mask:n}=e;if(!r||0===r.length)return;const a=r.length,s=i-1,l=o-1,f=[];let u,c,h,d,p,m,w;const y=v.getPixelArrayConstructor(e.pixelType);if(0===t){for(u=0;u<a;u++){for(p=r[u],m=new y(s*l),c=0;c<l;c++)for(d=c*i,h=0;h<s;h++)m[c*s+h]=p[d+h];f.push(m)}if(n)for(w=new Uint8Array(s*l),c=0;c<l;c++)for(d=c*i,h=0;h<s;h++)w[c*s+h]=n[d+h]}else{for(u=0;u<a;u++){for(p=r[u],m=new y(s*l),c=0;c<l;c++)for(d=c*i,h=0;h<s;h++)m[c*s+h]=(p[d+h]+p[d+h+1]+p[d+i+h]+p[d+i+h+1])/4;f.push(m)}if(n)for(w=new Uint8Array(s*l),c=0;c<l;c++)for(d=c*i,h=0;h<s;h++)w[c*s+h]=Math.min.apply(null,[n[d+h],n[d+h+1],n[d+i+h],n[d+i+h+1]])}e.width=s,e.height=l,e.mask=w,e.pixels=f}(o)),o)}const he=function(e){return e&&"esri.layers.support.PixelBlock"===e.declaredClass&&e.pixels&&e.pixels.length>0};function de(e,t){if(!t||!he(e))return e;const r=e.pixels.length;return t&&t.some((e=>e>=r))||1===r&&1===t.length&&0===t[0]?e:r!==t.length||t.some(((e,t)=>e!==t))?new v({pixelType:e.pixelType,width:e.width,height:e.height,mask:e.mask,validPixelCount:e.validPixelCount,maskIsAlpha:e.maskIsAlpha,pixels:t.map((t=>e.pixels[t])),statistics:e.statistics&&t.map((t=>e.statistics[t]))}):e}function pe(e){if(!e)return;const t=e.colormap;if(!t||0===t.length)return;const r=t.sort(((e,t)=>e[0]-t[0]));let i=0;r[0][0]<0&&(i=r[0][0]);const o=Math.max(256,r[r.length-1][0]-i+1),n=new Uint8Array(4*o),a=[];let s,l=0,f=0;const u=5===r[0].length;if(o>65536)return r.forEach((e=>{a[e[0]-i]=u?e.slice(1):e.slice(1).concat([255])})),{indexed2DColormap:a,offset:i,alphaSpecified:u};if(e.fillUnspecified)for(s=r[f],l=s[0]-i;l<o;l++)n[4*l]=s[1],n[4*l+1]=s[2],n[4*l+2]=s[3],n[4*l+3]=u?s[4]:255,l===s[0]-i&&(s=f===r.length-1?s:r[++f]);else for(l=0;l<r.length;l++)s=r[l],f=4*(s[0]-i),n[f]=s[1],n[f+1]=s[2],n[f+2]=s[3],n[f+3]=u?s[4]:255;return{indexedColormap:n,offset:i,alphaSpecified:u}}function me(e,t){if(!he(e))return e;if(!t&&(t.indexedColormap||t.indexed2DColormap))return e;const r=e.clone(),i=r.pixels;let o=r.mask;const n=r.width*r.height;if(1!==i.length)return e;const{indexedColormap:a,indexed2DColormap:s,offset:l,alphaSpecified:f}=t,u=a.length-1;let c=0;const h=i[0],d=new Uint8Array(h.length),p=new Uint8Array(h.length),m=new Uint8Array(h.length);let w,y=0;if(a)if(o)for(c=0;c<n;c++)o[c]&&(y=4*(h[c]-l),y<l||y>u?o[c]=0:(d[c]=a[y],p[c]=a[y+1],m[c]=a[y+2],o[c]=a[y+3]));else{for(o=new Uint8Array(n),c=0;c<n;c++)y=4*(h[c]-l),y<l||y>u?o[c]=0:(d[c]=a[y],p[c]=a[y+1],m[c]=a[y+2],o[c]=a[y+3]);r.mask=o}else if(o)for(c=0;c<n;c++)o[c]&&(w=s[h[c]],d[c]=w[0],p[c]=w[1],m[c]=w[2],o[c]=w[3]);else{for(o=new Uint8Array(n),c=0;c<n;c++)w=s[h[c]],d[c]=w[0],p[c]=w[1],m[c]=w[2],o[c]=w[3];r.mask=o}return r.pixels=[d,p,m],r.statistics=null,r.pixelType="u8",r.maskIsAlpha=f,r}function we(e){if(!he(e))return null;e.statistics||e.updateStatistics();const{pixels:t,mask:r,pixelType:i,statistics:o}=e,n=e.width*e.height,a=t.length;let s,l,f,u,c;const h=[],d=[];let p,m,w,y,g,C,A,v,T,k;const S=256;for(u=0;u<a;u++){if(p=new Uint32Array(S),w=t[u],"u8"===i)if(s=-.5,l=255.5,r)for(c=0;c<n;c++)r[c]&&p[w[c]]++;else for(c=0;c<n;c++)p[w[c]]++;else{if(s=o[u].minValue,l=o[u].maxValue,f=(l-s)/S,m=new Uint32Array(257),r)for(c=0;c<n;c++)r[c]&&m[Math.floor((w[c]-s)/f)]++;else for(c=0;c<n;c++)m[Math.floor((w[c]-s)/f)]++;for(c=0;c<255;c++)p[c]=m[c];p[255]=m[255]+m[256]}for(h.push({min:s,max:l,size:S,counts:p}),y=0,g=0,v=0,c=0;c<S;c++)y+=p[c],g+=c*p[c];for(T=g/y,c=0;c<S;c++)v+=p[c]*Math.pow(c-T,2);k=Math.sqrt(v/(y-1)),f=(l-s)/S,C=(T+.5)*f+s,A=k*f,d.push({min:s,max:l,avg:C,stddev:A})}return{statistics:d,histograms:h}}function ye(e){const t=[];for(let r=0;r<e.length;r++){const{min:i,max:o,size:n,counts:a}=e[r];let s=0,l=0;for(let e=0;e<n;e++)s+=a[e],l+=e*a[e];const f=l/s;let u=0;for(let e=0;e<n;e++)u+=a[e]*Math.pow(e-f,2);const c=(o-i)/n,h=(f+.5)*c+i,d=Math.sqrt(u/(s-1))*c;t.push({min:i,max:o,avg:h,stddev:d})}return t}function ge(e){const{minCutOff:t,maxCutOff:r,gamma:i,pixelType:o}=e,n=e.outMin||0,a=e.outMax||255;if(-1===["u8","u16","s8","s16"].indexOf(o))return null;const s=t.length;let l,f,u=0;"s8"===o?u=-127:"s16"===o&&(u=-32767);let c=256;["u16","s16"].indexOf(o)>-1&&(c=65536);const h=[],d=[],p=a-n;for(l=0;l<s;l++)d[l]=r[l]-t[l],h[l]=p/(r[l]-t[l]);const m=i&&i.length>=s,w=[];if(m)for(l=0;l<s;l++)w[l]=i[l]>1?i[l]>2?6.5+Math.pow(i[l]-2,2.5):6.5+100*Math.pow(2-i[l],4):1;let y;const g=[];let C,A,v;if(m)for(l=0;l<s;l++){for(v=[],f=0;f<c;f++)C=f+u,y=(C-t[l])/d[l],A=1,i[l]>1&&(A-=Math.pow(1/p,y*w[l])),v[f]=C<r[l]&&C>t[l]?Math.floor(A*p*Math.pow(y,1/i[l]))+n:C>=r[l]?a:n;g[l]=v}else for(l=0;l<s;l++){for(v=[],f=0;f<c;f++)C=f+u,v[f]=C<=t[l]?n:C>=r[l]?a:Math.floor((C-t[l])/d[l]*p)+n;g[l]=v}if(null!=e.contrastOffset){const t=function(e,t){const r=Math.min(Math.max(e,-100),100),i=Math.min(Math.max(t,-100),100);let o,n;const a=new Uint8Array(256);for(o=0;o<256;o++)r>0&&r<100?n=(200*o-25500+510*i)/(2*(100-r))+128:r<=0&&r>-100?n=(200*o-25500+510*i)*(100+r)/2e4+128:100===r?(n=200*o-25500+256*(100-r)+510*i,n=n>0?255:0):-100===r&&(n=128),a[o]=n>255?255:n<0?0:n;return a}(e.contrastOffset,e.brightnessOffset);for(l=0;l<s;l++)for(v=g[l],f=0;f<c;f++)v[f]=t[v[f]]}return{lut:g,offset:u}}function Ce(e,t){if(!he(e))return null;const r=e.clone(),{pixels:i,mask:o}=r,{minCutOff:n,maxCutOff:a,gamma:s}=t,l=t.outMin||0,f=t.outMax||255,u=r.width*r.height,c=i.length;let h,d,p,m,w;const y=f-l,g=[],C=[];for(h=0;h<c;h++)C[h]=a[h]-n[h],g[h]=y/(a[h]-n[h]);const A=s&&s.length>=c,v=[];if(A)for(h=0;h<c;h++)v[h]=s[h]>1?s[h]>2?6.5+Math.pow(s[h]-2,2.5):6.5+100*Math.pow(2-s[h],4):1;if(A)if(null!=o){for(d=0;d<u;d++)if(o[d])for(h=0;h<c;h++)p=i[h][d],w=(p-n[h])/C[h],m=1,s[h]>1&&(m-=Math.pow(1/y,w*v[h])),i[h][d]=p<a[h]&&p>n[h]?Math.floor(m*y*Math.pow(w,1/s[h]))+l:p>=a[h]?f:l}else for(d=0;d<u;d++)for(h=0;h<c;h++)p=i[h][d],w=(p-n[h])/C[h],m=1,s[h]>1&&(m-=Math.pow(1/y,w*v[h])),i[h][d]=p<a[h]&&p>n[h]?Math.floor(m*y*Math.pow(w,1/s[h]))+l:p>=a[h]?f:l;else if(null!=o){for(d=0;d<u;d++)if(o[d])for(h=0;h<c;h++)p=i[h][d],i[h][d]=p<a[h]&&p>n[h]?Math.floor((p-n[h])/C[h]*y)+l:p>=a[h]?f:l}else for(d=0;d<u;d++)for(h=0;h<c;h++)p=i[h][d],i[h][d]=p<a[h]&&p>n[h]?Math.floor((p-n[h])/C[h]*y)+l:p>=a[h]?f:l;return r.pixelType="u8",r.updateStatistics(),r}function Ae(e,t){if(!he(e))return null;const{pixels:r,mask:i}=e,o=e.width*e.height,n=r.length;let a=t.lut;const{offset:s}=t;let l,f;a&&1===a[0].length&&(a=r.map((()=>a)));const u=[];let c,h,d;if(s)if(null==i)for(l=0;l<n;l++){for(c=r[l],h=a[l],d=new Uint8Array(o),f=0;f<o;f++)d[f]=h[c[f]-s];u.push(d)}else for(l=0;l<n;l++){for(c=r[l],h=a[l],d=new Uint8Array(o),f=0;f<o;f++)i[f]&&(d[f]=h[c[f]-s]);u.push(d)}else if(null==i)for(l=0;l<n;l++){for(c=r[l],h=a[l],d=new Uint8Array(o),f=0;f<o;f++)d[f]=h[c[f]];u.push(d)}else for(l=0;l<n;l++){for(c=r[l],h=a[l],d=new Uint8Array(o),f=0;f<o;f++)i[f]&&(d[f]=h[c[f]]);u.push(d)}const p=new v({width:e.width,height:e.height,pixels:u,mask:i,pixelType:"u8"});return p.updateStatistics(),p}function ve(e,t,r,i,o,n,a,s){return{xmin:o<=r*e?0:o<r*e+e?o-r*e:e,ymin:n<=i*t?0:n<i*t+t?n-i*t:t,xmax:o+a<=r*e?0:o+a<r*e+e?o+a-r*e:e,ymax:n+s<=i*t?0:n+s<i*t+t?n+s-i*t:t}}function Te(e,t,r,i){const o=e.filter((e=>he(e)))[0];if(null==o)return null;const n=i?i.width:t.width,a=i?i.height:t.height,s=o.width,l=o.height,f=t.width/s,u=t.height/l,c=r?r.x:0,h=r?r.y:0,d=o.pixelType,p=v.getPixelArrayConstructor(d),m=o.pixels.length,w=[];let y,g,C,A,T,k,S,b,M,E,G,D,x;for(k=0;k<m;k++){for(g=new p(n*a),S=0;S<u;S++)for(b=0;b<f;b++)if(C=e[S*f+b],C)for(y=C.pixels[k],G=ve(s,l,b,S,c,h,n,a),M=G.ymin;M<G.ymax;M++)for(A=(S*l+M-h)*n+(b*s-c),T=M*s,E=G.xmin;E<G.xmax;E++)g[A+E]=y[T+E];w.push(g)}if(e.some((e=>null==e||e.mask&&e.mask.length>0)))for(D=new Uint8Array(n*a),S=0;S<u;S++)for(b=0;b<f;b++)if(C=e[S*f+b],x=C?C.mask:null,G=ve(s,l,b,S,c,h,n,a),x)for(M=G.ymin;M<G.ymax;M++)for(A=(S*l+M-h)*n+(b*s-c),T=M*s,E=G.xmin;E<G.xmax;E++)D[A+E]=x[T+E];else if(C)for(M=G.ymin;M<G.ymax;M++)for(A=(S*l+M-h)*n+(b*s-c),T=M*s,E=G.xmin;E<G.xmax;E++)D[A+E]=1;else for(M=G.ymin;M<G.ymax;M++)for(A=(S*l+M-h)*n+(b*s-c),T=M*s,E=G.xmin;E<G.xmax;E++)D[A+E]=0;const I=new v({width:n,height:a,pixels:w,pixelType:d,mask:D});return I.updateStatistics(),I}function ke(e,t,r){if(!he(e))return null;const{width:i,height:o}=e,n=t.x,a=t.y,s=r.width+n,l=r.height+a;if(n<0||a<0||s>i||l>o)return e;if(0===n&&0===a&&s===i&&l===o)return e;e.mask||(e.mask=new Uint8Array(i*o));const f=e.mask;for(let e=0;e<o;e++){const t=e*i;for(let r=0;r<i;r++)f[t+r]=e<a||e>=l||r<n||r>=s?0:1}return e.updateStatistics(),e}function Se(e){if(0===e.size)return 0;let t=0,r=-1,i=0;const o=e.keys();let n=o.next();for(;!n.done;)i=e.get(n.value),i>t&&(r=n.value,t=i),n=o.next();return r}function be(e,t,r){if(0===r)return;const i=e.get(t);1===i?e.delete(t):e.set(t,i-1)}function Me(e,t,r){0!==r&&e.set(t,e.has(t)?e.get(t)+1:1)}function Ee(e,t,r){let{x:i,y:o}=t;const{width:n,height:a}=r;if(0===i&&0===o&&a===e.height&&n===e.width)return e;const{width:s,height:l}=e,f=Math.max(0,o),u=Math.max(0,i),c=Math.min(i+n,s),h=Math.min(o+a,l);if(c<0||h<0||!he(e))return null;i=Math.max(0,-i),o=Math.max(0,-o);const{pixels:d,mask:p}=e,m=n*a,w=d.length,y=[];for(let t=0;t<w;t++){const r=d[t],a=v.createEmptyBand(e.pixelType,m);for(let e=f;e<h;e++){const t=e*s;let l=(e+o-f)*n+i;for(let e=u;e<c;e++)a[l++]=r[t+e]}y.push(a)}const g=new Uint8Array(m);for(let e=f;e<h;e++){const t=e*s;let r=(e+o-f)*n+i;for(let e=u;e<c;e++)g[r++]=p?p[t+e]:1}const C=new v({width:r.width,height:r.height,pixelType:e.pixelType,pixels:y,mask:g});return C.updateStatistics(),C}function Ge(e,t=!0){if(!he(e))return null;const{pixels:r,width:i,height:o,mask:n,pixelType:a}=e,s=[],l=Math.round(i/2),f=Math.round(o/2),u=o-1,c=i-1;for(let e=0;e<r.length;e++){const n=r[e],h=v.createEmptyBand(a,l*f);let d=0;for(let e=0;e<o;e+=2)for(let r=0;r<i;r+=2){const o=n[e*i+r];if(t){const t=r===c?o:n[e*i+r+1],a=e===u?o:n[e*i+r+i];h[d++]=(o+t+a+(r===c?a:e===u?t:n[e*i+r+i+1]))/4}else h[d++]=o}s.push(h)}let h=null;if(n){h=new Uint8Array(l*f);let e=0;for(let r=0;r<o;r+=2)for(let o=0;o<i;o+=2){const a=n[r*i+o];if(t){const t=o===c?a:n[r*i+o+1],s=r===u?a:n[r*i+o+i];h[e++]=a*t*s*(o===c?s:r===u?t:n[r*i+o+i+1])?1:0}else h[e++]=a}}return new v({width:l,height:f,pixelType:a,pixels:s,mask:h})}function De(e,t,r){if(!he(e))return null;const{width:i,height:o}=t;let{width:n,height:a}=e;const s=new Map,l={x:0,y:0},f=null==r?1:1+r;let u=e;for(let e=0;e<f;e++){const r=Math.ceil(n/i),c=Math.ceil(a/o);for(let n=0;n<c;n++){l.y=n*o;for(let o=0;o<r;o++){l.x=o*i;const r=Ee(u,l,t);s.set(`${e}/${n}/${o}`,r)}}e<f-1&&(u=Ge(u)),n=Math.round(n/2),a=Math.round(a/2)}return s}function xe(e,t,r,i,o="nearest"){if(!he(e))return null;"majority"===o&&(e=function(e){if(!he(e))return null;const t=e.clone(),{width:r,height:i,pixels:o,mask:n}=e,a=o[0],s=t.pixels[0];for(let e=2;e<i-1;e++){const t=new Map;for(let i=e-2;i<e+2;i++)for(let e=0;e<4;e++){const o=i*r+e;Me(t,a[o],n?n[o]:1)}s[e*r]=Se(t),s[e*r+1]=s[e*r+2]=s[e*r];let i=3;for(;i<r-1;i++){let o=(e-2)*r+i+1;Me(t,a[o],n?n[o]:1),o=(e-1)*r+i+1,Me(t,a[o],n?n[o]:1),o=e*r+i+1,Me(t,a[o],n?n[o]:1),o=(e+1)*r+i+1,Me(t,a[o],n?n[o]:1),o=(e-2)*r+i-3,be(t,a[o],n?n[o]:1),o=(e-1)*r+i-3,be(t,a[o],n?n[o]:1),o=e*r+i-3,be(t,a[o],n?n[o]:1),o=(e+1)*r+i-3,be(t,a[o],n?n[o]:1),s[e*r+i]=Se(t)}s[e*r+i+1]=s[e*r+i]}for(let e=0;e<r;e++)s[e]=s[r+e]=s[2*r+e],s[(i-1)*r+e]=s[(i-2)*r+e];return t.updateStatistics(),t}(e));const{pixels:n,mask:a,pixelType:s}=e,l=e.width,f=e.height,u=v.getPixelArrayConstructor(s),c=n.length,{width:h,height:d}=t,p=i.cols,m=i.rows,w=Math.ceil(h/p),y=Math.ceil(d/m);let g,C,A,T,k,S,b,M=!1;for(let e=0;e<r.length;e+=3)-1===r[e]&&-1===r[e+1]&&-1===r[e+2]&&(M=!0);const E=new Float32Array(h*d),G=new Float32Array(h*d);let D,x,I=0;const R="majority"===o?0:.5;for(let e=0;e<y;e++)for(let t=0;t<w;t++){g=12*(e*w+t),C=r[g],A=r[g+1],T=r[g+2],k=r[g+3],S=r[g+4],b=r[g+5];for(let r=0;r<m;r++){I=(e*m+r)*h+t*p,x=(r+.5)/m;for(let e=0;e<r;e++)D=(e+.5)/p,E[I+e]=Math.round((C*D+A*x+T)*l-R),G[I+e]=Math.round((k*D+S*x+b)*f-R)}g+=6,C=r[g],A=r[g+1],T=r[g+2],k=r[g+3],S=r[g+4],b=r[g+5];for(let r=0;r<m;r++){I=(e*m+r)*h+t*p,x=(r+.5)/m;for(let e=r;e<p;e++)D=(e+.5)/p,E[I+e]=Math.round((C*D+A*x+T)*l-R),G[I+e]=Math.round((k*D+S*x+b)*f-R)}}const P=(e,t)=>{for(let r=0;r<d;r++){g=r*h;for(let r=0;r<h;r++)e[g]=E[g]<0||G[g]<0?0:t[E[g]+G[g]*l],g++}},U=[];let B;for(let e=0;e<c;e++)B=new u(h*d),P(B,n[e]),U.push(B);const O=new v({width:h,height:d,pixelType:s,pixels:U});if(a)O.mask=new Uint8Array(h*d),P(O.mask,a);else if(M){O.mask=new Uint8Array(h*d);for(let e=0;e<h*d;e++)O.mask[e]=E[e]<0||G[e]<0?0:1}return O.updateStatistics(),O}function Ie(e){return"h"in e&&"s"in e&&"v"in e}function Re(e){return"l"in e&&"a"in e&&"b"in e}const Pe=[[.4124,.3576,.1805],[.2126,.7152,.0722],[.0193,.1192,.9505]],Ue=[[3.2406,-1.5372,-.4986],[-.9689,1.8758,.0415],[.0557,-.204,1.057]];function Be(e,t){const r=[];let i,o;if(e[0].length!==t.length)throw"dimensions do not match";const n=e.length,a=e[0].length;let s=0;for(i=0;i<n;i++){for(s=0,o=0;o<a;o++)s+=e[i][o]*t[o];r.push(s)}return r}function Oe(e){const t=Be(Ue,[e.x/100,e.y/100,e.z/100]).map((e=>{const t=e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055;return Math.min(1,Math.max(t,0))}));return{r:Math.round(255*t[0]),g:Math.round(255*t[1]),b:Math.round(255*t[2])}}function Le(e){const t=e.l,r=[(t+16)/116+e.a/500,(t+16)/116,(t+16)/116-e.b/200].map((e=>e>6/29?Math.pow(e,3):3*Math.pow(6/29,2)*(e-4/29)));return{x:95.047*r[0],y:100*r[1],z:108.883*r[2]}}function _e(e){return function(e){return"r"in e&&"g"in e&&"b"in e}(e)?e:function(e){return"l"in e&&"c"in e&&"h"in e}(e)?function(e){return Oe(Le(function(e){const t=e.c,r=e.h;return{l:e.l,a:t*Math.cos(r),b:t*Math.sin(r)}}(e)))}(e):Re(e)?function(e){return Oe(Le(e))}(e):function(e){return"x"in e&&"y"in e&&"z"in e}(e)?Oe(e):Ie(e)?function(e){const t=(e.h+360)%360/60,r=e.v/100*255,i=r*(e.s/100),o=i*(1-Math.abs(t%2-1));let n;switch(Math.floor(t)){case 0:n={r:i,g:o,b:0};break;case 1:n={r:o,g:i,b:0};break;case 2:n={r:0,g:i,b:o};break;case 3:n={r:0,g:o,b:i};break;case 4:n={r:o,g:0,b:i};break;case 5:case 6:n={r:i,g:0,b:o};break;default:n={r:0,g:0,b:0}}return n.r=Math.round(n.r+r-i),n.g=Math.round(n.g+r-i),n.b=Math.round(n.b+r-i),n}(e):e}function Ne(e){return Ie(e)?e:function(e){const t=e.r,r=e.g,i=e.b,o=Math.max(t,r,i),n=o-Math.min(t,r,i);let a=o,s=0===n?0:o===t?(r-i)/n%6:o===r?(i-t)/n+2:(t-r)/n+4,l=0===n?0:n/a;return s<0&&(s+=6),s*=60,l*=100,a*=100/255,{h:s,s:l,v:a}}(_e(e))}function Fe(e){return Re(e)?e:function(e){return function(e){const t=[e.x/95.047,e.y/100,e.z/108.883].map((e=>e>Math.pow(6/29,3)?Math.pow(e,1/3):1/3*Math.pow(29/6,2)*e+4/29));return{l:116*t[1]-16,a:500*(t[0]-t[1]),b:200*(t[1]-t[2])}}(function(e){const t=[e.r/255,e.g/255,e.b/255].map((e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4))),r=Be(Pe,t);return{x:100*r[0],y:100*r[1],z:100*r[2]}}(e))}(_e(e))}const Ve=[{id:"aspect_predefined",type:"multipart",colorRamps:[{fromColor:[190,190,190],toColor:[255,45,8]},{fromColor:[255,45,8],toColor:[255,181,61]},{fromColor:[255,181,61],toColor:[255,254,52]},{fromColor:[255,254,52],toColor:[0,251,50]},{fromColor:[0,251,50],toColor:[255,254,52]},{fromColor:[0,253,255],toColor:[0,181,255]},{fromColor:[0,181,255],toColor:[26,35,253]},{fromColor:[26,35,253],toColor:[255,57,251]},{fromColor:[255,57,251],toColor:[255,45,8]}]},{id:"blackToWhite_predefined",fromColor:[0,0,0],toColor:[255,255,255]},{id:"blueBright_predefined",fromColor:[204,204,255],toColor:[0,0,224]},{id:"blueLightToDark_predefined",fromColor:[211,229,232],toColor:[46,100,140]},{id:"blueGreenBright_predefined",fromColor:[203,245,234],toColor:[48,207,146]},{id:"blueGreenLightToDark_predefined",fromColor:[216,242,237],toColor:[21,79,74]},{id:"brownLightToDark_predefined",fromColor:[240,236,170],toColor:[102,72,48]},{id:"brownToBlueGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[156,85,31],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[33,130,145]}]},{id:"brownToBlueGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[110,70,45],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[48,100,102]}]},{id:"coefficientBias_predefined",fromColor:[214,214,255],toColor:[0,57,148]},{id:"coldToHotDiverging_predefined",type:"multipart",colorRamps:[{fromColor:[69,117,181],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[214,47,39]}]},{id:"conditionNumber_predefined",type:"multipart",colorRamps:[{fromColor:[0,97,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,34,0]}]},{id:"cyanToPurple_predefined",type:"multipart",colorRamps:[{fromColor:[0,245,245],toColor:[0,0,245]},{fromColor:[0,0,245],toColor:[245,0,245]}]},{id:"cyanLightToBlueDark_predefined",type:"multipart",colorRamps:[{fromColor:[182,237,240],toColor:[31,131,224]},{fromColor:[31,131,224],toColor:[9,9,145]}]},{id:"distance_predefined",fromColor:[255,200,0],toColor:[0,0,255]},{id:"elevation1_predefined",type:"multipart",colorRamps:[{fromColor:[175,240,233],toColor:[255,255,179]},{fromColor:[255,255,179],toColor:[0,128,64]},{fromColor:[0,128,64],toColor:[252,186,3]},{fromColor:[252,186,3],toColor:[128,0,0]},{fromColor:[120,0,0],toColor:[105,48,13]},{fromColor:[105,48,13],toColor:[171,171,171]},{fromColor:[171,171,171],toColor:[255,252,255]}]},{id:"elevation2_predefined",type:"multipart",colorRamps:[{fromColor:[118,219,211],toColor:[255,255,199]},{fromColor:[255,255,199],toColor:[255,255,128]},{fromColor:[255,255,128],toColor:[217,194,121]},{fromColor:[217,194,121],toColor:[135,96,38]},{fromColor:[135,96,38],toColor:[150,150,181]},{fromColor:[150,150,181],toColor:[181,150,181]},{fromColor:[181,150,181],toColor:[255,252,255]}]},{id:"errors_predefined",fromColor:[255,235,214],toColor:[196,10,10]},{id:"grayLightToDark_predefined",fromColor:[219,219,219],toColor:[69,69,69]},{id:"greenBright_predefined",fromColor:[204,255,204],toColor:[14,204,14]},{id:"greenLightToDark_predefined",fromColor:[220,245,233],toColor:[34,102,51]},{id:"greenToBlue_predefined",type:"multipart",colorRamps:[{fromColor:[32,204,16],toColor:[0,242,242]},{fromColor:[0,242,242],toColor:[2,33,227]}]},{id:"orangeBright_predefined",fromColor:[255,235,204],toColor:[240,118,5]},{id:"orangeLightToDark_predefined",fromColor:[250,233,212],toColor:[171,65,36]},{id:"partialSpectrum_predefined",type:"multipart",colorRamps:[{fromColor:[242,241,162],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]},{fromColor:[252,3,69],toColor:[176,7,237]},{fromColor:[176,7,237],toColor:[2,29,173]}]},{id:"partialSpectrum1Diverging_predefined",type:"multipart",colorRamps:[{fromColor:[135,38,38],toColor:[240,149,12]},{fromColor:[240,149,12],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[74,80,181]},{fromColor:[74,80,181],toColor:[39,32,122]}]},{id:"partialSpectrum2Diverging_predefined",type:"multipart",colorRamps:[{fromColor:[115,77,42],toColor:[201,137,52]},{fromColor:[201,137,52],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[91,63,176]},{fromColor:[91,63,176],toColor:[81,13,97]}]},{id:"pinkToYellowGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[158,30,113],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[99,110,45]}]},{id:"pinkToYellowGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[97,47,73],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[22,59,15]}]},{id:"precipitation_predefined",type:"multipart",colorRamps:[{fromColor:[194,82,60],toColor:[237,161,19]},{fromColor:[237,161,19],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,219,0]},{fromColor:[0,219,0],toColor:[32,153,143]},{fromColor:[32,153,143],toColor:[11,44,122]}]},{id:"prediction_predefined",type:"multipart",colorRamps:[{fromColor:[40,146,199],toColor:[250,250,100]},{fromColor:[250,250,100],toColor:[232,16,20]}]},{id:"purpleBright_predefined",fromColor:[255,204,255],toColor:[199,0,199]},{id:"purpleToGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[77,32,150],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[20,122,11]}]},{id:"purpleToGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[67,14,89],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[24,79,15]}]},{id:"purpleBlueBright_predefined",fromColor:[223,184,230],toColor:[112,12,242]},{id:"purpleBlueLightToDark_predefined",fromColor:[229,213,242],toColor:[93,44,112]},{id:"purpleRedBright_predefined",fromColor:[255,204,225],toColor:[199,0,99]},{id:"purpleRedLightToDark_predefined",fromColor:[250,215,246],toColor:[143,17,57]},{id:"redBright_predefined",fromColor:[255,204,204],toColor:[219,0,0]},{id:"redLightToDark_predefined",fromColor:[255,224,224],toColor:[143,10,10]},{id:"redToBlueDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[196,69,57],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[48,95,207]}]},{id:"redToBlueDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[107,13,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[13,53,97]}]},{id:"redToGreen_predefined",type:"multipart",colorRamps:[{fromColor:[245,0,0],toColor:[245,245,0]},{fromColor:[245,245,0],toColor:[0,245,0]}]},{id:"redToGreenDivergingBright_predefined",type:"multipart",colorRamps:[{fromColor:[186,20,20],toColor:[255,255,191]},{fromColor:[255,255,191],toColor:[54,145,33]}]},{id:"redToGreenDivergingDark_predefined",type:"multipart",colorRamps:[{fromColor:[97,21,13],toColor:[204,204,102]},{fromColor:[204,204,102],toColor:[16,69,16]}]},{id:"slope_predefined",type:"multipart",colorRamps:[{fromColor:[56,168,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,0,0]}]},{id:"spectrumFullBright_predefined",type:"multipart",colorRamps:[{fromColor:[255,0,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,0,255]}]},{id:"spectrumFullDark_predefined",type:"multipart",colorRamps:[{fromColor:[153,0,0],toColor:[153,153,0]},{fromColor:[153,153,0],toColor:[0,153,153]},{fromColor:[0,153,153],toColor:[0,0,153]}]},{id:"spectrumFullLight_predefined",type:"multipart",colorRamps:[{fromColor:[255,153,153],toColor:[255,255,153]},{fromColor:[255,255,153],toColor:[153,255,255]},{fromColor:[153,255,255],toColor:[153,153,255]}]},{id:"surface_predefined",type:"multipart",colorRamps:[{fromColor:[112,153,89],toColor:[242,238,162]},{fromColor:[242,238,162],toColor:[242,206,133]},{fromColor:[242,206,133],toColor:[194,140,124]},{fromColor:[194,140,124],toColor:[255,242,255]}]},{id:"temperature_predefined",type:"multipart",colorRamps:[{fromColor:[255,252,255],toColor:[255,0,255]},{fromColor:[255,0,255],toColor:[0,0,255]},{fromColor:[0,0,255],toColor:[0,255,255]},{fromColor:[0,255,255],toColor:[0,255,0]},{fromColor:[0,255,0],toColor:[255,255,0]},{fromColor:[255,255,0],toColor:[255,128,0]},{fromColor:[255,128,0],toColor:[128,0,0]}]},{id:"whiteToBlack_predefined",fromColor:[255,255,255],toColor:[0,0,0]},{id:"yellowToDarkRed_predefined",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[242,167,46]},{fromColor:[242,167,46],toColor:[107,0,0]}]},{id:"yellowToGreenToDarkBlue_predefined",type:"multipart",colorRamps:[{fromColor:[255,255,128],toColor:[56,224,9]},{fromColor:[56,224,9],toColor:[26,147,171]},{fromColor:[26,147,171],toColor:[12,16,120]}]},{id:"yellowToRed_predefined",fromColor:[245,245,0],toColor:[255,0,0]},{id:"yellowGreenBright_predefined",fromColor:[236,252,204],toColor:[157,204,16]},{id:"yellowGreenLightToDark_predefined",fromColor:[215,240,175],toColor:[96,107,45]}],je={aspect_predefined:"Aspect",blackToWhite_predefined:"Black to White",blueBright_predefined:"Blue Bright",blueLightToDark_predefined:"Blue Light to Dark",blueGreenBright_predefined:"Blue-Green Bright",blueGreenLightToDark_predefined:"Blue-Green Light to Dark",brownLightToDark_predefined:"Brown Light to Dark",brownToBlueGreenDivergingBright_predefined:"Brown to Blue Green Diverging, Bright",brownToBlueGreenDivergingDark_predefined:"Brown to Blue Green Diverging, Dark",coefficientBias_predefined:"Coefficient Bias",coldToHotDiverging_predefined:"Cold to Hot Diverging",conditionNumber_predefined:"Condition Number",cyanToPurple_predefined:"Cyan to Purple",cyanLightToBlueDark_predefined:"Cyan-Light to Blue-Dark",distance_predefined:"Distance",elevation1_predefined:"Elevation #1",elevation2_predefined:"Elevation #2",errors_predefined:"Errors",grayLightToDark_predefined:"Gray Light to Dark",greenBright_predefined:"Green Bright",greenLightToDark_predefined:"Green Light to Dark",greenToBlue_predefined:"Green to Blue",orangeBright_predefined:"Orange Bright",orangeLightToDark_predefined:"Orange Light to Dark",partialSpectrum_predefined:"Partial Spectrum",partialSpectrum1Diverging_predefined:"Partial Spectrum 1 Diverging",partialSpectrum2Diverging_predefined:"Partial Spectrum 2 Diverging",pinkToYellowGreenDivergingBright_predefined:"Pink to YellowGreen Diverging, Bright",pinkToYellowGreenDivergingDark_predefined:"Pink to YellowGreen Diverging, Dark",precipitation_predefined:"Precipitation",prediction_predefined:"Prediction",purpleBright_predefined:"Purple Bright",purpleToGreenDivergingBright_predefined:"Purple to Green Diverging, Bright",purpleToGreenDivergingDark_predefined:"Purple to Green Diverging, Dark",purpleBlueBright_predefined:"Purple-Blue Bright",purpleBlueLightToDark_predefined:"Purple-Blue Light to Dark",purpleRedBright_predefined:"Purple-Red Bright",purpleRedLightToDark_predefined:"Purple-Red Light to Dark",redBright_predefined:"Red Bright",redLightToDark_predefined:"Red Light to Dark",redToBlueDivergingBright_predefined:"Red to Blue Diverging, Bright",redToBlueDivergingDark_predefined:"Red to Blue Diverging, Dark",redToGreen_predefined:"Red to Green",redToGreenDivergingBright_predefined:"Red to Green Diverging, Bright",redToGreenDivergingDark_predefined:"Red to Green Diverging, Dark",slope_predefined:"Slope",spectrumFullBright_predefined:"Spectrum-Full Bright",spectrumFullDark_predefined:"Spectrum-Full Dark",spectrumFullLight_predefined:"Spectrum-Full Light",surface_predefined:"Surface",temperature_predefined:"Temperature",whiteToBlack_predefined:"White to Black",yellowToDarkRed_predefined:"Yellow to Dark Red",yellowToGreenToDarkBlue_predefined:"Yellow to Green to Dark Blue",yellowToRed_predefined:"Yellow to Red",yellowGreenBright_predefined:"Yellow-Green Bright",yellowGreenLightToDark_predefined:"Yellow-Green Light to Dark"};function Ke(e,t){if(!e||!t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]>t[r]+2||e[r]<t[r]-2)return!1;return!0}function He(e,t,r){const i=Fe(e),o=Fe(t);return _e({l:i.l*(1-r)+r*o.l,a:i.a*(1-r)+r*o.a,b:i.b*(1-r)+r*o.b})}function Ye(e){const t=function(e){if(!e)return;const t=Ve;let r,i=null;return"algorithmic"===e.type?t.some((t=>{if(Ke(e.fromColor.toRgb(),t.fromColor)&&Ke(e.toColor.toRgb(),t.toColor))return i=t.id,!0})):"multipart"===e.type&&t.some((t=>{if(e.colorRamps&&t.colorRamps&&e.colorRamps.length===t.colorRamps.length&&(r=e.colorRamps,!t.colorRamps.some(((e,t)=>{if(!Ke(r[t].fromColor.toRgb(),new h(e.fromColor).toRgb())||!Ke(r[t].toColor.toRgb(),new h(e.toColor).toRgb()))return!0})))){if(i)return!0;i=t.id}})),i}(e);return t?je[t]:null}function ze(e,t,r=!1){if(!e||!t||t<2)return;const i="toJSON"in e?e.toJSON():e,o="multipart"===i.type?i.colorRamps.length:1,n=[],a=[];let s,l,f,u,c,h=0;for(let e=0;e<o;e++)n[e]={start:null,end:null},n[e].start=h,n[e].end=h+1/o,h=n[e].end;for(let e=0;e<t;e++)u=e/(t-1),n.forEach(((n,h)=>{if(u>=n.start&&(u<n.end||e===t-1&&h===o-1)){c=(u-n.start)/(n.end-n.start),"multipart"===i.type?(s=i.colorRamps[h].fromColor,l=i.colorRamps[h].toColor):(s=i.fromColor,l=i.toColor),0===e?a.push([e].concat(s.slice(0,3))):e===t-1?a.push([e].concat(l.slice(0,3))):(f=He({r:s[0],g:s[1],b:s[2]},{r:l[0],g:l[1],b:l[2]},c),a.push([e,f.r,f.g,f.b]));const o=null!=s[3]?s[3]>1?s[3]/255:s[3]:1,d=null!=l[3]?l[3]>1?l[3]/255:l[3]:1;r&&a[e].push(Math.min(255,Math.round(255*(o*(1-c)+d*c))))}}));return a}let Je=class extends n{constructor(e){super(e),this.attributeTable=null,this.bandCount=null,this.colormap=null,this.extent=null,this.format=void 0,this.height=null,this.width=null,this.histograms=null,this.keyProperties={},this.multidimensionalInfo=null,this.noDataValue=null,this.pixelSize=null,this.pixelType=null,this.isPseudoSpatialReference=!1,this.spatialReference=null,this.statistics=null,this.storageInfo=null,this.transform=null}get dataType(){const e=this.keyProperties&&this.keyProperties.DataType;return e?e.toLowerCase():"generic"}get nativeExtent(){return this._get("nativeExtent")||this.extent}set nativeExtent(e){e&&this._set("nativeExtent",e)}get nativePixelSize(){const e=this.nativeExtent;return{x:e.width/this.width,y:e.height/this.height}}};t([r({json:{write:!0}})],Je.prototype,"attributeTable",void 0),t([r({json:{write:!0}})],Je.prototype,"bandCount",void 0),t([r({json:{write:!0}})],Je.prototype,"colormap",void 0),t([r({type:String,readOnly:!0})],Je.prototype,"dataType",null),t([r({type:d,json:{write:!0}})],Je.prototype,"extent",void 0),t([r({type:d,dependsOn:["extent"],json:{write:!0}})],Je.prototype,"nativeExtent",null),t([r({dependsOn:["nativeExtent"],json:{write:!0}})],Je.prototype,"nativePixelSize",null),t([r({json:{write:!0}})],Je.prototype,"format",void 0),t([r({json:{write:!0}})],Je.prototype,"height",void 0),t([r({json:{write:!0}})],Je.prototype,"width",void 0),t([r({json:{write:!0}})],Je.prototype,"histograms",void 0),t([r({json:{write:!0}})],Je.prototype,"keyProperties",void 0),t([r({json:{write:!0}})],Je.prototype,"multidimensionalInfo",void 0),t([r()],Je.prototype,"noDataValue",void 0),t([r({json:{write:!0}})],Je.prototype,"pixelSize",void 0),t([r({json:{write:!0}})],Je.prototype,"pixelType",void 0),t([r()],Je.prototype,"isPseudoSpatialReference",void 0),t([r({json:{write:!0}})],Je.prototype,"spatialReference",void 0),t([r({json:{write:!0}})],Je.prototype,"statistics",void 0),t([r({json:{write:!0}})],Je.prototype,"storageInfo",void 0),t([r({json:{write:!0}})],Je.prototype,"transform",void 0),Je=t([o("esri.layers.support.RasterInfo")],Je);var We=Je;const Xe=function(e){return e&&"esri.layers.support.PixelBlock"===e.declaredClass&&e.pixels&&e.pixels.length>0};function qe(e){let{altitude:t,azimuth:r}=e;const{hillshadeType:i,pixelSizePower:o,pixelSizeFactor:n,scalingType:a,isGCS:s,resolution:l}=e,f="multi-directional"===i?2*e.zFactor:e.zFactor,{x:u,y:c}=l;let h=f/(8*u),d=f/(8*c);if(s&&f>.001&&(h/=111e3,d/=111e3),"adjusted"===a)if(s){const e=111e3*u,t=111e3*c;h=(f+Math.pow(e,o)*n)/(8*e),d=(f+Math.pow(t,o)*n)/(8*t)}else h=(f+Math.pow(u,o)*n)/(8*u),d=(f+Math.pow(c,o)*n)/(8*c);let p=(90-t)*Math.PI/180,m=Math.cos(p),w=(360-r+90)*Math.PI/180,y=Math.sin(p)*Math.cos(w),g=Math.sin(p)*Math.sin(w);const C=[315,270,225,360,180,0],A=[60,60,60,60,60,90],v=new Float32Array([3,5,3,2,1,4]),T=v.reduce(((e,t)=>e+t)),k=v.map((e=>e/T)),S="multi-directional"===i?C.length:1,b=new Float32Array(6),M=new Float32Array(6),E=new Float32Array(6);if("multi-directional"===i)for(let e=0;e<S;e++)t=A[e],r=C[e],p=(90-t)*Math.PI/180,m=Math.cos(p),w=(360-r+90)*Math.PI/180,y=Math.sin(p)*Math.cos(w),g=Math.sin(p)*Math.sin(w),b[e]=m,M[e]=y,E[e]=g;else b.fill(m),M.fill(y),E.fill(g);return{resolution:l,factor:[h,d],sinZcosA:y,sinZsinA:g,cosZ:m,sinZcosAs:M,sinZsinAs:E,cosZs:b,weights:k,hillshadeType:["traditional","multi-directional"].indexOf(i)}}const Ze=e.getLogger("esri.renderers.support.RasterSymbolizer"),Qe={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767],u32:[0,4294967295],s32:[-2147483648,2147483647],f32:[-34e38,34e38],f64:[-Number.MAX_VALUE,Number.MAX_VALUE]};let $e=class extends n{constructor(e){super(e)}bind(){const{rendererJSON:e}=this;if(!e)return!1;let t;switch(this.lookup={rendererJSON:{}},e.type){case"uniqueValue":t=this._updateUVRenderer(e);break;case"rasterColormap":t=this._updateColormapRenderer(e);break;case"rasterStretch":t=this._updateStretchRenderer(e);break;case"classBreaks":t=this._updateClassBreaksRenderer(e);break;case"rasterShadedRelief":t=this._updateShadedReliefRenderer(e)}return t}symbolize(e){let t=e&&e.pixelBlock;if(!this.isValidPixelBlock(t))return t;if(e.simpleStretchParams&&"rasterStretch"===this.rendererJSON.type)return this.simpleStretch(t,e.simpleStretchParams);try{let r;switch(t.pixels.length>3&&(t=de(t,[0,1,2])),this.rendererJSON.type){case"uniqueValue":case"rasterColormap":r=this._symbolize_colormap(t);break;case"classBreaks":r=this._symbolize_classBreaks(t);break;case"rasterStretch":r=this._symbolize_stretch(t,e.bandIds);break;case"rasterShadedRelief":{const{extent:i}=e;r=this._symbolize_shadedRelief(t,{isGCS:i.spatialReference.isGeographic,resolution:{x:(i.xmax-i.xmin)/t.width,y:(i.ymax-i.ymin)/t.height}});break}}return r}catch(e){return Ze.error("symbolize",e.message),t}}simpleStretch(e,t){if(!this.isValidPixelBlock(e))return e;try{return e.pixels.length>3&&(e=de(e,[0,1,2])),Ce(e,t)}catch(t){return Ze.error("symbolize",t.message),e}}generateWebGLParameters(e){if(["uniqueValue","rasterColormap","classBreaks"].indexOf(this.rendererJSON.type)>-1){const{indexedColormap:e,offset:t}=this.lookup.colormapLut;return{colormap:e,colormapOffset:t,type:"lut"}}const{pixelBlock:t,isGCS:r,resolution:i,bandIds:o}=e,{rendererJSON:n}=this;return"rasterStretch"===n.type?this.generateStretchWebGLParams(t,n,o):"rasterShadedRelief"===n.type?this.generateShadedReliefWebGLParams(n,r,i):null}_isLUTChanged(e){if(!this.lookup||!this.lookup.rendererJSON)return!0;if("colorRamp"in this.rendererJSON){const t=this.rendererJSON.colorRamp;return e?JSON.stringify(t)!==JSON.stringify(this.lookup.rendererJSON.colorRamp):JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}return JSON.stringify(this.rendererJSON)!==JSON.stringify(this.lookup.rendererJSON)}_symbolize_colormap(e){return this._isLUTChanged()&&!this.bind()?e:me(e,this.lookup.colormapLut)}_symbolize_classBreaks(e){const t=["u8","u16","s8","s16"].indexOf(this.rasterInfo.pixelType)>-1;let r;return this._isLUTChanged()&&!this.bind()?e:(r=t?me(e,this.lookup.colormapLut):function(e,t){if(!he(e))return null;const r=e.clone(),{pixels:i}=r,o=r.width*r.height,n=t.length,a=Math.floor(n/2),s=t[Math.floor(a)],l=i[0];let f,u,c,h,d,p,m=!1;const w=new Uint8Array(o),y=new Uint8Array(o),g=new Uint8Array(o);let C=r.mask;const A=4===t[0].mappedColor.length;for(C||(C=new Uint8Array(o),C.fill(A?255:1),r.mask=C),d=0;d<o;d++)if(C[d]){for(f=l[d],m=!1,p=a,u=s,c=0,h=n-1;h-c>1;){if(f===u.value){m=!0;break}f>u.value?c=p:h=p,p=Math.floor((c+h)/2),u=t[Math.floor(p)]}m||(f===t[c].value?(u=t[c],m=!0):f===t[h].value?(u=t[h],m=!0):f<t[c].value?(m=!1,u=null):f>t[c].value&&(f<t[h].value?(u=t[c],m=!0):h===n-1?(m=!1,u=null):(u=t[h],m=!0))),m?(w[d]=u.mappedColor[0],y[d]=u.mappedColor[1],g[d]=u.mappedColor[2],C[d]=u.mappedColor[3]):w[d]=y[d]=g[d]=C[d]=0}return r.pixels=[w,y,g],r.mask=C,r.pixelType="u8",r.maskIsAlpha=A,r}(e,this.lookup.remapLut),r)}_symbolize_stretch(e,t){const{pixelType:r,bandCount:i}=this.rasterInfo,o=this.rendererJSON,n=["u8","u16","s8","s16"].indexOf(r)>-1;let a,s;const{gamma:l,useGamma:f}=o;if(n){var u;if(o.dra){const i=this.getStretchCutoff(o,e,t);a=ge({pixelType:r,...i,gamma:f?l:null})}else if(this._isLUTChanged()){if(!this.bind())return e;a=this.lookup?this.lookup.stretchLut:null}else a=this.lookup?this.lookup.stretchLut:null;if(!a)return e;i>1&&(null==t?void 0:t.length)===e.pixels.length&&(null==(u=a)?void 0:u.lut.length)===i&&(a={lut:t.map((e=>a.lut[e])),offset:a.offset}),s=Ae(e,a)}else s=Ce(e,{...this.getStretchCutoff(o,e,t),gamma:f?l:null});if(o.colorRamp){if(this._isLUTChanged(!0)&&!this.bind())return e;s=me(s,this.lookup.colormapLut)}return s}_symbolize_shadedRelief(e,t){var r,i;const o=this.rendererJSON,n=function(e,t){if(!Xe(e))return e;const{width:r,height:i,mask:o}=e,n=new Uint8Array(r*i);o&&n.set(o);const{factor:a,sinZcosA:s,sinZsinA:l,cosZ:f,sinZcosAs:u,sinZsinAs:c,cosZs:h,weights:d}=qe(t),[p,m]=a,{hillshadeType:w}=t,y=e.pixels[0],g=new Uint8Array(r*i);let C,A,T,k,S,b,M,E;for(let e=1;e<i-1;e++){const t=e*r;for(let e=1;e<r-1;e++){if(o&&!o[t+e]){g[t+e]=0;continue}let i=8;if(o&&(i=o[t-r+e-1]+o[t-r+e]+o[t-r+e+1]+o[t+e-1]+o[t+e+1]+o[t+r+e-1]+o[t+r+e]+o[t+r+e+1],i<7)){g[t+e]=0,n[t+e]=0;continue}7===i?(C=o[t-r+e-1]?y[t-r+e-1]:y[t+e],A=o[t-r+e]?y[t-r+e]:y[t+e],T=o[t-r+e+1]?y[t-r+e+1]:y[t+e],k=o[t+e-1]?y[t+e-1]:y[t+e],S=o[t+e+1]?y[t+e+1]:y[t+e],b=o[t+r+e-1]?y[t+r+e-1]:y[t+e],M=o[t+r+e]?y[t+r+e]:y[t+e],E=o[t+r+e+1]?y[t+r+e+1]:y[t+e]):(C=y[t-r+e-1],A=y[t-r+e],T=y[t-r+e+1],k=y[t+e-1],S=y[t+e+1],b=y[t+r+e-1],M=y[t+r+e],E=y[t+r+e+1]);const a=(T+S+S+E-(C+k+k+b))*p,v=(b+M+M+E-(C+A+A+T))*m,G=Math.sqrt(1+a*a+v*v);let D=0;if("traditional"===w){let e=255*(f+l*v-s*a)/G;e<0&&(e=0),D=e}else{const e=c.length;for(let t=0;t<e;t++){let e=255*(h[t]+c[t]*v-u[t]*a)/G;e<0&&(e=0),D+=e*d[t]}}g[t+e]=255&D}}for(let e=0;e<i;e++)g[e*r]=g[e*r+1],g[(e+1)*r-1]=g[(e+1)*r-2];for(let e=1;e<r-1;e++)g[e]=g[e+r],g[e+(i-1)*r]=g[e+(i-2)*r];return new v({width:r,height:i,pixels:[g],mask:o?n:null,pixelType:"u8",validPixelCount:e.validPixelCount,statistics:[{minValue:0,maxValue:255}]})}(e,{...o,...t});if(!o.colorRamp)return n;let a;if(this._isLUTChanged(!0)){if(!this.bind())return n;a=this.lookup?this.lookup.hsvMap:null}else a=this.lookup?this.lookup.hsvMap:null;return a?(function(e,t,r,i){if(!Xe(e)||!Xe(t))return;const{min:o,max:n}=i,a=e.pixels[0],{pixels:s,mask:l}=t,f=s[0],u=255.00001/(n-o),c=new Uint8ClampedArray(f.length),h=new Uint8ClampedArray(f.length),d=new Uint8ClampedArray(f.length),p=r.length-1;for(let e=0;e<f.length;e++){if(l&&0===l[e])continue;const t=Math.floor((f[e]-o)*u),[i,n]=r[t<0?0:t>p?p:t],s=a[e],m=s*n,w=m*(1-Math.abs(i%2-1)),y=s-m;switch(Math.floor(i)){case 0:c[e]=m+y,h[e]=w+y,d[e]=y;break;case 1:c[e]=w+y,h[e]=m+y,d[e]=y;break;case 2:c[e]=y,h[e]=m+y,d[e]=w+y;break;case 3:c[e]=y,h[e]=w+y,d[e]=m+y;break;case 4:c[e]=w+y,h[e]=y,d[e]=m+y;break;case 5:case 6:c[e]=m+y,h[e]=y,d[e]=w+y}}e.pixels=[c,h,d],e.updateStatistics()}(n,e,a,null!=(r=null==(i=m(this.rasterInfo.statistics))?void 0:i[0])?r:{min:0,max:8e3}),n):n}_updateUVRenderer(e){const{bandCount:t,attributeTable:r,statistics:i,pixelType:o}=this.rasterInfo,n=e.field1;if(!n)return!1;const a=["u8","s8"].indexOf(o)>-1&&i&&null!=i[0].min&&null!=i[0].max;if(!(function(e,t){const{attributeTable:r,bandCount:i}=e;return!(!p(r)||i>1||t&&null==r.fields.find((e=>e.name.toLowerCase()===t.toLowerCase())))}(this.rasterInfo,n)||1===t&&a))return!1;const s=[];if(r){const t=r.fields.filter((e=>"value"===e.name.toLowerCase()))[0];if(!t)return!1;r.features.forEach((r=>{var i;const o=e.uniqueValueInfos.filter((e=>String(e.value)===String(r.attributes[n])))[0],a=null==o||null==(i=o.symbol)?void 0:i.color;a&&s.push([r.attributes[t.name]].concat(a))}))}else{if("value"!==n.toLowerCase())return!1;e.uniqueValueInfos.forEach((e=>{var t;const r=null==e||null==(t=e.symbol)?void 0:t.color;r&&s.push([parseInt(""+e.value,10)].concat(r))}))}if(0===s.length)return!1;const l=pe({colormap:s});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=!0,!0}_updateColormapRenderer(e){if(!function(e){const{bandCount:t,colormap:r}=e;return p(r)&&r.length&&1===t}(this.rasterInfo))return!1;const t=e.colormapInfos.map((e=>[e.value].concat(e.color))).sort(((e,t)=>e[0]-t[0]));if(!t||0===t.length)return!1;const r=pe({colormap:t});return this.lookup={rendererJSON:e,colormapLut:r},this.canRenderInWebGL=!0,!0}_updateShadedReliefRenderer(e){if("elevation"!==this.rasterInfo.dataType)return!1;if(e.colorRamp){const t=pe({colormap:ze(e.colorRamp,256,!0)}),r=[],i=t.indexedColormap;for(let e=0;e<i.length;e+=4){const t=Ne({r:i[e],g:i[e+1],b:i[e+2]});r.push([t.h/60,t.s/100,255*t.v/100])}this.lookup={rendererJSON:e,colormapLut:t,hsvMap:r}}else this.lookup=null;return this.canRenderInWebGL=!0,!0}_updateClassBreaksRenderer(e){const t=["u8","u16","s8","s16"].indexOf(this.rasterInfo.pixelType)>-1,r=e.classBreakInfos;if(null==r||!r.length)return!1;const i=r.sort(((e,t)=>e.classMaxValue-t.classMaxValue)),o=i[i.length-1];let n=e.minValue;if(!t){const t=[];for(let e=0;e<i.length;e++){var a;t.push({value:null!=(a=i[e].classMinValue)?a:n,mappedColor:i[e].symbol.color}),n=i[e].classMaxValue}return t.push({value:o.classMaxValue,mappedColor:o.symbol.color}),this.lookup={rendererJSON:e,remapLut:t},this.canRenderInWebGL=!1,!0}const s=[];n=e.minValue;for(let e=0;e<i.length;e++){const t=i[e];for(let e=n;e<t.classMaxValue;e++)s.push([e].concat(t.symbol.color));n=t.classMaxValue}s.push([o.classMaxValue].concat(o.symbol.color));const l=pe({colormap:s,fillUnspecified:!1});return this.lookup={rendererJSON:e,colormapLut:l},this.canRenderInWebGL=!0,!0}_updateStretchRenderer(e){if(!("none"===e.stretchType||e.statistics||this.rasterInfo.statistics||e.dra))return!1;if(!e.dra&&"percentClip"===e.stretchType&&!e.histograms&&!this.rasterInfo.histograms)return!1;const{gamma:t,useGamma:r,colorRamp:i}=e,o=this.rasterInfo.pixelType;if(!e.dra&&["u8","u16","s8","s16"].indexOf(o)>-1){const i=ge({pixelType:o,...this.getStretchCutoff(e),gamma:r?t:null});this.lookup={rendererJSON:e,stretchLut:i}}if(i){const t=ze(i,256,!0);this.lookup||(this.lookup={rendererJSON:e}),this.lookup.colormapLut=pe({colormap:t}),this.lookup.rendererJSON=e}return this.canRenderInWebGL=!0,!0}getStretchCutoff(e,t,r){let i,o;const n=e.stretchType;var a;if(e.dra)if("minMax"===n&&t.statistics)i=t.statistics.map((e=>[e.minValue,e.maxValue,0,0]));else{const e=we(t);i=e.statistics,o=e.histograms}else i=(null==(a=e.statistics)?void 0:a.length)>0?e.statistics:m(this.rasterInfo.statistics),o=e.histograms||m(this.rasterInfo.histograms);const s=i||o?(i||o).length:this.rasterInfo.bandCount,l=[],f=[];let u,c,h,d,p,w,y,g,C;switch(i&&!Array.isArray(i[0])&&(i=i.map((e=>[e.min,e.max,e.avg,e.stddev]))),n){case"none":{const e=Qe[this.rasterInfo.pixelType]||Qe.f32;for(g=0;g<s;g++)l[g]=e[0],f[g]=e[1]}break;case"minMax":for(g=0;g<s;g++)l[g]=i[g][0],f[g]=i[g][1];break;case"standardDeviation":for(g=0;g<s;g++)l[g]=i[g][2]-e.numberOfStandardDeviations*i[g][3],f[g]=i[g][2]+e.numberOfStandardDeviations*i[g][3],l[g]<i[g][0]&&(l[g]=i[g][0]),f[g]>i[g][1]&&(f[g]=i[g][1]);break;case"percentClip":for(g=0;g<o.length;g++){for(u=o[g],p=new Uint32Array(u.size),d=u.counts,h=0,c=(u.max-u.min)/u.size,y=-.5===u.min&&1===c?.5:0,C=0;C<u.size;C++)h+=d[C],p[C]=h;for(w=e.minPercent*h/100,C=0;C<u.size;C++)if(p[C]>w){l[g]=u.min+c*(C+y);break}for(w=(1-e.maxPercent/100)*h,C=u.size-2;C>=0;C--)if(p[C]<w){f[g]=u.min+c*(C+2-y);break}}break;default:for(g=0;g<s;g++)l[g]=i[g][0],f[g]=i[g][1]}return this.getSelectedBandCutoffs({minCutOff:l,maxCutOff:f,outMax:e.max||255,outMin:e.min||0},r)}getSelectedBandCutoffs(e,t){if(null==t||0===t.length)return e;const r=Math.max.apply(null,t),{minCutOff:i,maxCutOff:o,outMin:n,outMax:a}=e;return i.length===t.length||i.length<=r?e:{minCutOff:t.map((e=>i[e])),maxCutOff:t.map((e=>o[e])),outMin:n,outMax:a}}generateStretchWebGLParams(e,t,r){let i=null,o=null;const n=this.lookup&&this.lookup.colormapLut;t.colorRamp&&n&&(i=n.indexedColormap,o=n.offset);const{gamma:a}=t,s=!!(t.useGamma&&a&&a.some((e=>1!==e))),{minCutOff:l,maxCutOff:f,outMin:u,outMax:c}=this.getStretchCutoff(t,e,r);e&&e.pixels&&2===e.pixels.length&&((e=e.clone()).statistics=[e.statistics[0]],e.pixels=[e.pixels[0]]);const h=Math.min(3,r&&r.length||e&&e.getPlaneCount()||this.rasterInfo.bandCount),d=new Float32Array(h),p=i||s?1:255;let m;for(m=0;m<h;m++)d[m]=(c-u)/(f[m]-l[m])/p;const w=new Float32Array(h);if(s)for(m=0;m<h;m++)w[m]=a[m]>1?a[m]>2?6.5+Math.pow(a[m]-2,2.5):6.5+100*Math.pow(2-a[m],4):1;return{bandCount:h,outMin:u/p,outMax:c/p,minCutOff:l,maxCutOff:f,factor:d,useGamma:s,gamma:s?a:[1,1,1],gammaCorrection:s?w:[1,1,1],colormap:i,colormapOffset:o,type:"stretch"}}generateShadedReliefWebGLParams(e,t,r){var i,o,n;let a=null,s=null;const l=this.lookup&&this.lookup.colormapLut;e.colorRamp&&l&&(a=l.indexedColormap,s=l.offset);const f=qe({...e,isGCS:t,resolution:r}),u=null==(i=m(this.rasterInfo.statistics))?void 0:i[0];return{...f,minValue:null!=(o=u.min)?o:0,maxValue:null!=(n=u.max)?n:8e3,hillshadeType:"traditional"===e.hillshadeType?0:1,type:"hillshade",colormap:a,colormapOffset:s}}isValidPixelBlock(e){return!!(e&&e.pixels&&e.pixels.length>0&&0!==e.validPixelCount)}};t([r({json:{write:!0}})],$e.prototype,"rendererJSON",void 0),t([r({type:We,json:{write:!0}})],$e.prototype,"rasterInfo",void 0),t([r({json:{write:!0}})],$e.prototype,"lookup",void 0),t([r({})],$e.prototype,"canRenderInWebGL",void 0),$e=t([o("esri.renderers.support.RasterSymbolizer")],$e);var et=$e;export{De as A,ue as I,et as R,L as S,ce as U,xe as a,We as b,Te as c,ye as d,G as e,ze as f,Q as g,Ve as l,ke as m,Ye as n,we as o,J as p,D as r,v as u,z as w,Z as y}