g&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){var p,b=o<=8?new Uint8Array(g):new Uint16Array(g);for(h=0;h =n?e[G]=L:e[G]=L*(1< =f?255:k>>h;B[T++]=w<=0?0:w>=f?255:w>>h;B[T++]=x<=0?0:x>=f?255:x>>h}if(O)for(m=0,T=3;m =g?255:C+u>>h}}else for(o=0;o >3,c=this.getImageBytes(n*o),l=this.getComponents(c);if(1!==s){this.needsDecode&&this.decodeBuffer(l);r=i*n;var u=255/((1< =k||E<0||E>=y?L<<=1:L=L<<1|r[M][E]}var D=C.readBit(S,L);O[P]=D}}return x}function g(e,t,i,o,c,l,h,u,g,p,b){e&&n("JBIG2 error: huffman is not supported");for(var v=[],y=0,k=s(i.length+o),w=b.decoder,x=b.contextCache;v.length >4===0?p:m)[15&D]=t(F,U)}break;case 65501:a();h=a();break;case 65498:a();var N,j=e[u++],_=[];for(v=0;v8?Math.pow((e+16)/116,3):e*w}function l(e,t,a){if(0!==e[0]||0!==e[1]||0!==e[2]){var r=c(0),i=r,n=c(e[0]),s=r,o=c(e[1]),l=r,h=c(e[2]),u=(1-i)/(1-n),f=1-u,d=(1-s)/(1-o),g=1-d,m=(1-l)/(1-h),p=1-m;a[0]=t[0]*u+f;a[1]=t[1]*d+g;a[2]=t[2]*m+p}else{a[0]=t[0];a[1]=t[1];a[2]=t[2]}}function h(e,r,i){if(1!==e[0]||1!==e[2]){var n=i;t(d,r,n);var s=v;a(e,n,s);t(g,s,i)}else{i[0]=r[0];i[1]=r[1];i[2]=r[2]}}function u(e,a,i){var n=i;t(d,a,n);var s=v;r(e,n,s);t(g,s,i)}function f(e,a,r,s,o,c){var f=n(0,1,a[r]*c),d=n(0,1,a[r+1]*c),g=n(0,1,a[r+2]*c),p=Math.pow(f,e.GR),v=Math.pow(d,e.GG),w=Math.pow(g,e.GB),x=e.MXA*p+e.MXB*v+e.MXC*w,C=e.MYA*p+e.MYB*v+e.MYC*w,S=e.MZA*p+e.MZB*v+e.MZC*w,A=y;A[0]=x;A[1]=C;A[2]=S;var I=k;h(e.whitePoint,A,I);var B=y;l(e.blackPoint,I,B);var R=k;u(b,B,R);var T=y;t(m,R,T);var O=i(T[0]),P=i(T[1]),M=i(T[2]);s[o]=Math.round(255*O);s[o+1]=Math.round(255*P);s[o+2]=Math.round(255*M)}var d=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),g=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),m=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]),b=new Float32Array([1,1,1]),v=new Float32Array(3),y=new Float32Array(3),k=new Float32Array(3),w=Math.pow(24/116,3)/8;e.prototype={getRgb:function(e,t){var a=new Uint8Array(3);this.getRgbItem(e,t,a,0);return a},getRgbItem:function(e,t,a,r){f(this,e,t,a,r,1)},getRgbBuffer:function(e,t,a,r,i,n,s){for(var o=1/((1<>")&&!w(this.buf1);)if(S(this.buf1)){var i=this.buf1.name;this.shift();if(w(this.buf1))break;r.set(i,this.getObj(e))}else{h("Malformed dictionary: key must be a name object");this.shift()}if(w(this.buf1)){this.recoveryMode||l("End of file inside dictionary");return r}if(x(this.buf2,"stream"))return this.allowStreams?this.makeStream(r,e):r;this.shift();return r;default:return t}if(f(t)){var n=t;if(f(this.buf1)&&x(this.buf2,"R")){var s=new k(n,this.buf1);this.shift();this.shift();return s}return n}if(g(t)){var o=t;e&&(o=e.decryptString(o));return o}return t},findDefaultInlineStreamEnd:function(e){for(var t,a,r,i,n=69,s=73,o=32,l=10,h=13,u=e.pos,f=0;(t=e.getByte())!==-1;)if(0===f)f=t===n?1:0;else if(1===f)f=t===s?2:0;else{c(2===f);if(t===o||t===l||t===h){r=5;i=e.peekBytes(r);for(a=0;ay&&(h=y)}p[c]=h}if(u>0){u--;l[d]=p}r.set(p,i)}else r.set(m,i)}}}}(),p=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}var t=100;e.prototype={push:function(e){this.stack.length>=t&&o("PostScript function stack overflow.");this.stack.push(e)},pop:function(){this.stack.length<=0&&o("PostScript function stack underflow.");return this.stack.pop()},copy:function(e){this.stack.length+e>=t&&o("PostScript function stack overflow.");for(var a=this.stack,r=a.length-e,i=e-1;i>=0;i--,r++)a.push(a[r])},index:function(e){this.push(this.stack[this.stack.length-e-1])},roll:function(e,t){var a,r,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(a=s,r=o;ae.min){s.unshift("Math.max(",r,", ");s.push(")")}if(n126||91===l||93===l||40===l||41===l||123===l||125===l||60===l||62===l||47===l||37===l||35===l)?s[o]=95:s[o]=l}t.push(c(s))}return t},parseStringIndex:function(e){for(var t=new S,a=0,r=e.count;a=-107&&e<=107)t=[e+139];else if(e>=108&&e<=1131){e-=108;t=[(e>>8)+247,255&e]}else if(e>=-1131&&e<=-108){e=-e-108;t=[(e>>8)+251,255&e]}else t=e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e];return t},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new A,a=0,r=e.length;a=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var m=new Uint8Array(f);for(r=0,i=0,n=l.length;r=n;--r)if(d[r]!==g){g=0;break}f-=g;l[l.length-1]=d.subarray(0,16-g)}}var m=new Uint8Array(f);for(r=0,i=0,n=l.length;r=a?this.flush():this.fnArray.length>=r&&(e===S.restore||e===S.endText)&&this.flush())},addDependency:function(e){if(!(e in this.dependencies)){this.dependencies[e]=!0;this.addOp(S.dependency,[e])}},addDependencies:function(e){for(var t in e)this.addDependency(t)},addOpList:function(e){I.extendObj(this.dependencies,e.dependencies);for(var t=0,a=e.length;ts&&O("Command "+n+": expected [0,"+s+"] args, but received "+o+" args.");else{if(o!==s){for(var c=this.nonProcessedArgs;o>s;){c.push(t.shift());o--}for(;or){m=Math.max(m,v);y+=b+2*i;v=0;b=0}p.push({transform:k,x:v,y:y,w:w.width,h:w.height});v+=w.width+2*i;b=Math.max(b,w.height)}var x=Math.max(m,v)+i,A=y+b+i,I=new Uint8Array(x*A*4),B=x<<2;for(g=0;ge.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){var n=e.resolutions[a],s=n.precinctParameters.numprecincts;if(!(i>=s)){for(;t>>f&(1<>2);k=w+y;x=w+v;B[T++]=k<=0?0:k>=f?255:k>>h;B[T++]=w<=0?0:w>=f?255:w>>h;B[T++]=x<=0?0:x>=f?255:x>>h}else for(m=0;m=a)break;s[m]&=h;if(!r[m]&&n[m]){var v=c[n[m]],y=e.readBit(o,v);if(y){var k=this.decodeSignBit(b,g,m);i[m]=k;r[m]=1;this.setNeighborsSignificance(b,g,m);s[m]|=f}l[m]++;s[m]|=u}}},decodeSignBit:function(e,t,a){var r,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,f=this.coefficentsSign;s=t>0&&0!==u[a-1];if(t+1>16;c+=2;break;case 2:h-=e[c++];break;case 18:h+=e[c++]}A[k].x=h}for(k=0;k>16;c+=2;break;case 4:u-=e[c++];break;case 36:u+=e[c++]}A[k].y=u}var B=0;for(c=0;c>1;en)){i.pos=p;var b=m.name;if(m.encoding){for(var v="",y=0,w=m.length;y0&&L(Me,-1,-1)){ce[oe]=Me;Oe=!0}}Oe||(ce[oe]=0)}}}else if(0===ye&&0===we)for(V=0;V
>>0}var i=e.getContexts(t),n=1,s=r(1),o=r(1)?r(1)?r(1)?r(1)?r(1)?r(32)+4436:r(12)+340:r(8)+84:r(6)+20:r(4)+4:r(2);return 0===s?o:o>0?-o:null}function r(e,t,a){for(var r=e.getContexts("IAID"),i=1,n=0;n=E&&R>2&3);p.referenceCorner=b>>4&3;p.transposed=!!(64&b);p.combinationOperator=b>>7&3;p.defaultPixelValue=b>>9&1;p.dsOffset=b<<17>>27;p.refinementTemplate=b>>15&1;if(p.huffman){var y=c(u,f);f+=2;p.huffmanFS=3&y;p.huffmanDS=y>>2&3;p.huffmanDT=y>>4&3;p.huffmanRefinementDW=y>>6&3;p.huffmanRefinementDH=y>>8&3;p.huffmanRefinementDX=y>>10&3;p.huffmanRefinementDY=y>>12&3;p.huffmanRefinementSizeSelector=!!(14&y)}if(p.refinement&&!p.refinementTemplate){r=[];for(i=0;i<2;i++){r.push({x:o(u,f),y:o(u,f+1)});f+=2}p.refinementAt=r}p.numberOfSymbolInstances=l(u,f);f+=4;p.huffman&&n("JBIG2 error: huffman is not supported");a=[p,h.referredTo,u,f,d];break;case 38:case 39:var k={};k.info=v(u,f);f+=T;var w=u[f++];k.mmr=!!(1&w);k.template=w>>1&3;k.prediction=!!(8&w);if(!k.mmr){s=0===k.template?4:1;r=[];for(i=0;i>2&1;x.combinationOperator=C>>3&3;x.requiresBuffer=!!(32&C);x.combinationOperatorOverride=!!(64&C);a=[x];break;case 49:break;case 50:break;case 51:break;case 62:break;default:n("JBIG2 error: segment type "+h.typeName+"("+h.type+") is not implemented")}var S="on"+h.typeName;S in t&&t[S].apply(t,a)}function k(e,t){for(var a=0,r=e.length;a0;)c=n.pop();c.index++;n.push(c);for(;n.length<=a;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(a+10){L--;return E>>L&1}E=e[t++];if(255===E){var a=e[t++];a&&i("JPEG error: unexpected marker "+(E<<8|a).toString(16))}L=7;return E>>>7}function d(e){for(var t=e;;){t=t[f()];if("number"==typeof t)return t;"object"!=typeof t&&i("JPEG error: invalid huffman sequence")}}function g(e){for(var t=0;e>0;){t=t<<1|f();e--}return t}function m(e){if(1===e)return 1===f()?1:-1;var t=g(e);return t>=1<