ngx-extended-pdf-viewer
Version:
Embedding PDF files in your Angular application. Highly configurable viewer including the toolbar, sidebar, and all the features you're used to.
23 lines • 239 kB
JavaScript
window.ngxZone.runOutsideAngular(() => {
/**
* @licstart The following is the entire license notice for the
* Javascript code in this page
*
* Copyright 2022 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @licend The above is the entire license notice for the
* Javascript code in this page
*/
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],t):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=t():e["pdfjs-dist/build/pdf"]=e.pdfjsLib=t()}(this,(function(){return(()=>{"use strict";var __webpack_modules__=[,(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.UNSUPPORTED_FEATURES=t.TextRenderingMode=t.StreamType=t.RenderingIntentFlag=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.IsLittleEndianCached=t.IsEvalSupportedCached=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FontType=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.AnnotationType=t.AnnotationStateModelType=t.AnnotationReviewState=t.AnnotationReplyType=t.AnnotationMode=t.AnnotationMarkedState=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0;t.arrayByteLength=arrayByteLength;t.arraysToBytes=function arraysToBytes(e){const t=e.length;if(1===t&&e[0]instanceof Uint8Array)return e[0];let n=0;for(let s=0;s<t;s++)n+=arrayByteLength(e[s]);let s=0;const r=new Uint8Array(n);for(let n=0;n<t;n++){let t=e[n];t instanceof Uint8Array||(t="string"==typeof t?stringToBytes(t):new Uint8Array(t));const a=t.byteLength;r.set(t,s);s+=a}return r};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,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const s=[];for(let r=0;r<t;r+=n){const a=Math.min(r+n,t),i=e.subarray(r,a);s.push(String.fromCharCode.apply(null,i))}return s.join("")};t.createPromiseCapability=function createPromiseCapability(){const e=Object.create(null);let t=!1;Object.defineProperty(e,"settled",{get:()=>t});e.promise=new Promise((function(n,s){e.resolve=function(e){t=!0;n(e)};e.reject=function(e){t=!0;s(e)}}));return e};t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t&&t.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=stringToUTF8String(e)}catch(e){}}const s=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){if(!e)return!1;switch(e.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":case"capacitor":return!0;default:return!1}}(s))return s}catch(e){}return null};t.escapeString=function escapeString(e){return e.replace(/([()\\\n\r])/g,(e=>"\n"===e?"\\n":"\r"===e?"\\r":`\\${e}`))};t.getModificationDate=function getModificationDate(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getVerbosityLevel=function getVerbosityLevel(){return r};t.info=function info(e){r>=s.INFOS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?console.log(`Info: ${e}`):Window&&Window.ngxConsole?Window.ngxConsole.log(`Info: ${e}`):console.log(`Info: ${e}`))};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&null!==e&&void 0!==e.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;for(let n=0,s=e.length;n<s;n++)if(e[n]!==t[n])return!1;return!0};t.isAscii=function isAscii(e){return/^[\x00-\x7F]*$/.test(e)};t.isBool=function isBool(e){return"boolean"==typeof e};t.isNum=function isNum(e){return"number"==typeof e};t.isSameOrigin=function isSameOrigin(e,t){let n;try{n=new URL(e);if(!n.origin||"null"===n.origin)return!1}catch(e){return!1}const s=new URL(t,n);return n.origin===s.origin};t.isString=function isString(e){return"string"==typeof e};t.objectFromMap=function objectFromMap(e){const t=Object.create(null);for(const[n,s]of e)t[n]=s;return t};t.objectSize=function objectSize(e){return Object.keys(e).length};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(r=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){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 n=new TextDecoder(t,{fatal:!0}),s=stringToBytes(e);return n.decode(s)}catch(e){warn(`stringToPDFString: "${e}".`)}}const t=[];for(let n=0,s=e.length;n<s;n++){const s=c[e.charCodeAt(n)];t.push(s?String.fromCharCode(s):e.charAt(n))}return t.join("")};t.stringToUTF16BEString=function stringToUTF16BEString(e){const t=["þÿ"];for(let n=0,s=e.length;n<s;n++){const s=e.charCodeAt(n);t.push(String.fromCharCode(s>>8&255),String.fromCharCode(255&s))}return t.join("")};t.stringToUTF8String=stringToUTF8String;t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;n(2);t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};t.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"};t.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"};t.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};t.AnnotationReplyType={GROUP:"Group",REPLY:"R"};t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};t.PageActionEventType={O:"PageOpen",C:"PageClose"};t.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};t.FontType={UNKNOWN:"UNKNOWN",TYPE1:"TYPE1",TYPE1STANDARD:"TYPE1STANDARD",TYPE1C:"TYPE1C",CIDFONTTYPE0:"CIDFONTTYPE0",CIDFONTTYPE0C:"CIDFONTTYPE0C",TRUETYPE:"TRUETYPE",CIDFONTTYPE2:"CIDFONTTYPE2",TYPE3:"TYPE3",OPENTYPE:"OPENTYPE",TYPE0:"TYPE0",MMTYPE1:"MMTYPE1"};const s={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=s;t.CMapCompressionType={NONE:0,BINARY:1,STREAM:2};t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotations:78,endAnnotations:79,beginAnnotation:80,endAnnotation:81,paintJpegXObject:82,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.UNSUPPORTED_FEATURES={unknown:"unknown",forms:"forms",javaScript:"javaScript",signatures:"signatures",smask:"smask",shadingPattern:"shadingPattern",font:"font",errorTilingPattern:"errorTilingPattern",errorExtGState:"errorExtGState",errorXObject:"errorXObject",errorFontLoadType3:"errorFontLoadType3",errorFontState:"errorFontState",errorFontMissing:"errorFontMissing",errorFontTranslate:"errorFontTranslate",errorColorSpace:"errorColorSpace",errorOperatorList:"errorOperatorList",errorFontToUnicode:"errorFontToUnicode",errorFontLoadNative:"errorFontLoadNative",errorFontBuildPath:"errorFontBuildPath",errorFontGetPath:"errorFontGetPath",errorMarkedContent:"errorMarkedContent",errorContentSubStream:"errorContentSubStream"};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let r=s.WARNINGS;function warn(e){r>=s.WARNINGS&&("undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?console.log(`Warning: ${e}`):Window&&Window.ngxConsole?Window.ngxConsole.log(`Warning: ${e}`):console.log(`Warning: ${e}`))}function unreachable(e){throw new Error(e)}function shadow(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!1});return n}const a=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=a;t.PasswordException=class PasswordException extends a{constructor(e,t){super(e,"PasswordException");this.code=t}};t.UnknownErrorException=class UnknownErrorException extends a{constructor(e,t){super(e,"UnknownErrorException");this.details=t}};t.InvalidPDFException=class InvalidPDFException extends a{constructor(e){super(e,"InvalidPDFException")}};t.MissingPDFException=class MissingPDFException extends a{constructor(e){super(e,"MissingPDFException")}};t.UnexpectedResponseException=class UnexpectedResponseException extends a{constructor(e,t){super(e,"UnexpectedResponseException");this.status=t}};t.FormatError=class FormatError extends a{constructor(e){super(e,"FormatError")}};t.AbortException=class AbortException extends a{constructor(e){super(e,"AbortException")}};function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let s=0;s<t;++s)n[s]=255&e.charCodeAt(s);return n}function arrayByteLength(e){if(void 0!==e.length)return e.length;if(void 0!==e.byteLength)return e.byteLength;unreachable("Invalid argument for arrayByteLength")}const i={get value(){return shadow(this,"value",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}};t.IsLittleEndianCached=i;const o={get value(){return shadow(this,"value",function isEvalSupported(){try{new Function("");return!0}catch(e){return!1}}())}};t.IsEvalSupportedCached=o;const l=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));class Util{static makeHexColor(e,t,n){return`#${l[e]}${l[t]}${l[n]}`}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=Util.applyTransform(e,t),s=Util.applyTransform(e.slice(2,4),t),r=Util.applyTransform([e[0],e[3]],t),a=Util.applyTransform([e[2],e[1]],t);return[Math.min(n[0],s[0],r[0],a[0]),Math.min(n[1],s[1],r[1],a[1]),Math.max(n[0],s[0],r[0],a[0]),Math.max(n[1],s[1],r[1],a[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static apply3dTransform(e,t){return[e[0]*t[0]+e[1]*t[1]+e[2]*t[2],e[3]*t[0]+e[4]*t[1]+e[5]*t[2],e[6]*t[0]+e[7]*t[1]+e[8]*t[2]]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],s=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],i=(n+a)/2,o=Math.sqrt((n+a)**2-4*(n*a-r*s))/2,l=i+o||1,c=i-o||1;return[Math.sqrt(l),Math.sqrt(c)]}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){function compare(e,t){return e-t}const n=[e[0],e[2],t[0],t[2]].sort(compare),s=[e[1],e[3],t[1],t[3]].sort(compare),r=[];e=Util.normalizeRect(e);t=Util.normalizeRect(t);if(!(n[0]===e[0]&&n[1]===t[0]||n[0]===t[0]&&n[1]===e[0]))return null;r[0]=n[1];r[2]=n[2];if(!(s[0]===e[1]&&s[1]===t[1]||s[0]===t[1]&&s[1]===e[1]))return null;r[1]=s[1];r[3]=s[2];return r}static bezierBoundingBox(e,t,n,s,r,a,i,o){const l=[],c=[[],[]];let h,d,u,p,g,f,m,_;for(let c=0;c<2;++c){if(0===c){d=6*e-12*n+6*r;h=-3*e+9*n-9*r+3*i;u=3*n-3*e}else{d=6*t-12*s+6*a;h=-3*t+9*s-9*a+3*o;u=3*s-3*t}if(Math.abs(h)<1e-12){if(Math.abs(d)<1e-12)continue;p=-u/d;0<p&&p<1&&l.push(p)}else{m=d*d-4*u*h;_=Math.sqrt(m);if(!(m<0)){g=(-d+_)/(2*h);0<g&&g<1&&l.push(g);f=(-d-_)/(2*h);0<f&&f<1&&l.push(f)}}}let A,b=l.length;const y=b;for(;b--;){p=l[b];A=1-p;c[0][b]=A*A*A*e+3*A*A*p*n+3*A*p*p*r+p*p*p*i;c[1][b]=A*A*A*t+3*A*A*p*s+3*A*p*p*a+p*p*p*o}c[0][y]=e;c[1][y]=t;c[0][y+1]=i;c[1][y+1]=o;c[0].length=c[1].length=y+2;return[Math.min(...c[0]),Math.min(...c[1]),Math.max(...c[0]),Math.max(...c[1])]}}t.Util=Util;const c=[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))}},()=>{},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0});exports.build=exports.RenderTask=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0;exports.getDocument=getDocument;exports.setPDFNetworkStreamFactory=setPDFNetworkStreamFactory;exports.version=void 0;var _util=__w_pdfjs_require__(1),_display_utils=__w_pdfjs_require__(4),_font_loader=__w_pdfjs_require__(6),_node_utils=__w_pdfjs_require__(7),_annotation_storage=__w_pdfjs_require__(9),_canvas=__w_pdfjs_require__(10),_worker_options=__w_pdfjs_require__(12),_is_node=__w_pdfjs_require__(8),_message_handler=__w_pdfjs_require__(13),_metadata=__w_pdfjs_require__(14),_optional_content_config=__w_pdfjs_require__(15),_transport_stream=__w_pdfjs_require__(16),_xfa_text=__w_pdfjs_require__(17);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,ServiceWorkerOptions={showUnverifiedSignatures:!1};window.ServiceWorkerOptions=ServiceWorkerOptions;const DefaultCanvasFactory=_is_node.isNodeJS?_node_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_is_node.isNodeJS?_node_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultStandardFontDataFactory=_is_node.isNodeJS?_node_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;let createPDFNetworkStream;function setPDFNetworkStreamFactory(e){createPDFNetworkStream=e}function getDocument(e){const t=new PDFDocumentLoadingTask;let n;if("string"==typeof e||e instanceof URL)n={url:e};else if((0,_util.isArrayBuffer)(e))n={data:e};else if(e instanceof PDFDataRangeTransport)n={range:e};else{if("object"!=typeof e)throw new Error("Invalid parameter in getDocument, need either string, URL, Uint8Array, or parameter object.");if(!e.url&&!e.data&&!e.range)throw new Error("Invalid parameter object: need either .data, .range or .url");n=e}const s=e.baseHref,r=Object.create(null);let a=null,i=null;for(const e in n){const t=n[e];switch(e){case"url":if("undefined"!=typeof window)try{r[e]=s?new URL(t,window.location.origin+s).href:new URL(t,window.location).href;continue}catch(e){(0,_util.warn)(`Cannot create valid URL: "${e}".`)}else if("string"==typeof t||t instanceof URL){r[e]=t.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":a=t;continue;case"worker":i=t;continue;case"data":if(_is_node.isNodeJS&&"undefined"!=typeof Buffer&&t instanceof Buffer)r[e]=new Uint8Array(t);else{if(t instanceof Uint8Array)break;if("string"==typeof t)r[e]=(0,_util.stringToBytes)(t);else if("object"!=typeof t||null===t||isNaN(t.length)){if(!(0,_util.isArrayBuffer)(t))throw new Error("Invalid PDF binary data: either typed array, string, or array-like object is expected in the data property.");r[e]=new Uint8Array(t)}else r[e]=new Uint8Array(t)}continue}r[e]=t}r.rangeChunkSize=r.rangeChunkSize||DEFAULT_RANGE_CHUNK_SIZE;r.CMapReaderFactory=r.CMapReaderFactory||DefaultCMapReaderFactory;r.StandardFontDataFactory=r.StandardFontDataFactory||DefaultStandardFontDataFactory;r.ignoreErrors=!0!==r.stopAtErrors;r.fontExtraProperties=!0===r.fontExtraProperties;r.pdfBug=!0===r.pdfBug;r.enableXfa=!0===r.enableXfa;("string"!=typeof r.docBaseUrl||(0,_display_utils.isDataScheme)(r.docBaseUrl))&&(r.docBaseUrl=null);Number.isInteger(r.maxImageSize)||(r.maxImageSize=-1);"boolean"!=typeof r.useWorkerFetch&&(r.useWorkerFetch=r.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&r.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory);"boolean"!=typeof r.isEvalSupported&&(r.isEvalSupported=!0);"boolean"!=typeof r.disableFontFace&&(r.disableFontFace=_is_node.isNodeJS);"boolean"!=typeof r.useSystemFonts&&(r.useSystemFonts=!_is_node.isNodeJS&&!r.disableFontFace);void 0===r.ownerDocument&&(r.ownerDocument=globalThis.document);"boolean"!=typeof r.disableRange&&(r.disableRange=!1);"boolean"!=typeof r.disableStream&&(r.disableStream=!1);"boolean"!=typeof r.disableAutoFetch&&(r.disableAutoFetch=!1);(0,_util.setVerbosityLevel)(r.verbosity);if(!i){const e={verbosity:r.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};i=e.port?PDFWorker.fromPort(e):new PDFWorker(e);t._worker=i}const o=t.docId;i.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");const e=_fetchDocument(i,r,a,o),n=new Promise((function(e){let t;a?t=new _transport_stream.PDFDataTransportStream({length:r.length,initialData:r.initialData,progressiveDone:r.progressiveDone,contentDispositionFilename:r.contentDispositionFilename,disableRange:r.disableRange,disableStream:r.disableStream},a):r.data||(t=createPDFNetworkStream({url:r.url,length:r.length,httpHeaders:r.httpHeaders,withCredentials:r.withCredentials,rangeChunkSize:r.rangeChunkSize,disableRange:r.disableRange,disableStream:r.disableStream}));e(t)}));return Promise.all([e,n]).then((function([e,n]){if(t.destroyed)throw new Error("Loading aborted");const s=new _message_handler.MessageHandler(o,e,i.port),a=new WorkerTransport(s,t,n,r);t._transport=a;s.send("showUnverifiedSignatures",window.ServiceWorkerOptions.showUnverifiedSignatures);s.send("Ready",null)}))})).catch(t._capability.reject);return t}async function _fetchDocument(e,t,n,s){if(e.destroyed)throw new Error("Worker was destroyed");if(n){t.length=n.length;t.initialData=n.initialData;t.progressiveDone=n.progressiveDone;t.contentDispositionFilename=n.contentDispositionFilename}let r=t.cMapUrl;"Function"===r.constructor.name&&(r=r());const a=await e.messageHandler.sendWithPromise("GetDocRequest",{docId:s,apiVersion:"2.13.408",source:{data:t.data,url:t.url,password:t.password,disableAutoFetch:t.disableAutoFetch,rangeChunkSize:t.rangeChunkSize,length:t.length},maxImageSize:t.maxImageSize,disableFontFace:t.disableFontFace,docBaseUrl:t.docBaseUrl,ignoreErrors:t.ignoreErrors,isEvalSupported:t.isEvalSupported,fontExtraProperties:t.fontExtraProperties,enableXfa:t.enableXfa,useSystemFonts:t.useSystemFonts,cMapUrl:t.useWorkerFetch?r:null,standardFontDataUrl:t.useWorkerFetch?t.standardFontDataUrl:null});if(e.destroyed)throw new Error("Worker was destroyed");return a}class PDFDocumentLoadingTask{static get idCounters(){return(0,_util.shadow)(this,"idCounters",{doc:0})}constructor(){this._capability=(0,_util.createPromiseCapability)();this._transport=null;this._worker=null;this.docId="d"+PDFDocumentLoadingTask.idCounters.doc++;this.destroyed=!1;this.onPassword=null;this.onProgress=null;this.onUnsupportedFeature=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;await(this._transport?.destroy());this._transport=null;if(this._worker){this._worker.destroy();this._worker=null}}}exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(e,t,n=!1,s=null){this.length=e;this.initialData=t;this.progressiveDone=n;this.contentDispositionFilename=s;this._rangeListeners=[];this._progressListeners=[];this._progressiveReadListeners=[];this._progressiveDoneListeners=[];this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t;Object.defineProperty(this,"fingerprint",{get(){(0,_display_utils.deprecated)("`PDFDocumentProxy.fingerprint`, please use `PDFDocumentProxy.fingerprints` instead.");return this.fingerprints[0]}});Object.defineProperty(this,"getStats",{value:async()=>{(0,_display_utils.deprecated)("`PDFDocumentProxy.getStats`, please use the `PDFDocumentProxy.stats`-getter instead.");return this.stats||{streamTypes:{},fontTypes:{}}}})}get annotationStorage(){return this._transport.annotationStorage}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get stats(){return this._transport.stats}get isPureXfa(){return!!this._transport._htmlForXfa}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJavaScript(){return this._transport.getJavaScript()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig(){return this._transport.getOptionalContentConfig()}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}saveDocument(){this._transport.annotationStorage.size<=0&&(0,_display_utils.deprecated)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");return this._transport.saveDocument()}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{constructor(e,t,n,s,r=!1){this._pageIndex=e;this._pageInfo=t;this._ownerDocument=s;this._transport=n;this._stats=r?new _display_utils.StatTimer:null;this._pdfBug=r;this.commonObjs=n.commonObjs;this.objs=new PDFObjects;this.cleanupAfterRender=!1;this.pendingCleanup=!1;this._intentStates=new Map;this._annotationPromises=new Map;this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:s=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:s,dontFlip:r})}getAnnotations({intent:e="display"}={}){const t=this._transport.getRenderingIntent(e);let n=this._annotationPromises.get(t.cacheKey);if(!n){n=this._transport.getAnnotations(this._pageIndex,t.renderingIntent);this._annotationPromises.set(t.cacheKey,n);n=n.then((e=>{for(const t of e){void 0!==t.titleObj&&Object.defineProperty(t,"title",{get(){(0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead.");return t.titleObj.str}});void 0!==t.contentsObj&&Object.defineProperty(t,"contents",{get(){(0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead.");return t.contentsObj.str}})}return e}))}return n}getJSActions(){return this._jsActionsPromise||=this._transport.getPageJSActions(this._pageIndex)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:s=_util.AnnotationMode.ENABLE,transform:r=null,imageLayer:a=null,canvasFactory:i=null,background:o=null,backgroundColorToReplace:l=null,optionalContentConfigPromise:c=null,annotationCanvasMap:h=null}){if(void 0!==arguments[0]?.renderInteractiveForms){(0,_display_utils.deprecated)("render no longer accepts the `renderInteractiveForms`-option, please use the `annotationMode`-option instead.");!0===arguments[0].renderInteractiveForms&&s===_util.AnnotationMode.ENABLE&&(s=_util.AnnotationMode.ENABLE_FORMS)}if(void 0!==arguments[0]?.includeAnnotationStorage){(0,_display_utils.deprecated)("render no longer accepts the `includeAnnotationStorage`-option, please use the `annotationMode`-option instead.");!0===arguments[0].includeAnnotationStorage&&s===_util.AnnotationMode.ENABLE&&(s=_util.AnnotationMode.ENABLE_STORAGE)}this._stats&&this._stats.time("Overall");const d=this._transport.getRenderingIntent(n,s);this.pendingCleanup=!1;c||(c=this._transport.getOptionalContentConfig());let u=this._intentStates.get(d.cacheKey);if(!u){u=Object.create(null);this._intentStates.set(d.cacheKey,u)}if(u.streamReaderCancelTimeout){clearTimeout(u.streamReaderCancelTimeout);u.streamReaderCancelTimeout=null}const p=i||new DefaultCanvasFactory({ownerDocument:this._ownerDocument}),g=!!(d.renderingIntent&_util.RenderingIntentFlag.PRINT);if(!u.displayReadyCapability){u.displayReadyCapability=(0,_util.createPromiseCapability)();u.operatorList={fnArray:[],argsArray:[],lastChunk:!1};this._stats&&this._stats.time("Page Request");this._pumpOperatorList(d)}const complete=e=>{u.renderTasks.delete(f);(this.cleanupAfterRender||g)&&(this.pendingCleanup=!0);this._tryCleanup();if(e){f.capability.reject(e);this._abortOperatorList({intentState:u,reason:e instanceof Error?e:new Error(e)})}else f.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall")}},f=new InternalRenderTask({callback:complete,params:{canvasContext:e,viewport:t,transform:r,imageLayer:a,background:o,backgroundColorToReplace:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:u.operatorList,pageIndex:this._pageIndex,canvasFactory:p,useRequestAnimationFrame:!g,pdfBug:this._pdfBug});(u.renderTasks||=new Set).add(f);const m=f.task;Promise.all([u.displayReadyCapability.promise,c]).then((([e,t])=>{if(this.pendingCleanup)complete();else{this._stats&&this._stats.time("Rendering");f.initializeGraphics({transparency:e,optionalContentConfig:t});f.operatorListChanged()}})).catch(complete);return m}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE}={}){const n=this._transport.getRenderingIntent(e,t,!0);let s,r=this._intentStates.get(n.cacheKey);if(!r){r=Object.create(null);this._intentStates.set(n.cacheKey,r)}if(!r.opListReadCapability){s=Object.create(null);s.operatorListChanged=function operatorListChanged(){if(r.operatorList.lastChunk){r.opListReadCapability.resolve(r.operatorList);r.renderTasks.delete(s)}};r.opListReadCapability=(0,_util.createPromiseCapability)();(r.renderTasks||=new Set).add(s);r.operatorList={fnArray:[],argsArray:[],lastChunk:!1};this._stats&&this._stats.time("Page Request");this._pumpOperatorList(n)}return r.opListReadCapability.promise}streamTextContent({disableCombineTextItems:e=!1,includeMarkedContent:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,combineTextItems:!0!==e,includeMarkedContent:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>_xfa_text.XfaText.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,n){const s=t.getReader(),r={items:[],styles:Object.create(null)};!function pump(){s.read().then((function({value:t,done:n}){if(n)e(r);else{Object.assign(r.styles,t.styles);r.items.push(...t.items);pump()}}),n)}()}))}getStructTree(){return this._structTreePromise||=this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values()){this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0});if(!t.opListReadCapability)for(const n of t.renderTasks){e.push(n.completed);n.cancel()}}this.objs.clear();this._annotationPromises.clear();this._jsActionsPromise=null;this._structTreePromise=null;this.pendingCleanup=!1;return Promise.all(e)}cleanup(e=!1){this.pendingCleanup=!0;this._tryCleanup(e)||(this.cleanupAfterRender=!0);return!0}_tryCleanup(e=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this._annotationPromises.clear();this._jsActionsPromise=null;this._structTreePromise=null;e&&this._stats&&(this._stats=new _display_utils.StatTimer);this.pendingCleanup=!1;return!0}_startRenderPage(e,t){const n=this._intentStates.get(t);if(n){this._stats&&this._stats.timeEnd("Page Request");n.displayReadyCapability&&n.displayReadyCapability.resolve(e)}}_renderPageChunk(e,t){for(let n=0,s=e.length;n<s;n++){t.operatorList.fnArray.push(e.fnArray[n]);t.operatorList.argsArray.push(e.argsArray[n])}t.operatorList.lastChunk=e.lastChunk;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:e,cacheKey:t}){const n=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:e&_util.RenderingIntentFlag.ANNOTATIONS_STORAGE?this._transport.annotationStorage.serializable:null}).getReader(),s=this._intentStates.get(t);s.streamReader=n;const pump=()=>{n.read().then((({value:e,done:t})=>{if(t)s.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(e,s);pump()}}),(e=>{s.streamReader=null;if(!this._transport.destroyed){if(s.operatorList){s.operatorList.lastChunk=!0;for(const e of s.renderTasks)e.operatorListChanged();this._tryCleanup()}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else{if(!s.opListReadCapability)throw e;s.opListReadCapability.reject(e)}}}))};pump()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(!n){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){e.streamReaderCancelTimeout=setTimeout((()=>{this._abortOperatorList({intentState:e,reason:t,force:!0});e.streamReaderCancelTimeout=null}),RENDERING_CANCELLED_TIMEOUT);return}}e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{}));e.streamReader=null;if(!this._transport.destroyed){for(const[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[];this._deferred=Promise.resolve()}postMessage(e,t){const n={data:structuredClone(e,t)};this._deferred.then((()=>{for(const e of this._listeners)e.call(this,n)}))}addEventListener(e,t){this._listeners.push(t)}removeEventListener(e,t){const n=this._listeners.indexOf(t);this._listeners.splice(n,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(_is_node.isNodeJS&&"function"==typeof require){PDFWorkerUtil.isWorkerDisabled=!0;PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js"}else if("object"==typeof document){const e=document?.currentScript?.src;e&&(PDFWorkerUtil.fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.createCDNWrapper=function(e){const t=`importScripts("${e}");`;return URL.createObjectURL(new Blob([t]))};class PDFWorker{static get _workerPorts(){return(0,_util.shadow)(this,"_workerPorts",new WeakMap)}constructor({name:e=null,port:t=null,verbosity:n=(0,_util.getVerbosityLevel)()}={}){if(t&&PDFWorker._workerPorts.has(t))throw new Error("Cannot use more than one PDFWorker per port.");this.name=e;this.destroyed=!1;this.verbosity=n;this._readyCapability=(0,_util.createPromiseCapability)();this._port=null;this._webWorker=null;this._messageHandler=null;if(t){PDFWorker._workerPorts.set(t,this);this._initializeFromPort(t)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e;this._messageHandler=new _message_handler.MessageHandler("main","worker",e);this._messageHandler.on("ready",(function(){}));this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!PDFWorkerUtil.isWorkerDisabled&&!PDFWorker._mainThreadWorkerMessageHandler){let e=PDFWorker.workerSrc;try{(0,_util.isSameOrigin)(window.location.href,e)||(e=PDFWorkerUtil.createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e),n=new _message_handler.MessageHandler("main","worker",t),terminateEarly=()=>{t.removeEventListener("error",onWorkerError);n.destroy();t.terminate();this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},onWorkerError=()=>{this._webWorker||terminateEarly()};t.addEventListener("error",onWorkerError);n.on("test",(e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else if(e){this._messageHandler=n;this._port=t;this._webWorker=t;this._readyCapability.resolve();n.send("configure",{verbosity:this.verbosity})}else{this._setupFakeWorker();n.destroy();t.terminate()}}));n.on("ready",(e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else try{sendTest()}catch(e){this._setupFakeWorker()}}));const sendTest=()=>{const e=new Uint8Array([255]);try{n.send("test",e,[e.buffer])}catch(t){(0,_util.warn)("Cannot use postMessage transfers.");e[0]=0;n.send("test",e)}};sendTest();return}catch(e){(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){if(!PDFWorkerUtil.isWorkerDisabled){(0,_util.warn)("Setting up fake worker.");PDFWorkerUtil.isWorkerDisabled=!0}PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new LoopbackPort;this._port=t;const n="fake"+PDFWorkerUtil.fakeWorkerId++,s=new _message_handler.MessageHandler(n+"_worker",n,t);e.setup(s,t);const r=new _message_handler.MessageHandler(n,n+"_worker",t);this._messageHandler=r;this._readyCapability.resolve();r.send("configure",{verbosity:this.verbosity})})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}PDFWorker._workerPorts.delete(this._port);this._port=null;if(this._messageHandler){this._messageHandler.destroy();this._messageHandler=null}}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this._workerPorts.has(e.port)?this._workerPorts.get(e.port):new PDFWorker(e)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return"Function"===_worker_options.GlobalWorkerOptions.workerSrc.constructor.name?_worker_options.GlobalWorkerOptions.workerSrc():_worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc){_is_node.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.');return PDFWorkerUtil.fallbackWorkerSrc}throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _mainThreadWorkerMessageHandler(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch(e){return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_is_node.isNodeJS&&"function"==typeof require){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}await(0,_display_utils.loadScript)(this.workerSrc);return window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}}exports.PDFWorker=PDFWorker;PDFWorker.getWorkerSrc=function(){(0,_display_utils.deprecated)("`PDFWorker.getWorkerSrc()`, please use `PDFWorker.workerSrc` instead.");return this.workerSrc};class WorkerTransport{#e=null;#t=new Map;#n=new Map;#s=null;constructor(e,t,n,s){this.messageHandler=e;this.loadingTask=t;this.commonObjs=new PDFObjects;this.fontLoader=new _font_loader.FontLoader({docId:t.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:s.ownerDocument,styleElement:s.styleElement});this._params=s;if(!s.useWorkerFetch){let e=s.cMapUrl;"Function"===e.constructor.name&&(e=e());this.CMapReaderFactory=new s.CMapReaderFactory({baseUrl:e,isCompressed:s.cMapPacked});this.StandardFontDataFactory=new s.StandardFontDataFactory({baseUrl:s.standardFontDataUrl})}this.destroyed=!1;this.destroyCapability=null;this._passwordCapability=null;this._networkStream=n;this._fullReader=null;this._lastProgress=null;this.downloadInfoCapability=(0,_util.createPromiseCapability)();this.setupMessageHandler()}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}get stats(){return this.#e}getRenderingIntent(e,t=_util.AnnotationMode.ENABLE,n=!1){let s=_util.RenderingIntentFlag.DISPLAY,r="";switch(e){case"any":s=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":s=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case _util.AnnotationMode.DISABLE:s+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:s+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:s+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE;r=this.annotationStorage.lastModified;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}n&&(s+=_util.RenderingIntentFlag.OPLIST);return{renderingIntent:s,cacheKey:`${s}_${r}`}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=(0,_util.createPromiseCapability)();this._passwordCapability&&this._passwordCapability.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#t.values())e.push(t._destroy());this.#t.clear();this.#n.clear();this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then((()=>{this.commonObjs.clear();this.fontLoader.clear();this.#s=null;this._getFieldObjectsPromise=null;this._hasJSActionsPromise=null;this._networkStream&&this._networkStream.cancelAllRequests(new _util.AbortException("Worker was terminated."));if(this.messageHandler){this.messageHandler.destroy();this.messageHandler=null}this.destroyCapability.resolve()}),this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available.");this._fullReader=this._networkStream.getFullReader();this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}};t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){if(n)t.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(e),"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch((e=>{t.error(e)}))};t.onCancel=e=>{this._fullReader.cancel(e);t.ready.catch((e=>{if(!this.destroyed)throw e}))}}));e.on("ReaderHeadersReady",(e=>{const n=(0,_util.createPromiseCapability)(),s=this._fullReader;s.headersReady.then((()=>{if(!s.isStreamingSupported||!s.isRangeSupported){this._lastProgress&&t.onProgress?.(this._lastProgress);s.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}}n.resolve({isStreamingSupported:s.isStreamingSupported,isRangeSupported:s.isRangeSupported,contentLength:s.contentLength})}),n.reject);return n.promise}));e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(e.begin,e.end);if(n){t.onPull=()=>{n.read().then((function({value:e,done:n}){if(n)t.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(e),"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch((e=>{t.error(e)}))};t.onCancel=e=>{n.cancel(e);t.ready.catch((e=>{if(!this.destroyed)throw e}))}}else t.close()}));e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages;this._htmlForXfa=e.htmlForXfa;delete e.htmlForXfa;t._capability.resolve(new PDFDocumentProxy(e,this))}));e.on("DocException",(function(e){let n;switch(e.name){case"PasswordException":n=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":n=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":n=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":n=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":n=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(n)}));e.on("PasswordRequest",(e=>{this._passwordCapability=(0,_util.createPromiseCapability)();if(t.onPassword){const updatePassword=e=>{e instanceof Error?this._passwordCapability.reject(e):this._passwordCapability.resolve({password:e})};try{t.onPassword(updatePassword,e.code)}catch(e){this._passwordCapability.reject(e)}}else this._passwordCapability.reject(new _util.PasswordException(e.message,e.code));return this._passwordCapability.promise}));e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)}));e.on("StartRenderPage",(e=>{if(this.destroyed)return;this.#t.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}));e.on("commonobj",(([t,n,s])=>{if(!this.destroyed&&!this.commonObjs.has(t))switch(n){case"Font":const r=this._params;if("error"in s){const e=s.error;(0,_util.warn)(`Error during font loading: ${e}`);this.commonObjs.resolve(t,e);break}let a=null;r.pdfBug&&globalThis.FontInspector?.enabled&&(a={registerFont(e,t){globalThis.FontInspector.fontAdded(e,t)}});const i=new _font_loader.FontFaceObject(s,{isEvalSupported:r.isEvalSupported,disableFontFace:r.disableFontFace,ignoreErrors:r.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:a});this.fontLoader.bind(i).catch((n=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!r.fontExtraProperties&&i.data&&(i.data=null);this.commonObjs.resolve(t,i)}));break;case"FontPath":case"Image":this.commonObjs.resolve(t,s);break;default:throw new Error(`Got unknown common object type ${n}`)}}));e.on("obj",(([e,t,n,s])=>{if(this.destroyed)return;const r=this.#t.get(t);if(!r.objs.has(e))switch(n){case"Image":r.objs.resolve(e,s);const t=8e6;s?.data?.length>t&&(r.cleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(e,s);break;default:throw new Error(`Got unknown object type ${n}`)}}));e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})}));e.on("DocStats",(e=>{this.destroyed||(this.#e=Object.freeze({streamTypes:Object.freeze(e.streamTypes),fontTypes:Object.freeze(e.fontTypes)}))}));e.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this));e.on("FetchBuiltInCMap",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(e):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))));e.on("FetchStandardFontData",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(e):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}_onUnsupportedFeature({featureId:e}){this.destroyed||this.loadingTask.onUnsupportedFeature?.(e)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request"));const t=e-1,n=this.#n.get(t);if(n)return n;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");const n=new PDFPageProxy(t,e,this,this._params.ownerDocument,this._params.pdfBug);this.#t.set(t,n);return n}));this.#n.set(t,s);return s}getPageIndex(e){return this.messageHandler.sendWithPromise("GetPageIndex",{ref:e})}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}saveDocument(){return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlFo