/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2020 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 */ !function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/image_decoders/pdf.image_decoders",[],t):"object"==typeof exports?exports["pdfjs-dist/image_decoders/pdf.image_decoders"]=t():e["pdfjs-dist/image_decoders/pdf.image_decoders"]=e.pdfjsImageDecoders=t()}(this,(function(){return function(e){var t={};function __w_pdfjs_require__(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};e[r].call(n.exports,n,n.exports,__w_pdfjs_require__);n.l=!0;return n.exports}__w_pdfjs_require__.m=e;__w_pdfjs_require__.c=t;__w_pdfjs_require__.d=function(e,t,r){__w_pdfjs_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})};__w_pdfjs_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});Object.defineProperty(e,"__esModule",{value:!0})};__w_pdfjs_require__.t=function(e,t){1&t&&(e=__w_pdfjs_require__(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);__w_pdfjs_require__.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(2&t&&"string"!=typeof e)for(var n in e)__w_pdfjs_require__.d(r,n,function(t){return e[t]}.bind(null,n));return r};__w_pdfjs_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};__w_pdfjs_require__.d(t,"a",t);return t};__w_pdfjs_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__w_pdfjs_require__.p="";return __w_pdfjs_require__(__w_pdfjs_require__.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"getVerbosityLevel",{enumerable:!0,get:function(){return n.getVerbosityLevel}});Object.defineProperty(t,"setVerbosityLevel",{enumerable:!0,get:function(){return n.setVerbosityLevel}});Object.defineProperty(t,"Jbig2mage",{enumerable:!0,get:function(){return i.Jbig2mage}});Object.defineProperty(t,"JpegImage",{enumerable:!0,get:function(){return o.JpegImage}});Object.defineProperty(t,"JpxImage",{enumerable:!0,get:function(){return s.JpxImage}});var n=r(1),i=r(4),o=r(8),s=r(9)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let n=0;nt});e.promise=new Promise((function(r,n){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;n(e)}}));return e};t.escapeString=function escapeString(e){return e.replace(/([\(\)\\])/g,"\\$1")};t.getModificationDate=function getModificationDate(e=new Date(Date.now())){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),(e.getUTCDate()+1).toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return i};t.info=function info(e){i>=n.INFOS&&console.log("Info: "+e)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isString=function isString(e){return"string"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let r;try{r=new URL(e);if(!r.origin||"null"===r.origin)return!1}catch(e){return!1}const n=new URL(t,r);return r.origin===n.origin};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null};t.removeNullCharacters=function removeNullCharacters(e){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}return e.replace(s,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(i=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let n=2;n=n.WARNINGS&&console.log("Warning: "+e)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const o=function BaseExceptionClosure(){function BaseException(e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=this.constructor.name}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=o;t.PasswordException=class PasswordException extends o{constructor(e,t){super(e);this.code=t}};t.UnknownErrorException=class UnknownErrorException extends o{constructor(e,t){super(e);this.details=t}};t.InvalidPDFException=class InvalidPDFException extends o{};t.MissingPDFException=class MissingPDFException extends o{};t.UnexpectedResponseException=class UnexpectedResponseException extends o{constructor(e,t){super(e);this.status=t}};t.FormatError=class FormatError extends o{};t.AbortException=class AbortException extends o{};const s=/\x00/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let n=0;ne[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){function compare(e,t){return e-t}const r=[e[0],e[2],t[0],t[2]].sort(compare),n=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;i[0]=r[1];i[2]=r[2];if(!(n[0]===e[1]&&n[1]===t[1]||n[0]===t[1]&&n[1]===e[1]))return null;i[1]=n[1];i[3]=n[2];return i}}t.Util=Util;const d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];const f=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,r,n=!1){if(!n&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let i=`data:${r};base64,`;for(let r=0,n=t.length;r>2]+e[(3&o)<<4|s>>4]+e[r+1>6:64]+e[r+2>>0}var o=readBits(1),s=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);return 0===o?s:s>0?-s:null}function decodeIAID(e,t,r){for(var n=e.getContexts("IAID"),i=1,o=0;o=L&&k=D){H=H<<1&x;for(u=0;u=0&&_=0&&(E=R[S][_])&&(H|=E<=e?D<<=1:D=D<<1|C[B][L]}for(h=0;h=w||L<0||L>=v?D<<=1:D=D<<1|i[B][L]}var M=I.readBit(P,D);_[E]=M}}return C}function decodeTextRegion(e,t,r,n,i,o,s,a,c,l,d,f,h,u,p,m,g,b,x){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var y,v,w=[];for(y=0;y1&&(n=e?x.readBits(b):decodeInteger(I,"IAIT",C));var _=s*P+n,E=e?u.symbolIDTable.decode(x):decodeIAID(I,C,c),B=t&&(e?x.readBit():decodeInteger(I,"IARI",C)),L=a[E],D=L[0].length,M=L.length;if(B){var O=decodeInteger(I,"IARDW",C),A=decodeInteger(I,"IARDH",C);L=decodeRefinement(D+=O,M+=A,p,L,(O>>1)+decodeInteger(I,"IARDX",C),(A>>1)+decodeInteger(I,"IARDY",C),!1,m,g)}var R,U,F,N=_-(1&f?0:M-1),H=S-(2&f?D-1:0);if(l){for(R=0;R>5&7,f=[31&c],h=r+6;if(7===c){d=536870911&(0,i.readUint32)(t,h-1);h+=3;var u=d+7>>3;f[0]=t[h++];for(;--u>0;)f.push(t[h++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");n.retainBits=f;let p=4;n.number<=256?p=1:n.number<=65536&&(p=2);var m,g,b=[];for(m=0;m>>24&255;v[3]=x.height>>16&255;v[4]=x.height>>8&255;v[5]=255&x.height;for(m=h,g=t.length;m>2&3;h.huffmanDWSelector=u>>4&3;h.bitmapSizeSelector=u>>6&1;h.aggregationInstancesSelector=u>>7&1;h.bitmapCodingContextUsed=!!(256&u);h.bitmapCodingContextRetained=!!(512&u);h.template=u>>10&3;h.refinementTemplate=u>>12&1;d+=2;if(!h.huffman){s=0===h.template?4:1;n=[];for(o=0;o>2&3;p.stripSize=1<>4&3;p.transposed=!!(64&m);p.combinationOperator=m>>7&3;p.defaultPixelValue=m>>9&1;p.dsOffset=m<<17>>27;p.refinementTemplate=m>>15&1;if(p.huffman){var g=(0,i.readUint16)(c,d);d+=2;p.huffmanFS=3&g;p.huffmanDS=g>>2&3;p.huffmanDT=g>>4&3;p.huffmanRefinementDW=g>>6&3;p.huffmanRefinementDH=g>>8&3;p.huffmanRefinementDX=g>>10&3;p.huffmanRefinementDY=g>>12&3;p.huffmanRefinementSizeSelector=!!(16384&g)}if(p.refinement&&!p.refinementTemplate){n=[];for(o=0;o<2;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}p.refinementAt=n}p.numberOfSymbolInstances=(0,i.readUint32)(c,d);d+=4;r=[p,a.referredTo,c,d,f];break;case 16:const e={},t=c[d++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[d++];e.patternHeight=c[d++];e.maxPatternIndex=(0,i.readUint32)(c,d);d+=4;r=[e,a.number,c,d,f];break;case 22:case 23:const w={};w.info=readRegionSegmentInformation(c,d);d+=l;const T=c[d++];w.mmr=!!(1&T);w.template=T>>1&3;w.enableSkip=!!(8&T);w.combinationOperator=T>>4&7;w.defaultPixelValue=T>>7&1;w.gridWidth=(0,i.readUint32)(c,d);d+=4;w.gridHeight=(0,i.readUint32)(c,d);d+=4;w.gridOffsetX=4294967295&(0,i.readUint32)(c,d);d+=4;w.gridOffsetY=4294967295&(0,i.readUint32)(c,d);d+=4;w.gridVectorX=(0,i.readUint16)(c,d);d+=2;w.gridVectorY=(0,i.readUint16)(c,d);d+=2;r=[w,a.referredTo,c,d,f];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,d);d+=l;var x=c[d++];b.mmr=!!(1&x);b.template=x>>1&3;b.prediction=!!(8&x);if(!b.mmr){s=0===b.template?4:1;n=[];for(o=0;o>2&1;y.combinationOperator=v>>3&3;y.requiresBuffer=!!(32&v);y.combinationOperatorOverride=!!(64&v);r=[y];break;case 49:case 50:case 51:break;case 53:r=[a.number,c,d,f];break;case 62:break;default:throw new Jbig2Error(`segment type ${a.typeName}(${a.type}) is not implemented`)}var w="on"+a.typeName;w in t&&t[w].apply(t,r)}function processSegments(e,t){for(var r=0,n=e.length;r>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;n>3,d=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,f=this.buffer,h=128>>(7&e.x),u=e.y*l+(e.x>>3);switch(d){case 0:for(r=0;r>=1)){i=128;o++}}u+=l}break;case 2:for(r=0;r>=1)){i=128;o++}}u+=l}break;default:throw new Jbig2Error(`operator ${d} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,r,n){var i=e.info,o=new DecodingContext(t,r,n),s=decodeBitmap(e.mmr,i.width,i.height,e.template,e.prediction,null,e.at,o);this.drawBitmap(i,s)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(e,t,r,n,o,s){let a,c;if(e.huffman){a=function getSymbolDictionaryHuffmanTables(e,t,r){let n,i,o,s,a=0;switch(e.huffmanDHSelector){case 0:case 1:n=getStandardTable(e.huffmanDHSelector+4);break;case 3:n=getCustomHuffmanTable(a,t,r);a++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:i=getStandardTable(e.huffmanDWSelector+2);break;case 3:i=getCustomHuffmanTable(a,t,r);a++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){o=getCustomHuffmanTable(a,t,r);a++}else o=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(a,t,r):getStandardTable(1);return{tableDeltaHeight:n,tableDeltaWidth:i,tableBitmapSize:o,tableAggregateInstances:s}}(e,r,this.customTables);c=new Reader(n,o,s)}var l=this.symbols;l||(this.symbols=l={});for(var d=[],f=0,h=r.length;f1)v=decodeTextRegion(e,t,n,p,0,T,1,r.concat(u),m,0,0,1,0,s,l,d,f,0,h);else{var C=decodeIAID(b,g,m),I=decodeInteger(b,"IARDX",g),P=decodeInteger(b,"IARDY",g);v=decodeRefinement(n,p,l,C=32){let r,n,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");n=i.readBits(2)+3;r=o[e-1].prefixLength;break;case 33:n=i.readBits(3)+3;r=0;break;case 34:n=i.readBits(7)+11;r=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s=0;b--){_=e?decodeMMRBitmap(S,l,d,!0):decodeBitmap(!1,l,d,r,!1,null,P,m);k[b]=_}for(E=0;E=0;x--){L=k[x][E][B]^L;D|=L<>8;A=h+E*u-B*p>>8;if(O>=0&&O+T<=n&&A>=0&&A+C<=o)for(b=0;b=o)){U=g[t];R=M[b];for(x=0;x=0&&e>1&7),l=1+(n>>4&7),d=[];let f,h,u=o;do{f=a.readBits(c);h=a.readBits(l);d.push(new HuffmanLine([u,f,h,0]));u+=1<>t&1;if(t<=0)this.children[r]=new HuffmanTreeNode(e);else{let n=this.children[r];n||(this.children[r]=n=new HuffmanTreeNode(null));n.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 Jbig2Error("invalid Huffman data");return t.decodeNode(e)}};function HuffmanTable(e,t){t||this.assignPrefixCodes(e);this.rootNode=new HuffmanTreeNode(null);for(let t=0,r=e.length;t0&&this.rootNode.buildTree(r,r.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let r=0;for(let n=0;n=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const e=this.currentByte>>this.shift&1;this.shift--;return e},readBits(e){let t,r=0;for(t=e-1;t>=0;t--)r|=this.readBit()<=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,r){let n=0;for(let i=0,o=t.length;i>r&1;r--}}if(n&&!l){const e=5;for(let t=0;tfunction parseJbig2Chunks(e){for(var t=new SimpleSegmentVisitor,r=0,n=e.length;r>=1}}return{imgData:f,width:c,height:l}}(e);this.width=r;this.height=n;return t}};return Jbig2Image}();t.Jbig2Image=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.getInheritableProperty=function getInheritableProperty({dict:e,key:t,getArray:r=!1,stopWhenFound:i=!0}){let o,s=0;for(;e;){const a=r?e.getArray(t):e.get(t);if(void 0!==a){if(i)return a;o||(o=[]);o.push(a)}if(++s>100){(0,n.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return o};t.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,n.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const r=[];let o;for(;e>=1e3;){e-=1e3;r.push("M")}o=e/100|0;e%=100;r.push(i[o]);o=e/10|0;e%=10;r.push(i[10+o]);r.push(i[20+e]);const s=r.join("");return t?s.toLowerCase():s};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.readInt8=function readInt8(e,t){return e[t]<<24>>24};t.readUint16=function readUint16(e,t){return e[t]<<8|e[t+1]};t.readUint32=function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var n=r(1);class MissingDataException extends n.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends n.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends n.BaseException{}t.XRefParseException=XRefParseException;const i=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ArithmeticDecoder=void 0;const n=[{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 ArithmeticDecoder{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;if(255===e[t])if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}else{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 o=n[r],s=o.qe;let a,c=this.a-s;if(this.chigh>15&1;this.clow=this.clow<<1&65535;this.ct--}while(0==(32768&c));this.a=c;e[t]=r<<1|i;return a}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var n=r(1);const i=function CCITTFaxDecoder(){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]],o=[[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 CCITTFaxDecoder(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,n=t.EndOfBlock;null==n&&(n=!0);this.eoblock=n;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;for(;0===(r=this._lookBits(12));)this._eatBits(1);1===r&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}CCITTFaxDecoder.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,r=this.columns;let i,o,s,a,c;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let s,c,l;if(this.nextLine2D){for(a=0;t[a]=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)}this._addPixels(t[this.codingPos]+s,o);t[this.codingPos]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,o);o^=1}}let d=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){s=this._lookBits(12);if(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)}if(1===s){this._eatBits(12);d=!0}else-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)}if(this.eoblock&&d&&this.byteAlign){s=this._lookBits(12);if(1===s){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(a=0;a<4;++a){s=this._lookBits(12);1!==s&&(0,n.info)("bad rtc code: "+s);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){s=this._lookBits(13);if(-1===s){this.eof=!0;return-1}if(s>>1==1)break;this._eatBits(1)}this._eatBits(12);if(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;if(0===this.outputBits&&t[this.codingPos]s){c<<=s;1&this.codingPos||(c|=255>>8-s);this.outputBits-=s;s=0}else{c<<=this.outputBits;1&this.codingPos||(c|=255>>8-this.outputBits);s-=this.outputBits;this.outputBits=0;if(t[this.codingPos]0){c<<=s;s=0}}}while(s)}this.black&&(c^=255);return c},_addPixels(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i]){if(e>this.columns){(0,n.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]){if(e>this.columns){(0,n.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]===n){this._eatBits(n);return[!0,t[1],!0]}}}return[!1,0,!1]},_getTwoDimCode(){let t,r=0;if(this.eoblock){r=this._lookBits(7);t=e[r];if(t&&t[0]>0){this._eatBits(t[0]);return t[1]}}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}(0,n.info)("Bad two dim code");return-1},_getWhiteCode(){let e,i=0;if(this.eoblock){i=this._lookBits(12);if(-1===i)return 1;e=i>>5==0?t[i]:r[i>>3];if(e[0]>0){this._eatBits(e[0]);return e[1]}}else{let e=this._findTableCode(1,9,r);if(e[0])return e[1];e=this._findTableCode(11,12,t);if(e[0])return e[1]}(0,n.info)("bad white code");this._eatBits(1);return 1},_getBlackCode(){let e,t;if(this.eoblock){e=this._lookBits(13);if(-1===e)return 1;t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?o[(e>>1)-64]:s[e>>7];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];e=this._findTableCode(7,12,o,64);if(e[0])return e[1];e=this._findTableCode(10,13,i);if(e[0])return e[1]}(0,n.info)("bad black code");this._eatBits(1);return 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)}};return CCITTFaxDecoder}();t.CCITTFaxDecoder=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.JpegImage=void 0;var n=r(1),i=r(5);class JpegError extends n.BaseException{constructor(e){super("JPEG error: "+e)}}class DNLMarkerError extends n.BaseException{constructor(e,t){super(e);this.scanLines=t}}class EOIMarkerError extends n.BaseException{}var o=function JpegImageClosure(){var e=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function JpegImage({decodeTransform:e=null,colorTransform:t=-1}={}){this._decodeTransform=e;this._colorTransform=t}function buildHuffmanTable(e,t){for(var r,n,i=0,o=[],s=16;s>0&&!e[s-1];)s--;o.push({children:[],index:0});var a,c=o[0];for(r=0;r0;)c=o.pop();c.index++;o.push(c);for(;o.length<=r;){o.push(a={children:[],index:0});c.children[c.index]=a.children;c=a}i++}if(r+10){b--;return g>>b&1}g=t[r++];if(255===g){var e=t[r++];if(e){if(220===e&&h){r+=2;const e=(0,i.readUint16)(t,r);r+=2;if(e>0&&e!==o.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(h){const e=w*(8===o.precision?8:0);if(e>0&&Math.round(o.scanLines/e)>=10)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",e)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new JpegError("unexpected marker "+(g<<8|e).toString(16))}}b=7;return g>>>7}function decodeHuffman(e){for(var t=e;;){switch(typeof(t=t[readBit()])){case"number":return t;case"object":continue}throw new JpegError("invalid huffman sequence")}}function receive(e){for(var t=0;e>0;){t=t<<1|readBit();e--}return t}function receiveAndExtend(e){if(1===e)return 1===readBit()?1:-1;var t=receive(e);return t>=1<0)x--;else for(var n=c,i=l;n<=i;){var o=decodeHuffman(t.huffmanTableAC),s=15&o,a=o>>4;if(0!==s){var d=e[n+=a];t.blockData[r+d]=receiveAndExtend(s)*(1<>4;if(0===(n=15&i))if(a<15){x=receive(a)+(1<>4;if(0!==a){var l=e[o+=c];t.blockData[r+l]=receiveAndExtend(a);o++}else{if(c<15)break;o+=16}}};var E,B,L,D,M=0;B=1===_?s[0].blocksPerLine*s[0].blocksPerColumn:u*o.mcusPerColumn;for(;M<=B;){var O=a?Math.min(B-M,a):B;if(O>0){for(C=0;C<_;C++)s[C].pred=0;x=0;if(1===_){T=s[0];for(k=0;k0?"unexpected":"excessive";(0,n.warn)(`decodeScan - ${e} MCU data, current marker is: ${E.invalid}`);r=E.offset}if(!(E.marker>=65488&&E.marker<=65495))break;r+=2}return r-m}function quantizeAndInverse(e,t,r){var n,i,o,s,a,c,l,d,f,h,u,p,m,g,b,x,y,v=e.quantizationTable,w=e.blockData;if(!v)throw new JpegError("missing required Quantization Table.");for(var T=0;T<64;T+=8){f=w[t+T];h=w[t+T+1];u=w[t+T+2];p=w[t+T+3];m=w[t+T+4];g=w[t+T+5];b=w[t+T+6];x=w[t+T+7];f*=v[T];if(0!=(h|u|p|m|g|b|x)){h*=v[T+1];u*=v[T+2];p*=v[T+3];m*=v[T+4];g*=v[T+5];i=(n=(n=5793*f+128>>8)+(i=5793*m+128>>8)+1>>1)-i;y=3784*(o=u)+1567*(s=b*=v[T+6])+128>>8;o=1567*o-3784*s+128>>8;l=(a=(a=2896*(h-(x*=v[T+7]))+128>>8)+(l=g<<4)+1>>1)-l;c=(d=(d=2896*(h+x)+128>>8)+(c=p<<4)+1>>1)-c;s=(n=n+(s=y)+1>>1)-s;o=(i=i+o+1>>1)-o;y=2276*a+3406*d+2048>>12;a=3406*a-2276*d+2048>>12;d=y;y=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;l=y;r[T]=n+d;r[T+7]=n-d;r[T+1]=i+l;r[T+6]=i-l;r[T+2]=o+c;r[T+5]=o-c;r[T+3]=s+a;r[T+4]=s-a}else{y=5793*f+512>>10;r[T]=y;r[T+1]=y;r[T+2]=y;r[T+3]=y;r[T+4]=y;r[T+5]=y;r[T+6]=y;r[T+7]=y}}for(var C=0;C<8;++C){f=r[C];if(0!=((h=r[C+8])|(u=r[C+16])|(p=r[C+24])|(m=r[C+32])|(g=r[C+40])|(b=r[C+48])|(x=r[C+56]))){i=(n=4112+((n=5793*f+2048>>12)+(i=5793*m+2048>>12)+1>>1))-i;y=3784*(o=u)+1567*(s=b)+2048>>12;o=1567*o-3784*s+2048>>12;s=y;l=(a=(a=2896*(h-x)+2048>>12)+(l=g)+1>>1)-l;c=(d=(d=2896*(h+x)+2048>>12)+(c=p)+1>>1)-c;y=2276*a+3406*d+2048>>12;a=3406*a-2276*d+2048>>12;d=y;y=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;(f=(n=n+s+1>>1)+d)<16?f=0:f>=4080?f=255:f>>=4;(h=(i=i+o+1>>1)+(l=y))<16?h=0:h>=4080?h=255:h>>=4;(u=(o=i-o)+c)<16?u=0:u>=4080?u=255:u>>=4;(p=(s=n-s)+a)<16?p=0:p>=4080?p=255:p>>=4;(m=s-a)<16?m=0:m>=4080?m=255:m>>=4;(g=o-c)<16?g=0:g>=4080?g=255:g>>=4;(b=i-l)<16?b=0:b>=4080?b=255:b>>=4;(x=n-d)<16?x=0:x>=4080?x=255:x>>=4;w[t+C]=f;w[t+C+8]=h;w[t+C+16]=u;w[t+C+24]=p;w[t+C+32]=m;w[t+C+40]=g;w[t+C+48]=b;w[t+C+56]=x}else{y=(y=5793*f+8192>>14)<-2040?0:y>=2024?255:y+2056>>4;w[t+C]=y;w[t+C+8]=y;w[t+C+16]=y;w[t+C+24]=y;w[t+C+32]=y;w[t+C+40]=y;w[t+C+48]=y;w[t+C+56]=y}}}function buildComponentData(e,t){for(var r=t.blocksPerLine,n=t.blocksPerColumn,i=new Int16Array(64),o=0;o=n)return null;var s=(0,i.readUint16)(e,t);if(s>=65472&&s<=65534)return{invalid:null,marker:s,offset:t};for(var a=(0,i.readUint16)(e,o);!(a>=65472&&a<=65534);){if(++o>=n)return null;a=(0,i.readUint16)(e,o)}return{invalid:s.toString(16),marker:a,offset:o}}JpegImage.prototype={parse(t,{dnlScanLines:r=null}={}){function readDataBlock(){const e=(0,i.readUint16)(t,a);let r=(a+=2)+e-2;var o=findNextFileMarker(t,r,a);if(o&&o.invalid){(0,n.warn)("readDataBlock - incorrect length, current marker is: "+o.invalid);r=o.offset}var s=t.subarray(a,r);a+=s.length;return s}function prepareComponents(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),n=0;n>4==0)for(g=0;g<64;g++)w[e[g]]=t[a++];else{if(v>>4!=1)throw new JpegError("DQT - invalid table spec");for(g=0;g<64;g++){w[e[g]]=(0,i.readUint16)(t,a);a+=2}}f[15&v]=w}break;case 65472:case 65473:case 65474:if(o)throw new JpegError("Only single frame JPEGs supported");a+=2;(o={}).extended=65473===p;o.progressive=65474===p;o.precision=t[a++];const z=(0,i.readUint16)(t,a);a+=2;o.scanLines=r||z;o.samplesPerLine=(0,i.readUint16)(t,a);a+=2;o.components=[];o.componentIds={};var T,C=t[a++],I=0,P=0;for(m=0;m>4,S=15&t[a+1];I>4==0?u:h)[15&E]=buildHuffmanTable(B,D)}break;case 65501:a+=2;s=(0,i.readUint16)(t,a);a+=2;break;case 65498:const j=1==++d&&!r;a+=2;var M,O=t[a++],A=[];for(m=0;m>4];M.huffmanTableAC=h[15&U];A.push(M)}var F=t[a++],N=t[a++],H=t[a++];try{var J=decodeScan(t,a,o,A,s,F,N,H>>4,15&H,j);a+=J}catch(e){if(e instanceof DNLMarkerError){(0,n.warn)(e.message+" -- attempting to re-parse the JPEG image.");return this.parse(t,{dnlScanLines:e.scanLines})}if(e instanceof EOIMarkerError){(0,n.warn)(e.message+" -- ignoring the rest of the image data.");break e}throw e}break;case 65500:a+=4;break;case 65535:255!==t[a]&&a--;break;default:const q=findNextFileMarker(t,a-2,a-3);if(q&&q.invalid){(0,n.warn)("JpegImage.parse - unexpected data, current marker is: "+q.invalid);a=q.offset;break}if(a>=t.length-1){(0,n.warn)("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break e}throw new JpegError("JpegImage.parse - unknown marker: "+p.toString(16))}p=(0,i.readUint16)(t,a);a+=2}this.width=o.samplesPerLine;this.height=o.scanLines;this.jfif=c;this.adobe=l;this.components=[];for(m=0;m>8)+T[f+1];return y},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform&&(82!==this.components[0].index||71!==this.components[1].index||66!==this.components[2].index):1===this._colorTransform},_convertYccToRgb:function convertYccToRgb(e){for(var t,r,n,i=0,o=e.length;i4)throw new JpegError("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,n);if(1===this.numComponents&&r){for(var o=i.length,s=new Uint8ClampedArray(3*o),a=0,c=0;c>24&255,a>>16&255,a>>8&255,255&a);(0,n.warn)("Unsupported header type "+a+" ("+h+")")}l&&(t+=c)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function JpxImage_parseImageProperties(e){for(var t=e.getByte();t>=0;){if(65361===(t<<8|(t=e.getByte()))){e.skip(4);var r=e.getInt32()>>>0,n=e.getInt32()>>>0,i=e.getInt32()>>>0,o=e.getInt32()>>>0;e.skip(16);var s=e.getUint16();this.width=r-i;this.height=n-o;this.componentsCount=s;this.bitsPerComponent=8;return}}throw new JpxError("No size marker found in JPX stream")},parseCodestream:function JpxImage_parseCodestream(e,t,r){var o={},s=!1;try{for(var a=t;a+1>5;f=[];for(;l>3;T.mu=0}else{T.epsilon=e[l]>>3;T.mu=(7&e[l])<<8|e[l+1];l+=2}f.push(T)}w.SPqcds=f;if(o.mainHeader)o.QCD=w;else{o.currentTile.QCD=w;o.currentTile.QCC=[]}break;case 65373:m=(0,i.readUint16)(e,a);var C,I={};l=a+2;if(o.SIZ.Csiz<257)C=e[l++];else{C=(0,i.readUint16)(e,l);l+=2}switch(31&(d=e[l++])){case 0:h=8;u=!0;break;case 1:h=16;u=!1;break;case 2:h=16;u=!0;break;default:throw new Error("Invalid SQcd value "+d)}I.noQuantization=8===h;I.scalarExpounded=u;I.guardBits=d>>5;f=[];for(;l>3;T.mu=0}else{T.epsilon=e[l]>>3;T.mu=(7&e[l])<<8|e[l+1];l+=2}f.push(T)}I.SPqcds=f;o.mainHeader?o.QCC[C]=I:o.currentTile.QCC[C]=I;break;case 65362:m=(0,i.readUint16)(e,a);var P={};l=a+2;var k=e[l++];P.entropyCoderWithCustomPrecincts=!!(1&k);P.sopMarkerUsed=!!(2&k);P.ephMarkerUsed=!!(4&k);P.progressionOrder=e[l++];P.layersCount=(0,i.readUint16)(e,l);l+=2;P.multipleComponentTransform=e[l++];P.decompositionLevelsCount=e[l++];P.xcb=2+(15&e[l++]);P.ycb=2+(15&e[l++]);var S=e[l++];P.selectiveArithmeticCodingBypass=!!(1&S);P.resetContextProbabilities=!!(2&S);P.terminationOnEachCodingPass=!!(4&S);P.verticallyStripe=!!(8&S);P.predictableTermination=!!(16&S);P.segmentationSymbolUsed=!!(32&S);P.reversibleTransformation=e[l++];if(P.entropyCoderWithCustomPrecincts){for(var _=[];l>4})}P.precinctsSizes=_}var B=[];P.selectiveArithmeticCodingBypass&&B.push("selectiveArithmeticCodingBypass");P.resetContextProbabilities&&B.push("resetContextProbabilities");P.terminationOnEachCodingPass&&B.push("terminationOnEachCodingPass");P.verticallyStripe&&B.push("verticallyStripe");P.predictableTermination&&B.push("predictableTermination");if(B.length>0){s=!0;throw new Error("Unsupported COD options ("+B.join(", ")+")")}if(o.mainHeader)o.COD=P;else{o.currentTile.COD=P;o.currentTile.COC=[]}break;case 65424:m=(0,i.readUint16)(e,a);(p={}).index=(0,i.readUint16)(e,a+2);p.length=(0,i.readUint32)(e,a+4);p.dataEnd=p.length+a-2;p.partIndex=e[a+8];p.partsCount=e[a+9];o.mainHeader=!1;if(0===p.partIndex){p.COD=o.COD;p.COC=o.COC.slice(0);p.QCD=o.QCD;p.QCC=o.QCC.slice(0)}o.currentTile=p;break;case 65427:if(0===(p=o.currentTile).partIndex){initializeTile(o,p.index);buildPackets(o)}parseTilePackets(o,e,a,m=p.dataEnd-a);break;case 65365:case 65367:case 65368:case 65380:m=(0,i.readUint16)(e,a);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+c.toString(16))}a+=m}}catch(e){if(s||this.failOnCorruptedImage)throw new JpxError(e.message);(0,n.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function transformComponents(e){for(var t=e.SIZ,r=e.components,n=t.Csiz,i=[],o=0,s=e.tiles.length;o>2);x[v++]=e+g>>d;x[v++]=e>>d;x[v++]=e+m>>d}else for(h=0;h>d;x[v++]=p-.34413*m-.71414*g>>d;x[v++]=p+1.772*m>>d}if(w)for(h=0,v=3;h>d}else for(a=0;a>d;v+=n}}i.push(y)}return i}(o);this.width=o.SIZ.Xsiz-o.SIZ.XOsiz;this.height=o.SIZ.Ysiz-o.SIZ.YOsiz;this.componentsCount=o.SIZ.Csiz}};function calculateComponentDimensions(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz);e.x1=Math.ceil(t.Xsiz/e.XRsiz);e.y0=Math.ceil(t.YOsiz/e.YRsiz);e.y1=Math.ceil(t.Ysiz/e.YRsiz);e.width=e.x1-e.x0;e.height=e.y1-e.y0}function calculateTileGrids(e,t){for(var r,n=e.SIZ,i=[],o=Math.ceil((n.Xsiz-n.XTOsiz)/n.XTsiz),s=Math.ceil((n.Ysiz-n.YTOsiz)/n.YTsiz),a=0;a0?Math.min(n.xcb,i.PPx-1):Math.min(n.xcb,i.PPx);i.ycb_=r>0?Math.min(n.ycb,i.PPy-1):Math.min(n.ycb,i.PPy);return i}function buildPrecincts(e,t,r){var n=1<t.trx0?Math.ceil(t.trx1/n)-Math.floor(t.trx0/n):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,d=c*l;t.precinctParameters={precinctWidth:n,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:d,precinctWidthInSubband:s,precinctHeightInSubband:a}}function buildCodeblocks(e,t,r){var n,i,o,s,a=r.xcb_,c=r.ycb_,l=1<>a,h=t.tby0>>c,u=t.tbx1+l-1>>a,p=t.tby1+d-1>>c,m=t.resolution.precinctParameters,g=[],b=[];for(i=h;ix.cbxMax&&(x.cbxMax=n);ix.cbyMax&&(x.cbyMax=i)}else b[s]=x={cbxMin:n,cbyMin:i,cbxMax:n,cbyMax:i};o.precinct=x}}t.codeblockParameters={codeblockWidth:a,codeblockHeight:c,numcodeblockwide:u-f+1,numcodeblockhigh:p-h+1};t.codeblocks=g;t.precincts=b}function createPacket(e,t,r){for(var n=[],i=e.subbands,o=0,s=i.length;oe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;fl.codingStyleParameters.decompositionLevelsCount)){var e=l.resolutions[r],o=e.precinctParameters.numprecincts;if(!(i>=o)){for(;t=0;--g){var b=c.resolutions[g],x=m*b.precinctParameters.precinctWidth,y=m*b.precinctParameters.precinctHeight;f=Math.min(f,x);h=Math.min(h,y);u=Math.max(u,b.precinctParameters.numprecinctswide);p=Math.max(p,b.precinctParameters.numprecinctshigh);d[g]={width:x,height:y};m<<=1}r=Math.min(r,f);n=Math.min(n,h);i=Math.max(i,u);o=Math.max(o,p);s[a]={resolutions:d,minWidth:f,minHeight:h,maxNumWide:u,maxNumHigh:p}}return{components:s,minWidth:r,minHeight:n,maxNumWide:i,maxNumHigh:o}}function buildPackets(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=t.Csiz,o=0;o>>(l-=e)&(1<0;){var O=y.shift();void 0===(b=O.codeblock).data&&(b.data=[]);b.data.push({data:n,start:o+c,end:o+c+O.dataLength,codingpasses:O.codingpasses});c+=O.dataLength}}}return c}function copyCoefficients(e,t,r,n,i,a,c,l){for(var d=n.tbx0,f=n.tby0,h=n.tbx1-n.tbx0,u=n.codeblocks,p="H"===n.type.charAt(0)?1:0,m="H"===n.type.charAt(1)?t:0,g=0,b=u.length;g=a?O:O*(1<0?1-y:0)}var _=v.subbands[I],E=e[_.type];copyCoefficients(C,w,0,_,m?1:2**(p+E-S)*(1+k/2048),h+S-1,m,u)}b.push({width:w,height:T,items:C})}var B=g.calculate(b,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:B.width,height:B.height,items:B.items}}function initializeTile(e,t){for(var r=e.SIZ.Csiz,n=e.tiles[t],i=0;i>=1;t>>=1;n++}n--;(r=this.levels[n]).items[r.index]=i;this.currentLevel=n;delete this.value},incrementValue:function TagTree_incrementValue(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function TagTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];if(--e<0){this.value=r;return!1}this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return TagTree}(),r=function InclusionTreeClosure(){function InclusionTree(e,t,r){var n=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var o=0;or){this.currentLevel=n;this.propagateValues();return!1}e>>=1;t>>=1;n++}this.currentLevel=n-1;return!0},incrementValue:function InclusionTree_incrementValue(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1;this.propagateValues()},propagateValues:function InclusionTree_propagateValues(){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 InclusionTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];t.items[t.index]=255;if(--e<0)return!1;this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return InclusionTree}(),s=function BitModelClosure(){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 BitModel(n,i,o,s,a){this.width=n;this.height=i;let c;c="HH"===o?r:"HL"===o?t:e;this.contextLabelTable=c;var l=n*i;this.neighborsSignificance=new Uint8Array(l);this.coefficentsSign=new Uint8Array(l);let d;d=a>14?new Uint32Array(l):a>6?new Uint16Array(l):new Uint8Array(l);this.coefficentsMagnitude=d;this.processingFlags=new Uint8Array(l);var f=new Uint8Array(l);if(0!==s)for(var h=0;h0,c=t+10){n=r-o;a&&(i[n-1]+=16);c&&(i[n+1]+=16);i[n]+=4}if(e+1=r)break;s[h]&=-2;if(!n[h]&&o[h]){var m=c[o[h]];if(e.readBit(a,m)){var g=this.decodeSignBit(p,f,h);i[h]=g;n[h]=1;this.setNeighborsSignificance(p,f,h);s[h]|=2}l[h]++;s[h]|=1}}},decodeSignBit:function BitModel_decodeSignBit(e,t,r){var n,i,o,s,a,c,l=this.width,d=this.height,f=this.coefficentsMagnitude,h=this.coefficentsSign;s=t>0&&0!==f[r-1];if(t+10&&0!==f[r-l];if(e+1=0){a=9+n;c=this.decoder.readBit(this.contexts,a)}else{a=9-n;c=1^this.decoder.readBit(this.contexts,a)}return c},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){for(var e,t=this.decoder,r=this.width,n=this.height,i=this.coefficentsMagnitude,o=this.neighborsSignificance,s=this.contexts,a=this.bitsDecoded,c=this.processingFlags,l=r*n,d=4*r,f=0;f>1,c=-1.586134342059924,l=-.052980118572961,d=.882911075530934,f=.443506852043971,h=1.230174104914001;n=(t|=0)-3;for(i=a+4;i--;n+=2)e[n]*=.8128930661159609;o=f*e[(n=t-2)-1];for(i=a+3;i--;n+=2){s=f*e[n+1];e[n]=h*e[n]-o-s;if(!i--)break;o=f*e[(n+=2)+1];e[n]=h*e[n]-o-s}o=d*e[(n=t-1)-1];for(i=a+2;i--;n+=2){s=d*e[n+1];e[n]-=o+s;if(!i--)break;o=d*e[(n+=2)+1];e[n]-=o+s}o=l*e[(n=t)-1];for(i=a+1;i--;n+=2){s=l*e[n+1];e[n]-=o+s;if(!i--)break;o=l*e[(n+=2)+1];e[n]-=o+s}if(0!==a){o=c*e[(n=t+1)-1];for(i=a;i--;n+=2){s=c*e[n+1];e[n]-=o+s;if(!i--)break;o=c*e[(n+=2)+1];e[n]-=o+s}}};return IrreversibleTransform}(),l=function ReversibleTransformClosure(){function ReversibleTransform(){a.call(this)}ReversibleTransform.prototype=Object.create(a.prototype);ReversibleTransform.prototype.filter=function reversibleTransformFilter(e,t,r){var n,i,o=r>>1;for(n=t|=0,i=o+1;i--;n+=2)e[n]-=e[n-1]+e[n+1]+2>>2;for(n=t+1,i=o;i--;n+=2)e[n]+=e[n-1]+e[n+1]>>1};return ReversibleTransform}();return JpxImage}();t.JpxImage=s}])}));