From 9547b55a9a7d392621ba590419ceab38dab9cc18 Mon Sep 17 00:00:00 2001 From: anupritaisno1 Date: Tue, 22 Sep 2020 06:05:04 +0000 Subject: [PATCH] update pdf.js to 2.5.207 release Signed-off-by: anupritaisno1 --- app/src/main/assets/pdf.js | 2 +- app/src/main/assets/pdf.worker.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/assets/pdf.js b/app/src/main/assets/pdf.js index c1087ef..c095278 100644 --- a/app/src/main/assets/pdf.js +++ b/app/src/main/assets/pdf.js @@ -19,4 +19,4 @@ * @licend The above is the entire license notice for the * Javascript code in this page */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=t():e["pdfjs-dist/build/pdf"]=e.pdfjsLib=t()}(this,(function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(s,n,function(t){return e[t]}.bind(null,n));return s},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";var s=r(1),n=r(3),i=r(16),a=r(17),o=r(4),l=r(18);const c=r(10),h=r(6);{const{isNodeJS:e}=r(7);if(e){const e=r(19).PDFNodeStream;n.setPDFNetworkStreamFactory(t=>new e(t))}else{const e=r(22).PDFNetworkStream;let t;o.isFetchSupported()&&(t=r(23).PDFFetchStream),n.setPDFNetworkStreamFactory(r=>t&&o.isValidFetchUrl(r.url)?new t(r):new e(r))}}t.build=n.build,t.version=n.version,t.getDocument=n.getDocument,t.LoopbackPort=n.LoopbackPort,t.PDFDataRangeTransport=n.PDFDataRangeTransport,t.PDFWorker=n.PDFWorker,t.renderTextLayer=i.renderTextLayer,t.AnnotationLayer=a.AnnotationLayer,t.createPromiseCapability=s.createPromiseCapability,t.PasswordResponses=s.PasswordResponses,t.InvalidPDFException=s.InvalidPDFException,t.MissingPDFException=s.MissingPDFException,t.SVGGraphics=l.SVGGraphics,t.NativeImageDecoding=s.NativeImageDecoding,t.CMapCompressionType=s.CMapCompressionType,t.PermissionFlag=s.PermissionFlag,t.UnexpectedResponseException=s.UnexpectedResponseException,t.OPS=s.OPS,t.VerbosityLevel=s.VerbosityLevel,t.UNSUPPORTED_FEATURES=s.UNSUPPORTED_FEATURES,t.createValidAbsoluteUrl=s.createValidAbsoluteUrl,t.createObjectURL=s.createObjectURL,t.removeNullCharacters=s.removeNullCharacters,t.shadow=s.shadow,t.Util=s.Util,t.RenderingCancelledException=o.RenderingCancelledException,t.getFilenameFromUrl=o.getFilenameFromUrl,t.LinkTarget=o.LinkTarget,t.addLinkAttributes=o.addLinkAttributes,t.loadScript=o.loadScript,t.PDFDateString=o.PDFDateString,t.GlobalWorkerOptions=c.GlobalWorkerOptions,t.apiCompatibilityParams=h.apiCompatibilityParams},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.arrayByteLength=u,t.arraysToBytes=function(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let s=0;st}),e.promise=new Promise((function(r,s){e.resolve=function(e){t=!0,r(e)},e.reject=function(e){t=!0,s(e)}})),e},t.getVerbosityLevel=function(){return n},t.info=function(e){n>=s.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength},t.isArrayEqual=function(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))},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 r;try{if(r=new URL(e),!r.origin||"null"===r.origin)return!1}catch(e){return!1}const s=new URL(t,r);return r.origin===s.origin},t.createValidAbsoluteUrl=function(e,t){if(!e)return null;try{const r=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}}(r))return r}catch(e){}return null},t.removeNullCharacters=function(e){if("string"!=typeof e)return i("The argument for removeNullCharacters must be a string."),e;return e.replace(h,"")},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(n=e)},t.shadow=l,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=d,t.stringToPDFString=function(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let s=2;s=s.WARNINGS&&console.log(`Warning: ${e}`)}function a(e){throw new Error(e)}function o(e,t){e||a(t)}function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1}),r}const c=function(){function e(t){this.constructor===e&&a("Cannot initialize BaseException."),this.message=t,this.name=this.constructor.name}return e.prototype=new Error,e.constructor=e,e}();t.BaseException=c;t.PasswordException=class extends c{constructor(e,t){super(e),this.code=t}};t.UnknownErrorException=class extends c{constructor(e,t){super(e),this.details=t}};t.InvalidPDFException=class extends c{};t.MissingPDFException=class extends c{};t.UnexpectedResponseException=class extends c{constructor(e,t){super(e),this.status=t}};t.FormatError=class extends c{};t.AbortException=class extends c{};const h=/\x00/g;function d(e){o("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let s=0;se[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 r(e,t){return e-t}const s=[e[0],e[2],t[0],t[2]].sort(r),n=[e[1],e[3],t[1],t[3]].sort(r),i=[];return e=m.normalizeRect(e),t=m.normalizeRect(t),s[0]===e[0]&&s[1]===t[0]||s[0]===t[0]&&s[1]===e[0]?(i[0]=s[1],i[2]=s[2],n[0]===e[1]&&n[1]===t[1]||n[0]===t[1]&&n[1]===e[1]?(i[1]=n[1],i[3]=n[2],i):null):null}}t.Util=m;const A=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];const b=function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function(t,r,s=!1){if(!s&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let n=`data:${r};base64,`;for(let r=0,s=t.length;r>2]+e[(3&i)<<4|a>>4]+e[r+1>6:64]+e[r+2{this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)})}then(e,t){throw new Error("Removed API method: PDFDocumentLoadingTask.then, use the `promise` getter instead.")}}}();class PDFDataRangeTransport{constructor(e,t,r=!1){this.length=e,this.initialData=t,this.progressiveDone=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const r of this._rangeListeners)r(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(const r of this._progressListeners)r(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e,this._transport=t}get numPages(){return this._pdfInfo.numPages}get fingerprint(){return this._pdfInfo.fingerprint}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getOpenActionDestination(){return(0,_display_utils.deprecated)("getOpenActionDestination, use getOpenAction instead."),this.getOpenAction().then((function(e){return e&&e.dest?e.dest:null}))}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getOutline(){return this._transport.getOutline()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getStats(){return this._transport.getStats()}cleanup(){return this._transport.startCleanup()}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(e,t,r,s=!1){this._pageIndex=e,this._pageInfo=t,this._transport=r,this._stats=s?new _display_utils.StatTimer:null,this._pdfBug=s,this.commonObjs=r.commonObjs,this.objs=new PDFObjects,this.cleanupAfterRender=!1,this.pendingCleanup=!1,this.intentStates=Object.create(null),this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:r=0,offsetY:s=0,dontFlip:n=!1}={}){if(arguments.length>1||"number"==typeof arguments[0])throw new Error("PDFPageProxy.getViewport is called with obsolete arguments.");return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:r,offsetY:s,dontFlip:n})}getAnnotations({intent:e=null}={}){return this.annotationsPromise&&this.annotationsIntent===e||(this.annotationsPromise=this._transport.getAnnotations(this._pageIndex,e),this.annotationsIntent=e),this.annotationsPromise}render({canvasContext:e,viewport:t,intent:r="display",enableWebGL:s=!1,renderInteractiveForms:n=!1,transform:i=null,imageLayer:a=null,canvasFactory:o=null,background:l=null}){this._stats&&this._stats.time("Overall");const c="print"===r?"print":"display";this.pendingCleanup=!1,this.intentStates[c]||(this.intentStates[c]=Object.create(null));const h=this.intentStates[c];h.streamReaderCancelTimeout&&(clearTimeout(h.streamReaderCancelTimeout),h.streamReaderCancelTimeout=null);const d=o||new _display_utils.DOMCanvasFactory,u=new _webgl.WebGLContext({enable:s});h.displayReadyCapability||(h.displayReadyCapability=(0,_util.createPromiseCapability)(),h.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList({pageIndex:this._pageIndex,intent:c,renderInteractiveForms:!0===n}));const p=e=>{const t=h.renderTasks.indexOf(g);t>=0&&h.renderTasks.splice(t,1),(this.cleanupAfterRender||"print"===c)&&(this.pendingCleanup=!0),this._tryCleanup(),e?(g.capability.reject(e),this._abortOperatorList({intentState:h,reason:e})):g.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"))},g=new InternalRenderTask({callback:p,params:{canvasContext:e,viewport:t,transform:i,imageLayer:a,background:l},objs:this.objs,commonObjs:this.commonObjs,operatorList:h.operatorList,pageIndex:this._pageIndex,canvasFactory:d,webGLContext:u,useRequestAnimationFrame:"print"!==c,pdfBug:this._pdfBug});h.renderTasks||(h.renderTasks=[]),h.renderTasks.push(g);const f=g.task;return h.displayReadyCapability.promise.then(e=>{this.pendingCleanup?p():(this._stats&&this._stats.time("Rendering"),g.initializeGraphics(e),g.operatorListChanged())}).catch(p),f}getOperatorList(){this.intentStates.oplist||(this.intentStates.oplist=Object.create(null));const e=this.intentStates.oplist;let t;return e.opListReadCapability||(t={},t.operatorListChanged=function(){if(e.operatorList.lastChunk){e.opListReadCapability.resolve(e.operatorList);const r=e.renderTasks.indexOf(t);r>=0&&e.renderTasks.splice(r,1)}},e.opListReadCapability=(0,_util.createPromiseCapability)(),e.renderTasks=[],e.renderTasks.push(t),e.operatorList={fnArray:[],argsArray:[],lastChunk:!1},this._stats&&this._stats.time("Page Request"),this._pumpOperatorList({pageIndex:this._pageIndex,intent:"oplist"})),e.opListReadCapability.promise}streamTextContent({normalizeWhitespace:e=!1,disableCombineTextItems:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,normalizeWhitespace:!0===e,combineTextItems:!0!==t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){const t=this.streamTextContent(e);return new Promise((function(e,r){const s=t.getReader(),n={items:[],styles:Object.create(null)};!function t(){s.read().then((function({value:r,done:s}){s?e(n):(Object.assign(n.styles,r.styles),n.items.push(...r.items),t())}),r)}()}))}_destroy(){this.destroyed=!0,this._transport.pageCache[this._pageIndex]=null;const e=[];return Object.keys(this.intentStates).forEach(t=>{const r=this.intentStates[t];this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0}),"oplist"!==t&&r.renderTasks.forEach((function(t){const r=t.capability.promise.catch((function(){}));e.push(r),t.cancel()}))}),this.objs.clear(),this.annotationsPromise=null,this.pendingCleanup=!1,Promise.all(e)}cleanup(e=!1){return this.pendingCleanup=!0,this._tryCleanup(e)}_tryCleanup(e=!1){return!(!this.pendingCleanup||Object.keys(this.intentStates).some(e=>{const t=this.intentStates[e];return 0!==t.renderTasks.length||!t.operatorList.lastChunk}))&&(Object.keys(this.intentStates).forEach(e=>{delete this.intentStates[e]}),this.objs.clear(),this.annotationsPromise=null,e&&this._stats&&(this._stats=new _display_utils.StatTimer),this.pendingCleanup=!1,!0)}_startRenderPage(e,t){const r=this.intentStates[t];r&&(this._stats&&this._stats.timeEnd("Page Request"),r.displayReadyCapability&&r.displayReadyCapability.resolve(e))}_renderPageChunk(e,t){for(let r=0,s=e.length;r{t.read().then(({value:e,done:t})=>{t?r.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,r),s())},e=>{if(r.streamReader=null,!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(let e=0;e{this._abortOperatorList({intentState:e,reason:t,force:!0}),e.streamReaderCancelTimeout=null},RENDERING_CANCELLED_TIMEOUT))}e.streamReader.cancel(new _util.AbortException(t&&t.message)),e.streamReader=null,this._transport.destroyed||(Object.keys(this.intentStates).some(t=>this.intentStates[t]===e&&(delete this.intentStates[t],!0)),this.cleanup())}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(e=!0){this._listeners=[],this._defer=e,this._deferred=Promise.resolve(void 0)}postMessage(e,t){if(!this._defer)return void this._listeners.forEach(t=>{t.call(this,{data:e})});const r=new WeakMap,s={data:function e(s){if("object"!=typeof s||null===s)return s;if(r.has(s))return r.get(s);let n,i;if((n=s.buffer)&&(0,_util.isArrayBuffer)(n)){return i=t&&t.includes(n)?new s.constructor(n,s.byteOffset,s.byteLength):new s.constructor(s),r.set(s,i),i}i=Array.isArray(s)?[]:{},r.set(s,i);for(const t in s){let r,n=s;for(;!(r=Object.getOwnPropertyDescriptor(n,t));)n=Object.getPrototypeOf(n);if(void 0!==r.value)if("function"!=typeof r.value)i[t]=e(r.value);else if(s.hasOwnProperty&&s.hasOwnProperty(t))throw new Error(`LoopbackPort.postMessage - cannot clone: ${s[t]}`)}return i}(e)};this._deferred.then(()=>{this._listeners.forEach(e=>{e.call(this,s)})})}addEventListener(e,t){this._listeners.push(t)}removeEventListener(e,t){const r=this._listeners.indexOf(t);this._listeners.splice(r,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorker=function PDFWorkerClosure(){const pdfWorkerPorts=new WeakMap;let isWorkerDisabled=!1,fallbackWorkerSrc,nextFakeWorkerId=0,fakeWorkerCapability;if(_is_node.isNodeJS&&"function"==typeof require)isWorkerDisabled=!0,fallbackWorkerSrc="./pdf.worker.js";else if("object"==typeof document&&"currentScript"in document){const e=document.currentScript&&document.currentScript.src;e&&(fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}function getWorkerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(void 0!==fallbackWorkerSrc)return _is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),fallbackWorkerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}function getMainThreadWorkerMessageHandler(){let e;try{e=globalThis.pdfjsWorker&&globalThis.pdfjsWorker.WorkerMessageHandler}catch(e){}return e||null}function setupFakeWorkerGlobal(){if(fakeWorkerCapability)return fakeWorkerCapability.promise;fakeWorkerCapability=(0,_util.createPromiseCapability)();const loader=async function(){const mainWorkerMessageHandler=getMainThreadWorkerMessageHandler();if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof require){const worker=eval("require")(getWorkerSrc());return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(getWorkerSrc()),window.pdfjsWorker.WorkerMessageHandler};return loader().then(fakeWorkerCapability.resolve,fakeWorkerCapability.reject),fakeWorkerCapability.promise}function createCDNWrapper(e){const t="importScripts('"+e+"');";return URL.createObjectURL(new Blob([t]))}class PDFWorker{constructor({name:e=null,port:t=null,verbosity:r=(0,_util.getVerbosityLevel)()}={}){if(t&&pdfWorkerPorts.has(t))throw new Error("Cannot use more than one PDFWorker per port");if(this.name=e,this.destroyed=!1,this.postMessageTransfers=!0,this.verbosity=r,this._readyCapability=(0,_util.createPromiseCapability)(),this._port=null,this._webWorker=null,this._messageHandler=null,t)return pdfWorkerPorts.set(t,this),void this._initializeFromPort(t);this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new _message_handler.MessageHandler("main","worker",e),this._messageHandler.on("ready",(function(){})),this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!isWorkerDisabled&&!getMainThreadWorkerMessageHandler()){let e=getWorkerSrc();try{(0,_util.isSameOrigin)(window.location.href,e)||(e=createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e),r=new _message_handler.MessageHandler("main","worker",t),s=()=>{t.removeEventListener("error",n),r.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=()=>{this._webWorker||s()};t.addEventListener("error",n),r.on("test",e=>{t.removeEventListener("error",n),this.destroyed?s():e?(this._messageHandler=r,this._port=t,this._webWorker=t,e.supportTransfers||(this.postMessageTransfers=!1),this._readyCapability.resolve(),r.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),r.destroy(),t.terminate())}),r.on("ready",e=>{if(t.removeEventListener("error",n),this.destroyed)s();else try{i()}catch(e){this._setupFakeWorker()}});const i=()=>{const e=new Uint8Array([this.postMessageTransfers?255:0]);try{r.send("test",e,[e.buffer])}catch(t){(0,_util.warn)("Cannot use postMessage transfers."),e[0]=0,r.send("test",e)}};return void i()}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),isWorkerDisabled=!0),setupFakeWorkerGlobal().then(e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const t=new LoopbackPort;this._port=t;const r="fake"+nextFakeWorkerId++,s=new _message_handler.MessageHandler(r+"_worker",r,t);e.setup(s,t);const n=new _message_handler.MessageHandler(r,r+"_worker",t);this._messageHandler=n,this._readyCapability.resolve(),n.send("configure",{verbosity:this.verbosity})}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),pdfWorkerPorts.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(!e||!e.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return pdfWorkerPorts.has(e.port)?pdfWorkerPorts.get(e.port):new PDFWorker(e)}static getWorkerSrc(){return getWorkerSrc()}}return PDFWorker}();exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,r,s){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new PDFObjects,this.fontLoader=new _font_loader.FontLoader({docId:t.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this)}),this._params=s,this.CMapReaderFactory=new s.CMapReaderFactory({baseUrl:s.cMapUrl,isCompressed:s.cMapPacked}),this.destroyed=!1,this.destroyCapability=null,this._passwordCapability=null,this._networkStream=r,this._fullReader=null,this._lastProgress=null,this.pageCache=[],this.pagePromises=[],this.downloadInfoCapability=(0,_util.createPromiseCapability)(),this.setupMessageHandler()}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=(0,_util.createPromiseCapability)(),this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];this.pageCache.forEach((function(t){t&&e.push(t._destroy())})),this.pageCache.length=0,this.pagePromises.length=0;const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.fontLoader.clear(),this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{(0,_util.assert)(this._networkStream),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:r}){r?t.close():((0,_util.assert)((0,_util.isArrayBuffer)(e)),t.enqueue(new Uint8Array(e),1,[e]))})).catch(e=>{t.error(e)})},t.onCancel=e=>{this._fullReader.cancel(e)}}),e.on("ReaderHeadersReady",e=>{const r=(0,_util.createPromiseCapability)(),s=this._fullReader;return s.headersReady.then(()=>{s.isStreamingSupported&&s.isRangeSupported||(this._lastProgress&&t.onProgress&&t.onProgress(this._lastProgress),s.onProgress=e=>{t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})}),r.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})},r.reject),r.promise}),e.on("GetRangeReader",(e,t)=>{(0,_util.assert)(this._networkStream);const r=this._networkStream.getRangeReader(e.begin,e.end);r?(t.onPull=()=>{r.read().then((function({value:e,done:r}){r?t.close():((0,_util.assert)((0,_util.isArrayBuffer)(e)),t.enqueue(new Uint8Array(e),1,[e]))})).catch(e=>{t.error(e)})},t.onCancel=e=>{r.cancel(e)}):t.close()}),e.on("GetDoc",({pdfInfo:e})=>{this._numPages=e.numPages,t._capability.resolve(new PDFDocumentProxy(e,this))}),e.on("DocException",(function(e){let r;switch(e.name){case"PasswordException":r=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":r=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":r=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":r=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":r=new _util.UnknownErrorException(e.message,e.details)}t._capability.reject(r)})),e.on("PasswordRequest",e=>{if(this._passwordCapability=(0,_util.createPromiseCapability)(),t.onPassword){const r=e=>{this._passwordCapability.resolve({password:e})};try{t.onPassword(r,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise}),e.on("DataLoaded",e=>{t.onProgress&&t.onProgress({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on("StartRenderPage",e=>{if(this.destroyed)return;this.pageCache[e.pageIndex]._startRenderPage(e.transparency,e.intent)}),e.on("commonobj",t=>{if(this.destroyed)return;const[r,s,n]=t;if(!this.commonObjs.has(r))switch(s){case"Font":const t=this._params;if("error"in n){const e=n.error;(0,_util.warn)(`Error during font loading: ${e}`),this.commonObjs.resolve(r,e);break}let i=null;t.pdfBug&&globalThis.FontInspector&&globalThis.FontInspector.enabled&&(i={registerFont(e,t){globalThis.FontInspector.fontAdded(e,t)}});const a=new _font_loader.FontFaceObject(n,{isEvalSupported:t.isEvalSupported,disableFontFace:t.disableFontFace,ignoreErrors:t.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:i});this.fontLoader.bind(a).then(()=>{this.commonObjs.resolve(r,a)},t=>{e.sendWithPromise("FontFallback",{id:r}).finally(()=>{this.commonObjs.resolve(r,a)})});break;case"FontPath":case"FontType3Res":this.commonObjs.resolve(r,n);break;default:throw new Error(`Got unknown common object type ${s}`)}}),e.on("obj",e=>{if(this.destroyed)return;const[t,r,s,n]=e,i=this.pageCache[r];if(!i.objs.has(t))switch(s){case"JpegStream":return new Promise((e,t)=>{const r=new Image;r.onload=function(){e(r)},r.onerror=function(){t(new Error("Error during JPEG image loading")),(0,_display_utils.releaseImageResources)(r)},r.src=n}).then(e=>{i.objs.resolve(t,e)});case"Image":i.objs.resolve(t,n);const e=8e6;n&&"data"in n&&n.data.length>e&&(i.cleanupAfterRender=!0);break;default:throw new Error(`Got unknown object type ${s}`)}}),e.on("DocProgress",e=>{this.destroyed||t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})}),e.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this)),e.on("JpegDecode",e=>{if(this.destroyed)return Promise.reject(new Error("Worker was destroyed"));if("undefined"==typeof document)return Promise.reject(new Error('"document" is not defined.'));const[t,r]=e;return 3!==r&&1!==r?Promise.reject(new Error("Only 3 components or 1 component can be returned")):new Promise((function(e,s){const n=new Image;n.onload=function(){const{width:t,height:s}=n,i=t*s,a=4*i,o=new Uint8ClampedArray(i*r);let l=document.createElement("canvas");l.width=t,l.height=s;let c=l.getContext("2d");c.drawImage(n,0,0);const h=c.getImageData(0,0,t,s).data;if(3===r)for(let e=0,t=0;e{if(this.destroyed)return void t.error(new Error("Worker was destroyed"));let r=!1;t.onPull=()=>{r?t.close():(r=!0,this.CMapReaderFactory.fetch(e).then((function(e){t.enqueue(e,1,[e.cMapData.buffer])})).catch((function(e){t.error(e)})))}})}_onUnsupportedFeature({featureId:e}){this.destroyed||this.loadingTask.onUnsupportedFeature&&this.loadingTask.onUnsupportedFeature(e)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request"));const t=e-1;if(t in this.pagePromises)return this.pagePromises[t];const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(e=>{if(this.destroyed)throw new Error("Transport destroyed");const r=new PDFPageProxy(t,e,this,this._params.pdfBug);return this.pageCache[t]=r,r});return this.pagePromises[t]=r,r}getPageIndex(e){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:e}).catch((function(e){return Promise.reject(new Error(e))}))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.messageHandler.sendWithPromise("GetMetadata",null).then(e=>({info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:this._fullReader?this._fullReader.filename:null}))}getStats(){return this.messageHandler.sendWithPromise("GetStats",null)}startCleanup(){return this.messageHandler.sendWithPromise("Cleanup",null).then(()=>{for(let e=0,t=this.pageCache.length;e{this._nextBound().catch(this.cancel.bind(this))}):Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this))}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),this._canvas&&e.delete(this._canvas),this.callback())))}}}(),version="2.4.456";exports.version=version;const build="228a591c";exports.build=build},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addLinkAttributes=function(e,{url:t,target:r,rel:n,enabled:i=!0}={}){(0,s.assert)(t&&"string"==typeof t,'addLinkAttributes: A valid "url" parameter must provided.');const a=(0,s.removeNullCharacters)(t);i?e.href=e.title=a:(e.href="",e.title=`Disabled: ${a}`,e.onclick=()=>!1);let l="";switch(r){case o.NONE:break;case o.SELF:l="_self";break;case o.BLANK:l="_blank";break;case o.PARENT:l="_parent";break;case o.TOP:l="_top"}e.target=l,e.rel="string"==typeof n?n:"noopener noreferrer nofollow"},t.getFilenameFromUrl=function(e){const t=e.indexOf("#"),r=e.indexOf("?"),s=Math.min(t>0?t:e.length,r>0?r:e.length);return e.substring(e.lastIndexOf("/",s)+1,s)},t.isFetchSupported=l,t.isValidFetchUrl=c,t.loadScript=function(e){return new Promise((t,r)=>{const s=document.createElement("script");s.src=e,s.onload=t,s.onerror=function(){r(new Error(`Cannot load script at: ${s.src}`))},(document.head||document.documentElement).appendChild(s)})},t.deprecated=function(e){console.log("Deprecated API usage: "+e)},t.releaseImageResources=function(e){(0,s.assert)(e instanceof Image,"Invalid `img` parameter.");const t=e.src;"string"==typeof t&&t.startsWith("blob:")&&URL.revokeObjectURL&&URL.revokeObjectURL(t);e.removeAttribute("src")},t.PDFDateString=t.StatTimer=t.DOMSVGFactory=t.DOMCMapReaderFactory=t.DOMCanvasFactory=t.DEFAULT_LINK_REL=t.LinkTarget=t.RenderingCancelledException=t.PageViewport=void 0;var s=r(1);t.DEFAULT_LINK_REL="noopener noreferrer nofollow";const n="http://www.w3.org/2000/svg";t.DOMCanvasFactory=class{create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const r=document.createElement("canvas"),s=r.getContext("2d");return r.width=e,r.height=t,{canvas:r,context:s}}reset(e,t,r){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}};t.DOMCMapReaderFactory=class{constructor({baseUrl:e=null,isCompressed:t=!1}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":""),r=this.isCompressed?s.CMapCompressionType.BINARY:s.CMapCompressionType.NONE;return l()&&c(t,document.baseURI)?fetch(t).then(async e=>{if(!e.ok)throw new Error(e.statusText);let t;return t=this.isCompressed?new Uint8Array(await e.arrayBuffer()):(0,s.stringToBytes)(await e.text()),{cMapData:t,compressionType:r}}).catch(e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}`+`CMap at: ${t}`)}):new Promise((e,n)=>{const i=new XMLHttpRequest;i.open("GET",t,!0),this.isCompressed&&(i.responseType="arraybuffer"),i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(200===i.status||0===i.status){let t;if(this.isCompressed&&i.response?t=new Uint8Array(i.response):!this.isCompressed&&i.responseText&&(t=(0,s.stringToBytes)(i.responseText)),t)return void e({cMapData:t,compressionType:r})}n(new Error(i.statusText))}},i.send(null)}).catch(e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}`+`CMap at: ${t}`)})}};t.DOMSVGFactory=class{create(e,t){(0,s.assert)(e>0&&t>0,"Invalid SVG dimensions");const r=document.createElementNS(n,"svg:svg");return r.setAttribute("version","1.1"),r.setAttribute("width",e+"px"),r.setAttribute("height",t+"px"),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox","0 0 "+e+" "+t),r}createElement(e){return(0,s.assert)("string"==typeof e,"Invalid SVG element type"),document.createElementNS(n,e)}};class i{constructor({viewBox:e,scale:t,rotation:r,offsetX:s=0,offsetY:n=0,dontFlip:i=!1}){this.viewBox=e,this.scale=t,this.rotation=r,this.offsetX=s,this.offsetY=n;const a=(e[2]+e[0])/2,o=(e[3]+e[1])/2;let l,c,h,d,u,p,g,f;switch(r=(r%=360)<0?r+360:r){case 180:l=-1,c=0,h=0,d=1;break;case 90:l=0,c=1,h=1,d=0;break;case 270:l=0,c=-1,h=-1,d=0;break;default:l=1,c=0,h=0,d=-1}i&&(h=-h,d=-d),0===l?(u=Math.abs(o-e[1])*t+s,p=Math.abs(a-e[0])*t+n,g=Math.abs(e[3]-e[1])*t,f=Math.abs(e[2]-e[0])*t):(u=Math.abs(a-e[0])*t+s,p=Math.abs(o-e[1])*t+n,g=Math.abs(e[2]-e[0])*t,f=Math.abs(e[3]-e[1])*t),this.transform=[l*t,c*t,h*t,d*t,u-l*t*a-h*t*o,p-c*t*a-d*t*o],this.width=g,this.height=f}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:r=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new i({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:r,offsetY:s,dontFlip:n})}convertToViewportPoint(e,t){return s.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=s.Util.applyTransform([e[0],e[1]],this.transform),r=s.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],r[0],r[1]]}convertToPdfPoint(e,t){return s.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=i;class a extends s.BaseException{constructor(e,t){super(e),this.type=t}}t.RenderingCancelledException=a;const o={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};t.LinkTarget=o;function l(){return"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&"undefined"!=typeof ReadableStream}function c(e,t){try{const{protocol:r}=t?new URL(e,t):new URL(e);return"http:"===r||"https:"===r}catch(e){return!1}}let h;t.StatTimer=class{constructor(){this.started=Object.create(null),this.times=[]}time(e){e in this.started&&(0,s.warn)(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,s.warn)(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let t=0;for(const e of this.times){const r=e.name;r.length>t&&(t=r.length)}for(const r of this.times){const s=r.end-r.start;e.push(`${r.name.padEnd(t)} ${s}ms\n`)}return e.join("")}};t.PDFDateString=class{static toDateObject(e){if(!e||!(0,s.isString)(e))return null;h||(h=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const t=h.exec(e);if(!t)return null;const r=parseInt(t[1],10);let n=parseInt(t[2],10);n=n>=1&&n<=12?n-1:0;let i=parseInt(t[3],10);i=i>=1&&i<=31?i:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const c=t[7]||"Z";let d=parseInt(t[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(t[9],10)||0;return u=u>=0&&u<=59?u:0,"-"===c?(a+=d,o+=u):"+"===c&&(a-=d,o-=u),new Date(Date.UTC(r,n,i,a,o,l))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.FontLoader=t.FontFaceObject=void 0;var s=r(1);class n{constructor({docId:e,onUnsupportedFeature:t}){this.constructor===n&&(0,s.unreachable)("Cannot initialize BaseFontLoader."),this.docId=e,this._onUnsupportedFeature=t,this.nativeFontFaces=[],this.styleElement=null}addNativeFontFace(e){this.nativeFontFaces.push(e),document.fonts.add(e)}insertRule(e){let t=this.styleElement;t||(t=this.styleElement=document.createElement("style"),t.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`,document.documentElement.getElementsByTagName("head")[0].appendChild(t));const r=t.sheet;r.insertRule(e,r.cssRules.length)}clear(){this.nativeFontFaces.forEach((function(e){document.fonts.delete(e)})),this.nativeFontFaces.length=0,this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async bind(e){if(e.attached||e.missingFile)return;if(e.attached=!0,this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(r){throw this._onUnsupportedFeature({featureId:s.UNSUPPORTED_FEATURES.font}),(0,s.warn)(`Failed to load font '${t.family}': '${r}'.`),e.disableFontFace=!0,r}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(r=>{const s=this._queueLoadingCallback(r);this._prepareFontLoadEvent([t],[e],s)})}}_queueLoadingCallback(e){(0,s.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){const e="undefined"!=typeof document&&!!document.fonts;return(0,s.shadow)(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){(0,s.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,s.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(e,t,r){(0,s.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let i;t.FontLoader=i,t.FontLoader=i=class extends n{constructor(e){super(e),this.loadingContext={requests:[],nextRequestId:0},this.loadTestFontId=0}get isSyncFontLoadingSupported(){let e=!1;if("undefined"==typeof navigator)e=!0;else{const t=/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);t&&t[1]>=14&&(e=!0)}return(0,s.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const t=this.loadingContext,r={id:`pdfjs-font-loading-${t.nextRequestId++}`,done:!1,complete:function(){for((0,s.assert)(!r.done,"completeRequest() cannot be called twice."),r.done=!0;t.requests.length>0&&t.requests[0].done;){const e=t.requests.shift();setTimeout(e.callback,0)}},callback:e};return t.requests.push(r),r}get _loadTestFont(){return(0,s.shadow)(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t,r){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function i(e,t,r,s){return e.substring(0,t)+s+e.substring(t+r)}let a,o;const l=document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;const d=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=i(u,976,d.length,d);let p=n(u,16);for(a=0,o=d.length-3;a30)return(0,s.warn)("Load test font never loaded."),void r();c.font="30px "+t,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0?r():setTimeout(e.bind(null,t,r))}(d,(function(){document.body.removeChild(m),r.complete()}))}};t.FontFaceObject=class{constructor(e,{isEvalSupported:t=!0,disableFontFace:r=!1,ignoreErrors:s=!1,onUnsupportedFeature:n=null,fontRegistry:i=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.isEvalSupported=!1!==t,this.disableFontFace=!0===r,this.ignoreErrors=!0===s,this._onUnsupportedFeature=n,this.fontRegistry=i}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;const e=new FontFace(this.loadedName,this.data,{});return this.fontRegistry&&this.fontRegistry.registerFont(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=(0,s.bytesToString)(new Uint8Array(this.data)),t=`url(data:${this.mimetype};base64,${btoa(e)});`,r=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this.fontRegistry&&this.fontRegistry.registerFont(this,t),r}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let r,n;try{r=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;return this._onUnsupportedFeature&&this._onUnsupportedFeature({featureId:s.UNSUPPORTED_FEATURES.font}),(0,s.warn)(`getPathGenerator - ignoring character: "${e}".`),this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&s.IsEvalSupportedCached.value){let e,s="";for(let t=0,i=r.length;t>2),_=b.length,y=c+7>>3,v=4294967295,S=s.IsLittleEndianCached.value?4278190080:255;for(n=0;ny?c:8*x-7,w=-8&k,R=0,P=0;C>=1}for(;r<_;)b[r++]=0;e.putImageData(p,0,16*n)}}else if(t.kind===s.ImageKind.RGBA_32BPP){for(i=0,o=16*c*4,n=0;n=d&&(o=c*(a=h)),r=0,i=o;i--;)m[r++]=f[g++],m[r++]=f[g++],m[r++]=f[g++],m[r++]=255;e.putImageData(p,0,16*n)}}}}function r(e,t){for(var r=t.height,s=t.width,n=r%16,i=(r-n)/16,a=0===n?i:i+1,o=e.createImageData(s,16),l=0,c=t.data,h=o.data,d=0;d>=1}e.putImageData(o,0,16*d)}}function l(e,t){for(var r=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"],s=0,n=r.length;s>8,e[i-2]=e[i-2]*a+r*o>>8,e[i-1]=e[i-1]*a+s*o>>8}}}function d(e,t,r){for(var s=e.length,n=3;n>8]>>8:t[n]*i>>16}}function p(e,t,r,s){var n=t.canvas,i=t.context;e.setTransform(t.scaleX,0,0,t.scaleY,t.offsetX,t.offsetY);var a=t.backdrop||null;if(!t.transferMap&&s.isEnabled){const i=s.composeSMask({layer:r.canvas,mask:n,properties:{subtype:t.subtype,backdrop:a}});return e.setTransform(1,0,0,1,0,0),void e.drawImage(i,t.offsetX,t.offsetY)}!function(e,t,r,s,n,i,a){var o,l=!!i,c=l?i[0]:0,p=l?i[1]:0,g=l?i[2]:0;o="Luminosity"===n?u:d;for(var f=Math.min(s,Math.ceil(1048576/r)),m=0;m10&&"function"==typeof r,d=h?Date.now()+15:0,u=0,p=this.commonObjs,g=this.objs;;){if(void 0!==n&&o===n.nextBreakPoint)return n.breakIt(o,r),o;if((c=a[o])!==s.OPS.dependency)this[c].apply(this,i[o]);else for(const e of i[o]){const t=e.startsWith("g_")?p:g;if(!t.has(e))return t.get(e,r),o}if(++o===l)return o;if(h&&++u>10){if(Date.now()>d)return r(),o;u=0}}},endDrawing:function(){null!==this.current.activeSMask&&this.endSMaskGroup(),this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null),this.cachedCanvases.clear(),this.webGLContext.clear(),this.imageLayer&&this.imageLayer.endLayout()},setLineWidth:function(e){this.current.lineWidth=e,this.ctx.lineWidth=e},setLineCap:function(e){this.ctx.lineCap=g[e]},setLineJoin:function(e){this.ctx.lineJoin=f[e]},setMiterLimit:function(e){this.ctx.miterLimit=e},setDash:function(e,t){var r=this.ctx;void 0!==r.setLineDash&&(r.setLineDash(e),r.lineDashOffset=t)},setRenderingIntent(e){},setFlatness(e){},setGState:function(e){for(var t=0,r=e.length;t0&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask?this.suspendSMaskGroup():this.endSMaskGroup()),this.current.activeSMask=i?this.tempSMask:null,this.current.activeSMask&&this.beginSMaskGroup(),this.tempSMask=null}}},beginSMaskGroup:function(){var e=this.current.activeSMask,t=e.canvas.width,r=e.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,t,r,!0),i=this.ctx,a=i.mozCurrentTransform;this.ctx.save();var o=n.context;o.scale(1/e.scaleX,1/e.scaleY),o.translate(-e.offsetX,-e.offsetY),o.transform.apply(o,a),e.startTransformInverse=o.mozCurrentTransformInverse,l(i,o),this.ctx=o,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++},suspendSMaskGroup:function(){var e=this.ctx;this.groupLevel--,this.ctx=this.groupStack.pop(),p(this.ctx,this.current.activeSMask,e,this.webGLContext),this.ctx.restore(),this.ctx.save(),l(e,this.ctx),this.current.resumeSMaskCtx=e;var t=s.Util.transform(this.current.activeSMask.startTransformInverse,e.mozCurrentTransform);this.ctx.transform.apply(this.ctx,t),e.save(),e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,e.canvas.width,e.canvas.height),e.restore()},resumeSMaskGroup:function(){var e=this.current.resumeSMaskCtx,t=this.ctx;this.ctx=e,this.groupStack.push(t),this.groupLevel++},endSMaskGroup:function(){var e=this.ctx;this.groupLevel--,this.ctx=this.groupStack.pop(),p(this.ctx,this.current.activeSMask,e,this.webGLContext),this.ctx.restore(),l(e,this.ctx);var t=s.Util.transform(this.current.activeSMask.startTransformInverse,e.mozCurrentTransform);this.ctx.transform.apply(this.ctx,t)},save:function(){this.ctx.save();var e=this.current;this.stateStack.push(e),this.current=e.clone(),this.current.resumeSMaskCtx=null},restore:function(){this.current.resumeSMaskCtx&&this.resumeSMaskGroup(),null===this.current.activeSMask||0!==this.stateStack.length&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask||this.endSMaskGroup(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.ctx.restore(),this.pendingClip=null,this._cachedGetSinglePixelWidth=null)},transform:function(e,t,r,s,n,i){this.ctx.transform(e,t,r,s,n,i),this._cachedGetSinglePixelWidth=null},constructPath:function(e,t){for(var r=this.ctx,n=this.current,i=n.x,a=n.y,o=0,l=0,c=e.length;o100&&(c=100),this.current.fontSizeScale=t/c,this.ctx.font=`${o} ${a} ${c}px ${l}`},setTextRenderingMode:function(e){this.current.textRenderingMode=e},setTextRise:function(e){this.current.textRise=e},moveText:function(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t},setLeadingMoveText:function(e,t){this.setLeading(-t),this.moveText(e,t)},setTextMatrix:function(e,t,r,s,n,i){this.current.textMatrix=[e,t,r,s,n,i],this.current.textMatrixScale=Math.sqrt(e*e+t*t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0},nextLine:function(){this.moveText(0,this.current.leading)},paintChar(e,t,r,n){var i=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,c=a.fontSize/a.fontSizeScale,h=l&s.TextRenderingMode.FILL_STROKE_MASK,d=!!(l&s.TextRenderingMode.ADD_TO_PATH_FLAG);const u=a.patternFill&&o.data;var p;((o.disableFontFace||d||u)&&(p=o.getPathGenerator(this.commonObjs,e)),o.disableFontFace||u?(i.save(),i.translate(t,r),i.beginPath(),p(i,c),n&&i.setTransform.apply(i,n),h!==s.TextRenderingMode.FILL&&h!==s.TextRenderingMode.FILL_STROKE||i.fill(),h!==s.TextRenderingMode.STROKE&&h!==s.TextRenderingMode.FILL_STROKE||i.stroke(),i.restore()):(h!==s.TextRenderingMode.FILL&&h!==s.TextRenderingMode.FILL_STROKE||i.fillText(e,t,r),h!==s.TextRenderingMode.STROKE&&h!==s.TextRenderingMode.FILL_STROKE||i.strokeText(e,t,r)),d)&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:i.mozCurrentTransform,x:t,y:r,fontSize:c,addToPath:p})},get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);for(var t=e.getImageData(0,0,10,10).data,r=!1,n=3;n0&&t[n]<255){r=!0;break}return(0,s.shadow)(this,"isFontSubpixelAAEnabled",r)},showText:function(e){var t=this.current,r=t.font;if(r.isType3Font)return this.showType3Text(e);var n=t.fontSize;if(0===n)return;var i=this.ctx,a=t.fontSizeScale,o=t.charSpacing,l=t.wordSpacing,c=t.fontDirection,h=t.textHScale*c,d=e.length,u=r.vertical,p=u?1:-1,g=r.defaultVMetrics,f=n*t.fontMatrix[0],m=t.textRenderingMode===s.TextRenderingMode.FILL&&!r.disableFontFace&&!t.patternFill;let A;if(i.save(),t.patternFill){i.save();const e=t.fillColor.getPattern(i,this);A=i.mozCurrentTransform,i.restore(),i.fillStyle=e}i.transform.apply(i,t.textMatrix),i.translate(t.x,t.y+t.textRise),c>0?i.scale(h,-1):i.scale(h,1);var b=t.lineWidth,_=t.textMatrixScale;if(0===_||0===b){var y=t.textRenderingMode&s.TextRenderingMode.FILL_STROKE_MASK;y!==s.TextRenderingMode.STROKE&&y!==s.TextRenderingMode.FILL_STROKE||(this._cachedGetSinglePixelWidth=null,b=.65*this.getSinglePixelWidth())}else b/=_;1!==a&&(i.scale(a,a),b/=a),i.lineWidth=b;var v,S=0;for(v=0;v0){var O=1e3*i.measureText(I).width/n*a;if(Dnew e(t,this.commonObjs,this.objs,this.canvasFactory,this.webGLContext)};r=new n.TilingPattern(t,s,this.ctx,a,i)}else r=(0,n.getShadingPatternFromIR)(t);return r},setStrokeColorN:function(){this.current.strokeColor=this.getColorN_Pattern(arguments)},setFillColorN:function(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0},setStrokeRGBColor:function(e,t,r){var n=s.Util.makeCssRgb(e,t,r);this.ctx.strokeStyle=n,this.current.strokeColor=n},setFillRGBColor:function(e,t,r){var n=s.Util.makeCssRgb(e,t,r);this.ctx.fillStyle=n,this.current.fillColor=n,this.current.patternFill=!1},shadingFill:function(e){var t=this.ctx;this.save();var r=(0,n.getShadingPatternFromIR)(e);t.fillStyle=r.getPattern(t,this,!0);var i=t.mozCurrentTransformInverse;if(i){var a=t.canvas,o=a.width,l=a.height,c=s.Util.applyTransform([0,0],i),h=s.Util.applyTransform([0,l],i),d=s.Util.applyTransform([o,0],i),u=s.Util.applyTransform([o,l],i),p=Math.min(c[0],h[0],d[0],u[0]),g=Math.min(c[1],h[1],d[1],u[1]),f=Math.max(c[0],h[0],d[0],u[0]),m=Math.max(c[1],h[1],d[1],u[1]);this.ctx.fillRect(p,g,f-p,m-g)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.restore()},beginInlineImage:function(){(0,s.unreachable)("Should not call beginInlineImage")},beginImageData:function(){(0,s.unreachable)("Should not call beginImageData")},paintFormXObjectBegin:function(e,t){if(this.save(),this.baseTransformStack.push(this.baseTransform),Array.isArray(e)&&6===e.length&&this.transform.apply(this,e),this.baseTransform=this.ctx.mozCurrentTransform,t){var r=t[2]-t[0],s=t[3]-t[1];this.ctx.rect(t[0],t[1],r,s),this.clip(),this.endPath()}},paintFormXObjectEnd:function(){this.restore(),this.baseTransform=this.baseTransformStack.pop()},beginGroup:function(e){this.save();var t=this.ctx;e.isolated||(0,s.info)("TODO: Support non-isolated groups."),e.knockout&&(0,s.warn)("Knockout groups not supported.");var r=t.mozCurrentTransform;if(e.matrix&&t.transform.apply(t,e.matrix),!e.bbox)throw new Error("Bounding box is required.");var n=s.Util.getAxialAlignedBoundingBox(e.bbox,t.mozCurrentTransform),i=[0,0,t.canvas.width,t.canvas.height];n=s.Util.intersect(n,i)||[0,0,0,0];var a=Math.floor(n[0]),o=Math.floor(n[1]),c=Math.max(Math.ceil(n[2])-a,1),h=Math.max(Math.ceil(n[3])-o,1),d=1,u=1;c>4096&&(d=c/4096,c=4096),h>4096&&(u=h/4096,h=4096);var p="groupAt"+this.groupLevel;e.smask&&(p+="_smask_"+this.smaskCounter++%2);var g=this.cachedCanvases.getCanvas(p,c,h,!0),f=g.context;f.scale(1/d,1/u),f.translate(-a,-o),f.transform.apply(f,r),e.smask?this.smaskStack.push({canvas:g.canvas,context:f,offsetX:a,offsetY:o,scaleX:d,scaleY:u,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(a,o),t.scale(d,u)),l(t,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++,this.current.activeSMask=null},endGroup:function(e){this.groupLevel--;var t=this.ctx;this.ctx=this.groupStack.pop(),void 0!==this.ctx.imageSmoothingEnabled?this.ctx.imageSmoothingEnabled=!1:this.ctx.mozImageSmoothingEnabled=!1,e.smask?this.tempSMask=this.smaskStack.pop():this.ctx.drawImage(t.canvas,0,0),this.restore()},beginAnnotations:function(){this.save(),this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)},endAnnotations:function(){this.restore()},beginAnnotation:function(e,t,r){if(this.save(),c(this.ctx),this.current=new o,Array.isArray(e)&&4===e.length){var s=e[2]-e[0],n=e[3]-e[1];this.ctx.rect(e[0],e[1],s,n),this.clip(),this.endPath()}this.transform.apply(this,t),this.transform.apply(this,r)},endAnnotation:function(){this.restore()},paintJpegXObject:function(e,t,r){const n=this.processingType3?this.commonObjs.get(e):this.objs.get(e);if(n){this.save();var i=this.ctx;if(i.scale(1/t,-1/r),i.drawImage(n,0,0,n.width,n.height,0,-r,t,r),this.imageLayer){var a=i.mozCurrentTransformInverse,o=this.getCanvasPosition(0,0);this.imageLayer.appendImage({objId:e,left:o[0],top:o[1],width:t/a[0],height:r/a[3]})}this.restore()}else(0,s.warn)("Dependent image isn't ready yet")},paintImageMaskXObject:function(e){var t=this.ctx,s=e.width,n=e.height,i=this.current.fillColor,a=this.current.patternFill,o=this.processingType3;if(o&&void 0===o.compiled&&(o.compiled=s<=1e3&&n<=1e3?function(e){var t,r,s,n,i=e.width,a=e.height,o=i+1,l=new Uint8Array(o*(a+1)),c=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),h=i+7&-8,d=e.data,u=new Uint8Array(h*a),p=0;for(t=0,n=d.length;t0;)u[p++]=f&g?0:255,g>>=1;var m=0;for(0!==u[p=0]&&(l[0]=1,++m),r=1;r>2)+(u[p+1]?4:0)+(u[p-h+1]?8:0)]&&(l[s+r]=c[A],++m),p++;if(u[p-h]!==u[p]&&(l[s+r]=u[p]?2:4,++m),m>1e3)return null}for(s=t*o,0!==u[p=h*(a-1)]&&(l[s]=8,++m),r=1;r1e3)return null;var b=new Int32Array([0,o,-1,0,-o,0,0,0,1]),_=[];for(t=0;m&&t<=a;t++){for(var y=t*o,v=y+i;y>4,l[y]&=C>>2|C<<2),x.push(y%o),x.push(y/o|0),l[y]||--m}while(k!==y);_.push(x),--t}}return function(e){e.save(),e.scale(1/i,-1/a),e.translate(0,-a),e.beginPath();for(var t=0,r=_.length;t2&&f>1||p>2&&m>1;){var b=f,_=m;h>2&&f>1&&(h/=f/(b=Math.ceil(f/2))),p>2&&m>1&&(p/=m/(_=Math.ceil(m/2))),(g=(a=this.cachedCanvases.getCanvas(A,b,_)).context).clearRect(0,0,b,_),g.drawImage(i,0,0,f,m,0,0,b,_),i=a.canvas,f=b,m=_,A="prescale1"===A?"prescale2":"prescale1"}if(n.drawImage(i,0,0,f,m,0,-s,r,s),this.imageLayer){var y=this.getCanvasPosition(0,-s);this.imageLayer.appendImage({imgData:e,left:y[0],top:y[1],width:r/o[0],height:s/o[3]})}this.restore()},paintInlineImageXObjectGroup:function(e,r){var s=this.ctx,n=e.width,i=e.height,a=this.cachedCanvases.getCanvas("inlineImage",n,i);t(a.context,e);for(var o=0,l=r.length;oc[s+1]&&(l=r,r=s,s=l,l=i,i=a,a=l),c[s+1]>c[n+1]&&(l=s,s=n,n=l,l=a,a=o,o=l),c[r+1]>c[s+1]&&(l=r,r=s,s=l,l=i,i=a,a=l);var p=(c[r]+t.offsetX)*t.scaleX,g=(c[r+1]+t.offsetY)*t.scaleY,f=(c[s]+t.offsetX)*t.scaleX,m=(c[s+1]+t.offsetY)*t.scaleY,A=(c[n]+t.offsetX)*t.scaleX,b=(c[n+1]+t.offsetY)*t.scaleY;if(!(g>=b))for(var _,y,v,S,x,C,k,w,R=h[i],P=h[i+1],T=h[i+2],E=h[a],F=h[a+1],L=h[a+2],I=h[o],M=h[o+1],D=h[o+2],O=Math.round(g),N=Math.round(b),j=O;j<=N;j++){if(jb?1:m===b?0:(m-j)/(m-b),_=f-(f-A)*e,y=E-(E-I)*e,v=F-(F-M)*e,S=L-(L-D)*e}let e;e=jb?1:(g-j)/(g-b),x=p-(p-A)*e,C=R-(R-I)*e,k=P-(P-M)*e,w=T-(T-D)*e;for(var U=Math.round(Math.min(_,x)),q=Math.round(Math.max(_,x)),W=u*j+4*U,G=U;G<=q;G++){let e=(_-G)/(_-x);e<0?e=0:e>1&&(e=1),d[W++]=y-(y-C)*e|0,d[W++]=v-(v-k)*e|0,d[W++]=S-(S-w)*e|0,d[W++]=255}}}function t(t,r,s){var n,i,a=r.coords,o=r.colors;switch(r.type){case"lattice":var l=r.verticesPerRow,c=Math.floor(a.length/l)-1,h=l-1;for(n=0;n=s?n=s:r=n/e,{scale:r,size:n}},clipBbox:function(e,t,r,s,n,i){if(Array.isArray(t)&&4===t.length){var a=n-r,o=i-s;e.ctx.rect(r,s,a,o),e.clip(),e.endPath()}},setFillAndStrokeStyleToContext:function(r,n,i){const a=r.ctx,o=r.current;switch(n){case e:var l=this.ctx;a.fillStyle=l.fillStyle,a.strokeStyle=l.strokeStyle,o.fillColor=l.fillStyle,o.strokeColor=l.strokeStyle;break;case t:var c=s.Util.makeCssRgb(i[0],i[1],i[2]);a.fillStyle=c,a.strokeStyle=c,o.fillColor=c,o.strokeColor=c;break;default:throw new s.FormatError(`Unsupported paint type: ${n}`)}},getPattern:function(e,t){(e=this.ctx).setTransform.apply(e,this.baseTransform),e.transform.apply(e,this.matrix);var r=this.createPatternCanvas(t);return e.createPattern(r,"repeat")}},r}();t.TilingPattern=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GlobalWorkerOptions=void 0;const s=Object.create(null);t.GlobalWorkerOptions=s,s.workerPort=void 0===s.workerPort?null:s.workerPort,s.workerSrc=void 0===s.workerSrc?"":s.workerSrc},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MessageHandler=void 0;var s=r(1);const n=1,i=2,a=1,o=2,l=3,c=4,h=5,d=6,u=7,p=8;function g(e){if("object"!=typeof e||null===e)return e;switch(e.name){case"AbortException":return new s.AbortException(e.message);case"MissingPDFException":return new s.MissingPDFException(e.message);case"UnexpectedResponseException":return new s.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new s.UnknownErrorException(e.message,e.details);default:return new s.UnknownErrorException(e.message,e.toString())}}t.MessageHandler=class{constructor(e,t,r){this.sourceName=e,this.targetName=t,this.comObj=r,this.callbackId=1,this.streamId=1,this.postMessageTransfers=!0,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),this._onComObjOnMessage=e=>{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,r=this.callbackCapabilities[e];if(!r)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===n)r.resolve(t.data);else{if(t.callback!==i)throw new Error("Unexpected callback case");r.reject(g(t.reason))}return}const s=this.actionHandler[t.action];if(!s)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const e=this.sourceName,a=t.sourceName;new Promise((function(e){e(s(t.data))})).then((function(s){r.postMessage({sourceName:e,targetName:a,callback:n,callbackId:t.callbackId,data:s})}),(function(s){r.postMessage({sourceName:e,targetName:a,callback:i,callbackId:t.callbackId,reason:g(s)})}))}else t.streamId?this._createStreamSink(t):s(t.data)},r.addEventListener("message",this._onComObjOnMessage)}on(e,t){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=t}send(e,t,r){this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},r)}sendWithPromise(e,t,r){const n=this.callbackId++,i=(0,s.createPromiseCapability)();this.callbackCapabilities[n]=i;try{this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:n,data:t},r)}catch(e){i.reject(e)}return i.promise}sendWithStream(e,t,r,n){const i=this.streamId++,o=this.sourceName,l=this.targetName,c=this.comObj;return new ReadableStream({start:r=>{const a=(0,s.createPromiseCapability)();return this.streamControllers[i]={controller:r,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},this._postMessage({sourceName:o,targetName:l,action:e,streamId:i,data:t,desiredSize:r.desiredSize},n),a.promise},pull:e=>{const t=(0,s.createPromiseCapability)();return this.streamControllers[i].pullCall=t,c.postMessage({sourceName:o,targetName:l,stream:d,streamId:i,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,s.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,s.createPromiseCapability)();return this.streamControllers[i].cancelCall=t,this.streamControllers[i].isClosed=!0,c.postMessage({sourceName:o,targetName:l,stream:a,streamId:i,reason:g(e)}),t.promise}},r)}_createStreamSink(e){const t=this,r=this.actionHandler[e.action],n=e.streamId,i=this.sourceName,a=e.sourceName,o=this.comObj,d={enqueue(e,r=1,o){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=r,l>0&&this.desiredSize<=0&&(this.sinkCapability=(0,s.createPromiseCapability)(),this.ready=this.sinkCapability.promise),t._postMessage({sourceName:i,targetName:a,stream:c,streamId:n,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:i,targetName:a,stream:l,streamId:n}),delete t.streamSinks[n])},error(e){(0,s.assert)(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,o.postMessage({sourceName:i,targetName:a,stream:h,streamId:n,reason:g(e)}))},sinkCapability:(0,s.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};d.sinkCapability.resolve(),d.ready=d.sinkCapability.promise,this.streamSinks[n]=d,new Promise((function(t){t(r(e.data,d))})).then((function(){o.postMessage({sourceName:i,targetName:a,stream:p,streamId:n,success:!0})}),(function(e){o.postMessage({sourceName:i,targetName:a,stream:p,streamId:n,reason:g(e)})}))}_processStreamMessage(e){const t=e.streamId,r=this.sourceName,n=e.sourceName,i=this.comObj;switch(e.stream){case p:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(g(e.reason));break;case u:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(g(e.reason));break;case d:if(!this.streamSinks[t]){i.postMessage({sourceName:r,targetName:n,stream:u,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:f}=this.streamSinks[e.streamId];new Promise((function(e){e(f&&f())})).then((function(){i.postMessage({sourceName:r,targetName:n,stream:u,streamId:t,success:!0})}),(function(e){i.postMessage({sourceName:r,targetName:n,stream:u,streamId:t,reason:g(e)})}));break;case c:if((0,s.assert)(this.streamControllers[t],"enqueue should have stream controller"),this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case l:if((0,s.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 h:(0,s.assert)(this.streamControllers[t],"error should have stream controller"),this.streamControllers[t].controller.error(g(e.reason)),this._deleteStreamController(t);break;case o:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(g(e.reason)),this._deleteStreamController(t);break;case a:if(!this.streamSinks[t])break;const{onCancel:m}=this.streamSinks[e.streamId];new Promise((function(t){t(m&&m(g(e.reason)))})).then((function(){i.postMessage({sourceName:r,targetName:n,stream:o,streamId:t,success:!0})}),(function(e){i.postMessage({sourceName:r,targetName:n,stream:o,streamId:t,reason:g(e)})})),this.streamSinks[t].sinkCapability.reject(g(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,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Metadata=void 0;var s=r(1),n=r(13);t.Metadata=class{constructor(e){(0,s.assert)("string"==typeof e,"Metadata: input is not a string"),e=this._repair(e);const t=(new n.SimpleXMLParser).parseFromString(e);this._metadataMap=new Map,t&&this._parse(t)}_repair(e){return e.replace(/^[^<]+/,"").replace(/>\\376\\377([^<]+)/g,(function(e,t){const r=t.replace(/\\([0-3])([0-7])([0-7])/g,(function(e,t,r,s){return String.fromCharCode(64*t+8*r+1*s)})).replace(/&(amp|apos|gt|lt|quot);/g,(function(e,t){switch(t){case"amp":return"&";case"apos":return"'";case"gt":return">";case"lt":return"<";case"quot":return'"'}throw new Error(`_repair: ${t} isn't defined.`)}));let s="";for(let e=0,t=r.length;e=32&&t<127&&60!==t&&62!==t&&38!==t?String.fromCharCode(t):"&#x"+(65536+t).toString(16).substring(1)+";"}return">"+s}))}_parse(e){let t=e.documentElement;if("rdf:rdf"!==t.nodeName.toLowerCase())for(t=t.firstChild;t&&"rdf:rdf"!==t.nodeName.toLowerCase();)t=t.nextSibling;const r=t?t.nodeName.toLowerCase():null;if(!t||"rdf:rdf"!==r||!t.hasChildNodes())return;const s=t.childNodes;for(let e=0,t=s.length;e0}}t.SimpleXMLParser=class extends class{_resolveEntities(e){return e.replace(/&([^;]+);/g,(e,t)=>{if("#x"===t.substring(0,2))return String.fromCharCode(parseInt(t.substring(2),16));if("#"===t.substring(0,1))return String.fromCharCode(parseInt(t.substring(1),10));switch(t){case"lt":return"<";case"gt":return">";case"amp":return"&";case"quot":return'"'}return this.onResolveEntity(t)})}_parseContent(e,t){const r=[];let s=t;function n(){for(;s"!==e[s]&&"/"!==e[s];)++s;const i=e.substring(t,s);for(n();s"!==e[s]&&"/"!==e[s]&&"?"!==e[s];){n();let t="",i="";for(;s"!==e[r]&&"/"!==e[r];)++r;const s=e.substring(t,r);!function(){for(;r"!==e[r+1]);)++r;return{name:s,value:e.substring(n,r),parsed:r-t}}parseXml(e){let t=0;for(;t",r),t<0)return void this.onError(c);this.onEndElement(e.substring(r,t)),r=t+1;break;case"?":++r;const s=this._parseProcessingInstruction(e,r);if("?>"!==e.substring(r+s.parsed,r+s.parsed+2))return void this.onError(i);this.onPi(s.name,s.value),r+=s.parsed+2;break;case"!":if("--"===e.substring(r+1,r+3)){if(t=e.indexOf("--\x3e",r+3),t<0)return void this.onError(o);this.onComment(e.substring(r+3,t)),r=t+3}else if("[CDATA["===e.substring(r+1,r+8)){if(t=e.indexOf("]]>",r+8),t<0)return void this.onError(n);this.onCdata(e.substring(r+8,t)),r=t+3}else{if("DOCTYPE"!==e.substring(r+1,r+8))return void this.onError(l);{const s=e.indexOf("[",r+8);let n=!1;if(t=e.indexOf(">",r+8),t<0)return void this.onError(a);if(s>0&&t>s){if(t=e.indexOf("]>",r+8),t<0)return void this.onError(a);n=!0}const i=e.substring(r+8,t+(n?1:0));this.onDoctype(i),r=t+(n?2:1)}}break;default:const h=this._parseContent(e,r);if(null===h)return void this.onError(l);let d=!1;if("/>"===e.substring(r+h.parsed,r+h.parsed+2))d=!0;else if(">"!==e.substring(r+h.parsed,r+h.parsed+1))return void this.onError(c);this.onBeginElement(h.name,h.attributes,d),r+=h.parsed+(d?2:1)}}else{for(;r0){const e=new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._contentLength=e.length,this._fullRequestReader=null,this._rangeReaders=[],this._pdfDataRangeTransport.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})}),this._pdfDataRangeTransport.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})}),this._pdfDataRangeTransport.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})}),this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),this._pdfDataRangeTransport.transportReady()}_onReceiveData(e){const t=new Uint8Array(e.chunk).buffer;if(void 0===e.begin)this._fullRequestReader?this._fullRequestReader._enqueue(t):this._queuedChunks.push(t);else{const r=this._rangeReaders.some((function(r){return r._begin===e.begin&&(r._enqueue(t),!0)}));(0,s.assert)(r)}}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}_onProgress(e){if(void 0===e.total){const t=this._rangeReaders[0];t&&t.onProgress&&t.onProgress({loaded:e.loaded})}else{const t=this._fullRequestReader;t&&t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,s.assert)(!this._fullRequestReader);const e=this._queuedChunks;return this._queuedChunks=null,new n(this,e,this._progressiveDone)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=new i(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e),this._rangeReaders.slice(0).forEach((function(t){t.cancel(e)})),this._pdfDataRangeTransport.abort()}};class n{constructor(e,t,r=!1){this._stream=e,this._done=r||!1,this._filename=null,this._queuedChunks=t||[],this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,s.createPromiseCapability)();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[]}progressiveDone(){this._done||(this._done=!0)}}class i{constructor(e,t,r){this._stream=e,this._begin=t,this._end=r,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1}),this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[]}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,s.createPromiseCapability)();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[],this._stream._removeRangeReader(this)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.WebGLContext=void 0;var s=r(1);t.WebGLContext=class{constructor({enable:e=!1}){this._enabled=!0===e}get isEnabled(){let e=this._enabled;return e&&(e=n.tryInitGL()),(0,s.shadow)(this,"isEnabled",e)}composeSMask({layer:e,mask:t,properties:r}){return n.composeSMask(e,t,r)}drawFigures({width:e,height:t,backgroundColor:r,figures:s,context:i}){return n.drawFigures(e,t,r,s,i)}clear(){n.cleanup()}};var n=function(){function e(e,t,r){var s=e.createShader(r);if(e.shaderSource(s,t),e.compileShader(s),!e.getShaderParameter(s,e.COMPILE_STATUS)){var n=e.getShaderInfoLog(s);throw new Error("Error during shader compilation: "+n)}return s}function t(t,r){return e(t,r,t.VERTEX_SHADER)}function r(t,r){return e(t,r,t.FRAGMENT_SHADER)}function s(e,t){for(var r=e.createProgram(),s=0,n=t.length;s 0.0) { maskColor.rgb = maskColor.rgb * maskColor.a + u_backdrop.rgb * (1.0 - maskColor.a); } float lum; if (u_subtype == 0) { lum = maskColor.a; } else { lum = maskColor.r * 0.3 + maskColor.g * 0.59 + maskColor.b * 0.11; } imageColor.a *= lum; imageColor.rgb *= imageColor.a; gl_FragColor = imageColor; } ")]);n.useProgram(c);var h={};h.gl=n,h.canvas=e,h.resolutionLocation=n.getUniformLocation(c,"u_resolution"),h.positionLocation=n.getAttribLocation(c,"a_position"),h.backdropLocation=n.getUniformLocation(c,"u_backdrop"),h.subtypeLocation=n.getUniformLocation(c,"u_subtype");var d=n.getAttribLocation(c,"a_texCoord"),u=n.getUniformLocation(c,"u_image"),p=n.getUniformLocation(c,"u_mask"),g=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,g),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),n.STATIC_DRAW),n.enableVertexAttribArray(d),n.vertexAttribPointer(d,2,n.FLOAT,!1,0,0),n.uniform1i(u,0),n.uniform1i(p,1),l=h}();var p=l,g=p.canvas,f=p.gl;g.width=d,g.height=u,f.viewport(0,0,f.drawingBufferWidth,f.drawingBufferHeight),f.uniform2f(p.resolutionLocation,d,u),h.backdrop?f.uniform4f(p.resolutionLocation,h.backdrop[0],h.backdrop[1],h.backdrop[2],1):f.uniform4f(p.resolutionLocation,0,0,0,0),f.uniform1i(p.subtypeLocation,"Luminosity"===h.subtype?1:0);var m=n(f,e,f.TEXTURE0),A=n(f,c,f.TEXTURE1),b=f.createBuffer();return f.bindBuffer(f.ARRAY_BUFFER,b),f.bufferData(f.ARRAY_BUFFER,new Float32Array([0,0,d,0,0,u,0,u,d,0,d,u]),f.STATIC_DRAW),f.enableVertexAttribArray(p.positionLocation),f.vertexAttribPointer(p.positionLocation,2,f.FLOAT,!1,0,0),f.clearColor(0,0,0,0),f.enable(f.BLEND),f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA),f.clear(f.COLOR_BUFFER_BIT),f.drawArrays(f.TRIANGLES,0,6),f.flush(),f.deleteTexture(m),f.deleteTexture(A),f.deleteBuffer(b),g},drawFigures:function(e,n,l,h,d){c||function(){var e,n;o(),e=a,a=null,n=i,i=null;var l=s(n,[t(n," attribute vec2 a_position; attribute vec3 a_color; uniform vec2 u_resolution; uniform vec2 u_scale; uniform vec2 u_offset; varying vec4 v_color; void main() { vec2 position = (a_position + u_offset) * u_scale; vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); v_color = vec4(a_color / 255.0, 1.0); } "),r(n," precision mediump float; varying vec4 v_color; void main() { gl_FragColor = v_color; } ")]);n.useProgram(l);var h={};h.gl=n,h.canvas=e,h.resolutionLocation=n.getUniformLocation(l,"u_resolution"),h.scaleLocation=n.getUniformLocation(l,"u_scale"),h.offsetLocation=n.getUniformLocation(l,"u_offset"),h.positionLocation=n.getAttribLocation(l,"a_position"),h.colorLocation=n.getAttribLocation(l,"a_color"),c=h}();var u=c,p=u.canvas,g=u.gl;p.width=e,p.height=n,g.viewport(0,0,g.drawingBufferWidth,g.drawingBufferHeight),g.uniform2f(u.resolutionLocation,e,n);var f,m,A,b=0;for(f=0,m=h.length;f1&&(h.vertical?o.canvasWidth=r.height*t._viewport.scale:o.canvasWidth=r.width*t._viewport.scale),t._textDivProperties.set(a,o),t._textContentStream&&t._layoutText(a),t._enhanceTextSelection){var f=1,m=0;0!==c&&(f=Math.cos(c),m=Math.sin(c));var A,b,_=(h.vertical?r.height:r.width)*t._viewport.scale,y=d;0!==c?(A=[f,m,-m,f,p,g],b=s.Util.getAxialAlignedBoundingBox([0,0,_,y],A)):b=[p,g,p+_,g+y],t._bounds.push({left:b[0],top:b[1],right:b[2],bottom:b[3],div:a,size:[_,y],m:A})}}function r(e){if(!e._canceled){var t=e._textDivs,r=e._capability,s=t.length;if(s>1e5)return e._renderingDone=!0,void r.resolve();if(!e._textContentStream)for(var n=0;n0&&(s=s?Math.min(i,s):i)}return s},A=1+Math.min(Math.abs(u),Math.abs(p));l.paddingLeft=m(f,32,16)/A,l.paddingTop=m(f,48,16)/A,l.paddingRight=m(f,0,16)/A,l.paddingBottom=m(f,16,16)/A,e._textDivProperties.set(o,l)}else l.paddingLeft=t[a].left-n[a].left,l.paddingTop=t[a].top-n[a].top,l.paddingRight=n[a].right-t[a].right,l.paddingBottom=n[a].bottom-t[a].bottom,e._textDivProperties.set(o,l)}}function i(e,t){t.sort((function(e,t){return e.x1-t.x1||e.index-t.index}));var r=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];t.forEach((function(e){for(var t=0;t=0&&r[i].start>=e.y2;)i--;var a,o,l=-1/0;for(a=t;a<=i;a++){var c;(c=(n=(s=r[a]).boundary).x2>e.x1?n.index>e.index?n.x1New:e.x1:void 0===n.x2New?(n.x2+e.x1)/2:n.x2New)>l&&(l=c)}for(e.x1New=l,a=t;a<=i;a++)void 0===(n=(s=r[a]).boundary).x2New?n.x2>e.x1?n.index>e.index&&(n.x2New=n.x2):n.x2New=l:n.x2New>l&&(n.x2New=Math.max(l,n.x2));var h=[],d=null;for(a=t;a<=i;a++){var u=(n=(s=r[a]).boundary).x2>e.x2?n:e;d===u?h[h.length-1].end=s.end:(h.push({start:s.start,end:s.end,boundary:u}),d=u)}for(r[t].start=0&&r[o].start>=n.y1;o--)p=r[o].boundary===n;for(o=i+1;!p&&o{this._layoutTextCtx&&(this._layoutTextCtx.canvas.width=0,this._layoutTextCtx.canvas.height=0,this._layoutTextCtx=null)}).catch(()=>{})}return a.prototype={get promise(){return this._capability.promise},cancel:function(){this._canceled=!0,this._reader&&(this._reader.cancel(new s.AbortException("TextLayer task cancelled.")),this._reader=null),null!==this._renderTimer&&(clearTimeout(this._renderTimer),this._renderTimer=null),this._capability.reject(new Error("TextLayer task cancelled."))},_processItems(e,r){for(let s=0,n=e.length;s0&&(t.scale=t.canvasWidth/i,r=`scaleX(${t.scale})`)}0!==t.angle&&(r=`rotate(${t.angle}deg) ${r}`),r.length>0&&(this._enhanceTextSelection&&(t.originalTransform=r),e.style.transform=r),this._textDivProperties.set(e,t),this._container.appendChild(e)},_render:function(e){const t=(0,s.createPromiseCapability)();let n=Object.create(null);const i=document.createElement("canvas");if(i.mozOpaque=!0,this._layoutTextCtx=i.getContext("2d",{alpha:!1}),this._textContent){const e=this._textContent.items,r=this._textContent.styles;this._processItems(e,r),t.resolve()}else{if(!this._textContentStream)throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');{const e=()=>{this._reader.read().then(({value:r,done:s})=>{s?t.resolve():(Object.assign(n,r.styles),this._processItems(r.items,n),e())},t.reject)};this._reader=this._textContentStream.getReader(),e()}}t.promise.then(()=>{n=null,e?this._renderTimer=setTimeout(()=>{r(this),this._renderTimer=null},e):r(this)},this._capability.reject)},expandTextDivs:function(e){if(!this._enhanceTextSelection||!this._renderingDone)return;null!==this._bounds&&(n(this),this._bounds=null);const t=[],r=[];for(var s=0,i=this._textDivs.length;s0?(r.push(`${i.paddingTop}px`),t.push(`translateY(${-i.paddingTop}px)`)):r.push(0),i.paddingRight>0?r.push(`${i.paddingRight/i.scale}px`):r.push(0),i.paddingBottom>0?r.push(`${i.paddingBottom}px`):r.push(0),i.paddingLeft>0?(r.push(`${i.paddingLeft/i.scale}px`),t.push(`translateX(${-i.paddingLeft/i.scale}px)`)):r.push(0),n.style.padding=r.join(" "),t.length&&(n.style.transform=t.join(" "))):(n.style.padding=null,n.style.transform=i.originalTransform))}}},function(e){var t=new a({textContent:e.textContent,textContentStream:e.textContentStream,container:e.container,viewport:e.viewport,textDivs:e.textDivs,textContentItemsStr:e.textContentItemsStr,enhanceTextSelection:e.enhanceTextSelection});return t._render(e.timeout),t}}();t.renderTextLayer=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationLayer=void 0;var s=r(4),n=r(1);class i{static create(e){switch(e.data.annotationType){case n.AnnotationType.LINK:return new o(e);case n.AnnotationType.TEXT:return new l(e);case n.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new h(e);case"Btn":return e.data.radioButton?new u(e):e.data.checkBox?new d(e):new p(e);case"Ch":return new g(e)}return new c(e);case n.AnnotationType.POPUP:return new f(e);case n.AnnotationType.FREETEXT:return new A(e);case n.AnnotationType.LINE:return new b(e);case n.AnnotationType.SQUARE:return new _(e);case n.AnnotationType.CIRCLE:return new y(e);case n.AnnotationType.POLYLINE:return new v(e);case n.AnnotationType.CARET:return new x(e);case n.AnnotationType.INK:return new C(e);case n.AnnotationType.POLYGON:return new S(e);case n.AnnotationType.HIGHLIGHT:return new k(e);case n.AnnotationType.UNDERLINE:return new w(e);case n.AnnotationType.SQUIGGLY:return new R(e);case n.AnnotationType.STRIKEOUT:return new P(e);case n.AnnotationType.STAMP:return new T(e);case n.AnnotationType.FILEATTACHMENT:return new E(e);default:return new a(e)}}}class a{constructor(e,t=!1,r=!1){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.page=e.page,this.viewport=e.viewport,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderInteractiveForms=e.renderInteractiveForms,this.svgFactory=e.svgFactory,t&&(this.container=this._createContainer(r))}_createContainer(e=!1){const t=this.data,r=this.page,s=this.viewport,i=document.createElement("section");let a=t.rect[2]-t.rect[0],o=t.rect[3]-t.rect[1];i.setAttribute("data-annotation-id",t.id);const l=n.Util.normalizeRect([t.rect[0],r.view[3]-t.rect[1]+r.view[1],t.rect[2],r.view[3]-t.rect[3]+r.view[1]]);if(i.style.transform=`matrix(${s.transform.join(",")})`,i.style.transformOrigin=`-${l[0]}px -${l[1]}px`,!e&&t.borderStyle.width>0){i.style.borderWidth=`${t.borderStyle.width}px`,t.borderStyle.style!==n.AnnotationBorderStyleType.UNDERLINE&&(a-=2*t.borderStyle.width,o-=2*t.borderStyle.width);const e=t.borderStyle.horizontalCornerRadius,r=t.borderStyle.verticalCornerRadius;if(e>0||r>0){const t=`${e}px / ${r}px`;i.style.borderRadius=t}switch(t.borderStyle.style){case n.AnnotationBorderStyleType.SOLID:i.style.borderStyle="solid";break;case n.AnnotationBorderStyleType.DASHED:i.style.borderStyle="dashed";break;case n.AnnotationBorderStyleType.BEVELED:(0,n.warn)("Unimplemented border style: beveled");break;case n.AnnotationBorderStyleType.INSET:(0,n.warn)("Unimplemented border style: inset");break;case n.AnnotationBorderStyleType.UNDERLINE:i.style.borderBottomStyle="solid"}t.color?i.style.borderColor=n.Util.makeCssRgb(0|t.color[0],0|t.color[1],0|t.color[2]):i.style.borderWidth=0}return i.style.left=`${l[0]}px`,i.style.top=`${l[1]}px`,i.style.width=`${a}px`,i.style.height=`${o}px`,i}_createPopup(e,t,r){t||((t=document.createElement("div")).style.height=e.style.height,t.style.width=e.style.width,e.appendChild(t));const s=new m({container:e,trigger:t,color:r.color,title:r.title,modificationDate:r.modificationDate,contents:r.contents,hideWrapper:!0}).render();s.style.left=e.style.width,e.appendChild(s)}render(){(0,n.unreachable)("Abstract method `AnnotationElement.render` called")}}class o extends a{constructor(e){super(e,!!(e.data.url||e.data.dest||e.data.action))}render(){this.container.className="linkAnnotation";const{data:e,linkService:t}=this,r=document.createElement("a");return e.url?(0,s.addLinkAttributes)(r,{url:e.url,target:e.newWindow?s.LinkTarget.BLANK:t.externalLinkTarget,rel:t.externalLinkRel,enabled:t.externalLinkEnabled}):e.action?this._bindNamedAction(r,e.action):this._bindLink(r,e.dest),this.container.appendChild(r),this.container}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.navigateTo(t),!1),t&&(e.className="internalLink")}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),e.className="internalLink"}}class l extends a{constructor(e){super(e,!!(e.data.hasPopup||e.data.title||e.data.contents))}render(){this.container.className="textAnnotation";const e=document.createElement("img");return e.style.height=this.container.style.height,e.style.width=this.container.style.width,e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.alt="[{{type}} Annotation]",e.dataset.l10nId="text_annotation_type",e.dataset.l10nArgs=JSON.stringify({type:this.data.name}),this.data.hasPopup||this._createPopup(this.container,e,this.data),this.container.appendChild(e),this.container}}class c extends a{render(){return this.container}}class h extends c{constructor(e){super(e,e.renderInteractiveForms||!e.data.hasAppearance&&!!e.data.fieldValue)}render(){const e=["left","center","right"];this.container.className="textWidgetAnnotation";let t=null;if(this.renderInteractiveForms){if(this.data.multiLine?(t=document.createElement("textarea"),t.textContent=this.data.fieldValue):(t=document.createElement("input"),t.type="text",t.setAttribute("value",this.data.fieldValue)),t.disabled=this.data.readOnly,null!==this.data.maxLen&&(t.maxLength=this.data.maxLen),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/this.data.maxLen;t.classList.add("comb"),t.style.letterSpacing=`calc(${e}px - 1ch)`}}else{t=document.createElement("div"),t.textContent=this.data.fieldValue,t.style.verticalAlign="middle",t.style.display="table-cell";let e=null;this.data.fontRefName&&this.page.commonObjs.has(this.data.fontRefName)&&(e=this.page.commonObjs.get(this.data.fontRefName)),this._setTextStyle(t,e)}return null!==this.data.textAlignment&&(t.style.textAlign=e[this.data.textAlignment]),this.container.appendChild(t),this.container}_setTextStyle(e,t){const r=e.style;if(r.fontSize=`${this.data.fontSize}px`,r.direction=this.data.fontDirection<0?"rtl":"ltr",!t)return;let s="normal";t.black?s="900":t.bold&&(s="bold"),r.fontWeight=s,r.fontStyle=t.italic?"italic":"normal";const n=t.loadedName?`"${t.loadedName}", `:"",i=t.fallbackName||"Helvetica, sans-serif";r.fontFamily=n+i}}class d extends c{constructor(e){super(e,e.renderInteractiveForms)}render(){this.container.className="buttonWidgetAnnotation checkBox";const e=document.createElement("input");return e.disabled=this.data.readOnly,e.type="checkbox",this.data.fieldValue&&"Off"!==this.data.fieldValue&&e.setAttribute("checked",!0),this.container.appendChild(e),this.container}}class u extends c{constructor(e){super(e,e.renderInteractiveForms)}render(){this.container.className="buttonWidgetAnnotation radioButton";const e=document.createElement("input");return e.disabled=this.data.readOnly,e.type="radio",e.name=this.data.fieldName,this.data.fieldValue===this.data.buttonValue&&e.setAttribute("checked",!0),this.container.appendChild(e),this.container}}class p extends o{render(){const e=super.render();return e.className="buttonWidgetAnnotation pushButton",e}}class g extends c{constructor(e){super(e,e.renderInteractiveForms)}render(){this.container.className="choiceWidgetAnnotation";const e=document.createElement("select");e.disabled=this.data.readOnly,this.data.combo||(e.size=this.data.options.length,this.data.multiSelect&&(e.multiple=!0));for(const t of this.data.options){const r=document.createElement("option");r.textContent=t.displayValue,r.value=t.exportValue,this.data.fieldValue.includes(t.displayValue)&&r.setAttribute("selected",!0),e.appendChild(r)}return this.container.appendChild(e),this.container}}class f extends a{constructor(e){super(e,!(!e.data.title&&!e.data.contents))}render(){if(this.container.className="popupAnnotation",["Line","Square","Circle","PolyLine","Polygon","Ink"].includes(this.data.parentType))return this.container;const e=`[data-annotation-id="${this.data.parentId}"]`,t=this.layer.querySelector(e);if(!t)return this.container;const r=new m({container:this.container,trigger:t,color:this.data.color,title:this.data.title,modificationDate:this.data.modificationDate,contents:this.data.contents}),s=parseFloat(t.style.left),n=parseFloat(t.style.width);return this.container.style.transformOrigin=`-${s+n}px -${t.style.top}`,this.container.style.left=`${s+n}px`,this.container.appendChild(r.render()),this.container}}class m{constructor(e){this.container=e.container,this.trigger=e.trigger,this.color=e.color,this.title=e.title,this.modificationDate=e.modificationDate,this.contents=e.contents,this.hideWrapper=e.hideWrapper||!1,this.pinned=!1}render(){const e=document.createElement("div");e.className="popupWrapper",this.hideElement=this.hideWrapper?e:this.container,this.hideElement.setAttribute("hidden",!0);const t=document.createElement("div");t.className="popup";const r=this.color;if(r){const e=.7*(255-r[0])+r[0],s=.7*(255-r[1])+r[1],i=.7*(255-r[2])+r[2];t.style.backgroundColor=n.Util.makeCssRgb(0|e,0|s,0|i)}const i=document.createElement("h1");i.textContent=this.title,t.appendChild(i);const a=s.PDFDateString.toDateObject(this.modificationDate);if(a){const e=document.createElement("span");e.textContent="{{date}}, {{time}}",e.dataset.l10nId="annotation_date_string",e.dataset.l10nArgs=JSON.stringify({date:a.toLocaleDateString(),time:a.toLocaleTimeString()}),t.appendChild(e)}const o=this._formatContents(this.contents);return t.appendChild(o),this.trigger.addEventListener("click",this._toggle.bind(this)),this.trigger.addEventListener("mouseover",this._show.bind(this,!1)),this.trigger.addEventListener("mouseout",this._hide.bind(this,!1)),t.addEventListener("click",this._hide.bind(this,!0)),e.appendChild(t),e}_formatContents(e){const t=document.createElement("p"),r=e.split(/(?:\r\n?|\n)/);for(let e=0,s=r.length;e>1&2147483647:r>>1&2147483647;t[e]=r}function r(e,r,s,n){let i=n;const a=r.length;s[i]=a>>24&255,s[i+1]=a>>16&255,s[i+2]=a>>8&255,s[i+3]=255&a,i+=4,s[i]=255&e.charCodeAt(0),s[i+1]=255&e.charCodeAt(1),s[i+2]=255&e.charCodeAt(2),s[i+3]=255&e.charCodeAt(3),i+=4,s.set(r,i),i+=r.length;const o=function(e,r,s){let n=-1;for(let i=r;i>>8^t[r]}return-1^n}(s,n+4,i);s[i]=o>>24&255,s[i+1]=o>>16&255,s[i+2]=o>>8&255,s[i+3]=255&o}function n(e){let t=e.length;const r=Math.ceil(t/65535),s=new Uint8Array(2+t+5*r+4);let n=0;s[n++]=120,s[n++]=156;let i=0;for(;t>65535;)s[n++]=0,s[n++]=255,s[n++]=255,s[n++]=0,s[n++]=0,s.set(e.subarray(i,i+65535),n),n+=65535,i+=65535,t-=65535;s[n++]=1,s[n++]=255&t,s[n++]=t>>8&255,s[n++]=255&~t,s[n++]=(65535&~t)>>8&255,s.set(e.subarray(i),n),n+=e.length-i;const a=function(e,t,r){let s=1,n=0;for(let i=t;i>24&255,s[n++]=a>>16&255,s[n++]=a>>8&255,s[n++]=255&a,s}function a(t,a,o,l){const c=t.width,h=t.height;let d,u,p;const g=t.data;switch(a){case s.ImageKind.GRAYSCALE_1BPP:u=0,d=1,p=c+7>>3;break;case s.ImageKind.RGB_24BPP:u=2,d=8,p=3*c;break;case s.ImageKind.RGBA_32BPP:u=6,d=8,p=4*c;break;default:throw new Error("invalid format")}const f=new Uint8Array((1+p)*h);let m=0,A=0;for(let e=0;e>24&255,c>>16&255,c>>8&255,255&c,h>>24&255,h>>16&255,h>>8&255,255&h,d,u,0,0,0]),_=function(e){if(!i.isNodeJS)return n(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);const r=require("zlib").deflateSync(t,{level:9});return r instanceof Uint8Array?r:new Uint8Array(r)}catch(e){(0,s.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return n(e)}(f),y=e.length+36+b.length+_.length,v=new Uint8Array(y);let S=0;return v.set(e,S),S+=e.length,r("IHDR",b,v,S),S+=12+b.length,r("IDATA",_,v,S),S+=12+_.length,r("IEND",new Uint8Array(0),v,S),(0,s.createObjectURL)(v,"image/png",o)}return function(e,t,r){return a(e,void 0===e.kind?s.ImageKind.GRAYSCALE_1BPP:e.kind,t,r)}}();class p{constructor(){this.fontSizeScale=1,this.fontWeight=e.fontWeight,this.fontSize=0,this.textMatrix=s.IDENTITY_MATRIX,this.fontMatrix=s.FONT_IDENTITY_MATRIX,this.leading=0,this.textRenderingMode=s.TextRenderingMode.FILL,this.textMatrixScale=1,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRise=0,this.fillColor=e.fillColor,this.strokeColor="#000000",this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.lineJoin="",this.lineCap="",this.miterLimit=0,this.dashArray=[],this.dashPhase=0,this.dependencies=[],this.activeClipUrl=null,this.clipGroup=null,this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e,this.y=t}}function o(e){if(Number.isInteger(e))return e.toString();const t=e.toFixed(10);let r=t.length-1;if("0"!==t[r])return t;do{r--}while("0"===t[r]);return t.substring(0,"."===t[r]?r:r+1)}function l(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${o(e[0])} ${o(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2]){return`rotate(${o(180*Math.acos(e[0])/Math.PI)})`}}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${o(e[4])} ${o(e[5])})`;return`matrix(${o(e[0])} ${o(e[1])} ${o(e[2])} ${o(e[3])} ${o(e[4])} `+`${o(e[5])})`}let g=0,f=0,m=0;t.SVGGraphics=a=class{constructor(e,t,r){this.svgFactory=new n.DOMSVGFactory,this.current=new p,this.transformMatrix=s.IDENTITY_MATRIX,this.transformStack=[],this.extraStack=[],this.commonObjs=e,this.objs=t,this.pendingClip=null,this.pendingEOFill=!1,this.embedFonts=!1,this.embeddedFonts=Object.create(null),this.cssStyle=null,this.forceDataSchema=!!r,this._operatorIdMapping=[];for(const e in s.OPS)this._operatorIdMapping[s.OPS[e]]=e}save(){this.transformStack.push(this.transformMatrix);const e=this.current;this.extraStack.push(e),this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop(),this.current=this.extraStack.pop(),this.pendingClip=null,this.tgrp=null}group(e){this.save(),this.executeOpTree(e),this.restore()}loadDependencies(e){const t=e.fnArray,r=e.argsArray;for(let e=0,n=t.length;e{e.get(t,r)});this.current.dependencies.push(r)}return Promise.all(this.current.dependencies)}transform(e,t,r,n,i,a){const o=[e,t,r,n,i,a];this.transformMatrix=s.Util.transform(this.transformMatrix,o),this.tgrp=null}getSVG(e,t){this.viewport=t;const r=this._initialize(t);return this.loadDependencies(e).then(()=>(this.transformMatrix=s.IDENTITY_MATRIX,this.executeOpTree(this.convertOpList(e)),r))}convertOpList(e){const t=this._operatorIdMapping,r=e.argsArray,s=e.fnArray,n=[];for(let e=0,i=s.length;e0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=h[e]}setLineJoin(e){this.current.lineJoin=d[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,r){this.current.strokeColor=s.Util.makeCssRgb(e,t,r)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,r){this.current.fillColor=s.Util.makeCssRgb(e,t,r),this.current.tspan=this.svgFactory.createElement("svg:tspan"),this.current.xcoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){const t=this.viewport.width,r=this.viewport.height,n=s.Util.inverseTransform(this.transformMatrix),i=s.Util.applyTransform([0,0],n),a=s.Util.applyTransform([0,r],n),o=s.Util.applyTransform([t,0],n),l=s.Util.applyTransform([t,r],n),c=Math.min(i[0],a[0],o[0],l[0]),h=Math.min(i[1],a[1],o[1],l[1]),d=Math.max(i[0],a[0],o[0],l[0]),u=Math.max(i[1],a[1],o[1],l[1]),p=this.svgFactory.createElement("svg:rect");p.setAttributeNS(null,"x",c),p.setAttributeNS(null,"y",h),p.setAttributeNS(null,"width",d-c),p.setAttributeNS(null,"height",u-h),p.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this._ensureTransformGroup().appendChild(p)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){const t=e[1],r=e[2],n=e[3]||s.IDENTITY_MATRIX,[i,a,o,l]=e[4],c=e[5],h=e[6],d=e[7],u=`shading${m++}`,[p,g]=s.Util.applyTransform([i,a],n),[f,A]=s.Util.applyTransform([o,l],n),[b,_]=s.Util.singularValueDecompose2dScale(n),y=c*b,v=h*_,S=this.svgFactory.createElement("svg:pattern");S.setAttributeNS(null,"id",u),S.setAttributeNS(null,"patternUnits","userSpaceOnUse"),S.setAttributeNS(null,"width",y),S.setAttributeNS(null,"height",v),S.setAttributeNS(null,"x",`${p}`),S.setAttributeNS(null,"y",`${g}`);const x=this.svg,C=this.transformMatrix,k=this.current.fillColor,w=this.current.strokeColor,R=this.svgFactory.create(f-p,A-g);if(this.svg=R,this.transformMatrix=n,2===d){const e=s.Util.makeCssRgb(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(r)),this.svg=x,this.transformMatrix=C,this.current.fillColor=k,this.current.strokeColor=w,S.appendChild(R.childNodes[0]),this.defs.appendChild(S),`url(#${u})`}_makeShadingPattern(e){switch(e[0]){case"RadialAxial":const t=`shading${m++}`,r=e[3];let n;switch(e[1]){case"axial":const r=e[4],s=e[5];n=this.svgFactory.createElement("svg:linearGradient"),n.setAttributeNS(null,"id",t),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"x1",r[0]),n.setAttributeNS(null,"y1",r[1]),n.setAttributeNS(null,"x2",s[0]),n.setAttributeNS(null,"y2",s[1]);break;case"radial":const i=e[4],a=e[5],o=e[6],l=e[7];n=this.svgFactory.createElement("svg:radialGradient"),n.setAttributeNS(null,"id",t),n.setAttributeNS(null,"gradientUnits","userSpaceOnUse"),n.setAttributeNS(null,"cx",a[0]),n.setAttributeNS(null,"cy",a[1]),n.setAttributeNS(null,"r",l),n.setAttributeNS(null,"fx",i[0]),n.setAttributeNS(null,"fy",i[1]),n.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(const e of r){const t=this.svgFactory.createElement("svg:stop");t.setAttributeNS(null,"offset",e[0]),t.setAttributeNS(null,"stop-color",e[1]),n.appendChild(t)}return this.defs.appendChild(n),`url(#${t})`;case"Mesh":return(0,s.warn)("Unimplemented pattern Mesh"),null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,t){this.current.dashArray=e,this.current.dashPhase=t}constructPath(e,t){const r=this.current;let n=r.x,i=r.y,a=[],l=0;for(const r of e)switch(0|r){case s.OPS.rectangle:n=t[l++],i=t[l++];const e=n+t[l++],r=i+t[l++];a.push("M",o(n),o(i),"L",o(e),o(i),"L",o(e),o(r),"L",o(n),o(r),"Z");break;case s.OPS.moveTo:n=t[l++],i=t[l++],a.push("M",o(n),o(i));break;case s.OPS.lineTo:n=t[l++],i=t[l++],a.push("L",o(n),o(i));break;case s.OPS.curveTo:n=t[l+4],i=t[l+5],a.push("C",o(t[l]),o(t[l+1]),o(t[l+2]),o(t[l+3]),o(n),o(i)),l+=6;break;case s.OPS.curveTo2:a.push("C",o(n),o(i),o(t[l]),o(t[l+1]),o(t[l+2]),o(t[l+3])),n=t[l+2],i=t[l+3],l+=4;break;case s.OPS.curveTo3:n=t[l+2],i=t[l+3],a.push("C",o(t[l]),o(t[l+1]),o(n),o(i),o(n),o(i)),l+=4;break;case s.OPS.closePath:a.push("Z")}a=a.join(" "),r.path&&e.length>0&&e[0]!==s.OPS.rectangle&&e[0]!==s.OPS.moveTo?a=r.path.getAttributeNS(null,"d")+a:(r.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().appendChild(r.path)),r.path.setAttributeNS(null,"d",a),r.path.setAttributeNS(null,"fill","none"),r.element=r.path,r.setCurrentPoint(n,i)}endPath(){const e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element)return void(this.pendingClip=null);const t=`clippath${g++}`,r=this.svgFactory.createElement("svg:clipPath");r.setAttributeNS(null,"id",t),r.setAttributeNS(null,"transform",l(this.transformMatrix));const s=e.element.cloneNode(!0);"evenodd"===this.pendingClip?s.setAttributeNS(null,"clip-rule","evenodd"):s.setAttributeNS(null,"clip-rule","nonzero"),this.pendingClip=null,r.appendChild(s),this.defs.appendChild(r),e.activeClipUrl&&(e.clipGroup=null,this.extraStack.forEach((function(e){e.clipGroup=null})),r.setAttributeNS(null,"clip-path",e.activeClipUrl)),e.activeClipUrl=`url(#${t})`,this.tgrp=null}clip(e){this.pendingClip=e}closePath(){const e=this.current;if(e.path){const t=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,r]of e)switch(t){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r);break;case"CA":this.setStrokeAlpha(r);break;case"ca":this.setFillAlpha(r);break;default:(0,s.warn)(`Unimplemented graphic state operator ${t}`)}}fill(){const e=this.current;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){const e=this.current;e.element&&(this._setStrokeAttributes(e.element),e.element.setAttributeNS(null,"fill","none"),this.endPath())}_setStrokeAttributes(e,t=1){const r=this.current;let s=r.dashArray;1!==t&&s.length>0&&(s=s.map((function(e){return t*e}))),e.setAttributeNS(null,"stroke",r.strokeColor),e.setAttributeNS(null,"stroke-opacity",r.strokeAlpha),e.setAttributeNS(null,"stroke-miterlimit",o(r.miterLimit)),e.setAttributeNS(null,"stroke-linecap",r.lineCap),e.setAttributeNS(null,"stroke-linejoin",r.lineJoin),e.setAttributeNS(null,"stroke-width",o(t*r.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",s.map(o).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",o(t*r.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fill()}fillStroke(){this.stroke(),this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd"),this.fillStroke()}closeStroke(){this.closePath(),this.stroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.closePath(),this.eoFillStroke()}paintSolidColorImageMask(){const e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0"),e.setAttributeNS(null,"y","0"),e.setAttributeNS(null,"width","1px"),e.setAttributeNS(null,"height","1px"),e.setAttributeNS(null,"fill",this.current.fillColor),this._ensureTransformGroup().appendChild(e)}paintJpegXObject(e,t,r){const s=this.objs.get(e),n=this.svgFactory.createElement("svg:image");n.setAttributeNS(c,"xlink:href",s.src),n.setAttributeNS(null,"width",o(t)),n.setAttributeNS(null,"height",o(r)),n.setAttributeNS(null,"x","0"),n.setAttributeNS(null,"y",o(-r)),n.setAttributeNS(null,"transform",`scale(${o(1/t)} ${o(-1/r)})`),this._ensureTransformGroup().appendChild(n)}paintImageXObject(e){const t=this.objs.get(e);t?this.paintInlineImageXObject(t):(0,s.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){const r=e.width,s=e.height,n=u(e,this.forceDataSchema,!!t),i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x","0"),i.setAttributeNS(null,"y","0"),i.setAttributeNS(null,"width",o(r)),i.setAttributeNS(null,"height",o(s)),this.current.element=i,this.clip("nonzero");const a=this.svgFactory.createElement("svg:image");a.setAttributeNS(c,"xlink:href",n),a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y",o(-s)),a.setAttributeNS(null,"width",o(r)+"px"),a.setAttributeNS(null,"height",o(s)+"px"),a.setAttributeNS(null,"transform",`scale(${o(1/r)} ${o(-1/s)})`),t?t.appendChild(a):this._ensureTransformGroup().appendChild(a)}paintImageMaskXObject(e){const t=this.current,r=e.width,s=e.height,n=t.fillColor;t.maskId=`mask${f++}`;const i=this.svgFactory.createElement("svg:mask");i.setAttributeNS(null,"id",t.maskId);const a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y","0"),a.setAttributeNS(null,"width",o(r)),a.setAttributeNS(null,"height",o(s)),a.setAttributeNS(null,"fill",n),a.setAttributeNS(null,"mask",`url(#${t.maskId})`),this.defs.appendChild(i),this._ensureTransformGroup().appendChild(a),this.paintInlineImageXObject(e,i)}paintFormXObjectBegin(e,t){if(Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),t){const e=t[2]-t[0],r=t[3]-t[1],s=this.svgFactory.createElement("svg:rect");s.setAttributeNS(null,"x",t[0]),s.setAttributeNS(null,"y",t[1]),s.setAttributeNS(null,"width",o(e)),s.setAttributeNS(null,"height",o(r)),this.current.element=s,this.clip("nonzero"),this.endPath()}}paintFormXObjectEnd(){}_initialize(e){const t=this.svgFactory.create(e.width,e.height),r=this.svgFactory.createElement("svg:defs");t.appendChild(r),this.defs=r;const s=this.svgFactory.createElement("svg:g");return s.setAttributeNS(null,"transform",l(e.transform)),t.appendChild(s),this.svg=s,t}_ensureClipGroup(){if(!this.current.clipGroup){const e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl),this.svg.appendChild(e),this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",l(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().appendChild(this.tgrp):this.svg.appendChild(this.tgrp)),this.tgrp}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PDFNodeStream=void 0;var s=r(1),n=r(20);const i=require("fs"),a=require("http"),o=require("https"),l=require("url"),c=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class{constructor(e){this.source=e,this.url=function(e){const t=l.parse(e);return"file:"===t.protocol||t.host?t:/^[a-z]:[/\\]/i.test(e)?l.parse(`file:///${e}`):(t.host||(t.protocol="file:"),t)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}getFullReader(){return(0,s.assert)(!this._fullRequestReader),this._fullRequestReader=this.isFsUrl?new f(this):new p(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=this.isFsUrl?new m(this,e,t):new g(this,e,t);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e),this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class h{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=(0,s.createPromiseCapability)(),this._headersCapability=(0,s.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=(0,s.createPromiseCapability)(),this.read()):(this._loaded+=e.length,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new s.AbortException("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class d{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=(0,s.createPromiseCapability)();const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=(0,s.createPromiseCapability)(),this.read()):(this._loaded+=e.length,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",()=>{this._readCapability.resolve()}),e.on("end",()=>{e.destroy(),this._done=!0,this._readCapability.resolve()}),e.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}function u(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class p extends h{constructor(e){super(e);const t=t=>{if(404===t.statusCode){const e=new s.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);const r=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:i,suggestedLength:a}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:r,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(r)};this._request=null,"http:"===this._url.protocol?this._request=a.request(u(this._url,e.httpHeaders),t):this._request=o.request(u(this._url,e.httpHeaders),t),this._request.on("error",e=>{this._storedError=e,this._headersCapability.reject(e)}),this._request.end()}}class g extends d{constructor(e,t,r){super(e),this._httpHeaders={};for(const t in e.httpHeaders){const r=e.httpHeaders[t];void 0!==r&&(this._httpHeaders[t]=r)}this._httpHeaders.Range=`bytes=${t}-${r-1}`;const n=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{const e=new s.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null,"http:"===this._url.protocol?this._request=a.request(u(this._url,this._httpHeaders),n):this._request=o.request(u(this._url,this._httpHeaders),n),this._request.on("error",e=>{this._storedError=e}),this._request.end()}}class f extends h{constructor(e){super(e);let t=decodeURIComponent(this._url.path);c.test(this._url.href)&&(t=t.replace(/^\//,"")),i.lstat(t,(e,r)=>{if(e)return"ENOENT"===e.code&&(e=new s.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=r.size,this._setReadableStream(i.createReadStream(t)),this._headersCapability.resolve()})}}class m extends d{constructor(e,t,r){super(e);let s=decodeURIComponent(this._url.path);c.test(this._url.href)&&(s=s.replace(/^\//,"")),this._setReadableStream(i.createReadStream(s,{start:t,end:r-1}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){if(404===e||0===e&&t.startsWith("file:"))return new s.MissingPDFException('Missing PDF "'+t+'".');return new s.UnexpectedResponseException("Unexpected server response ("+e+') while retrieving PDF "'+t+'".',e)},t.extractFilenameFromHeader=function(e){const t=e("Content-Disposition");if(t){let e=(0,n.getFilenameFromContentDispositionHeader)(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch(e){}if(/\.pdf$/i.test(e))return e}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:r,disableRange:n}){(0,s.assert)(r>0,"Range chunk size must be larger than zero");const i={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);if(!Number.isInteger(a))return i;if(i.suggestedLength=a,a<=2*r)return i;if(n||!t)return i;if("bytes"!==e("Accept-Ranges"))return i;if("identity"!==(e("Content-Encoding")||"identity"))return i;return i.allowRangeRequests=!0,i},t.validateResponseStatus=function(e){return 200===e||206===e};var s=r(1),n=r(21)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,r=s("filename\\*","i").exec(e);if(r){r=r[1];let e=a(r);return e=unescape(e),e=o(e),e=l(e),i(e)}if(r=function(e){const t=[];let r;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(r=n.exec(e));){let[,e,s,n]=r;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[s,n]}const i=[];for(let e=0;e=2&&r.onHeadersReceived&&(r.onHeadersReceived(),delete r.onHeadersReceived),4!==n.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===n.status&&this.isHttp)return void(r.onError&&r.onError(n.status));const i=n.status||200;if(!(200===i&&206===r.expectedStatus)&&i!==r.expectedStatus)return void(r.onError&&r.onError(n.status));const a=function(e){const t=e.response;return"string"!=typeof t?t:(0,s.stringToBytes)(t).buffer}(n);if(206===i){const e=n.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);r.onDone({begin:parseInt(t[1],10),chunk:a})}else a?r.onDone({begin:0,chunk:a}):r.onError&&r.onError(n.status)}hasPendingRequests(){for(const e in this.pendingRequests)return!0;return!1}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortAllRequests(){for(const e in this.pendingRequests)this.abortRequest(0|e)}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}t.PDFNetworkStream=class{constructor(e){this._source=e,this._manager=new i(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return(0,s.assert)(!this._fullRequestReader),this._fullRequestReader=new a(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const r=new o(this._manager,e,t);return r.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e),this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class a{constructor(e,t){this._manager=e;const r={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(r),this._headersReceivedCapability=(0,s.createPromiseCapability)(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),r=e=>t.getResponseHeader(e),{allowRangeRequests:s,suggestedLength:i}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=i||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e)if(this._requests.length>0){this._requests.shift().resolve({value:e.chunk,done:!1})}else this._cachedChunks.push(e.chunk);this._done=!0,this._cachedChunks.length>0||(this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[])}_onError(e){const t=this._url,r=(0,n.createResponseStatusError)(e,t);this._storedError=r,this._headersReceivedCapability.reject(r),this._requests.forEach((function(e){e.reject(r)})),this._requests=[],this._cachedChunks=[]}_onProgress(e){this.onProgress&&this.onProgress({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,s.createPromiseCapability)();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersReceivedCapability.reject(e),this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[],this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class o{constructor(e,t,r){this._manager=e;const s={onDone:this._onDone.bind(this),onProgress:this._onProgress.bind(this)};this._requestId=e.requestRange(t,r,s),this._requests=[],this._queuedChunk=null,this._done=!1,this.onProgress=null,this.onClosed=null}_close(){this.onClosed&&this.onClosed(this)}_onDone(e){const t=e.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0,this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[],this._close()}_onProgress(e){!this.isStreamingSupported&&this.onProgress&&this.onProgress({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(null!==this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,s.createPromiseCapability)();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})})),this._requests=[],this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFetchStream=void 0;var s=r(1),n=r(20);function i(e,t,r){return{method:"GET",headers:e,signal:r&&r.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function a(e){const t=new Headers;for(const r in e){const s=e[r];void 0!==s&&t.append(r,s)}return t}t.PDFFetchStream=class{constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}getFullReader(){return(0,s.assert)(!this._fullRequestReader),this._fullRequestReader=new o(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=new l(this,e,t);return this._rangeRequestReaders.push(r),r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e),this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class o{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=(0,s.createPromiseCapability)(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._headers=a(this._stream.httpHeaders);const r=t.url;fetch(r,i(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!(0,n.validateResponseStatus)(e.status))throw(0,n.createResponseStatusError)(e.status,r);this._reader=e.body.getReader(),this._headersCapability.resolve();const t=t=>e.headers.get(t),{allowRangeRequests:i,suggestedLength:a}=(0,n.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=a||this._contentLength,this._filename=(0,n.extractFilenameFromHeader)(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new s.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._reader&&this._reader.cancel(e),this._abortController&&this._abortController.abort()}}class l{constructor(e,t,r){this._stream=e,this._reader=null,this._loaded=0;const o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=(0,s.createPromiseCapability)(),this._isStreamingSupported=!o.disableStream,"undefined"!=typeof AbortController&&(this._abortController=new AbortController),this._headers=a(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${r-1}`);const l=o.url;fetch(l,i(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!(0,n.validateResponseStatus)(e.status))throw(0,n.createResponseStatusError)(e.status,l);this._readCapability.resolve(),this._reader=e.body.getReader()}),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress&&this.onProgress({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._reader&&this._reader.cancel(e),this._abortController&&this._abortController.abort()}}}])})); \ No newline at end of file +!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=t():e["pdfjs-dist/build/pdf"]=e.pdfjsLib=t()}(this,(function(){return function(e){var t={};function __w_pdfjs_require__(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};e[r].call(n.exports,n,n.exports,__w_pdfjs_require__);n.l=!0;return n.exports}__w_pdfjs_require__.m=e;__w_pdfjs_require__.c=t;__w_pdfjs_require__.d=function(e,t,r){__w_pdfjs_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})};__w_pdfjs_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});Object.defineProperty(e,"__esModule",{value:!0})};__w_pdfjs_require__.t=function(e,t){1&t&&(e=__w_pdfjs_require__(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);__w_pdfjs_require__.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(2&t&&"string"!=typeof e)for(var n in e)__w_pdfjs_require__.d(r,n,function(t){return e[t]}.bind(null,n));return r};__w_pdfjs_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};__w_pdfjs_require__.d(t,"a",t);return t};__w_pdfjs_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__w_pdfjs_require__.p="";return __w_pdfjs_require__(__w_pdfjs_require__.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"addLinkAttributes",{enumerable:!0,get:function(){return n.addLinkAttributes}});Object.defineProperty(t,"getFilenameFromUrl",{enumerable:!0,get:function(){return n.getFilenameFromUrl}});Object.defineProperty(t,"LinkTarget",{enumerable:!0,get:function(){return n.LinkTarget}});Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return n.loadScript}});Object.defineProperty(t,"PDFDateString",{enumerable:!0,get:function(){return n.PDFDateString}});Object.defineProperty(t,"RenderingCancelledException",{enumerable:!0,get:function(){return n.RenderingCancelledException}});Object.defineProperty(t,"build",{enumerable:!0,get:function(){return s.build}});Object.defineProperty(t,"getDocument",{enumerable:!0,get:function(){return s.getDocument}});Object.defineProperty(t,"LoopbackPort",{enumerable:!0,get:function(){return s.LoopbackPort}});Object.defineProperty(t,"PDFDataRangeTransport",{enumerable:!0,get:function(){return s.PDFDataRangeTransport}});Object.defineProperty(t,"PDFWorker",{enumerable:!0,get:function(){return s.PDFWorker}});Object.defineProperty(t,"version",{enumerable:!0,get:function(){return s.version}});Object.defineProperty(t,"CMapCompressionType",{enumerable:!0,get:function(){return a.CMapCompressionType}});Object.defineProperty(t,"createObjectURL",{enumerable:!0,get:function(){return a.createObjectURL}});Object.defineProperty(t,"createPromiseCapability",{enumerable:!0,get:function(){return a.createPromiseCapability}});Object.defineProperty(t,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return a.createValidAbsoluteUrl}});Object.defineProperty(t,"InvalidPDFException",{enumerable:!0,get:function(){return a.InvalidPDFException}});Object.defineProperty(t,"MissingPDFException",{enumerable:!0,get:function(){return a.MissingPDFException}});Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return a.OPS}});Object.defineProperty(t,"PasswordResponses",{enumerable:!0,get:function(){return a.PasswordResponses}});Object.defineProperty(t,"PermissionFlag",{enumerable:!0,get:function(){return a.PermissionFlag}});Object.defineProperty(t,"removeNullCharacters",{enumerable:!0,get:function(){return a.removeNullCharacters}});Object.defineProperty(t,"shadow",{enumerable:!0,get:function(){return a.shadow}});Object.defineProperty(t,"UnexpectedResponseException",{enumerable:!0,get:function(){return a.UnexpectedResponseException}});Object.defineProperty(t,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return a.UNSUPPORTED_FEATURES}});Object.defineProperty(t,"Util",{enumerable:!0,get:function(){return a.Util}});Object.defineProperty(t,"VerbosityLevel",{enumerable:!0,get:function(){return a.VerbosityLevel}});Object.defineProperty(t,"AnnotationLayer",{enumerable:!0,get:function(){return i.AnnotationLayer}});Object.defineProperty(t,"apiCompatibilityParams",{enumerable:!0,get:function(){return o.apiCompatibilityParams}});Object.defineProperty(t,"GlobalWorkerOptions",{enumerable:!0,get:function(){return l.GlobalWorkerOptions}});Object.defineProperty(t,"renderTextLayer",{enumerable:!0,get:function(){return c.renderTextLayer}});Object.defineProperty(t,"SVGGraphics",{enumerable:!0,get:function(){return h.SVGGraphics}});var n=r(1),s=r(5),a=r(2),i=r(19),o=r(9),l=r(12),c=r(20),h=r(21);{const{isNodeJS:e}=r(4);if(e){const e=r(22).PDFNodeStream;(0,s.setPDFNetworkStreamFactory)(t=>new e(t))}else{const e=r(25).PDFNetworkStream;let t;(0,n.isFetchSupported)()&&(t=r(26).PDFFetchStream);(0,s.setPDFNetworkStreamFactory)(r=>t&&(0,n.isValidFetchUrl)(r.url)?new t(r):new e(r))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.addLinkAttributes=function addLinkAttributes(e,{url:t,target:r,rel:s,enabled:i=!0}={}){(0,n.assert)(t&&"string"==typeof t,'addLinkAttributes: A valid "url" parameter must provided.');const o=(0,n.removeNullCharacters)(t);if(i)e.href=e.title=o;else{e.href="";e.title="Disabled: "+o;e.onclick=()=>!1}let l="";switch(r){case a.NONE:break;case a.SELF:l="_self";break;case a.BLANK:l="_blank";break;case a.PARENT:l="_parent";break;case a.TOP:l="_top"}e.target=l;e.rel="string"==typeof s?s:"noopener noreferrer nofollow"};t.getFilenameFromUrl=function getFilenameFromUrl(e){const t=e.indexOf("#"),r=e.indexOf("?"),n=Math.min(t>0?t:e.length,r>0?r:e.length);return e.substring(e.lastIndexOf("/",n)+1,n)};t.isFetchSupported=isFetchSupported;t.isValidFetchUrl=isValidFetchUrl;t.loadScript=function loadScript(e){return new Promise((t,r)=>{const n=document.createElement("script");n.src=e;n.onload=t;n.onerror=function(){r(new Error("Cannot load script at: "+n.src))};(document.head||document.documentElement).appendChild(n)})};t.deprecated=function deprecated(e){console.log("Deprecated API usage: "+e)};t.PDFDateString=t.StatTimer=t.DOMSVGFactory=t.DOMCMapReaderFactory=t.BaseCMapReaderFactory=t.DOMCanvasFactory=t.BaseCanvasFactory=t.DEFAULT_LINK_REL=t.LinkTarget=t.RenderingCancelledException=t.PageViewport=void 0;var n=r(2);t.DEFAULT_LINK_REL="noopener noreferrer nofollow";const s="http://www.w3.org/2000/svg";class BaseCanvasFactory{constructor(){this.constructor===BaseCanvasFactory&&(0,n.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){(0,n.unreachable)("Abstract method `create` called.")}reset(e,t,r){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||r<=0)throw new Error("Invalid canvas size");e.canvas.width=t;e.canvas.height=r}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0;e.canvas.height=0;e.canvas=null;e.context=null}}t.BaseCanvasFactory=BaseCanvasFactory;t.DOMCanvasFactory=class DOMCanvasFactory extends BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super();this._document=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const r=this._document.createElement("canvas"),n=r.getContext("2d");r.width=e;r.height=t;return{canvas:r,context:n}}};class BaseCMapReaderFactory{constructor({baseUrl:e=null,isCompressed:t=!1}){this.constructor===BaseCMapReaderFactory&&(0,n.unreachable)("Cannot initialize BaseCMapReaderFactory.");this.baseUrl=e;this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":""),r=this.isCompressed?n.CMapCompressionType.BINARY:n.CMapCompressionType.NONE;return this._fetchData(t,r).catch(e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}_fetchData(e,t){(0,n.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=BaseCMapReaderFactory;t.DOMCMapReaderFactory=class DOMCMapReaderFactory extends BaseCMapReaderFactory{_fetchData(e,t){return isFetchSupported()&&isValidFetchUrl(e,document.baseURI)?fetch(e).then(async e=>{if(!e.ok)throw new Error(e.statusText);let r;r=this.isCompressed?new Uint8Array(await e.arrayBuffer()):(0,n.stringToBytes)(await e.text());return{cMapData:r,compressionType:t}}):new Promise((r,s)=>{const a=new XMLHttpRequest;a.open("GET",e,!0);this.isCompressed&&(a.responseType="arraybuffer");a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){let e;this.isCompressed&&a.response?e=new Uint8Array(a.response):!this.isCompressed&&a.responseText&&(e=(0,n.stringToBytes)(a.responseText));if(e){r({cMapData:e,compressionType:t});return}}s(new Error(a.statusText))}};a.send(null)})}};t.DOMSVGFactory=class DOMSVGFactory{create(e,t){(0,n.assert)(e>0&&t>0,"Invalid SVG dimensions");const r=document.createElementNS(s,"svg:svg");r.setAttribute("version","1.1");r.setAttribute("width",e+"px");r.setAttribute("height",t+"px");r.setAttribute("preserveAspectRatio","none");r.setAttribute("viewBox","0 0 "+e+" "+t);return r}createElement(e){(0,n.assert)("string"==typeof e,"Invalid SVG element type");return document.createElementNS(s,e)}};class PageViewport{constructor({viewBox:e,scale:t,rotation:r,offsetX:n=0,offsetY:s=0,dontFlip:a=!1}){this.viewBox=e;this.scale=t;this.rotation=r;this.offsetX=n;this.offsetY=s;const i=(e[2]+e[0])/2,o=(e[3]+e[1])/2;let l,c,h,d,u,p,f,g;switch(r=(r%=360)<0?r+360:r){case 180:l=-1;c=0;h=0;d=1;break;case 90:l=0;c=1;h=1;d=0;break;case 270:l=0;c=-1;h=-1;d=0;break;case 0:l=1;c=0;h=0;d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a){h=-h;d=-d}if(0===l){u=Math.abs(o-e[1])*t+n;p=Math.abs(i-e[0])*t+s;f=Math.abs(e[3]-e[1])*t;g=Math.abs(e[2]-e[0])*t}else{u=Math.abs(i-e[0])*t+n;p=Math.abs(o-e[1])*t+s;f=Math.abs(e[2]-e[0])*t;g=Math.abs(e[3]-e[1])*t}this.transform=[l*t,c*t,h*t,d*t,u-l*t*i-h*t*o,p-c*t*i-d*t*o];this.width=f;this.height=g}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:r=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:r,offsetY:n,dontFlip:s})}convertToViewportPoint(e,t){return n.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=n.Util.applyTransform([e[0],e[1]],this.transform),r=n.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],r[0],r[1]]}convertToPdfPoint(e,t){return n.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=PageViewport;class RenderingCancelledException extends n.BaseException{constructor(e,t){super(e);this.type=t}}t.RenderingCancelledException=RenderingCancelledException;const a={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};t.LinkTarget=a;t.StatTimer=class StatTimer{constructor(){this.started=Object.create(null);this.times=[]}time(e){e in this.started&&(0,n.warn)("Timer is already running for "+e);this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,n.warn)("Timer has not been started for "+e);this.times.push({name:e,start:this.started[e],end:Date.now()});delete this.started[e]}toString(){const e=[];let t=0;for(const e of this.times){const r=e.name;r.length>t&&(t=r.length)}for(const r of this.times){const n=r.end-r.start;e.push(`${r.name.padEnd(t)} ${n}ms\n`)}return e.join("")}};function isFetchSupported(){return"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&"undefined"!=typeof ReadableStream}function isValidFetchUrl(e,t){try{const{protocol:r}=t?new URL(e,t):new URL(e);return"http:"===r||"https:"===r}catch(e){return!1}}let i;t.PDFDateString=class PDFDateString{static toDateObject(e){if(!e||!(0,n.isString)(e))return null;i||(i=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const t=i.exec(e);if(!t)return null;const r=parseInt(t[1],10);let s=parseInt(t[2],10);s=s>=1&&s<=12?s-1:0;let a=parseInt(t[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let l=parseInt(t[5],10);l=l>=0&&l<=59?l:0;let c=parseInt(t[6],10);c=c>=0&&c<=59?c:0;const h=t[7]||"Z";let d=parseInt(t[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(t[9],10)||0;u=u>=0&&u<=59?u:0;if("-"===h){o+=d;l+=u}else if("+"===h){o-=d;l-=u}return new Date(Date.UTC(r,s,a,o,l,c))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let n=0;nt});e.promise=new Promise((function(r,n){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;n(e)}}));return e};t.escapeString=function escapeString(e){return e.replace(/([\(\)\\])/g,"\\$1")};t.getModificationDate=function getModificationDate(e=new Date(Date.now())){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),(e.getUTCDate()+1).toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return s};t.info=function info(e){s>=n.INFOS&&console.log("Info: "+e)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isString=function isString(e){return"string"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let r;try{r=new URL(e);if(!r.origin||"null"===r.origin)return!1}catch(e){return!1}const n=new URL(t,r);return r.origin===n.origin};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null};t.removeNullCharacters=function removeNullCharacters(e){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}return e.replace(i,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(s=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let n=2;n=n.WARNINGS&&console.log("Warning: "+e)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const a=function BaseExceptionClosure(){function BaseException(e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=this.constructor.name}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=a;t.PasswordException=class PasswordException extends a{constructor(e,t){super(e);this.code=t}};t.UnknownErrorException=class UnknownErrorException extends a{constructor(e,t){super(e);this.details=t}};t.InvalidPDFException=class InvalidPDFException extends a{};t.MissingPDFException=class MissingPDFException extends a{};t.UnexpectedResponseException=class UnexpectedResponseException extends a{constructor(e,t){super(e);this.status=t}};t.FormatError=class FormatError extends a{};t.AbortException=class AbortException extends a{};const i=/\x00/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let n=0;ne[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){function compare(e,t){return e-t}const r=[e[0],e[2],t[0],t[2]].sort(compare),n=[e[1],e[3],t[1],t[3]].sort(compare),s=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;s[0]=r[1];s[2]=r[2];if(!(n[0]===e[1]&&n[1]===t[1]||n[0]===t[1]&&n[1]===e[1]))return null;s[1]=n[1];s[3]=n[2];return s}}t.Util=Util;const h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];const d=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,r,n=!1){if(!n&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let s=`data:${r};base64,`;for(let r=0,n=t.length;r>2]+e[(3&a)<<4|i>>4]+e[r+1>6:64]+e[r+2{this._transport=null;if(this._worker){this._worker.destroy();this._worker=null}})}}}();class PDFDataRangeTransport{constructor(e,t,r=!1){this.length=e;this.initialData=t;this.progressiveDone=r;this._rangeListeners=[];this._progressListeners=[];this._progressiveReadListeners=[];this._progressiveDoneListeners=[];this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const r of this._rangeListeners)r(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(const r of this._progressListeners)r(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(const t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get numPages(){return this._pdfInfo.numPages}get fingerprint(){return this._pdfInfo.fingerprint}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}getStats(){return this._transport.getStats()}cleanup(){return this._transport.startCleanup()}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(e){return this._transport.saveDocument(e)}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(e,t,r,n,s=!1){this._pageIndex=e;this._pageInfo=t;this._ownerDocument=n;this._transport=r;this._stats=s?new _display_utils.StatTimer:null;this._pdfBug=s;this.commonObjs=r.commonObjs;this.objs=new PDFObjects;this.cleanupAfterRender=!1;this.pendingCleanup=!1;this._intentStates=new Map;this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:r=0,offsetY:n=0,dontFlip:s=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:r,offsetY:n,dontFlip:s})}getAnnotations({intent:e=null}={}){if(!this.annotationsPromise||this.annotationsIntent!==e){this.annotationsPromise=this._transport.getAnnotations(this._pageIndex,e);this.annotationsIntent=e}return this.annotationsPromise}render({canvasContext:e,viewport:t,intent:r="display",enableWebGL:n=!1,renderInteractiveForms:s=!1,transform:a=null,imageLayer:i=null,canvasFactory:o=null,background:l=null,annotationStorage:c=null,optionalContentConfigPromise:h=null}){this._stats&&this._stats.time("Overall");const d="print"===r?"print":"display";this.pendingCleanup=!1;h||(h=this._transport.getOptionalContentConfig());let u=this._intentStates.get(d);if(!u){u=Object.create(null);this._intentStates.set(d,u)}if(u.streamReaderCancelTimeout){clearTimeout(u.streamReaderCancelTimeout);u.streamReaderCancelTimeout=null}const p=o||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),f=new _webgl.WebGLContext({enable:n});if(!u.displayReadyCapability){u.displayReadyCapability=(0,_util.createPromiseCapability)();u.operatorList={fnArray:[],argsArray:[],lastChunk:!1};this._stats&&this._stats.time("Page Request");this._pumpOperatorList({pageIndex:this._pageIndex,intent:d,renderInteractiveForms:!0===s,annotationStorage:c&&c.getAll()||null})}const complete=e=>{const t=u.renderTasks.indexOf(g);t>=0&&u.renderTasks.splice(t,1);(this.cleanupAfterRender||"print"===d)&&(this.pendingCleanup=!0);this._tryCleanup();if(e){g.capability.reject(e);this._abortOperatorList({intentState:u,reason:e})}else g.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall")}},g=new InternalRenderTask({callback:complete,params:{canvasContext:e,viewport:t,transform:a,imageLayer:i,background:l},objs:this.objs,commonObjs:this.commonObjs,operatorList:u.operatorList,pageIndex:this._pageIndex,canvasFactory:p,webGLContext:f,useRequestAnimationFrame:"print"!==d,pdfBug:this._pdfBug});u.renderTasks||(u.renderTasks=[]);u.renderTasks.push(g);const m=g.task;Promise.all([u.displayReadyCapability.promise,h]).then(([e,t])=>{if(this.pendingCleanup)complete();else{this._stats&&this._stats.time("Rendering");g.initializeGraphics({transparency:e,optionalContentConfig:t});g.operatorListChanged()}}).catch(complete);return m}getOperatorList(){let e,t=this._intentStates.get("oplist");if(!t){t=Object.create(null);this._intentStates.set("oplist",t)}if(!t.opListReadCapability){e=Object.create(null);e.operatorListChanged=function operatorListChanged(){if(t.operatorList.lastChunk){t.opListReadCapability.resolve(t.operatorList);const r=t.renderTasks.indexOf(e);r>=0&&t.renderTasks.splice(r,1)}};t.opListReadCapability=(0,_util.createPromiseCapability)();t.renderTasks=[];t.renderTasks.push(e);t.operatorList={fnArray:[],argsArray:[],lastChunk:!1};this._stats&&this._stats.time("Page Request");this._pumpOperatorList({pageIndex:this._pageIndex,intent:"oplist"})}return t.opListReadCapability.promise}streamTextContent({normalizeWhitespace:e=!1,disableCombineTextItems:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,normalizeWhitespace:!0===e,combineTextItems:!0!==t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){const t=this.streamTextContent(e);return new Promise((function(e,r){const n=t.getReader(),s={items:[],styles:Object.create(null)};!function pump(){n.read().then((function({value:t,done:r}){if(r)e(s);else{Object.assign(s.styles,t.styles);s.items.push(...t.items);pump()}}),r)}()}))}_destroy(){this.destroyed=!0;this._transport.pageCache[this._pageIndex]=null;const e=[];for(const[t,r]of this._intentStates){this._abortOperatorList({intentState:r,reason:new Error("Page was destroyed."),force:!0});if("oplist"!==t)for(const t of r.renderTasks){e.push(t.completed);t.cancel()}}this.objs.clear();this.annotationsPromise=null;this.pendingCleanup=!1;return Promise.all(e)}cleanup(e=!1){this.pendingCleanup=!0;return this._tryCleanup(e)}_tryCleanup(e=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(0!==e.length||!t.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this.annotationsPromise=null;e&&this._stats&&(this._stats=new _display_utils.StatTimer);this.pendingCleanup=!1;return!0}_startRenderPage(e,t){const r=this._intentStates.get(t);if(r){this._stats&&this._stats.timeEnd("Page Request");r.displayReadyCapability&&r.displayReadyCapability.resolve(e)}}_renderPageChunk(e,t){for(let r=0,n=e.length;r{t.read().then(({value:e,done:t})=>{if(t)r.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(e,r);pump()}},e=>{r.streamReader=null;if(!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(let e=0;e{this._abortOperatorList({intentState:e,reason:t,force:!0});e.streamReaderCancelTimeout=null},RENDERING_CANCELLED_TIMEOUT);return}}e.streamReader.cancel(new _util.AbortException(t&&t.message));e.streamReader=null;if(!this._transport.destroyed){for(const[t,r]of this._intentStates)if(r===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(e=!0){this._listeners=[];this._defer=e;this._deferred=Promise.resolve(void 0)}postMessage(e,t){if(!this._defer){this._listeners.forEach(t=>{t.call(this,{data:e})});return}const r=new WeakMap,n={data:function cloneValue(e){if("object"!=typeof e||null===e)return e;if(r.has(e))return r.get(e);let n,s;if((n=e.buffer)&&(0,_util.isArrayBuffer)(n)){s=t&&t.includes(n)?new e.constructor(n,e.byteOffset,e.byteLength):new e.constructor(e);r.set(e,s);return s}s=Array.isArray(e)?[]:{};r.set(e,s);for(const t in e){let r,n=e;for(;!(r=Object.getOwnPropertyDescriptor(n,t));)n=Object.getPrototypeOf(n);if(void 0!==r.value)if("function"!=typeof r.value)s[t]=cloneValue(r.value);else if(e.hasOwnProperty&&e.hasOwnProperty(t))throw new Error("LoopbackPort.postMessage - cannot clone: "+e[t])}return s}(e)};this._deferred.then(()=>{this._listeners.forEach(e=>{e.call(this,n)})})}addEventListener(e,t){this._listeners.push(t)}removeEventListener(e,t){const r=this._listeners.indexOf(t);this._listeners.splice(r,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorker=function PDFWorkerClosure(){const pdfWorkerPorts=new WeakMap;let isWorkerDisabled=!1,fallbackWorkerSrc,nextFakeWorkerId=0,fakeWorkerCapability;if(_is_node.isNodeJS&&"function"==typeof require){isWorkerDisabled=!0;fallbackWorkerSrc="./pdf.worker.js"}else if("object"==typeof document&&"currentScript"in document){const e=document.currentScript&&document.currentScript.src;e&&(fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}function getWorkerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(void 0!==fallbackWorkerSrc){_is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');return fallbackWorkerSrc}throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}function getMainThreadWorkerMessageHandler(){let e;try{e=globalThis.pdfjsWorker&&globalThis.pdfjsWorker.WorkerMessageHandler}catch(e){}return e||null}function setupFakeWorkerGlobal(){if(fakeWorkerCapability)return fakeWorkerCapability.promise;fakeWorkerCapability=(0,_util.createPromiseCapability)();const loader=async function(){const mainWorkerMessageHandler=getMainThreadWorkerMessageHandler();if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof require){const worker=eval("require")(getWorkerSrc());return worker.WorkerMessageHandler}await(0,_display_utils.loadScript)(getWorkerSrc());return window.pdfjsWorker.WorkerMessageHandler};loader().then(fakeWorkerCapability.resolve,fakeWorkerCapability.reject);return fakeWorkerCapability.promise}function createCDNWrapper(e){const t="importScripts('"+e+"');";return URL.createObjectURL(new Blob([t]))}class PDFWorker{constructor({name:e=null,port:t=null,verbosity:r=(0,_util.getVerbosityLevel)()}={}){if(t&&pdfWorkerPorts.has(t))throw new Error("Cannot use more than one PDFWorker per port");this.name=e;this.destroyed=!1;this.postMessageTransfers=!0;this.verbosity=r;this._readyCapability=(0,_util.createPromiseCapability)();this._port=null;this._webWorker=null;this._messageHandler=null;if(t){pdfWorkerPorts.set(t,this);this._initializeFromPort(t)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e;this._messageHandler=new _message_handler.MessageHandler("main","worker",e);this._messageHandler.on("ready",(function(){}));this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!isWorkerDisabled&&!getMainThreadWorkerMessageHandler()){let e=getWorkerSrc();try{(0,_util.isSameOrigin)(window.location.href,e)||(e=createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e),r=new _message_handler.MessageHandler("main","worker",t),terminateEarly=()=>{t.removeEventListener("error",onWorkerError);r.destroy();t.terminate();this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},onWorkerError=()=>{this._webWorker||terminateEarly()};t.addEventListener("error",onWorkerError);r.on("test",e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else if(e){this._messageHandler=r;this._port=t;this._webWorker=t;e.supportTransfers||(this.postMessageTransfers=!1);this._readyCapability.resolve();r.send("configure",{verbosity:this.verbosity})}else{this._setupFakeWorker();r.destroy();t.terminate()}});r.on("ready",e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else try{sendTest()}catch(e){this._setupFakeWorker()}});const sendTest=()=>{const e=new Uint8Array([this.postMessageTransfers?255:0]);try{r.send("test",e,[e.buffer])}catch(t){(0,_util.warn)("Cannot use postMessage transfers.");e[0]=0;r.send("test",e)}};sendTest();return}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){if(!isWorkerDisabled){(0,_util.warn)("Setting up fake worker.");isWorkerDisabled=!0}setupFakeWorkerGlobal().then(e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new LoopbackPort;this._port=t;const r="fake"+nextFakeWorkerId++,n=new _message_handler.MessageHandler(r+"_worker",r,t);e.setup(n,t);const s=new _message_handler.MessageHandler(r,r+"_worker",t);this._messageHandler=s;this._readyCapability.resolve();s.send("configure",{verbosity:this.verbosity})}).catch(e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}pdfWorkerPorts.delete(this._port);this._port=null;if(this._messageHandler){this._messageHandler.destroy();this._messageHandler=null}}static fromPort(e){if(!e||!e.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return pdfWorkerPorts.has(e.port)?pdfWorkerPorts.get(e.port):new PDFWorker(e)}static getWorkerSrc(){return getWorkerSrc()}}return PDFWorker}();exports.PDFWorker=PDFWorker;class WorkerTransport{constructor(e,t,r,n){this.messageHandler=e;this.loadingTask=t;this.commonObjs=new PDFObjects;this.fontLoader=new _font_loader.FontLoader({docId:t.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:n.ownerDocument});this._params=n;this.CMapReaderFactory=new n.CMapReaderFactory({baseUrl:n.cMapUrl,isCompressed:n.cMapPacked});this.destroyed=!1;this.destroyCapability=null;this._passwordCapability=null;this._networkStream=r;this._fullReader=null;this._lastProgress=null;this.pageCache=[];this.pagePromises=[];this.downloadInfoCapability=(0,_util.createPromiseCapability)();this.setupMessageHandler()}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=(0,_util.createPromiseCapability)();this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];this.pageCache.forEach((function(t){t&&e.push(t._destroy())}));this.pageCache.length=0;this.pagePromises.length=0;const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then(()=>{this.fontLoader.clear();this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated."));if(this.messageHandler){this.messageHandler.destroy();this.messageHandler=null}this.destroyCapability.resolve()},this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available.");this._fullReader=this._networkStream.getFullReader();this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}};t.onPull=()=>{this._fullReader.read().then((function({value:e,done:r}){if(r)t.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(e),"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch(e=>{t.error(e)})};t.onCancel=e=>{this._fullReader.cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}});e.on("ReaderHeadersReady",e=>{const r=(0,_util.createPromiseCapability)(),n=this._fullReader;n.headersReady.then(()=>{if(!n.isStreamingSupported||!n.isRangeSupported){this._lastProgress&&t.onProgress&&t.onProgress(this._lastProgress);n.onProgress=e=>{t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})}}r.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})},r.reject);return r.promise});e.on("GetRangeReader",(e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(e.begin,e.end);if(r){t.onPull=()=>{r.read().then((function({value:e,done:r}){if(r)t.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(e),"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch(e=>{t.error(e)})};t.onCancel=e=>{r.cancel(e);t.ready.catch(e=>{if(!this.destroyed)throw e})}}else t.close()});e.on("GetDoc",({pdfInfo:e})=>{this._numPages=e.numPages;t._capability.resolve(new PDFDocumentProxy(e,this))});e.on("DocException",(function(e){let r;switch(e.name){case"PasswordException":r=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":r=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":r=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":r=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":r=new _util.UnknownErrorException(e.message,e.details)}if(!(r instanceof Error)){const e="DocException - expected a valid Error.";(0,_util.warn)(e)}t._capability.reject(r)}));e.on("PasswordRequest",e=>{this._passwordCapability=(0,_util.createPromiseCapability)();if(t.onPassword){const updatePassword=e=>{this._passwordCapability.resolve({password:e})};try{t.onPassword(updatePassword,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise});e.on("DataLoaded",e=>{t.onProgress&&t.onProgress({loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)});e.on("StartRenderPage",e=>{if(this.destroyed)return;this.pageCache[e.pageIndex]._startRenderPage(e.transparency,e.intent)});e.on("commonobj",t=>{if(this.destroyed)return;const[r,n,s]=t;if(!this.commonObjs.has(r))switch(n){case"Font":const t=this._params;if("error"in s){const e=s.error;(0,_util.warn)("Error during font loading: "+e);this.commonObjs.resolve(r,e);break}let a=null;t.pdfBug&&globalThis.FontInspector&&globalThis.FontInspector.enabled&&(a={registerFont(e,t){globalThis.FontInspector.fontAdded(e,t)}});const i=new _font_loader.FontFaceObject(s,{isEvalSupported:t.isEvalSupported,disableFontFace:t.disableFontFace,ignoreErrors:t.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:a});this.fontLoader.bind(i).catch(t=>e.sendWithPromise("FontFallback",{id:r})).finally(()=>{!t.fontExtraProperties&&i.data&&(i.data=null);this.commonObjs.resolve(r,i)});break;case"FontPath":case"Image":this.commonObjs.resolve(r,s);break;default:throw new Error("Got unknown common object type "+n)}});e.on("obj",e=>{if(this.destroyed)return;const[t,r,n,s]=e,a=this.pageCache[r];if(!a.objs.has(t))switch(n){case"Image":a.objs.resolve(t,s);const e=8e6;s&&"data"in s&&s.data.length>e&&(a.cleanupAfterRender=!0);break;default:throw new Error("Got unknown object type "+n)}});e.on("DocProgress",e=>{this.destroyed||t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})});e.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this));e.on("FetchBuiltInCMap",(e,t)=>{if(this.destroyed){t.error(new Error("Worker was destroyed"));return}let r=!1;t.onPull=()=>{if(r)t.close();else{r=!0;this.CMapReaderFactory.fetch(e).then((function(e){t.enqueue(e,1,[e.cMapData.buffer])})).catch((function(e){t.error(e)}))}}})}_onUnsupportedFeature({featureId:e}){this.destroyed||this.loadingTask.onUnsupportedFeature&&this.loadingTask.onUnsupportedFeature(e)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request"));const t=e-1;if(t in this.pagePromises)return this.pagePromises[t];const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(e=>{if(this.destroyed)throw new Error("Transport destroyed");const r=new PDFPageProxy(t,e,this,this._params.ownerDocument,this._params.pdfBug);this.pageCache[t]=r;return r});this.pagePromises[t]=r;return r}getPageIndex(e){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:e}).catch((function(e){return Promise.reject(new Error(e))}))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}saveDocument(e){return this.messageHandler.sendWithPromise("SaveDocument",{numPages:this._numPages,annotationStorage:e&&e.getAll()||null,filename:this._fullReader?this._fullReader.filename:null}).finally(()=>{e&&e.resetModified()})}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then(e=>new _optional_content_config.OptionalContentConfig(e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.messageHandler.sendWithPromise("GetMetadata",null).then(e=>({info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:this._fullReader?this._fullReader.filename:null}))}getStats(){return this.messageHandler.sendWithPromise("GetStats",null)}startCleanup(){return this.messageHandler.sendWithPromise("Cleanup",null).then(()=>{for(let e=0,t=this.pageCache.length;e{this._nextBound().catch(this.cancel.bind(this))}):Promise.resolve().then(this._nextBound).catch(this.cancel.bind(this))}async _next(){if(!this.cancelled){this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=!1;if(this.operatorList.lastChunk){this.gfx.endDrawing();this._canvas&&e.delete(this._canvas);this.callback()}}}}}}(),version="2.6.347";exports.version=version;const build="3be9c65f";exports.build=build},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FontLoader=t.FontFaceObject=void 0;var n=r(2);class BaseFontLoader{constructor({docId:e,onUnsupportedFeature:t,ownerDocument:r=globalThis.document}){this.constructor===BaseFontLoader&&(0,n.unreachable)("Cannot initialize BaseFontLoader.");this.docId=e;this._onUnsupportedFeature=t;this._document=r;this.nativeFontFaces=[];this.styleElement=null}addNativeFontFace(e){this.nativeFontFaces.push(e);this._document.fonts.add(e)}insertRule(e){let t=this.styleElement;if(!t){t=this.styleElement=this._document.createElement("style");t.id="PDFJS_FONT_STYLE_TAG_"+this.docId;this._document.documentElement.getElementsByTagName("head")[0].appendChild(t)}const r=t.sheet;r.insertRule(e,r.cssRules.length)}clear(){this.nativeFontFaces.forEach(e=>{this._document.fonts.delete(e)});this.nativeFontFaces.length=0;if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async bind(e){if(e.attached||e.missingFile)return;e.attached=!0;if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(r){this._onUnsupportedFeature({featureId:n.UNSUPPORTED_FEATURES.errorFontLoadNative});(0,n.warn)(`Failed to load font '${t.family}': '${r}'.`);e.disableFontFace=!0;throw r}}return}const t=e.createFontFaceRule();if(t){this.insertRule(t);if(this.isSyncFontLoadingSupported)return;await new Promise(r=>{const n=this._queueLoadingCallback(r);this._prepareFontLoadEvent([t],[e],n)})}}_queueLoadingCallback(e){(0,n.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){const e=void 0!==this._document&&!!this._document.fonts;return(0,n.shadow)(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){(0,n.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,n.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(e,t,r){(0,n.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let s;t.FontLoader=s;t.FontLoader=s=class GenericFontLoader extends BaseFontLoader{constructor(e){super(e);this.loadingContext={requests:[],nextRequestId:0};this.loadTestFontId=0}get isSyncFontLoadingSupported(){let e=!1;if("undefined"==typeof navigator)e=!0;else{const t=/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);t&&t[1]>=14&&(e=!0)}return(0,n.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const t=this.loadingContext,r={id:"pdfjs-font-loading-"+t.nextRequestId++,done:!1,complete:function completeRequest(){(0,n.assert)(!r.done,"completeRequest() cannot be called twice.");r.done=!0;for(;t.requests.length>0&&t.requests[0].done;){const e=t.requests.shift();setTimeout(e.callback,0)}},callback:e};t.requests.push(r);return r}get _loadTestFont(){return(0,n.shadow)(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t,r){function int32(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function spliceString(e,t,r,n){return e.substring(0,t)+n+e.substring(t+r)}let s,a;const i=this._document.createElement("canvas");i.width=1;i.height=1;const o=i.getContext("2d");let l=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=spliceString(h,976,c.length,c);let d=int32(h,16);for(s=0,a=c.length-3;s30){(0,n.warn)("Load test font never loaded.");t();return}o.font="30px "+e;o.fillText(".",0,20);o.getImageData(0,0,1,1).data[3]>0?t():setTimeout(isFontReady.bind(null,e,t))}(c,()=>{this._document.body.removeChild(f);r.complete()})}};t.FontFaceObject=class FontFaceObject{constructor(e,{isEvalSupported:t=!0,disableFontFace:r=!1,ignoreErrors:n=!1,onUnsupportedFeature:s=null,fontRegistry:a=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.isEvalSupported=!1!==t;this.disableFontFace=!0===r;this.ignoreErrors=!0===n;this._onUnsupportedFeature=s;this.fontRegistry=a}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;const e=new FontFace(this.loadedName,this.data,{});this.fontRegistry&&this.fontRegistry.registerFont(this);return e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=(0,n.bytesToString)(new Uint8Array(this.data)),t=`url(data:${this.mimetype};base64,${btoa(e)});`,r=`@font-face {font-family:"${this.loadedName}";src:${t}}`;this.fontRegistry&&this.fontRegistry.registerFont(this,t);return r}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let r,s;try{r=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;this._onUnsupportedFeature&&this._onUnsupportedFeature({featureId:n.UNSUPPORTED_FEATURES.errorFontGetPath});(0,n.warn)(`getPathGenerator - ignoring character: "${e}".`);return this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&n.IsEvalSupportedCached.value){let e,n="";for(let t=0,a=r.length;t{require("fs").readFile(e,(e,s)=>{!e&&s?r({cMapData:new Uint8Array(s),compressionType:t}):n(new Error(e))})})}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationStorage=void 0;t.AnnotationStorage=class AnnotationStorage{constructor(){this._storage=new Map;this._modified=!1;this.onSetModified=null;this.onResetModified=null}getOrCreateValue(e,t){if(this._storage.has(e))return this._storage.get(e);this._storage.set(e,t);return t}setValue(e,t){this._storage.get(e)!==t&&this._setModified();this._storage.set(e,t)}getAll(){return 0===this._storage.size?null:Object.fromEntries(this._storage)}get size(){return this._storage.size}_setModified(){if(!this._modified){this._modified=!0;"function"==typeof this.onSetModified&&this.onSetModified()}}resetModified(){if(this._modified){this._modified=!1;"function"==typeof this.onResetModified&&this.onResetModified()}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.apiCompatibilityParams=void 0;var n=r(4);const s=Object.create(null);!function checkFontFace(){n.isNodeJS&&(s.disableFontFace=!0)}();const a=Object.freeze(s);t.apiCompatibilityParams=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CanvasGraphics=void 0;var n=r(2),s=r(11);function addContextCurrentTransform(e){if(!e.mozCurrentTransform){e._originalSave=e.save;e._originalRestore=e.restore;e._originalRotate=e.rotate;e._originalScale=e.scale;e._originalTranslate=e.translate;e._originalTransform=e.transform;e._originalSetTransform=e.setTransform;e._transformMatrix=e._transformMatrix||[1,0,0,1,0,0];e._transformStack=[];Object.defineProperty(e,"mozCurrentTransform",{get:function getCurrentTransform(){return this._transformMatrix}});Object.defineProperty(e,"mozCurrentTransformInverse",{get:function getCurrentTransformInverse(){var e=this._transformMatrix,t=e[0],r=e[1],n=e[2],s=e[3],a=e[4],i=e[5],o=t*s-r*n,l=r*n-t*s;return[s/o,r/l,n/l,t/o,(s*a-n*i)/l,(r*a-t*i)/o]}});e.save=function ctxSave(){var e=this._transformMatrix;this._transformStack.push(e);this._transformMatrix=e.slice(0,6);this._originalSave()};e.restore=function ctxRestore(){var e=this._transformStack.pop();if(e){this._transformMatrix=e;this._originalRestore()}};e.translate=function ctxTranslate(e,t){var r=this._transformMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5];this._originalTranslate(e,t)};e.scale=function ctxScale(e,t){var r=this._transformMatrix;r[0]=r[0]*e;r[1]=r[1]*e;r[2]=r[2]*t;r[3]=r[3]*t;this._originalScale(e,t)};e.transform=function ctxTransform(t,r,n,s,a,i){var o=this._transformMatrix;this._transformMatrix=[o[0]*t+o[2]*r,o[1]*t+o[3]*r,o[0]*n+o[2]*s,o[1]*n+o[3]*s,o[0]*a+o[2]*i+o[4],o[1]*a+o[3]*i+o[5]];e._originalTransform(t,r,n,s,a,i)};e.setTransform=function ctxSetTransform(t,r,n,s,a,i){this._transformMatrix=[t,r,n,s,a,i];e._originalSetTransform(t,r,n,s,a,i)};e.rotate=function ctxRotate(e){var t=Math.cos(e),r=Math.sin(e),n=this._transformMatrix;this._transformMatrix=[n[0]*t+n[2]*r,n[1]*t+n[3]*r,n[0]*-r+n[2]*t,n[1]*-r+n[3]*t,n[4],n[5]];this._originalRotate(e)}}}var a=function CachedCanvasesClosure(){function CachedCanvases(e){this.canvasFactory=e;this.cache=Object.create(null)}CachedCanvases.prototype={getCanvas:function CachedCanvases_getCanvas(e,t,r,n){var s;if(void 0!==this.cache[e]){s=this.cache[e];this.canvasFactory.reset(s,t,r);s.context.setTransform(1,0,0,1,0,0)}else{s=this.canvasFactory.create(t,r);this.cache[e]=s}n&&addContextCurrentTransform(s.context);return s},clear(){for(var e in this.cache){var t=this.cache[e];this.canvasFactory.destroy(t);delete this.cache[e]}}};return CachedCanvases}();var i=function CanvasExtraStateClosure(){function CanvasExtraState(){this.alphaIsShape=!1;this.fontSize=0;this.fontSizeScale=1;this.textMatrix=n.IDENTITY_MATRIX;this.textMatrixScale=1;this.fontMatrix=n.FONT_IDENTITY_MATRIX;this.leading=0;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRenderingMode=n.TextRenderingMode.FILL;this.textRise=0;this.fillColor="#000000";this.strokeColor="#000000";this.patternFill=!1;this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.activeSMask=null;this.resumeSMaskCtx=null;this.transferMaps=null}CanvasExtraState.prototype={clone:function CanvasExtraState_clone(){return Object.create(this)},setCurrentPoint:function CanvasExtraState_setCurrentPoint(e,t){this.x=e;this.y=t}};return CanvasExtraState}(),o=function CanvasGraphicsClosure(){function CanvasGraphics(e,t,r,n,s,o,l){this.ctx=e;this.current=new i;this.stateStack=[];this.pendingClip=null;this.pendingEOFill=!1;this.res=null;this.xobjs=null;this.commonObjs=t;this.objs=r;this.canvasFactory=n;this.webGLContext=s;this.imageLayer=o;this.groupStack=[];this.processingType3=null;this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.smaskCounter=0;this.tempSMask=null;this.contentVisible=!0;this.markedContentStack=[];this.optionalContentConfig=l;this.cachedCanvases=new a(this.canvasFactory);e&&addContextCurrentTransform(e);this._cachedGetSinglePixelWidth=null}function putBinaryImageData(e,t,r=null){if("undefined"!=typeof ImageData&&t instanceof ImageData){e.putImageData(t,0,0);return}var s,a,i,o,l,c=t.height,h=t.width,d=c%16,u=(c-d)/16,p=0===d?u:u+1,f=e.createImageData(h,16),g=0,m=t.data,_=f.data;let A,b,y,v;if(r)switch(r.length){case 1:A=r[0];b=r[0];y=r[0];v=r[0];break;case 4:A=r[0];b=r[1];y=r[2];v=r[3]}if(t.kind===n.ImageKind.GRAYSCALE_1BPP){var C=m.byteLength,S=new Uint32Array(_.buffer,0,_.byteLength>>2),x=S.length,P=h+7>>3,k=4294967295,R=n.IsLittleEndianCached.value?4278190080:255;v&&255===v[0]&&0===v[255]&&([k,R]=[R,k]);for(a=0;aP?h:8*w-7,E=-8&T,F=0,L=0;e>=1}}for(;s=u&&(l=h*(o=d));s=0;for(i=l;i--;){_[s++]=m[g++];_[s++]=m[g++];_[s++]=m[g++];_[s++]=255}if(t)for(let e=0;e>=1}e.putImageData(o,0,16*d)}}function copyCtxState(e,t){for(var r=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"],n=0,s=r.length;n>8;e[a-2]=e[a-2]*i+r*o>>8;e[a-1]=e[a-1]*i+n*o>>8}}}function composeSMaskAlpha(e,t,r){for(var n=e.length,s=3;s>8]>>8:t[s]*a>>16}}function composeSMask(e,t,r,n){var s=t.canvas,a=t.context;e.setTransform(t.scaleX,0,0,t.scaleY,t.offsetX,t.offsetY);var i=t.backdrop||null;if(t.transferMap||!n.isEnabled){!function genericComposeSMask(e,t,r,n,s,a,i){var o,l=!!a,c=l?a[0]:0,h=l?a[1]:0,d=l?a[2]:0;o="Luminosity"===s?composeSMaskLuminosity:composeSMaskAlpha;for(var u=Math.min(n,Math.ceil(1048576/r)),p=0;p10&&"function"==typeof r,d=h?Date.now()+15:0,u=0,p=this.commonObjs,f=this.objs;;){if(void 0!==s&&o===s.nextBreakPoint){s.breakIt(o,r);return o}if((c=i[o])!==n.OPS.dependency)this[c].apply(this,a[o]);else for(const e of a[o]){const t=e.startsWith("g_")?p:f;if(!t.has(e)){t.get(e,r);return o}}if(++o===l)return o;if(h&&++u>10){if(Date.now()>d){r();return o}u=0}}},endDrawing:function CanvasGraphics_endDrawing(){null!==this.current.activeSMask&&this.endSMaskGroup();this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.transparentCanvas=null}this.cachedCanvases.clear();this.webGLContext.clear();this.imageLayer&&this.imageLayer.endLayout()},setLineWidth:function CanvasGraphics_setLineWidth(e){this.current.lineWidth=e;this.ctx.lineWidth=e},setLineCap:function CanvasGraphics_setLineCap(t){this.ctx.lineCap=e[t]},setLineJoin:function CanvasGraphics_setLineJoin(e){this.ctx.lineJoin=t[e]},setMiterLimit:function CanvasGraphics_setMiterLimit(e){this.ctx.miterLimit=e},setDash:function CanvasGraphics_setDash(e,t){var r=this.ctx;if(void 0!==r.setLineDash){r.setLineDash(e);r.lineDashOffset=t}},setRenderingIntent(e){},setFlatness(e){},setGState:function CanvasGraphics_setGState(e){for(var t=0,r=e.length;t0&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask?this.suspendSMaskGroup():this.endSMaskGroup());this.current.activeSMask=a?this.tempSMask:null;this.current.activeSMask&&this.beginSMaskGroup();this.tempSMask=null;break;case"TR":this.current.transferMaps=a}}},beginSMaskGroup:function CanvasGraphics_beginSMaskGroup(){var e=this.current.activeSMask,t=e.canvas.width,r=e.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,t,r,!0),a=this.ctx,i=a.mozCurrentTransform;this.ctx.save();var o=s.context;o.scale(1/e.scaleX,1/e.scaleY);o.translate(-e.offsetX,-e.offsetY);o.transform.apply(o,i);e.startTransformInverse=o.mozCurrentTransformInverse;copyCtxState(a,o);this.ctx=o;this.setGState([["BM","source-over"],["ca",1],["CA",1]]);this.groupStack.push(a);this.groupLevel++},suspendSMaskGroup:function CanvasGraphics_endSMaskGroup(){var e=this.ctx;this.groupLevel--;this.ctx=this.groupStack.pop();composeSMask(this.ctx,this.current.activeSMask,e,this.webGLContext);this.ctx.restore();this.ctx.save();copyCtxState(e,this.ctx);this.current.resumeSMaskCtx=e;var t=n.Util.transform(this.current.activeSMask.startTransformInverse,e.mozCurrentTransform);this.ctx.transform.apply(this.ctx,t);e.save();e.setTransform(1,0,0,1,0,0);e.clearRect(0,0,e.canvas.width,e.canvas.height);e.restore()},resumeSMaskGroup:function CanvasGraphics_endSMaskGroup(){var e=this.current.resumeSMaskCtx,t=this.ctx;this.ctx=e;this.groupStack.push(t);this.groupLevel++},endSMaskGroup:function CanvasGraphics_endSMaskGroup(){var e=this.ctx;this.groupLevel--;this.ctx=this.groupStack.pop();composeSMask(this.ctx,this.current.activeSMask,e,this.webGLContext);this.ctx.restore();copyCtxState(e,this.ctx);var t=n.Util.transform(this.current.activeSMask.startTransformInverse,e.mozCurrentTransform);this.ctx.transform.apply(this.ctx,t)},save:function CanvasGraphics_save(){this.ctx.save();var e=this.current;this.stateStack.push(e);this.current=e.clone();this.current.resumeSMaskCtx=null},restore:function CanvasGraphics_restore(){this.current.resumeSMaskCtx&&this.resumeSMaskGroup();null===this.current.activeSMask||0!==this.stateStack.length&&this.stateStack[this.stateStack.length-1].activeSMask===this.current.activeSMask||this.endSMaskGroup();if(0!==this.stateStack.length){this.current=this.stateStack.pop();this.ctx.restore();this.pendingClip=null;this._cachedGetSinglePixelWidth=null}},transform:function CanvasGraphics_transform(e,t,r,n,s,a){this.ctx.transform(e,t,r,n,s,a);this._cachedGetSinglePixelWidth=null},constructPath:function CanvasGraphics_constructPath(e,t){for(var r=this.ctx,s=this.current,a=s.x,i=s.y,o=0,l=0,c=e.length;o100&&(c=100);this.current.fontSizeScale=t/c;this.ctx.font=`${o} ${i} ${c}px ${l}`},setTextRenderingMode:function CanvasGraphics_setTextRenderingMode(e){this.current.textRenderingMode=e},setTextRise:function CanvasGraphics_setTextRise(e){this.current.textRise=e},moveText:function CanvasGraphics_moveText(e,t){this.current.x=this.current.lineX+=e;this.current.y=this.current.lineY+=t},setLeadingMoveText:function CanvasGraphics_setLeadingMoveText(e,t){this.setLeading(-t);this.moveText(e,t)},setTextMatrix:function CanvasGraphics_setTextMatrix(e,t,r,n,s,a){this.current.textMatrix=[e,t,r,n,s,a];this.current.textMatrixScale=Math.sqrt(e*e+t*t);this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0},nextLine:function CanvasGraphics_nextLine(){this.moveText(0,this.current.leading)},paintChar(e,t,r,s){var a=this.ctx,i=this.current,o=i.font,l=i.textRenderingMode,c=i.fontSize/i.fontSizeScale,h=l&n.TextRenderingMode.FILL_STROKE_MASK,d=!!(l&n.TextRenderingMode.ADD_TO_PATH_FLAG);const u=i.patternFill&&!o.missingFile;var p;(o.disableFontFace||d||u)&&(p=o.getPathGenerator(this.commonObjs,e));if(o.disableFontFace||u){a.save();a.translate(t,r);a.beginPath();p(a,c);s&&a.setTransform.apply(a,s);h!==n.TextRenderingMode.FILL&&h!==n.TextRenderingMode.FILL_STROKE||a.fill();h!==n.TextRenderingMode.STROKE&&h!==n.TextRenderingMode.FILL_STROKE||a.stroke();a.restore()}else{h!==n.TextRenderingMode.FILL&&h!==n.TextRenderingMode.FILL_STROKE||a.fillText(e,t,r);h!==n.TextRenderingMode.STROKE&&h!==n.TextRenderingMode.FILL_STROKE||a.strokeText(e,t,r)}if(d){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:a.mozCurrentTransform,x:t,y:r,fontSize:c,addToPath:p})}},get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1);e.fillText("I",0,10);for(var t=e.getImageData(0,0,10,10).data,r=!1,s=3;s0&&t[s]<255){r=!0;break}return(0,n.shadow)(this,"isFontSubpixelAAEnabled",r)},showText:function CanvasGraphics_showText(e){var t=this.current,r=t.font;if(r.isType3Font)return this.showType3Text(e);var s=t.fontSize;if(0===s)return;var a=this.ctx,i=t.fontSizeScale,o=t.charSpacing,l=t.wordSpacing,c=t.fontDirection,h=t.textHScale*c,d=e.length,u=r.vertical,p=u?1:-1,f=r.defaultVMetrics,g=s*t.fontMatrix[0],m=t.textRenderingMode===n.TextRenderingMode.FILL&&!r.disableFontFace&&!t.patternFill;a.save();let _;if(t.patternFill){a.save();const e=t.fillColor.getPattern(a,this);_=a.mozCurrentTransform;a.restore();a.fillStyle=e}a.transform.apply(a,t.textMatrix);a.translate(t.x,t.y+t.textRise);c>0?a.scale(h,-1):a.scale(h,1);var A=t.lineWidth,b=t.textMatrixScale;if(0===b||0===A){var y=t.textRenderingMode&n.TextRenderingMode.FILL_STROKE_MASK;if(y===n.TextRenderingMode.STROKE||y===n.TextRenderingMode.FILL_STROKE){this._cachedGetSinglePixelWidth=null;A=.65*this.getSinglePixelWidth()}}else A/=b;if(1!==i){a.scale(i,i);A/=i}a.lineWidth=A;var v,C=0;for(v=0;v0){var I=1e3*a.measureText(E).width/s*i;if(Lnew CanvasGraphics(e,this.commonObjs,this.objs,this.canvasFactory,this.webGLContext)};t=new s.TilingPattern(e,r,this.ctx,a,n)}else t=(0,s.getShadingPatternFromIR)(e);return t},setStrokeColorN:function CanvasGraphics_setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)},setFillColorN:function CanvasGraphics_setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments);this.current.patternFill=!0},setStrokeRGBColor:function CanvasGraphics_setStrokeRGBColor(e,t,r){var s=n.Util.makeCssRgb(e,t,r);this.ctx.strokeStyle=s;this.current.strokeColor=s},setFillRGBColor:function CanvasGraphics_setFillRGBColor(e,t,r){var s=n.Util.makeCssRgb(e,t,r);this.ctx.fillStyle=s;this.current.fillColor=s;this.current.patternFill=!1},shadingFill:function CanvasGraphics_shadingFill(e){if(this.contentVisible){var t=this.ctx;this.save();var r=(0,s.getShadingPatternFromIR)(e);t.fillStyle=r.getPattern(t,this,!0);var a=t.mozCurrentTransformInverse;if(a){var i=t.canvas,o=i.width,l=i.height,c=n.Util.applyTransform([0,0],a),h=n.Util.applyTransform([0,l],a),d=n.Util.applyTransform([o,0],a),u=n.Util.applyTransform([o,l],a),p=Math.min(c[0],h[0],d[0],u[0]),f=Math.min(c[1],h[1],d[1],u[1]),g=Math.max(c[0],h[0],d[0],u[0]),m=Math.max(c[1],h[1],d[1],u[1]);this.ctx.fillRect(p,f,g-p,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.restore()}},beginInlineImage:function CanvasGraphics_beginInlineImage(){(0,n.unreachable)("Should not call beginInlineImage")},beginImageData:function CanvasGraphics_beginImageData(){(0,n.unreachable)("Should not call beginImageData")},paintFormXObjectBegin:function CanvasGraphics_paintFormXObjectBegin(e,t){if(this.contentVisible){this.save();this.baseTransformStack.push(this.baseTransform);Array.isArray(e)&&6===e.length&&this.transform.apply(this,e);this.baseTransform=this.ctx.mozCurrentTransform;if(t){var r=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],r,n);this.clip();this.endPath()}}},paintFormXObjectEnd:function CanvasGraphics_paintFormXObjectEnd(){if(this.contentVisible){this.restore();this.baseTransform=this.baseTransformStack.pop()}},beginGroup:function CanvasGraphics_beginGroup(e){if(this.contentVisible){this.save();var t=this.ctx;e.isolated||(0,n.info)("TODO: Support non-isolated groups.");e.knockout&&(0,n.warn)("Knockout groups not supported.");var r=t.mozCurrentTransform;e.matrix&&t.transform.apply(t,e.matrix);if(!e.bbox)throw new Error("Bounding box is required.");var s=n.Util.getAxialAlignedBoundingBox(e.bbox,t.mozCurrentTransform),a=[0,0,t.canvas.width,t.canvas.height];s=n.Util.intersect(s,a)||[0,0,0,0];var i=Math.floor(s[0]),o=Math.floor(s[1]),l=Math.max(Math.ceil(s[2])-i,1),c=Math.max(Math.ceil(s[3])-o,1),h=1,d=1;if(l>4096){h=l/4096;l=4096}if(c>4096){d=c/4096;c=4096}var u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);var p=this.cachedCanvases.getCanvas(u,l,c,!0),f=p.context;f.scale(1/h,1/d);f.translate(-i,-o);f.transform.apply(f,r);if(e.smask)this.smaskStack.push({canvas:p.canvas,context:f,offsetX:i,offsetY:o,scaleX:h,scaleY:d,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null});else{t.setTransform(1,0,0,1,0,0);t.translate(i,o);t.scale(h,d)}copyCtxState(t,f);this.ctx=f;this.setGState([["BM","source-over"],["ca",1],["CA",1]]);this.groupStack.push(t);this.groupLevel++;this.current.activeSMask=null}},endGroup:function CanvasGraphics_endGroup(e){if(this.contentVisible){this.groupLevel--;var t=this.ctx;this.ctx=this.groupStack.pop();void 0!==this.ctx.imageSmoothingEnabled?this.ctx.imageSmoothingEnabled=!1:this.ctx.mozImageSmoothingEnabled=!1;e.smask?this.tempSMask=this.smaskStack.pop():this.ctx.drawImage(t.canvas,0,0);this.restore()}},beginAnnotations:function CanvasGraphics_beginAnnotations(){this.save();this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)},endAnnotations:function CanvasGraphics_endAnnotations(){this.restore()},beginAnnotation:function CanvasGraphics_beginAnnotation(e,t,r){this.save();resetCtxToDefault(this.ctx);this.current=new i;if(Array.isArray(e)&&4===e.length){var n=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],n,s);this.clip();this.endPath()}this.transform.apply(this,t);this.transform.apply(this,r)},endAnnotation:function CanvasGraphics_endAnnotation(){this.restore()},paintImageMaskXObject:function CanvasGraphics_paintImageMaskXObject(e){if(this.contentVisible){var t=this.ctx,r=e.width,n=e.height,s=this.current.fillColor,a=this.current.patternFill,i=this.processingType3;i&&void 0===i.compiled&&(i.compiled=r<=1e3&&n<=1e3?function compileType3Glyph(e){var t,r,n,s,a=e.width,i=e.height,o=a+1,l=new Uint8Array(o*(i+1)),c=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),h=a+7&-8,d=e.data,u=new Uint8Array(h*i),p=0;for(t=0,s=d.length;t0;){u[p++]=g&f?0:255;f>>=1}var m=0;if(0!==u[p=0]){l[0]=1;++m}for(r=1;r>2)+(u[p+1]?4:0)+(u[p-h+1]?8:0)]){l[n+r]=c[_];++m}p++}if(u[p-h]!==u[p]){l[n+r]=u[p]?2:4;++m}if(m>1e3)return null}n=t*o;if(0!==u[p=h*(i-1)]){l[n]=8;++m}for(r=1;r1e3)return null;var A=new Int32Array([0,o,-1,0,-o,0,0,0,1]),b=[];for(t=0;m&&t<=i;t++){for(var y=t*o,v=y+a;y>4;l[y]&=x>>2|x<<2}S.push(y%o);S.push(y/o|0);l[y]||--m}while(P!==y);b.push(S);--t}}return function(e){e.save();e.scale(1/a,-1/i);e.translate(0,-i);e.beginPath();for(let r=0,n=b.length;r2&&f>1||u>2&&g>1;){var _=f,A=g;c>2&&f>1&&(c/=f/(_=Math.ceil(f/2)));u>2&&g>1&&(u/=g/(A=Math.ceil(g/2)));(p=(a=this.cachedCanvases.getCanvas(m,_,A)).context).clearRect(0,0,_,A);p.drawImage(s,0,0,f,g,0,0,_,A);s=a.canvas;f=_;g=A;m="prescale1"===m?"prescale2":"prescale1"}n.drawImage(s,0,0,f,g,0,-r,t,r);if(this.imageLayer){var b=this.getCanvasPosition(0,-r);this.imageLayer.appendImage({imgData:e,left:b[0],top:b[1],width:t/i[0],height:r/i[3]})}this.restore()}},paintInlineImageXObjectGroup:function CanvasGraphics_paintInlineImageXObjectGroup(e,t){if(this.contentVisible){var r=this.ctx,n=e.width,s=e.height,a=this.cachedCanvases.getCanvas("inlineImage",n,s);putBinaryImageData(a.context,e,this.current.transferMaps);for(var i=0,o=t.length;i=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}};for(var l in n.OPS)CanvasGraphics.prototype[n.OPS[l]]=CanvasGraphics.prototype[l];return CanvasGraphics}();t.CanvasGraphics=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getShadingPatternFromIR=function getShadingPatternFromIR(e){var t=s[e[0]];if(!t)throw new Error("Unknown IR type: "+e[0]);return t.fromIR(e)};t.TilingPattern=void 0;var n=r(2),s={};function applyBoundingBox(e,t){if(!t||"undefined"==typeof Path2D)return;const r=t[2]-t[0],n=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],r,n);e.clip(s)}s.RadialAxial={fromIR:function RadialAxial_fromIR(e){var t=e[1],r=e[2],n=e[3],s=e[4],a=e[5],i=e[6],o=e[7];return{type:"Pattern",getPattern:function RadialAxial_getPattern(e){applyBoundingBox(e,r);var l;"axial"===t?l=e.createLinearGradient(s[0],s[1],a[0],a[1]):"radial"===t&&(l=e.createRadialGradient(s[0],s[1],i,a[0],a[1],o));for(var c=0,h=n.length;cc[n+1]){l=r;r=n;n=l;l=a;a=i;i=l}if(c[n+1]>c[s+1]){l=n;n=s;s=l;l=i;i=o;o=l}if(c[r+1]>c[n+1]){l=r;r=n;n=l;l=a;a=i;i=l}var p=(c[r]+t.offsetX)*t.scaleX,f=(c[r+1]+t.offsetY)*t.scaleY,g=(c[n]+t.offsetX)*t.scaleX,m=(c[n+1]+t.offsetY)*t.scaleY,_=(c[s]+t.offsetX)*t.scaleX,A=(c[s+1]+t.offsetY)*t.scaleY;if(!(f>=A))for(var b,y,v,C,S,x,P,k,R=h[a],w=h[a+1],T=h[a+2],E=h[i],F=h[i+1],L=h[i+2],M=h[o],D=h[o+1],O=h[o+2],I=Math.round(f),N=Math.round(A),j=I;j<=N;j++){if(jA?1:m===A?0:(m-j)/(m-A);b=g-(g-_)*e;y=E-(E-M)*e;v=F-(F-D)*e;C=L-(L-O)*e}let e;e=jA?1:(f-j)/(f-A);S=p-(p-_)*e;x=R-(R-M)*e;P=w-(w-D)*e;k=T-(T-O)*e;for(var G=Math.round(Math.min(b,S)),U=Math.round(Math.max(b,S)),W=u*j+4*G,q=G;q<=U;q++){e=(b-q)/(b-S);e<0?e=0:e>1&&(e=1);d[W++]=y-(y-x)*e|0;d[W++]=v-(v-P)*e|0;d[W++]=C-(C-k)*e|0;d[W++]=255}}}function drawFigure(e,t,r){var n,s,a=t.coords,i=t.colors;switch(t.type){case"lattice":var o=t.verticesPerRow,l=Math.floor(a.length/o)-1,c=o-1;for(n=0;n=n?s=n:r=s/e;return{scale:r,size:s}},clipBbox:function clipBbox(e,t,r,n,s,a){if(Array.isArray(t)&&4===t.length){var i=s-r,o=a-n;e.ctx.rect(r,n,i,o);e.clip();e.endPath()}},setFillAndStrokeStyleToContext:function setFillAndStrokeStyleToContext(r,s,a){const i=r.ctx,o=r.current;switch(s){case e:var l=this.ctx;i.fillStyle=l.fillStyle;i.strokeStyle=l.strokeStyle;o.fillColor=l.fillStyle;o.strokeColor=l.strokeStyle;break;case t:var c=n.Util.makeCssRgb(a[0],a[1],a[2]);i.fillStyle=c;i.strokeStyle=c;o.fillColor=c;o.strokeColor=c;break;default:throw new n.FormatError("Unsupported paint type: "+s)}},getPattern:function TilingPattern_getPattern(e,t){(e=this.ctx).setTransform.apply(e,this.baseTransform);e.transform.apply(e,this.matrix);var r=this.createPatternCanvas(t);return e.createPattern(r,"repeat")}};return TilingPattern}();t.TilingPattern=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.GlobalWorkerOptions=void 0;const n=Object.create(null);t.GlobalWorkerOptions=n;n.workerPort=void 0===n.workerPort?null:n.workerPort;n.workerSrc=void 0===n.workerSrc?"":n.workerSrc},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.MessageHandler=void 0;var n=r(2);const s=1,a=2,i=1,o=2,l=3,c=4,h=5,d=6,u=7,p=8;function wrapReason(e){if("object"!=typeof e||null===e)return e;switch(e.name){case"AbortException":return new n.AbortException(e.message);case"MissingPDFException":return new n.MissingPDFException(e.message);case"UnexpectedResponseException":return new n.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new n.UnknownErrorException(e.message,e.details);default:return new n.UnknownErrorException(e.message,e.toString())}}t.MessageHandler=class MessageHandler{constructor(e,t,r){this.sourceName=e;this.targetName=t;this.comObj=r;this.callbackId=1;this.streamId=1;this.postMessageTransfers=!0;this.streamSinks=Object.create(null);this.streamControllers=Object.create(null);this.callbackCapabilities=Object.create(null);this.actionHandler=Object.create(null);this._onComObjOnMessage=e=>{const t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){this._processStreamMessage(t);return}if(t.callback){const e=t.callbackId,r=this.callbackCapabilities[e];if(!r)throw new Error("Cannot resolve callback "+e);delete this.callbackCapabilities[e];if(t.callback===s)r.resolve(t.data);else{if(t.callback!==a)throw new Error("Unexpected callback case");r.reject(wrapReason(t.reason))}return}const n=this.actionHandler[t.action];if(!n)throw new Error("Unknown action from worker: "+t.action);if(t.callbackId){const e=this.sourceName,i=t.sourceName;new Promise((function(e){e(n(t.data))})).then((function(n){r.postMessage({sourceName:e,targetName:i,callback:s,callbackId:t.callbackId,data:n})}),(function(n){r.postMessage({sourceName:e,targetName:i,callback:a,callbackId:t.callbackId,reason:wrapReason(n)})}))}else t.streamId?this._createStreamSink(t):n(t.data)};r.addEventListener("message",this._onComObjOnMessage)}on(e,t){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=t}send(e,t,r){this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},r)}sendWithPromise(e,t,r){const s=this.callbackId++,a=(0,n.createPromiseCapability)();this.callbackCapabilities[s]=a;try{this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:t},r)}catch(e){a.reject(e)}return a.promise}sendWithStream(e,t,r,s){const a=this.streamId++,o=this.sourceName,l=this.targetName,c=this.comObj;return new ReadableStream({start:r=>{const i=(0,n.createPromiseCapability)();this.streamControllers[a]={controller:r,startCall:i,pullCall:null,cancelCall:null,isClosed:!1};this._postMessage({sourceName:o,targetName:l,action:e,streamId:a,data:t,desiredSize:r.desiredSize},s);return i.promise},pull:e=>{const t=(0,n.createPromiseCapability)();this.streamControllers[a].pullCall=t;c.postMessage({sourceName:o,targetName:l,stream:d,streamId:a,desiredSize:e.desiredSize});return t.promise},cancel:e=>{(0,n.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,n.createPromiseCapability)();this.streamControllers[a].cancelCall=t;this.streamControllers[a].isClosed=!0;c.postMessage({sourceName:o,targetName:l,stream:i,streamId:a,reason:wrapReason(e)});return t.promise}},r)}_createStreamSink(e){const t=this,r=this.actionHandler[e.action],s=e.streamId,a=this.sourceName,i=e.sourceName,o=this.comObj,d={enqueue(e,r=1,o){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=r;if(l>0&&this.desiredSize<=0){this.sinkCapability=(0,n.createPromiseCapability)();this.ready=this.sinkCapability.promise}t._postMessage({sourceName:a,targetName:i,stream:c,streamId:s,chunk:e},o)},close(){if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:a,targetName:i,stream:l,streamId:s});delete t.streamSinks[s]}},error(e){(0,n.assert)(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:a,targetName:i,stream:h,streamId:s,reason:wrapReason(e)})}},sinkCapability:(0,n.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};d.sinkCapability.resolve();d.ready=d.sinkCapability.promise;this.streamSinks[s]=d;new Promise((function(t){t(r(e.data,d))})).then((function(){o.postMessage({sourceName:a,targetName:i,stream:p,streamId:s,success:!0})}),(function(e){o.postMessage({sourceName:a,targetName:i,stream:p,streamId:s,reason:wrapReason(e)})}))}_processStreamMessage(e){const t=e.streamId,r=this.sourceName,s=e.sourceName,a=this.comObj;switch(e.stream){case p:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(wrapReason(e.reason));break;case u:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(wrapReason(e.reason));break;case d:if(!this.streamSinks[t]){a.postMessage({sourceName:r,targetName:s,stream:u,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:f}=this.streamSinks[e.streamId];new Promise((function(e){e(f&&f())})).then((function(){a.postMessage({sourceName:r,targetName:s,stream:u,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:r,targetName:s,stream:u,streamId:t,reason:wrapReason(e)})}));break;case c:(0,n.assert)(this.streamControllers[t],"enqueue should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case l:(0,n.assert)(this.streamControllers[t],"close should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].isClosed=!0;this.streamControllers[t].controller.close();this._deleteStreamController(t);break;case h:(0,n.assert)(this.streamControllers[t],"error should have stream controller");this.streamControllers[t].controller.error(wrapReason(e.reason));this._deleteStreamController(t);break;case o:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(wrapReason(e.reason));this._deleteStreamController(t);break;case i:if(!this.streamSinks[t])break;const{onCancel:g}=this.streamSinks[e.streamId];new Promise((function(t){t(g&&g(wrapReason(e.reason)))})).then((function(){a.postMessage({sourceName:r,targetName:s,stream:o,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:r,targetName:s,stream:o,streamId:t,reason:wrapReason(e)})}));this.streamSinks[t].sinkCapability.reject(wrapReason(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,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Metadata=void 0;var n=r(2),s=r(15);t.Metadata=class Metadata{constructor(e){(0,n.assert)("string"==typeof e,"Metadata: input is not a string");e=this._repair(e);const t=(new s.SimpleXMLParser).parseFromString(e);this._metadataMap=new Map;t&&this._parse(t)}_repair(e){return e.replace(/^[^<]+/,"").replace(/>\\376\\377([^<]+)/g,(function(e,t){const r=t.replace(/\\([0-3])([0-7])([0-7])/g,(function(e,t,r,n){return String.fromCharCode(64*t+8*r+1*n)})).replace(/&(amp|apos|gt|lt|quot);/g,(function(e,t){switch(t){case"amp":return"&";case"apos":return"'";case"gt":return">";case"lt":return"<";case"quot":return'"'}throw new Error(`_repair: ${t} isn't defined.`)}));let n="";for(let e=0,t=r.length;e=32&&t<127&&60!==t&&62!==t&&38!==t?String.fromCharCode(t):"&#x"+(65536+t).toString(16).substring(1)+";"}return">"+n}))}_parse(e){let t=e.documentElement;if("rdf:rdf"!==t.nodeName.toLowerCase()){t=t.firstChild;for(;t&&"rdf:rdf"!==t.nodeName.toLowerCase();)t=t.nextSibling}const r=t?t.nodeName.toLowerCase():null;if(!t||"rdf:rdf"!==r||!t.hasChildNodes())return;const n=t.childNodes;for(let e=0,t=n.length;e0}}t.SimpleXMLParser=class SimpleXMLParser extends class XMLParserBase{_resolveEntities(e){return e.replace(/&([^;]+);/g,(e,t)=>{if("#x"===t.substring(0,2))return String.fromCharCode(parseInt(t.substring(2),16));if("#"===t.substring(0,1))return String.fromCharCode(parseInt(t.substring(1),10));switch(t){case"lt":return"<";case"gt":return">";case"amp":return"&";case"quot":return'"'}return this.onResolveEntity(t)})}_parseContent(e,t){const r=[];let n=t;function skipWs(){for(;n"!==e[n]&&"/"!==e[n];)++n;const s=e.substring(t,n);skipWs();for(;n"!==e[n]&&"/"!==e[n]&&"?"!==e[n];){skipWs();let t="",s="";for(;n"!==e[r]&&"/"!==e[r];)++r;const n=e.substring(t,r);!function skipWs(){for(;r"!==e[r+1]);)++r;return{name:n,value:e.substring(s,r),parsed:r-t}}parseXml(e){let t=0;for(;t",r);if(t<0){this.onError(c);return}this.onEndElement(e.substring(r,t));r=t+1;break;case"?":++r;const n=this._parseProcessingInstruction(e,r);if("?>"!==e.substring(r+n.parsed,r+n.parsed+2)){this.onError(a);return}this.onPi(n.name,n.value);r+=n.parsed+2;break;case"!":if("--"===e.substring(r+1,r+3)){t=e.indexOf("--\x3e",r+3);if(t<0){this.onError(o);return}this.onComment(e.substring(r+3,t));r=t+3}else if("[CDATA["===e.substring(r+1,r+8)){t=e.indexOf("]]>",r+8);if(t<0){this.onError(s);return}this.onCdata(e.substring(r+8,t));r=t+3}else{if("DOCTYPE"!==e.substring(r+1,r+8)){this.onError(l);return}{const n=e.indexOf("[",r+8);let s=!1;t=e.indexOf(">",r+8);if(t<0){this.onError(i);return}if(n>0&&t>n){t=e.indexOf("]>",r+8);if(t<0){this.onError(i);return}s=!0}const a=e.substring(r+8,t+(s?1:0));this.onDoctype(a);r=t+(s?2:1)}}break;default:const h=this._parseContent(e,r);if(null===h){this.onError(l);return}let d=!1;if("/>"===e.substring(r+h.parsed,r+h.parsed+2))d=!0;else if(">"!==e.substring(r+h.parsed,r+h.parsed+1)){this.onError(c);return}this.onBeginElement(h.name,h.attributes,d);r+=h.parsed+(d?2:1)}}else{for(;r0){const e=new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=t;this._isStreamingSupported=!e.disableStream;this._isRangeSupported=!e.disableRange;this._contentLength=e.length;this._fullRequestReader=null;this._rangeReaders=[];this._pdfDataRangeTransport.addRangeListener((e,t)=>{this._onReceiveData({begin:e,chunk:t})});this._pdfDataRangeTransport.addProgressListener((e,t)=>{this._onProgress({loaded:e,total:t})});this._pdfDataRangeTransport.addProgressiveReadListener(e=>{this._onReceiveData({chunk:e})});this._pdfDataRangeTransport.addProgressiveDoneListener(()=>{this._onProgressiveDone()});this._pdfDataRangeTransport.transportReady()}_onReceiveData(e){const t=new Uint8Array(e.chunk).buffer;if(void 0===e.begin)this._fullRequestReader?this._fullRequestReader._enqueue(t):this._queuedChunks.push(t);else{const r=this._rangeReaders.some((function(r){if(r._begin!==e.begin)return!1;r._enqueue(t);return!0}));(0,n.assert)(r,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}_onProgress(e){if(void 0===e.total){const t=this._rangeReaders[0];t&&t.onProgress&&t.onProgress({loaded:e.loaded})}else{const t=this._fullRequestReader;t&&t.onProgress&&t.onProgress({loaded:e.loaded,total:e.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone();this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;this._queuedChunks=null;return new PDFDataTransportStreamReader(this,e,this._progressiveDone)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=new PDFDataTransportStreamRangeReader(this,e,t);this._pdfDataRangeTransport.requestDataRange(e,t);this._rangeReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeReaders.slice(0).forEach((function(t){t.cancel(e)}));this._pdfDataRangeTransport.abort()}};class PDFDataTransportStreamReader{constructor(e,t,r=!1){this._stream=e;this._done=r||!1;this._filename=null;this._queuedChunks=t||[];this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[];this._headersReady=Promise.resolve();e._fullRequestReader=this;this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,n.createPromiseCapability)();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[]}progressiveDone(){this._done||(this._done=!0)}}class PDFDataTransportStreamRangeReader{constructor(e,t,r){this._stream=e;this._begin=t;this._end=r;this._queuedChunk=null;this._requests=[];this._done=!1;this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[]}this._done=!0;this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,n.createPromiseCapability)();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[];this._stream._removeRangeReader(this)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.WebGLContext=void 0;var n=r(2);t.WebGLContext=class WebGLContext{constructor({enable:e=!1}){this._enabled=!0===e}get isEnabled(){let e=this._enabled;e&&(e=s.tryInitGL());return(0,n.shadow)(this,"isEnabled",e)}composeSMask({layer:e,mask:t,properties:r}){return s.composeSMask(e,t,r)}drawFigures({width:e,height:t,backgroundColor:r,figures:n,context:a}){return s.drawFigures(e,t,r,n,a)}clear(){s.cleanup()}};var s=function WebGLUtilsClosure(){function loadShader(e,t,r){var n=e.createShader(r);e.shaderSource(n,t);e.compileShader(n);if(!e.getShaderParameter(n,e.COMPILE_STATUS)){var s=e.getShaderInfoLog(n);throw new Error("Error during shader compilation: "+s)}return n}function createVertexShader(e,t){return loadShader(e,t,e.VERTEX_SHADER)}function createFragmentShader(e,t){return loadShader(e,t,e.FRAGMENT_SHADER)}function createProgram(e,t){for(var r=e.createProgram(),n=0,s=t.length;n 0.0) { maskColor.rgb = maskColor.rgb * maskColor.a + u_backdrop.rgb * (1.0 - maskColor.a); } float lum; if (u_subtype == 0) { lum = maskColor.a; } else { lum = maskColor.r * 0.3 + maskColor.g * 0.59 + maskColor.b * 0.11; } imageColor.a *= lum; imageColor.rgb *= imageColor.a; gl_FragColor = imageColor; } ")]);s.useProgram(a);var i={};i.gl=s;i.canvas=n;i.resolutionLocation=s.getUniformLocation(a,"u_resolution");i.positionLocation=s.getAttribLocation(a,"a_position");i.backdropLocation=s.getUniformLocation(a,"u_backdrop");i.subtypeLocation=s.getUniformLocation(a,"u_subtype");var o=s.getAttribLocation(a,"a_texCoord"),l=s.getUniformLocation(a,"u_image"),c=s.getUniformLocation(a,"u_mask"),h=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,h);s.bufferData(s.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),s.STATIC_DRAW);s.enableVertexAttribArray(o);s.vertexAttribPointer(o,2,s.FLOAT,!1,0,0);s.uniform1i(l,0);s.uniform1i(c,1);r=i}();var l=r,c=l.canvas,h=l.gl;c.width=i;c.height=o;h.viewport(0,0,h.drawingBufferWidth,h.drawingBufferHeight);h.uniform2f(l.resolutionLocation,i,o);a.backdrop?h.uniform4f(l.resolutionLocation,a.backdrop[0],a.backdrop[1],a.backdrop[2],1):h.uniform4f(l.resolutionLocation,0,0,0,0);h.uniform1i(l.subtypeLocation,"Luminosity"===a.subtype?1:0);var d=createTexture(h,n,h.TEXTURE0),u=createTexture(h,s,h.TEXTURE1),p=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,p);h.bufferData(h.ARRAY_BUFFER,new Float32Array([0,0,i,0,0,o,0,o,i,0,i,o]),h.STATIC_DRAW);h.enableVertexAttribArray(l.positionLocation);h.vertexAttribPointer(l.positionLocation,2,h.FLOAT,!1,0,0);h.clearColor(0,0,0,0);h.enable(h.BLEND);h.blendFunc(h.ONE,h.ONE_MINUS_SRC_ALPHA);h.clear(h.COLOR_BUFFER_BIT);h.drawArrays(h.TRIANGLES,0,6);h.flush();h.deleteTexture(d);h.deleteTexture(u);h.deleteBuffer(p);return c},drawFigures:function drawFigures(r,s,a,i,o){n||function initFiguresGL(){var r,s;generateGL();r=t;t=null;s=e;e=null;var a=createProgram(s,[createVertexShader(s," attribute vec2 a_position; attribute vec3 a_color; uniform vec2 u_resolution; uniform vec2 u_scale; uniform vec2 u_offset; varying vec4 v_color; void main() { vec2 position = (a_position + u_offset) * u_scale; vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); v_color = vec4(a_color / 255.0, 1.0); } "),createFragmentShader(s," precision mediump float; varying vec4 v_color; void main() { gl_FragColor = v_color; } ")]);s.useProgram(a);var i={};i.gl=s;i.canvas=r;i.resolutionLocation=s.getUniformLocation(a,"u_resolution");i.scaleLocation=s.getUniformLocation(a,"u_scale");i.offsetLocation=s.getUniformLocation(a,"u_offset");i.positionLocation=s.getAttribLocation(a,"a_position");i.colorLocation=s.getAttribLocation(a,"a_color");n=i}();var l=n,c=l.canvas,h=l.gl;c.width=r;c.height=s;h.viewport(0,0,h.drawingBufferWidth,h.drawingBufferHeight);h.uniform2f(l.resolutionLocation,r,s);var d,u,p,f=0;for(d=0,u=i.length;d0){a.style.borderWidth=t.borderStyle.width+"px";if(t.borderStyle.style!==s.AnnotationBorderStyleType.UNDERLINE){i-=2*t.borderStyle.width;o-=2*t.borderStyle.width}const e=t.borderStyle.horizontalCornerRadius,r=t.borderStyle.verticalCornerRadius;if(e>0||r>0){const t=`${e}px / ${r}px`;a.style.borderRadius=t}switch(t.borderStyle.style){case s.AnnotationBorderStyleType.SOLID:a.style.borderStyle="solid";break;case s.AnnotationBorderStyleType.DASHED:a.style.borderStyle="dashed";break;case s.AnnotationBorderStyleType.BEVELED:(0,s.warn)("Unimplemented border style: beveled");break;case s.AnnotationBorderStyleType.INSET:(0,s.warn)("Unimplemented border style: inset");break;case s.AnnotationBorderStyleType.UNDERLINE:a.style.borderBottomStyle="solid"}t.color?a.style.borderColor=s.Util.makeCssRgb(0|t.color[0],0|t.color[1],0|t.color[2]):a.style.borderWidth=0}a.style.left=l[0]+"px";a.style.top=l[1]+"px";a.style.width=i+"px";a.style.height=o+"px";return a}_createPopup(e,t,r){if(!t){(t=document.createElement("div")).style.height=e.style.height;t.style.width=e.style.width;e.appendChild(t)}const n=new PopupElement({container:e,trigger:t,color:r.color,title:r.title,modificationDate:r.modificationDate,contents:r.contents,hideWrapper:!0}).render();n.style.left=e.style.width;e.appendChild(n)}render(){(0,s.unreachable)("Abstract method `AnnotationElement.render` called")}}class LinkAnnotationElement extends AnnotationElement{constructor(e){super(e,!!(e.data.url||e.data.dest||e.data.action))}render(){this.container.className="linkAnnotation";const{data:e,linkService:t}=this,r=document.createElement("a");e.url?(0,n.addLinkAttributes)(r,{url:e.url,target:e.newWindow?n.LinkTarget.BLANK:t.externalLinkTarget,rel:t.externalLinkRel,enabled:t.externalLinkEnabled}):e.action?this._bindNamedAction(r,e.action):this._bindLink(r,e.dest);this.container.appendChild(r);return this.container}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t);e.onclick=()=>{t&&this.linkService.navigateTo(t);return!1};t&&(e.className="internalLink")}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeNamedAction(t);return!1};e.className="internalLink"}}class TextAnnotationElement extends AnnotationElement{constructor(e){super(e,!!(e.data.hasPopup||e.data.title||e.data.contents))}render(){this.container.className="textAnnotation";const e=document.createElement("img");e.style.height=this.container.style.height;e.style.width=this.container.style.width;e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";e.alt="[{{type}} Annotation]";e.dataset.l10nId="text_annotation_type";e.dataset.l10nArgs=JSON.stringify({type:this.data.name});this.data.hasPopup||this._createPopup(this.container,e,this.data);this.container.appendChild(e);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){return this.container}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,e.renderInteractiveForms||!e.data.hasAppearance&&!!e.data.fieldValue)}render(){const e=["left","center","right"],t=this.annotationStorage,r=this.data.id;this.container.className="textWidgetAnnotation";let n=null;if(this.renderInteractiveForms){const e=t.getOrCreateValue(r,this.data.fieldValue);if(this.data.multiLine){n=document.createElement("textarea");n.textContent=e}else{n=document.createElement("input");n.type="text";n.setAttribute("value",e)}n.addEventListener("input",(function(e){t.setValue(r,e.target.value)}));n.disabled=this.data.readOnly;n.name=this.data.fieldName;null!==this.data.maxLen&&(n.maxLength=this.data.maxLen);if(this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/this.data.maxLen;n.classList.add("comb");n.style.letterSpacing=`calc(${e}px - 1ch)`}}else{n=document.createElement("div");n.textContent=this.data.fieldValue;n.style.verticalAlign="middle";n.style.display="table-cell";let e=null;this.data.fontRefName&&this.page.commonObjs.has(this.data.fontRefName)&&(e=this.page.commonObjs.get(this.data.fontRefName));this._setTextStyle(n,e)}null!==this.data.textAlignment&&(n.style.textAlign=e[this.data.textAlignment]);this.container.appendChild(n);return this.container}_setTextStyle(e,t){const r=e.style;r.fontSize=this.data.fontSize+"px";r.direction=this.data.fontDirection<0?"rtl":"ltr";if(!t)return;let n="normal";t.black?n="900":t.bold&&(n="bold");r.fontWeight=n;r.fontStyle=t.italic?"italic":"normal";const s=t.loadedName?`"${t.loadedName}", `:"",a=t.fallbackName||"Helvetica, sans-serif";r.fontFamily=s+a}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,e.renderInteractiveForms)}render(){const e=this.annotationStorage,t=this.data,r=t.id,n=e.getOrCreateValue(r,t.fieldValue&&"Off"!==t.fieldValue);this.container.className="buttonWidgetAnnotation checkBox";const s=document.createElement("input");s.disabled=t.readOnly;s.type="checkbox";s.name=this.data.fieldName;n&&s.setAttribute("checked",!0);s.addEventListener("change",(function(t){e.setValue(r,t.target.checked)}));this.container.appendChild(s);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,e.renderInteractiveForms)}render(){this.container.className="buttonWidgetAnnotation radioButton";const e=this.annotationStorage,t=this.data,r=t.id,n=e.getOrCreateValue(r,t.fieldValue===t.buttonValue),s=document.createElement("input");s.disabled=t.readOnly;s.type="radio";s.name=t.fieldName;n&&s.setAttribute("checked",!0);s.addEventListener("change",(function(t){const n=t.target.name;for(const r of document.getElementsByName(n))r!==t.target&&e.setValue(r.parentNode.getAttribute("data-annotation-id"),!1);e.setValue(r,t.target.checked)}));this.container.appendChild(s);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{render(){const e=super.render();e.className="buttonWidgetAnnotation pushButton";return e}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,e.renderInteractiveForms)}render(){this.container.className="choiceWidgetAnnotation";const e=this.annotationStorage,t=this.data.id;e.getOrCreateValue(t,this.data.fieldValue.length>0?this.data.fieldValue[0]:null);const r=document.createElement("select");r.disabled=this.data.readOnly;r.name=this.data.fieldName;if(!this.data.combo){r.size=this.data.options.length;this.data.multiSelect&&(r.multiple=!0)}for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue;t.value=e.exportValue;this.data.fieldValue.includes(e.exportValue)&&t.setAttribute("selected",!0);r.appendChild(t)}r.addEventListener("input",(function(r){const n=r.target.options,s=n[n.selectedIndex].value;e.setValue(t,s)}));this.container.appendChild(r);return this.container}}class PopupAnnotationElement extends AnnotationElement{constructor(e){super(e,!(!e.data.title&&!e.data.contents))}render(){this.container.className="popupAnnotation";if(["Line","Square","Circle","PolyLine","Polygon","Ink"].includes(this.data.parentType))return this.container;const e=`[data-annotation-id="${this.data.parentId}"]`,t=this.layer.querySelector(e);if(!t)return this.container;const r=new PopupElement({container:this.container,trigger:t,color:this.data.color,title:this.data.title,modificationDate:this.data.modificationDate,contents:this.data.contents}),n=parseFloat(t.style.left),s=parseFloat(t.style.width);this.container.style.transformOrigin=`-${n+s}px -${t.style.top}`;this.container.style.left=n+s+"px";this.container.appendChild(r.render());return this.container}}class PopupElement{constructor(e){this.container=e.container;this.trigger=e.trigger;this.color=e.color;this.title=e.title;this.modificationDate=e.modificationDate;this.contents=e.contents;this.hideWrapper=e.hideWrapper||!1;this.pinned=!1}render(){const e=document.createElement("div");e.className="popupWrapper";this.hideElement=this.hideWrapper?e:this.container;this.hideElement.setAttribute("hidden",!0);const t=document.createElement("div");t.className="popup";const r=this.color;if(r){const e=.7*(255-r[0])+r[0],n=.7*(255-r[1])+r[1],a=.7*(255-r[2])+r[2];t.style.backgroundColor=s.Util.makeCssRgb(0|e,0|n,0|a)}const a=document.createElement("h1");a.textContent=this.title;t.appendChild(a);const i=n.PDFDateString.toDateObject(this.modificationDate);if(i){const e=document.createElement("span");e.textContent="{{date}}, {{time}}";e.dataset.l10nId="annotation_date_string";e.dataset.l10nArgs=JSON.stringify({date:i.toLocaleDateString(),time:i.toLocaleTimeString()});t.appendChild(e)}const o=this._formatContents(this.contents);t.appendChild(o);this.trigger.addEventListener("click",this._toggle.bind(this));this.trigger.addEventListener("mouseover",this._show.bind(this,!1));this.trigger.addEventListener("mouseout",this._hide.bind(this,!1));t.addEventListener("click",this._hide.bind(this,!0));e.appendChild(t);return e}_formatContents(e){const t=document.createElement("p"),r=e.split(/(?:\r\n?|\n)/);for(let e=0,n=r.length;e1)f=!0;else if(r.transform[0]!==r.transform[3]){const e=Math.abs(r.transform[0]),t=Math.abs(r.transform[3]);e!==t&&Math.max(e,t)/Math.min(e,t)>1.5&&(f=!0)}f&&(c.vertical?i.canvasWidth=r.height*t._viewport.scale:i.canvasWidth=r.width*t._viewport.scale);t._textDivProperties.set(a,i);t._textContentStream&&t._layoutText(a);if(t._enhanceTextSelection){var g=1,m=0;if(0!==l){g=Math.cos(l);m=Math.sin(l)}var _,A,b=(c.vertical?r.height:r.width)*t._viewport.scale,y=h;if(0!==l){_=[g,m,-m,g,u,p];A=n.Util.getAxialAlignedBoundingBox([0,0,b,y],_)}else A=[u,p,u+b,p+y];t._bounds.push({left:A[0],top:A[1],right:A[2],bottom:A[3],div:a,size:[b,y],m:_})}}function render(e){if(!e._canceled){var t=e._textDivs,r=e._capability,n=t.length;if(n>1e5){e._renderingDone=!0;r.resolve()}else{if(!e._textContentStream)for(var s=0;s0&&(n=n?Math.min(r,n):r)}return n}function expand(e){for(var t=e._bounds,r=e._viewport,s=function expandBounds(e,t,r){var n=r.map((function(e,t){return{x1:e.left,y1:e.top,x2:e.right,y2:e.bottom,index:t,x1New:void 0,x2New:void 0}}));expandBoundsLTR(e,n);var s=new Array(r.length);n.forEach((function(e){var t=e.index;s[t]={left:e.x1New,top:0,right:e.x2New,bottom:0}}));r.map((function(t,r){var a=s[r],i=n[r];i.x1=t.top;i.y1=e-a.right;i.x2=t.bottom;i.y2=e-a.left;i.index=r;i.x1New=void 0;i.x2New=void 0}));expandBoundsLTR(t,n);n.forEach((function(e){var t=e.index;s[t].top=e.x1New;s[t].bottom=e.x2New}));return s}(r.width,r.height,t),a=0;a=0&&r[a].start>=e.y2;)a--;var i,o,l=-1/0;for(i=t;i<=a;i++){var c;(c=(s=(n=r[i]).boundary).x2>e.x1?s.index>e.index?s.x1New:e.x1:void 0===s.x2New?(s.x2+e.x1)/2:s.x2New)>l&&(l=c)}e.x1New=l;for(i=t;i<=a;i++)void 0===(s=(n=r[i]).boundary).x2New?s.x2>e.x1?s.index>e.index&&(s.x2New=s.x2):s.x2New=l:s.x2New>l&&(s.x2New=Math.max(l,s.x2));var h=[],d=null;for(i=t;i<=a;i++){var u=(s=(n=r[i]).boundary).x2>e.x2?s:e;if(d===u)h[h.length-1].end=n.end;else{h.push({start:n.start,end:n.end,boundary:u});d=u}}if(r[t].start=0&&r[o].start>=s.y1;o--)p=r[o].boundary===s;for(o=a+1;!p&&o{if(this._layoutTextCtx){this._layoutTextCtx.canvas.width=0;this._layoutTextCtx.canvas.height=0;this._layoutTextCtx=null}}).catch(()=>{})}TextLayerRenderTask.prototype={get promise(){return this._capability.promise},cancel:function TextLayer_cancel(){this._canceled=!0;if(this._reader){this._reader.cancel(new n.AbortException("TextLayer task cancelled."));this._reader=null}if(null!==this._renderTimer){clearTimeout(this._renderTimer);this._renderTimer=null}this._capability.reject(new Error("TextLayer task cancelled."))},_processItems(e,t){for(let r=0,n=e.length;r0){t.scale=t.canvasWidth/a;r=`scaleX(${t.scale})`}}0!==t.angle&&(r=`rotate(${t.angle}deg) ${r}`);if(r.length>0){this._enhanceTextSelection&&(t.originalTransform=r);e.style.transform=r}this._textDivProperties.set(e,t);this._container.appendChild(e)},_render:function TextLayer_render(e){const t=(0,n.createPromiseCapability)();let r=Object.create(null);const s=this._document.createElement("canvas");s.mozOpaque=!0;this._layoutTextCtx=s.getContext("2d",{alpha:!1});if(this._textContent){const e=this._textContent.items,r=this._textContent.styles;this._processItems(e,r);t.resolve()}else{if(!this._textContentStream)throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');{const pump=()=>{this._reader.read().then(({value:e,done:n})=>{if(n)t.resolve();else{Object.assign(r,e.styles);this._processItems(e.items,r);pump()}},t.reject)};this._reader=this._textContentStream.getReader();pump()}}t.promise.then(()=>{r=null;e?this._renderTimer=setTimeout(()=>{render(this);this._renderTimer=null},e):render(this)},this._capability.reject)},expandTextDivs:function TextLayer_expandTextDivs(e){if(!this._enhanceTextSelection||!this._renderingDone)return;if(null!==this._bounds){expand(this);this._bounds=null}const t=[],r=[];for(var n=0,s=this._textDivs.length;n0){r.push(a.paddingTop+"px");t.push(`translateY(${-a.paddingTop}px)`)}else r.push(0);a.paddingRight>0?r.push(a.paddingRight/a.scale+"px"):r.push(0);a.paddingBottom>0?r.push(a.paddingBottom+"px"):r.push(0);if(a.paddingLeft>0){r.push(a.paddingLeft/a.scale+"px");t.push(`translateX(${-a.paddingLeft/a.scale}px)`)}else r.push(0);s.style.padding=r.join(" ");t.length&&(s.style.transform=t.join(" "))}else{s.style.padding=null;s.style.transform=a.originalTransform}}}};return function renderTextLayer(e){var t=new TextLayerRenderTask({textContent:e.textContent,textContentStream:e.textContentStream,container:e.container,viewport:e.viewport,textDivs:e.textDivs,textContentItemsStr:e.textContentItemsStr,enhanceTextSelection:e.enhanceTextSelection});t._render(e.timeout);return t}}();t.renderTextLayer=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.SVGGraphics=void 0;var n=r(2),s=r(1),a=r(4);let SVGGraphics=function(){throw new Error("Not implemented: SVGGraphics")};t.SVGGraphics=SVGGraphics;{const e={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},r="http://www.w3.org/XML/1998/namespace",i="http://www.w3.org/1999/xlink",o=["butt","round","square"],l=["miter","round","bevel"],c=function(){const e=new Uint8Array([137,80,78,71,13,10,26,10]),t=new Int32Array(256);for(let e=0;e<256;e++){let r=e;for(let e=0;e<8;e++)r=1&r?3988292384^r>>1&2147483647:r>>1&2147483647;t[e]=r}function writePngChunk(e,r,n,s){let a=s;const i=r.length;n[a]=i>>24&255;n[a+1]=i>>16&255;n[a+2]=i>>8&255;n[a+3]=255&i;a+=4;n[a]=255&e.charCodeAt(0);n[a+1]=255&e.charCodeAt(1);n[a+2]=255&e.charCodeAt(2);n[a+3]=255&e.charCodeAt(3);a+=4;n.set(r,a);a+=r.length;const o=function crc32(e,r,n){let s=-1;for(let a=r;a>>8^t[r]}return-1^s}(n,s+4,a);n[a]=o>>24&255;n[a+1]=o>>16&255;n[a+2]=o>>8&255;n[a+3]=255&o}function deflateSyncUncompressed(e){let t=e.length;const r=Math.ceil(t/65535),n=new Uint8Array(2+t+5*r+4);let s=0;n[s++]=120;n[s++]=156;let a=0;for(;t>65535;){n[s++]=0;n[s++]=255;n[s++]=255;n[s++]=0;n[s++]=0;n.set(e.subarray(a,a+65535),s);s+=65535;a+=65535;t-=65535}n[s++]=1;n[s++]=255&t;n[s++]=t>>8&255;n[s++]=255&~t;n[s++]=(65535&~t)>>8&255;n.set(e.subarray(a),s);s+=e.length-a;const i=function adler32(e,t,r){let n=1,s=0;for(let a=t;a>24&255;n[s++]=i>>16&255;n[s++]=i>>8&255;n[s++]=255&i;return n}function encode(t,r,s,i){const o=t.width,l=t.height;let c,h,d;const u=t.data;switch(r){case n.ImageKind.GRAYSCALE_1BPP:h=0;c=1;d=o+7>>3;break;case n.ImageKind.RGB_24BPP:h=2;c=8;d=3*o;break;case n.ImageKind.RGBA_32BPP:h=6;c=8;d=4*o;break;default:throw new Error("invalid format")}const p=new Uint8Array((1+d)*l);let f=0,g=0;for(let e=0;e>24&255,o>>16&255,o>>8&255,255&o,l>>24&255,l>>16&255,l>>8&255,255&l,c,h,0,0,0]),_=function deflateSync(e){if(!a.isNodeJS)return deflateSyncUncompressed(e);try{let t;t=parseInt(process.versions.node)>=8?e:Buffer.from(e);const r=require("zlib").deflateSync(t,{level:9});return r instanceof Uint8Array?r:new Uint8Array(r)}catch(e){(0,n.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return deflateSyncUncompressed(e)}(p),A=e.length+36+m.length+_.length,b=new Uint8Array(A);let y=0;b.set(e,y);y+=e.length;writePngChunk("IHDR",m,b,y);y+=12+m.length;writePngChunk("IDATA",_,b,y);y+=12+_.length;writePngChunk("IEND",new Uint8Array(0),b,y);return(0,n.createObjectURL)(b,"image/png",s)}return function convertImgDataToPng(e,t,r){return encode(e,void 0===e.kind?n.ImageKind.GRAYSCALE_1BPP:e.kind,t,r)}}();class SVGExtraState{constructor(){this.fontSizeScale=1;this.fontWeight=e.fontWeight;this.fontSize=0;this.textMatrix=n.IDENTITY_MATRIX;this.fontMatrix=n.FONT_IDENTITY_MATRIX;this.leading=0;this.textRenderingMode=n.TextRenderingMode.FILL;this.textMatrixScale=1;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRise=0;this.fillColor=e.fillColor;this.strokeColor="#000000";this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.lineJoin="";this.lineCap="";this.miterLimit=0;this.dashArray=[];this.dashPhase=0;this.dependencies=[];this.activeClipUrl=null;this.clipGroup=null;this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e;this.y=t}}function pf(e){if(Number.isInteger(e))return e.toString();const t=e.toFixed(10);let r=t.length-1;if("0"!==t[r])return t;do{r--}while("0"===t[r]);return t.substring(0,"."===t[r]?r:r+1)}function pm(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${pf(e[0])} ${pf(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2]){return`rotate(${pf(180*Math.acos(e[0])/Math.PI)})`}}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${pf(e[4])} ${pf(e[5])})`;return`matrix(${pf(e[0])} ${pf(e[1])} ${pf(e[2])} ${pf(e[3])} ${pf(e[4])} `+pf(e[5])+")"}let h=0,d=0,u=0;t.SVGGraphics=SVGGraphics=class SVGGraphics{constructor(e,t,r=!1){this.svgFactory=new s.DOMSVGFactory;this.current=new SVGExtraState;this.transformMatrix=n.IDENTITY_MATRIX;this.transformStack=[];this.extraStack=[];this.commonObjs=e;this.objs=t;this.pendingClip=null;this.pendingEOFill=!1;this.embedFonts=!1;this.embeddedFonts=Object.create(null);this.cssStyle=null;this.forceDataSchema=!!r;this._operatorIdMapping=[];for(const e in n.OPS)this._operatorIdMapping[n.OPS[e]]=e}save(){this.transformStack.push(this.transformMatrix);const e=this.current;this.extraStack.push(e);this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop();this.current=this.extraStack.pop();this.pendingClip=null;this.tgrp=null}group(e){this.save();this.executeOpTree(e);this.restore()}loadDependencies(e){const t=e.fnArray,r=e.argsArray;for(let e=0,s=t.length;e{e.get(t,r)});this.current.dependencies.push(r)}return Promise.all(this.current.dependencies)}transform(e,t,r,s,a,i){const o=[e,t,r,s,a,i];this.transformMatrix=n.Util.transform(this.transformMatrix,o);this.tgrp=null}getSVG(e,t){this.viewport=t;const r=this._initialize(t);return this.loadDependencies(e).then(()=>{this.transformMatrix=n.IDENTITY_MATRIX;this.executeOpTree(this.convertOpList(e));return r})}convertOpList(e){const t=this._operatorIdMapping,r=e.argsArray,n=e.fnArray,s=[];for(let e=0,a=n.length;e0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=o[e]}setLineJoin(e){this.current.lineJoin=l[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,r){this.current.strokeColor=n.Util.makeCssRgb(e,t,r)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,r){this.current.fillColor=n.Util.makeCssRgb(e,t,r);this.current.tspan=this.svgFactory.createElement("svg:tspan");this.current.xcoords=[];this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){const t=this.viewport.width,r=this.viewport.height,s=n.Util.inverseTransform(this.transformMatrix),a=n.Util.applyTransform([0,0],s),i=n.Util.applyTransform([0,r],s),o=n.Util.applyTransform([t,0],s),l=n.Util.applyTransform([t,r],s),c=Math.min(a[0],i[0],o[0],l[0]),h=Math.min(a[1],i[1],o[1],l[1]),d=Math.max(a[0],i[0],o[0],l[0]),u=Math.max(a[1],i[1],o[1],l[1]),p=this.svgFactory.createElement("svg:rect");p.setAttributeNS(null,"x",c);p.setAttributeNS(null,"y",h);p.setAttributeNS(null,"width",d-c);p.setAttributeNS(null,"height",u-h);p.setAttributeNS(null,"fill",this._makeShadingPattern(e));this.current.fillAlpha<1&&p.setAttributeNS(null,"fill-opacity",this.current.fillAlpha);this._ensureTransformGroup().appendChild(p)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){const t=e[1],r=e[2],s=e[3]||n.IDENTITY_MATRIX,[a,i,o,l]=e[4],c=e[5],h=e[6],d=e[7],p="shading"+u++,[f,g]=n.Util.applyTransform([a,i],s),[m,_]=n.Util.applyTransform([o,l],s),[A,b]=n.Util.singularValueDecompose2dScale(s),y=c*A,v=h*b,C=this.svgFactory.createElement("svg:pattern");C.setAttributeNS(null,"id",p);C.setAttributeNS(null,"patternUnits","userSpaceOnUse");C.setAttributeNS(null,"width",y);C.setAttributeNS(null,"height",v);C.setAttributeNS(null,"x",""+f);C.setAttributeNS(null,"y",""+g);const S=this.svg,x=this.transformMatrix,P=this.current.fillColor,k=this.current.strokeColor,R=this.svgFactory.create(m-f,_-g);this.svg=R;this.transformMatrix=s;if(2===d){const e=n.Util.makeCssRgb(...t);this.current.fillColor=e;this.current.strokeColor=e}this.executeOpTree(this.convertOpList(r));this.svg=S;this.transformMatrix=x;this.current.fillColor=P;this.current.strokeColor=k;C.appendChild(R.childNodes[0]);this.defs.appendChild(C);return`url(#${p})`}_makeShadingPattern(e){switch(e[0]){case"RadialAxial":const t="shading"+u++,r=e[3];let s;switch(e[1]){case"axial":const r=e[4],n=e[5];s=this.svgFactory.createElement("svg:linearGradient");s.setAttributeNS(null,"id",t);s.setAttributeNS(null,"gradientUnits","userSpaceOnUse");s.setAttributeNS(null,"x1",r[0]);s.setAttributeNS(null,"y1",r[1]);s.setAttributeNS(null,"x2",n[0]);s.setAttributeNS(null,"y2",n[1]);break;case"radial":const a=e[4],i=e[5],o=e[6],l=e[7];s=this.svgFactory.createElement("svg:radialGradient");s.setAttributeNS(null,"id",t);s.setAttributeNS(null,"gradientUnits","userSpaceOnUse");s.setAttributeNS(null,"cx",i[0]);s.setAttributeNS(null,"cy",i[1]);s.setAttributeNS(null,"r",l);s.setAttributeNS(null,"fx",a[0]);s.setAttributeNS(null,"fy",a[1]);s.setAttributeNS(null,"fr",o);break;default:throw new Error("Unknown RadialAxial type: "+e[1])}for(const e of r){const t=this.svgFactory.createElement("svg:stop");t.setAttributeNS(null,"offset",e[0]);t.setAttributeNS(null,"stop-color",e[1]);s.appendChild(t)}this.defs.appendChild(s);return`url(#${t})`;case"Mesh":(0,n.warn)("Unimplemented pattern Mesh");return null;case"Dummy":return"hotpink";default:throw new Error("Unknown IR type: "+e[0])}}setDash(e,t){this.current.dashArray=e;this.current.dashPhase=t}constructPath(e,t){const r=this.current;let s=r.x,a=r.y,i=[],o=0;for(const r of e)switch(0|r){case n.OPS.rectangle:s=t[o++];a=t[o++];const e=s+t[o++],r=a+t[o++];i.push("M",pf(s),pf(a),"L",pf(e),pf(a),"L",pf(e),pf(r),"L",pf(s),pf(r),"Z");break;case n.OPS.moveTo:s=t[o++];a=t[o++];i.push("M",pf(s),pf(a));break;case n.OPS.lineTo:s=t[o++];a=t[o++];i.push("L",pf(s),pf(a));break;case n.OPS.curveTo:s=t[o+4];a=t[o+5];i.push("C",pf(t[o]),pf(t[o+1]),pf(t[o+2]),pf(t[o+3]),pf(s),pf(a));o+=6;break;case n.OPS.curveTo2:i.push("C",pf(s),pf(a),pf(t[o]),pf(t[o+1]),pf(t[o+2]),pf(t[o+3]));s=t[o+2];a=t[o+3];o+=4;break;case n.OPS.curveTo3:s=t[o+2];a=t[o+3];i.push("C",pf(t[o]),pf(t[o+1]),pf(s),pf(a),pf(s),pf(a));o+=4;break;case n.OPS.closePath:i.push("Z")}i=i.join(" ");if(r.path&&e.length>0&&e[0]!==n.OPS.rectangle&&e[0]!==n.OPS.moveTo)i=r.path.getAttributeNS(null,"d")+i;else{r.path=this.svgFactory.createElement("svg:path");this._ensureTransformGroup().appendChild(r.path)}r.path.setAttributeNS(null,"d",i);r.path.setAttributeNS(null,"fill","none");r.element=r.path;r.setCurrentPoint(s,a)}endPath(){const e=this.current;e.path=null;if(!this.pendingClip)return;if(!e.element){this.pendingClip=null;return}const t="clippath"+h++,r=this.svgFactory.createElement("svg:clipPath");r.setAttributeNS(null,"id",t);r.setAttributeNS(null,"transform",pm(this.transformMatrix));const n=e.element.cloneNode(!0);"evenodd"===this.pendingClip?n.setAttributeNS(null,"clip-rule","evenodd"):n.setAttributeNS(null,"clip-rule","nonzero");this.pendingClip=null;r.appendChild(n);this.defs.appendChild(r);if(e.activeClipUrl){e.clipGroup=null;this.extraStack.forEach((function(e){e.clipGroup=null}));r.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${t})`;this.tgrp=null}clip(e){this.pendingClip=e}closePath(){const e=this.current;if(e.path){const t=e.path.getAttributeNS(null,"d")+"Z";e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,r]of e)switch(t){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r);break;case"CA":this.setStrokeAlpha(r);break;case"ca":this.setFillAlpha(r);break;default:(0,n.warn)("Unimplemented graphic state operator "+t)}}fill(){const e=this.current;if(e.element){e.element.setAttributeNS(null,"fill",e.fillColor);e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha);this.endPath()}}stroke(){const e=this.current;if(e.element){this._setStrokeAttributes(e.element);e.element.setAttributeNS(null,"fill","none");this.endPath()}}_setStrokeAttributes(e,t=1){const r=this.current;let n=r.dashArray;1!==t&&n.length>0&&(n=n.map((function(e){return t*e})));e.setAttributeNS(null,"stroke",r.strokeColor);e.setAttributeNS(null,"stroke-opacity",r.strokeAlpha);e.setAttributeNS(null,"stroke-miterlimit",pf(r.miterLimit));e.setAttributeNS(null,"stroke-linecap",r.lineCap);e.setAttributeNS(null,"stroke-linejoin",r.lineJoin);e.setAttributeNS(null,"stroke-width",pf(t*r.lineWidth)+"px");e.setAttributeNS(null,"stroke-dasharray",n.map(pf).join(" "));e.setAttributeNS(null,"stroke-dashoffset",pf(t*r.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd");this.fill()}fillStroke(){this.stroke();this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd");this.fillStroke()}closeStroke(){this.closePath();this.stroke()}closeFillStroke(){this.closePath();this.fillStroke()}closeEOFillStroke(){this.closePath();this.eoFillStroke()}paintSolidColorImageMask(){const e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0");e.setAttributeNS(null,"y","0");e.setAttributeNS(null,"width","1px");e.setAttributeNS(null,"height","1px");e.setAttributeNS(null,"fill",this.current.fillColor);this._ensureTransformGroup().appendChild(e)}paintImageXObject(e){const t=e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e);t?this.paintInlineImageXObject(t):(0,n.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){const r=e.width,n=e.height,s=c(e,this.forceDataSchema,!!t),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0");a.setAttributeNS(null,"y","0");a.setAttributeNS(null,"width",pf(r));a.setAttributeNS(null,"height",pf(n));this.current.element=a;this.clip("nonzero");const o=this.svgFactory.createElement("svg:image");o.setAttributeNS(i,"xlink:href",s);o.setAttributeNS(null,"x","0");o.setAttributeNS(null,"y",pf(-n));o.setAttributeNS(null,"width",pf(r)+"px");o.setAttributeNS(null,"height",pf(n)+"px");o.setAttributeNS(null,"transform",`scale(${pf(1/r)} ${pf(-1/n)})`);t?t.appendChild(o):this._ensureTransformGroup().appendChild(o)}paintImageMaskXObject(e){const t=this.current,r=e.width,n=e.height,s=t.fillColor;t.maskId="mask"+d++;const a=this.svgFactory.createElement("svg:mask");a.setAttributeNS(null,"id",t.maskId);const i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x","0");i.setAttributeNS(null,"y","0");i.setAttributeNS(null,"width",pf(r));i.setAttributeNS(null,"height",pf(n));i.setAttributeNS(null,"fill",s);i.setAttributeNS(null,"mask",`url(#${t.maskId})`);this.defs.appendChild(a);this._ensureTransformGroup().appendChild(i);this.paintInlineImageXObject(e,a)}paintFormXObjectBegin(e,t){Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]);if(t){const e=t[2]-t[0],r=t[3]-t[1],n=this.svgFactory.createElement("svg:rect");n.setAttributeNS(null,"x",t[0]);n.setAttributeNS(null,"y",t[1]);n.setAttributeNS(null,"width",pf(e));n.setAttributeNS(null,"height",pf(r));this.current.element=n;this.clip("nonzero");this.endPath()}}paintFormXObjectEnd(){}_initialize(e){const t=this.svgFactory.create(e.width,e.height),r=this.svgFactory.createElement("svg:defs");t.appendChild(r);this.defs=r;const n=this.svgFactory.createElement("svg:g");n.setAttributeNS(null,"transform",pm(e.transform));t.appendChild(n);this.svg=n;return t}_ensureClipGroup(){if(!this.current.clipGroup){const e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl);this.svg.appendChild(e);this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){if(!this.tgrp){this.tgrp=this.svgFactory.createElement("svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix));this.current.activeClipUrl?this._ensureClipGroup().appendChild(this.tgrp):this.svg.appendChild(this.tgrp)}return this.tgrp}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFNodeStream=void 0;var n=r(2),s=r(23);const a=require("fs"),i=require("http"),o=require("https"),l=require("url"),c=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class PDFNodeStream{constructor(e){this.source=e;this.url=function parseUrl(e){const t=l.parse(e);if("file:"===t.protocol||t.host)return t;if(/^[a-z]:[/\\]/i.test(e))return l.parse("file:///"+e);t.host||(t.protocol="file:");return t}(e.url);this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol;this.isFsUrl="file:"===this.url.protocol;this.httpHeaders=this.isHttp&&e.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once.");this._fullRequestReader=this.isFsUrl?new PDFNodeStreamFsFullReader(this):new PDFNodeStreamFullReader(this);return this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=this.isFsUrl?new PDFNodeStreamFsRangeReader(this,e,t):new PDFNodeStreamRangeReader(this,e,t);this._rangeRequestReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class BaseFullReader{constructor(e){this._url=e.url;this._done=!1;this._storedError=null;this.onProgress=null;const t=e.source;this._contentLength=t.length;this._loaded=0;this._filename=null;this._disableRange=t.disableRange||!1;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!t.disableStream;this._isRangeSupported=!t.disableRange;this._readableStream=null;this._readCapability=(0,n.createPromiseCapability)();this._headersCapability=(0,n.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e){this._readCapability=(0,n.createPromiseCapability)();return this.read()}this._loaded+=e.length;this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e;this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e;e.on("readable",()=>{this._readCapability.resolve()});e.on("end",()=>{e.destroy();this._done=!0;this._readCapability.resolve()});e.on("error",e=>{this._error(e)});!this._isStreamingSupported&&this._isRangeSupported&&this._error(new n.AbortException("streaming is disabled"));this._storedError&&this._readableStream.destroy(this._storedError)}}class BaseRangeReader{constructor(e){this._url=e.url;this._done=!1;this._storedError=null;this.onProgress=null;this._loaded=0;this._readableStream=null;this._readCapability=(0,n.createPromiseCapability)();const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e){this._readCapability=(0,n.createPromiseCapability)();return this.read()}this._loaded+=e.length;this.onProgress&&this.onProgress({loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e;this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e;e.on("readable",()=>{this._readCapability.resolve()});e.on("end",()=>{e.destroy();this._done=!0;this._readCapability.resolve()});e.on("error",e=>{this._error(e)});this._storedError&&this._readableStream.destroy(this._storedError)}}function createRequestOptions(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class PDFNodeStreamFullReader extends BaseFullReader{constructor(e){super(e);const handleResponse=t=>{if(404===t.statusCode){const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e;this._headersCapability.reject(e);return}this._headersCapability.resolve();this._setReadableStream(t);const getResponseHeader=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:r,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r;this._contentLength=a||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader)};this._request=null;"http:"===this._url.protocol?this._request=i.request(createRequestOptions(this._url,e.httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,e.httpHeaders),handleResponse);this._request.on("error",e=>{this._storedError=e;this._headersCapability.reject(e)});this._request.end()}}class PDFNodeStreamRangeReader extends BaseRangeReader{constructor(e,t,r){super(e);this._httpHeaders={};for(const t in e.httpHeaders){const r=e.httpHeaders[t];void 0!==r&&(this._httpHeaders[t]=r)}this._httpHeaders.Range=`bytes=${t}-${r-1}`;const handleResponse=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null;"http:"===this._url.protocol?this._request=i.request(createRequestOptions(this._url,this._httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,this._httpHeaders),handleResponse);this._request.on("error",e=>{this._storedError=e});this._request.end()}}class PDFNodeStreamFsFullReader extends BaseFullReader{constructor(e){super(e);let t=decodeURIComponent(this._url.path);c.test(this._url.href)&&(t=t.replace(/^\//,""));a.lstat(t,(e,r)=>{if(e){"ENOENT"===e.code&&(e=new n.MissingPDFException(`Missing PDF "${t}".`));this._storedError=e;this._headersCapability.reject(e)}else{this._contentLength=r.size;this._setReadableStream(a.createReadStream(t));this._headersCapability.resolve()}})}}class PDFNodeStreamFsRangeReader extends BaseRangeReader{constructor(e,t,r){super(e);let n=decodeURIComponent(this._url.path);c.test(this._url.href)&&(n=n.replace(/^\//,""));this._setReadableStream(a.createReadStream(n,{start:t,end:r-1}))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.createResponseStatusError=function createResponseStatusError(e,t){if(404===e||0===e&&t.startsWith("file:"))return new n.MissingPDFException('Missing PDF "'+t+'".');return new n.UnexpectedResponseException("Unexpected server response ("+e+') while retrieving PDF "'+t+'".',e)};t.extractFilenameFromHeader=function extractFilenameFromHeader(e){const t=e("Content-Disposition");if(t){let e=(0,s.getFilenameFromContentDispositionHeader)(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch(e){}if(/\.pdf$/i.test(e))return e}return null};t.validateRangeRequestCapabilities=function validateRangeRequestCapabilities({getResponseHeader:e,isHttp:t,rangeChunkSize:r,disableRange:s}){(0,n.assert)(r>0,"Range chunk size must be larger than zero");const a={allowRangeRequests:!1,suggestedLength:void 0},i=parseInt(e("Content-Length"),10);if(!Number.isInteger(i))return a;a.suggestedLength=i;if(i<=2*r)return a;if(s||!t)return a;if("bytes"!==e("Accept-Ranges"))return a;if("identity"!==(e("Content-Encoding")||"identity"))return a;a.allowRangeRequests=!0;return a};t.validateResponseStatus=function validateResponseStatus(e){return 200===e||206===e};var n=r(2),s=r(24)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getFilenameFromContentDispositionHeader=function getFilenameFromContentDispositionHeader(e){let t=!0,r=toParamRegExp("filename\\*","i").exec(e);if(r){r=r[1];let e=rfc2616unquote(r);e=unescape(e);e=rfc5987decode(e);e=rfc2047decode(e);return fixupEncoding(e)}r=function rfc2231getparam(e){const t=[];let r;const n=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(r=n.exec(e));){let[,e,n,s]=r;e=parseInt(e,10);if(e in t){if(0===e)break}else t[e]=[n,s]}const s=[];for(let e=0;e=2&&r.onHeadersReceived){r.onHeadersReceived();delete r.onHeadersReceived}if(4!==s.readyState)return;if(!(e in this.pendingRequests))return;delete this.pendingRequests[e];if(0===s.status&&this.isHttp){r.onError&&r.onError(s.status);return}const a=s.status||200;if(!(200===a&&206===r.expectedStatus)&&a!==r.expectedStatus){r.onError&&r.onError(s.status);return}const i=function getArrayBuffer(e){const t=e.response;return"string"!=typeof t?t:(0,n.stringToBytes)(t).buffer}(s);if(206===a){const e=s.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);r.onDone({begin:parseInt(t[1],10),chunk:i})}else i?r.onDone({begin:0,chunk:i}):r.onError&&r.onError(s.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e];t.abort()}}t.PDFNetworkStream=class PDFNetworkStream{constructor(e){this._source=e;this._manager=new NetworkManager(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials});this._rangeChunkSize=e.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once.");this._fullRequestReader=new PDFNetworkStreamFullRequestReader(this._manager,this._source);return this._fullRequestReader}getRangeReader(e,t){const r=new PDFNetworkStreamRangeRequestReader(this._manager,e,t);r.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class PDFNetworkStreamFullRequestReader{constructor(e,t){this._manager=e;const r={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url;this._fullRequestId=e.requestFull(r);this._headersReceivedCapability=(0,n.createPromiseCapability)();this._disableRange=t.disableRange||!1;this._contentLength=t.length;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!1;this._isRangeSupported=!1;this._cachedChunks=[];this._requests=[];this._done=!1;this._storedError=void 0;this._filename=null;this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),getResponseHeader=e=>t.getResponseHeader(e),{allowRangeRequests:r,suggestedLength:n}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0);this._contentLength=n||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);this._isRangeSupported&&this._manager.abortRequest(e);this._headersReceivedCapability.resolve()}_onDone(e){if(e)if(this._requests.length>0){this._requests.shift().resolve({value:e.chunk,done:!1})}else this._cachedChunks.push(e.chunk);this._done=!0;if(!(this._cachedChunks.length>0)){this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[]}}_onError(e){const t=this._url,r=(0,s.createResponseStatusError)(e,t);this._storedError=r;this._headersReceivedCapability.reject(r);this._requests.forEach((function(e){e.reject(r)}));this._requests=[];this._cachedChunks=[]}_onProgress(e){this.onProgress&&this.onProgress({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,n.createPromiseCapability)();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._headersReceivedCapability.reject(e);this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[];this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}}class PDFNetworkStreamRangeRequestReader{constructor(e,t,r){this._manager=e;const n={onDone:this._onDone.bind(this),onProgress:this._onProgress.bind(this)};this._requestId=e.requestRange(t,r,n);this._requests=[];this._queuedChunk=null;this._done=!1;this.onProgress=null;this.onClosed=null}_close(){this.onClosed&&this.onClosed(this)}_onDone(e){const t=e.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0;this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[];this._close()}_onProgress(e){!this.isStreamingSupported&&this.onProgress&&this.onProgress({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(null!==this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=(0,n.createPromiseCapability)();this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._requests.forEach((function(e){e.resolve({value:void 0,done:!0})}));this._requests=[];this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFFetchStream=void 0;var n=r(2),s=r(23);function createFetchOptions(e,t,r){return{method:"GET",headers:e,signal:r&&r.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function createHeaders(e){const t=new Headers;for(const r in e){const n=e[r];void 0!==n&&t.append(r,n)}return t}t.PDFFetchStream=class PDFFetchStream{constructor(e){this.source=e;this.isHttp=/^https?:/i.test(e.url);this.httpHeaders=this.isHttp&&e.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?this._fullRequestReader._loaded:0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once.");this._fullRequestReader=new PDFFetchStreamReader(this);return this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const r=new PDFFetchStreamRangeReader(this,e,t);this._rangeRequestReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class PDFFetchStreamReader{constructor(e){this._stream=e;this._reader=null;this._loaded=0;this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1;this._contentLength=t.length;this._headersCapability=(0,n.createPromiseCapability)();this._disableRange=t.disableRange||!1;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);"undefined"!=typeof AbortController&&(this._abortController=new AbortController);this._isStreamingSupported=!t.disableStream;this._isRangeSupported=!t.disableRange;this._headers=createHeaders(this._stream.httpHeaders);const r=t.url;fetch(r,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!(0,s.validateResponseStatus)(e.status))throw(0,s.createResponseStatusError)(e.status,r);this._reader=e.body.getReader();this._headersCapability.resolve();const getResponseHeader=t=>e.headers.get(t),{allowRangeRequests:t,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t;this._contentLength=a||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new n.AbortException("Streaming is disabled."))}).catch(this._headersCapability.reject);this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._reader&&this._reader.cancel(e);this._abortController&&this._abortController.abort()}}class PDFFetchStreamRangeReader{constructor(e,t,r){this._stream=e;this._reader=null;this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1;this._readCapability=(0,n.createPromiseCapability)();this._isStreamingSupported=!a.disableStream;"undefined"!=typeof AbortController&&(this._abortController=new AbortController);this._headers=createHeaders(this._stream.httpHeaders);this._headers.append("Range",`bytes=${t}-${r-1}`);const i=a.url;fetch(i,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!(0,s.validateResponseStatus)(e.status))throw(0,s.createResponseStatusError)(e.status,i);this._readCapability.resolve();this._reader=e.body.getReader()}).catch(e=>{if(!e||"AbortError"!==e.name)throw e});this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this.onProgress&&this.onProgress({loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._reader&&this._reader.cancel(e);this._abortController&&this._abortController.abort()}}}])})); \ No newline at end of file diff --git a/app/src/main/assets/pdf.worker.js b/app/src/main/assets/pdf.worker.js index 1b4424b..ba03f47 100644 --- a/app/src/main/assets/pdf.worker.js +++ b/app/src/main/assets/pdf.worker.js @@ -19,4 +19,4 @@ * @licend The above is the entire license notice for the * Javascript code in this page */ -!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:{}};e[r].call(i.exports,i,i.exports,a);i.l=!0;return i.exports}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){1&t&&(e=a(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);a.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(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};a.d(t,"a",t);return t};a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};a.p="";return 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)()}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")}};return e}();t.WorkerTask=h;var u,d={setup(e,t){var a=!1;e.on("test",(function(t){if(a)return;a=!0;if(!(t instanceof Uint8Array)){e.send("test",null);return}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);v.postMessageTransfers=e.postMessageTransfers;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){i.reject(e);return 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);if(!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)();u&&u(new r.AbortException("Worker was terminated."));d.forEach((function(e){t.push(e.finished);e.terminate()}));return 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){w();if(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();if(e instanceof l.XRefParseException){a.requestLoadedStream();a.onLoadedStream().then((function(){w();C(!0).then(t,i)}))}else 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){e.terminate(new r.AbortException("Worker was terminated."));throw new Error("Worker was terminated")}(a=e).onLoadedStream().then((function(e){v.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(n,i)}(e);e=null}));return 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)}}));return 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){if(e.length!==t.length)return!1;return 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{a=new URL(e);if(!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){if("string"!=typeof e){n("The argument for removeNullCharacters must be a string.");return e}return 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){Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!1});return a}const l=function(){function e(t){this.constructor===e&&s("Cannot initialize BaseException.");this.message=t;this.name=this.constructor.name}e.prototype=new Error;e.constructor=e;return 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]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return 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=[];e=p.normalizeRect(e);t=p.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;n[0]=r[1];n[2]=r[2];if(!(i[0]===e[1]&&i[1]===t[1]||i[0]===t[1]&&i[1]===e[1]))return null;n[1]=i[1];n[3]=i[2];return n}}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];const 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)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return 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();-1!==e&&this.pos--;return e}peekBytes(e,t=!1){const a=this.getBytes(e,t);this.pos-=a.length;return a}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);t>this.progressiveDataLength&&this.ensureRange(e,t);return 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){t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e);function r(){}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;i.push(e);n+=(0,r.arrayByteLength)(e);a.isStreamingSupported&&this.onProgress({loaded:n});a.read().then(s,t);return}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();this._requestChunks(e);return 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;if(!(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){if(e<=0)return 0;return 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");(!(0,r.isNum)(e)||e<=0)&&(e=1);return(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;e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360);return(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){this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources"));return 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);e.send("StartRenderPage",{transparency:c.hasBlendModes(this.resources),pageIndex:this.pageIndex,intent:i});return 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){e.flush(!0);return{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);e.addOp(r.OPS.endAnnotations,[]);e.flush(!0);return{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){e.pos+=r-a;return!0}r--}}else{let a=0;for(;a<=s;){let r=0;for(;r=i){e.pos+=a;return!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{this.acroForm=this.catalog.catDict.get("AcroForm");if(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){e.skip(9);let a;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;e.reset();if(!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;if("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")){i&&!t.pageKidsCountCache.has(i)&&t.pageKidsCountCache.put(i,1);return[e,i]}throw new r.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.")}).catch(a=>{(0,r.info)(a);return 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){this._pagePromises.length=0;await this.cleanup();throw 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){this.pdfManager=e;this.xref=t;this.catDict=t.getCatalogObj();if(!(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 e=a.dict.get("Type"),t=a.dict.get("Subtype");if((0,i.isName)(e,"Metadata")&&(0,i.isName)(t,"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;e=e.getRaw("First");if(!(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");if((0,i.isRef)(e)&&!n.has(e)){a.push({obj:e,parent:b});n.put(e)}e=l.getRaw("Next");if((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});if(Array.isArray(r.dest)){t||(t=Object.create(null));t.dest=r.dest}else if(r.action){t||(t=Object.create(null));t.action=r.action}}else if(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");(0,i.isDict)(n)&&(0,i.isName)(n.get("S"),"JavaScript")&&a(n);return(0,r.shadow)(this,"javaScript",t)}fontFallback(e,t){const a=[];this.fontCache.forEach((function(e){a.push(e)}));return Promise.all(a).then(a=>{for(const r of a)if(r.loadedName===e){r.fallback(t);return}})}cleanup(){(0,i.clearPrimitiveCaches)();this.pageKidsCountCache.clear();const e=[];this.fontCache.forEach((function(t){e.push(t)}));return 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;!function h(){for(;a.length;){const u=a.pop();if((0,i.isRef)(u)){c=o.get(u);if(c>0&&l+c=0){const t=u.objId;t&&!o.has(t)&&o.put(t,c);if(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){t.resolve([u,null]);return}l++;continue}t.reject(new r.FormatError("Page dictionary kids object is not an array."));return}for(let e=d.length-1;e>=0;e--)a.push(d[e])}t.reject(new Error(`Page index ${e} not found.`))}();return 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.");n=t.getRaw("Parent");return 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){(0,r.warn)(`Search depth limit reached for "${this._type}" tree.`);return 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;this.shift();if((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}if((0,n.isCmd)(this.buf2,"stream"))return this.allowStreams?this.makeStream(r,e):r;this.shift();return 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);this.shift();this.shift();return 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{(0,i.assert)(2===n);if(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}if(-1===a){(0,i.warn)("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker");if(r){(0,i.warn)('... trying to recover by using the last "EI" occurrence.');e.skip(-(e.pos-r))}}let o=4;e.skip(-o);a=e.peekByte();e.skip(o);(0,s.isWhiteSpace)(a)||o--;return 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;if(-1===a){(0,i.warn)("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead.");e.skip(-s);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return s}findASCII85DecodeInlineStreamEnd(e){const t=e.pos;let a;for(;-1!==(a=e.getByte());)if(126===a){const t=e.pos;a=e.peekByte();for(;(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;if(-1===a){(0,i.warn)("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-r);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return r}findASCIIHexDecodeInlineStreamEnd(e){const t=e.pos;let a;for(;-1!==(a=e.getByte())&&62!==a;);const r=e.pos-t;if(-1===a){(0,i.warn)("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-r);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return 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;this.shift();if((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){this.buf2=n.Cmd.get("EI");this.shift();o.reset();return o}}e&&(f=e.createStream(f,h));f=this.filter(f,r,h);f.dict=r;if(void 0!==d){f.cacheKey=`inline_${h}_${d}`;this.imageCache[d]=f}this.buf2=n.Cmd.get("EI");this.shift();return f}_findStreamLength(e,t){const{stream:a}=this.lexer;a.pos=e;const r=t.length;for(;a.pos=r){a.pos+=s;return 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();if(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()}this.shift();r=r.makeSubStream(o,c,e);t&&(r=t.createStream(r,c));r=this.filter(r,e,c);r.dict=e;return r}filter(e,t,a){let r=t.get("Filter","F"),s=t.get("DecodeParms","DP");if((0,n.isName)(r)){Array.isArray(s)&&(0,i.warn)("/DecodeParms should not contain an Array, when /Filter contains a Name.");return 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())}else if(43===e){r=1;e=this.nextChar()}if(10===e||13===e)do{e=this.nextChar()}while(10===e||13===e);if(46===e){a=10;e=this.nextChar()}if(e<48||e>57){if(10===a&&0===r&&((0,s.isWhiteSpace)(e)||-1===e)){(0,i.warn)("Lexer.getNumber - treating a single decimal point as zero.");return 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;if(t)o=10*o+r;else{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;e=this.peekChar();if(43===e||45===e){c=45===e?-1:1;this.nextChar()}else if(e<48||e>57)break;t=!0}0!==a&&(n/=a);t&&(n*=10**(c*o));return 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:if(0==--e){this.nextChar();t=!0}else a.push(")");break;case 92:r=this.nextChar();switch(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;if(r>=48&&r<=55){e=(e<<3)+(15&r);r=this.nextChar();if(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;a.length=0;for(;(e=this.nextChar())>=0&&!f[e];)if(35===e){e=this.nextChar();if(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){(0,i.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(e)}) `+"in hexadecimal number.");a.push("#",String.fromCharCode(t));if(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));a.length>127&&(0,i.warn)(`Name token is longer than allowed by the spec: ${a.length}`);return 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;this._hexStringNumWarn=0;for(;;){if(r<0){(0,i.warn)("Unterminated hex string");break}if(62===r){this.nextChar();break}if(1!==f[r]){if(n){t=g(r);if(-1===t){this._hexStringWarn(r);r=this.nextChar();continue}}else{a=g(r);if(-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:this.nextChar();return n.Cmd.get("[");case 93:this.nextChar();return n.Cmd.get("]");case 60:t=this.nextChar();if(60===t){this.nextChar();return n.Cmd.get("<<")}return this.getHexString();case 62:t=this.nextChar();if(62===t){this.nextChar();return n.Cmd.get(">>")}return n.Cmd.get(">");case 123:this.nextChar();return n.Cmd.get("{");case 125:this.nextChar();return n.Cmd.get("}");case 41:this.nextChar();throw 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]}if("true"===a)return!0;if("false"===a)return!1;if("null"===a)return null;"BI"===a&&(this.beginInlineImagePos=this.stream.pos);return 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}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();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var a=this.getBytes(e,t);this.pos-=a.length;return a},getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return 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)}};return e}();t.Stream=s;var o=function(){function e(e){const t=(0,r.stringToBytes)(e);s.call(this,t)}e.prototype=s.prototype;return e}();t.StringStream=o;var c=function(){var e=new Uint8Array(0);function t(t){this._rawMinBufferLength=t||0;this.pos=0;this.bufferLength=0;this.eof=!1;this.buffer=e;this.minBufferLength=512;if(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();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var a=this.getBytes(e,t);this.pos-=a.length;return 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():[]}};return 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;return 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;return 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){this.bufferLength=I;return}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;this.pixBytes=s*o+7>>3;this.rowBytes=l*s*o+7>>3;c.call(this,t);return this}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);this.eof=!n.length;if(!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);this.eof=!i.length;if(!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};return 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)}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)}if(i<0)i=o;else{a[r++]=i<<4|o;i=-1}}if(i>=0&&this.eof){a[r++]=i<<4;i=-1}this.firstDigit=i;this.bufferLength=r}else this.eof=!0};return e}();t.AsciiHexStream=g;var m=function(){function e(e,t){this.str=e;this.dict=e.dict;c.call(this,t)}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){(t=this.ensureBuffer(a+r+1))[a++]=e[1];if(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;if(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)}e.prototype=Object.create(n.DecodeStream.prototype);e.prototype.readBlock=function(){for(;!this.eof;){const e=this.ccittFaxDecoder.readNextChar();if(-1===e){this.eof=!0;return}this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=e}};return 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;null==r&&(r=!0);this.eoblock=r;this.black=t.BlackIs1||!1;this.codingLine=new Uint32Array(this.columns+1);this.refLine=new Uint32Array(this.columns+2);this.codingLine[0]=this.columns;this.codingPos=0;this.row=0;this.nextLine2D=this.encoding<0;this.inputBits=0;this.inputBuf=0;this.outputBits=0;this.rowsDone=!1;for(;0===(a=this._lookBits(12));)this._eatBits(1);1===a&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}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){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let s,c,l;if(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)}this._addPixels(t[this.codingPos]+s,n);t[this.codingPos]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,n);n^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){s=this._lookBits(12);if(this.eoline)for(;-1!==s&&1!==s;){this._eatBits(1);s=this._lookBits(12)}else for(;0===s;){this._eatBits(1);s=this._lookBits(12)}if(1===s){this._eatBits(12);h=!0}else-1===s&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}if(this.eoblock&&h&&this.byteAlign){s=this._lookBits(12);if(1===s){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(o=0;o<4;++o){s=this._lookBits(12);1!==s&&(0,r.info)("bad rtc code: "+s);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){s=this._lookBits(13);if(-1===s){this.eof=!0;return-1}if(s>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&s)}}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1];this.row++}if(this.outputBits>=8){c=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&t[this.codingPos]s){c<<=s;1&this.codingPos||(c|=255>>8-s);this.outputBits-=s;s=0}else{c<<=this.outputBits;1&this.codingPos||(c|=255>>8-this.outputBits);s-=this.outputBits;this.outputBits=0;if(t[this.codingPos]0){c<<=s;s=0}}}while(s)}this.black&&(c^=255);return c},_addPixels(e,t){const a=this.codingLine;let i=this.codingPos;if(e>a[i]){if(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]){if(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){this._eatBits(r);return[!0,t[1],!0]}}}return[!1,0,!1]},_getTwoDimCode(){let t,a=0;if(this.eoblock){a=this._lookBits(7);t=e[a];if(t&&t[0]>0){this._eatBits(t[0]);return t[1]}}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}(0,r.info)("Bad two dim code");return-1},_getWhiteCode(){let e,i=0;if(this.eoblock){i=this._lookBits(12);if(-1===i)return 1;e=i>>5==0?t[i]:a[i>>3];if(e[0]>0){this._eatBits(e[0]);return e[1]}}else{let e=this._findTableCode(1,9,a);if(e[0])return e[1];e=this._findTableCode(11,12,t);if(e[0])return e[1]}(0,r.info)("bad white code");this._eatBits(1);return 1},_getBlackCode(){let e,t;if(this.eoblock){e=this._lookBits(13);if(-1===e)return 1;t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];e=this._findTableCode(7,12,n,64);if(e[0])return e[1];e=this._findTableCode(10,13,i);if(e[0])return e[1]}(0,r.info)("bad black code");this._eatBits(1);return 1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}};return 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)}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){z=z<<1&y;for(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;u[0]=e[d++];for(;--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;for(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;if(!d.huffman){s=0===d.template?4:1;r=[];for(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;if(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){r=[];for(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++];b.mmr=!!(1&y);b.template=y>>1&3;b.prediction=!!(8&y);if(!b.mmr){s=0===b.template?4:1;r=[];for(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;a>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;if(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")}if(e.bitmapSizeSelector){n=O(c,t,a);c++}else n=T(1);s=e.aggregationInstancesSelector?O(c,t,a):T(1);return{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;if(U>=0&&U+x<=r&&q>=0&&q+A<=n)for(v=0;v=n)){_=y[t];j=R[v];for(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)}};function I(e,t){t||this.assignPrefixCodes(e);this.rootNode=new A(null);for(let t=0,a=e.length;t0&&this.rootNode.buildTree(a,a.prefixLength-1)}}I.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let a=0;for(let r=0;r=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;this.shift--;return e},readBits(e){let t,a=0;for(t=e-1;t>=0;t--)a|=this.readBit()<=this.end?-1:this.data[this.position++]}};function O(e,t,a){let r=0;for(let i=0,n=t.length;i>a&1;a--}}if(r&&!l){const e=5;for(let t=0;tfunction(e){for(var t=new C,a=0,r=e.length;a>=1}}return{imgData:d,width:l,height:h}}(e);this.width=a;this.height=r;return t}};return 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;if(255===e[t])if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}else{t++;this.clow+=t65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(e,t){let 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));this.a=c;e[t]=a<<1|i;return 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)}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}t.pos=i;return(0,r.shadow)(this,"maybeValidDimensions",s)},configurable:!0});e.prototype.getIR=function(e=!1){return(0,r.createObjectURL)(this.bytes,"image/jpeg",e)};return 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();c.index++;n.push(c);for(;n.length<=a;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(a+10){S--;return 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);a+=2;if(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)F--;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;if(0===(r=15&i))if(c<15){F=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;_=1===q?h[0].blocksPerLine*h[0].blocksPerColumn:y*l.mcusPerColumn;for(;G<_;){var W=u?Math.min(_-G,u):_;for(N=0;N=65488&&X<=65495))break;a+=2}if((j=d(t,a))&&j.invalid){(0,r.warn)("decodeScan - unexpected Scan data, current marker is: "+j.invalid);a=j.offset}return 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];if(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}else{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];if(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}else{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}}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);if(n&&n.invalid){(0,r.warn)("readDataBlock - incorrect length, current marker is: "+n.invalid);a=n.offset}var s=t.subarray(p,a);p+=s.length;return 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 Z=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 $=l(t,p,g,G,m,V,K,Y>>4,15&Y,Z);p+=$}catch(e){if(e instanceof s){(0,r.warn)(`${e.message} -- attempting to re-parse the JPEG image.`);return 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}this.width=g.samplesPerLine;this.height=g.scanLines;this.jfif=b;this.adobe=y;this.components=[];for(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;l>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();this.width=a-i;this.height=r-n;this.componentsCount=o;this.bitsPerComponent=8;return}}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=[];for(;d>3;E.mu=0}else{E.epsilon=e[d]>>3;E.mu=(7&e[d])<<8|e[d+1];d+=2}g.push(E)}T.SPqcds=g;if(c.mainHeader)c.QCD=T;else{c.currentTile.QCD=T;c.currentTile.QCC=[]}break;case 65373:y=(0,i.readUint16)(e,h);var O,P={};d=h+2;if(c.SIZ.Csiz<257)O=e[d++];else{O=(0,i.readUint16)(e,d);d+=2}switch(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)}P.noQuantization=8===m;P.scalarExpounded=p;P.guardBits=f>>5;g=[];for(;d>3;E.mu=0}else{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++];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++];if(B.entropyCoderWithCustomPrecincts){for(var M=[];d>4})}B.precinctsSizes=M}var R=[];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");if(R.length>0){l=!0;throw new Error("Unsupported COD options ("+R.join(", ")+")")}if(c.mainHeader)c.COD=B;else{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;if(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:if(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}};function a(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz);e.x1=Math.ceil(t.Xsiz/e.XRsiz);e.y0=Math.ceil(t.YOsiz/e.YRsiz);e.y1=Math.ceil(t.Ysiz/e.YRsiz);e.width=e.x1-e.x0;e.height=e.y1-e.y0}function o(e,t){for(var a,r=e.SIZ,i=[],n=Math.ceil((r.Xsiz-r.XTOsiz)/r.XTsiz),s=Math.ceil((r.Ysiz-r.YTOsiz)/r.YTsiz),o=0;o0?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);return 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)}else 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>=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];if(--e<0){this.value=a;return!1}this.currentLevel=e;(t=this.levels[e]).items[t.index]=a;return!0}};return 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){this.currentLevel=r;this.propagateValues();return!1}e>>=1;t>>=1;r++}this.currentLevel=r-1;return!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];t.items[t.index]=255;if(--e<0)return!1;this.currentLevel=e;(t=this.levels[e]).items[t.index]=a;return!0}};return 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){this.width=r;this.height=i;let c;c="HH"===n?a:"HL"===n?t:e;this.contextLabelTable=c;var l=r*i;this.neighborsSignificance=new Uint8Array(l);this.coefficentsSign=new Uint8Array(l);let h;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}if(e+1=a)break;s[d]&=-2;if(!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];if(t+10&&0!==u[a-l];if(e+1=0){o=9+r;c=this.decoder.readBit(this.contexts,o)}else{o=9-r;c=1^this.decoder.readBit(this.contexts,o)}return 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;r=(t|=0)-3;for(i=o+4;i--;r+=2)e[r]*=.8128930661159609;n=u*e[(r=t-2)-1];for(i=o+3;i--;r+=2){s=u*e[r+1];e[r]=d*e[r]-n-s;if(!i--)break;n=u*e[(r+=2)+1];e[r]=d*e[r]-n-s}n=h*e[(r=t-1)-1];for(i=o+2;i--;r+=2){s=h*e[r+1];e[r]-=n+s;if(!i--)break;n=h*e[(r+=2)+1];e[r]-=n+s}n=l*e[(r=t)-1];for(i=o+1;i--;r+=2){s=l*e[r+1];e[r]-=n+s;if(!i--)break;n=l*e[(r+=2)+1];e[r]-=n+s}if(0!==o){n=c*e[(r=t+1)-1];for(i=o;i--;r+=2){s=c*e[r+1];e[r]-=n+s;if(!i--)break;n=c*e[(r+=2)+1];e[r]-=n+s}}};return e}(),E=function(){function e(){F.call(this)}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};return 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}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}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){if(e>=32){this.low=this.high>>>e-32|0;this.high=0}else{this.low=this.low>>>e|this.high<<32-e;this.high=this.high>>>e|0}},shiftLeft:function(e){if(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}};return 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;if(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)}else{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;for(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;if(r){s[i++]=115;s[i++]=65;s[i++]=108;s[i++]=84}return 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);null!=h&&(l=h.get("CFM"));if(!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")}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)}};return 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);this.getRgbItem(e,t,a,0);return 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]){i[0]=r[0];i[1]=r[1];i[2]=r[2];return}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]){a[0]=t[0];a[1]=t[1];a[2]=t[2];return}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){super("CalRGB",3);if(!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];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];if(n<0||o<0||1!==s)throw new r.FormatError(`Invalid WhitePoint components for ${this.name}`+", no fallback available");if(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)}if(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);return 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];if(!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}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){this.borderStyle=new d;if((0,n.isDict)(e))if(e.has("BS")){const t=e.get("BS"),a=t.get("Type");if(!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");if(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)){this.appearance=a;return}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;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;n.addOp(r.OPS.beginAnnotation,[i.rect,h,l]);return e.getOperatorList({stream:this.appearance,task:t,resources:a,operatorList:n}).then(()=>{n.addOp(r.OPS.endAnnotation,[]);this.appearance.reset();return 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;if(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;if(e.has("CreationDate")){this.setCreationDate(e.get("CreationDate"));this.data.creationDate=this.creationDate}else this.data.creationDate=null;if(e.has("M")){this.setModificationDate(e.get("M"));this.data.modificationDate=this.modificationDate}else this.data.modificationDate=null;this.data.hasPopup=e.has("Popup");if(e.has("C")){this.setColor(e.getArray("C"));this.data.color=this.color}else 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);if("Sig"===a.fieldType){a.fieldValue=null;this.setFlags(r.AnnotationFlag.HIDDEN)}}_constructFieldName(e){if(!e.has("T")&&!e.has("Parent")){(0,r.warn)("Unknown field name, falling back to empty field name.");return""}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");if(!(0,n.isDict)(a))break;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}}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]);return 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]];if(i&&!Array.isArray(i)){s.iCurr=a;a++;if(!i.checkFn||(0,i.checkFn)(s)){n=i;i=null}else i=null}else 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}};return a}(),n=function(){function e(e){this.queue=e}e.prototype={push(e,t){this.queue.fnArray.push(e);this.queue.argsArray.push(t)},flush(){},reset(){}};return 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()}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){if(!(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}){if(!a){e(t);r()}}),a)}()}));a.compressionType!==r.CMapCompressionType.NONE&&this.builtInCMapCache.set(e,a);return a}}function a(){this.reset()}a.prototype={check:function(){if(++this.checked<100)return!1;this.checked=0;return this.endTime<=Date.now()},reset:function(){this.endTime=Date.now()+20;this.checked=0}};function d(e,t=!1){if(Array.isArray(e)){for(let t=0,a=e.length;tf){(0,r.warn)("Image exceeded maximum allowed size and was removed.");return}if(c.get("ImageMask","IM")||!1){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");(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);n&&(s[n]={fn:r.OPS.paintImageMaskXObject,args:d});return}var S=c.get("SMask","SM")||!1,x=c.get("Mask")||!1;if(a&&!S&&!x&&!(t instanceof v.JpegStream)&&l+h<200){u=new C.PDFImage({xref:this.xref,res:e,image:t,isInline:a,pdfFunctionFactory:this.pdfFunctionFactory}).createImageData(!0);i.addOp(r.OPS.paintInlineImageXObject,[u]);return}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}`}if(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));return 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=>{(0,r.warn)("Unable to decode image: "+e);if(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;t&&(c=(t=t.slice())[0].name);return 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});return 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);return e.loadedName})},handleText(e,a){const i=a.font,n=i.charsToGlyphs(e);if(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)}return 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}if((0,n.isDict)(f)){l=l.then(()=>this.handleSMask(f,e,a,i,s));o.push([u,!0])}else(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){(0,r.warn)(`${i}.`);return 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);a=l.fetchIfRef(c);if(!(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);b&&(m=c.toString());if(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)){this.fontCache.putAlias(c,v);return this.fontCache.get(c)}}else y[g]={fontID:s.Font.getFontID()};b&&(y[g].aliasRef=c);m=y[g].fontID}if(b)this.fontCache.put(c,u.promise);else{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)}p.then((function(e){if(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))});return u.promise},buildPath(e,t,a,i=!1){var n=e.length-1;a||(a=[]);if(n<0||e.fnArray[n]!==r.OPS.constructPath){if(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){this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.unknown});(0,r.warn)(`parseColorSpace - ignoring ColorSpace: "${e}".`);return 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");l=u.Pattern.parseShading(m,p,this.xref,o,this.handler,this.pdfFunctionFactory);e.addOp(t,l.getIR());return}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}){i=i||n.Dict.empty;o=o||new T;if(!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;if(!(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;if(e.vertical){p.width=Math.sqrt(a[0]*a[0]+a[1]*a[1]);p.height=0;p.vertical=!0}else{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;if(c){p.spaceWidth=c;p.fakeSpaceMin=.3*c;p.fakeMultiSpaceMin=1.5*c;p.fakeMultiSpaceMax=4*c;p.textRunBreakAllowed=!e.isMonospace}else{p.spaceWidth=0;p.fakeSpaceMin=1/0;p.fakeMultiSpaceMin=1/0;p.fakeMultiSpaceMax=0;p.textRunBreakAllowed=!1}p.initialized=!0;return 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;if(t.vertical){i+=p=c*d.fontMatrix[0]*d.fontSize+f}else{r+=m=(c*d.fontMatrix[0]*d.fontSize+f)*d.textHScale}d.translateTextMatrix(m,p);a.str.push(h)}if(t.vertical){a.lastAdvanceHeight=i;a.height+=Math.abs(i)}else{a.lastAdvanceWidth=r;a.width+=r}return a}function O(e,t){if(!(e0;)t.push(" ")}function P(){if(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}));var e,t,a;p.initialized=!1;p.str.length=0}}function B(){const e=m.items.length;if(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;if(!k.read(y))break;d=s.state;var F,E=y.fn;C=y.args;switch(0|E){case r.OPS.setFont:var N=C[0].name,M=C[1];if(d.font&&N===d.fontName&&M===d.fontSize)break;P();d.fontName=N;d.fontSize=M;f(A(N,null));return;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]);F=C[0]-C[1];if(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:F=d.calcTextLineMatrixAdvance(C[0],C[1],C[2],C[3],C[4],C[5]);if(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)}else{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;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){e();return}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){w[z]=!0;e();return}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}".`)}})));return;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){d.fontName=null;d.fontSize=X[1];f(A(null,X[0]));return}}if(m.items.length>=h.desiredSize){g=!0;break}}if(g)f(x);else{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")){f=e.get("Encoding");if((0,n.isDict)(f)){m=f.get("BaseEncoding");m=(0,n.isName)(m)?m.name:null;if(f.has("Differences"))for(var p=f.get("Differences"),b=0,y=0,v=p.length;y0;a.dict=e;return h.then(e=>{a.toUnicode=e;return this.buildToUnicode(a)}).then(e=>{a.toUnicode=e;c&&(a.cidToGidMap=this.readCidToGidMap(c,e));return 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}i=+a;if(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){e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0;if(e.hasIncludedToUnicodeMap){!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._buildSimpleFontToUnicode(e));return 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=[];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)))}));return 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);e.forEach((function(e,a){for(var r=[],i=0;i{if(e instanceof r.AbortException)return null;if(this.options.ignoreErrors){this.handler.send("UnsupportedFeature",{featureId:r.UNSUPPORTED_FEATURES.font});(0,r.warn)(`readToUnicode - ignoring ToUnicode data: "${e}".`);return 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){m=e.has("DW")?e.get("DW"):1e3;if(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);return 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;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"));return this._fallbackFontDict=e};return 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}e.prototype={send(e){if(!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}}this.preprocessCommand(o,t);e.fn=o;e.args=t;return!0}if(a===n.EOF)return!1;if(null!==a){null===t&&(t=[]);t.push(a);if(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)}}};return 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){a.charcode=r;a.length=n+1;return}}}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)}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:h.readHex(m,S);h.readHexNumber(p,S);a(p,m,S);s.addCodespaceRange(S+1,e(m,S),e(p,S));for(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);s=n.getObj();if(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);n=a.getObj();if(!(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}!n&&c&&(n=c);return n?w(e,a,n):Promise.resolve(e)}function w(e,t,a){return k(a,t).then((function(t){e.useCMap=t;if(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()")}};return 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}};return 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";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=[];if("Type3"!==a.type){this.cidEncoding=a.cidEncoding;this.vertical=a.vertical;if(this.vertical){this.vmetrics=a.vmetrics;this.defaultVMetrics=a.defaultVMetrics}if(t&&!t.isEmpty){[n,s]=function(e,{type:t,subtype:a,composite:i}){let n,s;if(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";else if(function(e){var t=e.peekBytes(4);return"OTTO"===(0,r.bytesToString)(t)}(e))n=i?"CIDFontType2":"OpenType";else if(function(e){var t=e.peekBytes(2);if(37===t[0]&&33===t[1])return!0;if(128===t[0]&&1===t[1])return!0;return!1}(e))n=i?"CIDFontType0":"MMType1"===t?"MMType1":"Type1";else if(function(e){const t=e.peekBytes(4);if(t[0]>=1&&t[3]>=1&&t[3]<=4)return!0;return!1}(e))if(i){n="CIDFontType0";s="CIDFontType0C"}else{n="MMType1"===t?"MMType1":"Type1";s="Type1C"}else{(0,r.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");n=t;s=a}return[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);if(this.isOpenType){b(a);n="OpenType"}break;default:throw new r.FormatError(`Font ${n} is not supported`)}}catch(e){(0,r.warn)(e);this.fallbackToSystemFont();return}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}}e.getFontID=(t=1,function(){return String(t++)});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){e>32767?e=32767:e<-32768&&(e=-32768);return 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){l+="\0\0\n"+(0,r.string32)(4+8*c+4+T.length);E="";for(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;if(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=[];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});if(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);e.pos=s;if("head"===t){o[8]=o[9]=o[10]=o[11]=0;o[17]|=32}return{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){!function(e,t,a){e[t+1]=a;e[t]=a>>>8}(o,0,c=-1);r.set(o,i);s.length=o.length;return s}var l,h=10,u=0;for(l=0;lo.length)return s;if(!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;return s}if(o.length-v>3){v=v+3&-4;r.set(o.subarray(0,v),i);s.length=v;return s}r.set(o,i);s.length=o.length;return 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{if(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){s=d[d.length-1];if(isNaN(s))(0,r.info)("TT: CALL empty stack (or invalid entry).");else{t.functionsUsed[s]=!0;if(s in t.functionsStackDeltas){const e=d.length+t.functionsStackDeltas[s];if(e<0){(0,r.warn)("TT: CALL invalid functions stack delta.");t.hintsValid=!1;return}d.length=e}else if(s in t.functionsDefined&&!g.includes(s)){f.push({data:c,i:l,stackTop:d.length-1});g.push(s);if(!(o=t.functionsDefined[s])){(0,r.warn)("TT: CALL non-existent function");t.hintsValid=!1;return}c=o.data;l=o.i}}}if(!p&&!y){let e=0;k<=142?e=w[k]:k>=192&&k<=223?e=-1:k>=224&&(e=-2);if(k>=113&&k<=117){i=d.pop();isNaN(i)||(e=2*-i)}for(;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));if(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:o.dsigTag=e.getInt32()>>>0;o.dsigLength=e.getInt32()>>>0;o.dsigOffset=e.getInt32()>>>0;return 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){F=new d.Stream(x["CFF "].data);A=new T(F,o);b(o);return 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;if(R>65535){U=!1;R=L;(0,r.warn)("Not enough space in glyfs to duplicate first glyph.")}var q=0,j=0;if(M>=65536&&x.maxp.length>=22){t.pos+=8;if(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};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){(0,r.warn)("TT: invalid function id: "+a);e.hintsValid=!1;return}if(e.functionsUsed[a]&&!e.functionsDefined[a]){(0,r.warn)("TT: undefined function: "+a);e.hintsValid=!1;return}}}(n,i);if(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();if(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);if(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);if(!x.head)throw new r.FormatError('Required "head" table is not found');!function(e,t,i){var n,s,o,c,l=e.data,h=(n=l[0],s=l[1],o=l[2],c=l[3],(n<<24)+(s<<16)+(o<<8)+c);if(h>>16!=1){(0,r.info)("Attempting to fix invalid version in head table: "+h);l[0]=0;l[1]=1;l[2]=0;l[3]=0}var u=a(l[50],l[51]);if(u<0||u>1){(0,r.info)("Attempting to fix invalid indexToLocFormat in head table: "+u);var d=t+1;if(i===d<<1){l[50]=0;l[51]=0}else{if(i!==d<<2)throw new r.FormatError("Could not fix indexToLocFormat: "+u);l[50]=0;l[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;if(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}}else{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);l(d,0,w);for(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);else{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;if(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');if(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;$?a=t:void 0!==Y[t]&&(a=Y[t]);a>=0&&a>>0,g=!1;if(!o||o.platformId!==u||o.encodingId!==d){if(0===u&&0===d)g=!0;else if(1===u&&0===d)g=!0;else if(3!==u||1!==d||!i&&o){if(a&&3===u&&0===d){g=!0;l=!0}}else{g=!0;a||(l=!0)}g&&(o={platformId:u,encodingId:d,offset:f});if(l)break}}o&&(t.pos=s+o.offset);if(!o||-1===t.peekByte()){(0,r.warn)("Could not find a preferred cmap table.");return{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===Z&&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);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();if(a<4&&768&r)return!1;if(t.getUint16()>t.getUint16())return!1;t.getBytes(6);if(0===t.getUint16())return!1;e.data[8]=e.data[9]=0;return!0}(x["OS/2"])||(x["OS/2"]={tag:"OS/2",data:B(o,he.charCodeToGlyphId,W)});if(!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)if(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;l.charCodeToGlyphId[l.nextAvailableFontCharCode]=t;return 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{o=s.StandardEncoding;for(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}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){o+=r;for(;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");if(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++];if(30===a)return function(){var a="";const r=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];var i=e.length;for(;t>4,o=15&n;if(15===s)break;a+=r[s];if(15===o)break;a+=r[o]}return parseFloat(a)}();if(28===a)return a=((a=e[t++])<<24|e[t++]<<16)>>16;if(29===a)return a=(a=(a=(a=e[t++])<<8|e[t++])<<8|e[t++])<<8|e[t++];if(a>=32&&a<=246)return a-139;if(a>=247&&a<=250)return 256*(a-247)+e[t++]+108;if(a>=251&&a<=254)return-256*(a-251)-e[t++]-108;(0,r.warn)('CFFParser_parseDict: "'+a+'" is a reserved command.');return 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;if(this.seacAnalysisEnabled){a.seac=c.slice(o,o+4);return!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)){d=e[u];(0,r.warn)("Missing subrsIndex for "+d.id);return!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)){d=e[u];(0,r.warn)("Out of bounds subrIndex for "+d.id);return!1}a.stackSize=o;a.callDepth++;if(!this.parseCharString(a,g.get(p),n,s))return!1;a.callDepth--;o=a.stackSize;continue}if(11===u){a.stackSize=o;return!0}d=e[u]}if(d){if(d.stem){a.hints+=o>>1;if(3===u||23===u)a.hasVStems=!0;else if(a.hasVStems&&(1===u||18===u)){(0,r.warn)("CFF stem hints are in wrong order");i[h-1]=1===u?3:23}}if("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])}if("stackDelta"in d){"stackFn"in d&&d.stackFn(c,o);o+=d.stackDelta}else if(d.stackClearing)o=0;else if(d.resetStack){o=0;a.undefStack=!1}else if(d.undefStack){o=0;a.undefStack=!0;a.firstStackClearing=!1}}}a.stackSize=o;return!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);f&&(f=this.parseCharString(d,u,g,a));if(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);e.privateDict=o;if(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"];t-=1;switch(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}};return 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=[]}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);if(-1!==t)return t;t=this.strings.indexOf(e);return-1!==t?t+391:-1},add:function(e){this.strings.push(e)},get count(){return this.strings.length}};return e}();t.CFFStrings=h;var u=function(){function e(){this.objects=[];this.length=0}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}};return 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)}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]}};return e}();t.CFFFDSelect=y;var v=function(){function e(){this.offsets=Object.create(null)}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}}};return e}(),w=function(){function e(e){this.cff=e}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);t.add(i);if(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:a=new Uint8Array(1+e.fdSelect.length);a[0]=t;for(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],t>=a.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;t<1240?a=107:t<33900&&(a=1131);return 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;o=i+l+14;s=[];for(c=0;c>1;a=0&&e>16,h=0,u=0;c+=10;if(l<0)do{o=t[c]<<8|t[c+1];var d,f,g=t[c+2]<<8|t[c+3];c+=4;if(1&o){d=(t[c]<<24|t[c+1]<<16)>>16;f=(t[c+2]<<24|t[c+3]<<16)>>16;c+=4}else{d=t[c++];f=t[c++]}if(2&o){h=d;u=f}else{h=0;u=0}var m=1,p=1,b=0,y=0;if(8&o){m=p=(t[c]<<24|t[c+1]<<16)/1073741824;c+=2}else if(64&o){m=(t[c]<<24|t[c+1]<<16)/1073741824;p=(t[c+2]<<24|t[c+3]<<16)/1073741824;c+=4}else if(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];if(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);if(0===c.length)break;u+=c.shift();g(l,u)}break;case 7:for(;c.length>0;){u+=c.shift();g(l,u);if(0===c.length)break;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:x=c.pop();A=null;if(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:c.length%2&&(l+=c.shift());for(;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:c.length%2&&(u+=c.shift());for(;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);if(0===c.length)break;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);if(0===c.length)break;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}`);if(F<247)c.push(F-139);else if(F<251)c.push(256*(F-247)+p[b++]+108);else if(F<255)c.push(256*-(F-251)-p[b++]-108);else{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);else{s=65536*s|0;this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s)}}this.output.push.apply(this.output,t);a?this.stack.splice(i,e):this.stack.length=0;return!1}};return 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=0|a,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,r,n)}(s,55665,4))}this.seacAnalysisEnabled=!!i;this.stream=a;this.nextChar()}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)){this.nextChar();return 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":this.getToken();this.getToken();this.getToken();this.getToken();for(;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":this.readInt();this.getToken();for(;"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,0;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||I<=0)(0,r.info)("Bad shading domain.");else{var T,E=new Float32Array(o.numComps),O=new Float32Array(1);for(let e=0;e<=10;e++){O[0]=h+e*I;A(O,0,E,0);T=o.getRgb(E,0);var P=r.Util.makeCssRgb(T[0],T[1],T[2]);F.push([e/10,P])}var B="transparent";if(e.has("Background")){T=o.getRgb(e.get("Background"),0);B=r.Util.makeCssRgb(T[0],T[1],T[2])}if(!f){F.unshift([0,B]);F[1][0]+=g.SMALL_NUMBER}if(!m){F[F.length-1][0]-=g.SMALL_NUMBER;F.push([1,B])}this.colorStops=F}}e.prototype={getIR:function(){var e,t,a,i,n,s=this.coordsArr,l=this.shadingType;if(l===o){t=[s[0],s[1]];a=[s[2],s[3]];i=null;n=null;e="axial"}else if(l===c){t=[s[0],s[1]];a=[s[3],s[4]];i=s[2];n=s[5];e="radial"}else(0,r.unreachable)(`getPattern type unknown: ${l}`);var h=this.matrix;if(h){t=r.Util.applyTransform(t,h);a=r.Util.applyTransform(a,h);if(l===c){var u=r.Util.singularValueDecompose2dScale(h);i*=u[0];n*=u[1]}}return["RadialAxial",e,this.bbox,this.colorStops,t,a,i,n]}};return e}();g.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();if(e<0)return!1;this.buffer=e;this.bufferLength=8;return!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();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}}else 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}if(f>0){f--;d[l]=p}a.set(p,r)}else a.set(m,r)}}};var c=function(){function e(e){this.stack=e?Array.prototype.slice.call(e,0):[]}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(){}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(")")}if(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;t.length=0;t[0]=String.fromCharCode(e);for(;(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}else{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}o=0;switch(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");a=r.ColorSpace.parse(a,this.xref,this.resources,this.pdfFunctionFactory);return 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));return e}):Promise.resolve(e)}function t(e,t,a,r){(e=t+e*a)<0?e=0:e>r&&(e=r);return 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}if(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}this.bpc=y;if(!this.imageMask){var v=f.get("ColorSpace","CS");if(!v){(0,r.info)("JPX images (which do not require color spaces)");switch(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}this.decode=f.getArray("Decode","D");this.needsDecode=!1;if(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){(n=new Uint8ClampedArray(o)).set(e);for(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;l=0;for(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;"DeviceGray"===this.colorSpace.name&&1===u?f=r.ImageKind.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==u||this.needsDecode||(f=r.ImageKind.RGB_24BPP);if(f&&!this.smask&&!this.mask&&a===l&&i===h){n.kind=f;t=this.getImageBytes(h*d);if(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){this._processStreamMessage(t);return}if(t.callback){const e=t.callbackId,a=this.callbackCapabilities[e];if(!a)throw new Error(`Cannot resolve callback ${e}`);delete this.callbackCapabilities[e];if(t.callback===i)a.resolve(t.data);else{if(t.callback!==n)throw new Error("Unexpected callback case");a.reject(g(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,s=t.sourceName;new Promise((function(e){e(r(t.data))})).then((function(r){a.postMessage({sourceName:e,targetName:s,callback:i,callbackId:t.callbackId,data:r})}),(function(r){a.postMessage({sourceName:e,targetName:s,callback:n,callbackId:t.callbackId,reason:g(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,i){const n=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:a=>{const s=(0,r.createPromiseCapability)();this.streamControllers[n]={controller:a,startCall:s,pullCall:null,cancelCall:null,isClosed:!1};this._postMessage({sourceName:o,targetName:c,action:e,streamId:n,data:t,desiredSize:a.desiredSize},i);return s.promise},pull:e=>{const t=(0,r.createPromiseCapability)();this.streamControllers[n].pullCall=t;l.postMessage({sourceName:o,targetName:c,stream:u,streamId:n,desiredSize:e.desiredSize});return t.promise},cancel:e=>{(0,r.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,r.createPromiseCapability)();this.streamControllers[n].cancelCall=t;this.streamControllers[n].isClosed=!0;l.postMessage({sourceName:o,targetName:c,stream:s,streamId:n,reason:g(e)});return t.promise}},a)}_createStreamSink(e){const t=this,a=this.actionHandler[e.action],i=e.streamId,n=this.sourceName,s=e.sourceName,o=this.comObj,u={enqueue(e,a=1,o){if(this.isCancelled)return;const c=this.desiredSize;this.desiredSize-=a;if(c>0&&this.desiredSize<=0){this.sinkCapability=(0,r.createPromiseCapability)();this.ready=this.sinkCapability.promise}t._postMessage({sourceName:n,targetName:s,stream:l,streamId:i,chunk:e},o)},close(){if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:c,streamId:i});delete t.streamSinks[i]}},error(e){(0,r.assert)(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:h,streamId:i,reason:g(e)})}},sinkCapability:(0,r.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};u.sinkCapability.resolve();u.ready=u.sinkCapability.promise;this.streamSinks[i]=u;new Promise((function(t){t(a(e.data,u))})).then((function(){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,success:!0})}),(function(e){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,reason:g(e)})}))}_processStreamMessage(e){const t=e.streamId,a=this.sourceName,i=e.sourceName,n=this.comObj;switch(e.stream){case f:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(g(e.reason));break;case d:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(g(e.reason));break;case u:if(!this.streamSinks[t]){n.postMessage({sourceName:a,targetName:i,stream:d,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:m}=this.streamSinks[e.streamId];new Promise((function(e){e(m&&m())})).then((function(){n.postMessage({sourceName:a,targetName:i,stream:d,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:a,targetName:i,stream:d,streamId:t,reason:g(e)})}));break;case l:(0,r.assert)(this.streamControllers[t],"enqueue should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case c:(0,r.assert)(this.streamControllers[t],"close should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].isClosed=!0;this.streamControllers[t].controller.close();this._deleteStreamController(t);break;case h:(0,r.assert)(this.streamControllers[t],"error should have stream controller");this.streamControllers[t].controller.error(g(e.reason));this._deleteStreamController(t);break;case o:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(g(e.reason));this._deleteStreamController(t);break;case s:if(!this.streamSinks[t])break;const{onCancel:p}=this.streamSinks[e.streamId];new Promise((function(t){t(p&&p(g(e.reason)))})).then((function(){n.postMessage({sourceName:a,targetName:i,stream:o,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:a,targetName:i,stream:o,streamId:t,reason:g(e)})}));this.streamSinks[t].sinkCapability.reject(g(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(){(0,r.assert)(!this._fullRequestReader);this._fullRequestReader=new i(this._msgHandler);return this._fullRequestReader}getRangeReader(e,t){const a=new n(e,t,this._msgHandler);this._rangeRequestReaders.push(a);return 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)}}}])})); \ No newline at end of file +!function webpackUniversalModuleDefinition(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 __w_pdfjs_require__(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};e[r].call(a.exports,a,a.exports,__w_pdfjs_require__);a.l=!0;return a.exports}__w_pdfjs_require__.m=e;__w_pdfjs_require__.c=t;__w_pdfjs_require__.d=function(e,t,r){__w_pdfjs_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})};__w_pdfjs_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});Object.defineProperty(e,"__esModule",{value:!0})};__w_pdfjs_require__.t=function(e,t){1&t&&(e=__w_pdfjs_require__(e));if(8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);__w_pdfjs_require__.r(r);Object.defineProperty(r,"default",{enumerable:!0,value:e});if(2&t&&"string"!=typeof e)for(var a in e)__w_pdfjs_require__.d(r,a,function(t){return e[t]}.bind(null,a));return r};__w_pdfjs_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};__w_pdfjs_require__.d(t,"a",t);return t};__w_pdfjs_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};__w_pdfjs_require__.p="";return __w_pdfjs_require__(__w_pdfjs_require__.s=0)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"WorkerMessageHandler",{enumerable:!0,get:function(){return a.WorkerMessageHandler}});var a=r(1)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.WorkerMessageHandler=t.WorkerTask=void 0;var a=r(2),i=r(5),n=r(6),s=r(27),o=r(4),c=r(46),l=r(47),h=r(8);class WorkerTask{constructor(e){this.name=e;this.terminated=!1;this._capability=(0,a.createPromiseCapability)()}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")}}t.WorkerTask=WorkerTask;class WorkerMessageHandler{static setup(e,t){var r=!1;e.on("test",(function wphSetupTest(t){if(r)return;r=!0;if(!(t instanceof Uint8Array)){e.send("test",null);return}const a=255===t[0];e.postMessageTransfers=a;e.send("test",{supportTransfers:a})}));e.on("configure",(function wphConfigure(e){(0,a.setVerbosityLevel)(e.verbosity)}));e.on("GetDocRequest",(function wphSetupDoc(e){return WorkerMessageHandler.createDocumentHandler(e,t)}))}static createDocumentHandler(e,t){var r,o=!1,u=null,d=[];const f=(0,a.getVerbosityLevel)(),g=e.apiVersion;if("2.6.347"!==g)throw new Error(`The API version "${g}" does not match the Worker version "2.6.347".`);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.");if("undefined"==typeof ReadableStream||void 0===Promise.allSettled)throw new Error("The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream` and/or `Promise.allSettled`); please use an ES5-compatible build instead.");var p=e.docId,b=e.docBaseUrl,y=e.docId+"_worker",v=new c.MessageHandler(y,p,t);v.postMessageTransfers=e.postMessageTransfers;function ensureNotTerminated(){if(o)throw new Error("Worker was terminated")}function startWorkerTask(e){d.push(e)}function finishWorkerTask(e){e.finish();var t=d.indexOf(e);d.splice(t,1)}async function loadDocument(e){await r.ensureDoc("checkHeader");await r.ensureDoc("parseStartXRef");await r.ensureDoc("parse",[e]);e||await r.ensureDoc("checkFirstPage");const[t,a]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprint")]);return{numPages:t,fingerprint:a}}function getPdfManager(e,t){var r=(0,a.createPromiseCapability)();let i;var s=e.source;if(s.data){try{i=new n.LocalPdfManager(p,s.data,s.password,t,b);r.resolve(i)}catch(e){r.reject(e)}return r.promise}var o,c=[];try{o=new l.PDFWorkerStream(v)}catch(e){r.reject(e);return r.promise}var h=o.getFullReader();h.headersReady.then((function(){if(h.isRangeSupported){var e=s.disableAutoFetch||h.isStreamingSupported;i=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{let r=[];for(const e of t)r=e.filter(e=>null!==e).reduce((e,t)=>e.concat(t),r);if(0===r.length)return e.bytes;const n=o.xref;let c=Object.create(null);if(n.trailer){const e=Object.create(null),t=n.trailer.get("Info")||null;t&&t.forEach((t,r)=>{(0,a.isString)(t)&&(0,a.isString)(r)&&(e[t]=(0,a.stringToPDFString)(r))});c={rootRef:n.trailer.getRaw("Root")||null,encrypt:n.trailer.getRaw("Encrypt")||null,newRef:n.getNewRef(),infoRef:n.trailer.getRaw("Info")||null,info:e,fileIds:n.trailer.getRaw("ID")||null,startXRef:o.startXRef,filename:i}}n.resetNewRef();return(0,s.incrementalUpdate)(e.bytes,c,r)})}));v.on("GetOperatorList",(function wphSetupRenderPage(e,t){var i=e.pageIndex;r.getPage(i).then((function(r){var n=new WorkerTask("GetOperatorList: page "+i);startWorkerTask(n);const s=f>=a.VerbosityLevel.INFOS?Date.now():0;r.getOperatorList({handler:v,sink:t,task:n,intent:e.intent,renderInteractiveForms:e.renderInteractiveForms,annotationStorage:e.annotationStorage}).then((function(e){finishWorkerTask(n);s&&(0,a.info)(`page=${i+1} - getOperatorList: time=${Date.now()-s}ms, len=${e.length}`);t.close()}),(function(e){finishWorkerTask(n);if(!n.terminated){v.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList});t.error(e)}}))}))}),this);v.on("GetTextContent",(function wphExtractText(e,t){var i=e.pageIndex;t.onPull=function(e){};t.onCancel=function(e){};r.getPage(i).then((function(r){var n=new WorkerTask("GetTextContent: page "+i);startWorkerTask(n);const s=f>=a.VerbosityLevel.INFOS?Date.now():0;r.extractTextContent({handler:v,task:n,sink:t,normalizeWhitespace:e.normalizeWhitespace,combineTextItems:e.combineTextItems}).then((function(){finishWorkerTask(n);s&&(0,a.info)(`page=${i+1} - getTextContent: time=`+(Date.now()-s)+"ms");t.close()}),(function(e){finishWorkerTask(n);n.terminated||t.error(e)}))}))}));v.on("FontFallback",(function(e){return r.fontFallback(e.id,v)}));v.on("Cleanup",(function wphCleanup(e){return r.cleanup(!0)}));v.on("Terminate",(function wphTerminate(e){o=!0;const t=[];if(r){r.terminate(new a.AbortException("Worker was terminated."));const e=r.cleanup();t.push(e);r=null}else(0,i.clearPrimitiveCaches)();u&&u(new a.AbortException("Worker was terminated."));d.forEach((function(e){t.push(e.finished);e.terminate()}));return Promise.all(t).then((function(){v.destroy();v=null}))}));v.on("Ready",(function wphReady(t){!function setupDoc(e){function onSuccess(e){ensureNotTerminated();v.send("GetDoc",{pdfInfo:e})}function onFailure(e){ensureNotTerminated();if(e instanceof a.PasswordException){var t=new WorkerTask("PasswordException: response "+e.code);startWorkerTask(t);v.sendWithPromise("PasswordRequest",e).then((function({password:e}){finishWorkerTask(t);r.updatePassword(e);pdfManagerReady()})).catch((function(){finishWorkerTask(t);v.send("DocException",e)}))}else e instanceof a.InvalidPDFException||e instanceof a.MissingPDFException||e instanceof a.UnexpectedResponseException||e instanceof a.UnknownErrorException?v.send("DocException",e):v.send("DocException",new a.UnknownErrorException(e.message,e.toString()))}function pdfManagerReady(){ensureNotTerminated();loadDocument(!1).then(onSuccess,(function(e){ensureNotTerminated();if(e instanceof h.XRefParseException){r.requestLoadedStream();r.onLoadedStream().then((function(){ensureNotTerminated();loadDocument(!0).then(onSuccess,onFailure)}))}else onFailure(e)}))}ensureNotTerminated();getPdfManager(e,{maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties}).then((function(e){if(o){e.terminate(new a.AbortException("Worker was terminated."));throw new Error("Worker was terminated")}(r=e).onLoadedStream().then((function(e){v.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(pdfManagerReady,onFailure)}(e);e=null}));return y}static initializeFromPort(e){var t=new c.MessageHandler("worker","main",e);WorkerMessageHandler.setup(t,e);t.send("ready",null)}}t.WorkerMessageHandler=WorkerMessageHandler;"undefined"==typeof window&&!o.isNodeJS&&"undefined"!=typeof self&&function isMessagePort(e){return"function"==typeof e.postMessage&&"onmessage"in e}(self)&&WorkerMessageHandler.initializeFromPort(self)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let a=0;at});e.promise=new Promise((function(r,a){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;a(e)}}));return e};t.escapeString=function escapeString(e){return e.replace(/([\(\)\\])/g,"\\$1")};t.getModificationDate=function getModificationDate(e=new Date(Date.now())){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),(e.getUTCDate()+1).toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return i};t.info=function info(e){i>=a.INFOS&&console.log("Info: "+e)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;return e.every((function(e,r){return e===t[r]}))};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isString=function isString(e){return"string"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let r;try{r=new URL(e);if(!r.origin||"null"===r.origin)return!1}catch(e){return!1}const a=new URL(t,r);return r.origin===a.origin};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null};t.removeNullCharacters=function removeNullCharacters(e){if("string"!=typeof e){warn("The argument for removeNullCharacters must be a string.");return e}return e.replace(s,"")};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(i=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let a=2;a=a.WARNINGS&&console.log("Warning: "+e)}function unreachable(e){throw new Error(e)}function assert(e,t){e||unreachable(t)}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const n=function BaseExceptionClosure(){function BaseException(e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=this.constructor.name}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=n;t.PasswordException=class PasswordException extends n{constructor(e,t){super(e);this.code=t}};t.UnknownErrorException=class UnknownErrorException extends n{constructor(e,t){super(e);this.details=t}};t.InvalidPDFException=class InvalidPDFException extends n{};t.MissingPDFException=class MissingPDFException extends n{};t.UnexpectedResponseException=class UnexpectedResponseException extends n{constructor(e,t){super(e);this.status=t}};t.FormatError=class FormatError extends n{};t.AbortException=class AbortException extends n{};const s=/\x00/g;function stringToBytes(e){assert("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let a=0;ae[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){function compare(e,t){return e-t}const r=[e[0],e[2],t[0],t[2]].sort(compare),a=[e[1],e[3],t[1],t[3]].sort(compare),i=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(r[0]===e[0]&&r[1]===t[0]||r[0]===t[0]&&r[1]===e[0]))return null;i[0]=r[1];i[2]=r[2];if(!(a[0]===e[1]&&a[1]===t[1]||a[0]===t[1]&&a[1]===e[1]))return null;i[1]=a[1];i[3]=a[2];return i}}t.Util=Util;const h=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];const u=function createObjectURLClosure(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";return function createObjectURL(t,r,a=!1){if(!a&&URL.createObjectURL){const e=new Blob([t],{type:r});return URL.createObjectURL(e)}let i=`data:${r};base64,`;for(let r=0,a=t.length;r>2]+e[(3&n)<<4|s>>4]+e[r+1>6:64]+e[r+20?a:Dict.empty}const i=new Map;for(const e of t)if(e instanceof Dict)for(const[t,r]of Object.entries(e._map)){let e=i.get(t);if(void 0===e){e=[];i.set(t,e)}e.push(r)}for(const[t,r]of i){if(1===r.length||!(r[0]instanceof Dict)){a._map[t]=r[0];continue}const i=new Dict(e);for(const e of r)if(e instanceof Dict)for(const[t,r]of Object.entries(e._map))void 0===i._map[t]&&(i._map[t]=r);i.size>0&&(a._map[t]=i)}i.clear();return a.size>0?a:Dict.empty};return Dict}();t.Dict=s;var o=function RefClosure(){let e=Object.create(null);function Ref(e,t){this.num=e;this.gen=t}Ref.prototype={toString:function Ref_toString(){return 0===this.gen?this.num+"R":`${this.num}R${this.gen}`}};Ref.get=function(t,r){const a=0===r?t+"R":`${t}R${r}`,i=e[a];return i||(e[a]=new Ref(t,r))};Ref._clearCache=function(){e=Object.create(null)};return Ref}();t.Ref=o;t.RefSet=class RefSet{constructor(){this._set=new Set}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}};t.RefSetCache=class RefSetCache{constructor(){this._map=new Map}get size(){return this._map.size}get(e){return this._map.get(e.toString())}has(e){return this._map.has(e.toString())}put(e,t){this._map.set(e.toString(),t)}putAlias(e,t){this._map.set(e.toString(),this.get(t))}forEach(e){for(const t of this._map.values())e(t)}clear(){this._map.clear()}};function isName(e,t){return e instanceof i&&(void 0===t||e.name===t)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.NetworkPdfManager=t.LocalPdfManager=void 0;var a=r(2),i=r(7),n=r(8),s=r(9),o=r(12);class BasePdfManager{constructor(){this.constructor===BasePdfManager&&(0,a.unreachable)("Cannot initialize BasePdfManager.")}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){let e=null;if(this._docBaseUrl){const t=(0,a.createValidAbsoluteUrl)(this._docBaseUrl);t?e=t.href:(0,a.warn)(`Invalid absolute docBaseUrl: "${this._docBaseUrl}".`)}return(0,a.shadow)(this,"docBaseUrl",e)}onLoadedStream(){(0,a.unreachable)("Abstract method `onLoadedStream` called")}ensureDoc(e,t){return this.ensure(this.pdfDocument,e,t)}ensureXRef(e,t){return this.ensure(this.pdfDocument.xref,e,t)}ensureCatalog(e,t){return this.ensure(this.pdfDocument.catalog,e,t)}getPage(e){return this.pdfDocument.getPage(e)}fontFallback(e,t){return this.pdfDocument.fontFallback(e,t)}cleanup(e=!1){return this.pdfDocument.cleanup(e)}async ensure(e,t,r){(0,a.unreachable)("Abstract method `ensure` called")}requestRange(e,t){(0,a.unreachable)("Abstract method `requestRange` called")}requestLoadedStream(){(0,a.unreachable)("Abstract method `requestLoadedStream` called")}sendProgressiveData(e){(0,a.unreachable)("Abstract method `sendProgressiveData` called")}updatePassword(e){this._password=e}terminate(e){(0,a.unreachable)("Abstract method `terminate` called")}}t.LocalPdfManager=class LocalPdfManager extends BasePdfManager{constructor(e,t,r,a,i){super();this._docId=e;this._password=r;this._docBaseUrl=i;this.evaluatorOptions=a;const n=new o.Stream(t);this.pdfDocument=new s.PDFDocument(this,n);this._loadedStreamPromise=Promise.resolve(n)}async ensure(e,t,r){const a=e[t];return"function"==typeof a?a.apply(e,r):a}requestRange(e,t){return Promise.resolve()}requestLoadedStream(){}onLoadedStream(){return this._loadedStreamPromise}terminate(e){}};t.NetworkPdfManager=class NetworkPdfManager extends BasePdfManager{constructor(e,t,r,a,n){super();this._docId=e;this._password=r.password;this._docBaseUrl=n;this.msgHandler=r.msgHandler;this.evaluatorOptions=a;this.streamManager=new i.ChunkedStreamManager(t,{msgHandler:r.msgHandler,length:r.length,disableAutoFetch:r.disableAutoFetch,rangeChunkSize:r.rangeChunkSize});this.pdfDocument=new s.PDFDocument(this,this.streamManager.getStream())}async ensure(e,t,r){try{const a=e[t];return"function"==typeof a?a.apply(e,r):a}catch(a){if(!(a instanceof n.MissingDataException))throw a;await this.requestRange(a.begin,a.end);return this.ensure(e,t,r)}}requestRange(e,t){return this.streamManager.requestRange(e,t)}requestLoadedStream(){this.streamManager.requestAllChunks()}sendProgressiveData(e){this.streamManager.onReceiveData({chunk:e})}onLoadedStream(){return this.streamManager.onLoadedStream()}terminate(e){this.streamManager.abort(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ChunkedStreamManager=t.ChunkedStream=void 0;var a=r(2),i=r(8);class ChunkedStream{constructor(e,t,r){this.bytes=new Uint8Array(e);this.start=0;this.pos=0;this.end=e;this.chunkSize=t;this._loadedChunks=new Set;this.numChunks=Math.ceil(e/t);this.manager=r;this.progressiveDataLength=0;this.lastSuccessfulEnsureByteChunk=-1}getMissingChunks(){const e=[];for(let t=0,r=this.numChunks;t=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=r;e=t)return;if(t<=this.progressiveDataLength)return;const r=this.chunkSize,a=Math.floor(e/r),n=Math.floor((t-1)/r)+1;for(let r=a;r=this.end)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return 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 r=this.bytes,a=this.pos,i=this.end;if(!e){i>this.progressiveDataLength&&this.ensureRange(a,i);const e=r.subarray(a,i);return t?new Uint8ClampedArray(e):e}let n=a+e;n>i&&(n=i);n>this.progressiveDataLength&&this.ensureRange(a,n);this.pos=n;const s=r.subarray(a,n);return t?new Uint8ClampedArray(s):s}peekByte(){const e=this.getByte();-1!==e&&this.pos--;return e}peekBytes(e,t=!1){const r=this.getBytes(e,t);this.pos-=r.length;return r}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);t>this.progressiveDataLength&&this.ensureRange(e,t);return 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,r){t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e);function ChunkedStreamSubstream(){}ChunkedStreamSubstream.prototype=Object.create(this);ChunkedStreamSubstream.prototype.getMissingChunks=function(){const e=this.chunkSize,t=Math.floor(this.start/e),r=Math.floor((this.end-1)/e)+1,a=[];for(let e=t;e{const readChunk=s=>{try{if(!s.done){const e=s.value;i.push(e);n+=(0,a.arrayByteLength)(e);r.isStreamingSupported&&this.onProgress({loaded:n});r.read().then(readChunk,t);return}const o=(0,a.arraysToBytes)(i);i=null;e(o)}catch(e){t(e)}};r.read().then(readChunk,t)}).then(t=>{this.aborted||this.onReceiveData({chunk:t,begin:e})})}requestAllChunks(){const e=this.stream.getMissingChunks();this._requestChunks(e);return this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,r=new Set;this._chunksNeededByRequest.set(t,r);for(const t of e)this.stream.hasChunk(t)||r.add(t);if(0===r.size)return Promise.resolve();const i=(0,a.createPromiseCapability)();this._promisesByRequest.set(t,i);const n=[];for(const e of r){let r=this._requestsByChunk.get(e);if(!r){r=[];this._requestsByChunk.set(e,r);n.push(e)}r.push(t)}if(n.length>0){const e=this.groupChunks(n);for(const t of e){const e=t.beginChunk*this.chunkSize,r=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,r)}}return i.promise.catch(e=>{if(!this.aborted)throw e})}getStream(){return this.stream}requestRange(e,t){t=Math.min(t,this.length);const r=this.getBeginChunk(e),a=this.getEndChunk(t),i=[];for(let e=r;e=0&&a+1!==n){t.push({beginChunk:r,endChunk:a+1});r=n}i+1===e.length&&t.push({beginChunk:r,endChunk:n+1});a=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,r=void 0===e.begin,a=r?this.progressiveDataLength:e.begin,i=a+t.byteLength,n=Math.floor(a/this.chunkSize),s=i0||o.push(r)}}}if(!this.disableAutoFetch&&0===this._requestsByChunk.size){let e;if(1===this.stream.numChunksLoaded){const t=this.stream.numChunks-1;this.stream.hasChunk(t)||(e=t)}else e=this.stream.nextEmptyChunk(s);Number.isInteger(e)&&this._requestChunks([e])}for(const e of o){const t=this._promisesByRequest.get(e);this._promisesByRequest.delete(e);t.resolve()}this.msgHandler.send("DocProgress",{loaded:this.stream.numChunksLoaded*this.chunkSize,total:this.length})}onError(e){this._loadedStreamCapability.reject(e)}getBeginChunk(e){return Math.floor(e/this.chunkSize)}getEndChunk(e){return Math.floor((e-1)/this.chunkSize)+1}abort(e){this.aborted=!0;this.pdfNetworkStream&&this.pdfNetworkStream.cancelAllRequests(e);for(const t of this._promisesByRequest.values())t.reject(e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.getInheritableProperty=function getInheritableProperty({dict:e,key:t,getArray:r=!1,stopWhenFound:i=!0}){let n,s=0;for(;e;){const o=r?e.getArray(t):e.get(t);if(void 0!==o){if(i)return o;n||(n=[]);n.push(o)}if(++s>100){(0,a.warn)(`getInheritableProperty: maximum loop count exceeded for "${t}"`);break}e=e.get("Parent")}return n};t.toRomanNumerals=function toRomanNumerals(e,t=!1){(0,a.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const r=[];let n;for(;e>=1e3;){e-=1e3;r.push("M")}n=e/100|0;e%=100;r.push(i[n]);n=e/10|0;e%=10;r.push(i[10+n]);r.push(i[20+e]);const s=r.join("");return t?s.toLowerCase():s};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.readInt8=function readInt8(e,t){return e[t]<<24>>24};t.readUint16=function readUint16(e,t){return e[t]<<8|e[t+1]};t.readUint32=function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var a=r(2);class MissingDataException extends a.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`);this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class XRefEntryException extends a.BaseException{}t.XRefEntryException=XRefEntryException;class XRefParseException extends a.BaseException{}t.XRefParseException=XRefParseException;const i=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"]},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFDocument=t.Page=void 0;var a=r(2),i=r(10),n=r(5),s=r(8),o=r(12),c=r(25),l=r(22),h=r(11),u=r(26),d=r(28);const f=[0,0,612,792];function isAnnotationRenderable(e,t){return"display"===t&&e.viewable||"print"===t&&e.printable}class Page{constructor({pdfManager:e,xref:t,pageIndex:r,pageDict:a,ref:i,globalIdFactory:n,fontCache:s,builtInCMapCache:o,globalImageCache:c}){this.pdfManager=e;this.pageIndex=r;this.pageDict=a;this.xref=t;this.ref=i;this.fontCache=s;this.builtInCMapCache=o;this.globalImageCache=c;this.evaluatorOptions=e.evaluatorOptions;this.resourcesPromise=null;const l={obj:0};this._localIdFactory=class extends n{static createObjId(){return`p${r}_${++l.obj}`}}}_getInheritableProperty(e,t=!1){const r=(0,s.getInheritableProperty)({dict:this.pageDict,key:e,getArray:t,stopWhenFound:!1});return Array.isArray(r)?1!==r.length&&(0,n.isDict)(r[0])?n.Dict.merge({xref:this.xref,dictArray:r}):r[0]:r}get content(){return this.pageDict.get("Contents")}get resources(){return(0,a.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,a.warn)(`Empty /${e} entry.`)}return null}get mediaBox(){return(0,a.shadow)(this,"mediaBox",this._getBoundingBox("MediaBox")||f)}get cropBox(){return(0,a.shadow)(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");(!(0,a.isNum)(e)||e<=0)&&(e=1);return(0,a.shadow)(this,"userUnit",e)}get view(){const{cropBox:e,mediaBox:t}=this;let r;if(e===t||(0,a.isArrayEqual)(e,t))r=t;else{const i=a.Util.intersect(e,t);i&&i[2]-i[0]!=0&&i[3]-i[1]!=0?r=i:(0,a.warn)("Empty /CropBox and /MediaBox intersection.")}return(0,a.shadow)(this,"view",r||t)}get rotate(){let e=this._getInheritableProperty("Rotate")||0;e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360);return(0,a.shadow)(this,"rotate",e)}getContentStream(){const e=this.content;let t;if(Array.isArray(e)){const r=this.xref,a=[];for(const t of e)a.push(r.fetchIfRef(t));t=new o.StreamsSequenceStream(a)}else t=(0,n.isStream)(e)?e:new o.NullStream;return t}save(e,t,r){const i=new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions});return this._parsedAnnotations.then((function(e){const n=[];for(const s of e)isAnnotationRenderable(s,"print")&&n.push(s.save(i,t,r).catch((function(e){(0,a.warn)(`save - ignoring annotation data during "${t.name}" task: "${e}".`);return null})));return Promise.all(n)}))}loadResources(e){this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources"));return this.resourcesPromise.then(()=>new i.ObjectLoader(this.resources,e,this.xref).load())}getOperatorList({handler:e,sink:t,task:r,intent:i,renderInteractiveForms:n,annotationStorage:s}){const o=this.pdfManager.ensure(this,"getContentStream"),c=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),l=new d.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}),h=Promise.all([o,c]).then(([a])=>{const n=new u.OperatorList(i,t);e.send("StartRenderPage",{transparency:l.hasBlendModes(this.resources),pageIndex:this.pageIndex,intent:i});return l.getOperatorList({stream:a,task:r,resources:this.resources,operatorList:n}).then((function(){return n}))});return Promise.all([h,this._parsedAnnotations]).then((function([e,t]){if(0===t.length){e.flush(!0);return{length:e.totalLength}}const o=[];for(const e of t)isAnnotationRenderable(e,i)&&o.push(e.getOperatorList(l,r,n,s).catch((function(e){(0,a.warn)(`getOperatorList - ignoring annotation data during "${r.name}" task: "${e}".`);return null})));return Promise.all(o).then((function(t){e.addOp(a.OPS.beginAnnotations,[]);for(const r of t)e.addOpList(r);e.addOp(a.OPS.endAnnotations,[]);e.flush(!0);return{length:e.totalLength}}))}))}extractTextContent({handler:e,task:t,normalizeWhitespace:r,sink:a,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._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}).getTextContent({stream:n,task:t,resources:this.resources,normalizeWhitespace:r,combineTextItems:i,sink:a}))}getAnnotationsData(e){return this._parsedAnnotations.then((function(t){const r=[];for(let a=0,i=t.length;a{const e=[];for(const t of this.annotations)e.push(c.AnnotationFactory.create(this.xref,t,this.pdfManager,this._localIdFactory).catch((function(e){(0,a.warn)(`_parsedAnnotations: "${e}".`);return null})));return Promise.all(e).then((function(e){return e.filter(e=>!!e)}))});return(0,a.shadow)(this,"_parsedAnnotations",e)}}t.Page=Page;const g=new Uint8Array([37,80,68,70,45]),m=new Uint8Array([115,116,97,114,116,120,114,101,102]),p=new Uint8Array([101,110,100,111,98,106]),b=/^[1-9]\.[0-9]$/;function find(e,t,r=1024,a=!1){const i=t.length,n=e.peekBytes(r),s=n.length-i;if(s<=0)return!1;if(a){const r=i-1;let a=n.length-1;for(;a>=r;){let s=0;for(;s=i){e.pos+=a-r;return!0}a--}}else{let r=0;for(;r<=s;){let a=0;for(;a=i){e.pos+=r;return!0}r++}}return!1}t.PDFDocument=class PDFDocument{constructor(e,t){let r;if((0,n.isStream)(t))r=t;else{if(!(0,a.isArrayBuffer)(t))throw new Error("PDFDocument: Unknown argument type");r=new o.Stream(t)}if(r.length<=0)throw new a.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=e;this.stream=r;this.xref=new i.XRef(r,e);this._pagePromises=[];this._version=null;const s={font:0};this._globalIdFactory=class{static getDocId(){return"g_"+e.docId}static createFontId(){return"f"+ ++s.font}static createObjId(){(0,a.unreachable)("Abstract method `createObjId` called.")}}}parse(e){this.xref.parse(e);this.catalog=new i.Catalog(this.pdfManager,this.xref);this.catalog.version&&(this._version=this.catalog.version)}get linearization(){let e=null;try{e=h.Linearization.create(this.stream)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)(e)}return(0,a.shadow)(this,"linearization",e)}get startXRef(){const e=this.stream;let t=0;if(this.linearization){e.reset();find(e,p)&&(t=e.pos+6-e.start)}else{const r=1024,a=m.length;let i=!1,n=e.end;for(;!i&&n>0;){n-=r-a;n<0&&(n=0);e.pos=n;i=find(e,m,r,!0)}if(i){e.skip(9);let r;do{r=e.getByte()}while((0,s.isWhiteSpace)(r));let a="";for(;r>=32&&r<=57;){a+=String.fromCharCode(r);r=e.getByte()}t=parseInt(a,10);isNaN(t)&&(t=0)}}return(0,a.shadow)(this,"startXRef",t)}checkHeader(){const e=this.stream;e.reset();if(!find(e,g))return;e.moveStart();let t,r="";for(;(t=e.getByte())>32&&!(r.length>=12);)r+=String.fromCharCode(t);this._version||(this._version=r.substring(5))}parseStartXRef(){this.xref.setStartXRef(this.startXRef)}get numPages(){const e=this.linearization,t=e?e.numPages:this.catalog.numPages;return(0,a.shadow)(this,"numPages",t)}_hasOnlyDocumentSignatures(e,t=0){return e.every(e=>{if((e=this.xref.fetchIfRef(e)).has("Kids")){if(++t>10){(0,a.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");return!1}return this._hasOnlyDocumentSignatures(e.get("Kids"),t)}const r=(0,n.isName)(e.get("FT"),"Sig"),i=e.get("Rect"),s=Array.isArray(i)&&i.every(e=>0===e);return r&&s})}get formInfo(){const e={hasAcroForm:!1,hasXfa:!1},t=this.catalog.acroForm;if(!t)return(0,a.shadow)(this,"formInfo",e);try{const r=t.get("XFA"),a=Array.isArray(r)&&r.length>0||(0,n.isStream)(r)&&!r.isEmpty;e.hasXfa=a;const i=t.get("Fields"),s=Array.isArray(i)&&i.length>0,o=!!(1&t.get("SigFlags"))&&this._hasOnlyDocumentSignatures(i);e.hasAcroForm=s&&!o}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch form information.")}return(0,a.shadow)(this,"formInfo",e)}get documentInfo(){const e={Title:a.isString,Author:a.isString,Subject:a.isString,Keywords:a.isString,Creator:a.isString,Producer:a.isString,CreationDate:a.isString,ModDate:a.isString,Trapped:n.isName};let t=this._version;if("string"!=typeof t||!b.test(t)){(0,a.warn)("Invalid PDF header version number: "+t);t=null}const r={PDFFormatVersion:t,IsLinearized:!!this.linearization,IsAcroFormPresent:this.formInfo.hasAcroForm,IsXFAPresent:this.formInfo.hasXfa,IsCollectionPresent:!!this.catalog.collection};let i;try{i=this.xref.trailer.get("Info")}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.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)?r[t]="string"!=typeof s?s:(0,a.stringToPDFString)(s):(0,a.info)(`Bad value in document info for "${t}".`);else if("string"==typeof t){let e;if((0,a.isString)(s))e=(0,a.stringToPDFString)(s);else{if(!((0,n.isName)(s)||(0,a.isNum)(s)||(0,a.isBool)(s))){(0,a.info)(`Unsupported value in document info for (custom) "${t}".`);continue}e=s}r.Custom||(r.Custom=Object.create(null));r.Custom[t]=e}}return(0,a.shadow)(this,"documentInfo",r)}get fingerprint(){let e;const t=this.xref.trailer.get("ID");e=Array.isArray(t)&&t[0]&&(0,a.isString)(t[0])&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==t[0]?(0,a.stringToBytes)(t[0]):(0,l.calculateMD5)(this.stream.getByteRange(0,1024),0,1024);const r=[];for(let t=0,a=e.length;t{if((0,n.isDict)(e,"Page")||(0,n.isDict)(e)&&!e.has("Type")&&e.has("Contents")){i&&!t.pageKidsCountCache.has(i)&&t.pageKidsCountCache.put(i,1);return[e,i]}throw new a.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.")}).catch(r=>{(0,a.info)(r);return t.getPageDict(e)})}getPage(e){if(void 0!==this._pagePromises[e])return this._pagePromises[e];const{catalog:t,linearization:r}=this,a=r&&r.pageFirst===e?this._getLinearizationPage(e):t.getPageDict(e);return this._pagePromises[e]=a.then(([r,a])=>new Page({pdfManager:this.pdfManager,xref:this.xref,pageIndex:e,pageDict:r,ref:a,globalIdFactory:this._globalIdFactory,fontCache:t.fontCache,builtInCMapCache:t.builtInCMapCache,globalImageCache:t.globalImageCache}))}checkFirstPage(){return this.getPage(0).catch(async e=>{if(e instanceof s.XRefEntryException){this._pagePromises.length=0;await this.cleanup();throw new s.XRefParseException}})}fontFallback(e,t){return this.catalog.fontFallback(e,t)}async cleanup(e=!1){return this.catalog?this.catalog.cleanup(e):(0,n.clearPrimitiveCaches)()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FileSpec=t.XRef=t.ObjectLoader=t.Catalog=void 0;var a=r(2),i=r(5),n=r(11),s=r(8),o=r(22),c=r(23),l=r(24);function fetchDestination(e){return(0,i.isDict)(e)?e.get("D"):e}class Catalog{constructor(e,t){this.pdfManager=e;this.xref=t;this._catDict=t.getCatalogObj();if(!(0,i.isDict)(this._catDict))throw new a.FormatError("Catalog object is not a dictionary.");this.fontCache=new i.RefSetCache;this.builtInCMapCache=new Map;this.globalImageCache=new l.GlobalImageCache;this.pageKidsCountCache=new i.RefSetCache}get version(){const e=this._catDict.get("Version");return(0,i.isName)(e)?(0,a.shadow)(this,"version",e.name):(0,a.shadow)(this,"version",null)}get collection(){let e=null;try{const t=this._catDict.get("Collection");(0,i.isDict)(t)&&t.size>0&&(e=t)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch Collection entry; assuming no collection is present.")}return(0,a.shadow)(this,"collection",e)}get acroForm(){let e=null;try{const t=this._catDict.get("AcroForm");(0,i.isDict)(t)&&t.size>0&&(e=t)}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Cannot fetch AcroForm entry; assuming no forms are present.")}return(0,a.shadow)(this,"acroForm",e)}get metadata(){const e=this._catDict.getRaw("Metadata");if(!(0,i.isRef)(e))return(0,a.shadow)(this,"metadata",null);const t=!(this.xref.encrypt&&this.xref.encrypt.encryptMetadata),r=this.xref.fetch(e,t);let n;if(r&&(0,i.isDict)(r.dict)){const e=r.dict.get("Type"),t=r.dict.get("Subtype");if((0,i.isName)(e,"Metadata")&&(0,i.isName)(t,"XML"))try{n=(0,a.stringToUTF8String)((0,a.bytesToString)(r.getBytes()))}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.info)("Skipping invalid metadata.")}}return(0,a.shadow)(this,"metadata",n)}get toplevelPagesDict(){const e=this._catDict.get("Pages");if(!(0,i.isDict)(e))throw new a.FormatError("Invalid top-level pages dictionary.");return(0,a.shadow)(this,"toplevelPagesDict",e)}get documentOutline(){let e=null;try{e=this._readDocumentOutline()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read document outline.")}return(0,a.shadow)(this,"documentOutline",e)}_readDocumentOutline(){let e=this._catDict.get("Outlines");if(!(0,i.isDict)(e))return null;e=e.getRaw("First");if(!(0,i.isRef)(e))return null;const t={items:[]},r=[{obj:e,parent:t}],n=new i.RefSet;n.put(e);const s=this.xref,o=new Uint8ClampedArray(3);for(;r.length>0;){const t=r.shift(),l=s.fetchIfRef(t.obj);if(null===l)continue;if(!l.has("Title"))throw new a.FormatError("Invalid outline item encountered.");const h={url:null,dest:null};Catalog.parseDestDictionary({destDict:l,resultObj:h,docBaseUrl:this.pdfManager.docBaseUrl});const u=l.get("Title"),d=l.get("F")||0,f=l.getArray("C"),g=l.get("Count");let m=o;!Array.isArray(f)||3!==f.length||0===f[0]&&0===f[1]&&0===f[2]||(m=c.ColorSpace.singletons.rgb.getRgb(f,0));const p={dest:h.dest,url:h.url,unsafeUrl:h.unsafeUrl,newWindow:h.newWindow,title:(0,a.stringToPDFString)(u),color:m,count:Number.isInteger(g)?g:void 0,bold:!!(2&d),italic:!!(1&d),items:[]};t.parent.items.push(p);e=l.getRaw("First");if((0,i.isRef)(e)&&!n.has(e)){r.push({obj:e,parent:p});n.put(e)}e=l.getRaw("Next");if((0,i.isRef)(e)&&!n.has(e)){r.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,a.warn)("Unable to read permissions.")}return(0,a.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,a.isNum)(t))return null;t+=2**32;const r=[];for(const e in a.PermissionFlag){const i=a.PermissionFlag[e];t&i&&r.push(i)}return r}get optionalContentConfig(){let e=null;try{const t=this._catDict.get("OCProperties");if(!t)return(0,a.shadow)(this,"optionalContentConfig",null);const r=t.get("D");if(!r)return(0,a.shadow)(this,"optionalContentConfig",null);const n=t.get("OCGs");if(!Array.isArray(n))return(0,a.shadow)(this,"optionalContentConfig",null);const s=[],o=[];for(const e of n){if(!(0,i.isRef)(e))continue;o.push(e);const t=this.xref.fetchIfRef(e);s.push({id:e.toString(),name:(0,a.isString)(t.get("Name"))?(0,a.stringToPDFString)(t.get("Name")):null,intent:(0,a.isString)(t.get("Intent"))?(0,a.stringToPDFString)(t.get("Intent")):null})}e=this._readOptionalContentConfig(r,o);e.groups=s}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Unable to read optional content config: "+e)}return(0,a.shadow)(this,"optionalContentConfig",e)}_readOptionalContentConfig(e,t){function parseOnOff(e){const r=[];if(Array.isArray(e))for(const a of e)(0,i.isRef)(a)&&t.includes(a)&&r.push(a.toString());return r}function parseOrder(e,r=0){if(!Array.isArray(e))return null;const a=[];for(const s of e){if((0,i.isRef)(s)&&t.includes(s)){n.put(s);a.push(s.toString());continue}const e=parseNestedOrder(s,r);e&&a.push(e)}if(r>0)return a;const s=[];for(const e of t)n.has(e)||s.push(e.toString());s.length&&a.push({name:null,order:s});return a}function parseNestedOrder(e,t){if(++t>s){(0,a.warn)("parseNestedOrder - reached MAX_NESTED_LEVELS.");return null}const i=r.fetchIfRef(e);if(!Array.isArray(i))return null;const n=r.fetchIfRef(i[0]);if("string"!=typeof n)return null;const o=parseOrder(i.slice(1),t);return o&&o.length?{name:(0,a.stringToPDFString)(n),order:o}:null}const r=this.xref,n=new i.RefSet,s=10;return{name:(0,a.isString)(e.get("Name"))?(0,a.stringToPDFString)(e.get("Name")):null,creator:(0,a.isString)(e.get("Creator"))?(0,a.stringToPDFString)(e.get("Creator")):null,baseState:(0,i.isName)(e.get("BaseState"))?e.get("BaseState").name:null,on:parseOnOff(e.get("ON")),off:parseOnOff(e.get("OFF")),order:parseOrder(e.get("Order")),groups:null}}get numPages(){const e=this.toplevelPagesDict.get("Count");if(!Number.isInteger(e))throw new a.FormatError("Page count in top-level pages dictionary is not an integer.");return(0,a.shadow)(this,"numPages",e)}get destinations(){const e=this._readDests(),t=Object.create(null);if(e instanceof NameTree){const r=e.getAll();for(const e in r)t[e]=fetchDestination(r[e])}else e instanceof i.Dict&&e.forEach((function(e,r){r&&(t[e]=fetchDestination(r))}));return(0,a.shadow)(this,"destinations",t)}getDestination(e){const t=this._readDests();return t instanceof NameTree||t instanceof i.Dict?fetchDestination(t.get(e)||null):null}_readDests(){const e=this._catDict.get("Names");return e&&e.has("Dests")?new NameTree(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,a.warn)("Unable to read page labels.")}return(0,a.shadow)(this,"pageLabels",e)}_readPageLabels(){const e=this._catDict.getRaw("PageLabels");if(!e)return null;const t=new Array(this.numPages);let r=null,n="";const o=new NumberTree(e,this.xref).getAll();let c="",l=1;for(let e=0,h=this.numPages;e=1))throw new a.FormatError("Invalid start in PageLabel dictionary.");l=e}else l=1}switch(r){case"D":c=l;break;case"R":case"r":c=(0,s.toRomanNumerals)(l,"r"===r);break;case"A":case"a":const e=26,t=65,i=97,n="a"===r?i:t,o=l-1,h=String.fromCharCode(n+o%e),u=[];for(let t=0,r=o/e|0;t<=r;t++)u.push(h);c=u.join("");break;default:if(r)throw new a.FormatError(`Invalid style "${r}" 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,a.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,a.shadow)(this,"pageMode",t)}get viewerPreferences(){const e={HideToolbar:a.isBool,HideMenubar:a.isBool,HideWindowUI:a.isBool,FitWindow:a.isBool,CenterWindow:a.isBool,DisplayDocTitle:a.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:a.isBool,PrintPageRange:Array.isArray,NumCopies:Number.isInteger},t=this._catDict.get("ViewerPreferences");let r=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,a.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,r)=>Number.isInteger(e)&&e>0&&(0===t||e>=r[t-1])&&e<=this.numPages)&&(s=n);break;case"NumCopies":n>0&&(s=n);break;default:if("boolean"!=typeof n)throw new a.FormatError("viewerPreferences - expected a boolean value for: "+i);s=n}if(void 0!==s){r||(r=Object.create(null));r[i]=s}else(0,a.info)(`Bad value in ViewerPreferences for "${i}".`)}return(0,a.shadow)(this,"viewerPreferences",r)}get openAction(){const e=this._catDict.get("OpenAction");let t=null;if((0,i.isDict)(e)){const r=new i.Dict(this.xref);r.set("A",e);const a={url:null,dest:null,action:null};Catalog.parseDestDictionary({destDict:r,resultObj:a});if(Array.isArray(a.dest)){t||(t=Object.create(null));t.dest=a.dest}else if(a.action){t||(t=Object.create(null));t.action=a.action}}else if(Array.isArray(e)){t||(t=Object.create(null));t.dest=e}return(0,a.shadow)(this,"openAction",t)}get attachments(){const e=this._catDict.get("Names");let t=null;if(e&&e.has("EmbeddedFiles")){const r=new NameTree(e.getRaw("EmbeddedFiles"),this.xref).getAll();for(const e in r){const i=new u(r[e],this.xref);t||(t=Object.create(null));t[(0,a.stringToPDFString)(e)]=i.serializable}}return(0,a.shadow)(this,"attachments",t)}get javaScript(){const e=this._catDict.get("Names");let t=null;function appendIfJavaScriptDict(e){const r=e.get("S");if(!(0,i.isName)(r,"JavaScript"))return;let n=e.get("JS");if((0,i.isStream)(n))n=(0,a.bytesToString)(n.getBytes());else if(!(0,a.isString)(n))return;t||(t=[]);t.push((0,a.stringToPDFString)(n))}if(e&&e.has("JavaScript")){const t=new NameTree(e.getRaw("JavaScript"),this.xref).getAll();for(const e in t){const r=t[e];(0,i.isDict)(r)&&appendIfJavaScriptDict(r)}}const r=this._catDict.get("OpenAction");(0,i.isDict)(r)&&(0,i.isName)(r.get("S"),"JavaScript")&&appendIfJavaScriptDict(r);return(0,a.shadow)(this,"javaScript",t)}fontFallback(e,t){const r=[];this.fontCache.forEach((function(e){r.push(e)}));return Promise.all(r).then(r=>{for(const a of r)if(a.loadedName===e){a.fallback(t);return}})}cleanup(e=!1){(0,i.clearPrimitiveCaches)();this.globalImageCache.clear(e);this.pageKidsCountCache.clear();const t=[];this.fontCache.forEach((function(e){t.push(e)}));return Promise.all(t).then(e=>{for(const{dict:t}of e)delete t.translated;this.fontCache.clear();this.builtInCMapCache.clear()})}getPageDict(e){const t=(0,a.createPromiseCapability)(),r=[this._catDict.getRaw("Pages")],n=new i.RefSet,s=this.xref,o=this.pageKidsCountCache;let c,l=0;!function next(){for(;r.length;){const h=r.pop();if((0,i.isRef)(h)){c=o.get(h);if(c>0&&l+c=0){const t=h.objId;t&&!o.has(t)&&o.put(t,c);if(l+c<=e){l+=c;continue}}const u=h.get("Kids");if(!Array.isArray(u)){if((0,i.isName)(h.get("Type"),"Page")||!h.has("Type")&&h.has("Contents")){if(l===e){t.resolve([h,null]);return}l++;continue}t.reject(new a.FormatError("Page dictionary kids object is not an array."));return}for(let e=u.length-1;e>=0;e--)r.push(u[e])}t.reject(new Error(`Page index ${e} not found.`))}();return t.promise}getPageIndex(e){const t=this.xref;let r=0;return function next(n){return function pagesBeforeRef(r){let n,s=0;return t.fetchAsync(r).then((function(t){if((0,i.isRefsEqual)(r,e)&&!(0,i.isDict)(t,"Page")&&(!(0,i.isDict)(t)||t.has("Type")||!t.has("Contents")))throw new a.FormatError("The reference does not point to a /Page dictionary.");if(!t)return null;if(!(0,i.isDict)(t))throw new a.FormatError("Node must be a dictionary.");n=t.getRaw("Parent");return t.getAsync("Parent")})).then((function(e){if(!e)return null;if(!(0,i.isDict)(e))throw new a.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 a.FormatError(`Invalid XRef range fields: ${h}, ${u}`);if(!Number.isInteger(s)||!Number.isInteger(o)||!Number.isInteger(c))throw new a.FormatError(`Invalid XRef entry fields length: ${h}, ${u}`);for(t=i.entryNum;t=e.length);){r+=String.fromCharCode(a);a=e[t]}return r}function skipUntil(e,t,r){for(var a=r.length,i=e.length,n=0;t=a)break;t++;n++}return n}var e=/^(\d+)\s+(\d+)\s+obj\b/;const t=/\bendobj[\b\s]$/,r=/\s+(\d+\s+\d+\s+obj[\b\s<])$/;var o=new Uint8Array([116,114,97,105,108,101,114]),c=new Uint8Array([115,116,97,114,116,120,114,101,102]);const l=new Uint8Array([111,98,106]);var h=new Uint8Array([47,88,82,101,102]);this.entries.length=0;var u=this.stream;u.pos=0;for(var d,f,g=u.getBytes(),m=u.start,p=g.length,b=[],y=[];m=p)break;v=g[m]}while(10!==v&&13!==v);else++m}for(d=0,f=y.length;d0;){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){(0,a.warn)(`Search depth limit reached for "${this._type}" tree.`);return null}const n=r.get("Kids");if(!Array.isArray(n))return null;let s=0,o=n.length-1;for(;s<=o;){const a=s+o>>1,i=t.fetchIfRef(n[a]).get("Limits");if(et.fetchIfRef(i[1]))){r=t.fetchIfRef(n[a]);break}s=a+1}}if(s>o)return null}const n=r.get(this._type);if(Array.isArray(n)){let r=0,i=n.length-2;for(;r<=i;){const a=r+i>>1,s=a+(1&a),o=t.fetchIfRef(n[s]);if(eo))return t.fetchIfRef(n[s+1]);r=s+2}}(0,a.info)(`Falling back to an exhaustive search, for key "${e}", in "${this._type}" tree.`);for(let r=0,i=n.length;r>")&&!(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;this.shift();if((0,n.isEOF)(this.buf1))break;a.set(t,this.getObj(e))}if((0,n.isEOF)(this.buf1)){if(!this.recoveryMode)throw new i.FormatError("End of file inside dictionary");return a}if((0,n.isCmd)(this.buf2,"stream"))return this.allowStreams?this.makeStream(a,e):a;this.shift();return a;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);this.shift();this.shift();return e}return t}return"string"==typeof t&&e?e.decryptString(t):t}findDefaultInlineStreamEnd(e){const t=this.lexer,r=e.pos;let a,o,c=0;for(;-1!==(a=e.getByte());)if(0===c)c=69===a?1:0;else if(1===c)c=73===a?2:0;else{(0,i.assert)(2===c,"findDefaultInlineStreamEnd - invalid state.");if(32===a||10===a||13===a){o=e.pos;const r=e.peekBytes(10);for(let e=0,t=r.length;e127))){c=0;break}}if(2!==c)continue;if(t.knownCommands){const e=t.peekObj();e instanceof n.Cmd&&!t.knownCommands[e.cmd]&&(c=0)}else(0,i.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");if(2===c)break}else c=0}if(-1===a){(0,i.warn)("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker");if(o){(0,i.warn)('... trying to recover by using the last "EI" occurrence.');e.skip(-(e.pos-o))}}let l=4;e.skip(-l);a=e.peekByte();e.skip(l);(0,s.isWhiteSpace)(a)||l--;return e.pos-l-r}findDCTDecodeInlineStreamEnd(e){const t=e.pos;let r,a,n=!1;for(;-1!==(r=e.getByte());)if(255===r){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:a=e.getUint16();a>2?e.skip(a-2):e.skip(-2)}if(n)break}const s=e.pos-t;if(-1===r){(0,i.warn)("Inline DCTDecode image stream: EOI marker not found, searching for /EI/ instead.");e.skip(-s);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return s}findASCII85DecodeInlineStreamEnd(e){const t=e.pos;let r;for(;-1!==(r=e.getByte());)if(126===r){const t=e.pos;r=e.peekByte();for(;(0,s.isWhiteSpace)(r);){e.skip();r=e.peekByte()}if(62===r){e.skip();break}if(e.pos>t){const t=e.peekBytes(2);if(69===t[0]&&73===t[1])break}}const a=e.pos-t;if(-1===r){(0,i.warn)("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a}findASCIIHexDecodeInlineStreamEnd(e){const t=e.pos;let r;for(;-1!==(r=e.getByte())&&62!==r;);const a=e.pos-t;if(-1===r){(0,i.warn)("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-a);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return a}inlineStreamSkipEI(e){let t,r=0;for(;-1!==(t=e.getByte());)if(0===r)r=69===t?1:0;else if(1===r)r=73===t?2:0;else if(2===r)break}makeInlineImage(e){const t=this.lexer,r=t.stream,a=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;this.shift();if((0,n.isEOF)(this.buf1))break;a.set(t,this.getObj(e))}-1!==t.beginInlineImagePos&&(s=r.pos-t.beginInlineImagePos);const o=a.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=r.pos;let h;h="DCTDecode"===c||"DCT"===c?this.findDCTDecodeInlineStreamEnd(r):"ASCII85Decode"===c||"A85"===c?this.findASCII85DecodeInlineStreamEnd(r):"ASCIIHexDecode"===c||"AHx"===c?this.findASCIIHexDecodeInlineStreamEnd(r):this.findDefaultInlineStreamEnd(r);let u,d=r.makeSubStream(l,h,a);if(h<1e3&&s<5552){const e=d.getBytes();d.reset();const a=r.pos;r.pos=t.beginInlineImagePos;const i=r.getBytes(s);r.pos=a;u=computeAdler32(e)+"_"+computeAdler32(i);const o=this.imageCache[u];if(void 0!==o){this.buf2=n.Cmd.get("EI");this.shift();o.reset();return o}}e&&(d=e.createStream(d,h));d=this.filter(d,a,h);d.dict=a;if(void 0!==u){d.cacheKey=`inline_${h}_${u}`;this.imageCache[u]=d}this.buf2=n.Cmd.get("EI");this.shift();return d}_findStreamLength(e,t){const{stream:r}=this.lexer;r.pos=e;const a=t.length;for(;r.pos=a){r.pos+=s;return r.pos-e}s++}r.pos+=n}return-1}makeStream(e,t){const r=this.lexer;let a=r.stream;r.skipToNextLine();const o=a.pos-1;let c=e.get("Length");if(!Number.isInteger(c)){(0,i.info)(`Bad length "${c}" in stream`);c=0}a.pos=o+c;r.nextChar();if(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 r=1;for(let n=1;n<=r;n++){const r=e.length-n,c=e.slice(0,r),l=this._findStreamLength(o,c);if(l>=0){const e=a.peekBytes(r+1)[r];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;r.nextChar();this.shift();this.shift()}this.shift();a=a.makeSubStream(o,c,e);t&&(a=t.createStream(a,c));a=this.filter(a,e,c);a.dict=e;return a}filter(e,t,r){let a=t.get("Filter","F"),s=t.get("DecodeParms","DP");if((0,n.isName)(a)){Array.isArray(s)&&(0,i.warn)("/DecodeParms should not contain an Array, when /Filter contains a Name.");return this.makeFilter(e,a.name,r,s)}let o=r;if(Array.isArray(a)){const t=a,r=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 Lexer{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,r=0,a=0;if(45===e){a=-1;e=this.nextChar();45===e&&(e=this.nextChar())}else if(43===e){a=1;e=this.nextChar()}if(10===e||13===e)do{e=this.nextChar()}while(10===e||13===e);if(46===e){r=10;e=this.nextChar()}if(e<48||e>57){if(10===r&&0===a&&((0,s.isWhiteSpace)(e)||-1===e)){(0,i.warn)("Lexer.getNumber - treating a single decimal point as zero.");return 0}throw new i.FormatError(`Invalid number: ${String.fromCharCode(e)} (charCode ${e})`)}a=a||1;let n=e-48,o=0,c=1;for(;(e=this.nextChar())>=0;)if(e>=48&&e<=57){const a=e-48;if(t)o=10*o+a;else{0!==r&&(r*=10);n=10*n+a}}else if(46===e){if(0!==r)break;r=1}else if(45===e)(0,i.warn)("Badly formatted number: minus sign in the middle");else{if(69!==e&&101!==e)break;e=this.peekChar();if(43===e||45===e){c=45===e?-1:1;this.nextChar()}else if(e<48||e>57)break;t=!0}0!==r&&(n/=r);t&&(n*=10**(c*o));return a*n}getString(){let e=1,t=!1;const r=this.strBuf;r.length=0;let a=this.nextChar();for(;;){let n=!1;switch(0|a){case-1:(0,i.warn)("Unterminated string");t=!0;break;case 40:++e;r.push("(");break;case 41:if(0==--e){this.nextChar();t=!0}else r.push(")");break;case 92:a=this.nextChar();switch(a){case-1:(0,i.warn)("Unterminated string");t=!0;break;case 110:r.push("\n");break;case 114:r.push("\r");break;case 116:r.push("\t");break;case 98:r.push("\b");break;case 102:r.push("\f");break;case 92:case 40:case 41:r.push(String.fromCharCode(a));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:let e=15&a;a=this.nextChar();n=!0;if(a>=48&&a<=55){e=(e<<3)+(15&a);a=this.nextChar();if(a>=48&&a<=55){n=!1;e=(e<<3)+(15&a)}}r.push(String.fromCharCode(e));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:r.push(String.fromCharCode(a))}break;default:r.push(String.fromCharCode(a))}if(t)break;n||(a=this.nextChar())}return r.join("")}getName(){let e,t;const r=this.strBuf;r.length=0;for(;(e=this.nextChar())>=0&&!u[e];)if(35===e){e=this.nextChar();if(u[e]){(0,i.warn)("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number.");r.push("#");break}const a=toHexDigit(e);if(-1!==a){t=e;e=this.nextChar();const n=toHexDigit(e);if(-1===n){(0,i.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(e)}) in hexadecimal number.`);r.push("#",String.fromCharCode(t));if(u[e])break;r.push(String.fromCharCode(e));continue}r.push(String.fromCharCode(a<<4|n))}else r.push("#",String.fromCharCode(e))}else r.push(String.fromCharCode(e));r.length>127&&(0,i.warn)("Name token is longer than allowed by the spec: "+r.length);return n.Name.get(r.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,r,a=this.currentChar,n=!0;this._hexStringNumWarn=0;for(;;){if(a<0){(0,i.warn)("Unterminated hex string");break}if(62===a){this.nextChar();break}if(1!==u[a]){if(n){t=toHexDigit(a);if(-1===t){this._hexStringWarn(a);a=this.nextChar();continue}}else{r=toHexDigit(a);if(-1===r){this._hexStringWarn(a);a=this.nextChar();continue}e.push(String.fromCharCode(t<<4|r))}n=!n;a=this.nextChar()}else a=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!==u[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:this.nextChar();return n.Cmd.get("[");case 93:this.nextChar();return n.Cmd.get("]");case 60:t=this.nextChar();if(60===t){this.nextChar();return n.Cmd.get("<<")}return this.getHexString();case 62:t=this.nextChar();if(62===t){this.nextChar();return n.Cmd.get(">>")}return n.Cmd.get(">");case 123:this.nextChar();return n.Cmd.get("{");case 125:this.nextChar();return n.Cmd.get("}");case 41:this.nextChar();throw new i.FormatError("Illegal character: "+t)}let r=String.fromCharCode(t);const a=this.knownCommands;let s=a&&void 0!==a[r];for(;(t=this.nextChar())>=0&&!u[t];){const e=r+String.fromCharCode(t);if(s&&void 0===a[e])break;if(128===r.length)throw new i.FormatError("Command token too long: "+r.length);r=e;s=a&&void 0!==a[r]}if("true"===r)return!0;if("false"===r)return!1;if("null"===r)return null;"BI"===r&&(this.beginInlineImagePos=this.stream.pos);return n.Cmd.get(r)}peekObj(){const e=this.stream.pos,t=this.currentChar,r=this.beginInlineImagePos;let a;try{a=this.getObj()}catch(e){if(e instanceof s.MissingDataException)throw e;(0,i.warn)("peekObj: "+e)}this.stream.pos=e;this.currentChar=t;this.beginInlineImagePos=r;return 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=Lexer;t.Linearization=class Linearization{static create(e){function getInt(e,t,r=!1){const a=e.get(t);if(Number.isInteger(a)&&(r?a>=0:a>0))return a;throw new Error(`The "${t}" parameter in the linearization dictionary is invalid.`)}const t=new Parser({lexer:new Lexer(e),xref:null}),r=t.getObj(),a=t.getObj(),s=t.getObj(),o=t.getObj();let c,l;if(!(Number.isInteger(r)&&Number.isInteger(a)&&(0,n.isCmd)(s,"obj")&&(0,n.isDict)(o)&&(0,i.isNum)(c=o.get("Linearized"))&&c>0))return null;if((l=getInt(o,"L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:l,hints:function getHints(e){const t=e.get("H");let r;if(Array.isArray(t)&&(2===(r=t.length)||4===r)){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.")}(o),objectNumberFirst:getInt(o,"O"),endFirst:getInt(o,"E"),numPages:getInt(o,"N"),mainXRefEntriesOffset:getInt(o,"T"),pageFirst:o.has("P")?getInt(o,"P",!0):0}}}},function(e,t,r){"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 a=r(2),i=r(5),n=r(8),s=function StreamClosure(){function Stream(e,t,r,a){this.bytes=e instanceof Uint8Array?e:new Uint8Array(e);this.start=t||0;this.pos=this.start;this.end=t+r||this.bytes.length;this.dict=a}Stream.prototype={get length(){return this.end-this.start},get isEmpty(){return 0===this.length},getByte:function Stream_getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]},getUint16:function Stream_getUint16(){var e=this.getByte(),t=this.getByte();return-1===e||-1===t?-1:(e<<8)+t},getInt32:function Stream_getInt32(){return(this.getByte()<<24)+(this.getByte()<<16)+(this.getByte()<<8)+this.getByte()},getBytes(e,t=!1){var r=this.bytes,a=this.pos,i=this.end;if(!e){const e=r.subarray(a,i);return t?new Uint8ClampedArray(e):e}var n=a+e;n>i&&(n=i);this.pos=n;const s=r.subarray(a,n);return t?new Uint8ClampedArray(s):s},peekByte:function Stream_peekByte(){var e=this.getByte();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var r=this.getBytes(e,t);this.pos-=r.length;return r},getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return this.bytes.subarray(e,t)},skip:function Stream_skip(e){e||(e=1);this.pos+=e},reset:function Stream_reset(){this.pos=this.start},moveStart:function Stream_moveStart(){this.start=this.pos},makeSubStream:function Stream_makeSubStream(e,t,r){return new Stream(this.bytes.buffer,e,t,r)}};return Stream}();t.Stream=s;var o=function StringStreamClosure(){function StringStream(e){const t=(0,a.stringToBytes)(e);s.call(this,t)}StringStream.prototype=s.prototype;return StringStream}();t.StringStream=o;var c=function DecodeStreamClosure(){var e=new Uint8Array(0);function DecodeStream(t){this._rawMinBufferLength=t||0;this.pos=0;this.bufferLength=0;this.eof=!1;this.buffer=e;this.minBufferLength=512;if(t)for(;this.minBufferLengthi&&(r=i)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}this.pos=r;const n=this.buffer.subarray(a,r);return!t||n instanceof Uint8ClampedArray?n:new Uint8ClampedArray(n)},peekByte:function DecodeStream_peekByte(){var e=this.getByte();-1!==e&&this.pos--;return e},peekBytes(e,t=!1){var r=this.getBytes(e,t);this.pos-=r.length;return r},makeSubStream:function DecodeStream_makeSubStream(e,t,r){for(var a=e+t;this.bufferLength<=a&&!this.eof;)this.readBlock();return new s(this.buffer,e,t,r)},getByteRange(e,t){(0,a.unreachable)("Should not call DecodeStream.getByteRange")},skip:function DecodeStream_skip(e){e||(e=1);this.pos+=e},reset:function DecodeStream_reset(){this.pos=0},getBaseStreams:function DecodeStream_getBaseStreams(){return this.str&&this.str.getBaseStreams?this.str.getBaseStreams():[]}};return DecodeStream}();t.DecodeStream=c;var l=function StreamsSequenceStreamClosure(){function StreamsSequenceStream(e){this.streams=e;let t=0;for(let r=0,a=e.length;r>e;this.codeSize=i-=e;return t};FlateStream.prototype.getCode=function FlateStream_getCode(e){for(var t,r=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;return h};FlateStream.prototype.generateHuffmanTable=function flateStreamGenerateHuffmanTable(e){var t,r=e.length,a=0;for(t=0;ta&&(a=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 a.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,T=this.bufferLength;;){var I=this.getCode(h);if(I<256){T+1>=A&&(A=(s=this.ensureBuffer(T+1)).length);s[T++]=I}else{if(256===I){this.bufferLength=T;return}var F=(I=t[I-=257])>>16;F>0&&(F=this.getBits(F));o=(65535&I)+F;I=this.getCode(u);(F=(I=r[I])>>16)>0&&(F=this.getBits(F));var P=(65535&I)+F;T+o>=A&&(A=(s=this.ensureBuffer(T+o)).length);for(var E=0;E15))throw new a.FormatError("Unsupported predictor: "+n);this.readBlock=2===n?this.readBlockTiff:this.readBlockPng;this.str=e;this.dict=e.dict;var s=this.colors=r.get("Colors")||1,o=this.bits=r.get("BitsPerComponent")||8,l=this.columns=r.get("Columns")||1;this.pixBytes=s*o+7>>3;this.rowBytes=l*s*o+7>>3;c.call(this,t);return this}PredictorStream.prototype=Object.create(c.prototype);PredictorStream.prototype.readBlockTiff=function predictorStreamReadBlockTiff(){var e=this.rowBytes,t=this.bufferLength,r=this.ensureBuffer(t+e),a=this.bits,i=this.colors,n=this.str.getBytes(e);this.eof=!n.length;if(!this.eof){var s,o=0,c=0,l=0,h=0,u=t;if(1===a&&1===i)for(s=0;s>1;d^=d>>2;o=(1&(d^=d>>4))<<7;r[u++]=d}else if(8===a){for(s=0;s>8&255;r[u++]=255&g}}else{var m=new Uint8Array(i+1),p=(1<>l-a)&p;l-=a;c=c<=8){r[y++]=c>>h-8&255;h-=8}}h>0&&(r[y++]=(c<<8-h)+(o&(1<<8-h)-1))}this.bufferLength+=e}};PredictorStream.prototype.readBlockPng=function predictorStreamReadBlockPng(){var e=this.rowBytes,t=this.pixBytes,r=this.str.getByte(),i=this.str.getBytes(e);this.eof=!i.length;if(!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(r){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 r,a=this.bufferLength,i=e.length,n=this.ensureBuffer(a+i);for(r=0;r=0;--a){r[i+a]=255&o;o>>=8}}}else this.eof=!0};return Ascii85Stream}();t.Ascii85Stream=f;var g=function AsciiHexStreamClosure(){function AsciiHexStream(e,t){this.str=e;this.dict=e.dict;this.firstDigit=-1;t&&(t*=.5);c.call(this,t)}AsciiHexStream.prototype=Object.create(c.prototype);AsciiHexStream.prototype.readBlock=function AsciiHexStream_readBlock(){var e=this.str.getBytes(8e3);if(e.length){for(var t=e.length+1>>1,r=this.ensureBuffer(this.bufferLength+t),a=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)}if(i<0)i=o;else{r[a++]=i<<4|o;i=-1}}if(i>=0&&this.eof){r[a++]=i<<4;i=-1}this.firstDigit=i;this.bufferLength=a}else this.eof=!0};return AsciiHexStream}();t.AsciiHexStream=g;var m=function RunLengthStreamClosure(){function RunLengthStream(e,t){this.str=e;this.dict=e.dict;c.call(this,t)}RunLengthStream.prototype=Object.create(c.prototype);RunLengthStream.prototype.readBlock=function RunLengthStream_readBlock(){var e=this.str.getBytes(2);if(!e||e.length<2||128===e[0])this.eof=!0;else{var t,r=this.bufferLength,a=e[0];if(a<128){(t=this.ensureBuffer(r+a+1))[r++]=e[1];if(a>0){var i=this.str.getBytes(a);t.set(i,r);r+=a}}else{a=257-a;var n=e[1];t=this.ensureBuffer(r+a+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[r];r=l[r]}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;if(a<(g+=f)){do{a+=512}while(ae.getByte()};this.ccittFaxDecoder=new i.CCITTFaxDecoder(s,{K:r.get("K"),EndOfLine:r.get("EndOfLine"),EncodedByteAlign:r.get("EncodedByteAlign"),Columns:r.get("Columns"),Rows:r.get("Rows"),EndOfBlock:r.get("EndOfBlock"),BlackIs1:r.get("BlackIs1")});n.DecodeStream.call(this,t)}CCITTFaxStream.prototype=Object.create(n.DecodeStream.prototype);CCITTFaxStream.prototype.readBlock=function(){for(;!this.eof;){const e=this.ccittFaxDecoder.readNextChar();if(-1===e){this.eof=!0;return}this.ensureBuffer(this.bufferLength+1);this.buffer[this.bufferLength++]=e}};return CCITTFaxStream}();t.CCITTFaxStream=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var a=r(2);const i=function CCITTFaxDecoder(){const e=[[-1,-1],[-1,-1],[7,8],[7,7],[6,6],[6,6],[6,5],[6,5],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[4,0],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,1],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,4],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[3,3],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2],[1,2]],t=[[-1,-1],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[12,1984],[12,2048],[12,2112],[12,2176],[12,2240],[12,2304],[11,1856],[11,1856],[11,1920],[11,1920],[12,2368],[12,2432],[12,2496],[12,2560]],r=[[-1,-1],[-1,-1],[-1,-1],[-1,-1],[8,29],[8,29],[8,30],[8,30],[8,45],[8,45],[8,46],[8,46],[7,22],[7,22],[7,22],[7,22],[7,23],[7,23],[7,23],[7,23],[8,47],[8,47],[8,48],[8,48],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[6,13],[7,20],[7,20],[7,20],[7,20],[8,33],[8,33],[8,34],[8,34],[8,35],[8,35],[8,36],[8,36],[8,37],[8,37],[8,38],[8,38],[7,19],[7,19],[7,19],[7,19],[8,31],[8,31],[8,32],[8,32],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,1],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[6,12],[8,53],[8,53],[8,54],[8,54],[7,26],[7,26],[7,26],[7,26],[8,39],[8,39],[8,40],[8,40],[8,41],[8,41],[8,42],[8,42],[8,43],[8,43],[8,44],[8,44],[7,21],[7,21],[7,21],[7,21],[7,28],[7,28],[7,28],[7,28],[8,61],[8,61],[8,62],[8,62],[8,63],[8,63],[8,0],[8,0],[8,320],[8,320],[8,384],[8,384],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,10],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[5,11],[7,27],[7,27],[7,27],[7,27],[8,59],[8,59],[8,60],[8,60],[9,1472],[9,1536],[9,1600],[9,1728],[7,18],[7,18],[7,18],[7,18],[7,24],[7,24],[7,24],[7,24],[8,49],[8,49],[8,50],[8,50],[8,51],[8,51],[8,52],[8,52],[7,25],[7,25],[7,25],[7,25],[8,55],[8,55],[8,56],[8,56],[8,57],[8,57],[8,58],[8,58],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,192],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[6,1664],[8,448],[8,448],[8,512],[8,512],[9,704],[9,768],[8,640],[8,640],[8,576],[8,576],[9,832],[9,896],[9,960],[9,1024],[9,1088],[9,1152],[9,1216],[9,1280],[9,1344],[9,1408],[7,256],[7,256],[7,256],[7,256],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,2],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,128],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,8],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[5,9],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,16],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[6,17],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,4],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[4,5],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,14],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[6,15],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[5,64],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,6],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7],[4,7]],i=[[-1,-1],[-1,-1],[12,-2],[12,-2],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[-1,-1],[11,1792],[11,1792],[11,1792],[11,1792],[12,1984],[12,1984],[12,2048],[12,2048],[12,2112],[12,2112],[12,2176],[12,2176],[12,2240],[12,2240],[12,2304],[12,2304],[11,1856],[11,1856],[11,1856],[11,1856],[11,1920],[11,1920],[11,1920],[11,1920],[12,2368],[12,2368],[12,2432],[12,2432],[12,2496],[12,2496],[12,2560],[12,2560],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[10,18],[12,52],[12,52],[13,640],[13,704],[13,768],[13,832],[12,55],[12,55],[12,56],[12,56],[13,1280],[13,1344],[13,1408],[13,1472],[12,59],[12,59],[12,60],[12,60],[13,1536],[13,1600],[11,24],[11,24],[11,24],[11,24],[11,25],[11,25],[11,25],[11,25],[13,1664],[13,1728],[12,320],[12,320],[12,384],[12,384],[12,448],[12,448],[13,512],[13,576],[12,53],[12,53],[12,54],[12,54],[13,896],[13,960],[13,1024],[13,1088],[13,1152],[13,1216],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64],[10,64]],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 CCITTFaxDecoder(e,t={}){if(!e||"function"!=typeof e.next)throw new Error('CCITTFaxDecoder - invalid "source" parameter.');this.source=e;this.eof=!1;this.encoding=t.K||0;this.eoline=t.EndOfLine||!1;this.byteAlign=t.EncodedByteAlign||!1;this.columns=t.Columns||1728;this.rows=t.Rows||0;let r,a=t.EndOfBlock;null==a&&(a=!0);this.eoblock=a;this.black=t.BlackIs1||!1;this.codingLine=new Uint32Array(this.columns+1);this.refLine=new Uint32Array(this.columns+2);this.codingLine[0]=this.columns;this.codingPos=0;this.row=0;this.nextLine2D=this.encoding<0;this.inputBits=0;this.inputBuf=0;this.outputBits=0;this.rowsDone=!1;for(;0===(r=this._lookBits(12));)this._eatBits(1);1===r&&this._eatBits(12);if(this.encoding>0){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}}CCITTFaxDecoder.prototype={readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,r=this.columns;let i,n,s,o,c;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let s,c,l;if(this.nextLine2D){for(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)}this._addPixels(t[this.codingPos]+s,n);t[this.codingPos]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]=64);else do{s+=l=this._getWhiteCode()}while(l>=64);this._addPixels(t[this.codingPos]+s,n);n^=1}}let h=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){s=this._lookBits(12);if(this.eoline)for(;-1!==s&&1!==s;){this._eatBits(1);s=this._lookBits(12)}else for(;0===s;){this._eatBits(1);s=this._lookBits(12)}if(1===s){this._eatBits(12);h=!0}else-1===s&&(this.eof=!0)}else this.rowsDone=!0;if(!this.eof&&this.encoding>0&&!this.rowsDone){this.nextLine2D=!this._lookBits(1);this._eatBits(1)}if(this.eoblock&&h&&this.byteAlign){s=this._lookBits(12);if(1===s){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(o=0;o<4;++o){s=this._lookBits(12);1!==s&&(0,a.info)("bad rtc code: "+s);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){s=this._lookBits(13);if(-1===s){this.eof=!0;return-1}if(s>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&s)}}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1];this.row++}if(this.outputBits>=8){c=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&t[this.codingPos]s){c<<=s;1&this.codingPos||(c|=255>>8-s);this.outputBits-=s;s=0}else{c<<=this.outputBits;1&this.codingPos||(c|=255>>8-this.outputBits);s-=this.outputBits;this.outputBits=0;if(t[this.codingPos]0){c<<=s;s=0}}}while(s)}this.black&&(c^=255);return c},_addPixels(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;r[i]=e}this.codingPos=i},_addPixelsNeg(e,t){const r=this.codingLine;let i=this.codingPos;if(e>r[i]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&i^t&&++i;r[i]=e}else if(e0&&e=i){const t=r[e-i];if(t[0]===a){this._eatBits(a);return[!0,t[1],!0]}}}return[!1,0,!1]},_getTwoDimCode(){let t,r=0;if(this.eoblock){r=this._lookBits(7);t=e[r];if(t&&t[0]>0){this._eatBits(t[0]);return t[1]}}else{const t=this._findTableCode(1,7,e);if(t[0]&&t[2])return t[1]}(0,a.info)("Bad two dim code");return-1},_getWhiteCode(){let e,i=0;if(this.eoblock){i=this._lookBits(12);if(-1===i)return 1;e=i>>5==0?t[i]:r[i>>3];if(e[0]>0){this._eatBits(e[0]);return e[1]}}else{let e=this._findTableCode(1,9,r);if(e[0])return e[1];e=this._findTableCode(11,12,t);if(e[0])return e[1]}(0,a.info)("bad white code");this._eatBits(1);return 1},_getBlackCode(){let e,t;if(this.eoblock){e=this._lookBits(13);if(-1===e)return 1;t=e>>7==0?i[e]:e>>9==0&&e>>7!=0?n[(e>>1)-64]:s[e>>7];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(2,6,s);if(e[0])return e[1];e=this._findTableCode(7,12,n,64);if(e[0])return e[1];e=this._findTableCode(10,13,i);if(e[0])return e[1]}(0,a.info)("bad black code");this._eatBits(1);return 1},_lookBits(e){let t;for(;this.inputBits>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e},_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}};return CCITTFaxDecoder}();t.CCITTFaxDecoder=i},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Jbig2Stream=void 0;var a=r(5),i=r(12),n=r(16),s=r(2);const o=function Jbig2StreamClosure(){function Jbig2Stream(e,t,r,a){this.stream=e;this.maybeLength=t;this.dict=r;this.params=a;i.DecodeStream.call(this,t)}Jbig2Stream.prototype=Object.create(i.DecodeStream.prototype);Object.defineProperty(Jbig2Stream.prototype,"bytes",{get(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});Jbig2Stream.prototype.ensureBuffer=function(e){};Jbig2Stream.prototype.readBlock=function(){if(this.eof)return;const e=new n.Jbig2Image,t=[];if((0,a.isDict)(this.params)){const e=this.params.get("JBIG2Globals");if((0,a.isStream)(e)){const r=e.getBytes();t.push({data:r,start:0,end:r.length})}}t.push({data:this.bytes,start:0,end:this.bytes.length});const r=e.parseChunks(t),i=r.length;for(let e=0;e>>0}var n=readBits(1),s=readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(1)?readBits(32)+4436:readBits(12)+340:readBits(8)+84:readBits(6)+20:readBits(4)+4:readBits(2);return 0===n?s:s>0?-s:null}function decodeIAID(e,t,r){for(var a=e.getContexts("IAID"),i=1,n=0;n=B&&T=O){q=q<<1&y;for(f=0;f=0&&F=0&&(P=N[I][F])&&(q|=P<=e?O<<=1:O=O<<1|C[E][B]}for(d=0;d=k||B<0||B>=w?O<<=1:O=O<<1|i[E][B]}var M=x.readBit(A,O);F[P]=M}}return C}function decodeTextRegion(e,t,r,a,i,n,s,o,c,l,h,u,d,f,g,m,p,b,y){if(e&&t)throw new Jbig2Error("refinement with Huffman is not supported");var v,w,k=[];for(v=0;v1&&(a=e?y.readBits(b):decodeInteger(x,"IAIT",C));var F=s*A+a,P=e?f.symbolIDTable.decode(y):decodeIAID(x,C,c),E=t&&(e?y.readBit():decodeInteger(x,"IARI",C)),B=o[P],O=B[0].length,M=B.length;if(E){var D=decodeInteger(x,"IARDW",C),R=decodeInteger(x,"IARDH",C);B=decodeRefinement(O+=D,M+=R,g,B,(D>>1)+decodeInteger(x,"IARDX",C),(R>>1)+decodeInteger(x,"IARDY",C),!1,m,p)}var N,L,_,U=F-(1&u?0:M-1),q=I-(2&u?O-1:0);if(l){for(N=0;N>5&7,u=[31&c],d=r+6;if(7===c){h=536870911&(0,i.readUint32)(t,d-1);d+=3;var f=h+7>>3;u[0]=t[d++];for(;--f>0;)u.push(t[d++])}else if(5===c||6===c)throw new Jbig2Error("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;w[3]=y.height>>16&255;w[4]=y.height>>8&255;w[5]=255&y.height;for(m=d,p=t.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;if(!d.huffman){s=0===d.template?4:1;a=[];for(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;if(g.huffman){var p=(0,i.readUint16)(c,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){a=[];for(n=0;n<2;n++){a.push({x:(0,i.readInt8)(c,h),y:(0,i.readInt8)(c,h+1)});h+=2}g.refinementAt=a}g.numberOfSymbolInstances=(0,i.readUint32)(c,h);h+=4;r=[g,o.referredTo,c,h,u];break;case 16:const e={},t=c[h++];e.mmr=!!(1&t);e.template=t>>1&3;e.patternWidth=c[h++];e.patternHeight=c[h++];e.maxPatternIndex=(0,i.readUint32)(c,h);h+=4;r=[e,o.number,c,h,u];break;case 22:case 23:const k={};k.info=readRegionSegmentInformation(c,h);h+=l;const S=c[h++];k.mmr=!!(1&S);k.template=S>>1&3;k.enableSkip=!!(8&S);k.combinationOperator=S>>4&7;k.defaultPixelValue=S>>7&1;k.gridWidth=(0,i.readUint32)(c,h);h+=4;k.gridHeight=(0,i.readUint32)(c,h);h+=4;k.gridOffsetX=4294967295&(0,i.readUint32)(c,h);h+=4;k.gridOffsetY=4294967295&(0,i.readUint32)(c,h);h+=4;k.gridVectorX=(0,i.readUint16)(c,h);h+=2;k.gridVectorY=(0,i.readUint16)(c,h);h+=2;r=[k,o.referredTo,c,h,u];break;case 38:case 39:var b={};b.info=readRegionSegmentInformation(c,h);h+=l;var y=c[h++];b.mmr=!!(1&y);b.template=y>>1&3;b.prediction=!!(8&y);if(!b.mmr){s=0===b.template?4:1;a=[];for(n=0;n>2&1;v.combinationOperator=w>>3&3;v.requiresBuffer=!!(32&w);v.combinationOperatorOverride=!!(64&w);r=[v];break;case 49:case 50:case 51:break;case 53:r=[o.number,c,h,u];break;case 62:break;default:throw new Jbig2Error(`segment type ${o.typeName}(${o.type}) is not implemented`)}var k="on"+o.typeName;k in t&&t[k].apply(t,r)}function processSegments(e,t){for(var r=0,a=e.length;r>3,r=new Uint8ClampedArray(t*e.height);if(e.defaultPixelValue)for(var a=0,i=r.length;a>3,h=s.combinationOperatorOverride?e.combinationOperator:s.combinationOperator,u=this.buffer,d=128>>(7&e.x),f=e.y*l+(e.x>>3);switch(h){case 0:for(r=0;r>=1)){i=128;n++}}f+=l}break;case 2:for(r=0;r>=1)){i=128;n++}}f+=l}break;default:throw new Jbig2Error(`operator ${h} is not supported`)}},onImmediateGenericRegion:function SimpleSegmentVisitor_onImmediateGenericRegion(e,t,r,a){var i=e.info,n=new DecodingContext(t,r,a),s=decodeBitmap(e.mmr,i.width,i.height,e.template,e.prediction,null,e.at,n);this.drawBitmap(i,s)},onImmediateLosslessGenericRegion:function SimpleSegmentVisitor_onImmediateLosslessGenericRegion(){this.onImmediateGenericRegion.apply(this,arguments)},onSymbolDictionary:function SimpleSegmentVisitor_onSymbolDictionary(e,t,r,a,n,s){let o,c;if(e.huffman){o=function getSymbolDictionaryHuffmanTables(e,t,r){let a,i,n,s,o=0;switch(e.huffmanDHSelector){case 0:case 1:a=getStandardTable(e.huffmanDHSelector+4);break;case 3:a=getCustomHuffmanTable(o,t,r);o++;break;default:throw new Jbig2Error("invalid Huffman DH selector")}switch(e.huffmanDWSelector){case 0:case 1:i=getStandardTable(e.huffmanDWSelector+2);break;case 3:i=getCustomHuffmanTable(o,t,r);o++;break;default:throw new Jbig2Error("invalid Huffman DW selector")}if(e.bitmapSizeSelector){n=getCustomHuffmanTable(o,t,r);o++}else n=getStandardTable(1);s=e.aggregationInstancesSelector?getCustomHuffmanTable(o,t,r):getStandardTable(1);return{tableDeltaHeight:a,tableDeltaWidth:i,tableBitmapSize:n,tableAggregateInstances:s}}(e,r,this.customTables);c=new Reader(a,n,s)}var l=this.symbols;l||(this.symbols=l={});for(var h=[],u=0,d=r.length;u1)w=decodeTextRegion(e,t,a,g,0,S,1,r.concat(f),m,0,0,1,0,s,l,h,u,0,d);else{var C=decodeIAID(b,p,m),x=decodeInteger(b,"IARDX",p),A=decodeInteger(b,"IARDY",p);w=decodeRefinement(a,g,l,C=32){let r,a,s;switch(t){case 32:if(0===e)throw new Jbig2Error("no previous value in symbol ID table");a=i.readBits(2)+3;r=n[e-1].prefixLength;break;case 33:a=i.readBits(3)+3;r=0;break;case 34:a=i.readBits(7)+11;r=0;break;default:throw new Jbig2Error("invalid code length in symbol ID table")}for(s=0;s=0;b--){F=e?decodeMMRBitmap(I,l,h,!0):decodeBitmap(!1,l,h,r,!1,null,A,m);T[b]=F}for(P=0;P=0;y--){B=T[y][P][E]^B;O|=B<>8;R=d+P*f-E*g>>8;if(D>=0&&D+S<=a&&R>=0&&R+C<=n)for(b=0;b=n)){L=p[t];N=M[b];for(y=0;y=0&&e>1&7),l=1+(a>>4&7),h=[];let u,d,f=n;do{u=o.readBits(c);d=o.readBits(l);h.push(new HuffmanLine([f,u,d,0]));f+=1<>t&1;if(t<=0)this.children[r]=new HuffmanTreeNode(e);else{let a=this.children[r];a||(this.children[r]=a=new HuffmanTreeNode(null));a.buildTree(e,t-1)}},decodeNode(e){if(this.isLeaf){if(this.isOOB)return null;const t=e.readBits(this.rangeLength);return this.rangeLow+(this.isLowerRange?-t:t)}const t=this.children[e.readBit()];if(!t)throw new Jbig2Error("invalid Huffman data");return t.decodeNode(e)}};function HuffmanTable(e,t){t||this.assignPrefixCodes(e);this.rootNode=new HuffmanTreeNode(null);for(let t=0,r=e.length;t0&&this.rootNode.buildTree(r,r.prefixLength-1)}}HuffmanTable.prototype={decode(e){return this.rootNode.decodeNode(e)},assignPrefixCodes(e){const t=e.length;let r=0;for(let a=0;a=this.end)throw new Jbig2Error("end of data while reading bit");this.currentByte=this.data[this.position++];this.shift=7}const e=this.currentByte>>this.shift&1;this.shift--;return e},readBits(e){let t,r=0;for(t=e-1;t>=0;t--)r|=this.readBit()<=this.end?-1:this.data[this.position++]}};function getCustomHuffmanTable(e,t,r){let a=0;for(let i=0,n=t.length;i>r&1;r--}}if(a&&!l){const e=5;for(let t=0;tfunction parseJbig2Chunks(e){for(var t=new SimpleSegmentVisitor,r=0,a=e.length;r>=1}}return{imgData:u,width:c,height:l}}(e);this.width=r;this.height=a;return t}};return Jbig2Image}();t.Jbig2Image=o},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ArithmeticDecoder=void 0;const a=[{qe:22017,nmps:1,nlps:1,switchFlag:1},{qe:13313,nmps:2,nlps:6,switchFlag:0},{qe:6145,nmps:3,nlps:9,switchFlag:0},{qe:2753,nmps:4,nlps:12,switchFlag:0},{qe:1313,nmps:5,nlps:29,switchFlag:0},{qe:545,nmps:38,nlps:33,switchFlag:0},{qe:22017,nmps:7,nlps:6,switchFlag:1},{qe:21505,nmps:8,nlps:14,switchFlag:0},{qe:18433,nmps:9,nlps:14,switchFlag:0},{qe:14337,nmps:10,nlps:14,switchFlag:0},{qe:12289,nmps:11,nlps:17,switchFlag:0},{qe:9217,nmps:12,nlps:18,switchFlag:0},{qe:7169,nmps:13,nlps:20,switchFlag:0},{qe:5633,nmps:29,nlps:21,switchFlag:0},{qe:22017,nmps:15,nlps:14,switchFlag:1},{qe:21505,nmps:16,nlps:14,switchFlag:0},{qe:20737,nmps:17,nlps:15,switchFlag:0},{qe:18433,nmps:18,nlps:16,switchFlag:0},{qe:14337,nmps:19,nlps:17,switchFlag:0},{qe:13313,nmps:20,nlps:18,switchFlag:0},{qe:12289,nmps:21,nlps:19,switchFlag:0},{qe:10241,nmps:22,nlps:19,switchFlag:0},{qe:9217,nmps:23,nlps:20,switchFlag:0},{qe:8705,nmps:24,nlps:21,switchFlag:0},{qe:7169,nmps:25,nlps:22,switchFlag:0},{qe:6145,nmps:26,nlps:23,switchFlag:0},{qe:5633,nmps:27,nlps:24,switchFlag:0},{qe:5121,nmps:28,nlps:25,switchFlag:0},{qe:4609,nmps:29,nlps:26,switchFlag:0},{qe:4353,nmps:30,nlps:27,switchFlag:0},{qe:2753,nmps:31,nlps:28,switchFlag:0},{qe:2497,nmps:32,nlps:29,switchFlag:0},{qe:2209,nmps:33,nlps:30,switchFlag:0},{qe:1313,nmps:34,nlps:31,switchFlag:0},{qe:1089,nmps:35,nlps:32,switchFlag:0},{qe:673,nmps:36,nlps:33,switchFlag:0},{qe:545,nmps:37,nlps:34,switchFlag:0},{qe:321,nmps:38,nlps:35,switchFlag:0},{qe:273,nmps:39,nlps:36,switchFlag:0},{qe:133,nmps:40,nlps:37,switchFlag:0},{qe:73,nmps:41,nlps:38,switchFlag:0},{qe:37,nmps:42,nlps:39,switchFlag:0},{qe:21,nmps:43,nlps:40,switchFlag:0},{qe:9,nmps:44,nlps:41,switchFlag:0},{qe:5,nmps:45,nlps:42,switchFlag:0},{qe:1,nmps:45,nlps:43,switchFlag:0},{qe:22017,nmps:46,nlps:46,switchFlag:0}];t.ArithmeticDecoder=class ArithmeticDecoder{constructor(e,t,r){this.data=e;this.bp=t;this.dataEnd=r;this.chigh=e[t];this.clow=0;this.byteIn();this.chigh=this.chigh<<7&65535|this.clow>>9&127;this.clow=this.clow<<7&65535;this.ct-=7;this.a=32768}byteIn(){const e=this.data;let t=this.bp;if(255===e[t])if(e[t+1]>143){this.clow+=65280;this.ct=8}else{t++;this.clow+=e[t]<<9;this.ct=7;this.bp=t}else{t++;this.clow+=t65535){this.chigh+=this.clow>>16;this.clow&=65535}}readBit(e,t){let r=e[t]>>1,i=1&e[t];const n=a[r],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));this.a=c;e[t]=r<<1|i;return o}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.JpegStream=void 0;var a=r(12),i=r(5),n=r(19),s=r(2);const o=function JpegStreamClosure(){function JpegStream(e,t,r,i){let n;for(;-1!==(n=e.getByte());)if(255===n){e.skip(-1);break}this.stream=e;this.maybeLength=t;this.dict=r;this.params=i;a.DecodeStream.call(this,t)}JpegStream.prototype=Object.create(a.DecodeStream.prototype);Object.defineProperty(JpegStream.prototype,"bytes",{get:function JpegStream_bytes(){return(0,s.shadow)(this,"bytes",this.stream.getBytes(this.maybeLength))},configurable:!0});JpegStream.prototype.ensureBuffer=function(e){};JpegStream.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 r=this.dict.get("BitsPerComponent")||8,a=t.length,i=new Int32Array(a);let n=!1;const s=(1<0&&!e[s-1];)s--;n.push({children:[],index:0});var o,c=n[0];for(r=0;r0;)c=n.pop();c.index++;n.push(c);for(;n.length<=r;){n.push(o={children:[],index:0});c.children[c.index]=o.children;c=o}i++}if(r+10){b--;return p>>b&1}p=t[r++];if(255===p){var e=t[r++];if(e){if(220===e&&d){r+=2;const e=(0,i.readUint16)(t,r);r+=2;if(e>0&&e!==n.scanLines)throw new DNLMarkerError("Found DNL marker (0xFFDC) while parsing scan data",e)}else if(217===e){if(d){const e=k*(8===n.precision?8:0);if(e>0&&Math.round(n.scanLines/e)>=10)throw new DNLMarkerError("Found EOI marker (0xFFD9) while parsing scan data, possibly caused by incorrect `scanLines` parameter",e)}throw new EOIMarkerError("Found EOI marker (0xFFD9) while parsing scan data")}throw new JpegError("unexpected marker "+(p<<8|e).toString(16))}}b=7;return p>>>7}function decodeHuffman(e){for(var t=e;;){switch(typeof(t=t[readBit()])){case"number":return t;case"object":continue}throw new JpegError("invalid huffman sequence")}}function receive(e){for(var t=0;e>0;){t=t<<1|readBit();e--}return t}function receiveAndExtend(e){if(1===e)return 1===readBit()?1:-1;var t=receive(e);return t>=1<0)y--;else for(var a=c,i=l;a<=i;){var n=decodeHuffman(t.huffmanTableAC),s=15&n,o=n>>4;if(0!==s){var h=e[a+=o];t.blockData[r+h]=receiveAndExtend(s)*(1<>4;if(0===(a=15&i))if(o<15){y=receive(o)+(1<>4;if(0!==o){var l=e[n+=c];t.blockData[r+l]=receiveAndExtend(o);n++}else{if(c<15)break;n+=16}}};var P,E,B,O,M=0;E=1===F?s[0].blocksPerLine*s[0].blocksPerColumn:f*n.mcusPerColumn;for(;M<=E;){var D=o?Math.min(E-M,o):E;if(D>0){for(C=0;C0?"unexpected":"excessive";(0,a.warn)(`decodeScan - ${e} MCU data, current marker is: ${P.invalid}`);r=P.offset}if(!(P.marker>=65488&&P.marker<=65495))break;r+=2}return r-m}function quantizeAndInverse(e,t,r){var a,i,n,s,o,c,l,h,u,d,f,g,m,p,b,y,v,w=e.quantizationTable,k=e.blockData;if(!w)throw new JpegError("missing required Quantization Table.");for(var S=0;S<64;S+=8){u=k[t+S];d=k[t+S+1];f=k[t+S+2];g=k[t+S+3];m=k[t+S+4];p=k[t+S+5];b=k[t+S+6];y=k[t+S+7];u*=w[S];if(0!=(d|f|g|m|p|b|y)){d*=w[S+1];f*=w[S+2];g*=w[S+3];m*=w[S+4];p*=w[S+5];i=(a=(a=5793*u+128>>8)+(i=5793*m+128>>8)+1>>1)-i;v=3784*(n=f)+1567*(s=b*=w[S+6])+128>>8;n=1567*n-3784*s+128>>8;l=(o=(o=2896*(d-(y*=w[S+7]))+128>>8)+(l=p<<4)+1>>1)-l;c=(h=(h=2896*(d+y)+128>>8)+(c=g<<4)+1>>1)-c;s=(a=a+(s=v)+1>>1)-s;n=(i=i+n+1>>1)-n;v=2276*o+3406*h+2048>>12;o=3406*o-2276*h+2048>>12;h=v;v=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;l=v;r[S]=a+h;r[S+7]=a-h;r[S+1]=i+l;r[S+6]=i-l;r[S+2]=n+c;r[S+5]=n-c;r[S+3]=s+o;r[S+4]=s-o}else{v=5793*u+512>>10;r[S]=v;r[S+1]=v;r[S+2]=v;r[S+3]=v;r[S+4]=v;r[S+5]=v;r[S+6]=v;r[S+7]=v}}for(var C=0;C<8;++C){u=r[C];if(0!=((d=r[C+8])|(f=r[C+16])|(g=r[C+24])|(m=r[C+32])|(p=r[C+40])|(b=r[C+48])|(y=r[C+56]))){i=(a=4112+((a=5793*u+2048>>12)+(i=5793*m+2048>>12)+1>>1))-i;v=3784*(n=f)+1567*(s=b)+2048>>12;n=1567*n-3784*s+2048>>12;s=v;l=(o=(o=2896*(d-y)+2048>>12)+(l=p)+1>>1)-l;c=(h=(h=2896*(d+y)+2048>>12)+(c=g)+1>>1)-c;v=2276*o+3406*h+2048>>12;o=3406*o-2276*h+2048>>12;h=v;v=799*c+4017*l+2048>>12;c=4017*c-799*l+2048>>12;(u=(a=a+s+1>>1)+h)<16?u=0:u>=4080?u=255:u>>=4;(d=(i=i+n+1>>1)+(l=v))<16?d=0:d>=4080?d=255:d>>=4;(f=(n=i-n)+c)<16?f=0:f>=4080?f=255:f>>=4;(g=(s=a-s)+o)<16?g=0:g>=4080?g=255:g>>=4;(m=s-o)<16?m=0:m>=4080?m=255:m>>=4;(p=n-c)<16?p=0:p>=4080?p=255:p>>=4;(b=i-l)<16?b=0:b>=4080?b=255:b>>=4;(y=a-h)<16?y=0:y>=4080?y=255:y>>=4;k[t+C]=u;k[t+C+8]=d;k[t+C+16]=f;k[t+C+24]=g;k[t+C+32]=m;k[t+C+40]=p;k[t+C+48]=b;k[t+C+56]=y}else{v=(v=5793*u+8192>>14)<-2040?0:v>=2024?255:v+2056>>4;k[t+C]=v;k[t+C+8]=v;k[t+C+16]=v;k[t+C+24]=v;k[t+C+32]=v;k[t+C+40]=v;k[t+C+48]=v;k[t+C+56]=v}}}function buildComponentData(e,t){for(var r=t.blocksPerLine,a=t.blocksPerColumn,i=new Int16Array(64),n=0;n=a)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>=a)return null;o=(0,i.readUint16)(e,n)}return{invalid:s.toString(16),marker:o,offset:n}}JpegImage.prototype={parse(t,{dnlScanLines:r=null}={}){function readDataBlock(){const e=(0,i.readUint16)(t,o);let r=(o+=2)+e-2;var n=findNextFileMarker(t,r,o);if(n&&n.invalid){(0,a.warn)("readDataBlock - incorrect length, current marker is: "+n.invalid);r=n.offset}var s=t.subarray(o,r);o+=s.length;return s}function prepareComponents(e){for(var t=Math.ceil(e.samplesPerLine/8/e.maxH),r=Math.ceil(e.scanLines/8/e.maxV),a=0;a>4==0)for(p=0;p<64;p++)k[e[p]]=t[o++];else{if(w>>4!=1)throw new JpegError("DQT - invalid table spec");for(p=0;p<64;p++){k[e[p]]=(0,i.readUint16)(t,o);o+=2}}u[15&w]=k}break;case 65472:case 65473:case 65474:if(n)throw new JpegError("Only single frame JPEGs supported");o+=2;(n={}).extended=65473===g;n.progressive=65474===g;n.precision=t[o++];const H=(0,i.readUint16)(t,o);o+=2;n.scanLines=r||H;n.samplesPerLine=(0,i.readUint16)(t,o);o+=2;n.components=[];n.componentIds={};var S,C=t[o++],x=0,A=0;for(m=0;m>4,I=15&t[o+1];x>4==0?f:d)[15&P]=buildHuffmanTable(E,O)}break;case 65501:o+=2;s=(0,i.readUint16)(t,o);o+=2;break;case 65498:const G=1==++h&&!r;o+=2;var M,D=t[o++],R=[];for(m=0;m>4];M.huffmanTableAC=d[15&L];R.push(M)}var _=t[o++],U=t[o++],q=t[o++];try{var j=decodeScan(t,o,n,R,s,_,U,q>>4,15&q,G);o+=j}catch(e){if(e instanceof DNLMarkerError){(0,a.warn)(e.message+" -- attempting to re-parse the JPEG image.");return this.parse(t,{dnlScanLines:e.scanLines})}if(e instanceof EOIMarkerError){(0,a.warn)(e.message+" -- ignoring the rest of the image data.");break e}throw e}break;case 65500:o+=4;break;case 65535:255!==t[o]&&o--;break;default:const W=findNextFileMarker(t,o-2,o-3);if(W&&W.invalid){(0,a.warn)("JpegImage.parse - unexpected data, current marker is: "+W.invalid);o=W.offset;break}if(o>=t.length-1){(0,a.warn)("JpegImage.parse - reached the end of the image data without finding an EOI marker (0xFFD9).");break e}throw new JpegError("JpegImage.parse - unknown marker: "+g.toString(16))}g=(0,i.readUint16)(t,o);o+=2}this.width=n.samplesPerLine;this.height=n.scanLines;this.jfif=c;this.adobe=l;this.components=[];for(m=0;m>8)+S[u+1];return v},get _isColorConversionNeeded(){return this.adobe?!!this.adobe.transformCode:3===this.numComponents?0!==this._colorTransform&&(82!==this.components[0].index||71!==this.components[1].index||66!==this.components[2].index):1===this._colorTransform},_convertYccToRgb:function convertYccToRgb(e){for(var t,r,a,i=0,n=e.length;i4)throw new JpegError("Unsupported color mode");var i=this._getLinearizedBlockData(e,t,a);if(1===this.numComponents&&r){for(var n=i.length,s=new Uint8ClampedArray(3*n),o=0,c=0;c>24&255,o>>16&255,o>>8&255,255&o);(0,a.warn)("Unsupported header type "+o+" ("+d+")")}l&&(t+=c)}else this.parseCodestream(e,0,e.length)},parseImageProperties:function JpxImage_parseImageProperties(e){for(var t=e.getByte();t>=0;){if(65361===(t<<8|(t=e.getByte()))){e.skip(4);var r=e.getInt32()>>>0,a=e.getInt32()>>>0,i=e.getInt32()>>>0,n=e.getInt32()>>>0;e.skip(16);var s=e.getUint16();this.width=r-i;this.height=a-n;this.componentsCount=s;this.bitsPerComponent=8;return}}throw new JpxError("No size marker found in JPX stream")},parseCodestream:function JpxImage_parseCodestream(e,t,r){var n={},s=!1;try{for(var o=t;o+1>5;u=[];for(;l>3;S.mu=0}else{S.epsilon=e[l]>>3;S.mu=(7&e[l])<<8|e[l+1];l+=2}u.push(S)}k.SPqcds=u;if(n.mainHeader)n.QCD=k;else{n.currentTile.QCD=k;n.currentTile.QCC=[]}break;case 65373:m=(0,i.readUint16)(e,o);var C,x={};l=o+2;if(n.SIZ.Csiz<257)C=e[l++];else{C=(0,i.readUint16)(e,l);l+=2}switch(31&(h=e[l++])){case 0:d=8;f=!0;break;case 1:d=16;f=!1;break;case 2:d=16;f=!0;break;default:throw new Error("Invalid SQcd value "+h)}x.noQuantization=8===d;x.scalarExpounded=f;x.guardBits=h>>5;u=[];for(;l>3;S.mu=0}else{S.epsilon=e[l]>>3;S.mu=(7&e[l])<<8|e[l+1];l+=2}u.push(S)}x.SPqcds=u;n.mainHeader?n.QCC[C]=x:n.currentTile.QCC[C]=x;break;case 65362:m=(0,i.readUint16)(e,o);var A={};l=o+2;var T=e[l++];A.entropyCoderWithCustomPrecincts=!!(1&T);A.sopMarkerUsed=!!(2&T);A.ephMarkerUsed=!!(4&T);A.progressionOrder=e[l++];A.layersCount=(0,i.readUint16)(e,l);l+=2;A.multipleComponentTransform=e[l++];A.decompositionLevelsCount=e[l++];A.xcb=2+(15&e[l++]);A.ycb=2+(15&e[l++]);var I=e[l++];A.selectiveArithmeticCodingBypass=!!(1&I);A.resetContextProbabilities=!!(2&I);A.terminationOnEachCodingPass=!!(4&I);A.verticallyStripe=!!(8&I);A.predictableTermination=!!(16&I);A.segmentationSymbolUsed=!!(32&I);A.reversibleTransformation=e[l++];if(A.entropyCoderWithCustomPrecincts){for(var F=[];l>4})}A.precinctsSizes=F}var E=[];A.selectiveArithmeticCodingBypass&&E.push("selectiveArithmeticCodingBypass");A.resetContextProbabilities&&E.push("resetContextProbabilities");A.terminationOnEachCodingPass&&E.push("terminationOnEachCodingPass");A.verticallyStripe&&E.push("verticallyStripe");A.predictableTermination&&E.push("predictableTermination");if(E.length>0){s=!0;throw new Error("Unsupported COD options ("+E.join(", ")+")")}if(n.mainHeader)n.COD=A;else{n.currentTile.COD=A;n.currentTile.COC=[]}break;case 65424:m=(0,i.readUint16)(e,o);(g={}).index=(0,i.readUint16)(e,o+2);g.length=(0,i.readUint32)(e,o+4);g.dataEnd=g.length+o-2;g.partIndex=e[o+8];g.partsCount=e[o+9];n.mainHeader=!1;if(0===g.partIndex){g.COD=n.COD;g.COC=n.COC.slice(0);g.QCD=n.QCD;g.QCC=n.QCC.slice(0)}n.currentTile=g;break;case 65427:if(0===(g=n.currentTile).partIndex){initializeTile(n,g.index);buildPackets(n)}parseTilePackets(n,e,o,m=g.dataEnd-o);break;case 65365:case 65367:case 65368:case 65380:m=(0,i.readUint16)(e,o);break;case 65363:throw new Error("Codestream code 0xFF53 (COC) is not implemented");default:throw new Error("Unknown codestream code: "+c.toString(16))}o+=m}}catch(e){if(s||this.failOnCorruptedImage)throw new JpxError(e.message);(0,a.warn)("JPX: Trying to recover from: "+e.message)}this.tiles=function transformComponents(e){for(var t=e.SIZ,r=e.components,a=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+=a}}i.push(v)}return i}(n);this.width=n.SIZ.Xsiz-n.SIZ.XOsiz;this.height=n.SIZ.Ysiz-n.SIZ.YOsiz;this.componentsCount=n.SIZ.Csiz}};function calculateComponentDimensions(e,t){e.x0=Math.ceil(t.XOsiz/e.XRsiz);e.x1=Math.ceil(t.Xsiz/e.XRsiz);e.y0=Math.ceil(t.YOsiz/e.YRsiz);e.y1=Math.ceil(t.Ysiz/e.YRsiz);e.width=e.x1-e.x0;e.height=e.y1-e.y0}function calculateTileGrids(e,t){for(var r,a=e.SIZ,i=[],n=Math.ceil((a.Xsiz-a.XTOsiz)/a.XTsiz),s=Math.ceil((a.Ysiz-a.YTOsiz)/a.YTsiz),o=0;o0?Math.min(a.xcb,i.PPx-1):Math.min(a.xcb,i.PPx);i.ycb_=r>0?Math.min(a.ycb,i.PPy-1):Math.min(a.ycb,i.PPy);return i}function buildPrecincts(e,t,r){var a=1<t.trx0?Math.ceil(t.trx1/a)-Math.floor(t.trx0/a):0,l=t.try1>t.try0?Math.ceil(t.try1/i)-Math.floor(t.try0/i):0,h=c*l;t.precinctParameters={precinctWidth:a,precinctHeight:i,numprecinctswide:c,numprecinctshigh:l,numprecincts:h,precinctWidthInSubband:s,precinctHeightInSubband:o}}function buildCodeblocks(e,t,r){var a,i,n,s,o=r.xcb_,c=r.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=a);iy.cbyMax&&(y.cbyMax=i)}else b[s]=y={cbxMin:a,cbyMin:i,cbxMax:a,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 createPacket(e,t,r){for(var a=[],i=e.subbands,n=0,s=i.length;ne.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[l],r=t.precinctParameters.numprecincts;ue.codingStyleParameters.decompositionLevelsCount)){for(var t=e.resolutions[c],r=t.precinctParameters.numprecincts;ul.codingStyleParameters.decompositionLevelsCount)){var e=l.resolutions[r],n=e.precinctParameters.numprecincts;if(!(i>=n)){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}r=Math.min(r,u);a=Math.min(a,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:r,minHeight:a,maxNumWide:i,maxNumHigh:n}}function buildPackets(e){for(var t=e.SIZ,r=e.currentTile.index,a=e.tiles[r],i=t.Csiz,n=0;n>>(l-=e)&(1<0;){var D=v.shift();void 0===(b=D.codeblock).data&&(b.data=[]);b.data.push({data:a,start:n+c,end:n+c+D.dataLength,codingpasses:D.codingpasses});c+=D.dataLength}}}return c}function copyCoefficients(e,t,r,a,i,o,c,l){for(var h=a.tbx0,u=a.tby0,d=a.tbx1-a.tbx0,f=a.codeblocks,g="H"===a.type.charAt(0)?1:0,m="H"===a.type.charAt(1)?t:0,p=0,b=f.length;p=o?D:D*(1<0?1-v:0)}var F=w.subbands[x],P=e[F.type];copyCoefficients(C,k,0,F,m?1:2**(g+P-I)*(1+T/2048),d+I-1,m,f)}b.push({width:k,height:S,items:C})}var E=p.calculate(b,i.tcx0,i.tcy0);return{left:i.tcx0,top:i.tcy0,width:E.width,height:E.height,items:E.items}}function initializeTile(e,t){for(var r=e.SIZ.Csiz,a=e.tiles[t],i=0;i>=1;t>>=1;a++}a--;(r=this.levels[a]).items[r.index]=i;this.currentLevel=a;delete this.value},incrementValue:function TagTree_incrementValue(){var e=this.levels[this.currentLevel];e.items[e.index]++},nextLevel:function TagTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];if(--e<0){this.value=r;return!1}this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return TagTree}(),r=function InclusionTreeClosure(){function InclusionTree(e,t,r){var a=(0,i.log2)(Math.max(e,t))+1;this.levels=[];for(var n=0;nr){this.currentLevel=a;this.propagateValues();return!1}e>>=1;t>>=1;a++}this.currentLevel=a-1;return!0},incrementValue:function InclusionTree_incrementValue(e){var t=this.levels[this.currentLevel];t.items[t.index]=e+1;this.propagateValues()},propagateValues:function InclusionTree_propagateValues(){for(var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];--e>=0;)(t=this.levels[e]).items[t.index]=r},nextLevel:function InclusionTree_nextLevel(){var e=this.currentLevel,t=this.levels[e],r=t.items[t.index];t.items[t.index]=255;if(--e<0)return!1;this.currentLevel=e;(t=this.levels[e]).items[t.index]=r;return!0}};return InclusionTree}(),s=function BitModelClosure(){var e=new Uint8Array([0,5,8,0,3,7,8,0,4,7,8,0,0,0,0,0,1,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8,0,0,0,0,0,2,6,8,0,3,7,8,0,4,7,8]),t=new Uint8Array([0,3,4,0,5,7,7,0,8,8,8,0,0,0,0,0,1,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8,0,0,0,0,0,2,3,4,0,6,7,7,0,8,8,8]),r=new Uint8Array([0,1,2,0,1,2,2,0,2,2,2,0,0,0,0,0,3,4,5,0,4,5,5,0,5,5,5,0,0,0,0,0,6,7,7,0,7,7,7,0,7,7,7,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8,0,0,0,0,0,8,8,8,0,8,8,8,0,8,8,8]);function BitModel(a,i,n,s,o){this.width=a;this.height=i;let c;c="HH"===n?r:"HL"===n?t:e;this.contextLabelTable=c;var l=a*i;this.neighborsSignificance=new Uint8Array(l);this.coefficentsSign=new Uint8Array(l);let h;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){a=r-n;o&&(i[a-1]+=16);c&&(i[a+1]+=16);i[a]+=4}if(e+1=r)break;s[d]&=-2;if(!a[d]&&n[d]){var m=c[n[d]];if(e.readBit(o,m)){var p=this.decodeSignBit(g,u,d);i[d]=p;a[d]=1;this.setNeighborsSignificance(g,u,d);s[d]|=2}l[d]++;s[d]|=1}}},decodeSignBit:function BitModel_decodeSignBit(e,t,r){var a,i,n,s,o,c,l=this.width,h=this.height,u=this.coefficentsMagnitude,d=this.coefficentsSign;s=t>0&&0!==u[r-1];if(t+10&&0!==u[r-l];if(e+1=0){o=9+a;c=this.decoder.readBit(this.contexts,o)}else{o=9-a;c=1^this.decoder.readBit(this.contexts,o)}return c},runMagnitudeRefinementPass:function BitModel_runMagnitudeRefinementPass(){for(var e,t=this.decoder,r=this.width,a=this.height,i=this.coefficentsMagnitude,n=this.neighborsSignificance,s=this.contexts,o=this.bitsDecoded,c=this.processingFlags,l=r*a,h=4*r,u=0;u>1,c=-1.586134342059924,l=-.052980118572961,h=.882911075530934,u=.443506852043971,d=1.230174104914001;a=(t|=0)-3;for(i=o+4;i--;a+=2)e[a]*=.8128930661159609;n=u*e[(a=t-2)-1];for(i=o+3;i--;a+=2){s=u*e[a+1];e[a]=d*e[a]-n-s;if(!i--)break;n=u*e[(a+=2)+1];e[a]=d*e[a]-n-s}n=h*e[(a=t-1)-1];for(i=o+2;i--;a+=2){s=h*e[a+1];e[a]-=n+s;if(!i--)break;n=h*e[(a+=2)+1];e[a]-=n+s}n=l*e[(a=t)-1];for(i=o+1;i--;a+=2){s=l*e[a+1];e[a]-=n+s;if(!i--)break;n=l*e[(a+=2)+1];e[a]-=n+s}if(0!==o){n=c*e[(a=t+1)-1];for(i=o;i--;a+=2){s=c*e[a+1];e[a]-=n+s;if(!i--)break;n=c*e[(a+=2)+1];e[a]-=n+s}}};return IrreversibleTransform}(),l=function ReversibleTransformClosure(){function ReversibleTransform(){o.call(this)}ReversibleTransform.prototype=Object.create(o.prototype);ReversibleTransform.prototype.filter=function reversibleTransformFilter(e,t,r){var a,i,n=r>>1;for(a=t|=0,i=n+1;i--;a+=2)e[a]-=e[a-1]+e[a+1]+2>>2;for(a=t+1,i=n;i--;a+=2)e[a]+=e[a-1]+e[a+1]>>1};return ReversibleTransform}();return JpxImage}();t.JpxImage=s},function(e,t,r){"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 a=r(2),i=r(5),n=r(12),s=function ARCFourCipherClosure(){function ARCFourCipher(e){this.a=0;this.b=0;var t,r,a=new Uint8Array(256),i=0,n=e.length;for(t=0;t<256;++t)a[t]=t;for(t=0;t<256;++t){i=i+(r=a[t])+e[t%n]&255;a[t]=a[i];a[i]=r}this.s=a}ARCFourCipher.prototype={encryptBlock:function ARCFourCipher_encryptBlock(e){var t,r,a,i=e.length,n=this.a,s=this.b,o=this.s,c=new Uint8Array(i);for(t=0;t>5&255;f[n++]=i>>13&255;f[n++]=i>>21&255;f[n++]=i>>>29&255;f[n++]=0;f[n++]=0;f[n++]=0;var g=new Int32Array(16);for(n=0;n>>32-C)|0;b=k}c=c+b|0;l=l+y|0;h=h+v|0;u=u+w|0}return new Uint8Array([255&c,c>>8&255,c>>16&255,c>>>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=o;var c=function Word64Closure(){function Word64(e,t){this.high=0|e;this.low=0|t}Word64.prototype={and:function Word64_and(e){this.high&=e.high;this.low&=e.low},xor:function Word64_xor(e){this.high^=e.high;this.low^=e.low},or:function Word64_or(e){this.high|=e.high;this.low|=e.low},shiftRight:function Word64_shiftRight(e){if(e>=32){this.low=this.high>>>e-32|0;this.high=0}else{this.low=this.low>>>e|this.high<<32-e;this.high=this.high>>>e|0}},shiftLeft:function Word64_shiftLeft(e){if(e>=32){this.high=this.low<>>32-e;this.low=this.low<>>e|r<<32-e;this.high=r>>>e|t<<32-e},not:function Word64_not(){this.high=~this.high;this.low=~this.low},add:function Word64_add(e){var t=(this.low>>>0)+(e.low>>>0),r=(this.high>>>0)+(e.high>>>0);t>4294967295&&(r+=1);this.low=0|t;this.high=0|r},copyTo:function Word64_copyTo(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 Word64_assign(e){this.high=e.high;this.low=e.low}};return Word64}(),l=function calculateSHA256Closure(){function rotr(e,t){return e>>>t|e<<32-t}function ch(e,t,r){return e&t^~e&r}function maj(e,t,r){return e&t^e&r^t&r}function sigma(e){return rotr(e,2)^rotr(e,13)^rotr(e,22)}function sigmaPrime(e){return rotr(e,6)^rotr(e,11)^rotr(e,25)}function littleSigma(e){return rotr(e,7)^rotr(e,18)^e>>>3}var e=[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 hash(t,r,a){var i,n,s,o=1779033703,c=3144134277,l=1013904242,h=2773480762,u=1359893119,d=2600822924,f=528734635,g=1541459225,m=64*Math.ceil((a+9)/64),p=new Uint8Array(m);for(i=0;i>>29&255;p[i++]=a>>21&255;p[i++]=a>>13&255;p[i++]=a>>5&255;p[i++]=a<<3&255;var b,y=new Uint32Array(64);for(i=0;i>>10)+y[n-7]+littleSigma(y[n-15])+y[n-16]|0;var v,w,k=o,S=c,C=l,x=h,A=u,T=d,I=f,F=g;for(n=0;n<64;++n){v=F+sigmaPrime(A)+ch(A,T,I)+e[n]+y[n];w=sigma(k)+maj(k,S,C);F=I;I=T;T=A;A=x+v|0;x=C;C=S;S=k;k=v+w|0}o=o+k|0;c=c+S|0;l=l+C|0;h=h+x|0;u=u+A|0;d=d+T|0;f=f+I|0;g=g+F|0}return new Uint8Array([o>>24&255,o>>16&255,o>>8&255,255&o,c>>24&255,c>>16&255,c>>8&255,255&c,l>>24&255,l>>16&255,l>>8&255,255&l,h>>24&255,h>>16&255,h>>8&255,255&h,u>>24&255,u>>16&255,u>>8&255,255&u,d>>24&255,d>>16&255,d>>8&255,255&d,f>>24&255,f>>16&255,f>>8&255,255&f,g>>24&255,g>>16&255,g>>8&255,255&g])}}();t.calculateSHA256=l;var h=function calculateSHA512Closure(){function ch(e,t,r,a,i){e.assign(t);e.and(r);i.assign(t);i.not();i.and(a);e.xor(i)}function maj(e,t,r,a,i){e.assign(t);e.and(r);i.assign(t);i.and(a);e.xor(i);i.assign(r);i.and(a);e.xor(i)}function sigma(e,t,r){e.assign(t);e.rotateRight(28);r.assign(t);r.rotateRight(34);e.xor(r);r.assign(t);r.rotateRight(39);e.xor(r)}function sigmaPrime(e,t,r){e.assign(t);e.rotateRight(14);r.assign(t);r.rotateRight(18);e.xor(r);r.assign(t);r.rotateRight(41);e.xor(r)}function littleSigma(e,t,r){e.assign(t);e.rotateRight(1);r.assign(t);r.rotateRight(8);e.xor(r);r.assign(t);r.shiftRight(7);e.xor(r)}function littleSigmaPrime(e,t,r){e.assign(t);e.rotateRight(19);r.assign(t);r.rotateRight(61);e.xor(r);r.assign(t);r.shiftRight(6);e.xor(r)}var e=[new c(1116352408,3609767458),new c(1899447441,602891725),new c(3049323471,3964484399),new c(3921009573,2173295548),new c(961987163,4081628472),new c(1508970993,3053834265),new c(2453635748,2937671579),new c(2870763221,3664609560),new c(3624381080,2734883394),new c(310598401,1164996542),new c(607225278,1323610764),new c(1426881987,3590304994),new c(1925078388,4068182383),new c(2162078206,991336113),new c(2614888103,633803317),new c(3248222580,3479774868),new c(3835390401,2666613458),new c(4022224774,944711139),new c(264347078,2341262773),new c(604807628,2007800933),new c(770255983,1495990901),new c(1249150122,1856431235),new c(1555081692,3175218132),new c(1996064986,2198950837),new c(2554220882,3999719339),new c(2821834349,766784016),new c(2952996808,2566594879),new c(3210313671,3203337956),new c(3336571891,1034457026),new c(3584528711,2466948901),new c(113926993,3758326383),new c(338241895,168717936),new c(666307205,1188179964),new c(773529912,1546045734),new c(1294757372,1522805485),new c(1396182291,2643833823),new c(1695183700,2343527390),new c(1986661051,1014477480),new c(2177026350,1206759142),new c(2456956037,344077627),new c(2730485921,1290863460),new c(2820302411,3158454273),new c(3259730800,3505952657),new c(3345764771,106217008),new c(3516065817,3606008344),new c(3600352804,1432725776),new c(4094571909,1467031594),new c(275423344,851169720),new c(430227734,3100823752),new c(506948616,1363258195),new c(659060556,3750685593),new c(883997877,3785050280),new c(958139571,3318307427),new c(1322822218,3812723403),new c(1537002063,2003034995),new c(1747873779,3602036899),new c(1955562222,1575990012),new c(2024104815,1125592928),new c(2227730452,2716904306),new c(2361852424,442776044),new c(2428436474,593698344),new c(2756734187,3733110249),new c(3204031479,2999351573),new c(3329325298,3815920427),new c(3391569614,3928383900),new c(3515267271,566280711),new c(3940187606,3454069534),new c(4118630271,4000239992),new c(116418474,1914138554),new c(174292421,2731055270),new c(289380356,3203993006),new c(460393269,320620315),new c(685471733,587496836),new c(852142971,1086792851),new c(1017036298,365543100),new c(1126000580,2618297676),new c(1288033470,3409855158),new c(1501505948,4234509866),new c(1607167915,987167468),new c(1816402316,1246189591)];return function hash(t,r,a,i){var n,s,o,l,h,u,d,f;if(i=!!i){n=new c(3418070365,3238371032);s=new c(1654270250,914150663);o=new c(2438529370,812702999);l=new c(355462360,4144912697);h=new c(1731405415,4290775857);u=new c(2394180231,1750603025);d=new c(3675008525,1694076839);f=new c(1203062813,3204075428)}else{n=new c(1779033703,4089235720);s=new c(3144134277,2227873595);o=new c(1013904242,4271175723);l=new c(2773480762,1595750129);h=new c(1359893119,2917565137);u=new c(2600822924,725511199);d=new c(528734635,4215389547);f=new c(1541459225,327033209)}var g,m,p,b=128*Math.ceil((a+17)/128),y=new Uint8Array(b);for(g=0;g>>29&255;y[g++]=a>>21&255;y[g++]=a>>13&255;y[g++]=a>>5&255;y[g++]=a<<3&255;var v=new Array(80);for(g=0;g<80;g++)v[g]=new c(0,0);var w,k,S=new c(0,0),C=new c(0,0),x=new c(0,0),A=new c(0,0),T=new c(0,0),I=new c(0,0),F=new c(0,0),P=new c(0,0),E=new c(0,0),B=new c(0,0),O=new c(0,0),M=new c(0,0);for(g=0;g=1;--e){r=n[13];n[13]=n[9];n[9]=n[5];n[5]=n[1];n[1]=r;r=n[14];a=n[10];n[14]=n[6];n[10]=n[2];n[6]=r;n[2]=a;r=n[15];a=n[11];i=n[7];n[15]=n[3];n[11]=r;n[7]=a;n[3]=i;for(let e=0;e<16;++e)n[e]=this._inv_s[n[e]];for(let r=0,a=16*e;r<16;++r,++a)n[r]^=t[a];for(let e=0;e<16;e+=4){const t=this._mix[n[e]],a=this._mix[n[e+1]],i=this._mix[n[e+2]],s=this._mix[n[e+3]];r=t^a>>>8^a<<24^i>>>16^i<<16^s>>>24^s<<8;n[e]=r>>>24&255;n[e+1]=r>>16&255;n[e+2]=r>>8&255;n[e+3]=255&r}}r=n[13];n[13]=n[9];n[9]=n[5];n[5]=n[1];n[1]=r;r=n[14];a=n[10];n[14]=n[6];n[10]=n[2];n[6]=r;n[2]=a;r=n[15];a=n[11];i=n[7];n[15]=n[3];n[11]=r;n[7]=a;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 r=this._s;let a,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=a;--r)if(e[r]!==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,r=n.length;e=256&&(o=255&(27^o))}for(let t=0;t<4;++t){r[e]=a^=r[e-32];e++;r[e]=i^=r[e-32];e++;r[e]=n^=r[e-32];e++;r[e]=s^=r[e-32];e++}}return r}}t.AES256Cipher=AES256Cipher;var f=function PDF17Closure(){function compareByteArrays(e,t){if(e.length!==t.length)return!1;for(var r=0;rn-32;){var s=e.length+a.length+r.length,o=new Uint8Array(64*s),c=concatArrays(e,a);c=concatArrays(c,r);for(var d=0,f=0;d<64;d++,f+=s)o.set(c,f);i=new AES128Cipher(a.subarray(0,16)).encrypt(o,a.subarray(16,32));for(var g=0,m=0;m<16;m++){g*=1;g%=3;g+=(i[m]>>>0)%3;g%=3}0===g?a=l(i,0,i.length):1===g?a=u(i,0,i.length):2===g&&(a=h(i,0,i.length));n++}return a.subarray(0,32)}function PDF20(){}function compareByteArrays(e,t){if(e.length!==t.length)return!1;for(var r=0;r>8&255;g[m++]=n>>16&255;g[m++]=n>>>24&255;for(u=0,d=t.length;u=4&&!h){g[m++]=255;g[m++]=255;g[m++]=255;g[m++]=255}var p=o(g,0,m),b=l>>3;if(c>=3)for(u=0;u<50;++u)p=o(p,0,b);var y,v=p.subarray(0,b);if(c>=3){for(m=0;m<32;++m)g[m]=e[m];for(u=0,d=t.length;u>3;if(a>=3)for(n=0;n<50;++n)d=o(d,0,d.length);if(a>=3){u=r;var g,m=new Uint8Array(f);for(n=19;n>=0;n--){for(g=0;g=4){var O=r.get("CF");(0,i.isDict)(O)&&(O.suppressEncryption=!0);this.cf=O;this.stmf=r.get("StmF")||t;this.strf=r.get("StrF")||t;this.eff=r.get("EFF")||this.stmf}}function buildObjectKey(e,t,r,a){var i,n,s=new Uint8Array(r.length+9);for(i=0,n=r.length;i>8&255;s[i++]=e>>16&255;s[i++]=255&t;s[i++]=t>>8&255;if(a){s[i++]=115;s[i++]=65;s[i++]=108;s[i++]=84}return o(s,0,i).subarray(0,Math.min(r.length+5,16))}function buildCipherConstructor(e,t,r,n,o){if(!(0,i.isName)(t))throw new a.FormatError("Invalid crypt filter name.");var c,l=e.get(t.name);null!=l&&(c=l.get("CFM"));if(!c||"None"===c.name)return function cipherTransformFactoryBuildCipherConstructorNone(){return new d};if("V2"===c.name)return function cipherTransformFactoryBuildCipherConstructorV2(){return new s(buildObjectKey(r,n,o,!1))};if("AESV2"===c.name)return function cipherTransformFactoryBuildCipherConstructorAESV2(){return new AES128Cipher(buildObjectKey(r,n,o,!0))};if("AESV3"===c.name)return function cipherTransformFactoryBuildCipherConstructorAESV3(){return new AES256Cipher(o)};throw new a.FormatError("Unknown crypto method")}CipherTransformFactory.prototype={createCipherTransform:function CipherTransformFactory_createCipherTransform(e,t){if(4===this.algorithm||5===this.algorithm)return new m(buildCipherConstructor(this.cf,this.stmf,e,t,this.encryptionKey),buildCipherConstructor(this.cf,this.strf,e,t,this.encryptionKey));var r=buildObjectKey(e,t,this.encryptionKey,!1),a=function buildCipherCipherConstructor(){return new s(r)};return new m(a,a)}};return CipherTransformFactory}();t.CipherTransformFactory=p},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ColorSpace=void 0;var a=r(2),i=r(5),n=r(8);class ColorSpace{constructor(e,t){this.constructor===ColorSpace&&(0,a.unreachable)("Cannot initialize ColorSpace.");this.name=e;this.numComps=t}getRgb(e,t){const r=new Uint8ClampedArray(3);this.getRgbItem(e,t,r,0);return r}getRgbItem(e,t,r,i){(0,a.unreachable)("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,r,i,n,s,o){(0,a.unreachable)("Should not call ColorSpace.getRgbBuffer")}getOutputLength(e,t){(0,a.unreachable)("Should not call ColorSpace.getOutputLength")}isPassthrough(e){return!1}isDefaultDecode(e,t){return ColorSpace.isDefaultDecode(e,this.numComps)}fillRgb(e,t,r,a,i,n,s,o,c){const l=t*r;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;e=.99554525?1:adjustToRange(0,1,1.055*e**(1/2.4)-.055)}function adjustToRange(e,t,r){return Math.max(e,Math.min(t,r))}function decodeL(e){return e<0?-decodeL(-e):e>8?((e+16)/116)**3:e*((24/116)**3/8)}function convertToRgb(a,c,l,h,u,d){const f=adjustToRange(0,1,c[l]*d),g=adjustToRange(0,1,c[l+1]*d),m=adjustToRange(0,1,c[l+2]*d),p=1===f?1:f**a.GR,b=1===g?1:g**a.GG,y=1===m?1:m**a.GB,v=a.MXA*p+a.MXB*b+a.MXC*y,w=a.MYA*p+a.MYB*b+a.MYC*y,k=a.MZA*p+a.MZB*b+a.MZC*y,S=s;S[0]=v;S[1]=w;S[2]=k;const C=o;!function normalizeWhitePointToFlat(r,a,i){if(1===r[0]&&1===r[2]){i[0]=a[0];i[1]=a[1];i[2]=a[2];return}const s=i;matrixProduct(e,a,s);const o=n;!function convertToFlat(e,t,r){r[0]=1*t[0]/e[0];r[1]=1*t[1]/e[1];r[2]=1*t[2]/e[2]}(r,s,o);matrixProduct(t,o,i)}(a.whitePoint,S,C);const x=s;!function compensateBlackPoint(e,t,r){if(0===e[0]&&0===e[1]&&0===e[2]){r[0]=t[0];r[1]=t[1];r[2]=t[2];return}const a=decodeL(0),i=(1-a)/(1-decodeL(e[0])),n=1-i,s=(1-a)/(1-decodeL(e[1])),o=1-s,c=(1-a)/(1-decodeL(e[2])),l=1-c;r[0]=t[0]*i+n;r[1]=t[1]*s+o;r[2]=t[2]*c+l}(a.blackPoint,C,x);const A=o;!function normalizeWhitePointToD65(r,a,i){const s=i;matrixProduct(e,a,s);const o=n;!function convertToD65(e,t,r){r[0]=.95047*t[0]/e[0];r[1]=1*t[1]/e[1];r[2]=1.08883*t[2]/e[2]}(r,s,o);matrixProduct(t,o,i)}(i,x,A);const T=s;matrixProduct(r,A,T);h[u]=255*sRGBTransferFunction(T[0]);h[u+1]=255*sRGBTransferFunction(T[1]);h[u+2]=255*sRGBTransferFunction(T[2])}return class CalRGBCS extends ColorSpace{constructor(e,t,r,i){super("CalRGB",3);if(!e)throw new a.FormatError("WhitePoint missing - required for color space CalRGB");t=t||new Float32Array(3);r=r||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];this.blackPoint=t;this.GR=r[0];this.GG=r[1];this.GB=r[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];if(n<0||o<0||1!==s)throw new a.FormatError("Invalid WhitePoint components for "+this.name+", no fallback available");if(c<0||l<0||h<0){(0,a.info)(`Invalid BlackPoint for ${this.name} [${c}, ${l}, ${h}], falling back to default.`);this.blackPoint=new Float32Array(3)}if(this.GR<0||this.GG<0||this.GB<0){(0,a.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,r,a){convertToRgb(this,e,t,r,a,1)}getRgbBuffer(e,t,r,a,i,n,s){const o=1/((1<=6/29?e*e*e:108/841*(e-4/29);return t}function decode(e,t,r,a){return r+e*(a-r)/t}function convertToRgb(e,t,r,a,i,n){let s=t[r],o=t[r+1],c=t[r+2];if(!1!==a){s=decode(s,a,0,100);o=decode(o,a,e.amin,e.amax);c=decode(c,a,e.bmin,e.bmax)}o>e.amax?o=e.amax:oe.bmax?c=e.bmax:cthis.amax||this.bmin>this.bmax){(0,a.info)("Invalid Range, falling back to defaults");this.amin=-100;this.amax=100;this.bmin=-100;this.bmax=100}}getRgbItem(e,t,r,a){convertToRgb(this,e,t,!1,r,a)}getRgbBuffer(e,t,r,a,i,n,s){const o=(1<=GlobalImageCache.MAX_IMAGES_TO_CACHE)}addPageIndex(e,t){let r=this._refCache.get(e);if(!r){r=new Set;this._refCache.put(e,r)}r.add(t)}getData(e,t){const r=this._refCache.get(e);if(!r)return null;if(r.size=GlobalImageCache.MAX_IMAGES_TO_CACHE?(0,a.info)("GlobalImageCache.setData - ignoring image above MAX_IMAGES_TO_CACHE."):this._imageCache.put(e,t))}clear(e=!1){e||this._refCache.clear();this._imageCache.clear()}}t.GlobalImageCache=GlobalImageCache},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.getQuadPoints=getQuadPoints;t.MarkupAnnotation=t.AnnotationFactory=t.AnnotationBorderStyle=t.Annotation=void 0;var a=r(2),i=r(10),n=r(5),s=r(23),o=r(8),c=r(26),l=r(12),h=r(27);t.AnnotationFactory=class AnnotationFactory{static create(e,t,r,a){return r.ensureCatalog("acroForm").then(i=>r.ensure(this,"_create",[e,t,r,a,i]))}static _create(e,t,r,i,s){const c=e.fetchIfRef(t);if(!(0,n.isDict)(c))return;const l=(0,n.isRef)(t)?t.toString():"annot_"+i.createObjId();let h=c.get("Subtype");h=(0,n.isName)(h)?h.name:null;const u={xref:e,ref:t,dict:c,subtype:h,id:l,pdfManager:r,acroForm:s instanceof n.Dict?s:n.Dict.empty};switch(h){case"Link":return new LinkAnnotation(u);case"Text":return new TextAnnotation(u);case"Widget":let e=(0,o.getInheritableProperty)({dict:c,key:"FT"});e=(0,n.isName)(e)?e.name:null;switch(e){case"Tx":return new TextWidgetAnnotation(u);case"Btn":return new ButtonWidgetAnnotation(u);case"Ch":return new ChoiceWidgetAnnotation(u)}(0,a.warn)('Unimplemented widget field type "'+e+'", falling back to base field type.');return new WidgetAnnotation(u);case"Popup":return new PopupAnnotation(u);case"FreeText":return new FreeTextAnnotation(u);case"Line":return new LineAnnotation(u);case"Square":return new SquareAnnotation(u);case"Circle":return new CircleAnnotation(u);case"PolyLine":return new PolylineAnnotation(u);case"Polygon":return new PolygonAnnotation(u);case"Caret":return new CaretAnnotation(u);case"Ink":return new InkAnnotation(u);case"Highlight":return new HighlightAnnotation(u);case"Underline":return new UnderlineAnnotation(u);case"Squiggly":return new SquigglyAnnotation(u);case"StrikeOut":return new StrikeOutAnnotation(u);case"Stamp":return new StampAnnotation(u);case"FileAttachment":return new FileAttachmentAnnotation(u);default:h?(0,a.warn)('Unimplemented annotation type "'+h+'", falling back to base annotation.'):(0,a.warn)("Annotation is missing the required /Subtype.");return new Annotation(u)}}};function getQuadPoints(e,t){if(!e.has("QuadPoints"))return null;const r=e.getArray("QuadPoints");if(!Array.isArray(r)||r.length%8>0)return null;const a=[];for(let e=0,i=r.length/8;et[2]||st[3])return null;a[e].push({x:n,y:s})}}return a}function getTransformMatrix(e,t,r){const[i,n,s,o]=a.Util.getAxialAlignedBoundingBox(t,r);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]}class Annotation{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,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.HIDDEN)&&!this._hasFlag(e,a.AnnotationFlag.NOVIEW)}_isPrintable(e){return this._hasFlag(e,a.AnnotationFlag.PRINT)&&!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.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,a.stringToPDFString)(e||"")}setModificationDate(e){this.modificationDate=(0,a.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=a.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){this.borderStyle=new AnnotationBorderStyle;if((0,n.isDict)(e))if(e.has("BS")){const t=e.get("BS"),r=t.get("Type");if(!r||(0,n.isName)(r,"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");if(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 r=t.get("N");if((0,n.isStream)(r)){this.appearance=r;return}if(!(0,n.isDict)(r))return;const a=e.get("AS");(0,n.isName)(a)&&r.has(a.name)&&(this.appearance=r.get(a.name))}loadResources(e){return this.appearance.dict.getAsync("Resources").then(t=>{if(!t)return;return new i.ObjectLoader(t,e,t.xref).load().then((function(){return t}))})}getOperatorList(e,t,r,i){if(!this.appearance)return Promise.resolve(new c.OperatorList);const n=this.appearance,s=this.data,o=n.dict,l=this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"]),h=o.getArray("BBox")||[0,0,1,1],u=o.getArray("Matrix")||[1,0,0,1,0,0],d=getTransformMatrix(s.rect,h,u);return l.then(r=>{const i=new c.OperatorList;i.addOp(a.OPS.beginAnnotation,[s.rect,d,u]);return e.getOperatorList({stream:n,task:t,resources:r,operatorList:i}).then(()=>{i.addOp(a.OPS.endAnnotation,[]);n.reset();return i})})}async save(e,t,r){return null}}t.Annotation=Annotation;class AnnotationBorderStyle{constructor(){this.width=1;this.style=a.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 r=(t[2]-t[0])/2,i=(t[3]-t[1])/2;if(r>0&&i>0&&(e>r||e>i)){(0,a.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=a.AnnotationBorderStyleType.SOLID;break;case"D":this.style=a.AnnotationBorderStyleType.DASHED;break;case"B":this.style=a.AnnotationBorderStyleType.BEVELED;break;case"I":this.style=a.AnnotationBorderStyleType.INSET;break;case"U":this.style=a.AnnotationBorderStyleType.UNDERLINE}}setDashArray(e){if(Array.isArray(e)&&e.length>0){let t=!0,r=!0;for(const a of e){if(!(+a>=0)){t=!1;break}a>0&&(r=!1)}t&&!r?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=AnnotationBorderStyle;class MarkupAnnotation extends Annotation{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 r=t.get("RT");this.data.replyType=(0,n.isName)(r)?r.name:a.AnnotationReplyType.REPLY}if(this.data.replyType===a.AnnotationReplyType.GROUP){const e=t.get("IRT");this.data.title=(0,a.stringToPDFString)(e.get("T")||"");this.setContents(e.get("Contents"));this.data.contents=this.contents;if(e.has("CreationDate")){this.setCreationDate(e.get("CreationDate"));this.data.creationDate=this.creationDate}else this.data.creationDate=null;if(e.has("M")){this.setModificationDate(e.get("M"));this.data.modificationDate=this.modificationDate}else this.data.modificationDate=null;this.data.hasPopup=e.has("Popup");if(e.has("C")){this.setColor(e.getArray("C"));this.data.color=this.color}else this.data.color=null}else{this.data.title=(0,a.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,a.isString)(e)?e:null}}t.MarkupAnnotation=MarkupAnnotation;class WidgetAnnotation extends Annotation{constructor(e){super(e);const t=e.dict,r=this.data;this.ref=e.ref;r.annotationType=a.AnnotationType.WIDGET;r.fieldName=this._constructFieldName(t);const i=(0,o.getInheritableProperty)({dict:t,key:"V",getArray:!0});r.fieldValue=this._decodeFormValue(i);r.alternativeText=(0,a.stringToPDFString)(t.get("TU")||"");r.defaultAppearance=(0,o.getInheritableProperty)({dict:t,key:"DA"})||e.acroForm.get("DA")||"";const s=(0,o.getInheritableProperty)({dict:t,key:"FT"});r.fieldType=(0,n.isName)(s)?s.name:null;this.fieldResources=(0,o.getInheritableProperty)({dict:t,key:"DR"})||e.acroForm.get("DR")||n.Dict.empty;r.fieldFlags=(0,o.getInheritableProperty)({dict:t,key:"Ff"});(!Number.isInteger(r.fieldFlags)||r.fieldFlags<0)&&(r.fieldFlags=0);r.readOnly=this.hasFieldFlag(a.AnnotationFieldFlag.READONLY);if("Sig"===r.fieldType){r.fieldValue=null;this.setFlags(a.AnnotationFlag.HIDDEN)}}_constructFieldName(e){if(!e.has("T")&&!e.has("Parent")){(0,a.warn)("Unknown field name, falling back to empty field name.");return""}if(!e.has("Parent"))return(0,a.stringToPDFString)(e.get("T"));const t=[];e.has("T")&&t.unshift((0,a.stringToPDFString)(e.get("T")));let r=e;for(;r.has("Parent");){r=r.get("Parent");if(!(0,n.isDict)(r))break;r.has("T")&&t.unshift((0,a.stringToPDFString)(r.get("T")))}return t.join(".")}_decodeFormValue(e){return Array.isArray(e)?e.filter(e=>(0,a.isString)(e)).map(e=>(0,a.stringToPDFString)(e)):(0,n.isName)(e)?(0,a.stringToPDFString)(e.name):(0,a.isString)(e)?(0,a.stringToPDFString)(e):null}hasFieldFlag(e){return!!(this.data.fieldFlags&e)}getOperatorList(e,t,r,i){return r?Promise.resolve(new c.OperatorList):this._hasText?this._getAppearance(e,t,i).then(n=>{if(this.appearance&&null===n)return super.getOperatorList(e,t,r,i);const s=new c.OperatorList;if(!this.data.defaultAppearance||null===n)return s;const o=[1,0,0,1,0,0],h=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],u=getTransformMatrix(this.data.rect,h,o);s.addOp(a.OPS.beginAnnotation,[this.data.rect,u,o]);const d=new l.StringStream(n);return e.getOperatorList({stream:d,task:t,resources:this.fieldResources,operatorList:s}).then((function(){s.addOp(a.OPS.endAnnotation,[]);return s}))}):super.getOperatorList(e,t,r,i)}async save(e,t,r){if(this.data.fieldValue===r[this.data.id])return null;let i=await this._getAppearance(e,t,r);if(null===i)return null;const s=e.xref.fetchIfRef(this.ref);if(!(0,n.isDict)(s))return null;const o=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],c=e.xref.getNewRef(),l=new n.Dict(e.xref);l.set("N",c);const u=r[this.data.id],d=e.xref.encrypt;let f=null,g=null;if(d){f=d.createCipherTransform(this.ref.num,this.ref.gen);g=d.createCipherTransform(c.num,c.gen);i=g.encryptString(i)}s.set("V",u);s.set("AP",l);s.set("M","D:"+(0,a.getModificationDate)());const m=new n.Dict(e.xref);m.set("Length",i.length);m.set("Subtype",n.Name.get("Form"));m.set("Resources",this.fieldResources);m.set("BBox",o);const p=[`${this.ref.num} ${this.ref.gen} obj\n`];(0,h.writeDict)(s,p,f);p.push("\nendobj\n");const b=[`${c.num} ${c.gen} obj\n`];(0,h.writeDict)(m,b,g);b.push(" stream\n");b.push(i);b.push("\nendstream\nendobj\n");return[{ref:this.ref,data:p.join("")},{ref:c,data:b.join("")}]}async _getAppearance(e,t,r){const i=this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD);if(!r||i)return null;const n=r[this.data.id];if(""===n)return"";const s=this.data.rect[3]-this.data.rect[1],o=this.data.rect[2]-this.data.rect[0],c=await this._getFontData(e,t),[l,h]=c;let u=c[2];u=this._computeFontSize(l,h,u,s);let d=l.descent;isNaN(d)&&(d=0);const f=2+Math.abs(d)*u,g=this.data.defaultAppearance,m=this.data.textAlignment;if(this.data.comb)return this._getCombAppearance(g,n,o,2,f);if(this.data.multiLine)return this._getMultilineAppearance(g,n,l,u,o,s,m,2,f);if(0===m||m>2)return"/Tx BMC q BT "+g+` 1 0 0 1 2 ${f} Tm (${(0,a.escapeString)(n)}) Tj ET Q EMC`;return"/Tx BMC q BT "+g+" 1 0 0 1 0 0 Tm "+this._renderText(n,l,u,o,m,2,f)+" ET Q EMC"}async _getFontData(e,t){const r=new c.OperatorList,a={fontSize:0,font:null,fontName:null,clone(){return this}};await e.getOperatorList({stream:new l.StringStream(this.data.defaultAppearance),task:t,resources:this.fieldResources,operatorList:r,initialState:a});return[a.font,a.fontName,a.fontSize]}_computeFontSize(e,t,r,a){if(null===r||0===r){const i=.7*(e.charsToGlyphs("M",!0)[0].width/1e3);r=Math.max(1,Math.floor(a/(1.5*i)));let n=new RegExp(`/${t}\\s+[0-9.]+\\s+Tf`);-1===this.data.defaultAppearance.search(n)&&(n=new RegExp(`/${t}\\s+Tf`));this.data.defaultAppearance=this.data.defaultAppearance.replace(n,`/${t} ${r} Tf`)}return r}_renderText(e,t,r,i,n,s,o){const c=t.charsToGlyphs(e),l=r/1e3;let h,u=0;for(const e of c)u+=e.width*l;h=1===n?(i-u)/2:2===n?i-u-s:s;h=h.toFixed(2);return`${h} ${o=o.toFixed(2)} Td (${(0,a.escapeString)(e)}) Tj`}}class TextWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this._hasText=!0;const t=e.dict;(0,a.isString)(this.data.fieldValue)||(this.data.fieldValue="");let r=(0,o.getInheritableProperty)({dict:t,key:"Q"});(!Number.isInteger(r)||r<0||r>2)&&(r=null);this.data.textAlignment=r;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(a.AnnotationFieldFlag.MULTILINE);this.data.comb=this.hasFieldFlag(a.AnnotationFieldFlag.COMB)&&!this.hasFieldFlag(a.AnnotationFieldFlag.MULTILINE)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD)&&!this.hasFieldFlag(a.AnnotationFieldFlag.FILESELECT)&&null!==this.data.maxLen}_getCombAppearance(e,t,r,i,n){const s=(r/this.data.maxLen).toFixed(2),o=[];for(const e of t)o.push(`(${(0,a.escapeString)(e)}) Tj`);return"/Tx BMC q BT "+e+` 1 0 0 1 ${i} ${n} Tm ${o.join(` ${s} 0 Td `)} ET Q EMC`}_getMultilineAppearance(e,t,r,a,i,n,s,o,c){const l=t.split(/\r\n|\r|\n/),h=[],u=i-2*o;for(const e of l){const t=this._splitLine(e,r,a,u);for(const e of t){const t=0===h.length?o:0;h.push(this._renderText(e,r,a,i,s,t,-a))}}return"/Tx BMC q BT "+e+` 1 0 0 1 0 ${n} Tm ${h.join("\n")} ET Q EMC`}_splitLine(e,t,r,a){if(e.length<=1)return[e];const i=r/1e3,n=t.charsToGlyphs(" ",!0)[0].width*i,s=[];let o=-1,c=0,l=0;for(let r=0,h=e.length;ra){s.push(e.substring(c,r));c=r;l=n;o=-1}else{l+=n;o=r}else{const n=t.charsToGlyphs(h,!1)[0].width*i;if(l+n>a)if(-1!==o){s.push(e.substring(c,o+1));c=r=o+1;o=-1;l=0}else{s.push(e.substring(c,r));c=r;l=n}else l+=n}}c1e3){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}}r.splice(s,4*l,a.OPS.paintInlineImageXObjectGroup);i.splice(s,4*l,[{width:y,height:v,kind:a.ImageKind.RGBA_32BPP,data:w},d]);return s+1}));addState(e,[a.OPS.save,a.OPS.transform,a.OPS.paintImageMaskXObject,a.OPS.restore],null,(function iterateImageMaskGroup(e,t){var r=e.fnArray,i=(t-(e.iCurr-3))%4;switch(i){case 0:return r[t]===a.OPS.save;case 1:return r[t]===a.OPS.transform;case 2:return r[t]===a.OPS.paintImageMaskXObject;case 3:return r[t]===a.OPS.restore}throw new Error("iterateImageMaskGroup - invalid pos: "+i)}),(function foundImageMaskGroup(e,t){var r,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 handlePaintSolidColorImageMask(e,t,r,i){for(var n=e+2,s=0;s=4&&r[n-4]===r[s]&&r[n-3]===r[o]&&r[n-2]===r[c]&&r[n-1]===r[l]&&a[n-4][0]===h&&a[n-4][1]===u){d++;f-=5}for(var g=f+4,m=1;m=a)break}i=(i||e)[t[r]];if(i&&!Array.isArray(i)){s.iCurr=r;r++;if(!i.checkFn||(0,i.checkFn)(s)){n=i;i=null}else i=null}else r++}this.state=i;this.match=n;this.lastProcessed=r},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}};return QueueOptimizer}(),n=function NullOptimizerClosure(){function NullOptimizer(e){this.queue=e}NullOptimizer.prototype={push(e,t){this.queue.fnArray.push(e);this.queue.argsArray.push(t)},flush(){},reset(){}};return NullOptimizer}(),s=function OperatorListClosure(){function OperatorList(e,t){this._streamSink=t;this.fnArray=[];this.argsArray=[];this.optimizer=t&&"oplist"!==e?new i(this):new n(this);this.dependencies=new Set;this._totalLength=0;this.weight=0;this._resolved=t?null:Promise.resolve()}OperatorList.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===a.OPS.restore||e===a.OPS.endText))&&this.flush()},addDependency(e){if(!this.dependencies.has(e)){this.dependencies.add(e);this.addOp(a.OPS.dependency,[e])}},addDependencies(e){for(const t of e)this.addDependency(t)},addOpList(e){if(e instanceof OperatorList){for(const t of e.dependencies)this.dependencies.add(t);for(var t=0,r=e.length;te.ref.num-t.ref.num);const u=[[0,1,65535]],d=[0,1];let f=0;for(const{ref:e,data:t}of r){f=Math.max(f,l);u.push([1,l,Math.min(e.gen,65535)]);l+=t.length;d.push(e.num);d.push(1);c.push(t)}s.set("Index",d);if(0!==t.fileIds.length){const e=function computeMD5(e,t){const r=Math.floor(Date.now()/1e3),i=t.filename||"",s=[r.toString(),i,e.toString()];let o=s.reduce((e,t)=>e+t.length,0);for(const e of Object.values(t.info)){s.push(e);o+=e.length}const c=new Uint8Array(o);let l=0;for(const e of s){writeString(e,l,c);l+=e.length}return(0,a.bytesToString)((0,n.calculateMD5)(c))}(l,t);s.set("ID",[t.fileIds[0],e])}const g=[1,Math.ceil(Math.log2(f)/8),2],m=(g[0]+g[1]+g[2])*u.length;s.set("W",g);s.set("Length",m);c.push(`${o.num} ${o.gen} obj\n`);writeDict(s,c,null);c.push(" stream\n");const p=c.reduce((e,t)=>e+t.length,0),b=`\nendstream\nendobj\nstartxref\n${l}\n%%EOF\n`,y=new Uint8Array(e.length+p+m+b.length);y.set(e);let v=e.length;for(const e of c){writeString(e,v,y);v+=e.length}for(const[e,t,r]of u){v=writeInt(e,g[0],v,y);v=writeInt(t,g[1],v,y);v=writeInt(r,g[2],v,y)}writeString(b,v,y);return y};var a=r(2),i=r(5),n=r(22);function writeDict(e,t,r){t.push("<<");for(const a of e.getKeys()){t.push(` /${a} `);writeValue(e.getRaw(a),t,r)}t.push(">>")}function writeValue(e,t,r){if((0,i.isName)(e))t.push("/"+e.name);else if((0,i.isRef)(e))t.push(`${e.num} ${e.gen} R`);else if(Array.isArray(e))!function writeArray(e,t,r){t.push("[");let a=!0;for(const i of e){a?a=!1:t.push(" ");writeValue(i,t,r)}t.push("]")}(e,t,r);else if("string"==typeof e){null!==r&&(e=r.encryptString(e));t.push(`(${(0,a.escapeString)(e)})`)}else"number"==typeof e?t.push(function numberToString(e){if(Number.isInteger(e))return e.toString();const t=Math.round(100*e);return t%100==0?(t/100).toString():t%10==0?e.toFixed(1):e.toFixed(2)}(e)):(0,i.isDict)(e)?writeDict(e,t,r):(0,i.isStream)(e)&&function writeStream(e,t,r){writeDict(e.dict,t,r);t.push(" stream\n");let i=(0,a.bytesToString)(e.getBytes());null!==r&&(i=r.encryptString(i));t.push(i);t.push("\nendstream\n")}(e,t,r)}function writeInt(e,t,r,a){for(let i=t+r-1;i>r-1;i--){a[i]=255&e;e>>=8}return r+t}function writeString(e,t,r){for(let a=0,i=e.length;ag){(0,a.warn)("Image exceeded maximum allowed size and was removed.");return}if(c.get("ImageMask","IM")||!1){var m=c.get("Width","W"),p=c.get("Height","H"),y=m+7>>3,v=t.getBytes(y*p,!0),w=c.getArray("Decode","D");(d=S.PDFImage.createMask({imgArray:v,width:m,height:p,imageIsFromDecodeStream:t instanceof b.DecodeStream,inverseDecode:!!w&&w[0]>0})).cached=!!n;f=[d];i.addOp(a.OPS.paintImageMaskXObject,f);n&&s.set(n,l,{fn:a.OPS.paintImageMaskXObject,args:f});return}var k=c.get("SMask","SM")||!1,C=c.get("Mask")||!1;if(r&&!k&&!C&&h+u<200){const n=new S.PDFImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:o});d=n.createImageData(!0);i.addOp(a.OPS.paintInlineImageXObject,[d]);return}let x="img_"+this.idFactory.createObjId(),A=!1;if(this.parsingType3Font)x=`${this.idFactory.getDocId()}_type3_${x}`;else if(l){A=this.globalImageCache.shouldCache(l,this.pageIndex);A&&(x=`${this.idFactory.getDocId()}_${x}`)}i.addDependency(x);f=[x,h,u];S.PDFImage.buildImage({xref:this.xref,res:e,image:t,isInline:r,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:o}).then(e=>{d=e.createImageData(!1);return this._sendImgData(x,d,A)}).catch(e=>{(0,a.warn)(`Unable to decode image "${x}": "${e}".`);return this._sendImgData(x,null,A)});i.addOp(a.OPS.paintImageXObject,f);if(n){s.set(n,l,{fn:a.OPS.paintImageXObject,args:f});if(l){(0,a.assert)(!r,"Cannot cache an inline image globally.");this.globalImageCache.addPageIndex(l,this.pageIndex);A&&this.globalImageCache.setData(l,{objId:x,fn:a.OPS.paintImageXObject,args:f})}}}handleSMask(e,t,r,a,i,n){var s=e.get("G"),o={subtype:e.get("S").name,backdrop:e.get("BC")},c=e.get("TR");if((0,d.isPDFFunction)(c)){const e=this._pdfFunctionFactory.create(c);for(var l=new Uint8Array(256),h=new Float32Array(1),u=0;u<256;u++){h[0]=u/255;e(h,0,h,0);l[u]=255*h[0]|0}o.transferMap=l}return this.buildFormXObject(t,s,o,r,a,i.state.clone(),n)}handleTransferFunction(e){let t;if(Array.isArray(e))t=e;else{if(!(0,d.isPDFFunction)(e))return null;t=[e]}const r=[];let a=0,i=0;for(const e of t){const t=this.xref.fetchIfRef(e);a++;if((0,n.isName)(t,"Identity")){r.push(null);continue}if(!(0,d.isPDFFunction)(t))return null;const s=this._pdfFunctionFactory.create(t),o=new Uint8Array(256),c=new Float32Array(1);for(let e=0;e<256;e++){c[0]=e/255;s(c,0,c,0);o[e]=255*c[0]|0}r.push(o);i++}return 1!==a&&4!==a||0===i?null:r}handleTilingType(e,t,r,i,s,o,c){const l=new k.OperatorList,h=n.Dict.merge({xref:this.xref,dictArray:[s.get("Resources"),r]});return this.getOperatorList({stream:i,task:c,resources:h,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 a.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorTilingPattern});(0,a.warn)(`handleTilingType - ignoring pattern: "${e}".`)}})}handleSetFont(e,t,r,i,n,o){var c,l=0;if(t){t=t.slice();c=t[0].name;l=t[1]}return this.loadFont(c,r,e).then(t=>t.font.isType3Font?t.loadType3Data(this,e,n).then((function(){i.addDependencies(t.type3Dependencies);return t})).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontLoadType3});return new TranslatedFont({loadedName:"g_font_error",font:new s.ErrorFont("Type3 font load error: "+e),dict:t.font,extraProperties:this.options.fontExtraProperties})}):t).then(e=>{o.font=e.font;o.fontSize=l;o.fontName=c;e.send(this.handler);return e.loadedName})}handleText(e,t){const r=t.font,i=r.charsToGlyphs(e);if(r.data){(!!(t.textRenderingMode&a.TextRenderingMode.ADD_TO_PATH_FLAG)||"Pattern"===t.fillColorSpace.name||r.disableFontFace||this.options.disableFontFace)&&PartialEvaluator.buildFontPaths(r,i,this.handler)}return i}ensureStateFont(e){if(e.font)return;const t=new a.FormatError("Missing setFont (Tf) operator before text rendering operator.");if(!this.options.ignoreErrors)throw t;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontState});(0,a.warn)(`ensureStateFont: "${t}".`)}async setGState({resources:e,gState:t,operatorList:r,cacheKey:i,task:s,stateManager:o,localGStateCache:c,localColorSpaceCache:l}){const h=t.objId;let u=!0;for(var d=[],f=t.getKeys(),g=Promise.resolve(),m=0,p=f.length;mthis.handleSetFont(e,null,c[0],r,s,o.state).then((function(e){r.addDependency(e);d.push([i,[e,c[1]]])})));break;case"BM":d.push([i,normalizeBlendMode(c)]);break;case"SMask":if((0,n.isName)(c,"None")){d.push([i,!1]);break}if((0,n.isDict)(c)){u=!1;g=g.then(()=>this.handleSMask(c,e,r,s,o,l));d.push([i,!0])}else(0,a.warn)("Unsupported SMask type");break;case"TR":const t=this.handleTransferFunction(c);d.push([i,t]);break;case"OP":case"op":case"OPM":case"BG":case"BG2":case"UCR":case"UCR2":case"TR2":case"HT":case"SM":case"SA":case"AIS":case"TK":(0,a.info)("graphic state operator "+i);break;default:(0,a.info)("Unknown graphic state operator "+i)}}return g.then((function(){d.length>0&&r.addOp(a.OPS.setGState,[d]);u&&c.set(i,h,d)}))}loadFont(e,t,r){const errorFont=()=>Promise.resolve(new TranslatedFont({loadedName:"g_font_error",font:new s.ErrorFont(`Font "${e}" is not available.`),dict:t,extraProperties:this.options.fontExtraProperties}));var i,o=this.xref;if(t){if(!(0,n.isRef)(t))throw new a.FormatError('The "font" object should be a reference.');i=t}else{var c=r.get("Font");c&&(i=c.getRaw(e))}if(!i){const r=`Font "${e||t&&t.toString()}" is not available`;if(!this.options.ignoreErrors&&!this.parsingType3Font){(0,a.warn)(r+".");return errorFont()}this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontMissing});(0,a.warn)(r+" -- attempting to fallback to a default font.");i=PartialEvaluator.fallbackFontDict}if(this.fontCache.has(i))return this.fontCache.get(i);t=o.fetchIfRef(i);if(!(0,n.isDict)(t))return errorFont();if(t.translated)return t.translated;var l=(0,a.createPromiseCapability)(),h=this.preEvaluateFont(t);const{descriptor:u,hash:d}=h;var f,g,m=(0,n.isRef)(i);m&&(f="f"+i.toString());if(d&&(0,n.isDict)(u)){u.fontAliases||(u.fontAliases=Object.create(null));var p=u.fontAliases;if(p[d]){var b=p[d].aliasRef;if(m&&b&&this.fontCache.has(b)){this.fontCache.putAlias(i,b);return this.fontCache.get(i)}}else p[d]={fontID:this.idFactory.createFontId()};m&&(p[d].aliasRef=i);f=p[d].fontID}if(m)this.fontCache.put(i,l.promise);else{f||(f=this.idFactory.createFontId());this.fontCache.put("id_"+f,l.promise)}(0,a.assert)(f&&f.startsWith("f"),'The "fontID" must be (correctly) defined.');t.loadedName=`${this.idFactory.getDocId()}_${f}`;t.translated=l.promise;try{g=this.translateFont(h)}catch(e){g=Promise.reject(e)}g.then(e=>{if(void 0!==e.fontType){o.stats.fontTypes[e.fontType]=!0}l.resolve(new TranslatedFont({loadedName:t.loadedName,font:e,dict:t,extraProperties:this.options.fontExtraProperties}))}).catch(e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontTranslate});try{var r=u&&u.get("FontFile3"),i=r&&r.get("Subtype"),n=(0,s.getFontType)(h.type,i&&i.name);o.stats.fontTypes[n]=!0}catch(e){}l.resolve(new TranslatedFont({loadedName:t.loadedName,font:new s.ErrorFont(e instanceof Error?e.message:e),dict:t,extraProperties:this.options.fontExtraProperties}))});return l.promise}buildPath(e,t,r,i=!1){var n=e.length-1;r||(r=[]);if(n<0||e.fnArray[n]!==a.OPS.constructPath){if(i){(0,a.warn)(`Encountered path operator "${t}" inside of a text object.`);e.addOp(a.OPS.save,null)}e.addOp(a.OPS.constructPath,[[t],r]);i&&e.addOp(a.OPS.restore,null)}else{var s=e.argsArray[n];s[0].push(t);Array.prototype.push.apply(s[1],r)}}parseColorSpace({cs:e,resources:t,localColorSpaceCache:r}){return p.ColorSpace.parseAsync({cs:e,xref:this.xref,resources:t,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:r}).catch(e=>{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors){this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorColorSpace});(0,a.warn)(`parseColorSpace - ignoring ColorSpace: "${e}".`);return null}throw e})}async handleColorN(e,t,r,i,s,o,c,l){var h,d=r[r.length-1];if((0,n.isName)(d)&&(h=s.get(d.name))){var f=(0,n.isStream)(h)?h.dict:h,g=f.get("PatternType");if(g===x){var m=i.base?i.base.getRgb(r,0):null;return this.handleTilingType(t,m,o,h,f,e,c)}if(g===A){var p=f.get("Shading"),b=f.getArray("Matrix");h=u.Pattern.parseShading(p,b,this.xref,o,this.handler,this._pdfFunctionFactory,l);e.addOp(t,h.getIR());return}throw new a.FormatError("Unknown PatternType: "+g)}throw new a.FormatError("Unknown PatternName: "+d)}async parseMarkedContentProps(e,t){let r;if((0,n.isName)(e)){r=t.get("Properties").get(e.name)}else{if(!(0,n.isDict)(e))throw new a.FormatError("Optional content properties malformed.");r=e}const i=r.get("Type").name;if("OCG"===i)return{type:i,id:r.objId};if("OCMD"===i){const e=r.get("OCGs");if(Array.isArray(e)||(0,n.isDict)(e)){const t=[];Array.isArray(e)?r.get("OCGs").forEach(e=>{t.push(e.toString())}):t.push(e.objId);let a=null;r.get("VE")&&(a=!0);return{type:i,ids:t,policy:(0,n.isName)(r.get("P"))?r.get("P").name:null,expression:a}}if((0,n.isRef)(e))return{type:i,id:e.toString()}}return null}getOperatorList({stream:e,task:t,resources:r,operatorList:i,initialState:s=null}){r=r||n.Dict.empty;s=s||new EvalState;if(!i)throw new Error('getOperatorList: missing "operatorList" parameter');var o=this,c=this.xref;let l=!1;const h=new g.LocalImageCache,d=new g.LocalColorSpaceCache,f=new g.LocalGStateCache;var m=r.get("XObject")||n.Dict.empty,b=r.get("Pattern")||n.Dict.empty,y=new StateManager(s),v=new EvaluatorPreprocessor(e,c,y),w=new TimeSlotManager;function closePendingRestoreOPS(e){for(var t=0,r=v.savedStatesDepth;t0&&i.addOp(a.OPS.setGState,[e]);I=null;continue}}next(new Promise((function(e,s){if(!x)throw new a.FormatError("GState must be referred to by name.");const c=r.get("ExtGState");if(!(c instanceof n.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const l=c.get(x);if(!(l instanceof n.Dict))throw new a.FormatError("GState should be a dictionary.");o.setGState({resources:r,gState:l,operatorList:i,cacheKey:x,task:t,stateManager:y,localGStateCache:f,localColorSpaceCache:d}).then(e,s)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!o.options.ignoreErrors)throw e;o.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorExtGState});(0,a.warn)(`getOperatorList - ignoring ExtGState: "${e}".`)}})));return;case a.OPS.moveTo:case a.OPS.lineTo:case a.OPS.curveTo:case a.OPS.curveTo2:case a.OPS.curveTo3:case a.OPS.closePath:case a.OPS.rectangle:o.buildPath(i,F,I,l);continue;case a.OPS.markPoint:case a.OPS.markPointProps:case a.OPS.beginCompat:case a.OPS.endCompat:continue;case a.OPS.beginMarkedContentProps:if(!(0,n.isName)(I[0])){(0,a.warn)("Expected name for beginMarkedContentProps arg0="+I[0]);continue}if("OC"===I[0].name){next(o.parseMarkedContentProps(I[1],r).then(e=>{i.addOp(a.OPS.beginMarkedContentProps,["OC",e])}).catch(e=>{if(!(e instanceof a.AbortException)){if(!o.options.ignoreErrors)throw e;o.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorMarkedContent});(0,a.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${e}".`)}}));return}I=[I[0].name];break;case a.OPS.beginMarkedContent:case a.OPS.endMarkedContent:default:if(null!==I){for(k=0,S=I.length;k{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList});(0,a.warn)(`getOperatorList - ignoring errors during "${t.name}" task: "${e}".`);closePendingRestoreOPS()}})}getTextContent({stream:e,task:t,resources:r,stateManager:i=null,normalizeWhitespace:s=!1,combineTextItems:o=!1,sink:c,seenStyles:h=Object.create(null)}){r=r||n.Dict.empty;i=i||new StateManager(new TextState);var u=/\s/g,d={items:[],styles:Object.create(null)},f={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},p=this,b=this.xref,y=null;const v=new g.LocalImageCache,w=new g.LocalGStateCache;var k,S=new EvaluatorPreprocessor(e,b,i);function ensureTextContentItem(){if(f.initialized)return f;var e=k.font;if(!(e.loadedName in h)){h[e.loadedName]=!0;d.styles[e.loadedName]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:e.vertical}}f.fontName=e.loadedName;var t=[k.fontSize*k.textHScale,0,0,k.fontSize,0,k.textRise];if(e.isType3Font&&k.fontSize<=1&&!(0,a.isArrayEqual)(k.fontMatrix,a.FONT_IDENTITY_MATRIX)){const r=e.bbox[3]-e.bbox[1];r>0&&(t[3]*=r*k.fontMatrix[3])}var r=a.Util.transform(k.ctm,a.Util.transform(k.textMatrix,t));f.transform=r;if(e.vertical){f.width=Math.sqrt(r[0]*r[0]+r[1]*r[1]);f.height=0;f.vertical=!0}else{f.width=0;f.height=Math.sqrt(r[2]*r[2]+r[3]*r[3]);f.vertical=!1}var i=k.textLineMatrix[0],n=k.textLineMatrix[1],s=Math.sqrt(i*i+n*n);i=k.ctm[0];n=k.ctm[1];var o=Math.sqrt(i*i+n*n);f.textAdvanceScale=o*s;f.lastAdvanceWidth=0;f.lastAdvanceHeight=0;var c=e.spaceWidth/1e3*k.fontSize;if(c){f.spaceWidth=c;f.fakeSpaceMin=.3*c;f.fakeMultiSpaceMin=1.5*c;f.fakeMultiSpaceMax=4*c;f.textRunBreakAllowed=!e.isMonospace}else{f.spaceWidth=0;f.fakeSpaceMin=1/0;f.fakeMultiSpaceMin=1/0;f.fakeMultiSpaceMax=0;f.textRunBreakAllowed=!1}f.initialized=!0;return f}function replaceWhitespace(e){for(var t,r=0,a=e.length;r=32&&t<=127;)r++;return r0&&addFakeSpaces(f,r.str)}var g=0,m=0;if(t.vertical){i+=m=c*k.fontMatrix[0]*k.fontSize+d}else{a+=g=(c*k.fontMatrix[0]*k.fontSize+d)*k.textHScale}k.translateTextMatrix(g,m);r.str.push(h)}if(t.vertical){r.lastAdvanceHeight=i;r.height+=Math.abs(i)}else{r.lastAdvanceWidth=a;r.width+=a}return r}function addFakeSpaces(e,t){if(!(e0;)t.push(" ")}function flushTextContentItem(){if(f.initialized){f.vertical?f.height*=f.textAdvanceScale:f.width*=f.textAdvanceScale;d.items.push(function runBidiTransform(e){var t=e.str.join(""),r=(0,m.bidi)(t,-1,e.vertical);return{str:s?replaceWhitespace(r.str):r.str,dir:r.dir,width:e.width,height:e.height,transform:e.transform,fontName:e.fontName}}(f));f.initialized=!1;f.str.length=0}}function enqueueChunk(){const e=d.items.length;if(e>0){c.enqueue(d,e);d.items=[];d.styles=Object.create(null)}}var C=new TimeSlotManager;return new Promise((function promiseBody(e,l){const next=function(t){enqueueChunk();Promise.all([t,c.ready]).then((function(){try{promiseBody(e,l)}catch(e){l(e)}}),l)};t.ensureNotTerminated();C.reset();for(var u,g={},m=[];!(u=C.check());){m.length=0;g.args=m;if(!S.read(g))break;k=i.state;var x,A=g.fn;m=g.args;switch(0|A){case a.OPS.setFont:var I=m[0].name,F=m[1];if(k.font&&I===k.fontName&&F===k.fontSize)break;flushTextContentItem();k.fontName=I;k.fontSize=F;next(handleSetFont(I,null));return;case a.OPS.setTextRise:flushTextContentItem();k.textRise=m[0];break;case a.OPS.setHScale:flushTextContentItem();k.textHScale=m[0]/100;break;case a.OPS.setLeading:flushTextContentItem();k.leading=m[0];break;case a.OPS.moveText:var P=!!k.font&&0===(k.font.vertical?m[0]:m[1]);x=m[0]-m[1];if(o&&P&&f.initialized&&x>0&&x<=f.fakeMultiSpaceMax){k.translateTextLineMatrix(m[0],m[1]);f.width+=m[0]-f.lastAdvanceWidth;f.height+=m[1]-f.lastAdvanceHeight;addFakeSpaces(m[0]-f.lastAdvanceWidth-(m[1]-f.lastAdvanceHeight),f.str);break}flushTextContentItem();k.translateTextLineMatrix(m[0],m[1]);k.textMatrix=k.textLineMatrix.slice();break;case a.OPS.setLeadingMoveText:flushTextContentItem();k.leading=-m[1];k.translateTextLineMatrix(m[0],m[1]);k.textMatrix=k.textLineMatrix.slice();break;case a.OPS.nextLine:flushTextContentItem();k.carriageReturn();break;case a.OPS.setTextMatrix:x=k.calcTextLineMatrixAdvance(m[0],m[1],m[2],m[3],m[4],m[5]);if(o&&null!==x&&f.initialized&&x.value>0&&x.value<=f.fakeMultiSpaceMax){k.translateTextLineMatrix(x.width,x.height);f.width+=x.width-f.lastAdvanceWidth;f.height+=x.height-f.lastAdvanceHeight;addFakeSpaces(x.width-f.lastAdvanceWidth-(x.height-f.lastAdvanceHeight),f.str);break}flushTextContentItem();k.setTextMatrix(m[0],m[1],m[2],m[3],m[4],m[5]);k.setTextLineMatrix(m[0],m[1],m[2],m[3],m[4],m[5]);break;case a.OPS.setCharSpacing:k.charSpacing=m[0];break;case a.OPS.setWordSpacing:k.wordSpacing=m[0];break;case a.OPS.beginText:flushTextContentItem();k.textMatrix=a.IDENTITY_MATRIX.slice();k.textLineMatrix=a.IDENTITY_MATRIX.slice();break;case a.OPS.showSpacedText:if(!i.state.font){p.ensureStateFont(i.state);continue}for(var E,B=m[0],O=0,M=B.length;Of.fakeMultiSpaceMax)||(f.height+=E)}else{E=(x=-x)*k.textHScale;k.translateTextMatrix(E,0);(D=f.textRunBreakAllowed&&x>f.fakeMultiSpaceMax)||(f.width+=E)}D?flushTextContentItem():x>0&&addFakeSpaces(x,f.str)}break;case a.OPS.showText:if(!i.state.font){p.ensureStateFont(i.state);continue}buildTextContentItem(m[0]);break;case a.OPS.nextLineShowText:if(!i.state.font){p.ensureStateFont(i.state);continue}flushTextContentItem();k.carriageReturn();buildTextContentItem(m[0]);break;case a.OPS.nextLineSetSpacingShowText:if(!i.state.font){p.ensureStateFont(i.state);continue}flushTextContentItem();k.wordSpacing=m[0];k.charSpacing=m[1];k.carriageReturn();buildTextContentItem(m[2]);break;case a.OPS.paintXObject:flushTextContentItem();y||(y=r.get("XObject")||n.Dict.empty);var R=m[0].name;if(R&&v.getByName(R))break;next(new Promise((function(e,l){if(!R)throw new a.FormatError("XObject must be referred to by name.");let u=y.getRaw(R);if(u instanceof n.Ref){if(v.getByRef(u)){e();return}u=b.fetch(u)}if(!(0,n.isStream)(u))throw new a.FormatError("XObject should be a stream");const d=u.dict.get("Subtype");if(!(0,n.isName)(d))throw new a.FormatError("XObject should have a Name subtype");if("Form"!==d.name){v.set(R,u.dict.objId,!0);e();return}const f=i.state.clone(),g=new StateManager(f),m=u.dict.getArray("Matrix");Array.isArray(m)&&6===m.length&&g.transform(m);enqueueChunk();const w={enqueueInvoked:!1,enqueue(e,t){this.enqueueInvoked=!0;c.enqueue(e,t)},get desiredSize(){return c.desiredSize},get ready(){return c.ready}};p.getTextContent({stream:u,task:t,resources:u.dict.get("Resources")||r,stateManager:g,normalizeWhitespace:s,combineTextItems:o,sink:w,seenStyles:h}).then((function(){w.enqueueInvoked||v.set(R,u.dict.objId,!0);e()}),l)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!p.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring XObject: "${e}".`)}})));return;case a.OPS.setGState:if((R=m[0].name)&&w.getByName(R))break;next(new Promise((function(e,t){if(!R)throw new a.FormatError("GState must be referred to by name.");const i=r.get("ExtGState");if(!(i instanceof n.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const s=i.get(R);if(!(s instanceof n.Dict))throw new a.FormatError("GState should be a dictionary.");const o=s.get("Font");if(o){flushTextContentItem();k.fontName=null;k.fontSize=o[1];handleSetFont(null,o[0]).then(e,t)}else{w.set(R,s.objId,!0);e()}})).catch((function(e){if(!(e instanceof a.AbortException)){if(!p.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring ExtGState: "${e}".`)}})));return}if(d.items.length>=c.desiredSize){u=!0;break}}if(u)next(T);else{flushTextContentItem();enqueueChunk();e()}})).catch(e=>{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring errors during "${t.name}" task: "${e}".`);flushTextContentItem();enqueueChunk()}})}extractDataStructures(e,t,r){const i=this.xref;let c;var l=e.get("ToUnicode")||t.get("ToUnicode"),h=l?this.readToUnicode(l):Promise.resolve(void 0);if(r.composite){var u=e.get("CIDSystemInfo");(0,n.isDict)(u)&&(r.cidSystemInfo={registry:(0,a.stringToPDFString)(u.get("Registry")),ordering:(0,a.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")){f=e.get("Encoding");if((0,n.isDict)(f)){m=f.get("BaseEncoding");m=(0,n.isName)(m)?m.name:null;if(f.has("Differences"))for(var p=f.get("Differences"),b=0,y=0,v=p.length;y0;r.dict=e;return h.then(e=>{r.toUnicode=e;return this.buildToUnicode(r)}).then(e=>{r.toUnicode=e;c&&(r.cidToGidMap=this.readCidToGidMap(c,e));return r})}_buildSimpleFontToUnicode(e,t=!1){(0,a.assert)(!e.composite,"Must be a simple font.");const r=[],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,y.getGlyphsUnicode)();for(const a in i){let s=i[a];if(""!==s)if(void 0!==h[s])r[a]=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 r=s.substring(1);if(t){i=parseInt(r,16);break}i=+r;if(Number.isNaN(i)&&Number.isInteger(parseInt(r,16)))return this._buildSimpleFontToUnicode(e,!0)}break;default:const r=(0,l.getUnicodeForGlyph)(s,h);-1!==r&&(i=r)}if(i>0&&i<=1114111&&Number.isInteger(i)){if(n&&i===+a){const e=(0,o.getEncoding)(n);if(e&&(s=e[a])){r[a]=String.fromCharCode(h[s]);continue}}r[a]=String.fromCodePoint(i)}}}return new s.ToUnicodeMap(r)}buildToUnicode(e){e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0;if(e.hasIncludedToUnicodeMap){!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._buildSimpleFontToUnicode(e));return 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,r=e.cidSystemInfo.ordering,o=n.Name.get(t+"-"+r+"-UCS2");return i.CMapFactory.create({encoding:o,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(t){const r=e.cMap,i=[];r.forEach((function(e,r){if(r>65535)throw new a.FormatError("Max size of CID is 65,535");const n=t.lookup(r);n&&(i[e]=String.fromCharCode((n.charCodeAt(0)<<8)+n.charCodeAt(1)))}));return new s.ToUnicodeMap(i)}))}return Promise.resolve(new s.IdentityToUnicodeMap(e.firstChar,e.lastChar))}readToUnicode(e){var t=e;return(0,n.isName)(t)?i.CMapFactory.create({encoding:t,fetchBuiltInCMap:this._fetchBuiltInCMapBound,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._fetchBuiltInCMapBound,useCMap:null}).then((function(e){if(e instanceof i.IdentityCMap)return new s.IdentityToUnicodeMap(0,65535);var t=new Array(e.length);e.forEach((function(e,r){for(var a=[],i=0;i{if(e instanceof a.AbortException)return null;if(this.options.ignoreErrors){this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontToUnicode});(0,a.warn)(`readToUnicode - ignoring ToUnicode data: "${e}".`);return null}throw e}):Promise.resolve(null)}readCidToGidMap(e,t){for(var r=[],a=0,i=e.length;a>1;(0!==n||t.has(i))&&(r[i]=n)}return r}extractWidths(e,t,r){var a,i,o,c,l,h,u,d,f=this.xref,g=[],m=0,p=[];if(r.composite){m=e.has("DW")?e.get("DW"):1e3;if(d=e.get("W"))for(i=0,o=d.length;i{if(e){const r=[];let a=f;for(let t=0,i=e.length;tthis.extractDataStructures(o,r,t)).then(e=>{this.extractWidths(o,l,e);"Type3"===u&&(e.isType3Font=!0);return new s.Font(v.name,x,e)})}static buildFontPaths(e,t,r){function buildPath(t){e.renderer.hasBuiltPath(t)||r.send("commonobj",[`${e.loadedName}_path_${t}`,"FontPath",e.renderer.getPathJs(t)])}for(const e of t){buildPath(e.fontChar);const t=e.accent;t&&t.fontChar&&buildPath(t.fontChar)}}static get fallbackFontDict(){const e=new n.Dict;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"));return(0,a.shadow)(this,"fallbackFontDict",e)}}t.PartialEvaluator=PartialEvaluator;class TranslatedFont{constructor({loadedName:e,font:t,dict:r,extraProperties:a=!1}){this.loadedName=e;this.font=t;this.dict=r;this._extraProperties=a;this.type3Loaded=null;this.type3Dependencies=t.isType3Font?new Set:null;this.sent=!1}send(e){if(!this.sent){this.sent=!0;e.send("commonobj",[this.loadedName,"Font",this.font.exportData(this._extraProperties)])}}fallback(e){if(!this.font.data)return;this.font.disableFontFace=!0;const t=this.font.glyphCacheValues;PartialEvaluator.buildFontPaths(this.font,t,e)}loadType3Data(e,t,r){if(this.type3Loaded)return this.type3Loaded;if(!this.font.isType3Font)throw new Error("Must be a Type3 font.");var i=Object.create(e.options);i.ignoreErrors=!1;var n=e.clone(i);n.parsingType3Font=!0;const s=this.font,o=this.type3Dependencies;var c=Promise.resolve(),l=this.dict.get("CharProcs"),h=this.dict.get("Resources")||t,u=Object.create(null);for(const e of l.getKeys())c=c.then((function(){var t=l.get(e),i=new k.OperatorList;return n.getOperatorList({stream:t,task:r,resources:h,operatorList:i}).then((function(){u[e]=i.getIR();for(const e of i.dependencies)o.add(e)})).catch((function(t){(0,a.warn)(`Type3 font resource "${e}" is not available.`);const r=new k.OperatorList;u[e]=r.getIR()}))}));this.type3Loaded=c.then((function(){s.charProcOperatorList=u}));return this.type3Loaded}}class StateManager{constructor(e){this.state=e;this.stateStack=[]}save(){var e=this.state;this.stateStack.push(this.state);this.state=e.clone()}restore(){var e=this.stateStack.pop();e&&(this.state=e)}transform(e){this.state.ctm=a.Util.transform(this.state.ctm,e)}}class TextState{constructor(){this.ctm=new Float32Array(a.IDENTITY_MATRIX);this.fontName=null;this.fontSize=0;this.font=null;this.fontMatrix=a.FONT_IDENTITY_MATRIX;this.textMatrix=a.IDENTITY_MATRIX.slice();this.textLineMatrix=a.IDENTITY_MATRIX.slice();this.charSpacing=0;this.wordSpacing=0;this.leading=0;this.textHScale=1;this.textRise=0}setTextMatrix(e,t,r,a,i,n){var s=this.textMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=i;s[5]=n}setTextLineMatrix(e,t,r,a,i,n){var s=this.textLineMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=i;s[5]=n}translateTextMatrix(e,t){var r=this.textMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5]}translateTextLineMatrix(e,t){var r=this.textLineMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5]}calcTextLineMatrixAdvance(e,t,r,a,i,n){var s=this.font;if(!s)return null;var o=this.textLineMatrix;if(e!==o[0]||t!==o[1]||r!==o[2]||a!==o[3])return null;var c=i-o[4],l=n-o[5];if(s.vertical&&0!==c||!s.vertical&&0!==l)return null;var h,u,d=e*a-t*r;if(s.vertical){h=-l*r/d;u=l*e/d}else{h=c*a/d;u=-c*t/d}return{width:h,height:u,value:s.vertical?u:h}}calcRenderMatrix(e){var t=[this.fontSize*this.textHScale,0,0,this.fontSize,0,this.textRise];return a.Util.transform(e,a.Util.transform(this.textMatrix,t))}carriageReturn(){this.translateTextLineMatrix(0,-this.leading);this.textMatrix=this.textLineMatrix.slice()}clone(){var e=Object.create(this);e.textMatrix=this.textMatrix.slice();e.textLineMatrix=this.textLineMatrix.slice();e.fontMatrix=this.fontMatrix.slice();return e}}class EvalState{constructor(){this.ctm=new Float32Array(a.IDENTITY_MATRIX);this.font=null;this.textRenderingMode=a.TextRenderingMode.FILL;this.fillColorSpace=p.ColorSpace.singletons.gray;this.strokeColorSpace=p.ColorSpace.singletons.gray}clone(){return Object.create(this)}}class EvaluatorPreprocessor{static get opMap(){const e=(0,c.getLookupTableFactory)((function(e){e.w={id:a.OPS.setLineWidth,numArgs:1,variableArgs:!1};e.J={id:a.OPS.setLineCap,numArgs:1,variableArgs:!1};e.j={id:a.OPS.setLineJoin,numArgs:1,variableArgs:!1};e.M={id:a.OPS.setMiterLimit,numArgs:1,variableArgs:!1};e.d={id:a.OPS.setDash,numArgs:2,variableArgs:!1};e.ri={id:a.OPS.setRenderingIntent,numArgs:1,variableArgs:!1};e.i={id:a.OPS.setFlatness,numArgs:1,variableArgs:!1};e.gs={id:a.OPS.setGState,numArgs:1,variableArgs:!1};e.q={id:a.OPS.save,numArgs:0,variableArgs:!1};e.Q={id:a.OPS.restore,numArgs:0,variableArgs:!1};e.cm={id:a.OPS.transform,numArgs:6,variableArgs:!1};e.m={id:a.OPS.moveTo,numArgs:2,variableArgs:!1};e.l={id:a.OPS.lineTo,numArgs:2,variableArgs:!1};e.c={id:a.OPS.curveTo,numArgs:6,variableArgs:!1};e.v={id:a.OPS.curveTo2,numArgs:4,variableArgs:!1};e.y={id:a.OPS.curveTo3,numArgs:4,variableArgs:!1};e.h={id:a.OPS.closePath,numArgs:0,variableArgs:!1};e.re={id:a.OPS.rectangle,numArgs:4,variableArgs:!1};e.S={id:a.OPS.stroke,numArgs:0,variableArgs:!1};e.s={id:a.OPS.closeStroke,numArgs:0,variableArgs:!1};e.f={id:a.OPS.fill,numArgs:0,variableArgs:!1};e.F={id:a.OPS.fill,numArgs:0,variableArgs:!1};e["f*"]={id:a.OPS.eoFill,numArgs:0,variableArgs:!1};e.B={id:a.OPS.fillStroke,numArgs:0,variableArgs:!1};e["B*"]={id:a.OPS.eoFillStroke,numArgs:0,variableArgs:!1};e.b={id:a.OPS.closeFillStroke,numArgs:0,variableArgs:!1};e["b*"]={id:a.OPS.closeEOFillStroke,numArgs:0,variableArgs:!1};e.n={id:a.OPS.endPath,numArgs:0,variableArgs:!1};e.W={id:a.OPS.clip,numArgs:0,variableArgs:!1};e["W*"]={id:a.OPS.eoClip,numArgs:0,variableArgs:!1};e.BT={id:a.OPS.beginText,numArgs:0,variableArgs:!1};e.ET={id:a.OPS.endText,numArgs:0,variableArgs:!1};e.Tc={id:a.OPS.setCharSpacing,numArgs:1,variableArgs:!1};e.Tw={id:a.OPS.setWordSpacing,numArgs:1,variableArgs:!1};e.Tz={id:a.OPS.setHScale,numArgs:1,variableArgs:!1};e.TL={id:a.OPS.setLeading,numArgs:1,variableArgs:!1};e.Tf={id:a.OPS.setFont,numArgs:2,variableArgs:!1};e.Tr={id:a.OPS.setTextRenderingMode,numArgs:1,variableArgs:!1};e.Ts={id:a.OPS.setTextRise,numArgs:1,variableArgs:!1};e.Td={id:a.OPS.moveText,numArgs:2,variableArgs:!1};e.TD={id:a.OPS.setLeadingMoveText,numArgs:2,variableArgs:!1};e.Tm={id:a.OPS.setTextMatrix,numArgs:6,variableArgs:!1};e["T*"]={id:a.OPS.nextLine,numArgs:0,variableArgs:!1};e.Tj={id:a.OPS.showText,numArgs:1,variableArgs:!1};e.TJ={id:a.OPS.showSpacedText,numArgs:1,variableArgs:!1};e["'"]={id:a.OPS.nextLineShowText,numArgs:1,variableArgs:!1};e['"']={id:a.OPS.nextLineSetSpacingShowText,numArgs:3,variableArgs:!1};e.d0={id:a.OPS.setCharWidth,numArgs:2,variableArgs:!1};e.d1={id:a.OPS.setCharWidthAndBounds,numArgs:6,variableArgs:!1};e.CS={id:a.OPS.setStrokeColorSpace,numArgs:1,variableArgs:!1};e.cs={id:a.OPS.setFillColorSpace,numArgs:1,variableArgs:!1};e.SC={id:a.OPS.setStrokeColor,numArgs:4,variableArgs:!0};e.SCN={id:a.OPS.setStrokeColorN,numArgs:33,variableArgs:!0};e.sc={id:a.OPS.setFillColor,numArgs:4,variableArgs:!0};e.scn={id:a.OPS.setFillColorN,numArgs:33,variableArgs:!0};e.G={id:a.OPS.setStrokeGray,numArgs:1,variableArgs:!1};e.g={id:a.OPS.setFillGray,numArgs:1,variableArgs:!1};e.RG={id:a.OPS.setStrokeRGBColor,numArgs:3,variableArgs:!1};e.rg={id:a.OPS.setFillRGBColor,numArgs:3,variableArgs:!1};e.K={id:a.OPS.setStrokeCMYKColor,numArgs:4,variableArgs:!1};e.k={id:a.OPS.setFillCMYKColor,numArgs:4,variableArgs:!1};e.sh={id:a.OPS.shadingFill,numArgs:1,variableArgs:!1};e.BI={id:a.OPS.beginInlineImage,numArgs:0,variableArgs:!1};e.ID={id:a.OPS.beginImageData,numArgs:0,variableArgs:!1};e.EI={id:a.OPS.endInlineImage,numArgs:1,variableArgs:!1};e.Do={id:a.OPS.paintXObject,numArgs:1,variableArgs:!1};e.MP={id:a.OPS.markPoint,numArgs:1,variableArgs:!1};e.DP={id:a.OPS.markPointProps,numArgs:2,variableArgs:!1};e.BMC={id:a.OPS.beginMarkedContent,numArgs:1,variableArgs:!1};e.BDC={id:a.OPS.beginMarkedContentProps,numArgs:2,variableArgs:!1};e.EMC={id:a.OPS.endMarkedContent,numArgs:0,variableArgs:!1};e.BX={id:a.OPS.beginCompat,numArgs:0,variableArgs:!1};e.EX={id:a.OPS.endCompat,numArgs:0,variableArgs:!1};e.BM=null;e.BD=null;e.true=null;e.fa=null;e.fal=null;e.fals=null;e.false=null;e.nu=null;e.nul=null;e.null=null}));return(0,a.shadow)(this,"opMap",e())}static get MAX_INVALID_PATH_OPS(){return(0,a.shadow)(this,"MAX_INVALID_PATH_OPS",20)}constructor(e,t,r){this.parser=new f.Parser({lexer:new f.Lexer(e,EvaluatorPreprocessor.opMap),xref:t});this.stateManager=r;this.nonProcessedArgs=[];this._numInvalidPathOPS=0}get savedStatesDepth(){return this.stateManager.stateStack.length}read(e){for(var t=e.args;;){var r=this.parser.getObj();if(r instanceof n.Cmd){var i=r.cmd,s=EvaluatorPreprocessor.opMap[i];if(!s){(0,a.warn)(`Unknown command "${i}".`);continue}var o=s.id,c=s.numArgs,l=null!==t?t.length:0;if(s.variableArgs)l>c&&(0,a.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=a.OPS.moveTo&&o<=a.OPS.endPath&&++this._numInvalidPathOPS>EvaluatorPreprocessor.MAX_INVALID_PATH_OPS)throw new a.FormatError("Invalid "+e);(0,a.warn)("Skipping "+e);null!==t&&(t.length=0);continue}}this.preprocessCommand(o,t);e.fn=o;e.args=t;return!0}if(r===n.EOF)return!1;if(null!==r){null===t&&(t=[]);t.push(r);if(t.length>33)throw new a.FormatError("Too many arguments")}}}preprocessCommand(e,t){switch(0|e){case a.OPS.save:this.stateManager.save();break;case a.OPS.restore:this.stateManager.restore();break;case a.OPS.transform:this.stateManager.transform(t)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CMapFactory=t.IdentityCMap=t.CMap=void 0;var a=r(2),i=r(5),n=r(11),s=r(8),o=r(12),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 CMap{constructor(e=!1){this.codespaceRanges=[[],[],[],[]];this.numCodespaceRanges=0;this._map=[];this.name="";this.vertical=!1;this.useCMap=null;this.builtInCMap=e}addCodespaceRange(e,t,r){this.codespaceRanges[e-1].push(t,r);this.numCodespaceRanges++}mapCidRange(e,t,r){if(t-e>2**24-1)throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");for(;e<=t;)this._map[e++]=r++}mapBfRange(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");for(var a=r.length-1;e<=t;){this._map[e++]=r;r=r.substring(0,a)+String.fromCharCode(r.charCodeAt(a)+1)}}mapBfRangeToArray(e,t,r){if(t-e>2**24-1)throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");const a=r.length;let i=0;for(;e<=t&&i>>0;const s=i[n];for(let e=0,t=s.length;e=t&&a<=i){r.charcode=a;r.length=n+1;return}}}r.charcode=0;r.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=CMap;class IdentityCMap extends CMap{constructor(e,t){super();this.vertical=e;this.addCodespaceRange(t,0,65535)}mapCidRange(e,t,r){(0,a.unreachable)("should not call mapCidRange")}mapBfRange(e,t,r){(0,a.unreachable)("should not call mapBfRange")}mapBfRangeToArray(e,t,r){(0,a.unreachable)("should not call mapBfRangeToArray")}mapOne(e,t){(0,a.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,a.unreachable)("should not access .isIdentityCMap")}}t.IdentityCMap=IdentityCMap;var l=function BinaryCMapReaderClosure(){function hexToInt(e,t){for(var r=0,a=0;a<=t;a++)r=r<<8|e[a];return r>>>0}function hexToStr(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 addHex(e,t,r){for(var a=0,i=r;i>=0;i--){a+=e[i]+t[i];e[i]=255&a;a>>=8}}function incHex(e,t){for(var r=1,a=t;a>=0&&r>0;a--){r+=e[a];e[a]=255&r;r>>=8}}function BinaryCMapStream(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(19)}BinaryCMapStream.prototype={readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]},readNumber(){var e,t=0;do{var r=this.readByte();if(r<0)throw new a.FormatError("unexpected EOF in bcmap");e=!(128&r);t=t<<7|127&r}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 r,i=this.tmpBuf,n=0;do{var s=this.readByte();if(s<0)throw new a.FormatError("unexpected EOF in bcmap");r=!(128&s);i[n++]=127&s}while(!r);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 r=1&e[t]?255:0,a=0,i=0;i<=t;i++){a=(1&a)<<8|e[i];e[i]=a>>1^r}},readString(){for(var e=this.readNumber(),t="",r=0;r=0;){var m=c>>5;if(7!==m){var p=!!(16&c),b=15&c;if(b+1>16)throw new Error("processBinaryCMap: Invalid dataSize.");var y,v=n.readNumber();switch(m){case 0:n.readHex(h,b);n.readHexNumber(u,b);addHex(u,h,b);t.addCodespaceRange(b+1,hexToInt(h,b),hexToInt(u,b));for(y=1;y>>0}function expectString(e){if(!(0,a.isString)(e))throw new a.FormatError("Malformed CMap: expected string.")}function expectInt(e){if(!Number.isInteger(e))throw new a.FormatError("Malformed CMap: expected int.")}function parseBfChar(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endbfchar"))return;expectString(r);var a=strToInt(r);expectString(r=t.getObj());var n=r;e.mapOne(a,n)}}function parseBfRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endbfrange"))return;expectString(r);var n=strToInt(r);expectString(r=t.getObj());var s=strToInt(r);r=t.getObj();if(Number.isInteger(r)||(0,a.isString)(r)){var o=Number.isInteger(r)?String.fromCharCode(r):r;e.mapBfRange(n,s,o)}else{if(!(0,i.isCmd)(r,"["))break;r=t.getObj();for(var c=[];!(0,i.isCmd)(r,"]")&&!(0,i.isEOF)(r);){c.push(r);r=t.getObj()}e.mapBfRangeToArray(n,s,c)}}throw new a.FormatError("Invalid bf range.")}function parseCidChar(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcidchar"))return;expectString(r);var a=strToInt(r);expectInt(r=t.getObj());var n=r;e.mapOne(a,n)}}function parseCidRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcidrange"))return;expectString(r);var a=strToInt(r);expectString(r=t.getObj());var n=strToInt(r);expectInt(r=t.getObj());var s=r;e.mapCidRange(a,n,s)}}function parseCodespaceRange(e,t){for(;;){var r=t.getObj();if((0,i.isEOF)(r))break;if((0,i.isCmd)(r,"endcodespacerange"))return;if(!(0,a.isString)(r))break;var n=strToInt(r);r=t.getObj();if(!(0,a.isString)(r))break;var s=strToInt(r);e.addCodespaceRange(r.length,n,s)}throw new a.FormatError("Invalid codespace range.")}function parseWMode(e,t){var r=t.getObj();Number.isInteger(r)&&(e.vertical=!!r)}function parseCMapName(e,t){var r=t.getObj();(0,i.isName)(r)&&(0,a.isString)(r.name)&&(e.name=r.name)}function parseCMap(e,t,r,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?parseWMode(e,t):"CMapName"===l.name&&parseCMapName(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":parseCodespaceRange(e,t);break;case"beginbfchar":parseBfChar(e,t);break;case"begincidchar":parseCidChar(e,t);break;case"beginbfrange":parseBfRange(e,t);break;case"begincidrange":parseCidRange(e,t)}}catch(e){if(e instanceof s.MissingDataException)throw e;(0,a.warn)("Invalid cMap data: "+e);continue}!n&&c&&(n=c);return n?extendCMap(e,r,n):Promise.resolve(e)}function extendCMap(e,t,r){return createBuiltInCMap(r,t).then((function(t){e.useCMap=t;if(0===e.numCodespaceRanges){for(var r=e.useCMap.codespaceRanges,a=0;a=this.firstChar&&e<=this.lastChar?e:-1},amend(e){(0,a.unreachable)("Should not call amend()")}};return IdentityToUnicodeMap}();t.IdentityToUnicodeMap=k;var S=function OpenTypeFileBuilderClosure(){function writeInt16(e,t,r){e[t]=r>>8&255;e[t+1]=255&r}function writeInt32(e,t,r){e[t]=r>>24&255;e[t+1]=r>>16&255;e[t+2]=r>>8&255;e[t+3]=255&r}function writeData(e,t,r){var a,i;if(r instanceof Uint8Array)e.set(r,t);else if("string"==typeof r)for(a=0,i=r.length;ar;){r<<=1;a++}var i=r*t;return{range:i,entry:a,rangeShift:t*e-i}};OpenTypeFileBuilder.prototype={toArray:function OpenTypeFileBuilder_toArray(){var e=this.sfnt,t=this.tables,r=Object.keys(t);r.sort();var i,n,s,o,c,h=r.length,u=12+16*h,d=[u];for(i=0;i>>0;d.push(u)}var f=new Uint8Array(u);for(i=0;i>>0}writeInt32(f,u+4,m);writeInt32(f,u+8,d[i]);writeInt32(f,u+12,t[c].length);u+=16}return f},addTable:function OpenTypeFileBuilder_addTable(e,t){if(e in this.tables)throw new Error("Table "+e+" already exists");this.tables[e]=t}};return OpenTypeFileBuilder}(),C=function FontClosure(){function Font(e,t,r){var i;this.name=e;this.loadedName=r.loadedName;this.isType3Font=r.isType3Font;this.missingFile=!1;this.glyphCache=Object.create(null);this.isSerifFont=!!(r.flags&b.Serif);this.isSymbolicFont=!!(r.flags&b.Symbolic);this.isMonospace=!!(r.flags&b.FixedPitch);var n=r.type,s=r.subtype;this.type=n;this.subtype=s;let o="sans-serif";this.isMonospace?o="monospace":this.isSerifFont&&(o="serif");this.fallbackName=o;this.differences=r.differences;this.widths=r.widths;this.defaultWidth=r.defaultWidth;this.composite=r.composite;this.cMap=r.cMap;this.ascent=r.ascent/1e3;this.descent=r.descent/1e3;this.fontMatrix=r.fontMatrix;this.bbox=r.bbox;this.defaultEncoding=r.defaultEncoding;this.toUnicode=r.toUnicode;this.fallbackToUnicode=r.fallbackToUnicode||new w;this.toFontChar=[];if("Type3"!==r.type){this.cidEncoding=r.cidEncoding;this.vertical=!!r.vertical;if(this.vertical){this.vmetrics=r.vmetrics;this.defaultVMetrics=r.defaultVMetrics}if(t&&!t.isEmpty){[n,s]=function getFontFileType(e,{type:t,subtype:r,composite:i}){let n,s;if(function isTrueTypeFile(e){var t=e.peekBytes(4);return 65536===(0,l.readUint32)(t,0)||"true"===(0,a.bytesToString)(t)}(e)||isTrueTypeCollectionFile(e))n=i?"CIDFontType2":"TrueType";else if(function isOpenTypeFile(e){var t=e.peekBytes(4);return"OTTO"===(0,a.bytesToString)(t)}(e))n=i?"CIDFontType2":"OpenType";else if(function isType1File(e){var t=e.peekBytes(2);if(37===t[0]&&33===t[1])return!0;if(128===t[0]&&1===t[1])return!0;return!1}(e))n=i?"CIDFontType0":"MMType1"===t?"MMType1":"Type1";else if(function isCFFFile(e){const t=e.peekBytes(4);if(t[0]>=1&&t[3]>=1&&t[3]<=4)return!0;return!1}(e))if(i){n="CIDFontType0";s="CIDFontType0C"}else{n="MMType1"===t?"MMType1":"Type1";s="Type1C"}else{(0,a.warn)("getFontFileType: Unable to detect correct font file Type/Subtype.");n=t;s=r}return[n,s]}(t,r);n===this.type&&s===this.subtype||(0,a.info)(`Inconsistent font file Type/SubType, expected: ${this.type}/${this.subtype} but found: ${n}/${s}.`);try{var c;switch(n){case"MMType1":(0,a.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,r):new A(e,t,r);adjustWidths(r);c=this.convert(e,h,r);break;case"OpenType":case"TrueType":case"CIDFontType2":this.mimetype="font/opentype";c=this.checkAndRepair(e,t,r);if(this.isOpenType){adjustWidths(r);n="OpenType"}break;default:throw new a.FormatError(`Font ${n} is not supported`)}}catch(e){(0,a.warn)(e);this.fallbackToSystemFont();return}this.data=c;this.fontType=getFontType(n,s);this.fontMatrix=r.fontMatrix;this.widths=r.widths;this.defaultWidth=r.defaultWidth;this.toUnicode=r.toUnicode;this.seacMap=r.seacMap}else{t&&(0,a.warn)('Font file is empty in "'+e+'" ('+this.loadedName+")");this.fallbackToSystemFont()}}else{for(i=0;i<256;i++)this.toFontChar[i]=this.differences[i]||r.defaultEncoding[i];this.fontType=a.FontType.TYPE3}}function int16(e,t){return(e<<8)+t}function signedInt16(e,t){var r=(e<<8)+t;return 32768&r?r-65536:r}function string16(e){return String.fromCharCode(e>>8&255,255&e)}function safeString16(e){e>32767?e=32767:e<-32768&&(e=-32768);return String.fromCharCode(e>>8&255,255&e)}function isTrueTypeCollectionFile(e){const t=e.peekBytes(4);return"ttcf"===(0,a.bytesToString)(t)}function buildToFontChar(e,t,r){for(var a,i=[],n=0,s=e.length;nc){if(++s>=g.length){(0,a.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=r);i[u]=h;n[l]=u}}return{toFontChar:n,charCodeToGlyphId:i,nextAvailableFontCharCode:o}}function createCmapTable(e,t){var r,i,n,s,o=function getRanges(e,t){var r=[];for(var a in e)e[a]>=t||r.push({fontCharCode:0|a,glyphId:e[a]});0===r.length&&r.push({fontCharCode:0,glyphId:0});r.sort((function fontGetRangesSort(e,t){return e.fontCharCode-t.fontCharCode}));for(var i=[],n=r.length,s=0;s65535?2:1,l="\0\0"+string16(c)+"\0\0"+(0,a.string32)(4+8*c);for(r=o.length-1;r>=0&&!(o[r][0]<=65535);--r);var h=r+1;o[r][0]<65535&&65535===o[r][1]&&(o[r][1]=65534);var u,d,f,g,m=o[r][1]<65535?1:0,p=h+m,b=S.getSearchParams(p,2),y="",v="",w="",k="",C="",x=0;for(r=0,i=h;r0){v+="ÿÿ";y+="ÿÿ";w+="\0";k+="\0\0"}var I="\0\0"+string16(2*p)+string16(b.range)+string16(b.entry)+string16(b.rangeShift)+v+"\0\0"+y+w+k+C,F="",P="";if(c>1){l+="\0\0\n"+(0,a.string32)(4+8*c+4+I.length);F="";for(r=0,i=o.length;r(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=r.unitsPerEm||1/(e.fontMatrix||a.FONT_IDENTITY_MATRIX)[0],m=e.ascentScaled?1:g/1e3,p=r.ascent||Math.round(m*(e.ascent||f[3])),b=r.descent||Math.round(m*(e.descent||f[1]));b>0&&e.descent>0&&f[1]<0&&(b=-b);var y=r.yMax||p,v=-r.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,a.string32)(i)+(0,a.string32)(n)+(0,a.string32)(s)+(0,a.string32)(o)+"*21*"+string16(e.italicAngle?1:0)+string16(l||e.firstChar)+string16(h||e.lastChar)+string16(p)+string16(b)+"\0d"+string16(y)+string16(v)+"\0\0\0\0\0\0\0\0"+string16(e.xHeight)+string16(e.capHeight)+string16(0)+string16(l||e.firstChar)+"\0"}function createPostTable(e){var t=Math.floor(65536*e.italicAngle);return"\0\0\0"+(0,a.string32)(t)+"\0\0\0\0"+(0,a.string32)(e.fixedPitch)+"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}function createNameTable(e,t){t||(t=[[],[]]);var r,a,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(r=0,a=o.length;r0;if(u&&"CIDFontType2"===t&&this.cidEncoding.startsWith("Identity-")){const t=(0,o.getGlyphMapForStandardFonts)(),r=[];for(const e in t)r[+e]=t[e];if(/Arial-?Black/i.test(e)){var d=(0,o.getSupplementalGlyphMapForArialBlack)();for(const e in d)r[+e]=d[e]}else if(/Calibri/i.test(e)){const e=(0,o.getSupplementalGlyphMapForCalibri)();for(const t in e)r[+t]=e[t]}this.toUnicode instanceof k||this.toUnicode.forEach((function(e,t){r[+e]=t}));this.toFontChar=r;this.toUnicode=new w(r)}else if(/Symbol/i.test(i))this.toFontChar=buildToFontChar(s.SymbolSetEncoding,(0,n.getGlyphsUnicode)(),this.differences);else if(/Dingbats/i.test(i)){/Wingdings/i.test(e)&&(0,a.warn)("Non-embedded Wingdings font, falling back to ZapfDingbats.");this.toFontChar=buildToFontChar(s.ZapfDingbatsEncoding,(0,n.getDingbatsGlyphsUnicode)(),this.differences)}else if(u)this.toFontChar=buildToFontChar(this.defaultEncoding,(0,n.getGlyphsUnicode)(),this.differences);else{const t=(0,n.getGlyphsUnicode)(),r=[];this.toUnicode.forEach((e,a)=>{if(!this.composite){var i=this.differences[e]||this.defaultEncoding[e];const r=(0,c.getUnicodeForGlyph)(i,t);-1!==r&&(a=r)}r[+e]=a});if(this.composite&&this.toUnicode instanceof k&&/Verdana/i.test(e)){const e=(0,o.getGlyphMapForStandardFonts)();for(const t in e)r[+t]=e[t]}this.toFontChar=r}this.loadedName=i.split("-")[0];this.fontType=getFontType(t,r)},checkAndRepair:function Font_checkAndRepair(e,t,r){const o=["OS/2","cmap","head","hhea","hmtx","maxp","name","post","loca","glyf","fpgm","prep","cvt ","CFF "];function readTables(e,t){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 a=0;a>>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);e.pos=s;if("head"===t){o[8]=o[9]=o[10]=o[11]=0;o[17]|=32}return{tag:t,checksum:r,length:n,offset:i,data:o}}function readOpenTypeHeader(e){return{version:(0,a.bytesToString)(e.getBytes(4)),numTables:e.getUint16(),searchRange:e.getUint16(),entrySelector:e.getUint16(),rangeShift:e.getUint16()}}function sanitizeGlyph(e,t,r,a,i,n){var s={length:0,sizeOfInstructions:0};if(r-t<=12)return s;var o=e.subarray(t,r),c=signedInt16(o[0],o[1]);if(c<0){!function writeSignedInt16(e,t,r){e[t+1]=r;e[t]=r>>>8}(o,0,c=-1);a.set(o,i);s.length=o.length;return s}var l,h=10,u=0;for(l=0;lo.length)return s;if(!n&&f>0){a.set(o.subarray(0,d),i);a.set([0,0],i+d);a.set(o.subarray(g,y),i+d+2);y-=f;o.length-y>3&&(y=y+3&-4);s.length=y;return s}if(o.length-y>3){y=y+3&-4;a.set(o.subarray(0,y),i);s.length=y;return s}a.set(o,i);s.length=o.length;return s}function readNameTable(e){var r=(t.start?t.start:0)+e.offset;t.pos=r;var i=[[],[]],n=e.length,s=r+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&&(h+=S-1)}}else{if(b||v){(0,a.warn)("TT: nested FDEFs not allowed");p=!0}b=!0;d=h;s=f.pop();t.functionsDefined[s]={data:l,i:h}}else if(!b&&!v){s=f[f.length-1];if(isNaN(s))(0,a.info)("TT: CALL empty stack (or invalid entry).");else{t.functionsUsed[s]=!0;if(s in t.functionsStackDeltas){const e=f.length+t.functionsStackDeltas[s];if(e<0){(0,a.warn)("TT: CALL invalid functions stack delta.");t.hintsValid=!1;return}f.length=e}else if(s in t.functionsDefined&&!m.includes(s)){g.push({data:l,i:h,stackTop:f.length-1});m.push(s);if(!(o=t.functionsDefined[s])){(0,a.warn)("TT: CALL non-existent function");t.hintsValid=!1;return}l=o.data;h=o.i}}}if(!b&&!v){let e=0;k<=142?e=c[k]:k>=192&&k<=223?e=-1:k>=224&&(e=-2);if(k>=113&&k<=117){i=f.pop();isNaN(i)||(e=2*-i)}for(;e<0&&f.length>0;){f.pop();e++}for(;e>0;){f.push(NaN);e--}}}t.tooComplexToFollowFunctions=p;var C=[l];h>l.length&&C.push(new Uint8Array(h-l.length));if(d>u){(0,a.warn)("TT: complementing a missing function tail");C.push(new Uint8Array([34,45]))}!function foldTTTable(e,t){if(t.length>1){var r,a,i=0;for(r=0,a=t.length;r>>0,s=[];for(let t=0;t>>0);const o={ttcTag:t,majorVersion:r,minorVersion:i,numFonts:n,offsetTable:s};switch(r){case 1:return o;case 2:o.dsigTag=e.getInt32()>>>0;o.dsigLength=e.getInt32()>>>0;o.dsigOffset=e.getInt32()>>>0;return o}throw new a.FormatError(`Invalid TrueType Collection majorVersion: ${r}.`)}(e);for(let n=0;n0||!(r.cMap instanceof u.IdentityCMap));if("OTTO"===l.version&&!t||!h.head||!h.hhea||!h.maxp||!h.post){g=new d.Stream(h["CFF "].data);f=new T(g,r);adjustWidths(r);return this.convert(e,f,r)}delete h.glyf;delete h.loca;delete h.fpgm;delete h.prep;delete h["cvt "];this.isOpenType=!0}if(!h.maxp)throw new a.FormatError('Required "maxp" table is not found');t.pos=(t.start||0)+h.maxp.offset;var p=t.getInt32();const b=t.getUint16();let v=b+1,w=!0;if(v>65535){w=!1;v=b;(0,a.warn)("Not enough space in glyfs to duplicate first glyph.")}var k=0,C=0;if(p>=65536&&h.maxp.length>=22){t.pos+=8;if(t.getUint16()>2){h.maxp.data[14]=0;h.maxp.data[15]=2}t.pos+=4;k=t.getUint16();t.pos+=4;C=t.getUint16()}h.maxp.data[4]=v>>8;h.maxp.data[5]=255&v;var x=function sanitizeTTPrograms(e,t,r,i){var n={functionsDefined:[],functionsUsed:[],functionsStackDeltas:[],tooComplexToFollowFunctions:!1,hintsValid:!0};e&&sanitizeTTProgram(e,n);t&&sanitizeTTProgram(t,n);e&&function checkInvalidFunctions(e,t){if(!e.tooComplexToFollowFunctions)if(e.functionsDefined.length>t){(0,a.warn)("TT: more functions defined than expected");e.hintsValid=!1}else for(var r=0,i=e.functionsUsed.length;rt){(0,a.warn)("TT: invalid function id: "+r);e.hintsValid=!1;return}if(e.functionsUsed[r]&&!e.functionsDefined[r]){(0,a.warn)("TT: undefined function: "+r);e.hintsValid=!1;return}}}(n,i);if(r&&1&r.length){var s=new Uint8Array(r.length+1);s.set(r.data);r.data=s}return n.hintsValid}(h.fpgm,h.prep,h["cvt "],k);if(!x){delete h.fpgm;delete h.prep;delete h["cvt "]}!function sanitizeMetrics(e,t,r,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();if(s>i){(0,a.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-(r.length-4*s>>1);if(o>0){var c=new Uint8Array(r.length+2*o);c.set(r.data);if(n){c[r.length]=r.data[2];c[r.length+1]=r.data[3]}r.data=c}}else r&&(r.data=null)}(t,h.hhea,h.hmtx,v,w);if(!h.head)throw new a.FormatError('Required "head" table is not found');!function sanitizeHead(e,t,r){var i=e.data,n=function int32(e,t,r,a){return(e<<24)+(t<<16)+(r<<8)+a}(i[0],i[1],i[2],i[3]);if(n>>16!=1){(0,a.info)("Attempting to fix invalid version in head table: "+n);i[0]=0;i[1]=1;i[2]=0;i[3]=0}var s=int16(i[50],i[51]);if(s<0||s>1){(0,a.info)("Attempting to fix invalid indexToLocFormat in head table: "+s);var o=t+1;if(r===o<<1){i[50]=0;i[51]=0}else{if(r!==o<<2)throw new a.FormatError("Could not fix indexToLocFormat: "+s);i[50]=0;i[51]=1}}}(h.head,b,m?h.loca.length:0);var A=Object.create(null);if(m){var I=int16(h.head.data[50],h.head.data[51]),F=function sanitizeGlyphLocations(e,t,r,a,i,n,s){var o,c,l;if(a){o=4;c=function fontItemDecodeLong(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]};l=function fontItemEncodeLong(e,t,r){e[t]=r>>>24&255;e[t+1]=r>>16&255;e[t+2]=r>>8&255;e[t+3]=255&r}}else{o=2;c=function fontItemDecode(e,t){return e[t]<<9|e[t+1]<<1};l=function fontItemEncode(e,t,r){e[t]=r>>9&255;e[t+1]=r>>1&255}}var h=n?r+1:r,u=o*(1+h),d=new Uint8Array(u);d.set(e.data.subarray(0,u));e.data=d;var f,g,m=t.data,p=m.length,b=new Uint8Array(p);const y=[];for(f=0,g=0;fp&&(e=p);y.push({index:f,offset:e,endOffset:0})}y.sort((e,t)=>e.offset-t.offset);for(f=0;fe.index-t.index);var v=Object.create(null),w=0;l(d,0,w);for(f=0,g=o;fs&&(s=k.sizeOfInstructions);l(d,g,w+=S)}if(0===w){var C=new Uint8Array([0,1,0,0,0,0,0,0,0,0,0,0,0,0,49,0]);for(f=0,g=o;fx+w)t.data=b.subarray(0,x+w);else{t.data=new Uint8Array(x+w);t.data.set(b.subarray(0,w))}t.data.set(b.subarray(0,x),w);l(e.data,d.length-o,w+x)}else t.data=b.subarray(0,w);return{missingGlyphs:v,maxSizeOfInstructions:s}}(h.loca,h.glyf,b,I,x,w,C);A=F.missingGlyphs;if(p>=65536&&h.maxp.length>=22){h.maxp.data[26]=F.maxSizeOfInstructions>>8;h.maxp.data[27]=255&F.maxSizeOfInstructions}}if(!h.hhea)throw new a.FormatError('Required "hhea" table is not found');if(0===h.hhea.data[10]&&0===h.hhea.data[11]){h.hhea.data[10]=255;h.hhea.data[11]=255}var P={unitsPerEm:int16(h.head.data[18],h.head.data[19]),yMax:int16(h.head.data[42],h.head.data[43]),yMin:signedInt16(h.head.data[38],h.head.data[39]),ascent:int16(h.hhea.data[4],h.hhea.data[5]),descent:signedInt16(h.hhea.data[6],h.hhea.data[7])};this.ascent=P.ascent/P.unitsPerEm;this.descent=P.descent/P.unitsPerEm;h.post&&function readPostScriptTable(e,r,i){var n=(t.start?t.start:0)+e.offset;t.pos=n;var s,o=n+e.length,c=t.getInt32();t.skip(28);var l,h=!0;switch(c){case 65536:s=y;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 a.FormatError("Max size of CID is 65,535");var r=-1;O?r=t:void 0!==B[t]&&(r=B[t]);r>=0&&r>>0,g=!1;if(!o||o.platformId!==u||o.encodingId!==d){if(0!==u||0!==d&&1!==d&&3!==d)if(1===u&&0===d)g=!0;else if(3!==u||1!==d||!i&&o){if(r&&3===u&&0===d){g=!0;l=!0}}else{g=!0;r||(l=!0)}else g=!0;g&&(o={platformId:u,encodingId:d,offset:f});if(l)break}}o&&(t.pos=s+o.offset);if(!o||-1===t.peekByte()){(0,a.warn)("Could not find a preferred cmap table.");return{platformId:-1,encodingId:-1,mappings:[],hasShortCmap:!1}}var m=t.getUint16();t.skip(4);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.skip(6);var S,C=[];for(S=0;S>1)-(k-S);n.offsetIndex=T;x=Math.max(x,T+n.end-n.start+1)}else n.offsetIndex=-1}var I=[];for(p=0;p=61440&&t<=61695&&(t&=255);E[t]=N[e].glyphId}if(r.glyphNames&&e.length)for(let t=0;t<256;++t)if(void 0===E[t]&&e[t]){U=e[t];const a=r.glyphNames.indexOf(U);a>0&&hasGlyph(a)&&(E[t]=a)}}0===E.length&&(E[0]=0);let H=v-1;w||(H=0);var z=adjustMapping(E,hasGlyph,H);this.toFontChar=z.toFontChar;h.cmap={tag:"cmap",data:createCmapTable(z.charCodeToGlyphId,v)};h["OS/2"]&&function validateOS2Table(e,t){t.pos=(t.start||0)+e.offset;var r=t.getUint16();t.skip(60);var a=t.getUint16();if(r<4&&768&a)return!1;if(t.getUint16()>t.getUint16())return!1;t.skip(6);if(0===t.getUint16())return!1;e.data[8]=e.data[9]=0;return!0}(h["OS/2"],t)||(h["OS/2"]={tag:"OS/2",data:createOS2Table(r,z.charCodeToGlyphId,P)});if(!m)try{g=new d.Stream(h["CFF "].data);f=new i.CFFParser(g,r,!0).parse();f.duplicateFirstGlyph();var G=new i.CFFCompiler(f);h["CFF "].data=G.compile()}catch(e){(0,a.warn)("Failed to compile font "+r.loadedName)}if(h.name){var W=readNameTable(h.name);h.name.data=createNameTable(e,W)}else h.name={tag:"name",data:createNameTable(this.name)};var X=new S(l.version);for(var V in h)X.addTable(V,h[V].data);return X.toArray()},convert:function Font_convert(e,t,r){r.fixedPitch=!1;r.builtInEncoding&&function adjustToUnicode(e,t){if(!e.hasIncludedToUnicodeMap&&!(e.hasEncoding||t===e.defaultEncoding||e.toUnicode instanceof k)){var r=[],a=(0,n.getGlyphsUnicode)();for(var i in t){var s=t[i],o=(0,c.getUnicodeForGlyph)(s,a);-1!==o&&(r[i]=String.fromCharCode(o))}e.toUnicode.amend(r)}}(r,r.builtInEncoding);let i=1;t instanceof T&&(i=t.numGlyphs-1);var o=t.getGlyphMapping(r),l=adjustMapping(o,t.hasGlyphId.bind(t),i);this.toFontChar=l.toFontChar;var h=t.numGlyphs;function getCharCodes(e,t){var r=null;for(var a in e)if(t===e[a]){r||(r=[]);r.push(0|a)}return r}function createCharCode(e,t){for(var r in e)if(t===e[r])return 0|r;l.charCodeToGlyphId[l.nextAvailableFontCharCode]=t;return l.nextAvailableFontCharCode++}var u=t.seacs;if(u&&u.length){var d=r.fontMatrix||a.FONT_IDENTITY_MATRIX,f=t.getCharset(),g=Object.create(null);for(var m in u){var p=u[m|=0],b=s.StandardEncoding[p[2]],y=s.StandardEncoding[p[3]],v=f.indexOf(b),w=f.indexOf(y);if(!(v<0||w<0)){var C={x:p[0]*d[0]+p[1]*d[2]+d[4],y:p[0]*d[1]+p[1]*d[3]+d[5]},x=getCharCodes(o,m);if(x)for(let e=0,t=x.length;e=0?a:0}}else if(l)for(i in t)c[i]=t[i];else{o=s.StandardEncoding;for(i=0;i=0?a:0}}var h,u=e.differences;if(u)for(i in u){var d=u[i];if(-1===(a=r.indexOf(d))){h||(h=(0,n.getGlyphsUnicode)());var f=recoverGlyphName(d,h);f!==d&&(a=r.indexOf(f))}c[i]=a>=0?a:0}return c}var A=function Type1FontClosure(){function findBlock(e,t,r){for(var a,i=e.length,n=t.length,s=i-n,o=r,c=!1;o=n){o+=a;for(;o=0&&(n[s]=r)}return type1FontGlyphMapping(e,n,a)},hasGlyphId:function Type1Font_hasGlyphID(e){return!(e<0||e>=this.numGlyphs)&&(0===e||this.charstrings[e-1].charstring.length>0)},getSeacs:function Type1Font_getSeacs(e){var t,r,a=[];for(t=0,r=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=a.length;l=t)throw new a.FormatError("Invalid CFF header");if(0!==r){(0,a.info)("cff data is shifted");e=e.subarray(r);this.bytes=e}var i=e[0],n=e[1],s=e[2],o=e[3];return{obj:new CFFHeader(i,n,s,o),endPos:s}}parseDict(e){var t=0;function parseOperand(){var r=e[t++];if(30===r)return function parseFloatOperand(){var r="";const a=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];var i=e.length;for(;t>4,o=15&n;if(15===s)break;r+=a[s];if(15===o)break;r+=a[o]}return parseFloat(r)}();if(28===r)return r=((r=e[t++])<<24|e[t++]<<16)>>16;if(29===r)return r=(r=(r=(r=e[t++])<<8|e[t++])<<8|e[t++])<<8|e[t++];if(r>=32&&r<=246)return r-139;if(r>=247&&r<=250)return 256*(r-247)+e[t++]+108;if(r>=251&&r<=254)return-256*(r-251)-e[t++]-108;(0,a.warn)('CFFParser_parseDict: "'+r+'" is a reserved command.');return NaN}var r=[],i=[];t=0;for(var n=e.length;t10)return!1;for(var o=r.stackSize,c=r.stack,l=i.length,h=0;h>16;h+=2;o++}else if(14===u){if(o>=4){o-=4;if(this.seacAnalysisEnabled){r.seac=c.slice(o,o+4);return!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){r.hints+=o>>1;h+=r.hints+7>>3;o%=2;d=e[u]}else{if(10===u||29===u){var g;if(!(g=10===u?n:s)){d=e[u];(0,a.warn)("Missing subrsIndex for "+d.id);return!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)){d=e[u];(0,a.warn)("Out of bounds subrIndex for "+d.id);return!1}r.stackSize=o;r.callDepth++;if(!this.parseCharString(r,g.get(p),n,s))return!1;r.callDepth--;o=r.stackSize;continue}if(11===u){r.stackSize=o;return!0}d=e[u]}if(d){if(d.stem){r.hints+=o>>1;if(3===u||23===u)r.hasVStems=!0;else if(r.hasVStems&&(1===u||18===u)){(0,a.warn)("CFF stem hints are in wrong order");i[h-1]=1===u?3:23}}if("min"in d&&!r.undefStack&&o=2&&d.stem?o%=2:o>1&&(0,a.warn)("Found too many parameters for stack-clearing command");o>0&&c[o-1]>=0&&(r.width=c[o-1])}if("stackDelta"in d){"stackFn"in d&&d.stackFn(c,o);o+=d.stackDelta}else if(d.stackClearing)o=0;else if(d.resetStack){o=0;r.undefStack=!1}else if(d.undefStack){o=0;r.undefStack=!0;r.firstStackClearing=!1}}}r.stackSize=o;return!0}parseCharStrings({charStrings:e,localSubrIndex:t,globalSubrIndex:r,fdSelect:i,fdArray:n,privateDict:s}){for(var o=[],c=[],l=e.count,h=0;h=n.length){(0,a.warn)("Invalid fd index for glyph index.");f=!1}f&&(g=(m=n[p].privateDict).subrsIndex)}else t&&(g=t);f&&(f=this.parseCharString(d,u,g,r));if(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(e){var t=this.createDict(l,[],e.strings);e.setByKey(18,[0,0]);e.privateDict=t}parsePrivateDict(e){if(e.hasName("Private")){var t=e.getByName("Private");if(Array.isArray(t)&&2===t.length){var r=t[0],a=t[1];if(0===r||a>=this.bytes.length)this.emptyPrivateDictionary(e);else{var i=a+r,n=this.bytes.subarray(a,i),s=this.parseDict(n),o=this.createDict(l,s,e.strings);e.privateDict=o;if(o.getByName("Subrs")){var c=o.getByName("Subrs"),h=a+c;if(0===c||h>=this.bytes.length)this.emptyPrivateDictionary(e);else{var u=this.parseIndex(h);o.subrsIndex=u.obj}}}}else e.removeByName("Private")}else this.emptyPrivateDictionary(e)}parseCharsets(e,t,r,n){if(0===e)return new CFFCharset(!0,h.ISO_ADOBE,i.ISOAdobeCharset);if(1===e)return new CFFCharset(!0,h.EXPERT,i.ExpertCharset);if(2===e)return new CFFCharset(!0,h.EXPERT_SUBSET,i.ExpertSubsetCharset);var s=this.bytes,o=e,c=s[e++];const l=[n?0:".notdef"];var u,d,f;t-=1;switch(c){case 0:for(f=0;f=65535)(0,a.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(e){return!(e<0||e>=this.charStrings.count)&&this.charStrings.get(e).length>0}}t.CFF=CFF;class CFFHeader{constructor(e,t,r,a){this.major=e;this.minor=t;this.hdrSize=r;this.offSize=a}}t.CFFHeader=CFFHeader;class CFFStrings{constructor(){this.strings=[]}get(e){return e>=0&&e<=390?s[e]:e-391<=this.strings.length?this.strings[e-391]:s[0]}getSID(e){let t=s.indexOf(e);if(-1!==t)return t;t=this.strings.indexOf(e);return-1!==t?t+391:-1}add(e){this.strings.push(e)}get count(){return this.strings.length}}t.CFFStrings=CFFStrings;class CFFIndex{constructor(){this.objects=[];this.length=0}add(e){this.length+=e.length;this.objects.push(e)}set(e,t){this.length+=t.length-this.objects[e].length;this.objects[e]=t}get(e){return this.objects[e]}get count(){return this.objects.length}}t.CFFIndex=CFFIndex;class CFFDict{constructor(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)}setByKey(e,t){if(!(e in this.keyToNameMap))return!1;var r=t.length;if(0===r)return!0;for(var i=0;i=this.fdSelect.length?-1:this.fdSelect[e]}}t.CFFFDSelect=CFFFDSelect;class CFFOffsetTracker{constructor(){this.offsets=Object.create(null)}isTracking(e){return e in this.offsets}track(e,t){if(e in this.offsets)throw new a.FormatError("Already tracking location of "+e);this.offsets[e]=t}offset(e){for(var t in this.offsets)this.offsets[t]+=e}setEntryLocation(e,t,r){if(!(e in this.offsets))throw new a.FormatError("Not tracking location of "+e);for(var i=r.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}}}class CFFCompiler{constructor(e){this.cff=e}compile(){var e=this.cff,t={data:[],length:0,add:function CFFCompiler_add(e){this.data=this.data.concat(e);this.length=this.data.length}},r=this.compileHeader(e.header);t.add(r);var i=this.compileNameIndex(e.names);t.add(i);if(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(e){return[e.major,e.minor,e.hdrSize,e.offSize]}compileNameIndex(e){for(var t=new CFFIndex,r=0,i=e.length;r"~"||"["===l||"]"===l||"("===l||")"===l||"{"===l||"}"===l||"<"===l||">"===l||"/"===l||"%"===l)&&(l="_");o[c]=l}""===(o=o.join(""))&&(o="Bad_Font_Name");t.add((0,a.stringToBytes)(o))}return this.compileIndex(t)}compileTopDicts(e,t,r){for(var a=[],i=new CFFIndex,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(e){return this.compileTypedArray(e.raw)}compileFDSelect(e){const t=e.format;let r,a;switch(t){case 0:r=new Uint8Array(1+e.fdSelect.length);r[0]=t;for(a=0;a>8&255,255&i,n];for(a=1;a>8&255,255&a,t);n=t}}const o=(s.length-3)/3;s[1]=o>>8&255;s[2]=255&o;s.push(a>>8&255,255&a);r=new Uint8Array(s)}return this.compileTypedArray(r)}compileTypedArray(e){for(var t=[],r=0,a=e.length;r>8&255,255&a],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);r[i]&&(c+=r[i].length)}for(i=0;i=65520&&e<=65535?0:e>=62976&&e<=63743?i()[e]||e:173===e?45:e};t.reverseIfRtl=function reverseIfRtl(e){var t=e.length;if(t<=1||!function isRTLRangeFor(e){var t=n[13];return e>=t.begin&&e=(t=n[11]).begin&&e=0;a--)r+=e[a];return r};t.getUnicodeRangeFor=function getUnicodeRangeFor(e){for(var t=0,r=n.length;t=a.begin&&e=5&&i<=7))return-1;a=e.substring(1)}if(a===a.toUpperCase()&&(r=parseInt(a,16))>=0)return r}return-1}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FontRendererFactory=void 0;var a=r(2),i=r(31),n=r(34),s=r(33),o=r(12),c=function FontRendererFactoryClosure(){function getLong(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function getUshort(e,t){return e[t]<<8|e[t+1]}function getSubroutineBias(e){const t=e.length;let r=32768;t<1240?r=107:t<33900&&(r=1131);return r}function parseCmap(e,t,r){var i,n,s,o=1===getUshort(e,t+2)?getLong(e,t+8):getLong(e,t+16),c=getUshort(e,t+o);if(4===c){getUshort(e,t+o+2);var l=getUshort(e,t+o+6)>>1;n=t+o+14;i=[];for(s=0;s>1;r=0&&e>16,s=0,o=0;i+=10;if(n<0)do{a=e[i]<<8|e[i+1];var c,l,h=e[i+2]<<8|e[i+3];i+=4;if(1&a){c=(e[i]<<24|e[i+1]<<16)>>16;l=(e[i+2]<<24|e[i+3]<<16)>>16;i+=4}else{c=e[i++];l=e[i++]}if(2&a){s=c;o=l}else{s=0;o=0}var u=1,d=1,f=0,g=0;if(8&a){u=d=(e[i]<<24|e[i+1]<<16)/1073741824;i+=2}else if(64&a){u=(e[i]<<24|e[i+1]<<16)/1073741824;d=(e[i+2]<<24|e[i+3]<<16)/1073741824;i+=4}else if(128&a){u=(e[i]<<24|e[i+1]<<16)/1073741824;f=(e[i+2]<<24|e[i+3]<<16)/1073741824;g=(e[i+4]<<24|e[i+5]<<16)/1073741824;d=(e[i+6]<<24|e[i+7]<<16)/1073741824;i+=8}var m=r.glyphs[h];if(m){t.push({cmd:"save"});t.push({cmd:"transform",args:[u,f,g,d,s,o]});compileGlyf(m,t,r);t.push({cmd:"restore"})}}while(32&a);else{var p,b,y=[];for(p=0;p0;)w.push({flags:a})}for(p=0;p>16;i+=2;break;case 2:s-=e[i++];break;case 18:s+=e[i++]}w[p].x=s}for(p=0;p>16;i+=2;break;case 4:o-=e[i++];break;case 36:o+=e[i++]}w[p].y=o}var S=0;for(i=0;i>1;v=!0;break;case 4:c+=n.pop();moveTo(o,c);v=!0;break;case 5:for(;n.length>0;){o+=n.shift();c+=n.shift();lineTo(o,c)}break;case 6:for(;n.length>0;){lineTo(o+=n.shift(),c);if(0===n.length)break;c+=n.shift();lineTo(o,c)}break;case 7:for(;n.length>0;){c+=n.shift();lineTo(o,c);if(0===n.length)break;lineTo(o+=n.shift(),c)}break;case 8:for(;n.length>0;){u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}break;case 10:b=n.pop();y=null;if(r.isCFFCIDFont){const e=r.fdSelect.getFDIndex(i);if(e>=0&&eMath.abs(c-S)?o+=n.shift():c+=n.shift();bezierCurveTo(u,f,d,g,o,c);break;default:throw new a.FormatError("unknown operator: 12 "+w)}break;case 14:if(n.length>=4){var C=n.pop(),x=n.pop();c=n.pop();o=n.pop();t.push({cmd:"save"});t.push({cmd:"translate",args:[o,c]});var A=lookupCmap(r.cmap,String.fromCharCode(r.glyphNameMap[s.StandardEncoding[C]]));compileCharString(r.glyphs[A.glyphId],t,r,A.glyphId);t.push({cmd:"restore"});A=lookupCmap(r.cmap,String.fromCharCode(r.glyphNameMap[s.StandardEncoding[x]]));compileCharString(r.glyphs[A.glyphId],t,r,A.glyphId)}return;case 18:l+=n.length>>1;v=!0;break;case 19:case 20:h+=(l+=n.length>>1)+7>>3;v=!0;break;case 21:c+=n.pop();moveTo(o+=n.pop(),c);v=!0;break;case 22:moveTo(o+=n.pop(),c);v=!0;break;case 23:l+=n.length>>1;v=!0;break;case 24:for(;n.length>2;){u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}o+=n.shift();c+=n.shift();lineTo(o,c);break;case 25:for(;n.length>6;){o+=n.shift();c+=n.shift();lineTo(o,c)}u=o+n.shift();f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o,c);break;case 26:n.length%2&&(o+=n.shift());for(;n.length>0;){u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d;c=g+n.shift();bezierCurveTo(u,f,d,g,o,c)}break;case 27:n.length%2&&(c+=n.shift());for(;n.length>0;)bezierCurveTo(u=o+n.shift(),f=c,d=u+n.shift(),g=f+n.shift(),o=d+n.shift(),c=g);break;case 28:n.push((e[h]<<24|e[h+1]<<16)>>16);h+=2;break;case 29:b=n.pop()+r.gsubrsBias;(y=r.gsubrs[b])&&parse(y);break;case 30:for(;n.length>0;){u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+(1===n.length?n.shift():0);bezierCurveTo(u,f,d,g,o,c);if(0===n.length)break;u=o+n.shift();f=c;d=u+n.shift();g=f+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o=d+(1===n.length?n.shift():0),c)}break;case 31:for(;n.length>0;){u=o+n.shift();f=c;d=u+n.shift();g=f+n.shift();c=g+n.shift();bezierCurveTo(u,f,d,g,o=d+(1===n.length?n.shift():0),c);if(0===n.length)break;u=o;f=c+n.shift();d=u+n.shift();g=f+n.shift();o=d+n.shift();c=g+(1===n.length?n.shift():0);bezierCurveTo(u,f,d,g,o,c)}break;default:if(w<32)throw new a.FormatError("unknown operator: "+w);if(w<247)n.push(w-139);else if(w<251)n.push(256*(w-247)+e[h++]+108);else if(w<255)n.push(256*-(w-251)-e[h++]-108);else{n.push((e[h]<<24|e[h+1]<<16|e[h+2]<<8|e[h+3])/65536);h+=4}}v&&(n.length=0)}}(e)}(e,t,this,r)}}return{create:function FontRendererFactory_create(e,t){for(var r,i,n,s,o,c,l=new Uint8Array(e.data),h=getUshort(l,4),u=0,d=12;ua)return!0;for(var i=a-e,n=i;n>8&255,255&s);else{s=65536*s|0;this.output.push(255,s>>24&255,s>>16&255,s>>8&255,255&s)}}this.output.push.apply(this.output,t);r?this.stack.splice(i,e):this.stack.length=0;return!1}};return Type1CharString}(),c=function Type1ParserClosure(){function isHexDigit(e){return e>=48&&e<=57||e>=65&&e<=70||e>=97&&e<=102}function decrypt(e,t,r){if(r>=e.length)return new Uint8Array(0);var a,i,n=0|t;for(a=0;a>8;n=52845*(c+n)+22719&65535}return o}function isSpecial(e){return 47===e||91===e||93===e||123===e||125===e||40===e||41===e}function Type1Parser(e,t,r){if(t){var a=e.getBytes(),s=!((isHexDigit(a[0])||(0,i.isWhiteSpace)(a[0]))&&isHexDigit(a[1])&&isHexDigit(a[2])&&isHexDigit(a[3])&&isHexDigit(a[4])&&isHexDigit(a[5])&&isHexDigit(a[6])&&isHexDigit(a[7]));e=new n.Stream(s?decrypt(a,55665,4):function decryptAscii(e,t,r){var a,i,n=0|t,s=e.length,o=new Uint8Array(s>>>1);for(a=0,i=0;a>8;n=52845*(h+n)+22719&65535}}}return o.slice(r,i)}(a,55665,4))}this.seacAnalysisEnabled=!!r;this.stream=e;this.nextChar()}Type1Parser.prototype={readNumberArray:function Type1Parser_readNumberArray(){this.getToken();for(var e=[];;){var t=this.getToken();if(null===t||"]"===t||"}"===t)break;e.push(parseFloat(t||0))}return e},readNumber:function Type1Parser_readNumber(){var e=this.getToken();return parseFloat(e||0)},readInt:function Type1Parser_readInt(){var e=this.getToken();return 0|parseInt(e||0,10)},readBoolean:function Type1Parser_readBoolean(){return"true"===this.getToken()?1:0},nextChar:function Type1_nextChar(){return this.currentChar=this.stream.getByte()},getToken:function Type1Parser_getToken(){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(isSpecial(t)){this.nextChar();return String.fromCharCode(t)}var r="";do{r+=String.fromCharCode(t);t=this.nextChar()}while(t>=0&&!(0,i.isWhiteSpace)(t)&&!isSpecial(t));return r},readCharStrings:function Type1Parser_readCharStrings(e,t){return-1===t?e:decrypt(e,4330,t)},extractFontProgram:function Type1Parser_extractFontProgram(e){var t=this.stream,r=[],a=[],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":this.getToken();this.getToken();this.getToken();this.getToken();for(;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();a.push({glyph:d,encoded:h})}break;case"Subrs":this.readInt();this.getToken();for(;"dup"===this.getToken();){const e=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();r[e]=h}break;case"BlueValues":case"OtherBlues":case"FamilyBlues":case"FamilyOtherBlues":var f=this.readNumberArray();f.length>0&&f.length,0;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 g=0;g-1&&void 0===e.widths[t]&&t>=e.firstChar&&t<=e.lastChar&&(e.widths[t]=m.width)}}return u},extractFontHeader:function Type1Parser_extractFontHeader(e){for(var t;null!==(t=this.getToken());)if("/"===t)switch(t=this.getToken()){case"FontMatrix":var r=this.readNumberArray();e.fontMatrix=r;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=d||I<=0)(0,a.info)("Bad shading domain.");else{var P,E=new Float32Array(l.numComps),B=new Float32Array(1);for(let e=0;e<=10;e++){B[0]=u+e*I;T(B,0,E,0);P=l.getRgb(E,0);var O=a.Util.makeCssRgb(P[0],P[1],P[2]);F.push([e/10,O])}var M="transparent";if(e.has("Background")){P=l.getRgb(e.get("Background"),0);M=a.Util.makeCssRgb(P[0],P[1],P[2])}if(!m){F.unshift([0,M]);F[1][0]+=g.SMALL_NUMBER}if(!p){F[F.length-1][0]-=g.SMALL_NUMBER;F.push([1,M])}this.colorStops=F}}RadialAxial.prototype={getIR:function RadialAxial_getIR(){var e,t,r,i,n,s=this.coordsArr,l=this.shadingType;if(l===o){t=[s[0],s[1]];r=[s[2],s[3]];i=null;n=null;e="axial"}else if(l===c){t=[s[0],s[1]];r=[s[3],s[4]];i=s[2];n=s[5];e="radial"}else(0,a.unreachable)("getPattern type unknown: "+l);var h=this.matrix;if(h){t=a.Util.applyTransform(t,h);r=a.Util.applyTransform(r,h);if(l===c){var u=a.Util.singularValueDecompose2dScale(h);i*=u[0];n*=u[1]}}return["RadialAxial",e,this.bbox,this.colorStops,t,r,i,n]}};return RadialAxial}();g.Mesh=function MeshClosure(){function MeshStreamReader(e,t){this.stream=e;this.context=t;this.buffer=0;this.bufferLength=0;var r=t.numComps;this.tmpCompsBuf=new Float32Array(r);var a=t.colorSpace.numComps;this.tmpCsCompsBuf=t.colorFn?new Float32Array(a):this.tmpCompsBuf}MeshStreamReader.prototype={get hasData(){if(this.stream.end)return this.stream.pos0)return!0;var e=this.stream.getByte();if(e<0)return!1;this.buffer=e;this.bufferLength=8;return!0},readBits:function MeshStreamReader_readBits(e){var t=this.buffer,r=this.bufferLength;if(32===e){if(0===r)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 a=this.stream.getByte();this.buffer=a&(1<>r)>>>0}if(8===e&&0===r)return this.stream.getByte();for(;r>r},align:function MeshStreamReader_align(){this.buffer=0;this.bufferLength=0},readFlag:function MeshStreamReader_readFlag(){return this.readBits(this.context.bitsPerFlag)},readCoordinate:function MeshStreamReader_readCoordinate(){var e=this.context.bitsPerCoordinate,t=this.readBits(e),r=this.readBits(e),a=this.context.decode,i=e<32?1/((1<o?o:t;r=r>c?c:r;a=a>c)*h;l&=(1<r?e=r:e0&&(d=i[h-1]);var f=a[1];h>1,c=a.length>>1,u=new l(s),d=Object.create(null),f=8192,g=new Float32Array(c);return function constructPostScriptFromIRResult(e,t,r,a){var i,s,l="",h=g;for(i=0;i(v=n[2*i+1]))&&(s=v);p[i]=s}if(f>0){f--;d[l]=p}r.set(p,a)}else r.set(m,a)}}}}();var c=function PostScriptStackClosure(){function PostScriptStack(e){this.stack=e?Array.prototype.slice.call(e,0):[]}PostScriptStack.prototype={push:function PostScriptStack_push(e){if(this.stack.length>=100)throw new Error("PostScript function stack overflow.");this.stack.push(e)},pop:function PostScriptStack_pop(){if(this.stack.length<=0)throw new Error("PostScript function stack underflow.");return this.stack.pop()},copy:function PostScriptStack_copy(e){if(this.stack.length+e>=100)throw new Error("PostScript function stack overflow.");for(var t=this.stack,r=t.length-e,a=e-1;a>=0;a--,r++)t.push(t[r])},index:function PostScriptStack_index(e){this.push(this.stack[this.stack.length-e-1])},roll:function PostScriptStack_roll(e,t){var r,a,i,n=this.stack,s=n.length-e,o=n.length-1,c=s+(t-Math.floor(t/e)*e);for(r=s,a=o;r0?n.push(r<>a);break;case"ceiling":r=n.pop();n.push(Math.ceil(r));break;case"copy":r=n.pop();n.copy(r);break;case"cos":r=n.pop();n.push(Math.cos(r));break;case"cvi":r=0|n.pop();n.push(r);break;case"cvr":break;case"div":a=n.pop();r=n.pop();n.push(r/a);break;case"dup":n.copy(1);break;case"eq":a=n.pop();r=n.pop();n.push(r===a);break;case"exch":n.roll(2,1);break;case"exp":a=n.pop();r=n.pop();n.push(r**a);break;case"false":n.push(!1);break;case"floor":r=n.pop();n.push(Math.floor(r));break;case"ge":a=n.pop();r=n.pop();n.push(r>=a);break;case"gt":a=n.pop();r=n.pop();n.push(r>a);break;case"idiv":a=n.pop();r=n.pop();n.push(r/a|0);break;case"index":r=n.pop();n.index(r);break;case"le":a=n.pop();r=n.pop();n.push(r<=a);break;case"ln":r=n.pop();n.push(Math.log(r));break;case"log":r=n.pop();n.push(Math.log(r)/Math.LN10);break;case"lt":a=n.pop();r=n.pop();n.push(r=t?new AstLiteral(t):e.max<=t?e:new AstMin(e,t)}function PostScriptCompiler(){}PostScriptCompiler.prototype={compile:function PostScriptCompiler_compile(e,t,r){var a,i,n,s,o,c,l,h,u=[],d=[],f=t.length>>1,g=r.length>>1,m=0;for(let e=0;ee.min){s.unshift("Math.max(",i,", ");s.push(")")}if(n=0&&(t>=65&&t<=90||t>=97&&t<=122);)r.push(String.fromCharCode(t));const a=r.join("");switch(a.toLowerCase()){case"if":return o.IF;case"ifelse":return o.IFELSE;default:return o.getOperator(a)}}getNumber(){let e=this.currentChar;const t=this.strBuf;t.length=0;t[0]=String.fromCharCode(e);for(;(e=this.nextChar())>=0&&(e>=48&&e<=57||45===e||46===e);)t.push(String.fromCharCode(e));const r=parseFloat(t.join(""));if(isNaN(r))throw new a.FormatError("Invalid floating point number: "+r);return r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.bidi=function bidi(e,t,r){var c=!0,l=e.length;if(0===l||r)return createBidiText(e,c,r);s.length=l;o.length=l;var h,u,d=0;for(h=0;h=0&&"ET"===o[k];--k)o[k]="EN";for(k=h+1;k0&&(C=o[h-1]);var x=v;S+1A&&isOdd(A)&&(I=A)}for(A=T;A>=I;--A){var F=-1;for(h=0,u=m.length;h=0){reverseValues(s,F,h);F=-1}}else F<0&&(F=h);F>=0&&reverseValues(s,F,m.length)}for(h=0,u=s.length;h"!==P||(s[h]="")}return createBidiText(s.join(""),c)};var a=r(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 isOdd(e){return 0!=(1&e)}function isEven(e){return 0==(1&e)}function findUnequal(e,t,r){for(var a=t,i=e.length;a>>8;t[r++]=255&i}}}else{if(!(0,a.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e;r=t.byteLength}const i=r>>2,n=r-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}else{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}o=0;switch(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 r=(e>>>0).toString(16),a=(t>>>0).toString(16);return r.padStart(8,"0")+a.padStart(8,"0")}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFImage=void 0;var a=r(2),i=r(5),n=r(23),s=r(12),o=r(18),c=r(21);function decodeAndClamp(e,t,r,a){(e=t+e*r)<0?e=0:e>a&&(e=a);return e}function resizeImageMask(e,t,r,a,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=r/i,f=a/n,g=0,m=new Uint16Array(i),p=r;for(c=0;c0&&Number.isInteger(r.height)&&r.height>0&&(r.width!==p||r.height!==b)){(0,a.warn)("PDFImage - using the Width/Height of the image data, rather than the image dictionary.");p=r.width;b=r.height}if(p<1||b<1)throw new a.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=r.bitsPerComponent;if(!y&&!(y=f.get("BitsPerComponent","BPC"))){if(!this.imageMask)throw new a.FormatError("Bits per component missing in image: "+this.imageMask);y=1}this.bpc=y;if(!this.imageMask){let o=f.getRaw("ColorSpace")||f.getRaw("CS");if(!o){(0,a.info)("JPX images (which do not require color spaces)");switch(r.numComps){case 1:o=i.Name.get("DeviceGray");break;case 3:o=i.Name.get("DeviceRGB");break;case 4:o=i.Name.get("DeviceCMYK");break;default:throw new Error(`JPX images with ${r.numComps} color components not supported.`)}}this.colorSpace=n.ColorSpace.parse({cs:o,xref:e,resources:s?t:null,pdfFunctionFactory:u,localColorSpaceCache:d});this.numComps=this.colorSpace.numComps}this.decode=f.getArray("Decode","D");this.needsDecode=!1;if(this.decode&&(this.colorSpace&&!this.colorSpace.isDefaultDecode(this.decode,y)||h&&!n.ColorSpace.isDefaultDecode(this.decode,1))){this.needsDecode=!0;var v=(1<>3)*r,c=e.byteLength;if(!a||i&&!(o===c))if(i){(n=new Uint8ClampedArray(o)).set(e);for(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;l=0;for(d=0,c=n;d>y;r<0?r=0:r>u&&(r=u);o[d]=r;l&=(1<f[y+1]){m=255;break}}s[l]=m}}if(s)for(l=0,u=3,h=t*i;l>3;if(!e){var f;"DeviceGray"===this.colorSpace.name&&1===u?f=a.ImageKind.GRAYSCALE_1BPP:"DeviceRGB"!==this.colorSpace.name||8!==u||this.needsDecode||(f=a.ImageKind.RGB_24BPP);if(f&&!this.smask&&!this.mask&&r===l&&i===h){n.kind=f;t=this.getImageBytes(h*d);if(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,a.assert)(f===a.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){this._processStreamMessage(t);return}if(t.callback){const e=t.callbackId,r=this.callbackCapabilities[e];if(!r)throw new Error("Cannot resolve callback "+e);delete this.callbackCapabilities[e];if(t.callback===i)r.resolve(t.data);else{if(t.callback!==n)throw new Error("Unexpected callback case");r.reject(wrapReason(t.reason))}return}const a=this.actionHandler[t.action];if(!a)throw new Error("Unknown action from worker: "+t.action);if(t.callbackId){const e=this.sourceName,s=t.sourceName;new Promise((function(e){e(a(t.data))})).then((function(a){r.postMessage({sourceName:e,targetName:s,callback:i,callbackId:t.callbackId,data:a})}),(function(a){r.postMessage({sourceName:e,targetName:s,callback:n,callbackId:t.callbackId,reason:wrapReason(a)})}))}else t.streamId?this._createStreamSink(t):a(t.data)};r.addEventListener("message",this._onComObjOnMessage)}on(e,t){const r=this.actionHandler;if(r[e])throw new Error(`There is already an actionName called "${e}"`);r[e]=t}send(e,t,r){this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},r)}sendWithPromise(e,t,r){const i=this.callbackId++,n=(0,a.createPromiseCapability)();this.callbackCapabilities[i]=n;try{this._postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},r)}catch(e){n.reject(e)}return n.promise}sendWithStream(e,t,r,i){const n=this.streamId++,o=this.sourceName,c=this.targetName,l=this.comObj;return new ReadableStream({start:r=>{const s=(0,a.createPromiseCapability)();this.streamControllers[n]={controller:r,startCall:s,pullCall:null,cancelCall:null,isClosed:!1};this._postMessage({sourceName:o,targetName:c,action:e,streamId:n,data:t,desiredSize:r.desiredSize},i);return s.promise},pull:e=>{const t=(0,a.createPromiseCapability)();this.streamControllers[n].pullCall=t;l.postMessage({sourceName:o,targetName:c,stream:u,streamId:n,desiredSize:e.desiredSize});return t.promise},cancel:e=>{(0,a.assert)(e instanceof Error,"cancel must have a valid reason");const t=(0,a.createPromiseCapability)();this.streamControllers[n].cancelCall=t;this.streamControllers[n].isClosed=!0;l.postMessage({sourceName:o,targetName:c,stream:s,streamId:n,reason:wrapReason(e)});return t.promise}},r)}_createStreamSink(e){const t=this,r=this.actionHandler[e.action],i=e.streamId,n=this.sourceName,s=e.sourceName,o=this.comObj,u={enqueue(e,r=1,o){if(this.isCancelled)return;const c=this.desiredSize;this.desiredSize-=r;if(c>0&&this.desiredSize<=0){this.sinkCapability=(0,a.createPromiseCapability)();this.ready=this.sinkCapability.promise}t._postMessage({sourceName:n,targetName:s,stream:l,streamId:i,chunk:e},o)},close(){if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:c,streamId:i});delete t.streamSinks[i]}},error(e){(0,a.assert)(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;o.postMessage({sourceName:n,targetName:s,stream:h,streamId:i,reason:wrapReason(e)})}},sinkCapability:(0,a.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};u.sinkCapability.resolve();u.ready=u.sinkCapability.promise;this.streamSinks[i]=u;new Promise((function(t){t(r(e.data,u))})).then((function(){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,success:!0})}),(function(e){o.postMessage({sourceName:n,targetName:s,stream:f,streamId:i,reason:wrapReason(e)})}))}_processStreamMessage(e){const t=e.streamId,r=this.sourceName,i=e.sourceName,n=this.comObj;switch(e.stream){case f:e.success?this.streamControllers[t].startCall.resolve():this.streamControllers[t].startCall.reject(wrapReason(e.reason));break;case d:e.success?this.streamControllers[t].pullCall.resolve():this.streamControllers[t].pullCall.reject(wrapReason(e.reason));break;case u:if(!this.streamSinks[t]){n.postMessage({sourceName:r,targetName:i,stream:d,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:g}=this.streamSinks[e.streamId];new Promise((function(e){e(g&&g())})).then((function(){n.postMessage({sourceName:r,targetName:i,stream:d,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:r,targetName:i,stream:d,streamId:t,reason:wrapReason(e)})}));break;case l:(0,a.assert)(this.streamControllers[t],"enqueue should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].controller.enqueue(e.chunk);break;case c:(0,a.assert)(this.streamControllers[t],"close should have stream controller");if(this.streamControllers[t].isClosed)break;this.streamControllers[t].isClosed=!0;this.streamControllers[t].controller.close();this._deleteStreamController(t);break;case h:(0,a.assert)(this.streamControllers[t],"error should have stream controller");this.streamControllers[t].controller.error(wrapReason(e.reason));this._deleteStreamController(t);break;case o:e.success?this.streamControllers[t].cancelCall.resolve():this.streamControllers[t].cancelCall.reject(wrapReason(e.reason));this._deleteStreamController(t);break;case s:if(!this.streamSinks[t])break;const{onCancel:m}=this.streamSinks[e.streamId];new Promise((function(t){t(m&&m(wrapReason(e.reason)))})).then((function(){n.postMessage({sourceName:r,targetName:i,stream:o,streamId:t,success:!0})}),(function(e){n.postMessage({sourceName:r,targetName:i,stream:o,streamId:t,reason:wrapReason(e)})}));this.streamSinks[t].sinkCapability.reject(wrapReason(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,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PDFWorkerStream=void 0;var a=r(2);t.PDFWorkerStream=class PDFWorkerStream{constructor(e){this._msgHandler=e;this._contentLength=null;this._fullRequestReader=null;this._rangeRequestReaders=[]}getFullReader(){(0,a.assert)(!this._fullRequestReader,"PDFWorkerStream.getFullReader can only be called once.");this._fullRequestReader=new PDFWorkerStreamReader(this._msgHandler);return this._fullRequestReader}getRangeReader(e,t){const r=new PDFWorkerStreamRangeReader(e,t,this._msgHandler);this._rangeRequestReaders.push(r);return r}cancelAllRequests(e){this._fullRequestReader&&this._fullRequestReader.cancel(e);this._rangeRequestReaders.slice(0).forEach((function(t){t.cancel(e)}))}};class PDFWorkerStreamReader{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 PDFWorkerStreamRangeReader{constructor(e,t,r){this._msgHandler=r;this.onProgress=null;const a=this._msgHandler.sendWithStream("GetRangeReader",{begin:e,end:t});this._reader=a.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)}}}])})); \ No newline at end of file