UNPKG

@nuxeo/nuxeo-ui-elements

Version:
22 lines 114 kB
/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2021 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * Javascript code in this page */ !function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/image_decoders/pdf.image_decoders",[],t):"object"==typeof exports?exports["pdfjs-dist/image_decoders/pdf.image_decoders"]=t():e["pdfjs-dist/image_decoders/pdf.image_decoders"]=e.pdfjsImageDecoders=t()}(this,(function(){return(()=>{"use strict";var e=[,(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.UNSUPPORTED_FEATURES=t.TextRenderingMode=t.StreamType=t.RenderingIntentFlag=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.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 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 i=0;i<t;i++)n+=arrayByteLength(e[i]);let i=0;const r=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 s=t.byteLength;r.set(t,i);i+=s}return r};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 i=[];for(let r=0;r<t;r+=n){const s=Math.min(r+n,t),o=e.subarray(r,s);i.push(String.fromCharCode.apply(null,o))}return i.join("")};t.createObjectURL=function createObjectURL(e,t="",n=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!n)return URL.createObjectURL(new Blob([e],{type:t}));const i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let r=`data:${t};base64,`;for(let t=0,n=e.length;t<n;t+=3){const s=255&e[t],o=255&e[t+1],a=255&e[t+2];r+=i[s>>2]+i[(3&s)<<4|o>>4]+i[t+1<n?(15&o)<<2|a>>6:64]+i[t+2<n?63&a:64]}return r};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});e.promise=new Promise((function(n,i){e.resolve=function(e){t=!0;n(e)};e.reject=function(e){t=!0;i(e)}}));return e};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t&&t.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=stringToUTF8String(e)}catch(e){}}const i=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}}(i))return i}catch(e){}return null};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 r};t.info=function info(e){r>=i.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;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0};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 i=new URL(t,n);return n.origin===i.origin};t.isString=function isString(e){return"string"==typeof e};t.objectFromMap=function objectFromMap(e){const t=Object.create(null);for(const[n,i]of e)t[n]=i;return t};t.objectSize=function objectSize(e){return Object.keys(e).length};t.removeNullCharacters=function removeNullCharacters(e,t=!1){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}t&&(e=e.replace(a," "));return e.replace(o,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(r=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 i=2;i<t;i+=2)n.push(String.fromCharCode(e.charCodeAt(i)<<8|e.charCodeAt(i+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let i=2;i<t;i+=2)n.push(String.fromCharCode(e.charCodeAt(i+1)<<8|e.charCodeAt(i)));else for(let i=0;i<t;++i){const t=d[e.charCodeAt(i)];n.push(t?String.fromCharCode(t):e.charAt(i))}return n.join("")};t.stringToUTF16BEString=function stringToUTF16BEString(e){const t=["þÿ"];for(let n=0,i=e.length;n<i;n++){const i=e.charCodeAt(n);t.push(String.fromCharCode(i>>8&255),String.fromCharCode(255&i))}return t.join("")};t.stringToUTF8String=stringToUTF8String;t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;n(2);t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};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",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const i={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=i;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",signatures:"signatures",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",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let r=i.WARNINGS;function warn(e){r>=i.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 s=function BaseExceptionClosure(){function BaseException(e,t){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=s;t.PasswordException=class PasswordException extends s{constructor(e,t){super(e,"PasswordException");this.code=t}};t.UnknownErrorException=class UnknownErrorException extends s{constructor(e,t){super(e,"UnknownErrorException");this.details=t}};t.InvalidPDFException=class InvalidPDFException extends s{constructor(e){super(e,"InvalidPDFException")}};t.MissingPDFException=class MissingPDFException extends s{constructor(e){super(e,"MissingPDFException")}};t.UnexpectedResponseException=class UnexpectedResponseException extends s{constructor(e,t){super(e,"UnexpectedResponseException");this.status=t}};t.FormatError=class FormatError extends s{constructor(e){super(e,"FormatError")}};t.AbortException=class AbortException extends s{constructor(e){super(e,"AbortException")}};const o=/\x00+/g,a=/[\x01-\x1F]/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let i=0;i<t;++i)n[i]=255&e.charCodeAt(i);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 c={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=c;const l={get value(){return shadow(this,"value",function isEvalSupported(){try{new Function("");return!0}catch(e){return!1}}())}};t.IsEvalSupportedCached=l;const h=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,n){return`#${h[e]}${h[t]}${h[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),i=Util.applyTransform(e.slice(2,4),t),r=Util.applyTransform([e[0],e[3]],t),s=Util.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],s[0]),Math.min(n[1],i[1],r[1],s[1]),Math.max(n[0],i[0],r[0],s[0]),Math.max(n[1],i[1],r[1],s[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],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],s=e[2]*t[1]+e[3]*t[3],o=(n+s)/2,a=Math.sqrt((n+s)**2-4*(n*s-r*i))/2,c=o+a||1,l=o-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),i=[e[1],e[3],t[1],t[3]].sort(compare),r=[];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;r[0]=n[1];r[2]=n[2];if(!(i[0]===e[1]&&i[1]===t[1]||i[0]===t[1]&&i[1]===e[1]))return null;r[1]=i[1];r[3]=i[2];return r}static bezierBoundingBox(e,t,n,i,r,s,o,a){const c=[],l=[[],[]];let h,d,f,u,p,g,m,b;for(let l=0;l<2;++l){if(0===l){d=6*e-12*n+6*r;h=-3*e+9*n-9*r+3*o;f=3*n-3*e}else{d=6*t-12*i+6*s;h=-3*t+9*i-9*s+3*a;f=3*i-3*t}if(Math.abs(h)<1e-12){if(Math.abs(d)<1e-12)continue;u=-f/d;0<u&&u<1&&c.push(u)}else{m=d*d-4*f*h;b=Math.sqrt(m);if(!(m<0)){p=(-d+b)/(2*h);0<p&&p<1&&c.push(p);g=(-d-b)/(2*h);0<g&&g<1&&c.push(g)}}}let y,x=c.length;const w=x;for(;x--;){u=c[x];y=1-u;l[0][x]=y*y*y*e+3*y*y*u*n+3*y*u*u*r+u*u*u*o;l[1][x]=y*y*y*t+3*y*y*u*i+3*y*u*u*s+u*u*u*a}l[0][w]=e;l[1][w]=t;l[0][w+1]=o;l[1][w+1]=a;l[0].length=l[1].length=w+2;return[Math.min(...l[0]),Math.min(...l[1]),Math.max(...l[0]),Math.max(...l[1])]}}t.Util=Util;const d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToUTF8String(e){return decodeURIComponent(escape(e))}},(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 i=n(1),r=n(5),s=n(8),o=n(9);class Jbig2Error extends i.BaseException{constructor(e){super(`JBIG2 error: ${e}`,"Jbig2Error")}}class ContextCache{getContexts(e){return e in this?this[e]:this[e]=new Int8Array(65536)}}class DecodingContext{constructor(e,t,n){this.data=e;this.start=t;this.end=n}get decoder(){const e=new s.ArithmeticDecoder(this.data,this.start,this.end);return(0,i.shadow)(this,"decoder",e)}get contextCache(){const e=new ContextCache;return(0,i.shadow)(this,"contextCache",e)}}function decodeInteger(e,t,n){const i=e.getContexts(t);let r=1;function readBits(e){let t=0;for(let s=0;s<e;s++){const e=n.readBit(i,r);r=r<256?r<<1|e:511&(r<<1|e)|256;t=t<<1|e}return t>>>0}const s=readBits(1),o=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===s?o:o>0?-o:null}function decodeIAID(e,t,n){const i=e.getContexts("IAID");let r=1;for(let e=0;e<n;e++){r=r<<1|t.readBit(i,r)}return n<31?r&(1<<n)-1:2147483647&r}const a=["SymbolDictionary",null,null,null,"IntermediateTextRegion",null,"ImmediateTextRegion","ImmediateLosslessTextRegion",null,null,null,null,null,null,null,null,"PatternDictionary",null,null,null,"IntermediateHalftoneRegion",null,"ImmediateHalftoneRegion","ImmediateLosslessHalftoneRegion",null,null,null,null,null,null,null,null,null,null,null,null,"IntermediateGenericRegion",null,"ImmediateGenericRegion","ImmediateLosslessGenericRegion","IntermediateGenericRefinementRegion",null,"ImmediateGenericRefinementRegion","ImmediateLosslessGenericRefinementRegion",null,null,null,null,"PageInformation","EndOfPage","EndOfStripe","EndOfFile","Profiles","Tables",null,null,null,null,null,null,null,null,"Extension"],c=[[{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}]],l=[{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}]}],h=[39717,1941,229,405],d=[32,8];function decodeBitmap(e,t,n,i,r,s,o,a){if(e){return decodeMMRBitmap(new Reader(a.data,a.start,a.end),t,n,!1)}if(0===i&&!s&&!r&&4===o.length&&3===o[0].x&&-1===o[0].y&&-3===o[1].x&&-1===o[1].y&&2===o[2].x&&-2===o[2].y&&-2===o[3].x&&-2===o[3].y)return function decodeBitmapTemplate0(e,t,n){const i=n.decoder,r=n.contextCache.getContexts("GB"),s=[];let o,a,c,l,h,d,f;for(a=0;a<t;a++){h=s[a]=new Uint8Array(e);d=a<1?h:s[a-1];f=a<2?h:s[a-2];o=f[0]<<13|f[1]<<12|f[2]<<11|d[0]<<7|d[1]<<6|d[2]<<5|d[3]<<4;for(c=0;c<e;c++){h[c]=l=i.readBit(r,o);o=(31735&o)<<1|(c+3<e?f[c+3]<<11:0)|(c+4<e?d[c+4]<<4:0)|l}}return s}(t,n,a);const l=!!s,d=c[i].concat(o);d.sort((function(e,t){return e.y-t.y||e.x-t.x}));const f=d.length,u=new Int8Array(f),p=new Int8Array(f),g=[];let m,b,y=0,x=0,w=0,T=0;for(b=0;b<f;b++){u[b]=d[b].x;p[b]=d[b].y;x=Math.min(x,d[b].x);w=Math.max(w,d[b].x);T=Math.min(T,d[b].y);b<f-1&&d[b].y===d[b+1].y&&d[b].x===d[b+1].x-1?y|=1<<f-1-b:g.push(b)}const C=g.length,S=new Int8Array(C),P=new Int8Array(C),I=new Uint16Array(C);for(m=0;m<C;m++){b=g[m];S[m]=d[b].x;P[m]=d[b].y;I[m]=1<<f-1-b}const E=-x,k=-T,B=t-w,A=h[i];let D=new Uint8Array(t);const _=[],L=a.decoder,R=a.contextCache.getContexts("GB");let v,O,M,F,U,N=0,H=0;for(let e=0;e<n;e++){if(r){N^=L.readBit(R,A);if(N){_.push(D);continue}}D=new Uint8Array(D);_.push(D);for(v=0;v<t;v++){if(l&&s[e][v]){D[v]=0;continue}if(v>=E&&v<B&&e>=k){H=H<<1&y;for(b=0;b<C;b++){O=e+P[b];M=v+S[b];F=_[O][M];if(F){F=I[b];H|=F}}}else{H=0;U=f-1;for(b=0;b<f;b++,U--){M=v+u[b];if(M>=0&&M<t){O=e+p[b];if(O>=0){F=_[O][M];F&&(H|=F<<U)}}}}const n=L.readBit(R,H);D[v]=n}}return _}function decodeRefinement(e,t,n,i,r,s,o,a,c){let h=l[n].coding;0===n&&(h=h.concat([a[0]]));const f=h.length,u=new Int32Array(f),p=new Int32Array(f);let g;for(g=0;g<f;g++){u[g]=h[g].x;p[g]=h[g].y}let m=l[n].reference;0===n&&(m=m.concat([a[1]]));const b=m.length,y=new Int32Array(b),x=new Int32Array(b);for(g=0;g<b;g++){y[g]=m[g].x;x[g]=m[g].y}const w=i[0].length,T=i.length,C=d[n],S=[],P=c.decoder,I=c.contextCache.getContexts("GR");let E=0;for(let n=0;n<t;n++){if(o){E^=P.readBit(I,C);if(E)throw new Jbig2Error("prediction is not supported")}const t=new Uint8Array(e);S.push(t);for(let o=0;o<e;o++){let a,c,l=0;for(g=0;g<f;g++){a=n+p[g];c=o+u[g];a<0||c<0||c>=e?l<<=1:l=l<<1|S[a][c]}for(g=0;g<b;g++){a=n+x[g]-s;c=o+y[g]-r;a<0||a>=T||c<0||c>=w?l<<=1:l=l<<1|i[a][c]}const h=P.readBit(I,l);t[o]=h}}return S}function decodeTextRegion(e,t,n,i,r,s,o,a,c,l,h,d,f,u,p,g,m,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");const x=[];let w,T;for(w=0;w<i;w++){T=new Uint8Array(n);if(r)for(let e=0;e<n;e++)T[e]=r;x.push(T)}const C=m.decoder,S=m.contextCache;let P=e?-u.tableDeltaT.decode(y):-decodeInteger(S,"IADT",C),I=0;w=0;for(;w<s;){P+=e?u.tableDeltaT.decode(y):decodeInteger(S,"IADT",C);I+=e?u.tableFirstS.decode(y):decodeInteger(S,"IAFS",C);let i=I;for(;;){let r=0;o>1&&(r=e?y.readBits(b):decodeInteger(S,"IAIT",C));const s=o*P+r,I=e?u.symbolIDTable.decode(y):decodeIAID(S,C,c),E=t&&(e?y.readBit():decodeInteger(S,"IARI",C));let k=a[I],B=k[0].length,A=k.length;if(E){const e=decodeInteger(S,"IARDW",C),t=decodeInteger(S,"IARDH",C),n=decodeInteger(S,"IARDX",C),i=decodeInteger(S,"IARDY",C);B+=e;A+=t;k=decodeRefinement(B,A,p,k,(e>>1)+n,(t>>1)+i,!1,g,m)}const D=s-(1&d?0:A-1),_=i-(2&d?B-1:0);let L,R,v;if(l){for(L=0;L<A;L++){T=x[_+L];if(!T)continue;v=k[L];const e=Math.min(n-D,B);switch(f){case 0:for(R=0;R<e;R++)T[D+R]|=v[R];break;case 2:for(R=0;R<e;R++)T[D+R]^=v[R];break;default:throw new Jbig2Error(`operator ${f} is not supported`)}}i+=A-1}else{for(R=0;R<A;R++){T=x[D+R];if(T){v=k[R];switch(f){case 0:for(L=0;L<B;L++)T[_+L]|=v[L];break;case 2:for(L=0;L<B;L++)T[_+L]^=v[L];break;default:throw new Jbig2Error(`operator ${f} is not supported`)}}}i+=B-1}w++;const O=e?u.tableDeltaS.decode(y):decodeInteger(S,"IADS",C);if(null===O)break;i+=O+h}}return x}function readSegmentHeader(e,t){const n={};n.number=(0,r.readUint32)(e,t);const i=e[t+4],s=63&i;if(!a[s])throw new Jbig2Error("invalid segment type: "+s);n.type=s;n.typeName=a[s];n.deferredNonRetain=!!(128&i);const o=!!(64&i),c=e[t+5];let l=c>>5&7;const h=[31&c];let d=t+6;if(7===c){l=536870911&(0,r.readUint32)(e,d-1);d+=3;let t=l+7>>3;h[0]=e[d++];for(;--t>0;)h.push(e[d++])}else if(5===c||6===c)throw new Jbig2Error("invalid referred-to flags");n.retainBits=h;let u=4;n.number<=256?u=1:n.number<=65536&&(u=2);const p=[];let g,m;for(g=0;g<l;g++){let t;t=1===u?e[d]:2===u?(0,r.readUint16)(e,d):(0,r.readUint32)(e,d);p.push(t);d+=u}n.referredTo=p;if(o){n.pageAssociation=(0,r.readUint32)(e,d);d+=4}else n.pageAssociation=e[d++];n.length=(0,r.readUint32)(e,d);d+=4;if(4294967295===n.length){if(38!==s)throw new Jbig2Error("invalid unknown segment length");{const t=readRegionSegmentInformation(e,d),i=!!(1&e[d+f]),r=6,s=new Uint8Array(r);if(!i){s[0]=255;s[1]=172}s[2]=t.height>>>24&255;s[3]=t.height>>16&255;s[4]=t.height>>8&255;s[5]=255&t.height;for(g=d,m=e.length;g<m;g++){let t=0;for(;t<r&&s[t]===e[g+t];)t++;if(t===r){n.length=g+r;break}}if(4294967295===n.length)throw new Jbig2Error("segment end was not found")}}n.headerEnd=d;return n}function readSegments(e,t,n,i){const r=[];let s=n;for(;s<i;){const n=readSegmentHeader(t,s);s=n.headerEnd;const i={header:n,data:t};if(!e.randomAccess){i.start=s;s+=n.length;i.end=s}r.push(i);if(51===n.type)break}if(e.randomAccess)for(let e=0,t=r.length;e<t;e++){r[e].start=s;s+=r[e].header.length;r[e].end=s}return r}function readRegionSegmentInformation(e,t){return{width:(0,r.readUint32)(e,t),height:(0,r.readUint32)(e,t+4),x:(0,r.readUint32)(e,t+8),y:(0,r.readUint32)(e,t+12),combinationOperator:7&e[t+16]}}const f=17;function processSegment(e,t){const n=e.header,i=e.data,s=e.end;let o,a,c,l,h=e.start;switch(n.type){case 0:const e={},t=(0,r.readUint16)(i,h);e.huffman=!!(1&t);e.refinement=!!(2&t);e.huffmanDHSelector=t>>2&3;e.huffmanDWSelector=t>>4&3;e.bitmapSizeSelector=t>>6&1;e.aggregationInstancesSelector=t>>7&1;e.bitmapCodingContextUsed=!!(256&t);e.bitmapCodingContextRetained=!!(512&t);e.template=t>>10&3;e.refinementTemplate=t>>12&1;h+=2;if(!e.huffman){l=0===e.template?4:1;a=[];for(c=0;c<l;c++){a.push({x:(0,r.readInt8)(i,h),y:(0,r.readInt8)(i,h+1)});h+=2}e.at=a}if(e.refinement&&!e.refinementTemplate){a=[];for(c=0;c<2;c++){a.push({x:(0,r.readInt8)(i,h),y:(0,r.readInt8)(i,h+1)});h+=2}e.refinementAt=a}e.numberOfExportedSymbols=(0,r.readUint32)(i,h);h+=4;e.numberOfNewSymbols=(0,r.readUint32)(i,h);h+=4;o=[e,n.number,n.referredTo,i,h,s];break;case 6:case 7:const d={};d.info=readRegionSegmentInformation(i,h);h+=f;const u=(0,r.readUint16)(i,h);h+=2;d.huffman=!!(1&u);d.refinement=!!(2&u);d.logStripSize=u>>2&3;d.stripSize=1<<d.logStripSize;d.referenceCorner=u>>4&3;d.transposed=!!(64&u);d.combinationOperator=u>>7&3;d.defaultPixelValue=u>>9&1;d.dsOffset=u<<17>>27;d.refinementTemplate=u>>15&1;if(d.huffman){const e=(0,r.readUint16)(i,h);h+=2;d.huffmanFS=3&e;d.huffmanDS=e>>2&3;d.huffmanDT=e>>4&3;d.huffmanRefinementDW=e>>6&3;d.huffmanRefinementDH=e>>8&3;d.huffmanRefinementDX=e>>10&3;d.huffmanRefinementDY=e>>12&3;d.huffmanRefinementSizeSelector=!!(16384&e)}if(d.refinement&&!d.refinementTemplate){a=[];for(c=0;c<2;c++){a.push({x:(0,r.readInt8)(i,h),y:(0,r.readInt8)(i,h+1)});h+=2}d.refinementAt=a}d.numberOfSymbolInstances=(0,r.readUint32)(i,h);h+=4;o=[d,n.referredTo,i,h,s];break;case 16:const p={},g=i[h++];p.mmr=!!(1&g);p.template=g>>1&3;p.patternWidth=i[h++];p.patternHeight=i[h++];p.maxPatternIndex=(0,r.readUint32)(i,h);h+=4;o=[p,n.number,i,h,s];break;case 22:case 23:const m={};m.info=readRegionSegmentInformation(i,h);h+=f;const b=i[h++];m.mmr=!!(1&b);m.template=b>>1&3;m.enableSkip=!!(8&b);m.combinationOperator=b>>4&7;m.defaultPixelValue=b>>7&1;m.gridWidth=(0,r.readUint32)(i,h);h+=4;m.gridHeight=(0,r.readUint32)(i,h);h+=4;m.gridOffsetX=4294967295&(0,r.readUint32)(i,h);h+=4;m.gridOffsetY=4294967295&(0,r.readUint32)(i,h);h+=4;m.gridVectorX=(0,r.readUint16)(i,h);h+=2;m.gridVectorY=(0,r.readUint16)(i,h);h+=2;o=[m,n.referredTo,i,h,s];break;case 38:case 39:const y={};y.info=readRegionSegmentInformation(i,h);h+=f;const x=i[h++];y.mmr=!!(1&x);y.template=x>>1&3;y.prediction=!!(8&x);if(!y.mmr){l=0===y.template?4:1;a=[];for(c=0;c<l;c++){a.push({x:(0,r.readInt8)(i,h),y:(0,r.readInt8)(i,h+1)});h+=2}y.at=a}o=[y,i,h,s];break;case 48:const w={width:(0,r.readUint32)(i,h),height:(0,r.readUint32)(i,h+4),resolutionX:(0,r.readUint32)(i,h+8),resolutionY:(0,r.readUint32)(i,h+12)};4294967295===w.height&&delete w.height;const T=i[h+16];(0,r.readUint16)(i,h+17);w.lossless=!!(1&T);w.refinement=!!(2&T);w.defaultPixelValue=T>>2&1;w.combinationOperator=T>>3&3;w.requiresBuffer=!!(32&T);w.combinationOperatorOverride=!!(64&T);o=[w];break;case 49:case 50:case 51:case 62:break;case 53:o=[n.number,i,h,s];break;default:throw new Jbig2Error(`segment type ${n.typeName}(${n.type}) is not implemented`)}const d="on"+n.typeName;d in t&&t[d].apply(t,o)}function processSegments(e,t){for(let n=0,i=e.length;n<i;n++)processSegment(e[n],t)}class SimpleSegmentVisitor{onPageInformation(e){this.currentPageInfo=e;const t=e.width+7>>3,n=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(let e=0,t=n.length;e<t;e++)n[e]=255;this.buffer=n}drawBitmap(e,t){const n=this.currentPageInfo,i=e.width,r=e.height,s=n.width+7>>3,o=n.combinationOperatorOverride?e.combinationOperator:n.combinationOperator,a=this.buffer,c=128>>(7&e.x);let l,h,d,f,u=e.y*s+(e.x>>3);switch(o){case 0:for(l=0;l<r;l++){d=c;f=u;for(h=0;h<i;h++){t[l][h]&&(a[f]|=d);d>>=1;if(!d){d=128;f++}}u+=s}break;case 2:for(l=0;l<r;l++){d=c;f=u;for(h=0;h<i;h++){t[l][h]&&(a[f]^=d);d>>=1;if(!d){d=128;f++}}u+=s}break;default:throw new Jbig2Error(`operator ${o} is not supported`)}}onImmediateGenericRegion(e,t,n,i){const r=e.info,s=new DecodingContext(t,n,i),o=decodeBitmap(e.mmr,r.width,r.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(r,o)}onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)}onSymbolDictionary(e,t,n,i,s,o){let a,c;if(e.huffman){a=function getSymbolDictionaryHuffmanTables(e,t,n){let i,r,s,o,a=0;switch(e.huffmanDHSelector){case 0:case 1:i=getStandardTable(e.huffmanDHSelector+4);break;case 3:i=getCustomHuffmanTable(a,t,n);a++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:r=getStandardTable(e.huffmanDWSelector+2);break;case 3:r=getCustomHuffmanTable(a,t,n);a++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){s=getCustomHuffmanTable(a,t,n);a++}else s=getStandardTable(1);o=e.aggregationInstancesSelector?getCustomHuffmanTable(a,t,n):getStandardTable(1);return{tableDeltaHeight:i,tableDeltaWidth:r,tableBitmapSize:s,tableAggregateInstances:o}}(e,n,this.customTables);c=new Reader(i,s,o)}let l=this.symbols;l||(this.symbols=l={});let h=[];for(let e=0,t=n.length;e<t;e++){const t=l[n[e]];t&&(h=h.concat(t))}const d=new DecodingContext(i,s,o);l[t]=function decodeSymbolDictionary(e,t,n,i,s,o,a,c,l,h,d,f){if(e&&t)throw new Jbig2Error("symbol refinement with Huffman is not supported");const u=[];let p=0,g=(0,r.log2)(n.length+i);const m=d.decoder,b=d.contextCache;let y,x;if(e){y=getStandardTable(1);x=[];g=Math.max(g,1)}for(;u.length<i;){p+=e?o.tableDeltaHeight.decode(f):decodeInteger(b,"IADH",m);let i=0,r=0;const s=e?x.length:0;for(;;){const s=e?o.tableDeltaWidth.decode(f):decodeInteger(b,"IADW",m);if(null===s)break;i+=s;r+=i;let y;if(t){const r=decodeInteger(b,"IAAI",m);if(r>1)y=decodeTextRegion(e,t,i,p,0,r,1,n.concat(u),g,0,0,1,0,o,l,h,d,0,f);else{const e=decodeIAID(b,m,g),t=decodeInteger(b,"IARDX",m),r=decodeInteger(b,"IARDY",m);y=decodeRefinement(i,p,l,e<n.length?n[e]:u[e-n.length],t,r,!1,h,d)}u.push(y)}else if(e)x.push(i);else{y=decodeBitmap(!1,i,p,a,!1,null,c,d);u.push(y)}}if(e&&!t){const e=o.tableBitmapSize.decode(f);f.byteAlign();let t;if(0===e)t=readUncompressedBitmap(f,r,p);else{const n=f.end,i=f.position+e;f.end=i;t=decodeMMRBitmap(f,r,p,!1);f.end=n;f.position=i}const n=x.length;if(s===n-1)u.push(t);else{let e,i,r,o,a,c=0;for(e=s;e<n;e++){o=x[e];r=c+o;a=[];for(i=0;i<p;i++)a.push(t[i].subarray(c,r));u.push(a);c=r}}}}const w=[],T=[];let C,S,P=!1;const I=n.length+i;for(;T.length<I;){let t=e?y.decode(f):decodeInteger(b,"IAEX",m);for(;t--;)T.push(P);P=!P}for(C=0,S=n.length;C<S;C++)T[C]&&w.push(n[C]);for(let e=0;e<i;C++,e++)T[C]&&w.push(u[e]);return w}(e.huffman,e.refinement,h,e.numberOfNewSymbols,e.numberOfExportedSymbols,a,e.template,e.at,e.refinementTemplate,e.refinementAt,d,c)}onImmediateTextRegion(e,t,n,i,s){const o=e.info;let a,c;const l=this.symbols;let h=[];for(let e=0,n=t.length;e<n;e++){const n=l[t[e]];n&&(h=h.concat(n))}const d=(0,r.log2)(h.length);if(e.huffman){c=new Reader(n,i,s);a=function getTextRegionHuffmanTables(e,t,n,i,r){const s=[];for(let e=0;e<=34;e++){const t=r.readBits(4);s.push(new HuffmanLine([e,t,0,0]))}const o=new HuffmanTable(s,!1);s.length=0;for(let e=0;e<i;){const t=o.decode(r);if(t>=32){let n,i,o;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");i=r.readBits(2)+3;n=s[e-1].prefixLength;break;case 33:i=r.readBits(3)+3;n=0;break;case 34:i=r.readBits(7)+11;n=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(o=0;o<i;o++){s.push(new HuffmanLine([e,n,0,0]));e++}}else{s.push(new HuffmanLine([e,t,0,0]));e++}}r.byteAlign();const a=new HuffmanTable(s,!1);let c,l,h,d=0;switch(e.huffmanFS){case 0:case 1:c=getStandardTable(e.huffmanFS+6);break;case 3:c=getCustomHuffmanTable(d,t,n);d++;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(d,t,n);d++;break;default:throw new Jbig2Error("invalid Huffman DS selector")}switch(e.huffmanDT){case 0:case 1:case 2:h=getStandardTable(e.huffmanDT+11);break;case 3:h=getCustomHuffmanTable(d,t,n);d++;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:h}}(e,t,this.customTables,h.length,c)}const f=new DecodingContext(n,i,s),u=decodeTextRegion(e.huffman,e.refinement,o.width,o.height,e.defaultPixelValue,e.numberOfSymbolInstances,e.stripSize,h,d,e.transposed,e.dsOffset,e.referenceCorner,e.combinationOperator,a,e.refinementTemplate,e.refinementAt,f,e.logStripSize,c);this.drawBitmap(o,u)}onImmediateLosslessTextRegion(){this.onImmediateTextRegion.apply(this,arguments)}onPatternDictionary(e,t,n,i,r){let s=this.patterns;s||(this.patterns=s={});const o=new DecodingContext(n,i,r);s[t]=function decodePatternDictionary(e,t,n,i,r,s){const o=[];if(!e){o.push({x:-t,y:0});0===r&&o.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const a=decodeBitmap(e,(i+1)*t,n,r,!1,null,o,s),c=[];for(let e=0;e<=i;e++){const i=[],r=t*e,s=r+t;for(let e=0;e<n;e++)i.push(a[e].subarray(r,s));c.push(i)}return c}(e.mmr,e.patternWidth,e.patternHeight,e.maxPatternIndex,e.template,o)}onImmediateHalftoneRegion(e,t,n,i,s){const o=this.patterns[t[0]],a=e.info,c=new DecodingContext(n,i,s),l=function decodeHalftoneRegion(e,t,n,i,s,o,a,c,l,h,d,f,u,p,g){if(a)throw new Jbig2Error("skip is not supported");if(0!==c)throw new Jbig2Error(`operator "${c}" is not supported in halftone region`);const m=[];let b,y,x;for(b=0;b<s;b++){x=new Uint8Array(i);if(o)for(y=0;y<i;y++)x[y]=o;m.push(x)}const w=t.length,T=t[0],C=T[0].length,S=T.length,P=(0,r.log2)(w),I=[];if(!e){I.push({x:n<=1?3:2,y:-1});0===n&&I.push({x:-3,y:-1},{x:2,y:-2},{x:-2,y:-2})}const E=[];let k,B,A,D,_,L,R,v,O,M,F;e&&(k=new Reader(g.data,g.start,g.end));for(b=P-1;b>=0;b--){B=e?decodeMMRBitmap(k,l,h,!0):decodeBitmap(!1,l,h,n,!1,null,I,g);E[b]=B}for(A=0;A<h;A++)for(D=0;D<l;D++){_=0;L=0;for(y=P-1;y>=0;y--){_^=E[y][A][D];L|=_<<y}R=t[L];v=d+A*p+D*u>>8;O=f+A*u-D*p>>8;if(v>=0&&v+C<=i&&O>=0&&O+S<=s)for(b=0;b<S;b++){F=m[O+b];M=R[b];for(y=0;y<C;y++)F[v+y]|=M[y]}else{let e,t;for(b=0;b<S;b++){t=O+b;if(!(t<0||t>=s)){F=m[t];M=R[b];for(y=0;y<C;y++){e=v+y;e>=0&&e<i&&(F[e]|=M[y])}}}}}return m}(e.mmr,o,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,i){let s=this.customTables;s||(this.customTables=s={});s[e]=function decodeTablesSegment(e,t,n){const i=e[t],s=4294967295&(0,r.readUint32)(e,t+1),o=4294967295&(0,r.readUint32)(e,t+5),a=new Reader(e,t+9,n),c=1+(i>>1&7),l=1+(i>>4&7),h=[];let d,f,u=s;do{d=a.readBits(c);f=a.readBits(l);h.push(new HuffmanLine([u,d,f,0]));u+=1<<f}while(u<o);d=a.readBits(c);h.push(new HuffmanLine([s-1,d,32,0,"lower"]));d=a.readBits(c);h.push(new HuffmanLine([o,d,32,0]));if(1&i){d=a.readBits(c);h.push(new HuffmanLine([d,0]))}return new HuffmanTable(h,!1)}(t,n,i)}}class HuffmanLine{constructor(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]}}}class HuffmanTreeNode{constructor(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}buildTree(e,t){const n=e.prefixCode>>t&1;if(t<=0)this.children[n]=new HuffmanTreeNode(e);else{let i=this.children[n];i||(this.children[n]=i=new HuffmanTreeNode(null));i.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)}}class HuffmanTable{constructor(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)}}decode(e){return this.rootNode.decodeNode(e)}assignPrefixCodes(e){const t=e.length;let n=0;for(let i=0;i<t;i++)n=Math.max(n,e[i].prefixLength);const i=new Uint32Array(n+1);for(let n=0;n<t;n++)i[e[n].prefixLength]++;let r,s,o,a=1,c=0;i[0]=0;for(;a<=n;){c=c+i[a-1]<<1;r=c;s=0;for(;s<t;){o=e[s];if(o.prefixLength===a){o.prefixCode=r;r++}s++}a++}}}const u={};function getStandardTable(e){let t,n=u[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);u[e]=n;return n}class Reader{constructor(e,t,n){this.data=e;this.start=t;this.end=n;this.position=t;this.shift=-1;this.currentByte=0}readBit(){if(this.shift<0){if(this.position>=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const 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 i=0;for(let r=0,s=t.length;r<s;r++){const s=n[t[r]];if(s){if(e===i)return s;i++}}throw new Jbig2Error("can't find custom Huffman table")}function readUncompressedBitmap(e,t,n){const i=[];for(let r=0;r<n;r++){const n=new Uint8Array(t);i.push(n);for(let i=0;i<t;i++)n[i]=e.readBit();e.byteAlign()}return i}function decodeMMRBitmap(e,t,n,i){const r={K:-1,Columns:t,Rows:n,BlackIs1:!0,EndOfBlock:i},s=new o.CCITTFaxDecoder(e,r),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 i=0;i<t;i++){if(n<0){c=s.readNextChar();if(-1===c){c=0;l=!0}n=7}e[i]=c>>n&1;n--}}if(i&&!l){const e=5;for(let t=0;t<e&&-1!==s.readNextChar();t++);}return a}t.Jbig2Image=class Jbig2Image{parseChunks(e){return function parseJbig2Chunks(e){const t=new SimpleSegmentVisitor;for(let n=0,i=e.length;n<i;n++){const i=e[n];processSegments(readSegments({},i.data,i.start,i.end),t)}return t.buffer}(e)}parse(e){const{imgData:t,width:n,height:i}=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 i=Object.create(null);n+=8;const s=e[n++];i.randomAccess=!(1&s);if(!(2&s)){i.numberOfPages=(0,r.readUint32)(e,n);n+=4}const o=readSegments(i,e,n,t),a=new SimpleSegmentVisitor;processSegments(o,a);const{width:c,height:l}=a.currentPageInfo,h=a.buffer,d=new Uint8ClampedArray(c*l);let f=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=h[u++]}d[f++]=e&t?0:255;t>>=1}}return{imgData:d,width:c,height:l}}(e);this.width=n;this.height=i;return t}}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.XRefParseException=t.XRefEntryException=t.ParserEOFException=t.MissingDataException=t.DocStats=void 0;t.collectActions=function collectActions(e,t,n){const s=Object.create(null),o=getInheritableProperty({dict:t,key:"AA",stopWhenFound:!1});if(o)for(let t=o.length-1;t>=0;t--){const i=o[t];if(i instanceof r.Dict)for(const t of i.getKeys()){const o=n[t];if(!o)continue;const a=i.getRaw(t),c=new r.RefSet,l=[];_collectJS(a,e,l,c);l.length>0&&(s[o]=l)}}if(t.has("A")){const n=t.get("A"),i=new r.RefSet,o=[];_collectJS(n,e,o,i);o.length>0&&(s.Action=o)}return(0,i.objectSize)(s)>0?s:null};t.encodeToXmlString=function encodeToXmlString(e){const t=[];let n=0;for(let i=0,r=e.length;i<r;i++){const r=e.codePointAt(i);if(32<=r&&r<=126){const s=o[r];if(s){n<i&&t.push(e.substring(n,i));t.push(s);n=i+1}}else{n<i&&t.push(e.substring(n,i));t.push(`&#x${r.toString(16).toUpperCase()};`);r>55295&&(r<57344||r>65533)&&i++;n=i+1}}if(0===t.length)return e;n<e.length&&t.push(e.substring(n,e.length));return t.join("")};t.escapePDFName=function escapePDFName(e){const t=[];let n=0;for(let i=0,r=e.length;i<r;i++){const r=e.charCodeAt(i);if(r<33||r>126||35===r||40===r||41===r||60===r||62===r||91===r||93===r||123===r||125===r||47===r||37===r){n<i&&t.push(e.substring(n,i));t.push(`#${r.toString(16)}`);n=i+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,i=n.length;e<i;e+=2)t[n[e]]=n[e+1];n=null}return t}};t.getInheritableProperty=getInheritableProperty;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=/(.+)\[(\d+)\]$/;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.recoverJsURL=function recoverJsURL(e){const t=new RegExp("^\\s*("+["app.launchURL","window.open","xfa.host.gotoURL"].join("|").split(".").join("\\.")+")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))","i").exec(e);if(t&&t[2]){const e=t[2];let n=!1;"true"===t[3]&&"app.launchURL"===t[1]&&(n=!0);return{url:e,newWindow:n}}return null};t.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,i.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const n=[];let r;for(;e>=1e3;){e-=1e3;n.push("M")}r=e/100|0;e%=100;n.push(s[r]);r=e/10|0;e%=10;n.push(s[10+r]);n.push(s[20+e]);const o=n.join("");return t?o.toLowerCase():o};t.validateCSSFont=function validateCSSFont(e){const t=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:n,fontWeight:r,italicAngle:s}=e;if(/^".*"$/.test(n)){if(/[^\\]"/.test(n.slice(1,n.length-1))){(0,i.warn)(`XFA - FontFamily contains some unescaped ": ${n}.`);return!1}}else if(/^'.*'$/.test(n)){if(/[^\\]'/.test(n.slice(1,n.length-1))){(0,i.warn)(`XFA - FontFamily contains some unescaped ': ${n}.`);return!1}}else for(const e of n.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(e)||!/^[\w-\\]+$/.test(e)){(0,i.warn)(`XFA - FontFamily contains some invalid <custom-ident>: ${n}.`);return!1}const o=r?r.toString():"";e.fontWeight=t.has(o)?o:"400";const a=parseFloat(s);e.italicAngle=isNaN(a)||a<-90||a>90?"14":s.toString();return!0};var i=n(1),r=n(6);class MissingDataException extends i.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException");this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class ParserEOFException extends i.BaseException{constructor(e){super(e,"ParserEOFException")}}t.ParserEOFException=ParserEOFException;class XRefEntryException extends i.BaseException{constructor(e){super(e,"XRefEntryException")}}t.XRefEntryException=XRefEntryException;class XRefParseException extends i.BaseException{constructor(e){super(e,"XRefParseException")}}t.XRefParseException=XRefParseException;t.DocStats=class DocStats{constructor(e){this._handler=e;this._streamTypes=new Set;this._fontTypes=new Set}_send(){const e=Object.create(null),t=Object.create(null);for(const t of this._streamTypes)e[t]=!0;for(const e of this._fontTypes)t[e]=!0;this._handler.send("DocStats",{streamTypes:e,fontTypes:t})}addStreamType(e){if(!this._streamTypes.has(e)){this._streamTypes.add(e);this._send()}}addFontType(e){if(!this._fontTypes.has(e)){this._fontTypes.add(e);this._send()}}};function getInheritableProperty({dict:e,key:t,getArray:n=!1,stopWhenFound:i=!0}){let s;const o=new r.RefSet;for(;e instanceof r.Dict&&(!e.objId||!o.has(e.objId));){e.objId&&o.put(e.objId);const r=n?e.getArray(t):e.get(t);if(void 0!==r){if(i)return r;s||(s=[]);s.push(r)}e=e.get("Parent")}return s}const s=["","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,s){if(!e)return;let o=null;if((0,r.isRef)(e)){if(s.has(e))return;o=e;s.put(o);e=t.fetch(e)}if(Array.isArray(e))for(const i of e)_collectJS(i,t,n,s);else if(e instanceof r.Dict){if((0,r.isName)(e.get("S"),"JavaScript")&&e.has("JS")){const t=e.get("JS");let s;s=(0,r.isStream)(t)?t.getString():t;s=(0,i.stringToPDFString)(s);s&&n.push(s)}_collectJS(e.getRaw("Next"),t,n,s)}o&&s.remove(o)}const o={60:"&lt;",62:"&gt;",38:"&amp;",34:"&quot;",39:"&apos;"}},(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.RefSetCache=t.RefSet=t.Ref=t.Name=t.EOF=t.Dict=t.Cmd=t.CIRCULAR_REF=void 0;t.clearPrimitiveCaches=function clearPrimitiveCaches(){c._clearCache();a._clearCache();h._clearCache()};t.isCmd=function isCmd(e,t){return e instanceof c&&(void 0===t||e.cmd===t)};t.isDict=function isDict(e,t){return e instanceof Dict&&(void 0===t||isName(e.get("Type"),t))};t.isName=isName;t.isRef=function isRef(e){return e instanceof h};t.isRefsEqual=function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen};t.isStream=function isStream(e){return e instanceof r.BaseStream};var i=n(1),r=n(7);const s=Symbol("CIRCULAR_REF");t.CIRCULAR_REF=s;const o=Symbol("EOF");t.EOF=o;const a=function NameClosure(){let e=Object.create(null);class Name{constructor(e){this.name=e}static get(t){const n=e[t];return n||(e[t]=new Name(t))}static _clearCache(){e=Object.create(null)}}return Name}();t.Name=a;const c=function CmdClosure(){let e=Object.create(null);class Cmd{constructor(e){this.cmd=e}static get(t){const n=e[t];return n||(e[t]=new Cmd(t))}static _clearCache(){e=Object.create(null)}}return Cmd}();t.Cmd=c;const l=function nonSerializableClosure(){return l};class Dict{cons