// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define(["exports","./_commonjsHelpers"],function(Z,S){var V={exports:{}};(function(aa){(function(H){H=H();void 0!==H&&(aa.exports=H)})(function(){var H=function(){function L(T){this.message="JPEG error: "+T}L.prototype=Error();L.prototype.name="JpegError";return L.constructor=L}();return function(){function L(){this.decodeTransform=null;this.colorTransform=-1}function T(b,d){for(var l=0,k=[],a,t,e=16;0>u&1;h=b[d++];if(255===h){var m=b[d++];if(m)throw new H("unexpected marker "+(h<<8|m).toString(16));}u=7;return h>>>7}function g(m){for(;;){m=m[q()];if("number"===typeof m)return m; if("object"!==typeof m)throw new H("invalid huffman sequence");}}function c(m){for(var B=0;0=1<E;){var F=g(m.huffmanTableAC),G=F&15;F>>=4;if(0===G){if(15>F)break;E+=16}else E+=F,m.blockData[B+O[E]]=v(G),E++}}function y(m,B){var E=g(m.huffmanTableDC);E=0===E?0:v(E)<>=4;if(0===G){if(15>F){r=c(F)+(1<>=4;if(0===G)15>F?(r=c(F)+(1<=D)throw new H("marker was not found");if(65488<=D&&65495>=D)d+=2;else break}(D=U(b,d))&&D.invalid&&(console.log("decodeScan - unexpected Scan data, next marker is: "+ D.invalid),d=D.offset);return d-p}function ca(b,d){b=d.blocksPerLine;for(var l=d.blocksPerColumn,k=new Int16Array(64),a=0;ar;r+=8)e=u[A+r],w=u[A+r+1],v=u[A+r+2],c=u[A+r+3],g=u[A+r+4],q=u[A+r+5],x=u[A+r+6],f= u[A+r+7],e*=h[r],0===(w|v|c|g|q|x|f)?(e=5793*e+512>>10,p[r]=e,p[r+1]=e,p[r+2]=e,p[r+3]=e,p[r+4]=e,p[r+5]=e,p[r+6]=e,p[r+7]=e):(w*=h[r+1],v*=h[r+2],c*=h[r+3],g*=h[r+4],q*=h[r+5],x*=h[r+6],f*=h[r+7],C=5793*e+128>>8,z=5793*g+128>>8,n=v,y=x,g=2896*(w-f)+128>>8,f=2896*(w+f)+128>>8,c<<=4,q<<=4,C=C+z+1>>1,z=C-z,e=3784*n+1567*y+128>>8,n=1567*n-3784*y+128>>8,y=e,g=g+q+1>>1,q=g-q,f=f+c+1>>1,c=f-c,C=C+y+1>>1,y=C-y,z=z+n+1>>1,n=z-n,e=2276*g+3406*f+2048>>12,g=3406*g-2276*f+2048>>12,f=e,e=799*c+4017*q+2048>>12, c=4017*c-799*q+2048>>12,q=e,p[r]=C+f,p[r+7]=C-f,p[r+1]=z+q,p[r+6]=z-q,p[r+2]=n+c,p[r+5]=n-c,p[r+3]=y+g,p[r+4]=y-g);for(h=0;8>h;++h)e=p[h],w=p[h+8],v=p[h+16],c=p[h+24],g=p[h+32],q=p[h+40],x=p[h+48],f=p[h+56],0===(w|v|c|g|q|x|f)?(e=5793*e+8192>>14,e=-2040>e?0:2024<=e?255:e+2056>>4,u[A+h]=e,u[A+h+8]=e,u[A+h+16]=e,u[A+h+24]=e,u[A+h+32]=e,u[A+h+40]=e,u[A+h+48]=e,u[A+h+56]=e):(C=5793*e+2048>>12,z=5793*g+2048>>12,n=v,y=x,g=2896*(w-f)+2048>>12,f=2896*(w+f)+2048>>12,C=(C+z+1>>1)+4112,z=C-z,e=3784*n+1567*y+ 2048>>12,n=1567*n-3784*y+2048>>12,y=e,g=g+q+1>>1,q=g-q,f=f+c+1>>1,c=f-c,C=C+y+1>>1,y=C-y,z=z+n+1>>1,n=z-n,e=2276*g+3406*f+2048>>12,g=3406*g-2276*f+2048>>12,f=e,e=799*c+4017*q+2048>>12,c=4017*c-799*q+2048>>12,q=e,e=C+f,f=C-f,w=z+q,x=z-q,v=n+c,q=n-c,c=y+g,g=y-g,e=16>e?0:4080<=e?255:e>>4,w=16>w?0:4080<=w?255:w>>4,v=16>v?0:4080<=v?255:v>>4,c=16>c?0:4080<=c?255:c>>4,g=16>g?0:4080<=g?255:g>>4,q=16>q?0:4080<=q?255:q>>4,x=16>x?0:4080<=x?255:x>>4,f=16>f?0:4080<=f?255:f>>4,u[A+h]=e,u[A+h+8]=w,u[A+h+16]=v,u[A+ h+24]=c,u[A+h+32]=g,u[A+h+40]=q,u[A+h+48]=x,u[A+h+56]=f)}return d.blockData}function U(b,d,l){var k=b.length-1;l=l=k)return null;var a=b[d]<<8|b[d+1];if(65472<=a&&65534>=a)return{invalid:null,marker:a,offset:d};for(d=b[l]<<8|b[l+1];!(65472<=d&&65534>=d);){if(++l>=k)return null;d=b[l]<<8|b[l+1]}return{invalid:a.toString(16),marker:d,offset:l}}if(!self||!self.Uint8ClampedArray)return null;var O=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]);L.prototype={parse:function(b){function d(){var h=b[a]<<8|b[a+1];a+=2;return h}function l(){var h=d();h=a+h-2;var u=U(b,h,a);u&&u.invalid&&(console.log("readDataBlock - incorrect length, next marker is: "+u.invalid),h=u.offset);h=b.subarray(a,h);a+=h.length;return h}function k(h){for(var u=Math.ceil(h.samplesPerLine/8/h.maxH),r=Math.ceil(h.scanLines/8/h.maxV),I=0;I>4)for(c= 0;64>c;c++)v=O[c],y[v]=b[a++];else if(1===w>>4)for(c=0;64>c;c++)v=O[c],y[v]=d();else throw new H("DQT - invalid table spec");f[w&15]=y}break;case 65472:case 65473:case 65474:if(n)throw new H("Only single frame JPEGs supported");d();var n={};n.extended=65473===g;n.progressive=65474===g;n.precision=b[a++];n.scanLines=d();n.samplesPerLine=d();n.components=[];n.componentIds={};c=b[a++];for(g=y=w=0;g>4;var C=b[a+1]&15;wc;c++,a++)z+=y[c]=b[a];C=new Uint8Array(z);for(c=0;c>4?q:x)[w&15]=T(y,C)}break;case 65501:d();var A=d();break;case 65498:d();v=b[a++];c=[];for(g=0;g>4];p.huffmanTableAC=x[w&15];c.push(p)}g=b[a++];v=b[a++];w=b[a++];g=ba(b,a, n,c,A,g,v,w>>4,w&15);a+=g;break;case 65535:255!==b[a]&&a--;break;default:if(255===b[a-3]&&192<=b[a-2]&&254>=b[a-2])a-=3;else throw new H("unknown marker "+g.toString(16));}g=d()}this.width=n.samplesPerLine;this.height=n.scanLines;this.jfif=t;this.eof=a;this.adobe=e;this.components=[];for(g=0;g>8)+d[b+1];return q},_isColorConversionNeeded:function(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0===this.colorTransform?!1:!0:1===this.colorTransform?!0:!1},_convertYccToRgb:function(b){for(var d,l,k,a=0,t=b.length;a