pdf.min.js 237 KB

12345678910111213141516171819202122
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. !function webpackUniversalModuleDefinition(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],e):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e():t["pdfjs-dist/build/pdf"]=t.pdfjsLib=e()}(this,(()=>(()=>{"use strict";var __webpack_modules__=[,(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.VerbosityLevel=e.Util=e.UnknownErrorException=e.UnexpectedResponseException=e.UNSUPPORTED_FEATURES=e.TextRenderingMode=e.StreamType=e.RenderingIntentFlag=e.PermissionFlag=e.PasswordResponses=e.PasswordException=e.PageActionEventType=e.OPS=e.MissingPDFException=e.InvalidPDFException=e.ImageKind=e.IDENTITY_MATRIX=e.FormatError=e.FontType=e.FeatureTest=e.FONT_IDENTITY_MATRIX=e.DocumentActionEventType=e.CMapCompressionType=e.BaseException=e.AnnotationType=e.AnnotationStateModelType=e.AnnotationReviewState=e.AnnotationReplyType=e.AnnotationMode=e.AnnotationMarkedState=e.AnnotationFlag=e.AnnotationFieldFlag=e.AnnotationBorderStyleType=e.AnnotationActionEventType=e.AbortException=void 0;e.arrayByteLength=arrayByteLength;e.arraysToBytes=function arraysToBytes(t){const e=t.length;if(1===e&&t[0]instanceof Uint8Array)return t[0];let s=0;for(let n=0;n<e;n++)s+=arrayByteLength(t[n]);let n=0;const r=new Uint8Array(s);for(let s=0;s<e;s++){let e=t[s];e instanceof Uint8Array||(e="string"==typeof e?stringToBytes(e):new Uint8Array(e));const a=e.byteLength;r.set(e,n);n+=a}return r};e.assert=function assert(t,e){t||unreachable(e)};e.bytesToString=function bytesToString(t){"object"==typeof t&&null!==t&&void 0!==t.length||unreachable("Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const n=[];for(let r=0;r<e;r+=s){const a=Math.min(r+s,e),i=t.subarray(r,a);n.push(String.fromCharCode.apply(null,i))}return n.join("")};e.createPromiseCapability=function createPromiseCapability(){const t=Object.create(null);let e=!1;Object.defineProperty(t,"settled",{get:()=>e});t.promise=new Promise((function(s,n){t.resolve=function(t){e=!0;s(t)};t.reject=function(t){e=!0;n(t)}}));return t};e.createValidAbsoluteUrl=function createValidAbsoluteUrl(t,e=null,s=null){if(!t)return null;try{if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e&&e.length>=2&&(t=`http://${t}`)}if(s.tryConvertEncoding)try{t=stringToUTF8String(t)}catch(t){}}const n=e?new URL(t,e):new URL(t);if(function _isValidProtocol(t){if(!t)return!1;switch(t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n))return n}catch(t){}return null};e.escapeString=function escapeString(t){return t.replace(/([()\\\n\r])/g,(t=>"\n"===t?"\\n":"\r"===t?"\\r":`\\${t}`))};e.getModificationDate=function getModificationDate(t=new Date){return[t.getUTCFullYear().toString(),(t.getUTCMonth()+1).toString().padStart(2,"0"),t.getUTCDate().toString().padStart(2,"0"),t.getUTCHours().toString().padStart(2,"0"),t.getUTCMinutes().toString().padStart(2,"0"),t.getUTCSeconds().toString().padStart(2,"0")].join("")};e.getVerbosityLevel=function getVerbosityLevel(){return r};e.info=function info(t){r>=n.INFOS&&console.log(`Info: ${t}`)};e.isArrayBuffer=function isArrayBuffer(t){return"object"==typeof t&&null!==t&&void 0!==t.byteLength};e.isArrayEqual=function isArrayEqual(t,e){if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(t[s]!==e[s])return!1;return!0};e.isAscii=function isAscii(t){return/^[\x00-\x7F]*$/.test(t)};e.objectFromMap=function objectFromMap(t){const e=Object.create(null);for(const[s,n]of t)e[s]=n;return e};e.objectSize=function objectSize(t){return Object.keys(t).length};e.setVerbosityLevel=function setVerbosityLevel(t){Number.isInteger(t)&&(r=t)};e.shadow=shadow;e.string32=function string32(t){return String.fromCharCode(t>>24&255,t>>16&255,t>>8&255,255&t)};e.stringToBytes=stringToBytes;e.stringToPDFString=function stringToPDFString(t){if(t[0]>="ï"){let e;"þ"===t[0]&&"ÿ"===t[1]?e="utf-16be":"ÿ"===t[0]&&"þ"===t[1]?e="utf-16le":"ï"===t[0]&&"»"===t[1]&&"¿"===t[2]&&(e="utf-8");if(e)try{const s=new TextDecoder(e,{fatal:!0}),n=stringToBytes(t);return s.decode(n)}catch(t){warn(`stringToPDFString: "${t}".`)}}const e=[];for(let s=0,n=t.length;s<n;s++){const n=o[t.charCodeAt(s)];e.push(n?String.fromCharCode(n):t.charAt(s))}return e.join("")};e.stringToUTF16BEString=function stringToUTF16BEString(t){const e=["þÿ"];for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);e.push(String.fromCharCode(n>>8&255),String.fromCharCode(255&n))}return e.join("")};e.stringToUTF8String=stringToUTF8String;e.unreachable=unreachable;e.utf8StringToString=function utf8StringToString(t){return unescape(encodeURIComponent(t))};e.warn=warn;s(2);e.IDENTITY_MATRIX=[1,0,0,1,0,0];e.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];e.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};e.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};e.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};e.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};e.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};e.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};e.AnnotationStateModelType={MARKED:"Marked",REVIEW:"Review"};e.AnnotationMarkedState={MARKED:"Marked",UNMARKED:"Unmarked"};e.AnnotationReviewState={ACCEPTED:"Accepted",REJECTED:"Rejected",CANCELLED:"Cancelled",COMPLETED:"Completed",NONE:"None"};e.AnnotationReplyType={GROUP:"Group",REPLY:"R"};e.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};e.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};e.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};e.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"};e.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};e.PageActionEventType={O:"PageOpen",C:"PageClose"};e.StreamType={UNKNOWN:"UNKNOWN",FLATE:"FLATE",LZW:"LZW",DCT:"DCT",JPX:"JPX",JBIG:"JBIG",A85:"A85",AHX:"AHX",CCF:"CCF",RLX:"RLX"};e.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 n={ERRORS:0,WARNINGS:1,INFOS:5};e.VerbosityLevel=n;e.CMapCompressionType={NONE:0,BINARY:1,STREAM:2};e.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};e.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"};e.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let r=n.WARNINGS;function warn(t){r>=n.WARNINGS&&console.log(`Warning: ${t}`)}function unreachable(t){throw new Error(t)}function shadow(t,e,s){Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!1});return s}const a=function BaseExceptionClosure(){function BaseException(t,e){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=t;this.name=e}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();e.BaseException=a;e.PasswordException=class PasswordException extends a{constructor(t,e){super(t,"PasswordException");this.code=e}};e.UnknownErrorException=class UnknownErrorException extends a{constructor(t,e){super(t,"UnknownErrorException");this.details=e}};e.InvalidPDFException=class InvalidPDFException extends a{constructor(t){super(t,"InvalidPDFException")}};e.MissingPDFException=class MissingPDFException extends a{constructor(t){super(t,"MissingPDFException")}};e.UnexpectedResponseException=class UnexpectedResponseException extends a{constructor(t,e){super(t,"UnexpectedResponseException");this.status=e}};e.FormatError=class FormatError extends a{constructor(t){super(t,"FormatError")}};e.AbortException=class AbortException extends a{constructor(t){super(t,"AbortException")}};function stringToBytes(t){"string"!=typeof t&&unreachable("Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let n=0;n<e;++n)s[n]=255&t.charCodeAt(n);return s}function arrayByteLength(t){if(void 0!==t.length)return t.length;if(void 0!==t.byteLength)return t.byteLength;unreachable("Invalid argument for arrayByteLength")}e.FeatureTest=class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const t=new Uint8Array(4);t[0]=1;return 1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch(t){return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}};const i=[...Array(256).keys()].map((t=>t.toString(16).padStart(2,"0")));class Util{static makeHexColor(t,e,s){return`#${i[t]}${i[e]}${i[s]}`}static scaleMinMax(t,e){let s;if(t[0]){if(t[0]<0){s=e[0];e[0]=e[1];e[1]=s}e[0]*=t[0];e[1]*=t[0];if(t[3]<0){s=e[2];e[2]=e[3];e[3]=s}e[2]*=t[3];e[3]*=t[3]}else{s=e[0];e[0]=e[2];e[2]=s;s=e[1];e[1]=e[3];e[3]=s;if(t[1]<0){s=e[2];e[2]=e[3];e[3]=s}e[2]*=t[1];e[3]*=t[1];if(t[2]<0){s=e[0];e[0]=e[1];e[1]=s}e[0]*=t[2];e[1]*=t[2]}e[0]+=t[4];e[1]+=t[4];e[2]+=t[5];e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s]}static getAxialAlignedBoundingBox(t,e){const s=Util.applyTransform(t,e),n=Util.applyTransform(t.slice(2,4),e),r=Util.applyTransform([t[0],t[3]],e),a=Util.applyTransform([t[2],t[1]],e);return[Math.min(s[0],n[0],r[0],a[0]),Math.min(s[1],n[1],r[1],a[1]),Math.max(s[0],n[0],r[0],a[0]),Math.max(s[1],n[1],r[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static apply3dTransform(t,e){return[t[0]*e[0]+t[1]*e[1]+t[2]*e[2],t[3]*e[0]+t[4]*e[1]+t[5]*e[2],t[6]*e[0]+t[7]*e[1]+t[8]*e[2]]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],n=t[0]*e[1]+t[1]*e[3],r=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],i=(s+a)/2,o=Math.sqrt((s+a)**2-4*(s*a-r*n))/2,l=i+o||1,c=i-o||1;return[Math.sqrt(l),Math.sqrt(c)]}static normalizeRect(t){const e=t.slice(0);if(t[0]>t[2]){e[0]=t[2];e[2]=t[0]}if(t[1]>t[3]){e[1]=t[3];e[3]=t[1]}return e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,n,a]}static bezierBoundingBox(t,e,s,n,r,a,i,o){const l=[],c=[[],[]];let h,d,u,p,f,g,m,_;for(let c=0;c<2;++c){if(0===c){d=6*t-12*s+6*r;h=-3*t+9*s-9*r+3*i;u=3*s-3*t}else{d=6*e-12*n+6*a;h=-3*e+9*n-9*a+3*o;u=3*n-3*e}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)){f=(-d+_)/(2*h);0<f&&f<1&&l.push(f);g=(-d-_)/(2*h);0<g&&g<1&&l.push(g)}}}let A,b=l.length;const y=b;for(;b--;){p=l[b];A=1-p;c[0][b]=A*A*A*t+3*A*A*p*s+3*A*p*p*r+p*p*p*i;c[1][b]=A*A*A*e+3*A*A*p*n+3*A*p*p*a+p*p*p*o}c[0][y]=t;c[1][y]=e;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])]}}e.Util=Util;const o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToUTF8String(t){return decodeURIComponent(escape(t))}},(t,e,s)=>{s(3)},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.isNodeJS=void 0;const s=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);e.isNodeJS=s},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0});exports.build=exports.RenderTask=exports.PDFWorkerUtil=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__(5),_font_loader=__w_pdfjs_require__(7),_annotation_storage=__w_pdfjs_require__(8),_canvas=__w_pdfjs_require__(10),_worker_options=__w_pdfjs_require__(13),_is_node=__w_pdfjs_require__(3),_message_handler=__w_pdfjs_require__(14),_metadata=__w_pdfjs_require__(15),_optional_content_config=__w_pdfjs_require__(16),_transport_stream=__w_pdfjs_require__(17),_xfa_text=__w_pdfjs_require__(18);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100;let DefaultCanvasFactory=_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;let DefaultCMapReaderFactory=_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;let DefaultStandardFontDataFactory=_display_utils.DOMStandardFontDataFactory,createPDFNetworkStream;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;if(_is_node.isNodeJS){const{NodeCanvasFactory:t,NodeCMapReaderFactory:e,NodeStandardFontDataFactory:s}=__w_pdfjs_require__(19);exports.DefaultCanvasFactory=DefaultCanvasFactory=t;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory=e;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory=s}function setPDFNetworkStreamFactory(t){createPDFNetworkStream=t}function getDocument(t){const e=new PDFDocumentLoadingTask;let s;if("string"==typeof t||t instanceof URL)s={url:t};else if((0,_util.isArrayBuffer)(t))s={data:t};else if(t instanceof PDFDataRangeTransport)s={range:t};else{if("object"!=typeof t)throw new Error("Invalid parameter in getDocument, need either string, URL, Uint8Array, or parameter object.");if(!t.url&&!t.data&&!t.range)throw new Error("Invalid parameter object: need either .data, .range or .url");s=t}const n=Object.create(null);let r=null,a=null;for(const t in s){const e=s[t];switch(t){case"url":if("undefined"!=typeof window)try{n[t]=new URL(e,window.location).href;continue}catch(t){(0,_util.warn)(`Cannot create valid URL: "${t}".`)}else if("string"==typeof e||e instanceof URL){n[t]=e.toString();continue}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.");case"range":r=e;continue;case"worker":a=e;continue;case"data":if(_is_node.isNodeJS&&"undefined"!=typeof Buffer&&e instanceof Buffer)n[t]=new Uint8Array(e);else{if(e instanceof Uint8Array)break;if("string"==typeof e)n[t]=(0,_util.stringToBytes)(e);else if("object"!=typeof e||null===e||isNaN(e.length)){if(!(0,_util.isArrayBuffer)(e))throw new Error("Invalid PDF binary data: either typed array, string, or array-like object is expected in the data property.");n[t]=new Uint8Array(e)}else n[t]=new Uint8Array(e)}continue}n[t]=e}n.CMapReaderFactory=n.CMapReaderFactory||DefaultCMapReaderFactory;n.StandardFontDataFactory=n.StandardFontDataFactory||DefaultStandardFontDataFactory;n.ignoreErrors=!0!==n.stopAtErrors;n.fontExtraProperties=!0===n.fontExtraProperties;n.pdfBug=!0===n.pdfBug;n.enableXfa=!0===n.enableXfa;(!Number.isInteger(n.rangeChunkSize)||n.rangeChunkSize<1)&&(n.rangeChunkSize=DEFAULT_RANGE_CHUNK_SIZE);("string"!=typeof n.docBaseUrl||(0,_display_utils.isDataScheme)(n.docBaseUrl))&&(n.docBaseUrl=null);(!Number.isInteger(n.maxImageSize)||n.maxImageSize<-1)&&(n.maxImageSize=-1);"string"!=typeof n.cMapUrl&&(n.cMapUrl=null);"string"!=typeof n.standardFontDataUrl&&(n.standardFontDataUrl=null);"boolean"!=typeof n.useWorkerFetch&&(n.useWorkerFetch=n.CMapReaderFactory===_display_utils.DOMCMapReaderFactory&&n.StandardFontDataFactory===_display_utils.DOMStandardFontDataFactory);"boolean"!=typeof n.isEvalSupported&&(n.isEvalSupported=!0);"boolean"!=typeof n.disableFontFace&&(n.disableFontFace=_is_node.isNodeJS);"boolean"!=typeof n.useSystemFonts&&(n.useSystemFonts=!_is_node.isNodeJS&&!n.disableFontFace);"object"==typeof n.ownerDocument&&null!==n.ownerDocument||(n.ownerDocument=globalThis.document);"boolean"!=typeof n.disableRange&&(n.disableRange=!1);"boolean"!=typeof n.disableStream&&(n.disableStream=!1);"boolean"!=typeof n.disableAutoFetch&&(n.disableAutoFetch=!1);(0,_util.setVerbosityLevel)(n.verbosity);if(!a){const t={verbosity:n.verbosity,port:_worker_options.GlobalWorkerOptions.workerPort};a=t.port?PDFWorker.fromPort(t):new PDFWorker(t);e._worker=a}const i=e.docId;a.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");const t=_fetchDocument(a,n,r,i),s=new Promise((function(t){let e;r?e=new _transport_stream.PDFDataTransportStream({length:n.length,initialData:n.initialData,progressiveDone:n.progressiveDone,contentDispositionFilename:n.contentDispositionFilename,disableRange:n.disableRange,disableStream:n.disableStream},r):n.data||(e=createPDFNetworkStream({url:n.url,length:n.length,httpHeaders:n.httpHeaders,withCredentials:n.withCredentials,rangeChunkSize:n.rangeChunkSize,disableRange:n.disableRange,disableStream:n.disableStream}));t(e)}));return Promise.all([t,s]).then((function([t,s]){if(e.destroyed)throw new Error("Loading aborted");const r=new _message_handler.MessageHandler(i,t,a.port),o=new WorkerTransport(r,e,s,n);e._transport=o;r.send("Ready",null)}))})).catch(e._capability.reject);return e}async function _fetchDocument(t,e,s,n){if(t.destroyed)throw new Error("Worker was destroyed");if(s){e.length=s.length;e.initialData=s.initialData;e.progressiveDone=s.progressiveDone;e.contentDispositionFilename=s.contentDispositionFilename}const r=await t.messageHandler.sendWithPromise("GetDocRequest",{docId:n,apiVersion:"2.14.305",source:{data:e.data,url:e.url,password:e.password,disableAutoFetch:e.disableAutoFetch,rangeChunkSize:e.rangeChunkSize,length:e.length},maxImageSize:e.maxImageSize,disableFontFace:e.disableFontFace,docBaseUrl:e.docBaseUrl,ignoreErrors:e.ignoreErrors,isEvalSupported:e.isEvalSupported,fontExtraProperties:e.fontExtraProperties,enableXfa:e.enableXfa,useSystemFonts:e.useSystemFonts,cMapUrl:e.useWorkerFetch?e.cMapUrl:null,standardFontDataUrl:e.useWorkerFetch?e.standardFontDataUrl:null});if(t.destroyed)throw new Error("Worker was destroyed");return r}class PDFDocumentLoadingTask{static#t=0;constructor(){this._capability=(0,_util.createPromiseCapability)();this._transport=null;this._worker=null;this.docId="d"+PDFDocumentLoadingTask.#t++;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(t,e,s=!1,n=null){this.length=t;this.initialData=e;this.progressiveDone=s;this.contentDispositionFilename=n;this._rangeListeners=[];this._progressListeners=[];this._progressiveReadListeners=[];this._progressiveDoneListeners=[];this._readyCapability=(0,_util.createPromiseCapability)()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const s of this._progressListeners)s(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(t,e){this._pdfInfo=t;this._transport=e;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(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}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(t=!1){return this._transport.startCleanup(t||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(t,e,s,n,r=!1){this._pageIndex=t;this._pageInfo=e;this._ownerDocument=n;this._transport=s;this._stats=r?new _display_utils.StatTimer:null;this._pdfBug=r;this.commonObjs=s.commonObjs;this.objs=new PDFObjects;this._bitmaps=new Set;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:t,rotation:e=this.rotate,offsetX:s=0,offsetY:n=0,dontFlip:r=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const e=this._transport.getRenderingIntent(t);let s=this._annotationPromises.get(e.cacheKey);if(!s){s=this._transport.getAnnotations(this._pageIndex,e.renderingIntent);this._annotationPromises.set(e.cacheKey,s);s=s.then((t=>{for(const e of t){void 0!==e.titleObj&&Object.defineProperty(e,"title",{get(){(0,_display_utils.deprecated)("`title`-property on annotation, please use `titleObj` instead.");return e.titleObj.str}});void 0!==e.contentsObj&&Object.defineProperty(e,"contents",{get(){(0,_display_utils.deprecated)("`contents`-property on annotation, please use `contentsObj` instead.");return e.contentsObj.str}})}return t}))}return s}getJSActions(){return this._jsActionsPromise||=this._transport.getPageJSActions(this._pageIndex)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:s="display",annotationMode:n=_util.AnnotationMode.ENABLE,transform:r=null,imageLayer:a=null,canvasFactory:i=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:c=null,pageColors: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&&n===_util.AnnotationMode.ENABLE&&(n=_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&&n===_util.AnnotationMode.ENABLE&&(n=_util.AnnotationMode.ENABLE_STORAGE)}this._stats&&this._stats.time("Overall");const d=this._transport.getRenderingIntent(s,n);this.pendingCleanup=!1;l||(l=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}),f=!!(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=t=>{u.renderTasks.delete(g);(this.cleanupAfterRender||f)&&(this.pendingCleanup=!0);this._tryCleanup();if(t){g.capability.reject(t);this._abortOperatorList({intentState:u,reason:t instanceof Error?t:new Error(t)})}else g.capability.resolve();if(this._stats){this._stats.timeEnd("Rendering");this._stats.timeEnd("Overall")}},g=new InternalRenderTask({callback:complete,params:{canvasContext:t,viewport:e,transform:r,imageLayer:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:c,operatorList:u.operatorList,pageIndex:this._pageIndex,canvasFactory:p,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:h});(u.renderTasks||=new Set).add(g);const m=g.task;Promise.all([u.displayReadyCapability.promise,l]).then((([t,e])=>{if(this.pendingCleanup)complete();else{this._stats&&this._stats.time("Rendering");g.initializeGraphics({transparency:t,optionalContentConfig:e});g.operatorListChanged()}})).catch(complete);return m}getOperatorList({intent:t="display",annotationMode:e=_util.AnnotationMode.ENABLE}={}){const s=this._transport.getRenderingIntent(t,e,!0);let n,r=this._intentStates.get(s.cacheKey);if(!r){r=Object.create(null);this._intentStates.set(s.cacheKey,r)}if(!r.opListReadCapability){n=Object.create(null);n.operatorListChanged=function operatorListChanged(){if(r.operatorList.lastChunk){r.opListReadCapability.resolve(r.operatorList);r.renderTasks.delete(n)}};r.opListReadCapability=(0,_util.createPromiseCapability)();(r.renderTasks||=new Set).add(n);r.operatorList={fnArray:[],argsArray:[],lastChunk:!1};this._stats&&this._stats.time("Page Request");this._pumpOperatorList(s)}return r.opListReadCapability.promise}streamTextContent({disableCombineTextItems:t=!1,includeMarkedContent:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,combineTextItems:!0!==t,includeMarkedContent:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>_xfa_text.XfaText.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,s){const n=e.getReader(),r={items:[],styles:Object.create(null)};!function pump(){n.read().then((function({value:e,done:s}){if(s)t(r);else{Object.assign(r.styles,e.styles);r.items.push(...e.items);pump()}}),s)}()}))}getStructTree(){return this._structTreePromise||=this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values()){this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0});if(!e.opListReadCapability)for(const s of e.renderTasks){t.push(s.completed);s.cancel()}}this.objs.clear();for(const t of this._bitmaps)t.close();this._bitmaps.clear();this._annotationPromises.clear();this._jsActionsPromise=null;this._structTreePromise=null;this.pendingCleanup=!1;return Promise.all(t)}cleanup(t=!1){this.pendingCleanup=!0;return this._tryCleanup(t)}_tryCleanup(t=!1){if(!this.pendingCleanup)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this._annotationPromises.clear();this._jsActionsPromise=null;this._structTreePromise=null;t&&this._stats&&(this._stats=new _display_utils.StatTimer);for(const t of this._bitmaps)t.close();this._bitmaps.clear();this.pendingCleanup=!1;return!0}_startRenderPage(t,e){const s=this._intentStates.get(e);if(s){this._stats&&this._stats.timeEnd("Page Request");s.displayReadyCapability&&s.displayReadyCapability.resolve(t)}}_renderPageChunk(t,e){for(let s=0,n=t.length;s<n;s++){e.operatorList.fnArray.push(t.fnArray[s]);e.operatorList.argsArray.push(t.argsArray[s])}e.operatorList.lastChunk=t.lastChunk;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this._tryCleanup()}_pumpOperatorList({renderingIntent:t,cacheKey:e}){const s=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:t&_util.RenderingIntentFlag.ANNOTATIONS_STORAGE?this._transport.annotationStorage.serializable:null}).getReader(),n=this._intentStates.get(e);n.streamReader=s;const pump=()=>{s.read().then((({value:t,done:e})=>{if(e)n.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(t,n);pump()}}),(t=>{n.streamReader=null;if(!this._transport.destroyed){if(n.operatorList){n.operatorList.lastChunk=!0;for(const t of n.renderTasks)t.operatorListChanged();this._tryCleanup()}if(n.displayReadyCapability)n.displayReadyCapability.reject(t);else{if(!n.opListReadCapability)throw t;n.opListReadCapability.reject(t)}}}))};pump()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(!s){if(t.renderTasks.size>0)return;if(e instanceof _display_utils.RenderingCancelledException){t.streamReaderCancelTimeout=setTimeout((()=>{this._abortOperatorList({intentState:t,reason:e,force:!0});t.streamReaderCancelTimeout=null}),RENDERING_CANCELLED_TIMEOUT);return}}t.streamReader.cancel(new _util.AbortException(e.message)).catch((()=>{}));t.streamReader=null;if(!this._transport.destroyed){for(const[e,s]of this._intentStates)if(s===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{constructor(){this._listeners=[];this._deferred=Promise.resolve()}postMessage(t,e){const s={data:structuredClone(t,e)};this._deferred.then((()=>{for(const t of this._listeners)t.call(this,s)}))}addEventListener(t,e){this._listeners.push(e)}removeEventListener(t,e){const s=this._listeners.indexOf(e);this._listeners.splice(s,1)}terminate(){this._listeners.length=0}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;if(_is_node.isNodeJS&&"function"==typeof require){PDFWorkerUtil.isWorkerDisabled=!0;PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js"}else if("object"==typeof document){const t=document?.currentScript?.src;t&&(PDFWorkerUtil.fallbackWorkerSrc=t.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(t,e){let s;try{s=new URL(t);if(!s.origin||"null"===s.origin)return!1}catch(t){return!1}const n=new URL(e,s);return s.origin===n.origin};PDFWorkerUtil.createCDNWrapper=function(t){const e=`importScripts("${t}");`;return URL.createObjectURL(new Blob([e]))};class PDFWorker{static#e=new WeakMap;constructor({name:t=null,port:e=null,verbosity:s=(0,_util.getVerbosityLevel)()}={}){if(e&&PDFWorker.#e.has(e))throw new Error("Cannot use more than one PDFWorker per port.");this.name=t;this.destroyed=!1;this.verbosity=s;this._readyCapability=(0,_util.createPromiseCapability)();this._port=null;this._webWorker=null;this._messageHandler=null;if(e){PDFWorker.#e.set(e,this);this._initializeFromPort(e)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t;this._messageHandler=new _message_handler.MessageHandler("main","worker",t);this._messageHandler.on("ready",(function(){}));this._readyCapability.resolve()}_initialize(){if("undefined"!=typeof Worker&&!PDFWorkerUtil.isWorkerDisabled&&!PDFWorker._mainThreadWorkerMessageHandler){let t=PDFWorker.workerSrc;try{PDFWorkerUtil.isSameOrigin(window.location.href,t)||(t=PDFWorkerUtil.createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t),s=new _message_handler.MessageHandler("main","worker",e),terminateEarly=()=>{e.removeEventListener("error",onWorkerError);s.destroy();e.terminate();this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},onWorkerError=()=>{this._webWorker||terminateEarly()};e.addEventListener("error",onWorkerError);s.on("test",(t=>{e.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else if(t){this._messageHandler=s;this._port=e;this._webWorker=e;this._readyCapability.resolve();s.send("configure",{verbosity:this.verbosity})}else{this._setupFakeWorker();s.destroy();e.terminate()}}));s.on("ready",(t=>{e.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else try{sendTest()}catch(t){this._setupFakeWorker()}}));const sendTest=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};sendTest();return}catch(t){(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((t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new LoopbackPort;this._port=e;const s="fake"+PDFWorkerUtil.fakeWorkerId++,n=new _message_handler.MessageHandler(s+"_worker",s,e);t.setup(n,e);const r=new _message_handler.MessageHandler(s,s+"_worker",e);this._messageHandler=r;this._readyCapability.resolve();r.send("configure",{verbosity:this.verbosity})})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}PDFWorker.#e.delete(this._port);this._port=null;if(this._messageHandler){this._messageHandler.destroy();this._messageHandler=null}}static fromPort(t){if(!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.#e.has(t.port)?this.#e.get(t.port):new PDFWorker(t)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _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(t){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{#s=null;#n=new Map;#r=new Map;#a=null;constructor(t,e,s,n){this.messageHandler=t;this.loadingTask=e;this.commonObjs=new PDFObjects;this.fontLoader=new _font_loader.FontLoader({docId:e.docId,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),ownerDocument:n.ownerDocument,styleElement:n.styleElement});this._params=n;if(!n.useWorkerFetch){this.CMapReaderFactory=new n.CMapReaderFactory({baseUrl:n.cMapUrl,isCompressed:n.cMapPacked});this.StandardFontDataFactory=new n.StandardFontDataFactory({baseUrl:n.standardFontDataUrl})}this.destroyed=!1;this.destroyCapability=null;this._passwordCapability=null;this._networkStream=s;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.#s}getRenderingIntent(t,e=_util.AnnotationMode.ENABLE,s=!1){let n=_util.RenderingIntentFlag.DISPLAY,r="";switch(t){case"any":n=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":n=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${t}`)}switch(e){case _util.AnnotationMode.DISABLE:n+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:n+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:n+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE;r=this.annotationStorage.hash;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(n+=_util.RenderingIntentFlag.OPLIST);return{renderingIntent:n,cacheKey:`${n}_${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 t=[];for(const e of this.#n.values())t.push(e._destroy());this.#n.clear();this.#r.clear();this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);t.push(e);Promise.all(t).then((()=>{this.commonObjs.clear();this.fontLoader.clear();this.#a=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:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available.");this._fullReader=this._networkStream.getFullReader();this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}};e.onPull=()=>{this._fullReader.read().then((function({value:t,done:s}){if(s)e.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(t),"GetReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])}})).catch((t=>{e.error(t)}))};e.onCancel=t=>{this._fullReader.cancel(t);e.ready.catch((t=>{if(!this.destroyed)throw t}))}}));t.on("ReaderHeadersReady",(t=>{const s=(0,_util.createPromiseCapability)(),n=this._fullReader;n.headersReady.then((()=>{if(!n.isStreamingSupported||!n.isRangeSupported){this._lastProgress&&e.onProgress?.(this._lastProgress);n.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}}s.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})}),s.reject);return s.promise}));t.on("GetRangeReader",((t,e)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);if(s){e.onPull=()=>{s.read().then((function({value:t,done:s}){if(s)e.close();else{(0,_util.assert)((0,_util.isArrayBuffer)(t),"GetRangeReader - expected an ArrayBuffer.");e.enqueue(new Uint8Array(t),1,[t])}})).catch((t=>{e.error(t)}))};e.onCancel=t=>{s.cancel(t);e.ready.catch((t=>{if(!this.destroyed)throw t}))}}else e.close()}));t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages;this._htmlForXfa=t.htmlForXfa;delete t.htmlForXfa;e._capability.resolve(new PDFDocumentProxy(t,this))}));t.on("DocException",(function(t){let s;switch(t.name){case"PasswordException":s=new _util.PasswordException(t.message,t.code);break;case"InvalidPDFException":s=new _util.InvalidPDFException(t.message);break;case"MissingPDFException":s=new _util.MissingPDFException(t.message);break;case"UnexpectedResponseException":s=new _util.UnexpectedResponseException(t.message,t.status);break;case"UnknownErrorException":s=new _util.UnknownErrorException(t.message,t.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}e._capability.reject(s)}));t.on("PasswordRequest",(t=>{this._passwordCapability=(0,_util.createPromiseCapability)();if(e.onPassword){const updatePassword=t=>{t instanceof Error?this._passwordCapability.reject(t):this._passwordCapability.resolve({password:t})};try{e.onPassword(updatePassword,t.code)}catch(t){this._passwordCapability.reject(t)}}else this._passwordCapability.reject(new _util.PasswordException(t.message,t.code));return this._passwordCapability.promise}));t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length});this.downloadInfoCapability.resolve(t)}));t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#n.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}));t.on("commonobj",(([e,s,n])=>{if(!this.destroyed&&!this.commonObjs.has(e))switch(s){case"Font":const r=this._params;if("error"in n){const t=n.error;(0,_util.warn)(`Error during font loading: ${t}`);this.commonObjs.resolve(e,t);break}let a=null;r.pdfBug&&globalThis.FontInspector?.enabled&&(a={registerFont(t,e){globalThis.FontInspector.fontAdded(t,e)}});const i=new _font_loader.FontFaceObject(n,{isEvalSupported:r.isEvalSupported,disableFontFace:r.disableFontFace,ignoreErrors:r.ignoreErrors,onUnsupportedFeature:this._onUnsupportedFeature.bind(this),fontRegistry:a});this.fontLoader.bind(i).catch((s=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r.fontExtraProperties&&i.data&&(i.data=null);this.commonObjs.resolve(e,i)}));break;case"FontPath":case"Image":this.commonObjs.resolve(e,n);break;default:throw new Error(`Got unknown common object type ${s}`)}}));t.on("obj",(([t,e,s,n])=>{if(this.destroyed)return;const r=this.#n.get(e);if(!r.objs.has(t))switch(s){case"Image":r.objs.resolve(t,n);const e=8e6;if(n){let t;if(n.bitmap){const{bitmap:e,width:s,height:a}=n;t=s*a*4;r._bitmaps.add(e)}else t=n.data?.length||0;t>e&&(r.cleanupAfterRender=!0)}break;case"Pattern":r.objs.resolve(t,n);break;default:throw new Error(`Got unknown object type ${s}`)}}));t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}));t.on("DocStats",(t=>{this.destroyed||(this.#s=Object.freeze({streamTypes:Object.freeze(t.streamTypes),fontTypes:Object.freeze(t.fontTypes)}))}));t.on("UnsupportedFeature",this._onUnsupportedFeature.bind(this));t.on("FetchBuiltInCMap",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.CMapReaderFactory?this.CMapReaderFactory.fetch(t):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))));t.on("FetchStandardFontData",(t=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.StandardFontDataFactory?this.StandardFontDataFactory.fetch(t):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}_onUnsupportedFeature({featureId:t}){this.destroyed||this.loadingTask.onUnsupportedFeature?.(t)}getData(){return this.messageHandler.sendWithPromise("GetData",null)}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,s=this.#r.get(e);if(s)return s;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((t=>{if(this.destroyed)throw new Error("Transport destroyed");const s=new PDFPageProxy(e,t,this,this._params.ownerDocument,this._params.pdfBug);this.#n.set(e,s);return s}));this.#r.set(e,n);return n}getPageIndex(t){return"object"!=typeof t||null===t||!Number.isInteger(t.num)||t.num<0||!Number.isInteger(t.gen)||t.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen})}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}saveDocument(){return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:this.annotationStorage.serializable,filename:this._fullReader?.filename??null}).finally((()=>{this.annotationStorage.resetModified()}))}getFieldObjects(){return this._getFieldObjectsPromise||=this.messageHandler.sendWithPromise("GetFieldObjects",null)}hasJSActions(){return this._hasJSActionsPromise||=this.messageHandler.sendWithPromise("HasJSActions",null)}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getJavaScript(){return this.messageHandler.sendWithPromise("GetJavaScript",null)}getDocJSActions(){return this.messageHandler.sendWithPromise("GetDocJSActions",null)}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((t=>new _optional_content_config.OptionalContentConfig(t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){return this.#a||=this.messageHandler.sendWithPromise("GetMetadata",null).then((t=>({info:t[0],metadata:t[1]?new _metadata.Metadata(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})))}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){await this.messageHandler.sendWithPromise("Cleanup",null);if(!this.destroyed){for(const t of this.#n.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear();t||this.fontLoader.clear();this.#a=null;this._getFieldObjectsPromise=null;this._hasJSActionsPromise=null}}get loadingParams(){const t=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:t.disableAutoFetch,enableXfa:t.enableXfa})}}class PDFObjects{#i=Object.create(null);#o(t){const e=this.#i[t];return e||(this.#i[t]={capability:(0,_util.createPromiseCapability)(),data:null})}get(t,e=null){if(e){const s=this.#o(t);s.capability.promise.then((()=>e(s.data)));return null}const s=this.#i[t];if(!s?.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){return this.#i[t]?.capability.settled||!1}resolve(t,e=null){const s=this.#o(t);s.data=e;s.capability.resolve()}clear(){this.#i=Object.create(null)}}class RenderTask{constructor(t){this._internalRenderTask=t;this.onContinue=null}get promise(){return this._internalRenderTask.capability.promise}cancel(){this._internalRenderTask.cancel()}}exports.RenderTask=RenderTask;class InternalRenderTask{static#l=new WeakSet;constructor({callback:t,params:e,objs:s,commonObjs:n,annotationCanvasMap:r,operatorList:a,pageIndex:i,canvasFactory:o,useRequestAnimationFrame:l=!1,pdfBug:c=!1,pageColors:h=null}){this.callback=t;this.params=e;this.objs=s;this.commonObjs=n;this.annotationCanvasMap=r;this.operatorListIdx=null;this.operatorList=a;this._pageIndex=i;this.canvasFactory=o;this._pdfBug=c;this.pageColors=h;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===l&&"undefined"!=typeof window;this.cancelled=!1;this.capability=(0,_util.createPromiseCapability)();this.task=new RenderTask(this);this._cancelBound=this.cancel.bind(this);this._continueBound=this._continue.bind(this);this._scheduleNextBound=this._scheduleNext.bind(this);this._nextBound=this._next.bind(this);this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(InternalRenderTask.#l.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");InternalRenderTask.#l.add(this._canvas)}if(this._pdfBug&&globalThis.StepperManager?.enabled){this.stepper=globalThis.StepperManager.create(this._pageIndex);this.stepper.init(this.operatorList);this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint()}const{canvasContext:s,viewport:n,transform:r,imageLayer:a,background:i}=this.params;this.gfx=new _canvas.CanvasGraphics(s,this.commonObjs,this.objs,this.canvasFactory,a,e,this.annotationCanvasMap,this.pageColors);this.gfx.beginDrawing({transform:r,viewport:n,transparency:t,background:i});this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback&&this.graphicsReadyCallback()}cancel(t=null){this.running=!1;this.cancelled=!0;this.gfx&&this.gfx.endDrawing();this._canvas&&InternalRenderTask.#l.delete(this._canvas);this.callback(t||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,"canvas"))}operatorListChanged(){if(this.graphicsReady){this.stepper&&this.stepper.updateOperatorList(this.operatorList);this.running||this._continue()}else this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0;this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?window.requestAnimationFrame((()=>{this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(!this.cancelled){this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper);if(this.operatorListIdx===this.operatorList.argsArray.length){this.running=!1;if(this.operatorList.lastChunk){this.gfx.endDrawing();this._canvas&&InternalRenderTask.#l.delete(this._canvas);this.callback()}}}}}const version="2.14.305";exports.version=version;const build="eaaa8b4ad";exports.build=build},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.StatTimer=e.RenderingCancelledException=e.PixelsPerInch=e.PageViewport=e.PDFDateString=e.DOMStandardFontDataFactory=e.DOMSVGFactory=e.DOMCanvasFactory=e.DOMCMapReaderFactory=void 0;e.deprecated=function deprecated(t){console.log("Deprecated API usage: "+t)};e.getFilenameFromUrl=function getFilenameFromUrl(t){const e=t.indexOf("#"),s=t.indexOf("?"),n=Math.min(e>0?e:t.length,s>0?s:t.length);return t.substring(t.lastIndexOf("/",n)+1,n)};e.getPdfFilenameFromUrl=function getPdfFilenameFromUrl(t,e="document.pdf"){if("string"!=typeof t)return e;if(isDataScheme(t)){(0,r.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return e}const s=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let a=s.exec(n[1])||s.exec(n[2])||s.exec(n[3]);if(a){a=a[0];if(a.includes("%"))try{a=s.exec(decodeURIComponent(a))[0]}catch(t){}}return a||e};e.getXfaPageViewport=function getXfaPageViewport(t,{scale:e=1,rotation:s=0}){const{width:n,height:r}=t.attributes.style,a=[0,0,parseInt(n),parseInt(r)];return new PageViewport({viewBox:a,scale:e,rotation:s})};e.isDataScheme=isDataScheme;e.isPdfFile=function isPdfFile(t){return"string"==typeof t&&/\.pdf$/i.test(t)};e.isValidFetchUrl=isValidFetchUrl;e.loadScript=function loadScript(t,e=!1){return new Promise(((s,n)=>{const r=document.createElement("script");r.src=t;r.onload=function(t){e&&r.remove();s(t)};r.onerror=function(){n(new Error(`Cannot load script at: ${r.src}`))};(document.head||document.documentElement).appendChild(r)}))};var n=s(6),r=s(1);class PixelsPerInch{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}e.PixelsPerInch=PixelsPerInch;class DOMCanvasFactory extends n.BaseCanvasFactory{constructor({ownerDocument:t=globalThis.document}={}){super();this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");s.width=t;s.height=e;return s}}e.DOMCanvasFactory=DOMCanvasFactory;async function fetchData(t,e=!1){if(isValidFetchUrl(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);return e?new Uint8Array(await s.arrayBuffer()):(0,r.stringToBytes)(await s.text())}return new Promise(((s,n)=>{const a=new XMLHttpRequest;a.open("GET",t,!0);e&&(a.responseType="arraybuffer");a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){let t;e&&a.response?t=new Uint8Array(a.response):!e&&a.responseText&&(t=(0,r.stringToBytes)(a.responseText));if(t){s(t);return}}n(new Error(a.statusText))}};a.send(null)}))}class DOMCMapReaderFactory extends n.BaseCMapReaderFactory{_fetchData(t,e){return fetchData(t,this.isCompressed).then((t=>({cMapData:t,compressionType:e})))}}e.DOMCMapReaderFactory=DOMCMapReaderFactory;class DOMStandardFontDataFactory extends n.BaseStandardFontDataFactory{_fetchData(t){return fetchData(t,!0)}}e.DOMStandardFontDataFactory=DOMStandardFontDataFactory;class DOMSVGFactory extends n.BaseSVGFactory{_createSVG(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}}e.DOMSVGFactory=DOMSVGFactory;class PageViewport{constructor({viewBox:t,scale:e,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t;this.scale=e;this.rotation=s;this.offsetX=n;this.offsetY=r;const i=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,c,h,d,u,p,f,g;(s%=360)<0&&(s+=360);switch(s){case 180:l=-1;c=0;h=0;d=1;break;case 90:l=0;c=1;h=1;d=0;break;case 270:l=0;c=-1;h=-1;d=0;break;case 0:l=1;c=0;h=0;d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a){h=-h;d=-d}if(0===l){u=Math.abs(o-t[1])*e+n;p=Math.abs(i-t[0])*e+r;f=Math.abs(t[3]-t[1])*e;g=Math.abs(t[2]-t[0])*e}else{u=Math.abs(i-t[0])*e+n;p=Math.abs(o-t[1])*e+r;f=Math.abs(t[2]-t[0])*e;g=Math.abs(t[3]-t[1])*e}this.transform=[l*e,c*e,h*e,d*e,u-l*e*i-h*e*o,p-c*e*i-d*e*o];this.width=f;this.height=g}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:s=this.offsetX,offsetY:n=this.offsetY,dontFlip:r=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:n,dontFlip:r})}convertToViewportPoint(t,e){return r.Util.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=r.Util.applyTransform([t[0],t[1]],this.transform),s=r.Util.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return r.Util.applyInverseTransform([t,e],this.transform)}}e.PageViewport=PageViewport;class RenderingCancelledException extends r.BaseException{constructor(t,e){super(t,"RenderingCancelledException");this.type=e}}e.RenderingCancelledException=RenderingCancelledException;function isDataScheme(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}e.StatTimer=class StatTimer{constructor(){this.started=Object.create(null);this.times=[]}time(t){t in this.started&&(0,r.warn)(`Timer is already running for ${t}`);this.started[t]=Date.now()}timeEnd(t){t in this.started||(0,r.warn)(`Timer has not been started for ${t}`);this.times.push({name:t,start:this.started[t],end:Date.now()});delete this.started[t]}toString(){const t=[];let e=0;for(const t of this.times){const s=t.name;s.length>e&&(e=s.length)}for(const s of this.times){const n=s.end-s.start;t.push(`${s.name.padEnd(e)} ${n}ms\n`)}return t.join("")}};function isValidFetchUrl(t,e){try{const{protocol:s}=e?new URL(t,e):new URL(t);return"http:"===s||"https:"===s}catch(t){return!1}}let a;e.PDFDateString=class PDFDateString{static toDateObject(t){if(!t||"string"!=typeof t)return null;a||(a=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=a.exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let i=parseInt(e[4],10);i=i>=0&&i<=23?i:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const c=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;d=d>=0&&d<=59?d:0;if("-"===c){i+=h;o+=d}else if("+"===c){i-=h;o-=d}return new Date(Date.UTC(s,n,r,i,o,l))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.BaseStandardFontDataFactory=e.BaseSVGFactory=e.BaseCanvasFactory=e.BaseCMapReaderFactory=void 0;var n=s(1);class BaseCanvasFactory{constructor(){this.constructor===BaseCanvasFactory&&(0,n.unreachable)("Cannot initialize BaseCanvasFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d")}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e;t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0;t.canvas.height=0;t.canvas=null;t.context=null}_createCanvas(t,e){(0,n.unreachable)("Abstract method `_createCanvas` called.")}}e.BaseCanvasFactory=BaseCanvasFactory;class BaseCMapReaderFactory{constructor({baseUrl:t=null,isCompressed:e=!1}){this.constructor===BaseCMapReaderFactory&&(0,n.unreachable)("Cannot initialize BaseCMapReaderFactory.");this.baseUrl=t;this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":""),s=this.isCompressed?n.CMapCompressionType.BINARY:n.CMapCompressionType.NONE;return this._fetchData(e,s).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}_fetchData(t,e){(0,n.unreachable)("Abstract method `_fetchData` called.")}}e.BaseCMapReaderFactory=BaseCMapReaderFactory;class BaseStandardFontDataFactory{constructor({baseUrl:t=null}){this.constructor===BaseStandardFontDataFactory&&(0,n.unreachable)("Cannot initialize BaseStandardFontDataFactory.");this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetchData(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}_fetchData(t){(0,n.unreachable)("Abstract method `_fetchData` called.")}}e.BaseStandardFontDataFactory=BaseStandardFontDataFactory;class BaseSVGFactory{constructor(){this.constructor===BaseSVGFactory&&(0,n.unreachable)("Cannot initialize BaseSVGFactory.")}create(t,e){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");s.setAttribute("version","1.1");s.setAttribute("width",`${t}px`);s.setAttribute("height",`${e}px`);s.setAttribute("preserveAspectRatio","none");s.setAttribute("viewBox",`0 0 ${t} ${e}`);return s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){(0,n.unreachable)("Abstract method `_createSVG` called.")}}e.BaseSVGFactory=BaseSVGFactory},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.FontLoader=e.FontFaceObject=void 0;var n=s(1);class BaseFontLoader{constructor({docId:t,onUnsupportedFeature:e,ownerDocument:s=globalThis.document,styleElement:r=null}){this.constructor===BaseFontLoader&&(0,n.unreachable)("Cannot initialize BaseFontLoader.");this.docId=t;this._onUnsupportedFeature=e;this._document=s;this.nativeFontFaces=[];this.styleElement=null}addNativeFontFace(t){this.nativeFontFaces.push(t);this._document.fonts.add(t)}insertRule(t){let e=this.styleElement;if(!e){e=this.styleElement=this._document.createElement("style");e.id=`PDFJS_FONT_STYLE_TAG_${this.docId}`;this._document.documentElement.getElementsByTagName("head")[0].appendChild(e)}const s=e.sheet;s.insertRule(t,s.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.length=0;if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async bind(t){if(t.attached||t.missingFile)return;t.attached=!0;if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){this._onUnsupportedFeature({featureId:n.UNSUPPORTED_FEATURES.errorFontLoadNative});(0,n.warn)(`Failed to load font '${e.family}': '${s}'.`);t.disableFontFace=!0;throw s}}return}const e=t.createFontFaceRule();if(e){this.insertRule(e);if(this.isSyncFontLoadingSupported)return;await new Promise((s=>{const n=this._queueLoadingCallback(s);this._prepareFontLoadEvent([e],[t],n)}))}}_queueLoadingCallback(t){(0,n.unreachable)("Abstract method `_queueLoadingCallback`.")}get isFontLoadingAPISupported(){const t=!!this._document?.fonts;return(0,n.shadow)(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){(0,n.unreachable)("Abstract method `isSyncFontLoadingSupported`.")}get _loadTestFont(){(0,n.unreachable)("Abstract method `_loadTestFont`.")}_prepareFontLoadEvent(t,e,s){(0,n.unreachable)("Abstract method `_prepareFontLoadEvent`.")}}let r;e.FontLoader=r;e.FontLoader=r=class GenericFontLoader extends BaseFontLoader{constructor(t){super(t);this.loadingContext={requests:[],nextRequestId:0};this.loadTestFontId=0}get isSyncFontLoadingSupported(){let t=!1;if("undefined"==typeof navigator)t=!0;else{/Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent)?.[1]>=14&&(t=!0)}return(0,n.shadow)(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const e=this.loadingContext,s={id:"pdfjs-font-loading-"+e.nextRequestId++,done:!1,complete:function completeRequest(){(0,n.assert)(!s.done,"completeRequest() cannot be called twice.");s.done=!0;for(;e.requests.length>0&&e.requests[0].done;){const t=e.requests.shift();setTimeout(t.callback,0)}},callback:t};e.requests.push(s);return s}get _loadTestFont(){return(0,n.shadow)(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e,s){function int32(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function spliceString(t,e,s,n){return t.substring(0,e)+n+t.substring(e+s)}let r,a;const i=this._document.createElement("canvas");i.width=1;i.height=1;const o=i.getContext("2d");let l=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=spliceString(h,976,c.length,c);const d=1482184792;let u=int32(h,16);for(r=0,a=c.length-3;r<a;r+=4)u=u-d+int32(c,r)|0;r<c.length&&(u=u-d+int32(c+"XXX",r)|0);h=spliceString(h,16,4,(0,n.string32)(u));const p=`@font-face {font-family:"${c}";src:${`url(data:font/opentype;base64,${btoa(h)});`}}`;this.insertRule(p);const f=[];for(const t of e)f.push(t.loadedName);f.push(c);const g=this._document.createElement("div");g.style.visibility="hidden";g.style.width=g.style.height="10px";g.style.position="absolute";g.style.top=g.style.left="0px";for(const t of f){const e=this._document.createElement("span");e.textContent="Hi";e.style.fontFamily=t;g.appendChild(e)}this._document.body.appendChild(g);!function isFontReady(t,e){l++;if(l>30){(0,n.warn)("Load test font never loaded.");e();return}o.font="30px "+t;o.fillText(".",0,20);o.getImageData(0,0,1,1).data[3]>0?e():setTimeout(isFontReady.bind(null,t,e))}(c,(()=>{g.remove();s.complete()}))}};e.FontFaceObject=class FontFaceObject{constructor(t,{isEvalSupported:e=!0,disableFontFace:s=!1,ignoreErrors:n=!1,onUnsupportedFeature:r,fontRegistry:a=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.isEvalSupported=!1!==e;this.disableFontFace=!0===s;this.ignoreErrors=!0===n;this._onUnsupportedFeature=r;this.fontRegistry=a}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`);t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});this.fontRegistry&&this.fontRegistry.registerFont(this);return t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=(0,n.bytesToString)(this.data),e=`url(data:${this.mimetype};base64,${btoa(t)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`);s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;this.fontRegistry&&this.fontRegistry.registerFont(this,e);return s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(t){if(!this.ignoreErrors)throw t;this._onUnsupportedFeature({featureId:n.UNSUPPORTED_FEATURES.errorFontGetPath});(0,n.warn)(`getPathGenerator - ignoring character: "${t}".`);return this.compiledGlyphs[e]=function(t,e){}}if(this.isEvalSupported&&n.FeatureTest.isEvalSupported){const t=[];for(const e of s){const s=void 0!==e.args?e.args.join(","):"";t.push("c.",e.cmd,"(",s,");\n")}return this.compiledGlyphs[e]=new Function("c","size",t.join(""))}return this.compiledGlyphs[e]=function(t,e){for(const n of s){"scale"===n.cmd&&(n.args=[e,-e]);t[n.cmd].apply(t,n.args)}}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.AnnotationStorage=void 0;var n=s(9),r=s(1);e.AnnotationStorage=class AnnotationStorage{constructor(){this._storage=new Map;this._modified=!1;this.onSetModified=null;this.onResetModified=null}getValue(t,e){const s=this._storage.get(t);return void 0===s?e:Object.assign(e,s)}getRawValue(t){return this._storage.get(t)}setValue(t,e){const s=this._storage.get(t);let n=!1;if(void 0!==s){for(const[t,r]of Object.entries(e))if(s[t]!==r){n=!0;s[t]=r}}else{n=!0;this._storage.set(t,e)}n&&this._setModified()}getAll(){return this._storage.size>0?(0,r.objectFromMap)(this._storage):null}get size(){return this._storage.size}_setModified(){if(!this._modified){this._modified=!0;"function"==typeof this.onSetModified&&this.onSetModified()}}resetModified(){if(this._modified){this._modified=!1;"function"==typeof this.onResetModified&&this.onResetModified()}}get serializable(){return this._storage.size>0?this._storage:null}get hash(){const t=new n.MurmurHash3_64;for(const[e,s]of this._storage)t.update(`${e}:${JSON.stringify(s)}`);return t.hexdigest()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.MurmurHash3_64=void 0;var n=s(1);const r=3285377520,a=4294901760,i=65535;e.MurmurHash3_64=class MurmurHash3_64{constructor(t){this.h1=t?4294967295&t:r;this.h2=t?4294967295&t:r}update(t){let e,s;if("string"==typeof t){e=new Uint8Array(2*t.length);s=0;for(let n=0,r=t.length;n<r;n++){const r=t.charCodeAt(n);if(r<=255)e[s++]=r;else{e[s++]=r>>>8;e[s++]=255&r}}}else{if(!(0,n.isArrayBuffer)(t))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");e=t.slice();s=e.byteLength}const r=s>>2,o=s-4*r,l=new Uint32Array(e.buffer,0,r);let c=0,h=0,d=this.h1,u=this.h2;const p=3432918353,f=461845907,g=11601,m=13715;for(let t=0;t<r;t++)if(1&t){c=l[t];c=c*p&a|c*g&i;c=c<<15|c>>>17;c=c*f&a|c*m&i;d^=c;d=d<<13|d>>>19;d=5*d+3864292196}else{h=l[t];h=h*p&a|h*g&i;h=h<<15|h>>>17;h=h*f&a|h*m&i;u^=h;u=u<<13|u>>>19;u=5*u+3864292196}c=0;switch(o){case 3:c^=e[4*r+2]<<16;case 2:c^=e[4*r+1]<<8;case 1:c^=e[4*r];c=c*p&a|c*g&i;c=c<<15|c>>>17;c=c*f&a|c*m&i;1&r?d^=c:u^=c}this.h1=d;this.h2=u}hexdigest(){let t=this.h1,e=this.h2;t^=e>>>1;t=3981806797*t&a|36045*t&i;e=4283543511*e&a|(2950163797*(e<<16|t>>>16)&a)>>>16;t^=e>>>1;t=444984403*t&a|60499*t&i;e=3301882366*e&a|(3120437893*(e<<16|t>>>16)&a)>>>16;t^=e>>>1;const s=(t>>>0).toString(16),n=(e>>>0).toString(16);return s.padStart(8,"0")+n.padStart(8,"0")}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.CanvasGraphics=void 0;var n=s(1),r=s(11),a=s(12),i=s(3),o=s(5);const l=4096,c=16;function addContextCurrentTransform(t){t._transformStack&&(t._transformStack=[]);if(!t.mozCurrentTransform){t._originalSave=t.save;t._originalRestore=t.restore;t._originalRotate=t.rotate;t._originalScale=t.scale;t._originalTranslate=t.translate;t._originalTransform=t.transform;t._originalSetTransform=t.setTransform;t._originalResetTransform=t.resetTransform;t._transformMatrix=t._transformMatrix||[1,0,0,1,0,0];t._transformStack=[];try{const e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),"lineWidth");t._setLineWidth=e.set;t._getLineWidth=e.get;Object.defineProperty(t,"lineWidth",{set:function setLineWidth(t){this._setLineWidth(1.000001*t)},get:function getLineWidth(){return this._getLineWidth()}})}catch(t){}Object.defineProperty(t,"mozCurrentTransform",{get:function getCurrentTransform(){return this._transformMatrix}});Object.defineProperty(t,"mozCurrentTransformInverse",{get:function getCurrentTransformInverse(){const[t,e,s,n,r,a]=this._transformMatrix,i=t*n-e*s,o=e*s-t*n;return[n/i,e/o,s/o,t/i,(n*r-s*a)/o,(e*r-t*a)/i]}});t.save=function ctxSave(){const t=this._transformMatrix;this._transformStack.push(t);this._transformMatrix=t.slice(0,6);this._originalSave()};t.restore=function ctxRestore(){0===this._transformStack.length&&(0,n.warn)("Tried to restore a ctx when the stack was already empty.");const t=this._transformStack.pop();if(t){this._transformMatrix=t;this._originalRestore()}};t.translate=function ctxTranslate(t,e){const s=this._transformMatrix;s[4]=s[0]*t+s[2]*e+s[4];s[5]=s[1]*t+s[3]*e+s[5];this._originalTranslate(t,e)};t.scale=function ctxScale(t,e){const s=this._transformMatrix;s[0]*=t;s[1]*=t;s[2]*=e;s[3]*=e;this._originalScale(t,e)};t.transform=function ctxTransform(e,s,n,r,a,i){const o=this._transformMatrix;this._transformMatrix=[o[0]*e+o[2]*s,o[1]*e+o[3]*s,o[0]*n+o[2]*r,o[1]*n+o[3]*r,o[0]*a+o[2]*i+o[4],o[1]*a+o[3]*i+o[5]];t._originalTransform(e,s,n,r,a,i)};t.setTransform=function ctxSetTransform(e,s,n,r,a,i){this._transformMatrix=[e,s,n,r,a,i];t._originalSetTransform(e,s,n,r,a,i)};t.resetTransform=function ctxResetTransform(){this._transformMatrix=[1,0,0,1,0,0];t._originalResetTransform()};t.rotate=function ctxRotate(t){const e=Math.cos(t),s=Math.sin(t),n=this._transformMatrix;this._transformMatrix=[n[0]*e+n[2]*s,n[1]*e+n[3]*s,n[0]*-s+n[2]*e,n[1]*-s+n[3]*e,n[4],n[5]];this._originalRotate(t)}}}class CachedCanvases{constructor(t){this.canvasFactory=t;this.cache=Object.create(null)}getCanvas(t,e,s,n){let r;if(void 0!==this.cache[t]){r=this.cache[t];this.canvasFactory.reset(r,e,s);r.context.setTransform(1,0,0,1,0,0)}else{r=this.canvasFactory.create(e,s);this.cache[t]=r}n&&addContextCurrentTransform(r.context);return r}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e);delete this.cache[t]}}}function drawImageAtIntegerCoords(t,e,s,n,r,a,i,o,l,c){const[h,d,u,p,f,g]=t.mozCurrentTransform;if(0===d&&0===u){const m=i*h+f,_=Math.round(m),A=o*p+g,b=Math.round(A),y=(i+l)*h+f,S=Math.abs(Math.round(y)-_)||1,x=(o+c)*p+g,v=Math.abs(Math.round(x)-b)||1;t.setTransform(Math.sign(h),0,0,Math.sign(p),_,b);t.drawImage(e,s,n,r,a,0,0,S,v);t.setTransform(h,d,u,p,f,g);return[S,v]}if(0===h&&0===p){const m=o*u+f,_=Math.round(m),A=i*d+g,b=Math.round(A),y=(o+c)*u+f,S=Math.abs(Math.round(y)-_)||1,x=(i+l)*d+g,v=Math.abs(Math.round(x)-b)||1;t.setTransform(0,Math.sign(d),Math.sign(u),0,_,b);t.drawImage(e,s,n,r,a,0,0,v,S);t.setTransform(h,d,u,p,f,g);return[v,S]}t.drawImage(e,s,n,r,a,i,o,l,c);return[Math.hypot(h,d)*l,Math.hypot(u,p)*c]}class CanvasExtraState{constructor(t,e){this.alphaIsShape=!1;this.fontSize=0;this.fontSizeScale=1;this.textMatrix=n.IDENTITY_MATRIX;this.textMatrixScale=1;this.fontMatrix=n.FONT_IDENTITY_MATRIX;this.leading=0;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRenderingMode=n.TextRenderingMode.FILL;this.textRise=0;this.fillColor="#000000";this.strokeColor="#000000";this.patternFill=!1;this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.activeSMask=null;this.transferMaps=null;this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);t.clipBox=this.clipBox.slice();return t}setCurrentPoint(t,e){this.x=t;this.y=e}updatePathMinMax(t,e,s){[e,s]=n.Util.applyTransform([e,s],t);this.minX=Math.min(this.minX,e);this.minY=Math.min(this.minY,s);this.maxX=Math.max(this.maxX,e);this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=n.Util.applyTransform(e,t),r=n.Util.applyTransform(e.slice(2),t);this.minX=Math.min(this.minX,s[0],r[0]);this.minY=Math.min(this.minY,s[1],r[1]);this.maxX=Math.max(this.maxX,s[0],r[0]);this.maxY=Math.max(this.maxY,s[1],r[1])}updateScalingPathMinMax(t,e){n.Util.scaleMinMax(t,e);this.minX=Math.min(this.minX,e[0]);this.maxX=Math.max(this.maxX,e[1]);this.minY=Math.min(this.minY,e[2]);this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,r,a,i,o,l,c,h){const d=n.Util.bezierBoundingBox(e,s,r,a,i,o,l,c);if(h){h[0]=Math.min(h[0],d[0],d[2]);h[1]=Math.max(h[1],d[0],d[2]);h[2]=Math.min(h[2],d[1],d[3]);h[3]=Math.max(h[3],d[1],d[3])}else this.updateRectMinMax(t,d)}getPathBoundingBox(t=r.PathType.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===r.PathType.STROKE){e||(0,n.unreachable)("Stroke bounding box must include transform.");const t=n.Util.singularValueDecompose2dScale(e),r=t[0]*this.lineWidth/2,a=t[1]*this.lineWidth/2;s[0]-=r;s[1]-=a;s[2]+=r;s[3]+=a}return s}updateClipFromPath(){const t=n.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t;this.minX=1/0;this.minY=1/0;this.maxX=0;this.maxY=0}getClippedPathBoundingBox(t=r.PathType.FILL,e=null){return n.Util.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function putBinaryImageData(t,e,s=null){if("undefined"!=typeof ImageData&&e instanceof ImageData){t.putImageData(e,0,0);return}const r=e.height,a=e.width,i=r%c,o=(r-i)/c,l=0===i?o:o+1,h=t.createImageData(a,c);let d,u=0;const p=e.data,f=h.data;let g,m,_,A,b,y,S,x;if(s)switch(s.length){case 1:b=s[0];y=s[0];S=s[0];x=s[0];break;case 4:b=s[0];y=s[1];S=s[2];x=s[3]}if(e.kind===n.ImageKind.GRAYSCALE_1BPP){const e=p.byteLength,s=new Uint32Array(f.buffer,0,f.byteLength>>2),r=s.length,A=a+7>>3;let b=4294967295,y=n.FeatureTest.isLittleEndian?4278190080:255;x&&255===x[0]&&0===x[255]&&([b,y]=[y,b]);for(g=0;g<l;g++){_=g<o?c:i;d=0;for(m=0;m<_;m++){const t=e-u;let n=0;const r=t>A?a:8*t-7,i=-8&r;let o=0,l=0;for(;n<i;n+=8){l=p[u++];s[d++]=128&l?b:y;s[d++]=64&l?b:y;s[d++]=32&l?b:y;s[d++]=16&l?b:y;s[d++]=8&l?b:y;s[d++]=4&l?b:y;s[d++]=2&l?b:y;s[d++]=1&l?b:y}for(;n<r;n++){if(0===o){l=p[u++];o=128}s[d++]=l&o?b:y;o>>=1}}for(;d<r;)s[d++]=0;t.putImageData(h,0,g*c)}}else if(e.kind===n.ImageKind.RGBA_32BPP){const e=!!(b||y||S);m=0;A=a*c*4;for(g=0;g<o;g++){f.set(p.subarray(u,u+A));u+=A;if(e)for(let t=0;t<A;t+=4){b&&(f[t+0]=b[f[t+0]]);y&&(f[t+1]=y[f[t+1]]);S&&(f[t+2]=S[f[t+2]])}t.putImageData(h,0,m);m+=c}if(g<l){A=a*i*4;f.set(p.subarray(u,u+A));if(e)for(let t=0;t<A;t+=4){b&&(f[t+0]=b[f[t+0]]);y&&(f[t+1]=y[f[t+1]]);S&&(f[t+2]=S[f[t+2]])}t.putImageData(h,0,m)}}else{if(e.kind!==n.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);{const e=!!(b||y||S);_=c;A=a*_;for(g=0;g<l;g++){if(g>=o){_=i;A=a*_}d=0;for(m=A;m--;){f[d++]=p[u++];f[d++]=p[u++];f[d++]=p[u++];f[d++]=255}if(e)for(let t=0;t<d;t+=4){b&&(f[t+0]=b[f[t+0]]);y&&(f[t+1]=y[f[t+1]]);S&&(f[t+2]=S[f[t+2]])}t.putImageData(h,0,g*c)}}}}function putBinaryImageMask(t,e){if(e.bitmap){t.drawImage(e.bitmap,0,0);return}const s=e.height,n=e.width,r=s%c,i=(s-r)/c,o=0===r?i:i+1,l=t.createImageData(n,c);let h=0;const d=e.data,u=l.data;for(let e=0;e<o;e++){const s=e<i?c:r;({srcPos:h}=(0,a.applyMaskImageData)({src:d,srcPos:h,dest:u,width:n,height:s}));t.putImageData(l,0,e*c)}}function copyCtxState(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font"];for(let n=0,r=s.length;n<r;n++){const r=s[n];void 0!==t[r]&&(e[r]=t[r])}if(void 0!==t.setLineDash){e.setLineDash(t.getLineDash());e.lineDashOffset=t.lineDashOffset}}function resetCtxToDefault(t,e){t.strokeStyle=t.fillStyle=e||"#000000";t.fillRule="nonzero";t.globalAlpha=1;t.lineWidth=1;t.lineCap="butt";t.lineJoin="miter";t.miterLimit=10;t.globalCompositeOperation="source-over";t.font="10px sans-serif";if(void 0!==t.setLineDash){t.setLineDash([]);t.lineDashOffset=0}}function composeSMaskBackdrop(t,e,s,n){const r=t.length;for(let a=3;a<r;a+=4){const r=t[a];if(0===r){t[a-3]=e;t[a-2]=s;t[a-1]=n}else if(r<255){const i=255-r;t[a-3]=t[a-3]*r+e*i>>8;t[a-2]=t[a-2]*r+s*i>>8;t[a-1]=t[a-1]*r+n*i>>8}}}function composeSMaskAlpha(t,e,s){const n=t.length;for(let r=3;r<n;r+=4){const n=s?s[t[r]]:t[r];e[r]=e[r]*n*.00392156862745098|0}}function composeSMaskLuminosity(t,e,s){const n=t.length;for(let r=3;r<n;r+=4){const n=77*t[r-3]+152*t[r-2]+28*t[r-1];e[r]=s?e[r]*s[n>>8]>>8:e[r]*n>>16}}function composeSMask(t,e,s,n){const r=n[0],a=n[1],i=n[2]-r,o=n[3]-a;if(0!==i&&0!==o){!function genericComposeSMask(t,e,s,n,r,a,i,o,l,c,h){const d=!!a,u=d?a[0]:0,p=d?a[1]:0,f=d?a[2]:0;let g;g="Luminosity"===r?composeSMaskLuminosity:composeSMaskAlpha;const m=Math.min(n,Math.ceil(1048576/s));for(let r=0;r<n;r+=m){const a=Math.min(m,n-r),_=t.getImageData(o-c,r+(l-h),s,a),A=e.getImageData(o,r+l,s,a);d&&composeSMaskBackdrop(_.data,u,p,f);g(_.data,A.data,i);e.putImageData(A,o,r+l)}}(e.context,s,i,o,e.subtype,e.backdrop,e.transferMap,r,a,e.offsetX,e.offsetY);t.save();t.globalAlpha=1;t.globalCompositeOperation="source-over";t.setTransform(1,0,0,1,0,0);t.drawImage(s.canvas,0,0);t.restore()}}function getImageSmoothingEnabled(t,e){const s=n.Util.singularValueDecompose2dScale(t);s[0]=Math.fround(s[0]);s[1]=Math.fround(s[1]);const r=Math.fround((globalThis.devicePixelRatio||1)*o.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==e?e:s[0]<=r||s[1]<=r}const h=["butt","round","square"],d=["miter","round","bevel"],u={},p={};class CanvasGraphics{constructor(t,e,s,n,r,a,i,o){this.ctx=t;this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.stateStack=[];this.pendingClip=null;this.pendingEOFill=!1;this.res=null;this.xobjs=null;this.commonObjs=e;this.objs=s;this.canvasFactory=n;this.imageLayer=r;this.groupStack=[];this.processingType3=null;this.baseTransform=null;this.baseTransformStack=[];this.groupLevel=0;this.smaskStack=[];this.smaskCounter=0;this.tempSMask=null;this.suspendedCtx=null;this.contentVisible=!0;this.markedContentStack=[];this.optionalContentConfig=a;this.cachedCanvases=new CachedCanvases(this.canvasFactory);this.cachedPatterns=new Map;this.annotationCanvasMap=i;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.backgroundColor=o?.background||null;this.foregroundColor=o?.foreground||null;t&&addContextCurrentTransform(t);this._cachedScaleForStroking=null;this._cachedGetSinglePixelWidth=null;this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:n=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,i=n||"#ffffff";this.ctx.save();if(this.foregroundColor&&this.backgroundColor){this.ctx.fillStyle=this.foregroundColor;const t=this.foregroundColor=this.ctx.fillStyle;this.ctx.fillStyle=this.backgroundColor;const e=this.backgroundColor=this.ctx.fillStyle;let s=!0,n=i;this.ctx.fillStyle=i;n=this.ctx.fillStyle;s="string"==typeof n&&/^#[0-9A-Fa-f]{6}$/.test(n);if("#000000"===t&&"#ffffff"===e||t===e||!s)this.foregroundColor=this.backgroundColor=null;else{const s=parseInt(n.slice(1),16),r=(s&&16711680)>>16,a=(s&&65280)>>8,i=s&&255,newComp=t=>(t/=255)<=.03928?t/12.92:((t+.055)/1.055)**2.4,o=Math.round(.2126*newComp(r)+.7152*newComp(a)+.0722*newComp(i));this.selectColor=(s,n,r)=>{const a=.2126*newComp(s)+.7152*newComp(n)+.0722*newComp(r);return Math.round(a)===o?e:t}}}this.ctx.fillStyle=this.backgroundColor||i;this.ctx.fillRect(0,0,r,a);this.ctx.restore();if(s){const t=this.cachedCanvases.getCanvas("transparent",r,a,!0);this.compositeCtx=this.ctx;this.transparentCanvas=t.canvas;this.ctx=t.context;this.ctx.save();this.ctx.transform.apply(this.ctx,this.compositeCtx.mozCurrentTransform)}this.ctx.save();resetCtxToDefault(this.ctx,this.foregroundColor);if(t){this.ctx.transform.apply(this.ctx,t);this.outputScaleX=t[0];this.outputScaleY=t[0]}this.ctx.transform.apply(this.ctx,e.transform);this.viewportScale=e.scale;this.baseTransform=this.ctx.mozCurrentTransform.slice();this.imageLayer&&this.imageLayer.beginLayout()}executeOperatorList(t,e,s,r){const a=t.argsArray,i=t.fnArray;let o=e||0;const l=a.length;if(l===o)return o;const c=l-o>10&&"function"==typeof s,h=c?Date.now()+15:0;let d=0;const u=this.commonObjs,p=this.objs;let f;for(;;){if(void 0!==r&&o===r.nextBreakPoint){r.breakIt(o,s);return o}f=i[o];if(f!==n.OPS.dependency)this[f].apply(this,a[o]);else for(const t of a[o]){const e=t.startsWith("g_")?u:p;if(!e.has(t)){e.get(t,s);return o}}o++;if(o===l)return o;if(c&&++d>10){if(Date.now()>h){s();return o}d=0}}}endDrawing(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore();if(this.transparentCanvas){this.ctx=this.compositeCtx;this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.drawImage(this.transparentCanvas,0,0);this.ctx.restore();this.transparentCanvas=null}this.cachedCanvases.clear();this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear();this.imageLayer&&this.imageLayer.endLayout()}_scaleImage(t,e){const s=t.width,n=t.height;let r,a,i=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=s,c=n,h="prescale1";for(;i>2&&l>1||o>2&&c>1;){let e=l,s=c;if(i>2&&l>1){e=Math.ceil(l/2);i/=l/e}if(o>2&&c>1){s=Math.ceil(c/2);o/=c/s}r=this.cachedCanvases.getCanvas(h,e,s,!1);a=r.context;a.clearRect(0,0,e,s);a.drawImage(t,0,0,l,c,0,0,e,s);t=r.canvas;l=e;c=s;h="prescale1"===h?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:c}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:a}=t,i=this.current.fillColor,o=this.current.patternFill,l=e.mozCurrentTransform;let c,h,d,u;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer,s=l.slice(0,4);h=JSON.stringify(o?s:[s,i]);c=this._cachedBitmapsMap.get(e);if(!c){c=new Map;this._cachedBitmapsMap.set(e,c)}const n=c.get(h);if(n&&!o){return{canvas:n,offsetX:Math.round(Math.min(l[0],l[2])+l[4]),offsetY:Math.round(Math.min(l[1],l[3])+l[5])}}d=n}if(!d){u=this.cachedCanvases.getCanvas("maskCanvas",s,a,!1);putBinaryImageMask(u.context,t)}let p=n.Util.transform(l,[1/s,0,0,-1/a,0,0]);p=n.Util.transform(p,[1,0,0,1,0,-a]);const f=n.Util.applyTransform([0,0],p),g=n.Util.applyTransform([s,a],p),m=n.Util.normalizeRect([f[0],f[1],g[0],g[1]]),_=Math.round(m[2]-m[0])||1,A=Math.round(m[3]-m[1])||1,b=this.cachedCanvases.getCanvas("fillCanvas",_,A,!0),y=b.context,S=Math.min(f[0],g[0]),x=Math.min(f[1],g[1]);y.translate(-S,-x);y.transform.apply(y,p);if(!d){d=this._scaleImage(u.canvas,y.mozCurrentTransformInverse);d=d.img;c&&o&&c.set(h,d)}y.imageSmoothingEnabled=getImageSmoothingEnabled(y.mozCurrentTransform,t.interpolate);drawImageAtIntegerCoords(y,d,0,0,d.width,d.height,0,0,s,a);y.globalCompositeOperation="source-in";const v=n.Util.transform(y.mozCurrentTransformInverse,[1,0,0,1,-S,-x]);y.fillStyle=o?i.getPattern(e,this,v,r.PathType.FILL):i;y.fillRect(0,0,s,a);if(c&&!o){this.cachedCanvases.delete("fillCanvas");c.set(h,b.canvas)}return{canvas:b.canvas,offsetX:Math.round(S),offsetY:Math.round(x)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking=null);this.current.lineWidth=t;this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=h[t]}setLineJoin(t){this.ctx.lineJoin=d[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;if(void 0!==s.setLineDash){s.setLineDash(t);s.lineDashOffset=e}}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],n=s[0],r=s[1];switch(n){case"LW":this.setLineWidth(r);break;case"LC":this.setLineCap(r);break;case"LJ":this.setLineJoin(r);break;case"ML":this.setMiterLimit(r);break;case"D":this.setDash(r[0],r[1]);break;case"RI":this.setRenderingIntent(r);break;case"FL":this.setFlatness(r);break;case"Font":this.setFont(r[0],r[1]);break;case"CA":this.current.strokeAlpha=s[1];break;case"ca":this.current.fillAlpha=s[1];this.ctx.globalAlpha=s[1];break;case"BM":this.ctx.globalCompositeOperation=r;break;case"SMask":this.current.activeSMask=r?this.tempSMask:null;this.tempSMask=null;this.checkSMaskState();break;case"TR":this.current.transferMaps=r}}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(s,t,e,!0);this.suspendedCtx=this.ctx;this.ctx=n.context;const r=this.ctx;r.setTransform.apply(r,this.suspendedCtx.mozCurrentTransform);copyCtxState(this.suspendedCtx,r);!function mirrorContextOperations(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save;t.__originalRestore=t.restore;t.__originalRotate=t.rotate;t.__originalScale=t.scale;t.__originalTranslate=t.translate;t.__originalTransform=t.transform;t.__originalSetTransform=t.setTransform;t.__originalResetTransform=t.resetTransform;t.__originalClip=t.clip;t.__originalMoveTo=t.moveTo;t.__originalLineTo=t.lineTo;t.__originalBezierCurveTo=t.bezierCurveTo;t.__originalRect=t.rect;t.__originalClosePath=t.closePath;t.__originalBeginPath=t.beginPath;t._removeMirroring=()=>{t.save=t.__originalSave;t.restore=t.__originalRestore;t.rotate=t.__originalRotate;t.scale=t.__originalScale;t.translate=t.__originalTranslate;t.transform=t.__originalTransform;t.setTransform=t.__originalSetTransform;t.resetTransform=t.__originalResetTransform;t.clip=t.__originalClip;t.moveTo=t.__originalMoveTo;t.lineTo=t.__originalLineTo;t.bezierCurveTo=t.__originalBezierCurveTo;t.rect=t.__originalRect;t.closePath=t.__originalClosePath;t.beginPath=t.__originalBeginPath;delete t._removeMirroring};t.save=function ctxSave(){e.save();this.__originalSave()};t.restore=function ctxRestore(){e.restore();this.__originalRestore()};t.translate=function ctxTranslate(t,s){e.translate(t,s);this.__originalTranslate(t,s)};t.scale=function ctxScale(t,s){e.scale(t,s);this.__originalScale(t,s)};t.transform=function ctxTransform(t,s,n,r,a,i){e.transform(t,s,n,r,a,i);this.__originalTransform(t,s,n,r,a,i)};t.setTransform=function ctxSetTransform(t,s,n,r,a,i){e.setTransform(t,s,n,r,a,i);this.__originalSetTransform(t,s,n,r,a,i)};t.resetTransform=function ctxResetTransform(){e.resetTransform();this.__originalResetTransform()};t.rotate=function ctxRotate(t){e.rotate(t);this.__originalRotate(t)};t.clip=function ctxRotate(t){e.clip(t);this.__originalClip(t)};t.moveTo=function(t,s){e.moveTo(t,s);this.__originalMoveTo(t,s)};t.lineTo=function(t,s){e.lineTo(t,s);this.__originalLineTo(t,s)};t.bezierCurveTo=function(t,s,n,r,a,i){e.bezierCurveTo(t,s,n,r,a,i);this.__originalBezierCurveTo(t,s,n,r,a,i)};t.rect=function(t,s,n,r){e.rect(t,s,n,r);this.__originalRect(t,s,n,r)};t.closePath=function(){e.closePath();this.__originalClosePath()};t.beginPath=function(){e.beginPath();this.__originalBeginPath()}}(r,this.suspendedCtx);this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring();copyCtxState(this.ctx,this.suspendedCtx);this.ctx=this.suspendedCtx;this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;if(t){t[0]=Math.floor(t[0]);t[1]=Math.floor(t[1]);t[2]=Math.ceil(t[2]);t[3]=Math.ceil(t[3])}else t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask;composeSMask(this.suspendedCtx,e,this.ctx,t);this.ctx.save();this.ctx.setTransform(1,0,0,1,0,0);this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height);this.ctx.restore()}save(){if(this.inSMaskMode){copyCtxState(this.ctx,this.suspendedCtx);this.suspendedCtx.save()}else this.ctx.save();const t=this.current;this.stateStack.push(t);this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode();if(0!==this.stateStack.length){this.current=this.stateStack.pop();if(this.inSMaskMode){this.suspendedCtx.restore();copyCtxState(this.suspendedCtx,this.ctx)}else this.ctx.restore();this.checkSMaskState();this.pendingClip=null;this._cachedScaleForStroking=null;this._cachedGetSinglePixelWidth=null}}transform(t,e,s,n,r,a){this.ctx.transform(t,e,s,n,r,a);this._cachedScaleForStroking=null;this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const r=this.ctx,a=this.current;let i,o,l=a.x,c=a.y;const h=r.mozCurrentTransform,d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],u=d?s.slice(0):null;for(let s=0,p=0,f=t.length;s<f;s++)switch(0|t[s]){case n.OPS.rectangle:l=e[p++];c=e[p++];const t=e[p++],s=e[p++],f=l+t,g=c+s;r.moveTo(l,c);if(0===t||0===s)r.lineTo(f,g);else{r.lineTo(f,c);r.lineTo(f,g);r.lineTo(l,g)}d||a.updateRectMinMax(h,[l,c,f,g]);r.closePath();break;case n.OPS.moveTo:l=e[p++];c=e[p++];r.moveTo(l,c);d||a.updatePathMinMax(h,l,c);break;case n.OPS.lineTo:l=e[p++];c=e[p++];r.lineTo(l,c);d||a.updatePathMinMax(h,l,c);break;case n.OPS.curveTo:i=l;o=c;l=e[p+4];c=e[p+5];r.bezierCurveTo(e[p],e[p+1],e[p+2],e[p+3],l,c);a.updateCurvePathMinMax(h,i,o,e[p],e[p+1],e[p+2],e[p+3],l,c,u);p+=6;break;case n.OPS.curveTo2:i=l;o=c;r.bezierCurveTo(l,c,e[p],e[p+1],e[p+2],e[p+3]);a.updateCurvePathMinMax(h,i,o,l,c,e[p],e[p+1],e[p+2],e[p+3],u);l=e[p+2];c=e[p+3];p+=4;break;case n.OPS.curveTo3:i=l;o=c;l=e[p+2];c=e[p+3];r.bezierCurveTo(e[p],e[p+1],l,c,l,c);a.updateCurvePathMinMax(h,i,o,e[p],e[p+1],l,c,l,c,u);p+=4;break;case n.OPS.closePath:r.closePath()}d&&a.updateScalingPathMinMax(h,u);a.setCurrentPoint(l,c)}closePath(){this.ctx.closePath()}stroke(t){t=void 0===t||t;const e=this.ctx,s=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha;if(this.contentVisible)if("object"==typeof s&&s?.getPattern){e.save();e.strokeStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,r.PathType.STROKE);this.rescaleAndStroke(!1);e.restore()}else this.rescaleAndStroke(!0);t&&this.consumePath(this.current.getClippedPathBoundingBox());e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath();this.stroke()}fill(t){t=void 0===t||t;const e=this.ctx,s=this.current.fillColor;let n=!1;if(this.current.patternFill){e.save();e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,r.PathType.FILL);n=!0}const a=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==a)if(this.pendingEOFill){e.fill("evenodd");this.pendingEOFill=!1}else e.fill();n&&e.restore();t&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0;this.fill()}fillStroke(){this.fill(!1);this.stroke(!1);this.consumePath()}eoFillStroke(){this.pendingEOFill=!0;this.fillStroke()}closeFillStroke(){this.closePath();this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0;this.closePath();this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=u}eoClip(){this.pendingClip=p}beginText(){this.current.textMatrix=n.IDENTITY_MATRIX;this.current.textMatrixScale=1;this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save();e.beginPath();for(let s=0;s<t.length;s++){const n=t[s];e.setTransform.apply(e,n.transform);e.translate(n.x,n.y);n.addToPath(e,n.fontSize)}e.restore();e.clip();e.beginPath();delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const s=this.commonObjs.get(t),r=this.current;if(!s)throw new Error(`Can't find font for ${t}`);r.fontMatrix=s.fontMatrix||n.FONT_IDENTITY_MATRIX;0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||(0,n.warn)("Invalid font matrix for font "+t);if(e<0){e=-e;r.fontDirection=-1}else r.fontDirection=1;this.current.font=s;this.current.fontSize=e;if(s.isType3Font)return;const a=s.loadedName||"sans-serif";let i="normal";s.black?i="900":s.bold&&(i="bold");const o=s.italic?"italic":"normal",l=`"${a}", ${s.fallbackName}`;let c=e;e<16?c=16:e>100&&(c=100);this.current.fontSizeScale=e/c;this.ctx.font=`${o} ${i} ${c}px ${l}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t;this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e);this.moveText(t,e)}setTextMatrix(t,e,s,n,r,a){this.current.textMatrix=[t,e,s,n,r,a];this.current.textMatrixScale=Math.hypot(t,e);this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,r){const a=this.ctx,i=this.current,o=i.font,l=i.textRenderingMode,c=i.fontSize/i.fontSizeScale,h=l&n.TextRenderingMode.FILL_STROKE_MASK,d=!!(l&n.TextRenderingMode.ADD_TO_PATH_FLAG),u=i.patternFill&&!o.missingFile;let p;(o.disableFontFace||d||u)&&(p=o.getPathGenerator(this.commonObjs,t));if(o.disableFontFace||u){a.save();a.translate(e,s);a.beginPath();p(a,c);r&&a.setTransform.apply(a,r);h!==n.TextRenderingMode.FILL&&h!==n.TextRenderingMode.FILL_STROKE||a.fill();h!==n.TextRenderingMode.STROKE&&h!==n.TextRenderingMode.FILL_STROKE||a.stroke();a.restore()}else{h!==n.TextRenderingMode.FILL&&h!==n.TextRenderingMode.FILL_STROKE||a.fillText(t,e,s);h!==n.TextRenderingMode.STROKE&&h!==n.TextRenderingMode.FILL_STROKE||a.strokeText(t,e,s)}if(d){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:a.mozCurrentTransform,x:e,y:s,fontSize:c,addToPath:p})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10,!1);t.scale(1.5,1);t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){s=!0;break}return(0,n.shadow)(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const a=e.fontSize;if(0===a)return;const i=this.ctx,o=e.fontSizeScale,l=e.charSpacing,c=e.wordSpacing,h=e.fontDirection,d=e.textHScale*h,u=t.length,p=s.vertical,f=p?1:-1,g=s.defaultVMetrics,m=a*e.fontMatrix[0],_=e.textRenderingMode===n.TextRenderingMode.FILL&&!s.disableFontFace&&!e.patternFill;i.save();i.transform.apply(i,e.textMatrix);i.translate(e.x,e.y+e.textRise);h>0?i.scale(d,-1):i.scale(d,1);let A;if(e.patternFill){i.save();const t=e.fillColor.getPattern(i,this,i.mozCurrentTransformInverse,r.PathType.FILL);A=i.mozCurrentTransform;i.restore();i.fillStyle=t}let b=e.lineWidth;const y=e.textMatrixScale;if(0===y||0===b){const t=e.textRenderingMode&n.TextRenderingMode.FILL_STROKE_MASK;t!==n.TextRenderingMode.STROKE&&t!==n.TextRenderingMode.FILL_STROKE||(b=this.getSinglePixelWidth())}else b/=y;if(1!==o){i.scale(o,o);b/=o}i.lineWidth=b;let S,x=0;for(S=0;S<u;++S){const e=t[S];if("number"==typeof e){x+=f*e*a/1e3;continue}let n=!1;const r=(e.isSpace?c:0)+l,d=e.fontChar,u=e.accent;let b,y,v,C=e.width;if(p){const t=e.vmetric||g,s=-(e.vmetric?t[1]:.5*C)*m,n=t[2]*m;C=t?-t[0]:C;b=s/o;y=(x+n)/o}else{b=x/o;y=0}if(s.remeasure&&C>0){const t=1e3*i.measureText(d).width/a*o;if(C<t&&this.isFontSubpixelAAEnabled){const e=C/t;n=!0;i.save();i.scale(e,1);b/=e}else C!==t&&(b+=(C-t)/2e3*a/o)}if(this.contentVisible&&(e.isInFont||s.missingFile))if(_&&!u)i.fillText(d,b,y);else{this.paintChar(d,b,y,A);if(u){const t=b+a*u.offset.x/o,e=y-a*u.offset.y/o;this.paintChar(u.fontChar,t,e,A)}}v=p?C*m-r*h:C*m+r*h;x+=v;n&&i.restore()}p?e.y-=x:e.x+=x*d;i.restore();this.compose()}showType3Text(t){const e=this.ctx,s=this.current,r=s.font,a=s.fontSize,i=s.fontDirection,o=r.vertical?1:-1,l=s.charSpacing,c=s.wordSpacing,h=s.textHScale*i,d=s.fontMatrix||n.FONT_IDENTITY_MATRIX,u=t.length;let p,f,g,m;if(!(s.textRenderingMode===n.TextRenderingMode.INVISIBLE)&&0!==a){this._cachedScaleForStroking=null;this._cachedGetSinglePixelWidth=null;e.save();e.transform.apply(e,s.textMatrix);e.translate(s.x,s.y);e.scale(h,i);for(p=0;p<u;++p){f=t[p];if("number"==typeof f){m=o*f*a/1e3;this.ctx.translate(m,0);s.x+=m*h;continue}const i=(f.isSpace?c:0)+l,u=r.charProcOperatorList[f.operatorListId];if(!u){(0,n.warn)(`Type3 character "${f.operatorListId}" is not available.`);continue}if(this.contentVisible){this.processingType3=f;this.save();e.scale(a,a);e.transform.apply(e,d);this.executeOperatorList(u);this.restore()}g=n.Util.applyTransform([f.width,0],d)[0]*a+i;e.translate(g,0);s.x+=g*h}e.restore();this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,n,r,a){this.ctx.rect(s,n,r-s,a-n);this.ctx.clip();this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const s=t[1],n=this.baseTransform||this.ctx.mozCurrentTransform.slice(),a={createCanvasGraphics:t=>new CanvasGraphics(t,this.commonObjs,this.objs,this.canvasFactory)};e=new r.TilingPattern(t,s,this.ctx,a,n)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments);this.current.patternFill=!0}setStrokeRGBColor(t,e,s){const r=this.selectColor?.(t,e,s)||n.Util.makeHexColor(t,e,s);this.ctx.strokeStyle=r;this.current.strokeColor=r}setFillRGBColor(t,e,s){const r=this.selectColor?.(t,e,s)||n.Util.makeHexColor(t,e,s);this.ctx.fillStyle=r;this.current.fillColor=r;this.current.patternFill=!1}_getPattern(t,e=null){let s;if(this.cachedPatterns.has(t))s=this.cachedPatterns.get(t);else{s=(0,r.getShadingPattern)(this.objs.get(t));this.cachedPatterns.set(t,s)}e&&(s.matrix=e);return s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,e.mozCurrentTransformInverse,r.PathType.SHADING);const a=e.mozCurrentTransformInverse;if(a){const t=e.canvas,s=t.width,r=t.height,i=n.Util.applyTransform([0,0],a),o=n.Util.applyTransform([0,r],a),l=n.Util.applyTransform([s,0],a),c=n.Util.applyTransform([s,r],a),h=Math.min(i[0],o[0],l[0],c[0]),d=Math.min(i[1],o[1],l[1],c[1]),u=Math.max(i[0],o[0],l[0],c[0]),p=Math.max(i[1],o[1],l[1],c[1]);this.ctx.fillRect(h,d,u-h,p-d)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox());this.restore()}beginInlineImage(){(0,n.unreachable)("Should not call beginInlineImage")}beginImageData(){(0,n.unreachable)("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible){this.save();this.baseTransformStack.push(this.baseTransform);Array.isArray(t)&&6===t.length&&this.transform.apply(this,t);this.baseTransform=this.ctx.mozCurrentTransform;if(e){const t=e[2]-e[0],s=e[3]-e[1];this.ctx.rect(e[0],e[1],t,s);this.current.updateRectMinMax(this.ctx.mozCurrentTransform,e);this.clip();this.endPath()}}}paintFormXObjectEnd(){if(this.contentVisible){this.restore();this.baseTransform=this.baseTransformStack.pop()}}beginGroup(t){if(!this.contentVisible)return;this.save();if(this.inSMaskMode){this.endSMaskMode();this.current.activeSMask=null}const e=this.ctx;t.isolated||(0,n.info)("TODO: Support non-isolated groups.");t.knockout&&(0,n.warn)("Knockout groups not supported.");const s=e.mozCurrentTransform;t.matrix&&e.transform.apply(e,t.matrix);if(!t.bbox)throw new Error("Bounding box is required.");let r=n.Util.getAxialAlignedBoundingBox(t.bbox,e.mozCurrentTransform);const a=[0,0,e.canvas.width,e.canvas.height];r=n.Util.intersect(r,a)||[0,0,0,0];const i=Math.floor(r[0]),o=Math.floor(r[1]);let c=Math.max(Math.ceil(r[2])-i,1),h=Math.max(Math.ceil(r[3])-o,1),d=1,u=1;if(c>l){d=c/l;c=l}if(h>l){u=h/l;h=l}this.current.startNewPathAndClipBox([0,0,c,h]);let p="groupAt"+this.groupLevel;t.smask&&(p+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(p,c,h,!0),g=f.context;g.scale(1/d,1/u);g.translate(-i,-o);g.transform.apply(g,s);if(t.smask)this.smaskStack.push({canvas:f.canvas,context:g,offsetX:i,offsetY:o,scaleX:d,scaleY:u,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null});else{e.setTransform(1,0,0,1,0,0);e.translate(i,o);e.scale(d,u);e.save()}copyCtxState(e,g);this.ctx=g;this.setGState([["BM","source-over"],["ca",1],["CA",1]]);this.groupStack.push(e);this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();this.ctx=s;this.ctx.imageSmoothingEnabled=!1;if(t.smask){this.tempSMask=this.smaskStack.pop();this.restore()}else{this.ctx.restore();const t=this.ctx.mozCurrentTransform;this.restore();this.ctx.save();this.ctx.setTransform.apply(this.ctx,t);const s=n.Util.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0);this.ctx.restore();this.compose(s)}}beginAnnotations(){this.save();this.baseTransform&&this.ctx.setTransform.apply(this.ctx,this.baseTransform)}endAnnotations(){this.restore()}beginAnnotation(t,e,s,r,a){this.save();if(Array.isArray(e)&&4===e.length){const r=e[2]-e[0],i=e[3]-e[1];if(a&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0];s[5]-=e[1];(e=e.slice())[0]=e[1]=0;e[2]=r;e[3]=i;const[a,l]=n.Util.singularValueDecompose2dScale(this.ctx.mozCurrentTransform),{viewportScale:c}=this,h=Math.ceil(r*this.outputScaleX*c),d=Math.ceil(i*this.outputScaleY*c);this.annotationCanvas=this.canvasFactory.create(h,d);const{canvas:u,context:p}=this.annotationCanvas,f=`var(--zoom-factor) * ${o.PixelsPerInch.PDF_TO_CSS_UNITS}`;u.style.width=`calc(${r}px * ${f})`;u.style.height=`calc(${i}px * ${f})`;this.annotationCanvasMap.set(t,u);this.annotationCanvas.savedCtx=this.ctx;this.ctx=p;this.ctx.setTransform(a,0,0,-l,0,i*l);addContextCurrentTransform(this.ctx);resetCtxToDefault(this.ctx,this.foregroundColor)}else{resetCtxToDefault(this.ctx,this.foregroundColor);this.ctx.rect(e[0],e[1],r,i);this.ctx.clip();this.endPath()}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.transform.apply(this,s);this.transform.apply(this,r)}endAnnotation(){if(this.annotationCanvas){this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}this.restore()}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const s=this.ctx,n=this.processingType3;if(n){void 0===n.compiled&&(n.compiled=function compileType3Glyph(t){const{width:e,height:s}=t;if(e>1e3||s>1e3)return null;const n=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),r=e+1;let a,o,l,c=new Uint8Array(r*(s+1));const h=e+7&-8;let d=new Uint8Array(h*s),u=0;for(const e of t.data){let t=128;for(;t>0;){d[u++]=e&t?0:255;t>>=1}}let p=0;u=0;if(0!==d[u]){c[0]=1;++p}for(o=1;o<e;o++){if(d[u]!==d[u+1]){c[o]=d[u]?2:1;++p}u++}if(0!==d[u]){c[o]=2;++p}for(a=1;a<s;a++){u=a*h;l=a*r;if(d[u-h]!==d[u]){c[l]=d[u]?1:8;++p}let t=(d[u]?4:0)+(d[u-h]?8:0);for(o=1;o<e;o++){t=(t>>2)+(d[u+1]?4:0)+(d[u-h+1]?8:0);if(n[t]){c[l+o]=n[t];++p}u++}if(d[u-h]!==d[u]){c[l+o]=d[u]?2:4;++p}if(p>1e3)return null}u=h*(s-1);l=a*r;if(0!==d[u]){c[l]=8;++p}for(o=1;o<e;o++){if(d[u]!==d[u+1]){c[l+o]=d[u]?4:8;++p}u++}if(0!==d[u]){c[l+o]=4;++p}if(p>1e3)return null;const f=new Int32Array([0,r,-1,0,-r,0,0,0,1]);let g,m,_;i.isNodeJS?m=[]:g=new Path2D;for(a=0;p&&a<=s;a++){let t=a*r;const s=t+e;for(;t<s&&!c[t];)t++;if(t===s)continue;g?g.moveTo(t%r,a):_=[t%r,a];const n=t;let i=c[t];do{const e=f[i];do{t+=e}while(!c[t]);const s=c[t];if(5!==s&&10!==s){i=s;c[t]=0}else{i=s&51*i>>4;c[t]&=i>>2|i<<2}g?g.lineTo(t%r,t/r|0):_.push(t%r,t/r|0);c[t]||--p}while(n!==t);g||m.push(_);--a}d=null;c=null;return function(t){t.save();t.scale(1/e,-1/s);t.translate(0,-s);if(g)t.fill(g);else{t.beginPath();for(const e of m){t.moveTo(e[0],e[1]);for(let s=2,n=e.length;s<n;s+=2)t.lineTo(e[s],e[s+1])}t.fill()}t.beginPath();t.restore()}}(t));if(n.compiled){n.compiled(s);return}}const r=this._createMaskCanvas(t),a=r.canvas;s.save();s.setTransform(1,0,0,1,0,0);s.drawImage(a,r.offsetX,r.offsetY);s.restore();this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,r=0,a,i){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=o.mozCurrentTransform;o.transform(e,s,r,a,0,0);const c=this._createMaskCanvas(t);o.setTransform(1,0,0,1,0,0);for(let t=0,h=i.length;t<h;t+=2){const h=n.Util.transform(l,[e,s,r,a,i[t],i[t+1]]),[d,u]=n.Util.applyTransform([0,0],h);o.drawImage(c.canvas,d,u)}o.restore();this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,n=this.current.patternFill;for(let a=0,i=t.length;a<i;a++){const i=t[a],o=i.width,l=i.height,c=this.cachedCanvases.getCanvas("maskCanvas",o,l,!1),h=c.context;h.save();putBinaryImageMask(h,i);h.globalCompositeOperation="source-in";h.fillStyle=n?s.getPattern(h,this,e.mozCurrentTransformInverse,r.PathType.FILL):s;h.fillRect(0,0,o,l);h.restore();e.save();e.transform.apply(e,i.transform);e.scale(1,-1);drawImageAtIntegerCoords(e,c.canvas,0,0,o,l,0,-1,1,1);e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):(0,n.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,s,r){if(!this.contentVisible)return;const a=this.getObject(t);if(!a){(0,n.warn)("Dependent image isn't ready yet");return}const i=a.width,o=a.height,l=[];for(let t=0,n=r.length;t<n;t+=2)l.push({transform:[e,0,0,s,r[t],r[t+1]],x:0,y:0,w:i,h:o});this.paintInlineImageXObjectGroup(a,l)}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,n=this.ctx;this.save();n.scale(1/e,-1/s);let r;if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)r=t;else{const n=this.cachedCanvases.getCanvas("inlineImage",e,s,!1);putBinaryImageData(n.context,t,this.current.transferMaps);r=n.canvas}const a=this._scaleImage(r,n.mozCurrentTransformInverse);n.imageSmoothingEnabled=getImageSmoothingEnabled(n.mozCurrentTransform,t.interpolate);const[i,o]=drawImageAtIntegerCoords(n,a.img,0,0,a.paintWidth,a.paintHeight,0,-s,e,s);if(this.imageLayer){const e=this.getCanvasPosition(0,-s);this.imageLayer.appendImage({imgData:t,left:e[0],top:e[1],width:i,height:o})}this.compose();this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx,n=t.width,r=t.height,a=this.cachedCanvases.getCanvas("inlineImage",n,r,!1);putBinaryImageData(a.context,t,this.current.transferMaps);for(let i=0,o=e.length;i<o;i++){const o=e[i];s.save();s.transform.apply(s,o.transform);s.scale(1,-1);drawImageAtIntegerCoords(s,a.canvas,o.x,o.y,o.w,o.h,0,-1,1,1);if(this.imageLayer){const e=this.getCanvasPosition(o.x,o.y);this.imageLayer.appendImage({imgData:t,left:e[0],top:e[1],width:n,height:r})}s.restore()}this.compose()}paintSolidColorImageMask(){if(this.contentVisible){this.ctx.fillRect(0,0,1,1);this.compose()}}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath();this.pendingClip||this.compose(t);const s=this.ctx;if(this.pendingClip){e||(this.pendingClip===p?s.clip("evenodd"):s.clip());this.pendingClip=null}this.current.startNewPathAndClipBox(this.current.clipBox);s.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=this.ctx.mozCurrentTransform;if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(!this._cachedScaleForStroking){const{lineWidth:t}=this.current,e=this.ctx.mozCurrentTransform;let s,n;if(0===e[1]&&0===e[2]){const r=Math.abs(e[0]),a=Math.abs(e[3]);if(0===t){s=1/r;n=1/a}else{const e=r*t,i=a*t;s=e<1?1/e:1;n=i<1?1/i:1}}else{const r=Math.abs(e[0]*e[3]-e[2]*e[1]),a=Math.hypot(e[0],e[1]),i=Math.hypot(e[2],e[3]);if(0===t){s=i/r;n=a/r}else{const e=t*r;s=i>e?i/e:1;n=a>e?a/e:1}}this._cachedScaleForStroking=[s,n]}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[n,r]=this.getScaleForStroking();e.lineWidth=s||1;if(1===n&&1===r){e.stroke();return}let a,i,o;if(t){a=e.mozCurrentTransform.slice();i=e.getLineDash().slice();o=e.lineDashOffset}e.scale(n,r);const l=Math.max(n,r);e.setLineDash(e.getLineDash().map((t=>t/l)));e.lineDashOffset/=l;e.stroke();if(t){e.setTransform(...a);e.setLineDash(i);e.lineDashOffset=o}}getCanvasPosition(t,e){const s=this.ctx.mozCurrentTransform;return[s[0]*t+s[2]*e+s[4],s[1]*t+s[3]*e+s[5]]}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}e.CanvasGraphics=CanvasGraphics;for(const t in n.OPS)void 0!==CanvasGraphics.prototype[t]&&(CanvasGraphics.prototype[n.OPS[t]]=CanvasGraphics.prototype[t])},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.TilingPattern=e.PathType=void 0;e.getShadingPattern=function getShadingPattern(t){switch(t[0]){case"RadialAxial":return new RadialAxialShadingPattern(t);case"Mesh":return new MeshShadingPattern(t);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${t[0]}`)};var n=s(1),r=s(3);const a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};e.PathType=a;function applyBoundingBox(t,e){if(!e||r.isNodeJS)return;const s=e[2]-e[0],n=e[3]-e[1],a=new Path2D;a.rect(e[0],e[1],s,n);t.clip(a)}class BaseShadingPattern{constructor(){this.constructor===BaseShadingPattern&&(0,n.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,n.unreachable)("Abstract method `getPattern` called.")}}class RadialAxialShadingPattern extends BaseShadingPattern{constructor(t){super();this._type=t[1];this._bbox=t[2];this._colorStops=t[3];this._p0=t[4];this._p1=t[5];this._r0=t[6];this._r1=t[7];this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,s,r){let i;if(r===a.STROKE||r===a.FILL){const a=e.current.getClippedPathBoundingBox(r,t.mozCurrentTransform)||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=e.cachedCanvases.getCanvas("pattern",o,l,!0),h=c.context;h.clearRect(0,0,h.canvas.width,h.canvas.height);h.beginPath();h.rect(0,0,h.canvas.width,h.canvas.height);h.translate(-a[0],-a[1]);s=n.Util.transform(s,[1,0,0,1,a[0],a[1]]);h.transform.apply(h,e.baseTransform);this.matrix&&h.transform.apply(h,this.matrix);applyBoundingBox(h,this._bbox);h.fillStyle=this._createGradient(h);h.fill();i=t.createPattern(c.canvas,"no-repeat");const d=new DOMMatrix(s);try{i.setTransform(d)}catch(t){(0,n.warn)(`RadialAxialShadingPattern.getPattern: "${t?.message}".`)}}else{applyBoundingBox(t,this._bbox);i=this._createGradient(t)}return i}}function drawTriangle(t,e,s,n,r,a,i,o){const l=e.coords,c=e.colors,h=t.data,d=4*t.width;let u;if(l[s+1]>l[n+1]){u=s;s=n;n=u;u=a;a=i;i=u}if(l[n+1]>l[r+1]){u=n;n=r;r=u;u=i;i=o;o=u}if(l[s+1]>l[n+1]){u=s;s=n;n=u;u=a;a=i;i=u}const p=(l[s]+e.offsetX)*e.scaleX,f=(l[s+1]+e.offsetY)*e.scaleY,g=(l[n]+e.offsetX)*e.scaleX,m=(l[n+1]+e.offsetY)*e.scaleY,_=(l[r]+e.offsetX)*e.scaleX,A=(l[r+1]+e.offsetY)*e.scaleY;if(f>=A)return;const b=c[a],y=c[a+1],S=c[a+2],x=c[i],v=c[i+1],C=c[i+2],P=c[o],w=c[o+1],k=c[o+2],T=Math.round(f),F=Math.round(A);let R,E,M,D,O,I,L,N;for(let t=T;t<=F;t++){if(t<m){let e;e=t<f?0:(f-t)/(f-m);R=p-(p-g)*e;E=b-(b-x)*e;M=y-(y-v)*e;D=S-(S-C)*e}else{let e;e=t>A?1:m===A?0:(m-t)/(m-A);R=g-(g-_)*e;E=x-(x-P)*e;M=v-(v-w)*e;D=C-(C-k)*e}let e;e=t<f?0:t>A?1:(f-t)/(f-A);O=p-(p-_)*e;I=b-(b-P)*e;L=y-(y-w)*e;N=S-(S-k)*e;const s=Math.round(Math.min(R,O)),n=Math.round(Math.max(R,O));let r=d*t+4*s;for(let t=s;t<=n;t++){e=(R-t)/(R-O);e<0?e=0:e>1&&(e=1);h[r++]=E-(E-I)*e|0;h[r++]=M-(M-L)*e|0;h[r++]=D-(D-N)*e|0;h[r++]=255}}}function drawFigure(t,e,s){const n=e.coords,r=e.colors;let a,i;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(n.length/o)-1,c=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<c;a++,e++){drawTriangle(t,s,n[e],n[e+1],n[e+o],r[e],r[e+1],r[e+o]);drawTriangle(t,s,n[e+o+1],n[e+1],n[e+o],r[e+o+1],r[e+1],r[e+o])}}break;case"triangles":for(a=0,i=n.length;a<i;a+=3)drawTriangle(t,s,n[a],n[a+1],n[a+2],r[a],r[a+1],r[a+2]);break;default:throw new Error("illegal figure")}}class MeshShadingPattern extends BaseShadingPattern{constructor(t){super();this._coords=t[2];this._colors=t[3];this._figures=t[4];this._bounds=t[5];this._bbox=t[7];this._background=t[8];this.matrix=null}_createMeshCanvas(t,e,s){const n=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,i=Math.ceil(this._bounds[3])-r,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(i*t[1]*1.1)),3e3),c=a/o,h=i/l,d={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-r,scaleX:1/c,scaleY:1/h},u=o+4,p=l+4,f=s.getCanvas("mesh",u,p,!1),g=f.context,m=g.createImageData(o,l);if(e){const t=m.data;for(let s=0,n=t.length;s<n;s+=4){t[s]=e[0];t[s+1]=e[1];t[s+2]=e[2];t[s+3]=255}}for(const t of this._figures)drawFigure(m,t,d);g.putImageData(m,2,2);return{canvas:f.canvas,offsetX:n-2*c,offsetY:r-2*h,scaleX:c,scaleY:h}}getPattern(t,e,s,r){applyBoundingBox(t,this._bbox);let i;if(r===a.SHADING)i=n.Util.singularValueDecompose2dScale(t.mozCurrentTransform);else{i=n.Util.singularValueDecompose2dScale(e.baseTransform);if(this.matrix){const t=n.Util.singularValueDecompose2dScale(this.matrix);i=[i[0]*t[0],i[1]*t[1]]}}const o=this._createMeshCanvas(i,r===a.SHADING?null:this._background,e.cachedCanvases);if(r!==a.SHADING){t.setTransform.apply(t,e.baseTransform);this.matrix&&t.transform.apply(t,this.matrix)}t.translate(o.offsetX,o.offsetY);t.scale(o.scaleX,o.scaleY);return t.createPattern(o.canvas,"no-repeat")}}class DummyShadingPattern extends BaseShadingPattern{getPattern(){return"hotpink"}}const i=1,o=2;class TilingPattern{static get MAX_PATTERN_SIZE(){return(0,n.shadow)(this,"MAX_PATTERN_SIZE",3e3)}constructor(t,e,s,n,r){this.operatorList=t[2];this.matrix=t[3]||[1,0,0,1,0,0];this.bbox=t[4];this.xstep=t[5];this.ystep=t[6];this.paintType=t[7];this.tilingType=t[8];this.color=e;this.ctx=s;this.canvasGraphicsFactory=n;this.baseTransform=r}createPatternCanvas(t){const e=this.operatorList,s=this.bbox,r=this.xstep,a=this.ystep,i=this.paintType,o=this.tilingType,l=this.color,c=this.canvasGraphicsFactory;(0,n.info)("TilingType: "+o);const h=s[0],d=s[1],u=s[2],p=s[3],f=n.Util.singularValueDecompose2dScale(this.matrix),g=n.Util.singularValueDecompose2dScale(this.baseTransform),m=[f[0]*g[0],f[1]*g[1]],_=this.getSizeAndScale(r,this.ctx.canvas.width,m[0]),A=this.getSizeAndScale(a,this.ctx.canvas.height,m[1]),b=t.cachedCanvases.getCanvas("pattern",_.size,A.size,!0),y=b.context,S=c.createCanvasGraphics(y);S.groupLevel=t.groupLevel;this.setFillAndStrokeStyleToContext(S,i,l);let x=h,v=d,C=u,P=p;if(h<0){x=0;C+=Math.abs(h)}if(d<0){v=0;P+=Math.abs(d)}y.translate(-_.scale*x,-A.scale*v);S.transform(_.scale,0,0,A.scale,0,0);y.save();this.clipBbox(S,x,v,C,P);S.baseTransform=S.ctx.mozCurrentTransform.slice();S.executeOperatorList(e);S.endDrawing();return{canvas:b.canvas,scaleX:_.scale,scaleY:A.scale,offsetX:x,offsetY:v}}getSizeAndScale(t,e,s){t=Math.abs(t);const n=Math.max(TilingPattern.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);r>=n?r=n:s=r/t;return{scale:s,size:r}}clipBbox(t,e,s,n,r){const a=n-e,i=r-s;t.ctx.rect(e,s,a,i);t.current.updateRectMinMax(t.ctx.mozCurrentTransform,[e,s,n,r]);t.clip();t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const r=t.ctx,a=t.current;switch(e){case i:const t=this.ctx;r.fillStyle=t.fillStyle;r.strokeStyle=t.strokeStyle;a.fillColor=t.fillStyle;a.strokeColor=t.strokeStyle;break;case o:const l=n.Util.makeHexColor(s[0],s[1],s[2]);r.fillStyle=l;r.strokeStyle=l;a.fillColor=l;a.strokeColor=l;break;default:throw new n.FormatError(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,r){let i=s;if(r!==a.SHADING){i=n.Util.transform(i,e.baseTransform);this.matrix&&(i=n.Util.transform(i,this.matrix))}const o=this.createPatternCanvas(e);let l=new DOMMatrix(i);l=l.translate(o.offsetX,o.offsetY);l=l.scale(1/o.scaleX,1/o.scaleY);const c=t.createPattern(o.canvas,"repeat");try{c.setTransform(l)}catch(t){(0,n.warn)(`TilingPattern.getPattern: "${t?.message}".`)}return c}}e.TilingPattern=TilingPattern},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.applyMaskImageData=function applyMaskImageData({src:t,srcPos:e=0,dest:s,destPos:r=0,width:a,height:i,inverseDecode:o=!1}){const l=n.FeatureTest.isLittleEndian?4278190080:255,[c,h]=o?[0,l]:[l,0],d=a>>3,u=7&a,p=t.length;s=new Uint32Array(s.buffer);for(let n=0;n<i;n++){for(const n=e+d;e<n;e++){const n=e<p?t[e]:255;s[r++]=128&n?h:c;s[r++]=64&n?h:c;s[r++]=32&n?h:c;s[r++]=16&n?h:c;s[r++]=8&n?h:c;s[r++]=4&n?h:c;s[r++]=2&n?h:c;s[r++]=1&n?h:c}if(0===u)continue;const n=e<p?t[e++]:255;for(let t=0;t<u;t++)s[r++]=n&1<<7-t?h:c}return{srcPos:e,destPos:r}};var n=s(1)},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.GlobalWorkerOptions=void 0;const s=Object.create(null);e.GlobalWorkerOptions=s;s.workerPort=void 0===s.workerPort?null:s.workerPort;s.workerSrc=void 0===s.workerSrc?"":s.workerSrc},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.MessageHandler=void 0;var n=s(1);const r=1,a=2,i=1,o=2,l=3,c=4,h=5,d=6,u=7,p=8;function wrapReason(t){t instanceof Error||"object"==typeof t&&null!==t||(0,n.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(t.name){case"AbortException":return new n.AbortException(t.message);case"MissingPDFException":return new n.MissingPDFException(t.message);case"PasswordException":return new n.PasswordException(t.message,t.code);case"UnexpectedResponseException":return new n.UnexpectedResponseException(t.message,t.status);case"UnknownErrorException":return new n.UnknownErrorException(t.message,t.details);default:return new n.UnknownErrorException(t.message,t.toString())}}e.MessageHandler=class MessageHandler{constructor(t,e,s){this.sourceName=t;this.targetName=e;this.comObj=s;this.callbackId=1;this.streamId=1;this.streamSinks=Object.create(null);this.streamControllers=Object.create(null);this.callbackCapabilities=Object.create(null);this.actionHandler=Object.create(null);this._onComObjOnMessage=t=>{const e=t.data;if(e.targetName!==this.sourceName)return;if(e.stream){this._processStreamMessage(e);return}if(e.callback){const t=e.callbackId,s=this.callbackCapabilities[t];if(!s)throw new Error(`Cannot resolve callback ${t}`);delete this.callbackCapabilities[t];if(e.callback===r)s.resolve(e.data);else{if(e.callback!==a)throw new Error("Unexpected callback case");s.reject(wrapReason(e.reason))}return}const n=this.actionHandler[e.action];if(!n)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const t=this.sourceName,i=e.sourceName;new Promise((function(t){t(n(e.data))})).then((function(n){s.postMessage({sourceName:t,targetName:i,callback:r,callbackId:e.callbackId,data:n})}),(function(n){s.postMessage({sourceName:t,targetName:i,callback:a,callbackId:e.callbackId,reason:wrapReason(n)})}))}else e.streamId?this._createStreamSink(e):n(e.data)};s.addEventListener("message",this._onComObjOnMessage)}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const r=this.callbackId++,a=(0,n.createPromiseCapability)();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:r,data:e},s)}catch(t){a.reject(t)}return a.promise}sendWithStream(t,e,s,r){const a=this.streamId++,o=this.sourceName,l=this.targetName,c=this.comObj;return new ReadableStream({start:s=>{const i=(0,n.createPromiseCapability)();this.streamControllers[a]={controller:s,startCall:i,pullCall:null,cancelCall:null,isClosed:!1};c.postMessage({sourceName:o,targetName:l,action:t,streamId:a,data:e,desiredSize:s.desiredSize},r);return i.promise},pull:t=>{const e=(0,n.createPromiseCapability)();this.streamControllers[a].pullCall=e;c.postMessage({sourceName:o,targetName:l,stream:d,streamId:a,desiredSize:t.desiredSize});return e.promise},cancel:t=>{(0,n.assert)(t instanceof Error,"cancel must have a valid reason");const e=(0,n.createPromiseCapability)();this.streamControllers[a].cancelCall=e;this.streamControllers[a].isClosed=!0;c.postMessage({sourceName:o,targetName:l,stream:i,streamId:a,reason:wrapReason(t)});return e.promise}},s)}_createStreamSink(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,i=this,o=this.actionHandler[t.action],d={enqueue(t,i=1,o){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=i;if(l>0&&this.desiredSize<=0){this.sinkCapability=(0,n.createPromiseCapability)();this.ready=this.sinkCapability.promise}a.postMessage({sourceName:s,targetName:r,stream:c,streamId:e,chunk:t},o)},close(){if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:s,targetName:r,stream:l,streamId:e});delete i.streamSinks[e]}},error(t){(0,n.assert)(t instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:s,targetName:r,stream:h,streamId:e,reason:wrapReason(t)})}},sinkCapability:(0,n.createPromiseCapability)(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};d.sinkCapability.resolve();d.ready=d.sinkCapability.promise;this.streamSinks[e]=d;new Promise((function(e){e(o(t.data,d))})).then((function(){a.postMessage({sourceName:s,targetName:r,stream:p,streamId:e,success:!0})}),(function(t){a.postMessage({sourceName:s,targetName:r,stream:p,streamId:e,reason:wrapReason(t)})}))}_processStreamMessage(t){const e=t.streamId,s=this.sourceName,r=t.sourceName,a=this.comObj,f=this.streamControllers[e],g=this.streamSinks[e];switch(t.stream){case p:t.success?f.startCall.resolve():f.startCall.reject(wrapReason(t.reason));break;case u:t.success?f.pullCall.resolve():f.pullCall.reject(wrapReason(t.reason));break;case d:if(!g){a.postMessage({sourceName:s,targetName:r,stream:u,streamId:e,success:!0});break}g.desiredSize<=0&&t.desiredSize>0&&g.sinkCapability.resolve();g.desiredSize=t.desiredSize;new Promise((function(t){t(g.onPull&&g.onPull())})).then((function(){a.postMessage({sourceName:s,targetName:r,stream:u,streamId:e,success:!0})}),(function(t){a.postMessage({sourceName:s,targetName:r,stream:u,streamId:e,reason:wrapReason(t)})}));break;case c:(0,n.assert)(f,"enqueue should have stream controller");if(f.isClosed)break;f.controller.enqueue(t.chunk);break;case l:(0,n.assert)(f,"close should have stream controller");if(f.isClosed)break;f.isClosed=!0;f.controller.close();this._deleteStreamController(f,e);break;case h:(0,n.assert)(f,"error should have stream controller");f.controller.error(wrapReason(t.reason));this._deleteStreamController(f,e);break;case o:t.success?f.cancelCall.resolve():f.cancelCall.reject(wrapReason(t.reason));this._deleteStreamController(f,e);break;case i:if(!g)break;new Promise((function(e){e(g.onCancel&&g.onCancel(wrapReason(t.reason)))})).then((function(){a.postMessage({sourceName:s,targetName:r,stream:o,streamId:e,success:!0})}),(function(t){a.postMessage({sourceName:s,targetName:r,stream:o,streamId:e,reason:wrapReason(t)})}));g.sinkCapability.reject(wrapReason(t.reason));g.isCancelled=!0;delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async _deleteStreamController(t,e){await Promise.allSettled([t.startCall&&t.startCall.promise,t.pullCall&&t.pullCall.promise,t.cancelCall&&t.cancelCall.promise]);delete this.streamControllers[e]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.Metadata=void 0;var n=s(1);e.Metadata=class Metadata{#c;#h;constructor({parsedData:t,rawData:e}){this.#c=t;this.#h=e}getRaw(){return this.#h}get(t){return this.#c.get(t)??null}getAll(){return(0,n.objectFromMap)(this.#c)}has(t){return this.#c.has(t)}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.OptionalContentConfig=void 0;var n=s(1);class OptionalContentGroup{constructor(t,e){this.visible=!0;this.name=t;this.intent=e}}e.OptionalContentConfig=class OptionalContentConfig{constructor(t){this.name=null;this.creator=null;this._order=null;this._groups=new Map;if(null!==t){this.name=t.name;this.creator=t.creator;this._order=t.order;for(const e of t.groups)this._groups.set(e.id,new OptionalContentGroup(e.name,e.intent));if("OFF"===t.baseState)for(const t of this._groups)t.visible=!1;for(const e of t.on)this._groups.get(e).visible=!0;for(const e of t.off)this._groups.get(e).visible=!1}}_evaluateVisibilityExpression(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let r=1;r<e;r++){const e=t[r];let a;if(Array.isArray(e))a=this._evaluateVisibilityExpression(e);else{if(!this._groups.has(e)){(0,n.warn)(`Optional content group not found: ${e}`);return!0}a=this._groups.get(e).visible}switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===s}isVisible(t){if(0===this._groups.size)return!0;if(!t){(0,n.warn)("Optional content group not defined.");return!0}if("OCG"===t.type){if(!this._groups.has(t.id)){(0,n.warn)(`Optional content group not found: ${t.id}`);return!0}return this._groups.get(t.id).visible}if("OCMD"===t.type){if(t.expression)return this._evaluateVisibilityExpression(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e)){(0,n.warn)(`Optional content group not found: ${e}`);return!0}if(this._groups.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this._groups.has(e)){(0,n.warn)(`Optional content group not found: ${e}`);return!0}if(!this._groups.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e)){(0,n.warn)(`Optional content group not found: ${e}`);return!0}if(!this._groups.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this._groups.has(e)){(0,n.warn)(`Optional content group not found: ${e}`);return!0}if(this._groups.get(e).visible)return!1}return!0}(0,n.warn)(`Unknown optional content policy ${t.policy}.`);return!0}(0,n.warn)(`Unknown group type ${t.type}.`);return!0}setVisibility(t,e=!0){this._groups.has(t)?this._groups.get(t).visible=!!e:(0,n.warn)(`Optional content group not found: ${t}`)}getOrder(){return this._groups.size?this._order?this._order.slice():Array.from(this._groups.keys()):null}getGroups(){return this._groups.size>0?(0,n.objectFromMap)(this._groups):null}getGroup(t){return this._groups.get(t)||null}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.PDFDataTransportStream=void 0;var n=s(1),r=s(5);e.PDFDataTransportStream=class PDFDataTransportStream{constructor(t,e){(0,n.assert)(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');this._queuedChunks=[];this._progressiveDone=t.progressiveDone||!1;this._contentDispositionFilename=t.contentDispositionFilename||null;const s=t.initialData;if(s?.length>0){const t=new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=e;this._isStreamingSupported=!t.disableStream;this._isRangeSupported=!t.disableRange;this._contentLength=t.length;this._fullRequestReader=null;this._rangeReaders=[];this._pdfDataRangeTransport.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})}));this._pdfDataRangeTransport.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})}));this._pdfDataRangeTransport.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})}));this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()}));this._pdfDataRangeTransport.transportReady()}_onReceiveData(t){const e=new Uint8Array(t.chunk).buffer;if(void 0===t.begin)this._fullRequestReader?this._fullRequestReader._enqueue(e):this._queuedChunks.push(e);else{const s=this._rangeReaders.some((function(s){if(s._begin!==t.begin)return!1;s._enqueue(e);return!0}));(0,n.assert)(s,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){if(void 0===t.total){const e=this._rangeReaders[0];e?.onProgress&&e.onProgress({loaded:t.loaded})}else{const e=this._fullRequestReader;e?.onProgress&&e.onProgress({loaded:t.loaded,total:t.total})}}_onProgressiveDone(){this._fullRequestReader&&this._fullRequestReader.progressiveDone();this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;this._queuedChunks=null;return new PDFDataTransportStreamReader(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new PDFDataTransportStreamRangeReader(this,t,e);this._pdfDataRangeTransport.requestDataRange(t,e);this._rangeReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}};class PDFDataTransportStreamReader{constructor(t,e,s=!1,n=null){this._stream=t;this._done=s||!1;this._filename=(0,r.isPdfFile)(n)?n:null;this._queuedChunks=e||[];this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[];this._headersReady=Promise.resolve();t._fullRequestReader=this;this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,n.createPromiseCapability)();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class PDFDataTransportStreamRangeReader{constructor(t,e,s){this._stream=t;this._begin=e;this._end=s;this._queuedChunk=null;this._requests=[];this._done=!1;this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0;this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;this._queuedChunk=null;return{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,n.createPromiseCapability)();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._stream._removeRangeReader(this)}}},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.XfaText=void 0;class XfaText{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};!function walk(t){if(!t)return;let s=null;const n=t.name;if("#text"===n)s=t.value;else{if(!XfaText.shouldBuildText(n))return;t?.attributes?.textContent?s=t.attributes.textContent:t.value&&(s=t.value)}null!==s&&e.push({str:s});if(t.children)for(const e of t.children)walk(e)}(t);return s}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}e.XfaText=XfaText},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.NodeStandardFontDataFactory=e.NodeCanvasFactory=e.NodeCMapReaderFactory=void 0;var n=s(6);const fetchData=function(t){return new Promise(((e,s)=>{require("fs").readFile(t,((t,n)=>{!t&&n?e(new Uint8Array(n)):s(new Error(t))}))}))};class NodeCanvasFactory extends n.BaseCanvasFactory{_createCanvas(t,e){return require("canvas").createCanvas(t,e)}}e.NodeCanvasFactory=NodeCanvasFactory;class NodeCMapReaderFactory extends n.BaseCMapReaderFactory{_fetchData(t,e){return fetchData(t).then((t=>({cMapData:t,compressionType:e})))}}e.NodeCMapReaderFactory=NodeCMapReaderFactory;class NodeStandardFontDataFactory extends n.BaseStandardFontDataFactory{_fetchData(t){return fetchData(t)}}e.NodeStandardFontDataFactory=NodeStandardFontDataFactory},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.AnnotationLayer=void 0;var n=s(1),r=s(5),a=s(8),i=s(21),o=s(22);const l=1e3,c=new WeakSet;function getRectDims(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class AnnotationElementFactory{static create(t){switch(t.data.annotationType){case n.AnnotationType.LINK:return new LinkAnnotationElement(t);case n.AnnotationType.TEXT:return new TextAnnotationElement(t);case n.AnnotationType.WIDGET:switch(t.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(t);case"Btn":return t.data.radioButton?new RadioButtonWidgetAnnotationElement(t):t.data.checkBox?new CheckboxWidgetAnnotationElement(t):new PushButtonWidgetAnnotationElement(t);case"Ch":return new ChoiceWidgetAnnotationElement(t)}return new WidgetAnnotationElement(t);case n.AnnotationType.POPUP:return new PopupAnnotationElement(t);case n.AnnotationType.FREETEXT:return new FreeTextAnnotationElement(t);case n.AnnotationType.LINE:return new LineAnnotationElement(t);case n.AnnotationType.SQUARE:return new SquareAnnotationElement(t);case n.AnnotationType.CIRCLE:return new CircleAnnotationElement(t);case n.AnnotationType.POLYLINE:return new PolylineAnnotationElement(t);case n.AnnotationType.CARET:return new CaretAnnotationElement(t);case n.AnnotationType.INK:return new InkAnnotationElement(t);case n.AnnotationType.POLYGON:return new PolygonAnnotationElement(t);case n.AnnotationType.HIGHLIGHT:return new HighlightAnnotationElement(t);case n.AnnotationType.UNDERLINE:return new UnderlineAnnotationElement(t);case n.AnnotationType.SQUIGGLY:return new SquigglyAnnotationElement(t);case n.AnnotationType.STRIKEOUT:return new StrikeOutAnnotationElement(t);case n.AnnotationType.STAMP:return new StampAnnotationElement(t);case n.AnnotationType.FILEATTACHMENT:return new FileAttachmentAnnotationElement(t);default:return new AnnotationElement(t)}}}class AnnotationElement{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:n=!1}={}){this.isRenderable=e;this.data=t.data;this.layer=t.layer;this.page=t.page;this.viewport=t.viewport;this.linkService=t.linkService;this.downloadManager=t.downloadManager;this.imageResourcesPath=t.imageResourcesPath;this.renderForms=t.renderForms;this.svgFactory=t.svgFactory;this.annotationStorage=t.annotationStorage;this.enableScripting=t.enableScripting;this.hasJSActions=t.hasJSActions;this._fieldObjects=t.fieldObjects;this._mouseState=t.mouseState;e&&(this.container=this._createContainer(s));n&&(this.quadrilaterals=this._createQuadrilaterals(s))}_createContainer(t=!1){const e=this.data,s=this.page,r=this.viewport,a=document.createElement("section");let{width:i,height:o}=getRectDims(e.rect);a.setAttribute("data-annotation-id",e.id);const l=n.Util.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]);if(e.hasOwnCanvas){const t=r.transform.slice(),[e,s]=n.Util.singularValueDecompose2dScale(t);i=Math.ceil(i*e);o=Math.ceil(o*s);l[0]*=e;l[1]*=s;for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);a.style.transform=`matrix(${t.join(",")})`}else a.style.transform=`matrix(${r.transform.join(",")})`;a.style.transformOrigin=`${-l[0]}px ${-l[1]}px`;if(!t&&e.borderStyle.width>0){a.style.borderWidth=`${e.borderStyle.width}px`;if(e.borderStyle.style!==n.AnnotationBorderStyleType.UNDERLINE){i-=2*e.borderStyle.width;o-=2*e.borderStyle.width}const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`${t}px / ${s}px`;a.style.borderRadius=e}switch(e.borderStyle.style){case n.AnnotationBorderStyleType.SOLID:a.style.borderStyle="solid";break;case n.AnnotationBorderStyleType.DASHED:a.style.borderStyle="dashed";break;case n.AnnotationBorderStyleType.BEVELED:(0,n.warn)("Unimplemented border style: beveled");break;case n.AnnotationBorderStyleType.INSET:(0,n.warn)("Unimplemented border style: inset");break;case n.AnnotationBorderStyleType.UNDERLINE:a.style.borderBottomStyle="solid"}e.borderColor||e.color||null?a.style.borderColor=n.Util.makeHexColor(0|e.color[0],0|e.color[1],0|e.color[2]):a.style.borderWidth=0}a.style.left=`${l[0]}px`;a.style.top=`${l[1]}px`;if(e.hasOwnCanvas)a.style.width=a.style.height="auto";else{a.style.width=`${i}px`;a.style.height=`${o}px`}return a}get _commonActions(){const setColor=(t,e,s)=>{const n=s.detail[t];s.target.style[e]=i.ColorConverters[`${n[0]}_HTML`](n.slice(1))};return(0,n.shadow)(this,"_commonActions",{display:t=>{const e=t.detail.display%2==1;t.target.style.visibility=e?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{hidden:e,print:0===t.detail.display||3===t.detail.display})},print:t=>{this.annotationStorage.setValue(this.data.id,{print:t.detail.print})},hidden:t=>{t.target.style.visibility=t.detail.hidden?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{hidden:t.detail.hidden})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.detail.readonly?t.target.setAttribute("readonly",""):t.target.removeAttribute("readonly")},required:t=>{t.detail.required?t.target.setAttribute("required",""):t.target.removeAttribute("required")},bgColor:t=>{setColor("bgColor","backgroundColor",t)},fillColor:t=>{setColor("fillColor","backgroundColor",t)},fgColor:t=>{setColor("fgColor","color",t)},textColor:t=>{setColor("textColor","color",t)},borderColor:t=>{setColor("borderColor","borderColor",t)},strokeColor:t=>{setColor("strokeColor","borderColor",t)}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||s[n];r&&r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[n,r]of Object.entries(e)){const a=s[n];if(a){a({detail:r,target:t});delete e[n]}}}_createQuadrilaterals(t=!1){if(!this.data.quadPoints)return null;const e=[],s=this.data.rect;for(const s of this.data.quadPoints){this.data.rect=[s[2].x,s[2].y,s[1].x,s[1].y];e.push(this._createContainer(t))}this.data.rect=s;return e}_createPopup(t,e){let s=this.container;if(this.quadrilaterals){t=t||this.quadrilaterals;s=this.quadrilaterals[0]}if(!t){(t=document.createElement("div")).style.height=s.style.height;t.style.width=s.style.width;s.appendChild(t)}const n=new PopupElement({container:s,trigger:t,color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,hideWrapper:!0}).render();n.style.left=s.style.width;s.appendChild(n)}_renderQuadrilaterals(t){for(const e of this.quadrilaterals)e.className=t;return this.quadrilaterals}render(){(0,n.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const r=this._fieldObjects[t];if(r)for(const{page:t,id:a,exportValues:i}of r){if(-1===t)continue;if(a===e)continue;const r="string"==typeof i?i:null,o=document.getElementById(a);!o||c.has(o)?s.push({id:a,exportValue:r,domElement:o}):(0,n.warn)(`_getElementsByName - element not allowed: ${a}`)}return s}for(const n of document.getElementsByName(t)){const{id:t,exportValue:r}=n;t!==e&&(c.has(n)&&s.push({id:t,exportValue:r,domElement:n}))}return s}static get platform(){const t="undefined"!=typeof navigator?navigator.platform:"";return(0,n.shadow)(this,"platform",{isWin:t.includes("Win"),isMac:t.includes("Mac")})}}class LinkAnnotationElement extends AnnotationElement{constructor(t,e=null){super(t,{isRenderable:!!(t.data.url||t.data.dest||t.data.action||t.data.isTooltipOnly||t.data.resetForm||t.data.actions&&(t.data.actions.Action||t.data.actions["Mouse Up"]||t.data.actions["Mouse Down"])),ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0})}render(){const{data:t,linkService:e}=this,s=document.createElement("a");if(t.url)e.addLinkAttributes(s,t.url,t.newWindow);else if(t.action)this._bindNamedAction(s,t.action);else if(t.dest)this._bindLink(s,t.dest);else{let e=!1;if(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){e=!0;this._bindJSAction(s,t)}t.resetForm?this._bindResetFormAction(s,t.resetForm):e||this._bindLink(s,"")}if(this.quadrilaterals)return this._renderQuadrilaterals("linkAnnotation").map(((t,e)=>{const n=0===e?s:s.cloneNode();t.appendChild(n);return t}));this.container.className="linkAnnotation";this.container.appendChild(s);return this.container}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e);t.onclick=()=>{e&&this.linkService.goToDestination(e);return!1};(e||""===e)&&(t.className="internalLink")}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl("");t.onclick=()=>{this.linkService.executeNamedAction(e);return!1};t.className="internalLink"}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(e.actions)){const r=s.get(n);r&&(t[r]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:n}});return!1})}t.onclick||(t.onclick=()=>!1);t.className="internalLink"}_bindResetFormAction(t,e){const s=t.onclick;s||(t.href=this.linkService.getAnchorUrl(""));t.className="internalLink";if(this._fieldObjects)t.onclick=()=>{s&&s();const{fields:t,refs:n,include:r}=e,a=[];if(0!==t.length||0!==n.length){const e=new Set(n);for(const s of t){const t=this._fieldObjects[s]||[];for(const{id:s}of t)e.add(s)}for(const t of Object.values(this._fieldObjects))for(const s of t)e.has(s.id)===r&&a.push(s)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const i=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;o.push(e);switch(t.type){case"text":{const s=t.defaultValue||"";i.setValue(e,{value:s});break}case"checkbox":case"radiobutton":{const s=t.defaultValue===t.exportValues;i.setValue(e,{value:s});break}case"combobox":case"listbox":{const s=t.defaultValue||"";i.setValue(e,{value:s});break}default:continue}const s=document.getElementById(e);s&&c.has(s)&&s.dispatchEvent(new Event("resetform"))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}});return!1};else{(0,n.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');s||(t.onclick=()=>!1)}}}class TextAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){this.container.className="textAnnotation";const t=document.createElement("img");t.style.height=this.container.style.height;t.style.width=this.container.style.width;t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";t.alt="[{{type}} Annotation]";t.dataset.l10nId="text_annotation_type";t.dataset.l10nArgs=JSON.stringify({type:this.data.name});this.data.hasPopup||this._createPopup(t,this.data);this.container.appendChild(t);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){this.data.alternativeText&&(this.container.title=this.data.alternativeText);return this.container}_getKeyModifier(t){const{isWin:e,isMac:s}=AnnotationElement.platform;return e&&t.ctrlKey||s&&t.metaKey}_setEventListener(t,e,s,n){e.includes("mouse")?t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(e,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,s){for(const[n,r]of e)("Action"===r||this.data.actions?.[r])&&this._setEventListener(t,n,r,s)}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":n.Util.makeHexColor(e[0],e[1],e[2])}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(t){super(t,{isRenderable:t.renderForms||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,s,n){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id)){a.domElement&&(a.domElement[e]=s);r.setValue(a.id,{[n]:s})}}render(){const t=this.annotationStorage,e=this.data.id;this.container.className="textWidgetAnnotation";let s=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue}),r=n.formattedValue||n.value||"",a={userValue:null,formattedValue:null,valueOnFocus:""};if(this.data.multiLine){s=document.createElement("textarea");s.textContent=r}else{s=document.createElement("input");s.type="text";s.setAttribute("value",r)}c.add(s);s.disabled=this.data.readOnly;s.name=this.data.fieldName;s.tabIndex=l;a.userValue=r;s.setAttribute("id",e);s.addEventListener("input",(n=>{t.setValue(e,{value:n.target.value});this.setPropertyOnSiblings(s,"value",n.target.value,"value")}));s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";s.value=a.userValue=e;a.formattedValue=null}));let blurListener=t=>{const{formattedValue:e}=a;null!=e&&(t.target.value=e);t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",(t=>{a.userValue&&(t.target.value=a.userValue);a.valueOnFocus=t.target.value}));s.addEventListener("updatefromsandbox",(s=>{const n={value(s){a.userValue=s.detail.value??"";t.setValue(e,{value:a.userValue.toString()});s.target.value=a.userValue},formattedValue(s){const{formattedValue:n}=s.detail;a.formattedValue=n;null!=n&&s.target!==document.activeElement&&(s.target.value=n);t.setValue(e,{formattedValue:n})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)}};this._dispatchEventFromSandbox(n,s)}));s.addEventListener("keydown",(t=>{let s=-1;"Escape"===t.key?s=0:"Enter"===t.key?s=2:"Tab"===t.key&&(s=3);if(-1===s)return;const{value:n}=t.target;if(a.valueOnFocus!==n){a.userValue=n;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}})}}));const n=blurListener;blurListener=null;s.addEventListener("blur",(t=>{const{value:s}=t.target;a.userValue=s;this._mouseState.isDown&&a.valueOnFocus!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:1,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}});n(t)}));this.data.actions?.Keystroke&&s.addEventListener("beforeinput",(t=>{const{data:s,target:n}=t,{value:r,selectionStart:a,selectionEnd:i}=n;let o=a,l=i;switch(t.inputType){case"deleteWordBackward":{const t=r.substring(0,a).match(/\w*[^\w]*$/);t&&(o-=t[0].length);break}case"deleteWordForward":{const t=r.substring(a).match(/^[^\w]*\w*/);t&&(l+=t[0].length);break}case"deleteContentBackward":a===i&&(o-=1);break;case"deleteContentForward":a===i&&(l+=1)}t.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,change:s||"",willCommit:!1,selStart:o,selEnd:l}})}));this._setEventListeners(s,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}blurListener&&s.addEventListener("blur",blurListener);null!==this.data.maxLen&&(s.maxLength=this.data.maxLen);if(this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/this.data.maxLen;s.classList.add("comb");s.style.letterSpacing=`calc(${t}px - 1ch)`}}else{s=document.createElement("div");s.textContent=this.data.fieldValue;s.style.verticalAlign="middle";s.style.display="table-cell"}this._setTextStyle(s);this._setBackgroundColor(s);this._setDefaultPropertiesFromJS(s);this.container.appendChild(s);return this.container}_setTextStyle(t){const e=["left","center","right"],{fontSize:s,fontColor:r}=this.data.defaultAppearanceData,a=t.style;s&&(a.fontSize=`${s}px`);a.color=n.Util.makeHexColor(r[0],r[1],r[2]);null!==this.data.textAlignment&&(a.textAlign=e[this.data.textAlignment])}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;if("string"==typeof n){n="Off"!==n;t.setValue(s,{value:n})}this.container.className="buttonWidgetAnnotation checkBox";const r=document.createElement("input");c.add(r);r.disabled=e.readOnly;r.type="checkbox";r.name=e.fieldName;n&&r.setAttribute("checked",!0);r.setAttribute("id",s);r.setAttribute("exportValue",e.exportValue);r.tabIndex=l;r.addEventListener("change",(n=>{const{name:r,checked:a}=n.target;for(const n of this._getElementsByName(r,s)){const s=a&&n.exportValue===e.exportValue;n.domElement&&(n.domElement.checked=s);t.setValue(n.id,{value:s})}t.setValue(s,{value:a})}));r.addEventListener("resetform",(t=>{const s=e.defaultFieldValue||"Off";t.target.checked=s===e.exportValue}));if(this.enableScripting&&this.hasJSActions){r.addEventListener("updatefromsandbox",(e=>{const n={value(e){e.target.checked="Off"!==e.detail.value;t.setValue(s,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)}));this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}this._setBackgroundColor(r);this._setDefaultPropertiesFromJS(r);this.container.appendChild(r);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="buttonWidgetAnnotation radioButton";const t=this.annotationStorage,e=this.data,s=e.id;let n=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n){n=n!==e.buttonValue;t.setValue(s,{value:n})}const r=document.createElement("input");c.add(r);r.disabled=e.readOnly;r.type="radio";r.name=e.fieldName;n&&r.setAttribute("checked",!0);r.setAttribute("id",s);r.tabIndex=l;r.addEventListener("change",(e=>{const{name:n,checked:r}=e.target;for(const e of this._getElementsByName(n,s))t.setValue(e.id,{value:!1});t.setValue(s,{value:r})}));r.addEventListener("resetform",(t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue}));if(this.enableScripting&&this.hasJSActions){const n=e.buttonValue;r.addEventListener("updatefromsandbox",(e=>{const r={value:e=>{const r=n===e.detail.value;for(const n of this._getElementsByName(e.target.name)){const e=r&&n.id===s;n.domElement&&(n.domElement.checked=e);t.setValue(n.id,{value:e})}}};this._dispatchEventFromSandbox(r,e)}));this._setEventListeners(r,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}this._setBackgroundColor(r);this._setDefaultPropertiesFromJS(r);this.container.appendChild(r);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.className="buttonWidgetAnnotation pushButton";this.data.alternativeText&&(t.title=this.data.alternativeText);this._setDefaultPropertiesFromJS(t);return t}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.className="choiceWidgetAnnotation";const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue});let{fontSize:n}=this.data.defaultAppearanceData;n||(n=9);const r=`calc(${n}px * var(--zoom-factor))`,a=document.createElement("select");c.add(a);a.disabled=this.data.readOnly;a.name=this.data.fieldName;a.setAttribute("id",e);a.tabIndex=l;a.style.fontSize=`${n}px`;if(!this.data.combo){a.size=this.data.options.length;this.data.multiSelect&&(a.multiple=!0)}a.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of a.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue;e.value=t.exportValue;this.data.combo&&(e.style.fontSize=r);s.value.includes(t.exportValue)&&e.setAttribute("selected",!0);a.appendChild(e)}const getValue=(t,e)=>{const s=e?"value":"textContent",n=t.target.options;return t.target.multiple?Array.prototype.filter.call(n,(t=>t.selected)).map((t=>t[s])):-1===n.selectedIndex?null:n[n.selectedIndex][s]},getItems=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};if(this.enableScripting&&this.hasJSActions){a.addEventListener("updatefromsandbox",(s=>{const n={value(s){const n=s.detail.value,r=new Set(Array.isArray(n)?n:[n]);for(const t of a.options)t.selected=r.has(t.value);t.setValue(e,{value:getValue(s,!0)})},multipleSelection(t){a.multiple=!0},remove(s){const n=a.options,r=s.detail.remove;n[r].selected=!1;a.remove(r);if(n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:getValue(s,!0),items:getItems(s)})},clear(s){for(;0!==a.length;)a.remove(0);t.setValue(e,{value:null,items:[]})},insert(s){const{index:n,displayValue:r,exportValue:i}=s.detail.insert,o=document.createElement("option");o.textContent=r;o.value=i;a.insertBefore(o,a.children[n]);t.setValue(e,{value:getValue(s,!0),items:getItems(s)})},items(s){const{items:n}=s.detail;for(;0!==a.length;)a.remove(0);for(const t of n){const{displayValue:e,exportValue:s}=t,n=document.createElement("option");n.textContent=e;n.value=s;a.appendChild(n)}a.options.length>0&&(a.options[0].selected=!0);t.setValue(e,{value:getValue(s,!0),items:getItems(s)})},indices(s){const n=new Set(s.detail.indices);for(const t of s.target.options)t.selected=n.has(t.index);t.setValue(e,{value:getValue(s,!0)})},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,s)}));a.addEventListener("input",(s=>{const n=getValue(s,!0),r=getValue(s,!1);t.setValue(e,{value:n});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,changeEx:n,willCommit:!0,commitKey:1,keyDown:!1}})}));this._setEventListeners(a,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"]],(t=>t.target.checked))}else a.addEventListener("input",(function(s){t.setValue(e,{value:getValue(s,!0)})}));this._setBackgroundColor(a);this._setDefaultPropertiesFromJS(a);this.container.appendChild(a);return this.container}}class PopupAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str)})}render(){this.container.className="popupAnnotation";if(["Line","Square","Circle","PolyLine","Polygon","Ink"].includes(this.data.parentType))return this.container;const t=`[data-annotation-id="${this.data.parentId}"]`,e=this.layer.querySelectorAll(t);if(0===e.length)return this.container;const s=new PopupElement({container:this.container,trigger:Array.from(e),color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText}),r=this.page,a=n.Util.normalizeRect([this.data.parentRect[0],r.view[3]-this.data.parentRect[1]+r.view[1],this.data.parentRect[2],r.view[3]-this.data.parentRect[3]+r.view[1]]),i=a[0]+this.data.parentRect[2]-this.data.parentRect[0],o=a[1];this.container.style.transformOrigin=`${-i}px ${-o}px`;this.container.style.left=`${i}px`;this.container.style.top=`${o}px`;this.container.appendChild(s.render());return this.container}}class PopupElement{constructor(t){this.container=t.container;this.trigger=t.trigger;this.color=t.color;this.titleObj=t.titleObj;this.modificationDate=t.modificationDate;this.contentsObj=t.contentsObj;this.richText=t.richText;this.hideWrapper=t.hideWrapper||!1;this.pinned=!1}render(){const t=document.createElement("div");t.className="popupWrapper";this.hideElement=this.hideWrapper?t:this.container;this.hideElement.hidden=!0;const e=document.createElement("div");e.className="popup";const s=this.color;if(s){const t=.7*(255-s[0])+s[0],r=.7*(255-s[1])+s[1],a=.7*(255-s[2])+s[2];e.style.backgroundColor=n.Util.makeHexColor(0|t,0|r,0|a)}const a=document.createElement("h1");a.dir=this.titleObj.dir;a.textContent=this.titleObj.str;e.appendChild(a);const i=r.PDFDateString.toDateObject(this.modificationDate);if(i){const t=document.createElement("span");t.className="popupDate";t.textContent="{{date}}, {{time}}";t.dataset.l10nId="annotation_date_string";t.dataset.l10nArgs=JSON.stringify({date:i.toLocaleDateString(),time:i.toLocaleTimeString()});e.appendChild(t)}if(!this.richText?.str||this.contentsObj?.str&&this.contentsObj.str!==this.richText.str){const t=this._formatContents(this.contentsObj);e.appendChild(t)}else{o.XfaLayer.render({xfaHtml:this.richText.html,intent:"richText",div:e});e.lastChild.className="richText popupContent"}Array.isArray(this.trigger)||(this.trigger=[this.trigger]);for(const t of this.trigger){t.addEventListener("click",this._toggle.bind(this));t.addEventListener("mouseover",this._show.bind(this,!1));t.addEventListener("mouseout",this._hide.bind(this,!1))}e.addEventListener("click",this._hide.bind(this,!0));t.appendChild(e);return t}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.className="popupContent";s.dir=e;const n=t.split(/(?:\r\n?|\n)/);for(let t=0,e=n.length;t<e;++t){const r=n[t];s.appendChild(document.createTextNode(r));t<e-1&&s.appendChild(document.createElement("br"))}return s}_toggle(){this.pinned?this._hide(!0):this._show(!0)}_show(t=!1){t&&(this.pinned=!0);if(this.hideElement.hidden){this.hideElement.hidden=!1;this.container.style.zIndex+=1}}_hide(t=!0){t&&(this.pinned=!1);if(!this.hideElement.hidden&&!this.pinned){this.hideElement.hidden=!0;this.container.style.zIndex-=1}}}class FreeTextAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="freeTextAnnotation";this.data.hasPopup||this._createPopup(null,this.data);return this.container}}class LineAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="lineAnnotation";const t=this.data,{width:e,height:s}=getRectDims(t.rect),n=this.svgFactory.create(e,s),r=this.svgFactory.createElement("svg:line");r.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]);r.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]);r.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]);r.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]);r.setAttribute("stroke-width",t.borderStyle.width||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");n.appendChild(r);this.container.append(n);this._createPopup(r,t);return this.container}}class SquareAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="squareAnnotation";const t=this.data,{width:e,height:s}=getRectDims(t.rect),n=this.svgFactory.create(e,s),r=t.borderStyle.width,a=this.svgFactory.createElement("svg:rect");a.setAttribute("x",r/2);a.setAttribute("y",r/2);a.setAttribute("width",e-r);a.setAttribute("height",s-r);a.setAttribute("stroke-width",r||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.appendChild(a);this.container.append(n);this._createPopup(a,t);return this.container}}class CircleAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="circleAnnotation";const t=this.data,{width:e,height:s}=getRectDims(t.rect),n=this.svgFactory.create(e,s),r=t.borderStyle.width,a=this.svgFactory.createElement("svg:ellipse");a.setAttribute("cx",e/2);a.setAttribute("cy",s/2);a.setAttribute("rx",e/2-r/2);a.setAttribute("ry",s/2-r/2);a.setAttribute("stroke-width",r||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.appendChild(a);this.container.append(n);this._createPopup(a,t);return this.container}}class PolylineAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0});this.containerClassName="polylineAnnotation";this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,{width:e,height:s}=getRectDims(t.rect),n=this.svgFactory.create(e,s);let r=[];for(const e of t.vertices){const s=e.x-t.rect[0],n=t.rect[3]-e.y;r.push(s+","+n)}r=r.join(" ");const a=this.svgFactory.createElement(this.svgElementName);a.setAttribute("points",r);a.setAttribute("stroke-width",t.borderStyle.width||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.appendChild(a);this.container.append(n);this._createPopup(a,t);return this.container}}class PolygonAnnotationElement extends PolylineAnnotationElement{constructor(t){super(t);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class CaretAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="caretAnnotation";this.data.hasPopup||this._createPopup(null,this.data);return this.container}}class InkAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0});this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline"}render(){this.container.className=this.containerClassName;const t=this.data,{width:e,height:s}=getRectDims(t.rect),n=this.svgFactory.create(e,s);for(const e of t.inkLists){let s=[];for(const n of e){const e=n.x-t.rect[0],r=t.rect[3]-n.y;s.push(`${e},${r}`)}s=s.join(" ");const r=this.svgFactory.createElement(this.svgElementName);r.setAttribute("points",s);r.setAttribute("stroke-width",t.borderStyle.width||1);r.setAttribute("stroke","transparent");r.setAttribute("fill","transparent");this._createPopup(r,t);n.appendChild(r)}this.container.append(n);return this.container}}class HighlightAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){this.data.hasPopup||this._createPopup(null,this.data);if(this.quadrilaterals)return this._renderQuadrilaterals("highlightAnnotation");this.container.className="highlightAnnotation";return this.container}}class UnderlineAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){this.data.hasPopup||this._createPopup(null,this.data);if(this.quadrilaterals)return this._renderQuadrilaterals("underlineAnnotation");this.container.className="underlineAnnotation";return this.container}}class SquigglyAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){this.data.hasPopup||this._createPopup(null,this.data);if(this.quadrilaterals)return this._renderQuadrilaterals("squigglyAnnotation");this.container.className="squigglyAnnotation";return this.container}}class StrikeOutAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0,createQuadrilaterals:!0})}render(){this.data.hasPopup||this._createPopup(null,this.data);if(this.quadrilaterals)return this._renderQuadrilaterals("strikeoutAnnotation");this.container.className="strikeoutAnnotation";return this.container}}class StampAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!!(t.data.hasPopup||t.data.titleObj?.str||t.data.contentsObj?.str||t.data.richText?.str),ignoreBorder:!0})}render(){this.container.className="stampAnnotation";this.data.hasPopup||this._createPopup(null,this.data);return this.container}}class FileAttachmentAnnotationElement extends AnnotationElement{constructor(t){super(t,{isRenderable:!0});const{filename:e,content:s}=this.data.file;this.filename=(0,r.getFilenameFromUrl)(e);this.content=s;this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,filename:e,content:s})}render(){this.container.className="fileAttachmentAnnotation";const t=document.createElement("div");t.style.height=this.container.style.height;t.style.width=this.container.style.width;t.addEventListener("dblclick",this._download.bind(this));!this.data.hasPopup&&(this.data.titleObj?.str||this.data.contentsObj?.str||this.data.richText)&&this._createPopup(t,this.data);this.container.appendChild(t);return this.container}_download(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}e.AnnotationLayer=class AnnotationLayer{static render(t){const e=[],s=[];for(const r of t.annotations){if(!r)continue;const{width:t,height:a}=getRectDims(r.rect);t<=0||a<=0||(r.annotationType!==n.AnnotationType.POPUP?e.push(r):s.push(r))}s.length&&e.push(...s);const i=t.div;for(const s of e){const e=AnnotationElementFactory.create({data:s,layer:i,page:t.page,viewport:t.viewport,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new r.DOMSVGFactory,annotationStorage:t.annotationStorage||new a.AnnotationStorage,enableScripting:t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,mouseState:t.mouseState||{isDown:!1}});if(e.isRenderable){const t=e.render();s.hidden&&(t.style.visibility="hidden");if(Array.isArray(t))for(const e of t)i.appendChild(e);else e instanceof PopupAnnotationElement?i.prepend(t):i.appendChild(t)}}this.#d(i,t.annotationCanvasMap)}static update(t){const{page:e,viewport:s,annotations:r,annotationCanvasMap:a,div:i}=t,o=s.transform,l=`matrix(${o.join(",")})`;let c,h;for(const t of r){const s=i.querySelectorAll(`[data-annotation-id="${t.id}"]`);if(s)for(const r of s)if(t.hasOwnCanvas){const s=n.Util.normalizeRect([t.rect[0],e.view[3]-t.rect[1]+e.view[1],t.rect[2],e.view[3]-t.rect[3]+e.view[1]]);if(!h){c=Math.abs(o[0]||o[1]);const t=o.slice();for(let e=0;e<4;e++)t[e]=Math.sign(t[e]);h=`matrix(${t.join(",")})`}const a=s[0]*c,i=s[1]*c;r.style.left=`${a}px`;r.style.top=`${i}px`;r.style.transformOrigin=`${-a}px ${-i}px`;r.style.transform=h}else r.style.transform=l}this.#d(i,a);i.hidden=!1}static#d(t,e){if(e){for(const[s,n]of e){const e=t.querySelector(`[data-annotation-id="${s}"]`);if(!e)continue;const{firstChild:r}=e;"CANVAS"===r.nodeName?e.replaceChild(n,r):e.insertBefore(n,r)}e.clear()}}}},(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.ColorConverters=void 0;function makeColorComp(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}e.ColorConverters=class ColorConverters{static CMYK_G([t,e,s,n]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_HTML([t]){const e=makeColorComp(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_HTML([t,e,s]){return`#${makeColorComp(t)}${makeColorComp(e)}${makeColorComp(s)}`}static T_HTML(){return"#00000000"}static CMYK_RGB([t,e,s,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,s+n),1-Math.min(1,e+n)]}static CMYK_HTML(t){return this.RGB_HTML(this.CMYK_RGB(t))}static RGB_CMYK([t,e,s]){const n=1-t,r=1-e,a=1-s;return["CMYK",n,r,a,Math.min(n,r,a)]}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.XfaLayer=void 0;var n=s(18);e.XfaLayer=class XfaLayer{static setupStorage(t,e,s,n,r){const a=n.getValue(e,{value:null});switch(s.name){case"textarea":null!==a.value&&(t.textContent=a.value);if("print"===r)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked");if("print"===r)break;t.addEventListener("change",(t=>{n.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{null!==a.value&&t.setAttribute("value",a.value);if("print"===r)break;t.addEventListener("input",(t=>{n.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value)for(const t of s.children)t.attributes.value===a.value&&(t.attributes.selected=!0);t.addEventListener("input",(t=>{const s=t.target.options,r=-1===s.selectedIndex?"":s[s.selectedIndex].value;n.setValue(e,{value:r})}))}}static setAttributes({html:t,element:e,storage:s=null,intent:n,linkService:r}){const{attributes:a}=e,i=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${n}`);for(const[e,s]of Object.entries(a))if(null!=s&&"dataId"!==e)if("style"!==e)if("textContent"===e)t.textContent=s;else if("class"===e)s.length&&t.setAttribute(e,s.join(" "));else{if(i&&("href"===e||"newWindow"===e))continue;t.setAttribute(e,s)}else Object.assign(t.style,s);i&&r.addLinkAttributes(t,a.href,a.newWindow);s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){const e=t.annotationStorage,s=t.linkService,r=t.xfaHtml,a=t.intent||"display",i=document.createElement(r.name);r.attributes&&this.setAttributes({html:i,element:r,intent:a,linkService:s});const o=[[r,-1,i]],l=t.div;l.appendChild(i);if(t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=e}"richText"!==a&&l.setAttribute("class","xfaLayer xfaFont");const c=[];for(;o.length>0;){const[t,r,i]=o[o.length-1];if(r+1===t.children.length){o.pop();continue}const l=t.children[++o[o.length-1][1]];if(null===l)continue;const{name:h}=l;if("#text"===h){const t=document.createTextNode(l.value);c.push(t);i.appendChild(t);continue}let d;d=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,h):document.createElement(h);i.appendChild(d);l.attributes&&this.setAttributes({html:d,element:l,storage:e,intent:a,linkService:s});if(l.children&&l.children.length>0)o.push([l,-1,d]);else if(l.value){const t=document.createTextNode(l.value);n.XfaText.shouldBuildText(h)&&c.push(t);d.appendChild(t)}}for(const t of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e;t.div.hidden=!1}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.renderTextLayer=function renderTextLayer(t){const e=new TextLayerRenderTask({textContent:t.textContent,textContentStream:t.textContentStream,container:t.container,viewport:t.viewport,textDivs:t.textDivs,textContentItemsStr:t.textContentItemsStr,enhanceTextSelection:t.enhanceTextSelection});e._render(t.timeout);return e};var n=s(1);const r=30,a=new Map,i=/^\s+$/g;function appendText(t,e,s,o){const l=document.createElement("span"),c=t._enhanceTextSelection?{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,originalTransform:null,paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0,scale:1}:{angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL};t._textDivs.push(l);const h=n.Util.transform(t._viewport.transform,e.transform);let d=Math.atan2(h[1],h[0]);const u=s[e.fontName];u.vertical&&(d+=Math.PI/2);const p=Math.hypot(h[2],h[3]),f=p*function getAscent(t,e){const s=a.get(t);if(s)return s;e.save();e.font=`30px ${t}`;const n=e.measureText("");let i=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(i){e.restore();const s=i/(i+o);a.set(t,s);return s}e.strokeStyle="red";e.clearRect(0,0,r,r);e.strokeText("g",0,0);let l=e.getImageData(0,0,r,r).data;o=0;for(let t=l.length-1-3;t>=0;t-=4)if(l[t]>0){o=Math.ceil(t/4/r);break}e.clearRect(0,0,r,r);e.strokeText("A",0,r);l=e.getImageData(0,0,r,r).data;i=0;for(let t=0,e=l.length;t<e;t+=4)if(l[t]>0){i=r-Math.floor(t/4/r);break}e.restore();if(i){const e=i/(i+o);a.set(t,e);return e}a.set(t,.8);return.8}(u.fontFamily,o);let g,m;if(0===d){g=h[4];m=h[5]-f}else{g=h[4]+f*Math.sin(d);m=h[5]-f*Math.cos(d)}l.style.left=`${g}px`;l.style.top=`${m}px`;l.style.fontSize=`${p}px`;l.style.fontFamily=u.fontFamily;l.setAttribute("role","presentation");l.textContent=e.str;l.dir=e.dir;t._fontInspectorEnabled&&(l.dataset.fontName=e.fontName);0!==d&&(c.angle=d*(180/Math.PI));let _=!1;if(e.str.length>1||t._enhanceTextSelection&&i.test(e.str))_=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),s=Math.abs(e.transform[3]);t!==s&&Math.max(t,s)/Math.min(t,s)>1.5&&(_=!0)}_&&(u.vertical?c.canvasWidth=e.height*t._viewport.scale:c.canvasWidth=e.width*t._viewport.scale);t._textDivProperties.set(l,c);t._textContentStream&&t._layoutText(l);if(t._enhanceTextSelection&&c.hasText){let s=1,r=0;if(0!==d){s=Math.cos(d);r=Math.sin(d)}const a=(u.vertical?e.height:e.width)*t._viewport.scale,i=p;let o,c;if(0!==d){o=[s,r,-r,s,g,m];c=n.Util.getAxialAlignedBoundingBox([0,0,a,i],o)}else c=[g,m,g+a,m+i];t._bounds.push({left:c[0],top:c[1],right:c[2],bottom:c[3],div:l,size:[a,i],m:o})}}function render(t){if(t._canceled)return;const e=t._textDivs,s=t._capability,n=e.length;if(n>1e5){t._renderingDone=!0;s.resolve()}else{if(!t._textContentStream)for(let s=0;s<n;s++)t._layoutText(e[s]);t._renderingDone=!0;s.resolve()}}function findPositiveMin(t,e,s){let n=0;for(let r=0;r<s;r++){const s=t[e++];s>0&&(n=n?Math.min(s,n):s)}return n}function expand(t){const e=t._bounds,s=t._viewport,r=function expandBounds(t,e,s){const n=s.map((function(t,e){return{x1:t.left,y1:t.top,x2:t.right,y2:t.bottom,index:e,x1New:void 0,x2New:void 0}}));expandBoundsLTR(t,n);const r=new Array(s.length);for(const t of n){const e=t.index;r[e]={left:t.x1New,top:0,right:t.x2New,bottom:0}}s.map((function(e,s){const a=r[s],i=n[s];i.x1=e.top;i.y1=t-a.right;i.x2=e.bottom;i.y2=t-a.left;i.index=s;i.x1New=void 0;i.x2New=void 0}));expandBoundsLTR(e,n);for(const t of n){const e=t.index;r[e].top=t.x1New;r[e].bottom=t.x2New}return r}(s.width,s.height,e);for(let s=0;s<r.length;s++){const a=e[s].div,i=t._textDivProperties.get(a);if(0===i.angle){i.paddingLeft=e[s].left-r[s].left;i.paddingTop=e[s].top-r[s].top;i.paddingRight=r[s].right-e[s].right;i.paddingBottom=r[s].bottom-e[s].bottom;t._textDivProperties.set(a,i);continue}const o=r[s],l=e[s],c=l.m,h=c[0],d=c[1],u=[[0,0],[0,l.size[1]],[l.size[0],0],l.size],p=new Float64Array(64);for(let t=0,e=u.length;t<e;t++){const e=n.Util.applyTransform(u[t],c);p[t+0]=h&&(o.left-e[0])/h;p[t+4]=d&&(o.top-e[1])/d;p[t+8]=h&&(o.right-e[0])/h;p[t+12]=d&&(o.bottom-e[1])/d;p[t+16]=d&&(o.left-e[0])/-d;p[t+20]=h&&(o.top-e[1])/h;p[t+24]=d&&(o.right-e[0])/-d;p[t+28]=h&&(o.bottom-e[1])/h;p[t+32]=h&&(o.left-e[0])/-h;p[t+36]=d&&(o.top-e[1])/-d;p[t+40]=h&&(o.right-e[0])/-h;p[t+44]=d&&(o.bottom-e[1])/-d;p[t+48]=d&&(o.left-e[0])/d;p[t+52]=h&&(o.top-e[1])/-h;p[t+56]=d&&(o.right-e[0])/d;p[t+60]=h&&(o.bottom-e[1])/-h}const f=1+Math.min(Math.abs(h),Math.abs(d));i.paddingLeft=findPositiveMin(p,32,16)/f;i.paddingTop=findPositiveMin(p,48,16)/f;i.paddingRight=findPositiveMin(p,0,16)/f;i.paddingBottom=findPositiveMin(p,16,16)/f;t._textDivProperties.set(a,i)}}function expandBoundsLTR(t,e){e.sort((function(t,e){return t.x1-e.x1||t.index-e.index}));const s=[{start:-1/0,end:1/0,boundary:{x1:-1/0,y1:-1/0,x2:0,y2:1/0,index:-1,x1New:0,x2New:0}}];for(const t of e){let e=0;for(;e<s.length&&s[e].end<=t.y1;)e++;let n,r,a=s.length-1;for(;a>=0&&s[a].start>=t.y2;)a--;let i,o,l=-1/0;for(i=e;i<=a;i++){n=s[i];r=n.boundary;let e;e=r.x2>t.x1?r.index>t.index?r.x1New:t.x1:void 0===r.x2New?(r.x2+t.x1)/2:r.x2New;e>l&&(l=e)}t.x1New=l;for(i=e;i<=a;i++){n=s[i];r=n.boundary;void 0===r.x2New?r.x2>t.x1?r.index>t.index&&(r.x2New=r.x2):r.x2New=l:r.x2New>l&&(r.x2New=Math.max(l,r.x2))}const c=[];let h=null;for(i=e;i<=a;i++){n=s[i];r=n.boundary;const e=r.x2>t.x2?r:t;if(h===e)c[c.length-1].end=n.end;else{c.push({start:n.start,end:n.end,boundary:e});h=e}}if(s[e].start<t.y1){c[0].start=t.y1;c.unshift({start:s[e].start,end:t.y1,boundary:s[e].boundary})}if(t.y2<s[a].end){c[c.length-1].end=t.y2;c.push({start:t.y2,end:s[a].end,boundary:s[a].boundary})}for(i=e;i<=a;i++){n=s[i];r=n.boundary;if(void 0!==r.x2New)continue;let t=!1;for(o=e-1;!t&&o>=0&&s[o].start>=r.y1;o--)t=s[o].boundary===r;for(o=a+1;!t&&o<s.length&&s[o].end<=r.y2;o++)t=s[o].boundary===r;for(o=0;!t&&o<c.length;o++)t=c[o].boundary===r;t||(r.x2New=l)}Array.prototype.splice.apply(s,[e,a-e+1].concat(c))}for(const e of s){const s=e.boundary;void 0===s.x2New&&(s.x2New=Math.max(t,s.x2))}}class TextLayerRenderTask{constructor({textContent:t,textContentStream:e,container:s,viewport:r,textDivs:a,textContentItemsStr:i,enhanceTextSelection:o}){this._textContent=t;this._textContentStream=e;this._container=s;this._document=s.ownerDocument;this._viewport=r;this._textDivs=a||[];this._textContentItemsStr=i||[];this._enhanceTextSelection=!!o;this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled;this._reader=null;this._layoutTextLastFontSize=null;this._layoutTextLastFontFamily=null;this._layoutTextCtx=null;this._textDivProperties=new WeakMap;this._renderingDone=!1;this._canceled=!1;this._capability=(0,n.createPromiseCapability)();this._renderTimer=null;this._bounds=[];this._capability.promise.finally((()=>{this._enhanceTextSelection||(this._textDivProperties=null);if(this._layoutTextCtx){this._layoutTextCtx.canvas.width=0;this._layoutTextCtx.canvas.height=0;this._layoutTextCtx=null}})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0;if(this._reader){this._reader.cancel(new n.AbortException("TextLayer task cancelled.")).catch((()=>{}));this._reader=null}if(null!==this._renderTimer){clearTimeout(this._renderTimer);this._renderTimer=null}this._capability.reject(new Error("TextLayer task cancelled."))}_processItems(t,e){for(let s=0,n=t.length;s<n;s++)if(void 0!==t[s].str){this._textContentItemsStr.push(t[s].str);appendText(this,t[s],e,this._layoutTextCtx)}else if("beginMarkedContentProps"===t[s].type||"beginMarkedContent"===t[s].type){const e=this._container;this._container=document.createElement("span");this._container.classList.add("markedContent");null!==t[s].id&&this._container.setAttribute("id",`${t[s].id}`);e.appendChild(this._container)}else"endMarkedContent"===t[s].type&&(this._container=this._container.parentNode)}_layoutText(t){const e=this._textDivProperties.get(t);let s="";if(0!==e.canvasWidth&&e.hasText){const{fontSize:n,fontFamily:r}=t.style;if(n!==this._layoutTextLastFontSize||r!==this._layoutTextLastFontFamily){this._layoutTextCtx.font=`${n} ${r}`;this._layoutTextLastFontSize=n;this._layoutTextLastFontFamily=r}const{width:a}=this._layoutTextCtx.measureText(t.textContent);if(a>0){const t=e.canvasWidth/a;this._enhanceTextSelection&&(e.scale=t);s=`scaleX(${t})`}}0!==e.angle&&(s=`rotate(${e.angle}deg) ${s}`);if(s.length>0){this._enhanceTextSelection&&(e.originalTransform=s);t.style.transform=s}e.hasText&&this._container.appendChild(t);if(e.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation");this._container.appendChild(t)}}_render(t=0){const e=(0,n.createPromiseCapability)();let s=Object.create(null);const a=this._document.createElement("canvas");a.height=a.width=r;this._layoutTextCtx=a.getContext("2d",{alpha:!1});if(this._textContent){const t=this._textContent.items,s=this._textContent.styles;this._processItems(t,s);e.resolve()}else{if(!this._textContentStream)throw new Error('Neither "textContent" nor "textContentStream" parameters specified.');{const pump=()=>{this._reader.read().then((({value:t,done:n})=>{if(n)e.resolve();else{Object.assign(s,t.styles);this._processItems(t.items,s);pump()}}),e.reject)};this._reader=this._textContentStream.getReader();pump()}}e.promise.then((()=>{s=null;t?this._renderTimer=setTimeout((()=>{render(this);this._renderTimer=null}),t):render(this)}),this._capability.reject)}expandTextDivs(t=!1){if(!this._enhanceTextSelection||!this._renderingDone)return;if(null!==this._bounds){expand(this);this._bounds=null}const e=[],s=[];for(let n=0,r=this._textDivs.length;n<r;n++){const r=this._textDivs[n],a=this._textDivProperties.get(r);if(a.hasText)if(t){e.length=0;s.length=0;a.originalTransform&&e.push(a.originalTransform);if(a.paddingTop>0){s.push(`${a.paddingTop}px`);e.push(`translateY(${-a.paddingTop}px)`)}else s.push(0);a.paddingRight>0?s.push(a.paddingRight/a.scale+"px"):s.push(0);a.paddingBottom>0?s.push(`${a.paddingBottom}px`):s.push(0);if(a.paddingLeft>0){s.push(a.paddingLeft/a.scale+"px");e.push(`translateX(${-a.paddingLeft/a.scale}px)`)}else s.push(0);r.style.padding=s.join(" ");e.length&&(r.style.transform=e.join(" "))}else{r.style.padding=null;r.style.transform=a.originalTransform}}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.SVGGraphics=void 0;var n=s(1),r=s(5),a=s(3);let i=class{constructor(){(0,n.unreachable)("Not implemented: SVGGraphics")}};e.SVGGraphics=i;{const o={fontStyle:"normal",fontWeight:"normal",fillColor:"#000000"},l="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/1999/xlink",h=["butt","round","square"],d=["miter","round","bevel"],createObjectURL=function(t,e="",s=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!s)return URL.createObjectURL(new Blob([t],{type:e}));const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let r=`data:${e};base64,`;for(let e=0,s=t.length;e<s;e+=3){const a=255&t[e],i=255&t[e+1],o=255&t[e+2];r+=n[a>>2]+n[(3&a)<<4|i>>4]+n[e+1<s?(15&i)<<2|o>>6:64]+n[e+2<s?63&o:64]}return r},u=function(){const t=new Uint8Array([137,80,78,71,13,10,26,10]),e=new Int32Array(256);for(let t=0;t<256;t++){let s=t;for(let t=0;t<8;t++)s=1&s?3988292384^s>>1&2147483647:s>>1&2147483647;e[t]=s}function writePngChunk(t,s,n,r){let a=r;const i=s.length;n[a]=i>>24&255;n[a+1]=i>>16&255;n[a+2]=i>>8&255;n[a+3]=255&i;a+=4;n[a]=255&t.charCodeAt(0);n[a+1]=255&t.charCodeAt(1);n[a+2]=255&t.charCodeAt(2);n[a+3]=255&t.charCodeAt(3);a+=4;n.set(s,a);a+=s.length;const o=function crc32(t,s,n){let r=-1;for(let a=s;a<n;a++){const s=255&(r^t[a]);r=r>>>8^e[s]}return-1^r}(n,r+4,a);n[a]=o>>24&255;n[a+1]=o>>16&255;n[a+2]=o>>8&255;n[a+3]=255&o}function deflateSyncUncompressed(t){let e=t.length;const s=65535,n=Math.ceil(e/s),r=new Uint8Array(2+e+5*n+4);let a=0;r[a++]=120;r[a++]=156;let i=0;for(;e>s;){r[a++]=0;r[a++]=255;r[a++]=255;r[a++]=0;r[a++]=0;r.set(t.subarray(i,i+s),a);a+=s;i+=s;e-=s}r[a++]=1;r[a++]=255&e;r[a++]=e>>8&255;r[a++]=255&~e;r[a++]=(65535&~e)>>8&255;r.set(t.subarray(i),a);a+=t.length-i;const o=function adler32(t,e,s){let n=1,r=0;for(let a=e;a<s;++a){n=(n+(255&t[a]))%65521;r=(r+n)%65521}return r<<16|n}(t,0,t.length);r[a++]=o>>24&255;r[a++]=o>>16&255;r[a++]=o>>8&255;r[a++]=255&o;return r}function encode(e,s,r,i){const o=e.width,l=e.height;let c,h,d;const u=e.data;switch(s){case n.ImageKind.GRAYSCALE_1BPP:h=0;c=1;d=o+7>>3;break;case n.ImageKind.RGB_24BPP:h=2;c=8;d=3*o;break;case n.ImageKind.RGBA_32BPP:h=6;c=8;d=4*o;break;default:throw new Error("invalid format")}const p=new Uint8Array((1+d)*l);let f=0,g=0;for(let t=0;t<l;++t){p[f++]=0;p.set(u.subarray(g,g+d),f);g+=d;f+=d}if(s===n.ImageKind.GRAYSCALE_1BPP&&i){f=0;for(let t=0;t<l;t++){f++;for(let t=0;t<d;t++)p[f++]^=255}}const m=new Uint8Array([o>>24&255,o>>16&255,o>>8&255,255&o,l>>24&255,l>>16&255,l>>8&255,255&l,c,h,0,0,0]),_=function deflateSync(t){if(!a.isNodeJS)return deflateSyncUncompressed(t);try{let e;e=parseInt(process.versions.node)>=8?t:Buffer.from(t);const s=require("zlib").deflateSync(e,{level:9});return s instanceof Uint8Array?s:new Uint8Array(s)}catch(t){(0,n.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+t)}return deflateSyncUncompressed(t)}(p),A=t.length+36+m.length+_.length,b=new Uint8Array(A);let y=0;b.set(t,y);y+=t.length;writePngChunk("IHDR",m,b,y);y+=12+m.length;writePngChunk("IDATA",_,b,y);y+=12+_.length;writePngChunk("IEND",new Uint8Array(0),b,y);return createObjectURL(b,"image/png",r)}return function convertImgDataToPng(t,e,s){return encode(t,void 0===t.kind?n.ImageKind.GRAYSCALE_1BPP:t.kind,e,s)}}();class SVGExtraState{constructor(){this.fontSizeScale=1;this.fontWeight=o.fontWeight;this.fontSize=0;this.textMatrix=n.IDENTITY_MATRIX;this.fontMatrix=n.FONT_IDENTITY_MATRIX;this.leading=0;this.textRenderingMode=n.TextRenderingMode.FILL;this.textMatrixScale=1;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRise=0;this.fillColor=o.fillColor;this.strokeColor="#000000";this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.lineJoin="";this.lineCap="";this.miterLimit=0;this.dashArray=[];this.dashPhase=0;this.dependencies=[];this.activeClipUrl=null;this.clipGroup=null;this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(t,e){this.x=t;this.y=e}}function opListToTree(t){let e=[];const s=[];for(const n of t)if("save"!==n.fn)"restore"===n.fn?e=s.pop():e.push(n);else{e.push({fnId:92,fn:"group",items:[]});s.push(e);e=e[e.length-1].items}return e}function pf(t){if(Number.isInteger(t))return t.toString();const e=t.toFixed(10);let s=e.length-1;if("0"!==e[s])return e;do{s--}while("0"===e[s]);return e.substring(0,"."===e[s]?s:s+1)}function pm(t){if(0===t[4]&&0===t[5]){if(0===t[1]&&0===t[2])return 1===t[0]&&1===t[3]?"":`scale(${pf(t[0])} ${pf(t[3])})`;if(t[0]===t[3]&&t[1]===-t[2]){return`rotate(${pf(180*Math.acos(t[0])/Math.PI)})`}}else if(1===t[0]&&0===t[1]&&0===t[2]&&1===t[3])return`translate(${pf(t[4])} ${pf(t[5])})`;return`matrix(${pf(t[0])} ${pf(t[1])} ${pf(t[2])} ${pf(t[3])} ${pf(t[4])} ${pf(t[5])})`}let p=0,f=0,g=0;e.SVGGraphics=i=class{constructor(t,e,s=!1){this.svgFactory=new r.DOMSVGFactory;this.current=new SVGExtraState;this.transformMatrix=n.IDENTITY_MATRIX;this.transformStack=[];this.extraStack=[];this.commonObjs=t;this.objs=e;this.pendingClip=null;this.pendingEOFill=!1;this.embedFonts=!1;this.embeddedFonts=Object.create(null);this.cssStyle=null;this.forceDataSchema=!!s;this._operatorIdMapping=[];for(const t in n.OPS)this._operatorIdMapping[n.OPS[t]]=t}save(){this.transformStack.push(this.transformMatrix);const t=this.current;this.extraStack.push(t);this.current=t.clone()}restore(){this.transformMatrix=this.transformStack.pop();this.current=this.extraStack.pop();this.pendingClip=null;this.tgrp=null}group(t){this.save();this.executeOpTree(t);this.restore()}loadDependencies(t){const e=t.fnArray,s=t.argsArray;for(let t=0,r=e.length;t<r;t++)if(e[t]===n.OPS.dependency)for(const e of s[t]){const t=e.startsWith("g_")?this.commonObjs:this.objs,s=new Promise((s=>{t.get(e,s)}));this.current.dependencies.push(s)}return Promise.all(this.current.dependencies)}transform(t,e,s,r,a,i){const o=[t,e,s,r,a,i];this.transformMatrix=n.Util.transform(this.transformMatrix,o);this.tgrp=null}getSVG(t,e){this.viewport=e;const s=this._initialize(e);return this.loadDependencies(t).then((()=>{this.transformMatrix=n.IDENTITY_MATRIX;this.executeOpTree(this.convertOpList(t));return s}))}convertOpList(t){const e=this._operatorIdMapping,s=t.argsArray,n=t.fnArray,r=[];for(let t=0,a=n.length;t<a;t++){const a=n[t];r.push({fnId:a,fn:e[a],args:s[t]})}return opListToTree(r)}executeOpTree(t){for(const e of t){const t=e.fn,s=e.fnId,r=e.args;switch(0|s){case n.OPS.beginText:this.beginText();break;case n.OPS.dependency:break;case n.OPS.setLeading:this.setLeading(r);break;case n.OPS.setLeadingMoveText:this.setLeadingMoveText(r[0],r[1]);break;case n.OPS.setFont:this.setFont(r);break;case n.OPS.showText:case n.OPS.showSpacedText:this.showText(r[0]);break;case n.OPS.endText:this.endText();break;case n.OPS.moveText:this.moveText(r[0],r[1]);break;case n.OPS.setCharSpacing:this.setCharSpacing(r[0]);break;case n.OPS.setWordSpacing:this.setWordSpacing(r[0]);break;case n.OPS.setHScale:this.setHScale(r[0]);break;case n.OPS.setTextMatrix:this.setTextMatrix(r[0],r[1],r[2],r[3],r[4],r[5]);break;case n.OPS.setTextRise:this.setTextRise(r[0]);break;case n.OPS.setTextRenderingMode:this.setTextRenderingMode(r[0]);break;case n.OPS.setLineWidth:this.setLineWidth(r[0]);break;case n.OPS.setLineJoin:this.setLineJoin(r[0]);break;case n.OPS.setLineCap:this.setLineCap(r[0]);break;case n.OPS.setMiterLimit:this.setMiterLimit(r[0]);break;case n.OPS.setFillRGBColor:this.setFillRGBColor(r[0],r[1],r[2]);break;case n.OPS.setStrokeRGBColor:this.setStrokeRGBColor(r[0],r[1],r[2]);break;case n.OPS.setStrokeColorN:this.setStrokeColorN(r);break;case n.OPS.setFillColorN:this.setFillColorN(r);break;case n.OPS.shadingFill:this.shadingFill(r[0]);break;case n.OPS.setDash:this.setDash(r[0],r[1]);break;case n.OPS.setRenderingIntent:this.setRenderingIntent(r[0]);break;case n.OPS.setFlatness:this.setFlatness(r[0]);break;case n.OPS.setGState:this.setGState(r[0]);break;case n.OPS.fill:this.fill();break;case n.OPS.eoFill:this.eoFill();break;case n.OPS.stroke:this.stroke();break;case n.OPS.fillStroke:this.fillStroke();break;case n.OPS.eoFillStroke:this.eoFillStroke();break;case n.OPS.clip:this.clip("nonzero");break;case n.OPS.eoClip:this.clip("evenodd");break;case n.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case n.OPS.paintImageXObject:this.paintImageXObject(r[0]);break;case n.OPS.paintInlineImageXObject:this.paintInlineImageXObject(r[0]);break;case n.OPS.paintImageMaskXObject:this.paintImageMaskXObject(r[0]);break;case n.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(r[0],r[1]);break;case n.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case n.OPS.closePath:this.closePath();break;case n.OPS.closeStroke:this.closeStroke();break;case n.OPS.closeFillStroke:this.closeFillStroke();break;case n.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case n.OPS.nextLine:this.nextLine();break;case n.OPS.transform:this.transform(r[0],r[1],r[2],r[3],r[4],r[5]);break;case n.OPS.constructPath:this.constructPath(r[0],r[1]);break;case n.OPS.endPath:this.endPath();break;case 92:this.group(e.items);break;default:(0,n.warn)(`Unimplemented operator ${t}`)}}}setWordSpacing(t){this.current.wordSpacing=t}setCharSpacing(t){this.current.charSpacing=t}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(t,e,s,n,r,a){const i=this.current;i.textMatrix=i.lineMatrix=[t,e,s,n,r,a];i.textMatrixScale=Math.hypot(t,e);i.x=i.lineX=0;i.y=i.lineY=0;i.xcoords=[];i.ycoords=[];i.tspan=this.svgFactory.createElement("svg:tspan");i.tspan.setAttributeNS(null,"font-family",i.fontFamily);i.tspan.setAttributeNS(null,"font-size",`${pf(i.fontSize)}px`);i.tspan.setAttributeNS(null,"y",pf(-i.y));i.txtElement=this.svgFactory.createElement("svg:text");i.txtElement.appendChild(i.tspan)}beginText(){const t=this.current;t.x=t.lineX=0;t.y=t.lineY=0;t.textMatrix=n.IDENTITY_MATRIX;t.lineMatrix=n.IDENTITY_MATRIX;t.textMatrixScale=1;t.tspan=this.svgFactory.createElement("svg:tspan");t.txtElement=this.svgFactory.createElement("svg:text");t.txtgrp=this.svgFactory.createElement("svg:g");t.xcoords=[];t.ycoords=[]}moveText(t,e){const s=this.current;s.x=s.lineX+=t;s.y=s.lineY+=e;s.xcoords=[];s.ycoords=[];s.tspan=this.svgFactory.createElement("svg:tspan");s.tspan.setAttributeNS(null,"font-family",s.fontFamily);s.tspan.setAttributeNS(null,"font-size",`${pf(s.fontSize)}px`);s.tspan.setAttributeNS(null,"y",pf(-s.y))}showText(t){const e=this.current,s=e.font,r=e.fontSize;if(0===r)return;const a=e.fontSizeScale,i=e.charSpacing,c=e.wordSpacing,h=e.fontDirection,d=e.textHScale*h,u=s.vertical,p=u?1:-1,f=s.defaultVMetrics,g=r*e.fontMatrix[0];let m=0;for(const n of t){if(null===n){m+=h*c;continue}if("number"==typeof n){m+=p*n*r/1e3;continue}const t=(n.isSpace?c:0)+i,o=n.fontChar;let l,d,_,A=n.width;if(u){let t;const e=n.vmetric||f;t=n.vmetric?e[1]:.5*A;t=-t*g;const s=e[2]*g;A=e?-e[0]:A;l=t/a;d=(m+s)/a}else{l=m/a;d=0}if(n.isInFont||s.missingFile){e.xcoords.push(e.x+l);u&&e.ycoords.push(-e.y+d);e.tspan.textContent+=o}_=u?A*g-t*h:A*g+t*h;m+=_}e.tspan.setAttributeNS(null,"x",e.xcoords.map(pf).join(" "));u?e.tspan.setAttributeNS(null,"y",e.ycoords.map(pf).join(" ")):e.tspan.setAttributeNS(null,"y",pf(-e.y));u?e.y-=m:e.x+=m*d;e.tspan.setAttributeNS(null,"font-family",e.fontFamily);e.tspan.setAttributeNS(null,"font-size",`${pf(e.fontSize)}px`);e.fontStyle!==o.fontStyle&&e.tspan.setAttributeNS(null,"font-style",e.fontStyle);e.fontWeight!==o.fontWeight&&e.tspan.setAttributeNS(null,"font-weight",e.fontWeight);const _=e.textRenderingMode&n.TextRenderingMode.FILL_STROKE_MASK;if(_===n.TextRenderingMode.FILL||_===n.TextRenderingMode.FILL_STROKE){e.fillColor!==o.fillColor&&e.tspan.setAttributeNS(null,"fill",e.fillColor);e.fillAlpha<1&&e.tspan.setAttributeNS(null,"fill-opacity",e.fillAlpha)}else e.textRenderingMode===n.TextRenderingMode.ADD_TO_PATH?e.tspan.setAttributeNS(null,"fill","transparent"):e.tspan.setAttributeNS(null,"fill","none");if(_===n.TextRenderingMode.STROKE||_===n.TextRenderingMode.FILL_STROKE){const t=1/(e.textMatrixScale||1);this._setStrokeAttributes(e.tspan,t)}let A=e.textMatrix;if(0!==e.textRise){A=A.slice();A[5]+=e.textRise}e.txtElement.setAttributeNS(null,"transform",`${pm(A)} scale(${pf(d)}, -1)`);e.txtElement.setAttributeNS(l,"xml:space","preserve");e.txtElement.appendChild(e.tspan);e.txtgrp.appendChild(e.txtElement);this._ensureTransformGroup().appendChild(e.txtElement)}setLeadingMoveText(t,e){this.setLeading(-e);this.moveText(t,e)}addFontStyle(t){if(!t.data)throw new Error('addFontStyle: No font data available, ensure that the "fontExtraProperties" API parameter is set.');if(!this.cssStyle){this.cssStyle=this.svgFactory.createElement("svg:style");this.cssStyle.setAttributeNS(null,"type","text/css");this.defs.appendChild(this.cssStyle)}const e=createObjectURL(t.data,t.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${t.loadedName}"; src: url(${e}); }\n`}setFont(t){const e=this.current,s=this.commonObjs.get(t[0]);let r=t[1];e.font=s;if(this.embedFonts&&!s.missingFile&&!this.embeddedFonts[s.loadedName]){this.addFontStyle(s);this.embeddedFonts[s.loadedName]=s}e.fontMatrix=s.fontMatrix||n.FONT_IDENTITY_MATRIX;let a="normal";s.black?a="900":s.bold&&(a="bold");const i=s.italic?"italic":"normal";if(r<0){r=-r;e.fontDirection=-1}else e.fontDirection=1;e.fontSize=r;e.fontFamily=s.loadedName;e.fontWeight=a;e.fontStyle=i;e.tspan=this.svgFactory.createElement("svg:tspan");e.tspan.setAttributeNS(null,"y",pf(-e.y));e.xcoords=[];e.ycoords=[]}endText(){const t=this.current;if(t.textRenderingMode&n.TextRenderingMode.ADD_TO_PATH_FLAG&&t.txtElement?.hasChildNodes()){t.element=t.txtElement;this.clip("nonzero");this.endPath()}}setLineWidth(t){t>0&&(this.current.lineWidth=t)}setLineCap(t){this.current.lineCap=h[t]}setLineJoin(t){this.current.lineJoin=d[t]}setMiterLimit(t){this.current.miterLimit=t}setStrokeAlpha(t){this.current.strokeAlpha=t}setStrokeRGBColor(t,e,s){this.current.strokeColor=n.Util.makeHexColor(t,e,s)}setFillAlpha(t){this.current.fillAlpha=t}setFillRGBColor(t,e,s){this.current.fillColor=n.Util.makeHexColor(t,e,s);this.current.tspan=this.svgFactory.createElement("svg:tspan");this.current.xcoords=[];this.current.ycoords=[]}setStrokeColorN(t){this.current.strokeColor=this._makeColorN_Pattern(t)}setFillColorN(t){this.current.fillColor=this._makeColorN_Pattern(t)}shadingFill(t){const e=this.viewport.width,s=this.viewport.height,r=n.Util.inverseTransform(this.transformMatrix),a=n.Util.applyTransform([0,0],r),i=n.Util.applyTransform([0,s],r),o=n.Util.applyTransform([e,0],r),l=n.Util.applyTransform([e,s],r),c=Math.min(a[0],i[0],o[0],l[0]),h=Math.min(a[1],i[1],o[1],l[1]),d=Math.max(a[0],i[0],o[0],l[0]),u=Math.max(a[1],i[1],o[1],l[1]),p=this.svgFactory.createElement("svg:rect");p.setAttributeNS(null,"x",c);p.setAttributeNS(null,"y",h);p.setAttributeNS(null,"width",d-c);p.setAttributeNS(null,"height",u-h);p.setAttributeNS(null,"fill",this._makeShadingPattern(t));this.current.fillAlpha<1&&p.setAttributeNS(null,"fill-opacity",this.current.fillAlpha);this._ensureTransformGroup().appendChild(p)}_makeColorN_Pattern(t){return"TilingPattern"===t[0]?this._makeTilingPattern(t):this._makeShadingPattern(t)}_makeTilingPattern(t){const e=t[1],s=t[2],r=t[3]||n.IDENTITY_MATRIX,[a,i,o,l]=t[4],c=t[5],h=t[6],d=t[7],u="shading"+g++,[p,f,m,_]=n.Util.normalizeRect([...n.Util.applyTransform([a,i],r),...n.Util.applyTransform([o,l],r)]),[A,b]=n.Util.singularValueDecompose2dScale(r),y=c*A,S=h*b,x=this.svgFactory.createElement("svg:pattern");x.setAttributeNS(null,"id",u);x.setAttributeNS(null,"patternUnits","userSpaceOnUse");x.setAttributeNS(null,"width",y);x.setAttributeNS(null,"height",S);x.setAttributeNS(null,"x",`${p}`);x.setAttributeNS(null,"y",`${f}`);const v=this.svg,C=this.transformMatrix,P=this.current.fillColor,w=this.current.strokeColor,k=this.svgFactory.create(m-p,_-f);this.svg=k;this.transformMatrix=r;if(2===d){const t=n.Util.makeHexColor(...e);this.current.fillColor=t;this.current.strokeColor=t}this.executeOpTree(this.convertOpList(s));this.svg=v;this.transformMatrix=C;this.current.fillColor=P;this.current.strokeColor=w;x.appendChild(k.childNodes[0]);this.defs.appendChild(x);return`url(#${u})`}_makeShadingPattern(t){"string"==typeof t&&(t=this.objs.get(t));switch(t[0]){case"RadialAxial":const e="shading"+g++,s=t[3];let r;switch(t[1]){case"axial":const s=t[4],n=t[5];r=this.svgFactory.createElement("svg:linearGradient");r.setAttributeNS(null,"id",e);r.setAttributeNS(null,"gradientUnits","userSpaceOnUse");r.setAttributeNS(null,"x1",s[0]);r.setAttributeNS(null,"y1",s[1]);r.setAttributeNS(null,"x2",n[0]);r.setAttributeNS(null,"y2",n[1]);break;case"radial":const a=t[4],i=t[5],o=t[6],l=t[7];r=this.svgFactory.createElement("svg:radialGradient");r.setAttributeNS(null,"id",e);r.setAttributeNS(null,"gradientUnits","userSpaceOnUse");r.setAttributeNS(null,"cx",i[0]);r.setAttributeNS(null,"cy",i[1]);r.setAttributeNS(null,"r",l);r.setAttributeNS(null,"fx",a[0]);r.setAttributeNS(null,"fy",a[1]);r.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${t[1]}`)}for(const t of s){const e=this.svgFactory.createElement("svg:stop");e.setAttributeNS(null,"offset",t[0]);e.setAttributeNS(null,"stop-color",t[1]);r.appendChild(e)}this.defs.appendChild(r);return`url(#${e})`;case"Mesh":(0,n.warn)("Unimplemented pattern Mesh");return null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${t[0]}`)}}setDash(t,e){this.current.dashArray=t;this.current.dashPhase=e}constructPath(t,e){const s=this.current;let r=s.x,a=s.y,i=[],o=0;for(const s of t)switch(0|s){case n.OPS.rectangle:r=e[o++];a=e[o++];const t=r+e[o++],s=a+e[o++];i.push("M",pf(r),pf(a),"L",pf(t),pf(a),"L",pf(t),pf(s),"L",pf(r),pf(s),"Z");break;case n.OPS.moveTo:r=e[o++];a=e[o++];i.push("M",pf(r),pf(a));break;case n.OPS.lineTo:r=e[o++];a=e[o++];i.push("L",pf(r),pf(a));break;case n.OPS.curveTo:r=e[o+4];a=e[o+5];i.push("C",pf(e[o]),pf(e[o+1]),pf(e[o+2]),pf(e[o+3]),pf(r),pf(a));o+=6;break;case n.OPS.curveTo2:i.push("C",pf(r),pf(a),pf(e[o]),pf(e[o+1]),pf(e[o+2]),pf(e[o+3]));r=e[o+2];a=e[o+3];o+=4;break;case n.OPS.curveTo3:r=e[o+2];a=e[o+3];i.push("C",pf(e[o]),pf(e[o+1]),pf(r),pf(a),pf(r),pf(a));o+=4;break;case n.OPS.closePath:i.push("Z")}i=i.join(" ");if(s.path&&t.length>0&&t[0]!==n.OPS.rectangle&&t[0]!==n.OPS.moveTo)i=s.path.getAttributeNS(null,"d")+i;else{s.path=this.svgFactory.createElement("svg:path");this._ensureTransformGroup().appendChild(s.path)}s.path.setAttributeNS(null,"d",i);s.path.setAttributeNS(null,"fill","none");s.element=s.path;s.setCurrentPoint(r,a)}endPath(){const t=this.current;t.path=null;if(!this.pendingClip)return;if(!t.element){this.pendingClip=null;return}const e="clippath"+p++,s=this.svgFactory.createElement("svg:clipPath");s.setAttributeNS(null,"id",e);s.setAttributeNS(null,"transform",pm(this.transformMatrix));const n=t.element.cloneNode(!0);"evenodd"===this.pendingClip?n.setAttributeNS(null,"clip-rule","evenodd"):n.setAttributeNS(null,"clip-rule","nonzero");this.pendingClip=null;s.appendChild(n);this.defs.appendChild(s);if(t.activeClipUrl){t.clipGroup=null;for(const t of this.extraStack)t.clipGroup=null;s.setAttributeNS(null,"clip-path",t.activeClipUrl)}t.activeClipUrl=`url(#${e})`;this.tgrp=null}clip(t){this.pendingClip=t}closePath(){const t=this.current;if(t.path){const e=`${t.path.getAttributeNS(null,"d")}Z`;t.path.setAttributeNS(null,"d",e)}}setLeading(t){this.current.leading=-t}setTextRise(t){this.current.textRise=t}setTextRenderingMode(t){this.current.textRenderingMode=t}setHScale(t){this.current.textHScale=t/100}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s);break;case"CA":this.setStrokeAlpha(s);break;case"ca":this.setFillAlpha(s);break;default:(0,n.warn)(`Unimplemented graphic state operator ${e}`)}}fill(){const t=this.current;if(t.element){t.element.setAttributeNS(null,"fill",t.fillColor);t.element.setAttributeNS(null,"fill-opacity",t.fillAlpha);this.endPath()}}stroke(){const t=this.current;if(t.element){this._setStrokeAttributes(t.element);t.element.setAttributeNS(null,"fill","none");this.endPath()}}_setStrokeAttributes(t,e=1){const s=this.current;let n=s.dashArray;1!==e&&n.length>0&&(n=n.map((function(t){return e*t})));t.setAttributeNS(null,"stroke",s.strokeColor);t.setAttributeNS(null,"stroke-opacity",s.strokeAlpha);t.setAttributeNS(null,"stroke-miterlimit",pf(s.miterLimit));t.setAttributeNS(null,"stroke-linecap",s.lineCap);t.setAttributeNS(null,"stroke-linejoin",s.lineJoin);t.setAttributeNS(null,"stroke-width",pf(e*s.lineWidth)+"px");t.setAttributeNS(null,"stroke-dasharray",n.map(pf).join(" "));t.setAttributeNS(null,"stroke-dashoffset",pf(e*s.dashPhase)+"px")}eoFill(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd");this.fill()}fillStroke(){this.stroke();this.fill()}eoFillStroke(){this.current.element&&this.current.element.setAttributeNS(null,"fill-rule","evenodd");this.fillStroke()}closeStroke(){this.closePath();this.stroke()}closeFillStroke(){this.closePath();this.fillStroke()}closeEOFillStroke(){this.closePath();this.eoFillStroke()}paintSolidColorImageMask(){const t=this.svgFactory.createElement("svg:rect");t.setAttributeNS(null,"x","0");t.setAttributeNS(null,"y","0");t.setAttributeNS(null,"width","1px");t.setAttributeNS(null,"height","1px");t.setAttributeNS(null,"fill",this.current.fillColor);this._ensureTransformGroup().appendChild(t)}paintImageXObject(t){const e=t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t);e?this.paintInlineImageXObject(e):(0,n.warn)(`Dependent image with object ID ${t} is not ready yet`)}paintInlineImageXObject(t,e){const s=t.width,n=t.height,r=u(t,this.forceDataSchema,!!e),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0");a.setAttributeNS(null,"y","0");a.setAttributeNS(null,"width",pf(s));a.setAttributeNS(null,"height",pf(n));this.current.element=a;this.clip("nonzero");const i=this.svgFactory.createElement("svg:image");i.setAttributeNS(c,"xlink:href",r);i.setAttributeNS(null,"x","0");i.setAttributeNS(null,"y",pf(-n));i.setAttributeNS(null,"width",pf(s)+"px");i.setAttributeNS(null,"height",pf(n)+"px");i.setAttributeNS(null,"transform",`scale(${pf(1/s)} ${pf(-1/n)})`);e?e.appendChild(i):this._ensureTransformGroup().appendChild(i)}paintImageMaskXObject(t){const e=this.current,s=t.width,n=t.height,r=e.fillColor;e.maskId="mask"+f++;const a=this.svgFactory.createElement("svg:mask");a.setAttributeNS(null,"id",e.maskId);const i=this.svgFactory.createElement("svg:rect");i.setAttributeNS(null,"x","0");i.setAttributeNS(null,"y","0");i.setAttributeNS(null,"width",pf(s));i.setAttributeNS(null,"height",pf(n));i.setAttributeNS(null,"fill",r);i.setAttributeNS(null,"mask",`url(#${e.maskId})`);this.defs.appendChild(a);this._ensureTransformGroup().appendChild(i);this.paintInlineImageXObject(t,a)}paintFormXObjectBegin(t,e){Array.isArray(t)&&6===t.length&&this.transform(t[0],t[1],t[2],t[3],t[4],t[5]);if(e){const t=e[2]-e[0],s=e[3]-e[1],n=this.svgFactory.createElement("svg:rect");n.setAttributeNS(null,"x",e[0]);n.setAttributeNS(null,"y",e[1]);n.setAttributeNS(null,"width",pf(t));n.setAttributeNS(null,"height",pf(s));this.current.element=n;this.clip("nonzero");this.endPath()}}paintFormXObjectEnd(){}_initialize(t){const e=this.svgFactory.create(t.width,t.height),s=this.svgFactory.createElement("svg:defs");e.appendChild(s);this.defs=s;const n=this.svgFactory.createElement("svg:g");n.setAttributeNS(null,"transform",pm(t.transform));e.appendChild(n);this.svg=n;return e}_ensureClipGroup(){if(!this.current.clipGroup){const t=this.svgFactory.createElement("svg:g");t.setAttributeNS(null,"clip-path",this.current.activeClipUrl);this.svg.appendChild(t);this.current.clipGroup=t}return this.current.clipGroup}_ensureTransformGroup(){if(!this.tgrp){this.tgrp=this.svgFactory.createElement("svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix));this.current.activeClipUrl?this._ensureClipGroup().appendChild(this.tgrp):this.svg.appendChild(this.tgrp)}return this.tgrp}}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.PDFNodeStream=void 0;var n=s(1),r=s(26);const a=require("fs"),i=require("http"),o=require("https"),l=require("url"),c=/^file:\/\/\/[a-zA-Z]:\//;e.PDFNodeStream=class PDFNodeStream{constructor(t){this.source=t;this.url=function parseUrl(t){const e=l.parse(t);if("file:"===e.protocol||e.host)return e;if(/^[a-z]:[/\\]/i.test(t))return l.parse(`file:///${t}`);e.host||(e.protocol="file:");return e}(t.url);this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol;this.isFsUrl="file:"===this.url.protocol;this.httpHeaders=this.isHttp&&t.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once.");this._fullRequestReader=this.isFsUrl?new PDFNodeStreamFsFullReader(this):new PDFNodeStreamFullReader(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new PDFNodeStreamFsRangeReader(this,t,e):new PDFNodeStreamRangeReader(this,t,e);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class BaseFullReader{constructor(t){this._url=t.url;this._done=!1;this._storedError=null;this.onProgress=null;const e=t.source;this._contentLength=e.length;this._loaded=0;this._filename=null;this._disableRange=e.disableRange||!1;this._rangeChunkSize=e.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!e.disableStream;this._isRangeSupported=!e.disableRange;this._readableStream=null;this._readCapability=(0,n.createPromiseCapability)();this._headersCapability=(0,n.createPromiseCapability)()}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t){this._readCapability=(0,n.createPromiseCapability)();return this.read()}this._loaded+=t.length;this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t;this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t;t.on("readable",(()=>{this._readCapability.resolve()}));t.on("end",(()=>{t.destroy();this._done=!0;this._readCapability.resolve()}));t.on("error",(t=>{this._error(t)}));!this._isStreamingSupported&&this._isRangeSupported&&this._error(new n.AbortException("streaming is disabled"));this._storedError&&this._readableStream.destroy(this._storedError)}}class BaseRangeReader{constructor(t){this._url=t.url;this._done=!1;this._storedError=null;this.onProgress=null;this._loaded=0;this._readableStream=null;this._readCapability=(0,n.createPromiseCapability)();const e=t.source;this._isStreamingSupported=!e.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t){this._readCapability=(0,n.createPromiseCapability)();return this.read()}this._loaded+=t.length;this.onProgress&&this.onProgress({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t;this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t;t.on("readable",(()=>{this._readCapability.resolve()}));t.on("end",(()=>{t.destroy();this._done=!0;this._readCapability.resolve()}));t.on("error",(t=>{this._error(t)}));this._storedError&&this._readableStream.destroy(this._storedError)}}function createRequestOptions(t,e){return{protocol:t.protocol,auth:t.auth,host:t.hostname,port:t.port,path:t.path,method:"GET",headers:e}}class PDFNodeStreamFullReader extends BaseFullReader{constructor(t){super(t);const handleResponse=e=>{if(404===e.statusCode){const t=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t;this._headersCapability.reject(t);return}this._headersCapability.resolve();this._setReadableStream(e);const getResponseHeader=t=>this._readableStream.headers[t.toLowerCase()],{allowRangeRequests:s,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s;this._contentLength=a||this._contentLength;this._filename=(0,r.extractFilenameFromHeader)(getResponseHeader)};this._request=null;"http:"===this._url.protocol?this._request=i.request(createRequestOptions(this._url,t.httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,t.httpHeaders),handleResponse);this._request.on("error",(t=>{this._storedError=t;this._headersCapability.reject(t)}));this._request.end()}}class PDFNodeStreamRangeReader extends BaseRangeReader{constructor(t,e,s){super(t);this._httpHeaders={};for(const e in t.httpHeaders){const s=t.httpHeaders[e];void 0!==s&&(this._httpHeaders[e]=s)}this._httpHeaders.Range=`bytes=${e}-${s-1}`;const handleResponse=t=>{if(404!==t.statusCode)this._setReadableStream(t);else{const t=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=t}};this._request=null;"http:"===this._url.protocol?this._request=i.request(createRequestOptions(this._url,this._httpHeaders),handleResponse):this._request=o.request(createRequestOptions(this._url,this._httpHeaders),handleResponse);this._request.on("error",(t=>{this._storedError=t}));this._request.end()}}class PDFNodeStreamFsFullReader extends BaseFullReader{constructor(t){super(t);let e=decodeURIComponent(this._url.path);c.test(this._url.href)&&(e=e.replace(/^\//,""));a.lstat(e,((t,s)=>{if(t){"ENOENT"===t.code&&(t=new n.MissingPDFException(`Missing PDF "${e}".`));this._storedError=t;this._headersCapability.reject(t)}else{this._contentLength=s.size;this._setReadableStream(a.createReadStream(e));this._headersCapability.resolve()}}))}}class PDFNodeStreamFsRangeReader extends BaseRangeReader{constructor(t,e,s){super(t);let n=decodeURIComponent(this._url.path);c.test(this._url.href)&&(n=n.replace(/^\//,""));this._setReadableStream(a.createReadStream(n,{start:e,end:s-1}))}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.createResponseStatusError=function createResponseStatusError(t,e){if(404===t||0===t&&e.startsWith("file:"))return new n.MissingPDFException('Missing PDF "'+e+'".');return new n.UnexpectedResponseException(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)};e.extractFilenameFromHeader=function extractFilenameFromHeader(t){const e=t("Content-Disposition");if(e){let t=(0,r.getFilenameFromContentDispositionHeader)(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch(t){}if((0,a.isPdfFile)(t))return t}return null};e.validateRangeRequestCapabilities=function validateRangeRequestCapabilities({getResponseHeader:t,isHttp:e,rangeChunkSize:s,disableRange:n}){const r={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t("Content-Length"),10);if(!Number.isInteger(a))return r;r.suggestedLength=a;if(a<=2*s)return r;if(n||!e)return r;if("bytes"!==t("Accept-Ranges"))return r;if("identity"!==(t("Content-Encoding")||"identity"))return r;r.allowRangeRequests=!0;return r};e.validateResponseStatus=function validateResponseStatus(t){return 200===t||206===t};var n=s(1),r=s(27),a=s(5)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.getFilenameFromContentDispositionHeader=function getFilenameFromContentDispositionHeader(t){let e=!0,s=toParamRegExp("filename\\*","i").exec(t);if(s){s=s[1];let t=rfc2616unquote(s);t=unescape(t);t=rfc5987decode(t);t=rfc2047decode(t);return fixupEncoding(t)}s=function rfc2231getparam(t){const e=[];let s;const n=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=n.exec(t));){let[,t,n,r]=s;t=parseInt(t,10);if(t in e){if(0===t)break}else e[t]=[n,r]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[s,n]=e[t];n=rfc2616unquote(n);if(s){n=unescape(n);0===t&&(n=rfc5987decode(n))}r.push(n)}return r.join("")}(t);if(s){return fixupEncoding(rfc2047decode(s))}s=toParamRegExp("filename","i").exec(t);if(s){s=s[1];let t=rfc2616unquote(s);t=rfc2047decode(t);return fixupEncoding(t)}function toParamRegExp(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function textdecode(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const r=new TextDecoder(t,{fatal:!0}),a=(0,n.stringToBytes)(s);s=r.decode(a);e=!1}catch(t){}}return s}function fixupEncoding(t){if(e&&/[\x80-\xff]/.test(t)){t=textdecode("utf-8",t);e&&(t=textdecode("iso-8859-1",t))}return t}function rfc2616unquote(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');if(-1!==s){e[t]=e[t].slice(0,s);e.length=t+1}e[t]=e[t].replace(/\\(.)/g,"$1")}t=e.join('"')}return t}function rfc5987decode(t){const e=t.indexOf("'");if(-1===e)return t;return textdecode(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function rfc2047decode(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,s,n){if("q"===s||"Q"===s)return textdecode(e,n=(n=n.replace(/_/g," ")).replace(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{n=atob(n)}catch(t){}return textdecode(e,n)}))}return""};var n=s(1)},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.PDFNetworkStream=void 0;var n=s(1),r=s(26);class NetworkManager{constructor(t,e={}){this.url=t;this.isHttp=/^https?:/i.test(t);this.httpHeaders=this.isHttp&&e.httpHeaders||Object.create(null);this.withCredentials=e.withCredentials||!1;this.getXhr=e.getXhr||function NetworkManager_getXhr(){return new XMLHttpRequest};this.currXhrId=0;this.pendingRequests=Object.create(null)}requestRange(t,e,s){const n={begin:t,end:e};for(const t in s)n[t]=s[t];return this.request(n)}requestFull(t){return this.request(t)}request(t){const e=this.getXhr(),s=this.currXhrId++,n=this.pendingRequests[s]={xhr:e};e.open("GET",this.url);e.withCredentials=this.withCredentials;for(const t in this.httpHeaders){const s=this.httpHeaders[t];void 0!==s&&e.setRequestHeader(t,s)}if(this.isHttp&&"begin"in t&&"end"in t){e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`);n.expectedStatus=206}else n.expectedStatus=200;e.responseType="arraybuffer";t.onError&&(e.onerror=function(s){t.onError(e.status)});e.onreadystatechange=this.onStateChange.bind(this,s);e.onprogress=this.onProgress.bind(this,s);n.onHeadersReceived=t.onHeadersReceived;n.onDone=t.onDone;n.onError=t.onError;n.onProgress=t.onProgress;e.send(null);return s}onProgress(t,e){const s=this.pendingRequests[t];s&&s.onProgress?.(e)}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const r=s.xhr;if(r.readyState>=2&&s.onHeadersReceived){s.onHeadersReceived();delete s.onHeadersReceived}if(4!==r.readyState)return;if(!(t in this.pendingRequests))return;delete this.pendingRequests[t];if(0===r.status&&this.isHttp){s.onError?.(r.status);return}const a=r.status||200;if(!(200===a&&206===s.expectedStatus)&&a!==s.expectedStatus){s.onError?.(r.status);return}const i=function getArrayBuffer(t){const e=t.response;return"string"!=typeof e?e:(0,n.stringToBytes)(e).buffer}(r);if(206===a){const t=r.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);s.onDone({begin:parseInt(e[1],10),chunk:i})}else i?s.onDone({begin:0,chunk:i}):s.onError?.(r.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t];e.abort()}}e.PDFNetworkStream=class PDFNetworkStream{constructor(t){this._source=t;this._manager=new NetworkManager(t.url,{httpHeaders:t.httpHeaders,withCredentials:t.withCredentials});this._rangeChunkSize=t.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once.");this._fullRequestReader=new PDFNetworkStreamFullRequestReader(this._manager,this._source);return this._fullRequestReader}getRangeReader(t,e){const s=new PDFNetworkStreamRangeRequestReader(this._manager,t,e);s.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class PDFNetworkStreamFullRequestReader{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url;this._fullRequestId=t.requestFull(s);this._headersReceivedCapability=(0,n.createPromiseCapability)();this._disableRange=e.disableRange||!1;this._contentLength=e.length;this._rangeChunkSize=e.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!1;this._isRangeSupported=!1;this._cachedChunks=[];this._requests=[];this._done=!1;this._storedError=void 0;this._filename=null;this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t),getResponseHeader=t=>e.getResponseHeader(t),{allowRangeRequests:s,suggestedLength:n}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0);this._contentLength=n||this._contentLength;this._filename=(0,r.extractFilenameFromHeader)(getResponseHeader);this._isRangeSupported&&this._manager.abortRequest(t);this._headersReceivedCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);this._done=!0;if(!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=(0,r.createResponseStatusError)(t,this._url);this._headersReceivedCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0;this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,n.createPromiseCapability)();this._requests.push(t);return t.promise}cancel(t){this._done=!0;this._headersReceivedCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId);this._fullRequestReader=null}}class PDFNetworkStreamRangeRequestReader{constructor(t,e,s){this._manager=t;const n={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url;this._requestId=t.requestRange(e,s,n);this._requests=[];this._queuedChunk=null;this._done=!1;this._storedError=void 0;this.onProgress=null;this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._close()}_onError(t){this._storedError=(0,r.createResponseStatusError)(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0;this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;this._queuedChunk=null;return{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=(0,n.createPromiseCapability)();this._requests.push(t);return t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0;this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}}},(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0});e.PDFFetchStream=void 0;var n=s(1),r=s(26);function createFetchOptions(t,e,s){return{method:"GET",headers:t,signal:s?.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function createHeaders(t){const e=new Headers;for(const s in t){const n=t[s];void 0!==n&&e.append(s,n)}return e}e.PDFFetchStream=class PDFFetchStream{constructor(t){this.source=t;this.isHttp=/^https?:/i.test(t.url);this.httpHeaders=this.isHttp&&t.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once.");this._fullRequestReader=new PDFFetchStreamReader(this);return this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new PDFFetchStreamRangeReader(this,t,e);this._rangeRequestReaders.push(s);return s}cancelAllRequests(t){this._fullRequestReader&&this._fullRequestReader.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}};class PDFFetchStreamReader{constructor(t){this._stream=t;this._reader=null;this._loaded=0;this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1;this._contentLength=e.length;this._headersCapability=(0,n.createPromiseCapability)();this._disableRange=e.disableRange||!1;this._rangeChunkSize=e.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);"undefined"!=typeof AbortController&&(this._abortController=new AbortController);this._isStreamingSupported=!e.disableStream;this._isRangeSupported=!e.disableRange;this._headers=createHeaders(this._stream.httpHeaders);const s=e.url;fetch(s,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,r.validateResponseStatus)(t.status))throw(0,r.createResponseStatusError)(t.status,s);this._reader=t.body.getReader();this._headersCapability.resolve();const getResponseHeader=e=>t.headers.get(e),{allowRangeRequests:e,suggestedLength:a}=(0,r.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=e;this._contentLength=a||this._contentLength;this._filename=(0,r.extractFilenameFromHeader)(getResponseHeader);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new n.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject);this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};this._loaded+=t.byteLength;this.onProgress&&this.onProgress({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._reader&&this._reader.cancel(t);this._abortController&&this._abortController.abort()}}class PDFFetchStreamRangeReader{constructor(t,e,s){this._stream=t;this._reader=null;this._loaded=0;const a=t.source;this._withCredentials=a.withCredentials||!1;this._readCapability=(0,n.createPromiseCapability)();this._isStreamingSupported=!a.disableStream;"undefined"!=typeof AbortController&&(this._abortController=new AbortController);this._headers=createHeaders(this._stream.httpHeaders);this._headers.append("Range",`bytes=${e}-${s-1}`);const i=a.url;fetch(i,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((t=>{if(!(0,r.validateResponseStatus)(t.status))throw(0,r.createResponseStatusError)(t.status,i);this._readCapability.resolve();this._reader=t.body.getReader()})).catch(this._readCapability.reject);this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();if(e)return{value:t,done:e};this._loaded+=t.byteLength;this.onProgress&&this.onProgress({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._reader&&this._reader.cancel(t);this._abortController&&this._abortController.abort()}}}],__webpack_module_cache__={};function __w_pdfjs_require__(t){var e=__webpack_module_cache__[t];if(void 0!==e)return e.exports;var s=__webpack_module_cache__[t]={exports:{}};__webpack_modules__[t](s,s.exports,__w_pdfjs_require__);return s.exports}var __webpack_exports__={};(()=>{var t=__webpack_exports__;Object.defineProperty(t,"__esModule",{value:!0});Object.defineProperty(t,"AnnotationLayer",{enumerable:!0,get:function(){return r.AnnotationLayer}});Object.defineProperty(t,"AnnotationMode",{enumerable:!0,get:function(){return e.AnnotationMode}});Object.defineProperty(t,"CMapCompressionType",{enumerable:!0,get:function(){return e.CMapCompressionType}});Object.defineProperty(t,"GlobalWorkerOptions",{enumerable:!0,get:function(){return a.GlobalWorkerOptions}});Object.defineProperty(t,"InvalidPDFException",{enumerable:!0,get:function(){return e.InvalidPDFException}});Object.defineProperty(t,"LoopbackPort",{enumerable:!0,get:function(){return s.LoopbackPort}});Object.defineProperty(t,"MissingPDFException",{enumerable:!0,get:function(){return e.MissingPDFException}});Object.defineProperty(t,"OPS",{enumerable:!0,get:function(){return e.OPS}});Object.defineProperty(t,"PDFDataRangeTransport",{enumerable:!0,get:function(){return s.PDFDataRangeTransport}});Object.defineProperty(t,"PDFDateString",{enumerable:!0,get:function(){return n.PDFDateString}});Object.defineProperty(t,"PDFWorker",{enumerable:!0,get:function(){return s.PDFWorker}});Object.defineProperty(t,"PasswordResponses",{enumerable:!0,get:function(){return e.PasswordResponses}});Object.defineProperty(t,"PermissionFlag",{enumerable:!0,get:function(){return e.PermissionFlag}});Object.defineProperty(t,"PixelsPerInch",{enumerable:!0,get:function(){return n.PixelsPerInch}});Object.defineProperty(t,"RenderingCancelledException",{enumerable:!0,get:function(){return n.RenderingCancelledException}});Object.defineProperty(t,"SVGGraphics",{enumerable:!0,get:function(){return l.SVGGraphics}});Object.defineProperty(t,"UNSUPPORTED_FEATURES",{enumerable:!0,get:function(){return e.UNSUPPORTED_FEATURES}});Object.defineProperty(t,"UnexpectedResponseException",{enumerable:!0,get:function(){return e.UnexpectedResponseException}});Object.defineProperty(t,"Util",{enumerable:!0,get:function(){return e.Util}});Object.defineProperty(t,"VerbosityLevel",{enumerable:!0,get:function(){return e.VerbosityLevel}});Object.defineProperty(t,"XfaLayer",{enumerable:!0,get:function(){return c.XfaLayer}});Object.defineProperty(t,"build",{enumerable:!0,get:function(){return s.build}});Object.defineProperty(t,"createPromiseCapability",{enumerable:!0,get:function(){return e.createPromiseCapability}});Object.defineProperty(t,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return e.createValidAbsoluteUrl}});Object.defineProperty(t,"getDocument",{enumerable:!0,get:function(){return s.getDocument}});Object.defineProperty(t,"getFilenameFromUrl",{enumerable:!0,get:function(){return n.getFilenameFromUrl}});Object.defineProperty(t,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return n.getPdfFilenameFromUrl}});Object.defineProperty(t,"getXfaPageViewport",{enumerable:!0,get:function(){return n.getXfaPageViewport}});Object.defineProperty(t,"isPdfFile",{enumerable:!0,get:function(){return n.isPdfFile}});Object.defineProperty(t,"loadScript",{enumerable:!0,get:function(){return n.loadScript}});Object.defineProperty(t,"renderTextLayer",{enumerable:!0,get:function(){return o.renderTextLayer}});Object.defineProperty(t,"shadow",{enumerable:!0,get:function(){return e.shadow}});Object.defineProperty(t,"version",{enumerable:!0,get:function(){return s.version}});var e=__w_pdfjs_require__(1),s=__w_pdfjs_require__(4),n=__w_pdfjs_require__(5),r=__w_pdfjs_require__(20),a=__w_pdfjs_require__(13),i=__w_pdfjs_require__(3),o=__w_pdfjs_require__(23),l=__w_pdfjs_require__(24),c=__w_pdfjs_require__(22);if(i.isNodeJS){const{PDFNodeStream:t}=__w_pdfjs_require__(25);(0,s.setPDFNetworkStreamFactory)((e=>new t(e)))}else{const{PDFNetworkStream:t}=__w_pdfjs_require__(28),{PDFFetchStream:e}=__w_pdfjs_require__(29);(0,s.setPDFNetworkStreamFactory)((s=>(0,n.isValidFetchUrl)(s.url)?new e(s):new t(s)))}})();return __webpack_exports__})()));