@getflip/swirl-components 0.43.0 → 0.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components.json +1 -1
- package/dist/cjs/swirl-table.cjs.entry.js +13 -21
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +0 -22
- package/dist/collection/components/swirl-table/swirl-table.js +13 -21
- package/dist/components/assets/pdfjs/pdf.worker.min.js +0 -22
- package/dist/components/swirl-table.js +13 -21
- package/dist/esm/swirl-table.entry.js +13 -21
- package/dist/swirl-components/p-40b1fc51.entry.js +1 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-table/swirl-table.d.ts +1 -2
- package/package.json +1 -1
- package/dist/swirl-components/p-514fcbf9.entry.js +0 -1
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @licstart The following is the entire license notice for the
|
|
3
|
-
* JavaScript code in this page
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2022 Mozilla Foundation
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*
|
|
19
|
-
* @licend The above is the entire license notice for the
|
|
20
|
-
* JavaScript code in this page
|
|
21
|
-
*/
|
|
22
|
-
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf.worker",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf.worker"]=t():e["pdfjs-dist/build/pdf.worker"]=e.pdfjsWorker=t()}(globalThis,(()=>(()=>{var e=[,(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.WorkerTask=t.WorkerMessageHandler=void 0;var a=r(2),n=r(130),i=r(131),s=r(133),o=r(196),c=r(190),l=r(4),h=r(227),u=r(228);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){let r=!1;e.on("test",(function wphSetupTest(t){if(!r){r=!0;e.send("test",t instanceof Uint8Array)}}));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){let r,d=!1,f=null;const g=[],p=(0,a.getVerbosityLevel)(),m=e.apiVersion,b="2.16.105";if(m!==b)throw new Error(`The API version "${m}" does not match the Worker version "2.16.105".`);const y=[];for(const e in[])y.push(e);if(y.length)throw new Error("The `Array.prototype` contains unexpected enumerable properties: "+y.join(", ")+"; thus breaking e.g. `for...in` iteration of `Array`s.");if("undefined"==typeof ReadableStream){const e="The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream`); ";if(l.isNodeJS)throw new Error(e+"please use a `legacy`-build instead.");throw new Error(e+"please update to a supported browser.")}const w=e.docId,S=e.docBaseUrl,x=e.docId+"_worker";let k=new h.MessageHandler(x,w,t);function ensureNotTerminated(){if(d)throw new Error("Worker was terminated")}function startWorkerTask(e){g.push(e)}function finishWorkerTask(e){e.finish();const t=g.indexOf(e);g.splice(t,1)}async function loadDocument(e){await r.ensureDoc("checkHeader");await r.ensureDoc("parseStartXRef");await r.ensureDoc("parse",[e]);await r.ensureDoc("checkFirstPage",[e]);await r.ensureDoc("checkLastPage",[e]);const t=await r.ensureDoc("isPureXfa");if(t){const e=new WorkerTask("loadXfaFonts");startWorkerTask(e);await Promise.all([r.loadXfaFonts(k,e).catch((e=>{})).then((()=>finishWorkerTask(e))),r.loadXfaImages()])}const[a,n]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprints")]);return{numPages:a,fingerprints:n,htmlForXfa:t?await r.ensureDoc("htmlForXfa"):null}}function getPdfManager(e,t,r){const n=(0,a.createPromiseCapability)();let i;const o=e.source;if(o.data){try{i=new s.LocalPdfManager(w,o.data,o.password,k,t,r,S);n.resolve(i)}catch(e){n.reject(e)}return n.promise}let c,l=[];try{c=new u.PDFWorkerStream(k)}catch(e){n.reject(e);return n.promise}const h=c.getFullReader();h.headersReady.then((function(){if(!h.isRangeSupported)return;const e=o.disableAutoFetch||h.isStreamingSupported;i=new s.NetworkPdfManager(w,c,{msgHandler:k,password:o.password,length:h.contentLength,disableAutoFetch:e,rangeChunkSize:o.rangeChunkSize},t,r,S);for(const e of l)i.sendProgressiveData(e);l=[];n.resolve(i);f=null})).catch((function(e){n.reject(e);f=null}));let d=0;new Promise((function(e,c){const readChunk=function(e){let{value:u,done:g}=e;try{ensureNotTerminated();if(g){i||function(){const e=(0,a.arraysToBytes)(l);o.length&&e.length!==o.length&&(0,a.warn)("reported HTTP length is different from actual");try{i=new s.LocalPdfManager(w,e,o.password,k,t,r,S);n.resolve(i)}catch(e){n.reject(e)}l=[]}();f=null;return}d+=(0,a.arrayByteLength)(u);h.isStreamingSupported||k.send("DocProgress",{loaded:d,total:Math.max(d,h.contentLength||0)});i?i.sendProgressiveData(u):l.push(u);h.read().then(readChunk,c)}catch(e){c(e)}};h.read().then(readChunk,c)})).catch((function(e){n.reject(e);f=null}));f=function(e){c.cancelAllRequests(e)};return n.promise}k.on("GetPage",(function wphSetupGetPage(e){return r.getPage(e.pageIndex).then((function(e){return Promise.all([r.ensure(e,"rotate"),r.ensure(e,"ref"),r.ensure(e,"userUnit"),r.ensure(e,"view")]).then((function(e){let[t,r,a,n]=e;return{rotate:t,ref:r,userUnit:a,view:n}}))}))}));k.on("GetPageIndex",(function wphSetupGetPageIndex(e){const t=n.Ref.get(e.num,e.gen);return r.ensureCatalog("getPageIndex",[t])}));k.on("GetDestinations",(function wphSetupGetDestinations(e){return r.ensureCatalog("destinations")}));k.on("GetDestination",(function wphSetupGetDestination(e){return r.ensureCatalog("getDestination",[e.id])}));k.on("GetPageLabels",(function wphSetupGetPageLabels(e){return r.ensureCatalog("pageLabels")}));k.on("GetPageLayout",(function wphSetupGetPageLayout(e){return r.ensureCatalog("pageLayout")}));k.on("GetPageMode",(function wphSetupGetPageMode(e){return r.ensureCatalog("pageMode")}));k.on("GetViewerPreferences",(function(e){return r.ensureCatalog("viewerPreferences")}));k.on("GetOpenAction",(function(e){return r.ensureCatalog("openAction")}));k.on("GetAttachments",(function wphSetupGetAttachments(e){return r.ensureCatalog("attachments")}));k.on("GetJavaScript",(function wphSetupGetJavaScript(e){return r.ensureCatalog("javaScript")}));k.on("GetDocJSActions",(function wphSetupGetDocJSActions(e){return r.ensureCatalog("jsActions")}));k.on("GetPageJSActions",(function(e){let{pageIndex:t}=e;return r.getPage(t).then((function(e){return r.ensure(e,"jsActions")}))}));k.on("GetOutline",(function wphSetupGetOutline(e){return r.ensureCatalog("documentOutline")}));k.on("GetOptionalContentConfig",(function(e){return r.ensureCatalog("optionalContentConfig")}));k.on("GetPermissions",(function(e){return r.ensureCatalog("permissions")}));k.on("GetMetadata",(function wphSetupGetMetadata(e){return Promise.all([r.ensureDoc("documentInfo"),r.ensureCatalog("metadata")])}));k.on("GetMarkInfo",(function wphSetupGetMarkInfo(e){return r.ensureCatalog("markInfo")}));k.on("GetData",(function wphSetupGetData(e){r.requestLoadedStream();return r.onLoadedStream().then((function(e){return e.bytes}))}));k.on("GetAnnotations",(function(e){let{pageIndex:t,intent:a}=e;return r.getPage(t).then((function(e){const r=new WorkerTask(`GetAnnotations: page ${t}`);startWorkerTask(r);return e.getAnnotationsData(k,r,a).then((e=>{finishWorkerTask(r);return e}),(e=>{finishWorkerTask(r)}))}))}));k.on("GetFieldObjects",(function(e){return r.ensureDoc("fieldObjects")}));k.on("HasJSActions",(function(e){return r.ensureDoc("hasJSActions")}));k.on("GetCalculationOrderIds",(function(e){return r.ensureDoc("calculationOrderIds")}));k.on("SaveDocument",(function(e){let{isPureXfa:t,numPages:s,annotationStorage:o,filename:l}=e;r.requestLoadedStream();const h=t?null:(0,i.getNewAnnotationsMap)(o),u=[r.onLoadedStream(),r.ensureCatalog("acroForm"),r.ensureCatalog("acroFormRef"),r.ensureDoc("xref"),r.ensureDoc("startXRef")];if(h)for(const[e,t]of h)u.push(r.getPage(e).then((r=>{const a=new WorkerTask(`Save (editor): page ${e}`);return r.saveNewAnnotations(k,a,t).finally((function(){finishWorkerTask(a)}))})));if(t)u.push(r.serializeXfaData(o));else for(let e=0;e<s;e++)u.push(r.getPage(e).then((function(t){const r=new WorkerTask(`Save: page ${e}`);return t.save(k,r,o).finally((function(){finishWorkerTask(r)}))})));return Promise.all(u).then((function(e){let[r,i,s,o,h,...u]=e,d=[],f=null;if(t){f=u[0];if(!f)return r.bytes}else{d=u.flat(2);if(0===d.length)return r.bytes}const g=i instanceof n.Dict&&i.get("XFA")||null;let p=null,m=!1;if(Array.isArray(g)){for(let e=0,t=g.length;e<t;e+=2)if("datasets"===g[e]){p=g[e+1];s=null;m=!0}null===p&&(p=o.getNewRef())}else if(g){s=null;(0,a.warn)("Unsupported XFA type.")}let b=Object.create(null);if(o.trailer){const e=Object.create(null),t=o.trailer.get("Info")||null;t instanceof n.Dict&&t.forEach(((t,r)=>{"string"==typeof r&&(e[t]=(0,a.stringToPDFString)(r))}));b={rootRef:o.trailer.getRaw("Root")||null,encryptRef:o.trailer.getRaw("Encrypt")||null,newRef:o.getNewRef(),infoRef:o.trailer.getRaw("Info")||null,info:e,fileIds:o.trailer.get("ID")||null,startXRef:h,filename:l}}o.resetNewRef();return(0,c.incrementalUpdate)({originalData:r.bytes,xrefInfo:b,newRefs:d,xref:o,hasXfa:!!g,xfaDatasetsRef:p,hasXfaDatasetsEntry:m,acroFormRef:s,acroForm:i,xfaData:f})}))}));k.on("GetOperatorList",(function wphSetupRenderPage(e,t){const n=e.pageIndex;r.getPage(n).then((function(r){const i=new WorkerTask(`GetOperatorList: page ${n}`);startWorkerTask(i);const s=p>=a.VerbosityLevel.INFOS?Date.now():0;r.getOperatorList({handler:k,sink:t,task:i,intent:e.intent,cacheKey:e.cacheKey,annotationStorage:e.annotationStorage}).then((function(e){finishWorkerTask(i);s&&(0,a.info)(`page=${n+1} - getOperatorList: time=${Date.now()-s}ms, len=${e.length}`);t.close()}),(function(e){finishWorkerTask(i);if(!i.terminated){k.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorOperatorList});t.error(e)}}))}))}));k.on("GetTextContent",(function wphExtractText(e,t){const n=e.pageIndex;r.getPage(n).then((function(r){const i=new WorkerTask("GetTextContent: page "+n);startWorkerTask(i);const s=p>=a.VerbosityLevel.INFOS?Date.now():0;r.extractTextContent({handler:k,task:i,sink:t,includeMarkedContent:e.includeMarkedContent,combineTextItems:e.combineTextItems}).then((function(){finishWorkerTask(i);s&&(0,a.info)(`page=${n+1} - getTextContent: time=`+(Date.now()-s)+"ms");t.close()}),(function(e){finishWorkerTask(i);i.terminated||t.error(e)}))}))}));k.on("GetStructTree",(function wphGetStructTree(e){return r.getPage(e.pageIndex).then((function(e){return r.ensure(e,"getStructTree")}))}));k.on("FontFallback",(function(e){return r.fontFallback(e.id,k)}));k.on("Cleanup",(function wphCleanup(e){return r.cleanup(!0)}));k.on("Terminate",(function wphTerminate(e){d=!0;const t=[];if(r){r.terminate(new a.AbortException("Worker was terminated."));const e=r.cleanup();t.push(e);r=null}else(0,o.clearGlobalCaches)();f&&f(new a.AbortException("Worker was terminated."));for(const e of g){t.push(e.finished);e.terminate()}return Promise.all(t).then((function(){k.destroy();k=null}))}));k.on("Ready",(function wphReady(t){!function setupDoc(e){function onSuccess(e){ensureNotTerminated();k.send("GetDoc",{pdfInfo:e})}function onFailure(e){ensureNotTerminated();if(e instanceof a.PasswordException){const t=new WorkerTask(`PasswordException: response ${e.code}`);startWorkerTask(t);k.sendWithPromise("PasswordRequest",e).then((function(e){let{password:a}=e;finishWorkerTask(t);r.updatePassword(a);pdfManagerReady()})).catch((function(){finishWorkerTask(t);k.send("DocException",e)}))}else e instanceof a.InvalidPDFException||e instanceof a.MissingPDFException||e instanceof a.UnexpectedResponseException||e instanceof a.UnknownErrorException?k.send("DocException",e):k.send("DocException",new a.UnknownErrorException(e.message,e.toString()))}function pdfManagerReady(){ensureNotTerminated();loadDocument(!1).then(onSuccess,(function(e){ensureNotTerminated();if(e instanceof i.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,useSystemFonts:e.useSystemFonts,cMapUrl:e.cMapUrl,standardFontDataUrl:e.standardFontDataUrl},e.enableXfa).then((function(e){if(d){e.terminate(new a.AbortException("Worker was terminated."));throw new Error("Worker was terminated")}r=e;r.onLoadedStream().then((function(e){k.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(pdfManagerReady,onFailure)}(e);e=null}));return x}static initializeFromPort(e){const t=new h.MessageHandler("worker","main",e);WorkerMessageHandler.setup(t,e);t.send("ready",null)}}t.WorkerMessageHandler=WorkerMessageHandler;"undefined"==typeof window&&!l.isNodeJS&&"undefined"!=typeof self&&function isMessagePort(e){return"function"==typeof e.postMessage&&"onmessage"in e}(self)&&WorkerMessageHandler.initializeFromPort(self)},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.UNSUPPORTED_FEATURES=t.TextRenderingMode=t.StreamType=t.RenderingIntentFlag=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0;t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let a=0;a<t;a++)r+=arrayByteLength(e[a]);let a=0;const n=new Uint8Array(r);for(let r=0;r<t;r++){let t=e[r];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const i=t.byteLength;n.set(t,a);a+=i}return n};t.assert=function assert(e,t){e||unreachable(t)};t.bytesToString=function bytesToString(e){"object"==typeof e&&null!==e&&void 0!==e.length||unreachable("Invalid argument for bytesToString");const t=e.length,r=8192;if(t<r)return String.fromCharCode.apply(null,e);const a=[];for(let n=0;n<t;n+=r){const i=Math.min(n+r,t),s=e.subarray(n,i);a.push(String.fromCharCode.apply(null,s))}return a.join("")};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});e.promise=new Promise((function(r,a){e.resolve=function(e){t=!0;r(e)};e.reject=function(e){t=!0;a(e)}}));return e};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(!e)return null;try{if(r&&"string"==typeof e){if(r.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t&&t.length>=2&&(e=`http://${e}`)}if(r.tryConvertEncoding)try{e=stringToUTF8String(e)}catch(e){}}const a=t?new URL(e,t):new URL(e);if(_isValidProtocol(a))return a}catch(e){}return null};t.escapeString=function escapeString(e){return e.replace(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))};t.getModificationDate=function getModificationDate(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;const t=[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")];return t.join("")};t.getVerbosityLevel=function getVerbosityLevel(){return n};t.info=function info(e){n>=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;for(let r=0,a=e.length;r<a;r++)if(e[r]!==t[r])return!1;return!0};t.isAscii=function isAscii(e){return/^[\x00-\x7F]*$/.test(e)};t.objectFromMap=function objectFromMap(e){const t=Object.create(null);for(const[r,a]of e)t[r]=a;return t};t.objectSize=function objectSize(e){return Object.keys(e).length};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(n=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){if(e[0]>="ï"){let t;"þ"===e[0]&&"ÿ"===e[1]?t="utf-16be":"ÿ"===e[0]&&"þ"===e[1]?t="utf-16le":"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8");if(t)try{const r=new TextDecoder(t,{fatal:!0}),a=stringToBytes(e);return r.decode(a)}catch(e){warn(`stringToPDFString: "${e}".`)}}const t=[];for(let r=0,a=e.length;r<a;r++){const a=o[e.charCodeAt(r)];t.push(a?String.fromCharCode(a):e.charAt(r))}return t.join("")};t.stringToUTF16BEString=function stringToUTF16BEString(e){const t=["þÿ"];for(let r=0,a=e.length;r<a;r++){const a=e.charCodeAt(r);t.push(String.fromCharCode(a>>8&255),String.fromCharCode(255&a))}return t.join("")};t.stringToUTF8String=stringToUTF8String;t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;r(3);t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.LINE_FACTOR=1.35;t.LINE_DESCENT_FACTOR=.35;t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};t.AnnotationEditorPrefix="pdfjs_internal_editor_";t.AnnotationEditorType={DISABLE:-1,NONE:0,FREETEXT:3,INK:15};t.AnnotationEditorParamsType={FREETEXT_SIZE:1,FREETEXT_COLOR:2,FREETEXT_OPACITY:3,INK_COLOR:11,INK_THICKNESS:12,INK_OPACITY:13};t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};t.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"};t.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"};t.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};t.AnnotationReplyType={GROUP:"Group",REPLY:"R"};t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};t.PageActionEventType={O:"PageOpen",C:"PageClose"};t.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};t.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const a={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=a;t.CMapCompressionType={NONE:0,BINARY:1,STREAM:2};t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let n=a.WARNINGS;function warn(e){n>=a.WARNINGS&&console.log(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}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}}function shadow(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1});return r}const i=function BaseExceptionClosure(){function BaseException(e,t){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=i;t.PasswordException=class PasswordException extends i{constructor(e,t){super(e,"PasswordException");this.code=t}};t.UnknownErrorException=class UnknownErrorException extends i{constructor(e,t){super(e,"UnknownErrorException");this.details=t}};t.InvalidPDFException=class InvalidPDFException extends i{constructor(e){super(e,"InvalidPDFException")}};t.MissingPDFException=class MissingPDFException extends i{constructor(e){super(e,"MissingPDFException")}};t.UnexpectedResponseException=class UnexpectedResponseException extends i{constructor(e,t){super(e,"UnexpectedResponseException");this.status=t}};t.FormatError=class FormatError extends i{constructor(e){super(e,"FormatError")}};t.AbortException=class AbortException extends i{constructor(e){super(e,"AbortException")}};function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let a=0;a<t;++a)r[a]=255&e.charCodeAt(a);return r}function arrayByteLength(e){if(void 0!==e.length)return e.length;if(void 0!==e.byteLength)return e.byteLength;unreachable("Invalid argument for arrayByteLength")}t.FeatureTest=class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){return false;}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}};const s=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,r){return`#${s[e]}${s[t]}${s[r]}`}static scaleMinMax(e,t){let r;if(e[0]){if(e[0]<0){r=t[0];t[0]=t[1];t[1]=r}t[0]*=e[0];t[1]*=e[0];if(e[3]<0){r=t[2];t[2]=t[3];t[3]=r}t[2]*=e[3];t[3]*=e[3]}else{r=t[0];t[0]=t[2];t[2]=r;r=t[1];t[1]=t[3];t[3]=r;if(e[1]<0){r=t[2];t[2]=t[3];t[3]=r}t[2]*=e[1];t[3]*=e[1];if(e[2]<0){r=t[0];t[0]=t[1];t[1]=r}t[0]*=e[2];t[1]*=e[2]}t[0]+=e[4];t[1]+=e[4];t[2]+=e[5];t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const r=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/r,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/r]}static getAxialAlignedBoundingBox(e,t){const r=Util.applyTransform(e,t),a=Util.applyTransform(e.slice(2,4),t),n=Util.applyTransform([e[0],e[3]],t),i=Util.applyTransform([e[2],e[1]],t);return[Math.min(r[0],a[0],n[0],i[0]),Math.min(r[1],a[1],n[1],i[1]),Math.max(r[0],a[0],n[0],i[0]),Math.max(r[1],a[1],n[1],i[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static apply3dTransform(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],r=e[0]*t[0]+e[1]*t[2],a=e[0]*t[1]+e[1]*t[3],n=e[2]*t[0]+e[3]*t[2],i=e[2]*t[1]+e[3]*t[3],s=(r+i)/2,o=Math.sqrt((r+i)**2-4*(r*i-n*a))/2,c=s+o||1,l=s-o||1;return[Math.sqrt(c),Math.sqrt(l)]}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const r=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),a=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(r>a)return null;const n=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),i=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return n>i?null:[r,n,a,i]}static bezierBoundingBox(e,t,r,a,n,i,s,o){const c=[],l=[[],[]];let h,u,d,f,g,p,m,b;for(let l=0;l<2;++l){if(0===l){u=6*e-12*r+6*n;h=-3*e+9*r-9*n+3*s;d=3*r-3*e}else{u=6*t-12*a+6*i;h=-3*t+9*a-9*i+3*o;d=3*a-3*t}if(Math.abs(h)<1e-12){if(Math.abs(u)<1e-12)continue;f=-d/u;0<f&&f<1&&c.push(f)}else{m=u*u-4*d*h;b=Math.sqrt(m);if(!(m<0)){g=(-u+b)/(2*h);0<g&&g<1&&c.push(g);p=(-u-b)/(2*h);0<p&&p<1&&c.push(p)}}}let y,w=c.length;const S=w;for(;w--;){f=c[w];y=1-f;l[0][w]=y*y*y*e+3*y*y*f*r+3*y*f*f*n+f*f*f*s;l[1][w]=y*y*y*t+3*y*y*f*a+3*y*f*f*i+f*f*f*o}l[0][S]=e;l[1][S]=t;l[0][S+1]=s;l[1][S+1]=o;l[0].length=l[1].length=S+2;return[Math.min(...l[0]),Math.min(...l[1]),Math.max(...l[0]),Math.max(...l[1])]}}t.Util=Util;const o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToUTF8String(e){return decodeURIComponent(escape(e))}},(e,t,r)=>{"use strict";var a=r(4);if(!globalThis._pdfjsCompatibilityChecked){globalThis._pdfjsCompatibilityChecked=!0;!function checkNodeBtoa(){!globalThis.btoa&&a.isNodeJS&&(globalThis.btoa=function(e){return Buffer.from(e,"binary").toString("base64")})}();!function checkNodeAtob(){!globalThis.atob&&a.isNodeJS&&(globalThis.atob=function(e){return Buffer.from(e,"base64").toString("binary")})}();!function checkDOMMatrix(){!globalThis.DOMMatrix&&a.isNodeJS&&(globalThis.DOMMatrix=require("dommatrix/dist/dommatrix.js"))}();!function checkReadableStream(){!globalThis.ReadableStream&&a.isNodeJS&&(globalThis.ReadableStream=require("web-streams-polyfill/dist/ponyfill.js").ReadableStream)}();!function checkArrayAt(){Array.prototype.at||r(5)}();!function checkTypedArrayAt(){Uint8Array.prototype.at||r(77)}();!function checkStructuredClone(){globalThis.structuredClone||r(87)}()}},(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isNodeJS=void 0;const r=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=r},(e,t,r)=>{r(6);var a=r(76);e.exports=a("Array","at")},(e,t,r)=>{"use strict";var a=r(7),n=r(42),i=r(66),s=r(64),o=r(71);a({target:"Array",proto:!0},{at:function at(e){var t=n(this),r=i(t),a=s(e),o=a>=0?a:r+a;return o<0||o>=r?void 0:t[o]}});o("at")},(e,t,r)=>{var a=r(8),n=r(9).f,i=r(46),s=r(50),o=r(40),c=r(58),l=r(70);e.exports=function(e,t){var r,h,u,d,f,g=e.target,p=e.global,m=e.stat;if(r=p?a:m?a[g]||o(g,{}):(a[g]||{}).prototype)for(h in t){d=t[h];u=e.dontCallGetSet?(f=n(r,h))&&f.value:r[h];if(!l(p?h:g+(m?".":"#")+h,e.forced)&&void 0!==u){if(typeof d==typeof u)continue;c(d,u)}(e.sham||u&&u.sham)&&i(d,"sham",!0);s(r,h,d,e)}}},e=>{var check=function(e){return e&&e.Math==Math&&e};e.exports=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof global&&global)||function(){return this}()},(e,t,r)=>{var a=r(10),n=r(12),i=r(14),s=r(15),o=r(16),c=r(21),l=r(41),h=r(44),u=Object.getOwnPropertyDescriptor;t.f=a?u:function getOwnPropertyDescriptor(e,t){e=o(e);t=c(t);if(h)try{return u(e,t)}catch(e){}if(l(e,t))return s(!n(i.f,e,t),e[t])}},(e,t,r)=>{var a=r(11);e.exports=!a((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},e=>{e.exports=function(e){try{return!!e()}catch(e){return!0}}},(e,t,r)=>{var a=r(13),n=Function.prototype.call;e.exports=a?n.bind(n):function(){return n.apply(n,arguments)}},(e,t,r)=>{var a=r(11);e.exports=!a((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},(e,t)=>{"use strict";var r={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,n=a&&!r.call({1:2},1);t.f=n?function propertyIsEnumerable(e){var t=a(this,e);return!!t&&t.enumerable}:r},e=>{e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},(e,t,r)=>{var a=r(17),n=r(20);e.exports=function(e){return a(n(e))}},(e,t,r)=>{var a=r(18),n=r(11),i=r(19),s=Object,o=a("".split);e.exports=n((function(){return!s("z").propertyIsEnumerable(0)}))?function(e){return"String"==i(e)?o(e,""):s(e)}:s},(e,t,r)=>{var a=r(13),n=Function.prototype,i=n.bind,s=n.call,o=a&&i.bind(s,s);e.exports=a?function(e){return e&&o(e)}:function(e){return e&&function(){return s.apply(e,arguments)}}},(e,t,r)=>{var a=r(18),n=a({}.toString),i=a("".slice);e.exports=function(e){return i(n(e),8,-1)}},e=>{var t=TypeError;e.exports=function(e){if(null==e)throw t("Can't call method on "+e);return e}},(e,t,r)=>{var a=r(22),n=r(25);e.exports=function(e){var t=a(e,"string");return n(t)?t:t+""}},(e,t,r)=>{var a=r(12),n=r(23),i=r(25),s=r(32),o=r(35),c=r(36),l=TypeError,h=c("toPrimitive");e.exports=function(e,t){if(!n(e)||i(e))return e;var r,c=s(e,h);if(c){void 0===t&&(t="default");r=a(c,e,t);if(!n(r)||i(r))return r;throw l("Can't convert object to primitive value")}void 0===t&&(t="number");return o(e,t)}},(e,t,r)=>{var a=r(24);e.exports=function(e){return"object"==typeof e?null!==e:a(e)}},e=>{e.exports=function(e){return"function"==typeof e}},(e,t,r)=>{var a=r(26),n=r(24),i=r(27),s=r(28),o=Object;e.exports=s?function(e){return"symbol"==typeof e}:function(e){var t=a("Symbol");return n(t)&&i(t.prototype,o(e))}},(e,t,r)=>{var a=r(8),n=r(24),aFunction=function(e){return n(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?aFunction(a[e]):a[e]&&a[e][t]}},(e,t,r)=>{var a=r(18);e.exports=a({}.isPrototypeOf)},(e,t,r)=>{var a=r(29);e.exports=a&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},(e,t,r)=>{var a=r(30),n=r(11);e.exports=!!Object.getOwnPropertySymbols&&!n((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&a&&a<41}))},(e,t,r)=>{var a,n,i=r(8),s=r(31),o=i.process,c=i.Deno,l=o&&o.versions||c&&c.version,h=l&&l.v8;h&&(n=(a=h.split("."))[0]>0&&a[0]<4?1:+(a[0]+a[1]));!n&&s&&(!(a=s.match(/Edge\/(\d+)/))||a[1]>=74)&&(a=s.match(/Chrome\/(\d+)/))&&(n=+a[1]);e.exports=n},(e,t,r)=>{var a=r(26);e.exports=a("navigator","userAgent")||""},(e,t,r)=>{var a=r(33);e.exports=function(e,t){var r=e[t];return null==r?void 0:a(r)}},(e,t,r)=>{var a=r(24),n=r(34),i=TypeError;e.exports=function(e){if(a(e))return e;throw i(n(e)+" is not a function")}},e=>{var t=String;e.exports=function(e){try{return t(e)}catch(e){return"Object"}}},(e,t,r)=>{var a=r(12),n=r(24),i=r(23),s=TypeError;e.exports=function(e,t){var r,o;if("string"===t&&n(r=e.toString)&&!i(o=a(r,e)))return o;if(n(r=e.valueOf)&&!i(o=a(r,e)))return o;if("string"!==t&&n(r=e.toString)&&!i(o=a(r,e)))return o;throw s("Can't convert object to primitive value")}},(e,t,r)=>{var a=r(8),n=r(37),i=r(41),s=r(43),o=r(29),c=r(28),l=n("wks"),h=a.Symbol,u=h&&h.for,d=c?h:h&&h.withoutSetter||s;e.exports=function(e){if(!i(l,e)||!o&&"string"!=typeof l[e]){var t="Symbol."+e;o&&i(h,e)?l[e]=h[e]:l[e]=c&&u?u(t):d(t)}return l[e]}},(e,t,r)=>{var a=r(38),n=r(39);(e.exports=function(e,t){return n[e]||(n[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.24.1",mode:a?"pure":"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE",source:"https://github.com/zloirock/core-js"})},e=>{e.exports=!1},(e,t,r)=>{var a=r(8),n=r(40),i="__core-js_shared__",s=a[i]||n(i,{});e.exports=s},(e,t,r)=>{var a=r(8),n=Object.defineProperty;e.exports=function(e,t){try{n(a,e,{value:t,configurable:!0,writable:!0})}catch(r){a[e]=t}return t}},(e,t,r)=>{var a=r(18),n=r(42),i=a({}.hasOwnProperty);e.exports=Object.hasOwn||function hasOwn(e,t){return i(n(e),t)}},(e,t,r)=>{var a=r(20),n=Object;e.exports=function(e){return n(a(e))}},(e,t,r)=>{var a=r(18),n=0,i=Math.random(),s=a(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+s(++n+i,36)}},(e,t,r)=>{var a=r(10),n=r(11),i=r(45);e.exports=!a&&!n((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},(e,t,r)=>{var a=r(8),n=r(23),i=a.document,s=n(i)&&n(i.createElement);e.exports=function(e){return s?i.createElement(e):{}}},(e,t,r)=>{var a=r(10),n=r(47),i=r(15);e.exports=a?function(e,t,r){return n.f(e,t,i(1,r))}:function(e,t,r){e[t]=r;return e}},(e,t,r)=>{var a=r(10),n=r(44),i=r(48),s=r(49),o=r(21),c=TypeError,l=Object.defineProperty,h=Object.getOwnPropertyDescriptor,u="enumerable",d="configurable",f="writable";t.f=a?i?function defineProperty(e,t,r){s(e);t=o(t);s(r);if("function"==typeof e&&"prototype"===t&&"value"in r&&f in r&&!r.writable){var a=h(e,t);if(a&&a.writable){e[t]=r.value;r={configurable:d in r?r.configurable:a.configurable,enumerable:u in r?r.enumerable:a.enumerable,writable:!1}}}return l(e,t,r)}:l:function defineProperty(e,t,r){s(e);t=o(t);s(r);if(n)try{return l(e,t,r)}catch(e){}if("get"in r||"set"in r)throw c("Accessors not supported");"value"in r&&(e[t]=r.value);return e}},(e,t,r)=>{var a=r(10),n=r(11);e.exports=a&&n((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},(e,t,r)=>{var a=r(23),n=String,i=TypeError;e.exports=function(e){if(a(e))return e;throw i(n(e)+" is not an object")}},(e,t,r)=>{var a=r(24),n=r(47),i=r(51),s=r(40);e.exports=function(e,t,r,o){o||(o={});var c=o.enumerable,l=void 0!==o.name?o.name:t;a(r)&&i(r,l,o);if(o.global)c?e[t]=r:s(t,r);else{try{o.unsafe?e[t]&&(c=!0):delete e[t]}catch(e){}c?e[t]=r:n.f(e,t,{value:r,enumerable:!1,configurable:!o.nonConfigurable,writable:!o.nonWritable})}return e}},(e,t,r)=>{var a=r(11),n=r(24),i=r(41),s=r(10),o=r(52).CONFIGURABLE,c=r(53),l=r(54),h=l.enforce,u=l.get,d=Object.defineProperty,f=s&&!a((function(){return 8!==d((function(){}),"length",{value:8}).length})),g=String(String).split("String"),p=e.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]");r&&r.getter&&(t="get "+t);r&&r.setter&&(t="set "+t);(!i(e,"name")||o&&e.name!==t)&&(s?d(e,"name",{value:t,configurable:!0}):e.name=t);f&&r&&i(r,"arity")&&e.length!==r.arity&&d(e,"length",{value:r.arity});try{r&&i(r,"constructor")&&r.constructor?s&&d(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var a=h(e);i(a,"source")||(a.source=g.join("string"==typeof t?t:""));return e};Function.prototype.toString=p((function toString(){return n(this)&&u(this).source||c(this)}),"toString")},(e,t,r)=>{var a=r(10),n=r(41),i=Function.prototype,s=a&&Object.getOwnPropertyDescriptor,o=n(i,"name"),c=o&&"something"===function something(){}.name,l=o&&(!a||a&&s(i,"name").configurable);e.exports={EXISTS:o,PROPER:c,CONFIGURABLE:l}},(e,t,r)=>{var a=r(18),n=r(24),i=r(39),s=a(Function.toString);n(i.inspectSource)||(i.inspectSource=function(e){return s(e)});e.exports=i.inspectSource},(e,t,r)=>{var a,n,i,s=r(55),o=r(8),c=r(18),l=r(23),h=r(46),u=r(41),d=r(39),f=r(56),g=r(57),p="Object already initialized",m=o.TypeError,b=o.WeakMap;if(s||d.state){var y=d.state||(d.state=new b),w=c(y.get),S=c(y.has),x=c(y.set);a=function(e,t){if(S(y,e))throw new m(p);t.facade=e;x(y,e,t);return t};n=function(e){return w(y,e)||{}};i=function(e){return S(y,e)}}else{var k=f("state");g[k]=!0;a=function(e,t){if(u(e,k))throw new m(p);t.facade=e;h(e,k,t);return t};n=function(e){return u(e,k)?e[k]:{}};i=function(e){return u(e,k)}}e.exports={set:a,get:n,has:i,enforce:function(e){return i(e)?n(e):a(e,{})},getterFor:function(e){return function(t){var r;if(!l(t)||(r=n(t)).type!==e)throw m("Incompatible receiver, "+e+" required");return r}}}},(e,t,r)=>{var a=r(8),n=r(24),i=r(53),s=a.WeakMap;e.exports=n(s)&&/native code/.test(i(s))},(e,t,r)=>{var a=r(37),n=r(43),i=a("keys");e.exports=function(e){return i[e]||(i[e]=n(e))}},e=>{e.exports={}},(e,t,r)=>{var a=r(41),n=r(59),i=r(9),s=r(47);e.exports=function(e,t,r){for(var o=n(t),c=s.f,l=i.f,h=0;h<o.length;h++){var u=o[h];a(e,u)||r&&a(r,u)||c(e,u,l(t,u))}}},(e,t,r)=>{var a=r(26),n=r(18),i=r(60),s=r(69),o=r(49),c=n([].concat);e.exports=a("Reflect","ownKeys")||function ownKeys(e){var t=i.f(o(e)),r=s.f;return r?c(t,r(e)):t}},(e,t,r)=>{var a=r(61),n=r(68).concat("length","prototype");t.f=Object.getOwnPropertyNames||function getOwnPropertyNames(e){return a(e,n)}},(e,t,r)=>{var a=r(18),n=r(41),i=r(16),s=r(62).indexOf,o=r(57),c=a([].push);e.exports=function(e,t){var r,a=i(e),l=0,h=[];for(r in a)!n(o,r)&&n(a,r)&&c(h,r);for(;t.length>l;)n(a,r=t[l++])&&(~s(h,r)||c(h,r));return h}},(e,t,r)=>{var a=r(16),n=r(63),i=r(66),createMethod=function(e){return function(t,r,s){var o,c=a(t),l=i(c),h=n(s,l);if(e&&r!=r){for(;l>h;)if((o=c[h++])!=o)return!0}else for(;l>h;h++)if((e||h in c)&&c[h]===r)return e||h||0;return!e&&-1}};e.exports={includes:createMethod(!0),indexOf:createMethod(!1)}},(e,t,r)=>{var a=r(64),n=Math.max,i=Math.min;e.exports=function(e,t){var r=a(e);return r<0?n(r+t,0):i(r,t)}},(e,t,r)=>{var a=r(65);e.exports=function(e){var t=+e;return t!=t||0===t?0:a(t)}},e=>{var t=Math.ceil,r=Math.floor;e.exports=Math.trunc||function trunc(e){var a=+e;return(a>0?r:t)(a)}},(e,t,r)=>{var a=r(67);e.exports=function(e){return a(e.length)}},(e,t,r)=>{var a=r(64),n=Math.min;e.exports=function(e){return e>0?n(a(e),9007199254740991):0}},e=>{e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},(e,t)=>{t.f=Object.getOwnPropertySymbols},(e,t,r)=>{var a=r(11),n=r(24),i=/#|\.prototype\./,isForced=function(e,t){var r=o[s(e)];return r==l||r!=c&&(n(t)?a(t):!!t)},s=isForced.normalize=function(e){return String(e).replace(i,".").toLowerCase()},o=isForced.data={},c=isForced.NATIVE="N",l=isForced.POLYFILL="P";e.exports=isForced},(e,t,r)=>{var a=r(36),n=r(72),i=r(47).f,s=a("unscopables"),o=Array.prototype;null==o[s]&&i(o,s,{configurable:!0,value:n(null)});e.exports=function(e){o[s][e]=!0}},(e,t,r)=>{var a,n=r(49),i=r(73),s=r(68),o=r(57),c=r(75),l=r(45),h=r(56),u=h("IE_PROTO"),EmptyConstructor=function(){},scriptTag=function(e){return"<script>"+e+"</"+"script>"},NullProtoObjectViaActiveX=function(e){e.write(scriptTag(""));e.close();var t=e.parentWindow.Object;e=null;return t},NullProtoObject=function(){try{a=new ActiveXObject("htmlfile")}catch(e){}NullProtoObject="undefined"!=typeof document?document.domain&&a?NullProtoObjectViaActiveX(a):function(){var e,t=l("iframe");t.style.display="none";c.appendChild(t);t.src=String("javascript:");(e=t.contentWindow.document).open();e.write(scriptTag("document.F=Object"));e.close();return e.F}():NullProtoObjectViaActiveX(a);for(var e=s.length;e--;)delete NullProtoObject.prototype[s[e]];return NullProtoObject()};o[u]=!0;e.exports=Object.create||function create(e,t){var r;if(null!==e){EmptyConstructor.prototype=n(e);r=new EmptyConstructor;EmptyConstructor.prototype=null;r[u]=e}else r=NullProtoObject();return void 0===t?r:i.f(r,t)}},(e,t,r)=>{var a=r(10),n=r(48),i=r(47),s=r(49),o=r(16),c=r(74);t.f=a&&!n?Object.defineProperties:function defineProperties(e,t){s(e);for(var r,a=o(t),n=c(t),l=n.length,h=0;l>h;)i.f(e,r=n[h++],a[r]);return e}},(e,t,r)=>{var a=r(61),n=r(68);e.exports=Object.keys||function keys(e){return a(e,n)}},(e,t,r)=>{var a=r(26);e.exports=a("document","documentElement")},(e,t,r)=>{var a=r(8),n=r(18);e.exports=function(e,t){return n(a[e].prototype[t])}},(e,t,r)=>{r(78)},(e,t,r)=>{"use strict";var a=r(79),n=r(66),i=r(64),s=a.aTypedArray;(0,a.exportTypedArrayMethod)("at",(function at(e){var t=s(this),r=n(t),a=i(e),o=a>=0?a:r+a;return o<0||o>=r?void 0:t[o]}))},(e,t,r)=>{"use strict";var a,n,i,s=r(80),o=r(10),c=r(8),l=r(24),h=r(23),u=r(41),d=r(81),f=r(34),g=r(46),p=r(50),m=r(47).f,b=r(27),y=r(83),w=r(85),S=r(36),x=r(43),k=r(54),C=k.enforce,v=k.get,O=c.Int8Array,T=O&&O.prototype,M=c.Uint8ClampedArray,E=M&&M.prototype,D=O&&y(O),N=T&&y(T),R=Object.prototype,L=c.TypeError,j=S("toStringTag"),$=x("TYPED_ARRAY_TAG"),_="TypedArrayConstructor",U=s&&!!w&&"Opera"!==d(c.opera),X=!1,H={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},q={BigInt64Array:8,BigUint64Array:8},getTypedArrayConstructor=function(e){var t=y(e);if(h(t)){var r=v(t);return r&&u(r,_)?r.TypedArrayConstructor:getTypedArrayConstructor(t)}},isTypedArray=function(e){if(!h(e))return!1;var t=d(e);return u(H,t)||u(q,t)};for(a in H)(i=(n=c[a])&&n.prototype)?C(i).TypedArrayConstructor=n:U=!1;for(a in q)(i=(n=c[a])&&n.prototype)&&(C(i).TypedArrayConstructor=n);if(!U||!l(D)||D===Function.prototype){D=function TypedArray(){throw L("Incorrect invocation")};if(U)for(a in H)c[a]&&w(c[a],D)}if(!U||!N||N===R){N=D.prototype;if(U)for(a in H)c[a]&&w(c[a].prototype,N)}U&&y(E)!==N&&w(E,N);if(o&&!u(N,j)){X=!0;m(N,j,{get:function(){return h(this)?this[$]:void 0}});for(a in H)c[a]&&g(c[a],$,a)}e.exports={NATIVE_ARRAY_BUFFER_VIEWS:U,TYPED_ARRAY_TAG:X&&$,aTypedArray:function(e){if(isTypedArray(e))return e;throw L("Target is not a typed array")},aTypedArrayConstructor:function(e){if(l(e)&&(!w||b(D,e)))return e;throw L(f(e)+" is not a typed array constructor")},exportTypedArrayMethod:function(e,t,r,a){if(o){if(r)for(var n in H){var i=c[n];if(i&&u(i.prototype,e))try{delete i.prototype[e]}catch(r){try{i.prototype[e]=t}catch(e){}}}N[e]&&!r||p(N,e,r?t:U&&T[e]||t,a)}},exportTypedArrayStaticMethod:function(e,t,r){var a,n;if(o){if(w){if(r)for(a in H)if((n=c[a])&&u(n,e))try{delete n[e]}catch(e){}if(D[e]&&!r)return;try{return p(D,e,r?t:U&&D[e]||t)}catch(e){}}for(a in H)!(n=c[a])||n[e]&&!r||p(n,e,t)}},getTypedArrayConstructor:getTypedArrayConstructor,isView:function isView(e){if(!h(e))return!1;var t=d(e);return"DataView"===t||u(H,t)||u(q,t)},isTypedArray:isTypedArray,TypedArray:D,TypedArrayPrototype:N}},e=>{e.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},(e,t,r)=>{var a=r(82),n=r(24),i=r(19),s=r(36)("toStringTag"),o=Object,c="Arguments"==i(function(){return arguments}());e.exports=a?i:function(e){var t,r,a;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=function(e,t){try{return e[t]}catch(e){}}(t=o(e),s))?r:c?i(t):"Object"==(a=i(t))&&n(t.callee)?"Arguments":a}},(e,t,r)=>{var a={};a[r(36)("toStringTag")]="z";e.exports="[object z]"===String(a)},(e,t,r)=>{var a=r(41),n=r(24),i=r(42),s=r(56),o=r(84),c=s("IE_PROTO"),l=Object,h=l.prototype;e.exports=o?l.getPrototypeOf:function(e){var t=i(e);if(a(t,c))return t[c];var r=t.constructor;return n(r)&&t instanceof r?r.prototype:t instanceof l?h:null}},(e,t,r)=>{var a=r(11);e.exports=!a((function(){function F(){}F.prototype.constructor=null;return Object.getPrototypeOf(new F)!==F.prototype}))},(e,t,r)=>{var a=r(18),n=r(49),i=r(86);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{(e=a(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(r,[]);t=r instanceof Array}catch(e){}return function setPrototypeOf(r,a){n(r);i(a);t?e(r,a):r.__proto__=a;return r}}():void 0)},(e,t,r)=>{var a=r(24),n=String,i=TypeError;e.exports=function(e){if("object"==typeof e||a(e))return e;throw i("Can't set "+n(e)+" as a prototype")}},(e,t,r)=>{r(88);r(94);r(96);r(118);r(120);var a=r(129);e.exports=a.structuredClone},(e,t,r)=>{"use strict";var a=r(16),n=r(71),i=r(89),s=r(54),o=r(47).f,c=r(90),l=r(38),h=r(10),u="Array Iterator",d=s.set,f=s.getterFor(u);e.exports=c(Array,"Array",(function(e,t){d(this,{type:u,target:a(e),index:0,kind:t})}),(function(){var e=f(this),t=e.target,r=e.kind,a=e.index++;if(!t||a>=t.length){e.target=void 0;return{value:void 0,done:!0}}return"keys"==r?{value:a,done:!1}:"values"==r?{value:t[a],done:!1}:{value:[a,t[a]],done:!1}}),"values");var g=i.Arguments=i.Array;n("keys");n("values");n("entries");if(!l&&h&&"values"!==g.name)try{o(g,"name",{value:"values"})}catch(e){}},e=>{e.exports={}},(e,t,r)=>{"use strict";var a=r(7),n=r(12),i=r(38),s=r(52),o=r(24),c=r(91),l=r(83),h=r(85),u=r(93),d=r(46),f=r(50),g=r(36),p=r(89),m=r(92),b=s.PROPER,y=s.CONFIGURABLE,w=m.IteratorPrototype,S=m.BUGGY_SAFARI_ITERATORS,x=g("iterator"),k="keys",C="values",v="entries",returnThis=function(){return this};e.exports=function(e,t,r,s,g,m,O){c(r,t,s);var T,M,E,getIterationMethod=function(e){if(e===g&&j)return j;if(!S&&e in R)return R[e];switch(e){case k:return function keys(){return new r(this,e)};case C:return function values(){return new r(this,e)};case v:return function entries(){return new r(this,e)}}return function(){return new r(this)}},D=t+" Iterator",N=!1,R=e.prototype,L=R[x]||R["@@iterator"]||g&&R[g],j=!S&&L||getIterationMethod(g),$="Array"==t&&R.entries||L;if($&&(T=l($.call(new e)))!==Object.prototype&&T.next){i||l(T)===w||(h?h(T,w):o(T[x])||f(T,x,returnThis));u(T,D,!0,!0);i&&(p[D]=returnThis)}if(b&&g==C&&L&&L.name!==C)if(!i&&y)d(R,"name",C);else{N=!0;j=function values(){return n(L,this)}}if(g){M={values:getIterationMethod(C),keys:m?j:getIterationMethod(k),entries:getIterationMethod(v)};if(O)for(E in M)(S||N||!(E in R))&&f(R,E,M[E]);else a({target:t,proto:!0,forced:S||N},M)}i&&!O||R[x]===j||f(R,x,j,{name:g});p[t]=j;return M}},(e,t,r)=>{"use strict";var a=r(92).IteratorPrototype,n=r(72),i=r(15),s=r(93),o=r(89),returnThis=function(){return this};e.exports=function(e,t,r,c){var l=t+" Iterator";e.prototype=n(a,{next:i(+!c,r)});s(e,l,!1,!0);o[l]=returnThis;return e}},(e,t,r)=>{"use strict";var a,n,i,s=r(11),o=r(24),c=r(72),l=r(83),h=r(50),u=r(36),d=r(38),f=u("iterator"),g=!1;[].keys&&("next"in(i=[].keys())?(n=l(l(i)))!==Object.prototype&&(a=n):g=!0);null==a||s((function(){var e={};return a[f].call(e)!==e}))?a={}:d&&(a=c(a));o(a[f])||h(a,f,(function(){return this}));e.exports={IteratorPrototype:a,BUGGY_SAFARI_ITERATORS:g}},(e,t,r)=>{var a=r(47).f,n=r(41),i=r(36)("toStringTag");e.exports=function(e,t,r){e&&!r&&(e=e.prototype);e&&!n(e,i)&&a(e,i,{configurable:!0,value:t})}},(e,t,r)=>{var a=r(82),n=r(50),i=r(95);a||n(Object.prototype,"toString",i,{unsafe:!0})},(e,t,r)=>{"use strict";var a=r(82),n=r(81);e.exports=a?{}.toString:function toString(){return"[object "+n(this)+"]"}},(e,t,r)=>{r(97)},(e,t,r)=>{"use strict";r(98)("Map",(function(e){return function Map(){return e(this,arguments.length?arguments[0]:void 0)}}),r(115))},(e,t,r)=>{"use strict";var a=r(7),n=r(8),i=r(18),s=r(70),o=r(50),c=r(99),l=r(106),h=r(112),u=r(24),d=r(23),f=r(11),g=r(113),p=r(93),m=r(114);e.exports=function(e,t,r){var b=-1!==e.indexOf("Map"),y=-1!==e.indexOf("Weak"),w=b?"set":"add",S=n[e],x=S&&S.prototype,k=S,C={},fixMethod=function(e){var t=i(x[e]);o(x,e,"add"==e?function add(e){t(this,0===e?0:e);return this}:"delete"==e?function(e){return!(y&&!d(e))&&t(this,0===e?0:e)}:"get"==e?function get(e){return y&&!d(e)?void 0:t(this,0===e?0:e)}:"has"==e?function has(e){return!(y&&!d(e))&&t(this,0===e?0:e)}:function set(e,r){t(this,0===e?0:e,r);return this})};if(s(e,!u(S)||!(y||x.forEach&&!f((function(){(new S).entries().next()}))))){k=r.getConstructor(t,e,b,w);c.enable()}else if(s(e,!0)){var v=new k,O=v[w](y?{}:-0,1)!=v,T=f((function(){v.has(1)})),M=g((function(e){new S(e)})),E=!y&&f((function(){for(var e=new S,t=5;t--;)e[w](t,t);return!e.has(-0)}));if(!M){(k=t((function(e,t){h(e,x);var r=m(new S,e,k);null!=t&&l(t,r[w],{that:r,AS_ENTRIES:b});return r}))).prototype=x;x.constructor=k}if(T||E){fixMethod("delete");fixMethod("has");b&&fixMethod("get")}(E||O)&&fixMethod(w);y&&x.clear&&delete x.clear}C[e]=k;a({global:!0,constructor:!0,forced:k!=S},C);p(k,e);y||r.setStrong(k,e,b);return k}},(e,t,r)=>{var a=r(7),n=r(18),i=r(57),s=r(23),o=r(41),c=r(47).f,l=r(60),h=r(100),u=r(103),d=r(43),f=r(105),g=!1,p=d("meta"),m=0,setMetadata=function(e){c(e,p,{value:{objectID:"O"+m++,weakData:{}}})},b=e.exports={enable:function(){b.enable=function(){};g=!0;var e=l.f,t=n([].splice),r={};r[p]=1;if(e(r).length){l.f=function(r){for(var a=e(r),n=0,i=a.length;n<i;n++)if(a[n]===p){t(a,n,1);break}return a};a({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:h.f})}},fastKey:function(e,t){if(!s(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!o(e,p)){if(!u(e))return"F";if(!t)return"E";setMetadata(e)}return e[p].objectID},getWeakData:function(e,t){if(!o(e,p)){if(!u(e))return!0;if(!t)return!1;setMetadata(e)}return e[p].weakData},onFreeze:function(e){f&&g&&u(e)&&!o(e,p)&&setMetadata(e);return e}};i[p]=!0},(e,t,r)=>{var a=r(19),n=r(16),i=r(60).f,s=r(101),o="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];e.exports.f=function getOwnPropertyNames(e){return o&&"Window"==a(e)?function(e){try{return i(e)}catch(e){return s(o)}}(e):i(n(e))}},(e,t,r)=>{var a=r(63),n=r(66),i=r(102),s=Array,o=Math.max;e.exports=function(e,t,r){for(var c=n(e),l=a(t,c),h=a(void 0===r?c:r,c),u=s(o(h-l,0)),d=0;l<h;l++,d++)i(u,d,e[l]);u.length=d;return u}},(e,t,r)=>{"use strict";var a=r(21),n=r(47),i=r(15);e.exports=function(e,t,r){var s=a(t);s in e?n.f(e,s,i(0,r)):e[s]=r}},(e,t,r)=>{var a=r(11),n=r(23),i=r(19),s=r(104),o=Object.isExtensible,c=a((function(){o(1)}));e.exports=c||s?function isExtensible(e){return!!n(e)&&((!s||"ArrayBuffer"!=i(e))&&(!o||o(e)))}:o},(e,t,r)=>{var a=r(11);e.exports=a((function(){if("function"==typeof ArrayBuffer){var e=new ArrayBuffer(8);Object.isExtensible(e)&&Object.defineProperty(e,"a",{value:8})}}))},(e,t,r)=>{var a=r(11);e.exports=!a((function(){return Object.isExtensible(Object.preventExtensions({}))}))},(e,t,r)=>{var a=r(107),n=r(12),i=r(49),s=r(34),o=r(108),c=r(66),l=r(27),h=r(109),u=r(110),d=r(111),f=TypeError,Result=function(e,t){this.stopped=e;this.result=t},g=Result.prototype;e.exports=function(e,t,r){var p,m,b,y,w,S,x,k=r&&r.that,C=!(!r||!r.AS_ENTRIES),v=!(!r||!r.IS_RECORD),O=!(!r||!r.IS_ITERATOR),T=!(!r||!r.INTERRUPTED),M=a(t,k),stop=function(e){p&&d(p,"normal",e);return new Result(!0,e)},callFn=function(e){if(C){i(e);return T?M(e[0],e[1],stop):M(e[0],e[1])}return T?M(e,stop):M(e)};if(v)p=e.iterator;else if(O)p=e;else{if(!(m=u(e)))throw f(s(e)+" is not iterable");if(o(m)){for(b=0,y=c(e);y>b;b++)if((w=callFn(e[b]))&&l(g,w))return w;return new Result(!1)}p=h(e,m)}S=v?e.next:p.next;for(;!(x=n(S,p)).done;){try{w=callFn(x.value)}catch(e){d(p,"throw",e)}if("object"==typeof w&&w&&l(g,w))return w}return new Result(!1)}},(e,t,r)=>{var a=r(18),n=r(33),i=r(13),s=a(a.bind);e.exports=function(e,t){n(e);return void 0===t?e:i?s(e,t):function(){return e.apply(t,arguments)}}},(e,t,r)=>{var a=r(36),n=r(89),i=a("iterator"),s=Array.prototype;e.exports=function(e){return void 0!==e&&(n.Array===e||s[i]===e)}},(e,t,r)=>{var a=r(12),n=r(33),i=r(49),s=r(34),o=r(110),c=TypeError;e.exports=function(e,t){var r=arguments.length<2?o(e):t;if(n(r))return i(a(r,e));throw c(s(e)+" is not iterable")}},(e,t,r)=>{var a=r(81),n=r(32),i=r(89),s=r(36)("iterator");e.exports=function(e){if(null!=e)return n(e,s)||n(e,"@@iterator")||i[a(e)]}},(e,t,r)=>{var a=r(12),n=r(49),i=r(32);e.exports=function(e,t,r){var s,o;n(e);try{if(!(s=i(e,"return"))){if("throw"===t)throw r;return r}s=a(s,e)}catch(e){o=!0;s=e}if("throw"===t)throw r;if(o)throw s;n(s);return r}},(e,t,r)=>{var a=r(27),n=TypeError;e.exports=function(e,t){if(a(t,e))return e;throw n("Incorrect invocation")}},(e,t,r)=>{var a=r(36)("iterator"),n=!1;try{var i=0,s={next:function(){return{done:!!i++}},return:function(){n=!0}};s[a]=function(){return this};Array.from(s,(function(){throw 2}))}catch(e){}e.exports=function(e,t){if(!t&&!n)return!1;var r=!1;try{var i={};i[a]=function(){return{next:function(){return{done:r=!0}}}};e(i)}catch(e){}return r}},(e,t,r)=>{var a=r(24),n=r(23),i=r(85);e.exports=function(e,t,r){var s,o;i&&a(s=t.constructor)&&s!==r&&n(o=s.prototype)&&o!==r.prototype&&i(e,o);return e}},(e,t,r)=>{"use strict";var a=r(47).f,n=r(72),i=r(116),s=r(107),o=r(112),c=r(106),l=r(90),h=r(117),u=r(10),d=r(99).fastKey,f=r(54),g=f.set,p=f.getterFor;e.exports={getConstructor:function(e,t,r,l){var h=e((function(e,a){o(e,f);g(e,{type:t,index:n(null),first:void 0,last:void 0,size:0});u||(e.size=0);null!=a&&c(a,e[l],{that:e,AS_ENTRIES:r})})),f=h.prototype,m=p(t),define=function(e,t,r){var a,n,i=m(e),s=getEntry(e,t);if(s)s.value=r;else{i.last=s={index:n=d(t,!0),key:t,value:r,previous:a=i.last,next:void 0,removed:!1};i.first||(i.first=s);a&&(a.next=s);u?i.size++:e.size++;"F"!==n&&(i.index[n]=s)}return e},getEntry=function(e,t){var r,a=m(e),n=d(t);if("F"!==n)return a.index[n];for(r=a.first;r;r=r.next)if(r.key==t)return r};i(f,{clear:function clear(){for(var e=m(this),t=e.index,r=e.first;r;){r.removed=!0;r.previous&&(r.previous=r.previous.next=void 0);delete t[r.index];r=r.next}e.first=e.last=void 0;u?e.size=0:this.size=0},delete:function(e){var t=this,r=m(t),a=getEntry(t,e);if(a){var n=a.next,i=a.previous;delete r.index[a.index];a.removed=!0;i&&(i.next=n);n&&(n.previous=i);r.first==a&&(r.first=n);r.last==a&&(r.last=i);u?r.size--:t.size--}return!!a},forEach:function forEach(e){for(var t,r=m(this),a=s(e,arguments.length>1?arguments[1]:void 0);t=t?t.next:r.first;){a(t.value,t.key,this);for(;t&&t.removed;)t=t.previous}},has:function has(e){return!!getEntry(this,e)}});i(f,r?{get:function get(e){var t=getEntry(this,e);return t&&t.value},set:function set(e,t){return define(this,0===e?0:e,t)}}:{add:function add(e){return define(this,e=0===e?0:e,e)}});u&&a(f,"size",{get:function(){return m(this).size}});return h},setStrong:function(e,t,r){var a=t+" Iterator",n=p(t),i=p(a);l(e,t,(function(e,t){g(this,{type:a,target:e,state:n(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,r=e.last;r&&r.removed;)r=r.previous;if(!e.target||!(e.last=r=r?r.next:e.state.first)){e.target=void 0;return{value:void 0,done:!0}}return"keys"==t?{value:r.key,done:!1}:"values"==t?{value:r.value,done:!1}:{value:[r.key,r.value],done:!1}}),r?"entries":"values",!r,!0);h(t)}}},(e,t,r)=>{var a=r(50);e.exports=function(e,t,r){for(var n in t)a(e,n,t[n],r);return e}},(e,t,r)=>{"use strict";var a=r(26),n=r(47),i=r(36),s=r(10),o=i("species");e.exports=function(e){var t=a(e),r=n.f;s&&t&&!t[o]&&r(t,o,{configurable:!0,get:function(){return this}})}},(e,t,r)=>{r(119)},(e,t,r)=>{"use strict";r(98)("Set",(function(e){return function Set(){return e(this,arguments.length?arguments[0]:void 0)}}),r(115))},(e,t,r)=>{var a,n=r(38),i=r(7),s=r(8),o=r(26),c=r(18),l=r(11),h=r(43),u=r(24),d=r(121),f=r(23),g=r(25),p=r(106),m=r(49),b=r(81),y=r(41),w=r(102),S=r(46),x=r(66),k=r(122),C=r(123),v=r(125),O=r(30),T=r(126),M=r(127),E=r(128),D=s.Object,N=s.Date,R=s.Error,L=s.EvalError,j=s.RangeError,$=s.ReferenceError,_=s.SyntaxError,U=s.TypeError,X=s.URIError,H=s.PerformanceMark,q=s.WebAssembly,z=q&&q.CompileError||R,W=q&&q.LinkError||R,G=q&&q.RuntimeError||R,V=o("DOMException"),K=o("Set"),Y=o("Map"),J=Y.prototype,Z=c(J.has),Q=c(J.get),ee=c(J.set),te=c(K.prototype.add),re=o("Object","keys"),ae=c([].push),ne=c((!0).valueOf),ie=c(1..valueOf),se=c("".valueOf),oe=c(N.prototype.getTime),ce=h("structuredClone"),le="DataCloneError",he="Transferring",checkBasicSemantic=function(e){return!l((function(){var t=new s.Set([7]),r=e(t),a=e(D(7));return r==t||!r.has(7)||"object"!=typeof a||7!=a}))&&e},checkErrorsCloning=function(e,t){return!l((function(){var r=new t,a=e({a:r,b:r});return!(a&&a.a===a.b&&a.a instanceof t&&a.a.stack===r.stack)}))},ue=s.structuredClone,de=n||!checkErrorsCloning(ue,R)||!checkErrorsCloning(ue,V)||!(a=ue,!l((function(){var e=a(new s.AggregateError([1],ce,{cause:3}));return"AggregateError"!=e.name||1!=e.errors[0]||e.message!=ce||3!=e.cause}))),fe=!ue&&checkBasicSemantic((function(e){return new H(ce,{detail:e}).detail})),ge=checkBasicSemantic(ue)||fe,throwUncloneable=function(e){throw new V("Uncloneable type: "+e,le)},throwUnpolyfillable=function(e,t){throw new V((t||"Cloning")+" of "+e+" cannot be properly polyfilled in this engine",le)},structuredCloneInternal=function(e,t){g(e)&&throwUncloneable("Symbol");if(!f(e))return e;if(t){if(Z(t,e))return Q(t,e)}else t=new Y;var r,a,n,i,c,l,h,p,m,k,O=b(e),T=!1;switch(O){case"Array":n=[];T=!0;break;case"Object":n={};T=!0;break;case"Map":n=new Y;T=!0;break;case"Set":n=new K;T=!0;break;case"RegExp":n=new RegExp(e.source,C(e));break;case"Error":switch(a=e.name){case"AggregateError":n=o("AggregateError")([]);break;case"EvalError":n=L();break;case"RangeError":n=j();break;case"ReferenceError":n=$();break;case"SyntaxError":n=_();break;case"TypeError":n=U();break;case"URIError":n=X();break;case"CompileError":n=z();break;case"LinkError":n=W();break;case"RuntimeError":n=G();break;default:n=R()}T=!0;break;case"DOMException":n=new V(e.message,e.name);T=!0;break;case"DataView":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":r=s[O];f(r)||throwUnpolyfillable(O);n=new r(structuredCloneInternal(e.buffer,t),e.byteOffset,"DataView"===O?e.byteLength:e.length);break;case"DOMQuad":try{n=new DOMQuad(structuredCloneInternal(e.p1,t),structuredCloneInternal(e.p2,t),structuredCloneInternal(e.p3,t),structuredCloneInternal(e.p4,t))}catch(t){ge?n=ge(e):throwUnpolyfillable(O)}break;case"FileList":r=s.DataTransfer;if(d(r)){i=new r;for(c=0,l=x(e);c<l;c++)i.items.add(structuredCloneInternal(e[c],t));n=i.files}else ge?n=ge(e):throwUnpolyfillable(O);break;case"ImageData":try{n=new ImageData(structuredCloneInternal(e.data,t),e.width,e.height,{colorSpace:e.colorSpace})}catch(t){ge?n=ge(e):throwUnpolyfillable(O)}break;default:if(ge)n=ge(e);else switch(O){case"BigInt":n=D(e.valueOf());break;case"Boolean":n=D(ne(e));break;case"Number":n=D(ie(e));break;case"String":n=D(se(e));break;case"Date":n=new N(oe(e));break;case"ArrayBuffer":(r=s.DataView)||"function"==typeof e.slice||throwUnpolyfillable(O);try{if("function"==typeof e.slice)n=e.slice(0);else{l=e.byteLength;n=new ArrayBuffer(l);m=new r(e);k=new r(n);for(c=0;c<l;c++)k.setUint8(c,m.getUint8(c))}}catch(e){throw new V("ArrayBuffer is detached",le)}break;case"SharedArrayBuffer":n=e;break;case"Blob":try{n=e.slice(0,e.size,e.type)}catch(e){throwUnpolyfillable(O)}break;case"DOMPoint":case"DOMPointReadOnly":r=s[O];try{n=r.fromPoint?r.fromPoint(e):new r(e.x,e.y,e.z,e.w)}catch(e){throwUnpolyfillable(O)}break;case"DOMRect":case"DOMRectReadOnly":r=s[O];try{n=r.fromRect?r.fromRect(e):new r(e.x,e.y,e.width,e.height)}catch(e){throwUnpolyfillable(O)}break;case"DOMMatrix":case"DOMMatrixReadOnly":r=s[O];try{n=r.fromMatrix?r.fromMatrix(e):new r(e)}catch(e){throwUnpolyfillable(O)}break;case"AudioData":case"VideoFrame":u(e.clone)||throwUnpolyfillable(O);try{n=e.clone()}catch(e){throwUncloneable(O)}break;case"File":try{n=new File([e],e.name,e)}catch(e){throwUnpolyfillable(O)}break;case"CryptoKey":case"GPUCompilationMessage":case"GPUCompilationInfo":case"ImageBitmap":case"RTCCertificate":case"WebAssembly.Module":throwUnpolyfillable(O);default:throwUncloneable(O)}}ee(t,e,n);if(T)switch(O){case"Array":case"Object":h=re(e);for(c=0,l=x(h);c<l;c++){p=h[c];w(n,p,structuredCloneInternal(e[p],t))}break;case"Map":e.forEach((function(e,r){ee(n,structuredCloneInternal(r,t),structuredCloneInternal(e,t))}));break;case"Set":e.forEach((function(e){te(n,structuredCloneInternal(e,t))}));break;case"Error":S(n,"message",structuredCloneInternal(e.message,t));y(e,"cause")&&S(n,"cause",structuredCloneInternal(e.cause,t));"AggregateError"==a&&(n.errors=structuredCloneInternal(e.errors,t));case"DOMException":v&&S(n,"stack",structuredCloneInternal(e.stack,t))}return n},pe=ue&&!l((function(){if(M&&O>92||E&&O>94||T&&O>97)return!1;var e=new ArrayBuffer(8),t=ue(e,{transfer:[e]});return 0!=e.byteLength||8!=t.byteLength})),tryToTransfer=function(e,t){if(!f(e))throw U("Transfer option cannot be converted to a sequence");var r=[];p(e,(function(e){ae(r,m(e))}));var a,n,i,o,c,l,h=0,g=x(r);if(pe){o=ue(r,{transfer:r});for(;h<g;)ee(t,r[h],o[h++])}else for(;h<g;){a=r[h++];if(Z(t,a))throw new V("Duplicate transferable",le);switch(n=b(a)){case"ImageBitmap":i=s.OffscreenCanvas;d(i)||throwUnpolyfillable(n,he);try{(l=new i(a.width,a.height)).getContext("bitmaprenderer").transferFromImageBitmap(a);c=l.transferToImageBitmap()}catch(e){}break;case"AudioData":case"VideoFrame":u(a.clone)&&u(a.close)||throwUnpolyfillable(n,he);try{c=a.clone();a.close()}catch(e){}break;case"ArrayBuffer":case"MessagePort":case"OffscreenCanvas":case"ReadableStream":case"TransformStream":case"WritableStream":throwUnpolyfillable(n,he)}if(void 0===c)throw new V("This object cannot be transferred: "+n,le);ee(t,a,c)}};i({global:!0,enumerable:!0,sham:!pe,forced:de},{structuredClone:function structuredClone(e){var t,r=k(arguments.length,1)>1&&null!=arguments[1]?m(arguments[1]):void 0,a=r?r.transfer:void 0;if(void 0!==a){t=new Y;tryToTransfer(a,t)}return structuredCloneInternal(e,t)}})},(e,t,r)=>{var a=r(18),n=r(11),i=r(24),s=r(81),o=r(26),c=r(53),noop=function(){},l=[],h=o("Reflect","construct"),u=/^\s*(?:class|function)\b/,d=a(u.exec),f=!u.exec(noop),g=function isConstructor(e){if(!i(e))return!1;try{h(noop,l,e);return!0}catch(e){return!1}},p=function isConstructor(e){if(!i(e))return!1;switch(s(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return f||!!d(u,c(e))}catch(e){return!0}};p.sham=!0;e.exports=!h||n((function(){var e;return g(g.call)||!g(Object)||!g((function(){e=!0}))||e}))?p:g},e=>{var t=TypeError;e.exports=function(e,r){if(e<r)throw t("Not enough arguments");return e}},(e,t,r)=>{var a=r(12),n=r(41),i=r(27),s=r(124),o=RegExp.prototype;e.exports=function(e){var t=e.flags;return void 0!==t||"flags"in o||n(e,"flags")||!i(o,e)?t:a(s,e)}},(e,t,r)=>{"use strict";var a=r(49);e.exports=function(){var e=a(this),t="";e.hasIndices&&(t+="d");e.global&&(t+="g");e.ignoreCase&&(t+="i");e.multiline&&(t+="m");e.dotAll&&(t+="s");e.unicode&&(t+="u");e.unicodeSets&&(t+="v");e.sticky&&(t+="y");return t}},(e,t,r)=>{var a=r(11),n=r(15);e.exports=!a((function(){var e=Error("a");if(!("stack"in e))return!0;Object.defineProperty(e,"stack",n(1,7));return 7!==e.stack}))},(e,t,r)=>{var a=r(127),n=r(128);e.exports=!a&&!n&&"object"==typeof window&&"object"==typeof document},e=>{e.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version},(e,t,r)=>{var a=r(19),n=r(8);e.exports="process"==a(n.process)},(e,t,r)=>{var a=r(8);e.exports=a},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.RefSetCache=t.RefSet=t.Ref=t.Name=t.EOF=t.Dict=t.Cmd=t.CIRCULAR_REF=void 0;t.clearPrimitiveCaches=function clearPrimitiveCaches(){o._clearCache();s._clearCache();l._clearCache()};t.isCmd=function isCmd(e,t){return e instanceof o&&(void 0===t||e.cmd===t)};t.isDict=function isDict(e,t){return e instanceof Dict&&(void 0===t||isName(e.get("Type"),t))};t.isName=isName;t.isRefsEqual=function isRefsEqual(e,t){return e.num===t.num&&e.gen===t.gen};var a=r(2);const n=Symbol("CIRCULAR_REF");t.CIRCULAR_REF=n;const i=Symbol("EOF");t.EOF=i;const s=function NameClosure(){let e=Object.create(null);class Name{constructor(e){this.name=e}static get(t){return e[t]||(e[t]=new Name(t))}static _clearCache(){e=Object.create(null)}}return Name}();t.Name=s;const o=function CmdClosure(){let e=Object.create(null);class Cmd{constructor(e){this.cmd=e}static get(t){return e[t]||(e[t]=new Cmd(t))}static _clearCache(){e=Object.create(null)}}return Cmd}();t.Cmd=o;const c=function nonSerializableClosure(){return c};class Dict{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._map=Object.create(null);this.xref=e;this.objId=null;this.suppressEncryption=!1;this.__nonSerializable__=c}assignXref(e){this.xref=e}get size(){return Object.keys(this._map).length}get(e,t,r){let a=this._map[e];if(void 0===a&&void 0!==t){a=this._map[t];void 0===a&&void 0!==r&&(a=this._map[r])}return a instanceof l&&this.xref?this.xref.fetch(a,this.suppressEncryption):a}async getAsync(e,t,r){let a=this._map[e];if(void 0===a&&void 0!==t){a=this._map[t];void 0===a&&void 0!==r&&(a=this._map[r])}return a instanceof l&&this.xref?this.xref.fetchAsync(a,this.suppressEncryption):a}getArray(e,t,r){let a=this._map[e];if(void 0===a&&void 0!==t){a=this._map[t];void 0===a&&void 0!==r&&(a=this._map[r])}a instanceof l&&this.xref&&(a=this.xref.fetch(a,this.suppressEncryption));if(Array.isArray(a)){a=a.slice();for(let e=0,t=a.length;e<t;e++)a[e]instanceof l&&this.xref&&(a[e]=this.xref.fetch(a[e],this.suppressEncryption))}return a}getRaw(e){return this._map[e]}getKeys(){return Object.keys(this._map)}getRawValues(){return Object.values(this._map)}set(e,t){this._map[e]=t}has(e){return void 0!==this._map[e]}forEach(e){for(const t in this._map)e(t,this.get(t))}static get empty(){const e=new Dict(null);e.set=(e,t)=>{(0,a.unreachable)("Should not call `set` on the empty dictionary.")};return(0,a.shadow)(this,"empty",e)}static merge(e){let{xref:t,dictArray:r,mergeSubDicts:a=!1}=e;const n=new Dict(t),i=new Map;for(const e of r)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)}else if(!(a&&r instanceof Dict))continue;e.push(r)}for(const[e,r]of i){if(1===r.length||!(r[0]instanceof Dict)){n._map[e]=r[0];continue}const a=new Dict(t);for(const e of r)for(const[t,r]of Object.entries(e._map))void 0===a._map[t]&&(a._map[t]=r);a.size>0&&(n._map[e]=a)}i.clear();return n.size>0?n:Dict.empty}}t.Dict=Dict;const l=function RefClosure(){let e=Object.create(null);class Ref{constructor(e,t){this.num=e;this.gen=t}toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}static get(t,r){const a=0===r?`${t}R`:`${t}R${r}`;return e[a]||(e[a]=new Ref(t,r))}static _clearCache(){e=Object.create(null)}}return Ref}();t.Ref=l;class RefSet{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this._set=new Set(e&&e._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}[Symbol.iterator](){return this._set.values()}clear(){this._set.clear()}}t.RefSet=RefSet;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))}[Symbol.iterator](){return this._map.values()}clear(){this._map.clear()}}t.RefSetCache=RefSetCache;function isName(e,t){return e instanceof s&&(void 0===t||e.name===t)}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.XRefParseException=t.XRefEntryException=t.ParserEOFException=t.MissingDataException=t.DocStats=void 0;t.collectActions=function collectActions(e,t,r){const i=Object.create(null),s=getInheritableProperty({dict:t,key:"AA",stopWhenFound:!1});if(s)for(let t=s.length-1;t>=0;t--){const a=s[t];if(a instanceof n.Dict)for(const t of a.getKeys()){const s=r[t];if(!s)continue;const o=a.getRaw(t),c=new n.RefSet,l=[];_collectJS(o,e,l,c);l.length>0&&(i[s]=l)}}if(t.has("A")){const r=t.get("A"),a=new n.RefSet,s=[];_collectJS(r,e,s,a);s.length>0&&(i.Action=s)}return(0,a.objectSize)(i)>0?i:null};t.encodeToXmlString=function encodeToXmlString(e){const t=[];let r=0;for(let a=0,n=e.length;a<n;a++){const n=e.codePointAt(a);if(32<=n&&n<=126){const i=o[n];if(i){r<a&&t.push(e.substring(r,a));t.push(i);r=a+1}}else{r<a&&t.push(e.substring(r,a));t.push(`&#x${n.toString(16).toUpperCase()};`);n>55295&&(n<57344||n>65533)&&a++;r=a+1}}if(0===t.length)return e;r<e.length&&t.push(e.substring(r,e.length));return t.join("")};t.escapePDFName=function escapePDFName(e){const t=[];let r=0;for(let a=0,n=e.length;a<n;a++){const n=e.charCodeAt(a);if(n<33||n>126||35===n||40===n||41===n||60===n||62===n||91===n||93===n||123===n||125===n||47===n||37===n){r<a&&t.push(e.substring(r,a));t.push(`#${n.toString(16)}`);r=a+1}}if(0===t.length)return e;r<e.length&&t.push(e.substring(r,e.length));return t.join("")};t.getArrayLookupTableFactory=function getArrayLookupTableFactory(e){let t;return function(){if(e){let r=e();e=null;t=Object.create(null);for(let e=0,a=r.length;e<a;e+=2)t[r[e]]=r[e+1];r=null}return t}};t.getInheritableProperty=getInheritableProperty;t.getLookupTableFactory=function getLookupTableFactory(e){let t;return function(){if(e){t=Object.create(null);e(t);e=null}return t}};t.getNewAnnotationsMap=function getNewAnnotationsMap(e){if(!e)return null;const t=new Map;for(const[r,n]of e){if(!r.startsWith(a.AnnotationEditorPrefix))continue;let e=t.get(n.pageIndex);if(!e){e=[];t.set(n.pageIndex,e)}e.push(n)}return t.size>0?t:null};t.isWhiteSpace=function isWhiteSpace(e){return 32===e||9===e||13===e||10===e};t.log2=function log2(e){if(e<=0)return 0;return Math.ceil(Math.log2(e))};t.numberToString=function numberToString(e){if(Number.isInteger(e))return e.toString();const t=Math.round(100*e);if(t%100==0)return(t/100).toString();if(t%10==0)return e.toFixed(1);return e.toFixed(2)};t.parseXFAPath=function parseXFAPath(e){const t=/(.+)\[(\d+)\]$/;return e.split(".").map((e=>{const r=e.match(t);return r?{name:r[1],pos:parseInt(r[2],10)}:{name:e,pos:0}}))};t.readInt8=function readInt8(e,t){return e[t]<<24>>24};t.readUint16=function readUint16(e,t){return e[t]<<8|e[t+1]};t.readUint32=function readUint32(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0};t.recoverJsURL=function recoverJsURL(e){const t=new RegExp("^\\s*("+["app.launchURL","window.open","xfa.host.gotoURL"].join("|").split(".").join("\\.")+")\\((?:'|\")([^'\"]*)(?:'|\")(?:,\\s*(\\w+)\\)|\\))","i").exec(e);if(t&&t[2]){const e=t[2];let r=!1;"true"===t[3]&&"app.launchURL"===t[1]&&(r=!0);return{url:e,newWindow:r}}return null};t.toRomanNumerals=function toRomanNumerals(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[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(s[n]);n=e/10|0;e%=10;r.push(s[10+n]);r.push(s[20+e]);const i=r.join("");return t?i.toLowerCase():i};t.validateCSSFont=function validateCSSFont(e){const t=new Set(["100","200","300","400","500","600","700","800","900","1000","normal","bold","bolder","lighter"]),{fontFamily:r,fontWeight:n,italicAngle:i}=e;if(/^".*"$/.test(r)){if(/[^\\]"/.test(r.slice(1,r.length-1))){(0,a.warn)(`XFA - FontFamily contains some unescaped ": ${r}.`);return!1}}else if(/^'.*'$/.test(r)){if(/[^\\]'/.test(r.slice(1,r.length-1))){(0,a.warn)(`XFA - FontFamily contains some unescaped ': ${r}.`);return!1}}else for(const e of r.split(/[ \t]+/))if(/^(\d|(-(\d|-)))/.test(e)||!/^[\w-\\]+$/.test(e)){(0,a.warn)(`XFA - FontFamily contains some invalid <custom-ident>: ${r}.`);return!1}const s=n?n.toString():"";e.fontWeight=t.has(s)?s:"400";const o=parseFloat(i);e.italicAngle=isNaN(o)||o<-90||o>90?"14":i.toString();return!0};var a=r(2),n=r(130),i=r(132);class MissingDataException extends a.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`,"MissingDataException");this.begin=e;this.end=t}}t.MissingDataException=MissingDataException;class ParserEOFException extends a.BaseException{constructor(e){super(e,"ParserEOFException")}}t.ParserEOFException=ParserEOFException;class XRefEntryException extends a.BaseException{constructor(e){super(e,"XRefEntryException")}}t.XRefEntryException=XRefEntryException;class XRefParseException extends a.BaseException{constructor(e){super(e,"XRefParseException")}}t.XRefParseException=XRefParseException;t.DocStats=class DocStats{constructor(e){this._handler=e;this._streamTypes=new Set;this._fontTypes=new Set}_send(){const e=Object.create(null),t=Object.create(null);for(const t of this._streamTypes)e[t]=!0;for(const e of this._fontTypes)t[e]=!0;this._handler.send("DocStats",{streamTypes:e,fontTypes:t})}addStreamType(e){if(!this._streamTypes.has(e)){this._streamTypes.add(e);this._send()}}addFontType(e){if(!this._fontTypes.has(e)){this._fontTypes.add(e);this._send()}}};function getInheritableProperty(e){let t,{dict:r,key:a,getArray:i=!1,stopWhenFound:s=!0}=e;const o=new n.RefSet;for(;r instanceof n.Dict&&(!r.objId||!o.has(r.objId));){r.objId&&o.put(r.objId);const e=i?r.getArray(a):r.get(a);if(void 0!==e){if(s)return e;t||(t=[]);t.push(e)}r=r.get("Parent")}return t}const s=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"];function _collectJS(e,t,r,s){if(!e)return;let o=null;if(e instanceof n.Ref){if(s.has(e))return;o=e;s.put(o);e=t.fetch(e)}if(Array.isArray(e))for(const a of e)_collectJS(a,t,r,s);else if(e instanceof n.Dict){if((0,n.isName)(e.get("S"),"JavaScript")){const t=e.get("JS");let n;t instanceof i.BaseStream?n=t.getString():"string"==typeof t&&(n=t);n=n&&(0,a.stringToPDFString)(n).replace(/\u0000/g,"");n&&r.push(n)}_collectJS(e.getRaw("Next"),t,r,s)}o&&s.remove(o)}const o={60:"<",62:">",38:"&",34:""",39:"'"}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BaseStream=void 0;var a=r(2);class BaseStream{constructor(){this.constructor===BaseStream&&(0,a.unreachable)("Cannot initialize BaseStream.")}get length(){(0,a.unreachable)("Abstract getter `length` accessed")}get isEmpty(){(0,a.unreachable)("Abstract getter `isEmpty` accessed")}get isDataLoaded(){return(0,a.shadow)(this,"isDataLoaded",!0)}getByte(){(0,a.unreachable)("Abstract method `getByte` called")}getBytes(e){(0,a.unreachable)("Abstract method `getBytes` called")}peekByte(){const e=this.getByte();-1!==e&&this.pos--;return e}peekBytes(e){const t=this.getBytes(e);this.pos-=t.length;return t}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()}getByteRange(e,t){(0,a.unreachable)("Abstract method `getByteRange` called")}getString(e){return(0,a.bytesToString)(this.getBytes(e))}skip(e){this.pos+=e||1}reset(){(0,a.unreachable)("Abstract method `reset` called")}moveStart(){(0,a.unreachable)("Abstract method `moveStart` called")}makeSubStream(e,t){(0,a.unreachable)("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}t.BaseStream=BaseStream},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.NetworkPdfManager=t.LocalPdfManager=void 0;var a=r(2),n=r(134),i=r(131),s=r(136),o=r(135);function parseDocBaseUrl(e){if(e){const t=(0,a.createValidAbsoluteUrl)(e);if(t)return t.href;(0,a.warn)(`Invalid absolute docBaseUrl: "${e}".`)}return null}class BasePdfManager{constructor(){this.constructor===BasePdfManager&&(0,a.unreachable)("Cannot initialize BasePdfManager.")}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){const e=this.pdfDocument.catalog;return(0,a.shadow)(this,"docBaseUrl",e.baseUrl||this._docBaseUrl)}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)}loadXfaFonts(e,t){return this.pdfDocument.loadXfaFonts(e,t)}loadXfaImages(){return this.pdfDocument.loadXfaImages()}serializeXfaData(e){return this.pdfDocument.serializeXfaData(e)}cleanup(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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,n,i,c){super();this._docId=e;this._password=r;this._docBaseUrl=parseDocBaseUrl(c);this.msgHandler=a;this.evaluatorOptions=n;this.enableXfa=i;const l=new o.Stream(t);this.pdfDocument=new s.PDFDocument(this,l);this._loadedStreamPromise=Promise.resolve(l)}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,i,o){super();this._docId=e;this._password=r.password;this._docBaseUrl=parseDocBaseUrl(o);this.msgHandler=r.msgHandler;this.evaluatorOptions=a;this.enableXfa=i;this.streamManager=new n.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 i.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)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ChunkedStreamManager=t.ChunkedStream=void 0;var a=r(2),n=r(131),i=r(135);class ChunkedStream extends i.Stream{constructor(e,t,r){super(new Uint8Array(e),0,e,null);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<r;++t)this._loadedChunks.has(t)||e.push(t);return e}get numChunksLoaded(){return this._loadedChunks.size}get isDataLoaded(){return this.numChunksLoaded===this.numChunks}onReceiveData(e,t){const r=this.chunkSize;if(e%r!=0)throw new Error(`Bad begin offset: ${e}`);const a=e+t.byteLength;if(a%r!=0&&a!==this.bytes.length)throw new Error(`Bad end offset: ${a}`);this.bytes.set(new Uint8Array(t),e);const n=Math.floor(e/r),i=Math.floor((a-1)/r)+1;for(let e=n;e<i;++e)this._loadedChunks.add(e)}onReceiveProgressiveData(e){let t=this.progressiveDataLength;const r=Math.floor(t/this.chunkSize);this.bytes.set(new Uint8Array(e),t);t+=e.byteLength;this.progressiveDataLength=t;const a=t>=this.end?this.numChunks:Math.floor(t/this.chunkSize);for(let e=r;e<a;++e)this._loadedChunks.add(e)}ensureByte(e){if(e<this.progressiveDataLength)return;const t=Math.floor(e/this.chunkSize);if(!(t>this.numChunks)&&t!==this.lastSuccessfulEnsureByteChunk){if(!this._loadedChunks.has(t))throw new n.MissingDataException(e,e+1);this.lastSuccessfulEnsureByteChunk=t}}ensureRange(e,t){if(e>=t)return;if(t<=this.progressiveDataLength)return;const r=Math.floor(e/this.chunkSize);if(r>this.numChunks)return;const a=Math.min(Math.floor((t-1)/this.chunkSize)+1,this.numChunks);for(let i=r;i<a;++i)if(!this._loadedChunks.has(i))throw new n.MissingDataException(e,t)}nextEmptyChunk(e){const t=this.numChunks;for(let r=0;r<t;++r){const a=(e+r)%t;if(!this._loadedChunks.has(a))return a}return null}hasChunk(e){return this._loadedChunks.has(e)}getByte(){const e=this.pos;if(e>=this.end)return-1;e>=this.progressiveDataLength&&this.ensureByte(e);return this.bytes[this.pos++]}getBytes(e){const t=this.bytes,r=this.pos,a=this.end;if(!e){a>this.progressiveDataLength&&this.ensureRange(r,a);return t.subarray(r,a)}let n=r+e;n>a&&(n=a);n>this.progressiveDataLength&&this.ensureRange(r,n);this.pos=n;return t.subarray(r,n)}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)}makeSubStream(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;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<r;++e)this._loadedChunks.has(e)||a.push(e);return a};Object.defineProperty(ChunkedStreamSubstream.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const a=new ChunkedStreamSubstream;a.pos=a.start=e;a.end=e+t||this.end;a.dict=r;return a}getBaseStreams(){return[this]}}t.ChunkedStream=ChunkedStream;t.ChunkedStreamManager=class ChunkedStreamManager{constructor(e,t){this.length=t.length;this.chunkSize=t.rangeChunkSize;this.stream=new ChunkedStream(this.length,this.chunkSize,this);this.pdfNetworkStream=e;this.disableAutoFetch=t.disableAutoFetch;this.msgHandler=t.msgHandler;this.currRequestId=0;this._chunksNeededByRequest=new Map;this._requestsByChunk=new Map;this._promisesByRequest=new Map;this.progressiveDataLength=0;this.aborted=!1;this._loadedStreamCapability=(0,a.createPromiseCapability)()}onLoadedStream(){return this._loadedStreamCapability.promise}sendRequest(e,t){const r=this.pdfNetworkStream.getRangeReader(e,t);r.isStreamingSupported||(r.onProgress=this.onProgress.bind(this));let n=[],i=0;return new Promise(((e,t)=>{const readChunk=s=>{try{if(!s.done){const e=s.value;n.push(e);i+=(0,a.arrayByteLength)(e);r.isStreamingSupported&&this.onProgress({loaded:i});r.read().then(readChunk,t);return}const o=(0,a.arraysToBytes)(n);n=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 n=(0,a.createPromiseCapability)();this._promisesByRequest.set(t,n);const i=[];for(const e of r){let r=this._requestsByChunk.get(e);if(!r){r=[];this._requestsByChunk.set(e,r);i.push(e)}r.push(t)}if(i.length>0){const e=this.groupChunks(i);for(const t of e){const e=t.beginChunk*this.chunkSize,r=Math.min(t.endChunk*this.chunkSize,this.length);this.sendRequest(e,r).catch(n.reject)}}return n.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),n=[];for(let e=r;e<a;++e)n.push(e);return this._requestChunks(n)}requestRanges(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const t=[];for(const r of e){const e=this.getBeginChunk(r.begin),a=this.getEndChunk(r.end);for(let r=e;r<a;++r)t.includes(r)||t.push(r)}t.sort((function(e,t){return e-t}));return this._requestChunks(t)}groupChunks(e){const t=[];let r=-1,a=-1;for(let n=0,i=e.length;n<i;++n){const i=e[n];r<0&&(r=i);if(a>=0&&a+1!==i){t.push({beginChunk:r,endChunk:a+1});r=i}n+1===e.length&&t.push({beginChunk:r,endChunk:i+1});a=i}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,n=a+t.byteLength,i=Math.floor(a/this.chunkSize),s=n<this.length?Math.floor(n/this.chunkSize):Math.ceil(n/this.chunkSize);if(r){this.stream.onReceiveProgressiveData(t);this.progressiveDataLength=n}else this.stream.onReceiveData(a,t);this.stream.isDataLoaded&&this._loadedStreamCapability.resolve(this.stream);const o=[];for(let e=i;e<s;++e){const t=this._requestsByChunk.get(e);if(t){this._requestsByChunk.delete(e);for(const r of t){const t=this._chunksNeededByRequest.get(r);t.has(e)&&t.delete(e);t.size>0||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)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.StringStream=t.Stream=t.NullStream=void 0;var a=r(132),n=r(2);class Stream extends a.BaseStream{constructor(e,t,r,a){super();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}get length(){return this.end-this.start}get isEmpty(){return 0===this.length}getByte(){return this.pos>=this.end?-1:this.bytes[this.pos++]}getBytes(e){const t=this.bytes,r=this.pos,a=this.end;if(!e)return t.subarray(r,a);let n=r+e;n>a&&(n=a);this.pos=n;return t.subarray(r,n)}getByteRange(e,t){e<0&&(e=0);t>this.end&&(t=this.end);return this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return new Stream(this.bytes.buffer,e,t,r)}}t.Stream=Stream;t.StringStream=class StringStream extends Stream{constructor(e){super((0,n.stringToBytes)(e))}};t.NullStream=class NullStream extends Stream{constructor(){super(new Uint8Array(0))}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Page=t.PDFDocument=void 0;var a=r(137),n=r(2),i=r(131),s=r(130),o=r(176),c=r(132),l=r(192),h=r(194),u=r(196),d=r(225),f=r(142),g=r(135),p=r(200),m=r(187),b=r(140),y=r(144),w=r(199),S=r(190),x=r(201),k=r(226);const C=[0,0,612,792];class Page{constructor(e){let{pdfManager:t,xref:r,pageIndex:a,pageDict:n,ref:i,globalIdFactory:s,fontCache:o,builtInCMapCache:c,standardFontDataCache:l,globalImageCache:h,nonBlendModesSet:u,xfaFactory:d}=e;this.pdfManager=t;this.pageIndex=a;this.pageDict=n;this.xref=r;this.ref=i;this.fontCache=o;this.builtInCMapCache=c;this.standardFontDataCache=l;this.globalImageCache=h;this.nonBlendModesSet=u;this.evaluatorOptions=t.evaluatorOptions;this.resourcesPromise=null;this.xfaFactory=d;const f={obj:0};this._localIdFactory=class extends s{static createObjId(){return`p${a}_${++f.obj}`}static getPageObjId(){return`page${i.toString()}`}}}_getInheritableProperty(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=(0,i.getInheritableProperty)({dict:this.pageDict,key:e,getArray:t,stopWhenFound:!1});return Array.isArray(r)?1!==r.length&&r[0]instanceof s.Dict?s.Dict.merge({xref:this.xref,dictArray:r}):r[0]:r}get content(){return this.pageDict.getArray("Contents")}get resources(){const e=this._getInheritableProperty("Resources");return(0,n.shadow)(this,"resources",e instanceof s.Dict?e:s.Dict.empty)}_getBoundingBox(e){if(this.xfaData)return this.xfaData.bbox;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,n.warn)(`Empty /${e} entry.`)}return null}get mediaBox(){return(0,n.shadow)(this,"mediaBox",this._getBoundingBox("MediaBox")||C)}get cropBox(){return(0,n.shadow)(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");("number"!=typeof e||e<=0)&&(e=1);return(0,n.shadow)(this,"userUnit",e)}get view(){const{cropBox:e,mediaBox:t}=this;let r;if(e===t||(0,n.isArrayEqual)(e,t))r=t;else{const a=n.Util.intersect(e,t);a&&a[2]-a[0]!=0&&a[3]-a[1]!=0?r=a:(0,n.warn)("Empty /CropBox and /MediaBox intersection.")}return(0,n.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,n.shadow)(this,"rotate",e)}_onSubStreamError(e,t,r){if(!this.evaluatorOptions.ignoreErrors)throw t;e.send("UnsupportedFeature",{featureId:n.UNSUPPORTED_FEATURES.errorContentSubStream});(0,n.warn)(`getContentStream - ignoring sub-stream (${r}): "${t}".`)}getContentStream(e){return this.pdfManager.ensure(this,"content").then((t=>t instanceof c.BaseStream?t:Array.isArray(t)?new y.StreamsSequenceStream(t,this._onSubStreamError.bind(this,e)):new g.NullStream))}get xfaData(){return(0,n.shadow)(this,"xfaData",this.xfaFactory?{bbox:this.xfaFactory.getBoundingBox(this.pageIndex)}:null)}async saveNewAnnotations(e,t,r){if(this.xfaFactory)throw new Error("XFA: Cannot save new annotations.");const n=new b.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}),i=this.pageDict,s=this.annotations.slice(),o=await a.AnnotationFactory.saveNewAnnotations(n,t,r);for(const{ref:e}of o.annotations)s.push(e);const c=i.get("Annots");i.set("Annots",s);const l=[];let h=null;this.xref.encrypt&&(h=this.xref.encrypt.createCipherTransform(this.ref.num,this.ref.gen));(0,S.writeObject)(this.ref,i,l,h);c&&i.set("Annots",c);const u=o.dependencies;u.push({ref:this.ref,data:l.join("")},...o.annotations);return u}save(e,t,r){const a=new b.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions});return this._parsedAnnotations.then((function(e){const i=[];for(const s of e)s.mustBePrinted(r)&&i.push(s.save(a,t,r).catch((function(e){(0,n.warn)(`save - ignoring annotation data during "${t.name}" task: "${e}".`);return null})));return Promise.all(i).then((function(e){return e.filter((e=>!!e))}))}))}loadResources(e){this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources"));return this.resourcesPromise.then((()=>new p.ObjectLoader(this.resources,e,this.xref).load()))}getOperatorList(e){let{handler:t,sink:r,task:s,intent:o,cacheKey:c,annotationStorage:l=null}=e;const h=this.getContentStream(t),u=this.loadResources(["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"]),d=new b.PartialEvaluator({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}),f=this.xfaFactory?null:(0,i.getNewAnnotationsMap)(l);let g=Promise.resolve(null);if(f){const e=f.get(this.pageIndex);e&&(g=a.AnnotationFactory.printNewAnnotations(d,s,e))}const p=Promise.all([h,u]).then((e=>{let[a]=e;const n=new m.OperatorList(o,r);t.send("StartRenderPage",{transparency:d.hasBlendModes(this.resources,this.nonBlendModesSet),pageIndex:this.pageIndex,cacheKey:c});return d.getOperatorList({stream:a,task:s,resources:this.resources,operatorList:n}).then((function(){return n}))}));return Promise.all([p,this._parsedAnnotations,g]).then((function(e){let[t,r,a]=e;a&&(r=r.concat(a));if(0===r.length||o&n.RenderingIntentFlag.ANNOTATIONS_DISABLE){t.flush(!0);return{length:t.totalLength}}const i=!!(o&n.RenderingIntentFlag.ANNOTATIONS_FORMS),c=!!(o&n.RenderingIntentFlag.ANY),h=!!(o&n.RenderingIntentFlag.DISPLAY),u=!!(o&n.RenderingIntentFlag.PRINT),f=[];for(const e of r)(c||h&&e.mustBeViewed(l)||u&&e.mustBePrinted(l))&&f.push(e.getOperatorList(d,s,o,i,l).catch((function(e){(0,n.warn)(`getOperatorList - ignoring annotation data during "${s.name}" task: "${e}".`);return null})));return Promise.all(f).then((function(e){let r=!1,a=!1;for(const{opList:n,separateForm:i,separateCanvas:s}of e){t.addOpList(n);i&&(r=i);s&&(a=s)}t.flush(!0,{form:r,canvas:a});return{length:t.totalLength}}))}))}extractTextContent(e){let{handler:t,task:r,includeMarkedContent:a,sink:n,combineTextItems:i}=e;const s=this.getContentStream(t),o=this.loadResources(["ExtGState","Font","Properties","XObject"]);return Promise.all([s,o]).then((e=>{let[s]=e;return new b.PartialEvaluator({xref:this.xref,handler:t,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}).getTextContent({stream:s,task:r,resources:this.resources,includeMarkedContent:a,combineTextItems:i,sink:n,viewBox:this.view})}))}async getStructTree(){const e=await this.pdfManager.ensureCatalog("structTreeRoot");if(!e)return null;return(await this.pdfManager.ensure(this,"_parseStructTree",[e])).serializable}_parseStructTree(e){const t=new w.StructTreePage(e,this.pageDict);t.parse();return t}async getAnnotationsData(e,t,r){const a=await this._parsedAnnotations;if(0===a.length)return[];const i=[],s=[];let o;const c=!!(r&n.RenderingIntentFlag.ANY),l=!!(r&n.RenderingIntentFlag.DISPLAY),h=!!(r&n.RenderingIntentFlag.PRINT);for(const r of a){const a=c||l&&r.viewable;(a||h&&r.printable)&&s.push(r.data);if(r.hasTextContent&&a){o||(o=new b.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,standardFontDataCache:this.standardFontDataCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}));i.push(r.extractTextContent(o,t,this.view).catch((function(e){(0,n.warn)(`getAnnotationsData - ignoring textContent during "${t.name}" task: "${e}".`)})))}}await Promise.all(i);return s}get annotations(){const e=this._getInheritableProperty("Annots");return(0,n.shadow)(this,"annotations",Array.isArray(e)?e:[])}get _parsedAnnotations(){const e=this.pdfManager.ensure(this,"annotations").then((()=>{const e=[];for(const t of this.annotations)e.push(a.AnnotationFactory.create(this.xref,t,this.pdfManager,this._localIdFactory,!1).catch((function(e){(0,n.warn)(`_parsedAnnotations: "${e}".`);return null})));return Promise.all(e).then((function(e){if(0===e.length)return e;const t=[];let r;for(const n of e)if(n)if(n instanceof a.PopupAnnotation){r||(r=[]);r.push(n)}else t.push(n);r&&t.push(...r);return t}))}));return(0,n.shadow)(this,"_parsedAnnotations",e)}get jsActions(){const e=(0,i.collectActions)(this.xref,this.pageDict,n.PageActionEventType);return(0,n.shadow)(this,"jsActions",e)}}t.Page=Page;const v=new Uint8Array([37,80,68,70,45]),O=new Uint8Array([115,116,97,114,116,120,114,101,102]),T=new Uint8Array([101,110,100,111,98,106]),M=/^[1-9]\.\d$/;function find(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1024,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const n=t.length,i=e.peekBytes(r),s=i.length-n;if(s<=0)return!1;if(a){const r=n-1;let a=i.length-1;for(;a>=r;){let s=0;for(;s<n&&i[a-s]===t[r-s];)s++;if(s>=n){e.pos+=a-r;return!0}a--}}else{let r=0;for(;r<=s;){let a=0;for(;a<n&&i[r+a]===t[a];)a++;if(a>=n){e.pos+=r;return!0}r++}}return!1}t.PDFDocument=class PDFDocument{constructor(e,t){if(t.length<=0)throw new n.InvalidPDFException("The PDF file is empty, i.e. its size is zero bytes.");this.pdfManager=e;this.stream=t;this.xref=new k.XRef(t,e);this._pagePromises=new Map;this._version=null;const r={font:0};this._globalIdFactory=class{static getDocId(){return`g_${e.docId}`}static createFontId(){return"f"+ ++r.font}static createObjId(){(0,n.unreachable)("Abstract method `createObjId` called.")}static getPageObjId(){(0,n.unreachable)("Abstract method `getPageObjId` called.")}}}parse(e){this.xref.parse(e);this.catalog=new h.Catalog(this.pdfManager,this.xref);this.catalog.version&&(this._version=this.catalog.version)}get linearization(){let e=null;try{e=f.Linearization.create(this.stream)}catch(e){if(e instanceof i.MissingDataException)throw e;(0,n.info)(e)}return(0,n.shadow)(this,"linearization",e)}get startXRef(){const e=this.stream;let t=0;if(this.linearization){e.reset();find(e,T)&&(t=e.pos+6-e.start)}else{const r=1024,a=O.length;let n=!1,s=e.end;for(;!n&&s>0;){s-=r-a;s<0&&(s=0);e.pos=s;n=find(e,O,r,!0)}if(n){e.skip(9);let r;do{r=e.getByte()}while((0,i.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,n.shadow)(this,"startXRef",t)}checkHeader(){const e=this.stream;e.reset();if(!find(e,v))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(){let e=0;e=this.catalog.hasActualNumPages?this.catalog.numPages:this.xfaFactory?this.xfaFactory.getNumPages():this.linearization?this.linearization.numPages:this.catalog.numPages;return(0,n.shadow)(this,"numPages",e)}_hasOnlyDocumentSignatures(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return!!Array.isArray(e)&&e.every((e=>{if(!((e=this.xref.fetchIfRef(e))instanceof s.Dict))return!1;if(e.has("Kids")){if(++t>10){(0,n.warn)("_hasOnlyDocumentSignatures: maximum recursion depth reached");return!1}return this._hasOnlyDocumentSignatures(e.get("Kids"),t)}const r=(0,s.isName)(e.get("FT"),"Sig"),a=e.get("Rect"),i=Array.isArray(a)&&a.every((e=>0===e));return r&&i}))}get _xfaStreams(){const e=this.catalog.acroForm;if(!e)return null;const t=e.get("XFA"),r={"xdp:xdp":"",template:"",datasets:"",config:"",connectionSet:"",localeSet:"",stylesheet:"","/xdp:xdp":""};if(t instanceof c.BaseStream&&!t.isEmpty){r["xdp:xdp"]=t;return r}if(!Array.isArray(t)||0===t.length)return null;for(let e=0,a=t.length;e<a;e+=2){let n;n=0===e?"xdp:xdp":e===a-2?"/xdp:xdp":t[e];if(!r.hasOwnProperty(n))continue;const i=this.xref.fetchIfRef(t[e+1]);i instanceof c.BaseStream&&!i.isEmpty&&(r[n]=i)}return r}get xfaDatasets(){const e=this._xfaStreams;if(!e)return(0,n.shadow)(this,"xfaDatasets",null);for(const t of["datasets","xdp:xdp"]){const r=e[t];if(r)try{const e={[t]:(0,n.stringToUTF8String)(r.getString())};return(0,n.shadow)(this,"xfaDatasets",new d.DatasetReader(e))}catch(e){(0,n.warn)("XFA - Invalid utf-8 string.");break}}return(0,n.shadow)(this,"xfaDatasets",null)}get xfaData(){const e=this._xfaStreams;if(!e)return null;const t=Object.create(null);for(const[r,a]of Object.entries(e))if(a)try{t[r]=(0,n.stringToUTF8String)(a.getString())}catch(e){(0,n.warn)("XFA - Invalid utf-8 string.");return null}return t}get xfaFactory(){let e;this.pdfManager.enableXfa&&this.catalog.needsRendering&&this.formInfo.hasXfa&&!this.formInfo.hasAcroForm&&(e=this.xfaData);return(0,n.shadow)(this,"xfaFactory",e?new x.XFAFactory(e):null)}get isPureXfa(){return!!this.xfaFactory&&this.xfaFactory.isValid()}get htmlForXfa(){return this.xfaFactory?this.xfaFactory.getPages():null}async loadXfaImages(){const e=await this.pdfManager.ensureCatalog("xfaImages");if(!e)return;const t=e.getKeys(),r=new p.ObjectLoader(e,t,this.xref);await r.load();const a=new Map;for(const r of t){const t=e.get(r);t instanceof c.BaseStream&&a.set(r,t.getBytes())}this.xfaFactory.setImages(a)}async loadXfaFonts(e,t){const r=await this.pdfManager.ensureCatalog("acroForm");if(!r)return;const a=await r.getAsync("DR");if(!(a instanceof s.Dict))return;const c=new p.ObjectLoader(a,["Font"],this.xref);await c.load();const l=a.get("Font");if(!(l instanceof s.Dict))return;const h=Object.assign(Object.create(null),this.pdfManager.evaluatorOptions);h.useSystemFonts=!1;const u=new b.PartialEvaluator({xref:this.xref,handler:e,pageIndex:-1,idFactory:this._globalIdFactory,fontCache:this.catalog.fontCache,builtInCMapCache:this.catalog.builtInCMapCache,standardFontDataCache:this.catalog.standardFontDataCache,options:h}),d=new m.OperatorList,f=[],g={get font(){return f.at(-1)},set font(e){f.push(e)},clone(){return this}},y=new Map;l.forEach(((e,t)=>{y.set(e,t)}));const w=[];for(const[e,r]of y){const o=r.get("FontDescriptor");if(!(o instanceof s.Dict))continue;let c=o.get("FontFamily");c=c.replace(/[ ]+(\d)/g,"$1");const l={fontFamily:c,fontWeight:o.get("FontWeight"),italicAngle:-o.get("ItalicAngle")};(0,i.validateCSSFont)(l)&&w.push(u.handleSetFont(a,[s.Name.get(e),1],null,d,t,g,null,l).catch((function(e){(0,n.warn)(`loadXfaFonts: "${e}".`);return null})))}await Promise.all(w);const S=this.xfaFactory.setFonts(f);if(!S)return;h.ignoreErrors=!0;w.length=0;f.length=0;const x=new Set;for(const e of S)(0,o.getXfaFontName)(`${e}-Regular`)||x.add(e);x.size&&S.push("PdfJS-Fallback");for(const e of S)if(!x.has(e))for(const r of[{name:"Regular",fontWeight:400,italicAngle:0},{name:"Bold",fontWeight:700,italicAngle:0},{name:"Italic",fontWeight:400,italicAngle:12},{name:"BoldItalic",fontWeight:700,italicAngle:12}]){const i=`${e}-${r.name}`,c=(0,o.getXfaFontDict)(i);w.push(u.handleSetFont(a,[s.Name.get(i),1],null,d,t,g,c,{fontFamily:e,fontWeight:r.fontWeight,italicAngle:r.italicAngle}).catch((function(e){(0,n.warn)(`loadXfaFonts: "${e}".`);return null})))}await Promise.all(w);this.xfaFactory.appendFonts(f,x)}async serializeXfaData(e){return this.xfaFactory?this.xfaFactory.serializeData(e):null}get formInfo(){const e={hasFields:!1,hasAcroForm:!1,hasXfa:!1,hasSignatures:!1},t=this.catalog.acroForm;if(!t)return(0,n.shadow)(this,"formInfo",e);try{const r=t.get("Fields"),a=Array.isArray(r)&&r.length>0;e.hasFields=a;const n=t.get("XFA");e.hasXfa=Array.isArray(n)&&n.length>0||n instanceof c.BaseStream&&!n.isEmpty;const i=!!(1&t.get("SigFlags")),s=i&&this._hasOnlyDocumentSignatures(r);e.hasAcroForm=a&&!s;e.hasSignatures=i}catch(e){if(e instanceof i.MissingDataException)throw e;(0,n.warn)(`Cannot fetch form information: "${e}".`)}return(0,n.shadow)(this,"formInfo",e)}get documentInfo(){let e=this._version;if("string"!=typeof e||!M.test(e)){(0,n.warn)(`Invalid PDF header version number: ${e}`);e=null}const t={PDFFormatVersion:e,Language:this.catalog.lang,EncryptFilterName:this.xref.encrypt?this.xref.encrypt.filterName:null,IsLinearized:!!this.linearization,IsAcroFormPresent:this.formInfo.hasAcroForm,IsXFAPresent:this.formInfo.hasXfa,IsCollectionPresent:!!this.catalog.collection,IsSignaturesPresent:this.formInfo.hasSignatures};let r;try{r=this.xref.trailer.get("Info")}catch(e){if(e instanceof i.MissingDataException)throw e;(0,n.info)("The document information dictionary is invalid.")}if(!(r instanceof s.Dict))return(0,n.shadow)(this,"documentInfo",t);for(const e of r.getKeys()){const a=r.get(e);switch(e){case"Title":case"Author":case"Subject":case"Keywords":case"Creator":case"Producer":case"CreationDate":case"ModDate":if("string"==typeof a){t[e]=(0,n.stringToPDFString)(a);continue}break;case"Trapped":if(a instanceof s.Name){t[e]=a;continue}break;default:let r;switch(typeof a){case"string":r=(0,n.stringToPDFString)(a);break;case"number":case"boolean":r=a;break;default:a instanceof s.Name&&(r=a)}if(void 0===r){(0,n.warn)(`Bad value, for custom key "${e}", in Info: ${a}.`);continue}t.Custom||(t.Custom=Object.create(null));t.Custom[e]=r;continue}(0,n.warn)(`Bad value, for key "${e}", in Info: ${a}.`)}return(0,n.shadow)(this,"documentInfo",t)}get fingerprints(){function validate(e){return"string"==typeof e&&e.length>0&&"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"!==e}function hexString(e){const t=[];for(let r=0,a=e.length;r<a;r++){const a=e[r].toString(16);t.push(a.padStart(2,"0"))}return t.join("")}const e=this.xref.trailer.get("ID");let t,r;if(Array.isArray(e)&&validate(e[0])){t=(0,n.stringToBytes)(e[0]);e[1]!==e[0]&&validate(e[1])&&(r=(0,n.stringToBytes)(e[1]))}else t=(0,l.calculateMD5)(this.stream.getByteRange(0,1024),0,1024);return(0,n.shadow)(this,"fingerprints",[hexString(t),r?hexString(r):null])}async _getLinearizationPage(e){const{catalog:t,linearization:r,xref:a}=this,i=s.Ref.get(r.objectNumberFirst,0);try{const e=await a.fetchAsync(i);if(e instanceof s.Dict){let r=e.getRaw("Type");r instanceof s.Ref&&(r=await a.fetchAsync(r));if((0,s.isName)(r,"Page")||!e.has("Type")&&!e.has("Kids")){t.pageKidsCountCache.has(i)||t.pageKidsCountCache.put(i,1);t.pageIndexCache.has(i)||t.pageIndexCache.put(i,0);return[e,i]}}throw new n.FormatError("The Linearization dictionary doesn't point to a valid Page dictionary.")}catch(r){(0,n.warn)(`_getLinearizationPage: "${r.message}".`);return t.getPageDict(e)}}getPage(e){const t=this._pagePromises.get(e);if(t)return t;const{catalog:r,linearization:a,xfaFactory:n}=this;let i;i=n?Promise.resolve([s.Dict.empty,null]):a&&a.pageFirst===e?this._getLinearizationPage(e):r.getPageDict(e);i=i.then((t=>{let[a,i]=t;return new Page({pdfManager:this.pdfManager,xref:this.xref,pageIndex:e,pageDict:a,ref:i,globalIdFactory:this._globalIdFactory,fontCache:r.fontCache,builtInCMapCache:r.builtInCMapCache,standardFontDataCache:r.standardFontDataCache,globalImageCache:r.globalImageCache,nonBlendModesSet:r.nonBlendModesSet,xfaFactory:n})}));this._pagePromises.set(e,i);return i}async checkFirstPage(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0]))try{await this.getPage(0)}catch(e){if(e instanceof i.XRefEntryException){this._pagePromises.delete(0);await this.cleanup();throw new i.XRefParseException}}}async checkLastPage(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const{catalog:t,pdfManager:r}=this;t.setActualNumPages();let a;try{await Promise.all([r.ensureDoc("xfaFactory"),r.ensureDoc("linearization"),r.ensureCatalog("numPages")]);if(this.xfaFactory)return;a=this.linearization?this.linearization.numPages:t.numPages;if(!Number.isInteger(a))throw new n.FormatError("Page count is not an integer.");if(a<=1)return;await this.getPage(a-1)}catch(s){this._pagePromises.delete(a-1);await this.cleanup();if(s instanceof i.XRefEntryException&&!e)throw new i.XRefParseException;(0,n.warn)(`checkLastPage - invalid /Pages tree /Count: ${a}.`);let o;try{o=await t.getAllPageDicts(e)}catch(r){if(r instanceof i.XRefEntryException&&!e)throw new i.XRefParseException;t.setActualNumPages(1);return}for(const[e,[a,n]]of o){let i;if(a instanceof Error){i=Promise.reject(a);i.catch((()=>{}))}else i=Promise.resolve(new Page({pdfManager:r,xref:this.xref,pageIndex:e,pageDict:a,ref:n,globalIdFactory:this._globalIdFactory,fontCache:t.fontCache,builtInCMapCache:t.builtInCMapCache,standardFontDataCache:t.standardFontDataCache,globalImageCache:t.globalImageCache,nonBlendModesSet:t.nonBlendModesSet,xfaFactory:null}));this._pagePromises.set(e,i)}t.setActualNumPages(o.size)}}fontFallback(e,t){return this.catalog.fontFallback(e,t)}async cleanup(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.catalog?this.catalog.cleanup(e):(0,u.clearGlobalCaches)()}_collectFieldObjects(e,t,r){const i=this.xref.fetchIfRef(t);if(i.has("T")){const t=(0,n.stringToPDFString)(i.get("T"));e=""===e?t:`${e}.${t}`}r.has(e)||r.set(e,[]);r.get(e).push(a.AnnotationFactory.create(this.xref,t,this.pdfManager,this._localIdFactory,!0).then((e=>e&&e.getFieldObject())).catch((function(e){(0,n.warn)(`_collectFieldObjects: "${e}".`);return null})));if(i.has("Kids")){const t=i.get("Kids");for(const a of t)this._collectFieldObjects(e,a,r)}}get fieldObjects(){if(!this.formInfo.hasFields)return(0,n.shadow)(this,"fieldObjects",Promise.resolve(null));const e=Object.create(null),t=new Map;for(const e of this.catalog.acroForm.get("Fields"))this._collectFieldObjects("",e,t);const r=[];for(const[a,n]of t)r.push(Promise.all(n).then((t=>{(t=t.filter((e=>!!e))).length>0&&(e[a]=t)})));return(0,n.shadow)(this,"fieldObjects",Promise.all(r).then((()=>e)))}get hasJSActions(){const e=this.pdfManager.ensureDoc("_parseHasJSActions");return(0,n.shadow)(this,"hasJSActions",e)}async _parseHasJSActions(){const[e,t]=await Promise.all([this.pdfManager.ensureCatalog("jsActions"),this.pdfManager.ensureDoc("fieldObjects")]);return!!e||!!t&&Object.values(t).some((e=>e.some((e=>null!==e.actions))))}get calculationOrderIds(){const e=this.catalog.acroForm;if(!e||!e.has("CO"))return(0,n.shadow)(this,"calculationOrderIds",null);const t=e.get("CO");if(!Array.isArray(t)||0===t.length)return(0,n.shadow)(this,"calculationOrderIds",null);const r=[];for(const e of t)e instanceof s.Ref&&r.push(e.toString());return 0===r.length?(0,n.shadow)(this,"calculationOrderIds",null):(0,n.shadow)(this,"calculationOrderIds",r)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PopupAnnotation=t.MarkupAnnotation=t.AnnotationFactory=t.AnnotationBorderStyle=t.Annotation=void 0;t.getQuadPoints=getQuadPoints;var a=r(2),n=r(131),i=r(138),s=r(130),o=r(190),c=r(132),l=r(185),h=r(194),u=r(139),d=r(197),f=r(200),g=r(187),p=r(135),m=r(201);t.AnnotationFactory=class AnnotationFactory{static create(e,t,r,a,n){return Promise.all([r.ensureCatalog("acroForm"),r.ensureCatalog("baseUrl"),r.ensureDoc("xfaDatasets"),n?this._getPageIndex(e,t,r):-1]).then((i=>{let[s,o,c,l]=i;return r.ensure(this,"_create",[e,t,r,a,s,c,n,l])}))}static _create(e,t,r,i,o,c,l){let h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:-1;const u=e.fetchIfRef(t);if(!(u instanceof s.Dict))return;const d=t instanceof s.Ref?t.toString():`annot_${i.createObjId()}`;let f=u.get("Subtype");f=f instanceof s.Name?f.name:null;const g={xref:e,ref:t,dict:u,subtype:f,id:d,pdfManager:r,acroForm:o instanceof s.Dict?o:s.Dict.empty,xfaDatasets:c,collectFields:l,pageIndex:h};switch(f){case"Link":return new LinkAnnotation(g);case"Text":return new TextAnnotation(g);case"Widget":let e=(0,n.getInheritableProperty)({dict:u,key:"FT"});e=e instanceof s.Name?e.name:null;switch(e){case"Tx":return new TextWidgetAnnotation(g);case"Btn":return new ButtonWidgetAnnotation(g);case"Ch":return new ChoiceWidgetAnnotation(g);case"Sig":return new SignatureWidgetAnnotation(g)}(0,a.warn)(`Unimplemented widget field type "${e}", falling back to base field type.`);return new WidgetAnnotation(g);case"Popup":return new PopupAnnotation(g);case"FreeText":return new FreeTextAnnotation(g);case"Line":return new LineAnnotation(g);case"Square":return new SquareAnnotation(g);case"Circle":return new CircleAnnotation(g);case"PolyLine":return new PolylineAnnotation(g);case"Polygon":return new PolygonAnnotation(g);case"Caret":return new CaretAnnotation(g);case"Ink":return new InkAnnotation(g);case"Highlight":return new HighlightAnnotation(g);case"Underline":return new UnderlineAnnotation(g);case"Squiggly":return new SquigglyAnnotation(g);case"StrikeOut":return new StrikeOutAnnotation(g);case"Stamp":return new StampAnnotation(g);case"FileAttachment":return new FileAttachmentAnnotation(g);default:l||(f?(0,a.warn)(`Unimplemented annotation type "${f}", falling back to base annotation.`):(0,a.warn)("Annotation is missing the required /Subtype."));return new Annotation(g)}}static async _getPageIndex(e,t,r){try{const a=await e.fetchIfRefAsync(t);if(!(a instanceof s.Dict))return-1;const n=a.getRaw("P");if(!(n instanceof s.Ref))return-1;return await r.ensureCatalog("getPageIndex",[n])}catch(e){(0,a.warn)(`_getPageIndex: "${e}".`);return-1}}static async saveNewAnnotations(e,t,r){const n=e.xref;let i;const c=[],l=[];for(const h of r)switch(h.annotationType){case a.AnnotationEditorType.FREETEXT:if(!i){const e=new s.Dict(n);e.set("BaseFont",s.Name.get("Helvetica"));e.set("Type",s.Name.get("Font"));e.set("Subtype",s.Name.get("Type1"));e.set("Encoding",s.Name.get("WinAnsiEncoding"));const t=[];i=n.getNewRef();(0,o.writeObject)(i,e,t,null);c.push({ref:i,data:t.join("")})}l.push(FreeTextAnnotation.createNewAnnotation(n,h,c,{evaluator:e,task:t,baseFontRef:i}));break;case a.AnnotationEditorType.INK:l.push(InkAnnotation.createNewAnnotation(n,h,c))}return{annotations:await Promise.all(l),dependencies:c}}static async printNewAnnotations(e,t,r){if(!r)return null;const n=e.xref,i=[];for(const s of r)switch(s.annotationType){case a.AnnotationEditorType.FREETEXT:i.push(FreeTextAnnotation.createNewPrintAnnotation(n,s,{evaluator:e,task:t}));break;case a.AnnotationEditorType.INK:i.push(InkAnnotation.createNewPrintAnnotation(n,s))}return Promise.all(i)}};function getRgbColor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Uint8ClampedArray(3);if(!Array.isArray(e))return t;const r=t||new Uint8ClampedArray(3);switch(e.length){case 0:return null;case 1:u.ColorSpace.singletons.gray.getRgbItem(e,0,r,0);return r;case 3:u.ColorSpace.singletons.rgb.getRgbItem(e,0,r,0);return r;case 4:u.ColorSpace.singletons.cmyk.getRgbItem(e,0,r,0);return r;default:return t}}function getQuadPoints(e,t){if(!e.has("QuadPoints"))return null;const r=e.getArray("QuadPoints");if(!Array.isArray(r)||0===r.length||r.length%8>0)return null;const a=[];for(let e=0,n=r.length/8;e<n;e++){a.push([]);for(let n=8*e,i=8*e+8;n<i;n+=2){const i=r[n],s=r[n+1];if(null!==t&&(i<t[0]||i>t[2]||s<t[1]||s>t[3]))return null;a[e].push({x:i,y:s})}}return a.map((e=>{const[t,r,a,n]=e.reduce(((e,t)=>{let[r,a,n,i]=e;return[Math.min(r,t.x),Math.max(a,t.x),Math.min(n,t.y),Math.max(i,t.y)]}),[Number.MAX_VALUE,Number.MIN_VALUE,Number.MAX_VALUE,Number.MIN_VALUE]);return[{x:t,y:n},{x:r,y:n},{x:t,y:a},{x:r,y:a}]}))}function getTransformMatrix(e,t,r){const[n,i,s,o]=a.Util.getAxialAlignedBoundingBox(t,r);if(n===s||i===o)return[1,0,0,1,e[0],e[1]];const c=(e[2]-e[0])/(s-n),l=(e[3]-e[1])/(o-i);return[c,0,0,l,e[0]-n*c,e[1]-i*l]}class Annotation{constructor(e){const t=e.dict;this.setTitle(t.get("T"));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.setOptionalContent(t);const r=t.get("MK");this.setBorderAndBackgroundColors(r);this.setRotation(r);this._streams=[];this.appearance&&this._streams.push(this.appearance);this.data={annotationFlags:this.flags,borderStyle:this.borderStyle,color:this.color,backgroundColor:this.backgroundColor,borderColor:this.borderColor,rotation:this.rotation,contentsObj:this._contents,hasAppearance:!!this.appearance,id:e.id,modificationDate:this.modificationDate,rect:this.rectangle,subtype:e.subtype,hasOwnCanvas:!1};if(e.collectFields){const r=t.get("Kids");if(Array.isArray(r)){const e=[];for(const t of r)t instanceof s.Ref&&e.push(t.toString());0!==e.length&&(this.data.kidIds=e)}this.data.actions=(0,n.collectActions)(e.xref,t,a.AnnotationActionEventType);this.data.fieldName=this._constructFieldName(t);this.data.pageIndex=e.pageIndex}this._fallbackFontDict=null}_hasFlag(e,t){return!!(e&t)}_isViewable(e){return!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)&&!this._hasFlag(e,a.AnnotationFlag.NOVIEW)}_isPrintable(e){return this._hasFlag(e,a.AnnotationFlag.PRINT)&&!this._hasFlag(e,a.AnnotationFlag.INVISIBLE)}mustBeViewed(e){const t=e&&e.get(this.data.id);return t&&void 0!==t.hidden?!t.hidden:this.viewable&&!this._hasFlag(this.flags,a.AnnotationFlag.HIDDEN)}mustBePrinted(e){const t=e&&e.get(this.data.id);return t&&void 0!==t.print?t.print:this.printable}get viewable(){return null!==this.data.quadPoints&&(0===this.flags||this._isViewable(this.flags))}get printable(){return null!==this.data.quadPoints&&(0!==this.flags&&this._isPrintable(this.flags))}_parseStringHelper(e){const t="string"==typeof e?(0,a.stringToPDFString)(e):"";return{str:t,dir:t&&"rtl"===(0,l.bidi)(t).dir?"rtl":"ltr"}}setTitle(e){this._title=this._parseStringHelper(e)}setContents(e){this._contents=this._parseStringHelper(e)}setModificationDate(e){this.modificationDate="string"==typeof 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){this.color=getRgbColor(e)}setLineEndings(e){this.lineEndings=["None","None"];if(Array.isArray(e)&&2===e.length)for(let t=0;t<2;t++){const r=e[t];if(r instanceof s.Name)switch(r.name){case"None":continue;case"Square":case"Circle":case"Diamond":case"OpenArrow":case"ClosedArrow":case"Butt":case"ROpenArrow":case"RClosedArrow":case"Slash":this.lineEndings[t]=r.name;continue}(0,a.warn)(`Ignoring invalid lineEnding: ${r}`)}}setRotation(e){this.rotation=0;if(e instanceof s.Dict){let t=e.get("R")||0;if(Number.isInteger(t)&&0!==t){t%=360;t<0&&(t+=360);t%90==0&&(this.rotation=t)}}}setBorderAndBackgroundColors(e){if(e instanceof s.Dict){this.borderColor=getRgbColor(e.getArray("BC"),null);this.backgroundColor=getRgbColor(e.getArray("BG"),null)}else this.borderColor=this.backgroundColor=null}setBorderStyle(e){this.borderStyle=new AnnotationBorderStyle;if(e instanceof s.Dict)if(e.has("BS")){const t=e.get("BS"),r=t.get("Type");if(!r||(0,s.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],!0)}}else this.borderStyle.setWidth(0)}setAppearance(e){this.appearance=null;const t=e.get("AP");if(!(t instanceof s.Dict))return;const r=t.get("N");if(r instanceof c.BaseStream){this.appearance=r;return}if(!(r instanceof s.Dict))return;const a=e.get("AS");a instanceof s.Name&&r.has(a.name)&&(this.appearance=r.get(a.name))}setOptionalContent(e){this.oc=null;const t=e.get("OC");t instanceof s.Name?(0,a.warn)("setOptionalContent: Support for /Name-entry is not implemented."):t instanceof s.Dict&&(this.oc=t)}loadResources(e,t){return t.dict.getAsync("Resources").then((t=>{if(!t)return;return new f.ObjectLoader(t,e,t.xref).load().then((function(){return t}))}))}async getOperatorList(e,t,r,n,i){const o=this.data;let c=this.appearance;const l=!!(this.data.hasOwnCanvas&&r&a.RenderingIntentFlag.DISPLAY);if(!c){if(!l)return{opList:new g.OperatorList,separateForm:!1,separateCanvas:!1};c=new p.StringStream("");c.dict=new s.Dict}const h=c.dict,u=await this.loadResources(["ExtGState","ColorSpace","Pattern","Shading","XObject","Font"],c),d=h.getArray("BBox")||[0,0,1,1],f=h.getArray("Matrix")||[1,0,0,1,0,0],m=getTransformMatrix(o.rect,d,f),b=new g.OperatorList;let y;this.oc&&(y=await e.parseMarkedContentProps(this.oc,null));void 0!==y&&b.addOp(a.OPS.beginMarkedContentProps,["OC",y]);b.addOp(a.OPS.beginAnnotation,[o.id,o.rect,m,f,l]);await e.getOperatorList({stream:c,task:t,resources:u,operatorList:b,fallbackFontDict:this._fallbackFontDict});b.addOp(a.OPS.endAnnotation,[]);void 0!==y&&b.addOp(a.OPS.endMarkedContent,[]);this.reset();return{opList:b,separateForm:!1,separateCanvas:l}}async save(e,t,r){return null}get hasTextContent(){return!1}async extractTextContent(e,t,r){if(!this.appearance)return;const a=await this.loadResources(["ExtGState","Font","Properties","XObject"],this.appearance),n=[],i=[],s={desiredSize:Math.Infinity,ready:!0,enqueue(e,t){for(const t of e.items){i.push(t.str);if(t.hasEOL){n.push(i.join(""));i.length=0}}}};await e.getTextContent({stream:this.appearance,task:t,resources:a,includeMarkedContent:!0,combineTextItems:!0,sink:s,viewBox:r});this.reset();i.length&&n.push(i.join(""));n.length>0&&(this.data.textContent=n)}getFieldObject(){return this.data.kidIds?{id:this.data.id,actions:this.data.actions,name:this.data.fieldName,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,type:"",kidIds:this.data.kidIds,page:this.data.pageIndex,rotation:this.rotation}:null}reset(){for(const e of this._streams)e.reset()}_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;const n=new s.RefSet;e.objId&&n.put(e.objId);for(;r.has("Parent");){r=r.get("Parent");if(!(r instanceof s.Dict)||r.objId&&n.has(r.objId))break;r.objId&&n.put(r.objId);r.has("T")&&t.unshift((0,a.stringToPDFString)(r.get("T")))}return t.join(".")}}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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0,0];if(e instanceof s.Name)this.width=0;else if("number"==typeof e){if(e>0){const r=(t[2]-t[0])/2,n=(t[3]-t[1])/2;if(r>0&&n>0&&(e>r||e>n)){(0,a.warn)(`AnnotationBorderStyle.setWidth - ignoring width: ${e}`);e=1}}this.width=e}}setStyle(e){if(e instanceof s.Name)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){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Array.isArray(e)&&e.length>0){let r=!0,a=!0;for(const t of e){if(!(+t>=0)){r=!1;break}t>0&&(a=!1)}if(r&&!a){this.dashArray=e;t&&this.setStyle(s.Name.get("D"))}else 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=e instanceof s.Ref?e.toString():null;const r=t.get("RT");this.data.replyType=r instanceof s.Name?r.name:a.AnnotationReplyType.REPLY}if(this.data.replyType===a.AnnotationReplyType.GROUP){const e=t.get("IRT");this.setTitle(e.get("T"));this.data.titleObj=this._title;this.setContents(e.get("Contents"));this.data.contentsObj=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.titleObj=this._title;this.setCreationDate(t.get("CreationDate"));this.data.creationDate=this.creationDate;this.data.hasPopup=t.has("Popup");t.has("C")||(this.data.color=null)}t.has("RC")&&(this.data.richText=m.XFAFactory.getRichTextAsHtml(t.get("RC")))}setCreationDate(e){this.creationDate="string"==typeof e?e:null}_setDefaultAppearance(e){let{xref:t,extra:r,strokeColor:a,fillColor:n,blendMode:i,strokeAlpha:o,fillAlpha:c,pointsCallback:l}=e,h=Number.MAX_VALUE,u=Number.MAX_VALUE,d=Number.MIN_VALUE,f=Number.MIN_VALUE;const g=["q"];r&&g.push(r);a&&g.push(`${a[0]} ${a[1]} ${a[2]} RG`);n&&g.push(`${n[0]} ${n[1]} ${n[2]} rg`);let m=this.data.quadPoints;m||(m=[[{x:this.rectangle[0],y:this.rectangle[3]},{x:this.rectangle[2],y:this.rectangle[3]},{x:this.rectangle[0],y:this.rectangle[1]},{x:this.rectangle[2],y:this.rectangle[1]}]]);for(const e of m){const[t,r,a,n]=l(g,e);h=Math.min(h,t);d=Math.max(d,r);u=Math.min(u,a);f=Math.max(f,n)}g.push("Q");const b=new s.Dict(t),y=new s.Dict(t);y.set("Subtype",s.Name.get("Form"));const w=new p.StringStream(g.join(" "));w.dict=y;b.set("Fm0",w);const S=new s.Dict(t);i&&S.set("BM",s.Name.get(i));"number"==typeof o&&S.set("CA",o);"number"==typeof c&&S.set("ca",c);const x=new s.Dict(t);x.set("GS0",S);const k=new s.Dict(t);k.set("ExtGState",x);k.set("XObject",b);const C=new s.Dict(t);C.set("Resources",k);const v=this.data.rect=[h,u,d,f];C.set("BBox",v);this.appearance=new p.StringStream("/GS0 gs /Fm0 Do");this.appearance.dict=C;this._streams.push(this.appearance,w)}static async createNewAnnotation(e,t,r,a){const n=e.getNewRef(),i=e.getNewRef(),s=this.createNewDict(t,e,{apRef:i}),c=await this.createNewAppearanceStream(t,e,a),l=[];let h=e.encrypt?e.encrypt.createCipherTransform(i.num,i.gen):null;(0,o.writeObject)(i,c,l,h);r.push({ref:i,data:l.join("")});l.length=0;h=e.encrypt?e.encrypt.createCipherTransform(n.num,n.gen):null;(0,o.writeObject)(n,s,l,h);return{ref:n,data:l.join("")}}static async createNewPrintAnnotation(e,t,r){const a=await this.createNewAppearanceStream(t,e,r),n=this.createNewDict(t,e,{ap:a});return new this.prototype.constructor({dict:n,xref:e})}}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;void 0===r.fieldName&&(r.fieldName=this._constructFieldName(t));void 0===r.actions&&(r.actions=(0,n.collectActions)(e.xref,t,a.AnnotationActionEventType));let o=(0,n.getInheritableProperty)({dict:t,key:"V",getArray:!0});r.fieldValue=this._decodeFormValue(o);const c=(0,n.getInheritableProperty)({dict:t,key:"DV",getArray:!0});r.defaultFieldValue=this._decodeFormValue(c);if(void 0===o&&e.xfaDatasets){const t=this._title.str;if(t){this._hasValueFromXFA=!0;r.fieldValue=o=e.xfaDatasets.getValue(t)}}void 0===o&&null!==r.defaultFieldValue&&(r.fieldValue=r.defaultFieldValue);r.alternativeText=(0,a.stringToPDFString)(t.get("TU")||"");const l=(0,n.getInheritableProperty)({dict:t,key:"DA"})||e.acroForm.get("DA");this._defaultAppearance="string"==typeof l?l:"";r.defaultAppearanceData=(0,i.parseDefaultAppearance)(this._defaultAppearance);const h=(0,n.getInheritableProperty)({dict:t,key:"FT"});r.fieldType=h instanceof s.Name?h.name:null;const u=(0,n.getInheritableProperty)({dict:t,key:"DR"}),d=e.acroForm.get("DR"),f=this.appearance&&this.appearance.dict.get("Resources");this._fieldResources={localResources:u,acroFormResources:d,appearanceResources:f,mergedResources:s.Dict.merge({xref:e.xref,dictArray:[u,f,d],mergeSubDicts:!0})};r.fieldFlags=(0,n.getInheritableProperty)({dict:t,key:"Ff"});(!Number.isInteger(r.fieldFlags)||r.fieldFlags<0)&&(r.fieldFlags=0);r.readOnly=this.hasFieldFlag(a.AnnotationFieldFlag.READONLY);r.required=this.hasFieldFlag(a.AnnotationFieldFlag.REQUIRED);r.hidden=this._hasFlag(r.annotationFlags,a.AnnotationFlag.HIDDEN)}_decodeFormValue(e){return Array.isArray(e)?e.filter((e=>"string"==typeof e)).map((e=>(0,a.stringToPDFString)(e))):e instanceof s.Name?(0,a.stringToPDFString)(e.name):"string"==typeof e?(0,a.stringToPDFString)(e):null}hasFieldFlag(e){return!!(this.data.fieldFlags&e)}static _getRotationMatrix(e,t,r){switch(e){case 90:return[0,1,-1,0,t,0];case 180:return[-1,0,0,-1,t,r];case 270:return[0,-1,1,0,0,r];default:throw new Error("Invalid rotation")}}getRotationMatrix(e){const t=e?e.get(this.data.id):void 0;let r=t&&t.rotation;void 0===r&&(r=this.rotation);if(0===r)return a.IDENTITY_MATRIX;const n=this.data.rect[2]-this.data.rect[0],i=this.data.rect[3]-this.data.rect[1];return WidgetAnnotation._getRotationMatrix(r,n,i)}getBorderAndBackgroundAppearances(e){const t=e?e.get(this.data.id):void 0;let r=t&&t.rotation;void 0===r&&(r=this.rotation);if(!this.backgroundColor&&!this.borderColor)return"";const a=this.data.rect[2]-this.data.rect[0],n=this.data.rect[3]-this.data.rect[1],s=0===r||180===r?`0 0 ${a} ${n} re`:`0 0 ${n} ${a} re`;let o="";this.backgroundColor&&(o=`${(0,i.getPdfColor)(this.backgroundColor,!0)} ${s} f `);if(this.borderColor){o+=`${this.borderStyle.width||1} w ${(0,i.getPdfColor)(this.borderColor,!1)} ${s} S `}return o}async getOperatorList(e,t,r,n,i){if(n&&!(this instanceof SignatureWidgetAnnotation))return{opList:new g.OperatorList,separateForm:!0,separateCanvas:!1};if(!this._hasText)return super.getOperatorList(e,t,r,n,i);const s=await this._getAppearance(e,t,i);if(this.appearance&&null===s)return super.getOperatorList(e,t,r,n,i);const o=new g.OperatorList;if(!this._defaultAppearance||null===s)return{opList:o,separateForm:!1,separateCanvas:!1};const c=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],l=getTransformMatrix(this.data.rect,c,[1,0,0,1,0,0]);let h;this.oc&&(h=await e.parseMarkedContentProps(this.oc,null));void 0!==h&&o.addOp(a.OPS.beginMarkedContentProps,["OC",h]);o.addOp(a.OPS.beginAnnotation,[this.data.id,this.data.rect,l,this.getRotationMatrix(i),!1]);const u=new p.StringStream(s);await e.getOperatorList({stream:u,task:t,resources:this._fieldResources.mergedResources,operatorList:o});o.addOp(a.OPS.endAnnotation,[]);void 0!==h&&o.addOp(a.OPS.endMarkedContent,[]);return{opList:o,separateForm:!1,separateCanvas:!1}}_getMKDict(e){const t=new s.Dict(null);e&&t.set("R",e);this.borderColor&&t.set("BC",Array.from(this.borderColor).map((e=>e/255)));this.backgroundColor&&t.set("BG",Array.from(this.backgroundColor).map((e=>e/255)));return t.size>0?t:null}async save(e,t,r){const n=r?r.get(this.data.id):void 0;let i=n&&n.value,c=n&&n.rotation;if(i===this.data.fieldValue||void 0===i){if(!this._hasValueFromXFA&&void 0===c)return null;i=i||this.data.fieldValue}if(void 0===c&&!this._hasValueFromXFA&&Array.isArray(i)&&Array.isArray(this.data.fieldValue)&&i.length===this.data.fieldValue.length&&i.every(((e,t)=>e===this.data.fieldValue[t])))return null;void 0===c&&(c=this.rotation);let l=await this._getAppearance(e,t,r);if(null===l)return null;const{xref:h}=e,u=h.fetchIfRef(this.ref);if(!(u instanceof s.Dict))return null;const d=[0,0,this.data.rect[2]-this.data.rect[0],this.data.rect[3]-this.data.rect[1]],f={path:(0,a.stringToPDFString)(u.get("T")||""),value:i},g=h.getNewRef(),p=new s.Dict(h);p.set("N",g);const m=h.encrypt;let b=null,y=null;if(m){b=m.createCipherTransform(this.ref.num,this.ref.gen);y=m.createCipherTransform(g.num,g.gen);l=y.encryptString(l)}const encoder=e=>(0,a.isAscii)(e)?e:(0,a.stringToUTF16BEString)(e);u.set("V",Array.isArray(i)?i.map(encoder):encoder(i));u.set("AP",p);u.set("M",`D:${(0,a.getModificationDate)()}`);const w=this._getMKDict(c);w&&u.set("MK",w);const S=new s.Dict(h);S.set("Length",l.length);S.set("Subtype",s.Name.get("Form"));S.set("Resources",this._getSaveFieldResources(h));S.set("BBox",d);const x=this.getRotationMatrix(r);x!==a.IDENTITY_MATRIX&&S.set("Matrix",x);const k=[`${this.ref.num} ${this.ref.gen} obj\n`];(0,o.writeDict)(u,k,b);k.push("\nendobj\n");const C=[`${g.num} ${g.gen} obj\n`];(0,o.writeDict)(S,C,y);C.push(" stream\n",l,"\nendstream\nendobj\n");return[{ref:this.ref,data:k.join(""),xfa:f},{ref:g,data:C.join(""),xfa:null}]}async _getAppearance(e,t,r){if(this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD))return null;const n=r?r.get(this.data.id):void 0;let s,o;if(n){s=n.formattedValue||n.value;o=n.rotation}if(void 0===o&&void 0===s&&(!this._hasValueFromXFA||this.appearance))return null;if(void 0===s){s=this.data.fieldValue;if(!s)return""}Array.isArray(s)&&1===s.length&&(s=s[0]);(0,a.assert)("string"==typeof s,"Expected `value` to be a string.");s=s.trim();if(""===s)return"";void 0===o&&(o=this.rotation);let c=-1;this.data.multiLine&&(c=s.split(/\r\n|\r|\n/).length);let l=this.data.rect[3]-this.data.rect[1],h=this.data.rect[2]-this.data.rect[0];90!==o&&270!==o||([h,l]=[l,h]);this._defaultAppearance||(this.data.defaultAppearanceData=(0,i.parseDefaultAppearance)(this._defaultAppearance="/Helvetica 0 Tf 0 g"));const u=await WidgetAnnotation._getFontData(e,t,this.data.defaultAppearanceData,this._fieldResources.mergedResources),[d,f]=this._computeFontSize(l-2,h-4,s,u,c);let g=u.descent;isNaN(g)&&(g=0);const p=Math.min(Math.floor((l-f)/2),2)+Math.abs(g)*f,m=this.data.textAlignment;if(this.data.multiLine)return this._getMultilineAppearance(d,s,u,f,h,l,m,2,p,r);const b=u.encodeString(s).join("");if(this.data.comb)return this._getCombAppearance(d,u,b,h,2,p,r);const y=this.getBorderAndBackgroundAppearances(r);if(0===m||m>2)return`/Tx BMC q ${y}BT `+d+` 1 0 0 1 2 ${p} Tm (${(0,a.escapeString)(b)}) Tj ET Q EMC`;return`/Tx BMC q ${y}BT `+d+` 1 0 0 1 0 0 Tm ${this._renderText(b,u,f,h,m,2,p)} ET Q EMC`}static async _getFontData(e,t,r,a){const n=new g.OperatorList,i={font:null,clone(){return this}},{fontName:o,fontSize:c}=r;await e.handleSetFont(a,[o&&s.Name.get(o),c],null,n,t,i,null);return i.font}_getTextWidth(e,t){return t.charsToGlyphs(e).reduce(((e,t)=>e+t.width),0)/1e3}_computeFontSize(e,t,r,n,s){let{fontSize:o}=this.data.defaultAppearanceData;if(!o){const roundWithTwoDigits=e=>Math.floor(100*e)/100;if(-1===s){const i=this._getTextWidth(r,n);o=roundWithTwoDigits(Math.min(e/a.LINE_FACTOR,t/i))}else{const i=r.split(/\r\n?|\n/),c=[];for(const e of i){const t=n.encodeString(e).join(""),r=n.charsToGlyphs(t),a=n.getCharPositions(t);c.push({line:t,glyphs:r,positions:a})}const isTooBig=r=>{let a=0;for(const i of c){a+=this._splitLine(null,n,r,t,i).length*r;if(a>e)return!0}return!1};o=12;let l=o*a.LINE_FACTOR,h=Math.round(e/l);h=Math.max(h,s);for(;;){l=e/h;o=roundWithTwoDigits(l/a.LINE_FACTOR);if(!isTooBig(o))break;h++}}const{fontName:c,fontColor:l}=this.data.defaultAppearanceData;this._defaultAppearance=(0,i.createDefaultAppearance)({fontSize:o,fontName:c,fontColor:l})}return[this._defaultAppearance,o]}_renderText(e,t,r,i,s,o,c){let l;if(1===s){l=(i-this._getTextWidth(e,t)*r)/2}else if(2===s){l=i-this._getTextWidth(e,t)*r-o}else l=o;l=(0,n.numberToString)(l);return`${l} ${c=(0,n.numberToString)(c)} Td (${(0,a.escapeString)(e)}) Tj`}_getSaveFieldResources(e){const{localResources:t,appearanceResources:r,acroFormResources:a}=this._fieldResources,n=this.data.defaultAppearanceData&&this.data.defaultAppearanceData.fontName;if(!n)return t||s.Dict.empty;for(const e of[t,r])if(e instanceof s.Dict){const t=e.get("Font");if(t instanceof s.Dict&&t.has(n))return e}if(a instanceof s.Dict){const r=a.get("Font");if(r instanceof s.Dict&&r.has(n)){const a=new s.Dict(e);a.set(n,r.getRaw(n));const i=new s.Dict(e);i.set("Font",a);return s.Dict.merge({xref:e,dictArray:[i,t],mergeSubDicts:!0})}}return t||s.Dict.empty}getFieldObject(){return null}}class TextWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this._hasText=!0;const t=e.dict;"string"!=typeof this.data.fieldValue&&(this.data.fieldValue="");let r=(0,n.getInheritableProperty)({dict:t,key:"Q"});(!Number.isInteger(r)||r<0||r>2)&&(r=null);this.data.textAlignment=r;let i=(0,n.getInheritableProperty)({dict:t,key:"MaxLen"});(!Number.isInteger(i)||i<0)&&(i=0);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)&&0!==this.data.maxLen;this.data.doNotScroll=this.hasFieldFlag(a.AnnotationFieldFlag.DONOTSCROLL)}_getCombAppearance(e,t,r,i,s,o,c){const l=(0,n.numberToString)(i/this.data.maxLen),h=[],u=t.getCharPositions(r);for(const[e,t]of u)h.push(`(${(0,a.escapeString)(r.substring(e,t))}) Tj`);return`/Tx BMC q ${this.getBorderAndBackgroundAppearances(c)}BT `+e+` 1 0 0 1 ${s} ${o} Tm ${h.join(` ${l} 0 Td `)} ET Q EMC`}_getMultilineAppearance(e,t,r,a,n,i,s,o,c,l){const h=t.split(/\r\n?|\n/),u=[],d=n-2*o;for(const e of h){const t=this._splitLine(e,r,a,d);for(const e of t){const t=0===u.length?o:0;u.push(this._renderText(e,r,a,n,s,t,-a))}}const f=u.join("\n");return`/Tx BMC q ${this.getBorderAndBackgroundAppearances(l)}BT `+e+` 1 0 0 1 0 ${i} Tm ${f} ET Q EMC`}_splitLine(e,t,r,a){let n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e=n.line||t.encodeString(e).join("");const i=n.glyphs||t.charsToGlyphs(e);if(i.length<=1)return[e];const s=n.positions||t.getCharPositions(e),o=r/1e3,c=[];let l=-1,h=-1,u=-1,d=0,f=0;for(let t=0,r=i.length;t<r;t++){const[r,n]=s[t],g=i[t],p=g.width*o;if(" "===g.unicode)if(f+p>a){c.push(e.substring(d,r));d=r;f=p;l=-1;u=-1}else{f+=p;l=r;h=n;u=t}else if(f+p>a)if(-1!==l){c.push(e.substring(d,h));d=h;t=u+1;l=-1;f=0}else{c.push(e.substring(d,r));d=r;f=p}else f+=p}d<e.length&&c.push(e.substring(d,e.length));return c}getFieldObject(){return{id:this.data.id,value:this.data.fieldValue,defaultValue:this.data.defaultFieldValue||"",multiline:this.data.multiLine,password:this.hasFieldFlag(a.AnnotationFieldFlag.PASSWORD),charLimit:this.data.maxLen,comb:this.data.comb,editable:!this.data.readOnly,hidden:this.data.hidden,name:this.data.fieldName,rect:this.data.rect,actions:this.data.actions,page:this.data.pageIndex,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,rotation:this.rotation,type:"text"}}}class ButtonWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this.checkedAppearance=null;this.uncheckedAppearance=null;this.data.checkBox=!this.hasFieldFlag(a.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON);this.data.radioButton=this.hasFieldFlag(a.AnnotationFieldFlag.RADIO)&&!this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON);this.data.pushButton=this.hasFieldFlag(a.AnnotationFieldFlag.PUSHBUTTON);this.data.isTooltipOnly=!1;if(this.data.checkBox)this._processCheckBox(e);else if(this.data.radioButton)this._processRadioButton(e);else if(this.data.pushButton){this.data.hasOwnCanvas=!0;this._processPushButton(e)}else(0,a.warn)("Invalid field flags for button widget annotation")}async getOperatorList(e,t,r,n,i){if(this.data.pushButton)return super.getOperatorList(e,t,r,!1,i);let s=null,o=null;if(i){const e=i.get(this.data.id);s=e?e.value:null;o=e?e.rotation:null}if(null===s&&this.appearance)return super.getOperatorList(e,t,r,n,i);null==s&&(s=this.data.checkBox?this.data.fieldValue===this.data.exportValue:this.data.fieldValue===this.data.buttonValue);const c=s?this.checkedAppearance:this.uncheckedAppearance;if(c){const s=this.appearance,l=c.dict.getArray("Matrix")||a.IDENTITY_MATRIX;o&&c.dict.set("Matrix",this.getRotationMatrix(i));this.appearance=c;const h=super.getOperatorList(e,t,r,n,i);this.appearance=s;c.dict.set("Matrix",l);return h}return{opList:new g.OperatorList,separateForm:!1,separateCanvas:!1}}async save(e,t,r){return this.data.checkBox?this._saveCheckbox(e,t,r):this.data.radioButton?this._saveRadioButton(e,t,r):null}async _saveCheckbox(e,t,r){if(!r)return null;const n=r.get(this.data.id);let i=n&&n.rotation,c=n&&n.value;if(void 0===i){if(void 0===c)return null;if(this.data.fieldValue===this.data.exportValue===c)return null}const l=e.xref.fetchIfRef(this.ref);if(!(l instanceof s.Dict))return null;void 0===i&&(i=this.rotation);void 0===c&&(c=this.data.fieldValue===this.data.exportValue);const h={path:(0,a.stringToPDFString)(l.get("T")||""),value:c?this.data.exportValue:""},u=s.Name.get(c?this.data.exportValue:"Off");l.set("V",u);l.set("AS",u);l.set("M",`D:${(0,a.getModificationDate)()}`);const d=this._getMKDict(i);d&&l.set("MK",d);const f=e.xref.encrypt;let g=null;f&&(g=f.createCipherTransform(this.ref.num,this.ref.gen));const p=[`${this.ref.num} ${this.ref.gen} obj\n`];(0,o.writeDict)(l,p,g);p.push("\nendobj\n");return[{ref:this.ref,data:p.join(""),xfa:h}]}async _saveRadioButton(e,t,r){if(!r)return null;const n=r.get(this.data.id);let i=n&&n.rotation,c=n&&n.value;if(void 0===i){if(void 0===c)return null;if(this.data.fieldValue===this.data.buttonValue===c)return null}const l=e.xref.fetchIfRef(this.ref);if(!(l instanceof s.Dict))return null;void 0===c&&(c=this.data.fieldValue===this.data.buttonValue);void 0===i&&(i=this.rotation);const h={path:(0,a.stringToPDFString)(l.get("T")||""),value:c?this.data.buttonValue:""},u=s.Name.get(c?this.data.buttonValue:"Off");let d=null;const f=e.xref.encrypt;if(c)if(this.parent instanceof s.Ref){const t=e.xref.fetch(this.parent);let r=null;f&&(r=f.createCipherTransform(this.parent.num,this.parent.gen));t.set("V",u);d=[`${this.parent.num} ${this.parent.gen} obj\n`];(0,o.writeDict)(t,d,r);d.push("\nendobj\n")}else this.parent instanceof s.Dict&&this.parent.set("V",u);l.set("AS",u);l.set("M",`D:${(0,a.getModificationDate)()}`);const g=this._getMKDict(i);g&&l.set("MK",g);let p=null;f&&(p=f.createCipherTransform(this.ref.num,this.ref.gen));const m=[`${this.ref.num} ${this.ref.gen} obj\n`];(0,o.writeDict)(l,m,p);m.push("\nendobj\n");const b=[{ref:this.ref,data:m.join(""),xfa:h}];null!==d&&b.push({ref:this.parent,data:d.join(""),xfa:null});return b}_getDefaultCheckedAppearance(e,t){const r=this.data.rect[2]-this.data.rect[0],i=this.data.rect[3]-this.data.rect[1],o=[0,0,r,i],c=.8*Math.min(r,i);let l,h;if("check"===t){l={width:.755*c,height:.705*c};h="3"}else if("disc"===t){l={width:.791*c,height:.705*c};h="l"}else(0,a.unreachable)(`_getDefaultCheckedAppearance - unsupported type: ${t}`);const u=`q BT /PdfJsZaDb ${c} Tf 0 g ${(0,n.numberToString)((r-l.width)/2)} ${(0,n.numberToString)((i-l.height)/2)} Td (${h}) Tj ET Q`,d=new s.Dict(e.xref);d.set("FormType",1);d.set("Subtype",s.Name.get("Form"));d.set("Type",s.Name.get("XObject"));d.set("BBox",o);d.set("Matrix",[1,0,0,1,0,0]);d.set("Length",u.length);const f=new s.Dict(e.xref),g=new s.Dict(e.xref);g.set("PdfJsZaDb",this.fallbackFontDict);f.set("Font",g);d.set("Resources",f);this.checkedAppearance=new p.StringStream(u);this.checkedAppearance.dict=d;this._streams.push(this.checkedAppearance)}_processCheckBox(e){const t=e.dict.get("AP");if(!(t instanceof s.Dict))return;const r=t.get("N");if(!(r instanceof s.Dict))return;const a=this._decodeFormValue(e.dict.get("AS"));"string"==typeof a&&(this.data.fieldValue=a);const n=null!==this.data.fieldValue&&"Off"!==this.data.fieldValue?this.data.fieldValue:"Yes",i=r.getKeys();if(0===i.length)i.push("Off",n);else if(1===i.length)"Off"===i[0]?i.push(n):i.unshift("Off");else if(i.includes(n)){i.length=0;i.push("Off",n)}else{const e=i.find((e=>"Off"!==e));i.length=0;i.push("Off",e)}i.includes(this.data.fieldValue)||(this.data.fieldValue="Off");this.data.exportValue=i[1];this.checkedAppearance=r.get(this.data.exportValue)||null;this.uncheckedAppearance=r.get("Off")||null;this.checkedAppearance?this._streams.push(this.checkedAppearance):this._getDefaultCheckedAppearance(e,"check");this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance);this._fallbackFontDict=this.fallbackFontDict}_processRadioButton(e){this.data.fieldValue=this.data.buttonValue=null;const t=e.dict.get("Parent");if(t instanceof s.Dict){this.parent=e.dict.getRaw("Parent");const r=t.get("V");r instanceof s.Name&&(this.data.fieldValue=this._decodeFormValue(r))}const r=e.dict.get("AP");if(!(r instanceof s.Dict))return;const a=r.get("N");if(a instanceof s.Dict){for(const e of a.getKeys())if("Off"!==e){this.data.buttonValue=this._decodeFormValue(e);break}this.checkedAppearance=a.get(this.data.buttonValue)||null;this.uncheckedAppearance=a.get("Off")||null;this.checkedAppearance?this._streams.push(this.checkedAppearance):this._getDefaultCheckedAppearance(e,"disc");this.uncheckedAppearance&&this._streams.push(this.uncheckedAppearance);this._fallbackFontDict=this.fallbackFontDict}}_processPushButton(e){if(e.dict.has("A")||e.dict.has("AA")||this.data.alternativeText){this.data.isTooltipOnly=!e.dict.has("A")&&!e.dict.has("AA");h.Catalog.parseDestDictionary({destDict:e.dict,resultObj:this.data,docBaseUrl:e.pdfManager.docBaseUrl})}else(0,a.warn)("Push buttons without action dictionaries are not supported")}getFieldObject(){let e,t="button";if(this.data.checkBox){t="checkbox";e=this.data.exportValue}else if(this.data.radioButton){t="radiobutton";e=this.data.buttonValue}return{id:this.data.id,value:this.data.fieldValue||"Off",defaultValue:this.data.defaultFieldValue,exportValues:e,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,hidden:this.data.hidden,actions:this.data.actions,page:this.data.pageIndex,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,rotation:this.rotation,type:t}}get fallbackFontDict(){const e=new s.Dict;e.set("BaseFont",s.Name.get("ZapfDingbats"));e.set("Type",s.Name.get("FallbackType"));e.set("Subtype",s.Name.get("FallbackType"));e.set("Encoding",s.Name.get("ZapfDingbatsEncoding"));return(0,a.shadow)(this,"fallbackFontDict",e)}}class ChoiceWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this.data.options=[];const t=(0,n.getInheritableProperty)({dict:e.dict,key:"Opt"});if(Array.isArray(t)){const r=e.xref;for(let e=0,a=t.length;e<a;e++){const a=r.fetchIfRef(t[e]),n=Array.isArray(a);this.data.options[e]={exportValue:this._decodeFormValue(n?r.fetchIfRef(a[0]):a),displayValue:this._decodeFormValue(n?r.fetchIfRef(a[1]):a)}}}"string"==typeof this.data.fieldValue?this.data.fieldValue=[this.data.fieldValue]:this.data.fieldValue||(this.data.fieldValue=[]);this.data.combo=this.hasFieldFlag(a.AnnotationFieldFlag.COMBO);this.data.multiSelect=this.hasFieldFlag(a.AnnotationFieldFlag.MULTISELECT);this._hasText=!0}getFieldObject(){const e=this.data.combo?"combobox":"listbox",t=this.data.fieldValue.length>0?this.data.fieldValue[0]:null;return{id:this.data.id,value:t,defaultValue:this.data.defaultFieldValue,editable:!this.data.readOnly,name:this.data.fieldName,rect:this.data.rect,numItems:this.data.fieldValue.length,multipleSelection:this.data.multiSelect,hidden:this.data.hidden,actions:this.data.actions,items:this.data.options,page:this.data.pageIndex,strokeColor:this.data.borderColor,fillColor:this.data.backgroundColor,rotation:this.rotation,type:e}}async _getAppearance(e,t,r){if(this.data.combo)return super._getAppearance(e,t,r);if(!r)return null;const n=r.get(this.data.id);if(!n)return null;const s=n.rotation;let o=n.value;if(void 0===s&&void 0===o)return null;void 0===o?o=this.data.fieldValue:Array.isArray(o)||(o=[o]);let c=this.data.rect[3]-this.data.rect[1],l=this.data.rect[2]-this.data.rect[0];90!==s&&270!==s||([l,c]=[c,l]);const h=this.data.options.length,u=[];for(let e=0;e<h;e++){const{exportValue:t}=this.data.options[e];o.includes(t)&&u.push(e)}this._defaultAppearance||(this.data.defaultAppearanceData=(0,i.parseDefaultAppearance)(this._defaultAppearance="/Helvetica 0 Tf 0 g"));const d=await WidgetAnnotation._getFontData(e,t,this.data.defaultAppearanceData,this._fieldResources.mergedResources);let f,{fontSize:g}=this.data.defaultAppearanceData;if(g)f=this._defaultAppearance;else{const e=(c-2)/h;let t,r=-1;for(const{displayValue:e}of this.data.options){const a=this._getTextWidth(e,d);if(a>r){r=a;t=e}}[f,g]=this._computeFontSize(e,l-4,t,d,-1)}const p=g*a.LINE_FACTOR,m=(p-g)/2,b=Math.floor(c/p);let y;if(1===u.length){const e=u[0];y=e-e%b}else y=u.length?u[0]:0;const w=Math.min(y+b+1,h),S=["/Tx BMC q",`1 1 ${l} ${c} re W n`];if(u.length){S.push("0.600006 0.756866 0.854904 rg");for(const e of u)y<=e&&e<w&&S.push(`1 ${c-(e-y+1)*p} ${l} ${p} re f`)}S.push("BT",f,`1 0 0 1 0 ${c} Tm`);for(let e=y;e<w;e++){const{displayValue:t}=this.data.options[e],r=e===y?2:0,a=e===y?m:0;S.push(this._renderText(t,d,g,l,0,r,-p+a))}S.push("ET Q EMC");return S.join("\n")}}class SignatureWidgetAnnotation extends WidgetAnnotation{constructor(e){super(e);this.data.fieldValue=null}getFieldObject(){return{id:this.data.id,value:null,page:this.data.pageIndex,type:"signature"}}}class TextAnnotation extends MarkupAnnotation{constructor(e){super(e);const t=e.dict;this.data.annotationType=a.AnnotationType.TEXT;if(this.data.hasAppearance)this.data.name="NoIcon";else{this.data.rect[1]=this.data.rect[3]-22;this.data.rect[2]=this.data.rect[0]+22;this.data.name=t.has("Name")?t.get("Name").name:"Note"}if(t.has("State")){this.data.state=t.get("State")||null;this.data.stateModel=t.get("StateModel")||null}else{this.data.state=null;this.data.stateModel=null}}}class LinkAnnotation extends Annotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.LINK;const t=getQuadPoints(e.dict,this.rectangle);t&&(this.data.quadPoints=t);this.data.borderColor=this.data.borderColor||this.data.color;h.Catalog.parseDestDictionary({destDict:e.dict,resultObj:this.data,docBaseUrl:e.pdfManager.docBaseUrl})}}class PopupAnnotation extends Annotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.POPUP;let t=e.dict.get("Parent");if(!t){(0,a.warn)("Popup annotation has a missing or invalid parent annotation.");return}const r=t.get("Subtype");this.data.parentType=r instanceof s.Name?r.name:null;const n=e.dict.getRaw("Parent");this.data.parentId=n instanceof s.Ref?n.toString():null;const i=t.getArray("Rect");Array.isArray(i)&&4===i.length?this.data.parentRect=a.Util.normalizeRect(i):this.data.parentRect=[0,0,0,0];const o=t.get("RT");(0,s.isName)(o,a.AnnotationReplyType.GROUP)&&(t=t.get("IRT"));if(t.has("M")){this.setModificationDate(t.get("M"));this.data.modificationDate=this.modificationDate}else this.data.modificationDate=null;if(t.has("C")){this.setColor(t.getArray("C"));this.data.color=this.color}else this.data.color=null;if(!this.viewable){const e=t.get("F");this._isViewable(e)&&this.setFlags(e)}this.setTitle(t.get("T"));this.data.titleObj=this._title;this.setContents(t.get("Contents"));this.data.contentsObj=this._contents;t.has("RC")&&(this.data.richText=m.XFAFactory.getRichTextAsHtml(t.get("RC")))}}t.PopupAnnotation=PopupAnnotation;class FreeTextAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.FREETEXT}get hasTextContent(){return!!this.appearance}static createNewDict(e,t,r){let{apRef:n,ap:o}=r;const{color:c,fontSize:l,rect:h,rotation:u,user:d,value:f}=e,g=new s.Dict(t);g.set("Type",s.Name.get("Annot"));g.set("Subtype",s.Name.get("FreeText"));g.set("CreationDate",`D:${(0,a.getModificationDate)()}`);g.set("Rect",h);const p=`/Helv ${l} Tf ${(0,i.getPdfColor)(c,!0)}`;g.set("DA",p);g.set("Contents",f);g.set("F",4);g.set("Border",[0,0,0]);g.set("Rotate",u);d&&g.set("T",(0,a.stringToUTF8String)(d));const m=new s.Dict(t);g.set("AP",m);n?m.set("N",n):m.set("N",o);return g}static async createNewAppearanceStream(e,t,r){const{baseFontRef:o,evaluator:c,task:l}=r,{color:h,fontSize:u,rect:d,rotation:f,value:g}=e,m=new s.Dict(t),b=new s.Dict(t);if(o)b.set("Helv",o);else{const e=new s.Dict(t);e.set("BaseFont",s.Name.get("Helvetica"));e.set("Type",s.Name.get("Font"));e.set("Subtype",s.Name.get("Type1"));e.set("Encoding",s.Name.get("WinAnsiEncoding"));b.set("Helv",e)}m.set("Font",b);const y=await WidgetAnnotation._getFontData(c,l,{fontName:"Helvetica",fontSize:u},m),[w,S,x,k]=d;let C=x-w,v=k-S;f%180!=0&&([C,v]=[v,C]);const O=g.split("\n"),T=u/1e3;let M=-1/0;const E=[];for(let e of O){e=y.encodeString(e).join("");E.push(e);let t=0;const r=y.charsToGlyphs(e);for(const e of r)t+=e.width*T;M=Math.max(M,t)}let D=1;M>C&&(D=C/M);let N=1;const R=a.LINE_FACTOR*u,L=a.LINE_DESCENT_FACTOR*u,j=R*O.length;j>v&&(N=v/j);const $=u*Math.min(D,N),_=["q",`0 0 ${(0,n.numberToString)(C)} ${(0,n.numberToString)(v)} re W n`,"BT",`1 0 0 1 0 ${(0,n.numberToString)(v+L)} Tm 0 Tc ${(0,i.getPdfColor)(h,!0)}`,`/Helv ${(0,n.numberToString)($)} Tf`],U=(0,n.numberToString)(R);for(const e of E)_.push(`0 -${U} Td (${(0,a.escapeString)(e)}) Tj`);_.push("ET","Q");const X=_.join("\n"),H=new s.Dict(t);H.set("FormType",1);H.set("Subtype",s.Name.get("Form"));H.set("Type",s.Name.get("XObject"));H.set("BBox",[0,0,C,v]);H.set("Length",X.length);H.set("Resources",m);if(f){const e=WidgetAnnotation._getRotationMatrix(f,C,v);H.set("Matrix",e)}const q=new p.StringStream(X);q.dict=H;return q}}class LineAnnotation extends MarkupAnnotation{constructor(e){super(e);const{dict:t}=e;this.data.annotationType=a.AnnotationType.LINE;const r=t.getArray("L");this.data.lineCoordinates=a.Util.normalizeRect(r);this.setLineEndings(t.getArray("LE"));this.data.lineEndings=this.lineEndings;if(!this.appearance){const n=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],i=t.get("CA");let s=null,o=t.getArray("IC");if(o){o=getRgbColor(o,null);s=o?Array.from(o).map((e=>e/255)):null}const c=s?i:null,l=this.borderStyle.width||1,h=2*l,u=[this.data.lineCoordinates[0]-h,this.data.lineCoordinates[1]-h,this.data.lineCoordinates[2]+h,this.data.lineCoordinates[3]+h];a.Util.intersect(this.rectangle,u)||(this.rectangle=u);this._setDefaultAppearance({xref:e.xref,extra:`${l} w`,strokeColor:n,fillColor:s,strokeAlpha:i,fillAlpha:c,pointsCallback:(e,t)=>{e.push(`${r[0]} ${r[1]} m`,`${r[2]} ${r[3]} l`,"S");return[t[0].x-l,t[1].x+l,t[3].y-l,t[1].y+l]}})}}}class SquareAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.SQUARE;if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA");let a=null,n=e.dict.getArray("IC");if(n){n=getRgbColor(n,null);a=n?Array.from(n).map((e=>e/255)):null}const i=a?r:null;if(0===this.borderStyle.width&&!a)return;this._setDefaultAppearance({xref:e.xref,extra:`${this.borderStyle.width} w`,strokeColor:t,fillColor:a,strokeAlpha:r,fillAlpha:i,pointsCallback:(e,t)=>{const r=t[2].x+this.borderStyle.width/2,n=t[2].y+this.borderStyle.width/2,i=t[3].x-t[2].x-this.borderStyle.width,s=t[1].y-t[3].y-this.borderStyle.width;e.push(`${r} ${n} ${i} ${s} re`);a?e.push("B"):e.push("S");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}}class CircleAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.CIRCLE;if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA");let a=null,n=e.dict.getArray("IC");if(n){n=getRgbColor(n,null);a=n?Array.from(n).map((e=>e/255)):null}const i=a?r:null;if(0===this.borderStyle.width&&!a)return;const s=4/3*Math.tan(Math.PI/8);this._setDefaultAppearance({xref:e.xref,extra:`${this.borderStyle.width} w`,strokeColor:t,fillColor:a,strokeAlpha:r,fillAlpha:i,pointsCallback:(e,t)=>{const r=t[0].x+this.borderStyle.width/2,n=t[0].y-this.borderStyle.width/2,i=t[3].x-this.borderStyle.width/2,o=t[3].y+this.borderStyle.width/2,c=r+(i-r)/2,l=n+(o-n)/2,h=(i-r)/2*s,u=(o-n)/2*s;e.push(`${c} ${o} m`,`${c+h} ${o} ${i} ${l+u} ${i} ${l} c`,`${i} ${l-u} ${c+h} ${n} ${c} ${n} c`,`${c-h} ${n} ${r} ${l-u} ${r} ${l} c`,`${r} ${l+u} ${c-h} ${o} ${c} ${o} c`,"h");a?e.push("B"):e.push("S");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}}class PolylineAnnotation extends MarkupAnnotation{constructor(e){super(e);const{dict:t}=e;this.data.annotationType=a.AnnotationType.POLYLINE;this.data.vertices=[];if(!(this instanceof PolygonAnnotation)){this.setLineEndings(t.getArray("LE"));this.data.lineEndings=this.lineEndings}const r=t.getArray("Vertices");if(Array.isArray(r)){for(let e=0,t=r.length;e<t;e+=2)this.data.vertices.push({x:r[e],y:r[e+1]});if(!this.appearance){const r=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],n=t.get("CA"),i=this.borderStyle.width||1,s=2*i,o=[1/0,1/0,-1/0,-1/0];for(const e of this.data.vertices){o[0]=Math.min(o[0],e.x-s);o[1]=Math.min(o[1],e.y-s);o[2]=Math.max(o[2],e.x+s);o[3]=Math.max(o[3],e.y+s)}a.Util.intersect(this.rectangle,o)||(this.rectangle=o);this._setDefaultAppearance({xref:e.xref,extra:`${i} w`,strokeColor:r,strokeAlpha:n,pointsCallback:(e,t)=>{const r=this.data.vertices;for(let t=0,a=r.length;t<a;t++)e.push(`${r[t].x} ${r[t].y} ${0===t?"m":"l"}`);e.push("S");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}}}class PolygonAnnotation extends PolylineAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.POLYGON}}class CaretAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.CARET}}class InkAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.INK;this.data.inkLists=[];const t=e.dict.getArray("InkList");if(!Array.isArray(t))return;const r=e.xref;for(let e=0,a=t.length;e<a;++e){this.data.inkLists.push([]);for(let a=0,n=t[e].length;a<n;a+=2)this.data.inkLists[e].push({x:r.fetchIfRef(t[e][a]),y:r.fetchIfRef(t[e][a+1])})}if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA"),n=this.borderStyle.width||1,i=2*n,s=[1/0,1/0,-1/0,-1/0];for(const e of this.data.inkLists)for(const t of e){s[0]=Math.min(s[0],t.x-i);s[1]=Math.min(s[1],t.y-i);s[2]=Math.max(s[2],t.x+i);s[3]=Math.max(s[3],t.y+i)}a.Util.intersect(this.rectangle,s)||(this.rectangle=s);this._setDefaultAppearance({xref:e.xref,extra:`${n} w`,strokeColor:t,strokeAlpha:r,pointsCallback:(e,t)=>{for(const t of this.data.inkLists){for(let r=0,a=t.length;r<a;r++)e.push(`${t[r].x} ${t[r].y} ${0===r?"m":"l"}`);e.push("S")}return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}static createNewDict(e,t,r){let{apRef:n,ap:i}=r;const{paths:o,rect:c,rotation:l}=e,h=new s.Dict(t);h.set("Type",s.Name.get("Annot"));h.set("Subtype",s.Name.get("Ink"));h.set("CreationDate",`D:${(0,a.getModificationDate)()}`);h.set("Rect",c);h.set("InkList",o.map((e=>e.points)));h.set("F",4);h.set("Border",[0,0,0]);h.set("Rotate",l);const u=new s.Dict(t);h.set("AP",u);n?u.set("N",n):u.set("N",i);return h}static async createNewAppearanceStream(e,t,r){const{color:a,rect:o,rotation:c,paths:l,thickness:h,opacity:u}=e,[d,f,g,m]=o;let b=g-d,y=m-f;c%180!=0&&([b,y]=[y,b]);const w=[`${h} w 1 J 1 j`,`${(0,i.getPdfColor)(a,!1)}`];1!==u&&w.push("/R0 gs");const S=[];for(const{bezier:e}of l){S.length=0;S.push(`${(0,n.numberToString)(e[0])} ${(0,n.numberToString)(e[1])} m`);for(let t=2,r=e.length;t<r;t+=6){const r=e.slice(t,t+6).map(n.numberToString).join(" ");S.push(`${r} c`)}S.push("S");w.push(S.join("\n"))}const x=w.join("\n"),k=new s.Dict(t);k.set("FormType",1);k.set("Subtype",s.Name.get("Form"));k.set("Type",s.Name.get("XObject"));k.set("BBox",[0,0,b,y]);k.set("Length",x.length);if(c){const e=WidgetAnnotation._getRotationMatrix(c,b,y);k.set("Matrix",e)}if(1!==u){const e=new s.Dict(t),r=new s.Dict(t),a=new s.Dict(t);a.set("CA",u);a.set("Type",s.Name.get("ExtGState"));r.set("R0",a);e.set("ExtGState",r);k.set("Resources",e)}const C=new p.StringStream(x);C.dict=k;return C}}class HighlightAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.HIGHLIGHT;if(this.data.quadPoints=getQuadPoints(e.dict,null)){const t=this.appearance&&this.appearance.dict.get("Resources");if(!this.appearance||!t||!t.has("ExtGState")){this.appearance&&(0,a.warn)("HighlightAnnotation - ignoring built-in appearance stream.");const t=this.color?Array.from(this.color).map((e=>e/255)):[1,1,0],r=e.dict.get("CA");this._setDefaultAppearance({xref:e.xref,fillColor:t,blendMode:"Multiply",fillAlpha:r,pointsCallback:(e,t)=>{e.push(`${t[0].x} ${t[0].y} m`,`${t[1].x} ${t[1].y} l`,`${t[3].x} ${t[3].y} l`,`${t[2].x} ${t[2].y} l`,"f");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}else this.data.hasPopup=!1}}class UnderlineAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.UNDERLINE;if(this.data.quadPoints=getQuadPoints(e.dict,null)){if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA");this._setDefaultAppearance({xref:e.xref,extra:"[] 0 d 1 w",strokeColor:t,strokeAlpha:r,pointsCallback:(e,t)=>{e.push(`${t[2].x} ${t[2].y} m`,`${t[3].x} ${t[3].y} l`,"S");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}else this.data.hasPopup=!1}}class SquigglyAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.SQUIGGLY;if(this.data.quadPoints=getQuadPoints(e.dict,null)){if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA");this._setDefaultAppearance({xref:e.xref,extra:"[] 0 d 1 w",strokeColor:t,strokeAlpha:r,pointsCallback:(e,t)=>{const r=(t[0].y-t[2].y)/6;let a=r,n=t[2].x;const i=t[2].y,s=t[3].x;e.push(`${n} ${i+a} m`);do{n+=2;a=0===a?r:0;e.push(`${n} ${i+a} l`)}while(n<s);e.push("S");return[t[2].x,s,i-2*r,i+2*r]}})}}else this.data.hasPopup=!1}}class StrikeOutAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.STRIKEOUT;if(this.data.quadPoints=getQuadPoints(e.dict,null)){if(!this.appearance){const t=this.color?Array.from(this.color).map((e=>e/255)):[0,0,0],r=e.dict.get("CA");this._setDefaultAppearance({xref:e.xref,extra:"[] 0 d 1 w",strokeColor:t,strokeAlpha:r,pointsCallback:(e,t)=>{e.push((t[0].x+t[2].x)/2+" "+(t[0].y+t[2].y)/2+" m",(t[1].x+t[3].x)/2+" "+(t[1].y+t[3].y)/2+" l","S");return[t[0].x,t[1].x,t[3].y,t[1].y]}})}}else this.data.hasPopup=!1}}class StampAnnotation extends MarkupAnnotation{constructor(e){super(e);this.data.annotationType=a.AnnotationType.STAMP}}class FileAttachmentAnnotation extends MarkupAnnotation{constructor(e){super(e);const t=new d.FileSpec(e.dict.get("FS"),e.xref);this.data.annotationType=a.AnnotationType.FILEATTACHMENT;this.data.file=t.serializable}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.createDefaultAppearance=function createDefaultAppearance(e){let{fontSize:t,fontName:r,fontColor:n}=e;return`/${(0,a.escapePDFName)(r)} ${t} Tf ${getPdfColor(n,!0)}`};t.getPdfColor=getPdfColor;t.parseDefaultAppearance=function parseDefaultAppearance(e){return new DefaultAppearanceEvaluator(e).parse()};var a=r(131),n=r(2),i=r(139),s=r(140),o=r(130),c=r(135);class DefaultAppearanceEvaluator extends s.EvaluatorPreprocessor{constructor(e){super(new c.StringStream(e))}parse(){const e={fn:0,args:[]},t={fontSize:0,fontName:"",fontColor:new Uint8ClampedArray(3)};try{for(;;){e.args.length=0;if(!this.read(e))break;if(0!==this.savedStatesDepth)continue;const{fn:r,args:a}=e;switch(0|r){case n.OPS.setFont:const[e,r]=a;e instanceof o.Name&&(t.fontName=e.name);"number"==typeof r&&r>0&&(t.fontSize=r);break;case n.OPS.setFillRGBColor:i.ColorSpace.singletons.rgb.getRgbItem(a,0,t.fontColor,0);break;case n.OPS.setFillGray:i.ColorSpace.singletons.gray.getRgbItem(a,0,t.fontColor,0);break;case n.OPS.setFillColorSpace:i.ColorSpace.singletons.cmyk.getRgbItem(a,0,t.fontColor,0)}}}catch(e){(0,n.warn)(`parseDefaultAppearance - ignoring errors: "${e}".`)}return t}}function getPdfColor(e,t){if(e[0]===e[1]&&e[1]===e[2]){const r=e[0]/255;return`${(0,a.numberToString)(r)} ${t?"g":"G"}`}return Array.from(e).map((e=>(0,a.numberToString)(e/255))).join(" ")+" "+(t?"rg":"RG")}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.ColorSpace=void 0;var a=r(2),n=r(130),i=r(132),s=r(131);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,n){(0,a.unreachable)("Should not call ColorSpace.getRgbItem")}getRgbBuffer(e,t,r,n,i,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,n,i,s,o,c){const l=t*r;let h=null;const u=1<<s,d=r!==n||t!==a;if(this.isPassthrough(s))h=o;else if(1===this.numComps&&l>u&&"DeviceGray"!==this.name&&"DeviceRGB"!==this.name){const t=s<=8?new Uint8Array(u):new Uint16Array(u);for(let e=0;e<u;e++)t[e]=e;const r=new Uint8ClampedArray(3*u);this.getRgbBuffer(t,0,u,r,0,s,0);if(d){h=new Uint8Array(3*l);let e=0;for(let t=0;t<l;++t){const a=3*o[t];h[e++]=r[a];h[e++]=r[a+1];h[e++]=r[a+2]}}else{let t=0;for(let a=0;a<l;++a){const n=3*o[a];e[t++]=r[n];e[t++]=r[n+1];e[t++]=r[n+2];t+=c}}}else if(d){h=new Uint8ClampedArray(3*l);this.getRgbBuffer(o,0,l,h,0,s,0)}else this.getRgbBuffer(o,0,a*i,e,0,s,c);if(h)if(d)!function resizeRgbImage(e,t,r,a,n,i,s){s=1!==s?0:s;const o=r/n,c=a/i;let l,h=0;const u=new Uint16Array(n),d=3*r;for(let e=0;e<n;e++)u[e]=3*Math.floor(e*o);for(let r=0;r<i;r++){const a=Math.floor(r*c)*d;for(let r=0;r<n;r++){l=a+u[r];t[h++]=e[l++];t[h++]=e[l++];t[h++]=e[l++];h+=s}}}(h,e,t,r,a,n,c);else{let t=0,r=0;for(let n=0,s=a*i;n<s;n++){e[t++]=h[r++];e[t++]=h[r++];e[t++]=h[r++];t+=c}}}get usesZeroToOneRange(){return(0,a.shadow)(this,"usesZeroToOneRange",!0)}static _cache(e,t,r,a){if(!r)throw new Error('ColorSpace._cache - expected "localColorSpaceCache" argument.');if(!a)throw new Error('ColorSpace._cache - expected "parsedColorSpace" argument.');let i,s;if(e instanceof n.Ref){s=e;e=t.fetch(e)}e instanceof n.Name&&(i=e.name);(i||s)&&r.set(i,s,a)}static getCached(e,t,r){if(!r)throw new Error('ColorSpace.getCached - expected "localColorSpaceCache" argument.');if(e instanceof n.Ref){const a=r.getByRef(e);if(a)return a;try{e=t.fetch(e)}catch(e){if(e instanceof s.MissingDataException)throw e}}if(e instanceof n.Name){const t=r.getByName(e.name);if(t)return t}return null}static async parseAsync(e){let{cs:t,xref:r,resources:a=null,pdfFunctionFactory:n,localColorSpaceCache:i}=e;const s=this._parse(t,r,a,n);this._cache(t,r,i,s);return s}static parse(e){let{cs:t,xref:r,resources:a=null,pdfFunctionFactory:n,localColorSpaceCache:i}=e;const s=this.getCached(t,r,i);if(s)return s;const o=this._parse(t,r,a,n);this._cache(t,r,i,o);return o}static _parse(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3?arguments[3]:void 0;if((e=t.fetchIfRef(e))instanceof n.Name)switch(e.name){case"G":case"DeviceGray":return this.singletons.gray;case"RGB":case"DeviceRGB":return this.singletons.rgb;case"CMYK":case"DeviceCMYK":return this.singletons.cmyk;case"Pattern":return new PatternCS(null);default:if(r instanceof n.Dict){const a=r.get("ColorSpace");if(a instanceof n.Dict){const s=a.get(e.name);if(s){if(s instanceof n.Name)return this._parse(s,t,r,i);e=s;break}}}throw new a.FormatError(`Unrecognized ColorSpace: ${e.name}`)}if(Array.isArray(e)){const n=t.fetchIfRef(e[0]).name;let s,o,u,d,f,g;switch(n){case"G":case"DeviceGray":return this.singletons.gray;case"RGB":case"DeviceRGB":return this.singletons.rgb;case"CMYK":case"DeviceCMYK":return this.singletons.cmyk;case"CalGray":s=t.fetchIfRef(e[1]);d=s.getArray("WhitePoint");f=s.getArray("BlackPoint");g=s.get("Gamma");return new c(d,f,g);case"CalRGB":s=t.fetchIfRef(e[1]);d=s.getArray("WhitePoint");f=s.getArray("BlackPoint");g=s.getArray("Gamma");const p=s.getArray("Matrix");return new l(d,f,g,p);case"ICCBased":const m=t.fetchIfRef(e[1]).dict;o=m.get("N");const b=m.get("Alternate");if(b){const e=this._parse(b,t,r,i);if(e.numComps===o)return e;(0,a.warn)("ICCBased color space: Ignoring incorrect /Alternate entry.")}if(1===o)return this.singletons.gray;if(3===o)return this.singletons.rgb;if(4===o)return this.singletons.cmyk;break;case"Pattern":u=e[1]||null;u&&(u=this._parse(u,t,r,i));return new PatternCS(u);case"I":case"Indexed":u=this._parse(e[1],t,r,i);const y=t.fetchIfRef(e[2])+1,w=t.fetchIfRef(e[3]);return new IndexedCS(u,y,w);case"Separation":case"DeviceN":const S=t.fetchIfRef(e[1]);o=Array.isArray(S)?S.length:1;u=this._parse(e[2],t,r,i);const x=i.create(e[3]);return new AlternateCS(o,u,x);case"Lab":s=t.fetchIfRef(e[1]);d=s.getArray("WhitePoint");f=s.getArray("BlackPoint");const k=s.getArray("Range");return new h(d,f,k);default:throw new a.FormatError(`Unimplemented ColorSpace object: ${n}`)}}throw new a.FormatError(`Unrecognized ColorSpace object: ${e}`)}static isDefaultDecode(e,t){if(!Array.isArray(e))return!0;if(2*t!==e.length){(0,a.warn)("The decode map is not the correct length");return!0}for(let t=0,r=e.length;t<r;t+=2)if(0!==e[t]||1!==e[t+1])return!1;return!0}static get singletons(){return(0,a.shadow)(this,"singletons",{get gray(){return(0,a.shadow)(this,"gray",new DeviceGrayCS)},get rgb(){return(0,a.shadow)(this,"rgb",new DeviceRgbCS)},get cmyk(){return(0,a.shadow)(this,"cmyk",new o)}})}}t.ColorSpace=ColorSpace;class AlternateCS extends ColorSpace{constructor(e,t,r){super("Alternate",e);this.base=t;this.tintFn=r;this.tmpBuf=new Float32Array(t.numComps)}getRgbItem(e,t,r,a){const n=this.tmpBuf;this.tintFn(e,t,n,0);this.base.getRgbItem(n,0,r,a)}getRgbBuffer(e,t,r,a,n,i,s){const o=this.tintFn,c=this.base,l=1/((1<<i)-1),h=c.numComps,u=c.usesZeroToOneRange,d=(c.isPassthrough(8)||!u)&&0===s;let f=d?n:0;const g=d?a:new Uint8ClampedArray(h*r),p=this.numComps,m=new Float32Array(p),b=new Float32Array(h);let y,w;for(y=0;y<r;y++){for(w=0;w<p;w++)m[w]=e[t++]*l;o(m,0,b,0);if(u)for(w=0;w<h;w++)g[f++]=255*b[w];else{c.getRgbItem(b,0,g,f);f+=h}}d||c.getRgbBuffer(g,0,r,a,n,8,s)}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps/this.numComps,t)}}class PatternCS extends ColorSpace{constructor(e){super("Pattern",null);this.base=e}isDefaultDecode(e,t){(0,a.unreachable)("Should not call PatternCS.isDefaultDecode")}}class IndexedCS extends ColorSpace{constructor(e,t,r){super("Indexed",1);this.base=e;this.highVal=t;const n=e.numComps*t;this.lookup=new Uint8Array(n);if(r instanceof i.BaseStream){const e=r.getBytes(n);this.lookup.set(e)}else{if("string"!=typeof r)throw new a.FormatError(`IndexedCS - unrecognized lookup table: ${r}`);for(let e=0;e<n;++e)this.lookup[e]=255&r.charCodeAt(e)}}getRgbItem(e,t,r,a){const n=this.base.numComps,i=e[t]*n;this.base.getRgbBuffer(this.lookup,i,1,r,a,8,0)}getRgbBuffer(e,t,r,a,n,i,s){const o=this.base,c=o.numComps,l=o.getOutputLength(c,s),h=this.lookup;for(let i=0;i<r;++i){const r=e[t++]*c;o.getRgbBuffer(h,r,1,a,n,8,s);n+=l}}getOutputLength(e,t){return this.base.getOutputLength(e*this.base.numComps,t)}isDefaultDecode(e,t){if(!Array.isArray(e))return!0;if(2!==e.length){(0,a.warn)("Decode map length is not correct");return!0}if(!Number.isInteger(t)||t<1){(0,a.warn)("Bits per component is not correct");return!0}return 0===e[0]&&e[1]===(1<<t)-1}}class DeviceGrayCS extends ColorSpace{constructor(){super("DeviceGray",1)}getRgbItem(e,t,r,a){const n=255*e[t];r[a]=r[a+1]=r[a+2]=n}getRgbBuffer(e,t,r,a,n,i,s){const o=255/((1<<i)-1);let c=t,l=n;for(let t=0;t<r;++t){const t=o*e[c++];a[l++]=t;a[l++]=t;a[l++]=t;l+=s}}getOutputLength(e,t){return e*(3+t)}}class DeviceRgbCS extends ColorSpace{constructor(){super("DeviceRGB",3)}getRgbItem(e,t,r,a){r[a]=255*e[t];r[a+1]=255*e[t+1];r[a+2]=255*e[t+2]}getRgbBuffer(e,t,r,a,n,i,s){if(8===i&&0===s){a.set(e.subarray(t,t+3*r),n);return}const o=255/((1<<i)-1);let c=t,l=n;for(let t=0;t<r;++t){a[l++]=o*e[c++];a[l++]=o*e[c++];a[l++]=o*e[c++];l+=s}}getOutputLength(e,t){return e*(3+t)/3|0}isPassthrough(e){return 8===e}}const o=function DeviceCmykCSClosure(){function convertToRgb(e,t,r,a,n){const i=e[t]*r,s=e[t+1]*r,o=e[t+2]*r,c=e[t+3]*r;a[n]=255+i*(-4.387332384609988*i+54.48615194189176*s+18.82290502165302*o+212.25662451639585*c-285.2331026137004)+s*(1.7149763477362134*s-5.6096736904047315*o+-17.873870861415444*c-5.497006427196366)+o*(-2.5217340131683033*o-21.248923337353073*c+17.5119270841813)+c*(-21.86122147463605*c-189.48180835922747);a[n+1]=255+i*(8.841041422036149*i+60.118027045597366*s+6.871425592049007*o+31.159100130055922*c-79.2970844816548)+s*(-15.310361306967817*s+17.575251261109482*o+131.35250912493976*c-190.9453302588951)+o*(4.444339102852739*o+9.8632861493405*c-24.86741582555878)+c*(-20.737325471181034*c-187.80453709719578);a[n+2]=255+i*(.8842522430003296*i+8.078677503112928*s+30.89978309703729*o-.23883238689178934*c-14.183576799673286)+s*(10.49593273432072*s+63.02378494754052*o+50.606957656360734*c-112.23884253719248)+o*(.03296041114873217*o+115.60384449646641*c-193.58209356861505)+c*(-22.33816807309886*c-180.12613974708367)}return class DeviceCmykCS extends ColorSpace{constructor(){super("DeviceCMYK",4)}getRgbItem(e,t,r,a){convertToRgb(e,t,1,r,a)}getRgbBuffer(e,t,r,a,n,i,s){const o=1/((1<<i)-1);for(let i=0;i<r;i++){convertToRgb(e,t,o,a,n);t+=4;n+=3+s}}getOutputLength(e,t){return e/4*(3+t)|0}}}(),c=function CalGrayCSClosure(){function convertToRgb(e,t,r,a,n,i){const s=(t[r]*i)**e.G,o=e.YW*s,c=Math.max(295.8*o**.3333333333333333-40.8,0);a[n]=c;a[n+1]=c;a[n+2]=c}return class CalGrayCS extends ColorSpace{constructor(e,t,r){super("CalGray",1);if(!e)throw new a.FormatError("WhitePoint missing - required for color space CalGray");t=t||[0,0,0];r=r||1;this.XW=e[0];this.YW=e[1];this.ZW=e[2];this.XB=t[0];this.YB=t[1];this.ZB=t[2];this.G=r;if(this.XW<0||this.ZW<0||1!==this.YW)throw new a.FormatError(`Invalid WhitePoint components for ${this.name}, no fallback available`);if(this.XB<0||this.YB<0||this.ZB<0){(0,a.info)(`Invalid BlackPoint for ${this.name}, falling back to default.`);this.XB=this.YB=this.ZB=0}0===this.XB&&0===this.YB&&0===this.ZB||(0,a.warn)(`${this.name}, BlackPoint: XB: ${this.XB}, YB: ${this.YB}, ZB: ${this.ZB}, only default values are supported.`);if(this.G<1){(0,a.info)(`Invalid Gamma: ${this.G} for ${this.name}, falling back to default.`);this.G=1}}getRgbItem(e,t,r,a){convertToRgb(this,e,t,r,a,1)}getRgbBuffer(e,t,r,a,n,i,s){const o=1/((1<<i)-1);for(let i=0;i<r;++i){convertToRgb(this,e,t,a,n,o);t+=1;n+=3+s}}getOutputLength(e,t){return e*(3+t)}}}(),l=function CalRGBCSClosure(){const e=new Float32Array([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),t=new Float32Array([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),r=new Float32Array([3.2404542,-1.5371385,-.4985314,-.969266,1.8760108,.041556,.0556434,-.2040259,1.0572252]),n=new Float32Array([1,1,1]),i=new Float32Array(3),s=new Float32Array(3),o=new Float32Array(3);function matrixProduct(e,t,r){r[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2];r[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2];r[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2]}function sRGBTransferFunction(e){return e<=.0031308?adjustToRange(0,1,12.92*e):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:.0011070564598794539*e}function convertToRgb(a,c,l,h,u,d){const f=adjustToRange(0,1,c[l]*d),g=adjustToRange(0,1,c[l+1]*d),p=adjustToRange(0,1,c[l+2]*d),m=1===f?1:f**a.GR,b=1===g?1:g**a.GG,y=1===p?1:p**a.GB,w=a.MXA*m+a.MXB*b+a.MXC*y,S=a.MYA*m+a.MYB*b+a.MYC*y,x=a.MZA*m+a.MZB*b+a.MZC*y,k=s;k[0]=w;k[1]=S;k[2]=x;const C=o;!function normalizeWhitePointToFlat(r,a,n){if(1===r[0]&&1===r[2]){n[0]=a[0];n[1]=a[1];n[2]=a[2];return}const s=n;matrixProduct(e,a,s);const o=i;!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,n)}(a.whitePoint,k,C);const v=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),n=(1-a)/(1-decodeL(e[0])),i=1-n,s=(1-a)/(1-decodeL(e[1])),o=1-s,c=(1-a)/(1-decodeL(e[2])),l=1-c;r[0]=t[0]*n+i;r[1]=t[1]*s+o;r[2]=t[2]*c+l}(a.blackPoint,C,v);const O=o;!function normalizeWhitePointToD65(r,a,n){const s=n;matrixProduct(e,a,s);const o=i;!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,n)}(n,v,O);const T=s;matrixProduct(r,O,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,n){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]);n=n||new Float32Array([1,0,0,0,1,0,0,0,1]);const i=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=n[0];this.MYA=n[1];this.MZA=n[2];this.MXB=n[3];this.MYB=n[4];this.MZB=n[5];this.MXC=n[6];this.MYC=n[7];this.MZC=n[8];if(i<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,n,i,s){const o=1/((1<<i)-1);for(let i=0;i<r;++i){convertToRgb(this,e,t,a,n,o);t+=3;n+=3+s}}getOutputLength(e,t){return e*(3+t)/3|0}}}(),h=function LabCSClosure(){function fn_g(e){let t;t=e>=6/29?e**3: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,n,i){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:o<e.amin&&(o=e.amin);c>e.bmax?c=e.bmax:c<e.bmin&&(c=e.bmin);const l=(s+16)/116,h=l+o/500,u=l-c/200,d=e.XW*fn_g(h),f=e.YW*fn_g(l),g=e.ZW*fn_g(u);let p,m,b;if(e.ZW<1){p=3.1339*d+-1.617*f+-.4906*g;m=-.9785*d+1.916*f+.0333*g;b=.072*d+-.229*f+1.4057*g}else{p=3.2406*d+-1.5372*f+-.4986*g;m=-.9689*d+1.8758*f+.0415*g;b=.0557*d+-.204*f+1.057*g}n[i]=255*Math.sqrt(p);n[i+1]=255*Math.sqrt(m);n[i+2]=255*Math.sqrt(b)}return class LabCS extends ColorSpace{constructor(e,t,r){super("Lab",3);if(!e)throw new a.FormatError("WhitePoint missing - required for color space Lab");t=t||[0,0,0];r=r||[-100,100,-100,100];this.XW=e[0];this.YW=e[1];this.ZW=e[2];this.amin=r[0];this.amax=r[1];this.bmin=r[2];this.bmax=r[3];this.XB=t[0];this.YB=t[1];this.ZB=t[2];if(this.XW<0||this.ZW<0||1!==this.YW)throw new a.FormatError("Invalid WhitePoint components, no fallback available");if(this.XB<0||this.YB<0||this.ZB<0){(0,a.info)("Invalid BlackPoint, falling back to default");this.XB=this.YB=this.ZB=0}if(this.amin>this.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,n,i,s){const o=(1<<i)-1;for(let i=0;i<r;i++){convertToRgb(this,e,t,o,a,n);t+=3;n+=3+s}}getOutputLength(e,t){return e*(3+t)/3|0}isDefaultDecode(e,t){return!0}get usesZeroToOneRange(){return(0,a.shadow)(this,"usesZeroToOneRange",!1)}}}()},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.PartialEvaluator=t.EvaluatorPreprocessor=void 0;var a=r(2),n=r(141),i=r(130),s=r(159),o=r(163),c=r(162),l=r(166),h=r(165),u=r(175),d=r(176),f=r(167),g=r(182),p=r(142),m=r(184),b=r(135),y=r(132),w=r(185),S=r(139),x=r(144),k=r(164),C=r(131),v=r(170),O=r(186),T=r(187),M=r(188);const E=Object.freeze({maxImageSize:-1,disableFontFace:!1,ignoreErrors:!1,isEvalSupported:!0,fontExtraProperties:!1,useSystemFonts:!0,cMapUrl:null,standardFontDataUrl:null}),D=1,N=2,R=Promise.resolve();function normalizeBlendMode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(Array.isArray(e)){for(let t=0,r=e.length;t<r;t++){const r=normalizeBlendMode(e[t],!0);if(r)return r}(0,a.warn)(`Unsupported blend mode Array: ${e}`);return"source-over"}if(!(e instanceof i.Name))return t?null:"source-over";switch(e.name){case"Normal":case"Compatible":return"source-over";case"Multiply":return"multiply";case"Screen":return"screen";case"Overlay":return"overlay";case"Darken":return"darken";case"Lighten":return"lighten";case"ColorDodge":return"color-dodge";case"ColorBurn":return"color-burn";case"HardLight":return"hard-light";case"SoftLight":return"soft-light";case"Difference":return"difference";case"Exclusion":return"exclusion";case"Hue":return"hue";case"Saturation":return"saturation";case"Color":return"color";case"Luminosity":return"luminosity"}if(t)return null;(0,a.warn)(`Unsupported blend mode: ${e.name}`);return"source-over"}function incrementCachedImageMaskCount(e){e.fn===a.OPS.paintImageMaskXObject&&e.args[0]&&e.args[0].count>0&&e.args[0].count++}class TimeSlotManager{static get TIME_SLOT_DURATION_MS(){return(0,a.shadow)(this,"TIME_SLOT_DURATION_MS",20)}static get CHECK_TIME_EVERY(){return(0,a.shadow)(this,"CHECK_TIME_EVERY",100)}constructor(){this.reset()}check(){if(++this.checked<TimeSlotManager.CHECK_TIME_EVERY)return!1;this.checked=0;return this.endTime<=Date.now()}reset(){this.endTime=Date.now()+TimeSlotManager.TIME_SLOT_DURATION_MS;this.checked=0}}class PartialEvaluator{constructor(e){let{xref:t,handler:r,pageIndex:a,idFactory:n,fontCache:i,builtInCMapCache:s,standardFontDataCache:o,globalImageCache:c,options:l=null}=e;this.xref=t;this.handler=r;this.pageIndex=a;this.idFactory=n;this.fontCache=i;this.builtInCMapCache=s;this.standardFontDataCache=o;this.globalImageCache=c;this.options=l||E;this.parsingType3Font=!1;this._fetchBuiltInCMapBound=this.fetchBuiltInCMap.bind(this)}get _pdfFunctionFactory(){const e=new g.PDFFunctionFactory({xref:this.xref,isEvalSupported:this.options.isEvalSupported});return(0,a.shadow)(this,"_pdfFunctionFactory",e)}clone(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=Object.create(this);t.options=Object.assign(Object.create(null),this.options,e);return t}hasBlendModes(e,t){if(!(e instanceof i.Dict))return!1;if(e.objId&&t.has(e.objId))return!1;const r=new i.RefSet(t);e.objId&&r.put(e.objId);const n=[e],s=this.xref;for(;n.length;){const e=n.shift(),t=e.get("ExtGState");if(t instanceof i.Dict)for(let e of t.getRawValues()){if(e instanceof i.Ref){if(r.has(e))continue;try{e=s.fetch(e)}catch(t){r.put(e);(0,a.info)(`hasBlendModes - ignoring ExtGState: "${t}".`);continue}}if(!(e instanceof i.Dict))continue;e.objId&&r.put(e.objId);const t=e.get("BM");if(t instanceof i.Name){if("Normal"!==t.name)return!0}else if(void 0!==t&&Array.isArray(t))for(const e of t)if(e instanceof i.Name&&"Normal"!==e.name)return!0}const o=e.get("XObject");if(o instanceof i.Dict)for(let e of o.getRawValues()){if(e instanceof i.Ref){if(r.has(e))continue;try{e=s.fetch(e)}catch(t){r.put(e);(0,a.info)(`hasBlendModes - ignoring XObject: "${t}".`);continue}}if(!(e instanceof y.BaseStream))continue;e.dict.objId&&r.put(e.dict.objId);const t=e.dict.get("Resources");if(t instanceof i.Dict&&(!t.objId||!r.has(t.objId))){n.push(t);t.objId&&r.put(t.objId)}}}for(const e of r)t.put(e);return!1}async fetchBuiltInCMap(e){const t=this.builtInCMapCache.get(e);if(t)return t;let r;if(null!==this.options.cMapUrl){const t=`${this.options.cMapUrl}${e}.bcmap`,n=await fetch(t);if(!n.ok)throw new Error(`fetchBuiltInCMap: failed to fetch file "${t}" with "${n.statusText}".`);r={cMapData:new Uint8Array(await n.arrayBuffer()),compressionType:a.CMapCompressionType.BINARY}}else r=await this.handler.sendWithPromise("FetchBuiltInCMap",{name:e});r.compressionType!==a.CMapCompressionType.NONE&&this.builtInCMapCache.set(e,r);return r}async fetchStandardFontData(e){const t=this.standardFontDataCache.get(e);if(t)return new b.Stream(t);if(this.options.useSystemFonts&&"Symbol"!==e&&"ZapfDingbats"!==e)return null;const r=(0,l.getFontNameToFileMap)()[e];let n;if(null!==this.options.standardFontDataUrl){const e=`${this.options.standardFontDataUrl}${r}`,t=await fetch(e);t.ok?n=await t.arrayBuffer():(0,a.warn)(`fetchStandardFontData: failed to fetch file "${e}" with "${t.statusText}".`)}else try{n=await this.handler.sendWithPromise("FetchStandardFontData",{filename:r})}catch(e){(0,a.warn)(`fetchStandardFontData: failed to fetch file "${r}" with "${e}".`)}if(!n)return null;this.standardFontDataCache.set(e,n);return new b.Stream(n)}async buildFormXObject(e,t,r,n,s,o,c){const l=t.dict,h=l.getArray("Matrix");let u,d,f=l.getArray("BBox");f=Array.isArray(f)&&4===f.length?a.Util.normalizeRect(f):null;l.has("OC")&&(u=await this.parseMarkedContentProps(l.get("OC"),e));void 0!==u&&n.addOp(a.OPS.beginMarkedContentProps,["OC",u]);const g=l.get("Group");if(g){d={matrix:h,bbox:f,smask:r,isolated:!1,knockout:!1};const t=g.get("S");let s=null;if((0,i.isName)(t,"Transparency")){d.isolated=g.get("I")||!1;d.knockout=g.get("K")||!1;if(g.has("CS")){const t=g.getRaw("CS"),r=S.ColorSpace.getCached(t,this.xref,c);s=r||await this.parseColorSpace({cs:t,resources:e,localColorSpaceCache:c})}}if(r&&r.backdrop){s=s||S.ColorSpace.singletons.rgb;r.backdrop=s.getRgb(r.backdrop,0)}n.addOp(a.OPS.beginGroup,[d])}const p=g?[h,null]:[h,f];n.addOp(a.OPS.paintFormXObjectBegin,p);return this.getOperatorList({stream:t,task:s,resources:l.get("Resources")||e,operatorList:n,initialState:o}).then((function(){n.addOp(a.OPS.paintFormXObjectEnd,[]);g&&n.addOp(a.OPS.endGroup,[d]);void 0!==u&&n.addOp(a.OPS.endMarkedContent,[])}))}_sendImgData(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const a=t?[t.bitmap||t.data.buffer]:null;return this.parsingType3Font||r?this.handler.send("commonobj",[e,"Image",t],a):this.handler.send("obj",[e,this.pageIndex,"Image",t],a)}async buildPaintImageXObject(e){let{resources:t,image:r,isInline:n=!1,operatorList:i,cacheKey:s,localImageCache:o,localColorSpaceCache:c}=e;const l=r.dict,h=l.objId,u=l.get("W","Width"),d=l.get("H","Height");if(!u||"number"!=typeof u||!d||"number"!=typeof d){(0,a.warn)("Image dimensions are missing, or not numbers.");return}const f=this.options.maxImageSize;if(-1!==f&&u*d>f){const e="Image exceeded maximum allowed size and was removed.";if(this.options.ignoreErrors){(0,a.warn)(e);return}throw new Error(e)}let g;l.has("OC")&&(g=await this.parseMarkedContentProps(l.get("OC"),t));let p,m;if(l.get("IM","ImageMask")||!1){const e=l.get("I","Interpolate"),t=u+7>>3,n=r.getBytes(t*d),c=l.getArray("D","Decode");if(this.parsingType3Font){p=M.PDFImage.createRawMask({imgArray:n,width:u,height:d,imageIsFromDecodeStream:r instanceof x.DecodeStream,inverseDecode:!!c&&c[0]>0,interpolate:e});p.cached=!!s;m=[p];i.addImageOps(a.OPS.paintImageMaskXObject,m,g);s&&o.set(s,h,{fn:a.OPS.paintImageMaskXObject,args:m,optionalContent:g});return}p=M.PDFImage.createMask({imgArray:n,width:u,height:d,imageIsFromDecodeStream:r instanceof x.DecodeStream,inverseDecode:!!c&&c[0]>0,interpolate:e});if(p.isSingleOpaquePixel){i.addImageOps(a.OPS.paintSolidColorImageMask,[],g);s&&o.set(s,h,{fn:a.OPS.paintSolidColorImageMask,args:[],optionalContent:g});return}const f=`mask_${this.idFactory.createObjId()}`;i.addDependency(f);this._sendImgData(f,p);m=[{data:f,width:p.width,height:p.height,interpolate:p.interpolate,count:1}];i.addImageOps(a.OPS.paintImageMaskXObject,m,g);s&&o.set(s,h,{fn:a.OPS.paintImageMaskXObject,args:m,optionalContent:g});return}const b=l.get("SM","SMask")||!1,y=l.get("Mask")||!1;if(n&&!b&&!y&&u+d<200){const e=new M.PDFImage({xref:this.xref,res:t,image:r,isInline:n,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:c});p=e.createImageData(!0);i.addImageOps(a.OPS.paintInlineImageXObject,[p],g);return}let w=`img_${this.idFactory.createObjId()}`,S=!1;if(this.parsingType3Font)w=`${this.idFactory.getDocId()}_type3_${w}`;else if(h){S=this.globalImageCache.shouldCache(h,this.pageIndex);S&&(w=`${this.idFactory.getDocId()}_${w}`)}i.addDependency(w);m=[w,u,d];M.PDFImage.buildImage({xref:this.xref,res:t,image:r,isInline:n,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:c}).then((e=>{p=e.createImageData(!1);s&&h&&S&&this.globalImageCache.addByteSize(h,p.data.length);return this._sendImgData(w,p,S)})).catch((e=>{(0,a.warn)(`Unable to decode image "${w}": "${e}".`);return this._sendImgData(w,null,S)}));i.addImageOps(a.OPS.paintImageXObject,m,g);if(s){o.set(s,h,{fn:a.OPS.paintImageXObject,args:m,optionalContent:g});if(h){(0,a.assert)(!n,"Cannot cache an inline image globally.");this.globalImageCache.addPageIndex(h,this.pageIndex);S&&this.globalImageCache.setData(h,{objId:w,fn:a.OPS.paintImageXObject,args:m,optionalContent:g,byteSize:0})}}}handleSMask(e,t,r,a,n,i){const s=e.get("G"),o={subtype:e.get("S").name,backdrop:e.get("BC")},c=e.get("TR");if((0,g.isPDFFunction)(c)){const e=this._pdfFunctionFactory.create(c),t=new Uint8Array(256),r=new Float32Array(1);for(let a=0;a<256;a++){r[0]=a/255;e(r,0,r,0);t[a]=255*r[0]|0}o.transferMap=t}return this.buildFormXObject(t,s,o,r,a,n.state.clone(),i)}handleTransferFunction(e){let t;if(Array.isArray(e))t=e;else{if(!(0,g.isPDFFunction)(e))return null;t=[e]}const r=[];let a=0,n=0;for(const e of t){const t=this.xref.fetchIfRef(e);a++;if((0,i.isName)(t,"Identity")){r.push(null);continue}if(!(0,g.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);n++}return 1!==a&&4!==a||0===n?null:r}handleTilingType(e,t,r,n,s,o,c,l){const h=new T.OperatorList,d=i.Dict.merge({xref:this.xref,dictArray:[s.get("Resources"),r]});return this.getOperatorList({stream:n,task:c,resources:d,operatorList:h}).then((function(){const r=h.getIR(),a=(0,u.getTilingPatternIR)(r,s,t);o.addDependencies(h.dependencies);o.addOp(e,a);s.objId&&l.set(null,s.objId,{operatorListIR:r,dict:s})})).catch((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,n,o,c){let l=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,h=arguments.length>7&&void 0!==arguments[7]?arguments[7]:null;const u=t&&t[0]instanceof i.Name?t[0].name:null;return this.loadFont(u,r,e,l,h).then((t=>t.font.isType3Font?t.loadType3Data(this,e,o).then((function(){n.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,evaluatorOptions:this.options})})):t)).then((e=>{c.font=e.font;e.send(this.handler);return e.loadedName}))}handleText(e,t){const r=t.font,n=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,n,this.handler,this.options)}return n}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(e){let{resources:t,gState:r,operatorList:n,cacheKey:s,task:o,stateManager:c,localGStateCache:l,localColorSpaceCache:h}=e;const u=r.objId;let d=!0;const f=[],g=r.getKeys();let p=Promise.resolve();for(let e=0,s=g.length;e<s;e++){const s=g[e],l=r.get(s);switch(s){case"Type":break;case"LW":case"LC":case"LJ":case"ML":case"D":case"RI":case"FL":case"CA":case"ca":f.push([s,l]);break;case"Font":d=!1;p=p.then((()=>this.handleSetFont(t,null,l[0],n,o,c.state).then((function(e){n.addDependency(e);f.push([s,[e,l[1]]])}))));break;case"BM":f.push([s,normalizeBlendMode(l)]);break;case"SMask":if((0,i.isName)(l,"None")){f.push([s,!1]);break}if(l instanceof i.Dict){d=!1;p=p.then((()=>this.handleSMask(l,t,n,o,c,h)));f.push([s,!0])}else(0,a.warn)("Unsupported SMask type");break;case"TR":const e=this.handleTransferFunction(l);f.push([s,e]);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 "+s);break;default:(0,a.info)("Unknown graphic state operator "+s)}}return p.then((function(){f.length>0&&n.addOp(a.OPS.setGState,[f]);d&&l.set(s,u,f)}))}loadFont(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,c=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;const errorFont=async()=>new TranslatedFont({loadedName:"g_font_error",font:new s.ErrorFont(`Font "${e}" is not available.`),dict:t,evaluatorOptions:this.options}),l=this.xref;let h;if(t)t instanceof i.Ref&&(h=t);else{const t=r.get("Font");t&&(h=t.getRaw(e))}if(!h){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.`);h=n||PartialEvaluator.fallbackFontDict}if(this.parsingType3Font&&this.type3FontRefs.has(h))return errorFont();if(this.fontCache.has(h))return this.fontCache.get(h);if(!((t=l.fetchIfRef(h))instanceof i.Dict))return errorFont();if(t.cacheKey&&this.fontCache.has(t.cacheKey))return this.fontCache.get(t.cacheKey);const u=(0,a.createPromiseCapability)();let d;try{d=this.preEvaluateFont(t);d.cssFontInfo=c}catch(e){(0,a.warn)(`loadFont - preEvaluateFont failed: "${e}".`);return errorFont()}const{descriptor:f,hash:g}=d,p=h instanceof i.Ref;let m;p&&(m=`f${h.toString()}`);if(g&&f instanceof i.Dict){f.fontAliases||(f.fontAliases=Object.create(null));const e=f.fontAliases;if(e[g]){const t=e[g].aliasRef;if(p&&t&&this.fontCache.has(t)){this.fontCache.putAlias(h,t);return this.fontCache.get(h)}}else e[g]={fontID:this.idFactory.createFontId()};p&&(e[g].aliasRef=h);m=e[g].fontID}if(p)this.fontCache.put(h,u.promise);else{m||(m=this.idFactory.createFontId());t.cacheKey=`cacheKey_${m}`;this.fontCache.put(t.cacheKey,u.promise)}(0,a.assert)(m&&m.startsWith("f"),'The "fontID" must be (correctly) defined.');t.loadedName=`${this.idFactory.getDocId()}_${m}`;this.translateFont(d).then((e=>{void 0!==e.fontType&&l.stats.addFontType(e.fontType);u.resolve(new TranslatedFont({loadedName:t.loadedName,font:e,dict:t,evaluatorOptions:this.options}))})).catch((e=>{this.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontTranslate});(0,a.warn)(`loadFont - translateFont failed: "${e}".`);try{const e=f&&f.get("FontFile3"),t=e&&e.get("Subtype"),r=(0,o.getFontType)(d.type,t&&t.name);void 0!==r&&l.stats.addFontType(r)}catch(e){}u.resolve(new TranslatedFont({loadedName:t.loadedName,font:new s.ErrorFont(e instanceof Error?e.message:e),dict:t,evaluatorOptions:this.options}))}));return u.promise}buildPath(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];const i=e.length-1;r||(r=[]);let s;if(i<0||e.fnArray[i]!==a.OPS.constructPath){if(n){(0,a.warn)(`Encountered path operator "${t}" inside of a text object.`);e.addOp(a.OPS.save,null)}s=[1/0,-1/0,1/0,-1/0];e.addOp(a.OPS.constructPath,[[t],r,s]);n&&e.addOp(a.OPS.restore,null)}else{const a=e.argsArray[i];a[0].push(t);Array.prototype.push.apply(a[1],r);s=a[2]}switch(t){case a.OPS.rectangle:s[0]=Math.min(s[0],r[0],r[0]+r[2]);s[1]=Math.max(s[1],r[0],r[0]+r[2]);s[2]=Math.min(s[2],r[1],r[1]+r[3]);s[3]=Math.max(s[3],r[1],r[1]+r[3]);break;case a.OPS.moveTo:case a.OPS.lineTo:s[0]=Math.min(s[0],r[0]);s[1]=Math.max(s[1],r[0]);s[2]=Math.min(s[2],r[1]);s[3]=Math.max(s[3],r[1])}}parseColorSpace(e){let{cs:t,resources:r,localColorSpaceCache:n}=e;return S.ColorSpace.parseAsync({cs:t,xref:this.xref,resources:r,pdfFunctionFactory:this._pdfFunctionFactory,localColorSpaceCache:n}).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}))}parseShading(e){let{shading:t,resources:r,localColorSpaceCache:a,localShadingPatternCache:n}=e,i=n.get(t);if(!i){const e=u.Pattern.parseShading(t,this.xref,r,this.handler,this._pdfFunctionFactory,a).getIR();i=`pattern_${this.idFactory.createObjId()}`;n.set(t,i);this.handler.send("obj",[i,this.pageIndex,"Pattern",e])}return i}handleColorN(e,t,r,n,s,o,c,l,h,d){const f=r.pop();if(f instanceof i.Name){const g=s.getRaw(f.name),p=g instanceof i.Ref&&h.getByRef(g);if(p)try{const a=n.base?n.base.getRgb(r,0):null,i=(0,u.getTilingPatternIR)(p.operatorListIR,p.dict,a);e.addOp(t,i);return}catch(e){}const m=this.xref.fetchIfRef(g);if(m){const i=m instanceof y.BaseStream?m.dict:m,s=i.get("PatternType");if(s===D){const a=n.base?n.base.getRgb(r,0):null;return this.handleTilingType(t,a,o,m,i,e,c,h)}if(s===N){const r=i.get("Shading"),a=i.getArray("Matrix"),n=this.parseShading({shading:r,resources:o,localColorSpaceCache:l,localShadingPatternCache:d});e.addOp(t,["Shading",n,a]);return}throw new a.FormatError(`Unknown PatternType: ${s}`)}}throw new a.FormatError(`Unknown PatternName: ${f}`)}_parseVisibilityExpression(e,t,r){if(++t>10){(0,a.warn)("Visibility expression is too deeply nested");return}const n=e.length,s=this.xref.fetchIfRef(e[0]);if(!(n<2)&&s instanceof i.Name){switch(s.name){case"And":case"Or":case"Not":r.push(s.name);break;default:(0,a.warn)(`Invalid operator ${s.name} in visibility expression`);return}for(let a=1;a<n;a++){const n=e[a],s=this.xref.fetchIfRef(n);if(Array.isArray(s)){const e=[];r.push(e);this._parseVisibilityExpression(s,t,e)}else n instanceof i.Ref&&r.push(n.toString())}}else(0,a.warn)("Invalid visibility expression")}async parseMarkedContentProps(e,t){let r;if(e instanceof i.Name){r=t.get("Properties").get(e.name)}else{if(!(e instanceof i.Dict))throw new a.FormatError("Optional content properties malformed.");r=e}const n=r.get("Type").name;if("OCG"===n)return{type:n,id:r.objId};if("OCMD"===n){const e=r.get("VE");if(Array.isArray(e)){const t=[];this._parseVisibilityExpression(e,0,t);if(t.length>0)return{type:"OCMD",expression:t}}const t=r.get("OCGs");if(Array.isArray(t)||t instanceof i.Dict){const e=[];if(Array.isArray(t))for(const r of t)e.push(r.toString());else e.push(t.objId);return{type:n,ids:e,policy:r.get("P")instanceof i.Name?r.get("P").name:null,expression:null}}if(t instanceof i.Ref)return{type:n,id:t.toString()}}return null}getOperatorList(e){let{stream:t,task:r,resources:n,operatorList:s,initialState:o=null,fallbackFontDict:c=null}=e;n=n||i.Dict.empty;o=o||new EvalState;if(!s)throw new Error('getOperatorList: missing "operatorList" parameter');const l=this,h=this.xref;let u=!1;const d=new m.LocalImageCache,f=new m.LocalColorSpaceCache,g=new m.LocalGStateCache,p=new m.LocalTilingPatternCache,b=new Map,w=n.get("XObject")||i.Dict.empty,x=n.get("Pattern")||i.Dict.empty,k=new StateManager(o),C=new EvaluatorPreprocessor(t,h,k),v=new TimeSlotManager;function closePendingRestoreOPS(e){for(let e=0,t=C.savedStatesDepth;e<t;e++)s.addOp(a.OPS.restore,[])}return new Promise((function promiseBody(e,t){const next=function(r){Promise.all([r,s.ready]).then((function(){try{promiseBody(e,t)}catch(e){t(e)}}),t)};r.ensureNotTerminated();v.reset();const o={};let m,O,T,M,E,D;for(;!(m=v.check());){o.args=null;if(!C.read(o))break;let e=o.args,t=o.fn;switch(0|t){case a.OPS.paintXObject:D=e[0]instanceof i.Name;E=e[0].name;if(D){const t=d.getByName(E);if(t){s.addImageOps(t.fn,t.args,t.optionalContent);incrementCachedImageMaskCount(t);e=null;continue}}next(new Promise((function(e,t){if(!D)throw new a.FormatError("XObject must be referred to by name.");let o=w.getRaw(E);if(o instanceof i.Ref){const t=d.getByRef(o);if(t){s.addImageOps(t.fn,t.args,t.optionalContent);incrementCachedImageMaskCount(t);e();return}const r=l.globalImageCache.getData(o,l.pageIndex);if(r){s.addDependency(r.objId);s.addImageOps(r.fn,r.args,r.optionalContent);e();return}o=h.fetch(o)}if(!(o instanceof y.BaseStream))throw new a.FormatError("XObject should be a stream");const c=o.dict.get("Subtype");if(!(c instanceof i.Name))throw new a.FormatError("XObject should have a Name subtype");if("Form"!==c.name)if("Image"!==c.name){if("PS"!==c.name)throw new a.FormatError(`Unhandled XObject subtype ${c.name}`);(0,a.info)("Ignored XObject subtype PS");e()}else l.buildPaintImageXObject({resources:n,image:o,operatorList:s,cacheKey:E,localImageCache:d,localColorSpaceCache:f}).then(e,t);else{k.save();l.buildFormXObject(n,o,null,s,r,k.state.clone(),f).then((function(){k.restore();e()}),t)}})).catch((function(e){if(!(e instanceof a.AbortException)){if(!l.options.ignoreErrors)throw e;l.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorXObject});(0,a.warn)(`getOperatorList - ignoring XObject: "${e}".`)}})));return;case a.OPS.setFont:var N=e[1];next(l.handleSetFont(n,e,null,s,r,k.state,c).then((function(e){s.addDependency(e);s.addOp(a.OPS.setFont,[e,N])})));return;case a.OPS.beginText:u=!0;break;case a.OPS.endText:u=!1;break;case a.OPS.endInlineImage:var L=e[0].cacheKey;if(L){const t=d.getByName(L);if(t){s.addImageOps(t.fn,t.args,t.optionalContent);incrementCachedImageMaskCount(t);e=null;continue}}next(l.buildPaintImageXObject({resources:n,image:e[0],isInline:!0,operatorList:s,cacheKey:L,localImageCache:d,localColorSpaceCache:f}));return;case a.OPS.showText:if(!k.state.font){l.ensureStateFont(k.state);continue}e[0]=l.handleText(e[0],k.state);break;case a.OPS.showSpacedText:if(!k.state.font){l.ensureStateFont(k.state);continue}var j=e[0],$=[],_=j.length,U=k.state;for(O=0;O<_;++O){const e=j[O];"string"==typeof e?Array.prototype.push.apply($,l.handleText(e,U)):"number"==typeof e&&$.push(e)}e[0]=$;t=a.OPS.showText;break;case a.OPS.nextLineShowText:if(!k.state.font){l.ensureStateFont(k.state);continue}s.addOp(a.OPS.nextLine);e[0]=l.handleText(e[0],k.state);t=a.OPS.showText;break;case a.OPS.nextLineSetSpacingShowText:if(!k.state.font){l.ensureStateFont(k.state);continue}s.addOp(a.OPS.nextLine);s.addOp(a.OPS.setWordSpacing,[e.shift()]);s.addOp(a.OPS.setCharSpacing,[e.shift()]);e[0]=l.handleText(e[0],k.state);t=a.OPS.showText;break;case a.OPS.setTextRenderingMode:k.state.textRenderingMode=e[0];break;case a.OPS.setFillColorSpace:{const t=S.ColorSpace.getCached(e[0],h,f);if(t){k.state.fillColorSpace=t;continue}next(l.parseColorSpace({cs:e[0],resources:n,localColorSpaceCache:f}).then((function(e){e&&(k.state.fillColorSpace=e)})));return}case a.OPS.setStrokeColorSpace:{const t=S.ColorSpace.getCached(e[0],h,f);if(t){k.state.strokeColorSpace=t;continue}next(l.parseColorSpace({cs:e[0],resources:n,localColorSpaceCache:f}).then((function(e){e&&(k.state.strokeColorSpace=e)})));return}case a.OPS.setFillColor:M=k.state.fillColorSpace;e=M.getRgb(e,0);t=a.OPS.setFillRGBColor;break;case a.OPS.setStrokeColor:M=k.state.strokeColorSpace;e=M.getRgb(e,0);t=a.OPS.setStrokeRGBColor;break;case a.OPS.setFillGray:k.state.fillColorSpace=S.ColorSpace.singletons.gray;e=S.ColorSpace.singletons.gray.getRgb(e,0);t=a.OPS.setFillRGBColor;break;case a.OPS.setStrokeGray:k.state.strokeColorSpace=S.ColorSpace.singletons.gray;e=S.ColorSpace.singletons.gray.getRgb(e,0);t=a.OPS.setStrokeRGBColor;break;case a.OPS.setFillCMYKColor:k.state.fillColorSpace=S.ColorSpace.singletons.cmyk;e=S.ColorSpace.singletons.cmyk.getRgb(e,0);t=a.OPS.setFillRGBColor;break;case a.OPS.setStrokeCMYKColor:k.state.strokeColorSpace=S.ColorSpace.singletons.cmyk;e=S.ColorSpace.singletons.cmyk.getRgb(e,0);t=a.OPS.setStrokeRGBColor;break;case a.OPS.setFillRGBColor:k.state.fillColorSpace=S.ColorSpace.singletons.rgb;e=S.ColorSpace.singletons.rgb.getRgb(e,0);break;case a.OPS.setStrokeRGBColor:k.state.strokeColorSpace=S.ColorSpace.singletons.rgb;e=S.ColorSpace.singletons.rgb.getRgb(e,0);break;case a.OPS.setFillColorN:M=k.state.fillColorSpace;if("Pattern"===M.name){next(l.handleColorN(s,a.OPS.setFillColorN,e,M,x,n,r,f,p,b));return}e=M.getRgb(e,0);t=a.OPS.setFillRGBColor;break;case a.OPS.setStrokeColorN:M=k.state.strokeColorSpace;if("Pattern"===M.name){next(l.handleColorN(s,a.OPS.setStrokeColorN,e,M,x,n,r,f,p,b));return}e=M.getRgb(e,0);t=a.OPS.setStrokeRGBColor;break;case a.OPS.shadingFill:var X=n.get("Shading");if(!X)throw new a.FormatError("No shading resource found");var H=X.get(e[0].name);if(!H)throw new a.FormatError("No shading object found");e=[l.parseShading({shading:H,resources:n,localColorSpaceCache:f,localShadingPatternCache:b})];t=a.OPS.shadingFill;break;case a.OPS.setGState:D=e[0]instanceof i.Name;E=e[0].name;if(D){const t=g.getByName(E);if(t){t.length>0&&s.addOp(a.OPS.setGState,[t]);e=null;continue}}next(new Promise((function(e,t){if(!D)throw new a.FormatError("GState must be referred to by name.");const o=n.get("ExtGState");if(!(o instanceof i.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const c=o.get(E);if(!(c instanceof i.Dict))throw new a.FormatError("GState should be a dictionary.");l.setGState({resources:n,gState:c,operatorList:s,cacheKey:E,task:r,stateManager:k,localGStateCache:g,localColorSpaceCache:f}).then(e,t)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!l.options.ignoreErrors)throw e;l.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:l.buildPath(s,t,e,u);continue;case a.OPS.markPoint:case a.OPS.markPointProps:case a.OPS.beginCompat:case a.OPS.endCompat:continue;case a.OPS.beginMarkedContentProps:if(!(e[0]instanceof i.Name)){(0,a.warn)(`Expected name for beginMarkedContentProps arg0=${e[0]}`);continue}if("OC"===e[0].name){next(l.parseMarkedContentProps(e[1],n).then((e=>{s.addOp(a.OPS.beginMarkedContentProps,["OC",e])})).catch((e=>{if(!(e instanceof a.AbortException)){if(!l.options.ignoreErrors)throw e;l.handler.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorMarkedContent});(0,a.warn)(`getOperatorList - ignoring beginMarkedContentProps: "${e}".`)}})));return}e=[e[0].name,e[1]instanceof i.Dict?e[1].get("MCID"):null];break;case a.OPS.beginMarkedContent:case a.OPS.endMarkedContent:default:if(null!==e){for(O=0,T=e.length;O<T&&!(e[O]instanceof i.Dict);O++);if(O<T){(0,a.warn)("getOperatorList - ignoring operator: "+t);continue}}}s.addOp(t,e)}if(m)next(R);else{closePendingRestoreOPS();e()}})).catch((e=>{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 "${r.name}" task: "${e}".`);closePendingRestoreOPS()}}))}getTextContent(e){let{stream:t,task:r,resources:n,stateManager:s=null,combineTextItems:o=!1,includeMarkedContent:c=!1,sink:l,seenStyles:u=new Set,viewBox:d}=e;n=n||i.Dict.empty;s=s||new StateManager(new TextState);const f=(0,h.getNormalizedUnicodes)(),g={items:[],styles:Object.create(null)},p={initialized:!1,str:[],totalWidth:0,totalHeight:0,width:0,height:0,vertical:!1,prevTransform:null,textAdvanceScale:0,spaceInFlowMin:0,spaceInFlowMax:0,trackingSpaceMin:1/0,negativeSpaceMax:-1/0,notASpace:-1/0,transform:null,fontName:null,hasEOL:!1},b=[" "," "];let S=0;function saveLastChar(e){const t=(S+1)%2,r=" "!==b[S]&&" "===b[t];b[S]=e;S=t;return r}function resetLastChars(){b[0]=b[1]=" ";S=0}const x=this,k=this.xref,C=[];let v=null;const O=new m.LocalImageCache,T=new m.LocalGStateCache,M=new EvaluatorPreprocessor(t,k,s);let E;function getCurrentTextTransform(){const e=E.font,t=[E.fontSize*E.textHScale,0,0,E.fontSize,0,E.textRise];if(e.isType3Font&&(E.fontSize<=1||e.isCharBBox)&&!(0,a.isArrayEqual)(E.fontMatrix,a.FONT_IDENTITY_MATRIX)){const r=e.bbox[3]-e.bbox[1];r>0&&(t[3]*=r*E.fontMatrix[3])}return a.Util.transform(E.ctm,a.Util.transform(E.textMatrix,t))}function ensureTextContentItem(){if(p.initialized)return p;const e=E.font,t=e.loadedName;if(!u.has(t)){u.add(t);g.styles[t]={fontFamily:e.fallbackName,ascent:e.ascent,descent:e.descent,vertical:e.vertical}}p.fontName=t;const r=p.transform=getCurrentTextTransform();if(e.vertical){p.width=p.totalWidth=Math.hypot(r[0],r[1]);p.height=p.totalHeight=0;p.vertical=!0}else{p.width=p.totalWidth=0;p.height=p.totalHeight=Math.hypot(r[2],r[3]);p.vertical=!1}const a=Math.hypot(E.textLineMatrix[0],E.textLineMatrix[1]),n=Math.hypot(E.ctm[0],E.ctm[1]);p.textAdvanceScale=n*a;p.trackingSpaceMin=.1*E.fontSize;p.notASpace=.03*E.fontSize;p.negativeSpaceMax=-.2*E.fontSize;p.spaceInFlowMin=.1*E.fontSize;p.spaceInFlowMax=.6*E.fontSize;p.hasEOL=!1;p.initialized=!0;return p}function updateAdvanceScale(){if(!p.initialized)return;const e=Math.hypot(E.textLineMatrix[0],E.textLineMatrix[1]),t=Math.hypot(E.ctm[0],E.ctm[1])*e;if(t!==p.textAdvanceScale){if(p.vertical){p.totalHeight+=p.height*p.textAdvanceScale;p.height=0}else{p.totalWidth+=p.width*p.textAdvanceScale;p.width=0}p.textAdvanceScale=t}}function handleSetFont(e,t){return x.loadFont(e,t,n).then((function(e){return e.font.isType3Font?e.loadType3Data(x,n,r).catch((function(){})).then((function(){return e})):e})).then((function(e){E.font=e.font;E.fontMatrix=e.font.fontMatrix||a.FONT_IDENTITY_MATRIX}))}function applyInverseRotation(e,t,r){const a=Math.hypot(r[0],r[1]);return[(r[0]*e+r[1]*t)/a,(r[2]*e+r[3]*t)/a]}function compareWithLastPosition(){const e=getCurrentTextTransform();let t=e[4],r=e[5];const a=t-d[0],n=r-d[1];if(a<0||a>d[2]||n<0||n>d[3])return!1;if(!o||!E.font||!p.prevTransform)return!0;let i=p.prevTransform[4],s=p.prevTransform[5];if(i===t&&s===r)return!0;let c=-1;e[0]&&0===e[1]&&0===e[2]?c=e[0]>0?0:180:e[1]&&0===e[0]&&0===e[3]&&(c=e[1]>0?90:270);switch(c){case 0:break;case 90:[t,r]=[r,t];[i,s]=[s,i];break;case 180:[t,r,i,s]=[-t,-r,-i,-s];break;case 270:[t,r]=[-r,-t];[i,s]=[-s,-i];break;default:[t,r]=applyInverseRotation(t,r,e);[i,s]=applyInverseRotation(i,s,p.prevTransform)}if(E.font.vertical){const e=(s-r)/p.textAdvanceScale,a=t-i,n=Math.sign(p.height);if(e<n*p.negativeSpaceMax){if(Math.abs(a)>.5*p.width){appendEOL();return!0}resetLastChars();flushTextContentItem();return!0}if(Math.abs(a)>p.width){appendEOL();return!0}e<=n*p.notASpace&&resetLastChars();if(e<=n*p.trackingSpaceMin)p.height+=e;else if(!addFakeSpaces(e,p.prevTransform,n))if(0===p.str.length){resetLastChars();g.items.push({str:" ",dir:"ltr",width:0,height:Math.abs(e),transform:p.prevTransform,fontName:p.fontName,hasEOL:!1})}else p.height+=e;return!0}const l=(t-i)/p.textAdvanceScale,h=r-s,u=Math.sign(p.width);if(l<u*p.negativeSpaceMax){if(Math.abs(h)>.5*p.height){appendEOL();return!0}resetLastChars();flushTextContentItem();return!0}if(Math.abs(h)>p.height){appendEOL();return!0}l<=u*p.notASpace&&resetLastChars();if(l<=u*p.trackingSpaceMin)p.width+=l;else if(!addFakeSpaces(l,p.prevTransform,u))if(0===p.str.length){resetLastChars();g.items.push({str:" ",dir:"ltr",width:Math.abs(l),height:0,transform:p.prevTransform,fontName:p.fontName,hasEOL:!1})}else p.width+=l;return!0}function buildTextContentItem(e){let{chars:t,extraSpacing:r}=e;const a=E.font;if(!t){const e=E.charSpacing+r;e&&(a.vertical?E.translateTextMatrix(0,-e):E.translateTextMatrix(e*E.textHScale,0));return}const n=a.charsToGlyphs(t),i=E.fontMatrix[0]*E.fontSize;for(let e=0,t=n.length;e<t;e++){const s=n[e];if(s.isInvisibleFormatMark)continue;let o=E.charSpacing+(e+1===t?r:0),c=s.width;a.vertical&&(c=s.vmetric?s.vmetric[0]:-c);let l=c*i;if(s.isWhitespace){if(a.vertical){o+=-l+E.wordSpacing;E.translateTextMatrix(0,-o)}else{o+=l+E.wordSpacing;E.translateTextMatrix(o*E.textHScale,0)}saveLastChar(" ");continue}if(!compareWithLastPosition())continue;const u=ensureTextContentItem();s.isZeroWidthDiacritic&&(l=0);if(a.vertical){E.translateTextMatrix(0,l);l=Math.abs(l);u.height+=l}else{l*=E.textHScale;E.translateTextMatrix(l,0);u.width+=l}l&&(u.prevTransform=getCurrentTextTransform());let d=s.unicode;d=f[d]||d;d=(0,h.reverseIfRtl)(d);saveLastChar(d)&&u.str.push(" ");u.str.push(d);o&&(a.vertical?E.translateTextMatrix(0,-o):E.translateTextMatrix(o*E.textHScale,0))}}function appendEOL(){resetLastChars();if(p.initialized){p.hasEOL=!0;flushTextContentItem()}else g.items.push({str:"",dir:"ltr",width:0,height:0,transform:getCurrentTextTransform(),fontName:E.font.loadedName,hasEOL:!0})}function addFakeSpaces(e,t,r){if(r*p.spaceInFlowMin<=e&&e<=r*p.spaceInFlowMax){if(p.initialized){resetLastChars();p.str.push(" ")}return!1}const a=p.fontName;let n=0;if(p.vertical){n=e;e=0}flushTextContentItem();resetLastChars();g.items.push({str:" ",dir:"ltr",width:Math.abs(e),height:Math.abs(n),transform:t||getCurrentTextTransform(),fontName:a,hasEOL:!1});return!0}function flushTextContentItem(){if(p.initialized&&p.str){p.vertical?p.totalHeight+=p.height*p.textAdvanceScale:p.totalWidth+=p.width*p.textAdvanceScale;g.items.push(function runBidiTransform(e){const t=e.str.join(""),r=(0,w.bidi)(t,-1,e.vertical);return{str:r.str,dir:r.dir,width:Math.abs(e.totalWidth),height:Math.abs(e.totalHeight),transform:e.transform,fontName:e.fontName,hasEOL:e.hasEOL}}(p));p.initialized=!1;p.str.length=0}}function enqueueChunk(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=g.items.length;if(0!==t&&!(e&&t<10)){l.enqueue(g,t);g.items=[];g.styles=Object.create(null)}}const D=new TimeSlotManager;return new Promise((function promiseBody(e,t){const next=function(r){enqueueChunk(!0);Promise.all([r,l.ready]).then((function(){try{promiseBody(e,t)}catch(e){t(e)}}),t)};r.ensureNotTerminated();D.reset();const h={};let f,p=[];for(;!(f=D.check());){p.length=0;h.args=p;if(!M.read(h))break;E=s.state;const e=h.fn;p=h.args;switch(0|e){case a.OPS.setFont:var m=p[0].name,b=p[1];if(E.font&&m===E.fontName&&b===E.fontSize)break;flushTextContentItem();E.fontName=m;E.fontSize=b;next(handleSetFont(m,null));return;case a.OPS.setTextRise:E.textRise=p[0];break;case a.OPS.setHScale:E.textHScale=p[0]/100;break;case a.OPS.setLeading:E.leading=p[0];break;case a.OPS.moveText:E.translateTextLineMatrix(p[0],p[1]);E.textMatrix=E.textLineMatrix.slice();break;case a.OPS.setLeadingMoveText:E.leading=-p[1];E.translateTextLineMatrix(p[0],p[1]);E.textMatrix=E.textLineMatrix.slice();break;case a.OPS.nextLine:E.carriageReturn();break;case a.OPS.setTextMatrix:E.setTextMatrix(p[0],p[1],p[2],p[3],p[4],p[5]);E.setTextLineMatrix(p[0],p[1],p[2],p[3],p[4],p[5]);updateAdvanceScale();break;case a.OPS.setCharSpacing:E.charSpacing=p[0];break;case a.OPS.setWordSpacing:E.wordSpacing=p[0];break;case a.OPS.beginText:E.textMatrix=a.IDENTITY_MATRIX.slice();E.textLineMatrix=a.IDENTITY_MATRIX.slice();break;case a.OPS.showSpacedText:if(!s.state.font){x.ensureStateFont(s.state);continue}const e=(E.font.vertical?1:-1)*E.fontSize/1e3,t=p[0];for(let r=0,a=t.length;r<a-1;r++){const a=t[r];if("string"==typeof a)C.push(a);else if("number"==typeof a&&0!==a){const t=C.join("");C.length=0;buildTextContentItem({chars:t,extraSpacing:a*e})}}const h=t.at(-1);"string"==typeof h&&C.push(h);if(C.length>0){const e=C.join("");C.length=0;buildTextContentItem({chars:e,extraSpacing:0})}break;case a.OPS.showText:if(!s.state.font){x.ensureStateFont(s.state);continue}buildTextContentItem({chars:p[0],extraSpacing:0});break;case a.OPS.nextLineShowText:if(!s.state.font){x.ensureStateFont(s.state);continue}E.carriageReturn();buildTextContentItem({chars:p[0],extraSpacing:0});break;case a.OPS.nextLineSetSpacingShowText:if(!s.state.font){x.ensureStateFont(s.state);continue}E.wordSpacing=p[0];E.charSpacing=p[1];E.carriageReturn();buildTextContentItem({chars:p[2],extraSpacing:0});break;case a.OPS.paintXObject:flushTextContentItem();v||(v=n.get("XObject")||i.Dict.empty);var w=p[0]instanceof i.Name,S=p[0].name;if(w&&O.getByName(S))break;next(new Promise((function(e,t){if(!w)throw new a.FormatError("XObject must be referred to by name.");let h=v.getRaw(S);if(h instanceof i.Ref){if(O.getByRef(h)){e();return}if(x.globalImageCache.getData(h,x.pageIndex)){e();return}h=k.fetch(h)}if(!(h instanceof y.BaseStream))throw new a.FormatError("XObject should be a stream");const f=h.dict.get("Subtype");if(!(f instanceof i.Name))throw new a.FormatError("XObject should have a Name subtype");if("Form"!==f.name){O.set(S,h.dict.objId,!0);e();return}const g=s.state.clone(),p=new StateManager(g),m=h.dict.getArray("Matrix");Array.isArray(m)&&6===m.length&&p.transform(m);enqueueChunk();const b={enqueueInvoked:!1,enqueue(e,t){this.enqueueInvoked=!0;l.enqueue(e,t)},get desiredSize(){return l.desiredSize},get ready(){return l.ready}};x.getTextContent({stream:h,task:r,resources:h.dict.get("Resources")||n,stateManager:p,combineTextItems:o,includeMarkedContent:c,sink:b,seenStyles:u,viewBox:d}).then((function(){b.enqueueInvoked||O.set(S,h.dict.objId,!0);e()}),t)})).catch((function(e){if(!(e instanceof a.AbortException)){if(!x.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring XObject: "${e}".`)}})));return;case a.OPS.setGState:w=p[0]instanceof i.Name;S=p[0].name;if(w&&T.getByName(S))break;next(new Promise((function(e,t){if(!w)throw new a.FormatError("GState must be referred to by name.");const r=n.get("ExtGState");if(!(r instanceof i.Dict))throw new a.FormatError("ExtGState should be a dictionary.");const s=r.get(S);if(!(s instanceof i.Dict))throw new a.FormatError("GState should be a dictionary.");const o=s.get("Font");if(o){flushTextContentItem();E.fontName=null;E.fontSize=o[1];handleSetFont(null,o[0]).then(e,t)}else{T.set(S,s.objId,!0);e()}})).catch((function(e){if(!(e instanceof a.AbortException)){if(!x.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring ExtGState: "${e}".`)}})));return;case a.OPS.beginMarkedContent:flushTextContentItem();c&&g.items.push({type:"beginMarkedContent",tag:p[0]instanceof i.Name?p[0].name:null});break;case a.OPS.beginMarkedContentProps:flushTextContentItem();if(c){let e=null;p[1]instanceof i.Dict&&(e=p[1].get("MCID"));g.items.push({type:"beginMarkedContentProps",id:Number.isInteger(e)?`${x.idFactory.getPageObjId()}_mcid${e}`:null,tag:p[0]instanceof i.Name?p[0].name:null})}break;case a.OPS.endMarkedContent:flushTextContentItem();c&&g.items.push({type:"endMarkedContent"})}if(g.items.length>=l.desiredSize){f=!0;break}}if(f)next(R);else{flushTextContentItem();enqueueChunk();e()}})).catch((e=>{if(!(e instanceof a.AbortException)){if(!this.options.ignoreErrors)throw e;(0,a.warn)(`getTextContent - ignoring errors during "${r.name}" task: "${e}".`);flushTextContentItem();enqueueChunk()}}))}extractDataStructures(e,t,r){const n=this.xref;let s;const l=this.readToUnicode(r.toUnicode||e.get("ToUnicode")||t.get("ToUnicode"));if(r.composite){const t=e.get("CIDSystemInfo");t instanceof i.Dict&&(r.cidSystemInfo={registry:(0,a.stringToPDFString)(t.get("Registry")),ordering:(0,a.stringToPDFString)(t.get("Ordering")),supplement:t.get("Supplement")});try{const t=e.get("CIDToGIDMap");t instanceof y.BaseStream&&(s=t.getBytes())}catch(e){if(!this.options.ignoreErrors)throw e;(0,a.warn)(`extractDataStructures - ignoring CIDToGIDMap data: "${e}".`)}}const h=[];let u,d=null;if(e.has("Encoding")){u=e.get("Encoding");if(u instanceof i.Dict){d=u.get("BaseEncoding");d=d instanceof i.Name?d.name:null;if(u.has("Differences")){const e=u.get("Differences");let t=0;for(let r=0,s=e.length;r<s;r++){const s=n.fetchIfRef(e[r]);if("number"==typeof s)t=s;else{if(!(s instanceof i.Name))throw new a.FormatError(`Invalid entry in 'Differences' array: ${s}`);h[t++]=s.name}}}}else if(u instanceof i.Name)d=u.name;else{const e="Encoding is not a Name nor a Dict";if(!this.options.ignoreErrors)throw new a.FormatError(e);(0,a.warn)(e)}"MacRomanEncoding"!==d&&"MacExpertEncoding"!==d&&"WinAnsiEncoding"!==d&&(d=null)}if(d)r.defaultEncoding=(0,c.getEncoding)(d);else{const e=!!(r.flags&o.FontFlags.Symbolic),t=!!(r.flags&o.FontFlags.Nonsymbolic);u=c.StandardEncoding;"TrueType"!==r.type||t||(u=c.WinAnsiEncoding);if(e){u=c.MacRomanEncoding;r.file&&!r.isInternalFont||(/Symbol/i.test(r.name)?u=c.SymbolSetEncoding:/Dingbats|Wingdings/i.test(r.name)&&(u=c.ZapfDingbatsEncoding))}r.defaultEncoding=u}r.differences=h;r.baseEncodingName=d;r.hasEncoding=!!d||h.length>0;r.dict=e;return l.then((e=>{r.toUnicode=e;return this.buildToUnicode(r)})).then((e=>{r.toUnicode=e;s&&(r.cidToGidMap=this.readCidToGidMap(s,e));return r}))}_simpleFontToUnicode(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(0,a.assert)(!e.composite,"Must be a simple font.");const r=[],n=e.defaultEncoding.slice(),i=e.baseEncodingName,s=e.differences;for(const e in s){const t=s[e];".notdef"!==t&&(n[e]=t)}const o=(0,k.getGlyphsUnicode)();for(const a in n){let s=n[a];if(""!==s)if(void 0!==o[s])r[a]=String.fromCharCode(o[s]);else{let n=0;switch(s[0]){case"G":3===s.length&&(n=parseInt(s.substring(1),16));break;case"g":5===s.length&&(n=parseInt(s.substring(1),16));break;case"C":case"c":if(s.length>=3&&s.length<=4){const r=s.substring(1);if(t){n=parseInt(r,16);break}n=+r;if(Number.isNaN(n)&&Number.isInteger(parseInt(r,16)))return this._simpleFontToUnicode(e,!0)}break;default:const r=(0,h.getUnicodeForGlyph)(s,o);-1!==r&&(n=r)}if(n>0&&n<=1114111&&Number.isInteger(n)){if(i&&n===+a){const e=(0,c.getEncoding)(i);if(e&&(s=e[a])){r[a]=String.fromCharCode(o[s]);continue}}r[a]=String.fromCodePoint(n)}}}return r}async buildToUnicode(e){e.hasIncludedToUnicodeMap=!!e.toUnicode&&e.toUnicode.length>0;if(e.hasIncludedToUnicodeMap){!e.composite&&e.hasEncoding&&(e.fallbackToUnicode=this._simpleFontToUnicode(e));return e.toUnicode}if(!e.composite)return new f.ToUnicodeMap(this._simpleFontToUnicode(e));if(e.composite&&(e.cMap.builtInCMap&&!(e.cMap instanceof n.IdentityCMap)||"Adobe"===e.cidSystemInfo.registry&&("GB1"===e.cidSystemInfo.ordering||"CNS1"===e.cidSystemInfo.ordering||"Japan1"===e.cidSystemInfo.ordering||"Korea1"===e.cidSystemInfo.ordering))){const{registry:t,ordering:r}=e.cidSystemInfo,s=i.Name.get(`${t}-${r}-UCS2`),o=await n.CMapFactory.create({encoding:s,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}),c=[];e.cMap.forEach((function(e,t){if(t>65535)throw new a.FormatError("Max size of CID is 65,535");const r=o.lookup(t);r&&(c[e]=String.fromCharCode((r.charCodeAt(0)<<8)+r.charCodeAt(1)))}));return new f.ToUnicodeMap(c)}return new f.IdentityToUnicodeMap(e.firstChar,e.lastChar)}readToUnicode(e){return e?e instanceof i.Name?n.CMapFactory.create({encoding:e,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(e){return e instanceof n.IdentityCMap?new f.IdentityToUnicodeMap(0,65535):new f.ToUnicodeMap(e.getMap())})):e instanceof y.BaseStream?n.CMapFactory.create({encoding:e,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null}).then((function(e){if(e instanceof n.IdentityCMap)return new f.IdentityToUnicodeMap(0,65535);const t=new Array(e.length);e.forEach((function(e,r){if("number"==typeof r){t[e]=String.fromCodePoint(r);return}const a=[];for(let e=0;e<r.length;e+=2){const t=r.charCodeAt(e)<<8|r.charCodeAt(e+1);if(55296!=(63488&t)){a.push(t);continue}e+=2;const n=r.charCodeAt(e)<<8|r.charCodeAt(e+1);a.push(((1023&t)<<10)+(1023&n)+65536)}t[e]=String.fromCodePoint(...a)}));return new f.ToUnicodeMap(t)}),(e=>{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):Promise.resolve(null)}readCidToGidMap(e,t){const r=[];for(let a=0,n=e.length;a<n;a++){const n=e[a++]<<8|e[a],i=a>>1;(0!==n||t.has(i))&&(r[i]=n)}return r}extractWidths(e,t,r){const a=this.xref;let n=[],s=0;const c=[];let l,h,u,d,f,g,p,m;if(r.composite){s=e.has("DW")?e.get("DW"):1e3;m=e.get("W");if(m)for(h=0,u=m.length;h<u;h++){g=a.fetchIfRef(m[h++]);p=a.fetchIfRef(m[h]);if(Array.isArray(p))for(d=0,f=p.length;d<f;d++)n[g++]=a.fetchIfRef(p[d]);else{const e=a.fetchIfRef(m[++h]);for(d=g;d<=p;d++)n[d]=e}}if(r.vertical){let t=e.getArray("DW2")||[880,-1e3];l=[t[1],.5*s,t[0]];t=e.get("W2");if(t)for(h=0,u=t.length;h<u;h++){g=a.fetchIfRef(t[h++]);p=a.fetchIfRef(t[h]);if(Array.isArray(p))for(d=0,f=p.length;d<f;d++)c[g++]=[a.fetchIfRef(p[d++]),a.fetchIfRef(p[d++]),a.fetchIfRef(p[d])];else{const e=[a.fetchIfRef(t[++h]),a.fetchIfRef(t[++h]),a.fetchIfRef(t[++h])];for(d=g;d<=p;d++)c[d]=e}}}}else{const o=r.firstChar;m=e.get("Widths");if(m){d=o;for(h=0,u=m.length;h<u;h++)n[d++]=a.fetchIfRef(m[h]);s=parseFloat(t.get("MissingWidth"))||0}else{const t=e.get("BaseFont");if(t instanceof i.Name){const e=this.getBaseFontMetrics(t.name);n=this.buildCharCodeToWidth(e.widths,r);s=e.defaultWidth}}}let b=!0,y=s;for(const e in n){const t=n[e];if(t)if(y){if(y!==t){b=!1;break}}else y=t}b&&(r.flags|=o.FontFlags.FixedPitch);r.defaultWidth=s;r.widths=n;r.defaultVMetrics=l;r.vmetrics=c}isSerifFont(e){const t=e.split("-")[0];return t in(0,l.getSerifFonts)()||-1!==t.search(/serif/gi)}getBaseFontMetrics(e){let t=0,r=Object.create(null),a=!1;let n=(0,l.getStdFontMap)()[e]||e;const i=(0,v.getMetrics)();n in i||(n=this.isSerifFont(e)?"Times-Roman":"Helvetica");const s=i[n];if("number"==typeof s){t=s;a=!0}else r=s();return{defaultWidth:t,monospace:a,widths:r}}buildCharCodeToWidth(e,t){const r=Object.create(null),a=t.differences,n=t.defaultEncoding;for(let t=0;t<256;t++)t in a&&e[a[t]]?r[t]=e[a[t]]:t in n&&e[n[t]]&&(r[t]=e[n[t]]);return r}preEvaluateFont(e){const t=e;let r=e.get("Subtype");if(!(r instanceof i.Name))throw new a.FormatError("invalid font Subtype");let n,s,o=!1;if("Type0"===r.name){const t=e.get("DescendantFonts");if(!t)throw new a.FormatError("Descendant fonts are not specified");if(!((e=Array.isArray(t)?this.xref.fetchIfRef(t[0]):t)instanceof i.Dict))throw new a.FormatError("Descendant font is not a dictionary.");r=e.get("Subtype");if(!(r instanceof i.Name))throw new a.FormatError("invalid font Subtype");o=!0}const c=e.get("FirstChar")||0,l=e.get("LastChar")||(o?65535:255),h=e.get("FontDescriptor");if(h){n=new O.MurmurHash3_64;const r=t.getRaw("Encoding");if(r instanceof i.Name)n.update(r.name);else if(r instanceof i.Ref)n.update(r.toString());else if(r instanceof i.Dict)for(const e of r.getRawValues())if(e instanceof i.Name)n.update(e.name);else if(e instanceof i.Ref)n.update(e.toString());else if(Array.isArray(e)){const t=e.length,r=new Array(t);for(let a=0;a<t;a++){const t=e[a];t instanceof i.Name?r[a]=t.name:("number"==typeof t||t instanceof i.Ref)&&(r[a]=t.toString())}n.update(r.join())}n.update(`${c}-${l}`);s=e.get("ToUnicode")||t.get("ToUnicode");if(s instanceof y.BaseStream){const e=s.str||s,t=e.buffer?new Uint8Array(e.buffer.buffer,0,e.bufferLength):new Uint8Array(e.bytes.buffer,e.start,e.end-e.start);n.update(t)}else s instanceof i.Name&&n.update(s.name);const a=e.get("Widths")||t.get("Widths");if(Array.isArray(a)){const e=[];for(const t of a)("number"==typeof t||t instanceof i.Ref)&&e.push(t.toString());n.update(e.join())}if(o){n.update("compositeFont");const r=e.get("W")||t.get("W");if(Array.isArray(r)){const e=[];for(const t of r)if("number"==typeof t||t instanceof i.Ref)e.push(t.toString());else if(Array.isArray(t)){const r=[];for(const e of t)("number"==typeof e||e instanceof i.Ref)&&r.push(e.toString());e.push(`[${r.join()}]`)}n.update(e.join())}const a=e.getRaw("CIDToGIDMap")||t.getRaw("CIDToGIDMap");a instanceof i.Name?n.update(a.name):a instanceof i.Ref?n.update(a.toString()):a instanceof y.BaseStream&&n.update(a.peekBytes())}}return{descriptor:h,dict:e,baseDict:t,composite:o,type:r.name,firstChar:c,lastChar:l,toUnicode:s,hash:n?n.hexdigest():""}}async translateFont(e){let{descriptor:t,dict:r,baseDict:c,composite:h,type:u,firstChar:f,lastChar:g,toUnicode:p,cssFontInfo:m}=e;const y="Type3"===u;let w;if(!t){if(!y){let e=r.get("BaseFont");if(!(e instanceof i.Name))throw new a.FormatError("Base font is not specified");e=e.name.replace(/[,_]/g,"-");const t=this.getBaseFontMetrics(e),n=e.split("-")[0],h=(this.isSerifFont(n)?o.FontFlags.Serif:0)|(t.monospace?o.FontFlags.FixedPitch:0)|((0,l.getSymbolsFonts)()[n]?o.FontFlags.Symbolic:o.FontFlags.Nonsymbolic);w={type:u,name:e,loadedName:c.loadedName,widths:t.widths,defaultWidth:t.defaultWidth,isSimulatedFlags:!0,flags:h,firstChar:f,lastChar:g,toUnicode:p,xHeight:0,capHeight:0,italicAngle:0,isType3Font:y};const d=r.get("Widths"),m=(0,l.getStandardFontName)(e);let b=null;if(m){w.isStandardFont=!0;b=await this.fetchStandardFontData(m);w.isInternalFont=!!b}return this.extractDataStructures(r,r,w).then((r=>{if(d){const e=[];let t=f;for(let r=0,a=d.length;r<a;r++)e[t++]=this.xref.fetchIfRef(d[r]);r.widths=e}else r.widths=this.buildCharCodeToWidth(t.widths,r);return new s.Font(e,b,r)}))}t=new i.Dict(null);t.set("FontName",i.Name.get(u));t.set("FontBBox",r.getArray("FontBBox")||[0,0,0,0])}let S,x,k,C,v,O=t.get("FontName"),T=r.get("BaseFont");"string"==typeof O&&(O=i.Name.get(O));"string"==typeof T&&(T=i.Name.get(T));if(!y){const e=O&&O.name,t=T&&T.name;if(e!==t){(0,a.info)(`The FontDescriptor's FontName is "${e}" but should be the same as the Font's BaseFont "${t}".`);e&&t&&t.startsWith(e)&&(O=T)}}O=O||T;if(!(O instanceof i.Name))throw new a.FormatError("invalid font name");try{S=t.get("FontFile","FontFile2","FontFile3")}catch(e){if(!this.options.ignoreErrors)throw e;(0,a.warn)(`translateFont - fetching "${O.name}" font file: "${e}".`);S=new b.NullStream}let M=!1,E=!1,D=null;if(S){if(S.dict){const e=S.dict.get("Subtype");e instanceof i.Name&&(x=e.name);k=S.dict.get("Length1");C=S.dict.get("Length2");v=S.dict.get("Length3")}}else if(m){const e=(0,d.getXfaFontName)(O.name);if(e){m.fontFamily=`${m.fontFamily}-PdfJS-XFA`;m.metrics=e.metrics||null;D=e.factors||null;S=await this.fetchStandardFontData(e.name);E=!!S;c=r=(0,d.getXfaFontDict)(O.name);h=!0}}else if(!y){const e=(0,l.getStandardFontName)(O.name);if(e){M=!0;S=await this.fetchStandardFontData(e);E=!!S}}w={type:u,name:O.name,subtype:x,file:S,length1:k,length2:C,length3:v,isStandardFont:M,isInternalFont:E,loadedName:c.loadedName,composite:h,fixedPitch:!1,fontMatrix:r.getArray("FontMatrix")||a.FONT_IDENTITY_MATRIX,firstChar:f,lastChar:g,toUnicode:p,bbox:t.getArray("FontBBox")||r.getArray("FontBBox"),ascent:t.get("Ascent"),descent:t.get("Descent"),xHeight:t.get("XHeight")||0,capHeight:t.get("CapHeight")||0,flags:t.get("Flags"),italicAngle:t.get("ItalicAngle")||0,isType3Font:y,cssFontInfo:m,scaleFactors:D};if(h){const e=c.get("Encoding");e instanceof i.Name&&(w.cidEncoding=e.name);const t=await n.CMapFactory.create({encoding:e,fetchBuiltInCMap:this._fetchBuiltInCMapBound,useCMap:null});w.cMap=t;w.vertical=w.cMap.vertical}return this.extractDataStructures(r,c,w).then((e=>{this.extractWidths(r,t,e);return new s.Font(O.name,S,e)}))}static buildFontPaths(e,t,r,n){function buildPath(t){const i=`${e.loadedName}_path_${t}`;try{if(e.renderer.hasBuiltPath(t))return;r.send("commonobj",[i,"FontPath",e.renderer.getPathJs(t)])}catch(e){if(n.ignoreErrors){r.send("UnsupportedFeature",{featureId:a.UNSUPPORTED_FEATURES.errorFontBuildPath});(0,a.warn)(`buildFontPaths - ignoring ${i} glyph: "${e}".`);return}throw e}}for(const e of t){buildPath(e.fontChar);const t=e.accent;t&&t.fontChar&&buildPath(t.fontChar)}}static get fallbackFontDict(){const e=new i.Dict;e.set("BaseFont",i.Name.get("PDFJS-FallbackFont"));e.set("Type",i.Name.get("FallbackType"));e.set("Subtype",i.Name.get("FallbackType"));e.set("Encoding",i.Name.get("WinAnsiEncoding"));return(0,a.shadow)(this,"fallbackFontDict",e)}}t.PartialEvaluator=PartialEvaluator;class TranslatedFont{constructor(e){let{loadedName:t,font:r,dict:a,evaluatorOptions:n}=e;this.loadedName=t;this.font=r;this.dict=a;this._evaluatorOptions=n||E;this.type3Loaded=null;this.type3Dependencies=r.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._evaluatorOptions.fontExtraProperties)])}}fallback(e){if(this.font.data){this.font.disableFontFace=!0;PartialEvaluator.buildFontPaths(this.font,this.font.glyphCacheValues,e,this._evaluatorOptions)}}loadType3Data(e,t,r){if(this.type3Loaded)return this.type3Loaded;if(!this.font.isType3Font)throw new Error("Must be a Type3 font.");const n=e.clone({ignoreErrors:!1});n.parsingType3Font=!0;const s=new i.RefSet(e.type3FontRefs);this.dict.objId&&!s.has(this.dict.objId)&&s.put(this.dict.objId);n.type3FontRefs=s;const o=this.font,c=this.type3Dependencies;let l=Promise.resolve();const h=this.dict.get("CharProcs"),u=this.dict.get("Resources")||t,d=Object.create(null),f=a.Util.normalizeRect(o.bbox||[0,0,0,0]),g=f[2]-f[0],p=f[3]-f[1],m=Math.hypot(g,p);for(const e of h.getKeys())l=l.then((()=>{const t=h.get(e),i=new T.OperatorList;return n.getOperatorList({stream:t,task:r,resources:u,operatorList:i}).then((()=>{i.fnArray[0]===a.OPS.setCharWidthAndBounds&&this._removeType3ColorOperators(i,m);d[e]=i.getIR();for(const e of i.dependencies)c.add(e)})).catch((function(t){(0,a.warn)(`Type3 font resource "${e}" is not available.`);const r=new T.OperatorList;d[e]=r.getIR()}))}));this.type3Loaded=l.then((()=>{o.charProcOperatorList=d;if(this._bbox){o.isCharBBox=!0;o.bbox=this._bbox}}));return this.type3Loaded}_removeType3ColorOperators(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:NaN;const r=a.Util.normalizeRect(e.argsArray[0].slice(2)),n=r[2]-r[0],i=r[3]-r[1],s=Math.hypot(n,i);if(0===n||0===i){e.fnArray.splice(0,1);e.argsArray.splice(0,1)}else if(0===t||Math.round(s/t)>=10){this._bbox||(this._bbox=[1/0,1/0,-1/0,-1/0]);this._bbox[0]=Math.min(this._bbox[0],r[0]);this._bbox[1]=Math.min(this._bbox[1],r[1]);this._bbox[2]=Math.max(this._bbox[2],r[2]);this._bbox[3]=Math.max(this._bbox[3],r[3])}let o=0,c=e.length;for(;o<c;){switch(e.fnArray[o]){case a.OPS.setCharWidthAndBounds:break;case a.OPS.setStrokeColorSpace:case a.OPS.setFillColorSpace:case a.OPS.setStrokeColor:case a.OPS.setStrokeColorN:case a.OPS.setFillColor:case a.OPS.setFillColorN:case a.OPS.setStrokeGray:case a.OPS.setFillGray:case a.OPS.setStrokeRGBColor:case a.OPS.setFillRGBColor:case a.OPS.setStrokeCMYKColor:case a.OPS.setFillCMYKColor:case a.OPS.shadingFill:case a.OPS.setRenderingIntent:e.fnArray.splice(o,1);e.argsArray.splice(o,1);c--;continue;case a.OPS.setGState:const[t]=e.argsArray[o];let r=0,n=t.length;for(;r<n;){const[e]=t[r];switch(e){case"TR":case"TR2":case"HT":case"BG":case"BG2":case"UCR":case"UCR2":t.splice(r,1);n--;continue}r++}}o++}}}class StateManager{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new EvalState;this.state=e;this.stateStack=[]}save(){const e=this.state;this.stateStack.push(this.state);this.state=e.clone()}restore(){const 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,n,i){const s=this.textMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=n;s[5]=i}setTextLineMatrix(e,t,r,a,n,i){const s=this.textLineMatrix;s[0]=e;s[1]=t;s[2]=r;s[3]=a;s[4]=n;s[5]=i}translateTextMatrix(e,t){const 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){const r=this.textLineMatrix;r[4]=r[0]*e+r[2]*t+r[4];r[5]=r[1]*e+r[3]*t+r[5]}carriageReturn(){this.translateTextLineMatrix(0,-this.leading);this.textMatrix=this.textLineMatrix.slice()}clone(){const 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=S.ColorSpace.singletons.gray;this.strokeColorSpace=S.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",10)}constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new StateManager;this.parser=new p.Parser({lexer:new p.Lexer(e,EvaluatorPreprocessor.opMap),xref:t});this.stateManager=r;this.nonProcessedArgs=[];this._isPathOp=!1;this._numInvalidPathOPS=0}get savedStatesDepth(){return this.stateManager.stateStack.length}read(e){let t=e.args;for(;;){const r=this.parser.getObj();if(r instanceof i.Cmd){const n=r.cmd,i=EvaluatorPreprocessor.opMap[n];if(!i){(0,a.warn)(`Unknown command "${n}".`);continue}const s=i.id,o=i.numArgs;let c=null!==t?t.length:0;this._isPathOp||(this._numInvalidPathOPS=0);this._isPathOp=s>=a.OPS.moveTo&&s<=a.OPS.endPath;if(i.variableArgs)c>o&&(0,a.info)(`Command ${n}: expected [0, ${o}] args, but received ${c} args.`);else{if(c!==o){const e=this.nonProcessedArgs;for(;c>o;){e.push(t.shift());c--}for(;c<o&&0!==e.length;){null===t&&(t=[]);t.unshift(e.pop());c++}}if(c<o){const e=`command ${n}: expected ${o} args, but received ${c} args.`;if(this._isPathOp&&++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(s,t);e.fn=s;e.args=t;return!0}if(r===i.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)}}}t.EvaluatorPreprocessor=EvaluatorPreprocessor},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.IdentityCMap=t.CMapFactory=t.CMap=void 0;var a=r(2),n=r(130),i=r(132),s=r(142),o=r(131),c=r(135);const l=["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"],h=2**24-1;class CMap{constructor(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];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>h)throw new Error("mapCidRange - ignoring data above MAX_MAP_RANGE.");for(;e<=t;)this._map[e++]=r++}mapBfRange(e,t,r){if(t-e>h)throw new Error("mapBfRange - ignoring data above MAX_MAP_RANGE.");const a=r.length-1;for(;e<=t;){this._map[e++]=r;const t=r.charCodeAt(a)+1;t>255?r=r.substring(0,a-1)+String.fromCharCode(r.charCodeAt(a-1)+1)+"\0":r=r.substring(0,a)+String.fromCharCode(t)}}mapBfRangeToArray(e,t,r){if(t-e>h)throw new Error("mapBfRangeToArray - ignoring data above MAX_MAP_RANGE.");const a=r.length;let n=0;for(;e<=t&&n<a;){this._map[e]=r[n++];++e}}mapOne(e,t){this._map[e]=t}lookup(e){return this._map[e]}contains(e){return void 0!==this._map[e]}forEach(e){const t=this._map,r=t.length;if(r<=65536)for(let a=0;a<r;a++)void 0!==t[a]&&e(a,t[a]);else for(const r in t)e(r,t[r])}charCodeOf(e){const t=this._map;if(t.length<=65536)return t.indexOf(e);for(const r in t)if(t[r]===e)return 0|r;return-1}getMap(){return this._map}readCharCode(e,t,r){let a=0;const n=this.codespaceRanges;for(let i=0,s=n.length;i<s;i++){a=(a<<8|e.charCodeAt(t+i))>>>0;const s=n[i];for(let e=0,t=s.length;e<t;){const t=s[e++],n=s[e++];if(a>=t&&a<=n){r.charcode=a;r.length=i+1;return}}}r.charcode=0;r.length=1}getCharCodeLength(e){const t=this.codespaceRanges;for(let r=0,a=t.length;r<a;r++){const a=t[r];for(let t=0,n=a.length;t<n;){const n=a[t++],i=a[t++];if(e>=n&&e<=i)return r+1}}return 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;const u=function BinaryCMapReaderClosure(){function hexToInt(e,t){let r=0;for(let 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){let a=0;for(let n=r;n>=0;n--){a+=e[n]+t[n];e[n]=255&a;a>>=8}}function incHex(e,t){let r=1;for(let a=t;a>=0&&r>0;a--){r+=e[a];e[a]=255&r;r>>=8}}const e=16;class BinaryCMapStream{constructor(e){this.buffer=e;this.pos=0;this.end=e.length;this.tmpBuf=new Uint8Array(19)}readByte(){return this.pos>=this.end?-1:this.buffer[this.pos++]}readNumber(){let e,t=0;do{const 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(){const 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){let r;const n=this.tmpBuf;let i=0;do{const e=this.readByte();if(e<0)throw new a.FormatError("unexpected EOF in bcmap");r=!(128&e);n[i++]=127&e}while(!r);let s=t,o=0,c=0;for(;s>=0;){for(;c<8&&n.length>0;){o|=n[--i]<<c;c+=7}e[s]=255&o;s--;o>>=8;c-=8}}readHexSigned(e,t){this.readHexNumber(e,t);const r=1&e[t]?255:0;let a=0;for(let n=0;n<=t;n++){a=(1&a)<<8|e[n];e[n]=a>>1^r}}readString(){const e=this.readNumber();let t="";for(let r=0;r<e;r++)t+=String.fromCharCode(this.readNumber());return t}}return class BinaryCMapReader{async process(t,r,a){const n=new BinaryCMapStream(t),i=n.readByte();r.vertical=!!(1&i);let s=null;const o=new Uint8Array(e),c=new Uint8Array(e),l=new Uint8Array(e),h=new Uint8Array(e),u=new Uint8Array(e);let d,f;for(;(f=n.readByte())>=0;){const t=f>>5;if(7===t){switch(31&f){case 0:n.readString();break;case 1:s=n.readString()}continue}const a=!!(16&f),i=15&f;if(i+1>e)throw new Error("BinaryCMapReader.process: Invalid dataSize.");const g=1,p=n.readNumber();switch(t){case 0:n.readHex(o,i);n.readHexNumber(c,i);addHex(c,o,i);r.addCodespaceRange(i+1,hexToInt(o,i),hexToInt(c,i));for(let e=1;e<p;e++){incHex(c,i);n.readHexNumber(o,i);addHex(o,c,i);n.readHexNumber(c,i);addHex(c,o,i);r.addCodespaceRange(i+1,hexToInt(o,i),hexToInt(c,i))}break;case 1:n.readHex(o,i);n.readHexNumber(c,i);addHex(c,o,i);n.readNumber();for(let e=1;e<p;e++){incHex(c,i);n.readHexNumber(o,i);addHex(o,c,i);n.readHexNumber(c,i);addHex(c,o,i);n.readNumber()}break;case 2:n.readHex(l,i);d=n.readNumber();r.mapOne(hexToInt(l,i),d);for(let e=1;e<p;e++){incHex(l,i);if(!a){n.readHexNumber(u,i);addHex(l,u,i)}d=n.readSigned()+(d+1);r.mapOne(hexToInt(l,i),d)}break;case 3:n.readHex(o,i);n.readHexNumber(c,i);addHex(c,o,i);d=n.readNumber();r.mapCidRange(hexToInt(o,i),hexToInt(c,i),d);for(let e=1;e<p;e++){incHex(c,i);if(a)o.set(c);else{n.readHexNumber(o,i);addHex(o,c,i)}n.readHexNumber(c,i);addHex(c,o,i);d=n.readNumber();r.mapCidRange(hexToInt(o,i),hexToInt(c,i),d)}break;case 4:n.readHex(l,g);n.readHex(h,i);r.mapOne(hexToInt(l,g),hexToStr(h,i));for(let e=1;e<p;e++){incHex(l,g);if(!a){n.readHexNumber(u,g);addHex(l,u,g)}incHex(h,i);n.readHexSigned(u,i);addHex(h,u,i);r.mapOne(hexToInt(l,g),hexToStr(h,i))}break;case 5:n.readHex(o,g);n.readHexNumber(c,g);addHex(c,o,g);n.readHex(h,i);r.mapBfRange(hexToInt(o,g),hexToInt(c,g),hexToStr(h,i));for(let e=1;e<p;e++){incHex(c,g);if(a)o.set(c);else{n.readHexNumber(o,g);addHex(o,c,g)}n.readHexNumber(c,g);addHex(c,o,g);n.readHex(h,i);r.mapBfRange(hexToInt(o,g),hexToInt(c,g),hexToStr(h,i))}break;default:throw new Error(`BinaryCMapReader.process - unknown type: ${t}`)}}return s?a(s):r}}}(),d=function CMapFactoryClosure(){function strToInt(e){let t=0;for(let r=0;r<e.length;r++)t=t<<8|e.charCodeAt(r);return t>>>0}function expectString(e){if("string"!=typeof 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(;;){let r=t.getObj();if(r===n.EOF)break;if((0,n.isCmd)(r,"endbfchar"))return;expectString(r);const a=strToInt(r);r=t.getObj();expectString(r);const i=r;e.mapOne(a,i)}}function parseBfRange(e,t){for(;;){let r=t.getObj();if(r===n.EOF)break;if((0,n.isCmd)(r,"endbfrange"))return;expectString(r);const a=strToInt(r);r=t.getObj();expectString(r);const i=strToInt(r);r=t.getObj();if(Number.isInteger(r)||"string"==typeof r){const t=Number.isInteger(r)?String.fromCharCode(r):r;e.mapBfRange(a,i,t)}else{if(!(0,n.isCmd)(r,"["))break;{r=t.getObj();const s=[];for(;!(0,n.isCmd)(r,"]")&&r!==n.EOF;){s.push(r);r=t.getObj()}e.mapBfRangeToArray(a,i,s)}}}throw new a.FormatError("Invalid bf range.")}function parseCidChar(e,t){for(;;){let r=t.getObj();if(r===n.EOF)break;if((0,n.isCmd)(r,"endcidchar"))return;expectString(r);const a=strToInt(r);r=t.getObj();expectInt(r);const i=r;e.mapOne(a,i)}}function parseCidRange(e,t){for(;;){let r=t.getObj();if(r===n.EOF)break;if((0,n.isCmd)(r,"endcidrange"))return;expectString(r);const a=strToInt(r);r=t.getObj();expectString(r);const i=strToInt(r);r=t.getObj();expectInt(r);const s=r;e.mapCidRange(a,i,s)}}function parseCodespaceRange(e,t){for(;;){let r=t.getObj();if(r===n.EOF)break;if((0,n.isCmd)(r,"endcodespacerange"))return;if("string"!=typeof r)break;const a=strToInt(r);r=t.getObj();if("string"!=typeof r)break;const i=strToInt(r);e.addCodespaceRange(r.length,a,i)}throw new a.FormatError("Invalid codespace range.")}function parseWMode(e,t){const r=t.getObj();Number.isInteger(r)&&(e.vertical=!!r)}function parseCMapName(e,t){const r=t.getObj();r instanceof n.Name&&(e.name=r.name)}async function parseCMap(e,t,r,i){let s,c;e:for(;;)try{const r=t.getObj();if(r===n.EOF)break;if(r instanceof n.Name){"WMode"===r.name?parseWMode(e,t):"CMapName"===r.name&&parseCMapName(e,t);s=r}else if(r instanceof n.Cmd)switch(r.cmd){case"endcmap":break e;case"usecmap":s instanceof n.Name&&(c=s.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 o.MissingDataException)throw e;(0,a.warn)("Invalid cMap data: "+e);continue}!i&&c&&(i=c);return i?extendCMap(e,r,i):e}async function extendCMap(e,t,r){e.useCMap=await createBuiltInCMap(r,t);if(0===e.numCodespaceRanges){const t=e.useCMap.codespaceRanges;for(let r=0;r<t.length;r++)e.codespaceRanges[r]=t[r].slice();e.numCodespaceRanges=e.useCMap.numCodespaceRanges}e.useCMap.forEach((function(t,r){e.contains(t)||e.mapOne(t,e.useCMap.lookup(t))}));return e}async function createBuiltInCMap(e,t){if("Identity-H"===e)return new IdentityCMap(!1,2);if("Identity-V"===e)return new IdentityCMap(!0,2);if(!l.includes(e))throw new Error("Unknown CMap name: "+e);if(!t)throw new Error("Built-in CMap parameters are not provided.");const{cMapData:r,compressionType:n}=await t(e),i=new CMap(!0);if(n===a.CMapCompressionType.BINARY)return(new u).process(r,i,(e=>extendCMap(i,t,e)));if(n===a.CMapCompressionType.NONE){const e=new s.Lexer(new c.Stream(r));return parseCMap(i,e,t,null)}throw new Error("TODO: Only BINARY/NONE CMap compression is currently supported.")}return{async create(e){const t=e.encoding,r=e.fetchBuiltInCMap,a=e.useCMap;if(t instanceof n.Name)return createBuiltInCMap(t.name,r);if(t instanceof i.BaseStream){const e=await parseCMap(new CMap,new s.Lexer(t),r,a);return e.isIdentityCMap?createBuiltInCMap(e.name,r):e}throw new Error("Encoding required.")}}}();t.CMapFactory=d},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Parser=t.Linearization=t.Lexer=void 0;var a=r(2),n=r(130),i=r(131),s=r(143),o=r(145),c=r(146),l=r(148),h=r(149),u=r(152),d=r(154),f=r(156),g=r(135),p=r(157),m=r(158);function computeAdler32(e){const t=e.length;let r=1,a=0;for(let n=0;n<t;++n){r+=255&e[n];a+=r}return a%65521<<16|r%65521}class Parser{constructor(e){let{lexer:t,xref:r,allowStreams:a=!1,recoveryMode:n=!1}=e;this.lexer=t;this.xref=r;this.allowStreams=a;this.recoveryMode=n;this.imageCache=Object.create(null);this.refill()}refill(){this.buf1=this.lexer.getObj();this.buf2=this.lexer.getObj()}shift(){if(this.buf2 instanceof n.Cmd&&"ID"===this.buf2.cmd){this.buf1=this.buf2;this.buf2=null}else{this.buf1=this.buf2;this.buf2=this.lexer.getObj()}}tryShift(){try{this.shift();return!0}catch(e){if(e instanceof i.MissingDataException)throw e;return!1}}getObj(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;const t=this.buf1;this.shift();if(t instanceof n.Cmd)switch(t.cmd){case"BI":return this.makeInlineImage(e);case"[":const r=[];for(;!(0,n.isCmd)(this.buf1,"]")&&this.buf1!==n.EOF;)r.push(this.getObj(e));if(this.buf1===n.EOF){if(this.recoveryMode)return r;throw new i.ParserEOFException("End of file inside array.")}this.shift();return r;case"<<":const s=new n.Dict(this.xref);for(;!(0,n.isCmd)(this.buf1,">>")&&this.buf1!==n.EOF;){if(!(this.buf1 instanceof n.Name)){(0,a.info)("Malformed dictionary: key must be a name object");this.shift();continue}const t=this.buf1.name;this.shift();if(this.buf1===n.EOF)break;s.set(t,this.getObj(e))}if(this.buf1===n.EOF){if(this.recoveryMode)return s;throw new i.ParserEOFException("End of file inside dictionary.")}if((0,n.isCmd)(this.buf2,"stream"))return this.allowStreams?this.makeStream(s,e):s;this.shift();return s;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 s,o,c=0;for(;-1!==(s=e.getByte());)if(0===c)c=69===s?1:0;else if(1===c)c=73===s?2:0;else{(0,a.assert)(2===c,"findDefaultInlineStreamEnd - invalid state.");if(32===s||10===s||13===s){o=e.pos;const r=e.peekBytes(10);for(let e=0,t=r.length;e<t;e++){s=r[e];if((0!==s||0===r[e+1])&&(10!==s&&13!==s&&(s<32||s>127))){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,a.warn)("findDefaultInlineStreamEnd - `lexer.knownCommands` is undefined.");if(2===c)break}else c=0}if(-1===s){(0,a.warn)("findDefaultInlineStreamEnd: Reached the end of the stream without finding a valid EI marker");if(o){(0,a.warn)('... trying to recover by using the last "EI" occurrence.');e.skip(-(e.pos-o))}}let l=4;e.skip(-l);s=e.peekByte();e.skip(l);(0,i.isWhiteSpace)(s)||l--;return e.pos-l-r}findDCTDecodeInlineStreamEnd(e){const t=e.pos;let r,n,i=!1;for(;-1!==(r=e.getByte());)if(255===r){switch(e.getByte()){case 0:break;case 255:e.skip(-1);break;case 217:i=!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:n=e.getUint16();n>2?e.skip(n-2):e.skip(-2)}if(i)break}const s=e.pos-t;if(-1===r){(0,a.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,i.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 n=e.pos-t;if(-1===r){(0,a.warn)("Inline ASCII85Decode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-n);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return n}findASCIIHexDecodeInlineStreamEnd(e){const t=e.pos;let r;for(;-1!==(r=e.getByte())&&62!==r;);const n=e.pos-t;if(-1===r){(0,a.warn)("Inline ASCIIHexDecode image stream: EOD marker not found, searching for /EI/ instead.");e.skip(-n);return this.findDefaultInlineStreamEnd(e)}this.inlineStreamSkipEI(e);return n}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,i=new n.Dict(this.xref);let s;for(;!(0,n.isCmd)(this.buf1,"ID")&&this.buf1!==n.EOF;){if(!(this.buf1 instanceof n.Name))throw new a.FormatError("Dictionary key must be a name object");const t=this.buf1.name;this.shift();if(this.buf1===n.EOF)break;i.set(t,this.getObj(e))}-1!==t.beginInlineImagePos&&(s=r.pos-t.beginInlineImagePos);const o=i.get("F","Filter");let c;if(o instanceof n.Name)c=o.name;else if(Array.isArray(o)){const e=this.xref.fetchIfRef(o[0]);e instanceof n.Name&&(c=e.name)}const l=r.pos;let h;switch(c){case"DCT":case"DCTDecode":h=this.findDCTDecodeInlineStreamEnd(r);break;case"A85":case"ASCII85Decode":h=this.findASCII85DecodeInlineStreamEnd(r);break;case"AHx":case"ASCIIHexDecode":h=this.findASCIIHexDecodeInlineStreamEnd(r);break;default:h=this.findDefaultInlineStreamEnd(r)}let u,d=r.makeSubStream(l,h,i);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,i,h);d.dict=i;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<r.end;){const n=r.peekBytes(2048),i=n.length-a;if(i<=0)break;let s=0;for(;s<i;){let i=0;for(;i<a&&n[s+i]===t[i];)i++;if(i>=a){r.pos+=s;return r.pos-e}s++}r.pos+=i}return-1}makeStream(e,t){const r=this.lexer;let s=r.stream;r.skipToNextLine();const o=s.pos-1;let c=e.get("Length");if(!Number.isInteger(c)){(0,a.info)(`Bad length "${c&&c.toString()}" in stream.`);c=0}s.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=s.peekBytes(r+1)[r];if(!(0,i.isWhiteSpace)(e))break;(0,a.info)(`Found "${(0,a.bytesToString)(c)}" when searching for endstream command.`);t=l;break}}if(t<0)throw new a.FormatError("Missing endstream command.")}c=t;r.nextChar();this.shift();this.shift()}this.shift();s=s.makeSubStream(o,c,e);t&&(s=t.createStream(s,c));s=this.filter(s,e,c);s.dict=e;return s}filter(e,t,r){let i=t.get("F","Filter"),s=t.get("DP","DecodeParms");if(i instanceof n.Name){Array.isArray(s)&&(0,a.warn)("/DecodeParms should not be an Array, when /Filter is a Name.");return this.makeFilter(e,i.name,r,s)}let o=r;if(Array.isArray(i)){const t=i,r=s;for(let c=0,l=t.length;c<l;++c){i=this.xref.fetchIfRef(t[c]);if(!(i instanceof n.Name))throw new a.FormatError(`Bad filter name "${i}"`);s=null;Array.isArray(r)&&c in r&&(s=this.xref.fetchIfRef(r[c]));e=this.makeFilter(e,i.name,o,s);o=null}}return e}makeFilter(e,t,r,n){if(0===r){(0,a.warn)(`Empty "${t}" stream.`);return new g.NullStream}const b=this.xref.stats;try{switch(t){case"Fl":case"FlateDecode":b.addStreamType(a.StreamType.FLATE);return n?new p.PredictorStream(new l.FlateStream(e,r),r,n):new l.FlateStream(e,r);case"LZW":case"LZWDecode":b.addStreamType(a.StreamType.LZW);let t=1;if(n){n.has("EarlyChange")&&(t=n.get("EarlyChange"));return new p.PredictorStream(new f.LZWStream(e,r,t),r,n)}return new f.LZWStream(e,r,t);case"DCT":case"DCTDecode":b.addStreamType(a.StreamType.DCT);return new u.JpegStream(e,r,n);case"JPX":case"JPXDecode":b.addStreamType(a.StreamType.JPX);return new d.JpxStream(e,r,n);case"A85":case"ASCII85Decode":b.addStreamType(a.StreamType.A85);return new s.Ascii85Stream(e,r);case"AHx":case"ASCIIHexDecode":b.addStreamType(a.StreamType.AHX);return new o.AsciiHexStream(e,r);case"CCF":case"CCITTFaxDecode":b.addStreamType(a.StreamType.CCF);return new c.CCITTFaxStream(e,r,n);case"RL":case"RunLengthDecode":b.addStreamType(a.StreamType.RLX);return new m.RunLengthStream(e,r);case"JBIG2Decode":b.addStreamType(a.StreamType.JBIG);return new h.Jbig2Stream(e,r,n)}(0,a.warn)(`Filter "${t}" is not supported.`);return e}catch(e){if(e instanceof i.MissingDataException)throw e;(0,a.warn)(`Invalid stream: "${e}"`);return new g.NullStream}}}t.Parser=Parser;const b=[1,0,0,0,0,0,0,0,0,1,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,2,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];function toHexDigit(e){return e>=48&&e<=57?15&e:e>=65&&e<=70||e>=97&&e<=102?9+(15&e):-1}class Lexer{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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,n=0;if(45===e){n=-1;e=this.nextChar();45===e&&(e=this.nextChar())}else if(43===e){n=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((0,i.isWhiteSpace)(e)||-1===e){if(10===r&&0===n){(0,a.warn)("Lexer.getNumber - treating a single decimal point as zero.");return 0}if(0===r&&-1===n){(0,a.warn)("Lexer.getNumber - treating a single minus sign as zero.");return 0}}throw new a.FormatError(`Invalid number: ${String.fromCharCode(e)} (charCode ${e})`)}n=n||1;let s=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);s=10*s+a}}else if(46===e){if(0!==r)break;r=1}else if(45===e)(0,a.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&&(s/=r);t&&(s*=10**(c*o));return n*s}getString(){let e=1,t=!1;const r=this.strBuf;r.length=0;let n=this.nextChar();for(;;){let i=!1;switch(0|n){case-1:(0,a.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:n=this.nextChar();switch(n){case-1:(0,a.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(n));break;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:let e=15&n;n=this.nextChar();i=!0;if(n>=48&&n<=55){e=(e<<3)+(15&n);n=this.nextChar();if(n>=48&&n<=55){i=!1;e=(e<<3)+(15&n)}}r.push(String.fromCharCode(e));break;case 13:10===this.peekChar()&&this.nextChar();break;case 10:break;default:r.push(String.fromCharCode(n))}break;default:r.push(String.fromCharCode(n))}if(t)break;i||(n=this.nextChar())}return r.join("")}getName(){let e,t;const r=this.strBuf;r.length=0;for(;(e=this.nextChar())>=0&&!b[e];)if(35===e){e=this.nextChar();if(b[e]){(0,a.warn)("Lexer_getName: NUMBER SIGN (#) should be followed by a hexadecimal number.");r.push("#");break}const n=toHexDigit(e);if(-1!==n){t=e;e=this.nextChar();const i=toHexDigit(e);if(-1===i){(0,a.warn)(`Lexer_getName: Illegal digit (${String.fromCharCode(e)}) in hexadecimal number.`);r.push("#",String.fromCharCode(t));if(b[e])break;r.push(String.fromCharCode(e));continue}r.push(String.fromCharCode(n<<4|i))}else r.push("#",String.fromCharCode(e))}else r.push(String.fromCharCode(e));r.length>127&&(0,a.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,a.warn)(`getHexString - ignoring invalid character: ${e}`):(0,a.warn)("getHexString - ignoring additional invalid characters.")}getHexString(){const e=this.strBuf;e.length=0;let t,r,n=this.currentChar,i=!0;this._hexStringNumWarn=0;for(;;){if(n<0){(0,a.warn)("Unterminated hex string");break}if(62===n){this.nextChar();break}if(1!==b[n]){if(i){t=toHexDigit(n);if(-1===t){this._hexStringWarn(n);n=this.nextChar();continue}}else{r=toHexDigit(n);if(-1===r){this._hexStringWarn(n);n=this.nextChar();continue}e.push(String.fromCharCode(t<<4|r))}i=!i;n=this.nextChar()}else n=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!==b[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 a.FormatError(`Illegal character: ${t}`)}let r=String.fromCharCode(t);if(t<32||t>127){const e=this.peekChar();if(e>=32&&e<=127){this.nextChar();return n.Cmd.get(r)}}const i=this.knownCommands;let s=i&&void 0!==i[r];for(;(t=this.nextChar())>=0&&!b[t];){const e=r+String.fromCharCode(t);if(s&&void 0===i[e])break;if(128===r.length)throw new a.FormatError(`Command token too long: ${r.length}`);r=e;s=i&&void 0!==i[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 n;try{n=this.getObj()}catch(e){if(e instanceof i.MissingDataException)throw e;(0,a.warn)(`peekObj: ${e}`)}this.stream.pos=e;this.currentChar=t;this.beginInlineImagePos=r;return n}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){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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(),i=t.getObj(),s=t.getObj();let o,c;if(!(Number.isInteger(r)&&Number.isInteger(a)&&(0,n.isCmd)(i,"obj")&&s instanceof n.Dict&&"number"==typeof(o=s.get("Linearized"))&&o>0))return null;if((c=getInt(s,"L"))!==e.length)throw new Error('The "L" parameter in the linearization dictionary does not equal the stream length.');return{length:c,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;e<r;e++){const r=t[e];if(!(Number.isInteger(r)&&r>0))throw new Error(`Hint (${e}) in the linearization dictionary is invalid.`)}return t}throw new Error("Hint array in the linearization dictionary is invalid.")}(s),objectNumberFirst:getInt(s,"O"),endFirst:getInt(s,"E"),numPages:getInt(s,"N"),mainXRefEntriesOffset:getInt(s,"T"),pageFirst:s.has("P")?getInt(s,"P",!0):0}}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.Ascii85Stream=void 0;var a=r(144),n=r(131);class Ascii85Stream extends a.DecodeStream{constructor(e,t){t&&(t*=.8);super(t);this.str=e;this.dict=e.dict;this.input=new Uint8Array(5)}readBlock(){const e=this.str;let t=e.getByte();for(;(0,n.isWhiteSpace)(t);)t=e.getByte();if(-1===t||126===t){this.eof=!0;return}const r=this.bufferLength;let a,i;if(122===t){a=this.ensureBuffer(r+4);for(i=0;i<4;++i)a[r+i]=0;this.bufferLength+=4}else{const s=this.input;s[0]=t;for(i=1;i<5;++i){t=e.getByte();for(;(0,n.isWhiteSpace)(t);)t=e.getByte();s[i]=t;if(-1===t||126===t)break}a=this.ensureBuffer(r+i-1);this.bufferLength+=i-1;if(i<5){for(;i<5;++i)s[i]=117;this.eof=!0}let o=0;for(i=0;i<5;++i)o=85*o+(s[i]-33);for(i=3;i>=0;--i){a[r+i]=255&o;o>>=8}}}}t.Ascii85Stream=Ascii85Stream},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.StreamsSequenceStream=t.DecodeStream=void 0;var a=r(132),n=r(135);const i=new Uint8Array(0);class DecodeStream extends a.BaseStream{constructor(e){super();this._rawMinBufferLength=e||0;this.pos=0;this.bufferLength=0;this.eof=!1;this.buffer=i;this.minBufferLength=512;if(e)for(;this.minBufferLength<e;)this.minBufferLength*=2}get isEmpty(){for(;!this.eof&&0===this.bufferLength;)this.readBlock();return 0===this.bufferLength}ensureBuffer(e){const t=this.buffer;if(e<=t.byteLength)return t;let r=this.minBufferLength;for(;r<e;)r*=2;const a=new Uint8Array(r);a.set(t);return this.buffer=a}getByte(){const e=this.pos;for(;this.bufferLength<=e;){if(this.eof)return-1;this.readBlock()}return this.buffer[this.pos++]}getBytes(e){const t=this.pos;let r;if(e){this.ensureBuffer(t+e);r=t+e;for(;!this.eof&&this.bufferLength<r;)this.readBlock();const a=this.bufferLength;r>a&&(r=a)}else{for(;!this.eof;)this.readBlock();r=this.bufferLength}this.pos=r;return this.buffer.subarray(t,r)}reset(){this.pos=0}makeSubStream(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(void 0===t)for(;!this.eof;)this.readBlock();else{const r=e+t;for(;this.bufferLength<=r&&!this.eof;)this.readBlock()}return new n.Stream(this.buffer,e,t,r)}getBaseStreams(){return this.str?this.str.getBaseStreams():null}}t.DecodeStream=DecodeStream;t.StreamsSequenceStream=class StreamsSequenceStream extends DecodeStream{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=0;for(const t of e)r+=t instanceof DecodeStream?t._rawMinBufferLength:t.length;super(r);this.streams=e;this._onError=t}readBlock(){const e=this.streams;if(0===e.length){this.eof=!0;return}const t=e.shift();let r;try{r=t.getBytes()}catch(e){if(this._onError){this._onError(e,t.dict&&t.dict.objId);return}throw e}const a=this.bufferLength,n=a+r.length;this.ensureBuffer(n).set(r,a);this.bufferLength=n}getBaseStreams(){const e=[];for(const t of this.streams){const r=t.getBaseStreams();r&&e.push(...r)}return e.length>0?e:null}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.AsciiHexStream=void 0;var a=r(144);class AsciiHexStream extends a.DecodeStream{constructor(e,t){t&&(t*=.5);super(t);this.str=e;this.dict=e.dict;this.firstDigit=-1}readBlock(){const e=this.str.getBytes(8e3);if(!e.length){this.eof=!0;return}const t=e.length+1>>1,r=this.ensureBuffer(this.bufferLength+t);let a=this.bufferLength,n=this.firstDigit;for(const t of e){let e;if(t>=48&&t<=57)e=15&t;else{if(!(t>=65&&t<=70||t>=97&&t<=102)){if(62===t){this.eof=!0;break}continue}e=9+(15&t)}if(n<0)n=e;else{r[a++]=n<<4|e;n=-1}}if(n>=0&&this.eof){r[a++]=n<<4;n=-1}this.firstDigit=n;this.bufferLength=a}}t.AsciiHexStream=AsciiHexStream},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxStream=void 0;var a=r(147),n=r(144),i=r(130);class CCITTFaxStream extends n.DecodeStream{constructor(e,t,r){super(t);this.str=e;this.dict=e.dict;r instanceof i.Dict||(r=i.Dict.empty);const n={next:()=>e.getByte()};this.ccittFaxDecoder=new a.CCITTFaxDecoder(n,{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")})}readBlock(){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}}}t.CCITTFaxStream=CCITTFaxStream},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.CCITTFaxDecoder=void 0;var a=r(2);const n=-1,i=[[-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]],s=[[-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]],o=[[-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]],c=[[-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]],l=[[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]],h=[[-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]];t.CCITTFaxDecoder=class CCITTFaxDecoder{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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)}}readNextChar(){if(this.eof)return-1;const e=this.refLine,t=this.codingLine,r=this.columns;let i,s,o,c,l;if(0===this.outputBits){this.rowsDone&&(this.eof=!0);if(this.eof)return-1;this.err=!1;let o,l,h;if(this.nextLine2D){for(c=0;t[c]<r;++c)e[c]=t[c];e[c++]=r;e[c]=r;t[0]=0;this.codingPos=0;i=0;s=0;for(;t[this.codingPos]<r;){o=this._getTwoDimCode();switch(o){case 0:this._addPixels(e[i+1],s);e[i+1]<r&&(i+=2);break;case 1:o=l=0;if(s){do{o+=h=this._getBlackCode()}while(h>=64);do{l+=h=this._getWhiteCode()}while(h>=64)}else{do{o+=h=this._getWhiteCode()}while(h>=64);do{l+=h=this._getBlackCode()}while(h>=64)}this._addPixels(t[this.codingPos]+o,s);t[this.codingPos]<r&&this._addPixels(t[this.codingPos]+l,1^s);for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2;break;case 7:this._addPixels(e[i]+3,s);s^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 5:this._addPixels(e[i]+2,s);s^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 3:this._addPixels(e[i]+1,s);s^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 2:this._addPixels(e[i],s);s^=1;if(t[this.codingPos]<r){++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 8:this._addPixelsNeg(e[i]-3,s);s^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 6:this._addPixelsNeg(e[i]-2,s);s^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case 4:this._addPixelsNeg(e[i]-1,s);s^=1;if(t[this.codingPos]<r){i>0?--i:++i;for(;e[i]<=t[this.codingPos]&&e[i]<r;)i+=2}break;case n:this._addPixels(r,0);this.eof=!0;break;default:(0,a.info)("bad 2d code");this._addPixels(r,0);this.err=!0}}}else{t[0]=0;this.codingPos=0;s=0;for(;t[this.codingPos]<r;){o=0;if(s)do{o+=h=this._getBlackCode()}while(h>=64);else do{o+=h=this._getWhiteCode()}while(h>=64);this._addPixels(t[this.codingPos]+o,s);s^=1}}let u=!1;this.byteAlign&&(this.inputBits&=-8);if(this.eoblock||this.row!==this.rows-1){o=this._lookBits(12);if(this.eoline)for(;o!==n&&1!==o;){this._eatBits(1);o=this._lookBits(12)}else for(;0===o;){this._eatBits(1);o=this._lookBits(12)}if(1===o){this._eatBits(12);u=!0}else o===n&&(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&&u&&this.byteAlign){o=this._lookBits(12);if(1===o){this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}if(this.encoding>=0)for(c=0;c<4;++c){o=this._lookBits(12);1!==o&&(0,a.info)("bad rtc code: "+o);this._eatBits(12);if(this.encoding>0){this._lookBits(1);this._eatBits(1)}}this.eof=!0}}else if(this.err&&this.eoline){for(;;){o=this._lookBits(13);if(o===n){this.eof=!0;return-1}if(o>>1==1)break;this._eatBits(1)}this._eatBits(12);if(this.encoding>0){this._eatBits(1);this.nextLine2D=!(1&o)}}t[0]>0?this.outputBits=t[this.codingPos=0]:this.outputBits=t[this.codingPos=1];this.row++}if(this.outputBits>=8){l=1&this.codingPos?0:255;this.outputBits-=8;if(0===this.outputBits&&t[this.codingPos]<r){this.codingPos++;this.outputBits=t[this.codingPos]-t[this.codingPos-1]}}else{o=8;l=0;do{if("number"!=typeof this.outputBits)throw new a.FormatError('Invalid /CCITTFaxDecode data, "outputBits" must be a number.');if(this.outputBits>o){l<<=o;1&this.codingPos||(l|=255>>8-o);this.outputBits-=o;o=0}else{l<<=this.outputBits;1&this.codingPos||(l|=255>>8-this.outputBits);o-=this.outputBits;this.outputBits=0;if(t[this.codingPos]<r){this.codingPos++;this.outputBits=t[this.codingPos]-t[this.codingPos-1]}else if(o>0){l<<=o;o=0}}}while(o)}this.black&&(l^=255);return l}_addPixels(e,t){const r=this.codingLine;let n=this.codingPos;if(e>r[n]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&n^t&&++n;r[n]=e}this.codingPos=n}_addPixelsNeg(e,t){const r=this.codingLine;let n=this.codingPos;if(e>r[n]){if(e>this.columns){(0,a.info)("row is wrong length");this.err=!0;e=this.columns}1&n^t&&++n;r[n]=e}else if(e<r[n]){if(e<0){(0,a.info)("invalid code");this.err=!0;e=0}for(;n>0&&e<r[n-1];)--n;r[n]=e}this.codingPos=n}_findTableCode(e,t,r,a){const i=a||0;for(let a=e;a<=t;++a){let e=this._lookBits(a);if(e===n)return[!0,1,!1];a<t&&(e<<=t-a);if(!i||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 e,t=0;if(this.eoblock){t=this._lookBits(7);e=i[t];if(e&&e[0]>0){this._eatBits(e[0]);return e[1]}}else{const e=this._findTableCode(1,7,i);if(e[0]&&e[2])return e[1]}(0,a.info)("Bad two dim code");return n}_getWhiteCode(){let e,t=0;if(this.eoblock){t=this._lookBits(12);if(t===n)return 1;e=t>>5==0?s[t]:o[t>>3];if(e[0]>0){this._eatBits(e[0]);return e[1]}}else{let e=this._findTableCode(1,9,o);if(e[0])return e[1];e=this._findTableCode(11,12,s);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(e===n)return 1;t=e>>7==0?c[e]:e>>9==0&&e>>7!=0?l[(e>>1)-64]:h[e>>7];if(t[0]>0){this._eatBits(t[0]);return t[1]}}else{let e=this._findTableCode(2,6,h);if(e[0])return e[1];e=this._findTableCode(7,12,l,64);if(e[0])return e[1];e=this._findTableCode(10,13,c);if(e[0])return e[1]}(0,a.info)("bad black code");this._eatBits(1);return 1}_lookBits(e){let t;for(;this.inputBits<e;){if(-1===(t=this.source.next()))return 0===this.inputBits?n:this.inputBuf<<e-this.inputBits&65535>>16-e;this.inputBuf=this.inputBuf<<8|t;this.inputBits+=8}return this.inputBuf>>this.inputBits-e&65535>>16-e}_eatBits(e){(this.inputBits-=e)<0&&(this.inputBits=0)}}},(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.FlateStream=void 0;var a=r(144),n=r(2);const i=new Int32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),s=new Int32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),o=new Int32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,
|