/**
 * @licstart The following is the entire license notice for the
 * JavaScript code in this page
 *
 * Copyright 2023 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @licend The above is the entire license notice for the
 * JavaScript code in this page
 */
!function webpackUniversalModuleDefinition(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=e.pdfjsLib=t():"function"==typeof define&&define.amd?define("pdfjs-dist/build/pdf",[],(()=>e.pdfjsLib=t())):"object"==typeof exports?exports["pdfjs-dist/build/pdf"]=e.pdfjsLib=t():e["pdfjs-dist/build/pdf"]=e.pdfjsLib=t()}(globalThis,(()=>(()=>{"use strict";var __webpack_modules__=[,(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.VerbosityLevel=t.Util=t.UnknownErrorException=t.UnexpectedResponseException=t.TextRenderingMode=t.RenderingIntentFlag=t.PromiseCapability=t.PermissionFlag=t.PasswordResponses=t.PasswordException=t.PageActionEventType=t.OPS=t.MissingPDFException=t.MAX_IMAGE_SIZE_TO_CACHE=t.LINE_FACTOR=t.LINE_DESCENT_FACTOR=t.InvalidPDFException=t.ImageKind=t.IDENTITY_MATRIX=t.FormatError=t.FeatureTest=t.FONT_IDENTITY_MATRIX=t.DocumentActionEventType=t.CMapCompressionType=t.BaseException=t.BASELINE_FACTOR=t.AnnotationType=t.AnnotationReplyType=t.AnnotationPrefix=t.AnnotationMode=t.AnnotationFlag=t.AnnotationFieldFlag=t.AnnotationEditorType=t.AnnotationEditorPrefix=t.AnnotationEditorParamsType=t.AnnotationBorderStyleType=t.AnnotationActionEventType=t.AbortException=void 0;t.assert=function assert(e,t){e||unreachable(t)};t.bytesToString=bytesToString;t.createValidAbsoluteUrl=function createValidAbsoluteUrl(e,t=null,i=null){if(!e)return null;try{if(i&&"string"==typeof e){if(i.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(i.tryConvertEncoding)try{e=stringToUTF8String(e)}catch{}}const n=t?new URL(e,t):new URL(e);if(function _isValidProtocol(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n))return n}catch{}return null};t.getModificationDate=function getModificationDate(e=new Date){return[e.getUTCFullYear().toString(),(e.getUTCMonth()+1).toString().padStart(2,"0"),e.getUTCDate().toString().padStart(2,"0"),e.getUTCHours().toString().padStart(2,"0"),e.getUTCMinutes().toString().padStart(2,"0"),e.getUTCSeconds().toString().padStart(2,"0")].join("")};t.getUuid=function getUuid(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(255*Math.random());return bytesToString(e)};t.getVerbosityLevel=function getVerbosityLevel(){return s};t.info=function info(e){s>=n.INFOS&&console.log(`Info: ${e}`)};t.isArrayBuffer=function isArrayBuffer(e){return"object"==typeof e&&void 0!==e?.byteLength};t.isArrayEqual=function isArrayEqual(e,t){if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(e[i]!==t[i])return!1;return!0};t.isNodeJS=void 0;t.normalizeUnicode=function normalizeUnicode(e){if(!l){l=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu;d=new Map([["ﬅ","ſt"]])}return e.replaceAll(l,((e,t,i)=>t?t.normalize("NFKC"):d.get(i)))};t.objectFromMap=function objectFromMap(e){const t=Object.create(null);for(const[i,n]of e)t[i]=n;return t};t.objectSize=function objectSize(e){return Object.keys(e).length};t.setVerbosityLevel=function setVerbosityLevel(e){Number.isInteger(e)&&(s=e)};t.shadow=shadow;t.string32=function string32(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)};t.stringToBytes=stringToBytes;t.stringToPDFString=function stringToPDFString(e){if(e[0]>="ï"){let t;"þ"===e[0]&&"ÿ"===e[1]?t="utf-16be":"ÿ"===e[0]&&"þ"===e[1]?t="utf-16le":"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8");if(t)try{const i=new TextDecoder(t,{fatal:!0}),n=stringToBytes(e);return i.decode(n)}catch(e){warn(`stringToPDFString: "${e}".`)}}const t=[];for(let i=0,n=e.length;i<n;i++){const n=o[e.charCodeAt(i)];t.push(n?String.fromCharCode(n):e.charAt(i))}return t.join("")};t.stringToUTF8String=stringToUTF8String;t.unreachable=unreachable;t.utf8StringToString=function utf8StringToString(e){return unescape(encodeURIComponent(e))};t.warn=warn;const i=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type);t.isNodeJS=i;t.IDENTITY_MATRIX=[1,0,0,1,0,0];t.FONT_IDENTITY_MATRIX=[.001,0,0,.001,0,0];t.MAX_IMAGE_SIZE_TO_CACHE=1e7;t.LINE_FACTOR=1.35;t.LINE_DESCENT_FACTOR=.35;t.BASELINE_FACTOR=.25925925925925924;t.RenderingIntentFlag={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256};t.AnnotationMode={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3};t.AnnotationEditorPrefix="pdfjs_internal_editor_";t.AnnotationEditorType={DISABLE:-1,NONE:0,FREETEXT:3,STAMP:13,INK:15};t.AnnotationEditorParamsType={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23};t.PermissionFlag={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048};t.TextRenderingMode={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4};t.ImageKind={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3};t.AnnotationType={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26};t.AnnotationReplyType={GROUP:"Group",REPLY:"R"};t.AnnotationFlag={INVISIBLE:1,HIDDEN:2,PRINT:4,NOZOOM:8,NOROTATE:16,NOVIEW:32,READONLY:64,LOCKED:128,TOGGLENOVIEW:256,LOCKEDCONTENTS:512};t.AnnotationFieldFlag={READONLY:1,REQUIRED:2,NOEXPORT:4,MULTILINE:4096,PASSWORD:8192,NOTOGGLETOOFF:16384,RADIO:32768,PUSHBUTTON:65536,COMBO:131072,EDIT:262144,SORT:524288,FILESELECT:1048576,MULTISELECT:2097152,DONOTSPELLCHECK:4194304,DONOTSCROLL:8388608,COMB:16777216,RICHTEXT:33554432,RADIOSINUNISON:33554432,COMMITONSELCHANGE:67108864};t.AnnotationBorderStyleType={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5};t.AnnotationActionEventType={E:"Mouse Enter",X:"Mouse Exit",D:"Mouse Down",U:"Mouse Up",Fo:"Focus",Bl:"Blur",PO:"PageOpen",PC:"PageClose",PV:"PageVisible",PI:"PageInvisible",K:"Keystroke",F:"Format",V:"Validate",C:"Calculate"};t.DocumentActionEventType={WC:"WillClose",WS:"WillSave",DS:"DidSave",WP:"WillPrint",DP:"DidPrint"};t.PageActionEventType={O:"PageOpen",C:"PageClose"};const n={ERRORS:0,WARNINGS:1,INFOS:5};t.VerbosityLevel=n;t.CMapCompressionType={NONE:0,BINARY:1};t.OPS={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91};t.PasswordResponses={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let s=n.WARNINGS;function warn(e){s>=n.WARNINGS&&console.log(`Warning: ${e}`)}function unreachable(e){throw new Error(e)}function shadow(e,t,i,n=!1){Object.defineProperty(e,t,{value:i,enumerable:!n,configurable:!0,writable:!1});return i}const a=function BaseExceptionClosure(){function BaseException(e,t){this.constructor===BaseException&&unreachable("Cannot initialize BaseException.");this.message=e;this.name=t}BaseException.prototype=new Error;BaseException.constructor=BaseException;return BaseException}();t.BaseException=a;t.PasswordException=class PasswordException extends a{constructor(e,t){super(e,"PasswordException");this.code=t}};t.UnknownErrorException=class UnknownErrorException extends a{constructor(e,t){super(e,"UnknownErrorException");this.details=t}};t.InvalidPDFException=class InvalidPDFException extends a{constructor(e){super(e,"InvalidPDFException")}};t.MissingPDFException=class MissingPDFException extends a{constructor(e){super(e,"MissingPDFException")}};t.UnexpectedResponseException=class UnexpectedResponseException extends a{constructor(e,t){super(e,"UnexpectedResponseException");this.status=t}};t.FormatError=class FormatError extends a{constructor(e){super(e,"FormatError")}};t.AbortException=class AbortException extends a{constructor(e){super(e,"AbortException")}};function bytesToString(e){"object"==typeof e&&void 0!==e?.length||unreachable("Invalid argument for bytesToString");const t=e.length,i=8192;if(t<i)return String.fromCharCode.apply(null,e);const n=[];for(let s=0;s<t;s+=i){const a=Math.min(s+i,t),r=e.subarray(s,a);n.push(String.fromCharCode.apply(null,r))}return n.join("")}function stringToBytes(e){"string"!=typeof e&&unreachable("Invalid argument for stringToBytes");const t=e.length,i=new Uint8Array(t);for(let n=0;n<t;++n)i[n]=255&e.charCodeAt(n);return i}t.FeatureTest=class FeatureTest{static get isLittleEndian(){return shadow(this,"isLittleEndian",function isLittleEndian(){const e=new Uint8Array(4);e[0]=1;return 1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return shadow(this,"isEvalSupported",function isEvalSupported(){try{new Function("");return!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return shadow(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"==typeof navigator?shadow(this,"platform",{isWin:!1,isMac:!1}):shadow(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){return shadow(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}};const r=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));t.Util=class Util{static makeHexColor(e,t,i){return`#${r[e]}${r[t]}${r[i]}`}static scaleMinMax(e,t){let i;if(e[0]){if(e[0]<0){i=t[0];t[0]=t[1];t[1]=i}t[0]*=e[0];t[1]*=e[0];if(e[3]<0){i=t[2];t[2]=t[3];t[3]=i}t[2]*=e[3];t[3]*=e[3]}else{i=t[0];t[0]=t[2];t[2]=i;i=t[1];t[1]=t[3];t[3]=i;if(e[1]<0){i=t[2];t[2]=t[3];t[3]=i}t[2]*=e[1];t[3]*=e[1];if(e[2]<0){i=t[0];t[0]=t[1];t[1]=i}t[0]*=e[2];t[1]*=e[2]}t[0]+=e[4];t[1]+=e[4];t[2]+=e[5];t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const i=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/i,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/i]}static getAxialAlignedBoundingBox(e,t){const i=this.applyTransform(e,t),n=this.applyTransform(e.slice(2,4),t),s=this.applyTransform([e[0],e[3]],t),a=this.applyTransform([e[2],e[1]],t);return[Math.min(i[0],n[0],s[0],a[0]),Math.min(i[1],n[1],s[1],a[1]),Math.max(i[0],n[0],s[0],a[0]),Math.max(i[1],n[1],s[1],a[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],i=e[0]*t[0]+e[1]*t[2],n=e[0]*t[1]+e[1]*t[3],s=e[2]*t[0]+e[3]*t[2],a=e[2]*t[1]+e[3]*t[3],r=(i+a)/2,o=Math.sqrt((i+a)**2-4*(i*a-s*n))/2,l=r+o||1,d=r-o||1;return[Math.sqrt(l),Math.sqrt(d)]}static normalizeRect(e){const t=e.slice(0);if(e[0]>e[2]){t[0]=e[2];t[2]=e[0]}if(e[1]>e[3]){t[1]=e[3];t[3]=e[1]}return t}static intersect(e,t){const i=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),n=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(i>n)return null;const s=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),a=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>a?null:[i,s,n,a]}static bezierBoundingBox(e,t,i,n,s,a,r,o){const l=[],d=[[],[]];let h,c,u,p,g,f,m,b;for(let d=0;d<2;++d){if(0===d){c=6*e-12*i+6*s;h=-3*e+9*i-9*s+3*r;u=3*i-3*e}else{c=6*t-12*n+6*a;h=-3*t+9*n-9*a+3*o;u=3*n-3*t}if(Math.abs(h)<1e-12){if(Math.abs(c)<1e-12)continue;p=-u/c;0<p&&p<1&&l.push(p)}else{m=c*c-4*u*h;b=Math.sqrt(m);if(!(m<0)){g=(-c+b)/(2*h);0<g&&g<1&&l.push(g);f=(-c-b)/(2*h);0<f&&f<1&&l.push(f)}}}let v,_=l.length;const w=_;for(;_--;){p=l[_];v=1-p;d[0][_]=v*v*v*e+3*v*v*p*i+3*v*p*p*s+p*p*p*r;d[1][_]=v*v*v*t+3*v*v*p*n+3*v*p*p*a+p*p*p*o}d[0][w]=e;d[1][w]=t;d[0][w+1]=r;d[1][w+1]=o;d[0].length=d[1].length=w+2;return[Math.min(...d[0]),Math.min(...d[1]),Math.max(...d[0]),Math.max(...d[1])]}};const o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,728,711,710,729,733,731,730,732,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8226,8224,8225,8230,8212,8211,402,8260,8249,8250,8722,8240,8222,8220,8221,8216,8217,8218,8482,64257,64258,321,338,352,376,381,305,322,339,353,382,0,8364];function stringToUTF8String(e){return decodeURIComponent(escape(e))}t.PromiseCapability=class PromiseCapability{#e=!1;constructor(){this.promise=new Promise(((e,t)=>{this.resolve=t=>{this.#e=!0;e(t)};this.reject=e=>{this.#e=!0;t(e)}}))}get settled(){return this.#e}};let l=null,d=null;t.AnnotationPrefix="pdfjs_internal_id_"},(__unused_webpack_module,exports,__w_pdfjs_require__)=>{Object.defineProperty(exports,"__esModule",{value:!0});exports.RenderTask=exports.PDFWorkerUtil=exports.PDFWorker=exports.PDFPageProxy=exports.PDFDocumentProxy=exports.PDFDocumentLoadingTask=exports.PDFDataRangeTransport=exports.LoopbackPort=exports.DefaultStandardFontDataFactory=exports.DefaultFilterFactory=exports.DefaultCanvasFactory=exports.DefaultCMapReaderFactory=void 0;Object.defineProperty(exports,"SVGGraphics",{enumerable:!0,get:function(){return _displaySvg.SVGGraphics}});exports.build=void 0;exports.getDocument=getDocument;exports.version=void 0;var _util=__w_pdfjs_require__(1),_annotation_storage=__w_pdfjs_require__(3),_display_utils=__w_pdfjs_require__(6),_font_loader=__w_pdfjs_require__(9),_displayNode_utils=__w_pdfjs_require__(10),_canvas=__w_pdfjs_require__(11),_worker_options=__w_pdfjs_require__(14),_message_handler=__w_pdfjs_require__(15),_metadata=__w_pdfjs_require__(16),_optional_content_config=__w_pdfjs_require__(17),_transport_stream=__w_pdfjs_require__(18),_displayFetch_stream=__w_pdfjs_require__(19),_displayNetwork=__w_pdfjs_require__(22),_displayNode_stream=__w_pdfjs_require__(23),_displaySvg=__w_pdfjs_require__(24),_xfa_text=__w_pdfjs_require__(25);const DEFAULT_RANGE_CHUNK_SIZE=65536,RENDERING_CANCELLED_TIMEOUT=100,DELAYED_CLEANUP_TIMEOUT=5e3,DefaultCanvasFactory=_util.isNodeJS?_displayNode_utils.NodeCanvasFactory:_display_utils.DOMCanvasFactory;exports.DefaultCanvasFactory=DefaultCanvasFactory;const DefaultCMapReaderFactory=_util.isNodeJS?_displayNode_utils.NodeCMapReaderFactory:_display_utils.DOMCMapReaderFactory;exports.DefaultCMapReaderFactory=DefaultCMapReaderFactory;const DefaultFilterFactory=_util.isNodeJS?_displayNode_utils.NodeFilterFactory:_display_utils.DOMFilterFactory;exports.DefaultFilterFactory=DefaultFilterFactory;const DefaultStandardFontDataFactory=_util.isNodeJS?_displayNode_utils.NodeStandardFontDataFactory:_display_utils.DOMStandardFontDataFactory;exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;function getDocument(e){"string"==typeof e||e instanceof URL?e={url:e}:(0,_util.isArrayBuffer)(e)&&(e={data:e});if("object"!=typeof e)throw new Error("Invalid parameter in getDocument, need parameter object.");if(!e.url&&!e.data&&!e.range)throw new Error("Invalid parameter object: need either .data, .range or .url");const t=new PDFDocumentLoadingTask,{docId:i}=t,n=e.url?getUrlProp(e.url):null,s=e.data?getDataProp(e.data):null,a=e.httpHeaders||null,r=!0===e.withCredentials,o=e.password??null,l=e.range instanceof PDFDataRangeTransport?e.range:null,d=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let h=e.worker instanceof PDFWorker?e.worker:null;const c=e.verbosity,u="string"!=typeof e.docBaseUrl||(0,_display_utils.isDataScheme)(e.docBaseUrl)?null:e.docBaseUrl,p="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,f=e.CMapReaderFactory||DefaultCMapReaderFactory,m="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,b=e.StandardFontDataFactory||DefaultStandardFontDataFactory,v=!0!==e.stopAtErrors,_=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,w=!1!==e.isEvalSupported,y="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_util.isNodeJS,S=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,A="boolean"==typeof e.disableFontFace?e.disableFontFace:_util.isNodeJS,E=!0===e.fontExtraProperties,P=!0===e.enableXfa,C=e.ownerDocument||globalThis.document,x=!0===e.disableRange,T=!0===e.disableStream,M=!0===e.disableAutoFetch,I=!0===e.pdfBug,k=l?l.length:e.length??NaN,D="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_util.isNodeJS&&!A,L="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:f===_display_utils.DOMCMapReaderFactory&&b===_display_utils.DOMStandardFontDataFactory&&p&&m&&(0,_display_utils.isValidFetchUrl)(p,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(m,document.baseURI),F=e.canvasFactory||new DefaultCanvasFactory({ownerDocument:C}),R=e.filterFactory||new DefaultFilterFactory({docId:i,ownerDocument:C});(0,_util.setVerbosityLevel)(c);const O={canvasFactory:F,filterFactory:R};if(!L){O.cMapReaderFactory=new f({baseUrl:p,isCompressed:g});O.standardFontDataFactory=new b({baseUrl:m})}if(!h){const e={verbosity:c,port:_worker_options.GlobalWorkerOptions.workerPort};h=e.port?PDFWorker.fromPort(e):new PDFWorker(e);t._worker=h}const N={docId:i,apiVersion:"3.11.174",data:s,password:o,disableAutoFetch:M,rangeChunkSize:d,length:k,docBaseUrl:u,enableXfa:P,evaluatorOptions:{maxImageSize:_,disableFontFace:A,ignoreErrors:v,isEvalSupported:w,isOffscreenCanvasSupported:y,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:D,cMapUrl:L?p:null,standardFontDataUrl:L?m:null}},B={ignoreErrors:v,isEvalSupported:w,disableFontFace:A,fontExtraProperties:E,enableXfa:P,ownerDocument:C,disableAutoFetch:M,pdfBug:I,styleElement:null};h.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");const e=_fetchDocument(h,N),o=new Promise((function(e){let t;if(l)t=new _transport_stream.PDFDataTransportStream({length:k,initialData:l.initialData,progressiveDone:l.progressiveDone,contentDispositionFilename:l.contentDispositionFilename,disableRange:x,disableStream:T},l);else if(!s){t=(e=>_util.isNodeJS?new _displayNode_stream.PDFNodeStream(e):(0,_display_utils.isValidFetchUrl)(e.url)?new _displayFetch_stream.PDFFetchStream(e):new _displayNetwork.PDFNetworkStream(e))({url:n,length:k,httpHeaders:a,withCredentials:r,rangeChunkSize:d,disableRange:x,disableStream:T})}e(t)}));return Promise.all([e,o]).then((function([e,n]){if(t.destroyed)throw new Error("Loading aborted");const s=new _message_handler.MessageHandler(i,e,h.port),a=new WorkerTransport(s,t,n,B,O);t._transport=a;s.send("Ready",null)}))})).catch(t._capability.reject);return t}async function _fetchDocument(e,t){if(e.destroyed)throw new Error("Worker was destroyed");const i=await e.messageHandler.sendWithPromise("GetDocRequest",t,t.data?[t.data.buffer]:null);if(e.destroyed)throw new Error("Worker was destroyed");return i}function getUrlProp(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(_util.isNodeJS&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function getDataProp(e){if(_util.isNodeJS&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return(0,_util.stringToBytes)(e);if("object"==typeof e&&!isNaN(e?.length)||(0,_util.isArrayBuffer)(e))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}class PDFDocumentLoadingTask{static#t=0;constructor(){this._capability=new _util.PromiseCapability;this._transport=null;this._worker=null;this.docId="d"+PDFDocumentLoadingTask.#t++;this.destroyed=!1;this.onPassword=null;this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0);await(this._transport?.destroy())}catch(e){this._worker?.port&&delete this._worker._pendingDestroy;throw e}this._transport=null;if(this._worker){this._worker.destroy();this._worker=null}}}exports.PDFDocumentLoadingTask=PDFDocumentLoadingTask;class PDFDataRangeTransport{constructor(e,t,i=!1,n=null){this.length=e;this.initialData=t;this.progressiveDone=i;this.contentDispositionFilename=n;this._rangeListeners=[];this._progressListeners=[];this._progressiveReadListeners=[];this._progressiveDoneListeners=[];this._readyCapability=new _util.PromiseCapability}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const i of this._rangeListeners)i(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const i of this._progressListeners)i(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){(0,_util.unreachable)("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}exports.PDFDataRangeTransport=PDFDataRangeTransport;class PDFDocumentProxy{constructor(e,t){this._pdfInfo=e;this._transport=t;Object.defineProperty(this,"getJavaScript",{value:()=>{(0,_display_utils.deprecated)("`PDFDocumentProxy.getJavaScript`, please use `PDFDocumentProxy.getJSActions` instead.");return this.getJSActions().then((e=>{if(!e)return e;const t=[];for(const i in e)t.push(...e[i]);return t}))}})}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}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()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}exports.PDFDocumentProxy=PDFDocumentProxy;class PDFPageProxy{#i=null;#n=!1;constructor(e,t,i,n=!1){this._pageIndex=e;this._pageInfo=t;this._transport=i;this._stats=n?new _display_utils.StatTimer:null;this._pdfBug=n;this.commonObjs=i.commonObjs;this.objs=new PDFObjects;this._maybeCleanupAfterRender=!1;this._intentStates=new Map;this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:i=0,offsetY:n=0,dontFlip:s=!1}={}){return new _display_utils.PageViewport({viewBox:this.view,scale:e,rotation:t,offsetX:i,offsetY:n,dontFlip:s})}getAnnotations({intent:e="display"}={}){const t=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t.renderingIntent)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return(0,_util.shadow)(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:i="display",annotationMode:n=_util.AnnotationMode.ENABLE,transform:s=null,background:a=null,optionalContentConfigPromise:r=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:d=null}){this._stats?.time("Overall");const h=this._transport.getRenderingIntent(i,n,d);this.#n=!1;this.#s();r||(r=this._transport.getOptionalContentConfig());let c=this._intentStates.get(h.cacheKey);if(!c){c=Object.create(null);this._intentStates.set(h.cacheKey,c)}if(c.streamReaderCancelTimeout){clearTimeout(c.streamReaderCancelTimeout);c.streamReaderCancelTimeout=null}const u=!!(h.renderingIntent&_util.RenderingIntentFlag.PRINT);if(!c.displayReadyCapability){c.displayReadyCapability=new _util.PromiseCapability;c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(h)}const complete=e=>{c.renderTasks.delete(p);(this._maybeCleanupAfterRender||u)&&(this.#n=!0);this.#a(!u);if(e){p.capability.reject(e);this._abortOperatorList({intentState:c,reason:e instanceof Error?e:new Error(e)})}else p.capability.resolve();this._stats?.timeEnd("Rendering");this._stats?.timeEnd("Overall")},p=new InternalRenderTask({callback:complete,params:{canvasContext:e,viewport:t,transform:s,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:c.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!u,pdfBug:this._pdfBug,pageColors:l});(c.renderTasks||=new Set).add(p);const g=p.task;Promise.all([c.displayReadyCapability.promise,r]).then((([e,t])=>{if(this.destroyed)complete();else{this._stats?.time("Rendering");p.initializeGraphics({transparency:e,optionalContentConfig:t});p.operatorListChanged()}})).catch(complete);return g}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:i=null}={}){const n=this._transport.getRenderingIntent(e,t,i,!0);let s,a=this._intentStates.get(n.cacheKey);if(!a){a=Object.create(null);this._intentStates.set(n.cacheKey,a)}if(!a.opListReadCapability){s=Object.create(null);s.operatorListChanged=function operatorListChanged(){if(a.operatorList.lastChunk){a.opListReadCapability.resolve(a.operatorList);a.renderTasks.delete(s)}};a.opListReadCapability=new _util.PromiseCapability;(a.renderTasks||=new Set).add(s);a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null};this._stats?.time("Page Request");this._pumpOperatorList(n)}return a.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>_xfa_text.XfaText.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,i){const n=t.getReader(),s={items:[],styles:Object.create(null)};!function pump(){n.read().then((function({value:t,done:i}){if(i)e(s);else{Object.assign(s.styles,t.styles);s.items.push(...t.items);pump()}}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values()){this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0});if(!t.opListReadCapability)for(const i of t.renderTasks){e.push(i.completed);i.cancel()}}this.objs.clear();this.#n=!1;this.#s();return Promise.all(e)}cleanup(e=!1){this.#n=!0;const t=this.#a(!1);e&&t&&(this._stats&&=new _display_utils.StatTimer);return t}#a(e=!1){this.#s();if(!this.#n||this.destroyed)return!1;if(e){this.#i=setTimeout((()=>{this.#i=null;this.#a(!1)}),DELAYED_CLEANUP_TIMEOUT);return!1}for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;this._intentStates.clear();this.objs.clear();this.#n=!1;return!0}#s(){if(this.#i){clearTimeout(this.#i);this.#i=null}}_startRenderPage(e,t){const i=this._intentStates.get(t);if(i){this._stats?.timeEnd("Page Request");i.displayReadyCapability?.resolve(e)}}_renderPageChunk(e,t){for(let i=0,n=e.length;i<n;i++){t.operatorList.fnArray.push(e.fnArray[i]);t.operatorList.argsArray.push(e.argsArray[i])}t.operatorList.lastChunk=e.lastChunk;t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#a(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i}){const{map:n,transfers:s}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:n},s).getReader(),r=this._intentStates.get(t);r.streamReader=a;const pump=()=>{a.read().then((({value:e,done:t})=>{if(t)r.streamReader=null;else if(!this._transport.destroyed){this._renderPageChunk(e,r);pump()}}),(e=>{r.streamReader=null;if(!this._transport.destroyed){if(r.operatorList){r.operatorList.lastChunk=!0;for(const e of r.renderTasks)e.operatorListChanged();this.#a(!0)}if(r.displayReadyCapability)r.displayReadyCapability.reject(e);else{if(!r.opListReadCapability)throw e;r.opListReadCapability.reject(e)}}}))};pump()}_abortOperatorList({intentState:e,reason:t,force:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout){clearTimeout(e.streamReaderCancelTimeout);e.streamReaderCancelTimeout=null}if(!i){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let i=RENDERING_CANCELLED_TIMEOUT;t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay);e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null;this._abortOperatorList({intentState:e,reason:t,force:!0})}),i);return}}e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{}));e.streamReader=null;if(!this._transport.destroyed){for(const[t,i]of this._intentStates)if(i===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}exports.PDFPageProxy=PDFPageProxy;class LoopbackPort{#r=new Set;#o=Promise.resolve();postMessage(e,t){const i={data:structuredClone(e,t?{transfer:t}:null)};this.#o.then((()=>{for(const e of this.#r)e.call(this,i)}))}addEventListener(e,t){this.#r.add(t)}removeEventListener(e,t){this.#r.delete(t)}terminate(){this.#r.clear()}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};exports.PDFWorkerUtil=PDFWorkerUtil;if(_util.isNodeJS&&"function"==typeof require){PDFWorkerUtil.isWorkerDisabled=!0;PDFWorkerUtil.fallbackWorkerSrc="./pdf.worker.js"}else if("object"==typeof document){const e=document?.currentScript?.src;e&&(PDFWorkerUtil.fallbackWorkerSrc=e.replace(/(\.(?:min\.)?js)(\?.*)?$/i,".worker$1$2"))}PDFWorkerUtil.isSameOrigin=function(e,t){let i;try{i=new URL(e);if(!i.origin||"null"===i.origin)return!1}catch{return!1}const n=new URL(t,i);return i.origin===n.origin};PDFWorkerUtil.createCDNWrapper=function(e){const t=`importScripts("${e}");`;return URL.createObjectURL(new Blob([t]))};class PDFWorker{static#l;constructor({name:e=null,port:t=null,verbosity:i=(0,_util.getVerbosityLevel)()}={}){this.name=e;this.destroyed=!1;this.verbosity=i;this._readyCapability=new _util.PromiseCapability;this._port=null;this._webWorker=null;this._messageHandler=null;if(t){if(PDFWorker.#l?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");(PDFWorker.#l||=new WeakMap).set(t,this);this._initializeFromPort(t)}else this._initialize()}get promise(){return this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e;this._messageHandler=new _message_handler.MessageHandler("main","worker",e);this._messageHandler.on("ready",(function(){}));this._readyCapability.resolve();this._messageHandler.send("configure",{verbosity:this.verbosity})}_initialize(){if(!PDFWorkerUtil.isWorkerDisabled&&!PDFWorker._mainThreadWorkerMessageHandler){let{workerSrc:e}=PDFWorker;try{PDFWorkerUtil.isSameOrigin(window.location.href,e)||(e=PDFWorkerUtil.createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e),i=new _message_handler.MessageHandler("main","worker",t),terminateEarly=()=>{t.removeEventListener("error",onWorkerError);i.destroy();t.terminate();this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},onWorkerError=()=>{this._webWorker||terminateEarly()};t.addEventListener("error",onWorkerError);i.on("test",(e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else if(e){this._messageHandler=i;this._port=t;this._webWorker=t;this._readyCapability.resolve();i.send("configure",{verbosity:this.verbosity})}else{this._setupFakeWorker();i.destroy();t.terminate()}}));i.on("ready",(e=>{t.removeEventListener("error",onWorkerError);if(this.destroyed)terminateEarly();else try{sendTest()}catch{this._setupFakeWorker()}}));const sendTest=()=>{const e=new Uint8Array;i.send("test",e,[e.buffer])};sendTest();return}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){if(!PDFWorkerUtil.isWorkerDisabled){(0,_util.warn)("Setting up fake worker.");PDFWorkerUtil.isWorkerDisabled=!0}PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const t=new LoopbackPort;this._port=t;const i="fake"+PDFWorkerUtil.fakeWorkerId++,n=new _message_handler.MessageHandler(i+"_worker",i,t);e.setup(n,t);const s=new _message_handler.MessageHandler(i,i+"_worker",t);this._messageHandler=s;this._readyCapability.resolve();s.send("configure",{verbosity:this.verbosity})})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0;if(this._webWorker){this._webWorker.terminate();this._webWorker=null}PDFWorker.#l?.delete(this._port);this._port=null;if(this._messageHandler){this._messageHandler.destroy();this._messageHandler=null}}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const t=this.#l?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new PDFWorker(e)}static get workerSrc(){if(_worker_options.GlobalWorkerOptions.workerSrc)return _worker_options.GlobalWorkerOptions.workerSrc;if(null!==PDFWorkerUtil.fallbackWorkerSrc){_util.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{return null}}static get _setupFakeWorkerGlobal(){const loader=async()=>{const mainWorkerMessageHandler=this._mainThreadWorkerMessageHandler;if(mainWorkerMessageHandler)return mainWorkerMessageHandler;if(_util.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;class WorkerTransport{#d=new Map;#h=new Map;#c=new Map;#u=null;constructor(e,t,i,n,s){this.messageHandler=e;this.loadingTask=t;this.commonObjs=new PDFObjects;this.fontLoader=new _font_loader.FontLoader({ownerDocument:n.ownerDocument,styleElement:n.styleElement});this._params=n;this.canvasFactory=s.canvasFactory;this.filterFactory=s.filterFactory;this.cMapReaderFactory=s.cMapReaderFactory;this.standardFontDataFactory=s.standardFontDataFactory;this.destroyed=!1;this.destroyCapability=null;this._networkStream=i;this._fullReader=null;this._lastProgress=null;this.downloadInfoCapability=new _util.PromiseCapability;this.setupMessageHandler()}#p(e,t=null){const i=this.#d.get(e);if(i)return i;const n=this.messageHandler.sendWithPromise(e,t);this.#d.set(e,n);return n}get annotationStorage(){return(0,_util.shadow)(this,"annotationStorage",new _annotation_storage.AnnotationStorage)}getRenderingIntent(e,t=_util.AnnotationMode.ENABLE,i=null,n=!1){let s=_util.RenderingIntentFlag.DISPLAY,a=_annotation_storage.SerializableEmpty;switch(e){case"any":s=_util.RenderingIntentFlag.ANY;break;case"display":break;case"print":s=_util.RenderingIntentFlag.PRINT;break;default:(0,_util.warn)(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case _util.AnnotationMode.DISABLE:s+=_util.RenderingIntentFlag.ANNOTATIONS_DISABLE;break;case _util.AnnotationMode.ENABLE:break;case _util.AnnotationMode.ENABLE_FORMS:s+=_util.RenderingIntentFlag.ANNOTATIONS_FORMS;break;case _util.AnnotationMode.ENABLE_STORAGE:s+=_util.RenderingIntentFlag.ANNOTATIONS_STORAGE;a=(s&_util.RenderingIntentFlag.PRINT&&i instanceof _annotation_storage.PrintAnnotationStorage?i:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}n&&(s+=_util.RenderingIntentFlag.OPLIST);return{renderingIntent:s,cacheKey:`${s}_${a.hash}`,annotationStorageSerializable:a}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0;this.destroyCapability=new _util.PromiseCapability;this.#u?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#h.values())e.push(t._destroy());this.#h.clear();this.#c.clear();this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);e.push(t);Promise.all(e).then((()=>{this.commonObjs.clear();this.fontLoader.clear();this.#d.clear();this.filterFactory.destroy();this._networkStream?.cancelAllRequests(new _util.AbortException("Worker was terminated."));if(this.messageHandler){this.messageHandler.destroy();this.messageHandler=null}this.destroyCapability.resolve()}),this.destroyCapability.reject);return this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetReader - no `IPDFStream` instance available.");this._fullReader=this._networkStream.getFullReader();this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}};t.onPull=()=>{this._fullReader.read().then((function({value:e,done:i}){if(i)t.close();else{(0,_util.assert)(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch((e=>{t.error(e)}))};t.onCancel=e=>{this._fullReader.cancel(e);t.ready.catch((e=>{if(!this.destroyed)throw e}))}}));e.on("ReaderHeadersReady",(e=>{const i=new _util.PromiseCapability,n=this._fullReader;n.headersReady.then((()=>{if(!n.isStreamingSupported||!n.isRangeSupported){this._lastProgress&&t.onProgress?.(this._lastProgress);n.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}}i.resolve({isStreamingSupported:n.isStreamingSupported,isRangeSupported:n.isRangeSupported,contentLength:n.contentLength})}),i.reject);return i.promise}));e.on("GetRangeReader",((e,t)=>{(0,_util.assert)(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(e.begin,e.end);if(i){t.onPull=()=>{i.read().then((function({value:e,done:i}){if(i)t.close();else{(0,_util.assert)(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer.");t.enqueue(new Uint8Array(e),1,[e])}})).catch((e=>{t.error(e)}))};t.onCancel=e=>{i.cancel(e);t.ready.catch((e=>{if(!this.destroyed)throw e}))}}else t.close()}));e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages;this._htmlForXfa=e.htmlForXfa;delete e.htmlForXfa;t._capability.resolve(new PDFDocumentProxy(e,this))}));e.on("DocException",(function(e){let i;switch(e.name){case"PasswordException":i=new _util.PasswordException(e.message,e.code);break;case"InvalidPDFException":i=new _util.InvalidPDFException(e.message);break;case"MissingPDFException":i=new _util.MissingPDFException(e.message);break;case"UnexpectedResponseException":i=new _util.UnexpectedResponseException(e.message,e.status);break;case"UnknownErrorException":i=new _util.UnknownErrorException(e.message,e.details);break;default:(0,_util.unreachable)("DocException - expected a valid Error.")}t._capability.reject(i)}));e.on("PasswordRequest",(e=>{this.#u=new _util.PromiseCapability;if(t.onPassword){const updatePassword=e=>{e instanceof Error?this.#u.reject(e):this.#u.resolve({password:e})};try{t.onPassword(updatePassword,e.code)}catch(e){this.#u.reject(e)}}else this.#u.reject(new _util.PasswordException(e.message,e.code));return this.#u.promise}));e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length});this.downloadInfoCapability.resolve(e)}));e.on("StartRenderPage",(e=>{if(this.destroyed)return;this.#h.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}));e.on("commonobj",(([t,i,n])=>{if(!this.destroyed&&!this.commonObjs.has(t))switch(i){case"Font":const s=this._params;if("error"in n){const e=n.error;(0,_util.warn)(`Error during font loading: ${e}`);this.commonObjs.resolve(t,e);break}const a=s.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,r=new _font_loader.FontFaceObject(n,{isEvalSupported:s.isEvalSupported,disableFontFace:s.disableFontFace,ignoreErrors:s.ignoreErrors,inspectFont:a});this.fontLoader.bind(r).catch((i=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!s.fontExtraProperties&&r.data&&(r.data=null);this.commonObjs.resolve(t,r)}));break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,n);break;default:throw new Error(`Got unknown common object type ${i}`)}}));e.on("obj",(([e,t,i,n])=>{if(this.destroyed)return;const s=this.#h.get(t);if(!s.objs.has(e))switch(i){case"Image":s.objs.resolve(e,n);if(n){let e;if(n.bitmap){const{width:t,height:i}=n;e=t*i*4}else e=n.data?.length||0;e>_util.MAX_IMAGE_SIZE_TO_CACHE&&(s._maybeCleanupAfterRender=!0)}break;case"Pattern":s.objs.resolve(e,n);break;default:throw new Error(`Got unknown object type ${i}`)}}));e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})}));e.on("FetchBuiltInCMap",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))));e.on("FetchStandardFontData",(e=>this.destroyed?Promise.reject(new Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter."))))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&(0,_util.warn)("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfers:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,i=this.#c.get(t);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((e=>{if(this.destroyed)throw new Error("Transport destroyed");const i=new PDFPageProxy(t,e,this,this._params.pdfBug);this.#h.set(t,i);return i}));this.#c.set(t,n);return n}getPageIndex(e){return"object"!=typeof e||null===e||!Number.isInteger(e.num)||e.num<0||!Number.isInteger(e.gen)||e.gen<0?Promise.reject(new Error("Invalid pageIndex request.")):this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen})}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#p("GetFieldObjects")}hasJSActions(){return this.#p("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#p("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(){return this.messageHandler.sendWithPromise("GetOptionalContentConfig",null).then((e=>new _optional_content_config.OptionalContentConfig(e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=this.#d.get(e);if(t)return t;const i=this.messageHandler.sendWithPromise(e,null).then((e=>({info:e[0],metadata:e[1]?new _metadata.Metadata(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));this.#d.set(e,i);return i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#h.values()){if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`)}this.commonObjs.clear();e||this.fontLoader.clear();this.#d.clear();this.filterFactory.destroy(!0)}}get loadingParams(){const{disableAutoFetch:e,enableXfa:t}=this._params;return(0,_util.shadow)(this,"loadingParams",{disableAutoFetch:e,enableXfa:t})}}class PDFObjects{#g=Object.create(null);#f(e){return this.#g[e]||={capability:new _util.PromiseCapability,data:null}}get(e,t=null){if(t){const i=this.#f(e);i.capability.promise.then((()=>t(i.data)));return null}const i=this.#g[e];if(!i?.capability.settled)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return i.data}has(e){const t=this.#g[e];return t?.capability.settled||!1}resolve(e,t=null){const i=this.#f(e);i.data=t;i.capability.resolve()}clear(){for(const e in this.#g){const{data:t}=this.#g[e];t?.bitmap?.close()}this.#g=Object.create(null)}}class RenderTask{#m=null;constructor(e){this.#m=e;this.onContinue=null}get promise(){return this.#m.capability.promise}cancel(e=0){this.#m.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this.#m.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this.#m;return e.form||e.canvas&&t?.size>0}}exports.RenderTask=RenderTask;class InternalRenderTask{static#b=new WeakSet;constructor({callback:e,params:t,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:d=!1,pdfBug:h=!1,pageColors:c=null}){this.callback=e;this.params=t;this.objs=i;this.commonObjs=n;this.annotationCanvasMap=s;this.operatorListIdx=null;this.operatorList=a;this._pageIndex=r;this.canvasFactory=o;this.filterFactory=l;this._pdfBug=h;this.pageColors=c;this.running=!1;this.graphicsReadyCallback=null;this.graphicsReady=!1;this._useRequestAnimationFrame=!0===d&&"undefined"!=typeof window;this.cancelled=!1;this.capability=new _util.PromiseCapability;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=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(InternalRenderTask.#b.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.#b.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:i,viewport:n,transform:s,background:a}=this.params;this.gfx=new _canvas.CanvasGraphics(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors);this.gfx.beginDrawing({transform:s,viewport:n,transparency:e,background:a});this.operatorListIdx=0;this.graphicsReady=!0;this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1;this.cancelled=!0;this.gfx?.endDrawing();InternalRenderTask.#b.delete(this._canvas);this.callback(e||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){if(this.graphicsReady){this.stepper?.updateOperatorList(this.operatorList);this.running||this._continue()}else 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();InternalRenderTask.#b.delete(this._canvas);this.callback()}}}}}const version="3.11.174";exports.version=version;const build="ce8716743";exports.build=build},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.SerializableEmpty=t.PrintAnnotationStorage=t.AnnotationStorage=void 0;var n=i(1),s=i(4),a=i(8);const r=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=r;class AnnotationStorage{#v=!1;#_=new Map;constructor(){this.onSetModified=null;this.onResetModified=null;this.onAnnotationEditor=null}getValue(e,t){const i=this.#_.get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return this.#_.get(e)}remove(e){this.#_.delete(e);0===this.#_.size&&this.resetModified();if("function"==typeof this.onAnnotationEditor){for(const e of this.#_.values())if(e instanceof s.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){const i=this.#_.get(e);let n=!1;if(void 0!==i){for(const[e,s]of Object.entries(t))if(i[e]!==s){n=!0;i[e]=s}}else{n=!0;this.#_.set(e,t)}n&&this.#w();t instanceof s.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#_.has(e)}getAll(){return this.#_.size>0?(0,n.objectFromMap)(this.#_):null}setAll(e){for(const[t,i]of Object.entries(e))this.setValue(t,i)}get size(){return this.#_.size}#w(){if(!this.#v){this.#v=!0;"function"==typeof this.onSetModified&&this.onSetModified()}}resetModified(){if(this.#v){this.#v=!1;"function"==typeof this.onResetModified&&this.onResetModified()}}get print(){return new PrintAnnotationStorage(this)}get serializable(){if(0===this.#_.size)return r;const e=new Map,t=new a.MurmurHash3_64,i=[],n=Object.create(null);let o=!1;for(const[i,a]of this.#_){const r=a instanceof s.AnnotationEditor?a.serialize(!1,n):a;if(r){e.set(i,r);t.update(`${i}:${JSON.stringify(r)}`);o||=!!r.bitmap}}if(o)for(const t of e.values())t.bitmap&&i.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfers:i}:r}}t.AnnotationStorage=AnnotationStorage;class PrintAnnotationStorage extends AnnotationStorage{#y;constructor(e){super();const{map:t,hash:i,transfers:n}=e.serializable,s=structuredClone(t,n?{transfer:n}:null);this.#y={map:s,hash:i,transfers:n}}get print(){(0,n.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#y}}t.PrintAnnotationStorage=PrintAnnotationStorage},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationEditor=void 0;var n=i(5),s=i(1),a=i(6);class AnnotationEditor{#S="";#A=!1;#E=null;#P=null;#C=null;#x=!1;#T=null;#M=this.focusin.bind(this);#I=this.focusout.bind(this);#k=!1;#D=!1;#L=!1;_initialOptions=Object.create(null);_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#F=!1;#R=AnnotationEditor._zIndex++;static _borderLineWidth=-1;static _colorManager=new n.ColorManager;static _zIndex=1;static SMALL_EDITOR_SIZE=0;constructor(e){this.constructor===AnnotationEditor&&(0,s.unreachable)("Cannot initialize AnnotationEditor.");this.parent=e.parent;this.id=e.id;this.width=this.height=null;this.pageIndex=e.parent.pageIndex;this.name=e.name;this.div=null;this._uiManager=e.uiManager;this.annotationElementId=null;this._willKeepAspectRatio=!1;this._initialOptions.isCentered=e.isCentered;this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:i,pageHeight:n,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=t;this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360;this.pageDimensions=[i,n];this.pageTranslation=[a,r];const[o,l]=this.parentDimensions;this.x=e.x/o;this.y=e.y/l;this.isAttachedToDOM=!1;this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return(0,s.shadow)(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new FakeEditor({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId;t.deleted=!0;t._uiManager.addToAnnotationStorage(t)}static initialize(e,t=null){AnnotationEditor._l10nPromise||=new Map(["editor_alt_text_button_label","editor_alt_text_edit_button_label","editor_alt_text_decorative_tooltip"].map((t=>[t,e.get(t)])));if(t?.strings)for(const i of t.strings)AnnotationEditor._l10nPromise.set(i,e.get(i));if(-1!==AnnotationEditor._borderLineWidth)return;const i=getComputedStyle(document.documentElement);AnnotationEditor._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){(0,s.unreachable)("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#F}set _isDraggable(e){this.#F=e;this.div?.classList.toggle("draggable",e)}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e);this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2;this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e);this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2;this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#R}setParent(e){if(null!==e){this.pageIndex=e.pageIndex;this.pageDimensions=e.pageDimensions}this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#k?this.#k=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;if(!t?.closest(`#${this.id}`)){e.preventDefault();this.parent?.isMultipleSelection||this.commitOrRemove()}}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,i,n){const[s,a]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n);this.x=(e+i)/s;this.y=(t+n)/a;this.fixAndSetPosition()}#O([e,t],i,n){[i,n]=this.screenToPageTranslation(i,n);this.x+=i/e;this.y+=n/t;this.fixAndSetPosition()}translate(e,t){this.#O(this.parentDimensions,e,t)}translateInPage(e,t){this.#O(this.pageDimensions,e,t);this.div.scrollIntoView({block:"nearest"})}drag(e,t){const[i,n]=this.parentDimensions;this.x+=e/i;this.y+=t/n;if(this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();if(this.parent.findNewParent(this,e,t)){this.x-=Math.floor(this.x);this.y-=Math.floor(this.y)}}let{x:s,y:a}=this;const[r,o]=this.#N();s+=r;a+=o;this.div.style.left=`${(100*s).toFixed(2)}%`;this.div.style.top=`${(100*a).toFixed(2)}%`;this.div.scrollIntoView({block:"nearest"})}#N(){const[e,t]=this.parentDimensions,{_borderLineWidth:i}=AnnotationEditor,n=i/e,s=i/t;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}fixAndSetPosition(){const[e,t]=this.pageDimensions;let{x:i,y:n,width:s,height:a}=this;s*=e;a*=t;i*=e;n*=t;switch(this.rotation){case 0:i=Math.max(0,Math.min(e-s,i));n=Math.max(0,Math.min(t-a,n));break;case 90:i=Math.max(0,Math.min(e-a,i));n=Math.min(t,Math.max(s,n));break;case 180:i=Math.min(e,Math.max(s,i));n=Math.min(t,Math.max(a,n));break;case 270:i=Math.min(e,Math.max(a,i));n=Math.max(0,Math.min(t-s,n))}this.x=i/=e;this.y=n/=t;const[r,o]=this.#N();i+=r;n+=o;const{style:l}=this.div;l.left=`${(100*i).toFixed(2)}%`;l.top=`${(100*n).toFixed(2)}%`;this.moveInDOM()}static#B(e,t,i){switch(i){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return AnnotationEditor.#B(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return AnnotationEditor.#B(e,t,360-this.parentRotation)}#V(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,i]}=this,n=t*e,a=i*e;return s.FeatureTest.isCSSRoundSupported?[Math.round(n),Math.round(a)]:[n,a]}setDims(e,t){const[i,n]=this.parentDimensions;this.div.style.width=`${(100*e/i).toFixed(2)}%`;this.#x||(this.div.style.height=`${(100*t/n).toFixed(2)}%`);this.#E?.classList.toggle("small",e<AnnotationEditor.SMALL_EDITOR_SIZE||t<AnnotationEditor.SMALL_EDITOR_SIZE)}fixDims(){const{style:e}=this.div,{height:t,width:i}=e,n=i.endsWith("%"),s=!this.#x&&t.endsWith("%");if(n&&s)return;const[a,r]=this.parentDimensions;n||(e.width=`${(100*parseFloat(i)/a).toFixed(2)}%`);this.#x||s||(e.height=`${(100*parseFloat(t)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#U(){if(this.#T)return;this.#T=document.createElement("div");this.#T.classList.add("resizers");const e=["topLeft","topRight","bottomRight","bottomLeft"];this._willKeepAspectRatio||e.push("topMiddle","middleRight","bottomMiddle","middleLeft");for(const t of e){const e=document.createElement("div");this.#T.append(e);e.classList.add("resizer",t);e.addEventListener("pointerdown",this.#z.bind(this,t));e.addEventListener("contextmenu",a.noContextMenu)}this.div.prepend(this.#T)}#z(e,t){t.preventDefault();const{isMac:i}=s.FeatureTest.platform;if(0!==t.button||t.ctrlKey&&i)return;const n=this.#H.bind(this,e),a=this._isDraggable;this._isDraggable=!1;const r={passive:!0,capture:!0};window.addEventListener("pointermove",n,r);const o=this.x,l=this.y,d=this.width,h=this.height,c=this.parent.div.style.cursor,u=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const pointerUpCallback=()=>{this._isDraggable=a;window.removeEventListener("pointerup",pointerUpCallback);window.removeEventListener("blur",pointerUpCallback);window.removeEventListener("pointermove",n,r);this.parent.div.style.cursor=c;this.div.style.cursor=u;const e=this.x,t=this.y,i=this.width,s=this.height;e===o&&t===l&&i===d&&s===h||this.addCommands({cmd:()=>{this.width=i;this.height=s;this.x=e;this.y=t;const[n,a]=this.parentDimensions;this.setDims(n*i,a*s);this.fixAndSetPosition()},undo:()=>{this.width=d;this.height=h;this.x=o;this.y=l;const[e,t]=this.parentDimensions;this.setDims(e*d,t*h);this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",pointerUpCallback);window.addEventListener("blur",pointerUpCallback)}#H(e,t){const[i,n]=this.parentDimensions,s=this.x,a=this.y,r=this.width,o=this.height,l=AnnotationEditor.MIN_SIZE/i,d=AnnotationEditor.MIN_SIZE/n,round=e=>Math.round(1e4*e)/1e4,h=this.#V(this.rotation),transf=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],c=this.#V(360-this.rotation);let u,p,g=!1,f=!1;switch(e){case"topLeft":g=!0;u=(e,t)=>[0,0];p=(e,t)=>[e,t];break;case"topMiddle":u=(e,t)=>[e/2,0];p=(e,t)=>[e/2,t];break;case"topRight":g=!0;u=(e,t)=>[e,0];p=(e,t)=>[0,t];break;case"middleRight":f=!0;u=(e,t)=>[e,t/2];p=(e,t)=>[0,t/2];break;case"bottomRight":g=!0;u=(e,t)=>[e,t];p=(e,t)=>[0,0];break;case"bottomMiddle":u=(e,t)=>[e/2,t];p=(e,t)=>[e/2,0];break;case"bottomLeft":g=!0;u=(e,t)=>[0,t];p=(e,t)=>[e,0];break;case"middleLeft":f=!0;u=(e,t)=>[0,t/2];p=(e,t)=>[e,t/2]}const m=u(r,o),b=p(r,o);let v=transf(...b);const _=round(s+v[0]),w=round(a+v[1]);let y=1,S=1,[A,E]=this.screenToPageTranslation(t.movementX,t.movementY);[A,E]=(P=A/i,C=E/n,[c[0]*P+c[2]*C,c[1]*P+c[3]*C]);var P,C;if(g){const e=Math.hypot(r,o);y=S=Math.max(Math.min(Math.hypot(b[0]-m[0]-A,b[1]-m[1]-E)/e,1/r,1/o),l/r,d/o)}else f?y=Math.max(l,Math.min(1,Math.abs(b[0]-m[0]-A)))/r:S=Math.max(d,Math.min(1,Math.abs(b[1]-m[1]-E)))/o;const x=round(r*y),T=round(o*S);v=transf(...p(x,T));const M=_-v[0],I=w-v[1];this.width=x;this.height=T;this.x=M;this.y=I;this.setDims(i*x,n*T);this.fixAndSetPosition()}async addAltTextButton(){if(this.#E)return;const e=this.#E=document.createElement("button");e.className="altText";const t=await AnnotationEditor._l10nPromise.get("editor_alt_text_button_label");e.textContent=t;e.setAttribute("aria-label",t);e.tabIndex="0";e.addEventListener("contextmenu",a.noContextMenu);e.addEventListener("pointerdown",(e=>e.stopPropagation()));e.addEventListener("click",(e=>{e.preventDefault();this._uiManager.editAltText(this)}),{capture:!0});e.addEventListener("keydown",(t=>{if(t.target===e&&"Enter"===t.key){t.preventDefault();this._uiManager.editAltText(this)}}));this.#j();this.div.append(e);if(!AnnotationEditor.SMALL_EDITOR_SIZE){const t=40;AnnotationEditor.SMALL_EDITOR_SIZE=Math.min(128,Math.round(e.getBoundingClientRect().width*(1+t/100)))}}async#j(){const e=this.#E;if(!e)return;if(!this.#S&&!this.#A){e.classList.remove("done");this.#P?.remove();return}AnnotationEditor._l10nPromise.get("editor_alt_text_edit_button_label").then((t=>{e.setAttribute("aria-label",t)}));let t=this.#P;if(!t){this.#P=t=document.createElement("span");t.className="tooltip";t.setAttribute("role","tooltip");const i=t.id=`alt-text-tooltip-${this.id}`;e.setAttribute("aria-describedby",i);const n=100;e.addEventListener("mouseenter",(()=>{this.#C=setTimeout((()=>{this.#C=null;this.#P.classList.add("show");this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"alt_text_tooltip"}}})}),n)}));e.addEventListener("mouseleave",(()=>{clearTimeout(this.#C);this.#C=null;this.#P?.classList.remove("show")}))}e.classList.add("done");t.innerText=this.#A?await AnnotationEditor._l10nPromise.get("editor_alt_text_decorative_tooltip"):this.#S;t.parentNode||e.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:this.#S,decorative:this.#A}}set altTextData({altText:e,decorative:t}){if(this.#S!==e||this.#A!==t){this.#S=e;this.#A=t;this.#j()}}render(){this.div=document.createElement("div");this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360);this.div.className=this.name;this.div.setAttribute("id",this.id);this.div.setAttribute("tabIndex",0);this.setInForeground();this.div.addEventListener("focusin",this.#M);this.div.addEventListener("focusout",this.#I);const[e,t]=this.parentDimensions;if(this.parentRotation%180!=0){this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`;this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`}const[i,s]=this.getInitialTranslation();this.translate(i,s);(0,n.bindEvents)(this,this.div,["pointerdown"]);return this.div}pointerdown(e){const{isMac:t}=s.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)e.preventDefault();else{this.#k=!0;this.#W(e)}}#W(e){if(!this._isDraggable)return;const t=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let i,n;if(t){i={passive:!0,capture:!0};n=e=>{const[t,i]=this.screenToPageTranslation(e.movementX,e.movementY);this._uiManager.dragSelectedEditors(t,i)};window.addEventListener("pointermove",n,i)}const pointerUpCallback=()=>{window.removeEventListener("pointerup",pointerUpCallback);window.removeEventListener("blur",pointerUpCallback);t&&window.removeEventListener("pointermove",n,i);this.#k=!1;if(!this._uiManager.endDragSession()){const{isMac:t}=s.FeatureTest.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}};window.addEventListener("pointerup",pointerUpCallback);window.addEventListener("blur",pointerUpCallback)}moveInDOM(){this.parent?.moveEditorInDOM(this)}_setParentAndPosition(e,t,i){e.changeParent(this);this.x=t;this.y=i;this.fixAndSetPosition()}getRect(e,t){const i=this.parentScale,[n,s]=this.pageDimensions,[a,r]=this.pageTranslation,o=e/i,l=t/i,d=this.x*n,h=this.y*s,c=this.width*n,u=this.height*s;switch(this.rotation){case 0:return[d+o+a,s-h-l-u+r,d+o+c+a,s-h-l+r];case 90:return[d+l+a,s-h+o+r,d+l+u+a,s-h+o+c+r];case 180:return[d-o-c+a,s-h+l+r,d-o+a,s-h+l+u+r];case 270:return[d-l-u+a,s-h-o-c+r,d-l+a,s-h-o+r];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[i,n,s,a]=e,r=s-i,o=a-n;switch(this.rotation){case 0:return[i,t-a,r,o];case 90:return[i,t-n,o,r];case 180:return[s,t-n,r,o];case 270:return[s,t-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#L=!0}disableEditMode(){this.#L=!1}isInEditMode(){return this.#L}shouldGetKeyboardEvents(){return!1}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){this.div?.addEventListener("focusin",this.#M);this.div?.addEventListener("focusout",this.#I)}serialize(e=!1,t=null){(0,s.unreachable)("An editor must be serializable")}static deserialize(e,t,i){const n=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:i});n.rotation=e.rotation;const[s,a]=n.pageDimensions,[r,o,l,d]=n.getRectInCurrentCoords(e.rect,a);n.x=r/s;n.y=o/a;n.width=l/s;n.height=d/a;return n}remove(){this.div.removeEventListener("focusin",this.#M);this.div.removeEventListener("focusout",this.#I);this.isEmpty()||this.commit();this.parent?this.parent.remove(this):this._uiManager.removeEditor(this);this.#E?.remove();this.#E=null;this.#P=null}get isResizable(){return!1}makeResizable(){if(this.isResizable){this.#U();this.#T.classList.remove("hidden")}}select(){this.makeResizable();this.div?.classList.add("selectedEditor")}unselect(){this.#T?.classList.add("hidden");this.div?.classList.remove("selectedEditor");this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(e,t){}disableEditing(){this.#E&&(this.#E.hidden=!0)}enableEditing(){this.#E&&(this.#E.hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return this.#D}set isEditing(e){this.#D=e;if(this.parent)if(e){this.parent.setSelected(this);this.parent.setActiveEditor(this)}else this.parent.setActiveEditor(null)}setAspectRatio(e,t){this.#x=!0;const i=e/t,{style:n}=this.div;n.aspectRatio=i;n.height="auto"}static get MIN_SIZE(){return 16}}t.AnnotationEditor=AnnotationEditor;class FakeEditor extends AnnotationEditor{constructor(e){super(e);this.annotationElementId=e.annotationElementId;this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.KeyboardManager=t.CommandManager=t.ColorManager=t.AnnotationEditorUIManager=void 0;t.bindEvents=function bindEvents(e,t,i){for(const n of i)t.addEventListener(n,e[n].bind(e))};t.opacityToHex=function opacityToHex(e){return Math.round(Math.min(255,Math.max(1,255*e))).toString(16).padStart(2,"0")};var n=i(1),s=i(6);class IdManager{#G=0;getId(){return`${n.AnnotationEditorPrefix}${this.#G++}`}}class ImageManager{#$=(0,n.getUuid)();#G=0;#q=null;static get _isSVGFittingCanvas(){const e=new OffscreenCanvas(1,3).getContext("2d"),t=new Image;t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';const i=t.decode().then((()=>{e.drawImage(t,0,0,1,1,0,0,1,3);return 0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]}));return(0,n.shadow)(this,"_isSVGFittingCanvas",i)}async#X(e,t){this.#q||=new Map;let i=this.#q.get(e);if(null===i)return null;if(i?.bitmap){i.refCounter+=1;return i}try{i||={bitmap:null,id:`image_${this.#$}_${this.#G++}`,refCounter:0,isSvg:!1};let e;if("string"==typeof t){i.url=t;const n=await fetch(t);if(!n.ok)throw new Error(n.statusText);e=await n.blob()}else e=i.file=t;if("image/svg+xml"===e.type){const t=ImageManager._isSVGFittingCanvas,n=new FileReader,s=new Image,a=new Promise(((e,a)=>{s.onload=()=>{i.bitmap=s;i.isSvg=!0;e()};n.onload=async()=>{const e=i.svgUrl=n.result;s.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e};s.onerror=n.onerror=a}));n.readAsDataURL(e);await a}else i.bitmap=await createImageBitmap(e);i.refCounter=1}catch(e){console.error(e);i=null}this.#q.set(e,i);i&&this.#q.set(i.id,i);return i}async getFromFile(e){const{lastModified:t,name:i,size:n,type:s}=e;return this.#X(`${t}_${i}_${n}_${s}`,e)}async getFromUrl(e){return this.#X(e,e)}async getFromId(e){this.#q||=new Map;const t=this.#q.get(e);if(!t)return null;if(t.bitmap){t.refCounter+=1;return t}return t.file?this.getFromFile(t.file):this.getFromUrl(t.url)}getSvgUrl(e){const t=this.#q.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#q||=new Map;const t=this.#q.get(e);if(t){t.refCounter-=1;0===t.refCounter&&(t.bitmap=null)}}isValidId(e){return e.startsWith(`image_${this.#$}_`)}}class CommandManager{#K=[];#Y=!1;#Q;#Z=-1;constructor(e=128){this.#Q=e}add({cmd:e,undo:t,mustExec:i,type:n=NaN,overwriteIfSameType:s=!1,keepUndo:a=!1}){i&&e();if(this.#Y)return;const r={cmd:e,undo:t,type:n};if(-1===this.#Z){this.#K.length>0&&(this.#K.length=0);this.#Z=0;this.#K.push(r);return}if(s&&this.#K[this.#Z].type===n){a&&(r.undo=this.#K[this.#Z].undo);this.#K[this.#Z]=r;return}const o=this.#Z+1;if(o===this.#Q)this.#K.splice(0,1);else{this.#Z=o;o<this.#K.length&&this.#K.splice(o)}this.#K.push(r)}undo(){if(-1!==this.#Z){this.#Y=!0;this.#K[this.#Z].undo();this.#Y=!1;this.#Z-=1}}redo(){if(this.#Z<this.#K.length-1){this.#Z+=1;this.#Y=!0;this.#K[this.#Z].cmd();this.#Y=!1}}hasSomethingToUndo(){return-1!==this.#Z}hasSomethingToRedo(){return this.#Z<this.#K.length-1}destroy(){this.#K=null}}t.CommandManager=CommandManager;class KeyboardManager{constructor(e){this.buffer=[];this.callbacks=new Map;this.allKeys=new Set;const{isMac:t}=n.FeatureTest.platform;for(const[i,n,s={}]of e)for(const e of i){const i=e.startsWith("mac+");if(t&&i){this.callbacks.set(e.slice(4),{callback:n,options:s});this.allKeys.add(e.split("+").at(-1))}else if(!t&&!i){this.callbacks.set(e,{callback:n,options:s});this.allKeys.add(e.split("+").at(-1))}}}#J(e){e.altKey&&this.buffer.push("alt");e.ctrlKey&&this.buffer.push("ctrl");e.metaKey&&this.buffer.push("meta");e.shiftKey&&this.buffer.push("shift");this.buffer.push(e.key);const t=this.buffer.join("+");this.buffer.length=0;return t}exec(e,t){if(!this.allKeys.has(t.key))return;const i=this.callbacks.get(this.#J(t));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:a=[],checker:r=null}}=i;if(!r||r(e,t)){n.bind(e,...a)();if(!s){t.stopPropagation();t.preventDefault()}}}}t.KeyboardManager=KeyboardManager;class ColorManager{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);(0,s.getColorValues)(e);return(0,n.shadow)(this,"_colors",e)}convert(e){const t=(0,s.getRGB)(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,i]of this._colors)if(i.every(((e,i)=>e===t[i])))return ColorManager._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?n.Util.makeHexColor(...t):e}}t.ColorManager=ColorManager;class AnnotationEditorUIManager{#ee=null;#te=new Map;#ie=new Map;#ne=null;#se=null;#ae=new CommandManager;#re=0;#oe=new Set;#le=null;#de=null;#he=new Set;#ce=null;#ue=new IdManager;#pe=!1;#ge=!1;#fe=null;#me=n.AnnotationEditorType.NONE;#be=new Set;#ve=null;#_e=this.blur.bind(this);#we=this.focus.bind(this);#ye=this.copy.bind(this);#Se=this.cut.bind(this);#Ae=this.paste.bind(this);#Ee=this.keydown.bind(this);#Pe=this.onEditingAction.bind(this);#Ce=this.onPageChanging.bind(this);#xe=this.onScaleChanging.bind(this);#Te=this.onRotationChanging.bind(this);#Me={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1};#Ie=[0,0];#ke=null;#De=null;#Le=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=AnnotationEditorUIManager.prototype,arrowChecker=e=>{const{activeElement:t}=document;return t&&e.#De.contains(t)&&e.hasSomethingToControl()},t=this.TRANSLATE_SMALL,i=this.TRANSLATE_BIG;return(0,n.shadow)(this,"_keyboardManager",new KeyboardManager([[["ctrl+a","mac+meta+a"],e.selectAll],[["ctrl+z","mac+meta+z"],e.undo],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:arrowChecker}]]))}constructor(e,t,i,n,a,r){this.#De=e;this.#Le=t;this.#ne=i;this._eventBus=n;this._eventBus._on("editingaction",this.#Pe);this._eventBus._on("pagechanging",this.#Ce);this._eventBus._on("scalechanging",this.#xe);this._eventBus._on("rotationchanging",this.#Te);this.#se=a.annotationStorage;this.#ce=a.filterFactory;this.#ve=r;this.viewParameters={realScale:s.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}destroy(){this.#Fe();this.#Re();this._eventBus._off("editingaction",this.#Pe);this._eventBus._off("pagechanging",this.#Ce);this._eventBus._off("scalechanging",this.#xe);this._eventBus._off("rotationchanging",this.#Te);for(const e of this.#ie.values())e.destroy();this.#ie.clear();this.#te.clear();this.#he.clear();this.#ee=null;this.#be.clear();this.#ae.destroy();this.#ne.destroy()}get hcmFilter(){return(0,n.shadow)(this,"hcmFilter",this.#ve?this.#ce.addHCMFilter(this.#ve.foreground,this.#ve.background):"none")}get direction(){return(0,n.shadow)(this,"direction",getComputedStyle(this.#De).direction)}editAltText(e){this.#ne?.editAltText(this,e)}onPageChanging({pageNumber:e}){this.#re=e-1}focusMainContainer(){this.#De.focus()}findParent(e,t){for(const i of this.#ie.values()){const{x:n,y:s,width:a,height:r}=i.div.getBoundingClientRect();if(e>=n&&e<=n+a&&t>=s&&t<=s+r)return i}return null}disableUserSelect(e=!1){this.#Le.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#he.add(e)}removeShouldRescale(e){this.#he.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove();this.viewParameters.realScale=e*s.PixelsPerInch.PDF_TO_CSS_UNITS;for(const e of this.#he)e.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove();this.viewParameters.rotation=e}addToAnnotationStorage(e){e.isEmpty()||!this.#se||this.#se.has(e.id)||this.#se.setValue(e.id,e)}#Oe(){window.addEventListener("focus",this.#we);window.addEventListener("blur",this.#_e)}#Re(){window.removeEventListener("focus",this.#we);window.removeEventListener("blur",this.#_e)}blur(){if(!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#be)if(t.div.contains(e)){this.#fe=[t,e];t._focusEventsAllowed=!1;break}}focus(){if(!this.#fe)return;const[e,t]=this.#fe;this.#fe=null;t.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0});t.focus()}#Ne(){window.addEventListener("keydown",this.#Ee,{capture:!0})}#Fe(){window.removeEventListener("keydown",this.#Ee,{capture:!0})}#Be(){document.addEventListener("copy",this.#ye);document.addEventListener("cut",this.#Se);document.addEventListener("paste",this.#Ae)}#Ve(){document.removeEventListener("copy",this.#ye);document.removeEventListener("cut",this.#Se);document.removeEventListener("paste",this.#Ae)}addEditListeners(){this.#Ne();this.#Be()}removeEditListeners(){this.#Fe();this.#Ve()}copy(e){e.preventDefault();this.#ee?.commitOrRemove();if(!this.hasSelection)return;const t=[];for(const e of this.#be){const i=e.serialize(!0);i&&t.push(i)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e);this.delete()}paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of this.#de)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let i=t.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(e){(0,n.warn)(`paste: "${e.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const e=[];for(const t of i){const i=s.deserialize(t);if(!i)return;e.push(i)}const cmd=()=>{for(const t of e)this.#Ue(t);this.#ze(e)},undo=()=>{for(const t of e)t.remove()};this.addCommands({cmd:cmd,undo:undo,mustExec:!0})}catch(e){(0,n.warn)(`paste: "${e.message}".`)}}keydown(e){this.getActive()?.shouldGetKeyboardEvents()||AnnotationEditorUIManager._keyboardManager.exec(this,e)}onEditingAction(e){["undo","redo","delete","selectAll"].includes(e.name)&&this[e.name]()}#He(e){Object.entries(e).some((([e,t])=>this.#Me[e]!==t))&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Me,e)})}#je(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){if(e){this.#Oe();this.#Ne();this.#Be();this.#He({isEditing:this.#me!==n.AnnotationEditorType.NONE,isEmpty:this.#We(),hasSomethingToUndo:this.#ae.hasSomethingToUndo(),hasSomethingToRedo:this.#ae.hasSomethingToRedo(),hasSelectedEditor:!1})}else{this.#Re();this.#Fe();this.#Ve();this.#He({isEditing:!1});this.disableUserSelect(!1)}}registerEditorTypes(e){if(!this.#de){this.#de=e;for(const e of this.#de)this.#je(e.defaultPropertiesToUpdate)}}getId(){return this.#ue.getId()}get currentLayer(){return this.#ie.get(this.#re)}getLayer(e){return this.#ie.get(e)}get currentPageIndex(){return this.#re}addLayer(e){this.#ie.set(e.pageIndex,e);this.#pe?e.enable():e.disable()}removeLayer(e){this.#ie.delete(e.pageIndex)}updateMode(e,t=null){if(this.#me!==e){this.#me=e;if(e!==n.AnnotationEditorType.NONE){this.setEditingState(!0);this.#Ge();this.unselectAll();for(const t of this.#ie.values())t.updateMode(e);if(t)for(const e of this.#te.values())if(e.annotationElementId===t){this.setSelected(e);e.enterInEditMode();break}}else{this.setEditingState(!1);this.#$e()}}}updateToolbar(e){e!==this.#me&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#de)if(e!==n.AnnotationEditorParamsType.CREATE){for(const i of this.#be)i.updateParams(e,t);for(const i of this.#de)i.updateDefaultParams(e,t)}else this.currentLayer.addNewEditor(e)}enableWaiting(e=!1){if(this.#ge!==e){this.#ge=e;for(const t of this.#ie.values()){e?t.disableClick():t.enableClick();t.div.classList.toggle("waiting",e)}}}#Ge(){if(!this.#pe){this.#pe=!0;for(const e of this.#ie.values())e.enable()}}#$e(){this.unselectAll();if(this.#pe){this.#pe=!1;for(const e of this.#ie.values())e.disable()}}getEditors(e){const t=[];for(const i of this.#te.values())i.pageIndex===e&&t.push(i);return t}getEditor(e){return this.#te.get(e)}addEditor(e){this.#te.set(e.id,e)}removeEditor(e){this.#te.delete(e.id);this.unselect(e);e.annotationElementId&&this.#oe.has(e.annotationElementId)||this.#se?.remove(e.id)}addDeletedAnnotationElement(e){this.#oe.add(e.annotationElementId);e.deleted=!0}isDeletedAnnotationElement(e){return this.#oe.has(e)}removeDeletedAnnotationElement(e){this.#oe.delete(e.annotationElementId);e.deleted=!1}#Ue(e){const t=this.#ie.get(e.pageIndex);t?t.addOrRebuild(e):this.addEditor(e)}setActiveEditor(e){if(this.#ee!==e){this.#ee=e;e&&this.#je(e.propertiesToUpdate)}}toggleSelected(e){if(this.#be.has(e)){this.#be.delete(e);e.unselect();this.#He({hasSelectedEditor:this.hasSelection})}else{this.#be.add(e);e.select();this.#je(e.propertiesToUpdate);this.#He({hasSelectedEditor:!0})}}setSelected(e){for(const t of this.#be)t!==e&&t.unselect();this.#be.clear();this.#be.add(e);e.select();this.#je(e.propertiesToUpdate);this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#be.has(e)}unselect(e){e.unselect();this.#be.delete(e);this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#be.size}undo(){this.#ae.undo();this.#He({hasSomethingToUndo:this.#ae.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#We()})}redo(){this.#ae.redo();this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#ae.hasSomethingToRedo(),isEmpty:this.#We()})}addCommands(e){this.#ae.add(e);this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#We()})}#We(){if(0===this.#te.size)return!0;if(1===this.#te.size)for(const e of this.#te.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();if(!this.hasSelection)return;const e=[...this.#be];this.addCommands({cmd:()=>{for(const t of e)t.remove()},undo:()=>{for(const t of e)this.#Ue(t)},mustExec:!0})}commitOrRemove(){this.#ee?.commitOrRemove()}hasSomethingToControl(){return this.#ee||this.hasSelection}#ze(e){this.#be.clear();for(const t of e)if(!t.isEmpty()){this.#be.add(t);t.select()}this.#He({hasSelectedEditor:!0})}selectAll(){for(const e of this.#be)e.commit();this.#ze(this.#te.values())}unselectAll(){if(this.#ee)this.#ee.commitOrRemove();else if(this.hasSelection){for(const e of this.#be)e.unselect();this.#be.clear();this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,i=!1){i||this.commitOrRemove();if(!this.hasSelection)return;this.#Ie[0]+=e;this.#Ie[1]+=t;const[n,s]=this.#Ie,a=[...this.#be];this.#ke&&clearTimeout(this.#ke);this.#ke=setTimeout((()=>{this.#ke=null;this.#Ie[0]=this.#Ie[1]=0;this.addCommands({cmd:()=>{for(const e of a)this.#te.has(e.id)&&e.translateInPage(n,s)},undo:()=>{for(const e of a)this.#te.has(e.id)&&e.translateInPage(-n,-s)},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0);this.#le=new Map;for(const e of this.#be)this.#le.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#le)return!1;this.disableUserSelect(!1);const e=this.#le;this.#le=null;let t=!1;for(const[{x:i,y:n,pageIndex:s},a]of e){a.newX=i;a.newY=n;a.newPageIndex=s;t||=i!==a.savedX||n!==a.savedY||s!==a.savedPageIndex}if(!t)return!1;const move=(e,t,i,n)=>{if(this.#te.has(e.id)){const s=this.#ie.get(n);if(s)e._setParentAndPosition(s,t,i);else{e.pageIndex=n;e.x=t;e.y=i}}};this.addCommands({cmd:()=>{for(const[t,{newX:i,newY:n,newPageIndex:s}]of e)move(t,i,n,s)},undo:()=>{for(const[t,{savedX:i,savedY:n,savedPageIndex:s}]of e)move(t,i,n,s)},mustExec:!0});return!0}dragSelectedEditors(e,t){if(this.#le)for(const i of this.#le.keys())i.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);if(t){t.changeParent(e);t.addOrRebuild(e)}else{this.addEditor(e);this.addToAnnotationStorage(e);e.rebuild()}}else e.parent.addOrRebuild(e)}isActive(e){return this.#ee===e}getActive(){return this.#ee}getMode(){return this.#me}get imageManager(){return(0,n.shadow)(this,"imageManager",new ImageManager)}}t.AnnotationEditorUIManager=AnnotationEditorUIManager},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.StatTimer=t.RenderingCancelledException=t.PixelsPerInch=t.PageViewport=t.PDFDateString=t.DOMStandardFontDataFactory=t.DOMSVGFactory=t.DOMFilterFactory=t.DOMCanvasFactory=t.DOMCMapReaderFactory=void 0;t.deprecated=function deprecated(e){console.log("Deprecated API usage: "+e)};t.getColorValues=function getColorValues(e){const t=document.createElement("span");t.style.visibility="hidden";document.body.append(t);for(const i of e.keys()){t.style.color=i;const n=window.getComputedStyle(t).color;e.set(i,getRGB(n))}t.remove()};t.getCurrentTransform=function getCurrentTransform(e){const{a:t,b:i,c:n,d:s,e:a,f:r}=e.getTransform();return[t,i,n,s,a,r]};t.getCurrentTransformInverse=function getCurrentTransformInverse(e){const{a:t,b:i,c:n,d:s,e:a,f:r}=e.getTransform().invertSelf();return[t,i,n,s,a,r]};t.getFilenameFromUrl=function getFilenameFromUrl(e,t=!1){t||([e]=e.split(/[#?]/,1));return e.substring(e.lastIndexOf("/")+1)};t.getPdfFilenameFromUrl=function getPdfFilenameFromUrl(e,t="document.pdf"){if("string"!=typeof e)return t;if(isDataScheme(e)){(0,s.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.');return t}const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let a=i.exec(n[1])||i.exec(n[2])||i.exec(n[3]);if(a){a=a[0];if(a.includes("%"))try{a=i.exec(decodeURIComponent(a))[0]}catch{}}return a||t};t.getRGB=getRGB;t.getXfaPageViewport=function getXfaPageViewport(e,{scale:t=1,rotation:i=0}){const{width:n,height:s}=e.attributes.style,a=[0,0,parseInt(n),parseInt(s)];return new PageViewport({viewBox:a,scale:t,rotation:i})};t.isDataScheme=isDataScheme;t.isPdfFile=function isPdfFile(e){return"string"==typeof e&&/\.pdf$/i.test(e)};t.isValidFetchUrl=isValidFetchUrl;t.loadScript=function loadScript(e,t=!1){return new Promise(((i,n)=>{const s=document.createElement("script");s.src=e;s.onload=function(e){t&&s.remove();i(e)};s.onerror=function(){n(new Error(`Cannot load script at: ${s.src}`))};(document.head||document.documentElement).append(s)}))};t.noContextMenu=function noContextMenu(e){e.preventDefault()};t.setLayerDimensions=function setLayerDimensions(e,t,i=!1,n=!0){if(t instanceof PageViewport){const{pageWidth:n,pageHeight:a}=t.rawDims,{style:r}=e,o=s.FeatureTest.isCSSRoundSupported,l=`var(--scale-factor) * ${n}px`,d=`var(--scale-factor) * ${a}px`,h=o?`round(${l}, 1px)`:`calc(${l})`,c=o?`round(${d}, 1px)`:`calc(${d})`;if(i&&t.rotation%180!=0){r.width=c;r.height=h}else{r.width=h;r.height=c}}n&&e.setAttribute("data-main-rotation",t.rotation)};var n=i(7),s=i(1);const a="http://www.w3.org/2000/svg";class PixelsPerInch{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}t.PixelsPerInch=PixelsPerInch;class DOMFilterFactory extends n.BaseFilterFactory{#qe;#Xe;#t;#Ke;#Ye;#Qe;#Ze;#Je;#et;#tt;#G=0;constructor({docId:e,ownerDocument:t=globalThis.document}={}){super();this.#t=e;this.#Ke=t}get#q(){return this.#qe||=new Map}get#it(){if(!this.#Xe){const e=this.#Ke.createElement("div"),{style:t}=e;t.visibility="hidden";t.contain="strict";t.width=t.height=0;t.position="absolute";t.top=t.left=0;t.zIndex=-1;const i=this.#Ke.createElementNS(a,"svg");i.setAttribute("width",0);i.setAttribute("height",0);this.#Xe=this.#Ke.createElementNS(a,"defs");e.append(i);i.append(this.#Xe);this.#Ke.body.append(e)}return this.#Xe}addFilter(e){if(!e)return"none";let t,i,n,s,a=this.#q.get(e);if(a)return a;if(1===e.length){const a=e[0],r=new Array(256);for(let e=0;e<256;e++)r[e]=a[e]/255;s=t=i=n=r.join(",")}else{const[a,r,o]=e,l=new Array(256),d=new Array(256),h=new Array(256);for(let e=0;e<256;e++){l[e]=a[e]/255;d[e]=r[e]/255;h[e]=o[e]/255}t=l.join(",");i=d.join(",");n=h.join(",");s=`${t}${i}${n}`}a=this.#q.get(s);if(a){this.#q.set(e,a);return a}const r=`g_${this.#t}_transfer_map_${this.#G++}`,o=`url(#${r})`;this.#q.set(e,o);this.#q.set(s,o);const l=this.#nt(r);this.#st(t,i,n,l);return o}addHCMFilter(e,t){const i=`${e}-${t}`;if(this.#Qe===i)return this.#Ze;this.#Qe=i;this.#Ze="none";this.#Ye?.remove();if(!e||!t)return this.#Ze;const n=this.#at(e);e=s.Util.makeHexColor(...n);const a=this.#at(t);t=s.Util.makeHexColor(...a);this.#it.style.color="";if("#000000"===e&&"#ffffff"===t||e===t)return this.#Ze;const r=new Array(256);for(let e=0;e<=255;e++){const t=e/255;r[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const o=r.join(","),l=`g_${this.#t}_hcm_filter`,d=this.#Je=this.#nt(l);this.#st(o,o,o,d);this.#rt(d);const getSteps=(e,t)=>{const i=n[e]/255,s=a[e]/255,r=new Array(t+1);for(let e=0;e<=t;e++)r[e]=i+e/t*(s-i);return r.join(",")};this.#st(getSteps(0,5),getSteps(1,5),getSteps(2,5),d);this.#Ze=`url(#${l})`;return this.#Ze}addHighlightHCMFilter(e,t,i,n){const s=`${e}-${t}-${i}-${n}`;if(this.#et===s)return this.#tt;this.#et=s;this.#tt="none";this.#Je?.remove();if(!e||!t)return this.#tt;const[a,r]=[e,t].map(this.#at.bind(this));let o=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),l=Math.round(.2126*r[0]+.7152*r[1]+.0722*r[2]),[d,h]=[i,n].map(this.#at.bind(this));l<o&&([o,l,d,h]=[l,o,h,d]);this.#it.style.color="";const getSteps=(e,t,i)=>{const n=new Array(256),s=(l-o)/i,a=e/255,r=(t-e)/(255*i);let d=0;for(let e=0;e<=i;e++){const t=Math.round(o+e*s),i=a+e*r;for(let e=d;e<=t;e++)n[e]=i;d=t+1}for(let e=d;e<256;e++)n[e]=n[d-1];return n.join(",")},c=`g_${this.#t}_hcm_highlight_filter`,u=this.#Je=this.#nt(c);this.#rt(u);this.#st(getSteps(d[0],h[0],5),getSteps(d[1],h[1],5),getSteps(d[2],h[2],5),u);this.#tt=`url(#${c})`;return this.#tt}destroy(e=!1){if(!e||!this.#Ze&&!this.#tt){if(this.#Xe){this.#Xe.parentNode.parentNode.remove();this.#Xe=null}if(this.#qe){this.#qe.clear();this.#qe=null}this.#G=0}}#rt(e){const t=this.#Ke.createElementNS(a,"feColorMatrix");t.setAttribute("type","matrix");t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0");e.append(t)}#nt(e){const t=this.#Ke.createElementNS(a,"filter");t.setAttribute("color-interpolation-filters","sRGB");t.setAttribute("id",e);this.#it.append(t);return t}#ot(e,t,i){const n=this.#Ke.createElementNS(a,t);n.setAttribute("type","discrete");n.setAttribute("tableValues",i);e.append(n)}#st(e,t,i,n){const s=this.#Ke.createElementNS(a,"feComponentTransfer");n.append(s);this.#ot(s,"feFuncR",e);this.#ot(s,"feFuncG",t);this.#ot(s,"feFuncB",i)}#at(e){this.#it.style.color=e;return getRGB(getComputedStyle(this.#it).getPropertyValue("color"))}}t.DOMFilterFactory=DOMFilterFactory;class DOMCanvasFactory extends n.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super();this._document=e}_createCanvas(e,t){const i=this._document.createElement("canvas");i.width=e;i.height=t;return i}}t.DOMCanvasFactory=DOMCanvasFactory;async function fetchData(e,t=!1){if(isValidFetchUrl(e,document.baseURI)){const i=await fetch(e);if(!i.ok)throw new Error(i.statusText);return t?new Uint8Array(await i.arrayBuffer()):(0,s.stringToBytes)(await i.text())}return new Promise(((i,n)=>{const a=new XMLHttpRequest;a.open("GET",e,!0);t&&(a.responseType="arraybuffer");a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE){if(200===a.status||0===a.status){let e;t&&a.response?e=new Uint8Array(a.response):!t&&a.responseText&&(e=(0,s.stringToBytes)(a.responseText));if(e){i(e);return}}n(new Error(a.statusText))}};a.send(null)}))}class DOMCMapReaderFactory extends n.BaseCMapReaderFactory{_fetchData(e,t){return fetchData(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=DOMCMapReaderFactory;class DOMStandardFontDataFactory extends n.BaseStandardFontDataFactory{_fetchData(e){return fetchData(e,!0)}}t.DOMStandardFontDataFactory=DOMStandardFontDataFactory;class DOMSVGFactory extends n.BaseSVGFactory{_createSVG(e){return document.createElementNS(a,e)}}t.DOMSVGFactory=DOMSVGFactory;class PageViewport{constructor({viewBox:e,scale:t,rotation:i,offsetX:n=0,offsetY:s=0,dontFlip:a=!1}){this.viewBox=e;this.scale=t;this.rotation=i;this.offsetX=n;this.offsetY=s;const r=(e[2]+e[0])/2,o=(e[3]+e[1])/2;let l,d,h,c,u,p,g,f;(i%=360)<0&&(i+=360);switch(i){case 180:l=-1;d=0;h=0;c=1;break;case 90:l=0;d=1;h=1;c=0;break;case 270:l=0;d=-1;h=-1;c=0;break;case 0:l=1;d=0;h=0;c=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}if(a){h=-h;c=-c}if(0===l){u=Math.abs(o-e[1])*t+n;p=Math.abs(r-e[0])*t+s;g=(e[3]-e[1])*t;f=(e[2]-e[0])*t}else{u=Math.abs(r-e[0])*t+n;p=Math.abs(o-e[1])*t+s;g=(e[2]-e[0])*t;f=(e[3]-e[1])*t}this.transform=[l*t,d*t,h*t,c*t,u-l*t*r-h*t*o,p-d*t*r-c*t*o];this.width=g;this.height=f}get rawDims(){const{viewBox:e}=this;return(0,s.shadow)(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:s=!1}={}){return new PageViewport({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:i,offsetY:n,dontFlip:s})}convertToViewportPoint(e,t){return s.Util.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=s.Util.applyTransform([e[0],e[1]],this.transform),i=s.Util.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],i[0],i[1]]}convertToPdfPoint(e,t){return s.Util.applyInverseTransform([e,t],this.transform)}}t.PageViewport=PageViewport;class RenderingCancelledException extends s.BaseException{constructor(e,t=0){super(e,"RenderingCancelledException");this.extraDelay=t}}t.RenderingCancelledException=RenderingCancelledException;function isDataScheme(e){const t=e.length;let i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}t.StatTimer=class StatTimer{started=Object.create(null);times=[];time(e){e in this.started&&(0,s.warn)(`Timer is already running for ${e}`);this.started[e]=Date.now()}timeEnd(e){e in this.started||(0,s.warn)(`Timer has not been started for ${e}`);this.times.push({name:e,start:this.started[e],end:Date.now()});delete this.started[e]}toString(){const e=[];let t=0;for(const{name:e}of this.times)t=Math.max(e.length,t);for(const{name:i,start:n,end:s}of this.times)e.push(`${i.padEnd(t)} ${s-n}ms\n`);return e.join("")}};function isValidFetchUrl(e,t){try{const{protocol:i}=t?new URL(e,t):new URL(e);return"http:"===i||"https:"===i}catch{return!1}}let r;t.PDFDateString=class PDFDateString{static toDateObject(e){if(!e||"string"!=typeof e)return null;r||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=r.exec(e);if(!t)return null;const i=parseInt(t[1],10);let n=parseInt(t[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(t[3],10);s=s>=1&&s<=31?s:1;let a=parseInt(t[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(t[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;const d=t[7]||"Z";let h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(t[9],10)||0;c=c>=0&&c<=59?c:0;if("-"===d){a+=h;o+=c}else if("+"===d){a-=h;o-=c}return new Date(Date.UTC(i,n,s,a,o,l))}};function getRGB(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}if(e.startsWith("rgb("))return e.slice(4,-1).split(",").map((e=>parseInt(e)));if(e.startsWith("rgba("))return e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3);(0,s.warn)(`Not a valid color format: "${e}"`);return[0,0,0]}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.BaseStandardFontDataFactory=t.BaseSVGFactory=t.BaseFilterFactory=t.BaseCanvasFactory=t.BaseCMapReaderFactory=void 0;var n=i(1);class BaseFilterFactory{constructor(){this.constructor===BaseFilterFactory&&(0,n.unreachable)("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addHighlightHCMFilter(e,t,i,n){return"none"}destroy(e=!1){}}t.BaseFilterFactory=BaseFilterFactory;class BaseCanvasFactory{constructor(){this.constructor===BaseCanvasFactory&&(0,n.unreachable)("Cannot initialize BaseCanvasFactory.")}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(e,t);return{canvas:i,context:i.getContext("2d")}}reset(e,t,i){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||i<=0)throw new Error("Invalid canvas size");e.canvas.width=t;e.canvas.height=i}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0;e.canvas.height=0;e.canvas=null;e.context=null}_createCanvas(e,t){(0,n.unreachable)("Abstract method `_createCanvas` called.")}}t.BaseCanvasFactory=BaseCanvasFactory;class BaseCMapReaderFactory{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===BaseCMapReaderFactory&&(0,n.unreachable)("Cannot initialize BaseCMapReaderFactory.");this.baseUrl=e;this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":""),i=this.isCompressed?n.CMapCompressionType.BINARY:n.CMapCompressionType.NONE;return this._fetchData(t,i).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}_fetchData(e,t){(0,n.unreachable)("Abstract method `_fetchData` called.")}}t.BaseCMapReaderFactory=BaseCMapReaderFactory;class BaseStandardFontDataFactory{constructor({baseUrl:e=null}){this.constructor===BaseStandardFontDataFactory&&(0,n.unreachable)("Cannot initialize BaseStandardFontDataFactory.");this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetchData(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}_fetchData(e){(0,n.unreachable)("Abstract method `_fetchData` called.")}}t.BaseStandardFontDataFactory=BaseStandardFontDataFactory;class BaseSVGFactory{constructor(){this.constructor===BaseSVGFactory&&(0,n.unreachable)("Cannot initialize BaseSVGFactory.")}create(e,t,i=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");n.setAttribute("version","1.1");if(!i){n.setAttribute("width",`${e}px`);n.setAttribute("height",`${t}px`)}n.setAttribute("preserveAspectRatio","none");n.setAttribute("viewBox",`0 0 ${e} ${t}`);return n}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){(0,n.unreachable)("Abstract method `_createSVG` called.")}}t.BaseSVGFactory=BaseSVGFactory},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.MurmurHash3_64=void 0;var n=i(1);const s=3285377520,a=4294901760,r=65535;t.MurmurHash3_64=class MurmurHash3_64{constructor(e){this.h1=e?4294967295&e:s;this.h2=e?4294967295&e:s}update(e){let t,i;if("string"==typeof e){t=new Uint8Array(2*e.length);i=0;for(let n=0,s=e.length;n<s;n++){const s=e.charCodeAt(n);if(s<=255)t[i++]=s;else{t[i++]=s>>>8;t[i++]=255&s}}}else{if(!(0,n.isArrayBuffer)(e))throw new Error("Wrong data format in MurmurHash3_64_update. Input must be a string or array.");t=e.slice();i=t.byteLength}const s=i>>2,o=i-4*s,l=new Uint32Array(t.buffer,0,s);let d=0,h=0,c=this.h1,u=this.h2;const p=3432918353,g=461845907,f=11601,m=13715;for(let e=0;e<s;e++)if(1&e){d=l[e];d=d*p&a|d*f&r;d=d<<15|d>>>17;d=d*g&a|d*m&r;c^=d;c=c<<13|c>>>19;c=5*c+3864292196}else{h=l[e];h=h*p&a|h*f&r;h=h<<15|h>>>17;h=h*g&a|h*m&r;u^=h;u=u<<13|u>>>19;u=5*u+3864292196}d=0;switch(o){case 3:d^=t[4*s+2]<<16;case 2:d^=t[4*s+1]<<8;case 1:d^=t[4*s];d=d*p&a|d*f&r;d=d<<15|d>>>17;d=d*g&a|d*m&r;1&s?c^=d:u^=d}this.h1=c;this.h2=u}hexdigest(){let e=this.h1,t=this.h2;e^=t>>>1;e=3981806797*e&a|36045*e&r;t=4283543511*t&a|(2950163797*(t<<16|e>>>16)&a)>>>16;e^=t>>>1;e=444984403*e&a|60499*e&r;t=3301882366*t&a|(3120437893*(t<<16|e>>>16)&a)>>>16;e^=t>>>1;return(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.FontLoader=t.FontFaceObject=void 0;var n=i(1);t.FontLoader=class FontLoader{#lt=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e;this.nativeFontFaces=new Set;this.styleElement=null;this.loadingRequests=[];this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e);this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e);this._document.fonts.delete(e)}insertRule(e){if(!this.styleElement){this.styleElement=this._document.createElement("style");this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement)}const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear();this.#lt.clear();if(this.styleElement){this.styleElement.remove();this.styleElement=null}}async loadSystemFont(e){if(e&&!this.#lt.has(e.loadedName)){(0,n.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set.");if(this.isFontLoadingAPISupported){const{loadedName:t,src:i,style:s}=e,a=new FontFace(t,i,s);this.addNativeFontFace(a);try{await a.load();this.#lt.add(t)}catch{(0,n.warn)(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`);this.removeNativeFontFace(a)}}else(0,n.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;e.attached=!0;if(e.systemFontInfo){await this.loadSystemFont(e.systemFontInfo);return}if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(i){(0,n.warn)(`Failed to load font '${t.family}': '${i}'.`);e.disableFontFace=!0;throw i}}return}const t=e.createFontFaceRule();if(t){this.insertRule(t);if(this.isSyncFontLoadingSupported)return;await new Promise((t=>{const i=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,i)}))}}get isFontLoadingAPISupported(){const e=!!this._document?.fonts;return(0,n.shadow)(this,"isFontLoadingAPISupported",e)}get isSyncFontLoadingSupported(){let e=!1;(n.isNodeJS||"undefined"!=typeof navigator&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0);return(0,n.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,i={done:!1,complete:function completeRequest(){(0,n.assert)(!i.done,"completeRequest() cannot be called twice.");i.done=!0;for(;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};t.push(i);return i}get _loadTestFont(){const e=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return(0,n.shadow)(this,"_loadTestFont",e)}_prepareFontLoadEvent(e,t){function int32(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function spliceString(e,t,i,n){return e.substring(0,t)+n+e.substring(t+i)}let i,s;const a=this._document.createElement("canvas");a.width=1;a.height=1;const r=a.getContext("2d");let o=0;const l=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=spliceString(d,976,l.length,l);const h=1482184792;let c=int32(d,16);for(i=0,s=l.length-3;i<s;i+=4)c=c-h+int32(l,i)|0;i<l.length&&(c=c-h+int32(l+"XXX",i)|0);d=spliceString(d,16,4,(0,n.string32)(c));const u=`@font-face {font-family:"${l}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(u);const p=this._document.createElement("div");p.style.visibility="hidden";p.style.width=p.style.height="10px";p.style.position="absolute";p.style.top=p.style.left="0px";for(const t of[e.loadedName,l]){const e=this._document.createElement("span");e.textContent="Hi";e.style.fontFamily=t;p.append(e)}this._document.body.append(p);!function isFontReady(e,t){if(++o>30){(0,n.warn)("Load test font never loaded.");t();return}r.font="30px "+e;r.fillText(".",0,20);r.getImageData(0,0,1,1).data[3]>0?t():setTimeout(isFontReady.bind(null,e,t))}(l,(()=>{p.remove();t.complete()}))}};t.FontFaceObject=class FontFaceObject{constructor(e,{isEvalSupported:t=!0,disableFontFace:i=!1,ignoreErrors:n=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.isEvalSupported=!1!==t;this.disableFontFace=!0===i;this.ignoreErrors=!0===n;this._inspectFont=s}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`);e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});this._inspectFont?.(this);return e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=(0,n.bytesToString)(this.data),t=`url(data:${this.mimetype};base64,${btoa(e)});`;let i;if(this.cssFontInfo){let e=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(e+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`);i=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${e}src:${t}}`}else i=`@font-face {font-family:"${this.loadedName}";src:${t}}`;this._inspectFont?.(this,t);return i}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];let i;try{i=e.get(this.loadedName+"_path_"+t)}catch(e){if(!this.ignoreErrors)throw e;(0,n.warn)(`getPathGenerator - ignoring character: "${e}".`);return this.compiledGlyphs[t]=function(e,t){}}if(this.isEvalSupported&&n.FeatureTest.isEvalSupported){const e=[];for(const t of i){const i=void 0!==t.args?t.args.join(","):"";e.push("c.",t.cmd,"(",i,");\n")}return this.compiledGlyphs[t]=new Function("c","size",e.join(""))}return this.compiledGlyphs[t]=function(e,t){for(const n of i){"scale"===n.cmd&&(n.args=[t,-t]);e[n.cmd].apply(e,n.args)}}}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.NodeStandardFontDataFactory=t.NodeFilterFactory=t.NodeCanvasFactory=t.NodeCMapReaderFactory=void 0;var n=i(7);i(1);const fetchData=function(e){return new Promise(((t,i)=>{require("fs").readFile(e,((e,n)=>{!e&&n?t(new Uint8Array(n)):i(new Error(e))}))}))};class NodeFilterFactory extends n.BaseFilterFactory{}t.NodeFilterFactory=NodeFilterFactory;class NodeCanvasFactory extends n.BaseCanvasFactory{_createCanvas(e,t){return require("canvas").createCanvas(e,t)}}t.NodeCanvasFactory=NodeCanvasFactory;class NodeCMapReaderFactory extends n.BaseCMapReaderFactory{_fetchData(e,t){return fetchData(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=NodeCMapReaderFactory;class NodeStandardFontDataFactory extends n.BaseStandardFontDataFactory{_fetchData(e){return fetchData(e)}}t.NodeStandardFontDataFactory=NodeStandardFontDataFactory},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.CanvasGraphics=void 0;var n=i(1),s=i(6),a=i(12),r=i(13);const o=4096,l=16;class CachedCanvases{constructor(e){this.canvasFactory=e;this.cache=Object.create(null)}getCanvas(e,t,i){let n;if(void 0!==this.cache[e]){n=this.cache[e];this.canvasFactory.reset(n,t,i)}else{n=this.canvasFactory.create(t,i);this.cache[e]=n}return n}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t);delete this.cache[e]}}}function drawImageAtIntegerCoords(e,t,i,n,a,r,o,l,d,h){const[c,u,p,g,f,m]=(0,s.getCurrentTransform)(e);if(0===u&&0===p){const s=o*c+f,b=Math.round(s),v=l*g+m,_=Math.round(v),w=(o+d)*c+f,y=Math.abs(Math.round(w)-b)||1,S=(l+h)*g+m,A=Math.abs(Math.round(S)-_)||1;e.setTransform(Math.sign(c),0,0,Math.sign(g),b,_);e.drawImage(t,i,n,a,r,0,0,y,A);e.setTransform(c,u,p,g,f,m);return[y,A]}if(0===c&&0===g){const s=l*p+f,b=Math.round(s),v=o*u+m,_=Math.round(v),w=(l+h)*p+f,y=Math.abs(Math.round(w)-b)||1,S=(o+d)*u+m,A=Math.abs(Math.round(S)-_)||1;e.setTransform(0,Math.sign(u),Math.sign(p),0,b,_);e.drawImage(t,i,n,a,r,0,0,A,y);e.setTransform(c,u,p,g,f,m);return[A,y]}e.drawImage(t,i,n,a,r,o,l,d,h);return[Math.hypot(c,u)*d,Math.hypot(p,g)*h]}class CanvasExtraState{constructor(e,t){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="none";this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);e.clipBox=this.clipBox.slice();return e}setCurrentPoint(e,t){this.x=e;this.y=t}updatePathMinMax(e,t,i){[t,i]=n.Util.applyTransform([t,i],e);this.minX=Math.min(this.minX,t);this.minY=Math.min(this.minY,i);this.maxX=Math.max(this.maxX,t);this.maxY=Math.max(this.maxY,i)}updateRectMinMax(e,t){const i=n.Util.applyTransform(t,e),s=n.Util.applyTransform(t.slice(2),e);this.minX=Math.min(this.minX,i[0],s[0]);this.minY=Math.min(this.minY,i[1],s[1]);this.maxX=Math.max(this.maxX,i[0],s[0]);this.maxY=Math.max(this.maxY,i[1],s[1])}updateScalingPathMinMax(e,t){n.Util.scaleMinMax(e,t);this.minX=Math.min(this.minX,t[0]);this.maxX=Math.max(this.maxX,t[1]);this.minY=Math.min(this.minY,t[2]);this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,i,s,a,r,o,l,d,h){const c=n.Util.bezierBoundingBox(t,i,s,a,r,o,l,d);if(h){h[0]=Math.min(h[0],c[0],c[2]);h[1]=Math.max(h[1],c[0],c[2]);h[2]=Math.min(h[2],c[1],c[3]);h[3]=Math.max(h[3],c[1],c[3])}else this.updateRectMinMax(e,c)}getPathBoundingBox(e=a.PathType.FILL,t=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(e===a.PathType.STROKE){t||(0,n.unreachable)("Stroke bounding box must include transform.");const e=n.Util.singularValueDecompose2dScale(t),s=e[0]*this.lineWidth/2,a=e[1]*this.lineWidth/2;i[0]-=s;i[1]-=a;i[2]+=s;i[3]+=a}return i}updateClipFromPath(){const e=n.Util.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e;this.minX=1/0;this.minY=1/0;this.maxX=0;this.maxY=0}getClippedPathBoundingBox(e=a.PathType.FILL,t=null){return n.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function putBinaryImageData(e,t){if("undefined"!=typeof ImageData&&t instanceof ImageData){e.putImageData(t,0,0);return}const i=t.height,s=t.width,a=i%l,r=(i-a)/l,o=0===a?r:r+1,d=e.createImageData(s,l);let h,c=0;const u=t.data,p=d.data;let g,f,m,b;if(t.kind===n.ImageKind.GRAYSCALE_1BPP){const t=u.byteLength,i=new Uint32Array(p.buffer,0,p.byteLength>>2),b=i.length,v=s+7>>3,_=4294967295,w=n.FeatureTest.isLittleEndian?4278190080:255;for(g=0;g<o;g++){m=g<r?l:a;h=0;for(f=0;f<m;f++){const e=t-c;let n=0;const a=e>v?s:8*e-7,r=-8&a;let o=0,l=0;for(;n<r;n+=8){l=u[c++];i[h++]=128&l?_:w;i[h++]=64&l?_:w;i[h++]=32&l?_:w;i[h++]=16&l?_:w;i[h++]=8&l?_:w;i[h++]=4&l?_:w;i[h++]=2&l?_:w;i[h++]=1&l?_:w}for(;n<a;n++){if(0===o){l=u[c++];o=128}i[h++]=l&o?_:w;o>>=1}}for(;h<b;)i[h++]=0;e.putImageData(d,0,g*l)}}else if(t.kind===n.ImageKind.RGBA_32BPP){f=0;b=s*l*4;for(g=0;g<r;g++){p.set(u.subarray(c,c+b));c+=b;e.putImageData(d,0,f);f+=l}if(g<o){b=s*a*4;p.set(u.subarray(c,c+b));e.putImageData(d,0,f)}}else{if(t.kind!==n.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);m=l;b=s*m;for(g=0;g<o;g++){if(g>=r){m=a;b=s*m}h=0;for(f=b;f--;){p[h++]=u[c++];p[h++]=u[c++];p[h++]=u[c++];p[h++]=255}e.putImageData(d,0,g*l)}}}function putBinaryImageMask(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}const i=t.height,n=t.width,s=i%l,a=(i-s)/l,o=0===s?a:a+1,d=e.createImageData(n,l);let h=0;const c=t.data,u=d.data;for(let t=0;t<o;t++){const i=t<a?l:s;({srcPos:h}=(0,r.convertBlackAndWhiteToRGBA)({src:c,srcPos:h,dest:u,width:n,height:i,nonBlackColor:0}));e.putImageData(d,0,t*l)}}function copyCtxState(e,t){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of i)void 0!==e[n]&&(t[n]=e[n]);if(void 0!==e.setLineDash){t.setLineDash(e.getLineDash());t.lineDashOffset=e.lineDashOffset}}function resetCtxToDefault(e){e.strokeStyle=e.fillStyle="#000000";e.fillRule="nonzero";e.globalAlpha=1;e.lineWidth=1;e.lineCap="butt";e.lineJoin="miter";e.miterLimit=10;e.globalCompositeOperation="source-over";e.font="10px sans-serif";if(void 0!==e.setLineDash){e.setLineDash([]);e.lineDashOffset=0}if(!n.isNodeJS){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function composeSMaskBackdrop(e,t,i,n){const s=e.length;for(let a=3;a<s;a+=4){const s=e[a];if(0===s){e[a-3]=t;e[a-2]=i;e[a-1]=n}else if(s<255){const r=255-s;e[a-3]=e[a-3]*s+t*r>>8;e[a-2]=e[a-2]*s+i*r>>8;e[a-1]=e[a-1]*s+n*r>>8}}}function composeSMaskAlpha(e,t,i){const n=e.length;for(let s=3;s<n;s+=4){const n=i?i[e[s]]:e[s];t[s]=t[s]*n*.00392156862745098|0}}function composeSMaskLuminosity(e,t,i){const n=e.length;for(let s=3;s<n;s+=4){const n=77*e[s-3]+152*e[s-2]+28*e[s-1];t[s]=i?t[s]*i[n>>8]>>8:t[s]*n>>16}}function composeSMask(e,t,i,n){const s=n[0],a=n[1],r=n[2]-s,o=n[3]-a;if(0!==r&&0!==o){!function genericComposeSMask(e,t,i,n,s,a,r,o,l,d,h){const c=!!a,u=c?a[0]:0,p=c?a[1]:0,g=c?a[2]:0,f="Luminosity"===s?composeSMaskLuminosity:composeSMaskAlpha,m=Math.min(n,Math.ceil(1048576/i));for(let s=0;s<n;s+=m){const a=Math.min(m,n-s),b=e.getImageData(o-d,s+(l-h),i,a),v=t.getImageData(o,s+l,i,a);c&&composeSMaskBackdrop(b.data,u,p,g);f(b.data,v.data,r);t.putImageData(v,o,s+l)}}(t.context,i,r,o,t.subtype,t.backdrop,t.transferMap,s,a,t.offsetX,t.offsetY);e.save();e.globalAlpha=1;e.globalCompositeOperation="source-over";e.setTransform(1,0,0,1,0,0);e.drawImage(i.canvas,0,0);e.restore()}}function getImageSmoothingEnabled(e,t){const i=n.Util.singularValueDecompose2dScale(e);i[0]=Math.fround(i[0]);i[1]=Math.fround(i[1]);const a=Math.fround((globalThis.devicePixelRatio||1)*s.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:i[0]<=a||i[1]<=a}const d=["butt","round","square"],h=["miter","round","bevel"],c={},u={};class CanvasGraphics{constructor(e,t,i,n,s,{optionalContentConfig:a,markedContentStack:r=null},o,l){this.ctx=e;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=t;this.objs=i;this.canvasFactory=n;this.filterFactory=s;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=r||[];this.optionalContentConfig=a;this.cachedCanvases=new CachedCanvases(this.canvasFactory);this.cachedPatterns=new Map;this.annotationCanvasMap=o;this.viewportScale=1;this.outputScaleX=1;this.outputScaleY=1;this.pageColors=l;this._cachedScaleForStroking=[-1,0];this._cachedGetSinglePixelWidth=null;this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:i=!1,background:n=null}){const a=this.ctx.canvas.width,r=this.ctx.canvas.height,o=this.ctx.fillStyle;this.ctx.fillStyle=n||"#ffffff";this.ctx.fillRect(0,0,a,r);this.ctx.fillStyle=o;if(i){const e=this.cachedCanvases.getCanvas("transparent",a,r);this.compositeCtx=this.ctx;this.transparentCanvas=e.canvas;this.ctx=e.context;this.ctx.save();this.ctx.transform(...(0,s.getCurrentTransform)(this.compositeCtx))}this.ctx.save();resetCtxToDefault(this.ctx);if(e){this.ctx.transform(...e);this.outputScaleX=e[0];this.outputScaleY=e[0]}this.ctx.transform(...t.transform);this.viewportScale=t.scale;this.baseTransform=(0,s.getCurrentTransform)(this.ctx)}executeOperatorList(e,t,i,s){const a=e.argsArray,r=e.fnArray;let o=t||0;const l=a.length;if(l===o)return o;const d=l-o>10&&"function"==typeof i,h=d?Date.now()+15:0;let c=0;const u=this.commonObjs,p=this.objs;let g;for(;;){if(void 0!==s&&o===s.nextBreakPoint){s.breakIt(o,i);return o}g=r[o];if(g!==n.OPS.dependency)this[g].apply(this,a[o]);else for(const e of a[o]){const t=e.startsWith("g_")?u:p;if(!t.has(e)){t.get(e,i);return o}}o++;if(o===l)return o;if(d&&++c>10){if(Date.now()>h){i();return o}c=0}}}#dt(){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}}endDrawing(){this.#dt();this.cachedCanvases.clear();this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear();this.#ht()}#ht(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e;this.ctx.drawImage(this.ctx.canvas,0,0);this.ctx.filter=t}}}_scaleImage(e,t){const i=e.width,n=e.height;let s,a,r=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),l=i,d=n,h="prescale1";for(;r>2&&l>1||o>2&&d>1;){let t=l,i=d;if(r>2&&l>1){t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2);r/=l/t}if(o>2&&d>1){i=d>=16384?Math.floor(d/2)-1||1:Math.ceil(d)/2;o/=d/i}s=this.cachedCanvases.getCanvas(h,t,i);a=s.context;a.clearRect(0,0,t,i);a.drawImage(e,0,0,l,d,0,0,t,i);e=s.canvas;l=t;d=i;h="prescale1"===h?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:d}}_createMaskCanvas(e){const t=this.ctx,{width:i,height:r}=e,o=this.current.fillColor,l=this.current.patternFill,d=(0,s.getCurrentTransform)(t);let h,c,u,p;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;c=JSON.stringify(l?d:[d.slice(0,4),o]);h=this._cachedBitmapsMap.get(t);if(!h){h=new Map;this._cachedBitmapsMap.set(t,h)}const i=h.get(c);if(i&&!l){return{canvas:i,offsetX:Math.round(Math.min(d[0],d[2])+d[4]),offsetY:Math.round(Math.min(d[1],d[3])+d[5])}}u=i}if(!u){p=this.cachedCanvases.getCanvas("maskCanvas",i,r);putBinaryImageMask(p.context,e)}let g=n.Util.transform(d,[1/i,0,0,-1/r,0,0]);g=n.Util.transform(g,[1,0,0,1,0,-r]);const f=n.Util.applyTransform([0,0],g),m=n.Util.applyTransform([i,r],g),b=n.Util.normalizeRect([f[0],f[1],m[0],m[1]]),v=Math.round(b[2]-b[0])||1,_=Math.round(b[3]-b[1])||1,w=this.cachedCanvases.getCanvas("fillCanvas",v,_),y=w.context,S=Math.min(f[0],m[0]),A=Math.min(f[1],m[1]);y.translate(-S,-A);y.transform(...g);if(!u){u=this._scaleImage(p.canvas,(0,s.getCurrentTransformInverse)(y));u=u.img;h&&l&&h.set(c,u)}y.imageSmoothingEnabled=getImageSmoothingEnabled((0,s.getCurrentTransform)(y),e.interpolate);drawImageAtIntegerCoords(y,u,0,0,u.width,u.height,0,0,i,r);y.globalCompositeOperation="source-in";const E=n.Util.transform((0,s.getCurrentTransformInverse)(y),[1,0,0,1,-S,-A]);y.fillStyle=l?o.getPattern(t,this,E,a.PathType.FILL):o;y.fillRect(0,0,i,r);if(h&&!l){this.cachedCanvases.delete("fillCanvas");h.set(c,w.canvas)}return{canvas:w.canvas,offsetX:Math.round(S),offsetY:Math.round(A)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1);this.current.lineWidth=e;this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=d[e]}setLineJoin(e){this.ctx.lineJoin=h[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const i=this.ctx;if(void 0!==i.setLineDash){i.setLineDash(e);i.lineDashOffset=t}}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i[0],i[1]);break;case"CA":this.current.strokeAlpha=i;break;case"ca":this.current.fillAlpha=i;this.ctx.globalAlpha=i;break;case"BM":this.ctx.globalCompositeOperation=i;break;case"SMask":this.current.activeSMask=i?this.tempSMask:null;this.tempSMask=null;this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(i)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,n=this.cachedCanvases.getCanvas(i,e,t);this.suspendedCtx=this.ctx;this.ctx=n.context;const a=this.ctx;a.setTransform(...(0,s.getCurrentTransform)(this.suspendedCtx));copyCtxState(this.suspendedCtx,a);!function mirrorContextOperations(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save;e.__originalRestore=e.restore;e.__originalRotate=e.rotate;e.__originalScale=e.scale;e.__originalTranslate=e.translate;e.__originalTransform=e.transform;e.__originalSetTransform=e.setTransform;e.__originalResetTransform=e.resetTransform;e.__originalClip=e.clip;e.__originalMoveTo=e.moveTo;e.__originalLineTo=e.lineTo;e.__originalBezierCurveTo=e.bezierCurveTo;e.__originalRect=e.rect;e.__originalClosePath=e.closePath;e.__originalBeginPath=e.beginPath;e._removeMirroring=()=>{e.save=e.__originalSave;e.restore=e.__originalRestore;e.rotate=e.__originalRotate;e.scale=e.__originalScale;e.translate=e.__originalTranslate;e.transform=e.__originalTransform;e.setTransform=e.__originalSetTransform;e.resetTransform=e.__originalResetTransform;e.clip=e.__originalClip;e.moveTo=e.__originalMoveTo;e.lineTo=e.__originalLineTo;e.bezierCurveTo=e.__originalBezierCurveTo;e.rect=e.__originalRect;e.closePath=e.__originalClosePath;e.beginPath=e.__originalBeginPath;delete e._removeMirroring};e.save=function ctxSave(){t.save();this.__originalSave()};e.restore=function ctxRestore(){t.restore();this.__originalRestore()};e.translate=function ctxTranslate(e,i){t.translate(e,i);this.__originalTranslate(e,i)};e.scale=function ctxScale(e,i){t.scale(e,i);this.__originalScale(e,i)};e.transform=function ctxTransform(e,i,n,s,a,r){t.transform(e,i,n,s,a,r);this.__originalTransform(e,i,n,s,a,r)};e.setTransform=function ctxSetTransform(e,i,n,s,a,r){t.setTransform(e,i,n,s,a,r);this.__originalSetTransform(e,i,n,s,a,r)};e.resetTransform=function ctxResetTransform(){t.resetTransform();this.__originalResetTransform()};e.rotate=function ctxRotate(e){t.rotate(e);this.__originalRotate(e)};e.clip=function ctxRotate(e){t.clip(e);this.__originalClip(e)};e.moveTo=function(e,i){t.moveTo(e,i);this.__originalMoveTo(e,i)};e.lineTo=function(e,i){t.lineTo(e,i);this.__originalLineTo(e,i)};e.bezierCurveTo=function(e,i,n,s,a,r){t.bezierCurveTo(e,i,n,s,a,r);this.__originalBezierCurveTo(e,i,n,s,a,r)};e.rect=function(e,i,n,s){t.rect(e,i,n,s);this.__originalRect(e,i,n,s)};e.closePath=function(){t.closePath();this.__originalClosePath()};e.beginPath=function(){t.beginPath();this.__originalBeginPath()}}(a,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(e){if(!this.current.activeSMask)return;if(e){e[0]=Math.floor(e[0]);e[1]=Math.floor(e[1]);e[2]=Math.ceil(e[2]);e[3]=Math.ceil(e[3])}else e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask;composeSMask(this.suspendedCtx,t,this.ctx,e);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 e=this.current;this.stateStack.push(e);this.current=e.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[0]=-1;this._cachedGetSinglePixelWidth=null}}transform(e,t,i,n,s,a){this.ctx.transform(e,t,i,n,s,a);this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null}constructPath(e,t,i){const a=this.ctx,r=this.current;let o,l,d=r.x,h=r.y;const c=(0,s.getCurrentTransform)(a),u=0===c[0]&&0===c[3]||0===c[1]&&0===c[2],p=u?i.slice(0):null;for(let i=0,s=0,g=e.length;i<g;i++)switch(0|e[i]){case n.OPS.rectangle:d=t[s++];h=t[s++];const e=t[s++],i=t[s++],g=d+e,f=h+i;a.moveTo(d,h);if(0===e||0===i)a.lineTo(g,f);else{a.lineTo(g,h);a.lineTo(g,f);a.lineTo(d,f)}u||r.updateRectMinMax(c,[d,h,g,f]);a.closePath();break;case n.OPS.moveTo:d=t[s++];h=t[s++];a.moveTo(d,h);u||r.updatePathMinMax(c,d,h);break;case n.OPS.lineTo:d=t[s++];h=t[s++];a.lineTo(d,h);u||r.updatePathMinMax(c,d,h);break;case n.OPS.curveTo:o=d;l=h;d=t[s+4];h=t[s+5];a.bezierCurveTo(t[s],t[s+1],t[s+2],t[s+3],d,h);r.updateCurvePathMinMax(c,o,l,t[s],t[s+1],t[s+2],t[s+3],d,h,p);s+=6;break;case n.OPS.curveTo2:o=d;l=h;a.bezierCurveTo(d,h,t[s],t[s+1],t[s+2],t[s+3]);r.updateCurvePathMinMax(c,o,l,d,h,t[s],t[s+1],t[s+2],t[s+3],p);d=t[s+2];h=t[s+3];s+=4;break;case n.OPS.curveTo3:o=d;l=h;d=t[s+2];h=t[s+3];a.bezierCurveTo(t[s],t[s+1],d,h,d,h);r.updateCurvePathMinMax(c,o,l,t[s],t[s+1],d,h,d,h,p);s+=4;break;case n.OPS.closePath:a.closePath()}u&&r.updateScalingPathMinMax(c,p);r.setCurrentPoint(d,h)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,i=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha;if(this.contentVisible)if("object"==typeof i&&i?.getPattern){t.save();t.strokeStyle=i.getPattern(t,this,(0,s.getCurrentTransformInverse)(t),a.PathType.STROKE);this.rescaleAndStroke(!1);t.restore()}else this.rescaleAndStroke(!0);e&&this.consumePath(this.current.getClippedPathBoundingBox());t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath();this.stroke()}fill(e=!0){const t=this.ctx,i=this.current.fillColor;let n=!1;if(this.current.patternFill){t.save();t.fillStyle=i.getPattern(t,this,(0,s.getCurrentTransformInverse)(t),a.PathType.FILL);n=!0}const r=this.current.getClippedPathBoundingBox();if(this.contentVisible&&null!==r)if(this.pendingEOFill){t.fill("evenodd");this.pendingEOFill=!1}else t.fill();n&&t.restore();e&&this.consumePath(r)}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=c}eoClip(){this.pendingClip=u}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 e=this.pendingTextPaths,t=this.ctx;if(void 0!==e){t.save();t.beginPath();for(const i of e){t.setTransform(...i.transform);t.translate(i.x,i.y);i.addToPath(t,i.fontSize)}t.restore();t.clip();t.beginPath();delete this.pendingTextPaths}else t.beginPath()}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){const i=this.commonObjs.get(e),s=this.current;if(!i)throw new Error(`Can't find font for ${e}`);s.fontMatrix=i.fontMatrix||n.FONT_IDENTITY_MATRIX;0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||(0,n.warn)("Invalid font matrix for font "+e);if(t<0){t=-t;s.fontDirection=-1}else s.fontDirection=1;this.current.font=i;this.current.fontSize=t;if(i.isType3Font)return;const a=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${a}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const l=i.italic?"italic":"normal";let d=t;t<16?d=16:t>100&&(d=100);this.current.fontSizeScale=t/d;this.ctx.font=`${l} ${o} ${d}px ${r}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e;this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t);this.moveText(e,t)}setTextMatrix(e,t,i,n,s,a){this.current.textMatrix=[e,t,i,n,s,a];this.current.textMatrixScale=Math.hypot(e,t);this.current.x=this.current.lineX=0;this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,i,a){const r=this.ctx,o=this.current,l=o.font,d=o.textRenderingMode,h=o.fontSize/o.fontSizeScale,c=d&n.TextRenderingMode.FILL_STROKE_MASK,u=!!(d&n.TextRenderingMode.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile;let g;(l.disableFontFace||u||p)&&(g=l.getPathGenerator(this.commonObjs,e));if(l.disableFontFace||p){r.save();r.translate(t,i);r.beginPath();g(r,h);a&&r.setTransform(...a);c!==n.TextRenderingMode.FILL&&c!==n.TextRenderingMode.FILL_STROKE||r.fill();c!==n.TextRenderingMode.STROKE&&c!==n.TextRenderingMode.FILL_STROKE||r.stroke();r.restore()}else{c!==n.TextRenderingMode.FILL&&c!==n.TextRenderingMode.FILL_STROKE||r.fillText(e,t,i);c!==n.TextRenderingMode.STROKE&&c!==n.TextRenderingMode.FILL_STROKE||r.strokeText(e,t,i)}if(u){(this.pendingTextPaths||=[]).push({transform:(0,s.getCurrentTransform)(r),x:t,y:i,fontSize:h,addToPath:g})}}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1);e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let i=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){i=!0;break}return(0,n.shadow)(this,"isFontSubpixelAAEnabled",i)}showText(e){const t=this.current,i=t.font;if(i.isType3Font)return this.showType3Text(e);const r=t.fontSize;if(0===r)return;const o=this.ctx,l=t.fontSizeScale,d=t.charSpacing,h=t.wordSpacing,c=t.fontDirection,u=t.textHScale*c,p=e.length,g=i.vertical,f=g?1:-1,m=i.defaultVMetrics,b=r*t.fontMatrix[0],v=t.textRenderingMode===n.TextRenderingMode.FILL&&!i.disableFontFace&&!t.patternFill;o.save();o.transform(...t.textMatrix);o.translate(t.x,t.y+t.textRise);c>0?o.scale(u,-1):o.scale(u,1);let _;if(t.patternFill){o.save();const e=t.fillColor.getPattern(o,this,(0,s.getCurrentTransformInverse)(o),a.PathType.FILL);_=(0,s.getCurrentTransform)(o);o.restore();o.fillStyle=e}let w=t.lineWidth;const y=t.textMatrixScale;if(0===y||0===w){const e=t.textRenderingMode&n.TextRenderingMode.FILL_STROKE_MASK;e!==n.TextRenderingMode.STROKE&&e!==n.TextRenderingMode.FILL_STROKE||(w=this.getSinglePixelWidth())}else w/=y;if(1!==l){o.scale(l,l);w/=l}o.lineWidth=w;if(i.isInvalidPDFjsFont){const i=[];let n=0;for(const t of e){i.push(t.unicode);n+=t.width}o.fillText(i.join(""),0,0);t.x+=n*b*u;o.restore();this.compose();return}let S,A=0;for(S=0;S<p;++S){const t=e[S];if("number"==typeof t){A+=f*t*r/1e3;continue}let n=!1;const s=(t.isSpace?h:0)+d,a=t.fontChar,u=t.accent;let p,w,y=t.width;if(g){const e=t.vmetric||m,i=-(t.vmetric?e[1]:.5*y)*b,n=e[2]*b;y=e?-e[0]:y;p=i/l;w=(A+n)/l}else{p=A/l;w=0}if(i.remeasure&&y>0){const e=1e3*o.measureText(a).width/r*l;if(y<e&&this.isFontSubpixelAAEnabled){const t=y/e;n=!0;o.save();o.scale(t,1);p/=t}else y!==e&&(p+=(y-e)/2e3*r/l)}if(this.contentVisible&&(t.isInFont||i.missingFile))if(v&&!u)o.fillText(a,p,w);else{this.paintChar(a,p,w,_);if(u){const e=p+r*u.offset.x/l,t=w-r*u.offset.y/l;this.paintChar(u.fontChar,e,t,_)}}A+=g?y*b-s*c:y*b+s*c;n&&o.restore()}g?t.y-=A:t.x+=A*u;o.restore();this.compose()}showType3Text(e){const t=this.ctx,i=this.current,s=i.font,a=i.fontSize,r=i.fontDirection,o=s.vertical?1:-1,l=i.charSpacing,d=i.wordSpacing,h=i.textHScale*r,c=i.fontMatrix||n.FONT_IDENTITY_MATRIX,u=e.length;let p,g,f,m;if(!(i.textRenderingMode===n.TextRenderingMode.INVISIBLE)&&0!==a){this._cachedScaleForStroking[0]=-1;this._cachedGetSinglePixelWidth=null;t.save();t.transform(...i.textMatrix);t.translate(i.x,i.y);t.scale(h,r);for(p=0;p<u;++p){g=e[p];if("number"==typeof g){m=o*g*a/1e3;this.ctx.translate(m,0);i.x+=m*h;continue}const r=(g.isSpace?d:0)+l,u=s.charProcOperatorList[g.operatorListId];if(!u){(0,n.warn)(`Type3 character "${g.operatorListId}" is not available.`);continue}if(this.contentVisible){this.processingType3=g;this.save();t.scale(a,a);t.transform(...c);this.executeOperatorList(u);this.restore()}f=n.Util.applyTransform([g.width,0],c)[0]*a+r;t.translate(f,0);i.x+=f*h}t.restore();this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,n,s,a){this.ctx.rect(i,n,s-i,a-n);this.ctx.clip();this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){const i=e[1],n=this.baseTransform||(0,s.getCurrentTransform)(this.ctx),r={createCanvasGraphics:e=>new CanvasGraphics(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new a.TilingPattern(e,i,this.ctx,r,n)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments);this.current.patternFill=!0}setStrokeRGBColor(e,t,i){const s=n.Util.makeHexColor(e,t,i);this.ctx.strokeStyle=s;this.current.strokeColor=s}setFillRGBColor(e,t,i){const s=n.Util.makeHexColor(e,t,i);this.ctx.fillStyle=s;this.current.fillColor=s;this.current.patternFill=!1}_getPattern(e,t=null){let i;if(this.cachedPatterns.has(e))i=this.cachedPatterns.get(e);else{i=(0,a.getShadingPattern)(this.getObject(e));this.cachedPatterns.set(e,i)}t&&(i.matrix=t);return i}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const i=this._getPattern(e);t.fillStyle=i.getPattern(t,this,(0,s.getCurrentTransformInverse)(t),a.PathType.SHADING);const r=(0,s.getCurrentTransformInverse)(t);if(r){const{width:e,height:i}=t.canvas,[s,a,o,l]=n.Util.getAxialAlignedBoundingBox([0,0,e,i],r);this.ctx.fillRect(s,a,o-s,l-a)}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(e,t){if(this.contentVisible){this.save();this.baseTransformStack.push(this.baseTransform);Array.isArray(e)&&6===e.length&&this.transform(...e);this.baseTransform=(0,s.getCurrentTransform)(this.ctx);if(t){const e=t[2]-t[0],i=t[3]-t[1];this.ctx.rect(t[0],t[1],e,i);this.current.updateRectMinMax((0,s.getCurrentTransform)(this.ctx),t);this.clip();this.endPath()}}}paintFormXObjectEnd(){if(this.contentVisible){this.restore();this.baseTransform=this.baseTransformStack.pop()}}beginGroup(e){if(!this.contentVisible)return;this.save();if(this.inSMaskMode){this.endSMaskMode();this.current.activeSMask=null}const t=this.ctx;e.isolated||(0,n.info)("TODO: Support non-isolated groups.");e.knockout&&(0,n.warn)("Knockout groups not supported.");const i=(0,s.getCurrentTransform)(t);e.matrix&&t.transform(...e.matrix);if(!e.bbox)throw new Error("Bounding box is required.");let a=n.Util.getAxialAlignedBoundingBox(e.bbox,(0,s.getCurrentTransform)(t));const r=[0,0,t.canvas.width,t.canvas.height];a=n.Util.intersect(a,r)||[0,0,0,0];const l=Math.floor(a[0]),d=Math.floor(a[1]);let h=Math.max(Math.ceil(a[2])-l,1),c=Math.max(Math.ceil(a[3])-d,1),u=1,p=1;if(h>o){u=h/o;h=o}if(c>o){p=c/o;c=o}this.current.startNewPathAndClipBox([0,0,h,c]);let g="groupAt"+this.groupLevel;e.smask&&(g+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(g,h,c),m=f.context;m.scale(1/u,1/p);m.translate(-l,-d);m.transform(...i);if(e.smask)this.smaskStack.push({canvas:f.canvas,context:m,offsetX:l,offsetY:d,scaleX:u,scaleY:p,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null});else{t.setTransform(1,0,0,1,0,0);t.translate(l,d);t.scale(u,p);t.save()}copyCtxState(t,m);this.ctx=m;this.setGState([["BM","source-over"],["ca",1],["CA",1]]);this.groupStack.push(t);this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,i=this.groupStack.pop();this.ctx=i;this.ctx.imageSmoothingEnabled=!1;if(e.smask){this.tempSMask=this.smaskStack.pop();this.restore()}else{this.ctx.restore();const e=(0,s.getCurrentTransform)(this.ctx);this.restore();this.ctx.save();this.ctx.setTransform(...e);const i=n.Util.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0);this.ctx.restore();this.compose(i)}}beginAnnotation(e,t,i,a,r){this.#dt();resetCtxToDefault(this.ctx);this.ctx.save();this.save();this.baseTransform&&this.ctx.setTransform(...this.baseTransform);if(Array.isArray(t)&&4===t.length){const a=t[2]-t[0],o=t[3]-t[1];if(r&&this.annotationCanvasMap){(i=i.slice())[4]-=t[0];i[5]-=t[1];(t=t.slice())[0]=t[1]=0;t[2]=a;t[3]=o;const[r,l]=n.Util.singularValueDecompose2dScale((0,s.getCurrentTransform)(this.ctx)),{viewportScale:d}=this,h=Math.ceil(a*this.outputScaleX*d),c=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(h,c);const{canvas:u,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,u);this.annotationCanvas.savedCtx=this.ctx;this.ctx=p;this.ctx.save();this.ctx.setTransform(r,0,0,-l,0,o*l);resetCtxToDefault(this.ctx)}else{resetCtxToDefault(this.ctx);this.ctx.rect(t[0],t[1],a,o);this.ctx.clip();this.endPath()}}this.current=new CanvasExtraState(this.ctx.canvas.width,this.ctx.canvas.height);this.transform(...i);this.transform(...a)}endAnnotation(){if(this.annotationCanvas){this.ctx.restore();this.#ht();this.ctx=this.annotationCanvas.savedCtx;delete this.annotationCanvas.savedCtx;delete this.annotationCanvas}}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;(e=this.getObject(e.data,e)).count=t;const i=this.ctx,n=this.processingType3;if(n){void 0===n.compiled&&(n.compiled=function compileType3Glyph(e){const{width:t,height:i}=e;if(t>1e3||i>1e3)return null;const n=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),s=t+1;let a,r,o,l=new Uint8Array(s*(i+1));const d=t+7&-8;let h=new Uint8Array(d*i),c=0;for(const t of e.data){let e=128;for(;e>0;){h[c++]=t&e?0:255;e>>=1}}let u=0;c=0;if(0!==h[c]){l[0]=1;++u}for(r=1;r<t;r++){if(h[c]!==h[c+1]){l[r]=h[c]?2:1;++u}c++}if(0!==h[c]){l[r]=2;++u}for(a=1;a<i;a++){c=a*d;o=a*s;if(h[c-d]!==h[c]){l[o]=h[c]?1:8;++u}let e=(h[c]?4:0)+(h[c-d]?8:0);for(r=1;r<t;r++){e=(e>>2)+(h[c+1]?4:0)+(h[c-d+1]?8:0);if(n[e]){l[o+r]=n[e];++u}c++}if(h[c-d]!==h[c]){l[o+r]=h[c]?2:4;++u}if(u>1e3)return null}c=d*(i-1);o=a*s;if(0!==h[c]){l[o]=8;++u}for(r=1;r<t;r++){if(h[c]!==h[c+1]){l[o+r]=h[c]?4:8;++u}c++}if(0!==h[c]){l[o+r]=4;++u}if(u>1e3)return null;const p=new Int32Array([0,s,-1,0,-s,0,0,0,1]),g=new Path2D;for(a=0;u&&a<=i;a++){let e=a*s;const i=e+t;for(;e<i&&!l[e];)e++;if(e===i)continue;g.moveTo(e%s,a);const n=e;let r=l[e];do{const t=p[r];do{e+=t}while(!l[e]);const i=l[e];if(5!==i&&10!==i){r=i;l[e]=0}else{r=i&51*r>>4;l[e]&=r>>2|r<<2}g.lineTo(e%s,e/s|0);l[e]||--u}while(n!==e);--a}h=null;l=null;return function(e){e.save();e.scale(1/t,-1/i);e.translate(0,-i);e.fill(g);e.beginPath();e.restore()}}(e));if(n.compiled){n.compiled(i);return}}const s=this._createMaskCanvas(e),a=s.canvas;i.save();i.setTransform(1,0,0,1,0,0);i.drawImage(a,s.offsetX,s.offsetY);i.restore();this.compose()}paintImageMaskXObjectRepeat(e,t,i=0,a=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const l=this.ctx;l.save();const d=(0,s.getCurrentTransform)(l);l.transform(t,i,a,r,0,0);const h=this._createMaskCanvas(e);l.setTransform(1,0,0,1,h.offsetX-d[4],h.offsetY-d[5]);for(let e=0,s=o.length;e<s;e+=2){const s=n.Util.transform(d,[t,i,a,r,o[e],o[e+1]]),[c,u]=n.Util.applyTransform([0,0],s);l.drawImage(h.canvas,c,u)}l.restore();this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const t=this.ctx,i=this.current.fillColor,n=this.current.patternFill;for(const r of e){const{data:e,width:o,height:l,transform:d}=r,h=this.cachedCanvases.getCanvas("maskCanvas",o,l),c=h.context;c.save();putBinaryImageMask(c,this.getObject(e,r));c.globalCompositeOperation="source-in";c.fillStyle=n?i.getPattern(c,this,(0,s.getCurrentTransformInverse)(t),a.PathType.FILL):i;c.fillRect(0,0,o,l);c.restore();t.save();t.transform(...d);t.scale(1,-1);drawImageAtIntegerCoords(t,h.canvas,0,0,o,l,0,-1,1,1);t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,n.warn)("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,i,s){if(!this.contentVisible)return;const a=this.getObject(e);if(!a){(0,n.warn)("Dependent image isn't ready yet");return}const r=a.width,o=a.height,l=[];for(let e=0,n=s.length;e<n;e+=2)l.push({transform:[t,0,0,i,s[e],s[e+1]],x:0,y:0,w:r,h:o});this.paintInlineImageXObjectGroup(a,l)}applyTransferMapsToCanvas(e){if("none"!==this.current.transferMaps){e.filter=this.current.transferMaps;e.drawImage(e.canvas,0,0);e.filter="none"}return e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;const{bitmap:t,width:i,height:n}=e,s=this.cachedCanvases.getCanvas("inlineImage",i,n),a=s.context;a.filter=this.current.transferMaps;a.drawImage(t,0,0);a.filter="none";return s.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,i=e.height,a=this.ctx;this.save();if(!n.isNodeJS){const{filter:e}=a;"none"!==e&&""!==e&&(a.filter="none")}a.scale(1/t,-1/i);let r;if(e.bitmap)r=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)r=e;else{const n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;putBinaryImageData(n,e);r=this.applyTransferMapsToCanvas(n)}const o=this._scaleImage(r,(0,s.getCurrentTransformInverse)(a));a.imageSmoothingEnabled=getImageSmoothingEnabled((0,s.getCurrentTransform)(a),e.interpolate);drawImageAtIntegerCoords(a,o.img,0,0,o.paintWidth,o.paintHeight,0,-i,t,i);this.compose();this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;const i=this.ctx;let n;if(e.bitmap)n=e.bitmap;else{const t=e.width,i=e.height,s=this.cachedCanvases.getCanvas("inlineImage",t,i).context;putBinaryImageData(s,e);n=this.applyTransferMapsToCanvas(s)}for(const e of t){i.save();i.transform(...e.transform);i.scale(1,-1);drawImageAtIntegerCoords(i,n,e.x,e.y,e.w,e.h,0,-1,1,1);i.restore()}this.compose()}paintSolidColorImageMask(){if(this.contentVisible){this.ctx.fillRect(0,0,1,1);this.compose()}}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0});this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop();this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath();this.pendingClip||this.compose(e);const i=this.ctx;if(this.pendingClip){t||(this.pendingClip===u?i.clip("evenodd"):i.clip());this.pendingClip=null}this.current.startNewPathAndClipBox(this.current.clipBox);i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=(0,s.getCurrentTransform)(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),i=Math.hypot(e[0],e[2]),n=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:i,c:n,d:s}=this.ctx.getTransform();let a,r;if(0===i&&0===n){const i=Math.abs(t),n=Math.abs(s);if(i===n)if(0===e)a=r=1/i;else{const t=i*e;a=r=t<1?1/t:1}else if(0===e){a=1/i;r=1/n}else{const t=i*e,s=n*e;a=t<1?1/t:1;r=s<1?1/s:1}}else{const o=Math.abs(t*s-i*n),l=Math.hypot(t,i),d=Math.hypot(n,s);if(0===e){a=d/o;r=l/o}else{const t=e*o;a=d>t?d/t:1;r=l>t?l/t:1}}this._cachedScaleForStroking[0]=a;this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:i}=this.current,[n,s]=this.getScaleForStroking();t.lineWidth=i||1;if(1===n&&1===s){t.stroke();return}const a=t.getLineDash();e&&t.save();t.scale(n,s);if(a.length>0){const e=Math.max(n,s);t.setLineDash(a.map((t=>t/e)));t.lineDashOffset/=e}t.stroke();e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}t.CanvasGraphics=CanvasGraphics;for(const e in n.OPS)void 0!==CanvasGraphics.prototype[e]&&(CanvasGraphics.prototype[n.OPS[e]]=CanvasGraphics.prototype[e])},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TilingPattern=t.PathType=void 0;t.getShadingPattern=function getShadingPattern(e){switch(e[0]){case"RadialAxial":return new RadialAxialShadingPattern(e);case"Mesh":return new MeshShadingPattern(e);case"Dummy":return new DummyShadingPattern}throw new Error(`Unknown IR type: ${e[0]}`)};var n=i(1),s=i(6);const a={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};t.PathType=a;function applyBoundingBox(e,t){if(!t)return;const i=t[2]-t[0],n=t[3]-t[1],s=new Path2D;s.rect(t[0],t[1],i,n);e.clip(s)}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(e){super();this._type=e[1];this._bbox=e[2];this._colorStops=e[3];this._p0=e[4];this._p1=e[5];this._r0=e[6];this._r1=e[7];this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,i,r){let o;if(r===a.STROKE||r===a.FILL){const a=t.current.getClippedPathBoundingBox(r,(0,s.getCurrentTransform)(e))||[0,0,0,0],l=Math.ceil(a[2]-a[0])||1,d=Math.ceil(a[3]-a[1])||1,h=t.cachedCanvases.getCanvas("pattern",l,d,!0),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height);c.beginPath();c.rect(0,0,c.canvas.width,c.canvas.height);c.translate(-a[0],-a[1]);i=n.Util.transform(i,[1,0,0,1,a[0],a[1]]);c.transform(...t.baseTransform);this.matrix&&c.transform(...this.matrix);applyBoundingBox(c,this._bbox);c.fillStyle=this._createGradient(c);c.fill();o=e.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(i);o.setTransform(u)}else{applyBoundingBox(e,this._bbox);o=this._createGradient(e)}return o}}function drawTriangle(e,t,i,n,s,a,r,o){const l=t.coords,d=t.colors,h=e.data,c=4*e.width;let u;if(l[i+1]>l[n+1]){u=i;i=n;n=u;u=a;a=r;r=u}if(l[n+1]>l[s+1]){u=n;n=s;s=u;u=r;r=o;o=u}if(l[i+1]>l[n+1]){u=i;i=n;n=u;u=a;a=r;r=u}const p=(l[i]+t.offsetX)*t.scaleX,g=(l[i+1]+t.offsetY)*t.scaleY,f=(l[n]+t.offsetX)*t.scaleX,m=(l[n+1]+t.offsetY)*t.scaleY,b=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY;if(g>=v)return;const _=d[a],w=d[a+1],y=d[a+2],S=d[r],A=d[r+1],E=d[r+2],P=d[o],C=d[o+1],x=d[o+2],T=Math.round(g),M=Math.round(v);let I,k,D,L,F,R,O,N;for(let e=T;e<=M;e++){if(e<m){const t=e<g?0:(g-e)/(g-m);I=p-(p-f)*t;k=_-(_-S)*t;D=w-(w-A)*t;L=y-(y-E)*t}else{let t;t=e>v?1:m===v?0:(m-e)/(m-v);I=f-(f-b)*t;k=S-(S-P)*t;D=A-(A-C)*t;L=E-(E-x)*t}let t;t=e<g?0:e>v?1:(g-e)/(g-v);F=p-(p-b)*t;R=_-(_-P)*t;O=w-(w-C)*t;N=y-(y-x)*t;const i=Math.round(Math.min(I,F)),n=Math.round(Math.max(I,F));let s=c*e+4*i;for(let e=i;e<=n;e++){t=(I-e)/(I-F);t<0?t=0:t>1&&(t=1);h[s++]=k-(k-R)*t|0;h[s++]=D-(D-O)*t|0;h[s++]=L-(L-N)*t|0;h[s++]=255}}}function drawFigure(e,t,i){const n=t.coords,s=t.colors;let a,r;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(n.length/o)-1,d=o-1;for(a=0;a<l;a++){let t=a*o;for(let a=0;a<d;a++,t++){drawTriangle(e,i,n[t],n[t+1],n[t+o],s[t],s[t+1],s[t+o]);drawTriangle(e,i,n[t+o+1],n[t+1],n[t+o],s[t+o+1],s[t+1],s[t+o])}}break;case"triangles":for(a=0,r=n.length;a<r;a+=3)drawTriangle(e,i,n[a],n[a+1],n[a+2],s[a],s[a+1],s[a+2]);break;default:throw new Error("illegal figure")}}class MeshShadingPattern extends BaseShadingPattern{constructor(e){super();this._coords=e[2];this._colors=e[3];this._figures=e[4];this._bounds=e[5];this._bbox=e[7];this._background=e[8];this.matrix=null}_createMeshCanvas(e,t,i){const n=Math.floor(this._bounds[0]),s=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-n,r=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(a*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*e[1]*1.1)),3e3),d=a/o,h=r/l,c={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-s,scaleX:1/d,scaleY:1/h},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p,!1),f=g.context,m=f.createImageData(o,l);if(t){const e=m.data;for(let i=0,n=e.length;i<n;i+=4){e[i]=t[0];e[i+1]=t[1];e[i+2]=t[2];e[i+3]=255}}for(const e of this._figures)drawFigure(m,e,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:n-2*d,offsetY:s-2*h,scaleX:d,scaleY:h}}getPattern(e,t,i,r){applyBoundingBox(e,this._bbox);let o;if(r===a.SHADING)o=n.Util.singularValueDecompose2dScale((0,s.getCurrentTransform)(e));else{o=n.Util.singularValueDecompose2dScale(t.baseTransform);if(this.matrix){const e=n.Util.singularValueDecompose2dScale(this.matrix);o=[o[0]*e[0],o[1]*e[1]]}}const l=this._createMeshCanvas(o,r===a.SHADING?null:this._background,t.cachedCanvases);if(r!==a.SHADING){e.setTransform(...t.baseTransform);this.matrix&&e.transform(...this.matrix)}e.translate(l.offsetX,l.offsetY);e.scale(l.scaleX,l.scaleY);return e.createPattern(l.canvas,"no-repeat")}}class DummyShadingPattern extends BaseShadingPattern{getPattern(){return"hotpink"}}const r=1,o=2;class TilingPattern{static MAX_PATTERN_SIZE=3e3;constructor(e,t,i,n,s){this.operatorList=e[2];this.matrix=e[3]||[1,0,0,1,0,0];this.bbox=e[4];this.xstep=e[5];this.ystep=e[6];this.paintType=e[7];this.tilingType=e[8];this.color=t;this.ctx=i;this.canvasGraphicsFactory=n;this.baseTransform=s}createPatternCanvas(e){const t=this.operatorList,i=this.bbox,a=this.xstep,r=this.ystep,o=this.paintType,l=this.tilingType,d=this.color,h=this.canvasGraphicsFactory;(0,n.info)("TilingType: "+l);const c=i[0],u=i[1],p=i[2],g=i[3],f=n.Util.singularValueDecompose2dScale(this.matrix),m=n.Util.singularValueDecompose2dScale(this.baseTransform),b=[f[0]*m[0],f[1]*m[1]],v=this.getSizeAndScale(a,this.ctx.canvas.width,b[0]),_=this.getSizeAndScale(r,this.ctx.canvas.height,b[1]),w=e.cachedCanvases.getCanvas("pattern",v.size,_.size,!0),y=w.context,S=h.createCanvasGraphics(y);S.groupLevel=e.groupLevel;this.setFillAndStrokeStyleToContext(S,o,d);let A=c,E=u,P=p,C=g;if(c<0){A=0;P+=Math.abs(c)}if(u<0){E=0;C+=Math.abs(u)}y.translate(-v.scale*A,-_.scale*E);S.transform(v.scale,0,0,_.scale,0,0);y.save();this.clipBbox(S,A,E,P,C);S.baseTransform=(0,s.getCurrentTransform)(S.ctx);S.executeOperatorList(t);S.endDrawing();return{canvas:w.canvas,scaleX:v.scale,scaleY:_.scale,offsetX:A,offsetY:E}}getSizeAndScale(e,t,i){e=Math.abs(e);const n=Math.max(TilingPattern.MAX_PATTERN_SIZE,t);let s=Math.ceil(e*i);s>=n?s=n:i=s/e;return{scale:i,size:s}}clipBbox(e,t,i,n,a){const r=n-t,o=a-i;e.ctx.rect(t,i,r,o);e.current.updateRectMinMax((0,s.getCurrentTransform)(e.ctx),[t,i,n,a]);e.clip();e.endPath()}setFillAndStrokeStyleToContext(e,t,i){const s=e.ctx,a=e.current;switch(t){case r:const e=this.ctx;s.fillStyle=e.fillStyle;s.strokeStyle=e.strokeStyle;a.fillColor=e.fillStyle;a.strokeColor=e.strokeStyle;break;case o:const l=n.Util.makeHexColor(i[0],i[1],i[2]);s.fillStyle=l;s.strokeStyle=l;a.fillColor=l;a.strokeColor=l;break;default:throw new n.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,i,s){let r=i;if(s!==a.SHADING){r=n.Util.transform(r,t.baseTransform);this.matrix&&(r=n.Util.transform(r,this.matrix))}const o=this.createPatternCanvas(t);let l=new DOMMatrix(r);l=l.translate(o.offsetX,o.offsetY);l=l.scale(1/o.scaleX,1/o.scaleY);const d=e.createPattern(o.canvas,"repeat");d.setTransform(l);return d}}t.TilingPattern=TilingPattern},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.convertBlackAndWhiteToRGBA=convertBlackAndWhiteToRGBA;t.convertToRGBA=function convertToRGBA(e){switch(e.kind){case n.ImageKind.GRAYSCALE_1BPP:return convertBlackAndWhiteToRGBA(e);case n.ImageKind.RGB_24BPP:return function convertRGBToRGBA({src:e,srcPos:t=0,dest:i,destPos:s=0,width:a,height:r}){let o=0;const l=e.length>>2,d=new Uint32Array(e.buffer,t,l);if(n.FeatureTest.isLittleEndian){for(;o<l-2;o+=3,s+=4){const e=d[o],t=d[o+1],n=d[o+2];i[s]=4278190080|e;i[s+1]=e>>>24|t<<8|4278190080;i[s+2]=t>>>16|n<<16|4278190080;i[s+3]=n>>>8|4278190080}for(let t=4*o,n=e.length;t<n;t+=3)i[s++]=e[t]|e[t+1]<<8|e[t+2]<<16|4278190080}else{for(;o<l-2;o+=3,s+=4){const e=d[o],t=d[o+1],n=d[o+2];i[s]=255|e;i[s+1]=e<<24|t>>>8|255;i[s+2]=t<<16|n>>>16|255;i[s+3]=n<<8|255}for(let t=4*o,n=e.length;t<n;t+=3)i[s++]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|255}return{srcPos:t,destPos:s}}(e)}return null};t.grayToRGBA=function grayToRGBA(e,t){if(n.FeatureTest.isLittleEndian)for(let i=0,n=e.length;i<n;i++)t[i]=65793*e[i]|4278190080;else for(let i=0,n=e.length;i<n;i++)t[i]=16843008*e[i]|255};var n=i(1);function convertBlackAndWhiteToRGBA({src:e,srcPos:t=0,dest:i,width:s,height:a,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const l=n.FeatureTest.isLittleEndian?4278190080:255,[d,h]=o?[r,l]:[l,r],c=s>>3,u=7&s,p=e.length;i=new Uint32Array(i.buffer);let g=0;for(let n=0;n<a;n++){for(const n=t+c;t<n;t++){const n=t<p?e[t]:255;i[g++]=128&n?h:d;i[g++]=64&n?h:d;i[g++]=32&n?h:d;i[g++]=16&n?h:d;i[g++]=8&n?h:d;i[g++]=4&n?h:d;i[g++]=2&n?h:d;i[g++]=1&n?h:d}if(0===u)continue;const n=t<p?e[t++]:255;for(let e=0;e<u;e++)i[g++]=n&1<<7-e?h:d}return{srcPos:t,destPos:g}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GlobalWorkerOptions=void 0;const i=Object.create(null);t.GlobalWorkerOptions=i;i.workerPort=null;i.workerSrc=""},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.MessageHandler=void 0;var n=i(1);const s=1,a=2,r=1,o=2,l=3,d=4,h=5,c=6,u=7,p=8;function wrapReason(e){e instanceof Error||"object"==typeof e&&null!==e||(0,n.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.');switch(e.name){case"AbortException":return new n.AbortException(e.message);case"MissingPDFException":return new n.MissingPDFException(e.message);case"PasswordException":return new n.PasswordException(e.message,e.code);case"UnexpectedResponseException":return new n.UnexpectedResponseException(e.message,e.status);case"UnknownErrorException":return new n.UnknownErrorException(e.message,e.details);default:return new n.UnknownErrorException(e.message,e.toString())}}t.MessageHandler=class MessageHandler{constructor(e,t,i){this.sourceName=e;this.targetName=t;this.comObj=i;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=e=>{const t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){this.#ct(t);return}if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);delete this.callbackCapabilities[e];if(t.callback===s)i.resolve(t.data);else{if(t.callback!==a)throw new Error("Unexpected callback case");i.reject(wrapReason(t.reason))}return}const n=this.actionHandler[t.action];if(!n)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const e=this.sourceName,r=t.sourceName;new Promise((function(e){e(n(t.data))})).then((function(n){i.postMessage({sourceName:e,targetName:r,callback:s,callbackId:t.callbackId,data:n})}),(function(n){i.postMessage({sourceName:e,targetName:r,callback:a,callbackId:t.callbackId,reason:wrapReason(n)})}))}else t.streamId?this.#ut(t):n(t.data)};i.addEventListener("message",this._onComObjOnMessage)}on(e,t){const i=this.actionHandler;if(i[e])throw new Error(`There is already an actionName called "${e}"`);i[e]=t}send(e,t,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},i)}sendWithPromise(e,t,i){const s=this.callbackId++,a=new n.PromiseCapability;this.callbackCapabilities[s]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:t},i)}catch(e){a.reject(e)}return a.promise}sendWithStream(e,t,i,s){const a=this.streamId++,o=this.sourceName,l=this.targetName,d=this.comObj;return new ReadableStream({start:i=>{const r=new n.PromiseCapability;this.streamControllers[a]={controller:i,startCall:r,pullCall:null,cancelCall:null,isClosed:!1};d.postMessage({sourceName:o,targetName:l,action:e,streamId:a,data:t,desiredSize:i.desiredSize},s);return r.promise},pull:e=>{const t=new n.PromiseCapability;this.streamControllers[a].pullCall=t;d.postMessage({sourceName:o,targetName:l,stream:c,streamId:a,desiredSize:e.desiredSize});return t.promise},cancel:e=>{(0,n.assert)(e instanceof Error,"cancel must have a valid reason");const t=new n.PromiseCapability;this.streamControllers[a].cancelCall=t;this.streamControllers[a].isClosed=!0;d.postMessage({sourceName:o,targetName:l,stream:r,streamId:a,reason:wrapReason(e)});return t.promise}},i)}#ut(e){const t=e.streamId,i=this.sourceName,s=e.sourceName,a=this.comObj,r=this,o=this.actionHandler[e.action],c={enqueue(e,r=1,o){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=r;if(l>0&&this.desiredSize<=0){this.sinkCapability=new n.PromiseCapability;this.ready=this.sinkCapability.promise}a.postMessage({sourceName:i,targetName:s,stream:d,streamId:t,chunk:e},o)},close(){if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:i,targetName:s,stream:l,streamId:t});delete r.streamSinks[t]}},error(e){(0,n.assert)(e instanceof Error,"error must have a valid reason");if(!this.isCancelled){this.isCancelled=!0;a.postMessage({sourceName:i,targetName:s,stream:h,streamId:t,reason:wrapReason(e)})}},sinkCapability:new n.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};c.sinkCapability.resolve();c.ready=c.sinkCapability.promise;this.streamSinks[t]=c;new Promise((function(t){t(o(e.data,c))})).then((function(){a.postMessage({sourceName:i,targetName:s,stream:p,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:i,targetName:s,stream:p,streamId:t,reason:wrapReason(e)})}))}#ct(e){const t=e.streamId,i=this.sourceName,s=e.sourceName,a=this.comObj,g=this.streamControllers[t],f=this.streamSinks[t];switch(e.stream){case p:e.success?g.startCall.resolve():g.startCall.reject(wrapReason(e.reason));break;case u:e.success?g.pullCall.resolve():g.pullCall.reject(wrapReason(e.reason));break;case c:if(!f){a.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,success:!0});break}f.desiredSize<=0&&e.desiredSize>0&&f.sinkCapability.resolve();f.desiredSize=e.desiredSize;new Promise((function(e){e(f.onPull?.())})).then((function(){a.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,reason:wrapReason(e)})}));break;case d:(0,n.assert)(g,"enqueue should have stream controller");if(g.isClosed)break;g.controller.enqueue(e.chunk);break;case l:(0,n.assert)(g,"close should have stream controller");if(g.isClosed)break;g.isClosed=!0;g.controller.close();this.#pt(g,t);break;case h:(0,n.assert)(g,"error should have stream controller");g.controller.error(wrapReason(e.reason));this.#pt(g,t);break;case o:e.success?g.cancelCall.resolve():g.cancelCall.reject(wrapReason(e.reason));this.#pt(g,t);break;case r:if(!f)break;new Promise((function(t){t(f.onCancel?.(wrapReason(e.reason)))})).then((function(){a.postMessage({sourceName:i,targetName:s,stream:o,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:i,targetName:s,stream:o,streamId:t,reason:wrapReason(e)})}));f.sinkCapability.reject(wrapReason(e.reason));f.isCancelled=!0;delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async#pt(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]);delete this.streamControllers[t]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.Metadata=void 0;var n=i(1);t.Metadata=class Metadata{#gt;#ft;constructor({parsedData:e,rawData:t}){this.#gt=e;this.#ft=t}getRaw(){return this.#ft}get(e){return this.#gt.get(e)??null}getAll(){return(0,n.objectFromMap)(this.#gt)}has(e){return this.#gt.has(e)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.OptionalContentConfig=void 0;var n=i(1),s=i(8);const a=Symbol("INTERNAL");class OptionalContentGroup{#mt=!0;constructor(e,t){this.name=e;this.intent=t}get visible(){return this.#mt}_setVisible(e,t){e!==a&&(0,n.unreachable)("Internal method `_setVisible` called.");this.#mt=t}}t.OptionalContentConfig=class OptionalContentConfig{#bt=null;#vt=new Map;#_t=null;#wt=null;constructor(e){this.name=null;this.creator=null;if(null!==e){this.name=e.name;this.creator=e.creator;this.#wt=e.order;for(const t of e.groups)this.#vt.set(t.id,new OptionalContentGroup(t.name,t.intent));if("OFF"===e.baseState)for(const e of this.#vt.values())e._setVisible(a,!1);for(const t of e.on)this.#vt.get(t)._setVisible(a,!0);for(const t of e.off)this.#vt.get(t)._setVisible(a,!1);this.#_t=this.getHash()}}#yt(e){const t=e.length;if(t<2)return!0;const i=e[0];for(let s=1;s<t;s++){const t=e[s];let a;if(Array.isArray(t))a=this.#yt(t);else{if(!this.#vt.has(t)){(0,n.warn)(`Optional content group not found: ${t}`);return!0}a=this.#vt.get(t).visible}switch(i){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===i}isVisible(e){if(0===this.#vt.size)return!0;if(!e){(0,n.warn)("Optional content group not defined.");return!0}if("OCG"===e.type){if(!this.#vt.has(e.id)){(0,n.warn)(`Optional content group not found: ${e.id}`);return!0}return this.#vt.get(e.id).visible}if("OCMD"===e.type){if(e.expression)return this.#yt(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#vt.has(t)){(0,n.warn)(`Optional content group not found: ${t}`);return!0}if(this.#vt.get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!this.#vt.has(t)){(0,n.warn)(`Optional content group not found: ${t}`);return!0}if(!this.#vt.get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!this.#vt.has(t)){(0,n.warn)(`Optional content group not found: ${t}`);return!0}if(!this.#vt.get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!this.#vt.has(t)){(0,n.warn)(`Optional content group not found: ${t}`);return!0}if(this.#vt.get(t).visible)return!1}return!0}(0,n.warn)(`Unknown optional content policy ${e.policy}.`);return!0}(0,n.warn)(`Unknown group type ${e.type}.`);return!0}setVisibility(e,t=!0){if(this.#vt.has(e)){this.#vt.get(e)._setVisible(a,!!t);this.#bt=null}else(0,n.warn)(`Optional content group not found: ${e}`)}get hasInitialVisibility(){return null===this.#_t||this.getHash()===this.#_t}getOrder(){return this.#vt.size?this.#wt?this.#wt.slice():[...this.#vt.keys()]:null}getGroups(){return this.#vt.size>0?(0,n.objectFromMap)(this.#vt):null}getGroup(e){return this.#vt.get(e)||null}getHash(){if(null!==this.#bt)return this.#bt;const e=new s.MurmurHash3_64;for(const[t,i]of this.#vt)e.update(`${t}:${i.visible}`);return this.#bt=e.hexdigest()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFDataTransportStream=void 0;var n=i(1),s=i(6);t.PDFDataTransportStream=class PDFDataTransportStream{constructor({length:e,initialData:t,progressiveDone:i=!1,contentDispositionFilename:s=null,disableRange:a=!1,disableStream:r=!1},o){(0,n.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');this._queuedChunks=[];this._progressiveDone=i;this._contentDispositionFilename=s;if(t?.length>0){const e=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=o;this._isStreamingSupported=!r;this._isRangeSupported=!a;this._contentLength=e;this._fullRequestReader=null;this._rangeReaders=[];this._pdfDataRangeTransport.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})}));this._pdfDataRangeTransport.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})}));this._pdfDataRangeTransport.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})}));this._pdfDataRangeTransport.addProgressiveDoneListener((()=>{this._onProgressiveDone()}));this._pdfDataRangeTransport.transportReady()}_onReceiveData({begin:e,chunk:t}){const i=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;if(void 0===e)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{const t=this._rangeReaders.some((function(t){if(t._begin!==e)return!1;t._enqueue(i);return!0}));(0,n.assert)(t,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone();this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;this._queuedChunks=null;return new PDFDataTransportStreamReader(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new PDFDataTransportStreamRangeReader(this,e,t);this._pdfDataRangeTransport.requestDataRange(e,t);this._rangeReaders.push(i);return i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}};class PDFDataTransportStreamReader{constructor(e,t,i=!1,n=null){this._stream=e;this._done=i||!1;this._filename=(0,s.isPdfFile)(n)?n:null;this._queuedChunks=t||[];this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[];this._headersReady=Promise.resolve();e._fullRequestReader=this;this.onProgress=null}_enqueue(e){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunks.push(e);this._loaded+=e.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;this._requests.push(e);return e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class PDFDataTransportStreamRangeReader{constructor(e,t,i){this._stream=e;this._begin=t;this._end=i;this._queuedChunk=null;this._requests=[];this._done=!1;this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const e of this._requests)e.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 e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;this._requests.push(e);return e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0;this._stream._removeRangeReader(this)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFFetchStream=void 0;var n=i(1),s=i(20);function createFetchOptions(e,t,i){return{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function createHeaders(e){const t=new Headers;for(const i in e){const n=e[i];void 0!==n&&t.append(i,n)}return t}function getArrayBuffer(e){if(e instanceof Uint8Array)return e.buffer;if(e instanceof ArrayBuffer)return e;(0,n.warn)(`getArrayBuffer - unexpected data format: ${e}`);return new Uint8Array(e).buffer}t.PDFFetchStream=class PDFFetchStream{constructor(e){this.source=e;this.isHttp=/^https?:/i.test(e.url);this.httpHeaders=this.isHttp&&e.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once.");this._fullRequestReader=new PDFFetchStreamReader(this);return this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new PDFFetchStreamRangeReader(this,e,t);this._rangeRequestReaders.push(i);return i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class PDFFetchStreamReader{constructor(e){this._stream=e;this._reader=null;this._loaded=0;this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1;this._contentLength=t.length;this._headersCapability=new n.PromiseCapability;this._disableRange=t.disableRange||!1;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._abortController=new AbortController;this._isStreamingSupported=!t.disableStream;this._isRangeSupported=!t.disableRange;this._headers=createHeaders(this._stream.httpHeaders);const i=t.url;fetch(i,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,s.validateResponseStatus)(e.status))throw(0,s.createResponseStatusError)(e.status,i);this._reader=e.body.getReader();this._headersCapability.resolve();const getResponseHeader=t=>e.headers.get(t),{allowRangeRequests:t,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=t;this._contentLength=a||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new n.AbortException("Streaming is disabled."))})).catch(this._headersCapability.reject);this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}class PDFFetchStreamRangeReader{constructor(e,t,i){this._stream=e;this._reader=null;this._loaded=0;const a=e.source;this._withCredentials=a.withCredentials||!1;this._readCapability=new n.PromiseCapability;this._isStreamingSupported=!a.disableStream;this._abortController=new AbortController;this._headers=createHeaders(this._stream.httpHeaders);this._headers.append("Range",`bytes=${t}-${i-1}`);const r=a.url;fetch(r,createFetchOptions(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,s.validateResponseStatus)(e.status))throw(0,s.createResponseStatusError)(e.status,r);this._readCapability.resolve();this._reader=e.body.getReader()})).catch(this._readCapability.reject);this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();if(t)return{value:e,done:t};this._loaded+=e.byteLength;this.onProgress?.({loaded:this._loaded});return{value:getArrayBuffer(e),done:!1}}cancel(e){this._reader?.cancel(e);this._abortController.abort()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.createResponseStatusError=function createResponseStatusError(e,t){if(404===e||0===e&&t.startsWith("file:"))return new n.MissingPDFException('Missing PDF "'+t+'".');return new n.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)};t.extractFilenameFromHeader=function extractFilenameFromHeader(e){const t=e("Content-Disposition");if(t){let e=(0,s.getFilenameFromContentDispositionHeader)(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if((0,a.isPdfFile)(e))return e}return null};t.validateRangeRequestCapabilities=function validateRangeRequestCapabilities({getResponseHeader:e,isHttp:t,rangeChunkSize:i,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(e("Content-Length"),10);if(!Number.isInteger(a))return s;s.suggestedLength=a;if(a<=2*i)return s;if(n||!t)return s;if("bytes"!==e("Accept-Ranges"))return s;if("identity"!==(e("Content-Encoding")||"identity"))return s;s.allowRangeRequests=!0;return s};t.validateResponseStatus=function validateResponseStatus(e){return 200===e||206===e};var n=i(1),s=i(21),a=i(6)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.getFilenameFromContentDispositionHeader=function getFilenameFromContentDispositionHeader(e){let t=!0,i=toParamRegExp("filename\\*","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=unescape(e);e=rfc5987decode(e);e=rfc2047decode(e);return fixupEncoding(e)}i=function rfc2231getparam(e){const t=[];let i;const n=toParamRegExp("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(e));){let[,e,n,s]=i;e=parseInt(e,10);if(e in t){if(0===e)break}else t[e]=[n,s]}const s=[];for(let e=0;e<t.length&&e in t;++e){let[i,n]=t[e];n=rfc2616unquote(n);if(i){n=unescape(n);0===e&&(n=rfc5987decode(n))}s.push(n)}return s.join("")}(e);if(i){return fixupEncoding(rfc2047decode(i))}i=toParamRegExp("filename","i").exec(e);if(i){i=i[1];let e=rfc2616unquote(i);e=rfc2047decode(e);return fixupEncoding(e)}function toParamRegExp(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function textdecode(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(e,{fatal:!0}),a=(0,n.stringToBytes)(i);i=s.decode(a);t=!1}catch{}}return i}function fixupEncoding(e){if(t&&/[\x80-\xff]/.test(e)){e=textdecode("utf-8",e);t&&(e=textdecode("iso-8859-1",e))}return e}function rfc2616unquote(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const i=t[e].indexOf('"');if(-1!==i){t[e]=t[e].slice(0,i);t.length=e+1}t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function rfc5987decode(e){const t=e.indexOf("'");if(-1===t)return e;return textdecode(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function rfc2047decode(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,i,n){if("q"===i||"Q"===i)return textdecode(t,n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{n=atob(n)}catch{}return textdecode(t,n)}))}return""};var n=i(1)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFNetworkStream=void 0;var n=i(1),s=i(20);class NetworkManager{constructor(e,t={}){this.url=e;this.isHttp=/^https?:/i.test(e);this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null);this.withCredentials=t.withCredentials||!1;this.currXhrId=0;this.pendingRequests=Object.create(null)}requestRange(e,t,i){const n={begin:e,end:t};for(const e in i)n[e]=i[e];return this.request(n)}requestFull(e){return this.request(e)}request(e){const t=new XMLHttpRequest,i=this.currXhrId++,n=this.pendingRequests[i]={xhr:t};t.open("GET",this.url);t.withCredentials=this.withCredentials;for(const e in this.httpHeaders){const i=this.httpHeaders[e];void 0!==i&&t.setRequestHeader(e,i)}if(this.isHttp&&"begin"in e&&"end"in e){t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`);n.expectedStatus=206}else n.expectedStatus=200;t.responseType="arraybuffer";e.onError&&(t.onerror=function(i){e.onError(t.status)});t.onreadystatechange=this.onStateChange.bind(this,i);t.onprogress=this.onProgress.bind(this,i);n.onHeadersReceived=e.onHeadersReceived;n.onDone=e.onDone;n.onError=e.onError;n.onProgress=e.onProgress;t.send(null);return i}onProgress(e,t){const i=this.pendingRequests[e];i&&i.onProgress?.(t)}onStateChange(e,t){const i=this.pendingRequests[e];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived){i.onHeadersReceived();delete i.onHeadersReceived}if(4!==s.readyState)return;if(!(e in this.pendingRequests))return;delete this.pendingRequests[e];if(0===s.status&&this.isHttp){i.onError?.(s.status);return}const a=s.status||200;if(!(200===a&&206===i.expectedStatus)&&a!==i.expectedStatus){i.onError?.(s.status);return}const r=function getArrayBuffer(e){const t=e.response;return"string"!=typeof t?t:(0,n.stringToBytes)(t).buffer}(s);if(206===a){const e=s.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);i.onDone({begin:parseInt(t[1],10),chunk:r})}else r?i.onDone({begin:0,chunk:r}):i.onError?.(s.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e];t.abort()}}t.PDFNetworkStream=class PDFNetworkStream{constructor(e){this._source=e;this._manager=new NetworkManager(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials});this._rangeChunkSize=e.rangeChunkSize;this._fullRequestReader=null;this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once.");this._fullRequestReader=new PDFNetworkStreamFullRequestReader(this._manager,this._source);return this._fullRequestReader}getRangeReader(e,t){const i=new PDFNetworkStreamRangeRequestReader(this._manager,e,t);i.onClosed=this._onRangeRequestReaderClosed.bind(this);this._rangeRequestReaders.push(i);return i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class PDFNetworkStreamFullRequestReader{constructor(e,t){this._manager=e;const i={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url;this._fullRequestId=e.requestFull(i);this._headersReceivedCapability=new n.PromiseCapability;this._disableRange=t.disableRange||!1;this._contentLength=t.length;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!1;this._isRangeSupported=!1;this._cachedChunks=[];this._requests=[];this._done=!1;this._storedError=void 0;this._filename=null;this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e),getResponseHeader=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:n}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0);this._contentLength=n||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader);this._isRangeSupported&&this._manager.abortRequest(e);this._headersReceivedCapability.resolve()}_onDone(e){if(e)if(this._requests.length>0){this._requests.shift().resolve({value:e.chunk,done:!1})}else this._cachedChunks.push(e.chunk);this._done=!0;if(!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=(0,s.createResponseStatusError)(e,this._url);this._headersReceivedCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersReceivedCapability.promise}async read(){if(this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;this._requests.push(e);return e.promise}cancel(e){this._done=!0;this._headersReceivedCapability.reject(e);for(const e of this._requests)e.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(e,t,i){this._manager=e;const n={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url;this._requestId=e.requestRange(t,i,n);this._requests=[];this._queuedChunk=null;this._done=!1;this._storedError=void 0;this.onProgress=null;this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(e){const t=e.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunk=t;this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0;this._close()}_onError(e){this._storedError=(0,s.createResponseStatusError)(e,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0;this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;this._queuedChunk=null;return{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;this._requests.push(e);return e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0;this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId);this._close()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFNodeStream=void 0;var n=i(1),s=i(20);const a=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class PDFNodeStream{constructor(e){this.source=e;this.url=function parseUrl(e){const t=require("url"),i=t.parse(e);if("file:"===i.protocol||i.host)return i;if(/^[a-z]:[/\\]/i.test(e))return t.parse(`file:///${e}`);i.host||(i.protocol="file:");return i}(e.url);this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol;this.isFsUrl="file:"===this.url.protocol;this.httpHeaders=this.isHttp&&e.httpHeaders||{};this._fullRequestReader=null;this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){(0,n.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once.");this._fullRequestReader=this.isFsUrl?new PDFNodeStreamFsFullReader(this):new PDFNodeStreamFullReader(this);return this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=this.isFsUrl?new PDFNodeStreamFsRangeReader(this,e,t):new PDFNodeStreamRangeReader(this,e,t);this._rangeRequestReaders.push(i);return i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class BaseFullReader{constructor(e){this._url=e.url;this._done=!1;this._storedError=null;this.onProgress=null;const t=e.source;this._contentLength=t.length;this._loaded=0;this._filename=null;this._disableRange=t.disableRange||!1;this._rangeChunkSize=t.rangeChunkSize;this._rangeChunkSize||this._disableRange||(this._disableRange=!0);this._isStreamingSupported=!t.disableStream;this._isRangeSupported=!t.disableRange;this._readableStream=null;this._readCapability=new n.PromiseCapability;this._headersCapability=new n.PromiseCapability}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e){this._readCapability=new n.PromiseCapability;return this.read()}this._loaded+=e.length;this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e;this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e;e.on("readable",(()=>{this._readCapability.resolve()}));e.on("end",(()=>{e.destroy();this._done=!0;this._readCapability.resolve()}));e.on("error",(e=>{this._error(e)}));!this._isStreamingSupported&&this._isRangeSupported&&this._error(new n.AbortException("streaming is disabled"));this._storedError&&this._readableStream.destroy(this._storedError)}}class BaseRangeReader{constructor(e){this._url=e.url;this._done=!1;this._storedError=null;this.onProgress=null;this._loaded=0;this._readableStream=null;this._readCapability=new n.PromiseCapability;const t=e.source;this._isStreamingSupported=!t.disableStream}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;if(this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e){this._readCapability=new n.PromiseCapability;return this.read()}this._loaded+=e.length;this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e;this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e;e.on("readable",(()=>{this._readCapability.resolve()}));e.on("end",(()=>{e.destroy();this._done=!0;this._readCapability.resolve()}));e.on("error",(e=>{this._error(e)}));this._storedError&&this._readableStream.destroy(this._storedError)}}function createRequestOptions(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class PDFNodeStreamFullReader extends BaseFullReader{constructor(e){super(e);const handleResponse=t=>{if(404===t.statusCode){const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e;this._headersCapability.reject(e);return}this._headersCapability.resolve();this._setReadableStream(t);const getResponseHeader=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:i,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:getResponseHeader,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i;this._contentLength=a||this._contentLength;this._filename=(0,s.extractFilenameFromHeader)(getResponseHeader)};this._request=null;if("http:"===this._url.protocol){const t=require("http");this._request=t.request(createRequestOptions(this._url,e.httpHeaders),handleResponse)}else{const t=require("https");this._request=t.request(createRequestOptions(this._url,e.httpHeaders),handleResponse)}this._request.on("error",(e=>{this._storedError=e;this._headersCapability.reject(e)}));this._request.end()}}class PDFNodeStreamRangeReader extends BaseRangeReader{constructor(e,t,i){super(e);this._httpHeaders={};for(const t in e.httpHeaders){const i=e.httpHeaders[t];void 0!==i&&(this._httpHeaders[t]=i)}this._httpHeaders.Range=`bytes=${t}-${i-1}`;const handleResponse=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};this._request=null;if("http:"===this._url.protocol){const e=require("http");this._request=e.request(createRequestOptions(this._url,this._httpHeaders),handleResponse)}else{const e=require("https");this._request=e.request(createRequestOptions(this._url,this._httpHeaders),handleResponse)}this._request.on("error",(e=>{this._storedError=e}));this._request.end()}}class PDFNodeStreamFsFullReader extends BaseFullReader{constructor(e){super(e);let t=decodeURIComponent(this._url.path);a.test(this._url.href)&&(t=t.replace(/^\//,""));const i=require("fs");i.lstat(t,((e,s)=>{if(e){"ENOENT"===e.code&&(e=new n.MissingPDFException(`Missing PDF "${t}".`));this._storedError=e;this._headersCapability.reject(e)}else{this._contentLength=s.size;this._setReadableStream(i.createReadStream(t));this._headersCapability.resolve()}}))}}class PDFNodeStreamFsRangeReader extends BaseRangeReader{constructor(e,t,i){super(e);let n=decodeURIComponent(this._url.path);a.test(this._url.href)&&(n=n.replace(/^\//,""));const s=require("fs");this._setReadableStream(s.createReadStream(n,{start:t,end:i-1}))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.SVGGraphics=void 0;var n=i(6),s=i(1);const a="normal",r="normal",o="#000000",l=["butt","round","square"],d=["miter","round","bevel"],createObjectURL=function(e,t="",i=!1){if(URL.createObjectURL&&"undefined"!=typeof Blob&&!i)return URL.createObjectURL(new Blob([e],{type:t}));const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let s=`data:${t};base64,`;for(let t=0,i=e.length;t<i;t+=3){const a=255&e[t],r=255&e[t+1],o=255&e[t+2];s+=n[a>>2]+n[(3&a)<<4|r>>4]+n[t+1<i?(15&r)<<2|o>>6:64]+n[t+2<i?63&o:64]}return s},h=function(){const e=new Uint8Array([137,80,78,71,13,10,26,10]),t=new Int32Array(256);for(let e=0;e<256;e++){let i=e;for(let e=0;e<8;e++)i=1&i?3988292384^i>>1&2147483647:i>>1&2147483647;t[e]=i}function writePngChunk(e,i,n,s){let a=s;const r=i.length;n[a]=r>>24&255;n[a+1]=r>>16&255;n[a+2]=r>>8&255;n[a+3]=255&r;a+=4;n[a]=255&e.charCodeAt(0);n[a+1]=255&e.charCodeAt(1);n[a+2]=255&e.charCodeAt(2);n[a+3]=255&e.charCodeAt(3);a+=4;n.set(i,a);a+=i.length;const o=function crc32(e,i,n){let s=-1;for(let a=i;a<n;a++){const i=255&(s^e[a]);s=s>>>8^t[i]}return-1^s}(n,s+4,a);n[a]=o>>24&255;n[a+1]=o>>16&255;n[a+2]=o>>8&255;n[a+3]=255&o}function deflateSyncUncompressed(e){let t=e.length;const i=65535,n=Math.ceil(t/i),s=new Uint8Array(2+t+5*n+4);let a=0;s[a++]=120;s[a++]=156;let r=0;for(;t>i;){s[a++]=0;s[a++]=255;s[a++]=255;s[a++]=0;s[a++]=0;s.set(e.subarray(r,r+i),a);a+=i;r+=i;t-=i}s[a++]=1;s[a++]=255&t;s[a++]=t>>8&255;s[a++]=255&~t;s[a++]=(65535&~t)>>8&255;s.set(e.subarray(r),a);a+=e.length-r;const o=function adler32(e,t,i){let n=1,s=0;for(let a=t;a<i;++a){n=(n+(255&e[a]))%65521;s=(s+n)%65521}return s<<16|n}(e,0,e.length);s[a++]=o>>24&255;s[a++]=o>>16&255;s[a++]=o>>8&255;s[a++]=255&o;return s}function encode(t,i,n,a){const r=t.width,o=t.height;let l,d,h;const c=t.data;switch(i){case s.ImageKind.GRAYSCALE_1BPP:d=0;l=1;h=r+7>>3;break;case s.ImageKind.RGB_24BPP:d=2;l=8;h=3*r;break;case s.ImageKind.RGBA_32BPP:d=6;l=8;h=4*r;break;default:throw new Error("invalid format")}const u=new Uint8Array((1+h)*o);let p=0,g=0;for(let e=0;e<o;++e){u[p++]=0;u.set(c.subarray(g,g+h),p);g+=h;p+=h}if(i===s.ImageKind.GRAYSCALE_1BPP&&a){p=0;for(let e=0;e<o;e++){p++;for(let e=0;e<h;e++)u[p++]^=255}}const f=new Uint8Array([r>>24&255,r>>16&255,r>>8&255,255&r,o>>24&255,o>>16&255,o>>8&255,255&o,l,d,0,0,0]),m=function deflateSync(e){if(!s.isNodeJS)return deflateSyncUncompressed(e);try{const t=parseInt(process.versions.node)>=8?e:Buffer.from(e),i=require("zlib").deflateSync(t,{level:9});return i instanceof Uint8Array?i:new Uint8Array(i)}catch(e){(0,s.warn)("Not compressing PNG because zlib.deflateSync is unavailable: "+e)}return deflateSyncUncompressed(e)}(u),b=e.length+36+f.length+m.length,v=new Uint8Array(b);let _=0;v.set(e,_);_+=e.length;writePngChunk("IHDR",f,v,_);_+=12+f.length;writePngChunk("IDATA",m,v,_);_+=12+m.length;writePngChunk("IEND",new Uint8Array(0),v,_);return createObjectURL(v,"image/png",n)}return function convertImgDataToPng(e,t,i){return encode(e,void 0===e.kind?s.ImageKind.GRAYSCALE_1BPP:e.kind,t,i)}}();class SVGExtraState{constructor(){this.fontSizeScale=1;this.fontWeight=r;this.fontSize=0;this.textMatrix=s.IDENTITY_MATRIX;this.fontMatrix=s.FONT_IDENTITY_MATRIX;this.leading=0;this.textRenderingMode=s.TextRenderingMode.FILL;this.textMatrixScale=1;this.x=0;this.y=0;this.lineX=0;this.lineY=0;this.charSpacing=0;this.wordSpacing=0;this.textHScale=1;this.textRise=0;this.fillColor=o;this.strokeColor="#000000";this.fillAlpha=1;this.strokeAlpha=1;this.lineWidth=1;this.lineJoin="";this.lineCap="";this.miterLimit=0;this.dashArray=[];this.dashPhase=0;this.dependencies=[];this.activeClipUrl=null;this.clipGroup=null;this.maskId=""}clone(){return Object.create(this)}setCurrentPoint(e,t){this.x=e;this.y=t}}function pf(e){if(Number.isInteger(e))return e.toString();const t=e.toFixed(10);let i=t.length-1;if("0"!==t[i])return t;do{i--}while("0"===t[i]);return t.substring(0,"."===t[i]?i:i+1)}function pm(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${pf(e[0])} ${pf(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2]){return`rotate(${pf(180*Math.acos(e[0])/Math.PI)})`}}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${pf(e[4])} ${pf(e[5])})`;return`matrix(${pf(e[0])} ${pf(e[1])} ${pf(e[2])} ${pf(e[3])} ${pf(e[4])} ${pf(e[5])})`}let c=0,u=0,p=0;t.SVGGraphics=class SVGGraphics{constructor(e,t,i=!1){(0,n.deprecated)("The SVG back-end is no longer maintained and *may* be removed in the future.");this.svgFactory=new n.DOMSVGFactory;this.current=new SVGExtraState;this.transformMatrix=s.IDENTITY_MATRIX;this.transformStack=[];this.extraStack=[];this.commonObjs=e;this.objs=t;this.pendingClip=null;this.pendingEOFill=!1;this.embedFonts=!1;this.embeddedFonts=Object.create(null);this.cssStyle=null;this.forceDataSchema=!!i;this._operatorIdMapping=[];for(const e in s.OPS)this._operatorIdMapping[s.OPS[e]]=e}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}save(){this.transformStack.push(this.transformMatrix);const e=this.current;this.extraStack.push(e);this.current=e.clone()}restore(){this.transformMatrix=this.transformStack.pop();this.current=this.extraStack.pop();this.pendingClip=null;this.tgrp=null}group(e){this.save();this.executeOpTree(e);this.restore()}loadDependencies(e){const t=e.fnArray,i=e.argsArray;for(let e=0,n=t.length;e<n;e++)if(t[e]===s.OPS.dependency)for(const t of i[e]){const e=t.startsWith("g_")?this.commonObjs:this.objs,i=new Promise((i=>{e.get(t,i)}));this.current.dependencies.push(i)}return Promise.all(this.current.dependencies)}transform(e,t,i,n,a,r){const o=[e,t,i,n,a,r];this.transformMatrix=s.Util.transform(this.transformMatrix,o);this.tgrp=null}getSVG(e,t){this.viewport=t;const i=this._initialize(t);return this.loadDependencies(e).then((()=>{this.transformMatrix=s.IDENTITY_MATRIX;this.executeOpTree(this.convertOpList(e));return i}))}convertOpList(e){const t=this._operatorIdMapping,i=e.argsArray,n=e.fnArray,s=[];for(let e=0,a=n.length;e<a;e++){const a=n[e];s.push({fnId:a,fn:t[a],args:i[e]})}return function opListToTree(e){let t=[];const i=[];for(const n of e)if("save"!==n.fn)"restore"===n.fn?t=i.pop():t.push(n);else{t.push({fnId:92,fn:"group",items:[]});i.push(t);t=t.at(-1).items}return t}(s)}executeOpTree(e){for(const t of e){const e=t.fn,i=t.fnId,n=t.args;switch(0|i){case s.OPS.beginText:this.beginText();break;case s.OPS.dependency:break;case s.OPS.setLeading:this.setLeading(n);break;case s.OPS.setLeadingMoveText:this.setLeadingMoveText(n[0],n[1]);break;case s.OPS.setFont:this.setFont(n);break;case s.OPS.showText:case s.OPS.showSpacedText:this.showText(n[0]);break;case s.OPS.endText:this.endText();break;case s.OPS.moveText:this.moveText(n[0],n[1]);break;case s.OPS.setCharSpacing:this.setCharSpacing(n[0]);break;case s.OPS.setWordSpacing:this.setWordSpacing(n[0]);break;case s.OPS.setHScale:this.setHScale(n[0]);break;case s.OPS.setTextMatrix:this.setTextMatrix(n[0],n[1],n[2],n[3],n[4],n[5]);break;case s.OPS.setTextRise:this.setTextRise(n[0]);break;case s.OPS.setTextRenderingMode:this.setTextRenderingMode(n[0]);break;case s.OPS.setLineWidth:this.setLineWidth(n[0]);break;case s.OPS.setLineJoin:this.setLineJoin(n[0]);break;case s.OPS.setLineCap:this.setLineCap(n[0]);break;case s.OPS.setMiterLimit:this.setMiterLimit(n[0]);break;case s.OPS.setFillRGBColor:this.setFillRGBColor(n[0],n[1],n[2]);break;case s.OPS.setStrokeRGBColor:this.setStrokeRGBColor(n[0],n[1],n[2]);break;case s.OPS.setStrokeColorN:this.setStrokeColorN(n);break;case s.OPS.setFillColorN:this.setFillColorN(n);break;case s.OPS.shadingFill:this.shadingFill(n[0]);break;case s.OPS.setDash:this.setDash(n[0],n[1]);break;case s.OPS.setRenderingIntent:this.setRenderingIntent(n[0]);break;case s.OPS.setFlatness:this.setFlatness(n[0]);break;case s.OPS.setGState:this.setGState(n[0]);break;case s.OPS.fill:this.fill();break;case s.OPS.eoFill:this.eoFill();break;case s.OPS.stroke:this.stroke();break;case s.OPS.fillStroke:this.fillStroke();break;case s.OPS.eoFillStroke:this.eoFillStroke();break;case s.OPS.clip:this.clip("nonzero");break;case s.OPS.eoClip:this.clip("evenodd");break;case s.OPS.paintSolidColorImageMask:this.paintSolidColorImageMask();break;case s.OPS.paintImageXObject:this.paintImageXObject(n[0]);break;case s.OPS.paintInlineImageXObject:this.paintInlineImageXObject(n[0]);break;case s.OPS.paintImageMaskXObject:this.paintImageMaskXObject(n[0]);break;case s.OPS.paintFormXObjectBegin:this.paintFormXObjectBegin(n[0],n[1]);break;case s.OPS.paintFormXObjectEnd:this.paintFormXObjectEnd();break;case s.OPS.closePath:this.closePath();break;case s.OPS.closeStroke:this.closeStroke();break;case s.OPS.closeFillStroke:this.closeFillStroke();break;case s.OPS.closeEOFillStroke:this.closeEOFillStroke();break;case s.OPS.nextLine:this.nextLine();break;case s.OPS.transform:this.transform(n[0],n[1],n[2],n[3],n[4],n[5]);break;case s.OPS.constructPath:this.constructPath(n[0],n[1]);break;case s.OPS.endPath:this.endPath();break;case 92:this.group(t.items);break;default:(0,s.warn)(`Unimplemented operator ${e}`)}}}setWordSpacing(e){this.current.wordSpacing=e}setCharSpacing(e){this.current.charSpacing=e}nextLine(){this.moveText(0,this.current.leading)}setTextMatrix(e,t,i,n,s,a){const r=this.current;r.textMatrix=r.lineMatrix=[e,t,i,n,s,a];r.textMatrixScale=Math.hypot(e,t);r.x=r.lineX=0;r.y=r.lineY=0;r.xcoords=[];r.ycoords=[];r.tspan=this.svgFactory.createElement("svg:tspan");r.tspan.setAttributeNS(null,"font-family",r.fontFamily);r.tspan.setAttributeNS(null,"font-size",`${pf(r.fontSize)}px`);r.tspan.setAttributeNS(null,"y",pf(-r.y));r.txtElement=this.svgFactory.createElement("svg:text");r.txtElement.append(r.tspan)}beginText(){const e=this.current;e.x=e.lineX=0;e.y=e.lineY=0;e.textMatrix=s.IDENTITY_MATRIX;e.lineMatrix=s.IDENTITY_MATRIX;e.textMatrixScale=1;e.tspan=this.svgFactory.createElement("svg:tspan");e.txtElement=this.svgFactory.createElement("svg:text");e.txtgrp=this.svgFactory.createElement("svg:g");e.xcoords=[];e.ycoords=[]}moveText(e,t){const i=this.current;i.x=i.lineX+=e;i.y=i.lineY+=t;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))}showText(e){const t=this.current,i=t.font,n=t.fontSize;if(0===n)return;const l=t.fontSizeScale,d=t.charSpacing,h=t.wordSpacing,c=t.fontDirection,u=t.textHScale*c,p=i.vertical,g=p?1:-1,f=i.defaultVMetrics,m=n*t.fontMatrix[0];let b=0;for(const s of e){if(null===s){b+=c*h;continue}if("number"==typeof s){b+=g*s*n/1e3;continue}const e=(s.isSpace?h:0)+d,a=s.fontChar;let r,o,u=s.width;if(p){let e;const t=s.vmetric||f;e=s.vmetric?t[1]:.5*u;e=-e*m;const i=t[2]*m;u=t?-t[0]:u;r=e/l;o=(b+i)/l}else{r=b/l;o=0}if(s.isInFont||i.missingFile){t.xcoords.push(t.x+r);p&&t.ycoords.push(-t.y+o);t.tspan.textContent+=a}b+=p?u*m-e*c:u*m+e*c}t.tspan.setAttributeNS(null,"x",t.xcoords.map(pf).join(" "));p?t.tspan.setAttributeNS(null,"y",t.ycoords.map(pf).join(" ")):t.tspan.setAttributeNS(null,"y",pf(-t.y));p?t.y-=b:t.x+=b*u;t.tspan.setAttributeNS(null,"font-family",t.fontFamily);t.tspan.setAttributeNS(null,"font-size",`${pf(t.fontSize)}px`);t.fontStyle!==a&&t.tspan.setAttributeNS(null,"font-style",t.fontStyle);t.fontWeight!==r&&t.tspan.setAttributeNS(null,"font-weight",t.fontWeight);const v=t.textRenderingMode&s.TextRenderingMode.FILL_STROKE_MASK;if(v===s.TextRenderingMode.FILL||v===s.TextRenderingMode.FILL_STROKE){t.fillColor!==o&&t.tspan.setAttributeNS(null,"fill",t.fillColor);t.fillAlpha<1&&t.tspan.setAttributeNS(null,"fill-opacity",t.fillAlpha)}else t.textRenderingMode===s.TextRenderingMode.ADD_TO_PATH?t.tspan.setAttributeNS(null,"fill","transparent"):t.tspan.setAttributeNS(null,"fill","none");if(v===s.TextRenderingMode.STROKE||v===s.TextRenderingMode.FILL_STROKE){const e=1/(t.textMatrixScale||1);this._setStrokeAttributes(t.tspan,e)}let _=t.textMatrix;if(0!==t.textRise){_=_.slice();_[5]+=t.textRise}t.txtElement.setAttributeNS(null,"transform",`${pm(_)} scale(${pf(u)}, -1)`);t.txtElement.setAttributeNS("http://www.w3.org/XML/1998/namespace","xml:space","preserve");t.txtElement.append(t.tspan);t.txtgrp.append(t.txtElement);this._ensureTransformGroup().append(t.txtElement)}setLeadingMoveText(e,t){this.setLeading(-t);this.moveText(e,t)}addFontStyle(e){if(!e.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.append(this.cssStyle)}const t=createObjectURL(e.data,e.mimetype,this.forceDataSchema);this.cssStyle.textContent+=`@font-face { font-family: "${e.loadedName}"; src: url(${t}); }\n`}setFont(e){const t=this.current,i=this.commonObjs.get(e[0]);let n=e[1];t.font=i;if(this.embedFonts&&!i.missingFile&&!this.embeddedFonts[i.loadedName]){this.addFontStyle(i);this.embeddedFonts[i.loadedName]=i}t.fontMatrix=i.fontMatrix||s.FONT_IDENTITY_MATRIX;let a="normal";i.black?a="900":i.bold&&(a="bold");const r=i.italic?"italic":"normal";if(n<0){n=-n;t.fontDirection=-1}else t.fontDirection=1;t.fontSize=n;t.fontFamily=i.loadedName;t.fontWeight=a;t.fontStyle=r;t.tspan=this.svgFactory.createElement("svg:tspan");t.tspan.setAttributeNS(null,"y",pf(-t.y));t.xcoords=[];t.ycoords=[]}endText(){const e=this.current;if(e.textRenderingMode&s.TextRenderingMode.ADD_TO_PATH_FLAG&&e.txtElement?.hasChildNodes()){e.element=e.txtElement;this.clip("nonzero");this.endPath()}}setLineWidth(e){e>0&&(this.current.lineWidth=e)}setLineCap(e){this.current.lineCap=l[e]}setLineJoin(e){this.current.lineJoin=d[e]}setMiterLimit(e){this.current.miterLimit=e}setStrokeAlpha(e){this.current.strokeAlpha=e}setStrokeRGBColor(e,t,i){this.current.strokeColor=s.Util.makeHexColor(e,t,i)}setFillAlpha(e){this.current.fillAlpha=e}setFillRGBColor(e,t,i){this.current.fillColor=s.Util.makeHexColor(e,t,i);this.current.tspan=this.svgFactory.createElement("svg:tspan");this.current.xcoords=[];this.current.ycoords=[]}setStrokeColorN(e){this.current.strokeColor=this._makeColorN_Pattern(e)}setFillColorN(e){this.current.fillColor=this._makeColorN_Pattern(e)}shadingFill(e){const{width:t,height:i}=this.viewport,n=s.Util.inverseTransform(this.transformMatrix),[a,r,o,l]=s.Util.getAxialAlignedBoundingBox([0,0,t,i],n),d=this.svgFactory.createElement("svg:rect");d.setAttributeNS(null,"x",a);d.setAttributeNS(null,"y",r);d.setAttributeNS(null,"width",o-a);d.setAttributeNS(null,"height",l-r);d.setAttributeNS(null,"fill",this._makeShadingPattern(e));this.current.fillAlpha<1&&d.setAttributeNS(null,"fill-opacity",this.current.fillAlpha);this._ensureTransformGroup().append(d)}_makeColorN_Pattern(e){return"TilingPattern"===e[0]?this._makeTilingPattern(e):this._makeShadingPattern(e)}_makeTilingPattern(e){const t=e[1],i=e[2],n=e[3]||s.IDENTITY_MATRIX,[a,r,o,l]=e[4],d=e[5],h=e[6],c=e[7],u="shading"+p++,[g,f,m,b]=s.Util.normalizeRect([...s.Util.applyTransform([a,r],n),...s.Util.applyTransform([o,l],n)]),[v,_]=s.Util.singularValueDecompose2dScale(n),w=d*v,y=h*_,S=this.svgFactory.createElement("svg:pattern");S.setAttributeNS(null,"id",u);S.setAttributeNS(null,"patternUnits","userSpaceOnUse");S.setAttributeNS(null,"width",w);S.setAttributeNS(null,"height",y);S.setAttributeNS(null,"x",`${g}`);S.setAttributeNS(null,"y",`${f}`);const A=this.svg,E=this.transformMatrix,P=this.current.fillColor,C=this.current.strokeColor,x=this.svgFactory.create(m-g,b-f);this.svg=x;this.transformMatrix=n;if(2===c){const e=s.Util.makeHexColor(...t);this.current.fillColor=e;this.current.strokeColor=e}this.executeOpTree(this.convertOpList(i));this.svg=A;this.transformMatrix=E;this.current.fillColor=P;this.current.strokeColor=C;S.append(x.childNodes[0]);this.defs.append(S);return`url(#${u})`}_makeShadingPattern(e){"string"==typeof e&&(e=this.objs.get(e));switch(e[0]){case"RadialAxial":const t="shading"+p++,i=e[3];let n;switch(e[1]){case"axial":const i=e[4],s=e[5];n=this.svgFactory.createElement("svg:linearGradient");n.setAttributeNS(null,"id",t);n.setAttributeNS(null,"gradientUnits","userSpaceOnUse");n.setAttributeNS(null,"x1",i[0]);n.setAttributeNS(null,"y1",i[1]);n.setAttributeNS(null,"x2",s[0]);n.setAttributeNS(null,"y2",s[1]);break;case"radial":const a=e[4],r=e[5],o=e[6],l=e[7];n=this.svgFactory.createElement("svg:radialGradient");n.setAttributeNS(null,"id",t);n.setAttributeNS(null,"gradientUnits","userSpaceOnUse");n.setAttributeNS(null,"cx",r[0]);n.setAttributeNS(null,"cy",r[1]);n.setAttributeNS(null,"r",l);n.setAttributeNS(null,"fx",a[0]);n.setAttributeNS(null,"fy",a[1]);n.setAttributeNS(null,"fr",o);break;default:throw new Error(`Unknown RadialAxial type: ${e[1]}`)}for(const e of i){const t=this.svgFactory.createElement("svg:stop");t.setAttributeNS(null,"offset",e[0]);t.setAttributeNS(null,"stop-color",e[1]);n.append(t)}this.defs.append(n);return`url(#${t})`;case"Mesh":(0,s.warn)("Unimplemented pattern Mesh");return null;case"Dummy":return"hotpink";default:throw new Error(`Unknown IR type: ${e[0]}`)}}setDash(e,t){this.current.dashArray=e;this.current.dashPhase=t}constructPath(e,t){const i=this.current;let n=i.x,a=i.y,r=[],o=0;for(const i of e)switch(0|i){case s.OPS.rectangle:n=t[o++];a=t[o++];const e=n+t[o++],i=a+t[o++];r.push("M",pf(n),pf(a),"L",pf(e),pf(a),"L",pf(e),pf(i),"L",pf(n),pf(i),"Z");break;case s.OPS.moveTo:n=t[o++];a=t[o++];r.push("M",pf(n),pf(a));break;case s.OPS.lineTo:n=t[o++];a=t[o++];r.push("L",pf(n),pf(a));break;case s.OPS.curveTo:n=t[o+4];a=t[o+5];r.push("C",pf(t[o]),pf(t[o+1]),pf(t[o+2]),pf(t[o+3]),pf(n),pf(a));o+=6;break;case s.OPS.curveTo2:r.push("C",pf(n),pf(a),pf(t[o]),pf(t[o+1]),pf(t[o+2]),pf(t[o+3]));n=t[o+2];a=t[o+3];o+=4;break;case s.OPS.curveTo3:n=t[o+2];a=t[o+3];r.push("C",pf(t[o]),pf(t[o+1]),pf(n),pf(a),pf(n),pf(a));o+=4;break;case s.OPS.closePath:r.push("Z")}r=r.join(" ");if(i.path&&e.length>0&&e[0]!==s.OPS.rectangle&&e[0]!==s.OPS.moveTo)r=i.path.getAttributeNS(null,"d")+r;else{i.path=this.svgFactory.createElement("svg:path");this._ensureTransformGroup().append(i.path)}i.path.setAttributeNS(null,"d",r);i.path.setAttributeNS(null,"fill","none");i.element=i.path;i.setCurrentPoint(n,a)}endPath(){const e=this.current;e.path=null;if(!this.pendingClip)return;if(!e.element){this.pendingClip=null;return}const t="clippath"+c++,i=this.svgFactory.createElement("svg:clipPath");i.setAttributeNS(null,"id",t);i.setAttributeNS(null,"transform",pm(this.transformMatrix));const n=e.element.cloneNode(!0);"evenodd"===this.pendingClip?n.setAttributeNS(null,"clip-rule","evenodd"):n.setAttributeNS(null,"clip-rule","nonzero");this.pendingClip=null;i.append(n);this.defs.append(i);if(e.activeClipUrl){e.clipGroup=null;for(const e of this.extraStack)e.clipGroup=null;i.setAttributeNS(null,"clip-path",e.activeClipUrl)}e.activeClipUrl=`url(#${t})`;this.tgrp=null}clip(e){this.pendingClip=e}closePath(){const e=this.current;if(e.path){const t=`${e.path.getAttributeNS(null,"d")}Z`;e.path.setAttributeNS(null,"d",t)}}setLeading(e){this.current.leading=-e}setTextRise(e){this.current.textRise=e}setTextRenderingMode(e){this.current.textRenderingMode=e}setHScale(e){this.current.textHScale=e/100}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,i]of e)switch(t){case"LW":this.setLineWidth(i);break;case"LC":this.setLineCap(i);break;case"LJ":this.setLineJoin(i);break;case"ML":this.setMiterLimit(i);break;case"D":this.setDash(i[0],i[1]);break;case"RI":this.setRenderingIntent(i);break;case"FL":this.setFlatness(i);break;case"Font":this.setFont(i);break;case"CA":this.setStrokeAlpha(i);break;case"ca":this.setFillAlpha(i);break;default:(0,s.warn)(`Unimplemented graphic state operator ${t}`)}}fill(){const e=this.current;if(e.element){e.element.setAttributeNS(null,"fill",e.fillColor);e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha);this.endPath()}}stroke(){const e=this.current;if(e.element){this._setStrokeAttributes(e.element);e.element.setAttributeNS(null,"fill","none");this.endPath()}}_setStrokeAttributes(e,t=1){const i=this.current;let n=i.dashArray;1!==t&&n.length>0&&(n=n.map((function(e){return t*e})));e.setAttributeNS(null,"stroke",i.strokeColor);e.setAttributeNS(null,"stroke-opacity",i.strokeAlpha);e.setAttributeNS(null,"stroke-miterlimit",pf(i.miterLimit));e.setAttributeNS(null,"stroke-linecap",i.lineCap);e.setAttributeNS(null,"stroke-linejoin",i.lineJoin);e.setAttributeNS(null,"stroke-width",pf(t*i.lineWidth)+"px");e.setAttributeNS(null,"stroke-dasharray",n.map(pf).join(" "));e.setAttributeNS(null,"stroke-dashoffset",pf(t*i.dashPhase)+"px")}eoFill(){this.current.element?.setAttributeNS(null,"fill-rule","evenodd");this.fill()}fillStroke(){this.stroke();this.fill()}eoFillStroke(){this.current.element?.setAttributeNS(null,"fill-rule","evenodd");this.fillStroke()}closeStroke(){this.closePath();this.stroke()}closeFillStroke(){this.closePath();this.fillStroke()}closeEOFillStroke(){this.closePath();this.eoFillStroke()}paintSolidColorImageMask(){const e=this.svgFactory.createElement("svg:rect");e.setAttributeNS(null,"x","0");e.setAttributeNS(null,"y","0");e.setAttributeNS(null,"width","1px");e.setAttributeNS(null,"height","1px");e.setAttributeNS(null,"fill",this.current.fillColor);this._ensureTransformGroup().append(e)}paintImageXObject(e){const t=this.getObject(e);t?this.paintInlineImageXObject(t):(0,s.warn)(`Dependent image with object ID ${e} is not ready yet`)}paintInlineImageXObject(e,t){const i=e.width,n=e.height,s=h(e,this.forceDataSchema,!!t),a=this.svgFactory.createElement("svg:rect");a.setAttributeNS(null,"x","0");a.setAttributeNS(null,"y","0");a.setAttributeNS(null,"width",pf(i));a.setAttributeNS(null,"height",pf(n));this.current.element=a;this.clip("nonzero");const r=this.svgFactory.createElement("svg:image");r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s);r.setAttributeNS(null,"x","0");r.setAttributeNS(null,"y",pf(-n));r.setAttributeNS(null,"width",pf(i)+"px");r.setAttributeNS(null,"height",pf(n)+"px");r.setAttributeNS(null,"transform",`scale(${pf(1/i)} ${pf(-1/n)})`);t?t.append(r):this._ensureTransformGroup().append(r)}paintImageMaskXObject(e){const t=this.getObject(e.data,e);if(t.bitmap){(0,s.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");return}const i=this.current,n=t.width,a=t.height,r=i.fillColor;i.maskId="mask"+u++;const o=this.svgFactory.createElement("svg:mask");o.setAttributeNS(null,"id",i.maskId);const l=this.svgFactory.createElement("svg:rect");l.setAttributeNS(null,"x","0");l.setAttributeNS(null,"y","0");l.setAttributeNS(null,"width",pf(n));l.setAttributeNS(null,"height",pf(a));l.setAttributeNS(null,"fill",r);l.setAttributeNS(null,"mask",`url(#${i.maskId})`);this.defs.append(o);this._ensureTransformGroup().append(l);this.paintInlineImageXObject(t,o)}paintFormXObjectBegin(e,t){Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]);if(t){const e=t[2]-t[0],i=t[3]-t[1],n=this.svgFactory.createElement("svg:rect");n.setAttributeNS(null,"x",t[0]);n.setAttributeNS(null,"y",t[1]);n.setAttributeNS(null,"width",pf(e));n.setAttributeNS(null,"height",pf(i));this.current.element=n;this.clip("nonzero");this.endPath()}}paintFormXObjectEnd(){}_initialize(e){const t=this.svgFactory.create(e.width,e.height),i=this.svgFactory.createElement("svg:defs");t.append(i);this.defs=i;const n=this.svgFactory.createElement("svg:g");n.setAttributeNS(null,"transform",pm(e.transform));t.append(n);this.svg=n;return t}_ensureClipGroup(){if(!this.current.clipGroup){const e=this.svgFactory.createElement("svg:g");e.setAttributeNS(null,"clip-path",this.current.activeClipUrl);this.svg.append(e);this.current.clipGroup=e}return this.current.clipGroup}_ensureTransformGroup(){if(!this.tgrp){this.tgrp=this.svgFactory.createElement("svg:g");this.tgrp.setAttributeNS(null,"transform",pm(this.transformMatrix));this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)}return this.tgrp}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.XfaText=void 0;class XfaText{static textContent(e){const t=[],i={items:t,styles:Object.create(null)};!function walk(e){if(!e)return;let i=null;const n=e.name;if("#text"===n)i=e.value;else{if(!XfaText.shouldBuildText(n))return;e?.attributes?.textContent?i=e.attributes.textContent:e.value&&(i=e.value)}null!==i&&t.push({str:i});if(e.children)for(const t of e.children)walk(t)}(e);return i}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=XfaText},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TextLayerRenderTask=void 0;t.renderTextLayer=function renderTextLayer(e){if(!e.textContentSource&&(e.textContent||e.textContentStream)){(0,s.deprecated)("The TextLayerRender `textContent`/`textContentStream` parameters will be removed in the future, please use `textContentSource` instead.");e.textContentSource=e.textContent||e.textContentStream}const{container:t,viewport:i}=e,n=getComputedStyle(t),a=n.getPropertyValue("visibility"),r=parseFloat(n.getPropertyValue("--scale-factor"));"visible"===a&&(!r||Math.abs(r-i.scale)>1e-5)&&console.error("The `--scale-factor` CSS-variable must be set, to the same value as `viewport.scale`, either on the `container`-element itself or higher up in the DOM.");const o=new TextLayerRenderTask(e);o._render();return o};t.updateTextLayer=function updateTextLayer({container:e,viewport:t,textDivs:i,textDivProperties:n,isOffscreenCanvasSupported:a,mustRotate:r=!0,mustRescale:o=!0}){r&&(0,s.setLayerDimensions)(e,{rotation:t.rotation});if(o){const e=getCtx(0,a),s={prevFontSize:null,prevFontFamily:null,div:null,scale:t.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:e};for(const e of i){s.properties=n.get(e);s.div=e;layout(s)}}};var n=i(1),s=i(6);const a=30,r=.8,o=new Map;function getCtx(e,t){let i;if(t&&n.FeatureTest.isOffscreenCanvasSupported)i=new OffscreenCanvas(e,e).getContext("2d",{alpha:!1});else{const t=document.createElement("canvas");t.width=t.height=e;i=t.getContext("2d",{alpha:!1})}return i}function appendText(e,t,i){const s=document.createElement("span"),l={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(s);const d=n.Util.transform(e._transform,t.transform);let h=Math.atan2(d[1],d[0]);const c=i[t.fontName];c.vertical&&(h+=Math.PI/2);const u=Math.hypot(d[2],d[3]),p=u*function getAscent(e,t){const i=o.get(e);if(i)return i;const n=getCtx(a,t);n.font=`${a}px ${e}`;const s=n.measureText("");let l=s.fontBoundingBoxAscent,d=Math.abs(s.fontBoundingBoxDescent);if(l){const t=l/(l+d);o.set(e,t);n.canvas.width=n.canvas.height=0;return t}n.strokeStyle="red";n.clearRect(0,0,a,a);n.strokeText("g",0,0);let h=n.getImageData(0,0,a,a).data;d=0;for(let e=h.length-1-3;e>=0;e-=4)if(h[e]>0){d=Math.ceil(e/4/a);break}n.clearRect(0,0,a,a);n.strokeText("A",0,a);h=n.getImageData(0,0,a,a).data;l=0;for(let e=0,t=h.length;e<t;e+=4)if(h[e]>0){l=a-Math.floor(e/4/a);break}n.canvas.width=n.canvas.height=0;if(l){const t=l/(l+d);o.set(e,t);return t}o.set(e,r);return r}(c.fontFamily,e._isOffscreenCanvasSupported);let g,f;if(0===h){g=d[4];f=d[5]-p}else{g=d[4]+p*Math.sin(h);f=d[5]-p*Math.cos(h)}const m="calc(var(--scale-factor)*",b=s.style;if(e._container===e._rootContainer){b.left=`${(100*g/e._pageWidth).toFixed(2)}%`;b.top=`${(100*f/e._pageHeight).toFixed(2)}%`}else{b.left=`${m}${g.toFixed(2)}px)`;b.top=`${m}${f.toFixed(2)}px)`}b.fontSize=`${m}${u.toFixed(2)}px)`;b.fontFamily=c.fontFamily;l.fontSize=u;s.setAttribute("role","presentation");s.textContent=t.str;s.dir=t.dir;e._fontInspectorEnabled&&(s.dataset.fontName=t.fontName);0!==h&&(l.angle=h*(180/Math.PI));let v=!1;if(t.str.length>1)v=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),i=Math.abs(t.transform[3]);e!==i&&Math.max(e,i)/Math.min(e,i)>1.5&&(v=!0)}v&&(l.canvasWidth=c.vertical?t.height:t.width);e._textDivProperties.set(s,l);e._isReadableStream&&e._layoutText(s)}function layout(e){const{div:t,scale:i,properties:n,ctx:s,prevFontSize:a,prevFontFamily:r}=e,{style:o}=t;let l="";if(0!==n.canvasWidth&&n.hasText){const{fontFamily:d}=o,{canvasWidth:h,fontSize:c}=n;if(a!==c||r!==d){s.font=`${c*i}px ${d}`;e.prevFontSize=c;e.prevFontFamily=d}const{width:u}=s.measureText(t.textContent);u>0&&(l=`scaleX(${h*i/u})`)}0!==n.angle&&(l=`rotate(${n.angle}deg) ${l}`);l.length>0&&(o.transform=l)}class TextLayerRenderTask{constructor({textContentSource:e,container:t,viewport:i,textDivs:a,textDivProperties:r,textContentItemsStr:o,isOffscreenCanvasSupported:l}){this._textContentSource=e;this._isReadableStream=e instanceof ReadableStream;this._container=this._rootContainer=t;this._textDivs=a||[];this._textContentItemsStr=o||[];this._isOffscreenCanvasSupported=l;this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled;this._reader=null;this._textDivProperties=r||new WeakMap;this._canceled=!1;this._capability=new n.PromiseCapability;this._layoutTextParams={prevFontSize:null,prevFontFamily:null,div:null,scale:i.scale*(globalThis.devicePixelRatio||1),properties:null,ctx:getCtx(0,l)};const{pageWidth:d,pageHeight:h,pageX:c,pageY:u}=i.rawDims;this._transform=[1,0,0,-1,-c,u+h];this._pageWidth=d;this._pageHeight=h;(0,s.setLayerDimensions)(t,i);this._capability.promise.finally((()=>{this._layoutTextParams=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}this._capability.reject(new n.AbortException("TextLayer task cancelled."))}_processItems(e,t){for(const i of e)if(void 0!==i.str){this._textContentItemsStr.push(i.str);appendText(this,i,t)}else if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){const e=this._container;this._container=document.createElement("span");this._container.classList.add("markedContent");null!==i.id&&this._container.setAttribute("id",`${i.id}`);e.append(this._container)}else"endMarkedContent"===i.type&&(this._container=this._container.parentNode)}_layoutText(e){const t=this._layoutTextParams.properties=this._textDivProperties.get(e);this._layoutTextParams.div=e;layout(this._layoutTextParams);t.hasText&&this._container.append(e);if(t.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation");this._container.append(e)}}_render(){const e=new n.PromiseCapability;let t=Object.create(null);if(this._isReadableStream){const pump=()=>{this._reader.read().then((({value:i,done:n})=>{if(n)e.resolve();else{Object.assign(t,i.styles);this._processItems(i.items,t);pump()}}),e.reject)};this._reader=this._textContentSource.getReader();pump()}else{if(!this._textContentSource)throw new Error('No "textContentSource" parameter specified.');{const{items:t,styles:i}=this._textContentSource;this._processItems(t,i);e.resolve()}}e.promise.then((()=>{t=null;!function render(e){if(e._canceled)return;const t=e._textDivs,i=e._capability;if(t.length>1e5)i.resolve();else{if(!e._isReadableStream)for(const i of t)e._layoutText(i);i.resolve()}}(this)}),this._capability.reject)}}t.TextLayerRenderTask=TextLayerRenderTask},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationEditorLayer=void 0;var n=i(1),s=i(4),a=i(28),r=i(33),o=i(6),l=i(34);class AnnotationEditorLayer{#St;#At=!1;#Et=null;#Pt=this.pointerup.bind(this);#Ct=this.pointerdown.bind(this);#xt=new Map;#Tt=!1;#Mt=!1;#It=!1;#kt;static _initialized=!1;constructor({uiManager:e,pageIndex:t,div:i,accessibilityManager:n,annotationLayer:s,viewport:o,l10n:d}){const h=[a.FreeTextEditor,r.InkEditor,l.StampEditor];if(!AnnotationEditorLayer._initialized){AnnotationEditorLayer._initialized=!0;for(const e of h)e.initialize(d)}e.registerEditorTypes(h);this.#kt=e;this.pageIndex=t;this.div=i;this.#St=n;this.#Et=s;this.viewport=o;this.#kt.addLayer(this)}get isEmpty(){return 0===this.#xt.size}updateToolbar(e){this.#kt.updateToolbar(e)}updateMode(e=this.#kt.getMode()){this.#Dt();if(e===n.AnnotationEditorType.INK){this.addInkEditorIfNeeded(!1);this.disableClick()}else this.enableClick();if(e!==n.AnnotationEditorType.NONE){this.div.classList.toggle("freeTextEditing",e===n.AnnotationEditorType.FREETEXT);this.div.classList.toggle("inkEditing",e===n.AnnotationEditorType.INK);this.div.classList.toggle("stampEditing",e===n.AnnotationEditorType.STAMP);this.div.hidden=!1}}addInkEditorIfNeeded(e){if(!e&&this.#kt.getMode()!==n.AnnotationEditorType.INK)return;if(!e)for(const e of this.#xt.values())if(e.isEmpty()){e.setInBackground();return}this.#Lt({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(e){this.#kt.setEditingState(e)}addCommands(e){this.#kt.addCommands(e)}enable(){this.div.style.pointerEvents="auto";const e=new Set;for(const t of this.#xt.values()){t.enableEditing();t.annotationElementId&&e.add(t.annotationElementId)}if(!this.#Et)return;const t=this.#Et.getEditableAnnotations();for(const i of t){i.hide();if(this.#kt.isDeletedAnnotationElement(i.data.id))continue;if(e.has(i.data.id))continue;const t=this.deserialize(i);if(t){this.addOrRebuild(t);t.enableEditing()}}}disable(){this.#It=!0;this.div.style.pointerEvents="none";const e=new Set;for(const t of this.#xt.values()){t.disableEditing();if(t.annotationElementId&&null===t.serialize()){this.getEditableAnnotation(t.annotationElementId)?.show();t.remove()}else e.add(t.annotationElementId)}if(this.#Et){const t=this.#Et.getEditableAnnotations();for(const i of t){const{id:t}=i.data;e.has(t)||this.#kt.isDeletedAnnotationElement(t)||i.show()}}this.#Dt();this.isEmpty&&(this.div.hidden=!0);this.#It=!1}getEditableAnnotation(e){return this.#Et?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#kt.getActive()!==e&&this.#kt.setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",this.#Ct);this.div.addEventListener("pointerup",this.#Pt)}disableClick(){this.div.removeEventListener("pointerdown",this.#Ct);this.div.removeEventListener("pointerup",this.#Pt)}attach(e){this.#xt.set(e.id,e);const{annotationElementId:t}=e;t&&this.#kt.isDeletedAnnotationElement(t)&&this.#kt.removeDeletedAnnotationElement(e)}detach(e){this.#xt.delete(e.id);this.#St?.removePointerInTextLayer(e.contentDiv);!this.#It&&e.annotationElementId&&this.#kt.addDeletedAnnotationElement(e)}remove(e){this.detach(e);this.#kt.removeEditor(e);e.div.contains(document.activeElement)&&setTimeout((()=>{this.#kt.focusMainContainer()}),0);e.div.remove();e.isAttachedToDOM=!1;this.#Mt||this.addInkEditorIfNeeded(!1)}changeParent(e){if(e.parent!==this){if(e.annotationElementId){this.#kt.addDeletedAnnotationElement(e.annotationElementId);s.AnnotationEditor.deleteAnnotationElement(e);e.annotationElementId=null}this.attach(e);e.parent?.detach(e);e.setParent(this);if(e.div&&e.isAttachedToDOM){e.div.remove();this.div.append(e.div)}}}add(e){this.changeParent(e);this.#kt.addEditor(e);this.attach(e);if(!e.isAttachedToDOM){const t=e.render();this.div.append(t);e.isAttachedToDOM=!0}e.fixAndSetPosition();e.onceAdded();this.#kt.addToAnnotationStorage(e)}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;if(e.div.contains(t)){e._focusEventsAllowed=!1;setTimeout((()=>{if(e.div.contains(document.activeElement))e._focusEventsAllowed=!0;else{e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0});t.focus()}}),0)}e._structTreeParentId=this.#St?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?e.rebuild():this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#kt.getId()}#Ft(e){switch(this.#kt.getMode()){case n.AnnotationEditorType.FREETEXT:return new a.FreeTextEditor(e);case n.AnnotationEditorType.INK:return new r.InkEditor(e);case n.AnnotationEditorType.STAMP:return new l.StampEditor(e)}return null}pasteEditor(e,t){this.#kt.updateToolbar(e);this.#kt.updateMode(e);const{offsetX:i,offsetY:n}=this.#Rt(),s=this.getNextId(),a=this.#Ft({parent:this,id:s,x:i,y:n,uiManager:this.#kt,isCentered:!0,...t});a&&this.add(a)}deserialize(e){switch(e.annotationType??e.annotationEditorType){case n.AnnotationEditorType.FREETEXT:return a.FreeTextEditor.deserialize(e,this,this.#kt);case n.AnnotationEditorType.INK:return r.InkEditor.deserialize(e,this,this.#kt);case n.AnnotationEditorType.STAMP:return l.StampEditor.deserialize(e,this,this.#kt)}return null}#Lt(e,t){const i=this.getNextId(),n=this.#Ft({parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:this.#kt,isCentered:t});n&&this.add(n);return n}#Rt(){const{x:e,y:t,width:i,height:n}=this.div.getBoundingClientRect(),s=Math.max(0,e),a=Math.max(0,t),r=(s+Math.min(window.innerWidth,e+i))/2-e,o=(a+Math.min(window.innerHeight,t+n))/2-t,[l,d]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:d}}addNewEditor(){this.#Lt(this.#Rt(),!0)}setSelected(e){this.#kt.setSelected(e)}toggleSelected(e){this.#kt.toggleSelected(e)}isSelected(e){return this.#kt.isSelected(e)}unselect(e){this.#kt.unselect(e)}pointerup(e){const{isMac:t}=n.FeatureTest.platform;if(!(0!==e.button||e.ctrlKey&&t)&&e.target===this.div&&this.#Tt){this.#Tt=!1;this.#At?this.#kt.getMode()!==n.AnnotationEditorType.STAMP?this.#Lt(e,!1):this.#kt.unselectAll():this.#At=!0}}pointerdown(e){if(this.#Tt){this.#Tt=!1;return}const{isMac:t}=n.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#Tt=!0;const i=this.#kt.getActive();this.#At=!i||i.isEmpty()}findNewParent(e,t,i){const n=this.#kt.findParent(t,i);if(null===n||n===this)return!1;n.changeParent(e);return!0}destroy(){if(this.#kt.getActive()?.parent===this){this.#kt.commitOrRemove();this.#kt.setActiveEditor(null)}for(const e of this.#xt.values()){this.#St?.removePointerInTextLayer(e.contentDiv);e.setParent(null);e.isAttachedToDOM=!1;e.div.remove()}this.div=null;this.#xt.clear();this.#kt.removeLayer(this)}#Dt(){this.#Mt=!0;for(const e of this.#xt.values())e.isEmpty()&&e.remove();this.#Mt=!1}render({viewport:e}){this.viewport=e;(0,o.setLayerDimensions)(this.div,e);for(const e of this.#kt.getEditors(this.pageIndex))this.add(e);this.updateMode()}update({viewport:e}){this.#kt.commitOrRemove();this.viewport=e;(0,o.setLayerDimensions)(this.div,{rotation:e.rotation});this.updateMode()}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}}t.AnnotationEditorLayer=AnnotationEditorLayer},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.FreeTextEditor=void 0;var n=i(1),s=i(5),a=i(4),r=i(29);class FreeTextEditor extends a.AnnotationEditor{#Ot=this.editorDivBlur.bind(this);#Nt=this.editorDivFocus.bind(this);#Bt=this.editorDivInput.bind(this);#Vt=this.editorDivKeydown.bind(this);#Ut;#zt="";#Ht=`${this.id}-editor`;#jt;#Wt=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=FreeTextEditor.prototype,arrowChecker=e=>e.isEmpty(),t=s.AnnotationEditorUIManager.TRANSLATE_SMALL,i=s.AnnotationEditorUIManager.TRANSLATE_BIG;return(0,n.shadow)(this,"_keyboardManager",new s.KeyboardManager([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-t,0],checker:arrowChecker}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:arrowChecker}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[t,0],checker:arrowChecker}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:arrowChecker}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-t],checker:arrowChecker}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:arrowChecker}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,t],checker:arrowChecker}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:arrowChecker}]]))}static _type="freetext";constructor(e){super({...e,name:"freeTextEditor"});this.#Ut=e.color||FreeTextEditor._defaultColor||a.AnnotationEditor._defaultLineColor;this.#jt=e.fontSize||FreeTextEditor._defaultFontSize}static initialize(e){a.AnnotationEditor.initialize(e,{strings:["free_text2_default_content","editor_free_text2_aria_label"]});const t=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(t.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case n.AnnotationEditorParamsType.FREETEXT_SIZE:FreeTextEditor._defaultFontSize=t;break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:FreeTextEditor._defaultColor=t}}updateParams(e,t){switch(e){case n.AnnotationEditorParamsType.FREETEXT_SIZE:this.#Gt(t);break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:this.#$t(t)}}static get defaultPropertiesToUpdate(){return[[n.AnnotationEditorParamsType.FREETEXT_SIZE,FreeTextEditor._defaultFontSize],[n.AnnotationEditorParamsType.FREETEXT_COLOR,FreeTextEditor._defaultColor||a.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.FREETEXT_SIZE,this.#jt],[n.AnnotationEditorParamsType.FREETEXT_COLOR,this.#Ut]]}#Gt(e){const setFontsize=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`;this.translate(0,-(e-this.#jt)*this.parentScale);this.#jt=e;this.#qt()},t=this.#jt;this.addCommands({cmd:()=>{setFontsize(e)},undo:()=>{setFontsize(t)},mustExec:!0,type:n.AnnotationEditorParamsType.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#$t(e){const t=this.#Ut;this.addCommands({cmd:()=>{this.#Ut=this.editorDiv.style.color=e},undo:()=>{this.#Ut=this.editorDiv.style.color=t},mustExec:!0,type:n.AnnotationEditorParamsType.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-FreeTextEditor._internalPadding*e,-(FreeTextEditor._internalPadding+this.#jt)*e]}rebuild(){if(this.parent){super.rebuild();null!==this.div&&(this.isAttachedToDOM||this.parent.add(this))}}enableEditMode(){if(!this.isInEditMode()){this.parent.setEditingState(!1);this.parent.updateToolbar(n.AnnotationEditorType.FREETEXT);super.enableEditMode();this.overlayDiv.classList.remove("enabled");this.editorDiv.contentEditable=!0;this._isDraggable=!1;this.div.removeAttribute("aria-activedescendant");this.editorDiv.addEventListener("keydown",this.#Vt);this.editorDiv.addEventListener("focus",this.#Nt);this.editorDiv.addEventListener("blur",this.#Ot);this.editorDiv.addEventListener("input",this.#Bt)}}disableEditMode(){if(this.isInEditMode()){this.parent.setEditingState(!0);super.disableEditMode();this.overlayDiv.classList.add("enabled");this.editorDiv.contentEditable=!1;this.div.setAttribute("aria-activedescendant",this.#Ht);this._isDraggable=!0;this.editorDiv.removeEventListener("keydown",this.#Vt);this.editorDiv.removeEventListener("focus",this.#Nt);this.editorDiv.removeEventListener("blur",this.#Ot);this.editorDiv.removeEventListener("input",this.#Bt);this.div.focus({preventScroll:!0});this.isEditing=!1;this.parent.div.classList.add("freeTextEditing")}}focusin(e){if(this._focusEventsAllowed){super.focusin(e);e.target!==this.editorDiv&&this.editorDiv.focus()}}onceAdded(){if(this.width)this.#Xt();else{this.enableEditMode();this.editorDiv.focus();this._initialOptions?.isCentered&&this.center();this._initialOptions=null}}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1;if(this.parent){this.parent.setEditingState(!0);this.parent.div.classList.add("freeTextEditing")}super.remove()}#Kt(){const e=this.editorDiv.getElementsByTagName("div");if(0===e.length)return this.editorDiv.innerText;const t=[];for(const i of e)t.push(i.innerText.replace(/\r\n?|\n/,""));return t.join("\n")}#qt(){const[e,t]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,n=t.style.display;t.style.display="hidden";e.div.append(this.div);i=t.getBoundingClientRect();t.remove();t.style.display=n}if(this.rotation%180==this.parentRotation%180){this.width=i.width/e;this.height=i.height/t}else{this.width=i.height/e;this.height=i.width/t}this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit();this.disableEditMode();const e=this.#zt,t=this.#zt=this.#Kt().trimEnd();if(e===t)return;const setText=e=>{this.#zt=e;if(e){this.#Yt();this._uiManager.rebuild(this);this.#qt()}else this.remove()};this.addCommands({cmd:()=>{setText(t)},undo:()=>{setText(e)},mustExec:!1});this.#qt()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode();this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){if(e.target===this.div&&"Enter"===e.key){this.enterInEditMode();e.preventDefault()}}editorDivKeydown(e){FreeTextEditor._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freeTextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment");this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox");this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;if(this.width){e=this.x;t=this.y}super.render();this.editorDiv=document.createElement("div");this.editorDiv.className="internal";this.editorDiv.setAttribute("id",this.#Ht);this.enableEditing();a.AnnotationEditor._l10nPromise.get("editor_free_text2_aria_label").then((e=>this.editorDiv?.setAttribute("aria-label",e)));a.AnnotationEditor._l10nPromise.get("free_text2_default_content").then((e=>this.editorDiv?.setAttribute("default-content",e)));this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;i.fontSize=`calc(${this.#jt}px * var(--scale-factor))`;i.color=this.#Ut;this.div.append(this.editorDiv);this.overlayDiv=document.createElement("div");this.overlayDiv.classList.add("overlay","enabled");this.div.append(this.overlayDiv);(0,s.bindEvents)(this,this.div,["dblclick","keydown"]);if(this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this.#Wt;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[d,h]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=e+(s[0]-d)/o;u=t+this.height-(s[1]-h)/l;break;case 90:c=e+(s[0]-d)/o;u=t-(s[1]-h)/l;[a,r]=[r,-a];break;case 180:c=e-this.width+(s[0]-d)/o;u=t-(s[1]-h)/l;[a,r]=[-a,-r];break;case 270:c=e+(s[0]-d-this.height*l)/o;u=t+(s[1]-h-this.width*o)/l;[a,r]=[-r,a]}this.setAt(c*i,u*n,a,r)}else this.setAt(e*i,t*n,this.width*i,this.height*n);this.#Yt();this._isDraggable=!0;this.editorDiv.contentEditable=!1}else{this._isDraggable=!1;this.editorDiv.contentEditable=!0}return this.div}#Yt(){this.editorDiv.replaceChildren();if(this.#zt)for(const e of this.#zt.split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br"));this.editorDiv.append(t)}}get contentDiv(){return this.editorDiv}static deserialize(e,t,i){let s=null;if(e instanceof r.FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:a,rotation:r,id:o},textContent:l,textPosition:d,parent:{page:{pageNumber:h}}}=e;if(!l||0===l.length)return null;s=e={annotationType:n.AnnotationEditorType.FREETEXT,color:Array.from(i),fontSize:t,value:l.join("\n"),position:d,pageIndex:h-1,rect:a,rotation:r,id:o,deleted:!1}}const a=super.deserialize(e,t,i);a.#jt=e.fontSize;a.#Ut=n.Util.makeHexColor(...e.color);a.#zt=e.value;a.annotationElementId=e.id||null;a.#Wt=s;return a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const t=FreeTextEditor._internalPadding*this.parentScale,i=this.getRect(t,t),s=a.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#Ut),r={annotationType:n.AnnotationEditorType.FREETEXT,color:s,fontSize:this.#jt,value:this.#zt,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};if(e)return r;if(this.annotationElementId&&!this.#Qt(r))return null;r.id=this.annotationElementId;return r}#Qt(e){const{value:t,fontSize:i,color:n,rect:s,pageIndex:a}=this.#Wt;return e.value!==t||e.fontSize!==i||e.rect.some(((e,t)=>Math.abs(e-s[t])>=1))||e.color.some(((e,t)=>e!==n[t]))||e.pageIndex!==a}#Xt(e=!1){if(!this.annotationElementId)return;this.#qt();if(!e&&(0===this.width||0===this.height)){setTimeout((()=>this.#Xt(!0)),0);return}const t=FreeTextEditor._internalPadding*this.parentScale;this.#Wt.rect=this.getRect(t,t)}}t.FreeTextEditor=FreeTextEditor},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.StampAnnotationElement=t.InkAnnotationElement=t.FreeTextAnnotationElement=t.AnnotationLayer=void 0;var n=i(1),s=i(6),a=i(3),r=i(30),o=i(31),l=i(32);const d=1e3,h=new WeakSet;function getRectDims(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class AnnotationElementFactory{static create(e){switch(e.data.annotationType){case n.AnnotationType.LINK:return new LinkAnnotationElement(e);case n.AnnotationType.TEXT:return new TextAnnotationElement(e);case n.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new TextWidgetAnnotationElement(e);case"Btn":return e.data.radioButton?new RadioButtonWidgetAnnotationElement(e):e.data.checkBox?new CheckboxWidgetAnnotationElement(e):new PushButtonWidgetAnnotationElement(e);case"Ch":return new ChoiceWidgetAnnotationElement(e);case"Sig":return new SignatureWidgetAnnotationElement(e)}return new WidgetAnnotationElement(e);case n.AnnotationType.POPUP:return new PopupAnnotationElement(e);case n.AnnotationType.FREETEXT:return new FreeTextAnnotationElement(e);case n.AnnotationType.LINE:return new LineAnnotationElement(e);case n.AnnotationType.SQUARE:return new SquareAnnotationElement(e);case n.AnnotationType.CIRCLE:return new CircleAnnotationElement(e);case n.AnnotationType.POLYLINE:return new PolylineAnnotationElement(e);case n.AnnotationType.CARET:return new CaretAnnotationElement(e);case n.AnnotationType.INK:return new InkAnnotationElement(e);case n.AnnotationType.POLYGON:return new PolygonAnnotationElement(e);case n.AnnotationType.HIGHLIGHT:return new HighlightAnnotationElement(e);case n.AnnotationType.UNDERLINE:return new UnderlineAnnotationElement(e);case n.AnnotationType.SQUIGGLY:return new SquigglyAnnotationElement(e);case n.AnnotationType.STRIKEOUT:return new StrikeOutAnnotationElement(e);case n.AnnotationType.STAMP:return new StampAnnotationElement(e);case n.AnnotationType.FILEATTACHMENT:return new FileAttachmentAnnotationElement(e);default:return new AnnotationElement(e)}}}class AnnotationElement{#Zt=!1;constructor(e,{isRenderable:t=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!1}={}){this.isRenderable=t;this.data=e.data;this.layer=e.layer;this.linkService=e.linkService;this.downloadManager=e.downloadManager;this.imageResourcesPath=e.imageResourcesPath;this.renderForms=e.renderForms;this.svgFactory=e.svgFactory;this.annotationStorage=e.annotationStorage;this.enableScripting=e.enableScripting;this.hasJSActions=e.hasJSActions;this._fieldObjects=e.fieldObjects;this.parent=e.parent;t&&(this.container=this._createContainer(i));n&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:i}){return!!(e?.str||t?.str||i?.str)}get hasPopupData(){return AnnotationElement._hasPopupData(this.data)}_createContainer(e){const{data:t,parent:{page:i,viewport:s}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",t.id);this instanceof WidgetAnnotationElement||(a.tabIndex=d);a.style.zIndex=this.parent.zIndex++;this.data.popupRef&&a.setAttribute("aria-haspopup","dialog");t.noRotate&&a.classList.add("norotate");const{pageWidth:r,pageHeight:o,pageX:l,pageY:h}=s.rawDims;if(!t.rect||this instanceof PopupAnnotationElement){const{rotation:e}=t;t.hasOwnCanvas||0===e||this.setRotation(e,a);return a}const{width:c,height:u}=getRectDims(t.rect),p=n.Util.normalizeRect([t.rect[0],i.view[3]-t.rect[1]+i.view[1],t.rect[2],i.view[3]-t.rect[3]+i.view[1]]);if(!e&&t.borderStyle.width>0){a.style.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,i=t.borderStyle.verticalCornerRadius;if(e>0||i>0){const t=`calc(${e}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;a.style.borderRadius=t}else if(this instanceof RadioButtonWidgetAnnotationElement){const e=`calc(${c}px * var(--scale-factor)) / calc(${u}px * var(--scale-factor))`;a.style.borderRadius=e}switch(t.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"}const s=t.borderColor||null;if(s){this.#Zt=!0;a.style.borderColor=n.Util.makeHexColor(0|s[0],0|s[1],0|s[2])}else a.style.borderWidth=0}a.style.left=100*(p[0]-l)/r+"%";a.style.top=100*(p[1]-h)/o+"%";const{rotation:g}=t;if(t.hasOwnCanvas||0===g){a.style.width=100*c/r+"%";a.style.height=100*u/o+"%"}else this.setRotation(g,a);return a}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims,{width:s,height:a}=getRectDims(this.data.rect);let r,o;if(e%180==0){r=100*s/i;o=100*a/n}else{r=100*a/i;o=100*s/n}t.style.width=`${r}%`;t.style.height=`${o}%`;t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const setColor=(e,t,i)=>{const n=i.detail[e],s=n[0],a=n.slice(1);i.target.style[t]=r.ColorConverters[`${s}_HTML`](a);this.annotationStorage.setValue(this.data.id,{[t]:r.ColorConverters[`${s}_rgb`](a)})};return(0,n.shadow)(this,"_commonActions",{display:e=>{const{display:t}=e.detail,i=t%2==1;this.container.style.visibility=i?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible";this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{setColor("bgColor","backgroundColor",e)},fillColor:e=>{setColor("fillColor","backgroundColor",e)},fgColor:e=>{setColor("fgColor","color",e)},textColor:e=>{setColor("textColor","color",e)},borderColor:e=>{setColor("borderColor","borderColor",e)},strokeColor:e=>{setColor("strokeColor","borderColor",e)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t);this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const i=this._commonActions;for(const n of Object.keys(t.detail)){const s=e[n]||i[n];s?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const i=this._commonActions;for(const[n,s]of Object.entries(t)){const a=i[n];if(a){a({detail:{[n]:s},target:e});delete t[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,i,n,s]=this.data.rect;if(1===e.length){const[,{x:a,y:r},{x:o,y:l}]=e[0];if(n===a&&s===r&&t===o&&i===l)return}const{style:a}=this.container;let r;if(this.#Zt){const{borderColor:e,borderWidth:t}=a;a.borderWidth=0;r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${t}">`];this.container.classList.add("hasBorder")}const o=n-t,l=s-i,{svgFactory:d}=this,h=d.createElement("svg");h.classList.add("quadrilateralsContainer");h.setAttribute("width",0);h.setAttribute("height",0);const c=d.createElement("defs");h.append(c);const u=d.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p);u.setAttribute("clipPathUnits","objectBoundingBox");c.append(u);for(const[,{x:i,y:n},{x:a,y:h}]of e){const e=d.createElement("rect"),c=(a-t)/o,p=(s-n)/l,g=(i-a)/o,f=(n-h)/l;e.setAttribute("x",c);e.setAttribute("y",p);e.setAttribute("width",g);e.setAttribute("height",f);u.append(e);r?.push(`<rect vector-effect="non-scaling-stroke" x="${c}" y="${p}" width="${g}" height="${f}"/>`)}if(this.#Zt){r.push("</g></svg>')");a.backgroundImage=r.join("")}this.container.append(h);this.container.style.clipPath=`url(#${p})`}_createPopup(){const{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");const i=new PopupAnnotationElement({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(i.render())}render(){(0,n.unreachable)("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[e];if(s)for(const{page:e,id:a,exportValues:r}of s){if(-1===e)continue;if(a===t)continue;const s="string"==typeof r?r:null,o=document.querySelector(`[data-element-id="${a}"]`);!o||h.has(o)?i.push({id:a,exportValue:s,domElement:o}):(0,n.warn)(`_getElementsByName - element not allowed: ${a}`)}return i}for(const n of document.getElementsByName(e)){const{exportValue:e}=n,s=n.getAttribute("data-element-id");s!==t&&(h.has(n)&&i.push({id:s,exportValue:e,domElement:n}))}return i}show(){this.container&&(this.container.hidden=!1);this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0);this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})}))}}class LinkAnnotationElement extends AnnotationElement{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0});this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;if(e.url){t.addLinkAttributes(i,e.url,e.newWindow);n=!0}else if(e.action){this._bindNamedAction(i,e.action);n=!0}else if(e.attachment){this._bindAttachment(i,e.attachment);n=!0}else if(e.setOCGState){this.#Jt(i,e.setOCGState);n=!0}else if(e.dest){this._bindLink(i,e.dest);n=!0}else{if(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions){this._bindJSAction(i,e);n=!0}if(e.resetForm){this._bindResetFormAction(i,e.resetForm);n=!0}else if(this.isTooltipOnly&&!n){this._bindLink(i,"");n=!0}}this.container.classList.add("linkAnnotation");n&&this.container.append(i);return this.container}#ei(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t);e.onclick=()=>{t&&this.linkService.goToDestination(t);return!1};(t||""===t)&&this.#ei()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeNamedAction(t);return!1};this.#ei()}_bindAttachment(e,t){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.downloadManager?.openOrDownloadData(this.container,t.content,t.filename);return!1};this.#ei()}#Jt(e,t){e.href=this.linkService.getAnchorUrl("");e.onclick=()=>{this.linkService.executeSetOCGState(t);return!1};this.#ei()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(t.actions)){const s=i.get(n);s&&(e[s]=()=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:n}});return!1})}e.onclick||(e.onclick=()=>!1);this.#ei()}_bindResetFormAction(e,t){const i=e.onclick;i||(e.href=this.linkService.getAnchorUrl(""));this.#ei();if(this._fieldObjects)e.onclick=()=>{i?.();const{fields:e,refs:s,include:a}=t,r=[];if(0!==e.length||0!==s.length){const t=new Set(s);for(const i of e){const e=this._fieldObjects[i]||[];for(const{id:i}of e)t.add(i)}for(const e of Object.values(this._fieldObjects))for(const i of e)t.has(i.id)===a&&r.push(i)}else for(const e of Object.values(this._fieldObjects))r.push(...e);const o=this.annotationStorage,l=[];for(const e of r){const{id:t}=e;l.push(t);switch(e.type){case"text":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}case"checkbox":case"radiobutton":{const i=e.defaultValue===e.exportValues;o.setValue(t,{value:i});break}case"combobox":case"listbox":{const i=e.defaultValue||"";o.setValue(t,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${t}"]`);i&&(h.has(i)?i.dispatchEvent(new Event("resetform")):(0,n.warn)(`_bindResetFormAction - element not allowed: ${t}`))}this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}});return!1};else{(0,n.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.');i||(e.onclick=()=>!1)}}}class TextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg";e.alt="[{{type}} Annotation]";e.dataset.l10nId="text_annotation_type";e.dataset.l10nArgs=JSON.stringify({type:this.data.name});!this.data.popupRef&&this.hasPopupData&&this._createPopup();this.container.append(e);return this.container}}class WidgetAnnotationElement extends AnnotationElement{render(){this.data.alternativeText&&(this.container.title=this.data.alternativeText);return this.container}showElementAndHideCanvas(e){if(this.data.hasOwnCanvas){"CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0);e.hidden=!1}}_getKeyModifier(e){const{isWin:t,isMac:i}=n.FeatureTest.platform;return t&&e.ctrlKey||i&&e.metaKey}_setEventListener(e,t,i,n,s){i.includes("mouse")?e.addEventListener(i,(e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(i,(e=>{if("blur"===i){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===i){if(t.focused)return;t.focused=!0}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(e)}})}))}_setEventListeners(e,t,i,n){for(const[s,a]of i)if("Action"===a||this.data.actions?.[a]){"Focus"!==a&&"Blur"!==a||(t||={focused:!1});this._setEventListener(e,t,s,a,n);"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null)}}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":n.Util.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const t=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,a=e.style;let r;const roundToOneDecimal=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(n.LINE_FACTOR*s))||1);r=Math.min(s,roundToOneDecimal(t/n.LINE_FACTOR))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,roundToOneDecimal(e/n.LINE_FACTOR))}a.fontSize=`calc(${r}px * var(--scale-factor))`;a.color=n.Util.makeHexColor(i[0],i[1],i[2]);null!==this.data.textAlignment&&(a.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required");e.setAttribute("aria-required",t)}}class TextWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,i,n){const s=this.annotationStorage;for(const a of this._getElementsByName(e.name,e.id)){a.domElement&&(a.domElement[t]=i);s.setValue(a.id,{[n]:i})}}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const n=e.getValue(t,{value:this.data.fieldValue});let s=n.value||"";const a=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;a&&s.length>a&&(s=s.slice(0,a));let r=n.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:s,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};if(this.data.multiLine){i=document.createElement("textarea");i.textContent=r??s;this.data.doNotScroll&&(i.style.overflowY="hidden")}else{i=document.createElement("input");i.type="text";i.setAttribute("value",r??s);this.data.doNotScroll&&(i.style.overflowX="hidden")}this.data.hasOwnCanvas&&(i.hidden=!0);h.add(i);i.setAttribute("data-element-id",t);i.disabled=this.data.readOnly;i.name=this.data.fieldName;i.tabIndex=d;this._setRequired(i,this.data.required);a&&(i.maxLength=a);i.addEventListener("input",(n=>{e.setValue(t,{value:n.target.value});this.setPropertyOnSiblings(i,"value",n.target.value,"value");o.formattedValue=null}));i.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue??"";i.value=o.userValue=t;o.formattedValue=null}));let blurListener=e=>{const{formattedValue:t}=o;null!=t&&(e.target.value=t);e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(e=>{if(o.focused)return;const{target:t}=e;o.userValue&&(t.value=o.userValue);o.lastCommittedValue=t.value;o.commitKey=1;o.focused=!0}));i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const n={value(i){o.userValue=i.detail.value??"";e.setValue(t,{value:o.userValue.toString()});i.target.value=o.userValue},formattedValue(i){const{formattedValue:n}=i.detail;o.formattedValue=n;null!=n&&i.target!==document.activeElement&&(i.target.value=n);e.setValue(t,{formattedValue:n})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:i=>{const{charLimit:n}=i.detail,{target:s}=i;if(0===n){s.removeAttribute("maxLength");return}s.setAttribute("maxLength",n);let a=o.userValue;if(a&&!(a.length<=n)){a=a.slice(0,n);s.value=o.userValue=a;e.setValue(t,{value:a});this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}})}}};this._dispatchEventFromSandbox(n,i)}));i.addEventListener("keydown",(e=>{o.commitKey=1;let i=-1;"Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(o.commitKey=3):i=2;if(-1===i)return;const{value:n}=e.target;if(o.lastCommittedValue!==n){o.lastCommittedValue=n;o.userValue=n;this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})}}));const n=blurListener;blurListener=null;i.addEventListener("blur",(e=>{if(!o.focused||!e.relatedTarget)return;o.focused=!1;const{value:i}=e.target;o.userValue=i;o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}});n(e)}));this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(e=>{o.lastCommittedValue=null;const{data:i,target:n}=e,{value:s,selectionStart:a,selectionEnd:r}=n;let l=a,d=r;switch(e.inputType){case"deleteWordBackward":{const e=s.substring(0,a).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{const e=s.substring(a).match(/^[^\w]*\w*/);e&&(d+=e[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(d+=1)}e.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:l,selEnd:d}})}));this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}blurListener&&i.addEventListener("blur",blurListener);if(this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/a;i.classList.add("comb");i.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else{i=document.createElement("div");i.textContent=this.data.fieldValue;i.style.verticalAlign="middle";i.style.display="table-cell"}this._setTextStyle(i);this._setBackgroundColor(i);this._setDefaultPropertiesFromJS(i);this.container.append(i);return this.container}}class SignatureWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class CheckboxWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,i=t.id;let n=e.getValue(i,{value:t.exportValue===t.fieldValue}).value;if("string"==typeof n){n="Off"!==n;e.setValue(i,{value:n})}this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");h.add(s);s.setAttribute("data-element-id",i);s.disabled=t.readOnly;this._setRequired(s,this.data.required);s.type="checkbox";s.name=t.fieldName;n&&s.setAttribute("checked",!0);s.setAttribute("exportValue",t.exportValue);s.tabIndex=d;s.addEventListener("change",(n=>{const{name:s,checked:a}=n.target;for(const n of this._getElementsByName(s,i)){const i=a&&n.exportValue===t.exportValue;n.domElement&&(n.domElement.checked=i);e.setValue(n.id,{value:i})}e.setValue(i,{value:a})}));s.addEventListener("resetform",(e=>{const i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue}));if(this.enableScripting&&this.hasJSActions){s.addEventListener("updatefromsandbox",(t=>{const n={value(t){t.target.checked="Off"!==t.detail.value;e.setValue(i,{value:t.target.checked})}};this._dispatchEventFromSandbox(n,t)}));this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}this._setBackgroundColor(s);this._setDefaultPropertiesFromJS(s);this.container.append(s);return this.container}}class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,i=t.id;let n=e.getValue(i,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof n){n=n!==t.buttonValue;e.setValue(i,{value:n})}const s=document.createElement("input");h.add(s);s.setAttribute("data-element-id",i);s.disabled=t.readOnly;this._setRequired(s,this.data.required);s.type="radio";s.name=t.fieldName;n&&s.setAttribute("checked",!0);s.tabIndex=d;s.addEventListener("change",(t=>{const{name:n,checked:s}=t.target;for(const t of this._getElementsByName(n,i))e.setValue(t.id,{value:!1});e.setValue(i,{value:s})}));s.addEventListener("resetform",(e=>{const i=t.defaultFieldValue;e.target.checked=null!=i&&i===t.buttonValue}));if(this.enableScripting&&this.hasJSActions){const n=t.buttonValue;s.addEventListener("updatefromsandbox",(t=>{const s={value:t=>{const s=n===t.detail.value;for(const n of this._getElementsByName(t.target.name)){const t=s&&n.id===i;n.domElement&&(n.domElement.checked=t);e.setValue(n.id,{value:t})}}};this._dispatchEventFromSandbox(s,t)}));this._setEventListeners(s,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}this._setBackgroundColor(s);this._setDefaultPropertiesFromJS(s);this.container.append(s);return this.container}}class PushButtonWidgetAnnotationElement extends LinkAnnotationElement{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");this.data.alternativeText&&(e.title=this.data.alternativeText);const t=e.lastChild;if(this.enableScripting&&this.hasJSActions&&t){this._setDefaultPropertiesFromJS(t);t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))}return e}}class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,i=e.getValue(t,{value:this.data.fieldValue}),n=document.createElement("select");h.add(n);n.setAttribute("data-element-id",t);n.disabled=this.data.readOnly;this._setRequired(n,this.data.required);n.name=this.data.fieldName;n.tabIndex=d;let s=this.data.combo&&this.data.options.length>0;if(!this.data.combo){n.size=this.data.options.length;this.data.multiSelect&&(n.multiple=!0)}n.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue;for(const e of n.options)e.selected=e.value===t}));for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue;t.value=e.exportValue;if(i.value.includes(e.exportValue)){t.setAttribute("selected",!0);s=!1}n.append(t)}let a=null;if(s){const e=document.createElement("option");e.value=" ";e.setAttribute("hidden",!0);e.setAttribute("selected",!0);n.prepend(e);a=()=>{e.remove();n.removeEventListener("input",a);a=null};n.addEventListener("input",a)}const getValue=e=>{const t=e?"value":"textContent",{options:i,multiple:s}=n;return s?Array.prototype.filter.call(i,(e=>e.selected)).map((e=>e[t])):-1===i.selectedIndex?null:i[i.selectedIndex][t]};let r=getValue(!1);const getItems=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};if(this.enableScripting&&this.hasJSActions){n.addEventListener("updatefromsandbox",(i=>{const s={value(i){a?.();const s=i.detail.value,o=new Set(Array.isArray(s)?s:[s]);for(const e of n.options)e.selected=o.has(e.value);e.setValue(t,{value:getValue(!0)});r=getValue(!1)},multipleSelection(e){n.multiple=!0},remove(i){const s=n.options,a=i.detail.remove;s[a].selected=!1;n.remove(a);if(s.length>0){-1===Array.prototype.findIndex.call(s,(e=>e.selected))&&(s[0].selected=!0)}e.setValue(t,{value:getValue(!0),items:getItems(i)});r=getValue(!1)},clear(i){for(;0!==n.length;)n.remove(0);e.setValue(t,{value:null,items:[]});r=getValue(!1)},insert(i){const{index:s,displayValue:a,exportValue:o}=i.detail.insert,l=n.children[s],d=document.createElement("option");d.textContent=a;d.value=o;l?l.before(d):n.append(d);e.setValue(t,{value:getValue(!0),items:getItems(i)});r=getValue(!1)},items(i){const{items:s}=i.detail;for(;0!==n.length;)n.remove(0);for(const e of s){const{displayValue:t,exportValue:i}=e,s=document.createElement("option");s.textContent=t;s.value=i;n.append(s)}n.options.length>0&&(n.options[0].selected=!0);e.setValue(t,{value:getValue(!0),items:getItems(i)});r=getValue(!1)},indices(i){const n=new Set(i.detail.indices);for(const e of i.target.options)e.selected=n.has(e.index);e.setValue(t,{value:getValue(!0)});r=getValue(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(s,i)}));n.addEventListener("input",(i=>{const n=getValue(!0);e.setValue(t,{value:n});i.preventDefault();this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,changeEx:n,willCommit:!1,commitKey:1,keyDown:!1}})}));this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))}else n.addEventListener("input",(function(i){e.setValue(t,{value:getValue(!0)})}));this.data.combo&&this._setTextStyle(n);this._setBackgroundColor(n);this._setDefaultPropertiesFromJS(n);this.container.append(n);return this.container}}class PopupAnnotationElement extends AnnotationElement{constructor(e){const{data:t,elements:i}=e;super(e,{isRenderable:AnnotationElement._hasPopupData(t)});this.elements=i}render(){this.container.classList.add("popupAnnotation");const e=new PopupElement({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const i of this.elements){i.popup=e;t.push(i.data.id);i.addHighlightArea()}this.container.setAttribute("aria-controls",t.map((e=>`${n.AnnotationPrefix}${e}`)).join(","));return this.container}}class PopupElement{#ti=null;#ii=this.#ni.bind(this);#si=this.#ai.bind(this);#ri=this.#oi.bind(this);#li=this.#di.bind(this);#Ut=null;#De=null;#hi=null;#ci=null;#ui=null;#pi=null;#gi=!1;#fi=null;#mi=null;#bi=null;#vi=null;#_i=!1;constructor({container:e,color:t,elements:i,titleObj:n,modificationDate:a,contentsObj:r,richText:o,parent:l,rect:d,parentRect:h,open:c}){this.#De=e;this.#vi=n;this.#hi=r;this.#bi=o;this.#ui=l;this.#Ut=t;this.#mi=d;this.#pi=h;this.#ci=i;const u=s.PDFDateString.toDateObject(a);u&&(this.#ti=l.l10n.get("annotation_date_string",{date:u.toLocaleDateString(),time:u.toLocaleTimeString()}));this.trigger=i.flatMap((e=>e.getElementsToTriggerPopup()));for(const e of this.trigger){e.addEventListener("click",this.#li);e.addEventListener("mouseenter",this.#ri);e.addEventListener("mouseleave",this.#si);e.classList.add("popupTriggerArea")}for(const e of i)e.container?.addEventListener("keydown",this.#ii);this.#De.hidden=!0;c&&this.#di()}render(){if(this.#fi)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:s,pageY:a}}}=this.#ui,r=this.#fi=document.createElement("div");r.className="popup";if(this.#Ut){const e=r.style.outlineColor=n.Util.makeHexColor(...this.#Ut);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))r.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;r.style.backgroundColor=n.Util.makeHexColor(...this.#Ut.map((t=>Math.floor(e*(255-t)+t))))}}const o=document.createElement("span");o.className="header";const d=document.createElement("h1");o.append(d);({dir:d.dir,str:d.textContent}=this.#vi);r.append(o);if(this.#ti){const e=document.createElement("span");e.classList.add("popupDate");this.#ti.then((t=>{e.textContent=t}));o.append(e)}const h=this.#hi,c=this.#bi;if(!c?.str||h?.str&&h.str!==c.str){const e=this._formatContents(h);r.append(e)}else{l.XfaLayer.render({xfaHtml:c.html,intent:"richText",div:r});r.lastChild.classList.add("richText","popupContent")}let u=!!this.#pi,p=u?this.#pi:this.#mi;for(const e of this.#ci)if(!p||null!==n.Util.intersect(e.data.rect,p)){p=e.data.rect;u=!0;break}const g=n.Util.normalizeRect([p[0],e[3]-p[1]+e[1],p[2],e[3]-p[3]+e[1]]),f=u?p[2]-p[0]+5:0,m=g[0]+f,b=g[1],{style:v}=this.#De;v.left=100*(m-s)/t+"%";v.top=100*(b-a)/i+"%";this.#De.append(r)}_formatContents({str:e,dir:t}){const i=document.createElement("p");i.classList.add("popupContent");i.dir=t;const n=e.split(/(?:\r\n?|\n)/);for(let e=0,t=n.length;e<t;++e){const s=n[e];i.append(document.createTextNode(s));e<t-1&&i.append(document.createElement("br"))}return i}#ni(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&this.#gi)&&this.#di()}#di(){this.#gi=!this.#gi;if(this.#gi){this.#oi();this.#De.addEventListener("click",this.#li);this.#De.addEventListener("keydown",this.#ii)}else{this.#ai();this.#De.removeEventListener("click",this.#li);this.#De.removeEventListener("keydown",this.#ii)}}#oi(){this.#fi||this.render();if(this.isVisible)this.#gi&&this.#De.classList.add("focused");else{this.#De.hidden=!1;this.#De.style.zIndex=parseInt(this.#De.style.zIndex)+1e3}}#ai(){this.#De.classList.remove("focused");if(!this.#gi&&this.isVisible){this.#De.hidden=!0;this.#De.style.zIndex=parseInt(this.#De.style.zIndex)-1e3}}forceHide(){this.#_i=this.isVisible;this.#_i&&(this.#De.hidden=!0)}maybeShow(){if(this.#_i){this.#_i=!1;this.#De.hidden=!1}}get isVisible(){return!1===this.#De.hidden}}class FreeTextAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.textContent=e.data.textContent;this.textPosition=e.data.textPosition;this.annotationEditorType=n.AnnotationEditorType.FREETEXT}render(){this.container.classList.add("freeTextAnnotation");if(this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent");e.setAttribute("role","comment");for(const t of this.textContent){const i=document.createElement("span");i.textContent=t;e.append(i)}this.container.append(e)}!this.data.popupRef&&this.hasPopupData&&this._createPopup();this._editOnDoubleClick();return this.container}}t.FreeTextAnnotationElement=FreeTextAnnotationElement;class LineAnnotationElement extends AnnotationElement{#wi=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:i}=getRectDims(e.rect),n=this.svgFactory.create(t,i,!0),s=this.#wi=this.svgFactory.createElement("svg:line");s.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]);s.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]);s.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]);s.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]);s.setAttribute("stroke-width",e.borderStyle.width||1);s.setAttribute("stroke","transparent");s.setAttribute("fill","transparent");n.append(s);this.container.append(n);!e.popupRef&&this.hasPopupData&&this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#wi}addHighlightArea(){this.container.classList.add("highlightArea")}}class SquareAnnotationElement extends AnnotationElement{#yi=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:i}=getRectDims(e.rect),n=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,a=this.#yi=this.svgFactory.createElement("svg:rect");a.setAttribute("x",s/2);a.setAttribute("y",s/2);a.setAttribute("width",t-s);a.setAttribute("height",i-s);a.setAttribute("stroke-width",s||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.append(a);this.container.append(n);!e.popupRef&&this.hasPopupData&&this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#yi}addHighlightArea(){this.container.classList.add("highlightArea")}}class CircleAnnotationElement extends AnnotationElement{#Si=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:i}=getRectDims(e.rect),n=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,a=this.#Si=this.svgFactory.createElement("svg:ellipse");a.setAttribute("cx",t/2);a.setAttribute("cy",i/2);a.setAttribute("rx",t/2-s/2);a.setAttribute("ry",i/2-s/2);a.setAttribute("stroke-width",s||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.append(a);this.container.append(n);!e.popupRef&&this.hasPopupData&&this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#Si}addHighlightArea(){this.container.classList.add("highlightArea")}}class PolylineAnnotationElement extends AnnotationElement{#Ai=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="polylineAnnotation";this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const e=this.data,{width:t,height:i}=getRectDims(e.rect),n=this.svgFactory.create(t,i,!0);let s=[];for(const t of e.vertices){const i=t.x-e.rect[0],n=e.rect[3]-t.y;s.push(i+","+n)}s=s.join(" ");const a=this.#Ai=this.svgFactory.createElement(this.svgElementName);a.setAttribute("points",s);a.setAttribute("stroke-width",e.borderStyle.width||1);a.setAttribute("stroke","transparent");a.setAttribute("fill","transparent");n.append(a);this.container.append(n);!e.popupRef&&this.hasPopupData&&this._createPopup();return this.container}getElementsToTriggerPopup(){return this.#Ai}addHighlightArea(){this.container.classList.add("highlightArea")}}class PolygonAnnotationElement extends PolylineAnnotationElement{constructor(e){super(e);this.containerClassName="polygonAnnotation";this.svgElementName="svg:polygon"}}class CaretAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("caretAnnotation");!this.data.popupRef&&this.hasPopupData&&this._createPopup();return this.container}}class InkAnnotationElement extends AnnotationElement{#Ei=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});this.containerClassName="inkAnnotation";this.svgElementName="svg:polyline";this.annotationEditorType=n.AnnotationEditorType.INK}render(){this.container.classList.add(this.containerClassName);const e=this.data,{width:t,height:i}=getRectDims(e.rect),n=this.svgFactory.create(t,i,!0);for(const t of e.inkLists){let i=[];for(const n of t){const t=n.x-e.rect[0],s=e.rect[3]-n.y;i.push(`${t},${s}`)}i=i.join(" ");const s=this.svgFactory.createElement(this.svgElementName);this.#Ei.push(s);s.setAttribute("points",i);s.setAttribute("stroke-width",e.borderStyle.width||1);s.setAttribute("stroke","transparent");s.setAttribute("fill","transparent");!e.popupRef&&this.hasPopupData&&this._createPopup();n.append(s)}this.container.append(n);return this.container}getElementsToTriggerPopup(){return this.#Ei}addHighlightArea(){this.container.classList.add("highlightArea")}}t.InkAnnotationElement=InkAnnotationElement;class HighlightAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){!this.data.popupRef&&this.hasPopupData&&this._createPopup();this.container.classList.add("highlightAnnotation");return this.container}}class UnderlineAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){!this.data.popupRef&&this.hasPopupData&&this._createPopup();this.container.classList.add("underlineAnnotation");return this.container}}class SquigglyAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){!this.data.popupRef&&this.hasPopupData&&this._createPopup();this.container.classList.add("squigglyAnnotation");return this.container}}class StrikeOutAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){!this.data.popupRef&&this.hasPopupData&&this._createPopup();this.container.classList.add("strikeoutAnnotation");return this.container}}class StampAnnotationElement extends AnnotationElement{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("stampAnnotation");!this.data.popupRef&&this.hasPopupData&&this._createPopup();return this.container}}t.StampAnnotationElement=StampAnnotationElement;class FileAttachmentAnnotationElement extends AnnotationElement{#Pi=null;constructor(e){super(e,{isRenderable:!0});const{filename:t,content:i}=this.data.file;this.filename=(0,s.getFilenameFromUrl)(t,!0);this.content=i;this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,filename:t,content:i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let i;if(t.hasAppearance||0===t.fillAlpha)i=document.createElement("div");else{i=document.createElement("img");i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`;t.fillAlpha&&t.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)}i.addEventListener("dblclick",this.#Ci.bind(this));this.#Pi=i;const{isMac:s}=n.FeatureTest.platform;e.addEventListener("keydown",(e=>{"Enter"===e.key&&(s?e.metaKey:e.ctrlKey)&&this.#Ci()}));!t.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea");e.append(i);return e}getElementsToTriggerPopup(){return this.#Pi}addHighlightArea(){this.container.classList.add("highlightArea")}#Ci(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}t.AnnotationLayer=class AnnotationLayer{#St=null;#xi=null;#Ti=new Map;constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,l10n:n,page:s,viewport:a}){this.div=e;this.#St=t;this.#xi=i;this.l10n=n;this.page=s;this.viewport=a;this.zIndex=0;this.l10n||=o.NullL10n}#Mi(e,t){const i=e.firstChild||e;i.id=`${n.AnnotationPrefix}${t}`;this.div.append(e);this.#St?.moveElementInDOM(this.div,e,i,!1)}async render(e){const{annotations:t}=e,i=this.div;(0,s.setLayerDimensions)(i,this.viewport);const r=new Map,o={data:null,layer:i,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new s.DOMSVGFactory,annotationStorage:e.annotationStorage||new a.AnnotationStorage,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=e.annotationType===n.AnnotationType.POPUP;if(t){const t=r.get(e.id);if(!t)continue;o.elements=t}else{const{width:t,height:i}=getRectDims(e.rect);if(t<=0||i<=0)continue}o.data=e;const i=AnnotationElementFactory.create(o);if(!i.isRenderable)continue;if(!t&&e.popupRef){const t=r.get(e.popupRef);t?t.push(i):r.set(e.popupRef,[i])}i.annotationEditorType>0&&this.#Ti.set(i.data.id,i);const s=i.render();e.hidden&&(s.style.visibility="hidden");this.#Mi(s,e.id)}this.#Ii();await this.l10n.translate(i)}update({viewport:e}){const t=this.div;this.viewport=e;(0,s.setLayerDimensions)(t,{rotation:e.rotation});this.#Ii();t.hidden=!1}#Ii(){if(!this.#xi)return;const e=this.div;for(const[t,i]of this.#xi){const n=e.querySelector(`[data-annotation-id="${t}"]`);if(!n)continue;const{firstChild:s}=n;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.before(i):n.append(i)}this.#xi.clear()}getEditableAnnotations(){return Array.from(this.#Ti.values())}getEditableAnnotation(e){return this.#Ti.get(e)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.ColorConverters=void 0;function makeColorComp(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function scaleAndClamp(e){return Math.max(0,Math.min(255,255*e))}t.ColorConverters=class ColorConverters{static CMYK_G([e,t,i,n]){return["G",1-Math.min(1,.3*e+.59*i+.11*t+n)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=scaleAndClamp(e),e,e]}static G_HTML([e]){const t=makeColorComp(e);return`#${t}${t}${t}`}static RGB_G([e,t,i]){return["G",.3*e+.59*t+.11*i]}static RGB_rgb(e){return e.map(scaleAndClamp)}static RGB_HTML(e){return`#${e.map(makeColorComp).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,i,n]){return["RGB",1-Math.min(1,e+n),1-Math.min(1,i+n),1-Math.min(1,t+n)]}static CMYK_rgb([e,t,i,n]){return[scaleAndClamp(1-Math.min(1,e+n)),scaleAndClamp(1-Math.min(1,i+n)),scaleAndClamp(1-Math.min(1,t+n))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,i]){const n=1-e,s=1-t,a=1-i;return["CMYK",n,s,a,Math.min(n,s,a)]}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.NullL10n=void 0;t.getL10nFallback=getL10nFallback;const i={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} × {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing…",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image",editor_alt_text_button_label:"Alt text",editor_alt_text_edit_button_label:"Edit alt text",editor_alt_text_decorative_tooltip:"Marked as decorative",print_progress_percent:"{{progress}}%"};function getL10nFallback(e,t){switch(e){case"find_match_count":e=`find_match_count[${1===t.total?"one":"other"}]`;break;case"find_match_count_limit":e=`find_match_count_limit[${1===t.limit?"one":"other"}]`}return i[e]||""}const n={getLanguage:async()=>"en-us",getDirection:async()=>"ltr",get:async(e,t=null,i=getL10nFallback(e,t))=>function formatL10nValue(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,i)=>i in t?t[i]:"{{"+i+"}}")):e}(i,t),async translate(e){}};t.NullL10n=n},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.XfaLayer=void 0;var n=i(25);t.XfaLayer=class XfaLayer{static setupStorage(e,t,i,n,s){const a=n.getValue(t,{value:null});switch(i.name){case"textarea":null!==a.value&&(e.textContent=a.value);if("print"===s)break;e.addEventListener("input",(e=>{n.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){a.value===i.attributes.xfaOn?e.setAttribute("checked",!0):a.value===i.attributes.xfaOff&&e.removeAttribute("checked");if("print"===s)break;e.addEventListener("change",(e=>{n.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{null!==a.value&&e.setAttribute("value",a.value);if("print"===s)break;e.addEventListener("input",(e=>{n.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==a.value){e.setAttribute("value",a.value);for(const e of i.children)e.attributes.value===a.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected}e.addEventListener("input",(e=>{const i=e.target.options,s=-1===i.selectedIndex?"":i[i.selectedIndex].value;n.setValue(t,{value:s})}))}}static setAttributes({html:e,element:t,storage:i=null,intent:n,linkService:s}){const{attributes:a}=t,r=e instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${n}`);for(const[t,i]of Object.entries(a))if(null!=i)switch(t){case"class":i.length&&e.setAttribute(t,i.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",i);break;case"style":Object.assign(e.style,i);break;case"textContent":e.textContent=i;break;default:(!r||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,i)}r&&s.addLinkAttributes(e,a.href,a.newWindow);i&&a.dataId&&this.setupStorage(e,a.dataId,t,i)}static render(e){const t=e.annotationStorage,i=e.linkService,s=e.xfaHtml,a=e.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:a,linkService:i});const o=[[s,-1,r]],l=e.div;l.append(r);if(e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=t}"richText"!==a&&l.setAttribute("class","xfaLayer xfaFont");const d=[];for(;o.length>0;){const[e,s,r]=o.at(-1);if(s+1===e.children.length){o.pop();continue}const l=e.children[++o.at(-1)[1]];if(null===l)continue;const{name:h}=l;if("#text"===h){const e=document.createTextNode(l.value);d.push(e);r.append(e);continue}const c=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,h):document.createElement(h);r.append(c);l.attributes&&this.setAttributes({html:c,element:l,storage:t,intent:a,linkService:i});if(l.children&&l.children.length>0)o.push([l,-1,c]);else if(l.value){const e=document.createTextNode(l.value);n.XfaText.shouldBuildText(h)&&d.push(e);c.append(e)}}for(const e of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:d}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t;e.div.hidden=!1}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.InkEditor=void 0;var n=i(1),s=i(4),a=i(29),r=i(6),o=i(5);class InkEditor extends s.AnnotationEditor{#ki=0;#Di=0;#Li=this.canvasPointermove.bind(this);#Fi=this.canvasPointerleave.bind(this);#Ri=this.canvasPointerup.bind(this);#Oi=this.canvasPointerdown.bind(this);#Ni=new Path2D;#Bi=!1;#Vi=!1;#Ui=!1;#zi=null;#Hi=0;#ji=0;#Wi=null;static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=1;static _type="ink";constructor(e){super({...e,name:"inkEditor"});this.color=e.color||null;this.thickness=e.thickness||null;this.opacity=e.opacity||null;this.paths=[];this.bezierPath2D=[];this.allRawPaths=[];this.currentPath=[];this.scaleFactor=1;this.translationX=this.translationY=0;this.x=0;this.y=0;this._willKeepAspectRatio=!0}static initialize(e){s.AnnotationEditor.initialize(e,{strings:["editor_ink_canvas_aria_label","editor_ink2_aria_label"]})}static updateDefaultParams(e,t){switch(e){case n.AnnotationEditorParamsType.INK_THICKNESS:InkEditor._defaultThickness=t;break;case n.AnnotationEditorParamsType.INK_COLOR:InkEditor._defaultColor=t;break;case n.AnnotationEditorParamsType.INK_OPACITY:InkEditor._defaultOpacity=t/100}}updateParams(e,t){switch(e){case n.AnnotationEditorParamsType.INK_THICKNESS:this.#Gi(t);break;case n.AnnotationEditorParamsType.INK_COLOR:this.#$t(t);break;case n.AnnotationEditorParamsType.INK_OPACITY:this.#$i(t)}}static get defaultPropertiesToUpdate(){return[[n.AnnotationEditorParamsType.INK_THICKNESS,InkEditor._defaultThickness],[n.AnnotationEditorParamsType.INK_COLOR,InkEditor._defaultColor||s.AnnotationEditor._defaultLineColor],[n.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*InkEditor._defaultOpacity)]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||InkEditor._defaultThickness],[n.AnnotationEditorParamsType.INK_COLOR,this.color||InkEditor._defaultColor||s.AnnotationEditor._defaultLineColor],[n.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??InkEditor._defaultOpacity))]]}#Gi(e){const t=this.thickness;this.addCommands({cmd:()=>{this.thickness=e;this.#qi()},undo:()=>{this.thickness=t;this.#qi()},mustExec:!0,type:n.AnnotationEditorParamsType.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#$t(e){const t=this.color;this.addCommands({cmd:()=>{this.color=e;this.#Xi()},undo:()=>{this.color=t;this.#Xi()},mustExec:!0,type:n.AnnotationEditorParamsType.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#$i(e){e/=100;const t=this.opacity;this.addCommands({cmd:()=>{this.opacity=e;this.#Xi()},undo:()=>{this.opacity=t;this.#Xi()},mustExec:!0,type:n.AnnotationEditorParamsType.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){if(!this.canvas){this.#Ki();this.#Yi()}if(!this.isAttachedToDOM){this.parent.add(this);this.#Qi()}this.#qi()}}}remove(){if(null!==this.canvas){this.isEmpty()||this.commit();this.canvas.width=this.canvas.height=0;this.canvas.remove();this.canvas=null;this.#zi.disconnect();this.#zi=null;super.remove()}}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this);super.setParent(e)}onScaleChanging(){const[e,t]=this.parentDimensions,i=this.width*e,n=this.height*t;this.setDimensions(i,n)}enableEditMode(){if(!this.#Bi&&null!==this.canvas){super.enableEditMode();this._isDraggable=!1;this.canvas.addEventListener("pointerdown",this.#Oi)}}disableEditMode(){if(this.isInEditMode()&&null!==this.canvas){super.disableEditMode();this._isDraggable=!this.isEmpty();this.div.classList.remove("editing");this.canvas.removeEventListener("pointerdown",this.#Oi)}}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#Zi(){const{parentRotation:e,parentDimensions:[t,i]}=this;switch(e){case 90:return[0,i,i,t];case 180:return[t,i,t,i];case 270:return[t,0,i,t];default:return[0,0,t,i]}}#Ji(){const{ctx:e,color:t,opacity:i,thickness:n,parentScale:s,scaleFactor:a}=this;e.lineWidth=n*s/a;e.lineCap="round";e.lineJoin="round";e.miterLimit=10;e.strokeStyle=`${t}${(0,o.opacityToHex)(i)}`}#en(e,t){this.canvas.addEventListener("contextmenu",r.noContextMenu);this.canvas.addEventListener("pointerleave",this.#Fi);this.canvas.addEventListener("pointermove",this.#Li);this.canvas.addEventListener("pointerup",this.#Ri);this.canvas.removeEventListener("pointerdown",this.#Oi);this.isEditing=!0;if(!this.#Ui){this.#Ui=!0;this.#Qi();this.thickness||=InkEditor._defaultThickness;this.color||=InkEditor._defaultColor||s.AnnotationEditor._defaultLineColor;this.opacity??=InkEditor._defaultOpacity}this.currentPath.push([e,t]);this.#Vi=!1;this.#Ji();this.#Wi=()=>{this.#tn();this.#Wi&&window.requestAnimationFrame(this.#Wi)};window.requestAnimationFrame(this.#Wi)}#in(e,t){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&t===n)return;const s=this.currentPath;let a=this.#Ni;s.push([e,t]);this.#Vi=!0;if(s.length<=2){a.moveTo(...s[0]);a.lineTo(e,t)}else{if(3===s.length){this.#Ni=a=new Path2D;a.moveTo(...s[0])}this.#nn(a,...s.at(-3),...s.at(-2),e,t)}}#sn(){if(0===this.currentPath.length)return;const e=this.currentPath.at(-1);this.#Ni.lineTo(...e)}#an(e,t){this.#Wi=null;e=Math.min(Math.max(e,0),this.canvas.width);t=Math.min(Math.max(t,0),this.canvas.height);this.#in(e,t);this.#sn();let i;if(1!==this.currentPath.length)i=this.#rn();else{const n=[e,t];i=[[n,n.slice(),n.slice(),n]]}const n=this.#Ni,s=this.currentPath;this.currentPath=[];this.#Ni=new Path2D;this.addCommands({cmd:()=>{this.allRawPaths.push(s);this.paths.push(i);this.bezierPath2D.push(n);this.rebuild()},undo:()=>{this.allRawPaths.pop();this.paths.pop();this.bezierPath2D.pop();if(0===this.paths.length)this.remove();else{if(!this.canvas){this.#Ki();this.#Yi()}this.#qi()}},mustExec:!0})}#tn(){if(!this.#Vi)return;this.#Vi=!1;const e=Math.ceil(this.thickness*this.parentScale),t=this.currentPath.slice(-3),i=t.map((e=>e[0])),n=t.map((e=>e[1])),{ctx:s}=(Math.min(...i),Math.max(...i),Math.min(...n),Math.max(...n),this);s.save();s.clearRect(0,0,this.canvas.width,this.canvas.height);for(const e of this.bezierPath2D)s.stroke(e);s.stroke(this.#Ni);s.restore()}#nn(e,t,i,n,s,a,r){const o=(t+n)/2,l=(i+s)/2,d=(n+a)/2,h=(s+r)/2;e.bezierCurveTo(o+2*(n-o)/3,l+2*(s-l)/3,d+2*(n-d)/3,h+2*(s-h)/3,d,h)}#rn(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const t=[];let i,[n,s]=e[0];for(i=1;i<e.length-2;i++){const[a,r]=e[i],[o,l]=e[i+1],d=(a+o)/2,h=(r+l)/2,c=[n+2*(a-n)/3,s+2*(r-s)/3],u=[d+2*(a-d)/3,h+2*(r-h)/3];t.push([[n,s],c,u,[d,h]]);[n,s]=[d,h]}const[a,r]=e[i],[o,l]=e[i+1],d=[n+2*(a-n)/3,s+2*(r-s)/3],h=[o+2*(a-o)/3,l+2*(r-l)/3];t.push([[n,s],d,h,[o,l]]);return t}#Xi(){if(this.isEmpty()){this.#on();return}this.#Ji();const{canvas:e,ctx:t}=this;t.setTransform(1,0,0,1,0,0);t.clearRect(0,0,e.width,e.height);this.#on();for(const e of this.bezierPath2D)t.stroke(e)}commit(){if(!this.#Bi){super.commit();this.isEditing=!1;this.disableEditMode();this.setInForeground();this.#Bi=!0;this.div.classList.add("disabled");this.#qi(!0);this.makeResizable();this.parent.addInkEditorIfNeeded(!0);this.moveInDOM();this.div.focus({preventScroll:!0})}}focusin(e){if(this._focusEventsAllowed){super.focusin(e);this.enableEditMode()}}canvasPointerdown(e){if(0===e.button&&this.isInEditMode()&&!this.#Bi){this.setInForeground();e.preventDefault();"mouse"!==e.type&&this.div.focus();this.#en(e.offsetX,e.offsetY)}}canvasPointermove(e){e.preventDefault();this.#in(e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault();this.#ln(e)}canvasPointerleave(e){this.#ln(e)}#ln(e){this.canvas.removeEventListener("pointerleave",this.#Fi);this.canvas.removeEventListener("pointermove",this.#Li);this.canvas.removeEventListener("pointerup",this.#Ri);this.canvas.addEventListener("pointerdown",this.#Oi);setTimeout((()=>{this.canvas.removeEventListener("contextmenu",r.noContextMenu)}),10);this.#an(e.offsetX,e.offsetY);this.addToAnnotationStorage();this.setInBackground()}#Ki(){this.canvas=document.createElement("canvas");this.canvas.width=this.canvas.height=0;this.canvas.className="inkEditorCanvas";s.AnnotationEditor._l10nPromise.get("editor_ink_canvas_aria_label").then((e=>this.canvas?.setAttribute("aria-label",e)));this.div.append(this.canvas);this.ctx=this.canvas.getContext("2d")}#Yi(){this.#zi=new ResizeObserver((e=>{const t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}));this.#zi.observe(this.div)}get isResizable(){return!this.isEmpty()&&this.#Bi}render(){if(this.div)return this.div;let e,t;if(this.width){e=this.x;t=this.y}super.render();s.AnnotationEditor._l10nPromise.get("editor_ink2_aria_label").then((e=>this.div?.setAttribute("aria-label",e)));const[i,n,a,r]=this.#Zi();this.setAt(i,n,0,0);this.setDims(a,r);this.#Ki();if(this.width){const[i,n]=this.parentDimensions;this.setAspectRatio(this.width*i,this.height*n);this.setAt(e*i,t*n,this.width*i,this.height*n);this.#Ui=!0;this.#Qi();this.setDims(this.width*i,this.height*n);this.#Xi();this.div.classList.add("disabled")}else{this.div.classList.add("editing");this.enableEditMode()}this.#Yi();return this.div}#Qi(){if(!this.#Ui)return;const[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e);this.canvas.height=Math.ceil(this.height*t);this.#on()}setDimensions(e,t){const i=Math.round(e),n=Math.round(t);if(this.#Hi===i&&this.#ji===n)return;this.#Hi=i;this.#ji=n;this.canvas.style.visibility="hidden";const[s,a]=this.parentDimensions;this.width=e/s;this.height=t/a;this.fixAndSetPosition();this.#Bi&&this.#dn(e,t);this.#Qi();this.#Xi();this.canvas.style.visibility="visible";this.fixDims()}#dn(e,t){const i=this.#hn(),n=(e-i)/this.#Di,s=(t-i)/this.#ki;this.scaleFactor=Math.min(n,s)}#on(){const e=this.#hn()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)}static#cn(e){const t=new Path2D;for(let i=0,n=e.length;i<n;i++){const[n,s,a,r]=e[i];0===i&&t.moveTo(...n);t.bezierCurveTo(s[0],s[1],a[0],a[1],r[0],r[1])}return t}static#un(e,t,i){const[n,s,a,r]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2){e[t]+=n;e[t+1]=r-e[t+1]}break;case 90:for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=e[t+1]+n;e[t+1]=i+s}break;case 180:for(let t=0,i=e.length;t<i;t+=2){e[t]=a-e[t];e[t+1]+=s}break;case 270:for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=a-e[t+1];e[t+1]=r-i}break;default:throw new Error("Invalid rotation")}return e}static#pn(e,t,i){const[n,s,a,r]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2){e[t]-=n;e[t+1]=r-e[t+1]}break;case 90:for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=e[t+1]-s;e[t+1]=i-n}break;case 180:for(let t=0,i=e.length;t<i;t+=2){e[t]=a-e[t];e[t+1]-=s}break;case 270:for(let t=0,i=e.length;t<i;t+=2){const i=e[t];e[t]=r-e[t+1];e[t+1]=a-i}break;default:throw new Error("Invalid rotation")}return e}#gn(e,t,i,n){const s=[],a=this.thickness/2,r=e*t+a,o=e*i+a;for(const t of this.paths){const i=[],a=[];for(let n=0,s=t.length;n<s;n++){const[l,d,h,c]=t[n],u=e*l[0]+r,p=e*l[1]+o,g=e*d[0]+r,f=e*d[1]+o,m=e*h[0]+r,b=e*h[1]+o,v=e*c[0]+r,_=e*c[1]+o;if(0===n){i.push(u,p);a.push(u,p)}i.push(g,f,m,b,v,_);a.push(g,f);n===s-1&&a.push(v,_)}s.push({bezier:InkEditor.#un(i,n,this.rotation),points:InkEditor.#un(a,n,this.rotation)})}return s}#fn(){let e=1/0,t=-1/0,i=1/0,s=-1/0;for(const a of this.paths)for(const[r,o,l,d]of a){const a=n.Util.bezierBoundingBox(...r,...o,...l,...d);e=Math.min(e,a[0]);i=Math.min(i,a[1]);t=Math.max(t,a[2]);s=Math.max(s,a[3])}return[e,i,t,s]}#hn(){return this.#Bi?Math.ceil(this.thickness*this.parentScale):0}#qi(e=!1){if(this.isEmpty())return;if(!this.#Bi){this.#Xi();return}const t=this.#fn(),i=this.#hn();this.#Di=Math.max(s.AnnotationEditor.MIN_SIZE,t[2]-t[0]);this.#ki=Math.max(s.AnnotationEditor.MIN_SIZE,t[3]-t[1]);const n=Math.ceil(i+this.#Di*this.scaleFactor),a=Math.ceil(i+this.#ki*this.scaleFactor),[r,o]=this.parentDimensions;this.width=n/r;this.height=a/o;this.setAspectRatio(n,a);const l=this.translationX,d=this.translationY;this.translationX=-t[0];this.translationY=-t[1];this.#Qi();this.#Xi();this.#Hi=n;this.#ji=a;this.setDims(n,a);const h=e?i/this.scaleFactor/2:0;this.translate(l-this.translationX-h,d-this.translationY-h)}static deserialize(e,t,i){if(e instanceof a.InkAnnotationElement)return null;const r=super.deserialize(e,t,i);r.thickness=e.thickness;r.color=n.Util.makeHexColor(...e.color);r.opacity=e.opacity;const[o,l]=r.pageDimensions,d=r.width*o,h=r.height*l,c=r.parentScale,u=e.thickness/2;r.#Bi=!0;r.#Hi=Math.round(d);r.#ji=Math.round(h);const{paths:p,rect:g,rotation:f}=e;for(let{bezier:e}of p){e=InkEditor.#pn(e,g,f);const t=[];r.paths.push(t);let i=c*(e[0]-u),n=c*(e[1]-u);for(let s=2,a=e.length;s<a;s+=6){const a=c*(e[s]-u),r=c*(e[s+1]-u),o=c*(e[s+2]-u),l=c*(e[s+3]-u),d=c*(e[s+4]-u),h=c*(e[s+5]-u);t.push([[i,n],[a,r],[o,l],[d,h]]);i=d;n=h}const s=this.#cn(t);r.bezierPath2D.push(s)}const m=r.#fn();r.#Di=Math.max(s.AnnotationEditor.MIN_SIZE,m[2]-m[0]);r.#ki=Math.max(s.AnnotationEditor.MIN_SIZE,m[3]-m[1]);r.#dn(d,h);return r}serialize(){if(this.isEmpty())return null;const e=this.getRect(0,0),t=s.AnnotationEditor._colorManager.convert(this.ctx.strokeStyle);return{annotationType:n.AnnotationEditorType.INK,color:t,thickness:this.thickness,opacity:this.opacity,paths:this.#gn(this.scaleFactor/this.parentScale,this.translationX,this.translationY,e),pageIndex:this.pageIndex,rect:e,rotation:this.rotation,structTreeParentId:this._structTreeParentId}}}t.InkEditor=InkEditor},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.StampEditor=void 0;var n=i(1),s=i(4),a=i(6),r=i(29);class StampEditor extends s.AnnotationEditor{#mn=null;#bn=null;#vn=null;#_n=null;#wn=null;#yn=null;#zi=null;#Sn=null;#An=!1;#En=!1;static _type="stamp";constructor(e){super({...e,name:"stampEditor"});this.#_n=e.bitmapUrl;this.#wn=e.bitmapFile}static initialize(e){s.AnnotationEditor.initialize(e)}static get supportedTypes(){return(0,n.shadow)(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((e=>`image/${e}`)))}static get supportedTypesStr(){return(0,n.shadow)(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(n.AnnotationEditorType.STAMP,{bitmapFile:e.getAsFile()})}#Pn(e,t=!1){if(e){this.#mn=e.bitmap;if(!t){this.#bn=e.id;this.#An=e.isSvg}this.#Ki()}else this.remove()}#Cn(){this.#vn=null;this._uiManager.enableWaiting(!1);this.#yn&&this.div.focus()}#xn(){if(this.#bn){this._uiManager.enableWaiting(!0);this._uiManager.imageManager.getFromId(this.#bn).then((e=>this.#Pn(e,!0))).finally((()=>this.#Cn()));return}if(this.#_n){const e=this.#_n;this.#_n=null;this._uiManager.enableWaiting(!0);this.#vn=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#Pn(e))).finally((()=>this.#Cn()));return}if(this.#wn){const e=this.#wn;this.#wn=null;this._uiManager.enableWaiting(!0);this.#vn=this._uiManager.imageManager.getFromFile(e).then((e=>this.#Pn(e))).finally((()=>this.#Cn()));return}const e=document.createElement("input");e.type="file";e.accept=StampEditor.supportedTypesStr;this.#vn=new Promise((t=>{e.addEventListener("change",(async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this.#Pn(t)}else this.remove();t()}));e.addEventListener("cancel",(()=>{this.remove();t()}))})).finally((()=>this.#Cn()));e.click()}remove(){if(this.#bn){this.#mn=null;this._uiManager.imageManager.deleteId(this.#bn);this.#yn?.remove();this.#yn=null;this.#zi?.disconnect();this.#zi=null}super.remove()}rebuild(){if(this.parent){super.rebuild();if(null!==this.div){this.#bn&&this.#xn();this.isAttachedToDOM||this.parent.add(this)}}else this.#bn&&this.#xn()}onceAdded(){this._isDraggable=!0;this.div.focus()}isEmpty(){return!(this.#vn||this.#mn||this.#_n||this.#wn)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width){e=this.x;t=this.y}super.render();this.div.hidden=!0;this.#mn?this.#Ki():this.#xn();if(this.width){const[i,n]=this.parentDimensions;this.setAt(e*i,t*n,this.width*i,this.height*n)}return this.div}#Ki(){const{div:e}=this;let{width:t,height:i}=this.#mn;const[n,s]=this.pageDimensions,a=.75;if(this.width){t=this.width*n;i=this.height*s}else if(t>a*n||i>a*s){const e=Math.min(a*n/t,a*s/i);t*=e;i*=e}const[r,o]=this.parentDimensions;this.setDims(t*r/n,i*o/s);this._uiManager.enableWaiting(!1);const l=this.#yn=document.createElement("canvas");e.append(l);e.hidden=!1;this.#Tn(t,i);this.#Yi();if(!this.#En){this.parent.addUndoableEditor(this);this.#En=!0}this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"inserted_image"}}});this.addAltTextButton()}#Mn(e,t){const[i,n]=this.parentDimensions;this.width=e/i;this.height=t/n;this.setDims(e,t);this._initialOptions?.isCentered?this.center():this.fixAndSetPosition();this._initialOptions=null;null!==this.#Sn&&clearTimeout(this.#Sn);this.#Sn=setTimeout((()=>{this.#Sn=null;this.#Tn(e,t)}),200)}#In(e,t){const{width:i,height:n}=this.#mn;let s=i,a=n,r=this.#mn;for(;s>2*e||a>2*t;){const i=s,n=a;s>2*e&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2));a>2*t&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(s,a);o.getContext("2d").drawImage(r,0,0,i,n,0,0,s,a);r=o.transferToImageBitmap()}return r}#Tn(e,t){e=Math.ceil(e);t=Math.ceil(t);const i=this.#yn;if(!i||i.width===e&&i.height===t)return;i.width=e;i.height=t;const n=this.#An?this.#mn:this.#In(e,t),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter;s.drawImage(n,0,0,n.width,n.height,0,0,e,t)}#kn(e){if(e){if(this.#An){const e=this._uiManager.imageManager.getSvgUrl(this.#bn);if(e)return e}const e=document.createElement("canvas");({width:e.width,height:e.height}=this.#mn);e.getContext("2d").drawImage(this.#mn,0,0);return e.toDataURL()}if(this.#An){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*a.PixelsPerInch.PDF_TO_CSS_UNITS),n=Math.round(this.height*t*a.PixelsPerInch.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,n);s.getContext("2d").drawImage(this.#mn,0,0,this.#mn.width,this.#mn.height,0,0,i,n);return s.transferToImageBitmap()}return structuredClone(this.#mn)}#Yi(){this.#zi=new ResizeObserver((e=>{const t=e[0].contentRect;t.width&&t.height&&this.#Mn(t.width,t.height)}));this.#zi.observe(this.div)}static deserialize(e,t,i){if(e instanceof r.StampAnnotationElement)return null;const n=super.deserialize(e,t,i),{rect:s,bitmapUrl:a,bitmapId:o,isSvg:l,accessibilityData:d}=e;o&&i.imageManager.isValidId(o)?n.#bn=o:n.#_n=a;n.#An=l;const[h,c]=n.pageDimensions;n.width=(s[2]-s[0])/h;n.height=(s[3]-s[1])/c;d&&(n.altTextData=d);return n}serialize(e=!1,t=null){if(this.isEmpty())return null;const i={annotationType:n.AnnotationEditorType.STAMP,bitmapId:this.#bn,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#An,structTreeParentId:this._structTreeParentId};if(e){i.bitmapUrl=this.#kn(!0);i.accessibilityData=this.altTextData;return i}const{decorative:s,altText:a}=this.altTextData;!s&&a&&(i.accessibilityData={type:"Figure",alt:a});if(null===t)return i;t.stamps||=new Map;const r=this.#An?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(t.stamps.has(this.#bn)){if(this.#An){const e=t.stamps.get(this.#bn);if(r>e.area){e.area=r;e.serialized.bitmap.close();e.serialized.bitmap=this.#kn(!1)}}}else{t.stamps.set(this.#bn,{area:r,serialized:i});i.bitmap=this.#kn(!1)}return i}}t.StampEditor=StampEditor}],__webpack_module_cache__={};function __w_pdfjs_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var i=__webpack_module_cache__[e]={exports:{}};__webpack_modules__[e](i,i.exports,__w_pdfjs_require__);return i.exports}var __webpack_exports__={};(()=>{var e=__webpack_exports__;Object.defineProperty(e,"__esModule",{value:!0});Object.defineProperty(e,"AbortException",{enumerable:!0,get:function(){return t.AbortException}});Object.defineProperty(e,"AnnotationEditorLayer",{enumerable:!0,get:function(){return a.AnnotationEditorLayer}});Object.defineProperty(e,"AnnotationEditorParamsType",{enumerable:!0,get:function(){return t.AnnotationEditorParamsType}});Object.defineProperty(e,"AnnotationEditorType",{enumerable:!0,get:function(){return t.AnnotationEditorType}});Object.defineProperty(e,"AnnotationEditorUIManager",{enumerable:!0,get:function(){return r.AnnotationEditorUIManager}});Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return o.AnnotationLayer}});Object.defineProperty(e,"AnnotationMode",{enumerable:!0,get:function(){return t.AnnotationMode}});Object.defineProperty(e,"CMapCompressionType",{enumerable:!0,get:function(){return t.CMapCompressionType}});Object.defineProperty(e,"DOMSVGFactory",{enumerable:!0,get:function(){return n.DOMSVGFactory}});Object.defineProperty(e,"FeatureTest",{enumerable:!0,get:function(){return t.FeatureTest}});Object.defineProperty(e,"GlobalWorkerOptions",{enumerable:!0,get:function(){return l.GlobalWorkerOptions}});Object.defineProperty(e,"ImageKind",{enumerable:!0,get:function(){return t.ImageKind}});Object.defineProperty(e,"InvalidPDFException",{enumerable:!0,get:function(){return t.InvalidPDFException}});Object.defineProperty(e,"MissingPDFException",{enumerable:!0,get:function(){return t.MissingPDFException}});Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return t.OPS}});Object.defineProperty(e,"PDFDataRangeTransport",{enumerable:!0,get:function(){return i.PDFDataRangeTransport}});Object.defineProperty(e,"PDFDateString",{enumerable:!0,get:function(){return n.PDFDateString}});Object.defineProperty(e,"PDFWorker",{enumerable:!0,get:function(){return i.PDFWorker}});Object.defineProperty(e,"PasswordResponses",{enumerable:!0,get:function(){return t.PasswordResponses}});Object.defineProperty(e,"PermissionFlag",{enumerable:!0,get:function(){return t.PermissionFlag}});Object.defineProperty(e,"PixelsPerInch",{enumerable:!0,get:function(){return n.PixelsPerInch}});Object.defineProperty(e,"PromiseCapability",{enumerable:!0,get:function(){return t.PromiseCapability}});Object.defineProperty(e,"RenderingCancelledException",{enumerable:!0,get:function(){return n.RenderingCancelledException}});Object.defineProperty(e,"SVGGraphics",{enumerable:!0,get:function(){return i.SVGGraphics}});Object.defineProperty(e,"UnexpectedResponseException",{enumerable:!0,get:function(){return t.UnexpectedResponseException}});Object.defineProperty(e,"Util",{enumerable:!0,get:function(){return t.Util}});Object.defineProperty(e,"VerbosityLevel",{enumerable:!0,get:function(){return t.VerbosityLevel}});Object.defineProperty(e,"XfaLayer",{enumerable:!0,get:function(){return d.XfaLayer}});Object.defineProperty(e,"build",{enumerable:!0,get:function(){return i.build}});Object.defineProperty(e,"createValidAbsoluteUrl",{enumerable:!0,get:function(){return t.createValidAbsoluteUrl}});Object.defineProperty(e,"getDocument",{enumerable:!0,get:function(){return i.getDocument}});Object.defineProperty(e,"getFilenameFromUrl",{enumerable:!0,get:function(){return n.getFilenameFromUrl}});Object.defineProperty(e,"getPdfFilenameFromUrl",{enumerable:!0,get:function(){return n.getPdfFilenameFromUrl}});Object.defineProperty(e,"getXfaPageViewport",{enumerable:!0,get:function(){return n.getXfaPageViewport}});Object.defineProperty(e,"isDataScheme",{enumerable:!0,get:function(){return n.isDataScheme}});Object.defineProperty(e,"isPdfFile",{enumerable:!0,get:function(){return n.isPdfFile}});Object.defineProperty(e,"loadScript",{enumerable:!0,get:function(){return n.loadScript}});Object.defineProperty(e,"noContextMenu",{enumerable:!0,get:function(){return n.noContextMenu}});Object.defineProperty(e,"normalizeUnicode",{enumerable:!0,get:function(){return t.normalizeUnicode}});Object.defineProperty(e,"renderTextLayer",{enumerable:!0,get:function(){return s.renderTextLayer}});Object.defineProperty(e,"setLayerDimensions",{enumerable:!0,get:function(){return n.setLayerDimensions}});Object.defineProperty(e,"shadow",{enumerable:!0,get:function(){return t.shadow}});Object.defineProperty(e,"updateTextLayer",{enumerable:!0,get:function(){return s.updateTextLayer}});Object.defineProperty(e,"version",{enumerable:!0,get:function(){return i.version}});var t=__w_pdfjs_require__(1),i=__w_pdfjs_require__(2),n=__w_pdfjs_require__(6),s=__w_pdfjs_require__(26),a=__w_pdfjs_require__(27),r=__w_pdfjs_require__(5),o=__w_pdfjs_require__(29),l=__w_pdfjs_require__(14),d=__w_pdfjs_require__(32)})();return __webpack_exports__})()));
/**
 * @licstart The following is the entire license notice for the
 * JavaScript code in this page
 *
 * Copyright 2023 Mozilla Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @licend The above is the entire license notice for the
 * JavaScript code in this page
 */(()=>{"use strict";var e=[,(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GenericCom=void 0;var n=i(2),s=i(42),a=i(43),r=i(44),o=i(46);t.GenericCom={};class GenericPreferences extends s.BasePreferences{async _writeToStorage(e){localStorage.setItem("pdfjs.preferences",JSON.stringify(e))}async _readFromStorage(e){return JSON.parse(localStorage.getItem("pdfjs.preferences"))}}class GenericExternalServices extends n.DefaultExternalServices{static createDownloadManager(){return new a.DownloadManager}static createPreferences(){return new GenericPreferences}static createL10n({locale:e="en-US"}){return new r.GenericL10n(e)}static createScripting({sandboxBundleSrc:e}){return new o.GenericScripting(e)}}n.PDFViewerApplication.externalServices=GenericExternalServices},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFViewerApplication=t.PDFPrintServiceFactory=t.DefaultExternalServices=void 0;var n=i(3),s=i(4),a=i(5),r=i(6),o=i(7),l=i(8),d=i(9),h=i(10),c=i(11),u=i(12),p=i(14),g=i(16),f=i(17),m=i(18),b=i(20),v=i(21),_=i(22),w=i(23),y=i(24),S=i(25),A=i(26),E=i(27),P=i(29),C=i(39),x=i(40),T=i(41);const M=1e3,I=-1,k=1,D={AUTOMATIC:0,LIGHT:1,DARK:2};class DefaultExternalServices{constructor(){throw new Error("Cannot initialize DefaultExternalServices.")}static updateFindControlState(e){}static updateFindMatchesCount(e){}static initPassiveLoading(e){}static reportTelemetry(e){}static createDownloadManager(){throw new Error("Not implemented: createDownloadManager")}static createPreferences(){throw new Error("Not implemented: createPreferences")}static createL10n(e){throw new Error("Not implemented: createL10n")}static createScripting(e){throw new Error("Not implemented: createScripting")}static get supportsPinchToZoom(){return(0,s.shadow)(this,"supportsPinchToZoom",!0)}static get supportsIntegratedFind(){return(0,s.shadow)(this,"supportsIntegratedFind",!1)}static get supportsDocumentFonts(){return(0,s.shadow)(this,"supportsDocumentFonts",!0)}static get supportedMouseWheelZoomModifierKeys(){return(0,s.shadow)(this,"supportedMouseWheelZoomModifierKeys",{ctrlKey:!0,metaKey:!0})}static get isInAutomation(){return(0,s.shadow)(this,"isInAutomation",!1)}static updateEditorStates(e){throw new Error("Not implemented: updateEditorStates")}static get canvasMaxAreaInBytes(){return(0,s.shadow)(this,"canvasMaxAreaInBytes",-1)}static getNimbusExperimentData(){return(0,s.shadow)(this,"getNimbusExperimentData",Promise.resolve(null))}}t.DefaultExternalServices=DefaultExternalServices;const L={initialBookmark:document.location.hash.substring(1),_initializedCapability:new s.PromiseCapability,appConfig:null,pdfDocument:null,pdfLoadingTask:null,printService:null,pdfViewer:null,pdfThumbnailViewer:null,pdfRenderingQueue:null,pdfPresentationMode:null,pdfDocumentProperties:null,pdfLinkService:null,pdfHistory:null,pdfSidebar:null,pdfOutlineViewer:null,pdfAttachmentViewer:null,pdfLayerViewer:null,pdfCursorTools:null,pdfScriptingManager:null,store:null,downloadManager:null,overlayManager:null,preferences:null,toolbar:null,secondaryToolbar:null,eventBus:null,l10n:null,annotationEditorParams:null,isInitialViewSet:!1,downloadComplete:!1,isViewerEmbedded:window.parent!==window,url:"",baseUrl:"",_downloadUrl:"",externalServices:DefaultExternalServices,_boundEvents:Object.create(null),documentInfo:null,metadata:null,_contentDispositionFilename:null,_contentLength:null,_saveInProgress:!1,_wheelUnusedTicks:0,_wheelUnusedFactor:1,_touchUnusedTicks:0,_touchUnusedFactor:1,_PDFBug:null,_hasAnnotationEditors:!1,_title:document.title,_printAnnotationStoragePromise:null,_touchInfo:null,_isCtrlKeyDown:!1,_nimbusDataPromise:null,async initialize(e){this.preferences=this.externalServices.createPreferences();this.appConfig=e;await this._initializeOptions();this._forceCssTheme();await this._initializeL10n();this.isViewerEmbedded&&a.AppOptions.get("externalLinkTarget")===o.LinkTarget.NONE&&a.AppOptions.set("externalLinkTarget",o.LinkTarget.TOP);await this._initializeViewerComponents();this.bindEvents();this.bindWindowEvents();const t=e.appContainer||document.documentElement;this.l10n.translate(t).then((()=>{this.eventBus.dispatch("localized",{source:this})}));this._initializedCapability.resolve()},async _initializeOptions(){if(a.AppOptions.get("disablePreferences"))a.AppOptions.get("pdfBugEnabled")&&await this._parseHashParams();else{a.AppOptions._hasUserOptions()&&console.warn('_initializeOptions: The Preferences may override manually set AppOptions; please use the "disablePreferences"-option in order to prevent that.');try{a.AppOptions.setAll(await this.preferences.getAll())}catch(e){console.error(`_initializeOptions: "${e.message}".`)}a.AppOptions.get("pdfBugEnabled")&&await this._parseHashParams()}},async _parseHashParams(){const e=document.location.hash.substring(1);if(!e)return;const{mainContainer:t,viewerContainer:i}=this.appConfig,r=(0,n.parseQueryString)(e);if("true"===r.get("disableworker"))try{await async function loadFakeWorker(){s.GlobalWorkerOptions.workerSrc||=a.AppOptions.get("workerSrc");await(0,s.loadScript)(s.PDFWorker.workerSrc)}()}catch(e){console.error(`_parseHashParams: "${e.message}".`)}r.has("disablerange")&&a.AppOptions.set("disableRange","true"===r.get("disablerange"));r.has("disablestream")&&a.AppOptions.set("disableStream","true"===r.get("disablestream"));r.has("disableautofetch")&&a.AppOptions.set("disableAutoFetch","true"===r.get("disableautofetch"));r.has("disablefontface")&&a.AppOptions.set("disableFontFace","true"===r.get("disablefontface"));r.has("disablehistory")&&a.AppOptions.set("disableHistory","true"===r.get("disablehistory"));r.has("verbosity")&&a.AppOptions.set("verbosity",0|r.get("verbosity"));if(r.has("textlayer"))switch(r.get("textlayer")){case"off":a.AppOptions.set("textLayerMode",n.TextLayerMode.DISABLE);break;case"visible":case"shadow":case"hover":i.classList.add(`textLayer-${r.get("textlayer")}`);try{await loadPDFBug(this);this._PDFBug.loadCSS()}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}if(r.has("pdfbug")){a.AppOptions.set("pdfBug",!0);a.AppOptions.set("fontExtraProperties",!0);const e=r.get("pdfbug").split(",");try{await loadPDFBug(this);this._PDFBug.init(t,e)}catch(e){console.error(`_parseHashParams: "${e.message}".`)}}r.has("locale")&&a.AppOptions.set("locale",r.get("locale"))},async _initializeL10n(){this.l10n=this.externalServices.createL10n({locale:a.AppOptions.get("locale")});const e=await this.l10n.getDirection();document.getElementsByTagName("html")[0].dir=e},_forceCssTheme(){const e=a.AppOptions.get("viewerCssTheme");if(e!==D.AUTOMATIC&&Object.values(D).includes(e))try{const t=document.styleSheets[0],i=t?.cssRules||[];for(let n=0,s=i.length;n<s;n++){const s=i[n];if(s instanceof CSSMediaRule&&"(prefers-color-scheme: dark)"===s.media?.[0]){if(e===D.LIGHT){t.deleteRule(n);return}const i=/^@media \(prefers-color-scheme: dark\) {\n\s*([\w\s-.,:;/\\{}()]+)\n}$/.exec(s.cssText);if(i?.[1]){t.deleteRule(n);t.insertRule(i[1],n)}return}}}catch(e){console.error(`_forceCssTheme: "${e?.message}".`)}},async _initializeViewerComponents(){const{appConfig:e,externalServices:t,l10n:i}=this,T=t.isInAutomation?new r.AutomationEventBus:new r.EventBus;this.eventBus=T;this.overlayManager=new h.OverlayManager;const M=new y.PDFRenderingQueue;M.onIdle=this._cleanup.bind(this);this.pdfRenderingQueue=M;const I=new o.PDFLinkService({eventBus:T,externalLinkTarget:a.AppOptions.get("externalLinkTarget"),externalLinkRel:a.AppOptions.get("externalLinkRel"),ignoreDestinationZoom:a.AppOptions.get("ignoreDestinationZoom")});this.pdfLinkService=I;const k=t.createDownloadManager();this.downloadManager=k;const D=new m.PDFFindController({linkService:I,eventBus:T,updateMatchesCountOnProgress:!0});this.findController=D;const L=new S.PDFScriptingManager({eventBus:T,sandboxBundleSrc:a.AppOptions.get("sandboxBundleSrc"),externalServices:t,docProperties:this._scriptingDocProperties.bind(this)});this.pdfScriptingManager=L;const F=e.mainContainer,R=e.viewerContainer,O=a.AppOptions.get("annotationEditorMode"),N=a.AppOptions.get("isOffscreenCanvasSupported")&&s.FeatureTest.isOffscreenCanvasSupported,B=a.AppOptions.get("forcePageColors")||window.matchMedia("(forced-colors: active)").matches?{background:a.AppOptions.get("pageColorsBackground"),foreground:a.AppOptions.get("pageColorsForeground")}:null,V=e.altTextDialog?new l.AltTextManager(e.altTextDialog,F,this.overlayManager,T):null,U=new P.PDFViewer({container:F,viewer:R,eventBus:T,renderingQueue:M,linkService:I,downloadManager:k,altTextManager:V,findController:D,scriptingManager:a.AppOptions.get("enableScripting")&&L,l10n:i,textLayerMode:a.AppOptions.get("textLayerMode"),annotationMode:a.AppOptions.get("annotationMode"),annotationEditorMode:O,imageResourcesPath:a.AppOptions.get("imageResourcesPath"),enablePrintAutoRotate:a.AppOptions.get("enablePrintAutoRotate"),isOffscreenCanvasSupported:N,maxCanvasPixels:a.AppOptions.get("maxCanvasPixels"),enablePermissions:a.AppOptions.get("enablePermissions"),pageColors:B});this.pdfViewer=U;M.setViewer(U);I.setViewer(U);L.setViewer(U);if(e.sidebar?.thumbnailView){this.pdfThumbnailViewer=new E.PDFThumbnailViewer({container:e.sidebar.thumbnailView,eventBus:T,renderingQueue:M,linkService:I,l10n:i,pageColors:B});M.setThumbnailViewer(this.pdfThumbnailViewer)}if(!this.isViewerEmbedded&&!a.AppOptions.get("disableHistory")){this.pdfHistory=new b.PDFHistory({linkService:I,eventBus:T});I.setHistory(this.pdfHistory)}!this.supportsIntegratedFind&&e.findBar&&(this.findBar=new f.PDFFindBar(e.findBar,T,i));if(e.annotationEditorParams)if(O!==s.AnnotationEditorType.DISABLE){a.AppOptions.get("enableStampEditor")&&N&&e.toolbar?.editorStampButton?.classList.remove("hidden");this.annotationEditorParams=new d.AnnotationEditorParams(e.annotationEditorParams,T)}else for(const e of["editorModeButtons","editorModeSeparator"])document.getElementById(e)?.classList.add("hidden");e.documentProperties&&(this.pdfDocumentProperties=new g.PDFDocumentProperties(e.documentProperties,this.overlayManager,T,i,(()=>this._docFilename)));e.secondaryToolbar?.cursorHandToolButton&&(this.pdfCursorTools=new p.PDFCursorTools({container:F,eventBus:T,cursorToolOnLoad:a.AppOptions.get("cursorToolOnLoad")}));e.toolbar&&(this.toolbar=new x.Toolbar(e.toolbar,T,i));e.secondaryToolbar&&(this.secondaryToolbar=new C.SecondaryToolbar(e.secondaryToolbar,T));this.supportsFullscreen&&e.secondaryToolbar?.presentationModeButton&&(this.pdfPresentationMode=new w.PDFPresentationMode({container:F,pdfViewer:U,eventBus:T}));e.passwordOverlay&&(this.passwordPrompt=new c.PasswordPrompt(e.passwordOverlay,this.overlayManager,i,this.isViewerEmbedded));e.sidebar?.outlineView&&(this.pdfOutlineViewer=new _.PDFOutlineViewer({container:e.sidebar.outlineView,eventBus:T,linkService:I,downloadManager:k}));e.sidebar?.attachmentsView&&(this.pdfAttachmentViewer=new u.PDFAttachmentViewer({container:e.sidebar.attachmentsView,eventBus:T,downloadManager:k}));e.sidebar?.layersView&&(this.pdfLayerViewer=new v.PDFLayerViewer({container:e.sidebar.layersView,eventBus:T,l10n:i}));if(e.sidebar){this.pdfSidebar=new A.PDFSidebar({elements:e.sidebar,eventBus:T,l10n:i});this.pdfSidebar.onToggled=this.forceRendering.bind(this);this.pdfSidebar.onUpdateThumbnails=()=>{for(const e of U.getCachedPageViews())e.renderingState===n.RenderingStates.FINISHED&&this.pdfThumbnailViewer.getThumbnail(e.id-1)?.setImage(e);this.pdfThumbnailViewer.scrollThumbnailIntoView(U.currentPageNumber)}}},async run(e){await this.initialize(e);const{appConfig:t,eventBus:i}=this;let s;const r=document.location.search.substring(1);s=(0,n.parseQueryString)(r).get("file")??a.AppOptions.get("defaultUrl");validateFileURL(s);const o=t.openFileInput;o.value=null;o.addEventListener("change",(function(e){const{files:t}=e.target;t&&0!==t.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.target})}));t.mainContainer.addEventListener("dragover",(function(e){e.preventDefault();e.dataTransfer.dropEffect="copy"===e.dataTransfer.effectAllowed?"copy":"move"}));t.mainContainer.addEventListener("drop",(function(e){e.preventDefault();const{files:t}=e.dataTransfer;t&&0!==t.length&&i.dispatch("fileinputchange",{source:this,fileInput:e.dataTransfer})}));if(!this.supportsDocumentFonts){a.AppOptions.set("disableFontFace",!0);this.l10n.get("web_fonts_disabled").then((e=>{console.warn(e)}))}if(!this.supportsPrinting){t.toolbar?.print?.classList.add("hidden");t.secondaryToolbar?.printButton.classList.add("hidden")}this.supportsFullscreen||t.secondaryToolbar?.presentationModeButton.classList.add("hidden");this.supportsIntegratedFind&&t.toolbar?.viewFind?.classList.add("hidden");t.mainContainer.addEventListener("transitionend",(function(e){e.target===this&&i.dispatch("resize",{source:this})}),!0);s?this.open({url:s}):this._hideViewBookmark()},get initialized(){return this._initializedCapability.settled},get initializedPromise(){return this._initializedCapability.promise},zoomIn(e,t){this.pdfViewer.isInPresentationMode||this.pdfViewer.increaseScale({drawingDelay:a.AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t})},zoomOut(e,t){this.pdfViewer.isInPresentationMode||this.pdfViewer.decreaseScale({drawingDelay:a.AppOptions.get("defaultZoomDelay"),steps:e,scaleFactor:t})},zoomReset(){this.pdfViewer.isInPresentationMode||(this.pdfViewer.currentScaleValue=n.DEFAULT_SCALE_VALUE)},get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0},get page(){return this.pdfViewer.currentPageNumber},set page(e){this.pdfViewer.currentPageNumber=e},get supportsPrinting(){return R.instance.supportsPrinting},get supportsFullscreen(){return(0,s.shadow)(this,"supportsFullscreen",document.fullscreenEnabled)},get supportsPinchToZoom(){return this.externalServices.supportsPinchToZoom},get supportsIntegratedFind(){return this.externalServices.supportsIntegratedFind},get supportsDocumentFonts(){return this.externalServices.supportsDocumentFonts},get loadingBar(){const e=document.getElementById("loadingBar"),t=e?new n.ProgressBar(e):null;return(0,s.shadow)(this,"loadingBar",t)},get supportedMouseWheelZoomModifierKeys(){return this.externalServices.supportedMouseWheelZoomModifierKeys},initPassiveLoading(e){throw new Error("Not implemented: initPassiveLoading")},setTitleUsingUrl(e="",t=null){this.url=e;this.baseUrl=e.split("#")[0];t&&(this._downloadUrl=t===e?this.baseUrl:t.split("#")[0]);(0,s.isDataScheme)(e)&&this._hideViewBookmark();let i=(0,s.getPdfFilenameFromUrl)(e,"");if(!i)try{i=decodeURIComponent((0,s.getFilenameFromUrl)(e))||e}catch{i=e}this.setTitle(i)},setTitle(e=this._title){this._title=e;if(this.isViewerEmbedded)return;const t=this._hasAnnotationEditors&&!this.pdfRenderingQueue.printing;document.title=`${t?"* ":""}${e}`},get _docFilename(){return this._contentDispositionFilename||(0,s.getPdfFilenameFromUrl)(this.url)},_hideViewBookmark(){const{secondaryToolbar:e}=this.appConfig;e?.viewBookmarkButton.classList.add("hidden");e?.presentationModeButton.classList.contains("hidden")&&document.getElementById("viewBookmarkSeparator")?.classList.add("hidden")},async close(){this._unblockDocumentLoadEvent();this._hideViewBookmark();if(!this.pdfLoadingTask)return;if(this.pdfDocument?.annotationStorage.size>0&&this._annotationStorageModified)try{await this.save()}catch{}const e=[];e.push(this.pdfLoadingTask.destroy());this.pdfLoadingTask=null;if(this.pdfDocument){this.pdfDocument=null;this.pdfThumbnailViewer?.setDocument(null);this.pdfViewer.setDocument(null);this.pdfLinkService.setDocument(null);this.pdfDocumentProperties?.setDocument(null)}this.pdfLinkService.externalLinkEnabled=!0;this.store=null;this.isInitialViewSet=!1;this.downloadComplete=!1;this.url="";this.baseUrl="";this._downloadUrl="";this.documentInfo=null;this.metadata=null;this._contentDispositionFilename=null;this._contentLength=null;this._saveInProgress=!1;this._hasAnnotationEditors=!1;e.push(this.pdfScriptingManager.destroyPromise,this.passwordPrompt.close());this.setTitle();this.pdfSidebar?.reset();this.pdfOutlineViewer?.reset();this.pdfAttachmentViewer?.reset();this.pdfLayerViewer?.reset();this.pdfHistory?.reset();this.findBar?.reset();this.toolbar?.reset();this.secondaryToolbar?.reset();this._PDFBug?.cleanup();await Promise.all(e)},async open(e){let t=!1;if("string"==typeof e){e={url:e};t=!0}else if(e?.byteLength){e={data:e};t=!0}t&&console.error("The `PDFViewerApplication.open` signature was updated, please use an object instead.");this.pdfLoadingTask&&await this.close();const i=a.AppOptions.getAll(a.OptionKind.WORKER);Object.assign(s.GlobalWorkerOptions,i);e.url&&this.setTitleUsingUrl(e.originalUrl||e.url,e.url);const n=a.AppOptions.getAll(a.OptionKind.API),r={canvasMaxAreaInBytes:this.externalServices.canvasMaxAreaInBytes,...n,...e},o=(0,s.getDocument)(r);this.pdfLoadingTask=o;o.onPassword=(e,t)=>{this.isViewerEmbedded&&this._unblockDocumentLoadEvent();this.pdfLinkService.externalLinkEnabled=!1;this.passwordPrompt.setUpdateCallback(e,t);this.passwordPrompt.open()};o.onProgress=({loaded:e,total:t})=>{this.progress(e/t)};return o.promise.then((e=>{this.load(e)}),(e=>{if(o!==this.pdfLoadingTask)return;let t="loading_error";e instanceof s.InvalidPDFException?t="invalid_file_error":e instanceof s.MissingPDFException?t="missing_file_error":e instanceof s.UnexpectedResponseException&&(t="unexpected_response_error");return this.l10n.get(t).then((t=>{this._documentError(t,{message:e?.message});throw e}))}))},_ensureDownloadComplete(){if(!this.pdfDocument||!this.downloadComplete)throw new Error("PDF document not downloaded.")},async download(e={}){const t=this._downloadUrl,i=this._docFilename;try{this._ensureDownloadComplete();const n=await this.pdfDocument.getData(),s=new Blob([n],{type:"application/pdf"});await this.downloadManager.download(s,t,i,e)}catch{await this.downloadManager.downloadUrl(t,i,e)}},async save(e={}){if(this._saveInProgress)return;this._saveInProgress=!0;await this.pdfScriptingManager.dispatchWillSave();const t=this._downloadUrl,i=this._docFilename;try{this._ensureDownloadComplete();const n=await this.pdfDocument.saveDocument(),s=new Blob([n],{type:"application/pdf"});await this.downloadManager.download(s,t,i,e)}catch(t){console.error(`Error when saving the document: ${t.message}`);await this.download(e)}finally{await this.pdfScriptingManager.dispatchDidSave();this._saveInProgress=!1}this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"save"}})},downloadOrSave(e={}){this.pdfDocument?.annotationStorage.size>0?this.save(e):this.download(e)},openInExternalApp(){this.downloadOrSave({openInExternalApp:!0})},_documentError(e,t=null){this._unblockDocumentLoadEvent();this._otherError(e,t);this.eventBus.dispatch("documenterror",{source:this,message:e,reason:t?.message??null})},_otherError(e,t=null){const i=[`PDF.js v${s.version||"?"} (build: ${s.build||"?"})`];if(t){i.push(`Message: ${t.message}`);if(t.stack)i.push(`Stack: ${t.stack}`);else{t.filename&&i.push(`File: ${t.filename}`);t.lineNumber&&i.push(`Line: ${t.lineNumber}`)}}console.error(`${e}\n\n${i.join("\n")}`)},progress(e){if(!this.loadingBar||this.downloadComplete)return;const t=Math.round(100*e);if(!(t<=this.loadingBar.percent)){this.loadingBar.percent=t;(this.pdfDocument?.loadingParams.disableAutoFetch??a.AppOptions.get("disableAutoFetch"))&&this.loadingBar.setDisableAutoFetch()}},load(e){this.pdfDocument=e;e.getDownloadInfo().then((({length:e})=>{this._contentLength=e;this.downloadComplete=!0;this.loadingBar?.hide();o.then((()=>{this.eventBus.dispatch("documentloaded",{source:this})}))}));const t=e.getPageLayout().catch((()=>{})),i=e.getPageMode().catch((()=>{})),s=e.getOpenAction().catch((()=>{}));this.toolbar?.setPagesCount(e.numPages,!1);this.secondaryToolbar?.setPagesCount(e.numPages);this.pdfLinkService.setDocument(e);this.pdfDocumentProperties?.setDocument(e);const r=this.pdfViewer;r.setDocument(e);const{firstPagePromise:o,onePageRendered:l,pagesPromise:d}=r;this.pdfThumbnailViewer?.setDocument(e);const h=(this.store=new T.ViewHistory(e.fingerprints[0])).getMultiple({page:null,zoom:n.DEFAULT_SCALE_VALUE,scrollLeft:"0",scrollTop:"0",rotation:null,sidebarView:n.SidebarView.UNKNOWN,scrollMode:n.ScrollMode.UNKNOWN,spreadMode:n.SpreadMode.UNKNOWN}).catch((()=>{}));o.then((o=>{this.loadingBar?.setWidth(this.appConfig.viewerContainer);this._initializeAnnotationStorageCallbacks(e);Promise.all([n.animationStarted,h,t,i,s]).then((async([t,i,s,o,l])=>{const h=a.AppOptions.get("viewOnLoad");this._initializePdfHistory({fingerprint:e.fingerprints[0],viewOnLoad:h,initialDest:l?.dest});const c=this.initialBookmark,u=a.AppOptions.get("defaultZoomValue");let p=u?`zoom=${u}`:null,g=null,f=a.AppOptions.get("sidebarViewOnLoad"),m=a.AppOptions.get("scrollModeOnLoad"),b=a.AppOptions.get("spreadModeOnLoad");if(i?.page&&h!==k){p=`page=${i.page}&zoom=${u||i.zoom},${i.scrollLeft},${i.scrollTop}`;g=parseInt(i.rotation,10);f===n.SidebarView.UNKNOWN&&(f=0|i.sidebarView);m===n.ScrollMode.UNKNOWN&&(m=0|i.scrollMode);b===n.SpreadMode.UNKNOWN&&(b=0|i.spreadMode)}o&&f===n.SidebarView.UNKNOWN&&(f=(0,n.apiPageModeToSidebarView)(o));if(s&&m===n.ScrollMode.UNKNOWN&&b===n.SpreadMode.UNKNOWN){b=(0,n.apiPageLayoutToViewerModes)(s).spreadMode}this.setInitialView(p,{rotation:g,sidebarView:f,scrollMode:m,spreadMode:b});this.eventBus.dispatch("documentinit",{source:this});this.isViewerEmbedded||r.focus();await Promise.race([d,new Promise((e=>{setTimeout(e,1e4)}))]);if((c||p)&&!r.hasEqualPageSizes){this.initialBookmark=c;r.currentScaleValue=r.currentScaleValue;this.setInitialView(p)}})).catch((()=>{this.setInitialView()})).then((function(){r.update()}))}));d.then((()=>{this._unblockDocumentLoadEvent();this._initializeAutoPrint(e,s)}),(e=>{this.l10n.get("loading_error").then((t=>{this._documentError(t,{message:e?.message})}))}));l.then((t=>{this.externalServices.reportTelemetry({type:"pageInfo",timestamp:t.timestamp});this.pdfOutlineViewer&&e.getOutline().then((t=>{e===this.pdfDocument&&this.pdfOutlineViewer.render({outline:t,pdfDocument:e})}));this.pdfAttachmentViewer&&e.getAttachments().then((t=>{e===this.pdfDocument&&this.pdfAttachmentViewer.render({attachments:t})}));this.pdfLayerViewer&&r.optionalContentConfigPromise.then((t=>{e===this.pdfDocument&&this.pdfLayerViewer.render({optionalContentConfig:t,pdfDocument:e})}))}));this._initializePageLabels(e);this._initializeMetadata(e)},async _scriptingDocProperties(e){if(!this.documentInfo){await new Promise((e=>{this.eventBus._on("metadataloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}if(!this._contentLength){await new Promise((e=>{this.eventBus._on("documentloaded",e,{once:!0})}));if(e!==this.pdfDocument)return null}return{...this.documentInfo,baseURL:this.baseUrl,filesize:this._contentLength,filename:this._docFilename,metadata:this.metadata?.getRaw(),authors:this.metadata?.get("dc:creator"),numPages:this.pagesCount,URL:this.url}},async _initializeAutoPrint(e,t){const[i,s]=await Promise.all([t,this.pdfViewer.enableScripting?null:e.getJSActions()]);if(e!==this.pdfDocument)return;let a="Print"===i?.action;if(s){console.warn("Warning: JavaScript support is not enabled");for(const e in s){if(a)break;switch(e){case"WillClose":case"WillSave":case"DidSave":case"WillPrint":case"DidPrint":continue}a=s[e].some((e=>n.AutoPrintRegExp.test(e)))}}a&&this.triggerPrinting()},async _initializeMetadata(e){const{info:t,metadata:i,contentDispositionFilename:n,contentLength:a}=await e.getMetadata();if(e!==this.pdfDocument)return;this.documentInfo=t;this.metadata=i;this._contentDispositionFilename??=n;this._contentLength??=a;console.log(`PDF ${e.fingerprints[0]} [${t.PDFFormatVersion} ${(t.Producer||"-").trim()} / ${(t.Creator||"-").trim()}] (PDF.js: ${s.version||"?"} [${s.build||"?"}])`);let r=t.Title;const o=i?.get("dc:title");o&&("Untitled"===o||/[\uFFF0-\uFFFF]/g.test(o)||(r=o));r?this.setTitle(`${r} - ${this._contentDispositionFilename||this._title}`):this._contentDispositionFilename&&this.setTitle(this._contentDispositionFilename);!t.IsXFAPresent||t.IsAcroFormPresent||e.isPureXfa?!t.IsAcroFormPresent&&!t.IsXFAPresent||this.pdfViewer.renderForms||console.warn("Warning: Interactive form support is not enabled"):e.loadingParams.enableXfa?console.warn("Warning: XFA Foreground documents are not supported"):console.warn("Warning: XFA support is not enabled");t.IsSignaturesPresent&&console.warn("Warning: Digital signatures validation is not supported");this.eventBus.dispatch("metadataloaded",{source:this})},async _initializePageLabels(e){const t=await e.getPageLabels();if(e!==this.pdfDocument)return;if(!t||a.AppOptions.get("disablePageLabels"))return;const i=t.length;let n=0,s=0;for(let e=0;e<i;e++){const i=t[e];if(i===(e+1).toString())n++;else{if(""!==i)break;s++}}if(n>=i||s>=i)return;const{pdfViewer:r,pdfThumbnailViewer:o,toolbar:l}=this;r.setPageLabels(t);o?.setPageLabels(t);l?.setPagesCount(i,!0);l?.setPageNumber(r.currentPageNumber,r.currentPageLabel)},_initializePdfHistory({fingerprint:e,viewOnLoad:t,initialDest:i=null}){if(this.pdfHistory){this.pdfHistory.initialize({fingerprint:e,resetHistory:t===k,updateUrl:a.AppOptions.get("historyUpdateUrl")});if(this.pdfHistory.initialBookmark){this.initialBookmark=this.pdfHistory.initialBookmark;this.initialRotation=this.pdfHistory.initialRotation}if(i&&!this.initialBookmark&&t===I){this.initialBookmark=JSON.stringify(i);this.pdfHistory.push({explicitDest:i,pageNumber:null})}}},_initializeAnnotationStorageCallbacks(e){if(e!==this.pdfDocument)return;const{annotationStorage:t}=e;t.onSetModified=()=>{window.addEventListener("beforeunload",beforeUnload);this._annotationStorageModified=!0};t.onResetModified=()=>{window.removeEventListener("beforeunload",beforeUnload);delete this._annotationStorageModified};t.onAnnotationEditor=e=>{this._hasAnnotationEditors=!!e;this.setTitle();e&&this.externalServices.reportTelemetry({type:"editing",data:{type:e}})}},setInitialView(e,{rotation:t,sidebarView:i,scrollMode:s,spreadMode:a}={}){const setRotation=e=>{(0,n.isValidRotation)(e)&&(this.pdfViewer.pagesRotation=e)};this.isInitialViewSet=!0;this.pdfSidebar?.setInitialView(i);((e,t)=>{(0,n.isValidScrollMode)(e)&&(this.pdfViewer.scrollMode=e);(0,n.isValidSpreadMode)(t)&&(this.pdfViewer.spreadMode=t)})(s,a);if(this.initialBookmark){setRotation(this.initialRotation);delete this.initialRotation;this.pdfLinkService.setHash(this.initialBookmark);this.initialBookmark=null}else if(e){setRotation(t);this.pdfLinkService.setHash(e)}this.toolbar?.setPageNumber(this.pdfViewer.currentPageNumber,this.pdfViewer.currentPageLabel);this.secondaryToolbar?.setPageNumber(this.pdfViewer.currentPageNumber);this.pdfViewer.currentScaleValue||(this.pdfViewer.currentScaleValue=n.DEFAULT_SCALE_VALUE)},_cleanup(){if(this.pdfDocument){this.pdfViewer.cleanup();this.pdfThumbnailViewer?.cleanup();this.pdfDocument.cleanup()}},forceRendering(){this.pdfRenderingQueue.printing=!!this.printService;this.pdfRenderingQueue.isThumbnailViewEnabled=this.pdfSidebar?.visibleView===n.SidebarView.THUMBS;this.pdfRenderingQueue.renderHighestPriority()},beforePrint(){this._printAnnotationStoragePromise=this.pdfScriptingManager.dispatchWillPrint().catch((()=>{})).then((()=>this.pdfDocument?.annotationStorage.print));if(this.printService)return;if(!this.supportsPrinting){this.l10n.get("printing_not_supported").then((e=>{this._otherError(e)}));return}if(!this.pdfViewer.pageViewsReady){this.l10n.get("printing_not_ready").then((e=>{window.alert(e)}));return}const e=this.pdfViewer.getPagesOverview(),t=this.appConfig.printContainer,i=a.AppOptions.get("printResolution"),n=this.pdfViewer.optionalContentConfigPromise,s=R.instance.createPrintService(this.pdfDocument,e,t,i,n,this._printAnnotationStoragePromise,this.l10n);this.printService=s;this.forceRendering();this.setTitle();s.layout();this._hasAnnotationEditors&&this.externalServices.reportTelemetry({type:"editing",data:{type:"print"}})},afterPrint(){if(this._printAnnotationStoragePromise){this._printAnnotationStoragePromise.then((()=>{this.pdfScriptingManager.dispatchDidPrint()}));this._printAnnotationStoragePromise=null}if(this.printService){this.printService.destroy();this.printService=null;this.pdfDocument?.annotationStorage.resetModified()}this.forceRendering();this.setTitle()},rotatePages(e){this.pdfViewer.pagesRotation+=e},requestPresentationMode(){this.pdfPresentationMode?.request()},triggerPrinting(){this.supportsPrinting&&window.print()},bindEvents(){const{eventBus:e,_boundEvents:t}=this;t.beforePrint=this.beforePrint.bind(this);t.afterPrint=this.afterPrint.bind(this);e._on("resize",webViewerResize);e._on("hashchange",webViewerHashchange);e._on("beforeprint",t.beforePrint);e._on("afterprint",t.afterPrint);e._on("pagerender",webViewerPageRender);e._on("pagerendered",webViewerPageRendered);e._on("updateviewarea",webViewerUpdateViewarea);e._on("pagechanging",webViewerPageChanging);e._on("scalechanging",webViewerScaleChanging);e._on("rotationchanging",webViewerRotationChanging);e._on("sidebarviewchanged",webViewerSidebarViewChanged);e._on("pagemode",webViewerPageMode);e._on("namedaction",webViewerNamedAction);e._on("presentationmodechanged",webViewerPresentationModeChanged);e._on("presentationmode",webViewerPresentationMode);e._on("switchannotationeditormode",webViewerSwitchAnnotationEditorMode);e._on("switchannotationeditorparams",webViewerSwitchAnnotationEditorParams);e._on("print",webViewerPrint);e._on("download",webViewerDownload);e._on("openinexternalapp",webViewerOpenInExternalApp);e._on("firstpage",webViewerFirstPage);e._on("lastpage",webViewerLastPage);e._on("nextpage",webViewerNextPage);e._on("previouspage",webViewerPreviousPage);e._on("zoomin",webViewerZoomIn);e._on("zoomout",webViewerZoomOut);e._on("zoomreset",webViewerZoomReset);e._on("pagenumberchanged",webViewerPageNumberChanged);e._on("scalechanged",webViewerScaleChanged);e._on("rotatecw",webViewerRotateCw);e._on("rotateccw",webViewerRotateCcw);e._on("optionalcontentconfig",webViewerOptionalContentConfig);e._on("switchscrollmode",webViewerSwitchScrollMode);e._on("scrollmodechanged",webViewerScrollModeChanged);e._on("switchspreadmode",webViewerSwitchSpreadMode);e._on("spreadmodechanged",webViewerSpreadModeChanged);e._on("documentproperties",webViewerDocumentProperties);e._on("findfromurlhash",webViewerFindFromUrlHash);e._on("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._on("updatefindcontrolstate",webViewerUpdateFindControlState);if(a.AppOptions.get("pdfBug")){t.reportPageStatsPDFBug=reportPageStatsPDFBug;e._on("pagerendered",t.reportPageStatsPDFBug);e._on("pagechanging",t.reportPageStatsPDFBug)}e._on("fileinputchange",webViewerFileInputChange);e._on("openfile",webViewerOpenFile)},bindWindowEvents(){const{eventBus:e,_boundEvents:t}=this;!function addWindowResolutionChange(e=null){e&&function webViewerResolutionChange(e){L.pdfViewer.refresh()}();const i=window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`);i.addEventListener("change",addWindowResolutionChange,{once:!0});t.removeWindowResolutionChange||=function(){i.removeEventListener("change",addWindowResolutionChange);t.removeWindowResolutionChange=null}}();t.windowResize=()=>{e.dispatch("resize",{source:window})};t.windowHashChange=()=>{e.dispatch("hashchange",{source:window,hash:document.location.hash.substring(1)})};t.windowBeforePrint=()=>{e.dispatch("beforeprint",{source:window})};t.windowAfterPrint=()=>{e.dispatch("afterprint",{source:window})};t.windowUpdateFromSandbox=t=>{e.dispatch("updatefromsandbox",{source:window,detail:t.detail})};window.addEventListener("visibilitychange",webViewerVisibilityChange);window.addEventListener("wheel",webViewerWheel,{passive:!1});window.addEventListener("touchstart",webViewerTouchStart,{passive:!1});window.addEventListener("touchmove",webViewerTouchMove,{passive:!1});window.addEventListener("touchend",webViewerTouchEnd,{passive:!1});window.addEventListener("click",webViewerClick);window.addEventListener("keydown",webViewerKeyDown);window.addEventListener("keyup",webViewerKeyUp);window.addEventListener("resize",t.windowResize);window.addEventListener("hashchange",t.windowHashChange);window.addEventListener("beforeprint",t.windowBeforePrint);window.addEventListener("afterprint",t.windowAfterPrint);window.addEventListener("updatefromsandbox",t.windowUpdateFromSandbox)},unbindEvents(){const{eventBus:e,_boundEvents:t}=this;e._off("resize",webViewerResize);e._off("hashchange",webViewerHashchange);e._off("beforeprint",t.beforePrint);e._off("afterprint",t.afterPrint);e._off("pagerender",webViewerPageRender);e._off("pagerendered",webViewerPageRendered);e._off("updateviewarea",webViewerUpdateViewarea);e._off("pagechanging",webViewerPageChanging);e._off("scalechanging",webViewerScaleChanging);e._off("rotationchanging",webViewerRotationChanging);e._off("sidebarviewchanged",webViewerSidebarViewChanged);e._off("pagemode",webViewerPageMode);e._off("namedaction",webViewerNamedAction);e._off("presentationmodechanged",webViewerPresentationModeChanged);e._off("presentationmode",webViewerPresentationMode);e._off("print",webViewerPrint);e._off("download",webViewerDownload);e._off("openinexternalapp",webViewerOpenInExternalApp);e._off("firstpage",webViewerFirstPage);e._off("lastpage",webViewerLastPage);e._off("nextpage",webViewerNextPage);e._off("previouspage",webViewerPreviousPage);e._off("zoomin",webViewerZoomIn);e._off("zoomout",webViewerZoomOut);e._off("zoomreset",webViewerZoomReset);e._off("pagenumberchanged",webViewerPageNumberChanged);e._off("scalechanged",webViewerScaleChanged);e._off("rotatecw",webViewerRotateCw);e._off("rotateccw",webViewerRotateCcw);e._off("optionalcontentconfig",webViewerOptionalContentConfig);e._off("switchscrollmode",webViewerSwitchScrollMode);e._off("scrollmodechanged",webViewerScrollModeChanged);e._off("switchspreadmode",webViewerSwitchSpreadMode);e._off("spreadmodechanged",webViewerSpreadModeChanged);e._off("documentproperties",webViewerDocumentProperties);e._off("findfromurlhash",webViewerFindFromUrlHash);e._off("updatefindmatchescount",webViewerUpdateFindMatchesCount);e._off("updatefindcontrolstate",webViewerUpdateFindControlState);if(t.reportPageStatsPDFBug){e._off("pagerendered",t.reportPageStatsPDFBug);e._off("pagechanging",t.reportPageStatsPDFBug);t.reportPageStatsPDFBug=null}e._off("fileinputchange",webViewerFileInputChange);e._off("openfile",webViewerOpenFile);t.beforePrint=null;t.afterPrint=null},unbindWindowEvents(){const{_boundEvents:e}=this;window.removeEventListener("visibilitychange",webViewerVisibilityChange);window.removeEventListener("wheel",webViewerWheel,{passive:!1});window.removeEventListener("touchstart",webViewerTouchStart,{passive:!1});window.removeEventListener("touchmove",webViewerTouchMove,{passive:!1});window.removeEventListener("touchend",webViewerTouchEnd,{passive:!1});window.removeEventListener("click",webViewerClick);window.removeEventListener("keydown",webViewerKeyDown);window.removeEventListener("keyup",webViewerKeyUp);window.removeEventListener("resize",e.windowResize);window.removeEventListener("hashchange",e.windowHashChange);window.removeEventListener("beforeprint",e.windowBeforePrint);window.removeEventListener("afterprint",e.windowAfterPrint);window.removeEventListener("updatefromsandbox",e.windowUpdateFromSandbox);e.removeWindowResolutionChange?.();e.windowResize=null;e.windowHashChange=null;e.windowBeforePrint=null;e.windowAfterPrint=null;e.windowUpdateFromSandbox=null},_accumulateTicks(e,t){(this[t]>0&&e<0||this[t]<0&&e>0)&&(this[t]=0);this[t]+=e;const i=Math.trunc(this[t]);this[t]-=i;return i},_accumulateFactor(e,t,i){if(1===t)return 1;(this[i]>1&&t<1||this[i]<1&&t>1)&&(this[i]=1);const n=Math.floor(e*t*this[i]*100)/(100*e);this[i]=t/n;return n},_centerAtPos(e,t,i){const{pdfViewer:n}=this,s=n.currentScale/e-1;if(0!==s){const[e,a]=n.containerTopLeft;n.container.scrollLeft+=(t-a)*s;n.container.scrollTop+=(i-e)*s}},_unblockDocumentLoadEvent(){document.blockUnblockOnload?.(!1);this._unblockDocumentLoadEvent=()=>{}},get scriptingReady(){return this.pdfScriptingManager.ready}};t.PDFViewerApplication=L;{const e=["null","http://mozilla.github.io","https://mozilla.github.io"];var validateFileURL=function(t){if(t)try{const i=new URL(window.location.href).origin||"null";if(e.includes(i))return;if(new URL(t,window.location.href).origin!==i)throw new Error("file origin does not match viewer's")}catch(e){L.l10n.get("loading_error").then((t=>{L._documentError(t,{message:e?.message})}));throw e}}}async function loadPDFBug(e){const{debuggerScriptPath:t}=e.appConfig,{PDFBug:i}=await import(t);e._PDFBug=i}function reportPageStatsPDFBug({pageNumber:e}){if(!globalThis.Stats?.enabled)return;const t=L.pdfViewer.getPageView(e-1);globalThis.Stats.add(e,t?.pdfPage?.stats)}function webViewerPageRender({pageNumber:e}){e===L.page&&L.toolbar?.updateLoadingIndicatorState(!0)}function webViewerPageRendered({pageNumber:e,error:t}){e===L.page&&L.toolbar?.updateLoadingIndicatorState(!1);if(L.pdfSidebar?.visibleView===n.SidebarView.THUMBS){const t=L.pdfViewer.getPageView(e-1),i=L.pdfThumbnailViewer?.getThumbnail(e-1);t&&i?.setImage(t)}t&&L.l10n.get("rendering_error").then((e=>{L._otherError(e,t)}))}function webViewerPageMode({mode:e}){let t;switch(e){case"thumbs":t=n.SidebarView.THUMBS;break;case"bookmarks":case"outline":t=n.SidebarView.OUTLINE;break;case"attachments":t=n.SidebarView.ATTACHMENTS;break;case"layers":t=n.SidebarView.LAYERS;break;case"none":t=n.SidebarView.NONE;break;default:console.error('Invalid "pagemode" hash parameter: '+e);return}L.pdfSidebar?.switchView(t,!0)}function webViewerNamedAction(e){switch(e.action){case"GoToPage":L.appConfig.toolbar?.pageNumber.select();break;case"Find":L.supportsIntegratedFind||L?.findBar.toggle();break;case"Print":L.triggerPrinting();break;case"SaveAs":L.downloadOrSave()}}function webViewerPresentationModeChanged(e){L.pdfViewer.presentationModeState=e.state}function webViewerSidebarViewChanged({view:e}){L.pdfRenderingQueue.isThumbnailViewEnabled=e===n.SidebarView.THUMBS;L.isInitialViewSet&&L.store?.set("sidebarView",e).catch((()=>{}))}function webViewerUpdateViewarea({location:e}){L.isInitialViewSet&&L.store?.setMultiple({page:e.pageNumber,zoom:e.scale,scrollLeft:e.left,scrollTop:e.top,rotation:e.rotation}).catch((()=>{}));if(L.appConfig.secondaryToolbar){const t=L.pdfLinkService.getAnchorUrl(e.pdfOpenParams);L.appConfig.secondaryToolbar.viewBookmarkButton.href=t}}function webViewerScrollModeChanged(e){L.isInitialViewSet&&!L.pdfViewer.isInPresentationMode&&L.store?.set("scrollMode",e.mode).catch((()=>{}))}function webViewerSpreadModeChanged(e){L.isInitialViewSet&&!L.pdfViewer.isInPresentationMode&&L.store?.set("spreadMode",e.mode).catch((()=>{}))}function webViewerResize(){const{pdfDocument:e,pdfViewer:t,pdfRenderingQueue:i}=L;if(i.printing&&window.matchMedia("print").matches)return;if(!e)return;const n=t.currentScaleValue;"auto"!==n&&"page-fit"!==n&&"page-width"!==n||(t.currentScaleValue=n);t.update()}function webViewerHashchange(e){const t=e.hash;t&&(L.isInitialViewSet?L.pdfHistory?.popStateInProgress||L.pdfLinkService.setHash(t):L.initialBookmark=t)}var webViewerFileInputChange=function(e){if(L.pdfViewer?.isInPresentationMode)return;const t=e.fileInput.files[0];L.open({url:URL.createObjectURL(t),originalUrl:t.name})},webViewerOpenFile=function(e){L.appConfig.openFileInput.click()};function webViewerPresentationMode(){L.requestPresentationMode()}function webViewerSwitchAnnotationEditorMode(e){L.pdfViewer.annotationEditorMode=e}function webViewerSwitchAnnotationEditorParams(e){L.pdfViewer.annotationEditorParams=e}function webViewerPrint(){L.triggerPrinting()}function webViewerDownload(){L.downloadOrSave()}function webViewerOpenInExternalApp(){L.openInExternalApp()}function webViewerFirstPage(){L.page=1}function webViewerLastPage(){L.page=L.pagesCount}function webViewerNextPage(){L.pdfViewer.nextPage()}function webViewerPreviousPage(){L.pdfViewer.previousPage()}function webViewerZoomIn(){L.zoomIn()}function webViewerZoomOut(){L.zoomOut()}function webViewerZoomReset(){L.zoomReset()}function webViewerPageNumberChanged(e){const t=L.pdfViewer;""!==e.value&&L.pdfLinkService.goToPage(e.value);e.value!==t.currentPageNumber.toString()&&e.value!==t.currentPageLabel&&L.toolbar?.setPageNumber(t.currentPageNumber,t.currentPageLabel)}function webViewerScaleChanged(e){L.pdfViewer.currentScaleValue=e.value}function webViewerRotateCw(){L.rotatePages(90)}function webViewerRotateCcw(){L.rotatePages(-90)}function webViewerOptionalContentConfig(e){L.pdfViewer.optionalContentConfigPromise=e.promise}function webViewerSwitchScrollMode(e){L.pdfViewer.scrollMode=e.mode}function webViewerSwitchSpreadMode(e){L.pdfViewer.spreadMode=e.mode}function webViewerDocumentProperties(){L.pdfDocumentProperties?.open()}function webViewerFindFromUrlHash(e){L.eventBus.dispatch("find",{source:e.source,type:"",query:e.query,caseSensitive:!1,entireWord:!1,highlightAll:!0,findPrevious:!1,matchDiacritics:!0})}function webViewerUpdateFindMatchesCount({matchesCount:e}){L.supportsIntegratedFind?L.externalServices.updateFindMatchesCount(e):L.findBar.updateResultsCount(e)}function webViewerUpdateFindControlState({state:e,previous:t,matchesCount:i,rawQuery:n}){L.supportsIntegratedFind?L.externalServices.updateFindControlState({result:e,findPrevious:t,matchesCount:i,rawQuery:n}):L.findBar?.updateUIState(e,t,i)}function webViewerScaleChanging(e){L.toolbar?.setPageScale(e.presetValue,e.scale);L.pdfViewer.update()}function webViewerRotationChanging(e){L.pdfThumbnailViewer&&(L.pdfThumbnailViewer.pagesRotation=e.pagesRotation);L.forceRendering();L.pdfViewer.currentPageNumber=e.pageNumber}function webViewerPageChanging({pageNumber:e,pageLabel:t}){L.toolbar?.setPageNumber(e,t);L.secondaryToolbar?.setPageNumber(e);L.pdfSidebar?.visibleView===n.SidebarView.THUMBS&&L.pdfThumbnailViewer?.scrollThumbnailIntoView(e);const i=L.pdfViewer.getPageView(e-1);L.toolbar?.updateLoadingIndicatorState(i?.renderingState===n.RenderingStates.RUNNING)}function webViewerVisibilityChange(e){"visible"===document.visibilityState&&setZoomDisabledTimeout()}let F=null;function setZoomDisabledTimeout(){F&&clearTimeout(F);F=setTimeout((function(){F=null}),M)}function webViewerWheel(e){const{pdfViewer:t,supportedMouseWheelZoomModifierKeys:i,supportsPinchToZoom:s}=L;if(t.isInPresentationMode)return;const a=e.deltaMode;let r=Math.exp(-e.deltaY/100);const o=e.ctrlKey&&!L._isCtrlKeyDown&&a===WheelEvent.DOM_DELTA_PIXEL&&0===e.deltaX&&(Math.abs(r-1)<.05||!1)&&0===e.deltaZ;if(o||e.ctrlKey&&i.ctrlKey||e.metaKey&&i.metaKey){e.preventDefault();if(F||"hidden"===document.visibilityState||L.overlayManager.active)return;const i=t.currentScale;if(o&&s){r=L._accumulateFactor(i,r,"_wheelUnusedFactor");if(r<1)L.zoomOut(null,r);else{if(!(r>1))return;L.zoomIn(null,r)}}else{const t=(0,n.normalizeWheelEventDirection)(e);let i=0;if(a===WheelEvent.DOM_DELTA_LINE||a===WheelEvent.DOM_DELTA_PAGE)i=Math.abs(t)>=1?Math.sign(t):L._accumulateTicks(t,"_wheelUnusedTicks");else{const e=30;i=L._accumulateTicks(t/e,"_wheelUnusedTicks")}if(i<0)L.zoomOut(-i);else{if(!(i>0))return;L.zoomIn(i)}}L._centerAtPos(i,e.clientX,e.clientY)}else setZoomDisabledTimeout()}function webViewerTouchStart(e){if(L.pdfViewer.isInPresentationMode||e.touches.length<2)return;e.preventDefault();if(2!==e.touches.length||L.overlayManager.active){L._touchInfo=null;return}let[t,i]=e.touches;t.identifier>i.identifier&&([t,i]=[i,t]);L._touchInfo={touch0X:t.pageX,touch0Y:t.pageY,touch1X:i.pageX,touch1Y:i.pageY}}function webViewerTouchMove(e){if(!L._touchInfo||2!==e.touches.length)return;const{pdfViewer:t,_touchInfo:i,supportsPinchToZoom:n}=L;let[s,a]=e.touches;s.identifier>a.identifier&&([s,a]=[a,s]);const{pageX:r,pageY:o}=s,{pageX:l,pageY:d}=a,{touch0X:h,touch0Y:c,touch1X:u,touch1Y:p}=i;if(Math.abs(h-r)<=1&&Math.abs(c-o)<=1&&Math.abs(u-l)<=1&&Math.abs(p-d)<=1)return;i.touch0X=r;i.touch0Y=o;i.touch1X=l;i.touch1Y=d;if(h===r&&c===o){const e=u-r,t=p-o,i=l-r,n=d-o,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else if(u===l&&p===d){const e=h-l,t=c-d,i=r-l,n=o-d,s=e*n-t*i;if(Math.abs(s)>.02*Math.hypot(e,t)*Math.hypot(i,n))return}else{if((r-h)*(l-u)+(o-c)*(d-p)>=0)return}e.preventDefault();const g=Math.hypot(r-l,o-d)||1,f=Math.hypot(h-u,c-p)||1,m=t.currentScale;if(n){const e=L._accumulateFactor(m,g/f,"_touchUnusedFactor");if(e<1)L.zoomOut(null,e);else{if(!(e>1))return;L.zoomIn(null,e)}}else{const e=30,t=L._accumulateTicks((g-f)/e,"_touchUnusedTicks");if(t<0)L.zoomOut(-t);else{if(!(t>0))return;L.zoomIn(t)}}L._centerAtPos(m,(r+l)/2,(o+d)/2)}function webViewerTouchEnd(e){if(L._touchInfo){e.preventDefault();L._touchInfo=null;L._touchUnusedTicks=0;L._touchUnusedFactor=1}}function webViewerClick(e){if(!L.secondaryToolbar?.isOpen)return;const t=L.appConfig;(L.pdfViewer.containsElement(e.target)||t.toolbar?.container.contains(e.target)&&e.target!==t.secondaryToolbar?.toggleButton)&&L.secondaryToolbar.close()}function webViewerKeyUp(e){"Control"===e.key&&(L._isCtrlKeyDown=!1)}function webViewerKeyDown(e){L._isCtrlKeyDown="Control"===e.key;if(L.overlayManager.active)return;const{eventBus:t,pdfViewer:i}=L,s=i.isInPresentationMode;let a=!1,r=!1;const o=(e.ctrlKey?1:0)|(e.altKey?2:0)|(e.shiftKey?4:0)|(e.metaKey?8:0);if(1===o||8===o||5===o||12===o)switch(e.keyCode){case 70:if(!L.supportsIntegratedFind&&!e.shiftKey){L.findBar?.open();a=!0}break;case 71:if(!L.supportsIntegratedFind){const{state:e}=L.findController;if(e){const i={source:window,type:"again",findPrevious:5===o||12===o};t.dispatch("find",{...e,...i})}a=!0}break;case 61:case 107:case 187:case 171:L.zoomIn();a=!0;break;case 173:case 109:case 189:L.zoomOut();a=!0;break;case 48:case 96:if(!s){setTimeout((function(){L.zoomReset()}));a=!1}break;case 38:if(s||L.page>1){L.page=1;a=!0;r=!0}break;case 40:if(s||L.page<L.pagesCount){L.page=L.pagesCount;a=!0;r=!0}}if(1===o||8===o)switch(e.keyCode){case 83:t.dispatch("download",{source:window});a=!0;break;case 79:t.dispatch("openfile",{source:window});a=!0}if(3===o||10===o)switch(e.keyCode){case 80:L.requestPresentationMode();a=!0;L.externalServices.reportTelemetry({type:"buttons",data:{id:"presentationModeKeyboard"}});break;case 71:if(L.appConfig.toolbar){L.appConfig.toolbar.pageNumber.select();a=!0}}if(a){r&&!s&&i.focus();e.preventDefault();return}const l=(0,n.getActiveOrFocusedElement)(),d=l?.tagName.toUpperCase();if("INPUT"!==d&&"TEXTAREA"!==d&&"SELECT"!==d&&!l?.isContentEditable||27===e.keyCode){if(0===o){let t=0,o=!1;switch(e.keyCode){case 38:case 33:i.isVerticalScrollbarEnabled&&(o=!0);t=-1;break;case 8:s||(o=!0);t=-1;break;case 37:i.isHorizontalScrollbarEnabled&&(o=!0);case 75:case 80:t=-1;break;case 27:if(L.secondaryToolbar?.isOpen){L.secondaryToolbar.close();a=!0}if(!L.supportsIntegratedFind&&L.findBar?.opened){L.findBar.close();a=!0}break;case 40:case 34:i.isVerticalScrollbarEnabled&&(o=!0);t=1;break;case 13:case 32:s||(o=!0);t=1;break;case 39:i.isHorizontalScrollbarEnabled&&(o=!0);case 74:case 78:t=1;break;case 36:if(s||L.page>1){L.page=1;a=!0;r=!0}break;case 35:if(s||L.page<L.pagesCount){L.page=L.pagesCount;a=!0;r=!0}break;case 83:L.pdfCursorTools?.switchTool(n.CursorTool.SELECT);break;case 72:L.pdfCursorTools?.switchTool(n.CursorTool.HAND);break;case 82:L.rotatePages(90);break;case 115:L.pdfSidebar?.toggle()}if(0!==t&&(!o||"page-fit"===i.currentScaleValue)){t>0?i.nextPage():i.previousPage();a=!0}}if(4===o)switch(e.keyCode){case 13:case 32:if(!s&&"page-fit"!==i.currentScaleValue)break;i.previousPage();a=!0;break;case 82:L.rotatePages(-90)}a||s||(e.keyCode>=33&&e.keyCode<=40||32===e.keyCode&&"BUTTON"!==d)&&(r=!0);r&&!i.containsElement(l)&&i.focus();a&&e.preventDefault()}}function beforeUnload(e){e.preventDefault();e.returnValue="";return!1}const R={instance:{supportsPrinting:!1,createPrintService(){throw new Error("Not implemented: createPrintService")}}};t.PDFPrintServiceFactory=R},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.animationStarted=t.VERTICAL_PADDING=t.UNKNOWN_SCALE=t.TextLayerMode=t.SpreadMode=t.SidebarView=t.ScrollMode=t.SCROLLBAR_PADDING=t.RenderingStates=t.ProgressBar=t.PresentationModeState=t.OutputScale=t.MIN_SCALE=t.MAX_SCALE=t.MAX_AUTO_SCALE=t.DEFAULT_SCALE_VALUE=t.DEFAULT_SCALE_DELTA=t.DEFAULT_SCALE=t.CursorTool=t.AutoPrintRegExp=void 0;t.apiPageLayoutToViewerModes=function apiPageLayoutToViewerModes(e){let t=n.VERTICAL,i=s.NONE;switch(e){case"SinglePage":t=n.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=n.PAGE;case"TwoColumnLeft":i=s.ODD;break;case"TwoPageRight":t=n.PAGE;case"TwoColumnRight":i=s.EVEN}return{scrollMode:t,spreadMode:i}};t.apiPageModeToSidebarView=function apiPageModeToSidebarView(e){switch(e){case"UseNone":return i.NONE;case"UseThumbs":return i.THUMBS;case"UseOutlines":return i.OUTLINE;case"UseAttachments":return i.ATTACHMENTS;case"UseOC":return i.LAYERS}return i.NONE};t.approximateFraction=function approximateFraction(e){if(Math.floor(e)===e)return[e,1];const t=1/e;if(t>8)return[1,8];if(Math.floor(t)===t)return[1,t];const i=e>1?t:e;let n,s=0,a=1,r=1,o=1;for(;;){const e=s+r,t=a+o;if(t>8)break;if(i<=e/t){r=e;o=t}else{s=e;a=t}}n=i-s/a<r/o-i?i===e?[s,a]:[a,s]:i===e?[r,o]:[o,r];return n};t.backtrackBeforeAllVisibleElements=backtrackBeforeAllVisibleElements;t.binarySearchFirstItem=binarySearchFirstItem;t.docStyle=void 0;t.getActiveOrFocusedElement=function getActiveOrFocusedElement(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;t?.shadowRoot;){e=t.shadowRoot;t=e.activeElement||e.querySelector(":focus")}return t};t.getPageSizeInches=function getPageSizeInches({view:e,userUnit:t,rotate:i}){const[n,s,a,r]=e,o=i%180!=0,l=(a-n)/72*t,d=(r-s)/72*t;return{width:o?d:l,height:o?l:d}};t.getVisibleElements=function getVisibleElements({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const a=e.scrollTop,r=a+e.clientHeight,o=e.scrollLeft,l=o+e.clientWidth;const d=[],h=new Set,c=t.length;let u=binarySearchFirstItem(t,n?function isElementNextAfterViewHorizontally(e){const t=e.div,i=t.offsetLeft+t.clientLeft,n=i+t.clientWidth;return s?i<l:n>o}:function isElementBottomAfterViewTop(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>a});u>0&&u<c&&!n&&(u=backtrackBeforeAllVisibleElements(u,t,a));let p=n?l:-1;for(let e=u;e<c;e++){const i=t[e],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,f=s.clientHeight,m=c+g,b=u+f;if(-1===p)b>=r&&(p=b);else if((n?c:u)>p)break;if(b<=a||u>=r||m<=o||c>=l)continue;const v=Math.max(0,a-u)+Math.max(0,b-r),_=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,w=(f-v)/f*_*100|0;d.push({id:i.id,x:c,y:u,view:i,percent:w,widthPercent:100*_|0});h.add(i.id)}const g=d[0],f=d.at(-1);i&&d.sort((function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id}));return{first:g,last:f,views:d,ids:h}};t.isPortraitOrientation=function isPortraitOrientation(e){return e.width<=e.height};t.isValidRotation=function isValidRotation(e){return Number.isInteger(e)&&e%90==0};t.isValidScrollMode=function isValidScrollMode(e){return Number.isInteger(e)&&Object.values(n).includes(e)&&e!==n.UNKNOWN};t.isValidSpreadMode=function isValidSpreadMode(e){return Number.isInteger(e)&&Object.values(s).includes(e)&&e!==s.UNKNOWN};t.normalizeWheelEventDelta=function normalizeWheelEventDelta(e){const t=e.deltaMode;let i=normalizeWheelEventDirection(e);t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30);return i};t.normalizeWheelEventDirection=normalizeWheelEventDirection;t.parseQueryString=function parseQueryString(e){const t=new Map;for(const[i,n]of new URLSearchParams(e))t.set(i.toLowerCase(),n);return t};t.removeNullCharacters=function removeNullCharacters(e,t=!1){if("string"!=typeof e){console.error("The argument must be a string.");return e}t&&(e=e.replaceAll(a," "));return e.replaceAll("\0","")};t.roundToDivide=function roundToDivide(e,t){const i=e%t;return 0===i?e:Math.round(e-i+t)};t.scrollIntoView=function scrollIntoView(e,t,i=!1){let n=e.offsetParent;if(!n){console.error("offsetParent is not set -- cannot scroll");return}let s=e.offsetTop+e.clientTop,a=e.offsetLeft+e.clientLeft;for(;n.clientHeight===n.scrollHeight&&n.clientWidth===n.scrollWidth||i&&(n.classList.contains("markedContent")||"hidden"===getComputedStyle(n).overflow);){s+=n.offsetTop;a+=n.offsetLeft;n=n.offsetParent;if(!n)return}if(t){void 0!==t.top&&(s+=t.top);if(void 0!==t.left){a+=t.left;n.scrollLeft=a}}n.scrollTop=s};t.toggleCheckedBtn=function toggleCheckedBtn(e,t,i=null){e.classList.toggle("toggled",t);e.setAttribute("aria-checked",t);i?.classList.toggle("hidden",!t)};t.toggleExpandedBtn=function toggleExpandedBtn(e,t,i=null){e.classList.toggle("toggled",t);e.setAttribute("aria-expanded",t);i?.classList.toggle("hidden",!t)};t.watchScroll=function watchScroll(e,t){const debounceScroll=function(s){n||(n=window.requestAnimationFrame((function viewAreaElementScrolled(){n=null;const s=e.scrollLeft,a=i.lastX;s!==a&&(i.right=s>a);i.lastX=s;const r=e.scrollTop,o=i.lastY;r!==o&&(i.down=r>o);i.lastY=r;t(i)})))},i={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:debounceScroll};let n=null;e.addEventListener("scroll",debounceScroll,!0);return i};t.DEFAULT_SCALE_VALUE="auto";t.DEFAULT_SCALE=1;t.DEFAULT_SCALE_DELTA=1.1;t.MIN_SCALE=.1;t.MAX_SCALE=10;t.UNKNOWN_SCALE=0;t.MAX_AUTO_SCALE=1.25;t.SCROLLBAR_PADDING=40;t.VERTICAL_PADDING=5;t.RenderingStates={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3};t.PresentationModeState={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3};const i={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4};t.SidebarView=i;t.TextLayerMode={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2};const n={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3};t.ScrollMode=n;const s={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};t.SpreadMode=s;t.CursorTool={SELECT:0,HAND:1,ZOOM:2};t.AutoPrintRegExp=/\bprint\s*\(/;t.OutputScale=class OutputScale{constructor(){const e=window.devicePixelRatio||1;this.sx=e;this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}};const a=/[\x01-\x1F]/g;function binarySearchFirstItem(e,t,i=0){let n=i,s=e.length-1;if(s<0||!t(e[s]))return e.length;if(t(e[n]))return n;for(;n<s;){const i=n+s>>1;t(e[i])?s=i:n=i+1}return n}function backtrackBeforeAllVisibleElements(e,t,i){if(e<2)return e;let n=t[e].div,s=n.offsetTop+n.clientTop;if(s>=i){n=t[e-1].div;s=n.offsetTop+n.clientTop}for(let i=e-2;i>=0;--i){n=t[i].div;if(n.offsetTop+n.clientTop+n.clientHeight<=s)break;e=i}return e}function normalizeWheelEventDirection(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t);return t}const r=new Promise((function(e){window.requestAnimationFrame(e)}));t.animationStarted=r;const o=document.documentElement.style;t.docStyle=o;t.ProgressBar=class ProgressBar{#Dn=null;#Ln=null;#Fn=0;#Rn=null;#mt=!0;constructor(e){this.#Dn=e.classList;this.#Rn=e.style}get percent(){return this.#Fn}set percent(e){this.#Fn=function clamp(e,t,i){return Math.min(Math.max(e,t),i)}(e,0,100);if(isNaN(e))this.#Dn.add("indeterminate");else{this.#Dn.remove("indeterminate");this.#Rn.setProperty("--progressBar-percent",`${this.#Fn}%`)}}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&this.#Rn.setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(e=5e3){if(!isNaN(this.#Fn)){this.#Ln&&clearTimeout(this.#Ln);this.show();this.#Ln=setTimeout((()=>{this.#Ln=null;this.hide()}),e)}}hide(){if(this.#mt){this.#mt=!1;this.#Dn.add("hidden")}}show(){if(!this.#mt){this.#mt=!0;this.#Dn.remove("hidden")}}}},e=>{e.exports=globalThis.pdfjsLib},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.compatibilityParams=t.OptionKind=t.AppOptions=void 0;const i=Object.create(null);t.compatibilityParams=i;{const e=navigator.userAgent||"",t=navigator.platform||"",n=navigator.maxTouchPoints||1,s=/Android/.test(e),a=/\b(iPad|iPhone|iPod)(?=;)/.test(e)||"MacIntel"===t&&n>1;!function checkCanvasSizeLimitation(){(a||s)&&(i.maxCanvasPixels=5242880)}()}const n={VIEWER:2,API:4,WORKER:8,PREFERENCE:128};t.OptionKind=n;const s={annotationEditorMode:{value:0,kind:n.VIEWER+n.PREFERENCE},annotationMode:{value:2,kind:n.VIEWER+n.PREFERENCE},cursorToolOnLoad:{value:0,kind:n.VIEWER+n.PREFERENCE},defaultZoomDelay:{value:400,kind:n.VIEWER+n.PREFERENCE},defaultZoomValue:{value:"",kind:n.VIEWER+n.PREFERENCE},disableHistory:{value:!1,kind:n.VIEWER},disablePageLabels:{value:!1,kind:n.VIEWER+n.PREFERENCE},enablePermissions:{value:!1,kind:n.VIEWER+n.PREFERENCE},enablePrintAutoRotate:{value:!0,kind:n.VIEWER+n.PREFERENCE},enableScripting:{value:!0,kind:n.VIEWER+n.PREFERENCE},enableStampEditor:{value:!0,kind:n.VIEWER+n.PREFERENCE},externalLinkRel:{value:"noopener noreferrer nofollow",kind:n.VIEWER},externalLinkTarget:{value:0,kind:n.VIEWER+n.PREFERENCE},historyUpdateUrl:{value:!1,kind:n.VIEWER+n.PREFERENCE},ignoreDestinationZoom:{value:!1,kind:n.VIEWER+n.PREFERENCE},imageResourcesPath:{value:"./images/",kind:n.VIEWER},maxCanvasPixels:{value:16777216,kind:n.VIEWER},forcePageColors:{value:!1,kind:n.VIEWER+n.PREFERENCE},pageColorsBackground:{value:"Canvas",kind:n.VIEWER+n.PREFERENCE},pageColorsForeground:{value:"CanvasText",kind:n.VIEWER+n.PREFERENCE},pdfBugEnabled:{value:!1,kind:n.VIEWER+n.PREFERENCE},printResolution:{value:150,kind:n.VIEWER},sidebarViewOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},scrollModeOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},spreadModeOnLoad:{value:-1,kind:n.VIEWER+n.PREFERENCE},textLayerMode:{value:1,kind:n.VIEWER+n.PREFERENCE},viewerCssTheme:{value:0,kind:n.VIEWER+n.PREFERENCE},viewOnLoad:{value:0,kind:n.VIEWER+n.PREFERENCE},cMapPacked:{value:!0,kind:n.API},cMapUrl:{value:"../web/cmaps/",kind:n.API},disableAutoFetch:{value:!1,kind:n.API+n.PREFERENCE},disableFontFace:{value:!1,kind:n.API+n.PREFERENCE},disableRange:{value:!1,kind:n.API+n.PREFERENCE},disableStream:{value:!1,kind:n.API+n.PREFERENCE},docBaseUrl:{value:"",kind:n.API},enableXfa:{value:!0,kind:n.API+n.PREFERENCE},fontExtraProperties:{value:!1,kind:n.API},isEvalSupported:{value:!0,kind:n.API},isOffscreenCanvasSupported:{value:!0,kind:n.API},maxImageSize:{value:-1,kind:n.API},pdfBug:{value:!1,kind:n.API},standardFontDataUrl:{value:"../web/standard_fonts/",kind:n.API},verbosity:{value:1,kind:n.API},workerPort:{value:null,kind:n.WORKER},workerSrc:{value:"../build/pdf.worker.js",kind:n.WORKER}};s.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:n.VIEWER};s.disablePreferences={value:!1,kind:n.VIEWER};s.locale={value:navigator.language||"en-US",kind:n.VIEWER};s.sandboxBundleSrc={value:"../build/pdf.sandbox.js",kind:n.VIEWER};const a=Object.create(null);class AppOptions{constructor(){throw new Error("Cannot initialize AppOptions.")}static get(e){const t=a[e];if(void 0!==t)return t;const n=s[e];return void 0!==n?i[e]??n.value:void 0}static getAll(e=null){const t=Object.create(null);for(const r in s){const o=s[r];if(e){if(0==(e&o.kind))continue;if(e===n.PREFERENCE){const e=o.value,i=typeof e;if("boolean"===i||"string"===i||"number"===i&&Number.isInteger(e)){t[r]=e;continue}throw new Error(`Invalid type for preference: ${r}`)}}const l=a[r];t[r]=void 0!==l?l:i[r]??o.value}return t}static set(e,t){a[e]=t}static setAll(e){for(const t in e)a[t]=e[t]}static remove(e){delete a[e]}}t.AppOptions=AppOptions;AppOptions._hasUserOptions=function(){return Object.keys(a).length>0}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.WaitOnType=t.EventBus=t.AutomationEventBus=void 0;t.waitOnEventOrTimeout=function waitOnEventOrTimeout({target:e,name:t,delay:n=0}){return new Promise((function(s,a){if("object"!=typeof e||!t||"string"!=typeof t||!(Number.isInteger(n)&&n>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");function handler(i){e instanceof EventBus?e._off(t,r):e.removeEventListener(t,r);l&&clearTimeout(l);s(i)}const r=handler.bind(null,i.EVENT);e instanceof EventBus?e._on(t,r):e.addEventListener(t,r);const o=handler.bind(null,i.TIMEOUT),l=setTimeout(o,n)}))};const i={EVENT:"event",TIMEOUT:"timeout"};t.WaitOnType=i;class EventBus{#r=Object.create(null);on(e,t,i=null){this._on(e,t,{external:!0,once:i?.once})}off(e,t,i=null){this._off(e,t,{external:!0,once:i?.once})}dispatch(e,t){const i=this.#r[e];if(!i||0===i.length)return;let n;for(const{listener:s,external:a,once:r}of i.slice(0)){r&&this._off(e,s);a?(n||=[]).push(s):s(t)}if(n){for(const e of n)e(t);n=null}}_on(e,t,i=null){(this.#r[e]||=[]).push({listener:t,external:!0===i?.external,once:!0===i?.once})}_off(e,t,i=null){const n=this.#r[e];if(n)for(let e=0,i=n.length;e<i;e++)if(n[e].listener===t){n.splice(e,1);return}}}t.EventBus=EventBus;t.AutomationEventBus=class AutomationEventBus extends EventBus{dispatch(e,t){throw new Error("Not implemented: AutomationEventBus.dispatch")}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.SimpleLinkService=t.PDFLinkService=t.LinkTarget=void 0;var n=i(3);const s={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};t.LinkTarget=s;function addLinkAttributes(e,{url:t,target:i,rel:n,enabled:a=!0}={}){if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');if(a)e.href=e.title=t;else{e.href="";e.title=`Disabled: ${t}`;e.onclick=()=>!1}let r="";switch(i){case s.NONE:break;case s.SELF:r="_self";break;case s.BLANK:r="_blank";break;case s.PARENT:r="_parent";break;case s.TOP:r="_top"}e.target=r;e.rel="string"==typeof n?n:"noopener noreferrer nofollow"}class PDFLinkService{#On=new Map;constructor({eventBus:e,externalLinkTarget:t=null,externalLinkRel:i=null,ignoreDestinationZoom:n=!1}={}){this.eventBus=e;this.externalLinkTarget=t;this.externalLinkRel=i;this.externalLinkEnabled=!0;this._ignoreDestinationZoom=n;this.baseUrl=null;this.pdfDocument=null;this.pdfViewer=null;this.pdfHistory=null}setDocument(e,t=null){this.baseUrl=t;this.pdfDocument=e;this.#On.clear()}setViewer(e){this.pdfViewer=e}setHistory(e){this.pdfHistory=e}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfViewer.currentPageNumber}set page(e){this.pdfViewer.currentPageNumber=e}get rotation(){return this.pdfViewer.pagesRotation}set rotation(e){this.pdfViewer.pagesRotation=e}get isInPresentationMode(){return this.pdfViewer.isInPresentationMode}#Nn(e,t=null,i){const n=i[0];let s;if("object"==typeof n&&null!==n){s=this._cachedPageNumber(n);if(!s){this.pdfDocument.getPageIndex(n).then((s=>{this.cachePageRef(s+1,n);this.#Nn(e,t,i)})).catch((()=>{console.error(`PDFLinkService.#goToDestinationHelper: "${n}" is not a valid page reference, for dest="${e}".`)}));return}}else{if(!Number.isInteger(n)){console.error(`PDFLinkService.#goToDestinationHelper: "${n}" is not a valid destination reference, for dest="${e}".`);return}s=n+1}if(!s||s<1||s>this.pagesCount)console.error(`PDFLinkService.#goToDestinationHelper: "${s}" is not a valid page number, for dest="${e}".`);else{if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.push({namedDest:t,explicitDest:i,pageNumber:s})}this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom})}}async goToDestination(e){if(!this.pdfDocument)return;let t,i;if("string"==typeof e){t=e;i=await this.pdfDocument.getDestination(e)}else{t=null;i=await e}Array.isArray(i)?this.#Nn(e,t,i):console.error(`PDFLinkService.goToDestination: "${i}" is not a valid destination array, for dest="${e}".`)}goToPage(e){if(!this.pdfDocument)return;const t="string"==typeof e&&this.pdfViewer.pageLabelToPageNumber(e)||0|e;if(Number.isInteger(t)&&t>0&&t<=this.pagesCount){if(this.pdfHistory){this.pdfHistory.pushCurrentPosition();this.pdfHistory.pushPage(t)}this.pdfViewer.scrollPageIntoView({pageNumber:t})}else console.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`)}addLinkAttributes(e,t,i=!1){addLinkAttributes(e,{url:t,target:i?s.BLANK:this.externalLinkTarget,rel:this.externalLinkRel,enabled:this.externalLinkEnabled})}getDestinationHash(e){if("string"==typeof e){if(e.length>0)return this.getAnchorUrl("#"+escape(e))}else if(Array.isArray(e)){const t=JSON.stringify(e);if(t.length>0)return this.getAnchorUrl("#"+escape(t))}return this.getAnchorUrl("")}getAnchorUrl(e){return this.baseUrl?this.baseUrl+e:e}setHash(e){if(!this.pdfDocument)return;let t,i;if(e.includes("=")){const s=(0,n.parseQueryString)(e);if(s.has("search")){const e=s.get("search").replaceAll('"',""),t="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:t?e:e.match(/\S+/g)})}s.has("page")&&(t=0|s.get("page")||1);if(s.has("zoom")){const e=s.get("zoom").split(","),t=e[0],n=parseFloat(t);t.includes("Fit")?"Fit"===t||"FitB"===t?i=[null,{name:t}]:"FitH"===t||"FitBH"===t||"FitV"===t||"FitBV"===t?i=[null,{name:t},e.length>1?0|e[1]:null]:"FitR"===t?5!==e.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:t},0|e[1],0|e[2],0|e[3],0|e[4]]:console.error(`PDFLinkService.setHash: "${t}" is not a valid zoom value.`):i=[null,{name:"XYZ"},e.length>1?0|e[1]:null,e.length>2?0|e[2]:null,n?n/100:t]}i?this.pdfViewer.scrollPageIntoView({pageNumber:t||this.page,destArray:i,allowNegativeOffset:!0}):t&&(this.page=t);s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")});s.has("nameddest")&&this.goToDestination(s.get("nameddest"))}else{i=unescape(e);try{i=JSON.parse(i);Array.isArray(i)||(i=i.toString())}catch{}if("string"==typeof i||PDFLinkService.#Bn(i)){this.goToDestination(i);return}console.error(`PDFLinkService.setHash: "${unescape(e)}" is not a valid destination.`)}}executeNamedAction(e){switch(e){case"GoBack":this.pdfHistory?.back();break;case"GoForward":this.pdfHistory?.forward();break;case"NextPage":this.pdfViewer.nextPage();break;case"PrevPage":this.pdfViewer.previousPage();break;case"LastPage":this.page=this.pagesCount;break;case"FirstPage":this.page=1}this.eventBus.dispatch("namedaction",{source:this,action:e})}async executeSetOCGState(e){const t=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;if(t!==this.pdfDocument)return;let n;for(const t of e.state){switch(t){case"ON":case"OFF":case"Toggle":n=t;continue}switch(n){case"ON":i.setVisibility(t,!0);break;case"OFF":i.setVisibility(t,!1);break;case"Toggle":const e=i.getGroup(t);e&&i.setVisibility(t,!e.visible)}}this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i)}cachePageRef(e,t){if(!t)return;const i=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;this.#On.set(i,e)}_cachedPageNumber(e){if(!e)return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#On.get(t)||null}static#Bn(e){if(!Array.isArray(e))return!1;const t=e.length;if(t<2)return!1;const i=e[0];if(!("object"==typeof i&&Number.isInteger(i.num)&&Number.isInteger(i.gen)||Number.isInteger(i)&&i>=0))return!1;const n=e[1];if("object"!=typeof n||"string"!=typeof n.name)return!1;let s=!0;switch(n.name){case"XYZ":if(5!==t)return!1;break;case"Fit":case"FitB":return 2===t;case"FitH":case"FitBH":case"FitV":case"FitBV":if(3!==t)return!1;break;case"FitR":if(6!==t)return!1;s=!1;break;default:return!1}for(let i=2;i<t;i++){const t=e[i];if(!("number"==typeof t||s&&null===t))return!1}return!0}}t.PDFLinkService=PDFLinkService;t.SimpleLinkService=class SimpleLinkService{constructor(){this.externalLinkEnabled=!0}get pagesCount(){return 0}get page(){return 0}set page(e){}get rotation(){return 0}set rotation(e){}get isInPresentationMode(){return!1}async goToDestination(e){}goToPage(e){}addLinkAttributes(e,t,i=!1){addLinkAttributes(e,{url:t,enabled:this.externalLinkEnabled})}getDestinationHash(e){return"#"}getAnchorUrl(e){return"#"}setHash(e){}executeNamedAction(e){}executeSetOCGState(e){}cachePageRef(e,t){}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AltTextManager=void 0;var n=i(4);t.AltTextManager=class AltTextManager{#Vn=this.#Un.bind(this);#zn=this.#Hn.bind(this);#jn=this.#Wn.bind(this);#Gn=null;#$n;#qn;#Xn;#Kn=!1;#Yn;#Qn;#Zn;#Jn;#es;#kt;#ts=null;#is=null;#ns=null;#De;#ss=null;constructor({dialog:e,optionDescription:t,optionDecorative:i,textarea:n,cancelButton:s,saveButton:a},r,o,l){this.#qn=e;this.#Yn=t;this.#Qn=i;this.#es=n;this.#$n=s;this.#Jn=a;this.#Zn=o;this.#Xn=l;this.#De=r;e.addEventListener("close",this.#as.bind(this));e.addEventListener("contextmenu",(e=>{e.target!==this.#es&&e.preventDefault()}));s.addEventListener("click",this.#rs.bind(this));a.addEventListener("click",this.#os.bind(this));t.addEventListener("change",this.#Vn);i.addEventListener("change",this.#Vn);this.#Zn.register(e)}get _elements(){return(0,n.shadow)(this,"_elements",[this.#Yn,this.#Qn,this.#es,this.#Jn,this.#$n])}#ls(){if(this.#is)return;const e=new n.DOMSVGFactory,t=this.#is=e.createElement("svg");t.setAttribute("width","0");t.setAttribute("height","0");const i=e.createElement("defs");t.append(i);const s=e.createElement("mask");i.append(s);s.setAttribute("id","alttext-manager-mask");s.setAttribute("maskContentUnits","objectBoundingBox");let a=e.createElement("rect");s.append(a);a.setAttribute("fill","white");a.setAttribute("width","1");a.setAttribute("height","1");a.setAttribute("x","0");a.setAttribute("y","0");a=this.#ns=e.createElement("rect");s.append(a);a.setAttribute("fill","black");this.#qn.append(t)}async editAltText(e,t){if(this.#Gn||!t)return;this.#ls();this.#Kn=!1;for(const e of this._elements)e.addEventListener("click",this.#jn);const{altText:i,decorative:n}=t.altTextData;if(!0===n){this.#Qn.checked=!0;this.#Yn.checked=!1}else{this.#Qn.checked=!1;this.#Yn.checked=!0}this.#ts=this.#es.value=i?.trim()||"";this.#Un();this.#Gn=t;this.#kt=e;this.#kt.removeEditListeners();this.#Xn._on("resize",this.#zn);try{await this.#Zn.open(this.#qn);this.#Hn()}catch(e){this.#as();throw e}}#Hn(){if(!this.#Gn)return;const e=this.#qn,{style:t}=e,{x:i,y:n,width:s,height:a}=this.#De.getBoundingClientRect(),{innerWidth:r,innerHeight:o}=window,{width:l,height:d}=e.getBoundingClientRect(),{x:h,y:c,width:u,height:p}=this.#Gn.getClientDimensions(),g=10,f="ltr"===this.#kt.direction,m=Math.max(h,i),b=Math.min(h+u,i+s),v=Math.max(c,n),_=Math.min(c+p,n+a);this.#ns.setAttribute("width",""+(b-m)/r);this.#ns.setAttribute("height",""+(_-v)/o);this.#ns.setAttribute("x",""+m/r);this.#ns.setAttribute("y",""+v/o);let w=null,y=Math.max(c,0);y+=Math.min(o-(y+d),0);f?h+u+g+l<r?w=h+u+g:h>l+g&&(w=h-l-g):h>l+g?w=h-l-g:h+u+g+l<r&&(w=h+u+g);if(null===w){y=null;w=Math.max(h,0);w+=Math.min(r-(w+l),0);c>d+g?y=c-d-g:c+p+g+d<o&&(y=c+p+g)}if(null!==y){e.classList.add("positioned");f?t.left=`${w}px`:t.right=r-w-l+"px";t.top=`${y}px`}else{e.classList.remove("positioned");t.left="";t.top=""}}#rs(){this.#Zn.active===this.#qn&&this.#Zn.close(this.#qn)}#as(){this.#Xn.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.#Gn.editorType,data:this.#ss||{action:"alt_text_cancel",alt_text_keyboard:!this.#Kn}}});this.#ss=null;this.#ds();this.#kt?.addEditListeners();this.#Xn._off("resize",this.#zn);this.#Gn=null;this.#kt=null}#Un(){this.#es.disabled=this.#Qn.checked}#os(){const e=this.#es.value.trim(),t=this.#Qn.checked;this.#Gn.altTextData={altText:e,decorative:t};this.#ss={action:"alt_text_save",alt_text_description:!!e,alt_text_edit:!!this.#ts&&this.#ts!==e,alt_text_decorative:t,alt_text_keyboard:!this.#Kn};this.#rs()}#Wn(e){if(0!==e.detail){this.#Kn=!0;this.#ds()}}#ds(){for(const e of this._elements)e.removeEventListener("click",this.#jn)}destroy(){this.#kt=null;this.#rs();this.#is?.remove();this.#is=this.#ns=null}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationEditorParams=void 0;var n=i(4);t.AnnotationEditorParams=class AnnotationEditorParams{constructor(e,t){this.eventBus=t;this.#hs(e)}#hs({editorFreeTextFontSize:e,editorFreeTextColor:t,editorInkColor:i,editorInkThickness:s,editorInkOpacity:a,editorStampAddImage:r}){const dispatchEvent=(e,t)=>{this.eventBus.dispatch("switchannotationeditorparams",{source:this,type:n.AnnotationEditorParamsType[e],value:t})};e.addEventListener("input",(function(){dispatchEvent("FREETEXT_SIZE",this.valueAsNumber)}));t.addEventListener("input",(function(){dispatchEvent("FREETEXT_COLOR",this.value)}));i.addEventListener("input",(function(){dispatchEvent("INK_COLOR",this.value)}));s.addEventListener("input",(function(){dispatchEvent("INK_THICKNESS",this.valueAsNumber)}));a.addEventListener("input",(function(){dispatchEvent("INK_OPACITY",this.valueAsNumber)}));r.addEventListener("click",(()=>{dispatchEvent("CREATE")}));this.eventBus._on("annotationeditorparamschanged",(r=>{for(const[o,l]of r.details)switch(o){case n.AnnotationEditorParamsType.FREETEXT_SIZE:e.value=l;break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:t.value=l;break;case n.AnnotationEditorParamsType.INK_COLOR:i.value=l;break;case n.AnnotationEditorParamsType.INK_THICKNESS:s.value=l;break;case n.AnnotationEditorParamsType.INK_OPACITY:a.value=l}}))}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.OverlayManager=void 0;t.OverlayManager=class OverlayManager{#cs=new WeakMap;#us=null;get active(){return this.#us}async register(e,t=!1){if("object"!=typeof e)throw new Error("Not enough parameters.");if(this.#cs.has(e))throw new Error("The overlay is already registered.");this.#cs.set(e,{canForceClose:t});e.addEventListener("cancel",(e=>{this.#us=null}))}async open(e){if(!this.#cs.has(e))throw new Error("The overlay does not exist.");if(this.#us){if(this.#us===e)throw new Error("The overlay is already active.");if(!this.#cs.get(e).canForceClose)throw new Error("Another overlay is currently active.");await this.close()}this.#us=e;e.showModal()}async close(e=this.#us){if(!this.#cs.has(e))throw new Error("The overlay does not exist.");if(!this.#us)throw new Error("The overlay is currently not active.");if(this.#us!==e)throw new Error("Another overlay is currently active.");e.close();this.#us=null}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PasswordPrompt=void 0;var n=i(4);t.PasswordPrompt=class PasswordPrompt{#ps=null;#gs=null;#fs=null;constructor(e,t,i,n=!1){this.dialog=e.dialog;this.label=e.label;this.input=e.input;this.submitButton=e.submitButton;this.cancelButton=e.cancelButton;this.overlayManager=t;this.l10n=i;this._isViewerEmbedded=n;this.submitButton.addEventListener("click",this.#ms.bind(this));this.cancelButton.addEventListener("click",this.close.bind(this));this.input.addEventListener("keydown",(e=>{13===e.keyCode&&this.#ms()}));this.overlayManager.register(this.dialog,!0);this.dialog.addEventListener("close",this.#bs.bind(this))}async open(){this.#ps&&await this.#ps.promise;this.#ps=new n.PromiseCapability;try{await this.overlayManager.open(this.dialog)}catch(e){this.#ps.resolve();throw e}const e=this.#fs===n.PasswordResponses.INCORRECT_PASSWORD;this._isViewerEmbedded&&!e||this.input.focus();this.label.textContent=await this.l10n.get("password_"+(e?"invalid":"label"))}async close(){this.overlayManager.active===this.dialog&&this.overlayManager.close(this.dialog)}#ms(){const e=this.input.value;e?.length>0&&this.#vs(e)}#bs(){this.#vs(new Error("PasswordPrompt cancelled."));this.#ps.resolve()}#vs(e){if(this.#gs){this.close();this.input.value="";this.#gs(e);this.#gs=null}}async setUpdateCallback(e,t){this.#ps&&await this.#ps.promise;this.#gs=e;this.#fs=t}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFAttachmentViewer=void 0;var n=i(4),s=i(13),a=i(6);class PDFAttachmentViewer extends s.BaseTreeViewer{constructor(e){super(e);this.downloadManager=e.downloadManager;this.eventBus._on("fileattachmentannotation",this.#_s.bind(this))}reset(e=!1){super.reset();this._attachments=null;e||(this._renderedCapability=new n.PromiseCapability);this._pendingDispatchEvent=!1}async _dispatchEvent(e){this._renderedCapability.resolve();if(0===e&&!this._pendingDispatchEvent){this._pendingDispatchEvent=!0;await(0,a.waitOnEventOrTimeout)({target:this.eventBus,name:"annotationlayerrendered",delay:1e3});if(!this._pendingDispatchEvent)return}this._pendingDispatchEvent=!1;this.eventBus.dispatch("attachmentsloaded",{source:this,attachmentsCount:e})}_bindLink(e,{content:t,filename:i}){e.onclick=()=>{this.downloadManager.openOrDownloadData(e,t,i);return!1}}render({attachments:e,keepRenderedCapability:t=!1}){this._attachments&&this.reset(t);this._attachments=e||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment();let s=0;for(const t in e){const a=e[t],r=a.content,o=(0,n.getFilenameFromUrl)(a.filename,!0),l=document.createElement("div");l.className="treeItem";const d=document.createElement("a");this._bindLink(d,{content:r,filename:o});d.textContent=this._normalizeTextContent(o);l.append(d);i.append(l);s++}this._finishRendering(i,s)}#_s({filename:e,content:t}){const i=this._renderedCapability.promise;i.then((()=>{if(i!==this._renderedCapability.promise)return;const n=this._attachments||Object.create(null);for(const t in n)if(e===t)return;n[e]={filename:e,content:t};this.render({attachments:n,keepRenderedCapability:!0})}))}}t.PDFAttachmentViewer=PDFAttachmentViewer},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.BaseTreeViewer=void 0;var n=i(3);const s="selected";class BaseTreeViewer{constructor(e){if(this.constructor===BaseTreeViewer)throw new Error("Cannot initialize BaseTreeViewer.");this.container=e.container;this.eventBus=e.eventBus;this.reset()}reset(){this._pdfDocument=null;this._lastToggleIsShow=!0;this._currentTreeItem=null;this.container.textContent="";this.container.classList.remove("treeWithDeepNesting")}_dispatchEvent(e){throw new Error("Not implemented: _dispatchEvent")}_bindLink(e,t){throw new Error("Not implemented: _bindLink")}_normalizeTextContent(e){return(0,n.removeNullCharacters)(e,!0)||"–"}_addToggleButton(e,t=!1){const i=document.createElement("div");i.className="treeItemToggler";t&&i.classList.add("treeItemsHidden");i.onclick=t=>{t.stopPropagation();i.classList.toggle("treeItemsHidden");if(t.shiftKey){const t=!i.classList.contains("treeItemsHidden");this._toggleTreeItem(e,t)}};e.prepend(i)}_toggleTreeItem(e,t=!1){this._lastToggleIsShow=t;for(const i of e.querySelectorAll(".treeItemToggler"))i.classList.toggle("treeItemsHidden",!t)}_toggleAllTreeItems(){this._toggleTreeItem(this.container,!this._lastToggleIsShow)}_finishRendering(e,t,i=!1){if(i){this.container.classList.add("treeWithDeepNesting");this._lastToggleIsShow=!e.querySelector(".treeItemsHidden")}this.container.append(e);this._dispatchEvent(t)}render(e){throw new Error("Not implemented: render")}_updateCurrentTreeItem(e=null){if(this._currentTreeItem){this._currentTreeItem.classList.remove(s);this._currentTreeItem=null}if(e){e.classList.add(s);this._currentTreeItem=e}}_scrollToCurrentTreeItem(e){if(!e)return;let t=e.parentNode;for(;t&&t!==this.container;){if(t.classList.contains("treeItem")){const e=t.firstElementChild;e?.classList.remove("treeItemsHidden")}t=t.parentNode}this._updateCurrentTreeItem(e);this.container.scrollTo(e.offsetLeft,e.offsetTop+-100)}}t.BaseTreeViewer=BaseTreeViewer},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFCursorTools=void 0;var n=i(4),s=i(3),a=i(15);t.PDFCursorTools=class PDFCursorTools{#us=s.CursorTool.SELECT;#ws=null;constructor({container:e,eventBus:t,cursorToolOnLoad:i=s.CursorTool.SELECT}){this.container=e;this.eventBus=t;this.#ys();Promise.resolve().then((()=>{this.switchTool(i)}))}get activeTool(){return this.#us}switchTool(e){if(null!==this.#ws)return;if(e===this.#us)return;const disableActiveTool=()=>{switch(this.#us){case s.CursorTool.SELECT:break;case s.CursorTool.HAND:this._handTool.deactivate();case s.CursorTool.ZOOM:}};switch(e){case s.CursorTool.SELECT:disableActiveTool();break;case s.CursorTool.HAND:disableActiveTool();this._handTool.activate();break;case s.CursorTool.ZOOM:default:console.error(`switchTool: "${e}" is an unsupported value.`);return}this.#us=e;this.eventBus.dispatch("cursortoolchanged",{source:this,tool:e})}#ys(){this.eventBus._on("switchcursortool",(e=>{this.switchTool(e.tool)}));let e=n.AnnotationEditorType.NONE,t=s.PresentationModeState.NORMAL;const disableActive=()=>{const e=this.#us;this.switchTool(s.CursorTool.SELECT);this.#ws??=e},enableActive=()=>{const i=this.#ws;if(null!==i&&e===n.AnnotationEditorType.NONE&&t===s.PresentationModeState.NORMAL){this.#ws=null;this.switchTool(i)}};this.eventBus._on("secondarytoolbarreset",(i=>{if(null!==this.#ws){e=n.AnnotationEditorType.NONE;t=s.PresentationModeState.NORMAL;enableActive()}}));this.eventBus._on("annotationeditormodechanged",(({mode:t})=>{e=t;t===n.AnnotationEditorType.NONE?enableActive():disableActive()}));this.eventBus._on("presentationmodechanged",(({state:e})=>{t=e;e===s.PresentationModeState.NORMAL?enableActive():e===s.PresentationModeState.FULLSCREEN&&disableActive()}))}get _handTool(){return(0,n.shadow)(this,"_handTool",new a.GrabToPan({element:this.container}))}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GrabToPan=void 0;const i="grab-to-pan-grab";t.GrabToPan=class GrabToPan{constructor({element:e}){this.element=e;this.document=e.ownerDocument;this.activate=this.activate.bind(this);this.deactivate=this.deactivate.bind(this);this.toggle=this.toggle.bind(this);this._onMouseDown=this.#Ss.bind(this);this._onMouseMove=this.#As.bind(this);this._endPan=this.#Es.bind(this);(this.overlay=document.createElement("div")).className="grab-to-pan-grabbing"}activate(){if(!this.active){this.active=!0;this.element.addEventListener("mousedown",this._onMouseDown,!0);this.element.classList.add(i)}}deactivate(){if(this.active){this.active=!1;this.element.removeEventListener("mousedown",this._onMouseDown,!0);this._endPan();this.element.classList.remove(i)}}toggle(){this.active?this.deactivate():this.activate()}ignoreTarget(e){return e.matches("a[href], a[href] *, input, textarea, button, button *, select, option")}#Ss(e){if(0!==e.button||this.ignoreTarget(e.target))return;if(e.originalTarget)try{e.originalTarget.tagName}catch{return}this.scrollLeftStart=this.element.scrollLeft;this.scrollTopStart=this.element.scrollTop;this.clientXStart=e.clientX;this.clientYStart=e.clientY;this.document.addEventListener("mousemove",this._onMouseMove,!0);this.document.addEventListener("mouseup",this._endPan,!0);this.element.addEventListener("scroll",this._endPan,!0);e.preventDefault();e.stopPropagation();const t=document.activeElement;t&&!t.contains(e.target)&&t.blur()}#As(e){this.element.removeEventListener("scroll",this._endPan,!0);if(!(1&e.buttons)){this._endPan();return}const t=e.clientX-this.clientXStart,i=e.clientY-this.clientYStart;this.element.scrollTo({top:this.scrollTopStart-i,left:this.scrollLeftStart-t,behavior:"instant"});this.overlay.parentNode||document.body.append(this.overlay)}#Es(){this.element.removeEventListener("scroll",this._endPan,!0);this.document.removeEventListener("mousemove",this._onMouseMove,!0);this.document.removeEventListener("mouseup",this._endPan,!0);this.overlay.remove()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFDocumentProperties=void 0;var n=i(3),s=i(4);const a=["en-us","en-lr","my"],r={"8.5x11":"Letter","8.5x14":"Legal"},o={"297x420":"A3","210x297":"A4"};function getPageName(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}t.PDFDocumentProperties=class PDFDocumentProperties{#Ps=null;constructor({dialog:e,fields:t,closeButton:i},n,s,r,o){this.dialog=e;this.fields=t;this.overlayManager=n;this.l10n=r;this._fileNameLookup=o;this.#Cs();i.addEventListener("click",this.close.bind(this));this.overlayManager.register(this.dialog);s._on("pagechanging",(e=>{this._currentPageNumber=e.pageNumber}));s._on("rotationchanging",(e=>{this._pagesRotation=e.pagesRotation}));this._isNonMetricLocale=!0;r.getLanguage().then((e=>{this._isNonMetricLocale=a.includes(e)}))}async open(){await Promise.all([this.overlayManager.open(this.dialog),this._dataAvailableCapability.promise]);const e=this._currentPageNumber,t=this._pagesRotation;if(this.#Ps&&e===this.#Ps._currentPageNumber&&t===this.#Ps._pagesRotation){this.#xs();return}const{info:i,contentLength:s}=await this.pdfDocument.getMetadata(),[a,r,o,l,d,h]=await Promise.all([this._fileNameLookup(),this.#Ts(s),this.#Ms(i.CreationDate),this.#Ms(i.ModDate),this.pdfDocument.getPage(e).then((e=>this.#Is((0,n.getPageSizeInches)(e),t))),this.#ks(i.IsLinearized)]);this.#Ps=Object.freeze({fileName:a,fileSize:r,title:i.Title,author:i.Author,subject:i.Subject,keywords:i.Keywords,creationDate:o,modificationDate:l,creator:i.Creator,producer:i.Producer,version:i.PDFFormatVersion,pageCount:this.pdfDocument.numPages,pageSize:d,linearized:h,_currentPageNumber:e,_pagesRotation:t});this.#xs();const{length:c}=await this.pdfDocument.getDownloadInfo();if(s===c)return;const u=Object.assign(Object.create(null),this.#Ps);u.fileSize=await this.#Ts(c);this.#Ps=Object.freeze(u);this.#xs()}async close(){this.overlayManager.close(this.dialog)}setDocument(e){if(this.pdfDocument){this.#Cs();this.#xs(!0)}if(e){this.pdfDocument=e;this._dataAvailableCapability.resolve()}}#Cs(){this.pdfDocument=null;this.#Ps=null;this._dataAvailableCapability=new s.PromiseCapability;this._currentPageNumber=1;this._pagesRotation=0}#xs(e=!1){if(!e&&this.#Ps){if(this.overlayManager.active===this.dialog)for(const e in this.fields){const t=this.#Ps[e];this.fields[e].textContent=t||0===t?t:"-"}}else for(const e in this.fields)this.fields[e].textContent="-"}async#Ts(e=0){const t=e/1024,i=t/1024;if(t)return this.l10n.get("document_properties_"+(i>=1?"mb":"kb"),{size_mb:i>=1&&(+i.toPrecision(3)).toLocaleString(),size_kb:i<1&&(+t.toPrecision(3)).toLocaleString(),size_b:e.toLocaleString()})}async#Is(e,t){if(!e)return;t%180!=0&&(e={width:e.height,height:e.width});const i=(0,n.isPortraitOrientation)(e);let s={width:Math.round(100*e.width)/100,height:Math.round(100*e.height)/100},a={width:Math.round(25.4*e.width*10)/10,height:Math.round(25.4*e.height*10)/10},l=getPageName(s,i,r)||getPageName(a,i,o);if(!(l||Number.isInteger(a.width)&&Number.isInteger(a.height))){const t={width:25.4*e.width,height:25.4*e.height},n={width:Math.round(a.width),height:Math.round(a.height)};if(Math.abs(t.width-n.width)<.1&&Math.abs(t.height-n.height)<.1){l=getPageName(n,i,o);if(l){s={width:Math.round(n.width/25.4*100)/100,height:Math.round(n.height/25.4*100)/100};a=n}}}const[{width:d,height:h},c,u,p]=await Promise.all([this._isNonMetricLocale?s:a,this.l10n.get("document_properties_page_size_unit_"+(this._isNonMetricLocale?"inches":"millimeters")),l&&this.l10n.get(`document_properties_page_size_name_${l.toLowerCase()}`),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"))]);return this.l10n.get(`document_properties_page_size_dimension_${u?"name_":""}string`,{width:d.toLocaleString(),height:h.toLocaleString(),unit:c,name:u,orientation:p})}async#Ms(e){const t=s.PDFDateString.toDateObject(e);if(t)return this.l10n.get("document_properties_date_string",{date:t.toLocaleDateString(),time:t.toLocaleTimeString()})}#ks(e){return this.l10n.get("document_properties_linearized_"+(e?"yes":"no"))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFFindBar=void 0;var n=i(18),s=i(3);t.PDFFindBar=class PDFFindBar{constructor(e,t,i){this.opened=!1;this.bar=e.bar;this.toggleButton=e.toggleButton;this.findField=e.findField;this.highlightAll=e.highlightAllCheckbox;this.caseSensitive=e.caseSensitiveCheckbox;this.matchDiacritics=e.matchDiacriticsCheckbox;this.entireWord=e.entireWordCheckbox;this.findMsg=e.findMsg;this.findResultsCount=e.findResultsCount;this.findPreviousButton=e.findPreviousButton;this.findNextButton=e.findNextButton;this.eventBus=t;this.l10n=i;this.toggleButton.addEventListener("click",(()=>{this.toggle()}));this.findField.addEventListener("input",(()=>{this.dispatchEvent("")}));this.bar.addEventListener("keydown",(e=>{switch(e.keyCode){case 13:e.target===this.findField&&this.dispatchEvent("again",e.shiftKey);break;case 27:this.close()}}));this.findPreviousButton.addEventListener("click",(()=>{this.dispatchEvent("again",!0)}));this.findNextButton.addEventListener("click",(()=>{this.dispatchEvent("again",!1)}));this.highlightAll.addEventListener("click",(()=>{this.dispatchEvent("highlightallchange")}));this.caseSensitive.addEventListener("click",(()=>{this.dispatchEvent("casesensitivitychange")}));this.entireWord.addEventListener("click",(()=>{this.dispatchEvent("entirewordchange")}));this.matchDiacritics.addEventListener("click",(()=>{this.dispatchEvent("diacriticmatchingchange")}));this.eventBus._on("resize",this.#Ds.bind(this))}reset(){this.updateUIState()}dispatchEvent(e,t=!1){this.eventBus.dispatch("find",{source:this,type:e,query:this.findField.value,caseSensitive:this.caseSensitive.checked,entireWord:this.entireWord.checked,highlightAll:this.highlightAll.checked,findPrevious:t,matchDiacritics:this.matchDiacritics.checked})}updateUIState(e,t,i){let s=Promise.resolve(""),a="";switch(e){case n.FindState.FOUND:break;case n.FindState.PENDING:a="pending";break;case n.FindState.NOT_FOUND:s=this.l10n.get("find_not_found");a="notFound";break;case n.FindState.WRAPPED:s=this.l10n.get("find_reached_"+(t?"top":"bottom"))}this.findField.setAttribute("data-status",a);this.findField.setAttribute("aria-invalid",e===n.FindState.NOT_FOUND);s.then((e=>{this.findMsg.setAttribute("data-status",a);this.findMsg.textContent=e;this.#Ds()}));this.updateResultsCount(i)}updateResultsCount({current:e=0,total:t=0}={}){let i=Promise.resolve("");if(t>0)if(t>1e3){let e="find_match_count_limit";i=this.l10n.get(e,{limit:1e3})}else{let n="find_match_count";i=this.l10n.get(n,{current:e,total:t})}i.then((e=>{this.findResultsCount.textContent=e;this.#Ds()}))}open(){if(!this.opened){this.opened=!0;(0,s.toggleExpandedBtn)(this.toggleButton,!0,this.bar)}this.findField.select();this.findField.focus();this.#Ds()}close(){if(this.opened){this.opened=!1;(0,s.toggleExpandedBtn)(this.toggleButton,!1,this.bar);this.eventBus.dispatch("findbarclose",{source:this})}}toggle(){this.opened?this.close():this.open()}#Ds(){if(!this.opened)return;this.bar.classList.remove("wrapContainers");this.bar.clientHeight>this.bar.firstElementChild.clientHeight&&this.bar.classList.add("wrapContainers")}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFFindController=t.FindState=void 0;var n=i(3),s=i(19),a=i(4);const r={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3};t.FindState=r;const o={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},l=new Set([12441,12442,2381,2509,2637,2765,2893,3021,3149,3277,3387,3388,3405,3530,3642,3770,3972,4153,4154,5908,5940,6098,6752,6980,7082,7083,7154,7155,11647,43014,43052,43204,43347,43456,43766,44013,3158,3953,3954,3962,3963,3964,3965,3968,3956]);let d;const h=/\p{M}+/gu,c=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,u=/([^\p{M}])\p{M}*$/u,p=/^\p{M}*([^\p{M}])/u,g=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,f=new Map,m=new Map;let b=null,v=null;function normalize(e){const t=[];let i,n;for(;null!==(i=g.exec(e));){let{index:e}=i;for(const n of i[0]){let i=f.get(n);if(!i){i=n.normalize("NFD").length;f.set(n,i)}t.push([i,e++])}}if(0===t.length&&b)n=b;else if(t.length>0&&v)n=v;else{const e=`([${Object.keys(o).join("")}])|([${(0,s.getNormalizeWithNFKC)()}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;n=0===t.length?b=new RegExp(e+"|(\\u0000)","gum"):v=new RegExp(e+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const a=[];for(;null!==(i=h.exec(e));)a.push([i[0].length,i.index]);let r=e.normalize("NFD");const l=[[0,0]];let d=0,c=0,u=0,p=0,_=0,w=!1;r=r.replace(n,((e,i,n,s,r,h,g,f,b,v)=>{v-=p;if(i){const e=o[i],t=e.length;for(let e=1;e<t;e++)l.push([v-u+e,u-e]);u-=t-1;return e}if(n){let e=m.get(n);if(!e){e=n.normalize("NFKC");m.set(n,e)}const t=e.length;for(let e=1;e<t;e++)l.push([v-u+e,u-e]);u-=t-1;return e}if(s){w=!0;if(v+_===a[d]?.[1])++d;else{l.push([v-1-u+1,u-1]);u-=1;p+=1}l.push([v-u+1,u]);p+=1;_+=1;return s.charAt(0)}if(r){const e=r.endsWith("\n"),t=e?r.length-2:r.length;w=!0;let i=t;if(v+_===a[d]?.[1]){i-=a[d][0];++d}for(let e=1;e<=i;e++)l.push([v-1-u+e,u-e]);u-=i;p+=i;if(e){v+=t-1;l.push([v-u+1,1+u]);u+=1;p+=1;_+=1;return r.slice(0,t)}return r}if(h){const e=h.length-2;l.push([v-u+e,1+u]);u+=1;p+=1;_+=1;return h.slice(0,-2)}if(g){const e=g.length-1;l.push([v-u+e,u]);p+=1;_+=1;return g.slice(0,-1)}if(f){l.push([v-u+1,u-1]);u-=1;p+=1;_+=1;return" "}if(v+_===t[c]?.[1]){const e=t[c][0]-1;++c;for(let t=1;t<=e;t++)l.push([v-(u-t),u-t]);u-=e;p+=e}return b}));l.push([r.length,u]);return[r,l,w]}function getOriginalIndex(e,t,i){if(!e)return[t,i];const s=t,a=t+i-1;let r=(0,n.binarySearchFirstItem)(e,(e=>e[0]>=s));e[r][0]>s&&--r;let o=(0,n.binarySearchFirstItem)(e,(e=>e[0]>=a),r);e[o][0]>a&&--o;const l=s+e[r][1];return[l,a+e[o][1]+1-l]}t.PDFFindController=class PDFFindController{#Ls=null;#Fs=!0;#Rs=0;constructor({linkService:e,eventBus:t,updateMatchesCountOnProgress:i=!0}){this._linkService=e;this._eventBus=t;this.#Fs=i;this.onIsPageVisible=null;this.#Cs();t._on("find",this.#Os.bind(this));t._on("findbarclose",this.#Ns.bind(this))}get highlightMatches(){return this._highlightMatches}get pageMatches(){return this._pageMatches}get pageMatchesLength(){return this._pageMatchesLength}get selected(){return this._selected}get state(){return this.#Ls}setDocument(e){this._pdfDocument&&this.#Cs();if(e){this._pdfDocument=e;this._firstPageCapability.resolve()}}#Os(e){if(!e)return;if(!1===e.phraseSearch){console.error("The `phraseSearch`-parameter was removed, please provide an Array of strings in the `query`-parameter instead.");"string"==typeof e.query&&(e.query=e.query.match(/\S+/g))}const t=this._pdfDocument,{type:i}=e;(null===this.#Ls||this.#Bs(e))&&(this._dirtyMatch=!0);this.#Ls=e;"highlightallchange"!==i&&this.#Un(r.PENDING);this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;this.#Kt();const e=!this._highlightMatches,n=!!this._findTimeout;if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(i)if(this._dirtyMatch)this.#Vs();else if("again"===i){this.#Vs();e&&this.#Ls.highlightAll&&this.#Us()}else if("highlightallchange"===i){n?this.#Vs():this._highlightMatches=!0;this.#Us()}else this.#Vs();else this._findTimeout=setTimeout((()=>{this.#Vs();this._findTimeout=null}),250)}))}scrollMatchIntoView({element:e=null,selectedLeft:t=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!e)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;const a={top:-50,left:t+-400};(0,n.scrollIntoView)(e,a,!0)}#Cs(){this._highlightMatches=!1;this._scrollMatches=!1;this._pdfDocument=null;this._pageMatches=[];this._pageMatchesLength=[];this.#Rs=0;this.#Ls=null;this._selected={pageIdx:-1,matchIdx:-1};this._offset={pageIdx:null,matchIdx:null,wrapped:!1};this._extractTextPromises=[];this._pageContents=[];this._pageDiffs=[];this._hasDiacritics=[];this._matchesCountTotal=0;this._pagesToSearch=null;this._pendingFindMatches=new Set;this._resumePageIdx=null;this._dirtyMatch=!1;clearTimeout(this._findTimeout);this._findTimeout=null;this._firstPageCapability=new a.PromiseCapability}get#zs(){const{query:e}=this.#Ls;if("string"==typeof e){if(e!==this._rawQuery){this._rawQuery=e;[this._normalizedQuery]=normalize(e)}return this._normalizedQuery}return(e||[]).filter((e=>!!e)).map((e=>normalize(e)[0]))}#Bs(e){const t=e.query,i=this.#Ls.query,n=typeof t;if(n!==typeof i)return!0;if("string"===n){if(t!==i)return!0}else if(JSON.stringify(t)!==JSON.stringify(i))return!0;switch(e.type){case"again":const e=this._selected.pageIdx+1,t=this._linkService;return e>=1&&e<=t.pagesCount&&e!==t.page&&!(this.onIsPageVisible?.(e)??1);case"highlightallchange":return!1}return!0}#Hs(e,t,i){let n=e.slice(0,t).match(u);if(n){const i=e.charCodeAt(t),a=n[1].charCodeAt(0);if((0,s.getCharacterType)(i)===(0,s.getCharacterType)(a))return!1}n=e.slice(t+i).match(p);if(n){const a=e.charCodeAt(t+i-1),r=n[1].charCodeAt(0);if((0,s.getCharacterType)(a)===(0,s.getCharacterType)(r))return!1}return!0}#js(e,t,i,n){const s=this._pageMatches[i]=[],a=this._pageMatchesLength[i]=[];if(!e)return;const r=this._pageDiffs[i];let o;for(;null!==(o=e.exec(n));){if(t&&!this.#Hs(n,o.index,o[0].length))continue;const[e,i]=getOriginalIndex(r,o.index,o[0].length);if(i){s.push(e);a.push(i)}}}#Ws(e,t){const{matchDiacritics:i}=this.#Ls;let n=!1;const s="[ ]*";(e=e.replaceAll(c,((e,s,a,r,o,d)=>{if(s)return`[ ]*\\${s}[ ]*`;if(a)return`[ ]*${a}[ ]*`;if(r)return"[ ]+";if(i)return o||d;if(o)return l.has(o.charCodeAt(0))?o:"";if(t){n=!0;return`${d}\\p{M}*`}return d}))).endsWith(s)&&(e=e.slice(0,e.length-4));if(i&&t){d||=String.fromCharCode(...l);n=!0;e=`${e}(?=[${d}]|[^\\p{M}]|$)`}return[n,e]}#Gs(e){let t=this.#zs;if(0===t.length)return;const{caseSensitive:i,entireWord:n}=this.#Ls,s=this._pageContents[e],a=this._hasDiacritics[e];let r=!1;"string"==typeof t?[r,t]=this.#Ws(t,a):t=t.sort().reverse().map((e=>{const[t,i]=this.#Ws(e,a);r||=t;return`(${i})`})).join("|");t=t?new RegExp(t,`g${r?"u":""}${i?"":"i"}`):null;this.#js(t,n,e,s);this.#Ls.highlightAll&&this.#$s(e);if(this._resumePageIdx===e){this._resumePageIdx=null;this.#qs()}const o=this._pageMatches[e].length;this._matchesCountTotal+=o;this.#Fs?o>0&&this.#Xs():++this.#Rs===this._linkService.pagesCount&&this.#Xs()}#Kt(){if(this._extractTextPromises.length>0)return;let e=Promise.resolve();const t={disableNormalization:!0};for(let i=0,n=this._linkService.pagesCount;i<n;i++){const n=new a.PromiseCapability;this._extractTextPromises[i]=n.promise;e=e.then((()=>this._pdfDocument.getPage(i+1).then((e=>e.getTextContent(t))).then((e=>{const t=[];for(const i of e.items){t.push(i.str);i.hasEOL&&t.push("\n")}[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=normalize(t.join(""));n.resolve()}),(e=>{console.error(`Unable to get text content for page ${i+1}`,e);this._pageContents[i]="";this._pageDiffs[i]=null;this._hasDiacritics[i]=!1;n.resolve()}))))}}#$s(e){this._scrollMatches&&this._selected.pageIdx===e&&(this._linkService.page=e+1);this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}#Us(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#Vs(){const e=this.#Ls.findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;this._highlightMatches=!0;if(this._dirtyMatch){this._dirtyMatch=!1;this._selected.pageIdx=this._selected.matchIdx=-1;this._offset.pageIdx=t;this._offset.matchIdx=null;this._offset.wrapped=!1;this._resumePageIdx=null;this._pageMatches.length=0;this._pageMatchesLength.length=0;this.#Rs=0;this._matchesCountTotal=0;this.#Us();for(let e=0;e<i;e++)if(!this._pendingFindMatches.has(e)){this._pendingFindMatches.add(e);this._extractTextPromises[e].then((()=>{this._pendingFindMatches.delete(e);this.#Gs(e)}))}}if(0===this.#zs.length){this.#Un(r.FOUND);return}if(this._resumePageIdx)return;const n=this._offset;this._pagesToSearch=i;if(null!==n.matchIdx){const t=this._pageMatches[n.pageIdx].length;if(!e&&n.matchIdx+1<t||e&&n.matchIdx>0){n.matchIdx=e?n.matchIdx-1:n.matchIdx+1;this.#Ks(!0);return}this.#Ys(e)}this.#qs()}#Qs(e){const t=this._offset,i=e.length,n=this.#Ls.findPrevious;if(i){t.matchIdx=n?i-1:0;this.#Ks(!0);return!0}this.#Ys(n);if(t.wrapped){t.matchIdx=null;if(this._pagesToSearch<0){this.#Ks(!1);return!0}}return!1}#qs(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;e=this._pageMatches[t];if(!e){this._resumePageIdx=t;break}}while(!this.#Qs(e))}#Ys(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1;t.matchIdx=null;this._pagesToSearch--;if(t.pageIdx>=i||t.pageIdx<0){t.pageIdx=e?i-1:0;t.wrapped=!0}}#Ks(e=!1){let t=r.NOT_FOUND;const i=this._offset.wrapped;this._offset.wrapped=!1;if(e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx;this._selected.matchIdx=this._offset.matchIdx;t=i?r.WRAPPED:r.FOUND;-1!==e&&e!==this._selected.pageIdx&&this.#$s(e)}this.#Un(t,this.#Ls.findPrevious);if(-1!==this._selected.pageIdx){this._scrollMatches=!0;this.#$s(this._selected.pageIdx)}}#Ns(e){const t=this._pdfDocument;this._firstPageCapability.promise.then((()=>{if(this._pdfDocument&&(!t||this._pdfDocument===t)){if(this._findTimeout){clearTimeout(this._findTimeout);this._findTimeout=null}if(this._resumePageIdx){this._resumePageIdx=null;this._dirtyMatch=!0}this.#Un(r.FOUND);this._highlightMatches=!1;this.#Us()}}))}#Zs(){const{pageIdx:e,matchIdx:t}=this._selected;let i=0,n=this._matchesCountTotal;if(-1!==t){for(let t=0;t<e;t++)i+=this._pageMatches[t]?.length||0;i+=t+1}(i<1||i>n)&&(i=n=0);return{current:i,total:n}}#Xs(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Zs()})}#Un(e,t=!1){(this.#Fs||this.#Rs===this._linkService.pagesCount&&e!==r.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,matchesCount:this.#Zs(),rawQuery:this.#Ls?.query??null})}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.CharacterType=void 0;t.getCharacterType=function getCharacterType(e){if(function isAlphabeticalScript(e){return e<11904}(e))return function isAscii(e){return 0==(65408&e)}(e)?function isAsciiSpace(e){return 32===e||9===e||13===e||10===e}(e)?i.SPACE:function isAsciiAlpha(e){return e>=97&&e<=122||e>=65&&e<=90}(e)||function isAsciiDigit(e){return e>=48&&e<=57}(e)||95===e?i.ALPHA_LETTER:i.PUNCT:function isThai(e){return 3584==(65408&e)}(e)?i.THAI_LETTER:160===e?i.SPACE:i.ALPHA_LETTER;if(function isHan(e){return e>=13312&&e<=40959||e>=63744&&e<=64255}(e))return i.HAN_LETTER;if(function isKatakana(e){return e>=12448&&e<=12543}(e))return i.KATAKANA_LETTER;if(function isHiragana(e){return e>=12352&&e<=12447}(e))return i.HIRAGANA_LETTER;if(function isHalfwidthKatakana(e){return e>=65376&&e<=65439}(e))return i.HALFWIDTH_KATAKANA_LETTER;return i.ALPHA_LETTER};t.getNormalizeWithNFKC=function getNormalizeWithNFKC(){n||=" ¨ª¯²-µ¸-º¼-¾Ĳ-ĳĿ-ŀŉſǄ-ǌǱ-ǳʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕　〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ﬀ-ﬆﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ！-ﾾￂ-ￇￊ-ￏￒ-ￗￚ-ￜ￠-￦";return n};const i={SPACE:0,ALPHA_LETTER:1,PUNCT:2,HAN_LETTER:3,KATAKANA_LETTER:4,HIRAGANA_LETTER:5,HALFWIDTH_KATAKANA_LETTER:6,THAI_LETTER:7};t.CharacterType=i;let n},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFHistory=void 0;t.isDestArraysEqual=isDestArraysEqual;t.isDestHashesEqual=isDestHashesEqual;var n=i(3),s=i(6);function getCurrentHash(){return document.location.hash}t.PDFHistory=class PDFHistory{constructor({linkService:e,eventBus:t}){this.linkService=e;this.eventBus=t;this._initialized=!1;this._fingerprint="";this.reset();this._boundEvents=null;this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1;this.eventBus._on("pagesloaded",(e=>{this._isPagesLoaded=!!e.pagesCount}),{once:!0})}))}initialize({fingerprint:e,resetHistory:t=!1,updateUrl:i=!1}){if(!e||"string"!=typeof e){console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');return}this._initialized&&this.reset();const n=""!==this._fingerprint&&this._fingerprint!==e;this._fingerprint=e;this._updateUrl=!0===i;this._initialized=!0;this._bindEvents();const s=window.history.state;this._popStateInProgress=!1;this._blockHashChange=0;this._currentHash=getCurrentHash();this._numPositionUpdates=0;this._uid=this._maxUid=0;this._destination=null;this._position=null;if(!this._isValidState(s,!0)||t){const{hash:e,page:i,rotation:s}=this._parseCurrentHash(!0);if(!e||n||t){this._pushOrReplaceState(null,!0);return}this._pushOrReplaceState({hash:e,page:i,rotation:s},!0);return}const a=s.destination;this._updateInternalState(a,s.uid,!0);void 0!==a.rotation&&(this._initialRotation=a.rotation);if(a.dest){this._initialBookmark=JSON.stringify(a.dest);this._destination.page=null}else a.hash?this._initialBookmark=a.hash:a.page&&(this._initialBookmark=`page=${a.page}`)}reset(){if(this._initialized){this._pageHide();this._initialized=!1;this._unbindEvents()}if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._initialBookmark=null;this._initialRotation=null}push({namedDest:e=null,explicitDest:t,pageNumber:i}){if(!this._initialized)return;if(e&&"string"!=typeof e){console.error(`PDFHistory.push: "${e}" is not a valid namedDest parameter.`);return}if(!Array.isArray(t)){console.error(`PDFHistory.push: "${t}" is not a valid explicitDest parameter.`);return}if(!this._isValidPage(i)&&(null!==i||this._destination)){console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);return}const n=e||JSON.stringify(t);if(!n)return;let s=!1;if(this._destination&&(isDestHashesEqual(this._destination.hash,n)||isDestArraysEqual(this._destination.dest,t))){if(this._destination.page)return;s=!0}if(!this._popStateInProgress||s){this._pushOrReplaceState({dest:t,hash:n,page:i,rotation:this.linkService.rotation},s);if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then((()=>{this._popStateInProgress=!1}))}}}pushPage(e){if(this._initialized)if(this._isValidPage(e)){if(this._destination?.page!==e&&!this._popStateInProgress){this._pushOrReplaceState({dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation});if(!this._popStateInProgress){this._popStateInProgress=!0;Promise.resolve().then((()=>{this._popStateInProgress=!1}))}}}else console.error(`PDFHistory.pushPage: "${e}" is not a valid page number.`)}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this._tryPushCurrentPosition()}back(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;this._isValidState(e)&&e.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const e=window.history.state;this._isValidState(e)&&e.uid<this._maxUid&&window.history.forward()}get popStateInProgress(){return this._initialized&&(this._popStateInProgress||this._blockHashChange>0)}get initialBookmark(){return this._initialized?this._initialBookmark:null}get initialRotation(){return this._initialized?this._initialRotation:null}_pushOrReplaceState(e,t=!1){const i=t||!this._destination,n={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:e};this._updateInternalState(e,n.uid);let s;if(this._updateUrl&&e?.hash){const t=document.location.href.split("#")[0];t.startsWith("file://")||(s=`${t}#${e.hash}`)}i?window.history.replaceState(n,"",s):window.history.pushState(n,"",s)}_tryPushCurrentPosition(e=!1){if(!this._position)return;let t=this._position;if(e){t=Object.assign(Object.create(null),this._position);t.temporary=!0}if(!this._destination){this._pushOrReplaceState(t);return}if(this._destination.temporary){this._pushOrReplaceState(t,!0);return}if(this._destination.hash===t.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=t.first&&this._destination.page<=t.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this._pushOrReplaceState(t,i)}_isValidPage(e){return Number.isInteger(e)&&e>0&&e<=this.linkService.pagesCount}_isValidState(e,t=!1){if(!e)return!1;if(e.fingerprint!==this._fingerprint){if(!t)return!1;{if("string"!=typeof e.fingerprint||e.fingerprint.length!==this._fingerprint.length)return!1;const[t]=performance.getEntriesByType("navigation");if("reload"!==t?.type)return!1}}return!(!Number.isInteger(e.uid)||e.uid<0)&&(null!==e.destination&&"object"==typeof e.destination)}_updateInternalState(e,t,i=!1){if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}i&&e?.temporary&&delete e.temporary;this._destination=e;this._uid=t;this._maxUid=Math.max(this._maxUid,t);this._numPositionUpdates=0}_parseCurrentHash(e=!1){const t=unescape(getCurrentHash()).substring(1),i=(0,n.parseQueryString)(t),s=i.get("nameddest")||"";let a=0|i.get("page");(!this._isValidPage(a)||e&&s.length>0)&&(a=null);return{hash:t,page:a,rotation:this.linkService.rotation}}_updateViewarea({location:e}){if(this._updateViewareaTimeout){clearTimeout(this._updateViewareaTimeout);this._updateViewareaTimeout=null}this._position={hash:e.pdfOpenParams.substring(1),page:this.linkService.page,first:e.pageNumber,rotation:e.rotation};if(!this._popStateInProgress){this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++;this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this._tryPushCurrentPosition(!0);this._updateViewareaTimeout=null}),1e3)}}_popState({state:e}){const t=getCurrentHash(),i=this._currentHash!==t;this._currentHash=t;if(!e){this._uid++;const{hash:e,page:t,rotation:i}=this._parseCurrentHash();this._pushOrReplaceState({hash:e,page:t,rotation:i},!0);return}if(!this._isValidState(e))return;this._popStateInProgress=!0;if(i){this._blockHashChange++;(0,s.waitOnEventOrTimeout)({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--}))}const a=e.destination;this._updateInternalState(a,e.uid,!0);(0,n.isValidRotation)(a.rotation)&&(this.linkService.rotation=a.rotation);a.dest?this.linkService.goToDestination(a.dest):a.hash?this.linkService.setHash(a.hash):a.page&&(this.linkService.page=a.page);Promise.resolve().then((()=>{this._popStateInProgress=!1}))}_pageHide(){this._destination&&!this._destination.temporary||this._tryPushCurrentPosition()}_bindEvents(){if(!this._boundEvents){this._boundEvents={updateViewarea:this._updateViewarea.bind(this),popState:this._popState.bind(this),pageHide:this._pageHide.bind(this)};this.eventBus._on("updateviewarea",this._boundEvents.updateViewarea);window.addEventListener("popstate",this._boundEvents.popState);window.addEventListener("pagehide",this._boundEvents.pageHide)}}_unbindEvents(){if(this._boundEvents){this.eventBus._off("updateviewarea",this._boundEvents.updateViewarea);window.removeEventListener("popstate",this._boundEvents.popState);window.removeEventListener("pagehide",this._boundEvents.pageHide);this._boundEvents=null}}};function isDestHashesEqual(e,t){if("string"!=typeof e||"string"!=typeof t)return!1;if(e===t)return!0;return(0,n.parseQueryString)(e).get("nameddest")===t}function isDestArraysEqual(e,t){function isEntryEqual(e,t){if(typeof e!=typeof t)return!1;if(Array.isArray(e)||Array.isArray(t))return!1;if(null!==e&&"object"==typeof e&&null!==t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const i in e)if(!isEntryEqual(e[i],t[i]))return!1;return!0}return e===t||Number.isNaN(e)&&Number.isNaN(t)}if(!Array.isArray(e)||!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let i=0,n=e.length;i<n;i++)if(!isEntryEqual(e[i],t[i]))return!1;return!0}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFLayerViewer=void 0;var n=i(13);class PDFLayerViewer extends n.BaseTreeViewer{constructor(e){super(e);this.l10n=e.l10n;this.eventBus._on("optionalcontentconfigchanged",(e=>{this.#Js(e.promise)}));this.eventBus._on("resetlayers",(()=>{this.#Js()}));this.eventBus._on("togglelayerstree",this._toggleAllTreeItems.bind(this))}reset(){super.reset();this._optionalContentConfig=null;this._optionalContentHash=null}_dispatchEvent(e){this.eventBus.dispatch("layersloaded",{source:this,layersCount:e})}_bindLink(e,{groupId:t,input:i}){const setVisibility=()=>{this._optionalContentConfig.setVisibility(t,i.checked);this._optionalContentHash=this._optionalContentConfig.getHash();this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(this._optionalContentConfig)})};e.onclick=t=>{if(t.target===i){setVisibility();return!0}if(t.target!==e)return!0;i.checked=!i.checked;setVisibility();return!1}}async _setNestedName(e,{name:t=null}){if("string"!=typeof t){e.textContent=await this.l10n.get("additional_layers");e.style.fontStyle="italic"}else e.textContent=this._normalizeTextContent(t)}_addToggleButton(e,{name:t=null}){super._addToggleButton(e,null===t)}_toggleAllTreeItems(){this._optionalContentConfig&&super._toggleAllTreeItems()}render({optionalContentConfig:e,pdfDocument:t}){this._optionalContentConfig&&this.reset();this._optionalContentConfig=e||null;this._pdfDocument=t||null;const i=e?.getOrder();if(!i){this._dispatchEvent(0);return}this._optionalContentHash=e.getHash();const n=document.createDocumentFragment(),s=[{parent:n,groups:i}];let a=0,r=!1;for(;s.length>0;){const t=s.shift();for(const i of t.groups){const n=document.createElement("div");n.className="treeItem";const o=document.createElement("a");n.append(o);if("object"==typeof i){r=!0;this._addToggleButton(n,i);this._setNestedName(o,i);const e=document.createElement("div");e.className="treeItems";n.append(e);s.push({parent:e,groups:i.order})}else{const t=e.getGroup(i),n=document.createElement("input");this._bindLink(o,{groupId:i,input:n});n.type="checkbox";n.checked=t.visible;const s=document.createElement("label");s.textContent=this._normalizeTextContent(t.name);s.append(n);o.append(s);a++}t.parent.append(n)}}this._finishRendering(n,a,r)}async#Js(e=null){if(!this._optionalContentConfig)return;const t=this._pdfDocument,i=await(e||t.getOptionalContentConfig());if(t===this._pdfDocument){if(e){if(i.getHash()===this._optionalContentHash)return}else this.eventBus.dispatch("optionalcontentconfig",{source:this,promise:Promise.resolve(i)});this.render({optionalContentConfig:i,pdfDocument:this._pdfDocument})}}}t.PDFLayerViewer=PDFLayerViewer},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFOutlineViewer=void 0;var n=i(13),s=i(4),a=i(3);class PDFOutlineViewer extends n.BaseTreeViewer{constructor(e){super(e);this.linkService=e.linkService;this.downloadManager=e.downloadManager;this.eventBus._on("toggleoutlinetree",this._toggleAllTreeItems.bind(this));this.eventBus._on("currentoutlineitem",this._currentOutlineItem.bind(this));this.eventBus._on("pagechanging",(e=>{this._currentPageNumber=e.pageNumber}));this.eventBus._on("pagesloaded",(e=>{this._isPagesLoaded=!!e.pagesCount;this._currentOutlineItemCapability&&!this._currentOutlineItemCapability.settled&&this._currentOutlineItemCapability.resolve(this._isPagesLoaded)}));this.eventBus._on("sidebarviewchanged",(e=>{this._sidebarView=e.view}))}reset(){super.reset();this._outline=null;this._pageNumberToDestHashCapability=null;this._currentPageNumber=1;this._isPagesLoaded=null;this._currentOutlineItemCapability&&!this._currentOutlineItemCapability.settled&&this._currentOutlineItemCapability.resolve(!1);this._currentOutlineItemCapability=null}_dispatchEvent(e){this._currentOutlineItemCapability=new s.PromiseCapability;0===e||this._pdfDocument?.loadingParams.disableAutoFetch?this._currentOutlineItemCapability.resolve(!1):null!==this._isPagesLoaded&&this._currentOutlineItemCapability.resolve(this._isPagesLoaded);this.eventBus.dispatch("outlineloaded",{source:this,outlineCount:e,currentOutlineItemPromise:this._currentOutlineItemCapability.promise})}_bindLink(e,{url:t,newWindow:i,action:n,attachment:s,dest:a,setOCGState:r}){const{linkService:o}=this;if(t)o.addLinkAttributes(e,t,i);else if(n){e.href=o.getAnchorUrl("");e.onclick=()=>{o.executeNamedAction(n);return!1}}else if(s){e.href=o.getAnchorUrl("");e.onclick=()=>{this.downloadManager.openOrDownloadData(e,s.content,s.filename);return!1}}else if(r){e.href=o.getAnchorUrl("");e.onclick=()=>{o.executeSetOCGState(r);return!1}}else{e.href=o.getDestinationHash(a);e.onclick=e=>{this._updateCurrentTreeItem(e.target.parentNode);a&&o.goToDestination(a);return!1}}}_setStyles(e,{bold:t,italic:i}){t&&(e.style.fontWeight="bold");i&&(e.style.fontStyle="italic")}_addToggleButton(e,{count:t,items:i}){let n=!1;if(t<0){let e=i.length;if(e>0){const t=[...i];for(;t.length>0;){const{count:i,items:n}=t.shift();if(i>0&&n.length>0){e+=n.length;t.push(...n)}}}Math.abs(t)===e&&(n=!0)}super._addToggleButton(e,n)}_toggleAllTreeItems(){this._outline&&super._toggleAllTreeItems()}render({outline:e,pdfDocument:t}){this._outline&&this.reset();this._outline=e||null;this._pdfDocument=t||null;if(!e){this._dispatchEvent(0);return}const i=document.createDocumentFragment(),n=[{parent:i,items:e}];let s=0,a=!1;for(;n.length>0;){const e=n.shift();for(const t of e.items){const i=document.createElement("div");i.className="treeItem";const r=document.createElement("a");this._bindLink(r,t);this._setStyles(r,t);r.textContent=this._normalizeTextContent(t.title);i.append(r);if(t.items.length>0){a=!0;this._addToggleButton(i,t);const e=document.createElement("div");e.className="treeItems";i.append(e);n.push({parent:e,items:t.items})}e.parent.append(i);s++}}this._finishRendering(i,s,a)}async _currentOutlineItem(){if(!this._isPagesLoaded)throw new Error("_currentOutlineItem: All pages have not been loaded.");if(!this._outline||!this._pdfDocument)return;const e=await this._getPageNumberToDestHash(this._pdfDocument);if(e){this._updateCurrentTreeItem(null);if(this._sidebarView===a.SidebarView.OUTLINE)for(let t=this._currentPageNumber;t>0;t--){const i=e.get(t);if(!i)continue;const n=this.container.querySelector(`a[href="${i}"]`);if(n){this._scrollToCurrentTreeItem(n.parentNode);break}}}}async _getPageNumberToDestHash(e){if(this._pageNumberToDestHashCapability)return this._pageNumberToDestHashCapability.promise;this._pageNumberToDestHashCapability=new s.PromiseCapability;const t=new Map,i=new Map,n=[{nesting:0,items:this._outline}];for(;n.length>0;){const s=n.shift(),a=s.nesting;for(const{dest:r,items:o}of s.items){let s,l;if("string"==typeof r){s=await e.getDestination(r);if(e!==this._pdfDocument)return null}else s=r;if(Array.isArray(s)){const[n]=s;if("object"==typeof n&&null!==n){l=this.linkService._cachedPageNumber(n);if(!l)try{l=await e.getPageIndex(n)+1;if(e!==this._pdfDocument)return null;this.linkService.cachePageRef(l,n)}catch{}}else Number.isInteger(n)&&(l=n+1);if(Number.isInteger(l)&&(!t.has(l)||a>i.get(l))){const e=this.linkService.getDestinationHash(r);t.set(l,e);i.set(l,a)}}o.length>0&&n.push({nesting:a+1,items:o})}}this._pageNumberToDestHashCapability.resolve(t.size>0?t:null);return this._pageNumberToDestHashCapability.promise}}t.PDFOutlineViewer=PDFOutlineViewer},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFPresentationMode=void 0;var n=i(3),s=i(4);const a="pdfPresentationMode",r="pdfPresentationModeControls",o=Math.PI/6;t.PDFPresentationMode=class PDFPresentationMode{#Ls=n.PresentationModeState.UNKNOWN;#ea=null;constructor({container:e,pdfViewer:t,eventBus:i}){this.container=e;this.pdfViewer=t;this.eventBus=i;this.contextMenuOpen=!1;this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0;this.touchSwipeState=null}async request(){const{container:e,pdfViewer:t}=this;if(this.active||!t.pagesCount||!e.requestFullscreen)return!1;this.#ta();this.#ia(n.PresentationModeState.CHANGING);const i=e.requestFullscreen();this.#ea={pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null};if(!(t.spreadMode===n.SpreadMode.NONE||t.pageViewsReady&&t.hasEqualPageSizes)){console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes.");this.#ea.spreadMode=t.spreadMode}t.annotationEditorMode!==s.AnnotationEditorType.DISABLE&&(this.#ea.annotationEditorMode=t.annotationEditorMode);try{await i;t.focus();return!0}catch{this.#na();this.#ia(n.PresentationModeState.NORMAL)}return!1}get active(){return this.#Ls===n.PresentationModeState.CHANGING||this.#Ls===n.PresentationModeState.FULLSCREEN}#sa(e){if(!this.active)return;e.preventDefault();const t=(0,n.normalizeWheelEventDelta)(e),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)){(this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&this.#aa();this.mouseScrollDelta+=t;if(Math.abs(this.mouseScrollDelta)>=.1){const e=this.mouseScrollDelta;this.#aa();(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}}}#ia(e){this.#Ls=e;this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})}#ra(){this.#ia(n.PresentationModeState.FULLSCREEN);this.container.classList.add(a);setTimeout((()=>{this.pdfViewer.scrollMode=n.ScrollMode.PAGE;null!==this.#ea.spreadMode&&(this.pdfViewer.spreadMode=n.SpreadMode.NONE);this.pdfViewer.currentPageNumber=this.#ea.pageNumber;this.pdfViewer.currentScaleValue="page-fit";null!==this.#ea.annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:s.AnnotationEditorType.NONE})}),0);this.#oa();this.#la();this.contextMenuOpen=!1;window.getSelection().removeAllRanges()}#da(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(a);setTimeout((()=>{this.#na();this.#ia(n.PresentationModeState.NORMAL);this.pdfViewer.scrollMode=this.#ea.scrollMode;null!==this.#ea.spreadMode&&(this.pdfViewer.spreadMode=this.#ea.spreadMode);this.pdfViewer.currentScaleValue=this.#ea.scaleValue;this.pdfViewer.currentPageNumber=e;null!==this.#ea.annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:this.#ea.annotationEditorMode});this.#ea=null}),0);this.#ha();this.#ca();this.#aa();this.contextMenuOpen=!1}#ua(e){if(this.contextMenuOpen){this.contextMenuOpen=!1;e.preventDefault()}else if(!(0!==e.button||e.target.href&&e.target.parentNode?.hasAttribute("data-internal-link"))){e.preventDefault();e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()}}#pa(){this.contextMenuOpen=!0}#la(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(r);this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(r);delete this.controlsTimeout}),3e3)}#ca(){if(this.controlsTimeout){clearTimeout(this.controlsTimeout);this.container.classList.remove(r);delete this.controlsTimeout}}#aa(){this.mouseScrollTimeStamp=0;this.mouseScrollDelta=0}#ga(e){if(this.active)if(e.touches.length>1)this.touchSwipeState=null;else switch(e.type){case"touchstart":this.touchSwipeState={startX:e.touches[0].pageX,startY:e.touches[0].pageY,endX:e.touches[0].pageX,endY:e.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=e.touches[0].pageX;this.touchSwipeState.endY=e.touches[0].pageY;e.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let t=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,n=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(n,i));Math.abs(i)>50&&(s<=o||s>=Math.PI-o)?t=i:Math.abs(n)>50&&Math.abs(s-Math.PI/2)<=o&&(t=n);t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}}#oa(){this.showControlsBind=this.#la.bind(this);this.mouseDownBind=this.#ua.bind(this);this.mouseWheelBind=this.#sa.bind(this);this.resetMouseScrollStateBind=this.#aa.bind(this);this.contextMenuBind=this.#pa.bind(this);this.touchSwipeBind=this.#ga.bind(this);window.addEventListener("mousemove",this.showControlsBind);window.addEventListener("mousedown",this.mouseDownBind);window.addEventListener("wheel",this.mouseWheelBind,{passive:!1});window.addEventListener("keydown",this.resetMouseScrollStateBind);window.addEventListener("contextmenu",this.contextMenuBind);window.addEventListener("touchstart",this.touchSwipeBind);window.addEventListener("touchmove",this.touchSwipeBind);window.addEventListener("touchend",this.touchSwipeBind)}#ha(){window.removeEventListener("mousemove",this.showControlsBind);window.removeEventListener("mousedown",this.mouseDownBind);window.removeEventListener("wheel",this.mouseWheelBind,{passive:!1});window.removeEventListener("keydown",this.resetMouseScrollStateBind);window.removeEventListener("contextmenu",this.contextMenuBind);window.removeEventListener("touchstart",this.touchSwipeBind);window.removeEventListener("touchmove",this.touchSwipeBind);window.removeEventListener("touchend",this.touchSwipeBind);delete this.showControlsBind;delete this.mouseDownBind;delete this.mouseWheelBind;delete this.resetMouseScrollStateBind;delete this.contextMenuBind;delete this.touchSwipeBind}#fa(){document.fullscreenElement?this.#ra():this.#da()}#ta(){this.fullscreenChangeBind=this.#fa.bind(this);window.addEventListener("fullscreenchange",this.fullscreenChangeBind)}#na(){window.removeEventListener("fullscreenchange",this.fullscreenChangeBind);delete this.fullscreenChangeBind}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFRenderingQueue=void 0;var n=i(4),s=i(3);t.PDFRenderingQueue=class PDFRenderingQueue{constructor(){this.pdfViewer=null;this.pdfThumbnailViewer=null;this.onIdle=null;this.highestPriorityPage=null;this.idleTimeout=null;this.printing=!1;this.isThumbnailViewEnabled=!1;Object.defineProperty(this,"hasViewer",{value:()=>!!this.pdfViewer})}setViewer(e){this.pdfViewer=e}setThumbnailViewer(e){this.pdfThumbnailViewer=e}isHighestPriority(e){return this.highestPriorityPage===e.renderingId}renderHighestPriority(e){if(this.idleTimeout){clearTimeout(this.idleTimeout);this.idleTimeout=null}this.pdfViewer.forceRendering(e)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(e,t,i,n=!1){const s=e.views,a=s.length;if(0===a)return null;for(let e=0;e<a;e++){const t=s[e].view;if(!this.isViewFinished(t))return t}const r=e.first.id,o=e.last.id;if(o-r+1>a){const n=e.ids;for(let e=1,s=o-r;e<s;e++){const s=i?r+e:o-e;if(n.has(s))continue;const a=t[s-1];if(!this.isViewFinished(a))return a}}let l=i?o:r-2,d=t[l];if(d&&!this.isViewFinished(d))return d;if(n){l+=i?1:-1;d=t[l];if(d&&!this.isViewFinished(d))return d}return null}isViewFinished(e){return e.renderingState===s.RenderingStates.FINISHED}renderView(e){switch(e.renderingState){case s.RenderingStates.FINISHED:return!1;case s.RenderingStates.PAUSED:this.highestPriorityPage=e.renderingId;e.resume();break;case s.RenderingStates.RUNNING:this.highestPriorityPage=e.renderingId;break;case s.RenderingStates.INITIAL:this.highestPriorityPage=e.renderingId;e.draw().finally((()=>{this.renderHighestPriority()})).catch((e=>{e instanceof n.RenderingCancelledException||console.error(`renderView: "${e}"`)}))}return!0}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFScriptingManager=void 0;var n=i(3),s=i(4);t.PDFScriptingManager=class PDFScriptingManager{#ma=null;#ba=null;#va=null;#Xn=null;#_a=null;#wa=null;#ya=null;#Sa=!1;#Aa=null;#Ea=null;#Pa=null;constructor({eventBus:e,sandboxBundleSrc:t=null,externalServices:i=null,docProperties:n=null}){this.#Xn=e;this.#Aa=t;this.#_a=i;this.#va=n}setViewer(e){this.#ya=e}async setDocument(e){this.#wa&&await this.#Ca();this.#wa=e;if(!e)return;const[t,i,n]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(t||n){if(e===this.#wa){try{this.#Ea=this.#xa()}catch(e){console.error(`setDocument: "${e.message}".`);await this.#Ca();return}this._internalEvents.set("updatefromsandbox",(e=>{e?.source===window&&this.#Ta(e.detail)}));this._internalEvents.set("dispatcheventinsandbox",(e=>{this.#Ea?.dispatchEventInSandbox(e.detail)}));this._internalEvents.set("pagechanging",(({pageNumber:e,previous:t})=>{if(e!==t){this.#Ma(t);this.#Ia(e)}}));this._internalEvents.set("pagerendered",(({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===this.#ya.currentPageNumber&&this.#Ia(e)}));this._internalEvents.set("pagesdestroy",(async()=>{await this.#Ma(this.#ya.currentPageNumber);await(this.#Ea?.dispatchEventInSandbox({id:"doc",name:"WillClose"}));this.#ma?.resolve()}));for(const[e,t]of this._internalEvents)this.#Xn._on(e,t);try{const s=await this.#va(e);if(e!==this.#wa)return;await this.#Ea.createSandbox({objects:t,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...s,actions:n}});this.#Xn.dispatch("sandboxcreated",{source:this})}catch(e){console.error(`setDocument: "${e.message}".`);await this.#Ca();return}await(this.#Ea?.dispatchEventInSandbox({id:"doc",name:"Open"}));await this.#Ia(this.#ya.currentPageNumber,!0);Promise.resolve().then((()=>{e===this.#wa&&(this.#Sa=!0)}))}}else await this.#Ca()}async dispatchWillSave(){return this.#Ea?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Ea?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Ea){await(this.#Pa?.promise);this.#Pa=new s.PromiseCapability;try{await this.#Ea.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){this.#Pa.resolve();this.#Pa=null;throw e}await this.#Pa.promise}}async dispatchDidPrint(){return this.#Ea?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#ba?.promise||null}get ready(){return this.#Sa}get _internalEvents(){return(0,s.shadow)(this,"_internalEvents",new Map)}get _pageOpenPending(){return(0,s.shadow)(this,"_pageOpenPending",new Set)}get _visitedPages(){return(0,s.shadow)(this,"_visitedPages",new Map)}async#Ta(e){const t=this.#ya,i=t.isInPresentationMode||t.isChangingPresentationMode,{id:s,siblings:a,command:r,value:o}=e;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(o);break;case"layout":if(!i){const e=(0,n.apiPageLayoutToViewerModes)(o);t.spreadMode=e.spreadMode}break;case"page-num":t.currentPageNumber=o+1;break;case"print":await t.pagesPromise;this.#Xn.dispatch("print",{source:this});break;case"println":console.log(o);break;case"zoom":i||(t.currentScaleValue=o);break;case"SaveAs":this.#Xn.dispatch("download",{source:this});break;case"FirstPage":t.currentPageNumber=1;break;case"LastPage":t.currentPageNumber=t.pagesCount;break;case"NextPage":t.nextPage();break;case"PrevPage":t.previousPage();break;case"ZoomViewIn":i||t.increaseScale();break;case"ZoomViewOut":i||t.decreaseScale();break;case"WillPrintFinished":this.#Pa?.resolve();this.#Pa=null}return}if(i&&e.focus)return;delete e.id;delete e.siblings;const l=a?[s,...a]:[s];for(const t of l){const i=document.querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):this.#wa?.annotationStorage.setValue(t,e)}}async#Ia(e,t=!1){const i=this.#wa,a=this._visitedPages;t&&(this.#ma=new s.PromiseCapability);if(!this.#ma)return;const r=this.#ya.getPageView(e-1);if(r?.renderingState!==n.RenderingStates.FINISHED){this._pageOpenPending.add(e);return}this._pageOpenPending.delete(e);const o=(async()=>{const t=await(a.has(e)?null:r.pdfPage?.getJSActions());i===this.#wa&&await(this.#Ea?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();a.set(e,o)}async#Ma(e){const t=this.#wa,i=this._visitedPages;if(!this.#ma)return;if(this._pageOpenPending.has(e))return;const n=i.get(e);if(n){i.set(e,null);await n;t===this.#wa&&await(this.#Ea?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e}))}}#xa(){this.#ba=new s.PromiseCapability;if(this.#Ea)throw new Error("#initScripting: Scripting already exists.");return this.#_a.createScripting({sandboxBundleSrc:this.#Aa})}async#Ca(){if(this.#Ea){if(this.#ma){await Promise.race([this.#ma.promise,new Promise((e=>{setTimeout(e,1e3)}))]).catch((()=>{}));this.#ma=null}this.#wa=null;try{await this.#Ea.destroySandbox()}catch{}this.#Pa?.reject(new Error("Scripting destroyed."));this.#Pa=null;for(const[e,t]of this._internalEvents)this.#Xn._off(e,t);this._internalEvents.clear();this._pageOpenPending.clear();this._visitedPages.clear();this.#Ea=null;this.#Sa=!1;this.#ba?.resolve()}else{this.#wa=null;this.#ba?.resolve()}}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFSidebar=void 0;var n=i(3);const s="sidebarResizing",a="pdfSidebarNotification";t.PDFSidebar=class PDFSidebar{#ka=!1;#Da=this.#La.bind(this);#Fa=this.#Ra.bind(this);#Oa=null;#Na=null;constructor({elements:e,eventBus:t,l10n:i}){this.isOpen=!1;this.active=n.SidebarView.THUMBS;this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;this.onToggled=null;this.onUpdateThumbnails=null;this.outerContainer=e.outerContainer;this.sidebarContainer=e.sidebarContainer;this.toggleButton=e.toggleButton;this.resizer=e.resizer;this.thumbnailButton=e.thumbnailButton;this.outlineButton=e.outlineButton;this.attachmentsButton=e.attachmentsButton;this.layersButton=e.layersButton;this.thumbnailView=e.thumbnailView;this.outlineView=e.outlineView;this.attachmentsView=e.attachmentsView;this.layersView=e.layersView;this._outlineOptionsContainer=e.outlineOptionsContainer;this._currentOutlineItemButton=e.currentOutlineItemButton;this.eventBus=t;this.l10n=i;i.getDirection().then((e=>{this.#ka="rtl"===e}));this.#ys()}reset(){this.isInitialViewSet=!1;this.isInitialEventDispatched=!1;this.#Ba(!0);this.switchView(n.SidebarView.THUMBS);this.outlineButton.disabled=!1;this.attachmentsButton.disabled=!1;this.layersButton.disabled=!1;this._currentOutlineItemButton.disabled=!0}get visibleView(){return this.isOpen?this.active:n.SidebarView.NONE}setInitialView(e=n.SidebarView.NONE){if(!this.isInitialViewSet){this.isInitialViewSet=!0;if(e!==n.SidebarView.NONE&&e!==n.SidebarView.UNKNOWN){this.switchView(e,!0);this.isInitialEventDispatched||this.#Va()}else this.#Va()}}switchView(e,t=!1){const i=e!==this.active;let s=!1;switch(e){case n.SidebarView.NONE:this.isOpen&&this.close();return;case n.SidebarView.THUMBS:this.isOpen&&i&&(s=!0);break;case n.SidebarView.OUTLINE:if(this.outlineButton.disabled)return;break;case n.SidebarView.ATTACHMENTS:if(this.attachmentsButton.disabled)return;break;case n.SidebarView.LAYERS:if(this.layersButton.disabled)return;break;default:console.error(`PDFSidebar.switchView: "${e}" is not a valid view.`);return}this.active=e;(0,n.toggleCheckedBtn)(this.thumbnailButton,e===n.SidebarView.THUMBS,this.thumbnailView);(0,n.toggleCheckedBtn)(this.outlineButton,e===n.SidebarView.OUTLINE,this.outlineView);(0,n.toggleCheckedBtn)(this.attachmentsButton,e===n.SidebarView.ATTACHMENTS,this.attachmentsView);(0,n.toggleCheckedBtn)(this.layersButton,e===n.SidebarView.LAYERS,this.layersView);this._outlineOptionsContainer.classList.toggle("hidden",e!==n.SidebarView.OUTLINE);if(!t||this.isOpen){if(s){this.onUpdateThumbnails();this.onToggled()}i&&this.#Va()}else this.open()}open(){if(!this.isOpen){this.isOpen=!0;(0,n.toggleExpandedBtn)(this.toggleButton,!0);this.outerContainer.classList.add("sidebarMoving","sidebarOpen");this.active===n.SidebarView.THUMBS&&this.onUpdateThumbnails();this.onToggled();this.#Va();this.#Ba()}}close(){if(this.isOpen){this.isOpen=!1;(0,n.toggleExpandedBtn)(this.toggleButton,!1);this.outerContainer.classList.add("sidebarMoving");this.outerContainer.classList.remove("sidebarOpen");this.onToggled();this.#Va()}}toggle(){this.isOpen?this.close():this.open()}#Va(){this.isInitialViewSet&&(this.isInitialEventDispatched||=!0);this.eventBus.dispatch("sidebarviewchanged",{source:this,view:this.visibleView})}#Ua(){this.toggleButton.setAttribute("data-l10n-id","toggle_sidebar_notification2");this.l10n.translate(this.toggleButton);this.isOpen||this.toggleButton.classList.add(a)}#Ba(e=!1){(this.isOpen||e)&&this.toggleButton.classList.remove(a);if(e){this.toggleButton.setAttribute("data-l10n-id","toggle_sidebar");this.l10n.translate(this.toggleButton)}}#ys(){this.sidebarContainer.addEventListener("transitionend",(e=>{e.target===this.sidebarContainer&&this.outerContainer.classList.remove("sidebarMoving")}));this.toggleButton.addEventListener("click",(()=>{this.toggle()}));this.thumbnailButton.addEventListener("click",(()=>{this.switchView(n.SidebarView.THUMBS)}));this.outlineButton.addEventListener("click",(()=>{this.switchView(n.SidebarView.OUTLINE)}));this.outlineButton.addEventListener("dblclick",(()=>{this.eventBus.dispatch("toggleoutlinetree",{source:this})}));this.attachmentsButton.addEventListener("click",(()=>{this.switchView(n.SidebarView.ATTACHMENTS)}));this.layersButton.addEventListener("click",(()=>{this.switchView(n.SidebarView.LAYERS)}));this.layersButton.addEventListener("dblclick",(()=>{this.eventBus.dispatch("resetlayers",{source:this})}));this._currentOutlineItemButton.addEventListener("click",(()=>{this.eventBus.dispatch("currentoutlineitem",{source:this})}));const onTreeLoaded=(e,t,i)=>{t.disabled=!e;e?this.#Ua():this.active===i&&this.switchView(n.SidebarView.THUMBS)};this.eventBus._on("outlineloaded",(e=>{onTreeLoaded(e.outlineCount,this.outlineButton,n.SidebarView.OUTLINE);e.currentOutlineItemPromise.then((e=>{this.isInitialViewSet&&(this._currentOutlineItemButton.disabled=!e)}))}));this.eventBus._on("attachmentsloaded",(e=>{onTreeLoaded(e.attachmentsCount,this.attachmentsButton,n.SidebarView.ATTACHMENTS)}));this.eventBus._on("layersloaded",(e=>{onTreeLoaded(e.layersCount,this.layersButton,n.SidebarView.LAYERS)}));this.eventBus._on("presentationmodechanged",(e=>{e.state===n.PresentationModeState.NORMAL&&this.visibleView===n.SidebarView.THUMBS&&this.onUpdateThumbnails()}));this.resizer.addEventListener("mousedown",(e=>{if(0===e.button){this.outerContainer.classList.add(s);window.addEventListener("mousemove",this.#Da);window.addEventListener("mouseup",this.#Fa)}}));this.eventBus._on("resize",(e=>{if(e.source!==window)return;this.#Oa=null;if(!this.#Na)return;if(!this.isOpen){this.#za(this.#Na);return}this.outerContainer.classList.add(s);const t=this.#za(this.#Na);Promise.resolve().then((()=>{this.outerContainer.classList.remove(s);t&&this.eventBus.dispatch("resize",{source:this})}))}))}get outerContainerWidth(){return this.#Oa||=this.outerContainer.clientWidth}#za(e=0){const t=Math.floor(this.outerContainerWidth/2);e>t&&(e=t);e<200&&(e=200);if(e===this.#Na)return!1;this.#Na=e;n.docStyle.setProperty("--sidebar-width",`${e}px`);return!0}#La(e){let t=e.clientX;this.#ka&&(t=this.outerContainerWidth-t);this.#za(t)}#Ra(e){this.outerContainer.classList.remove(s);this.eventBus.dispatch("resize",{source:this});window.removeEventListener("mousemove",this.#Da);window.removeEventListener("mouseup",this.#Fa)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFThumbnailViewer=void 0;var n=i(3),s=i(28);const a="selected";t.PDFThumbnailViewer=class PDFThumbnailViewer{constructor({container:e,eventBus:t,linkService:i,renderingQueue:s,l10n:a,pageColors:r}){this.container=e;this.eventBus=t;this.linkService=i;this.renderingQueue=s;this.l10n=a;this.pageColors=r||null;this.scroll=(0,n.watchScroll)(this.container,this._scrollUpdated.bind(this));this._resetView()}_scrollUpdated(){this.renderingQueue.renderHighestPriority()}getThumbnail(e){return this._thumbnails[e]}_getVisibleThumbs(){return(0,n.getVisibleElements)({scrollEl:this.container,views:this._thumbnails})}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t){console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');return}if(e!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(a);t.div.classList.add(a)}const{first:i,last:s,views:r}=this._getVisibleThumbs();if(r.length>0){let a=!1;if(e<=i.id||e>=s.id)a=!0;else for(const{id:t,percent:i}of r)if(t===e){a=i<100;break}a&&(0,n.scrollIntoView)(t.div,{top:-19})}this._currentPageNumber=e}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!(0,n.isValidRotation)(e))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===e)return;this._pagesRotation=e;const t={rotation:e};for(const e of this._thumbnails)e.update(t)}cleanup(){for(const e of this._thumbnails)e.renderingState!==n.RenderingStates.FINISHED&&e.reset();s.TempImageFactory.destroyCanvas()}_resetView(){this._thumbnails=[];this._currentPageNumber=1;this._pageLabels=null;this._pagesRotation=0;this.container.textContent=""}setDocument(e){if(this.pdfDocument){this._cancelRendering();this._resetView()}this.pdfDocument=e;if(!e)return;const t=e.getPage(1),i=e.getOptionalContentConfig();t.then((t=>{const n=e.numPages,r=t.getViewport({scale:1});for(let e=1;e<=n;++e){const t=new s.PDFThumbnailView({container:this.container,eventBus:this.eventBus,id:e,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,l10n:this.l10n,pageColors:this.pageColors});this._thumbnails.push(t)}this._thumbnails[0]?.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].div.classList.add(a)})).catch((e=>{console.error("Unable to initialize thumbnail viewer",e)}))}_cancelRendering(){for(const e of this._thumbnails)e.cancelRendering()}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._thumbnails.length;e<t;e++)this._thumbnails[e].setPageLabel(this._pageLabels?.[e]??null)}}async#Ha(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);return t}catch(e){console.error("Unable to get page for thumb view",e);return null}}#ja(e){return 1===e.first?.id||e.last?.id!==this._thumbnails.length&&this.scroll.down}forceRendering(){const e=this._getVisibleThumbs(),t=this.#ja(e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t);if(i){this.#Ha(i).then((()=>{this.renderingQueue.renderView(i)}));return!0}return!1}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TempImageFactory=t.PDFThumbnailView=void 0;var n=i(3),s=i(4);class TempImageFactory{static#Wa=null;static getCanvas(e,t){const i=this.#Wa||=document.createElement("canvas");i.width=e;i.height=t;const n=i.getContext("2d",{alpha:!1});n.save();n.fillStyle="rgb(255, 255, 255)";n.fillRect(0,0,e,t);n.restore();return[i,i.getContext("2d")]}static destroyCanvas(){const e=this.#Wa;if(e){e.width=0;e.height=0}this.#Wa=null}}t.TempImageFactory=TempImageFactory;t.PDFThumbnailView=class PDFThumbnailView{constructor({container:e,eventBus:t,id:i,defaultViewport:s,optionalContentConfigPromise:a,linkService:r,renderingQueue:o,l10n:l,pageColors:d}){this.id=i;this.renderingId="thumbnail"+i;this.pageLabel=null;this.pdfPage=null;this.rotation=0;this.viewport=s;this.pdfPageRotate=s.rotation;this._optionalContentConfigPromise=a||null;this.pageColors=d||null;this.eventBus=t;this.linkService=r;this.renderingQueue=o;this.renderTask=null;this.renderingState=n.RenderingStates.INITIAL;this.resume=null;this.l10n=l;const h=document.createElement("a");h.href=r.getAnchorUrl("#page="+i);this._thumbPageTitle.then((e=>{h.title=e}));h.onclick=function(){r.goToPage(i);return!1};this.anchor=h;const c=document.createElement("div");c.className="thumbnail";c.setAttribute("data-page-number",this.id);this.div=c;this.#Ga();const u=document.createElement("div");u.className="thumbnailImage";this._placeholderImg=u;c.append(u);h.append(c);e.append(h)}#Ga(){const{width:e,height:t}=this.viewport,i=e/t;this.canvasWidth=98;this.canvasHeight=this.canvasWidth/i|0;this.scale=this.canvasWidth/e;const{style:n}=this.div;n.setProperty("--thumbnail-width",`${this.canvasWidth}px`);n.setProperty("--thumbnail-height",`${this.canvasHeight}px`)}setPdfPage(e){this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:1,rotation:t});this.reset()}reset(){this.cancelRendering();this.renderingState=n.RenderingStates.INITIAL;this.div.removeAttribute("data-loaded");this.image?.replaceWith(this._placeholderImg);this.#Ga();if(this.image){this.image.removeAttribute("src");delete this.image}}update({rotation:e=null}){"number"==typeof e&&(this.rotation=e);const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:t});this.reset()}cancelRendering(){if(this.renderTask){this.renderTask.cancel();this.renderTask=null}this.resume=null}_getPageDrawContext(e=1){const t=document.createElement("canvas"),i=t.getContext("2d",{alpha:!1}),s=new n.OutputScale;t.width=e*this.canvasWidth*s.sx|0;t.height=e*this.canvasHeight*s.sy|0;return{ctx:i,canvas:t,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}}_convertCanvasToImage(e){if(this.renderingState!==n.RenderingStates.FINISHED)throw new Error("_convertCanvasToImage: Rendering has not finished.");const t=this._reduceImage(e),i=document.createElement("img");i.className="thumbnailImage";this._thumbPageCanvas.then((e=>{i.setAttribute("aria-label",e)}));i.src=t.toDataURL();this.image=i;this.div.setAttribute("data-loaded",!0);this._placeholderImg.replaceWith(i);t.width=0;t.height=0}async#$a(e,t,i=null){e===this.renderTask&&(this.renderTask=null);if(!(i instanceof s.RenderingCancelledException)){this.renderingState=n.RenderingStates.FINISHED;this._convertCanvasToImage(t);if(i)throw i}}async draw(){if(this.renderingState!==n.RenderingStates.INITIAL){console.error("Must be in new state before drawing");return}const{pdfPage:e}=this;if(!e){this.renderingState=n.RenderingStates.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=n.RenderingStates.RUNNING;const{ctx:t,canvas:i,transform:s}=this._getPageDrawContext(2),a={canvasContext:t,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=e.render(a);r.onContinue=e=>{if(this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=n.RenderingStates.PAUSED;this.resume=()=>{this.renderingState=n.RenderingStates.RUNNING;e()}}};const o=r.promise.then((()=>this.#$a(r,i)),(e=>this.#$a(r,i,e)));o.finally((()=>{i.width=0;i.height=0;this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})}));return o}setImage(e){if(this.renderingState!==n.RenderingStates.INITIAL)return;const{thumbnailCanvas:t,pdfPage:i,scale:s}=e;if(t){this.pdfPage||this.setPdfPage(i);if(!(s<this.scale)){this.renderingState=n.RenderingStates.FINISHED;this._convertCanvasToImage(t)}}}_reduceImage(e){const{ctx:t,canvas:i}=this._getPageDrawContext();if(e.width<=2*i.width){t.drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height);return i}let n=i.width<<3,s=i.height<<3;const[a,r]=TempImageFactory.getCanvas(n,s);for(;n>e.width||s>e.height;){n>>=1;s>>=1}r.drawImage(e,0,0,e.width,e.height,0,0,n,s);for(;n>2*i.width;){r.drawImage(a,0,0,n,s,0,0,n>>1,s>>1);n>>=1;s>>=1}t.drawImage(a,0,0,n,s,0,0,i.width,i.height);return i}get _thumbPageTitle(){return this.l10n.get("thumb_page_title",{page:this.pageLabel??this.id})}get _thumbPageCanvas(){return this.l10n.get("thumb_page_canvas",{page:this.pageLabel??this.id})}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;this._thumbPageTitle.then((e=>{this.anchor.title=e}));this.renderingState===n.RenderingStates.FINISHED&&this._thumbPageCanvas.then((e=>{this.image?.setAttribute("aria-label",e)}))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PagesCountLimit=t.PDFViewer=t.PDFPageViewBuffer=void 0;var n=i(4),s=i(3),a=i(30),r=i(31),o=i(24),l=i(7);const d={FORCE_SCROLL_MODE_PAGE:15e3,FORCE_LAZY_PAGE_INIT:7500,PAUSE_EAGER_PAGE_INIT:250};t.PagesCountLimit=d;function isValidAnnotationEditorMode(e){return Object.values(n.AnnotationEditorType).includes(e)&&e!==n.AnnotationEditorType.DISABLE}class PDFPageViewBuffer{#qa=new Set;#Xa=0;constructor(e){this.#Xa=e}push(e){const t=this.#qa;t.has(e)&&t.delete(e);t.add(e);t.size>this.#Xa&&this.#Ka()}resize(e,t=null){this.#Xa=e;const i=this.#qa;if(t){const e=i.size;let n=1;for(const s of i){if(t.has(s.id)){i.delete(s);i.add(s)}if(++n>e)break}}for(;i.size>this.#Xa;)this.#Ka()}has(e){return this.#qa.has(e)}[Symbol.iterator](){return this.#qa.keys()}#Ka(){const e=this.#qa.keys().next().value;e?.destroy();this.#qa.delete(e)}}t.PDFPageViewBuffer=PDFPageViewBuffer;t.PDFViewer=class PDFViewer{#Ya=null;#ne=null;#Qa=n.AnnotationEditorType.NONE;#Za=null;#Ja=n.AnnotationMode.ENABLE_FORMS;#er=null;#tr=null;#ir=!1;#nr=!1;#sr=null;#ar=!1;#rr=0;#or=new ResizeObserver(this.#lr.bind(this));#dr=null;#hr=null;#cr=null;#ur=s.TextLayerMode.ENABLE;constructor(e){const t="3.11.174";if(n.version!==t)throw new Error(`The API version "${n.version}" does not match the Viewer version "${t}".`);this.container=e.container;this.viewer=e.viewer||e.container.firstElementChild;if("DIV"!==this.container?.tagName||"DIV"!==this.viewer?.tagName)throw new Error("Invalid `container` and/or `viewer` option.");if(this.container.offsetParent&&"absolute"!==getComputedStyle(this.container).position)throw new Error("The `container` must be absolutely positioned.");this.#or.observe(this.container);this.eventBus=e.eventBus;this.linkService=e.linkService||new l.SimpleLinkService;this.downloadManager=e.downloadManager||null;this.findController=e.findController||null;this.#ne=e.altTextManager||null;this.findController&&(this.findController.onIsPageVisible=e=>this._getVisiblePages().ids.has(e));this._scriptingManager=e.scriptingManager||null;this.#ur=e.textLayerMode??s.TextLayerMode.ENABLE;this.#Ja=e.annotationMode??n.AnnotationMode.ENABLE_FORMS;this.#Qa=e.annotationEditorMode??n.AnnotationEditorType.NONE;this.imageResourcesPath=e.imageResourcesPath||"";this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1;this.removePageBorders=e.removePageBorders||!1;if(e.useOnlyCssZoom){console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");e.maxCanvasPixels=0}this.isOffscreenCanvasSupported=e.isOffscreenCanvasSupported??!0;this.maxCanvasPixels=e.maxCanvasPixels;this.l10n=e.l10n||a.NullL10n;this.#ir=e.enablePermissions||!1;this.pageColors=e.pageColors||null;this.defaultRenderingQueue=!e.renderingQueue;if(this.defaultRenderingQueue){this.renderingQueue=new o.PDFRenderingQueue;this.renderingQueue.setViewer(this)}else this.renderingQueue=e.renderingQueue;this.scroll=(0,s.watchScroll)(this.container,this._scrollUpdate.bind(this));this.presentationModeState=s.PresentationModeState.UNKNOWN;this._onBeforeDraw=this._onAfterDraw=null;this._resetView();this.removePageBorders&&this.viewer.classList.add("removePageBorders");this.#pr();this.eventBus._on("thumbnailrendered",(({pageNumber:e,pdfPage:t})=>{const i=this._pages[e-1];this.#Ya.has(i)||t?.cleanup()}))}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}getCachedPageViews(){return new Set(this.#Ya)}get pageViewsReady(){return this._pagesCapability.settled&&this._pages.every((e=>e?.pdfPage))}get renderForms(){return this.#Ja===n.AnnotationMode.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(e){if(!Number.isInteger(e))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(e,!0)||console.error(`currentPageNumber: "${e}" is not a valid page.`))}_setCurrentPageNumber(e,t=!1){if(this._currentPageNumber===e){t&&this.#gr();return!0}if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;this._currentPageNumber=e;this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i});t&&this.#gr();return!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(e){if(!this.pdfDocument)return;let t=0|e;if(this._pageLabels){const i=this._pageLabels.indexOf(e);i>=0&&(t=i+1)}this._setCurrentPageNumber(t,!0)||console.error(`currentPageLabel: "${e}" is not a valid page.`)}get currentScale(){return this._currentScale!==s.UNKNOWN_SCALE?this._currentScale:s.DEFAULT_SCALE}set currentScale(e){if(isNaN(e))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#fr(e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&this.#fr(e,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!(0,s.isValidRotation)(e))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;(e%=360)<0&&(e+=360);if(this._pagesRotation===e)return;this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e});this._currentScaleValue&&this.#fr(this._currentScaleValue,{noScroll:!0});this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:e,pageNumber:t});this.defaultRenderingQueue&&this.update()}get firstPagePromise(){return this.pdfDocument?this._firstPageCapability.promise:null}get onePageRendered(){return this.pdfDocument?this._onePageRenderedCapability.promise:null}get pagesPromise(){return this.pdfDocument?this._pagesCapability.promise:null}#mr(){const e=this;return{get annotationEditorUIManager(){return e.#Za},get annotationStorage(){return e.pdfDocument?.annotationStorage},get downloadManager(){return e.downloadManager},get enableScripting(){return!!e._scriptingManager},get fieldObjectsPromise(){return e.pdfDocument?.getFieldObjects()},get findController(){return e.findController},get hasJSActionsPromise(){return e.pdfDocument?.hasJSActions()},get linkService(){return e.linkService}}}#br(e){const t={annotationEditorMode:this.#Qa,annotationMode:this.#Ja,textLayerMode:this.#ur};if(!e)return t;e.includes(n.PermissionFlag.COPY)||this.#ur!==s.TextLayerMode.ENABLE||(t.textLayerMode=s.TextLayerMode.ENABLE_PERMISSIONS);e.includes(n.PermissionFlag.MODIFY_CONTENTS)||(t.annotationEditorMode=n.AnnotationEditorType.DISABLE);e.includes(n.PermissionFlag.MODIFY_ANNOTATIONS)||e.includes(n.PermissionFlag.FILL_INTERACTIVE_FORMS)||this.#Ja!==n.AnnotationMode.ENABLE_FORMS||(t.annotationMode=n.AnnotationMode.ENABLE);return t}#vr(){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return Promise.resolve();const e=new Promise((e=>{this.#hr=()=>{if("hidden"===document.visibilityState){e();document.removeEventListener("visibilitychange",this.#hr);this.#hr=null}};document.addEventListener("visibilitychange",this.#hr)}));return Promise.race([this._onePageRenderedCapability.promise,e])}async getAllText(){const e=[],t=[];for(let i=1,n=this.pdfDocument.numPages;i<=n;++i){if(this.#ar)return null;t.length=0;const n=await this.pdfDocument.getPage(i),{items:a}=await n.getTextContent();for(const e of a){e.str&&t.push(e.str);e.hasEOL&&t.push("\n")}e.push((0,s.removeNullCharacters)(t.join("")))}return e.join("\n")}#_r(e,t){const i=document.getSelection(),{focusNode:n,anchorNode:a}=i;if(a&&n&&i.containsNode(this.#sr)){if(this.#nr||e===s.TextLayerMode.ENABLE_PERMISSIONS){t.preventDefault();t.stopPropagation();return}this.#nr=!0;const i=this.container.style.cursor;this.container.style.cursor="wait";const interruptCopy=e=>this.#ar="Escape"===e.key;window.addEventListener("keydown",interruptCopy);this.getAllText().then((async e=>{null!==e&&await navigator.clipboard.writeText(e)})).catch((e=>{console.warn(`Something goes wrong when extracting the text: ${e.message}`)})).finally((()=>{this.#nr=!1;this.#ar=!1;window.removeEventListener("keydown",interruptCopy);this.container.style.cursor=i}));t.preventDefault();t.stopPropagation()}}setDocument(e){if(this.pdfDocument){this.eventBus.dispatch("pagesdestroy",{source:this});this._cancelRendering();this._resetView();this.findController?.setDocument(null);this._scriptingManager?.setDocument(null);if(this.#Za){this.#Za.destroy();this.#Za=null}}this.pdfDocument=e;if(!e)return;const t=e.numPages,i=e.getPage(1),a=e.getOptionalContentConfig(),o=this.#ir?e.getPermissions():Promise.resolve();if(t>d.FORCE_SCROLL_MODE_PAGE){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const e=this._scrollMode=s.ScrollMode.PAGE;this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e})}this._pagesCapability.promise.then((()=>{this.eventBus.dispatch("pagesloaded",{source:this,pagesCount:t})}),(()=>{}));this._onBeforeDraw=e=>{const t=this._pages[e.pageNumber-1];t&&this.#Ya.push(t)};this.eventBus._on("pagerender",this._onBeforeDraw);this._onAfterDraw=e=>{if(!e.cssTransform&&!this._onePageRenderedCapability.settled){this._onePageRenderedCapability.resolve({timestamp:e.timestamp});this.eventBus._off("pagerendered",this._onAfterDraw);this._onAfterDraw=null;if(this.#hr){document.removeEventListener("visibilitychange",this.#hr);this.#hr=null}}};this.eventBus._on("pagerendered",this._onAfterDraw);Promise.all([i,o]).then((([i,o])=>{if(e!==this.pdfDocument)return;this._firstPageCapability.resolve(i);this._optionalContentConfigPromise=a;const{annotationEditorMode:l,annotationMode:h,textLayerMode:c}=this.#br(o);if(c!==s.TextLayerMode.DISABLE){const e=this.#sr=document.createElement("div");e.id="hiddenCopyElement";this.viewer.before(e)}if(l!==n.AnnotationEditorType.DISABLE){const t=l;if(e.isPureXfa)console.warn("Warning: XFA-editing is not implemented.");else if(isValidAnnotationEditorMode(t)){this.#Za=new n.AnnotationEditorUIManager(this.container,this.viewer,this.#ne,this.eventBus,e,this.pageColors);t!==n.AnnotationEditorType.NONE&&this.#Za.updateMode(t)}else console.error(`Invalid AnnotationEditor mode: ${t}`)}const u=this.#mr.bind(this),p=this._scrollMode===s.ScrollMode.PAGE?null:this.viewer,g=this.currentScale,f=i.getViewport({scale:g*n.PixelsPerInch.PDF_TO_CSS_UNITS});this.viewer.style.setProperty("--scale-factor",f.scale);"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||this.viewer.style.setProperty("--hcm-highligh-filter",e.filterFactory.addHighlightHCMFilter("CanvasText","Canvas","HighlightText","Highlight"));for(let e=1;e<=t;++e){const t=new r.PDFPageView({container:p,eventBus:this.eventBus,id:e,scale:g,defaultViewport:f.clone(),optionalContentConfigPromise:a,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:h,imageResourcesPath:this.imageResourcesPath,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,maxCanvasPixels:this.maxCanvasPixels,pageColors:this.pageColors,l10n:this.l10n,layerProperties:u});this._pages.push(t)}const m=this._pages[0];if(m){m.setPdfPage(i);this.linkService.cachePageRef(1,i.ref)}this._scrollMode===s.ScrollMode.PAGE?this.#wr():this._spreadMode!==s.SpreadMode.NONE&&this._updateSpreadMode();this.#vr().then((async()=>{this.findController?.setDocument(e);this._scriptingManager?.setDocument(e);if(this.#sr){this.#tr=this.#_r.bind(this,c);document.addEventListener("copy",this.#tr)}this.#Za&&this.eventBus.dispatch("annotationeditormodechanged",{source:this,mode:this.#Qa});if(e.loadingParams.disableAutoFetch||t>d.FORCE_LAZY_PAGE_INIT){this._pagesCapability.resolve();return}let i=t-1;if(i<=0)this._pagesCapability.resolve();else for(let n=2;n<=t;++n){const t=e.getPage(n).then((e=>{const t=this._pages[n-1];t.pdfPage||t.setPdfPage(e);this.linkService.cachePageRef(n,e.ref);0==--i&&this._pagesCapability.resolve()}),(e=>{console.error(`Unable to get page ${n} to initialize viewer`,e);0==--i&&this._pagesCapability.resolve()}));n%d.PAUSE_EAGER_PAGE_INIT==0&&await t}}));this.eventBus.dispatch("pagesinit",{source:this});e.getMetadata().then((({info:t})=>{e===this.pdfDocument&&t.Language&&(this.viewer.lang=t.Language)}));this.defaultRenderingQueue&&this.update()})).catch((e=>{console.error("Unable to initialize viewer",e);this._pagesCapability.reject(e)}))}setPageLabels(e){if(this.pdfDocument){if(e)if(Array.isArray(e)&&this.pdfDocument.numPages===e.length)this._pageLabels=e;else{this._pageLabels=null;console.error("setPageLabels: Invalid page labels.")}else this._pageLabels=null;for(let e=0,t=this._pages.length;e<t;e++)this._pages[e].setPageLabel(this._pageLabels?.[e]??null)}}_resetView(){this._pages=[];this._currentPageNumber=1;this._currentScale=s.UNKNOWN_SCALE;this._currentScaleValue=null;this._pageLabels=null;this.#Ya=new PDFPageViewBuffer(10);this._location=null;this._pagesRotation=0;this._optionalContentConfigPromise=null;this._firstPageCapability=new n.PromiseCapability;this._onePageRenderedCapability=new n.PromiseCapability;this._pagesCapability=new n.PromiseCapability;this._scrollMode=s.ScrollMode.VERTICAL;this._previousScrollMode=s.ScrollMode.UNKNOWN;this._spreadMode=s.SpreadMode.NONE;this.#dr={previousPageNumber:1,scrollDown:!0,pages:[]};if(this._onBeforeDraw){this.eventBus._off("pagerender",this._onBeforeDraw);this._onBeforeDraw=null}if(this._onAfterDraw){this.eventBus._off("pagerendered",this._onAfterDraw);this._onAfterDraw=null}if(this.#hr){document.removeEventListener("visibilitychange",this.#hr);this.#hr=null}this.viewer.textContent="";this._updateScrollMode();this.viewer.removeAttribute("lang");if(this.#sr){document.removeEventListener("copy",this.#tr);this.#tr=null;this.#sr.remove();this.#sr=null}}#wr(){if(this._scrollMode!==s.ScrollMode.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=this.#dr,i=this.viewer;i.textContent="";t.pages.length=0;if(this._spreadMode!==s.SpreadMode.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;if(-1===s)n.add(e-1);else if(e%2!==s){n.add(e-1);n.add(e)}else{n.add(e-2);n.add(e-1)}const a=document.createElement("div");a.className="spread";if(this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage";a.append(e)}for(const e of n){const i=this._pages[e];if(i){a.append(i.div);t.pages.push(i)}}i.append(a)}else{const n=this._pages[e-1];i.append(n.div);t.pages.push(n)}t.scrollDown=e>=t.previousPageNumber;t.previousPageNumber=e}_scrollUpdate(){0!==this.pagesCount&&this.update()}#yr(e,t=null){const{div:i,id:n}=e;this._currentPageNumber!==n&&this._setCurrentPageNumber(n);if(this._scrollMode===s.ScrollMode.PAGE){this.#wr();this.update()}if(!t&&!this.isInPresentationMode){const e=i.offsetLeft+i.clientLeft,n=e+i.clientWidth,{scrollLeft:a,clientWidth:r}=this.container;(this._scrollMode===s.ScrollMode.HORIZONTAL||e<a||n>a+r)&&(t={left:0,top:0})}(0,s.scrollIntoView)(i,t);!this._currentScaleValue&&this._location&&(this._location=null)}#Sr(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}#Ar(e,t,{noScroll:i=!1,preset:s=!1,drawingDelay:a=-1}){this._currentScaleValue=t.toString();if(this.#Sr(e)){s&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t});return}this.viewer.style.setProperty("--scale-factor",e*n.PixelsPerInch.PDF_TO_CSS_UNITS);const r=a>=0&&a<1e3;this.refresh(!0,{scale:e,drawingDelay:r?a:-1});r&&(this.#cr=setTimeout((()=>{this.#cr=null;this.refresh()}),a));this._currentScale=e;if(!i){let e,t=this._currentPageNumber;if(this._location&&!this.isInPresentationMode&&!this.isChangingPresentationMode){t=this._location.pageNumber;e=[null,{name:"XYZ"},this._location.left,this._location.top,null]}this.scrollPageIntoView({pageNumber:t,destArray:e,allowNegativeOffset:!0})}this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:s?t:void 0});this.defaultRenderingQueue&&this.update()}get#Er(){return this._spreadMode!==s.SpreadMode.NONE&&this._scrollMode!==s.ScrollMode.HORIZONTAL?2:1}#fr(e,t){let i=parseFloat(e);if(i>0){t.preset=!1;this.#Ar(i,e,t)}else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let a=s.SCROLLBAR_PADDING,r=s.VERTICAL_PADDING;if(this.isInPresentationMode){a=r=4;this._spreadMode!==s.SpreadMode.NONE&&(a*=2)}else this.removePageBorders?a=r=0:this._scrollMode===s.ScrollMode.HORIZONTAL&&([a,r]=[r,a]);const o=(this.container.clientWidth-a)/n.width*n.scale/this.#Er,l=(this.container.clientHeight-r)/n.height*n.scale;switch(e){case"page-actual":i=1;break;case"page-width":i=o;break;case"page-height":i=l;break;case"page-fit":i=Math.min(o,l);break;case"auto":const t=(0,s.isPortraitOrientation)(n)?o:Math.min(l,o);i=Math.min(s.MAX_AUTO_SCALE,t);break;default:console.error(`#setScale: "${e}" is an unknown zoom value.`);return}t.preset=!0;this.#Ar(i,e,t)}}#gr(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#fr(this._currentScaleValue,{noScroll:!0});this.#yr(e)}pageLabelToPageNumber(e){if(!this._pageLabels)return null;const t=this._pageLabels.indexOf(e);return t<0?null:t+1}scrollPageIntoView({pageNumber:e,destArray:t=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:a=!1}){if(!this.pdfDocument)return;const r=Number.isInteger(e)&&this._pages[e-1];if(!r){console.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);return}if(this.isInPresentationMode||!t){this._setCurrentPageNumber(e,!0);return}let o,l,d=0,h=0,c=0,u=0;const p=r.rotation%180!=0,g=(p?r.height:r.width)/r.scale/n.PixelsPerInch.PDF_TO_CSS_UNITS,f=(p?r.width:r.height)/r.scale/n.PixelsPerInch.PDF_TO_CSS_UNITS;let m=0;switch(t[1].name){case"XYZ":d=t[2];h=t[3];m=t[4];d=null!==d?d:0;h=null!==h?h:f;break;case"Fit":case"FitB":m="page-fit";break;case"FitH":case"FitBH":h=t[2];m="page-width";if(null===h&&this._location){d=this._location.left;h=this._location.top}else("number"!=typeof h||h<0)&&(h=f);break;case"FitV":case"FitBV":d=t[2];c=g;u=f;m="page-height";break;case"FitR":d=t[2];h=t[3];c=t[4]-d;u=t[5]-h;let e=s.SCROLLBAR_PADDING,i=s.VERTICAL_PADDING;this.removePageBorders&&(e=i=0);o=(this.container.clientWidth-e)/c/n.PixelsPerInch.PDF_TO_CSS_UNITS;l=(this.container.clientHeight-i)/u/n.PixelsPerInch.PDF_TO_CSS_UNITS;m=Math.min(Math.abs(o),Math.abs(l));break;default:console.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`);return}a||(m&&m!==this._currentScale?this.currentScaleValue=m:this._currentScale===s.UNKNOWN_SCALE&&(this.currentScaleValue=s.DEFAULT_SCALE_VALUE));if("page-fit"===m&&!t[4]){this.#yr(r);return}const b=[r.viewport.convertToViewportPoint(d,h),r.viewport.convertToViewportPoint(d+c,h+u)];let v=Math.min(b[0][0],b[1][0]),_=Math.min(b[0][1],b[1][1]);if(!i){v=Math.max(v,0);_=Math.max(_,0)}this.#yr(r,{left:v,top:_})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,a=this._pages[s-1],r=this.container,o=a.getPagePoint(r.scrollLeft-e.x,r.scrollTop-e.y),l=Math.round(o[0]),d=Math.round(o[1]);let h=`#page=${s}`;this.isInPresentationMode||(h+=`&zoom=${n},${l},${d}`);this._location={pageNumber:s,scale:n,top:d,left:l,rotation:this._pagesRotation,pdfOpenParams:h}}update(){const e=this._getVisiblePages(),t=e.views,i=t.length;if(0===i)return;const n=Math.max(10,2*i+1);this.#Ya.resize(n,e.ids);this.renderingQueue.renderHighestPriority(e);const a=this._spreadMode===s.SpreadMode.NONE&&(this._scrollMode===s.ScrollMode.PAGE||this._scrollMode===s.ScrollMode.VERTICAL),r=this._currentPageNumber;let o=!1;for(const e of t){if(e.percent<100)break;if(e.id===r&&a){o=!0;break}}this._setCurrentPageNumber(o?r:t[0].id);this._updateLocation(e.first);this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}containsElement(e){return this.container.contains(e)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===s.PresentationModeState.FULLSCREEN}get isChangingPresentationMode(){return this.presentationModeState===s.PresentationModeState.CHANGING}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const e=this._scrollMode===s.ScrollMode.PAGE?this.#dr.pages:this._pages,t=this._scrollMode===s.ScrollMode.HORIZONTAL,i=t&&this._isContainerRtl;return(0,s.getVisibleElements)({scrollEl:this.container,views:e,sortByVisibility:!0,horizontal:t,rtl:i})}cleanup(){for(const e of this._pages)e.renderingState!==s.RenderingStates.FINISHED&&e.reset()}_cancelRendering(){for(const e of this._pages)e.cancelRendering()}async#Ha(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);e.pdfPage||e.setPdfPage(t);this.linkService._cachedPageNumber?.(t.ref)||this.linkService.cachePageRef(e.id,t.ref);return t}catch(e){console.error("Unable to get page for page view",e);return null}}#ja(e){if(1===e.first?.id)return!0;if(e.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case s.ScrollMode.PAGE:return this.#dr.scrollDown;case s.ScrollMode.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(e){const t=e||this._getVisiblePages(),i=this.#ja(t),n=this._spreadMode!==s.SpreadMode.NONE&&this._scrollMode!==s.ScrollMode.HORIZONTAL,a=this.renderingQueue.getHighestPriority(t,this._pages,i,n);if(a){this.#Ha(a).then((()=>{this.renderingQueue.renderView(a)}));return!0}return!1}get hasEqualPageSizes(){const e=this._pages[0];for(let t=1,i=this._pages.length;t<i;++t){const i=this._pages[t];if(i.width!==e.width||i.height!==e.height)return!1}return!0}getPagesOverview(){let e;return this._pages.map((t=>{const i=t.pdfPage.getViewport({scale:1}),n=(0,s.isPortraitOrientation)(i);if(void 0===e)e=n;else if(this.enablePrintAutoRotate&&n!==e)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}}))}get optionalContentConfigPromise(){if(!this.pdfDocument)return Promise.resolve(null);if(!this._optionalContentConfigPromise){console.error("optionalContentConfigPromise: Not initialized yet.");return this.pdfDocument.getOptionalContentConfig()}return this._optionalContentConfigPromise}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);if(this.pdfDocument&&this._optionalContentConfigPromise){this._optionalContentConfigPromise=e;this.refresh(!1,{optionalContentConfigPromise:e});this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:e})}}get scrollMode(){return this._scrollMode}set scrollMode(e){if(this._scrollMode!==e){if(!(0,s.isValidScrollMode)(e))throw new Error(`Invalid scroll mode: ${e}`);if(!(this.pagesCount>d.FORCE_SCROLL_MODE_PAGE)){this._previousScrollMode=this._scrollMode;this._scrollMode=e;this.eventBus.dispatch("scrollmodechanged",{source:this,mode:e});this._updateScrollMode(this._currentPageNumber)}}}_updateScrollMode(e=null){const t=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",t===s.ScrollMode.HORIZONTAL);i.classList.toggle("scrollWrapped",t===s.ScrollMode.WRAPPED);if(this.pdfDocument&&e){t===s.ScrollMode.PAGE?this.#wr():this._previousScrollMode===s.ScrollMode.PAGE&&this._updateSpreadMode();this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#fr(this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}get spreadMode(){return this._spreadMode}set spreadMode(e){if(this._spreadMode!==e){if(!(0,s.isValidSpreadMode)(e))throw new Error(`Invalid spread mode: ${e}`);this._spreadMode=e;this.eventBus.dispatch("spreadmodechanged",{source:this,mode:e});this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(e=null){if(!this.pdfDocument)return;const t=this.viewer,i=this._pages;if(this._scrollMode===s.ScrollMode.PAGE)this.#wr();else{t.textContent="";if(this._spreadMode===s.SpreadMode.NONE)for(const e of this._pages)t.append(e.div);else{const e=this._spreadMode-1;let n=null;for(let s=0,a=i.length;s<a;++s){if(null===n){n=document.createElement("div");n.className="spread";t.append(n)}else if(s%2===e){n=n.cloneNode(!1);t.append(n)}n.append(i[s].div)}}}if(e){this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#fr(this._currentScaleValue,{noScroll:!0});this._setCurrentPageNumber(e,!0);this.update()}}_getPageAdvance(e,t=!1){switch(this._scrollMode){case s.ScrollMode.WRAPPED:{const{views:i}=this._getVisiblePages(),n=new Map;for(const{id:e,y:t,percent:s,widthPercent:a}of i){if(0===s||a<100)continue;let i=n.get(t);i||n.set(t,i||=[]);i.push(e)}for(const i of n.values()){const n=i.indexOf(e);if(-1===n)continue;const s=i.length;if(1===s)break;if(t)for(let t=n-1,s=0;t>=s;t--){const n=i[t],s=i[t+1]-1;if(n<s)return e-s}else for(let t=n+1,a=s;t<a;t++){const n=i[t],s=i[t-1]+1;if(n>s)return s-e}if(t){const t=i[0];if(t<e)return e-t+1}else{const t=i[s-1];if(t>e)return t-e+1}break}break}case s.ScrollMode.HORIZONTAL:break;case s.ScrollMode.PAGE:case s.ScrollMode.VERTICAL:{if(this._spreadMode===s.SpreadMode.NONE)break;const i=this._spreadMode-1;if(t&&e%2!==i)break;if(!t&&e%2===i)break;const{views:n}=this._getVisiblePages(),a=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of n)if(e===a){if(t>0&&100===i)return 2;break}break}}return 1}nextPage(){const e=this._currentPageNumber,t=this.pagesCount;if(e>=t)return!1;const i=this._getPageAdvance(e,!1)||1;this.currentPageNumber=Math.min(e+i,t);return!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=this._getPageAdvance(e,!0)||1;this.currentPageNumber=Math.max(e-t,1);return!0}increaseScale({drawingDelay:e,scaleFactor:t,steps:i}={}){if(!this.pdfDocument)return;let n=this._currentScale;if(t>1)n=Math.round(n*t*100)/100;else{i??=1;do{n=Math.ceil(10*(n*s.DEFAULT_SCALE_DELTA).toFixed(2))/10}while(--i>0&&n<s.MAX_SCALE)}this.#fr(Math.min(s.MAX_SCALE,n),{noScroll:!1,drawingDelay:e})}decreaseScale({drawingDelay:e,scaleFactor:t,steps:i}={}){if(!this.pdfDocument)return;let n=this._currentScale;if(t>0&&t<1)n=Math.round(n*t*100)/100;else{i??=1;do{n=Math.floor(10*(n/s.DEFAULT_SCALE_DELTA).toFixed(2))/10}while(--i>0&&n>s.MIN_SCALE)}this.#fr(Math.max(s.MIN_SCALE,n),{noScroll:!1,drawingDelay:e})}#pr(e=this.container.clientHeight){if(e!==this.#rr){this.#rr=e;s.docStyle.setProperty("--viewer-container-height",`${e}px`)}}#lr(e){for(const t of e)if(t.target===this.container){this.#pr(Math.floor(t.borderBoxSize[0].blockSize));this.#er=null;break}}get containerTopLeft(){return this.#er||=[this.container.offsetTop,this.container.offsetLeft]}get annotationEditorMode(){return this.#Za?this.#Qa:n.AnnotationEditorType.DISABLE}set annotationEditorMode({mode:e,editId:t=null}){if(!this.#Za)throw new Error("The AnnotationEditor is not enabled.");if(this.#Qa!==e){if(!isValidAnnotationEditorMode(e))throw new Error(`Invalid AnnotationEditor mode: ${e}`);if(this.pdfDocument){this.#Qa=e;this.eventBus.dispatch("annotationeditormodechanged",{source:this,mode:e});this.#Za.updateMode(e,t)}}}set annotationEditorParams({type:e,value:t}){if(!this.#Za)throw new Error("The AnnotationEditor is not enabled.");this.#Za.updateParams(e,t)}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(const e of this._pages)e.update(t);if(null!==this.#cr){clearTimeout(this.#cr);this.#cr=null}e||this.update()}}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.NullL10n=void 0;t.getL10nFallback=getL10nFallback;const i={of_pages:"of {{pagesCount}}",page_of_pages:"({{pageNumber}} of {{pagesCount}})",document_properties_kb:"{{size_kb}} KB ({{size_b}} bytes)",document_properties_mb:"{{size_mb}} MB ({{size_b}} bytes)",document_properties_date_string:"{{date}}, {{time}}",document_properties_page_size_unit_inches:"in",document_properties_page_size_unit_millimeters:"mm",document_properties_page_size_orientation_portrait:"portrait",document_properties_page_size_orientation_landscape:"landscape",document_properties_page_size_name_a3:"A3",document_properties_page_size_name_a4:"A4",document_properties_page_size_name_letter:"Letter",document_properties_page_size_name_legal:"Legal",document_properties_page_size_dimension_string:"{{width}} × {{height}} {{unit}} ({{orientation}})",document_properties_page_size_dimension_name_string:"{{width}} × {{height}} {{unit}} ({{name}}, {{orientation}})",document_properties_linearized_yes:"Yes",document_properties_linearized_no:"No",additional_layers:"Additional Layers",page_landmark:"Page {{page}}",thumb_page_title:"Page {{page}}",thumb_page_canvas:"Thumbnail of Page {{page}}",find_reached_top:"Reached top of document, continued from bottom",find_reached_bottom:"Reached end of document, continued from top","find_match_count[one]":"{{current}} of {{total}} match","find_match_count[other]":"{{current}} of {{total}} matches","find_match_count_limit[one]":"More than {{limit}} match","find_match_count_limit[other]":"More than {{limit}} matches",find_not_found:"Phrase not found",page_scale_width:"Page Width",page_scale_fit:"Page Fit",page_scale_auto:"Automatic Zoom",page_scale_actual:"Actual Size",page_scale_percent:"{{scale}}%",loading_error:"An error occurred while loading the PDF.",invalid_file_error:"Invalid or corrupted PDF file.",missing_file_error:"Missing PDF file.",unexpected_response_error:"Unexpected server response.",rendering_error:"An error occurred while rendering the page.",annotation_date_string:"{{date}}, {{time}}",printing_not_supported:"Warning: Printing is not fully supported by this browser.",printing_not_ready:"Warning: The PDF is not fully loaded for printing.",web_fonts_disabled:"Web fonts are disabled: unable to use embedded PDF fonts.",free_text2_default_content:"Start typing…",editor_free_text2_aria_label:"Text Editor",editor_ink2_aria_label:"Draw Editor",editor_ink_canvas_aria_label:"User-created image",editor_alt_text_button_label:"Alt text",editor_alt_text_edit_button_label:"Edit alt text",editor_alt_text_decorative_tooltip:"Marked as decorative",print_progress_percent:"{{progress}}%"};function getL10nFallback(e,t){switch(e){case"find_match_count":e=`find_match_count[${1===t.total?"one":"other"}]`;break;case"find_match_count_limit":e=`find_match_count_limit[${1===t.limit?"one":"other"}]`}return i[e]||""}const n={getLanguage:async()=>"en-us",getDirection:async()=>"ltr",get:async(e,t=null,i=getL10nFallback(e,t))=>function formatL10nValue(e,t){return t?e.replaceAll(/\{\{\s*(\w+)\s*\}\}/g,((e,i)=>i in t?t[i]:"{{"+i+"}}")):e}(i,t),async translate(e){}};t.NullL10n=n},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFPageView=void 0;var n=i(4),s=i(3),a=i(32),r=i(33),o=i(5),l=i(30),d=(i(7),i(34)),h=i(35),c=i(36),u=i(37),p=i(38);const g=o.compatibilityParams.maxCanvasPixels||16777216,DEFAULT_LAYER_PROPERTIES=()=>null;t.PDFPageView=class PDFPageView{#Ja=n.AnnotationMode.ENABLE_FORMS;#Pr=!1;#mr=null;#Cr=null;#xr=null;#Tr=null;#Mr=s.RenderingStates.INITIAL;#ur=s.TextLayerMode.ENABLE;#Ir={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#kr=new WeakMap;constructor(e){const t=e.container,i=e.defaultViewport;this.id=e.id;this.renderingId="page"+this.id;this.#mr=e.layerProperties||DEFAULT_LAYER_PROPERTIES;this.pdfPage=null;this.pageLabel=null;this.rotation=0;this.scale=e.scale||s.DEFAULT_SCALE;this.viewport=i;this.pdfPageRotate=i.rotation;this._optionalContentConfigPromise=e.optionalContentConfigPromise||null;this.#ur=e.textLayerMode??s.TextLayerMode.ENABLE;this.#Ja=e.annotationMode??n.AnnotationMode.ENABLE_FORMS;this.imageResourcesPath=e.imageResourcesPath||"";this.isOffscreenCanvasSupported=e.isOffscreenCanvasSupported??!0;this.maxCanvasPixels=e.maxCanvasPixels??g;this.pageColors=e.pageColors||null;this.eventBus=e.eventBus;this.renderingQueue=e.renderingQueue;this.l10n=e.l10n||l.NullL10n;this.renderTask=null;this.resume=null;this._isStandalone=!this.renderingQueue?.hasViewer();this._container=t;if(e.useOnlyCssZoom){console.error("useOnlyCssZoom was removed, please use `maxCanvasPixels = 0` instead.");this.maxCanvasPixels=0}this._annotationCanvasMap=null;this.annotationLayer=null;this.annotationEditorLayer=null;this.textLayer=null;this.zoomLayer=null;this.xfaLayer=null;this.structTreeLayer=null;const a=document.createElement("div");a.className="page";a.setAttribute("data-page-number",this.id);a.setAttribute("role","region");this.l10n.get("page_landmark",{page:this.id}).then((e=>{a.setAttribute("aria-label",e)}));this.div=a;this.#Mn();t?.append(a);if(this._isStandalone){t?.style.setProperty("--scale-factor",this.scale*n.PixelsPerInch.PDF_TO_CSS_UNITS);const{optionalContentConfigPromise:i}=e;i&&i.then((e=>{i===this._optionalContentConfigPromise&&(this.#Ir.initialOptionalContent=e.hasInitialVisibility)}))}}get renderingState(){return this.#Mr}set renderingState(e){if(e!==this.#Mr){this.#Mr=e;if(this.#Cr){clearTimeout(this.#Cr);this.#Cr=null}switch(e){case s.RenderingStates.PAUSED:this.div.classList.remove("loading");break;case s.RenderingStates.RUNNING:this.div.classList.add("loadingIcon");this.#Cr=setTimeout((()=>{this.div.classList.add("loading");this.#Cr=null}),0);break;case s.RenderingStates.INITIAL:case s.RenderingStates.FINISHED:this.div.classList.remove("loadingIcon","loading")}}}#Mn(){const{viewport:e}=this;if(this.pdfPage){if(this.#xr===e.rotation)return;this.#xr=e.rotation}(0,n.setLayerDimensions)(this.div,e,!0,!1)}setPdfPage(e){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||this._container?.style.setProperty("--hcm-highligh-filter",e.filterFactory.addHighlightHCMFilter("CanvasText","Canvas","HighlightText","Highlight"));this.pdfPage=e;this.pdfPageRotate=e.rotate;const t=(this.rotation+this.pdfPageRotate)%360;this.viewport=e.getViewport({scale:this.scale*n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:t});this.#Mn();this.reset()}destroy(){this.reset();this.pdfPage?.cleanup()}get _textHighlighter(){return(0,n.shadow)(this,"_textHighlighter",new c.TextHighlighter({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#mr().findController}))}async#Dr(){let e=null;try{await this.annotationLayer.render(this.viewport,"display")}catch(t){console.error(`#renderAnnotationLayer: "${t}".`);e=t}finally{this.eventBus.dispatch("annotationlayerrendered",{source:this,pageNumber:this.id,error:e})}}async#Lr(){let e=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(t){console.error(`#renderAnnotationEditorLayer: "${t}".`);e=t}finally{this.eventBus.dispatch("annotationeditorlayerrendered",{source:this,pageNumber:this.id,error:e})}}async#Fr(){let e=null;try{const e=await this.xfaLayer.render(this.viewport,"display");e?.textDivs&&this._textHighlighter&&this.#Rr(e.textDivs)}catch(t){console.error(`#renderXfaLayer: "${t}".`);e=t}finally{this.eventBus.dispatch("xfalayerrendered",{source:this,pageNumber:this.id,error:e})}}async#Or(){const{pdfPage:e,textLayer:t,viewport:i}=this;if(!t)return;let s=null;try{if(!t.renderingDone){const i=e.streamTextContent({includeMarkedContent:!0,disableNormalization:!0});t.setTextContentSource(i)}await t.render(i)}catch(e){if(e instanceof n.AbortException)return;console.error(`#renderTextLayer: "${e}".`);s=e}this.eventBus.dispatch("textlayerrendered",{source:this,pageNumber:this.id,numTextDivs:t.numTextDivs,error:s});this.#Nr()}async#Nr(){if(!this.textLayer)return;this.structTreeLayer||=new d.StructTreeLayerBuilder;const e=await(this.structTreeLayer.renderingDone?null:this.pdfPage.getStructTree()),t=this.structTreeLayer?.render(e);t&&this.canvas?.append(t);this.structTreeLayer?.show()}async#Rr(e){const t=await this.pdfPage.getTextContent(),i=[];for(const e of t.items)i.push(e.str);this._textHighlighter.setTextMapping(e,i);this._textHighlighter.enable()}_resetZoomLayer(e=!1){if(!this.zoomLayer)return;const t=this.zoomLayer.firstChild;this.#kr.delete(t);t.width=0;t.height=0;e&&this.zoomLayer.remove();this.zoomLayer=null}reset({keepZoomLayer:e=!1,keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:i=!1,keepXfaLayer:n=!1,keepTextLayer:a=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:i,keepXfaLayer:n,keepTextLayer:a});this.renderingState=s.RenderingStates.INITIAL;const r=this.div,o=r.childNodes,l=e&&this.zoomLayer||null,d=t&&this.annotationLayer?.div||null,h=i&&this.annotationEditorLayer?.div||null,c=n&&this.xfaLayer?.div||null,u=a&&this.textLayer?.div||null;for(let e=o.length-1;e>=0;e--){const t=o[e];switch(t){case l:case d:case h:case c:case u:continue}t.remove()}r.removeAttribute("data-loaded");d&&this.annotationLayer.hide();h&&this.annotationEditorLayer.hide();c&&this.xfaLayer.hide();u&&this.textLayer.hide();this.structTreeLayer?.hide();if(!l){if(this.canvas){this.#kr.delete(this.canvas);this.canvas.width=0;this.canvas.height=0;delete this.canvas}this._resetZoomLayer()}}update({scale:e=0,rotation:t=null,optionalContentConfigPromise:i=null,drawingDelay:a=-1}){this.scale=e||this.scale;"number"==typeof t&&(this.rotation=t);if(i instanceof Promise){this._optionalContentConfigPromise=i;i.then((e=>{i===this._optionalContentConfigPromise&&(this.#Ir.initialOptionalContent=e.hasInitialVisibility)}))}this.#Ir.directDrawing=!0;const r=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:this.scale*n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:r});this.#Mn();this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale);if(this.canvas){let e=!1;if(this.#Pr)if(0===this.maxCanvasPixels)e=!0;else if(this.maxCanvasPixels>0){const{width:t,height:i}=this.viewport,{sx:n,sy:s}=this.outputScale;e=(Math.floor(t)*n|0)*(Math.floor(i)*s|0)>this.maxCanvasPixels}const t=!e&&a>=0&&a<1e3;if(t||e){if(t&&this.renderingState!==s.RenderingStates.FINISHED){this.cancelRendering({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:a});this.renderingState=s.RenderingStates.FINISHED;this.#Ir.directDrawing=!1}this.cssTransform({target:this.canvas,redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!t,hideTextLayer:t});if(t)return;this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#Tr});return}if(!this.zoomLayer&&!this.canvas.hidden){this.zoomLayer=this.canvas.parentNode;this.zoomLayer.style.position="absolute"}}this.zoomLayer&&this.cssTransform({target:this.zoomLayer.firstChild});this.reset({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0})}cancelRendering({keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:t=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,cancelExtraDelay:s=0}={}){if(this.renderTask){this.renderTask.cancel(s);this.renderTask=null}this.resume=null;if(this.textLayer&&(!n||!this.textLayer.div)){this.textLayer.cancel();this.textLayer=null}this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null);if(this.annotationLayer&&(!e||!this.annotationLayer.div)){this.annotationLayer.cancel();this.annotationLayer=null;this._annotationCanvasMap=null}if(this.annotationEditorLayer&&(!t||!this.annotationEditorLayer.div)){this.annotationEditorLayer.cancel();this.annotationEditorLayer=null}if(this.xfaLayer&&(!i||!this.xfaLayer.div)){this.xfaLayer.cancel();this.xfaLayer=null;this._textHighlighter?.disable()}}cssTransform({target:e,redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:i=!1,redrawXfaLayer:n=!1,redrawTextLayer:s=!1,hideTextLayer:a=!1}){if(!e.hasAttribute("zooming")){e.setAttribute("zooming",!0);const{style:t}=e;t.width=t.height=""}const r=this.#kr.get(e);if(this.viewport!==r){const t=this.viewport.rotation-r.rotation,i=Math.abs(t);let n=1,s=1;if(90===i||270===i){const{width:e,height:t}=this.viewport;n=t/e;s=e/t}e.style.transform=`rotate(${t}deg) scale(${n}, ${s})`}t&&this.annotationLayer&&this.#Dr();i&&this.annotationEditorLayer&&this.#Lr();n&&this.xfaLayer&&this.#Fr();if(this.textLayer)if(a){this.textLayer.hide();this.structTreeLayer?.hide()}else s&&this.#Or()}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}async#$a(e,t=null){e===this.renderTask&&(this.renderTask=null);if(t instanceof n.RenderingCancelledException)this.#Tr=null;else{this.#Tr=t;this.renderingState=s.RenderingStates.FINISHED;this._resetZoomLayer(!0);this.#Ir.regularAnnotations=!e.separateAnnots;this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#Tr});if(t)throw t}}async draw(){if(this.renderingState!==s.RenderingStates.INITIAL){console.error("Must be in new state before drawing");this.reset()}const{div:e,l10n:t,pageColors:i,pdfPage:o,viewport:l}=this;if(!o){this.renderingState=s.RenderingStates.FINISHED;throw new Error("pdfPage is not loaded")}this.renderingState=s.RenderingStates.RUNNING;const d=document.createElement("div");d.classList.add("canvasWrapper");e.append(d);if(!this.textLayer&&this.#ur!==s.TextLayerMode.DISABLE&&!o.isPureXfa){this._accessibilityManager||=new h.TextAccessibilityManager;this.textLayer=new u.TextLayerBuilder({highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,enablePermissions:this.#ur===s.TextLayerMode.ENABLE_PERMISSIONS});e.append(this.textLayer.div)}if(!this.annotationLayer&&this.#Ja!==n.AnnotationMode.DISABLE){const{annotationStorage:i,downloadManager:s,enableScripting:a,fieldObjectsPromise:l,hasJSActionsPromise:d,linkService:h}=this.#mr();this._annotationCanvasMap||=new Map;this.annotationLayer=new r.AnnotationLayerBuilder({pageDiv:e,pdfPage:o,annotationStorage:i,imageResourcesPath:this.imageResourcesPath,renderForms:this.#Ja===n.AnnotationMode.ENABLE_FORMS,linkService:h,downloadManager:s,l10n:t,enableScripting:a,hasJSActionsPromise:d,fieldObjectsPromise:l,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager})}const{width:c,height:g}=l,f=document.createElement("canvas");f.setAttribute("role","presentation");f.hidden=!0;const m=!(!i?.background||!i?.foreground);let showCanvas=e=>{if(!m||e){f.hidden=!1;showCanvas=null}};d.append(f);this.canvas=f;const b=f.getContext("2d",{alpha:!1}),v=this.outputScale=new s.OutputScale;if(0===this.maxCanvasPixels){const e=1/this.scale;v.sx*=e;v.sy*=e;this.#Pr=!0}else if(this.maxCanvasPixels>0){const e=c*g,t=Math.sqrt(this.maxCanvasPixels/e);if(v.sx>t||v.sy>t){v.sx=t;v.sy=t;this.#Pr=!0}else this.#Pr=!1}const _=(0,s.approximateFraction)(v.sx),w=(0,s.approximateFraction)(v.sy);f.width=(0,s.roundToDivide)(c*v.sx,_[0]);f.height=(0,s.roundToDivide)(g*v.sy,w[0]);const{style:y}=f;y.width=(0,s.roundToDivide)(c,_[1])+"px";y.height=(0,s.roundToDivide)(g,w[1])+"px";this.#kr.set(f,l);const S={canvasContext:b,transform:v.scaled?[v.sx,0,0,v.sy,0,0]:null,viewport:l,annotationMode:this.#Ja,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i},A=this.renderTask=this.pdfPage.render(S);A.onContinue=e=>{showCanvas?.(!1);if(!this.renderingQueue||this.renderingQueue.isHighestPriority(this))e();else{this.renderingState=s.RenderingStates.PAUSED;this.resume=()=>{this.renderingState=s.RenderingStates.RUNNING;e()}}};const E=A.promise.then((async()=>{showCanvas?.(!0);await this.#$a(A);this.#Or();this.annotationLayer&&await this.#Dr();if(!this.annotationEditorLayer){const{annotationEditorUIManager:i}=this.#mr();if(!i)return;this.annotationEditorLayer=new a.AnnotationEditorLayerBuilder({uiManager:i,pageDiv:e,pdfPage:o,l10n:t,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer})}this.#Lr()}),(e=>{e instanceof n.RenderingCancelledException||showCanvas?.(!0);return this.#$a(A,e)}));if(o.isPureXfa){if(this.xfaLayer)this.xfaLayer.div&&e.append(this.xfaLayer.div);else{const{annotationStorage:t,linkService:i}=this.#mr();this.xfaLayer=new p.XfaLayerBuilder({pageDiv:e,pdfPage:o,annotationStorage:t,linkService:i})}this.#Fr()}e.setAttribute("data-loaded",!0);this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id});return E}setPageLabel(e){this.pageLabel="string"==typeof e?e:null;null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:e,initialOptionalContent:t,regularAnnotations:i}=this.#Ir;return e&&t&&i?this.canvas:null}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationEditorLayerBuilder=void 0;var n=i(4),s=i(30);t.AnnotationEditorLayerBuilder=class AnnotationEditorLayerBuilder{#Et=null;#kt;constructor(e){this.pageDiv=e.pageDiv;this.pdfPage=e.pdfPage;this.accessibilityManager=e.accessibilityManager;this.l10n=e.l10n||s.NullL10n;this.annotationEditorLayer=null;this.div=null;this._cancelled=!1;this.#kt=e.uiManager;this.#Et=e.annotationLayer||null}async render(e,t="display"){if("display"!==t)return;if(this._cancelled)return;const i=e.clone({dontFlip:!0});if(this.div){this.annotationEditorLayer.update({viewport:i});this.show();return}const s=this.div=document.createElement("div");s.className="annotationEditorLayer";s.tabIndex=0;s.hidden=!0;s.dir=this.#kt.direction;this.pageDiv.append(s);this.annotationEditorLayer=new n.AnnotationEditorLayer({uiManager:this.#kt,div:s,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#Et});const a={viewport:i,div:s,annotations:null,intent:t};this.annotationEditorLayer.render(a);this.show()}cancel(){this._cancelled=!0;if(this.div){this.pageDiv=null;this.annotationEditorLayer.destroy();this.div.remove()}}hide(){this.div&&(this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isEmpty&&(this.div.hidden=!1)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.AnnotationLayerBuilder=void 0;var n=i(4),s=i(30),a=i(3);t.AnnotationLayerBuilder=class AnnotationLayerBuilder{#Br=null;constructor({pageDiv:e,pdfPage:t,linkService:i,downloadManager:n,annotationStorage:a=null,imageResourcesPath:r="",renderForms:o=!0,l10n:l=s.NullL10n,enableScripting:d=!1,hasJSActionsPromise:h=null,fieldObjectsPromise:c=null,annotationCanvasMap:u=null,accessibilityManager:p=null}){this.pageDiv=e;this.pdfPage=t;this.linkService=i;this.downloadManager=n;this.imageResourcesPath=r;this.renderForms=o;this.l10n=l;this.annotationStorage=a;this.enableScripting=d;this._hasJSActionsPromise=h||Promise.resolve(!1);this._fieldObjectsPromise=c||Promise.resolve(null);this._annotationCanvasMap=u;this._accessibilityManager=p;this.annotationLayer=null;this.div=null;this._cancelled=!1;this._eventBus=i.eventBus}async render(e,t="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;this.annotationLayer.update({viewport:e.clone({dontFlip:!0})});return}const[i,s,r]=await Promise.all([this.pdfPage.getAnnotations({intent:t}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const o=this.div=document.createElement("div");o.className="annotationLayer";this.pageDiv.append(o);if(0!==i.length){this.annotationLayer=new n.AnnotationLayer({div:o,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,l10n:this.l10n,page:this.pdfPage,viewport:e.clone({dontFlip:!0})});await this.annotationLayer.render({annotations:i,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:s,fieldObjects:r});this.linkService.isInPresentationMode&&this.#Vr(a.PresentationModeState.FULLSCREEN);if(!this.#Br){this.#Br=e=>{this.#Vr(e.state)};this._eventBus?._on("presentationmodechanged",this.#Br)}}else this.hide()}cancel(){this._cancelled=!0;if(this.#Br){this._eventBus?._off("presentationmodechanged",this.#Br);this.#Br=null}}hide(){this.div&&(this.div.hidden=!0)}#Vr(e){if(!this.div)return;let t=!1;switch(e){case a.PresentationModeState.FULLSCREEN:t=!0;break;case a.PresentationModeState.NORMAL:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||(e.inert=t)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.StructTreeLayerBuilder=void 0;var n=i(3);const s={Document:null,DocumentFragment:null,Part:"group",Sect:"group",Div:"group",Aside:"note",NonStruct:"none",P:null,H:"heading",Title:null,FENote:"note",Sub:"group",Lbl:null,Span:null,Em:null,Strong:null,Link:"link",Annot:"note",Form:"form",Ruby:null,RB:null,RT:null,RP:null,Warichu:null,WT:null,WP:null,L:"list",LI:"listitem",LBody:null,Table:"table",TR:"row",TH:"columnheader",TD:"cell",THead:"columnheader",TBody:null,TFoot:null,Caption:null,Figure:"figure",Formula:null,Artifact:null},a=/^H(\d+)$/;t.StructTreeLayerBuilder=class StructTreeLayerBuilder{#Ur=void 0;get renderingDone(){return void 0!==this.#Ur}render(e){if(void 0!==this.#Ur)return this.#Ur;const t=this.#zr(e);t?.classList.add("structTree");return this.#Ur=t}hide(){this.#Ur&&!this.#Ur.hidden&&(this.#Ur.hidden=!0)}show(){this.#Ur?.hidden&&(this.#Ur.hidden=!1)}#Hr(e,t){const{alt:i,id:s,lang:a}=e;void 0!==i&&t.setAttribute("aria-label",(0,n.removeNullCharacters)(i));void 0!==s&&t.setAttribute("aria-owns",s);void 0!==a&&t.setAttribute("lang",(0,n.removeNullCharacters)(a,!0))}#zr(e){if(!e)return null;const t=document.createElement("span");if("role"in e){const{role:i}=e,n=i.match(a);if(n){t.setAttribute("role","heading");t.setAttribute("aria-level",n[1])}else s[i]&&t.setAttribute("role",s[i])}this.#Hr(e,t);if(e.children)if(1===e.children.length&&"id"in e.children[0])this.#Hr(e.children[0],t);else for(const i of e.children)t.append(this.#zr(i));return t}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TextAccessibilityManager=void 0;var n=i(3);class TextAccessibilityManager{#jr=!1;#Wr=null;#Gr=new Map;#$r=new Map;setTextMapping(e){this.#Wr=e}static#qr(e,t){const i=e.getBoundingClientRect(),n=t.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===n.width&&0===n.height)return-1;const s=i.y,a=i.y+i.height,r=i.y+i.height/2,o=n.y,l=n.y+n.height,d=n.y+n.height/2;if(r<=o&&d>=a)return-1;if(d<=s&&r>=l)return 1;return i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#jr)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Wr)throw new Error("Text divs and strings have not been set.");this.#jr=!0;this.#Wr=this.#Wr.slice();this.#Wr.sort(TextAccessibilityManager.#qr);if(this.#Gr.size>0){const e=this.#Wr;for(const[t,i]of this.#Gr){document.getElementById(t)?this.#Xr(t,e[i]):this.#Gr.delete(t)}}for(const[e,t]of this.#$r)this.addPointerInTextLayer(e,t);this.#$r.clear()}disable(){if(this.#jr){this.#$r.clear();this.#Wr=null;this.#jr=!1}}removePointerInTextLayer(e){if(!this.#jr){this.#$r.delete(e);return}const t=this.#Wr;if(!t||0===t.length)return;const{id:i}=e,n=this.#Gr.get(i);if(void 0===n)return;const s=t[n];this.#Gr.delete(i);let a=s.getAttribute("aria-owns");if(a?.includes(i)){a=a.split(" ").filter((e=>e!==i)).join(" ");if(a)s.setAttribute("aria-owns",a);else{s.removeAttribute("aria-owns");s.setAttribute("role","presentation")}}}#Xr(e,t){const i=t.getAttribute("aria-owns");i?.includes(e)||t.setAttribute("aria-owns",i?`${i} ${e}`:e);t.removeAttribute("role")}addPointerInTextLayer(e,t){const{id:i}=e;if(!i)return null;if(!this.#jr){this.#$r.set(e,t);return null}t&&this.removePointerInTextLayer(e);const s=this.#Wr;if(!s||0===s.length)return null;const a=(0,n.binarySearchFirstItem)(s,(t=>TextAccessibilityManager.#qr(e,t)<0)),r=Math.max(0,a-1),o=s[r];this.#Xr(i,o);this.#Gr.set(i,r);const l=o.parentNode;return l?.classList.contains("markedContent")?l.id:null}moveElementInDOM(e,t,i,s){const a=this.addPointerInTextLayer(i,s);if(!e.hasChildNodes()){e.append(t);return a}const r=Array.from(e.childNodes).filter((e=>e!==t));if(0===r.length)return a;const o=i||t,l=(0,n.binarySearchFirstItem)(r,(e=>TextAccessibilityManager.#qr(o,e)<0));0===l?r[0].before(t):r[l-1].after(t);return a}}t.TextAccessibilityManager=TextAccessibilityManager},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TextHighlighter=void 0;t.TextHighlighter=class TextHighlighter{constructor({findController:e,eventBus:t,pageIndex:i}){this.findController=e;this.matches=[];this.eventBus=t;this.pageIdx=i;this._onUpdateTextLayerMatches=null;this.textDivs=null;this.textContentItemsStr=null;this.enabled=!1}setTextMapping(e,t){this.textDivs=e;this.textContentItemsStr=t}enable(){if(!this.textDivs||!this.textContentItemsStr)throw new Error("Text divs and strings have not been set.");if(this.enabled)throw new Error("TextHighlighter is already enabled.");this.enabled=!0;if(!this._onUpdateTextLayerMatches){this._onUpdateTextLayerMatches=e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()};this.eventBus._on("updatetextlayermatches",this._onUpdateTextLayerMatches)}this._updateMatches()}disable(){if(this.enabled){this.enabled=!1;if(this._onUpdateTextLayerMatches){this.eventBus._off("updatetextlayermatches",this._onUpdateTextLayerMatches);this._onUpdateTextLayerMatches=null}this._updateMatches(!0)}}_convertMatches(e,t){if(!e)return[];const{textContentItemsStr:i}=this;let n=0,s=0;const a=i.length-1,r=[];for(let o=0,l=e.length;o<l;o++){let l=e[o];for(;n!==a&&l>=s+i[n].length;){s+=i[n].length;n++}n===i.length&&console.error("Could not find a matching mapping");const d={begin:{divIdx:n,offset:l-s}};l+=t[o];for(;n!==a&&l>s+i[n].length;){s+=i[n].length;n++}d.end={divIdx:n,offset:l-s};r.push(d)}return r}_renderMatches(e){if(0===e.length)return;const{findController:t,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,a=i===t.selected.pageIdx,r=t.selected.matchIdx;let o=null;const l={divIdx:-1,offset:void 0};function beginText(e,t){const i=e.divIdx;s[i].textContent="";return appendTextToDiv(i,0,e.offset,t)}function appendTextToDiv(e,t,i,a){let r=s[e];if(r.nodeType===Node.TEXT_NODE){const t=document.createElement("span");r.before(t);t.append(r);s[e]=t;r=t}const o=n[e].substring(t,i),l=document.createTextNode(o);if(a){const e=document.createElement("span");e.className=`${a} appended`;e.append(l);r.append(e);return a.includes("selected")?e.offsetLeft:0}r.append(l);return 0}let d=r,h=d+1;if(t.state.highlightAll){d=0;h=e.length}else if(!a)return;let c=-1,u=-1;for(let n=d;n<h;n++){const d=e[n],h=d.begin;if(h.divIdx===c&&h.offset===u)continue;c=h.divIdx;u=h.offset;const p=d.end,g=a&&n===r,f=g?" selected":"";let m=0;if(o&&h.divIdx===o.divIdx)appendTextToDiv(o.divIdx,o.offset,h.offset);else{null!==o&&appendTextToDiv(o.divIdx,o.offset,l.offset);beginText(h)}if(h.divIdx===p.divIdx)m=appendTextToDiv(h.divIdx,h.offset,p.offset,"highlight"+f);else{m=appendTextToDiv(h.divIdx,h.offset,l.offset,"highlight begin"+f);for(let e=h.divIdx+1,t=p.divIdx;e<t;e++)s[e].className="highlight middle"+f;beginText(p,"highlight end"+f)}o=p;g&&t.scrollMatchIntoView({element:s[h.divIdx],selectedLeft:m,pageIndex:i,matchIndex:r})}o&&appendTextToDiv(o.divIdx,o.offset,l.offset)}_updateMatches(e=!1){if(!this.enabled&&!e)return;const{findController:t,matches:i,pageIdx:n}=this,{textContentItemsStr:s,textDivs:a}=this;let r=-1;for(const e of i){for(let t=Math.max(r,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=a[t];e.textContent=s[t];e.className=""}r=e.end.divIdx+1}if(!t?.highlightMatches||e)return;const o=t.pageMatches[n]||null,l=t.pageMatchesLength[n]||null;this.matches=this._convertMatches(o,l);this._renderMatches(this.matches)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.TextLayerBuilder=void 0;var n=i(4),s=i(3);t.TextLayerBuilder=class TextLayerBuilder{#ir=!1;#Kr=0;#Yr=0;#Qr=null;constructor({highlighter:e=null,accessibilityManager:t=null,isOffscreenCanvasSupported:i=!0,enablePermissions:n=!1}){this.textContentItemsStr=[];this.renderingDone=!1;this.textDivs=[];this.textDivProperties=new WeakMap;this.textLayerRenderTask=null;this.highlighter=e;this.accessibilityManager=t;this.isOffscreenCanvasSupported=i;this.#ir=!0===n;this.div=document.createElement("div");this.div.className="textLayer";this.hide()}#Zr(){this.renderingDone=!0;const e=document.createElement("div");e.className="endOfContent";this.div.append(e);this.#Jr()}get numTextDivs(){return this.textDivs.length}async render(e){if(!this.#Qr)throw new Error('No "textContentSource" parameter specified.');const t=e.scale*(globalThis.devicePixelRatio||1),{rotation:i}=e;if(this.renderingDone){const s=i!==this.#Kr,a=t!==this.#Yr;if(s||a){this.hide();(0,n.updateTextLayer)({container:this.div,viewport:e,textDivs:this.textDivs,textDivProperties:this.textDivProperties,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,mustRescale:a,mustRotate:s});this.#Yr=t;this.#Kr=i}this.show()}else{this.cancel();this.highlighter?.setTextMapping(this.textDivs,this.textContentItemsStr);this.accessibilityManager?.setTextMapping(this.textDivs);this.textLayerRenderTask=(0,n.renderTextLayer)({textContentSource:this.#Qr,container:this.div,viewport:e,textDivs:this.textDivs,textDivProperties:this.textDivProperties,textContentItemsStr:this.textContentItemsStr,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported});await this.textLayerRenderTask.promise;this.#Zr();this.#Yr=t;this.#Kr=i;this.show();this.accessibilityManager?.enable()}}hide(){if(!this.div.hidden){this.highlighter?.disable();this.div.hidden=!0}}show(){if(this.div.hidden&&this.renderingDone){this.div.hidden=!1;this.highlighter?.enable()}}cancel(){if(this.textLayerRenderTask){this.textLayerRenderTask.cancel();this.textLayerRenderTask=null}this.highlighter?.disable();this.accessibilityManager?.disable();this.textContentItemsStr.length=0;this.textDivs.length=0;this.textDivProperties=new WeakMap}setTextContentSource(e){this.cancel();this.#Qr=e}#Jr(){const{div:e}=this;e.addEventListener("mousedown",(t=>{const i=e.querySelector(".endOfContent");if(!i)return;let n=t.target!==e;n&&="none"!==getComputedStyle(i).getPropertyValue("-moz-user-select");if(n){const n=e.getBoundingClientRect(),s=Math.max(0,(t.pageY-n.top)/n.height);i.style.top=(100*s).toFixed(2)+"%"}i.classList.add("active")}));e.addEventListener("mouseup",(()=>{const t=e.querySelector(".endOfContent");if(t){t.style.top="";t.classList.remove("active")}}));e.addEventListener("copy",(e=>{if(!this.#ir){const t=document.getSelection();e.clipboardData.setData("text/plain",(0,s.removeNullCharacters)((0,n.normalizeUnicode)(t.toString())))}e.preventDefault();e.stopPropagation()}))}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.XfaLayerBuilder=void 0;var n=i(4);t.XfaLayerBuilder=class XfaLayerBuilder{constructor({pageDiv:e,pdfPage:t,annotationStorage:i=null,linkService:n,xfaHtml:s=null}){this.pageDiv=e;this.pdfPage=t;this.annotationStorage=i;this.linkService=n;this.xfaHtml=s;this.div=null;this._cancelled=!1}async render(e,t="display"){if("print"===t){const i={viewport:e.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t},s=document.createElement("div");this.pageDiv.append(s);i.div=s;return n.XfaLayer.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const s={viewport:e.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:t};if(this.div)return n.XfaLayer.update(s);this.div=document.createElement("div");this.pageDiv.append(this.div);s.div=this.div;return n.XfaLayer.render(s)}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.SecondaryToolbar=void 0;var n=i(3),s=i(29);t.SecondaryToolbar=class SecondaryToolbar{constructor(e,t){this.toolbar=e.toolbar;this.toggleButton=e.toggleButton;this.buttons=[{element:e.presentationModeButton,eventName:"presentationmode",close:!0},{element:e.printButton,eventName:"print",close:!0},{element:e.downloadButton,eventName:"download",close:!0},{element:e.viewBookmarkButton,eventName:null,close:!0},{element:e.firstPageButton,eventName:"firstpage",close:!0},{element:e.lastPageButton,eventName:"lastpage",close:!0},{element:e.pageRotateCwButton,eventName:"rotatecw",close:!1},{element:e.pageRotateCcwButton,eventName:"rotateccw",close:!1},{element:e.cursorSelectToolButton,eventName:"switchcursortool",eventDetails:{tool:n.CursorTool.SELECT},close:!0},{element:e.cursorHandToolButton,eventName:"switchcursortool",eventDetails:{tool:n.CursorTool.HAND},close:!0},{element:e.scrollPageButton,eventName:"switchscrollmode",eventDetails:{mode:n.ScrollMode.PAGE},close:!0},{element:e.scrollVerticalButton,eventName:"switchscrollmode",eventDetails:{mode:n.ScrollMode.VERTICAL},close:!0},{element:e.scrollHorizontalButton,eventName:"switchscrollmode",eventDetails:{mode:n.ScrollMode.HORIZONTAL},close:!0},{element:e.scrollWrappedButton,eventName:"switchscrollmode",eventDetails:{mode:n.ScrollMode.WRAPPED},close:!0},{element:e.spreadNoneButton,eventName:"switchspreadmode",eventDetails:{mode:n.SpreadMode.NONE},close:!0},{element:e.spreadOddButton,eventName:"switchspreadmode",eventDetails:{mode:n.SpreadMode.ODD},close:!0},{element:e.spreadEvenButton,eventName:"switchspreadmode",eventDetails:{mode:n.SpreadMode.EVEN},close:!0},{element:e.documentPropertiesButton,eventName:"documentproperties",close:!0}];this.buttons.push({element:e.openFileButton,eventName:"openfile",close:!0});this.items={firstPage:e.firstPageButton,lastPage:e.lastPageButton,pageRotateCw:e.pageRotateCwButton,pageRotateCcw:e.pageRotateCcwButton};this.eventBus=t;this.opened=!1;this.#eo();this.#to(e);this.#io(e);this.#no(e);this.reset()}get isOpen(){return this.opened}setPageNumber(e){this.pageNumber=e;this.#Un()}setPagesCount(e){this.pagesCount=e;this.#Un()}reset(){this.pageNumber=0;this.pagesCount=0;this.#Un();this.eventBus.dispatch("secondarytoolbarreset",{source:this})}#Un(){this.items.firstPage.disabled=this.pageNumber<=1;this.items.lastPage.disabled=this.pageNumber>=this.pagesCount;this.items.pageRotateCw.disabled=0===this.pagesCount;this.items.pageRotateCcw.disabled=0===this.pagesCount}#eo(){this.toggleButton.addEventListener("click",this.toggle.bind(this));for(const{element:e,eventName:t,close:i,eventDetails:n}of this.buttons)e.addEventListener("click",(s=>{null!==t&&this.eventBus.dispatch(t,{source:this,...n});i&&this.close();this.eventBus.dispatch("reporttelemetry",{source:this,details:{type:"buttons",data:{id:e.id}}})}))}#to({cursorSelectToolButton:e,cursorHandToolButton:t}){this.eventBus._on("cursortoolchanged",(({tool:i})=>{(0,n.toggleCheckedBtn)(e,i===n.CursorTool.SELECT);(0,n.toggleCheckedBtn)(t,i===n.CursorTool.HAND)}))}#io({scrollPageButton:e,scrollVerticalButton:t,scrollHorizontalButton:i,scrollWrappedButton:a,spreadNoneButton:r,spreadOddButton:o,spreadEvenButton:l}){const scrollModeChanged=({mode:d})=>{(0,n.toggleCheckedBtn)(e,d===n.ScrollMode.PAGE);(0,n.toggleCheckedBtn)(t,d===n.ScrollMode.VERTICAL);(0,n.toggleCheckedBtn)(i,d===n.ScrollMode.HORIZONTAL);(0,n.toggleCheckedBtn)(a,d===n.ScrollMode.WRAPPED);const h=this.pagesCount>s.PagesCountLimit.FORCE_SCROLL_MODE_PAGE;e.disabled=h;t.disabled=h;i.disabled=h;a.disabled=h;const c=d===n.ScrollMode.HORIZONTAL;r.disabled=c;o.disabled=c;l.disabled=c};this.eventBus._on("scrollmodechanged",scrollModeChanged);this.eventBus._on("secondarytoolbarreset",(e=>{e.source===this&&scrollModeChanged({mode:n.ScrollMode.VERTICAL})}))}#no({spreadNoneButton:e,spreadOddButton:t,spreadEvenButton:i}){const spreadModeChanged=({mode:s})=>{(0,n.toggleCheckedBtn)(e,s===n.SpreadMode.NONE);(0,n.toggleCheckedBtn)(t,s===n.SpreadMode.ODD);(0,n.toggleCheckedBtn)(i,s===n.SpreadMode.EVEN)};this.eventBus._on("spreadmodechanged",spreadModeChanged);this.eventBus._on("secondarytoolbarreset",(e=>{e.source===this&&spreadModeChanged({mode:n.SpreadMode.NONE})}))}open(){if(!this.opened){this.opened=!0;(0,n.toggleExpandedBtn)(this.toggleButton,!0,this.toolbar)}}close(){if(this.opened){this.opened=!1;(0,n.toggleExpandedBtn)(this.toggleButton,!1,this.toolbar)}}toggle(){this.opened?this.close():this.open()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.Toolbar=void 0;var n=i(3),s=i(4);t.Toolbar=class Toolbar{#so=!1;constructor(e,t,i){this.toolbar=e.container;this.eventBus=t;this.l10n=i;this.buttons=[{element:e.previous,eventName:"previouspage"},{element:e.next,eventName:"nextpage"},{element:e.zoomIn,eventName:"zoomin"},{element:e.zoomOut,eventName:"zoomout"},{element:e.print,eventName:"print"},{element:e.download,eventName:"download"},{element:e.editorFreeTextButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorFreeTextButton;return t.contains("toggled")?s.AnnotationEditorType.NONE:s.AnnotationEditorType.FREETEXT}}},{element:e.editorInkButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorInkButton;return t.contains("toggled")?s.AnnotationEditorType.NONE:s.AnnotationEditorType.INK}}},{element:e.editorStampButton,eventName:"switchannotationeditormode",eventDetails:{get mode(){const{classList:t}=e.editorStampButton;return t.contains("toggled")?s.AnnotationEditorType.NONE:s.AnnotationEditorType.STAMP}}}];this.buttons.push({element:e.openFile,eventName:"openfile"});this.items={numPages:e.numPages,pageNumber:e.pageNumber,scaleSelect:e.scaleSelect,customScaleOption:e.customScaleOption,previous:e.previous,next:e.next,zoomIn:e.zoomIn,zoomOut:e.zoomOut};this.#hs(e);this.reset()}setPageNumber(e,t){this.pageNumber=e;this.pageLabel=t;this.#Un(!1)}setPagesCount(e,t){this.pagesCount=e;this.hasPageLabels=t;this.#Un(!0)}setPageScale(e,t){this.pageScaleValue=(e||t).toString();this.pageScale=t;this.#Un(!1)}reset(){this.pageNumber=0;this.pageLabel=null;this.hasPageLabels=!1;this.pagesCount=0;this.pageScaleValue=n.DEFAULT_SCALE_VALUE;this.pageScale=n.DEFAULT_SCALE;this.#Un(!0);this.updateLoadingIndicatorState();this.eventBus.dispatch("toolbarreset",{source:this})}#hs(e){const{pageNumber:t,scaleSelect:i}=this.items,n=this;for(const{element:e,eventName:t,eventDetails:i}of this.buttons)e.addEventListener("click",(e=>{null!==t&&this.eventBus.dispatch(t,{source:this,...i})}));t.addEventListener("click",(function(){this.select()}));t.addEventListener("change",(function(){n.eventBus.dispatch("pagenumberchanged",{source:n,value:this.value})}));i.addEventListener("change",(function(){"custom"!==this.value&&n.eventBus.dispatch("scalechanged",{source:n,value:this.value})}));i.addEventListener("click",(function(e){const t=e.target;this.value===n.pageScaleValue&&"OPTION"===t.tagName.toUpperCase()&&this.blur()}));i.oncontextmenu=s.noContextMenu;this.eventBus._on("localized",(()=>{this.#so=!0;this.#ao();this.#Un(!0)}));this.#ro(e)}#ro({editorFreeTextButton:e,editorFreeTextParamsToolbar:t,editorInkButton:i,editorInkParamsToolbar:a,editorStampButton:r,editorStampParamsToolbar:o}){const editorModeChanged=({mode:l})=>{(0,n.toggleCheckedBtn)(e,l===s.AnnotationEditorType.FREETEXT,t);(0,n.toggleCheckedBtn)(i,l===s.AnnotationEditorType.INK,a);(0,n.toggleCheckedBtn)(r,l===s.AnnotationEditorType.STAMP,o);const d=l===s.AnnotationEditorType.DISABLE;e.disabled=d;i.disabled=d;r.disabled=d};this.eventBus._on("annotationeditormodechanged",editorModeChanged);this.eventBus._on("toolbarreset",(e=>{e.source===this&&editorModeChanged({mode:s.AnnotationEditorType.DISABLE})}))}#Un(e=!1){if(!this.#so)return;const{pageNumber:t,pagesCount:i,pageScaleValue:s,pageScale:a,items:r}=this;if(e){if(this.hasPageLabels)r.pageNumber.type="text";else{r.pageNumber.type="number";this.l10n.get("of_pages",{pagesCount:i}).then((e=>{r.numPages.textContent=e}))}r.pageNumber.max=i}if(this.hasPageLabels){r.pageNumber.value=this.pageLabel;this.l10n.get("page_of_pages",{pageNumber:t,pagesCount:i}).then((e=>{r.numPages.textContent=e}))}else r.pageNumber.value=t;r.previous.disabled=t<=1;r.next.disabled=t>=i;r.zoomOut.disabled=a<=n.MIN_SCALE;r.zoomIn.disabled=a>=n.MAX_SCALE;this.l10n.get("page_scale_percent",{scale:Math.round(1e4*a)/100}).then((e=>{let t=!1;for(const e of r.scaleSelect.options)if(e.value===s){e.selected=!0;t=!0}else e.selected=!1;if(!t){r.customScaleOption.textContent=e;r.customScaleOption.selected=!0}}))}updateLoadingIndicatorState(e=!1){const{pageNumber:t}=this.items;t.classList.toggle("visiblePageIsLoading",e)}async#ao(){const{items:e,l10n:t}=this,i=Promise.all([t.get("page_scale_auto"),t.get("page_scale_actual"),t.get("page_scale_fit"),t.get("page_scale_width")]);await n.animationStarted;const s=getComputedStyle(e.scaleSelect),a=parseFloat(s.getPropertyValue("--scale-select-width")),r=document.createElement("canvas"),o=r.getContext("2d",{alpha:!1});o.font=`${s.fontSize} ${s.fontFamily}`;let l=0;for(const e of await i){const{width:t}=o.measureText(e);t>l&&(l=t)}l+=.3*a;if(l>a){e.scaleSelect.parentNode.style.setProperty("--scale-select-width",`${l}px`)}r.width=0;r.height=0}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.ViewHistory=void 0;t.ViewHistory=class ViewHistory{constructor(e,t=20){this.fingerprint=e;this.cacheSize=t;this._initializedPromise=this._readFromStorage().then((e=>{const t=JSON.parse(e||"{}");let i=-1;if(Array.isArray(t.files)){for(;t.files.length>=this.cacheSize;)t.files.shift();for(let e=0,n=t.files.length;e<n;e++){if(t.files[e].fingerprint===this.fingerprint){i=e;break}}}else t.files=[];-1===i&&(i=t.files.push({fingerprint:this.fingerprint})-1);this.file=t.files[i];this.database=t}))}async _writeToStorage(){const e=JSON.stringify(this.database);localStorage.setItem("pdfjs.history",e)}async _readFromStorage(){return localStorage.getItem("pdfjs.history")}async set(e,t){await this._initializedPromise;this.file[e]=t;return this._writeToStorage()}async setMultiple(e){await this._initializedPromise;for(const t in e)this.file[t]=e[t];return this._writeToStorage()}async get(e,t){await this._initializedPromise;const i=this.file[e];return void 0!==i?i:t}async getMultiple(e){await this._initializedPromise;const t=Object.create(null);for(const i in e){const n=this.file[i];t[i]=void 0!==n?n:e[i]}return t}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.BasePreferences=void 0;i(5);class BasePreferences{#oo=Object.freeze({annotationEditorMode:0,annotationMode:2,cursorToolOnLoad:0,defaultZoomDelay:400,defaultZoomValue:"",disablePageLabels:!1,enablePermissions:!1,enablePrintAutoRotate:!0,enableScripting:!0,enableStampEditor:!0,externalLinkTarget:0,historyUpdateUrl:!1,ignoreDestinationZoom:!1,forcePageColors:!1,pageColorsBackground:"Canvas",pageColorsForeground:"CanvasText",pdfBugEnabled:!1,sidebarViewOnLoad:-1,scrollModeOnLoad:-1,spreadModeOnLoad:-1,textLayerMode:1,viewerCssTheme:0,viewOnLoad:0,disableAutoFetch:!1,disableFontFace:!1,disableRange:!1,disableStream:!1,enableXfa:!0});#lo=Object.create(null);#do=null;constructor(){if(this.constructor===BasePreferences)throw new Error("Cannot initialize BasePreferences.");this.#do=this._readFromStorage(this.#oo).then((e=>{for(const t in this.#oo){const i=e?.[t];typeof i==typeof this.#oo[t]&&(this.#lo[t]=i)}}))}async _writeToStorage(e){throw new Error("Not implemented: _writeToStorage")}async _readFromStorage(e){throw new Error("Not implemented: _readFromStorage")}async reset(){await this.#do;const e=this.#lo;this.#lo=Object.create(null);return this._writeToStorage(this.#oo).catch((t=>{this.#lo=e;throw t}))}async set(e,t){await this.#do;const i=this.#oo[e],n=this.#lo;if(void 0===i)throw new Error(`Set preference: "${e}" is undefined.`);if(void 0===t)throw new Error("Set preference: no value is specified.");const s=typeof t,a=typeof i;if(s!==a){if("number"!==s||"string"!==a)throw new Error(`Set preference: "${t}" is a ${s}, expected a ${a}.`);t=t.toString()}else if("number"===s&&!Number.isInteger(t))throw new Error(`Set preference: "${t}" must be an integer.`);this.#lo[e]=t;return this._writeToStorage(this.#lo).catch((e=>{this.#lo=n;throw e}))}async get(e){await this.#do;const t=this.#oo[e];if(void 0===t)throw new Error(`Get preference: "${e}" is undefined.`);return this.#lo[e]??t}async getAll(){await this.#do;const e=Object.create(null);for(const t in this.#oo)e[t]=this.#lo[t]??this.#oo[t];return e}}t.BasePreferences=BasePreferences},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.DownloadManager=void 0;var n=i(4);function download(e,t){const i=document.createElement("a");if(!i.click)throw new Error('DownloadManager: "a.click()" is not supported.');i.href=e;i.target="_parent";"download"in i&&(i.download=t);(document.body||document.documentElement).append(i);i.click();i.remove()}t.DownloadManager=class DownloadManager{#ho=new WeakMap;downloadUrl(e,t,i){(0,n.createValidAbsoluteUrl)(e,"http://example.com")?download(e+"#pdfjs.action=download",t):console.error(`downloadUrl - not a valid URL: ${e}`)}downloadData(e,t,i){download(URL.createObjectURL(new Blob([e],{type:i})),t)}openOrDownloadData(e,t,i){const s=(0,n.isPdfFile)(i),a=s?"application/pdf":"";if(s){let n,s=this.#ho.get(e);if(!s){s=URL.createObjectURL(new Blob([t],{type:a}));this.#ho.set(e,s)}n="?file="+encodeURIComponent(s+"#"+i);try{window.open(n);return!0}catch(t){console.error(`openOrDownloadData: ${t}`);URL.revokeObjectURL(s);this.#ho.delete(e)}}this.downloadData(t,i,a);return!1}download(e,t,i,n){download(URL.createObjectURL(e),i)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GenericL10n=void 0;i(45);var n=i(30);const s={en:"en-US",es:"es-ES",fy:"fy-NL",ga:"ga-IE",gu:"gu-IN",hi:"hi-IN",hy:"hy-AM",nb:"nb-NO",ne:"ne-NP",nn:"nn-NO",pa:"pa-IN",pt:"pt-PT",sv:"sv-SE",zh:"zh-CN"};t.GenericL10n=class GenericL10n{constructor(e){const{webL10n:t}=document;this._lang=e;this._ready=new Promise(((i,n)=>{t.setLanguage(function fixupLangCode(e){return s[e?.toLowerCase()]||e}(e),(()=>{i(t)}))}))}async getLanguage(){return(await this._ready).getLanguage()}async getDirection(){return(await this._ready).getDirection()}async get(e,t=null,i=(0,n.getL10nFallback)(e,t)){return(await this._ready).get(e,t,i)}async translate(e){return(await this._ready).translate(e)}}},()=>{document.webL10n=function(e,t){var i={},n="",s="textContent",a="",r={},o="loading",l=!0;function xhrLoadText(e,t,i){t=t||function _onSuccess(e){};i=i||function _onFailure(){};var n=new XMLHttpRequest;n.open("GET",e,l);n.overrideMimeType&&n.overrideMimeType("text/plain; charset=utf-8");n.onreadystatechange=function(){4==n.readyState&&(200==n.status||0===n.status?t(n.responseText):i())};n.onerror=i;n.ontimeout=i;try{n.send(null)}catch(e){i()}}function parseResource(e,t,a,r){var o=e.replace(/[^\/]*$/,"")||"./";function evalString(e){return e.lastIndexOf("\\")<0?e:e.replace(/\\\\/g,"\\").replace(/\\n/g,"\n").replace(/\\r/g,"\r").replace(/\\t/g,"\t").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\{/g,"{").replace(/\\}/g,"}").replace(/\\"/g,'"').replace(/\\'/g,"'")}xhrLoadText(e,(function(e){n+=e;!function parseProperties(e,i){var n={},s=/^\s*|\s*$/,a=/^\s*#|^\s*$/,r=/^\s*\[(.*)\]\s*$/,l=/^\s*@import\s+url\((.*)\)\s*$/i,d=/^([^=\s]*)\s*=\s*(.+)$/;function parseRawLines(e,i,h){var c=e.replace(s,"").split(/[\r\n]+/),u="*",p=t.split("-",1)[0],g=!1,f="";!function nextEntry(){for(;;){if(!c.length){h();return}var e=c.shift();if(!a.test(e)){if(i){if(f=r.exec(e)){u=f[1].toLowerCase();g="*"!==u&&u!==t&&u!==p;continue}if(g)continue;if(f=l.exec(e)){loadImport(o+f[1],nextEntry);return}}var s=e.match(d);s&&3==s.length&&(n[s[1]]=evalString(s[2]))}}}()}function loadImport(e,t){xhrLoadText(e,(function(e){parseRawLines(e,!1,t)}),(function(){console.warn(e+" not found.");t()}))}parseRawLines(e,!0,(function(){i(n)}))}(e,(function(e){for(var t in e){var n,r,o=t.lastIndexOf(".");if(o>0){n=t.substring(0,o);r=t.substring(o+1)}else{n=t;r=s}i[n]||(i[n]={});i[n][r]=e[t]}a&&a()}))}),r)}function loadLocale(e,s){e&&(e=e.toLowerCase());s=s||function _callback(){};!function clear(){i={};n="";a=""}();a=e;var r=function getL10nResourceLinks(){return t.querySelectorAll('link[type="application/l10n"]')}(),l=r.length;if(0!==l){var d,h=0;d=function(){if(++h>=l){s();o="complete"}};for(var c=0;c<l;c++){new L10nResourceLink(r[c]).load(e,d)}}else{var u=function getL10nDictionary(){var e=t.querySelector('script[type="application/l10n"]');return e?JSON.parse(e.innerHTML):null}();if(u&&u.locales&&u.default_locale){console.log("using the embedded JSON directory, early way out");if(!(i=u.locales[e])){var p=u.default_locale.toLowerCase();for(var g in u.locales){if((g=g.toLowerCase())===e){i=u.locales[e];break}g===p&&(i=u.locales[p])}}s()}else console.log("no resource to load, early way out");o="complete"}function L10nResourceLink(e){var t=e.href;this.load=function(e,i){parseResource(t,e,i,(function(){console.warn(t+" not found.");console.warn('"'+e+'" resource not found');a="";i()}))}}}r.plural=function(e,t,n,o){var l=parseFloat(t);if(isNaN(l))return e;if(o!=s)return e;r._pluralRules||(r._pluralRules=function getPluralRules(e){function isIn(e,t){return-1!==t.indexOf(e)}function isBetween(e,t,i){return t<=e&&e<=i}var t={0:function(e){return"other"},1:function(e){return isBetween(e%100,3,10)?"few":0===e?"zero":isBetween(e%100,11,99)?"many":2==e?"two":1==e?"one":"other"},2:function(e){return 0!==e&&e%10==0?"many":2==e?"two":1==e?"one":"other"},3:function(e){return 1==e?"one":"other"},4:function(e){return isBetween(e,0,1)?"one":"other"},5:function(e){return isBetween(e,0,2)&&2!=e?"one":"other"},6:function(e){return 0===e?"zero":e%10==1&&e%100!=11?"one":"other"},7:function(e){return 2==e?"two":1==e?"one":"other"},8:function(e){return isBetween(e,3,6)?"few":isBetween(e,7,10)?"many":2==e?"two":1==e?"one":"other"},9:function(e){return 0===e||1!=e&&isBetween(e%100,1,19)?"few":1==e?"one":"other"},10:function(e){return isBetween(e%10,2,9)&&!isBetween(e%100,11,19)?"few":e%10!=1||isBetween(e%100,11,19)?"other":"one"},11:function(e){return isBetween(e%10,2,4)&&!isBetween(e%100,12,14)?"few":e%10==0||isBetween(e%10,5,9)||isBetween(e%100,11,14)?"many":e%10==1&&e%100!=11?"one":"other"},12:function(e){return isBetween(e,2,4)?"few":1==e?"one":"other"},13:function(e){return isBetween(e%10,2,4)&&!isBetween(e%100,12,14)?"few":1!=e&&isBetween(e%10,0,1)||isBetween(e%10,5,9)||isBetween(e%100,12,14)?"many":1==e?"one":"other"},14:function(e){return isBetween(e%100,3,4)?"few":e%100==2?"two":e%100==1?"one":"other"},15:function(e){return 0===e||isBetween(e%100,2,10)?"few":isBetween(e%100,11,19)?"many":1==e?"one":"other"},16:function(e){return e%10==1&&11!=e?"one":"other"},17:function(e){return 3==e?"few":0===e?"zero":6==e?"many":2==e?"two":1==e?"one":"other"},18:function(e){return 0===e?"zero":isBetween(e,0,2)&&0!==e&&2!=e?"one":"other"},19:function(e){return isBetween(e,2,10)?"few":isBetween(e,0,1)?"one":"other"},20:function(e){return!isBetween(e%10,3,4)&&e%10!=9||isBetween(e%100,10,19)||isBetween(e%100,70,79)||isBetween(e%100,90,99)?e%1e6==0&&0!==e?"many":e%10!=2||isIn(e%100,[12,72,92])?e%10!=1||isIn(e%100,[11,71,91])?"other":"one":"two":"few"},21:function(e){return 0===e?"zero":1==e?"one":"other"},22:function(e){return isBetween(e,0,1)||isBetween(e,11,99)?"one":"other"},23:function(e){return isBetween(e%10,1,2)||e%20==0?"one":"other"},24:function(e){return isBetween(e,3,10)||isBetween(e,13,19)?"few":isIn(e,[2,12])?"two":isIn(e,[1,11])?"one":"other"}},i={af:3,ak:4,am:4,ar:1,asa:3,az:0,be:11,bem:3,bez:3,bg:3,bh:4,bm:0,bn:3,bo:0,br:20,brx:3,bs:11,ca:3,cgg:3,chr:3,cs:12,cy:17,da:3,de:3,dv:3,dz:0,ee:3,el:3,en:3,eo:3,es:3,et:3,eu:3,fa:0,ff:5,fi:3,fil:4,fo:3,fr:5,fur:3,fy:3,ga:8,gd:24,gl:3,gsw:3,gu:3,guw:4,gv:23,ha:3,haw:3,he:2,hi:4,hr:11,hu:0,id:0,ig:0,ii:0,is:3,it:3,iu:7,ja:0,jmc:3,jv:0,ka:0,kab:5,kaj:3,kcg:3,kde:0,kea:0,kk:3,kl:3,km:0,kn:0,ko:0,ksb:3,ksh:21,ku:3,kw:7,lag:18,lb:3,lg:3,ln:4,lo:0,lt:10,lv:6,mas:3,mg:4,mk:16,ml:3,mn:3,mo:9,mr:3,ms:0,mt:15,my:0,nah:3,naq:7,nb:3,nd:3,ne:3,nl:3,nn:3,no:3,nr:3,nso:4,ny:3,nyn:3,om:3,or:3,pa:3,pap:3,pl:13,ps:3,pt:3,rm:3,ro:9,rof:3,ru:11,rwk:3,sah:0,saq:3,se:7,seh:3,ses:0,sg:0,sh:11,shi:19,sk:12,sl:14,sma:7,smi:7,smj:7,smn:7,sms:7,sn:3,so:3,sq:3,sr:11,ss:3,ssy:3,st:3,sv:3,sw:3,syr:3,ta:3,te:3,teo:3,th:0,ti:4,tig:3,tk:3,tl:4,tn:3,to:0,tr:0,ts:3,tzm:22,uk:11,ur:3,ve:3,vi:0,vun:3,wa:4,wae:3,wo:0,xh:3,xog:3,yo:0,zh:0,zu:3}[e.replace(/-.*$/,"")];if(!(i in t)){console.warn("plural form unknown for ["+e+"]");return function(){return"other"}}return t[i]}(a));var d="["+r._pluralRules(l)+"]";0===l&&n+"[zero]"in i?e=i[n+"[zero]"][o]:1==l&&n+"[one]"in i?e=i[n+"[one]"][o]:2==l&&n+"[two]"in i?e=i[n+"[two]"][o]:n+d in i?e=i[n+d][o]:n+"[other]"in i&&(e=i[n+"[other]"][o]);return e};function getL10nData(e,t,n){var s=i[e];if(!s){console.warn("#"+e+" is undefined.");if(!n)return null;s=n}var a={};for(var r in s){var o=s[r];o=substArguments(o=substIndexes(o,t,e,r),t,e);a[r]=o}return a}function substIndexes(e,t,n,s){var a=/\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/.exec(e);if(!a||!a.length)return e;var o,l=a[1],d=a[2];t&&d in t?o=t[d]:d in i&&(o=i[d]);if(l in r){e=(0,r[l])(e,o,n,s)}return e}function substArguments(e,t,n){return e.replace(/\{\{\s*(.+?)\s*\}\}/g,(function(e,s){if(t&&s in t)return t[s];if(s in i)return i[s];console.log("argument {{"+s+"}} for #"+n+" is undefined.");return e}))}function translateElement(e){var i=function getL10nAttributes(e){if(!e)return{};var t=e.getAttribute("data-l10n-id"),i=e.getAttribute("data-l10n-args"),n={};if(i)try{n=JSON.parse(i)}catch(e){console.warn("could not parse arguments for #"+t)}return{id:t,args:n}}(e);if(i.id){var n=getL10nData(i.id,i.args);if(n){if(n[s]){if(0===function getChildElementCount(e){if(e.children)return e.children.length;if(void 0!==e.childElementCount)return e.childElementCount;for(var t=0,i=0;i<e.childNodes.length;i++)t+=1===e.nodeType?1:0;return t}(e))e[s]=n[s];else{for(var a=e.childNodes,r=!1,o=0,l=a.length;o<l;o++)if(3===a[o].nodeType&&/\S/.test(a[o].nodeValue))if(r)a[o].nodeValue="";else{a[o].nodeValue=n[s];r=!0}if(!r){var d=t.createTextNode(n[s]);e.prepend(d)}}delete n[s]}for(var h in n)e[h]=n[h]}else console.warn("#"+i.id+" is undefined.")}}return{get:function(e,t,i){var n,a=e.lastIndexOf("."),r=s;if(a>0){r=e.substring(a+1);e=e.substring(0,a)}i&&((n={})[r]=i);var o=getL10nData(e,t,n);return o&&r in o?o[r]:"{{"+e+"}}"},getData:function(){return i},getText:function(){return n},getLanguage:function(){return a},setLanguage:function(e,t){loadLocale(e,(function(){t&&t()}))},getDirection:function(){var e=a.split("-",1)[0];return["ar","he","fa","ps","ur"].indexOf(e)>=0?"rtl":"ltr"},translate:function translateFragment(e){for(var i=function getTranslatableChildren(e){return e?e.querySelectorAll("*[data-l10n-id]"):[]}(e=e||t.documentElement),n=i.length,s=0;s<n;s++)translateElement(i[s]);translateElement(e)},getReadyState:function(){return o},ready:function(i){i&&("complete"==o||"interactive"==o?e.setTimeout((function(){i()})):t.addEventListener&&t.addEventListener("localized",(function once(){t.removeEventListener("localized",once);i()})))}}}(window,document)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.GenericScripting=void 0;t.docProperties=async function docProperties(e){const t="".split("#")[0];let{info:i,metadata:s,contentDispositionFilename:a,contentLength:r}=await e.getMetadata();if(!r){const{length:t}=await e.getDownloadInfo();r=t}return{...i,baseURL:t,filesize:r,filename:a||(0,n.getPdfFilenameFromUrl)(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:e.numPages,URL:""}};var n=i(4);t.GenericScripting=class GenericScripting{constructor(e){this._ready=(0,n.loadScript)(e,!0).then((()=>window.pdfjsSandbox.QuickJSSandbox()))}async createSandbox(e){(await this._ready).create(e)}async dispatchEventInSandbox(e){const t=await this._ready;setTimeout((()=>t.dispatchEvent(e)),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.PDFPrintService=void 0;var n=i(4),s=i(2),a=i(48);let r=null,o=null,l=null;class PDFPrintService{constructor(e,t,i,n,s=null,a=null,r){this.pdfDocument=e;this.pagesOverview=t;this.printContainer=i;this._printResolution=n||150;this._optionalContentConfigPromise=s||e.getOptionalContentConfig();this._printAnnotationStoragePromise=a||Promise.resolve();this.l10n=r;this.currentPage=-1;this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const e=document.querySelector("body");e.setAttribute("data-pdfjsprinting",!0);const{width:t,height:i}=this.pagesOverview[0];this.pagesOverview.every((e=>e.width===t&&e.height===i))||console.warn("Not all pages have the same size. The printed result may be incorrect!");this.pageStyleSheet=document.createElement("style");this.pageStyleSheet.textContent=`@page { size: ${t}pt ${i}pt;}`;e.append(this.pageStyleSheet)}destroy(){if(r!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting");if(this.pageStyleSheet){this.pageStyleSheet.remove();this.pageStyleSheet=null}this.scratchCanvas.width=this.scratchCanvas.height=0;this.scratchCanvas=null;r=null;ensureOverlay().then((function(){l.active===o&&l.close(o)}))}renderPages(){if(this.pdfDocument.isPureXfa){(0,a.getXfaHtmlForPrinting)(this.printContainer,this.pdfDocument);return Promise.resolve()}const e=this.pagesOverview.length,renderNextPage=(t,i)=>{this.throwIfInactive();if(++this.currentPage>=e){renderProgress(e,e,this.l10n);t();return}const s=this.currentPage;renderProgress(s,e,this.l10n);(function renderPage(e,t,i,s,a,o,l){const d=r.scratchCanvas,h=a/n.PixelsPerInch.PDF;d.width=Math.floor(s.width*h);d.height=Math.floor(s.height*h);const c=d.getContext("2d");c.save();c.fillStyle="rgb(255, 255, 255)";c.fillRect(0,0,d.width,d.height);c.restore();return Promise.all([t.getPage(i),l]).then((function([e,t]){const i={canvasContext:c,transform:[h,0,0,h,0,0],viewport:e.getViewport({scale:1,rotation:s.rotation}),intent:"print",annotationMode:n.AnnotationMode.ENABLE_STORAGE,optionalContentConfigPromise:o,printAnnotationStorage:t};return e.render(i).promise}))})(0,this.pdfDocument,s+1,this.pagesOverview[s],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){renderNextPage(t,i)}),i)};return new Promise(renderNextPage)}useRenderedPage(){this.throwIfInactive();const e=document.createElement("img"),t=this.scratchCanvas;"toBlob"in t?t.toBlob((function(t){e.src=URL.createObjectURL(t)})):e.src=t.toDataURL();const i=document.createElement("div");i.className="printedPage";i.append(e);this.printContainer.append(i);return new Promise((function(t,i){e.onload=t;e.onerror=i}))}performPrint(){this.throwIfInactive();return new Promise((e=>{setTimeout((()=>{if(this.active){d.call(window);setTimeout(e,20)}else e()}),0)}))}get active(){return this===r}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}t.PDFPrintService=PDFPrintService;const d=window.print;window.print=function(){if(r)console.warn("Ignored window.print() because of a pending print job.");else{ensureOverlay().then((function(){r&&l.open(o)}));try{dispatchEvent("beforeprint")}finally{if(!r){console.error("Expected print service to be initialized.");ensureOverlay().then((function(){l.active===o&&l.close(o)}));return}const e=r;r.renderPages().then((function(){return e.performPrint()})).catch((function(){})).then((function(){e.active&&abort()}))}}};function dispatchEvent(e){const t=new CustomEvent(e,{bubbles:!1,cancelable:!1,detail:"custom"});window.dispatchEvent(t)}function abort(){if(r){r.destroy();dispatchEvent("afterprint")}}function renderProgress(e,t,i){o||=document.getElementById("printServiceDialog");const n=Math.round(100*e/t),s=o.querySelector("progress"),a=o.querySelector(".relative-progress");s.value=n;i.get("print_progress_percent",{progress:n}).then((e=>{a.textContent=e}))}window.addEventListener("keydown",(function(e){if(80===e.keyCode&&(e.ctrlKey||e.metaKey)&&!e.altKey&&(!e.shiftKey||window.chrome||window.opera)){window.print();e.preventDefault();e.stopImmediatePropagation()}}),!0);if("onbeforeprint"in window){const stopPropagationIfNeeded=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",stopPropagationIfNeeded);window.addEventListener("afterprint",stopPropagationIfNeeded)}let h;function ensureOverlay(){if(!h){l=s.PDFViewerApplication.overlayManager;if(!l)throw new Error("The overlay manager has not yet been initialized.");o||=document.getElementById("printServiceDialog");h=l.register(o,!0);document.getElementById("printCancel").onclick=abort;o.addEventListener("close",abort)}return h}s.PDFPrintServiceFactory.instance={supportsPrinting:!0,createPrintService(e,t,i,n,s,a,o){if(r)throw new Error("The print service is created and active.");r=new PDFPrintService(e,t,i,n,s,a,o);return r}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0});t.getXfaHtmlForPrinting=function getXfaHtmlForPrinting(e,t){const i=t.allXfaHtml,r=new s.SimpleLinkService,o=Math.round(100*n.PixelsPerInch.PDF_TO_CSS_UNITS)/100;for(const s of i.children){const i=document.createElement("div");i.className="xfaPrintedPage";e.append(i);const l=new a.XfaLayerBuilder({pageDiv:i,pdfPage:null,annotationStorage:t.annotationStorage,linkService:r,xfaHtml:s}),d=(0,n.getXfaPageViewport)(s,{scale:o});l.render(d,"print")}};var n=i(4),s=i(7),a=i(38)}],t={};function __webpack_require__(i){var n=t[i];if(void 0!==n)return n.exports;var s=t[i]={exports:{}};e[i](s,s.exports,__webpack_require__);return s.exports}var i={};(()=>{var e=i;Object.defineProperty(e,"__esModule",{value:!0});Object.defineProperty(e,"PDFViewerApplication",{enumerable:!0,get:function(){return a.PDFViewerApplication}});e.PDFViewerApplicationConstants=void 0;Object.defineProperty(e,"PDFViewerApplicationOptions",{enumerable:!0,get:function(){return n.AppOptions}});__webpack_require__(1);__webpack_require__(47);var t=__webpack_require__(3),n=__webpack_require__(5),s=__webpack_require__(7),a=__webpack_require__(2);const r={LinkTarget:s.LinkTarget,RenderingStates:t.RenderingStates,ScrollMode:t.ScrollMode,SpreadMode:t.SpreadMode};e.PDFViewerApplicationConstants=r;window.PDFViewerApplication=a.PDFViewerApplication;window.PDFViewerApplicationConstants=r;window.PDFViewerApplicationOptions=n.AppOptions;function webViewerLoad(){const e=function getViewerConfiguration(){return{appContainer:document.body,mainContainer:document.getElementById("viewerContainer"),viewerContainer:document.getElementById("viewer"),toolbar:{container:document.getElementById("toolbarViewer"),numPages:document.getElementById("numPages"),pageNumber:document.getElementById("pageNumber"),scaleSelect:document.getElementById("scaleSelect"),customScaleOption:document.getElementById("customScaleOption"),previous:document.getElementById("previous"),next:document.getElementById("next"),zoomIn:document.getElementById("zoomIn"),zoomOut:document.getElementById("zoomOut"),viewFind:document.getElementById("viewFind"),openFile:document.getElementById("openFile"),print:document.getElementById("print"),editorFreeTextButton:document.getElementById("editorFreeText"),editorFreeTextParamsToolbar:document.getElementById("editorFreeTextParamsToolbar"),editorInkButton:document.getElementById("editorInk"),editorInkParamsToolbar:document.getElementById("editorInkParamsToolbar"),editorStampButton:document.getElementById("editorStamp"),editorStampParamsToolbar:document.getElementById("editorStampParamsToolbar"),download:document.getElementById("download")},secondaryToolbar:{toolbar:document.getElementById("secondaryToolbar"),toggleButton:document.getElementById("secondaryToolbarToggle"),presentationModeButton:document.getElementById("presentationMode"),openFileButton:document.getElementById("secondaryOpenFile"),printButton:document.getElementById("secondaryPrint"),downloadButton:document.getElementById("secondaryDownload"),viewBookmarkButton:document.getElementById("viewBookmark"),firstPageButton:document.getElementById("firstPage"),lastPageButton:document.getElementById("lastPage"),pageRotateCwButton:document.getElementById("pageRotateCw"),pageRotateCcwButton:document.getElementById("pageRotateCcw"),cursorSelectToolButton:document.getElementById("cursorSelectTool"),cursorHandToolButton:document.getElementById("cursorHandTool"),scrollPageButton:document.getElementById("scrollPage"),scrollVerticalButton:document.getElementById("scrollVertical"),scrollHorizontalButton:document.getElementById("scrollHorizontal"),scrollWrappedButton:document.getElementById("scrollWrapped"),spreadNoneButton:document.getElementById("spreadNone"),spreadOddButton:document.getElementById("spreadOdd"),spreadEvenButton:document.getElementById("spreadEven"),documentPropertiesButton:document.getElementById("documentProperties")},sidebar:{outerContainer:document.getElementById("outerContainer"),sidebarContainer:document.getElementById("sidebarContainer"),toggleButton:document.getElementById("sidebarToggle"),resizer:document.getElementById("sidebarResizer"),thumbnailButton:document.getElementById("viewThumbnail"),outlineButton:document.getElementById("viewOutline"),attachmentsButton:document.getElementById("viewAttachments"),layersButton:document.getElementById("viewLayers"),thumbnailView:document.getElementById("thumbnailView"),outlineView:document.getElementById("outlineView"),attachmentsView:document.getElementById("attachmentsView"),layersView:document.getElementById("layersView"),outlineOptionsContainer:document.getElementById("outlineOptionsContainer"),currentOutlineItemButton:document.getElementById("currentOutlineItem")},findBar:{bar:document.getElementById("findbar"),toggleButton:document.getElementById("viewFind"),findField:document.getElementById("findInput"),highlightAllCheckbox:document.getElementById("findHighlightAll"),caseSensitiveCheckbox:document.getElementById("findMatchCase"),matchDiacriticsCheckbox:document.getElementById("findMatchDiacritics"),entireWordCheckbox:document.getElementById("findEntireWord"),findMsg:document.getElementById("findMsg"),findResultsCount:document.getElementById("findResultsCount"),findPreviousButton:document.getElementById("findPrevious"),findNextButton:document.getElementById("findNext")},passwordOverlay:{dialog:document.getElementById("passwordDialog"),label:document.getElementById("passwordText"),input:document.getElementById("password"),submitButton:document.getElementById("passwordSubmit"),cancelButton:document.getElementById("passwordCancel")},documentProperties:{dialog:document.getElementById("documentPropertiesDialog"),closeButton:document.getElementById("documentPropertiesClose"),fields:{fileName:document.getElementById("fileNameField"),fileSize:document.getElementById("fileSizeField"),title:document.getElementById("titleField"),author:document.getElementById("authorField"),subject:document.getElementById("subjectField"),keywords:document.getElementById("keywordsField"),creationDate:document.getElementById("creationDateField"),modificationDate:document.getElementById("modificationDateField"),creator:document.getElementById("creatorField"),producer:document.getElementById("producerField"),version:document.getElementById("versionField"),pageCount:document.getElementById("pageCountField"),pageSize:document.getElementById("pageSizeField"),linearized:document.getElementById("linearizedField")}},altTextDialog:{dialog:document.getElementById("altTextDialog"),optionDescription:document.getElementById("descriptionButton"),optionDecorative:document.getElementById("decorativeButton"),textarea:document.getElementById("descriptionTextarea"),cancelButton:document.getElementById("altTextCancel"),saveButton:document.getElementById("altTextSave")},annotationEditorParams:{editorFreeTextFontSize:document.getElementById("editorFreeTextFontSize"),editorFreeTextColor:document.getElementById("editorFreeTextColor"),editorInkColor:document.getElementById("editorInkColor"),editorInkThickness:document.getElementById("editorInkThickness"),editorInkOpacity:document.getElementById("editorInkOpacity"),editorStampAddImage:document.getElementById("editorStampAddImage")},printContainer:document.getElementById("printContainer"),openFileInput:document.getElementById("fileInput"),debuggerScriptPath:"./debugger.js"}}(),t=new CustomEvent("webviewerloaded",{bubbles:!0,cancelable:!0,detail:{source:window}});try{parent.document.dispatchEvent(t)}catch(e){console.error(`webviewerloaded: ${e}`);document.dispatchEvent(t)}a.PDFViewerApplication.run(e)}document.blockUnblockOnload?.(!0);"interactive"===document.readyState||"complete"===document.readyState?webViewerLoad():document.addEventListener("DOMContentLoaded",webViewerLoad,!0)})()})();