@pdfslick/react 1.5.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/umd/index.js CHANGED
@@ -1,4 +1,4 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).PDFSlickReact={},e.React,e.jsxRuntime,e.ReactDOM)}(this,(function(exports,React,jsxRuntime,reactDom){"use strict";var _documentCurrentScript="undefined"!=typeof document?document.currentScript:null;const createStoreImpl=e=>{let t;const i=new Set,n=(e,n)=>{const s="function"==typeof e?e(t):e;if(!Object.is(s,t)){const e=t;t=(null!=n?n:"object"!=typeof s||null===s)?s:Object.assign({},t,s),i.forEach((i=>i(t,e)))}},s=()=>t,r={setState:n,getState:s,getInitialState:()=>a,subscribe:e=>(i.add(e),()=>i.delete(e)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},a=t=e(n,s,r);return r},createStore$1=e=>e?createStoreImpl(e):createStoreImpl;function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function getAugmentedNamespace(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var i=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})})),i}var withSelector={exports:{}},withSelector_production_min={},shim={exports:{}},useSyncExternalStoreShim_production_min={},hasRequiredUseSyncExternalStoreShim_production_min,hasRequiredShim,hasRequiredWithSelector_production_min;function requireUseSyncExternalStoreShim_production_min(){if(hasRequiredUseSyncExternalStoreShim_production_min)return useSyncExternalStoreShim_production_min;hasRequiredUseSyncExternalStoreShim_production_min=1;var e=React;var t="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},i=e.useState,n=e.useEffect,s=e.useLayoutEffect,r=e.useDebugValue;function a(e){var i=e.getSnapshot;e=e.value;try{var n=i();return!t(e,n)}catch(e){return!0}}var o="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var o=t(),l=i({inst:{value:o,getSnapshot:t}}),h=l[0].inst,c=l[1];return s((function(){h.value=o,h.getSnapshot=t,a(h)&&c({inst:h})}),[e,o,t]),n((function(){return a(h)&&c({inst:h}),e((function(){a(h)&&c({inst:h})}))}),[e]),r(o),o};return useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:o,useSyncExternalStoreShim_production_min}function requireShim(){return hasRequiredShim||(hasRequiredShim=1,shim.exports=requireUseSyncExternalStoreShim_production_min()),shim.exports}
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("react"),require("react/jsx-runtime"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react/jsx-runtime","react-dom"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickReact={},t.React,t.jsxRuntime,t.ReactDOM)}(this,(function(t,e,i,s){"use strict";var n="undefined"!=typeof document?document.currentScript:null;const r=t=>{let e;const i=new Set,s=(t,s)=>{const n="function"==typeof t?t(e):t;if(!Object.is(n,e)){const t=e;e=(null!=s?s:"object"!=typeof n||null===n)?n:Object.assign({},e,n),i.forEach((i=>i(e,t)))}},n=()=>e,r={setState:s,getState:n,getInitialState:()=>a,subscribe:t=>(i.add(t),()=>i.delete(t)),destroy:()=>{console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),i.clear()}},a=e=t(s,n,r);return r};function a(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return l||(l=1,u.exports=function(){if(o)return p;o=1;var t=e,i="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=t.useState,n=t.useEffect,r=t.useLayoutEffect,a=t.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var s=e();return!i(t,s)}catch(t){return!0}}var h="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var i=e(),o=s({inst:{value:i,getSnapshot:e}}),h=o[0].inst,d=o[1];return r((function(){h.value=i,h.getSnapshot=e,l(h)&&d({inst:h})}),[t,i,e]),n((function(){return l(h)&&d({inst:h}),t((function(){l(h)&&d({inst:h})}))}),[t]),a(i),i};return p.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:h,p}()),u.exports}
2
2
  /**
3
3
  * @license React
4
4
  * use-sync-external-store-shim/with-selector.production.min.js
@@ -7,12 +7,12 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */function requireWithSelector_production_min(){if(hasRequiredWithSelector_production_min)return withSelector_production_min;hasRequiredWithSelector_production_min=1;var e=React,t=requireShim();var i="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},n=t.useSyncExternalStore,s=e.useRef,r=e.useEffect,a=e.useMemo,o=e.useDebugValue;return withSelector_production_min.useSyncExternalStoreWithSelector=function(e,t,l,h,c){var d=s(null);if(null===d.current){var u={hasValue:!1,value:null};d.current=u}else u=d.current;d=a((function(){function e(e){if(!r){if(r=!0,n=e,e=h(e),void 0!==c&&u.hasValue){var t=u.value;if(c(t,e))return s=t}return s=e}if(t=s,i(n,e))return t;var a=h(e);return void 0!==c&&c(t,a)?t:(n=e,s=a)}var n,s,r=!1,a=void 0===l?null:l;return[function(){return e(t())},null===a?void 0:function(){return e(a())}]}),[t,l,h,c]);var p=n(e,d[0],d[1]);return r((function(){u.hasValue=!0,u.value=p}),[p]),o(p),p},withSelector_production_min}withSelector.exports=requireWithSelector_production_min();var withSelectorExports=withSelector.exports,useSyncExternalStoreExports=getDefaultExportFromCjs(withSelectorExports);const{useDebugValue:useDebugValue}=React,{useSyncExternalStoreWithSelector:useSyncExternalStoreWithSelector}=useSyncExternalStoreExports;let didWarnAboutEqualityFn=!1;const identity=e=>e;function useStore(e,t=identity,i){i&&!didWarnAboutEqualityFn&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),didWarnAboutEqualityFn=!0);const n=useSyncExternalStoreWithSelector(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,i);return useDebugValue(n),n}function commonjsRequire(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var pdf={exports:{}},_nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({__proto__:null,default:_nodeResolve_empty}),require$$5=getAugmentedNamespace(_nodeResolve_empty$1);
10
+ */d.exports=function(){if(h)return c;h=1;var t=e,i=g(),s="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},n=i.useSyncExternalStore,r=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,h,d){var c=r(null);if(null===c.current){var u={hasValue:!1,value:null};c.current=u}else u=c.current;c=o((function(){function t(t){if(!a){if(a=!0,n=t,t=h(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return r=e}return r=t}if(e=r,s(n,t))return e;var i=h(t);return void 0!==d&&d(e,i)?e:(n=t,r=i)}var n,r,a=!1,o=void 0===i?null:i;return[function(){return t(e())},null===o?void 0:function(){return t(o())}]}),[e,i,h,d]);var p=n(t,c[0],c[1]);return a((function(){u.hasValue=!0,u.value=p}),[p]),l(p),p},c}();var f=a(d.exports);const{useDebugValue:m}=e,{useSyncExternalStoreWithSelector:b}=f;let v=!1;const w=t=>t;
11
11
  /**
12
12
  * @licstart The following is the entire license notice for the
13
13
  * JavaScript code in this page
14
14
  *
15
- * Copyright 2023 Mozilla Foundation
15
+ * Copyright 2024 Mozilla Foundation
16
16
  *
17
17
  * Licensed under the Apache License, Version 2.0 (the "License");
18
18
  * you may not use this file except in compliance with the License.
@@ -28,27 +28,4 @@
28
28
  *
29
29
  * @licend The above is the entire license notice for the
30
30
  * JavaScript code in this page
31
- */
32
- (function(module,exports){var root,factory;root=globalThis,factory=()=>(()=>{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(e,t){e||a(t)},t.bytesToString=h,t.createValidAbsoluteUrl=function(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=p(e)}catch{}}const n=t?new URL(e,t):new URL(e);if(function(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(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(){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 h(e)},t.getVerbosityLevel=function(){return s},t.info=function(e){s>=n.INFOS&&console.log(`Info: ${e}`)},t.isArrayBuffer=function(e){return"object"==typeof e&&void 0!==e?.byteLength},t.isArrayEqual=function(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(e){return g||(g=/([\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,f=new Map([["ſt","ſt"]])),e.replaceAll(g,((e,t,i)=>t?t.normalize("NFKC"):f.get(i)))},t.objectFromMap=function(e){const t=Object.create(null);for(const[i,n]of e)t[i]=n;return t},t.objectSize=function(e){return Object.keys(e).length},t.setVerbosityLevel=function(e){Number.isInteger(e)&&(s=e)},t.shadow=o,t.string32=function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)},t.stringToBytes=c,t.stringToPDFString=function(e){if(e[0]>="ï"){let t;if("þ"===e[0]&&"ÿ"===e[1]?t="utf-16be":"ÿ"===e[0]&&"þ"===e[1]?t="utf-16le":"ï"===e[0]&&"»"===e[1]&&"¿"===e[2]&&(t="utf-8"),t)try{const i=new TextDecoder(t,{fatal:!0}),n=c(e);return i.decode(n)}catch(e){r(`stringToPDFString: "${e}".`)}}const t=[];for(let i=0,n=e.length;i<n;i++){const n=u[e.charCodeAt(i)];t.push(n?String.fromCharCode(n):e.charAt(i))}return t.join("")},t.stringToUTF8String=p,t.unreachable=a,t.utf8StringToString=function(e){return unescape(encodeURIComponent(e))},t.warn=r;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 r(e){s>=n.WARNINGS&&console.log(`Warning: ${e}`)}function a(e){throw new Error(e)}function o(e,t,i,n=!1){return Object.defineProperty(e,t,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}const l=function(){function e(t,i){this.constructor===e&&a("Cannot initialize BaseException."),this.message=t,this.name=i}return e.prototype=new Error,e.constructor=e,e}();function h(e){"object"==typeof e&&void 0!==e?.length||a("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 r=Math.min(s+i,t),a=e.subarray(s,r);n.push(String.fromCharCode.apply(null,a))}return n.join("")}function c(e){"string"!=typeof e&&a("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.BaseException=l,t.PasswordException=class extends l{constructor(e,t){super(e,"PasswordException"),this.code=t}},t.UnknownErrorException=class extends l{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}},t.InvalidPDFException=class extends l{constructor(e){super(e,"InvalidPDFException")}},t.MissingPDFException=class extends l{constructor(e){super(e,"MissingPDFException")}},t.UnexpectedResponseException=class extends l{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}},t.FormatError=class extends l{constructor(e){super(e,"FormatError")}},t.AbortException=class extends l{constructor(e){super(e,"AbortException")}},t.FeatureTest=class{static get isLittleEndian(){return o(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return o(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return o(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get platform(){return"undefined"==typeof navigator?o(this,"platform",{isWin:!1,isMac:!1}):o(this,"platform",{isWin:navigator.platform.includes("Win"),isMac:navigator.platform.includes("Mac")})}static get isCSSRoundSupported(){return o(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}};const d=[...Array(256).keys()].map((e=>e.toString(16).padStart(2,"0")));t.Util=class{static makeHexColor(e,t,i){return`#${d[e]}${d[t]}${d[i]}`}static scaleMinMax(e,t){let i;e[0]?(e[0]<0&&(i=t[0],t[0]=t[1],t[1]=i),t[0]*=e[0],t[1]*=e[0],e[3]<0&&(i=t[2],t[2]=t[3],t[3]=i),t[2]*=e[3],t[3]*=e[3]):(i=t[0],t[0]=t[2],t[2]=i,i=t[1],t[1]=t[3],t[3]=i,e[1]<0&&(i=t[2],t[2]=t[3],t[3]=i),t[2]*=e[1],t[3]*=e[1],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),r=this.applyTransform([e[2],e[1]],t);return[Math.min(i[0],n[0],s[0],r[0]),Math.min(i[1],n[1],s[1],r[1]),Math.max(i[0],n[0],s[0],r[0]),Math.max(i[1],n[1],s[1],r[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],r=e[2]*t[1]+e[3]*t[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-s*n))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){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])),r=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return s>r?null:[i,s,n,r]}static bezierBoundingBox(e,t,i,n,s,r,a,o){const l=[],h=[[],[]];let c,d,u,p,g,f,m,_;for(let h=0;h<2;++h)if(0===h?(d=6*e-12*i+6*s,c=-3*e+9*i-9*s+3*a,u=3*i-3*e):(d=6*t-12*n+6*r,c=-3*t+9*n-9*r+3*o,u=3*n-3*t),Math.abs(c)<1e-12){if(Math.abs(d)<1e-12)continue;p=-u/d,0<p&&p<1&&l.push(p)}else m=d*d-4*u*c,_=Math.sqrt(m),m<0||(g=(-d+_)/(2*c),0<g&&g<1&&l.push(g),f=(-d-_)/(2*c),0<f&&f<1&&l.push(f));let v,b=l.length;const y=b;for(;b--;)p=l[b],v=1-p,h[0][b]=v*v*v*e+3*v*v*p*i+3*v*p*p*s+p*p*p*a,h[1][b]=v*v*v*t+3*v*v*p*n+3*v*p*p*r+p*p*p*o;return h[0][y]=e,h[1][y]=t,h[0][y+1]=a,h[1][y+1]=o,h[0].length=h[1].length=y+2,[Math.min(...h[0]),Math.min(...h[1]),Math.max(...h[0]),Math.max(...h[1])]}};const u=[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 p(e){return decodeURIComponent(escape(e))}t.PromiseCapability=class{#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 g=null,f=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;function getDocument(e){if("string"==typeof e||e instanceof URL?e={url:e}:(0,_util.isArrayBuffer)(e)&&(e={data:e}),"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,r=e.httpHeaders||null,a=!0===e.withCredentials,o=e.password??null,l=e.range instanceof PDFDataRangeTransport?e.range:null,h=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:DEFAULT_RANGE_CHUNK_SIZE;let c=e.worker instanceof PDFWorker?e.worker:null;const d=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,_=e.StandardFontDataFactory||DefaultStandardFontDataFactory,v=!0!==e.stopAtErrors,b=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,y=!1!==e.isEvalSupported,S="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!_util.isNodeJS,P=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,A="boolean"==typeof e.disableFontFace?e.disableFontFace:_util.isNodeJS,w=!0===e.fontExtraProperties,E=!0===e.enableXfa,x=e.ownerDocument||globalThis.document,C=!0===e.disableRange,M=!0===e.disableStream,T=!0===e.disableAutoFetch,D=!0===e.pdfBug,F=l?l.length:e.length??NaN,k="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!_util.isNodeJS&&!A,L="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:f===_display_utils.DOMCMapReaderFactory&&_===_display_utils.DOMStandardFontDataFactory&&p&&m&&(0,_display_utils.isValidFetchUrl)(p,document.baseURI)&&(0,_display_utils.isValidFetchUrl)(m,document.baseURI),R=e.canvasFactory||new DefaultCanvasFactory({ownerDocument:x}),I=e.filterFactory||new DefaultFilterFactory({docId:i,ownerDocument:x});(0,_util.setVerbosityLevel)(d);const O={canvasFactory:R,filterFactory:I};if(L||(O.cMapReaderFactory=new f({baseUrl:p,isCompressed:g}),O.standardFontDataFactory=new _({baseUrl:m})),!c){const e={verbosity:d,port:_worker_options.GlobalWorkerOptions.workerPort};c=e.port?PDFWorker.fromPort(e):new PDFWorker(e),t._worker=c}const N={docId:i,apiVersion:"3.11.174",data:s,password:o,disableAutoFetch:T,rangeChunkSize:h,length:F,docBaseUrl:u,enableXfa:E,evaluatorOptions:{maxImageSize:b,disableFontFace:A,ignoreErrors:v,isEvalSupported:y,isOffscreenCanvasSupported:S,canvasMaxAreaInBytes:P,fontExtraProperties:w,useSystemFonts:k,cMapUrl:L?p:null,standardFontDataUrl:L?m:null}},B={ignoreErrors:v,isEvalSupported:y,disableFontFace:A,fontExtraProperties:w,enableXfa:E,ownerDocument:x,disableAutoFetch:T,pdfBug:D,styleElement:null};return c.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");const e=_fetchDocument(c,N),o=new Promise((function(e){let t;var i;l?t=new _transport_stream.PDFDataTransportStream({length:F,initialData:l.initialData,progressiveDone:l.progressiveDone,contentDispositionFilename:l.contentDispositionFilename,disableRange:C,disableStream:M},l):s||(i={url:n,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:C,disableStream:M},t=_util.isNodeJS?new _displayNode_stream.PDFNodeStream(i):(0,_display_utils.isValidFetchUrl)(i.url)?new _displayFetch_stream.PDFFetchStream(i):new _displayNetwork.PDFNetworkStream(i)),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,c.port),r=new WorkerTransport(s,t,n,B,O);t._transport=r,s.send("Ready",null)}))})).catch(t._capability.reject),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.")}exports.DefaultStandardFontDataFactory=DefaultStandardFontDataFactory;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){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,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."),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:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,n,h);this.#n=!1,this.#s(),a||(a=this._transport.getOptionalContentConfig());let d=this._intentStates.get(c.cacheKey);d||(d=Object.create(null),this._intentStates.set(c.cacheKey,d)),d.streamReaderCancelTimeout&&(clearTimeout(d.streamReaderCancelTimeout),d.streamReaderCancelTimeout=null);const u=!!(c.renderingIntent&_util.RenderingIntentFlag.PRINT);d.displayReadyCapability||(d.displayReadyCapability=new _util.PromiseCapability,d.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const p=e=>{d.renderTasks.delete(g),(this._maybeCleanupAfterRender||u)&&(this.#n=!0),this.#r(!u),e?(g.capability.reject(e),this._abortOperatorList({intentState:d,reason:e instanceof Error?e:new Error(e)})):g.capability.resolve(),this._stats?.timeEnd("Rendering"),this._stats?.timeEnd("Overall")},g=new InternalRenderTask({callback:p,params:{canvasContext:e,viewport:t,transform:s,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:d.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!u,pdfBug:this._pdfBug,pageColors:l});(d.renderTasks||=new Set).add(g);const f=g.task;return Promise.all([d.displayReadyCapability.promise,a]).then((([e,t])=>{this.destroyed?p():(this._stats?.time("Rendering"),g.initializeGraphics({transparency:e,optionalContentConfig:t}),g.operatorListChanged())})).catch(p),f}getOperatorList({intent:e="display",annotationMode:t=_util.AnnotationMode.ENABLE,printAnnotationStorage:i=null}={}){const n=this._transport.getRenderingIntent(e,t,i,!0);let s,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(s=Object.create(null),s.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(s))},r.opListReadCapability=new _util.PromiseCapability,(r.renderTasks||=new Set).add(s),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.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 t(){n.read().then((function({value:i,done:n}){n?e(s):(Object.assign(s.styles,i.styles),s.items.push(...i.items),t())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const i of t.renderTasks)e.push(i.completed),i.cancel();return this.objs.clear(),this.#n=!1,this.#s(),Promise.all(e)}cleanup(e=!1){this.#n=!0;const t=this.#r(!1);return e&&t&&(this._stats&&=new _display_utils.StatTimer),t}#r(e=!1){if(this.#s(),!this.#n||this.destroyed)return!1;if(e)return this.#i=setTimeout((()=>{this.#i=null,this.#r(!1)}),DELAYED_CLEANUP_TIMEOUT),!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#n=!1,!0}#s(){this.#i&&(clearTimeout(this.#i),this.#i=null)}_startRenderPage(e,t){const i=this._intentStates.get(t);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.#r(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:i}){const{map:n,transfers:s}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:n},s).getReader(),a=this._intentStates.get(t);a.streamReader=r;const o=()=>{r.read().then((({value:e,done:t})=>{t?a.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,a),o())}),(e=>{if(a.streamReader=null,!this._transport.destroyed){if(a.operatorList){a.operatorList.lastChunk=!0;for(const e of a.renderTasks)e.operatorListChanged();this.#r(!0)}if(a.displayReadyCapability)a.displayReadyCapability.reject(e);else{if(!a.opListReadCapability)throw e;a.opListReadCapability.reject(e)}}}))};o()}_abortOperatorList({intentState:e,reason:t,force:i=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!i){if(e.renderTasks.size>0)return;if(t instanceof _display_utils.RenderingCancelledException){let i=RENDERING_CANCELLED_TIMEOUT;return t.extraDelay>0&&t.extraDelay<1e3&&(i+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),i))}}if(e.streamReader.cancel(new _util.AbortException(t.message)).catch((()=>{})),e.streamReader=null,!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{#a=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.#a)e.call(this,i)}))}addEventListener(e,t){this.#a.add(t)}removeEventListener(e,t){this.#a.delete(t)}terminate(){this.#a.clear()}}exports.LoopbackPort=LoopbackPort;const PDFWorkerUtil={isWorkerDisabled:!1,fallbackWorkerSrc:null,fakeWorkerId:0};if(exports.PDFWorkerUtil=PDFWorkerUtil,_util.isNodeJS&&"function"==typeof commonjsRequire)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{if(i=new URL(e),!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)()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=i,this._readyCapability=new _util.PromiseCapability,this._port=null,this._webWorker=null,this._messageHandler=null,t){if(PDFWorker.#l?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");return(PDFWorker.#l||=new WeakMap).set(t,this),void this._initializeFromPort(t)}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),n=()=>{t.removeEventListener("error",s),i.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},s=()=>{this._webWorker||n()};t.addEventListener("error",s),i.on("test",(e=>{t.removeEventListener("error",s),this.destroyed?n():e?(this._messageHandler=i,this._port=t,this._webWorker=t,this._readyCapability.resolve(),i.send("configure",{verbosity:this.verbosity})):(this._setupFakeWorker(),i.destroy(),t.terminate())})),i.on("ready",(e=>{if(t.removeEventListener("error",s),this.destroyed)n();else try{r()}catch{this._setupFakeWorker()}}));const r=()=>{const e=new Uint8Array;i.send("test",e,[e.buffer])};return void r()}catch{(0,_util.info)("The worker has been disabled.")}}this._setupFakeWorker()}_setupFakeWorker(){PDFWorkerUtil.isWorkerDisabled||((0,_util.warn)("Setting up fake worker."),PDFWorkerUtil.isWorkerDisabled=!0),PDFWorker._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));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,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),PDFWorker.#l?.delete(this._port),this._port=null,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)return _util.isNodeJS||(0,_display_utils.deprecated)('No "GlobalWorkerOptions.workerSrc" specified.'),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 commonjsRequire){const worker=eval("require")(this.workerSrc);return worker.WorkerMessageHandler}return await(0,_display_utils.loadScript)(this.workerSrc),window.pdfjsWorker.WorkerMessageHandler};return(0,_util.shadow)(this,"_setupFakeWorkerGlobal",loader())}}exports.PDFWorker=PDFWorker;class WorkerTransport{#h=new Map;#c=new Map;#d=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.#h.get(e);if(i)return i;const n=this.messageHandler.sendWithPromise(e,t);return this.#h.set(e,n),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,r=_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,r=(s&_util.RenderingIntentFlag.PRINT&&i instanceof _annotation_storage.PrintAnnotationStorage?i:this.annotationStorage).serializable;break;default:(0,_util.warn)(`getRenderingIntent - invalid annotationMode: ${t}`)}return n&&(s+=_util.RenderingIntentFlag.OPLIST),{renderingIntent:s,cacheKey:`${s}_${r.hash}`,annotationStorageSerializable:r}}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.#c.values())e.push(t._destroy());this.#c.clear(),this.#d.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#h.clear(),this.filterFactory.destroy(),this._networkStream?.cancelAllRequests(new _util.AbortException("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()}),this.destroyCapability.reject),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}){i?t.close():((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;return n.headersReady.then((()=>{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),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);i?(t.onPull=()=>{i.read().then((function({value:e,done:i}){i?t.close():((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}))}):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=>{if(this.#u=new _util.PromiseCapability,t.onPassword){const i=e=>{e instanceof Error?this.#u.reject(e):this.#u.resolve({password:e})};try{t.onPassword(i,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=>{this.destroyed||this.#c.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 r=s.pdfBug&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,a=new _font_loader.FontFaceObject(n,{isEvalSupported:s.isEvalSupported,disableFontFace:s.disableFontFace,ignoreErrors:s.ignoreErrors,inspectFont:r});this.fontLoader.bind(a).catch((i=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!s.fontExtraProperties&&a.data&&(a.data=null),this.commonObjs.resolve(t,a)}));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.#c.get(t);if(!s.objs.has(e))switch(i){case"Image":if(s.objs.resolve(e,n),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.#d.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);return this.#c.set(t,i),i}));return this.#d.set(t,n),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.#h.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})));return this.#h.set(e,i),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.#c.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#h.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);return i.capability.promise.then((()=>t(i.data))),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#_=new WeakSet;constructor({callback:e,params:t,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=s,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"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.#_.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.#_.add(this._canvas)}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:r}=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:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),InternalRenderTask.#_.delete(this._canvas),this.callback(e||new _display_utils.RenderingCancelledException(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):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(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),InternalRenderTask.#_.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),r=i(8);const a=Object.freeze({map:null,hash:"",transfers:void 0});t.SerializableEmpty=a;class o{#v=!1;#b=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const i=this.#b.get(e);return void 0===i?t:Object.assign(t,i)}getRawValue(e){return this.#b.get(e)}remove(e){if(this.#b.delete(e),0===this.#b.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#b.values())if(e instanceof s.AnnotationEditor)return;this.onAnnotationEditor(null)}}setValue(e,t){const i=this.#b.get(e);let n=!1;if(void 0!==i)for(const[e,s]of Object.entries(t))i[e]!==s&&(n=!0,i[e]=s);else n=!0,this.#b.set(e,t);n&&this.#y(),t instanceof s.AnnotationEditor&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#b.has(e)}getAll(){return this.#b.size>0?(0,n.objectFromMap)(this.#b):null}setAll(e){for(const[t,i]of Object.entries(e))this.setValue(t,i)}get size(){return this.#b.size}#y(){this.#v||(this.#v=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#v&&(this.#v=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new l(this)}get serializable(){if(0===this.#b.size)return a;const e=new Map,t=new r.MurmurHash3_64,i=[],n=Object.create(null);let o=!1;for(const[i,r]of this.#b){const a=r instanceof s.AnnotationEditor?r.serialize(!1,n):r;a&&(e.set(i,a),t.update(`${i}:${JSON.stringify(a)}`),o||=!!a.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}:a}}t.AnnotationStorage=o;class l extends o{#S;constructor(e){super();const{map:t,hash:i,transfers:n}=e.serializable,s=structuredClone(t,n?{transfer:n}:null);this.#S={map:s,hash:i,transfers:n}}get print(){(0,n.unreachable)("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#S}}t.PrintAnnotationStorage=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditor=void 0;var n=i(5),s=i(1),r=i(6);class a{#P="";#A=!1;#w=null;#E=null;#x=null;#C=!1;#M=null;#T=this.focusin.bind(this);#D=this.focusout.bind(this);#F=!1;#k=!1;#L=!1;_initialOptions=Object.create(null);_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#R=!1;#I=a._zIndex++;static _borderLineWidth=-1;static _colorManager=new n.ColorManager;static _zIndex=1;static SMALL_EDITOR_SIZE=0;constructor(e){this.constructor===a&&(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:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[r,o];const[l,h]=this.parentDimensions;this.x=e.x/l,this.y=e.y/h,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 o({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){if(a._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)]))),t?.strings)for(const i of t.strings)a._l10nPromise.set(i,e.get(i));if(-1!==a._borderLineWidth)return;const i=getComputedStyle(document.documentElement);a._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.#R}set _isDraggable(e){this.#R=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.#I}setParent(e){null!==e&&(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#F?this.#F=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;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,r]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(e+i)/s,this.y=(t+n)/r,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;if(this.x+=e/i,this.y+=t/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:s,y:r}=this;const[a,o]=this.#N();s+=a,r+=o,this.div.style.left=`${(100*s).toFixed(2)}%`,this.div.style.top=`${(100*r).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}#N(){const[e,t]=this.parentDimensions,{_borderLineWidth:i}=a,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:r}=this;switch(s*=e,r*=t,i*=e,n*=t,this.rotation){case 0:i=Math.max(0,Math.min(e-s,i)),n=Math.max(0,Math.min(t-r,n));break;case 90:i=Math.max(0,Math.min(e-r,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(r,n));break;case 270:i=Math.min(e,Math.max(r,i)),n=Math.max(0,Math.min(t-s,n))}this.x=i/=e,this.y=n/=t;const[a,o]=this.#N();i+=a,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 a.#B(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return a.#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,r=i*e;return s.FeatureTest.isCSSRoundSupported?[Math.round(n),Math.round(r)]:[n,r]}setDims(e,t){const[i,n]=this.parentDimensions;this.div.style.width=`${(100*e/i).toFixed(2)}%`,this.#C||(this.div.style.height=`${(100*t/n).toFixed(2)}%`),this.#w?.classList.toggle("small",e<a.SMALL_EDITOR_SIZE||t<a.SMALL_EDITOR_SIZE)}fixDims(){const{style:e}=this.div,{height:t,width:i}=e,n=i.endsWith("%"),s=!this.#C&&t.endsWith("%");if(n&&s)return;const[r,a]=this.parentDimensions;n||(e.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#C||s||(e.height=`${(100*parseFloat(t)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#U(){if(this.#M)return;this.#M=document.createElement("div"),this.#M.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.#M.append(e),e.classList.add("resizer",t),e.addEventListener("pointerdown",this.#j.bind(this,t)),e.addEventListener("contextmenu",r.noContextMenu)}this.div.prepend(this.#M)}#j(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),r=this._isDraggable;this._isDraggable=!1;const a={passive:!0,capture:!0};window.addEventListener("pointermove",n,a);const o=this.x,l=this.y,h=this.width,c=this.height,d=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 p=()=>{this._isDraggable=r,window.removeEventListener("pointerup",p),window.removeEventListener("blur",p),window.removeEventListener("pointermove",n,a),this.parent.div.style.cursor=d,this.div.style.cursor=u;const e=this.x,t=this.y,i=this.width,s=this.height;e===o&&t===l&&i===h&&s===c||this.addCommands({cmd:()=>{this.width=i,this.height=s,this.x=e,this.y=t;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition()},undo:()=>{this.width=h,this.height=c,this.x=o,this.y=l;const[e,t]=this.parentDimensions;this.setDims(e*h,t*c),this.fixAndSetPosition()},mustExec:!0})};window.addEventListener("pointerup",p),window.addEventListener("blur",p)}#H(e,t){const[i,n]=this.parentDimensions,s=this.x,r=this.y,o=this.width,l=this.height,h=a.MIN_SIZE/i,c=a.MIN_SIZE/n,d=e=>Math.round(1e4*e)/1e4,u=this.#V(this.rotation),p=(e,t)=>[u[0]*e+u[2]*t,u[1]*e+u[3]*t],g=this.#V(360-this.rotation);let f,m,_=!1,v=!1;switch(e){case"topLeft":_=!0,f=(e,t)=>[0,0],m=(e,t)=>[e,t];break;case"topMiddle":f=(e,t)=>[e/2,0],m=(e,t)=>[e/2,t];break;case"topRight":_=!0,f=(e,t)=>[e,0],m=(e,t)=>[0,t];break;case"middleRight":v=!0,f=(e,t)=>[e,t/2],m=(e,t)=>[0,t/2];break;case"bottomRight":_=!0,f=(e,t)=>[e,t],m=(e,t)=>[0,0];break;case"bottomMiddle":f=(e,t)=>[e/2,t],m=(e,t)=>[e/2,0];break;case"bottomLeft":_=!0,f=(e,t)=>[0,t],m=(e,t)=>[e,0];break;case"middleLeft":v=!0,f=(e,t)=>[0,t/2],m=(e,t)=>[e,t/2]}const b=f(o,l),y=m(o,l);let S=p(...y);const P=d(s+S[0]),A=d(r+S[1]);let w=1,E=1,[x,C]=this.screenToPageTranslation(t.movementX,t.movementY);var M,T;if([x,C]=(M=x/i,T=C/n,[g[0]*M+g[2]*T,g[1]*M+g[3]*T]),_){const e=Math.hypot(o,l);w=E=Math.max(Math.min(Math.hypot(y[0]-b[0]-x,y[1]-b[1]-C)/e,1/o,1/l),h/o,c/l)}else v?w=Math.max(h,Math.min(1,Math.abs(y[0]-b[0]-x)))/o:E=Math.max(c,Math.min(1,Math.abs(y[1]-b[1]-C)))/l;const D=d(o*w),F=d(l*E);S=p(...m(D,F));const k=P-S[0],L=A-S[1];this.width=D,this.height=F,this.x=k,this.y=L,this.setDims(i*D,n*F),this.fixAndSetPosition()}async addAltTextButton(){if(this.#w)return;const e=this.#w=document.createElement("button");e.className="altText";const t=await a._l10nPromise.get("editor_alt_text_button_label");if(e.textContent=t,e.setAttribute("aria-label",t),e.tabIndex="0",e.addEventListener("contextmenu",r.noContextMenu),e.addEventListener("pointerdown",(e=>e.stopPropagation())),e.addEventListener("click",(e=>{e.preventDefault(),this._uiManager.editAltText(this)}),{capture:!0}),e.addEventListener("keydown",(t=>{t.target===e&&"Enter"===t.key&&(t.preventDefault(),this._uiManager.editAltText(this))})),this.#W(),this.div.append(e),!a.SMALL_EDITOR_SIZE){const t=40;a.SMALL_EDITOR_SIZE=Math.min(128,Math.round(e.getBoundingClientRect().width*(1+t/100)))}}async#W(){const e=this.#w;if(!e)return;if(!this.#P&&!this.#A)return e.classList.remove("done"),void this.#E?.remove();a._l10nPromise.get("editor_alt_text_edit_button_label").then((t=>{e.setAttribute("aria-label",t)}));let t=this.#E;if(!t){this.#E=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.#x=setTimeout((()=>{this.#x=null,this.#E.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.#x),this.#x=null,this.#E?.classList.remove("show")}))}e.classList.add("done"),t.innerText=this.#A?await a._l10nPromise.get("editor_alt_text_decorative_tooltip"):this.#P,t.parentNode||e.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}get altTextData(){return{altText:this.#P,decorative:this.#A}}set altTextData({altText:e,decorative:t}){this.#P===e&&this.#A===t||(this.#P=e,this.#A=t,this.#W())}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.#T),this.div.addEventListener("focusout",this.#D);const[e,t]=this.parentDimensions;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();return this.translate(i,s),(0,n.bindEvents)(this,this.div,["pointerdown"]),this.div}pointerdown(e){const{isMac:t}=s.FeatureTest.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(this.#F=!0,this.#z(e))}#z(e){if(!this._isDraggable)return;const t=this._uiManager.isSelected(this);let i,n;this._uiManager.setUpDragSession(),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 r=()=>{if(window.removeEventListener("pointerup",r),window.removeEventListener("blur",r),t&&window.removeEventListener("pointermove",n,i),this.#F=!1,!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",r),window.addEventListener("blur",r)}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,[r,a]=this.pageTranslation,o=e/i,l=t/i,h=this.x*n,c=this.y*s,d=this.width*n,u=this.height*s;switch(this.rotation){case 0:return[h+o+r,s-c-l-u+a,h+o+d+r,s-c-l+a];case 90:return[h+l+r,s-c+o+a,h+l+u+r,s-c+o+d+a];case 180:return[h-o-d+r,s-c+l+a,h-o+r,s-c+l+u+a];case 270:return[h-l-u+r,s-c-o-d+a,h-l+r,s-c-o+a];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[i,n,s,r]=e,a=s-i,o=r-n;switch(this.rotation){case 0:return[i,t-r,a,o];case 90:return[i,t-n,o,a];case 180:return[s,t-n,a,o];case 270:return[s,t-r,o,a];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.#T),this.div?.addEventListener("focusout",this.#D)}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,r]=n.pageDimensions,[a,o,l,h]=n.getRectInCurrentCoords(e.rect,r);return n.x=a/s,n.y=o/r,n.width=l/s,n.height=h/r,n}remove(){this.div.removeEventListener("focusin",this.#T),this.div.removeEventListener("focusout",this.#D),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#w?.remove(),this.#w=null,this.#E=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#U(),this.#M.classList.remove("hidden"))}select(){this.makeResizable(),this.div?.classList.add("selectedEditor")}unselect(){this.#M?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus()}updateParams(e,t){}disableEditing(){this.#w&&(this.#w.hidden=!0)}enableEditing(){this.#w&&(this.#w.hidden=!1)}enterInEditMode(){}get contentDiv(){return this.div}get isEditing(){return this.#k}set isEditing(e){this.#k=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#C=!0;const i=e/t,{style:n}=this.div;n.aspectRatio=i,n.height="auto"}static get MIN_SIZE(){return 16}}t.AnnotationEditor=a;class o extends a{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(e,t,i){for(const n of i)t.addEventListener(n,e[n].bind(e))},t.opacityToHex=function(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 r{#G=0;getId(){return`${n.AnnotationEditorPrefix}${this.#G++}`}}class a{#$=(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),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)return i.refCounter+=1,i;try{let e;if(i||={bitmap:null,id:`image_${this.#$}_${this.#G++}`,refCounter:0,isSvg:!1},"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=a._isSVGFittingCanvas,n=new FileReader,s=new Image,r=new Promise(((e,r)=>{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=r}));n.readAsDataURL(e),await r}else i.bitmap=await createImageBitmap(e);i.refCounter=1}catch(e){console.error(e),i=null}return this.#q.set(e,i),i&&this.#q.set(i.id,i),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);return t?t.bitmap?(t.refCounter+=1,t):t.file?this.getFromFile(t.file):this.getFromUrl(t.url):null}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);t&&(t.refCounter-=1,0===t.refCounter&&(t.bitmap=null))}isValidId(e){return e.startsWith(`image_${this.#$}_`)}}class o{#K=[];#Y=!1;#Q;#J=-1;constructor(e=128){this.#Q=e}add({cmd:e,undo:t,mustExec:i,type:n=NaN,overwriteIfSameType:s=!1,keepUndo:r=!1}){if(i&&e(),this.#Y)return;const a={cmd:e,undo:t,type:n};if(-1===this.#J)return this.#K.length>0&&(this.#K.length=0),this.#J=0,void this.#K.push(a);if(s&&this.#K[this.#J].type===n)return r&&(a.undo=this.#K[this.#J].undo),void(this.#K[this.#J]=a);const o=this.#J+1;o===this.#Q?this.#K.splice(0,1):(this.#J=o,o<this.#K.length&&this.#K.splice(o)),this.#K.push(a)}undo(){-1!==this.#J&&(this.#Y=!0,this.#K[this.#J].undo(),this.#Y=!1,this.#J-=1)}redo(){this.#J<this.#K.length-1&&(this.#J+=1,this.#Y=!0,this.#K[this.#J].cmd(),this.#Y=!1)}hasSomethingToUndo(){return-1!==this.#J}hasSomethingToRedo(){return this.#J<this.#K.length-1}destroy(){this.#K=null}}t.CommandManager=o;class l{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+");t&&i?(this.callbacks.set(e.slice(4),{callback:n,options:s}),this.allKeys.add(e.split("+").at(-1))):t||i||(this.callbacks.set(e,{callback:n,options:s}),this.allKeys.add(e.split("+").at(-1)))}}#Z(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("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;const i=this.callbacks.get(this.#Z(t));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:r=[],checker:a=null}}=i;a&&!a(e,t)||(n.bind(e,...r)(),s||(t.stopPropagation(),t.preventDefault()))}}t.KeyboardManager=l;class h{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return(0,s.getColorValues)(e),(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 h._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?n.Util.makeHexColor(...t):e}}t.ColorManager=h;class c{#ee=null;#te=new Map;#ie=new Map;#ne=null;#se=null;#re=new o;#ae=0;#oe=new Set;#le=null;#he=null;#ce=new Set;#de=null;#ue=new r;#pe=!1;#ge=!1;#fe=null;#me=n.AnnotationEditorType.NONE;#_e=new Set;#ve=null;#be=this.blur.bind(this);#ye=this.focus.bind(this);#Se=this.copy.bind(this);#Pe=this.cut.bind(this);#Ae=this.paste.bind(this);#we=this.keydown.bind(this);#Ee=this.onEditingAction.bind(this);#xe=this.onPageChanging.bind(this);#Ce=this.onScaleChanging.bind(this);#Me=this.onRotationChanging.bind(this);#Te={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1};#De=[0,0];#Fe=null;#ke=null;#Le=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=c.prototype,t=e=>{const{activeElement:t}=document;return t&&e.#ke.contains(t)&&e.hasSomethingToControl()},i=this.TRANSLATE_SMALL,s=this.TRANSLATE_BIG;return(0,n.shadow)(this,"_keyboardManager",new l([[["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:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:t}]]))}constructor(e,t,i,n,r,a){this.#ke=e,this.#Le=t,this.#ne=i,this._eventBus=n,this._eventBus._on("editingaction",this.#Ee),this._eventBus._on("pagechanging",this.#xe),this._eventBus._on("scalechanging",this.#Ce),this._eventBus._on("rotationchanging",this.#Me),this.#se=r.annotationStorage,this.#de=r.filterFactory,this.#ve=a,this.viewParameters={realScale:s.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:0}}destroy(){this.#Re(),this.#Ie(),this._eventBus._off("editingaction",this.#Ee),this._eventBus._off("pagechanging",this.#xe),this._eventBus._off("scalechanging",this.#Ce),this._eventBus._off("rotationchanging",this.#Me);for(const e of this.#ie.values())e.destroy();this.#ie.clear(),this.#te.clear(),this.#ce.clear(),this.#ee=null,this.#_e.clear(),this.#re.destroy(),this.#ne.destroy()}get hcmFilter(){return(0,n.shadow)(this,"hcmFilter",this.#ve?this.#de.addHCMFilter(this.#ve.foreground,this.#ve.background):"none")}get direction(){return(0,n.shadow)(this,"direction",getComputedStyle(this.#ke).direction)}editAltText(e){this.#ne?.editAltText(this,e)}onPageChanging({pageNumber:e}){this.#ae=e-1}focusMainContainer(){this.#ke.focus()}findParent(e,t){for(const i of this.#ie.values()){const{x:n,y:s,width:r,height:a}=i.div.getBoundingClientRect();if(e>=n&&e<=n+r&&t>=s&&t<=s+a)return i}return null}disableUserSelect(e=!1){this.#Le.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#ce.add(e)}removeShouldRescale(e){this.#ce.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*s.PixelsPerInch.PDF_TO_CSS_UNITS;for(const e of this.#ce)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.#ye),window.addEventListener("blur",this.#be)}#Ie(){window.removeEventListener("focus",this.#ye),window.removeEventListener("blur",this.#be)}blur(){if(!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#_e)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.#we,{capture:!0})}#Re(){window.removeEventListener("keydown",this.#we,{capture:!0})}#Be(){document.addEventListener("copy",this.#Se),document.addEventListener("cut",this.#Pe),document.addEventListener("paste",this.#Ae)}#Ve(){document.removeEventListener("copy",this.#Se),document.removeEventListener("cut",this.#Pe),document.removeEventListener("paste",this.#Ae)}addEditListeners(){this.#Ne(),this.#Be()}removeEditListeners(){this.#Re(),this.#Ve()}copy(e){if(e.preventDefault(),this.#ee?.commitOrRemove(),!this.hasSelection)return;const t=[];for(const e of this.#_e){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.#he)if(t.isHandlingMimeForPasting(e.type))return void t.paste(e,this.currentLayer);let i=t.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(e){return void(0,n.warn)(`paste: "${e.message}".`)}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 t=()=>{for(const t of e)this.#Ue(t);this.#je(e)},n=()=>{for(const t of e)t.remove()};this.addCommands({cmd:t,undo:n,mustExec:!0})}catch(e){(0,n.warn)(`paste: "${e.message}".`)}}keydown(e){this.getActive()?.shouldGetKeyboardEvents()||c._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.#Te[e]!==t))&&this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#Te,e)})}#We(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#Oe(),this.#Ne(),this.#Be(),this.#He({isEditing:this.#me!==n.AnnotationEditorType.NONE,isEmpty:this.#ze(),hasSomethingToUndo:this.#re.hasSomethingToUndo(),hasSomethingToRedo:this.#re.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Ie(),this.#Re(),this.#Ve(),this.#He({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#he){this.#he=e;for(const e of this.#he)this.#We(e.defaultPropertiesToUpdate)}}getId(){return this.#ue.getId()}get currentLayer(){return this.#ie.get(this.#ae)}getLayer(e){return this.#ie.get(e)}get currentPageIndex(){return this.#ae}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){if(this.#me=e,e===n.AnnotationEditorType.NONE)return this.setEditingState(!1),void this.#Ge();this.setEditingState(!0),this.#$e(),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}}}updateToolbar(e){e!==this.#me&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#he)if(e!==n.AnnotationEditorParamsType.CREATE){for(const i of this.#_e)i.updateParams(e,t);for(const i of this.#he)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)}}#$e(){if(!this.#pe){this.#pe=!0;for(const e of this.#ie.values())e.enable()}}#Ge(){if(this.unselectAll(),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){this.#ee!==e&&(this.#ee=e,e&&this.#We(e.propertiesToUpdate))}toggleSelected(e){if(this.#_e.has(e))return this.#_e.delete(e),e.unselect(),void this.#He({hasSelectedEditor:this.hasSelection});this.#_e.add(e),e.select(),this.#We(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}setSelected(e){for(const t of this.#_e)t!==e&&t.unselect();this.#_e.clear(),this.#_e.add(e),e.select(),this.#We(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#_e.has(e)}unselect(e){e.unselect(),this.#_e.delete(e),this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#_e.size}undo(){this.#re.undo(),this.#He({hasSomethingToUndo:this.#re.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#ze()})}redo(){this.#re.redo(),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#re.hasSomethingToRedo(),isEmpty:this.#ze()})}addCommands(e){this.#re.add(e),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#ze()})}#ze(){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(){if(this.commitOrRemove(),!this.hasSelection)return;const e=[...this.#_e];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}#je(e){this.#_e.clear();for(const t of e)t.isEmpty()||(this.#_e.add(t),t.select());this.#He({hasSelectedEditor:!0})}selectAll(){for(const e of this.#_e)e.commit();this.#je(this.#te.values())}unselectAll(){if(this.#ee)this.#ee.commitOrRemove();else if(this.hasSelection){for(const e of this.#_e)e.unselect();this.#_e.clear(),this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#De[0]+=e,this.#De[1]+=t;const[n,s]=this.#De,r=[...this.#_e];this.#Fe&&clearTimeout(this.#Fe),this.#Fe=setTimeout((()=>{this.#Fe=null,this.#De[0]=this.#De[1]=0,this.addCommands({cmd:()=>{for(const e of r)this.#te.has(e.id)&&e.translateInPage(n,s)},undo:()=>{for(const e of r)this.#te.has(e.id)&&e.translateInPage(-n,-s)},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#le=new Map;for(const e of this.#_e)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},r]of e)r.newX=i,r.newY=n,r.newPageIndex=s,t||=i!==r.savedX||n!==r.savedY||s!==r.savedPageIndex;if(!t)return!1;const i=(e,t,i,n)=>{if(this.#te.has(e.id)){const s=this.#ie.get(n);s?e._setParentAndPosition(s,t,i):(e.pageIndex=n,e.x=t,e.y=i)}};return this.addCommands({cmd:()=>{for(const[t,{newX:n,newY:s,newPageIndex:r}]of e)i(t,n,s,r)},undo:()=>{for(const[t,{savedX:n,savedY:s,savedPageIndex:r}]of e)i(t,n,s,r)},mustExec:!0}),!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);t?(t.changeParent(e),t.addOrRebuild(e)):(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 a)}}t.AnnotationEditorUIManager=c},(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(e){console.log("Deprecated API usage: "+e)},t.getColorValues=function(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,v(n))}t.remove()},t.getCurrentTransform=function(e){const{a:t,b:i,c:n,d:s,e:r,f:a}=e.getTransform();return[t,i,n,s,r,a]},t.getCurrentTransformInverse=function(e){const{a:t,b:i,c:n,d:s,e:r,f:a}=e.getTransform().invertSelf();return[t,i,n,s,r,a]},t.getFilenameFromUrl=function(e,t=!1){return t||([e]=e.split(/[#?]/,1)),e.substring(e.lastIndexOf("/")+1)},t.getPdfFilenameFromUrl=function(e,t="document.pdf"){if("string"!=typeof e)return t;if(f(e))return(0,s.warn)('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,n=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let r=i.exec(n[1])||i.exec(n[2])||i.exec(n[3]);if(r&&(r=r[0],r.includes("%")))try{r=i.exec(decodeURIComponent(r))[0]}catch{}return r||t},t.getRGB=v,t.getXfaPageViewport=function(e,{scale:t=1,rotation:i=0}){const{width:n,height:s}=e.attributes.style,r=[0,0,parseInt(n),parseInt(s)];return new p({viewBox:r,scale:t,rotation:i})},t.isDataScheme=f,t.isPdfFile=function(e){return"string"==typeof e&&/\.pdf$/i.test(e)},t.isValidFetchUrl=m,t.loadScript=function(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(e){e.preventDefault()},t.setLayerDimensions=function(e,t,i=!1,n=!0){if(t instanceof p){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:a}=e,o=s.FeatureTest.isCSSRoundSupported,l=`var(--scale-factor) * ${n}px`,h=`var(--scale-factor) * ${r}px`,c=o?`round(${l}, 1px)`:`calc(${l})`,d=o?`round(${h}, 1px)`:`calc(${h})`;i&&t.rotation%180!=0?(a.width=d,a.height=c):(a.width=c,a.height=d)}n&&e.setAttribute("data-main-rotation",t.rotation)};var n=i(7),s=i(1);const r="http://www.w3.org/2000/svg";class a{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}t.PixelsPerInch=a;class o extends n.BaseFilterFactory{#qe;#Xe;#t;#Ke;#Ye;#Qe;#Je;#Ze;#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(r,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#Xe=this.#Ke.createElementNS(r,"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,r=this.#q.get(e);if(r)return r;if(1===e.length){const r=e[0],a=new Array(256);for(let e=0;e<256;e++)a[e]=r[e]/255;s=t=i=n=a.join(",")}else{const[r,a,o]=e,l=new Array(256),h=new Array(256),c=new Array(256);for(let e=0;e<256;e++)l[e]=r[e]/255,h[e]=a[e]/255,c[e]=o[e]/255;t=l.join(","),i=h.join(","),n=c.join(","),s=`${t}${i}${n}`}if(r=this.#q.get(s),r)return this.#q.set(e,r),r;const a=`g_${this.#t}_transfer_map_${this.#G++}`,o=`url(#${a})`;this.#q.set(e,o),this.#q.set(s,o);const l=this.#nt(a);return this.#st(t,i,n,l),o}addHCMFilter(e,t){const i=`${e}-${t}`;if(this.#Qe===i)return this.#Je;if(this.#Qe=i,this.#Je="none",this.#Ye?.remove(),!e||!t)return this.#Je;const n=this.#rt(e);e=s.Util.makeHexColor(...n);const r=this.#rt(t);if(t=s.Util.makeHexColor(...r),this.#it.style.color="","#000000"===e&&"#ffffff"===t||e===t)return this.#Je;const a=new Array(256);for(let e=0;e<=255;e++){const t=e/255;a[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const o=a.join(","),l=`g_${this.#t}_hcm_filter`,h=this.#Ze=this.#nt(l);this.#st(o,o,o,h),this.#at(h);const c=(e,t)=>{const i=n[e]/255,s=r[e]/255,a=new Array(t+1);for(let e=0;e<=t;e++)a[e]=i+e/t*(s-i);return a.join(",")};return this.#st(c(0,5),c(1,5),c(2,5),h),this.#Je=`url(#${l})`,this.#Je}addHighlightHCMFilter(e,t,i,n){const s=`${e}-${t}-${i}-${n}`;if(this.#et===s)return this.#tt;if(this.#et=s,this.#tt="none",this.#Ze?.remove(),!e||!t)return this.#tt;const[r,a]=[e,t].map(this.#rt.bind(this));let o=Math.round(.2126*r[0]+.7152*r[1]+.0722*r[2]),l=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),[h,c]=[i,n].map(this.#rt.bind(this));l<o&&([o,l,h,c]=[l,o,c,h]),this.#it.style.color="";const d=(e,t,i)=>{const n=new Array(256),s=(l-o)/i,r=e/255,a=(t-e)/(255*i);let h=0;for(let e=0;e<=i;e++){const t=Math.round(o+e*s),i=r+e*a;for(let e=h;e<=t;e++)n[e]=i;h=t+1}for(let e=h;e<256;e++)n[e]=n[h-1];return n.join(",")},u=`g_${this.#t}_hcm_highlight_filter`,p=this.#Ze=this.#nt(u);return this.#at(p),this.#st(d(h[0],c[0],5),d(h[1],c[1],5),d(h[2],c[2],5),p),this.#tt=`url(#${u})`,this.#tt}destroy(e=!1){e&&(this.#Je||this.#tt)||(this.#Xe&&(this.#Xe.parentNode.parentNode.remove(),this.#Xe=null),this.#qe&&(this.#qe.clear(),this.#qe=null),this.#G=0)}#at(e){const t=this.#Ke.createElementNS(r,"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(r,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#it.append(t),t}#ot(e,t,i){const n=this.#Ke.createElementNS(r,t);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)}#st(e,t,i,n){const s=this.#Ke.createElementNS(r,"feComponentTransfer");n.append(s),this.#ot(s,"feFuncR",e),this.#ot(s,"feFuncG",t),this.#ot(s,"feFuncB",i)}#rt(e){return this.#it.style.color=e,v(getComputedStyle(this.#it).getPropertyValue("color"))}}t.DOMFilterFactory=o;class l extends n.BaseCanvasFactory{constructor({ownerDocument:e=globalThis.document}={}){super(),this._document=e}_createCanvas(e,t){const i=this._document.createElement("canvas");return i.width=e,i.height=t,i}}async function h(e,t=!1){if(m(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 r=new XMLHttpRequest;r.open("GET",e,!0),t&&(r.responseType="arraybuffer"),r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){let e;if(t&&r.response?e=new Uint8Array(r.response):!t&&r.responseText&&(e=(0,s.stringToBytes)(r.responseText)),e)return void i(e)}n(new Error(r.statusText))}},r.send(null)}))}t.DOMCanvasFactory=l;class c extends n.BaseCMapReaderFactory{_fetchData(e,t){return h(e,this.isCompressed).then((e=>({cMapData:e,compressionType:t})))}}t.DOMCMapReaderFactory=c;class d extends n.BaseStandardFontDataFactory{_fetchData(e){return h(e,!0)}}t.DOMStandardFontDataFactory=d;class u extends n.BaseSVGFactory{_createSVG(e){return document.createElementNS(r,e)}}t.DOMSVGFactory=u;class p{constructor({viewBox:e,scale:t,rotation:i,offsetX:n=0,offsetY:s=0,dontFlip:r=!1}){this.viewBox=e,this.scale=t,this.rotation=i,this.offsetX=n,this.offsetY=s;const a=(e[2]+e[0])/2,o=(e[3]+e[1])/2;let l,h,c,d,u,p,g,f;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,c=0,d=1;break;case 90:l=0,h=1,c=1,d=0;break;case 270:l=0,h=-1,c=-1,d=0;break;case 0:l=1,h=0,c=0,d=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(c=-c,d=-d),0===l?(u=Math.abs(o-e[1])*t+n,p=Math.abs(a-e[0])*t+s,g=(e[3]-e[1])*t,f=(e[2]-e[0])*t):(u=Math.abs(a-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,h*t,c*t,d*t,u-l*t*a-c*t*o,p-h*t*a-d*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 p({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=p;class g extends s.BaseException{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function f(e){const t=e.length;let i=0;for(;i<t&&""===e[i].trim();)i++;return"data:"===e.substring(i,i+5).toLowerCase()}function m(e,t){try{const{protocol:i}=t?new URL(e,t):new URL(e);return"http:"===i||"https:"===i}catch{return!1}}let _;function v(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):((0,s.warn)(`Not a valid color format: "${e}"`),[0,0,0])}t.RenderingCancelledException=g,t.StatTimer=class{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("")}},t.PDFDateString=class{static toDateObject(e){if(!e||"string"!=typeof e)return null;_||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=_.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 r=parseInt(t[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(t[6],10);o=o>=0&&o<=59?o:0;const l=t[7]||"Z";let h=parseInt(t[8],10);h=h>=0&&h<=23?h:0;let c=parseInt(t[9],10)||0;return c=c>=0&&c<=59?c:0,"-"===l?(r+=h,a+=c):"+"===l&&(r-=h,a-=c),new Date(Date.UTC(i,n,s,r,a,o))}}},(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 s{constructor(){this.constructor===s&&(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=s;class r{constructor(){this.constructor===r&&(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=r;class a{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===a&&(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=a;class o{constructor({baseUrl:e=null}){this.constructor===o&&(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=o;class l{constructor(){this.constructor===l&&(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");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${e}px`),n.setAttribute("height",`${t}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${e} ${t}`),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=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.MurmurHash3_64=void 0;var n=i(1);const s=3285377520,r=4294901760,a=65535;t.MurmurHash3_64=class{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);s<=255?t[i++]=s:(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 h=0,c=0,d=this.h1,u=this.h2;const p=3432918353,g=461845907,f=11601,m=13715;for(let e=0;e<s;e++)1&e?(h=l[e],h=h*p&r|h*f&a,h=h<<15|h>>>17,h=h*g&r|h*m&a,d^=h,d=d<<13|d>>>19,d=5*d+3864292196):(c=l[e],c=c*p&r|c*f&a,c=c<<15|c>>>17,c=c*g&r|c*m&a,u^=c,u=u<<13|u>>>19,u=5*u+3864292196);switch(h=0,o){case 3:h^=t[4*s+2]<<16;case 2:h^=t[4*s+1]<<8;case 1:h^=t[4*s],h=h*p&r|h*f&a,h=h<<15|h>>>17,h=h*g&r|h*m&a,1&s?d^=h:u^=h}this.h1=d,this.h2=u}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&r|36045*e&a,t=4283543511*t&r|(2950163797*(t<<16|e>>>16)&r)>>>16,e^=t>>>1,e=444984403*e&r|60499*e&a,t=3301882366*t&r|(3120437893*(t<<16|e>>>16)&r)>>>16,e^=t>>>1,(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{#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){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(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont(e){if(e&&!this.#lt.has(e.loadedName))if((0,n.assert)(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:t,src:i,style:s}=e,r=new FontFace(t,i,s);this.addNativeFontFace(r);try{await r.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(r)}}else(0,n.unreachable)("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void await this.loadSystemFont(e.systemFontInfo);if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(i){throw(0,n.warn)(`Failed to load font '${t.family}': '${i}'.`),e.disableFontFace=!0,i}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),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;return(n.isNodeJS||"undefined"!=typeof navigator&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),(0,n.shadow)(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,i={done:!1,complete:function(){for((0,n.assert)(!i.done,"completeRequest() cannot be called twice."),i.done=!0;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(i),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 i(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function s(e,t,i,n){return e.substring(0,t)+n+e.substring(t+i)}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;const c=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=s(d,976,c.length,c);const u=1482184792;let p=i(d,16);for(r=0,a=c.length-3;r<a;r+=4)p=p-u+i(c,r)|0;r<c.length&&(p=p-u+i(c+"XXX",r)|0),d=s(d,16,4,(0,n.string32)(p));const g=`@font-face {font-family:"${c}";src:url(data:font/opentype;base64,${btoa(d)});}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const t of[e.loadedName,c]){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,f.append(e)}this._document.body.append(f),function e(t,i){if(++h>30)return(0,n.warn)("Load test font never loaded."),void i();l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0?i():setTimeout(e.bind(null,t,i))}(c,(()=>{f.remove(),t.complete()}))}},t.FontFaceObject=class{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,{});return this._inspectFont?.(this),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}}`;return this._inspectFont?.(this,t),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;return(0,n.warn)(`getPathGenerator - ignoring character: "${e}".`),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 s=function(e){return new Promise(((t,i)=>{require$$5.readFile(e,((e,n)=>{!e&&n?t(new Uint8Array(n)):i(new Error(e))}))}))};class r extends n.BaseFilterFactory{}t.NodeFilterFactory=r;class a extends n.BaseCanvasFactory{_createCanvas(e,t){return require$$5.createCanvas(e,t)}}t.NodeCanvasFactory=a;class o extends n.BaseCMapReaderFactory{_fetchData(e,t){return s(e).then((e=>({cMapData:e,compressionType:t})))}}t.NodeCMapReaderFactory=o;class l extends n.BaseStandardFontDataFactory{_fetchData(e){return s(e)}}t.NodeStandardFontDataFactory=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CanvasGraphics=void 0;var n=i(1),s=i(6),r=i(12),a=i(13);const o=4096,l=16;class h{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,i){let n;return void 0!==this.cache[e]?(n=this.cache[e],this.canvasFactory.reset(n,t,i)):(n=this.canvasFactory.create(t,i),this.cache[e]=n),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 c(e,t,i,n,r,a,o,l,h,c){const[d,u,p,g,f,m]=(0,s.getCurrentTransform)(e);if(0===u&&0===p){const s=o*d+f,_=Math.round(s),v=l*g+m,b=Math.round(v),y=(o+h)*d+f,S=Math.abs(Math.round(y)-_)||1,P=(l+c)*g+m,A=Math.abs(Math.round(P)-b)||1;return e.setTransform(Math.sign(d),0,0,Math.sign(g),_,b),e.drawImage(t,i,n,r,a,0,0,S,A),e.setTransform(d,u,p,g,f,m),[S,A]}if(0===d&&0===g){const s=l*p+f,_=Math.round(s),v=o*u+m,b=Math.round(v),y=(l+c)*p+f,S=Math.abs(Math.round(y)-_)||1,P=(o+h)*u+m,A=Math.abs(Math.round(P)-b)||1;return e.setTransform(0,Math.sign(u),Math.sign(p),0,_,b),e.drawImage(t,i,n,r,a,0,0,A,S),e.setTransform(d,u,p,g,f,m),[A,S]}return e.drawImage(t,i,n,r,a,o,l,h,c),[Math.hypot(d,u)*h,Math.hypot(p,g)*c]}class d{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);return e.clipBox=this.clipBox.slice(),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,r,a,o,l,h,c){const d=n.Util.bezierBoundingBox(t,i,s,r,a,o,l,h);if(c)return c[0]=Math.min(c[0],d[0],d[2]),c[1]=Math.max(c[1],d[0],d[2]),c[2]=Math.min(c[2],d[1],d[3]),void(c[3]=Math.max(c[3],d[1],d[3]));this.updateRectMinMax(e,d)}getPathBoundingBox(e=r.PathType.FILL,t=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(e===r.PathType.STROKE){t||(0,n.unreachable)("Stroke bounding box must include transform.");const e=n.Util.singularValueDecompose2dScale(t),s=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;i[0]-=s,i[1]-=r,i[2]+=s,i[3]+=r}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=r.PathType.FILL,t=null){return n.Util.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function u(e,t){if("undefined"!=typeof ImageData&&t instanceof ImageData)return void e.putImageData(t,0,0);const i=t.height,s=t.width,r=i%l,a=(i-r)/l,o=0===r?a:a+1,h=e.createImageData(s,l);let c,d=0;const u=t.data,p=h.data;let g,f,m,_;if(t.kind===n.ImageKind.GRAYSCALE_1BPP){const t=u.byteLength,i=new Uint32Array(p.buffer,0,p.byteLength>>2),_=i.length,v=s+7>>3,b=4294967295,y=n.FeatureTest.isLittleEndian?4278190080:255;for(g=0;g<o;g++){for(m=g<a?l:r,c=0,f=0;f<m;f++){const e=t-d;let n=0;const r=e>v?s:8*e-7,a=-8&r;let o=0,l=0;for(;n<a;n+=8)l=u[d++],i[c++]=128&l?b:y,i[c++]=64&l?b:y,i[c++]=32&l?b:y,i[c++]=16&l?b:y,i[c++]=8&l?b:y,i[c++]=4&l?b:y,i[c++]=2&l?b:y,i[c++]=1&l?b:y;for(;n<r;n++)0===o&&(l=u[d++],o=128),i[c++]=l&o?b:y,o>>=1}for(;c<_;)i[c++]=0;e.putImageData(h,0,g*l)}}else if(t.kind===n.ImageKind.RGBA_32BPP){for(f=0,_=s*l*4,g=0;g<a;g++)p.set(u.subarray(d,d+_)),d+=_,e.putImageData(h,0,f),f+=l;g<o&&(_=s*r*4,p.set(u.subarray(d,d+_)),e.putImageData(h,0,f))}else{if(t.kind!==n.ImageKind.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(m=l,_=s*m,g=0;g<o;g++){for(g>=a&&(m=r,_=s*m),c=0,f=_;f--;)p[c++]=u[d++],p[c++]=u[d++],p[c++]=u[d++],p[c++]=255;e.putImageData(h,0,g*l)}}}function p(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);const i=t.height,n=t.width,s=i%l,r=(i-s)/l,o=0===s?r:r+1,h=e.createImageData(n,l);let c=0;const d=t.data,u=h.data;for(let t=0;t<o;t++){const i=t<r?l:s;({srcPos:c}=(0,a.convertBlackAndWhiteToRGBA)({src:d,srcPos:c,dest:u,width:n,height:i,nonBlackColor:0})),e.putImageData(h,0,t*l)}}function g(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]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function f(e){if(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",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!n.isNodeJS){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function m(e,t,i,n){const s=e.length;for(let r=3;r<s;r+=4){const s=e[r];if(0===s)e[r-3]=t,e[r-2]=i,e[r-1]=n;else if(s<255){const a=255-s;e[r-3]=e[r-3]*s+t*a>>8,e[r-2]=e[r-2]*s+i*a>>8,e[r-1]=e[r-1]*s+n*a>>8}}}function _(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 v(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 b(e,t,i,n){const s=n[0],r=n[1],a=n[2]-s,o=n[3]-r;0!==a&&0!==o&&(function(e,t,i,n,s,r,a,o,l,h,c){const d=!!r,u=d?r[0]:0,p=d?r[1]:0,g=d?r[2]:0,f="Luminosity"===s?v:_,b=Math.min(n,Math.ceil(1048576/i));for(let s=0;s<n;s+=b){const r=Math.min(b,n-s),_=e.getImageData(o-h,s+(l-c),i,r),v=t.getImageData(o,s+l,i,r);d&&m(_.data,u,p,g),f(_.data,v.data,a),t.putImageData(v,o,s+l)}}(t.context,i,a,o,t.subtype,t.backdrop,t.transferMap,s,r,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 y(e,t){const i=n.Util.singularValueDecompose2dScale(e);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const r=Math.fround((globalThis.devicePixelRatio||1)*s.PixelsPerInch.PDF_TO_CSS_UNITS);return void 0!==t?t:i[0]<=r||i[1]<=r}const S=["butt","round","square"],P=["miter","round","bevel"],A={},w={};class E{constructor(e,t,i,n,s,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=e,this.current=new d(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=a||[],this.optionalContentConfig=r,this.cachedCanvases=new h(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 r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,i){const e=this.cachedCanvases.getCanvas("transparent",r,a);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(),f(this.ctx),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 r=e.argsArray,a=e.fnArray;let o=t||0;const l=r.length;if(l===o)return o;const h=l-o>10&&"function"==typeof i,c=h?Date.now()+15:0;let d=0;const u=this.commonObjs,p=this.objs;let g;for(;;){if(void 0!==s&&o===s.nextBreakPoint)return s.breakIt(o,i),o;if(g=a[o],g!==n.OPS.dependency)this[g].apply(this,r[o]);else for(const e of r[o]){const t=e.startsWith("g_")?u:p;if(!t.has(e))return t.get(e,i),o}if(o++,o===l)return o;if(h&&++d>10){if(Date.now()>c)return i(),o;d=0}}}#ht(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.ctx.restore(),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.#ht(),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.#ct()}#ct(){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,r,a=Math.max(Math.hypot(t[0],t[1]),1),o=Math.max(Math.hypot(t[2],t[3]),1),l=i,h=n,c="prescale1";for(;a>2&&l>1||o>2&&h>1;){let t=l,i=h;a>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/t),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),s=this.cachedCanvases.getCanvas(c,t,i),r=s.context,r.clearRect(0,0,t,i),r.drawImage(e,0,0,l,h,0,0,t,i),e=s.canvas,l=t,h=i,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:h}}_createMaskCanvas(e){const t=this.ctx,{width:i,height:a}=e,o=this.current.fillColor,l=this.current.patternFill,h=(0,s.getCurrentTransform)(t);let d,u,g,f;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;u=JSON.stringify(l?h:[h.slice(0,4),o]),d=this._cachedBitmapsMap.get(t),d||(d=new Map,this._cachedBitmapsMap.set(t,d));const i=d.get(u);if(i&&!l)return{canvas:i,offsetX:Math.round(Math.min(h[0],h[2])+h[4]),offsetY:Math.round(Math.min(h[1],h[3])+h[5])};g=i}g||(f=this.cachedCanvases.getCanvas("maskCanvas",i,a),p(f.context,e));let m=n.Util.transform(h,[1/i,0,0,-1/a,0,0]);m=n.Util.transform(m,[1,0,0,1,0,-a]);const _=n.Util.applyTransform([0,0],m),v=n.Util.applyTransform([i,a],m),b=n.Util.normalizeRect([_[0],_[1],v[0],v[1]]),S=Math.round(b[2]-b[0])||1,P=Math.round(b[3]-b[1])||1,A=this.cachedCanvases.getCanvas("fillCanvas",S,P),w=A.context,E=Math.min(_[0],v[0]),x=Math.min(_[1],v[1]);w.translate(-E,-x),w.transform(...m),g||(g=this._scaleImage(f.canvas,(0,s.getCurrentTransformInverse)(w)),g=g.img,d&&l&&d.set(u,g)),w.imageSmoothingEnabled=y((0,s.getCurrentTransform)(w),e.interpolate),c(w,g,0,0,g.width,g.height,0,0,i,a),w.globalCompositeOperation="source-in";const C=n.Util.transform((0,s.getCurrentTransformInverse)(w),[1,0,0,1,-E,-x]);return w.fillStyle=l?o.getPattern(t,this,C,r.PathType.FILL):o,w.fillRect(0,0,i,a),d&&!l&&(this.cachedCanvases.delete("fillCanvas"),d.set(u,A.canvas)),{canvas:A.canvas,offsetX:Math.round(E),offsetY:Math.round(x)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=S[e]}setLineJoin(e){this.ctx.lineJoin=P[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const i=this.ctx;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 r=this.ctx;r.setTransform(...(0,s.getCurrentTransform)(this.suspendedCtx)),g(this.suspendedCtx,r),function(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(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,i){t.translate(e,i),this.__originalTranslate(e,i)},e.scale=function(e,i){t.scale(e,i),this.__originalScale(e,i)},e.transform=function(e,i,n,s,r,a){t.transform(e,i,n,s,r,a),this.__originalTransform(e,i,n,s,r,a)},e.setTransform=function(e,i,n,s,r,a){t.setTransform(e,i,n,s,r,a),this.__originalSetTransform(e,i,n,s,r,a)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(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,r,a){t.bezierCurveTo(e,i,n,s,r,a),this.__originalBezierCurveTo(e,i,n,s,r,a)},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()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),g(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;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])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask;b(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(){this.inSMaskMode?(g(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),g(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,i,n,s,r){this.ctx.transform(e,t,i,n,s,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,i){const r=this.ctx,a=this.current;let o,l,h=a.x,c=a.y;const d=(0,s.getCurrentTransform)(r),u=0===d[0]&&0===d[3]||0===d[1]&&0===d[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:h=t[s++],c=t[s++];const e=t[s++],i=t[s++],g=h+e,f=c+i;r.moveTo(h,c),0===e||0===i?r.lineTo(g,f):(r.lineTo(g,c),r.lineTo(g,f),r.lineTo(h,f)),u||a.updateRectMinMax(d,[h,c,g,f]),r.closePath();break;case n.OPS.moveTo:h=t[s++],c=t[s++],r.moveTo(h,c),u||a.updatePathMinMax(d,h,c);break;case n.OPS.lineTo:h=t[s++],c=t[s++],r.lineTo(h,c),u||a.updatePathMinMax(d,h,c);break;case n.OPS.curveTo:o=h,l=c,h=t[s+4],c=t[s+5],r.bezierCurveTo(t[s],t[s+1],t[s+2],t[s+3],h,c),a.updateCurvePathMinMax(d,o,l,t[s],t[s+1],t[s+2],t[s+3],h,c,p),s+=6;break;case n.OPS.curveTo2:o=h,l=c,r.bezierCurveTo(h,c,t[s],t[s+1],t[s+2],t[s+3]),a.updateCurvePathMinMax(d,o,l,h,c,t[s],t[s+1],t[s+2],t[s+3],p),h=t[s+2],c=t[s+3],s+=4;break;case n.OPS.curveTo3:o=h,l=c,h=t[s+2],c=t[s+3],r.bezierCurveTo(t[s],t[s+1],h,c,h,c),a.updateCurvePathMinMax(d,o,l,t[s],t[s+1],h,c,h,c,p),s+=4;break;case n.OPS.closePath:r.closePath()}u&&a.updateScalingPathMinMax(d,p),a.setCurrentPoint(h,c)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,i=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(t.save(),t.strokeStyle=i.getPattern(t,this,(0,s.getCurrentTransformInverse)(t),r.PathType.STROKE),this.rescaleAndStroke(!1),t.restore()):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;this.current.patternFill&&(t.save(),t.fillStyle=i.getPattern(t,this,(0,s.getCurrentTransformInverse)(t),r.PathType.FILL),n=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),n&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=A}eoClip(){this.pendingClip=w}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}`);if(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),t<0?(t=-t,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=t,i.isType3Font)return;const r=i.loadedName||"sans-serif",a=i.systemFontInfo?.css||`"${r}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const l=i.italic?"italic":"normal";let h=t;t<16?h=16:t>100&&(h=100),this.current.fontSizeScale=t/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}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,r){this.current.textMatrix=[e,t,i,n,s,r],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,r){const a=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,c=o.fontSize/o.fontSizeScale,d=h&n.TextRenderingMode.FILL_STROKE_MASK,u=!!(h&n.TextRenderingMode.ADD_TO_PATH_FLAG),p=o.patternFill&&!l.missingFile;let g;(l.disableFontFace||u||p)&&(g=l.getPathGenerator(this.commonObjs,e)),l.disableFontFace||p?(a.save(),a.translate(t,i),a.beginPath(),g(a,c),r&&a.setTransform(...r),d!==n.TextRenderingMode.FILL&&d!==n.TextRenderingMode.FILL_STROKE||a.fill(),d!==n.TextRenderingMode.STROKE&&d!==n.TextRenderingMode.FILL_STROKE||a.stroke(),a.restore()):(d!==n.TextRenderingMode.FILL&&d!==n.TextRenderingMode.FILL_STROKE||a.fillText(e,t,i),d!==n.TextRenderingMode.STROKE&&d!==n.TextRenderingMode.FILL_STROKE||a.strokeText(e,t,i)),u&&(this.pendingTextPaths||=[]).push({transform:(0,s.getCurrentTransform)(a),x:t,y:i,fontSize:c,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 a=t.fontSize;if(0===a)return;const o=this.ctx,l=t.fontSizeScale,h=t.charSpacing,c=t.wordSpacing,d=t.fontDirection,u=t.textHScale*d,p=e.length,g=i.vertical,f=g?1:-1,m=i.defaultVMetrics,_=a*t.fontMatrix[0],v=t.textRenderingMode===n.TextRenderingMode.FILL&&!i.disableFontFace&&!t.patternFill;let b;if(o.save(),o.transform(...t.textMatrix),o.translate(t.x,t.y+t.textRise),d>0?o.scale(u,-1):o.scale(u,1),t.patternFill){o.save();const e=t.fillColor.getPattern(o,this,(0,s.getCurrentTransformInverse)(o),r.PathType.FILL);b=(0,s.getCurrentTransform)(o),o.restore(),o.fillStyle=e}let y=t.lineWidth;const S=t.textMatrixScale;if(0===S||0===y){const e=t.textRenderingMode&n.TextRenderingMode.FILL_STROKE_MASK;e!==n.TextRenderingMode.STROKE&&e!==n.TextRenderingMode.FILL_STROKE||(y=this.getSinglePixelWidth())}else y/=S;if(1!==l&&(o.scale(l,l),y/=l),o.lineWidth=y,i.isInvalidPDFjsFont){const i=[];let n=0;for(const t of e)i.push(t.unicode),n+=t.width;return o.fillText(i.join(""),0,0),t.x+=n*_*u,o.restore(),void this.compose()}let P,A=0;for(P=0;P<p;++P){const t=e[P];if("number"==typeof t){A+=f*t*a/1e3;continue}let n=!1;const s=(t.isSpace?c:0)+h,r=t.fontChar,u=t.accent;let p,y,S=t.width;if(g){const e=t.vmetric||m,i=-(t.vmetric?e[1]:.5*S)*_,n=e[2]*_;S=e?-e[0]:S,p=i/l,y=(A+n)/l}else p=A/l,y=0;if(i.remeasure&&S>0){const e=1e3*o.measureText(r).width/a*l;if(S<e&&this.isFontSubpixelAAEnabled){const t=S/e;n=!0,o.save(),o.scale(t,1),p/=t}else S!==e&&(p+=(S-e)/2e3*a/l)}if(this.contentVisible&&(t.isInFont||i.missingFile))if(v&&!u)o.fillText(r,p,y);else if(this.paintChar(r,p,y,b),u){const e=p+a*u.offset.x/l,t=y-a*u.offset.y/l;this.paintChar(u.fontChar,e,t,b)}A+=g?S*_-s*d:S*_+s*d,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,r=i.fontSize,a=i.fontDirection,o=s.vertical?1:-1,l=i.charSpacing,h=i.wordSpacing,c=i.textHScale*a,d=i.fontMatrix||n.FONT_IDENTITY_MATRIX,u=e.length;let p,g,f,m;if(i.textRenderingMode!==n.TextRenderingMode.INVISIBLE&&0!==r){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...i.textMatrix),t.translate(i.x,i.y),t.scale(c,a),p=0;p<u;++p){if(g=e[p],"number"==typeof g){m=o*g*r/1e3,this.ctx.translate(m,0),i.x+=m*c;continue}const a=(g.isSpace?h:0)+l,u=s.charProcOperatorList[g.operatorListId];u?(this.contentVisible&&(this.processingType3=g,this.save(),t.scale(r,r),t.transform(...d),this.executeOperatorList(u),this.restore()),f=n.Util.applyTransform([g.width,0],d)[0]*r+a,t.translate(f,0),i.x+=f*c):(0,n.warn)(`Type3 character "${g.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,i,n,s,r){this.ctx.rect(i,n,s-i,r-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),a={createCanvasGraphics:e=>new E(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new r.TilingPattern(e,i,this.ctx,a,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;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=(0,r.getShadingPattern)(this.getObject(e)),this.cachedPatterns.set(e,i)),t&&(i.matrix=t),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),r.PathType.SHADING);const a=(0,s.getCurrentTransformInverse)(t);if(a){const{width:e,height:i}=t.canvas,[s,r,o,l]=n.Util.getAxialAlignedBoundingBox([0,0,e,i],a);this.ctx.fillRect(s,r,o-s,l-r)}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),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(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),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);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=n.Util.getAxialAlignedBoundingBox(e.bbox,(0,s.getCurrentTransform)(t));const a=[0,0,t.canvas.width,t.canvas.height];r=n.Util.intersect(r,a)||[0,0,0,0];const l=Math.floor(r[0]),h=Math.floor(r[1]);let c=Math.max(Math.ceil(r[2])-l,1),d=Math.max(Math.ceil(r[3])-h,1),u=1,p=1;c>o&&(u=c/o,c=o),d>o&&(p=d/o,d=o),this.current.startNewPathAndClipBox([0,0,c,d]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);const m=this.cachedCanvases.getCanvas(f,c,d),_=m.context;_.scale(1/u,1/p),_.translate(-l,-h),_.transform(...i),e.smask?this.smaskStack.push({canvas:m.canvas,context:_,offsetX:l,offsetY:h,scaleX:u,scaleY:p,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(l,h),t.scale(u,p),t.save()),g(t,_),this.ctx=_,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();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,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,r,a){if(this.#ht(),f(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),Array.isArray(t)&&4===t.length){const r=t[2]-t[0],o=t[3]-t[1];if(a&&this.annotationCanvasMap){(i=i.slice())[4]-=t[0],i[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=r,t[3]=o;const[a,l]=n.Util.singularValueDecompose2dScale((0,s.getCurrentTransform)(this.ctx)),{viewportScale:h}=this,c=Math.ceil(r*this.outputScaleX*h),d=Math.ceil(o*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,d);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(a,0,0,-l,0,o*l),f(this.ctx)}else f(this.ctx),this.ctx.rect(t[0],t[1],r,o),this.ctx.clip(),this.endPath()}this.current=new d(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#ct(),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(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 r,a,o,l=new Uint8Array(s*(i+1));const h=t+7&-8;let c=new Uint8Array(h*i),d=0;for(const t of e.data){let e=128;for(;e>0;)c[d++]=t&e?0:255,e>>=1}let u=0;for(d=0,0!==c[d]&&(l[0]=1,++u),a=1;a<t;a++)c[d]!==c[d+1]&&(l[a]=c[d]?2:1,++u),d++;for(0!==c[d]&&(l[a]=2,++u),r=1;r<i;r++){d=r*h,o=r*s,c[d-h]!==c[d]&&(l[o]=c[d]?1:8,++u);let e=(c[d]?4:0)+(c[d-h]?8:0);for(a=1;a<t;a++)e=(e>>2)+(c[d+1]?4:0)+(c[d-h+1]?8:0),n[e]&&(l[o+a]=n[e],++u),d++;if(c[d-h]!==c[d]&&(l[o+a]=c[d]?2:4,++u),u>1e3)return null}for(d=h*(i-1),o=r*s,0!==c[d]&&(l[o]=8,++u),a=1;a<t;a++)c[d]!==c[d+1]&&(l[o+a]=c[d]?4:8,++u),d++;if(0!==c[d]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,s,-1,0,-s,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let e=r*s;const i=e+t;for(;e<i&&!l[e];)e++;if(e===i)continue;g.moveTo(e%s,r);const n=e;let a=l[e];do{const t=p[a];do{e+=t}while(!l[e]);const i=l[e];5!==i&&10!==i?(a=i,l[e]=0):(a=i&51*a>>4,l[e]&=a>>2|a<<2),g.lineTo(e%s,e/s|0),l[e]||--u}while(n!==e);--r}return c=null,l=null,function(e){e.save(),e.scale(1/t,-1/i),e.translate(0,-i),e.fill(g),e.beginPath(),e.restore()}}(e)),n.compiled))return void n.compiled(i);const s=this._createMaskCanvas(e),r=s.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,s.offsetX,s.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,i=0,r=0,a,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const l=this.ctx;l.save();const h=(0,s.getCurrentTransform)(l);l.transform(t,i,r,a,0,0);const c=this._createMaskCanvas(e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]);for(let e=0,s=o.length;e<s;e+=2){const s=n.Util.transform(h,[t,i,r,a,o[e],o[e+1]]),[d,u]=n.Util.applyTransform([0,0],s);l.drawImage(c.canvas,d,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 a of e){const{data:e,width:o,height:l,transform:h}=a,d=this.cachedCanvases.getCanvas("maskCanvas",o,l),u=d.context;u.save(),p(u,this.getObject(e,a)),u.globalCompositeOperation="source-in",u.fillStyle=n?i.getPattern(u,this,(0,s.getCurrentTransformInverse)(t),r.PathType.FILL):i,u.fillRect(0,0,o,l),u.restore(),t.save(),t.transform(...h),t.scale(1,-1),c(t,d.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 r=this.getObject(e);if(!r)return void(0,n.warn)("Dependent image isn't ready yet");const a=r.width,o=r.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:a,h:o});this.paintInlineImageXObjectGroup(r,l)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),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),r=s.context;return r.filter=this.current.transferMaps,r.drawImage(t,0,0),r.filter="none",s.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,i=e.height,r=this.ctx;if(this.save(),!n.isNodeJS){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}let a;if(r.scale(1/t,-1/i),e.bitmap)a=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)a=e;else{const n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;u(n,e),a=this.applyTransferMapsToCanvas(n)}const o=this._scaleImage(a,(0,s.getCurrentTransformInverse)(r));r.imageSmoothingEnabled=y((0,s.getCurrentTransform)(r),e.interpolate),c(r,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;u(s,e),n=this.applyTransferMapsToCanvas(s)}for(const e of t)i.save(),i.transform(...e.transform),i.scale(1,-1),c(i,n,e.x,e.y,e.w,e.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){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;this.pendingClip&&(t||(this.pendingClip===w?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 r,a;if(0===i&&0===n){const i=Math.abs(t),n=Math.abs(s);if(i===n)if(0===e)r=a=1/i;else{const t=i*e;r=a=t<1?1/t:1}else if(0===e)r=1/i,a=1/n;else{const t=i*e,s=n*e;r=t<1?1/t:1,a=s<1?1/s:1}}else{const o=Math.abs(t*s-i*n),l=Math.hypot(t,i),h=Math.hypot(n,s);if(0===e)r=h/o,a=l/o;else{const t=e*o;r=h>t?h/t:1,a=l>t?l/t:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:i}=this.current,[n,s]=this.getScaleForStroking();if(t.lineWidth=i||1,1===n&&1===s)return void t.stroke();const r=t.getLineDash();if(e&&t.save(),t.scale(n,s),r.length>0){const e=Math.max(n,s);t.setLineDash(r.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=E;for(const e in n.OPS)void 0!==E.prototype[e]&&(E.prototype[n.OPS[e]]=E.prototype[e])},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TilingPattern=t.PathType=void 0,t.getShadingPattern=function(e){switch(e[0]){case"RadialAxial":return new l(e);case"Mesh":return new d(e);case"Dummy":return new u}throw new Error(`Unknown IR type: ${e[0]}`)};var n=i(1),s=i(6);const r={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function a(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)}t.PathType=r;class o{constructor(){this.constructor===o&&(0,n.unreachable)("Cannot initialize BaseShadingPattern.")}getPattern(){(0,n.unreachable)("Abstract method `getPattern` called.")}}class l extends o{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,o){let l;if(o===r.STROKE||o===r.FILL){const r=t.current.getClippedPathBoundingBox(o,(0,s.getCurrentTransform)(e))||[0,0,0,0],h=Math.ceil(r[2]-r[0])||1,c=Math.ceil(r[3]-r[1])||1,d=t.cachedCanvases.getCanvas("pattern",h,c,!0),u=d.context;u.clearRect(0,0,u.canvas.width,u.canvas.height),u.beginPath(),u.rect(0,0,u.canvas.width,u.canvas.height),u.translate(-r[0],-r[1]),i=n.Util.transform(i,[1,0,0,1,r[0],r[1]]),u.transform(...t.baseTransform),this.matrix&&u.transform(...this.matrix),a(u,this._bbox),u.fillStyle=this._createGradient(u),u.fill(),l=e.createPattern(d.canvas,"no-repeat");const p=new DOMMatrix(i);l.setTransform(p)}else a(e,this._bbox),l=this._createGradient(e);return l}}function h(e,t,i,n,s,r,a,o){const l=t.coords,h=t.colors,c=e.data,d=4*e.width;let u;l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=a,a=u),l[n+1]>l[s+1]&&(u=n,n=s,s=u,u=a,a=o,o=u),l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=a,a=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,_=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY;if(g>=v)return;const b=h[r],y=h[r+1],S=h[r+2],P=h[a],A=h[a+1],w=h[a+2],E=h[o],x=h[o+1],C=h[o+2],M=Math.round(g),T=Math.round(v);let D,F,k,L,R,I,O,N;for(let e=M;e<=T;e++){if(e<m){const t=e<g?0:(g-e)/(g-m);D=p-(p-f)*t,F=b-(b-P)*t,k=y-(y-A)*t,L=S-(S-w)*t}else{let t;t=e>v?1:m===v?0:(m-e)/(m-v),D=f-(f-_)*t,F=P-(P-E)*t,k=A-(A-x)*t,L=w-(w-C)*t}let t;t=e<g?0:e>v?1:(g-e)/(g-v),R=p-(p-_)*t,I=b-(b-E)*t,O=y-(y-x)*t,N=S-(S-C)*t;const i=Math.round(Math.min(D,R)),n=Math.round(Math.max(D,R));let s=d*e+4*i;for(let e=i;e<=n;e++)t=(D-e)/(D-R),t<0?t=0:t>1&&(t=1),c[s++]=F-(F-I)*t|0,c[s++]=k-(k-O)*t|0,c[s++]=L-(L-N)*t|0,c[s++]=255}}function c(e,t,i){const n=t.coords,s=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(n.length/o)-1,c=o-1;for(r=0;r<l;r++){let t=r*o;for(let r=0;r<c;r++,t++)h(e,i,n[t],n[t+1],n[t+o],s[t],s[t+1],s[t+o]),h(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(r=0,a=n.length;r<a;r+=3)h(e,i,n[r],n[r+1],n[r+2],s[r],s[r+1],s[r+2]);break;default:throw new Error("illegal figure")}}class d extends o{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]),r=Math.ceil(this._bounds[2])-n,a=Math.ceil(this._bounds[3])-s,o=Math.min(Math.ceil(Math.abs(r*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*e[1]*1.1)),3e3),h=r/o,d=a/l,u={coords:this._coords,colors:this._colors,offsetX:-n,offsetY:-s,scaleX:1/h,scaleY:1/d},p=o+4,g=l+4,f=i.getCanvas("mesh",p,g,!1),m=f.context,_=m.createImageData(o,l);if(t){const e=_.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)c(_,e,u);return m.putImageData(_,2,2),{canvas:f.canvas,offsetX:n-2*h,offsetY:s-2*d,scaleX:h,scaleY:d}}getPattern(e,t,i,o){let l;if(a(e,this._bbox),o===r.SHADING)l=n.Util.singularValueDecompose2dScale((0,s.getCurrentTransform)(e));else if(l=n.Util.singularValueDecompose2dScale(t.baseTransform),this.matrix){const e=n.Util.singularValueDecompose2dScale(this.matrix);l=[l[0]*e[0],l[1]*e[1]]}const h=this._createMeshCanvas(l,o===r.SHADING?null:this._background,t.cachedCanvases);return o!==r.SHADING&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(h.offsetX,h.offsetY),e.scale(h.scaleX,h.scaleY),e.createPattern(h.canvas,"no-repeat")}}class u extends o{getPattern(){return"hotpink"}}const p=1,g=2;class f{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,r=this.xstep,a=this.ystep,o=this.paintType,l=this.tilingType,h=this.color,c=this.canvasGraphicsFactory;(0,n.info)("TilingType: "+l);const d=i[0],u=i[1],p=i[2],g=i[3],f=n.Util.singularValueDecompose2dScale(this.matrix),m=n.Util.singularValueDecompose2dScale(this.baseTransform),_=[f[0]*m[0],f[1]*m[1]],v=this.getSizeAndScale(r,this.ctx.canvas.width,_[0]),b=this.getSizeAndScale(a,this.ctx.canvas.height,_[1]),y=e.cachedCanvases.getCanvas("pattern",v.size,b.size,!0),S=y.context,P=c.createCanvasGraphics(S);P.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(P,o,h);let A=d,w=u,E=p,x=g;return d<0&&(A=0,E+=Math.abs(d)),u<0&&(w=0,x+=Math.abs(u)),S.translate(-v.scale*A,-b.scale*w),P.transform(v.scale,0,0,b.scale,0,0),S.save(),this.clipBbox(P,A,w,E,x),P.baseTransform=(0,s.getCurrentTransform)(P.ctx),P.executeOperatorList(t),P.endDrawing(),{canvas:y.canvas,scaleX:v.scale,scaleY:b.scale,offsetX:A,offsetY:w}}getSizeAndScale(e,t,i){e=Math.abs(e);const n=Math.max(f.MAX_PATTERN_SIZE,t);let s=Math.ceil(e*i);return s>=n?s=n:i=s/e,{scale:i,size:s}}clipBbox(e,t,i,n,r){const a=n-t,o=r-i;e.ctx.rect(t,i,a,o),e.current.updateRectMinMax((0,s.getCurrentTransform)(e.ctx),[t,i,n,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,i){const s=e.ctx,r=e.current;switch(t){case p:const e=this.ctx;s.fillStyle=e.fillStyle,s.strokeStyle=e.strokeStyle,r.fillColor=e.fillStyle,r.strokeColor=e.strokeStyle;break;case g:const a=n.Util.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,r.fillColor=a,r.strokeColor=a;break;default:throw new n.FormatError(`Unsupported paint type: ${t}`)}}getPattern(e,t,i,s){let a=i;s!==r.SHADING&&(a=n.Util.transform(a,t.baseTransform),this.matrix&&(a=n.Util.transform(a,this.matrix)));const o=this.createPatternCanvas(t);let l=new DOMMatrix(a);l=l.translate(o.offsetX,o.offsetY),l=l.scale(1/o.scaleX,1/o.scaleY);const h=e.createPattern(o.canvas,"repeat");return h.setTransform(l),h}}t.TilingPattern=f},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.convertBlackAndWhiteToRGBA=s,t.convertToRGBA=function(e){switch(e.kind){case n.ImageKind.GRAYSCALE_1BPP:return s(e);case n.ImageKind.RGB_24BPP:return function({src:e,srcPos:t=0,dest:i,destPos:s=0,width:r,height:a}){let o=0;const l=e.length>>2,h=new Uint32Array(e.buffer,t,l);if(n.FeatureTest.isLittleEndian){for(;o<l-2;o+=3,s+=4){const e=h[o],t=h[o+1],n=h[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=h[o],t=h[o+1],n=h[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(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 s({src:e,srcPos:t=0,dest:i,width:s,height:r,nonBlackColor:a=4294967295,inverseDecode:o=!1}){const l=n.FeatureTest.isLittleEndian?4278190080:255,[h,c]=o?[a,l]:[l,a],d=s>>3,u=7&s,p=e.length;i=new Uint32Array(i.buffer);let g=0;for(let n=0;n<r;n++){for(const n=t+d;t<n;t++){const n=t<p?e[t]:255;i[g++]=128&n?c:h,i[g++]=64&n?c:h,i[g++]=32&n?c:h,i[g++]=16&n?c:h,i[g++]=8&n?c:h,i[g++]=4&n?c:h,i[g++]=2&n?c:h,i[g++]=1&n?c:h}if(0===u)continue;const n=t<p?e[t++]:255;for(let e=0;e<u;e++)i[g++]=n&1<<7-e?c:h}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,r=2,a=1,o=2,l=3,h=4,c=5,d=6,u=7,p=8;function g(e){switch(e instanceof Error||"object"==typeof e&&null!==e||(0,n.unreachable)('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),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{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)return void this.#dt(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===s)i.resolve(t.data);else{if(t.callback!==r)throw new Error("Unexpected callback case");i.reject(g(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,a=t.sourceName;new Promise((function(e){e(n(t.data))})).then((function(n){i.postMessage({sourceName:e,targetName:a,callback:s,callbackId:t.callbackId,data:n})}),(function(n){i.postMessage({sourceName:e,targetName:a,callback:r,callbackId:t.callbackId,reason:g(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++,r=new n.PromiseCapability;this.callbackCapabilities[s]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:s,data:t},i)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,i,s){const r=this.streamId++,o=this.sourceName,l=this.targetName,h=this.comObj;return new ReadableStream({start:i=>{const a=new n.PromiseCapability;return this.streamControllers[r]={controller:i,startCall:a,pullCall:null,cancelCall:null,isClosed:!1},h.postMessage({sourceName:o,targetName:l,action:e,streamId:r,data:t,desiredSize:i.desiredSize},s),a.promise},pull:e=>{const t=new n.PromiseCapability;return this.streamControllers[r].pullCall=t,h.postMessage({sourceName:o,targetName:l,stream:d,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{(0,n.assert)(e instanceof Error,"cancel must have a valid reason");const t=new n.PromiseCapability;return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,h.postMessage({sourceName:o,targetName:l,stream:a,streamId:r,reason:g(e)}),t.promise}},i)}#ut(e){const t=e.streamId,i=this.sourceName,s=e.sourceName,r=this.comObj,a=this,o=this.actionHandler[e.action],d={enqueue(e,a=1,o){if(this.isCancelled)return;const l=this.desiredSize;this.desiredSize-=a,l>0&&this.desiredSize<=0&&(this.sinkCapability=new n.PromiseCapability,this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:s,stream:h,streamId:t,chunk:e},o)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:l,streamId:t}),delete a.streamSinks[t])},error(e){(0,n.assert)(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:s,stream:c,streamId:t,reason:g(e)}))},sinkCapability:new n.PromiseCapability,onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};d.sinkCapability.resolve(),d.ready=d.sinkCapability.promise,this.streamSinks[t]=d,new Promise((function(t){t(o(e.data,d))})).then((function(){r.postMessage({sourceName:i,targetName:s,stream:p,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:s,stream:p,streamId:t,reason:g(e)})}))}#dt(e){const t=e.streamId,i=this.sourceName,s=e.sourceName,r=this.comObj,f=this.streamControllers[t],m=this.streamSinks[t];switch(e.stream){case p:e.success?f.startCall.resolve():f.startCall.reject(g(e.reason));break;case u:e.success?f.pullCall.resolve():f.pullCall.reject(g(e.reason));break;case d:if(!m){r.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,success:!0});break}m.desiredSize<=0&&e.desiredSize>0&&m.sinkCapability.resolve(),m.desiredSize=e.desiredSize,new Promise((function(e){e(m.onPull?.())})).then((function(){r.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:s,stream:u,streamId:t,reason:g(e)})}));break;case h:if((0,n.assert)(f,"enqueue should have stream controller"),f.isClosed)break;f.controller.enqueue(e.chunk);break;case l:if((0,n.assert)(f,"close should have stream controller"),f.isClosed)break;f.isClosed=!0,f.controller.close(),this.#pt(f,t);break;case c:(0,n.assert)(f,"error should have stream controller"),f.controller.error(g(e.reason)),this.#pt(f,t);break;case o:e.success?f.cancelCall.resolve():f.cancelCall.reject(g(e.reason)),this.#pt(f,t);break;case a:if(!m)break;new Promise((function(t){t(m.onCancel?.(g(e.reason)))})).then((function(){r.postMessage({sourceName:i,targetName:s,stream:o,streamId:t,success:!0})}),(function(e){r.postMessage({sourceName:i,targetName:s,stream:o,streamId:t,reason:g(e)})})),m.sinkCapability.reject(g(e.reason)),m.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{#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 r=Symbol("INTERNAL");class a{#mt=!0;constructor(e,t){this.name=e,this.intent=t}get visible(){return this.#mt}_setVisible(e,t){e!==r&&(0,n.unreachable)("Internal method `_setVisible` called."),this.#mt=t}}t.OptionalContentConfig=class{#_t=null;#vt=new Map;#bt=null;#yt=null;constructor(e){if(this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,this.#yt=e.order;for(const t of e.groups)this.#vt.set(t.id,new a(t.name,t.intent));if("OFF"===e.baseState)for(const e of this.#vt.values())e._setVisible(r,!1);for(const t of e.on)this.#vt.get(t)._setVisible(r,!0);for(const t of e.off)this.#vt.get(t)._setVisible(r,!1);this.#bt=this.getHash()}}#St(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 r;if(Array.isArray(t))r=this.#St(t);else{if(!this.#vt.has(t))return(0,n.warn)(`Optional content group not found: ${t}`),!0;r=this.#vt.get(t).visible}switch(i){case"And":if(!r)return!1;break;case"Or":if(r)return!0;break;case"Not":return!r;default:return!0}}return"And"===i}isVisible(e){if(0===this.#vt.size)return!0;if(!e)return(0,n.warn)("Optional content group not defined."),!0;if("OCG"===e.type)return this.#vt.has(e.id)?this.#vt.get(e.id).visible:((0,n.warn)(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#St(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#vt.has(t))return(0,n.warn)(`Optional content group not found: ${t}`),!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))return(0,n.warn)(`Optional content group not found: ${t}`),!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))return(0,n.warn)(`Optional content group not found: ${t}`),!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))return(0,n.warn)(`Optional content group not found: ${t}`),!0;if(this.#vt.get(t).visible)return!1}return!0}return(0,n.warn)(`Unknown optional content policy ${e.policy}.`),!0}return(0,n.warn)(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0){this.#vt.has(e)?(this.#vt.get(e)._setVisible(r,!!t),this.#_t=null):(0,n.warn)(`Optional content group not found: ${e}`)}get hasInitialVisibility(){return null===this.#bt||this.getHash()===this.#bt}getOrder(){return this.#vt.size?this.#yt?this.#yt.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.#_t)return this.#_t;const e=new s.MurmurHash3_64;for(const[t,i]of this.#vt)e.update(`${t}:${i.visible}`);return this.#_t=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{constructor({length:e,initialData:t,progressiveDone:i=!1,contentDispositionFilename:s=null,disableRange:r=!1,disableStream:a=!1},o){if((0,n.assert)(o,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.'),this._queuedChunks=[],this._progressiveDone=i,this._contentDispositionFilename=s,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=!a,this._isRangeSupported=!r,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){return t._begin===e&&(t._enqueue(i),!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;return this._queuedChunks=null,new r(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new a(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}};class r{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){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):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;return this._requests.push(e),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 a{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;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;return this._requests.push(e),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 r(e,t,i){return{method:"GET",headers:e,signal:i.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function a(e){const t=new Headers;for(const i in e){const n=e[i];void 0!==n&&t.append(i,n)}return t}function o(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:((0,n.warn)(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}t.PDFFetchStream=class{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(){return(0,n.assert)(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new l(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=new h(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class l{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=a(this._stream.httpHeaders);const i=t.url;fetch(i,r(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 t=t=>e.headers.get(t),{allowRangeRequests:r,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=(0,s.extractFilenameFromHeader)(t),!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();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:o(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class h{constructor(e,t,i){this._stream=e,this._reader=null,this._loaded=0;const o=e.source;this._withCredentials=o.withCredentials||!1,this._readCapability=new n.PromiseCapability,this._isStreamingSupported=!o.disableStream,this._abortController=new AbortController,this._headers=a(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${i-1}`);const l=o.url;fetch(l,r(this._headers,this._withCredentials,this._abortController)).then((e=>{if(!(0,s.validateResponseStatus)(e.status))throw(0,s.createResponseStatusError)(e.status,l);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();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:o(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createResponseStatusError=function(e,t){return 404===e||0===e&&t.startsWith("file:")?new n.MissingPDFException('Missing PDF "'+t+'".'):new n.UnexpectedResponseException(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)},t.extractFilenameFromHeader=function(e){const t=e("Content-Disposition");if(t){let e=(0,s.getFilenameFromContentDispositionHeader)(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if((0,r.isPdfFile)(e))return e}return null},t.validateRangeRequestCapabilities=function({getResponseHeader:e,isHttp:t,rangeChunkSize:i,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(e("Content-Length"),10);return Number.isInteger(r)?(s.suggestedLength=r,r<=2*i||n||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity")||(s.allowRangeRequests=!0),s):s},t.validateResponseStatus=function(e){return 200===e||206===e};var n=i(1),s=i(21),r=i(6)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getFilenameFromContentDispositionHeader=function(e){let t=!0,i=s("filename\\*","i").exec(e);if(i){i=i[1];let e=o(i);return e=unescape(e),e=l(e),e=h(e),a(e)}if(i=function(e){const t=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(e));){let[,e,n,s]=i;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[n,s]}const r=[];for(let e=0;e<t.length&&e in t;++e){let[i,n]=t[e];n=o(n),i&&(n=unescape(n),0===e&&(n=l(n))),r.push(n)}return r.join("")}(e),i)return a(h(i));if(i=s("filename","i").exec(e),i){i=i[1];let e=o(i);return e=h(e),a(e)}function s(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function r(e,i){if(e){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(e,{fatal:!0}),r=(0,n.stringToBytes)(i);i=s.decode(r),t=!1}catch{}}return i}function a(e){return t&&/[\x80-\xff]/.test(e)&&(e=r("utf-8",e),t&&(e=r("iso-8859-1",e))),e}function o(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const i=t[e].indexOf('"');-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 l(e){const t=e.indexOf("'");return-1===t?e:r(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function h(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 r(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 r(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 r{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)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),n.expectedStatus=206):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),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),4!==s.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===s.status&&this.isHttp)return void i.onError?.(s.status);const r=s.status||200;if((200!==r||206!==i.expectedStatus)&&r!==i.expectedStatus)return void i.onError?.(s.status);const a=function(e){const t=e.response;return"string"!=typeof t?t:(0,n.stringToBytes)(t).buffer}(s);if(206===r){const e=s.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);i.onDone({begin:parseInt(t[1],10),chunk:a})}else a?i.onDone({begin:0,chunk:a}):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{constructor(e){this._source=e,this._manager=new r(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(){return(0,n.assert)(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new a(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const i=new o(this._manager,e,t);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class a{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),i=e=>t.getResponseHeader(e),{allowRangeRequests:n,suggestedLength:r}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=(0,s.extractFilenameFromHeader)(i),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(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;return this._requests.push(e),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 o{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;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):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;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=new n.PromiseCapability;return this._requests.push(e),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 r=/^file:\/\/\/[a-zA-Z]:\//;t.PDFNodeStream=class{constructor(e){this.source=e,this.url=function(e){const t=require$$5,i=t.parse(e);return"file:"===i.protocol||i.host?i:/^[a-z]:[/\\]/i.test(e)?t.parse(`file:///${e}`):(i.host||(i.protocol="file:"),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(){return(0,n.assert)(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new d(this):new h(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const i=this.isFsUrl?new u(this,e,t):new c(this,e,t);return this._rangeRequestReaders.push(i),i}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}};class a{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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=new n.PromiseCapability,this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{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 o{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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=new n.PromiseCapability,this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{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 l(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class h extends a{constructor(e){super(e);const t=t=>{if(404===t.statusCode){const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);return this._storedError=e,void this._headersCapability.reject(e)}this._headersCapability.resolve(),this._setReadableStream(t);const i=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:r,suggestedLength:a}=(0,s.validateRangeRequestCapabilities)({getResponseHeader:i,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=r,this._contentLength=a||this._contentLength,this._filename=(0,s.extractFilenameFromHeader)(i)};if(this._request=null,"http:"===this._url.protocol){const i=require$$5;this._request=i.request(l(this._url,e.httpHeaders),t)}else{const i=require$$5;this._request=i.request(l(this._url,e.httpHeaders),t)}this._request.on("error",(e=>{this._storedError=e,this._headersCapability.reject(e)})),this._request.end()}}class c extends o{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 s=e=>{if(404!==e.statusCode)this._setReadableStream(e);else{const e=new n.MissingPDFException(`Missing PDF "${this._url}".`);this._storedError=e}};if(this._request=null,"http:"===this._url.protocol){const e=require$$5;this._request=e.request(l(this._url,this._httpHeaders),s)}else{const e=require$$5;this._request=e.request(l(this._url,this._httpHeaders),s)}this._request.on("error",(e=>{this._storedError=e})),this._request.end()}}class d extends a{constructor(e){super(e);let t=decodeURIComponent(this._url.path);r.test(this._url.href)&&(t=t.replace(/^\//,""));const i=require$$5;i.lstat(t,((e,s)=>{if(e)return"ENOENT"===e.code&&(e=new n.MissingPDFException(`Missing PDF "${t}".`)),this._storedError=e,void this._headersCapability.reject(e);this._contentLength=s.size,this._setReadableStream(i.createReadStream(t)),this._headersCapability.resolve()}))}}class u extends o{constructor(e,t,i){super(e);let n=decodeURIComponent(this._url.path);r.test(this._url.href)&&(n=n.replace(/^\//,""));const s=require$$5;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 r="normal",a="normal",o="#000000",l=["butt","round","square"],h=["miter","round","bevel"],c=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 r=255&e[t],a=255&e[t+1],o=255&e[t+2];s+=n[r>>2]+n[(3&r)<<4|a>>4]+n[t+1<i?(15&a)<<2|o>>6:64]+n[t+2<i?63&o:64]}return s},d=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 i(e,i,n,s){let r=s;const a=i.length;n[r]=a>>24&255,n[r+1]=a>>16&255,n[r+2]=a>>8&255,n[r+3]=255&a,r+=4,n[r]=255&e.charCodeAt(0),n[r+1]=255&e.charCodeAt(1),n[r+2]=255&e.charCodeAt(2),n[r+3]=255&e.charCodeAt(3),r+=4,n.set(i,r),r+=i.length;const o=function(e,i,n){let s=-1;for(let r=i;r<n;r++){const i=255&(s^e[r]);s=s>>>8^t[i]}return-1^s}(n,s+4,r);n[r]=o>>24&255,n[r+1]=o>>16&255,n[r+2]=o>>8&255,n[r+3]=255&o}function n(e){let t=e.length;const i=65535,n=Math.ceil(t/i),s=new Uint8Array(2+t+5*n+4);let r=0;s[r++]=120,s[r++]=156;let a=0;for(;t>i;)s[r++]=0,s[r++]=255,s[r++]=255,s[r++]=0,s[r++]=0,s.set(e.subarray(a,a+i),r),r+=i,a+=i,t-=i;s[r++]=1,s[r++]=255&t,s[r++]=t>>8&255,s[r++]=255&~t,s[r++]=(65535&~t)>>8&255,s.set(e.subarray(a),r),r+=e.length-a;const o=function(e,t,i){let n=1,s=0;for(let r=t;r<i;++r)n=(n+(255&e[r]))%65521,s=(s+n)%65521;return s<<16|n}(e,0,e.length);return s[r++]=o>>24&255,s[r++]=o>>16&255,s[r++]=o>>8&255,s[r++]=255&o,s}function r(t,r,a,o){const l=t.width,h=t.height;let d,u,p;const g=t.data;switch(r){case s.ImageKind.GRAYSCALE_1BPP:u=0,d=1,p=l+7>>3;break;case s.ImageKind.RGB_24BPP:u=2,d=8,p=3*l;break;case s.ImageKind.RGBA_32BPP:u=6,d=8,p=4*l;break;default:throw new Error("invalid format")}const f=new Uint8Array((1+p)*h);let m=0,_=0;for(let e=0;e<h;++e)f[m++]=0,f.set(g.subarray(_,_+p),m),_+=p,m+=p;if(r===s.ImageKind.GRAYSCALE_1BPP&&o){m=0;for(let e=0;e<h;e++){m++;for(let e=0;e<p;e++)f[m++]^=255}}const v=new Uint8Array([l>>24&255,l>>16&255,l>>8&255,255&l,h>>24&255,h>>16&255,h>>8&255,255&h,d,u,0,0,0]),b=function(e){if(!s.isNodeJS)return n(e);try{const t=parseInt(process.versions.node)>=8?e:Buffer.from(e),i=require$$5.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 n(e)}(f),y=e.length+36+v.length+b.length,S=new Uint8Array(y);let P=0;return S.set(e,P),P+=e.length,i("IHDR",v,S,P),P+=12+v.length,i("IDATA",b,S,P),P+=12+b.length,i("IEND",new Uint8Array(0),S,P),c(S,"image/png",a)}return function(e,t,i){return r(e,void 0===e.kind?s.ImageKind.GRAYSCALE_1BPP:e.kind,t,i)}}();class u{constructor(){this.fontSizeScale=1,this.fontWeight=a,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 p(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 g(e){if(0===e[4]&&0===e[5]){if(0===e[1]&&0===e[2])return 1===e[0]&&1===e[3]?"":`scale(${p(e[0])} ${p(e[3])})`;if(e[0]===e[3]&&e[1]===-e[2])return`rotate(${p(180*Math.acos(e[0])/Math.PI)})`}else if(1===e[0]&&0===e[1]&&0===e[2]&&1===e[3])return`translate(${p(e[4])} ${p(e[5])})`;return`matrix(${p(e[0])} ${p(e[1])} ${p(e[2])} ${p(e[3])} ${p(e[4])} ${p(e[5])})`}let f=0,m=0,_=0;t.SVGGraphics=class{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 u,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,r,a){const o=[e,t,i,n,r,a];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)),i)))}convertOpList(e){const t=this._operatorIdMapping,i=e.argsArray,n=e.fnArray,s=[];for(let e=0,r=n.length;e<r;e++){const r=n[e];s.push({fnId:r,fn:t[r],args:i[e]})}return function(e){let t=[];const i=[];for(const n of e)"save"!==n.fn?"restore"===n.fn?t=i.pop():t.push(n):(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,r){const a=this.current;a.textMatrix=a.lineMatrix=[e,t,i,n,s,r],a.textMatrixScale=Math.hypot(e,t),a.x=a.lineX=0,a.y=a.lineY=0,a.xcoords=[],a.ycoords=[],a.tspan=this.svgFactory.createElement("svg:tspan"),a.tspan.setAttributeNS(null,"font-family",a.fontFamily),a.tspan.setAttributeNS(null,"font-size",`${p(a.fontSize)}px`),a.tspan.setAttributeNS(null,"y",p(-a.y)),a.txtElement=this.svgFactory.createElement("svg:text"),a.txtElement.append(a.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",`${p(i.fontSize)}px`),i.tspan.setAttributeNS(null,"y",p(-i.y))}showText(e){const t=this.current,i=t.font,n=t.fontSize;if(0===n)return;const l=t.fontSizeScale,h=t.charSpacing,c=t.wordSpacing,d=t.fontDirection,u=t.textHScale*d,f=i.vertical,m=f?1:-1,_=i.defaultVMetrics,v=n*t.fontMatrix[0];let b=0;for(const s of e){if(null===s){b+=d*c;continue}if("number"==typeof s){b+=m*s*n/1e3;continue}const e=(s.isSpace?c:0)+h,r=s.fontChar;let a,o,u=s.width;if(f){let e;const t=s.vmetric||_;e=s.vmetric?t[1]:.5*u,e=-e*v;const i=t[2]*v;u=t?-t[0]:u,a=e/l,o=(b+i)/l}else a=b/l,o=0;(s.isInFont||i.missingFile)&&(t.xcoords.push(t.x+a),f&&t.ycoords.push(-t.y+o),t.tspan.textContent+=r),b+=f?u*v-e*d:u*v+e*d}t.tspan.setAttributeNS(null,"x",t.xcoords.map(p).join(" ")),f?t.tspan.setAttributeNS(null,"y",t.ycoords.map(p).join(" ")):t.tspan.setAttributeNS(null,"y",p(-t.y)),f?t.y-=b:t.x+=b*u,t.tspan.setAttributeNS(null,"font-family",t.fontFamily),t.tspan.setAttributeNS(null,"font-size",`${p(t.fontSize)}px`),t.fontStyle!==r&&t.tspan.setAttributeNS(null,"font-style",t.fontStyle),t.fontWeight!==a&&t.tspan.setAttributeNS(null,"font-weight",t.fontWeight);const y=t.textRenderingMode&s.TextRenderingMode.FILL_STROKE_MASK;if(y===s.TextRenderingMode.FILL||y===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)):t.textRenderingMode===s.TextRenderingMode.ADD_TO_PATH?t.tspan.setAttributeNS(null,"fill","transparent"):t.tspan.setAttributeNS(null,"fill","none"),y===s.TextRenderingMode.STROKE||y===s.TextRenderingMode.FILL_STROKE){const e=1/(t.textMatrixScale||1);this._setStrokeAttributes(t.tspan,e)}let S=t.textMatrix;0!==t.textRise&&(S=S.slice(),S[5]+=t.textRise),t.txtElement.setAttributeNS(null,"transform",`${g(S)} scale(${p(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.');this.cssStyle||(this.cssStyle=this.svgFactory.createElement("svg:style"),this.cssStyle.setAttributeNS(null,"type","text/css"),this.defs.append(this.cssStyle));const t=c(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,!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 r="normal";i.black?r="900":i.bold&&(r="bold");const a=i.italic?"italic":"normal";n<0?(n=-n,t.fontDirection=-1):t.fontDirection=1,t.fontSize=n,t.fontFamily=i.loadedName,t.fontWeight=r,t.fontStyle=a,t.tspan=this.svgFactory.createElement("svg:tspan"),t.tspan.setAttributeNS(null,"y",p(-t.y)),t.xcoords=[],t.ycoords=[]}endText(){const e=this.current;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=h[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),[r,a,o,l]=s.Util.getAxialAlignedBoundingBox([0,0,t,i],n),h=this.svgFactory.createElement("svg:rect");h.setAttributeNS(null,"x",r),h.setAttributeNS(null,"y",a),h.setAttributeNS(null,"width",o-r),h.setAttributeNS(null,"height",l-a),h.setAttributeNS(null,"fill",this._makeShadingPattern(e)),this.current.fillAlpha<1&&h.setAttributeNS(null,"fill-opacity",this.current.fillAlpha),this._ensureTransformGroup().append(h)}_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,[r,a,o,l]=e[4],h=e[5],c=e[6],d=e[7],u="shading"+_++,[p,g,f,m]=s.Util.normalizeRect([...s.Util.applyTransform([r,a],n),...s.Util.applyTransform([o,l],n)]),[v,b]=s.Util.singularValueDecompose2dScale(n),y=h*v,S=c*b,P=this.svgFactory.createElement("svg:pattern");P.setAttributeNS(null,"id",u),P.setAttributeNS(null,"patternUnits","userSpaceOnUse"),P.setAttributeNS(null,"width",y),P.setAttributeNS(null,"height",S),P.setAttributeNS(null,"x",`${p}`),P.setAttributeNS(null,"y",`${g}`);const A=this.svg,w=this.transformMatrix,E=this.current.fillColor,x=this.current.strokeColor,C=this.svgFactory.create(f-p,m-g);if(this.svg=C,this.transformMatrix=n,2===d){const e=s.Util.makeHexColor(...t);this.current.fillColor=e,this.current.strokeColor=e}return this.executeOpTree(this.convertOpList(i)),this.svg=A,this.transformMatrix=w,this.current.fillColor=E,this.current.strokeColor=x,P.append(C.childNodes[0]),this.defs.append(P),`url(#${u})`}_makeShadingPattern(e){switch("string"==typeof e&&(e=this.objs.get(e)),e[0]){case"RadialAxial":const t="shading"+_++,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 r=e[4],a=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",a[0]),n.setAttributeNS(null,"cy",a[1]),n.setAttributeNS(null,"r",l),n.setAttributeNS(null,"fx",r[0]),n.setAttributeNS(null,"fy",r[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)}return this.defs.append(n),`url(#${t})`;case"Mesh":return(0,s.warn)("Unimplemented pattern Mesh"),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,r=i.y,a=[],o=0;for(const i of e)switch(0|i){case s.OPS.rectangle:n=t[o++],r=t[o++];const e=n+t[o++],i=r+t[o++];a.push("M",p(n),p(r),"L",p(e),p(r),"L",p(e),p(i),"L",p(n),p(i),"Z");break;case s.OPS.moveTo:n=t[o++],r=t[o++],a.push("M",p(n),p(r));break;case s.OPS.lineTo:n=t[o++],r=t[o++],a.push("L",p(n),p(r));break;case s.OPS.curveTo:n=t[o+4],r=t[o+5],a.push("C",p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3]),p(n),p(r)),o+=6;break;case s.OPS.curveTo2:a.push("C",p(n),p(r),p(t[o]),p(t[o+1]),p(t[o+2]),p(t[o+3])),n=t[o+2],r=t[o+3],o+=4;break;case s.OPS.curveTo3:n=t[o+2],r=t[o+3],a.push("C",p(t[o]),p(t[o+1]),p(n),p(r),p(n),p(r)),o+=4;break;case s.OPS.closePath:a.push("Z")}a=a.join(" "),i.path&&e.length>0&&e[0]!==s.OPS.rectangle&&e[0]!==s.OPS.moveTo?a=i.path.getAttributeNS(null,"d")+a:(i.path=this.svgFactory.createElement("svg:path"),this._ensureTransformGroup().append(i.path)),i.path.setAttributeNS(null,"d",a),i.path.setAttributeNS(null,"fill","none"),i.element=i.path,i.setCurrentPoint(n,r)}endPath(){const e=this.current;if(e.path=null,!this.pendingClip)return;if(!e.element)return void(this.pendingClip=null);const t="clippath"+f++,i=this.svgFactory.createElement("svg:clipPath");i.setAttributeNS(null,"id",t),i.setAttributeNS(null,"transform",g(this.transformMatrix));const n=e.element.cloneNode(!0);if("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),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;e.element&&(e.element.setAttributeNS(null,"fill",e.fillColor),e.element.setAttributeNS(null,"fill-opacity",e.fillAlpha),this.endPath())}stroke(){const e=this.current;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",p(i.miterLimit)),e.setAttributeNS(null,"stroke-linecap",i.lineCap),e.setAttributeNS(null,"stroke-linejoin",i.lineJoin),e.setAttributeNS(null,"stroke-width",p(t*i.lineWidth)+"px"),e.setAttributeNS(null,"stroke-dasharray",n.map(p).join(" ")),e.setAttributeNS(null,"stroke-dashoffset",p(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=d(e,this.forceDataSchema,!!t),r=this.svgFactory.createElement("svg:rect");r.setAttributeNS(null,"x","0"),r.setAttributeNS(null,"y","0"),r.setAttributeNS(null,"width",p(i)),r.setAttributeNS(null,"height",p(n)),this.current.element=r,this.clip("nonzero");const a=this.svgFactory.createElement("svg:image");a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",s),a.setAttributeNS(null,"x","0"),a.setAttributeNS(null,"y",p(-n)),a.setAttributeNS(null,"width",p(i)+"px"),a.setAttributeNS(null,"height",p(n)+"px"),a.setAttributeNS(null,"transform",`scale(${p(1/i)} ${p(-1/n)})`),t?t.append(a):this._ensureTransformGroup().append(a)}paintImageMaskXObject(e){const t=this.getObject(e.data,e);if(t.bitmap)return void(0,s.warn)("paintImageMaskXObject: ImageBitmap support is not implemented, ensure that the `isOffscreenCanvasSupported` API parameter is disabled.");const i=this.current,n=t.width,r=t.height,a=i.fillColor;i.maskId="mask"+m++;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",p(n)),l.setAttributeNS(null,"height",p(r)),l.setAttributeNS(null,"fill",a),l.setAttributeNS(null,"mask",`url(#${i.maskId})`),this.defs.append(o),this._ensureTransformGroup().append(l),this.paintInlineImageXObject(t,o)}paintFormXObjectBegin(e,t){if(Array.isArray(e)&&6===e.length&&this.transform(e[0],e[1],e[2],e[3],e[4],e[5]),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",p(e)),n.setAttributeNS(null,"height",p(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");return n.setAttributeNS(null,"transform",g(e.transform)),t.append(n),this.svg=n,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(){return this.tgrp||(this.tgrp=this.svgFactory.createElement("svg:g"),this.tgrp.setAttributeNS(null,"transform",g(this.transformMatrix)),this.current.activeClipUrl?this._ensureClipGroup().append(this.tgrp):this.svg.append(this.tgrp)),this.tgrp}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaText=void 0;class i{static textContent(e){const t=[],n={items:t,styles:Object.create(null)};return function e(n){if(!n)return;let s=null;const r=n.name;if("#text"===r)s=n.value;else{if(!i.shouldBuildText(r))return;n?.attributes?.textContent?s=n.attributes.textContent:n.value&&(s=n.value)}if(null!==s&&t.push({str:s}),n.children)for(const t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}t.XfaText=i},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextLayerRenderTask=void 0,t.renderTextLayer=function(e){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),r=n.getPropertyValue("visibility"),a=parseFloat(n.getPropertyValue("--scale-factor"));"visible"===r&&(!a||Math.abs(a-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 d(e);return o._render(),o},t.updateTextLayer=function({container:e,viewport:t,textDivs:i,textDivProperties:n,isOffscreenCanvasSupported:r,mustRotate:a=!0,mustRescale:o=!0}){if(a&&(0,s.setLayerDimensions)(e,{rotation:t.rotation}),o){const e=l(0,r),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,c(s)}};var n=i(1),s=i(6);const r=30,a=.8,o=new Map;function l(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 h(e,t,i){const s=document.createElement("span"),h={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};e._textDivs.push(s);const c=n.Util.transform(e._transform,t.transform);let d=Math.atan2(c[1],c[0]);const u=i[t.fontName];u.vertical&&(d+=Math.PI/2);const p=Math.hypot(c[2],c[3]),g=p*function(e,t){const i=o.get(e);if(i)return i;const n=l(r,t);n.font=`${r}px ${e}`;const s=n.measureText("");let h=s.fontBoundingBoxAscent,c=Math.abs(s.fontBoundingBoxDescent);if(h){const t=h/(h+c);return o.set(e,t),n.canvas.width=n.canvas.height=0,t}n.strokeStyle="red",n.clearRect(0,0,r,r),n.strokeText("g",0,0);let d=n.getImageData(0,0,r,r).data;c=0;for(let e=d.length-1-3;e>=0;e-=4)if(d[e]>0){c=Math.ceil(e/4/r);break}n.clearRect(0,0,r,r),n.strokeText("A",0,r),d=n.getImageData(0,0,r,r).data,h=0;for(let e=0,t=d.length;e<t;e+=4)if(d[e]>0){h=r-Math.floor(e/4/r);break}if(n.canvas.width=n.canvas.height=0,h){const t=h/(h+c);return o.set(e,t),t}return o.set(e,a),a}(u.fontFamily,e._isOffscreenCanvasSupported);let f,m;0===d?(f=c[4],m=c[5]-g):(f=c[4]+g*Math.sin(d),m=c[5]-g*Math.cos(d));const _="calc(var(--scale-factor)*",v=s.style;e._container===e._rootContainer?(v.left=`${(100*f/e._pageWidth).toFixed(2)}%`,v.top=`${(100*m/e._pageHeight).toFixed(2)}%`):(v.left=`${_}${f.toFixed(2)}px)`,v.top=`${_}${m.toFixed(2)}px)`),v.fontSize=`${_}${p.toFixed(2)}px)`,v.fontFamily=u.fontFamily,h.fontSize=p,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,e._fontInspectorEnabled&&(s.dataset.fontName=t.fontName),0!==d&&(h.angle=d*(180/Math.PI));let b=!1;if(t.str.length>1)b=!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&&(b=!0)}b&&(h.canvasWidth=u.vertical?t.height:t.width),e._textDivProperties.set(s,h),e._isReadableStream&&e._layoutText(s)}function c(e){const{div:t,scale:i,properties:n,ctx:s,prevFontSize:r,prevFontFamily:a}=e,{style:o}=t;let l="";if(0!==n.canvasWidth&&n.hasText){const{fontFamily:h}=o,{canvasWidth:c,fontSize:d}=n;r===d&&a===h||(s.font=`${d*i}px ${h}`,e.prevFontSize=d,e.prevFontFamily=h);const{width:u}=s.measureText(t.textContent);u>0&&(l=`scaleX(${c*i/u})`)}0!==n.angle&&(l=`rotate(${n.angle}deg) ${l}`),l.length>0&&(o.transform=l)}class d{constructor({textContentSource:e,container:t,viewport:i,textDivs:r,textDivProperties:a,textContentItemsStr:o,isOffscreenCanvasSupported:h}){this._textContentSource=e,this._isReadableStream=e instanceof ReadableStream,this._container=this._rootContainer=t,this._textDivs=r||[],this._textContentItemsStr=o||[],this._isOffscreenCanvasSupported=h,this._fontInspectorEnabled=!!globalThis.FontInspector?.enabled,this._reader=null,this._textDivProperties=a||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:l(0,h)};const{pageWidth:c,pageHeight:d,pageX:u,pageY:p}=i.rawDims;this._transform=[1,0,0,-1,-u,p+d],this._pageWidth=c,this._pageHeight=d,(0,s.setLayerDimensions)(t,i),this._capability.promise.finally((()=>{this._layoutTextParams=null})).catch((()=>{}))}get promise(){return this._capability.promise}cancel(){this._canceled=!0,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),h(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);if(this._layoutTextParams.div=e,c(this._layoutTextParams),t.hasText&&this._container.append(e),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 i=()=>{this._reader.read().then((({value:n,done:s})=>{s?e.resolve():(Object.assign(t,n.styles),this._processItems(n.items,t),i())}),e.reject)};this._reader=this._textContentSource.getReader(),i()}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(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=d},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.AnnotationEditorLayer=void 0;var n=i(1),s=i(4),r=i(28),a=i(33),o=i(6),l=i(34);class h{#Pt;#At=!1;#wt=null;#Et=this.pointerup.bind(this);#xt=this.pointerdown.bind(this);#Ct=new Map;#Mt=!1;#Tt=!1;#Dt=!1;#Ft;static _initialized=!1;constructor({uiManager:e,pageIndex:t,div:i,accessibilityManager:n,annotationLayer:s,viewport:o,l10n:c}){const d=[r.FreeTextEditor,a.InkEditor,l.StampEditor];if(!h._initialized){h._initialized=!0;for(const e of d)e.initialize(c)}e.registerEditorTypes(d),this.#Ft=e,this.pageIndex=t,this.div=i,this.#Pt=n,this.#wt=s,this.viewport=o,this.#Ft.addLayer(this)}get isEmpty(){return 0===this.#Ct.size}updateToolbar(e){this.#Ft.updateToolbar(e)}updateMode(e=this.#Ft.getMode()){this.#kt(),e===n.AnnotationEditorType.INK?(this.addInkEditorIfNeeded(!1),this.disableClick()):this.enableClick(),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.#Ft.getMode()===n.AnnotationEditorType.INK){if(!e)for(const e of this.#Ct.values())if(e.isEmpty())return void e.setInBackground();this.#Lt({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){this.#Ft.setEditingState(e)}addCommands(e){this.#Ft.addCommands(e)}enable(){this.div.style.pointerEvents="auto";const e=new Set;for(const t of this.#Ct.values())t.enableEditing(),t.annotationElementId&&e.add(t.annotationElementId);if(!this.#wt)return;const t=this.#wt.getEditableAnnotations();for(const i of t){if(i.hide(),this.#Ft.isDeletedAnnotationElement(i.data.id))continue;if(e.has(i.data.id))continue;const t=this.deserialize(i);t&&(this.addOrRebuild(t),t.enableEditing())}}disable(){this.#Dt=!0,this.div.style.pointerEvents="none";const e=new Set;for(const t of this.#Ct.values())t.disableEditing(),t.annotationElementId&&null===t.serialize()?(this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.add(t.annotationElementId);if(this.#wt){const t=this.#wt.getEditableAnnotations();for(const i of t){const{id:t}=i.data;e.has(t)||this.#Ft.isDeletedAnnotationElement(t)||i.show()}}this.#kt(),this.isEmpty&&(this.div.hidden=!0),this.#Dt=!1}getEditableAnnotation(e){return this.#wt?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#Ft.getActive()!==e&&this.#Ft.setActiveEditor(e)}enableClick(){this.div.addEventListener("pointerdown",this.#xt),this.div.addEventListener("pointerup",this.#Et)}disableClick(){this.div.removeEventListener("pointerdown",this.#xt),this.div.removeEventListener("pointerup",this.#Et)}attach(e){this.#Ct.set(e.id,e);const{annotationElementId:t}=e;t&&this.#Ft.isDeletedAnnotationElement(t)&&this.#Ft.removeDeletedAnnotationElement(e)}detach(e){this.#Ct.delete(e.id),this.#Pt?.removePointerInTextLayer(e.contentDiv),!this.#Dt&&e.annotationElementId&&this.#Ft.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#Ft.removeEditor(e),e.div.contains(document.activeElement)&&setTimeout((()=>{this.#Ft.focusMainContainer()}),0),e.div.remove(),e.isAttachedToDOM=!1,this.#Tt||this.addInkEditorIfNeeded(!1)}changeParent(e){e.parent!==this&&(e.annotationElementId&&(this.#Ft.addDeletedAnnotationElement(e.annotationElementId),s.AnnotationEditor.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(this.changeParent(e),this.#Ft.addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),this.#Ft.addToAnnotationStorage(e)}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&(e._focusEventsAllowed=!1,setTimeout((()=>{e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0}),t.focus())}),0)),e._structTreeParentId=this.#Pt?.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.#Ft.getId()}#Rt(e){switch(this.#Ft.getMode()){case n.AnnotationEditorType.FREETEXT:return new r.FreeTextEditor(e);case n.AnnotationEditorType.INK:return new a.InkEditor(e);case n.AnnotationEditorType.STAMP:return new l.StampEditor(e)}return null}pasteEditor(e,t){this.#Ft.updateToolbar(e),this.#Ft.updateMode(e);const{offsetX:i,offsetY:n}=this.#It(),s=this.getNextId(),r=this.#Rt({parent:this,id:s,x:i,y:n,uiManager:this.#Ft,isCentered:!0,...t});r&&this.add(r)}deserialize(e){switch(e.annotationType??e.annotationEditorType){case n.AnnotationEditorType.FREETEXT:return r.FreeTextEditor.deserialize(e,this,this.#Ft);case n.AnnotationEditorType.INK:return a.InkEditor.deserialize(e,this,this.#Ft);case n.AnnotationEditorType.STAMP:return l.StampEditor.deserialize(e,this,this.#Ft)}return null}#Lt(e,t){const i=this.getNextId(),n=this.#Rt({parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:this.#Ft,isCentered:t});return n&&this.add(n),n}#It(){const{x:e,y:t,width:i,height:n}=this.div.getBoundingClientRect(),s=Math.max(0,e),r=Math.max(0,t),a=(s+Math.min(window.innerWidth,e+i))/2-e,o=(r+Math.min(window.innerHeight,t+n))/2-t,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.#Lt(this.#It(),!0)}setSelected(e){this.#Ft.setSelected(e)}toggleSelected(e){this.#Ft.toggleSelected(e)}isSelected(e){return this.#Ft.isSelected(e)}unselect(e){this.#Ft.unselect(e)}pointerup(e){const{isMac:t}=n.FeatureTest.platform;0!==e.button||e.ctrlKey&&t||e.target===this.div&&this.#Mt&&(this.#Mt=!1,this.#At?this.#Ft.getMode()!==n.AnnotationEditorType.STAMP?this.#Lt(e,!1):this.#Ft.unselectAll():this.#At=!0)}pointerdown(e){if(this.#Mt)return void(this.#Mt=!1);const{isMac:t}=n.FeatureTest.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;this.#Mt=!0;const i=this.#Ft.getActive();this.#At=!i||i.isEmpty()}findNewParent(e,t,i){const n=this.#Ft.findParent(t,i);return null!==n&&n!==this&&(n.changeParent(e),!0)}destroy(){this.#Ft.getActive()?.parent===this&&(this.#Ft.commitOrRemove(),this.#Ft.setActiveEditor(null));for(const e of this.#Ct.values())this.#Pt?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#Ct.clear(),this.#Ft.removeLayer(this)}#kt(){this.#Tt=!0;for(const e of this.#Ct.values())e.isEmpty()&&e.remove();this.#Tt=!1}render({viewport:e}){this.viewport=e,(0,o.setLayerDimensions)(this.div,e);for(const e of this.#Ft.getEditors(this.pageIndex))this.add(e);this.updateMode()}update({viewport:e}){this.#Ft.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=h},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FreeTextEditor=void 0;var n=i(1),s=i(5),r=i(4),a=i(29);class o extends r.AnnotationEditor{#Ot=this.editorDivBlur.bind(this);#Nt=this.editorDivFocus.bind(this);#Bt=this.editorDivInput.bind(this);#Vt=this.editorDivKeydown.bind(this);#Ut;#jt="";#Ht=`${this.id}-editor`;#Wt;#zt=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=o.prototype,t=e=>e.isEmpty(),i=s.AnnotationEditorUIManager.TRANSLATE_SMALL,r=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:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:t}]]))}static _type="freetext";constructor(e){super({...e,name:"freeTextEditor"}),this.#Ut=e.color||o._defaultColor||r.AnnotationEditor._defaultLineColor,this.#Wt=e.fontSize||o._defaultFontSize}static initialize(e){r.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:o._defaultFontSize=t;break;case n.AnnotationEditorParamsType.FREETEXT_COLOR:o._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,o._defaultFontSize],[n.AnnotationEditorParamsType.FREETEXT_COLOR,o._defaultColor||r.AnnotationEditor._defaultLineColor]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.FREETEXT_SIZE,this.#Wt],[n.AnnotationEditorParamsType.FREETEXT_COLOR,this.#Ut]]}#Gt(e){const t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#Wt)*this.parentScale),this.#Wt=e,this.#qt()},i=this.#Wt;this.addCommands({cmd:()=>{t(e)},undo:()=>{t(i)},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[-o._internalPadding*e,-(o._internalPadding+this.#Wt)*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){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(){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){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width?this.#Xt():(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,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}this.rotation%180==this.parentRotation%180?(this.width=i.width/e,this.height=i.height/t):(this.width=i.height/e,this.height=i.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=this.#jt,t=this.#jt=this.#Kt().trimEnd();if(e===t)return;const i=e=>{this.#jt=e,e?(this.#Yt(),this._uiManager.rebuild(this),this.#qt()):this.remove()};this.addCommands({cmd:()=>{i(t)},undo:()=>{i(e)},mustExec:!1}),this.#qt()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){o._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;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(),r.AnnotationEditor._l10nPromise.get("editor_free_text2_aria_label").then((e=>this.editorDiv?.setAttribute("aria-label",e))),r.AnnotationEditor._l10nPromise.get("free_text2_default_content").then((e=>this.editorDiv?.setAttribute("default-content",e))),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#Wt}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"]),this.width){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:s}=this.#zt;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=e+(s[0]-h)/o,u=t+this.height-(s[1]-c)/l;break;case 90:d=e+(s[0]-h)/o,u=t-(s[1]-c)/l,[r,a]=[a,-r];break;case 180:d=e-this.width+(s[0]-h)/o,u=t-(s[1]-c)/l,[r,a]=[-r,-a];break;case 270:d=e+(s[0]-h-this.height*l)/o,u=t+(s[1]-c-this.width*o)/l,[r,a]=[-a,r]}this.setAt(d*i,u*n,r,a)}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(){if(this.editorDiv.replaceChildren(),this.#jt)for(const e of this.#jt.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 a.FreeTextAnnotationElement){const{data:{defaultAppearanceData:{fontSize:t,fontColor:i},rect:r,rotation:a,id:o},textContent:l,textPosition:h,parent:{page:{pageNumber:c}}}=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:h,pageIndex:c-1,rect:r,rotation:a,id:o,deleted:!1}}const r=super.deserialize(e,t,i);return r.#Wt=e.fontSize,r.#Ut=n.Util.makeHexColor(...e.color),r.#jt=e.value,r.annotationElementId=e.id||null,r.#zt=s,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};const t=o._internalPadding*this.parentScale,i=this.getRect(t,t),s=r.AnnotationEditor._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#Ut),a={annotationType:n.AnnotationEditorType.FREETEXT,color:s,fontSize:this.#Wt,value:this.#jt,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!this.#Qt(a)?null:(a.id=this.annotationElementId,a)}#Qt(e){const{value:t,fontSize:i,color:n,rect:s,pageIndex:r}=this.#zt;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!==r}#Xt(e=!1){if(!this.annotationElementId)return;if(this.#qt(),!e&&(0===this.width||0===this.height))return void setTimeout((()=>this.#Xt(!0)),0);const t=o._internalPadding*this.parentScale;this.#zt.rect=this.getRect(t,t)}}t.FreeTextEditor=o},(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),r=i(3),a=i(30),o=i(31),l=i(32);const h=1e3,c=new WeakSet;function d(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class u{static create(e){switch(e.data.annotationType){case n.AnnotationType.LINK:return new g(e);case n.AnnotationType.TEXT:return new f(e);case n.AnnotationType.WIDGET:switch(e.data.fieldType){case"Tx":return new _(e);case"Btn":return e.data.radioButton?new y(e):e.data.checkBox?new b(e):new S(e);case"Ch":return new P(e);case"Sig":return new v(e)}return new m(e);case n.AnnotationType.POPUP:return new A(e);case n.AnnotationType.FREETEXT:return new E(e);case n.AnnotationType.LINE:return new x(e);case n.AnnotationType.SQUARE:return new C(e);case n.AnnotationType.CIRCLE:return new M(e);case n.AnnotationType.POLYLINE:return new T(e);case n.AnnotationType.CARET:return new F(e);case n.AnnotationType.INK:return new k(e);case n.AnnotationType.POLYGON:return new D(e);case n.AnnotationType.HIGHLIGHT:return new L(e);case n.AnnotationType.UNDERLINE:return new R(e);case n.AnnotationType.SQUIGGLY:return new I(e);case n.AnnotationType.STRIKEOUT:return new O(e);case n.AnnotationType.STAMP:return new N(e);case n.AnnotationType.FILEATTACHMENT:return new B(e);default:return new p(e)}}}class p{#Jt=!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 p._hasPopupData(this.data)}_createContainer(e){const{data:t,parent:{page:i,viewport:s}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),this instanceof m||(r.tabIndex=h),r.style.zIndex=this.parent.zIndex++,this.data.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.noRotate&&r.classList.add("norotate");const{pageWidth:a,pageHeight:o,pageX:l,pageY:c}=s.rawDims;if(!t.rect||this instanceof A){const{rotation:e}=t;return t.hasOwnCanvas||0===e||this.setRotation(e,r),r}const{width:u,height:p}=d(t.rect),g=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){r.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))`;r.style.borderRadius=t}else if(this instanceof y){const e=`calc(${u}px * var(--scale-factor)) / calc(${p}px * var(--scale-factor))`;r.style.borderRadius=e}switch(t.borderStyle.style){case n.AnnotationBorderStyleType.SOLID:r.style.borderStyle="solid";break;case n.AnnotationBorderStyleType.DASHED:r.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:r.style.borderBottomStyle="solid"}const s=t.borderColor||null;s?(this.#Jt=!0,r.style.borderColor=n.Util.makeHexColor(0|s[0],0|s[1],0|s[2])):r.style.borderWidth=0}r.style.left=100*(g[0]-l)/a+"%",r.style.top=100*(g[1]-c)/o+"%";const{rotation:f}=t;return t.hasOwnCanvas||0===f?(r.style.width=100*u/a+"%",r.style.height=100*p/o+"%"):this.setRotation(f,r),r}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims,{width:s,height:r}=d(this.data.rect);let a,o;e%180==0?(a=100*s/i,o=100*r/n):(a=100*r/i,o=100*s/n),t.style.width=`${a}%`,t.style.height=`${o}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(e,t,i)=>{const n=i.detail[e],s=n[0],r=n.slice(1);i.target.style[t]=a.ColorConverters[`${s}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[t]:a.ColorConverters[`${s}_rgb`](r)})};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:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},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 r=i[n];r&&(r({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:r,y:a},{x:o,y:l}]=e[0];if(n===r&&s===a&&t===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Jt){const{borderColor:e,borderWidth:t}=r;r.borderWidth=0,a=["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:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(const[,{x:i,y:n},{x:r,y:c}]of e){const e=h.createElement("rect"),d=(r-t)/o,p=(s-n)/l,g=(i-r)/o,f=(n-c)/l;e.setAttribute("x",d),e.setAttribute("y",p),e.setAttribute("width",g),e.setAttribute("height",f),u.append(e),a?.push(`<rect vector-effect="non-scaling-stroke" x="${d}" y="${p}" width="${g}" height="${f}"/>`)}this.#Jt&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");const i=new A({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:r,exportValues:a}of s){if(-1===e)continue;if(r===t)continue;const s="string"==typeof a?a:null,o=document.querySelector(`[data-element-id="${r}"]`);!o||c.has(o)?i.push({id:r,exportValue:s,domElement:o}):(0,n.warn)(`_getElementsByName - element not allowed: ${r}`)}return i}for(const n of document.getElementsByName(e)){const{exportValue:e}=n,s=n.getAttribute("data-element-id");s!==t&&c.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 g extends p{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;return e.url?(t.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(this._bindAttachment(i,e.attachment),n=!0):e.setOCGState?(this.#Zt(i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),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),!1),(t||""===t)&&this.#ei()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#ei()}_bindAttachment(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.downloadManager?.openOrDownloadData(this.container,t.content,t.filename),!1),this.#ei()}#Zt(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!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}}),!1))}e.onclick||(e.onclick=()=>!1),this.#ei()}_bindResetFormAction(e,t){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),this.#ei(),!this._fieldObjects)return(0,n.warn)('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(e.onclick=()=>!1));e.onclick=()=>{i?.();const{fields:e,refs:s,include:r}=t,a=[];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)===r&&a.push(i)}else for(const e of Object.values(this._fieldObjects))a.push(...e);const o=this.annotationStorage,l=[];for(const e of a){const{id:t}=e;switch(l.push(t),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&&(c.has(i)?i.dispatchEvent(new Event("resetform")):(0,n.warn)(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}}),!1}}}class f extends p{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return 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),this.container}}class m extends p{render(){return this.data.alternativeText&&(this.container.title=this.data.alternativeText),this.container}showElementAndHideCanvas(e){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,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(t||={focused:!1}),this._setEventListener(e,t,s,r,n),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||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,r=e.style;let a;const o=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);a=Math.min(s,o(t/n.LINE_FACTOR))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,o(e/n.LINE_FACTOR))}r.fontSize=`calc(${a}px * var(--scale-factor))`,r.color=n.Util.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(r.textAlign=t[this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class _ extends m{constructor(e){super(e,{isRenderable:e.renderForms||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,i,n){const s=this.annotationStorage;for(const r of this._getElementsByName(e.name,e.id))r.domElement&&(r.domElement[t]=i),s.setValue(r.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 r=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;r&&s.length>r&&(s=s.slice(0,r));let a=n.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:s,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??s,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),c.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=h,this._setRequired(i,this.data.required),r&&(i.maxLength=r),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 l=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)return void s.removeAttribute("maxLength");s.setAttribute("maxLength",n);let r=o.userValue;!r||r.length<=n||(r=r.slice(0,n),s.value=o.userValue=r,e.setValue(t,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}};this._dispatchEventFromSandbox(n,i)})),i.addEventListener("keydown",(e=>{o.commitKey=1;let i=-1;if("Escape"===e.key?i=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(o.commitKey=3):i=2,-1===i)return;const{value:n}=e.target;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=l;l=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:r,selectionEnd:a}=n;let l=r,h=a;switch(e.inputType){case"deleteWordBackward":{const e=s.substring(0,r).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{const e=s.substring(r).match(/^[^\w]*\w*/);e&&(h+=e[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:s,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/r;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";return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class v extends m{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class b extends m{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;"string"==typeof n&&(n="Off"!==n,e.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return c.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=h,s.addEventListener("change",(n=>{const{name:s,checked:r}=n.target;for(const n of this._getElementsByName(s,i)){const i=r&&n.exportValue===t.exportValue;n.domElement&&(n.domElement.checked=i),e.setValue(n.id,{value:i})}e.setValue(i,{value:r})})),s.addEventListener("resetform",(e=>{const i=t.defaultFieldValue||"Off";e.target.checked=i===t.exportValue})),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),this.container}}class y extends m{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;"string"==typeof n&&(n=n!==t.buttonValue,e.setValue(i,{value:n}));const s=document.createElement("input");if(c.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=h,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})),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))}return this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class S extends g{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;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class P extends m{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");c.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=h;let s=this.data.combo&&this.data.options.length>0;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,i.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),s=!1),n.append(t)}let r=null;if(s){const e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),n.prepend(e),r=()=>{e.remove(),n.removeEventListener("input",r),r=null},n.addEventListener("input",r)}const a=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 o=a(!1);const l=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",(i=>{const s={value(i){r?.();const s=i.detail.value,l=new Set(Array.isArray(s)?s:[s]);for(const e of n.options)e.selected=l.has(e.value);e.setValue(t,{value:a(!0)}),o=a(!1)},multipleSelection(e){n.multiple=!0},remove(i){const s=n.options,r=i.detail.remove;s[r].selected=!1,n.remove(r),s.length>0&&-1===Array.prototype.findIndex.call(s,(e=>e.selected))&&(s[0].selected=!0),e.setValue(t,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==n.length;)n.remove(0);e.setValue(t,{value:null,items:[]}),o=a(!1)},insert(i){const{index:s,displayValue:r,exportValue:h}=i.detail.insert,c=n.children[s],d=document.createElement("option");d.textContent=r,d.value=h,c?c.before(d):n.append(d),e.setValue(t,{value:a(!0),items:l(i)}),o=a(!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:a(!0),items:l(i)}),o=a(!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:a(!0)}),o=a(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(s,i)})),n.addEventListener("input",(i=>{const n=a(!0);e.setValue(t,{value:n}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,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))):n.addEventListener("input",(function(i){e.setValue(t,{value:a(!0)})})),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class A extends p{constructor(e){const{data:t,elements:i}=e;super(e,{isRenderable:p._hasPopupData(t)}),this.elements=i}render(){this.container.classList.add("popupAnnotation");const e=new w({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();return this.container.setAttribute("aria-controls",t.map((e=>`${n.AnnotationPrefix}${e}`)).join(",")),this.container}}class w{#ti=null;#ii=this.#ni.bind(this);#si=this.#ri.bind(this);#ai=this.#oi.bind(this);#li=this.#hi.bind(this);#Ut=null;#ke=null;#ci=null;#di=null;#ui=null;#pi=null;#gi=!1;#fi=null;#mi=null;#_i=null;#vi=null;#bi=!1;constructor({container:e,color:t,elements:i,titleObj:n,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:d}){this.#ke=e,this.#vi=n,this.#ci=a,this.#_i=o,this.#ui=l,this.#Ut=t,this.#mi=h,this.#pi=c,this.#di=i;const u=s.PDFDateString.toDateObject(r);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.#ai),e.addEventListener("mouseleave",this.#si),e.classList.add("popupTriggerArea");for(const e of i)e.container?.addEventListener("keydown",this.#ii);this.#ke.hidden=!0,d&&this.#hi()}render(){if(this.#fi)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:i,pageX:s,pageY:r}}}=this.#ui,a=this.#fi=document.createElement("div");if(a.className="popup",this.#Ut){const e=a.style.outlineColor=n.Util.makeHexColor(...this.#Ut);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))a.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;a.style.backgroundColor=n.Util.makeHexColor(...this.#Ut.map((t=>Math.floor(e*(255-t)+t))))}}const o=document.createElement("span");o.className="header";const h=document.createElement("h1");if(o.append(h),({dir:h.dir,str:h.textContent}=this.#vi),a.append(o),this.#ti){const e=document.createElement("span");e.classList.add("popupDate"),this.#ti.then((t=>{e.textContent=t})),o.append(e)}const c=this.#ci,d=this.#_i;if(!d?.str||c?.str&&c.str!==d.str){const e=this._formatContents(c);a.append(e)}else l.XfaLayer.render({xfaHtml:d.html,intent:"richText",div:a}),a.lastChild.classList.add("richText","popupContent");let u=!!this.#pi,p=u?this.#pi:this.#mi;for(const e of this.#di)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,_=g[1],{style:v}=this.#ke;v.left=100*(m-s)/t+"%",v.top=100*(_-r)/i+"%",this.#ke.append(a)}_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.#hi()}#hi(){this.#gi=!this.#gi,this.#gi?(this.#oi(),this.#ke.addEventListener("click",this.#li),this.#ke.addEventListener("keydown",this.#ii)):(this.#ri(),this.#ke.removeEventListener("click",this.#li),this.#ke.removeEventListener("keydown",this.#ii))}#oi(){this.#fi||this.render(),this.isVisible?this.#gi&&this.#ke.classList.add("focused"):(this.#ke.hidden=!1,this.#ke.style.zIndex=parseInt(this.#ke.style.zIndex)+1e3)}#ri(){this.#ke.classList.remove("focused"),!this.#gi&&this.isVisible&&(this.#ke.hidden=!0,this.#ke.style.zIndex=parseInt(this.#ke.style.zIndex)-1e3)}forceHide(){this.#bi=this.isVisible,this.#bi&&(this.#ke.hidden=!0)}maybeShow(){this.#bi&&(this.#bi=!1,this.#ke.hidden=!1)}get isVisible(){return!1===this.#ke.hidden}}class E extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=n.AnnotationEditorType.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),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)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}t.FreeTextAnnotationElement=E;class x extends p{#yi=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:i}=d(e.rect),n=this.svgFactory.create(t,i,!0),s=this.#yi=this.svgFactory.createElement("svg:line");return 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(),this.container}getElementsToTriggerPopup(){return this.#yi}addHighlightArea(){this.container.classList.add("highlightArea")}}class C extends p{#Si=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:i}=d(e.rect),n=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,r=this.#Si=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",s/2),r.setAttribute("y",s/2),r.setAttribute("width",t-s),r.setAttribute("height",i-s),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Si}addHighlightArea(){this.container.classList.add("highlightArea")}}class M extends p{#Pi=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:i}=d(e.rect),n=this.svgFactory.create(t,i,!0),s=e.borderStyle.width,r=this.#Pi=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",t/2),r.setAttribute("cy",i/2),r.setAttribute("rx",t/2-s/2),r.setAttribute("ry",i/2-s/2),r.setAttribute("stroke-width",s||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Pi}addHighlightArea(){this.container.classList.add("highlightArea")}}class T extends p{#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}=d(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 r=this.#Ai=this.svgFactory.createElement(this.svgElementName);return r.setAttribute("points",s),r.setAttribute("stroke-width",e.borderStyle.width||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),n.append(r),this.container.append(n),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ai}addHighlightArea(){this.container.classList.add("highlightArea")}}class D extends T{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class F extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class k extends p{#wi=[];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}=d(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.#wi.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)}return this.container.append(n),this.container}getElementsToTriggerPopup(){return this.#wi}addHighlightArea(){this.container.classList.add("highlightArea")}}t.InkAnnotationElement=k;class L extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this.container}}class R extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class I extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class O extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class N extends p{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("stampAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}t.StampAnnotationElement=N;class B extends p{#Ei=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;t.hasAppearance||0===t.fillAlpha?i=document.createElement("div"):(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.#xi.bind(this)),this.#Ei=i;const{isMac:s}=n.FeatureTest.platform;return e.addEventListener("keydown",(e=>{"Enter"===e.key&&(s?e.metaKey:e.ctrlKey)&&this.#xi()})),!t.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return this.#Ei}addHighlightArea(){this.container.classList.add("highlightArea")}#xi(){this.downloadManager?.openOrDownloadData(this.container,this.content,this.filename)}}t.AnnotationLayer=class{#Pt=null;#Ci=null;#Mi=new Map;constructor({div:e,accessibilityManager:t,annotationCanvasMap:i,l10n:n,page:s,viewport:r}){this.div=e,this.#Pt=t,this.#Ci=i,this.l10n=n,this.page=s,this.viewport=r,this.zIndex=0,this.l10n||=o.NullL10n}#Ti(e,t){const i=e.firstChild||e;i.id=`${n.AnnotationPrefix}${t}`,this.div.append(e),this.#Pt?.moveElementInDOM(this.div,e,i,!1)}async render(e){const{annotations:t}=e,i=this.div;(0,s.setLayerDimensions)(i,this.viewport);const a=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 r.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=a.get(e.id);if(!t)continue;o.elements=t}else{const{width:t,height:i}=d(e.rect);if(t<=0||i<=0)continue}o.data=e;const i=u.create(o);if(!i.isRenderable)continue;if(!t&&e.popupRef){const t=a.get(e.popupRef);t?t.push(i):a.set(e.popupRef,[i])}i.annotationEditorType>0&&this.#Mi.set(i.data.id,i);const s=i.render();e.hidden&&(s.style.visibility="hidden"),this.#Ti(s,e.id)}this.#Di(),await this.l10n.translate(i)}update({viewport:e}){const t=this.div;this.viewport=e,(0,s.setLayerDimensions)(t,{rotation:e.rotation}),this.#Di(),t.hidden=!1}#Di(){if(!this.#Ci)return;const e=this.div;for(const[t,i]of this.#Ci){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.#Ci.clear()}getEditableAnnotations(){return Array.from(this.#Mi.values())}getEditableAnnotation(e){return this.#Mi.get(e)}}},(e,t)=>{function i(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function n(e){return Math.max(0,Math.min(255,255*e))}Object.defineProperty(t,"__esModule",{value:!0}),t.ColorConverters=void 0,t.ColorConverters=class{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=n(e),e,e]}static G_HTML([e]){const t=i(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(n)}static RGB_HTML(e){return`#${e.map(i).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,s]){return[n(1-Math.min(1,e+s)),n(1-Math.min(1,i+s)),n(1-Math.min(1,t+s))]}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,r=1-i;return["CMYK",n,s,r,Math.min(n,s,r)]}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NullL10n=void 0,t.getL10nFallback=n;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"};function n(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]||""}i.print_progress_percent="{{progress}}%";const s={getLanguage:async()=>"en-us",getDirection:async()=>"ltr",get:async(e,t=null,i=n(e,t))=>function(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=s},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.XfaLayer=void 0;var n=i(25);t.XfaLayer=class{static setupStorage(e,t,i,n,s){const r=n.getValue(t,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(e.textContent=r.value),"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){if(r.value===i.attributes.xfaOn?e.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&e.removeAttribute("checked"),"print"===s)break;e.addEventListener("change",(e=>{n.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&e.setAttribute("value",r.value),"print"===s)break;e.addEventListener("input",(e=>{n.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==r.value){e.setAttribute("value",r.value);for(const e of i.children)e.attributes.value===r.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:r}=t,a=e instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);for(const[t,i]of Object.entries(r))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:(!a||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,i)}a&&s.addLinkAttributes(e,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(e,r.dataId,t,i)}static render(e){const t=e.annotationStorage,i=e.linkService,s=e.xfaHtml,r=e.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:r,linkService:i});const o=[[s,-1,a]],l=e.div;if(l.append(a),e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;l.style.transform=t}"richText"!==r&&l.setAttribute("class","xfaLayer xfaFont");const h=[];for(;o.length>0;){const[e,s,a]=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:c}=l;if("#text"===c){const e=document.createTextNode(l.value);h.push(e),a.append(e);continue}const d=l?.attributes?.xmlns?document.createElementNS(l.attributes.xmlns,c):document.createElement(c);if(a.append(d),l.attributes&&this.setAttributes({html:d,element:l,storage:t,intent:r,linkService:i}),l.children&&l.children.length>0)o.push([l,-1,d]);else if(l.value){const e=document.createTextNode(l.value);n.XfaText.shouldBuildText(c)&&h.push(e),d.append(e)}}for(const e of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:h}}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),r=i(29),a=i(6),o=i(5);class l extends s.AnnotationEditor{#Fi=0;#ki=0;#Li=this.canvasPointermove.bind(this);#Ri=this.canvasPointerleave.bind(this);#Ii=this.canvasPointerup.bind(this);#Oi=this.canvasPointerdown.bind(this);#Ni=new Path2D;#Bi=!1;#Vi=!1;#Ui=!1;#ji=null;#Hi=0;#Wi=0;#zi=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:l._defaultThickness=t;break;case n.AnnotationEditorParamsType.INK_COLOR:l._defaultColor=t;break;case n.AnnotationEditorParamsType.INK_OPACITY:l._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,l._defaultThickness],[n.AnnotationEditorParamsType.INK_COLOR,l._defaultColor||s.AnnotationEditor._defaultLineColor],[n.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*l._defaultOpacity)]]}get propertiesToUpdate(){return[[n.AnnotationEditorParamsType.INK_THICKNESS,this.thickness||l._defaultThickness],[n.AnnotationEditorParamsType.INK_COLOR,this.color||l._defaultColor||s.AnnotationEditor._defaultLineColor],[n.AnnotationEditorParamsType.INK_OPACITY,Math.round(100*(this.opacity??l._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(){this.parent&&(super.rebuild(),null!==this.div&&(this.canvas||(this.#Ki(),this.#Yi()),this.isAttachedToDOM||(this.parent.add(this),this.#Qi()),this.#qi()))}remove(){null!==this.canvas&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#ji.disconnect(),this.#ji=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(){this.#Bi||null===this.canvas||(super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#Oi))}disableEditMode(){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}#Ji(){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]}}#Zi(){const{ctx:e,color:t,opacity:i,thickness:n,parentScale:s,scaleFactor:r}=this;e.lineWidth=n*s/r,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${(0,o.opacityToHex)(i)}`}#en(e,t){this.canvas.addEventListener("contextmenu",a.noContextMenu),this.canvas.addEventListener("pointerleave",this.#Ri),this.canvas.addEventListener("pointermove",this.#Li),this.canvas.addEventListener("pointerup",this.#Ii),this.canvas.removeEventListener("pointerdown",this.#Oi),this.isEditing=!0,this.#Ui||(this.#Ui=!0,this.#Qi(),this.thickness||=l._defaultThickness,this.color||=l._defaultColor||s.AnnotationEditor._defaultLineColor,this.opacity??=l._defaultOpacity),this.currentPath.push([e,t]),this.#Vi=!1,this.#Zi(),this.#zi=()=>{this.#tn(),this.#zi&&window.requestAnimationFrame(this.#zi)},window.requestAnimationFrame(this.#zi)}#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 r=this.#Ni;if(s.push([e,t]),this.#Vi=!0,s.length<=2)return r.moveTo(...s[0]),void r.lineTo(e,t);3===s.length&&(this.#Ni=r=new Path2D,r.moveTo(...s[0])),this.#nn(r,...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)}#rn(e,t){let i;if(this.#zi=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(),1!==this.currentPath.length)i=this.#an();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(),0===this.paths.length?this.remove():(this.canvas||(this.#Ki(),this.#Yi()),this.#qi())},mustExec:!0})}#tn(){if(!this.#Vi)return;this.#Vi=!1,Math.ceil(this.thickness*this.parentScale);const e=this.currentPath.slice(-3),t=e.map((e=>e[0])),i=e.map((e=>e[1]));Math.min(...t),Math.max(...t),Math.min(...i),Math.max(...i);const{ctx:n}=this;n.save(),n.clearRect(0,0,this.canvas.width,this.canvas.height);for(const e of this.bezierPath2D)n.stroke(e);n.stroke(this.#Ni),n.restore()}#nn(e,t,i,n,s,r,a){const o=(t+n)/2,l=(i+s)/2,h=(n+r)/2,c=(s+a)/2;e.bezierCurveTo(o+2*(n-o)/3,l+2*(s-l)/3,h+2*(n-h)/3,c+2*(s-c)/3,h,c)}#an(){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[r,a]=e[i],[o,l]=e[i+1],h=(r+o)/2,c=(a+l)/2,d=[n+2*(r-n)/3,s+2*(a-s)/3],u=[h+2*(r-h)/3,c+2*(a-c)/3];t.push([[n,s],d,u,[h,c]]),[n,s]=[h,c]}const[r,a]=e[i],[o,l]=e[i+1],h=[n+2*(r-n)/3,s+2*(a-s)/3],c=[o+2*(r-o)/3,l+2*(a-l)/3];return t.push([[n,s],h,c,[o,l]]),t}#Xi(){if(this.isEmpty())return void this.#on();this.#Zi();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(){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){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){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.#Ri),this.canvas.removeEventListener("pointermove",this.#Li),this.canvas.removeEventListener("pointerup",this.#Ii),this.canvas.addEventListener("pointerdown",this.#Oi),setTimeout((()=>{this.canvas.removeEventListener("contextmenu",a.noContextMenu)}),10),this.#rn(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.#ji=new ResizeObserver((e=>{const t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)})),this.#ji.observe(this.div)}get isResizable(){return!this.isEmpty()&&this.#Bi}render(){if(this.div)return this.div;let e,t;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,r,a]=this.#Ji();if(this.setAt(i,n,0,0),this.setDims(r,a),this.#Ki(),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();return this.#Yi(),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.#Wi===n)return;this.#Hi=i,this.#Wi=n,this.canvas.style.visibility="hidden";const[s,r]=this.parentDimensions;this.width=e/s,this.height=t/r,this.fixAndSetPosition(),this.#Bi&&this.#hn(e,t),this.#Qi(),this.#Xi(),this.canvas.style.visibility="visible",this.fixDims()}#hn(e,t){const i=this.#cn(),n=(e-i)/this.#ki,s=(t-i)/this.#Fi;this.scaleFactor=Math.min(n,s)}#on(){const e=this.#cn()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)}static#dn(e){const t=new Path2D;for(let i=0,n=e.length;i<n;i++){const[n,s,r,a]=e[i];0===i&&t.moveTo(...n),t.bezierCurveTo(s[0],s[1],r[0],r[1],a[0],a[1])}return t}static#un(e,t,i){const[n,s,r,a]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2)e[t]+=n,e[t+1]=a-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]=r-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}static#pn(e,t,i){const[n,s,r,a]=t;switch(i){case 0:for(let t=0,i=e.length;t<i;t+=2)e[t]-=n,e[t+1]=a-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]=r-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}#gn(e,t,i,n){const s=[],r=this.thickness/2,a=e*t+r,o=e*i+r;for(const t of this.paths){const i=[],r=[];for(let n=0,s=t.length;n<s;n++){const[l,h,c,d]=t[n],u=e*l[0]+a,p=e*l[1]+o,g=e*h[0]+a,f=e*h[1]+o,m=e*c[0]+a,_=e*c[1]+o,v=e*d[0]+a,b=e*d[1]+o;0===n&&(i.push(u,p),r.push(u,p)),i.push(g,f,m,_,v,b),r.push(g,f),n===s-1&&r.push(v,b)}s.push({bezier:l.#un(i,n,this.rotation),points:l.#un(r,n,this.rotation)})}return s}#fn(){let e=1/0,t=-1/0,i=1/0,s=-1/0;for(const r of this.paths)for(const[a,o,l,h]of r){const r=n.Util.bezierBoundingBox(...a,...o,...l,...h);e=Math.min(e,r[0]),i=Math.min(i,r[1]),t=Math.max(t,r[2]),s=Math.max(s,r[3])}return[e,i,t,s]}#cn(){return this.#Bi?Math.ceil(this.thickness*this.parentScale):0}#qi(e=!1){if(this.isEmpty())return;if(!this.#Bi)return void this.#Xi();const t=this.#fn(),i=this.#cn();this.#ki=Math.max(s.AnnotationEditor.MIN_SIZE,t[2]-t[0]),this.#Fi=Math.max(s.AnnotationEditor.MIN_SIZE,t[3]-t[1]);const n=Math.ceil(i+this.#ki*this.scaleFactor),r=Math.ceil(i+this.#Fi*this.scaleFactor),[a,o]=this.parentDimensions;this.width=n/a,this.height=r/o,this.setAspectRatio(n,r);const l=this.translationX,h=this.translationY;this.translationX=-t[0],this.translationY=-t[1],this.#Qi(),this.#Xi(),this.#Hi=n,this.#Wi=r,this.setDims(n,r);const c=e?i/this.scaleFactor/2:0;this.translate(l-this.translationX-c,h-this.translationY-c)}static deserialize(e,t,i){if(e instanceof r.InkAnnotationElement)return null;const a=super.deserialize(e,t,i);a.thickness=e.thickness,a.color=n.Util.makeHexColor(...e.color),a.opacity=e.opacity;const[o,h]=a.pageDimensions,c=a.width*o,d=a.height*h,u=a.parentScale,p=e.thickness/2;a.#Bi=!0,a.#Hi=Math.round(c),a.#Wi=Math.round(d);const{paths:g,rect:f,rotation:m}=e;for(let{bezier:e}of g){e=l.#pn(e,f,m);const t=[];a.paths.push(t);let i=u*(e[0]-p),n=u*(e[1]-p);for(let s=2,r=e.length;s<r;s+=6){const r=u*(e[s]-p),a=u*(e[s+1]-p),o=u*(e[s+2]-p),l=u*(e[s+3]-p),h=u*(e[s+4]-p),c=u*(e[s+5]-p);t.push([[i,n],[r,a],[o,l],[h,c]]),i=h,n=c}const s=this.#dn(t);a.bezierPath2D.push(s)}const _=a.#fn();return a.#ki=Math.max(s.AnnotationEditor.MIN_SIZE,_[2]-_[0]),a.#Fi=Math.max(s.AnnotationEditor.MIN_SIZE,_[3]-_[1]),a.#hn(c,d),a}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=l},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StampEditor=void 0;var n=i(1),s=i(4),r=i(6),a=i(29);class o extends s.AnnotationEditor{#mn=null;#_n=null;#vn=null;#bn=null;#yn=null;#Sn=null;#ji=null;#Pn=null;#An=!1;#wn=!1;static _type="stamp";constructor(e){super({...e,name:"stampEditor"}),this.#bn=e.bitmapUrl,this.#yn=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()})}#En(e,t=!1){e?(this.#mn=e.bitmap,t||(this.#_n=e.id,this.#An=e.isSvg),this.#Ki()):this.remove()}#xn(){this.#vn=null,this._uiManager.enableWaiting(!1),this.#Sn&&this.div.focus()}#Cn(){if(this.#_n)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#_n).then((e=>this.#En(e,!0))).finally((()=>this.#xn()));if(this.#bn){const e=this.#bn;return this.#bn=null,this._uiManager.enableWaiting(!0),void(this.#vn=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#En(e))).finally((()=>this.#xn())))}if(this.#yn){const e=this.#yn;return this.#yn=null,this._uiManager.enableWaiting(!0),void(this.#vn=this._uiManager.imageManager.getFromFile(e).then((e=>this.#En(e))).finally((()=>this.#xn())))}const e=document.createElement("input");e.type="file",e.accept=o.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.#En(t)}else this.remove();t()})),e.addEventListener("cancel",(()=>{this.remove(),t()}))})).finally((()=>this.#xn())),e.click()}remove(){this.#_n&&(this.#mn=null,this._uiManager.imageManager.deleteId(this.#_n),this.#Sn?.remove(),this.#Sn=null,this.#ji?.disconnect(),this.#ji=null),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#_n&&this.#Cn(),this.isAttachedToDOM||this.parent.add(this))):this.#_n&&this.#Cn()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#vn||this.#mn||this.#bn||this.#yn)}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.#Cn(),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,r=.75;if(this.width)t=this.width*n,i=this.height*s;else if(t>r*n||i>r*s){const e=Math.min(r*n/t,r*s/i);t*=e,i*=e}const[a,o]=this.parentDimensions;this.setDims(t*a/n,i*o/s),this._uiManager.enableWaiting(!1);const l=this.#Sn=document.createElement("canvas");e.append(l),e.hidden=!1,this.#Mn(t,i),this.#Yi(),this.#wn||(this.parent.addUndoableEditor(this),this.#wn=!0),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",subtype:this.editorType,data:{action:"inserted_image"}}}),this.addAltTextButton()}#Tn(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.#Pn&&clearTimeout(this.#Pn),this.#Pn=setTimeout((()=>{this.#Pn=null,this.#Mn(e,t)}),200)}#Dn(e,t){const{width:i,height:n}=this.#mn;let s=i,r=n,a=this.#mn;for(;s>2*e||r>2*t;){const i=s,n=r;s>2*e&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),r>2*t&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(s,r);o.getContext("2d").drawImage(a,0,0,i,n,0,0,s,r),a=o.transferToImageBitmap()}return a}#Mn(e,t){e=Math.ceil(e),t=Math.ceil(t);const i=this.#Sn;if(!i||i.width===e&&i.height===t)return;i.width=e,i.height=t;const n=this.#An?this.#mn:this.#Dn(e,t),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(n,0,0,n.width,n.height,0,0,e,t)}#Fn(e){if(e){if(this.#An){const e=this._uiManager.imageManager.getSvgUrl(this.#_n);if(e)return e}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#mn),e.getContext("2d").drawImage(this.#mn,0,0),e.toDataURL()}if(this.#An){const[e,t]=this.pageDimensions,i=Math.round(this.width*e*r.PixelsPerInch.PDF_TO_CSS_UNITS),n=Math.round(this.height*t*r.PixelsPerInch.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,n);return s.getContext("2d").drawImage(this.#mn,0,0,this.#mn.width,this.#mn.height,0,0,i,n),s.transferToImageBitmap()}return structuredClone(this.#mn)}#Yi(){this.#ji=new ResizeObserver((e=>{const t=e[0].contentRect;t.width&&t.height&&this.#Tn(t.width,t.height)})),this.#ji.observe(this.div)}static deserialize(e,t,i){if(e instanceof a.StampAnnotationElement)return null;const n=super.deserialize(e,t,i),{rect:s,bitmapUrl:r,bitmapId:o,isSvg:l,accessibilityData:h}=e;o&&i.imageManager.isValidId(o)?n.#_n=o:n.#bn=r,n.#An=l;const[c,d]=n.pageDimensions;return n.width=(s[2]-s[0])/c,n.height=(s[3]-s[1])/d,h&&(n.altTextData=h),n}serialize(e=!1,t=null){if(this.isEmpty())return null;const i={annotationType:n.AnnotationEditorType.STAMP,bitmapId:this.#_n,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#An,structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=this.#Fn(!0),i.accessibilityData=this.altTextData,i;const{decorative:s,altText:r}=this.altTextData;if(!s&&r&&(i.accessibilityData={type:"Figure",alt:r}),null===t)return i;t.stamps||=new Map;const a=this.#An?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(t.stamps.has(this.#_n)){if(this.#An){const e=t.stamps.get(this.#_n);a>e.area&&(e.area=a,e.serialized.bitmap.close(),e.serialized.bitmap=this.#Fn(!1))}}else t.stamps.set(this.#_n,{area:a,serialized:i}),i.bitmap=this.#Fn(!1);return i}}t.StampEditor=o}],__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:{}};return __webpack_modules__[e](i,i.exports,__w_pdfjs_require__),i.exports}var __webpack_exports__={};return(()=>{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 r.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 a.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 h.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),r=__w_pdfjs_require__(27),a=__w_pdfjs_require__(5),o=__w_pdfjs_require__(29),l=__w_pdfjs_require__(14),h=__w_pdfjs_require__(32)})(),__webpack_exports__})(),module.exports=root.pdfjsLib=factory()})(pdf);var pdfExports=pdf.exports,pdf_viewer={exports:{}};
33
- /**
34
- * @licstart The following is the entire license notice for the
35
- * JavaScript code in this page
36
- *
37
- * Copyright 2023 Mozilla Foundation
38
- *
39
- * Licensed under the Apache License, Version 2.0 (the "License");
40
- * you may not use this file except in compliance with the License.
41
- * You may obtain a copy of the License at
42
- *
43
- * http://www.apache.org/licenses/LICENSE-2.0
44
- *
45
- * Unless required by applicable law or agreed to in writing, software
46
- * distributed under the License is distributed on an "AS IS" BASIS,
47
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
- * See the License for the specific language governing permissions and
49
- * limitations under the License.
50
- *
51
- * @licend The above is the entire license notice for the
52
- * JavaScript code in this page
53
- */
54
- !function(e,t){var i,n;i=globalThis,n=()=>(()=>{var e=[,(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFFindController=t.FindState=void 0;var n=i(2),s=i(3),r=i(4);const a={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3};t.FindState=a;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 h;const c=/\p{M}+/gu,d=/([.*+?^${}()|[\]\\])|(\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 _=null,v=null;function b(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);i||(i=n.normalize("NFD").length,f.set(n,i)),t.push([i,e++])}}if(0===t.length&&_)n=_;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?_=new RegExp(e+"|(\\u0000)","gum"):v=new RegExp(e+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const r=[];for(;null!==(i=c.exec(e));)r.push([i[0].length,i.index]);let a=e.normalize("NFD");const l=[[0,0]];let h=0,d=0,u=0,p=0,b=0,y=!1;return a=a.replace(n,((e,i,n,s,a,c,g,f,_,v)=>{if(v-=p,i){const e=o[i],t=e.length;for(let e=1;e<t;e++)l.push([v-u+e,u-e]);return u-=t-1,e}if(n){let e=m.get(n);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]);return u-=t-1,e}if(s)return y=!0,v+b===r[h]?.[1]?++h:(l.push([v-1-u+1,u-1]),u-=1,p+=1),l.push([v-u+1,u]),p+=1,b+=1,s.charAt(0);if(a){const e=a.endsWith("\n"),t=e?a.length-2:a.length;y=!0;let i=t;v+b===r[h]?.[1]&&(i-=r[h][0],++h);for(let e=1;e<=i;e++)l.push([v-1-u+e,u-e]);return u-=i,p+=i,e?(v+=t-1,l.push([v-u+1,1+u]),u+=1,p+=1,b+=1,a.slice(0,t)):a}if(c){const e=c.length-2;return l.push([v-u+e,1+u]),u+=1,p+=1,b+=1,c.slice(0,-2)}if(g){const e=g.length-1;return l.push([v-u+e,u]),p+=1,b+=1,g.slice(0,-1)}if(f)return l.push([v-u+1,u-1]),u-=1,p+=1,b+=1," ";if(v+b===t[d]?.[1]){const e=t[d][0]-1;++d;for(let t=1;t<=e;t++)l.push([v-(u-t),u-t]);u-=e,p+=e}return _})),l.push([a.length,u]),[a,l,y]}function y(e,t,i){if(!e)return[t,i];const s=t,r=t+i-1;let a=(0,n.binarySearchFirstItem)(e,(e=>e[0]>=s));e[a][0]>s&&--a;let o=(0,n.binarySearchFirstItem)(e,(e=>e[0]>=r),a);e[o][0]>r&&--o;const l=s+e[a][1];return[l,r+e[o][1]+1-l]}t.PDFFindController=class{#kn=null;#Ln=!0;#Rn=0;constructor({linkService:e,eventBus:t,updateMatchesCountOnProgress:i=!0}){this._linkService=e,this._eventBus=t,this.#Ln=i,this.onIsPageVisible=null,this.#In(),t._on("find",this.#On.bind(this)),t._on("findbarclose",this.#Nn.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.#kn}setDocument(e){this._pdfDocument&&this.#In(),e&&(this._pdfDocument=e,this._firstPageCapability.resolve())}#On(e){if(!e)return;!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.#kn||this.#Bn(e))&&(this._dirtyMatch=!0),this.#kn=e,"highlightallchange"!==i&&this.#Vn(a.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||t&&this._pdfDocument!==t)return;this.#Kt();const e=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#Un():"again"===i?(this.#Un(),e&&this.#kn.highlightAll&&this.#jn()):"highlightallchange"===i?(n?this.#Un():this._highlightMatches=!0,this.#jn()):this.#Un():this._findTimeout=setTimeout((()=>{this.#Un(),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 r={top:-50,left:t+-400};(0,n.scrollIntoView)(e,r,!0)}#In(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Rn=0,this.#kn=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 r.PromiseCapability}get#Hn(){const{query:e}=this.#kn;return"string"==typeof e?(e!==this._rawQuery&&(this._rawQuery=e,[this._normalizedQuery]=b(e)),this._normalizedQuery):(e||[]).filter((e=>!!e)).map((e=>b(e)[0]))}#Bn(e){const t=e.query,i=this.#kn.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}#Wn(e,t,i){let n=e.slice(0,t).match(u);if(n){const i=e.charCodeAt(t),r=n[1].charCodeAt(0);if((0,s.getCharacterType)(i)===(0,s.getCharacterType)(r))return!1}if(n=e.slice(t+i).match(p),n){const r=e.charCodeAt(t+i-1),a=n[1].charCodeAt(0);if((0,s.getCharacterType)(r)===(0,s.getCharacterType)(a))return!1}return!0}#zn(e,t,i,n){const s=this._pageMatches[i]=[],r=this._pageMatchesLength[i]=[];if(!e)return;const a=this._pageDiffs[i];let o;for(;null!==(o=e.exec(n));){if(t&&!this.#Wn(n,o.index,o[0].length))continue;const[e,i]=y(a,o.index,o[0].length);i&&(s.push(e),r.push(i))}}#Gn(e,t){const{matchDiacritics:i}=this.#kn;let n=!1;const s="[ ]*";return(e=e.replaceAll(d,((e,s,r,a,o,h)=>s?`[ ]*\\${s}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||h:o?l.has(o.charCodeAt(0))?o:"":t?(n=!0,`${h}\\p{M}*`):h))).endsWith(s)&&(e=e.slice(0,e.length-4)),i&&t&&(h||=String.fromCharCode(...l),n=!0,e=`${e}(?=[${h}]|[^\\p{M}]|$)`),[n,e]}#$n(e){let t=this.#Hn;if(0===t.length)return;const{caseSensitive:i,entireWord:n}=this.#kn,s=this._pageContents[e],r=this._hasDiacritics[e];let a=!1;"string"==typeof t?[a,t]=this.#Gn(t,r):t=t.sort().reverse().map((e=>{const[t,i]=this.#Gn(e,r);return a||=t,`(${i})`})).join("|"),t=t?new RegExp(t,`g${a?"u":""}${i?"":"i"}`):null,this.#zn(t,n,e,s),this.#kn.highlightAll&&this.#qn(e),this._resumePageIdx===e&&(this._resumePageIdx=null,this.#Xn());const o=this._pageMatches[e].length;this._matchesCountTotal+=o,this.#Ln?o>0&&this.#Kn():++this.#Rn===this._linkService.pagesCount&&this.#Kn()}#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 r.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]]=b(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()}))))}}#qn(e){this._scrollMatches&&this._selected.pageIdx===e&&(this._linkService.page=e+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:e})}#jn(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#Un(){const e=this.#kn.findPrevious,t=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,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.#Rn=0,this._matchesCountTotal=0,this.#jn();for(let e=0;e<i;e++)this._pendingFindMatches.has(e)||(this._pendingFindMatches.add(e),this._extractTextPromises[e].then((()=>{this._pendingFindMatches.delete(e),this.#$n(e)})))}if(0===this.#Hn.length)return void this.#Vn(a.FOUND);if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,null!==n.matchIdx){const t=this._pageMatches[n.pageIdx].length;if(!e&&n.matchIdx+1<t||e&&n.matchIdx>0)return n.matchIdx=e?n.matchIdx-1:n.matchIdx+1,void this.#Yn(!0);this.#Qn(e)}this.#Xn()}#Jn(e){const t=this._offset,i=e.length,n=this.#kn.findPrevious;return i?(t.matchIdx=n?i-1:0,this.#Yn(!0),!0):(this.#Qn(n),!!(t.wrapped&&(t.matchIdx=null,this._pagesToSearch<0))&&(this.#Yn(!1),!0))}#Xn(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let e=null;do{const t=this._offset.pageIdx;if(e=this._pageMatches[t],!e){this._resumePageIdx=t;break}}while(!this.#Jn(e))}#Qn(e){const t=this._offset,i=this._linkService.pagesCount;t.pageIdx=e?t.pageIdx-1:t.pageIdx+1,t.matchIdx=null,this._pagesToSearch--,(t.pageIdx>=i||t.pageIdx<0)&&(t.pageIdx=e?i-1:0,t.wrapped=!0)}#Yn(e=!1){let t=a.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,e){const e=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,t=i?a.WRAPPED:a.FOUND,-1!==e&&e!==this._selected.pageIdx&&this.#qn(e)}this.#Vn(t,this.#kn.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#qn(this._selected.pageIdx))}#Nn(e){const t=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||t&&this._pdfDocument!==t||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#Vn(a.FOUND),this._highlightMatches=!1,this.#jn())}))}#Zn(){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}return(i<1||i>n)&&(i=n=0),{current:i,total:n}}#Kn(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Zn()})}#Vn(e,t=!1){(this.#Ln||this.#Rn===this._linkService.pagesCount&&e!==a.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:e,previous:t,matchesCount:this.#Zn(),rawQuery:this.#kn?.query??null})}}},(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(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(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(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,r=1,a=1,o=1;for(;;){const e=s+a,t=r+o;if(t>8)break;i<=e/t?(a=e,o=t):(s=e,r=t)}return n=i-s/r<a/o-i?i===e?[s,r]:[r,s]:i===e?[a,o]:[o,a],n},t.backtrackBeforeAllVisibleElements=o,t.binarySearchFirstItem=a,t.docStyle=void 0,t.getActiveOrFocusedElement=function(){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({view:e,userUnit:t,rotate:i}){const[n,s,r,a]=e,o=i%180!=0,l=(r-n)/72*t,h=(a-s)/72*t;return{width:o?h:l,height:o?l:h}},t.getVisibleElements=function({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const r=e.scrollTop,l=r+e.clientHeight,h=e.scrollLeft,c=h+e.clientWidth,d=[],u=new Set,p=t.length;let g=a(t,n?function(e){const t=e.div,i=t.offsetLeft+t.clientLeft,n=i+t.clientWidth;return s?i<c:n>h}:function(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>r});g>0&&g<p&&!n&&(g=o(g,t,r));let f=n?c:-1;for(let e=g;e<p;e++){const i=t[e],s=i.div,a=s.offsetLeft+s.clientLeft,o=s.offsetTop+s.clientTop,p=s.clientWidth,g=s.clientHeight,m=a+p,_=o+g;if(-1===f)_>=l&&(f=_);else if((n?a:o)>f)break;if(_<=r||o>=l||m<=h||a>=c)continue;const v=Math.max(0,r-o)+Math.max(0,_-l),b=(p-(Math.max(0,h-a)+Math.max(0,m-c)))/p,y=(g-v)/g*b*100|0;d.push({id:i.id,x:a,y:o,view:i,percent:y,widthPercent:100*b|0}),u.add(i.id)}const m=d[0],_=d.at(-1);return i&&d.sort((function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id})),{first:m,last:_,views:d,ids:u}},t.isPortraitOrientation=function(e){return e.width<=e.height},t.isValidRotation=function(e){return Number.isInteger(e)&&e%90==0},t.isValidScrollMode=function(e){return Number.isInteger(e)&&Object.values(n).includes(e)&&e!==n.UNKNOWN},t.isValidSpreadMode=function(e){return Number.isInteger(e)&&Object.values(s).includes(e)&&e!==s.UNKNOWN},t.normalizeWheelEventDelta=function(e){const t=e.deltaMode;let i=l(e);return t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30),i},t.normalizeWheelEventDirection=l,t.parseQueryString=function(e){const t=new Map;for(const[i,n]of new URLSearchParams(e))t.set(i.toLowerCase(),n);return t},t.removeNullCharacters=function(e,t=!1){return"string"!=typeof e?(console.error("The argument must be a string."),e):(t&&(e=e.replaceAll(r," ")),e.replaceAll("\0",""))},t.roundToDivide=function(e,t){const i=e%t;return 0===i?e:Math.round(e-i+t)},t.scrollIntoView=function(e,t,i=!1){let n=e.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=e.offsetTop+e.clientTop,r=e.offsetLeft+e.clientLeft;for(;n.clientHeight===n.scrollHeight&&n.clientWidth===n.scrollWidth||i&&(n.classList.contains("markedContent")||"hidden"===getComputedStyle(n).overflow);)if(s+=n.offsetTop,r+=n.offsetLeft,n=n.offsetParent,!n)return;t&&(void 0!==t.top&&(s+=t.top),void 0!==t.left&&(r+=t.left,n.scrollLeft=r)),n.scrollTop=s},t.toggleCheckedBtn=function(e,t,i=null){e.classList.toggle("toggled",t),e.setAttribute("aria-checked",t),i?.classList.toggle("hidden",!t)},t.toggleExpandedBtn=function(e,t,i=null){e.classList.toggle("toggled",t),e.setAttribute("aria-expanded",t),i?.classList.toggle("hidden",!t)},t.watchScroll=function(e,t){const i=function(i){s||(s=window.requestAnimationFrame((function(){s=null;const i=e.scrollLeft,r=n.lastX;i!==r&&(n.right=i>r),n.lastX=i;const a=e.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,t(n)})))},n={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:i};let s=null;return e.addEventListener("scroll",i,!0),n},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{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}};const r=/[\x01-\x1F]/g;function a(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 o(e,t,i){if(e<2)return e;let n=t[e].div,s=n.offsetTop+n.clientTop;s>=i&&(n=t[e-1].div,s=n.offsetTop+n.clientTop);for(let i=e-2;i>=0&&(n=t[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)e=i;return e}function l(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t),t}const h=new Promise((function(e){window.requestAnimationFrame(e)}));t.animationStarted=h;const c=document.documentElement.style;t.docStyle=c,t.ProgressBar=class{#es=null;#ts=null;#is=0;#ns=null;#mt=!0;constructor(e){this.#es=e.classList,this.#ns=e.style}get percent(){return this.#is}set percent(e){var t,i,n;this.#is=(t=e,i=0,n=100,Math.min(Math.max(t,i),n)),isNaN(e)?this.#es.add("indeterminate"):(this.#es.remove("indeterminate"),this.#ns.setProperty("--progressBar-percent",`${this.#is}%`))}setWidth(e){if(!e)return;const t=e.parentNode.offsetWidth-e.offsetWidth;t>0&&this.#ns.setProperty("--progressBar-end-offset",`${t}px`)}setDisableAutoFetch(e=5e3){isNaN(this.#is)||(this.#ts&&clearTimeout(this.#ts),this.show(),this.#ts=setTimeout((()=>{this.#ts=null,this.hide()}),e))}hide(){this.#mt&&(this.#mt=!1,this.#es.add("hidden"))}show(){this.#mt||(this.#mt=!0,this.#es.remove("hidden"))}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CharacterType=void 0,t.getCharacterType=function(e){return function(e){return e<11904}(e)?function(e){return 0==(65408&e)}(e)?function(e){return 32===e||9===e||13===e||10===e}(e)?i.SPACE:function(e){return e>=97&&e<=122||e>=65&&e<=90}(e)||function(e){return e>=48&&e<=57}(e)||95===e?i.ALPHA_LETTER:i.PUNCT:function(e){return 3584==(65408&e)}(e)?i.THAI_LETTER:160===e?i.SPACE:i.ALPHA_LETTER:function(e){return e>=13312&&e<=40959||e>=63744&&e<=64255}(e)?i.HAN_LETTER:function(e){return e>=12448&&e<=12543}(e)?i.KATAKANA_LETTER:function(e){return e>=12352&&e<=12447}(e)?i.HIRAGANA_LETTER:function(e){return e>=65376&&e<=65439}(e)?i.HALFWIDTH_KATAKANA_LETTER:i.ALPHA_LETTER},t.getNormalizeWithNFKC=function(){return n||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",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};let n;t.CharacterType=i},e=>{e.exports=globalThis.pdfjsLib},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleLinkService=t.PDFLinkService=t.LinkTarget=void 0;var n=i(2);const s={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};function r(e,{url:t,target:i,rel:n,enabled:r=!0}={}){if(!t||"string"!=typeof t)throw new Error('A valid "url" parameter must provided.');r?e.href=e.title=t:(e.href="",e.title=`Disabled: ${t}`,e.onclick=()=>!1);let a="";switch(i){case s.NONE:break;case s.SELF:a="_self";break;case s.BLANK:a="_blank";break;case s.PARENT:a="_parent";break;case s.TOP:a="_top"}e.target=a,e.rel="string"==typeof n?n:"noopener noreferrer nofollow"}t.LinkTarget=s;class a{#ss=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.#ss.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}#rs(e,t=null,i){const n=i[0];let s;if("object"==typeof n&&null!==n){if(s=this._cachedPageNumber(n),!s)return void this.pdfDocument.getPageIndex(n).then((s=>{this.cachePageRef(s+1,n),this.#rs(e,t,i)})).catch((()=>{console.error(`PDFLinkService.#goToDestinationHelper: "${n}" is not a valid page reference, for dest="${e}".`)}))}else{if(!Number.isInteger(n))return void console.error(`PDFLinkService.#goToDestinationHelper: "${n}" is not a valid destination reference, for dest="${e}".`);s=n+1}!s||s<1||s>this.pagesCount?console.error(`PDFLinkService.#goToDestinationHelper: "${s}" is not a valid page number, for dest="${e}".`):(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;"string"==typeof e?(t=e,i=await this.pdfDocument.getDestination(e)):(t=null,i=await e),Array.isArray(i)?this.#rs(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;Number.isInteger(t)&&t>0&&t<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(t)),this.pdfViewer.scrollPageIntoView({pageNumber:t})):console.error(`PDFLinkService.goToPage: "${e}" is not a valid page.`)}addLinkAttributes(e,t,i=!1){r(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)})}if(s.has("page")&&(t=0|s.get("page")||1),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||a.#as(i))return void this.goToDestination(i);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.#ss.set(i,e)}_cachedPageNumber(e){if(!e)return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#ss.get(t)||null}static#as(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=a,t.SimpleLinkService=class{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){r(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.AnnotationLayerBuilder=void 0;var n=i(4),s=i(7),r=i(2);t.AnnotationLayerBuilder=class{#os=null;constructor({pageDiv:e,pdfPage:t,linkService:i,downloadManager:n,annotationStorage:r=null,imageResourcesPath:a="",renderForms:o=!0,l10n:l=s.NullL10n,enableScripting:h=!1,hasJSActionsPromise:c=null,fieldObjectsPromise:d=null,annotationCanvasMap:u=null,accessibilityManager:p=null}){this.pageDiv=e,this.pdfPage=t,this.linkService=i,this.downloadManager=n,this.imageResourcesPath=a,this.renderForms=o,this.l10n=l,this.annotationStorage=r,this.enableScripting=h,this._hasJSActionsPromise=c||Promise.resolve(!1),this._fieldObjectsPromise=d||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;return void this.annotationLayer.update({viewport:e.clone({dontFlip:!0})})}const[i,s,a]=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),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:a}),this.linkService.isInPresentationMode&&this.#ls(r.PresentationModeState.FULLSCREEN),this.#os||(this.#os=e=>{this.#ls(e.state)},this._eventBus?._on("presentationmodechanged",this.#os))):this.hide()}cancel(){this._cancelled=!0,this.#os&&(this._eventBus?._off("presentationmodechanged",this.#os),this.#os=null)}hide(){this.div&&(this.div.hidden=!0)}#ls(e){if(!this.div)return;let t=!1;switch(e){case r.PresentationModeState.FULLSCREEN:t=!0;break;case r.PresentationModeState.NORMAL:break;default:return}for(const e of this.div.childNodes)e.hasAttribute("data-internal-link")||(e.inert=t)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.NullL10n=void 0,t.getL10nFallback=n;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"};function n(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]||""}i.print_progress_percent="{{progress}}%";const s={getLanguage:async()=>"en-us",getDirection:async()=>"ltr",get:async(e,t=null,i=n(e,t))=>function(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=s},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DownloadManager=void 0;var n=i(4);function s(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{#hs=new WeakMap;downloadUrl(e,t,i){(0,n.createValidAbsoluteUrl)(e,"http://example.com")?s(e+"#pdfjs.action=download",t):console.error(`downloadUrl - not a valid URL: ${e}`)}downloadData(e,t,i){s(URL.createObjectURL(new Blob([e],{type:i})),t)}openOrDownloadData(e,t,i){const s=(0,n.isPdfFile)(i)?"application/pdf":"";return this.downloadData(t,i,s),!1}download(e,t,i,n){s(URL.createObjectURL(e),i)}}},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.WaitOnType=t.EventBus=t.AutomationEventBus=void 0,t.waitOnEventOrTimeout=function({target:e,name:t,delay:s=0}){return new Promise((function(r,a){if("object"!=typeof e||!t||"string"!=typeof t||!(Number.isInteger(s)&&s>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");function o(i){e instanceof n?e._off(t,l):e.removeEventListener(t,l),c&&clearTimeout(c),r(i)}const l=o.bind(null,i.EVENT);e instanceof n?e._on(t,l):e.addEventListener(t,l);const h=o.bind(null,i.TIMEOUT),c=setTimeout(h,s)}))};const i={EVENT:"event",TIMEOUT:"timeout"};t.WaitOnType=i;class n{#a=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.#a[e];if(!i||0===i.length)return;let n;for(const{listener:s,external:r,once:a}of i.slice(0))a&&this._off(e,s),r?(n||=[]).push(s):s(t);if(n){for(const e of n)e(t);n=null}}_on(e,t,i=null){(this.#a[e]||=[]).push({listener:t,external:!0===i?.external,once:!0===i?.once})}_off(e,t,i=null){const n=this.#a[e];if(n)for(let e=0,i=n.length;e<i;e++)if(n[e].listener===t)return void n.splice(e,1)}}t.EventBus=n,t.AutomationEventBus=class extends n{dispatch(e,t){throw new Error("Not implemented: AutomationEventBus.dispatch")}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GenericL10n=void 0,i(11);var n=i(7);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{constructor(e){const{webL10n:t}=document;this._lang=e,this._ready=new Promise(((i,n)=>{var r;t.setLanguage((r=e,s[r?.toLowerCase()]||r),(()=>{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",r="",a={},o="loading",l=!0;function h(e,t,i){t=t||function(e){},i=i||function(){};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 c(e,t,r,a){var o=e.replace(/[^\/]*$/,"")||"./";function l(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,"'")}h(e,(function(e){n+=e,function(e,i){var n={},s=/^\s*|\s*$/,r=/^\s*#|^\s*$/,a=/^\s*\[(.*)\]\s*$/,c=/^\s*@import\s+url\((.*)\)\s*$/i,d=/^([^=\s]*)\s*=\s*(.+)$/;function u(e,i,h){var u=e.replace(s,"").split(/[\r\n]+/),g="*",f=t.split("-",1)[0],m=!1,_="";!function e(){for(;;){if(!u.length)return void h();var s=u.shift();if(!r.test(s)){if(i){if(_=a.exec(s)){g=_[1].toLowerCase(),m="*"!==g&&g!==t&&g!==f;continue}if(m)continue;if(_=c.exec(s))return void p(o+_[1],e)}var v=s.match(d);v&&3==v.length&&(n[v[1]]=l(v[2]))}}}()}function p(e,t){h(e,(function(e){u(e,!1,t)}),(function(){console.warn(e+" not found."),t()}))}u(e,!0,(function(){i(n)}))}(e,(function(e){for(var t in e){var n,a,o=t.lastIndexOf(".");o>0?(n=t.substring(0,o),a=t.substring(o+1)):(n=t,a=s),i[n]||(i[n]={}),i[n][a]=e[t]}r&&r()}))}),a)}function d(e,s){e&&(e=e.toLowerCase()),s=s||function(){},i={},n="",r="",r=e;var a=t.querySelectorAll('link[type="application/l10n"]'),l=a.length;if(0!==l){var h,d,u=0;d=function(){++u>=l&&(s(),o="complete")};for(var p=0;p<l;p++)new _(a[p]).load(e,d)}else{var g=(h=t.querySelector('script[type="application/l10n"]'))?JSON.parse(h.innerHTML):null;if(g&&g.locales&&g.default_locale){if(console.log("using the embedded JSON directory, early way out"),!(i=g.locales[e])){var f=g.default_locale.toLowerCase();for(var m in g.locales){if((m=m.toLowerCase())===e){i=g.locales[e];break}m===f&&(i=g.locales[f])}}s()}else console.log("no resource to load, early way out");o="complete"}function _(e){var t=e.href;this.load=function(e,i){c(t,e,i,(function(){console.warn(t+" not found."),console.warn('"'+e+'" resource not found'),r="",i()}))}}}function u(e,t,n){var s=i[e];if(!s){if(console.warn("#"+e+" is undefined."),!n)return null;s=n}var r={};for(var a in s){var o=s[a];o=g(o=p(o,t,e,a),t,e),r[a]=o}return r}function p(e,t,n,s){var r=/\{\[\s*([a-zA-Z]+)\(([a-zA-Z]+)\)\s*\]\}/.exec(e);if(!r||!r.length)return e;var o,l=r[1],h=r[2];return t&&h in t?o=t[h]:h in i&&(o=i[h]),l in a&&(e=(0,a[l])(e,o,n,s)),e}function g(e,t,n){return e.replace(/\{\{\s*(.+?)\s*\}\}/g,(function(e,s){return t&&s in t?t[s]:s in i?i[s]:(console.log("argument {{"+s+"}} for #"+n+" is undefined."),e)}))}function f(e){var i=function(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=u(i.id,i.args);if(n){if(n[s]){if(0===function(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 r=e.childNodes,a=!1,o=0,l=r.length;o<l;o++)3===r[o].nodeType&&/\S/.test(r[o].nodeValue)&&(a?r[o].nodeValue="":(r[o].nodeValue=n[s],a=!0));if(!a){var h=t.createTextNode(n[s]);e.prepend(h)}}delete n[s]}for(var c in n)e[c]=n[c]}else console.warn("#"+i.id+" is undefined.")}}return a.plural=function(e,t,n,o){var l=parseFloat(t);if(isNaN(l))return e;if(o!=s)return e;a._pluralRules||(a._pluralRules=function(e){function t(e,t){return-1!==t.indexOf(e)}function i(e,t,i){return t<=e&&e<=i}var n={0:function(e){return"other"},1:function(e){return i(e%100,3,10)?"few":0===e?"zero":i(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 i(e,0,1)?"one":"other"},5:function(e){return i(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 i(e,3,6)?"few":i(e,7,10)?"many":2==e?"two":1==e?"one":"other"},9:function(e){return 0===e||1!=e&&i(e%100,1,19)?"few":1==e?"one":"other"},10:function(e){return i(e%10,2,9)&&!i(e%100,11,19)?"few":e%10!=1||i(e%100,11,19)?"other":"one"},11:function(e){return i(e%10,2,4)&&!i(e%100,12,14)?"few":e%10==0||i(e%10,5,9)||i(e%100,11,14)?"many":e%10==1&&e%100!=11?"one":"other"},12:function(e){return i(e,2,4)?"few":1==e?"one":"other"},13:function(e){return i(e%10,2,4)&&!i(e%100,12,14)?"few":1!=e&&i(e%10,0,1)||i(e%10,5,9)||i(e%100,12,14)?"many":1==e?"one":"other"},14:function(e){return i(e%100,3,4)?"few":e%100==2?"two":e%100==1?"one":"other"},15:function(e){return 0===e||i(e%100,2,10)?"few":i(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":i(e,0,2)&&0!==e&&2!=e?"one":"other"},19:function(e){return i(e,2,10)?"few":i(e,0,1)?"one":"other"},20:function(e){return!i(e%10,3,4)&&e%10!=9||i(e%100,10,19)||i(e%100,70,79)||i(e%100,90,99)?e%1e6==0&&0!==e?"many":e%10!=2||t(e%100,[12,72,92])?e%10!=1||t(e%100,[11,71,91])?"other":"one":"two":"few"},21:function(e){return 0===e?"zero":1==e?"one":"other"},22:function(e){return i(e,0,1)||i(e,11,99)?"one":"other"},23:function(e){return i(e%10,1,2)||e%20==0?"one":"other"},24:function(e){return i(e,3,10)||i(e,13,19)?"few":t(e,[2,12])?"two":t(e,[1,11])?"one":"other"}},s={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(/-.*$/,"")];return s in n?n[s]:(console.warn("plural form unknown for ["+e+"]"),function(){return"other"})}(r));var h="["+a._pluralRules(l)+"]";return 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+h in i?e=i[n+h][o]:n+"[other]"in i&&(e=i[n+"[other]"][o]),e},{get:function(e,t,i){var n,r=e.lastIndexOf("."),a=s;r>0&&(a=e.substring(r+1),e=e.substring(0,r)),i&&((n={})[a]=i);var o=u(e,t,n);return o&&a in o?o[a]:"{{"+e+"}}"},getData:function(){return i},getText:function(){return n},getLanguage:function(){return r},setLanguage:function(e,t){d(e,(function(){t&&t()}))},getDirection:function(){var e=r.split("-",1)[0];return["ar","he","fa","ps","ur"].indexOf(e)>=0?"rtl":"ltr"},translate:function(e){for(var i=function(e){return e?e.querySelectorAll("*[data-l10n-id]"):[]}(e=e||t.documentElement),n=i.length,s=0;s<n;s++)f(i[s]);f(e)},getReadyState:function(){return o},ready:function(i){i&&("complete"==o||"interactive"==o?e.setTimeout((function(){i()})):t.addEventListener&&t.addEventListener("localized",(function e(){t.removeEventListener("localized",e),i()})))}}}(window,document)},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFHistory=void 0,t.isDestArraysEqual=o,t.isDestHashesEqual=a;var n=i(2),s=i(9);function r(){return document.location.hash}function a(e,t){return"string"==typeof e&&"string"==typeof t&&(e===t||(0,n.parseQueryString)(e).get("nameddest")===t)}function o(e,t){function i(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 n in e)if(!i(e[n],t[n]))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 n=0,s=e.length;n<s;n++)if(!i(e[n],t[n]))return!1;return!0}t.PDFHistory=class{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)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');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;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=r(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this._isValidState(s,!0)||t){const{hash:e,page:i,rotation:s}=this._parseCurrentHash(!0);return!e||n||t?void this._pushOrReplaceState(null,!0):void this._pushOrReplaceState({hash:e,page:i,rotation:s},!0)}const a=s.destination;this._updateInternalState(a,s.uid,!0),void 0!==a.rotation&&(this._initialRotation=a.rotation),a.dest?(this._initialBookmark=JSON.stringify(a.dest),this._destination.page=null):a.hash?this._initialBookmark=a.hash:a.page&&(this._initialBookmark=`page=${a.page}`)}reset(){this._initialized&&(this._pageHide(),this._initialized=!1,this._unbindEvents()),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)return void console.error(`PDFHistory.push: "${e}" is not a valid namedDest parameter.`);if(!Array.isArray(t))return void console.error(`PDFHistory.push: "${t}" is not a valid explicitDest parameter.`);if(!this._isValidPage(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const n=e||JSON.stringify(t);if(!n)return;let s=!1;if(this._destination&&(a(this._destination.hash,n)||o(this._destination.dest,t))){if(this._destination.page)return;s=!0}this._popStateInProgress&&!s||(this._pushOrReplaceState({dest:t,hash:n,page:i,rotation:this.linkService.rotation},s),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(e){this._initialized&&(this._isValidPage(e)?this._destination?.page!==e&&(this._popStateInProgress||(this._pushOrReplaceState({dest:null,hash:`page=${e}`,page:e,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):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};let s;if(this._updateInternalState(e,n.uid),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),!this._destination)return void this._pushOrReplaceState(t);if(this._destination.temporary)return void this._pushOrReplaceState(t,!0);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){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(r()).substring(1),i=(0,n.parseQueryString)(t),s=i.get("nameddest")||"";let a=0|i.get("page");return(!this._isValidPage(a)||e&&s.length>0)&&(a=null),{hash:t,page:a,rotation:this.linkService.rotation}}_updateViewarea({location:e}){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},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=r(),i=this._currentHash!==t;if(this._currentHash=t,!e){this._uid++;const{hash:e,page:t,rotation:i}=this._parseCurrentHash();return void this._pushOrReplaceState({hash:e,page:t,rotation:i},!0)}if(!this._isValidState(e))return;this._popStateInProgress=!0,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(){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(){this._boundEvents&&(this.eventBus._off("updateviewarea",this._boundEvents.updateViewarea),window.removeEventListener("popstate",this._boundEvents.popState),window.removeEventListener("pagehide",this._boundEvents.pageHide),this._boundEvents=null)}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFPageView=void 0;var n=i(4),s=i(2),r=i(14),a=i(6),o=i(15),l=i(7),h=i(5),c=i(16),d=i(17),u=i(18),p=i(19),g=i(20);const f=o.compatibilityParams.maxCanvasPixels||16777216,m=()=>({annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new h.SimpleLinkService}});t.PDFPageView=class{#cs=n.AnnotationMode.ENABLE_FORMS;#ds=!1;#us=null;#ps=null;#gs=null;#fs=null;#ms=s.RenderingStates.INITIAL;#_s=s.TextLayerMode.ENABLE;#vs={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#bs=new WeakMap;constructor(e){const t=e.container,i=e.defaultViewport;this.id=e.id,this.renderingId="page"+this.id,this.#us=e.layerProperties||m,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.#_s=e.textLayerMode??s.TextLayerMode.ENABLE,this.#cs=e.annotationMode??n.AnnotationMode.ENABLE_FORMS,this.imageResourcesPath=e.imageResourcesPath||"",this.isOffscreenCanvasSupported=e.isOffscreenCanvasSupported??!0,this.maxCanvasPixels=e.maxCanvasPixels??f,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,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 r=document.createElement("div");if(r.className="page",r.setAttribute("data-page-number",this.id),r.setAttribute("role","region"),this.l10n.get("page_landmark",{page:this.id}).then((e=>{r.setAttribute("aria-label",e)})),this.div=r,this.#Tn(),t?.append(r),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.#vs.initialOptionalContent=e.hasInitialVisibility)}))}}get renderingState(){return this.#ms}set renderingState(e){if(e!==this.#ms)switch(this.#ms=e,this.#ps&&(clearTimeout(this.#ps),this.#ps=null),e){case s.RenderingStates.PAUSED:this.div.classList.remove("loading");break;case s.RenderingStates.RUNNING:this.div.classList.add("loadingIcon"),this.#ps=setTimeout((()=>{this.div.classList.add("loading"),this.#ps=null}),0);break;case s.RenderingStates.INITIAL:case s.RenderingStates.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#Tn(){const{viewport:e}=this;if(this.pdfPage){if(this.#gs===e.rotation)return;this.#gs=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.#Tn(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}get _textHighlighter(){return(0,n.shadow)(this,"_textHighlighter",new u.TextHighlighter({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#us().findController}))}async#ys(){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#Ss(){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#Ps(){let e=null;try{const e=await this.xfaLayer.render(this.viewport,"display");e?.textDivs&&this._textHighlighter&&this.#As(e.textDivs)}catch(t){console.error(`#renderXfaLayer: "${t}".`),e=t}finally{this.eventBus.dispatch("xfalayerrendered",{source:this,pageNumber:this.id,error:e})}}async#ws(){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.#Es()}async#Es(){if(!this.textLayer)return;this.structTreeLayer||=new c.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#As(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.#bs.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:r=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:i,keepXfaLayer:n,keepTextLayer:r}),this.renderingState=s.RenderingStates.INITIAL;const a=this.div,o=a.childNodes,l=e&&this.zoomLayer||null,h=t&&this.annotationLayer?.div||null,c=i&&this.annotationEditorLayer?.div||null,d=n&&this.xfaLayer?.div||null,u=r&&this.textLayer?.div||null;for(let e=o.length-1;e>=0;e--){const t=o[e];switch(t){case l:case h:case c:case d:case u:continue}t.remove()}a.removeAttribute("data-loaded"),h&&this.annotationLayer.hide(),c&&this.annotationEditorLayer.hide(),d&&this.xfaLayer.hide(),u&&this.textLayer.hide(),this.structTreeLayer?.hide(),l||(this.canvas&&(this.#bs.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:r=-1}){this.scale=e||this.scale,"number"==typeof t&&(this.rotation=t),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((e=>{i===this._optionalContentConfigPromise&&(this.#vs.initialOptionalContent=e.hasInitialVisibility)}))),this.#vs.directDrawing=!0;const a=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*n.PixelsPerInch.PDF_TO_CSS_UNITS,rotation:a}),this.#Tn(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let e=!1;if(this.#ds)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&&r>=0&&r<1e3;if(t||e){if(t&&this.renderingState!==s.RenderingStates.FINISHED&&(this.cancelRendering({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:r}),this.renderingState=s.RenderingStates.FINISHED,this.#vs.directDrawing=!1),this.cssTransform({target:this.canvas,redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!t,hideTextLayer:t}),t)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#fs})}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}={}){this.renderTask&&(this.renderTask.cancel(s),this.renderTask=null),this.resume=null,!this.textLayer||n&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationLayer||e&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),!this.annotationEditorLayer||t&&this.annotationEditorLayer.div||(this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!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:r=!1}){if(!e.hasAttribute("zooming")){e.setAttribute("zooming",!0);const{style:t}=e;t.width=t.height=""}const a=this.#bs.get(e);if(this.viewport!==a){const t=this.viewport.rotation-a.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.#ys(),i&&this.annotationEditorLayer&&this.#Ss(),n&&this.xfaLayer&&this.#Ps(),this.textLayer&&(r?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#ws())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(e,t){return this.viewport.convertToPdfPoint(e,t)}async#xs(e,t=null){if(e===this.renderTask&&(this.renderTask=null),t instanceof n.RenderingCancelledException)this.#fs=null;else if(this.#fs=t,this.renderingState=s.RenderingStates.FINISHED,this._resetZoomLayer(!0),this.#vs.regularAnnotations=!e.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#fs}),t)throw t}async draw(){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)throw this.renderingState=s.RenderingStates.FINISHED,new Error("pdfPage is not loaded");this.renderingState=s.RenderingStates.RUNNING;const h=document.createElement("div");if(h.classList.add("canvasWrapper"),e.append(h),this.textLayer||this.#_s===s.TextLayerMode.DISABLE||o.isPureXfa||(this._accessibilityManager||=new d.TextAccessibilityManager,this.textLayer=new p.TextLayerBuilder({highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,enablePermissions:this.#_s===s.TextLayerMode.ENABLE_PERMISSIONS}),e.append(this.textLayer.div)),!this.annotationLayer&&this.#cs!==n.AnnotationMode.DISABLE){const{annotationStorage:i,downloadManager:s,enableScripting:r,fieldObjectsPromise:l,hasJSActionsPromise:h,linkService:c}=this.#us();this._annotationCanvasMap||=new Map,this.annotationLayer=new a.AnnotationLayerBuilder({pageDiv:e,pdfPage:o,annotationStorage:i,imageResourcesPath:this.imageResourcesPath,renderForms:this.#cs===n.AnnotationMode.ENABLE_FORMS,linkService:c,downloadManager:s,l10n:t,enableScripting:r,hasJSActionsPromise:h,fieldObjectsPromise:l,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager})}const{width:c,height:u}=l,f=document.createElement("canvas");f.setAttribute("role","presentation"),f.hidden=!0;const m=!(!i?.background||!i?.foreground);let _=e=>{m&&!e||(f.hidden=!1,_=null)};h.append(f),this.canvas=f;const v=f.getContext("2d",{alpha:!1}),b=this.outputScale=new s.OutputScale;if(0===this.maxCanvasPixels){const e=1/this.scale;b.sx*=e,b.sy*=e,this.#ds=!0}else if(this.maxCanvasPixels>0){const e=c*u,t=Math.sqrt(this.maxCanvasPixels/e);b.sx>t||b.sy>t?(b.sx=t,b.sy=t,this.#ds=!0):this.#ds=!1}const y=(0,s.approximateFraction)(b.sx),S=(0,s.approximateFraction)(b.sy);f.width=(0,s.roundToDivide)(c*b.sx,y[0]),f.height=(0,s.roundToDivide)(u*b.sy,S[0]);const{style:P}=f;P.width=(0,s.roundToDivide)(c,y[1])+"px",P.height=(0,s.roundToDivide)(u,S[1])+"px",this.#bs.set(f,l);const A={canvasContext:v,transform:b.scaled?[b.sx,0,0,b.sy,0,0]:null,viewport:l,annotationMode:this.#cs,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i},w=this.renderTask=this.pdfPage.render(A);w.onContinue=e=>{if(_?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=s.RenderingStates.PAUSED,void(this.resume=()=>{this.renderingState=s.RenderingStates.RUNNING,e()});e()};const E=w.promise.then((async()=>{if(_?.(!0),await this.#xs(w),this.#ws(),this.annotationLayer&&await this.#ys(),!this.annotationEditorLayer){const{annotationEditorUIManager:i}=this.#us();if(!i)return;this.annotationEditorLayer=new r.AnnotationEditorLayerBuilder({uiManager:i,pageDiv:e,pdfPage:o,l10n:t,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer})}this.#Ss()}),(e=>(e instanceof n.RenderingCancelledException||_?.(!0),this.#xs(w,e))));if(o.isPureXfa){if(this.xfaLayer)this.xfaLayer.div&&e.append(this.xfaLayer.div);else{const{annotationStorage:t,linkService:i}=this.#us();this.xfaLayer=new g.XfaLayerBuilder({pageDiv:e,pdfPage:o,annotationStorage:t,linkService:i})}this.#Ps()}return e.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),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.#vs;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(7);t.AnnotationEditorLayerBuilder=class{#wt=null;#Ft;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.#Ft=e.uiManager,this.#wt=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)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.tabIndex=0,s.hidden=!0,s.dir=this.#Ft.direction,this.pageDiv.append(s),this.annotationEditorLayer=new n.AnnotationEditorLayer({uiManager:this.#Ft,div:s,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#wt});const r={viewport:i,div:s,annotations:null,intent:t};this.annotationEditorLayer.render(r),this.show()}cancel(){this._cancelled=!0,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)=>{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);(/\b(iPad|iPhone|iPod)(?=;)/.test(e)||"MacIntel"===t&&n>1||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 r=Object.create(null);class a{constructor(){throw new Error("Cannot initialize AppOptions.")}static get(e){const t=r[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 a in s){const o=s[a];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[a]=e;continue}throw new Error(`Invalid type for preference: ${a}`)}}const l=r[a];t[a]=void 0!==l?l:i[a]??o.value}return t}static set(e,t){r[e]=t}static setAll(e){for(const t in e)r[t]=e[t]}static remove(e){delete r[e]}}t.AppOptions=a,a._hasUserOptions=function(){return Object.keys(r).length>0}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.StructTreeLayerBuilder=void 0;var n=i(2);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},r=/^H(\d+)$/;t.StructTreeLayerBuilder=class{#Cs=void 0;get renderingDone(){return void 0!==this.#Cs}render(e){if(void 0!==this.#Cs)return this.#Cs;const t=this.#Ms(e);return t?.classList.add("structTree"),this.#Cs=t}hide(){this.#Cs&&!this.#Cs.hidden&&(this.#Cs.hidden=!0)}show(){this.#Cs?.hidden&&(this.#Cs.hidden=!1)}#Ts(e,t){const{alt:i,id:s,lang:r}=e;void 0!==i&&t.setAttribute("aria-label",(0,n.removeNullCharacters)(i)),void 0!==s&&t.setAttribute("aria-owns",s),void 0!==r&&t.setAttribute("lang",(0,n.removeNullCharacters)(r,!0))}#Ms(e){if(!e)return null;const t=document.createElement("span");if("role"in e){const{role:i}=e,n=i.match(r);n?(t.setAttribute("role","heading"),t.setAttribute("aria-level",n[1])):s[i]&&t.setAttribute("role",s[i])}if(this.#Ts(e,t),e.children)if(1===e.children.length&&"id"in e.children[0])this.#Ts(e.children[0],t);else for(const i of e.children)t.append(this.#Ms(i));return t}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextAccessibilityManager=void 0;var n=i(2);class s{#Ds=!1;#Fs=null;#ks=new Map;#Ls=new Map;setTextMapping(e){this.#Fs=e}static#Rs(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,r=i.y+i.height,a=i.y+i.height/2,o=n.y,l=n.y+n.height,h=n.y+n.height/2;return a<=o&&h>=r?-1:h<=s&&a>=l?1:i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#Ds)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Fs)throw new Error("Text divs and strings have not been set.");if(this.#Ds=!0,this.#Fs=this.#Fs.slice(),this.#Fs.sort(s.#Rs),this.#ks.size>0){const e=this.#Fs;for(const[t,i]of this.#ks)document.getElementById(t)?this.#Is(t,e[i]):this.#ks.delete(t)}for(const[e,t]of this.#Ls)this.addPointerInTextLayer(e,t);this.#Ls.clear()}disable(){this.#Ds&&(this.#Ls.clear(),this.#Fs=null,this.#Ds=!1)}removePointerInTextLayer(e){if(!this.#Ds)return void this.#Ls.delete(e);const t=this.#Fs;if(!t||0===t.length)return;const{id:i}=e,n=this.#ks.get(i);if(void 0===n)return;const s=t[n];this.#ks.delete(i);let r=s.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter((e=>e!==i)).join(" "),r?s.setAttribute("aria-owns",r):(s.removeAttribute("aria-owns"),s.setAttribute("role","presentation")))}#Is(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.#Ds)return this.#Ls.set(e,t),null;t&&this.removePointerInTextLayer(e);const r=this.#Fs;if(!r||0===r.length)return null;const a=(0,n.binarySearchFirstItem)(r,(t=>s.#Rs(e,t)<0)),o=Math.max(0,a-1),l=r[o];this.#Is(i,l),this.#ks.set(i,o);const h=l.parentNode;return h?.classList.contains("markedContent")?h.id:null}moveElementInDOM(e,t,i,r){const a=this.addPointerInTextLayer(i,r);if(!e.hasChildNodes())return e.append(t),a;const o=Array.from(e.childNodes).filter((e=>e!==t));if(0===o.length)return a;const l=i||t,h=(0,n.binarySearchFirstItem)(o,(e=>s.#Rs(l,e)<0));return 0===h?o[0].before(t):o[h-1].after(t),a}}t.TextAccessibilityManager=s},(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TextHighlighter=void 0,t.TextHighlighter=class{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,this._onUpdateTextLayerMatches||(this._onUpdateTextLayerMatches=e=>{e.pageIndex!==this.pageIdx&&-1!==e.pageIndex||this._updateMatches()},this.eventBus._on("updatetextlayermatches",this._onUpdateTextLayerMatches)),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,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 r=i.length-1,a=[];for(let o=0,l=e.length;o<l;o++){let l=e[o];for(;n!==r&&l>=s+i[n].length;)s+=i[n].length,n++;n===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:n,offset:l-s}};for(l+=t[o];n!==r&&l>s+i[n].length;)s+=i[n].length,n++;h.end={divIdx:n,offset:l-s},a.push(h)}return a}_renderMatches(e){if(0===e.length)return;const{findController:t,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,r=i===t.selected.pageIdx,a=t.selected.matchIdx;let o=null;const l={divIdx:-1,offset:void 0};function h(e,t){const i=e.divIdx;return s[i].textContent="",c(i,0,e.offset,t)}function c(e,t,i,r){let a=s[e];if(a.nodeType===Node.TEXT_NODE){const t=document.createElement("span");a.before(t),t.append(a),s[e]=t,a=t}const o=n[e].substring(t,i),l=document.createTextNode(o);if(r){const e=document.createElement("span");return e.className=`${r} appended`,e.append(l),a.append(e),r.includes("selected")?e.offsetLeft:0}return a.append(l),0}let d=a,u=d+1;if(t.state.highlightAll)d=0,u=e.length;else if(!r)return;let p=-1,g=-1;for(let n=d;n<u;n++){const d=e[n],u=d.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=d.end,m=r&&n===a,_=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?c(o.divIdx,o.offset,u.offset):(null!==o&&c(o.divIdx,o.offset,l.offset),h(u)),u.divIdx===f.divIdx)v=c(u.divIdx,u.offset,f.offset,"highlight"+_);else{v=c(u.divIdx,u.offset,l.offset,"highlight begin"+_);for(let e=u.divIdx+1,t=f.divIdx;e<t;e++)s[e].className="highlight middle"+_;h(f,"highlight end"+_)}o=f,m&&t.scrollMatchIntoView({element:s[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&c(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:r}=this;let a=-1;for(const e of i){for(let t=Math.max(a,e.begin.divIdx),i=e.end.divIdx;t<=i;t++){const e=r[t];e.textContent=s[t],e.className=""}a=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(2);t.TextLayerBuilder=class{#Os=!1;#Ns=0;#Bs=0;#Vs=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.#Os=!0===n,this.div=document.createElement("div"),this.div.className="textLayer",this.hide()}#Us(){this.renderingDone=!0;const e=document.createElement("div");e.className="endOfContent",this.div.append(e),this.#js()}get numTextDivs(){return this.textDivs.length}async render(e){if(!this.#Vs)throw new Error('No "textContentSource" parameter specified.');const t=e.scale*(globalThis.devicePixelRatio||1),{rotation:i}=e;if(this.renderingDone){const s=i!==this.#Ns,r=t!==this.#Bs;return(s||r)&&(this.hide(),(0,n.updateTextLayer)({container:this.div,viewport:e,textDivs:this.textDivs,textDivProperties:this.textDivProperties,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,mustRescale:r,mustRotate:s}),this.#Bs=t,this.#Ns=i),void this.show()}this.cancel(),this.highlighter?.setTextMapping(this.textDivs,this.textContentItemsStr),this.accessibilityManager?.setTextMapping(this.textDivs),this.textLayerRenderTask=(0,n.renderTextLayer)({textContentSource:this.#Vs,container:this.div,viewport:e,textDivs:this.textDivs,textDivProperties:this.textDivProperties,textContentItemsStr:this.textContentItemsStr,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported}),await this.textLayerRenderTask.promise,this.#Us(),this.#Bs=t,this.#Ns=i,this.show(),this.accessibilityManager?.enable()}hide(){this.div.hidden||(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.renderingDone&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){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.#Vs=e}#js(){const{div:e}=this;e.addEventListener("mousedown",(t=>{const i=e.querySelector(".endOfContent");if(!i)return;let n=t.target!==e;if(n&&="none"!==getComputedStyle(i).getPropertyValue("-moz-user-select"),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");t&&(t.style.top="",t.classList.remove("active"))})),e.addEventListener("copy",(e=>{if(!this.#Os){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{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");return this.pageDiv.append(s),i.div=s,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};return this.div?n.XfaLayer.update(s):(this.div=document.createElement("div"),this.pageDiv.append(this.div),s.div=this.div,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.PDFScriptingManager=void 0;var n=i(22),s=i(23);class r extends s.PDFScriptingManager{constructor(e){e.externalServices||window.addEventListener("updatefromsandbox",(t=>{e.eventBus.dispatch("updatefromsandbox",{source:window,detail:t.detail})})),e.externalServices||={createScripting:({sandboxBundleSrc:e})=>new n.GenericScripting(e)},e.docProperties||=e=>(0,n.docProperties)(e),super(e)}}t.PDFScriptingManager=r},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.GenericScripting=void 0,t.docProperties=async function(e){const t="".split("#")[0];let{info:i,metadata:s,contentDispositionFilename:r,contentLength:a}=await e.getMetadata();if(!a){const{length:t}=await e.getDownloadInfo();a=t}return{...i,baseURL:t,filesize:a,filename:r||(0,n.getPdfFilenameFromUrl)(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:e.numPages,URL:""}};var n=i(4);t.GenericScripting=class{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.PDFScriptingManager=void 0;var n=i(2),s=i(4);t.PDFScriptingManager=class{#Hs=null;#Ws=null;#zs=null;#Gs=null;#$s=null;#qs=null;#Xs=null;#Ks=!1;#Ys=null;#Qs=null;#Js=null;constructor({eventBus:e,sandboxBundleSrc:t=null,externalServices:i=null,docProperties:n=null}){this.#Gs=e,this.#Ys=t,this.#$s=i,this.#zs=n}setViewer(e){this.#Xs=e}async setDocument(e){if(this.#qs&&await this.#Zs(),this.#qs=e,!e)return;const[t,i,n]=await Promise.all([e.getFieldObjects(),e.getCalculationOrderIds(),e.getJSActions()]);if(t||n){if(e===this.#qs){try{this.#Qs=this.#er()}catch(e){return console.error(`setDocument: "${e.message}".`),void await this.#Zs()}this._internalEvents.set("updatefromsandbox",(e=>{e?.source===window&&this.#tr(e.detail)})),this._internalEvents.set("dispatcheventinsandbox",(e=>{this.#Qs?.dispatchEventInSandbox(e.detail)})),this._internalEvents.set("pagechanging",(({pageNumber:e,previous:t})=>{e!==t&&(this.#ir(t),this.#nr(e))})),this._internalEvents.set("pagerendered",(({pageNumber:e})=>{this._pageOpenPending.has(e)&&e===this.#Xs.currentPageNumber&&this.#nr(e)})),this._internalEvents.set("pagesdestroy",(async()=>{await this.#ir(this.#Xs.currentPageNumber),await(this.#Qs?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#Hs?.resolve()}));for(const[e,t]of this._internalEvents)this.#Gs._on(e,t);try{const s=await this.#zs(e);if(e!==this.#qs)return;await this.#Qs.createSandbox({objects:t,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...s,actions:n}}),this.#Gs.dispatch("sandboxcreated",{source:this})}catch(e){return console.error(`setDocument: "${e.message}".`),void await this.#Zs()}await(this.#Qs?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#nr(this.#Xs.currentPageNumber,!0),Promise.resolve().then((()=>{e===this.#qs&&(this.#Ks=!0)}))}}else await this.#Zs()}async dispatchWillSave(){return this.#Qs?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Qs?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Qs){await(this.#Js?.promise),this.#Js=new s.PromiseCapability;try{await this.#Qs.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(e){throw this.#Js.resolve(),this.#Js=null,e}await this.#Js.promise}}async dispatchDidPrint(){return this.#Qs?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#Ws?.promise||null}get ready(){return this.#Ks}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#tr(e){const t=this.#Xs,i=t.isInPresentationMode||t.isChangingPresentationMode,{id:s,siblings:r,command:a,value:o}=e;if(!s){switch(a){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.#Gs.dispatch("print",{source:this});break;case"println":console.log(o);break;case"zoom":i||(t.currentScaleValue=o);break;case"SaveAs":this.#Gs.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.#Js?.resolve(),this.#Js=null}return}if(i&&e.focus)return;delete e.id,delete e.siblings;const l=r?[s,...r]:[s];for(const t of l){const i=document.querySelector(`[data-element-id="${t}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:e})):this.#qs?.annotationStorage.setValue(t,e)}}async#nr(e,t=!1){const i=this.#qs,r=this._visitedPages;if(t&&(this.#Hs=new s.PromiseCapability),!this.#Hs)return;const a=this.#Xs.getPageView(e-1);if(a?.renderingState!==n.RenderingStates.FINISHED)return void this._pageOpenPending.add(e);this._pageOpenPending.delete(e);const o=(async()=>{const t=await(r.has(e)?null:a.pdfPage?.getJSActions());i===this.#qs&&await(this.#Qs?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:e,actions:t}))})();r.set(e,o)}async#ir(e){const t=this.#qs,i=this._visitedPages;if(!this.#Hs)return;if(this._pageOpenPending.has(e))return;const n=i.get(e);n&&(i.set(e,null),await n,t===this.#qs&&await(this.#Qs?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:e})))}#er(){if(this.#Ws=new s.PromiseCapability,this.#Qs)throw new Error("#initScripting: Scripting already exists.");return this.#$s.createScripting({sandboxBundleSrc:this.#Ys})}async#Zs(){if(!this.#Qs)return this.#qs=null,void this.#Ws?.resolve();this.#Hs&&(await Promise.race([this.#Hs.promise,new Promise((e=>{setTimeout(e,1e3)}))]).catch((()=>{})),this.#Hs=null),this.#qs=null;try{await this.#Qs.destroySandbox()}catch{}this.#Js?.reject(new Error("Scripting destroyed.")),this.#Js=null;for(const[e,t]of this._internalEvents)this.#Gs._off(e,t);this._internalEvents.clear(),this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Qs=null,this.#Ks=!1,this.#Ws?.resolve()}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFSinglePageViewer=void 0;var n=i(2),s=i(25);class r extends s.PDFViewer{_resetView(){super._resetView(),this._scrollMode=n.ScrollMode.PAGE,this._spreadMode=n.SpreadMode.NONE}set scrollMode(e){}_updateScrollMode(){}set spreadMode(e){}_updateSpreadMode(){}}t.PDFSinglePageViewer=r},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PagesCountLimit=t.PDFViewer=t.PDFPageViewBuffer=void 0;var n=i(4),s=i(2),r=i(7),a=i(13),o=i(26),l=i(5);const h={FORCE_SCROLL_MODE_PAGE:15e3,FORCE_LAZY_PAGE_INIT:7500,PAUSE_EAGER_PAGE_INIT:250};function c(e){return Object.values(n.AnnotationEditorType).includes(e)&&e!==n.AnnotationEditorType.DISABLE}t.PagesCountLimit=h;class d{#sr=new Set;#rr=0;constructor(e){this.#rr=e}push(e){const t=this.#sr;t.has(e)&&t.delete(e),t.add(e),t.size>this.#rr&&this.#ar()}resize(e,t=null){this.#rr=e;const i=this.#sr;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)),++n>e)break}for(;i.size>this.#rr;)this.#ar()}has(e){return this.#sr.has(e)}[Symbol.iterator](){return this.#sr.keys()}#ar(){const e=this.#sr.keys().next().value;e?.destroy(),this.#sr.delete(e)}}t.PDFPageViewBuffer=d,t.PDFViewer=class{#or=null;#ne=null;#lr=n.AnnotationEditorType.NONE;#hr=null;#cs=n.AnnotationMode.ENABLE_FORMS;#cr=null;#dr=null;#Os=!1;#ur=!1;#pr=null;#gr=!1;#fr=0;#mr=new ResizeObserver(this.#_r.bind(this));#vr=null;#br=null;#yr=null;#_s=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}".`);if(this.container=e.container,this.viewer=e.viewer||e.container.firstElementChild,"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.#mr.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.#_s=e.textLayerMode??s.TextLayerMode.ENABLE,this.#cs=e.annotationMode??n.AnnotationMode.ENABLE_FORMS,this.#lr=e.annotationEditorMode??n.AnnotationEditorType.NONE,this.imageResourcesPath=e.imageResourcesPath||"",this.enablePrintAutoRotate=e.enablePrintAutoRotate||!1,this.removePageBorders=e.removePageBorders||!1,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||r.NullL10n,this.#Os=e.enablePermissions||!1,this.pageColors=e.pageColors||null,this.defaultRenderingQueue=!e.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new o.PDFRenderingQueue,this.renderingQueue.setViewer(this)):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.#Sr(),this.eventBus._on("thumbnailrendered",(({pageNumber:e,pdfPage:t})=>{const i=this._pages[e-1];this.#or.has(i)||t?.cleanup()}))}get pagesCount(){return this._pages.length}getPageView(e){return this._pages[e]}getCachedPageViews(){return new Set(this.#or)}get pageViewsReady(){return this._pagesCapability.settled&&this._pages.every((e=>e?.pdfPage))}get renderForms(){return this.#cs===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)return t&&this.#Pr(),!0;if(!(0<e&&e<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=e,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:e,pageLabel:this._pageLabels?.[e-1]??null,previous:i}),t&&this.#Pr(),!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.#Ar(e,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(e){this.pdfDocument&&this.#Ar(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;if((e%=360)<0&&(e+=360),this._pagesRotation===e)return;this._pagesRotation=e;const t=this._currentPageNumber;this.refresh(!0,{rotation:e}),this._currentScaleValue&&this.#Ar(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}#us(){const e=this;return{get annotationEditorUIManager(){return e.#hr},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}}}#wr(e){const t={annotationEditorMode:this.#lr,annotationMode:this.#cs,textLayerMode:this.#_s};return e?(e.includes(n.PermissionFlag.COPY)||this.#_s!==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.#cs!==n.AnnotationMode.ENABLE_FORMS||(t.annotationMode=n.AnnotationMode.ENABLE),t):t}#Er(){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return Promise.resolve();const e=new Promise((e=>{this.#br=()=>{"hidden"===document.visibilityState&&(e(),document.removeEventListener("visibilitychange",this.#br),this.#br=null)},document.addEventListener("visibilitychange",this.#br)}));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.#gr)return null;t.length=0;const n=await this.pdfDocument.getPage(i),{items:r}=await n.getTextContent();for(const e of r)e.str&&t.push(e.str),e.hasEOL&&t.push("\n");e.push((0,s.removeNullCharacters)(t.join("")))}return e.join("\n")}#xr(e,t){const i=document.getSelection(),{focusNode:n,anchorNode:r}=i;if(r&&n&&i.containsNode(this.#pr)){if(this.#ur||e===s.TextLayerMode.ENABLE_PERMISSIONS)return t.preventDefault(),void t.stopPropagation();this.#ur=!0;const i=this.container.style.cursor;this.container.style.cursor="wait";const n=e=>this.#gr="Escape"===e.key;window.addEventListener("keydown",n),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.#ur=!1,this.#gr=!1,window.removeEventListener("keydown",n),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),this.#hr&&(this.#hr.destroy(),this.#hr=null)),this.pdfDocument=e,!e)return;const t=e.numPages,i=e.getPage(1),r=e.getOptionalContentConfig(),o=this.#Os?e.getPermissions():Promise.resolve();if(t>h.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.#or.push(t)},this.eventBus._on("pagerender",this._onBeforeDraw),this._onAfterDraw=e=>{e.cssTransform||this._onePageRenderedCapability.settled||(this._onePageRenderedCapability.resolve({timestamp:e.timestamp}),this.eventBus._off("pagerendered",this._onAfterDraw),this._onAfterDraw=null,this.#br&&(document.removeEventListener("visibilitychange",this.#br),this.#br=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=r;const{annotationEditorMode:l,annotationMode:d,textLayerMode:u}=this.#wr(o);if(u!==s.TextLayerMode.DISABLE){const e=this.#pr=document.createElement("div");e.id="hiddenCopyElement",this.viewer.before(e)}if(l!==n.AnnotationEditorType.DISABLE){const t=l;e.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):c(t)?(this.#hr=new n.AnnotationEditorUIManager(this.container,this.viewer,this.#ne,this.eventBus,e,this.pageColors),t!==n.AnnotationEditorType.NONE&&this.#hr.updateMode(t)):console.error(`Invalid AnnotationEditor mode: ${t}`)}const p=this.#us.bind(this),g=this._scrollMode===s.ScrollMode.PAGE?null:this.viewer,f=this.currentScale,m=i.getViewport({scale:f*n.PixelsPerInch.PDF_TO_CSS_UNITS});this.viewer.style.setProperty("--scale-factor",m.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 a.PDFPageView({container:g,eventBus:this.eventBus,id:e,scale:f,defaultViewport:m.clone(),optionalContentConfigPromise:r,renderingQueue:this.renderingQueue,textLayerMode:u,annotationMode:d,imageResourcesPath:this.imageResourcesPath,isOffscreenCanvasSupported:this.isOffscreenCanvasSupported,maxCanvasPixels:this.maxCanvasPixels,pageColors:this.pageColors,l10n:this.l10n,layerProperties:p});this._pages.push(t)}const _=this._pages[0];_&&(_.setPdfPage(i),this.linkService.cachePageRef(1,i.ref)),this._scrollMode===s.ScrollMode.PAGE?this.#Cr():this._spreadMode!==s.SpreadMode.NONE&&this._updateSpreadMode(),this.#Er().then((async()=>{if(this.findController?.setDocument(e),this._scriptingManager?.setDocument(e),this.#pr&&(this.#dr=this.#xr.bind(this,u),document.addEventListener("copy",this.#dr)),this.#hr&&this.eventBus.dispatch("annotationeditormodechanged",{source:this,mode:this.#lr}),e.loadingParams.disableAutoFetch||t>h.FORCE_LAZY_PAGE_INIT)return void this._pagesCapability.resolve();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%h.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){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):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.#or=new d(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.#vr={previousPageNumber:1,scrollDown:!0,pages:[]},this._onBeforeDraw&&(this.eventBus._off("pagerender",this._onBeforeDraw),this._onBeforeDraw=null),this._onAfterDraw&&(this.eventBus._off("pagerendered",this._onAfterDraw),this._onAfterDraw=null),this.#br&&(document.removeEventListener("visibilitychange",this.#br),this.#br=null),this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#pr&&(document.removeEventListener("copy",this.#dr),this.#dr=null,this.#pr.remove(),this.#pr=null)}#Cr(){if(this._scrollMode!==s.ScrollMode.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const e=this._currentPageNumber,t=this.#vr,i=this.viewer;if(i.textContent="",t.pages.length=0,this._spreadMode!==s.SpreadMode.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;-1===s?n.add(e-1):e%2!==s?(n.add(e-1),n.add(e)):(n.add(e-2),n.add(e-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const e=document.createElement("div");e.className="dummyPage",r.append(e)}for(const e of n){const i=this._pages[e];i&&(r.append(i.div),t.pages.push(i))}i.append(r)}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()}#Mr(e,t=null){const{div:i,id:n}=e;if(this._currentPageNumber!==n&&this._setCurrentPageNumber(n),this._scrollMode===s.ScrollMode.PAGE&&(this.#Cr(),this.update()),!t&&!this.isInPresentationMode){const e=i.offsetLeft+i.clientLeft,n=e+i.clientWidth,{scrollLeft:r,clientWidth:a}=this.container;(this._scrollMode===s.ScrollMode.HORIZONTAL||e<r||n>r+a)&&(t={left:0,top:0})}(0,s.scrollIntoView)(i,t),!this._currentScaleValue&&this._location&&(this._location=null)}#Tr(e){return e===this._currentScale||Math.abs(e-this._currentScale)<1e-15}#Dr(e,t,{noScroll:i=!1,preset:s=!1,drawingDelay:r=-1}){if(this._currentScaleValue=t.toString(),this.#Tr(e))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:e,presetValue:t}));this.viewer.style.setProperty("--scale-factor",e*n.PixelsPerInch.PDF_TO_CSS_UNITS);const a=r>=0&&r<1e3;if(this.refresh(!0,{scale:e,drawingDelay:a?r:-1}),a&&(this.#yr=setTimeout((()=>{this.#yr=null,this.refresh()}),r)),this._currentScale=e,!i){let e,t=this._currentPageNumber;!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#Fr(){return this._spreadMode!==s.SpreadMode.NONE&&this._scrollMode!==s.ScrollMode.HORIZONTAL?2:1}#Ar(e,t){let i=parseFloat(e);if(i>0)t.preset=!1,this.#Dr(i,e,t);else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let r=s.SCROLLBAR_PADDING,a=s.VERTICAL_PADDING;this.isInPresentationMode?(r=a=4,this._spreadMode!==s.SpreadMode.NONE&&(r*=2)):this.removePageBorders?r=a=0:this._scrollMode===s.ScrollMode.HORIZONTAL&&([r,a]=[a,r]);const o=(this.container.clientWidth-r)/n.width*n.scale/this.#Fr,l=(this.container.clientHeight-a)/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:return void console.error(`#setScale: "${e}" is an unknown zoom value.`)}t.preset=!0,this.#Dr(i,e,t)}}#Pr(){const e=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#Ar(this._currentScaleValue,{noScroll:!0}),this.#Mr(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:r=!1}){if(!this.pdfDocument)return;const a=Number.isInteger(e)&&this._pages[e-1];if(!a)return void console.error(`scrollPageIntoView: "${e}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!t)return void this._setCurrentPageNumber(e,!0);let o,l,h=0,c=0,d=0,u=0;const p=a.rotation%180!=0,g=(p?a.height:a.width)/a.scale/n.PixelsPerInch.PDF_TO_CSS_UNITS,f=(p?a.width:a.height)/a.scale/n.PixelsPerInch.PDF_TO_CSS_UNITS;let m=0;switch(t[1].name){case"XYZ":h=t[2],c=t[3],m=t[4],h=null!==h?h:0,c=null!==c?c:f;break;case"Fit":case"FitB":m="page-fit";break;case"FitH":case"FitBH":c=t[2],m="page-width",null===c&&this._location?(h=this._location.left,c=this._location.top):("number"!=typeof c||c<0)&&(c=f);break;case"FitV":case"FitBV":h=t[2],d=g,u=f,m="page-height";break;case"FitR":h=t[2],c=t[3],d=t[4]-h,u=t[5]-c;let e=s.SCROLLBAR_PADDING,i=s.VERTICAL_PADDING;this.removePageBorders&&(e=i=0),o=(this.container.clientWidth-e)/d/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:return void console.error(`scrollPageIntoView: "${t[1].name}" is not a valid destination type.`)}if(r||(m&&m!==this._currentScale?this.currentScaleValue=m:this._currentScale===s.UNKNOWN_SCALE&&(this.currentScaleValue=s.DEFAULT_SCALE_VALUE)),"page-fit"===m&&!t[4])return void this.#Mr(a);const _=[a.viewport.convertToViewportPoint(h,c),a.viewport.convertToViewportPoint(h+d,c+u)];let v=Math.min(_[0][0],_[1][0]),b=Math.min(_[0][1],_[1][1]);i||(v=Math.max(v,0),b=Math.max(b,0)),this.#Mr(a,{left:v,top:b})}_updateLocation(e){const t=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===t?Math.round(1e4*t)/100:i,s=e.id,r=this._pages[s-1],a=this.container,o=r.getPagePoint(a.scrollLeft-e.x,a.scrollTop-e.y),l=Math.round(o[0]),h=Math.round(o[1]);let c=`#page=${s}`;this.isInPresentationMode||(c+=`&zoom=${n},${l},${h}`),this._location={pageNumber:s,scale:n,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:c}}update(){const e=this._getVisiblePages(),t=e.views,i=t.length;if(0===i)return;const n=Math.max(10,2*i+1);this.#or.resize(n,e.ids),this.renderingQueue.renderHighestPriority(e);const r=this._spreadMode===s.SpreadMode.NONE&&(this._scrollMode===s.ScrollMode.PAGE||this._scrollMode===s.ScrollMode.VERTICAL),a=this._currentPageNumber;let o=!1;for(const e of t){if(e.percent<100)break;if(e.id===a&&r){o=!0;break}}this._setCurrentPageNumber(o?a: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.#vr.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#kr(e){if(e.pdfPage)return e.pdfPage;try{const t=await this.pdfDocument.getPage(e.id);return e.pdfPage||e.setPdfPage(t),this.linkService._cachedPageNumber?.(t.ref)||this.linkService.cachePageRef(e.id,t.ref),t}catch(e){return console.error("Unable to get page for page view",e),null}}#Lr(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.#vr.scrollDown;case s.ScrollMode.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(e){const t=e||this._getVisiblePages(),i=this.#Lr(t),n=this._spreadMode!==s.SpreadMode.NONE&&this._scrollMode!==s.ScrollMode.HORIZONTAL,r=this.renderingQueue.getHighestPriority(t,this._pages,i,n);return!!r&&(this.#kr(r).then((()=>{this.renderingQueue.renderView(r)})),!0)}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(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig()):Promise.resolve(null)}set optionalContentConfigPromise(e){if(!(e instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${e}`);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}`);this.pagesCount>h.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),this.pdfDocument&&e&&(t===s.ScrollMode.PAGE?this.#Cr():this._previousScrollMode===s.ScrollMode.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Ar(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.#Cr();else if(t.textContent="",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,r=i.length;s<r;++s)null===n?(n=document.createElement("div"),n.className="spread",t.append(n)):s%2===e&&(n=n.cloneNode(!1),t.append(n)),n.append(i[s].div)}e&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Ar(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:r}of i){if(0===s||r<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,r=s;t<r;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(),r=t?e-1:e+1;for(const{id:e,percent:t,widthPercent:i}of n)if(e===r){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;return this.currentPageNumber=Math.min(e+i,t),!0}previousPage(){const e=this._currentPageNumber;if(e<=1)return!1;const t=this._getPageAdvance(e,!0)||1;return this.currentPageNumber=Math.max(e-t,1),!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.#Ar(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.#Ar(Math.max(s.MIN_SCALE,n),{noScroll:!1,drawingDelay:e})}#Sr(e=this.container.clientHeight){e!==this.#fr&&(this.#fr=e,s.docStyle.setProperty("--viewer-container-height",`${e}px`))}#_r(e){for(const t of e)if(t.target===this.container){this.#Sr(Math.floor(t.borderBoxSize[0].blockSize)),this.#cr=null;break}}get containerTopLeft(){return this.#cr||=[this.container.offsetTop,this.container.offsetLeft]}get annotationEditorMode(){return this.#hr?this.#lr:n.AnnotationEditorType.DISABLE}set annotationEditorMode({mode:e,editId:t=null}){if(!this.#hr)throw new Error("The AnnotationEditor is not enabled.");if(this.#lr!==e){if(!c(e))throw new Error(`Invalid AnnotationEditor mode: ${e}`);this.pdfDocument&&(this.#lr=e,this.eventBus.dispatch("annotationeditormodechanged",{source:this,mode:e}),this.#hr.updateMode(e,t))}}set annotationEditorParams({type:e,value:t}){if(!this.#hr)throw new Error("The AnnotationEditor is not enabled.");this.#hr.updateParams(e,t)}refresh(e=!1,t=Object.create(null)){if(this.pdfDocument){for(const e of this._pages)e.update(t);null!==this.#yr&&(clearTimeout(this.#yr),this.#yr=null),e||this.update()}}}},(e,t,i)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.PDFRenderingQueue=void 0;var n=i(4),s=i(2);t.PDFRenderingQueue=class{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){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,r=s.length;if(0===r)return null;for(let e=0;e<r;e++){const t=s[e].view;if(!this.isViewFinished(t))return t}const a=e.first.id,o=e.last.id;if(o-a+1>r){const n=e.ids;for(let e=1,s=o-a;e<s;e++){const s=i?a+e:o-e;if(n.has(s))continue;const r=t[s-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=t[l];return h&&!this.isViewFinished(h)||n&&(l+=i?1:-1,h=t[l],h&&!this.isViewFinished(h))?h: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}}}],t={};function i(n){var s=t[n];if(void 0!==s)return s.exports;var r=t[n]={exports:{}};return e[n](r,r.exports,i),r.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"AnnotationLayerBuilder",{enumerable:!0,get:function(){return a.AnnotationLayerBuilder}}),Object.defineProperty(e,"DownloadManager",{enumerable:!0,get:function(){return o.DownloadManager}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return l.EventBus}}),Object.defineProperty(e,"FindState",{enumerable:!0,get:function(){return t.FindState}}),Object.defineProperty(e,"GenericL10n",{enumerable:!0,get:function(){return h.GenericL10n}}),Object.defineProperty(e,"LinkTarget",{enumerable:!0,get:function(){return s.LinkTarget}}),Object.defineProperty(e,"NullL10n",{enumerable:!0,get:function(){return c.NullL10n}}),Object.defineProperty(e,"PDFFindController",{enumerable:!0,get:function(){return t.PDFFindController}}),Object.defineProperty(e,"PDFHistory",{enumerable:!0,get:function(){return d.PDFHistory}}),Object.defineProperty(e,"PDFLinkService",{enumerable:!0,get:function(){return s.PDFLinkService}}),Object.defineProperty(e,"PDFPageView",{enumerable:!0,get:function(){return u.PDFPageView}}),Object.defineProperty(e,"PDFScriptingManager",{enumerable:!0,get:function(){return p.PDFScriptingManager}}),Object.defineProperty(e,"PDFSinglePageViewer",{enumerable:!0,get:function(){return g.PDFSinglePageViewer}}),Object.defineProperty(e,"PDFViewer",{enumerable:!0,get:function(){return f.PDFViewer}}),Object.defineProperty(e,"ProgressBar",{enumerable:!0,get:function(){return r.ProgressBar}}),Object.defineProperty(e,"RenderingStates",{enumerable:!0,get:function(){return r.RenderingStates}}),Object.defineProperty(e,"ScrollMode",{enumerable:!0,get:function(){return r.ScrollMode}}),Object.defineProperty(e,"SimpleLinkService",{enumerable:!0,get:function(){return s.SimpleLinkService}}),Object.defineProperty(e,"SpreadMode",{enumerable:!0,get:function(){return r.SpreadMode}}),Object.defineProperty(e,"StructTreeLayerBuilder",{enumerable:!0,get:function(){return m.StructTreeLayerBuilder}}),Object.defineProperty(e,"TextLayerBuilder",{enumerable:!0,get:function(){return _.TextLayerBuilder}}),Object.defineProperty(e,"XfaLayerBuilder",{enumerable:!0,get:function(){return v.XfaLayerBuilder}}),Object.defineProperty(e,"parseQueryString",{enumerable:!0,get:function(){return r.parseQueryString}});var t=i(1),s=i(5),r=i(2),a=i(6),o=i(8),l=i(9),h=i(10),c=i(7),d=i(12),u=i(13),p=i(21),g=i(24),f=i(25),m=i(16),_=i(19),v=i(20)})(),n})(),e.exports=i.pdfjsViewer=n()}(pdf_viewer);var pdf_viewerExports=pdf_viewer.exports,_ProgressBar_classList,_ProgressBar_disableAutoFetchTimeout,_ProgressBar_percent,_ProgressBar_style,_ProgressBar_visible;function __awaiter(e,t,i,n){return new(i||(i=Promise))((function(t,s){function r(e){try{o(n.next(e))}catch(e){s(e)}}function a(e){try{o(n.throw(e))}catch(e){s(e)}}function o(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i((function(e){e(n)}))).then(r,a)}o((n=n.apply(e,[])).next())}))}function __classPrivateFieldGet(e,t,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(e):n?n.value:t.get(e)}function __classPrivateFieldSet(e,t,i,n,s){if("function"==typeof t?e!==t||!s:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s?s.value=i:t.set(e,i),i}"function"==typeof SuppressedError&&SuppressedError;const DEFAULT_SCALE_VALUE="auto",DEFAULT_SCALE=1,DEFAULT_SCALE_DELTA=1.1,MIN_SCALE=.1,MAX_SCALE=10,UNKNOWN_SCALE=0,MAX_AUTO_SCALE=1.25,SCROLLBAR_PADDING=40,VERTICAL_PADDING=5,RenderingStates={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},PresentationModeState={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},SidebarView={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},RendererType={CANVAS:"canvas",SVG:"svg"},TextLayerMode={DISABLE:0,ENABLE:1},ScrollMode={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},SpreadMode={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2},CursorTool={SELECT:0,HAND:1,ZOOM:2},AutoPrintRegExp=/\bprint\s*\(/;class OutputScale{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}}function scrollIntoView(e,t,i=!1){let n=e.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=e.offsetTop+e.clientTop,r=e.offsetLeft+e.clientLeft;for(;n.clientHeight===n.scrollHeight&&n.clientWidth===n.scrollWidth||i&&(n.classList.contains("markedContent")||"hidden"===getComputedStyle(n).overflow);)if(s+=n.offsetTop,r+=n.offsetLeft,n=n.offsetParent,!n)return;t&&(void 0!==t.top&&(s+=t.top),void 0!==t.left&&(r+=t.left,n.scrollLeft=r)),n.scrollTop=s,n.scrollLeft=r}function watchScroll(e,t){const i=function(i){s||(s=window.requestAnimationFrame((function(){s=null;const i=e.scrollLeft,r=n.lastX;i!==r&&(n.right=i>r),n.lastX=i;const a=e.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,t(n)})))},n={right:!0,down:!0,lastX:e.scrollLeft,lastY:e.scrollTop,_eventHandler:i};let s=null;return e.addEventListener("scroll",i,!0),n}function parseQueryString(e){const t=new Map;for(const[i,n]of new URLSearchParams(e))t.set(i.toLowerCase(),n);return t}const NullCharactersRegExp=/\x00/g,InvisibleCharactersRegExp=/[\x01-\x1F]/g;function removeNullCharacters(e,t=!1){return"string"!=typeof e?(console.error("The argument must be a string."),e):(t&&(e=e.replace(InvisibleCharactersRegExp," ")),e.replace(NullCharactersRegExp,""))}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 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,r=1,a=1,o=1;for(;;){const e=s+a,t=r+o;if(t>8)break;i<=e/t?(a=e,o=t):(s=e,r=t)}return n=i-s/r<a/o-i?i===e?[s,r]:[r,s]:i===e?[a,o]:[o,a],n}function roundToDivide(e,t){const i=e%t;return 0===i?e:Math.round(e-i+t)}function getPageSizeInches({view:e,userUnit:t,rotate:i}){const[n,s,r,a]=e,o=i%180!=0,l=(r-n)/72*t,h=(a-s)/72*t;return{width:o?h:l,height:o?l:h}}function backtrackBeforeAllVisibleElements(e,t,i){if(e<2)return e;let n=t[e].div,s=n.offsetTop+n.clientTop;s>=i&&(n=t[e-1].div,s=n.offsetTop+n.clientTop);for(let i=e-2;i>=0&&(n=t[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)e=i;return e}function getVisibleElements({scrollEl:e,views:t,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!1}){const r=e.scrollTop,a=r+e.clientHeight,o=e.scrollLeft,l=o+e.clientWidth;const h=[],c=new Set,d=t.length;let u=binarySearchFirstItem(t,n?function(e){const t=e.div,i=t.offsetLeft+t.clientLeft,n=i+t.clientWidth;return s?i<l:n>o}:function(e){const t=e.div;return t.offsetTop+t.clientTop+t.clientHeight>r});u>0&&u<d&&!n&&(u=backtrackBeforeAllVisibleElements(u,t,r));let p=n?l:-1;for(let e=u;e<d;e++){const i=t[e],s=i.div,d=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,f=s.clientHeight,m=d+g,_=u+f;if(-1===p)_>=a&&(p=_);else if((n?d:u)>p)break;if(_<=r||u>=a||m<=o||d>=l)continue;const v=Math.max(0,r-u)+Math.max(0,_-a),b=(g-(Math.max(0,o-d)+Math.max(0,m-l)))/g,y=(f-v)/f*b*100|0;h.push({id:i.id,x:d,y:u,view:i,percent:y,widthPercent:100*b|0}),c.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(e,t){const i=e.percent-t.percent;return Math.abs(i)>.001?-i:e.id-t.id})),{first:g,last:f,views:h,ids:c}}function noContextMenuHandler(e){e.preventDefault()}function normalizeWheelEventDirection(e){let t=Math.hypot(e.deltaX,e.deltaY);const i=Math.atan2(e.deltaY,e.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(t=-t),t}function normalizeWheelEventDelta(e){const t=e.deltaMode;let i=normalizeWheelEventDirection(e);return t===WheelEvent.DOM_DELTA_PIXEL?i/=900:t===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function isValidRotation(e){return Number.isInteger(e)&&e%90==0}function isValidScrollMode(e){return Number.isInteger(e)&&Object.values(ScrollMode).includes(e)&&e!==ScrollMode.UNKNOWN}function isValidSpreadMode(e){return Number.isInteger(e)&&Object.values(SpreadMode).includes(e)&&e!==SpreadMode.UNKNOWN}function isPortraitOrientation(e){return e.width<=e.height}const animationStarted=new Promise((function(e){window.requestAnimationFrame(e)})),docStyle=document.documentElement.style;function clamp(e,t,i){return Math.min(Math.max(e,t),i)}class ProgressBar{constructor(e){_ProgressBar_classList.set(this,null),_ProgressBar_disableAutoFetchTimeout.set(this,null),_ProgressBar_percent.set(this,0),_ProgressBar_style.set(this,null),_ProgressBar_visible.set(this,!0),__classPrivateFieldSet(this,_ProgressBar_classList,e.classList),__classPrivateFieldSet(this,_ProgressBar_style,e.style)}get percent(){return __classPrivateFieldGet(this,_ProgressBar_percent,"f")}set percent(e){var t,i,n;__classPrivateFieldSet(this,_ProgressBar_percent,clamp(e,0,100)),isNaN(e)?null===(t=__classPrivateFieldGet(this,_ProgressBar_classList,"f"))||void 0===t||t.add("indeterminate"):(null===(i=__classPrivateFieldGet(this,_ProgressBar_classList,"f"))||void 0===i||i.remove("indeterminate"),null===(n=__classPrivateFieldGet(this,_ProgressBar_style,"f"))||void 0===n||n.setProperty("--progressBar-percent",`${__classPrivateFieldGet(this,_ProgressBar_percent,"f")}%`))}setWidth(e){var t;if(!e)return;const i=e.parentNode.offsetWidth-e.offsetWidth;i>0&&(null===(t=__classPrivateFieldGet(this,_ProgressBar_style,"f"))||void 0===t||t.setProperty("--progressBar-end-offset",`${i}px`))}setDisableAutoFetch(e=5e3){isNaN(__classPrivateFieldGet(this,_ProgressBar_percent,"f"))||(__classPrivateFieldGet(this,_ProgressBar_disableAutoFetchTimeout,"f")&&clearTimeout(__classPrivateFieldGet(this,_ProgressBar_disableAutoFetchTimeout,"f")),this.show(),__classPrivateFieldSet(this,_ProgressBar_disableAutoFetchTimeout,setTimeout((()=>{__classPrivateFieldSet(this,_ProgressBar_disableAutoFetchTimeout,null,"f"),this.hide()}),e)))}hide(){var e;__classPrivateFieldGet(this,_ProgressBar_visible,"f")&&(__classPrivateFieldSet(this,_ProgressBar_visible,!1),null===(e=__classPrivateFieldGet(this,_ProgressBar_classList,"f"))||void 0===e||e.add("hidden"))}show(){var e;__classPrivateFieldGet(this,_ProgressBar_visible,"f")||(__classPrivateFieldSet(this,_ProgressBar_visible,!0),null===(e=__classPrivateFieldGet(this,_ProgressBar_classList,"f"))||void 0===e||e.remove("hidden"))}}function getActiveOrFocusedElement(){let e=document,t=e.activeElement||e.querySelector(":focus");for(;null==t?void 0:t.shadowRoot;)e=t.shadowRoot,t=e.activeElement||e.querySelector(":focus");return t}function apiPageLayoutToViewerModes(e){let t=ScrollMode.VERTICAL,i=SpreadMode.NONE;switch(e){case"SinglePage":t=ScrollMode.PAGE;break;case"OneColumn":break;case"TwoPageLeft":t=ScrollMode.PAGE;case"TwoColumnLeft":i=SpreadMode.ODD;break;case"TwoPageRight":t=ScrollMode.PAGE;case"TwoColumnRight":i=SpreadMode.EVEN}return{scrollMode:t,spreadMode:i}}function apiPageModeToSidebarView(e){switch(e){case"UseNone":return SidebarView.NONE;case"UseThumbs":return SidebarView.THUMBS;case"UseOutlines":return SidebarView.OUTLINE;case"UseAttachments":return SidebarView.ATTACHMENTS;case"UseOC":return SidebarView.LAYERS}return SidebarView.NONE}_ProgressBar_classList=new WeakMap,_ProgressBar_disableAutoFetchTimeout=new WeakMap,_ProgressBar_percent=new WeakMap,_ProgressBar_style=new WeakMap,_ProgressBar_visible=new WeakMap;const CLEANUP_TIMEOUT=3e4;class PDFRenderingQueue{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1}setViewer(e){this.pdfViewer=e}setThumbnailViewer(e){this.pdfThumbnailViewer=e}isHighestPriority(e){return this.highestPriorityPage===e.renderingId}hasViewer(){return!!this.pdfViewer}renderHighestPriority(e){var t,i;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),(null===(t=this.pdfViewer)||void 0===t?void 0:t.forceRendering(e))||this.isThumbnailViewEnabled&&(null===(i=this.pdfThumbnailViewer)||void 0===i?void 0:i.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),CLEANUP_TIMEOUT))}getHighestPriority(e,t,i,n=!1){const s=e.views,r=s.length;if(0===r)return null;for(let e=0;e<r;e++){const t=s[e].view;if(!this.isViewFinished(t))return t}const a=e.first.id,o=e.last.id;if(o-a+1>r){const n=e.ids;for(let e=1,s=o-a;e<s;e++){const s=i?a+e:o-e;if(n.has(s))continue;const r=t[s-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=t[l];return h&&!this.isViewFinished(h)||n&&(l+=i?1:-1,h=t[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(e){return e.renderingState===RenderingStates.FINISHED}renderView(e){switch(e.renderingState){case RenderingStates.FINISHED:return!1;case RenderingStates.PAUSED:this.highestPriorityPage=e.renderingId,e.resume();break;case RenderingStates.RUNNING:this.highestPriorityPage=e.renderingId;break;case RenderingStates.INITIAL:this.highestPriorityPage=e.renderingId,e.draw().finally((()=>{this.renderHighestPriority()})).catch((e=>{e instanceof pdfExports.RenderingCancelledException||console.error(`renderView: "${e}"`)}))}return!0}}var _a,_TempImageFactory_tempCanvas;const DRAW_UPSCALE_FACTOR=2,MAX_NUM_SCALING_STEPS=3;class TempImageFactory{static getCanvas(e,t){const i=__classPrivateFieldSet(this,_a,__classPrivateFieldGet(this,_a,"f",_TempImageFactory_tempCanvas)||document.createElement("canvas"),"f",_TempImageFactory_tempCanvas);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();const s=i.getContext("2d");return[i,s]}static destroyCanvas(){const e=__classPrivateFieldGet(this,_a,"f",_TempImageFactory_tempCanvas);e&&(e.width=0,e.height=0),__classPrivateFieldSet(this,_a,null,"f",_TempImageFactory_tempCanvas)}}_a=TempImageFactory,_TempImageFactory_tempCanvas={value:null};class PDFThumbnailView{constructor({container:e,eventBus:t,id:i,defaultViewport:n,optionalContentConfigPromise:s,linkService:r,renderingQueue:a,l10n:o,pageColors:l,store:h,thumbnailWidth:c}){this.container=e,this.eventBus=t,this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.store=h,this.loaded=!1,this.pdfPage=null,this.rotation=0,this.viewport=n,this.pdfPageRotate=n.rotation,this._optionalContentConfigPromise=s||null,this.pageColors=l||null,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=RenderingStates.INITIAL,this.resume=null;const d=this.viewport.width,u=d/this.viewport.height;this.canvasWidth=c,this.canvasHeight=this.canvasWidth/u|0,this.scale=this.canvasWidth/d,this.l10n=o,this.canvas=null,this.src=null;const p=document.createElement("div");p.className="thumbnail pdfSlickThumbHolder",p.setAttribute("data-page-number",this.id.toString()),this.div=p,e.append(p)}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=RenderingStates.INITIAL;const e=this.viewport.width,t=e/this.viewport.height;this.canvasHeight=this.canvasWidth/t|0,this.scale=this.canvasWidth/e,this.div.removeAttribute("data-loaded"),this.loaded=!1,this.canvas&&(this.canvas.width=0,this.canvas.height=0,delete this.canvas)}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(){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}),n=new OutputScale;t.width=e*this.canvasWidth*n.sx|0,t.height=e*this.canvasHeight*n.sy|0;return{ctx:i,canvas:t,transform:n.scaled?[n.sx,0,0,n.sy,0,0]:null}}_convertCanvasToImage(e){if(this.renderingState!==RenderingStates.FINISHED)throw new Error("_convertCanvasToImage: Rendering has not finished.");const t=this._reduceImage(e);this.src=t.toDataURL(),this.div.setAttribute("data-loaded","true"),this.loaded=!0,this.store.getState()._setThumbnailView(this.id,this),t.width=0,t.height=0}draw(){if(this.renderingState!==RenderingStates.INITIAL)return console.error("Must be in new state before drawing"),Promise.resolve();const{pdfPage:e}=this;if(!e)return this.renderingState=RenderingStates.FINISHED,Promise.reject(new Error("pdfPage is not loaded"));this.renderingState=RenderingStates.RUNNING;const t=(e=null)=>__awaiter(this,void 0,void 0,(function*(){if(a===this.renderTask&&(this.renderTask=null),!(e instanceof pdfExports.RenderingCancelledException)&&(this.renderingState=RenderingStates.FINISHED,this._convertCanvasToImage(n),e))throw e})),{ctx:i,canvas:n,transform:s}=this._getPageDrawContext(DRAW_UPSCALE_FACTOR),r={canvasContext:i,transform:s,viewport:this.viewport.clone({scale:DRAW_UPSCALE_FACTOR*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},a=this.renderTask=e.render(r);a.onContinue=e=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=RenderingStates.PAUSED,void(this.resume=()=>{this.renderingState=RenderingStates.RUNNING,e()});e()};const o=a.promise.then((function(){return t(null)}),(function(e){return t(e)}));return o.finally((()=>{n.width=0,n.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),o}setImage(e){if(this.renderingState!==RenderingStates.INITIAL)return;const{thumbnailCanvas:t,pdfPage:i,scale:n}=e;t&&(this.pdfPage||this.setPdfPage(i),n<this.scale||(this.renderingState=RenderingStates.FINISHED,this._convertCanvasToImage(t)))}_reduceImage(e){const{ctx:t,canvas:i}=this._getPageDrawContext();if(e.width<=2*i.width)return t.drawImage(e,0,0,e.width,e.height,0,0,i.width,i.height),i;let n=i.width<<MAX_NUM_SCALING_STEPS,s=i.height<<MAX_NUM_SCALING_STEPS;const[r,a]=TempImageFactory.getCanvas(n,s);for(;n>e.width||s>e.height;)n>>=1,s>>=1;for(a.drawImage(e,0,0,e.width,e.height,0,0,n,s);n>2*i.width;)a.drawImage(r,0,0,n,s,0,0,n>>1,s>>1),n>>=1,s>>=1;return t.drawImage(r,0,0,n,s,0,0,i.width,i.height),i}get _thumbPageTitle(){var e;return this.l10n.get("thumb_page_title",{page:null!==(e=this.pageLabel)&&void 0!==e?e:this.id})}get _thumbPageCanvas(){var e;return this.l10n.get("thumb_page_canvas",{page:null!==(e=this.pageLabel)&&void 0!==e?e:this.id})}setPageLabel(e){this.pageLabel="string"==typeof e?e:null}}var _PDFThumbnailViewer_instances,_PDFThumbnailViewer_ensurePdfPageLoaded,_PDFThumbnailViewer_getScrollAhead;const THUMBNAIL_SCROLL_MARGIN=-19,THUMBNAIL_SELECTED_CLASS="selected";class PDFThumbnailViewer{constructor({container:e,eventBus:t,linkService:i,renderingQueue:n,l10n:s,pageColors:r,store:a,thumbnailWidth:o}){_PDFThumbnailViewer_instances.add(this),this.container=e,this.eventBus=t,this.linkService=i,this.renderingQueue=n,this.l10n=s,this.pageColors=r||null,this._thumbnails=[],this._currentPageNumber=0,this._pagesRotation=0,this._pageLabels=[],this.pdfDocument=null,this.store=a,this.thumbnailWidth=o,!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFThumbnailViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.scroll=watchScroll(this.container,this._scrollUpdated.bind(this)),this._resetView()}_scrollUpdated(){this.renderingQueue.renderHighestPriority()}getThumbnail(e){return this._thumbnails[e]}_getVisibleThumbs(){return getVisibleElements({scrollEl:this.container,views:this._thumbnails})}scrollThumbnailIntoView(e){if(!this.pdfDocument)return;const t=this._thumbnails[e-1];if(!t)return void console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');if(e!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(THUMBNAIL_SELECTED_CLASS),t.div.classList.add(THUMBNAIL_SELECTED_CLASS)}const i=this._getVisibleThumbs(),{first:n,last:s,views:r}=i;if(r.length>0){let i=!1;if(e<=n.id||e>=(null==s?void 0:s.id))i=!0;else for(const{id:t,percent:n}of r)if(t===e){i=n<100;break}i&&scrollIntoView(t.div,{top:THUMBNAIL_SCROLL_MARGIN})}this._currentPageNumber=e,this.forceRendering()}get pagesRotation(){return this._pagesRotation}set pagesRotation(e){if(!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!==RenderingStates.FINISHED&&e.reset();TempImageFactory.destroyCanvas()}_resetView(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=[],this._pagesRotation=0,this.container.textContent=""}setDocument(e){if(this.pdfDocument&&(this._cancelRendering(),this._resetView()),this.pdfDocument=e,!e)return;const t=e.getPage(1),i=e.getOptionalContentConfig();t.then((t=>{var n;const s=e.numPages,r=t.getViewport({scale:1});for(let e=1;e<=s;++e){const t=new 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,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(t)}null===(n=this._thumbnails[0])||void 0===n||n.setPdfPage(t);this._thumbnails[this._currentPageNumber-1].div.classList.add(THUMBNAIL_SELECTED_CLASS),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((e=>{console.error("Unable to initialize thumbnail viewer",e)}))}_cancelRendering(){for(const e of this._thumbnails)e.cancelRendering()}setPageLabels(e){var t,i;if(this.pdfDocument){e?Array.isArray(e)&&this.pdfDocument.numPages===e.length?this._pageLabels=e:(this._pageLabels=[],console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=[];for(let e=0,n=this._thumbnails.length;e<n;e++)this._thumbnails[e].setPageLabel(null!==(i=null===(t=this._pageLabels)||void 0===t?void 0:t[e])&&void 0!==i?i:null)}}forceRendering(){const e=this._getVisibleThumbs(),t=__classPrivateFieldGet(this,_PDFThumbnailViewer_instances,"m",_PDFThumbnailViewer_getScrollAhead).call(this,e),i=this.renderingQueue.getHighestPriority(e,this._thumbnails,t);return!!i&&(__classPrivateFieldGet(this,_PDFThumbnailViewer_instances,"m",_PDFThumbnailViewer_ensurePdfPageLoaded).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}var _OverlayManager_overlays,_OverlayManager_active;_PDFThumbnailViewer_instances=new WeakSet,_PDFThumbnailViewer_ensurePdfPageLoaded=function(e){var t;return __awaiter(this,void 0,void 0,(function*(){if(null==e?void 0:e.pdfPage)return e.pdfPage;try{const i=yield null===(t=this.pdfDocument)||void 0===t?void 0:t.getPage(e.id);return(null==e?void 0:e.pdfPage)||e.setPdfPage(i),i}catch(e){return console.error("Unable to get page for thumb view",e),null}}))},_PDFThumbnailViewer_getScrollAhead=function(e){var t,i;return 1===(null===(t=e.first)||void 0===t?void 0:t.id)||(null===(i=e.last)||void 0===i?void 0:i.id)!==this._thumbnails.length&&this.scroll.down};class OverlayManager{constructor(){_OverlayManager_overlays.set(this,new WeakMap),_OverlayManager_active.set(this,null)}get active(){return __classPrivateFieldGet(this,_OverlayManager_active,"f")}register(e,t=!1){return __awaiter(this,void 0,void 0,(function*(){if("object"!=typeof e)throw new Error("Not enough parameters.");if(__classPrivateFieldGet(this,_OverlayManager_overlays,"f").has(e))throw new Error("The overlay is already registered.");__classPrivateFieldGet(this,_OverlayManager_overlays,"f").set(e,{canForceClose:t}),e.addEventListener("cancel",(()=>{__classPrivateFieldSet(this,_OverlayManager_active,null)}))}))}unregister(e){return __awaiter(this,void 0,void 0,(function*(){if(!__classPrivateFieldGet(this,_OverlayManager_overlays,"f").has(e))throw new Error("The overlay does not exist.");if(__classPrivateFieldGet(this,_OverlayManager_active,"f")===e)throw new Error("The overlay cannot be removed while it is active.");__classPrivateFieldGet(this,_OverlayManager_overlays,"f").delete(e)}))}open(e){return __awaiter(this,void 0,void 0,(function*(){if(!__classPrivateFieldGet(this,_OverlayManager_overlays,"f").has(e))throw new Error("The overlay does not exist.");if(__classPrivateFieldGet(this,_OverlayManager_active,"f")){if(__classPrivateFieldGet(this,_OverlayManager_active,"f")===e)throw new Error("The overlay is already active.");if(!__classPrivateFieldGet(this,_OverlayManager_overlays,"f").get(e).canForceClose)throw new Error("Another overlay is currently active.");yield this.close()}__classPrivateFieldSet(this,_OverlayManager_active,e),e.showModal()}))}close(e=__classPrivateFieldGet(this,_OverlayManager_active,"f")){return __awaiter(this,void 0,void 0,(function*(){if(!e||!__classPrivateFieldGet(this,_OverlayManager_overlays,"f").has(e))throw new Error("The overlay does not exist.");if(!__classPrivateFieldGet(this,_OverlayManager_active,"f"))throw new Error("The overlay is currently not active.");if(__classPrivateFieldGet(this,_OverlayManager_active,"f")!==e)throw new Error("Another overlay is currently active.");e.close(),__classPrivateFieldSet(this,_OverlayManager_active,null)}))}}function getXfaHtmlForPrinting(e,t){const i=t.allXfaHtml,n=new pdf_viewerExports.SimpleLinkService,s=Math.round(100*pdfExports.PixelsPerInch.PDF_TO_CSS_UNITS)/100;for(const r of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",e.append(i);const a=new pdf_viewerExports.XfaLayerBuilder({pageDiv:i,pdfPage:null,annotationStorage:t.annotationStorage,linkService:n,xfaHtml:r}),o=pdfExports.getXfaPageViewport(r,{scale:s});a.render(o,"print")}}_OverlayManager_overlays=new WeakMap,_OverlayManager_active=new WeakMap;let activeService=null,dialog=null,overlayManager=new OverlayManager;function renderPage(e,t,i,n,s,r,a){const o=activeService.scratchCanvas,l=s/pdfExports.PixelsPerInch.PDF;o.width=Math.floor(n.width*l),o.height=Math.floor(n.height*l);const h=o.getContext("2d");return h.save(),h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,o.width,o.height),h.restore(),Promise.all([t.getPage(i),a]).then((function([e,t]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:e.getViewport({scale:1,rotation:n.rotation}),intent:"print",annotationMode:pdfExports.AnnotationMode.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:t};return e.render(i).promise}))}class PDFPrintService{constructor(e,t,i,n,s=null,r=null,a){this.pdfDocument=e,this.pagesOverview=t,this.printContainer=i,this._printResolution=n||150,this._optionalContentConfigPromise=s||e.getOptionalContentConfig(),this._printAnnotationStoragePromise=r||Promise.resolve(),this.l10n=a,this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const e=document.querySelector("body");null==e||e.setAttribute("data-pdfjsprinting","true");this.pagesOverview.every((e=>e.width===this.pagesOverview[0].width&&e.height===this.pagesOverview[0].height),this)||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style");const t=this.pagesOverview[0];this.pageStyleSheet.textContent="@page { size: "+t.width+"pt "+t.height+"pt;}",null==e||e.append(this.pageStyleSheet)}destroy(){if(activeService!==this)return;this.printContainer.textContent="";const e=document.querySelector("body");null==e||e.removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,activeService=null,ensureOverlay().then((function(){overlayManager.active===dialog&&overlayManager.close(dialog)}))}renderPages(){if(this.pdfDocument.isPureXfa)return getXfaHtmlForPrinting(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,t=(i,n)=>{if(this.throwIfInactive(),++this.currentPage>=e)return renderProgress(e,e,this.l10n),void i();const s=this.currentPage;renderProgress(s,e,this.l10n),renderPage(this,this.pdfDocument,s+1,this.pagesOverview[s],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){t(i,n)}),n)};return new Promise(t)}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");return i.className="printedPage",i.append(e),this.printContainer.append(i),new Promise((function(t,i){e.onload=t,e.onerror=i}))}performPrint(){return this.throwIfInactive(),new Promise((e=>{setTimeout((()=>{this.active?(print.call(window),setTimeout(e,20)):e()}),0)}))}get active(){return this===activeService}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const print=window.print;function dispatchEvent(e){const t=document.createEvent("CustomEvent");t.initCustomEvent(e,!1,!1,"custom"),window.dispatchEvent(t)}function abort(){activeService&&(activeService.destroy(),dispatchEvent("afterprint"))}function renderProgress(e,t,i){dialog||(dialog=document.getElementById("printServiceDialog"));const n=Math.round(100*e/t),s=dialog.querySelector("progress"),r=dialog.querySelector(".relative-progress");s.value=n,i.get("print_progress_percent",{progress:n}).then((e=>{r.textContent=e}))}if(window.print=function(){if(activeService)console.warn("Ignored window.print() because of a pending print job.");else{ensureOverlay().then((function(){activeService&&overlayManager.open(dialog)}));try{dispatchEvent("beforeprint")}finally{if(!activeService)return console.error("Expected print service to be initialized."),void ensureOverlay().then((function(){overlayManager.active===dialog&&overlayManager.close(dialog)}));const e=activeService;activeService.renderPages().then((function(){return e.performPrint()})).catch((function(){})).then((function(){e.active&&abort()}))}}},window.addEventListener("keydown",(function(e){80!==e.keyCode||!e.ctrlKey&&!e.metaKey||e.altKey||e.shiftKey||(window.print(),e.preventDefault(),e.stopImmediatePropagation())}),!0),"onbeforeprint"in window){const e=function(e){"custom"!==e.detail&&e.stopImmediatePropagation()};window.addEventListener("beforeprint",e),window.addEventListener("afterprint",e)}let overlayPromise;function ensureOverlay(){if(!overlayPromise){if(!overlayManager)throw new Error("The overlay manager has not yet been initialized.");dialog||(dialog=document.getElementById("printServiceDialog")),overlayPromise=overlayManager.register(dialog,!0),document.getElementById("printCancel").onclick=abort,dialog.addEventListener("close",abort)}return overlayPromise}const PDFPrintServiceFactory={instance:{supportsPrinting:!0,createPrintService(e,t,i,n,s,r,a){if(activeService)throw new Error("The print service is created and active.");return activeService=new PDFPrintService(e,t,i,n,s,r,a),activeService}}};var _PDFPresentationMode_instances,_PDFPresentationMode_state,_PDFPresentationMode_args,_PDFPresentationMode_mouseWheel,_PDFPresentationMode_notifyStateChange,_PDFPresentationMode_enter,_PDFPresentationMode_exit,_PDFPresentationMode_mouseDown,_PDFPresentationMode_contextMenu,_PDFPresentationMode_showControls,_PDFPresentationMode_hideControls,_PDFPresentationMode_resetMouseScrollState,_PDFPresentationMode_touchSwipe,_PDFPresentationMode_addWindowListeners,_PDFPresentationMode_removeWindowListeners,_PDFPresentationMode_fullscreenChange,_PDFPresentationMode_addFullscreenChangeListeners,_PDFPresentationMode_removeFullscreenChangeListeners;const DELAY_BEFORE_HIDING_CONTROLS=3e3,ACTIVE_SELECTOR="pdfPresentationMode",CONTROLS_SELECTOR="pdfPresentationModeControls",MOUSE_SCROLL_COOLDOWN_TIME=50,PAGE_SWITCH_THRESHOLD=.1,SWIPE_MIN_DISTANCE_THRESHOLD=50,SWIPE_ANGLE_THRESHOLD=Math.PI/6;class PDFPresentationMode{constructor({container:e,pdfViewer:t,eventBus:i}){_PDFPresentationMode_instances.add(this),_PDFPresentationMode_state.set(this,PresentationModeState.UNKNOWN),_PDFPresentationMode_args.set(this,null),this.container=e,this.pdfViewer=t,this.eventBus=i,this.contextMenuOpen=!1,this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0,this.touchSwipeState=null}request(){return __awaiter(this,void 0,void 0,(function*(){const{container:e,pdfViewer:t}=this;if(this.active||!t.pagesCount||!e.requestFullscreen)return!1;__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_addFullscreenChangeListeners).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_notifyStateChange).call(this,PresentationModeState.CHANGING);const i=e.requestFullscreen();__classPrivateFieldSet(this,_PDFPresentationMode_args,{pageNumber:t.currentPageNumber,scaleValue:t.currentScaleValue,scrollMode:t.scrollMode,spreadMode:null,annotationEditorMode:null}),t.spreadMode===SpreadMode.NONE||t.pageViewsReady&&t.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").spreadMode=t.spreadMode),t.annotationEditorMode!==pdfExports.AnnotationEditorType.DISABLE&&(__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").annotationEditorMode=t.annotationEditorMode);try{return yield i,t.focus(),!0}catch(e){__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_removeFullscreenChangeListeners).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_notifyStateChange).call(this,PresentationModeState.NORMAL)}return!1}))}get active(){return __classPrivateFieldGet(this,_PDFPresentationMode_state,"f")===PresentationModeState.CHANGING||__classPrivateFieldGet(this,_PDFPresentationMode_state,"f")===PresentationModeState.FULLSCREEN}}_PDFPresentationMode_state=new WeakMap,_PDFPresentationMode_args=new WeakMap,_PDFPresentationMode_instances=new WeakSet,_PDFPresentationMode_mouseWheel=function(e){if(!this.active)return;e.preventDefault();const t=normalizeWheelEventDelta(e),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<MOUSE_SCROLL_COOLDOWN_TIME)&&((this.mouseScrollDelta>0&&t<0||this.mouseScrollDelta<0&&t>0)&&__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_resetMouseScrollState).call(this),this.mouseScrollDelta+=t,Math.abs(this.mouseScrollDelta)>=PAGE_SWITCH_THRESHOLD)){const e=this.mouseScrollDelta;__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_resetMouseScrollState).call(this);(e>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},_PDFPresentationMode_notifyStateChange=function(e){__classPrivateFieldSet(this,_PDFPresentationMode_state,e),this.eventBus.dispatch("presentationmodechanged",{source:this,state:e})},_PDFPresentationMode_enter=function(){var e;__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_notifyStateChange).call(this,PresentationModeState.FULLSCREEN),this.container.classList.add(ACTIVE_SELECTOR),setTimeout((()=>{this.pdfViewer.scrollMode=ScrollMode.PAGE,null!==__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").spreadMode&&(this.pdfViewer.spreadMode=SpreadMode.NONE),this.pdfViewer.currentPageNumber=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode=pdfExports.AnnotationEditorType.NONE)}),0),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_addWindowListeners).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_showControls).call(this),this.contextMenuOpen=!1,null===(e=window.getSelection())||void 0===e||e.removeAllRanges()},_PDFPresentationMode_exit=function(){const e=this.pdfViewer.currentPageNumber;this.container.classList.remove(ACTIVE_SELECTOR),setTimeout((()=>{var t;__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_removeFullscreenChangeListeners).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_notifyStateChange).call(this,PresentationModeState.NORMAL),this.pdfViewer.scrollMode=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").scrollMode,null!==(null===(t=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f"))||void 0===t?void 0:t.spreadMode)&&(this.pdfViewer.spreadMode=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").spreadMode),this.pdfViewer.currentScaleValue=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").scaleValue,this.pdfViewer.currentPageNumber=e,null!==__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode=__classPrivateFieldGet(this,_PDFPresentationMode_args,"f").annotationEditorMode),__classPrivateFieldSet(this,_PDFPresentationMode_args,null)}),0),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_removeWindowListeners).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_hideControls).call(this),__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_resetMouseScrollState).call(this),this.contextMenuOpen=!1},_PDFPresentationMode_mouseDown=function(e){var t;if(this.contextMenuOpen)return this.contextMenuOpen=!1,void e.preventDefault();0===e.button&&(e.target.href&&(null===(t=e.target.parentNode)||void 0===t?void 0:t.hasAttribute("data-internal-link"))||(e.preventDefault(),e.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()))},_PDFPresentationMode_contextMenu=function(){this.contextMenuOpen=!0},_PDFPresentationMode_showControls=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(CONTROLS_SELECTOR),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(CONTROLS_SELECTOR),delete this.controlsTimeout}),DELAY_BEFORE_HIDING_CONTROLS)},_PDFPresentationMode_hideControls=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(CONTROLS_SELECTOR),delete this.controlsTimeout)},_PDFPresentationMode_resetMouseScrollState=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},_PDFPresentationMode_touchSwipe=function(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)>SWIPE_MIN_DISTANCE_THRESHOLD&&(s<=SWIPE_ANGLE_THRESHOLD||s>=Math.PI-SWIPE_ANGLE_THRESHOLD)?t=i:Math.abs(n)>SWIPE_MIN_DISTANCE_THRESHOLD&&Math.abs(s-Math.PI/2)<=SWIPE_ANGLE_THRESHOLD&&(t=n),t>0?this.pdfViewer.previousPage():t<0&&this.pdfViewer.nextPage()}},_PDFPresentationMode_addWindowListeners=function(){this.showControlsBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_showControls).bind(this),this.mouseDownBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_mouseDown).bind(this),this.mouseWheelBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_mouseWheel).bind(this),this.resetMouseScrollStateBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_resetMouseScrollState).bind(this),this.contextMenuBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_contextMenu).bind(this),this.touchSwipeBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_touchSwipe).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)},_PDFPresentationMode_removeWindowListeners=function(){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},_PDFPresentationMode_fullscreenChange=function(){document.fullscreenElement?__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_enter).call(this):__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_exit).call(this)},_PDFPresentationMode_addFullscreenChangeListeners=function(){this.fullscreenChangeBind=__classPrivateFieldGet(this,_PDFPresentationMode_instances,"m",_PDFPresentationMode_fullscreenChange).bind(this),window.addEventListener("fullscreenchange",this.fullscreenChangeBind)},_PDFPresentationMode_removeFullscreenChangeListeners=function(){window.removeEventListener("fullscreenchange",this.fullscreenChangeBind),delete this.fullscreenChangeBind};const initialState={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:SpreadMode.UNKNOWN,scrollMode:ScrollMode.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:pdfExports.AnnotationEditorType.NONE,pdfSlick:null},create=()=>createStore$1(((e,t)=>Object.assign(Object.assign({},initialState),{_setThumbnailView:(i,n)=>{const s=new Map(t().thumbnails),r=new Map(t().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:c,pageLabel:d,src:u=null}=n;r.set(i,n),s.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:c,pageLabel:d,src:u}),e({thumbnailViews:r,thumbnails:s})},_setThumbnailsViews:t=>{const i=new Map(t.map((e=>[e.id,e]))),n=new Map(t.map((e=>{const{canvasWidth:t,canvasHeight:i,scale:n,rotation:s,loaded:r,pageLabel:a,src:o=null}=e;return[e.id,{pageNumber:e.id,width:t,height:i,scale:n,rotation:s,loaded:r,pageLabel:a,src:o}]})));e({thumbnailViews:i,thumbnails:n})}})));var _PDFSlick_instances,_PDFSlick_renderingQueue,_PDFSlick_container,_PDFSlick_viewerContainer,_PDFSlick_thumbsContainer,_PDFSlick_annotationMode,_PDFSlick_annotationEditorMode,_PDFSlick_onError,_PDFSlick_initializePageLabels,_PDFSlick_parseDocumentInfo,_PDFSlick_parsePageSize,_PDFSlick_initInternalEventListeners,_PDFSlick_onDocumentReady,_PDFSlick_onRotationChanging,_PDFSlick_onSwitchSpreadMode,_PDFSlick_onSwitchScrollMode,_PDFSlick_onScaleChanging,_PDFSlick_onPageChanging,_PDFSlick_onPageRendered;pdfExports.GlobalWorkerOptions.workerSrc=new URL("pdfjs-dist/build/pdf.worker.js","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:_documentCurrentScript&&_documentCurrentScript.src||new URL("index.js",document.baseURI).href).toString();const US_PAGE_NAMES={"8.5x11":"Letter","8.5x14":"Legal"},METRIC_PAGE_NAMES={"297x420":"A3","210x297":"A4"};function getPageName(e,t,i){return i[`${t?e.width:e.height}x${t?e.height:e.width}`]}class PDFSlick{constructor({container:e,viewer:t,thumbs:i,store:n=create(),options:s,onError:r}){var a,o,l,h,c,d,u,p,g,f,m,_,v;_PDFSlick_instances.add(this),_PDFSlick_renderingQueue.set(this,void 0),_PDFSlick_container.set(this,void 0),_PDFSlick_viewerContainer.set(this,void 0),_PDFSlick_thumbsContainer.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,_PDFSlick_annotationMode.set(this,void 0),_PDFSlick_annotationEditorMode.set(this,void 0),_PDFSlick_onError.set(this,void 0),__classPrivateFieldSet(this,_PDFSlick_container,e),__classPrivateFieldSet(this,_PDFSlick_viewerContainer,t),__classPrivateFieldSet(this,_PDFSlick_thumbsContainer,i),__classPrivateFieldSet(this,_PDFSlick_onError,r),this.l10n=null!==(a=null==s?void 0:s.l10n)&&void 0!==a?a:pdf_viewerExports.NullL10n,this.downloadManager=new pdf_viewerExports.DownloadManager,this.textLayerMode=null!==(o=null==s?void 0:s.textLayerMode)&&void 0!==o?o:TextLayerMode.ENABLE,__classPrivateFieldSet(this,_PDFSlick_annotationMode,null!==(l=null==s?void 0:s.annotationMode)&&void 0!==l?l:pdfExports.AnnotationMode.ENABLE_FORMS),__classPrivateFieldSet(this,_PDFSlick_annotationEditorMode,null!==(h=null==s?void 0:s.annotationEditorMode)&&void 0!==h?h:pdfExports.AnnotationEditorType.NONE),this.removePageBorders=null!==(c=null==s?void 0:s.removePageBorders)&&void 0!==c&&c,this.singlePageViewer=null!==(d=null==s?void 0:s.singlePageViewer)&&void 0!==d&&d,this.enablePrintAutoRotate=null!==(u=null==s?void 0:s.enablePrintAutoRotate)&&void 0!==u&&u,this.useOnlyCssZoom=null!==(p=null==s?void 0:s.useOnlyCssZoom)&&void 0!==p&&p,this.pageColors=null!==(g=null==s?void 0:s.pageColors)&&void 0!==g?g:null,this.maxCanvasPixels=null!==(f=null==s?void 0:s.maxCanvasPixels)&&void 0!==f?f:16777216,this.printResolution=null!==(m=null==s?void 0:s.printResolution)&&void 0!==m?m:96,this.thumbnailWidth=null!==(_=null==s?void 0:s.thumbnailWidth)&&void 0!==_?_:125,!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.l10n=pdf_viewerExports.NullL10n,this.store=n;const b=new PDFRenderingQueue;b.onIdle=this._cleanup.bind(this),b.isThumbnailViewEnabled=!0,__classPrivateFieldSet(this,_PDFSlick_renderingQueue,b);const y=new pdf_viewerExports.EventBus,S=new pdf_viewerExports.PDFLinkService({eventBus:y,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),P=Object.assign(Object.assign({container:e},t&&{viewer:t}),{eventBus:y,linkService:S,renderingQueue:b,defaultRenderingQueue:!0,textLayerMode:this.textLayerMode,l10n:this.l10n,annotationMode:__classPrivateFieldGet(this,_PDFSlick_annotationMode,"f"),annotationEditorMode:__classPrivateFieldGet(this,_PDFSlick_annotationEditorMode,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/",useOnlyCssZoom:this.useOnlyCssZoom}),A=this.singlePageViewer?new pdf_viewerExports.PDFSinglePageViewer(P):new pdf_viewerExports.PDFViewer(P);b.setViewer(A),i&&(this.thumbnailViewer=new PDFThumbnailViewer({container:i,eventBus:y,linkService:S,renderingQueue:b,l10n:this.l10n,pageColors:this.pageColors,store:n,thumbnailWidth:this.thumbnailWidth}),b.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new PDFPresentationMode({container:e,pdfViewer:A,eventBus:y})),this.eventBus=y,this.linkService=S,this.viewer=A,this.linkService.setViewer(A);const w=null!==(v=null==s?void 0:s.scaleValue)&&void 0!==v?v:"auto";this.store.setState({scaleValue:w})}loadDocument(e,t){var i,n,s,r,a;return __awaiter(this,void 0,void 0,(function*(){if(this.url&&"string"==typeof this.url)try{URL.revokeObjectURL(this.url)}catch(e){}try{null===(i=this.document)||void 0===i||i.destroy(),null===(n=this.viewer)||void 0===n||n.cleanup(),e instanceof URL?this.url=e.toString():e instanceof ArrayBuffer?this.url=URL.createObjectURL(new Blob([e],{type:"application/pdf"})):this.url=e;const o=null!==(s=null==t?void 0:t.filename)&&void 0!==s?s:pdfExports.getPdfFilenameFromUrl(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=yield pdfExports.getDocument({url:this.url,isEvalSupported:!1}).promise;this.document=l,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(l)),__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_initInternalEventListeners).call(this),yield __classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_initializePageLabels).call(this),this.store.setState({filename:o,numPages:l.numPages,pageNumber:1,isDocumentLoaded:!0,url:e.toString()});const h=yield l.getAttachments(),c=new Map(Object.keys(null!=h?h:{}).sort(((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase()))).map((e=>[e,h[e]])));this.store.setState({attachments:c}),yield __classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_parseDocumentInfo).call(this),this.forceRendering()}catch(e){__classPrivateFieldGet(this,_PDFSlick_onError,"f")&&__classPrivateFieldGet(this,_PDFSlick_onError,"f").call(this,e)}}))}forceRendering(e=!0){__classPrivateFieldGet(this,_PDFSlick_renderingQueue,"f").printing=!!this.printService,__classPrivateFieldGet(this,_PDFSlick_renderingQueue,"f").isThumbnailViewEnabled=e,__classPrivateFieldGet(this,_PDFSlick_renderingQueue,"f").renderHighestPriority()}gotoPage(e){this.linkService.goToPage(e)}openOrDownloadData(e,t,i){var n;null===(n=this.downloadManager)||void 0===n||n.openOrDownloadData(e,t,i)}download(){var e,t;return __awaiter(this,void 0,void 0,(function*(){const i=this.url,{filename:n}=this;try{const t=yield this.document.getData(),s=new Blob([t],{type:"application/pdf"});yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(s,i,n,{})}catch(e){yield null===(t=this.downloadManager)||void 0===t?void 0:t.downloadUrl(i,n,{})}}))}save(){var e;return __awaiter(this,void 0,void 0,(function*(){const t=this.url,{filename:i}=this;try{const n=yield this.document.saveDocument(),s=new Blob([n],{type:"application/pdf"});yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(s,t,i,{})}catch(e){console.error(`Error when saving the document: ${e.message}`),yield this.download()}}))}downloadOrSave(){var e;const{annotationStorage:t}=null!==(e=this.document)&&void 0!==e?e:{};t&&t.size>0?this.save():this.download()}get supportsPrinting(){return PDFPrintServiceFactory.instance.supportsPrinting}beforePrint(){if(this.printService)return;if(!this.supportsPrinting)return;if(!this.viewer.pageViewsReady)return void this.l10n.get("printing_not_ready").then((e=>{window.alert(e)}));const e=this.viewer.getPagesOverview(),t=document.getElementById("printContainer"),i=this.printResolution,n=this.viewer.optionalContentConfigPromise,s=PDFPrintServiceFactory.instance.createPrintService(this.document,e,t,i,n,null,this.l10n);this.printService=s,this.forceRendering(),s.layout()}afterPrint(){var e;this.printService&&(this.printService.destroy(),this.printService=null,null===(e=this.document)||void 0===e||e.annotationStorage.resetModified()),this.forceRendering()}requestPresentationMode(){var e;null===(e=this.pdfPresentationMode)||void 0===e||e.request()}triggerPrinting(){this.supportsPrinting&&window.print()}_cleanup(){var e;if(this.document)try{this.viewer.cleanup(),null===(e=this.thumbnailViewer)||void 0===e||e.cleanup(),this.document.cleanup()}catch(e){console.error("Unable to perform cleanup",e)}}setAnnotationEditorMode(e){this.viewer.annotationEditorMode={mode:e},this.store.setState({annotationEditorMode:e})}setAnnotationEditorParams(e){const t=Array.isArray(e)?e:[e];for(const e of t)this.viewer.annotationEditorParams=e}setSpreadMode(e){isValidSpreadMode(e)&&(this.viewer.spreadMode=e,this.dispatch("switchspreadmode",{mode:e}))}setScrollMode(e){isValidScrollMode(e)&&(this.viewer.scrollMode=e,this.dispatch("switchscrollmode",{mode:e}))}setRotation(e){isValidRotation(e)&&(this.viewer.pagesRotation=e)}getPagesOverview(){var e,t;try{return null!==(t=null===(e=this.viewer)||void 0===e?void 0:e.getPagesOverview())&&void 0!==t?t:[]}catch(e){return[]}}increaseScale(){this.viewer.increaseScale()}decreaseScale(){this.viewer.decreaseScale()}set currentScaleValue(e){this.viewer.currentScaleValue=e}set currentScale(e){this.viewer.currentScale=e}getPageView(e){return this.viewer.getPageView(e)}on(e,t,i){this.eventBus.on(e,t,i)}off(e,t,i){this.eventBus.off(e,t,i)}dispatch(e,t){this.eventBus.dispatch(e,t)}}_PDFSlick_renderingQueue=new WeakMap,_PDFSlick_container=new WeakMap,_PDFSlick_viewerContainer=new WeakMap,_PDFSlick_thumbsContainer=new WeakMap,_PDFSlick_annotationMode=new WeakMap,_PDFSlick_annotationEditorMode=new WeakMap,_PDFSlick_onError=new WeakMap,_PDFSlick_instances=new WeakSet,_PDFSlick_initializePageLabels=function(){var e;return __awaiter(this,void 0,void 0,(function*(){const t=this.document,i=null!==(e=yield t.getPageLabels())&&void 0!==e?e:[],n=i.length;let s=0,r=0;for(let e=0;e<n;e++){const t=i[e];if(t===(e+1).toString())s++;else{if(""!==t)break;r++}}if(s>=n||r>=n)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)}))},_PDFSlick_parseDocumentInfo=function(){return __awaiter(this,void 0,void 0,(function*(){const{info:e,contentLength:t}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then((e=>__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_parsePageSize).call(this,getPageSizeInches(e),0)));this.store.setState({filesize:t,title:e.Title,author:e.Author,subject:e.Subject,keywords:e.Keywords,creator:e.Creator,producer:e.Producer,version:e.PDFFormatVersion,creationDate:pdfExports.PDFDateString.toDateObject(e.CreationDate),modificationDate:pdfExports.PDFDateString.toDateObject(e.ModDate),isLinearized:e.IsLinearized,pageSize:i})}))},_PDFSlick_parsePageSize=function(e,t){return __awaiter(this,void 0,void 0,(function*(){if(!e)return;t%180!=0&&(e={width:e.height,height:e.width});const i=isPortraitOrientation(e);let n={width:Math.round(100*e.width)/100,height:Math.round(100*e.height)/100},s={width:Math.round(25.4*e.width*10)/10,height:Math.round(25.4*e.height*10)/10},r=getPageName(n,i,US_PAGE_NAMES)||getPageName(s,i,METRIC_PAGE_NAMES);if(!(r||Number.isInteger(s.width)&&Number.isInteger(s.height))){const t={width:25.4*e.width,height:25.4*e.height},a={width:Math.round(s.width),height:Math.round(s.height)};Math.abs(t.width-a.width)<.1&&Math.abs(t.height-a.height)<.1&&(r=getPageName(a,i,METRIC_PAGE_NAMES),r&&(n={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},s=a))}const[{width:a,height:o},l,h,c]=yield Promise.all([n,this.l10n.get("document_properties_page_size_unit_inches"),r&&this.l10n.get(`document_properties_page_size_name_${r.toLowerCase()}`),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"))]);return{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:c}}))},_PDFSlick_initInternalEventListeners=function(){this.eventBus._on("pagesinit",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onDocumentReady).bind(this)),this.eventBus._on("scalechanging",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onScaleChanging).bind(this)),this.eventBus._on("pagechanging",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onPageChanging).bind(this)),this.eventBus._on("pagerendered",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onPageRendered).bind(this)),this.eventBus._on("rotationchanging",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onRotationChanging).bind(this)),this.eventBus._on("switchspreadmode",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onSwitchSpreadMode).bind(this)),this.eventBus._on("switchscrollmode",__classPrivateFieldGet(this,_PDFSlick_instances,"m",_PDFSlick_onSwitchScrollMode).bind(this)),this.eventBus._on("beforeprint",this.beforePrint.bind(this)),this.eventBus._on("afterprint",this.afterPrint.bind(this)),window.onbeforeprint=e=>{this.eventBus.dispatch("beforeprint",{source:window})},window.onafterprint=e=>{this.eventBus.dispatch("afterprint",{source:window})}},_PDFSlick_onDocumentReady=function({source:e}){var t;return __awaiter(this,void 0,void 0,(function*(){const i=yield null===(t=this.document)||void 0===t?void 0:t.getOutline(),n=this.store.getState().scaleValue;e.currentScale=1,e.currentScaleValue="auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:n,pagesReady:!0})}))},_PDFSlick_onRotationChanging=function({pagesRotation:e,pageNumber:t}){this.store.setState({pagesRotation:e}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=e),this.forceRendering(),this.viewer.currentPageNumber=t},_PDFSlick_onSwitchSpreadMode=function({mode:e}){this.store.setState({spreadMode:e})},_PDFSlick_onSwitchScrollMode=function({mode:e}){this.store.setState({scrollMode:e})},_PDFSlick_onScaleChanging=function({scale:e,presetValue:t}){this.store.setState({scale:e,scaleValue:t}),this.viewer.update()},_PDFSlick_onPageChanging=function({pageNumber:e}){var t;null===(t=this.thumbnailViewer)||void 0===t||t.scrollThumbnailIntoView(e),this.store.setState({pageNumber:e})},_PDFSlick_onPageRendered=function({pageNumber:e,error:t}){var i;if(__classPrivateFieldGet(this,_PDFSlick_thumbsContainer,"f")){const t=this.viewer.getPageView(e-1),n=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(e-1);t&&n&&n.setImage(t)}};var noop=function(){},isBrowser="undefined"!=typeof window,useIsomorphicLayoutEffect=isBrowser?React.useLayoutEffect:React.useEffect;function useTimeoutFn(e,t){var i=React.useRef(!1),n=React.useRef(),s=React.useRef(e),r=React.useCallback((function(){return i.current}),[]),a=React.useCallback((function(){i.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout((function(){i.current=!0,s.current()}),t)}),[t]),o=React.useCallback((function(){i.current=null,n.current&&clearTimeout(n.current)}),[]);return React.useEffect((function(){s.current=e}),[e]),React.useEffect((function(){return a(),o}),[t]),[r,o,a]}function useDebounce(e,t,i){void 0===i&&(i=[]);var n=useTimeoutFn(e,t),s=n[0],r=n[1],a=n[2];return React.useEffect(a,i),[s,r]}var defaultState={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};function useMeasure(){var e=React.useState(null),t=e[0],i=e[1],n=React.useState(defaultState),s=n[0],r=n[1],a=React.useMemo((function(){return new window.ResizeObserver((function(e){if(e[0]){var t=e[0].contentRect,i=t.x,n=t.y,s=t.width,a=t.height,o=t.top,l=t.left,h=t.bottom,c=t.right;r({x:i,y:n,width:s,height:a,top:o,left:l,bottom:h,right:c})}}))}),[]);return useIsomorphicLayoutEffect((function(){if(t)return a.observe(t),function(){a.disconnect()}}),[t]),[i,s]}var useMeasure$1=isBrowser&&void 0!==window.ResizeObserver?useMeasure:function(){return[noop,defaultState]};function PDFSlickViewer({usePDFSlickStore:e,viewerRef:t,className:i}){const n=e((e=>e.pdfSlick)),s=e((e=>e.scaleValue)),[r,{width:a}]=useMeasure$1();return useDebounce((()=>{a&&(!n||"auto"!==s&&"page-fit"!==s&&"page-width"!==s||(n.viewer.currentScaleValue=s),null==n||n.viewer.update())}),0,[a]),jsxRuntime.jsx("div",Object.assign({ref:e=>{t(e),r(e)},id:"viewerContainer",className:`pdfSlickContainer ${null!=i?i:""}`,style:{position:"absolute",inset:0}},{children:jsxRuntime.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})}))}function PDFSlickThumbnails({children:e,thumbsRef:t,usePDFSlickStore:i,className:n}){const s=i((e=>e.thumbnailViews)),r=i((e=>e.pdfSlick)),[a,{width:o}]=useMeasure$1();return useDebounce((()=>{o&&(null==r||r.forceRendering())}),0,[o]),jsxRuntime.jsx("div",Object.assign({ref:e=>{t(e),a(e)}},{className:n},{style:{position:"absolute",overflow:"auto",inset:0}},{children:Array.from(s).map((([t,i])=>{var n;return reactDom.createPortal(e({pageNumber:t,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(n=null==i?void 0:i.src)&&void 0!==n?n:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)}))}))}function createStore(e){return function(t,i){return useStore(e,t,i)}}const usePDFSlick=(e,t)=>{const[i,n]=React.useState(!1),[s,r]=React.useState(null),[a,o]=React.useState(null),[l,h]=React.useState(null),c=React.useMemo((()=>create()),[]),d=React.useMemo((()=>createStore(c)),[]),u=React.useCallback((e=>{null!==e&&r(e)}),[]),p=React.useCallback((e=>{null!==e&&o(e)}),[]);return React.useEffect((()=>{if(e&&s){const i=new PDFSlick({container:s,thumbs:a,store:c,options:t,onError:e=>h(e)});i.loadDocument(e,t).then((()=>{n(!0)})),c.setState({pdfSlick:i})}return()=>{}}),[e,s]),{isDocumentLoaded:i,viewerRef:u,thumbsRef:p,usePDFSlickStore:d,store:c,PDFSlickViewer:PDFSlickViewer,PDFSlickThumbnails:PDFSlickThumbnails,error:l}};exports.AutoPrintRegExp=AutoPrintRegExp,exports.CursorTool=CursorTool,exports.DEFAULT_SCALE=DEFAULT_SCALE,exports.DEFAULT_SCALE_DELTA=DEFAULT_SCALE_DELTA,exports.DEFAULT_SCALE_VALUE=DEFAULT_SCALE_VALUE,exports.MAX_AUTO_SCALE=MAX_AUTO_SCALE,exports.MAX_SCALE=MAX_SCALE,exports.MIN_SCALE=MIN_SCALE,exports.OutputScale=OutputScale,exports.PDFSlick=PDFSlick,exports.PDFSlickThumbnails=PDFSlickThumbnails,exports.PDFSlickViewer=PDFSlickViewer,exports.PresentationModeState=PresentationModeState,exports.ProgressBar=ProgressBar,exports.RendererType=RendererType,exports.RenderingStates=RenderingStates,exports.SCROLLBAR_PADDING=SCROLLBAR_PADDING,exports.ScrollMode=ScrollMode,exports.SidebarView=SidebarView,exports.SpreadMode=SpreadMode,exports.TextLayerMode=TextLayerMode,exports.UNKNOWN_SCALE=UNKNOWN_SCALE,exports.VERTICAL_PADDING=VERTICAL_PADDING,exports.animationStarted=animationStarted,exports.apiPageLayoutToViewerModes=apiPageLayoutToViewerModes,exports.apiPageModeToSidebarView=apiPageModeToSidebarView,exports.approximateFraction=approximateFraction,exports.backtrackBeforeAllVisibleElements=backtrackBeforeAllVisibleElements,exports.binarySearchFirstItem=binarySearchFirstItem,exports.create=create,exports.createStore=createStore,exports.docStyle=docStyle,exports.getActiveOrFocusedElement=getActiveOrFocusedElement,exports.getPageSizeInches=getPageSizeInches,exports.getVisibleElements=getVisibleElements,exports.initialState=initialState,exports.isPortraitOrientation=isPortraitOrientation,exports.isValidRotation=isValidRotation,exports.isValidScrollMode=isValidScrollMode,exports.isValidSpreadMode=isValidSpreadMode,exports.noContextMenuHandler=noContextMenuHandler,exports.normalizeWheelEventDelta=normalizeWheelEventDelta,exports.normalizeWheelEventDirection=normalizeWheelEventDirection,exports.parseQueryString=parseQueryString,exports.removeNullCharacters=removeNullCharacters,exports.roundToDivide=roundToDivide,exports.scrollIntoView=scrollIntoView,exports.usePDFSlick=usePDFSlick,exports.watchScroll=watchScroll}));
31
+ */var y={d:(t,e)=>{for(var i in e)y.o(e,i)&&!y.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},A=globalThis.pdfjsLib={};y.d(A,{AbortException:()=>Dt,AnnotationEditorLayer:()=>Dn,AnnotationEditorParamsType:()=>F,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>Te,AnnotationLayer:()=>gn,AnnotationMode:()=>R,ColorPicker:()=>Sn,DOMSVGFactory:()=>Ns,DrawLayer:()=>Rn,FeatureTest:()=>Ot,GlobalWorkerOptions:()=>_i,ImageKind:()=>U,InvalidPDFException:()=>Mt,MissingPDFException:()=>kt,OPS:()=>ft,OutputScale:()=>we,PDFDataRangeTransport:()=>ws,PDFDateString:()=>pe,PDFWorker:()=>xs,PasswordResponses:()=>mt,PermissionFlag:()=>O,PixelsPerInch:()=>te,RenderingCancelledException:()=>se,TextLayer:()=>hs,UnexpectedResponseException:()=>Lt,Util:()=>jt,VerbosityLevel:()=>gt,XfaLayer:()=>Fs,build:()=>ks,createValidAbsoluteUrl:()=>St,fetchData:()=>ee,getDocument:()=>ms,getFilenameFromUrl:()=>ae,getPdfFilenameFromUrl:()=>oe,getXfaPageViewport:()=>ge,isDataScheme:()=>ne,isPdfFile:()=>re,noContextMenu:()=>de,normalizeUnicode:()=>zt,setLayerDimensions:()=>ve,shadow:()=>Ct,stopEvent:()=>ce,version:()=>Ms});const _=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),x=[1,0,0,1,0,0],S=[.001,0,0,.001,0,0],C=1.35,E=1,P=2,T=4,M=16,k=32,L=64,I=128,D=256,R={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},N={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},F={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},O={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},B=0,j=1,V=2,H=3,z=3,$=4,U={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},W=1,G=2,q=3,X=4,K=5,Y=6,Q=7,J=8,Z=9,tt=10,et=11,it=12,st=13,nt=14,rt=15,at=16,ot=17,lt=20,ht=1,dt=2,ct=3,ut=4,pt=5,gt={ERRORS:0,WARNINGS:1,INFOS:5},ft={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,setStrokeTransparent:92,setFillTransparent:93},mt={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let bt=gt.WARNINGS;function vt(t){Number.isInteger(t)&&(bt=t)}function wt(){return bt}function yt(t){bt>=gt.INFOS&&console.log(`Info: ${t}`)}function At(t){bt>=gt.WARNINGS&&console.log(`Warning: ${t}`)}function _t(t){throw new Error(t)}function xt(t,e){t||_t(e)}function St(t,e=null,i=null){if(!t)return null;try{if(i&&"string"==typeof t){if(i.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);e?.length>=2&&(t=`http://${t}`)}if(i.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const s=e?new URL(t,e):new URL(t);if(function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(s))return s}catch{}return null}function Ct(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const Et=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class Pt extends Et{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Tt extends Et{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let Mt=class extends Et{constructor(t){super(t,"InvalidPDFException")}},kt=class extends Et{constructor(t){super(t,"MissingPDFException")}},Lt=class extends Et{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class It extends Et{constructor(t){super(t,"FormatError")}}let Dt=class extends Et{constructor(t){super(t,"AbortException")}};function Rt(t){"object"==typeof t&&void 0!==t?.length||_t("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const s=[];for(let n=0;n<e;n+=i){const r=Math.min(n+i,e),a=t.subarray(n,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function Nt(t){"string"!=typeof t&&_t("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let s=0;s<e;++s)i[s]=255&t.charCodeAt(s);return i}function Ft(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class Ot{static get isLittleEndian(){return Ct(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Ct(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Ct(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Ct(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?Ct(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):Ct(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Ct(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Bt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let jt=class{static makeHexColor(t,e,i){return`#${Bt[t]}${Bt[e]}${Bt[i]}`}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static applyTransform(t,e){return[t[0]*e[0]+t[1]*e[2]+e[4],t[0]*e[1]+t[1]*e[3]+e[5]]}static applyInverseTransform(t,e){const i=e[0]*e[3]-e[1]*e[2];return[(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/i,(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/i]}static getAxialAlignedBoundingBox(t,e){const i=this.applyTransform(t,e),s=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),r=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],r[0]),Math.min(i[1],s[1],n[1],r[1]),Math.max(i[0],s[0],n[0],r[0]),Math.max(i[1],s[1],n[1],r[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],i=t[0]*e[0]+t[1]*e[2],s=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],r=t[2]*e[1]+t[3]*e[3],a=(i+r)/2,o=Math.sqrt((i+r)**2-4*(i*r-n*s))/2,l=a+o||1,h=a-o||1;return[Math.sqrt(l),Math.sqrt(h)]}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),s=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>s)return null;const n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),r=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>r?null:[i,n,s,r]}static#t(t,e,i,s,n,r,a,o,l,h){if(l<=0||l>=1)return;const d=1-l,c=l*l,u=c*l,p=d*(d*(d*t+3*l*e)+3*c*i)+u*s,g=d*(d*(d*n+3*l*r)+3*c*a)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)}static#e(t,e,i,s,n,r,a,o,l,h,d,c){if(Math.abs(l)<1e-12)return void(Math.abs(h)>=1e-12&&this.#t(t,e,i,s,n,r,a,o,-d/h,c));const u=h**2-4*d*l;if(u<0)return;const p=Math.sqrt(u),g=2*l;this.#t(t,e,i,s,n,r,a,o,(-h+p)/g,c),this.#t(t,e,i,s,n,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,r,a,o,l){return l?(l[0]=Math.min(l[0],t,a),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,a),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,a),Math.min(e,o),Math.max(t,a),Math.max(e,o)],this.#e(t,i,n,a,e,s,r,o,3*(3*(i-n)-t+a),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,a,e,s,r,o,3*(3*(s-r)-e+o),6*(e-2*s+r),3*(s-e),l),l}};let Vt=null,Ht=null;function zt(t){return Vt||(Vt=/([\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,Ht=new Map([["ſt","ſt"]])),t.replaceAll(Vt,((t,e,i)=>e?e.normalize("NFKC"):Ht.get(i)))}const $t="pdfjs_internal_id_",Ut=0,Wt=1,Gt=2,qt=3,Xt=4,Kt=5,Yt=6,Qt=7,Jt=8;"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const Zt="http://www.w3.org/2000/svg";let te=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function ee(t,e="text"){if(he(t,document.baseURI)){const i=await fetch(t);if(!i.ok)throw new Error(i.statusText);switch(e){case"arraybuffer":return i.arrayBuffer();case"blob":return i.blob();case"json":return i.json()}return i.text()}return new Promise(((i,s)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)s(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(n.response)}i(n.responseText)}},n.send(null)}))}class ie{constructor({viewBox:t,scale:e,rotation:i,offsetX:s=0,offsetY:n=0,dontFlip:r=!1}){this.viewBox=t,this.scale=e,this.rotation=i,this.offsetX=s,this.offsetY=n;const a=(t[2]+t[0])/2,o=(t[3]+t[1])/2;let l,h,d,c,u,p,g,f;switch((i%=360)<0&&(i+=360),i){case 180:l=-1,h=0,d=0,c=1;break;case 90:l=0,h=1,d=1,c=0;break;case 270:l=0,h=-1,d=-1,c=0;break;case 0:l=1,h=0,d=0,c=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,c=-c),0===l?(u=Math.abs(o-t[1])*e+s,p=Math.abs(a-t[0])*e+n,g=(t[3]-t[1])*e,f=(t[2]-t[0])*e):(u=Math.abs(a-t[0])*e+s,p=Math.abs(o-t[1])*e+n,g=(t[2]-t[0])*e,f=(t[3]-t[1])*e),this.transform=[l*e,h*e,d*e,c*e,u-l*e*a-d*e*o,p-h*e*a-c*e*o],this.width=g,this.height=f}get rawDims(){const{viewBox:t}=this;return Ct(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new ie({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return jt.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=jt.applyTransform([t[0],t[1]],this.transform),i=jt.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return jt.applyInverseTransform([t,e],this.transform)}}let se=class extends Et{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function ne(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function re(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function ae(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function oe(t,e="document.pdf"){if("string"!=typeof t)return e;if(ne(t))return At('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,s=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(t);let n=i.exec(s[1])||i.exec(s[2])||i.exec(s[3]);if(n&&(n=n[0],n.includes("%")))try{n=i.exec(decodeURIComponent(n))[0]}catch{}return n||e}class le{started=Object.create(null);times=[];time(t){t in this.started&&At(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||At(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:t}of this.times)e=Math.max(t.length,e);for(const{name:i,start:s,end:n}of this.times)t.push(`${i.padEnd(e)} ${n-s}ms\n`);return t.join("")}}function he(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function de(t){t.preventDefault()}function ce(t){t.preventDefault(),t.stopPropagation()}function ue(t){console.log("Deprecated API usage: "+t)}let pe=class{static#i;static toDateObject(t){if(!t||"string"!=typeof t)return null;this.#i||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const e=this.#i.exec(t);if(!e)return null;const i=parseInt(e[1],10);let s=parseInt(e[2],10);s=s>=1&&s<=12?s-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let a=parseInt(e[5],10);a=a>=0&&a<=59?a:0;let o=parseInt(e[6],10);o=o>=0&&o<=59?o:0;const l=e[7]||"Z";let h=parseInt(e[8],10);h=h>=0&&h<=23?h:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===l?(r+=h,a+=d):"+"===l&&(r-=h,a-=d),new Date(Date.UTC(i,s,n,r,a,o))}};function ge(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new ie({viewBox:r,scale:e,rotation:i})}function fe(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map((t=>parseInt(t))):t.startsWith("rgba(")?t.slice(5,-1).split(",").map((t=>parseInt(t))).slice(0,3):(At(`Not a valid color format: "${t}"`),[0,0,0])}function me(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function be(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform().invertSelf();return[e,i,s,n,r,a]}function ve(t,e,i=!1,s=!0){if(e instanceof ie){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:r}=t,a=Ot.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=a?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let we=class{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}};class ye{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=t,ye.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const t=this.#s=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;t.addEventListener("contextmenu",de,{signal:e}),t.addEventListener("pointerdown",ye.#h,{signal:e});const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const s=this.#r.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-s[0]:s[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*s[1]}% + var(--editor-toolbar-vert-offset))`}return this.#d(),t}get div(){return this.#s}static#h(t){t.stopPropagation()}#c(t){this.#r._focusEventsAllowed=!1,ce(t)}#u(t){this.#r._focusEventsAllowed=!0,ce(t)}#p(t){const e=this.#r._uiManager._signal;t.addEventListener("focusin",this.#c.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",de,{signal:e})}hide(){this.#s.classList.add("hidden"),this.#n?.hideDropdown()}show(){this.#s.classList.remove("hidden"),this.#o?.shown()}#d(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",ye.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#a.append(i)}get#g(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#p(e),this.#a.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#a.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Ae{#a=null;#s=null;#f;constructor(t){this.#f=t}#m(){const t=this.#s=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",de,{signal:this.#f._signal});const e=this.#a=document.createElement("div");return e.className="buttons",t.append(e),this.#b(),t}#v(t,e){let i=0,s=0;for(const n of t){const t=n.y+n.height;if(t<i)continue;const r=n.x+(e?n.width:0);t>i?(s=r,i=t):e?r>s&&(s=r):r<s&&(s=r)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:r}=this.#s||=this.#m();t.append(this.#s),r.insetInlineEnd=100*s+"%",r.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){this.#s.remove()}#b(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const i=this.#f._signal;t.addEventListener("contextmenu",de,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#a.append(t)}}function _e(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class xe{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class Se{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Rt(t)}();#w=0;#A=null;static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.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>';return Ct(this,"_isSVGFittingCanvas",e.decode().then((()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0]))))}async#_(t,e){this.#A||=new Map;let i=this.#A.get(t);if(null===i)return null;if(i?.bitmap)return i.refCounter+=1,i;try{let t;if(i||={bitmap:null,id:`image_${this.#y}_${this.#w++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await ee(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Se._isSVGFittingCanvas,s=new FileReader,n=new Image,r=new Promise(((t,r)=>{n.onload=()=>{i.bitmap=n,i.isSvg=!0,t()},s.onload=async()=>{const t=i.svgUrl=s.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=s.onerror=r}));s.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){At(t),i=null}return this.#A.set(t,i),i&&this.#A.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:s,type:n}=t;return this.#_(`${e}_${i}_${s}_${n}`,t)}async getFromUrl(t){return this.#_(t,t)}async getFromBlob(t,e){const i=await e;return this.#_(t,i)}async getFromId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){this.#A||=new Map;let i=this.#A.get(t);if(i?.bitmap)return i.refCounter+=1,i;const s=new OffscreenCanvas(e.width,e.height);return s.getContext("2d").drawImage(e,0,0),i={bitmap:s.transferToImageBitmap(),id:`image_${this.#y}_${this.#w++}`,refCounter:1,isSvg:!1},this.#A.set(t,i),this.#A.set(i.id,i),i}getSvgUrl(t){const e=this.#A.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#A||=new Map;const e=this.#A.get(t);if(!e)return;if(e.refCounter-=1,0!==e.refCounter)return;const{bitmap:i}=e;if(!e.url&&!e.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=t.convertToBlob()}i.close?.(),e.bitmap=null}isValidId(t){return t.startsWith(`image_${this.#y}_`)}}class Ce{#x=[];#S=!1;#C;#E=-1;constructor(t=128){this.#C=t}add({cmd:t,undo:e,post:i,mustExec:s,type:n=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(s&&t(),this.#S)return;const o={cmd:t,undo:e,post:i,type:n};if(-1===this.#E)return this.#x.length>0&&(this.#x.length=0),this.#E=0,void this.#x.push(o);if(r&&this.#x[this.#E].type===n)return a&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class Ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Ot.platform;for(const[i,s,n={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:s,options:n}),this.allKeys.add(t.split("+").at(-1)))}}#P(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(this.#P(e));if(!i)return;const{callback:s,options:{bubbles:n=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(s.bind(t,...r,e)(),n||ce(e))}}class Pe{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",document.body.append(e);for(const i of t.keys()){e.style.color=i;const s=window.getComputedStyle(e).color;t.set(i,fe(s))}e.remove()}(t),Ct(this,"_colors",t)}convert(t){const e=fe(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[t,i]of this._colors)if(i.every(((t,i)=>t===e[i])))return Pe._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?jt.makeHexColor(...e):t}}let Te=class t{#T=new AbortController;#M=null;#k=new Map;#L=new Map;#I=null;#D=null;#R=null;#N=new Ce;#F=null;#O=null;#B=0;#j=new Set;#V=null;#H=null;#z=new Set;_editorUndoBar=null;#$=!1;#U=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new xe;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#rt=N.NONE;#at=new Set;#ot=null;#lt=null;#ht=null;#dt={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ct=[0,0];#ut=null;#pt=null;#gt=null;#ft=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#pt.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),s=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return Ct(this,"_keyboardManager",new Ee([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,e,i,s,n,r,a,o,l,h,d,c){const u=this._signal=this.#T.signal;this.#pt=t,this.#gt=e,this.#I=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:u}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:u}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:u}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:u}),s._on("setpreference",this.onSetPreference.bind(this),{signal:u}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:u}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=r,this.#K=a||null,this.#$=o,this.#U=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:te.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null}destroy(){this.#ft?.resolve(),this.#ft=null,this.#T?.abort(),this.#T=null,this._signal=null;for(const t of this.#L.values())t.destroy();this.#L.clear(),this.#k.clear(),this.#z.clear(),this.#M=null,this.#at.clear(),this.#N.destroy(),this.#I?.destroy(),this.#Q?.hide(),this.#Q=null,this.#q&&(clearTimeout(this.#q),this.#q=null),this.#ut&&(clearTimeout(this.#ut),this.#ut=null),this._editorUndoBar?.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#nt}get useNewAltTextFlow(){return this.#U}get useNewAltTextWhenAddingImage(){return this.#W}get hcmFilter(){return Ct(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return Ct(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return Ct(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return Ct(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(t=>t.reverse()))):null)}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#O=t}setMainHighlightColorPicker(t){this.#st=t}editAltText(t,e=!1){this.#I?.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)this.#W=e}onPageChanging({pageNumber:t}){this.#B=t-1}focusMainContainer(){this.#pt.focus()}findParent(t,e){for(const i of this.#L.values()){const{x:s,y:n,width:r,height:a}=i.div.getBoundingClientRect();if(t>=s&&t<=s+r&&e>=n&&e<=n+a)return i}return null}disableUserSelect(t=!1){this.#gt.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#z.add(t)}removeShouldRescale(t){this.#z.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*te.PDF_TO_CSS_UNITS;for(const t of this.#z)t.onScaleChanging();this.#O?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#wt({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#yt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#L.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r}=e,a=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#rt===N.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:r,text:a}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(N.HIGHLIGHT,c):c()}#At(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#wt(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#Q||=new Ae(this),this.#Q.show(e,i,"ltr"===this.direction))}addToAnnotationStorage(t){t.isEmpty()||!this.#D||this.#D.has(t.id)||this.#D.setValue(t.id,t)}#_t(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#ot)return;const i=this.#wt(t).closest(".textLayer");if(i){if(this.#Q?.hide(),this.#ot=e,this.#xt({hasSelectedText:!0}),(this.#rt===N.HIGHLIGHT||this.#rt===N.NONE)&&(this.#rt===N.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#rt===N.HIGHLIGHT?this.#yt(i):null;t?.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#St("main_toolbar"))};window.addEventListener("pointerup",n,{signal:s}),window.addEventListener("blur",n,{signal:s})}}else this.#ot&&(this.#Q?.hide(),this.#ot=null,this.#xt({hasSelectedText:!1}))}#St(t=""){this.#rt===N.HIGHLIGHT?this.highlightSelection(t):this.#$&&this.#At()}#mt(){document.addEventListener("selectionchange",this.#_t.bind(this),{signal:this._signal})}#Ct(){if(this.#X)return;this.#X=new AbortController;const t=this.combinedSignal(this.#X);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#Et(){this.#X?.abort(),this.#X=null}blur(){if(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#at)if(e.div.contains(t)){this.#it=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#it)return;const[t,e]=this.#it;this.#it=null,e.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),e.focus()}#vt(){if(this.#et)return;this.#et=new AbortController;const t=this.combinedSignal(this.#et);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Pt(){this.#et?.abort(),this.#et=null}#Tt(){if(this.#F)return;this.#F=new AbortController;const t=this.combinedSignal(this.#F);document.addEventListener("copy",this.copy.bind(this),{signal:t}),document.addEventListener("cut",this.cut.bind(this),{signal:t}),document.addEventListener("paste",this.paste.bind(this),{signal:t})}#Mt(){this.#F?.abort(),this.#F=null}#bt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#vt(),this.#Tt()}removeEditListeners(){this.#Pt(),this.#Mt()}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const i of this.#H)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#M?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#at){const i=t.serialize(!0);i&&e.push(i)}0!==e.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const t of e.items)for(const e of this.#H)if(e.isHandlingMimeForPasting(t.type))return void e.paste(t,this.currentLayer);let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(t){return void At(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const s=this.currentLayer;try{const t=[];for(const e of i){const i=await s.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#kt(e);this.#Lt(t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(t){At(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#rt===N.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#Y&&(this.#Y=!1,this.#St("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#xt(t){Object.entries(t).some((([t,e])=>this.#dt[t]!==e))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#dt,t)}),this.#rt===N.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#It([[F.HIGHLIGHT_FREE,!0]]))}#It(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Tt(),this.#xt({isEditing:this.#rt!==N.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Mt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#It(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#L.get(this.#B)}getLayer(t){return this.#L.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#L.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#L.delete(t.pageIndex)}async updateMode(t,e=null,i=!1){if(this.#rt!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#rt=t,t===N.NONE)return this.setEditingState(!1),this.#Rt(),this._editorUndoBar?.hide(),void this.#ft.resolve();this.setEditingState(!0),await this.#Nt(),this.unselectAll();for(const e of this.#L.values())e.updateMode(t);if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#ft.resolve();for(const t of this.#k.values())t.annotationElementId===e?(this.setSelected(t),t.enterInEditMode()):t.unselect();this.#ft.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==this.#rt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#H){switch(t){case F.CREATE:return void this.currentLayer.addNewEditor();case F.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case F.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#ht||=new Map).set(t,e),this.showAllEditors("highlight",e)}for(const i of this.#at)i.updateParams(t,e);for(const i of this.#H)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#k.values())i.editorType===t&&i.show(e);(this.#ht?.get(F.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#It([[F.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#L.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Nt(){if(!this.#Z){this.#Z=!0;const t=[];for(const e of this.#L.values())t.push(e.enable());await Promise.all(t);for(const t of this.#k.values())t.enable()}}#Rt(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const t of this.#L.values())t.disable();for(const t of this.#k.values())t.disable()}}getEditors(t){const e=[];for(const i of this.#k.values())i.pageIndex===t&&e.push(i);return e}getEditor(t){return this.#k.get(t)}addEditor(t){this.#k.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#q&&clearTimeout(this.#q),this.#q=setTimeout((()=>{this.focusMainContainer(),this.#q=null}),0)),this.#k.delete(t.id),this.unselect(t),t.annotationElementId&&this.#j.has(t.annotationElementId)||this.#D?.remove(t.id)}addDeletedAnnotationElement(t){this.#j.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#j.has(t)}removeDeletedAnnotationElement(t){this.#j.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#kt(t){const e=this.#L.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#M!==t&&(this.#M=t,t&&this.#It(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#It(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#It(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#at.has(t))return this.#at.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#at.add(t),t.select(),this.#It(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#at)e!==t&&e.unselect();this.#at.clear(),this.#at.add(t),t.select(),this.#It(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#at.has(t)}get firstSelectedEditor(){return this.#at.values().next().value}unselect(t){t.unselect(),this.#at.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#at.size}get isEnterHandled(){return 1===this.#at.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#xt({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Dt()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Dt()})}addCommands(t){this.#N.add(t),this.#xt({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Dt()})}cleanUndoStack(t){this.#N.cleanType(t)}#Dt(){if(0===this.#k.size)return!0;if(1===this.#k.size)for(const t of this.#k.values())return t.isEmpty();return!1}delete(){this.commitOrRemove();const t=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...this.#at],i=()=>{for(const t of e)this.#kt(t)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(i,1===e.length?e[0].editorType:e.length);for(const t of e)t.remove()},undo:i,mustExec:!0})}commitOrRemove(){this.#M?.commitOrRemove()}hasSomethingToControl(){return this.#M||this.hasSelection}#Lt(t){for(const t of this.#at)t.unselect();this.#at.clear();for(const e of t)e.isEmpty()||(this.#at.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#at)t.commit();this.#Lt(this.#k.values())}unselectAll(){if((!this.#M||(this.#M.commitOrRemove(),this.#rt===N.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#at)t.unselect();this.#at.clear(),this.#xt({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#ct[0]+=t,this.#ct[1]+=e;const[s,n]=this.#ct,r=[...this.#at];this.#ut&&clearTimeout(this.#ut),this.#ut=setTimeout((()=>{this.#ut=null,this.#ct[0]=this.#ct[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of r)this.#k.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of r)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#V=new Map;for(const t of this.#at)this.#V.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#V)return!1;this.disableUserSelect(!1);const t=this.#V;this.#V=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},r]of t)r.newX=i,r.newY=s,r.newPageIndex=n,e||=i!==r.savedX||s!==r.savedY||n!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,s)=>{if(this.#k.has(t.id)){const n=this.#L.get(s);n?t._setParentAndPosition(n,e,i):(t.pageIndex=s,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:s,newY:n,newPageIndex:r}]of t)i(e,s,n,r)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:r}]of t)i(e,s,n,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#V)for(const i of this.#V.keys())i.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#at.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#M===t}getActive(){return this.#M}getMode(){return this.#rt}get imageManager(){return Ct(this,"imageManager",new Se)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,s=e.rangeCount;i<s;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:s,width:n,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-s)/r,y:1-(t+a-i)/n,width:o/r,height:a/n});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/n,y:1-(e+o-s)/r,width:a/n,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-s)/r,y:(t-i)/n,width:o/r,height:a/n});break;default:a=(t,e,a,o)=>({x:(t-i)/n,y:(e-s)/r,width:a/n,height:o/r})}const o=[];for(let t=0,i=e.rangeCount;t<i;t++){const i=e.getRangeAt(t);if(!i.collapsed)for(const{x:t,y:e,width:s,height:n}of i.getClientRects())0!==s&&0!==n&&o.push(a(t,e,s,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#R||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#R?.delete(t)}renderAnnotationElement(t){const e=this.#R?.get(t.data.id);if(!e)return;const i=this.#D.getRawValue(e);i&&(this.#rt!==N.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class Me{#o=null;#Ot=!1;#Bt=null;#jt=null;#Vt=null;#Ht=null;#zt=!1;#$t=null;#r=null;#Ut=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Gt=t._uiManager.useNewAltTextFlow,Me.#qt||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(t){Me._l10n??=t}async render(){const t=this.#Bt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#jt=document.createElement("span");t.append(e),this.#Gt?(t.classList.add("new"),t.setAttribute("data-l10n-id",Me.#qt.missing),e.setAttribute("data-l10n-id",Me.#qt["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=this.#r._uiManager._signal;t.addEventListener("contextmenu",de,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#Gt&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Xt}})};return t.addEventListener("click",s,{capture:!0,signal:i}),t.addEventListener("keydown",(e=>{e.target===t&&"Enter"===e.key&&(this.#zt=!0,s(e))}),{signal:i}),await this.#Kt(),t}get#Xt(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Bt&&(this.#Bt.focus({focusVisible:this.#zt}),this.#zt=!1)}isEmpty(){return this.#Gt?null===this.#o:!this.#o&&!this.#Ot}hasData(){return this.#Gt?null!==this.#o||!!this.#Ut:this.isEmpty()}get guessedText(){return this.#Ut}async setGuessedText(t){null===this.#o&&(this.#Ut=t,this.#Wt=await Me._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#Kt())}toggleAltTextBadge(t=!1){if(!this.#Gt||this.#o)return this.#$t?.remove(),void(this.#$t=null);if(!this.#$t){const t=this.#$t=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#$t.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#Ut!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#Ut,textWithDisclaimer:this.#Wt}}get data(){return{altText:this.#o,decorative:this.#Ot}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:s,cancel:n=!1}){i&&(this.#Ut=i,this.#Wt=s),this.#o===t&&this.#Ot===e||(n||(this.#o=t,this.#Ot=e),this.#Kt())}toggle(t=!1){this.#Bt&&(!t&&this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Bt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Xt}})}destroy(){this.#Bt?.remove(),this.#Bt=null,this.#jt=null,this.#Vt=null,this.#$t?.remove(),this.#$t=null}async#Kt(){const t=this.#Bt;if(!t)return;if(this.#Gt){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",Me.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",Me.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Vt?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Vt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Vt;if(!e){this.#Vt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,s=this.#r._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Ht),this.#Ht=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Ht=setTimeout((()=>{this.#Ht=null,this.#Vt.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Ht&&(clearTimeout(this.#Ht),this.#Ht=null),this.#Vt?.classList.remove("show")}),{signal:s})}this.#Ot?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=this.#o),e.parentNode||t.append(e);const i=this.#r.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}class ke{#Yt=null;#Qt=null;#o=null;#Jt=!1;#Zt=null;#te="";#ee=!1;#ie=null;#se=null;#ne=null;#re=null;#ae="";#oe=!1;#le=null;#he=!1;#de=!1;#ce=!1;#ue=null;#pe=0;#ge=0;#fe=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#me=!1;#be=ke._zIndex++;static _borderLineWidth=-1;static _colorManager=new Pe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ke.prototype._resizeWithKeyboard,e=Te.TRANSLATE_SMALL,i=Te.TRANSLATE_BIG;return Ct(this,"_resizerKeyboardManager",new Ee([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],ke.prototype._stopResizingWithKeyboard]]))}constructor(t){this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null;const{rotation:e,rawDims:{pageWidth:i,pageHeight:s,pageX:n,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,r];const[a,o]=this.parentDimensions;this.x=t.x/a,this.y=t.y/o,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Ct(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Le({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(ke._l10n??=t,ke._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==ke._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ke._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#me}set _isDraggable(t){this.#me=t,this.div?.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#be}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#ve(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#oe?this.#oe=!1:this.parent.setSelected(this))}focusout(t){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const e=t.relatedTarget;e?.closest(`#${this.id}`)||(t.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,s){const[n,r]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/r,this.fixAndSetPosition()}#we([t,e],i,s){[i,s]=this.screenToPageTranslation(i,s),this.x+=i/t,this.y+=s/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#we(this.parentDimensions,t,e)}translateInPage(t,e){this.#le||=[this.x,this.y,this.width,this.height],this.#we(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#le||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[s,n]}=this;if(this.x+=t/s,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:r,y:a}=this;const[o,l]=this.getBaseTranslation();r+=o,a+=l;const{style:h}=i;h.left=`${(100*r).toFixed(2)}%`,h.top=`${(100*a).toFixed(2)}%`,this._onTranslating(r,a),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!this.#le&&(this.#le[0]!==this.x||this.#le[1]!==this.y)}get _hasBeenResized(){return!!this.#le&&(this.#le[2]!==this.width||this.#le[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ke,s=i/t,n=i/e;switch(this.rotation){case 90:return[-s,n];case 180:return[s,n];case 270:return[s,-n];default:return[-s,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,s]}=this;let{x:n,y:r,width:a,height:o}=this;if(a*=i,o*=s,n*=i,r*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-a,n)),r=Math.max(0,Math.min(s-o,r));break;case 90:n=Math.max(0,Math.min(i-o,n)),r=Math.min(s,Math.max(a,r));break;case 180:n=Math.min(i,Math.max(a,n)),r=Math.min(s,Math.max(o,r));break;case 270:n=Math.min(i,Math.max(o,n)),r=Math.max(0,Math.min(s-a,r))}this.x=n/=i,this.y=r/=s;const[l,h]=this.getBaseTranslation();n+=l,r+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#ye(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}}screenToPageTranslation(t,e){return ke.#ye(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ke.#ye(t,e,360-this.parentRotation)}#Ae(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,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:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(t,e){const[i,s]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/i).toFixed(2)}%`,this.#ee||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ee&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ee||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_e(){if(this.#ie)return;this.#ie=document.createElement("div"),this.#ie.classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const t=document.createElement("div");this.#ie.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#xe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",de,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#ie)}#xe(t,e){e.preventDefault();const{isMac:i}=Ot.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const s=this._isDraggable;this._isDraggable=!1,this.#se=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Se.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",ce,{passive:!1,signal:r}),window.addEventListener("contextmenu",de,{signal:r}),this.#ne={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const a=this.parent.div.style.cursor,o=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const l=()=>{n.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=s,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#Ce()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#Ee(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,r]=this.parentDimensions;this.setDims(n*i,r*s),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ce(){if(!this.#ne)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#ne;this.#ne=null;const n=this.x,r=this.y,a=this.width,o=this.height;n===t&&r===e&&a===i&&o===s||this.addCommands({cmd:this.#Ee.bind(this,n,r,a,o),undo:this.#Ee.bind(this,t,e,i,s),mustExec:!0})}#Se(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=ke.MIN_SIZE/i,h=ke.MIN_SIZE/s,d=t=>Math.round(1e4*t)/1e4,c=this.#Ae(this.rotation),u=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],p=this.#Ae(360-this.rotation);let g,f,m=!1,b=!1;switch(t){case"topLeft":m=!0,g=(t,e)=>[0,0],f=(t,e)=>[t,e];break;case"topMiddle":g=(t,e)=>[t/2,0],f=(t,e)=>[t/2,e];break;case"topRight":m=!0,g=(t,e)=>[t,0],f=(t,e)=>[0,e];break;case"middleRight":b=!0,g=(t,e)=>[t,e/2],f=(t,e)=>[0,e/2];break;case"bottomRight":m=!0,g=(t,e)=>[t,e],f=(t,e)=>[0,0];break;case"bottomMiddle":g=(t,e)=>[t/2,e],f=(t,e)=>[t/2,0];break;case"bottomLeft":m=!0,g=(t,e)=>[0,e],f=(t,e)=>[t,0];break;case"middleLeft":b=!0,g=(t,e)=>[0,e/2],f=(t,e)=>[t,e/2]}const v=g(a,o),w=f(a,o);let y=u(...w);const A=d(n+y[0]),_=d(r+y[1]);let x,S,C=1,E=1;if(e.fromKeyboard)({deltaX:x,deltaY:S}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#se;[x,S]=this.screenToPageTranslation(t-s,i-n),this.#se[0]=t,this.#se[1]=i}var P,T;if([x,S]=(P=x/i,T=S/s,[p[0]*P+p[2]*T,p[1]*P+p[3]*T]),m){const t=Math.hypot(a,o);C=E=Math.max(Math.min(Math.hypot(w[0]-v[0]-x,w[1]-v[1]-S)/t,1/a,1/o),l/a,h/o)}else b?C=Math.max(l,Math.min(1,Math.abs(w[0]-v[0]-x)))/a:E=Math.max(h,Math.min(1,Math.abs(w[1]-v[1]-S)))/o;const M=d(a*C),k=d(o*E);y=u(...f(M,k));const L=A-y[0],I=_-y[1];this.#le||=[this.x,this.y,this.width,this.height],this.width=M,this.height=k,this.x=L,this.y=I,this.setDims(i*M,s*k),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#de||(this._editToolbar=new ye(this),this.div.append(this._editToolbar.render()),this.#o&&await this._editToolbar.addAltText(this.#o)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#o?.destroy())}addContainer(t){const e=this._editToolbar?.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#o||(Me.initialize(ke._l10n),this.#o=new Me(this),this.#Yt&&(this.#o.data=this.#Yt,this.#Yt=null),await this.addEditToolbar())}get altTextData(){return this.#o?.data}set altTextData(t){this.#o&&(this.#o.data=t)}get guessedAltText(){return this.#o?.guessedText}async setGuessedAltText(t){await(this.#o?.setGuessedText(t))}serializeAltText(t){return this.#o?.serialize(t)}hasAltText(){return!!this.#o&&!this.#o.isEmpty()}hasAltTextData(){return this.#o?.hasData()??!1}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.tabIndex=this.#Jt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#Pe();const[t,e]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[i,s]=this.getInitialTranslation();return this.translate(i,s),_e(this,this.div,["pointerdown"]),this._uiManager._editorUndoBar?.hide(),this.div}pointerdown(t){const{isMac:e}=Ot.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#oe=!0,this._isDraggable?this.#Te(t):this.#Me(t))}get isSelected(){return this._uiManager.isSelected(this)}#Me(t){const{isMac:e}=Ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#Te(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();const i=new AbortController,s=this._uiManager.combinedSignal(i),n={capture:!0,passive:!1,signal:s},r=t=>{i.abort(),this.#Zt=null,this.#oe=!1,this._uiManager.endDragSession()||this.#Me(t)};e&&(this.#pe=t.clientX,this.#ge=t.clientY,this.#Zt=t.pointerId,this.#te=t.pointerType,window.addEventListener("pointermove",(t=>{const{clientX:e,clientY:i,pointerId:s}=t;if(s!==this.#Zt)return void ce(t);const[n,r]=this.screenToPageTranslation(e-this.#pe,i-this.#ge);this.#pe=e,this.#ge=i,this._uiManager.dragSelectedEditors(n,r)}),n),window.addEventListener("touchmove",ce,n),window.addEventListener("pointerdown",(t=>{t.isPrimary&&t.pointerType===this.#te&&r(t),ce(t)}),n)),this._onStartDragging();const a=t=>{if(!this.#Zt||this.#Zt===t.pointerId)return r(t),void this._onStopDragging();ce(t)};window.addEventListener("pointerup",a,{signal:s}),window.addEventListener("blur",a,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#ue&&clearTimeout(this.#ue),this.#ue=setTimeout((()=>{this.#ue=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const s=this.parentScale,[n,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*r,u=this.width*n,p=this.height*r;switch(i){case 0:return[d+l+a,r-c-h-p+o,d+l+u+a,r-c-h+o];case 90:return[d+h+a,r-c+l+o,d+h+p+a,r-c+l+u+o];case 180:return[d-l-u+a,r-c+h+o,d-l+a,r-c+h+p+o];case 270:return[d-h-p+a,r-c-l-u+o,d-h+a,r-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,r]=t,a=n-i,o=r-s;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-s,o,a];case 180:return[n,e-s,a,o];case 270:return[n,e-r,o,a];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#de=!0}disableEditMode(){this.#de=!1}isInEditMode(){return this.#de}shouldGetKeyboardEvents(){return this.#ce}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:s}=this.getClientDimensions(),{innerHeight:n,innerWidth:r}=window;return e<r&&s>0&&t<n&&i>0}#Pe(){if(this.#re||!this.div)return;this.#re=new AbortController;const t=this._uiManager.combinedSignal(this.#re);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#Pe()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){_t("An editor must be serializable")}static async deserialize(t,e,i){const s=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i});s.rotation=t.rotation,s.#Yt=t.accessibilityData;const[n,r]=s.pageDimensions,[a,o,l,h]=s.getRectInCurrentCoords(t.rect,r);return s.x=a/n,s.y=o/r,s.width=l/n,s.height=h/r,s}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#re?.abort(),this.#re=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#ue&&(clearTimeout(this.#ue),this.#ue=null),this.#ve(),this.removeEditToolbar(),this.#fe){for(const t of this.#fe.values())clearTimeout(t);this.#fe=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_e(),this.#ie.classList.remove("hidden"),_e(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#ne={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#ie.children;if(!this.#Qt){this.#Qt=Array.from(e);const t=this.#ke.bind(this),i=this.#Le.bind(this),s=this._uiManager._signal;for(const e of this.#Qt){const n=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:s}),e.addEventListener("blur",i,{signal:s}),e.addEventListener("focus",this.#Ie.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",ke._l10nResizer[n])}}const i=this.#Qt[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#Qt.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#ie.append(this.#ie.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#ie.firstChild.before(this.#ie.lastChild);let t=0;for(const i of e){const e=this.#Qt[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ke._l10nResizer[e])}}this.#De(0),this.#ce=!0,this.#ie.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#ke(t){ke._resizerKeyboardManager.exec(this,t)}#Le(t){this.#ce&&t.relatedTarget?.parentNode!==this.#ie&&this.#ve()}#Ie(t){this.#ae=this.#ce?t:""}#De(t){if(this.#Qt)for(const e of this.#Qt)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#ce&&this.#Se(this.#ae,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ve(){this.#ce=!1,this.#De(-1),this.#Ce()}_stopResizingWithKeyboard(){this.#ve(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#o?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#ie?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#o?.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#he}set isEditing(t){this.#he=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ee=!0;const i=t/e,{style:s}=this.div;s.aspectRatio=i,s.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){this.#fe||=new Map;const{action:e}=t;let i=this.#fe.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#fe.delete(e),0===this.#fe.size&&(this.#fe=null)}),ke._telemetryTimeout),void this.#fe.set(e,i)}t.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),this.#Jt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Jt=!0}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===e?.nodeName&&e.classList.contains("annotationContent")&&e.remove()}}class Le extends ke{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ie=3285377520,De=4294901760,Re=65535;class Ne{constructor(t){this.h1=t?4294967295&t:Ie,this.h2=t?4294967295&t:Ie}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let s=0,n=t.length;s<n;s++){const n=t.charCodeAt(s);n<=255?e[i++]=n:(e[i++]=n>>>8,e[i++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const s=i>>2,n=i-4*s,r=new Uint32Array(e.buffer,0,s);let a=0,o=0,l=this.h1,h=this.h2;const d=3432918353,c=461845907,u=11601,p=13715;for(let t=0;t<s;t++)1&t?(a=r[t],a=a*d&De|a*u&Re,a=a<<15|a>>>17,a=a*c&De|a*p&Re,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&De|o*u&Re,o=o<<15|o>>>17,o=o*c&De|o*p&Re,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,n){case 3:a^=e[4*s+2]<<16;case 2:a^=e[4*s+1]<<8;case 1:a^=e[4*s],a=a*d&De|a*u&Re,a=a<<15|a>>>17,a=a*c&De|a*p&Re,1&s?l^=a:h^=a}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&De|36045*t&Re,e=4283543511*e&De|(2950163797*(e<<16|t>>>16)&De)>>>16,t^=e>>>1,t=444984403*t&De|60499*t&Re,e=3301882366*e&De|(3120437893*(e<<16|t>>>16)&De)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Fe=Object.freeze({map:null,hash:"",transfer:void 0});class Oe{#Re=!1;#Ne=null;#Fe=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Fe.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Fe.get(t)}remove(t){if(this.#Fe.delete(t),0===this.#Fe.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Fe.values())if(t instanceof ke)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Fe.get(t);let s=!1;if(void 0!==i)for(const[t,n]of Object.entries(e))i[t]!==n&&(s=!0,i[t]=n);else s=!0,this.#Fe.set(t,e);s&&this.#Oe(),e instanceof ke&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Fe.has(t)}getAll(){return this.#Fe.size>0?Ft(this.#Fe):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Fe.size}#Oe(){this.#Re||(this.#Re=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Re&&(this.#Re=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Be(this)}get serializable(){if(0===this.#Fe.size)return Fe;const t=new Map,e=new Ne,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Fe){const a=r instanceof ke?r.serialize(!1,s):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),n||=!!a.bitmap)}if(n)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Fe}get editorStats(){let t=null;const e=new Map;for(const i of this.#Fe.values()){if(!(i instanceof ke))continue;const s=i.telemetryFinalData;if(!s)continue;const{type:n}=s;e.has(n)||e.set(n,Object.getPrototypeOf(i).constructor),t||=Object.create(null);const r=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=r.get(t);i||(i=new Map,r.set(t,i));const s=i.get(e)??0;i.set(e,s+1)}}for(const[i,s]of e)t[i]=s.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#Ne=null}get modifiedIds(){if(this.#Ne)return this.#Ne;const t=[];for(const e of this.#Fe.values())e instanceof ke&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Ne={ids:new Set(t),hash:t.join(",")}}}class Be extends Oe{#Be;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#Be={map:n,hash:i,transfer:s}}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Be}get modifiedIds(){return Ct(this,"modifiedIds",{ids:new Set,hash:""})}}class je{#je=new Set;constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){this._document=t,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(t){this.nativeFontFaces.add(t),this._document.fonts.add(t)}removeNativeFontFace(t){this.nativeFontFaces.delete(t),this._document.fonts.delete(t)}insertRule(t){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const e=this.styleElement.sheet;e.insertRule(t,e.cssRules.length)}clear(){for(const t of this.nativeFontFaces)this._document.fonts.delete(t);this.nativeFontFaces.clear(),this.#je.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#je.has(t.loadedName))if(xt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,r=new FontFace(i,s,n);this.addNativeFontFace(r);try{await r.load(),this.#je.add(i),e?.(t)}catch{At(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}}else _t("Not implemented: loadSystemFont without the Font Loading API.")}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void await this.loadSystemFont(t);if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(i){throw At(`Failed to load font '${e.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise((e=>{const i=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,i)}))}}get isFontLoadingAPISupported(){return Ct(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(_||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),Ct(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(xt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(i),i}get _loadTestFont(){return Ct(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function i(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function s(t,e,i,s){return t.substring(0,e)+s+t.substring(e+i)}let n,r;const a=this._document.createElement("canvas");a.width=1,a.height=1;const o=a.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let d=this._loadTestFont;d=s(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(n=0,r=h.length-3;n<r;n+=4)u=u-c+i(h,n)|0;var p;n<h.length&&(u=u-c+i(h+"XXX",n)|0),d=s(d,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(d)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,f.append(t)}this._document.body.append(f),function t(e,i){if(++l>30)return At("Load test font never loaded."),void i();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?i():setTimeout(t.bind(null,e,i))}(h,(()=>{f.remove(),e.complete()}))}}class Ve{constructor(t,{disableFontFace:e=!1,inspectFont:i=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this._inspectFont=i}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let t;if(this.cssFontInfo){const e={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(e.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,e)}else t=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),t}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${e=this.data,Uint8Array.prototype.toBase64?e.toBase64():btoa(Rt(e))});`;var 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}}`;return this._inspectFont?.(this,t),i}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];let i;try{i=t.get(this.loadedName+"_path_"+e)}catch(t){At(`getPathGenerator - ignoring character: "${t}".`)}if(!Array.isArray(i)||0===i.length)return this.compiledGlyphs[e]=function(t,e){};const s=[];for(let t=0,e=i.length;t<e;)switch(i[t++]){case Ut:{const[e,n,r,a,o,l]=i.slice(t,t+6);s.push((t=>t.bezierCurveTo(e,n,r,a,o,l))),t+=6}break;case Wt:{const[e,n]=i.slice(t,t+2);s.push((t=>t.moveTo(e,n))),t+=2}break;case Gt:{const[e,n]=i.slice(t,t+2);s.push((t=>t.lineTo(e,n))),t+=2}break;case qt:{const[e,n,r,a]=i.slice(t,t+4);s.push((t=>t.quadraticCurveTo(e,n,r,a))),t+=4}break;case Xt:s.push((t=>t.restore()));break;case Kt:s.push((t=>t.save()));break;case Yt:xt(2===s.length,"Scale command is only valid at the third position.");break;case Qt:{const[e,n,r,a,o,l]=i.slice(t,t+6);s.push((t=>t.transform(e,n,r,a,o,l))),t+=6}break;case Jt:{const[e,n]=i.slice(t,t+2);s.push((t=>t.translate(e,n))),t+=2}}return s.push((t=>t.closePath())),this.compiledGlyphs[e]=function(t,e){s[0](t),s[1](t),t.scale(e,-e);for(let e=2,i=s.length;e<i;e++)s[e](t)}}}class He{#Ve=!1;constructor({enableHWA:t=!1}){this.#Ve=t}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!this.#Ve})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){_t("Abstract method `_createCanvas` called.")}}class ze{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then((t=>({cMapData:t,isCompressed:this.isCompressed}))).catch((t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)}))}async _fetch(t){_t("Abstract method `_fetch` called.")}}class $e extends ze{async _fetch(t){const e=await ee(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Nt(e)}}class Ue{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,s,n){return"none"}destroy(t=!1){}}class We{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch((t=>{throw new Error(`Unable to load font data at: ${e}`)}))}async _fetch(t){_t("Abstract method `_fetch` called.")}}class Ge extends We{async _fetch(t){const e=await ee(t,"arraybuffer");return new Uint8Array(e)}}async function qe(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}const Xe="Fill",Ke="Stroke",Ye="Shading";function Qe(t,e){if(!e)return;const i=e[2]-e[0],s=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],i,s),t.clip(n)}class Je{getPattern(){_t("Abstract method `getPattern` called.")}}class Ze extends Je{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const t of this._colorStops)e.addColorStop(t[0],t[1]);return e}getPattern(t,e,i,s){let n;if(s===Ke||s===Xe){const r=e.current.getClippedPathBoundingBox(s,me(t))||[0,0,0,0],a=Math.ceil(r[2]-r[0])||1,o=Math.ceil(r[3]-r[1])||1,l=e.cachedCanvases.getCanvas("pattern",a,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-r[0],-r[1]),i=jt.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Qe(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(i);n.setTransform(d)}else Qe(t,this._bbox),n=this._createGradient(t);return n}}function ti(t,e,i,s,n,r,a,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.width;let u;l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=a,a=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=r,r=a,a=u);const p=(l[i]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,f=(l[s]+e.offsetX)*e.scaleX,m=(l[s+1]+e.offsetY)*e.scaleY,b=(l[n]+e.offsetX)*e.scaleX,v=(l[n+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[r],y=h[r+1],A=h[r+2],_=h[a],x=h[a+1],S=h[a+2],C=h[o],E=h[o+1],P=h[o+2],T=Math.round(g),M=Math.round(v);let k,L,I,D,R,N,F,O;for(let t=T;t<=M;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);k=p-(p-f)*e,L=w-(w-_)*e,I=y-(y-x)*e,D=A-(A-S)*e}else{let e;e=t>v?1:m===v?0:(m-t)/(m-v),k=f-(f-b)*e,L=_-(_-C)*e,I=x-(x-E)*e,D=S-(S-P)*e}let e;e=t<g?0:t>v?1:(g-t)/(g-v),R=p-(p-b)*e,N=w-(w-C)*e,F=y-(y-E)*e,O=A-(A-P)*e;const i=Math.round(Math.min(k,R)),s=Math.round(Math.max(k,R));let n=c*t+4*i;for(let t=i;t<=s;t++)e=(k-t)/(k-R),e<0?e=0:e>1&&(e=1),d[n++]=L-(L-N)*e|0,d[n++]=I-(I-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function ei(t,e,i){const s=e.coords,n=e.colors;let r,a;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)ti(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),ti(t,i,s[e+o+1],s[e+1],s[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)ti(t,i,s[r],s[r+1],s[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class ii extends Je{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[7],this._background=t[8],this.matrix=null}_createMeshCanvas(t,e,i){const s=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),r=Math.ceil(this._bounds[2])-s,a=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(r*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(a*t[1]*1.1)),3e3),h=r/o,d=a/l,c={coords:this._coords,colors:this._colors,offsetX:-s,offsetY:-n,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let i=0,s=t.length;i<s;i+=4)t[i]=e[0],t[i+1]=e[1],t[i+2]=e[2],t[i+3]=255}for(const t of this._figures)ei(m,t,c);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:s-2*h,offsetY:n-2*d,scaleX:h,scaleY:d}}getPattern(t,e,i,s){let n;if(Qe(t,this._bbox),s===Ye)n=jt.singularValueDecompose2dScale(me(t));else if(n=jt.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=jt.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const r=this._createMeshCanvas(n,s===Ye?null:this._background,e.cachedCanvases);return s!==Ye&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class si extends Je{getPattern(){return"hotpink"}}const ni=1,ri=2;class ai{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,s,n){this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.color=e,this.ctx=i,this.canvasGraphicsFactory=s,this.baseTransform=n}createPatternCanvas(t){const{bbox:e,operatorList:i,paintType:s,tilingType:n,color:r,canvasGraphicsFactory:a}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),yt("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=jt.singularValueDecompose2dScale(this.matrix),m=jt.singularValueDecompose2dScale(this.baseTransform),b=f[0]*m[0],v=f[1]*m[1];let w=p,y=g,A=!1,_=!1;const x=Math.ceil(o*b),S=Math.ceil(l*v);x>=Math.ceil(p*b)?w=o:A=!0,S>=Math.ceil(g*v)?y=l:_=!0;const C=this.getSizeAndScale(w,this.ctx.canvas.width,b),E=this.getSizeAndScale(y,this.ctx.canvas.height,v),P=t.cachedCanvases.getCanvas("pattern",C.size,E.size),T=P.context,M=a.createCanvasGraphics(T);if(M.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(M,s,r),T.translate(-C.scale*h,-E.scale*d),M.transform(C.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(M,h,d,c,u),M.baseTransform=me(M.ctx),M.executeOperatorList(i),M.endDrawing(),T.restore(),A||_){const e=P.canvas;A&&(w=o),_&&(y=l);const i=this.getSizeAndScale(w,this.ctx.canvas.width,b),s=this.getSizeAndScale(y,this.ctx.canvas.height,v),n=i.size,r=s.size,a=t.cachedCanvases.getCanvas("pattern-workaround",n,r),c=a.context,u=A?Math.floor(p/o):0,f=_?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let i=0;i<=f;i++)c.drawImage(e,n*t,r*i,n,r,0,0,n,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:s.scale,offsetX:h,offsetY:d}}return{canvas:P.canvas,scaleX:C.scale,scaleY:E.scale,offsetX:h,offsetY:d}}getSizeAndScale(t,e,i){const s=Math.max(ai.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*i);return n>=s?n=s:i=n/t,{scale:i,size:n}}clipBbox(t,e,i,s,n){const r=s-e,a=n-i;t.ctx.rect(e,i,r,a),t.current.updateRectMinMax(me(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case ni:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case ri:const r=jt.makeHexColor(i[0],i[1],i[2]);s.fillStyle=r,s.strokeStyle=r,n.fillColor=r,n.strokeColor=r;break;default:throw new It(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==Ye&&(n=jt.transform(n,e.baseTransform),this.matrix&&(n=jt.transform(n,this.matrix)));const r=this.createPatternCanvas(e);let a=new DOMMatrix(n);a=a.translate(r.offsetX,r.offsetY),a=a.scale(1/r.scaleX,1/r.scaleY);const o=t.createPattern(r.canvas,"repeat");return o.setTransform(a),o}}function oi({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Ot.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],d=s>>3,c=7&s,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let s=0;s<n;s++){for(const s=e+d;e<s;e++){const s=e<u?t[e]:255;i[p++]=128&s?h:l,i[p++]=64&s?h:l,i[p++]=32&s?h:l,i[p++]=16&s?h:l,i[p++]=8&s?h:l,i[p++]=4&s?h:l,i[p++]=2&s?h:l,i[p++]=1&s?h:l}if(0===c)continue;const s=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=s&1<<7-t?h:l}return{srcPos:e,destPos:p}}const li=16;class hi{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let s;return void 0!==this.cache[t]?(s=this.cache[t],this.canvasFactory.reset(s,e,i)):(s=this.canvasFactory.create(e,i),this.cache[t]=s),s}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function di(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,f]=me(t);if(0===c&&0===u){const m=a*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(a+l)*d+g,A=Math.abs(Math.round(y)-b)||1,_=(o+h)*p+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,s,n,r,0,0,A,x),t.setTransform(d,c,u,p,g,f),[A,x]}if(0===d&&0===p){const m=o*u+g,b=Math.round(m),v=a*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(a+l)*c+f,x=Math.abs(Math.round(_)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,s,n,r,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class ci{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=x,this.textMatrixScale=1,this.fontMatrix=S,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=B,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,i){[e,i]=jt.applyTransform([e,i],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,i),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,i)}updateRectMinMax(t,e){const i=jt.applyTransform(e,t),s=jt.applyTransform(e.slice(2),t),n=jt.applyTransform([e[0],e[3]],t),r=jt.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],r[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],r[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],r[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],r[1])}updateScalingPathMinMax(t,e){jt.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,i,s,n,r,a,o,l,h){const d=jt.bezierBoundingBox(e,i,s,n,r,a,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Xe,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ke){e||_t("Stroke bounding box must include transform.");const t=jt.singularValueDecompose2dScale(e),s=t[0]*this.lineWidth/2,n=t[1]*this.lineWidth/2;i[0]-=s,i[1]-=n,i[2]+=s,i[3]+=n}return i}updateClipFromPath(){const t=jt.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Xe,e=null){return jt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ui(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%li,r=(i-n)/li,a=0===n?r:r+1,o=t.createImageData(s,li);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===U.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),f=i.length,m=s+7>>3,b=4294967295,v=Ot.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?li:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const r=t>m?s:8*t-7,a=-8&r;let o=0,c=0;for(;n<a;n+=8)c=d[h++],i[l++]=128&c?b:v,i[l++]=64&c?b:v,i[l++]=32&c?b:v,i[l++]=16&c?b:v,i[l++]=8&c?b:v,i[l++]=4&c?b:v,i[l++]=2&c?b:v,i[l++]=1&c?b:v;for(;n<r;n++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<f;)i[l++]=0;t.putImageData(o,0,u*li)}}else if(e.kind===U.RGBA_32BPP){for(p=0,f=s*li*4,u=0;u<r;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=li;u<a&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==U.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=li,f=s*g,u=0;u<a;u++){for(u>=r&&(g=n,f=s*g),l=0,p=f;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*li)}}}function pi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%li,r=(i-n)/li,a=0===n?r:r+1,o=t.createImageData(s,li);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?li:n;({srcPos:l}=oi({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*li)}}function gi(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of i)void 0!==t[s]&&(e[s]=t[s]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function fi(t){if(t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0),!_){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function mi(t,e){if(e)return!0;const i=jt.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*te.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const bi=["butt","round","square"],vi=["miter","round","bevel"],wi={},yi={};class Ai{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new ci(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=s,this.filterFactory=n,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=a||[],this.optionalContentConfig=r,this.cachedCanvases=new hi(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(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:s=null}){const n=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",n,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...me(this.compositeCtx))}this.ctx.save(),fi(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=me(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,r=t.fnArray;let a=e||0;const o=n.length;if(o===a)return a;const l=o-a>10&&"function"==typeof i,h=l?Date.now()+15:0;let d=0;const c=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==s&&a===s.nextBreakPoint)return s.breakIt(a,i),a;if(p=r[a],p!==ft.dependency)this[p].apply(this,n[a]);else for(const t of n[a]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),a}if(a++,a===o)return a;if(l&&++d>10){if(Date.now()>h)return i(),a;d=0}}}#He(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),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.#He(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),this.#ze()}#ze(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}}_scaleImage(t,e){const i=t.width??t.displayWidth,s=t.height??t.displayHeight;let n,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=s,d="prescale1";for(;a>2&&l>1||o>2&&h>1;){let e=l,i=h;a>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),a/=l/e),o>2&&h>1&&(i=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/i),n=this.cachedCanvases.getCanvas(d,e,i),r=n.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=n.canvas,l=e,h=i,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:i,height:s}=t,n=this.current.fillColor,r=this.current.patternFill,a=me(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(r?a:[a.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const i=o.get(l);if(i&&!r){return{canvas:i,offsetX:Math.round(Math.min(a[0],a[2])+a[4]),offsetY:Math.round(Math.min(a[1],a[3])+a[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),pi(d.context,t));let c=jt.transform(a,[1/i,0,0,-1/s,0,0]);c=jt.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=jt.getAxialAlignedBoundingBox([0,0,i,s],c),m=Math.round(g-u)||1,b=Math.round(f-p)||1,v=this.cachedCanvases.getCanvas("fillCanvas",m,b),w=v.context,y=u,A=p;w.translate(-y,-A),w.transform(...c),h||(h=this._scaleImage(d.canvas,be(w)),h=h.img,o&&r&&o.set(l,h)),w.imageSmoothingEnabled=mi(me(w),t.interpolate),di(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=jt.transform(be(w),[1,0,0,1,-y,-A]);return w.fillStyle=r?n.getPattern(e,this,_,Xe):n,w.fillRect(0,0,i,s),o&&!r&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,v.canvas)),{canvas:v.canvas,offsetX:Math.round(y),offsetY:Math.round(A)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=bi[t]}setLineJoin(t){this.ctx.lineJoin=vi[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const i=this.ctx;void 0!==i.setLineDash&&(i.setLineDash(t),i.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,i]of t)switch(e){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 t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(i,t,e);this.suspendedCtx=this.ctx,this.ctx=s.context;const n=this.ctx;n.setTransform(...me(this.suspendedCtx)),gi(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,i){e.translate(t,i),this.__originalTranslate(t,i)},t.scale=function(t,i){e.scale(t,i),this.__originalScale(t,i)},t.transform=function(t,i,s,n,r,a){e.transform(t,i,s,n,r,a),this.__originalTransform(t,i,s,n,r,a)},t.setTransform=function(t,i,s,n,r,a){e.setTransform(t,i,s,n,r,a),this.__originalSetTransform(t,i,s,n,r,a)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,i){e.moveTo(t,i),this.__originalMoveTo(t,i)},t.lineTo=function(t,i){e.lineTo(t,i),this.__originalLineTo(t,i)},t.bezierCurveTo=function(t,i,s,n,r,a){e.bezierCurveTo(t,i,s,n,r,a),this.__originalBezierCurveTo(t,i,s,n,r,a)},t.rect=function(t,i,s,n){e.rect(t,i,s,n),this.__originalRect(t,i,s,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,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(),gi(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,s){const n=s[0],r=s[1],a=s[2]-n,o=s[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,n,r,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,s,n,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r){const e=jt.makeHexColor(...r);if(u<0||p<0||u+i>c.width||p+s>c.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,s),n=t.context;n.drawImage(c,-u,-p),n.globalCompositeOperation="destination-atop",n.fillStyle=e,n.fillRect(0,0,i,s),n.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const n=new Path2D;n.rect(u,p,i,s),t.clip(n),t.globalCompositeOperation="destination-atop",t.fillStyle=e,t.fillRect(u,p,i,s),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,s),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,s,o,l,i,s),e.restore()}save(){this.inSMaskMode?(gi(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),gi(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,i,s,n,r){this.ctx.transform(t,e,i,s,n,r),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let r,a,o=n.x,l=n.y;const h=me(s),d=0===h[0]&&0===h[3]||0===h[1]&&0===h[2],c=d?i.slice(0):null;for(let i=0,u=0,p=t.length;i<p;i++)switch(0|t[i]){case ft.rectangle:o=e[u++],l=e[u++];const t=e[u++],i=e[u++],p=o+t,g=l+i;s.moveTo(o,l),0===t||0===i?s.lineTo(p,g):(s.lineTo(p,l),s.lineTo(p,g),s.lineTo(o,g)),d||n.updateRectMinMax(h,[o,l,p,g]),s.closePath();break;case ft.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case ft.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case ft.curveTo:r=o,a=l,o=e[u+4],l=e[u+5],s.bezierCurveTo(e[u],e[u+1],e[u+2],e[u+3],o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case ft.curveTo2:r=o,a=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,r,a,o,l,e[u],e[u+1],e[u+2],e[u+3],c),o=e[u+2],l=e[u+3],u+=4;break;case ft.curveTo3:r=o,a=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,r,a,e[u],e[u+1],o,l,o,l,c),u+=4;break;case ft.closePath:s.closePath()}d&&n.updateScalingPathMinMax(h,c),n.setCurrentPoint(o,l)}closePath(){this.ctx.closePath()}stroke(t=!0){const e=this.ctx,i=this.current.strokeColor;e.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof i&&i?.getPattern?(e.save(),e.strokeStyle=i.getPattern(e,this,be(e),Ke),this.rescaleAndStroke(!1),e.restore()):this.rescaleAndStroke(!0)),t&&this.consumePath(this.current.getClippedPathBoundingBox()),e.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(t=!0){const e=this.ctx,i=this.current.fillColor;let s=!1;this.current.patternFill&&(e.save(),e.fillStyle=i.getPattern(e,this,be(e),Xe),s=!0);const n=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==n&&(this.pendingEOFill?(e.fill("evenodd"),this.pendingEOFill=!1):e.fill()),s&&e.restore(),t&&this.consumePath(n)}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=wi}eoClip(){this.pendingClip=yi}beginText(){this.current.textMatrix=x,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0!==t){e.save(),e.beginPath();for(const i of t)e.setTransform(...i.transform),e.translate(i.x,i.y),i.addToPath(e,i.fontSize);e.restore(),e.clip(),e.beginPath(),delete this.pendingTextPaths}else e.beginPath()}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){const i=this.commonObjs.get(t),s=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(s.fontMatrix=i.fontMatrix||S,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||At("Invalid font matrix for font "+t),e<0?(e=-e,s.fontDirection=-1):s.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const n=i.loadedName||"sans-serif",r=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let a="normal";i.black?a="900":i.bold&&(a="bold");const o=i.italic?"italic":"normal";let l=e;e<16?l=16:e>100&&(l=100),this.current.fontSizeScale=e/l,this.ctx.font=`${o} ${a} ${l}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,i,s,n,r){this.current.textMatrix=[t,e,i,s,n,r],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,i,s,n){const r=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&z,c=!!(l&$),u=a.patternFill&&!o.missingFile,p=a.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p?(r.save(),r.translate(e,i),r.beginPath(),g(r,h),d!==B&&d!==V||(s&&r.setTransform(...s),r.fill()),d!==j&&d!==V||(n&&r.setTransform(...n),r.stroke()),r.restore()):(d!==B&&d!==V||r.fillText(t,e,i),d!==j&&d!==V||r.strokeText(t,e,i)),c){(this.pendingTextPaths||=[]).push({transform:me(r),x:e,y:i,fontSize:h,addToPath:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let t=3;t<e.length;t+=4)if(e[t]>0&&e[t]<255){i=!0;break}return Ct(this,"isFontSubpixelAAEnabled",i)}showText(t){const e=this.current,i=e.font;if(i.isType3Font)return this.showType3Text(t);const s=e.fontSize;if(0===s)return;const n=this.ctx,r=e.fontSizeScale,a=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,d=t.length,c=i.vertical,u=c?1:-1,p=i.defaultVMetrics,g=s*e.fontMatrix[0],f=e.textRenderingMode===B&&!i.disableFontFace&&!e.patternFill;let m,b;if(n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,be(n),Xe);m=me(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,be(n),Ke);b=me(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&z;t!==j&&t!==V||(v=this.getSinglePixelWidth())}else v/=w;if(1!==r&&(n.scale(r,r),v/=r),n.lineWidth=v,i.isInvalidPDFjsFont){const i=[];let s=0;for(const e of t)i.push(e.unicode),s+=e.width;return n.fillText(i.join(""),0,0),e.x+=s*g*h,n.restore(),void this.compose()}let y,A=0;for(y=0;y<d;++y){const e=t[y];if("number"==typeof e){A+=u*e*s/1e3;continue}let h=!1;const d=(e.isSpace?o:0)+a,v=e.fontChar,w=e.accent;let _,x,S=e.width;if(c){const t=e.vmetric||p,i=-(e.vmetric?t[1]:.5*S)*g,s=t[2]*g;S=t?-t[0]:S,_=i/r,x=(A+s)/r}else _=A/r,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*r;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),_/=e}else S!==t&&(_+=(S-t)/2e3*s/r)}if(this.contentVisible&&(e.isInFont||i.missingFile))if(f&&!w)n.fillText(v,_,x);else if(this.paintChar(v,_,x,m,b),w){const t=_+s*w.offset.x/r,e=x-s*w.offset.y/r;this.paintChar(w.fontChar,t,e,m,b)}A+=c?S*g-d*l:S*g+d*l,h&&n.restore()}c?e.y-=A:e.x+=A*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,i=this.current,s=i.font,n=i.fontSize,r=i.fontDirection,a=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,h=i.textHScale*r,d=i.fontMatrix||S,c=t.length;let u,p,g,f;if(!(i.textRenderingMode===H)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(h,r),u=0;u<c;++u){if(p=t[u],"number"==typeof p){f=a*p*n/1e3,this.ctx.translate(f,0),i.x+=f*h;continue}const r=(p.isSpace?l:0)+o,c=s.charProcOperatorList[p.operatorListId];if(!c){At(`Type3 character "${p.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=p,this.save(),e.scale(n,n),e.transform(...d),this.executeOperatorList(c),this.restore());g=jt.applyTransform([p.width,0],d)[0]*n+r,e.translate(g,0),i.x+=g*h}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,r){this.ctx.rect(i,s,n-i,r-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||me(this.ctx),n={createCanvasGraphics:t=>new Ai(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new ai(t,i,this.ctx,n,s)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,i){this.ctx.strokeStyle=this.current.strokeColor=jt.makeHexColor(t,e,i),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e,i){this.ctx.fillStyle=this.current.fillColor=jt.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new Ze(t);case"Mesh":return new ii(t);case"Dummy":return new si}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t)),this.cachedPatterns.set(t,i)),e&&(i.matrix=e),i}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const i=this._getPattern(t);e.fillStyle=i.getPattern(e,this,be(e),Ye);const s=be(e);if(s){const{width:t,height:i}=e.canvas,[n,r,a,o]=jt.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,r,a-n,o-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=me(this.ctx),e)){const t=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],t,i),this.current.updateRectMinMax(me(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||yt("TODO: Support non-isolated groups."),t.knockout&&At("Knockout groups not supported.");const i=me(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=jt.getAxialAlignedBoundingBox(t.bbox,me(e));const n=[0,0,e.canvas.width,e.canvas.height];s=jt.intersect(s,n)||[0,0,0,0];const r=Math.floor(s[0]),a=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-r,1),l=Math.max(Math.ceil(s[3])-a,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const d=this.cachedCanvases.getCanvas(h,o,l),c=d.context;c.translate(-r,-a),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:r,offsetY:a,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(r,a),e.save()),gi(e,c),this.ctx=c,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const t=me(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=jt.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(i)}}beginAnnotation(t,e,i,s,n){if(this.#He(),fi(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],r=e[3]-e[1];if(n&&this.annotationCanvasMap){(i=i.slice())[4]-=e[0],i[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=s,e[3]=r;const[n,a]=jt.singularValueDecompose2dScale(me(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(r*this.outputScaleY*o);this.annotationCanvas=this.canvasFactory.create(l,h);const{canvas:d,context:c}=this.annotationCanvas;this.annotationCanvasMap.set(t,d),this.annotationCanvas.savedCtx=this.ctx,this.ctx=c,this.ctx.save(),this.ctx.setTransform(n,0,0,-a,0,r*a),fi(this.ctx)}else fi(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new ci(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#ze(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;(t=this.getObject(t.data,t)).count=e;const i=this.ctx,s=this.processingType3;if(s&&(void 0===s.compiled&&(s.compiled=function(t){const{width:e,height:i}=t;if(e>1e3||i>1e3)return null;const s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=e+1;let r,a,o,l=new Uint8Array(n*(i+1));const h=e+7&-8;let d=new Uint8Array(h*i),c=0;for(const e of t.data){let t=128;for(;t>0;)d[c++]=e&t?0:255,t>>=1}let u=0;for(c=0,0!==d[c]&&(l[0]=1,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[a]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[a]=2,++u),r=1;r<i;r++){c=r*h,o=r*n,d[c-h]!==d[c]&&(l[o]=d[c]?1:8,++u);let t=(d[c]?4:0)+(d[c-h]?8:0);for(a=1;a<e;a++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+a]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+a]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=r*n,0!==d[c]&&(l[o]=8,++u),a=1;a<e;a++)d[c]!==d[c+1]&&(l[o+a]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+a]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(r=0;u&&r<=i;r++){let t=r*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,r);const s=t;let a=l[t];do{const e=p[a];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(a=i,l[t]=0):(a=i&51*a>>4,l[t]&=a>>2|a<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--r}return d=null,l=null,function(t){t.save(),t.scale(1/e,-1/i),t.translate(0,-i),t.fill(g),t.beginPath(),t.restore()}}(t)),s.compiled))return void s.compiled(i);const n=this._createMaskCanvas(t),r=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(r,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,r){if(!this.contentVisible)return;t=this.getObject(t.data,t);const a=this.ctx;a.save();const o=me(a);a.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);a.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=r.length;t<h;t+=2){const h=jt.transform(o,[e,i,s,n,r[t],r[t+1]]),[d,c]=jt.applyTransform([0,0],h);a.drawImage(l.canvas,d,c)}a.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,i=this.current.fillColor,s=this.current.patternFill;for(const n of t){const{data:t,width:r,height:a,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",r,a),h=l.context;h.save();pi(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,be(e),Xe):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),di(e,l.canvas,0,0,r,a,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):At("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void At("Dependent image isn't ready yet");const r=n.width,a=n.height,o=[];for(let t=0,n=s.length;t<n;t+=2)o.push({transform:[e,0,0,i,s[t],s[t+1]],x:0,y:0,w:r,h:a});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:i,height:s}=t,n=this.cachedCanvases.getCanvas("inlineImage",i,s),r=n.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!_){const{filter:t}=s;"none"!==t&&""!==t&&(s.filter="none")}let n;if(s.scale(1/e,-1/i),t.bitmap)n=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)n=t;else{const s=this.cachedCanvases.getCanvas("inlineImage",e,i).context;ui(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,be(s));s.imageSmoothingEnabled=mi(me(s),t.interpolate),di(s,r.img,0,0,r.paintWidth,r.paintHeight,0,-i,e,i),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx;let s;if(t.bitmap)s=t.bitmap;else{const e=t.width,i=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,i).context;ui(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),di(i,s,t.x,t.y,t.w,t.h,0,-1,1,1),i.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t){const e=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(t);const i=this.ctx;this.pendingClip&&(e||(this.pendingClip===yi?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=me(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),s=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,s)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:s,d:n}=this.ctx.getTransform();let r,a;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)r=a=1/i;else{const e=i*t;r=a=e<1?1/e:1}else if(0===t)r=1/i,a=1/s;else{const e=i*t,n=s*t;r=e<1?1/e:1,a=n<1?1/n:1}}else{const o=Math.abs(e*n-i*s),l=Math.hypot(e,i),h=Math.hypot(s,n);if(0===t)r=h/o,a=l/o;else{const e=t*o;r=h>e?h/e:1,a=l>e?l/e:1}}this._cachedScaleForStroking[0]=r,this._cachedScaleForStroking[1]=a}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:i}=this.current,[s,n]=this.getScaleForStroking();if(e.lineWidth=i||1,1===s&&1===n)return void e.stroke();const r=e.getLineDash();if(t&&e.save(),e.scale(s,n),r.length>0){const t=Math.max(s,n);e.setLineDash(r.map((e=>e/t))),e.lineDashOffset/=t}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}}for(const t in ft)void 0!==Ai.prototype[t]&&(Ai.prototype[ft[t]]=Ai.prototype[t]);let _i=class{static#$e=null;static#Ue="";static get workerPort(){return this.#$e}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#$e=t}static get workerSrc(){return this.#Ue}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Ue=t}};const xi=1,Si=2,Ci=1,Ei=2,Pi=3,Ti=4,Mi=5,ki=6,Li=7,Ii=8;function Di(){}function Ri(t){switch(t instanceof Error||"object"==typeof t&&null!==t||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new Dt(t.message);case"MissingPDFException":return new kt(t.message);case"PasswordException":return new Pt(t.message,t.code);case"UnexpectedResponseException":return new Lt(t.message,t.status);case"UnknownErrorException":return new Tt(t.message,t.details);default:return new Tt(t.message,t.toString())}}class Ni{#We=new AbortController;constructor(t,e,i){this.sourceName=t,this.targetName=e,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),i.addEventListener("message",this.#Ge.bind(this),{signal:this.#We.signal})}#Ge({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#qe(t);if(t.callback){const e=t.callbackId,i=this.callbackCapabilities[e];if(!i)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===xi)i.resolve(t.data);else{if(t.callback!==Si)throw new Error("Unexpected callback case");i.reject(Ri(t.reason))}return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,s=t.sourceName,n=this.comObj;Promise.try(e,t.data).then((function(e){n.postMessage({sourceName:i,targetName:s,callback:xi,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:Si,callbackId:t.callbackId,reason:Ri(e)})}))}else t.streamId?this.#Xe(t):e(t.data)}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const s=this.callbackId++,n=Promise.withResolvers();this.callbackCapabilities[s]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:s,data:e},i)}catch(t){n.reject(t)}return n.promise}sendWithStream(t,e,i,s){const n=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:n,data:e,desiredSize:i.desiredSize},s),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:ki,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{xt(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Ci,streamId:n,reason:Ri(t)}),e.promise}},i)}#Xe(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this,a=this.actionHandler[t.action],o={enqueue(t,r=1,a){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=r,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:Ti,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Pi,streamId:e}),delete r.streamSinks[e])},error(t){xt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Mi,streamId:e,reason:Ri(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(a,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ii,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ii,streamId:e,reason:Ri(t)})}))}#qe(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Ii:t.success?r.startCall.resolve():r.startCall.reject(Ri(t.reason));break;case Li:t.success?r.pullCall.resolve():r.pullCall.reject(Ri(t.reason));break;case ki:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Li,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Di).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Li,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Li,streamId:e,reason:Ri(t)})}));break;case Ti:if(xt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Pi:if(xt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#Ke(r,e);break;case Mi:xt(r,"error should have stream controller"),r.controller.error(Ri(t.reason)),this.#Ke(r,e);break;case Ei:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ri(t.reason)),this.#Ke(r,e);break;case Ci:if(!a)break;const o=Ri(t.reason);Promise.try(a.onCancel||Di,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ei,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ei,streamId:e,reason:Ri(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Ke(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#We?.abort(),this.#We=null}}class Fi{#Ye;#Qe;constructor({parsedData:t,rawData:e}){this.#Ye=t,this.#Qe=e}getRaw(){return this.#Qe}get(t){return this.#Ye.get(t)??null}getAll(){return Ft(this.#Ye)}has(t){return this.#Ye.has(t)}}const Oi=Symbol("INTERNAL");class Bi{#Je=!1;#Ze=!1;#ti=!1;#ei=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#Je=!!(t&P),this.#Ze=!!(t&T),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#ti)return this.#ei;if(!this.#ei)return!1;const{print:t,view:e}=this.usage;return this.#Je?"OFF"!==e?.viewState:!this.#Ze||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Oi&&_t("Internal method `_setVisible` called."),this.#ti=i,this.#ei=e}}class ji{#ii=null;#si=new Map;#ni=null;#ri=null;constructor(t,e=P){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#ri=t.order;for(const i of t.groups)this.#si.set(i.id,new Bi(e,i));if("OFF"===t.baseState)for(const t of this.#si.values())t._setVisible(Oi,!1);for(const e of t.on)this.#si.get(e)._setVisible(Oi,!0);for(const e of t.off)this.#si.get(e)._setVisible(Oi,!1);this.#ni=this.getHash()}}#ai(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let s=1;s<e;s++){const e=t[s];let n;if(Array.isArray(e))n=this.#ai(e);else{if(!this.#si.has(e))return At(`Optional content group not found: ${e}`),!0;n=this.#si.get(e).visible}switch(i){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===i}isVisible(t){if(0===this.#si.size)return!0;if(!t)return yt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#si.has(t.id)?this.#si.get(t.id).visible:(At(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ai(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#si.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#si.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#si.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#si.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#si.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#si.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#si.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#si.get(e).visible)return!1}return!0}return At(`Unknown optional content policy ${t.policy}.`),!0}return At(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const s=this.#si.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#si.get(i)?._setVisible(Oi,!1,!0);s._setVisible(Oi,!!e,!0),this.#ii=null}else At(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const s of t){switch(s){case"ON":case"OFF":case"Toggle":i=s;continue}const t=this.#si.get(s);if(t)switch(i){case"ON":this.setVisibility(s,!0,e);break;case"OFF":this.setVisibility(s,!1,e);break;case"Toggle":this.setVisibility(s,!t.visible,e)}}this.#ii=null}get hasInitialVisibility(){return null===this.#ni||this.getHash()===this.#ni}getOrder(){return this.#si.size?this.#ri?this.#ri.slice():[...this.#si.keys()]:null}getGroups(){return this.#si.size>0?Ft(this.#si):null}getGroup(t){return this.#si.get(t)||null}getHash(){if(null!==this.#ii)return this.#ii;const t=new Ne;for(const[e,i]of this.#si)t.update(`${e}:${i.visible}`);return this.#ii=t.hexdigest()}}class Vi{constructor(t,{disableRange:e=!1,disableStream:i=!1}){xt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,n?.length>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=s,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener(((t,e)=>{this._onReceiveData({begin:t,chunk:e})})),t.addProgressListener(((t,e)=>{this._onProgress({loaded:t,total:e})})),t.addProgressiveReadListener((t=>{this._onReceiveData({chunk:t})})),t.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{xt(this._rangeReaders.some((function(e){return e._begin===t&&(e._enqueue(i),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(t){void 0===t.total?this._rangeReaders[0]?.onProgress?.({loaded:t.loaded}):this._fullRequestReader?.onProgress?.({loaded:t.loaded,total:t.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){xt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Hi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new zi(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeReaders.slice(0))e.cancel(t);this._pdfDataRangeTransport.abort()}}class Hi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=re(s)?s:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class zi{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function $i(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const s=e[t];void 0!==s&&i.append(t,s)}return i}function Ui(t){try{return new URL(t).origin}catch{}return null}function Wi({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return n;if(n.suggestedLength=r,r<=2*i)return n;if(s||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function Gi(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=s("filename\\*","i").exec(t);if(i){i=i[1];let t=a(i);return t=unescape(t),t=o(t),t=l(t),r(t)}if(i=function(t){const e=[];let i;const n=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=n.exec(t));){let[,t,s,n]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[s,n]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=a(s),i&&(s=unescape(s),0===t&&(s=o(s))),r.push(s)}return r.join("")}(t),i)return r(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function s(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const s=new TextDecoder(t,{fatal:!0}),n=Nt(i);i=s.decode(n),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function a(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const i=e[t].indexOf('"');-1!==i&&(e[t]=e[t].slice(0,i),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(t,e,i,s){if("q"===i||"Q"===i)return n(e,s=(s=s.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(t,e){return String.fromCharCode(parseInt(e,16))})));try{s=atob(s)}catch{}return n(e,s)}))}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(re(t))return t}return null}function qi(t,e){return 404===t||0===t&&e.startsWith("file:")?new kt('Missing PDF "'+e+'".'):new Lt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Xi(t){return 200===t||206===t}function Ki(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Yi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(At(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Qi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=$i(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return xt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Ji(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Zi(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class Ji{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),s=e.url;fetch(s,Ki(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Ui(e.url),!Xi(e.status))throw qi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Wi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Gi(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Dt("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Yi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Zi{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const s=t.source;this._withCredentials=s.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!s.disableStream,this._abortController=new AbortController;const n=new Headers(t.headers);n.append("Range",`bytes=${e}-${i-1}`);const r=s.url;fetch(r,Ki(n,this._withCredentials,this._abortController)).then((e=>{const i=Ui(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Xi(e.status))throw qi(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:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Yi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ts{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=$i(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,i){const s={begin:t,end:e};for(const t in i)s[t]=i[t];return this.request(s)}requestFull(t){return this.request(t)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,s=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[t,i]of this.headers)e.setRequestHeader(t,i);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),s.expectedStatus=206):s.expectedStatus=200,e.responseType="arraybuffer",t.onError&&(e.onerror=function(i){t.onError(e.status)}),e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),s.onHeadersReceived=t.onHeadersReceived,s.onDone=t.onDone,s.onError=t.onError,s.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){const i=this.pendingRequests[t];i&&i.onProgress?.(e)}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const s=i.xhr;if(s.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==s.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===s.status&&this.isHttp)return void i.onError?.(s.status);const n=s.status||200;if(!(200===n&&206===i.expectedStatus)&&n!==i.expectedStatus)return void i.onError?.(s.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:Nt(e).buffer}(s);if(206===n){const t=s.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);i.onDone({begin:parseInt(e[1],10),chunk:r})}else r?i.onDone({begin:0,chunk:r}):i.onError?.(s.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class es{constructor(t){this._source=t,this._manager=new ts(t),this._rangeChunkSize=t.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(t){const e=this._rangeRequestReaders.indexOf(t);e>=0&&this._rangeRequestReaders.splice(e,1)}getFullReader(){return xt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new is(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new ss(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class is{constructor(t,e){this._manager=t;const i={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(i),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=Ui(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trim().split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=Wi({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Gi(s),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=qi(t,this._url),this._headersCapability.reject(this._storedError);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){this.onProgress?.({loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class ss{constructor(t,e,i){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,i,s),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ui(this._manager.getRequestXhr(this._requestId)?.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??=qi(t,this._url);for(const t of this._requests)t.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){this.isStreamingSupported||this.onProgress?.({loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ns=/^[a-z][a-z0-9\-+.]+:/i;class rs{constructor(t){this.source=t,this.url=function(t){if(ns.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),xt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return xt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new as(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new os(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){this._fullRequestReader?.cancel(t);for(const e of this._rangeRequestReaders.slice(0))e.cancel(t)}}class as{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then((t=>{this._contentLength=t.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()}),(t=>{"ENOENT"===t.code&&(t=new kt(`Missing PDF "${this._url}".`)),this._storedError=t,this._headersCapability.reject(t)}))}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(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Dt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class os{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const s=t.source;this._isStreamingSupported=!s.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();if(null===t)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=t.length,this.onProgress?.({loaded:this._loaded});return{value:new Uint8Array(t).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",(()=>{this._readCapability.resolve()})),t.on("end",(()=>{t.destroy(),this._done=!0,this._readCapability.resolve()})),t.on("error",(t=>{this._error(t)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const ls=30;let hs=class t{#oi=Promise.withResolvers();#pt=null;#li=!1;#hi=!!globalThis.FontInspector?.enabled;#di=null;#ci=null;#ui=0;#pi=0;#gi=null;#fi=null;#mi=0;#bi=0;#vi=Object.create(null);#wi=[];#yi=null;#Ai=[];#_i=new WeakMap;#xi=null;static#Si=new Map;static#Ci=new Map;static#Ei=new WeakMap;static#Pi=null;static#Ti=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#yi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#yi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#fi=i,this.#bi=s.scale*(globalThis.devicePixelRatio||1),this.#mi=s.rotation,this.#ci={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#xi=[1,0,0,-1,-a,o+r],this.#pi=n,this.#ui=r,t.#Mi(),ve(i,s),this.#oi.promise.finally((()=>{t.#Ti.delete(this),this.#ci=null,this.#vi=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Ot.platform;return Ct(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#gi.read().then((({value:t,done:i})=>{i?this.#oi.resolve():(this.#di??=t.lang,Object.assign(this.#vi,t.styles),this.#ki(t.items),e())}),this.#oi.reject)};return this.#gi=this.#yi.getReader(),t.#Ti.add(this),e(),this.#oi.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#mi&&(i?.(),this.#mi=n,ve(this.#fi,{rotation:n})),s!==this.#bi){i?.(),this.#bi=s;const e={div:null,properties:null,ctx:t.#Li(this.#di)};for(const t of this.#Ai)e.properties=this.#_i.get(t),e.div=t,this.#Ii(e)}}cancel(){const t=new Dt("TextLayer task cancelled.");this.#gi?.cancel(t).catch((()=>{})),this.#gi=null,this.#oi.reject(t)}get textDivs(){return this.#Ai}get textContentItemsStr(){return this.#wi}#ki(e){if(this.#li)return;this.#ci.ctx??=t.#Li(this.#di);const i=this.#Ai,s=this.#wi;for(const t of e){if(i.length>1e5)return At("Ignoring additional textDivs for performance reasons."),void(this.#li=!0);if(void 0!==t.str)s.push(t.str),this.#Di(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#pt;this.#pt=document.createElement("span"),this.#pt.classList.add("markedContent"),null!==t.id&&this.#pt.setAttribute("id",`${t.id}`),e.append(this.#pt)}else"endMarkedContent"===t.type&&(this.#pt=this.#pt.parentNode)}}#Di(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#Ai.push(i);const n=jt.transform(this.#xi,e.transform);let r=Math.atan2(n[1],n[0]);const a=this.#vi[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#hi&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ri(o,this.#di);let d,c;0===r?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(r),c=n[5]-h*Math.cos(r));const u="calc(var(--scale-factor)*",p=i.style;this.#pt===this.#fi?(p.left=`${(100*d/this.#pi).toFixed(2)}%`,p.top=`${(100*c/this.#ui).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Pi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#hi&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==r&&(s.angle=r*(180/Math.PI));let g=!1;if(e.str.length>1)g=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),i=Math.abs(e.transform[3]);t!==i&&Math.max(t,i)/Math.min(t,i)>1.5&&(g=!0)}if(g&&(s.canvasWidth=a.vertical?e.height:e.width),this.#_i.set(i,s),this.#ci.div=i,this.#ci.properties=s,this.#Ii(this.#ci),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Ii(e){const{div:i,properties:s,ctx:n}=e,{style:r}=i;let a="";if(t.#Pi>1&&(a=`scale(${1/t.#Pi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=s;t.#Ni(n,l*this.#bi,e);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#bi/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Ti.size>0)){this.#Si.clear();for(const{canvas:t}of this.#Ci.values())t.remove();this.#Ci.clear()}}static#Li(t=null){let e=this.#Ci.get(t||="");if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Ci.set(t,e),this.#Ei.set(e,{size:0,family:""})}return e}static#Ni(t,e,i){const s=this.#Ei.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#Mi(){if(null!==this.#Pi)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),this.#Pi=t.getBoundingClientRect().height,t.remove()}static#Ri(t,e){const i=this.#Si.get(t);if(i)return i;const s=this.#Li(e);s.canvas.width=s.canvas.height=ls,this.#Ni(s,ls,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#Si.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,ls,ls),s.strokeText("g",0,0);let o=s.getImageData(0,0,ls,ls).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/ls);break}s.clearRect(0,0,ls,ls),s.strokeText("A",0,ls),o=s.getImageData(0,0,ls,ls).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=ls-Math.floor(t/4/ls);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#Si.set(t,l),l}};class ds{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let s=null;const n=i.name;if("#text"===n)s=i.value;else{if(!ds.shouldBuildText(n))return;i?.attributes?.textContent?s=i.attributes.textContent:i.value&&(s=i.value)}if(null!==s&&e.push({str:s}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}const cs=65536,us=_?class extends He{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}:class extends He{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}},ps=_?class extends ze{async _fetch(t){return qe(t)}}:$e,gs=_?class extends Ue{}:class extends Ue{#Fi;#Oi;#Bi;#ji;#Vi;#Hi;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ji=t,this.#Vi=e}get#A(){return this.#Oi||=new Map}get#zi(){return this.#Hi||=new Map}get#$i(){if(!this.#Bi){const t=this.#Vi.createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const i=this.#Vi.createElementNS(Zt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#Bi=this.#Vi.createElementNS(Zt,"defs"),t.append(i),i.append(this.#Bi),this.#Vi.body.append(t)}return this.#Bi}#Ui(t){if(1===t.length){const e=t[0],i=new Array(256);for(let t=0;t<256;t++)i[t]=e[t]/255;const s=i.join(",");return[s,s,s]}const[e,i,s]=t,n=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,r[t]=i[t]/255,a[t]=s[t]/255;return[n.join(","),r.join(","),a.join(",")]}#Wi(t){if(void 0===this.#Fi){this.#Fi="";const t=this.#Vi.URL;t!==this.#Vi.baseURI&&(ne(t)?At('#createUrl: ignore "data:"-URL for performance reasons.'):this.#Fi=t.split("#",1)[0])}return`url(${this.#Fi}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#Ui(t),r=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(r),e)return this.#A.set(t,e),e;const a=`g_${this.#ji}_transfer_map_${this.#w++}`,o=this.#Wi(a);this.#A.set(t,o),this.#A.set(r,o);const l=this.#Gi(a);return this.#qi(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#zi.get(s);if(n?.key===i)return n.url;if(n?(n.filter?.remove(),n.key=i,n.url="none",n.filter=null):(n={key:i,url:"none",filter:null},this.#zi.set(s,n)),!t||!e)return n.url;const r=this.#Xi(t);t=jt.makeHexColor(...r);const a=this.#Xi(e);if(e=jt.makeHexColor(...a),this.#$i.style.color="","#000000"===t&&"#ffffff"===e||t===e)return n.url;const o=new Array(256);for(let t=0;t<=255;t++){const e=t/255;o[t]=e<=.03928?e/12.92:((e+.055)/1.055)**2.4}const l=o.join(","),h=`g_${this.#ji}_hcm_filter`,d=n.filter=this.#Gi(h);this.#qi(l,l,l,d),this.#Ki(d);const c=(t,e)=>{const i=r[t]/255,s=a[t]/255,n=new Array(e+1);for(let t=0;t<=e;t++)n[t]=i+t/e*(s-i);return n.join(",")};return this.#qi(c(0,5),c(1,5),c(2,5),d),n.url=this.#Wi(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#Ui([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ji}_alpha_map_${this.#w++}`,r=this.#Wi(n);this.#A.set(t,r),this.#A.set(s,r);const a=this.#Gi(n);return this.#Yi(i,a),r}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#Ui([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ji}_luminosity_map_${this.#w++}`,r=this.#Wi(n);this.#A.set(t,r),this.#A.set(i,r);const a=this.#Gi(n);return this.#Qi(a),t&&this.#Yi(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#zi.get(t);if(a?.key===r)return a.url;if(a?(a.filter?.remove(),a.key=r,a.url="none",a.filter=null):(a={key:r,url:"none",filter:null},this.#zi.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#Xi.bind(this));let h=Math.round(.2126*o[0]+.7152*o[1]+.0722*o[2]),d=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[c,u]=[s,n].map(this.#Xi.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#$i.style.color="";const p=(t,e,i)=>{const s=new Array(256),n=(d-h)/i,r=t/255,a=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=r+t*a;for(let t=o;t<=e;t++)s[t]=i;o=e+1}for(let t=o;t<256;t++)s[t]=s[o-1];return s.join(",")},g=`g_${this.#ji}_hcm_${t}_filter`,f=a.filter=this.#Gi(g);return this.#Ki(f),this.#qi(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#Wi(g),a.url}destroy(t=!1){t&&this.#Hi?.size||(this.#Bi?.parentNode.parentNode.remove(),this.#Bi=null,this.#Oi?.clear(),this.#Oi=null,this.#Hi?.clear(),this.#Hi=null,this.#w=0)}#Qi(t){const e=this.#Vi.createElementNS(Zt,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)}#Ki(t){const e=this.#Vi.createElementNS(Zt,"feColorMatrix");e.setAttribute("type","matrix"),e.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"),t.append(e)}#Gi(t){const e=this.#Vi.createElementNS(Zt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#$i.append(e),e}#Ji(t,e,i){const s=this.#Vi.createElementNS(Zt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#qi(t,e,i,s){const n=this.#Vi.createElementNS(Zt,"feComponentTransfer");s.append(n),this.#Ji(n,"feFuncR",t),this.#Ji(n,"feFuncG",e),this.#Ji(n,"feFuncB",i)}#Yi(t,e){const i=this.#Vi.createElementNS(Zt,"feComponentTransfer");e.append(i),this.#Ji(i,"feFuncA",t)}#Xi(t){return this.#$i.style.color=t,fe(getComputedStyle(this.#$i).getPropertyValue("color"))}},fs=_?class extends We{async _fetch(t){return qe(t)}}:Ge;function ms(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new vs,{docId:i}=e,s=t.url?function(t){if(t instanceof URL)return t.href;try{return new URL(t,window.location).href}catch{if(_&&"string"==typeof t)return t}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(_&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return Nt(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(t?.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,r=t.httpHeaders||null,a=!0===t.withCredentials,o=t.password??null,l=t.range instanceof ws?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:cs;let d=t.worker instanceof xs?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||ne(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,g=!1!==t.cMapPacked,f=t.CMapReaderFactory||ps,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||fs,v=!0!==t.stopAtErrors,w=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,y=!1!==t.isEvalSupported,A="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!_,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!_&&(Ot.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:_,E=!0===t.fontExtraProperties,P=!0===t.enableXfa,T=t.ownerDocument||globalThis.document,M=!0===t.disableRange,k=!0===t.disableStream,L=!0===t.disableAutoFetch,I=!0===t.pdfBug,D=t.CanvasFactory||us,R=t.FilterFactory||gs,N=!0===t.enableHWA,F=l?l.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!_&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:f===$e&&b===Ge&&p&&m&&he(p,document.baseURI)&&he(m,document.baseURI);t.canvasFactory&&ue("`canvasFactory`-instance option, please use `CanvasFactory` instead."),t.filterFactory&&ue("`filterFactory`-instance option, please use `FilterFactory` instead.");vt(c);const j={canvasFactory:new D({ownerDocument:T,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:T}),cMapReaderFactory:B?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:B?null:new b({baseUrl:m})};if(!d){const t={verbosity:c,port:_i.workerPort};d=t.port?xs.fromPort(t):new xs(t),e._worker=d}const V={docId:i,apiVersion:"4.9.155",data:n,password:o,disableAutoFetch:L,rangeChunkSize:h,length:F,docBaseUrl:u,enableXfa:P,evaluatorOptions:{maxImageSize:w,disableFontFace:C,ignoreErrors:v,isEvalSupported:y,isOffscreenCanvasSupported:A,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?p:null,standardFontDataUrl:B?m:null}},H={disableFontFace:C,fontExtraProperties:E,ownerDocument:T,pdfBug:I,styleElement:null,loadingParams:{disableAutoFetch:L,enableXfa:P}};return d.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const t=d.messageHandler.sendWithPromise("GetDocRequest",V,n?[n.buffer]:null);let o;if(l)o=new Vi(l,{disableRange:M,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(_)if(he(s)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");t=Qi}else t=rs;else t=he(s)?Qi:es;o=new t({url:s,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:M,disableStream:k})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const s=new Ni(i,t,d.port),n=new Ss(s,e,o,H,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function bs(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class vs{static#ji=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+vs.#ji++,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(t){throw this._worker?.port&&delete this._worker._pendingDestroy,t}this._transport=null,this._worker?.destroy(),this._worker=null}}let ws=class{constructor(t,e,i=!1,s=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=s,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const i of this._rangeListeners)i(t,e)}onDataProgress(t,e){this._readyCapability.promise.then((()=>{for(const i of this._progressListeners)i(t,e)}))}onDataProgressiveRead(t){this._readyCapability.promise.then((()=>{for(const e of this._progressiveReadListeners)e(t)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const t of this._progressiveDoneListeners)t()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class ys{constructor(t,e){this._pdfInfo=t,this._transport=e}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Ct(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}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(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}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()}}class As{#Zi=null;#ts=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new le:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new Es,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:t,rotation:e=this.rotate,offsetX:i=0,offsetY:s=0,dontFlip:n=!1}={}){return new ie({viewBox:this.view,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Ct(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,viewport:e,intent:i="display",annotationMode:s=R.ENABLE,transform:n=null,background:r=null,optionalContentConfigPromise:a=null,annotationCanvasMap:o=null,pageColors:l=null,printAnnotationStorage:h=null,isEditing:d=!1}){this._stats?.time("Overall");const c=this._transport.getRenderingIntent(i,s,h,d),{renderingIntent:u,cacheKey:p}=c;this.#ts=!1,this.#es(),a||=this._transport.getOptionalContentConfig(u);let g=this._intentStates.get(p);g||(g=Object.create(null),this._intentStates.set(p,g)),g.streamReaderCancelTimeout&&(clearTimeout(g.streamReaderCancelTimeout),g.streamReaderCancelTimeout=null);const f=!!(u&T);g.displayReadyCapability||(g.displayReadyCapability=Promise.withResolvers(),g.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const m=t=>{g.renderTasks.delete(b),(this._maybeCleanupAfterRender||f)&&(this.#ts=!0),this.#is(!f),t?(b.capability.reject(t),this._abortOperatorList({intentState:g,reason:t instanceof Error?t:new Error(t)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new Ts({callback:m,params:{canvasContext:t,viewport:e,transform:n,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:g.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!f,pdfBug:this._pdfBug,pageColors:l});(g.renderTasks||=new Set).add(b);const v=b.task;return Promise.all([g.displayReadyCapability.promise,a]).then((([t,e])=>{if(this.destroyed)m();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:t,optionalContentConfig:e}),b.operatorListChanged()}})).catch(m),v}getOperatorList({intent:t="display",annotationMode:e=R.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let r,a=this._intentStates.get(n.cacheKey);return a||(a=Object.create(null),this._intentStates.set(n.cacheKey,a)),a.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){a.operatorList.lastChunk&&(a.opListReadCapability.resolve(a.operatorList),a.renderTasks.delete(r))},a.opListReadCapability=Promise.withResolvers(),(a.renderTasks||=new Set).add(r),a.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),a.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then((t=>ds.textContent(t)));const e=this.streamTextContent(t);return new Promise((function(t,i){const s=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){s.read().then((function({value:i,done:s}){s?t(n):(n.lang??=i.lang,Object.assign(n.styles,i.styles),n.items.push(...i.items),e())}),i)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),this.#ts=!1,this.#es(),Promise.all(t)}cleanup(t=!1){this.#ts=!0;const e=this.#is(!1);return t&&e&&(this._stats&&=new le),e}#is(t=!1){if(this.#es(),!this.#ts||this.destroyed)return!1;if(t)return this.#Zi=setTimeout((()=>{this.#Zi=null,this.#is(!1)}),5e3),!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#ts=!1,!0}#es(){this.#Zi&&(clearTimeout(this.#Zi),this.#Zi=null)}_startRenderPage(t,e){const i=this._intentStates.get(e);i&&(this._stats?.timeEnd("Page Request"),i.displayReadyCapability?.resolve(t))}_renderPageChunk(t,e){for(let i=0,s=t.length;i<s;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const t of e.renderTasks)t.operatorListChanged();t.lastChunk&&this.#is(!0)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:s}){const{map:n,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},r).getReader(),o=this._intentStates.get(e);o.streamReader=a;const l=()=>{a.read().then((({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())}),(t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();this.#is(!0)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}}))};l()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof se){let i=100;return e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout((()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})}),i))}}if(t.streamReader.cancel(new Dt(e.message)).catch((()=>{})),t.streamReader=null,!this._transport.destroyed){for(const[e,i]of this._intentStates)if(i===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}class _s{#ss=new Map;#ns=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#ns.then((()=>{for(const[t]of this.#ss)t.call(this,i)}))}addEventListener(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void At("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}this.#ss.set(e,s)}removeEventListener(t,e){const i=this.#ss.get(e);i?.(),this.#ss.delete(e)}terminate(){for(const[,t]of this.#ss)t?.();this.#ss.clear()}}let xs=class t{static#rs=0;static#as=!1;static#os;static{_&&(this.#as=!0,_i.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{let i;try{if(i=new URL(t),!i.origin||"null"===i.origin)return!1}catch{return!1}const s=new URL(e,i);return i.origin===s.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))}}constructor({name:e=null,port:i=null,verbosity:s=wt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,i){if(t.#os?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#os||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#ls(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new Ni("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#ls()}_initialize(){if(t.#as||t.#hs)return void this._setupFakeWorker();let{workerSrc:e}=t;try{t._isSameOrigin(window.location.href,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),s=new Ni("main","worker",i),n=()=>{r.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:r.signal}),s.on("test",(t=>{r.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#ls()):n()})),s.on("ready",(t=>{if(r.abort(),this.destroyed)n();else try{a()}catch{this._setupFakeWorker()}}));const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{yt("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#as||(At("Setting up fake worker."),t.#as=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new _s;this._port=i;const s="fake"+t.#rs++,n=new Ni(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new Ni(s,s+"_worker",i),this.#ls()})).catch((t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,t.#os?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const i=this.#os?.get(e.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(_i.workerSrc)return _i.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#hs(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Ct(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#hs)return this.#hs;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class Ss{#ds=new Map;#cs=new Map;#us=new Map;#ps=new Map;#gs=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Es,this.fontLoader=new je({ownerDocument:s.ownerDocument,styleElement:s.styleElement}),this.loadingParams=s.loadingParams,this._params=s,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#fs(t,e=null){const i=this.#ds.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#ds.set(t,s),s}get annotationStorage(){return Ct(this,"annotationStorage",new Oe)}getRenderingIntent(t,e=R.ENABLE,i=null,s=!1,n=!1){let r=P,a=Fe;switch(t){case"any":r=E;break;case"display":break;case"print":r=T;break;default:At(`getRenderingIntent - invalid intent: ${t}`)}const o=r&T&&i instanceof Be?i:this.annotationStorage;switch(e){case R.DISABLE:r+=L;break;case R.ENABLE:break;case R.ENABLE_FORMS:r+=M;break;case R.ENABLE_STORAGE:r+=k,a=o.serializable;break;default:At(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=I),n&&(r+=D);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,h].join("_"),annotationStorageSerializable:a,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#gs?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#cs.values())t.push(e._destroy());this.#cs.clear(),this.#us.clear(),this.#ps.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#ds.clear(),this.filterFactory.destroy(),hs.cleanup(),this._networkStream?.cancelAllRequests(new Dt("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",((t,e)=>{xt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then((function({value:t,done:i}){i?e.close():(xt(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}})),t.on("ReaderHeadersReady",(async t=>{await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:s,contentLength:n}=this._fullReader;return i&&s||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:s,contentLength:n}})),t.on("GetRangeReader",((t,e)=>{xt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const i=this._networkStream.getRangeReader(t.begin,t.end);i?(e.onPull=()=>{i.read().then((function({value:t,done:i}){i?e.close():(xt(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))})).catch((t=>{e.error(t)}))},e.onCancel=t=>{i.cancel(t),e.ready.catch((t=>{if(!this.destroyed)throw t}))}):e.close()})),t.on("GetDoc",(({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new ys(t,this))})),t.on("DocException",(function(t){let i;switch(t.name){case"PasswordException":i=new Pt(t.message,t.code);break;case"InvalidPDFException":i=new Mt(t.message);break;case"MissingPDFException":i=new kt(t.message);break;case"UnexpectedResponseException":i=new Lt(t.message,t.status);break;case"UnknownErrorException":i=new Tt(t.message,t.details);break;default:_t("DocException - expected a valid Error.")}e._capability.reject(i)})),t.on("PasswordRequest",(t=>{if(this.#gs=Promise.withResolvers(),e.onPassword){const i=t=>{t instanceof Error?this.#gs.reject(t):this.#gs.resolve({password:t})};try{e.onPassword(i,t.code)}catch(t){this.#gs.reject(t)}}else this.#gs.reject(new Pt(t.message,t.code));return this.#gs.promise})),t.on("DataLoaded",(t=>{e.onProgress?.({loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)})),t.on("StartRenderPage",(t=>{if(this.destroyed)return;this.#cs.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)})),t.on("commonobj",(([e,i,s])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":const{disableFontFace:n,fontExtraProperties:r,pdfBug:a}=this._params;if("error"in s){const t=s.error;At(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=a&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new Ve(s,{disableFontFace:n,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!r&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;xt(h,"The imageRef must be defined.");for(const t of this.#cs.values())for(const[,i]of t.objs)if(i?.ref===h)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,s);break;default:throw new Error(`Got unknown common object type ${i}`)}return null})),t.on("obj",(([t,e,i,s])=>{if(this.destroyed)return;const n=this.#cs.get(e);if(!n.objs.has(t))if(0!==n._intentStates.size)switch(i){case"Image":n.objs.resolve(t,s),s?.dataLen>1e7&&(n._maybeCleanupAfterRender=!0);break;case"Pattern":n.objs.resolve(t,s);break;default:throw new Error(`Got unknown object type ${i}`)}else s?.bitmap?.close()})),t.on("DocProgress",(t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})})),t.on("FetchBuiltInCMap",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(t)})),t.on("FetchStandardFontData",(async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(t)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&At("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:this._fullReader?.filename??null},e).finally((()=>{this.annotationStorage.resetModified()}))}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=this.#us.get(e);if(i)return i;const s=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then((i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#ps.set(i.refStr,t);const s=new As(e,i,this,this._params.pdfBug);return this.#cs.set(e,s),s}));return this.#us.set(e,s),s}getPageIndex(t){return bs(t)?this.messageHandler.sendWithPromise("GetPageIndex",{num:t.num,gen:t.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(t,e){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:t,intent:e})}getFieldObjects(){return this.#fs("GetFieldObjects")}hasJSActions(){return this.#fs("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#fs("GetDocJSActions")}getPageJSActions(t){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:t})}getStructTree(t){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:t})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(t){return this.#fs("GetOptionalContentConfig").then((e=>new ji(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#ds.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Fi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#ds.set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of this.#cs.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#ds.clear(),this.filterFactory.destroy(!0),hs.cleanup()}}cachedPageNumber(t){if(!bs(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#ps.get(e)??null}}const Cs=Symbol("INITIAL_DATA");class Es{#ms=Object.create(null);#bs(t){return this.#ms[t]||={...Promise.withResolvers(),data:Cs}}get(t,e=null){if(e){const i=this.#bs(t);return i.promise.then((()=>e(i.data))),null}const i=this.#ms[t];if(!i||i.data===Cs)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#ms[t];return!!e&&e.data!==Cs}resolve(t,e=null){const i=this.#bs(t);i.data=e,i.resolve()}clear(){for(const t in this.#ms){const{data:e}=this.#ms[t];e?.bitmap?.close()}this.#ms=Object.create(null)}*[Symbol.iterator](){for(const t in this.#ms){const{data:e}=this.#ms[t];e!==Cs&&(yield[t,e])}}}class Ps{#vs=null;constructor(t){this.#vs=t,this.onContinue=null}get promise(){return this.#vs.capability.promise}cancel(t=0){this.#vs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#vs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#vs;return t.form||t.canvas&&e?.size>0}}class Ts{#ws=null;static#ys=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null}){this.callback=t,this.params=e,this.objs=i,this.commonObjs=s,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=r,this._pageIndex=a,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=d,this.pageColors=c,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ps(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Ts.#ys.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.");Ts.#ys.add(this._canvas)}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:s,transform:n,background:r}=this.params;this.gfx=new Ai(i,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#ws&&(window.cancelAnimationFrame(this.#ws),this.#ws=null),Ts.#ys.delete(this._canvas),this.callback(t||new se(`Rendering cancelled, page ${this._pageIndex+1}`,e))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#ws=window.requestAnimationFrame((()=>{this.#ws=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Ts.#ys.delete(this._canvas),this.callback())))}}const Ms="4.9.155",ks="a4eb8407c";function Ls(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Is(t){return Math.max(0,Math.min(255,255*t))}class Ds{static CMYK_G([t,e,i,s]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+s)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=Is(t),t,t]}static G_HTML([t]){const e=Ls(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Is)}static RGB_HTML(t){return`#${t.map(Ls).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,s]){return["RGB",1-Math.min(1,t+s),1-Math.min(1,i+s),1-Math.min(1,e+s)]}static CMYK_rgb([t,e,i,s]){return[Is(1-Math.min(1,t+s)),Is(1-Math.min(1,i+s)),Is(1-Math.min(1,e+s))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const s=1-t,n=1-e,r=1-i;return["CMYK",s,n,r,Math.min(s,n,r)]}}class Rs{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const s=this._createSVG("svg:svg");return s.setAttribute("version","1.1"),i||(s.setAttribute("width",`${t}px`),s.setAttribute("height",`${e}px`)),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("viewBox",`0 0 ${t} ${e}`),s}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){_t("Abstract method `_createSVG` called.")}}let Ns=class extends Rs{_createSVG(t){return document.createElementNS(Zt,t)}},Fs=class{static setupStorage(t,e,i,s,n){const r=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}));break;case"input":if("radio"===i.attributes.type||"checkbox"===i.attributes.type){if(r.value===i.attributes.xfaOn?t.setAttribute("checked",!0):r.value===i.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",(t=>{s.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})}))}else{if(null!==r.value&&t.setAttribute("value",r.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==r.value){t.setAttribute("value",r.value);for(const t of i.children)t.attributes.value===r.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",(t=>{const i=t.target.options,n=-1===i.selectedIndex?"":i[i.selectedIndex].value;s.setValue(e,{value:n})}))}}static setAttributes({html:t,element:e,storage:i=null,intent:s,linkService:n}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${s}`);for(const[e,i]of Object.entries(r))if(null!=i)switch(e){case"class":i.length&&t.setAttribute(e,i.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",i);break;case"style":Object.assign(t.style,i);break;case"textContent":t.textContent=i;break;default:(!a||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}a&&n.addLinkAttributes(t,r.href,r.newWindow),i&&r.dataId&&this.setupStorage(t,r.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",r=document.createElement(s.name);s.attributes&&this.setAttributes({html:r,element:s,intent:n,linkService:i});const a="richText"!==n,o=t.div;if(o.append(r),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}a&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);r.append(t),a&&ds.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,r]];for(;h.length>0;){const[t,s,r]=h.at(-1);if(s+1===t.children.length){h.pop();continue}const o=t.children[++h.at(-1)[1]];if(null===o)continue;const{name:d}=o;if("#text"===d){const t=document.createTextNode(o.value);l.push(t),r.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(r.append(c),o.attributes&&this.setAttributes({html:c,element:o,storage:e,intent:n,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);a&&ds.shouldBuildText(d)&&l.push(t),c.append(t)}}for(const t of o.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))t.setAttribute("readOnly",!0);return{textDivs:l}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}};const Os=1e3,Bs=new WeakSet;function js(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Vs{static create(t){switch(t.data.annotationType){case G:return new zs(t);case W:return new $s(t);case lt:switch(t.data.fieldType){case"Tx":return new Ws(t);case"Btn":return t.data.radioButton?new Xs(t):t.data.checkBox?new qs(t):new Ks(t);case"Ch":return new Ys(t);case"Sig":return new Gs(t)}return new Us(t);case at:return new Qs(t);case q:return new Zs(t);case X:return new tn(t);case K:return new en(t);case Y:return new sn(t);case J:return new nn(t);case nt:return new an(t);case rt:return new on(t);case Q:return new rn(t);case Z:return new ln(t);case tt:return new hn(t);case et:return new dn(t);case it:return new cn(t);case st:return new un(t);case ot:return new pn(t);default:return new Hs(t)}}}class Hs{#As=null;#_s=!1;#xs=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:s=!1}={}){this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,e&&(this.container=this._createContainer(i)),s&&this._createQuadrilaterals()}static _hasPopupData({titleObj:t,contentsObj:e,richText:i}){return!!(t?.str||e?.str||i?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Hs._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#As||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#Ss(e),this.#xs?.popup.updateEdited(t)}resetEdited(){this.#As&&(this.#Ss(this.#As.rect),this.#xs?.popup.resetEdited(),this.#As=null)}#Ss(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=js(t);e.left=100*(t[0]-a)/n+"%",e.top=100*(r-t[3]+o)/r+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/r+"%"):this.setRotation(s)}_createContainer(t){const{data:e,parent:{page:i,viewport:s}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof Us||(n.tabIndex=Os);const{style:r}=n;if(r.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Qs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=js(e.rect);if(!t&&e.borderStyle.width>0){r.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,i=e.borderStyle.verticalCornerRadius;if(t>0||i>0){const e=`calc(${t}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;r.borderRadius=e}else if(this instanceof Xs){const t=`calc(${a}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case ht:r.borderStyle="solid";break;case dt:r.borderStyle="dashed";break;case ct:At("Unimplemented border style: beveled");break;case ut:At("Unimplemented border style: inset");break;case pt:r.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#_s=!0,r.borderColor=jt.makeHexColor(0|s[0],0|s[1],0|s[2])):r.borderWidth=0}const l=jt.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:h,pageHeight:d,pageX:c,pageY:u}=s.rawDims;r.left=100*(l[0]-c)/h+"%",r.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(r.width=100*a/h+"%",r.height=100*o/d+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:s}=this.parent.viewport.rawDims,{width:n,height:r}=js(this.data.rect);let a,o;t%180==0?(a=100*n/i,o=100*r/s):(a=100*r/i,o=100*n/s),e.style.width=`${a}%`,e.style.height=`${o}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const s=i.detail[t],n=s[0],r=s.slice(1);i.target.style[e]=Ds[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Ds[`${n}_rgb`](r)})};return Ct(this,"_commonActions",{display:t=>{const{display:e}=t.detail,i=e%2==1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout((()=>t.target.focus({preventScroll:!1})),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const s of Object.keys(e.detail)){const n=t[s]||i[s];n?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[s,n]of Object.entries(e)){const r=i[s];if(r){r({detail:{[s]:n},target:t}),delete e[s]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,s,n]=this.data.rect.map((t=>Math.fround(t)));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(s===r&&n===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#_s){const{borderColor:t,borderWidth:e}=r;r.borderWidth=0,a=["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="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=s-e,l=n-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0);const c=h.createElement("defs");d.append(c);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),c.append(u);for(let i=2,s=t.length;i<s;i+=8){const s=t[i],r=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-r)/l,m=(s-d)/o,b=(r-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#_s&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#xs=new Qs({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(e.render())}render(){_t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const s=this._fieldObjects[t];if(s)for(const{page:t,id:n,exportValues:r}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${n}"]`);!a||Bs.has(a)?i.push({id:n,exportValue:s,domElement:a}):At(`_getElementsByName - element not allowed: ${n}`)}return i}for(const s of document.getElementsByName(t)){const{exportValue:t}=s,n=s.getAttribute("data-element-id");n!==e&&(Bs.has(s)&&i.push({id:n,exportValue:t,domElement:s}))}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 t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e})}))}}class zs extends Hs{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!e?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,i=document.createElement("a");i.setAttribute("data-element-id",t.id);let s=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),s=!0):t.action?(this._bindNamedAction(i,t.action),s=!0):t.attachment?(this.#Cs(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#Es(i,t.setOCGState),s=!0):t.dest?(this._bindLink(i,t.dest),s=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),s=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),s=!0):this.isTooltipOnly&&!s&&(this._bindLink(i,""),s=!0)),this.container.classList.add("linkAnnotation"),s&&this.container.append(i),this.container}#Ps(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Ps()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ps()}#Cs(t,e,i=null){t.href=this.linkService.getAnchorUrl(""),e.description&&(t.title=e.description),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,i),!1),this.#Ps()}#Es(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ps()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const s of Object.keys(e.actions)){const n=i.get(s);n&&(t[n]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:s}}),!1))}t.onclick||(t.onclick=()=>!1),this.#Ps()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ps(),!this._fieldObjects)return At('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:s,include:n}=e,r=[];if(0!==t.length||0!==s.length){const e=new Set(s);for(const i of t){const t=this._fieldObjects[i]||[];for(const{id:i}of t)e.add(i)}for(const t of Object.values(this._fieldObjects))for(const i of t)e.has(i.id)===n&&r.push(i)}else for(const t of Object.values(this._fieldObjects))r.push(...t);const a=this.annotationStorage,o=[];for(const t of r){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;a.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";a.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(Bs.has(i)?i.dispatchEvent(new Event("resetform")):At(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class $s extends Hs{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(t),this.container}}class Us extends Hs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Ot.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,s,n){i.includes("mouse")?t.addEventListener(i,(t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})})):t.addEventListener(i,(t=>{if("blur"===i){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===i){if(e.focused)return;e.focused=!0}n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:s,value:n(t)}})}))}_setEventListeners(t,e,i,s){for(const[n,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,n,r,s),"Focus"!==r||this.data.actions?.Blur?"Blur"!==r||this.data.actions?.Focus||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":jt.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,s=this.data.defaultAppearanceData.fontSize||9,n=t.style;let r;const a=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(C*s))||1);r=Math.min(s,a(e/C))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(s,a(t/C))}n.fontSize=`calc(${r}px * var(--scale-factor))`,n.color=jt.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Ws extends Us{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,s){const n=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),n.setValue(r.id,{[s]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const s=t.getValue(e,{value:this.data.fieldValue});let n=s.value||"";const r=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;r&&n.length>r&&(n=n.slice(0,r));let a=s.formattedValue||this.data.textContent?.join("\n")||null;a&&this.data.comb&&(a=a.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:a,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=a??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",a??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Bs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Os,this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",(s=>{t.setValue(e,{value:s.target.value}),this.setPropertyOnSiblings(i,"value",s.target.value,"value"),o.formattedValue=null})),i.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null}));let l=t=>{const{formattedValue:e}=o;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",(t=>{if(o.focused)return;const{target:e}=t;o.userValue&&(e.value=o.userValue),o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)})),i.addEventListener("updatefromsandbox",(i=>{this.showElementAndHideCanvas(i.target);const s={value(i){o.userValue=i.detail.value??"",t.setValue(e,{value:o.userValue.toString()}),i.target.value=o.userValue},formattedValue(i){const{formattedValue:s}=i.detail;o.formattedValue=s,null!=s&&i.target!==document.activeElement&&(i.target.value=s),t.setValue(e,{formattedValue:s})},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:i=>{const{charLimit:s}=i.detail,{target:n}=i;if(0===s)return void n.removeAttribute("maxLength");n.setAttribute("maxLength",s);let r=o.userValue;!r||r.length<=s||(r=r.slice(0,s),n.value=o.userValue=r,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:n.selectionStart,selEnd:n.selectionEnd}}))}};this._dispatchEventFromSandbox(s,i)})),i.addEventListener("keydown",(t=>{o.commitKey=1;let i=-1;if("Escape"===t.key?i=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(o.commitKey=3):i=2,-1===i)return;const{value:s}=t.target;o.lastCommittedValue!==s&&(o.lastCommittedValue=s,o.userValue=s,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))}));const s=l;l=null,i.addEventListener("blur",(t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{value:i}=t.target;o.userValue=i,o.lastCommittedValue!==i&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:i,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),s(t)})),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",(t=>{o.lastCommittedValue=null;const{data:i,target:s}=t,{value:n,selectionStart:r,selectionEnd:a}=s;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(r).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":r===a&&(l-=1);break;case"deleteContentForward":r===a&&(h+=1)}t.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,change:i||"",willCommit:!1,selStart:l,selEnd:h}})})),this._setEventListeners(i,o,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.value))}if(l&&i.addEventListener("blur",l),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/r;i.classList.add("comb"),i.style.letterSpacing=`calc(${t}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.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class Gs extends Us{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class qs extends Us{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof s&&(s="Off"!==s,t.setValue(i,{value:s})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return Bs.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=Os,n.addEventListener("change",(s=>{const{name:n,checked:r}=s.target;for(const s of this._getElementsByName(n,i)){const i=r&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:r})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue})),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",(e=>{const s={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(s,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Xs extends Us{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let s=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof s&&(s=s!==e.buttonValue,t.setValue(i,{value:s})),s)for(const s of this._getElementsByName(e.fieldName,i))t.setValue(s.id,{value:!1});const n=document.createElement("input");if(Bs.add(n),n.setAttribute("data-element-id",i),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,s&&n.setAttribute("checked",!0),n.tabIndex=Os,n.addEventListener("change",(e=>{const{name:s,checked:n}=e.target;for(const e of this._getElementsByName(s,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:n})})),n.addEventListener("resetform",(t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue})),this.enableScripting&&this.hasJSActions){const s=e.buttonValue;n.addEventListener("updatefromsandbox",(e=>{const n={value:e=>{const n=s===e.detail.value;for(const s of this._getElementsByName(e.target.name)){const e=n&&s.id===i;s.domElement&&(s.domElement.checked=e),t.setValue(s.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)})),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(t=>t.target.checked))}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Ks extends zs{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",(t=>{this._dispatchEventFromSandbox({},t)}))),t}}class Ys extends Us{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),s=document.createElement("select");Bs.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,this._setRequired(s,this.data.required),s.name=this.data.fieldName,s.tabIndex=Os;let n=this.data.combo&&this.data.options.length>0;this.data.combo||(s.size=this.data.options.length,this.data.multiSelect&&(s.multiple=!0)),s.addEventListener("resetform",(t=>{const e=this.data.defaultFieldValue;for(const t of s.options)t.selected=t.value===e}));for(const t of this.data.options){const e=document.createElement("option");e.textContent=t.displayValue,e.value=t.exportValue,i.value.includes(t.exportValue)&&(e.setAttribute("selected",!0),n=!1),s.append(e)}let r=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),r=()=>{t.remove(),s.removeEventListener("input",r),r=null},s.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:n}=s;return n?Array.prototype.filter.call(i,(t=>t.selected)).map((t=>t[e])):-1===i.selectedIndex?null:i[i.selectedIndex][e]};let o=a(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,(t=>({displayValue:t.textContent,exportValue:t.value})))};return this.enableScripting&&this.hasJSActions?(s.addEventListener("updatefromsandbox",(i=>{const n={value(i){r?.();const n=i.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of s.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,r=i.detail.remove;if(n[r].selected=!1,s.remove(r),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:n,displayValue:r,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},items(i){const{items:n}=i.detail;for(;0!==s.length;)s.remove(0);for(const t of n){const{displayValue:e,exportValue:i}=t,n=document.createElement("option");n.textContent=e,n.value=i,s.append(n)}s.options.length>0&&(s.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const s=new Set(i.detail.indices);for(const t of i.target.options)t.selected=s.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=a(!0),n=a(!1);t.setValue(e,{value:s}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:n,changeEx:s,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(s,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(t=>t.target.value))):s.addEventListener("input",(function(i){t.setValue(e,{value:a(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Qs extends Hs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:Hs._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Js({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}),e=[];for(const i of this.elements)i.popup=t,i.container.ariaHasPopup="dialog",e.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",e.map((t=>`${$t}${t}`)).join(",")),this.container}}class Js{#Ts=this.#Ms.bind(this);#ks=this.#Ls.bind(this);#Is=this.#Ds.bind(this);#Rs=this.#Ns.bind(this);#Fs=null;#pt=null;#Os=null;#Bs=null;#js=null;#Vs=null;#Hs=null;#zs=!1;#$s=null;#E=null;#Us=null;#Ws=null;#Gs=null;#As=null;#qs=!1;constructor({container:t,color:e,elements:i,titleObj:s,modificationDate:n,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#Gs=s,this.#Os=r,this.#Ws=a,this.#Vs=o,this.#Fs=e,this.#Us=l,this.#Hs=h,this.#js=i,this.#Bs=pe.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Rs),t.addEventListener("mouseenter",this.#Is),t.addEventListener("mouseleave",this.#ks),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Ts);this.#pt.hidden=!0,d&&this.#Ns()}render(){if(this.#$s)return;const t=this.#$s=document.createElement("div");if(t.className="popup",this.#Fs){const e=t.style.outlineColor=jt.makeHexColor(...this.#Fs);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`;else{const e=.7;t.style.backgroundColor=jt.makeHexColor(...this.#Fs.map((t=>Math.floor(e*(255-t)+t))))}}const e=document.createElement("span");e.className="header";const i=document.createElement("h1");if(e.append(i),({dir:i.dir,str:i.textContent}=this.#Gs),t.append(e),this.#Bs){const t=document.createElement("span");t.classList.add("popupDate"),t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#Bs.valueOf()})),e.append(t)}const s=this.#Xs;if(s)Fs.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#Os);t.append(e)}this.#pt.append(t)}get#Xs(){const t=this.#Ws,e=this.#Os;return!t?.str||e?.str&&e.str!==t.str?null:this.#Ws.html||null}get#Ks(){return this.#Xs?.attributes?.style?.fontSize||0}get#Ys(){return this.#Xs?.attributes?.style?.color||null}#Qs(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#Ys,fontSize:this.#Ks?`calc(${this.#Ks}px * var(--scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:s});return i}_formatContents({str:t,dir:e}){const i=document.createElement("p");i.classList.add("popupContent"),i.dir=e;const s=t.split(/(?:\r\n?|\n)/);for(let t=0,e=s.length;t<e;++t){const n=s[t];i.append(document.createTextNode(n)),t<e-1&&i.append(document.createElement("br"))}return i}#Ms(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#zs)&&this.#Ns()}updateEdited({rect:t,popupContent:e}){this.#As||={contentsObj:this.#Os,richText:this.#Ws},t&&(this.#E=null),e&&(this.#Ws=this.#Qs(e),this.#Os=null),this.#$s?.remove(),this.#$s=null}resetEdited(){this.#As&&(({contentsObj:this.#Os,richText:this.#Ws}=this.#As),this.#As=null,this.#$s?.remove(),this.#$s=null,this.#E=null)}#Js(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#Vs;let r=!!this.#Hs,a=r?this.#Hs:this.#Us;for(const t of this.#js)if(!a||null!==jt.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=jt.normalizeRect([a[0],t[3]-a[1]+t[1],a[2],t[3]-a[3]+t[1]]),l=r?a[2]-a[0]+5:0,h=o[0]+l,d=o[1];this.#E=[100*(h-s)/e,100*(d-n)/i];const{style:c}=this.#pt;c.left=`${this.#E[0]}%`,c.top=`${this.#E[1]}%`}#Ns(){this.#zs=!this.#zs,this.#zs?(this.#Ds(),this.#pt.addEventListener("click",this.#Rs),this.#pt.addEventListener("keydown",this.#Ts)):(this.#Ls(),this.#pt.removeEventListener("click",this.#Rs),this.#pt.removeEventListener("keydown",this.#Ts))}#Ds(){this.#$s||this.render(),this.isVisible?this.#zs&&this.#pt.classList.add("focused"):(this.#Js(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ls(){this.#pt.classList.remove("focused"),!this.#zs&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#qs=this.isVisible,this.#qs&&(this.#pt.hidden=!0)}maybeShow(){this.#qs&&(this.#$s||this.#Ds(),this.#qs=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class Zs extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=N.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class tn extends Hs{#Zs=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=js(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#Zs=this.svgFactory.createElement("svg:line");return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),s.append(n),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Zs}addHighlightArea(){this.container.classList.add("highlightArea")}}class en extends Hs{#tn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=js(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#tn=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",n/2),r.setAttribute("y",n/2),r.setAttribute("width",e-n),r.setAttribute("height",i-n),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#tn}addHighlightArea(){this.container.classList.add("highlightArea")}}class sn extends Hs{#en=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=js(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#en=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/2-n/2),r.setAttribute("ry",i/2-n/2),r.setAttribute("stroke-width",n||1),r.setAttribute("stroke","transparent"),r.setAttribute("fill","transparent"),s.append(r),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#en}addHighlightArea(){this.container.classList.add("highlightArea")}}class nn extends Hs{#in=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:i,popupRef:s}}=this;if(!e)return this.container;const{width:n,height:r}=js(t),a=this.svgFactory.create(n,r,!0);let o=[];for(let i=0,s=e.length;i<s;i+=2){const s=e[i]-t[0],n=t[3]-e[i+1];o.push(`${s},${n}`)}o=o.join(" ");const l=this.#in=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",o),l.setAttribute("stroke-width",i.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),a.append(l),this.container.append(a),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#in}addHighlightArea(){this.container.classList.add("highlightArea")}}class rn extends nn{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class an extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class on extends Hs{#sn=null;#nn=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?N.HIGHLIGHT:N.INK}#rn(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:i,borderStyle:s,popupRef:n}}=this,{transform:r,width:a,height:o}=this.#rn(e,t),l=this.svgFactory.create(a,o,!0),h=this.#sn=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",s.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",r);for(let t=0,e=i.length;t<e;t++){const e=this.svgFactory.createElement(this.svgElementName);this.#nn.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:s}=t,n=this.#sn;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#nn.length;t<e;t++)this.#nn[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#rn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#nn}addHighlightArea(){this.container.classList.add("highlightArea")}}class ln extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=N.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class hn extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class dn extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class cn extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class un extends Hs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=N.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class pn extends Hs{#an=null;constructor(t){super(t,{isRenderable:!0});const{file:e}=this.data;this.filename=e.filename,this.content=e.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...e})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let i;e.hasAppearance||0===e.fillAlpha?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),i.addEventListener("dblclick",this.#on.bind(this)),this.#an=i;const{isMac:s}=Ot.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#on()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#an}addHighlightArea(){this.container.classList.add("highlightArea")}#on(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let gn=class{#ln=null;#hn=null;#dn=new Map;#cn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#ln=e,this.#hn=i,this.#cn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#dn.size>0}async#un(t,e){const i=t.firstChild||t,s=i.id=`${$t}${e}`,n=await(this.#cn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#ln?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;ve(i,this.viewport);const s=new Map,n={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Ns,annotationStorage:t.annotationStorage||new Oe,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const t of e){if(t.noHTML)continue;const e=t.annotationType===at;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=js(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=Vs.create(n);if(!i.isRenderable)continue;if(!e&&t.popupRef){const e=s.get(t.popupRef);e?e.push(i):s.set(t.popupRef,[i])}const r=i.render();t.hidden&&(r.style.visibility="hidden"),await this.#un(r,t.id),i._isEditable&&(this.#dn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#pn()}update({viewport:t}){const e=this.div;this.viewport=t,ve(e,{rotation:t.rotation}),this.#pn(),e.hidden=!1}#pn(){if(!this.#hn)return;const t=this.div;for(const[e,i]of this.#hn){const s=t.querySelector(`[data-annotation-id="${e}"]`);if(!s)continue;i.className="annotationContent";const{firstChild:n}=s;n?"CANVAS"===n.nodeName?n.replaceWith(i):n.classList.contains("annotationContent")?n.after(i):n.before(i):s.append(i)}this.#hn.clear()}getEditableAnnotations(){return Array.from(this.#dn.values())}getEditableAnnotation(t){return this.#dn.get(t)}};const fn=/\r\n?|\n/g;class mn extends ke{#Fs;#gn="";#fn=`${this.id}-editor`;#mn=null;#Ks;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=mn.prototype,e=t=>t.isEmpty(),i=Te.TRANSLATE_SMALL,s=Te.TRANSLATE_BIG;return Ct(this,"_keyboardManager",new Ee([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=N.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#Fs=t.color||mn._defaultColor||ke._defaultLineColor,this.#Ks=t.fontSize||mn._defaultFontSize}static initialize(t,e){ke.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case F.FREETEXT_SIZE:mn._defaultFontSize=e;break;case F.FREETEXT_COLOR:mn._defaultColor=e}}updateParams(t,e){switch(t){case F.FREETEXT_SIZE:this.#bn(e);break;case F.FREETEXT_COLOR:this.#vn(e)}}static get defaultPropertiesToUpdate(){return[[F.FREETEXT_SIZE,mn._defaultFontSize],[F.FREETEXT_COLOR,mn._defaultColor||ke._defaultLineColor]]}get propertiesToUpdate(){return[[F.FREETEXT_SIZE,this.#Ks],[F.FREETEXT_COLOR,this.#Fs]]}#bn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#Ks)*this.parentScale),this.#Ks=t,this.#wn()},i=this.#Ks;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#vn(t){const e=t=>{this.#Fs=this.editorDiv.style.color=t},i=this.#Fs;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-mn._internalPadding*t,-(mn._internalPadding+this.#Ks)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(N.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#mn=new AbortController;const t=this._uiManager.combinedSignal(this.#mn);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#fn),this._isDraggable=!0,this.#mn?.abort(),this.#mn=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){this.width||(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,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#yn(){const t=[];this.editorDiv.normalize();let e=null;for(const i of this.editorDiv.childNodes)e?.nodeType===Node.TEXT_NODE&&"BR"===i.nodeName||(t.push(mn.#An(i)),e=i);return t.join("\n")}#wn(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,s=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),i=e.getBoundingClientRect(),e.remove(),e.style.display=s,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=i.width/t,this.height=i.height/e):(this.width=i.height/t,this.height=i.width/e),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const t=this.#gn,e=this.#gn=this.#yn().trimEnd();if(t===e)return;const i=t=>{this.#gn=t,t?(this.#_n(),this._uiManager.rebuild(this),this.#wn()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#wn()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(t){this.enterInEditMode()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){mn._keyboardManager.exec(this,t)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){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 t,e;this.width&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#fn),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:i}=this.editorDiv;if(i.fontSize=`calc(${this.#Ks}px * var(--scale-factor))`,i.color=this.#Fs,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),_e(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[r,a]=this.getInitialTranslation();[r,a]=this.pageTranslationToScreen(r,a);const[o,l]=this.pageDimensions,[h,d]=this.pageTranslation;let c,u;switch(this.rotation){case 0:c=t+(n[0]-h)/o,u=e+this.height-(n[1]-d)/l;break;case 90:c=t+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[a,-r];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[r,a]=[-r,-a];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[r,a]=[-a,r]}this.setAt(c*i,u*s,r,a)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#_n(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#An(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(fn,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=mn.#xn(e.getData("text")||"").replaceAll(fn,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const r=n.getRangeAt(0);if(!s.includes("\n"))return r.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:a,startOffset:o}=r,l=[],h=[];if(a.nodeType===Node.TEXT_NODE){const t=a.parentElement;if(h.push(a.nodeValue.slice(o).replaceAll(fn,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(mn.#An(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(fn,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(mn.#An(i))}this.#gn=`${l.join("\n")}${s}${h.join("\n")}`,this.#_n();const d=new Range;let c=l.reduce(((t,e)=>t+e.length),0);for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(c<=e){d.setStart(t,c),d.setEnd(t,c);break}c-=e}n.removeAllRanges(),n.addRange(d)}#_n(){if(this.editorDiv.replaceChildren(),this.#gn)for(const t of this.#gn.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Sn(){return this.#gn.replaceAll(" "," ")}static#xn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Zs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:r,id:a,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:N.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#Ks=t.fontSize,n.#Fs=jt.makeHexColor(...t.color),n.#gn=mn.#xn(t.value),n.annotationElementId=t.id||null,n._initialData=s,n}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=mn._internalPadding*this.parentScale,i=this.getRect(e,e),s=ke._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#Fs),n={annotationType:N.FREETEXT,color:s,fontSize:this.#Ks,value:this.#Sn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Cn(n)?null:(n.id=this.annotationElementId,n)}#Cn(t){const{value:e,fontSize:i,color:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some(((t,e)=>t!==s[e]))||t.pageIndex!==n}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(this.deleted)return e;const{style:i}=e;i.fontSize=`calc(${this.#Ks}px * var(--scale-factor))`,i.color=this.#Fs,e.replaceChildren();for(const t of this.#gn.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=mn._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#gn}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class bn{static PRECISION=1e-4;toSVGPath(){_t("Abstract method `toSVGPath` must be implemented.")}get box(){_t("Abstract getter `box` must be implemented.")}serialize(t,e){_t("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*s,r[a+1]=i+t[a+1]*n;return r}static _rescaleAndSwap(t,e,i,s,n,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*s,r[a+1]=i+t[a]*n;return r}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,r=t.length;n<r;n+=2)s[n]=e+t[n],s[n+1]=i+t[n+1];return s}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,s,n){switch(n){case 90:return[1-e/i,t/s];case 180:return[1-t/i,1-e/s];case 270:return[e/i,1-t/s];default:return[t/i,e/s]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,s,n,r){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+r)/6,(i+n)/2,(s+r)/2]}}class vn{#En;#Pn=[];#Tn;#Mn;#kn=[];#Ln=new Float32Array(18);#In;#Dn;#Rn;#Nn;#Fn;#On;#Bn=[];static#jn=8;static#Vn=2;static#Hn=vn.#jn+vn.#Vn;constructor({x:t,y:e},i,s,n,r,a=0){this.#En=i,this.#On=n*s,this.#Mn=r,this.#Ln.set([NaN,NaN,NaN,NaN,t,e],6),this.#Tn=a,this.#Nn=vn.#jn*s,this.#Rn=vn.#Hn*s,this.#Fn=s,this.#Bn.push(t,e)}isEmpty(){return isNaN(this.#Ln[8])}#zn(){const t=this.#Ln.subarray(4,6),e=this.#Ln.subarray(16,18),[i,s,n,r]=this.#En;return[(this.#In+(t[0]-e[0])/2-i)/n,(this.#Dn+(t[1]-e[1])/2-s)/r,(this.#In+(e[0]-t[0])/2-i)/n,(this.#Dn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#In=t,this.#Dn=e;const[i,s,n,r]=this.#En;let[a,o,l,h]=this.#Ln.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Rn)return!1;const p=u-this.#Nn,g=p/u,f=g*d,m=g*c;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#Bn?.push(t,e);const w=f/p,y=-m/p*this.#On,A=w*this.#On;if(this.#Ln.set(this.#Ln.subarray(2,8),0),this.#Ln.set([l+y,h+A],4),this.#Ln.set(this.#Ln.subarray(14,18),12),this.#Ln.set([l-y,h-A],16),isNaN(this.#Ln[6]))return 0===this.#kn.length&&(this.#Ln.set([a+y,o+A],2),this.#kn.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+A-s)/r),this.#Ln.set([a-y,o-A],14),this.#Pn.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-A-s)/r)),this.#Ln.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Ln.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(m,f))<Math.PI/2?([a,o,l,h]=this.#Ln.subarray(2,6),this.#kn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Ln.subarray(14,18),this.#Pn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Ln.subarray(0,6),this.#kn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),[l,h,a,o,b,v]=this.#Ln.subarray(12,18),this.#Pn.push(((b+5*a)/6-i)/n,((v+5*o)/6-s)/r,((5*a+l)/6-i)/n,((5*o+h)/6-s)/r,((a+l)/2-i)/n,((o+h)/2-s)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#kn,e=this.#Pn;if(isNaN(this.#Ln[6])&&!this.isEmpty())return this.#$n();const i=[];i.push(`M${t[4]} ${t[5]}`);for(let e=6;e<t.length;e+=6)isNaN(t[e])?i.push(`L${t[e+4]} ${t[e+5]}`):i.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);this.#Un(i);for(let t=e.length-6;t>=6;t-=6)isNaN(e[t])?i.push(`L${e[t+4]} ${e[t+5]}`):i.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);return this.#Wn(i),i.join(" ")}#$n(){const[t,e,i,s]=this.#En,[n,r,a,o]=this.#zn();return`M${(this.#Ln[2]-t)/i} ${(this.#Ln[3]-e)/s} L${(this.#Ln[4]-t)/i} ${(this.#Ln[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Ln[16]-t)/i} ${(this.#Ln[17]-e)/s} L${(this.#Ln[14]-t)/i} ${(this.#Ln[15]-e)/s} Z`}#Wn(t){const e=this.#Pn;t.push(`L${e[4]} ${e[5]} Z`)}#Un(t){const[e,i,s,n]=this.#En,r=this.#Ln.subarray(4,6),a=this.#Ln.subarray(16,18),[o,l,h,d]=this.#zn();t.push(`L${(r[0]-e)/s} ${(r[1]-i)/n} L${o} ${l} L${h} ${d} L${(a[0]-e)/s} ${(a[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,r){return new wn(t,e,i,s,n,r)}getOutlines(){const t=this.#kn,e=this.#Pn,i=this.#Ln,[s,n,r,a]=this.#En,o=new Float32Array((this.#Bn?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#Bn[t]-s)/r,o[t+1]=(this.#Bn[t+1]-n)/a;if(o[o.length-2]=(this.#In-s)/r,o[o.length-1]=(this.#Dn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#Gn(o);const l=new Float32Array(this.#kn.length+24+this.#Pn.length);let h=t.length;for(let e=0;e<h;e+=2)isNaN(t[e])?l[e]=l[e+1]=NaN:(l[e]=t[e],l[e+1]=t[e+1]);h=this.#qn(l,h);for(let t=e.length-6;t>=6;t-=6)for(let i=0;i<6;i+=2)isNaN(e[t+i])?(l[h]=l[h+1]=NaN,h+=2):(l[h]=e[t+i],l[h+1]=e[t+i+1],h+=2);return this.#Xn(l,h),this.newFreeDrawOutline(l,o,this.#En,this.#Fn,this.#Tn,this.#Mn)}#Gn(t){const e=this.#Ln,[i,s,n,r]=this.#En,[a,o,l,h]=this.#zn(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/r,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/r,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/r],0),this.newFreeDrawOutline(d,t,this.#En,this.#Fn,this.#Tn,this.#Mn)}#Xn(t,e){const i=this.#Pn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#qn(t,e){const i=this.#Ln.subarray(4,6),s=this.#Ln.subarray(16,18),[n,r,a,o]=this.#En,[l,h,d,c]=this.#zn();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/a,(s[1]-r)/o],e),e+24}}class wn extends bn{#En;#Kn=new Float32Array(4);#Tn;#Mn;#Bn;#Fn;#Yn;constructor(t,e,i,s,n,r){super(),this.#Yn=t,this.#Bn=e,this.#En=i,this.#Fn=s,this.#Tn=n,this.#Mn=r,this.lastPoint=[NaN,NaN],this.#Qn(r);const[a,o,l,h]=this.#Kn;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-a)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-a)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#Yn[4]} ${this.#Yn[5]}`];for(let e=6,i=this.#Yn.length;e<i;e+=6)isNaN(this.#Yn[e])?t.push(`L${this.#Yn[e+4]} ${this.#Yn[e+5]}`):t.push(`C${this.#Yn[e]} ${this.#Yn[e+1]} ${this.#Yn[e+2]} ${this.#Yn[e+3]} ${this.#Yn[e+4]} ${this.#Yn[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const r=i-t,a=s-e;let o,l;switch(n){case 0:o=bn._rescale(this.#Yn,t,s,r,-a),l=bn._rescale(this.#Bn,t,s,r,-a);break;case 90:o=bn._rescaleAndSwap(this.#Yn,t,e,r,a),l=bn._rescaleAndSwap(this.#Bn,t,e,r,a);break;case 180:o=bn._rescale(this.#Yn,i,e,-r,a),l=bn._rescale(this.#Bn,i,e,-r,a);break;case 270:o=bn._rescaleAndSwap(this.#Yn,i,s,-r,-a),l=bn._rescaleAndSwap(this.#Bn,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#Qn(t){const e=this.#Yn;let i=e[4],s=e[5],n=i,r=s,a=i,o=s,l=i,h=s;const d=t?Math.max:Math.min;for(let t=6,c=e.length;t<c;t+=6){if(isNaN(e[t]))n=Math.min(n,e[t+4]),r=Math.min(r,e[t+5]),a=Math.max(a,e[t+4]),o=Math.max(o,e[t+5]),h<e[t+5]?(l=e[t+4],h=e[t+5]):h===e[t+5]&&(l=d(l,e[t+4]));else{const c=jt.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),r=Math.min(r,c[1]),a=Math.max(a,c[2]),o=Math.max(o,c[3]),h<c[3]?(l=c[2],h=c[3]):h===c[3]&&(l=d(l,c[2]))}i=e[t+4],s=e[t+5]}const c=this.#Kn;c[0]=n-this.#Tn,c[1]=r-this.#Tn,c[2]=a-n+2*this.#Tn,c[3]=o-r+2*this.#Tn,this.lastPoint=[l,h]}get box(){return this.#Kn}newOutliner(t,e,i,s,n,r=0){return new vn(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#Kn,[a,o,l,h]=this.#En,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#Bn[0]*d+u,y:this.#Bn[1]*c+p},this.#En,this.#Fn,t,this.#Mn,e??this.#Tn);for(let t=2;t<this.#Bn.length;t+=2)g.add({x:this.#Bn[t]*d+u,y:this.#Bn[t+1]*c+p});return g.getOutlines()}}class yn{#En;#Jn;#Zn=[];#tr=[];constructor(t,e=0,i=0,s=!0){let n=1/0,r=-1/0,a=1/0,o=-1/0;const l=10**-4;for(const{x:i,y:s,width:h,height:d}of t){const t=Math.floor((i-e)/l)*l,c=Math.ceil((i+h+e)/l)*l,u=Math.floor((s-e)/l)*l,p=Math.ceil((s+d+e)/l)*l,g=[t,u,p,!0],f=[c,u,p,!1];this.#Zn.push(g,f),n=Math.min(n,t),r=Math.max(r,c),a=Math.min(a,u),o=Math.max(o,p)}const h=r-n+2*i,d=o-a+2*i,c=n-i,u=a-i,p=this.#Zn.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#Zn){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#En=new Float32Array([c,u,h,d]),this.#Jn=g}getOutlines(){this.#Zn.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#Zn)e[3]?(t.push(...this.#er(e)),this.#ir(e)):(this.#sr(e),t.push(...this.#er(e)));return this.#nr(t)}#nr(t){const e=[],i=new Set;for(const i of t){const[t,s,n]=i;e.push([t,s,i],[t,n,i])}e.sort(((t,e)=>t[1]-e[1]||t[0]-e[0]));for(let t=0,s=e.length;t<s;t+=2){const s=e[t][2],n=e[t+1][2];s.push(n),n.push(s),i.add(s),i.add(n)}const s=[];let n;for(;i.size>0;){const t=i.values().next().value;let[e,r,a,o,l]=t;i.delete(t);let h=e,d=r;for(n=[e,a],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,r,a,o,l]=t,h!==e&&(n.push(h,d,e,d===r?r:a),h=e),d=d===r?a:r}n.push(h,d)}return new An(s,this.#En,this.#Jn)}#rr(t){const e=this.#tr;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,r=e[n][0];if(r===t)return n;r<t?i=n+1:s=n-1}return s+1}#ir([,t,e]){const i=this.#rr(t);this.#tr.splice(i,0,[t,e])}#sr([,t,e]){const i=this.#rr(t);for(let s=i;s<this.#tr.length;s++){const[i,n]=this.#tr[s];if(i!==t)break;if(i===t&&n===e)return void this.#tr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#tr[s];if(i!==t)break;if(i===t&&n===e)return void this.#tr.splice(s,1)}}#er(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#rr(s);for(let t=0;t<r;t++){const[i,s]=this.#tr[t];for(let t=0,r=n.length;t<r;t++){const[,a,o]=n[t];if(!(s<=a||o<=i))if(a>=i)if(o>s)n[t][1]=s;else{if(1===r)return[];n.splice(t,1),t--,r--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class An extends bn{#En;#ar;constructor(t,e,i){super(),this.#ar=t,this.#En=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#ar){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const r=e[n],a=e[n+1];r===i?(t.push(`V${a}`),s=a):a===s&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const r=[],a=i-t,o=s-e;for(const e of this.#ar){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*a,i[n+1]=s-e[n+1]*o;r.push(i)}return r}get box(){return this.#En}get classNamesForOutlining(){return["highlightOutline"]}}class _n extends vn{newFreeDrawOutline(t,e,i,s,n,r){return new xn(t,e,i,s,n,r)}}class xn extends wn{newOutliner(t,e,i,s,n,r=0){return new _n(t,e,i,s,n,r)}}let Sn=class t{#or=null;#lr=null;#hr;#dr=null;#cr=!1;#ur=!1;#r=null;#pr;#gr=null;#f=null;#fr;static#mr=null;static get _keyboardManager(){return Ct(this,"_keyboardManager",new Ee([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:i=null}){e?(this.#ur=!1,this.#fr=F.HIGHLIGHT_COLOR,this.#r=e):(this.#ur=!0,this.#fr=F.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#pr=this.#f._eventBus,this.#hr=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#mr||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const t=this.#or=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.setAttribute("aria-haspopup",!0);const e=this.#f._signal;t.addEventListener("click",this.#br.bind(this),{signal:e}),t.addEventListener("keydown",this.#Ms.bind(this),{signal:e});const i=this.#lr=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#hr,t.append(i),t}renderMainDropdown(){const t=this.#dr=this.#vr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#vr(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",de,{signal:i}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[s,n]of this.#f.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=s,r.setAttribute("data-l10n-id",t.#mr[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.setAttribute("aria-selected",n===this.#hr),r.addEventListener("click",this.#wr.bind(this,n),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#Ms.bind(this),{signal:i}),e}#wr(t,e){e.stopPropagation(),this.#pr.dispatch("switchannotationeditorparams",{source:this,type:this.#fr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#or)return void this.#br(t);const e=t.target.getAttribute("data-color");e&&this.#wr(e,t)}_moveToNext(t){this.#yr?t.target!==this.#or?t.target.nextSibling?.focus():this.#dr.firstChild?.focus():this.#br(t)}_moveToPrevious(t){t.target!==this.#dr?.firstChild&&t.target!==this.#or?(this.#yr||this.#br(t),t.target.previousSibling?.focus()):this.#yr&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#yr?this.#dr.firstChild?.focus():this.#br(t)}_moveToEnd(t){this.#yr?this.#dr.lastChild?.focus():this.#br(t)}#Ms(e){t._keyboardManager.exec(this,e)}#br(t){if(this.#yr)return void this.hideDropdown();if(this.#cr=0===t.detail,this.#gr||(this.#gr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#gr)})),this.#dr)return void this.#dr.classList.remove("hidden");const e=this.#dr=this.#vr();this.#or.append(e)}#h(t){this.#dr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#dr?.classList.add("hidden"),this.#gr?.abort(),this.#gr=null}get#yr(){return this.#dr&&!this.#dr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#ur||(this.#yr?(this.hideDropdown(),this.#or.focus({preventScroll:!0,focusVisible:this.#cr})):this.#r?.unselect())}updateColor(t){if(this.#lr&&(this.#lr.style.backgroundColor=t),!this.#dr)return;const e=this.#f.highlightColors.values();for(const i of this.#dr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#or?.remove(),this.#or=null,this.#lr=null,this.#dr?.remove(),this.#dr=null}};class Cn extends ke{#Ar=null;#_r=0;#xr;#Sr=null;#n=null;#Cr=null;#Er=null;#Pr=0;#Tr=null;#Mr=null;#w=null;#kr=!1;#Jn=null;#Lr;#Ir=null;#Dr="";#On;#Rr="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=N.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Cn.prototype;return Ct(this,"_keyboardManager",new Ee([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||Cn._defaultColor,this.#On=t.thickness||Cn._defaultThickness,this.#Lr=t.opacity||Cn._defaultOpacity,this.#xr=t.boxes||null,this.#Rr=t.methodOfCreation||"",this.#Dr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#kr=!0,this.#Nr(t),this.#Fr()):this.#xr&&(this.#Ar=t.anchorNode,this.#_r=t.anchorOffset,this.#Er=t.focusNode,this.#Pr=t.focusOffset,this.#Or(),this.#Fr(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#kr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#On,methodOfCreation:this.#Rr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#Or(){const t=new yn(this.#xr,.001);this.#Mr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Mr.box;const e=new yn(this.#xr,.0025,.001,"ltr"===this._uiManager.direction);this.#Cr=e.getOutlines();const{lastPoint:i}=this.#Cr;this.#Jn=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Nr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#Mr=t;if(this.#Cr=t.getNewOutline(this.#On/2+1.5,.0025),e>=0)this.#w=e,this.#Sr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Ir=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Cr.box,path:{d:this.#Cr.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:Cn.#Br(this.#Mr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Ir,{bbox:Cn.#Br(this.#Cr.box,e),path:{d:this.#Cr.toSVGPath()}})}const[s,n,r,a]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=r*e/t,this.height=a*t/e;break}}const{lastPoint:o}=this.#Cr;this.#Jn=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){ke.initialize(t,e),Cn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case F.HIGHLIGHT_DEFAULT_COLOR:Cn._defaultColor=e;break;case F.HIGHLIGHT_THICKNESS:Cn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#Jn}updateParams(t,e){switch(t){case F.HIGHLIGHT_COLOR:this.#vn(e);break;case F.HIGHLIGHT_THICKNESS:this.#jr(e)}}static get defaultPropertiesToUpdate(){return[[F.HIGHLIGHT_DEFAULT_COLOR,Cn._defaultColor],[F.HIGHLIGHT_THICKNESS,Cn._defaultThickness]]}get propertiesToUpdate(){return[[F.HIGHLIGHT_COLOR,this.color||Cn._defaultColor],[F.HIGHLIGHT_THICKNESS,this.#On||Cn._defaultThickness],[F.HIGHLIGHT_FREE,this.#kr]]}#vn(t){const e=(t,e)=>{this.color=t,this.#Lr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Lr;this.addCommands({cmd:e.bind(this,t,Cn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#jr(t){const e=this.#On,i=t=>{this.#On=t,this.#Vr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:F.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}async addEditToolbar(){const t=await super.addEditToolbar();return t?(this._uiManager.highlightColors&&(this.#n=new Sn({editor:this}),t.addColorPicker(this.#n)),t):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Hr())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Hr())}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#zr(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Fr(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#zr():t&&(this.#Fr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#Vr(t){if(!this.#kr)return;this.#Nr({highlightOutlines:this.#Mr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#zr(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Ir),this.#Ir=null)}#Fr(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#Sr}=t.drawLayer.draw({bbox:this.#Mr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Lr},rootClass:{highlight:!0,free:this.#kr},path:{d:this.#Mr.toSVGPath()}},!1,!0)),this.#Ir=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#kr},bbox:this.#Cr.box,path:{d:this.#Cr.toSVGPath()}},this.#kr),this.#Tr&&(this.#Tr.style.clipPath=this.#Sr))}static#Br([t,e,i,s],n){switch(n){case 90:return[1-e-s,t,s,i];case 180:return[1-t-i,1-e-s,i,s];case 270:return[e,1-t-i,s,i]}return[t,e,i,s]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#kr?(t=(t-this.rotation+360)%360,i=Cn.#Br(this.#Mr.box,t)):i=Cn.#Br([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Ir,{bbox:Cn.#Br(this.#Cr.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Dr&&(t.setAttribute("aria-label",this.#Dr),t.setAttribute("role","mark")),this.#kr?t.classList.add("free"):this.div.addEventListener("keydown",this.#$r.bind(this),{signal:this._uiManager._signal});const e=this.#Tr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#Sr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),_e(this,this.#Tr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ir,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ir,{rootClass:{hovered:!1}})}#$r(t){Cn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#Ur(!0);break;case 1:case 3:this.#Ur(!1)}}#Ur(t){if(!this.#Ar)return;const e=window.getSelection();t?e.setPosition(this.#Ar,this.#_r):e.setPosition(this.#Er,this.#Pr)}select(){super.select(),this.#Ir&&this.parent?.drawLayer.updateProperties(this.#Ir,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Ir&&(this.parent?.drawLayer.updateProperties(this.#Ir,{rootClass:{selected:!1}}),this.#kr||this.#Ur(!1))}get _mustFixPosition(){return!this.#kr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Ir,{rootClass:{hidden:!t}}))}#Hr(){return this.#kr?this.rotation:0}#Wr(){if(this.#kr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#xr,r=new Float32Array(8*n.length);let a=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;r[a]=r[a+4]=n,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=n+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#Gr(t){return this.#Mr.serialize(t,this.#Hr())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#qr(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",ce,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",de,{signal:d}),i.addEventListener("pointermove",this.#Xr.bind(this,t),{signal:d}),this._freeHighlight=new _n({x:s,y:n},[r,a,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#Xr(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#qr(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(t,e,i){let s=null;if(t instanceof ln){const{data:{quadPoints:e,rect:i,rotation:n,id:r,color:a,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:N.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}else if(t instanceof on){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:N.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:l}}const{color:n,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=jt.makeHexColor(...n),l.#Lr=o||1,a&&(l.#On=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#xr=[];for(let e=0;e<r.length;e+=8)t.push({x:(r[e]-c)/h,y:1-(r[e+1]-u)/d,width:(r[e+2]-r[e])/h,height:(r[e+1]-r[e+5])/d});l.#Or(),l.#Fr(),l.rotate(l.rotation)}else if(a){l.#kr=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new _n(i,[0,0,h,d],1,l.#On/2,!0,.001);for(let e=0,n=t.length;e<n;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),s.add(i);const{id:n,clipPathId:r}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:s.toSVGPath()}},!0,!0);l.#Nr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#Fr()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=ke._colorManager.convert(this.color),s={annotationType:N.HIGHLIGHT,color:i,opacity:this.#Lr,thickness:this.#On,quadPoints:this.#Wr(),outlines:this.#Gr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#Hr(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Cn(s)?null:(s.id=this.annotationElementId,s)}#Cn(t){const{color:e}=this._initialData;return t.color.some(((t,i)=>t!==e[i]))}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class En{#Kr=Object.create(null);updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))this.updateProperty(e,i)}updateSVGProperty(t,e){this.#Kr[t]=e}toSVGProperties(){const t=this.#Kr;return this.#Kr=Object.create(null),{root:t}}reset(){this.#Kr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){_t("Not implemented")}}class Pn extends ke{#Yr=null;#Qr;_drawId=null;static _currentDrawId=-1;static _currentDraw=null;static _currentDrawingOptions=null;static _currentParent=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#Qr=t.mustBeCommitted||!1,t.drawOutlines&&(this.#Jr(t),this.#Fr())}#Jr({drawOutlines:t,drawId:e,drawingOptions:i}){this.#Yr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Zr(t,this.parent),this.#ta(t.box)}#Zr(t,e){const{id:i}=e.drawLayer.draw(Pn._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[s,n]of Object.entries(e))i.has(s)?Object.assign(t[s],n):t[s]=n;return t}static getDefaultDrawingOptions(t){_t("Not implemented")}static get typesMap(){_t("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(t,e){const i=this.typesMap.get(t);i&&this._defaultDrawingOptions.updateProperty(i,e),this._currentParent&&(this._currentDraw.updateProperty(i,e),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const i=this.constructor.typesMap.get(t);i&&this._updateProperty(t,i,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[i,s]of this.typesMap)t.push([i,e[s]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,s]of this.constructor.typesMap)t.push([i,e[s]]);return t}_updateProperty(t,e,i){const s=this._drawingOptions,n=s[e],r=t=>{s.updateProperty(e,t);const i=this.#Yr.updateProperty(e,t);i&&this.#ta(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Pn._mergeSVGProperties(this.#Yr.getPathResizingSVGProperties(this.#ea()),{bbox:this.#ia()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Pn._mergeSVGProperties(this.#Yr.getPathResizedSVGProperties(this.#ea()),{bbox:this.#ia()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#ia(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Pn._mergeSVGProperties(this.#Yr.getPathTranslatedSVGProperties(this.#ea(),this.parentDimensions),{bbox:this.#ia()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#Qr&&(this.#Qr=!1,this.commit(),this.parent.setSelected(this),this.isOnScreen&&this.div.focus())}remove(){this.#zr(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Fr(),this.#ta(this.#Yr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#zr()):t&&(this._uiManager.addShouldRescale(this),this.#Fr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#zr(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#Fr(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Zr(this.#Yr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#sa([t,e,i,s]){const{parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/n),s*(n/r)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(r/n),s*(n/r)];default:return[t,e,i,s]}}#ea(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(n/r),s*(r/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/r),s*(r/n)];default:return[t,e,i,s]}}#ta(t){if([this.x,this.y,this.width,this.height]=this.#sa(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#ia(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*n+r)/90){case 1:return[1-e-s,t,s,i];case 2:return[1-t-i,1-e-s,i,s];case 3:return[e,1-t-i,s,i];case 4:return[t,e-i*(a/o),s*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),s*(o/a)];case 6:return[1-t-s*(o/a),1-e,s*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-s*(o/a),i*(a/o),s*(o/a)];case 8:return[t-i,e-s,i,s];case 9:return[1-e,t-i,s,i];case 10:return[1-t,1-e,i,s];case 11:return[e-s,1-t,s,i];case 12:return[t-s*(o/a),e,s*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-s*(o/a),i*(a/o),s*(o/a)];case 14:return[1-t,1-e-i*(a/o),s*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),s*(o/a)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Pn._mergeSVGProperties({bbox:this.#ia()},this.#Yr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#ta(this.#Yr.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const t=super.render();t.classList.add("draw");const e=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal";const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),this._uiManager.addShouldRescale(this),this.disableEditing(),t}static createDrawerInstance(t,e,i,s,n){_t("Not implemented")}static startDrawing(t,e,i,{target:s,offsetX:n,offsetY:r}){const{viewport:{rotation:a}}=t,{width:o,height:l}=s.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h);window.addEventListener("pointerup",(e=>{h.abort(),t.toggleDrawing(!0),this._endDraw(e)}),{signal:d}),window.addEventListener("pointerdown",ce,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",de,{signal:d}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:d}),t.toggleDrawing(),e._editorUndoBar?.hide(),this._currentDraw?t.drawLayer.updateProperties(this._currentDrawId,this._currentDraw.startNew(n,r,o,l,a)):(e.updateUIForDefaultProperties(this),this._currentDraw=this.createDrawerInstance(n,r,o,l,a),this._currentDrawingOptions=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(this._currentDrawingOptions.toSVGProperties(),this._currentDraw.defaultSVGProperties),!0,!1)))}static _drawMove({offsetX:t,offsetY:e}){this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._currentDraw.add(t,e))}static _endDraw({offsetX:t,offsetY:e}){const i=this._currentParent;if(i.drawLayer.updateProperties(this._currentDrawId,this._currentDraw.end(t,e)),this.supportMultipleDrawings){const t=this._currentDraw,e=this._currentDrawId,s=t.getLastElement();i.addCommands({cmd:()=>{i.drawLayer.updateProperties(e,t.setLastElement(s))},undo:()=>{i.drawLayer.updateProperties(e,t.removeLastElement())},mustExec:!1,type:F.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(F.DRAW_STEP),!this._currentDraw.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:this._currentDraw.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:this._currentDrawingOptions,mustBeCommitted:!t});return this._cleanup(),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(),null}static _cleanup(){this._currentDrawId=-1,this._currentDraw=null,this._currentDrawingOptions=null,this._currentParent=null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,r){_t("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Jr({drawOutlines:o}),l.#Fr(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#Yr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class Tn{#Ln=new Float64Array(6);#Zs;#na;#mi;#On;#Bn;#ra="";#aa=0;#ar=new Mn;#oa;#la;constructor(t,e,i,s,n,r){this.#oa=i,this.#la=s,this.#mi=n,this.#On=r,[t,e]=this.#ha(t,e);const a=this.#Zs=[NaN,NaN,NaN,NaN,t,e];this.#Bn=[t,e],this.#na=[{line:a,points:this.#Bn}],this.#Ln.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#On=e)}#ha(t,e){return bn._normalizePoint(t,e,this.#oa,this.#la,this.#mi)}isEmpty(){return!this.#na||0===this.#na.length}add(t,e){[t,e]=this.#ha(t,e);const[i,s,n,r]=this.#Ln.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#oa*a,this.#la*o)<=2?null:(this.#Bn.push(t,e),isNaN(i)?(this.#Ln.set([n,r,t,e],2),this.#Zs.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Ln[0])&&this.#Zs.splice(6,6),this.#Ln.set([i,s,n,r,t,e],0),this.#Zs.push(...bn.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#Bn.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#oa=i,this.#la=s,this.#mi=n,[t,e]=this.#ha(t,e);const r=this.#Zs=[NaN,NaN,NaN,NaN,t,e];this.#Bn=[t,e];const a=this.#na.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#na.push({line:r,points:this.#Bn}),this.#Ln.set(r,0),this.#aa=0,this.toSVGPath(),null}getLastElement(){return this.#na.at(-1)}setLastElement(t){return this.#na?(this.#na.push(t),this.#Zs=t.line,this.#Bn=t.points,this.#aa=0,{path:{d:this.toSVGPath()}}):this.#ar.setLastElement(t)}removeLastElement(){if(!this.#na)return this.#ar.removeLastElement();this.#na.pop(),this.#ra="";for(let t=0,e=this.#na.length;t<e;t++){const{line:e,points:i}=this.#na[t];this.#Zs=e,this.#Bn=i,this.#aa=0,this.toSVGPath()}return{path:{d:this.#ra}}}toSVGPath(){const t=bn.svgRound(this.#Zs[4]),e=bn.svgRound(this.#Zs[5]);if(2===this.#Bn.length)return this.#ra=`${this.#ra} M ${t} ${e} Z`,this.#ra;if(this.#Bn.length<=6){const i=this.#ra.lastIndexOf("M");this.#ra=`${this.#ra.slice(0,i)} M ${t} ${e}`,this.#aa=6}if(4===this.#Bn.length){const t=bn.svgRound(this.#Zs[10]),e=bn.svgRound(this.#Zs[11]);return this.#ra=`${this.#ra} L ${t} ${e}`,this.#aa=12,this.#ra}const i=[];0===this.#aa&&(i.push(`M ${t} ${e}`),this.#aa=6);for(let t=this.#aa,e=this.#Zs.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#Zs.slice(t,t+6).map(bn.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#ra+=i.join(" "),this.#aa=this.#Zs.length,this.#ra}getOutlines(t,e,i,s){const n=this.#na.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#ar.build(this.#na,t,e,i,this.#mi,this.#On,s),this.#Ln=null,this.#Zs=null,this.#na=null,this.#ra=null,this.#ar}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class Mn extends bn{#Kn;#da=0;#Tn;#na;#oa;#la;#ca;#mi;#On;build(t,e,i,s,n,r,a){this.#oa=e,this.#la=i,this.#ca=s,this.#mi=n,this.#On=r,this.#Tn=a??0,this.#na=t,this.#ua()}setLastElement(t){return this.#na.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#na.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#na)if(t.push(`M${bn.svgRound(e[4])} ${bn.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,r,a,o,l]=e.subarray(i,i+6).map(bn.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${bn.svgRound(e[10])} ${bn.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,d]=this.#pa();let c,u,p,g,f,m,b,v,w;switch(this.#mi){case 0:w=bn._rescale,c=t,u=e+s,p=i,g=-s,f=t+o*i,m=e+(1-l-d)*s,b=t+(o+h)*i,v=e+(1-l)*s;break;case 90:w=bn._rescaleAndSwap,c=t,u=e,p=i,g=s,f=t+l*i,m=e+o*s,b=t+(l+d)*i,v=e+(o+h)*s;break;case 180:w=bn._rescale,c=t+i,u=e,p=-i,g=s,f=t+(1-o-h)*i,m=e+l*s,b=t+(1-o)*i,v=e+(l+d)*s;break;case 270:w=bn._rescaleAndSwap,c=t+i,u=e+s,p=-i,g=-s,f=t+(1-l-d)*i,m=e+(1-o-h)*s,b=t+(1-l)*i,v=e+(1-o)*s}for(const{line:t,points:e}of this.#na)r.push(w(t,c,u,p,g,n?new Array(t.length):null)),a.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:r,points:a,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=bn._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=bn._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=bn._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=bn._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!r){r=[];for(const t of a){const e=t.length;if(2===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){r.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const i=new Float32Array(3*(e-2));r.push(i);let[s,n,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(bn.createBezierPoints(s,n,a,o,e,l),3*(r-2)),[s,n,a,o]=[a,o,e,l]}}}for(let t=0,e=r.length;t<e;t++)h.push({line:g(r[t].map((t=>t??NaN)),d,c,u,p),points:g(a[t].map((t=>t??NaN)),d,c,u,p)});const f=new Mn;return f.build(h,i,s,1,o,l,n),f}#ga(t=this.#On){const e=this.#Tn+t/2*this.#ca;return this.#mi%180==0?[e/this.#oa,e/this.#la]:[e/this.#la,e/this.#oa]}#pa(){const[t,e,i,s]=this.#Kn,[n,r]=this.#ga(0);return[t+n,e+r,i-2*n,s-2*r]}#ua(){const t=this.#Kn=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#na){if(e.length<=12){for(let i=4,s=e.length;i<s;i+=6){const[s,n]=e.subarray(i,i+2);t[0]=Math.min(t[0],s),t[1]=Math.min(t[1],n),t[2]=Math.max(t[2],s),t[3]=Math.max(t[3],n)}continue}let i=e[4],s=e[5];for(let n=6,r=e.length;n<r;n+=6){const[r,a,o,l,h,d]=e.subarray(n,n+6);jt.bezierBoundingBox(i,s,r,a,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#ga();t[0]=Math.min(1,Math.max(0,t[0]-e)),t[1]=Math.min(1,Math.max(0,t[1]-i)),t[2]=Math.min(1,Math.max(0,t[2]+e)),t[3]=Math.min(1,Math.max(0,t[3]+i)),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Kn}updateProperty(t,e){return"stroke-width"===t?this.#jr(e):null}#jr(t){const[e,i]=this.#ga();this.#On=t;const[s,n]=this.#ga(),[r,a]=[s-e,n-i],o=this.#Kn;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#ga();this.#oa=t,this.#la=e,this.#ca=i;const[r,a]=this.#ga(),o=r-s,l=a-n,h=this.#Kn;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#da=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Kn.map(bn.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Kn;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bn.svgRound(t)} ${bn.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Kn;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#da){case 90:s=e/t,n=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${r} ${bn.svgRound(a)} ${bn.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#ga(),[a,o,l,h]=this.#Kn;if(Math.abs(l-n)<=bn.PRECISION||Math.abs(h-r)<=bn.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${bn.svgRound(t)} ${bn.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${r})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*r)/(h-2*r),u=l/i,p=h/s;return{path:{"transform-origin":`${bn.svgRound(a)} ${bn.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${bn.svgRound(n)} ${bn.svgRound(r)}) scale(${d} ${c}) translate(${bn.svgRound(-n)} ${bn.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#ga(),a=this.#Kn,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=bn.PRECISION||Math.abs(d-r)<=bn.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#na)bn._translate(t,n,r,t),bn._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bn.svgRound(t)} ${bn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*r)/(d-2*r),p=-c*(o+n)+t+n,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#na)bn._rescale(t,p,g,c,u,t),bn._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bn.svgRound(t)} ${bn.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#Kn,a=t-r[0],o=e-r[1];if(this.#oa===s&&this.#la===n)for(const{line:t,points:e}of this.#na)bn._translate(t,a,o,t),bn._translate(e,a,o,e);else{const t=this.#oa/s,e=this.#la/n;this.#oa=s,this.#la=n;for(const{line:i,points:s}of this.#na)bn._rescale(i,a,o,t,e,i),bn._rescale(s,a,o,t,e,s);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${bn.svgRound(t)} ${bn.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Kn;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${bn.svgRound(t[0])} ${bn.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class kn extends En{#fa;constructor(t){super(),this.#fa=t,super.updateProperties({fill:"none",stroke:ke._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??=this["stroke-width"],e*=this.#fa.realScale),super.updateSVGProperty(t,e)}clone(){const t=new kn(this.#fa);return t.updateAll(this),t}}class Ln extends Pn{static _type="ink";static _editorType=N.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){ke.initialize(t,e),this._defaultDrawingOptions=new kn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Ct(this,"typesMap",new Map([[F.INK_THICKNESS,"stroke-width"],[F.INK_COLOR,"stroke"],[F.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new Tn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return Mn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof on){const{data:{inkLists:e,rect:i,rotation:n,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:N.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:r,deleted:!1,popupRef:h}}const n=await super.deserialize(t,e,i);return n.annotationElementId=t.id||null,n._initialData=s,n}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:i}=this;e.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:t,thickness:e,opacity:i}){this._drawingOptions=Ln.getDefaultDrawingOptions({stroke:jt.makeHexColor(...t),"stroke-width":e,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:i,rect:s}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":r,"stroke-width":a}}=this,o={annotationType:N.INK,color:ke._colorManager.convert(n),opacity:r,thickness:a,paths:{lines:e,points:i},pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?o:this.annotationElementId&&!this.#Cn(o)?null:(o.id=this.annotationElementId,o)}#Cn(t){const{color:e,thickness:i,opacity:s,pageIndex:n}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||t.color.some(((t,i)=>t!==e[i]))||t.thickness!==i||t.opacity!==s||t.pageIndex!==n}renderAnnotationElement(t){const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e}),null}}class In extends ke{#ma=null;#ba=null;#va=null;#wa=null;#ya=null;#Aa="";#_a=null;#xa=null;#Sa=null;#Ca=!1;#Ea=!1;static _type="stamp";static _editorType=N.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#wa=t.bitmapUrl,this.#ya=t.bitmapFile}static initialize(t,e){ke.initialize(t,e)}static get supportedTypes(){return Ct(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return Ct(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(N.STAMP,{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}#Pa(t,e=!1){t?(this.#ma=t.bitmap,e||(this.#ba=t.id,this.#Ca=t.isSvg),t.file&&(this.#Aa=t.file.name),this.#Ta()):this.remove()}#Ma(){if(this.#va=null,this._uiManager.enableWaiting(!1),this.#_a){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ma)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#ma){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:i}=this._uiManager;if(!i)throw new Error("No ML.");if(!await i.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:s,width:n,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:s,width:n,height:r,channels:s.length/(n*r)}});if(!a)throw new Error("No response from the AI service.");if(a.error)throw new Error("Error from the AI service.");if(a.cancel)return null;if(!a.output)throw new Error("No valid response from the AI service.");const o=a.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#ka(){if(this.#ba)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#ba).then((t=>this.#Pa(t,!0))).finally((()=>this.#Ma()));if(this.#wa){const t=this.#wa;return this.#wa=null,this._uiManager.enableWaiting(!0),void(this.#va=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Pa(t))).finally((()=>this.#Ma())))}if(this.#ya){const t=this.#ya;return this.#ya=null,this._uiManager.enableWaiting(!0),void(this.#va=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Pa(t))).finally((()=>this.#Ma())))}const t=document.createElement("input");t.type="file",t.accept=In.supportedTypesStr;const e=this._uiManager._signal;this.#va=new Promise((i=>{t.addEventListener("change",(async()=>{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Pa(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Ma())),t.click()}remove(){this.#ba&&(this.#ma=null,this._uiManager.imageManager.deleteId(this.#ba),this.#_a?.remove(),this.#_a=null,this.#xa?.disconnect(),this.#xa=null,this.#Sa&&(clearTimeout(this.#Sa),this.#Sa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#ba&&null===this.#_a&&this.#ka(),this.isAttachedToDOM||this.parent.add(this))):this.#ba&&this.#ka()}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#va||this.#ma||this.#wa||this.#ya||this.#ba)}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;if(this.width&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#ma?this.#Ta():this.#ka(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this.div}#Ta(){const{div:t}=this;let{width:e,height:i}=this.#ma;const[s,n]=this.pageDimensions,r=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>r*s||i>r*n){const t=Math.min(r*s/e,r*n/i);e*=t,i*=t}const[a,o]=this.parentDimensions;this.setDims(e*a/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#_a=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#La(e,i),this.#Ia(),this.#Ea||(this.parent.addUndoableEditor(this),this.#Ea=!0),this._reportTelemetry({action:"inserted_image"}),this.#Aa&&l.setAttribute("aria-label",this.#Aa)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#ma,r=new we;let a=this.#ma,o=s,l=n,h=null;if(e){if(s>e||n>e){const t=Math.min(e/s,e/n);o=Math.floor(s*t),l=Math.floor(n*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#Ca||(a=this.#Da(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(c="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,f=p*r.sy,m=new OffscreenCanvas(2*g,2*f),b=m.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*f),b.fillStyle=u,b.fillRect(0,0,g,f),b.fillRect(g,f,g,f),d.fillStyle=d.createPattern(m,"repeat"),d.fillRect(0,0,t,i),d.drawImage(a,0,0,a.width,a.height,0,0,t,i)}let d=null;if(i){let e,i;if(r.symmetric&&a.width<t&&a.height<t)e=a.width,i=a.height;else if(a=this.#ma,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ca||(a=this.#Da(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(a,0,0,a.width,a.height,0,0,e,i),d={width:e,height:i,data:o.getImageData(0,0,e,i).data}}return{canvas:h,width:o,height:l,imageData:d}}#Ra(t,e){const[i,s]=this.parentDimensions;this.width=t/i,this.height=e/s,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#Sa&&clearTimeout(this.#Sa);this.#Sa=setTimeout((()=>{this.#Sa=null,this.#La(t,e)}),200)}#Da(t,e){const{width:i,height:s}=this.#ma;let n=i,r=s,a=this.#ma;for(;n>2*t||r>2*e;){const i=n,s=r;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2));const o=new OffscreenCanvas(n,r);o.getContext("2d").drawImage(a,0,0,i,s,0,0,n,r),a=o.transferToImageBitmap()}return a}#La(t,e){const i=new we,s=Math.ceil(t*i.sx),n=Math.ceil(e*i.sy),r=this.#_a;if(!r||r.width===s&&r.height===n)return;r.width=s,r.height=n;const a=this.#Ca?this.#ma:this.#Da(s,n),o=r.getContext("2d");o.filter=this._uiManager.hcmFilter,o.drawImage(a,0,0,a.width,a.height,0,0,s,n)}getImageForAltText(){return this.#_a}#Na(t){if(t){if(this.#Ca){const t=this._uiManager.imageManager.getSvgUrl(this.#ba);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#ma);return t.getContext("2d").drawImage(this.#ma,0,0),t.toDataURL()}if(this.#Ca){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*te.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*te.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#ma,0,0,this.#ma.width,this.#ma.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#ma)}#Ia(){this._uiManager._signal&&(this.#xa=new ResizeObserver((t=>{const e=t[0].contentRect;e.width&&e.height&&this.#Ra(e.width,e.height)})),this.#xa.observe(this.div),this._uiManager._signal.addEventListener("abort",(()=>{this.#xa?.disconnect(),this.#xa=null}),{once:!0}))}static async deserialize(t,e,i){let s=null;if(t instanceof un){const{data:{rect:n,rotation:r,id:a,structParent:o,popupRef:l},container:h,parent:{page:{pageNumber:d}}}=t,c=h.querySelector("canvas"),u=i.imageManager.getFromCanvas(h.id,c);c.remove();const p=(await e._structTree.getAriaAttributes(`${$t}${a}`))?.get("aria-label")||"";s=t={annotationType:N.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:r,id:a,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:r,bitmap:a,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#ba=l,a&&(n.#ma=a)):n.#wa=o,n.#Ca=h;const[c,u]=n.pageDimensions;return n.width=(r[2]-r[0])/c,n.height=(r[3]-r[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Ea=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:N.STAMP,bitmapId:this.#ba,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ca,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#Na(!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:s,altText:n}=this.serializeAltText(!1);if(!s&&n&&(i.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=this.#Cn(i);if(t.isSame)return null;t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,null===e)return i;e.stamps||=new Map;const r=this.#Ca?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#ba)){if(this.#Ca){const t=e.stamps.get(this.#ba);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Na(!1))}}else e.stamps.set(this.#ba,{area:r,serialized:i}),i.bitmap=this.#Na(!1);return i}#Cn(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,s=t.pageIndex===e,n=(t.accessibilityData?.alt||"")===i;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&s&&n,isSameAltText:n}}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}}let Dn=class t{#ln;#Fa=!1;#Oa=null;#Ba=null;#ja=null;#Va=new Map;#Ha=!1;#za=!1;#$a=null;#Ua=null;#Wa=null;#f;static _initialized=!1;static#H=new Map([mn,Ln,In,Cn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#H.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#f=e,this.pageIndex=i,this.div=s,this.#ln=r,this.#Oa=a,this.viewport=h,this.#Ua=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#Va.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===N.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#Ga(),e){case N.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case N.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case N.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:i}=this.div;for(const s of t.#H.values())i.toggle(`${s._type}Editing`,e===s._editorType);this.div.hidden=!1}hasTextLayer(t){return t===this.#Ua?.div}setEditingState(t){this.#f.setEditingState(t)}addCommands(t){this.#f.addCommands(t)}cleanUndoStack(t){this.#f.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Oa?.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#Va.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#Oa)return;const e=this.#Oa.getEditableAnnotations();for(const i of e){if(i.hide(),this.#f.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}}disable(){this.#za=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#Va.values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),this.getEditableAnnotation(t.annotationElementId)?.show(),t.remove()):e.set(t.annotationElementId,t));if(this.#Oa){const t=this.#Oa.getEditableAnnotations();for(const s of t){const{id:t}=s.data;if(this.#f.isDeletedAnnotationElement(t))continue;let n=i.get(t);n?(n.resetAnnotationElement(s),n.show(!1),s.show()):(n=e.get(t),n&&(this.#f.addChangedExistingAnnotation(n),n.renderAnnotationElement(s)&&n.show(!1)),s.show())}}this.#Ga(),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const e of t.#H.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#za=!1}getEditableAnnotation(t){return this.#Oa?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Ua?.div&&!this.#Wa){this.#Wa=new AbortController;const t=this.#f.combinedSignal(this.#Wa);this.#Ua.div.addEventListener("pointerdown",this.#qa.bind(this),{signal:t}),this.#Ua.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Ua?.div&&this.#Wa&&(this.#Wa.abort(),this.#Wa=null,this.#Ua.div.classList.remove("highlighting"))}#qa(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#Ua.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#Ua.div.contains(e)){const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#Ua.div.classList.add("free"),this.toggleDrawing(),Cn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#Ua.div,x:t.x,y:t.y}),this.#Ua.div.addEventListener("pointerup",(()=>{this.#Ua.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#Ba)return;this.#Ba=new AbortController;const t=this.#f.combinedSignal(this.#Ba);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){this.#Ba?.abort(),this.#Ba=null}attach(t){this.#Va.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#Va.delete(t.id),this.#ln?.removePointerInTextLayer(t.contentDiv),!this.#za&&t.annotationElementId&&this.#f.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#f.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#f.addDeletedAnnotationElement(t.annotationElementId),ke.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),t.parent?.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(t.parent!==this||!t.isAttachedToDOM){if(this.changeParent(t),this.#f.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#ja&&(t._focusEventsAllowed=!1,this.#ja=setTimeout((()=>{this.#ja=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",(()=>{t._focusEventsAllowed=!0}),{once:!0,signal:this.#f._signal}),e.focus())}),0)),t._structTreeParentId=this.#ln?.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||=this,t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return this.#f.getId()}get#Xa(){return t.#H.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#Ka(t){const e=this.#Xa;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#Xa?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#Ya(),n=this.getNextId(),r=this.#Ka({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});r&&this.add(r)}async deserialize(e){return await(t.#H.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#f))||null}createAndAddNewEditor(t,e,i={}){const s=this.getNextId(),n=this.#Ka({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#Ya(){const{x:t,y:e,width:i,height:s}=this.div.getBoundingClientRect(),n=Math.max(0,t),r=Math.max(0,e),a=(n+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#Ya(),!0)}setSelected(t){this.#f.setSelected(t)}toggleSelected(t){this.#f.toggleSelected(t)}unselect(t){this.#f.unselect(t)}pointerup(t){const{isMac:e}=Ot.platform;0!==t.button||t.ctrlKey&&e||t.target===this.div&&this.#Ha&&(this.#Ha=!1,this.#Xa?.isDrawer&&this.#Xa.supportMultipleDrawings||(this.#Fa?this.#f.getMode()!==N.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#Fa=!0))}pointerdown(t){if(this.#f.getMode()===N.HIGHLIGHT&&this.enableTextSelection(),this.#Ha)return void(this.#Ha=!1);const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#Ha=!0,this.#Xa?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#Fa=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#$a)return void this.#Xa.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#$a=new AbortController;const e=this.#f.combinedSignal(this.#$a);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&this.commitOrRemove()}),{signal:e}),this.#Xa.startDrawing(this,this.#f,!1,t)}endDrawingSession(t=!1){return this.#$a?(this.#f.setCurrentDrawingSession(null),this.#$a.abort(),this.#$a=null,this.#Xa.endDrawing(t)):null}findNewParent(t,e,i){const s=this.#f.findParent(e,i);return null!==s&&s!==this&&(s.changeParent(t),!0)}commitOrRemove(){return!!this.#$a&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#$a&&this.#Xa.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#ja&&(clearTimeout(this.#ja),this.#ja=null);for(const t of this.#Va.values())this.#ln?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#Va.clear(),this.#f.removeLayer(this)}#Ga(){for(const t of this.#Va.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,ve(this.div,t);for(const t of this.#f.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#f.commitOrRemove(),this.#Ga();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,ve(this.div,{rotation:i}),e!==i)for(const t of this.#Va.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},Rn=class t{#Vs=null;#w=0;#Qa=new Map;#Ja=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#Vs){if(this.#Vs!==t){if(this.#Qa.size>0)for(const e of this.#Qa.values())e.remove(),t.append(e);this.#Vs=t}}else this.#Vs=t}static get _svgFactory(){return Ct(this,"_svgFactory",new Ns)}static#Za(t,[e,i,s,n]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*s+"%",r.height=100*n+"%"}#to(){const e=t._svgFactory.create(1,1,!0);return this.#Vs.append(e),e.setAttribute("aria-hidden",!0),e}#eo(e,i){const s=t._svgFactory.createElement("clipPath");e.append(s);const n=`clip_${i}`;s.setAttribute("id",n),s.setAttribute("clipPathUnits","objectBoundingBox");const r=t._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${i}`),r.classList.add("clip"),n}#io(t,e){for(const[i,s]of Object.entries(e))null===s?t.removeAttribute(i):t.setAttribute(i,s)}draw(e,i=!1,s=!1){const n=this.#w++,r=this.#to(),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#Ja.set(n,o);const h=s?this.#eo(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#Qa.set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#to(),r=t._svgFactory.createElement("defs");n.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;let l;if(a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");r.append(e),l=`mask_p${this.pageIndex}_${s}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const i=t._svgFactory.createElement("rect");e.append(i),i.setAttribute("width","1"),i.setAttribute("height","1"),i.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,e),this.#Qa.set(s,n),s}finalizeDraw(t,e){this.#Ja.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:s,bbox:n,rootClass:r,path:a}=i,o="number"==typeof e?this.#Qa.get(e):e;if(o){if(s&&this.#io(o,s),n&&t.#Za(o,n),r){const{classList:t}=o;for(const[e,i]of Object.entries(r))t.toggle(e,i)}if(a){const t=o.firstChild.firstChild;this.#io(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Qa.get(t);i&&(e.#Vs.append(i),this.#Qa.delete(t),e.#Qa.set(t,i))}remove(t){this.#Ja.delete(t),null!==this.#Vs&&(this.#Qa.get(t).remove(),this.#Qa.delete(t))}destroy(){this.#Vs=null;for(const t of this.#Qa.values())t.remove();this.#Qa.clear(),this.#Ja.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:yn};var Nn=A.AnnotationEditorParamsType,Fn=A.AnnotationEditorType,On=A.AnnotationMode,Bn=A.GlobalWorkerOptions,jn=A.PDFDateString,Vn=A.PixelsPerInch,Hn=A.RenderingCancelledException,zn=A.getDocument,$n=A.getPdfFilenameFromUrl,Un=A.getXfaPageViewport,Wn={d:(t,e)=>{for(var i in e)Wn.o(e,i)&&!Wn.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},Gn=globalThis.pdfjsViewer={};Wn.d(Gn,{AnnotationLayerBuilder:()=>Da,DownloadManager:()=>Na,EventBus:()=>Ba,FindState:()=>Cr,GenericL10n:()=>tl,LinkTarget:()=>Vr,PDFFindController:()=>jr,PDFHistory:()=>il,PDFLinkService:()=>Hr,PDFPageView:()=>Sl,PDFScriptingManager:()=>Pl,PDFSinglePageViewer:()=>Nl,PDFViewer:()=>Rl,ProgressBar:()=>pr,RenderingStates:()=>qn,ScrollMode:()=>er,SimpleLinkService:()=>zr,SpreadMode:()=>ir,StructTreeLayerBuilder:()=>bl,TextLayerBuilder:()=>yl,XfaLayerBuilder:()=>Al,parseQueryString:()=>nr});const qn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Xn=0,Kn=1,Yn=2,Qn=3,Jn=0,Zn=1,tr=2,er={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},ir={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function sr(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n}function nr(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const rr=/[\x00-\x1F]/g;function ar(t,e=!1){return rr.test(t)?e?t.replaceAll(rr,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function or(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function lr(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s}function hr(t,e){return t-t%e}function dr(t){return Number.isInteger(t)&&t%90==0}function cr(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const ur=document.documentElement.style;let pr=class{#so=null;#no=null;#ro=0;#ao=null;#ei=!0;constructor(t){this.#so=t.classList,this.#ao=t.style}get percent(){return this.#ro}set percent(t){var e,i,s;this.#ro=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#so.add("indeterminate"):(this.#so.remove("indeterminate"),this.#ao.setProperty("--progressBar-percent",`${this.#ro}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#ao.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#ro||isNaN(this.#ro)||(this.#no&&clearTimeout(this.#no),this.show(),this.#no=setTimeout((()=>{this.#no=null,this.hide()}),t))}hide(){this.#ei&&(this.#ei=!1,this.#so.add("hidden"))}show(){this.#ei||(this.#ei=!0,this.#so.remove("hidden"))}};const gr=function(){const t=document.createElement("div");return t.style.width="round(down, calc(1.6666666666666665 * 792px), 1px)","calc(1320px)"===t.style.width?Math.fround:t=>t}(),fr=0,mr=1,br=2,vr=3,wr=4,yr=5,Ar=6,_r=7;function xr(t){return function(t){return t<11904}(t)?function(t){return!(65408&t)}(t)?function(t){return 32===t||9===t||13===t||10===t}(t)?fr:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?mr:br:function(t){return 3584==(65408&t)}(t)?_r:160===t?fr:mr:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?vr:function(t){return t>=12448&&t<=12543}(t)?wr:function(t){return t>=12352&&t<=12447}(t)?yr:function(t){return t>=65376&&t<=65439}(t)?Ar:mr}let Sr;const Cr={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},Er={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Pr=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 Tr;const Mr=/\p{M}+/gu,kr=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,Lr=/([^\p{M}])\p{M}*$/u,Ir=/^\p{M}*([^\p{M}])/u,Dr=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Rr=new Map,Nr=new Map;let Fr=null,Or=null;function Br(t){const e=[];let i,s;for(;null!==(i=Dr.exec(t));){let{index:t}=i;for(const s of i[0]){let i=Rr.get(s);i||(i=s.normalize("NFD").length,Rr.set(s,i)),e.push([i,t++])}}if(0===e.length&&Fr)s=Fr;else if(e.length>0&&Or)s=Or;else{const t=`([${Object.keys(Er).join("")}])|([${Sr||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",Sr}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;s=0===e.length?Fr=new RegExp(t+"|(\\u0000)","gum"):Or=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=Mr.exec(t));)n.push([i[0].length,i.index]);let r=t.normalize("NFD");const a=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;r=r.replace(s,((t,i,s,r,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=Er[i],e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=Nr.get(s);t||(t=s.normalize("NFKC"),Nr.set(s,t));const e=t.length;for(let t=1;t<e;t++)a.push(w-h+t,h-t);return h-=e-1,t}if(r)return u=!0,w+c===n[o]?.[1]?++o:(a.push(w-1-h+1,h-1),h-=1,d+=1),a.push(w-h+1,h),d+=1,c+=1,r.charAt(0);if(p){const t=p.endsWith("\n"),e=t?p.length-2:p.length;u=!0;let i=e;w+c===n[o]?.[1]&&(i-=n[o][0],++o);for(let t=1;t<=i;t++)a.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,a.push(w-h+1,1+h),h+=1,d+=1,c+=1,p.slice(0,e)):p}if(g)return d+=1,c+=1,g.replace("\n","");if(f){const t=f.length-2;return a.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return a.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return a.push(w-h+1,h-1),h-=1,d+=1,c+=1," ";if(w+c===e[l]?.[1]){const t=e[l][0]-1;++l;for(let e=1;e<=t;e++)a.push(w-(h-e),h-e);h-=t,d+=t}return v})),a.push(r.length,h);const p=new Uint32Array(a.length>>1),g=new Int32Array(a.length>>1);for(let t=0,e=a.length;t<e;t+=2)p[t>>1]=a[t],g[t>>1]=a[t+1];return[r,[p,g],u]}class jr{#oo=null;#lo=!0;#ho=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#lo=i,this.onIsPageVisible=null,this.#do(),e._on("find",this.#co.bind(this)),e._on("findbarclose",this.#uo.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.#oo}setDocument(t){this._pdfDocument&&this.#do(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#co(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#oo||this.#po(t))&&(this._dirtyMatch=!0),this.#oo=t,"highlightallchange"!==i&&this.#go(Cr.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#yn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#fo():"again"===i?(this.#fo(),t&&this.#oo.highlightAll&&this.#mo()):"highlightallchange"===i?(s?this.#fo():this._highlightMatches=!0,this.#mo()):this.#fo():this._findTimeout=setTimeout((()=>{this.#fo(),this._findTimeout=null}),250)}))}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:s=-1}){if(!this._scrollMatches||!t)return;if(-1===s||s!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;sr(t,{top:-50,left:e+-400},!0)}#do(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#ho=0,this.#oo=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=Promise.withResolvers()}get#bo(){const{query:t}=this.#oo;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=Br(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>Br(t)[0]))}#po(t){const e=t.query,i=this.#oo.query,s=typeof e;if(s!==typeof i)return!0;if("string"===s){if(e!==i)return!0}else if(JSON.stringify(e)!==JSON.stringify(i))return!0;switch(t.type){case"again":const t=this._selected.pageIdx+1,e=this._linkService;return t>=1&&t<=e.pagesCount&&t!==e.page&&!(this.onIsPageVisible?.(t)??1);case"highlightallchange":return!1}return!0}#vo(t,e,i){let s=t.slice(0,e).match(Lr);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(xr(i)===xr(n))return!1}if(s=t.slice(e+i).match(Ir),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(xr(n)===xr(r))return!1}return!0}#wo(t,e){const{matchDiacritics:i}=this.#oo;let s=!1;const n="[ ]*";return(t=t.replaceAll(kr,((t,n,r,a,o,l)=>n?`[ ]*\\${n}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?Pr.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(Tr||=String.fromCharCode(...Pr),s=!0,t=`${t}(?=[${Tr}]|[^\\p{M}]|$)`),[s,t]}#yo(t){const e=this.#bo;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];s?.forEach((({index:t,length:e})=>{const[i,s]=function(t,e,i){if(!t)return[e,i];const[s,n]=t,r=e,a=e+i-1;let o=or(s,(t=>t>=r));s[o]>r&&--o;let l=or(s,(t=>t>=a),o);s[l]>a&&--l;const h=r+n[o];return[h,a+n[l]+1-h]}(a,t,e);s&&(n.push(i),r.push(s))})),this.#oo.highlightAll&&this.#Ao(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#_o());const o=n.length;this._matchesCountTotal+=o,this.#lo?o>0&&this.#xo():++this.#ho===this._linkService.pagesCount&&this.#xo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#wo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#wo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#oo;t=new RegExp(t,`g${n?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#vo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#yn(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0};for(let i=0,s=this._linkService.pagesCount;i<s;i++){const{promise:s,resolve:n}=Promise.withResolvers();this._extractTextPromises[i]=s,t=t.then((()=>this._pdfDocument.getPage(i+1).then((t=>t.getTextContent(e))).then((t=>{const e=[];for(const i of t.items)e.push(i.str),i.hasEOL&&e.push("\n");[this._pageContents[i],this._pageDiffs[i],this._hasDiacritics[i]]=Br(e.join("")),n()}),(t=>{console.error(`Unable to get text content for page ${i+1}`,t),this._pageContents[i]="",this._pageDiffs[i]=null,this._hasDiacritics[i]=!1,n()}))))}}#Ao(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#mo(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#fo(){const t=this.#oo.findPrevious,e=this._linkService.page-1,i=this._linkService.pagesCount;if(this._highlightMatches=!0,this._dirtyMatch){this._dirtyMatch=!1,this._selected.pageIdx=this._selected.matchIdx=-1,this._offset.pageIdx=e,this._offset.matchIdx=null,this._offset.wrapped=!1,this._resumePageIdx=null,this._pageMatches.length=0,this._pageMatchesLength.length=0,this.#ho=0,this._matchesCountTotal=0,this.#mo();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#yo(t)})))}if(0===this.#bo.length)return void this.#go(Cr.FOUND);if(this._resumePageIdx)return;const s=this._offset;if(this._pagesToSearch=i,null!==s.matchIdx){const e=this._pageMatches[s.pageIdx].length;if(!t&&s.matchIdx+1<e||t&&s.matchIdx>0)return s.matchIdx=t?s.matchIdx-1:s.matchIdx+1,void this.#So(!0);this.#Co(t)}this.#_o()}#Eo(t){const e=this._offset,i=t.length,s=this.#oo.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#So(!0),!0):(this.#Co(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#So(!1),!0))}#_o(){null!==this._resumePageIdx&&console.error("There can only be one pending page.");let t=null;do{const e=this._offset.pageIdx;if(t=this._pageMatches[e],!t){this._resumePageIdx=e;break}}while(!this.#Eo(t))}#Co(t){const e=this._offset,i=this._linkService.pagesCount;e.pageIdx=t?e.pageIdx-1:e.pageIdx+1,e.matchIdx=null,this._pagesToSearch--,(e.pageIdx>=i||e.pageIdx<0)&&(e.pageIdx=t?i-1:0,e.wrapped=!0)}#So(t=!1){let e=Cr.NOT_FOUND;const i=this._offset.wrapped;if(this._offset.wrapped=!1,t){const t=this._selected.pageIdx;this._selected.pageIdx=this._offset.pageIdx,this._selected.matchIdx=this._offset.matchIdx,e=i?Cr.WRAPPED:Cr.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Ao(t)}this.#go(e,this.#oo.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Ao(this._selected.pageIdx))}#uo(t){const e=this._pdfDocument;this._firstPageCapability.promise.then((()=>{!this._pdfDocument||e&&this._pdfDocument!==e||(this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),this._resumePageIdx&&(this._resumePageIdx=null,this._dirtyMatch=!0),this.#go(Cr.FOUND),this._highlightMatches=!1,this.#mo())}))}#Po(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,s=this._matchesCountTotal;if(-1!==e){for(let e=0;e<t;e++)i+=this._pageMatches[e]?.length||0;i+=e+1}return(i<1||i>s)&&(i=s=0),{current:i,total:s}}#xo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Po()})}#go(t,e=!1){(this.#lo||this.#ho===this._linkService.pagesCount&&t!==Cr.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#oo?.entireWord??null,matchesCount:this.#Po(),rawQuery:this.#oo?.query??null})}}const Vr={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Hr{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:s=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=s,this.baseUrl=null,this.pdfDocument=null,this.pdfViewer=null,this.pdfHistory=null}setDocument(t,e=null){this.baseUrl=e,this.pdfDocument=t}setViewer(t){this.pdfViewer=t}setHistory(t){this.pdfHistory=t}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return this.pdfDocument?this.pdfViewer.currentPageNumber:1}set page(t){this.pdfDocument&&(this.pdfViewer.currentPageNumber=t)}get rotation(){return this.pdfDocument?this.pdfViewer.pagesRotation:0}set rotation(t){this.pdfDocument&&(this.pdfViewer.pagesRotation=t)}get isInPresentationMode(){return!!this.pdfDocument&&this.pdfViewer.isInPresentationMode}async goToDestination(t){if(!this.pdfDocument)return;let e,i,s;if("string"==typeof t?(e=t,i=await this.pdfDocument.getDestination(t)):(e=null,i=await t),!Array.isArray(i))return void console.error(`goToDestination: "${i}" is not a valid destination array, for dest="${t}".`);const[n]=i;if(n&&"object"==typeof n){if(s=this.pdfDocument.cachedPageNumber(n),!s)try{s=await this.pdfDocument.getPageIndex(n)+1}catch{return void console.error(`goToDestination: "${n}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(n)&&(s=n+1);!s||s<1||s>this.pagesCount?console.error(`goToDestination: "${s}" is not a valid page number, for dest="${t}".`):(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:s})),this.pdfViewer.scrollPageIntoView({pageNumber:s,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom}))}goToPage(t){if(!this.pdfDocument)return;const e="string"==typeof t&&this.pdfViewer.pageLabelToPageNumber(t)||0|t;Number.isInteger(e)&&e>0&&e<=this.pagesCount?(this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.pushPage(e)),this.pdfViewer.scrollPageIntoView({pageNumber:e})):console.error(`PDFLinkService.goToPage: "${t}" is not a valid page.`)}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const s=i?Vr.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(s){case Vr.NONE:break;case Vr.SELF:r="_self";break;case Vr.BLANK:r="_blank";break;case Vr.PARENT:r="_parent";break;case Vr.TOP:r="_top"}t.target=r,t.rel="string"==typeof n?n:"noopener noreferrer nofollow"}getDestinationHash(t){if("string"==typeof t){if(t.length>0)return this.getAnchorUrl("#"+escape(t))}else if(Array.isArray(t)){const e=JSON.stringify(t);if(e.length>0)return this.getAnchorUrl("#"+escape(e))}return this.getAnchorUrl("")}getAnchorUrl(t){return this.baseUrl?this.baseUrl+t:t}setHash(t){if(!this.pdfDocument)return;let e,i;if(t.includes("=")){const s=nr(t);if(s.has("search")){const t=s.get("search").replaceAll('"',""),e="true"===s.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(s.has("page")&&(e=0|s.get("page")||1),s.has("zoom")){const t=s.get("zoom").split(","),e=t[0],n=parseFloat(e);e.includes("Fit")?"Fit"===e||"FitB"===e?i=[null,{name:e}]:"FitH"===e||"FitBH"===e||"FitV"===e||"FitBV"===e?i=[null,{name:e},t.length>1?0|t[1]:null]:"FitR"===e?5!==t.length?console.error('PDFLinkService.setHash: Not enough parameters for "FitR".'):i=[null,{name:e},0|t[1],0|t[2],0|t[3],0|t[4]]:console.error(`PDFLinkService.setHash: "${e}" is not a valid zoom value.`):i=[null,{name:"XYZ"},t.length>1?0|t[1]:null,t.length>2?0|t[2]:null,n?n/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),s.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:s.get("pagemode")}),void(s.has("nameddest")&&this.goToDestination(s.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||Hr.#To(i)?this.goToDestination(i):console.error(`PDFLinkService.setHash: "${unescape(t)}" is not a valid destination.`)}executeNamedAction(t){if(this.pdfDocument){switch(t){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:t})}}async executeSetOCGState(t){if(!this.pdfDocument)return;const e=this.pdfDocument,i=await this.pdfViewer.optionalContentConfigPromise;e===this.pdfDocument&&(i.setOCGState(t),this.pdfViewer.optionalContentConfigPromise=Promise.resolve(i))}static#To(t){if(!Array.isArray(t)||t.length<2)return!1;const[e,i,...s]=t;if(!("object"==typeof e&&Number.isInteger(e?.num)&&Number.isInteger(e?.gen)||Number.isInteger(e)))return!1;if("object"!=typeof i||"string"!=typeof i?.name)return!1;const n=s.length;let r=!0;switch(i.name){case"XYZ":if(n<2||n>3)return!1;break;case"Fit":case"FitB":return 0===n;case"FitH":case"FitBH":case"FitV":case"FitBV":if(n>1)return!1;break;case"FitR":if(4!==n)return!1;r=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||r&&null===t))return!1;return!0}}class zr extends Hr{setDocument(t,e=null){}}const{AbortException:$r,AnnotationEditorLayer:Ur,AnnotationEditorParamsType:Wr,AnnotationEditorType:Gr,AnnotationEditorUIManager:qr,AnnotationLayer:Xr,AnnotationMode:Kr,build:Yr,ColorPicker:Qr,createValidAbsoluteUrl:Jr,DOMSVGFactory:Zr,DrawLayer:ta,FeatureTest:ea,fetchData:ia,getDocument:sa,getFilenameFromUrl:na,getPdfFilenameFromUrl:ra,getXfaPageViewport:aa,GlobalWorkerOptions:oa,ImageKind:la,InvalidPDFException:ha,isDataScheme:da,isPdfFile:ca,MissingPDFException:ua,noContextMenu:pa,normalizeUnicode:ga,OPS:fa,OutputScale:ma,PasswordResponses:ba,PDFDataRangeTransport:va,PDFDateString:wa,PDFWorker:ya,PermissionFlag:Aa,PixelsPerInch:_a,RenderingCancelledException:xa,setLayerDimensions:Sa,shadow:Ca,stopEvent:Ea,TextLayer:Pa,UnexpectedResponseException:Ta,Util:Ma,VerbosityLevel:ka,version:La,XfaLayer:Ia}=globalThis.pdfjsLib;class Da{#Mo=null;#ko=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:r=!0,enableScripting:a=!1,hasJSActionsPromise:o=null,fieldObjectsPromise:l=null,annotationCanvasMap:h=null,accessibilityManager:d=null,annotationEditorUIManager:c=null,onAppend:u=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=n,this.renderForms=r,this.annotationStorage=s,this.enableScripting=a,this._hasJSActionsPromise=o||Promise.resolve(!1),this._fieldObjectsPromise=l||Promise.resolve(null),this._annotationCanvasMap=h,this._accessibilityManager=d,this._annotationEditorUIManager=c,this.#Mo=u,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render(t,e,i="display"){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[s,n,r]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");a.className="annotationLayer",this.#Mo?.(a),0!==s.length?(this.annotationLayer=new Xr({div:a,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e?.structTreeLayer||null}),await this.annotationLayer.render({annotations:s,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,linkService:this.linkService,downloadManager:this.downloadManager,annotationStorage:this.annotationStorage,enableScripting:this.enableScripting,hasJSActions:n,fieldObjects:r}),this.linkService.isInPresentationMode&&this.#Lo(Qn),this.#ko||(this.#ko=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#Lo(t.state)}),{signal:this.#ko.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#ko?.abort(),this.#ko=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#Lo(t){if(!this.div)return;let e=!1;switch(t){case Qn:e=!0;break;case Kn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function Ra(t,e){const i=document.createElement("a");if(!i.click)throw new Error('DownloadManager: "a.click()" is not supported.');i.href=t,i.target="_parent","download"in i&&(i.download=e),(document.body||document.documentElement).append(i),i.click(),i.remove()}class Na{#Io=new WeakMap;downloadData(t,e,i){Ra(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=ca(e)?"application/pdf":"";return this.downloadData(t,e,s),!1}download(t,e,i){let s;if(t)s=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!Jr(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}Ra(s,i)}}const Fa="event",Oa="timeout";class Ba{#ss=Object.create(null);on(t,e,i=null){this._on(t,e,{external:!0,once:i?.once,signal:i?.signal})}off(t,e,i=null){this._off(t,e)}dispatch(t,e){const i=this.#ss[t];if(!i||0===i.length)return;let s;for(const{listener:n,external:r,once:a}of i.slice(0))a&&this._off(t,n),r?(s||=[]).push(n):n(e);if(s){for(const t of s)t(e);s=null}}_on(t,e,i=null){let s=null;if(i?.signal instanceof AbortSignal){const{signal:n}=i;if(n.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(t,e);s=()=>n.removeEventListener("abort",r),n.addEventListener("abort",r)}(this.#ss[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#ss[t];if(s)for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i.listener===e)return i.rmAbort?.(),void s.splice(t,1)}}}class ja{constructor(t){this.value=t}valueOf(){return this.value}}class Va extends ja{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Ha extends ja{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),this.value.toString(10)}}}class za extends ja{constructor(t,e={}){super(t),this.opts=e}toString(t){try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){return t.reportError(e),new Date(this.value).toISOString()}}}function $a(t,e,i){if(i===e)return!0;if(i instanceof Ha&&e instanceof Ha&&i.value===e.value)return!0;if(e instanceof Ha&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Ua(t,e,i){return e[i]?Xa(t,e[i].value):(t.reportError(new RangeError("No default")),new Va)}function Wa(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=Ga(t,n.value):i.push(Ga(t,n));return{positional:i,named:s}}function Ga(t,e){switch(e.type){case"str":return e.value;case"num":return new Ha(e.value,{minimumFractionDigits:e.precision});case"var":return function(t,{name:e}){let i;if(t.params){if(!Object.prototype.hasOwnProperty.call(t.params,e))return new Va(`$${e}`);i=t.params[e]}else{if(!t.args||!Object.prototype.hasOwnProperty.call(t.args,e))return t.reportError(new ReferenceError(`Unknown variable: $${e}`)),new Va(`$${e}`);i=t.args[e]}if(i instanceof ja)return i;switch(typeof i){case"string":return i;case"number":return new Ha(i);case"object":if(i instanceof Date)return new za(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new Va(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){const s=t.bundle._messages.get(e);if(!s)return t.reportError(new ReferenceError(`Unknown message: ${e}`)),new Va(e);if(i){const n=s.attributes[i];return n?Xa(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new Va(`${e}.${i}`))}if(s.value)return Xa(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new Va(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,r=t.bundle._terms.get(n);if(!r)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new Va(n);if(i){const e=r.attributes[i];if(e){t.params=Wa(t,s).named;const i=Xa(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new Va(`${n}.${i}`)}t.params=Wa(t,s).named;const a=Xa(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let s=t.bundle._functions[e];if(!s)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new Va(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new Va(`${e}()`);try{let e=Wa(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new Va(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=Ga(t,e);if(n instanceof Va)return Ua(t,i,s);for(const e of i){if($a(t,n,Ga(t,e.key)))return Xa(t,e.value)}return Ua(t,i,s)}(t,e);default:return new Va}}function qa(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new Va;t.dirty.add(e);const i=[],s=t.bundle._useIsolating&&e.length>1;for(const n of e)if("string"!=typeof n){if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),new RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);s&&i.push("⁨"),i.push(Ga(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Xa(t,e){return"string"==typeof e?t.bundle._transform(e):qa(t,e)}class Ka{constructor(t,e,i){this.dirty=new WeakSet,this.params=null,this.placeables=0,this.bundle=t,this.errors=e,this.args=i}reportError(t){if(!(this.errors&&t instanceof Error))throw t;this.errors.push(t)}memoizeIntlObject(t,e){let i=this.bundle._intls.get(t);i||(i={},this.bundle._intls.set(t,i));let s=JSON.stringify(e);return i[s]||(i[s]=new t(this.bundle.locales,e)),i[s]}}function Ya(t,e){const i=Object.create(null);for(const[s,n]of Object.entries(t))e.includes(s)&&(i[s]=n.valueOf());return i}const Qa=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Ja(t,e){let i=t[0];if(i instanceof Va)return new Va(`NUMBER(${i.valueOf()})`);if(i instanceof Ha)return new Ha(i.valueOf(),{...i.opts,...Ya(e,Qa)});if(i instanceof za)return new Ha(i.valueOf(),{...Ya(e,Qa)});throw new TypeError("Invalid argument to NUMBER")}const Za=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function to(t,e){let i=t[0];if(i instanceof Va)return new Va(`DATETIME(${i.valueOf()})`);if(i instanceof za)return new za(i.valueOf(),{...i.opts,...Ya(e,Za)});if(i instanceof Ha)return new za(i.valueOf(),{...Ya(e,Za)});throw new TypeError("Invalid argument to DATETIME")}const eo=new Map;class io{constructor(t,{functions:e,useIsolating:i=!0,transform:s=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:Ja,DATETIME:to,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=eo.get(e);return void 0===i&&(i=new Map,eo.set(e,i)),i}(t)}hasMessage(t){return this._messages.has(t)}getMessage(t){return this._messages.get(t)}addResource(t,{allowOverrides:e=!1}={}){const i=[];for(let s=0;s<t.body.length;s++){let n=t.body[s];if(n.id.startsWith("-")){if(!1===e&&this._terms.has(n.id)){i.push(new Error(`Attempt to override an existing term: "${n.id}"`));continue}this._terms.set(n.id,n)}else{if(!1===e&&this._messages.has(n.id)){i.push(new Error(`Attempt to override an existing message: "${n.id}"`));continue}this._messages.set(n.id,n)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let s=new Ka(this,i,e);try{return qa(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new Va).toString(s);throw t}}}const so=/^(-?[a-zA-Z][\w-]*) *= */gm,no=/\.([a-zA-Z][\w-]*) *= */y,ro=/\*?\[/y,ao=/(-?[0-9]+(?:\.([0-9]+))?)/y,oo=/([a-zA-Z][\w-]*)/y,lo=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,ho=/^[A-Z][A-Z0-9_-]*$/,co=/([^{}\n\r]+)/y,uo=/([^\\"\n\r]*)/y,po=/\\([\\"])/y,go=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,fo=/^\n+/,mo=/ +$/,bo=/ *\r?\n/g,vo=/( *)$/,wo=/{\s*/y,yo=/\s*}/y,Ao=/\[\s*/y,_o=/\s*] */y,xo=/\s*\(\s*/y,So=/\s*->\s*/y,Co=/\s*:\s*/y,Eo=/\s*,?\s*/y,Po=/\s+/y;class To{constructor(t){this.body=[],so.lastIndex=0;let e=0;for(;;){let i=so.exec(t);if(null===i)break;e=so.lastIndex;try{this.body.push(o(i[1]))}catch(t){if(t instanceof SyntaxError)continue;throw t}}function i(i){return i.lastIndex=e,i.test(t)}function s(i,s){if(t[e]===i)return e++,!0;if(s)throw new s(`Expected ${i}`);return!1}function n(t,s){if(i(t))return e=t.lastIndex,!0;if(s)throw new s(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function a(t){return r(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(no);){let e=a(no),i=l();if(null===i)throw new SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(s).length)throw new SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:s}}function l(){let s;if(i(co)&&(s=a(co)),"{"===t[e]||"}"===t[e])return h(s?[s]:[],1/0);let n=b();return n?s?h([s,n],n.length):(n.value=v(n.value,fo),h([n],n.length)):s?v(s,mo):null}function h(s=[],n){for(;;){if(i(co)){s.push(a(co));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;s.push(r),n=Math.min(n,r.length)}let r=s.length-1,o=s[r];"string"==typeof o&&(s[r]=v(o,mo));let l=[];for(let t of s)t instanceof Mo&&(t=t.value.slice(0,t.value.length-n)),t&&l.push(t);return l}function d(){n(wo,SyntaxError);let t=c();if(n(yo))return t;if(n(So)){let e=function(){let t,e=[],n=0;for(;i(ro);){s("*")&&(t=n);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:r}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(yo,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(lo)){let[,i,s,a=null]=r(lo);if("$"===i)return{type:"var",name:s};if(n(xo)){let r=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(Eo)}}();if("-"===i)return{type:"term",name:s,attr:a,args:r};if(ho.test(s))return{type:"func",name:s,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:a,args:[]}:{type:"mesg",name:s,attr:a}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(Co)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(Ao,SyntaxError),t=i(ao)?f():{type:"str",value:a(oo)},n(_o,SyntaxError),t}function g(){if(i(ao))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=a(uo),"\\"!==t[e]){if(s('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=m()}}();throw new SyntaxError("Invalid expression")}function f(){let[,t,e=""]=r(ao),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(po))return a(po);if(i(go)){let[,t,e]=r(go),i=parseInt(t||e,16);return i<=55295||57344<=i?String.fromCodePoint(i):"�"}throw new SyntaxError("Unknown escape sequence")}function b(){let i=e;switch(n(Po),t[e]){case".":case"[":case"*":case"}":case void 0:return!1;case"{":return w(t.slice(i,e))}return" "===t[e-1]&&w(t.slice(i,e))}function v(t,e){return t.replace(e,"")}function w(t){let e=t.replace(bo,"\n"),i=vo.exec(t)[1].length;return new Mo(e,i)}}}class Mo{constructor(t,e){this.value=t,this.length=e}}const ko=/<|&#?\w+;/,Lo={"http://www.w3.org/1999/xhtml":["em","strong","small","s","cite","q","dfn","abbr","data","time","code","var","samp","kbd","sub","sup","i","b","u","mark","bdi","bdo","span","br","wbr"]},Io={"http://www.w3.org/1999/xhtml":{global:["title","aria-label","aria-valuetext"],a:["download"],area:["download","alt"],input:["alt","placeholder"],menuitem:["label"],menu:["label"],optgroup:["label"],option:["label"],track:["label"],img:["alt"],textarea:["placeholder"],th:["abbr"]},"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul":{global:["accesskey","aria-label","aria-valuetext","label","title","tooltiptext"],description:["value"],key:["key","keycode"],label:["value"],textbox:["placeholder","value"]}};function Do(t,e){const{value:i}=e;if("string"==typeof i)if("title"===t.localName&&"http://www.w3.org/1999/xhtml"===t.namespaceURI)t.textContent=i;else if(ko.test(i)){const e=t.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","template");e.innerHTML=i,function(t,e){for(const i of t.childNodes)if(i.nodeType!==i.TEXT_NODE)if(i.hasAttribute("data-l10n-name")){const s=Fo(e,i);t.replaceChild(s,i)}else if(jo(i)){const e=Oo(i);t.replaceChild(e,i)}else console.warn(`An element of forbidden type "${i.localName}" was found in the translation. Only safe text-level elements and elements with data-l10n-name are allowed.`),t.replaceChild(Bo(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;No(e,t)}function Ro(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function No(t,e){const i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map((t=>t.trim())):null;for(const s of Array.from(e.attributes))Vo(s.name,e,i)&&!Ro(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))Vo(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function Fo(t,e){const i=e.getAttribute("data-l10n-name"),s=t.querySelector(`[data-l10n-name="${i}"]`);if(!s)return console.warn(`An element named "${i}" wasn't found in the source.`),Bo(e);if(s.localName!==e.localName)return console.warn(`An element named "${i}" was found in the translation but its type ${e.localName} didn't match the element found in the source (${s.localName}).`),Bo(e);t.removeChild(s);return Ho(e,s.cloneNode(!1))}function Oo(t){const e=t.ownerDocument.createElement(t.localName);return Ho(t,e)}function Bo(t){return t.ownerDocument.createTextNode(t.textContent)}function jo(t){const e=Lo[t.namespaceURI];return e&&e.includes(t.localName)}function Vo(t,e,i=null){if(i&&i.includes(t))return!0;const s=Io[e.namespaceURI];if(!s)return!1;const n=t.toLowerCase(),r=e.localName;if(s.global.includes(n))return!0;if(!s[r])return!1;if(s[r].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function Ho(t,e){return e.textContent=t.textContent,No(t,e),e}class zo extends Array{static from(t){return t instanceof this?t:new this(t)}}class $o extends zo{constructor(t){if(super(),Symbol.asyncIterator in Object(t))this.iterator=t[Symbol.asyncIterator]();else{if(!(Symbol.iterator in Object(t)))throw new TypeError("Argument must implement the iteration protocol.");this.iterator=t[Symbol.iterator]()}}[Symbol.asyncIterator](){const t=this;let e=0;return{next:async()=>(t.length<=e&&t.push(t.iterator.next()),t[e++])}}async touchNext(t=1){let e=0;for(;e++<t;){const t=this[this.length-1];if(t&&(await t).done)break;this.push(this.iterator.next())}return this[this.length-1]}}class Uo{constructor(t=[],e){this.resourceIds=t,this.generateBundles=e,this.onChange(!0)}addResourceIds(t,e=!1){return this.resourceIds.push(...t),this.onChange(e),this.resourceIds.length}removeResourceIds(t){return this.resourceIds=this.resourceIds.filter((e=>!t.includes(e))),this.onChange(),this.resourceIds.length}async formatWithFallback(t,e){const i=[];let s=!1;for await(const n of this.bundles){s=!0;const r=qo(e,n,t,i);if(0===r.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return s||"undefined"==typeof console||console.warn(`[fluent] Request for keys failed because no resource bundles got generated.\n keys: ${JSON.stringify(t)}.\n resourceIds: ${JSON.stringify(this.resourceIds)}.`),i}formatMessages(t){return this.formatWithFallback(t,Go)}formatValues(t){return this.formatWithFallback(t,Wo)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=$o.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Wo(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function Go(t,e,i,s){const n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let r=Object.keys(i.attributes);if(r.length>0){n.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=t.formatPattern(i.attributes[o],s,e);n.attributes[a]={name:o,value:r}}}return n}function qo(t,e,i,s){const n=[],r=new Set;return i.forEach((({id:i,args:a},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,a),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else r.add(i)})),r}const Xo="data-l10n-id",Ko="data-l10n-args",Yo=`[${Xo}]`;class Qo extends Uo{constructor(t,e){super(t,e),this.roots=new Set,this.pendingrAF=null,this.pendingElements=new Set,this.windowElement=null,this.mutationObserver=null,this.observerConfig={attributes:!0,characterData:!1,childList:!0,subtree:!0,attributeFilter:[Xo,Ko]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Xo,e),i?t.setAttribute(Ko,JSON.stringify(i)):t.removeAttribute(Ko),t}getAttributes(t){return{id:t.getAttribute(Xo),args:JSON.parse(t.getAttribute(Ko)||null)}}connectRoot(t){for(const e of this.roots)if(e===t||e.contains(t)||t.contains(e))throw new Error("Cannot add a root that overlaps with existing root.");if(this.windowElement){if(this.windowElement!==t.ownerDocument.defaultView)throw new Error("Cannot connect a root:\n DOMLocalization already has a root from a different window.")}else this.windowElement=t.ownerDocument.defaultView,this.mutationObserver=new this.windowElement.MutationObserver((t=>this.translateMutations(t)));this.roots.add(t),this.mutationObserver.observe(t,this.observerConfig)}disconnectRoot(t){return this.roots.delete(t),this.pauseObserving(),0===this.roots.size?(this.mutationObserver=null,this.windowElement&&this.pendingrAF&&this.windowElement.cancelAnimationFrame(this.pendingrAF),this.windowElement=null,this.pendingrAF=null,this.pendingElements.clear(),!0):(this.resumeObserving(),!1)}translateRoots(){const t=Array.from(this.roots);return Promise.all(t.map((t=>this.translateFragment(t))))}pauseObserving(){this.mutationObserver&&(this.translateMutations(this.mutationObserver.takeRecords()),this.mutationObserver.disconnect())}resumeObserving(){if(this.mutationObserver)for(const t of this.roots)this.mutationObserver.observe(t,this.observerConfig)}translateMutations(t){for(const e of t)switch(e.type){case"attributes":e.target.hasAttribute("data-l10n-id")&&this.pendingElements.add(e.target);break;case"childList":for(const t of e.addedNodes)if(t.nodeType===t.ELEMENT_NODE)if(t.childElementCount)for(const e of this.getTranslatables(t))this.pendingElements.add(e);else t.hasAttribute(Xo)&&this.pendingElements.add(t)}this.pendingElements.size>0&&null===this.pendingrAF&&(this.pendingrAF=this.windowElement.requestAnimationFrame((()=>{this.translateElements(Array.from(this.pendingElements)),this.pendingElements.clear(),this.pendingrAF=null})))}translateFragment(t){return this.translateElements(this.getTranslatables(t))}async translateElements(t){if(!t.length)return;const e=t.map(this.getKeysForElement),i=await this.formatMessages(e);return this.applyTranslations(t,i)}applyTranslations(t,e){this.pauseObserving();for(let i=0;i<t.length;i++)void 0!==e[i]&&Do(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Yo));return"function"==typeof t.hasAttribute&&t.hasAttribute(Xo)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Xo),args:JSON.parse(t.getAttribute(Ko)||null)}}}class Jo{#Do;#js;#di;#Ro;constructor({lang:t,isRTL:e},i=null){this.#di=Jo.#No(t),this.#Ro=i,this.#Do=e??Jo.#Fo(this.#di)?"rtl":"ltr"}_setL10n(t){this.#Ro=t}getLanguage(){return this.#di}getDirection(){return this.#Do}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#Ro.formatMessages(t)).map((t=>t.value))}const s=await this.#Ro.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#js||=new Set).add(t);try{this.#Ro.connectRoot(t),await this.#Ro.translateRoots()}catch{}}async translateOnce(t){try{await this.#Ro.translateElements([t])}catch(t){console.error(`translateOnce: "${t}".`)}}async destroy(){if(this.#js){for(const t of this.#js)this.#Ro.disconnectRoot(t);this.#js.clear(),this.#js=null}this.#Ro.pauseObserving()}pause(){this.#Ro.pauseObserving()}resume(){this.#Ro.resumeObserving()}static#No(t){return{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=t?.toLowerCase()||"en-us"]||t}static#Fo(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Zo(t,e){const i=new To(e),s=new io(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class tl extends Jo{constructor(t){super({lang:t});const e=t?tl.#Oo.bind(tl,"en-us",this.getLanguage()):tl.#Bo.bind(tl,this.getLanguage());this._setL10n(new Qo([],e))}static async*#Oo(t,e){const{baseURL:i,paths:s}=await this.#jo(),n=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&n.push(i),n.push(t)}for(const t of n){const e=await this.#Vo(t,i,s);e?yield e:"en-us"===t&&(yield this.#Ho(t))}}static async#Vo(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return Zo(t,await ia(n,"text"))}static async#jo(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await ia(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#Bo(t){yield this.#Ho(t)}static async#Ho(t){return Zo(t,'pdfjs-previous-button =\n .title = Previous Page\npdfjs-previous-button-label = Previous\npdfjs-next-button =\n .title = Next Page\npdfjs-next-button-label = Next\npdfjs-page-input =\n .title = Page\npdfjs-of-pages = of { $pagesCount }\npdfjs-page-of-pages = ({ $pageNumber } of { $pagesCount })\npdfjs-zoom-out-button =\n .title = Zoom Out\npdfjs-zoom-out-button-label = Zoom Out\npdfjs-zoom-in-button =\n .title = Zoom In\npdfjs-zoom-in-button-label = Zoom In\npdfjs-zoom-select =\n .title = Zoom\npdfjs-presentation-mode-button =\n .title = Switch to Presentation Mode\npdfjs-presentation-mode-button-label = Presentation Mode\npdfjs-open-file-button =\n .title = Open File\npdfjs-open-file-button-label = Open\npdfjs-print-button =\n .title = Print\npdfjs-print-button-label = Print\npdfjs-save-button =\n .title = Save\npdfjs-save-button-label = Save\npdfjs-download-button =\n .title = Download\npdfjs-download-button-label = Download\npdfjs-bookmark-button =\n .title = Current Page (View URL from Current Page)\npdfjs-bookmark-button-label = Current Page\npdfjs-tools-button =\n .title = Tools\npdfjs-tools-button-label = Tools\npdfjs-first-page-button =\n .title = Go to First Page\npdfjs-first-page-button-label = Go to First Page\npdfjs-last-page-button =\n .title = Go to Last Page\npdfjs-last-page-button-label = Go to Last Page\npdfjs-page-rotate-cw-button =\n .title = Rotate Clockwise\npdfjs-page-rotate-cw-button-label = Rotate Clockwise\npdfjs-page-rotate-ccw-button =\n .title = Rotate Counterclockwise\npdfjs-page-rotate-ccw-button-label = Rotate Counterclockwise\npdfjs-cursor-text-select-tool-button =\n .title = Enable Text Selection Tool\npdfjs-cursor-text-select-tool-button-label = Text Selection Tool\npdfjs-cursor-hand-tool-button =\n .title = Enable Hand Tool\npdfjs-cursor-hand-tool-button-label = Hand Tool\npdfjs-scroll-page-button =\n .title = Use Page Scrolling\npdfjs-scroll-page-button-label = Page Scrolling\npdfjs-scroll-vertical-button =\n .title = Use Vertical Scrolling\npdfjs-scroll-vertical-button-label = Vertical Scrolling\npdfjs-scroll-horizontal-button =\n .title = Use Horizontal Scrolling\npdfjs-scroll-horizontal-button-label = Horizontal Scrolling\npdfjs-scroll-wrapped-button =\n .title = Use Wrapped Scrolling\npdfjs-scroll-wrapped-button-label = Wrapped Scrolling\npdfjs-spread-none-button =\n .title = Do not join page spreads\npdfjs-spread-none-button-label = No Spreads\npdfjs-spread-odd-button =\n .title = Join page spreads starting with odd-numbered pages\npdfjs-spread-odd-button-label = Odd Spreads\npdfjs-spread-even-button =\n .title = Join page spreads starting with even-numbered pages\npdfjs-spread-even-button-label = Even Spreads\npdfjs-document-properties-button =\n .title = Document Properties…\npdfjs-document-properties-button-label = Document Properties…\npdfjs-document-properties-file-name = File name:\npdfjs-document-properties-file-size = File size:\npdfjs-document-properties-size-kb = { NUMBER($kb, maximumSignificantDigits: 3) } KB ({ $b } bytes)\npdfjs-document-properties-size-mb = { NUMBER($mb, maximumSignificantDigits: 3) } MB ({ $b } bytes)\npdfjs-document-properties-title = Title:\npdfjs-document-properties-author = Author:\npdfjs-document-properties-subject = Subject:\npdfjs-document-properties-keywords = Keywords:\npdfjs-document-properties-creation-date = Creation Date:\npdfjs-document-properties-modification-date = Modification Date:\npdfjs-document-properties-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-document-properties-creator = Creator:\npdfjs-document-properties-producer = PDF Producer:\npdfjs-document-properties-version = PDF Version:\npdfjs-document-properties-page-count = Page Count:\npdfjs-document-properties-page-size = Page Size:\npdfjs-document-properties-page-size-unit-inches = in\npdfjs-document-properties-page-size-unit-millimeters = mm\npdfjs-document-properties-page-size-orientation-portrait = portrait\npdfjs-document-properties-page-size-orientation-landscape = landscape\npdfjs-document-properties-page-size-name-a-three = A3\npdfjs-document-properties-page-size-name-a-four = A4\npdfjs-document-properties-page-size-name-letter = Letter\npdfjs-document-properties-page-size-name-legal = Legal\npdfjs-document-properties-page-size-dimension-string = { $width } × { $height } { $unit } ({ $orientation })\npdfjs-document-properties-page-size-dimension-name-string = { $width } × { $height } { $unit } ({ $name }, { $orientation })\npdfjs-document-properties-linearized = Fast Web View:\npdfjs-document-properties-linearized-yes = Yes\npdfjs-document-properties-linearized-no = No\npdfjs-document-properties-close-button = Close\npdfjs-print-progress-message = Preparing document for printing…\npdfjs-print-progress-percent = { $progress }%\npdfjs-print-progress-close-button = Cancel\npdfjs-printing-not-supported = Warning: Printing is not fully supported by this browser.\npdfjs-printing-not-ready = Warning: The PDF is not fully loaded for printing.\npdfjs-toggle-sidebar-button =\n .title = Toggle Sidebar\npdfjs-toggle-sidebar-notification-button =\n .title = Toggle Sidebar (document contains outline/attachments/layers)\npdfjs-toggle-sidebar-button-label = Toggle Sidebar\npdfjs-document-outline-button =\n .title = Show Document Outline (double-click to expand/collapse all items)\npdfjs-document-outline-button-label = Document Outline\npdfjs-attachments-button =\n .title = Show Attachments\npdfjs-attachments-button-label = Attachments\npdfjs-layers-button =\n .title = Show Layers (double-click to reset all layers to the default state)\npdfjs-layers-button-label = Layers\npdfjs-thumbs-button =\n .title = Show Thumbnails\npdfjs-thumbs-button-label = Thumbnails\npdfjs-current-outline-item-button =\n .title = Find Current Outline Item\npdfjs-current-outline-item-button-label = Current Outline Item\npdfjs-findbar-button =\n .title = Find in Document\npdfjs-findbar-button-label = Find\npdfjs-additional-layers = Additional Layers\npdfjs-thumb-page-title =\n .title = Page { $page }\npdfjs-thumb-page-canvas =\n .aria-label = Thumbnail of Page { $page }\npdfjs-find-input =\n .title = Find\n .placeholder = Find in document…\npdfjs-find-previous-button =\n .title = Find the previous occurrence of the phrase\npdfjs-find-previous-button-label = Previous\npdfjs-find-next-button =\n .title = Find the next occurrence of the phrase\npdfjs-find-next-button-label = Next\npdfjs-find-highlight-checkbox = Highlight All\npdfjs-find-match-case-checkbox-label = Match Case\npdfjs-find-match-diacritics-checkbox-label = Match Diacritics\npdfjs-find-entire-word-checkbox-label = Whole Words\npdfjs-find-reached-top = Reached top of document, continued from bottom\npdfjs-find-reached-bottom = Reached end of document, continued from top\npdfjs-find-match-count =\n { $total ->\n [one] { $current } of { $total } match\n *[other] { $current } of { $total } matches\n }\npdfjs-find-match-count-limit =\n { $limit ->\n [one] More than { $limit } match\n *[other] More than { $limit } matches\n }\npdfjs-find-not-found = Phrase not found\npdfjs-page-scale-width = Page Width\npdfjs-page-scale-fit = Page Fit\npdfjs-page-scale-auto = Automatic Zoom\npdfjs-page-scale-actual = Actual Size\npdfjs-page-scale-percent = { $scale }%\npdfjs-page-landmark =\n .aria-label = Page { $page }\npdfjs-loading-error = An error occurred while loading the PDF.\npdfjs-invalid-file-error = Invalid or corrupted PDF file.\npdfjs-missing-file-error = Missing PDF file.\npdfjs-unexpected-response-error = Unexpected server response.\npdfjs-rendering-error = An error occurred while rendering the page.\npdfjs-annotation-date-time-string = { DATETIME($dateObj, dateStyle: "short", timeStyle: "medium") }\npdfjs-text-annotation-type =\n .alt = [{ $type } Annotation]\npdfjs-password-label = Enter the password to open this PDF file.\npdfjs-password-invalid = Invalid password. Please try again.\npdfjs-password-ok-button = OK\npdfjs-password-cancel-button = Cancel\npdfjs-web-fonts-disabled = Web fonts are disabled: unable to use embedded PDF fonts.\npdfjs-editor-free-text-button =\n .title = Text\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-ink-button-label = Draw\npdfjs-editor-stamp-button =\n .title = Add or edit images\npdfjs-editor-stamp-button-label = Add or edit images\npdfjs-editor-highlight-button =\n .title = Highlight\npdfjs-editor-highlight-button-label = Highlight\npdfjs-highlight-floating-button1 =\n .title = Highlight\n .aria-label = Highlight\npdfjs-highlight-floating-button-label = Highlight\npdfjs-editor-remove-ink-button =\n .title = Remove drawing\npdfjs-editor-remove-freetext-button =\n .title = Remove text\npdfjs-editor-remove-stamp-button =\n .title = Remove image\npdfjs-editor-remove-highlight-button =\n .title = Remove highlight\npdfjs-editor-free-text-color-input = Color\npdfjs-editor-free-text-size-input = Size\npdfjs-editor-ink-color-input = Color\npdfjs-editor-ink-thickness-input = Thickness\npdfjs-editor-ink-opacity-input = Opacity\npdfjs-editor-stamp-add-image-button =\n .title = Add image\npdfjs-editor-stamp-add-image-button-label = Add image\npdfjs-editor-free-highlight-thickness-input = Thickness\npdfjs-editor-free-highlight-thickness-title =\n .title = Change thickness when highlighting items other than text\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-ink =\n .aria-label = Draw Editor\npdfjs-ink-canvas =\n .aria-label = User-created image\npdfjs-editor-alt-text-button =\n .aria-label = Alt text\npdfjs-editor-alt-text-button-label = Alt text\npdfjs-editor-alt-text-edit-button =\n .aria-label = Edit alt text\npdfjs-editor-alt-text-dialog-label = Choose an option\npdfjs-editor-alt-text-dialog-description = Alt text (alternative text) helps when people can’t see the image or when it doesn’t load.\npdfjs-editor-alt-text-add-description-label = Add a description\npdfjs-editor-alt-text-add-description-description = Aim for 1-2 sentences that describe the subject, setting, or actions.\npdfjs-editor-alt-text-mark-decorative-label = Mark as decorative\npdfjs-editor-alt-text-mark-decorative-description = This is used for ornamental images, like borders or watermarks.\npdfjs-editor-alt-text-cancel-button = Cancel\npdfjs-editor-alt-text-save-button = Save\npdfjs-editor-alt-text-decorative-tooltip = Marked as decorative\npdfjs-editor-alt-text-textarea =\n .placeholder = For example, “A young man sits down at a table to eat a meal”\npdfjs-editor-resizer-top-left =\n .aria-label = Top left corner — resize\npdfjs-editor-resizer-top-middle =\n .aria-label = Top middle — resize\npdfjs-editor-resizer-top-right =\n .aria-label = Top right corner — resize\npdfjs-editor-resizer-middle-right =\n .aria-label = Middle right — resize\npdfjs-editor-resizer-bottom-right =\n .aria-label = Bottom right corner — resize\npdfjs-editor-resizer-bottom-middle =\n .aria-label = Bottom middle — resize\npdfjs-editor-resizer-bottom-left =\n .aria-label = Bottom left corner — resize\npdfjs-editor-resizer-middle-left =\n .aria-label = Middle left — resize\npdfjs-editor-highlight-colorpicker-label = Highlight color\npdfjs-editor-colorpicker-button =\n .title = Change color\npdfjs-editor-colorpicker-dropdown =\n .aria-label = Color choices\npdfjs-editor-colorpicker-yellow =\n .title = Yellow\npdfjs-editor-colorpicker-green =\n .title = Green\npdfjs-editor-colorpicker-blue =\n .title = Blue\npdfjs-editor-colorpicker-pink =\n .title = Pink\npdfjs-editor-colorpicker-red =\n .title = Red\npdfjs-editor-highlight-show-all-button-label = Show all\npdfjs-editor-highlight-show-all-button =\n .title = Show all\npdfjs-editor-new-alt-text-dialog-edit-label = Edit alt text (image description)\npdfjs-editor-new-alt-text-dialog-add-label = Add alt text (image description)\npdfjs-editor-new-alt-text-textarea =\n .placeholder = Write your description here…\npdfjs-editor-new-alt-text-description = Short description for people who can’t see the image or when the image doesn’t load.\npdfjs-editor-new-alt-text-disclaimer1 = This alt text was created automatically and may be inaccurate.\npdfjs-editor-new-alt-text-disclaimer-learn-more-url = Learn more\npdfjs-editor-new-alt-text-create-automatically-button-label = Create alt text automatically\npdfjs-editor-new-alt-text-not-now-button = Not now\npdfjs-editor-new-alt-text-error-title = Couldn’t create alt text automatically\npdfjs-editor-new-alt-text-error-description = Please write your own alt text or try again later.\npdfjs-editor-new-alt-text-error-close-button = Close\npdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\n .aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)\npdfjs-editor-new-alt-text-added-button =\n .aria-label = Alt text added\npdfjs-editor-new-alt-text-added-button-label = Alt text added\npdfjs-editor-new-alt-text-missing-button =\n .aria-label = Missing alt text\npdfjs-editor-new-alt-text-missing-button-label = Missing alt text\npdfjs-editor-new-alt-text-to-review-button =\n .aria-label = Review alt text\npdfjs-editor-new-alt-text-to-review-button-label = Review alt text\npdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer = Created automatically: { $generatedAltText }\npdfjs-image-alt-text-settings-button =\n .title = Image alt text settings\npdfjs-image-alt-text-settings-button-label = Image alt text settings\npdfjs-editor-alt-text-settings-dialog-label = Image alt text settings\npdfjs-editor-alt-text-settings-automatic-title = Automatic alt text\npdfjs-editor-alt-text-settings-create-model-button-label = Create alt text automatically\npdfjs-editor-alt-text-settings-create-model-description = Suggests descriptions to help people who can’t see the image or when the image doesn’t load.\npdfjs-editor-alt-text-settings-download-model-label = Alt text AI model ({ $totalSize } MB)\npdfjs-editor-alt-text-settings-ai-model-description = Runs locally on your device so your data stays private. Required for automatic alt text.\npdfjs-editor-alt-text-settings-delete-model-button = Delete\npdfjs-editor-alt-text-settings-download-model-button = Download\npdfjs-editor-alt-text-settings-downloading-model-button = Downloading…\npdfjs-editor-alt-text-settings-editor-title = Alt text editor\npdfjs-editor-alt-text-settings-show-dialog-button-label = Show alt text editor right away when adding an image\npdfjs-editor-alt-text-settings-show-dialog-description = Helps you make sure all your images have alt text.\npdfjs-editor-alt-text-settings-close-button = Close\npdfjs-editor-undo-bar-message-highlight = Highlight removed\npdfjs-editor-undo-bar-message-freetext = Text removed\npdfjs-editor-undo-bar-message-ink = Drawing removed\npdfjs-editor-undo-bar-message-stamp = Image removed\npdfjs-editor-undo-bar-message-multiple =\n { $count ->\n [one] { $count } annotation removed\n *[other] { $count } annotations removed\n }\npdfjs-editor-undo-bar-undo-button =\n .title = Undo\npdfjs-editor-undo-bar-undo-button-label = Undo\npdfjs-editor-undo-bar-close-button =\n .title = Close\npdfjs-editor-undo-bar-close-button-label = Close')}}function el(){return document.location.hash}class il{#ko=null;constructor({linkService:t,eventBus:e}){this.linkService=t,this.eventBus=e,this._initialized=!1,this._fingerprint="",this.reset(),this.eventBus._on("pagesinit",(()=>{this._isPagesLoaded=!1,this.eventBus._on("pagesloaded",(t=>{this._isPagesLoaded=!!t.pagesCount}),{once:!0})}))}initialize({fingerprint:t,resetHistory:e=!1,updateUrl:i=!1}){if(!t||"string"!=typeof t)return void console.error('PDFHistory.initialize: The "fingerprint" must be a non-empty string.');this._initialized&&this.reset();const s=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#zo();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=el(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#$o(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#Uo(!0);return!t||s||e?void this.#Wo(null,!0):void this.#Wo({hash:t,page:i,rotation:n},!0)}const r=n.destination;this.#Go(r,n.uid,!0),void 0!==r.rotation&&(this._initialRotation=r.rotation),r.dest?(this._initialBookmark=JSON.stringify(r.dest),this._destination.page=null):r.hash?this._initialBookmark=r.hash:r.page&&(this._initialBookmark=`page=${r.page}`)}reset(){this._initialized&&(this.#qo(),this._initialized=!1,this.#Xo()),this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._initialBookmark=null,this._initialRotation=null}push({namedDest:t=null,explicitDest:e,pageNumber:i}){if(!this._initialized)return;if(t&&"string"!=typeof t)return void console.error(`PDFHistory.push: "${t}" is not a valid namedDest parameter.`);if(!Array.isArray(e))return void console.error(`PDFHistory.push: "${e}" is not a valid explicitDest parameter.`);if(!this.#Ko(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const s=t||JSON.stringify(e);if(!s)return;let n=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(nr(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,s)||function(t,e){function i(t,e){if(typeof t!=typeof e)return!1;if(Array.isArray(t)||Array.isArray(e))return!1;if(null!==t&&"object"==typeof t&&null!==e){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(!i(t[s],e[s]))return!1;return!0}return t===e||Number.isNaN(t)&&Number.isNaN(e)}if(!Array.isArray(t)||!Array.isArray(e))return!1;if(t.length!==e.length)return!1;for(let s=0,n=t.length;s<n;s++)if(!i(t[s],e[s]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;n=!0}this._popStateInProgress&&!n||(this.#Wo({dest:e,hash:s,page:i,rotation:this.linkService.rotation},n),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))}pushPage(t){this._initialized&&(this.#Ko(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#Wo({dest:null,hash:`page=${t}`,page:t,rotation:this.linkService.rotation}),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then((()=>{this._popStateInProgress=!1}))))):console.error(`PDFHistory.pushPage: "${t}" is not a valid page number.`))}pushCurrentPosition(){this._initialized&&!this._popStateInProgress&&this.#Yo()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#$o(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#$o(t)&&t.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}#Wo(t,e=!1){const i=e||!this._destination,s={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let n;if(this.#Go(t,s.uid),this._updateUrl&&t?.hash){const e=document.location.href.split("#",1)[0];e.startsWith("file://")||(n=`${e}#${t.hash}`)}i?window.history.replaceState(s,"",n):window.history.pushState(s,"",n)}#Yo(t=!1){if(!this._position)return;let e=this._position;if(t&&(e=Object.assign(Object.create(null),this._position),e.temporary=!0),!this._destination)return void this.#Wo(e);if(this._destination.temporary)return void this.#Wo(e,!0);if(this._destination.hash===e.hash)return;if(!this._destination.page&&this._numPositionUpdates<=50)return;let i=!1;if(this._destination.page>=e.first&&this._destination.page<=e.page){if(void 0!==this._destination.dest||!this._destination.first)return;i=!0}this.#Wo(e,i)}#Ko(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#$o(t,e=!1){if(!t)return!1;if(t.fingerprint!==this._fingerprint){if(!e)return!1;{if("string"!=typeof t.fingerprint||t.fingerprint.length!==this._fingerprint.length)return!1;const[e]=performance.getEntriesByType("navigation");if("reload"!==e?.type)return!1}}return!(!Number.isInteger(t.uid)||t.uid<0)&&(null!==t.destination&&"object"==typeof t.destination)}#Go(t,e,i=!1){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),i&&t?.temporary&&delete t.temporary,this._destination=t,this._uid=e,this._maxUid=Math.max(this._maxUid,e),this._numPositionUpdates=0}#Uo(t=!1){const e=unescape(el()).substring(1),i=nr(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#Ko(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Qo({location:t}){this._updateViewareaTimeout&&(clearTimeout(this._updateViewareaTimeout),this._updateViewareaTimeout=null),this._position={hash:t.pdfOpenParams.substring(1),page:this.linkService.page,first:t.pageNumber,rotation:t.rotation},this._popStateInProgress||(this._isPagesLoaded&&this._destination&&!this._destination.page&&this._numPositionUpdates++,this._updateViewareaTimeout=setTimeout((()=>{this._popStateInProgress||this.#Yo(!0),this._updateViewareaTimeout=null}),1e3))}#Jo({state:t}){const e=el(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#Uo();return void this.#Wo({hash:t,page:e,rotation:i},!0)}if(!this.#$o(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!e||"string"!=typeof e||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:s,resolve:n}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(o),n(t)}t[t instanceof Ba?"_on":"addEventListener"](e,a.bind(null,Fa),{signal:r.signal});const o=setTimeout(a.bind(null,Oa),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#Go(s,t.uid,!0),dr(s.rotation)&&(this.linkService.rotation=s.rotation),s.dest?this.linkService.goToDestination(s.dest):s.hash?this.linkService.setHash(s.hash):s.page&&(this.linkService.page=s.page),Promise.resolve().then((()=>{this._popStateInProgress=!1}))}#qo(){this._destination&&!this._destination.temporary||this.#Yo()}#zo(){if(this.#ko)return;this.#ko=new AbortController;const{signal:t}=this.#ko;this.eventBus._on("updateviewarea",this.#Qo.bind(this),{signal:t}),window.addEventListener("popstate",this.#Jo.bind(this),{signal:t}),window.addEventListener("pagehide",this.#qo.bind(this),{signal:t})}#Xo(){this.#ko?.abort(),this.#ko=null}}class sl{#Oa=null;#Zo=null;#Mo=null;#cn=null;#Ua=null;#f;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new tl,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#Oa=t.annotationLayer||null,this.#Ua=t.textLayer||null,this.#Zo=t.drawLayer||null,this.#Mo=t.onAppend||null,this.#cn=t.structTreeLayer||null}async render(t,e="display"){if("display"!==e)return;if(this._cancelled)return;const i=t.clone({dontFlip:!0});if(this.div)return this.annotationEditorLayer.update({viewport:i}),void this.show();const s=this.div=document.createElement("div");s.className="annotationEditorLayer",s.hidden=!0,s.dir=this.#f.direction,this.#Mo?.(s),this.annotationEditorLayer=new Ur({uiManager:this.#f,div:s,structTreeLayer:this.#cn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#Oa,textLayer:this.#Ua,drawLayer:this.#Zo});const n={viewport:i,div:s,annotations:null,intent:e};this.annotationEditorLayer.render(n),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1)}}{var nl=new Map;const t=navigator.userAgent||"",e=navigator.platform||"",i=navigator.maxTouchPoints||1,s=/Android/.test(t);(/\b(iPad|iPhone|iPod)(?=;)/.test(t)||"MacIntel"===e&&i>1||s)&&nl.set("maxCanvasPixels",5242880),s&&nl.set("useSystemFonts",!1)}const rl=1,al=2,ol=4,ll=8,hl=16,dl=128,cl={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},ul={allowedGlobalEvents:{value:null,kind:rl},canvasMaxAreaInBytes:{value:-1,kind:rl+ol},isInAutomation:{value:!1,kind:rl},localeProperties:{value:{lang:navigator.language||"en-US"},kind:rl},nimbusDataStr:{value:"",kind:rl},supportsCaretBrowsingMode:{value:!1,kind:rl},supportsDocumentFonts:{value:!0,kind:rl},supportsIntegratedFind:{value:!1,kind:rl},supportsMouseWheelZoomCtrlKey:{value:!0,kind:rl},supportsMouseWheelZoomMetaKey:{value:!0,kind:rl},supportsPinchToZoom:{value:!0,kind:rl},toolbarDensity:{value:0,kind:rl+hl},altTextLearnMoreUrl:{value:"",kind:al+dl},annotationEditorMode:{value:0,kind:al+dl},annotationMode:{value:2,kind:al+dl},cursorToolOnLoad:{value:0,kind:al+dl},debuggerSrc:{value:"./debugger.mjs",kind:al},defaultZoomDelay:{value:400,kind:al+dl},defaultZoomValue:{value:"",kind:al+dl},disableHistory:{value:!1,kind:al},disablePageLabels:{value:!1,kind:al+dl},enableAltText:{value:!1,kind:al+dl},enableAltTextModelDownload:{value:!0,kind:al+dl+hl},enableGuessAltText:{value:!0,kind:al+dl+hl},enableHighlightFloatingButton:{value:!1,kind:al+dl},enableNewAltTextWhenAddingImage:{value:!0,kind:al+dl},enablePermissions:{value:!1,kind:al+dl},enablePrintAutoRotate:{value:!0,kind:al+dl},enableScripting:{value:!0,kind:al+dl},enableUpdatedAddImage:{value:!1,kind:al+dl},externalLinkRel:{value:"noopener noreferrer nofollow",kind:al},externalLinkTarget:{value:0,kind:al+dl},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:al+dl},historyUpdateUrl:{value:!1,kind:al+dl},ignoreDestinationZoom:{value:!1,kind:al+dl},imageResourcesPath:{value:"./images/",kind:al},maxCanvasPixels:{value:2**25,kind:al},forcePageColors:{value:!1,kind:al+dl},pageColorsBackground:{value:"Canvas",kind:al+dl},pageColorsForeground:{value:"CanvasText",kind:al+dl},pdfBugEnabled:{value:!1,kind:al+dl},printResolution:{value:150,kind:al},sidebarViewOnLoad:{value:-1,kind:al+dl},scrollModeOnLoad:{value:-1,kind:al+dl},spreadModeOnLoad:{value:-1,kind:al+dl},textLayerMode:{value:1,kind:al+dl},viewOnLoad:{value:0,kind:al+dl},cMapPacked:{value:!0,kind:ol},cMapUrl:{value:"../web/cmaps/",kind:ol},disableAutoFetch:{value:!1,kind:ol+dl},disableFontFace:{value:!1,kind:ol+dl},disableRange:{value:!1,kind:ol+dl},disableStream:{value:!1,kind:ol+dl},docBaseUrl:{value:"",kind:ol},enableHWA:{value:!0,kind:ol+al+dl},enableXfa:{value:!0,kind:ol+dl},fontExtraProperties:{value:!1,kind:ol},isEvalSupported:{value:!0,kind:ol},isOffscreenCanvasSupported:{value:!0,kind:ol},maxImageSize:{value:-1,kind:ol},pdfBug:{value:!1,kind:ol},standardFontDataUrl:{value:"../web/standard_fonts/",kind:ol},useSystemFonts:{value:void 0,kind:ol,type:cl.BOOLEAN+cl.UNDEFINED},verbosity:{value:1,kind:ol},workerPort:{value:null,kind:ll},workerSrc:{value:"../build/pdf.worker.mjs",kind:ll}};ul.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:al},ul.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:al},ul.viewerCssTheme={value:0,kind:al+dl},ul.enableFakeMLManager={value:!0,kind:al},ul.disablePreferences={value:!1,kind:al};class pl{static eventBus;static#tl=new Map;static{for(const t in ul)this.#tl.set(t,ul[t].value);for(const[t,e]of nl)this.#tl.set(t,e);this._hasInvokedSet=!1,this._checkDisablePreferences=()=>!!this.get("disablePreferences")||(this._hasInvokedSet&&console.warn('The Preferences may override manually set AppOptions; please use the "disablePreferences"-option to prevent that.'),!1)}static get(t){return this.#tl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in ul){const n=ul[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#tl.get(s))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const s in t){const n=ul[s],r=t[s];if(!n||!(typeof r==typeof n.value||cl[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;(!e||a&rl||a&dl)&&(this.eventBus&&a&hl&&(i||=new Map).set(s,r),this.#tl.set(s,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class gl{#Zo=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#Zo||this._cancelled||(this.#Zo=new ta({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#Zo&&(this.#Zo.destroy(),this.#Zo=null)}setParent(t){this.#Zo?.setParent(t)}getDrawLayer(){return this.#Zo}}const fl={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},ml=/^H(\d+)$/;class bl{#el;#il=null;#sl;#nl=new Map;#rl;#al=null;constructor(t,e){this.#el=t.getStructTree(),this.#rl=e}async render(){if(this.#sl)return this.#sl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#sl=t;try{this.#il=this.#ol(await this.#el)}catch(t){i(t)}return this.#el=null,this.#il?.classList.add("structTree"),e(this.#il),t}async getAriaAttributes(t){try{return await this.render(),this.#nl.get(t)}catch{}return null}hide(){this.#il&&!this.#il.hidden&&(this.#il.hidden=!0)}show(){this.#il?.hidden&&(this.#il.hidden=!1)}#ll(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=ar(i);for(const e of t.children)if("annotation"===e.type){let t=this.#nl.get(e.id);t||(t=new Map,this.#nl.set(e.id,t)),t.set("aria-label",n),s=!0}s||e.setAttribute("aria-label",n)}void 0!==s&&e.setAttribute("aria-owns",s),void 0!==n&&e.setAttribute("lang",ar(n,!0))}#hl(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#rl||!i||!s||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#al||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",ar(i));const{pageHeight:l,pageX:h,pageY:d}=this.#rl,c="calc(var(--scale-factor)*",{style:u}=o;return u.width=`${c}${s[2]-s[0]}px)`,u.height=`${c}${s[3]-s[1]}px)`,u.left=`${c}${s[0]-h}px)`,u.top=`${c}${l-s[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#al){for(const[t,e]of this.#al)document.getElementById(t)?.append(e);this.#al.clear(),this.#al=null}}#ol(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(ml);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):fl[i]&&e.setAttribute("role",fl[i]),"Figure"===i&&this.#hl(t,e))return e}if(this.#ll(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#ll(t.children[0],e);else for(const i of t.children)e.append(this.#ol(i));return e}}class vl{#dl=!1;#cl=null;#ul=new Map;#pl=new Map;setTextMapping(t){this.#cl=t}static#gl(t,e){const i=t.getBoundingClientRect(),s=e.getBoundingClientRect();if(0===i.width&&0===i.height)return 1;if(0===s.width&&0===s.height)return-1;const n=i.y,r=i.y+i.height,a=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(a<=o&&h>=r)return-1;if(h<=n&&a>=l)return 1;return i.x+i.width/2-(s.x+s.width/2)}enable(){if(this.#dl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#cl)throw new Error("Text divs and strings have not been set.");if(this.#dl=!0,this.#cl=this.#cl.slice(),this.#cl.sort(vl.#gl),this.#ul.size>0){const t=this.#cl;for(const[e,i]of this.#ul){document.getElementById(e)?this.#fl(e,t[i]):this.#ul.delete(e)}}for(const[t,e]of this.#pl)this.addPointerInTextLayer(t,e);this.#pl.clear()}disable(){this.#dl&&(this.#pl.clear(),this.#cl=null,this.#dl=!1)}removePointerInTextLayer(t){if(!this.#dl)return void this.#pl.delete(t);const e=this.#cl;if(!e||0===e.length)return;const{id:i}=t,s=this.#ul.get(i);if(void 0===s)return;const n=e[s];this.#ul.delete(i);let r=n.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter((t=>t!==i)).join(" "),r?n.setAttribute("aria-owns",r):(n.removeAttribute("aria-owns"),n.setAttribute("role","presentation")))}#fl(t,e){const i=e.getAttribute("aria-owns");i?.includes(t)||e.setAttribute("aria-owns",i?`${i} ${t}`:t),e.removeAttribute("role")}addPointerInTextLayer(t,e){const{id:i}=t;if(!i)return null;if(!this.#dl)return this.#pl.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#cl;if(!s||0===s.length)return null;const n=or(s,(e=>vl.#gl(t,e)<0)),r=Math.max(0,n-1),a=s[r];this.#fl(i,a),this.#ul.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,s){const n=this.addPointerInTextLayer(i,s);if(!t.hasChildNodes())return t.append(e),n;const r=Array.from(t.childNodes).filter((t=>t!==e));if(0===r.length)return n;const a=i||e,o=or(r,(t=>vl.#gl(a,t)<0));return 0===o?r[0].before(e):r[o-1].after(e),n}}class wl{#ko=null;constructor({findController:t,eventBus:e,pageIndex:i}){this.findController=t,this.matches=[],this.eventBus=e,this.pageIdx=i,this.textDivs=null,this.textContentItemsStr=null,this.enabled=!1}setTextMapping(t,e){this.textDivs=t,this.textContentItemsStr=e}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,this.#ko||(this.#ko=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#ko.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#ko?.abort(),this.#ko=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let s=0,n=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==r&&l>=n+i[s].length;)n+=i[s].length,s++;s===i.length&&console.error("Could not find a matching mapping");const h={begin:{divIdx:s,offset:l-n}};for(l+=e[o];s!==r&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},a.push(h)}return a}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let o=null;const l={divIdx:-1,offset:void 0};function h(t,e){const i=t.divIdx;return n[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,r){let a=n[t];if(a.nodeType===Node.TEXT_NODE){const e=document.createElement("span");a.before(e),e.append(a),n[t]=e,a=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(r){const t=document.createElement("span");return t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")?t.offsetLeft:0}return a.append(l),0}let c=a,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!r)return;let p=-1,g=-1;for(let s=c;s<u;s++){const c=t[s],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const f=c.end,m=r&&s===a,b=m?" selected":"";let v=0;if(o&&u.divIdx===o.divIdx?d(o.divIdx,o.offset,u.offset):(null!==o&&d(o.divIdx,o.offset,l.offset),h(u)),u.divIdx===f.divIdx)v=d(u.divIdx,u.offset,f.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=f.divIdx;t<e;t++)n[t].className="highlight middle"+b;h(f,"highlight end"+b)}o=f,m&&e.scrollMatchIntoView({element:n[u.divIdx],selectedLeft:v,pageIndex:i,matchIndex:a})}o&&d(o.divIdx,o.offset,l.offset)}_updateMatches(t=!1){if(!this.enabled&&!t)return;const{findController:e,matches:i,pageIdx:s}=this,{textContentItemsStr:n,textDivs:r}=this;let a=-1;for(const t of i){for(let e=Math.max(a,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=r[e];t.textContent=n[e],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[s]||null,l=e.pageMatchesLength[s]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class yl{#ml=!1;#Mo=null;#bl=!1;#Ua=null;static#vl=new Map;static#wl=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:s=!1,onAppend:n=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#ml=!0===s,this.#Mo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#bl&&this.#Ua)return this.#Ua.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#Ua=new Pa({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#Ua;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#Ua.render(),this.#bl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#yl(n),this.#Mo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#bl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#bl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#Ua?.cancel(),this.#Ua=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),yl.#Al(this.div)}#yl(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#ml){const e=document.getSelection();t.clipboardData.setData("text/plain",ar(ga(e.toString())))}Ea(t)})),yl.#vl.set(e,t),yl.#_l()}static#Al(t){this.#vl.delete(t),0===this.#vl.size&&(this.#wl?.abort(),this.#wl=null)}static#_l(){if(this.#wl)return;this.#wl=new AbortController;const{signal:t}=this.#wl,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var s,n;document.addEventListener("pointerdown",(()=>{i=!0}),{signal:t}),document.addEventListener("pointerup",(()=>{i=!1,this.#vl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#vl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#vl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#vl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#vl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#vl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#vl.values().next().value).getPropertyValue("-moz-user-select"),s)return;const r=t.getRangeAt(0),a=n&&(0===r.compareBoundaryPoints(Range.END_TO_END,n)||0===r.compareBoundaryPoints(Range.START_TO_END,n));let o=a?r.startContainer:r.endContainer;o.nodeType===Node.TEXT_NODE&&(o=o.parentNode);const l=o.parentElement?.closest(".textLayer"),h=this.#vl.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),n=r.cloneRange()}),{signal:t})}}class Al{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:s=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=s,this.div=null,this._cancelled=!1}async render(t,e="display"){if("print"===e){const i={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:this.xfaHtml,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div=document.createElement("div"),i.div=this.div,Ia.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const s={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?Ia.update(s):(this.div=document.createElement("div"),s.div=this.div,Ia.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const _l={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new zr}},xl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class Sl{#xl=Kr.ENABLE_FORMS;#Ve=!1;#Sl=!1;#he=!1;#Cl=null;#El=null;#Pl=null;#Tl=1;#Ml=1;#kl=null;#Ll=qn.INITIAL;#Il=Zn;#Dl={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#Rl=new WeakMap;#Nl=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Cl=t.layerProperties||_l,this.pdfPage=null,this.pageLabel=null,this.rotation=0,this.scale=t.scale||1,this.viewport=i,this.pdfPageRotate=i.rotation,this._optionalContentConfigPromise=t.optionalContentConfigPromise||null,this.#Il=t.textLayerMode??Zn,this.#xl=t.annotationMode??Kr.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??pl.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#Ve=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new tl,this.renderTask=null,this.resume=null,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.zoomLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null;const s=document.createElement("div");if(s.className="page",s.setAttribute("data-page-number",this.id),s.setAttribute("role","region"),s.setAttribute("data-l10n-id","pdfjs-page-landmark"),s.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=s,this.#Ra(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*_a.PDF_TO_CSS_UNITS),this.pageColors?.background&&e?.style.setProperty("--page-bg-color",this.pageColors.background);const{optionalContentConfigPromise:i}=t;i&&i.then((t=>{i===this._optionalContentConfigPromise&&(this.#Dl.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#Fl(t,e){const i=xl.get(e),s=this.#Nl[i];if(this.#Nl[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#Nl[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#Ll}set renderingState(t){if(t!==this.#Ll)switch(this.#Ll=t,this.#El&&(clearTimeout(this.#El),this.#El=null),t){case qn.PAUSED:this.div.classList.remove("loading");break;case qn.RUNNING:this.div.classList.add("loadingIcon"),this.#El=setTimeout((()=>{this.div.classList.add("loading"),this.#El=null}),0);break;case qn.INITIAL:case qn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#Ra(){const{viewport:t}=this;if(this.pdfPage){if(this.#Pl===t.rotation)return;this.#Pl=t.rotation}Sa(this.div,t,!0,!1)}setPdfPage(t){!this._isStandalone||"CanvasText"!==this.pageColors?.foreground&&"Canvas"!==this.pageColors?.background||(this._container?.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),this._container?.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","Highlight"))),this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:this.scale*_a.PDF_TO_CSS_UNITS,rotation:e}),this.#Ra(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return Ca(this,"_textHighlighter",new wl({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Cl.findController}))}#Ol(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#Bl(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error(`#renderAnnotationLayer: "${e}".`),t=e}finally{this.#Ol("annotationlayerrendered",t)}}async#jl(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error(`#renderAnnotationEditorLayer: "${e}".`),t=e}finally{this.#Ol("annotationeditorlayerrendered",t)}}async#Vl(){try{await this.drawLayer.render("display")}catch(t){console.error(`#renderDrawLayer: "${t}".`)}}async#Hl(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#zl(t.textDivs)}catch(e){console.error(`#renderXfaLayer: "${e}".`),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#Fl(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#Ol("xfalayerrendered",t)}}async#$l(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof $r)return;console.error(`#renderTextLayer: "${e}".`),t=e}this.#Ol("textlayerrendered",t),this.#Ul()}async#Ul(){if(!this.textLayer)return;const t=await(this.structTreeLayer?.render());t&&(this.l10n.pause(),this.structTreeLayer?.addElementsToTextLayer(),this.canvas&&t.parentNode!==this.canvas&&this.canvas.append(t),this.l10n.resume()),this.structTreeLayer?.show()}async#zl(t){const e=await this.pdfPage.getTextContent(),i=[];for(const t of e.items)i.push(t.str);this._textHighlighter.setTextMapping(t,i),this._textHighlighter.enable()}_resetZoomLayer(t=!1){if(!this.zoomLayer)return;const e=this.zoomLayer.firstChild;this.#Rl.delete(e),e.width=0,e.height=0,t&&this.zoomLayer.remove(),this.zoomLayer=null}reset({keepZoomLayer:t=!1,keepAnnotationLayer:e=!1,keepAnnotationEditorLayer:i=!1,keepXfaLayer:s=!1,keepTextLayer:n=!1}={}){this.cancelRendering({keepAnnotationLayer:e,keepAnnotationEditorLayer:i,keepXfaLayer:s,keepTextLayer:n}),this.renderingState=qn.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.zoomLayer||null,l=e&&this.annotationLayer?.div||null,h=i&&this.annotationEditorLayer?.div||null,d=s&&this.xfaLayer?.div||null,c=n&&this.textLayer?.div||null;for(let t=a.length-1;t>=0;t--){const e=a[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#Nl.indexOf(e);i>=0&&(this.#Nl[i]=null)}r.removeAttribute("data-loaded"),l&&this.annotationLayer.hide(),h&&this.annotationEditorLayer.hide(),d&&this.xfaLayer.hide(),c&&this.textLayer.hide(),this.structTreeLayer?.hide(),o||(this.canvas&&(this.#Rl.delete(this.canvas),this.canvas.width=0,this.canvas.height=0,delete this.canvas),this._resetZoomLayer())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#he=t,this.reset({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0}))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:s=-1}){this.scale=t||this.scale,"number"==typeof e&&(this.rotation=e),i instanceof Promise&&(this._optionalContentConfigPromise=i,i.then((t=>{i===this._optionalContentConfigPromise&&(this.#Dl.initialOptionalContent=t.hasInitialVisibility)}))),this.#Dl.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*_a.PDF_TO_CSS_UNITS,rotation:n}),this.#Ra(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Sl)if(0===this.maxCanvasPixels)t=!0;else if(this.maxCanvasPixels>0){const{width:e,height:i}=this.viewport,{sx:s,sy:n}=this.outputScale;t=(Math.floor(e)*s|0)*(Math.floor(i)*n|0)>this.maxCanvasPixels}const e=s>=0&&s<1e3;if(e||t){if(e&&!t&&this.renderingState!==qn.FINISHED&&(this.cancelRendering({keepZoomLayer:!0,keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=qn.FINISHED,this.#Dl.directDrawing=!1),this.cssTransform({target:this.canvas,redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),e)return;return void this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!0,timestamp:performance.now(),error:this.#kl})}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:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,cancelExtraDelay:n=0}={}){this.renderTask&&(this.renderTask.cancel(n),this.renderTask=null),this.resume=null,!this.textLayer||s&&this.textLayer.div||(this.textLayer.cancel(),this.textLayer=null),!this.annotationLayer||t&&this.annotationLayer.div||(this.annotationLayer.cancel(),this.annotationLayer=null,this._annotationCanvasMap=null),this.structTreeLayer&&!this.textLayer&&(this.structTreeLayer=null),!this.annotationEditorLayer||e&&this.annotationEditorLayer.div||(this.drawLayer&&(this.drawLayer.cancel(),this.drawLayer=null),this.annotationEditorLayer.cancel(),this.annotationEditorLayer=null),!this.xfaLayer||i&&this.xfaLayer.div||(this.xfaLayer.cancel(),this.xfaLayer=null,this._textHighlighter?.disable())}cssTransform({target:t,redrawAnnotationLayer:e=!1,redrawAnnotationEditorLayer:i=!1,redrawXfaLayer:s=!1,redrawTextLayer:n=!1,hideTextLayer:r=!1}){if(!t.hasAttribute("zooming")){t.setAttribute("zooming",!0);const{style:e}=t;e.width=e.height=""}const a=this.#Rl.get(t);if(this.viewport!==a){const e=this.viewport.rotation-a.rotation,i=Math.abs(e);let s=1,n=1;if(90===i||270===i){const{width:t,height:e}=this.viewport;s=e/t,n=t/e}t.style.transform=`rotate(${e}deg) scale(${s}, ${n})`}e&&this.annotationLayer&&this.#Bl(),i&&this.annotationEditorLayer&&(this.drawLayer&&this.#Vl(),this.#jl()),s&&this.xfaLayer&&this.#Hl(),this.textLayer&&(r?(this.textLayer.hide(),this.structTreeLayer?.hide()):n&&this.#$l())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#Wl(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof xa)this.#kl=null;else if(this.#kl=e,this.renderingState=qn.FINISHED,this._resetZoomLayer(!0),this.#Dl.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#kl}),e)throw e}async draw(){this.renderingState!==qn.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pageColors:i,pdfPage:s,viewport:n}=this;if(!s)throw this.renderingState=qn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=qn.RUNNING;const r=document.createElement("div");if(r.classList.add("canvasWrapper"),this.#Fl(r,"canvasWrapper"),this.textLayer||this.#Il===Jn||s.isPureXfa||(this._accessibilityManager||=new vl,this.textLayer=new yl({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#Il===tr,onAppend:t=>{this.l10n.pause(),this.#Fl(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#xl!==Kr.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Cl;this._annotationCanvasMap||=new Map,this.annotationLayer=new Da({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#xl===Kr.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#Fl(t,"annotationLayer")}})}const{width:a,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation"),l.hidden=!0;const h=!(!i?.background||!i?.foreground);let d=t=>{h&&!t||(l.hidden=!1,d=null)};r.append(l),this.canvas=l;const c=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#Ve}),u=this.outputScale=new ma;if(0===this.maxCanvasPixels){const t=1/this.scale;u.sx*=t,u.sy*=t,this.#Sl=!0}else if(this.maxCanvasPixels>0){const t=a*o,e=Math.sqrt(this.maxCanvasPixels/t);u.sx>e||u.sy>e?(u.sx=e,u.sy=e,this.#Sl=!0):this.#Sl=!1}const p=lr(u.sx),g=lr(u.sy),f=l.width=hr(gr(a*u.sx),p[0]),m=l.height=hr(gr(o*u.sy),g[0]),b=hr(gr(a),p[1]),v=hr(gr(o),g[1]);u.sx=f/b,u.sy=m/v,this.#Tl!==p[1]&&(t.style.setProperty("--scale-round-x",`${p[1]}px`),this.#Tl=p[1]),this.#Ml!==g[1]&&(t.style.setProperty("--scale-round-y",`${g[1]}px`),this.#Ml=g[1]),this.#Rl.set(l,n);const w={canvasContext:c,transform:u.scaled?[u.sx,0,0,u.sy,0,0]:null,viewport:n,annotationMode:this.#xl,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#he},y=this.renderTask=s.render(w);y.onContinue=t=>{if(d?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=qn.PAUSED,void(this.resume=()=>{this.renderingState=qn.RUNNING,t()});t()};const A=y.promise.then((async()=>{d?.(!0),await this.#Wl(y),this.structTreeLayer||=new bl(s,n.rawDims),this.#$l(),this.annotationLayer&&await this.#Bl();const{annotationEditorUIManager:t}=this.#Cl;t&&(this.drawLayer||=new gl({pageIndex:this.id}),await this.#Vl(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new sl({uiManager:t,pdfPage:s,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#Fl(t,"annotationEditorLayer")}}),this.#jl())}),(t=>(t instanceof xa||d?.(!0),this.#Wl(y,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Cl;this.xfaLayer=new Al({pdfPage:s,annotationStorage:t,linkService:e})}this.#Hl()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),A}setPageLabel(t){this.pageLabel="string"==typeof t?t:null,this.div.setAttribute("data-l10n-args",JSON.stringify({page:this.pageLabel??this.id})),null!==this.pageLabel?this.div.setAttribute("data-page-label",this.pageLabel):this.div.removeAttribute("data-page-label")}get thumbnailCanvas(){const{directDrawing:t,initialOptionalContent:e,regularAnnotations:i}=this.#Dl;return t&&e&&i?this.canvas:null}}class Cl{constructor(t){this._ready=new Promise(((e,i)=>{import(t).then((t=>{e(t.QuickJSSandbox())})).catch(i)}))}async createSandbox(t){(await this._ready).create(t)}async dispatchEventInSandbox(t){const e=await this._ready;setTimeout((()=>e.dispatchEvent(t)),0)}async destroySandbox(){(await this._ready).nukeSandbox()}}class El{#Gl=null;#ql=null;#Xl=null;#ko=null;#pr=null;#Kl=null;#Yl=null;#Ql=null;#Jl=!1;#Zl=null;#th=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#pr=t,this.#Kl=e,this.#Xl=i}setViewer(t){this.#Ql=t}async setDocument(t){if(this.#Yl&&await this.#eh(),this.#Yl=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#eh();if(t!==this.#Yl)return;try{this.#Zl=this.#ih()}catch(t){return console.error(`setDocument: "${t.message}".`),void await this.#eh()}const n=this.#pr;this.#ko=new AbortController;const{signal:r}=this.#ko;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#sh(t.detail)}),{signal:r}),n._on("dispatcheventinsandbox",(t=>{this.#Zl?.dispatchEventInSandbox(t.detail)}),{signal:r}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#nh(e),this.#rh(t))}),{signal:r}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Ql.currentPageNumber&&this.#rh(t)}),{signal:r}),n._on("pagesdestroy",(async()=>{await this.#nh(this.#Ql.currentPageNumber),await(this.#Zl?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#Gl?.resolve()}),{signal:r});try{const r=await this.#Xl(t);if(t!==this.#Yl)return;await this.#Zl.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:s}}),n.dispatch("sandboxcreated",{source:this})}catch(t){return console.error(`setDocument: "${t.message}".`),void await this.#eh()}await(this.#Zl?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#rh(this.#Ql.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#Yl&&(this.#Jl=!0)}))}async dispatchWillSave(){return this.#Zl?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Zl?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Zl){await(this.#th?.promise),this.#th=Promise.withResolvers();try{await this.#Zl.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#th.resolve(),this.#th=null,t}await this.#th.promise}}async dispatchDidPrint(){return this.#Zl?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#ql?.promise||null}get ready(){return this.#Jl}get _pageOpenPending(){return Ca(this,"_pageOpenPending",new Set)}get _visitedPages(){return Ca(this,"_visitedPages",new Map)}async#sh(t){const e=this.#Ql,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:r,value:a}=t;if(!s){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const t=function(t){let e=er.VERTICAL,i=ir.NONE;switch(t){case"SinglePage":e=er.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=er.PAGE;case"TwoColumnLeft":i=ir.ODD;break;case"TwoPageRight":e=er.PAGE;case"TwoColumnRight":i=ir.EVEN}return{scrollMode:e,spreadMode:i}}(a);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=a+1;break;case"print":await e.pagesPromise,this.#pr.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#pr.dispatch("download",{source:this});break;case"FirstPage":e.currentPageNumber=1;break;case"LastPage":e.currentPageNumber=e.pagesCount;break;case"NextPage":e.nextPage();break;case"PrevPage":e.previousPage();break;case"ZoomViewIn":i||e.increaseScale();break;case"ZoomViewOut":i||e.decreaseScale();break;case"WillPrintFinished":this.#th?.resolve(),this.#th=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=n?[s,...n]:[s];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#Yl?.annotationStorage.setValue(e,t)}}async#rh(t,e=!1){const i=this.#Yl,s=this._visitedPages;if(e&&(this.#Gl=Promise.withResolvers()),!this.#Gl)return;const n=this.#Ql.getPageView(t-1);if(n?.renderingState!==qn.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const r=(async()=>{const e=await(s.has(t)?null:n.pdfPage?.getJSActions());i===this.#Yl&&await(this.#Zl?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,r)}async#nh(t){const e=this.#Yl,i=this._visitedPages;if(!this.#Gl)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#Yl&&await(this.#Zl?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#ih(){if(this.#ql=Promise.withResolvers(),this.#Zl)throw new Error("#initScripting: Scripting already exists.");return this.#Kl.createScripting()}async#eh(){if(!this.#Zl)return this.#Yl=null,void this.#ql?.resolve();this.#Gl&&(await Promise.race([this.#Gl.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#Gl=null),this.#Yl=null;try{await this.#Zl.destroySandbox()}catch{}this.#th?.reject(new Error("Scripting destroyed.")),this.#th=null,this.#ko?.abort(),this.#ko=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Zl=null,this.#Jl=!1,this.#ql?.resolve()}}class Pl extends El{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new Cl(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:r}=await t.getMetadata();if(!r){const{length:e}=await t.getDownloadInfo();r=e}return{...i,baseURL:e,filesize:r,filename:n||ra(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let Tl=class{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(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}renderHighestPriority(t){this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&this.pdfThumbnailViewer?.forceRendering()||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===qn.FINISHED}renderView(t){switch(t.renderingState){case qn.FINISHED:return!1;case qn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case qn.RUNNING:this.highestPriorityPage=t.renderingId;break;case qn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof xa||console.error(`renderView: "${t}"`)}))}return!0}};const Ml=1e4,kl=5e3,Ll=250;function Il(t){return Object.values(Gr).includes(t)&&t!==Gr.DISABLE}class Dl{#ah=new Set;#oh=0;constructor(t){this.#oh=t}push(t){const e=this.#ah;e.has(t)&&e.delete(t),e.add(t),e.size>this.#oh&&this.#lh()}resize(t,e=null){this.#oh=t;const i=this.#ah;if(e){const t=i.size;let s=1;for(const n of i)if(e.has(n.id)&&(i.delete(n),i.add(n)),++s>t)break}for(;i.size>this.#oh;)this.#lh()}has(t){return this.#ah.has(t)}[Symbol.iterator](){return this.#ah.keys()}#lh(){const t=this.#ah.keys().next().value;t?.destroy(),this.#ah.delete(t)}}class Rl{#hh=null;#I=null;#dh=null;#ch=Gr.NONE;#uh=null;#xl=Kr.ENABLE_FORMS;#ph=null;#gh=null;#Ve=!1;#$=!1;#ml=!1;#U=!1;#W=!1;#ko=null;#nt=null;#fh=null;#mh=null;#bh=!1;#vh=null;#wh=!1;#yh=0;#Ah=new ResizeObserver(this.#_h.bind(this));#xh=null;#Sh=null;#Il=Zn;constructor(t){const e="4.9.155";if(La!==e)throw new Error(`The API version "${La}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,"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.#Ah.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new zr,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#I=t.altTextManager||null,this.#gh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#Il=t.textLayerMode??Zn,this.#xl=t.annotationMode??Kr.ENABLE_FORMS,this.#ch=t.annotationEditorMode??Gr.NONE,this.#dh=t.annotationEditorHighlightColors||null,this.#$=!0===t.enableHighlightFloatingButton,this.#U=!0===t.enableUpdatedAddImage,this.#W=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.l10n=t.l10n,this.l10n||=new tl,this.#ml=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#Ve=t.enableHWA||!1,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new Tl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Ah.disconnect(),this.#Ah=null}),{once:!0}),this.scroll=function(t,e,i){const s=function(i){r||(r=window.requestAnimationFrame((function(){r=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const a=t.scrollTop,o=n.lastY;a!==o&&(n.down=a>o),n.lastY=a,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let r=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=Xn,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Ch(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#hh.has(i)||e?.cleanup()})),t.l10n||this.l10n.translate(this.container)}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#hh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#xl===Kr.ENABLE_FORMS}get enableScripting(){return!!this._scriptingManager}get currentPageNumber(){return this._currentPageNumber}set currentPageNumber(t){if(!Number.isInteger(t))throw new Error("Invalid page number.");this.pdfDocument&&(this._setCurrentPageNumber(t,!0)||console.error(`currentPageNumber: "${t}" is not a valid page.`))}_setCurrentPageNumber(t,e=!1){if(this._currentPageNumber===t)return e&&this.#Eh(),!0;if(!(0<t&&t<=this.pagesCount))return!1;const i=this._currentPageNumber;return this._currentPageNumber=t,this.eventBus.dispatch("pagechanging",{source:this,pageNumber:t,pageLabel:this._pageLabels?.[t-1]??null,previous:i}),e&&this.#Eh(),!0}get currentPageLabel(){return this._pageLabels?.[this._currentPageNumber-1]??null}set currentPageLabel(t){if(!this.pdfDocument)return;let e=0|t;if(this._pageLabels){const i=this._pageLabels.indexOf(t);i>=0&&(e=i+1)}this._setCurrentPageNumber(e,!0)||console.error(`currentPageLabel: "${t}" is not a valid page.`)}get currentScale(){return 0!==this._currentScale?this._currentScale:1}set currentScale(t){if(isNaN(t))throw new Error("Invalid numeric scale.");this.pdfDocument&&this.#Ph(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#Ph(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!dr(t))throw new Error("Invalid pages rotation angle.");if(!this.pdfDocument)return;if((t%=360)<0&&(t+=360),this._pagesRotation===t)return;this._pagesRotation=t;const e=this._currentPageNumber;this.refresh(!0,{rotation:t}),this._currentScaleValue&&this.#Ph(this._currentScaleValue,{noScroll:!0}),this.eventBus.dispatch("rotationchanging",{source:this,pagesRotation:t,pageNumber:e}),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}get _layerProperties(){const t=this;return Ca(this,"_layerProperties",{get annotationEditorUIManager(){return t.#uh},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableScripting(){return!!t._scriptingManager},get fieldObjectsPromise(){return t.pdfDocument?.getFieldObjects()},get findController(){return t.findController},get hasJSActionsPromise(){return t.pdfDocument?.hasJSActions()},get linkService(){return t.linkService}})}#Th(t){const e={annotationEditorMode:this.#ch,annotationMode:this.#xl,textLayerMode:this.#Il};return t?(t.includes(Aa.COPY)||this.#Il!==Zn||(e.textLayerMode=tr),t.includes(Aa.MODIFY_CONTENTS)||(e.annotationEditorMode=Gr.DISABLE),t.includes(Aa.MODIFY_ANNOTATIONS)||t.includes(Aa.FILL_INTERACTIVE_FORMS)||this.#xl!==Kr.ENABLE_FORMS||(e.annotationMode=Kr.ENABLE),e):e}async#Mh(t){if("hidden"===document.visibilityState||!this.container.offsetParent||0===this._getVisiblePages().views.length)return;const e=Promise.withResolvers(),i=new AbortController;document.addEventListener("visibilitychange",(()=>{"hidden"===document.visibilityState&&e.resolve()}),{signal:"function"==typeof AbortSignal.any?AbortSignal.any([t,i.signal]):t}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,s=this.pdfDocument.numPages;i<=s;++i){if(this.#wh)return null;e.length=0;const s=await this.pdfDocument.getPage(i),{items:n}=await s.getTextContent();for(const t of n)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(ar(e.join("")))}return t.join("\n")}#kh(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#vh)){if(this.#bh||t===tr)return void Ea(e);this.#bh=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#wh="Escape"===t.key),{signal:s.signal}),this.getAllText().then((async t=>{null!==t&&await navigator.clipboard.writeText(t)})).catch((t=>{console.warn(`Something goes wrong when extracting the text: ${t.message}`)})).finally((()=>{this.#bh=!1,this.#wh=!1,s.abort(),i.remove("copyAll")})),Ea(e)}}setDocument(t){if(this.pdfDocument&&(this.eventBus.dispatch("pagesdestroy",{source:this}),this._cancelRendering(),this._resetView(),this.findController?.setDocument(null),this._scriptingManager?.setDocument(null),this.#uh?.destroy(),this.#uh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#ml?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#ko=new AbortController;const{signal:l}=this.#ko;if(e>Ml){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=er.PAGE;r.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{r.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));r._on("pagerender",(t=>{const e=this._pages[t.pageNumber-1];e&&this.#hh.push(e)}),{signal:l});const h=t=>{t.cssTransform||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",h))};r._on("pagerendered",h,{signal:l}),Promise.all([i,n]).then((([i,n])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=s;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#Th(n);if(c!==Jn){const t=this.#vh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==Gr.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):Il(e)?(this.#uh=new qr(this.container,o,this.#I,r,t,a,this.#dh,this.#$,this.#U,this.#W,this.#nt,this.#gh),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#uh}),e!==Gr.NONE&&(e===Gr.STAMP&&this.#nt?.loadModel("altText"),this.#uh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===er.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*_a.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),a?.background&&o.style.setProperty("--page-bg-color",a.background),"CanvasText"!==a?.foreground&&"Canvas"!==a?.background||(o.style.setProperty("--hcm-highlight-filter",t.filterFactory.addHighlightHCMFilter("highlight","CanvasText","Canvas","HighlightText","Highlight")),o.style.setProperty("--hcm-highlight-selected-filter",t.filterFactory.addHighlightHCMFilter("highlight_selected","CanvasText","Canvas","HighlightText","ButtonText")));for(let t=1;t<=e;++t){const e=new Sl({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#Ve});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===er.PAGE?this.#Lh():this._spreadMode!==ir.NONE&&this._updateSpreadMode(),this.#Mh(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#vh&&document.addEventListener("copy",this.#kh.bind(this,c),{signal:l}),this.#uh&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#ch}),t.loadingParams.disableAutoFetch||e>kl)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let s=2;s<=e;++s){const e=t.getPage(s).then((t=>{const e=this._pages[s-1];e.pdfPage||e.setPdfPage(t),0==--i&&this._pagesCapability.resolve()}),(t=>{console.error(`Unable to get page ${s} to initialize viewer`,t),0==--i&&this._pagesCapability.resolve()}));s%Ll==0&&await e}})),r.dispatch("pagesinit",{source:this}),t.getMetadata().then((({info:e})=>{t===this.pdfDocument&&e.Language&&(o.lang=e.Language)})),this.defaultRenderingQueue&&this.update()})).catch((t=>{console.error("Unable to initialize viewer",t),this._pagesCapability.reject(t)}))}setPageLabels(t){if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,e=this._pages.length;t<e;t++)this._pages[t].setPageLabel(this._pageLabels?.[t]??null)}}_resetView(){this._pages=[],this._currentPageNumber=1,this._currentScale=0,this._currentScaleValue=null,this._pageLabels=null,this.#hh=new Dl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=er.VERTICAL,this._previousScrollMode=er.UNKNOWN,this._spreadMode=ir.NONE,this.#xh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#ko?.abort(),this.#ko=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#vh?.remove(),this.#vh=null,this.#Ih()}#Lh(){if(this._scrollMode!==er.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#xh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==ir.NONE||this.isInPresentationMode){const s=new Set,n=this._spreadMode-1;-1===n?s.add(t-1):t%2!==n?(s.add(t-1),s.add(t)):(s.add(t-2),s.add(t-1));const r=document.createElement("div");if(r.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",r.append(t)}for(const t of s){const i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{const s=this._pages[t-1];i.append(s.div),e.pages.push(s)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&this.update()}#Dh(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===er.PAGE&&(this.#Lh(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===er.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}sr(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#Rh(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#Nh(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#Rh(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*_a.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#Sh=setTimeout((()=>{this.#Sh=null,this.refresh()}),n));const o=this._currentScale;if(this._currentScale=t,!i){let e,i=this._currentPageNumber;if(!this._location||this.isInPresentationMode||this.isChangingPresentationMode||(i=this._location.pageNumber,e=[null,{name:"XYZ"},this._location.left,this._location.top,null]),this.scrollPageIntoView({pageNumber:i,destArray:e,allowNegativeOffset:!0}),Array.isArray(r)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-s)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:s?e:void 0}),this.defaultRenderingQueue&&this.update()}get#Fh(){return this._spreadMode!==ir.NONE&&this._scrollMode!==er.HORIZONTAL?2:1}#Ph(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#Nh(i,t,e);else{const s=this._pages[this._currentPageNumber-1];if(!s)return;let n=40,r=5;this.isInPresentationMode?(n=r=4,this._spreadMode!==ir.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===er.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#Fh,o=(this.container.clientHeight-r)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=a;break;case"page-height":i=o;break;case"page-fit":i=Math.min(a,o);break;case"auto":const e=cr(s)?a:Math.min(o,a);i=Math.min(1.25,e);break;default:return void console.error(`#setScale: "${t}" is an unknown zoom value.`)}e.preset=!0,this.#Nh(i,t,e)}}#Eh(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#Ph(this._currentScaleValue,{noScroll:!0}),this.#Dh(t)}pageLabelToPageNumber(t){if(!this._pageLabels)return null;const e=this._pageLabels.indexOf(t);return e<0?null:e+1}scrollPageIntoView({pageNumber:t,destArray:e=null,allowNegativeOffset:i=!1,ignoreDestinationZoom:s=!1}){if(!this.pdfDocument)return;const n=Number.isInteger(t)&&this._pages[t-1];if(!n)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let r,a,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/_a.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/_a.PDF_TO_CSS_UNITS;let g=0;switch(e[1].name){case"XYZ":o=e[2],l=e[3],g=e[4],o=null!==o?o:0,l=null!==l?l:p;break;case"Fit":case"FitB":g="page-fit";break;case"FitH":case"FitBH":l=e[2],g="page-width",null===l&&this._location?(o=this._location.left,l=this._location.top):("number"!=typeof l||l<0)&&(l=p);break;case"FitV":case"FitBV":o=e[2],h=u,d=p,g="page-height";break;case"FitR":o=e[2],l=e[3],h=e[4]-o,d=e[5]-l;let t=40,i=5;this.removePageBorders&&(t=i=0),r=(this.container.clientWidth-t)/h/_a.PDF_TO_CSS_UNITS,a=(this.container.clientHeight-i)/d/_a.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(r),Math.abs(a));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(s||(g&&g!==this._currentScale?this.currentScaleValue=g:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===g&&!e[4])return void this.#Dh(n);const f=[n.viewport.convertToViewportPoint(o,l),n.viewport.convertToViewportPoint(o+h,l+d)];let m=Math.min(f[0][0],f[1][0]),b=Math.min(f[0][1],f[1][1]);i||(m=Math.max(m,0),b=Math.max(b,0)),this.#Dh(n,{left:m,top:b})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,s=parseFloat(i)===e?Math.round(1e4*e)/100:i,n=t.id,r=this._pages[n-1],a=this.container,o=r.getPagePoint(a.scrollLeft-t.x,a.scrollTop-t.y),l=Math.round(o[0]),h=Math.round(o[1]);let d=`#page=${n}`;this.isInPresentationMode||(d+=`&zoom=${s},${l},${h}`),this._location={pageNumber:n,scale:s,top:h,left:l,rotation:this._pagesRotation,pdfOpenParams:d}}update(){const t=this._getVisiblePages(),e=t.views,i=e.length;if(0===i)return;const s=Math.max(10,2*i+1);this.#hh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===ir.NONE&&(this._scrollMode===er.PAGE||this._scrollMode===er.VERTICAL),r=this._currentPageNumber;let a=!1;for(const t of e){if(t.percent<100)break;if(t.id===r&&n){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#Oh(){const t=this._getVisiblePages(),e=[],{ids:i,views:s}=t;for(const t of s){const{view:s}=t;s.hasEditableAnnotations()?e.push(t):i.delete(s.id)}return 0===e.length?null:(this.renderingQueue.renderHighestPriority({first:e[0],last:e.at(-1),views:e,ids:i}),i)}containsElement(t){return this.container.contains(t)}focus(){this.container.focus()}get _isContainerRtl(){return"rtl"===getComputedStyle(this.container).direction}get isInPresentationMode(){return this.presentationModeState===Qn}get isChangingPresentationMode(){return this.presentationModeState===Yn}get isHorizontalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollWidth>this.container.clientWidth}get isVerticalScrollbarEnabled(){return!this.isInPresentationMode&&this.container.scrollHeight>this.container.clientHeight}_getVisiblePages(){const t=this._scrollMode===er.PAGE?this.#xh.pages:this._pages,e=this._scrollMode===er.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=or(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=function(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==qn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#Bh(t){if(t.pdfPage)return t.pdfPage;try{const e=await this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for page view",t),null}}#jh(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case er.PAGE:return this.#xh.scrollDown;case er.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#jh(e),s=this._spreadMode!==ir.NONE&&this._scrollMode!==er.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#Bh(n).then((()=>{this.renderingQueue.renderView(n)})),!0)}get hasEqualPageSizes(){const t=this._pages[0];for(let e=1,i=this._pages.length;e<i;++e){const i=this._pages[e];if(i.width!==t.width||i.height!==t.height)return!1}return!0}getPagesOverview(){let t;return this._pages.map((e=>{const i=e.pdfPage.getViewport({scale:1}),s=cr(i);if(void 0===t)t=s;else if(this.enablePrintAutoRotate&&s!==t)return{width:i.height,height:i.width,rotation:(i.rotation-90)%360};return{width:i.width,height:i.height,rotation:i.rotation}}))}get optionalContentConfigPromise(){return this.pdfDocument?this._optionalContentConfigPromise?this._optionalContentConfigPromise:(console.error("optionalContentConfigPromise: Not initialized yet."),this.pdfDocument.getOptionalContentConfig({intent:"display"})):Promise.resolve(null)}set optionalContentConfigPromise(t){if(!(t instanceof Promise))throw new Error(`Invalid optionalContentConfigPromise: ${t}`);this.pdfDocument&&this._optionalContentConfigPromise&&(this._optionalContentConfigPromise=t,this.refresh(!1,{optionalContentConfigPromise:t}),this.eventBus.dispatch("optionalcontentconfigchanged",{source:this,promise:t}))}get scrollMode(){return this._scrollMode}set scrollMode(t){if(this._scrollMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(er).includes(t)&&t!==er.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Ml||(this._previousScrollMode=this._scrollMode,this._scrollMode=t,this.eventBus.dispatch("scrollmodechanged",{source:this,mode:t}),this._updateScrollMode(this._currentPageNumber))}}_updateScrollMode(t=null){const e=this._scrollMode,i=this.viewer;i.classList.toggle("scrollHorizontal",e===er.HORIZONTAL),i.classList.toggle("scrollWrapped",e===er.WRAPPED),this.pdfDocument&&t&&(e===er.PAGE?this.#Lh():this._previousScrollMode===er.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Ph(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}get spreadMode(){return this._spreadMode}set spreadMode(t){if(this._spreadMode!==t){if(!function(t){return Number.isInteger(t)&&Object.values(ir).includes(t)&&t!==ir.UNKNOWN}(t))throw new Error(`Invalid spread mode: ${t}`);this._spreadMode=t,this.eventBus.dispatch("spreadmodechanged",{source:this,mode:t}),this._updateSpreadMode(this._currentPageNumber)}}_updateSpreadMode(t=null){if(!this.pdfDocument)return;const e=this.viewer,i=this._pages;if(this._scrollMode===er.PAGE)this.#Lh();else if(e.textContent="",this._spreadMode===ir.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,r=i.length;n<r;++n)null===s?(s=document.createElement("div"),s.className="spread",e.append(s)):n%2===t&&(s=s.cloneNode(!1),e.append(s)),s.append(i[n].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Ph(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case er.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:r}of i){if(0===n||r<100)continue;let i=s.get(e);i||s.set(e,i||=[]),i.push(t)}for(const i of s.values()){const s=i.indexOf(t);if(-1===s)continue;const n=i.length;if(1===n)break;if(e)for(let e=s-1,n=0;e>=n;e--){const s=i[e],n=i[e+1]-1;if(s<n)return t-n}else for(let e=s+1,r=n;e<r;e++){const s=i[e],n=i[e-1]+1;if(s>n)return n-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[n-1];if(e>t)return e-t+1}break}break}case er.HORIZONTAL:break;case er.PAGE:case er.VERTICAL:{if(this._spreadMode===ir.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:s}=this._getVisiblePages(),n=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of s)if(t===n){if(e>0&&100===i)return 2;break}break}}return 1}nextPage(){const t=this._currentPageNumber,e=this.pagesCount;if(t>=e)return!1;const i=this._getPageAdvance(t,!1)||1;return this.currentPageNumber=Math.min(t+i,e),!0}previousPage(){const t=this._currentPageNumber;if(t<=1)return!1;const e=this._getPageAdvance(t,!0)||1;return this.currentPageNumber=Math.max(t-e,1),!0}updateScale({drawingDelay:t,scaleFactor:e=null,steps:i=null,origin:s}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let n=this._currentScale;if(e>0&&1!==e)n=Math.round(n*e*100)/100;else if(i){const t=i>0?1.1:1/1.1,e=i>0?Math.ceil:Math.floor;i=Math.abs(i);do{n=e(10*(n*t).toFixed(2))/10}while(--i>0)}n=Math.max(.1,Math.min(10,n)),this.#Ph(n,{noScroll:!1,drawingDelay:t,origin:s})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Ch(t=this.container.clientHeight){t!==this.#yh&&(this.#yh=t,ur.setProperty("--viewer-container-height",`${t}px`))}#_h(t){for(const e of t)if(e.target===this.container){this.#Ch(Math.floor(e.borderBoxSize[0].blockSize)),this.#ph=null;break}}get containerTopLeft(){return this.#ph||=[this.container.offsetTop,this.container.offsetLeft]}#Ih(){this.#fh?.abort(),this.#fh=null,null!==this.#mh&&(clearTimeout(this.#mh),this.#mh=null)}get annotationEditorMode(){return this.#uh?this.#ch:Gr.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#uh)throw new Error("The AnnotationEditor is not enabled.");if(this.#ch===t)return;if(!Il(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===Gr.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#Ih(),this.#ch=t,this.#uh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===Gr.NONE||this.#ch===Gr.NONE){const e=t!==Gr.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#Oh();if(e&&i){this.#Ih(),this.#fh=new AbortController;const t=AbortSignal.any([this.#ko.signal,this.#fh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#mh=setTimeout(n,0))}),{signal:t})}}n()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);null!==this.#Sh&&(clearTimeout(this.#Sh),this.#Sh=null),t||this.update()}}}class Nl extends Rl{_resetView(){super._resetView(),this._scrollMode=er.PAGE,this._spreadMode=ir.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var Fl,Ol,Bl,jl,Vl,Hl=Gn.DownloadManager,zl=Gn.EventBus,$l=Gn.GenericL10n,Ul=Gn.PDFLinkService,Wl=Gn.PDFSinglePageViewer,Gl=Gn.PDFViewer,ql=Gn.SimpleLinkService,Xl=Gn.XfaLayerBuilder;function Kl(t,e,i,s){return new(i||(i=Promise))((function(e,n){function r(t){try{o(s.next(t))}catch(t){n(t)}}function a(t){try{o(s.throw(t))}catch(t){n(t)}}function o(t){var s;t.done?e(t.value):(s=t.value,s instanceof i?s:new i((function(t){t(s)}))).then(r,a)}o((s=s.apply(t,[])).next())}))}function Yl(t,e,i,s){if("a"===i&&!s)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?s:"a"===i?s.call(t):s?s.value:e.get(t)}function Ql(t,e,i,s,n){if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;const Jl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Zl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},th={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},eh={DISABLE:0,ENABLE:1},ih={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},sh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class nh{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function rh(t,e,i=!1){let s=t.offsetParent;if(!s)return void console.error("offsetParent is not set -- cannot scroll");let n=t.offsetTop+t.clientTop,r=t.offsetLeft+t.clientLeft;for(;s.clientHeight===s.scrollHeight&&s.clientWidth===s.scrollWidth||i&&(s.classList.contains("markedContent")||"hidden"===getComputedStyle(s).overflow);)if(n+=s.offsetTop,r+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(r+=e.left,s.scrollLeft=r)),s.scrollTop=n,s.scrollLeft=r}function ah(t,e){const i=function(i){n||(n=window.requestAnimationFrame((function(){n=null;const i=t.scrollLeft,r=s.lastX;i!==r&&(s.right=i>r),s.lastX=i;const a=t.scrollTop,o=s.lastY;a!==o&&(s.down=a>o),s.lastY=a,e(s)})))},s={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:i};let n=null;return t.addEventListener("scroll",i,!0),s}const oh=/\x00/g,lh=/[\x01-\x1F]/g;function hh(t,e,i=0){let s=i,n=t.length-1;if(n<0||!e(t[n]))return t.length;if(e(t[s]))return s;for(;s<n;){const i=s+n>>1;e(t[i])?n=i:s=i+1}return s}function dh({view:t,userUnit:e,rotate:i}){const[s,n,r,a]=t,o=i%180!=0,l=(r-s)/72*e,h=(a-n)/72*e;return{width:o?h:l,height:o?l:h}}function ch(t,e,i){if(t<2)return t;let s=e[t].div,n=s.offsetTop+s.clientTop;n>=i&&(s=e[t-1].div,n=s.offsetTop+s.clientTop);for(let i=t-2;i>=0&&(s=e[i].div,!(s.offsetTop+s.clientTop+s.clientHeight<=n));--i)t=i;return t}function uh({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const r=t.scrollTop,a=r+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=hh(e,s?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,s=i+e.clientWidth;return n?i<l:s>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!s&&(u=ch(u,e,r));let p=s?l:-1;for(let t=u;t<c;t++){const i=e[t],n=i.div,c=n.offsetLeft+n.clientLeft,u=n.offsetTop+n.clientTop,g=n.clientWidth,f=n.clientHeight,m=c+g,b=u+f;if(-1===p)b>=a&&(p=b);else if((s?c:u)>p)break;if(b<=r||u>=a||m<=o||c>=l)continue;const v=Math.max(0,r-u)+Math.max(0,b-a),w=(g-(Math.max(0,o-c)+Math.max(0,m-l)))/g,y=(f-v)/f*w*100|0;h.push({id:i.id,x:c,y:u,view:i,percent:y,widthPercent:100*w|0}),d.add(i.id)}const g=h[0],f=h.at(-1);return i&&h.sort((function(t,e){const i=t.percent-e.percent;return Math.abs(i)>.001?-i:t.id-e.id})),{first:g,last:f,views:h,ids:d}}function ph(t){let e=Math.hypot(t.deltaX,t.deltaY);const i=Math.atan2(t.deltaY,t.deltaX);return-.25*Math.PI<i&&i<.75*Math.PI&&(e=-e),e}function gh(t){const e=t.deltaMode;let i=ph(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function fh(t){return Number.isInteger(t)&&t%90==0}function mh(t){return Number.isInteger(t)&&Object.values(ih).includes(t)&&t!==ih.UNKNOWN}function bh(t){return Number.isInteger(t)&&Object.values(sh).includes(t)&&t!==sh.UNKNOWN}function vh(t){return t.width<=t.height}const wh=new Promise((function(t){window.requestAnimationFrame(t)})),yh=document.documentElement.style;Fl=new WeakMap,Ol=new WeakMap,Bl=new WeakMap,jl=new WeakMap,Vl=new WeakMap;class Ah{constructor(){this.pdfViewer=null,this.pdfThumbnailViewer=null,this.onIdle=null,this.highestPriorityPage=null,this.idleTimeout=null,this.printing=!1,this.isThumbnailViewEnabled=!1}setViewer(t){this.pdfViewer=t}setThumbnailViewer(t){this.pdfThumbnailViewer=t}isHighestPriority(t){return this.highestPriorityPage===t.renderingId}hasViewer(){return!!this.pdfViewer}renderHighestPriority(t){var e,i;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),(null===(e=this.pdfViewer)||void 0===e?void 0:e.forceRendering(t))||this.isThumbnailViewEnabled&&(null===(i=this.pdfThumbnailViewer)||void 0===i?void 0:i.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,s=!1){const n=t.views,r=n.length;if(0===r)return null;for(let t=0;t<r;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const a=t.first.id,o=t.last.id;if(o-a+1>r){const s=t.ids;for(let t=1,n=o-a;t<n;t++){const n=i?a+t:o-t;if(s.has(n))continue;const r=e[n-1];if(!this.isViewFinished(r))return r}}let l=i?o:a-2,h=e[l];return h&&!this.isViewFinished(h)||s&&(l+=i?1:-1,h=e[l],h&&!this.isViewFinished(h))?h:null}isViewFinished(t){return t.renderingState===Jl.FINISHED}renderView(t){switch(t.renderingState){case Jl.FINISHED:return!1;case Jl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Jl.RUNNING:this.highestPriorityPage=t.renderingId;break;case Jl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Hn||console.error(`renderView: "${t}"`)}))}return!0}}var _h,xh;class Sh{static getCanvas(t,e){const i=Ql(this,_h,Yl(this,_h,"f",xh)||document.createElement("canvas"),0,xh);i.width=t,i.height=e;const s=i.getContext("2d",{alpha:!1});s.save(),s.fillStyle="rgb(255, 255, 255)",s.fillRect(0,0,t,e),s.restore();const n=i.getContext("2d");return[i,n]}static destroyCanvas(){const t=Yl(this,_h,"f",xh);t&&(t.width=0,t.height=0),Ql(this,_h,null,0,xh)}}_h=Sh,xh={value:null};class Ch{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:r,renderingQueue:a,l10n:o,pageColors:l,store:h,thumbnailWidth:d}){this.container=t,this.eventBus=e,this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.store=h,this.loaded=!1,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=n||null,this.pageColors=l||null,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=Jl.INITIAL,this.resume=null;const c=this.viewport.width,u=c/this.viewport.height;this.canvasWidth=d,this.canvasHeight=this.canvasWidth/u|0,this.scale=this.canvasWidth/c,this.l10n=o,this.canvas=null,this.src=null;const p=document.createElement("div");p.className="thumbnail pdfSlickThumbHolder",p.setAttribute("data-page-number",this.id.toString()),this.div=p,t.append(p)}setPdfPage(t){this.pdfPage=t,this.pdfPageRotate=t.rotate;const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=t.getViewport({scale:1,rotation:e}),this.reset()}reset(){this.cancelRendering(),this.renderingState=Jl.INITIAL;const t=this.viewport.width,e=t/this.viewport.height;this.canvasHeight=this.canvasWidth/e|0,this.scale=this.canvasWidth/t,this.div.removeAttribute("data-loaded"),this.loaded=!1,this.canvas&&(this.canvas.width=0,this.canvas.height=0,delete this.canvas)}update({rotation:t=null}){"number"==typeof t&&(this.rotation=t);const e=(this.rotation+this.pdfPageRotate)%360;this.viewport=this.viewport.clone({scale:1,rotation:e}),this.reset()}cancelRendering(){this.renderTask&&(this.renderTask.cancel(),this.renderTask=null),this.resume=null}_getPageDrawContext(t=1){const e=document.createElement("canvas"),i=e.getContext("2d",{alpha:!1}),s=new nh;e.width=t*this.canvasWidth*s.sx|0,e.height=t*this.canvasHeight*s.sy|0;return{ctx:i,canvas:e,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}}_convertCanvasToImage(t){if(this.renderingState!==Jl.FINISHED)throw new Error("_convertCanvasToImage: Rendering has not finished.");const e=this._reduceImage(t);this.src=e.toDataURL(),this.div.setAttribute("data-loaded","true"),this.loaded=!0,this.store.getState()._setThumbnailView(this.id,this),e.width=0,e.height=0}draw(){if(this.renderingState!==Jl.INITIAL)return console.error("Must be in new state before drawing"),Promise.resolve();const{pdfPage:t}=this;if(!t)return this.renderingState=Jl.FINISHED,Promise.reject(new Error("pdfPage is not loaded"));this.renderingState=Jl.RUNNING;const e=(t=null)=>Kl(this,0,void 0,(function*(){if(a===this.renderTask&&(this.renderTask=null),!(t instanceof Hn)&&(this.renderingState=Jl.FINISHED,this._convertCanvasToImage(s),t))throw t})),{ctx:i,canvas:s,transform:n}=this._getPageDrawContext(2),r={canvasContext:i,transform:n,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},a=this.renderTask=t.render(r);a.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Jl.PAUSED,void(this.resume=()=>{this.renderingState=Jl.RUNNING,t()});t()};const o=a.promise.then((function(){return e(null)}),(function(t){return e(t)}));return o.finally((()=>{s.width=0,s.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),o}setImage(t){if(this.renderingState!==Jl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=Jl.FINISHED,this._convertCanvasToImage(e)))}_reduceImage(t){const{ctx:e,canvas:i}=this._getPageDrawContext();if(t.width<=2*i.width)return e.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i;let s=i.width<<3,n=i.height<<3;const[r,a]=Sh.getCanvas(s,n);for(;s>t.width||n>t.height;)s>>=1,n>>=1;for(a.drawImage(t,0,0,t.width,t.height,0,0,s,n);s>2*i.width;)a.drawImage(r,0,0,s,n,0,0,s>>1,n>>1),s>>=1,n>>=1;return e.drawImage(r,0,0,s,n,0,0,i.width,i.height),i}get _thumbPageTitle(){var t;return this.l10n.get("thumb_page_title",{page:null!==(t=this.pageLabel)&&void 0!==t?t:this.id})}get _thumbPageCanvas(){var t;return this.l10n.get("thumb_page_canvas",{page:null!==(t=this.pageLabel)&&void 0!==t?t:this.id})}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var Eh,Ph,Th;const Mh="selected";class kh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,l10n:n,pageColors:r,store:a,thumbnailWidth:o}){Eh.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.l10n=n,this.pageColors=r||null,this._thumbnails=[],this._currentPageNumber=0,this._pagesRotation=0,this._pageLabels=[],this.pdfDocument=null,this.store=a,this.thumbnailWidth=o,!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFThumbnailViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.scroll=ah(this.container,this._scrollUpdated.bind(this)),this._resetView()}_scrollUpdated(){this.renderingQueue.renderHighestPriority()}getThumbnail(t){return this._thumbnails[t]}_getVisibleThumbs(){return uh({scrollEl:this.container,views:this._thumbnails})}scrollThumbnailIntoView(t){if(!this.pdfDocument)return;const e=this._thumbnails[t-1];if(!e)return void console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.');if(t!==this._currentPageNumber){this._thumbnails[this._currentPageNumber-1].div.classList.remove(Mh),e.div.classList.add(Mh)}const i=this._getVisibleThumbs(),{first:s,last:n,views:r}=i;if(r.length>0){let i=!1;if(t<=s.id||t>=(null==n?void 0:n.id))i=!0;else for(const{id:e,percent:s}of r)if(e===t){i=s<100;break}i&&rh(e.div,{top:-19})}this._currentPageNumber=t,this.forceRendering()}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!fh(t))throw new Error("Invalid thumbnails rotation angle.");if(!this.pdfDocument)return;if(this._pagesRotation===t)return;this._pagesRotation=t;const e={rotation:t};for(const t of this._thumbnails)t.update(e)}cleanup(){for(const t of this._thumbnails)t.renderingState!==Jl.FINISHED&&t.reset();Sh.destroyCanvas()}_resetView(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=[],this._pagesRotation=0,this.container.textContent=""}setDocument(t){if(this.pdfDocument&&(this._cancelRendering(),this._resetView()),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig();e.then((e=>{var s;const n=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new Ch({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,l10n:this.l10n,pageColors:this.pageColors,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(e)}null===(s=this._thumbnails[0])||void 0===s||s.setPdfPage(e);this._thumbnails[this._currentPageNumber-1].div.classList.add(Mh),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((t=>{console.error("Unable to initialize thumbnail viewer",t)}))}_cancelRendering(){for(const t of this._thumbnails)t.cancelRendering()}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=[],console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=[];for(let t=0,s=this._thumbnails.length;t<s;t++)this._thumbnails[t].setPageLabel(null!==(i=null===(e=this._pageLabels)||void 0===e?void 0:e[t])&&void 0!==i?i:null)}}forceRendering(){const t=this._getVisibleThumbs(),e=Yl(this,Eh,"m",Th).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(Yl(this,Eh,"m",Ph).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}var Lh,Ih;Eh=new WeakSet,Ph=function(t){var e;return Kl(this,0,void 0,(function*(){if(null==t?void 0:t.pdfPage)return t.pdfPage;try{const i=yield null===(e=this.pdfDocument)||void 0===e?void 0:e.getPage(t.id);return(null==t?void 0:t.pdfPage)||t.setPdfPage(i),i}catch(t){return console.error("Unable to get page for thumb view",t),null}}))},Th=function(t){var e,i;return 1===(null===(e=t.first)||void 0===e?void 0:e.id)||(null===(i=t.last)||void 0===i?void 0:i.id)!==this._thumbnails.length&&this.scroll.down};Lh=new WeakMap,Ih=new WeakMap;let Dh=null,Rh=null,Nh=new class{constructor(){Lh.set(this,new WeakMap),Ih.set(this,null)}get active(){return Yl(this,Ih,"f")}register(t,e=!1){return Kl(this,0,void 0,(function*(){if("object"!=typeof t)throw new Error("Not enough parameters.");if(Yl(this,Lh,"f").has(t))throw new Error("The overlay is already registered.");Yl(this,Lh,"f").set(t,{canForceClose:e}),t.addEventListener("cancel",(()=>{Ql(this,Ih,null)}))}))}unregister(t){return Kl(this,0,void 0,(function*(){if(!Yl(this,Lh,"f").has(t))throw new Error("The overlay does not exist.");if(Yl(this,Ih,"f")===t)throw new Error("The overlay cannot be removed while it is active.");Yl(this,Lh,"f").delete(t)}))}open(t){return Kl(this,0,void 0,(function*(){if(!Yl(this,Lh,"f").has(t))throw new Error("The overlay does not exist.");if(Yl(this,Ih,"f")){if(Yl(this,Ih,"f")===t)throw new Error("The overlay is already active.");if(!Yl(this,Lh,"f").get(t).canForceClose)throw new Error("Another overlay is currently active.");yield this.close()}Ql(this,Ih,t),t.showModal()}))}close(t=Yl(this,Ih,"f")){return Kl(this,0,void 0,(function*(){if(!t||!Yl(this,Lh,"f").has(t))throw new Error("The overlay does not exist.");if(!Yl(this,Ih,"f"))throw new Error("The overlay is currently not active.");if(Yl(this,Ih,"f")!==t)throw new Error("Another overlay is currently active.");t.close(),Ql(this,Ih,null)}))}};class Fh{constructor(t,e,i,s,n=null,r=null,a){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=s||150,this._optionalContentConfigPromise=n||t.getOptionalContentConfig(),this._printAnnotationStoragePromise=r||Promise.resolve(),this.l10n=a,this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");null==t||t.setAttribute("data-pdfjsprinting","true");this.pagesOverview.every((t=>t.width===this.pagesOverview[0].width&&t.height===this.pagesOverview[0].height),this)||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style");const e=this.pagesOverview[0];this.pageStyleSheet.textContent="@page { size: "+e.width+"pt "+e.height+"pt;}",null==t||t.append(this.pageStyleSheet)}destroy(){if(Dh!==this)return;this.printContainer.textContent="";const t=document.querySelector("body");null==t||t.removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,Dh=null,zh().then((function(){Nh.active===Rh&&Nh.close(Rh)}))}renderPages(){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new ql,n=Math.round(100*Vn.PDF_TO_CSS_UNITS)/100;for(const r of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const a=new Xl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:r}),o=Un(r,{scale:n});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const t=this.pagesOverview.length,e=(i,s)=>{if(this.throwIfInactive(),++this.currentPage>=t)return Vh(t,t,this.l10n),void i();const n=this.currentPage;Vh(n,t,this.l10n),function(t,e,i,s,n,r,a){const o=Dh.scratchCanvas,l=n/Vn.PDF;o.width=Math.floor(s.width*l),o.height=Math.floor(s.height*l);const h=o.getContext("2d");return h.save(),h.fillStyle="rgb(255, 255, 255)",h.fillRect(0,0,o.width,o.height),h.restore(),Promise.all([e.getPage(i),a]).then((function([t,e]){const i={canvasContext:h,transform:[l,0,0,l,0,0],viewport:t.getViewport({scale:1,rotation:s.rotation}),intent:"print",annotationMode:On.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise}))}(0,this.pdfDocument,n+1,this.pagesOverview[n],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){e(i,s)}),s)};return new Promise(e)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img"),e=this.scratchCanvas;"toBlob"in e?e.toBlob((function(e){t.src=URL.createObjectURL(e)})):t.src=e.toDataURL();const i=document.createElement("div");return i.className="printedPage",i.append(t),this.printContainer.append(i),new Promise((function(e,i){t.onload=e,t.onerror=i}))}performPrint(){return this.throwIfInactive(),new Promise((t=>{setTimeout((()=>{this.active?(Oh.call(window),setTimeout(t,20)):t()}),0)}))}get active(){return this===Dh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Oh=window.print;function Bh(t){const e=document.createEvent("CustomEvent");e.initCustomEvent(t,!1,!1,"custom"),window.dispatchEvent(e)}function jh(){Dh&&(Dh.destroy(),Bh("afterprint"))}function Vh(t,e,i){Rh||(Rh=document.getElementById("printServiceDialog"));const s=Math.round(100*t/e),n=Rh.querySelector("progress"),r=Rh.querySelector(".relative-progress");n.value=s,i.get("print_progress_percent",{progress:s}).then((t=>{r.textContent=t}))}if(window.print=function(){if(Dh)console.warn("Ignored window.print() because of a pending print job.");else{zh().then((function(){Dh&&Nh.open(Rh)}));try{Bh("beforeprint")}finally{if(!Dh)return console.error("Expected print service to be initialized."),void zh().then((function(){Nh.active===Rh&&Nh.close(Rh)}));const t=Dh;Dh.renderPages().then((function(){return t.performPrint()})).catch((function(){})).then((function(){t.active&&jh()}))}}},window.addEventListener("keydown",(function(t){80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey||(window.print(),t.preventDefault(),t.stopImmediatePropagation())}),!0),"onbeforeprint"in window){const t=function(t){"custom"!==t.detail&&t.stopImmediatePropagation()};window.addEventListener("beforeprint",t),window.addEventListener("afterprint",t)}let Hh;function zh(){if(!Hh){if(!Nh)throw new Error("The overlay manager has not yet been initialized.");Rh||(Rh=document.getElementById("printServiceDialog")),Hh=Nh.register(Rh,!0),document.getElementById("printCancel").onclick=jh,Rh.addEventListener("close",jh)}return Hh}const $h={instance:{supportsPrinting:!0,createPrintService(t,e,i,s,n,r,a){if(Dh)throw new Error("The print service is created and active.");return Dh=new Fh(t,e,i,s,n,r,a),Dh}}};var Uh,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed,id,sd,nd,rd,ad,od;const ld="pdfPresentationMode",hd="pdfPresentationModeControls",dd=Math.PI/6;class cd{constructor({container:t,pdfViewer:e,eventBus:i}){Uh.add(this),Wh.set(this,Zl.UNKNOWN),Gh.set(this,null),this.container=t,this.pdfViewer=e,this.eventBus=i,this.contextMenuOpen=!1,this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0,this.touchSwipeState=null}request(){return Kl(this,0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;Yl(this,Uh,"m",ad).call(this),Yl(this,Uh,"m",Xh).call(this,Zl.CHANGING);const i=t.requestFullscreen();Ql(this,Gh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===sh.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),Yl(this,Gh,"f").spreadMode=e.spreadMode),e.annotationEditorMode.mode!==Fn.DISABLE&&(Yl(this,Gh,"f").annotationEditorMode=e.annotationEditorMode.mode);try{return yield i,e.focus(),!0}catch(t){Yl(this,Uh,"m",od).call(this),Yl(this,Uh,"m",Xh).call(this,Zl.NORMAL)}return!1}))}get active(){return Yl(this,Wh,"f")===Zl.CHANGING||Yl(this,Wh,"f")===Zl.FULLSCREEN}}Wh=new WeakMap,Gh=new WeakMap,Uh=new WeakSet,qh=function(t){if(!this.active)return;t.preventDefault();const e=gh(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&Yl(this,Uh,"m",ed).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;Yl(this,Uh,"m",ed).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Xh=function(t){Ql(this,Wh,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Kh=function(){var t;Yl(this,Uh,"m",Xh).call(this,Zl.FULLSCREEN),this.container.classList.add(ld),setTimeout((()=>{this.pdfViewer.scrollMode=ih.PAGE,null!==Yl(this,Gh,"f").spreadMode&&(this.pdfViewer.spreadMode=sh.NONE),this.pdfViewer.currentPageNumber=Yl(this,Gh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==Yl(this,Gh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Fn.NONE})}),0),Yl(this,Uh,"m",sd).call(this),Yl(this,Uh,"m",Zh).call(this),this.contextMenuOpen=!1,null===(t=window.getSelection())||void 0===t||t.removeAllRanges()},Yh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(ld),setTimeout((()=>{var e;Yl(this,Uh,"m",od).call(this),Yl(this,Uh,"m",Xh).call(this,Zl.NORMAL),this.pdfViewer.scrollMode=Yl(this,Gh,"f").scrollMode,null!==(null===(e=Yl(this,Gh,"f"))||void 0===e?void 0:e.spreadMode)&&(this.pdfViewer.spreadMode=Yl(this,Gh,"f").spreadMode),this.pdfViewer.currentScaleValue=Yl(this,Gh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==Yl(this,Gh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Yl(this,Gh,"f").annotationEditorMode}),Ql(this,Gh,null)}),0),Yl(this,Uh,"m",nd).call(this),Yl(this,Uh,"m",td).call(this),Yl(this,Uh,"m",ed).call(this),this.contextMenuOpen=!1},Qh=function(t){var e;if(this.contextMenuOpen)return this.contextMenuOpen=!1,void t.preventDefault();0===t.button&&(t.target.href&&(null===(e=t.target.parentNode)||void 0===e?void 0:e.hasAttribute("data-internal-link"))||(t.preventDefault(),t.shiftKey?this.pdfViewer.previousPage():this.pdfViewer.nextPage()))},Jh=function(){this.contextMenuOpen=!0},Zh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(hd),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(hd),delete this.controlsTimeout}),3e3)},td=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(hd),delete this.controlsTimeout)},ed=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},id=function(t){if(this.active)if(t.touches.length>1)this.touchSwipeState=null;else switch(t.type){case"touchstart":this.touchSwipeState={startX:t.touches[0].pageX,startY:t.touches[0].pageY,endX:t.touches[0].pageX,endY:t.touches[0].pageY};break;case"touchmove":if(null===this.touchSwipeState)return;this.touchSwipeState.endX=t.touches[0].pageX,this.touchSwipeState.endY=t.touches[0].pageY,t.preventDefault();break;case"touchend":if(null===this.touchSwipeState)return;let e=0;const i=this.touchSwipeState.endX-this.touchSwipeState.startX,s=this.touchSwipeState.endY-this.touchSwipeState.startY,n=Math.abs(Math.atan2(s,i));Math.abs(i)>50&&(n<=dd||n>=Math.PI-dd)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=dd&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},sd=function(){this.showControlsBind=Yl(this,Uh,"m",Zh).bind(this),this.mouseDownBind=Yl(this,Uh,"m",Qh).bind(this),this.mouseWheelBind=Yl(this,Uh,"m",qh).bind(this),this.resetMouseScrollStateBind=Yl(this,Uh,"m",ed).bind(this),this.contextMenuBind=Yl(this,Uh,"m",Jh).bind(this),this.touchSwipeBind=Yl(this,Uh,"m",id).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)},nd=function(){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},rd=function(){document.fullscreenElement?Yl(this,Uh,"m",Kh).call(this):Yl(this,Uh,"m",Yh).call(this)},ad=function(){this.fullscreenChangeBind=Yl(this,Uh,"m",rd).bind(this),window.addEventListener("fullscreenchange",this.fullscreenChangeBind)},od=function(){window.removeEventListener("fullscreenchange",this.fullscreenChangeBind),delete this.fullscreenChangeBind};const ud={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:sh.UNKNOWN,scrollMode:ih.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:Fn.NONE,pdfSlick:null},pd=()=>{return(t=(t,e)=>Object.assign(Object.assign({},ud),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),r=new Map(e().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;r.set(i,s),n.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:r,thumbnails:n})},_setThumbnailsViews:e=>{const i=new Map(e.map((t=>[t.id,t]))),s=new Map(e.map((t=>{const{canvasWidth:e,canvasHeight:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:r,pageLabel:a,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?r(t):r;var t};var gd,fd,md,bd,vd,wd,yd,Ad,_d,xd,Sd,Cd,Ed,Pd,Td,Md,kd,Ld,Id;Bn.workerSrc=new URL("pdfjs-dist/build/pdf.worker.min.mjs","undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:n&&"SCRIPT"===n.tagName.toUpperCase()&&n.src||new URL("index.js",document.baseURI).href).toString();const Dd={"8.5x11":"Letter","8.5x14":"Legal"},Rd={"297x420":"A3","210x297":"A4"};function Nd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Fd{constructor({container:t,viewer:e,thumbs:i,store:s=pd(),options:n,onError:r}){var a,o,l,h,d,c,u,p,g,f,m,b,v,w;gd.add(this),fd.set(this,void 0),md.set(this,void 0),bd.set(this,void 0),vd.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,wd.set(this,void 0),yd.set(this,void 0),Ad.set(this,void 0),Ql(this,md,t),Ql(this,bd,e),Ql(this,vd,i),Ql(this,Ad,r),this.l10n=null!==(a=null==n?void 0:n.l10n)&&void 0!==a?a:new $l(navigator.language),this.downloadManager=new Hl,this.textLayerMode=null!==(o=null==n?void 0:n.textLayerMode)&&void 0!==o?o:eh.ENABLE,Ql(this,wd,null!==(l=null==n?void 0:n.annotationMode)&&void 0!==l?l:On.ENABLE_FORMS),Ql(this,yd,null!==(h=null==n?void 0:n.annotationEditorMode)&&void 0!==h?h:Fn.NONE),this.annotationEditorHighlightColors=null!==(d=null==n?void 0:n.annotationEditorHighlightColors)&&void 0!==d?d:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(c=null==n?void 0:n.removePageBorders)&&void 0!==c&&c,this.singlePageViewer=null!==(u=null==n?void 0:n.singlePageViewer)&&void 0!==u&&u,this.enablePrintAutoRotate=null!==(p=null==n?void 0:n.enablePrintAutoRotate)&&void 0!==p&&p,this.useOnlyCssZoom=null!==(g=null==n?void 0:n.useOnlyCssZoom)&&void 0!==g&&g,this.pageColors=null!==(f=null==n?void 0:n.pageColors)&&void 0!==f?f:null,this.maxCanvasPixels=null!==(m=null==n?void 0:n.maxCanvasPixels)&&void 0!==m?m:16777216,this.printResolution=null!==(b=null==n?void 0:n.printResolution)&&void 0!==b?b:96,this.thumbnailWidth=null!==(v=null==n?void 0:n.thumbnailWidth)&&void 0!==v?v:125,!this.pageColors||CSS.supports("color",this.pageColors.background)&&CSS.supports("color",this.pageColors.foreground)||((this.pageColors.background||this.pageColors.foreground)&&console.warn("PDFViewer: Ignoring `pageColors`-option, since the browser doesn't support the values used."),this.pageColors=null),this.store=s;const y=new Ah;y.onIdle=this._cleanup.bind(this),y.isThumbnailViewEnabled=!0,Ql(this,fd,y);const A=new zl,_=new Ul({eventBus:A,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),x=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:A,linkService:_,renderingQueue:y,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:Yl(this,wd,"f"),annotationEditorMode:Yl(this,yd,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),S=this.singlePageViewer?new Wl(x):new Gl(x);y.setViewer(S),i&&(this.thumbnailViewer=new kh({container:i,eventBus:A,linkService:_,renderingQueue:y,l10n:this.l10n,pageColors:this.pageColors,store:s,thumbnailWidth:this.thumbnailWidth}),y.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new cd({container:t,pdfViewer:S,eventBus:A})),this.eventBus=A,this.linkService=_,this.viewer=S,this.linkService.setViewer(S);const C=null!==(w=null==n?void 0:n.scaleValue)&&void 0!==w?w:"auto";this.store.setState({scaleValue:C})}loadDocument(t,e){var i,s,n,r,a;return Kl(this,0,void 0,(function*(){if(this.url&&"string"==typeof this.url)try{URL.revokeObjectURL(this.url)}catch(t){}try{null===(i=this.document)||void 0===i||i.destroy(),null===(s=this.viewer)||void 0===s||s.cleanup(),t instanceof URL?this.url=t.toString():t instanceof ArrayBuffer?this.url=URL.createObjectURL(new Blob([t],{type:"application/pdf"})):this.url=t;const o=null!==(n=null==e?void 0:e.filename)&&void 0!==n?n:$n(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=yield zn({url:this.url,isEvalSupported:!1}).promise;this.document=l,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(l)),Yl(this,gd,"m",Cd).call(this),yield Yl(this,gd,"m",_d).call(this),this.store.setState({filename:o,numPages:l.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const h=yield l.getAttachments(),d=new Map(Object.keys(null!=h?h:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,h[t]])));this.store.setState({attachments:d}),yield Yl(this,gd,"m",xd).call(this),this.forceRendering()}catch(t){Yl(this,Ad,"f")&&Yl(this,Ad,"f").call(this,t)}}))}forceRendering(t=!0){Yl(this,fd,"f").printing=!!this.printService,Yl(this,fd,"f").isThumbnailViewEnabled=t,Yl(this,fd,"f").renderHighestPriority()}gotoPage(t){this.linkService.goToPage(t)}openOrDownloadData(t,e){var i;null===(i=this.downloadManager)||void 0===i||i.openOrDownloadData(t,e)}download(){var t,e;return Kl(this,0,void 0,(function*(){const i=this.url,{filename:s}=this;try{const e=yield this.document.getData(),n=new Blob([e],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,i,s)}catch(t){yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(null,i,s)}}))}save(){var t;return Kl(this,0,void 0,(function*(){const e=this.url,{filename:i}=this;try{const s=yield this.document.saveDocument(),n=new Blob([s],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(n,e,i)}catch(t){console.error(`Error when saving the document: ${t.message}`),yield this.download()}}))}downloadOrSave(){var t;const{annotationStorage:e}=null!==(t=this.document)&&void 0!==t?t:{};e&&e.size>0?this.save():this.download()}get supportsPrinting(){return $h.instance.supportsPrinting}beforePrint(){if(this.printService)return;if(!this.supportsPrinting)return;if(!this.viewer.pageViewsReady)return void this.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)}));const t=this.viewer.getPagesOverview(),e=document.getElementById("printContainer"),i=this.printResolution,s=this.viewer.optionalContentConfigPromise,n=$h.instance.createPrintService(this.document,t,e,i,s,null,this.l10n);this.printService=n,this.forceRendering(),n.layout()}afterPrint(){var t;this.printService&&(this.printService.destroy(),this.printService=null,null===(t=this.document)||void 0===t||t.annotationStorage.resetModified()),this.forceRendering()}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){this.supportsPrinting&&window.print()}_cleanup(){var t;if(this.document)try{this.viewer.cleanup(),null===(t=this.thumbnailViewer)||void 0===t||t.cleanup(),this.document.cleanup()}catch(t){console.error("Unable to perform cleanup",t)}}setAnnotationEditorMode(t){this.viewer.annotationEditorMode={mode:t},this.dispatch("switchannotationeditormode",{source:this,mode:t}),this.store.setState({annotationEditorMode:t})}setAnnotationEditorParams(t){const e=Array.isArray(t)?t:[t];for(const t of e)this.dispatch("switchannotationeditorparams",{source:this,type:t.type,value:t.value})}setHighlightDefaultColor(t){this.setAnnotationEditorMode(Fn.HIGHLIGHT),this.setAnnotationEditorParams([{type:Nn.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){bh(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){mh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){fh(t)&&(this.viewer.pagesRotation=t)}getPagesOverview(){var t,e;try{return null!==(e=null===(t=this.viewer)||void 0===t?void 0:t.getPagesOverview())&&void 0!==e?e:[]}catch(t){return[]}}increaseScale(){this.viewer.increaseScale()}decreaseScale(){this.viewer.decreaseScale()}set currentScaleValue(t){this.viewer.currentScaleValue=t}set currentScale(t){this.viewer.currentScale=t}getPageView(t){return this.viewer.getPageView(t)}on(t,e,i){this.eventBus.on(t,e,i)}off(t,e,i){this.eventBus.off(t,e,i)}dispatch(t,e){this.eventBus.dispatch(t,e)}}fd=new WeakMap,md=new WeakMap,bd=new WeakMap,vd=new WeakMap,wd=new WeakMap,yd=new WeakMap,Ad=new WeakMap,gd=new WeakSet,_d=function(){var t;return Kl(this,0,void 0,(function*(){const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],s=i.length;let n=0,r=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;r++}}if(n>=s||r>=s)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)}))},xd=function(){return Kl(this,0,void 0,(function*(){const{info:t,contentLength:e}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then((t=>Yl(this,gd,"m",Sd).call(this,dh(t),0)));this.store.setState({filesize:e,title:t.Title,author:t.Author,subject:t.Subject,keywords:t.Keywords,creator:t.Creator,producer:t.Producer,version:t.PDFFormatVersion,creationDate:jn.toDateObject(t.CreationDate),modificationDate:jn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},Sd=function(t,e){return Kl(this,0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=vh(t);let s={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},n={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},r=Nd(s,i,Dd)||Nd(n,i,Rd);if(!(r||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},a={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-a.width)<.1&&Math.abs(e.height-a.height)<.1&&(r=Nd(a,i,Rd),r&&(s={width:Math.round(a.width/25.4*100)/100,height:Math.round(a.height/25.4*100)/100},n=a))}const[{width:a,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),r&&this.l10n.get(`document_properties_page_size_name_${r.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:a.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},Cd=function(){this.eventBus._on("pagesinit",Yl(this,gd,"m",Ed).bind(this)),this.eventBus._on("scalechanging",Yl(this,gd,"m",kd).bind(this)),this.eventBus._on("pagechanging",Yl(this,gd,"m",Ld).bind(this)),this.eventBus._on("pagerendered",Yl(this,gd,"m",Id).bind(this)),this.eventBus._on("rotationchanging",Yl(this,gd,"m",Pd).bind(this)),this.eventBus._on("switchspreadmode",Yl(this,gd,"m",Td).bind(this)),this.eventBus._on("switchscrollmode",Yl(this,gd,"m",Md).bind(this)),this.eventBus._on("beforeprint",this.beforePrint.bind(this)),this.eventBus._on("afterprint",this.afterPrint.bind(this)),window.onbeforeprint=t=>{this.eventBus.dispatch("beforeprint",{source:window})},window.onafterprint=t=>{this.eventBus.dispatch("afterprint",{source:window})}},Ed=function({source:t}){var e;return Kl(this,0,void 0,(function*(){const i=yield null===(e=this.document)||void 0===e?void 0:e.getOutline(),s=this.store.getState().scaleValue;t.currentScale=1,t.currentScaleValue="auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:s,pagesReady:!0})}))},Pd=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},Td=function({mode:t}){this.store.setState({spreadMode:t})},Md=function({mode:t}){this.store.setState({scrollMode:t})},kd=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},Ld=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},Id=function({pageNumber:t,error:e}){var i;if(Yl(this,vd,"f")){const e=this.viewer.getPageView(t-1),s=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(t-1);e&&s&&s.setImage(e)}};var Od=function(){},Bd="undefined"!=typeof window,jd=Bd?e.useLayoutEffect:e.useEffect;function Vd(t,i,s){void 0===s&&(s=[]);var n=function(t,i){var s=e.useRef(!1),n=e.useRef(),r=e.useRef(t),a=e.useCallback((function(){return s.current}),[]),o=e.useCallback((function(){s.current=!1,n.current&&clearTimeout(n.current),n.current=setTimeout((function(){s.current=!0,r.current()}),i)}),[i]),l=e.useCallback((function(){s.current=null,n.current&&clearTimeout(n.current)}),[]);return e.useEffect((function(){r.current=t}),[t]),e.useEffect((function(){return o(),l}),[i]),[a,l,o]}(t,i),r=n[0],a=n[1],o=n[2];return e.useEffect(o,s),[r,a]}var Hd={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var zd=Bd&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],s=t[1],n=e.useState(Hd),r=n[0],a=n[1],o=e.useMemo((function(){return new window.ResizeObserver((function(t){if(t[0]){var e=t[0].contentRect,i=e.x,s=e.y,n=e.width,r=e.height,o=e.top,l=e.left,h=e.bottom,d=e.right;a({x:i,y:s,width:n,height:r,top:o,left:l,bottom:h,right:d})}}))}),[]);return jd((function(){if(i)return o.observe(i),function(){o.disconnect()}}),[i]),[s,r]}:function(){return[Od,Hd]};function $d({usePDFSlickStore:t,viewerRef:e,className:s}){const n=t((t=>t.pdfSlick)),r=t((t=>t.scaleValue)),[a,{width:o}]=zd();return Vd((()=>{o&&(!n||"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(n.viewer.currentScaleValue=r),null==n||n.viewer.update())}),0,[o]),i.jsx("div",Object.assign({ref:t=>{e(t),a(t)},id:"viewerContainer",className:`pdfSlickContainer ${null!=s?s:""}`,style:{position:"absolute",inset:0,overflow:"auto"}},{children:i.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})}))}function Ud({children:t,thumbsRef:e,usePDFSlickStore:n,className:r}){const a=n((t=>t.thumbnailViews)),o=n((t=>t.pdfSlick)),[l,{width:h}]=zd();return Vd((()=>{h&&(null==o||o.forceRendering())}),0,[h]),i.jsx("div",Object.assign({ref:t=>{e(t),l(t)}},{className:r},{style:{position:"absolute",overflow:"auto",inset:0}},{children:Array.from(a).map((([e,i])=>{var n;return s.createPortal(t({pageNumber:e,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(n=null==i?void 0:i.src)&&void 0!==n?n:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)}))}))}function Wd(t){return function(e,i){return function(t,e=w,i){i&&!v&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),v=!0);const s=b(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,i);return m(s),s}(t,e,i)}}t.AutoPrintRegExp=/\bprint\s*\(/,t.CursorTool={SELECT:0,HAND:1,ZOOM:2},t.DEFAULT_SCALE=1,t.DEFAULT_SCALE_DELTA=1.1,t.DEFAULT_SCALE_VALUE="auto",t.MAX_AUTO_SCALE=1.25,t.MAX_SCALE=10,t.MIN_SCALE=.1,t.OutputScale=nh,t.PDFSlick=Fd,t.PDFSlickThumbnails=Ud,t.PDFSlickViewer=$d,t.PresentationModeState=Zl,t.ProgressBar=class{constructor(t){Fl.set(this,null),Ol.set(this,null),Bl.set(this,0),jl.set(this,null),Vl.set(this,!0),Ql(this,Fl,t.classList),Ql(this,jl,t.style)}get percent(){return Yl(this,Bl,"f")}set percent(t){var e,i,s,n,r,a;Ql(this,Bl,(n=t,r=0,a=100,Math.min(Math.max(n,r),a))),isNaN(t)?null===(e=Yl(this,Fl,"f"))||void 0===e||e.add("indeterminate"):(null===(i=Yl(this,Fl,"f"))||void 0===i||i.remove("indeterminate"),null===(s=Yl(this,jl,"f"))||void 0===s||s.setProperty("--progressBar-percent",`${Yl(this,Bl,"f")}%`))}setWidth(t){var e;if(!t)return;const i=t.parentNode.offsetWidth-t.offsetWidth;i>0&&(null===(e=Yl(this,jl,"f"))||void 0===e||e.setProperty("--progressBar-end-offset",`${i}px`))}setDisableAutoFetch(t=5e3){isNaN(Yl(this,Bl,"f"))||(Yl(this,Ol,"f")&&clearTimeout(Yl(this,Ol,"f")),this.show(),Ql(this,Ol,setTimeout((()=>{Ql(this,Ol,null),this.hide()}),t)))}hide(){var t;Yl(this,Vl,"f")&&(Ql(this,Vl,!1),null===(t=Yl(this,Fl,"f"))||void 0===t||t.add("hidden"))}show(){var t;Yl(this,Vl,"f")||(Ql(this,Vl,!0),null===(t=Yl(this,Fl,"f"))||void 0===t||t.remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Jl,t.SCROLLBAR_PADDING=40,t.ScrollMode=ih,t.SidebarView=th,t.SpreadMode=sh,t.TextLayerMode=eh,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=wh,t.apiPageLayoutToViewerModes=function(t){let e=ih.VERTICAL,i=sh.NONE;switch(t){case"SinglePage":e=ih.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=ih.PAGE;case"TwoColumnLeft":i=sh.ODD;break;case"TwoPageRight":e=ih.PAGE;case"TwoColumnRight":i=sh.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return th.NONE;case"UseThumbs":return th.THUMBS;case"UseOutlines":return th.OUTLINE;case"UseAttachments":return th.ATTACHMENTS;case"UseOC":return th.LAYERS}return th.NONE},t.approximateFraction=function(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let s,n=0,r=1,a=1,o=1;for(;;){const t=n+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(n=t,r=e)}return s=i-n/r<a/o-i?i===t?[n,r]:[r,n]:i===t?[a,o]:[o,a],s},t.backtrackBeforeAllVisibleElements=ch,t.binarySearchFirstItem=hh,t.create=pd,t.createStore=Wd,t.docStyle=yh,t.getActiveOrFocusedElement=function(){let t=document,e=t.activeElement||t.querySelector(":focus");for(;null==e?void 0:e.shadowRoot;)t=e.shadowRoot,e=t.activeElement||t.querySelector(":focus");return e},t.getPageSizeInches=dh,t.getVisibleElements=uh,t.initialState=ud,t.isPortraitOrientation=vh,t.isValidRotation=fh,t.isValidScrollMode=mh,t.isValidSpreadMode=bh,t.noContextMenuHandler=function(t){t.preventDefault()},t.normalizeWheelEventDelta=gh,t.normalizeWheelEventDirection=ph,t.parseQueryString=function(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e},t.removeNullCharacters=function(t,e=!1){return"string"!=typeof t?(console.error("The argument must be a string."),t):(e&&(t=t.replace(lh," ")),t.replace(oh,""))},t.roundToDivide=function(t,e){const i=t%e;return 0===i?t:Math.round(t-i+e)},t.scrollIntoView=rh,t.usePDFSlick=(t,i)=>{const[s,n]=e.useState(!1),[r,a]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo((()=>pd()),[]),u=e.useMemo((()=>Wd(c)),[]),p=e.useCallback((t=>{null!==t&&a(t)}),[]),g=e.useCallback((t=>{null!==t&&l(t)}),[]);return e.useEffect((()=>{if(t&&r){const e=new Fd({container:r,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then((()=>{n(!0)})),c.setState({pdfSlick:e})}return()=>{}}),[t,r]),{isDocumentLoaded:s,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:$d,PDFSlickThumbnails:Ud,error:h}},t.watchScroll=ah}));