@recogito/recogito-react-pdf
Version:
A React component for annotating PDF, powered by PDF.js and RecogitoJS
2 lines • 853 kB
JavaScript
/*! For license information please see pdf.worker.js.LICENSE.txt */
(()=>{var e={806:function(e){var t;t=function(){return(()=>{"use strict";var e=[,(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WorkerTask=t.WorkerMessageHandler=void 0;var a,n=r(2),i=r(5),s=r(7),o=r(64),c=r(4),l=r(89),h=r(90),u=r(9);class d{constructor(e){this.name=e,this.terminated=!1,this._capability=(0,n.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=d;class f{static setup(e,t){let r=!1;e.on("test",(function(t){if(r)return;if(r=!0,!(t instanceof Uint8Array))return void e.send("test",null);const a=255===t[0];e.postMessageTransfers=a,e.send("test",{supportTransfers:a})})),e.on("configure",(function(e){(0,n.setVerbosityLevel)(e.verbosity)})),e.on("GetDocRequest",(function(e){return f.createDocumentHandler(e,t)}))}static createDocumentHandler(e,t){let r,a=!1,c=null;const f=[],g=(0,n.getVerbosityLevel)(),p=e.apiVersion;if("2.9.359"!==p)throw new Error(`The API version "${p}" does not match the Worker version "2.9.359".`);const m=[];for(const e in[])m.push(e);if(m.length)throw new Error("The `Array.prototype` contains unexpected enumerable properties: "+m.join(", ")+"; thus breaking e.g. `for...in` iteration of `Array`s.");if("undefined"==typeof ReadableStream)throw new Error("The browser/environment lacks native support for critical functionality used by the PDF.js library (e.g. `ReadableStream`); please use a `legacy`-build instead.");const b=e.docId,y=e.docBaseUrl,w=e.docId+"_worker";let S=new l.MessageHandler(w,b,t);function x(){if(a)throw new Error("Worker was terminated")}function k(e){f.push(e)}function A(e){e.finish();const t=f.indexOf(e);f.splice(t,1)}async function v(e){await r.ensureDoc("checkHeader"),await r.ensureDoc("parseStartXRef"),await r.ensureDoc("parse",[e]),e||await r.ensureDoc("checkFirstPage");const[t,a,n]=await Promise.all([r.ensureDoc("numPages"),r.ensureDoc("fingerprint"),r.ensureDoc("isPureXfa")]);if(n){const e=new d("loadXfaFonts");k(e),await r.loadXfaFonts(S,e).catch((e=>{})).then((()=>A(e)))}return{numPages:t,fingerprint:a,isPureXfa:n}}return S.postMessageTransfers=e.postMessageTransfers,S.on("GetPage",(function(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,t,r,a]){return{rotate:e,ref:t,userUnit:r,view:a}}))}))})),S.on("GetPageIndex",(function({ref:e}){const t=i.Ref.get(e.num,e.gen);return r.ensureCatalog("getPageIndex",[t])})),S.on("GetDestinations",(function(e){return r.ensureCatalog("destinations")})),S.on("GetDestination",(function(e){return r.ensureCatalog("getDestination",[e.id])})),S.on("GetPageLabels",(function(e){return r.ensureCatalog("pageLabels")})),S.on("GetPageLayout",(function(e){return r.ensureCatalog("pageLayout")})),S.on("GetPageMode",(function(e){return r.ensureCatalog("pageMode")})),S.on("GetViewerPreferences",(function(e){return r.ensureCatalog("viewerPreferences")})),S.on("GetOpenAction",(function(e){return r.ensureCatalog("openAction")})),S.on("GetAttachments",(function(e){return r.ensureCatalog("attachments")})),S.on("GetJavaScript",(function(e){return r.ensureCatalog("javaScript")})),S.on("GetDocJSActions",(function(e){return r.ensureCatalog("jsActions")})),S.on("GetPageJSActions",(function({pageIndex:e}){return r.getPage(e).then((function(e){return r.ensure(e,"jsActions")}))})),S.on("GetPageXfa",(function({pageIndex:e}){return r.getPage(e).then((function(e){return r.ensure(e,"xfaData")}))})),S.on("GetOutline",(function(e){return r.ensureCatalog("documentOutline")})),S.on("GetOptionalContentConfig",(function(e){return r.ensureCatalog("optionalContentConfig")})),S.on("GetPermissions",(function(e){return r.ensureCatalog("permissions")})),S.on("GetMetadata",(function(e){return Promise.all([r.ensureDoc("documentInfo"),r.ensureCatalog("metadata")])})),S.on("GetMarkInfo",(function(e){return r.ensureCatalog("markInfo")})),S.on("GetData",(function(e){return r.requestLoadedStream(),r.onLoadedStream().then((function(e){return e.bytes}))})),S.on("GetStats",(function(e){return r.ensureXRef("stats")})),S.on("GetAnnotations",(function({pageIndex:e,intent:t}){return r.getPage(e).then((function(e){return e.getAnnotationsData(t)}))})),S.on("GetFieldObjects",(function(e){return r.ensureDoc("fieldObjects")})),S.on("HasJSActions",(function(e){return r.ensureDoc("hasJSActions")})),S.on("GetCalculationOrderIds",(function(e){return r.ensureDoc("calculationOrderIds")})),S.on("SaveDocument",(function({numPages:e,annotationStorage:t,filename:a}){r.requestLoadedStream();const s=[r.onLoadedStream(),r.ensureCatalog("acroForm"),r.ensureDoc("xref"),r.ensureDoc("startXRef")];for(let a=0;a<e;a++)s.push(r.getPage(a).then((function(e){const r=new d(`Save: page ${a}`);return k(r),e.save(S,r,t).finally((function(){A(r)}))})));return Promise.all(s).then((function([e,t,r,s,...c]){let l=[];for(const e of c)l=e.filter((e=>null!==e)).reduce(((e,t)=>e.concat(t)),l);if(0===l.length)return e.bytes;const h=t instanceof i.Dict&&t.get("XFA")||[];let u=null;if(Array.isArray(h))for(let e=0,t=h.length;e<t;e+=2)"datasets"===h[e]&&(u=h[e+1]);else(0,n.warn)("Unsupported XFA type.");let d=Object.create(null);if(r.trailer){const e=Object.create(null),t=r.trailer.get("Info")||null;t instanceof i.Dict&&t.forEach(((t,r)=>{(0,n.isString)(t)&&(0,n.isString)(r)&&(e[t]=(0,n.stringToPDFString)(r))})),d={rootRef:r.trailer.getRaw("Root")||null,encryptRef:r.trailer.getRaw("Encrypt")||null,newRef:r.getNewRef(),infoRef:r.trailer.getRaw("Info")||null,info:e,fileIds:r.trailer.get("ID")||null,startXRef:s,filename:a}}return r.resetNewRef(),(0,o.incrementalUpdate)({originalData:e.bytes,xrefInfo:d,newRefs:l,xref:r,datasetsRef:u})}))})),S.on("GetOperatorList",(function(e,t){const a=e.pageIndex;r.getPage(a).then((function(r){const i=new d(`GetOperatorList: page ${a}`);k(i);const s=g>=n.VerbosityLevel.INFOS?Date.now():0;r.getOperatorList({handler:S,sink:t,task:i,intent:e.intent,renderInteractiveForms:e.renderInteractiveForms,annotationStorage:e.annotationStorage}).then((function(e){A(i),s&&(0,n.info)(`page=${a+1} - getOperatorList: time=${Date.now()-s}ms, len=${e.length}`),t.close()}),(function(e){A(i),i.terminated||(S.send("UnsupportedFeature",{featureId:n.UNSUPPORTED_FEATURES.errorOperatorList}),t.error(e))}))}))})),S.on("GetTextContent",(function(e,t){const a=e.pageIndex;t.onPull=function(e){},t.onCancel=function(e){},r.getPage(a).then((function(r){const i=new d("GetTextContent: page "+a);k(i);const s=g>=n.VerbosityLevel.INFOS?Date.now():0;r.extractTextContent({handler:S,task:i,sink:t,normalizeWhitespace:e.normalizeWhitespace,includeMarkedContent:e.includeMarkedContent,combineTextItems:e.combineTextItems}).then((function(){A(i),s&&(0,n.info)(`page=${a+1} - getTextContent: time=`+(Date.now()-s)+"ms"),t.close()}),(function(e){A(i),i.terminated||t.error(e)}))}))})),S.on("GetStructTree",(function(e){return r.getPage(e.pageIndex).then((function(e){return r.ensure(e,"getStructTree")}))})),S.on("FontFallback",(function(e){return r.fontFallback(e.id,S)})),S.on("Cleanup",(function(e){return r.cleanup(!0)})),S.on("Terminate",(function(e){a=!0;const t=[];if(r){r.terminate(new n.AbortException("Worker was terminated."));const e=r.cleanup();t.push(e),r=null}else(0,i.clearPrimitiveCaches)();c&&c(new n.AbortException("Worker was terminated."));for(const e of f)t.push(e.finished),e.terminate();return Promise.all(t).then((function(){S.destroy(),S=null}))})),S.on("Ready",(function(t){!function(e){function t(e){x(),S.send("GetDoc",{pdfInfo:e})}function i(e){if(x(),e instanceof n.PasswordException){const t=new d(`PasswordException: response ${e.code}`);k(t),S.sendWithPromise("PasswordRequest",e).then((function({password:e}){A(t),r.updatePassword(e),o()})).catch((function(){A(t),S.send("DocException",e)}))}else e instanceof n.InvalidPDFException||e instanceof n.MissingPDFException||e instanceof n.UnexpectedResponseException||e instanceof n.UnknownErrorException?S.send("DocException",e):S.send("DocException",new n.UnknownErrorException(e.message,e.toString()))}function o(){x(),v(!1).then(t,(function(e){x(),e instanceof u.XRefParseException?(r.requestLoadedStream(),r.onLoadedStream().then((function(){x(),v(!0).then(t,i)}))):i(e)}))}x(),function(e,t,r){const a=(0,n.createPromiseCapability)();let i;const o=e.source;if(o.data){try{i=new s.LocalPdfManager(b,o.data,o.password,t,r,y),a.resolve(i)}catch(e){a.reject(e)}return a.promise}let l,u=[];try{l=new h.PDFWorkerStream(S)}catch(e){return a.reject(e),a.promise}const d=l.getFullReader();d.headersReady.then((function(){if(!d.isRangeSupported)return;const e=o.disableAutoFetch||d.isStreamingSupported;i=new s.NetworkPdfManager(b,l,{msgHandler:S,password:o.password,length:d.contentLength,disableAutoFetch:e,rangeChunkSize:o.rangeChunkSize},t,r,y);for(let e=0;e<u.length;e++)i.sendProgressiveData(u[e]);u=[],a.resolve(i),c=null})).catch((function(e){a.reject(e),c=null}));let f=0;return new Promise((function(e,l){const h=function({value:e,done:g}){try{if(x(),g)return i||function(){const e=(0,n.arraysToBytes)(u);o.length&&e.length!==o.length&&(0,n.warn)("reported HTTP length is different from actual");try{i=new s.LocalPdfManager(b,e,o.password,t,r,y),a.resolve(i)}catch(e){a.reject(e)}u=[]}(),void(c=null);f+=(0,n.arrayByteLength)(e),d.isStreamingSupported||S.send("DocProgress",{loaded:f,total:Math.max(f,d.contentLength||0)}),i?i.sendProgressiveData(e):u.push(e),d.read().then(h,l)}catch(e){l(e)}};d.read().then(h,l)})).catch((function(e){a.reject(e),c=null})),c=function(e){l.cancelAllRequests(e)},a.promise}(e,{maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties},e.enableXfa).then((function(e){if(a)throw e.terminate(new n.AbortException("Worker was terminated.")),new Error("Worker was terminated");r=e,r.onLoadedStream().then((function(e){S.send("DataLoaded",{length:e.bytes.byteLength})}))})).then(o,i)}(e),e=null})),w}static initializeFromPort(e){const t=new l.MessageHandler("worker","main",e);f.setup(t,e),t.send("ready",null)}}t.WorkerMessageHandler=f,"undefined"==typeof window&&!c.isNodeJS&&"undefined"!=typeof self&&"function"==typeof(a=self).postMessage&&"onmessage"in a&&f.initializeFromPort(self)},(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.arrayByteLength=d,t.arraysToBytes=function(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let r=0;for(let a=0;a<t;a++)r+=d(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?u(t):new Uint8Array(t));const i=t.byteLength;n.set(t,a),a+=i}return n},t.assert=o,t.bytesToString=function(e){o(null!==e&&"object"==typeof e&&void 0!==e.length,"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.createObjectURL=function(e,t="",r=!1){if(URL.createObjectURL&&!r)return URL.createObjectURL(new Blob([e],{type:t}));const a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let n=`data:${t};base64,`;for(let t=0,r=e.length;t<r;t+=3){const i=255&e[t],s=255&e[t+1],o=255&e[t+2];n+=a[i>>2]+a[(3&i)<<4|s>>4]+a[t+1<r?(15&s)<<2|o>>6:64]+a[t+2<r?63&o:64]}return n},t.createPromiseCapability=function(){const e=Object.create(null);let t=!1;return 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)}})),e},t.createValidAbsoluteUrl=function(e,t){if(!e)return null;try{const r=t?new URL(e,t):new URL(e);if(function(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch(e){}return null},t.escapeString=function(e){return e.replace(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))},t.getModificationDate=function(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")},t.getVerbosityLevel=function(){return n},t.info=function(e){n>=a.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength},t.isArrayEqual=function(e,t){if(e.length!==t.length)return!1;for(let r=0,a=e.length;r<a;r++)if(e[r]!==t[r])return!1;return!0},t.isAscii=function(e){return/^[\x00-\x7F]*$/.test(e)},t.isBool=function(e){return"boolean"==typeof e},t.isNum=function(e){return"number"==typeof e},t.isSameOrigin=function(e,t){let r;try{if(r=new URL(e),!r.origin||"null"===r.origin)return!1}catch(e){return!1}const a=new URL(t,r);return r.origin===a.origin},t.isString=function(e){return"string"==typeof e},t.objectFromMap=function(e){const t=Object.create(null);for(const[r,a]of e)t[r]=a;return t},t.objectSize=function(e){return Object.keys(e).length},t.removeNullCharacters=function(e){return"string"!=typeof e?(i("The argument for removeNullCharacters must be a string."),e):e.replace(h,"")},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(n=e)},t.shadow=c,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=u,t.stringToPDFString=function(e){const t=e.length,r=[];if("þ"===e[0]&&"ÿ"===e[1])for(let a=2;a<t;a+=2)r.push(String.fromCharCode(e.charCodeAt(a)<<8|e.charCodeAt(a+1)));else if("ÿ"===e[0]&&"þ"===e[1])for(let a=2;a<t;a+=2)r.push(String.fromCharCode(e.charCodeAt(a+1)<<8|e.charCodeAt(a)));else for(let a=0;a<t;++a){const t=b[e.charCodeAt(a)];r.push(t?String.fromCharCode(t):e.charAt(a))}return r.join("")},t.stringToUTF16BEString=function(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=function(e){return decodeURIComponent(escape(e))},t.unreachable=s,t.utf8StringToString=function(e){return unescape(encodeURIComponent(e))},t.warn=i,t.VerbosityLevel=t.Util=t.UNSUPPORTED_FEATURES=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.StreamType=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.IsLittleEndianCached=t.IsEvalSupportedCached=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0,r(3),t.IDENTITY_MATRIX=[1,0,0,1,0,0],t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0],t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},t.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"},t.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"},t.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"},t.AnnotationReplyType={GROUP:"Group",REPLY:"R"},t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512},t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864},t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"},t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"},t.PageActionEventType={O:"PageOpen",C:"PageClose"},t.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"},t.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const 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"},t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let n=a.WARNINGS;function i(e){n>=a.WARNINGS&&console.log(`Warning: ${e}`)}function s(e){throw new Error(e)}function o(e,t){e||s(t)}function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!1}),r}const l=function(){function e(t){this.constructor===e&&s("Cannot initialize BaseException."),this.message=t,this.name=this.constructor.name}return e.prototype=new Error,e.constructor=e,e}();t.BaseException=l,t.PasswordException=class extends l{constructor(e,t){super(e),this.code=t}},t.UnknownErrorException=class extends l{constructor(e,t){super(e),this.details=t}},t.InvalidPDFException=class extends l{},t.MissingPDFException=class extends l{},t.UnexpectedResponseException=class extends l{constructor(e,t){super(e),this.status=t}},t.FormatError=class extends l{},t.AbortException=class extends l{};const h=/\x00/g;function u(e){o("string"==typeof e,"Invalid argument for stringToBytes");const t=e.length,r=new Uint8Array(t);for(let a=0;a<t;++a)r[a]=255&e.charCodeAt(a);return r}function d(e){return void 0!==e.length?e.length:(o(void 0!==e.byteLength,"arrayByteLength - invalid argument."),e.byteLength)}const f={get value(){return c(this,"value",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}};t.IsLittleEndianCached=f;const g={get value(){return c(this,"value",function(){try{return new Function(""),!0}catch(e){return!1}}())}};t.IsEvalSupportedCached=g;const p=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class m{static makeHexColor(e,t,r){return`#${p[e]}${p[t]}${p[r]}`}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=m.applyTransform(e,t),a=m.applyTransform(e.slice(2,4),t),n=m.applyTransform([e[0],e[3]],t),i=m.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);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){function r(e,t){return e-t}const a=[e[0],e[2],t[0],t[2]].sort(r),n=[e[1],e[3],t[1],t[3]].sort(r),i=[];return e=m.normalizeRect(e),t=m.normalizeRect(t),a[0]===e[0]&&a[1]===t[0]||a[0]===t[0]&&a[1]===e[0]?(i[0]=a[1],i[2]=a[2],n[0]===e[1]&&n[1]===t[1]||n[0]===t[1]&&n[1]===e[1]?(i[1]=n[1],i[3]=n[2],i):null):null}}t.Util=m;const b=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364]},(e,t,r)=>{r(4)},(e,t)=>{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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clearPrimitiveCaches=function(){o._clearCache(),s._clearCache(),h._clearCache()},t.isCmd=function(e,t){return e instanceof o&&(void 0===t||e.cmd===t)},t.isDict=function(e,t){return e instanceof l&&(void 0===t||u(e.get("Type"),t))},t.isEOF=function(e){return e===i},t.isName=u,t.isRef=function(e){return e instanceof h},t.isRefsEqual=function(e,t){return e.num===t.num&&e.gen===t.gen},t.isStream=function(e){return e instanceof n.BaseStream},t.RefSetCache=t.RefSet=t.Ref=t.Name=t.EOF=t.Dict=t.Cmd=void 0;var a=r(2),n=r(6);const i={};t.EOF=i;const s=function(){let e=Object.create(null);class t{constructor(e){this.name=e}static get(r){return e[r]||(e[r]=new t(r))}static _clearCache(){e=Object.create(null)}}return t}();t.Name=s;const o=function(){let e=Object.create(null);class t{constructor(e){this.cmd=e}static get(r){return e[r]||(e[r]=new t(r))}static _clearCache(){e=Object.create(null)}}return t}();t.Cmd=o;const c=function(){return c};class l{constructor(e=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];return void 0===a&&void 0!==t&&(a=this._map[t],void 0===a&&void 0!==r&&(a=this._map[r])),a instanceof h&&this.xref?this.xref.fetch(a,this.suppressEncryption):a}async getAsync(e,t,r){let a=this._map[e];return void 0===a&&void 0!==t&&(a=this._map[t],void 0===a&&void 0!==r&&(a=this._map[r])),a instanceof h&&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 h&&this.xref&&(a=this.xref.fetch(a,this.suppressEncryption)),Array.isArray(a)){a=a.slice();for(let e=0,t=a.length;e<t;e++)a[e]instanceof h&&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 l(null);return e.set=(e,t)=>{(0,a.unreachable)("Should not call `set` on the empty dictionary.")},(0,a.shadow)(this,"empty",e)}static merge({xref:e,dictArray:t,mergeSubDicts:r=!1}){const a=new l(e);if(!r){for(const e of t)if(e instanceof l)for(const[t,r]of Object.entries(e._map))void 0===a._map[t]&&(a._map[t]=r);return a.size>0?a:l.empty}const n=new Map;for(const e of t)if(e instanceof l)for(const[t,r]of Object.entries(e._map)){let e=n.get(t);void 0===e&&(e=[],n.set(t,e)),e.push(r)}for(const[t,r]of n){if(1===r.length||!(r[0]instanceof l)){a._map[t]=r[0];continue}const n=new l(e);for(const e of r)if(e instanceof l)for(const[t,r]of Object.entries(e._map))void 0===n._map[t]&&(n._map[t]=r);n.size>0&&(a._map[t]=n)}return n.clear(),a.size>0?a:l.empty}}t.Dict=l;const h=function(){let e=Object.create(null);class t{constructor(e,t){this.num=e,this.gen=t}toString(){return 0===this.gen?`${this.num}R`:`${this.num}R${this.gen}`}static get(r,a){const n=0===a?`${r}R`:`${r}R${a}`;return e[n]||(e[n]=new t(r,a))}static _clearCache(){e=Object.create(null)}}return t}();function u(e,t){return e instanceof s&&(void 0===t||e.name===t)}t.Ref=h,t.RefSet=class{constructor(e=null){this._set=new Set(e&&e._set)}has(e){return this._set.has(e.toString())}put(e){this._set.add(e.toString())}remove(e){this._set.delete(e.toString())}forEach(e){for(const t of this._set.values())e(t)}clear(){this._set.clear()}},t.RefSetCache=class{constructor(){this._map=new Map}get size(){return this._map.size}get(e){return this._map.get(e.toString())}has(e){return this._map.has(e.toString())}put(e,t){this._map.set(e.toString(),t)}putAlias(e,t){this._map.set(e.toString(),this.get(t))}forEach(e){for(const t of this._map.values())e(t)}clear(){this._map.clear()}}},(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BaseStream=void 0;var a=r(2);class n{constructor(){this.constructor===n&&(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,t=!1){(0,a.unreachable)("Abstract method `getBytes` called")}peekByte(){const e=this.getByte();return-1!==e&&this.pos--,e}peekBytes(e,t=!1){const r=this.getBytes(e,t);return this.pos-=r.length,r}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,!1))}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,r=null){(0,a.unreachable)("Abstract method `makeSubStream` called")}getBaseStreams(){return null}}t.BaseStream=n},(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NetworkPdfManager=t.LocalPdfManager=void 0;var a=r(2),n=r(8),i=r(9),s=r(11),o=r(10);function c(e){if(e){const t=(0,a.createValidAbsoluteUrl)(e);if(t)return t.href;(0,a.warn)(`Invalid absolute docBaseUrl: "${e}".`)}return null}class l{constructor(){this.constructor===l&&(0,a.unreachable)("Cannot initialize BasePdfManager.")}get docId(){return this._docId}get password(){return this._password}get docBaseUrl(){return 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)}cleanup(e=!1){return this.pdfDocument.cleanup(e)}async ensure(e,t,r){(0,a.unreachable)("Abstract method `ensure` called")}requestRange(e,t){(0,a.unreachable)("Abstract method `requestRange` called")}requestLoadedStream(){(0,a.unreachable)("Abstract method `requestLoadedStream` called")}sendProgressiveData(e){(0,a.unreachable)("Abstract method `sendProgressiveData` called")}updatePassword(e){this._password=e}terminate(e){(0,a.unreachable)("Abstract method `terminate` called")}}t.LocalPdfManager=class extends l{constructor(e,t,r,a,n,i){super(),this._docId=e,this._password=r,this._docBaseUrl=c(i),this.evaluatorOptions=a,this.enableXfa=n;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 extends l{constructor(e,t,r,a,i,o){super(),this._docId=e,this._password=r.password,this._docBaseUrl=c(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;return await this.requestRange(a.begin,a.end),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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ChunkedStreamManager=t.ChunkedStream=void 0;var a=r(2),n=r(9),i=r(10);class s 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.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=this.chunkSize,a=Math.floor(e/r),i=Math.floor((t-1)/r)+1;for(let r=a;r<i;++r)if(!this._loadedChunks.has(r))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;return e>=this.end?-1:(e>=this.progressiveDataLength&&this.ensureByte(e),this.bytes[this.pos++])}getBytes(e,t=!1){const r=this.bytes,a=this.pos,n=this.end;if(!e){n>this.progressiveDataLength&&this.ensureRange(a,n);const e=r.subarray(a,n);return t?new Uint8ClampedArray(e):e}let i=a+e;i>n&&(i=n),i>this.progressiveDataLength&&this.ensureRange(a,i),this.pos=i;const s=r.subarray(a,i);return t?new Uint8ClampedArray(s):s}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),t>this.progressiveDataLength&&this.ensureRange(e,t),this.bytes.subarray(e,t)}makeSubStream(e,t,r=null){function a(){}t?e+t>this.progressiveDataLength&&this.ensureRange(e,e+t):e>=this.progressiveDataLength&&this.ensureByte(e),a.prototype=Object.create(this),a.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(a.prototype,"isDataLoaded",{get(){return this.numChunksLoaded===this.numChunks||0===this.getMissingChunks().length},configurable:!0});const n=new a;return n.pos=n.start=e,n.end=e+t||this.end,n.dict=r,n}getBaseStreams(){return[this]}}t.ChunkedStream=s,t.ChunkedStreamManager=class{constructor(e,t){this.length=t.length,this.chunkSize=t.rangeChunkSize,this.stream=new s(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;new Promise(((e,t)=>{const s=o=>{try{if(!o.done){const e=o.value;return n.push(e),i+=(0,a.arrayByteLength)(e),r.isStreamingSupported&&this.onProgress({loaded:i}),void r.read().then(s,t)}const c=(0,a.arraysToBytes)(n);n=null,e(c)}catch(e){t(e)}};r.read().then(s,t)})).then((t=>{this.aborted||this.onReceiveData({chunk:t,begin:e})}))}requestAllChunks(){const e=this.stream.getMissingChunks();return this._requestChunks(e),this._loadedStreamCapability.promise}_requestChunks(e){const t=this.currRequestId++,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);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)}}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(e=[]){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)}return t.sort((function(e,t){return e-t})),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),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);r?(this.stream.onReceiveProgressiveData(t),this.progressiveDataLength=n):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)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.collectActions=function(e,t,r){const i=Object.create(null),s=c({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=[];h(a.getRaw(t),e,o,new n.RefSet),o.length>0&&(i[s]=o)}}if(t.has("A")){const r=[];h(t.get("A"),e,r,new n.RefSet),r.length>0&&(i.Action=r)}return(0,a.objectSize)(i)>0?i:null},t.encodeToXmlString=function(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=u[n];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}return 0===t.length?e:(r<e.length&&t.push(e.substring(r,e.length)),t.join(""))},t.escapePDFName=function(e){const t=[];let r=0;for(let a=0,n=e.length;a<n;a++){const n=e.charCodeAt(a);(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)}return 0===t.length?e:(r<e.length&&t.push(e.substring(r,e.length)),t.join(""))},t.getArrayLookupTableFactory=function(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=c,t.getLookupTableFactory=function(e){let t;return function(){return e&&(t=Object.create(null),e(t),e=null),t}},t.isWhiteSpace=function(e){return 32===e||9===e||13===e||10===e},t.log2=function(e){return e<=0?0:Math.ceil(Math.log2(e))},t.parseXFAPath=function(e){const t=/(.+)\[([0-9]+)\]$/;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(e,t){return e[t]<<24>>24},t.readUint16=function(e,t){return e[t]<<8|e[t+1]},t.readUint32=function(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0},t.toRomanNumerals=function(e,t=!1){(0,a.assert)(Number.isInteger(e)&&e>0,"The number should be a positive integer.");const r=[];let n;for(;e>=1e3;)e-=1e3,r.push("M");n=e/100|0,e%=100,r.push(l[n]),n=e/10|0,e%=10,r.push(l[10+n]),r.push(l[20+e]);const i=r.join("");return t?i.toLowerCase():i},t.validateCSSFont=function(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)))return(0,a.warn)(`XFA - FontFamily contains some unescaped ": ${r}.`),!1}else if(/^'.*'$/.test(r)){if(/[^\\]'/.test(r.slice(1,r.length-1)))return(0,a.warn)(`XFA - FontFamily contains some unescaped ': ${r}.`),!1}else for(const e of r.split(/[ \t]+/))if(/^([0-9]|(-([0-9]|-)))/.test(e)||!/^[a-zA-Z0-9\-_\\]+$/.test(e))return(0,a.warn)(`XFA - FontFamily contains some invalid <custom-ident>: ${r}.`),!1;const s=n?n.toString():"";e.fontWeight=t.has(s)?s:"400";const o=parseFloat(i);return e.italicAngle=isNaN(o)||o<-90||o>90?"14":i.toString(),!0},t.XRefParseException=t.XRefEntryException=t.MissingDataException=void 0;var a=r(2),n=r(5);class i extends a.BaseException{constructor(e,t){super(`Missing data [${e}, ${t})`),this.begin=e,this.end=t}}t.MissingDataException=i;class s extends a.BaseException{}t.XRefEntryException=s;class o extends a.BaseException{}function c({dict:e,key:t,getArray:r=!1,stopWhenFound:a=!0}){let i;const s=new n.RefSet;for(;e instanceof n.Dict&&(!e.objId||!s.has(e.objId));){e.objId&&s.put(e.objId);const n=r?e.getArray(t):e.get(t);if(void 0!==n){if(a)return n;i||(i=[]),i.push(n)}e=e.get("Parent")}return i}t.XRefParseException=o;const l=["","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 h(e,t,r,i){if(!e)return;let s=null;if((0,n.isRef)(e)){if(i.has(e))return;s=e,i.put(s),e=t.fetch(e)}if(Array.isArray(e))for(const a of e)h(a,t,r,i);else if(e instanceof n.Dict){if((0,n.isName)(e.get("S"),"JavaScript")&&e.has("JS")){const t=e.get("JS");let i;i=(0,n.isStream)(t)?t.getString():t,i=(0,a.stringToPDFString)(i),i&&r.push(i)}h(e.getRaw("Next"),t,r,i)}s&&i.remove(s)}const u={60:"<",62:">",38:"&",34:""",39:"'"}},(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StringStream=t.Stream=t.NullStream=void 0;var a=r(6),n=r(2);class i 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,t=!1){const r=this.bytes,a=this.pos,n=this.end;if(!e){const e=r.subarray(a,n);return t?new Uint8ClampedArray(e):e}let i=a+e;i>n&&(i=n),this.pos=i;const s=r.subarray(a,i);return t?new Uint8ClampedArray(s):s}getByteRange(e,t){return e<0&&(e=0),t>this.end&&(t=this.end),this.bytes.subarray(e,t)}reset(){this.pos=this.start}moveStart(){this.start=this.pos}makeSubStream(e,t,r=null){return new i(this.bytes.buffer,e,t,r)}}t.Stream=i,t.StringStream=class extends i{constructor(e){super((0,n.stringToBytes)(e))}},t.NullStream=class extends i{constructor(){super(new Uint8Array(0))}}},(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFDocument=t.Page=void 0;var a=r(2),n=r(5),i=r(9),s=r(10),o=r(12),c=r(6),l=r(65),h=r(57),u=r(17),d=r(63),f=r(55),g=r(15),p=r(19),m=r(62),b=r(67),y=r(88);const w=[0,0,612,792];class S{constructor({pdfManager:e,xref:t,pageIndex:r,pageDict:a,ref:n,globalIdFactory:i,fontCache:s,builtInCMapCache:o,globalImageCache:c,nonBlendModesSet:l,xfaFactory:h}){this.pdfManager=e,this.pageIndex=r,this.pageDict=a,this.xref=t,this.ref=n,this.fontCache=s,this.builtInCMapCache=o,this.globalImageCache=c,this.nonBlendModesSet=l,this.evaluatorOptions=e.evaluatorOptions,this.resourcesPromise=null,this.xfaFactory=h;const u={obj:0};this._localIdFactory=class extends i{static createObjId(){return`p${r}_${++u.obj}`}static getPageObjId(){return`page${n.toString()}`}}}_getInheritableProperty(e,t=!1){const r=(0,i.getInheritableProperty)({dict:this.pageDict,key:e,getArray:t,stopWhenFound:!1});return Array.isArray(r)?1!==r.length&&(0,n.isDict)(r[0])?n.Dict.merge({xref:this.xref,dictArray:r}):r[0]:r}get content(){return this.pageDict.getArray("Contents")}get resources(){return(0,a.shadow)(this,"resources",this._getInheritableProperty("Resources")||n.Dict.empty)}_getBoundingBox(e){if(this.xfaData){const{width:e,height:t}=this.xfaData.attributes.style;return[0,0,parseInt(e),parseInt(t)]}const t=this._getInheritableProperty(e,!0);if(Array.isArray(t)&&4===t.length){if(t[2]-t[0]!=0&&t[3]-t[1]!=0)return t;(0,a.warn)(`Empty /${e} entry.`)}return null}get mediaBox(){return(0,a.shadow)(this,"mediaBox",this._getBoundingBox("MediaBox")||w)}get cropBox(){return(0,a.shadow)(this,"cropBox",this._getBoundingBox("CropBox")||this.mediaBox)}get userUnit(){let e=this.pageDict.get("UserUnit");return(!(0,a.isNum)(e)||e<=0)&&(e=1),(0,a.shadow)(this,"userUnit",e)}get view(){const{cropBox:e,mediaBox:t}=this;let r;if(e===t||(0,a.isArrayEqual)(e,t))r=t;else{const n=a.Util.intersect(e,t);n&&n[2]-n[0]!=0&&n[3]-n[1]!=0?r=n:(0,a.warn)("Empty /CropBox and /MediaBox intersection.")}return(0,a.shadow)(this,"view",r||t)}get rotate(){let e=this._getInheritableProperty("Rotate")||0;return e%90!=0?e=0:e>=360?e%=360:e<0&&(e=(e%360+360)%360),(0,a.shadow)(this,"rotate",e)}getContentStream(){return this.pdfManager.ensure(this,"content").then((e=>e instanceof c.BaseStream?e:Array.isArray(e)?new p.StreamsSequenceStream(e):new s.NullStream))}get xfaData(){return this.xfaFactory?(0,a.shadow)(this,"xfaData",this.xfaFactory.getPage(this.pageIndex)):(0,a.shadow)(this,"xfaData",null)}save(e,t,r){const n=new g.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions});return this._parsedAnnotations.then((function(e){const i=[];for(const s of e)s.mustBePrinted(r)&&i.push(s.save(n,t,r).catch((function(e){return(0,a.warn)(`save - ignoring annotation data during "${t.name}" task: "${e}".`),null})));return Promise.all(i)}))}loadResources(e){return this.resourcesPromise||(this.resourcesPromise=this.pdfManager.ensure(this,"resources")),this.resourcesPromise.then((()=>new d.ObjectLoader(this.resources,e,this.xref).load()))}getOperatorList({handler:e,sink:t,task:r,intent:n,renderInteractiveForms:i,annotationStorage:s}){const o=this.getContentStream(),c=this.loadResources(["ColorSpace","ExtGState","Font","Pattern","Properties","Shading","XObject"]),l=new g.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}),h=Promise.all([o,c]).then((([a])=>{const i=new f.OperatorList(n,t);return e.send("StartRenderPage",{transparency:l.hasBlendModes(this.resources,this.nonBlendModesSet),pageIndex:this.pageIndex,intent:n}),l.getOperatorList({stream:a,task:r,resources:this.resources,operatorList:i}).then((function(){return i}))}));return Promise.all([h,this._parsedAnnotations]).then((function([e,t]){if(0===t.length)return e.flush(!0),{length:e.totalLength};const o=[];for(const e of t)("display"===n&&e.mustBeViewed(s)||"print"===n&&e.mustBePrinted(s))&&o.push(e.getOperatorList(l,r,i,s).catch((function(e){return(0,a.warn)(`getOperatorList - ignoring annotation data during "${r.name}" task: "${e}".`),null})));return Promise.all(o).then((function(t){e.addOp(a.OPS.beginAnnotations,[]);for(const r of t)e.addOpList(r);return e.addOp(a.OPS.endAnnotations,[]),e.flush(!0),{length:e.totalLength}}))}))}extractTextContent({handler:e,task:t,normalizeWhitespace:r,includeMarkedContent:a,sink:n,combineTextItems:i}){const s=this.getContentStream(),o=this.loadResources(["ExtGState","Font","Properties","XObject"]);return Promise.all([s,o]).then((([s])=>new g.PartialEvaluator({xref:this.xref,handler:e,pageIndex:this.pageIndex,idFactory:this._localIdFactory,fontCache:this.fontCache,builtInCMapCache:this.builtInCMapCache,globalImageCache:this.globalImageCache,options:this.evaluatorOptions}).getTextContent({stream:s,task:t,resources:this.resources,normalizeWhitespace:r,includeMarkedContent:a,combineTextItems:i,sink:n})))}async getStructTree(){const e=await this.pdfManager.ensureCatalog("structTreeRoot");return e?(await this.pdfManager.ensure(this,"_parseStructTree",[e])).serializable:null}_parseStructTree(e){const t=new m.StructTreePage(e,this.pageDict);return t.parse(),t}getAnnotationsData(e){return this._parsedAnnotations.then((function(t){const r=[];for(let a=0,n=t.length;a<n;a++)(!e||"display"===e&&t[a].viewable||"print"===e&&t[a].printable)&&r.push(t[a].data);return r}))}get annotations(){const e=this._getInheritableProperty("Annots");return(0,a.shadow)(this,"annotations",Array.isArray(e)?e:[])}get _parsedAnnotations(){const e=this.pdfManager.ensure(this,"