/*! For license information please see pdf.worker.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf.worker",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf.worker"]=t():e["pdfjs-dist/build/pdf.worker"]=e.pdfjsWorker=t()}(this,(function(){return function(e){var t={};function a(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=e,a.c=t,a.d=function(e,t,r){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(a.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)a.d(r,i,function(t){return e[t]}.bind(null,i));return r},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){"use strict";const r=a(1);t.WorkerMessageHandler=r.WorkerMessageHandler},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WorkerMessageHandler=t.WorkerTask=void 0;var r=a(2),i=a(4),n=a(5),s=a(44),o=a(45),c=a(46),l=a(7),h=function(){function e(e){this.name=e,this.terminated=!1,this._capability=(0,r.createPromiseCapability)()}return e.prototype={get finished(){return this._capability.promise},finish(){this._capability.resolve()},terminate(){this.terminated=!0},ensureNotTerminated(){if(this.terminated)throw new Error("Worker task was terminated")}},e}();t.WorkerTask=h;var u,d={setup(e,t){var a=!1;e.on("test",(function(t){if(a)return;if(a=!0,!(t instanceof Uint8Array))return void e.send("test",null);const r=255===t[0];e.postMessageTransfers=r,e.send("test",{supportTransfers:r})})),e.on("configure",(function(e){(0,r.setVerbosityLevel)(e.verbosity)})),e.on("GetDocRequest",(function(e){return d.createDocumentHandler(e,t)}))},createDocumentHandler(e,t){var a,s=!1,u=null,d=[];const f=(0,r.getVerbosityLevel)(),g=e.apiVersion;if("2.4.456"!==g)throw new Error(`The API version "${g}" does not match the Worker version "2.4.456".`);const m=[];for(const e in[])m.push(e);if(m.length)throw new Error("The `Array.prototype` contains unexpected enumerable properties: "+m.join(", ")+"; thus breaking e.g. `for...in` iteration of `Array`s.");var p=e.docId,b=e.docBaseUrl,y=e.docId+"_worker",v=new o.MessageHandler(y,p,t);function w(){if(s)throw new Error("Worker was terminated")}function k(e){d.push(e)}function S(e){e.finish();var t=d.indexOf(e);d.splice(t,1)}async function C(e){await a.ensureDoc("checkHeader"),await a.ensureDoc("parseStartXRef"),await a.ensureDoc("parse",[e]),e||await a.ensureDoc("checkFirstPage");const[t,r]=await Promise.all([a.ensureDoc("numPages"),a.ensureDoc("fingerprint")]);return{numPages:t,fingerprint:r}}function x(e,t){var a,i=(0,r.createPromiseCapability)(),s=e.source;if(s.data){try{a=new n.LocalPdfManager(p,s.data,s.password,t,b),i.resolve(a)}catch(e){i.reject(e)}return i.promise}var o,l=[];try{o=new c.PDFWorkerStream(v)}catch(e){return i.reject(e),i.promise}var h=o.getFullReader();h.headersReady.then((function(){if(h.isRangeSupported){var e=s.disableAutoFetch||h.isStreamingSupported;a=new n.NetworkPdfManager(p,o,{msgHandler:v,password:s.password,length:h.contentLength,disableAutoFetch:e,rangeChunkSize:s.rangeChunkSize},t,b);for(let e=0;e=r.VerbosityLevel.INFOS?Date.now():0;a.getOperatorList({handler:v,sink:t,task:n,intent:e.intent,renderInteractiveForms:e.renderInteractiveForms}).then((function(e){S(n),s&&(0,r.info)(`page=${i+1} - getOperatorList: time=${Date.now()-s}ms, len=${e.length}`),t.close()}),(function(e){S(n),n.terminated||(v.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.unknown}),t.error(e))}))}))}),this),v.on("GetTextContent",(function(e,t){var i=e.pageIndex;t.onPull=function(e){},t.onCancel=function(e){},a.getPage(i).then((function(a){var n=new h("GetTextContent: page "+i);k(n);const s=f>=r.VerbosityLevel.INFOS?Date.now():0;a.extractTextContent({handler:v,task:n,sink:t,normalizeWhitespace:e.normalizeWhitespace,combineTextItems:e.combineTextItems}).then((function(){S(n),s&&(0,r.info)(`page=${i+1} - getTextContent: time=`+(Date.now()-s)+"ms"),t.close()}),(function(e){S(n),n.terminated||t.error(e)}))}))})),v.on("FontFallback",(function(e){return a.fontFallback(e.id,v)})),v.on("Cleanup",(function(e){return a.cleanup()})),v.on("Terminate",(function(e){s=!0;const t=[];if(a){a.terminate(new r.AbortException("Worker was terminated."));const e=a.cleanup();t.push(e),a=null}else(0,i.clearPrimitiveCaches)();return u&&u(new r.AbortException("Worker was terminated.")),d.forEach((function(e){t.push(e.finished),e.terminate()})),Promise.all(t).then((function(){v.destroy(),v=null}))})),v.on("Ready",(function(t){!function(e){function t(e){w(),v.send("GetDoc",{pdfInfo:e})}function i(e){if(w(),e instanceof r.PasswordException){var t=new h("PasswordException: response "+e.code);k(t),v.sendWithPromise("PasswordRequest",e).then((function(e){S(t),a.updatePassword(e.password),n()})).catch((function(){S(t),v.send("DocException",e)}))}else e instanceof r.InvalidPDFException||e instanceof r.MissingPDFException||e instanceof r.UnexpectedResponseException||e instanceof r.UnknownErrorException?v.send("DocException",e):v.send("DocException",new r.UnknownErrorException(e.message,e.toString()))}function n(){w(),C(!1).then(t,(function(e){w(),e instanceof l.XRefParseException?(a.requestLoadedStream(),a.onLoadedStream().then((function(){w(),C(!0).then(t,i)}))):i(e)}),i)}w(),x(e,{forceDataSchema:e.disableCreateObjectURL,maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,nativeImageDecoderSupport:e.nativeImageDecoderSupport,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported}).then((function(e){if(s)throw e.terminate(new r.AbortException("Worker was terminated.")),new Error("Worker was terminated");(a=e).onLoadedStream().then((function(e){v.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(n,i)}(e),e=null})),y},initializeFromPort(e){var t=new o.MessageHandler("worker","main",e);d.setup(t,e),t.send("ready",null)}};t.WorkerMessageHandler=d,"undefined"==typeof window&&!s.isNodeJS&&"undefined"!=typeof self&&"function"==typeof(u=self).postMessage&&"onmessage"in u&&d.initializeFromPort(self)},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.arrayByteLength=d,t.arraysToBytes=function(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let a=0;for(let r=0;rt}),e.promise=new Promise((function(a,r){e.resolve=function(e){t=!0,a(e)},e.reject=function(e){t=!0,r(e)}})),e},t.getVerbosityLevel=function(){return i},t.info=function(e){i>=r.INFOS&&console.log("Info: "+e)},t.isArrayBuffer=function(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength},t.isArrayEqual=function(e,t){return e.length===t.length&&e.every((function(e,a){return e===t[a]}))},t.isBool=function(e){return"boolean"==typeof e},t.isEmptyObj=function(e){for(const t in e)return!1;return!0},t.isNum=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSameOrigin=function(e,t){let a;try{if(a=new URL(e),!a.origin||"null"===a.origin)return!1}catch(e){return!1}const r=new URL(t,a);return a.origin===r.origin},t.createValidAbsoluteUrl=function(e,t){if(!e)return null;try{const a=t?new URL(e,t):new URL(e);if(function(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(a))return a}catch(e){}return null},t.removeNullCharacters=function(e){return"string"!=typeof e?(n("The argument for removeNullCharacters must be a string."),e):e.replace(h,"")},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(i=e)},t.shadow=c,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=u,t.stringToPDFString=function(e){const t=e.length,a=[];if("þ"===e[0]&&"ÿ"===e[1])for(let r=2;r=r.WARNINGS&&console.log("Warning: "+e)}function s(e){throw new Error(e)}function o(e,t){e||s(t)}function c(e,t,a){return Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!1}),a}const l=function(){function e(t){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=this.constructor.name}return e.prototype=new Error,e.constructor=e,e}();t.BaseException=l,t.PasswordException=class extends l{constructor(e,t){super(e),this.code=t}},t.UnknownErrorException=class extends l{constructor(e,t){super(e),this.details=t}},t.InvalidPDFException=class extends l{},t.MissingPDFException=class extends l{},t.UnexpectedResponseException=class extends l{constructor(e,t){super(e),this.status=t}},t.FormatError=class extends l{},t.AbortException=class extends l{};const h=/\x00/g;function u(e){o("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,a=new Uint8Array(t);for(let r=0;re[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){function a(e,t){return e-t}const r=[e[0],e[2],t[0],t[2]].sort(a),i=[e[1],e[3],t[1],t[3]].sort(a),n=[];return e=p.normalizeRect(e),t=p.normalizeRect(t),r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]?(n[0]=r[1],n[2]=r[2],i[0]===e[1]&&i[1]===t[1]||i[0]===t[1]&&i[1]===e[1]?(n[1]=i[1],n[3]=i[2],n):null):null}}t.Util=p;const b=[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],y=function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function(t,a,r=!1){if(!r&&URL.createObjectURL){const e=new Blob([t],{type:a});return URL.createObjectURL(e)}let i=`data:${a};base64,`;for(let a=0,r=t.length;a>2]+e[(3&n)<<4|s>>4]+e[a+1>6:64]+e[a+2=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=a;e=t)return;if(t<=this.progressiveDataLength)return;const a=this.chunkSize,r=Math.floor(e/a),n=Math.floor((t-1)/a)+1;for(let a=r;a=this.end?-1:(e>=this.progressiveDataLength&&this.ensureByte(e),this.bytes[this.pos++])}getUint16(){const e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t}getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()}getBytes(e,t=!1){const a=this.bytes,r=this.pos,i=this.end;if(!e){i>this.progressiveDataLength&&this.ensureRange(r,i);const e=a.subarray(r,i);return t?new Uint8ClampedArray(e):e}let n=r+e;n>i&&(n=i),n>this.progressiveDataLength&&this.ensureRange(r,n),this.pos=n;const s=a.subarray(r,n);return t?new Uint8ClampedArray(s):s}peekByte(){const e=this.getByte();return-1!==e&&this.pos--,e}peekBytes(e,t=!1){const a=this.getBytes(e,t);return this.pos-=a.length,a}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),t>this.progressiveDataLength&&this.ensureRange(e,t),this.bytes.subarray(e,t)}skip(e){e||(e=1),this.pos+=e}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,a){function r(){}t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e),r.prototype=Object.create(this),r.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),a=Math.floor((this.end-1)/e)+1,r=[];for(let e=t;e{const s=o=>{try{if(!o.done){const e=o.value;return i.push(e),n+=(0,r.arrayByteLength)(e),a.isStreamingSupported&&this.onProgress({loaded:n}),void a.read().then(s,t)}const c=(0,r.arraysToBytes)(i);i=null,e(c)}catch(e){t(e)}};a.read().then(s,t)}).then(t=>{this.aborted||this.onReceiveData({chunk:t,begin:e})})}requestAllChunks(){const e=this.stream.getMissingChunks();return this._requestChunks(e),this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,a=Object.create(null);this.chunksNeededByRequest[t]=a;for(const t of e)this.stream.hasChunk(t)||(a[t]=!0);if((0,r.isEmptyObj)(a))return Promise.resolve();const i=(0,r.createPromiseCapability)();this.promisesByRequest[t]=i;const n=[];for(let e in a)e|=0,e in this.requestsByChunk||(this.requestsByChunk[e]=[],n.push(e)),this.requestsByChunk[e].push(t);if(!n.length)return i.promise;const s=this.groupChunks(n);for(const e of s){const t=e.beginChunk*this.chunkSize,a=Math.min(e.endChunk*this.chunkSize,this.length);this.sendRequest(t,a)}return i.promise}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const a=this.getBeginChunk(e),r=this.getEndChunk(t),i=[];for(let e=a;e=0&&r+1!==n&&(t.push({beginChunk:a,endChunk:r+1}),a=n),i+1===e.length&&t.push({beginChunk:a,endChunk:n+1}),r=n}return t}onProgress(e){this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize+e.loaded,total:this.length})}onReceiveData(e){const t=e.chunk,a=void 0===e.begin,i=a?this.progressiveDataLength:e.begin,n=i+t.byteLength,s=Math.floor(i/this.chunkSize),o=n100){(0,r.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return n},t.toRomanNumerals=function(e,t=!1){(0,r.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const a=[];let i;for(;e>=1e3;)e-=1e3,a.push("M");i=e/100|0,e%=100,a.push(o[i]),i=e/10|0,e%=10,a.push(o[10+i]),a.push(o[20+e]);const n=a.join("");return t?n.toLowerCase():n},t.log2=function(e){return e<=0?0:Math.ceil(Math.log2(e))},t.readInt8=function(e,t){return e[t]<<24>>24},t.readUint16=function(e,t){return e[t]<<8|e[t+1]},t.readUint32=function(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0},t.isWhiteSpace=function(e){return 32===e||9===e||13===e||10===e},t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var r=a(2);class i extends r.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`),this.begin=e,this.end=t}}t.MissingDataException=i;class n extends r.BaseException{}t.XRefEntryException=n;class s extends r.BaseException{}t.XRefParseException=s;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(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDocument=t.Page=void 0;var r=a(2),i=a(9),n=a(4),s=a(7),o=a(11),c=a(23),l=a(21),h=a(10),u=a(24),d=a(25),f=a(39);const g=[0,0,612,792];function m(e,t){return"display"===t&&e.viewable||"print"===t&&e.printable}class p{constructor({pdfManager:e,xref:t,pageIndex:a,pageDict:r,ref:i,fontCache:n,builtInCMapCache:s,pdfFunctionFactory:o}){this.pdfManager=e,this.pageIndex=a,this.pageDict=r,this.xref=t,this.ref=i,this.fontCache=n,this.builtInCMapCache=s,this.pdfFunctionFactory=o,this.evaluatorOptions=e.evaluatorOptions,this.resourcesPromise=null;const c={obj:0};this.idFactory={createObjId:()=>`p${a}_${++c.obj}`,getDocId:()=>"g_"+e.docId}}_getInheritableProperty(e,t=!1){const a=(0,s.getInheritableProperty)({dict:this.pageDict,key:e,getArray:t,stopWhenFound:!1});return Array.isArray(a)?1!==a.length&&(0,n.isDict)(a[0])?n.Dict.merge(this.xref,a):a[0]:a}get content(){return this.pageDict.get("Contents")}get resources(){return(0,r.shadow)(this,"resources",this._getInheritableProperty("Resources")||n.Dict.empty)}_getBoundingBox(e){const t=this._getInheritableProperty(e,!0);if(Array.isArray(t)&&4===t.length){if(t[2]-t[0]!=0&&t[3]-t[1]!=0)return t;(0,r.warn)(`Empty /${e} entry.`)}return null}get mediaBox(){return(0,r.shadow)(this,"mediaBox",this._getBoundingBox("MediaBox")||g)}get cropBox(){return(0,r.shadow)(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");return(!(0,r.isNum)(e)||e<=0)&&(e=1),(0,r.shadow)(this,"userUnit",e)}get view(){const{cropBox:e,mediaBox:t}=this;let a;if(e===t||(0,r.isArrayEqual)(e,t))a=t;else{const i=r.Util.intersect(e,t);i&&i[2]-i[0]!=0&&i[3]-i[1]!=0?a=i:(0,r.warn)("Empty /CropBox and /MediaBox intersection.")}return(0,r.shadow)(this,"view",a||t)}get rotate(){let e=this._getInheritableProperty("Rotate")||0;return e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360),(0,r.shadow)(this,"rotate",e)}getContentStream(){const e=this.content;let t;if(Array.isArray(e)){const a=this.xref,r=[];for(const t of e)r.push(a.fetchIfRef(t));t=new o.StreamsSequenceStream(r)}else t=(0,n.isStream)(e)?e:new o.NullStream;return t}loadResources(e){return this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources")),this.resourcesPromise.then(()=>new i.ObjectLoader(this.resources,e,this.xref).load())}getOperatorList({handler:e,sink:t,task:a,intent:i,renderInteractiveForms:n}){const s=this.pdfManager.ensure(this,"getContentStream"),o=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),c=new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this.idFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,options:this.evaluatorOptions,pdfFunctionFactory:this.pdfFunctionFactory}),l=Promise.all([s,o]).then(([r])=>{const n=new u.OperatorList(i,t,this.pageIndex);return e.send("StartRenderPage",{transparency:c.hasBlendModes(this.resources),pageIndex:this.pageIndex,intent:i}),c.getOperatorList({stream:r,task:a,resources:this.resources,operatorList:n}).then((function(){return n}))});return Promise.all([l,this._parsedAnnotations]).then((function([e,t]){if(0===t.length)return e.flush(!0),{length:e.totalLength};const s=[];for(const e of t)m(e,i)&&s.push(e.getOperatorList(c,a,n));return Promise.all(s).then((function(t){e.addOp(r.OPS.beginAnnotations,[]);for(const a of t)e.addOpList(a);return e.addOp(r.OPS.endAnnotations,[]),e.flush(!0),{length:e.totalLength}}))}))}extractTextContent({handler:e,task:t,normalizeWhitespace:a,sink:r,combineTextItems:i}){const n=this.pdfManager.ensure(this,"getContentStream"),s=this.loadResources(["ExtGState","XObject","Font"]);return Promise.all([n,s]).then(([n])=>new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this.idFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,options:this.evaluatorOptions,pdfFunctionFactory:this.pdfFunctionFactory}).getTextContent({stream:n,task:t,resources:this.resources,normalizeWhitespace:a,combineTextItems:i,sink:r}))}getAnnotationsData(e){return this._parsedAnnotations.then((function(t){const a=[];for(let r=0,i=t.length;r{const e=this.annotations,t=[];for(let a=0,r=e.length;a=a;){let s=0;for(;s=i)return e.pos+=r-a,!0;r--}}else{let a=0;for(;a<=s;){let r=0;for(;r=i)return e.pos+=a,!0;a++}}return!1}t.PDFDocument=class{constructor(e,t){let a;if((0,n.isStream)(t))a=t;else{if(!(0,r.isArrayBuffer)(t))throw new Error("PDFDocument: Unknown argument type");a=new o.Stream(t)}if(a.length<=0)throw new r.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=e,this.stream=a,this.xref=new i.XRef(a,e),this.pdfFunctionFactory=new f.PDFFunctionFactory({xref:this.xref,isEvalSupported:e.evaluatorOptions.isEvalSupported}),this._pagePromises=[]}parse(e){this.setup(e);const t=this.catalog.catDict.get("Version");(0,n.isName)(t)&&(this.pdfFormatVersion=t.name);try{if(this.acroForm=this.catalog.catDict.get("AcroForm"),this.acroForm){this.xfa=this.acroForm.get("XFA");const e=this.acroForm.get("Fields");Array.isArray(e)&&0!==e.length||this.xfa||(this.acroForm=null)}}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.info)("Cannot fetch AcroForm entry; assuming no AcroForms are present"),this.acroForm=null}try{const e=this.catalog.catDict.get("Collection");(0,n.isDict)(e)&&e.getKeys().length>0&&(this.collection=e)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.info)("Cannot fetch Collection dictionary.")}}get linearization(){let e=null;try{e=h.Linearization.create(this.stream)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.info)(e)}return(0,r.shadow)(this,"linearization",e)}get startXRef(){const e=this.stream;let t=0;if(this.linearization)e.reset(),k(e,v)&&(t=e.pos+6-e.start);else{const a=1024,r=y.length;let i=!1,n=e.end;for(;!i&&n>0;)n-=a-r,n<0&&(n=0),e.pos=n,i=k(e,y,a,!0);if(i){let a;e.skip(9);do{a=e.getByte()}while((0,s.isWhiteSpace)(a));let r="";for(;a>=32&&a<=57;)r+=String.fromCharCode(a),a=e.getByte();t=parseInt(r,10),isNaN(t)&&(t=0)}}return(0,r.shadow)(this,"startXRef",t)}checkHeader(){const e=this.stream;if(e.reset(),!k(e,b))return;e.moveStart();let t,a="";for(;(t=e.getByte())>32&&!(a.length>=12);)a+=String.fromCharCode(t);this.pdfFormatVersion||(this.pdfFormatVersion=a.substring(5))}parseStartXRef(){this.xref.setStartXRef(this.startXRef)}setup(e){this.xref.parse(e),this.catalog=new i.Catalog(this.pdfManager,this.xref)}get numPages(){const e=this.linearization,t=e?e.numPages:this.catalog.numPages;return(0,r.shadow)(this,"numPages",t)}get documentInfo(){const e={Title:r.isString,Author:r.isString,Subject:r.isString,Keywords:r.isString,Creator:r.isString,Producer:r.isString,CreationDate:r.isString,ModDate:r.isString,Trapped:n.isName};let t=this.pdfFormatVersion;"string"==typeof t&&w.test(t)||((0,r.warn)("Invalid PDF header version number: "+t),t=null);const a={PDFFormatVersion:t,IsLinearized:!!this.linearization,IsAcroFormPresent:!!this.acroForm,IsXFAPresent:!!this.xfa,IsCollectionPresent:!!this.collection};let i;try{i=this.xref.trailer.get("Info")}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.info)("The document information dictionary is invalid.")}if((0,n.isDict)(i))for(const t of i.getKeys()){const s=i.get(t);if(e[t])e[t](s)?a[t]="string"!=typeof s?s:(0,r.stringToPDFString)(s):(0,r.info)(`Bad value in document info for "${t}".`);else if("string"==typeof t){let e;if((0,r.isString)(s))e=(0,r.stringToPDFString)(s);else{if(!((0,n.isName)(s)||(0,r.isNum)(s)||(0,r.isBool)(s))){(0,r.info)(`Unsupported value in document info for (custom) "${t}".`);continue}e=s}a.Custom||(a.Custom=Object.create(null)),a.Custom[t]=e}}return(0,r.shadow)(this,"documentInfo",a)}get fingerprint(){let e;const t=this.xref.trailer.get("ID");e=Array.isArray(t)&&t[0]&&(0,r.isString)(t[0])&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==t[0]?(0,r.stringToBytes)(t[0]):(0,l.calculateMD5)(this.stream.getByteRange(0,1024),0,1024);const a=[];for(let t=0,r=e.length;t{if((0,n.isDict)(e,"Page")||(0,n.isDict)(e)&&!e.has("Type")&&e.has("Contents"))return i&&!t.pageKidsCountCache.has(i)&&t.pageKidsCountCache.put(i,1),[e,i];throw new r.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.")}).catch(a=>((0,r.info)(a),t.getPageDict(e)))}getPage(e){if(void 0!==this._pagePromises[e])return this._pagePromises[e];const{catalog:t,linearization:a}=this,r=a&&a.pageFirst===e?this._getLinearizationPage(e):t.getPageDict(e);return this._pagePromises[e]=r.then(([a,r])=>new p({pdfManager:this.pdfManager,xref:this.xref,pageIndex:e,pageDict:a,ref:r,fontCache:t.fontCache,builtInCMapCache:t.builtInCMapCache,pdfFunctionFactory:this.pdfFunctionFactory}))}checkFirstPage(){return this.getPage(0).catch(async e=>{if(e instanceof s.XRefEntryException)throw this._pagePromises.length=0,await this.cleanup(),new s.XRefParseException})}fontFallback(e,t){return this.catalog.fontFallback(e,t)}async cleanup(){return this.catalog?this.catalog.cleanup():(0,n.clearPrimitiveCaches)()}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FileSpec=t.XRef=t.ObjectLoader=t.Catalog=void 0;var r=a(2),i=a(4),n=a(10),s=a(7),o=a(21),c=a(22);function l(e){return(0,i.isDict)(e)?e.get("D"):e}class h{constructor(e,t){if(this.pdfManager=e,this.xref=t,this.catDict=t.getCatalogObj(),!(0,i.isDict)(this.catDict))throw new r.FormatError("Catalog object is not a dictionary.");this.fontCache=new i.RefSetCache,this.builtInCMapCache=new Map,this.pageKidsCountCache=new i.RefSetCache}get metadata(){const e=this.catDict.getRaw("Metadata");if(!(0,i.isRef)(e))return(0,r.shadow)(this,"metadata",null);const t=!(this.xref.encrypt&&this.xref.encrypt.encryptMetadata),a=this.xref.fetch(e,t);let n;if(a&&(0,i.isDict)(a.dict)){const t=a.dict.get("Type"),o=a.dict.get("Subtype");if((0,i.isName)(t,"Metadata")&&(0,i.isName)(o,"XML"))try{n=(0,r.stringToUTF8String)((0,r.bytesToString)(a.getBytes()))}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.info)("Skipping invalid metadata.")}}return(0,r.shadow)(this,"metadata",n)}get toplevelPagesDict(){const e=this.catDict.get("Pages");if(!(0,i.isDict)(e))throw new r.FormatError("Invalid top-level pages dictionary.");return(0,r.shadow)(this,"toplevelPagesDict",e)}get documentOutline(){let e=null;try{e=this._readDocumentOutline()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.warn)("Unable to read document outline.")}return(0,r.shadow)(this,"documentOutline",e)}_readDocumentOutline(){let e=this.catDict.get("Outlines");if(!(0,i.isDict)(e))return null;if(e=e.getRaw("First"),!(0,i.isRef)(e))return null;const t={items:[]},a=[{obj:e,parent:t}],n=new i.RefSet;n.put(e);const s=this.xref,o=new Uint8ClampedArray(3);for(;a.length>0;){const t=a.shift(),l=s.fetchIfRef(t.obj);if(null===l)continue;if(!l.has("Title"))throw new r.FormatError("Invalid outline item encountered.");const u={url:null,dest:null};h.parseDestDictionary({destDict:l,resultObj:u,docBaseUrl:this.pdfManager.docBaseUrl});const d=l.get("Title"),f=l.get("F")||0,g=l.getArray("C"),m=l.get("Count");let p=o;!Array.isArray(g)||3!==g.length||0===g[0]&&0===g[1]&&0===g[2]||(p=c.ColorSpace.singletons.rgb.getRgb(g,0));const b={dest:u.dest,url:u.url,unsafeUrl:u.unsafeUrl,newWindow:u.newWindow,title:(0,r.stringToPDFString)(d),color:p,count:Number.isInteger(m)?m:void 0,bold:!!(2&f),italic:!!(1&f),items:[]};t.parent.items.push(b),e=l.getRaw("First"),(0,i.isRef)(e)&&!n.has(e)&&(a.push({obj:e,parent:b}),n.put(e)),e=l.getRaw("Next"),(0,i.isRef)(e)&&!n.has(e)&&(a.push({obj:e,parent:t.parent}),n.put(e))}return t.items.length>0?t.items:null}get permissions(){let e=null;try{e=this._readPermissions()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.warn)("Unable to read permissions.")}return(0,r.shadow)(this,"permissions",e)}_readPermissions(){const e=this.xref.trailer.get("Encrypt");if(!(0,i.isDict)(e))return null;let t=e.get("P");if(!(0,r.isNum)(t))return null;t+=2**32;const a=[];for(const e in r.PermissionFlag){const i=r.PermissionFlag[e];t&i&&a.push(i)}return a}get numPages(){const e=this.toplevelPagesDict.get("Count");if(!Number.isInteger(e))throw new r.FormatError("Page count in top-level pages dictionary is not an integer.");return(0,r.shadow)(this,"numPages",e)}get destinations(){const e=this._readDests(),t=Object.create(null);if(e instanceof f){const a=e.getAll();for(const e in a)t[e]=l(a[e])}else e instanceof i.Dict&&e.forEach((function(e,a){a&&(t[e]=l(a))}));return(0,r.shadow)(this,"destinations",t)}getDestination(e){const t=this._readDests();return t instanceof f||t instanceof i.Dict?l(t.get(e)||null):null}_readDests(){const e=this.catDict.get("Names");return e&&e.has("Dests")?new f(e.getRaw("Dests"),this.xref):this.catDict.has("Dests")?this.catDict.get("Dests"):void 0}get pageLabels(){let e=null;try{e=this._readPageLabels()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.warn)("Unable to read page labels.")}return(0,r.shadow)(this,"pageLabels",e)}_readPageLabels(){const e=this.catDict.getRaw("PageLabels");if(!e)return null;const t=new Array(this.numPages);let a=null,n="";const o=new g(e,this.xref).getAll();let c="",l=1;for(let e=0,h=this.numPages;e=1))throw new r.FormatError("Invalid start in PageLabel dictionary.");l=e}else l=1}switch(a){case"D":c=l;break;case"R":case"r":c=(0,s.toRomanNumerals)(l,"r"===a);break;case"A":case"a":const e=26,t=65,i=97,n="a"===a?i:t,o=l-1,h=String.fromCharCode(n+o%e),u=[];for(let t=0,a=o/e|0;t<=a;t++)u.push(h);c=u.join("");break;default:if(a)throw new r.FormatError(`Invalid style "${a}" in PageLabel dictionary.`);c=""}t[e]=n+c,l++}return t}get pageLayout(){const e=this.catDict.get("PageLayout");let t="";if((0,i.isName)(e))switch(e.name){case"SinglePage":case"OneColumn":case"TwoColumnLeft":case"TwoColumnRight":case"TwoPageLeft":case"TwoPageRight":t=e.name}return(0,r.shadow)(this,"pageLayout",t)}get pageMode(){const e=this.catDict.get("PageMode");let t="UseNone";if((0,i.isName)(e))switch(e.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"FullScreen":case"UseOC":case"UseAttachments":t=e.name}return(0,r.shadow)(this,"pageMode",t)}get viewerPreferences(){const e={HideToolbar:r.isBool,HideMenubar:r.isBool,HideWindowUI:r.isBool,FitWindow:r.isBool,CenterWindow:r.isBool,DisplayDocTitle:r.isBool,NonFullScreenPageMode:i.isName,Direction:i.isName,ViewArea:i.isName,ViewClip:i.isName,PrintArea:i.isName,PrintClip:i.isName,PrintScaling:i.isName,Duplex:i.isName,PickTrayByPDFSize:r.isBool,PrintPageRange:Array.isArray,NumCopies:Number.isInteger},t=this.catDict.get("ViewerPreferences"),a=Object.create(null);if((0,i.isDict)(t))for(const i in e){if(!t.has(i))continue;const n=t.get(i);if(!e[i](n)){(0,r.info)(`Bad value in ViewerPreferences for "${i}".`);continue}let s;switch(i){case"NonFullScreenPageMode":switch(n.name){case"UseNone":case"UseOutlines":case"UseThumbs":case"UseOC":s=n.name;break;default:s="UseNone"}break;case"Direction":switch(n.name){case"L2R":case"R2L":s=n.name;break;default:s="L2R"}break;case"ViewArea":case"ViewClip":case"PrintArea":case"PrintClip":switch(n.name){case"MediaBox":case"CropBox":case"BleedBox":case"TrimBox":case"ArtBox":s=n.name;break;default:s="CropBox"}break;case"PrintScaling":switch(n.name){case"None":case"AppDefault":s=n.name;break;default:s="AppDefault"}break;case"Duplex":switch(n.name){case"Simplex":case"DuplexFlipShortEdge":case"DuplexFlipLongEdge":s=n.name;break;default:s="None"}break;case"PrintPageRange":if(n.length%2!=0)break;n.every((e,t,a)=>Number.isInteger(e)&&e>0&&(0===t||e>=a[t-1])&&e<=this.numPages)&&(s=n);break;case"NumCopies":n>0&&(s=n);break;default:(0,r.assert)("boolean"==typeof n),s=n}void 0!==s?a[i]=s:(0,r.info)(`Bad value in ViewerPreferences for "${i}".`)}return(0,r.shadow)(this,"viewerPreferences",a)}get openAction(){const e=this.catDict.get("OpenAction");let t=null;if((0,i.isDict)(e)){const a=new i.Dict(this.xref);a.set("A",e);const r={url:null,dest:null,action:null};h.parseDestDictionary({destDict:a,resultObj:r}),Array.isArray(r.dest)?(t||(t=Object.create(null)),t.dest=r.dest):r.action&&(t||(t=Object.create(null)),t.action=r.action)}else Array.isArray(e)&&(t||(t=Object.create(null)),t.dest=e);return(0,r.shadow)(this,"openAction",t)}get attachments(){const e=this.catDict.get("Names");let t=null;if(e&&e.has("EmbeddedFiles")){const a=new f(e.getRaw("EmbeddedFiles"),this.xref).getAll();for(const e in a){const i=new m(a[e],this.xref);t||(t=Object.create(null)),t[(0,r.stringToPDFString)(e)]=i.serializable}}return(0,r.shadow)(this,"attachments",t)}get javaScript(){const e=this.catDict.get("Names");let t=null;function a(e){const a=e.get("S");if(!(0,i.isName)(a,"JavaScript"))return;let n=e.get("JS");if((0,i.isStream)(n))n=(0,r.bytesToString)(n.getBytes());else if(!(0,r.isString)(n))return;t||(t=[]),t.push((0,r.stringToPDFString)(n))}if(e&&e.has("JavaScript")){const t=new f(e.getRaw("JavaScript"),this.xref).getAll();for(const e in t){const r=t[e];(0,i.isDict)(r)&&a(r)}}const n=this.catDict.get("OpenAction");return(0,i.isDict)(n)&&(0,i.isName)(n.get("S"),"JavaScript")&&a(n),(0,r.shadow)(this,"javaScript",t)}fontFallback(e,t){const a=[];return this.fontCache.forEach((function(e){a.push(e)})),Promise.all(a).then(a=>{for(const r of a)if(r.loadedName===e)return void r.fallback(t)})}cleanup(){(0,i.clearPrimitiveCaches)(),this.pageKidsCountCache.clear();const e=[];return this.fontCache.forEach((function(t){e.push(t)})),Promise.all(e).then(e=>{for(const{dict:t}of e)delete t.translated;this.fontCache.clear(),this.builtInCMapCache.clear()})}getPageDict(e){const t=(0,r.createPromiseCapability)(),a=[this.catDict.getRaw("Pages")],n=new i.RefSet,s=this.xref,o=this.pageKidsCountCache;let c,l=0;return function h(){for(;a.length;){const u=a.pop();if((0,i.isRef)(u)){if(c=o.get(u),c>0&&l+c=0){const t=u.objId;if(t&&!o.has(t)&&o.put(t,c),l+c<=e){l+=c;continue}}const d=u.get("Kids");if(!Array.isArray(d)){if((0,i.isName)(u.get("Type"),"Page")||!u.has("Type")&&u.has("Contents")){if(l===e)return void t.resolve([u,null]);l++;continue}return void t.reject(new r.FormatError("Page dictionary kids object is not an array."))}for(let e=d.length-1;e>=0;e--)a.push(d[e])}t.reject(new Error(`Page index ${e} not found.`))}(),t.promise}getPageIndex(e){const t=this.xref;let a=0;return function n(s){return function(a){let n,s=0;return t.fetchAsync(a).then((function(t){if((0,i.isRefsEqual)(a,e)&&!(0,i.isDict)(t,"Page")&&(!(0,i.isDict)(t)||t.has("Type")||!t.has("Contents")))throw new r.FormatError("The reference does not point to a /Page dictionary.");if(!t)return null;if(!(0,i.isDict)(t))throw new r.FormatError("Node must be a dictionary.");return n=t.getRaw("Parent"),t.getAsync("Parent")})).then((function(e){if(!e)return null;if(!(0,i.isDict)(e))throw new r.FormatError("Parent must be a dictionary.");return e.getAsync("Kids")})).then((function(e){if(!e)return null;const o=[];let c=!1;for(let n=0,l=e.length;n0;){var h=l[0],u=l[1];if(!Number.isInteger(h)||!Number.isInteger(u))throw new r.FormatError(`Invalid XRef range fields: ${h}, ${u}`);if(!Number.isInteger(s)||!Number.isInteger(o)||!Number.isInteger(c))throw new r.FormatError(`Invalid XRef entry fields length: ${h}, ${u}`);for(t=i.entryNum;t=e.length);)a+=String.fromCharCode(r),r=e[t];return a}function t(e,t,a){for(var r=a.length,i=e.length,n=0;t=r)break;t++,n++}return n}var a=/^(\d+)\s+(\d+)\s+obj\b/;const o=/\bendobj[\b\s]$/,c=/\s+(\d+\s+\d+\s+obj[\b\s<])$/;var l=new Uint8Array([116,114,97,105,108,101,114]),h=new Uint8Array([115,116,97,114,116,120,114,101,102]);const u=new Uint8Array([111,98,106]);var d=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var f=this.stream;f.pos=0;for(var g,m,p=f.getBytes(),b=f.start,y=p.length,v=[],w=[];b=y)break;k=p[b]}while(10!==k&&13!==k);else++b}for(g=0,m=w.length;g0;){const s=t.fetchIfRef(n.shift());if(!(0,i.isDict)(s))continue;if(s.has("Kids")){const e=s.get("Kids");for(let t=0,i=e.length;t10)return(0,r.warn)(`Search depth limit reached for "${this._type}" tree.`),null;const n=a.get("Kids");if(!Array.isArray(n))return null;let s=0,o=n.length-1;for(;s<=o;){const r=s+o>>1,i=t.fetchIfRef(n[r]).get("Limits");if(et.fetchIfRef(i[1]))){a=t.fetchIfRef(n[r]);break}s=r+1}}if(s>o)return null}const n=a.get(this._type);if(Array.isArray(n)){let a=0,i=n.length-2;for(;a<=i;){const r=a+i>>1,s=r+(1&r),o=t.fetchIfRef(n[s]);if(eo))return t.fetchIfRef(n[s+1]);a=s+2}}(0,r.info)(`Falling back to an exhaustive search, for key "${e}", in "${this._type}" tree.`);for(let a=0,i=n.length;a>")&&!(0,n.isEOF)(this.buf1);){if(!(0,n.isName)(this.buf1)){(0,i.info)("Malformed dictionary: key must be a name object"),this.shift();continue}const t=this.buf1.name;if(this.shift(),(0,n.isEOF)(this.buf1))break;r.set(t,this.getObj(e))}if((0,n.isEOF)(this.buf1)){if(!this.recoveryMode)throw new i.FormatError("End of file inside dictionary");return r}return(0,n.isCmd)(this.buf2,"stream")?this.allowStreams?this.makeStream(r,e):r:(this.shift(),r);default:return t}if(Number.isInteger(t)){if(Number.isInteger(this.buf1)&&(0,n.isCmd)(this.buf2,"R")){const e=n.Ref.get(t,this.buf1);return this.shift(),this.shift(),e}return t}return"string"==typeof t&&e?e.decryptString(t):t}findDefaultInlineStreamEnd(e){const t=e.pos;let a,r,n=0;for(;-1!==(a=e.getByte());)if(0===n)n=69===a?1:0;else if(1===n)n=73===a?2:0;else if((0,i.assert)(2===n),32===a||10===a||13===a){r=e.pos;const t=e.peekBytes(10);for(let e=0,r=t.length;e127)){n=0;break}if(2===n)break}else n=0;-1===a&&((0,i.warn)("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker"),r&&((0,i.warn)('... trying to recover by using the last "EI" occurrence.'),e.skip(-(e.pos-r))));let o=4;return e.skip(-o),a=e.peekByte(),e.skip(o),(0,s.isWhiteSpace)(a)||o--,e.pos-o-t}findDCTDecodeInlineStreamEnd(e){const t=e.pos;let a,r,n=!1;for(;-1!==(a=e.getByte());)if(255===a){switch(e.getByte()){case 0:break;case 255:e.skip(-1);break;case 217:n=!0;break;case 192:case 193:case 194:case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:r=e.getUint16(),r>2?e.skip(r-2):e.skip(-2)}if(n)break}const s=e.pos-t;return-1===a?((0,i.warn)("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead."),e.skip(-s),this.findDefaultInlineStreamEnd(e)):(this.inlineStreamSkipEI(e),s)}findASCII85DecodeInlineStreamEnd(e){const t=e.pos;let a;for(;-1!==(a=e.getByte());)if(126===a){const t=e.pos;for(a=e.peekByte();(0,s.isWhiteSpace)(a);)e.skip(),a=e.peekByte();if(62===a){e.skip();break}if(e.pos>t){const t=e.peekBytes(2);if(69===t[0]&&73===t[1])break}}const r=e.pos-t;return-1===a?((0,i.warn)("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead."),e.skip(-r),this.findDefaultInlineStreamEnd(e)):(this.inlineStreamSkipEI(e),r)}findASCIIHexDecodeInlineStreamEnd(e){const t=e.pos;let a;for(;-1!==(a=e.getByte())&&62!==a;);const r=e.pos-t;return-1===a?((0,i.warn)("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead."),e.skip(-r),this.findDefaultInlineStreamEnd(e)):(this.inlineStreamSkipEI(e),r)}inlineStreamSkipEI(e){let t,a=0;for(;-1!==(t=e.getByte());)if(0===a)a=69===t?1:0;else if(1===a)a=73===t?2:0;else if(2===a)break}makeInlineImage(e){const t=this.lexer,a=t.stream,r=new n.Dict(this.xref);let s;for(;!(0,n.isCmd)(this.buf1,"ID")&&!(0,n.isEOF)(this.buf1);){if(!(0,n.isName)(this.buf1))throw new i.FormatError("Dictionary key must be a name object");const t=this.buf1.name;if(this.shift(),(0,n.isEOF)(this.buf1))break;r.set(t,this.getObj(e))}-1!==t.beginInlineImagePos&&(s=a.pos-t.beginInlineImagePos);const o=r.get("Filter","F");let c;if((0,n.isName)(o))c=o.name;else if(Array.isArray(o)){const e=this.xref.fetchIfRef(o[0]);(0,n.isName)(e)&&(c=e.name)}const l=a.pos;let h;h="DCTDecode"===c||"DCT"===c?this.findDCTDecodeInlineStreamEnd(a):"ASCII85Decode"===c||"A85"===c?this.findASCII85DecodeInlineStreamEnd(a):"ASCIIHexDecode"===c||"AHx"===c?this.findASCIIHexDecodeInlineStreamEnd(a):this.findDefaultInlineStreamEnd(a);let d,f=a.makeSubStream(l,h,r);if(h<1e3&&s<5552){const e=f.getBytes();f.reset();const r=a.pos;a.pos=t.beginInlineImagePos;const i=a.getBytes(s);a.pos=r,d=u(e)+"_"+u(i);const o=this.imageCache[d];if(void 0!==o)return this.buf2=n.Cmd.get("EI"),this.shift(),o.reset(),o}return e&&(f=e.createStream(f,h)),f=this.filter(f,r,h),f.dict=r,void 0!==d&&(f.cacheKey=`inline_${h}_${d}`,this.imageCache[d]=f),this.buf2=n.Cmd.get("EI"),this.shift(),f}_findStreamLength(e,t){const{stream:a}=this.lexer;a.pos=e;const r=t.length;for(;a.pos=r)return a.pos+=s,a.pos-e;s++}a.pos+=n}return-1}makeStream(e,t){const a=this.lexer;let r=a.stream;a.skipToNextLine();const o=r.pos-1;let c=e.get("Length");if(Number.isInteger(c)||((0,i.info)(`Bad length "${c}" in stream`),c=0),r.pos=o+c,a.nextChar(),this.tryShift()&&(0,n.isCmd)(this.buf2,"endstream"))this.shift();else{const e=new Uint8Array([101,110,100,115,116,114,101,97,109]);let t=this._findStreamLength(o,e);if(t<0){const a=1;for(let n=1;n<=a;n++){const a=e.length-n,c=e.slice(0,a),l=this._findStreamLength(o,c);if(l>=0){const e=r.peekBytes(a+1)[a];if(!(0,s.isWhiteSpace)(e))break;(0,i.info)(`Found "${(0,i.bytesToString)(c)}" when searching for endstream command.`),t=l;break}}if(t<0)throw new i.FormatError("Missing endstream command.")}c=t,a.nextChar(),this.shift(),this.shift()}return this.shift(),r=r.makeSubStream(o,c,e),t&&(r=t.createStream(r,c)),r=this.filter(r,e,c),r.dict=e,r}filter(e,t,a){let r=t.get("Filter","F"),s=t.get("DecodeParms","DP");if((0,n.isName)(r))return Array.isArray(s)&&(0,i.warn)("/DecodeParms should not contain an Array, when /Filter contains a Name."),this.makeFilter(e,r.name,a,s);let o=a;if(Array.isArray(r)){const t=r,a=s;for(let c=0,l=t.length;c=48&&e<=57?15&e:e>=65&&e<=70||e>=97&&e<=102?9+(15&e):-1}class m{constructor(e,t=null){this.stream=e,this.nextChar(),this.strBuf=[],this.knownCommands=t,this._hexStringNumWarn=0,this.beginInlineImagePos=-1}nextChar(){return this.currentChar=this.stream.getByte()}peekChar(){return this.stream.peekByte()}getNumber(){let e=this.currentChar,t=!1,a=0,r=0;if(45===e?(r=-1,e=this.nextChar(),45===e&&(e=this.nextChar())):43===e&&(r=1,e=this.nextChar()),10===e||13===e)do{e=this.nextChar()}while(10===e||13===e);if(46===e&&(a=10,e=this.nextChar()),e<48||e>57){if(10===a&&0===r&&((0,s.isWhiteSpace)(e)||-1===e))return(0,i.warn)("Lexer.getNumber - treating a single decimal point as zero."),0;throw new i.FormatError(`Invalid number: ${String.fromCharCode(e)} (charCode ${e})`)}r=r||1;let n=e-48,o=0,c=1;for(;(e=this.nextChar())>=0;)if(e>=48&&e<=57){const r=e-48;t?o=10*o+r:(0!==a&&(a*=10),n=10*n+r)}else if(46===e){if(0!==a)break;a=1}else if(45===e)(0,i.warn)("Badly formatted number: minus sign in the middle");else{if(69!==e&&101!==e)break;if(e=this.peekChar(),43===e||45===e)c=45===e?-1:1,this.nextChar();else if(e<48||e>57)break;t=!0}return 0!==a&&(n/=a),t&&(n*=10**(c*o)),r*n}getString(){let e=1,t=!1;const a=this.strBuf;a.length=0;let r=this.nextChar();for(;;){let n=!1;switch(0|r){case-1:(0,i.warn)("Unterminated string"),t=!0;break;case 40:++e,a.push("(");break;case 41:0==--e?(this.nextChar(),t=!0):a.push(")");break;case 92:switch(r=this.nextChar(),r){case-1:(0,i.warn)("Unterminated string"),t=!0;break;case 110:a.push("\n");break;case 114:a.push("\r");break;case 116:a.push("\t");break;case 98:a.push("\b");break;case 102:a.push("\f");break;case 92:case 40:case 41:a.push(String.fromCharCode(r));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:let e=15&r;r=this.nextChar(),n=!0,r>=48&&r<=55&&(e=(e<<3)+(15&r),r=this.nextChar(),r>=48&&r<=55&&(n=!1,e=(e<<3)+(15&r))),a.push(String.fromCharCode(e));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:a.push(String.fromCharCode(r))}break;default:a.push(String.fromCharCode(r))}if(t)break;n||(r=this.nextChar())}return a.join("")}getName(){let e,t;const a=this.strBuf;for(a.length=0;(e=this.nextChar())>=0&&!f[e];)if(35===e){if(e=this.nextChar(),f[e]){(0,i.warn)("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number."),a.push("#");break}const r=g(e);if(-1!==r){t=e,e=this.nextChar();const n=g(e);if(-1===n){if((0,i.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(e)}) in hexadecimal number.`),a.push("#",String.fromCharCode(t)),f[e])break;a.push(String.fromCharCode(e));continue}a.push(String.fromCharCode(r<<4|n))}else a.push("#",String.fromCharCode(e))}else a.push(String.fromCharCode(e));return a.length>127&&(0,i.warn)("Name token is longer than allowed by the spec: "+a.length),n.Name.get(a.join(""))}_hexStringWarn(e){5!=this._hexStringNumWarn++?this._hexStringNumWarn>5||(0,i.warn)("getHexString - ignoring invalid character: "+e):(0,i.warn)("getHexString - ignoring additional invalid characters.")}getHexString(){const e=this.strBuf;e.length=0;let t,a,r=this.currentChar,n=!0;for(this._hexStringNumWarn=0;;){if(r<0){(0,i.warn)("Unterminated hex string");break}if(62===r){this.nextChar();break}if(1!==f[r]){if(n){if(t=g(r),-1===t){this._hexStringWarn(r),r=this.nextChar();continue}}else{if(a=g(r),-1===a){this._hexStringWarn(r),r=this.nextChar();continue}e.push(String.fromCharCode(t<<4|a))}n=!n,r=this.nextChar()}else r=this.nextChar()}return e.join("")}getObj(){let e=!1,t=this.currentChar;for(;;){if(t<0)return n.EOF;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(1!==f[t])break;t=this.nextChar()}switch(0|t){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 43:case 45:case 46:return this.getNumber();case 40:return this.getString();case 47:return this.getName();case 91:return this.nextChar(),n.Cmd.get("[");case 93:return this.nextChar(),n.Cmd.get("]");case 60:return t=this.nextChar(),60===t?(this.nextChar(),n.Cmd.get("<<")):this.getHexString();case 62:return t=this.nextChar(),62===t?(this.nextChar(),n.Cmd.get(">>")):n.Cmd.get(">");case 123:return this.nextChar(),n.Cmd.get("{");case 125:return this.nextChar(),n.Cmd.get("}");case 41:throw this.nextChar(),new i.FormatError("Illegal character: "+t)}let a=String.fromCharCode(t);const r=this.knownCommands;let s=r&&void 0!==r[a];for(;(t=this.nextChar())>=0&&!f[t];){const e=a+String.fromCharCode(t);if(s&&void 0===r[e])break;if(128===a.length)throw new i.FormatError("Command token too long: "+a.length);a=e,s=r&&void 0!==r[a]}return"true"===a||"false"!==a&&("null"===a?null:("BI"===a&&(this.beginInlineImagePos=this.stream.pos),n.Cmd.get(a)))}skipToNextLine(){let e=this.currentChar;for(;e>=0;){if(13===e){e=this.nextChar(),10===e&&this.nextChar();break}if(10===e){this.nextChar();break}e=this.nextChar()}}}t.Lexer=m,t.Linearization=class{static create(e){function t(e,t,a=!1){const r=e.get(t);if(Number.isInteger(r)&&(a?r>=0:r>0))return r;throw new Error(`The "${t}" parameter in the linearization dictionary is invalid.`)}const a=new d({lexer:new m(e),xref:null}),r=a.getObj(),s=a.getObj(),o=a.getObj(),c=a.getObj();let l,h;if(!(Number.isInteger(r)&&Number.isInteger(s)&&(0,n.isCmd)(o,"obj")&&(0,n.isDict)(c)&&(0,i.isNum)(l=c.get("Linearized"))&&l>0))return null;if((h=t(c,"L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:h,hints:function(e){const t=e.get("H");let a;if(Array.isArray(t)&&(2===(a=t.length)||4===a)){for(let e=0;e0))throw new Error(`Hint (${e}) in the linearization dictionary is invalid.`)}return t}throw new Error("Hint array in the linearization dictionary is invalid.")}(c),objectNumberFirst:t(c,"O"),endFirst:t(c,"E"),numPages:t(c,"N"),mainXRefEntriesOffset:t(c,"T"),pageFirst:c.has("P")?t(c,"P",!0):0}}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.LZWStream=t.StringStream=t.StreamsSequenceStream=t.Stream=t.RunLengthStream=t.PredictorStream=t.NullStream=t.FlateStream=t.DecodeStream=t.DecryptStream=t.AsciiHexStream=t.Ascii85Stream=void 0;var r=a(2),i=a(4),n=a(7),s=function(){function e(e,t,a,r){this.bytes=e instanceof Uint8Array?e:new Uint8Array(e),this.start=t||0,this.pos=this.start,this.end=t+a||this.bytes.length,this.dict=r}return e.prototype={get length(){return this.end-this.start},get isEmpty(){return 0===this.length},getByte:function(){return this.pos>=this.end?-1:this.bytes[this.pos++]},getUint16:function(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()},getBytes(e,t=!1){var a=this.bytes,r=this.pos,i=this.end;if(!e){const e=a.subarray(r,i);return t?new Uint8ClampedArray(e):e}var n=r+e;n>i&&(n=i),this.pos=n;const s=a.subarray(r,n);return t?new Uint8ClampedArray(s):s},peekByte:function(){var e=this.getByte();return-1!==e&&this.pos--,e},peekBytes(e,t=!1){var a=this.getBytes(e,t);return this.pos-=a.length,a},getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),this.bytes.subarray(e,t)},skip:function(e){e||(e=1),this.pos+=e},reset:function(){this.pos=this.start},moveStart:function(){this.start=this.pos},makeSubStream:function(t,a,r){return new e(this.bytes.buffer,t,a,r)}},e}();t.Stream=s;var o=function(){function e(e){const t=(0,r.stringToBytes)(e);s.call(this,t)}return e.prototype=s.prototype,e}();t.StringStream=o;var c=function(){var e=new Uint8Array(0);function t(t){if(this._rawMinBufferLength=t||0,this.pos=0,this.bufferLength=0,this.eof=!1,this.buffer=e,this.minBufferLength=512,t)for(;this.minBufferLengthi&&(a=i)}else{for(;!this.eof;)this.readBlock();a=this.bufferLength}this.pos=a;const n=this.buffer.subarray(r,a);return!t||n instanceof Uint8ClampedArray?n:new Uint8ClampedArray(n)},peekByte:function(){var e=this.getByte();return-1!==e&&this.pos--,e},peekBytes(e,t=!1){var a=this.getBytes(e,t);return this.pos-=a.length,a},makeSubStream:function(e,t,a){for(var r=e+t;this.bufferLength<=r&&!this.eof;)this.readBlock();return new s(this.buffer,e,t,a)},getByteRange(e,t){(0,r.unreachable)("Should not call DecodeStream.getByteRange")},skip:function(e){e||(e=1),this.pos+=e},reset:function(){this.pos=0},getBaseStreams:function(){return this.str&&this.str.getBaseStreams?this.str.getBaseStreams():[]}},t}();t.DecodeStream=c;var l=function(){function e(e){this.streams=e;let t=0;for(let a=0,r=e.length;a>e,this.codeSize=i-=e,t},s.prototype.getCode=function(e){for(var t,a=this.str,i=e[0],n=e[1],s=this.codeSize,o=this.codeBuf;s>16,h=65535&c;if(l<1||s>l,this.codeSize=s-l,h},s.prototype.generateHuffmanTable=function(e){var t,a=e.length,r=0;for(t=0;tr&&(r=e[t]);for(var i=1<>=1;for(t=h;t>=1)){var h,u;if(1===l)h=i,u=n;else{if(2!==l)throw new r.FormatError("Unknown block type in flate stream");var d,f=this.getBits(5)+257,g=this.getBits(5)+1,m=this.getBits(4)+4,p=new Uint8Array(e.length);for(d=0;d0;)S[d++]=w}h=this.generateHuffmanTable(S.subarray(0,f)),u=this.generateHuffmanTable(S.subarray(f,k))}for(var A=(s=this.buffer)?s.length:0,I=this.bufferLength;;){var F=this.getCode(h);if(F<256)I+1>=A&&(A=(s=this.ensureBuffer(I+1)).length),s[I++]=F;else{if(256===F)return void(this.bufferLength=I);var T=(F=t[F-=257])>>16;T>0&&(T=this.getBits(T)),o=(65535&F)+T,F=this.getCode(u),(T=(F=a[F])>>16)>0&&(T=this.getBits(T));var E=(65535&F)+T;I+o>=A&&(A=(s=this.ensureBuffer(I+o)).length);for(var O=0;O15))throw new r.FormatError("Unsupported predictor: "+n);this.readBlock=2===n?this.readBlockTiff:this.readBlockPng,this.str=e,this.dict=e.dict;var s=this.colors=a.get("Colors")||1,o=this.bits=a.get("BitsPerComponent")||8,l=this.columns=a.get("Columns")||1;return this.pixBytes=s*o+7>>3,this.rowBytes=l*s*o+7>>3,c.call(this,t),this}return e.prototype=Object.create(c.prototype),e.prototype.readBlockTiff=function(){var e=this.rowBytes,t=this.bufferLength,a=this.ensureBuffer(t+e),r=this.bits,i=this.colors,n=this.str.getBytes(e);if(this.eof=!n.length,!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===r&&1===i)for(s=0;s>1,d^=d>>2,o=(1&(d^=d>>4))<<7,a[u++]=d}else if(8===r){for(s=0;s>8&255,a[u++]=255&g}}else{var m=new Uint8Array(i+1),p=(1<>l-r)&p,l-=r,c=c<=8&&(a[y++]=c>>h-8&255,h-=8);h>0&&(a[y++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}},e.prototype.readBlockPng=function(){var e=this.rowBytes,t=this.pixBytes,a=this.str.getByte(),i=this.str.getBytes(e);if(this.eof=!i.length,!this.eof){var n=this.bufferLength,s=this.ensureBuffer(n+e),o=s.subarray(n-e,n);0===o.length&&(o=new Uint8Array(e));var c,l,h,u=n;switch(a){case 0:for(c=0;c>1)+i[c];for(;c>1)+i[c]&255,u++;break;case 4:for(c=0;c0;e=(0,this.decrypt)(e,!t);var a,r=this.bufferLength,i=e.length,n=this.ensureBuffer(r+i);for(a=0;a=0;--r)a[i+r]=255&o,o>>=8}}else this.eof=!0},e}();t.Ascii85Stream=f;var g=function(){function e(e,t){this.str=e,this.dict=e.dict,this.firstDigit=-1,t&&(t*=.5),c.call(this,t)}return e.prototype=Object.create(c.prototype),e.prototype.readBlock=function(){var e=this.str.getBytes(8e3);if(e.length){for(var t=e.length+1>>1,a=this.ensureBuffer(this.bufferLength+t),r=this.bufferLength,i=this.firstDigit,n=0,s=e.length;n=48&&c<=57)o=15&c;else{if(!(c>=65&&c<=70||c>=97&&c<=102)){if(62===c){this.eof=!0;break}continue}o=9+(15&c)}i<0?i=o:(a[r++]=i<<4|o,i=-1)}i>=0&&this.eof&&(a[r++]=i<<4,i=-1),this.firstDigit=i,this.bufferLength=r}else this.eof=!0},e}();t.AsciiHexStream=g;var m=function(){function e(e,t){this.str=e,this.dict=e.dict,c.call(this,t)}return e.prototype=Object.create(c.prototype),e.prototype.readBlock=function(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,a=this.bufferLength,r=e[0];if(r<128){if((t=this.ensureBuffer(a+r+1))[a++]=e[1],r>0){var i=this.str.getBytes(r);t.set(i,a),a+=r}}else{r=257-r;var n=e[1];t=this.ensureBuffer(a+r+1);for(var s=0;s>>t&(1<0;if(b<256)d[0]=b,f=1;else{if(!(b>=258)){if(256===b){h=9,s=258,f=0;continue}this.eof=!0,delete this.lzwState;break}if(b=0;t--)d[t]=o[a],a=l[a];else d[f++]=d[0]}if(y&&(l[s]=u,c[s]=c[u]+1,o[s]=d[0],h=++s+n&s+n-1?h:0|Math.min(Math.log(s+n)/.6931471805599453+1,12)),u=b,r<(g+=f)){do{r+=512}while(re.getByte()};this.ccittFaxDecoder=new i.CCITTFaxDecoder(s,{K:a.get("K"),EndOfLine:a.get("EndOfLine"),EncodedByteAlign:a.get("EncodedByteAlign"),Columns:a.get("Columns"),Rows:a.get("Rows"),EndOfBlock:a.get("EndOfBlock"),BlackIs1:a.get("BlackIs1")}),n.DecodeStream.call(this,t)}return e.prototype=Object.create(n.DecodeStream.prototype),e.prototype.readBlock=function(){for(;!this.eof;){const e=this.ccittFaxDecoder.readNextChar();if(-1===e)return void(this.eof=!0);this.ensureBuffer(this.bufferLength+1),this.buffer[this.bufferLength++]=e}},e}();t.CCITTFaxStream=s},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CCITTFaxDecoder=void 0;var r=a(2);const i=function(){const e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],a=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],i=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],n=[[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[8,13],[11,23],[11,23],[12,50],[12,51],[12,44],[12,45],[12,46],[12,47],[12,57],[12,58],[12,61],[12,256],[10,16],[10,16],[10,16],[10,16],[10,17],[10,17],[10,17],[10,17],[12,48],[12,49],[12,62],[12,63],[12,30],[12,31],[12,32],[12,33],[12,40],[12,41],[11,22],[11,22],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[8,14],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,10],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[7,11],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[9,15],[12,128],[12,192],[12,26],[12,27],[12,28],[12,29],[11,19],[11,19],[11,20],[11,20],[12,34],[12,35],[12,36],[12,37],[12,38],[12,39],[11,21],[11,21],[12,42],[12,43],[10,0],[10,0],[10,0],[10,0],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12],[7,12]],s=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[6,9],[6,8],[5,7],[5,7],[4,6],[4,6],[4,6],[4,6],[4,5],[4,5],[4,5],[4,5],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,3],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2],[2,2]];function o(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 a,r=t.EndOfBlock;for(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;0===(a=this._lookBits(12));)this._eatBits(1);1===a&&this._eatBits(12),this.encoding>0&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1))}return o.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,a=this.columns;let i,n,s,o,c;if(0===this.outputBits){if(this.rowsDone&&(this.eof=!0),this.eof)return-1;let s,c,l;if(this.err=!1,this.nextLine2D){for(o=0;t[o]=64);do{c+=l=this._getWhiteCode()}while(l>=64)}else{do{s+=l=this._getWhiteCode()}while(l>=64);do{c+=l=this._getBlackCode()}while(l>=64)}for(this._addPixels(t[this.codingPos]+s,n),t[this.codingPos]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,n),n^=1}let h=!1;if(this.byteAlign&&(this.inputBits&=-8),this.eoblock||this.row!==this.rows-1){if(s=this._lookBits(12),this.eoline)for(;-1!==s&&1!==s;)this._eatBits(1),s=this._lookBits(12);else for(;0===s;)this._eatBits(1),s=this._lookBits(12);1===s?(this._eatBits(12),h=!0):-1===s&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone&&(this.nextLine2D=!this._lookBits(1),this._eatBits(1)),this.eoblock&&h&&this.byteAlign){if(s=this._lookBits(12),1===s){if(this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1)),this.encoding>=0)for(o=0;o<4;++o)s=this._lookBits(12),1!==s&&(0,r.info)("bad rtc code: "+s),this._eatBits(12),this.encoding>0&&(this._lookBits(1),this._eatBits(1));this.eof=!0}}else if(this.err&&this.eoline){for(;;){if(s=this._lookBits(13),-1===s)return this.eof=!0,-1;if(s>>1==1)break;this._eatBits(1)}this._eatBits(12),this.encoding>0&&(this._eatBits(1),this.nextLine2D=!(1&s))}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1],this.row++}if(this.outputBits>=8)c=1&this.codingPos?0:255,this.outputBits-=8,0===this.outputBits&&t[this.codingPos]s?(c<<=s,1&this.codingPos||(c|=255>>8-s),this.outputBits-=s,s=0):(c<<=this.outputBits,1&this.codingPos||(c|=255>>8-this.outputBits),s-=this.outputBits,this.outputBits=0,t[this.codingPos]0&&(c<<=s,s=0))}while(s)}return this.black&&(c^=255),c},_addPixels(e,t){const a=this.codingLine;let i=this.codingPos;e>a[i]&&(e>this.columns&&((0,r.info)("row is wrong length"),this.err=!0,e=this.columns),1&i^t&&++i,a[i]=e),this.codingPos=i},_addPixelsNeg(e,t){const a=this.codingLine;let i=this.codingPos;if(e>a[i])e>this.columns&&((0,r.info)("row is wrong length"),this.err=!0,e=this.columns),1&i^t&&++i,a[i]=e;else if(e0&&e=i){const t=a[e-i];if(t[0]===r)return this._eatBits(r),[!0,t[1],!0]}}return[!1,0,!1]},_getTwoDimCode(){let t,a=0;if(this.eoblock){if(a=this._lookBits(7),t=e[a],t&&t[0]>0)return this._eatBits(t[0]),t[1]}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}return(0,r.info)("Bad two dim code"),-1},_getWhiteCode(){let e,i=0;if(this.eoblock){if(i=this._lookBits(12),-1===i)return 1;if(e=i>>5==0?t[i]:a[i>>3],e[0]>0)return this._eatBits(e[0]),e[1]}else{let e=this._findTableCode(1,9,a);if(e[0])return e[1];if(e=this._findTableCode(11,12,t),e[0])return e[1]}return(0,r.info)("bad white code"),this._eatBits(1),1},_getBlackCode(){let e,t;if(this.eoblock){if(e=this._lookBits(13),-1===e)return 1;if(t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7],t[0]>0)return this._eatBits(t[0]),t[1]}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];if(e=this._findTableCode(7,12,n,64),e[0])return e[1];if(e=this._findTableCode(10,13,i),e[0])return e[1]}return(0,r.info)("bad black code"),this._eatBits(1),1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t,this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}},o}();t.CCITTFaxDecoder=i},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Jbig2Stream=void 0;var r=a(4),i=a(11),n=a(15),s=a(2);const o=function(){function e(e,t,a,r){this.stream=e,this.maybeLength=t,this.dict=a,this.params=r,i.DecodeStream.call(this,t)}return e.prototype=Object.create(i.DecodeStream.prototype),Object.defineProperty(e.prototype,"bytes",{get(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0}),e.prototype.ensureBuffer=function(e){},e.prototype.readBlock=function(){if(this.eof)return;const e=new n.Jbig2Image,t=[];if((0,r.isDict)(this.params)){const e=this.params.get("JBIG2Globals");if((0,r.isStream)(e)){const a=e.getBytes();t.push({data:a,start:0,end:a.length})}}t.push({data:this.bytes,start:0,end:this.bytes.length});const a=e.parseChunks(t),i=a.length;for(let e=0;e>>0}var s=n(1),o=n(1)?n(1)?n(1)?n(1)?n(1)?n(32)+4436:n(12)+340:n(8)+84:n(6)+20:n(4)+4:n(2);return 0===s?o:o>0?-o:null}function c(e,t,a){for(var r=e.getContexts("IAID"),i=1,n=0;n=D&&I=N)for(z=z<<1&y,f=0;f=0&&T=0&&(O=U[F][T])&&(z|=O<=e?D<<=1:D=D<<1|x[P][B];for(d=0;d=S||B<0||B>=k?D<<=1:D=D<<1|r[P][B];var N=A.readBit(I,D);E[O]=N}}return x}function p(e,t,r,i,n,s,l,h,u,d,f,g,p,b,y,v,w,k,S){if(e&&t)throw new o("refinement with Huffman is not supported");var C,x,A=[];for(C=0;C1&&(i=e?S.readBits(k):a(T,"IAIT",F));var B=l*E+i,D=e?b.symbolIDTable.decode(S):c(T,F,u),N=t&&(e?S.readBit():a(T,"IARI",F)),M=h[D],L=M[0].length,R=M.length;if(N){var U=a(T,"IARDW",F),q=a(T,"IARDH",F);M=m(L+=U,R+=q,y,M,(U>>1)+a(T,"IARDX",F),(q>>1)+a(T,"IARDY",F),!1,v,w)}var j,_,z,H=B-(1&g?0:R-1),G=P-(2&g?L-1:0);if(d){for(j=0;j>5&7,u=[31&c],d=t+6;if(7===c){h=536870911&(0,i.readUint32)(e,d-1),d+=3;var f=h+7>>3;for(u[0]=e[d++];--f>0;)u.push(e[d++])}else if(5===c||6===c)throw new o("invalid referred-to flags");a.retainBits=u;let g=4;a.number<=256?g=1:a.number<=65536&&(g=2);var m,p,b=[];for(m=0;m>>24&255,S[3]=y.height>>16&255,S[4]=y.height>>8&255,S[5]=255&y.height,m=d,p=e.length;m>2&3,d.huffmanDWSelector=f>>4&3,d.bitmapSizeSelector=f>>6&1,d.aggregationInstancesSelector=f>>7&1,d.bitmapCodingContextUsed=!!(256&f),d.bitmapCodingContextRetained=!!(512&f),d.template=f>>10&3,d.refinementTemplate=f>>12&1,h+=2,!d.huffman){for(s=0===d.template?4:1,r=[],n=0;n>2&3,g.stripSize=1<>4&3,g.transposed=!!(64&m),g.combinationOperator=m>>7&3,g.defaultPixelValue=m>>9&1,g.dsOffset=m<<17>>27,g.refinementTemplate=m>>15&1,g.huffman){var p=(0,i.readUint16)(l,h);h+=2,g.huffmanFS=3&p,g.huffmanDS=p>>2&3,g.huffmanDT=p>>4&3,g.huffmanRefinementDW=p>>6&3,g.huffmanRefinementDH=p>>8&3,g.huffmanRefinementDX=p>>10&3,g.huffmanRefinementDY=p>>12&3,g.huffmanRefinementSizeSelector=!!(16384&p)}if(g.refinement&&!g.refinementTemplate){for(r=[],n=0;n<2;n++)r.push({x:(0,i.readInt8)(l,h),y:(0,i.readInt8)(l,h+1)}),h+=2;g.refinementAt=r}g.numberOfSymbolInstances=(0,i.readUint32)(l,h),h+=4,a=[g,c.referredTo,l,h,u];break;case 16:const e={},t=l[h++];e.mmr=!!(1&t),e.template=t>>1&3,e.patternWidth=l[h++],e.patternHeight=l[h++],e.maxPatternIndex=(0,i.readUint32)(l,h),h+=4,a=[e,c.number,l,h,u];break;case 22:case 23:const C={};C.info=v(l,h),h+=w;const x=l[h++];C.mmr=!!(1&x),C.template=x>>1&3,C.enableSkip=!!(8&x),C.combinationOperator=x>>4&7,C.defaultPixelValue=x>>7&1,C.gridWidth=(0,i.readUint32)(l,h),h+=4,C.gridHeight=(0,i.readUint32)(l,h),h+=4,C.gridOffsetX=4294967295&(0,i.readUint32)(l,h),h+=4,C.gridOffsetY=4294967295&(0,i.readUint32)(l,h),h+=4,C.gridVectorX=(0,i.readUint16)(l,h),h+=2,C.gridVectorY=(0,i.readUint16)(l,h),h+=2,a=[C,c.referredTo,l,h,u];break;case 38:case 39:var b={};b.info=v(l,h),h+=w;var y=l[h++];if(b.mmr=!!(1&y),b.template=y>>1&3,b.prediction=!!(8&y),!b.mmr){for(s=0===b.template?4:1,r=[],n=0;n>2&1,k.combinationOperator=S>>3&3,k.requiresBuffer=!!(32&S),k.combinationOperatorOverride=!!(64&S),a=[k];break;case 49:case 50:case 51:break;case 53:a=[c.number,l,h,u];break;case 62:break;default:throw new o(`segment type ${c.typeName}(${c.type}) is not implemented`)}var C="on"+c.typeName;C in t&&t[C].apply(t,a)}function S(e,t){for(var a=0,r=e.length;a0&&this.rootNode.buildTree(a,a.prefixLength-1)}}C.prototype={onPageInformation:function(e){this.currentPageInfo=e;var t=e.width+7>>3,a=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var r=0,i=a.length;r>3,u=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,d=this.buffer,f=128>>(7&e.x),g=e.y*h+(e.x>>3);switch(u){case 0:for(a=0;a>=1)||(i=128,n++);g+=h}break;case 2:for(a=0;a>=1)||(i=128,n++);g+=h}break;default:throw new o(`operator ${u} is not supported`)}},onImmediateGenericRegion:function(e,a,r,i){var n=e.info,s=new t(a,r,i),o=g(e.mmr,n.width,n.height,e.template,e.prediction,null,e.at,s);this.drawBitmap(n,o)},onImmediateLosslessGenericRegion:function(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function(e,r,n,s,l,h){let u,d;e.huffman&&(u=function(e,t,a){let r,i,n,s,c=0;switch(e.huffmanDHSelector){case 0:case 1:r=T(e.huffmanDHSelector+4);break;case 3:r=O(c,t,a),c++;break;default:throw new o("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:i=T(e.huffmanDWSelector+2);break;case 3:i=O(c,t,a),c++;break;default:throw new o("invalid Huffman DW selector")}return e.bitmapSizeSelector?(n=O(c,t,a),c++):n=T(1),s=e.aggregationInstancesSelector?O(c,t,a):T(1),{tableDeltaHeight:r,tableDeltaWidth:i,tableBitmapSize:n,tableAggregateInstances:s}}(e,n,this.customTables),d=new E(s,l,h));var f=this.symbols;f||(this.symbols=f={});for(var b=[],y=0,v=n.length;y1)I=p(e,t,i,w,0,E,1,r.concat(v),k,0,0,1,0,l,d,f,b,0,y);else{var O=c(C,S,k),D=a(C,"IARDX",S),N=a(C,"IARDY",S);I=m(i,w,d,O=32){let a,r,s;switch(t){case 32:if(0===e)throw new o("no previous value in symbol ID table");r=i.readBits(2)+3,a=n[e-1].prefixLength;break;case 33:r=i.readBits(3)+3,a=0;break;case 34:r=i.readBits(7)+11,a=0;break;default:throw new o("invalid code length in symbol ID table")}for(s=0;s=0;v--)P=e?B(O,h,u,!0):g(!1,h,u,a,!1,null,F,b),T[v]=P;for(D=0;D=0;w--)M=T[w][D][N]^M,L|=M<>8,q=f+D*m-N*p>>8,U>=0&&U+x<=r&&q>=0&&q+A<=n)for(v=0;v=n))for(_=y[t],j=R[v],w=0;w=0&&e>1&7),l=1+(r>>4&7),h=[];let u,d,f=n;do{u=o.readBits(c),d=o.readBits(l),h.push(new x([f,u,d,0])),f+=1<>t&1;if(t<=0)this.children[a]=new A(e);else{let r=this.children[a];r||(this.children[a]=r=new A(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 o("invalid Huffman data");return t.decodeNode(e)}},I.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let a=0;for(let r=0;r>a&1,a--}if(r&&!l){const e=5;for(let t=0;t=this.end)throw new o("end of data while reading bit");this.currentByte=this.data[this.position++],this.shift=7}const e=this.currentByte>>this.shift&1;return this.shift--,e},readBits(e){let t,a=0;for(t=e-1;t>=0;t--)a|=this.readBit()<=this.end?-1:this.data[this.position++]}},D.prototype={parseChunks:e=>function(e){for(var t=new C,a=0,r=e.length;a>=1}return{imgData:d,width:l,height:h}}(e);return this.width=a,this.height=r,t}},D}();t.Jbig2Image=c},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ArithmeticDecoder=void 0;const r=[{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{constructor(e,t,a){this.data=e,this.bp=t,this.dataEnd=a,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;255===e[t]?e[t+1]>143?(this.clow+=65280,this.ct=8):(t++,this.clow+=e[t]<<9,this.ct=7,this.bp=t):(t++,this.clow+=t65535&&(this.chigh+=this.clow>>16,this.clow&=65535)}readBit(e,t){let a=e[t]>>1,i=1&e[t];const n=r[a],s=n.qe;let o,c=this.a-s;if(this.chigh>15&1,this.clow=this.clow<<1&65535,this.ct--}while(0==(32768&c));return this.a=c,e[t]=a<<1|i,o}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegStream=void 0;var r=a(2),i=a(11),n=a(4),s=a(18);const o=function(){function e(e,t,a,r){let n;for(;-1!==(n=e.getByte());)if(255===n){e.skip(-1);break}this.stream=e,this.maybeLength=t,this.dict=a,this.params=r,i.DecodeStream.call(this,t)}return e.prototype=Object.create(i.DecodeStream.prototype),Object.defineProperty(e.prototype,"bytes",{get:function(){return(0,r.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0}),e.prototype.ensureBuffer=function(e){},e.prototype.readBlock=function(){if(this.eof)return;const e={decodeTransform:void 0,colorTransform:void 0},t=this.dict.getArray("Decode","D");if(this.forceRGB&&Array.isArray(t)){const a=this.dict.get("BitsPerComponent")||8,r=t.length,i=new Int32Array(r);let n=!1;const s=(1<10*a){s=!1;break}break;case 195:case 197:case 198:case 199:case 201:case 202:case 203:case 205:case 206:case 207:o=!0;break;case 196:case 204:case 218:case 219:case 220:case 221:case 222:case 223:case 224:case 225:case 226:case 227:case 228:case 229:case 230:case 231:case 232:case 233:case 234:case 235:case 236:case 237:case 238:case 239:case 254:const r=t.getUint16();r>2?t.skip(r-2):t.skip(-2);break;case 255:t.skip(-1);break;case 217:o=!0}if(o)break}return t.pos=i,(0,r.shadow)(this,"maybeValidDimensions",s)},configurable:!0}),e.prototype.getIR=function(e=!1){return(0,r.createObjectURL)(this.bytes,"image/jpeg",e)},e}();t.JpegStream=o},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.JpegImage=void 0;var r=a(2),i=a(7);class n extends r.BaseException{constructor(e){super("JPEG error: "+e)}}class s extends r.BaseException{constructor(e,t){super(e),this.scanLines=t}}class o extends r.BaseException{}var c=function(){var e=new Uint8Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]);function t({decodeTransform:e=null,colorTransform:t=-1}={}){this._decodeTransform=e,this._colorTransform=t}function a(e,t){for(var a,r,i=0,n=[],s=16;s>0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(a=0;a0;)c=n.pop();for(c.index++,n.push(c);n.length<=a;)n.push(o={children:[],index:0}),c.children[c.index]=o.children,c=o;i++}a+10)return S--,k>>S&1;if(255===(k=t[a++])){var e=t[a++];if(e){if(220===e&&b){a+=2;const e=(0,i.readUint16)(t,a);if(a+=2,e>0&&e!==l.scanLines)throw new s("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(b){const e=8*O;if(e>0&&e>>7}function x(e){for(var t=e;;){switch(typeof(t=t[C()])){case"number":return t;case"object":continue}throw new n("invalid huffman sequence")}}function A(e){for(var t=0;e>0;)t=t<<1|C(),e--;return t}function I(e){if(1===e)return 1===C()?1:-1;var t=A(e);return t>=1<0)T--;else for(var r=f,i=g;r<=i;){var n=x(t.huffmanTableAC),s=15&n,o=n>>4;if(0!==s){var c=e[r+=o];t.blockData[a+c]=I(s)*(1<>4,0==(r=15&i))c<15?(T=A(c)+(1<>4;if(0!==o){var l=e[n+=c];t.blockData[a+l]=I(o),n++}else{if(c<15)break;n+=16}}};var j,_,z,H,G=0;for(_=1===q?h[0].blocksPerLine*h[0].blocksPerColumn:y*l.mcusPerColumn;G<_;){var W=u?Math.min(_-G,u):_;for(N=0;N=65488&&X<=65495))break;a+=2}return(j=d(t,a))&&j.invalid&&((0,r.warn)("decodeScan - unexpected Scan data, current marker is: "+j.invalid),a=j.offset),a-w}function h(e,t,a){var r,i,s,o,c,l,h,u,d,f,g,m,p,b,y,v,w,k=e.quantizationTable,S=e.blockData;if(!k)throw new n("missing required Quantization Table.");for(var C=0;C<64;C+=8)d=S[t+C],f=S[t+C+1],g=S[t+C+2],m=S[t+C+3],p=S[t+C+4],b=S[t+C+5],y=S[t+C+6],v=S[t+C+7],d*=k[C],0!=(f|g|m|p|b|y|v)?(f*=k[C+1],g*=k[C+2],m*=k[C+3],p*=k[C+4],b*=k[C+5],i=(r=(r=5793*d+128>>8)+(i=5793*p+128>>8)+1>>1)-i,w=3784*(s=g)+1567*(o=y*=k[C+6])+128>>8,s=1567*s-3784*o+128>>8,h=(c=(c=2896*(f-(v*=k[C+7]))+128>>8)+(h=b<<4)+1>>1)-h,l=(u=(u=2896*(f+v)+128>>8)+(l=m<<4)+1>>1)-l,o=(r=r+(o=w)+1>>1)-o,s=(i=i+s+1>>1)-s,w=2276*c+3406*u+2048>>12,c=3406*c-2276*u+2048>>12,u=w,w=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,h=w,a[C]=r+u,a[C+7]=r-u,a[C+1]=i+h,a[C+6]=i-h,a[C+2]=s+l,a[C+5]=s-l,a[C+3]=o+c,a[C+4]=o-c):(w=5793*d+512>>10,a[C]=w,a[C+1]=w,a[C+2]=w,a[C+3]=w,a[C+4]=w,a[C+5]=w,a[C+6]=w,a[C+7]=w);for(var x=0;x<8;++x)d=a[x],0!=((f=a[x+8])|(g=a[x+16])|(m=a[x+24])|(p=a[x+32])|(b=a[x+40])|(y=a[x+48])|(v=a[x+56]))?(i=(r=4112+((r=5793*d+2048>>12)+(i=5793*p+2048>>12)+1>>1))-i,w=3784*(s=g)+1567*(o=y)+2048>>12,s=1567*s-3784*o+2048>>12,o=w,h=(c=(c=2896*(f-v)+2048>>12)+(h=b)+1>>1)-h,l=(u=(u=2896*(f+v)+2048>>12)+(l=m)+1>>1)-l,w=2276*c+3406*u+2048>>12,c=3406*c-2276*u+2048>>12,u=w,w=799*l+4017*h+2048>>12,l=4017*l-799*h+2048>>12,(d=(r=r+o+1>>1)+u)<16?d=0:d>=4080?d=255:d>>=4,(f=(i=i+s+1>>1)+(h=w))<16?f=0:f>=4080?f=255:f>>=4,(g=(s=i-s)+l)<16?g=0:g>=4080?g=255:g>>=4,(m=(o=r-o)+c)<16?m=0:m>=4080?m=255:m>>=4,(p=o-c)<16?p=0:p>=4080?p=255:p>>=4,(b=s-l)<16?b=0:b>=4080?b=255:b>>=4,(y=i-h)<16?y=0:y>=4080?y=255:y>>=4,(v=r-u)<16?v=0:v>=4080?v=255:v>>=4,S[t+x]=d,S[t+x+8]=f,S[t+x+16]=g,S[t+x+24]=m,S[t+x+32]=p,S[t+x+40]=b,S[t+x+48]=y,S[t+x+56]=v):(w=(w=5793*d+8192>>14)<-2040?0:w>=2024?255:w+2056>>4,S[t+x]=w,S[t+x+8]=w,S[t+x+16]=w,S[t+x+24]=w,S[t+x+32]=w,S[t+x+40]=w,S[t+x+48]=w,S[t+x+56]=w)}function u(e,t){for(var a=t.blocksPerLine,r=t.blocksPerColumn,i=new Int16Array(64),n=0;n=r)return null;var s=(0,i.readUint16)(e,t);if(s>=65472&&s<=65534)return{invalid:null,marker:s,offset:t};for(var o=(0,i.readUint16)(e,n);!(o>=65472&&o<=65534);){if(++n>=r)return null;o=(0,i.readUint16)(e,n)}return{invalid:s.toString(16),marker:o,offset:n}}return t.prototype={parse(t,{dnlScanLines:c=null}={}){function h(){const e=(0,i.readUint16)(t,p);let a=(p+=2)+e-2;var n=d(t,a,p);n&&n.invalid&&((0,r.warn)("readDataBlock - incorrect length, current marker is: "+n.invalid),a=n.offset);var s=t.subarray(p,a);return p+=s.length,s}function f(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),a=Math.ceil(e.scanLines/8/e.maxV),r=0;r>4==0)for(A=0;A<64;A++)O[e[A]]=t[p++];else{if(E>>4!=1)throw new n("DQT - invalid table spec");for(A=0;A<64;A++)O[e[A]]=(0,i.readUint16)(t,p),p+=2}w[15&E]=O}break;case 65472:case 65473:case 65474:if(g)throw new n("Only single frame JPEGs supported");p+=2,(g={}).extended=65473===C,g.progressive=65474===C,g.precision=t[p++];const u=(0,i.readUint16)(t,p);p+=2,g.scanLines=c||u,g.samplesPerLine=(0,i.readUint16)(t,p),p+=2,g.components=[],g.componentIds={};var P,B=t[p++],D=0,N=0;for(x=0;x>4,L=15&t[p+1];D>4==0?S:k)[15&U]=a(q,_)}break;case 65501:p+=2,m=(0,i.readUint16)(t,p),p+=2;break;case 65498:const $=1==++v&&!c;p+=2;var z,H=t[p++],G=[];for(x=0;x>4],z.huffmanTableAC=k[15&X],G.push(z)}var V=t[p++],K=t[p++],Y=t[p++];try{var J=l(t,p,g,G,m,V,K,Y>>4,15&Y,$);p+=J}catch(e){if(e instanceof s)return(0,r.warn)(e.message+" -- attempting to re-parse the JPEG image."),this.parse(t,{dnlScanLines:e.scanLines});if(e instanceof o){(0,r.warn)(e.message+" -- ignoring the rest of the image data.");break e}throw e}break;case 65500:p+=4;break;case 65535:255!==t[p]&&p--;break;default:const Q=d(t,p-2,p-3);if(Q&&Q.invalid){(0,r.warn)("JpegImage.parse - unexpected data, current marker is: "+Q.invalid),p=Q.offset;break}if(p>=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 n("JpegImage.parse - unknown marker: "+C.toString(16))}C=(0,i.readUint16)(t,p),p+=2}for(this.width=g.samplesPerLine,this.height=g.scanLines,this.jfif=b,this.adobe=y,this.components=[],x=0;x>8)+S[u+1];return v},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform:1===this._colorTransform},_convertYccToRgb:function(e){for(var t,a,r,i=0,n=e.length;i4)throw new n("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,r);if(1===this.numComponents&&a){for(var s=i.length,o=new Uint8ClampedArray(3*s),c=0,l=0;l0?Math.min(r.xcb,i.PPx-1):Math.min(r.xcb,i.PPx),i.ycb_=a>0?Math.min(r.ycb,i.PPy-1):Math.min(r.ycb,i.PPy),i}function l(e,t,a){var r=1<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,h=c*l;t.precinctParameters={precinctWidth:r,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function h(e,t,a){var r,i,n,s,o=a.xcb_,c=a.ycb_,l=1<>o,d=t.tby0>>c,f=t.tbx1+l-1>>o,g=t.tby1+h-1>>c,m=t.resolution.precinctParameters,p=[],b=[];for(i=d;iy.cbxMax&&(y.cbxMax=r),iy.cbyMax&&(y.cbyMax=i)):b[s]=y={cbxMin:r,cbyMin:i,cbxMax:r,cbyMax:i},n.precinct=y}t.codeblockParameters={codeblockWidth:o,codeblockHeight:c,numcodeblockwide:f-u+1,numcodeblockhigh:g-d+1},t.codeblocks=p,t.precincts=b}function u(e,t,a){for(var r=[],i=e.subbands,n=0,s=i.length;ne.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[h],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],a=t.precinctParameters.numprecincts;fe.codingStyleParameters.decompositionLevelsCount)){var n=e.resolutions[a],o=n.precinctParameters.numprecincts;if(!(i>=o)){for(;t=0;--p){var b=c.resolutions[p],y=m*b.precinctParameters.precinctWidth,v=m*b.precinctParameters.precinctHeight;u=Math.min(u,y),d=Math.min(d,v),f=Math.max(f,b.precinctParameters.numprecinctswide),g=Math.max(g,b.precinctParameters.numprecinctshigh),h[p]={width:y,height:v},m<<=1}a=Math.min(a,u),r=Math.min(r,d),i=Math.max(i,f),n=Math.max(n,g),s[o]={resolutions:h,minWidth:u,minHeight:d,maxNumWide:f,maxNumHigh:g}}return{components:s,minWidth:a,minHeight:r,maxNumWide:i,maxNumHigh:n}}function v(e){for(var t=e.SIZ,a=e.currentTile.index,r=e.tiles[a],i=t.Csiz,n=0;n>>(o-=e)&(1<0;){var q=S.shift();void 0===(w=q.codeblock).data&&(w.data=[]),w.data.push({data:t,start:a+s,end:a+s+q.dataLength,codingpasses:q.codingpasses}),s+=q.dataLength}}}return s}function k(e,t,a,r,i,s,o,c){for(var l=r.tbx0,h=r.tby0,u=r.tbx1-r.tbx0,d=r.codeblocks,f="H"===r.type.charAt(0)?1:0,g="H"===r.type.charAt(1)?t:0,m=0,p=d.length;m=s?N:N*(1<0?1-b:0));var F=y.subbands[C],O=e[F.type];k(S,v,0,F,f?1:2**(d+O-I)*(1+A/2048),h+I-1,f,u)}m.push({width:v,height:w,items:S})}var P=g.calculate(m,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:P.width,height:P.height,items:P.items}}function C(e,t){for(var a=e.SIZ.Csiz,r=e.tiles[t],i=0;i>24&255,c>>16&255,c>>8&255,255&c);(0,r.warn)("Unsupported header type "+c+" ("+f+")")}h&&(t+=l)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function(e){for(var t=e.getByte();t>=0;)if(65361==(t<<8|(t=e.getByte()))){e.skip(4);var a=e.getInt32()>>>0,r=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0;e.skip(16);var o=e.getUint16();return this.width=a-i,this.height=r-n,this.componentsCount=o,void(this.bitsPerComponent=8)}throw new s("No size marker found in JPX stream")},parseCodestream:function(e,t,n){var c={},l=!1;try{for(var h=t;h+1>5,g=[];d>3,E.mu=0):(E.epsilon=e[d]>>3,E.mu=(7&e[d])<<8|e[d+1],d+=2),g.push(E)}T.SPqcds=g,c.mainHeader?c.QCD=T:(c.currentTile.QCD=T,c.currentTile.QCC=[]);break;case 65373:y=(0,i.readUint16)(e,h);var O,P={};switch(d=h+2,c.SIZ.Csiz<257?O=e[d++]:(O=(0,i.readUint16)(e,d),d+=2),31&(f=e[d++])){case 0:m=8,p=!0;break;case 1:m=16,p=!1;break;case 2:m=16,p=!0;break;default:throw new Error("Invalid SQcd value "+f)}for(P.noQuantization=8===m,P.scalarExpounded=p,P.guardBits=f>>5,g=[];d>3,E.mu=0):(E.epsilon=e[d]>>3,E.mu=(7&e[d])<<8|e[d+1],d+=2),g.push(E);P.SPqcds=g,c.mainHeader?c.QCC[O]=P:c.currentTile.QCC[O]=P;break;case 65362:y=(0,i.readUint16)(e,h);var B={};d=h+2;var D=e[d++];B.entropyCoderWithCustomPrecincts=!!(1&D),B.sopMarkerUsed=!!(2&D),B.ephMarkerUsed=!!(4&D),B.progressionOrder=e[d++],B.layersCount=(0,i.readUint16)(e,d),d+=2,B.multipleComponentTransform=e[d++],B.decompositionLevelsCount=e[d++],B.xcb=2+(15&e[d++]),B.ycb=2+(15&e[d++]);var N=e[d++];if(B.selectiveArithmeticCodingBypass=!!(1&N),B.resetContextProbabilities=!!(2&N),B.terminationOnEachCodingPass=!!(4&N),B.verticallyStripe=!!(8&N),B.predictableTermination=!!(16&N),B.segmentationSymbolUsed=!!(32&N),B.reversibleTransformation=e[d++],B.entropyCoderWithCustomPrecincts){for(var M=[];d>4})}B.precinctsSizes=M}var R=[];if(B.selectiveArithmeticCodingBypass&&R.push("selectiveArithmeticCodingBypass"),B.resetContextProbabilities&&R.push("resetContextProbabilities"),B.terminationOnEachCodingPass&&R.push("terminationOnEachCodingPass"),B.verticallyStripe&&R.push("verticallyStripe"),B.predictableTermination&&R.push("predictableTermination"),R.length>0)throw l=!0,new Error("Unsupported COD options ("+R.join(", ")+")");c.mainHeader?c.COD=B:(c.currentTile.COD=B,c.currentTile.COC=[]);break;case 65424:y=(0,i.readUint16)(e,h),(b={}).index=(0,i.readUint16)(e,h+2),b.length=(0,i.readUint32)(e,h+4),b.dataEnd=b.length+h-2,b.partIndex=e[h+8],b.partsCount=e[h+9],c.mainHeader=!1,0===b.partIndex&&(b.COD=c.COD,b.COC=c.COC.slice(0),b.QCD=c.QCD,b.QCC=c.QCC.slice(0)),c.currentTile=b;break;case 65427:0===(b=c.currentTile).partIndex&&(C(c,b.index),v(c)),w(c,e,h,y=b.dataEnd-h);break;case 65365:case 65367:case 65368:case 65380:y=(0,i.readUint16)(e,h);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+u.toString(16))}h+=y}}catch(e){if(l||this.failOnCorruptedImage)throw new s(e.message);(0,r.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function(e){for(var t=e.SIZ,a=e.components,r=t.Csiz,i=[],n=0,s=e.tiles.length;n>2);y[w++]=e+p>>h,y[w++]=e>>h,y[w++]=e+m>>h}else for(d=0;d>h,y[w++]=g-.34413*m-.71414*p>>h,y[w++]=g+1.772*m>>h;if(k)for(d=0,w=3;d>h}else for(o=0;o>h,w+=r}i.push(v)}return i}(c),this.width=c.SIZ.Xsiz-c.SIZ.XOsiz,this.height=c.SIZ.Ysiz-c.SIZ.YOsiz,this.componentsCount=c.SIZ.Csiz}};var x=function(){function e(e,t){var a=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var r=0;r>=1,t>>=1,r++}r--,(a=this.levels[r]).items[a.index]=i,this.currentLevel=r,delete this.value},incrementValue:function(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];return--e<0?(this.value=a,!1):(this.currentLevel=e,(t=this.levels[e]).items[t.index]=a,!0)}},e}(),A=function(){function e(e,t,a){var r=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var n=0;na)return this.currentLevel=r,this.propagateValues(),!1;e>>=1,t>>=1,r++}return this.currentLevel=r-1,!0},incrementValue:function(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1,this.propagateValues()},propagateValues:function(){for(var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=a},nextLevel:function(){var e=this.currentLevel,t=this.levels[e],a=t.items[t.index];return t.items[t.index]=255,!(--e<0)&&(this.currentLevel=e,(t=this.levels[e]).items[t.index]=a,!0)}},e}(),I=function(){var e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),t=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),a=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 r(r,i,n,s,o){let c;this.width=r,this.height=i,c="HH"===n?a:"HL"===n?t:e,this.contextLabelTable=c;var l=r*i;let h;this.neighborsSignificance=new Uint8Array(l),this.coefficentsSign=new Uint8Array(l),h=o>14?new Uint32Array(l):o>6?new Uint16Array(l):new Uint8Array(l),this.coefficentsMagnitude=h,this.processingFlags=new Uint8Array(l);var u=new Uint8Array(l);if(0!==s)for(var d=0;d0,c=t+10&&(r=a-n,o&&(i[r-1]+=16),c&&(i[r+1]+=16),i[r]+=4),e+1=a)break;if(s[d]&=-2,!r[d]&&n[d]){var m=c[n[d]];if(e.readBit(o,m)){var p=this.decodeSignBit(g,u,d);i[d]=p,r[d]=1,this.setNeighborsSignificance(g,u,d),s[d]|=2}l[d]++,s[d]|=1}}},decodeSignBit:function(e,t,a){var r,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==u[a-1],t+10&&0!==u[a-l],e+1=0?(o=9+r,c=this.decoder.readBit(this.contexts,o)):(o=9-r,c=1^this.decoder.readBit(this.contexts,o)),c},runMagnitudeRefinementPass:function(){for(var e,t=this.decoder,a=this.width,r=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=a*r,h=4*a,u=0;u>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,d=1.230174104914001;for(r=(t|=0)-3,i=o+4;i--;r+=2)e[r]*=.8128930661159609;for(n=u*e[(r=t-2)-1],i=o+3;i--&&(s=u*e[r+1],e[r]=d*e[r]-n-s,i--);r+=2)n=u*e[(r+=2)+1],e[r]=d*e[r]-n-s;for(n=h*e[(r=t-1)-1],i=o+2;i--&&(s=h*e[r+1],e[r]-=n+s,i--);r+=2)n=h*e[(r+=2)+1],e[r]-=n+s;for(n=l*e[(r=t)-1],i=o+1;i--&&(s=l*e[r+1],e[r]-=n+s,i--);r+=2)n=l*e[(r+=2)+1],e[r]-=n+s;if(0!==o)for(n=c*e[(r=t+1)-1],i=o;i--&&(s=c*e[r+1],e[r]-=n+s,i--);r+=2)n=c*e[(r+=2)+1],e[r]-=n+s},e}(),E=function(){function e(){F.call(this)}return e.prototype=Object.create(F.prototype),e.prototype.filter=function(e,t,a){var r,i,n=a>>1;for(r=t|=0,i=n+1;i--;r+=2)e[r]-=e[r-1]+e[r+1]+2>>2;for(r=t+1,i=n;i--;r+=2)e[r]+=e[r-1]+e[r+1]>>1},e}();return t}();t.JpxImage=o},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.calculateSHA512=t.calculateSHA384=t.calculateSHA256=t.calculateMD5=t.PDF20=t.PDF17=t.CipherTransformFactory=t.ARCFourCipher=t.AES256Cipher=t.AES128Cipher=void 0;var r=a(2),i=a(4),n=a(11),s=function(){function e(e){this.a=0,this.b=0;var t,a,r=new Uint8Array(256),i=0,n=e.length;for(t=0;t<256;++t)r[t]=t;for(t=0;t<256;++t)i=i+(a=r[t])+e[t%n]&255,r[t]=r[i],r[i]=a;this.s=r}return e.prototype={encryptBlock:function(e){var t,a,r,i=e.length,n=this.a,s=this.b,o=this.s,c=new Uint8Array(i);for(t=0;t>5&255,f[r++]=a>>13&255,f[r++]=a>>21&255,f[r++]=a>>>29&255,f[r++]=0,f[r++]=0,f[r++]=0;var g=new Int32Array(16);for(r=0;r>>32-C)|0,b=k}s=s+b|0,l=l+y|0,h=h+v|0,u=u+w|0}return new Uint8Array([255&s,s>>8&255,s>>16&255,s>>>24&255,255&l,l>>8&255,l>>16&255,l>>>24&255,255&h,h>>8&255,h>>16&255,h>>>24&255,255&u,u>>8&255,u>>16&255,u>>>24&255])});t.calculateMD5=l;var h=function(){function e(e,t){this.high=0|e,this.low=0|t}return e.prototype={and:function(e){this.high&=e.high,this.low&=e.low},xor:function(e){this.high^=e.high,this.low^=e.low},or:function(e){this.high|=e.high,this.low|=e.low},shiftRight:function(e){e>=32?(this.low=this.high>>>e-32|0,this.high=0):(this.low=this.low>>>e|this.high<<32-e,this.high=this.high>>>e|0)},shiftLeft:function(e){e>=32?(this.high=this.low<>>32-e,this.low=this.low<>>e|a<<32-e,this.high=a>>>e|t<<32-e},not:function(){this.high=~this.high,this.low=~this.low},add:function(e){var t=(this.low>>>0)+(e.low>>>0),a=(this.high>>>0)+(e.high>>>0);t>4294967295&&(a+=1),this.low=0|t,this.high=0|a},copyTo:function(e,t){e[t]=this.high>>>24&255,e[t+1]=this.high>>16&255,e[t+2]=this.high>>8&255,e[t+3]=255&this.high,e[t+4]=this.low>>>24&255,e[t+5]=this.low>>16&255,e[t+6]=this.low>>8&255,e[t+7]=255&this.low},assign:function(e){this.high=e.high,this.low=e.low}},e}(),u=function(){function e(e,t){return e>>>t|e<<32-t}function t(e,t,a){return e&t^~e&a}function a(e,t,a){return e&t^e&a^t&a}function r(t){return e(t,2)^e(t,13)^e(t,22)}function i(t){return e(t,6)^e(t,11)^e(t,25)}function n(t){return e(t,7)^e(t,18)^t>>>3}var s=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];return function(o,c,l){var h,u,d,f=1779033703,g=3144134277,m=1013904242,p=2773480762,b=1359893119,y=2600822924,v=528734635,w=1541459225,k=64*Math.ceil((l+9)/64),S=new Uint8Array(k);for(h=0;h>>29&255,S[h++]=l>>21&255,S[h++]=l>>13&255,S[h++]=l>>5&255,S[h++]=l<<3&255;var C,x=new Uint32Array(64);for(h=0;h>>10)+x[u-7]+n(x[u-15])+x[u-16]|0;var A,I,F=f,T=g,E=m,O=p,P=b,B=y,D=v,N=w;for(u=0;u<64;++u)A=N+i(P)+t(P,B,D)+s[u]+x[u],I=r(F)+a(F,T,E),N=D,D=B,B=P,P=O+A|0,O=E,E=T,T=F,F=A+I|0;f=f+F|0,g=g+T|0,m=m+E|0,p=p+O|0,b=b+P|0,y=y+B|0,v=v+D|0,w=w+N|0}return new Uint8Array([f>>24&255,f>>16&255,f>>8&255,255&f,g>>24&255,g>>16&255,g>>8&255,255&g,m>>24&255,m>>16&255,m>>8&255,255&m,p>>24&255,p>>16&255,p>>8&255,255&p,b>>24&255,b>>16&255,b>>8&255,255&b,y>>24&255,y>>16&255,y>>8&255,255&y,v>>24&255,v>>16&255,v>>8&255,255&v,w>>24&255,w>>16&255,w>>8&255,255&w])}}();t.calculateSHA256=u;var d=function(){function e(e,t,a,r,i){e.assign(t),e.and(a),i.assign(t),i.not(),i.and(r),e.xor(i)}function t(e,t,a,r,i){e.assign(t),e.and(a),i.assign(t),i.and(r),e.xor(i),i.assign(a),i.and(r),e.xor(i)}function a(e,t,a){e.assign(t),e.rotateRight(28),a.assign(t),a.rotateRight(34),e.xor(a),a.assign(t),a.rotateRight(39),e.xor(a)}function r(e,t,a){e.assign(t),e.rotateRight(14),a.assign(t),a.rotateRight(18),e.xor(a),a.assign(t),a.rotateRight(41),e.xor(a)}function i(e,t,a){e.assign(t),e.rotateRight(1),a.assign(t),a.rotateRight(8),e.xor(a),a.assign(t),a.shiftRight(7),e.xor(a)}function n(e,t,a){e.assign(t),e.rotateRight(19),a.assign(t),a.rotateRight(61),e.xor(a),a.assign(t),a.shiftRight(6),e.xor(a)}var s=[new h(1116352408,3609767458),new h(1899447441,602891725),new h(3049323471,3964484399),new h(3921009573,2173295548),new h(961987163,4081628472),new h(1508970993,3053834265),new h(2453635748,2937671579),new h(2870763221,3664609560),new h(3624381080,2734883394),new h(310598401,1164996542),new h(607225278,1323610764),new h(1426881987,3590304994),new h(1925078388,4068182383),new h(2162078206,991336113),new h(2614888103,633803317),new h(3248222580,3479774868),new h(3835390401,2666613458),new h(4022224774,944711139),new h(264347078,2341262773),new h(604807628,2007800933),new h(770255983,1495990901),new h(1249150122,1856431235),new h(1555081692,3175218132),new h(1996064986,2198950837),new h(2554220882,3999719339),new h(2821834349,766784016),new h(2952996808,2566594879),new h(3210313671,3203337956),new h(3336571891,1034457026),new h(3584528711,2466948901),new h(113926993,3758326383),new h(338241895,168717936),new h(666307205,1188179964),new h(773529912,1546045734),new h(1294757372,1522805485),new h(1396182291,2643833823),new h(1695183700,2343527390),new h(1986661051,1014477480),new h(2177026350,1206759142),new h(2456956037,344077627),new h(2730485921,1290863460),new h(2820302411,3158454273),new h(3259730800,3505952657),new h(3345764771,106217008),new h(3516065817,3606008344),new h(3600352804,1432725776),new h(4094571909,1467031594),new h(275423344,851169720),new h(430227734,3100823752),new h(506948616,1363258195),new h(659060556,3750685593),new h(883997877,3785050280),new h(958139571,3318307427),new h(1322822218,3812723403),new h(1537002063,2003034995),new h(1747873779,3602036899),new h(1955562222,1575990012),new h(2024104815,1125592928),new h(2227730452,2716904306),new h(2361852424,442776044),new h(2428436474,593698344),new h(2756734187,3733110249),new h(3204031479,2999351573),new h(3329325298,3815920427),new h(3391569614,3928383900),new h(3515267271,566280711),new h(3940187606,3454069534),new h(4118630271,4000239992),new h(116418474,1914138554),new h(174292421,2731055270),new h(289380356,3203993006),new h(460393269,320620315),new h(685471733,587496836),new h(852142971,1086792851),new h(1017036298,365543100),new h(1126000580,2618297676),new h(1288033470,3409855158),new h(1501505948,4234509866),new h(1607167915,987167468),new h(1816402316,1246189591)];return function(o,c,l,u){var d,f,g,m,p,b,y,v;(u=!!u)?(d=new h(3418070365,3238371032),f=new h(1654270250,914150663),g=new h(2438529370,812702999),m=new h(355462360,4144912697),p=new h(1731405415,4290775857),b=new h(2394180231,1750603025),y=new h(3675008525,1694076839),v=new h(1203062813,3204075428)):(d=new h(1779033703,4089235720),f=new h(3144134277,2227873595),g=new h(1013904242,4271175723),m=new h(2773480762,1595750129),p=new h(1359893119,2917565137),b=new h(2600822924,725511199),y=new h(528734635,4215389547),v=new h(1541459225,327033209));var w,k,S,C=128*Math.ceil((l+17)/128),x=new Uint8Array(C);for(w=0;w>>29&255,x[w++]=l>>21&255,x[w++]=l>>13&255,x[w++]=l>>5&255,x[w++]=l<<3&255;var A=new Array(80);for(w=0;w<80;w++)A[w]=new h(0,0);var I,F,T=new h(0,0),E=new h(0,0),O=new h(0,0),P=new h(0,0),B=new h(0,0),D=new h(0,0),N=new h(0,0),M=new h(0,0),L=new h(0,0),R=new h(0,0),U=new h(0,0),q=new h(0,0);for(w=0;w=1;--e){a=n[13],n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=a,a=n[14],r=n[10],n[14]=n[6],n[10]=n[2],n[6]=a,n[2]=r,a=n[15],r=n[11],i=n[7],n[15]=n[3],n[11]=a,n[7]=r,n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]];for(let a=0,r=16*e;a<16;++a,++r)n[a]^=t[r];for(let e=0;e<16;e+=4){const t=this._mix[n[e]],r=this._mix[n[e+1]],i=this._mix[n[e+2]],s=this._mix[n[e+3]];a=t^r>>>8^r<<24^i>>>16^i<<16^s>>>24^s<<8,n[e]=a>>>24&255,n[e+1]=a>>16&255,n[e+2]=a>>8&255,n[e+3]=255&a}}a=n[13],n[13]=n[9],n[9]=n[5],n[5]=n[1],n[1]=a,a=n[14],r=n[10],n[14]=n[6],n[10]=n[2],n[6]=a,n[2]=r,a=n[15],r=n[11],i=n[7],n[15]=n[3],n[11]=a,n[7]=r,n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]],n[e]^=t[e];return n}_encrypt(e,t){const a=this._s;let r,i,n;const s=new Uint8Array(16);s.set(e);for(let e=0;e<16;++e)s[e]^=t[e];for(let e=1;e=r;--a)if(e[a]!==t){t=0;break}o-=t,n[n.length-1]=e.subarray(0,16-t)}}const c=new Uint8Array(o);for(let e=0,t=0,a=n.length;e=256&&(o=255&(27^o)));for(let t=0;t<4;++t)a[e]=r^=a[e-32],e++,a[e]=i^=a[e-32],e++,a[e]=n^=a[e-32],e++,a[e]=s^=a[e-32],e++}return a}}t.AES256Cipher=b;var y=function(){function e(e,t){if(e.length!==t.length)return!1;for(var a=0;as-32;){var o=t.length+i.length+r.length,c=new Uint8Array(64*o),l=e(t,i);l=e(l,r);for(var h=0,g=0;h<64;h++,g+=o)c.set(l,g);n=new p(i.subarray(0,16)).encrypt(c,i.subarray(16,32));for(var m=0,b=0;b<16;b++)m*=1,m%=3,m+=(n[b]>>>0)%3,m%=3;0===m?i=u(n,0,n.length):1===m?i=f(n,0,n.length):2===m&&(i=d(n,0,n.length)),s++}return i.subarray(0,32)}function a(){}function r(e,t){if(e.length!==t.length)return!1;for(var a=0;a>8&255,g[m++]=n>>16&255,g[m++]=n>>>24&255,u=0,d=t.length;u=4&&!h&&(g[m++]=255,g[m++]=255,g[m++]=255,g[m++]=255);var p=l(g,0,m),b=c>>3;if(o>=3)for(u=0;u<50;++u)p=l(p,0,b);var y,v=p.subarray(0,b);if(o>=3){for(m=0;m<32;++m)g[m]=e[m];for(u=0,d=t.length;u>3;if(r>=3)for(n=0;n<50;++n)d=l(d,0,d.length);if(r>=3){u=a;var g,m=new Uint8Array(f);for(n=19;n>=0;n--){for(g=0;g=4){var D=n.get("CF");(0,i.isDict)(D)&&(D.suppressEncryption=!0),this.cf=D,this.stmf=n.get("StmF")||a,this.strf=n.get("StrF")||a,this.eff=n.get("EFF")||this.stmf}}function o(e,t,a,r){var i,n,s=new Uint8Array(a.length+9);for(i=0,n=a.length;i>8&255,s[i++]=e>>16&255,s[i++]=255&t,s[i++]=t>>8&255,r&&(s[i++]=115,s[i++]=65,s[i++]=108,s[i++]=84),l(s,0,i).subarray(0,Math.min(a.length+5,16))}function c(e,t,a,n,c){if(!(0,i.isName)(t))throw new r.FormatError("Invalid crypt filter name.");var l,h=e.get(t.name);if(null!=h&&(l=h.get("CFM")),!l||"None"===l.name)return function(){return new g};if("V2"===l.name)return function(){return new s(o(a,n,c,!1))};if("AESV2"===l.name)return function(){return new p(o(a,n,c,!0))};if("AESV3"===l.name)return function(){return new b(c)};throw new r.FormatError("Unknown crypto method")}return n.prototype={createCipherTransform:function(e,t){if(4===this.algorithm||5===this.algorithm)return new w(c(this.cf,this.stmf,e,t,this.encryptionKey),c(this.cf,this.strf,e,t,this.encryptionKey));var a=o(e,t,this.encryptionKey,!1),r=function(){return new s(a)};return new w(r,r)}},n}();t.CipherTransformFactory=k},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ColorSpace=void 0;var r=a(2),i=a(4);class n{constructor(e,t){this.constructor===n&&(0,r.unreachable)("Cannot initialize ColorSpace."),this.name=e,this.numComps=t}getRgb(e,t){const a=new Uint8ClampedArray(3);return this.getRgbItem(e,t,a,0),a}getRgbItem(e,t,a,i){(0,r.unreachable)("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,a,i,n,s,o){(0,r.unreachable)("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){(0,r.unreachable)("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return n.isDefaultDecode(e,this.numComps)}fillRgb(e,t,a,r,i,n,s,o,c){const l=t*a;let h=null;const u=1<u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=s<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e8?((e+16)/116)**3:e*((24/116)**3/8)}function f(r,n,f,g,m,p){const b=u(0,1,n[f]*p),y=u(0,1,n[f+1]*p),v=u(0,1,n[f+2]*p),w=b**r.GR,k=y**r.GG,S=v**r.GB,C=r.MXA*w+r.MXB*k+r.MXC*S,x=r.MYA*w+r.MYB*k+r.MYC*S,A=r.MZA*w+r.MZB*k+r.MZC*S,I=o;I[0]=C,I[1]=x,I[2]=A;const F=c;!function(a,r,i){if(1===a[0]&&1===a[2])return i[0]=r[0],i[1]=r[1],void(i[2]=r[2]);const n=i;l(e,r,n);const o=s;!function(e,t,a){a[0]=1*t[0]/e[0],a[1]=1*t[1]/e[1],a[2]=1*t[2]/e[2]}(a,n,o),l(t,o,i)}(r.whitePoint,I,F);const T=o;!function(e,t,a){if(0===e[0]&&0===e[1]&&0===e[2])return a[0]=t[0],a[1]=t[1],void(a[2]=t[2]);const r=d(0),i=(1-r)/(1-d(e[0])),n=1-i,s=(1-r)/(1-d(e[1])),o=1-s,c=(1-r)/(1-d(e[2])),l=1-c;a[0]=t[0]*i+n,a[1]=t[1]*s+o,a[2]=t[2]*c+l}(r.blackPoint,F,T);const E=c;!function(a,r,i){const n=i;l(e,r,n);const o=s;!function(e,t,a){a[0]=.95047*t[0]/e[0],a[1]=1*t[1]/e[1],a[2]=1.08883*t[2]/e[2]}(a,n,o),l(t,o,i)}(i,T,E);const O=o;l(a,E,O),g[m]=255*h(O[0]),g[m+1]=255*h(O[1]),g[m+2]=255*h(O[2])}return class extends n{constructor(e,t,a,i){if(super("CalRGB",3),!e)throw new r.FormatError("WhitePoint missing - required for color space CalRGB");t=t||new Float32Array(3),a=a||new Float32Array([1,1,1]),i=i||new Float32Array([1,0,0,0,1,0,0,0,1]);const n=e[0],s=e[1],o=e[2];this.whitePoint=e;const c=t[0],l=t[1],h=t[2];if(this.blackPoint=t,this.GR=a[0],this.GG=a[1],this.GB=a[2],this.MXA=i[0],this.MYA=i[1],this.MZA=i[2],this.MXB=i[3],this.MYB=i[4],this.MZB=i[5],this.MXC=i[6],this.MYC=i[7],this.MZC=i[8],n<0||o<0||1!==s)throw new r.FormatError("Invalid WhitePoint components for "+this.name+", no fallback available");(c<0||l<0||h<0)&&((0,r.info)(`Invalid BlackPoint for ${this.name} [${c}, ${l}, ${h}], falling back to default.`),this.blackPoint=new Float32Array(3)),(this.GR<0||this.GG<0||this.GB<0)&&((0,r.info)(`Invalid Gamma [${this.GR}, ${this.GG}, ${this.GB}] for `+this.name+", falling back to default."),this.GR=this.GG=this.GB=1)}getRgbItem(e,t,a,r){f(this,e,t,a,r,1)}getRgbBuffer(e,t,a,r,i,n,s){const o=1/((1<=6/29?e*e*e:108/841*(e-4/29),t}function t(e,t,a,r){return a+e*(r-a)/t}function a(a,r,i,n,s,o){let c=r[i],l=r[i+1],h=r[i+2];!1!==n&&(c=t(c,n,0,100),l=t(l,n,a.amin,a.amax),h=t(h,n,a.bmin,a.bmax)),l>a.amax?l=a.amax:la.bmax?h=a.bmax:hthis.amax||this.bmin>this.bmax)&&((0,r.info)("Invalid Range, falling back to defaults"),this.amin=-100,this.amax=100,this.bmin=-100,this.bmax=100)}getRgbItem(e,t,r,i){a(this,e,t,!1,r,i)}getRgbBuffer(e,t,r,i,n,s,o){const c=(1<0)return null;const r=[];for(let e=0,i=a.length/8;et[2]||st[3])return null;r[e].push({x:n,y:s})}}return r}t.AnnotationFactory=class{static create(e,t,a,r){return a.ensure(this,"_create",[e,t,a,r])}static _create(e,t,a,i){const s=e.fetchIfRef(t);if(!(0,n.isDict)(s))return;const c=(0,n.isRef)(t)?t.toString():"annot_"+i.createObjId();let l=s.get("Subtype");l=(0,n.isName)(l)?l.name:null;const h={xref:e,dict:s,subtype:l,id:c,pdfManager:a};switch(l){case"Link":return new v(h);case"Text":return new y(h);case"Widget":let e=(0,o.getInheritableProperty)({dict:s,key:"FT"});switch(e=(0,n.isName)(e)?e.name:null,e){case"Tx":return new m(h);case"Btn":return new p(h);case"Ch":return new b(h)}return(0,r.warn)('Unimplemented widget field type "'+e+'", falling back to base field type.'),new g(h);case"Popup":return new w(h);case"FreeText":return new k(h);case"Line":return new S(h);case"Square":return new C(h);case"Circle":return new x(h);case"PolyLine":return new A(h);case"Polygon":return new I(h);case"Caret":return new F(h);case"Ink":return new T(h);case"Highlight":return new E(h);case"Underline":return new O(h);case"Squiggly":return new P(h);case"StrikeOut":return new B(h);case"Stamp":return new D(h);case"FileAttachment":return new N(h);default:return l?(0,r.warn)('Unimplemented annotation type "'+l+'", falling back to base annotation.'):(0,r.warn)("Annotation is missing the required /Subtype."),new u(h)}}};class u{constructor(e){const t=e.dict;this.setContents(t.get("Contents")),this.setModificationDate(t.get("M")),this.setFlags(t.get("F")),this.setRectangle(t.getArray("Rect")),this.setColor(t.getArray("C")),this.setBorderStyle(t),this.setAppearance(t),this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,contents:this.contents,hasAppearance:!!this.appearance,id:e.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:e.subtype}}_hasFlag(e,t){return!!(e&t)}_isViewable(e){return!this._hasFlag(e,r.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,r.AnnotationFlag.HIDDEN)&&!this._hasFlag(e,r.AnnotationFlag.NOVIEW)}_isPrintable(e){return this._hasFlag(e,r.AnnotationFlag.PRINT)&&!this._hasFlag(e,r.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,r.AnnotationFlag.HIDDEN)}get viewable(){return 0===this.flags||this._isViewable(this.flags)}get printable(){return 0!==this.flags&&this._isPrintable(this.flags)}setContents(e){this.contents=(0,r.stringToPDFString)(e||"")}setModificationDate(e){this.modificationDate=(0,r.isString)(e)?e:null}setFlags(e){this.flags=Number.isInteger(e)&&e>0?e:0}hasFlag(e){return this._hasFlag(this.flags,e)}setRectangle(e){Array.isArray(e)&&4===e.length?this.rectangle=r.Util.normalizeRect(e):this.rectangle=[0,0,0,0]}setColor(e){const t=new Uint8ClampedArray(3);if(Array.isArray(e))switch(e.length){case 0:this.color=null;break;case 1:s.ColorSpace.singletons.gray.getRgbItem(e,0,t,0),this.color=t;break;case 3:s.ColorSpace.singletons.rgb.getRgbItem(e,0,t,0),this.color=t;break;case 4:s.ColorSpace.singletons.cmyk.getRgbItem(e,0,t,0),this.color=t;break;default:this.color=t}else this.color=t}setBorderStyle(e){if(this.borderStyle=new d,(0,n.isDict)(e))if(e.has("BS")){const t=e.get("BS"),a=t.get("Type");a&&!(0,n.isName)(a,"Border")||(this.borderStyle.setWidth(t.get("W"),this.rectangle),this.borderStyle.setStyle(t.get("S")),this.borderStyle.setDashArray(t.getArray("D")))}else if(e.has("Border")){const t=e.getArray("Border");Array.isArray(t)&&t.length>=3&&(this.borderStyle.setHorizontalCornerRadius(t[0]),this.borderStyle.setVerticalCornerRadius(t[1]),this.borderStyle.setWidth(t[2],this.rectangle),4===t.length&&this.borderStyle.setDashArray(t[3]))}else this.borderStyle.setWidth(0)}setAppearance(e){this.appearance=null;const t=e.get("AP");if(!(0,n.isDict)(t))return;const a=t.get("N");if((0,n.isStream)(a))return void(this.appearance=a);if(!(0,n.isDict)(a))return;const r=e.get("AS");(0,n.isName)(r)&&a.has(r.name)&&(this.appearance=a.get(r.name))}loadResources(e){return this.appearance.dict.getAsync("Resources").then(t=>{if(t)return new i.ObjectLoader(t,e,t.xref).load().then((function(){return t}))})}getOperatorList(e,t,a){if(!this.appearance)return Promise.resolve(new c.OperatorList);const i=this.data,n=this.appearance.dict,s=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),o=n.getArray("BBox")||[0,0,1,1],l=n.getArray("Matrix")||[1,0,0,1,0,0],h=function(e,t,a){const[i,n,s,o]=r.Util.getAxialAlignedBoundingBox(t,a);if(i===s||n===o)return[1,0,0,1,e[0],e[1]];const c=(e[2]-e[0])/(s-i),l=(e[3]-e[1])/(o-n);return[c,0,0,l,e[0]-i*c,e[1]-n*l]}(i.rect,o,l);return s.then(a=>{const n=new c.OperatorList;return n.addOp(r.OPS.beginAnnotation,[i.rect,h,l]),e.getOperatorList({stream:this.appearance,task:t,resources:a,operatorList:n}).then(()=>(n.addOp(r.OPS.endAnnotation,[]),this.appearance.reset(),n))})}}t.Annotation=u;class d{constructor(){this.width=1,this.style=r.AnnotationBorderStyleType.SOLID,this.dashArray=[3],this.horizontalCornerRadius=0,this.verticalCornerRadius=0}setWidth(e,t=[0,0,0,0]){if((0,n.isName)(e))this.width=0;else if(Number.isInteger(e)){if(e>0){const a=(t[2]-t[0])/2,i=(t[3]-t[1])/2;a>0&&i>0&&(e>a||e>i)&&((0,r.warn)("AnnotationBorderStyle.setWidth - ignoring width: "+e),e=1)}this.width=e}}setStyle(e){if((0,n.isName)(e))switch(e.name){case"S":this.style=r.AnnotationBorderStyleType.SOLID;break;case"D":this.style=r.AnnotationBorderStyleType.DASHED;break;case"B":this.style=r.AnnotationBorderStyleType.BEVELED;break;case"I":this.style=r.AnnotationBorderStyleType.INSET;break;case"U":this.style=r.AnnotationBorderStyleType.UNDERLINE}}setDashArray(e){if(Array.isArray(e)&&e.length>0){let t=!0,a=!0;for(const r of e){if(!(+r>=0)){t=!1;break}r>0&&(a=!1)}t&&!a?this.dashArray=e:this.width=0}else e&&(this.width=0)}setHorizontalCornerRadius(e){Number.isInteger(e)&&(this.horizontalCornerRadius=e)}setVerticalCornerRadius(e){Number.isInteger(e)&&(this.verticalCornerRadius=e)}}t.AnnotationBorderStyle=d;class f extends u{constructor(e){super(e);const t=e.dict;if(t.has("IRT")){const e=t.getRaw("IRT");this.data.inReplyTo=(0,n.isRef)(e)?e.toString():null;const a=t.get("RT");this.data.replyType=(0,n.isName)(a)?a.name:r.AnnotationReplyType.REPLY}if(this.data.replyType===r.AnnotationReplyType.GROUP){const e=t.get("IRT");this.data.title=(0,r.stringToPDFString)(e.get("T")||""),this.setContents(e.get("Contents")),this.data.contents=this.contents,e.has("CreationDate")?(this.setCreationDate(e.get("CreationDate")),this.data.creationDate=this.creationDate):this.data.creationDate=null,e.has("M")?(this.setModificationDate(e.get("M")),this.data.modificationDate=this.modificationDate):this.data.modificationDate=null,this.data.hasPopup=e.has("Popup"),e.has("C")?(this.setColor(e.getArray("C")),this.data.color=this.color):this.data.color=null}else this.data.title=(0,r.stringToPDFString)(t.get("T")||""),this.setCreationDate(t.get("CreationDate")),this.data.creationDate=this.creationDate,this.data.hasPopup=t.has("Popup"),t.has("C")||(this.data.color=null)}setCreationDate(e){this.creationDate=(0,r.isString)(e)?e:null}}t.MarkupAnnotation=f;class g extends u{constructor(e){super(e);const t=e.dict,a=this.data;a.annotationType=r.AnnotationType.WIDGET,a.fieldName=this._constructFieldName(t),a.fieldValue=(0,o.getInheritableProperty)({dict:t,key:"V",getArray:!0}),a.alternativeText=(0,r.stringToPDFString)(t.get("TU")||""),a.defaultAppearance=(0,o.getInheritableProperty)({dict:t,key:"DA"})||"";const i=(0,o.getInheritableProperty)({dict:t,key:"FT"});a.fieldType=(0,n.isName)(i)?i.name:null,this.fieldResources=(0,o.getInheritableProperty)({dict:t,key:"DR"})||n.Dict.empty,a.fieldFlags=(0,o.getInheritableProperty)({dict:t,key:"Ff"}),(!Number.isInteger(a.fieldFlags)||a.fieldFlags<0)&&(a.fieldFlags=0),a.readOnly=this.hasFieldFlag(r.AnnotationFieldFlag.READONLY),"Sig"===a.fieldType&&(a.fieldValue=null,this.setFlags(r.AnnotationFlag.HIDDEN))}_constructFieldName(e){if(!e.has("T")&&!e.has("Parent"))return(0,r.warn)("Unknown field name, falling back to empty field name."),"";if(!e.has("Parent"))return(0,r.stringToPDFString)(e.get("T"));const t=[];e.has("T")&&t.unshift((0,r.stringToPDFString)(e.get("T")));let a=e;for(;a.has("Parent")&&(a=a.get("Parent"),(0,n.isDict)(a));)a.has("T")&&t.unshift((0,r.stringToPDFString)(a.get("T")));return t.join(".")}hasFieldFlag(e){return!!(this.data.fieldFlags&e)}getOperatorList(e,t,a){return a?Promise.resolve(new c.OperatorList):super.getOperatorList(e,t,a)}}class m extends g{constructor(e){super(e);const t=e.dict;this.data.fieldValue=(0,r.stringToPDFString)(this.data.fieldValue||"");let a=(0,o.getInheritableProperty)({dict:t,key:"Q"});(!Number.isInteger(a)||a<0||a>2)&&(a=null),this.data.textAlignment=a;let i=(0,o.getInheritableProperty)({dict:t,key:"MaxLen"});(!Number.isInteger(i)||i<0)&&(i=null),this.data.maxLen=i,this.data.multiLine=this.hasFieldFlag(r.AnnotationFieldFlag.MULTILINE),this.data.comb=this.hasFieldFlag(r.AnnotationFieldFlag.COMB)&&!this.hasFieldFlag(r.AnnotationFieldFlag.MULTILINE)&&!this.hasFieldFlag(r.AnnotationFieldFlag.PASSWORD)&&!this.hasFieldFlag(r.AnnotationFieldFlag.FILESELECT)&&null!==this.data.maxLen}getOperatorList(e,t,a){if(a||this.appearance)return super.getOperatorList(e,t,a);const i=new c.OperatorList;if(!this.data.defaultAppearance)return Promise.resolve(i);const n=new l.Stream((0,r.stringToBytes)(this.data.defaultAppearance));return e.getOperatorList({stream:n,task:t,resources:this.fieldResources,operatorList:i}).then((function(){return i}))}}class p extends g{constructor(e){super(e),this.data.checkBox=!this.hasFieldFlag(r.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(r.AnnotationFieldFlag.PUSHBUTTON),this.data.radioButton=this.hasFieldFlag(r.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(r.AnnotationFieldFlag.PUSHBUTTON),this.data.pushButton=this.hasFieldFlag(r.AnnotationFieldFlag.PUSHBUTTON),this.data.checkBox?this._processCheckBox(e):this.data.radioButton?this._processRadioButton(e):this.data.pushButton?this._processPushButton(e):(0,r.warn)("Invalid field flags for button widget annotation")}_processCheckBox(e){(0,n.isName)(this.data.fieldValue)&&(this.data.fieldValue=this.data.fieldValue.name);const t=e.dict.get("AP");if(!(0,n.isDict)(t))return;const a=t.get("D");if(!(0,n.isDict)(a))return;const r=a.getKeys();2===r.length&&(this.data.exportValue="Off"===r[0]?r[1]:r[0])}_processRadioButton(e){this.data.fieldValue=this.data.buttonValue=null;const t=e.dict.get("Parent");if((0,n.isDict)(t)&&t.has("V")){const e=t.get("V");(0,n.isName)(e)&&(this.data.fieldValue=e.name)}const a=e.dict.get("AP");if(!(0,n.isDict)(a))return;const r=a.get("N");if((0,n.isDict)(r))for(const e of r.getKeys())if("Off"!==e){this.data.buttonValue=e;break}}_processPushButton(e){e.dict.has("A")?i.Catalog.parseDestDictionary({destDict:e.dict,resultObj:this.data,docBaseUrl:e.pdfManager.docBaseUrl}):(0,r.warn)("Push buttons without action dictionaries are not supported")}}class b extends g{constructor(e){super(e),this.data.options=[];const t=(0,o.getInheritableProperty)({dict:e.dict,key:"Opt"});if(Array.isArray(t)){const a=e.xref;for(let e=0,i=t.length;e1e3&&(u=Math.max(u,g),m+=f+2,g=0,f=0),d.push({transform:p,x:g,y:m,w:b.width,h:b.height}),g+=b.width+2,f=Math.max(f,b.height)}var y=Math.max(u,g)+1,v=m+f+1,w=new Uint8ClampedArray(y*v*4),k=y<<2;for(h=0;h=0;)S[A-4]=S[A],S[A-3]=S[A+1],S[A-2]=S[A+2],S[A-1]=S[A+3],S[A+C]=S[A+C-4],S[A+C+1]=S[A+C-3],S[A+C+2]=S[A+C-2],S[A+C+3]=S[A+C-1],A-=k}return a.splice(s,4*l,r.OPS.paintInlineImageXObjectGroup),i.splice(s,4*l,[{width:y,height:v,kind:r.ImageKind.RGBA_32BPP,data:w},d]),s+1})),e(t,[r.OPS.save,r.OPS.transform,r.OPS.paintImageMaskXObject,r.OPS.restore],null,(function(e,t){var a=e.fnArray,i=(t-(e.iCurr-3))%4;switch(i){case 0:return a[t]===r.OPS.save;case 1:return a[t]===r.OPS.transform;case 2:return a[t]===r.OPS.paintImageMaskXObject;case 3:return a[t]===r.OPS.restore}throw new Error("iterateImageMaskGroup - invalid pos: "+i)}),(function(e,t){var a,i=e.fnArray,n=e.argsArray,s=e.iCurr,o=s-3,c=s-2,l=s-1,h=Math.floor((t-o)/4);if((h=function(e,t,a,i){for(var n=e+2,s=0;s=4&&a[n-4]===a[s]&&a[n-3]===a[o]&&a[n-2]===a[c]&&a[n-1]===a[l]&&r[n-4][0]===h&&r[n-4][1]===u&&(d++,f-=5);for(var g=f+4,m=1;m=r)break}i=(i||t)[e[a]],i&&!Array.isArray(i)?(s.iCurr=a,a++,!i.checkFn||(0,i.checkFn)(s)?(n=i,i=null):i=null):a++}this.state=i,this.match=n,this.lastProcessed=a},push(e,t){this.queue.fnArray.push(e),this.queue.argsArray.push(t),this._optimize()},flush(){for(;this.match;){const e=this.queue.fnArray.length;this.lastProcessed=(0,this.match.processFn)(this.context,e),this.match=null,this.state=null,this._optimize()}},reset(){this.state=null,this.match=null,this.lastProcessed=0}},a}(),n=function(){function e(e){this.queue=e}return e.prototype={push(e,t){this.queue.fnArray.push(e),this.queue.argsArray.push(t)},flush(){},reset(){}},e}(),s=function(){function e(e,t,a){this._streamSink=t,this.fnArray=[],this.argsArray=[],this.optimizer=t&&"oplist"!==e?new i(this):new n(this),this.dependencies=Object.create(null),this._totalLength=0,this.pageIndex=a,this.intent=e,this.weight=0,this._resolved=t?null:Promise.resolve()}return e.prototype={get length(){return this.argsArray.length},get ready(){return this._resolved||this._streamSink.ready},get totalLength(){return this._totalLength+this.length},addOp(e,t){this.optimizer.push(e,t),this.weight++,this._streamSink&&(this.weight>=1e3||this.weight>=995&&(e===r.OPS.restore||e===r.OPS.endText))&&this.flush()},addDependency(e){e in this.dependencies||(this.dependencies[e]=!0,this.addOp(r.OPS.dependency,[e]))},addDependencies(e){for(var t in e)this.addDependency(t)},addOpList(e){Object.assign(this.dependencies,e.dependencies);for(var t=0,a=e.length;t{if(this.builtInCMapCache.has(e))return this.builtInCMapCache.get(e);const t=this.handler.sendWithStream("FetchBuiltInCMap",{name:e}).getReader(),a=await new Promise((function(e,a){!function r(){t.read().then((function({value:t,done:a}){a||(e(t),r())}),a)}()}));return a.compressionType!==r.CMapCompressionType.NONE&&this.builtInCMapCache.set(e,a),a}}function a(){this.reset()}function d(e,t=!1){if(Array.isArray(e)){for(let t=0,a=e.length;tf)return void(0,r.warn)("Image exceeded maximum allowed size and was removed.");if(c.get("ImageMask","IM")){var g=c.get("Width","W"),p=c.get("Height","H"),b=g+7>>3,y=t.getBytes(b*p,!0),w=c.getArray("Decode","D");return(u=C.PDFImage.createMask({imgArray:y,width:g,height:p,imageIsFromDecodeStream:t instanceof m.DecodeStream,inverseDecode:!!w&&w[0]>0})).cached=!!n,d=[u],i.addOp(r.OPS.paintImageMaskXObject,d),void(n&&(s[n]={fn:r.OPS.paintImageMaskXObject,args:d}))}var S=c.get("SMask","SM")||!1,x=c.get("Mask")||!1;if(a&&!S&&!x&&!(t instanceof v.JpegStream)&&l+h<200)return u=new C.PDFImage({xref:this.xref,res:e,image:t,isInline:a,pdfFunctionFactory:this.pdfFunctionFactory}).createImageData(!0),void i.addOp(r.OPS.paintInlineImageXObject,[u]);const A=o?r.NativeImageDecoding.NONE:this.options.nativeImageDecoderSupport;let I="img_"+this.idFactory.createObjId();if(this.parsingType3Font&&((0,r.assert)(A===r.NativeImageDecoding.NONE,"Type3 image resources should be completely decoded in the worker."),I=`${this.idFactory.getDocId()}_type3res_${I}`),A!==r.NativeImageDecoding.NONE&&!S&&!x&&t instanceof v.JpegStream&&k.NativeImageDecoder.isSupported(t,this.xref,e,this.pdfFunctionFactory)&&t.maybeValidDimensions)return this.handler.sendWithPromise("obj",[I,this.pageIndex,"JpegStream",t.getIR(this.options.forceDataSchema)]).then((function(){i.addDependency(I),d=[I,l,h],i.addOp(r.OPS.paintJpegXObject,d),n&&(s[n]={fn:r.OPS.paintJpegXObject,args:d})}),o=>((0,r.warn)("Native JPEG decoding failed -- trying to recover: "+(o&&o.message)),this.buildPaintImageXObject({resources:e,image:t,isInline:a,operatorList:i,cacheKey:n,imageCache:s,forceDisableNativeImageDecoder:!0})));var F=null;A===r.NativeImageDecoding.DECODE&&(t instanceof v.JpegStream||x instanceof v.JpegStream||S instanceof v.JpegStream)&&(F=new k.NativeImageDecoder({xref:this.xref,resources:e,handler:this.handler,forceDataSchema:this.options.forceDataSchema,pdfFunctionFactory:this.pdfFunctionFactory})),i.addDependency(I),d=[I,l,h];const T=C.PDFImage.buildImage({handler:this.handler,xref:this.xref,res:e,image:t,isInline:a,nativeDecoder:F,pdfFunctionFactory:this.pdfFunctionFactory}).then(e=>{var t=e.createImageData(!1);if(this.parsingType3Font)return this.handler.sendWithPromise("commonobj",[I,"FontType3Res",t],[t.data.buffer]);this.handler.send("obj",[I,this.pageIndex,"Image",t],[t.data.buffer])}).catch(e=>{if((0,r.warn)("Unable to decode image: "+e),this.parsingType3Font)return this.handler.sendWithPromise("commonobj",[I,"FontType3Res",null]);this.handler.send("obj",[I,this.pageIndex,"Image",null])});this.parsingType3Font&&await T,i.addOp(r.OPS.paintImageXObject,d),n&&(s[n]={fn:r.OPS.paintImageXObject,args:d})},handleSMask:function(e,t,a,r,i){var n=e.get("G"),s={subtype:e.get("S").name,backdrop:e.get("BC")},o=e.get("TR");if((0,y.isPDFFunction)(o)){const e=this.pdfFunctionFactory.create(o);for(var c=new Uint8Array(256),l=new Float32Array(1),h=0;h<256;h++)l[0]=h/255,e(l,0,l,0),c[h]=255*l[0]|0;s.transferMap=c}return this.buildFormXObject(t,n,s,a,r,i.state.clone())},handleTilingType(e,t,a,i,s,o,c){const l=new S.OperatorList,h=[s.get("Resources"),a],d=n.Dict.merge(this.xref,h);return this.getOperatorList({stream:i,task:c,resources:d,operatorList:l}).then((function(){return(0,u.getTilingPatternIR)({fnArray:l.fnArray,argsArray:l.argsArray},s,t)})).then((function(t){o.addDependencies(l.dependencies),o.addOp(e,t)}),e=>{if(!(e instanceof r.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.unknown}),(0,r.warn)(`handleTilingType - ignoring pattern: "${e}".`)}})},handleSetFont:function(e,t,a,i,n,o){var c;return t&&(c=(t=t.slice())[0].name),this.loadFont(c,a,e).then(t=>t.font.isType3Font?t.loadType3Data(this,e,i,n).then((function(){return t})).catch(e=>(this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font}),new A("g_font_error",new s.ErrorFont("Type3 font load error: "+e),t.font))):t).then(e=>(o.font=e.font,e.send(this.handler),e.loadedName))},handleText(e,a){const i=a.font,n=i.charsToGlyphs(e);return i.data&&(a.textRenderingMode&r.TextRenderingMode.ADD_TO_PATH_FLAG||"Pattern"===a.fillColorSpace.name||i.disableFontFace||this.options.disableFontFace)&&t.buildFontPaths(i,n,this.handler),n},ensureStateFont(e){if(e.font)return;const t=new r.FormatError("Missing setFont (Tf) operator before text rendering operator.");if(!this.options.ignoreErrors)throw t;this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font}),(0,r.warn)(`ensureStateFont: "${t}".`)},setGState:function(e,t,a,i,s){for(var o=[],c=t.getKeys(),l=Promise.resolve(),h=0,u=c.length;hthis.handleSetFont(e,null,f[0],a,i,s.state).then((function(e){a.addDependency(e),o.push([u,[e,f[1]]])})));break;case"BM":o.push([u,d(f)]);break;case"SMask":if((0,n.isName)(f,"None")){o.push([u,!1]);break}(0,n.isDict)(f)?(l=l.then(()=>this.handleSMask(f,e,a,i,s)),o.push([u,!0])):(0,r.warn)("Unsupported SMask type");break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":(0,r.info)("graphic state operator "+u);break;default:(0,r.info)("Unknown graphic state operator "+u)}}return l.then((function(){o.length>0&&a.addOp(r.OPS.setGState,[o])}))},loadFont:function(e,a,i){function o(){return Promise.resolve(new A("g_font_error",new s.ErrorFont("Font "+e+" is not available"),a))}var c,l=this.xref;if(a){if(!(0,n.isRef)(a))throw new r.FormatError('The "font" object should be a reference.');c=a}else{var h=i.get("Font");h&&(c=h.getRaw(e))}if(!c){const i=`Font "${e||a&&a.toString()}" is not available`;if(!this.options.ignoreErrors&&!this.parsingType3Font)return(0,r.warn)(i+"."),o();this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font}),(0,r.warn)(i+" -- attempting to fallback to a default font."),c=t.getFallbackFontDict()}if(this.fontCache.has(c))return this.fontCache.get(c);if(a=l.fetchIfRef(c),!(0,n.isDict)(a))return o();if(a.translated)return a.translated;var u=(0,r.createPromiseCapability)(),d=this.preEvaluateFont(a);const{descriptor:f,hash:g}=d;var m,p,b=(0,n.isRef)(c);if(b&&(m=c.toString()),g&&(0,n.isDict)(f)){f.fontAliases||(f.fontAliases=Object.create(null));var y=f.fontAliases;if(y[g]){var v=y[g].aliasRef;if(b&&v&&this.fontCache.has(v))return this.fontCache.putAlias(c,v),this.fontCache.get(c)}else y[g]={fontID:s.Font.getFontID()};b&&(y[g].aliasRef=c),m=y[g].fontID}b?this.fontCache.put(c,u.promise):(m||(m=this.idFactory.createObjId()),this.fontCache.put("id_"+m,u.promise)),(0,r.assert)(m,'The "fontID" must be defined.'),a.loadedName=`${this.idFactory.getDocId()}_f${m}`,a.translated=u.promise;try{p=this.translateFont(d)}catch(e){p=Promise.reject(e)}return p.then((function(e){void 0!==e.fontType&&(l.stats.fontTypes[e.fontType]=!0),u.resolve(new A(a.loadedName,e,a))})).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font});try{var t=f&&f.get("FontFile3"),i=t&&t.get("Subtype"),n=(0,s.getFontType)(d.type,i&&i.name);l.stats.fontTypes[n]=!0}catch(e){}u.resolve(new A(a.loadedName,new s.ErrorFont(e instanceof Error?e.message:e),a))}),u.promise},buildPath(e,t,a,i=!1){var n=e.length-1;if(a||(a=[]),n<0||e.fnArray[n]!==r.OPS.constructPath)i&&((0,r.warn)(`Encountered path operator "${t}" inside of a text object.`),e.addOp(r.OPS.save,null)),e.addOp(r.OPS.constructPath,[[t],a]),i&&e.addOp(r.OPS.restore,null);else{var s=e.argsArray[n];s[0].push(t),Array.prototype.push.apply(s[1],a)}},parseColorSpace({cs:e,resources:t}){return new Promise(a=>{a(g.ColorSpace.parse(e,this.xref,t,this.pdfFunctionFactory))}).catch(e=>{if(e instanceof r.AbortException)return null;if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.unknown}),(0,r.warn)(`parseColorSpace - ignoring ColorSpace: "${e}".`),null;throw e})},async handleColorN(e,t,a,i,s,o,c){var l,h=a[a.length-1];if((0,n.isName)(h)&&(l=s.get(h.name))){var d=(0,n.isStream)(l)?l.dict:l,f=d.get("PatternType");if(1===f){var g=i.base?i.base.getRgb(a,0):null;return this.handleTilingType(t,g,o,l,d,e,c)}if(2===f){var m=d.get("Shading"),p=d.getArray("Matrix");return l=u.Pattern.parseShading(m,p,this.xref,o,this.handler,this.pdfFunctionFactory),void e.addOp(t,l.getIR())}throw new r.FormatError("Unknown PatternType: "+f)}throw new r.FormatError("Unknown PatternName: "+h)},getOperatorList({stream:e,task:t,resources:i,operatorList:s,initialState:o=null}){if(i=i||n.Dict.empty,o=o||new T,!s)throw new Error('getOperatorList: missing "operatorList" parameter');var c=this,l=this.xref;let h=!1;var d=Object.create(null),f=i.get("XObject")||n.Dict.empty,m=i.get("Pattern")||n.Dict.empty,p=new I(o),b=new E(e,l,p),y=new a;function v(e){for(var t=0,a=b.savedStatesDepth;t{if(!(e instanceof r.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.unknown}),(0,r.warn)(`getOperatorList - ignoring errors during "${t.name}" task: "${e}".`),v()}})},getTextContent({stream:e,task:t,resources:i,stateManager:s=null,normalizeWhitespace:o=!1,combineTextItems:c=!1,sink:h,seenStyles:u=Object.create(null)}){i=i||n.Dict.empty,s=s||new I(new F);var d,g=/\s/g,m={items:[],styles:Object.create(null)},p={initialized:!1,str:[],width:0,height:0,vertical:!1,lastAdvanceWidth:0,lastAdvanceHeight:0,textAdvanceScale:0,spaceWidth:0,fakeSpaceMin:1/0,fakeMultiSpaceMin:1/0,fakeMultiSpaceMax:-0,textRunBreakAllowed:!1,transform:null,fontName:null},b=this,y=this.xref,v=null,w=Object.create(null),k=new E(e,y,s);function S(){if(p.initialized)return p;var e=d.font;e.loadedName in u||(u[e.loadedName]=!0,m.styles[e.loadedName]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:!!e.vertical}),p.fontName=e.loadedName;var t=[d.fontSize*d.textHScale,0,0,d.fontSize,0,d.textRise];if(e.isType3Font&&d.fontSize<=1&&!(0,r.isArrayEqual)(d.fontMatrix,r.FONT_IDENTITY_MATRIX)){const a=e.bbox[3]-e.bbox[1];a>0&&(t[3]*=a*d.fontMatrix[3])}var a=r.Util.transform(d.ctm,r.Util.transform(d.textMatrix,t));p.transform=a,e.vertical?(p.width=Math.sqrt(a[0]*a[0]+a[1]*a[1]),p.height=0,p.vertical=!0):(p.width=0,p.height=Math.sqrt(a[2]*a[2]+a[3]*a[3]),p.vertical=!1);var i=d.textLineMatrix[0],n=d.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=d.ctm[0],n=d.ctm[1];var o=Math.sqrt(i*i+n*n);p.textAdvanceScale=o*s,p.lastAdvanceWidth=0,p.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*d.fontSize;return c?(p.spaceWidth=c,p.fakeSpaceMin=.3*c,p.fakeMultiSpaceMin=1.5*c,p.fakeMultiSpaceMax=4*c,p.textRunBreakAllowed=!e.isMonospace):(p.spaceWidth=0,p.fakeSpaceMin=1/0,p.fakeMultiSpaceMin=1/0,p.fakeMultiSpaceMax=0,p.textRunBreakAllowed=!1),p.initialized=!0,p}function C(e){for(var t,a=0,r=e.length;a=32&&t<=127;)a++;return a0&&O(g,a.str)}var m=0,p=0;t.vertical?i+=p=o*d.fontMatrix[0]*d.fontSize+f:r+=m=(o*d.fontMatrix[0]*d.fontSize+f)*d.textHScale,d.translateTextMatrix(m,p),a.str.push(h)}return t.vertical?(a.lastAdvanceHeight=i,a.height+=Math.abs(i)):(a.lastAdvanceWidth=r,a.width+=r),a}function O(e,t){if(!(e0;)t.push(" ")}function P(){var e,t,a;p.initialized&&(p.vertical?p.height*=p.textAdvanceScale:p.width*=p.textAdvanceScale,m.items.push((t=(e=p).str.join(""),a=(0,f.bidi)(t,-1,e.vertical),{str:o?C(a.str):a.str,dir:a.dir,width:e.width,height:e.height,transform:e.transform,fontName:e.fontName})),p.initialized=!1,p.str.length=0)}function B(){const e=m.items.length;e>0&&(h.enqueue(m,e),m.items=[],m.styles=Object.create(null))}var D=new a;return new Promise((function e(a,l){const f=function(t){B(),Promise.all([t,h.ready]).then((function(){try{e(a,l)}catch(e){l(e)}}),l)};t.ensureNotTerminated(),D.reset();for(var g,y={},C=[];!(g=D.check())&&(C.length=0,y.args=C,k.read(y));){d=s.state;var F,E=y.fn;switch(C=y.args,0|E){case r.OPS.setFont:var N=C[0].name,M=C[1];if(d.font&&N===d.fontName&&M===d.fontSize)break;return P(),d.fontName=N,d.fontSize=M,void f(A(N,null));case r.OPS.setTextRise:P(),d.textRise=C[0];break;case r.OPS.setHScale:P(),d.textHScale=C[0]/100;break;case r.OPS.setLeading:P(),d.leading=C[0];break;case r.OPS.moveText:var L=!!d.font&&0===(d.font.vertical?C[0]:C[1]);if(F=C[0]-C[1],c&&L&&p.initialized&&F>0&&F<=p.fakeMultiSpaceMax){d.translateTextLineMatrix(C[0],C[1]),p.width+=C[0]-p.lastAdvanceWidth,p.height+=C[1]-p.lastAdvanceHeight,O(C[0]-p.lastAdvanceWidth-(C[1]-p.lastAdvanceHeight),p.str);break}P(),d.translateTextLineMatrix(C[0],C[1]),d.textMatrix=d.textLineMatrix.slice();break;case r.OPS.setLeadingMoveText:P(),d.leading=-C[1],d.translateTextLineMatrix(C[0],C[1]),d.textMatrix=d.textLineMatrix.slice();break;case r.OPS.nextLine:P(),d.carriageReturn();break;case r.OPS.setTextMatrix:if(F=d.calcTextLineMatrixAdvance(C[0],C[1],C[2],C[3],C[4],C[5]),c&&null!==F&&p.initialized&&F.value>0&&F.value<=p.fakeMultiSpaceMax){d.translateTextLineMatrix(F.width,F.height),p.width+=F.width-p.lastAdvanceWidth,p.height+=F.height-p.lastAdvanceHeight,O(F.width-p.lastAdvanceWidth-(F.height-p.lastAdvanceHeight),p.str);break}P(),d.setTextMatrix(C[0],C[1],C[2],C[3],C[4],C[5]),d.setTextLineMatrix(C[0],C[1],C[2],C[3],C[4],C[5]);break;case r.OPS.setCharSpacing:d.charSpacing=C[0];break;case r.OPS.setWordSpacing:d.wordSpacing=C[0];break;case r.OPS.beginText:P(),d.textMatrix=r.IDENTITY_MATRIX.slice(),d.textLineMatrix=r.IDENTITY_MATRIX.slice();break;case r.OPS.showSpacedText:if(!s.state.font){b.ensureStateFont(s.state);continue}for(var R,U=C[0],q=0,j=U.length;qp.fakeMultiSpaceMax)||(p.height+=R)):(R=(F=-F)*d.textHScale,d.translateTextMatrix(R,0),(_=p.textRunBreakAllowed&&F>p.fakeMultiSpaceMax)||(p.width+=R)),_?P():F>0&&O(F,p.str)}break;case r.OPS.showText:if(!s.state.font){b.ensureStateFont(s.state);continue}T(C[0]);break;case r.OPS.nextLineShowText:if(!s.state.font){b.ensureStateFont(s.state);continue}P(),d.carriageReturn(),T(C[0]);break;case r.OPS.nextLineSetSpacingShowText:if(!s.state.font){b.ensureStateFont(s.state);continue}P(),d.wordSpacing=C[0],d.charSpacing=C[1],d.carriageReturn(),T(C[2]);break;case r.OPS.paintXObject:P(),v||(v=i.get("XObject")||n.Dict.empty);var z=C[0].name;if(z&&void 0!==w[z])break;return void f(new Promise((function(e,a){if(!z)throw new r.FormatError("XObject must be referred to by name.");const l=v.get(z);if(!l)return void e();if(!(0,n.isStream)(l))throw new r.FormatError("XObject should be a stream");const d=l.dict.get("Subtype");if(!(0,n.isName)(d))throw new r.FormatError("XObject should have a Name subtype");if("Form"!==d.name)return w[z]=!0,void e();const f=s.state.clone(),g=new I(f),m=l.dict.getArray("Matrix");Array.isArray(m)&&6===m.length&&g.transform(m),B();const p={enqueueInvoked:!1,enqueue(e,t){this.enqueueInvoked=!0,h.enqueue(e,t)},get desiredSize(){return h.desiredSize},get ready(){return h.ready}};b.getTextContent({stream:l,task:t,resources:l.dict.get("Resources")||i,stateManager:g,normalizeWhitespace:o,combineTextItems:c,sink:p,seenStyles:u}).then((function(){p.enqueueInvoked||(w[z]=!0),e()}),a)})).catch((function(e){if(!(e instanceof r.AbortException)){if(!b.options.ignoreErrors)throw e;(0,r.warn)(`getTextContent - ignoring XObject: "${e}".`)}})));case r.OPS.setGState:P();var H=C[0],G=i.get("ExtGState");if(!(0,n.isDict)(G)||!(0,n.isName)(H))break;var W=G.get(H.name);if(!(0,n.isDict)(W))break;var X=W.get("Font");if(X)return d.fontName=null,d.fontSize=X[1],void f(A(null,X[0]))}if(m.items.length>=h.desiredSize){g=!0;break}}g?f(x):(P(),B(),a())})).catch(e=>{if(!(e instanceof r.AbortException)){if(!this.options.ignoreErrors)throw e;(0,r.warn)(`getTextContent - ignoring errors during "${t.name}" task: "${e}".`),P(),B()}})},extractDataStructures:function(e,t,a){const i=this.xref;let c;var l=e.get("ToUnicode")||t.get("ToUnicode"),h=l?this.readToUnicode(l):Promise.resolve(void 0);if(a.composite){var u=e.get("CIDSystemInfo");(0,n.isDict)(u)&&(a.cidSystemInfo={registry:(0,r.stringToPDFString)(u.get("Registry")),ordering:(0,r.stringToPDFString)(u.get("Ordering")),supplement:u.get("Supplement")});var d=e.get("CIDToGIDMap");(0,n.isStream)(d)&&(c=d.getBytes())}var f,g=[],m=null;if(e.has("Encoding")){if(f=e.get("Encoding"),(0,n.isDict)(f)){if(m=f.get("BaseEncoding"),m=(0,n.isName)(m)?m.name:null,f.has("Differences"))for(var p=f.get("Differences"),b=0,y=0,v=p.length;y0,a.dict=e,h.then(e=>(a.toUnicode=e,this.buildToUnicode(a))).then(e=>(a.toUnicode=e,c&&(a.cidToGidMap=this.readCidToGidMap(c,e)),a))},_buildSimpleFontToUnicode(e,t=!1){(0,r.assert)(!e.composite,"Must be a simple font.");const a=[],i=e.defaultEncoding.slice(),n=e.baseEncodingName,c=e.differences;for(const e in c){const t=c[e];".notdef"!==t&&(i[e]=t)}const h=(0,p.getGlyphsUnicode)();for(const r in i){let s=i[r];if(""!==s)if(void 0!==h[s])a[r]=String.fromCharCode(h[s]);else{let i=0;switch(s[0]){case"G":3===s.length&&(i=parseInt(s.substring(1),16));break;case"g":5===s.length&&(i=parseInt(s.substring(1),16));break;case"C":case"c":if(s.length>=3&&s.length<=4){const a=s.substring(1);if(t){i=parseInt(a,16);break}if(i=+a,Number.isNaN(i)&&Number.isInteger(parseInt(a,16)))return this._buildSimpleFontToUnicode(e,!0)}break;default:const a=(0,l.getUnicodeForGlyph)(s,h);-1!==a&&(i=a)}if(i>0&&Number.isInteger(i)){if(n&&i===+r){const e=(0,o.getEncoding)(n);if(e&&(s=e[r])){a[r]=String.fromCharCode(h[s]);continue}}a[r]=String.fromCodePoint(i)}}}return new s.ToUnicodeMap(a)},buildToUnicode(e){if(e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0,e.hasIncludedToUnicodeMap)return!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._buildSimpleFontToUnicode(e)),Promise.resolve(e.toUnicode);if(!e.composite)return Promise.resolve(this._buildSimpleFontToUnicode(e));if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof i.IdentityCMap)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){const t=e.cidSystemInfo.registry,a=e.cidSystemInfo.ordering,o=n.Name.get(t+"-"+a+"-UCS2");return i.CMapFactory.create({encoding:o,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(t){const a=e.cMap,i=[];return a.forEach((function(e,a){if(a>65535)throw new r.FormatError("Max size of CID is 65,535");const n=t.lookup(a);n&&(i[e]=String.fromCharCode((n.charCodeAt(0)<<8)+n.charCodeAt(1)))})),new s.ToUnicodeMap(i)}))}return Promise.resolve(new s.IdentityToUnicodeMap(e.firstChar,e.lastChar))},readToUnicode:function(e){var t=e;return(0,n.isName)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(e){return e instanceof i.IdentityCMap?new s.IdentityToUnicodeMap(0,65535):new s.ToUnicodeMap(e.getMap())})):(0,n.isStream)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this.fetchBuiltInCMap,useCMap:null}).then((function(e){if(e instanceof i.IdentityCMap)return new s.IdentityToUnicodeMap(0,65535);var t=new Array(e.length);return e.forEach((function(e,a){for(var r=[],i=0;i{if(e instanceof r.AbortException)return null;if(this.options.ignoreErrors)return this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font}),(0,r.warn)(`readToUnicode - ignoring ToUnicode data: "${e}".`),null;throw e}):Promise.resolve(null)},readCidToGidMap(e,t){for(var a=[],r=0,i=e.length;r>1;(0!==n||t.has(i))&&(a[i]=n)}return a},extractWidths:function(e,t,a){var r,i,o,c,l,h,u,d,f=this.xref,g=[],m=0,p=[];if(a.composite){if(m=e.has("DW")?e.get("DW"):1e3,d=e.get("W"))for(i=0,o=d.length;i{if(e){const a=[];let r=f;for(let t=0,i=e.length;tthis.extractDataStructures(o,a,t)).then(e=>(this.extractWidths(o,l,e),"Type3"===u&&(e.isType3Font=!0),new s.Font(v.name,x,e)))}},t.buildFontPaths=function(e,t,a){function r(t){e.renderer.hasBuiltPath(t)||a.send("commonobj",[`${e.loadedName}_path_${t}`,"FontPath",e.renderer.getPathJs(t)])}for(const e of t){r(e.fontChar);const t=e.accent;t&&t.fontChar&&r(t.fontChar)}},t.getFallbackFontDict=function(){if(this._fallbackFontDict)return this._fallbackFontDict;const e=new n.Dict;return e.set("BaseFont",n.Name.get("PDFJS-FallbackFont")),e.set("Type",n.Name.get("FallbackType")),e.set("Subtype",n.Name.get("FallbackType")),e.set("Encoding",n.Name.get("WinAnsiEncoding")),this._fallbackFontDict=e},t}();t.PartialEvaluator=x;var A=function(){function e(e,t,a){this.loadedName=e,this.font=t,this.dict=a,this.type3Loaded=null,this.sent=!1}return e.prototype={send(e){this.sent||(this.sent=!0,e.send("commonobj",[this.loadedName,"Font",this.font.exportData()]))},fallback(e){if(!this.font.data)return;this.font.disableFontFace=!0;const t=this.font.glyphCacheValues;x.buildFontPaths(this.font,t,e)},loadType3Data(e,t,a,i){if(!this.font.isType3Font)throw new Error("Must be a Type3 font.");if(this.type3Loaded)return this.type3Loaded;var n=Object.create(e.options);n.ignoreErrors=!1,n.nativeImageDecoderSupport=r.NativeImageDecoding.NONE;var s=e.clone(n);s.parsingType3Font=!0;for(var o=this.font,c=Promise.resolve(),l=this.dict.get("CharProcs"),h=this.dict.get("Resources")||t,u=l.getKeys(),d=Object.create(null),f=0,g=u.length;fc&&(0,r.info)(`Command ${i}: expected [0, ${c}] args, but received ${l} args.`);else{if(l!==c){for(var h=this.nonProcessedArgs;l>c;)h.push(t.shift()),l--;for(;l=r.OPS.moveTo&&o<=r.OPS.endPath&&++this._numInvalidPathOPS>20)throw new r.FormatError("Invalid "+e);(0,r.warn)("Skipping "+e),null!==t&&(t.length=0);continue}}return this.preprocessCommand(o,t),e.fn=o,e.args=t,!0}if(a===n.EOF)return!1;if(null!==a&&(null===t&&(t=[]),t.push(a),t.length>33))throw new r.FormatError("Too many arguments")}},preprocessCommand:function(e,t){switch(0|e){case r.OPS.save:this.stateManager.save();break;case r.OPS.restore:this.stateManager.restore();break;case r.OPS.transform:this.stateManager.transform(t)}}},t}()},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.CMapFactory=t.IdentityCMap=t.CMap=void 0;var r=a(2),i=a(4),n=a(10),s=a(7),o=a(11),c=["Adobe-GB1-UCS2","Adobe-CNS1-UCS2","Adobe-Japan1-UCS2","Adobe-Korea1-UCS2","78-EUC-H","78-EUC-V","78-H","78-RKSJ-H","78-RKSJ-V","78-V","78ms-RKSJ-H","78ms-RKSJ-V","83pv-RKSJ-H","90ms-RKSJ-H","90ms-RKSJ-V","90msp-RKSJ-H","90msp-RKSJ-V","90pv-RKSJ-H","90pv-RKSJ-V","Add-H","Add-RKSJ-H","Add-RKSJ-V","Add-V","Adobe-CNS1-0","Adobe-CNS1-1","Adobe-CNS1-2","Adobe-CNS1-3","Adobe-CNS1-4","Adobe-CNS1-5","Adobe-CNS1-6","Adobe-GB1-0","Adobe-GB1-1","Adobe-GB1-2","Adobe-GB1-3","Adobe-GB1-4","Adobe-GB1-5","Adobe-Japan1-0","Adobe-Japan1-1","Adobe-Japan1-2","Adobe-Japan1-3","Adobe-Japan1-4","Adobe-Japan1-5","Adobe-Japan1-6","Adobe-Korea1-0","Adobe-Korea1-1","Adobe-Korea1-2","B5-H","B5-V","B5pc-H","B5pc-V","CNS-EUC-H","CNS-EUC-V","CNS1-H","CNS1-V","CNS2-H","CNS2-V","ETHK-B5-H","ETHK-B5-V","ETen-B5-H","ETen-B5-V","ETenms-B5-H","ETenms-B5-V","EUC-H","EUC-V","Ext-H","Ext-RKSJ-H","Ext-RKSJ-V","Ext-V","GB-EUC-H","GB-EUC-V","GB-H","GB-V","GBK-EUC-H","GBK-EUC-V","GBK2K-H","GBK2K-V","GBKp-EUC-H","GBKp-EUC-V","GBT-EUC-H","GBT-EUC-V","GBT-H","GBT-V","GBTpc-EUC-H","GBTpc-EUC-V","GBpc-EUC-H","GBpc-EUC-V","H","HKdla-B5-H","HKdla-B5-V","HKdlb-B5-H","HKdlb-B5-V","HKgccs-B5-H","HKgccs-B5-V","HKm314-B5-H","HKm314-B5-V","HKm471-B5-H","HKm471-B5-V","HKscs-B5-H","HKscs-B5-V","Hankaku","Hiragana","KSC-EUC-H","KSC-EUC-V","KSC-H","KSC-Johab-H","KSC-Johab-V","KSC-V","KSCms-UHC-H","KSCms-UHC-HW-H","KSCms-UHC-HW-V","KSCms-UHC-V","KSCpc-EUC-H","KSCpc-EUC-V","Katakana","NWP-H","NWP-V","RKSJ-H","RKSJ-V","Roman","UniCNS-UCS2-H","UniCNS-UCS2-V","UniCNS-UTF16-H","UniCNS-UTF16-V","UniCNS-UTF32-H","UniCNS-UTF32-V","UniCNS-UTF8-H","UniCNS-UTF8-V","UniGB-UCS2-H","UniGB-UCS2-V","UniGB-UTF16-H","UniGB-UTF16-V","UniGB-UTF32-H","UniGB-UTF32-V","UniGB-UTF8-H","UniGB-UTF8-V","UniJIS-UCS2-H","UniJIS-UCS2-HW-H","UniJIS-UCS2-HW-V","UniJIS-UCS2-V","UniJIS-UTF16-H","UniJIS-UTF16-V","UniJIS-UTF32-H","UniJIS-UTF32-V","UniJIS-UTF8-H","UniJIS-UTF8-V","UniJIS2004-UTF16-H","UniJIS2004-UTF16-V","UniJIS2004-UTF32-H","UniJIS2004-UTF32-V","UniJIS2004-UTF8-H","UniJIS2004-UTF8-V","UniJISPro-UCS2-HW-V","UniJISPro-UCS2-V","UniJISPro-UTF8-V","UniJISX0213-UTF32-H","UniJISX0213-UTF32-V","UniJISX02132004-UTF32-H","UniJISX02132004-UTF32-V","UniKS-UCS2-H","UniKS-UCS2-V","UniKS-UTF16-H","UniKS-UTF16-V","UniKS-UTF32-H","UniKS-UTF32-V","UniKS-UTF8-H","UniKS-UTF8-V","V","WP-Symbol"];class l{constructor(e=!1){this.codespaceRanges=[[],[],[],[]],this.numCodespaceRanges=0,this._map=[],this.name="",this.vertical=!1,this.useCMap=null,this.builtInCMap=e}addCodespaceRange(e,t,a){this.codespaceRanges[e-1].push(t,a),this.numCodespaceRanges++}mapCidRange(e,t,a){for(;e<=t;)this._map[e++]=a++}mapBfRange(e,t,a){for(var r=a.length-1;e<=t;)this._map[e++]=a,a=a.substring(0,r)+String.fromCharCode(a.charCodeAt(r)+1)}mapBfRangeToArray(e,t,a){const r=a.length;let i=0;for(;e<=t&&i>>0;const s=i[n];for(let e=0,t=s.length;e=t&&r<=i)return a.charcode=r,void(a.length=n+1)}}a.charcode=0,a.length=1}get length(){return this._map.length}get isIdentityCMap(){if("Identity-H"!==this.name&&"Identity-V"!==this.name)return!1;if(65536!==this._map.length)return!1;for(let e=0;e<65536;e++)if(this._map[e]!==e)return!1;return!0}}t.CMap=l;class h extends l{constructor(e,t){super(),this.vertical=e,this.addCodespaceRange(t,0,65535)}mapCidRange(e,t,a){(0,r.unreachable)("should not call mapCidRange")}mapBfRange(e,t,a){(0,r.unreachable)("should not call mapBfRange")}mapBfRangeToArray(e,t,a){(0,r.unreachable)("should not call mapBfRangeToArray")}mapOne(e,t){(0,r.unreachable)("should not call mapCidOne")}lookup(e){return Number.isInteger(e)&&e<=65535?e:void 0}contains(e){return Number.isInteger(e)&&e<=65535}forEach(e){for(let t=0;t<=65535;t++)e(t,t)}charCodeOf(e){return Number.isInteger(e)&&e<=65535?e:-1}getMap(){const e=new Array(65536);for(let t=0;t<=65535;t++)e[t]=t;return e}get length(){return 65536}get isIdentityCMap(){(0,r.unreachable)("should not access .isIdentityCMap")}}t.IdentityCMap=h;var u=function(){function e(e,t){for(var a=0,r=0;r<=t;r++)a=a<<8|e[r];return a>>>0}function t(e,t){return 1===t?String.fromCharCode(e[0],e[1]):3===t?String.fromCharCode(e[0],e[1],e[2],e[3]):String.fromCharCode.apply(null,e.subarray(0,t+1))}function a(e,t,a){for(var r=0,i=a;i>=0;i--)r+=e[i]+t[i],e[i]=255&r,r>>=8}function i(e,t){for(var a=1,r=t;r>=0&&a>0;r--)a+=e[r],e[r]=255&a,a>>=8}function n(e){this.buffer=e,this.pos=0,this.end=e.length,this.tmpBuf=new Uint8Array(19)}function s(){}return n.prototype={readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]},readNumber(){var e,t=0;do{var a=this.readByte();if(a<0)throw new r.FormatError("unexpected EOF in bcmap");e=!(128&a),t=t<<7|127&a}while(!e);return t},readSigned(){var e=this.readNumber();return 1&e?~(e>>>1):e>>>1},readHex(e,t){e.set(this.buffer.subarray(this.pos,this.pos+t+1)),this.pos+=t+1},readHexNumber(e,t){var a,i=this.tmpBuf,n=0;do{var s=this.readByte();if(s<0)throw new r.FormatError("unexpected EOF in bcmap");a=!(128&s),i[n++]=127&s}while(!a);for(var o=t,c=0,l=0;o>=0;){for(;l<8&&i.length>0;)c=i[--n]<>=8,l-=8}},readHexSigned(e,t){this.readHexNumber(e,t);for(var a=1&e[t]?255:0,r=0,i=0;i<=t;i++)r=(1&r)<<8|e[i],e[i]=r>>1^a},readString(){for(var e=this.readNumber(),t="",a=0;a=0;){var w=f>>5;if(7!==w){var k=!!(16&f),S=15&f;if(S+1>16)throw new Error("processBinaryCMap: Invalid dataSize.");var C,x=h.readNumber();switch(w){case 0:for(h.readHex(m,S),h.readHexNumber(p,S),a(p,m,S),s.addCodespaceRange(S+1,e(m,S),e(p,S)),C=1;C>>0}function t(e){if(!(0,r.isString)(e))throw new r.FormatError("Malformed CMap: expected string.")}function a(e){if(!Number.isInteger(e))throw new r.FormatError("Malformed CMap: expected int.")}function d(a,r){for(;;){var n=r.getObj();if((0,i.isEOF)(n))break;if((0,i.isCmd)(n,"endbfchar"))return;t(n);var s=e(n);t(n=r.getObj());var o=n;a.mapOne(s,o)}}function f(a,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endbfrange"))return;t(s);var o=e(s);t(s=n.getObj());var c=e(s);if(s=n.getObj(),Number.isInteger(s)||(0,r.isString)(s)){var l=Number.isInteger(s)?String.fromCharCode(s):s;a.mapBfRange(o,c,l)}else{if(!(0,i.isCmd)(s,"["))break;s=n.getObj();for(var h=[];!(0,i.isCmd)(s,"]")&&!(0,i.isEOF)(s);)h.push(s),s=n.getObj();a.mapBfRangeToArray(o,c,h)}}throw new r.FormatError("Invalid bf range.")}function g(r,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endcidchar"))return;t(s);var o=e(s);a(s=n.getObj());var c=s;r.mapOne(o,c)}}function m(r,n){for(;;){var s=n.getObj();if((0,i.isEOF)(s))break;if((0,i.isCmd)(s,"endcidrange"))return;t(s);var o=e(s);t(s=n.getObj());var c=e(s);a(s=n.getObj());var l=s;r.mapCidRange(o,c,l)}}function p(t,a){for(;;){var n=a.getObj();if((0,i.isEOF)(n))break;if((0,i.isCmd)(n,"endcodespacerange"))return;if(!(0,r.isString)(n))break;var s=e(n);if(n=a.getObj(),!(0,r.isString)(n))break;var o=e(n);t.addCodespaceRange(n.length,s,o)}throw new r.FormatError("Invalid codespace range.")}function b(e,t){var a=t.getObj();Number.isInteger(a)&&(e.vertical=!!a)}function y(e,t){var a=t.getObj();(0,i.isName)(a)&&(0,r.isString)(a.name)&&(e.name=a.name)}function v(e,t,a,n){var o,c;e:for(;;)try{var l=t.getObj();if((0,i.isEOF)(l))break;if((0,i.isName)(l))"WMode"===l.name?b(e,t):"CMapName"===l.name&&y(e,t),o=l;else if((0,i.isCmd)(l))switch(l.cmd){case"endcmap":break e;case"usecmap":(0,i.isName)(o)&&(c=o.name);break;case"begincodespacerange":p(e,t);break;case"beginbfchar":d(e,t);break;case"begincidchar":g(e,t);break;case"beginbfrange":f(e,t);break;case"begincidrange":m(e,t)}}catch(e){if(e instanceof s.MissingDataException)throw e;(0,r.warn)("Invalid cMap data: "+e);continue}return!n&&c&&(n=c),n?w(e,a,n):Promise.resolve(e)}function w(e,t,a){return k(a,t).then((function(t){if(e.useCMap=t,0===e.numCodespaceRanges){for(var a=e.useCMap.codespaceRanges,r=0;r=this.firstChar&&e<=this.lastChar?e:-1},amend(e){(0,r.unreachable)("Should not call amend()")}},e}();t.IdentityToUnicodeMap=S;var C=function(){function e(e,t,a){e[t]=a>>8&255,e[t+1]=255&a}function t(e,t,a){e[t]=a>>24&255,e[t+1]=a>>16&255,e[t+2]=a>>8&255,e[t+3]=255&a}function a(e,t,a){var r,i;if(a instanceof Uint8Array)e.set(a,t);else if("string"==typeof a)for(r=0,i=a.length;ra;)a<<=1,r++;var i=a*t;return{range:i,entry:r,rangeShift:t*e-i}},i.prototype={toArray:function(){var n=this.sfnt,s=this.tables,o=Object.keys(s);o.sort();var c,h,u,d,f,g=o.length,m=12+16*g,p=[m];for(c=0;c>>0,p.push(m);var b=new Uint8Array(m);for(c=0;c>>0;t(b,m+4,v),t(b,m+8,p[c]),t(b,m+12,s[f].length),m+=16}return b},addTable:function(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}},i}(),x=function(){function e(e,t,a){var i;this.name=e,this.loadedName=a.loadedName,this.isType3Font=a.isType3Font,this.sizes=[],this.missingFile=!1,this.glyphCache=Object.create(null),this.isSerifFont=!!(a.flags&m.Serif),this.isSymbolicFont=!!(a.flags&m.Symbolic),this.isMonospace=!!(a.flags&m.FixedPitch);var n=a.type,s=a.subtype;this.type=n,this.subtype=s;let o="sans-serif";if(this.isMonospace?o="monospace":this.isSerifFont&&(o="serif"),this.fallbackName=o,this.differences=a.differences,this.widths=a.widths,this.defaultWidth=a.defaultWidth,this.composite=a.composite,this.wideChars=a.wideChars,this.cMap=a.cMap,this.ascent=a.ascent/1e3,this.descent=a.descent/1e3,this.fontMatrix=a.fontMatrix,this.bbox=a.bbox,this.defaultEncoding=a.defaultEncoding,this.toUnicode=a.toUnicode,this.fallbackToUnicode=a.fallbackToUnicode||new k,this.toFontChar=[],"Type3"!==a.type)if(this.cidEncoding=a.cidEncoding,this.vertical=a.vertical,this.vertical&&(this.vmetrics=a.vmetrics,this.defaultVMetrics=a.defaultVMetrics),t&&!t.isEmpty){[n,s]=function(e,{type:t,subtype:a,composite:i}){let n,s;return function(e){var t=e.peekBytes(4);return 65536===(0,l.readUint32)(t,0)||"true"===(0,r.bytesToString)(t)}(e)||I(e)?n=i?"CIDFontType2":"TrueType":!function(e){var t=e.peekBytes(4);return"OTTO"===(0,r.bytesToString)(t)}(e)?!function(e){var t=e.peekBytes(2);return 37===t[0]&&33===t[1]||128===t[0]&&1===t[1]}(e)?!function(e){const t=e.peekBytes(4);return t[0]>=1&&t[3]>=1&&t[3]<=4}(e)?((0,r.warn)("getFontFileType: Unable to detect correct font file Type/Subtype."),n=t,s=a):i?(n="CIDFontType0",s="CIDFontType0C"):(n="MMType1"===t?"MMType1":"Type1",s="Type1C"):n=i?"CIDFontType0":"MMType1"===t?"MMType1":"Type1":n=i?"CIDFontType2":"OpenType",[n,s]}(t,a),n===this.type&&s===this.subtype||(0,r.info)(`Inconsistent font file Type/SubType, expected: ${this.type}/${this.subtype} but found: ${n}/${s}.`);try{var c;switch(n){case"MMType1":(0,r.info)("MMType1 font ("+e+"), falling back to Type1.");case"Type1":case"CIDFontType0":this.mimetype="font/opentype";var h="Type1C"===s||"CIDFontType0C"===s?new T(t,a):new F(e,t,a);b(a),c=this.convert(e,h,a);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype",c=this.checkAndRepair(e,t,a),this.isOpenType&&(b(a),n="OpenType");break;default:throw new r.FormatError(`Font ${n} is not supported`)}}catch(e){return(0,r.warn)(e),void this.fallbackToSystemFont()}this.data=c,this.fontType=y(n,s),this.fontMatrix=a.fontMatrix,this.widths=a.widths,this.defaultWidth=a.defaultWidth,this.toUnicode=a.toUnicode,this.encoding=a.baseEncoding,this.seacMap=a.seacMap}else t&&(0,r.warn)('Font file is empty in "'+e+'" ('+this.loadedName+")"),this.fallbackToSystemFont();else{for(i=0;i<256;i++)this.toFontChar[i]=this.differences[i]||a.defaultEncoding[i];this.fontType=r.FontType.TYPE3}}var t;function a(e,t){return(e<<8)+t}function f(e,t){var a=(e<<8)+t;return 32768&a?a-65536:a}function x(e){return String.fromCharCode(e>>8&255,255&e)}function A(e){return e>32767?e=32767:e<-32768&&(e=-32768),String.fromCharCode(e>>8&255,255&e)}function I(e){const t=e.peekBytes(4);return"ttcf"===(0,r.bytesToString)(t)}function E(e,t,a){for(var r,i=[],n=0,s=e.length;nc){if(++s>=g.length){(0,r.warn)("Ran out of space in font private use area.");break}o=g[s][0],c=g[s][1]}var u=o++;0===h&&(h=a),i[u]=h,n[l]=u}}return{toFontChar:n,charCodeToGlyphId:i,nextAvailableFontCharCode:o}}function P(e,t){var a,i,n,s,o=function(e,t){var a=[];for(var r in e)e[r]>=t||a.push({fontCharCode:0|r,glyphId:e[r]});0===a.length&&a.push({fontCharCode:0,glyphId:0}),a.sort((function(e,t){return e.fontCharCode-t.fontCharCode}));for(var i=[],n=a.length,s=0;s65535?2:1,l="\0\0"+x(c)+"\0\0"+(0,r.string32)(4+8*c);for(a=o.length-1;a>=0&&!(o[a][0]<=65535);--a);var h=a+1;o[a][0]<65535&&65535===o[a][1]&&(o[a][1]=65534);var u,d,f,g,m=o[a][1]<65535?1:0,p=h+m,b=C.getSearchParams(p,2),y="",v="",w="",k="",S="",A=0;for(a=0,i=h;a0&&(v+="ÿÿ",y+="ÿÿ",w+="\0",k+="\0\0");var T="\0\0"+x(2*p)+x(b.range)+x(b.entry)+x(b.rangeShift)+v+"\0\0"+y+w+k+S,E="",O="";if(c>1){for(l+="\0\0\n"+(0,r.string32)(4+8*c+4+T.length),E="",a=0,i=o.length;a(u|=0)||!l)&&(l=u),h 123 are reserved for internal usage");o|=1<65535&&(h=65535)}else l=0,h=255;var f=e.bbox||[0,0,0,0],g=a.unitsPerEm||1/(e.fontMatrix||r.FONT_IDENTITY_MATRIX)[0],m=e.ascentScaled?1:g/1e3,p=a.ascent||Math.round(m*(e.ascent||f[3])),b=a.descent||Math.round(m*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var y=a.yMax||p,v=-a.yMin||-b;return"\0$ô\0\0\0Š»\0\0\0ŒŠ»\0\0ß\x001\0\0\0\0"+String.fromCharCode(e.fixedPitch?9:0)+"\0\0\0\0\0\0"+(0,r.string32)(i)+(0,r.string32)(n)+(0,r.string32)(s)+(0,r.string32)(o)+"*21*"+x(e.italicAngle?1:0)+x(l||e.firstChar)+x(h||e.lastChar)+x(p)+x(b)+"\0d"+x(y)+x(v)+"\0\0\0\0\0\0\0\0"+x(e.xHeight)+x(e.capHeight)+x(0)+x(l||e.firstChar)+"\0"}function D(e){var t=Math.floor(65536*e.italicAngle);return"\0\0\0"+(0,r.string32)(t)+"\0\0\0\0"+(0,r.string32)(e.fixedPitch)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function N(e,t){t||(t=[[],[]]);var a,r,i,n,s,o=[t[0][0]||"Original licence",t[0][1]||e,t[0][2]||"Unknown",t[0][3]||"uniqueID",t[0][4]||e,t[0][5]||"Version 0.11",t[0][6]||"",t[0][7]||"Unknown",t[0][8]||"Unknown",t[0][9]||"Unknown"],c=[];for(a=0,r=o.length;a0,f&&"CIDFontType2"===i&&this.cidEncoding.startsWith("Identity-")){const t=(0,o.getGlyphMapForStandardFonts)(),r=[];for(e in t)r[+e]=t[e];if(/Arial-?Black/i.test(a)){var g=(0,o.getSupplementalGlyphMapForArialBlack)();for(e in g)r[+e]=g[e]}else if(/Calibri/i.test(a)){const t=(0,o.getSupplementalGlyphMapForCalibri)();for(e in t)r[+e]=t[e]}this.toUnicode instanceof S||this.toUnicode.forEach((function(e,t){r[+e]=t})),this.toFontChar=r,this.toUnicode=new k(r)}else if(/Symbol/i.test(h))this.toFontChar=E(s.SymbolSetEncoding,(0,n.getGlyphsUnicode)(),this.differences);else if(/Dingbats/i.test(h))/Wingdings/i.test(a)&&(0,r.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats."),this.toFontChar=E(s.ZapfDingbatsEncoding,(0,n.getDingbatsGlyphsUnicode)(),this.differences);else if(f)this.toFontChar=E(this.defaultEncoding,(0,n.getGlyphsUnicode)(),this.differences);else{const r=(0,n.getGlyphsUnicode)(),i=[];if(this.toUnicode.forEach((e,a)=>{if(!this.composite){var n=this.differences[e]||this.defaultEncoding[e];-1!==(t=(0,c.getUnicodeForGlyph)(n,r))&&(a=t)}i[+e]=a}),this.composite&&this.toUnicode instanceof S&&/Verdana/i.test(a)){const t=(0,o.getGlyphMapForStandardFonts)();for(e in t)i[+e]=t[e]}this.toFontChar=i}this.loadedName=h.split("-")[0],this.fontType=y(i,l)},checkAndRepair:function(e,t,o){const c=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];function l(e,a){const r=Object.create(null);r["OS/2"]=null,r.cmap=null,r.head=null,r.hhea=null,r.hmtx=null,r.maxp=null,r.name=null,r.post=null;for(let e=0;e>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0,s=e.pos;e.pos=e.start?e.start:0,e.skip(i);var o=e.getBytes(n);return e.pos=s,"head"===t&&(o[8]=o[9]=o[10]=o[11]=0,o[17]|=32),{tag:t,checksum:a,length:n,offset:i,data:o}}function g(e){return{version:(0,r.bytesToString)(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function m(e,t,a,r,i,n){var s={length:0,sizeOfInstructions:0};if(a-t<=12)return s;var o=e.subarray(t,a),c=f(o[0],o[1]);if(c<0)return function(e,t,a){e[1]=a,e[0]=a>>>8}(o,0,c=-1),r.set(o,i),s.length=o.length,s;var l,h=10,u=0;for(l=0;lo.length?s:!n&&g>0?(r.set(o.subarray(0,d),i),r.set([0,0],i+d),r.set(o.subarray(m,v),i+d+2),v-=g,o.length-v>3&&(v=v+3&-4),s.length=v,s):o.length-v>3?(v=v+3&-4,r.set(o.subarray(0,v),i),s.length=v,s):(r.set(o,i),s.length=o.length,s)}function y(e){var a=(t.start?t.start:0)+e.offset;t.pos=a;var i=[[],[]],n=e.length,s=a+n;if(0!==t.getUint16()||n<6)return i;var o,c,l=t.getUint16(),h=t.getUint16(),u=[];for(o=0;os)){t.pos=g;var m=f.name;if(f.encoding){for(var p="",b=0,y=f.length;b0&&(l+=S-1)}}else(p||y)&&((0,r.warn)("TT: nested FDEFs not allowed"),m=!0),p=!0,u=l,s=d.pop(),t.functionsDefined[s]={data:c,i:l};else if(!p&&!y)if(s=d[d.length-1],isNaN(s))(0,r.info)("TT: CALL empty stack (or invalid entry).");else if(t.functionsUsed[s]=!0,s in t.functionsStackDeltas){const e=d.length+t.functionsStackDeltas[s];if(e<0)return(0,r.warn)("TT: CALL invalid functions stack delta."),void(t.hintsValid=!1);d.length=e}else if(s in t.functionsDefined&&!g.includes(s)){if(f.push({data:c,i:l,stackTop:d.length-1}),g.push(s),!(o=t.functionsDefined[s]))return(0,r.warn)("TT: CALL non-existent function"),void(t.hintsValid=!1);c=o.data,l=o.i}if(!p&&!y){let e=0;for(k<=142?e=w[k]:k>=192&&k<=223?e=-1:k>=224&&(e=-2),k>=113&&k<=117&&(i=d.pop(),isNaN(i)||(e=2*-i));e<0&&d.length>0;)d.pop(),e++;for(;e>0;)d.push(NaN),e--}}t.tooComplexToFollowFunctions=m;var C=[c];l>c.length&&C.push(new Uint8Array(l-c.length)),u>h&&((0,r.warn)("TT: complementing a missing function tail"),C.push(new Uint8Array([34,45]))),function(e,t){if(t.length>1){var a,r,i=0;for(a=0,r=t.length;a>>0,s=[];for(let t=0;t>>0);const o={ttcTag:t,majorVersion:a,minorVersion:i,numFonts:n,offsetTable:s};switch(a){case 1:return o;case 2:return o.dsigTag=e.getInt32()>>>0,o.dsigLength=e.getInt32()>>>0,o.dsigOffset=e.getInt32()>>>0,o}throw new r.FormatError(`Invalid TrueType Collection majorVersion: ${a}.`)}(e);for(let n=0;n0||!(o.cMap instanceof u.IdentityCMap));if("OTTO"===S.version&&!t||!x.head||!x.hhea||!x.maxp||!x.post)return F=new d.Stream(x["CFF "].data),A=new T(F,o),b(o),this.convert(e,A,o);delete x.glyf,delete x.loca,delete x.fpgm,delete x.prep,delete x["cvt "],this.isOpenType=!0}if(!x.maxp)throw new r.FormatError('Required "maxp" table is not found');t.pos=(t.start||0)+x.maxp.offset;var M=t.getInt32();const L=t.getUint16();let R=L+1,U=!0;R>65535&&(U=!1,R=L,(0,r.warn)("Not enough space in glyfs to duplicate first glyph."));var q=0,j=0;M>=65536&&x.maxp.length>=22&&(t.pos+=8,t.getUint16()>2&&(x.maxp.data[14]=0,x.maxp.data[15]=2),t.pos+=4,q=t.getUint16(),t.pos+=4,j=t.getUint16()),x.maxp.data[4]=R>>8,x.maxp.data[5]=255&R;var _=function(e,t,a,i){var n={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};if(e&&k(e,n),t&&k(t,n),e&&function(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t)(0,r.warn)("TT: more functions defined than expected"),e.hintsValid=!1;else for(var a=0,i=e.functionsUsed.length;at)return(0,r.warn)("TT: invalid function id: "+a),void(e.hintsValid=!1);if(e.functionsUsed[a]&&!e.functionsDefined[a])return(0,r.warn)("TT: undefined function: "+a),void(e.hintsValid=!1)}}(n,i),a&&1&a.length){var s=new Uint8Array(a.length+1);s.set(a.data),a.data=s}return n.hintsValid}(x.fpgm,x.prep,x["cvt "],q);if(_||(delete x.fpgm,delete x.prep,delete x["cvt "]),function(e,t,a,i,n){if(t){e.pos=(e.start?e.start:0)+t.offset,e.pos+=4,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=2,e.pos+=8,e.pos+=2;var s=e.getUint16();s>i&&((0,r.info)("The numOfMetrics ("+s+") should not be greater than the numGlyphs ("+i+")"),s=i,t.data[34]=(65280&s)>>8,t.data[35]=255&s);var o=i-s-(a.length-4*s>>1);if(o>0){var c=new Uint8Array(a.length+2*o);c.set(a.data),n&&(c[a.length]=a.data[2],c[a.length+1]=a.data[3]),a.data=c}}else a&&(a.data=null)}(t,x.hhea,x.hmtx,R,U),!x.head)throw new r.FormatError('Required "head" table is not found');!function(e,t,i){var n=e.data,s=(n[0]<<24)+(n[1]<<16)+(n[2]<<8)+n[3];s>>16!=1&&((0,r.info)("Attempting to fix invalid version in head table: "+s),n[0]=0,n[1]=1,n[2]=0,n[3]=0);var o=a(n[50],n[51]);if(o<0||o>1){(0,r.info)("Attempting to fix invalid indexToLocFormat in head table: "+o);var c=t+1;if(i===c<<1)n[50]=0,n[51]=0;else{if(i!==c<<2)throw new r.FormatError("Could not fix indexToLocFormat: "+o);n[50]=0,n[51]=1}}}(x.head,L,E?x.loca.length:0);var z=Object.create(null);if(E){var H=a(x.head.data[50],x.head.data[51]),G=function(e,t,a,r,i,n,s){var o,c,l;r?(o=4,c=function(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]},l=function(e,t,a){e[t]=a>>>24&255,e[t+1]=a>>16&255,e[t+2]=a>>8&255,e[t+3]=255&a}):(o=2,c=function(e,t){return e[t]<<9|e[t+1]<<1},l=function(e,t,a){e[t]=a>>9&255,e[t+1]=a>>1&255});var h=n?a+1:a,u=o*(1+h),d=new Uint8Array(u);d.set(e.data.subarray(0,u)),e.data=d;var f,g,p=t.data,b=p.length,y=new Uint8Array(b),v=c(d,0),w=0,k=Object.create(null);for(l(d,0,w),f=0,g=o;fb&&(b+3&-4)===S&&(S=b),S>b&&(v=S);var C=m(p,v,S,y,w,i),x=C.length;0===x&&(k[f]=!0),C.sizeOfInstructions>s&&(s=C.sizeOfInstructions),l(d,g,w+=x),v=S}if(0===w){var A=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(f=0,g=o;fI+w?t.data=y.subarray(0,I+w):(t.data=new Uint8Array(I+w),t.data.set(y.subarray(0,w))),t.data.set(y.subarray(0,I),w),l(e.data,d.length-o,w+I)}else t.data=y.subarray(0,w);return{missingGlyphs:k,maxSizeOfInstructions:s}}(x.loca,x.glyf,L,H,_,U,j);z=G.missingGlyphs,M>=65536&&x.maxp.length>=22&&(x.maxp.data[26]=G.maxSizeOfInstructions>>8,x.maxp.data[27]=255&G.maxSizeOfInstructions)}if(!x.hhea)throw new r.FormatError('Required "hhea" table is not found');0===x.hhea.data[10]&&0===x.hhea.data[11]&&(x.hhea.data[10]=255,x.hhea.data[11]=255);var W={unitsPerEm:a(x.head.data[18],x.head.data[19]),yMax:a(x.head.data[42],x.head.data[43]),yMin:f(x.head.data[38],x.head.data[39]),ascent:a(x.hhea.data[4],x.hhea.data[5]),descent:f(x.hhea.data[6],x.hhea.data[7])};this.ascent=W.ascent/W.unitsPerEm,this.descent=W.descent/W.unitsPerEm,x.post&&function(e,a,i){var n=(t.start?t.start:0)+e.offset;t.pos=n;var s,o=n+e.length,c=t.getInt32();t.getBytes(28);var l,h=!0;switch(c){case 65536:s=p;break;case 131072:var u=t.getUint16();if(u!==i){h=!1;break}var d=[];for(l=0;l=32768){h=!1;break}d.push(f)}if(!h)break;for(var g=[],m=[];t.pos65535)throw new r.FormatError("Max size of CID is 65,535");var a=-1;J?a=t:void 0!==Y[t]&&(a=Y[t]),a>=0&&a>>0,g=!1;if((!o||o.platformId!==u||o.encodingId!==d)&&(0===u&&0===d||1===u&&0===d?g=!0:3!==u||1!==d||!i&&o?a&&3===u&&0===d&&(g=!0,l=!0):(g=!0,a||(l=!0)),g&&(o={platformId:u,encodingId:d,offset:f}),l))break}if(o&&(t.pos=s+o.offset),!o||-1===t.peekByte())return(0,r.warn)("Could not find a preferred cmap table."),{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1};var m=t.getUint16();t.getUint16(),t.getUint16();var p,b,y=!1,v=[];if(0===m){for(p=0;p<256;p++){var w=t.getByte();w&&v.push({charCode:p,glyphId:w})}y=!0}else if(4===m){var k=t.getUint16()>>1;t.getBytes(6);var S,C=[];for(S=0;S>1)-(k-S);n.offsetIndex=I,x=Math.max(x,I+n.end-n.start+1)}else n.offsetIndex=-1}var F=[];for(p=0;p0&&K(ce)&&(V[X]=ce)}}}}else if(0===$&&0===Q)for(let e=0;e=61440&&X<=61695&&(X&=255),V[X]=ee[e].glyphId}0===V.length&&(V[0]=0);let le=R-1;U||(le=0);var he=O(V,K,le);if(this.toFontChar=he.toFontChar,x.cmap={tag:"cmap",data:P(he.charCodeToGlyphId,R)},x["OS/2"]&&function(e){var t=new d.Stream(e.data),a=t.getUint16();t.getBytes(60);var r=t.getUint16();return!(a<4&&768&r)&&(!(t.getUint16()>t.getUint16())&&(t.getBytes(6),0!==t.getUint16()&&(e.data[8]=e.data[9]=0,!0)))}(x["OS/2"])||(x["OS/2"]={tag:"OS/2",data:B(o,he.charCodeToGlyphId,W)}),!E)try{F=new d.Stream(x["CFF "].data),A=new i.CFFParser(F,o,!0).parse(),A.duplicateFirstGlyph();var ue=new i.CFFCompiler(A);x["CFF "].data=ue.compile()}catch(e){(0,r.warn)("Failed to compile font "+o.loadedName)}if(x.name){var de=y(x.name);x.name.data=N(e,de)}else x.name={tag:"name",data:N(this.name)};var fe=new C(S.version);for(var ge in x)fe.addTable(ge,x[ge].data);return fe.toArray()},convert:function(e,t,a){a.fixedPitch=!1,a.builtInEncoding&&function(e,t){if(!e.hasIncludedToUnicodeMap&&!(e.hasEncoding||t===e.defaultEncoding||e.toUnicode instanceof S)){var a=[],r=(0,n.getGlyphsUnicode)();for(var i in t){var s=t[i],o=(0,c.getUnicodeForGlyph)(s,r);-1!==o&&(a[i]=String.fromCharCode(o))}e.toUnicode.amend(a)}}(a,a.builtInEncoding);let i=1;t instanceof T&&(i=t.numGlyphs-1);var o=t.getGlyphMapping(a),l=O(o,t.hasGlyphId.bind(t),i);this.toFontChar=l.toFontChar;var h=t.numGlyphs;function u(e,t){var a=null;for(var r in e)t===e[r]&&(a||(a=[]),a.push(0|r));return a}function d(e,t){for(var a in e)if(t===e[a])return 0|a;return l.charCodeToGlyphId[l.nextAvailableFontCharCode]=t,l.nextAvailableFontCharCode++}var f=t.seacs;if(f&&f.length){var g=a.fontMatrix||r.FONT_IDENTITY_MATRIX,m=t.getCharset(),p=Object.create(null);for(var b in f){var y=f[b|=0],v=s.StandardEncoding[y[2]],w=s.StandardEncoding[y[3]],k=m.indexOf(v),I=m.indexOf(w);if(!(k<0||I<0)){var F={x:y[0]*g[0]+y[1]*g[2]+g[4],y:y[0]*g[1]+y[1]*g[3]+g[5]},E=u(o,b);if(E)for(var M=0,L=E.length;M=0?r:0;else if(l)for(i in t)c[i]=t[i];else for(o=s.StandardEncoding,i=0;i=0?r:0;var h,u=e.differences;if(u)for(i in u){var d=u[i];if(-1===(r=a.indexOf(d))){h||(h=(0,n.getGlyphsUnicode)());var f=v(d,h);f!==d&&(r=a.indexOf(f))}c[i]=r>=0?r:0}return c}t.ErrorFont=A;var F=function(){function e(e,t,a){for(var r,i=e.length,n=t.length,s=i-n,o=a,c=!1;o=n){for(o+=r;o=0&&(n[s]=t)}return I(e,n,r)},hasGlyphId:function(e){return!(e<0||e>=this.numGlyphs)&&(0===e||this.charstrings[e-1].charstring.length>0)},getSeacs:function(e){var t,a,r=[];for(t=0,a=e.length;t0;y--)b[y]-=b[y-1];g.setByName(p,b)}}s.topDict.privateDict=g;var v=new i.CFFIndex;for(l=0,h=r.length;l=t)throw new r.FormatError("Invalid CFF header");0!==a&&((0,r.info)("cff data is shifted"),e=e.subarray(a),this.bytes=e);var i=e[0],n=e[1],s=e[2],o=e[3];return{obj:new l(i,n,s,o),endPos:s}},parseDict:function(e){var t=0;function a(){var a=e[t++];return 30===a?function(){var a="";const r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(var i=e.length;t>4,o=15&n;if(15===s)break;if(a+=r[s],15===o)break;a+=r[o]}return parseFloat(a)}():28===a?((a=e[t++])<<24|e[t++]<<16)>>16:29===a?(a=(a=(a=e[t++])<<8|e[t++])<<8|e[t++])<<8|e[t++]:a>=32&&a<=246?a-139:a>=247&&a<=250?256*(a-247)+e[t++]+108:a>=251&&a<=254?-256*(a-251)-e[t++]-108:((0,r.warn)('CFFParser_parseDict: "'+a+'" is a reserved command.'),NaN)}var i=[],n=[];t=0;for(var s=e.length;t10)return!1;for(var o=a.stackSize,c=a.stack,l=i.length,h=0;h>16,h+=2,o++;else if(14===u){if(o>=4&&(o-=4,this.seacAnalysisEnabled))return a.seac=c.slice(o,o+4),!1;d=e[u]}else if(u>=32&&u<=246)c[o]=u-139,o++;else if(u>=247&&u<=254)c[o]=u<251?(u-247<<8)+i[h]+108:-(u-251<<8)-i[h]-108,h++,o++;else if(255===u)c[o]=(i[h]<<24|i[h+1]<<16|i[h+2]<<8|i[h+3])/65536,h+=4,o++;else if(19===u||20===u)a.hints+=o>>1,h+=a.hints+7>>3,o%=2,d=e[u];else{if(10===u||29===u){var g;if(!(g=10===u?n:s))return d=e[u],(0,r.warn)("Missing subrsIndex for "+d.id),!1;var m=32768;g.count<1240?m=107:g.count<33900&&(m=1131);var p=c[--o]+m;if(p<0||p>=g.count||isNaN(p))return d=e[u],(0,r.warn)("Out of bounds subrIndex for "+d.id),!1;if(a.stackSize=o,a.callDepth++,!this.parseCharString(a,g.get(p),n,s))return!1;a.callDepth--,o=a.stackSize;continue}if(11===u)return a.stackSize=o,!0;d=e[u]}if(d){if(d.stem&&(a.hints+=o>>1,3===u||23===u?a.hasVStems=!0:!a.hasVStems||1!==u&&18!==u||((0,r.warn)("CFF stem hints are in wrong order"),i[h-1]=1===u?3:23)),"min"in d&&!a.undefStack&&o=2&&d.stem?o%=2:o>1&&(0,r.warn)("Found too many parameters for stack-clearing command"),o>0&&c[o-1]>=0&&(a.width=c[o-1])),"stackDelta"in d?("stackFn"in d&&d.stackFn(c,o),o+=d.stackDelta):d.stackClearing?o=0:d.resetStack?(o=0,a.undefStack=!1):d.undefStack&&(o=0,a.undefStack=!0,a.firstStackClearing=!1)}}return a.stackSize=o,!0},parseCharStrings({charStrings:e,localSubrIndex:t,globalSubrIndex:a,fdSelect:i,fdArray:n,privateDict:s}){for(var o=[],c=[],l=e.count,h=0;h=n.length&&((0,r.warn)("Invalid fd index for glyph index."),f=!1),f&&(g=(m=n[p].privateDict).subrsIndex)}else t&&(g=t);if(f&&(f=this.parseCharString(d,u,g,a)),null!==d.width){const e=m.getByName("nominalWidthX");c[h]=e+d.width}else{const e=m.getByName("defaultWidthX");c[h]=e}null!==d.seac&&(o[h]=d.seac),f||e.set(h,new Uint8Array([14]))}return{charStrings:e,seacs:o,widths:c}},emptyPrivateDictionary:function(e){var t=this.createDict(g,[],e.strings);e.setByKey(18,[0,0]),e.privateDict=t},parsePrivateDict:function(e){if(e.hasName("Private")){var t=e.getByName("Private");if(Array.isArray(t)&&2===t.length){var a=t[0],r=t[1];if(0===a||r>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=r+a,n=this.bytes.subarray(r,i),s=this.parseDict(n),o=this.createDict(g,s,e.strings);if(e.privateDict=o,o.getByName("Subrs")){var c=o.getByName("Subrs"),l=r+c;if(0===c||l>=this.bytes.length)this.emptyPrivateDictionary(e);else{var h=this.parseIndex(l);o.subrsIndex=h.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)},parseCharsets:function(e,t,a,n){if(0===e)return new p(!0,m.ISO_ADOBE,i.ISOAdobeCharset);if(1===e)return new p(!0,m.EXPERT,i.ExpertCharset);if(2===e)return new p(!0,m.EXPERT_SUBSET,i.ExpertSubsetCharset);var s,o,c,l=this.bytes,h=e,u=l[e++],d=[".notdef"];switch(t-=1,u){case 0:for(c=0;c=65535)(0,r.warn)("Not enough space in charstrings to duplicate first glyph.");else{var e=this.charStrings.get(0);this.charStrings.add(e),this.isCIDFont&&this.fdSelect.fdSelect.push(this.fdSelect.fdSelect[0])}},hasGlyphId:function(e){return!(e<0||e>=this.charStrings.count)&&this.charStrings.get(e).length>0}},e}();t.CFF=c;var l=function(e,t,a,r){this.major=e,this.minor=t,this.hdrSize=a,this.offSize=r};t.CFFHeader=l;var h=function(){function e(){this.strings=[]}return e.prototype={get:function(e){return e>=0&&e<=390?s[e]:e-391<=this.strings.length?this.strings[e-391]:s[0]},getSID:function(e){let t=s.indexOf(e);return-1!==t?t:(t=this.strings.indexOf(e),-1!==t?t+391:-1)},add:function(e){this.strings.push(e)},get count(){return this.strings.length}},e}();t.CFFStrings=h;var u=function(){function e(){this.objects=[],this.length=0}return e.prototype={add:function(e){this.length+=e.length,this.objects.push(e)},set:function(e,t){this.length+=t.length-this.objects[e].length,this.objects[e]=t},get:function(e){return this.objects[e]},get count(){return this.objects.length}},e}();t.CFFIndex=u;var d=function(){function e(e,t){this.keyToNameMap=e.keyToNameMap,this.nameToKeyMap=e.nameToKeyMap,this.defaults=e.defaults,this.types=e.types,this.opcodes=e.opcodes,this.order=e.order,this.strings=t,this.values=Object.create(null)}return e.prototype={setByKey:function(e,t){if(!(e in this.keyToNameMap))return!1;var a=t.length;if(0===a)return!0;for(var i=0;i=this.fdSelect.length?-1:this.fdSelect[e]}},e}();t.CFFFDSelect=y;var v=function(){function e(){this.offsets=Object.create(null)}return e.prototype={isTracking:function(e){return e in this.offsets},track:function(e,t){if(e in this.offsets)throw new r.FormatError("Already tracking location of "+e);this.offsets[e]=t},offset:function(e){for(var t in this.offsets)this.offsets[t]+=e},setEntryLocation:function(e,t,a){if(!(e in this.offsets))throw new r.FormatError("Not tracking location of "+e);for(var i=a.data,n=this.offsets[e],s=0,o=t.length;s>24&255,i[h]=f>>16&255,i[u]=f>>8&255,i[d]=255&f}}},e}(),w=function(){function e(e){this.cff=e}return e.prototype={compile:function(){var e=this.cff,t={data:[],length:0,add:function(e){this.data=this.data.concat(e),this.length=this.data.length}},a=this.compileHeader(e.header);t.add(a);var i=this.compileNameIndex(e.names);if(t.add(i),e.isCIDFont&&e.topDict.hasName("FontMatrix")){var n=e.topDict.getByName("FontMatrix");e.topDict.removeByName("FontMatrix");for(var s=0,o=e.fdArray.length;s=-107&&e<=107?[e+139]:e>=108&&e<=1131?[247+((e-=108)>>8),255&e]:e>=-1131&&e<=-108?[251+((e=-e-108)>>8),255&e]:e>=-32768&&e<=32767?[28,e>>8&255,255&e]:[29,e>>24&255,e>>16&255,e>>8&255,255&e]},compileHeader:function(e){return[e.major,e.minor,e.hdrSize,e.offSize]},compileNameIndex:function(e){for(var t=new u,a=0,i=e.length;a"~"||"["===l||"]"===l||"("===l||")"===l||"{"===l||"}"===l||"<"===l||">"===l||"/"===l||"%"===l)&&(l="_"),o[c]=l}""===(o=o.join(""))&&(o="Bad_Font_Name"),t.add((0,r.stringToBytes)(o))}return this.compileIndex(t)},compileTopDicts:function(e,t,a){for(var r=[],i=new u,n=0,s=e.length;n>8&255,255&s]);else{n=new Uint8Array(1+2*s),n[0]=0;let t=0;const i=e.charset.length;let o=!1;for(let s=1;s>8&255,n[s+1]=255&c}}return this.compileTypedArray(n)},compileEncoding:function(e){return this.compileTypedArray(e.raw)},compileFDSelect:function(e){const t=e.format;let a,r;switch(t){case 0:for(a=new Uint8Array(1+e.fdSelect.length),a[0]=t,r=0;r>8&255,255&i,n];for(r=1;r>8&255,255&r,t),n=t)}const o=(s.length-3)/3;s[1]=o>>8&255,s[2]=255&o,s.push(r>>8&255,255&r),a=new Uint8Array(s)}return this.compileTypedArray(a)},compileTypedArray:function(e){for(var t=[],a=0,r=e.length;a>8&255,255&r],o=1;for(i=0;i>8&255,255&c):3===n?s.push(c>>16&255,c>>8&255,255&c):s.push(c>>>24&255,c>>16&255,c>>8&255,255&c),a[i]&&(c+=a[i].length);for(i=0;i=65520&&e<=65535?0:e>=62976&&e<=63743?i()[e]||e:173===e?45:e},t.reverseIfRtl=function(e){var t,a,r=e.length;if(r<=1||!((t=e.charCodeAt(0))>=(a=n[13]).begin&&t=(a=n[11]).begin&&t=0;s--)i+=e[s];return i},t.getUnicodeRangeFor=function(e){for(var t=0,a=n.length;t=r.begin&&e=5&&i<=7))return-1;r=e.substring(1)}if(r===r.toUpperCase()&&(a=parseInt(r,16))>=0)return a}return-1}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FontRendererFactory=void 0;var r=a(2),i=a(28),n=a(31),s=a(30),o=a(11),c=function(){function e(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function t(e,t){return e[t]<<8|e[t+1]}function a(e){const t=e.length;let a=32768;return t<1240?a=107:t<33900&&(a=1131),a}function c(a,i,n){var s,o,c,l=1===t(a,i+2)?e(a,i+8):e(a,i+16),h=t(a,i+l);if(4===h){t(a,i+l+2);var u=t(a,i+l+6)>>1;for(o=i+l+14,s=[],c=0;c>1;a=0&&e>16,h=0,u=0;if(c+=10,l<0)do{o=t[c]<<8|t[c+1];var d,f,g=t[c+2]<<8|t[c+3];c+=4,1&o?(d=(t[c]<<24|t[c+1]<<16)>>16,f=(t[c+2]<<24|t[c+3]<<16)>>16,c+=4):(d=t[c++],f=t[c++]),2&o?(h=d,u=f):(h=0,u=0);var m=1,p=1,b=0,y=0;8&o?(m=p=(t[c]<<24|t[c+1]<<16)/1073741824,c+=2):64&o?(m=(t[c]<<24|t[c+1]<<16)/1073741824,p=(t[c+2]<<24|t[c+3]<<16)/1073741824,c+=4):128&o&&(m=(t[c]<<24|t[c+1]<<16)/1073741824,b=(t[c+2]<<24|t[c+3]<<16)/1073741824,y=(t[c+4]<<24|t[c+5]<<16)/1073741824,p=(t[c+6]<<24|t[c+7]<<16)/1073741824,c+=8);var v=r.glyphs[g];v&&(a.push({cmd:"save"}),a.push({cmd:"transform",args:[m,b,y,p,h,u]}),e(v,a,r),a.push({cmd:"restore"}))}while(32&o);else{var w,k,S=[];for(w=0;w0;)x.push({flags:o})}for(w=0;w>16,c+=2;break;case 2:h-=t[c++];break;case 18:h+=t[c++]}x[w].x=h}for(w=0;w>16,c+=2;break;case 4:u-=t[c++];break;case 36:u+=t[c++]}x[w].y=u}var I=0;for(c=0;c>1,I=!0;break;case 4:u+=c.pop(),f(l,u),I=!0;break;case 5:for(;c.length>0;)l+=c.shift(),u+=c.shift(),g(l,u);break;case 6:for(;c.length>0&&(g(l+=c.shift(),u),0!==c.length);)u+=c.shift(),g(l,u);break;case 7:for(;c.length>0&&(u+=c.shift(),g(l,u),0!==c.length);)g(l+=c.shift(),u);break;case 8:for(;c.length>0;)y=l+c.shift(),w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k+c.shift(),m(y,w,v,k,l,u);break;case 10:if(x=c.pop(),A=null,n.isCFFCIDFont){const e=n.fdSelect.getFDIndex(o);if(e>=0&&eMath.abs(u-E)?l+=c.shift():u+=c.shift(),m(y,w,v,k,l,u);break;default:throw new r.FormatError("unknown operator: 12 "+F)}break;case 14:if(c.length>=4){var O=c.pop(),P=c.pop();u=c.pop(),l=c.pop(),i.push({cmd:"save"}),i.push({cmd:"translate",args:[l,u]});var B=h(n.cmap,String.fromCharCode(n.glyphNameMap[s.StandardEncoding[O]]));e(n.glyphs[B.glyphId],i,n,B.glyphId),i.push({cmd:"restore"}),B=h(n.cmap,String.fromCharCode(n.glyphNameMap[s.StandardEncoding[P]])),e(n.glyphs[B.glyphId],i,n,B.glyphId)}return;case 18:d+=c.length>>1,I=!0;break;case 19:case 20:b+=(d+=c.length>>1)+7>>3,I=!0;break;case 21:u+=c.pop(),f(l+=c.pop(),u),I=!0;break;case 22:f(l+=c.pop(),u),I=!0;break;case 23:d+=c.length>>1,I=!0;break;case 24:for(;c.length>2;)y=l+c.shift(),w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k+c.shift(),m(y,w,v,k,l,u);l+=c.shift(),u+=c.shift(),g(l,u);break;case 25:for(;c.length>6;)l+=c.shift(),u+=c.shift(),g(l,u);y=l+c.shift(),w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k+c.shift(),m(y,w,v,k,l,u);break;case 26:for(c.length%2&&(l+=c.shift());c.length>0;)y=l,w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v,u=k+c.shift(),m(y,w,v,k,l,u);break;case 27:for(c.length%2&&(u+=c.shift());c.length>0;)m(y=l+c.shift(),w=u,v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k);break;case 28:c.push((p[b]<<24|p[b+1]<<16)>>16),b+=2;break;case 29:x=c.pop()+n.gsubrsBias,(A=n.gsubrs[x])&&t(A);break;case 30:for(;c.length>0&&(y=l,w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k+(1===c.length?c.shift():0),m(y,w,v,k,l,u),0!==c.length);)y=l+c.shift(),w=u,v=y+c.shift(),k=w+c.shift(),u=k+c.shift(),m(y,w,v,k,l=v+(1===c.length?c.shift():0),u);break;case 31:for(;c.length>0&&(y=l+c.shift(),w=u,v=y+c.shift(),k=w+c.shift(),u=k+c.shift(),m(y,w,v,k,l=v+(1===c.length?c.shift():0),u),0!==c.length);)y=l,w=u+c.shift(),v=y+c.shift(),k=w+c.shift(),l=v+c.shift(),u=k+(1===c.length?c.shift():0),m(y,w,v,k,l,u);break;default:if(F<32)throw new r.FormatError("unknown operator: "+F);F<247?c.push(F-139):F<251?c.push(256*(F-247)+p[b++]+108):F<255?c.push(256*-(F-251)-p[b++]-108):(c.push((p[b]<<24|p[b+1]<<16|p[b+2]<<8|p[b+3])/65536),b+=4)}I&&(c.length=0)}}(t)}(e,t,this,i)}}return{create:function(a,i){for(var n,s,o,h,u,d,m=new Uint8Array(a.data),p=t(m,4),b=0,y=12;br)return!0;for(var i=r-e,n=i;n>8&255,255&s):(s=65536*s|0,this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s))}return this.output.push.apply(this.output,t),a?this.stack.splice(i,e):this.stack.length=0,!1}},d}(),c=function(){function e(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function t(e,t,a){if(a>=e.length)return new Uint8Array(0);var r,i,n=0|t;for(r=0;r>8,n=52845*(c+n)+22719&65535}return o}function a(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function s(a,r,i){if(r){var s=a.getBytes(),o=!(e(s[0])&&e(s[1])&&e(s[2])&&e(s[3]));a=new n.Stream(o?t(s,55665,4):function(t,a,r){var i,n,s=55665,o=t.length,c=new Uint8Array(o>>>1);for(i=0,n=0;i>8,s=52845*(u+s)+22719&65535}}}return Array.prototype.slice.call(c,4,n)}(s))}this.seacAnalysisEnabled=!!i,this.stream=a,this.nextChar()}return s.prototype={readNumberArray:function(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function(){var e=this.getToken();return parseFloat(e||0)},readInt:function(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function(){return"true"===this.getToken()?1:0},nextChar:function(){return this.currentChar=this.stream.getByte()},getToken:function(){for(var e=!1,t=this.currentChar;;){if(-1===t)return null;if(e)10!==t&&13!==t||(e=!1);else if(37===t)e=!0;else if(!(0,i.isWhiteSpace)(t))break;t=this.nextChar()}if(a(t))return this.nextChar(),String.fromCharCode(t);var r="";do{r+=String.fromCharCode(t),t=this.nextChar()}while(t>=0&&!(0,i.isWhiteSpace)(t)&&!a(t));return r},readCharStrings:function(e,a){return-1===a?e:t(e,4330,a)},extractFontProgram:function(e){var t=this.stream,a=[],r=[],i=Object.create(null);i.lenIV=4;for(var n,s,c,l,h,u={subrs:[],charstrings:[],properties:{privateData:i}};null!==(n=this.getToken());)if("/"===n)switch(n=this.getToken()){case"CharStrings":for(this.getToken(),this.getToken(),this.getToken(),this.getToken();null!==(n=this.getToken())&&"end"!==n;)if("/"===n){var d=this.getToken();s=this.readInt(),this.getToken(),c=s>0?t.getBytes(s):new Uint8Array(0),l=u.properties.privateData.lenIV,h=this.readCharStrings(c,l),this.nextChar(),"noaccess"===(n=this.getToken())&&this.getToken(),r.push({glyph:d,encoded:h})}break;case"Subrs":for(this.readInt(),this.getToken();"dup"===this.getToken();){var f=this.readInt();s=this.readInt(),this.getToken(),c=s>0?t.getBytes(s):new Uint8Array(0),l=u.properties.privateData.lenIV,h=this.readCharStrings(c,l),this.nextChar(),"noaccess"===(n=this.getToken())&&this.getToken(),a[f]=h}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var g=this.readNumberArray();g.length>0&&g.length;break;case"StemSnapH":case"StemSnapV":u.properties.privateData[n]=this.readNumberArray();break;case"StdHW":case"StdVW":u.properties.privateData[n]=this.readNumberArray()[0];break;case"BlueShift":case"lenIV":case"BlueFuzz":case"BlueScale":case"LanguageGroup":case"ExpansionFactor":u.properties.privateData[n]=this.readNumber();break;case"ForceBold":u.properties.privateData[n]=this.readBoolean()}for(var m=0;m-1&&void 0===e.widths[t]&&t>=e.firstChar&&t<=e.lastChar&&(e.widths[t]=p.width)}}return u},extractFontHeader:function(e){for(var t;null!==(t=this.getToken());)if("/"===t)switch(t=this.getToken()){case"FontMatrix":var a=this.readNumberArray();e.fontMatrix=a;break;case"Encoding":var i,n=this.getToken();if(/^\d+$/.test(n)){i=[];var s=0|parseInt(n,10);this.getToken();for(var o=0;o=u||A<=0)(0,r.info)("Bad shading domain.");else{var F,T=new Float32Array(o.numComps),E=new Float32Array(1);for(let e=0;e<=10;e++){E[0]=h+e*A,x(E,0,T,0),F=o.getRgb(T,0);var O=r.Util.makeCssRgb(F[0],F[1],F[2]);I.push([e/10,O])}var P="transparent";e.has("Background")&&(F=o.getRgb(e.get("Background"),0),P=r.Util.makeCssRgb(F[0],F[1],F[2])),f||(I.unshift([0,P]),I[1][0]+=c.SMALL_NUMBER),g||(I[I.length-1][0]-=c.SMALL_NUMBER,I.push([1,P])),this.colorStops=I}}return e.prototype={getIR:function(){var e,t,a,i,n,s=this.coordsArr,o=this.shadingType;2===o?(t=[s[0],s[1]],a=[s[2],s[3]],i=null,n=null,e="axial"):3===o?(t=[s[0],s[1]],a=[s[3],s[4]],i=s[2],n=s[5],e="radial"):(0,r.unreachable)("getPattern type unknown: "+o);var c=this.matrix;if(c&&(t=r.Util.applyTransform(t,c),a=r.Util.applyTransform(a,c),3===o)){var l=r.Util.singularValueDecompose2dScale(c);i*=l[0],n*=l[1]}return["RadialAxial",e,this.bbox,this.colorStops,t,a,i,n]}},e}(),c.Mesh=function(){function e(e,t){this.stream=e,this.context=t,this.buffer=0,this.bufferLength=0;var a=t.numComps;this.tmpCompsBuf=new Float32Array(a);var r=t.colorSpace.numComps;this.tmpCsCompsBuf=t.colorFn?new Float32Array(r):this.tmpCompsBuf}e.prototype={get hasData(){if(this.stream.end)return this.stream.pos0)return!0;var e=this.stream.getByte();return!(e<0)&&(this.buffer=e,this.bufferLength=8,!0)},readBits:function(e){var t=this.buffer,a=this.bufferLength;if(32===e){if(0===a)return(this.stream.getByte()<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte())>>>0;t=t<<24|this.stream.getByte()<<16|this.stream.getByte()<<8|this.stream.getByte();var r=this.stream.getByte();return this.buffer=r&(1<>a)>>>0}if(8===e&&0===a)return this.stream.getByte();for(;a>a},align:function(){this.buffer=0,this.bufferLength=0},readFlag:function(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function(){var e=this.context.bitsPerCoordinate,t=this.readBits(e),a=this.readBits(e),r=this.context.decode,i=e<32?1/((1<o?o:t,a=a>c?c:a,r=r=0&&"ET"===f[F];--F)f[F]="EN";for(F=p+1;F0&&(E=f[p-1]);var O=A;T+1P&&s(P)&&(D=P);for(P=B;P>=D;--P){var N=-1;for(p=0,b=k.length;p=0&&(h(d,N,p),N=-1):N<0&&(N=p);N>=0&&h(d,N,k.length)}for(p=0,b=d.length;p"!==M||(d[p]="")}return u(d.join(""),g)};var r=a(2),i=["BN","BN","BN","BN","BN","BN","BN","BN","BN","S","B","S","WS","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","B","B","B","S","WS","ON","ON","ET","ET","ET","ON","ON","ON","ON","ON","ES","CS","ES","CS","CS","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","CS","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","ON","ON","ON","BN","BN","BN","BN","BN","BN","B","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","BN","CS","ON","ET","ET","ET","ET","ON","ON","ON","ON","L","ON","ON","BN","ON","ON","ET","ET","EN","EN","ON","L","ON","ON","ON","EN","L","ON","ON","ON","ON","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","L","ON","L","L","L","L","L","L","L","L"],n=["AN","AN","AN","AN","AN","AN","ON","ON","AL","ET","ET","AL","CS","AL","ON","ON","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","AN","AN","AN","AN","AN","AN","AN","AN","AN","ET","AN","AN","AL","AL","AL","NSM","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","AL","NSM","NSM","NSM","NSM","NSM","NSM","NSM","AN","ON","NSM","NSM","NSM","NSM","NSM","NSM","AL","AL","NSM","NSM","ON","NSM","NSM","NSM","NSM","AL","AL","EN","EN","EN","EN","EN","EN","EN","EN","EN","EN","AL","AL","AL","AL","AL","AL"];function s(e){return 0!=(1&e)}function o(e){return 0==(1&e)}function c(e,t,a){for(var r=t,i=e.length;r>c)*h,l&=(1<a?e=a:e0&&(d=i[h-1]);var f=r[1];h>1,c=i.length>>1,u=new l(s),d=Object.create(null),f=8192,g=new Float32Array(c);return function(e,t,a,r){var i,s,l="",h=g;for(i=0;i(v=n[2*i+1]))&&(s=v),p[i]=s}f>0&&(f--,d[l]=p),a.set(p,r)}else a.set(m,r)}}},c=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}return e.prototype={push:function(e){if(this.stack.length>=100)throw new Error("PostScript function stack overflow.");this.stack.push(e)},pop:function(){if(this.stack.length<=0)throw new Error("PostScript function stack underflow.");return this.stack.pop()},copy:function(e){if(this.stack.length+e>=100)throw new Error("PostScript function stack overflow.");for(var t=this.stack,a=t.length-e,r=e-1;r>=0;r--,a++)t.push(t[a])},index:function(e){this.push(this.stack[this.stack.length-e-1])},roll:function(e,t){var a,r,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(a=s,r=o;a0?n.push(a<>i);break;case"ceiling":a=n.pop(),n.push(Math.ceil(a));break;case"copy":a=n.pop(),n.copy(a);break;case"cos":a=n.pop(),n.push(Math.cos(a));break;case"cvi":a=0|n.pop(),n.push(a);break;case"cvr":break;case"div":i=n.pop(),a=n.pop(),n.push(a/i);break;case"dup":n.copy(1);break;case"eq":i=n.pop(),a=n.pop(),n.push(a===i);break;case"exch":n.roll(2,1);break;case"exp":i=n.pop(),a=n.pop(),n.push(a**i);break;case"false":n.push(!1);break;case"floor":a=n.pop(),n.push(Math.floor(a));break;case"ge":i=n.pop(),a=n.pop(),n.push(a>=i);break;case"gt":i=n.pop(),a=n.pop(),n.push(a>i);break;case"idiv":i=n.pop(),a=n.pop(),n.push(a/i|0);break;case"index":a=n.pop(),n.index(a);break;case"le":i=n.pop(),a=n.pop(),n.push(a<=i);break;case"ln":a=n.pop(),n.push(Math.log(a));break;case"log":a=n.pop(),n.push(Math.log(a)/Math.LN10);break;case"lt":i=n.pop(),a=n.pop(),n.push(a=t?new a(t):e.max<=t?e:new n(e,t)}function f(){}return e.prototype.visit=function(e){(0,r.unreachable)("abstract method")},t.prototype=Object.create(e.prototype),t.prototype.visit=function(e){e.visitArgument(this)},a.prototype=Object.create(e.prototype),a.prototype.visit=function(e){e.visitLiteral(this)},i.prototype=Object.create(e.prototype),i.prototype.visit=function(e){e.visitBinaryOperation(this)},n.prototype=Object.create(e.prototype),n.prototype.visit=function(e){e.visitMin(this)},s.prototype=Object.create(e.prototype),s.prototype.visit=function(e){e.visitVariable(this)},o.prototype=Object.create(e.prototype),o.prototype.visit=function(e){e.visitVariableDefinition(this)},c.prototype={visitArgument(e){this.parts.push("Math.max(",e.min,", Math.min(",e.max,", src[srcOffset + ",e.index,"]))")},visitVariable(e){this.parts.push("v",e.index)},visitLiteral(e){this.parts.push(e.number)},visitBinaryOperation(e){this.parts.push("("),e.arg1.visit(this),this.parts.push(" ",e.op," "),e.arg2.visit(this),this.parts.push(")")},visitVariableDefinition(e){this.parts.push("var "),e.variable.visit(this),this.parts.push(" = "),e.arg.visit(this),this.parts.push(";")},visitMin(e){this.parts.push("Math.min("),e.arg.visit(this),this.parts.push(", ",e.max,")")},toString(){return this.parts.join("")}},f.prototype={compile:function(e,r,i){var n,f,g,m,p,b,y,v,w,k,S=[],C=[],x=r.length>>1,A=i.length>>1,I=0;for(n=0;ne.min&&(s.unshift("Math.max(",r,", "),s.push(")")),n=0&&(t>=65&&t<=90||t>=97&&t<=122);)a.push(String.fromCharCode(t));const r=a.join("");switch(r.toLowerCase()){case"if":return o.IF;case"ifelse":return o.IFELSE;default:return o.getOperator(r)}}getNumber(){let e=this.currentChar;const t=this.strBuf;for(t.length=0,t[0]=String.fromCharCode(e);(e=this.nextChar())>=0&&(e>=48&&e<=57||45===e||46===e);)t.push(String.fromCharCode(e));const a=parseFloat(t.join(""));if(isNaN(a))throw new r.FormatError("Invalid floating point number: "+a);return a}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var r=a(2);t.MurmurHash3_64=class{constructor(e){this.h1=e?4294967295&e:3285377520,this.h2=e?4294967295&e:3285377520}update(e){let t,a;if((0,r.isString)(e)){t=new Uint8Array(2*e.length),a=0;for(let r=0,i=e.length;r>>8,t[a++]=255&i)}}else{if(!(0,r.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e,a=t.byteLength}const i=a>>2,n=a-4*i,s=new Uint32Array(t.buffer,0,i);let o=0,c=0,l=this.h1,h=this.h2;const u=3432918353,d=461845907;for(let e=0;e>>17,o=o*d&4294901760|13715*o&65535,l^=o,l=l<<13|l>>>19,l=5*l+3864292196):(c=s[e],c=c*u&4294901760|11601*c&65535,c=c<<15|c>>>17,c=c*d&4294901760|13715*c&65535,h^=c,h=h<<13|h>>>19,h=5*h+3864292196);switch(o=0,n){case 3:o^=t[4*i+2]<<16;case 2:o^=t[4*i+1]<<8;case 1:o^=t[4*i],o=o*u&4294901760|11601*o&65535,o=o<<15|o>>>17,o=o*d&4294901760|13715*o&65535,1&i?l^=o:h^=o}this.h1=l,this.h2=h}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1,e=3981806797*e&4294901760|36045*e&65535,t=4283543511*t&4294901760|(2950163797*(t<<16|e>>>16)&4294901760)>>>16,e^=t>>>1,e=444984403*e&4294901760|60499*e&65535,t=3301882366*t&4294901760|(3120437893*(t<<16|e>>>16)&4294901760)>>>16,e^=t>>>1;const a=(e>>>0).toString(16),r=(t>>>0).toString(16);return a.padStart(8,"0")+r.padStart(8,"0")}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.NativeImageDecoder=void 0;var r=a(22),i=a(17),n=a(11);class s{constructor({xref:e,resources:t,handler:a,forceDataSchema:r=!1,pdfFunctionFactory:i}){this.xref=e,this.resources=t,this.handler=a,this.forceDataSchema=r,this.pdfFunctionFactory=i}canDecode(e){return e instanceof i.JpegStream&&s.isDecodable(e,this.xref,this.resources,this.pdfFunctionFactory)&&e.maybeValidDimensions}decode(e){const t=e.dict;let a=t.get("ColorSpace","CS");return a=r.ColorSpace.parse(a,this.xref,this.resources,this.pdfFunctionFactory),this.handler.sendWithPromise("JpegDecode",[e.getIR(this.forceDataSchema),a.numComps]).then((function({data:e,width:a,height:r}){return new n.Stream(e,0,e.length,t)}))}static isSupported(e,t,a,i){const n=e.dict;if(n.has("DecodeParms")||n.has("DP"))return!1;const s=r.ColorSpace.parse(n.get("ColorSpace","CS"),t,a,i);return("DeviceGray"===s.name||"DeviceRGB"===s.name)&&s.isDefaultDecode(n.getArray("Decode","D"))}static isDecodable(e,t,a,i){const n=e.dict;if(n.has("DecodeParms")||n.has("DP"))return!1;const s=r.ColorSpace.parse(n.get("ColorSpace","CS"),t,a,i),o=n.get("BitsPerComponent","BPC")||1;return(1===s.numComps||3===s.numComps)&&s.isDefaultDecode(n.getArray("Decode","D"),o)}}t.NativeImageDecoder=s},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PDFImage=void 0;var r=a(2),i=a(4),n=a(22),s=a(11),o=a(17),c=a(20),l=function(){function e(e,t){return t&&t.canDecode(e)?t.decode(e).catch(t=>((0,r.warn)("Native image decoding failed -- trying to recover: "+(t&&t.message)),e)):Promise.resolve(e)}function t(e,t,a,r){return(e=t+e*a)<0?e=0:e>r&&(e=r),e}function a(e,t,a,r,i,n){var s=i*n;let o;o=t<=8?new Uint8Array(s):t<=16?new Uint16Array(s):new Uint32Array(s);var c,l,h,u,d=a/i,f=r/n,g=0,m=new Uint16Array(i),p=a;for(c=0;c0&&Number.isInteger(a.height)&&a.height>0&&(a.width!==p||a.height!==b)&&((0,r.warn)("PDFImage - using the Width/Height of the image data, rather than the image dictionary."),p=a.width,b=a.height),p<1||b<1)throw new r.FormatError(`Invalid image width: ${p} or height: ${b}`);this.width=p,this.height=b,this.interpolate=f.get("Interpolate","I")||!1,this.imageMask=f.get("ImageMask","IM")||!1,this.matte=f.get("Matte")||!1;var y=a.bitsPerComponent;if(!y&&!(y=f.get("BitsPerComponent","BPC"))){if(!this.imageMask)throw new r.FormatError("Bits per component missing in image: "+this.imageMask);y=1}if(this.bpc=y,!this.imageMask){var v=f.get("ColorSpace","CS");if(!v)switch((0,r.info)("JPX images (which do not require color spaces)"),a.numComps){case 1:v=i.Name.get("DeviceGray");break;case 3:v=i.Name.get("DeviceRGB");break;case 4:v=i.Name.get("DeviceCMYK");break;default:throw new Error(`JPX images with ${a.numComps} color components not supported.`)}const o=s?t:null;this.colorSpace=n.ColorSpace.parse(v,e,o,d),this.numComps=this.colorSpace.numComps}if(this.decode=f.getArray("Decode","D"),this.needsDecode=!1,this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode,y)||u&&!n.ColorSpace.isDefaultDecode(this.decode,1))){this.needsDecode=!0;var w=(1<>3)*a,c=e.byteLength;if(!r||i&&o!==c)if(i)for((n=new Uint8ClampedArray(o)).set(e),s=c;s>7&1,o[d+1]=l>>6&1,o[d+2]=l>>5&1,o[d+3]=l>>4&1,o[d+4]=l>>3&1,o[d+5]=l>>2&1,o[d+6]=l>>1&1,o[d+7]=1&l,d+=8;if(d>=1}else{var b=0;for(l=0,d=0,c=n;d>y;a<0?a=0:a>u&&(a=u),o[d]=a,l&=(1<m[w+1]){b=255;break}}o[u]=b}}if(o)for(u=0,f=3,d=t*n;u>3;if(!e){var f;if("DeviceGray"===this.colorSpace.name&&1===u?f=r.ImageKind.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==u||this.needsDecode||(f=r.ImageKind.RGB_24BPP),f&&!this.smask&&!this.mask&&a===l&&i===h){if(n.kind=f,t=this.getImageBytes(h*d),this.image instanceof s.DecodeStream)n.data=t;else{var g=new Uint8ClampedArray(t.length);g.set(t),n.data=g}if(this.needsDecode){(0,r.assert)(f===r.ImageKind.GRAYSCALE_1BPP,"PDFImage.createImageData: The image must be grayscale.");for(var m=n.data,p=0,b=m.length;p>3,l=this.getImageBytes(s*c),h=this.getComponents(l);if(1!==o){this.needsDecode&&this.decodeBuffer(h),i=n*s;var u=255/((1<{const t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream)return void this._processStreamMessage(t);if(t.callback){const e=t.callbackId,a=this.callbackCapabilities[e];if(!a)throw new Error("Cannot resolve callback "+e);if(delete this.callbackCapabilities[e],1===t.callback)a.resolve(t.data);else{if(2!==t.callback)throw new Error("Unexpected callback case");a.reject(i(t.reason))}return}const r=this.actionHandler[t.action];if(!r)throw new Error("Unknown action from worker: "+t.action);if(t.callbackId){const e=this.sourceName,n=t.sourceName;new Promise((function(e){e(r(t.data))})).then((function(r){a.postMessage({sourceName:e,targetName:n,callback:1,callbackId:t.callbackId,data:r})}),(function(r){a.postMessage({sourceName:e,targetName:n,callback:2,callbackId:t.callbackId,reason:i(r)})}))}else t.streamId?this._createStreamSink(t):r(t.data)},a.addEventListener("message",this._onComObjOnMessage)}on(e,t){const a=this.actionHandler;if(a[e])throw new Error(`There is already an actionName called "${e}"`);a[e]=t}send(e,t,a){this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},a)}sendWithPromise(e,t,a){const i=this.callbackId++,n=(0,r.createPromiseCapability)();this.callbackCapabilities[i]=n;try{this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},a)}catch(e){n.reject(e)}return n.promise}sendWithStream(e,t,a,n){const s=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:a=>{const i=(0,r.createPromiseCapability)();return this.streamControllers[s]={controller:a,startCall:i,pullCall:null,cancelCall:null,isClosed:!1},this._postMessage({sourceName:o,targetName:c,action:e,streamId:s,data:t,desiredSize:a.desiredSize},n),i.promise},pull:e=>{const t=(0,r.createPromiseCapability)();return this.streamControllers[s].pullCall=t,l.postMessage({sourceName:o,targetName:c,stream:6,streamId:s,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,r.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,r.createPromiseCapability)();return this.streamControllers[s].cancelCall=t,this.streamControllers[s].isClosed=!0,l.postMessage({sourceName:o,targetName:c,stream:1,streamId:s,reason:i(e)}),t.promise}},a)}_createStreamSink(e){const t=this,a=this.actionHandler[e.action],n=e.streamId,s=this.sourceName,o=e.sourceName,c=this.comObj,l={enqueue(e,a=1,i){if(this.isCancelled)return;const c=this.desiredSize;this.desiredSize-=a,c>0&&this.desiredSize<=0&&(this.sinkCapability=(0,r.createPromiseCapability)(),this.ready=this.sinkCapability.promise),t._postMessage({sourceName:s,targetName:o,stream:4,streamId:n,chunk:e},i)},close(){this.isCancelled||(this.isCancelled=!0,c.postMessage({sourceName:s,targetName:o,stream:3,streamId:n}),delete t.streamSinks[n])},error(e){(0,r.assert)(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,c.postMessage({sourceName:s,targetName:o,stream:5,streamId:n,reason:i(e)}))},sinkCapability:(0,r.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[n]=l,new Promise((function(t){t(a(e.data,l))})).then((function(){c.postMessage({sourceName:s,targetName:o,stream:8,streamId:n,success:!0})}),(function(e){c.postMessage({sourceName:s,targetName:o,stream:8,streamId:n,reason:i(e)})}))}_processStreamMessage(e){const t=e.streamId,a=this.sourceName,n=e.sourceName,s=this.comObj;switch(e.stream){case 8:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(i(e.reason));break;case 7:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(i(e.reason));break;case 6:if(!this.streamSinks[t]){s.postMessage({sourceName:a,targetName:n,stream:7,streamId:t,success:!0});break}this.streamSinks[t].desiredSize<=0&&e.desiredSize>0&&this.streamSinks[t].sinkCapability.resolve(),this.streamSinks[t].desiredSize=e.desiredSize;const{onPull:o}=this.streamSinks[e.streamId];new Promise((function(e){e(o&&o())})).then((function(){s.postMessage({sourceName:a,targetName:n,stream:7,streamId:t,success:!0})}),(function(e){s.postMessage({sourceName:a,targetName:n,stream:7,streamId:t,reason:i(e)})}));break;case 4:if((0,r.assert)(this.streamControllers[t],"enqueue should have stream controller"),this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case 3:if((0,r.assert)(this.streamControllers[t],"close should have stream controller"),this.streamControllers[t].isClosed)break;this.streamControllers[t].isClosed=!0,this.streamControllers[t].controller.close(),this._deleteStreamController(t);break;case 5:(0,r.assert)(this.streamControllers[t],"error should have stream controller"),this.streamControllers[t].controller.error(i(e.reason)),this._deleteStreamController(t);break;case 2:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(i(e.reason)),this._deleteStreamController(t);break;case 1:if(!this.streamSinks[t])break;const{onCancel:c}=this.streamSinks[e.streamId];new Promise((function(t){t(c&&c(i(e.reason)))})).then((function(){s.postMessage({sourceName:a,targetName:n,stream:2,streamId:t,success:!0})}),(function(e){s.postMessage({sourceName:a,targetName:n,stream:2,streamId:t,reason:i(e)})})),this.streamSinks[t].sinkCapability.reject(i(e.reason)),this.streamSinks[t].isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(e){await Promise.allSettled([this.streamControllers[e].startCall,this.streamControllers[e].pullCall,this.streamControllers[e].cancelCall].map((function(e){return e&&e.promise}))),delete this.streamControllers[e]}_postMessage(e,t){t&&this.postMessageTransfers?this.comObj.postMessage(e,t):this.comObj.postMessage(e)}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PDFWorkerStream=void 0;var r=a(2);t.PDFWorkerStream=class{constructor(e){this._msgHandler=e,this._contentLength=null,this._fullRequestReader=null,this._rangeRequestReaders=[]}getFullReader(){return(0,r.assert)(!this._fullRequestReader),this._fullRequestReader=new i(this._msgHandler),this._fullRequestReader}getRangeReader(e,t){const a=new n(e,t,this._msgHandler);return this._rangeRequestReaders.push(a),a}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e),this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class i{constructor(e){this._msgHandler=e,this.onProgress=null,this._contentLength=null,this._isRangeSupported=!1,this._isStreamingSupported=!1;const t=this._msgHandler.sendWithStream("GetReader");this._reader=t.getReader(),this._headersReady=this._msgHandler.sendWithPromise("ReaderHeadersReady").then(e=>{this._isStreamingSupported=e.isStreamingSupported,this._isRangeSupported=e.isRangeSupported,this._contentLength=e.contentLength})}get headersReady(){return this._headersReady}get contentLength(){return this._contentLength}get isStreamingSupported(){return this._isStreamingSupported}get isRangeSupported(){return this._isRangeSupported}async read(){const{value:e,done:t}=await this._reader.read();return t?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}class n{constructor(e,t,a){this._msgHandler=a,this.onProgress=null;const r=this._msgHandler.sendWithStream("GetRangeReader",{begin:e,end:t});this._reader=r.getReader()}get isStreamingSupported(){return!1}async read(){const{value:e,done:t}=await this._reader.read();return t?{value:void 0,done:!0}:{value:e.buffer,done:!1}}cancel(e){this._reader.cancel(e)}}}])}));