2
0

pdf.image_decoders.min.js 108 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(()=>{"use strict";var e=[(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"getVerbosityLevel",{enumerable:!0,get:function(){return r.getVerbosityLevel}});Object.defineProperty(t,"setVerbosityLevel",{enumerable:!0,get:function(){return r.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 r=n(1),i=n(4),o=n(9),s=n(10)},(e,t,n)=>{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 n=0;for(let r=0;r<t;r++)n+=arrayByteLength(e[r]);let r=0;const i=new Uint8Array(n);for(let n=0;n<t;n++){let t=e[n];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const o=t.byteLength;i.set(t,r);r+=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,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const r=[];for(let i=0;i<t;i+=n){const o=Math.min(i+n,t),s=e.subarray(i,o);r.push(String.fromCharCode.apply(null,s))}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(n,r){e.resolve=function(e){t=!0;n(e)};e.reject=function(e){t=!0;r(e)}}));return e};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const n=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}}(n))return n}catch(e){}return null};t.encodeToXmlString=function encodeToXmlString(e){const t=[];let n=0;for(let r=0,i=e.length;r<i;r++){const i=e.codePointAt(r);if(32<=i&&i<=126){const o=d[i];if(o){n<r&&t.push(e.substring(n,r));t.push(o);n=r+1}}else{n<r&&t.push(e.substring(n,r));t.push(`&#x${i.toString(16).toUpperCase()};`);i>55295&&(i<57344||i>65533)&&r++;n=r+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")};t.escapeString=function escapeString(e){return e.replace(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))};t.getModificationDate=function getModificationDate(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().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>=r.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,n){return e===t[n]}))};t.isAscii=function isAscii(e){return/^[\x00-\x7F]*$/.test(e)};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let n;try{n=new URL(e);if(!n.origin||"null"===n.origin)return!1}catch(e){return!1}const r=new URL(t,n);return n.origin===r.origin};t.isString=function isString(e){return"string"==typeof e};t.objectFromEntries=function objectFromEntries(e){return Object.assign(Object.create(null),Object.fromEntries(e))};t.objectSize=function objectSize(e){return Object.keys(e).length};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,n=[];if("þ"===e[0]&&"ÿ"===e[1])for(let r=2;r<t;r+=2)n.push(String.fromCharCode(e.charCodeAt(r)<<8|e.charCodeAt(r+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let r=2;r<t;r+=2)n.push(String.fromCharCode(e.charCodeAt(r+1)<<8|e.charCodeAt(r)));else for(let r=0;r<t;++r){const t=f[e.charCodeAt(r)];n.push(t?String.fromCharCode(t):e.charAt(r))}return n.join("")};t.stringToUTF16BEString=function stringToUTF16BEString(e){const t=["þÿ"];for(let n=0,r=e.length;n<r;n++){const r=e.charCodeAt(n);t.push(String.fromCharCode(r>>8&255));t.push(String.fromCharCode(255&r))}return t.join("")};t.stringToUTF8String=function stringToUTF8String(e){return decodeURIComponent(escape(e))};t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;t.VerbosityLevel=t.Util=t.UNSUPPORTED_FEATURES=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.StreamType=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.IsLittleEndianCached=t.IsEvalSupportedCached=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.createObjectURL=t.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0;n(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.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};t.PageActionEventType={O:"PageOpen",C:"PageClose"};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 r={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=r;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=r.WARNINGS;function warn(e){i>=r.WARNINGS&&console.log(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1});return n}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,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=255&e.charCodeAt(r);return n}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=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,n){return`#${l[e]}${l[t]}${l[n]}`}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 n=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])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=Util.applyTransform(e,t),r=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(n[0],r[0],i[0],o[0]),Math.min(n[1],r[1],i[1],o[1]),Math.max(n[0],r[0],i[0],o[0]),Math.max(n[1],r[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]],n=e[0]*t[0]+e[1]*t[2],r=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=(n+o)/2,a=Math.sqrt((n+o)*(n+o)-4*(n*o-i*r))/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 n=[e[0],e[2],t[0],t[2]].sort(compare),r=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(n[0]===e[0]&&n[1]===t[0]||n[0]===t[0]&&n[1]===e[0]))return null;i[0]=n[1];i[2]=n[2];if(!(r[0]===e[1]&&r[1]===t[1]||r[0]===t[1]&&r[1]===e[1]))return null;i[1]=r[1];i[3]=r[2];return i}}t.Util=Util;const f=[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 h=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,n,r=!1){if(!r&&URL.createObjectURL){const e=new Blob([t],{type:n});return URL.createObjectURL(e)}let i=`data:${n};base64,`;for(let n=0,r=t.length;n<r;n+=3){const o=255&t[n],s=255&t[n+1],a=255&t[n+2];i+=e[o>>2]+e[(3&o)<<4|s>>4]+e[n+1<r?(15&s)<<2|a>>6:64]+e[n+2<r?63&a:64]}return i}}();t.createObjectURL=h;const d={60:"&lt;",62:"&gt;",38:"&amp;",34:"&quot;",39:"&apos;"}},(e,t,n)=>{n(3)},(e,t)=>{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},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Image=void 0;var r=n(1),i=n(5),o=n(7),s=n(8);class Jbig2Error extends r.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,n){this.data=e;this.start=t;this.end=n}DecodingContext.prototype={get decoder(){var e=new o.ArithmeticDecoder(this.data,this.start,this.end);return(0,r.shadow)(this,"decoder",e)},get contextCache(){var e=new ContextCache;return(0,r.shadow)(this,"contextCache",e)}};function decodeInteger(e,t,n){var r=e.getContexts(t),i=1;function readBits(e){for(var t=0,o=0;o<e;o++){var s=n.readBit(r,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,n){for(var r=e.getContexts("IAID"),i=1,o=0;o<n;o++){i=i<<1|t.readBit(r,i)}return n<31?i&(1<<n)-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}]],n=[{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,n,r,i,o,s,c,l){if(e){return decodeMMRBitmap(new Reader(l.data,l.start,l.end),n,r,!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,n){var r,i,o,s,a,c,l,f=n.decoder,h=n.contextCache.getContexts("GB"),d=[];for(i=0;i<t;i++){a=d[i]=new Uint8Array(e);c=i<1?a:d[i-1];r=(l=i<2?a:d[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=f.readBit(h,r);r=(31735&r)<<1|(o+3<e?l[o+3]<<11:0)|(o+4<e?c[o+4]<<4:0)|s}}return d}(n,r,l);var f=!!s,h=t[i].concat(c);h.sort((function(e,t){return e.y-t.y||e.x-t.x}));var d,u,p=h.length,m=new Int8Array(p),g=new Int8Array(p),b=[],y=0,v=0,x=0,w=0;for(u=0;u<p;u++){m[u]=h[u].x;g[u]=h[u].y;v=Math.min(v,h[u].x);x=Math.max(x,h[u].x);w=Math.min(w,h[u].y);u<p-1&&h[u].y===h[u+1].y&&h[u].x===h[u+1].x-1?y|=1<<p-1-u:b.push(u)}var C=b.length,T=new Int8Array(C),I=new Int8Array(C),S=new Uint16Array(C);for(d=0;d<C;d++){u=b[d];T[d]=h[u].x;I[d]=h[u].y;S[d]=1<<p-1-u}for(var P,k,E,B,D,_=-v,A=-w,L=n-x,R=a[i],O=new Uint8Array(n),M=[],U=l.decoder,F=l.contextCache.getContexts("GB"),N=0,H=0,J=0;J<r;J++){if(o){if(N^=U.readBit(F,R)){M.push(O);continue}}O=new Uint8Array(O);M.push(O);for(P=0;P<n;P++)if(f&&s[J][P])O[P]=0;else{if(P>=_&&P<L&&J>=A){H=H<<1&y;for(u=0;u<C;u++){k=J+I[u];E=P+T[u];(B=M[k][E])&&(H|=B=S[u])}}else{H=0;D=p-1;for(u=0;u<p;u++,D--)(E=P+m[u])>=0&&E<n&&(k=J+g[u])>=0&&(B=M[k][E])&&(H|=B<<D)}var z=U.readBit(F,H);O[P]=z}}return M}function decodeRefinement(e,t,r,i,o,s,a,l,f){var h=n[r].coding;0===r&&(h=h.concat([l[0]]));var d,u=h.length,p=new Int32Array(u),m=new Int32Array(u);for(d=0;d<u;d++){p[d]=h[d].x;m[d]=h[d].y}var g=n[r].reference;0===r&&(g=g.concat([l[1]]));var b=g.length,y=new Int32Array(b),v=new Int32Array(b);for(d=0;d<b;d++){y[d]=g[d].x;v[d]=g[d].y}for(var x=i[0].length,w=i.length,C=c[r],T=[],I=f.decoder,S=f.contextCache.getContexts("GR"),P=0,k=0;k<t;k++){if(a){if(P^=I.readBit(S,C))throw new Jbig2Error("prediction is not supported")}var E=new Uint8Array(e);T.push(E);for(var B=0;B<e;B++){var D,_,A=0;for(d=0;d<u;d++){D=k+m[d];_=B+p[d];D<0||_<0||_>=e?A<<=1:A=A<<1|T[D][_]}for(d=0;d<b;d++){D=k+v[d]-s;_=B+y[d]-o;D<0||D>=w||_<0||_>=x?A<<=1:A=A<<1|i[D][_]}var L=I.readBit(S,A);E[B]=L}}return T}function decodeTextRegion(e,t,n,r,i,o,s,a,c,l,f,h,d,u,p,m,g,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var v,x,w=[];for(v=0;v<r;v++){x=new Uint8Array(n);if(i)for(var C=0;C<n;C++)x[C]=i;w.push(x)}var T=g.decoder,I=g.contextCache,S=e?-u.tableDeltaT.decode(y):-decodeInteger(I,"IADT",T),P=0;v=0;for(;v<o;){S+=e?u.tableDeltaT.decode(y):decodeInteger(I,"IADT",T);for(var k=P+=e?u.tableFirstS.decode(y):decodeInteger(I,"IAFS",T);;){let r=0;s>1&&(r=e?y.readBits(b):decodeInteger(I,"IAIT",T));var E=s*S+r,B=e?u.symbolIDTable.decode(y):decodeIAID(I,T,c),D=t&&(e?y.readBit():decodeInteger(I,"IARI",T)),_=a[B],A=_[0].length,L=_.length;if(D){var R=decodeInteger(I,"IARDW",T),O=decodeInteger(I,"IARDH",T);_=decodeRefinement(A+=R,L+=O,p,_,(R>>1)+decodeInteger(I,"IARDX",T),(O>>1)+decodeInteger(I,"IARDY",T),!1,m,g)}var M,U,F,N=E-(1&h?0:L-1),H=k-(2&h?A-1:0);if(l){for(M=0;M<L;M++)if(x=w[H+M]){F=_[M];var J=Math.min(n-N,A);switch(d){case 0:for(U=0;U<J;U++)x[N+U]|=F[U];break;case 2:for(U=0;U<J;U++)x[N+U]^=F[U];break;default:throw new Jbig2Error(`operator ${d} is not supported`)}}k+=L-1}else{for(U=0;U<L;U++)if(x=w[N+U]){F=_[U];switch(d){case 0:for(M=0;M<A;M++)x[H+M]|=F[M];break;case 2:for(M=0;M<A;M++)x[H+M]^=F[M];break;default:throw new Jbig2Error(`operator ${d} is not supported`)}}k+=A-1}v++;var z=e?u.tableDeltaS.decode(y):decodeInteger(I,"IADS",T);if(null===z)break;k+=z+f}}return w}function readSegmentHeader(t,n){var r={};r.number=(0,i.readUint32)(t,n);var o=t[n+4],s=63&o;if(!e[s])throw new Jbig2Error("invalid segment type: "+s);r.type=s;r.typeName=e[s];r.deferredNonRetain=!!(128&o);var a=!!(64&o),c=t[n+5],f=c>>5&7,h=[31&c],d=n+6;if(7===c){f=536870911&(0,i.readUint32)(t,d-1);d+=3;var u=f+7>>3;h[0]=t[d++];for(;--u>0;)h.push(t[d++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");r.retainBits=h;let p=4;r.number<=256?p=1:r.number<=65536&&(p=2);var m,g,b=[];for(m=0;m<f;m++){let e;e=1===p?t[d]:2===p?(0,i.readUint16)(t,d):(0,i.readUint32)(t,d);b.push(e);d+=p}r.referredTo=b;if(a){r.pageAssociation=(0,i.readUint32)(t,d);d+=4}else r.pageAssociation=t[d++];r.length=(0,i.readUint32)(t,d);d+=4;if(4294967295===r.length){if(38!==s)throw new Jbig2Error("invalid unknown segment length");var y=readRegionSegmentInformation(t,d),v=!!(1&t[d+l]),x=new Uint8Array(6);if(!v){x[0]=255;x[1]=172}x[2]=y.height>>>24&255;x[3]=y.height>>16&255;x[4]=y.height>>8&255;x[5]=255&y.height;for(m=d,g=t.length;m<g;m++){for(var w=0;w<6&&x[w]===t[m+w];)w++;if(6===w){r.length=m+6;break}}if(4294967295===r.length)throw new Jbig2Error("segment end was not found")}r.headerEnd=d;return r}function readSegments(e,t,n,r){for(var i=[],o=n;o<r;){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 n,r,o,s,a=e.header,c=e.data,f=e.start,h=e.end;switch(a.type){case 0:var d={},u=(0,i.readUint16)(c,f);d.huffman=!!(1&u);d.refinement=!!(2&u);d.huffmanDHSelector=u>>2&3;d.huffmanDWSelector=u>>4&3;d.bitmapSizeSelector=u>>6&1;d.aggregationInstancesSelector=u>>7&1;d.bitmapCodingContextUsed=!!(256&u);d.bitmapCodingContextRetained=!!(512&u);d.template=u>>10&3;d.refinementTemplate=u>>12&1;f+=2;if(!d.huffman){s=0===d.template?4:1;r=[];for(o=0;o<s;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}d.at=r}if(d.refinement&&!d.refinementTemplate){r=[];for(o=0;o<2;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}d.refinementAt=r}d.numberOfExportedSymbols=(0,i.readUint32)(c,f);f+=4;d.numberOfNewSymbols=(0,i.readUint32)(c,f);f+=4;n=[d,a.number,a.referredTo,c,f,h];break;case 6:case 7:var p={};p.info=readRegionSegmentInformation(c,f);f+=l;var m=(0,i.readUint16)(c,f);f+=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,f);f+=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){r=[];for(o=0;o<2;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}p.refinementAt=r}p.numberOfSymbolInstances=(0,i.readUint32)(c,f);f+=4;n=[p,a.referredTo,c,f,h];break;case 16:const e={},t=c[f++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[f++];e.patternHeight=c[f++];e.maxPatternIndex=(0,i.readUint32)(c,f);f+=4;n=[e,a.number,c,f,h];break;case 22:case 23:const w={};w.info=readRegionSegmentInformation(c,f);f+=l;const C=c[f++];w.mmr=!!(1&C);w.template=C>>1&3;w.enableSkip=!!(8&C);w.combinationOperator=C>>4&7;w.defaultPixelValue=C>>7&1;w.gridWidth=(0,i.readUint32)(c,f);f+=4;w.gridHeight=(0,i.readUint32)(c,f);f+=4;w.gridOffsetX=4294967295&(0,i.readUint32)(c,f);f+=4;w.gridOffsetY=4294967295&(0,i.readUint32)(c,f);f+=4;w.gridVectorX=(0,i.readUint16)(c,f);f+=2;w.gridVectorY=(0,i.readUint16)(c,f);f+=2;n=[w,a.referredTo,c,f,h];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,f);f+=l;var y=c[f++];b.mmr=!!(1&y);b.template=y>>1&3;b.prediction=!!(8&y);if(!b.mmr){s=0===b.template?4:1;r=[];for(o=0;o<s;o++){r.push({x:(0,i.readInt8)(c,f),y:(0,i.readInt8)(c,f+1)});f+=2}b.at=r}n=[b,c,f,h];break;case 48:var v={width:(0,i.readUint32)(c,f),height:(0,i.readUint32)(c,f+4),resolutionX:(0,i.readUint32)(c,f+8),resolutionY:(0,i.readUint32)(c,f+12)};4294967295===v.height&&delete v.height;var x=c[f+16];(0,i.readUint16)(c,f+17);v.lossless=!!(1&x);v.refinement=!!(2&x);v.defaultPixelValue=x>>2&1;v.combinationOperator=x>>3&3;v.requiresBuffer=!!(32&x);v.combinationOperatorOverride=!!(64&x);n=[v];break;case 49:case 50:case 51:break;case 53:n=[a.number,c,f,h];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,n)}function processSegments(e,t){for(var n=0,r=e.length;n<r;n++)processSegment(e[n],t)}function SimpleSegmentVisitor(){}SimpleSegmentVisitor.prototype={onPageInformation:function SimpleSegmentVisitor_onPageInformation(e){this.currentPageInfo=e;var t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var r=0,i=n.length;r<i;r++)n[r]=255;this.buffer=n},drawBitmap:function SimpleSegmentVisitor_drawBitmap(e,t){var n,r,i,o,s=this.currentPageInfo,a=e.width,c=e.height,l=s.width+7>>3,f=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,h=this.buffer,d=128>>(7&e.x),u=e.y*l+(e.x>>3);switch(f){case 0:for(n=0;n<c;n++){i=d;o=u;for(r=0;r<a;r++){t[n][r]&&(h[o]|=i);if(!(i>>=1)){i=128;o++}}u+=l}break;case 2:for(n=0;n<c;n++){i=d;o=u;for(r=0;r<a;r++){t[n][r]&&(h[o]^=i);if(!(i>>=1)){i=128;o++}}u+=l}break;default:throw new Jbig2Error(`operator ${f} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,n,r){var i=e.info,o=new DecodingContext(t,n,r),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,n,r,o,s){let a,c;if(e.huffman){a=function getSymbolDictionaryHuffmanTables(e,t,n){let r,i,o,s,a=0;switch(e.huffmanDHSelector){case 0:case 1:r=getStandardTable(e.huffmanDHSelector+4);break;case 3:r=getCustomHuffmanTable(a,t,n);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,n);a++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){o=getCustomHuffmanTable(a,t,n);a++}else o=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(a,t,n):getStandardTable(1);return{tableDeltaHeight:r,tableDeltaWidth:i,tableBitmapSize:o,tableAggregateInstances:s}}(e,n,this.customTables);c=new Reader(r,o,s)}var l=this.symbols;l||(this.symbols=l={});for(var f=[],h=0,d=n.length;h<d;h++){const e=l[n[h]];e&&(f=f.concat(e))}var u=new DecodingContext(r,o,s);l[t]=function decodeSymbolDictionary(e,t,n,r,o,s,a,c,l,f,h,d){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");var u=[],p=0,m=(0,i.log2)(n.length+r),g=h.decoder,b=h.contextCache;let y,v;if(e){y=getStandardTable(1);v=[];m=Math.max(m,1)}for(;u.length<r;){p+=e?s.tableDeltaHeight.decode(d):decodeInteger(b,"IADH",g);let r=0,i=0;const o=e?v.length:0;for(;;){var x,w=e?s.tableDeltaWidth.decode(d):decodeInteger(b,"IADW",g);if(null===w)break;r+=w;i+=r;if(t){var C=decodeInteger(b,"IAAI",g);if(C>1)x=decodeTextRegion(e,t,r,p,0,C,1,n.concat(u),m,0,0,1,0,s,l,f,h,0,d);else{var T=decodeIAID(b,g,m),I=decodeInteger(b,"IARDX",g),S=decodeInteger(b,"IARDY",g);x=decodeRefinement(r,p,l,T<n.length?n[T]:u[T-n.length],I,S,!1,f,h)}u.push(x)}else if(e)v.push(r);else{x=decodeBitmap(!1,r,p,a,!1,null,c,h);u.push(x)}}if(e&&!t){const e=s.tableBitmapSize.decode(d);d.byteAlign();let t;if(0===e)t=readUncompressedBitmap(d,i,p);else{const n=d.end,r=d.position+e;d.end=r;t=decodeMMRBitmap(d,i,p,!1);d.end=n;d.position=r}const n=v.length;if(o===n-1)u.push(t);else{let e,r,i,s,a,c=0;for(e=o;e<n;e++){s=v[e];i=c+s;a=[];for(r=0;r<p;r++)a.push(t[r].subarray(c,i));u.push(a);c=i}}}}for(var P=[],k=[],E=!1,B=n.length+r;k.length<B;){for(var D=e?y.decode(d):decodeInteger(b,"IAEX",g);D--;)k.push(E);E=!E}for(var _=0,A=n.length;_<A;_++)k[_]&&P.push(n[_]);for(var L=0;L<r;_++,L++)k[_]&&P.push(u[L]);return P}(e.huffman,e.refinement,f,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,u,c)},onImmediateTextRegion:function SimpleSegmentVisitor_onImmediateTextRegion(e,t,n,r,o){var s=e.info;let a,c;for(var l=this.symbols,f=[],h=0,d=t.length;h<d;h++){const e=l[t[h]];e&&(f=f.concat(e))}var u=(0,i.log2)(f.length);if(e.huffman){c=new Reader(n,r,o);a=function getTextRegionHuffmanTables(e,t,n,r,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<r;){const t=s.decode(i);if(t>=32){let n,r,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");r=i.readBits(2)+3;n=o[e-1].prefixLength;break;case 33:r=i.readBits(3)+3;n=0;break;case 34:r=i.readBits(7)+11;n=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s<r;s++){o.push(new HuffmanLine([e,n,0,0]));e++}}else{o.push(new HuffmanLine([e,t,0,0]));e++}}i.byteAlign();const a=new HuffmanTable(o,!1);let c,l,f,h=0;switch(e.huffmanFS){case 0:case 1:c=getStandardTable(e.huffmanFS+6);break;case 3:c=getCustomHuffmanTable(h,t,n);h++;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(h,t,n);h++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(e.huffmanDT){case 0:case 1:case 2:f=getStandardTable(e.huffmanDT+11);break;case 3:f=getCustomHuffmanTable(h,t,n);h++;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:f}}(e,t,this.customTables,f.length,c)}var p=new DecodingContext(n,r,o),m=decodeTextRegion(e.huffman,e.refinement,s.width,s.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,f,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,n,r,i){let o=this.patterns;o||(this.patterns=o={});const s=new DecodingContext(n,r,i);o[t]=function decodePatternDictionary(e,t,n,r,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,(r+1)*t,n,i,!1,null,s,o),c=[];for(let e=0;e<=r;e++){const r=[],i=t*e,o=i+t;for(let e=0;e<n;e++)r.push(a[e].subarray(i,o));c.push(r)}return c}(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,s)},onImmediateHalftoneRegion(e,t,n,r,o){const s=this.patterns[t[0]],a=e.info,c=new DecodingContext(n,r,o),l=function decodeHalftoneRegion(e,t,n,r,o,s,a,c,l,f,h,d,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,y,v;for(b=0;b<o;b++){v=new Uint8Array(r);if(s)for(y=0;y<r;y++)v[y]=s;g.push(v)}const x=t.length,w=t[0],C=w[0].length,T=w.length,I=(0,i.log2)(x),S=[];if(!e){S.push({x:n<=1?3:2,y:-1});if(0===n){S.push({x:-3,y:-1});S.push({x:2,y:-2});S.push({x:-2,y:-2})}}const P=[];let k,E,B,D,_,A,L,R,O,M,U;e&&(k=new Reader(m.data,m.start,m.end));for(b=I-1;b>=0;b--){E=e?decodeMMRBitmap(k,l,f,!0):decodeBitmap(!1,l,f,n,!1,null,S,m);P[b]=E}for(B=0;B<f;B++)for(D=0;D<l;D++){_=0;A=0;for(y=I-1;y>=0;y--){_=P[y][B][D]^_;A|=_<<y}L=t[A];R=h+B*p+D*u>>8;O=d+B*u-D*p>>8;if(R>=0&&R+C<=r&&O>=0&&O+T<=o)for(b=0;b<T;b++){U=g[O+b];M=L[b];for(y=0;y<C;y++)U[R+y]|=M[y]}else{let e,t;for(b=0;b<T;b++){t=O+b;if(!(t<0||t>=o)){U=g[t];M=L[b];for(y=0;y<C;y++){e=R+y;e>=0&&e<r&&(U[e]|=M[y])}}}}}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,n,r){let o=this.customTables;o||(this.customTables=o={});o[e]=function decodeTablesSegment(e,t,n){const r=e[t],o=4294967295&(0,i.readUint32)(e,t+1),s=4294967295&(0,i.readUint32)(e,t+5),a=new Reader(e,t+9,n),c=1+(r>>1&7),l=1+(r>>4&7),f=[];let h,d,u=o;do{h=a.readBits(c);d=a.readBits(l);f.push(new HuffmanLine([u,h,d,0]));u+=1<<d}while(u<s);h=a.readBits(c);f.push(new HuffmanLine([o-1,h,32,0,"lower"]));h=a.readBits(c);f.push(new HuffmanLine([s,h,32,0]));if(1&r){h=a.readBits(c);f.push(new HuffmanLine([h,0]))}return new HuffmanTable(f,!1)}(t,n,r)}};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 n=e.prefixCode>>t&1;if(t<=0)this.children[n]=new HuffmanTreeNode(e);else{let r=this.children[n];r||(this.children[n]=r=new HuffmanTreeNode(null));r.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,n=e.length;t<n;t++){const n=e[t];n.prefixLength>0&&this.rootNode.buildTree(n,n.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let n=0;for(let r=0;r<t;r++)n=Math.max(n,e[r].prefixLength);const r=new Uint32Array(n+1);for(let n=0;n<t;n++)r[e[n].prefixLength]++;let i,o,s,a=1,c=0;r[0]=0;for(;a<=n;){c=c+r[a-1]<<1;i=c;o=0;for(;o<t;){s=e[o];if(s.prefixLength===a){s.prefixCode=i;i++}o++}a++}}};const f={};function getStandardTable(e){let t,n=f[e];if(n)return n;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,n=t.length;e<n;e++)t[e]=new HuffmanLine(t[e]);n=new HuffmanTable(t,!0);f[e]=n;return n}function Reader(e,t,n){this.data=e;this.start=t;this.end=n;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,n=0;for(t=e-1;t>=0;t--)n|=this.readBit()<<t;return n},byteAlign(){this.shift=-1},next(){return this.position>=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,n){let r=0;for(let i=0,o=t.length;i<o;i++){const o=n[t[i]];if(o){if(e===r)return o;r++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(e,t,n){const r=[];for(let i=0;i<n;i++){const n=new Uint8Array(t);r.push(n);for(let r=0;r<t;r++)n[r]=e.readBit();e.byteAlign()}return r}function decodeMMRBitmap(e,t,n,r){const i={K:-1,Columns:t,Rows:n,BlackIs1:!0,EndOfBlock:r},o=new s.CCITTFaxDecoder(e,i),a=[];let c,l=!1;for(let e=0;e<n;e++){const e=new Uint8Array(t);a.push(e);let n=-1;for(let r=0;r<t;r++){if(n<0){c=o.readNextChar();if(-1===c){c=0;l=!0}n=7}e[r]=c>>n&1;n--}}if(r&&!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,n=0,r=e.length;n<r;n++){var i=e[n];processSegments(readSegments({},i.data,i.start,i.end),t)}return t.buffer}(e),parse(e){const{imgData:t,width:n,height:r}=function parseJbig2(e){const t=e.length;let n=0;if(151!==e[n]||74!==e[n+1]||66!==e[n+2]||50!==e[n+3]||13!==e[n+4]||10!==e[n+5]||26!==e[n+6]||10!==e[n+7])throw new Jbig2Error("parseJbig2 - invalid header.");const r=Object.create(null);n+=8;const o=e[n++];r.randomAccess=!(1&o);if(!(2&o)){r.numberOfPages=(0,i.readUint32)(e,n);n+=4}const s=readSegments(r,e,n,t),a=new SimpleSegmentVisitor;processSegments(s,a);const{width:c,height:l}=a.currentPageInfo,f=a.buffer,h=new Uint8ClampedArray(c*l);let d=0,u=0;for(let e=0;e<l;e++){let e,t=0;for(let n=0;n<c;n++){if(!t){t=128;e=f[u++]}h[d++]=e&t?0:255;t>>=1}}return{imgData:h,width:c,height:l}}(e);this.width=n;this.height=r;return t}};return Jbig2Image}();t.Jbig2Image=a},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.collectActions=function collectActions(e,t,n){const o=Object.create(null);if(t.has("AA")){const r=t.get("AA");for(const t of r.getKeys()){const s=n[t];if(!s)continue;const a=r.getRaw(t),c=new i.RefSet,l=[];_collectJS(a,e,l,c);l.length>0&&(o[s]=l)}}if(t.has("A")){const n=t.get("A"),r=new i.RefSet,s=[];_collectJS(n,e,s,r);s.length>0&&(o.Action=s)}return(0,r.objectSize)(o)>0?o:null};t.escapePDFName=function escapePDFName(e){const t=[];let n=0;for(let r=0,i=e.length;r<i;r++){const i=e.charCodeAt(r);if(i<33||i>126||35===i||40===i||41===i||60===i||62===i||91===i||93===i||123===i||125===i||47===i||37===i){n<r&&t.push(e.substring(n,r));t.push(`#${i.toString(16)}`);n=r+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")};t.getArrayLookupTableFactory=function getArrayLookupTableFactory(e){let t;return function(){if(e){let n=e();e=null;t=Object.create(null);for(let e=0,r=n.length;e<r;e+=2)t[n[e]]=n[e+1];n=null}return t}};t.getInheritableProperty=function getInheritableProperty({dict:e,key:t,getArray:n=!1,stopWhenFound:i=!0}){let o,s=0;for(;e;){const a=n?e.getArray(t):e.get(t);if(void 0!==a){if(i)return a;o||(o=[]);o.push(a)}if(++s>100){(0,r.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return o};t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.parseXFAPath=function parseXFAPath(e){const t=/(.+)\[([0-9]+)\]$/;return e.split(".").map((e=>{const n=e.match(t);return n?{name:n[1],pos:parseInt(n[2],10)}:{name:e,pos:0}}))};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.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,r.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n=[];let i;for(;e>=1e3;){e-=1e3;n.push("M")}i=e/100|0;e%=100;n.push(o[i]);i=e/10|0;e%=10;n.push(o[10+i]);n.push(o[20+e]);const s=n.join("");return t?s.toLowerCase():s};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var r=n(1),i=n(6);class MissingDataException extends r.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends r.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends r.BaseException{}t.XRefParseException=XRefParseException;const o=["","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 _collectJS(e,t,n,o){if(!e)return;let s=null;if((0,i.isRef)(e)){if(o.has(e))return;s=e;o.put(s);e=t.fetch(e)}if(Array.isArray(e))for(const r of e)_collectJS(r,t,n,o);else if(e instanceof i.Dict){if((0,i.isName)(e.get("S"),"JavaScript")&&e.has("JS")){const t=e.get("JS");let o;o=(0,i.isStream)(t)?(0,r.bytesToString)(t.getBytes()):t;o=(0,r.stringToPDFString)(o);o&&n.push(o)}_collectJS(e.getRaw("Next"),t,n,o)}s&&o.remove(s)}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.clearPrimitiveCaches=function clearPrimitiveCaches(){s._clearCache();o._clearCache();c._clearCache()};t.isCmd=function isCmd(e,t){return e instanceof s&&(void 0===t||e.cmd===t)};t.isDict=function isDict(e,t){return e instanceof a&&(void 0===t||isName(e.get("Type"),t))};t.isEOF=function isEOF(e){return e===i};t.isName=isName;t.isRef=function isRef(e){return e instanceof c};t.isRefsEqual=function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen};t.isStream=function isStream(e){return"object"==typeof e&&null!==e&&void 0!==e.getBytes};t.RefSetCache=t.RefSet=t.Ref=t.Name=t.EOF=t.Dict=t.Cmd=void 0;var r=n(1),i={};t.EOF=i;var o=function NameClosure(){let e=Object.create(null);function Name(e){this.name=e}Name.prototype={};Name.get=function Name_get(t){var n=e[t];return n||(e[t]=new Name(t))};Name._clearCache=function(){e=Object.create(null)};return Name}();t.Name=o;var s=function CmdClosure(){let e=Object.create(null);function Cmd(e){this.cmd=e}Cmd.prototype={};Cmd.get=function Cmd_get(t){var n=e[t];return n||(e[t]=new Cmd(t))};Cmd._clearCache=function(){e=Object.create(null)};return Cmd}();t.Cmd=s;var a=function DictClosure(){var e=function nonSerializableClosure(){return e};function Dict(t){this._map=Object.create(null);this.xref=t;this.objId=null;this.suppressEncryption=!1;this.__nonSerializable__=e}Dict.prototype={assignXref:function Dict_assignXref(e){this.xref=e},get size(){return Object.keys(this._map).length},get(e,t,n){let r=this._map[e];if(void 0===r&&void 0!==t){r=this._map[t];void 0===r&&void 0!==n&&(r=this._map[n])}return r instanceof c&&this.xref?this.xref.fetch(r,this.suppressEncryption):r},async getAsync(e,t,n){let r=this._map[e];if(void 0===r&&void 0!==t){r=this._map[t];void 0===r&&void 0!==n&&(r=this._map[n])}return r instanceof c&&this.xref?this.xref.fetchAsync(r,this.suppressEncryption):r},getArray(e,t,n){let r=this.get(e,t,n);if(!Array.isArray(r)||!this.xref)return r;r=r.slice();for(let e=0,t=r.length;e<t;e++)r[e]instanceof c&&(r[e]=this.xref.fetch(r[e],this.suppressEncryption));return r},getRaw:function Dict_getRaw(e){return this._map[e]},getKeys:function Dict_getKeys(){return Object.keys(this._map)},getRawValues:function Dict_getRawValues(){return Object.values(this._map)},set:function Dict_set(e,t){this._map[e]=t},has:function Dict_has(e){return void 0!==this._map[e]},forEach:function Dict_forEach(e){for(var t in this._map)e(t,this.get(t))}};Dict.empty=function(){const e=new Dict(null);e.set=(e,t)=>{(0,r.unreachable)("Should not call `set` on the empty dictionary.")};return e}();Dict.merge=function({xref:e,dictArray:t,mergeSubDicts:n=!1}){const r=new Dict(e);if(!n){for(const e of t)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map))void 0===r._map[t]&&(r._map[t]=n);return r.size>0?r:Dict.empty}const i=new Map;for(const e of t)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map)){let e=i.get(t);if(void 0===e){e=[];i.set(t,e)}e.push(n)}for(const[t,n]of i){if(1===n.length||!(n[0]instanceof Dict)){r._map[t]=n[0];continue}const i=new Dict(e);for(const e of n)if(e instanceof Dict)for(const[t,n]of Object.entries(e._map))void 0===i._map[t]&&(i._map[t]=n);i.size>0&&(r._map[t]=i)}i.clear();return r.size>0?r:Dict.empty};return Dict}();t.Dict=a;var c=function RefClosure(){let e=Object.create(null);function Ref(e,t){this.num=e;this.gen=t}Ref.prototype={toString:function Ref_toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}};Ref.get=function(t,n){const r=0===n?`${t}R`:`${t}R${n}`,i=e[r];return i||(e[r]=new Ref(t,n))};Ref._clearCache=function(){e=Object.create(null)};return Ref}();t.Ref=c;t.RefSet=class RefSet{constructor(e=null){this._set=new Set(e&&e._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}forEach(e){for(const t of this._set.values())e(t)}clear(){this._set.clear()}};t.RefSetCache=class RefSetCache{constructor(){this._map=new Map}get size(){return this._map.size}get(e){return this._map.get(e.toString())}has(e){return this._map.has(e.toString())}put(e,t){this._map.set(e.toString(),t)}putAlias(e,t){this._map.set(e.toString(),this.get(t))}forEach(e){for(const t of this._map.values())e(t)}clear(){this._map.clear()}};function isName(e,t){return e instanceof o&&(void 0===t||e.name===t)}},(e,t)=>{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,n){this.data=e;this.bp=t;this.dataEnd=n;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}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var r=n(1);const i=function CCITTFaxDecoder(){const e=-1,t=[[-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]],n=[[-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]],i=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],o=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],s=[[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]],a=[[-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 n,r=t.EndOfBlock;null==r&&(r=!0);this.eoblock=r;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===(n=this._lookBits(12));)this._eatBits(1);1===n&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}CCITTFaxDecoder.prototype={readNextChar(){if(this.eof)return-1;const t=this.refLine,n=this.codingLine,i=this.columns;let o,s,a,c,l;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let a,l,f;if(this.nextLine2D){for(c=0;n[c]<i;++c)t[c]=n[c];t[c++]=i;t[c]=i;n[0]=0;this.codingPos=0;o=0;s=0;for(;n[this.codingPos]<i;){a=this._getTwoDimCode();switch(a){case 0:this._addPixels(t[o+1],s);t[o+1]<i&&(o+=2);break;case 1:a=l=0;if(s){do{a+=f=this._getBlackCode()}while(f>=64);do{l+=f=this._getWhiteCode()}while(f>=64)}else{do{a+=f=this._getWhiteCode()}while(f>=64);do{l+=f=this._getBlackCode()}while(f>=64)}this._addPixels(n[this.codingPos]+a,s);n[this.codingPos]<i&&this._addPixels(n[this.codingPos]+l,1^s);for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2;break;case 7:this._addPixels(t[o]+3,s);s^=1;if(n[this.codingPos]<i){++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 5:this._addPixels(t[o]+2,s);s^=1;if(n[this.codingPos]<i){++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 3:this._addPixels(t[o]+1,s);s^=1;if(n[this.codingPos]<i){++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 2:this._addPixels(t[o],s);s^=1;if(n[this.codingPos]<i){++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 8:this._addPixelsNeg(t[o]-3,s);s^=1;if(n[this.codingPos]<i){o>0?--o:++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 6:this._addPixelsNeg(t[o]-2,s);s^=1;if(n[this.codingPos]<i){o>0?--o:++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case 4:this._addPixelsNeg(t[o]-1,s);s^=1;if(n[this.codingPos]<i){o>0?--o:++o;for(;t[o]<=n[this.codingPos]&&t[o]<i;)o+=2}break;case e:this._addPixels(i,0);this.eof=!0;break;default:(0,r.info)("bad 2d code");this._addPixels(i,0);this.err=!0}}}else{n[0]=0;this.codingPos=0;s=0;for(;n[this.codingPos]<i;){a=0;if(s)do{a+=f=this._getBlackCode()}while(f>=64);else do{a+=f=this._getWhiteCode()}while(f>=64);this._addPixels(n[this.codingPos]+a,s);s^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){a=this._lookBits(12);if(this.eoline)for(;a!==e&&1!==a;){this._eatBits(1);a=this._lookBits(12)}else for(;0===a;){this._eatBits(1);a=this._lookBits(12)}if(1===a){this._eatBits(12);h=!0}else a===e&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}if(this.eoblock&&h&&this.byteAlign){a=this._lookBits(12);if(1===a){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(c=0;c<4;++c){a=this._lookBits(12);1!==a&&(0,r.info)("bad rtc code: "+a);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){a=this._lookBits(13);if(a===e){this.eof=!0;return-1}if(a>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&a)}}n[0]>0?this.outputBits=n[this.codingPos=0]:this.outputBits=n[this.codingPos=1];this.row++}if(this.outputBits>=8){l=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&n[this.codingPos]<i){this.codingPos++;this.outputBits=n[this.codingPos]-n[this.codingPos-1]}}else{a=8;l=0;do{if(this.outputBits>a){l<<=a;1&this.codingPos||(l|=255>>8-a);this.outputBits-=a;a=0}else{l<<=this.outputBits;1&this.codingPos||(l|=255>>8-this.outputBits);a-=this.outputBits;this.outputBits=0;if(n[this.codingPos]<i){this.codingPos++;this.outputBits=n[this.codingPos]-n[this.codingPos-1]}else if(a>0){l<<=a;a=0}}}while(a)}this.black&&(l^=255);return l},_addPixels(e,t){const n=this.codingLine;let i=this.codingPos;if(e>n[i]){if(e>this.columns){(0,r.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;n[i]=e}this.codingPos=i},_addPixelsNeg(e,t){const n=this.codingLine;let i=this.codingPos;if(e>n[i]){if(e>this.columns){(0,r.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;n[i]=e}else if(e<n[i]){if(e<0){(0,r.info)("invalid code");this.err=!0;e=0}for(;i>0&&e<n[i-1];)--i;n[i]=e}this.codingPos=i},_findTableCode(t,n,r,i){const o=i||0;for(let i=t;i<=n;++i){let t=this._lookBits(i);if(t===e)return[!0,1,!1];i<n&&(t<<=n-i);if(!o||t>=o){const e=r[t-o];if(e[0]===i){this._eatBits(i);return[!0,e[1],!0]}}}return[!1,0,!1]},_getTwoDimCode(){let n,i=0;if(this.eoblock){i=this._lookBits(7);n=t[i];if(n&&n[0]>0){this._eatBits(n[0]);return n[1]}}else{const e=this._findTableCode(1,7,t);if(e[0]&&e[2])return e[1]}(0,r.info)("Bad two dim code");return e},_getWhiteCode(){let t,o=0;if(this.eoblock){o=this._lookBits(12);if(o===e)return 1;t=o>>5==0?n[o]:i[o>>3];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(1,9,i);if(e[0])return e[1];e=this._findTableCode(11,12,n);if(e[0])return e[1]}(0,r.info)("bad white code");this._eatBits(1);return 1},_getBlackCode(){let t,n;if(this.eoblock){t=this._lookBits(13);if(t===e)return 1;n=t>>7==0?o[t]:t>>9==0&&t>>7!=0?s[(t>>1)-64]:a[t>>7];if(n[0]>0){this._eatBits(n[0]);return n[1]}}else{let e=this._findTableCode(2,6,a);if(e[0])return e[1];e=this._findTableCode(7,12,s,64);if(e[0])return e[1];e=this._findTableCode(10,13,o);if(e[0])return e[1]}(0,r.info)("bad black code");this._eatBits(1);return 1},_lookBits(t){let n;for(;this.inputBits<t;){if(-1===(n=this.source.next()))return 0===this.inputBits?e:this.inputBuf<<t-this.inputBits&65535>>16-t;this.inputBuf=this.inputBuf<<8|n;this.inputBits+=8}return this.inputBuf>>this.inputBits-t&65535>>16-t},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}};return CCITTFaxDecoder}();t.CCITTFaxDecoder=i},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.JpegImage=void 0;var r=n(1),i=n(5);class JpegError extends r.BaseException{constructor(e){super(`JPEG error: ${e}`)}}class DNLMarkerError extends r.BaseException{constructor(e,t){super(e);this.scanLines=t}}class EOIMarkerError extends r.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]),t=4017,n=799,o=3406,s=2276,a=1567,c=3784,l=5793,f=2896;function JpegImage({decodeTransform:e=null,colorTransform:t=-1}={}){this._decodeTransform=e;this._colorTransform=t}function buildHuffmanTable(e,t){for(var n,r,i=0,o=[],s=16;s>0&&!e[s-1];)s--;o.push({children:[],index:0});var a,c=o[0];for(n=0;n<s;n++){for(r=0;r<e[n];r++){(c=o.pop()).children[c.index]=t[i];for(;c.index>0;)c=o.pop();c.index++;o.push(c);for(;o.length<=n;){o.push(a={children:[],index:0});c.children[c.index]=a.children;c=a}i++}if(n+1<s){o.push(a={children:[],index:0});c.children[c.index]=a.children;c=a}}return o[0].children}function getBlockBufferOffset(e,t,n){return 64*((e.blocksPerLine+1)*t+n)}function decodeScan(t,n,o,s,a,c,l,f,h,d=!1){var u=o.mcusPerLine,p=o.progressive;const m=n;let g=0,b=0;function readBit(){if(b>0){b--;return g>>b&1}g=t[n++];if(255===g){var e=t[n++];if(e){if(220===e&&d){n+=2;const e=(0,i.readUint16)(t,n);n+=2;if(e>0&&e!==o.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(d){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 y=0;var v,x=0;let w=0;function decodeMcu(e,t,n,r,i){var o=n%u;w=(n/u|0)*e.v+r;var s=o*e.h+i;t(e,getBlockBufferOffset(e,w,s))}function decodeBlock(e,t,n){w=n/e.blocksPerLine|0;var r=n%e.blocksPerLine;t(e,getBlockBufferOffset(e,w,r))}var C,T,I,S,P,k,E=s.length;k=p?0===c?0===f?function decodeDCFirst(e,t){var n=decodeHuffman(e.huffmanTableDC),r=0===n?0:receiveAndExtend(n)<<h;e.blockData[t]=e.pred+=r}:function decodeDCSuccessive(e,t){e.blockData[t]|=readBit()<<h}:0===f?function decodeACFirst(t,n){if(y>0)y--;else for(var r=c,i=l;r<=i;){var o=decodeHuffman(t.huffmanTableAC),s=15&o,a=o>>4;if(0!==s){var f=e[r+=a];t.blockData[n+f]=receiveAndExtend(s)*(1<<h);r++}else{if(a<15){y=receive(a)+(1<<a)-1;break}r+=16}}}:function decodeACSuccessive(t,n){for(var r,i,o=c,s=l,a=0;o<=s;){const s=n+e[o],c=t.blockData[s]<0?-1:1;switch(x){case 0:a=(i=decodeHuffman(t.huffmanTableAC))>>4;if(0==(r=15&i))if(a<15){y=receive(a)+(1<<a);x=4}else{a=16;x=1}else{if(1!==r)throw new JpegError("invalid ACn encoding");v=receiveAndExtend(r);x=a?2:3}continue;case 1:case 2:t.blockData[s]?t.blockData[s]+=c*(readBit()<<h):0==--a&&(x=2===x?3:0);break;case 3:if(t.blockData[s])t.blockData[s]+=c*(readBit()<<h);else{t.blockData[s]=v<<h;x=0}break;case 4:t.blockData[s]&&(t.blockData[s]+=c*(readBit()<<h))}o++}4===x&&0==--y&&(x=0)}:function decodeBaseline(t,n){var r=decodeHuffman(t.huffmanTableDC),i=0===r?0:receiveAndExtend(r);t.blockData[n]=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[n+l]=receiveAndExtend(a);o++}else{if(c<15)break;o+=16}}};var B,D,_,A,L=0;D=1===E?s[0].blocksPerLine*s[0].blocksPerColumn:u*o.mcusPerColumn;for(;L<=D;){var R=a?Math.min(D-L,a):D;if(R>0){for(T=0;T<E;T++)s[T].pred=0;y=0;if(1===E){C=s[0];for(P=0;P<R;P++){decodeBlock(C,k,L);L++}}else for(P=0;P<R;P++){for(T=0;T<E;T++){_=(C=s[T]).h;A=C.v;for(I=0;I<A;I++)for(S=0;S<_;S++)decodeMcu(C,k,L,I,S)}L++}}b=0;if(!(B=findNextFileMarker(t,n)))break;if(B.invalid){const e=R>0?"unexpected":"excessive";(0,r.warn)(`decodeScan - ${e} MCU data, current marker is: ${B.invalid}`);n=B.offset}if(!(B.marker>=65488&&B.marker<=65495))break;n+=2}return n-m}function quantizeAndInverse(e,r,i){var h,d,u,p,m,g,b,y,v,x,w,C,T,I,S,P,k,E=e.quantizationTable,B=e.blockData;if(!E)throw new JpegError("missing required Quantization Table.");for(var D=0;D<64;D+=8){v=B[r+D];x=B[r+D+1];w=B[r+D+2];C=B[r+D+3];T=B[r+D+4];I=B[r+D+5];S=B[r+D+6];P=B[r+D+7];v*=E[D];if(0!=(x|w|C|T|I|S|P)){x*=E[D+1];w*=E[D+2];C*=E[D+3];T*=E[D+4];I*=E[D+5];S*=E[D+6];P*=E[D+7];d=(h=(h=l*v+128>>8)+(d=l*T+128>>8)+1>>1)-d;k=(u=w)*c+(p=S)*a+128>>8;u=u*a-p*c+128>>8;b=(m=(m=f*(x-P)+128>>8)+(b=I<<4)+1>>1)-b;g=(y=(y=f*(x+P)+128>>8)+(g=C<<4)+1>>1)-g;p=(h=h+(p=k)+1>>1)-p;u=(d=d+u+1>>1)-u;k=m*s+y*o+2048>>12;m=m*o-y*s+2048>>12;y=k;k=g*n+b*t+2048>>12;g=g*t-b*n+2048>>12;b=k;i[D]=h+y;i[D+7]=h-y;i[D+1]=d+b;i[D+6]=d-b;i[D+2]=u+g;i[D+5]=u-g;i[D+3]=p+m;i[D+4]=p-m}else{k=l*v+512>>10;i[D]=k;i[D+1]=k;i[D+2]=k;i[D+3]=k;i[D+4]=k;i[D+5]=k;i[D+6]=k;i[D+7]=k}}for(var _=0;_<8;++_){v=i[_];if(0!=((x=i[_+8])|(w=i[_+16])|(C=i[_+24])|(T=i[_+32])|(I=i[_+40])|(S=i[_+48])|(P=i[_+56]))){d=(h=4112+((h=l*v+2048>>12)+(d=l*T+2048>>12)+1>>1))-d;k=(u=w)*c+(p=S)*a+2048>>12;u=u*a-p*c+2048>>12;p=k;b=(m=(m=f*(x-P)+2048>>12)+(b=I)+1>>1)-b;g=(y=(y=f*(x+P)+2048>>12)+(g=C)+1>>1)-g;k=m*s+y*o+2048>>12;m=m*o-y*s+2048>>12;y=k;k=g*n+b*t+2048>>12;g=g*t-b*n+2048>>12;(v=(h=h+p+1>>1)+y)<16?v=0:v>=4080?v=255:v>>=4;(x=(d=d+u+1>>1)+(b=k))<16?x=0:x>=4080?x=255:x>>=4;(w=(u=d-u)+g)<16?w=0:w>=4080?w=255:w>>=4;(C=(p=h-p)+m)<16?C=0:C>=4080?C=255:C>>=4;(T=p-m)<16?T=0:T>=4080?T=255:T>>=4;(I=u-g)<16?I=0:I>=4080?I=255:I>>=4;(S=d-b)<16?S=0:S>=4080?S=255:S>>=4;(P=h-y)<16?P=0:P>=4080?P=255:P>>=4;B[r+_]=v;B[r+_+8]=x;B[r+_+16]=w;B[r+_+24]=C;B[r+_+32]=T;B[r+_+40]=I;B[r+_+48]=S;B[r+_+56]=P}else{k=(k=l*v+8192>>14)<-2040?0:k>=2024?255:k+2056>>4;B[r+_]=k;B[r+_+8]=k;B[r+_+16]=k;B[r+_+24]=k;B[r+_+32]=k;B[r+_+40]=k;B[r+_+48]=k;B[r+_+56]=k}}}function buildComponentData(e,t){for(var n=t.blocksPerLine,r=t.blocksPerColumn,i=new Int16Array(64),o=0;o<r;o++)for(var s=0;s<n;s++){quantizeAndInverse(t,getBlockBufferOffset(t,o,s),i)}return t.blockData}function findNextFileMarker(e,t,n=t){const r=e.length-1;var o=n<t?n:t;if(t>=r)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>=r)return null;a=(0,i.readUint16)(e,o)}return{invalid:s.toString(16),marker:a,offset:o}}JpegImage.prototype={parse(t,{dnlScanLines:n=null}={}){function readDataBlock(){const e=(0,i.readUint16)(t,a);let n=(a+=2)+e-2;var o=findNextFileMarker(t,n,a);if(o&&o.invalid){(0,r.warn)("readDataBlock - incorrect length, current marker is: "+o.invalid);n=o.offset}var s=t.subarray(a,n);a+=s.length;return s}function prepareComponents(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),n=Math.ceil(e.scanLines/8/e.maxV),r=0;r<e.components.length;r++){L=e.components[r];var i=Math.ceil(Math.ceil(e.samplesPerLine/8)*L.h/e.maxH),o=Math.ceil(Math.ceil(e.scanLines/8)*L.v/e.maxV),s=t*L.h,a=64*(n*L.v)*(s+1);L.blockData=new Int16Array(a);L.blocksPerLine=i;L.blocksPerColumn=o}e.mcusPerLine=t;e.mcusPerColumn=n}var o,s,a=0,c=null,l=null;let f=0;var h=[],d=[],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 y=readDataBlock();65504===p&&74===y[0]&&70===y[1]&&73===y[2]&&70===y[3]&&0===y[4]&&(c={version:{major:y[5],minor:y[6]},densityUnits:y[7],xDensity:y[8]<<8|y[9],yDensity:y[10]<<8|y[11],thumbWidth:y[12],thumbHeight:y[13],thumbData:y.subarray(14,14+3*y[12]*y[13])});65518===p&&65===y[0]&&100===y[1]&&111===y[2]&&98===y[3]&&101===y[4]&&(l={version:y[5]<<8|y[6],flags0:y[7]<<8|y[8],flags1:y[9]<<8|y[10],transformCode:y[11]});break;case 65499:for(var v=(0,i.readUint16)(t,a)+(a+=2)-2;a<v;){var x=t[a++],w=new Uint16Array(64);if(x>>4==0)for(g=0;g<64;g++)w[e[g]]=t[a++];else{if(x>>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}}h[15&x]=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=n||z;o.samplesPerLine=(0,i.readUint16)(t,a);a+=2;o.components=[];o.componentIds={};var C,T=t[a++],I=0,S=0;for(m=0;m<T;m++){C=t[a];var P=t[a+1]>>4,k=15&t[a+1];I<P&&(I=P);S<k&&(S=k);var E=t[a+2];b=o.components.push({h:P,v:k,quantizationId:E,quantizationTable:null});o.componentIds[C]=b-1;a+=3}o.maxH=I;o.maxV=S;prepareComponents(o);break;case 65476:const X=(0,i.readUint16)(t,a);a+=2;for(m=2;m<X;){var B=t[a++],D=new Uint8Array(16),_=0;for(g=0;g<16;g++,a++)_+=D[g]=t[a];var A=new Uint8Array(_);for(g=0;g<_;g++,a++)A[g]=t[a];m+=17+_;(B>>4==0?u:d)[15&B]=buildHuffmanTable(D,A)}break;case 65501:a+=2;s=(0,i.readUint16)(t,a);a+=2;break;case 65498:const j=1==++f&&!n;a+=2;var L,R=t[a++],O=[];for(m=0;m<R;m++){const e=t[a++];var M=o.componentIds[e];(L=o.components[M]).index=e;var U=t[a++];L.huffmanTableDC=u[U>>4];L.huffmanTableAC=d[15&U];O.push(L)}var F=t[a++],N=t[a++],H=t[a++];try{var J=decodeScan(t,a,o,O,s,F,N,H>>4,15&H,j);a+=J}catch(e){if(e instanceof DNLMarkerError){(0,r.warn)(`${e.message} -- attempting to re-parse the JPEG image.`);return this.parse(t,{dnlScanLines:e.scanLines})}if(e instanceof EOIMarkerError){(0,r.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 Y=findNextFileMarker(t,a-2,a-3);if(Y&&Y.invalid){(0,r.warn)("JpegImage.parse - unexpected data, current marker is: "+Y.invalid);a=Y.offset;break}if(!Y||a>=t.length-1){(0,r.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=h[(L=o.components[m]).quantizationId];z&&(L.quantizationTable=z);this.components.push({index:L.index,output:buildComponentData(0,L),scaleX:L.h/o.maxH,scaleY:L.v/o.maxV,blocksPerLine:L.blocksPerLine,blocksPerColumn:L.blocksPerColumn})}this.numComponents=this.components.length},_getLinearizedBlockData(e,t,n=!1){var r,i,o,s,a,c,l,f,h,d,u,p=this.width/e,m=this.height/t,g=0,b=this.components.length,y=e*t*b,v=new Uint8ClampedArray(y),x=new Uint32Array(e),w=4294967288;let C;for(l=0;l<b;l++){i=(r=this.components[l]).scaleX*p;o=r.scaleY*m;g=l;u=r.output;s=r.blocksPerLine+1<<3;if(i!==C){for(a=0;a<e;a++){f=0|a*i;x[a]=(f&w)<<3|7&f}C=i}for(c=0;c<t;c++){d=s*((f=0|c*o)&w)|(7&f)<<3;for(a=0;a<e;a++){v[g]=u[d+x[a]];g+=b}}}let T=this._decodeTransform;n||4!==b||T||(T=new Int32Array([-256,255,-256,255,-256,255,-256,255]));if(T)for(l=0;l<y;)for(f=0,h=0;f<b;f++,l++,h+=2)v[l]=(v[l]*T[h]>>8)+T[h+1];return v},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,n,r,i=0,o=e.length;i<o;i+=3){t=e[i];n=e[i+1];r=e[i+2];e[i]=t-179.456+1.402*r;e[i+1]=t+135.459-.344*n-.714*r;e[i+2]=t-226.816+1.772*n}return e},_convertYcckToRgb:function convertYcckToRgb(e){for(var t,n,r,i,o=0,s=0,a=e.length;s<a;s+=4){t=e[s];n=e[s+1];r=e[s+2];i=e[s+3];e[o++]=n*(-660635669420364e-19*n+.000437130475926232*r-54080610064599e-18*t+.00048449797120281*i-.154362151871126)-122.67195406894+r*(-.000957964378445773*r+.000817076911346625*t-.00477271405408747*i+1.53380253221734)+t*(.000961250184130688*t-.00266257332283933*i+.48357088451265)+i*(-.000336197177618394*i+.484791561490776);e[o++]=107.268039397724+n*(219927104525741e-19*n-.000640992018297945*r+.000659397001245577*t+.000426105652938837*i-.176491792462875)+r*(-.000778269941513683*r+.00130872261408275*t+.000770482631801132*i-.151051492775562)+t*(.00126935368114843*t-.00265090189010898*i+.25802910206845)+i*(-.000318913117588328*i-.213742400323665);e[o++]=n*(-.000570115196973677*n-263409051004589e-19*r+.0020741088115012*t-.00288260236853442*i+.814272968359295)-20.810012546947+r*(-153496057440975e-19*r-.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,n,r,i=0,o=e.length;i<o;i+=4){t=e[i];n=e[i+1];r=e[i+2];e[i]=434.456-t-1.402*r;e[i+1]=119.541-t+.344*n+.714*r;e[i+2]=481.816-t-1.772*n}return e},_convertCmykToRgb:function convertCmykToRgb(e){for(var t,n,r,i,o=0,s=0,a=e.length;s<a;s+=4){t=e[s];n=e[s+1];r=e[s+2];i=e[s+3];e[o++]=255+t*(-6747147073602441e-20*t+.0008379262121013727*n+.0002894718188643294*r+.003264231057537806*i-1.1185611867203937)+n*(26374107616089405e-21*n-8626949158638572e-20*r-.0002748769067499491*i-.02155688794978967)+r*(-3878099212869363e-20*r-.0003267808279485286*i+.0686742238595345)-i*(.0003361971776183937*i+.7430659151342254);e[o++]=255+t*(.00013596372813588848*t+.000924537132573585*n+.00010567359618683593*r+.0004791864687436512*i-.3109689587515875)+n*(-.00023545346108370344*n+.0002702845253534714*r+.0020200308977307156*i-.7488052167015494)+r*(6834815998235662e-20*r+.00015168452363460973*i-.09751927774728933)-i*(.0003189131175883281*i+.7364883807733168);e[o++]=255+t*(13598650411385307e-21*t+.00012423956175490851*n+.0004751985097583589*r-36729317476630422e-22*i-.05562186980264034)+n*(.00016141380598724676*n+.0009692239130725186*r+.0007782692450036253*i-.44015232367526463)+r*(5.068882914068769e-7*r+.0017778369011375071*i-.7591454649749609)-i*(.0003435319965105553*i+.7063770186160144)}return e.subarray(0,o)},getData({width:e,height:t,forceRGB:n=!1,isSourcePDF:r=!1}){if(this.numComponents>4)throw new JpegError("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,r);if(1===this.numComponents&&n){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 n?this._convertYcckToRgb(i):this._convertYcckToCmyk(i);if(n)return this._convertCmykToRgb(i)}return i}};return JpegImage}();t.JpegImage=o},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.JpxImage=void 0;var r=n(1),i=n(5),o=n(7);class JpxError extends r.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,n=e.length;t<n;){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=n-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 f=e[t];if(1===f){var h=(0,i.readUint32)(e,t+3);switch(h){case 16:case 17:case 18:break;default:(0,r.warn)("Unknown colorspace "+h)}}else 2===f&&(0,r.info)("ICC profile not supported");break;case 1785737827:this.parseCodestream(e,t,t+c);break;case 1783636e3:218793738!==(0,i.readUint32)(e,t)&&(0,r.warn)("Invalid JP2 signature");break;case 1783634458:case 1718909296:case 1920099697:case 1919251232:case 1768449138:break;default:var d=String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,255&a);(0,r.warn)("Unsupported header type "+a+" ("+d+")")}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 n=e.getInt32()>>>0,r=e.getInt32()>>>0,i=e.getInt32()>>>0,o=e.getInt32()>>>0;e.skip(16);var s=e.getUint16();this.width=n-i;this.height=r-o;this.componentsCount=s;this.bitsPerComponent=8;return}}throw new JpxError("No size marker found in JPX stream")},parseCodestream:function JpxImage_parseCodestream(e,t,n){var o={},s=!1;try{for(var a=t;a+1<n;){var c=(0,i.readUint16)(e,a);a+=2;var l,f,h,d,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 y=[];l=a+38;for(var v=0;v<b;v++){var x={precision:1+(127&e[l]),isSigned:!!(128&e[l]),XRsiz:e[l+1],YRsiz:e[l+2]};l+=3;calculateComponentDimensions(x,g);y.push(x)}o.SIZ=g;o.components=y;calculateTileGrids(o,y);o.QCC=[];o.COC=[];break;case 65372:m=(0,i.readUint16)(e,a);var w={};l=a+2;switch(31&(f=e[l++])){case 0:d=8;u=!0;break;case 1:d=16;u=!1;break;case 2:d=16;u=!0;break;default:throw new Error("Invalid SQcd value "+f)}w.noQuantization=8===d;w.scalarExpounded=u;w.guardBits=f>>5;h=[];for(;l<m+a;){var C={};if(8===d){C.epsilon=e[l++]>>3;C.mu=0}else{C.epsilon=e[l]>>3;C.mu=(7&e[l])<<8|e[l+1];l+=2}h.push(C)}w.SPqcds=h;if(o.mainHeader)o.QCD=w;else{o.currentTile.QCD=w;o.currentTile.QCC=[]}break;case 65373:m=(0,i.readUint16)(e,a);var T,I={};l=a+2;if(o.SIZ.Csiz<257)T=e[l++];else{T=(0,i.readUint16)(e,l);l+=2}switch(31&(f=e[l++])){case 0:d=8;u=!0;break;case 1:d=16;u=!1;break;case 2:d=16;u=!0;break;default:throw new Error("Invalid SQcd value "+f)}I.noQuantization=8===d;I.scalarExpounded=u;I.guardBits=f>>5;h=[];for(;l<m+a;){C={};if(8===d){C.epsilon=e[l++]>>3;C.mu=0}else{C.epsilon=e[l]>>3;C.mu=(7&e[l])<<8|e[l+1];l+=2}h.push(C)}I.SPqcds=h;o.mainHeader?o.QCC[T]=I:o.currentTile.QCC[T]=I;break;case 65362:m=(0,i.readUint16)(e,a);var S={};l=a+2;var P=e[l++];S.entropyCoderWithCustomPrecincts=!!(1&P);S.sopMarkerUsed=!!(2&P);S.ephMarkerUsed=!!(4&P);S.progressionOrder=e[l++];S.layersCount=(0,i.readUint16)(e,l);l+=2;S.multipleComponentTransform=e[l++];S.decompositionLevelsCount=e[l++];S.xcb=2+(15&e[l++]);S.ycb=2+(15&e[l++]);var k=e[l++];S.selectiveArithmeticCodingBypass=!!(1&k);S.resetContextProbabilities=!!(2&k);S.terminationOnEachCodingPass=!!(4&k);S.verticallyStripe=!!(8&k);S.predictableTermination=!!(16&k);S.segmentationSymbolUsed=!!(32&k);S.reversibleTransformation=e[l++];if(S.entropyCoderWithCustomPrecincts){for(var E=[];l<m+a;){var B=e[l++];E.push({PPx:15&B,PPy:B>>4})}S.precinctsSizes=E}var D=[];S.selectiveArithmeticCodingBypass&&D.push("selectiveArithmeticCodingBypass");S.resetContextProbabilities&&D.push("resetContextProbabilities");S.terminationOnEachCodingPass&&D.push("terminationOnEachCodingPass");S.verticallyStripe&&D.push("verticallyStripe");S.predictableTermination&&D.push("predictableTermination");if(D.length>0){s=!0;(0,r.warn)(`JPX: Unsupported COD options (${D.join(", ")}).`)}if(o.mainHeader)o.COD=S;else{o.currentTile.COD=S;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 65363:(0,r.warn)("JPX: Codestream code 0xFF53 (COC) is not implemented.");case 65365:case 65367:case 65368:case 65380:m=(0,i.readUint16)(e,a);break;default:throw new Error("Unknown codestream code: "+c.toString(16))}a+=m}}catch(e){if(s||this.failOnCorruptedImage)throw new JpxError(e.message);(0,r.warn)(`JPX: Trying to recover from: "${e.message}".`)}this.tiles=function transformComponents(e){for(var t=e.SIZ,n=e.components,r=t.Csiz,i=[],o=0,s=e.tiles.length;o<s;o++){var a,c=e.tiles[o],l=[];for(a=0;a<r;a++)l[a]=transformTile(e,c,a);var f,h,d,u,p,m,g,b=l[0],y=new Uint8ClampedArray(b.items.length*r),v={left:b.left,top:b.top,width:b.width,height:b.height,items:y},x=0;if(c.codingStyleDefaultParameters.multipleComponentTransform){var w=4===r,C=l[0].items,T=l[1].items,I=l[2].items,S=w?l[3].items:null;h=.5+(128<<(f=n[0].precision-8));var P=c.components[0],k=r-3;u=C.length;if(P.codingStyleParameters.reversibleTransformation)for(d=0;d<u;d++,x+=k){p=C[d]+h;m=T[d];const e=p-((g=I[d])+m>>2);y[x++]=e+g>>f;y[x++]=e>>f;y[x++]=e+m>>f}else for(d=0;d<u;d++,x+=k){p=C[d]+h;m=T[d];g=I[d];y[x++]=p+1.402*g>>f;y[x++]=p-.34413*m-.71414*g>>f;y[x++]=p+1.772*m>>f}if(w)for(d=0,x=3;d<u;d++,x+=4)y[x]=S[d]+h>>f}else for(a=0;a<r;a++){var E=l[a].items;h=.5+(128<<(f=n[a].precision-8));for(x=a,d=0,u=E.length;d<u;d++){y[x]=E[d]+h>>f;x+=r}}i.push(v)}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 n,r=e.SIZ,i=[],o=Math.ceil((r.Xsiz-r.XTOsiz)/r.XTsiz),s=Math.ceil((r.Ysiz-r.YTOsiz)/r.YTsiz),a=0;a<s;a++)for(var c=0;c<o;c++){(n={}).tx0=Math.max(r.XTOsiz+c*r.XTsiz,r.XOsiz);n.ty0=Math.max(r.YTOsiz+a*r.YTsiz,r.YOsiz);n.tx1=Math.min(r.XTOsiz+(c+1)*r.XTsiz,r.Xsiz);n.ty1=Math.min(r.YTOsiz+(a+1)*r.YTsiz,r.Ysiz);n.width=n.tx1-n.tx0;n.height=n.ty1-n.ty0;n.components=[];i.push(n)}e.tiles=i;for(var l=0,f=r.Csiz;l<f;l++)for(var h=t[l],d=0,u=i.length;d<u;d++){var p={};n=i[d];p.tcx0=Math.ceil(n.tx0/h.XRsiz);p.tcy0=Math.ceil(n.ty0/h.YRsiz);p.tcx1=Math.ceil(n.tx1/h.XRsiz);p.tcy1=Math.ceil(n.ty1/h.YRsiz);p.width=p.tcx1-p.tcx0;p.height=p.tcy1-p.tcy0;n.components[l]=p}}function getBlocksDimensions(e,t,n){var r=t.codingStyleParameters,i={};if(r.entropyCoderWithCustomPrecincts){i.PPx=r.precinctsSizes[n].PPx;i.PPy=r.precinctsSizes[n].PPy}else{i.PPx=15;i.PPy=15}i.xcb_=n>0?Math.min(r.xcb,i.PPx-1):Math.min(r.xcb,i.PPx);i.ycb_=n>0?Math.min(r.ycb,i.PPy-1):Math.min(r.ycb,i.PPy);return i}function buildPrecincts(e,t,n){var r=1<<n.PPx,i=1<<n.PPy,o=0===t.resLevel,s=1<<n.PPx+(o?0:-1),a=1<<n.PPy+(o?0:-1),c=t.trx1>t.trx0?Math.ceil(t.trx1/r)-Math.floor(t.trx0/r):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,f=c*l;t.precinctParameters={precinctWidth:r,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:f,precinctWidthInSubband:s,precinctHeightInSubband:a}}function buildCodeblocks(e,t,n){var r,i,o,s,a=n.xcb_,c=n.ycb_,l=1<<a,f=1<<c,h=t.tbx0>>a,d=t.tby0>>c,u=t.tbx1+l-1>>a,p=t.tby1+f-1>>c,m=t.resolution.precinctParameters,g=[],b=[];for(i=d;i<p;i++)for(r=h;r<u;r++){(o={cbx:r,cby:i,tbx0:l*r,tby0:f*i,tbx1:l*(r+1),tby1:f*(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 y=b[s];if(void 0!==y){r<y.cbxMin?y.cbxMin=r:r>y.cbxMax&&(y.cbxMax=r);i<y.cbyMin?y.cbxMin=i:i>y.cbyMax&&(y.cbyMax=i)}else b[s]=y={cbxMin:r,cbyMin:i,cbxMax:r,cbyMax:i};o.precinct=y}}t.codeblockParameters={codeblockWidth:a,codeblockHeight:c,numcodeblockwide:u-h+1,numcodeblockhigh:p-d+1};t.codeblocks=g;t.precincts=b}function createPacket(e,t,n){for(var r=[],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 f=a[c];f.precinctNumber===t&&r.push(f)}return{layerNumber:n,codeblocks:r}}function LayerResolutionComponentPositionIterator(e){for(var t=e.SIZ,n=e.currentTile.index,r=e.tiles[n],i=r.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=0,a=0;a<o;a++)s=Math.max(s,r.components[a].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,f=0,h=0;this.nextPacket=function JpxImage_nextPacket(){for(;c<i;c++){for(;l<=s;l++){for(;f<o;f++){var e=r.components[f];if(!(l>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],n=t.precinctParameters.numprecincts;h<n;){var a=createPacket(t,h,c);h++;return a}h=0}}f=0}l=0}throw new JpxError("Out of packets")}}function ResolutionLayerComponentPositionIterator(e){for(var t=e.SIZ,n=e.currentTile.index,r=e.tiles[n],i=r.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=0,a=0;a<o;a++)s=Math.max(s,r.components[a].codingStyleParameters.decompositionLevelsCount);var c=0,l=0,f=0,h=0;this.nextPacket=function JpxImage_nextPacket(){for(;c<=s;c++){for(;l<i;l++){for(;f<o;f++){var e=r.components[f];if(!(c>e.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],n=t.precinctParameters.numprecincts;h<n;){var a=createPacket(t,h,l);h++;return a}h=0}}f=0}l=0}throw new JpxError("Out of packets")}}function ResolutionPositionComponentLayerIterator(e){var t,n,r,i,o=e.SIZ,s=e.currentTile.index,a=e.tiles[s],c=a.codingStyleDefaultParameters.layersCount,l=o.Csiz,f=0;for(r=0;r<l;r++){const e=a.components[r];f=Math.max(f,e.codingStyleParameters.decompositionLevelsCount)}var h=new Int32Array(f+1);for(n=0;n<=f;++n){var d=0;for(r=0;r<l;++r){var u=a.components[r].resolutions;n<u.length&&(d=Math.max(d,u[n].precinctParameters.numprecincts))}h[n]=d}t=0;n=0;r=0;i=0;this.nextPacket=function JpxImage_nextPacket(){for(;n<=f;n++){for(;i<h[n];i++){for(;r<l;r++){const l=a.components[r];if(!(n>l.codingStyleParameters.decompositionLevelsCount)){var e=l.resolutions[n],o=e.precinctParameters.numprecincts;if(!(i>=o)){for(;t<c;){var s=createPacket(e,i,t);t++;return s}t=0}}}r=0}i=0}throw new JpxError("Out of packets")}}function PositionComponentResolutionLayerIterator(e){var t=e.SIZ,n=e.currentTile.index,r=e.tiles[n],i=r.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=getPrecinctSizesInImageScale(r),a=s,c=0,l=0,f=0,h=0,d=0;this.nextPacket=function JpxImage_nextPacket(){for(;d<a.maxNumHigh;d++){for(;h<a.maxNumWide;h++){for(;f<o;f++){for(var e=r.components[f],t=e.codingStyleParameters.decompositionLevelsCount;l<=t;l++){var n=e.resolutions[l],u=s.components[f].resolutions[l],p=getPrecinctIndexIfExist(h,d,u,a,n);if(null!==p){for(;c<i;){var m=createPacket(n,p,c);c++;return m}c=0}}l=0}f=0}h=0}throw new JpxError("Out of packets")}}function ComponentPositionResolutionLayerIterator(e){var t=e.SIZ,n=e.currentTile.index,r=e.tiles[n],i=r.codingStyleDefaultParameters.layersCount,o=t.Csiz,s=getPrecinctSizesInImageScale(r),a=0,c=0,l=0,f=0,h=0;this.nextPacket=function JpxImage_nextPacket(){for(;l<o;++l){for(var e=r.components[l],t=s.components[l],n=e.codingStyleParameters.decompositionLevelsCount;h<t.maxNumHigh;h++){for(;f<t.maxNumWide;f++){for(;c<=n;c++){var d=e.resolutions[c],u=t.resolutions[c],p=getPrecinctIndexIfExist(f,h,u,t,d);if(null!==p){for(;a<i;){var m=createPacket(d,p,a);a++;return m}a=0}}c=0}f=0}h=0}throw new JpxError("Out of packets")}}function getPrecinctIndexIfExist(e,t,n,r,i){var o=e*r.minWidth,s=t*r.minHeight;if(o%n.width!=0||s%n.height!=0)return null;var a=s/n.width*i.precinctParameters.numprecinctswide;return o/n.height+a}function getPrecinctSizesInImageScale(e){for(var t=e.components.length,n=Number.MAX_VALUE,r=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,f=new Array(l+1),h=Number.MAX_VALUE,d=Number.MAX_VALUE,u=0,p=0,m=1,g=l;g>=0;--g){var b=c.resolutions[g],y=m*b.precinctParameters.precinctWidth,v=m*b.precinctParameters.precinctHeight;h=Math.min(h,y);d=Math.min(d,v);u=Math.max(u,b.precinctParameters.numprecinctswide);p=Math.max(p,b.precinctParameters.numprecinctshigh);f[g]={width:y,height:v};m<<=1}n=Math.min(n,h);r=Math.min(r,d);i=Math.max(i,u);o=Math.max(o,p);s[a]={resolutions:f,minWidth:h,minHeight:d,maxNumWide:u,maxNumHigh:p}}return{components:s,minWidth:n,minHeight:r,maxNumWide:i,maxNumHigh:o}}function buildPackets(e){for(var t=e.SIZ,n=e.currentTile.index,r=e.tiles[n],i=t.Csiz,o=0;o<i;o++){for(var s=r.components[o],a=s.codingStyleParameters.decompositionLevelsCount,c=[],l=[],f=0;f<=a;f++){var h,d=getBlocksDimensions(0,s,f),u={},p=1<<a-f;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=f;buildPrecincts(0,u,d);c.push(u);if(0===f){(h={}).type="LL";h.tbx0=Math.ceil(s.tcx0/p);h.tby0=Math.ceil(s.tcy0/p);h.tbx1=Math.ceil(s.tcx1/p);h.tby1=Math.ceil(s.tcy1/p);h.resolution=u;buildCodeblocks(0,h,d);l.push(h);u.subbands=[h]}else{var m=1<<a-f+1,g=[];(h={}).type="HL";h.tbx0=Math.ceil(s.tcx0/m-.5);h.tby0=Math.ceil(s.tcy0/m);h.tbx1=Math.ceil(s.tcx1/m-.5);h.tby1=Math.ceil(s.tcy1/m);h.resolution=u;buildCodeblocks(0,h,d);l.push(h);g.push(h);(h={}).type="LH";h.tbx0=Math.ceil(s.tcx0/m);h.tby0=Math.ceil(s.tcy0/m-.5);h.tbx1=Math.ceil(s.tcx1/m);h.tby1=Math.ceil(s.tcy1/m-.5);h.resolution=u;buildCodeblocks(0,h,d);l.push(h);g.push(h);(h={}).type="HH";h.tbx0=Math.ceil(s.tcx0/m-.5);h.tby0=Math.ceil(s.tcy0/m-.5);h.tbx1=Math.ceil(s.tcx1/m-.5);h.tby1=Math.ceil(s.tcy1/m-.5);h.resolution=u;buildCodeblocks(0,h,d);l.push(h);g.push(h);u.subbands=g}}s.resolutions=c;s.subbands=l}var b=r.codingStyleDefaultParameters.progressionOrder;switch(b){case 0:r.packetsIterator=new LayerResolutionComponentPositionIterator(e);break;case 1:r.packetsIterator=new ResolutionLayerComponentPositionIterator(e);break;case 2:r.packetsIterator=new ResolutionPositionComponentLayerIterator(e);break;case 3:r.packetsIterator=new PositionComponentResolutionLayerIterator(e);break;case 4:r.packetsIterator=new ComponentPositionResolutionLayerIterator(e);break;default:throw new JpxError(`Unsupported progression order ${b}`)}}function parseTilePackets(e,r,o,s){var a,c=0,l=0,f=!1;function readBits(e){for(;l<e;){var t=r[o+c];c++;if(f){a=a<<7|t;l+=7;f=!1}else{a=a<<8|t;l+=8}255===t&&(f=!0)}return a>>>(l-=e)&(1<<e)-1}function skipMarkerIfEqual(e){if(255===r[o+c-1]&&r[o+c]===e){skipBytes(1);return!0}if(255===r[o+c]&&r[o+c+1]===e){skipBytes(2);return!0}return!1}function skipBytes(e){c+=e}function alignToByte(){l=0;if(f){c++;f=!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 h=e.currentTile.index,d=e.tiles[h],u=e.COD.sopMarkerUsed,p=e.COD.ephMarkerUsed,m=d.packetsIterator;c<s;){alignToByte();u&&skipMarkerIfEqual(145)&&skipBytes(4);var g=m.nextPacket();if(readBits(1)){for(var b,y=g.layerNumber,v=[],x=0,w=g.codeblocks.length;x<w;x++){var C=(b=g.codeblocks[x]).precinct,T=b.cbx-C.cbxMin,I=b.cby-C.cbyMin,S=!1,P=!1;if(void 0!==b.included)S=!!readBits(1);else{var k,E;if(void 0!==(C=b.precinct).inclusionTree)k=C.inclusionTree;else{var B=C.cbxMax-C.cbxMin+1,D=C.cbyMax-C.cbyMin+1;k=new n(B,D,y);E=new t(B,D);C.inclusionTree=k;C.zeroBitPlanesTree=E}if(k.reset(T,I,y))for(;;){if(!readBits(1)){k.incrementValue(y);break}if(!k.nextLevel()){b.included=!0;S=P=!0;break}}}if(S){if(P){(E=C.zeroBitPlanesTree).reset(T,I);for(;;)if(readBits(1)){if(!E.nextLevel())break}else E.incrementValue();b.zeroBitPlanes=E.value}for(var _=readCodingpasses();readBits(1);)b.Lblock++;var A=(0,i.log2)(_),L=readBits((_<1<<A?A-1:A)+b.Lblock);v.push({codeblock:b,codingpasses:_,dataLength:L})}}alignToByte();p&&skipMarkerIfEqual(146);for(;v.length>0;){var R=v.shift();void 0===(b=R.codeblock).data&&(b.data=[]);b.data.push({data:r,start:o+c,end:o+c+R.dataLength,codingpasses:R.codingpasses});c+=R.dataLength}}}return c}function copyCoefficients(e,t,n,r,i,a,c,l){for(var f=r.tbx0,h=r.tby0,d=r.tbx1-r.tbx0,u=r.codeblocks,p="H"===r.type.charAt(0)?1:0,m="H"===r.type.charAt(1)?t:0,g=0,b=u.length;g<b;++g){var y=u[g],v=y.tbx1_-y.tbx0_,x=y.tby1_-y.tby0_;if(0!==v&&0!==x&&void 0!==y.data){var w,C;w=new s(v,x,y.subbandType,y.zeroBitPlanes,a);C=2;var T,I,S,P=y.data,k=0,E=0;for(T=0,I=P.length;T<I;T++){k+=(S=P[T]).end-S.start;E+=S.codingpasses}var B=new Uint8Array(k),D=0;for(T=0,I=P.length;T<I;T++){var _=(S=P[T]).data.subarray(S.start,S.end);B.set(_,D);D+=_.length}var A=new o.ArithmeticDecoder(B,0,k);w.setDecoder(A);for(T=0;T<E;T++){switch(C){case 0:w.runSignificancePropagationPass();break;case 1:w.runMagnitudeRefinementPass();break;case 2:w.runCleanupPass();l&&w.checkSegmentationSymbol()}C=(C+1)%3}var L,R,O,M=y.tbx0_-f+(y.tby0_-h)*d,U=w.coefficentsSign,F=w.coefficentsMagnitude,N=w.bitsDecoded,H=c?0:.5;D=0;var J="LL"!==r.type;for(T=0;T<x;T++){var z=2*(M/d|0)*(t-d)+p+m;for(L=0;L<v;L++){if(0!==(R=F[D])){R=(R+H)*i;0!==U[D]&&(R=-R);O=N[D];var X=J?z+(M<<1):M;e[X]=c&&O>=a?R:R*(1<<a-O)}M++;D++}M+=d-v}}}}function transformTile(t,n,r){for(var i=n.components[r],o=i.codingStyleParameters,s=i.quantizationParameters,a=o.decompositionLevelsCount,f=s.SPqcds,h=s.scalarExpounded,d=s.guardBits,u=o.segmentationSymbolUsed,p=t.components[r].precision,m=o.reversibleTransformation,g=m?new l:new c,b=[],y=0,v=0;v<=a;v++){for(var x=i.resolutions[v],w=x.trx1-x.trx0,C=x.try1-x.try0,T=new Float32Array(w*C),I=0,S=x.subbands.length;I<S;I++){var P,k;if(h){P=f[y].mu;k=f[y].epsilon;y++}else{P=f[0].mu;k=f[0].epsilon+(v>0?1-v:0)}var E=x.subbands[I],B=e[E.type];copyCoefficients(T,w,0,E,m?1:2**(p+B-k)*(1+P/2048),d+k-1,m,u)}b.push({width:w,height:C,items:T})}var D=g.calculate(b,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:D.width,height:D.height,items:D.items}}function initializeTile(e,t){for(var n=e.SIZ.Csiz,r=e.tiles[t],i=0;i<n;i++){var o=r.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}r.codingStyleDefaultParameters=e.currentTile.COD}var t=function TagTreeClosure(){function TagTree(e,t){var n=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var r=0;r<n;r++){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 n,r=0,i=0;r<this.levels.length;){var o=e+t*(n=this.levels[r]).width;if(void 0!==n.items[o]){i=n.items[o];break}n.index=o;e>>=1;t>>=1;r++}r--;(n=this.levels[r]).items[n.index]=i;this.currentLevel=r;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],n=t.items[t.index];if(--e<0){this.value=n;return!1}this.currentLevel=e;(t=this.levels[e]).items[t.index]=n;return!0}};return TagTree}(),n=function InclusionTreeClosure(){function InclusionTree(e,t,n){var r=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var o=0;o<r;o++){for(var s=new Uint8Array(e*t),a=0,c=s.length;a<c;a++)s[a]=n;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,n){for(var r=0;r<this.levels.length;){var i=this.levels[r],o=e+t*i.width;i.index=o;var s=i.items[o];if(255===s)break;if(s>n){this.currentLevel=r;this.propagateValues();return!1}e>>=1;t>>=1;r++}this.currentLevel=r-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],n=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=n},nextLevel:function InclusionTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],n=t.items[t.index];t.items[t.index]=255;if(--e<0)return!1;this.currentLevel=e;(t=this.levels[e]).items[t.index]=n;return!0}};return InclusionTree}(),s=function BitModelClosure(){var e=17,t=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]),n=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(e,i,o,s,a){this.width=e;this.height=i;let c;c="HH"===o?r:"HL"===o?n:t;this.contextLabelTable=c;var l=e*i;this.neighborsSignificance=new Uint8Array(l);this.coefficentsSign=new Uint8Array(l);let f;f=a>14?new Uint32Array(l):a>6?new Uint16Array(l):new Uint8Array(l);this.coefficentsMagnitude=f;this.processingFlags=new Uint8Array(l);var h=new Uint8Array(l);if(0!==s)for(var d=0;d<l;d++)h[d]=s;this.bitsDecoded=h;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,n){var r,i=this.neighborsSignificance,o=this.width,s=this.height,a=t>0,c=t+1<o;if(e>0){r=n-o;a&&(i[r-1]+=16);c&&(i[r+1]+=16);i[r]+=4}if(e+1<s){r=n+o;a&&(i[r-1]+=16);c&&(i[r+1]+=16);i[r]+=4}a&&(i[n-1]+=1);c&&(i[n+1]+=1);i[n]|=128},runSignificancePropagationPass:function BitModel_runSignificancePropagationPass(){for(var e=this.decoder,t=this.width,n=this.height,r=this.coefficentsMagnitude,i=this.coefficentsSign,o=this.neighborsSignificance,s=this.processingFlags,a=this.contexts,c=this.contextLabelTable,l=this.bitsDecoded,f=0;f<n;f+=4)for(var h=0;h<t;h++)for(var d=f*t+h,u=0;u<4;u++,d+=t){var p=f+u;if(p>=n)break;s[d]&=-2;if(!r[d]&&o[d]){var m=c[o[d]];if(e.readBit(a,m)){var g=this.decodeSignBit(p,h,d);i[d]=g;r[d]=1;this.setNeighborsSignificance(p,h,d);s[d]|=2}l[d]++;s[d]|=1}}},decodeSignBit:function BitModel_decodeSignBit(e,t,n){var r,i,o,s,a,c,l=this.width,f=this.height,h=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==h[n-1];if(t+1<l&&0!==h[n+1]){o=d[n+1];r=s?1-o-(i=d[n-1]):1-o-o}else r=s?1-(i=d[n-1])-i:0;var u=3*r;s=e>0&&0!==h[n-l];if(e+1<f&&0!==h[n+l]){o=d[n+l];r=s?1-o-(i=d[n-l])+u:1-o-o+u}else r=s?1-(i=d[n-l])-i+u:u;if(r>=0){a=9+r;c=this.decoder.readBit(this.contexts,a)}else{a=9-r;c=1^this.decoder.readBit(this.contexts,a)}return c},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){for(var e,t=this.decoder,n=this.width,r=this.height,i=this.coefficentsMagnitude,o=this.neighborsSignificance,s=this.contexts,a=this.bitsDecoded,c=this.processingFlags,l=n*r,f=4*n,h=0;h<l;h=e){e=Math.min(l,h+f);for(var d=0;d<n;d++)for(var u=h+d;u<e;u+=n)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 t,n=this.decoder,r=this.width,i=this.height,o=this.neighborsSignificance,s=this.coefficentsMagnitude,a=this.coefficentsSign,c=this.contexts,l=this.contextLabelTable,f=this.bitsDecoded,h=this.processingFlags,d=r,u=2*r,p=3*r,m=0;m<i;m=t){t=Math.min(m+4,i);for(var g=m*r,b=m+3<i,y=0;y<r;y++){var v,x=g+y,w=0,C=x,T=m;if(b&&0===h[x]&&0===h[x+d]&&0===h[x+u]&&0===h[x+p]&&0===o[x]&&0===o[x+d]&&0===o[x+u]&&0===o[x+p]){if(!n.readBit(c,18)){f[x]++;f[x+d]++;f[x+u]++;f[x+p]++;continue}if(0!==(w=n.readBit(c,e)<<1|n.readBit(c,e))){T=m+w;C+=w*r}v=this.decodeSignBit(T,y,C);a[C]=v;s[C]=1;this.setNeighborsSignificance(T,y,C);h[C]|=2;C=x;for(var I=m;I<=T;I++,C+=r)f[C]++;w++}for(T=m+w;T<t;T++,C+=r)if(!s[C]&&0==(1&h[C])){var S=l[o[C]];if(1===n.readBit(c,S)){v=this.decodeSignBit(T,y,C);a[C]=v;s[C]=1;this.setNeighborsSignificance(T,y,C);h[C]|=2}f[C]++}}}},checkSegmentationSymbol:function BitModel_checkSegmentationSymbol(){var t=this.decoder,n=this.contexts;if(10!==(t.readBit(n,e)<<3|t.readBit(n,e)<<2|t.readBit(n,e)<<1|t.readBit(n,e)))throw new JpxError("Invalid segmentation symbol")}};return BitModel}(),a=function TransformClosure(){function Transform(){}Transform.prototype.calculate=function transformCalculate(e,t,n){for(var r=e[0],i=1,o=e.length;i<o;i++)r=this.iterate(r,e[i],t,n);return r};Transform.prototype.extend=function extend(e,t,n){var r=t-1,i=t+1,o=t+n-2,s=t+n;e[r--]=e[i++];e[s++]=e[o--];e[r--]=e[i++];e[s++]=e[o--];e[r--]=e[i++];e[s++]=e[o--];e[r]=e[i];e[s]=e[o]};Transform.prototype.iterate=function Transform_iterate(e,t,n,r){var i,o,s,a,c,l,f=e.width,h=e.height,d=e.items,u=t.width,p=t.height,m=t.items;for(s=0,i=0;i<h;i++){a=2*i*u;for(o=0;o<f;o++,s++,a+=2)m[a]=d[s]}d=e.items=null;var g=new Float32Array(u+8);if(1===u){if(0!=(1&n))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,y=[];for(i=0;i<b;i++)y.push(new Float32Array(p+8));var v,x=0;e=4+p;if(1===p){if(0!=(1&r))for(c=0;c<u;c++)m[c]*=.5}else for(c=0;c<u;c++){if(0===x){b=Math.min(u-c,b);for(s=c,a=4;a<e;s+=u,a++)for(v=0;v<b;v++)y[v][a]=m[s+v];x=b}var w=y[--x];this.extend(w,4,p);this.filter(w,4,p);if(0===x){s=c-b+1;for(a=4;a<e;s+=u,a++)for(v=0;v<b;v++)m[s+v]=y[v][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,n){var r,i,o,s,a=n>>1,c=-1.586134342059924,l=-.052980118572961,f=.882911075530934,h=.443506852043971,d=1.230174104914001;r=(t|=0)-3;for(i=a+4;i--;r+=2)e[r]*=.8128930661159609;o=h*e[(r=t-2)-1];for(i=a+3;i--;r+=2){s=h*e[r+1];e[r]=d*e[r]-o-s;if(!i--)break;o=h*e[(r+=2)+1];e[r]=d*e[r]-o-s}o=f*e[(r=t-1)-1];for(i=a+2;i--;r+=2){s=f*e[r+1];e[r]-=o+s;if(!i--)break;o=f*e[(r+=2)+1];e[r]-=o+s}o=l*e[(r=t)-1];for(i=a+1;i--;r+=2){s=l*e[r+1];e[r]-=o+s;if(!i--)break;o=l*e[(r+=2)+1];e[r]-=o+s}if(0!==a){o=c*e[(r=t+1)-1];for(i=a;i--;r+=2){s=c*e[r+1];e[r]-=o+s;if(!i--)break;o=c*e[(r+=2)+1];e[r]-=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,n){var r,i,o=n>>1;for(r=t|=0,i=o+1;i--;r+=2)e[r]-=e[r-1]+e[r+1]+2>>2;for(r=t+1,i=o;i--;r+=2)e[r]+=e[r-1]+e[r+1]>>1};return ReversibleTransform}();return JpxImage}();t.JpxImage=s}],t={};return function __w_pdfjs_require__(n){if(t[n])return t[n].exports;var r=t[n]={exports:{}};e[n](r,r.exports,__w_pdfjs_require__);return r.exports}(0)})()}));