pdf.image_decoders.min.js 102 KB

12345678910111213141516171819202122
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2020 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. !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;n<t;n++)r+=arrayByteLength(e[n]);let n=0;const i=new Uint8Array(r);for(let r=0;r<t;r++){let t=e[r];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const o=t.byteLength;i.set(t,n);n+=o}return i};t.assert=assert;t.bytesToString=function bytesToString(e){assert(null!==e&&"object"==typeof e&&void 0!==e.length,"Invalid argument for bytesToString");const t=e.length;if(t<8192)return String.fromCharCode.apply(null,e);const r=[];for(let n=0;n<t;n+=8192){const i=Math.min(n+8192,t),o=e.subarray(n,i);r.push(String.fromCharCode.apply(null,o))}return r.join("")};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});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<t;n+=2)r.push(String.fromCharCode(e.charCodeAt(n)<<8|e.charCodeAt(n+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let n=2;n<t;n+=2)r.push(String.fromCharCode(e.charCodeAt(n+1)<<8|e.charCodeAt(n)));else for(let n=0;n<t;++n){const t=d[e.charCodeAt(n)];r.push(t?String.fromCharCode(t):e.charAt(n))}return r.join("")};t.stringToUTF8String=function stringToUTF8String(e){return decodeURIComponent(escape(e))};t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;t.unreachable=unreachable;t.IsEvalSupportedCached=t.IsLittleEndianCached=t.createObjectURL=t.FormatError=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.StreamType=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.MissingPDFException=t.InvalidPDFException=t.AbortException=t.CMapCompressionType=t.ImageKind=t.FontType=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.UNSUPPORTED_FEATURES=t.VerbosityLevel=t.OPS=t.IDENTITY_MATRIX=t.FONT_IDENTITY_MATRIX=t.BaseException=void 0;r(2);t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};t.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"};t.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"};t.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};t.AnnotationReplyType={GROUP:"Group",REPLY:"R"};t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};t.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};t.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const n={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=n;t.CMapCompressionType={NONE:0,BINARY:1,STREAM:2};t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent"};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let i=n.WARNINGS;function warn(e){i>=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;n<t;++n)r[n]=255&e.charCodeAt(n);return r}function arrayByteLength(e){if(void 0!==e.length)return e.length;assert(void 0!==e.byteLength,"arrayByteLength - invalid argument.");return e.byteLength}const a={get value(){return shadow(this,"value",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}};t.IsLittleEndianCached=a;const c={get value(){return shadow(this,"value",function isEvalSupported(){try{new Function("");return!0}catch(e){return!1}}())}};t.IsEvalSupportedCached=c;const l=["rgb(",0,",",0,",",0,")"];class Util{static makeCssRgb(e,t,r){l[1]=e;l[3]=t;l[5]=r;return l.join("")}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const r=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/r,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/r]}static getAxialAlignedBoundingBox(e,t){const r=Util.applyTransform(e,t),n=Util.applyTransform(e.slice(2,4),t),i=Util.applyTransform([e[0],e[3]],t),o=Util.applyTransform([e[2],e[1]],t);return[Math.min(r[0],n[0],i[0],o[0]),Math.min(r[1],n[1],i[1],o[1]),Math.max(r[0],n[0],i[0],o[0]),Math.max(r[1],n[1],i[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static apply3dTransform(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],r=e[0]*t[0]+e[1]*t[2],n=e[0]*t[1]+e[1]*t[3],i=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],s=(r+o)/2,a=Math.sqrt((r+o)*(r+o)-4*(r*o-i*n))/2,c=s+a||1,l=s-a||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[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<n;r+=3){const o=255&t[r],s=255&t[r+1],a=255&t[r+2];i+=e[o>>2]+e[(3&o)<<4|s>>4]+e[r+1<n?(15&s)<<2|a>>6:64]+e[r+2<n?63&a:64]}return i}}();t.createObjectURL=f},function(e,t,r){"use strict";r(3)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isNodeJS=void 0;const n=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Image=void 0;var n=r(1),i=r(5),o=r(6),s=r(7);class Jbig2Error extends n.BaseException{constructor(e){super("JBIG2 error: "+e)}}var a=function Jbig2ImageClosure(){function ContextCache(){}ContextCache.prototype={getContexts(e){return e in this?this[e]:this[e]=new Int8Array(65536)}};function DecodingContext(e,t,r){this.data=e;this.start=t;this.end=r}DecodingContext.prototype={get decoder(){var e=new o.ArithmeticDecoder(this.data,this.start,this.end);return(0,n.shadow)(this,"decoder",e)},get contextCache(){var e=new ContextCache;return(0,n.shadow)(this,"contextCache",e)}};function decodeInteger(e,t,r){var n=e.getContexts(t),i=1;function readBits(e){for(var t=0,o=0;o<e;o++){var s=r.readBit(n,i);i=i<256?i<<1|s:511&(i<<1|s)|256;t=t<<1|s}return t>>>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<r;o++){i=i<<1|t.readBit(n,i)}return r<31?i&(1<<r)-1:2147483647&i}var e=["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"],t=[[{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}]],r=[{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}]}],a=[39717,1941,229,405],c=[32,8];function decodeBitmap(e,r,n,i,o,s,c,l){if(e){return decodeMMRBitmap(new Reader(l.data,l.start,l.end),r,n,!1)}if(0===i&&!s&&!o&&4===c.length&&3===c[0].x&&-1===c[0].y&&-3===c[1].x&&-1===c[1].y&&2===c[2].x&&-2===c[2].y&&-2===c[3].x&&-2===c[3].y)return function decodeBitmapTemplate0(e,t,r){var n,i,o,s,a,c,l,d=r.decoder,f=r.contextCache.getContexts("GB"),h=[];for(i=0;i<t;i++){a=h[i]=new Uint8Array(e);c=i<1?a:h[i-1];n=(l=i<2?a:h[i-2])[0]<<13|l[1]<<12|l[2]<<11|c[0]<<7|c[1]<<6|c[2]<<5|c[3]<<4;for(o=0;o<e;o++){a[o]=s=d.readBit(f,n);n=(31735&n)<<1|(o+3<e?l[o+3]<<11:0)|(o+4<e?c[o+4]<<4:0)|s}}return h}(r,n,l);var d=!!s,f=t[i].concat(c);f.sort((function(e,t){return e.y-t.y||e.x-t.x}));var h,u,p=f.length,m=new Int8Array(p),g=new Int8Array(p),b=[],x=0,y=0,v=0,w=0;for(u=0;u<p;u++){m[u]=f[u].x;g[u]=f[u].y;y=Math.min(y,f[u].x);v=Math.max(v,f[u].x);w=Math.min(w,f[u].y);u<p-1&&f[u].y===f[u+1].y&&f[u].x===f[u+1].x-1?x|=1<<p-1-u:b.push(u)}var T=b.length,C=new Int8Array(T),I=new Int8Array(T),P=new Uint16Array(T);for(h=0;h<T;h++){u=b[h];C[h]=f[u].x;I[h]=f[u].y;P[h]=1<<p-1-u}for(var k,S,_,E,B,L=-y,D=-w,M=r-v,O=a[i],A=new Uint8Array(r),R=[],U=l.decoder,F=l.contextCache.getContexts("GB"),N=0,H=0,J=0;J<n;J++){if(o){if(N^=U.readBit(F,O)){R.push(A);continue}}A=new Uint8Array(A);R.push(A);for(k=0;k<r;k++)if(d&&s[J][k])A[k]=0;else{if(k>=L&&k<M&&J>=D){H=H<<1&x;for(u=0;u<T;u++){S=J+I[u];_=k+C[u];(E=R[S][_])&&(H|=E=P[u])}}else{H=0;B=p-1;for(u=0;u<p;u++,B--)(_=k+m[u])>=0&&_<r&&(S=J+g[u])>=0&&(E=R[S][_])&&(H|=E<<B)}var z=U.readBit(F,H);A[k]=z}}return R}function decodeRefinement(e,t,n,i,o,s,a,l,d){var f=r[n].coding;0===n&&(f=f.concat([l[0]]));var h,u=f.length,p=new Int32Array(u),m=new Int32Array(u);for(h=0;h<u;h++){p[h]=f[h].x;m[h]=f[h].y}var g=r[n].reference;0===n&&(g=g.concat([l[1]]));var b=g.length,x=new Int32Array(b),y=new Int32Array(b);for(h=0;h<b;h++){x[h]=g[h].x;y[h]=g[h].y}for(var v=i[0].length,w=i.length,T=c[n],C=[],I=d.decoder,P=d.contextCache.getContexts("GR"),k=0,S=0;S<t;S++){if(a){if(k^=I.readBit(P,T))throw new Jbig2Error("prediction is not supported")}var _=new Uint8Array(e);C.push(_);for(var E=0;E<e;E++){var B,L,D=0;for(h=0;h<u;h++){B=S+m[h];L=E+p[h];B<0||L<0||L>=e?D<<=1:D=D<<1|C[B][L]}for(h=0;h<b;h++){B=S+y[h]-s;L=E+x[h]-o;B<0||B>=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;y<n;y++){v=new Uint8Array(r);if(i)for(var T=0;T<r;T++)v[T]=i;w.push(v)}var C=g.decoder,I=g.contextCache,P=e?-u.tableDeltaT.decode(x):-decodeInteger(I,"IADT",C),k=0;y=0;for(;y<o;){P+=e?u.tableDeltaT.decode(x):decodeInteger(I,"IADT",C);for(var S=k+=e?u.tableFirstS.decode(x):decodeInteger(I,"IAFS",C);;){let n=0;s>1&&(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<M;R++)if(v=w[H+R]){F=L[R];var J=Math.min(r-N,D);switch(h){case 0:for(U=0;U<J;U++)v[N+U]|=F[U];break;case 2:for(U=0;U<J;U++)v[N+U]^=F[U];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}S+=M-1}else{for(U=0;U<M;U++)if(v=w[N+U]){F=L[U];switch(h){case 0:for(R=0;R<D;R++)v[H+R]|=F[R];break;case 2:for(R=0;R<D;R++)v[H+R]^=F[R];break;default:throw new Jbig2Error(`operator ${h} is not supported`)}}S+=D-1}y++;var z=e?u.tableDeltaS.decode(x):decodeInteger(I,"IADS",C);if(null===z)break;S+=z+d}}return w}function readSegmentHeader(t,r){var n={};n.number=(0,i.readUint32)(t,r);var o=t[r+4],s=63&o;if(!e[s])throw new Jbig2Error("invalid segment type: "+s);n.type=s;n.typeName=e[s];n.deferredNonRetain=!!(128&o);var a=!!(64&o),c=t[r+5],d=c>>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<d;m++){let e;e=1===p?t[h]:2===p?(0,i.readUint16)(t,h):(0,i.readUint32)(t,h);b.push(e);h+=p}n.referredTo=b;if(a){n.pageAssociation=(0,i.readUint32)(t,h);h+=4}else n.pageAssociation=t[h++];n.length=(0,i.readUint32)(t,h);h+=4;if(4294967295===n.length){if(38!==s)throw new Jbig2Error("invalid unknown segment length");var x=readRegionSegmentInformation(t,h),y=!!(1&t[h+l]),v=new Uint8Array(6);if(!y){v[0]=255;v[1]=172}v[2]=x.height>>>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<g;m++){for(var w=0;w<6&&v[w]===t[m+w];)w++;if(6===w){n.length=m+6;break}}if(4294967295===n.length)throw new Jbig2Error("segment end was not found")}n.headerEnd=h;return n}function readSegments(e,t,r,n){for(var i=[],o=r;o<n;){var s=readSegmentHeader(t,o);o=s.headerEnd;var a={header:s,data:t};if(!e.randomAccess){a.start=o;o+=s.length;a.end=o}i.push(a);if(51===s.type)break}if(e.randomAccess)for(var c=0,l=i.length;c<l;c++){i[c].start=o;o+=i[c].header.length;i[c].end=o}return i}function readRegionSegmentInformation(e,t){return{width:(0,i.readUint32)(e,t),height:(0,i.readUint32)(e,t+4),x:(0,i.readUint32)(e,t+8),y:(0,i.readUint32)(e,t+12),combinationOperator:7&e[t+16]}}var l=17;function processSegment(e,t){var r,n,o,s,a=e.header,c=e.data,d=e.start,f=e.end;switch(a.type){case 0:var h={},u=(0,i.readUint16)(c,d);h.huffman=!!(1&u);h.refinement=!!(2&u);h.huffmanDHSelector=u>>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<s;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}h.at=n}if(h.refinement&&!h.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}h.refinementAt=n}h.numberOfExportedSymbols=(0,i.readUint32)(c,d);d+=4;h.numberOfNewSymbols=(0,i.readUint32)(c,d);d+=4;r=[h,a.number,a.referredTo,c,d,f];break;case 6:case 7:var p={};p.info=readRegionSegmentInformation(c,d);d+=l;var m=(0,i.readUint16)(c,d);d+=2;p.huffman=!!(1&m);p.refinement=!!(2&m);p.logStripSize=m>>2&3;p.stripSize=1<<p.logStripSize;p.referenceCorner=m>>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<s;o++){n.push({x:(0,i.readInt8)(c,d),y:(0,i.readInt8)(c,d+1)});d+=2}b.at=n}r=[b,c,d,f];break;case 48:var y={width:(0,i.readUint32)(c,d),height:(0,i.readUint32)(c,d+4),resolutionX:(0,i.readUint32)(c,d+8),resolutionY:(0,i.readUint32)(c,d+12)};4294967295===y.height&&delete y.height;var v=c[d+16];(0,i.readUint16)(c,d+17);y.lossless=!!(1&v);y.refinement=!!(2&v);y.defaultPixelValue=v>>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<n;r++)processSegment(e[r],t)}function SimpleSegmentVisitor(){}SimpleSegmentVisitor.prototype={onPageInformation:function SimpleSegmentVisitor_onPageInformation(e){this.currentPageInfo=e;var t=e.width+7>>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var n=0,i=r.length;n<i;n++)r[n]=255;this.buffer=r},drawBitmap:function SimpleSegmentVisitor_drawBitmap(e,t){var r,n,i,o,s=this.currentPageInfo,a=e.width,c=e.height,l=s.width+7>>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<c;r++){i=h;o=u;for(n=0;n<a;n++){t[r][n]&&(f[o]|=i);if(!(i>>=1)){i=128;o++}}u+=l}break;case 2:for(r=0;r<c;r++){i=h;o=u;for(n=0;n<a;n++){t[r][n]&&(f[o]^=i);if(!(i>>=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;f<h;f++){const e=l[r[f]];e&&(d=d.concat(e))}var u=new DecodingContext(n,o,s);l[t]=function decodeSymbolDictionary(e,t,r,n,o,s,a,c,l,d,f,h){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");var u=[],p=0,m=(0,i.log2)(r.length+n),g=f.decoder,b=f.contextCache;let x,y;if(e){x=getStandardTable(1);y=[];m=Math.max(m,1)}for(;u.length<n;){p+=e?s.tableDeltaHeight.decode(h):decodeInteger(b,"IADH",g);let n=0,i=0;const o=e?y.length:0;for(;;){var v,w=e?s.tableDeltaWidth.decode(h):decodeInteger(b,"IADW",g);if(null===w)break;n+=w;i+=n;if(t){var T=decodeInteger(b,"IAAI",g);if(T>1)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<r.length?r[C]:u[C-r.length],I,P,!1,d,f)}u.push(v)}else if(e)y.push(n);else{v=decodeBitmap(!1,n,p,a,!1,null,c,f);u.push(v)}}if(e&&!t){const e=s.tableBitmapSize.decode(h);h.byteAlign();let t;if(0===e)t=readUncompressedBitmap(h,i,p);else{const r=h.end,n=h.position+e;h.end=n;t=decodeMMRBitmap(h,i,p,!1);h.end=r;h.position=n}const r=y.length;if(o===r-1)u.push(t);else{let e,n,i,s,a,c=0;for(e=o;e<r;e++){s=y[e];i=c+s;a=[];for(n=0;n<p;n++)a.push(t[n].subarray(c,i));u.push(a);c=i}}}}for(var k=[],S=[],_=!1,E=r.length+n;S.length<E;){for(var B=e?x.decode(h):decodeInteger(b,"IAEX",g);B--;)S.push(_);_=!_}for(var L=0,D=r.length;L<D;L++)S[L]&&k.push(r[L]);for(var M=0;M<n;L++,M++)S[L]&&k.push(u[M]);return k}(e.huffman,e.refinement,d,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,u,c)},onImmediateTextRegion:function SimpleSegmentVisitor_onImmediateTextRegion(e,t,r,n,o){var s=e.info;let a,c;for(var l=this.symbols,d=[],f=0,h=t.length;f<h;f++){const e=l[t[f]];e&&(d=d.concat(e))}var u=(0,i.log2)(d.length);if(e.huffman){c=new Reader(r,n,o);a=function getTextRegionHuffmanTables(e,t,r,n,i){const o=[];for(let e=0;e<=34;e++){const t=i.readBits(4);o.push(new HuffmanLine([e,t,0,0]))}const s=new HuffmanTable(o,!1);o.length=0;for(let e=0;e<n;){const t=s.decode(i);if(t>=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<n;s++){o.push(new HuffmanLine([e,r,0,0]));e++}}else{o.push(new HuffmanLine([e,t,0,0]));e++}}i.byteAlign();const a=new HuffmanTable(o,!1);let c,l,d,f=0;switch(e.huffmanFS){case 0:case 1:c=getStandardTable(e.huffmanFS+6);break;case 3:c=getCustomHuffmanTable(f,t,r);f++;break;default:throw new Jbig2Error("invalid Huffman FS selector")}switch(e.huffmanDS){case 0:case 1:case 2:l=getStandardTable(e.huffmanDS+8);break;case 3:l=getCustomHuffmanTable(f,t,r);f++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(e.huffmanDT){case 0:case 1:case 2:d=getStandardTable(e.huffmanDT+11);break;case 3:d=getCustomHuffmanTable(f,t,r);f++;break;default:throw new Jbig2Error("invalid Huffman DT selector")}if(e.refinement)throw new Jbig2Error("refinement with Huffman is not supported");return{symbolIDTable:a,tableFirstS:c,tableDeltaS:l,tableDeltaT:d}}(e,t,this.customTables,d.length,c)}var p=new DecodingContext(r,n,o),m=decodeTextRegion(e.huffman,e.refinement,s.width,s.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,d,u,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,a,e.refinementTemplate,e.refinementAt,p,e.logStripSize,c);this.drawBitmap(s,m)},onImmediateLosslessTextRegion:function SimpleSegmentVisitor_onImmediateLosslessTextRegion(){this.onImmediateTextRegion.apply(this,arguments)},onPatternDictionary(e,t,r,n,i){let o=this.patterns;o||(this.patterns=o={});const s=new DecodingContext(r,n,i);o[t]=function decodePatternDictionary(e,t,r,n,i,o){const s=[];if(!e){s.push({x:-t,y:0});if(0===i){s.push({x:-3,y:-1});s.push({x:2,y:-2});s.push({x:-2,y:-2})}}const a=decodeBitmap(e,(n+1)*t,r,i,!1,null,s,o),c=[];for(let e=0;e<=n;e++){const n=[],i=t*e,o=i+t;for(let e=0;e<r;e++)n.push(a[e].subarray(i,o));c.push(n)}return c}(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,s)},onImmediateHalftoneRegion(e,t,r,n,o){const s=this.patterns[t[0]],a=e.info,c=new DecodingContext(r,n,o),l=function decodeHalftoneRegion(e,t,r,n,o,s,a,c,l,d,f,h,u,p,m){if(a)throw new Jbig2Error("skip is not supported");if(0!==c)throw new Jbig2Error("operator "+c+" is not supported in halftone region");const g=[];let b,x,y;for(b=0;b<o;b++){y=new Uint8Array(n);if(s)for(x=0;x<n;x++)y[x]=s;g.push(y)}const v=t.length,w=t[0],T=w[0].length,C=w.length,I=(0,i.log2)(v),P=[];if(!e){P.push({x:r<=1?3:2,y:-1});if(0===r){P.push({x:-3,y:-1});P.push({x:2,y:-2});P.push({x:-2,y:-2})}}const k=[];let S,_,E,B,L,D,M,O,A,R,U;e&&(S=new Reader(m.data,m.start,m.end));for(b=I-1;b>=0;b--){_=e?decodeMMRBitmap(S,l,d,!0):decodeBitmap(!1,l,d,r,!1,null,P,m);k[b]=_}for(E=0;E<d;E++)for(B=0;B<l;B++){L=0;D=0;for(x=I-1;x>=0;x--){L=k[x][E][B]^L;D|=L<<x}M=t[D];O=f+E*p+B*u>>8;A=h+E*u-B*p>>8;if(O>=0&&O+T<=n&&A>=0&&A+C<=o)for(b=0;b<C;b++){U=g[A+b];R=M[b];for(x=0;x<T;x++)U[O+x]|=R[x]}else{let e,t;for(b=0;b<C;b++){t=A+b;if(!(t<0||t>=o)){U=g[t];R=M[b];for(x=0;x<T;x++){e=O+x;e>=0&&e<n&&(U[e]|=R[x])}}}}}return g}(e.mmr,s,e.template,a.width,a.height,e.defaultPixelValue,e.enableSkip,e.combinationOperator,e.gridWidth,e.gridHeight,e.gridOffsetX,e.gridOffsetY,e.gridVectorX,e.gridVectorY,c);this.drawBitmap(a,l)},onImmediateLosslessHalftoneRegion(){this.onImmediateHalftoneRegion.apply(this,arguments)},onTables(e,t,r,n){let o=this.customTables;o||(this.customTables=o={});o[e]=function decodeTablesSegment(e,t,r){const n=e[t],o=4294967295&(0,i.readUint32)(e,t+1),s=4294967295&(0,i.readUint32)(e,t+5),a=new Reader(e,t+9,r),c=1+(n>>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<<h}while(u<s);f=a.readBits(c);d.push(new HuffmanLine([o-1,f,32,0,"lower"]));f=a.readBits(c);d.push(new HuffmanLine([s,f,32,0]));if(1&n){f=a.readBits(c);d.push(new HuffmanLine([f,0]))}return new HuffmanTable(d,!1)}(t,r,n)}};function HuffmanLine(e){if(2===e.length){this.isOOB=!0;this.rangeLow=0;this.prefixLength=e[0];this.rangeLength=0;this.prefixCode=e[1];this.isLowerRange=!1}else{this.isOOB=!1;this.rangeLow=e[0];this.prefixLength=e[1];this.rangeLength=e[2];this.prefixCode=e[3];this.isLowerRange="lower"===e[4]}}function HuffmanTreeNode(e){this.children=[];if(e){this.isLeaf=!0;this.rangeLength=e.rangeLength;this.rangeLow=e.rangeLow;this.isLowerRange=e.isLowerRange;this.isOOB=e.isOOB}else this.isLeaf=!1}HuffmanTreeNode.prototype={buildTree(e,t){const r=e.prefixCode>>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;t<r;t++){const r=e[t];r.prefixLength>0&&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<t;n++)r=Math.max(r,e[n].prefixLength);const n=new Uint32Array(r+1);for(let r=0;r<t;r++)n[e[r].prefixLength]++;let i,o,s,a=1,c=0;n[0]=0;for(;a<=r;){c=c+n[a-1]<<1;i=c;o=0;for(;o<t;){s=e[o];if(s.prefixLength===a){s.prefixCode=i;i++}o++}a++}}};const d={};function getStandardTable(e){let t,r=d[e];if(r)return r;switch(e){case 1:t=[[0,1,4,0],[16,2,8,2],[272,3,16,6],[65808,3,32,7]];break;case 2:t=[[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:t=[[-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:t=[[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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[-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:t=[[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:t=[[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:t=[[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:t=[[-2,3,0,4],[-1,3,0,5],[0,1,0,0],[1,3,0,6],[2,3,0,7]];break;case 15:t=[[-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.${e} does not exist`)}for(let e=0,r=t.length;e<r;e++)t[e]=new HuffmanLine(t[e]);r=new HuffmanTable(t,!0);d[e]=r;return r}function Reader(e,t,r){this.data=e;this.start=t;this.end=r;this.position=t;this.shift=-1;this.currentByte=0}Reader.prototype={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 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()<<t;return r},byteAlign(){this.shift=-1},next(){return this.position>=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,r){let n=0;for(let i=0,o=t.length;i<o;i++){const o=r[t[i]];if(o){if(e===n)return o;n++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(e,t,r){const n=[];for(let i=0;i<r;i++){const r=new Uint8Array(t);n.push(r);for(let n=0;n<t;n++)r[n]=e.readBit();e.byteAlign()}return n}function decodeMMRBitmap(e,t,r,n){const i={K:-1,Columns:t,Rows:r,BlackIs1:!0,EndOfBlock:n},o=new s.CCITTFaxDecoder(e,i),a=[];let c,l=!1;for(let e=0;e<r;e++){const e=new Uint8Array(t);a.push(e);let r=-1;for(let n=0;n<t;n++){if(r<0){c=o.readNextChar();if(-1===c){c=0;l=!0}r=7}e[n]=c>>r&1;r--}}if(n&&!l){const e=5;for(let t=0;t<e&&-1!==o.readNextChar();t++);}return a}function Jbig2Image(){}Jbig2Image.prototype={parseChunks:e=>function parseJbig2Chunks(e){for(var t=new SimpleSegmentVisitor,r=0,n=e.length;r<n;r++){var i=e[r];processSegments(readSegments({},i.data,i.start,i.end),t)}return t.buffer}(e),parse(e){const{imgData:t,width:r,height:n}=function parseJbig2(e){const t=e.length;let r=0;if(151!==e[r]||74!==e[r+1]||66!==e[r+2]||50!==e[r+3]||13!==e[r+4]||10!==e[r+5]||26!==e[r+6]||10!==e[r+7])throw new Jbig2Error("parseJbig2 - invalid header.");const n=Object.create(null);r+=8;const o=e[r++];n.randomAccess=!(1&o);if(!(2&o)){n.numberOfPages=(0,i.readUint32)(e,r);r+=4}const s=readSegments(n,e,r,t),a=new SimpleSegmentVisitor;processSegments(s,a);const{width:c,height:l}=a.currentPageInfo,d=a.buffer,f=new Uint8ClampedArray(c*l);let h=0,u=0;for(let e=0;e<l;e++){let e,t=0;for(let r=0;r<c;r++){if(!t){t=128;e=d[u++]}f[h++]=e&t?0:255;t>>=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+=t<this.dataEnd?e[t]<<8:65280;this.ct=8;this.bp=t}if(this.clow>65535){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<s)if(c<s){c=s;a=i;r=o.nmps}else{c=s;a=1^i;1===o.switchFlag&&(i=a);r=o.nlps}else{this.chigh-=s;if(0!=(32768&c)){this.a=c;return i}if(c<s){a=1^i;1===o.switchFlag&&(i=a);r=o.nlps}else{a=i;r=o.nmps}}do{0===this.ct&&this.byteIn();c<<=1;this.chigh=this.chigh<<1&65535|this.clow>>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]<r;++a)e[a]=t[a];e[a++]=r;e[a]=r;t[0]=0;this.codingPos=0;i=0;o=0;for(;t[this.codingPos]<r;){s=this._getTwoDimCode();switch(s){case 0:this._addPixels(e[i+1],o);e[i+1]<r&&(i+=2);break;case 1:s=c=0;if(o){do{s+=l=this._getBlackCode()}while(l>=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]<r&&this._addPixels(t[this.codingPos]+c,1^o);for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2;break;case 7:this._addPixels(e[i]+3,o);o^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 5:this._addPixels(e[i]+2,o);o^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 3:this._addPixels(e[i]+1,o);o^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 2:this._addPixels(e[i],o);o^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 8:this._addPixelsNeg(e[i]-3,o);o^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 6:this._addPixelsNeg(e[i]-2,o);o^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 4:this._addPixelsNeg(e[i]-1,o);o^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case-1:this._addPixels(r,0);this.eof=!0;break;default:(0,n.info)("bad 2d code");this._addPixels(r,0);this.err=!0}}}else{t[0]=0;this.codingPos=0;o=0;for(;t[this.codingPos]<r;){s=0;if(o)do{s+=l=this._getBlackCode()}while(l>=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]<r){this.codingPos++;this.outputBits=t[this.codingPos]-t[this.codingPos-1]}}else{s=8;c=0;do{if(this.outputBits>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]<r){this.codingPos++;this.outputBits=t[this.codingPos]-t[this.codingPos-1]}else if(s>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(e<r[i]){if(e<0){(0,n.info)("invalid code");this.err=!0;e=0}for(;i>0&&e<r[i-1];)--i;r[i]=e}this.codingPos=i},_findTableCode(e,t,r,n){const i=n||0;for(let n=e;n<=t;++n){let e=this._lookBits(n);if(-1===e)return[!0,1,!1];n<t&&(e<<=t-n);if(!i||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<e;){if(-1===(t=this.source.next()))return 0===this.inputBits?-1:this.inputBuf<<e-this.inputBits&65535>>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;r<s;r++){for(n=0;n<e[r];n++){(c=o.pop()).children[c.index]=t[i];for(;c.index>0;)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+1<s){o.push(a={children:[],index:0});c.children[c.index]=a.children;c=a}}return o[0].children}function getBlockBufferOffset(e,t,r){return 64*((e.blocksPerLine+1)*t+r)}function decodeScan(t,r,o,s,a,c,l,d,f,h=!1){var u=o.mcusPerLine,p=o.progressive;const m=r;let g=0,b=0;function readBit(){if(b>0){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<<e-1?t:t+(-1<<e)+1}var x=0;var y,v=0;let w=0;function decodeMcu(e,t,r,n,i){var o=r%u;w=(r/u|0)*e.v+n;var s=o*e.h+i;t(e,getBlockBufferOffset(e,w,s))}function decodeBlock(e,t,r){w=r/e.blocksPerLine|0;var n=r%e.blocksPerLine;t(e,getBlockBufferOffset(e,w,n))}var T,C,I,P,k,S,_=s.length;S=p?0===c?0===d?function decodeDCFirst(e,t){var r=decodeHuffman(e.huffmanTableDC),n=0===r?0:receiveAndExtend(r)<<f;e.blockData[t]=e.pred+=n}:function decodeDCSuccessive(e,t){e.blockData[t]|=readBit()<<f}:0===d?function decodeACFirst(t,r){if(x>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<<f);n++}else{if(a<15){x=receive(a)+(1<<a)-1;break}n+=16}}}:function decodeACSuccessive(t,r){for(var n,i,o=c,s=l,a=0;o<=s;){const s=r+e[o],c=t.blockData[s]<0?-1:1;switch(v){case 0:a=(i=decodeHuffman(t.huffmanTableAC))>>4;if(0===(n=15&i))if(a<15){x=receive(a)+(1<<a);v=4}else{a=16;v=1}else{if(1!==n)throw new JpegError("invalid ACn encoding");y=receiveAndExtend(n);v=a?2:3}continue;case 1:case 2:t.blockData[s]?t.blockData[s]+=c*(readBit()<<f):0===--a&&(v=2===v?3:0);break;case 3:if(t.blockData[s])t.blockData[s]+=c*(readBit()<<f);else{t.blockData[s]=y<<f;v=0}break;case 4:t.blockData[s]&&(t.blockData[s]+=c*(readBit()<<f))}o++}4===v&&0===--x&&(v=0)}:function decodeBaseline(t,r){var n=decodeHuffman(t.huffmanTableDC),i=0===n?0:receiveAndExtend(n);t.blockData[r]=t.pred+=i;for(var o=1;o<64;){var s=decodeHuffman(t.huffmanTableAC),a=15&s,c=s>>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;k<O;k++){decodeBlock(T,S,M);M++}}else for(k=0;k<O;k++){for(C=0;C<_;C++){L=(T=s[C]).h;D=T.v;for(I=0;I<D;I++)for(P=0;P<L;P++)decodeMcu(T,S,M,I,P)}M++}}b=0;if(!(E=findNextFileMarker(t,r)))break;if(E.invalid){const e=O>0?"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;o++)for(var s=0;s<r;s++){quantizeAndInverse(t,getBlockBufferOffset(t,o,s),i)}return t.blockData}function findNextFileMarker(e,t,r=t){const n=e.length-1;var o=r<t?r:t;if(t>=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<e.components.length;n++){M=e.components[n];var i=Math.ceil(Math.ceil(e.samplesPerLine/8)*M.h/e.maxH),o=Math.ceil(Math.ceil(e.scanLines/8)*M.v/e.maxV),s=t*M.h,a=64*(r*M.v)*(s+1);M.blockData=new Int16Array(a);M.blocksPerLine=i;M.blocksPerColumn=o}e.mcusPerLine=t;e.mcusPerColumn=r}var o,s,a=0,c=null,l=null;let d=0;var f=[],h=[],u=[];let p=(0,i.readUint16)(t,a);a+=2;if(65496!==p)throw new JpegError("SOI not found");p=(0,i.readUint16)(t,a);a+=2;e:for(;65497!==p;){var m,g,b;switch(p){case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var x=readDataBlock();65504===p&&74===x[0]&&70===x[1]&&73===x[2]&&70===x[3]&&0===x[4]&&(c={version:{major:x[5],minor:x[6]},densityUnits:x[7],xDensity:x[8]<<8|x[9],yDensity:x[10]<<8|x[11],thumbWidth:x[12],thumbHeight:x[13],thumbData:x.subarray(14,14+3*x[12]*x[13])});65518===p&&65===x[0]&&100===x[1]&&111===x[2]&&98===x[3]&&101===x[4]&&(l={version:x[5]<<8|x[6],flags0:x[7]<<8|x[8],flags1:x[9]<<8|x[10],transformCode:x[11]});break;case 65499:for(var y=(0,i.readUint16)(t,a)+(a+=2)-2;a<y;){var v=t[a++],w=new Uint16Array(64);if(v>>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<C;m++){T=t[a];var k=t[a+1]>>4,S=15&t[a+1];I<k&&(I=k);P<S&&(P=S);var _=t[a+2];b=o.components.push({h:k,v:S,quantizationId:_,quantizationTable:null});o.componentIds[T]=b-1;a+=3}o.maxH=I;o.maxV=P;prepareComponents(o);break;case 65476:const X=(0,i.readUint16)(t,a);a+=2;for(m=2;m<X;){var E=t[a++],B=new Uint8Array(16),L=0;for(g=0;g<16;g++,a++)L+=B[g]=t[a];var D=new Uint8Array(L);for(g=0;g<L;g++,a++)D[g]=t[a];m+=17+L;(E>>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<O;m++){const e=t[a++];var R=o.componentIds[e];(M=o.components[R]).index=e;var U=t[a++];M.huffmanTableDC=u[U>>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<o.components.length;m++){var z=f[(M=o.components[m]).quantizationId];z&&(M.quantizationTable=z);this.components.push({index:M.index,output:buildComponentData(0,M),scaleX:M.h/o.maxH,scaleY:M.v/o.maxV,blocksPerLine:M.blocksPerLine,blocksPerColumn:M.blocksPerColumn})}this.numComponents=this.components.length},_getLinearizedBlockData(e,t,r=!1){var n,i,o,s,a,c,l,d,f,h,u,p=this.width/e,m=this.height/t,g=0,b=this.components.length,x=e*t*b,y=new Uint8ClampedArray(x),v=new Uint32Array(e);let w;for(l=0;l<b;l++){i=(n=this.components[l]).scaleX*p;o=n.scaleY*m;g=l;u=n.output;s=n.blocksPerLine+1<<3;if(i!==w){for(a=0;a<e;a++){d=0|a*i;v[a]=(4294967288&d)<<3|7&d}w=i}for(c=0;c<t;c++){h=s*(4294967288&(d=0|c*o))|(7&d)<<3;for(a=0;a<e;a++){y[g]=u[h+v[a]];g+=b}}}let T=this._decodeTransform;r||4!==b||T||(T=new Int32Array([-256,255,-256,255,-256,255,-256,255]));if(T)for(l=0;l<x;)for(d=0,f=0;d<b;d++,l++,f+=2)y[l]=(y[l]*T[f]>>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;i<o;i+=3){t=e[i];r=e[i+1];n=e[i+2];e[i]=t-179.456+1.402*n;e[i+1]=t+135.459-.344*r-.714*n;e[i+2]=t-226.816+1.772*r}return e},_convertYcckToRgb:function convertYcckToRgb(e){for(var t,r,n,i,o=0,s=0,a=e.length;s<a;s+=4){t=e[s];r=e[s+1];n=e[s+2];i=e[s+3];e[o++]=r*(-660635669420364e-19*r+.000437130475926232*n-54080610064599e-18*t+.00048449797120281*i-.154362151871126)-122.67195406894+n*(-.000957964378445773*n+.000817076911346625*t-.00477271405408747*i+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*i+.48357088451265)+i*(-.000336197177618394*i+.484791561490776);e[o++]=107.268039397724+r*(219927104525741e-19*r-.000640992018297945*n+.000659397001245577*t+.000426105652938837*i-.176491792462875)+n*(-.000778269941513683*n+.00130872261408275*t+.000770482631801132*i-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*i+.25802910206845)+i*(-.000318913117588328*i-.213742400323665);e[o++]=r*(-.000570115196973677*r-263409051004589e-19*n+.0020741088115012*t-.00288260236853442*i+.814272968359295)-20.810012546947+n*(-153496057440975e-19*n-.000132689043961446*t+.000560833691242812*i-.195152027534049)+t*(.00174418132927582*t-.00255243321439347*i+.116935020465145)+i*(-.000343531996510555*i+.24165260232407)}return e.subarray(0,o)},_convertYcckToCmyk:function convertYcckToCmyk(e){for(var t,r,n,i=0,o=e.length;i<o;i+=4){t=e[i];r=e[i+1];n=e[i+2];e[i]=434.456-t-1.402*n;e[i+1]=119.541-t+.344*r+.714*n;e[i+2]=481.816-t-1.772*r}return e},_convertCmykToRgb:function convertCmykToRgb(e){for(var t,r,n,i,o=0,s=0,a=e.length;s<a;s+=4){t=e[s];r=e[s+1];n=e[s+2];i=e[s+3];e[o++]=255+t*(-6747147073602441e-20*t+.0008379262121013727*r+.0002894718188643294*n+.003264231057537806*i-1.1185611867203937)+r*(26374107616089405e-21*r-8626949158638572e-20*n-.0002748769067499491*i-.02155688794978967)+n*(-3878099212869363e-20*n-.0003267808279485286*i+.0686742238595345)-i*(.0003361971776183937*i+.7430659151342254);e[o++]=255+t*(.00013596372813588848*t+.000924537132573585*r+.00010567359618683593*n+.0004791864687436512*i-.3109689587515875)+r*(-.00023545346108370344*r+.0002702845253534714*n+.0020200308977307156*i-.7488052167015494)+n*(6834815998235662e-20*n+.00015168452363460973*i-.09751927774728933)-i*(.0003189131175883281*i+.7364883807733168);e[o++]=255+t*(13598650411385307e-21*t+.00012423956175490851*r+.0004751985097583589*n-36729317476630422e-22*i-.05562186980264034)+r*(.00016141380598724676*r+.0009692239130725186*n+.0007782692450036253*i-.44015232367526463)+n*(5.068882914068769e-7*n+.0017778369011375071*i-.7591454649749609)-i*(.0003435319965105553*i+.7063770186160144)}return e.subarray(0,o)},getData({width:e,height:t,forceRGB:r=!1,isSourcePDF:n=!1}){if(this.numComponents>4)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<o;c++){var l=i[c];s[a++]=l;s[a++]=l;s[a++]=l}return s}if(3===this.numComponents&&this._isColorConversionNeeded)return this._convertYccToRgb(i);if(4===this.numComponents){if(this._isColorConversionNeeded)return r?this._convertYcckToRgb(i):this._convertYcckToCmyk(i);if(r)return this._convertCmykToRgb(i)}return i}};return JpegImage}();t.JpegImage=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.JpxImage=void 0;var n=r(1),i=r(5),o=r(6);class JpxError extends n.BaseException{constructor(e){super("JPX error: "+e)}}var s=function JpxImageClosure(){var e={LL:0,LH:1,HL:1,HH:2};function JpxImage(){this.failOnCorruptedImage=!1}JpxImage.prototype={parse:function JpxImage_parse(e){if(65359!==(0,i.readUint16)(e,0))for(var t=0,r=e.length;t<r;){var o=8,s=(0,i.readUint32)(e,t),a=(0,i.readUint32)(e,t+4);t+=o;if(1===s){s=4294967296*(0,i.readUint32)(e,t)+(0,i.readUint32)(e,t+4);t+=8;o+=8}0===s&&(s=r-t+o);if(s<o)throw new JpxError("Invalid box field size");var c=s-o,l=!0;switch(a){case 1785737832:l=!1;break;case 1668246642:var d=e[t];if(1===d){var f=(0,i.readUint32)(e,t+3);switch(f){case 16:case 17:case 18:break;default:(0,n.warn)("Unknown colorspace "+f)}}else 2===d&&(0,n.info)("ICC profile not supported");break;case 1785737827:this.parseCodestream(e,t,t+c);break;case 1783636e3:218793738!==(0,i.readUint32)(e,t)&&(0,n.warn)("Invalid JP2 signature");break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var h=String.fromCharCode(a>>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<r;){var c=(0,i.readUint16)(e,a);a+=2;var l,d,f,h,u,p,m=0;switch(c){case 65359:o.mainHeader=!0;break;case 65497:break;case 65361:m=(0,i.readUint16)(e,a);var g={};g.Xsiz=(0,i.readUint32)(e,a+4);g.Ysiz=(0,i.readUint32)(e,a+8);g.XOsiz=(0,i.readUint32)(e,a+12);g.YOsiz=(0,i.readUint32)(e,a+16);g.XTsiz=(0,i.readUint32)(e,a+20);g.YTsiz=(0,i.readUint32)(e,a+24);g.XTOsiz=(0,i.readUint32)(e,a+28);g.YTOsiz=(0,i.readUint32)(e,a+32);var b=(0,i.readUint16)(e,a+36);g.Csiz=b;var x=[];l=a+38;for(var y=0;y<b;y++){var v={precision:1+(127&e[l]),isSigned:!!(128&e[l]),XRsiz:e[l+1],YRsiz:e[l+2]};l+=3;calculateComponentDimensions(v,g);x.push(v)}o.SIZ=g;o.components=x;calculateTileGrids(o,x);o.QCC=[];o.COC=[];break;case 65372:m=(0,i.readUint16)(e,a);var w={};l=a+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)}w.noQuantization=8===h;w.scalarExpounded=u;w.guardBits=d>>5;f=[];for(;l<m+a;){var T={};if(8===h){T.epsilon=e[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<m+a;){T={};if(8===h){T.epsilon=e[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<m+a;){var E=e[l++];_.push({PPx:15&E,PPy:E>>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<s;o++){var a,c=e.tiles[o],l=[];for(a=0;a<n;a++)l[a]=transformTile(e,c,a);var d,f,h,u,p,m,g,b=l[0],x=new Uint8ClampedArray(b.items.length*n),y={left:b.left,top:b.top,width:b.width,height:b.height,items:x},v=0;if(c.codingStyleDefaultParameters.multipleComponentTransform){var w=4===n,T=l[0].items,C=l[1].items,I=l[2].items,P=w?l[3].items:null;d=r[0].precision-8;f=.5+(128<<d);var k=c.components[0],S=n-3;u=T.length;if(k.codingStyleParameters.reversibleTransformation)for(h=0;h<u;h++,v+=S){p=T[h]+f;m=C[h];g=I[h];const e=p-(g+m>>2);x[v++]=e+g>>d;x[v++]=e>>d;x[v++]=e+m>>d}else for(h=0;h<u;h++,v+=S){p=T[h]+f;m=C[h];g=I[h];x[v++]=p+1.402*g>>d;x[v++]=p-.34413*m-.71414*g>>d;x[v++]=p+1.772*m>>d}if(w)for(h=0,v=3;h<u;h++,v+=4)x[v]=P[h]+f>>d}else for(a=0;a<n;a++){var _=l[a].items;d=r[a].precision-8;f=.5+(128<<d);for(v=a,h=0,u=_.length;h<u;h++){x[v]=_[h]+f>>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;a<s;a++)for(var c=0;c<o;c++){(r={}).tx0=Math.max(n.XTOsiz+c*n.XTsiz,n.XOsiz);r.ty0=Math.max(n.YTOsiz+a*n.YTsiz,n.YOsiz);r.tx1=Math.min(n.XTOsiz+(c+1)*n.XTsiz,n.Xsiz);r.ty1=Math.min(n.YTOsiz+(a+1)*n.YTsiz,n.Ysiz);r.width=r.tx1-r.tx0;r.height=r.ty1-r.ty0;r.components=[];i.push(r)}e.tiles=i;for(var l=0,d=n.Csiz;l<d;l++)for(var f=t[l],h=0,u=i.length;h<u;h++){var p={};r=i[h];p.tcx0=Math.ceil(r.tx0/f.XRsiz);p.tcy0=Math.ceil(r.ty0/f.YRsiz);p.tcx1=Math.ceil(r.tx1/f.XRsiz);p.tcy1=Math.ceil(r.ty1/f.YRsiz);p.width=p.tcx1-p.tcx0;p.height=p.tcy1-p.tcy0;r.components[l]=p}}function getBlocksDimensions(e,t,r){var n=t.codingStyleParameters,i={};if(n.entropyCoderWithCustomPrecincts){i.PPx=n.precinctsSizes[r].PPx;i.PPy=n.precinctsSizes[r].PPy}else{i.PPx=15;i.PPy=15}i.xcb_=r>0?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<<r.PPx,i=1<<r.PPy,o=0===t.resLevel,s=1<<r.PPx+(o?0:-1),a=1<<r.PPy+(o?0:-1),c=t.trx1>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,d=1<<c,f=t.tbx0>>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;i<p;i++)for(n=f;n<u;n++){(o={cbx:n,cby:i,tbx0:l*n,tby0:d*i,tbx1:l*(n+1),tby1:d*(i+1)}).tbx0_=Math.max(t.tbx0,o.tbx0);o.tby0_=Math.max(t.tby0,o.tby0);o.tbx1_=Math.min(t.tbx1,o.tbx1);o.tby1_=Math.min(t.tby1,o.tby1);s=Math.floor((o.tbx0_-t.tbx0)/m.precinctWidthInSubband)+Math.floor((o.tby0_-t.tby0)/m.precinctHeightInSubband)*m.numprecinctswide;o.precinctNumber=s;o.subbandType=t.type;o.Lblock=3;if(!(o.tbx1_<=o.tbx0_||o.tby1_<=o.tby0_)){g.push(o);var x=b[s];if(void 0!==x){n<x.cbxMin?x.cbxMin=n:n>x.cbxMax&&(x.cbxMax=n);i<x.cbyMin?x.cbxMin=i:i>x.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;o<s;o++)for(var a=i[o].codeblocks,c=0,l=a.length;c<l;c++){var d=a[c];d.precinctNumber===t&&n.push(d)}return{layerNumber:r,codeblocks:n}}function LayerResolutionComponentPositionIterator(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=0,a=0;a<o;a++)s=Math.max(s,n.components[a].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,d=0,f=0;this.nextPacket=function JpxImage_nextPacket(){for(;c<i;c++){for(;l<=s;l++){for(;d<o;d++){var e=n.components[d];if(!(l>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;f<r;){var a=createPacket(t,f,c);f++;return a}f=0}}d=0}l=0}throw new JpxError("Out of packets")}}function ResolutionLayerComponentPositionIterator(e){for(var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=0,a=0;a<o;a++)s=Math.max(s,n.components[a].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,d=0,f=0;this.nextPacket=function JpxImage_nextPacket(){for(;c<=s;c++){for(;l<i;l++){for(;d<o;d++){var e=n.components[d];if(!(c>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;f<r;){var a=createPacket(t,f,l);f++;return a}f=0}}d=0}l=0}throw new JpxError("Out of packets")}}function ResolutionPositionComponentLayerIterator(e){var t,r,n,i,o=e.SIZ,s=e.currentTile.index,a=e.tiles[s],c=a.codingStyleDefaultParameters.layersCount,l=o.Csiz,d=0;for(n=0;n<l;n++){const e=a.components[n];d=Math.max(d,e.codingStyleParameters.decompositionLevelsCount)}var f=new Int32Array(d+1);for(r=0;r<=d;++r){var h=0;for(n=0;n<l;++n){var u=a.components[n].resolutions;r<u.length&&(h=Math.max(h,u[r].precinctParameters.numprecincts))}f[r]=h}t=0;r=0;n=0;i=0;this.nextPacket=function JpxImage_nextPacket(){for(;r<=d;r++){for(;i<f[r];i++){for(;n<l;n++){const l=a.components[n];if(!(r>l.codingStyleParameters.decompositionLevelsCount)){var e=l.resolutions[r],o=e.precinctParameters.numprecincts;if(!(i>=o)){for(;t<c;){var s=createPacket(e,i,t);t++;return s}t=0}}}n=0}i=0}throw new JpxError("Out of packets")}}function PositionComponentResolutionLayerIterator(e){var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=getPrecinctSizesInImageScale(n),a=s,c=0,l=0,d=0,f=0,h=0;this.nextPacket=function JpxImage_nextPacket(){for(;h<a.maxNumHigh;h++){for(;f<a.maxNumWide;f++){for(;d<o;d++){for(var e=n.components[d],t=e.codingStyleParameters.decompositionLevelsCount;l<=t;l++){var r=e.resolutions[l],u=s.components[d].resolutions[l],p=getPrecinctIndexIfExist(f,h,u,a,r);if(null!==p){for(;c<i;){var m=createPacket(r,p,c);c++;return m}c=0}}l=0}d=0}f=0}throw new JpxError("Out of packets")}}function ComponentPositionResolutionLayerIterator(e){var t=e.SIZ,r=e.currentTile.index,n=e.tiles[r],i=n.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=getPrecinctSizesInImageScale(n),a=0,c=0,l=0,d=0,f=0;this.nextPacket=function JpxImage_nextPacket(){for(;l<o;++l){for(var e=n.components[l],t=s.components[l],r=e.codingStyleParameters.decompositionLevelsCount;f<t.maxNumHigh;f++){for(;d<t.maxNumWide;d++){for(;c<=r;c++){var h=e.resolutions[c],u=t.resolutions[c],p=getPrecinctIndexIfExist(d,f,u,t,h);if(null!==p){for(;a<i;){var m=createPacket(h,p,a);a++;return m}a=0}}c=0}d=0}f=0}throw new JpxError("Out of packets")}}function getPrecinctIndexIfExist(e,t,r,n,i){var o=e*n.minWidth,s=t*n.minHeight;if(o%r.width!=0||s%r.height!=0)return null;var a=s/r.width*i.precinctParameters.numprecinctswide;return o/r.height+a}function getPrecinctSizesInImageScale(e){for(var t=e.components.length,r=Number.MAX_VALUE,n=Number.MAX_VALUE,i=0,o=0,s=new Array(t),a=0;a<t;a++){for(var c=e.components[a],l=c.codingStyleParameters.decompositionLevelsCount,d=new Array(l+1),f=Number.MAX_VALUE,h=Number.MAX_VALUE,u=0,p=0,m=1,g=l;g>=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<i;o++){for(var s=n.components[o],a=s.codingStyleParameters.decompositionLevelsCount,c=[],l=[],d=0;d<=a;d++){var f,h=getBlocksDimensions(0,s,d),u={},p=1<<a-d;u.trx0=Math.ceil(s.tcx0/p);u.try0=Math.ceil(s.tcy0/p);u.trx1=Math.ceil(s.tcx1/p);u.try1=Math.ceil(s.tcy1/p);u.resLevel=d;buildPrecincts(0,u,h);c.push(u);if(0===d){(f={}).type="LL";f.tbx0=Math.ceil(s.tcx0/p);f.tby0=Math.ceil(s.tcy0/p);f.tbx1=Math.ceil(s.tcx1/p);f.tby1=Math.ceil(s.tcy1/p);f.resolution=u;buildCodeblocks(0,f,h);l.push(f);u.subbands=[f]}else{var m=1<<a-d+1,g=[];(f={}).type="HL";f.tbx0=Math.ceil(s.tcx0/m-.5);f.tby0=Math.ceil(s.tcy0/m);f.tbx1=Math.ceil(s.tcx1/m-.5);f.tby1=Math.ceil(s.tcy1/m);f.resolution=u;buildCodeblocks(0,f,h);l.push(f);g.push(f);(f={}).type="LH";f.tbx0=Math.ceil(s.tcx0/m);f.tby0=Math.ceil(s.tcy0/m-.5);f.tbx1=Math.ceil(s.tcx1/m);f.tby1=Math.ceil(s.tcy1/m-.5);f.resolution=u;buildCodeblocks(0,f,h);l.push(f);g.push(f);(f={}).type="HH";f.tbx0=Math.ceil(s.tcx0/m-.5);f.tby0=Math.ceil(s.tcy0/m-.5);f.tbx1=Math.ceil(s.tcx1/m-.5);f.tby1=Math.ceil(s.tcy1/m-.5);f.resolution=u;buildCodeblocks(0,f,h);l.push(f);g.push(f);u.subbands=g}}s.resolutions=c;s.subbands=l}var b=n.codingStyleDefaultParameters.progressionOrder;switch(b){case 0:n.packetsIterator=new LayerResolutionComponentPositionIterator(e);break;case 1:n.packetsIterator=new ResolutionLayerComponentPositionIterator(e);break;case 2:n.packetsIterator=new ResolutionPositionComponentLayerIterator(e);break;case 3:n.packetsIterator=new PositionComponentResolutionLayerIterator(e);break;case 4:n.packetsIterator=new ComponentPositionResolutionLayerIterator(e);break;default:throw new JpxError("Unsupported progression order "+b)}}function parseTilePackets(e,n,o,s){var a,c=0,l=0,d=!1;function readBits(e){for(;l<e;){var t=n[o+c];c++;if(d){a=a<<7|t;l+=7;d=!1}else{a=a<<8|t;l+=8}255===t&&(d=!0)}return a>>>(l-=e)&(1<<e)-1}function skipMarkerIfEqual(e){if(255===n[o+c-1]&&n[o+c]===e){skipBytes(1);return!0}if(255===n[o+c]&&n[o+c+1]===e){skipBytes(2);return!0}return!1}function skipBytes(e){c+=e}function alignToByte(){l=0;if(d){c++;d=!1}}function readCodingpasses(){if(0===readBits(1))return 1;if(0===readBits(1))return 2;var e=readBits(2);return e<3?e+3:(e=readBits(5))<31?e+6:(e=readBits(7))+37}for(var f=e.currentTile.index,h=e.tiles[f],u=e.COD.sopMarkerUsed,p=e.COD.ephMarkerUsed,m=h.packetsIterator;c<s;){alignToByte();u&&skipMarkerIfEqual(145)&&skipBytes(4);var g=m.nextPacket();if(readBits(1)){for(var b,x=g.layerNumber,y=[],v=0,w=g.codeblocks.length;v<w;v++){var T=(b=g.codeblocks[v]).precinct,C=b.cbx-T.cbxMin,I=b.cby-T.cbyMin,P=!1,k=!1;if(void 0!==b.included)P=!!readBits(1);else{var S,_;if(void 0!==(T=b.precinct).inclusionTree)S=T.inclusionTree;else{var E=T.cbxMax-T.cbxMin+1,B=T.cbyMax-T.cbyMin+1;S=new r(E,B,x);_=new t(E,B);T.inclusionTree=S;T.zeroBitPlanesTree=_}if(S.reset(C,I,x))for(;;){if(!readBits(1)){S.incrementValue(x);break}if(!S.nextLevel()){b.included=!0;P=k=!0;break}}}if(P){if(k){(_=T.zeroBitPlanesTree).reset(C,I);for(;;)if(readBits(1)){if(!_.nextLevel())break}else _.incrementValue();b.zeroBitPlanes=_.value}for(var L=readCodingpasses();readBits(1);)b.Lblock++;var D=(0,i.log2)(L),M=readBits((L<1<<D?D-1:D)+b.Lblock);y.push({codeblock:b,codingpasses:L,dataLength:M})}}alignToByte();p&&skipMarkerIfEqual(146);for(;y.length>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<b;++g){var x=u[g],y=x.tbx1_-x.tbx0_,v=x.tby1_-x.tby0_;if(0!==y&&0!==v&&void 0!==x.data){var w,T;w=new s(y,v,x.subbandType,x.zeroBitPlanes,a);T=2;var C,I,P,k=x.data,S=0,_=0;for(C=0,I=k.length;C<I;C++){S+=(P=k[C]).end-P.start;_+=P.codingpasses}var E=new Uint8Array(S),B=0;for(C=0,I=k.length;C<I;C++){var L=(P=k[C]).data.subarray(P.start,P.end);E.set(L,B);B+=L.length}var D=new o.ArithmeticDecoder(E,0,S);w.setDecoder(D);for(C=0;C<_;C++){switch(T){case 0:w.runSignificancePropagationPass();break;case 1:w.runMagnitudeRefinementPass();break;case 2:w.runCleanupPass();l&&w.checkSegmentationSymbol()}T=(T+1)%3}var M,O,A,R=x.tbx0_-d+(x.tby0_-f)*h,U=w.coefficentsSign,F=w.coefficentsMagnitude,N=w.bitsDecoded,H=c?0:.5;B=0;var J="LL"!==n.type;for(C=0;C<v;C++){var z=2*(R/h|0)*(t-h)+p+m;for(M=0;M<y;M++){if(0!==(O=F[B])){O=(O+H)*i;0!==U[B]&&(O=-O);A=N[B];var X=J?z+(R<<1):R;e[X]=c&&A>=a?O:O*(1<<a-A)}R++;B++}R+=h-y}}}}function transformTile(t,r,n){for(var i=r.components[n],o=i.codingStyleParameters,s=i.quantizationParameters,a=o.decompositionLevelsCount,d=s.SPqcds,f=s.scalarExpounded,h=s.guardBits,u=o.segmentationSymbolUsed,p=t.components[n].precision,m=o.reversibleTransformation,g=m?new l:new c,b=[],x=0,y=0;y<=a;y++){for(var v=i.resolutions[y],w=v.trx1-v.trx0,T=v.try1-v.try0,C=new Float32Array(w*T),I=0,P=v.subbands.length;I<P;I++){var k,S;if(f){k=d[x].mu;S=d[x].epsilon;x++}else{k=d[0].mu;S=d[0].epsilon+(y>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<r;i++){var o=n.components[i],s=void 0!==e.currentTile.QCC[i]?e.currentTile.QCC[i]:e.currentTile.QCD;o.quantizationParameters=s;var a=void 0!==e.currentTile.COC[i]?e.currentTile.COC[i]:e.currentTile.COD;o.codingStyleParameters=a}n.codingStyleDefaultParameters=e.currentTile.COD}var t=function TagTreeClosure(){function TagTree(e,t){var r=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var n=0;n<r;n++){var o={width:e,height:t,items:[]};this.levels.push(o);e=Math.ceil(e/2);t=Math.ceil(t/2)}}TagTree.prototype={reset:function TagTree_reset(e,t){for(var r,n=0,i=0;n<this.levels.length;){var o=e+t*(r=this.levels[n]).width;if(void 0!==r.items[o]){i=r.items[o];break}r.index=o;e>>=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;o<n;o++){for(var s=new Uint8Array(e*t),a=0,c=s.length;a<c;a++)s[a]=r;var l={width:e,height:t,items:s};this.levels.push(l);e=Math.ceil(e/2);t=Math.ceil(t/2)}}InclusionTree.prototype={reset:function InclusionTree_reset(e,t,r){for(var n=0;n<this.levels.length;){var i=this.levels[n],o=e+t*i.width;i.index=o;var s=i.items[o];if(255===s)break;if(s>r){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;h<l;h++)f[h]=s;this.bitsDecoded=f;this.reset()}BitModel.prototype={setDecoder:function BitModel_setDecoder(e){this.decoder=e},reset:function BitModel_reset(){this.contexts=new Int8Array(19);this.contexts[0]=8;this.contexts[17]=92;this.contexts[18]=6},setNeighborsSignificance:function BitModel_setNeighborsSignificance(e,t,r){var n,i=this.neighborsSignificance,o=this.width,s=this.height,a=t>0,c=t+1<o;if(e>0){n=r-o;a&&(i[n-1]+=16);c&&(i[n+1]+=16);i[n]+=4}if(e+1<s){n=r+o;a&&(i[n-1]+=16);c&&(i[n+1]+=16);i[n]+=4}a&&(i[r-1]+=1);c&&(i[r+1]+=1);i[r]|=128},runSignificancePropagationPass:function BitModel_runSignificancePropagationPass(){for(var e=this.decoder,t=this.width,r=this.height,n=this.coefficentsMagnitude,i=this.coefficentsSign,o=this.neighborsSignificance,s=this.processingFlags,a=this.contexts,c=this.contextLabelTable,l=this.bitsDecoded,d=0;d<r;d+=4)for(var f=0;f<t;f++)for(var h=d*t+f,u=0;u<4;u++,h+=t){var p=d+u;if(p>=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+1<l&&0!==f[r+1]){o=h[r+1];n=s?1-o-(i=h[r-1]):1-o-o}else n=s?1-(i=h[r-1])-i:0;var u=3*n;s=e>0&&0!==f[r-l];if(e+1<d&&0!==f[r+l]){o=h[r+l];n=s?1-o-(i=h[r-l])+u:1-o-o+u}else n=s?1-(i=h[r-l])-i+u:u;if(n>=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<l;f=e){e=Math.min(l,f+d);for(var h=0;h<r;h++)for(var u=f+h;u<e;u+=r)if(i[u]&&0==(1&c[u])){var p=16;if(0!=(2&c[u])){c[u]^=2;p=0===(127&o[u])?15:14}var m=t.readBit(s,p);i[u]=i[u]<<1|m;a[u]++;c[u]|=1}}},runCleanupPass:function BitModel_runCleanupPass(){for(var e,t=this.decoder,r=this.width,n=this.height,i=this.neighborsSignificance,o=this.coefficentsMagnitude,s=this.coefficentsSign,a=this.contexts,c=this.contextLabelTable,l=this.bitsDecoded,d=this.processingFlags,f=r,h=2*r,u=3*r,p=0;p<n;p=e){e=Math.min(p+4,n);for(var m=p*r,g=p+3<n,b=0;b<r;b++){var x,y=m+b,v=0,w=y,T=p;if(g&&0===d[y]&&0===d[y+f]&&0===d[y+h]&&0===d[y+u]&&0===i[y]&&0===i[y+f]&&0===i[y+h]&&0===i[y+u]){if(!t.readBit(a,18)){l[y]++;l[y+f]++;l[y+h]++;l[y+u]++;continue}if(0!==(v=t.readBit(a,17)<<1|t.readBit(a,17))){T=p+v;w+=v*r}x=this.decodeSignBit(T,b,w);s[w]=x;o[w]=1;this.setNeighborsSignificance(T,b,w);d[w]|=2;w=y;for(var C=p;C<=T;C++,w+=r)l[w]++;v++}for(T=p+v;T<e;T++,w+=r)if(!o[w]&&0==(1&d[w])){var I=c[i[w]];if(1===t.readBit(a,I)){x=this.decodeSignBit(T,b,w);s[w]=x;o[w]=1;this.setNeighborsSignificance(T,b,w);d[w]|=2}l[w]++}}}},checkSegmentationSymbol:function BitModel_checkSegmentationSymbol(){var e=this.decoder,t=this.contexts;if(10!==(e.readBit(t,17)<<3|e.readBit(t,17)<<2|e.readBit(t,17)<<1|e.readBit(t,17)))throw new JpxError("Invalid segmentation symbol")}};return BitModel}(),a=function TransformClosure(){function Transform(){}Transform.prototype.calculate=function transformCalculate(e,t,r){for(var n=e[0],i=1,o=e.length;i<o;i++)n=this.iterate(n,e[i],t,r);return n};Transform.prototype.extend=function extend(e,t,r){var n=t-1,i=t+1,o=t+r-2,s=t+r;e[n--]=e[i++];e[s++]=e[o--];e[n--]=e[i++];e[s++]=e[o--];e[n--]=e[i++];e[s++]=e[o--];e[n]=e[i];e[s]=e[o]};Transform.prototype.iterate=function Transform_iterate(e,t,r,n){var i,o,s,a,c,l,d=e.width,f=e.height,h=e.items,u=t.width,p=t.height,m=t.items;for(s=0,i=0;i<f;i++){a=2*i*u;for(o=0;o<d;o++,s++,a+=2)m[a]=h[s]}h=e.items=null;var g=new Float32Array(u+8);if(1===u){if(0!=(1&r))for(l=0,s=0;l<p;l++,s+=u)m[s]*=.5}else for(l=0,s=0;l<p;l++,s+=u){g.set(m.subarray(s,s+u),4);this.extend(g,4,u);this.filter(g,4,u);m.set(g.subarray(4,4+u),s)}var b=16,x=[];for(i=0;i<b;i++)x.push(new Float32Array(p+8));var y,v=0;e=4+p;if(1===p){if(0!=(1&n))for(c=0;c<u;c++)m[c]*=.5}else for(c=0;c<u;c++){if(0===v){b=Math.min(u-c,b);for(s=c,a=4;a<e;s+=u,a++)for(y=0;y<b;y++)x[y][a]=m[s+y];v=b}var w=x[--v];this.extend(w,4,p);this.filter(w,4,p);if(0===v){s=c-b+1;for(a=4;a<e;s+=u,a++)for(y=0;y<b;y++)m[s+y]=x[y][a]}}return{width:u,height:p,items:m}};return Transform}(),c=function IrreversibleTransformClosure(){function IrreversibleTransform(){a.call(this)}IrreversibleTransform.prototype=Object.create(a.prototype);IrreversibleTransform.prototype.filter=function irreversibleTransformFilter(e,t,r){var n,i,o,s,a=r>>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}])}));