UNPKG

pdfjs-dist

Version:

Generic build of Mozilla's PDF.js library.

21 lines • 418 kB
/** * @licstart The following is the entire license notice for the * JavaScript code in this page * * Copyright 2024 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * JavaScript code in this page */var A={d:(I,g)=>{for(var Q in g)A.o(g,Q)&&!A.o(I,Q)&&Object.defineProperty(I,Q,{enumerable:!0,get:g[Q]})},o:(A,I)=>Object.prototype.hasOwnProperty.call(A,I)},__webpack_exports__ = globalThis.pdfjsImageDecoders = {};A.d(__webpack_exports__,{Jbig2Error:()=>Jbig2Error,Jbig2Image:()=>Jbig2Image,JpegError:()=>JpegError,JpegImage:()=>JpegImage,JpxError:()=>JpxError,JpxImage:()=>JpxImage,VerbosityLevel:()=>I,getVerbosityLevel:()=>getVerbosityLevel,setVerbosityLevel:()=>setVerbosityLevel});"object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&process.type;const I={ERRORS:0,WARNINGS:1,INFOS:5};let g=I.WARNINGS;function setVerbosityLevel(A){Number.isInteger(A)&&(g=A)}function getVerbosityLevel(){return g}function info(A){g>=I.INFOS&&console.log(`Info: ${A}`)}function util_warn(A){g>=I.WARNINGS&&console.log(`Warning: ${A}`)}function util_unreachable(A){throw new Error(A)}function util_shadow(A,I,g,Q=!1){Object.defineProperty(A,I,{value:g,enumerable:!Q,configurable:!0,writable:!1});return g}const Q=function BaseExceptionClosure(){function BaseException(A,I){this.message=A;this.name=I}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();class FormatError extends Q{constructor(A){super(A,"FormatError")}}function bytesToString(A){"object"==typeof A&&void 0!==A?.length||util_unreachable("Invalid argument for bytesToString");const I=A.length,g=8192;if(I<g)return String.fromCharCode.apply(null,A);const Q=[];for(let B=0;B<I;B+=g){const C=Math.min(B+g,I),E=A.subarray(B,C);Q.push(String.fromCharCode.apply(null,E))}return Q.join("")}class util_FeatureTest{static get isLittleEndian(){return util_shadow(this,"isLittleEndian",function isLittleEndian(){const A=new Uint8Array(4);A[0]=1;return 1===new Uint32Array(A.buffer,0,1)[0]}())}static get isEvalSupported(){return util_shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return util_shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?util_shadow(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):util_shadow(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return util_shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}Array.from(Array(256).keys(),(A=>A.toString(16).padStart(2,"0")));Symbol("CIRCULAR_REF"),Symbol("EOF");Object.create(null),Object.create(null),Object.create(null);Symbol.iterator;Symbol.iterator;class base_stream_BaseStream{get length(){util_unreachable("Abstract getter `length` accessed")}get isEmpty(){util_unreachable("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return util_shadow(this,"isDataLoaded",!0)}getByte(){util_unreachable("Abstract method `getByte` called")}getBytes(A){util_unreachable("Abstract method `getBytes` called")}async getImageData(A,I){return this.getBytes(A,I)}async asyncGetBytes(){util_unreachable("Abstract method `asyncGetBytes` called")}get isAsync(){return!1}get canAsyncDecodeImageFromBuffer(){return!1}async getTransferableImage(){return null}peekByte(){const A=this.getByte();-1!==A&&this.pos--;return A}peekBytes(A){const I=this.getBytes(A);this.pos-=I.length;return I}getUint16(){const A=this.getByte(),I=this.getByte();return-1===A||-1===I?-1:(A<<8)+I}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getByteRange(A,I){util_unreachable("Abstract method `getByteRange` called")}getString(A){return bytesToString(this.getBytes(A))}skip(A){this.pos+=A||1}reset(){util_unreachable("Abstract method `reset` called")}moveStart(){util_unreachable("Abstract method `moveStart` called")}makeSubStream(A,I,g=null){util_unreachable("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}function log2(A){return A<=0?0:Math.ceil(Math.log2(A))}function readInt8(A,I){return A[I]<<24>>24}function readUint16(A,I){return A[I]<<8|A[I+1]}function readUint32(A,I){return(A[I]<<24|A[I+1]<<16|A[I+2]<<8|A[I+3])>>>0}const B=[{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}];class ArithmeticDecoder{constructor(A,I,g){this.data=A;this.bp=I;this.dataEnd=g;this.chigh=A[I];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 A=this.data;let I=this.bp;if(255===A[I])if(A[I+1]>143){this.clow+=65280;this.ct=8}else{I++;this.clow+=A[I]<<9;this.ct=7;this.bp=I}else{I++;this.clow+=I<this.dataEnd?A[I]<<8:65280;this.ct=8;this.bp=I}if(this.clow>65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(A,I){let g=A[I]>>1,Q=1&A[I];const C=B[g],E=C.qe;let i,D=this.a-E;if(this.chigh<E)if(D<E){D=E;i=Q;g=C.nmps}else{D=E;i=1^Q;1===C.switchFlag&&(Q=i);g=C.nlps}else{this.chigh-=E;if(0!=(32768&D)){this.a=D;return Q}if(D<E){i=1^Q;1===C.switchFlag&&(Q=i);g=C.nlps}else{i=Q;g=C.nmps}}do{0===this.ct&&this.byteIn();D<<=1;this.chigh=this.chigh<<1&65535|this.clow>>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0==(32768&D));this.a=D;A[I]=g<<1|Q;return i}}const C=-1,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]],i=[[-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]],D=[[-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]],o=[[-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]],h=[[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]];class CCITTFaxDecoder{constructor(A,I={}){if(!A||"function"!=typeof A.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=A;this.eof=!1;this.encoding=I.K||0;this.eoline=I.EndOfLine||!1;this.byteAlign=I.EncodedByteAlign||!1;this.columns=I.Columns||1728;this.rows=I.Rows||0;this.eoblock=I.EndOfBlock??!0;this.black=I.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;let g;for(;0===(g=this._lookBits(12));)this._eatBits(1);1===g&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}readNextChar(){if(this.eof)return-1;const A=this.refLine,I=this.codingLine,g=this.columns;let Q,B,E,i,D;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let E,D,o;if(this.nextLine2D){for(i=0;I[i]<g;++i)A[i]=I[i];A[i++]=g;A[i]=g;I[0]=0;this.codingPos=0;Q=0;B=0;for(;I[this.codingPos]<g;){E=this._getTwoDimCode();switch(E){case 0:this._addPixels(A[Q+1],B);A[Q+1]<g&&(Q+=2);break;case 1:E=D=0;if(B){do{E+=o=this._getBlackCode()}while(o>=64);do{D+=o=this._getWhiteCode()}while(o>=64)}else{do{E+=o=this._getWhiteCode()}while(o>=64);do{D+=o=this._getBlackCode()}while(o>=64)}this._addPixels(I[this.codingPos]+E,B);I[this.codingPos]<g&&this._addPixels(I[this.codingPos]+D,1^B);for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2;break;case 7:this._addPixels(A[Q]+3,B);B^=1;if(I[this.codingPos]<g){++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 5:this._addPixels(A[Q]+2,B);B^=1;if(I[this.codingPos]<g){++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 3:this._addPixels(A[Q]+1,B);B^=1;if(I[this.codingPos]<g){++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 2:this._addPixels(A[Q],B);B^=1;if(I[this.codingPos]<g){++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 8:this._addPixelsNeg(A[Q]-3,B);B^=1;if(I[this.codingPos]<g){Q>0?--Q:++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 6:this._addPixelsNeg(A[Q]-2,B);B^=1;if(I[this.codingPos]<g){Q>0?--Q:++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case 4:this._addPixelsNeg(A[Q]-1,B);B^=1;if(I[this.codingPos]<g){Q>0?--Q:++Q;for(;A[Q]<=I[this.codingPos]&&A[Q]<g;)Q+=2}break;case C:this._addPixels(g,0);this.eof=!0;break;default:info("bad 2d code");this._addPixels(g,0);this.err=!0}}}else{I[0]=0;this.codingPos=0;B=0;for(;I[this.codingPos]<g;){E=0;if(B)do{E+=o=this._getBlackCode()}while(o>=64);else do{E+=o=this._getWhiteCode()}while(o>=64);this._addPixels(I[this.codingPos]+E,B);B^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){E=this._lookBits(12);if(this.eoline)for(;E!==C&&1!==E;){this._eatBits(1);E=this._lookBits(12)}else for(;0===E;){this._eatBits(1);E=this._lookBits(12)}if(1===E){this._eatBits(12);h=!0}else E===C&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}if(this.eoblock&&h&&this.byteAlign){E=this._lookBits(12);if(1===E){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(i=0;i<4;++i){E=this._lookBits(12);1!==E&&info("bad rtc code: "+E);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){E=this._lookBits(13);if(E===C){this.eof=!0;return-1}if(E>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&E)}}this.outputBits=I[0]>0?I[this.codingPos=0]:I[this.codingPos=1];this.row++}if(this.outputBits>=8){D=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&I[this.codingPos]<g){this.codingPos++;this.outputBits=I[this.codingPos]-I[this.codingPos-1]}}else{E=8;D=0;do{if("number"!=typeof this.outputBits)throw new FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');if(this.outputBits>E){D<<=E;1&this.codingPos||(D|=255>>8-E);this.outputBits-=E;E=0}else{D<<=this.outputBits;1&this.codingPos||(D|=255>>8-this.outputBits);E-=this.outputBits;this.outputBits=0;if(I[this.codingPos]<g){this.codingPos++;this.outputBits=I[this.codingPos]-I[this.codingPos-1]}else if(E>0){D<<=E;E=0}}}while(E)}this.black&&(D^=255);return D}_addPixels(A,I){const g=this.codingLine;let Q=this.codingPos;if(A>g[Q]){if(A>this.columns){info("row is wrong length");this.err=!0;A=this.columns}1&Q^I&&++Q;g[Q]=A}this.codingPos=Q}_addPixelsNeg(A,I){const g=this.codingLine;let Q=this.codingPos;if(A>g[Q]){if(A>this.columns){info("row is wrong length");this.err=!0;A=this.columns}1&Q^I&&++Q;g[Q]=A}else if(A<g[Q]){if(A<0){info("invalid code");this.err=!0;A=0}for(;Q>0&&A<g[Q-1];)--Q;g[Q]=A}this.codingPos=Q}_findTableCode(A,I,g,Q){const B=Q||0;for(let Q=A;Q<=I;++Q){let A=this._lookBits(Q);if(A===C)return[!0,1,!1];Q<I&&(A<<=I-Q);if(!B||A>=B){const I=g[A-B];if(I[0]===Q){this._eatBits(Q);return[!0,I[1],!0]}}}return[!1,0,!1]}_getTwoDimCode(){let A,I=0;if(this.eoblock){I=this._lookBits(7);A=E[I];if(A?.[0]>0){this._eatBits(A[0]);return A[1]}}else{const A=this._findTableCode(1,7,E);if(A[0]&&A[2])return A[1]}info("Bad two dim code");return C}_getWhiteCode(){let A,I=0;if(this.eoblock){I=this._lookBits(12);if(I===C)return 1;A=I>>5==0?i[I]:D[I>>3];if(A[0]>0){this._eatBits(A[0]);return A[1]}}else{let A=this._findTableCode(1,9,D);if(A[0])return A[1];A=this._findTableCode(11,12,i);if(A[0])return A[1]}info("bad white code");this._eatBits(1);return 1}_getBlackCode(){let A,I;if(this.eoblock){A=this._lookBits(13);if(A===C)return 1;I=A>>7==0?o[A]:A>>9==0&&A>>7!=0?h[(A>>1)-64]:s[A>>7];if(I[0]>0){this._eatBits(I[0]);return I[1]}}else{let A=this._findTableCode(2,6,s);if(A[0])return A[1];A=this._findTableCode(7,12,h,64);if(A[0])return A[1];A=this._findTableCode(10,13,o);if(A[0])return A[1]}info("bad black code");this._eatBits(1);return 1}_lookBits(A){let I;for(;this.inputBits<A;){if(-1===(I=this.source.next()))return 0===this.inputBits?C:this.inputBuf<<A-this.inputBits&65535>>16-A;this.inputBuf=this.inputBuf<<8|I;this.inputBits+=8}return this.inputBuf>>this.inputBits-A&65535>>16-A}_eatBits(A){(this.inputBits-=A)<0&&(this.inputBits=0)}}class Jbig2Error extends Q{constructor(A){super(A,"Jbig2Error")}}class ContextCache{getContexts(A){return A in this?this[A]:this[A]=new Int8Array(65536)}}class DecodingContext{constructor(A,I,g){this.data=A;this.start=I;this.end=g}get decoder(){return util_shadow(this,"decoder",new ArithmeticDecoder(this.data,this.start,this.end))}get contextCache(){return util_shadow(this,"contextCache",new ContextCache)}}const F=2**31-1,G=-(2**31);function decodeInteger(A,I,g){const Q=A.getContexts(I);let B=1;function readBits(A){let I=0;for(let C=0;C<A;C++){const A=g.readBit(Q,B);B=B<256?B<<1|A:511&(B<<1|A)|256;I=I<<1|A}return I>>>0}const C=readBits(1),E=readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(32)+4436:readBits(12)+340:readBits(8)+84:readBits(6)+20:readBits(4)+4:readBits(2);let i;0===C?i=E:E>0&&(i=-E);return i>=G&&i<=F?i:null}function decodeIAID(A,I,g){const Q=A.getContexts("IAID");let B=1;for(let A=0;A<g;A++){B=B<<1|I.readBit(Q,B)}return g<31?B&(1<<g)-1:2147483647&B}const a=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"PatternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],y=[[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:2,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:2,y:-1},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}],[{x:-1,y:-2},{x:0,y:-2},{x:1,y:-2},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-2,y:0},{x:-1,y:0}],[{x:-3,y:-1},{x:-2,y:-1},{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-4,y:0},{x:-3,y:0},{x:-2,y:0},{x:-1,y:0}]],w=[{coding:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:1,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:-1,y:1},{x:0,y:1},{x:1,y:1}]},{coding:[{x:-1,y:-1},{x:0,y:-1},{x:1,y:-1},{x:-1,y:0}],reference:[{x:0,y:-1},{x:-1,y:0},{x:0,y:0},{x:1,y:0},{x:0,y:1},{x:1,y:1}]}],R=[39717,1941,229,405],S=[32,8];function decodeBitmap(A,I,g,Q,B,C,E,i){if(A){return decodeMMRBitmap(new Reader(i.data,i.start,i.end),I,g,!1)}if(0===Q&&!C&&!B&&4===E.length&&3===E[0].x&&-1===E[0].y&&-3===E[1].x&&-1===E[1].y&&2===E[2].x&&-2===E[2].y&&-2===E[3].x&&-2===E[3].y)return function decodeBitmapTemplate0(A,I,g){const Q=g.decoder,B=g.contextCache.getContexts("GB"),C=[];let E,i,D,o,h,s,F;for(i=0;i<I;i++){h=C[i]=new Uint8Array(A);s=i<1?h:C[i-1];F=i<2?h:C[i-2];E=F[0]<<13|F[1]<<12|F[2]<<11|s[0]<<7|s[1]<<6|s[2]<<5|s[3]<<4;for(D=0;D<A;D++){h[D]=o=Q.readBit(B,E);E=(31735&E)<<1|(D+3<A?F[D+3]<<11:0)|(D+4<A?s[D+4]<<4:0)|o}}return C}(I,g,i);const D=!!C,o=y[Q].concat(E);o.sort((function(A,I){return A.y-I.y||A.x-I.x}));const h=o.length,s=new Int8Array(h),F=new Int8Array(h),G=[];let a,w,S=0,c=0,N=0,J=0;for(w=0;w<h;w++){s[w]=o[w].x;F[w]=o[w].y;c=Math.min(c,o[w].x);N=Math.max(N,o[w].x);J=Math.min(J,o[w].y);w<h-1&&o[w].y===o[w+1].y&&o[w].x===o[w+1].x-1?S|=1<<h-1-w:G.push(w)}const k=G.length,t=new Int8Array(k),U=new Int8Array(k),Y=new Uint16Array(k);for(a=0;a<k;a++){w=G[a];t[a]=o[w].x;U[a]=o[w].y;Y[a]=1<<h-1-w}const H=-c,e=-J,n=I-N,L=R[Q];let d=new Uint8Array(I);const K=[],M=i.decoder,r=i.contextCache.getContexts("GB");let q,l,f,b,W,Z=0,x=0;for(let A=0;A<g;A++){if(B){Z^=M.readBit(r,L);if(Z){K.push(d);continue}}d=new Uint8Array(d);K.push(d);for(q=0;q<I;q++){if(D&&C[A][q]){d[q]=0;continue}if(q>=H&&q<n&&A>=e){x=x<<1&S;for(w=0;w<k;w++){l=A+U[w];f=q+t[w];b=K[l][f];if(b){b=Y[w];x|=b}}}else{x=0;W=h-1;for(w=0;w<h;w++,W--){f=q+s[w];if(f>=0&&f<I){l=A+F[w];if(l>=0){b=K[l][f];b&&(x|=b<<W)}}}}const g=M.readBit(r,x);d[q]=g}}return K}function decodeRefinement(A,I,g,Q,B,C,E,i,D){let o=w[g].coding;0===g&&(o=o.concat([i[0]]));const h=o.length,s=new Int32Array(h),F=new Int32Array(h);let G;for(G=0;G<h;G++){s[G]=o[G].x;F[G]=o[G].y}let a=w[g].reference;0===g&&(a=a.concat([i[1]]));const y=a.length,R=new Int32Array(y),c=new Int32Array(y);for(G=0;G<y;G++){R[G]=a[G].x;c[G]=a[G].y}const N=Q[0].length,J=Q.length,k=S[g],t=[],U=D.decoder,Y=D.contextCache.getContexts("GR");let H=0;for(let g=0;g<I;g++){if(E){H^=U.readBit(Y,k);if(H)throw new Jbig2Error("prediction is not supported")}const I=new Uint8Array(A);t.push(I);for(let E=0;E<A;E++){let i,D,o=0;for(G=0;G<h;G++){i=g+F[G];D=E+s[G];i<0||D<0||D>=A?o<<=1:o=o<<1|t[i][D]}for(G=0;G<y;G++){i=g+c[G]-C;D=E+R[G]-B;i<0||i>=J||D<0||D>=N?o<<=1:o=o<<1|Q[i][D]}const a=U.readBit(Y,o);I[E]=a}}return t}function decodeTextRegion(A,I,g,Q,B,C,E,i,D,o,h,s,F,G,a,y,w,R,S){if(A&&I)throw new Jbig2Error("refinement with Huffman is not supported");const c=[];let N,J;for(N=0;N<Q;N++){J=new Uint8Array(g);if(B)for(let A=0;A<g;A++)J[A]=B;c.push(J)}const k=w.decoder,t=w.contextCache;let U=A?-G.tableDeltaT.decode(S):-decodeInteger(t,"IADT",k),Y=0;N=0;for(;N<C;){U+=A?G.tableDeltaT.decode(S):decodeInteger(t,"IADT",k);Y+=A?G.tableFirstS.decode(S):decodeInteger(t,"IAFS",k);let Q=Y;for(;;){let B=0;E>1&&(B=A?S.readBits(R):decodeInteger(t,"IAIT",k));const C=E*U+B,Y=A?G.symbolIDTable.decode(S):decodeIAID(t,k,D),H=I&&(A?S.readBit():decodeInteger(t,"IARI",k));let e=i[Y],n=e[0].length,L=e.length;if(H){const A=decodeInteger(t,"IARDW",k),I=decodeInteger(t,"IARDH",k);n+=A;L+=I;e=decodeRefinement(n,L,a,e,(A>>1)+decodeInteger(t,"IARDX",k),(I>>1)+decodeInteger(t,"IARDY",k),!1,y,w)}let d=0;o?1&s?d=L-1:Q+=L-1:s>1?Q+=n-1:d=n-1;const K=C-(1&s?0:L-1),M=Q-(2&s?n-1:0);let r,q,l;if(o)for(r=0;r<L;r++){J=c[M+r];if(!J)continue;l=e[r];const A=Math.min(g-K,n);switch(F){case 0:for(q=0;q<A;q++)J[K+q]|=l[q];break;case 2:for(q=0;q<A;q++)J[K+q]^=l[q];break;default:throw new Jbig2Error(`operator ${F} is not supported`)}}else for(q=0;q<L;q++){J=c[K+q];if(J){l=e[q];switch(F){case 0:for(r=0;r<n;r++)J[M+r]|=l[r];break;case 2:for(r=0;r<n;r++)J[M+r]^=l[r];break;default:throw new Jbig2Error(`operator ${F} is not supported`)}}}N++;const f=A?G.tableDeltaS.decode(S):decodeInteger(t,"IADS",k);if(null===f)break;Q+=d+f+h}}return c}function readSegmentHeader(A,I){const g={};g.number=readUint32(A,I);const Q=A[I+4],B=63&Q;if(!a[B])throw new Jbig2Error("invalid segment type: "+B);g.type=B;g.typeName=a[B];g.deferredNonRetain=!!(128&Q);const C=!!(64&Q),E=A[I+5];let i=E>>5&7;const D=[31&E];let o=I+6;if(7===E){i=536870911&readUint32(A,o-1);o+=3;let I=i+7>>3;D[0]=A[o++];for(;--I>0;)D.push(A[o++])}else if(5===E||6===E)throw new Jbig2Error("invalid referred-to flags");g.retainBits=D;let h=4;g.number<=256?h=1:g.number<=65536&&(h=2);const s=[];let F,G;for(F=0;F<i;F++){let I;I=1===h?A[o]:2===h?readUint16(A,o):readUint32(A,o);s.push(I);o+=h}g.referredTo=s;if(C){g.pageAssociation=readUint32(A,o);o+=4}else g.pageAssociation=A[o++];g.length=readUint32(A,o);o+=4;if(4294967295===g.length){if(38!==B)throw new Jbig2Error("invalid unknown segment length");{const I=readRegionSegmentInformation(A,o),Q=!!(1&A[o+c]),B=6,C=new Uint8Array(B);if(!Q){C[0]=255;C[1]=172}C[2]=I.height>>>24&255;C[3]=I.height>>16&255;C[4]=I.height>>8&255;C[5]=255&I.height;for(F=o,G=A.length;F<G;F++){let I=0;for(;I<B&&C[I]===A[F+I];)I++;if(I===B){g.length=F+B;break}}if(4294967295===g.length)throw new Jbig2Error("segment end was not found")}}g.headerEnd=o;return g}function readSegments(A,I,g,Q){const B=[];let C=g;for(;C<Q;){const g=readSegmentHeader(I,C);C=g.headerEnd;const Q={header:g,data:I};if(!A.randomAccess){Q.start=C;C+=g.length;Q.end=C}B.push(Q);if(51===g.type)break}if(A.randomAccess)for(let A=0,I=B.length;A<I;A++){B[A].start=C;C+=B[A].header.length;B[A].end=C}return B}function readRegionSegmentInformation(A,I){return{width:readUint32(A,I),height:readUint32(A,I+4),x:readUint32(A,I+8),y:readUint32(A,I+12),combinationOperator:7&A[I+16]}}const c=17;function processSegment(A,I){const g=A.header,Q=A.data,B=A.end;let C,E,i,D,o=A.start;switch(g.type){case 0:const A={},I=readUint16(Q,o);A.huffman=!!(1&I);A.refinement=!!(2&I);A.huffmanDHSelector=I>>2&3;A.huffmanDWSelector=I>>4&3;A.bitmapSizeSelector=I>>6&1;A.aggregationInstancesSelector=I>>7&1;A.bitmapCodingContextUsed=!!(256&I);A.bitmapCodingContextRetained=!!(512&I);A.template=I>>10&3;A.refinementTemplate=I>>12&1;o+=2;if(!A.huffman){D=0===A.template?4:1;E=[];for(i=0;i<D;i++){E.push({x:readInt8(Q,o),y:readInt8(Q,o+1)});o+=2}A.at=E}if(A.refinement&&!A.refinementTemplate){E=[];for(i=0;i<2;i++){E.push({x:readInt8(Q,o),y:readInt8(Q,o+1)});o+=2}A.refinementAt=E}A.numberOfExportedSymbols=readUint32(Q,o);o+=4;A.numberOfNewSymbols=readUint32(Q,o);o+=4;C=[A,g.number,g.referredTo,Q,o,B];break;case 6:case 7:const h={};h.info=readRegionSegmentInformation(Q,o);o+=c;const s=readUint16(Q,o);o+=2;h.huffman=!!(1&s);h.refinement=!!(2&s);h.logStripSize=s>>2&3;h.stripSize=1<<h.logStripSize;h.referenceCorner=s>>4&3;h.transposed=!!(64&s);h.combinationOperator=s>>7&3;h.defaultPixelValue=s>>9&1;h.dsOffset=s<<17>>27;h.refinementTemplate=s>>15&1;if(h.huffman){const A=readUint16(Q,o);o+=2;h.huffmanFS=3&A;h.huffmanDS=A>>2&3;h.huffmanDT=A>>4&3;h.huffmanRefinementDW=A>>6&3;h.huffmanRefinementDH=A>>8&3;h.huffmanRefinementDX=A>>10&3;h.huffmanRefinementDY=A>>12&3;h.huffmanRefinementSizeSelector=!!(16384&A)}if(h.refinement&&!h.refinementTemplate){E=[];for(i=0;i<2;i++){E.push({x:readInt8(Q,o),y:readInt8(Q,o+1)});o+=2}h.refinementAt=E}h.numberOfSymbolInstances=readUint32(Q,o);o+=4;C=[h,g.referredTo,Q,o,B];break;case 16:const F={},G=Q[o++];F.mmr=!!(1&G);F.template=G>>1&3;F.patternWidth=Q[o++];F.patternHeight=Q[o++];F.maxPatternIndex=readUint32(Q,o);o+=4;C=[F,g.number,Q,o,B];break;case 22:case 23:const a={};a.info=readRegionSegmentInformation(Q,o);o+=c;const y=Q[o++];a.mmr=!!(1&y);a.template=y>>1&3;a.enableSkip=!!(8&y);a.combinationOperator=y>>4&7;a.defaultPixelValue=y>>7&1;a.gridWidth=readUint32(Q,o);o+=4;a.gridHeight=readUint32(Q,o);o+=4;a.gridOffsetX=4294967295&readUint32(Q,o);o+=4;a.gridOffsetY=4294967295&readUint32(Q,o);o+=4;a.gridVectorX=readUint16(Q,o);o+=2;a.gridVectorY=readUint16(Q,o);o+=2;C=[a,g.referredTo,Q,o,B];break;case 38:case 39:const w={};w.info=readRegionSegmentInformation(Q,o);o+=c;const R=Q[o++];w.mmr=!!(1&R);w.template=R>>1&3;w.prediction=!!(8&R);if(!w.mmr){D=0===w.template?4:1;E=[];for(i=0;i<D;i++){E.push({x:readInt8(Q,o),y:readInt8(Q,o+1)});o+=2}w.at=E}C=[w,Q,o,B];break;case 48:const S={width:readUint32(Q,o),height:readUint32(Q,o+4),resolutionX:readUint32(Q,o+8),resolutionY:readUint32(Q,o+12)};4294967295===S.height&&delete S.height;const N=Q[o+16];readUint16(Q,o+17);S.lossless=!!(1&N);S.refinement=!!(2&N);S.defaultPixelValue=N>>2&1;S.combinationOperator=N>>3&3;S.requiresBuffer=!!(32&N);S.combinationOperatorOverride=!!(64&N);C=[S];break;case 49:case 50:case 51:case 62:break;case 53:C=[g.number,Q,o,B];break;default:throw new Jbig2Error(`segment type ${g.typeName}(${g.type}) is not implemented`)}const h="on"+g.typeName;h in I&&I[h].apply(I,C)}function processSegments(A,I){for(let g=0,Q=A.length;g<Q;g++)processSegment(A[g],I)}class SimpleSegmentVisitor{onPageInformation(A){this.currentPageInfo=A;const I=A.width+7>>3,g=new Uint8ClampedArray(I*A.height);A.defaultPixelValue&&g.fill(255);this.buffer=g}drawBitmap(A,I){const g=this.currentPageInfo,Q=A.width,B=A.height,C=g.width+7>>3,E=g.combinationOperatorOverride?A.combinationOperator:g.combinationOperator,i=this.buffer,D=128>>(7&A.x);let o,h,s,F,G=A.y*C+(A.x>>3);switch(E){case 0:for(o=0;o<B;o++){s=D;F=G;for(h=0;h<Q;h++){I[o][h]&&(i[F]|=s);s>>=1;if(!s){s=128;F++}}G+=C}break;case 2:for(o=0;o<B;o++){s=D;F=G;for(h=0;h<Q;h++){I[o][h]&&(i[F]^=s);s>>=1;if(!s){s=128;F++}}G+=C}break;default:throw new Jbig2Error(`operator ${E} is not supported`)}}onImmediateGenericRegion(A,I,g,Q){const B=A.info,C=new DecodingContext(I,g,Q),E=decodeBitmap(A.mmr,B.width,B.height,A.template,A.prediction,null,A.at,C);this.drawBitmap(B,E)}onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion(...arguments)}onSymbolDictionary(A,I,g,Q,B,C){let E,i;if(A.huffman){E=function getSymbolDictionaryHuffmanTables(A,I,g){let Q,B,C,E,i=0;switch(A.huffmanDHSelector){case 0:case 1:Q=getStandardTable(A.huffmanDHSelector+4);break;case 3:Q=getCustomHuffmanTable(i,I,g);i++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(A.huffmanDWSelector){case 0:case 1:B=getStandardTable(A.huffmanDWSelector+2);break;case 3:B=getCustomHuffmanTable(i,I,g);i++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(A.bitmapSizeSelector){C=getCustomHuffmanTable(i,I,g);i++}else C=getStandardTable(1);E=A.aggregationInstancesSelector?getCustomHuffmanTable(i,I,g):getStandardTable(1);return{tableDeltaHeight:Q,tableDeltaWidth:B,tableBitmapSize:C,tableAggregateInstances:E}}(A,g,this.customTables);i=new Reader(Q,B,C)}let D=this.symbols;D||(this.symbols=D={});const o=[];for(const A of g){const I=D[A];I&&o.push(...I)}const h=new DecodingContext(Q,B,C);D[I]=function decodeSymbolDictionary(A,I,g,Q,B,C,E,i,D,o,h,s){if(A&&I)throw new Jbig2Error("symbol refinement with Huffman is not supported");const F=[];let G=0,a=log2(g.length+Q);const y=h.decoder,w=h.contextCache;let R,S;if(A){R=getStandardTable(1);S=[];a=Math.max(a,1)}for(;F.length<Q;){G+=A?C.tableDeltaHeight.decode(s):decodeInteger(w,"IADH",y);let Q=0,B=0;const R=A?S.length:0;for(;;){const R=A?C.tableDeltaWidth.decode(s):decodeInteger(w,"IADW",y);if(null===R)break;Q+=R;B+=Q;let c;if(I){const B=decodeInteger(w,"IAAI",y);if(B>1)c=decodeTextRegion(A,I,Q,G,0,B,1,g.concat(F),a,0,0,1,0,C,D,o,h,0,s);else{const A=decodeIAID(w,y,a),I=decodeInteger(w,"IARDX",y),B=decodeInteger(w,"IARDY",y);c=decodeRefinement(Q,G,D,A<g.length?g[A]:F[A-g.length],I,B,!1,o,h)}F.push(c)}else if(A)S.push(Q);else{c=decodeBitmap(!1,Q,G,E,!1,null,i,h);F.push(c)}}if(A&&!I){const A=C.tableBitmapSize.decode(s);s.byteAlign();let I;if(0===A)I=readUncompressedBitmap(s,B,G);else{const g=s.end,Q=s.position+A;s.end=Q;I=decodeMMRBitmap(s,B,G,!1);s.end=g;s.position=Q}const g=S.length;if(R===g-1)F.push(I);else{let A,Q,B,C,E,i=0;for(A=R;A<g;A++){C=S[A];B=i+C;E=[];for(Q=0;Q<G;Q++)E.push(I[Q].subarray(i,B));F.push(E);i=B}}}}const c=[],N=[];let J,k,t=!1;const U=g.length+Q;for(;N.length<U;){let I=A?R.decode(s):decodeInteger(w,"IAEX",y);for(;I--;)N.push(t);t=!t}for(J=0,k=g.length;J<k;J++)N[J]&&c.push(g[J]);for(let A=0;A<Q;J++,A++)N[J]&&c.push(F[A]);return c}(A.huffman,A.refinement,o,A.numberOfNewSymbols,A.numberOfExportedSymbols,E,A.template,A.at,A.refinementTemplate,A.refinementAt,h,i)}onImmediateTextRegion(A,I,g,Q,B){const C=A.info;let E,i;const D=this.symbols,o=[];for(const A of I){const I=D[A];I&&o.push(...I)}const h=log2(o.length);if(A.huffman){i=new Reader(g,Q,B);E=function getTextRegionHuffmanTables(A,I,g,Q,B){const C=[];for(let A=0;A<=34;A++){const I=B.readBits(4);C.push(new HuffmanLine([A,I,0,0]))}const E=new HuffmanTable(C,!1);C.length=0;for(let A=0;A<Q;){const I=E.decode(B);if(I>=32){let g,Q,E;switch(I){case 32:if(0===A)throw new Jbig2Error("no previous value in symbol ID table");Q=B.readBits(2)+3;g=C[A-1].prefixLength;break;case 33:Q=B.readBits(3)+3;g=0;break;case 34:Q=B.readBits(7)+11;g=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(E=0;E<Q;E++){C.push(new HuffmanLine([A,g,0,0]));A++}}else{C.push(new HuffmanLine([A,I,0,0]));A++}}B.byteAlign();const i=new HuffmanTable(C,!1);let D,o,h,s=0;switch(A.huffmanFS){case 0:case 1:D=getStandardTable(A.huffmanFS+6);break;case 3:D=getCustomHuffmanTable(s,I,g);s++;break;default:throw new Jbig2Error("invalid Huffman FS selector")}switch(A.huffmanDS){case 0:case 1:case 2:o=getStandardTable(A.huffmanDS+8);break;case 3:o=getCustomHuffmanTable(s,I,g);s++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(A.huffmanDT){case 0:case 1:case 2:h=getStandardTable(A.huffmanDT+11);break;case 3:h=getCustomHuffmanTable(s,I,g);s++;break;default:throw new Jbig2Error("invalid Huffman DT selector")}if(A.refinement)throw new Jbig2Error("refinement with Huffman is not supported");return{symbolIDTable:i,tableFirstS:D,tableDeltaS:o,tableDeltaT:h}}(A,I,this.customTables,o.length,i)}const s=new DecodingContext(g,Q,B),F=decodeTextRegion(A.huffman,A.refinement,C.width,C.height,A.defaultPixelValue,A.numberOfSymbolInstances,A.stripSize,o,h,A.transposed,A.dsOffset,A.referenceCorner,A.combinationOperator,E,A.refinementTemplate,A.refinementAt,s,A.logStripSize,i);this.drawBitmap(C,F)}onImmediateLosslessTextRegion(){this.onImmediateTextRegion(...arguments)}onPatternDictionary(A,I,g,Q,B){let C=this.patterns;C||(this.patterns=C={});const E=new DecodingContext(g,Q,B);C[I]=function decodePatternDictionary(A,I,g,Q,B,C){const E=[];if(!A){E.push({x:-I,y:0});0===B&&E.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const i=decodeBitmap(A,(Q+1)*I,g,B,!1,null,E,C),D=[];for(let A=0;A<=Q;A++){const Q=[],B=I*A,C=B+I;for(let A=0;A<g;A++)Q.push(i[A].subarray(B,C));D.push(Q)}return D}(A.mmr,A.patternWidth,A.patternHeight,A.maxPatternIndex,A.template,E)}onImmediateHalftoneRegion(A,I,g,Q,B){const C=this.patterns[I[0]],E=A.info,i=new DecodingContext(g,Q,B),D=function decodeHalftoneRegion(A,I,g,Q,B,C,E,i,D,o,h,s,F,G,a){if(E)throw new Jbig2Error("skip is not supported");if(0!==i)throw new Jbig2Error(`operator "${i}" is not supported in halftone region`);const y=[];let w,R,S;for(w=0;w<B;w++){S=new Uint8Array(Q);if(C)for(R=0;R<Q;R++)S[R]=C;y.push(S)}const c=I.length,N=I[0],J=N[0].length,k=N.length,t=log2(c),U=[];if(!A){U.push({x:g<=1?3:2,y:-1});0===g&&U.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const Y=[];let H,e,n,L,d,K,M,r,q,l,f;A&&(H=new Reader(a.data,a.start,a.end));for(w=t-1;w>=0;w--){e=A?decodeMMRBitmap(H,D,o,!0):decodeBitmap(!1,D,o,g,!1,null,U,a);Y[w]=e}for(n=0;n<o;n++)for(L=0;L<D;L++){d=0;K=0;for(R=t-1;R>=0;R--){d^=Y[R][n][L];K|=d<<R}M=I[K];r=h+n*G+L*F>>8;q=s+n*F-L*G>>8;if(r>=0&&r+J<=Q&&q>=0&&q+k<=B)for(w=0;w<k;w++){f=y[q+w];l=M[w];for(R=0;R<J;R++)f[r+R]|=l[R]}else{let A,I;for(w=0;w<k;w++){I=q+w;if(!(I<0||I>=B)){f=y[I];l=M[w];for(R=0;R<J;R++){A=r+R;A>=0&&A<Q&&(f[A]|=l[R])}}}}}return y}(A.mmr,C,A.template,E.width,E.height,A.defaultPixelValue,A.enableSkip,A.combinationOperator,A.gridWidth,A.gridHeight,A.gridOffsetX,A.gridOffsetY,A.gridVectorX,A.gridVectorY,i);this.drawBitmap(E,D)}onImmediateLosslessHalftoneRegion(){this.onImmediateHalftoneRegion(...arguments)}onTables(A,I,g,Q){let B=this.customTables;B||(this.customTables=B={});B[A]=function decodeTablesSegment(A,I,g){const Q=A[I],B=4294967295&readUint32(A,I+1),C=4294967295&readUint32(A,I+5),E=new Reader(A,I+9,g),i=1+(Q>>1&7),D=1+(Q>>4&7),o=[];let h,s,F=B;do{h=E.readBits(i);s=E.readBits(D);o.push(new HuffmanLine([F,h,s,0]));F+=1<<s}while(F<C);h=E.readBits(i);o.push(new HuffmanLine([B-1,h,32,0,"lower"]));h=E.readBits(i);o.push(new HuffmanLine([C,h,32,0]));if(1&Q){h=E.readBits(i);o.push(new HuffmanLine([h,0]))}return new HuffmanTable(o,!1)}(I,g,Q)}}class HuffmanLine{constructor(A){if(2===A.length){this.isOOB=!0;this.rangeLow=0;this.prefixLength=A[0];this.rangeLength=0;this.prefixCode=A[1];this.isLowerRange=!1}else{this.isOOB=!1;this.rangeLow=A[0];this.prefixLength=A[1];this.rangeLength=A[2];this.prefixCode=A[3];this.isLowerRange="lower"===A[4]}}}class HuffmanTreeNode{constructor(A){this.children=[];if(A){this.isLeaf=!0;this.rangeLength=A.rangeLength;this.rangeLow=A.rangeLow;this.isLowerRange=A.isLowerRange;this.isOOB=A.isOOB}else this.isLeaf=!1}buildTree(A,I){const g=A.prefixCode>>I&1;if(I<=0)this.children[g]=new HuffmanTreeNode(A);else{let Q=this.children[g];Q||(this.children[g]=Q=new HuffmanTreeNode(null));Q.buildTree(A,I-1)}}decodeNode(A){if(this.isLeaf){if(this.isOOB)return null;const I=A.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-I:I)}const I=this.children[A.readBit()];if(!I)throw new Jbig2Error("invalid Huffman data");return I.decodeNode(A)}}class HuffmanTable{constructor(A,I){I||this.assignPrefixCodes(A);this.rootNode=new HuffmanTreeNode(null);for(let I=0,g=A.length;I<g;I++){const g=A[I];g.prefixLength>0&&this.rootNode.buildTree(g,g.prefixLength-1)}}decode(A){return this.rootNode.decodeNode(A)}assignPrefixCodes(A){const I=A.length;let g=0;for(let Q=0;Q<I;Q++)g=Math.max(g,A[Q].prefixLength);const Q=new Uint32Array(g+1);for(let g=0;g<I;g++)Q[A[g].prefixLength]++;let B,C,E,i=1,D=0;Q[0]=0;for(;i<=g;){D=D+Q[i-1]<<1;B=D;C=0;for(;C<I;){E=A[C];if(E.prefixLength===i){E.prefixCode=B;B++}C++}i++}}}const N={};function getStandardTable(A){let I,g=N[A];if(g)return g;switch(A){case 1:I=[[0,1,4,0],[16,2,8,2],[272,3,16,6],[65808,3,32,7]];break;case 2:I=[[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[75,6,32,62],[6,63]];break;case 3:I=[[-256,8,8,254],[0,1,0,0],[1,2,0,2],[2,3,0,6],[3,4,3,14],[11,5,6,30],[-257,8,32,255,"lower"],[75,7,32,126],[6,62]];break;case 4:I=[[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[76,5,32,31]];break;case 5:I=[[-255,7,8,126],[1,1,0,0],[2,2,0,2],[3,3,0,6],[4,4,3,14],[12,5,6,30],[-256,7,32,127,"lower"],[76,6,32,62]];break;case 6:I=[[-2048,5,10,28],[-1024,4,9,8],[-512,4,8,9],[-256,4,7,10],[-128,5,6,29],[-64,5,5,30],[-32,4,5,11],[0,2,7,0],[128,3,7,2],[256,3,8,3],[512,4,9,12],[1024,4,10,13],[-2049,6,32,62,"lower"],[2048,6,32,63]];break;case 7:I=[[-1024,4,9,8],[-512,3,8,0],[-256,4,7,9],[-128,5,6,26],[-64,5,5,27],[-32,4,5,10],[0,4,5,11],[32,5,5,28],[64,5,6,29],[128,4,7,12],[256,3,8,1],[512,3,9,2],[1024,3,10,3],[-1025,5,32,30,"lower"],[2048,5,32,31]];break;case 8:I=[[-15,8,3,252],[-7,9,1,508],[-5,8,1,253],[-3,9,0,509],[-2,7,0,124],[-1,4,0,10],[0,2,1,0],[2,5,0,26],[3,6,0,58],[4,3,4,4],[20,6,1,59],[22,4,4,11],[38,4,5,12],[70,5,6,27],[134,5,7,28],[262,6,7,60],[390,7,8,125],[646,6,10,61],[-16,9,32,510,"lower"],[1670,9,32,511],[2,1]];break;case 9:I=[[-31,8,4,252],[-15,9,2,508],[-11,8,2,253],[-7,9,1,509],[-5,7,1,124],[-3,4,1,10],[-1,3,1,2],[1,3,1,3],[3,5,1,26],[5,6,1,58],[7,3,5,4],[39,6,2,59],[43,4,5,11],[75,4,6,12],[139,5,7,27],[267,5,8,28],[523,6,8,60],[779,7,9,125],[1291,6,11,61],[-32,9,32,510,"lower"],[3339,9,32,511],[2,0]];break;case 10:I=[[-21,7,4,122],[-5,8,0,252],[-4,7,0,123],[-3,5,0,24],[-2,2,2,0],[2,5,0,25],[3,6,0,54],[4,7,0,124],[5,8,0,253],[6,2,6,1],[70,5,5,26],[102,6,5,55],[134,6,6,56],[198,6,7,57],[326,6,8,58],[582,6,9,59],[1094,6,10,60],[2118,7,11,125],[-22,8,32,254,"lower"],[4166,8,32,255],[2,2]];break;case 11:I=[[1,1,0,0],[2,2,1,2],[4,4,0,12],[5,4,1,13],[7,5,1,28],[9,5,2,29],[13,6,2,60],[17,7,2,122],[21,7,3,123],[29,7,4,124],[45,7,5,125],[77,7,6,126],[141,7,32,127]];break;case 12:I=[[1,1,0,0],[2,2,0,2],[3,3,1,6],[5,5,0,28],[6,5,1,29],[8,6,1,60],[10,7,0,122],[11,7,1,123],[13,7,2,124],[17,7,3,125],[25,7,4,126],[41,8,5,254],[73,8,32,255]];break;case 13:I=[[1,1,0,0],[2,3,0,4],[3,4,0,12],[4,5,0,28],[5,4,1,13],[7,3,3,5],[15,6,1,58],[17,6,2,59],[21,6,3,60],[29,6,4,61],[45,6,5,62],[77,7,6,126],[141,7,32,127]];break;case 14:I=[[-2,3,0,4],[-1,3,0,5],[0,1,0,0],[1,3,0,6],[2,3,0,7]];break;case 15:I=[[-24,7,4,124],[-8,6,2,60],[-4,5,1,28],[-2,4,0,12],[-1,3,0,4],[0,1,0,0],[1,3,0,5],[2,4,0,13],[3,5,1,29],[5,6,2,61],[9,7,4,125],[-25,7,32,126,"lower"],[25,7,32,127]];break;default:throw new Jbig2Error(`standard table B.${A} does not exist`)}for(let A=0,g=I.length;A<g;A++)I[A]=new HuffmanLine(I[A]);g=new HuffmanTable(I,!0);N[A]=g;return g}class Reader{constructor(A,I,g){this.data=A;this.start=I;this.end=g;this.position=I;this.shift=-1;this.currentByte=0}readBit(){if(this.shift<0){if(this.position>=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const A=this.currentByte>>this.shift&1;this.shift--;return A}readBits(A){let I,g=0;for(I=A-1;I>=0;I--)g|=this.readBit()<<I;return g}byteAlign(){this.shift=-1}next(){return this.position>=this.end?-1:this.data[this.position++]}}function getCustomHuffmanTable(A,I,g){let Q=0;for(let B=0,C=I.length;B<C;B++){const C=g[I[B]];if(C){if(A===Q)return C;Q++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(A,I,g){const Q=[];for(let B=0;B<g;B++){const g=new Uint8Array(I);Q.push(g);for(let Q=0;Q<I;Q++)g[Q]=A.readBit();A.byteAlign()}return Q}function decodeMMRBitmap(A,I,g,Q){const B=new CCITTFaxDecoder(A,{K:-1,Columns:I,Rows:g,BlackIs1:!0,EndOfBlock:Q}),C=[];let E,i=!1;for(let A=0;A<g;A++){const A=new Uint8Array(I);C.push(A);let g=-1;for(let Q=0;Q<I;Q++){if(g<0){E=B.readNextChar();if(-1===E){E=0;i=!0}g=7}A[Q]=E>>g&1;g--}}if(Q&&!i){const A=5;for(let I=0;I<A&&-1!==B.readNextChar();I++);}return C}class Jbig2Image{parseChunks(A){return function parseJbig2Chunks(A){const I=new SimpleSegmentVisitor;for(let g=0,Q=A.length;g<Q;g++){const Q=A[g];processSegments(readSegments({},Q.data,Q.start,Q.end),I)}return I.buffer}(A)}parse(A){const{imgData:I,width:g,height:Q}=function parseJbig2(A){const I=A.length;let g=0;if(151!==A[g]||74!==A[g+1]||66!==A[g+2]||50!==A[g+3]||13!==A[g+4]||10!==A[g+5]||26!==A[g+6]||10!==A[g+7])throw new Jbig2Error("parseJbig2 - invalid header.");const Q=Object.create(null);g+=8;const B=A[g++];Q.randomAccess=!(1&B);if(!(2&B)){Q.numberOfPages=readUint32(A,g);g+=4}const C=readSegments(Q,A,g,I),E=new SimpleSegmentVisitor;processSegments(C,E);const{width:i,height:D}=E.currentPageInfo,o=E.buffer,h=new Uint8ClampedArray(i*D);let s=0,F=0;for(let A=0;A<D;A++){let A,I=0;for(let g=0;g<i;g++){if(!I){I=128;A=o[F++]}h[s++]=A&I?0:255;I>>=1}}return{imgData:h,width:i,height:D}}(A);this.width=g;this.height=Q;return I}}class JpegError extends Q{constructor(A){super(A,"JpegError")}}class DNLMarkerError extends Q{constructor(A,I){super(A,"DNLMarkerError");this.scanLines=I}}class EOIMarkerError extends Q{constructor(A){super(A,"EOIMarkerError")}}const J=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),k=4017,t=799,U=3406,Y=2276,H=1567,e=3784,n=5793,L=2896;function buildHuffmanTable(A,I){let g,Q,B=0,C=16;for(;C>0&&!A[C-1];)C--;const E=[{children:[],index:0}];let i,D=E[0];for(g=0;g<C;g++){for(Q=0;Q<A[g];Q++){D=E.pop();D.children[D.index]=I[B];for(;D.index>0;)D=E.pop();D.index++;E.push(D);for(;E.length<=g;){E.push(i={children:[],index:0});D.children[D.index]=i.children;D=i}B++}if(g+1<C){E.push(i={children:[],index:0});D.children[D.index]=i.children;D=i}}return E[0].children}function getBlockBufferOffset(A,I,g){return 64*((A.blocksPerLine+1)*I+g)}function decodeScan(A,I,g,Q,B,C,E,i,D,o=!1){const h=g.mcusPerLine,s=g.progressive,F=I;let G=0,a=0;function readBit(){if(a>0){a--;return G>>a&1}G=A[I++];if(255===G){const Q=A[I++];if(Q){if(220===Q&&o){const Q=readUint16(A,I+=2);I+=2;if(Q>0&&Q!==g.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",Q)}else if(217===Q){if(o){const A=S*(8===g.precision?8:0);if(A>0&&Math.round(g.scanLines/A)>=5)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",A)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new JpegError(`unexpected marker ${(G<<8|Q).toString(16)}`)}}a=7;return G>>>7}function decodeHuffman(A){let I=A;for(;;){I=I[readBit()];switch(typeof I){case"number":return I;case"object":continue}throw new JpegError("invalid huffman sequence")}}function receive(A){let I=0;for(;A>0;){I=I<<1|readBit();A--}return I}function receiveAndExtend(A){if(1===A)return 1===readBit()?1:-1;const I=receive(A);return I>=1<<A-1?I:I+(-1<<A)+1}let y=0;let w,R=0;let S=0;function decodeMcu(A,I,g,Q,B){const C=g%h;S=(g/h|0)*A.v+Q;const E=C*A.h+B;I(A,getBlockBufferOffset(A,S,E))}function decodeBlock(A,I,g){S=g/A.blocksPerLine|0;const Q=g%A.blocksPerLine;I(A,getBlockBufferOffset(A,S,Q))}const c=Q.length;let N,k,t,U,Y,H;H=s?0===C?0===i?function decodeDCFirst(A,I){const g=decodeHuffman(A.huffmanTableDC),Q=0===g?0:receiveAndExtend(g)<<D;A.blockData[I]=A.pred+=Q}:function decodeDCSuccessive(A,I){A.blockData[I]|=readBit()<<D}:0===i?function decodeACFirst(A,I){if(y>0){y--;return}let g=C;const Q=E;for(;g<=Q;){const Q=decodeHuffman(A.huffmanTableAC),B=15&Q,C=Q>>4;if(0===B){if(C<15){y=receive(C)+(1<<C)-1;break}g+=16;continue}g+=C;const E=J[g];A.blockData[I+E]=receiveAndExtend(B)*(1<<D);g++}}:function decodeACSuccessive(A,I){let g=C;const Q=E;let B,i,o=0;for(;g<=Q