a&&(a=e[t]);for(var i=1<>=1;for(t=h;t>=1)){var h,u;if(1===l)h=i,u=n;else{if(2!==l)throw new a.FormatError("Unknown block type in flate stream");var d,f=this.getBits(5)+257,g=this.getBits(5)+1,p=this.getBits(4)+4,m=new Uint8Array(e.length);for(d=0;d0;)k[d++]=w}h=this.generateHuffmanTable(k.subarray(0,f)),u=this.generateHuffmanTable(k.subarray(f,A))}for(var C=(s=this.buffer)?s.length:0,_=this.bufferLength;;){var P=this.getCode(h);if(P<256)_+1>=C&&(C=(s=this.ensureBuffer(_+1)).length),s[_++]=P;else{if(256===P)return void(this.bufferLength=_);var T=(P=t[P-=257])>>16;T>0&&(T=this.getBits(T)),o=(65535&P)+T,P=this.getCode(u),(T=(P=r[P])>>16)>0&&(T=this.getBits(T));var I=(65535&P)+T;_+o>=C&&(C=(s=this.ensureBuffer(_+o)).length);for(var E=0;E15))throw new a.FormatError("Unsupported predictor: "+n);this.readBlock=2===n?this.readBlockTiff:this.readBlockPng,this.str=e,this.dict=e.dict;var s=this.colors=r.get("Colors")||1,o=this.bits=r.get("BitsPerComponent")||8,l=this.columns=r.get("Columns")||1;return this.pixBytes=s*o+7>>3,this.rowBytes=l*s*o+7>>3,c.call(this,t),this}return e.prototype=Object.create(c.prototype),e.prototype.readBlockTiff=function(){var e=this.rowBytes,t=this.bufferLength,r=this.ensureBuffer(t+e),a=this.bits,i=this.colors,n=this.str.getBytes(e);if(this.eof=!n.length,!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===a&&1===i)for(s=0;s>1,d^=d>>2,o=(1&(d^=d>>4))<<7,r[u++]=d}else if(8===a){for(s=0;s>8&255,r[u++]=255&g}}else{var p=new Uint8Array(i+1),m=(1<>l-a)&m,l-=a,c=c<=8&&(r[y++]=c>>h-8&255,h-=8);h>0&&(r[y++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}},e.prototype.readBlockPng=function(){var e=this.rowBytes,t=this.pixBytes,r=this.str.getByte(),i=this.str.getBytes(e);if(this.eof=!i.length,!this.eof){var n=this.bufferLength,s=this.ensureBuffer(n+e),o=s.subarray(n-e,n);0===o.length&&(o=new Uint8Array(e));var c,l,h,u=n;switch(r){case 0:for(c=0;c>1)+i[c];for(;c>1)+i[c]&255,u++;break;case 4:for(c=0;c0;e=(0,this.decrypt)(e,!t);var r,a=this.bufferLength,i=e.length,n=this.ensureBuffer(a+i);for(r=0;r=0;--a)r[i+a]=255&o,o>>=8}}else this.eof=!0},e}();t.Ascii85Stream=f;var g=function(){function e(e,t){this.str=e,this.dict=e.dict,this.firstDigit=-1,t&&(t*=.5),c.call(this,t)}return e.prototype=Object.create(c.prototype),e.prototype.readBlock=function(){var e=this.str.getBytes(8e3);if(e.length){for(var t=e.length+1>>1,r=this.ensureBuffer(this.bufferLength+t),a=this.bufferLength,i=this.firstDigit,n=0,s=e.length;n=48&&c<=57)o=15&c;else{if(!(c>=65&&c<=70||c>=97&&c<=102)){if(62===c){this.eof=!0;break}continue}o=9+(15&c)}i<0?i=o:(r[a++]=i<<4|o,i=-1)}i>=0&&this.eof&&(r[a++]=i<<4,i=-1),this.firstDigit=i,this.bufferLength=a}else this.eof=!0},e}();t.AsciiHexStream=g;var p=function(){function e(e,t){this.str=e,this.dict=e.dict,c.call(this,t)}return e.prototype=Object.create(c.prototype),e.prototype.readBlock=function(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,r=this.bufferLength,a=e[0];if(a<128){if((t=this.ensureBuffer(r+a+1))[r++]=e[1],a>0){var i=this.str.getBytes(a);t.set(i,r),r+=a}}else{a=257-a;var n=e[1];t=this.ensureBuffer(r+a+1);for(var s=0;s>>t&(1<0;if(b<256)d[0]=b,f=1;else{if(!(b>=258)){if(256===b){h=9,s=258,f=0;continue}this.eof=!0,delete this.lzwState;break}if(b=0;t--)d[t]=o[r],r=l[r];else d[f++]=d[0]}if(y&&(l[s]=u,c[s]=c[u]+1,o[s]=d[0],h=++s+n&s+n-1?h:0|Math.min(Math.log(s+n)/.6931471805599453+1,12)),u=b,a<(g+=f)){do{a+=512}while(ae.getByte()};this.ccittFaxDecoder=new i.CCITTFaxDecoder(s,{K:r.get("K"),EndOfLine:r.get("EndOfLine"),EncodedByteAlign:r.get("EncodedByteAlign"),Columns:r.get("Columns"),Rows:r.get("Rows"),EndOfBlock:r.get("EndOfBlock"),BlackIs1:r.get("BlackIs1")}),n.DecodeStream.call(this,t)}return e.prototype=Object.create(n.DecodeStream.prototype),e.prototype.readBlock=function(){for(;!this.eof;){const e=this.ccittFaxDecoder.readNextChar();if(-1===e)return void(this.eof=!0);this.ensureBuffer(this.bufferLength+1),this.buffer[this.bufferLength++]=e}},e}();t.CCITTFaxStream=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CCITTFaxDecoder=void 0;var a=r(2);const i=function(){const e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],r=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],i=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],n=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],s=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function o(e,t={}){if(!e||"function"!=typeof e.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=e,this.eof=!1,this.encoding=t.K||0,this.eoline=t.EndOfLine||!1,this.byteAlign=t.EncodedByteAlign||!1,this.columns=t.Columns||1728,this.rows=t.Rows||0;let r,a=t.EndOfBlock;for(null==a&&(a=!0),this.eoblock=a,this.black=t.BlackIs1||!1,this.codingLine=new Uint32Array(this.columns+1),this.refLine=new Uint32Array(this.columns+2),this.codingLine[0]=this.columns,this.codingPos=0,this.row=0,this.nextLine2D=this.encoding<0,this.inputBits=0,this.inputBuf=0,this.outputBits=0,this.rowsDone=!1;0===(r=this._lookBits(12));)this._eatBits(1);1===r&&this._eatBits(12),this.encoding>0&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1))}return o.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,r=this.columns;let i,n,s,o,c;if(0===this.outputBits){if(this.rowsDone&&(this.eof=!0),this.eof)return-1;let s,c,l;if(this.err=!1,this.nextLine2D){for(o=0;t[o]=64);do{c+=l=this._getWhiteCode()}while(l>=64)}else{do{s+=l=this._getWhiteCode()}while(l>=64);do{c+=l=this._getBlackCode()}while(l>=64)}for(this._addPixels(t[this.codingPos]+s,n),t[this.codingPos]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,n),n^=1}let h=!1;if(this.byteAlign&&(this.inputBits&=-8),this.eoblock||this.row!==this.rows-1){if(s=this._lookBits(12),this.eoline)for(;-1!==s&&1!==s;)this._eatBits(1),s=this._lookBits(12);else for(;0===s;)this._eatBits(1),s=this._lookBits(12);1===s?(this._eatBits(12),h=!0):-1===s&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1)),this.eoblock&&h&&this.byteAlign){if(s=this._lookBits(12),1===s){if(this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1)),this.encoding>=0)for(o=0;o<4;++o)s=this._lookBits(12),1!==s&&(0,a.info)("bad rtc code: "+s),this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1));this.eof=!0}}else if(this.err&&this.eoline){for(;;){if(s=this._lookBits(13),-1===s)return this.eof=!0,-1;if(s>>1==1)break;this._eatBits(1)}this._eatBits(12),this.encoding>0&&(this._eatBits(1),this.nextLine2D=!(1&s))}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1],this.row++}if(this.outputBits>=8)c=1&this.codingPos?0:255,this.outputBits-=8,0===this.outputBits&&t[this.codingPos]s?(c<<=s,1&this.codingPos||(c|=255>>8-s),this.outputBits-=s,s=0):(c<<=this.outputBits,1&this.codingPos||(c|=255>>8-this.outputBits),s-=this.outputBits,this.outputBits=0,t[this.codingPos]0&&(c<<=s,s=0))}while(s)}return this.black&&(c^=255),c},_addPixels(e,t){const r=this.codingLine;let i=this.codingPos;e>r[i]&&(e>this.columns&&((0,a.info)("row is wrong length"),this.err=!0,e=this.columns),1&i^t&&++i,r[i]=e),this.codingPos=i},_addPixelsNeg(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i])e>this.columns&&((0,a.info)("row is wrong length"),this.err=!0,e=this.columns),1&i^t&&++i,r[i]=e;else if(e0&&e=i){const t=r[e-i];if(t[0]===a)return this._eatBits(a),[!0,t[1],!0]}}return[!1,0,!1]},_getTwoDimCode(){let t,r=0;if(this.eoblock){if(r=this._lookBits(7),t=e[r],t&&t[0]>0)return this._eatBits(t[0]),t[1]}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}return(0,a.info)("Bad two dim code"),-1},_getWhiteCode(){let e,i=0;if(this.eoblock){if(i=this._lookBits(12),-1===i)return 1;if(e=i>>5==0?t[i]:r[i>>3],e[0]>0)return this._eatBits(e[0]),e[1]}else{let e=this._findTableCode(1,9,r);if(e[0])return e[1];if(e=this._findTableCode(11,12,t),e[0])return e[1]}return(0,a.info)("bad white code"),this._eatBits(1),1},_getBlackCode(){let e,t;if(this.eoblock){if(e=this._lookBits(13),-1===e)return 1;if(t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7],t[0]>0)return this._eatBits(t[0]),t[1]}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];if(e=this._findTableCode(7,12,n,64),e[0])return e[1];if(e=this._findTableCode(10,13,i),e[0])return e[1]}return(0,a.info)("bad black code"),this._eatBits(1),1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t,this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}},o}();t.CCITTFaxDecoder=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Jbig2Stream=void 0;var a=r(5),i=r(12),n=r(16),s=r(2);const o=function(){function e(e,t,r,a){this.stream=e,this.maybeLength=t,this.dict=r,this.params=a,i.DecodeStream.call(this,t)}return e.prototype=Object.create(i.DecodeStream.prototype),Object.defineProperty(e.prototype,"bytes",{get(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0}),e.prototype.ensureBuffer=function(e){},e.prototype.readBlock=function(){if(this.eof)return;const e=new n.Jbig2Image,t=[];if((0,a.isDict)(this.params)){const e=this.params.get("JBIG2Globals");if((0,a.isStream)(e)){const r=e.getBytes();t.push({data:r,start:0,end:r.length})}}t.push({data:this.bytes,start:0,end:this.bytes.length});const r=e.parseChunks(t),i=r.length;for(let e=0;e>>0}var s=n(1),o=n(1)?n(1)?n(1)?n(1)?n(1)?n(32)+4436:n(12)+340:n(8)+84:n(6)+20:n(4)+4:n(2);return 0===s?o:o>0?-o:null}function c(e,t,r){for(var a=e.getContexts("IAID"),i=1,n=0;n=L&&_=O)for(H=H<<1&y,f=0;f=0&&T=0&&(E=B[P][T])&&(H|=E<=e?L<<=1:L=L<<1|x[F][R];for(d=0;d=k||R<0||R>=A?L<<=1:L=L<<1|a[F][R];var O=C.readBit(_,L);I[E]=O}}return x}function m(e,t,a,i,n,s,l,h,u,d,f,g,m,b,y,v,w,A,k){if(e&&t)throw new o("refinement with Huffman is not supported");var S,x,C=[];for(S=0;S1&&(i=e?k.readBits(A):r(T,"IAIT",P));var R=l*I+i,L=e?b.symbolIDTable.decode(k):c(T,P,u),O=t&&(e?k.readBit():r(T,"IARI",P)),M=h[L],D=M[0].length,N=M.length;if(O){var B=r(T,"IARDW",P),U=r(T,"IARDH",P);M=p(D+=B,N+=U,y,M,(B>>1)+r(T,"IARDX",P),(U>>1)+r(T,"IARDY",P),!1,v,w)}var j,q,H,G=R-(1&g?0:N-1),z=F-(2&g?D-1:0);if(d){for(j=0;j>5&7,u=[31&c],d=t+6;if(7===c){h=536870911&(0,i.readUint32)(e,d-1),d+=3;var f=h+7>>3;for(u[0]=e[d++];--f>0;)u.push(e[d++])}else if(5===c||6===c)throw new o("invalid referred-to flags");r.retainBits=u;let g=4;r.number<=256?g=1:r.number<=65536&&(g=2);var p,m,b=[];for(p=0;p>>24&255,k[3]=y.height>>16&255,k[4]=y.height>>8&255,k[5]=255&y.height,p=d,m=e.length;p>2&3,d.huffmanDWSelector=f>>4&3,d.bitmapSizeSelector=f>>6&1,d.aggregationInstancesSelector=f>>7&1,d.bitmapCodingContextUsed=!!(256&f),d.bitmapCodingContextRetained=!!(512&f),d.template=f>>10&3,d.refinementTemplate=f>>12&1,h+=2,!d.huffman){for(s=0===d.template?4:1,a=[],n=0;n>2&3,g.stripSize=1<>4&3,g.transposed=!!(64&p),g.combinationOperator=p>>7&3,g.defaultPixelValue=p>>9&1,g.dsOffset=p<<17>>27,g.refinementTemplate=p>>15&1,g.huffman){var m=(0,i.readUint16)(l,h);h+=2,g.huffmanFS=3&m,g.huffmanDS=m>>2&3,g.huffmanDT=m>>4&3,g.huffmanRefinementDW=m>>6&3,g.huffmanRefinementDH=m>>8&3,g.huffmanRefinementDX=m>>10&3,g.huffmanRefinementDY=m>>12&3,g.huffmanRefinementSizeSelector=!!(16384&m)}if(g.refinement&&!g.refinementTemplate){for(a=[],n=0;n<2;n++)a.push({x:(0,i.readInt8)(l,h),y:(0,i.readInt8)(l,h+1)}),h+=2;g.refinementAt=a}g.numberOfSymbolInstances=(0,i.readUint32)(l,h),h+=4,r=[g,c.referredTo,l,h,u];break;case 16:const e={},t=l[h++];e.mmr=!!(1&t),e.template=t>>1&3,e.patternWidth=l[h++],e.patternHeight=l[h++],e.maxPatternIndex=(0,i.readUint32)(l,h),h+=4,r=[e,c.number,l,h,u];break;case 22:case 23:const S={};S.info=v(l,h),h+=w;const x=l[h++];S.mmr=!!(1&x),S.template=x>>1&3,S.enableSkip=!!(8&x),S.combinationOperator=x>>4&7,S.defaultPixelValue=x>>7&1,S.gridWidth=(0,i.readUint32)(l,h),h+=4,S.gridHeight=(0,i.readUint32)(l,h),h+=4,S.gridOffsetX=4294967295&(0,i.readUint32)(l,h),h+=4,S.gridOffsetY=4294967295&(0,i.readUint32)(l,h),h+=4,S.gridVectorX=(0,i.readUint16)(l,h),h+=2,S.gridVectorY=(0,i.readUint16)(l,h),h+=2,r=[S,c.referredTo,l,h,u];break;case 38:case 39:var b={};b.info=v(l,h),h+=w;var y=l[h++];if(b.mmr=!!(1&y),b.template=y>>1&3,b.prediction=!!(8&y),!b.mmr){for(s=0===b.template?4:1,a=[],n=0;n>2&1,A.combinationOperator=k>>3&3,A.requiresBuffer=!!(32&k),A.combinationOperatorOverride=!!(64&k),r=[A];break;case 49:case 50:case 51:break;case 53:r=[c.number,l,h,u];break;case 62:break;default:throw new o(`segment type ${c.typeName}(${c.type}) is not implemented`)}var S="on"+c.typeName;S in t&&t[S].apply(t,r)}function k(e,t){for(var r=0,a=e.length;r0&&this.rootNode.buildTree(r,r.prefixLength-1)}}S.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var a=0,i=r.length;a>3,u=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,d=this.buffer,f=128>>(7&e.x),g=e.y*h+(e.x>>3);switch(u){case 0:for(r=0;r>=1)||(i=128,n++);g+=h}break;case 2:for(r=0;r>=1)||(i=128,n++);g+=h}break;default:throw new o(`operator ${u} is not supported`)}},onImmediateGenericRegion:function(e,r,a,i){var n=e.info,s=new t(r,a,i),o=g(e.mmr,n.width,n.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(n,o)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,a,n,s,l,h){let u,d;e.huffman&&(u=function(e,t,r){let a,i,n,s,c=0;switch(e.huffmanDHSelector){case 0:case 1:a=T(e.huffmanDHSelector+4);break;case 3:a=E(c,t,r),c++;break;default:throw new o("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:i=T(e.huffmanDWSelector+2);break;case 3:i=E(c,t,r),c++;break;default:throw new o("invalid Huffman DW selector")}return e.bitmapSizeSelector?(n=E(c,t,r),c++):n=T(1),s=e.aggregationInstancesSelector?E(c,t,r):T(1),{tableDeltaHeight:a,tableDeltaWidth:i,tableBitmapSize:n,tableAggregateInstances:s}}(e,n,this.customTables),d=new I(s,l,h));var f=this.symbols;f||(this.symbols=f={});for(var b=[],y=0,v=n.length;y1)_=m(e,t,i,w,0,I,1,a.concat(v),A,0,0,1,0,l,d,f,b,0,y);else{var E=c(S,k,A),L=r(S,"IARDX",k),O=r(S,"IARDY",k);_=p(i,w,d,E=32){let r,a,s;switch(t){case 32:if(0===e)throw new o("no previous value in symbol ID table");a=i.readBits(2)+3,r=n[e-1].prefixLength;break;case 33:a=i.readBits(3)+3,r=0;break;case 34:a=i.readBits(7)+11,r=0;break;default:throw new o("invalid code length in symbol ID table")}for(s=0;s=0;v--)F=e?R(E,h,u,!0):g(!1,h,u,r,!1,null,P,b),T[v]=F;for(L=0;L=0;w--)M=T[w][L][O]^M,D|=M<>8,U=f+L*p-O*m>>8,B>=0&&B+x<=a&&U>=0&&U+C<=n)for(v=0;v=n))for(q=y[t],j=N[v],w=0;w=0&&e>1&7),l=1+(a>>4&7),h=[];let u,d,f=n;do{u=o.readBits(c),d=o.readBits(l),h.push(new x([f,u,d,0])),f+=1<>t&1;if(t<=0)this.children[r]=new C(e);else{let a=this.children[r];a||(this.children[r]=a=new C(null)),a.buildTree(e,t-1)}},decodeNode(e){if(this.isLeaf){if(this.isOOB)return null;const t=e.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-t:t)}const t=this.children[e.readBit()];if(!t)throw new o("invalid Huffman data");return t.decodeNode(e)}},_.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let r=0;for(let a=0;a>r&1,r--}if(a&&!l){const e=5;for(let t=0;t=this.end)throw new o("end of data while reading bit");this.currentByte=this.data[this.position++],this.shift=7}const e=this.currentByte>>this.shift&1;return this.shift--,e},readBits(e){let t,r=0;for(t=e-1;t>=0;t--)r|=this.readBit()<=this.end?-1:this.data[this.position++]}},L.prototype={parseChunks:e=>function(e){for(var t=new S,r=0,a=e.length;r>=1}return{imgData:d,width:l,height:h}}(e);return this.width=r,this.height=a,t}},L}();t.Jbig2Image=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ArithmeticDecoder=void 0;const a=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];t.ArithmeticDecoder=class{constructor(e,t,r){this.data=e,this.bp=t,this.dataEnd=r,this.chigh=e[t],this.clow=0,this.byteIn(),this.chigh=this.chigh<<7&65535|this.clow>>9&127,this.clow=this.clow<<7&65535,this.ct-=7,this.a=32768}byteIn(){const e=this.data;let t=this.bp;255===e[t]?e[t+1]>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t):(t++,this.clow+=t65535&&(this.chigh+=this.clow>>16,this.clow&=65535)}readBit(e,t){let r=e[t]>>1,i=1&e[t];const n=a[r],s=n.qe;let o,c=this.a-s;if(this.chigh>15&1,this.clow=this.clow<<1&65535,this.ct--}while(0==(32768&c));return this.a=c,e[t]=r<<1|i,o}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegStream=void 0;var a=r(12),i=r(5),n=r(19),s=r(2);const o=function(){function e(e,t,r,i){let n;for(;-1!==(n=e.getByte());)if(255===n){e.skip(-1);break}this.stream=e,this.maybeLength=t,this.dict=r,this.params=i,a.DecodeStream.call(this,t)}return e.prototype=Object.create(a.DecodeStream.prototype),Object.defineProperty(e.prototype,"bytes",{get:function(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0}),e.prototype.ensureBuffer=function(e){},e.prototype.readBlock=function(){if(this.eof)return;const e={decodeTransform:void 0,colorTransform:void 0},t=this.dict.getArray("Decode","D");if(this.forceRGB&&Array.isArray(t)){const r=this.dict.get("BitsPerComponent")||8,a=t.length,i=new Int32Array(a);let n=!1;const s=(1<0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(r=0;r0;)c=n.pop();for(c.index++,n.push(c);n.length<=r;)n.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o;i++}r+10)return k--,A>>k&1;if(A=t[r++],255===A){var e=t[r++];if(e){if(220===e&&b){r+=2;const e=(0,i.readUint16)(t,r);if(r+=2,e>0&&e!==l.scanLines)throw new s("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(b){const e=8*E;if(e>0&&e>>7}function x(e){for(var t=e;;){switch(typeof(t=t[S()])){case"number":return t;case"object":continue}throw new n("invalid huffman sequence")}}function C(e){for(var t=0;e>0;)t=t<<1|S(),e--;return t}function _(e){if(1===e)return 1===S()?1:-1;var t=C(e);return t>=1<0)T--;else for(var a=f,i=g;a<=i;){var n=x(t.huffmanTableAC),s=15&n,o=n>>4;if(0!==s){var c=e[a+=o];t.blockData[r+c]=_(s)*(1<>4,0==(a=15&i))c<15?(T=C(c)+(1<>4;if(0!==o){var l=e[n+=c];t.blockData[r+l]=_(o),n++}else{if(c<15)break;n+=16}}};var j,q,H,G,z=0;for(q=1===U?h[0].blocksPerLine*h[0].blocksPerColumn:y*l.mcusPerColumn;z<=q;){var W=u?Math.min(q-z,u):q;if(W>0){for(O=0;O0?"unexpected":"excessive";(0,a.warn)(`decodeScan - ${e} MCU data, current marker is: ${j.invalid}`),r=j.offset}if(!(j.marker>=65488&&j.marker<=65495))break;r+=2}return r-w}function h(e,t,r){var a,i,s,o,c,l,h,u,d,f,g,p,m,b,y,v,w,A=e.quantizationTable,k=e.blockData;if(!A)throw new n("missing required Quantization Table.");for(var S=0;S<64;S+=8)d=k[t+S],f=k[t+S+1],g=k[t+S+2],p=k[t+S+3],m=k[t+S+4],b=k[t+S+5],y=k[t+S+6],v=k[t+S+7],d*=A[S],0!=(f|g|p|m|b|y|v)?(f*=A[S+1],g*=A[S+2],p*=A[S+3],m*=A[S+4],b*=A[S+5],i=(a=(a=5793*d+128>>8)+(i=5793*m+128>>8)+1>>1)-i,w=3784*(s=g)+1567*(o=y*=A[S+6])+128>>8,s=1567*s-3784*o+128>>8,h=(c=(c=2896*(f-(v*=A[S+7]))+128>>8)+(h=b<<4)+1>>1)-h,l=(u=(u=2896*(f+v)+128>>8)+(l=p<<4)+1>>1)-l,o=(a=a+(o=w)+1>>1)-o,s=(i=i+s+1>>1)-s,w=2276*c+3406*u+2048>>12,c=3406*c-2276*u+2048>>12,u=w,w=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,h=w,r[S]=a+u,r[S+7]=a-u,r[S+1]=i+h,r[S+6]=i-h,r[S+2]=s+l,r[S+5]=s-l,r[S+3]=o+c,r[S+4]=o-c):(w=5793*d+512>>10,r[S]=w,r[S+1]=w,r[S+2]=w,r[S+3]=w,r[S+4]=w,r[S+5]=w,r[S+6]=w,r[S+7]=w);for(var x=0;x<8;++x)d=r[x],0!=((f=r[x+8])|(g=r[x+16])|(p=r[x+24])|(m=r[x+32])|(b=r[x+40])|(y=r[x+48])|(v=r[x+56]))?(i=(a=4112+((a=5793*d+2048>>12)+(i=5793*m+2048>>12)+1>>1))-i,w=3784*(s=g)+1567*(o=y)+2048>>12,s=1567*s-3784*o+2048>>12,o=w,h=(c=(c=2896*(f-v)+2048>>12)+(h=b)+1>>1)-h,l=(u=(u=2896*(f+v)+2048>>12)+(l=p)+1>>1)-l,w=2276*c+3406*u+2048>>12,c=3406*c-2276*u+2048>>12,u=w,w=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,(d=(a=a+o+1>>1)+u)<16?d=0:d>=4080?d=255:d>>=4,(f=(i=i+s+1>>1)+(h=w))<16?f=0:f>=4080?f=255:f>>=4,(g=(s=i-s)+l)<16?g=0:g>=4080?g=255:g>>=4,(p=(o=a-o)+c)<16?p=0:p>=4080?p=255:p>>=4,(m=o-c)<16?m=0:m>=4080?m=255:m>>=4,(b=s-l)<16?b=0:b>=4080?b=255:b>>=4,(y=i-h)<16?y=0:y>=4080?y=255:y>>=4,(v=a-u)<16?v=0:v>=4080?v=255:v>>=4,k[t+x]=d,k[t+x+8]=f,k[t+x+16]=g,k[t+x+24]=p,k[t+x+32]=m,k[t+x+40]=b,k[t+x+48]=y,k[t+x+56]=v):(w=(w=5793*d+8192>>14)<-2040?0:w>=2024?255:w+2056>>4,k[t+x]=w,k[t+x+8]=w,k[t+x+16]=w,k[t+x+24]=w,k[t+x+32]=w,k[t+x+40]=w,k[t+x+48]=w,k[t+x+56]=w)}function u(e,t){for(var r=t.blocksPerLine,a=t.blocksPerColumn,i=new Int16Array(64),n=0;n=a)return null;var s=(0,i.readUint16)(e,t);if(s>=65472&&s<=65534)return{invalid:null,marker:s,offset:t};for(var o=(0,i.readUint16)(e,n);!(o>=65472&&o<=65534);){if(++n>=a)return null;o=(0,i.readUint16)(e,n)}return{invalid:s.toString(16),marker:o,offset:n}}return t.prototype={parse(t,{dnlScanLines:c=null}={}){function h(){const e=(0,i.readUint16)(t,m);let r=(m+=2)+e-2;var n=d(t,r,m);n&&n.invalid&&((0,a.warn)("readDataBlock - incorrect length, current marker is: "+n.invalid),r=n.offset);var s=t.subarray(m,r);return m+=s.length,s}function f(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),a=0;a>4==0)for(C=0;C<64;C++)E[e[C]]=t[m++];else{if(I>>4!=1)throw new n("DQT - invalid table spec");for(C=0;C<64;C++)E[e[C]]=(0,i.readUint16)(t,m),m+=2}w[15&I]=E}break;case 65472:case 65473:case 65474:if(g)throw new n("Only single frame JPEGs supported");m+=2,(g={}).extended=65473===S,g.progressive=65474===S,g.precision=t[m++];const u=(0,i.readUint16)(t,m);m+=2,g.scanLines=c||u,g.samplesPerLine=(0,i.readUint16)(t,m),m+=2,g.components=[],g.componentIds={};var F,R=t[m++],L=0,O=0;for(x=0;x>4,D=15&t[m+1];L>4==0?k:A)[15&B]=r(U,q)}break;case 65501:m+=2,p=(0,i.readUint16)(t,m),m+=2;break;case 65498:const J=1==++v&&!c;m+=2;var H,G=t[m++],z=[];for(x=0;x>4],H.huffmanTableAC=A[15&V],z.push(H)}var X=t[m++],Y=t[m++],K=t[m++];try{var $=l(t,m,g,z,p,X,Y,K>>4,15&K,J);m+=$}catch(e){if(e instanceof s)return(0,a.warn)(e.message+" -- attempting to re-parse the JPEG image."),this.parse(t,{dnlScanLines:e.scanLines});if(e instanceof o){(0,a.warn)(e.message+" -- ignoring the rest of the image data.");break e}throw e}break;case 65500:m+=4;break;case 65535:255!==t[m]&&m--;break;default:const Z=d(t,m-2,m-3);if(Z&&Z.invalid){(0,a.warn)("JpegImage.parse - unexpected data, current marker is: "+Z.invalid),m=Z.offset;break}if(m>=t.length-1){(0,a.warn)("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break e}throw new n("JpegImage.parse - unknown marker: "+S.toString(16))}S=(0,i.readUint16)(t,m),m+=2}for(this.width=g.samplesPerLine,this.height=g.scanLines,this.jfif=b,this.adobe=y,this.components=[],x=0;x>8)+k[u+1];return v},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform:1===this._colorTransform},_convertYccToRgb:function(e){for(var t,r,a,i=0,n=e.length;i4)throw new n("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,a);if(1===this.numComponents&&r){for(var s=i.length,o=new Uint8ClampedArray(3*s),c=0,l=0;l0?Math.min(a.xcb,i.PPx-1):Math.min(a.xcb,i.PPx),i.ycb_=r>0?Math.min(a.ycb,i.PPy-1):Math.min(a.ycb,i.PPy),i}function l(e,t,r){var a=1<t.trx0?Math.ceil(t.trx1/a)-Math.floor(t.trx0/a):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={precinctWidth:a,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function h(e,t,r){var a,i,n,s,o=r.xcb_,c=r.ycb_,l=1<>o,d=t.tby0>>c,f=t.tbx1+l-1>>o,g=t.tby1+h-1>>c,p=t.resolution.precinctParameters,m=[],b=[];for(i=d;iy.cbxMax&&(y.cbxMax=a),iy.cbyMax&&(y.cbyMax=i)):b[s]=y={cbxMin:a,cbyMin:i,cbxMax:a,cbyMax:i},n.precinct=y}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:f-u+1,numcodeblockhigh:g-d+1},t.codeblocks=m,t.precincts=b}function u(e,t,r){for(var a=[],i=e.subbands,n=0,s=i.length;ne.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],r=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;fs.codingStyleParameters.decompositionLevelsCount)){var e=s.resolutions[r],n=e.precinctParameters.numprecincts;if(!(i>=n)){for(;t=0;--m){var b=c.resolutions[m],y=p*b.precinctParameters.precinctWidth,v=p*b.precinctParameters.precinctHeight;u=Math.min(u,y),d=Math.min(d,v),f=Math.max(f,b.precinctParameters.numprecinctswide),g=Math.max(g,b.precinctParameters.numprecinctshigh),h[m]={width:y,height:v},p<<=1}r=Math.min(r,u),a=Math.min(a,d),i=Math.max(i,f),n=Math.max(n,g),s[o]={resolutions:h,minWidth:u,minHeight:d,maxNumWide:f,maxNumHigh:g}}return{components:s,minWidth:r,minHeight:a,maxNumWide:i,maxNumHigh:n}}function v(e){for(var t=e.SIZ,r=e.currentTile.index,a=e.tiles[r],i=t.Csiz,n=0;n>>(o-=e)&(1<0;){var U=k.shift();void 0===(w=U.codeblock).data&&(w.data=[]),w.data.push({data:t,start:r+s,end:r+s+U.dataLength,codingpasses:U.codingpasses}),s+=U.dataLength}}}return s}function A(e,t,r,a,i,s,o,c){for(var l=a.tbx0,h=a.tby0,u=a.tbx1-a.tbx0,d=a.codeblocks,f="H"===a.type.charAt(0)?1:0,g="H"===a.type.charAt(1)?t:0,p=0,m=d.length;p=s?O:O*(1<0?1-b:0));var P=y.subbands[S],E=e[P.type];A(k,v,0,P,f?1:2**(d+E-_)*(1+C/2048),h+_-1,f,u)}p.push({width:v,height:w,items:k})}var F=g.calculate(p,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:F.width,height:F.height,items:F.items}}function S(e,t){for(var r=e.SIZ.Csiz,a=e.tiles[t],i=0;i>24&255,c>>16&255,c>>8&255,255&c);(0,a.warn)("Unsupported header type "+c+" ("+f+")")}h&&(t+=l)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function(e){for(var t=e.getByte();t>=0;)if(65361==(t<<8|(t=e.getByte()))){e.skip(4);var r=e.getInt32()>>>0,a=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0;e.skip(16);var o=e.getUint16();return this.width=r-i,this.height=a-n,this.componentsCount=o,void(this.bitsPerComponent=8)}throw new s("No size marker found in JPX stream")},parseCodestream:function(e,t,n){var c={},l=!1;try{for(var h=t;h+1>5,g=[];d>3,I.mu=0):(I.epsilon=e[d]>>3,I.mu=(7&e[d])<<8|e[d+1],d+=2),g.push(I)}T.SPqcds=g,c.mainHeader?c.QCD=T:(c.currentTile.QCD=T,c.currentTile.QCC=[]);break;case 65373:y=(0,i.readUint16)(e,h);var E,F={};switch(d=h+2,c.SIZ.Csiz<257?E=e[d++]:(E=(0,i.readUint16)(e,d),d+=2),31&(f=e[d++])){case 0:p=8,m=!0;break;case 1:p=16,m=!1;break;case 2:p=16,m=!0;break;default:throw new Error("Invalid SQcd value "+f)}for(F.noQuantization=8===p,F.scalarExpounded=m,F.guardBits=f>>5,g=[];d>3,I.mu=0):(I.epsilon=e[d]>>3,I.mu=(7&e[d])<<8|e[d+1],d+=2),g.push(I);F.SPqcds=g,c.mainHeader?c.QCC[E]=F:c.currentTile.QCC[E]=F;break;case 65362:y=(0,i.readUint16)(e,h);var R={};d=h+2;var L=e[d++];R.entropyCoderWithCustomPrecincts=!!(1&L),R.sopMarkerUsed=!!(2&L),R.ephMarkerUsed=!!(4&L),R.progressionOrder=e[d++],R.layersCount=(0,i.readUint16)(e,d),d+=2,R.multipleComponentTransform=e[d++],R.decompositionLevelsCount=e[d++],R.xcb=2+(15&e[d++]),R.ycb=2+(15&e[d++]);var O=e[d++];if(R.selectiveArithmeticCodingBypass=!!(1&O),R.resetContextProbabilities=!!(2&O),R.terminationOnEachCodingPass=!!(4&O),R.verticallyStripe=!!(8&O),R.predictableTermination=!!(16&O),R.segmentationSymbolUsed=!!(32&O),R.reversibleTransformation=e[d++],R.entropyCoderWithCustomPrecincts){for(var M=[];d>4})}R.precinctsSizes=M}var N=[];if(R.selectiveArithmeticCodingBypass&&N.push("selectiveArithmeticCodingBypass"),R.resetContextProbabilities&&N.push("resetContextProbabilities"),R.terminationOnEachCodingPass&&N.push("terminationOnEachCodingPass"),R.verticallyStripe&&N.push("verticallyStripe"),R.predictableTermination&&N.push("predictableTermination"),N.length>0)throw l=!0,new Error("Unsupported COD options ("+N.join(", ")+")");c.mainHeader?c.COD=R:(c.currentTile.COD=R,c.currentTile.COC=[]);break;case 65424:y=(0,i.readUint16)(e,h),(b={}).index=(0,i.readUint16)(e,h+2),b.length=(0,i.readUint32)(e,h+4),b.dataEnd=b.length+h-2,b.partIndex=e[h+8],b.partsCount=e[h+9],c.mainHeader=!1,0===b.partIndex&&(b.COD=c.COD,b.COC=c.COC.slice(0),b.QCD=c.QCD,b.QCC=c.QCC.slice(0)),c.currentTile=b;break;case 65427:0===(b=c.currentTile).partIndex&&(S(c,b.index),v(c)),w(c,e,h,y=b.dataEnd-h);break;case 65365:case 65367:case 65368:case 65380:y=(0,i.readUint16)(e,h);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+u.toString(16))}h+=y}}catch(e){if(l||this.failOnCorruptedImage)throw new s(e.message);(0,a.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function(e){for(var t=e.SIZ,r=e.components,a=t.Csiz,i=[],n=0,s=e.tiles.length;n>2);y[w++]=e+m>>h,y[w++]=e>>h,y[w++]=e+p>>h}else for(d=0;d>h,y[w++]=g-.34413*p-.71414*m>>h,y[w++]=g+1.772*p>>h;if(A)for(d=0,w=3;d>h}else for(o=0;o>h,w+=a}i.push(v)}return i}(c),this.width=c.SIZ.Xsiz-c.SIZ.XOsiz,this.height=c.SIZ.Ysiz-c.SIZ.YOsiz,this.componentsCount=c.SIZ.Csiz}};var x=function(){function e(e,t){var r=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var a=0;a>=1,t>>=1,a++}a--,(r=this.levels[a]).items[r.index]=i,this.currentLevel=a,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return--e<0?(this.value=r,!1):(this.currentLevel=e,(t=this.levels[e]).items[t.index]=r,!0)}},e}(),C=function(){function e(e,t,r){var a=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var n=0;nr)return this.currentLevel=a,this.propagateValues(),!1;e>>=1,t>>=1,a++}return this.currentLevel=a-1,!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=r},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];return t.items[t.index]=255,!(--e<0||(this.currentLevel=e,(t=this.levels[e]).items[t.index]=r,0))}},e}(),_=function(){var e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),t=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),r=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function a(a,i,n,s,o){let c;this.width=a,this.height=i,c="HH"===n?r:"HL"===n?t:e,this.contextLabelTable=c;var l=a*i;let h;this.neighborsSignificance=new Uint8Array(l),this.coefficentsSign=new Uint8Array(l),h=o>14?new Uint32Array(l):o>6?new Uint16Array(l):new Uint8Array(l),this.coefficentsMagnitude=h,this.processingFlags=new Uint8Array(l);var u=new Uint8Array(l);if(0!==s)for(var d=0;d0,c=t+10&&(a=r-n,o&&(i[a-1]+=16),c&&(i[a+1]+=16),i[a]+=4),e+1=r)break;if(s[d]&=-2,!a[d]&&n[d]){var p=c[n[d]];if(e.readBit(o,p)){var m=this.decodeSignBit(g,u,d);i[d]=m,a[d]=1,this.setNeighborsSignificance(g,u,d),s[d]|=2}l[d]++,s[d]|=1}}},decodeSignBit:function(e,t,r){var a,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==u[r-1],t+10&&0!==u[r-l],e+1=0?(o=9+a,c=this.decoder.readBit(this.contexts,o)):(o=9-a,c=1^this.decoder.readBit(this.contexts,o)),c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,r=this.width,a=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=r*a,h=4*r,u=0;u>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,d=1.230174104914001;for(a=(t|=0)-3,i=o+4;i--;a+=2)e[a]*=.8128930661159609;for(n=u*e[(a=t-2)-1],i=o+3;i--&&(s=u*e[a+1],e[a]=d*e[a]-n-s,i--);a+=2)n=u*e[(a+=2)+1],e[a]=d*e[a]-n-s;for(n=h*e[(a=t-1)-1],i=o+2;i--&&(s=h*e[a+1],e[a]-=n+s,i--);a+=2)n=h*e[(a+=2)+1],e[a]-=n+s;for(n=l*e[(a=t)-1],i=o+1;i--&&(s=l*e[a+1],e[a]-=n+s,i--);a+=2)n=l*e[(a+=2)+1],e[a]-=n+s;if(0!==o)for(n=c*e[(a=t+1)-1],i=o;i--&&(s=c*e[a+1],e[a]-=n+s,i--);a+=2)n=c*e[(a+=2)+1],e[a]-=n+s},e}(),I=function(){function e(){P.call(this)}return e.prototype=Object.create(P.prototype),e.prototype.filter=function(e,t,r){var a,i,n=r>>1;for(a=t|=0,i=n+1;i--;a+=2)e[a]-=e[a-1]+e[a+1]+2>>2;for(a=t+1,i=n;i--;a+=2)e[a]+=e[a-1]+e[a+1]>>1},e}();return t}();t.JpxImage=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculateSHA512=t.calculateSHA384=t.calculateSHA256=t.calculateMD5=t.PDF20=t.PDF17=t.CipherTransformFactory=t.ARCFourCipher=t.AES256Cipher=t.AES128Cipher=void 0;var a=r(2),i=r(5),n=r(12),s=function(){function e(e){this.a=0,this.b=0;var t,r,a=new Uint8Array(256),i=0,n=e.length;for(t=0;t<256;++t)a[t]=t;for(t=0;t<256;++t)i=i+(r=a[t])+e[t%n]&255,a[t]=a[i],a[i]=r;this.s=a}return e.prototype={encryptBlock:function(e){var t,r,a,i=e.length,n=this.a,s=this.b,o=this.s,c=new Uint8Array(i);for(t=0;t>5&255,f[a++]=r>>13&255,f[a++]=r>>21&255,f[a++]=r>>>29&255,f[a++]=0,f[a++]=0,f[a++]=0;var g=new Int32Array(16);for(a=0;a>>32-S)|0,b=A}s=s+b|0,l=l+y|0,h=h+v|0,u=u+w|0}return new Uint8Array([255&s,s>>8&255,s>>16&255,s>>>24&255,255&l,l>>8&255,l>>16&255,l>>>24&255,255&h,h>>8&255,h>>16&255,h>>>24&255,255&u,u>>8&255,u>>16&255,u>>>24&255])});t.calculateMD5=l;var h=function(){function e(e,t){this.high=0|e,this.low=0|t}return e.prototype={and:function(e){this.high&=e.high,this.low&=e.low},xor:function(e){this.high^=e.high,this.low^=e.low},or:function(e){this.high|=e.high,this.low|=e.low},shiftRight:function(e){e>=32?(this.low=this.high>>>e-32|0,this.high=0):(this.low=this.low>>>e|this.high<<32-e,this.high=this.high>>>e|0)},shiftLeft:function(e){e>=32?(this.high=this.low<>>32-e,this.low=this.low<>>e|r<<32-e,this.high=r>>>e|t<<32-e},not:function(){this.high=~this.high,this.low=~this.low},add:function(e){var t=(this.low>>>0)+(e.low>>>0),r=(this.high>>>0)+(e.high>>>0);t>4294967295&&(r+=1),this.low=0|t,this.high=0|r},copyTo:function(e,t){e[t]=this.high>>>24&255,e[t+1]=this.high>>16&255,e[t+2]=this.high>>8&255,e[t+3]=255&this.high,e[t+4]=this.low>>>24&255,e[t+5]=this.low>>16&255,e[t+6]=this.low>>8&255,e[t+7]=255&this.low},assign:function(e){this.high=e.high,this.low=e.low}},e}(),u=function(){function e(e,t){return e>>>t|e<<32-t}function t(e,t,r){return e&t^~e&r}function r(e,t,r){return e&t^e&r^t&r}function a(t){return e(t,2)^e(t,13)^e(t,22)}function i(t){return e(t,6)^e(t,11)^e(t,25)}function n(t){return e(t,7)^e(t,18)^t>>>3}var s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return function(o,c,l){var h,u,d,f=1779033703,g=3144134277,p=1013904242,m=2773480762,b=1359893119,y=2600822924,v=528734635,w=1541459225,A=64*Math.ceil((l+9)/64),k=new Uint8Array(A);for(h=0;h>>29&255,k[h++]=l>>21&255,k[h++]=l>>13&255,k[h++]=l>>5&255,k[h++]=l<<3&255;var S,x=new Uint32Array(64);for(h=0;h>>10)+x[u-7]+n(x[u-15])+x[u-16];var C,_,P=f,T=g,I=p,E=m,F=b,R=y,L=v,O=w;for(u=0;u<64;++u)C=O+i(F)+t(F,R,L)+s[u]+x[u],_=a(P)+r(P,T,I),O=L,L=R,R=F,F=E+C|0,E=I,I=T,T=P,P=C+_|0;f=f+P|0,g=g+T|0,p=p+I|0,m=m+E|0,b=b+F|0,y=y+R|0,v=v+L|0,w=w+O|0}return new Uint8Array([f>>24&255,f>>16&255,f>>8&255,255&f,g>>24&255,g>>16&255,g>>8&255,255&g,p>>24&255,p>>16&255,p>>8&255,255&p,m>>24&255,m>>16&255,m>>8&255,255&m,b>>24&255,b>>16&255,b>>8&255,255&b,y>>24&255,y>>16&255,y>>8&255,255&y,v>>24&255,v>>16&255,v>>8&255,255&v,w>>24&255,w>>16&255,w>>8&255,255&w])}}();t.calculateSHA256=u;var d=function(){function e(e,t,r,a,i){e.assign(t),e.and(r),i.assign(t),i.not(),i.and(a),e.xor(i)}function t(e,t,r,a,i){e.assign(t),e.and(r),i.assign(t),i.and(a),e.xor(i),i.assign(r),i.and(a),e.xor(i)}function r(e,t,r){e.assign(t),e.rotateRight(28),r.assign(t),r.rotateRight(34),e.xor(r),r.assign(t),r.rotateRight(39),e.xor(r)}function a(e,t,r){e.assign(t),e.rotateRight(14),r.assign(t),r.rotateRight(18),e.xor(r),r.assign(t),r.rotateRight(41),e.xor(r)}function i(e,t,r){e.assign(t),e.rotateRight(1),r.assign(t),r.rotateRight(8),e.xor(r),r.assign(t),r.shiftRight(7),e.xor(r)}function n(e,t,r){e.assign(t),e.rotateRight(19),r.assign(t),r.rotateRight(61),e.xor(r),r.assign(t),r.shiftRight(6),e.xor(r)}var s=[new h(1116352408,3609767458),new h(1899447441,602891725),new h(3049323471,3964484399),new h(3921009573,2173295548),new h(961987163,4081628472),new h(1508970993,3053834265),new h(2453635748,2937671579),new h(2870763221,3664609560),new h(3624381080,2734883394),new h(310598401,1164996542),new h(607225278,1323610764),new h(1426881987,3590304994),new h(1925078388,4068182383),new h(2162078206,991336113),new h(2614888103,633803317),new h(3248222580,3479774868),new h(3835390401,2666613458),new h(4022224774,944711139),new h(264347078,2341262773),new h(604807628,2007800933),new h(770255983,1495990901),new h(1249150122,1856431235),new h(1555081692,3175218132),new h(1996064986,2198950837),new h(2554220882,3999719339),new h(2821834349,766784016),new h(2952996808,2566594879),new h(3210313671,3203337956),new h(3336571891,1034457026),new h(3584528711,2466948901),new h(113926993,3758326383),new h(338241895,168717936),new h(666307205,1188179964),new h(773529912,1546045734),new h(1294757372,1522805485),new h(1396182291,2643833823),new h(1695183700,2343527390),new h(1986661051,1014477480),new h(2177026350,1206759142),new h(2456956037,344077627),new h(2730485921,1290863460),new h(2820302411,3158454273),new h(3259730800,3505952657),new h(3345764771,106217008),new h(3516065817,3606008344),new h(3600352804,1432725776),new h(4094571909,1467031594),new h(275423344,851169720),new h(430227734,3100823752),new h(506948616,1363258195),new h(659060556,3750685593),new h(883997877,3785050280),new h(958139571,3318307427),new h(1322822218,3812723403),new h(1537002063,2003034995),new h(1747873779,3602036899),new h(1955562222,1575990012),new h(2024104815,1125592928),new h(2227730452,2716904306),new h(2361852424,442776044),new h(2428436474,593698344),new h(2756734187,3733110249),new h(3204031479,2999351573),new h(3329325298,3815920427),new h(3391569614,3928383900),new h(3515267271,566280711),new h(3940187606,3454069534),new h(4118630271,4000239992),new h(116418474,1914138554),new h(174292421,2731055270),new h(289380356,3203993006),new h(460393269,320620315),new h(685471733,587496836),new h(852142971,1086792851),new h(1017036298,365543100),new h(1126000580,2618297676),new h(1288033470,3409855158),new h(1501505948,4234509866),new h(1607167915,987167468),new h(1816402316,1246189591)];return function(o,c,l,u){var d,f,g,p,m,b,y,v;(u=!!u)?(d=new h(3418070365,3238371032),f=new h(1654270250,914150663),g=new h(2438529370,812702999),p=new h(355462360,4144912697),m=new h(1731405415,4290775857),b=new h(2394180231,1750603025),y=new h(3675008525,1694076839),v=new h(1203062813,3204075428)):(d=new h(1779033703,4089235720),f=new h(3144134277,2227873595),g=new h(1013904242,4271175723),p=new h(2773480762,1595750129),m=new h(1359893119,2917565137),b=new h(2600822924,725511199),y=new h(528734635,4215389547),v=new h(1541459225,327033209));var w,A,k,S=128*Math.ceil((l+17)/128),x=new Uint8Array(S);for(w=0;w>>29&255,x[w++]=l>>21&255,x[w++]=l>>13&255,x[w++]=l>>5&255,x[w++]=l<<3&255;var C=new Array(80);for(w=0;w<80;w++)C[w]=new h(0,0);var _,P,T=new h(0,0),I=new h(0,0),E=new h(0,0),F=new h(0,0),R=new h(0,0),L=new h(0,0),O=new h(0,0),M=new h(0,0),D=new h(0,0),N=new h(0,0),B=new h(0,0),U=new h(0,0);for(w=0;w=1;--e){r=n[13],n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=r,r=n[14],a=n[10],n[14]=n[6],n[10]=n[2],n[6]=r,n[2]=a,r=n[15],a=n[11],i=n[7],n[15]=n[3],n[11]=r,n[7]=a,n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]];for(let r=0,a=16*e;r<16;++r,++a)n[r]^=t[a];for(let e=0;e<16;e+=4){const t=this._mix[n[e]],a=this._mix[n[e+1]],i=this._mix[n[e+2]],s=this._mix[n[e+3]];r=t^a>>>8^a<<24^i>>>16^i<<16^s>>>24^s<<8,n[e]=r>>>24&255,n[e+1]=r>>16&255,n[e+2]=r>>8&255,n[e+3]=255&r}}r=n[13],n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=r,r=n[14],a=n[10],n[14]=n[6],n[10]=n[2],n[6]=r,n[2]=a,r=n[15],a=n[11],i=n[7],n[15]=n[3],n[11]=r,n[7]=a,n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]],n[e]^=t[e];return n}_encrypt(e,t){const r=this._s;let a,i,n;const s=new Uint8Array(16);s.set(e);for(let e=0;e<16;++e)s[e]^=t[e];for(let e=1;e=a;--r)if(e[r]!==t){t=0;break}o-=t,n[n.length-1]=e.subarray(0,16-t)}}const c=new Uint8Array(o);for(let e=0,t=0,r=n.length;e=256&&(o=255&(27^o)));for(let t=0;t<4;++t)r[e]=a^=r[e-32],e++,r[e]=i^=r[e-32],e++,r[e]=n^=r[e-32],e++,r[e]=s^=r[e-32],e++}return r}}t.AES256Cipher=b;var y=function(){function e(e,t){if(e.length!==t.length)return!1;for(var r=0;rs-32;){var o=t.length+i.length+a.length,c=new Uint8Array(64*o),l=e(t,i);l=e(l,a);for(var h=0,g=0;h<64;h++,g+=o)c.set(l,g);n=new m(i.subarray(0,16)).encrypt(c,i.subarray(16,32));for(var p=0,b=0;b<16;b++)p*=1,p%=3,p+=(n[b]>>>0)%3,p%=3;0===p?i=u(n,0,n.length):1===p?i=f(n,0,n.length):2===p&&(i=d(n,0,n.length)),s++}return i.subarray(0,32)}function r(){}function a(e,t){if(e.length!==t.length)return!1;for(var r=0;r>8&255,g[p++]=n>>16&255,g[p++]=n>>>24&255,u=0,d=t.length;u=4&&!h&&(g[p++]=255,g[p++]=255,g[p++]=255,g[p++]=255);var m=l(g,0,p),b=c>>3;if(o>=3)for(u=0;u<50;++u)m=l(m,0,b);var y,v=m.subarray(0,b);if(o>=3){for(p=0;p<32;++p)g[p]=e[p];for(u=0,d=t.length;u>3;if(a>=3)for(n=0;n<50;++n)d=l(d,0,d.length);if(a>=3){u=r;var g,p=new Uint8Array(f);for(n=19;n>=0;n--){for(g=0;g=4){var L=n.get("CF");(0,i.isDict)(L)&&(L.suppressEncryption=!0),this.cf=L,this.stmf=n.get("StmF")||r,this.strf=n.get("StrF")||r,this.eff=n.get("EFF")||this.stmf}}function o(e,t,r,a){var i,n,s=new Uint8Array(r.length+9);for(i=0,n=r.length;i>8&255,s[i++]=e>>16&255,s[i++]=255&t,s[i++]=t>>8&255,a&&(s[i++]=115,s[i++]=65,s[i++]=108,s[i++]=84),l(s,0,i).subarray(0,Math.min(r.length+5,16))}function c(e,t,r,n,c){if(!(0,i.isName)(t))throw new a.FormatError("Invalid crypt filter name.");var l,h=e.get(t.name);if(null!=h&&(l=h.get("CFM")),!l||"None"===l.name)return function(){return new g};if("V2"===l.name)return function(){return new s(o(r,n,c,!1))};if("AESV2"===l.name)return function(){return new m(o(r,n,c,!0))};if("AESV3"===l.name)return function(){return new b(c)};throw new a.FormatError("Unknown crypto method")}return n.prototype={createCipherTransform:function(e,t){if(4===this.algorithm||5===this.algorithm)return new w(c(this.cf,this.stmf,e,t,this.encryptionKey),c(this.cf,this.strf,e,t,this.encryptionKey));var r=o(e,t,this.encryptionKey,!1),a=function(){return new s(r)};return new w(a,a)}},n}();t.CipherTransformFactory=A},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorSpace=void 0;var a=r(2),i=r(5);class n{constructor(e,t){this.constructor===n&&(0,a.unreachable)("Cannot initialize ColorSpace."),this.name=e,this.numComps=t}getRgb(e,t){const r=new Uint8ClampedArray(3);return this.getRgbItem(e,t,r,0),r}getRgbItem(e,t,r,i){(0,a.unreachable)("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,r,i,n,s,o){(0,a.unreachable)("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){(0,a.unreachable)("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return n.isDefaultDecode(e,this.numComps)}fillRgb(e,t,r,a,i,n,s,o,c){const l=t*r;let h=null;const u=1<u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=s<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e8?((e+16)/116)**3:e*((24/116)**3/8)}function f(a,n,f,g,p,m){const b=u(0,1,n[f]*m),y=u(0,1,n[f+1]*m),v=u(0,1,n[f+2]*m),w=b**a.GR,A=y**a.GG,k=v**a.GB,S=a.MXA*w+a.MXB*A+a.MXC*k,x=a.MYA*w+a.MYB*A+a.MYC*k,C=a.MZA*w+a.MZB*A+a.MZC*k,_=o;_[0]=S,_[1]=x,_[2]=C;const P=c;!function(r,a,i){if(1===r[0]&&1===r[2])return i[0]=a[0],i[1]=a[1],void(i[2]=a[2]);const n=i;l(e,a,n);const o=s;!function(e,t,r){r[0]=1*t[0]/e[0],r[1]=1*t[1]/e[1],r[2]=1*t[2]/e[2]}(r,n,o),l(t,o,i)}(a.whitePoint,_,P);const T=o;!function(e,t,r){if(0===e[0]&&0===e[1]&&0===e[2])return r[0]=t[0],r[1]=t[1],void(r[2]=t[2]);const a=d(0),i=(1-a)/(1-d(e[0])),n=1-i,s=(1-a)/(1-d(e[1])),o=1-s,c=(1-a)/(1-d(e[2])),l=1-c;r[0]=t[0]*i+n,r[1]=t[1]*s+o,r[2]=t[2]*c+l}(a.blackPoint,P,T);const I=c;!function(r,a,i){const n=i;l(e,a,n);const o=s;!function(e,t,r){r[0]=.95047*t[0]/e[0],r[1]=1*t[1]/e[1],r[2]=1.08883*t[2]/e[2]}(r,n,o),l(t,o,i)}(i,T,I);const E=o;l(r,I,E),g[p]=255*h(E[0]),g[p+1]=255*h(E[1]),g[p+2]=255*h(E[2])}return class extends n{constructor(e,t,r,i){if(super("CalRGB",3),!e)throw new a.FormatError("WhitePoint missing - required for color space CalRGB");t=t||new Float32Array(3),r=r||new Float32Array([1,1,1]),i=i||new Float32Array([1,0,0,0,1,0,0,0,1]);const n=e[0],s=e[1],o=e[2];this.whitePoint=e;const c=t[0],l=t[1],h=t[2];if(this.blackPoint=t,this.GR=r[0],this.GG=r[1],this.GB=r[2],this.MXA=i[0],this.MYA=i[1],this.MZA=i[2],this.MXB=i[3],this.MYB=i[4],this.MZB=i[5],this.MXC=i[6],this.MYC=i[7],this.MZC=i[8],n<0||o<0||1!==s)throw new a.FormatError("Invalid WhitePoint components for "+this.name+", no fallback available");(c<0||l<0||h<0)&&((0,a.info)(`Invalid BlackPoint for ${this.name} [${c}, ${l}, ${h}], falling back to default.`),this.blackPoint=new Float32Array(3)),(this.GR<0||this.GG<0||this.GB<0)&&((0,a.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for `+this.name+", falling back to default."),this.GR=this.GG=this.GB=1)}getRgbItem(e,t,r,a){f(this,e,t,r,a,1)}getRgbBuffer(e,t,r,a,i,n,s){const o=1/((1<=6/29?e*e*e:108/841*(e-4/29),t}function t(e,t,r,a){return r+e*(a-r)/t}function r(r,a,i,n,s,o){let c=a[i],l=a[i+1],h=a[i+2];!1!==n&&(c=t(c,n,0,100),l=t(l,n,r.amin,r.amax),h=t(h,n,r.bmin,r.bmax)),l>r.amax?l=r.amax:lr.bmax?h=r.bmax:hthis.amax||this.bmin>this.bmax)&&((0,a.info)("Invalid Range, falling back to defaults"),this.amin=-100,this.amax=100,this.bmin=-100,this.bmax=100)}getRgbItem(e,t,a,i){r(this,e,t,!1,a,i)}getRgbBuffer(e,t,a,i,n,s,o){const c=(1<=n.MAX_IMAGES_TO_CACHE)}addPageIndex(e,t){let r=this._refCache.get(e);r||(r=new Set,this._refCache.put(e,r)),r.add(t)}getData(e,t){if(!this._refCache.has(e))return null;const r=this._refCache.get(e);return r.size=n.MAX_IMAGES_TO_CACHE?(0,a.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE."):this._imageCache.put(e,t))}clear(e=!1){e||this._refCache.clear(),this._imageCache.clear()}}t.GlobalImageCache=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getQuadPoints=h,t.MarkupAnnotation=t.AnnotationFactory=t.AnnotationBorderStyle=t.Annotation=void 0;var a=r(2),i=r(10),n=r(5),s=r(23),o=r(8),c=r(26),l=r(12);function h(e,t){if(!e.has("QuadPoints"))return null;const r=e.getArray("QuadPoints");if(!Array.isArray(r)||r.length%8>0)return null;const a=[];for(let e=0,i=r.length/8;et[2]||st[3])return null;a[e].push({x:n,y:s})}}return a}t.AnnotationFactory=class{static create(e,t,r,a){return r.ensure(this,"_create",[e,t,r,a])}static _create(e,t,r,i){const s=e.fetchIfRef(t);if(!(0,n.isDict)(s))return;const c=(0,n.isRef)(t)?t.toString():"annot_"+i.createObjId();let l=s.get("Subtype");l=(0,n.isName)(l)?l.name:null;const h={xref:e,dict:s,subtype:l,id:c,pdfManager:r};switch(l){case"Link":return new v(h);case"Text":return new y(h);case"Widget":let e=(0,o.getInheritableProperty)({dict:s,key:"FT"});switch(e=(0,n.isName)(e)?e.name:null,e){case"Tx":return new p(h);case"Btn":return new m(h);case"Ch":return new b(h)}return(0,a.warn)('Unimplemented widget field type "'+e+'", falling back to base field type.'),new g(h);case"Popup":return new w(h);case"FreeText":return new A(h);case"Line":return new k(h);case"Square":return new S(h);case"Circle":return new x(h);case"PolyLine":return new C(h);case"Polygon":return new _(h);case"Caret":return new P(h);case"Ink":return new T(h);case"Highlight":return new I(h);case"Underline":return new E(h);case"Squiggly":return new F(h);case"StrikeOut":return new R(h);case"Stamp":return new L(h);case"FileAttachment":return new O(h);default:return l?(0,a.warn)('Unimplemented annotation type "'+l+'", falling back to base annotation.'):(0,a.warn)("Annotation is missing the required /Subtype."),new u(h)}}};class u{constructor(e){const t=e.dict;this.setContents(t.get("Contents")),this.setModificationDate(t.get("M")),this.setFlags(t.get("F")),this.setRectangle(t.getArray("Rect")),this.setColor(t.getArray("C")),this.setBorderStyle(t),this.setAppearance(t),this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,contents:this.contents,hasAppearance:!!this.appearance,id:e.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:e.subtype}}_hasFlag(e,t){return!!(e&t)}_isViewable(e){return!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.HIDDEN)&&!this._hasFlag(e,a.AnnotationFlag.NOVIEW)}_isPrintable(e){return this._hasFlag(e,a.AnnotationFlag.PRINT)&&!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.HIDDEN)}get viewable(){return 0===this.flags||this._isViewable(this.flags)}get printable(){return 0!==this.flags&&this._isPrintable(this.flags)}setContents(e){this.contents=(0,a.stringToPDFString)(e||"")}setModificationDate(e){this.modificationDate=(0,a.isString)(e)?e:null}setFlags(e){this.flags=Number.isInteger(e)&&e>0?e:0}hasFlag(e){return this._hasFlag(this.flags,e)}setRectangle(e){Array.isArray(e)&&4===e.length?this.rectangle=a.Util.normalizeRect(e):this.rectangle=[0,0,0,0]}setColor(e){const t=new Uint8ClampedArray(3);if(Array.isArray(e))switch(e.length){case 0:this.color=null;break;case 1:s.ColorSpace.singletons.gray.getRgbItem(e,0,t,0),this.color=t;break;case 3:s.ColorSpace.singletons.rgb.getRgbItem(e,0,t,0),this.color=t;break;case 4:s.ColorSpace.singletons.cmyk.getRgbItem(e,0,t,0),this.color=t;break;default:this.color=t}else this.color=t}setBorderStyle(e){if(this.borderStyle=new d,(0,n.isDict)(e))if(e.has("BS")){const t=e.get("BS"),r=t.get("Type");r&&!(0,n.isName)(r,"Border")||(this.borderStyle.setWidth(t.get("W"),this.rectangle),this.borderStyle.setStyle(t.get("S")),this.borderStyle.setDashArray(t.getArray("D")))}else if(e.has("Border")){const t=e.getArray("Border");Array.isArray(t)&&t.length>=3&&(this.borderStyle.setHorizontalCornerRadius(t[0]),this.borderStyle.setVerticalCornerRadius(t[1]),this.borderStyle.setWidth(t[2],this.rectangle),4===t.length&&this.borderStyle.setDashArray(t[3]))}else this.borderStyle.setWidth(0)}setAppearance(e){this.appearance=null;const t=e.get("AP");if(!(0,n.isDict)(t))return;const r=t.get("N");if((0,n.isStream)(r))return void(this.appearance=r);if(!(0,n.isDict)(r))return;const a=e.get("AS");(0,n.isName)(a)&&r.has(a.name)&&(this.appearance=r.get(a.name))}loadResources(e){return this.appearance.dict.getAsync("Resources").then(t=>{if(t)return new i.ObjectLoader(t,e,t.xref).load().then((function(){return t}))})}getOperatorList(e,t,r){if(!this.appearance)return Promise.resolve(new c.OperatorList);const i=this.data,n=this.appearance.dict,s=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),o=n.getArray("BBox")||[0,0,1,1],l=n.getArray("Matrix")||[1,0,0,1,0,0],h=function(e,t,r){const[i,n,s,o]=a.Util.getAxialAlignedBoundingBox(t,r);if(i===s||n===o)return[1,0,0,1,e[0],e[1]];const c=(e[2]-e[0])/(s-i),l=(e[3]-e[1])/(o-n);return[c,0,0,l,e[0]-i*c,e[1]-n*l]}(i.rect,o,l);return s.then(r=>{const n=new c.OperatorList;return n.addOp(a.OPS.beginAnnotation,[i.rect,h,l]),e.getOperatorList({stream:this.appearance,task:t,resources:r,operatorList:n}).then(()=>(n.addOp(a.OPS.endAnnotation,[]),this.appearance.reset(),n))})}}t.Annotation=u;class d{constructor(){this.width=1,this.style=a.AnnotationBorderStyleType.SOLID,this.dashArray=[3],this.horizontalCornerRadius=0,this.verticalCornerRadius=0}setWidth(e,t=[0,0,0,0]){if((0,n.isName)(e))this.width=0;else if(Number.isInteger(e)){if(e>0){const r=(t[2]-t[0])/2,i=(t[3]-t[1])/2;r>0&&i>0&&(e>r||e>i)&&((0,a.warn)("AnnotationBorderStyle.setWidth - ignoring width: "+e),e=1)}this.width=e}}setStyle(e){if((0,n.isName)(e))switch(e.name){case"S":this.style=a.AnnotationBorderStyleType.SOLID;break;case"D":this.style=a.AnnotationBorderStyleType.DASHED;break;case"B":this.style=a.AnnotationBorderStyleType.BEVELED;break;case"I":this.style=a.AnnotationBorderStyleType.INSET;break;case"U":this.style=a.AnnotationBorderStyleType.UNDERLINE}}setDashArray(e){if(Array.isArray(e)&&e.length>0){let t=!0,r=!0;for(const a of e){if(!(+a>=0)){t=!1;break}a>0&&(r=!1)}t&&!r?this.dashArray=e:this.width=0}else e&&(this.width=0)}setHorizontalCornerRadius(e){Number.isInteger(e)&&(this.horizontalCornerRadius=e)}setVerticalCornerRadius(e){Number.isInteger(e)&&(this.verticalCornerRadius=e)}}t.AnnotationBorderStyle=d;class f extends u{constructor(e){super(e);const t=e.dict;if(t.has("IRT")){const e=t.getRaw("IRT");this.data.inReplyTo=(0,n.isRef)(e)?e.toString():null;const r=t.get("RT");this.data.replyType=(0,n.isName)(r)?r.name:a.AnnotationReplyType.REPLY}if(this.data.replyType===a.AnnotationReplyType.GROUP){const e=t.get("IRT");this.data.title=(0,a.stringToPDFString)(e.get("T")||""),this.setContents(e.get("Contents")),this.data.contents=this.contents,e.has("CreationDate")?(this.setCreationDate(e.get("CreationDate")),this.data.creationDate=this.creationDate):this.data.creationDate=null,e.has("M")?(this.setModificationDate(e.get("M")),this.data.modificationDate=this.modificationDate):this.data.modificationDate=null,this.data.hasPopup=e.has("Popup"),e.has("C")?(this.setColor(e.getArray("C")),this.data.color=this.color):this.data.color=null}else this.data.title=(0,a.stringToPDFString)(t.get("T")||""),this.setCreationDate(t.get("CreationDate")),this.data.creationDate=this.creationDate,this.data.hasPopup=t.has("Popup"),t.has("C")||(this.data.color=null)}setCreationDate(e){this.creationDate=(0,a.isString)(e)?e:null}}t.MarkupAnnotation=f;class g extends u{constructor(e){super(e);const t=e.dict,r=this.data;r.annotationType=a.AnnotationType.WIDGET,r.fieldName=this._constructFieldName(t),r.fieldValue=(0,o.getInheritableProperty)({dict:t,key:"V",getArray:!0}),r.alternativeText=(0,a.stringToPDFString)(t.get("TU")||""),r.defaultAppearance=(0,o.getInheritableProperty)({dict:t,key:"DA"})||"";const i=(0,o.getInheritableProperty)({dict:t,key:"FT"});r.fieldType=(0,n.isName)(i)?i.name:null,this.fieldResources=(0,o.getInheritableProperty)({dict:t,key:"DR"})||n.Dict.empty,r.fieldFlags=(0,o.getInheritableProperty)({dict:t,key:"Ff"}),(!Number.isInteger(r.fieldFlags)||r.fieldFlags<0)&&(r.fieldFlags=0),r.readOnly=this.hasFieldFlag(a.AnnotationFieldFlag.READONLY),"Sig"===r.fieldType&&(r.fieldValue=null,this.setFlags(a.AnnotationFlag.HIDDEN))}_constructFieldName(e){if(!e.has("T")&&!e.has("Parent"))return(0,a.warn)("Unknown field name, falling back to empty field name."),"";if(!e.has("Parent"))return(0,a.stringToPDFString)(e.get("T"));const t=[];e.has("T")&&t.unshift((0,a.stringToPDFString)(e.get("T")));let r=e;for(;r.has("Parent")&&(r=r.get("Parent"),(0,n.isDict)(r));)r.has("T")&&t.unshift((0,a.stringToPDFString)(r.get("T")));return t.join(".")}hasFieldFlag(e){return!!(this.data.fieldFlags&e)}getOperatorList(e,t,r){return r?Promise.resolve(new c.OperatorList):super.getOperatorList(e,t,r)}}class p extends g{constructor(e){super(e);const t=e.dict;this.data.fieldValue=(0,a.stringToPDFString)(this.data.fieldValue||"");let r=(0,o.getInheritableProperty)({dict:t,key:"Q"});(!Number.isInteger(r)||r<0||r>2)&&(r=null),this.data.textAlignment=r;let i=(0,o.getInheritableProperty)({dict:t,key:"MaxLen"});(!Number.isInteger(i)||i<0)&&(i=null),this.data.maxLen=i,this.data.multiLine=this.hasFieldFlag(a.AnnotationFieldFlag.MULTILINE),this.data.comb=this.hasFieldFlag(a.AnnotationFieldFlag.COMB)&&!this.hasFieldFlag(a.AnnotationFieldFlag.MULTILINE)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD)&&!this.hasFieldFlag(a.AnnotationFieldFlag.FILESELECT)&&null!==this.data.maxLen}getOperatorList(e,t,r){if(r||this.appearance)return super.getOperatorList(e,t,r);const i=new c.OperatorList;if(!this.data.defaultAppearance)return Promise.resolve(i);const n=new l.Stream((0,a.stringToBytes)(this.data.defaultAppearance));return e.getOperatorList({stream:n,task:t,resources:this.fieldResources,operatorList:i}).then((function(){return i}))}}class m extends g{constructor(e){super(e),this.data.checkBox=!this.hasFieldFlag(a.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON),this.data.radioButton=this.hasFieldFlag(a.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON),this.data.pushButton=this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON),this.data.checkBox?this._processCheckBox(e):this.data.radioButton?this._processRadioButton(e):this.data.pushButton?this._processPushButton(e):(0,a.warn)("Invalid field flags for button widget annotation")}_processCheckBox(e){(0,n.isName)(this.data.fieldValue)&&(this.data.fieldValue=this.data.fieldValue.name);const t=e.dict.get("AP");if(!(0,n.isDict)(t))return;const r=t.get("D");if(!(0,n.isDict)(r))return;const a=r.getKeys();2===a.length&&(this.data.exportValue="Off"===a[0]?a[1]:a[0])}_processRadioButton(e){this.data.fieldValue=this.data.buttonValue=null;const t=e.dict.get("Parent");if((0,n.isDict)(t)&&t.has("V")){const e=t.get("V");(0,n.isName)(e)&&(this.data.fieldValue=e.name)}const r=e.dict.get("AP");if(!(0,n.isDict)(r))return;const a=r.get("N");if((0,n.isDict)(a))for(const e of a.getKeys())if("Off"!==e){this.data.buttonValue=e;break}}_processPushButton(e){e.dict.has("A")?i.Catalog.parseDestDictionary({destDict:e.dict,resultObj:this.data,docBaseUrl:e.pdfManager.docBaseUrl}):(0,a.warn)("Push buttons without action dictionaries are not supported")}}class b extends g{constructor(e){super(e),this.data.options=[];const t=(0,o.getInheritableProperty)({dict:e.dict,key:"Opt"});if(Array.isArray(t)){const r=e.xref;for(let e=0,i=t.length;e1e3&&(u=Math.max(u,g),p+=f+2,g=0,f=0),d.push({transform:m,x:g,y:p,w:b.width,h:b.height}),g+=b.width+2,f=Math.max(f,b.height)}var y=Math.max(u,g)+1,v=p+f+1,w=new Uint8ClampedArray(y*v*4),A=y<<2;for(h=0;h=0;)k[C-4]=k[C],k[C-3]=k[C+1],k[C-2]=k[C+2],k[C-1]=k[C+3],k[C+S]=k[C+S-4],k[C+S+1]=k[C+S-3],k[C+S+2]=k[C+S-2],k[C+S+3]=k[C+S-1],C-=A}return r.splice(s,4*l,a.OPS.paintInlineImageXObjectGroup),i.splice(s,4*l,[{width:y,height:v,kind:a.ImageKind.RGBA_32BPP,data:w},d]),s+1})),e(t,[a.OPS.save,a.OPS.transform,a.OPS.paintImageMaskXObject,a.OPS.restore],null,(function(e,t){var r=e.fnArray,i=(t-(e.iCurr-3))%4;switch(i){case 0:return r[t]===a.OPS.save;case 1:return r[t]===a.OPS.transform;case 2:return r[t]===a.OPS.paintImageMaskXObject;case 3:return r[t]===a.OPS.restore}throw new Error("iterateImageMaskGroup - invalid pos: "+i)}),(function(e,t){var r,i=e.fnArray,n=e.argsArray,s=e.iCurr,o=s-3,c=s-2,l=s-1,h=Math.floor((t-o)/4);if((h=function(e,t,r,i){for(var n=e+2,s=0;s=4&&r[n-4]===r[s]&&r[n-3]===r[o]&&r[n-2]===r[c]&&r[n-1]===r[l]&&a[n-4][0]===h&&a[n-4][1]===u&&(d++,f-=5);for(var g=f+4,p=1;p=a)break}i=(i||t)[e[r]],i&&!Array.isArray(i)?(s.iCurr=r,r++,!i.checkFn||(0,i.checkFn)(s)?(n=i,i=null):i=null):r++}this.state=i,this.match=n,this.lastProcessed=r},push(e,t){this.queue.fnArray.push(e),this.queue.argsArray.push(t),this._optimize()},flush(){for(;this.match;){const e=this.queue.fnArray.length;this.lastProcessed=(0,this.match.processFn)(this.context,e),this.match=null,this.state=null,this._optimize()}},reset(){this.state=null,this.match=null,this.lastProcessed=0}},r}(),n=function(){function e(e){this.queue=e}return e.prototype={push(e,t){this.queue.fnArray.push(e),this.queue.argsArray.push(t)},flush(){},reset(){}},e}(),s=function(){function e(e,t,r){this._streamSink=t,this.fnArray=[],this.argsArray=[],this.optimizer=t&&"oplist"!==e?new i(this):new n(this),this.dependencies=Object.create(null),this._totalLength=0,this.pageIndex=r,this.intent=e,this.weight=0,this._resolved=t?null:Promise.resolve()}return e.prototype={get length(){return this.argsArray.length},get ready(){return this._resolved||this._streamSink.ready},get totalLength(){return this._totalLength+this.length},addOp(e,t){this.optimizer.push(e,t),this.weight++,this._streamSink&&(this.weight>=1e3||this.weight>=995&&(e===a.OPS.restore||e===a.OPS.endText))&&this.flush()},addDependency(e){e in this.dependencies||(this.dependencies[e]=!0,this.addOp(a.OPS.dependency,[e]))},addDependencies(e){for(var t in e)this.addDependency(t)},addOpList(t){if(t instanceof e){Object.assign(this.dependencies,t.dependencies);for(var r=0,i=t.length;r{if(this.builtInCMapCache.has(e))return this.builtInCMapCache.get(e);const t=this.handler.sendWithStream("FetchBuiltInCMap",{name:e}).getReader(),r=await new Promise((function(e,r){!function a(){t.read().then((function({value:t,done:r}){r||(e(t),a())}),r)}()}));return r.compressionType!==a.CMapCompressionType.NONE&&this.builtInCMapCache.set(e,r),r}}function r(){this.reset()}function d(e,t=!1){if(Array.isArray(e)){for(let t=0,r=e.length;tf)return void(0,a.warn)("Image exceeded maximum allowed size and was removed.");if(o.get("ImageMask","IM")){var g=o.get("Width","W"),m=o.get("Height","H"),b=g+7>>3,y=t.getBytes(b*m,!0),v=o.getArray("Decode","D");return(u=k.PDFImage.createMask({imgArray:y,width:g,height:m,imageIsFromDecodeStream:t instanceof p.DecodeStream,inverseDecode:!!v&&v[0]>0})).cached=!!n,d=[u],i.addOp(a.OPS.paintImageMaskXObject,d),void(n&&s.set(n,c,{fn:a.OPS.paintImageMaskXObject,args:d}))}var w=o.get("SMask","SM")||!1,A=o.get("Mask")||!1;if(r&&!w&&!A&&l+h<200){const n=new k.PDFImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this.pdfFunctionFactory});return u=n.createImageData(!0),void i.addOp(a.OPS.paintInlineImageXObject,[u])}let S="img_"+this.idFactory.createObjId(),x=!1;this.parsingType3Font?S=`${this.idFactory.getDocId()}_type3res_${S}`:c&&(x=this.globalImageCache.shouldCache(c,this.pageIndex),x&&(S=`${this.idFactory.getDocId()}_${S}`)),i.addDependency(S),d=[S,l,h];const C=k.PDFImage.buildImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this.pdfFunctionFactory}).then(e=>{if(u=e.createImageData(!1),this.parsingType3Font)return this.handler.sendWithPromise("commonobj",[S,"FontType3Res",u],[u.data.buffer]);x?this.handler.send("commonobj",[S,"Image",u],[u.data.buffer]):this.handler.send("obj",[S,this.pageIndex,"Image",u],[u.data.buffer])}).catch(e=>{if((0,a.warn)("Unable to decode image: "+e),this.parsingType3Font)return this.handler.sendWithPromise("commonobj",[S,"FontType3Res",null]);x?this.handler.send("commonobj",[S,"Image",null]):this.handler.send("obj",[S,this.pageIndex,"Image",null])});this.parsingType3Font&&await C,i.addOp(a.OPS.paintImageXObject,d),n&&(s.set(n,c,{fn:a.OPS.paintImageXObject,args:d}),c&&((0,a.assert)(!r,"Cannot cache an inline image globally."),this.globalImageCache.addPageIndex(c,this.pageIndex),x&&this.globalImageCache.setData(c,{objId:S,fn:a.OPS.paintImageXObject,args:d})))},handleSMask:function(e,t,r,a,i){var n=e.get("G"),s={subtype:e.get("S").name,backdrop:e.get("BC")},o=e.get("TR");if((0,y.isPDFFunction)(o)){const e=this.pdfFunctionFactory.create(o);for(var c=new Uint8Array(256),l=new Float32Array(1),h=0;h<256;h++)l[0]=h/255,e(l,0,l,0),c[h]=255*l[0]|0;s.transferMap=c}return this.buildFormXObject(t,n,s,r,a,i.state.clone())},handleTilingType(e,t,r,i,s,o,c){const l=new A.OperatorList,h=[s.get("Resources"),r],d=n.Dict.merge(this.xref,h);return this.getOperatorList({stream:i,task:c,resources:d,operatorList:l}).then((function(){return(0,u.getTilingPatternIR)({fnArray:l.fnArray,argsArray:l.argsArray},s,t)})).then((function(t){o.addDependencies(l.dependencies),o.addOp(e,t)}),e=>{if(!(e instanceof a.AbortException)){if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorTilingPattern}),void(0,a.warn)(`handleTilingType - ignoring pattern: "${e}".`);throw e}})},handleSetFont:function(e,t,r,i,n,o){var c;return t&&(c=(t=t.slice())[0].name),this.loadFont(c,r,e).then(t=>t.font.isType3Font?t.loadType3Data(this,e,i,n).then((function(){return t})).catch(e=>(this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontLoadType3}),new x({loadedName:"g_font_error",font:new s.ErrorFont("Type3 font load error: "+e),dict:t.font,extraProperties:this.options.fontExtraProperties}))):t).then(e=>(o.font=e.font,e.send(this.handler),e.loadedName))},handleText(e,r){const i=r.font,n=i.charsToGlyphs(e);return i.data&&(r.textRenderingMode&a.TextRenderingMode.ADD_TO_PATH_FLAG||"Pattern"===r.fillColorSpace.name||i.disableFontFace||this.options.disableFontFace)&&t.buildFontPaths(i,n,this.handler),n},ensureStateFont(e){if(e.font)return;const t=new a.FormatError("Missing setFont (Tf) operator before text rendering operator.");if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontState}),void(0,a.warn)(`ensureStateFont: "${t}".`);throw t},setGState:function(e,t,r,i,s){for(var o=[],c=t.getKeys(),l=Promise.resolve(),h=0,u=c.length;hthis.handleSetFont(e,null,f[0],r,i,s.state).then((function(e){r.addDependency(e),o.push([u,[e,f[1]]])})));break;case"BM":o.push([u,d(f)]);break;case"SMask":if((0,n.isName)(f,"None")){o.push([u,!1]);break}(0,n.isDict)(f)?(l=l.then(()=>this.handleSMask(f,e,r,i,s)),o.push([u,!0])):(0,a.warn)("Unsupported SMask type");break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":(0,a.info)("graphic state operator "+u);break;default:(0,a.info)("Unknown graphic state operator "+u)}}return l.then((function(){o.length>0&&r.addOp(a.OPS.setGState,[o])}))},loadFont:function(e,r,i){const o=()=>Promise.resolve(new x({loadedName:"g_font_error",font:new s.ErrorFont(`Font "${e}" is not available.`),dict:r,extraProperties:this.options.fontExtraProperties}));var c,l=this.xref;if(r){if(!(0,n.isRef)(r))throw new a.FormatError('The "font" object should be a reference.');c=r}else{var h=i.get("Font");h&&(c=h.getRaw(e))}if(!c){const i=`Font "${e||r&&r.toString()}" is not available`;if(!this.options.ignoreErrors&&!this.parsingType3Font)return(0,a.warn)(i+"."),o();this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontMissing}),(0,a.warn)(i+" -- attempting to fallback to a default font."),c=t.getFallbackFontDict()}if(this.fontCache.has(c))return this.fontCache.get(c);if(r=l.fetchIfRef(c),!(0,n.isDict)(r))return o();if(r.translated)return r.translated;var u=(0,a.createPromiseCapability)(),d=this.preEvaluateFont(r);const{descriptor:f,hash:g}=d;var p,m,b=(0,n.isRef)(c);if(b&&(p=c.toString()),g&&(0,n.isDict)(f)){f.fontAliases||(f.fontAliases=Object.create(null));var y=f.fontAliases;if(y[g]){var v=y[g].aliasRef;if(b&&v&&this.fontCache.has(v))return this.fontCache.putAlias(c,v),this.fontCache.get(c)}else y[g]={fontID:s.Font.getFontID()};b&&(y[g].aliasRef=c),p=y[g].fontID}b?this.fontCache.put(c,u.promise):(p||(p=this.idFactory.createObjId()),this.fontCache.put("id_"+p,u.promise)),(0,a.assert)(p,'The "fontID" must be defined.'),r.loadedName=`${this.idFactory.getDocId()}_f${p}`,r.translated=u.promise;try{m=this.translateFont(d)}catch(e){m=Promise.reject(e)}return m.then(e=>{void 0!==e.fontType&&(l.stats.fontTypes[e.fontType]=!0),u.resolve(new x({loadedName:r.loadedName,font:e,dict:r,extraProperties:this.options.fontExtraProperties}))}).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontTranslate});try{var t=f&&f.get("FontFile3"),i=t&&t.get("Subtype"),n=(0,s.getFontType)(d.type,i&&i.name);l.stats.fontTypes[n]=!0}catch(e){}u.resolve(new x({loadedName:r.loadedName,font:new s.ErrorFont(e instanceof Error?e.message:e),dict:r,extraProperties:this.options.fontExtraProperties}))}),u.promise},buildPath(e,t,r,i=!1){var n=e.length-1;if(r||(r=[]),n<0||e.fnArray[n]!==a.OPS.constructPath)i&&((0,a.warn)(`Encountered path operator "${t}" inside of a text object.`),e.addOp(a.OPS.save,null)),e.addOp(a.OPS.constructPath,[[t],r]),i&&e.addOp(a.OPS.restore,null);else{var s=e.argsArray[n];s[0].push(t),Array.prototype.push.apply(s[1],r)}},parseColorSpace({cs:e,resources:t}){return new Promise(r=>{r(g.ColorSpace.parse(e,this.xref,t,this.pdfFunctionFactory))}).catch(e=>{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorColorSpace}),(0,a.warn)(`parseColorSpace - ignoring ColorSpace: "${e}".`),null;throw e})},async handleColorN(e,t,r,i,s,o,c){var l,h=r[r.length-1];if((0,n.isName)(h)&&(l=s.get(h.name))){var d=(0,n.isStream)(l)?l.dict:l,f=d.get("PatternType");if(1===f){var g=i.base?i.base.getRgb(r,0):null;return this.handleTilingType(t,g,o,l,d,e,c)}if(2===f){var p=d.get("Shading"),m=d.getArray("Matrix");return l=u.Pattern.parseShading(p,m,this.xref,o,this.handler,this.pdfFunctionFactory),void e.addOp(t,l.getIR())}throw new a.FormatError("Unknown PatternType: "+f)}throw new a.FormatError("Unknown PatternName: "+h)},getOperatorList({stream:e,task:t,resources:i,operatorList:s,initialState:o=null}){if(i=i||n.Dict.empty,o=o||new P,!s)throw new Error('getOperatorList: missing "operatorList" parameter');var c=this,l=this.xref;let h=!1;const d=new v.LocalImageCache;var f=i.get("XObject")||n.Dict.empty,p=i.get("Pattern")||n.Dict.empty,m=new C(o),b=new T(e,l,m),y=new r;function w(e){for(var t=0,r=b.savedStatesDepth;t{if(!(e instanceof a.AbortException)){if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList}),(0,a.warn)(`getOperatorList - ignoring errors during "${t.name}" task: "${e}".`),void w();throw e}})},getTextContent({stream:e,task:t,resources:i,stateManager:s=null,normalizeWhitespace:o=!1,combineTextItems:c=!1,sink:h,seenStyles:u=Object.create(null)}){i=i||n.Dict.empty,s=s||new C(new _);var d=/\s/g,g={items:[],styles:Object.create(null)},p={initialized:!1,str:[],width:0,height:0,vertical:!1,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:1/0,fakeMultiSpaceMin:1/0,fakeMultiSpaceMax:-0,textRunBreakAllowed:!1,transform:null,fontName:null},m=this,b=this.xref,y=null;const w=new v.LocalImageCache;var A,k=new T(e,b,s);function x(){if(p.initialized)return p;var e=A.font;e.loadedName in u||(u[e.loadedName]=!0,g.styles[e.loadedName]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:e.vertical}),p.fontName=e.loadedName;var t=[A.fontSize*A.textHScale,0,0,A.fontSize,0,A.textRise];if(e.isType3Font&&A.fontSize<=1&&!(0,a.isArrayEqual)(A.fontMatrix,a.FONT_IDENTITY_MATRIX)){const r=e.bbox[3]-e.bbox[1];r>0&&(t[3]*=r*A.fontMatrix[3])}var r=a.Util.transform(A.ctm,a.Util.transform(A.textMatrix,t));p.transform=r,e.vertical?(p.width=Math.sqrt(r[0]*r[0]+r[1]*r[1]),p.height=0,p.vertical=!0):(p.width=0,p.height=Math.sqrt(r[2]*r[2]+r[3]*r[3]),p.vertical=!1);var i=A.textLineMatrix[0],n=A.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=A.ctm[0],n=A.ctm[1];var o=Math.sqrt(i*i+n*n);p.textAdvanceScale=o*s,p.lastAdvanceWidth=0,p.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*A.fontSize;return c?(p.spaceWidth=c,p.fakeSpaceMin=.3*c,p.fakeMultiSpaceMin=1.5*c,p.fakeMultiSpaceMax=4*c,p.textRunBreakAllowed=!e.isMonospace):(p.spaceWidth=0,p.fakeSpaceMin=1/0,p.fakeMultiSpaceMin=1/0,p.fakeMultiSpaceMax=0,p.textRunBreakAllowed=!1),p.initialized=!0,p}function P(e){for(var t,r=0,a=e.length;r=32&&t<=127;)r++;return r0&&F(f,r.str)}var g=0,p=0;t.vertical?i+=p=c*A.fontMatrix[0]*A.fontSize+d:a+=g=(c*A.fontMatrix[0]*A.fontSize+d)*A.textHScale,A.translateTextMatrix(g,p),r.str.push(h)}return t.vertical?(r.lastAdvanceHeight=i,r.height+=Math.abs(i)):(r.lastAdvanceWidth=a,r.width+=a),r}function F(e,t){if(!(e0;)t.push(" ")}function R(){var e,t,r;p.initialized&&(p.vertical?p.height*=p.textAdvanceScale:p.width*=p.textAdvanceScale,g.items.push((t=(e=p).str.join(""),r=(0,f.bidi)(t,-1,e.vertical),{str:o?P(r.str):r.str,dir:r.dir,width:e.width,height:e.height,transform:e.transform,fontName:e.fontName})),p.initialized=!1,p.str.length=0)}function L(){const e=g.items.length;e>0&&(h.enqueue(g,e),g.items=[],g.styles=Object.create(null))}var O=new r;return new Promise((function e(r,l){const d=function(t){L(),Promise.all([t,h.ready]).then((function(){try{e(r,l)}catch(e){l(e)}}),l)};t.ensureNotTerminated(),O.reset();for(var f,v={},_=[];!(f=O.check())&&(_.length=0,v.args=_,k.read(v));){A=s.state;var P,T=v.fn;switch(_=v.args,0|T){case a.OPS.setFont:var M=_[0].name,D=_[1];if(A.font&&M===A.fontName&&D===A.fontSize)break;return R(),A.fontName=M,A.fontSize=D,void d(I(M,null));case a.OPS.setTextRise:R(),A.textRise=_[0];break;case a.OPS.setHScale:R(),A.textHScale=_[0]/100;break;case a.OPS.setLeading:R(),A.leading=_[0];break;case a.OPS.moveText:var N=!!A.font&&0===(A.font.vertical?_[0]:_[1]);if(P=_[0]-_[1],c&&N&&p.initialized&&P>0&&P<=p.fakeMultiSpaceMax){A.translateTextLineMatrix(_[0],_[1]),p.width+=_[0]-p.lastAdvanceWidth,p.height+=_[1]-p.lastAdvanceHeight,F(_[0]-p.lastAdvanceWidth-(_[1]-p.lastAdvanceHeight),p.str);break}R(),A.translateTextLineMatrix(_[0],_[1]),A.textMatrix=A.textLineMatrix.slice();break;case a.OPS.setLeadingMoveText:R(),A.leading=-_[1],A.translateTextLineMatrix(_[0],_[1]),A.textMatrix=A.textLineMatrix.slice();break;case a.OPS.nextLine:R(),A.carriageReturn();break;case a.OPS.setTextMatrix:if(P=A.calcTextLineMatrixAdvance(_[0],_[1],_[2],_[3],_[4],_[5]),c&&null!==P&&p.initialized&&P.value>0&&P.value<=p.fakeMultiSpaceMax){A.translateTextLineMatrix(P.width,P.height),p.width+=P.width-p.lastAdvanceWidth,p.height+=P.height-p.lastAdvanceHeight,F(P.width-p.lastAdvanceWidth-(P.height-p.lastAdvanceHeight),p.str);break}R(),A.setTextMatrix(_[0],_[1],_[2],_[3],_[4],_[5]),A.setTextLineMatrix(_[0],_[1],_[2],_[3],_[4],_[5]);break;case a.OPS.setCharSpacing:A.charSpacing=_[0];break;case a.OPS.setWordSpacing:A.wordSpacing=_[0];break;case a.OPS.beginText:R(),A.textMatrix=a.IDENTITY_MATRIX.slice(),A.textLineMatrix=a.IDENTITY_MATRIX.slice();break;case a.OPS.showSpacedText:if(!s.state.font){m.ensureStateFont(s.state);continue}for(var B,U=_[0],j=0,q=U.length;jp.fakeMultiSpaceMax)||(p.height+=B)):(B=(P=-P)*A.textHScale,A.translateTextMatrix(B,0),(H=p.textRunBreakAllowed&&P>p.fakeMultiSpaceMax)||(p.width+=B)),H?R():P>0&&F(P,p.str)}break;case a.OPS.showText:if(!s.state.font){m.ensureStateFont(s.state);continue}E(_[0]);break;case a.OPS.nextLineShowText:if(!s.state.font){m.ensureStateFont(s.state);continue}R(),A.carriageReturn(),E(_[0]);break;case a.OPS.nextLineSetSpacingShowText:if(!s.state.font){m.ensureStateFont(s.state);continue}R(),A.wordSpacing=_[0],A.charSpacing=_[1],A.carriageReturn(),E(_[2]);break;case a.OPS.paintXObject:R(),y||(y=i.get("XObject")||n.Dict.empty);var G=_[0].name;if(G&&w.getByName(G))break;return void d(new Promise((function(e,r){if(!G)throw new a.FormatError("XObject must be referred to by name.");let l=y.getRaw(G);if(l instanceof n.Ref){if(w.getByRef(l))return void e();l=b.fetch(l)}if(!l)return void e();if(!(0,n.isStream)(l))throw new a.FormatError("XObject should be a stream");const d=l.dict.get("Subtype");if(!(0,n.isName)(d))throw new a.FormatError("XObject should have a Name subtype");if("Form"!==d.name)return w.set(G,l.dict.objId,!0),void e();const f=s.state.clone(),g=new C(f),p=l.dict.getArray("Matrix");Array.isArray(p)&&6===p.length&&g.transform(p),L();const v={enqueueInvoked:!1,enqueue(e,t){this.enqueueInvoked=!0,h.enqueue(e,t)},get desiredSize(){return h.desiredSize},get ready(){return h.ready}};m.getTextContent({stream:l,task:t,resources:l.dict.get("Resources")||i,stateManager:g,normalizeWhitespace:o,combineTextItems:c,sink:v,seenStyles:u}).then((function(){v.enqueueInvoked||w.set(G,l.dict.objId,!0),e()}),r)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!m.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring XObject: "${e}".`)}})));case a.OPS.setGState:R();var z=_[0],W=i.get("ExtGState");if(!(0,n.isDict)(W)||!(0,n.isName)(z))break;var V=W.get(z.name);if(!(0,n.isDict)(V))break;var X=V.get("Font");if(X)return A.fontName=null,A.fontSize=X[1],void d(I(null,X[0]))}if(g.items.length>=h.desiredSize){f=!0;break}}f?d(S):(R(),L(),r())})).catch(e=>{if(!(e instanceof a.AbortException)){if(this.options.ignoreErrors)return(0,a.warn)(`getTextContent - ignoring errors during "${t.name}" task: "${e}".`),R(),void L();throw e}})},extractDataStructures:function(e,t,r){const i=this.xref;let c;var l=e.get("ToUnicode")||t.get("ToUnicode"),h=l?this.readToUnicode(l):Promise.resolve(void 0);if(r.composite){var u=e.get("CIDSystemInfo");(0,n.isDict)(u)&&(r.cidSystemInfo={registry:(0,a.stringToPDFString)(u.get("Registry")),ordering:(0,a.stringToPDFString)(u.get("Ordering")),supplement:u.get("Supplement")});var d=e.get("CIDToGIDMap");(0,n.isStream)(d)&&(c=d.getBytes())}var f,g=[],p=null;if(e.has("Encoding")){if(f=e.get("Encoding"),(0,n.isDict)(f)){if(p=f.get("BaseEncoding"),p=(0,n.isName)(p)?p.name:null,f.has("Differences"))for(var m=f.get("Differences"),b=0,y=0,v=m.length;y0,r.dict=e,h.then(e=>(r.toUnicode=e,this.buildToUnicode(r))).then(e=>(r.toUnicode=e,c&&(r.cidToGidMap=this.readCidToGidMap(c,e)),r))},_buildSimpleFontToUnicode(e,t=!1){(0,a.assert)(!e.composite,"Must be a simple font.");const r=[],i=e.defaultEncoding.slice(),n=e.baseEncodingName,c=e.differences;for(const e in c){const t=c[e];".notdef"!==t&&(i[e]=t)}const h=(0,m.getGlyphsUnicode)();for(const a in i){let s=i[a];if(""!==s)if(void 0!==h[s])r[a]=String.fromCharCode(h[s]);else{let i=0;switch(s[0]){case"G":3===s.length&&(i=parseInt(s.substring(1),16));break;case"g":5===s.length&&(i=parseInt(s.substring(1),16));break;case"C":case"c":if(s.length>=3&&s.length<=4){const r=s.substring(1);if(t){i=parseInt(r,16);break}if(i=+r,Number.isNaN(i)&&Number.isInteger(parseInt(r,16)))return this._buildSimpleFontToUnicode(e,!0)}break;default:const r=(0,l.getUnicodeForGlyph)(s,h);-1!==r&&(i=r)}if(i>0&&i<=1114111&&Number.isInteger(i)){if(n&&i===+a){const e=(0,o.getEncoding)(n);if(e&&(s=e[a])){r[a]=String.fromCharCode(h[s]);continue}}r[a]=String.fromCodePoint(i)}}}return new s.ToUnicodeMap(r)},buildToUnicode(e){if(e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0,e.hasIncludedToUnicodeMap)return!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._buildSimpleFontToUnicode(e)),Promise.resolve(e.toUnicode);if(!e.composite)return Promise.resolve(this._buildSimpleFontToUnicode(e));if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof i.IdentityCMap)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){const t=e.cidSystemInfo.registry,r=e.cidSystemInfo.ordering,o=n.Name.get(t+"-"+r+"-UCS2");return i.CMapFactory.create({encoding:o,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(t){const r=e.cMap,i=[];return r.forEach((function(e,r){if(r>65535)throw new a.FormatError("Max size of CID is 65,535");const n=t.lookup(r);n&&(i[e]=String.fromCharCode((n.charCodeAt(0)<<8)+n.charCodeAt(1)))})),new s.ToUnicodeMap(i)}))}return Promise.resolve(new s.IdentityToUnicodeMap(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return(0,n.isName)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(e){return e instanceof i.IdentityCMap?new s.IdentityToUnicodeMap(0,65535):new s.ToUnicodeMap(e.getMap())})):(0,n.isStream)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(e){if(e instanceof i.IdentityCMap)return new s.IdentityToUnicodeMap(0,65535);var t=new Array(e.length);return e.forEach((function(e,r){for(var a=[],i=0;i{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontToUnicode}),(0,a.warn)(`readToUnicode - ignoring ToUnicode data: "${e}".`),null;throw e}):Promise.resolve(null)},readCidToGidMap(e,t){for(var r=[],a=0,i=e.length;a>1;(0!==n||t.has(i))&&(r[i]=n)}return r},extractWidths:function(e,t,r){var a,i,o,c,l,h,u,d,f=this.xref,g=[],p=0,m=[];if(r.composite){if(p=e.has("DW")?e.get("DW"):1e3,d=e.get("W"))for(i=0,o=d.length;i{if(e){const r=[];let a=f;for(let t=0,i=e.length;tthis.extractDataStructures(o,r,t)).then(e=>(this.extractWidths(o,l,e),"Type3"===u&&(e.isType3Font=!0),new s.Font(v.name,x,e)))}},t.buildFontPaths=function(e,t,r){function a(t){e.renderer.hasBuiltPath(t)||r.send("commonobj",[`${e.loadedName}_path_${t}`,"FontPath",e.renderer.getPathJs(t)])}for(const e of t){a(e.fontChar);const t=e.accent;t&&t.fontChar&&a(t.fontChar)}},t.getFallbackFontDict=function(){if(this._fallbackFontDict)return this._fallbackFontDict;const e=new n.Dict;return e.set("BaseFont",n.Name.get("PDFJS-FallbackFont")),e.set("Type",n.Name.get("FallbackType")),e.set("Subtype",n.Name.get("FallbackType")),e.set("Encoding",n.Name.get("WinAnsiEncoding")),this._fallbackFontDict=e},t}();t.PartialEvaluator=S;class x{constructor({loadedName:e,font:t,dict:r,extraProperties:a=!1}){this.loadedName=e,this.font=t,this.dict=r,this._extraProperties=a,this.type3Loaded=null,this.sent=!1}send(e){this.sent||(this.sent=!0,e.send("commonobj",[this.loadedName,"Font",this.font.exportData(this._extraProperties)]))}fallback(e){if(!this.font.data)return;this.font.disableFontFace=!0;const t=this.font.glyphCacheValues;S.buildFontPaths(this.font,t,e)}loadType3Data(e,t,r,i){if(!this.font.isType3Font)throw new Error("Must be a Type3 font.");if(this.type3Loaded)return this.type3Loaded;var n=Object.create(e.options);n.ignoreErrors=!1;var s=e.clone(n);s.parsingType3Font=!0;for(var o=this.font,c=Promise.resolve(),l=this.dict.get("CharProcs"),h=this.dict.get("Resources")||t,u=l.getKeys(),d=Object.create(null),f=0,g=u.length;fc&&(0,a.info)(`Command ${i}: expected [0, ${c}] args, but received ${l} args.`);else{if(l!==c){for(var h=this.nonProcessedArgs;l>c;)h.push(t.shift()),l--;for(;l=a.OPS.moveTo&&o<=a.OPS.endPath&&++this._numInvalidPathOPS>20)throw new a.FormatError("Invalid "+e);(0,a.warn)("Skipping "+e),null!==t&&(t.length=0);continue}}return this.preprocessCommand(o,t),e.fn=o,e.args=t,!0}if(r===n.EOF)return!1;if(null!==r&&(null===t&&(t=[]),t.push(r),t.length>33))throw new a.FormatError("Too many arguments")}},preprocessCommand:function(e,t){switch(0|e){case a.OPS.save:this.stateManager.save();break;case a.OPS.restore:this.stateManager.restore();break;case a.OPS.transform:this.stateManager.transform(t)}}},t}()},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CMapFactory=t.IdentityCMap=t.CMap=void 0;var a=r(2),i=r(5),n=r(11),s=r(8),o=r(12),c=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"];class l{constructor(e=!1){this.codespaceRanges=[[],[],[],[]],this.numCodespaceRanges=0,this._map=[],this.name="",this.vertical=!1,this.useCMap=null,this.builtInCMap=e}addCodespaceRange(e,t,r){this.codespaceRanges[e-1].push(t,r),this.numCodespaceRanges++}mapCidRange(e,t,r){if(t-e>2**24-1)throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");for(;e<=t;)this._map[e++]=r++}mapBfRange(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");for(var a=r.length-1;e<=t;)this._map[e++]=r,r=r.substring(0,a)+String.fromCharCode(r.charCodeAt(a)+1)}mapBfRangeToArray(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");const a=r.length;let i=0;for(;e<=t&&i>>0;const s=i[n];for(let e=0,t=s.length;e=t&&a<=i)return r.charcode=a,void(r.length=n+1)}}r.charcode=0,r.length=1}get length(){return this._map.length}get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(let e=0;e<65536;e++)if(this._map[e]!==e)return!1;return!0}}t.CMap=l;class h extends l{constructor(e,t){super(),this.vertical=e,this.addCodespaceRange(t,0,65535)}mapCidRange(e,t,r){(0,a.unreachable)("should not call mapCidRange")}mapBfRange(e,t,r){(0,a.unreachable)("should not call mapBfRange")}mapBfRangeToArray(e,t,r){(0,a.unreachable)("should not call mapBfRangeToArray")}mapOne(e,t){(0,a.unreachable)("should not call mapCidOne")}lookup(e){return Number.isInteger(e)&&e<=65535?e:void 0}contains(e){return Number.isInteger(e)&&e<=65535}forEach(e){for(let t=0;t<=65535;t++)e(t,t)}charCodeOf(e){return Number.isInteger(e)&&e<=65535?e:-1}getMap(){const e=new Array(65536);for(let t=0;t<=65535;t++)e[t]=t;return e}get length(){return 65536}get isIdentityCMap(){(0,a.unreachable)("should not access .isIdentityCMap")}}t.IdentityCMap=h;var u=function(){function e(e,t){for(var r=0,a=0;a<=t;a++)r=r<<8|e[a];return r>>>0}function t(e,t){return 1===t?String.fromCharCode(e[0],e[1]):3===t?String.fromCharCode(e[0],e[1],e[2],e[3]):String.fromCharCode.apply(null,e.subarray(0,t+1))}function r(e,t,r){for(var a=0,i=r;i>=0;i--)a+=e[i]+t[i],e[i]=255&a,a>>=8}function i(e,t){for(var r=1,a=t;a>=0&&r>0;a--)r+=e[a],e[a]=255&r,r>>=8}function n(e){this.buffer=e,this.pos=0,this.end=e.length,this.tmpBuf=new Uint8Array(19)}function s(){}return n.prototype={readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]},readNumber(){var e,t=0;do{var r=this.readByte();if(r<0)throw new a.FormatError("unexpected EOF in bcmap");e=!(128&r),t=t<<7|127&r}while(!e);return t},readSigned(){var e=this.readNumber();return 1&e?~(e>>>1):e>>>1},readHex(e,t){e.set(this.buffer.subarray(this.pos,this.pos+t+1)),this.pos+=t+1},readHexNumber(e,t){var r,i=this.tmpBuf,n=0;do{var s=this.readByte();if(s<0)throw new a.FormatError("unexpected EOF in bcmap");r=!(128&s),i[n++]=127&s}while(!r);for(var o=t,c=0,l=0;o>=0;){for(;l<8&&i.length>0;)c=i[--n]<>=8,l-=8}},readHexSigned(e,t){this.readHexNumber(e,t);for(var r=1&e[t]?255:0,a=0,i=0;i<=t;i++)a=(1&a)<<8|e[i],e[i]=a>>1^r},readString(){for(var e=this.readNumber(),t="",r=0;r=0;){var w=f>>5;if(7!==w){var A=!!(16&f),k=15&f;if(k+1>16)throw new Error("processBinaryCMap: Invalid dataSize.");var S,x=h.readNumber();switch(w){case 0:for(h.readHex(p,k),h.readHexNumber(m,k),r(m,p,k),s.addCodespaceRange(k+1,e(p,k),e(m,k)),S=1;S>>0}function t(e){if(!(0,a.isString)(e))throw new a.FormatError("Malformed CMap: expected string.")}function r(e){if(!Number.isInteger(e))throw new a.FormatError("Malformed CMap: expected int.")}function d(r,a){for(;;){var n=a.getObj();if((0,i.isEOF)(n))break;if((0,i.isCmd)(n,"endbfchar"))return;t(n);var s=e(n);t(n=a.getObj());var o=n;r.mapOne(s,o)}}function f(r,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endbfrange"))return;t(s);var o=e(s);t(s=n.getObj());var c=e(s);if(s=n.getObj(),Number.isInteger(s)||(0,a.isString)(s)){var l=Number.isInteger(s)?String.fromCharCode(s):s;r.mapBfRange(o,c,l)}else{if(!(0,i.isCmd)(s,"["))break;s=n.getObj();for(var h=[];!(0,i.isCmd)(s,"]")&&!(0,i.isEOF)(s);)h.push(s),s=n.getObj();r.mapBfRangeToArray(o,c,h)}}throw new a.FormatError("Invalid bf range.")}function g(a,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endcidchar"))return;t(s);var o=e(s);r(s=n.getObj());var c=s;a.mapOne(o,c)}}function p(a,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endcidrange"))return;t(s);var o=e(s);t(s=n.getObj());var c=e(s);r(s=n.getObj());var l=s;a.mapCidRange(o,c,l)}}function m(t,r){for(;;){var n=r.getObj();if((0,i.isEOF)(n))break;if((0,i.isCmd)(n,"endcodespacerange"))return;if(!(0,a.isString)(n))break;var s=e(n);if(n=r.getObj(),!(0,a.isString)(n))break;var o=e(n);t.addCodespaceRange(n.length,s,o)}throw new a.FormatError("Invalid codespace range.")}function b(e,t){var r=t.getObj();Number.isInteger(r)&&(e.vertical=!!r)}function y(e,t){var r=t.getObj();(0,i.isName)(r)&&(0,a.isString)(r.name)&&(e.name=r.name)}function v(e,t,r,n){var o,c;e:for(;;)try{var l=t.getObj();if((0,i.isEOF)(l))break;if((0,i.isName)(l))"WMode"===l.name?b(e,t):"CMapName"===l.name&&y(e,t),o=l;else if((0,i.isCmd)(l))switch(l.cmd){case"endcmap":break e;case"usecmap":(0,i.isName)(o)&&(c=o.name);break;case"begincodespacerange":m(e,t);break;case"beginbfchar":d(e,t);break;case"begincidchar":g(e,t);break;case"beginbfrange":f(e,t);break;case"begincidrange":p(e,t)}}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Invalid cMap data: "+e);continue}return!n&&c&&(n=c),n?w(e,r,n):Promise.resolve(e)}function w(e,t,r){return A(r,t).then((function(t){if(e.useCMap=t,0===e.numCodespaceRanges){for(var r=e.useCMap.codespaceRanges,a=0;a=this.firstChar&&e<=this.lastChar?e:-1},amend(e){(0,a.unreachable)("Should not call amend()")}},e}();t.IdentityToUnicodeMap=x;var C=function(){function e(e,t,r){e[t]=r>>8&255,e[t+1]=255&r}function t(e,t,r){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}function r(e,t,r){var a,i;if(r instanceof Uint8Array)e.set(r,t);else if("string"==typeof r)for(a=0,i=r.length;ar;)r<<=1,a++;var i=r*t;return{range:i,entry:a,rangeShift:t*e-i}},i.prototype={toArray:function(){var n=this.sfnt,s=this.tables,o=Object.keys(s);o.sort();var c,h,u,d,f,g=o.length,p=12+16*g,m=[p];for(c=0;c>>0,m.push(p);var b=new Uint8Array(p);for(c=0;c>>0;t(b,p+4,v),t(b,p+8,m[c]),t(b,p+12,s[f].length),p+=16}return b},addTable:function(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}},i}(),_=function(){function e(e,t,r){var i;this.name=e,this.loadedName=r.loadedName,this.isType3Font=r.isType3Font,this.missingFile=!1,this.glyphCache=Object.create(null),this.isSerifFont=!!(r.flags&b.Serif),this.isSymbolicFont=!!(r.flags&b.Symbolic),this.isMonospace=!!(r.flags&b.FixedPitch);var n=r.type,s=r.subtype;this.type=n,this.subtype=s;let o="sans-serif";if(this.isMonospace?o="monospace":this.isSerifFont&&(o="serif"),this.fallbackName=o,this.differences=r.differences,this.widths=r.widths,this.defaultWidth=r.defaultWidth,this.composite=r.composite,this.cMap=r.cMap,this.ascent=r.ascent/1e3,this.descent=r.descent/1e3,this.fontMatrix=r.fontMatrix,this.bbox=r.bbox,this.defaultEncoding=r.defaultEncoding,this.toUnicode=r.toUnicode,this.fallbackToUnicode=r.fallbackToUnicode||new S,this.toFontChar=[],"Type3"!==r.type){if(this.cidEncoding=r.cidEncoding,this.vertical=!!r.vertical,this.vertical&&(this.vmetrics=r.vmetrics,this.defaultVMetrics=r.defaultVMetrics),!t||t.isEmpty)return t&&(0,a.warn)('Font file is empty in "'+e+'" ('+this.loadedName+")"),void this.fallbackToSystemFont();[n,s]=function(e,{type:t,subtype:r,composite:i}){let n,s;return function(e){var t=e.peekBytes(4);return 65536===(0,l.readUint32)(t,0)||"true"===(0,a.bytesToString)(t)}(e)||T(e)?n=i?"CIDFontType2":"TrueType":function(e){var t=e.peekBytes(4);return"OTTO"===(0,a.bytesToString)(t)}(e)?n=i?"CIDFontType2":"OpenType":function(e){var t=e.peekBytes(2);return 37===t[0]&&33===t[1]||128===t[0]&&1===t[1]}(e)?n=i?"CIDFontType0":"MMType1"===t?"MMType1":"Type1":function(e){const t=e.peekBytes(4);return t[0]>=1&&t[3]>=1&&t[3]<=4}(e)?i?(n="CIDFontType0",s="CIDFontType0C"):(n="MMType1"===t?"MMType1":"Type1",s="Type1C"):((0,a.warn)("getFontFileType: Unable to detect correct font file Type/Subtype."),n=t,s=r),[n,s]}(t,r),n===this.type&&s===this.subtype||(0,a.info)(`Inconsistent font file Type/SubType, expected: ${this.type}/${this.subtype} but found: ${n}/${s}.`);try{var c;switch(n){case"MMType1":(0,a.info)("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var h="Type1C"===s||"CIDFontType0C"===s?new E(t,r):new I(e,t,r);v(r),c=this.convert(e,h,r);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype",c=this.checkAndRepair(e,t,r),this.isOpenType&&(v(r),n="OpenType");break;default:throw new a.FormatError(`Font ${n} is not supported`)}}catch(e){return(0,a.warn)(e),void this.fallbackToSystemFont()}this.data=c,this.fontType=w(n,s),this.fontMatrix=r.fontMatrix,this.widths=r.widths,this.defaultWidth=r.defaultWidth,this.toUnicode=r.toUnicode,this.seacMap=r.seacMap}else{for(i=0;i<256;i++)this.toFontChar[i]=this.differences[i]||r.defaultEncoding[i];this.fontType=a.FontType.TYPE3}}var t;function r(e,t){return(e<<8)+t}function f(e,t){var r=(e<<8)+t;return 32768&r?r-65536:r}function _(e){return String.fromCharCode(e>>8&255,255&e)}function P(e){return e>32767?e=32767:e<-32768&&(e=-32768),String.fromCharCode(e>>8&255,255&e)}function T(e){const t=e.peekBytes(4);return"ttcf"===(0,a.bytesToString)(t)}function F(e,t,r){for(var a,i=[],n=0,s=e.length;nc){if(++s>=g.length){(0,a.warn)("Ran out of space in font private use area.");break}o=g[s][0],c=g[s][1]}var u=o++;0===h&&(h=r),i[u]=h,n[l]=u}}return{toFontChar:n,charCodeToGlyphId:i,nextAvailableFontCharCode:o}}function L(e,t){var r,i,n,s,o=function(e,t){var r=[];for(var a in e)e[a]>=t||r.push({fontCharCode:0|a,glyphId:e[a]});0===r.length&&r.push({fontCharCode:0,glyphId:0}),r.sort((function(e,t){return e.fontCharCode-t.fontCharCode}));for(var i=[],n=r.length,s=0;s65535?2:1,l="\0\0"+_(c)+"\0\0"+(0,a.string32)(4+8*c);for(r=o.length-1;r>=0&&!(o[r][0]<=65535);--r);var h=r+1;o[r][0]<65535&&65535===o[r][1]&&(o[r][1]=65534);var u,d,f,g,p=o[r][1]<65535?1:0,m=h+p,b=C.getSearchParams(m,2),y="",v="",w="",A="",k="",S=0;for(r=0,i=h;r0&&(v+="ÿÿ",y+="ÿÿ",w+="\0",A+="\0\0");var T="\0\0"+_(2*m)+_(b.range)+_(b.entry)+_(b.rangeShift)+v+"\0\0"+y+w+A+k,I="",E="";if(c>1){for(l+="\0\0\n"+(0,a.string32)(4+8*c+4+T.length),I="",r=0,i=o.length;r(u|=0)||!l)&&(l=u),h 123 are reserved for internal usage");o|=1<65535&&(h=65535)}else l=0,h=255;var f=e.bbox||[0,0,0,0],g=r.unitsPerEm||1/(e.fontMatrix||a.FONT_IDENTITY_MATRIX)[0],p=e.ascentScaled?1:g/1e3,m=r.ascent||Math.round(p*(e.ascent||f[3])),b=r.descent||Math.round(p*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var y=r.yMax||m,v=-r.yMin||-b;return"\0$ô\0\0\0»\0\0\0»\0\0ß\x001\0\0\0\0"+String.fromCharCode(e.fixedPitch?9:0)+"\0\0\0\0\0\0"+(0,a.string32)(i)+(0,a.string32)(n)+(0,a.string32)(s)+(0,a.string32)(o)+"*21*"+_(e.italicAngle?1:0)+_(l||e.firstChar)+_(h||e.lastChar)+_(m)+_(b)+"\0d"+_(y)+_(v)+"\0\0\0\0\0\0\0\0"+_(e.xHeight)+_(e.capHeight)+_(0)+_(l||e.firstChar)+"\0"}function M(e){var t=Math.floor(65536*e.italicAngle);return"\0\0\0"+(0,a.string32)(t)+"\0\0\0\0"+(0,a.string32)(e.fixedPitch)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function D(e,t){t||(t=[[],[]]);var r,a,i,n,s,o=[t[0][0]||"Original licence",t[0][1]||e,t[0][2]||"Unknown",t[0][3]||"uniqueID",t[0][4]||e,t[0][5]||"Version 0.11",t[0][6]||"",t[0][7]||"Unknown",t[0][8]||"Unknown",t[0][9]||"Unknown"],c=[];for(r=0,a=o.length;r0,u&&"CIDFontType2"===t&&this.cidEncoding.startsWith("Identity-")){const t=(0,o.getGlyphMapForStandardFonts)(),r=[];for(const e in t)r[+e]=t[e];if(/Arial-?Black/i.test(e)){var d=(0,o.getSupplementalGlyphMapForArialBlack)();for(const e in d)r[+e]=d[e]}else if(/Calibri/i.test(e)){const e=(0,o.getSupplementalGlyphMapForCalibri)();for(const t in e)r[+t]=e[t]}this.toUnicode instanceof x||this.toUnicode.forEach((function(e,t){r[+e]=t})),this.toFontChar=r,this.toUnicode=new S(r)}else if(/Symbol/i.test(i))this.toFontChar=F(s.SymbolSetEncoding,(0,n.getGlyphsUnicode)(),this.differences);else if(/Dingbats/i.test(i))/Wingdings/i.test(e)&&(0,a.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats."),this.toFontChar=F(s.ZapfDingbatsEncoding,(0,n.getDingbatsGlyphsUnicode)(),this.differences);else if(u)this.toFontChar=F(this.defaultEncoding,(0,n.getGlyphsUnicode)(),this.differences);else{const t=(0,n.getGlyphsUnicode)(),r=[];if(this.toUnicode.forEach((e,a)=>{if(!this.composite){var i=this.differences[e]||this.defaultEncoding[e];const r=(0,c.getUnicodeForGlyph)(i,t);-1!==r&&(a=r)}r[+e]=a}),this.composite&&this.toUnicode instanceof x&&/Verdana/i.test(e)){const e=(0,o.getGlyphMapForStandardFonts)();for(const t in e)r[+t]=e[t]}this.toFontChar=r}this.loadedName=i.split("-")[0],this.fontType=w(t,r)},checkAndRepair:function(e,t,o){const c=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];function l(e,t){const r=Object.create(null);r["OS/2"]=null,r.cmap=null,r.head=null,r.hhea=null,r.hmtx=null,r.maxp=null,r.name=null,r.post=null;for(let a=0;a>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0,s=e.pos;e.pos=e.start?e.start:0,e.skip(i);var o=e.getBytes(n);return e.pos=s,"head"===t&&(o[8]=o[9]=o[10]=o[11]=0,o[17]|=32),{tag:t,checksum:r,length:n,offset:i,data:o}}function g(e){return{version:(0,a.bytesToString)(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function p(e,t,r,a,i,n){var s={length:0,sizeOfInstructions:0};if(r-t<=12)return s;var o,c,l,h=e.subarray(t,r),u=f(h[0],h[1]);if(u<0)return l=u=-1,(o=h)[1+(c=0)]=l,o[c]=l>>>8,a.set(h,i),s.length=h.length,s;var d,g=10,p=0;for(d=0;dh.length?s:!n&&b>0?(a.set(h.subarray(0,m),i),a.set([0,0],i+m),a.set(h.subarray(y,k),i+m+2),k-=b,h.length-k>3&&(k=k+3&-4),s.length=k,s):h.length-k>3?(k=k+3&-4,a.set(h.subarray(0,k),i),s.length=k,s):(a.set(h,i),s.length=h.length,s)}function m(e){var r=(t.start?t.start:0)+e.offset;t.pos=r;var i=[[],[]],n=e.length,s=r+n;if(0!==t.getUint16()||n<6)return i;var o,c,l=t.getUint16(),h=t.getUint16(),u=[];for(o=0;os)){t.pos=g;var p=f.name;if(f.encoding){for(var m="",b=0,y=f.length;b0&&(l+=k-1)}}else(m||v)&&((0,a.warn)("TT: nested FDEFs not allowed"),p=!0),m=!0,u=l,s=d.pop(),t.functionsDefined[s]={data:c,i:l};else if(!m&&!v)if(s=d[d.length-1],isNaN(s))(0,a.info)("TT: CALL empty stack (or invalid entry).");else if(t.functionsUsed[s]=!0,s in t.functionsStackDeltas){const e=d.length+t.functionsStackDeltas[s];if(e<0)return(0,a.warn)("TT: CALL invalid functions stack delta."),void(t.hintsValid=!1);d.length=e}else if(s in t.functionsDefined&&!g.includes(s)){if(f.push({data:c,i:l,stackTop:d.length-1}),g.push(s),!(o=t.functionsDefined[s]))return(0,a.warn)("TT: CALL non-existent function"),void(t.hintsValid=!1);c=o.data,l=o.i}if(!m&&!v){let e=0;for(A<=142?e=b[A]:A>=192&&A<=223?e=-1:A>=224&&(e=-2),A>=113&&A<=117&&(i=d.pop(),isNaN(i)||(e=2*-i));e<0&&d.length>0;)d.pop(),e++;for(;e>0;)d.push(NaN),e--}}t.tooComplexToFollowFunctions=p;var S=[c];l>c.length&&S.push(new Uint8Array(l-c.length)),u>h&&((0,a.warn)("TT: complementing a missing function tail"),S.push(new Uint8Array([34,45]))),function(e,t){if(t.length>1){var r,a,i=0;for(r=0,a=t.length;r>>0,s=[];for(let t=0;t>>0);const o={ttcTag:t,majorVersion:r,minorVersion:i,numFonts:n,offsetTable:s};switch(r){case 1:return o;case 2:return o.dsigTag=e.getInt32()>>>0,o.dsigLength=e.getInt32()>>>0,o.dsigOffset=e.getInt32()>>>0,o}throw new a.FormatError(`Invalid TrueType Collection majorVersion: ${r}.`)}(e);for(let n=0;n0||!(o.cMap instanceof u.IdentityCMap));if("OTTO"===k.version&&!t||!S.head||!S.hhea||!S.maxp||!S.post)return _=new d.Stream(S["CFF "].data),x=new E(_,o),v(o),this.convert(e,x,o);delete S.glyf,delete S.loca,delete S.fpgm,delete S.prep,delete S["cvt "],this.isOpenType=!0}if(!S.maxp)throw new a.FormatError('Required "maxp" table is not found');t.pos=(t.start||0)+S.maxp.offset;var I=t.getInt32();const F=t.getUint16();let N=F+1,B=!0;N>65535&&(B=!1,N=F,(0,a.warn)("Not enough space in glyfs to duplicate first glyph."));var U=0,j=0;I>=65536&&S.maxp.length>=22&&(t.pos+=8,t.getUint16()>2&&(S.maxp.data[14]=0,S.maxp.data[15]=2),t.pos+=4,U=t.getUint16(),t.pos+=4,j=t.getUint16()),S.maxp.data[4]=N>>8,S.maxp.data[5]=255&N;var q=function(e,t,r,i){var n={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};if(e&&w(e,n),t&&w(t,n),e&&function(e,t){if(!e.tooComplexToFollowFunctions){if(e.functionsDefined.length>t)return(0,a.warn)("TT: more functions defined than expected"),void(e.hintsValid=!1);for(var r=0,i=e.functionsUsed.length;rt)return(0,a.warn)("TT: invalid function id: "+r),void(e.hintsValid=!1);if(e.functionsUsed[r]&&!e.functionsDefined[r])return(0,a.warn)("TT: undefined function: "+r),void(e.hintsValid=!1)}}}(n,i),r&&1&r.length){var s=new Uint8Array(r.length+1);s.set(r.data),r.data=s}return n.hintsValid}(S.fpgm,S.prep,S["cvt "],U);if(q||(delete S.fpgm,delete S.prep,delete S["cvt "]),function(e,t,r,i,n){if(t){e.pos=(e.start?e.start:0)+t.offset,e.pos+=4,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=8,e.pos+=2;var s=e.getUint16();s>i&&((0,a.info)("The numOfMetrics ("+s+") should not be greater than the numGlyphs ("+i+")"),s=i,t.data[34]=(65280&s)>>8,t.data[35]=255&s);var o=i-s-(r.length-4*s>>1);if(o>0){var c=new Uint8Array(r.length+2*o);c.set(r.data),n&&(c[r.length]=r.data[2],c[r.length+1]=r.data[3]),r.data=c}}else r&&(r.data=null)}(t,S.hhea,S.hmtx,N,B),!S.head)throw new a.FormatError('Required "head" table is not found');!function(e,t,i){var n,s,o,c,l=e.data,h=(n=l[0],s=l[1],o=l[2],c=l[3],(n<<24)+(s<<16)+(o<<8)+c);h>>16!=1&&((0,a.info)("Attempting to fix invalid version in head table: "+h),l[0]=0,l[1]=1,l[2]=0,l[3]=0);var u=r(l[50],l[51]);if(u<0||u>1){(0,a.info)("Attempting to fix invalid indexToLocFormat in head table: "+u);var d=t+1;if(i===d<<1)l[50]=0,l[51]=0;else{if(i!==d<<2)throw new a.FormatError("Could not fix indexToLocFormat: "+u);l[50]=0,l[51]=1}}}(S.head,F,P?S.loca.length:0);var H=Object.create(null);if(P){var G=r(S.head.data[50],S.head.data[51]),z=function(e,t,r,a,i,n,s){var o,c,l;a?(o=4,c=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},l=function(e,t,r){e[t]=r>>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r}):(o=2,c=function(e,t){return e[t]<<9|e[t+1]<<1},l=function(e,t,r){e[t]=r>>9&255,e[t+1]=r>>1&255});var h=n?r+1:r,u=o*(1+h),d=new Uint8Array(u);d.set(e.data.subarray(0,u)),e.data=d;var f,g,m=t.data,b=m.length,y=new Uint8Array(b),v=c(d,0),w=0,A=Object.create(null);for(l(d,0,w),f=0,g=o;fb&&(b+3&-4)===k&&(k=b),k>b&&(v=k);var S=p(m,v,k,y,w,i),x=S.length;0===x&&(A[f]=!0),S.sizeOfInstructions>s&&(s=S.sizeOfInstructions),l(d,g,w+=x),v=k}if(0===w){var C=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(f=0,g=o;f_+w?t.data=y.subarray(0,_+w):(t.data=new Uint8Array(_+w),t.data.set(y.subarray(0,w))),t.data.set(y.subarray(0,_),w),l(e.data,d.length-o,w+_)}else t.data=y.subarray(0,w);return{missingGlyphs:A,maxSizeOfInstructions:s}}(S.loca,S.glyf,F,G,q,B,j);H=z.missingGlyphs,I>=65536&&S.maxp.length>=22&&(S.maxp.data[26]=z.maxSizeOfInstructions>>8,S.maxp.data[27]=255&z.maxSizeOfInstructions)}if(!S.hhea)throw new a.FormatError('Required "hhea" table is not found');0===S.hhea.data[10]&&0===S.hhea.data[11]&&(S.hhea.data[10]=255,S.hhea.data[11]=255);var W={unitsPerEm:r(S.head.data[18],S.head.data[19]),yMax:r(S.head.data[42],S.head.data[43]),yMin:f(S.head.data[38],S.head.data[39]),ascent:r(S.hhea.data[4],S.hhea.data[5]),descent:f(S.hhea.data[6],S.hhea.data[7])};this.ascent=W.ascent/W.unitsPerEm,this.descent=W.descent/W.unitsPerEm,S.post&&function(e,r,i){var n=(t.start?t.start:0)+e.offset;t.pos=n;var s,o=n+e.length,c=t.getInt32();t.skip(28);var l,h=!0;switch(c){case 65536:s=y;break;case 131072:var u=t.getUint16();if(u!==i){h=!1;break}var d=[];for(l=0;l=32768){h=!1;break}d.push(f)}if(!h)break;for(var g=[],p=[];t.pos65535)throw new a.FormatError("Max size of CID is 65,535");var r=-1;K?r=t:void 0!==Y[t]&&(r=Y[t]),r>=0&&r>>0,g=!1;if((!o||o.platformId!==u||o.encodingId!==d)&&(0===u&&0===d||1===u&&0===d?g=!0:3!==u||1!==d||!i&&o?r&&3===u&&0===d&&(g=!0,l=!0):(g=!0,r||(l=!0)),g&&(o={platformId:u,encodingId:d,offset:f}),l))break}if(o&&(t.pos=s+o.offset),!o||-1===t.peekByte())return(0,a.warn)("Could not find a preferred cmap table."),{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1};var p=t.getUint16();t.skip(4);var m,b,y=!1,v=[];if(0===p){for(m=0;m<256;m++){var w=t.getByte();w&&v.push({charCode:m,glyphId:w})}y=!0}else if(4===p){var A=t.getUint16()>>1;t.skip(6);var k,S=[];for(k=0;k>1)-(A-k);n.offsetIndex=_,x=Math.max(x,_+n.end-n.start+1)}else n.offsetIndex=-1}var P=[];for(m=0;m0&&X(oe)&&(V[e]=oe)}}}}else if(0===Q&&0===J)for(let e=0;e=61440&&t<=61695&&(t&=255),V[t]=Z[e].glyphId}}0===V.length&&(V[0]=0);let ce=N-1;B||(ce=0);var le=R(V,X,ce);if(this.toFontChar=le.toFontChar,S.cmap={tag:"cmap",data:L(le.charCodeToGlyphId,N)},S["OS/2"]&&function(e,t){t.pos=(t.start||0)+e.offset;var r=t.getUint16();t.skip(60);var a=t.getUint16();return!(r<4&&768&a||t.getUint16()>t.getUint16()||(t.skip(6),0===t.getUint16()||(e.data[8]=e.data[9]=0,0)))}(S["OS/2"],t)||(S["OS/2"]={tag:"OS/2",data:O(o,le.charCodeToGlyphId,W)}),!P)try{_=new d.Stream(S["CFF "].data),x=new i.CFFParser(_,o,!0).parse(),x.duplicateFirstGlyph();var he=new i.CFFCompiler(x);S["CFF "].data=he.compile()}catch(e){(0,a.warn)("Failed to compile font "+o.loadedName)}if(S.name){var ue=m(S.name);S.name.data=D(e,ue)}else S.name={tag:"name",data:D(this.name)};var de=new C(k.version);for(var fe in S)de.addTable(fe,S[fe].data);return de.toArray()},convert:function(e,t,r){r.fixedPitch=!1,r.builtInEncoding&&function(e,t){if(!e.hasIncludedToUnicodeMap&&!(e.hasEncoding||t===e.defaultEncoding||e.toUnicode instanceof x)){var r=[],a=(0,n.getGlyphsUnicode)();for(var i in t){var s=t[i],o=(0,c.getUnicodeForGlyph)(s,a);-1!==o&&(r[i]=String.fromCharCode(o))}e.toUnicode.amend(r)}}(r,r.builtInEncoding);let i=1;t instanceof E&&(i=t.numGlyphs-1);var o=t.getGlyphMapping(r),l=R(o,t.hasGlyphId.bind(t),i);this.toFontChar=l.toFontChar;var h=t.numGlyphs;function u(e,t){var r=null;for(var a in e)t===e[a]&&(r||(r=[]),r.push(0|a));return r}function d(e,t){for(var r in e)if(t===e[r])return 0|r;return l.charCodeToGlyphId[l.nextAvailableFontCharCode]=t,l.nextAvailableFontCharCode++}var f=t.seacs;if(f&&f.length){var g=r.fontMatrix||a.FONT_IDENTITY_MATRIX,p=t.getCharset(),m=Object.create(null);for(var b in f){var y=f[b|=0],v=s.StandardEncoding[y[2]],w=s.StandardEncoding[y[3]],A=p.indexOf(v),k=p.indexOf(w);if(!(A<0||k<0)){var S={x:y[0]*g[0]+y[1]*g[2]+g[4],y:y[0]*g[1]+y[1]*g[3]+g[5]},T=u(o,b);if(T)for(let e=0,t=T.length;e=0?a:0;else if(l)for(i in t)c[i]=t[i];else for(o=s.StandardEncoding,i=0;i=0?a:0;var h,u=e.differences;if(u)for(i in u){var d=u[i];if(-1===(a=r.indexOf(d))){h||(h=(0,n.getGlyphsUnicode)());var f=A(d,h);f!==d&&(a=r.indexOf(f))}c[i]=a>=0?a:0}return c}t.ErrorFont=P;var I=function(){function e(e,t,r){for(var a,i=e.length,n=t.length,s=i-n,o=r,c=!1;o=n){for(o+=a;o=0&&(n[s]=r)}return T(e,n,a)},hasGlyphId:function(e){return!(e<0||e>=this.numGlyphs)&&(0===e||this.charstrings[e-1].charstring.length>0)},getSeacs:function(e){var t,r,a=[];for(t=0,r=e.length;t0;y--)b[y]-=b[y-1];g.setByName(m,b)}}s.topDict.privateDict=g;var v=new i.CFFIndex;for(l=0,h=a.length;l=t)throw new a.FormatError("Invalid CFF header");0!==r&&((0,a.info)("cff data is shifted"),e=e.subarray(r),this.bytes=e);var i=e[0],n=e[1],s=e[2],o=e[3];return{obj:new l(i,n,s,o),endPos:s}},parseDict:function(e){var t=0;function r(){var r=e[t++];return 30===r?function(){var r="";const a=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(var i=e.length;t>4,o=15&n;if(15===s)break;if(r+=a[s],15===o)break;r+=a[o]}return parseFloat(r)}():28===r?r=((r=e[t++])<<24|e[t++]<<16)>>16:29===r?r=(r=(r=(r=e[t++])<<8|e[t++])<<8|e[t++])<<8|e[t++]:r>=32&&r<=246?r-139:r>=247&&r<=250?256*(r-247)+e[t++]+108:r>=251&&r<=254?-256*(r-251)-e[t++]-108:((0,a.warn)('CFFParser_parseDict: "'+r+'" is a reserved command.'),NaN)}var i=[],n=[];t=0;for(var s=e.length;t10)return!1;for(var o=r.stackSize,c=r.stack,l=i.length,h=0;h>16,h+=2,o++;else if(14===u){if(o>=4&&(o-=4,this.seacAnalysisEnabled))return r.seac=c.slice(o,o+4),!1;d=e[u]}else if(u>=32&&u<=246)c[o]=u-139,o++;else if(u>=247&&u<=254)c[o]=u<251?(u-247<<8)+i[h]+108:-(u-251<<8)-i[h]-108,h++,o++;else if(255===u)c[o]=(i[h]<<24|i[h+1]<<16|i[h+2]<<8|i[h+3])/65536,h+=4,o++;else if(19===u||20===u)r.hints+=o>>1,h+=r.hints+7>>3,o%=2,d=e[u];else{if(10===u||29===u){var g;if(!(g=10===u?n:s))return d=e[u],(0,a.warn)("Missing subrsIndex for "+d.id),!1;var p=32768;g.count<1240?p=107:g.count<33900&&(p=1131);var m=c[--o]+p;if(m<0||m>=g.count||isNaN(m))return d=e[u],(0,a.warn)("Out of bounds subrIndex for "+d.id),!1;if(r.stackSize=o,r.callDepth++,!this.parseCharString(r,g.get(m),n,s))return!1;r.callDepth--,o=r.stackSize;continue}if(11===u)return r.stackSize=o,!0;d=e[u]}if(d){if(d.stem&&(r.hints+=o>>1,3===u||23===u?r.hasVStems=!0:!r.hasVStems||1!==u&&18!==u||((0,a.warn)("CFF stem hints are in wrong order"),i[h-1]=1===u?3:23)),"min"in d&&!r.undefStack&&o=2&&d.stem?o%=2:o>1&&(0,a.warn)("Found too many parameters for stack-clearing command"),o>0&&c[o-1]>=0&&(r.width=c[o-1])),"stackDelta"in d?("stackFn"in d&&d.stackFn(c,o),o+=d.stackDelta):d.stackClearing?o=0:d.resetStack?(o=0,r.undefStack=!1):d.undefStack&&(o=0,r.undefStack=!0,r.firstStackClearing=!1)}}return r.stackSize=o,!0},parseCharStrings({charStrings:e,localSubrIndex:t,globalSubrIndex:r,fdSelect:i,fdArray:n,privateDict:s}){for(var o=[],c=[],l=e.count,h=0;h=n.length&&((0,a.warn)("Invalid fd index for glyph index."),f=!1),f&&(g=(p=n[m].privateDict).subrsIndex)}else t&&(g=t);if(f&&(f=this.parseCharString(d,u,g,r)),null!==d.width){const e=p.getByName("nominalWidthX");c[h]=e+d.width}else{const e=p.getByName("defaultWidthX");c[h]=e}null!==d.seac&&(o[h]=d.seac),f||e.set(h,new Uint8Array([14]))}return{charStrings:e,seacs:o,widths:c}},emptyPrivateDictionary:function(e){var t=this.createDict(g,[],e.strings);e.setByKey(18,[0,0]),e.privateDict=t},parsePrivateDict:function(e){if(e.hasName("Private")){var t=e.getByName("Private");if(Array.isArray(t)&&2===t.length){var r=t[0],a=t[1];if(0===r||a>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=a+r,n=this.bytes.subarray(a,i),s=this.parseDict(n),o=this.createDict(g,s,e.strings);if(e.privateDict=o,o.getByName("Subrs")){var c=o.getByName("Subrs"),l=a+c;if(0===c||l>=this.bytes.length)this.emptyPrivateDictionary(e);else{var h=this.parseIndex(l);o.subrsIndex=h.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)},parseCharsets:function(e,t,r,n){if(0===e)return new m(!0,p.ISO_ADOBE,i.ISOAdobeCharset);if(1===e)return new m(!0,p.EXPERT,i.ExpertCharset);if(2===e)return new m(!0,p.EXPERT_SUBSET,i.ExpertSubsetCharset);var s=this.bytes,o=e,c=s[e++];const l=[n?0:".notdef"];var h,u,d;switch(t-=1,c){case 0:for(d=0;d=65535)(0,a.warn)("Not enough space in charstrings to duplicate first glyph.");else{var e=this.charStrings.get(0);this.charStrings.add(e),this.isCIDFont&&this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0])}},hasGlyphId:function(e){return!(e<0||e>=this.charStrings.count)&&this.charStrings.get(e).length>0}},e}();t.CFF=c;var l=function(e,t,r,a){this.major=e,this.minor=t,this.hdrSize=r,this.offSize=a};t.CFFHeader=l;var h=function(){function e(){this.strings=[]}return e.prototype={get:function(e){return e>=0&&e<=390?s[e]:e-391<=this.strings.length?this.strings[e-391]:s[0]},getSID:function(e){let t=s.indexOf(e);return-1!==t?t:(t=this.strings.indexOf(e),-1!==t?t+391:-1)},add:function(e){this.strings.push(e)},get count(){return this.strings.length}},e}();t.CFFStrings=h;var u=function(){function e(){this.objects=[],this.length=0}return e.prototype={add:function(e){this.length+=e.length,this.objects.push(e)},set:function(e,t){this.length+=t.length-this.objects[e].length,this.objects[e]=t},get:function(e){return this.objects[e]},get count(){return this.objects.length}},e}();t.CFFIndex=u;var d=function(){function e(e,t){this.keyToNameMap=e.keyToNameMap,this.nameToKeyMap=e.nameToKeyMap,this.defaults=e.defaults,this.types=e.types,this.opcodes=e.opcodes,this.order=e.order,this.strings=t,this.values=Object.create(null)}return e.prototype={setByKey:function(e,t){if(!(e in this.keyToNameMap))return!1;var r=t.length;if(0===r)return!0;for(var i=0;i=this.fdSelect.length?-1:this.fdSelect[e]}},e}();t.CFFFDSelect=y;var v=function(){function e(){this.offsets=Object.create(null)}return e.prototype={isTracking:function(e){return e in this.offsets},track:function(e,t){if(e in this.offsets)throw new a.FormatError("Already tracking location of "+e);this.offsets[e]=t},offset:function(e){for(var t in this.offsets)this.offsets[t]+=e},setEntryLocation:function(e,t,r){if(!(e in this.offsets))throw new a.FormatError("Not tracking location of "+e);for(var i=r.data,n=this.offsets[e],s=0,o=t.length;s>24&255,i[h]=f>>16&255,i[u]=f>>8&255,i[d]=255&f}}},e}(),w=function(){function e(e){this.cff=e}return e.prototype={compile:function(){var e=this.cff,t={data:[],length:0,add:function(e){this.data=this.data.concat(e),this.length=this.data.length}},r=this.compileHeader(e.header);t.add(r);var i=this.compileNameIndex(e.names);if(t.add(i),e.isCIDFont&&e.topDict.hasName("FontMatrix")){var n=e.topDict.getByName("FontMatrix");e.topDict.removeByName("FontMatrix");for(var s=0,o=e.fdArray.length;s=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e]},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new u,r=0,i=e.length;r"~"||"["===l||"]"===l||"("===l||")"===l||"{"===l||"}"===l||"<"===l||">"===l||"/"===l||"%"===l)&&(l="_"),o[c]=l}""===(o=o.join(""))&&(o="Bad_Font_Name"),t.add((0,a.stringToBytes)(o))}return this.compileIndex(t)},compileTopDicts:function(e,t,r){for(var a=[],i=new u,n=0,s=e.length;n>8&255,255&s]);else{n=new Uint8Array(1+2*s),n[0]=0;let t=0;const i=e.charset.length;let o=!1;for(let s=1;s>8&255,n[s+1]=255&c}}return this.compileTypedArray(n)},compileEncoding:function(e){return this.compileTypedArray(e.raw)},compileFDSelect:function(e){const t=e.format;let r,a;switch(t){case 0:for(r=new Uint8Array(1+e.fdSelect.length),r[0]=t,a=0;a>8&255,255&i,n];for(a=1;a>8&255,255&a,t),n=t)}const o=(s.length-3)/3;s[1]=o>>8&255,s[2]=255&o,s.push(a>>8&255,255&a),r=new Uint8Array(s)}return this.compileTypedArray(r)},compileTypedArray:function(e){for(var t=[],r=0,a=e.length;r>8&255,255&a],o=1;for(i=0;i>8&255,255&c):3===n?s.push(c>>16&255,c>>8&255,255&c):s.push(c>>>24&255,c>>16&255,c>>8&255,255&c),r[i]&&(c+=r[i].length);for(i=0;i=65520&&e<=65535?0:e>=62976&&e<=63743?i()[e]||e:173===e?45:e},t.reverseIfRtl=function(e){var t,r,a=e.length;if(a<=1||!((t=e.charCodeAt(0))>=(r=n[13]).begin&&t=(r=n[11]).begin&&t=0;s--)i+=e[s];return i},t.getUnicodeRangeFor=function(e){for(var t=0,r=n.length;t=a.begin&&e=5&&i<=7))return-1;a=e.substring(1)}if(a===a.toUpperCase()&&(r=parseInt(a,16))>=0)return r}return-1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FontRendererFactory=void 0;var a=r(2),i=r(30),n=r(33),s=r(32),o=r(12),c=function(){function e(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function t(e,t){return e[t]<<8|e[t+1]}function r(e){const t=e.length;let r=32768;return t<1240?r=107:t<33900&&(r=1131),r}function c(r,i,n){var s,o,c,l=1===t(r,i+2)?e(r,i+8):e(r,i+16),h=t(r,i+l);if(4===h){t(r,i+l+2);var u=t(r,i+l+6)>>1;for(o=i+l+14,s=[],c=0;c>1;r=0&&e>16,h=0,u=0;if(c+=10,l<0)do{o=t[c]<<8|t[c+1];var d,f,g=t[c+2]<<8|t[c+3];c+=4,1&o?(d=(t[c]<<24|t[c+1]<<16)>>16,f=(t[c+2]<<24|t[c+3]<<16)>>16,c+=4):(d=t[c++],f=t[c++]),2&o?(h=d,u=f):(h=0,u=0);var p=1,m=1,b=0,y=0;8&o?(p=m=(t[c]<<24|t[c+1]<<16)/1073741824,c+=2):64&o?(p=(t[c]<<24|t[c+1]<<16)/1073741824,m=(t[c+2]<<24|t[c+3]<<16)/1073741824,c+=4):128&o&&(p=(t[c]<<24|t[c+1]<<16)/1073741824,b=(t[c+2]<<24|t[c+3]<<16)/1073741824,y=(t[c+4]<<24|t[c+5]<<16)/1073741824,m=(t[c+6]<<24|t[c+7]<<16)/1073741824,c+=8);var v=a.glyphs[g];v&&(r.push({cmd:"save"}),r.push({cmd:"transform",args:[p,b,y,m,h,u]}),e(v,r,a),r.push({cmd:"restore"}))}while(32&o);else{var w,A,k=[];for(w=0;w0;)x.push({flags:o})}for(w=0;w>16,c+=2;break;case 2:h-=t[c++];break;case 18:h+=t[c++]}x[w].x=h}for(w=0;w>16,c+=2;break;case 4:u-=t[c++];break;case 36:u+=t[c++]}x[w].y=u}var _=0;for(c=0;c>1,_=!0;break;case 4:g+=d.pop(),c(f,g),_=!0;break;case 5:for(;d.length>0;)f+=d.shift(),g+=d.shift(),l(f,g);break;case 6:for(;d.length>0&&(l(f+=d.shift(),g),0!==d.length);)g+=d.shift(),l(f,g);break;case 7:for(;d.length>0&&(g+=d.shift(),l(f,g),0!==d.length);)l(f+=d.shift(),g);break;case 8:for(;d.length>0;)y=f+d.shift(),w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A+d.shift(),u(y,w,v,A,f,g);break;case 10:if(x=d.pop(),C=null,n.isCFFCIDFont){const e=n.fdSelect.getFDIndex(o);if(e>=0&&eMath.abs(g-I)?f+=d.shift():g+=d.shift(),u(y,w,v,A,f,g);break;default:throw new a.FormatError("unknown operator: 12 "+P)}break;case 14:if(d.length>=4){var E=d.pop(),F=d.pop();g=d.pop(),f=d.pop(),i.push({cmd:"save"}),i.push({cmd:"translate",args:[f,g]});var R=h(n.cmap,String.fromCharCode(n.glyphNameMap[s.StandardEncoding[E]]));e(n.glyphs[R.glyphId],i,n,R.glyphId),i.push({cmd:"restore"}),R=h(n.cmap,String.fromCharCode(n.glyphNameMap[s.StandardEncoding[F]])),e(n.glyphs[R.glyphId],i,n,R.glyphId)}return;case 18:p+=d.length>>1,_=!0;break;case 19:case 20:b+=(p+=d.length>>1)+7>>3,_=!0;break;case 21:g+=d.pop(),c(f+=d.pop(),g),_=!0;break;case 22:c(f+=d.pop(),g),_=!0;break;case 23:p+=d.length>>1,_=!0;break;case 24:for(;d.length>2;)y=f+d.shift(),w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A+d.shift(),u(y,w,v,A,f,g);f+=d.shift(),g+=d.shift(),l(f,g);break;case 25:for(;d.length>6;)f+=d.shift(),g+=d.shift(),l(f,g);y=f+d.shift(),w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A+d.shift(),u(y,w,v,A,f,g);break;case 26:for(d.length%2&&(f+=d.shift());d.length>0;)y=f,w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v,g=A+d.shift(),u(y,w,v,A,f,g);break;case 27:for(d.length%2&&(g+=d.shift());d.length>0;)u(y=f+d.shift(),w=g,v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A);break;case 28:d.push((m[b]<<24|m[b+1]<<16)>>16),b+=2;break;case 29:x=d.pop()+n.gsubrsBias,(C=n.gsubrs[x])&&t(C);break;case 30:for(;d.length>0&&(y=f,w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A+(1===d.length?d.shift():0),u(y,w,v,A,f,g),0!==d.length);)y=f+d.shift(),w=g,v=y+d.shift(),A=w+d.shift(),g=A+d.shift(),u(y,w,v,A,f=v+(1===d.length?d.shift():0),g);break;case 31:for(;d.length>0&&(y=f+d.shift(),w=g,v=y+d.shift(),A=w+d.shift(),g=A+d.shift(),u(y,w,v,A,f=v+(1===d.length?d.shift():0),g),0!==d.length);)y=f,w=g+d.shift(),v=y+d.shift(),A=w+d.shift(),f=v+d.shift(),g=A+(1===d.length?d.shift():0),u(y,w,v,A,f,g);break;default:if(P<32)throw new a.FormatError("unknown operator: "+P);P<247?d.push(P-139):P<251?d.push(256*(P-247)+m[b++]+108):P<255?d.push(256*-(P-251)-m[b++]-108):(d.push((m[b]<<24|m[b+1]<<16|m[b+2]<<8|m[b+3])/65536),b+=4)}_&&(d.length=0)}}(t)}(e,t,this,i)}}return{create:function(r,i){for(var n,s,o,h,u,d,p=new Uint8Array(r.data),m=t(p,4),b=0,y=12;ba)return!0;for(var i=a-e,n=i;n>8&255,255&s):(s=65536*s|0,this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s))}return this.output.push.apply(this.output,t),r?this.stack.splice(i,e):this.stack.length=0,!1}},d}(),c=function(){function e(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function t(e,t,r){if(r>=e.length)return new Uint8Array(0);var a,i,n=0|t;for(a=0;a>8,n=52845*(c+n)+22719&65535}return o}function r(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function s(r,a,s){if(a){var o=r.getBytes(),c=!((e(o[0])||(0,i.isWhiteSpace)(o[0]))&&e(o[1])&&e(o[2])&&e(o[3])&&e(o[4])&&e(o[5])&&e(o[6])&&e(o[7]));r=new n.Stream(c?t(o,55665,4):function(t,r,a){var i,n,s=0|r,o=t.length,c=new Uint8Array(o>>>1);for(i=0,n=0;i>8,s=52845*(u+s)+22719&65535}}}return c.slice(a,n)}(o,55665,4))}this.seacAnalysisEnabled=!!s,this.stream=r,this.nextChar()}return s.prototype={readNumberArray:function(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function(){var e=this.getToken();return parseFloat(e||0)},readInt:function(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function(){return"true"===this.getToken()?1:0},nextChar:function(){return this.currentChar=this.stream.getByte()},getToken:function(){for(var e=!1,t=this.currentChar;;){if(-1===t)return null;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!(0,i.isWhiteSpace)(t))break;t=this.nextChar()}if(r(t))return this.nextChar(),String.fromCharCode(t);var a="";do{a+=String.fromCharCode(t),t=this.nextChar()}while(t>=0&&!(0,i.isWhiteSpace)(t)&&!r(t));return a},readCharStrings:function(e,r){return-1===r?e:t(e,4330,r)},extractFontProgram:function(e){var t=this.stream,r=[],a=[],i=Object.create(null);i.lenIV=4;for(var n,s,c,l,h,u={subrs:[],charstrings:[],properties:{privateData:i}};null!==(n=this.getToken());)if("/"===n)switch(n=this.getToken()){case"CharStrings":for(this.getToken(),this.getToken(),this.getToken(),this.getToken();null!==(n=this.getToken())&&"end"!==n;)if("/"===n){var d=this.getToken();s=this.readInt(),this.getToken(),c=s>0?t.getBytes(s):new Uint8Array(0),l=u.properties.privateData.lenIV,h=this.readCharStrings(c,l),this.nextChar(),"noaccess"===(n=this.getToken())&&this.getToken(),a.push({glyph:d,encoded:h})}break;case"Subrs":for(this.readInt(),this.getToken();"dup"===this.getToken();){const e=this.readInt();s=this.readInt(),this.getToken(),c=s>0?t.getBytes(s):new Uint8Array(0),l=u.properties.privateData.lenIV,h=this.readCharStrings(c,l),this.nextChar(),"noaccess"===(n=this.getToken())&&this.getToken(),r[e]=h}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var f=this.readNumberArray();f.length>0&&f.length;break;case"StemSnapH":case"StemSnapV":u.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":u.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":u.properties.privateData[n]=this.readNumber();break;case"ForceBold":u.properties.privateData[n]=this.readBoolean()}for(var g=0;g-1&&void 0===e.widths[t]&&t>=e.firstChar&&t<=e.lastChar&&(e.widths[t]=p.width)}}return u},extractFontHeader:function(e){for(var t;null!==(t=this.getToken());)if("/"===t)switch(t=this.getToken()){case"FontMatrix":var r=this.readNumberArray();e.fontMatrix=r;break;case"Encoding":var i,n=this.getToken();if(/^\d+$/.test(n)){i=[];var s=0|parseInt(n,10);this.getToken();for(var o=0;o