@pdfslick/react 2.3.0 → 3.1.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(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;function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a,o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return o||(o=1,u.exports=function(){if(a)return p;a=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,o=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(),a=s({inst:{value:i,getSnapshot:e}}),h=a[0].inst,d=a[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]),o(i),i};return p.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:h,p}()),u.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,n){"use strict";var s="undefined"!=typeof document?document.currentScript:null;function r(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var a,o,l,h,d={exports:{}},c={},u={exports:{}},p={};function g(){return o||(o=1,u.exports=function(){if(a)return p;a=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},n=t.useState,s=t.useEffect,r=t.useLayoutEffect,o=t.useDebugValue;function l(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!i(t,n)}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(),a=n({inst:{value:i,getSnapshot:e}}),h=a[0].inst,d=a[1];return r(function(){h.value=i,h.getSnapshot=e,l(h)&&d({inst:h})},[t,i,e]),s(function(){return l(h)&&d({inst:h}),t(function(){l(h)&&d({inst:h})})},[t]),o(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.js
@@ -7,7 +7,7 @@
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
- */var f=(h||(h=1,d.exports=function(){if(l)return c;l=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,h=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,l,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=l(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=l(t);return void 0!==d&&d(e,i)?(n=t,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,l,d]);var p=n(t,c[0],c[1]);return a((function(){u.hasValue=!0,u.value=p}),[p]),h(p),p},c}()),d.exports),m=r(f);const b=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))},a=e=t(s,n,r);return r},{useSyncExternalStoreWithSelector:v}=m,w=t=>t;
10
+ */var m=(h||(h=1,d.exports=function(){if(l)return c;l=1;var t=e,i=g(),n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},s=i.useSyncExternalStore,r=t.useRef,a=t.useEffect,o=t.useMemo,h=t.useDebugValue;return c.useSyncExternalStoreWithSelector=function(t,e,i,l,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,s=t,t=l(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return r=e}return r=t}if(e=r,n(s,t))return e;var i=l(t);return void 0!==d&&d(e,i)?(s=t,e):(s=t,r=i)}var s,r,a=!1,o=void 0===i?null:i;return[function(){return t(e())},null===o?void 0:function(){return t(o())}]},[e,i,l,d]);var p=s(t,c[0],c[1]);return a(function(){u.hasValue=!0,u.value=p},[p]),h(p),p},c}()),d.exports),f=r(m);const b=t=>{let e;const i=new Set,n=(t,n)=>{const s="function"==typeof t?t(e):t;if(!Object.is(s,e)){const t=e;e=(null!=n?n:"object"!=typeof s||null===s)?s:Object.assign({},e,s),i.forEach(i=>i(e,t))}},s=()=>e,r={setState:n,getState:s,getInitialState:()=>a,subscribe:t=>(i.add(t),()=>i.delete(t))},a=e=t(n,s,r);return r},{useSyncExternalStoreWithSelector:v}=f,w=t=>t;
11
11
  /**
12
12
  * @licstart The following is the entire license notice for the
13
13
  * JavaScript code in this page
@@ -28,4 +28,27 @@
28
28
  *
29
29
  * @licend The above is the entire license notice for the
30
30
  * JavaScript code in this page
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:()=>Sn,AnnotationEditorParamsType:()=>F,AnnotationEditorType:()=>N,AnnotationEditorUIManager:()=>ve,AnnotationLayer:()=>rn,AnnotationMode:()=>R,ColorPicker:()=>fn,DOMSVGFactory:()=>Es,DrawLayer:()=>Cn,FeatureTest:()=>Ot,GlobalWorkerOptions:()=>Ei,ImageKind:()=>$,InvalidPDFException:()=>Tt,MissingPDFException:()=>kt,OPS:()=>ft,OutputScale:()=>he,PDFDataRangeTransport:()=>ds,PDFDateString:()=>se,PDFWorker:()=>gs,PasswordResponses:()=>mt,PermissionFlag:()=>O,PixelsPerInch:()=>Wt,RenderingCancelledException:()=>Xt,TextLayer:()=>ts,TouchManager:()=>ye,UnexpectedResponseException:()=>It,Util:()=>jt,VerbosityLevel:()=>gt,XfaLayer:()=>Ps,build:()=>As,createValidAbsoluteUrl:()=>St,fetchData:()=>Gt,getDocument:()=>os,getFilenameFromUrl:()=>Qt,getPdfFilenameFromUrl:()=>Jt,getXfaPageViewport:()=>ne,isDataScheme:()=>Kt,isPdfFile:()=>Yt,noContextMenu:()=>ee,normalizeUnicode:()=>zt,setLayerDimensions:()=>le,shadow:()=>Ct,stopEvent:()=>ie,version:()=>ys});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,M=4,T=16,k=32,I=64,L=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,U=4,$={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 Mt extends Et{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let Tt=class extends Et{constructor(t){super(t,"InvalidPDFException")}},kt=class extends Et{constructor(t){super(t,"MissingPDFException")}},It=class extends Et{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class Lt 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 Ut="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const $t="http://www.w3.org/2000/svg";let Wt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Gt(t,e="text"){if(te(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 qt{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,f,m;switch((s%=360)<0&&(s+=360),s){case 180:h=-1,d=0,c=0,u=1;break;case 90:h=0,d=1,c=1,u=0;break;case 270:h=0,d=-1,c=-1,u=0;break;case 0:h=1,d=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+r,f=(t[3]-t[1])*i,m=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+n,g=Math.abs(l-t[1])*i+r,f=(t[2]-t[0])*i,m=(t[3]-t[1])*i),this.transform=[h*i,d*i,c*i,u*i,p-h*i*o-c*i*l,g-d*i*o-u*i*l],this.width=f,this.height=m}get rawDims(){const{userUnit:t,viewBox:e}=this,i=e.map((e=>e*t));return Ct(this,"rawDims",{pageWidth:i[2]-i[0],pageHeight:i[3]-i[1],pageX:i[0],pageY:i[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:s=this.offsetY,dontFlip:n=!1}={}){return new qt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,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 Xt=class extends Et{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Kt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Yt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Qt(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Jt(t,e="document.pdf"){if("string"!=typeof t)return e;if(Kt(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 Zt{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 te(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function ee(t){t.preventDefault()}function ie(t){t.preventDefault(),t.stopPropagation()}let se=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 ne(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,r=[0,0,parseInt(s),parseInt(n)];return new qt({viewBox:r,userUnit:1,scale:e,rotation:i})}function re(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 ae(t){const{a:e,b:i,c:s,d:n,e:r,f:a}=t.getTransform();return[e,i,s,n,r,a]}function oe(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 le(t,e,i=!1,s=!0){if(e instanceof qt){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 he=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 de{#s=null;#n=null;#r;#a=null;#o=null;static#l=null;constructor(t){this.#r=t,de.#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",ee,{signal:e}),t.addEventListener("pointerdown",de.#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,ie(t)}#u(t){this.#r._focusEventsAllowed=!0,ie(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",ee,{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",de.#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 ce{#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",ee,{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",ee,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#a.append(t)}}function ue(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class pe{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class ge{#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 Gt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ge._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 fe{#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 me{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||ie(e))}}class be{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,re(s))}e.remove()}(t),Ct(this,"_colors",t)}convert(t){const e=re(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 be._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?jt.makeHexColor(...e):t}}let ve=class t{#M=new AbortController;#T=null;#k=new Map;#I=new Map;#L=null;#D=null;#R=null;#N=new fe;#F=null;#O=null;#B=0;#j=new Set;#V=null;#H=null;#z=new Set;_editorUndoBar=null;#U=!1;#$=!1;#W=!1;#G=null;#q=null;#X=null;#K=null;#Y=!1;#Q=null;#J=new pe;#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 me([[["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,u){const p=this._signal=this.#M.signal;this.#pt=t,this.#gt=e,this.#L=i,this._eventBus=s,s._on("editingaction",this.onEditingAction.bind(this),{signal:p}),s._on("pagechanging",this.onPageChanging.bind(this),{signal:p}),s._on("scalechanging",this.onScaleChanging.bind(this),{signal:p}),s._on("rotationchanging",this.onRotationChanging.bind(this),{signal:p}),s._on("setpreference",this.onSetPreference.bind(this),{signal:p}),s._on("switchannotationeditorparams",(t=>this.updateParams(t.type,t.value)),{signal:p}),this.#mt(),this.#bt(),this.#vt(),this.#D=n.annotationStorage,this.#G=n.filterFactory,this.#lt=r,this.#K=a||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:Wt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=c||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ft?.resolve(),this.#ft=null,this.#M?.abort(),this.#M=null,this._signal=null;for(const t of this.#I.values())t.destroy();this.#I.clear(),this.#k.clear(),this.#z.clear(),this.#T=null,this.#at.clear(),this.#N.destroy(),this.#L?.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.#$}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.#L?.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.#I.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*Wt.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.#I.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 ce(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.#U&&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}#Mt(){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})}#Tt(){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.#Mt()}removeEditListeners(){this.#Pt(),this.#Tt()}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.#T?.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.#It(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.#Lt([[F.HIGHLIGHT_FREE,!0]]))}#Lt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Mt(),this.#xt({isEditing:this.#rt!==N.NONE,isEmpty:this.#Dt(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Et(),this.#Tt(),this.#xt({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#H){this.#H=t;for(const t of this.#H)this.#Lt(t.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#I.get(this.#B)}getLayer(t){return this.#I.get(t)}get currentPageIndex(){return this.#B}addLayer(t){this.#I.set(t.pageIndex,t),this.#Z?t.enable():t.disable()}removeLayer(t){this.#I.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.#I.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.#Lt([[F.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#tt!==t){this.#tt=t;for(const e of this.#I.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.#I.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.#I.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.#I.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#T!==t&&(this.#T=t,t&&this.#Lt(t.propertiesToUpdate))}get#Ft(){let t=null;for(t of this.#at);return t}updateUI(t){this.#Ft===t&&this.#Lt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Lt(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.#Lt(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.#Lt(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.#T?.commitOrRemove()}hasSomethingToControl(){return this.#T||this.hasSelection}#It(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.#It(this.#k.values())}unselectAll(){if((!this.#T||(this.#T.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.#I.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.#T===t}getActive(){return this.#T}getMode(){return this.#rt}get imageManager(){return Ct(this,"imageManager",new ge)}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 we{#o=null;#Ot=!1;#Bt=null;#jt=null;#Vt=null;#Ht=null;#zt=!1;#Ut=null;#r=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#r=t,this.#Gt=t._uiManager.useNewAltTextFlow,we.#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){we._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",we.#qt.missing),e.setAttribute("data-l10n-id",we.#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",ee,{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.#$t:this.isEmpty()}get guessedText(){return this.#$t}async setGuessedText(t){null===this.#o&&(this.#$t=t,this.#Wt=await we._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.#Ut?.remove(),void(this.#Ut=null);if(!this.#Ut){const t=this.#Ut=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#Ut.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#$t!==e||(e=this.#Wt),{altText:e,decorative:this.#Ot,guessedText:this.#$t,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.#$t=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.#Ut?.remove(),this.#Ut=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",we.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",we.#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)}}let ye=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#re=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:r=null,signal:a}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=r,this.#ne=new AbortController,this.#ie=AbortSignal.any([a,this.#ne.signal]),t.addEventListener("touchstart",this.#ae.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Ct(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ae(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#re){this.#re=new AbortController;const t=AbortSignal.any([this.#ie,this.#re.signal]),e=this.#pt,i={signal:t,passive:!1};e.addEventListener("touchmove",this.#oe.bind(this),i),e.addEventListener("touchend",this.#le.bind(this),i),e.addEventListener("touchcancel",this.#le.bind(this),i),this.#Zt?.()}if(ie(t),2!==t.touches.length||this.#Qt?.())return void(this.#se=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#se={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#oe(e){if(!this.#se||2!==e.touches.length)return;let[i,s]=e.touches;i.identifier>s.identifier&&([i,s]=[s,i]);const{screenX:n,screenY:r}=i,{screenX:a,screenY:o}=s,l=this.#se,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=a-n,m=o-r,b=Math.hypot(f,m)||1,v=Math.hypot(p,g)||1;if(!this.#Yt&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+a)/2,(r+o)/2];this.#te?.(w,v,b)}#le(t){this.#re.abort(),this.#re=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class Ae{#he=null;#de=null;#o=null;#ce=!1;#ue=null;#pe="";#ge=!1;#fe=null;#me=null;#be=null;#ve=null;#we="";#ye=!1;#Ae=null;#_e=!1;#xe=!1;#Se=!1;#Ce=null;#Ee=0;#Pe=0;#Me=null;#Te=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#ke=!1;#Ie=Ae._zIndex++;static _borderLineWidth=-1;static _colorManager=new be;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=Ae.prototype._resizeWithKeyboard,e=ve.TRANSLATE_SMALL,i=ve.TRANSLATE_BIG;return Ct(this,"_resizerKeyboardManager",new me([[["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"],Ae.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 _e({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(Ae._l10n??=t,Ae._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!==Ae._borderLineWidth)return;const i=getComputedStyle(document.documentElement);Ae._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.#ke}set _isDraggable(t){this.#ke=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.#Ie}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):this.#Le(),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ye?this.#ye=!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()}#De([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.#De(this.parentDimensions,t,e)}translateInPage(t,e){this.#Ae||=[this.x,this.y,this.width,this.height],this.#De(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){this.#Ae||=[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.#Ae&&(this.#Ae[0]!==this.x||this.#Ae[1]!==this.y)}get _hasBeenResized(){return!!this.#Ae&&(this.#Ae[2]!==this.width||this.#Ae[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=Ae,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#Re(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 Ae.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return Ae.#Re(t,e,360-this.parentRotation)}#Ne(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.#ge||(n.height=`${(100*e/s).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:i}=t,s=i.endsWith("%"),n=!this.#ge&&e.endsWith("%");if(s&&n)return;const[r,a]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/r).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/a).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#Fe(){if(this.#fe)return;this.#fe=document.createElement("div"),this.#fe.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.#fe.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#Oe.bind(this,i),{signal:e}),t.addEventListener("contextmenu",ee,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(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.#me=[e.screenX,e.screenY];const n=new AbortController,r=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",ie,{passive:!1,signal:r}),window.addEventListener("contextmenu",ee,{signal:r}),this.#be={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.#je()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#Ve(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(){}#je(){if(!this.#be)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:s}=this.#be;this.#be=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.#Ve.bind(this,n,r,a,o),undo:this.#Ve.bind(this,t,e,i,s),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#Be(t,e){const[i,s]=this.parentDimensions,n=this.x,r=this.y,a=this.width,o=this.height,l=Ae.MIN_SIZE/i,h=Ae.MIN_SIZE/s,d=this.#Ne(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#Ne(360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let w=c(...v);const y=Ae._round(n+w[0]),A=Ae._round(r+w[1]);let _,x,S=1,C=1;if(e.fromKeyboard)({deltaX:_,deltaY:x}=e);else{const{screenX:t,screenY:i}=e,[s,n]=this.#me;[_,x]=this.screenToPageTranslation(t-s,i-n),this.#me[0]=t,this.#me[1]=i}var E,P;if([_,x]=(E=_/i,P=x/s,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),f){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/a,1/o),l/a,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/a:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const M=Ae._round(a*S),T=Ae._round(o*C);w=c(...g(M,T));const k=y-w[0],I=A-w[1];this.#Ae||=[this.x,this.y,this.width,this.height],this.width=M,this.height=T,this.x=k,this.y=I,this.setDims(i*M,s*T),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}async addEditToolbar(){return this._editToolbar||this.#xe||(this._editToolbar=new de(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||(we.initialize(Ae._l10n),this.#o=new we(this),this.#he&&(this.#o.data=this.#he,this.#he=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.#ce?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#He();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),ue(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Te||=new ye({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ze.bind(this),onPinching:this.#Ue.bind(this),onPinchEnd:this.#$e.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#ze(){this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ue(t,e,i){let s=i/e*.7+1-.7;if(1===s)return;const n=this.#Ne(this.rotation),r=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=Ae.MIN_SIZE/a,p=Ae.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=Ae._round(d*s),f=Ae._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=r(d/2,c/2),b=Ae._round(l+m[0]),v=Ae._round(h+m[1]),w=r(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(a*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=Ot.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ye=!0,this._isDraggable?this.#We(t):this.#Ge(t))}get isSelected(){return this._uiManager.isSelected(this)}#Ge(t){const{isMac:e}=Ot.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#We(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const s=new AbortController,n=this._uiManager.combinedSignal(s),r={capture:!0,passive:!1,signal:n},a=t=>{s.abort(),this.#ue=null,this.#ye=!1,this._uiManager.endDragSession()||this.#Ge(t),i&&this._onStopDragging()};e&&(this.#Ee=t.clientX,this.#Pe=t.clientY,this.#ue=t.pointerId,this.#pe=t.pointerType,window.addEventListener("pointermove",(t=>{i||(i=!0,this._onStartDragging());const{clientX:e,clientY:s,pointerId:n}=t;if(n!==this.#ue)return void ie(t);const[r,a]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(r,a)}),r),window.addEventListener("touchmove",ie,r),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Te||t.isPrimary)&&a(t),ie(t)}),r));const o=t=>{this.#ue&&this.#ue!==t.pointerId?ie(t):a(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ce&&clearTimeout(this.#Ce),this.#Ce=setTimeout((()=>{this.#Ce=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(t){}isEmpty(){return!1}enableEditMode(){this.#xe=!0}disableEditMode(){this.#xe=!1}isInEditMode(){return this.#xe}shouldGetKeyboardEvents(){return this.#Se}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}#He(){if(this.#ve||!this.div)return;this.#ve=new AbortController;const t=this._uiManager.combinedSignal(this.#ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#He()}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.#he=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.#ve?.abort(),this.#ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ce&&(clearTimeout(this.#Ce),this.#Ce=null),this.#Le(),this.removeEditToolbar(),this.#Me){for(const t of this.#Me.values())clearTimeout(t);this.#Me=null}this.parent=null,this.#Te?.destroy(),this.#Te=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#Fe(),this.#fe.classList.remove("hidden"),ue(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.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#fe.children;if(!this.#de){this.#de=Array.from(e);const t=this.#qe.bind(this),i=this.#Xe.bind(this),s=this._uiManager._signal;for(const e of this.#de){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.#Ke.bind(this,n),{signal:s}),e.setAttribute("data-l10n-id",Ae._l10nResizer[n])}}const i=this.#de[0];let s=0;for(const t of e){if(t===i)break;s++}const n=(360-this.rotation+this.parentRotation)%360/90*(this.#de.length/4);if(n!==s){if(n<s)for(let t=0;t<s-n;t++)this.#fe.append(this.#fe.firstChild);else if(n>s)for(let t=0;t<n-s;t++)this.#fe.firstChild.before(this.#fe.lastChild);let t=0;for(const i of e){const e=this.#de[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",Ae._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){Ae._resizerKeyboardManager.exec(this,t)}#Xe(t){this.#Se&&t.relatedTarget?.parentNode!==this.#fe&&this.#Le()}#Ke(t){this.#we=this.#Se?t:""}#Ye(t){if(this.#de)for(const e of this.#de)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#Se&&this.#Be(this.#we,{deltaX:t,deltaY:e,fromKeyboard:!0})}#Le(){this.#Se=!1,this.#Ye(-1),this.#je()}_stopResizingWithKeyboard(){this.#Le(),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.#fe?.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.#_e}set isEditing(t){this.#_e=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){this.#ge=!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.#Me||=new Map;const{action:e}=t;let i=this.#Me.get(e);return i&&clearTimeout(i),i=setTimeout((()=>{this._reportTelemetry(t),this.#Me.delete(e),0===this.#Me.size&&(this.#Me=null)}),Ae._telemetryTimeout),void this.#Me.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.#ce=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#ce=!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 _e extends Ae{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const xe=3285377520,Se=4294901760,Ce=65535;class Ee{constructor(t){this.h1=t?4294967295&t:xe,this.h2=t?4294967295&t:xe}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&Se|a*u&Ce,a=a<<15|a>>>17,a=a*c&Se|a*p&Ce,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&Se|o*u&Ce,o=o<<15|o>>>17,o=o*c&Se|o*p&Ce,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&Se|a*u&Ce,a=a<<15|a>>>17,a=a*c&Se|a*p&Ce,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&Se|36045*t&Ce,e=4283543511*e&Se|(2950163797*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,t=444984403*t&Se|60499*t&Ce,e=3301882366*e&Se|(3120437893*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Pe=Object.freeze({map:null,hash:"",transfer:void 0});class Me{#Qe=!1;#Je=null;#Ze=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Ze.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Ze.get(t)}remove(t){if(this.#Ze.delete(t),0===this.#Ze.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of this.#Ze.values())if(t instanceof Ae)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Ze.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.#Ze.set(t,e);s&&this.#ti(),e instanceof Ae&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?Ft(this.#Ze):null}setAll(t){for(const[e,i]of Object.entries(t))this.setValue(e,i)}get size(){return this.#Ze.size}#ti(){this.#Qe||(this.#Qe=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qe&&(this.#Qe=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Te(this)}get serializable(){if(0===this.#Ze.size)return Pe;const t=new Map,e=new Ee,i=[],s=Object.create(null);let n=!1;for(const[i,r]of this.#Ze){const a=r instanceof Ae?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}:Pe}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof Ae))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.#Je=null}get modifiedIds(){if(this.#Je)return this.#Je;const t=[];for(const e of this.#Ze.values())e instanceof Ae&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class Te extends Me{#ei;constructor(t){super();const{map:e,hash:i,transfer:s}=t.serializable,n=structuredClone(e,s?{transfer:s}:null);this.#ei={map:n,hash:i,transfer:s}}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return Ct(this,"modifiedIds",{ids:new Set,hash:""})}}class ke{#ii=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.#ii.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(t&&!this.#ii.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.#ii.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 Ie{constructor(t,{disableFontFace:e=!1,fontExtraProperties:i=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const e in t)this[e]=t[e];this.disableFontFace=!0===e,this.fontExtraProperties=!0===i,this._inspectFont=s}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];const i=this.loadedName+"_path_"+e;let s;try{s=t.get(i)}catch(t){At(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const Le=1,De=2,Re=1,Ne=2,Fe=3,Oe=4,Be=5,je=6,Ve=7,He=8;function ze(){}function Ue(t){if(t instanceof Dt||t instanceof Tt||t instanceof kt||t instanceof Pt||t instanceof It||t instanceof Mt)return 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"InvalidPDFException":return new Tt(t.message);case"MissingPDFException":return new kt(t.message);case"PasswordException":return new Pt(t.message,t.code);case"UnexpectedResponseException":return new It(t.message,t.status);case"UnknownErrorException":return new Mt(t.message,t.details)}return new Mt(t.message,t.toString())}class $e{#si=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.#ni.bind(this),{signal:this.#si.signal})}#ni({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#ri(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===Le)i.resolve(t.data);else{if(t.callback!==De)throw new Error("Unexpected callback case");i.reject(Ue(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:Le,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:De,callbackId:t.callbackId,reason:Ue(e)})}))}else t.streamId?this.#ai(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:je,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:Re,streamId:n,reason:Ue(t)}),e.promise}},i)}#ai(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:Oe,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Fe,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:Be,streamId:e,reason:Ue(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:He,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:He,streamId:e,reason:Ue(t)})}))}#ri(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 He:t.success?r.startCall.resolve():r.startCall.reject(Ue(t.reason));break;case Ve:t.success?r.pullCall.resolve():r.pullCall.reject(Ue(t.reason));break;case je:if(!a){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||ze).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ve,streamId:e,reason:Ue(t)})}));break;case Oe:if(xt(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Fe:if(xt(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#oi(r,e);break;case Be:xt(r,"error should have stream controller"),r.controller.error(Ue(t.reason)),this.#oi(r,e);break;case Ne:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ue(t.reason)),this.#oi(r,e);break;case Re:if(!a)break;const o=Ue(t.reason);Promise.try(a.onCancel||ze,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ne,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ne,streamId:e,reason:Ue(t)})})),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#oi(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#si?.abort(),this.#si=null}}class We{#li=!1;constructor({enableHWA:t=!1}){this.#li=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.#li})}}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 Ge{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 qe extends Ge{async _fetch(t){const e=await Gt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Nt(e)}}class Xe{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 Ke{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 Ye extends Ke{async _fetch(t){const e=await Gt(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)}_&&At("Please use the `legacy` build in Node.js environments.");const Je="Fill",Ze="Stroke",ti="Shading";function ei(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 ii{getPattern(){_t("Abstract method `getPattern` called.")}}class si extends ii{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===Ze||s===Je){const r=e.current.getClippedPathBoundingBox(s,ae(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),ei(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 ei(t,this._bbox),n=this._createGradient(t);return n}}function ni(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],M=Math.round(g),T=Math.round(v);let k,I,L,D,R,N,F,O;for(let t=M;t<=T;t++){if(t<m){const e=t<g?0:(g-t)/(g-m);k=p-(p-f)*e,I=w-(w-_)*e,L=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,I=_-(_-C)*e,L=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++]=I-(I-N)*e|0,d[n++]=L-(L-F)*e|0,d[n++]=D-(D-O)*e|0,d[n++]=255}}function ri(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++)ni(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),ni(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)ni(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 ai extends ii{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)ri(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(ei(t,this._bbox),s===ti)n=jt.singularValueDecompose2dScale(ae(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===ti?null:this._background,e.cachedCanvases);return s!==ti&&(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 oi extends ii{getPattern(){return"hotpink"}}const li=1,hi=2;class di{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),M=P.context,T=a.createCanvasGraphics(M);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,s,r),M.translate(-C.scale*h,-E.scale*d),T.transform(C.scale,0,0,E.scale,0,0),M.save(),this.clipBbox(T,h,d,c,u),T.baseTransform=ae(T.ctx),T.executeOperatorList(i),T.endDrawing(),M.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(di.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(ae(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case li:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case hi: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 Lt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==ti&&(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 ci({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 ui=16;class pi{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 gi(t,e,i,s,n,r,a,o,l,h){const[d,c,u,p,g,f]=ae(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 fi{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=Je,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Ze){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=Je,e=null){return jt.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function mi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%ui,r=(i-n)/ui,a=0===n?r:r+1,o=t.createImageData(s,ui);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===$.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?ui: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*ui)}}else if(e.kind===$.RGBA_32BPP){for(p=0,f=s*ui*4,u=0;u<r;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=ui;u<a&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==$.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=ui,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*ui)}}}function bi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%ui,r=(i-n)/ui,a=0===n?r:r+1,o=t.createImageData(s,ui);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?ui:n;({srcPos:l}=ci({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*ui)}}function vi(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 wi(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 yi(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)*Wt.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const Ai=["butt","round","square"],_i=["miter","round","bevel"],xi={},Si={};class Ci{constructor(t,e,i,s,n,{optionalContentConfig:r,markedContentStack:a=null},o,l){this.ctx=t,this.current=new fi(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 pi(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(...ae(this.compositeCtx))}this.ctx.save(),wi(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=ae(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}}}#hi(){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.#hi(),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.#di()}#di(){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=ae(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),bi(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,oe(w)),h=h.img,o&&r&&o.set(l,h)),w.imageSmoothingEnabled=yi(ae(w),t.interpolate),gi(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=jt.transform(oe(w),[1,0,0,1,-y,-A]);return w.fillStyle=r?n.getPattern(e,this,_,Je):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=Ai[t]}setLineJoin(t){this.ctx.lineJoin=_i[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(...ae(this.suspendedCtx)),vi(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(),vi(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?(vi(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(),vi(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=ae(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,oe(e),Ze),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,oe(e),Je),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=xi}eoClip(){this.pendingClip=Si}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)return void e.beginPath();const i=new Path2D,s=e.getTransform().invertSelf();for(const{transform:e,x:n,y:r,fontSize:a,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,r).scale(a,-a));e.clip(i),e.beginPath(),delete this.pendingTextPaths}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)}#ci(t,e,i){const s=new Path2D;return s.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),s}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),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){if(r.save(),r.translate(e,i),r.scale(h,-h),d===B||d===V)if(s){const t=r.getTransform();r.setTransform(...s),r.fill(this.#ci(g,t,s))}else r.fill(g);if(d===j||d===V)if(n){const t=r.getTransform();r.setTransform(...n),r.stroke(this.#ci(g,t,n))}else r.lineWidth/=h,r.stroke(g);r.restore()}else d!==B&&d!==V||r.fillText(t,e,i),d!==j&&d!==V||r.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:ae(r),x:e,y:i,fontSize:h,path: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,oe(n),Je);m=ae(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,oe(n),Ze);b=ae(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||ae(this.ctx),n={createCanvasGraphics:t=>new Ci(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new di(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 si(t);case"Mesh":return new ai(t);case"Dummy":return new oi}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,oe(e),ti);const s=oe(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=ae(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(ae(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=ae(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=jt.getAxialAlignedBoundingBox(t.bbox,ae(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()),vi(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=ae(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.#hi(),wi(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(ae(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),wi(this.ctx)}else wi(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,r),this.ctx.clip(),this.ctx.beginPath()}this.current=new fi(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...i),this.transform(...s)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#di(),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=ae(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();bi(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,oe(e),Je):i,h.fillRect(0,0,r,a),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),gi(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;mi(s,t),n=this.applyTransferMapsToCanvas(s)}const r=this._scaleImage(n,oe(s));s.imageSmoothingEnabled=yi(ae(s),t.interpolate),gi(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;mi(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),gi(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===Si?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ae(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!==Ci.prototype[t]&&(Ci.prototype[ft[t]]=Ci.prototype[t]);let Ei=class{static#ui=null;static#pi="";static get workerPort(){return this.#ui}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#ui=t}static get workerSrc(){return this.#pi}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#pi=t}};class Pi{#gi;#fi;constructor({parsedData:t,rawData:e}){this.#gi=t,this.#fi=e}getRaw(){return this.#fi}get(t){return this.#gi.get(t)??null}getAll(){return Ft(this.#gi)}has(t){return this.#gi.has(t)}}const Mi=Symbol("INTERNAL");class Ti{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&P),this.#bi=!!(t&M),this.name=e,this.intent=i,this.usage=s,this.rbGroups=n}get visible(){if(this.#vi)return this.#wi;if(!this.#wi)return!1;const{print:t,view:e}=this.usage;return this.#mi?"OFF"!==e?.viewState:!this.#bi||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==Mi&&_t("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class ki{#yi=null;#Ai=new Map;#_i=null;#xi=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.#xi=t.order;for(const i of t.groups)this.#Ai.set(i.id,new Ti(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(Mi,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(Mi,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(Mi,!1);this.#_i=this.getHash()}}#Si(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.#Si(e);else{if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;n=this.#Ai.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.#Ai.size)return!0;if(!t)return yt("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(At(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#Si(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(!this.#Ai.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#Ai.has(e))return At(`Optional content group not found: ${e}`),!0;if(this.#Ai.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.#Ai.get(t);if(s){if(i&&e&&s.rbGroups.length)for(const e of s.rbGroups)for(const i of e)i!==t&&this.#Ai.get(i)?._setVisible(Mi,!1,!0);s._setVisible(Mi,!!e,!0),this.#yi=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.#Ai.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.#yi=null}get hasInitialVisibility(){return null===this.#_i||this.getHash()===this.#_i}getOrder(){return this.#Ai.size?this.#xi?this.#xi.slice():[...this.#Ai.keys()]:null}getGroups(){return this.#Ai.size>0?Ft(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new Ee;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class Ii{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 Li(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Di(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 Li{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Yt(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 Di{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 Ri(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 Ni(t){try{return new URL(t).origin}catch{}return null}function Fi({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 Oi(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(Yt(t))return t}return null}function Bi(t,e){return 404===t||0===t&&e.startsWith("file:")?new kt('Missing PDF "'+e+'".'):new It(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function ji(t){return 200===t||206===t}function Vi(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Hi(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(At(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class zi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Ri(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 Ui(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new $i(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 Ui{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,Vi(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=Ni(e.url),!ji(e.status))throw Bi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:r}=Fi({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=r||this._contentLength,this._filename=Oi(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:Hi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class $i{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,Vi(n,this._withCredentials,this._abortController)).then((e=>{const i=Ni(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!ji(e.status))throw Bi(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:Hi(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Wi{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Ri(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}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",xt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{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);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(At('Missing or invalid "Content-Range" header.'),i.onError(0))}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 Gi{constructor(t){this._source=t,this._manager=new Wi(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 qi(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Xi(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 qi{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),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=Ni(e.responseURL);const i=e.getAllResponseHeaders(),s=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]})):[]),{allowRangeRequests:n,suggestedLength:r}=Fi({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=Oi(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=Bi(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 Xi{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=Ni(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??=Bi(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 Ki=/^[a-z][a-z0-9\-+.]+:/i;class Yi{constructor(t){this.source=t,this.url=function(t){if(Ki.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 Qi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ji(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 Qi{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 Ji{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 Zi=30;let ts=class t{#Ci=Promise.withResolvers();#pt=null;#Ei=!1;#Pi=!!globalThis.FontInspector?.enabled;#Mi=null;#Ti=null;#ki=0;#Ii=0;#Li=null;#Di=null;#Ri=0;#Ni=0;#Fi=Object.create(null);#Oi=[];#Bi=null;#ji=[];#Vi=new WeakMap;#Hi=null;static#zi=new Map;static#Ui=new Map;static#$i=new WeakMap;static#Wi=null;static#Gi=new Set;constructor({textContentSource:e,container:i,viewport:s}){if(e instanceof ReadableStream)this.#Bi=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Bi=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#pt=this.#Di=i,this.#Ni=s.scale*(globalThis.devicePixelRatio||1),this.#Ri=s.rotation,this.#Ti={div:null,properties:null,ctx:null};const{pageWidth:n,pageHeight:r,pageX:a,pageY:o}=s.rawDims;this.#Hi=[1,0,0,-1,-a,o+r],this.#Ii=n,this.#ki=r,t.#qi(),le(i,s),this.#Ci.promise.finally((()=>{t.#Gi.delete(this),this.#Ti=null,this.#Fi=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.#Li.read().then((({value:t,done:i})=>{i?this.#Ci.resolve():(this.#Mi??=t.lang,Object.assign(this.#Fi,t.styles),this.#Xi(t.items),e())}),this.#Ci.reject)};return this.#Li=this.#Bi.getReader(),t.#Gi.add(this),e(),this.#Ci.promise}update({viewport:e,onBefore:i=null}){const s=e.scale*(globalThis.devicePixelRatio||1),n=e.rotation;if(n!==this.#Ri&&(i?.(),this.#Ri=n,le(this.#Di,{rotation:n})),s!==this.#Ni){i?.(),this.#Ni=s;const e={div:null,properties:null,ctx:t.#Ki(this.#Mi)};for(const t of this.#ji)e.properties=this.#Vi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new Dt("TextLayer task cancelled.");this.#Li?.cancel(t).catch((()=>{})),this.#Li=null,this.#Ci.reject(t)}get textDivs(){return this.#ji}get textContentItemsStr(){return this.#Oi}#Xi(e){if(this.#Ei)return;this.#Ti.ctx??=t.#Ki(this.#Mi);const i=this.#ji,s=this.#Oi;for(const t of e){if(i.length>1e5)return At("Ignoring additional textDivs for performance reasons."),void(this.#Ei=!0);if(void 0!==t.str)s.push(t.str),this.#Qi(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)}}#Qi(e){const i=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ji.push(i);const n=jt.transform(this.#Hi,e.transform);let r=Math.atan2(n[1],n[0]);const a=this.#Fi[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#Pi&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*t.#Ji(o,this.#Mi);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.#Di?(p.left=`${(100*d/this.#Ii).toFixed(2)}%`,p.top=`${(100*c/this.#ki).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Wi*l).toFixed(2)}px)`,p.fontFamily=o,s.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#Pi&&(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.#Vi.set(i,s),this.#Ti.div=i,this.#Ti.properties=s,this.#Yi(this.#Ti),s.hasText&&this.#pt.append(i),s.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#pt.append(t)}}#Yi(e){const{div:i,properties:s,ctx:n}=e,{style:r}=i;let a="";if(t.#Wi>1&&(a=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#Ni/h}) ${a}`)}0!==s.angle&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Gi.size>0)){this.#zi.clear();for(const{canvas:t}of this.#Ui.values())t.remove();this.#Ui.clear()}}static#Ki(t=null){let e=this.#Ui.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.#Ui.set(t,e),this.#$i.set(e,{size:0,family:""})}return e}static#Zi(t,e,i){const s=this.#$i.get(t);e===s.size&&i===s.family||(t.font=`${e}px ${i}`,s.size=e,s.family=i)}static#qi(){if(null!==this.#Wi)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.#Wi=t.getBoundingClientRect().height,t.remove()}static#Ji(t,e){const i=this.#zi.get(t);if(i)return i;const s=this.#Ki(e);s.canvas.width=s.canvas.height=Zi,this.#Zi(s,Zi,t);const n=s.measureText("");let r=n.fontBoundingBoxAscent,a=Math.abs(n.fontBoundingBoxDescent);if(r){const e=r/(r+a);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Zi,Zi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Zi,Zi).data;a=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){a=Math.ceil(t/4/Zi);break}s.clearRect(0,0,Zi,Zi),s.strokeText("A",0,Zi),o=s.getImageData(0,0,Zi,Zi).data,r=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){r=Zi-Math.floor(t/4/Zi);break}s.canvas.width=s.canvas.height=0;const l=r?r/(r+a):.8;return this.#zi.set(t,l),l}};class es{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(!es.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 is=65536,ss=_?class extends We{_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 We{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}},ns=_?class extends Ge{async _fetch(t){return Qe(t)}}:qe,rs=_?class extends Xe{}:class extends Xe{#ts;#es;#is;#ss;#ns;#rs;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#as(){return this.#rs||=new Map}get#os(){if(!this.#is){const t=this.#ns.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.#ns.createElementNS($t,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS($t,"defs"),t.append(i),i.append(this.#is),this.#ns.body.append(t)}return this.#is}#ls(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(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(Kt(t)?At('#createUrl: ignore "data:"-URL for performance reasons.'):this.#ts=t.split("#",1)[0])}return`url(${this.#ts}#${t})`}addFilter(t){if(!t)return"none";let e=this.#A.get(t);if(e)return e;const[i,s,n]=this.#ls(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.#ss}_transfer_map_${this.#w++}`,o=this.#hs(a);this.#A.set(t,o),this.#A.set(r,o);const l=this.#ds(a);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#as.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.#as.set(s,n)),!t||!e)return n.url;const r=this.#us(t);t=jt.makeHexColor(...r);const a=this.#us(e);if(e=jt.makeHexColor(...a),this.#os.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.#ss}_hcm_filter`,d=n.filter=this.#ds(h);this.#cs(l,l,l,d),this.#ps(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.#cs(c(0,5),c(1,5),c(2,5),d),n.url=this.#hs(h),n.url}addAlphaFilter(t){let e=this.#A.get(t);if(e)return e;const[i]=this.#ls([t]),s=`alpha_${i}`;if(e=this.#A.get(s),e)return this.#A.set(t,e),e;const n=`g_${this.#ss}_alpha_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(s,r);const a=this.#ds(n);return this.#gs(i,a),r}addLuminosityFilter(t){let e,i,s=this.#A.get(t||"luminosity");if(s)return s;if(t?([e]=this.#ls([t]),i=`luminosity_${e}`):i="luminosity",s=this.#A.get(i),s)return this.#A.set(t,s),s;const n=`g_${this.#ss}_luminosity_map_${this.#w++}`,r=this.#hs(n);this.#A.set(t,r),this.#A.set(i,r);const a=this.#ds(n);return this.#fs(a),t&&this.#gs(e,a),r}addHighlightHCMFilter(t,e,i,s,n){const r=`${e}-${i}-${s}-${n}`;let a=this.#as.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.#as.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#us.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.#us.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#os.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.#ss}_hcm_${t}_filter`,f=a.filter=this.#ds(g);return this.#ps(f),this.#cs(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),f),a.url=this.#hs(g),a.url}destroy(t=!1){t&&this.#rs?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#rs?.clear(),this.#rs=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS($t,"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)}#ps(t){const e=this.#ns.createElementNS($t,"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)}#ds(t){const e=this.#ns.createElementNS($t,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#os.append(e),e}#ms(t,e,i){const s=this.#ns.createElementNS($t,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS($t,"feComponentTransfer");s.append(n),this.#ms(n,"feFuncR",t),this.#ms(n,"feFuncG",e),this.#ms(n,"feFuncB",i)}#gs(t,e){const i=this.#ns.createElementNS($t,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,re(getComputedStyle(this.#os).getPropertyValue("color"))}},as=_?class extends Ke{async _fetch(t){return Qe(t)}}:Ye;function os(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new hs,{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 ds?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:is;let d=t.worker instanceof gs?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||Kt(t.docBaseUrl)?null:t.docBaseUrl,p="string"==typeof t.cMapUrl?t.cMapUrl:null,g=!1!==t.cMapPacked,f=t.CMapReaderFactory||ns,m="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,b=t.StandardFontDataFactory||as,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,M=t.ownerDocument||globalThis.document,T=!0===t.disableRange,k=!0===t.disableStream,I=!0===t.disableAutoFetch,L=!0===t.pdfBug,D=t.CanvasFactory||ss,R=t.FilterFactory||rs,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===qe&&b===Ye&&p&&m&&te(p,document.baseURI)&&te(m,document.baseURI);vt(c);const j={canvasFactory:new D({ownerDocument:M,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:B?null:new b({baseUrl:m})};if(!d){const t={verbosity:c,port:Ei.workerPort};d=t.port?gs.fromPort(t):new gs(t),e._worker=d}const V={docId:i,apiVersion:"4.10.38",data:n,password:o,disableAutoFetch:I,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:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,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 Ii(l,{disableRange:T,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(_)if(te(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=zi}else t=Yi;else t=te(s)?zi:Gi;o=new t({url:s,length:F,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:T,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 $e(i,t,d.port),n=new fs(s,e,o,H,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function ls(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class hs{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+hs.#ss++,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 ds=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 cs{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 us{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Zt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new bs,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 qt({viewBox:this.view,userUnit:this.userUnit,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.#vs=!1,this.#ws(),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&M);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.#vs=!0),this.#ys(!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 ws({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=>es.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.#vs=!1,this.#ws(),Promise.all(t)}cleanup(t=!1){this.#vs=!0;const e=this.#ys(!1);return t&&e&&(this._stats&&=new Zt),e}#ys(t=!1){if(this.#ws(),!this.#vs||this.destroyed)return!1;if(t)return this.#bs=setTimeout((()=>{this.#bs=null,this.#ys(!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.#vs=!1,!0}#ws(){this.#bs&&(clearTimeout(this.#bs),this.#bs=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.#ys(!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.#ys(!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 Xt){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 ps{#As=new Map;#_s=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#_s.then((()=>{for(const[t]of this.#As)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.#As.set(e,s)}removeEventListener(t,e){const i=this.#As.get(e);i?.(),this.#As.delete(e)}terminate(){for(const[,t]of this.#As)t?.();this.#As.clear()}}let gs=class t{static#xs=0;static#Ss=!1;static#Cs;static{_&&(this.#Ss=!0,Ei.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.#Cs?.has(i))throw new Error("Cannot use more than one PDFWorker per port.");return(t.#Cs||=new WeakMap).set(i,this),void this._initializeFromPort(i)}this._initialize()}get promise(){return this._readyCapability.promise}#Es(){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 $e("main","worker",t),this._messageHandler.on("ready",(function(){})),this.#Es()}_initialize(){if(t.#Ss||t.#Ps)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 $e("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.#Es()):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.#Ss||(At("Setting up fake worker."),t.#Ss=!0),t._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const i=new ps;this._port=i;const s="fake"+t.#xs++,n=new $e(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new $e(s,s+"_worker",i),this.#Es()})).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.#Cs?.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.#Cs?.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(Ei.workerSrc)return Ei.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Ct(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class fs{#Ms=new Map;#Ts=new Map;#ks=new Map;#Is=new Map;#Ls=null;constructor(t,e,i,s,n){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new bs,this.fontLoader=new ke({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()}#Ds(t,e=null){const i=this.#Ms.get(t);if(i)return i;const s=this.messageHandler.sendWithPromise(t,e);return this.#Ms.set(t,s),s}get annotationStorage(){return Ct(this,"annotationStorage",new Me)}getRenderingIntent(t,e=R.ENABLE,i=null,s=!1,n=!1){let r=P,a=Pe;switch(t){case"any":r=E;break;case"display":break;case"print":r=M;break;default:At(`getRenderingIntent - invalid intent: ${t}`)}const o=r&M&&i instanceof Te?i:this.annotationStorage;switch(e){case R.DISABLE:r+=I;break;case R.ENABLE:break;case R.ENABLE_FORMS:r+=T;break;case R.ENABLE_STORAGE:r+=k,a=o.serializable;break;default:At(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(r+=L),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.#Ls?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Ts.values())t.push(e._destroy());this.#Ts.clear(),this.#ks.clear(),this.#Is.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.#Ms.clear(),this.filterFactory.destroy(),ts.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 cs(t,this))})),t.on("DocException",(t=>{e._capability.reject(Ue(t))})),t.on("PasswordRequest",(t=>{this.#Ls=Promise.withResolvers();try{if(!e.onPassword)throw Ue(t);const i=t=>{t instanceof Error?this.#Ls.reject(t):this.#Ls.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#Ls.reject(t)}return this.#Ls.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.#Ts.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 Ie(s,{disableFontFace:n,fontExtraProperties:r,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.#Ts.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.#Ts.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.#ks.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.#Is.set(i.refStr,t);const s=new us(e,i,this,this._params.pdfBug);return this.#Ts.set(e,s),s}));return this.#ks.set(e,s),s}getPageIndex(t){return ls(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.#Ds("GetFieldObjects")}hasJSActions(){return this.#Ds("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.#Ds("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.#Ds("GetOptionalContentConfig").then((e=>new ki(e,t)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Ms.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then((t=>({info:t[0],metadata:t[1]?new Pi(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#Ms.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.#Ts.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Ms.clear(),this.filterFactory.destroy(!0),ts.cleanup()}}cachedPageNumber(t){if(!ls(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const ms=Symbol("INITIAL_DATA");class bs{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:ms}}get(t,e=null){if(e){const i=this.#Ns(t);return i.promise.then((()=>e(i.data))),null}const i=this.#Rs[t];if(!i||i.data===ms)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#Rs[t];return!!e&&e.data!==ms}delete(t){const e=this.#Rs[t];return!(!e||e.data===ms)&&(delete this.#Rs[t],!0)}resolve(t,e=null){const i=this.#Ns(t);i.data=e,i.resolve()}clear(){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e?.bitmap?.close()}this.#Rs=Object.create(null)}*[Symbol.iterator](){for(const t in this.#Rs){const{data:e}=this.#Rs[t];e!==ms&&(yield[t,e])}}}class vs{#Fs=null;constructor(t){this.#Fs=t,this.onContinue=null}get promise(){return this.#Fs.capability.promise}cancel(t=0){this.#Fs.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#Fs.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#Fs;return t.form||t.canvas&&e?.size>0}}class ws{#Os=null;static#Bs=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 vs(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(ws.#Bs.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.");ws.#Bs.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 Ci(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.#Os&&(window.cancelAnimationFrame(this.#Os),this.#Os=null),ws.#Bs.delete(this._canvas),this.callback(t||new Xt(`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.#Os=window.requestAnimationFrame((()=>{this.#Os=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(),ws.#Bs.delete(this._canvas),this.callback())))}}const ys="4.10.38",As="f9bea397f";function _s(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function xs(t){return Math.max(0,Math.min(255,255*t))}class Ss{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=xs(t),t,t]}static G_HTML([t]){const e=_s(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(xs)}static RGB_HTML(t){return`#${t.map(_s).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[xs(1-Math.min(1,t+s)),xs(1-Math.min(1,i+s)),xs(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 Cs{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 Es=class extends Cs{_createSVG(t){return document.createElementNS($t,t)}},Ps=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&&es.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&&es.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 Ms=1e3,Ts=new WeakSet;function ks(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class Is{static create(t){switch(t.data.annotationType){case G:return new Ds(t);case W:return new Rs(t);case lt:switch(t.data.fieldType){case"Tx":return new Fs(t);case"Btn":return t.data.radioButton?new js(t):t.data.checkBox?new Bs(t):new Vs(t);case"Ch":return new Hs(t);case"Sig":return new Os(t)}return new Ns(t);case at:return new zs(t);case q:return new $s(t);case X:return new Ws(t);case K:return new Gs(t);case Y:return new qs(t);case J:return new Xs(t);case nt:return new Ys(t);case rt:return new Qs(t);case Q:return new Ks(t);case Z:return new Js(t);case tt:return new Zs(t);case et:return new tn(t);case it:return new en(t);case st:return new sn(t);case ot:return new nn(t);default:return new Ls(t)}}}class Ls{#js=null;#Vs=!1;#Hs=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 Ls._hasPopupData(this.data)}updateEdited(t){if(!this.container)return;this.#js||={rect:this.data.rect.slice(0)};const{rect:e}=t;e&&this.#zs(e),this.#Hs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Hs?.popup.resetEdited(),this.#js=null)}#zs(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}=ks(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 Ns||(n.tabIndex=Ms);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 zs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:a,height:o}=ks(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 js){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.#Vs=!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}=ks(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]=Ss[`${n}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Ss[`${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.#Vs){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.#Vs&&(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.#Hs=new zs({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||Ts.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&&(Ts.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 Ds extends Ls{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.#Us(i,t.attachment,t.attachmentDest),s=!0):t.setOCGState?(this.#$s(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}#Ws(){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.#Ws()}_bindNamedAction(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),this.#Ws()}#Us(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.#Ws()}#$s(t,e){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),this.#Ws()}_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.#Ws()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Ws(),!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&&(Ts.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 Rs extends Ls{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 Ns extends Ls{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 Fs extends Ns{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),Ts.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=Ms,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 Os extends Ns{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Bs extends Ns{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 Ts.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=Ms,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 js extends Ns{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(Ts.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=Ms,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 Vs extends Ds{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 Hs extends Ns{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");Ts.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=Ms;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 zs extends Ls{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:Ls._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Us({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=>`${Ut}${t}`)).join(",")),this.container}}class Us{#Gs=this.#qs.bind(this);#Xs=this.#Ks.bind(this);#Ys=this.#Qs.bind(this);#Js=this.#Zs.bind(this);#tn=null;#pt=null;#en=null;#in=null;#sn=null;#nn=null;#rn=null;#an=!1;#on=null;#E=null;#ln=null;#hn=null;#dn=null;#js=null;#cn=!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.#dn=s,this.#en=r,this.#hn=a,this.#nn=o,this.#tn=e,this.#ln=l,this.#rn=h,this.#sn=i,this.#in=se.toDateObject(n),this.trigger=i.flatMap((t=>t.getElementsToTriggerPopup()));for(const t of this.trigger)t.addEventListener("click",this.#Js),t.addEventListener("mouseenter",this.#Ys),t.addEventListener("mouseleave",this.#Xs),t.classList.add("popupTriggerArea");for(const t of i)t.container?.addEventListener("keydown",this.#Gs);this.#pt.hidden=!0,d&&this.#Zs()}render(){if(this.#on)return;const t=this.#on=document.createElement("div");if(t.className="popup",this.#tn){const e=t.style.outlineColor=jt.makeHexColor(...this.#tn);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.#tn.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.#dn),t.append(e),this.#in){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.#in.valueOf()})),e.append(t)}const s=this.#un;if(s)Ps.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const e=this._formatContents(this.#en);t.append(e)}this.#pt.append(t)}get#un(){const t=this.#hn,e=this.#en;return!t?.str||e?.str&&e.str!==t.str?null:this.#hn.html||null}get#pn(){return this.#un?.attributes?.style?.fontSize||0}get#gn(){return this.#un?.attributes?.style?.color||null}#fn(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},s={style:{color:this.#gn,fontSize:this.#pn?`calc(${this.#pn}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}#qs(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#an)&&this.#Zs()}updateEdited({rect:t,popupContent:e}){this.#js||={contentsObj:this.#en,richText:this.#hn},t&&(this.#E=null),e&&(this.#hn=this.#fn(e),this.#en=null),this.#on?.remove(),this.#on=null}resetEdited(){this.#js&&(({contentsObj:this.#en,richText:this.#hn}=this.#js),this.#js=null,this.#on?.remove(),this.#on=null,this.#E=null)}#mn(){if(null!==this.#E)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:s,pageY:n}}}=this.#nn;let r=!!this.#rn,a=r?this.#rn:this.#ln;for(const t of this.#sn)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]}%`}#Zs(){this.#an=!this.#an,this.#an?(this.#Qs(),this.#pt.addEventListener("click",this.#Js),this.#pt.addEventListener("keydown",this.#Gs)):(this.#Ks(),this.#pt.removeEventListener("click",this.#Js),this.#pt.removeEventListener("keydown",this.#Gs))}#Qs(){this.#on||this.render(),this.isVisible?this.#an&&this.#pt.classList.add("focused"):(this.#mn(),this.#pt.hidden=!1,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)+1e3)}#Ks(){this.#pt.classList.remove("focused"),!this.#an&&this.isVisible&&(this.#pt.hidden=!0,this.#pt.style.zIndex=parseInt(this.#pt.style.zIndex)-1e3)}forceHide(){this.#cn=this.isVisible,this.#cn&&(this.#pt.hidden=!0)}maybeShow(){this.#cn&&(this.#on||this.#Qs(),this.#cn=!1,this.#pt.hidden=!1)}get isVisible(){return!1===this.#pt.hidden}}class $s extends Ls{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 Ws extends Ls{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=this.#bn=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.#bn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gs extends Ls{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#vn=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.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class qs extends Ls{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=ks(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,r=this.#wn=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.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Xs extends Ls{#yn=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}=ks(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.#yn=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.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ks extends Xs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ys extends Ls{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 Qs extends Ls{#An=null;#_n=[];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}#xn(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.#xn(e,t),l=this.svgFactory.create(a,o,!0),h=this.#An=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.#_n.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.#An;if(e>=0&&n.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#_n.length;t<e;t++)this.#_n[t].setAttribute("points",i[t].join(","));if(s){const{transform:t,width:e,height:i}=this.#xn(this.data.rotation,s);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#_n}addHighlightArea(){this.container.classList.add("highlightArea")}}class Js extends Ls{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 Zs extends Ls{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 tn extends Ls{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 en extends Ls{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 sn extends Ls{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 nn extends Ls{#Sn=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.#Cn.bind(this)),this.#Sn=i;const{isMac:s}=Ot.platform;return t.addEventListener("keydown",(t=>{"Enter"===t.key&&(s?t.metaKey:t.ctrlKey)&&this.#Cn()})),!e.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#Sn}addHighlightArea(){this.container.classList.add("highlightArea")}#Cn(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}let rn=class{#En=null;#Pn=null;#Mn=new Map;#Tn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:r,structTreeLayer:a}){this.div=t,this.#En=e,this.#Pn=i,this.#Tn=a||null,this.page=n,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Mn.size>0}async#kn(t,e){const i=t.firstChild||t,s=i.id=`${Ut}${e}`,n=await(this.#Tn?.getAriaAttributes(s));if(n)for(const[t,e]of n)i.setAttribute(t,e);this.div.append(t),this.#En?.moveElementInDOM(this.div,t,i,!1)}async render(t){const{annotations:e}=t,i=this.div;le(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 Es,annotationStorage:t.annotationStorage||new Me,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}=ks(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=Is.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.#kn(r,t.id),i._isEditable&&(this.#Mn.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}this.#In()}update({viewport:t}){const e=this.div;this.viewport=t,le(e,{rotation:t.rotation}),this.#In(),e.hidden=!1}#In(){if(!this.#Pn)return;const t=this.div;for(const[e,i]of this.#Pn){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.#Pn.clear()}getEditableAnnotations(){return Array.from(this.#Mn.values())}getEditableAnnotation(t){return this.#Mn.get(t)}};const an=/\r\n?|\n/g;class on extends Ae{#tn;#Ln="";#Dn=`${this.id}-editor`;#Rn=null;#pn;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=on.prototype,e=t=>t.isEmpty(),i=ve.TRANSLATE_SMALL,s=ve.TRANSLATE_BIG;return Ct(this,"_keyboardManager",new me([[["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.#tn=t.color||on._defaultColor||Ae._defaultLineColor,this.#pn=t.fontSize||on._defaultFontSize}static initialize(t,e){Ae.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:on._defaultFontSize=e;break;case F.FREETEXT_COLOR:on._defaultColor=e}}updateParams(t,e){switch(t){case F.FREETEXT_SIZE:this.#Nn(e);break;case F.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[F.FREETEXT_SIZE,on._defaultFontSize],[F.FREETEXT_COLOR,on._defaultColor||Ae._defaultLineColor]]}get propertiesToUpdate(){return[[F.FREETEXT_SIZE,this.#pn],[F.FREETEXT_COLOR,this.#tn]]}#Nn(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--scale-factor))`,this.translate(0,-(t-this.#pn)*this.parentScale),this.#pn=t,this.#On()},i=this.#pn;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})}#Fn(t){const e=t=>{this.#tn=this.editorDiv.style.color=t},i=this.#tn;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[-on._internalPadding*t,-(on._internalPadding+this.#pn)*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.#Rn=new AbortController;const t=this._uiManager.combinedSignal(this.#Rn);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.#Dn),this._isDraggable=!0,this.#Rn?.abort(),this.#Rn=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(t){this.width||(this.enableEditMode(),t&&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()}#Bn(){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(on.#jn(i)),e=i);return t.join("\n")}#On(){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.#Ln,e=this.#Ln=this.#Bn().trimEnd();if(t===e)return;const i=t=>{this.#Ln=t,t?(this.#Vn(),this._uiManager.rebuild(this),this.#On()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#On()}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){on._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.#Dn),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.#pn}px * var(--scale-factor))`,i.color=this.#tn,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),ue(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.#Vn(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#jn(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(an,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=on.#Hn(e.getData("text")||"").replaceAll(an,"\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(an,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(on.#jn(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(an,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(on.#jn(i))}this.#Ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#Vn();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)}#Vn(){if(this.editorDiv.replaceChildren(),this.#Ln)for(const t of this.#Ln.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#zn(){return this.#Ln.replaceAll(" "," ")}static#Hn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof $s){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.#pn=t.fontSize,n.#tn=jt.makeHexColor(...t.color),n.#Ln=on.#Hn(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=on._internalPadding*this.parentScale,i=this.getRect(e,e),s=Ae._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:N.FREETEXT,color:s,fontSize:this.#pn,value:this.#zn(),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return t?n:this.annotationElementId&&!this.#Un(n)?null:(n.id=this.annotationElementId,n)}#Un(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.#pn}px * var(--scale-factor))`,i.color=this.#tn,e.replaceChildren();for(const t of this.#Ln.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}const s=on._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class ln{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 hn{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#tr;#er;#ir=[];static#sr=8;static#nr=2;static#rr=hn.#sr+hn.#nr;constructor({x:t,y:e},i,s,n,r,a=0){this.#$n=i,this.#er=n*s,this.#qn=r,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=a,this.#Zn=hn.#sr*s,this.#Jn=hn.#rr*s,this.#tr=s,this.#ir.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ar(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,r]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/r,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/r]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,r]=this.#$n;let[a,o,l,h]=this.#Kn.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Jn)return!1;const p=u-this.#Zn,g=p/u,f=g*d,m=g*c;let b=a,v=o;a=l,o=h,l+=f,h+=m,this.#ir?.push(t,e);const w=f/p,y=-m/p*this.#er,A=w*this.#er;if(this.#Kn.set(this.#Kn.subarray(2,8),0),this.#Kn.set([l+y,h+A],4),this.#Kn.set(this.#Kn.subarray(14,18),12),this.#Kn.set([l-y,h-A],16),isNaN(this.#Kn[6]))return 0===this.#Xn.length&&(this.#Kn.set([a+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(a+y-i)/n,(o+A-s)/r),this.#Kn.set([a-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(a-y-i)/n,(o-A-s)/r)),this.#Kn.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Kn.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.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/n,((o+h)/2-s)/r),[a,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/n,((v+o)/2-s)/r),!0):([b,v,a,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.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.#Kn.subarray(12,18),this.#Wn.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.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#or();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.#lr(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.#hr(i),i.join(" ")}#or(){const[t,e,i,s]=this.#$n,[n,r,a,o]=this.#ar();return`M${(this.#Kn[2]-t)/i} ${(this.#Kn[3]-e)/s} L${(this.#Kn[4]-t)/i} ${(this.#Kn[5]-e)/s} L${n} ${r} L${a} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#hr(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#lr(t){const[e,i,s,n]=this.#$n,r=this.#Kn.subarray(4,6),a=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ar();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 dn(t,e,i,s,n,r)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,r,a]=this.#$n,o=new Float32Array((this.#ir?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ir[t]-s)/r,o[t+1]=(this.#ir[t+1]-n)/a;if(o[o.length-2]=(this.#Yn-s)/r,o[o.length-1]=(this.#Qn-n)/a,isNaN(i[6])&&!this.isEmpty())return this.#dr(o);const l=new Float32Array(this.#Xn.length+24+this.#Wn.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.#cr(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.#ur(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#tr,this.#Gn,this.#qn)}#dr(t){const e=this.#Kn,[i,s,n,r]=this.#$n,[a,o,l,h]=this.#ar(),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.#$n,this.#tr,this.#Gn,this.#qn)}#ur(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#cr(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,r,a,o]=this.#$n,[l,h,d,c]=this.#ar();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 dn extends ln{#$n;#pr=new Float32Array(4);#Gn;#qn;#ir;#tr;#gr;constructor(t,e,i,s,n,r){super(),this.#gr=t,this.#ir=e,this.#$n=i,this.#tr=s,this.#Gn=n,this.#qn=r,this.lastPoint=[NaN,NaN],this.#fr(r);const[a,o,l,h]=this.#pr;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.#gr[4]} ${this.#gr[5]}`];for(let e=6,i=this.#gr.length;e<i;e+=6)isNaN(this.#gr[e])?t.push(`L${this.#gr[e+4]} ${this.#gr[e+5]}`):t.push(`C${this.#gr[e]} ${this.#gr[e+1]} ${this.#gr[e+2]} ${this.#gr[e+3]} ${this.#gr[e+4]} ${this.#gr[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=ln._rescale(this.#gr,t,s,r,-a),l=ln._rescale(this.#ir,t,s,r,-a);break;case 90:o=ln._rescaleAndSwap(this.#gr,t,e,r,a),l=ln._rescaleAndSwap(this.#ir,t,e,r,a);break;case 180:o=ln._rescale(this.#gr,i,e,-r,a),l=ln._rescale(this.#ir,i,e,-r,a);break;case 270:o=ln._rescaleAndSwap(this.#gr,i,s,-r,-a),l=ln._rescaleAndSwap(this.#ir,i,s,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#fr(t){const e=this.#gr;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.#pr;c[0]=n-this.#Gn,c[1]=r-this.#Gn,c[2]=a-n+2*this.#Gn,c[3]=o-r+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pr}newOutliner(t,e,i,s,n,r=0){return new hn(t,e,i,s,n,r)}getNewOutline(t,e){const[i,s,n,r]=this.#pr,[a,o,l,h]=this.#$n,d=n*l,c=r*h,u=i*l+a,p=s*h+o,g=this.newOutliner({x:this.#ir[0]*d+u,y:this.#ir[1]*c+p},this.#$n,this.#tr,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ir.length;t+=2)g.add({x:this.#ir[t]*d+u,y:this.#ir[t+1]*c+p});return g.getOutlines()}}class cn{#$n;#mr;#br=[];#vr=[];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.#br.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.#br.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#br){const[e,i,s]=t;t[0]=(e-c)/h,t[1]=(i-u)/d,t[2]=(s-u)/d}this.#$n=new Float32Array([c,u,h,d]),this.#mr=g}getOutlines(){this.#br.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#br)e[3]?(t.push(...this.#wr(e)),this.#yr(e)):(this.#Ar(e),t.push(...this.#wr(e)));return this.#_r(t)}#_r(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 un(s,this.#$n,this.#mr)}#xr(t){const e=this.#vr;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}#yr([,t,e]){const i=this.#xr(t);this.#vr.splice(i,0,[t,e])}#Ar([,t,e]){const i=this.#xr(t);for(let s=i;s<this.#vr.length;s++){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#vr[s];if(i!==t)break;if(i===t&&n===e)return void this.#vr.splice(s,1)}}#wr(t){const[e,i,s]=t,n=[[e,i,s]],r=this.#xr(s);for(let t=0;t<r;t++){const[i,s]=this.#vr[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 un extends ln{#$n;#Sr;constructor(t,e,i){super(),this.#Sr=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sr){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.#Sr){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.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class pn extends hn{newFreeDrawOutline(t,e,i,s,n,r){return new gn(t,e,i,s,n,r)}}class gn extends dn{newOutliner(t,e,i,s,n,r=0){return new pn(t,e,i,s,n,r)}}let fn=class t{#Cr=null;#Er=null;#Pr;#Mr=null;#Tr=!1;#kr=!1;#r=null;#Ir;#Lr=null;#f=null;#Dr;static#Rr=null;static get _keyboardManager(){return Ct(this,"_keyboardManager",new me([[["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.#kr=!1,this.#Dr=F.HIGHLIGHT_COLOR,this.#r=e):(this.#kr=!0,this.#Dr=F.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Ir=this.#f._eventBus,this.#Pr=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Rr||=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.#Cr=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.#Nr.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Er=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pr,t.append(i),t}renderMainDropdown(){const t=this.#Mr=this.#Fr();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fr(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",ee,{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.#Rr[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=n,r.setAttribute("aria-selected",n===this.#Pr),r.addEventListener("click",this.#Or.bind(this,n),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Or(t,e){e.stopPropagation(),this.#Ir.dispatch("switchannotationeditorparams",{source:this,type:this.#Dr,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Cr)return void this.#Nr(t);const e=t.target.getAttribute("data-color");e&&this.#Or(e,t)}_moveToNext(t){this.#Br?t.target!==this.#Cr?t.target.nextSibling?.focus():this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToPrevious(t){t.target!==this.#Mr?.firstChild&&t.target!==this.#Cr?(this.#Br||this.#Nr(t),t.target.previousSibling?.focus()):this.#Br&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Br?this.#Mr.firstChild?.focus():this.#Nr(t)}_moveToEnd(t){this.#Br?this.#Mr.lastChild?.focus():this.#Nr(t)}#qs(e){t._keyboardManager.exec(this,e)}#Nr(t){if(this.#Br)return void this.hideDropdown();if(this.#Tr=0===t.detail,this.#Lr||(this.#Lr=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#Lr)})),this.#Mr)return void this.#Mr.classList.remove("hidden");const e=this.#Mr=this.#Fr();this.#Cr.append(e)}#h(t){this.#Mr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Mr?.classList.add("hidden"),this.#Lr?.abort(),this.#Lr=null}get#Br(){return this.#Mr&&!this.#Mr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#kr||(this.#Br?(this.hideDropdown(),this.#Cr.focus({preventScroll:!0,focusVisible:this.#Tr})):this.#r?.unselect())}updateColor(t){if(this.#Er&&(this.#Er.style.backgroundColor=t),!this.#Mr)return;const e=this.#f.highlightColors.values();for(const i of this.#Mr.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Cr?.remove(),this.#Cr=null,this.#Er=null,this.#Mr?.remove(),this.#Mr=null}};class mn extends Ae{#jr=null;#Vr=0;#Hr;#zr=null;#n=null;#Ur=null;#$r=null;#Wr=0;#Gr=null;#qr=null;#w=null;#Xr=!1;#mr=null;#Kr;#Yr=null;#Qr="";#er;#Jr="";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=mn.prototype;return Ct(this,"_keyboardManager",new me([[["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||mn._defaultColor,this.#er=t.thickness||mn._defaultThickness,this.#Kr=t.opacity||mn._defaultOpacity,this.#Hr=t.boxes||null,this.#Jr=t.methodOfCreation||"",this.#Qr=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xr=!0,this.#Zr(t),this.#ta()):this.#Hr&&(this.#jr=t.anchorNode,this.#Vr=t.anchorOffset,this.#$r=t.focusNode,this.#Wr=t.focusOffset,this.#ea(),this.#ta(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xr?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#er,methodOfCreation:this.#Jr}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#ea(){const t=new cn(this.#Hr,.001);this.#qr=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qr.box;const e=new cn(this.#Hr,.0025,.001,"ltr"===this._uiManager.direction);this.#Ur=e.getOutlines();const{lastPoint:i}=this.#Ur;this.#mr=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Zr({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qr=t;if(this.#Ur=t.getNewOutline(this.#er/2+1.5,.0025),e>=0)this.#w=e,this.#zr=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Yr=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:mn.#ia(this.#qr.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Yr,{bbox:mn.#ia(this.#Ur.box,e),path:{d:this.#Ur.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.#Ur;this.#mr=[(o[0]-s)/r,(o[1]-n)/a]}static initialize(t,e){Ae.initialize(t,e),mn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case F.HIGHLIGHT_DEFAULT_COLOR:mn._defaultColor=e;break;case F.HIGHLIGHT_THICKNESS:mn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#mr}updateParams(t,e){switch(t){case F.HIGHLIGHT_COLOR:this.#Fn(e);break;case F.HIGHLIGHT_THICKNESS:this.#sa(e)}}static get defaultPropertiesToUpdate(){return[[F.HIGHLIGHT_DEFAULT_COLOR,mn._defaultColor],[F.HIGHLIGHT_THICKNESS,mn._defaultThickness]]}get propertiesToUpdate(){return[[F.HIGHLIGHT_COLOR,this.color||mn._defaultColor],[F.HIGHLIGHT_THICKNESS,this.#er||mn._defaultThickness],[F.HIGHLIGHT_FREE,this.#Xr]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Kr=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Kr;this.addCommands({cmd:e.bind(this,t,mn._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)}#sa(t){const e=this.#er,i=t=>{this.#er=t,this.#na(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 fn({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.#ra())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ra())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#aa(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#aa():t&&(this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#na(t){if(!this.#Xr)return;this.#Zr({highlightOutlines:this.#qr.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#aa(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Yr),this.#Yr=null)}#ta(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#zr}=t.drawLayer.draw({bbox:this.#qr.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Kr},rootClass:{highlight:!0,free:this.#Xr},path:{d:this.#qr.toSVGPath()}},!1,!0)),this.#Yr=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xr},bbox:this.#Ur.box,path:{d:this.#Ur.toSVGPath()}},this.#Xr),this.#Gr&&(this.#Gr.style.clipPath=this.#zr))}static#ia([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.#Xr?(t=(t-this.rotation+360)%360,i=mn.#ia(this.#qr.box,t)):i=mn.#ia([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Yr,{bbox:mn.#ia(this.#Ur.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qr&&(t.setAttribute("aria-label",this.#Qr),t.setAttribute("role","mark")),this.#Xr?t.classList.add("free"):this.div.addEventListener("keydown",this.#oa.bind(this),{signal:this._uiManager._signal});const e=this.#Gr=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#zr;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),ue(this,this.#Gr,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1}})}#oa(t){mn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#la(!0);break;case 1:case 3:this.#la(!1)}}#la(t){if(!this.#jr)return;const e=window.getSelection();t?e.setPosition(this.#jr,this.#Vr):e.setPosition(this.#$r,this.#Wr)}select(){super.select(),this.#Yr&&this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Yr&&(this.parent?.drawLayer.updateProperties(this.#Yr,{rootClass:{selected:!1}}),this.#Xr||this.#la(!1))}get _mustFixPosition(){return!this.#Xr}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Yr,{rootClass:{hidden:!t}}))}#ra(){return this.#Xr?this.rotation:0}#ha(){if(this.#Xr)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Hr,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}#da(t){return this.#qr.serialize(t,this.#ra())}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.#ca(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",ie,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",ee,{signal:d}),i.addEventListener("pointermove",this.#ua.bind(this,t),{signal:d}),this._freeHighlight=new pn({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#ua(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#ca(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 Js){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 Qs){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.#Kr=o||1,a&&(l.#er=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#Hr=[];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.#ea(),l.#ta(),l.rotate(l.rotation)}else if(a){l.#Xr=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new pn(i,[0,0,h,d],1,l.#er/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.#Zr({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:r}),l.#ta()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=Ae._colorManager.convert(this.color),s={annotationType:N.HIGHLIGHT,color:i,opacity:this.#Kr,thickness:this.#er,quadPoints:this.#ha(),outlines:this.#da(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ra(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Un(s)?null:(s.id=this.annotationElementId,s)}#Un(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 bn{#pa=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.#pa[t]=e}toSVGProperties(){const t=this.#pa;return this.#pa=Object.create(null),{root:t}}reset(){this.#pa=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){_t("Not implemented")}}class vn extends Ae{#ga=null;#fa;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#ma=null;static#ba=null;static#va=null;static#wa=NaN;static#ya=null;static#Aa=null;static#_a=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fa=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xa(t),this.#ta())}#xa({drawOutlines:t,drawId:e,drawingOptions:i}){this.#ga=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sa(t,this.parent),this.#Ca(t.box)}#Sa(t,e){const{id:i}=e.drawLayer.draw(vn._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&&(vn.#ma.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.#ga.updateProperty(e,t);i&&this.#Ca(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,vn._mergeSVGProperties(this.#ga.getPathResizingSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties(this.#ga.getPathResizedSVGProperties(this.#Ea()),{bbox:this.#Pa()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pa(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,vn._mergeSVGProperties(this.#ga.getPathTranslatedSVGProperties(this.#Ea(),this.parentDimensions),{bbox:this.#Pa()}))}_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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#fa&&(this.#fa=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#aa(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ta(),this.#Ca(this.#ga.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#aa()):t&&(this._uiManager.addShouldRescale(this),this.#ta(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#aa(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ta(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sa(this.#ga,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Ma([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]}}#Ca(t){if([this.x,this.y,this.width,this.height]=this.#Ma(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pa(){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,vn._mergeSVGProperties({bbox:this.#Pa()},this.#ga.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Ca(this.#ga.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,s){const{target:n,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=s;if(vn.#ya&&vn.#ya!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=vn.#ba=new AbortController,p=t.combinedSignal(u);vn.#wa||=o,vn.#ya??=l,window.addEventListener("pointerup",(t=>{vn.#wa===t.pointerId?this._endDraw(t):vn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{vn.#wa===t.pointerId?this._currentParent.endDrawingSession():vn.#Aa?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{vn.#ya===t.pointerType&&((vn.#Aa||=new Set).add(t.pointerId),vn.#ma.isCancellable()&&(vn.#ma.removeLastElement(),vn.#ma.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",ee,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===vn.#_a&&ie(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),vn.#ma?t.drawLayer.updateProperties(this._currentDrawId,vn.#ma.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),vn.#ma=this.createDrawerInstance(r,a,d,c,h),vn.#va=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(vn.#va.toSVGProperties(),vn.#ma.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(vn.#_a=-1,!vn.#ma)return;const{offsetX:e,offsetY:i,pointerId:s}=t;vn.#wa===s&&(vn.#Aa?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,vn.#ma.add(e,i)),vn.#_a=t.timeStamp,ie(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,vn.#ma=null,vn.#va=null,vn.#ya=null,vn.#_a=NaN),vn.#ba&&(vn.#ba.abort(),vn.#ba=null,vn.#wa=NaN,vn.#Aa=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,vn.#ma.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=vn.#ma,i=this._currentDrawId,s=t.getLastElement();e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(s))},undo:()=>{e.drawLayer.updateProperties(i,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),!vn.#ma.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:vn.#ma.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:vn.#va,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),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.#xa({drawOutlines:o}),l.#ta(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#ga.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class wn{#Kn=new Float64Array(6);#bn;#Ta;#Ri;#er;#ir;#ka="";#Ia=0;#Sr=new yn;#La;#Da;constructor(t,e,i,s,n,r){this.#La=i,this.#Da=s,this.#Ri=n,this.#er=r,[t,e]=this.#Ra(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e],this.#Ta=[{line:a,points:this.#ir}],this.#Kn.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#er=e)}#Ra(t,e){return ln._normalizePoint(t,e,this.#La,this.#Da,this.#Ri)}isEmpty(){return!this.#Ta||0===this.#Ta.length}isCancellable(){return this.#ir.length<=10}add(t,e){[t,e]=this.#Ra(t,e);const[i,s,n,r]=this.#Kn.subarray(2,6),a=t-n,o=e-r;return Math.hypot(this.#La*a,this.#Da*o)<=2?null:(this.#ir.push(t,e),isNaN(i)?(this.#Kn.set([n,r,t,e],2),this.#bn.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Kn[0])&&this.#bn.splice(6,6),this.#Kn.set([i,s,n,r,t,e],0),this.#bn.push(...ln.createBezierPoints(i,s,n,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ir.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#La=i,this.#Da=s,this.#Ri=n,[t,e]=this.#Ra(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ir=[t,e];const a=this.#Ta.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#Ta.push({line:r,points:this.#ir}),this.#Kn.set(r,0),this.#Ia=0,this.toSVGPath(),null}getLastElement(){return this.#Ta.at(-1)}setLastElement(t){return this.#Ta?(this.#Ta.push(t),this.#bn=t.line,this.#ir=t.points,this.#Ia=0,{path:{d:this.toSVGPath()}}):this.#Sr.setLastElement(t)}removeLastElement(){if(!this.#Ta)return this.#Sr.removeLastElement();this.#Ta.pop(),this.#ka="";for(let t=0,e=this.#Ta.length;t<e;t++){const{line:e,points:i}=this.#Ta[t];this.#bn=e,this.#ir=i,this.#Ia=0,this.toSVGPath()}return{path:{d:this.#ka}}}toSVGPath(){const t=ln.svgRound(this.#bn[4]),e=ln.svgRound(this.#bn[5]);if(2===this.#ir.length)return this.#ka=`${this.#ka} M ${t} ${e} Z`,this.#ka;if(this.#ir.length<=6){const i=this.#ka.lastIndexOf("M");this.#ka=`${this.#ka.slice(0,i)} M ${t} ${e}`,this.#Ia=6}if(4===this.#ir.length){const t=ln.svgRound(this.#bn[10]),e=ln.svgRound(this.#bn[11]);return this.#ka=`${this.#ka} L ${t} ${e}`,this.#Ia=12,this.#ka}const i=[];0===this.#Ia&&(i.push(`M ${t} ${e}`),this.#Ia=6);for(let t=this.#Ia,e=this.#bn.length;t<e;t+=6){const[e,s,n,r,a,o]=this.#bn.slice(t,t+6).map(ln.svgRound);i.push(`C${e} ${s} ${n} ${r} ${a} ${o}`)}return this.#ka+=i.join(" "),this.#Ia=this.#bn.length,this.#ka}getOutlines(t,e,i,s){const n=this.#Ta.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sr.build(this.#Ta,t,e,i,this.#Ri,this.#er,s),this.#Kn=null,this.#bn=null,this.#Ta=null,this.#ka=null,this.#Sr}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class yn extends ln{#pr;#Na=0;#Gn;#Ta;#La;#Da;#Fa;#Ri;#er;build(t,e,i,s,n,r,a){this.#La=e,this.#Da=i,this.#Fa=s,this.#Ri=n,this.#er=r,this.#Gn=a??0,this.#Ta=t,this.#Oa()}setLastElement(t){return this.#Ta.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Ta.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Ta)if(t.push(`M${ln.svgRound(e[4])} ${ln.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(ln.svgRound);t.push(`C${s} ${n} ${r} ${a} ${o} ${l}`)}else t.push(`L${ln.svgRound(e[10])} ${ln.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const r=[],a=[],[o,l,h,d]=this.#Ba();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=ln._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=ln._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=ln._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=ln._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.#Ta)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=ln._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=ln._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=ln._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=ln._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(ln.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 yn;return f.build(h,i,s,1,o,l,n),f}#ja(t=this.#er){const e=this.#Gn+t/2*this.#Fa;return this.#Ri%180==0?[e/this.#La,e/this.#Da]:[e/this.#Da,e/this.#La]}#Ba(){const[t,e,i,s]=this.#pr,[n,r]=this.#ja(0);return[t+n,e+r,i-2*n,s-2*r]}#Oa(){const t=this.#pr=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Ta){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.#ja();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.#pr}updateProperty(t,e){return"stroke-width"===t?this.#sa(e):null}#sa(t){const[e,i]=this.#ja();this.#er=t;const[s,n]=this.#ja(),[r,a]=[s-e,n-i],o=this.#pr;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[s,n]=this.#ja();this.#La=t,this.#Da=e,this.#Fa=i;const[r,a]=this.#ja(),o=r-s,l=a-n,h=this.#pr;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Na=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pr.map(ln.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pr;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pr;let i=0,s=0,n=0,r=0,a=0,o=0;switch(this.#Na){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} ${ln.svgRound(a)} ${ln.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),[a,o,l,h]=this.#pr;if(Math.abs(l-n)<=ln.PRECISION||Math.abs(h-r)<=ln.PRECISION){const n=t+i/2-(a+l/2),r=e+s/2-(o+h/2);return{path:{"transform-origin":`${ln.svgRound(t)} ${ln.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":`${ln.svgRound(a)} ${ln.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${ln.svgRound(n)} ${ln.svgRound(r)}) scale(${d} ${c}) translate(${ln.svgRound(-n)} ${ln.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,r]=this.#ja(),a=this.#pr,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=s,Math.abs(h-n)<=ln.PRECISION||Math.abs(d-r)<=ln.PRECISION){const n=t+i/2-(o+h/2),r=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Ta)ln._translate(t,n,r,t),ln._translate(e,n,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.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.#Ta)ln._rescale(t,p,g,c,u,t),ln._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ln.svgRound(t)} ${ln.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,r=this.#pr,a=t-r[0],o=e-r[1];if(this.#La===s&&this.#Da===n)for(const{line:t,points:e}of this.#Ta)ln._translate(t,a,o,t),ln._translate(e,a,o,e);else{const t=this.#La/s,e=this.#Da/n;this.#La=s,this.#Da=n;for(const{line:i,points:s}of this.#Ta)ln._rescale(i,a,o,t,e,i),ln._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":`${ln.svgRound(t)} ${ln.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pr;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ln.svgRound(t[0])} ${ln.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class An extends bn{#Va;constructor(t){super(),this.#Va=t,super.updateProperties({fill:"none",stroke:Ae._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.#Va.realScale),super.updateSVGProperty(t,e)}clone(){const t=new An(this.#Va);return t.updateAll(this),t}}class _n extends vn{static _type="ink";static _editorType=N.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){Ae.initialize(t,e),this._defaultDrawingOptions=new An(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 wn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,r){return yn.deserialize(t,e,i,s,n,r)}static async deserialize(t,e,i){let s=null;if(t instanceof Qs){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=_n.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:Ae._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.#Un(o)?null:(o.id=this.annotationElementId,o)}#Un(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 xn extends Ae{#Ha=null;#za=null;#Ua=null;#$a=null;#Wa=null;#Ga="";#qa=null;#Xa=null;#Ka=!1;#Ya=!1;static _type="stamp";static _editorType=N.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$a=t.bitmapUrl,this.#Wa=t.bitmapFile}static initialize(t,e){Ae.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}}#Qa(t,e=!1){t?(this.#Ha=t.bitmap,e||(this.#za=t.id,this.#Ka=t.isSvg),t.file&&(this.#Ga=t.file.name),this.#Ja()):this.remove()}#Za(){if(this.#Ua=null,this._uiManager.enableWaiting(!1),this.#qa){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Ha){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}#to(){if(this.#za)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#za).then((t=>this.#Qa(t,!0))).finally((()=>this.#Za()));if(this.#$a){const t=this.#$a;return this.#$a=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}if(this.#Wa){const t=this.#Wa;return this.#Wa=null,this._uiManager.enableWaiting(!0),void(this.#Ua=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qa(t))).finally((()=>this.#Za())))}const t=document.createElement("input");t.type="file",t.accept=xn.supportedTypesStr;const e=this._uiManager._signal;this.#Ua=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.#Qa(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Za())),t.click()}remove(){this.#za&&(this.#Ha=null,this._uiManager.imageManager.deleteId(this.#za),this.#qa?.remove(),this.#qa=null,this.#Xa&&(clearTimeout(this.#Xa),this.#Xa=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#za&&null===this.#qa&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#za&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ua||this.#Ha||this.#$a||this.#Wa||this.#za)}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.#Ha?this.#Ja():this.#to(),this.width&&!this.annotationElementId){const[i,s]=this.parentDimensions;this.setAt(t*i,e*s,this.width*i,this.height*s)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Xa&&clearTimeout(this.#Xa);this.#Xa=setTimeout((()=>{this.#Xa=null,this.#eo()}),200)}#Ja(){const{div:t}=this;let{width:e,height:i}=this.#Ha;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.#qa=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=e/s,this.height=i/n,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#eo(),this.#Ya||(this.parent.addUndoableEditor(this),this.#Ya=!0),this._reportTelemetry({action:"inserted_image"}),this.#Ga&&l.setAttribute("aria-label",this.#Ga)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Ha,r=new he;let a=this.#Ha,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.#Ka||(a=this.#io(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.#Ha,s>t||n>t){const r=Math.min(t/s,t/n);e=Math.floor(s*r),i=Math.floor(n*r),this.#Ka||(a=this.#io(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}}#io(t,e){const{width:i,height:s}=this.#Ha;let n=i,r=s,a=this.#Ha;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}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new he,r=Math.ceil(i*t*n.sx),a=Math.ceil(s*e*n.sy),o=this.#qa;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#Ka?this.#Ha:this.#io(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}getImageForAltText(){return this.#qa}#so(t){if(t){if(this.#Ka){const t=this._uiManager.imageManager.getSvgUrl(this.#za);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Ha);return t.getContext("2d").drawImage(this.#Ha,0,0),t.toDataURL()}if(this.#Ka){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Wt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*Wt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Ha,0,0,this.#Ha.width,this.#Ha.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Ha)}static async deserialize(t,e,i){let s=null;if(t instanceof sn){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(`${Ut}${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.#za=l,a&&(n.#Ha=a)):n.#$a=o,n.#Ka=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.#Ya=!!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.#za,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Ka,structTreeParentId:this._structTreeParentId};if(t)return i.bitmapUrl=this.#so(!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.#Un(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.#Ka?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#za)){if(this.#Ka){const t=e.stamps.get(this.#za);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#za,{area:r,serialized:i}),i.bitmap=this.#so(!1);return i}#Un(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 Sn=class t{#En;#no=!1;#ro=null;#ao=null;#oo=null;#lo=new Map;#ho=!1;#do=!1;#co=!1;#uo=null;#po=null;#go=null;#fo=null;#f;static _initialized=!1;static#H=new Map([on,_n,xn,mn].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.#En=r,this.#ro=a,this.viewport=h,this.#go=l,this.drawLayer=o,this._structTree=n,this.#f.addLayer(this)}get isEmpty(){return 0===this.#lo.size}get isInvisible(){return this.isEmpty&&this.#f.getMode()===N.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),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.#go?.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.#ro?.div.classList.toggle("disabled",!t)}async enable(){this.#co=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const e of this.#lo.values())e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#f.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));if(!this.#ro)return void(this.#co=!1);const e=this.#ro.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())}this.#co=!1}disable(){this.#do=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,i=new Map;for(const t of this.#lo.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.#ro){const t=this.#ro.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.#mo(),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.#do=!1}getEditableAnnotation(t){return this.#ro?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#f.getActive()!==t&&this.#f.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#go?.div&&!this.#fo){this.#fo=new AbortController;const t=this.#f.combinedSignal(this.#fo);this.#go.div.addEventListener("pointerdown",this.#bo.bind(this),{signal:t}),this.#go.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#go?.div&&this.#fo&&(this.#fo.abort(),this.#fo=null,this.#go.div.classList.remove("highlighting"))}#bo(t){this.#f.unselectAll();const{target:e}=t;if(e===this.#go.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#go.div.contains(e)){const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),mn.startHighlighting(this,"ltr"===this.#f.direction,{target:this.#go.div,x:t.x,y:t.y}),this.#go.div.addEventListener("pointerup",(()=>{this.#go.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#f._signal}),t.preventDefault()}}enableClick(){if(this.#ao)return;this.#ao=new AbortController;const t=this.#f.combinedSignal(this.#ao);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#ao?.abort(),this.#ao=null}attach(t){this.#lo.set(t.id,t);const{annotationElementId:e}=t;e&&this.#f.isDeletedAnnotationElement(e)&&this.#f.removeDeletedAnnotationElement(t)}detach(t){this.#lo.delete(t.id),this.#En?.removePointerInTextLayer(t.contentDiv),!this.#do&&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),Ae.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.#co),this.#f.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#oo&&(t._focusEventsAllowed=!1,this.#oo=setTimeout((()=>{this.#oo=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.#En?.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#vo(){return t.#H.get(this.#f.getMode())}combinedSignal(t){return this.#f.combinedSignal(t)}#wo(t){const e=this.#vo;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#vo?.canCreateNewEmptyEditor()}pasteEditor(t,e){this.#f.updateToolbar(t),this.#f.updateMode(t);const{offsetX:i,offsetY:s}=this.#yo(),n=this.getNextId(),r=this.#wo({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.#wo({parent:this,id:s,x:t.offsetX,y:t.offsetY,uiManager:this.#f,isCentered:e,...i});return n&&this.add(n),n}#yo(){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.#yo(),!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.#ho&&(this.#ho=!1,this.#vo?.isDrawer&&this.#vo.supportMultipleDrawings||(this.#no?this.#f.getMode()!==N.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===N.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=Ot.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#ho=!0,this.#vo?.isDrawer)return void this.startDrawingSession(t);const i=this.#f.getActive();this.#no=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus(),this.#uo)return void this.#vo.startDrawing(this,this.#f,!1,t);this.#f.setCurrentDrawingSession(this),this.#uo=new AbortController;const e=this.#f.combinedSignal(this.#uo);this.div.addEventListener("blur",(({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#po=null,this.commitOrRemove())}),{signal:e}),this.#vo.startDrawing(this,this.#f,!1,t)}pause(t){if(t){const{activeElement:t}=document;this.div.contains(t)&&(this.#po=t)}else this.#po&&setTimeout((()=>{this.#po?.focus(),this.#po=null}),0)}endDrawingSession(t=!1){return this.#uo?(this.#f.setCurrentDrawingSession(null),this.#uo.abort(),this.#uo=null,this.#po=null,this.#vo.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.#uo&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#uo&&this.#vo.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#f.getActive()?.parent===this&&(this.#f.commitOrRemove(),this.#f.setActiveEditor(null)),this.#oo&&(clearTimeout(this.#oo),this.#oo=null);for(const t of this.#lo.values())this.#En?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#lo.clear(),this.#f.removeLayer(this)}#mo(){for(const t of this.#lo.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,le(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.#mo();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,le(this.div,{rotation:i}),e!==i)for(const t of this.#lo.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#f.viewParameters.realScale}},Cn=class t{#nn=null;#w=0;#Ao=new Map;#_o=new Map;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#nn){if(this.#nn!==t){if(this.#Ao.size>0)for(const e of this.#Ao.values())e.remove(),t.append(e);this.#nn=t}}else this.#nn=t}static get _svgFactory(){return Ct(this,"_svgFactory",new Es)}static#xo(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+"%"}#So(){const e=t._svgFactory.create(1,1,!0);return this.#nn.append(e),e.setAttribute("aria-hidden",!0),e}#Co(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}#Eo(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.#So(),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.#_o.set(n,o);const h=s?this.#Co(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#Ao.set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),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.#Ao.set(s,n),s}finalizeDraw(t,e){this.#_o.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.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(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.#Eo(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#Ao.get(t);i&&(e.#nn.append(i),this.#Ao.delete(t),e.#Ao.set(t,i))}remove(t){this.#_o.delete(t),null!==this.#nn&&(this.#Ao.get(t).remove(),this.#Ao.delete(t))}destroy(){this.#nn=null;for(const t of this.#Ao.values())t.remove();this.#Ao.clear(),this.#_o.clear()}};globalThis.pdfjsTestingUtils={HighlightOutliner:cn};var En=A.AnnotationEditorParamsType,Pn=A.AnnotationEditorType,Mn=A.AnnotationMode,Tn=A.GlobalWorkerOptions,kn=A.PDFDateString,In=A.PixelsPerInch,Ln=A.RenderingCancelledException,Dn=A.getDocument,Rn=A.getPdfFilenameFromUrl,Nn=A.getXfaPageViewport,Fn={d:(t,e)=>{for(var i in e)Fn.o(e,i)&&!Fn.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},On=globalThis.pdfjsViewer={};Fn.d(On,{AnnotationLayerBuilder:()=>Ca,DownloadManager:()=>Pa,EventBus:()=>ka,FindState:()=>mr,GenericL10n:()=>Go,LinkTarget:()=>Ir,PDFFindController:()=>kr,PDFHistory:()=>Xo,PDFLinkService:()=>Lr,PDFPageView:()=>ml,PDFScriptingManager:()=>wl,PDFSinglePageViewer:()=>Pl,PDFViewer:()=>El,ProgressBar:()=>nr,RenderingStates:()=>Bn,ScrollMode:()=>Gn,SimpleLinkService:()=>Dr,SpreadMode:()=>qn,StructTreeLayerBuilder:()=>hl,TextLayerBuilder:()=>ul,XfaLayerBuilder:()=>pl,parseQueryString:()=>Kn});const Bn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},jn=0,Vn=1,Hn=2,zn=3,Un=0,$n=1,Wn=2,Gn={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},qn={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Xn(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 Kn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Yn=/[\x00-\x1F]/g;function Qn(t,e=!1){return Yn.test(t)?e?t.replaceAll(Yn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function Jn(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 Zn(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 tr(t,e){return t-t%e}function er(t){return Number.isInteger(t)&&t%90==0}function ir(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const sr=document.documentElement.style;let nr=class{#Po=null;#Mo=null;#To=0;#ko=null;#wi=!0;constructor(t){this.#Po=t.classList,this.#ko=t.style}get percent(){return this.#To}set percent(t){var e,i,s;this.#To=(e=t,i=0,s=100,Math.min(Math.max(e,i),s)),isNaN(t)?this.#Po.add("indeterminate"):(this.#Po.remove("indeterminate"),this.#ko.setProperty("--progressBar-percent",`${this.#To}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#ko.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#To||isNaN(this.#To)||(this.#Mo&&clearTimeout(this.#Mo),this.show(),this.#Mo=setTimeout((()=>{this.#Mo=null,this.hide()}),t))}hide(){this.#wi&&(this.#wi=!1,this.#Po.add("hidden"))}show(){this.#wi||(this.#wi=!0,this.#Po.remove("hidden"))}};const rr=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}(),ar=0,or=1,lr=2,hr=3,dr=4,cr=5,ur=6,pr=7;function gr(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)?ar:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?or:lr:function(t){return 3584==(65408&t)}(t)?pr:160===t?ar:or:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?hr:function(t){return t>=12448&&t<=12543}(t)?dr:function(t){return t>=12352&&t<=12447}(t)?cr:function(t){return t>=65376&&t<=65439}(t)?ur:or}let fr;const mr={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},br={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},vr=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 wr;const yr=/\p{M}+/gu,Ar=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,_r=/([^\p{M}])\p{M}*$/u,xr=/^\p{M}*([^\p{M}])/u,Sr=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Cr=new Map,Er=new Map;let Pr=null,Mr=null;function Tr(t){const e=[];let i,s;for(;null!==(i=Sr.exec(t));){let{index:t}=i;for(const s of i[0]){let i=Cr.get(s);i||(i=s.normalize("NFD").length,Cr.set(s,i)),e.push([i,t++])}}if(0===e.length&&Pr)s=Pr;else if(e.length>0&&Mr)s=Mr;else{const t=`([${Object.keys(br).join("")}])|([${fr||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",fr}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;s=0===e.length?Pr=new RegExp(t+"|(\\u0000)","gum"):Mr=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=yr.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=br[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=Er.get(s);t||(t=s.normalize("NFKC"),Er.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 kr{#Io=null;#Lo=!0;#Do=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#Lo=i,this.onIsPageVisible=null,this.#Ro(),e._on("find",this.#No.bind(this)),e._on("findbarclose",this.#Fo.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.#Io}setDocument(t){this._pdfDocument&&this.#Ro(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#No(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#Io||this.#Oo(t))&&(this._dirtyMatch=!0),this.#Io=t,"highlightallchange"!==i&&this.#Bo(mr.PENDING),this._firstPageCapability.promise.then((()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#Bn();const t=!this._highlightMatches,s=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#jo():"again"===i?(this.#jo(),t&&this.#Io.highlightAll&&this.#Vo()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Vo()):this.#jo():this._findTimeout=setTimeout((()=>{this.#jo(),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;Xn(t,{top:-50,left:e+-400},!0)}#Ro(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#Do=0,this.#Io=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#Ho(){const{query:t}=this.#Io;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=Tr(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>Tr(t)[0]))}#Oo(t){const e=t.query,i=this.#Io.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}#zo(t,e,i){let s=t.slice(0,e).match(_r);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(gr(i)===gr(n))return!1}if(s=t.slice(e+i).match(xr),s){const n=t.charCodeAt(e+i-1),r=s[1].charCodeAt(0);if(gr(n)===gr(r))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Io;let s=!1;const n="[ ]*";return(t=t.replaceAll(Ar,((t,n,r,a,o,l)=>n?`[ ]*\\${n}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?vr.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(wr||=String.fromCharCode(...vr),s=!0,t=`${t}(?=[${wr}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Ho;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=Jn(s,(t=>t>=r));s[o]>r&&--o;let l=Jn(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.#Io.highlightAll&&this.#Wo(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Go());const o=n.length;this._matchesCountTotal+=o,this.#Lo?o>0&&this.#qo():++this.#Do===this._linkService.pagesCount&&this.#qo()}match(t,e,i){const s=this._hasDiacritics[i];let n=!1;if("string"==typeof t?[n,t]=this.#Uo(t,s):t=t.sort().reverse().map((t=>{const[e,i]=this.#Uo(t,s);return n||=e,`(${i})`})).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#Io;t=new RegExp(t,`g${n?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#zo(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#Bn(){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]]=Tr(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()}))))}}#Wo(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Vo(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#jo(){const t=this.#Io.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.#Do=0,this._matchesCountTotal=0,this.#Vo();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then((()=>{this._pendingFindMatches.delete(t),this.#$o(t)})))}if(0===this.#Ho.length)return void this.#Bo(mr.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.#Xo(!0);this.#Ko(t)}this.#Go()}#Yo(t){const e=this._offset,i=t.length,s=this.#Io.findPrevious;return i?(e.matchIdx=s?i-1:0,this.#Xo(!0),!0):(this.#Ko(s),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Xo(!1),!0))}#Go(){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.#Yo(t))}#Ko(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)}#Xo(t=!1){let e=mr.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?mr.WRAPPED:mr.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Wo(t)}this.#Bo(e,this.#Io.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Wo(this._selected.pageIdx))}#Fo(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.#Bo(mr.FOUND),this._highlightMatches=!1,this.#Vo())}))}#Qo(){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}}#qo(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#Qo()})}#Bo(t,e=!1){(this.#Lo||this.#Do===this._linkService.pagesCount&&t!==mr.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#Io?.entireWord??null,matchesCount:this.#Qo(),rawQuery:this.#Io?.query??null})}}const Ir={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Lr{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?Ir.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 Ir.NONE:break;case Ir.SELF:r="_self";break;case Ir.BLANK:r="_blank";break;case Ir.PARENT:r="_parent";break;case Ir.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=Kn(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||Lr.#Jo(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#Jo(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 Dr extends Lr{setDocument(t,e=null){}}const{AbortException:Rr,AnnotationEditorLayer:Nr,AnnotationEditorParamsType:Fr,AnnotationEditorType:Or,AnnotationEditorUIManager:Br,AnnotationLayer:jr,AnnotationMode:Vr,build:Hr,ColorPicker:zr,createValidAbsoluteUrl:Ur,DOMSVGFactory:$r,DrawLayer:Wr,FeatureTest:Gr,fetchData:qr,getDocument:Xr,getFilenameFromUrl:Kr,getPdfFilenameFromUrl:Yr,getXfaPageViewport:Qr,GlobalWorkerOptions:Jr,ImageKind:Zr,InvalidPDFException:ta,isDataScheme:ea,isPdfFile:ia,MissingPDFException:sa,noContextMenu:na,normalizeUnicode:ra,OPS:aa,OutputScale:oa,PasswordResponses:la,PDFDataRangeTransport:ha,PDFDateString:da,PDFWorker:ca,PermissionFlag:ua,PixelsPerInch:pa,RenderingCancelledException:ga,setLayerDimensions:fa,shadow:ma,stopEvent:ba,TextLayer:va,TouchManager:wa,UnexpectedResponseException:ya,Util:Aa,VerbosityLevel:_a,version:xa,XfaLayer:Sa}=globalThis.pdfjsLib;class Ca{#Zo=null;#tl=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.#Zo=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.#Zo?.(a),0!==s.length?(this.annotationLayer=new jr({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.#el(zn),this.#tl||(this.#tl=new AbortController,this._eventBus?._on("presentationmodechanged",(t=>{this.#el(t.state)}),{signal:this.#tl.signal}))):this.hide()}cancel(){this._cancelled=!0,this.#tl?.abort(),this.#tl=null}hide(){this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}#el(t){if(!this.div)return;let e=!1;switch(t){case zn:e=!0;break;case Vn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function Ea(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 Pa{#il=new WeakMap;downloadData(t,e,i){Ea(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=ia(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(!Ur(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}Ea(s,i)}}const Ma="event",Ta="timeout";class ka{#As=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.#As[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.#As[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:s})}_off(t,e,i=null){const s=this.#As[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 Ia{constructor(t){this.value=t}valueOf(){return this.value}}class La extends Ia{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class Da extends Ia{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 Ra extends Ia{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 Na(t,e,i){if(i===e)return!0;if(i instanceof Da&&e instanceof Da&&i.value===e.value)return!0;if(e instanceof Da&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Fa(t,e,i){return e[i]?Va(t,e[i].value):(t.reportError(new RangeError("No default")),new La)}function Oa(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=Ba(t,n.value):i.push(Ba(t,n));return{positional:i,named:s}}function Ba(t,e){switch(e.type){case"str":return e.value;case"num":return new Da(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 La(`$${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 La(`$${e}`);i=t.args[e]}if(i instanceof Ia)return i;switch(typeof i){case"string":return i;case"number":return new Da(i);case"object":if(i instanceof Date)return new Ra(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new La(`$${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 La(e);if(i){const n=s.attributes[i];return n?Va(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new La(`${e}.${i}`))}if(s.value)return Va(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new La(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 La(n);if(i){const e=r.attributes[i];if(e){t.params=Oa(t,s).named;const i=Va(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new La(`${n}.${i}`)}t.params=Oa(t,s).named;const a=Va(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 La(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new La(`${e}()`);try{let e=Oa(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new La(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=Ba(t,e);if(n instanceof La)return Fa(t,i,s);for(const e of i){if(Na(t,n,Ba(t,e.key)))return Va(t,e.value)}return Fa(t,i,s)}(t,e);default:return new La}}function ja(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new La;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(Ba(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Va(t,e){return"string"==typeof e?t.bundle._transform(e):ja(t,e)}class Ha{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 za(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 Ua=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function $a(t,e){let i=t[0];if(i instanceof La)return new La(`NUMBER(${i.valueOf()})`);if(i instanceof Da)return new Da(i.valueOf(),{...i.opts,...za(e,Ua)});if(i instanceof Ra)return new Da(i.valueOf(),{...za(e,Ua)});throw new TypeError("Invalid argument to NUMBER")}const Wa=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ga(t,e){let i=t[0];if(i instanceof La)return new La(`DATETIME(${i.valueOf()})`);if(i instanceof Ra)return new Ra(i.valueOf(),{...i.opts,...za(e,Wa)});if(i instanceof Da)return new Ra(i.valueOf(),{...za(e,Wa)});throw new TypeError("Invalid argument to DATETIME")}const qa=new Map;class Xa{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:$a,DATETIME:Ga,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=qa.get(e);return void 0===i&&(i=new Map,qa.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 Ha(this,i,e);try{return ja(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new La).toString(s);throw t}}}const Ka=/^(-?[a-zA-Z][\w-]*) *= */gm,Ya=/\.([a-zA-Z][\w-]*) *= */y,Qa=/\*?\[/y,Ja=/(-?[0-9]+(?:\.([0-9]+))?)/y,Za=/([a-zA-Z][\w-]*)/y,to=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,eo=/^[A-Z][A-Z0-9_-]*$/,io=/([^{}\n\r]+)/y,so=/([^\\"\n\r]*)/y,no=/\\([\\"])/y,ro=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,ao=/^\n+/,oo=/ +$/,lo=/ *\r?\n/g,ho=/( *)$/,co=/{\s*/y,uo=/\s*}/y,po=/\[\s*/y,go=/\s*] */y,fo=/\s*\(\s*/y,mo=/\s*->\s*/y,bo=/\s*:\s*/y,vo=/\s*,?\s*/y,wo=/\s+/y;class yo{constructor(t){this.body=[],Ka.lastIndex=0;let e=0;for(;;){let i=Ka.exec(t);if(null===i)break;e=Ka.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(Ya);){let e=a(Ya),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(io)&&(s=a(io)),"{"===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,ao),h([n],n.length)):s?v(s,oo):null}function h(s=[],n){for(;;){if(i(io)){s.push(a(io));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,oo));let l=[];for(let t of s)t instanceof Ao&&(t=t.value.slice(0,t.value.length-n)),t&&l.push(t);return l}function d(){n(co,SyntaxError);let t=c();if(n(uo))return t;if(n(mo)){let e=function(){let t,e=[],n=0;for(;i(Qa);){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(uo,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(to)){let[,i,s,a=null]=r(to);if("$"===i)return{type:"var",name:s};if(n(fo)){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(vo)}}();if("-"===i)return{type:"term",name:s,attr:a,args:r};if(eo.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(bo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(po,SyntaxError),t=i(Ja)?f():{type:"str",value:a(Za)},n(go,SyntaxError),t}function g(){if(i(Ja))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=a(so),"\\"!==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(Ja),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(no))return a(no);if(i(ro)){let[,t,e]=r(ro),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(wo),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(lo,"\n"),i=ho.exec(t)[1].length;return new Ao(e,i)}}}class Ao{constructor(t,e){this.value=t,this.length=e}}const _o=/<|&#?\w+;/,xo={"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"]},So={"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 Co(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(_o.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=Mo(e,i);t.replaceChild(s,i)}else if(Io(i)){const e=To(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(ko(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;Po(e,t)}function Eo(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function Po(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))Lo(s.name,e,i)&&!Eo(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))Lo(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function Mo(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.`),ko(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}).`),ko(e);t.removeChild(s);return Do(e,s.cloneNode(!1))}function To(t){const e=t.ownerDocument.createElement(t.localName);return Do(t,e)}function ko(t){return t.ownerDocument.createTextNode(t.textContent)}function Io(t){const e=xo[t.namespaceURI];return e&&e.includes(t.localName)}function Lo(t,e,i=null){if(i&&i.includes(t))return!0;const s=So[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 Do(t,e){return e.textContent=t.textContent,Po(t,e),e}class Ro extends Array{static from(t){return t instanceof this?t:new this(t)}}class No extends Ro{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 Fo{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=jo(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,Bo)}formatValues(t){return this.formatWithFallback(t,Oo)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=No.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Oo(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function Bo(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 jo(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 Vo="data-l10n-id",Ho="data-l10n-args",zo=`[${Vo}]`;class Uo extends Fo{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:[Vo,Ho]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Vo,e),i?t.setAttribute(Ho,JSON.stringify(i)):t.removeAttribute(Ho),t}getAttributes(t){return{id:t.getAttribute(Vo),args:JSON.parse(t.getAttribute(Ho)||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(Vo)&&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]&&Co(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(zo));return"function"==typeof t.hasAttribute&&t.hasAttribute(Vo)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Vo),args:JSON.parse(t.getAttribute(Ho)||null)}}}class $o{#sl;#sn;#Mi;#nl;constructor({lang:t,isRTL:e},i=null){this.#Mi=$o.#rl(t),this.#nl=i,this.#sl=e??$o.#al(this.#Mi)?"rtl":"ltr"}_setL10n(t){this.#nl=t}getLanguage(){return this.#Mi}getDirection(){return this.#sl}async get(t,e=null,i){if(Array.isArray(t)){t=t.map((t=>({id:t})));return(await this.#nl.formatMessages(t)).map((t=>t.value))}const s=await this.#nl.formatMessages([{id:t,args:e}]);return s[0]?.value||i}async translate(t){(this.#sn||=new Set).add(t);try{this.#nl.connectRoot(t),await this.#nl.translateRoots()}catch{}}async translateOnce(t){try{await this.#nl.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#sn){for(const t of this.#sn)this.#nl.disconnectRoot(t);this.#sn.clear(),this.#sn=null}this.#nl.pauseObserving()}pause(){this.#nl.pauseObserving()}resume(){this.#nl.resumeObserving()}static#rl(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#al(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function Wo(t,e){const i=new yo(e),s=new Xa(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class Go extends $o{constructor(t){super({lang:t});const e=t?Go.#ol.bind(Go,"en-us",this.getLanguage()):Go.#ll.bind(Go,this.getLanguage());this._setL10n(new Uo([],e))}static async*#ol(t,e){const{baseURL:i,paths:s}=await this.#hl(),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.#dl(t,i,s);e?yield e:"en-us"===t&&(yield this.#cl(t))}}static async#dl(t,e,i){const s=i[t];if(!s)return null;const n=new URL(s,e);return Wo(t,await qr(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await qr(t,"json");return{baseURL:t.replace(/[^/]*$/,"")||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#ll(t){yield this.#cl(t)}static async#cl(t){return Wo(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 qo(){return document.location.hash}class Xo{#tl=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.#ul();const n=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=qo(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#pl(n,!0)||e){const{hash:t,page:i,rotation:n}=this.#gl(!0);return!t||s||e?void this.#fl(null,!0):void this.#fl({hash:t,page:i,rotation:n},!0)}const r=n.destination;this.#ml(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.#bl(),this._initialized=!1,this.#vl()),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.#wl(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(Kn(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.#fl({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.#wl(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#fl({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.#yl()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#pl(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}#fl(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.#ml(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)}#yl(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.#fl(e);if(this._destination.temporary)return void this.#fl(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.#fl(e,i)}#wl(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#pl(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)}#ml(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}#gl(t=!1){const e=unescape(qo()).substring(1),i=Kn(e),s=i.get("nameddest")||"";let n=0|i.get("page");return(!this.#wl(n)||t&&s.length>0)&&(n=null),{hash:e,page:n,rotation:this.linkService.rotation}}#Al({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.#yl(!0),this._updateViewareaTimeout=null}),1e3))}#_l({state:t}){const e=qo(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#gl();return void this.#fl({hash:t,page:e,rotation:i},!0)}if(!this.#pl(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(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 ka?"_on":"addEventListener"](e,a.bind(null,Ma),{signal:r.signal});const o=setTimeout(a.bind(null,Ta),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#ml(s,t.uid,!0),er(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}))}#bl(){this._destination&&!this._destination.temporary||this.#yl()}#ul(){if(this.#tl)return;this.#tl=new AbortController;const{signal:t}=this.#tl;this.eventBus._on("updateviewarea",this.#Al.bind(this),{signal:t}),window.addEventListener("popstate",this.#_l.bind(this),{signal:t}),window.addEventListener("pagehide",this.#bl.bind(this),{signal:t})}#vl(){this.#tl?.abort(),this.#tl=null}}class Ko{#ro=null;#xl=null;#Zo=null;#Tn=null;#go=null;#f;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new Go,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#ro=t.annotationLayer||null,this.#go=t.textLayer||null,this.#xl=t.drawLayer||null,this.#Zo=t.onAppend||null,this.#Tn=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.#Zo?.(s),this.annotationEditorLayer=new Nr({uiManager:this.#f,div:s,structTreeLayer:this.#Tn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ro,textLayer:this.#go,drawLayer:this.#xl});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.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var Yo=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)&&Yo.set("maxCanvasPixels",5242880),s&&Yo.set("useSystemFonts",!1)}const Qo=1,Jo=2,Zo=4,tl=8,el=16,il=128,sl={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},nl={allowedGlobalEvents:{value:null,kind:Qo},canvasMaxAreaInBytes:{value:-1,kind:Qo+Zo},isInAutomation:{value:!1,kind:Qo},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Qo},nimbusDataStr:{value:"",kind:Qo},supportsCaretBrowsingMode:{value:!1,kind:Qo},supportsDocumentFonts:{value:!0,kind:Qo},supportsIntegratedFind:{value:!1,kind:Qo},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Qo},supportsMouseWheelZoomMetaKey:{value:!0,kind:Qo},supportsPinchToZoom:{value:!0,kind:Qo},toolbarDensity:{value:0,kind:Qo+el},altTextLearnMoreUrl:{value:"",kind:Jo+il},annotationEditorMode:{value:0,kind:Jo+il},annotationMode:{value:2,kind:Jo+il},cursorToolOnLoad:{value:0,kind:Jo+il},debuggerSrc:{value:"./debugger.mjs",kind:Jo},defaultZoomDelay:{value:400,kind:Jo+il},defaultZoomValue:{value:"",kind:Jo+il},disableHistory:{value:!1,kind:Jo},disablePageLabels:{value:!1,kind:Jo+il},enableAltText:{value:!1,kind:Jo+il},enableAltTextModelDownload:{value:!0,kind:Jo+il+el},enableGuessAltText:{value:!0,kind:Jo+il+el},enableHighlightFloatingButton:{value:!1,kind:Jo+il},enableNewAltTextWhenAddingImage:{value:!0,kind:Jo+il},enablePermissions:{value:!1,kind:Jo+il},enablePrintAutoRotate:{value:!0,kind:Jo+il},enableScripting:{value:!0,kind:Jo+il},enableUpdatedAddImage:{value:!1,kind:Jo+il},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Jo},externalLinkTarget:{value:0,kind:Jo+il},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Jo+il},historyUpdateUrl:{value:!1,kind:Jo+il},ignoreDestinationZoom:{value:!1,kind:Jo+il},imageResourcesPath:{value:"./images/",kind:Jo},maxCanvasPixels:{value:2**25,kind:Jo},forcePageColors:{value:!1,kind:Jo+il},pageColorsBackground:{value:"Canvas",kind:Jo+il},pageColorsForeground:{value:"CanvasText",kind:Jo+il},pdfBugEnabled:{value:!1,kind:Jo+il},printResolution:{value:150,kind:Jo},sidebarViewOnLoad:{value:-1,kind:Jo+il},scrollModeOnLoad:{value:-1,kind:Jo+il},spreadModeOnLoad:{value:-1,kind:Jo+il},textLayerMode:{value:1,kind:Jo+il},viewOnLoad:{value:0,kind:Jo+il},cMapPacked:{value:!0,kind:Zo},cMapUrl:{value:"../web/cmaps/",kind:Zo},disableAutoFetch:{value:!1,kind:Zo+il},disableFontFace:{value:!1,kind:Zo+il},disableRange:{value:!1,kind:Zo+il},disableStream:{value:!1,kind:Zo+il},docBaseUrl:{value:"",kind:Zo},enableHWA:{value:!0,kind:Zo+Jo+il},enableXfa:{value:!0,kind:Zo+il},fontExtraProperties:{value:!1,kind:Zo},isEvalSupported:{value:!0,kind:Zo},isOffscreenCanvasSupported:{value:!0,kind:Zo},maxImageSize:{value:-1,kind:Zo},pdfBug:{value:!1,kind:Zo},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Zo},useSystemFonts:{value:void 0,kind:Zo,type:sl.BOOLEAN+sl.UNDEFINED},verbosity:{value:1,kind:Zo},workerPort:{value:null,kind:tl},workerSrc:{value:"../build/pdf.worker.mjs",kind:tl}};nl.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Jo},nl.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Jo},nl.viewerCssTheme={value:0,kind:Jo+il},nl.enableFakeMLManager={value:!0,kind:Jo},nl.disablePreferences={value:!1,kind:Jo};class rl{static eventBus;static#Sl=new Map;static{for(const t in nl)this.#Sl.set(t,nl[t].value);for(const[t,e]of Yo)this.#Sl.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.#Sl.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const s in nl){const n=nl[s];(!t||t&n.kind)&&(i[s]=e?n.value:this.#Sl.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=nl[s],r=t[s];if(!n||!(typeof r==typeof n.value||sl[(typeof r).toUpperCase()]&n.type))continue;const{kind:a}=n;(!e||a&Qo||a&il)&&(this.eventBus&&a&el&&(i||=new Map).set(s,r),this.#Sl.set(s,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class al{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new Wr({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#xl&&(this.#xl.destroy(),this.#xl=null)}setParent(t){this.#xl?.setParent(t)}getDrawLayer(){return this.#xl}}const ol={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},ll=/^H(\d+)$/;class hl{#Cl;#El=null;#Pl;#Ml=new Map;#Tl;#kl=null;constructor(t,e){this.#Cl=t.getStructTree(),this.#Tl=e}async render(){if(this.#Pl)return this.#Pl;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#Pl=t;try{this.#El=this.#Il(await this.#Cl)}catch(t){i(t)}return this.#Cl=null,this.#El?.classList.add("structTree"),e(this.#El),t}async getAriaAttributes(t){try{return await this.render(),this.#Ml.get(t)}catch{}return null}hide(){this.#El&&!this.#El.hidden&&(this.#El.hidden=!0)}show(){this.#El?.hidden&&(this.#El.hidden=!1)}#Ll(t,e){const{alt:i,id:s,lang:n}=t;if(void 0!==i){let s=!1;const n=Qn(i);for(const e of t.children)if("annotation"===e.type){let t=this.#Ml.get(e.id);t||(t=new Map,this.#Ml.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",Qn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,r=n?.[0];if(!this.#Tl||!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.#kl||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Qn(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Tl,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.#kl){for(const[t,e]of this.#kl)document.getElementById(t)?.append(e);this.#kl.clear(),this.#kl=null}}#Il(t){if(!t)return null;const e=document.createElement("span");if("role"in t){const{role:i}=t,s=i.match(ll);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):ol[i]&&e.setAttribute("role",ol[i]),"Figure"===i&&this.#Dl(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.#Il(i));return e}}class dl{#Rl=!1;#Nl=null;#Fl=new Map;#Ol=new Map;setTextMapping(t){this.#Nl=t}static#Bl(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.#Rl)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Nl)throw new Error("Text divs and strings have not been set.");if(this.#Rl=!0,this.#Nl=this.#Nl.slice(),this.#Nl.sort(dl.#Bl),this.#Fl.size>0){const t=this.#Nl;for(const[e,i]of this.#Fl){document.getElementById(e)?this.#jl(e,t[i]):this.#Fl.delete(e)}}for(const[t,e]of this.#Ol)this.addPointerInTextLayer(t,e);this.#Ol.clear()}disable(){this.#Rl&&(this.#Ol.clear(),this.#Nl=null,this.#Rl=!1)}removePointerInTextLayer(t){if(!this.#Rl)return void this.#Ol.delete(t);const e=this.#Nl;if(!e||0===e.length)return;const{id:i}=t,s=this.#Fl.get(i);if(void 0===s)return;const n=e[s];this.#Fl.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")))}#jl(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.#Rl)return this.#Ol.set(t,e),null;e&&this.removePointerInTextLayer(t);const s=this.#Nl;if(!s||0===s.length)return null;const n=Jn(s,(e=>dl.#Bl(t,e)<0)),r=Math.max(0,n-1),a=s[r];this.#jl(i,a),this.#Fl.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=Jn(r,(t=>dl.#Bl(a,t)<0));return 0===o?r[0].before(e):r[o-1].after(e),n}}class cl{#tl=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.#tl||(this.#tl=new AbortController,this.eventBus._on("updatetextlayermatches",(t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()}),{signal:this.#tl.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#tl?.abort(),this.#tl=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={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");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){const{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 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 ul{#Vl=!1;#Zo=null;#Hl=!1;#go=null;static#zl=new Map;static#Ul=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.#Vl=!0===s,this.#Zo=n,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render(t,e=null){if(this.#Hl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new va({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:s}=this.#go;this.highlighter?.setTextMapping(i,s),this.accessibilityManager?.setTextMapping(i),await this.#go.render(),this.#Hl=!0;const n=document.createElement("div");n.className="endOfContent",this.div.append(n),this.#$l(n),this.#Zo?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Hl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Hl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),ul.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Vl){const e=document.getSelection();t.clipboardData.setData("text/plain",Qn(ra(e.toString())))}ba(t)})),ul.#zl.set(e,t),ul.#Gl()}static#Wl(t){this.#zl.delete(t),0===this.#zl.size&&(this.#Ul?.abort(),this.#Ul=null)}static#Gl(){if(this.#Ul)return;this.#Ul=new AbortController;const{signal:t}=this.#Ul,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.#zl.forEach(e)}),{signal:t}),window.addEventListener("blur",(()=>{i=!1,this.#zl.forEach(e)}),{signal:t}),document.addEventListener("keyup",(()=>{i||this.#zl.forEach(e)}),{signal:t}),document.addEventListener("selectionchange",(()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#zl.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const s=t.getRangeAt(e);for(const t of this.#zl.keys())!i.has(t)&&s.intersectsNode(t)&&i.add(t)}for(const[t,s]of this.#zl)i.has(t)?t.classList.add("selecting"):e(s,t);if(s??="none"===getComputedStyle(this.#zl.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.#zl.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 pl{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,Sa.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?Sa.update(s):(this.div=document.createElement("div"),s.div=this.div,Sa.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const gl={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Dr}},fl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class ml{#ql=Vr.ENABLE_FORMS;#Xl=null;#li=!1;#Kl=!1;#_e=!1;#Yl=null;#Ql=null;#Jl=null;#Zl=null;#th=1;#eh=1;#ih=null;#sh=Bn.INITIAL;#nh=$n;#rh={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#ah=[null,null,null,null];constructor(t){const e=t.container,i=t.defaultViewport;this.id=t.id,this.renderingId="page"+this.id,this.#Yl=t.layerProperties||gl,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.#nh=t.textLayerMode??$n,this.#ql=t.annotationMode??Vr.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??rl.get("maxCanvasPixels"),this.pageColors=t.pageColors||null,this.#li=t.enableHWA||!1,this.eventBus=t.eventBus,this.renderingQueue=t.renderingQueue,this.l10n=t.l10n,this.l10n||=new Go,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.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.#oh(),e?.append(s),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*pa.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.#rh.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#lh(t,e){const i=fl.get(e),s=this.#ah[i];if(this.#ah[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#ah[e];if(i)return void i.after(t)}this.div.prepend(t)}}get renderingState(){return this.#sh}set renderingState(t){if(t!==this.#sh)switch(this.#sh=t,this.#Ql&&(clearTimeout(this.#Ql),this.#Ql=null),t){case Bn.PAUSED:this.div.classList.remove("loading");break;case Bn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case Bn.INITIAL:case Bn.FINISHED:this.div.classList.remove("loadingIcon","loading")}}#oh(){const{viewport:t}=this;if(this.pdfPage){if(this.#Zl===t.rotation)return;this.#Zl=t.rotation}fa(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*pa.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return ma(this,"_textHighlighter",new cl({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#Yl.findController}))}#hh(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#dh(){let t=null;try{await this.annotationLayer.render(this.viewport,{structTreeLayer:this.structTreeLayer},"display")}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#hh("annotationlayerrendered",t)}}async#ch(){let t=null;try{await this.annotationEditorLayer.render(this.viewport,"display")}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#hh("annotationeditorlayerrendered",t)}}async#uh(){try{await this.drawLayer.render("display")}catch(t){console.error("#renderDrawLayer:",t)}}async#ph(){let t=null;try{const t=await this.xfaLayer.render(this.viewport,"display");t?.textDivs&&this._textHighlighter&&this.#gh(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#lh(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#hh("xfalayerrendered",t)}}async#fh(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render(this.viewport)}catch(e){if(e instanceof Rr)return;console.error("#renderTextLayer:",e),t=e}this.#hh("textlayerrendered",t),this.#mh()}async#mh(){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#gh(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()}#bh(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#Jl=null)}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:s=!1,keepCanvasWrapper:n=!1}={}){this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:s}),this.renderingState=Bn.INITIAL;const r=this.div,a=r.childNodes,o=t&&this.annotationLayer?.div||null,l=e&&this.annotationEditorLayer?.div||null,h=i&&this.xfaLayer?.div||null,d=s&&this.textLayer?.div||null,c=n&&this.#Xl||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.#ah.indexOf(e);i>=0&&(this.#ah[i]=null)}r.removeAttribute("data-loaded"),o&&this.annotationLayer.hide(),l&&this.annotationEditorLayer.hide(),h&&this.xfaLayer.hide(),d&&this.textLayer.hide(),this.structTreeLayer?.hide(),!n&&this.#Xl&&(this.#Xl=null,this.#bh())}toggleEditingMode(t){this.hasEditableAnnotations()&&(this.#_e=t,this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!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.#rh.initialOptionalContent=t.hasInitialVisibility)}))),this.#rh.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*pa.PDF_TO_CSS_UNITS,rotation:n}),this.#oh(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.canvas){let t=!1;if(this.#Kl)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!==Bn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=Bn.FINISHED,this.#rh.directDrawing=!1),this.cssTransform({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.#ih})}}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!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({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:s=!1,hideTextLayer:n=!1}){const{canvas:r}=this;if(!r)return;const a=this.#Jl;if(this.viewport!==a){const t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;r.style.transform=`rotate(${t}deg) scale(${s},${n})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#dh(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#uh(),this.#ch()),i&&this.xfaLayer&&this.#ph(),this.textLayer&&(n?(this.textLayer.hide(),this.structTreeLayer?.hide()):s&&this.#fh())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}async#vh(t,e=null){if(t===this.renderTask&&(this.renderTask=null),e instanceof ga)this.#ih=null;else if(this.#ih=e,this.renderingState=Bn.FINISHED,this.#rh.regularAnnotations=!t.separateAnnots,this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:!1,timestamp:performance.now(),error:this.#ih}),e)throw e}async draw(){this.renderingState!==Bn.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=Bn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Bn.RUNNING;let r=this.#Xl;if(r||(r=this.#Xl=document.createElement("div"),r.classList.add("canvasWrapper"),this.#lh(r,"canvasWrapper")),this.textLayer||this.#nh===Un||s.isPureXfa||(this._accessibilityManager||=new dl,this.textLayer=new ul({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===Wn,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Vr.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:r,hasJSActionsPromise:a,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new Ca({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Vr.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:a,fieldObjectsPromise:r,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:a,height:o}=n,l=document.createElement("canvas");l.setAttribute("role","presentation");const h=!(!i?.background||!i?.foreground),d=this.canvas,c=!d&&!h;this.canvas=l,this.#Jl=n;let u=t=>{if(c)return r.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):r.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new oa;if(0===this.maxCanvasPixels){const t=1/this.scale;g.sx*=t,g.sy*=t,this.#Kl=!0}else if(this.maxCanvasPixels>0){const t=a*o,e=Math.sqrt(this.maxCanvasPixels/t);g.sx>e||g.sy>e?(g.sx=e,g.sy=e,this.#Kl=!0):this.#Kl=!1}const f=Zn(g.sx),m=Zn(g.sy),b=l.width=tr(rr(a*g.sx),f[0]),v=l.height=tr(rr(o*g.sy),m[0]),w=tr(rr(a),f[1]),y=tr(rr(o),m[1]);g.sx=b/w,g.sy=v/y,this.#th!==f[1]&&(t.style.setProperty("--scale-round-x",`${f[1]}px`),this.#th=f[1]),this.#eh!==m[1]&&(t.style.setProperty("--scale-round-y",`${m[1]}px`),this.#eh=m[1]);const A={canvasContext:p,transform:g.scaled?[g.sx,0,0,g.sy,0,0]:null,viewport:n,annotationMode:this.#ql,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:i,isEditing:this.#_e},_=this.renderTask=s.render(A);_.onContinue=t=>{if(u?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=Bn.PAUSED,void(this.resume=()=>{this.renderingState=Bn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new hl(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new al({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(r),this.annotationEditorLayer||=new Ko({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.#lh(t,"annotationEditorLayer")}}),this.#ch())}),(t=>(t instanceof ga?(d?.remove(),this.#bh()):u?.(!0),this.#vh(_,t))));if(s.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#Yl;this.xfaLayer=new pl({pdfPage:s,annotationStorage:t,linkService:e})}this.#ph()}return t.setAttribute("data-loaded",!0),this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id}),x}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.#rh;return t&&e&&i?this.canvas:null}}class bl{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 vl{#wh=null;#yh=null;#Ah=null;#tl=null;#Ir=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ir=t,this.#_h=e,this.#Ah=i}setViewer(t){this.#Sh=t}async setDocument(t){if(this.#xh&&await this.#Mh(),this.#xh=t,!t)return;const[e,i,s]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!s)return void await this.#Mh();if(t!==this.#xh)return;try{this.#Eh=this.#Th()}catch(t){return console.error("setDocument:",t),void await this.#Mh()}const n=this.#Ir;this.#tl=new AbortController;const{signal:r}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#kh(t.detail)}),{signal:r}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:r}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Ih(e),this.#Lh(t))}),{signal:r}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#Lh(t)}),{signal:r}),n._on("pagesdestroy",(async()=>{await this.#Ih(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:r});try{const r=await this.#Ah(t);if(t!==this.#xh)return;await this.#Eh.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),void await this.#Mh()}await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#Lh(this.#Sh.currentPageNumber,!0),Promise.resolve().then((()=>{t===this.#xh&&(this.#Ch=!0)}))}async dispatchWillSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#Eh){await(this.#Ph?.promise),this.#Ph=Promise.withResolvers();try{await this.#Eh.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#Ph.resolve(),this.#Ph=null,t}await this.#Ph.promise}}async dispatchDidPrint(){return this.#Eh?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#yh?.promise||null}get ready(){return this.#Ch}get _pageOpenPending(){return ma(this,"_pageOpenPending",new Set)}get _visitedPages(){return ma(this,"_visitedPages",new Map)}async#kh(t){const e=this.#Sh,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=Gn.VERTICAL,i=qn.NONE;switch(t){case"SinglePage":e=Gn.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Gn.PAGE;case"TwoColumnLeft":i=qn.ODD;break;case"TwoPageRight":e=Gn.PAGE;case"TwoColumnRight":i=qn.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.#Ir.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#Ir.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.#Ph?.resolve(),this.#Ph=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.#xh?.annotationStorage.setValue(e,t)}}async#Lh(t,e=!1){const i=this.#xh,s=this._visitedPages;if(e&&(this.#wh=Promise.withResolvers()),!this.#wh)return;const n=this.#Sh.getPageView(t-1);if(n?.renderingState!==Bn.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.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();s.set(t,r)}async#Ih(t){const e=this.#xh,i=this._visitedPages;if(!this.#wh)return;if(this._pageOpenPending.has(t))return;const s=i.get(t);s&&(i.set(t,null),await s,e===this.#xh&&await(this.#Eh?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#Th(){if(this.#yh=Promise.withResolvers(),this.#Eh)throw new Error("#initScripting: Scripting already exists.");return this.#_h.createScripting()}async#Mh(){if(!this.#Eh)return this.#xh=null,void this.#yh?.resolve();this.#wh&&(await Promise.race([this.#wh.promise,new Promise((t=>{setTimeout(t,1e3)}))]).catch((()=>{})),this.#wh=null),this.#xh=null;try{await this.#Eh.destroySandbox()}catch{}this.#Ph?.reject(new Error("Scripting destroyed.")),this.#Ph=null,this.#tl?.abort(),this.#tl=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#Eh=null,this.#Ch=!1,this.#yh?.resolve()}}class wl extends vl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new bl(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||Yr(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let yl=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===Bn.FINISHED}renderView(t){switch(t.renderingState){case Bn.FINISHED:return!1;case Bn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Bn.RUNNING:this.highestPriorityPage=t.renderingId;break;case Bn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof ga||console.error("renderView:",t)}))}return!0}};const Al=1e4,_l=5e3,xl=250;function Sl(t){return Object.values(Or).includes(t)&&t!==Or.DISABLE}class Cl{#Dh=new Set;#Rh=0;constructor(t){this.#Rh=t}push(t){const e=this.#Dh;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Rh&&this.#Nh()}resize(t,e=null){this.#Rh=t;const i=this.#Dh;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.#Rh;)this.#Nh()}has(t){return this.#Dh.has(t)}[Symbol.iterator](){return this.#Dh.keys()}#Nh(){const t=this.#Dh.keys().next().value;t?.destroy(),this.#Dh.delete(t)}}class El{#Fh=null;#L=null;#Oh=null;#Bh=Or.NONE;#jh=null;#ql=Vr.ENABLE_FORMS;#Vh=null;#Hh=null;#li=!1;#U=!1;#Vl=!1;#$=!1;#W=!1;#tl=null;#nt=null;#zh=null;#Uh=null;#$h=!1;#Wh=null;#Gh=!1;#qh=0;#Xh=new ResizeObserver(this.#Kh.bind(this));#Yh=null;#Qh=null;#Jh=!0;#nh=$n;constructor(t){const e="4.10.38";if(xa!==e)throw new Error(`The API version "${xa}" 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.#Xh.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Dr,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#L=t.altTextManager||null,this.#Hh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??$n,this.#ql=t.annotationMode??Vr.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??Or.NONE,this.#Oh=t.annotationEditorHighlightColors||null,this.#U=!0===t.enableHighlightFloatingButton,this.#$=!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 Go,this.#Vl=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#nt=t.mlManager||null,this.#li=t.enableHWA||!1,this.#Jh=!1!==t.supportsPinchToZoom,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new yl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",(()=>{this.#Xh.disconnect(),this.#Xh=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=jn,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Zh(),this.eventBus._on("thumbnailrendered",(({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Fh.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.#Fh)}get pageViewsReady(){return this._pages.every((t=>t?.pdfPage))}get renderForms(){return this.#ql===Vr.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.#td(),!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.#td(),!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.#ed(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#ed(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!er(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.#ed(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 ma(this,"_layerProperties",{get annotationEditorUIManager(){return t.#jh},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}})}#id(t){const e={annotationEditorMode:this.#Bh,annotationMode:this.#ql,textLayerMode:this.#nh};return t?(t.includes(ua.COPY)||this.#nh!==$n||(e.textLayerMode=Wn),t.includes(ua.MODIFY_CONTENTS)||(e.annotationEditorMode=Or.DISABLE),t.includes(ua.MODIFY_ANNOTATIONS)||t.includes(ua.FILL_INTERACTIVE_FORMS)||this.#ql!==Vr.ENABLE_FORMS||(e.annotationMode=Vr.ENABLE),e):e}async#sd(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.#Gh)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(Qn(e.join("")))}return t.join("\n")}#nd(t,e){const i=document.getSelection(),{focusNode:s,anchorNode:n}=i;if(n&&s&&i.containsNode(this.#Wh)){if(this.#$h||t===Wn)return void ba(e);this.#$h=!0;const{classList:i}=this.viewer;i.add("copyAll");const s=new AbortController;window.addEventListener("keydown",(t=>this.#Gh="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.#$h=!1,this.#Gh=!1,s.abort(),i.remove("copyAll")})),ba(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.#jh?.destroy(),this.#jh=null),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),s=t.getOptionalContentConfig({intent:"display"}),n=this.#Vl?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>Al){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=Gn.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.#Fh.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.#id(n);if(c!==Un){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==Or.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):Sl(e)?(this.#jh=new Br(this.container,o,this.#L,r,t,a,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Hh,this.#Jh),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==Or.NONE&&(e===Or.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===Gn.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*pa.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 ml({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.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===Gn.PAGE?this.#rd():this._spreadMode!==qn.NONE&&this._updateSpreadMode(),this.#sd(l).then((async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Wh&&document.addEventListener("copy",this.#nd.bind(this,c),{signal:l}),this.#jh&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>_l)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%xl==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.#Fh=new Cl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=Gn.VERTICAL,this._previousScrollMode=Gn.UNKNOWN,this._spreadMode=qn.NONE,this.#Yh={previousPageNumber:1,scrollDown:!0,pages:[]},this.#tl?.abort(),this.#tl=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Wh?.remove(),this.#Wh=null,this.#ad()}#rd(){if(this._scrollMode!==Gn.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#Yh,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==qn.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()}#od(t,e=null){const{div:i,id:s}=t;if(this._currentPageNumber!==s&&this._setCurrentPageNumber(s),this._scrollMode===Gn.PAGE&&(this.#rd(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:r}=this.container;(this._scrollMode===Gn.HORIZONTAL||t<n||s>n+r)&&(e={left:0,top:0})}Xn(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#ld(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#hd(t,e,{noScroll:i=!1,preset:s=!1,drawingDelay:n=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#ld(t))return void(s&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*pa.PDF_TO_CSS_UNITS);const a=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:a?n:-1}),a&&(this.#Qh=setTimeout((()=>{this.#Qh=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#dd(){return this._spreadMode!==qn.NONE&&this._scrollMode!==Gn.HORIZONTAL?2:1}#ed(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#hd(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!==qn.NONE&&(n*=2)):this.removePageBorders?n=r=0:this._scrollMode===Gn.HORIZONTAL&&([n,r]=[r,n]);const a=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,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=ir(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.#hd(i,t,e)}}#td(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#ed(this._currentScaleValue,{noScroll:!0}),this.#od(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/pa.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/pa.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/pa.PDF_TO_CSS_UNITS,a=(this.container.clientHeight-i)/d/pa.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.#od(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.#od(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.#Fh.resize(s,t.ids),this.renderingQueue.renderHighestPriority(t);const n=this._spreadMode===qn.NONE&&(this._scrollMode===Gn.PAGE||this._scrollMode===Gn.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})}#cd(){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===zn}get isChangingPresentationMode(){return this.presentationModeState===Hn}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===Gn.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===Gn.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=Jn(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!==Bn.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ud(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}}#pd(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case Gn.PAGE:return this.#Yh.scrollDown;case Gn.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==qn.NONE&&this._scrollMode!==Gn.HORIZONTAL,n=this.renderingQueue.getHighestPriority(e,this._pages,i,s);return!!n&&(this.#ud(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=ir(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(Gn).includes(t)&&t!==Gn.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Al||(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===Gn.HORIZONTAL),i.classList.toggle("scrollWrapped",e===Gn.WRAPPED),this.pdfDocument&&t&&(e===Gn.PAGE?this.#rd():this._previousScrollMode===Gn.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#ed(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(qn).includes(t)&&t!==qn.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===Gn.PAGE)this.#rd();else if(e.textContent="",this._spreadMode===qn.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.#ed(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case Gn.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 Gn.HORIZONTAL:break;case Gn.PAGE:case Gn.VERTICAL:{if(this._spreadMode===qn.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.#ed(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)})}#Zh(t=this.container.clientHeight){t!==this.#qh&&(this.#qh=t,sr.setProperty("--viewer-container-height",`${t}px`))}#Kh(t){for(const e of t)if(e.target===this.container){this.#Zh(Math.floor(e.borderBoxSize[0].blockSize)),this.#Vh=null;break}}get containerTopLeft(){return this.#Vh||=[this.container.offsetTop,this.container.offsetLeft]}#ad(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:Or.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1}){if(!this.#jh)throw new Error("The AnnotationEditor is not enabled.");if(this.#Bh===t)return;if(!Sl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===Or.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#ad(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===Or.NONE||this.#Bh===Or.NONE){const e=t!==Or.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#ad(),this.#zh=new AbortController;const t=AbortSignal.any([this.#tl.signal,this.#zh.signal]);return void s._on("pagerendered",(({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Uh=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.#Qh&&(clearTimeout(this.#Qh),this.#Qh=null),t||this.update()}}}class Pl extends El{_resetView(){super._resetView(),this._scrollMode=Gn.PAGE,this._spreadMode=qn.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var Ml,Tl,kl,Il,Ll,Dl=On.DownloadManager,Rl=On.EventBus,Nl=On.GenericL10n,Fl=On.PDFFindController,Ol=On.PDFLinkService,Bl=On.PDFSinglePageViewer,jl=On.PDFViewer,Vl=On.SimpleLinkService,Hl=On.XfaLayerBuilder;function zl(t,e,i,s){return new(i||(i=Promise))((function(n,r){function a(t){try{l(s.next(t))}catch(t){r(t)}}function o(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,o)}l((s=s.apply(t,e||[])).next())}))}function Ul(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 $l(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 Wl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Gl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},ql={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},Xl={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Kl={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Yl={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class Ql{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function Jl(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 Zl(t,e,i=void 0){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}),null==i||i.addEventListener("abort",(()=>window.cancelAnimationFrame(r)),{once:!0}),n}const th=/[\x00-\x1F]/g;function eh(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 ih({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 sh(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 nh({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=eh(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=sh(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 rh(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 ah(t){const e=t.deltaMode;let i=rh(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function oh(t){return Number.isInteger(t)&&t%90==0}function lh(t){return Number.isInteger(t)&&Object.values(Kl).includes(t)&&t!==Kl.UNKNOWN}function hh(t){return Number.isInteger(t)&&Object.values(Yl).includes(t)&&t!==Yl.UNKNOWN}function dh(t){return t.width<=t.height}const ch=new Promise((function(t){window.requestAnimationFrame(t)})),uh=document.documentElement.style;Ml=new WeakMap,Tl=new WeakMap,kl=new WeakMap,Il=new WeakMap,Ll=new WeakMap;const ph=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}();class gh{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){var e;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&(null===(e=this.pdfThumbnailViewer)||void 0===e?void 0:e.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===Wl.FINISHED}renderView(t){switch(t.renderingState){case Wl.FINISHED:return!1;case Wl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Wl.RUNNING:this.highestPriorityPage=t.renderingId;break;case Wl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Ln||console.error("renderView:",t)}))}return!0}}var fh,mh,bh,vh,wh,yh,Ah,_h;class xh{static getCanvas(t,e){const i=$l(this,fh,Ul(this,fh,"f",mh)||document.createElement("canvas"),0,mh);i.width=t,i.height=e;const s=i.getContext("2d",{alpha:!1});return s.save(),s.fillStyle="rgb(255, 255, 255)",s.fillRect(0,0,t,e),s.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const t=Ul(this,fh,"f",mh);t&&(t.width=0,t.height=0),$l(this,fh,null,0,mh)}}fh=xh,mh={value:null};class Sh{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:n,linkService:r,renderingQueue:a,pageColors:o,enableHWA:l,store:h,thumbnailWidth:d}){bh.add(this),this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=s,this.pdfPageRotate=s.rotation,this._optionalContentConfigPromise=n||null,this.pageColors=o||null,this.enableHWA=l||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=Wl.INITIAL,this.resume=null,this.store=h,this.thumbnailWidth=d,this.loaded=!1;const c=document.createElement("div");c.className="thumbnail pdfSlickThumbHolder",c.setAttribute("data-page-number",this.id.toString()),this.div=c,Ul(this,bh,"m",vh).call(this),t.append(c)}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=Wl.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,Ul(this,bh,"m",vh).call(this)}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}draw(){return zl(this,void 0,void 0,(function*(){if(this.renderingState!==Wl.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:t}=this;if(!t)throw this.renderingState=Wl.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Wl.RUNNING;const{ctx:e,canvas:i,transform:s}=Ul(this,bh,"m",wh).call(this,2),n={canvasContext:e,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=t.render(n);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Wl.PAUSED,void(this.resume=()=>{this.renderingState=Wl.RUNNING,t()});t()};const a=r.promise.then((()=>Ul(this,bh,"m",Ah).call(this,r,i)),(t=>Ul(this,bh,"m",Ah).call(this,r,i,t)));return a.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),a}))}setImage(t){if(this.renderingState!==Wl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=Wl.FINISHED,Ul(this,bh,"m",yh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var Ch,Eh,Ph,Mh,Th,kh,Ih;bh=new WeakSet,vh=function(){const{width:t,height:e}=this.viewport,i=t/e;this.canvasWidth=this.thumbnailWidth,this.canvasHeight=this.canvasWidth/i|0,this.scale=this.canvasWidth/t;const{style:s}=this.div;s.setProperty("--thumbnail-width",`${this.canvasWidth}px`),s.setProperty("--thumbnail-height",`${this.canvasHeight}px`)},wh=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),s=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),n=new Ql;i.width=t*this.canvasWidth*n.sx|0,i.height=t*this.canvasHeight*n.sy|0;return{ctx:s,canvas:i,transform:n.scaled?[n.sx,0,0,n.sy,0,0]:null}},yh=function(t){if(this.renderingState!==Wl.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=Ul(this,bh,"m",_h).call(this,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},Ah=function(t,e){return zl(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof Ln)&&(this.renderingState=Wl.FINISHED,Ul(this,bh,"m",yh).call(this,e),i))throw i}))},_h=function(t){const{ctx:e,canvas:i}=Ul(this,bh,"m",wh).call(this,1,!0);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]=xh.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};const Lh="selected";class Dh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,pageColors:n,abortSignal:r,enableHWA:a,store:o,thumbnailWidth:l}){Ch.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.pageColors=n||null,this.enableHWA=a||!1,this.store=o,this.thumbnailWidth=l,this.scroll=Zl(this.container,Ul(this,Ch,"m",Eh).bind(this),r),Ul(this,Ch,"m",Mh).call(this)}getThumbnail(t){return this._thumbnails[t]}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(Lh),e.div.classList.add(Lh)}const{first:i,last:s,views:n}=Ul(this,Ch,"m",Ph).call(this);if(n.length>0){let r=!1;if(t<=i.id||t>=s.id)r=!0;else for(const{id:e,percent:i}of n)if(e===t){r=i<100;break}r&&Jl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!oh(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!==Wl.FINISHED&&t.reset();xh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(Ul(this,Ch,"m",Th).call(this),Ul(this,Ch,"m",Mh).call(this)),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig({intent:"display"});e.then((e=>{var s;const n=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new Sh({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,pageColors:this.pageColors,enableHWA:this.enableHWA,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(Lh),this.store.getState()._setThumbnailsViews(this._thumbnails)})).catch((t=>{console.error("Unable to initialize thumbnail viewer",t)}))}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=null;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=Ul(this,Ch,"m",Ph).call(this),e=Ul(this,Ch,"m",Ih).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(Ul(this,Ch,"m",kh).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}Ch=new WeakSet,Eh=function(){this.renderingQueue.renderHighestPriority()},Ph=function(){return nh({scrollEl:this.container,views:this._thumbnails})},Mh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},Th=function(){for(const t of this._thumbnails)t.cancelRendering()},kh=function(t){return zl(this,void 0,void 0,(function*(){if(t.pdfPage)return t.pdfPage;try{const e=yield this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for thumb view",t),null}}))},Ih=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};let Rh=null;class Nh{constructor({pdfDocument:t,pagesOverview:e,printContainer:i,printResolution:s,printAnnotationStoragePromise:n=null}){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=s||150,this._optionalContentConfigPromise=t.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=n||Promise.resolve(),this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");t.setAttribute("data-pdfjsprinting","true");const{width:e,height:i}=this.pagesOverview[0];this.pagesOverview.every((t=>t.width===e&&t.height===i))||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style"),this.pageStyleSheet.textContent=`@page { size: ${e}pt ${i}pt;}`,t.append(this.pageStyleSheet)}destroy(){if(Rh!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,Rh=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new Vl,n=Math.round(100*In.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 Hl({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:r}),o=Nn(r,{scale:n});a.render(o,"print"),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,i=(s,n)=>{if(this.throwIfInactive(),++this.currentPage>=e)return t({index:e,total:e}),void s();const r=this.currentPage;t({index:r,total:e}),function(t,e,i,s,n,r,a){const o=t.scratchCanvas,l=n/In.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:Mn.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof Ln||console.error(t),t}))}))}(this,this.pdfDocument,r+1,this.pagesOverview[r],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then((function(){i(s,n)}),n)};return new Promise(i)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img");this.scratchCanvas.toBlob((e=>{t.src=URL.createObjectURL(e)}));const e=document.createElement("div");e.className="printedPage",e.append(t),this.printContainer.append(e);const{promise:i,resolve:s,reject:n}=Promise.withResolvers();return t.onload=s,t.onerror=n,i.catch((()=>{})).then((()=>{URL.revokeObjectURL(t.src)})),i}performPrint(){return this.throwIfInactive(),new Promise((t=>{setTimeout((()=>{this.active?(window.print(),setTimeout(t,20)):t()}),0)}))}get active(){return this===Rh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const Fh={instance:{supportsPrinting:!0,createPrintService(t){if(Rh)throw new Error("The print service is created and active.");return Rh=new Nh(t)}}};var Oh,Bh,jh,Vh,Hh,zh,Uh,$h,Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed;const id="pdfPresentationMode",sd="pdfPresentationModeControls",nd=Math.PI/6;class rd{constructor({container:t,pdfViewer:e,eventBus:i}){Oh.add(this),Bh.set(this,Gl.UNKNOWN),jh.set(this,null),Vh.set(this,null),Hh.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 zl(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;Ul(this,Oh,"m",td).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.CHANGING);const i=t.requestFullscreen();$l(this,jh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===Yl.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),Ul(this,jh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==Pn.DISABLE&&(Ul(this,jh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){Ul(this,Oh,"m",ed).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.NORMAL)}return!1}))}get active(){return Ul(this,Bh,"f")===Gl.CHANGING||Ul(this,Bh,"f")===Gl.FULLSCREEN}}Bh=new WeakMap,jh=new WeakMap,Vh=new WeakMap,Hh=new WeakMap,Oh=new WeakSet,zh=function(t){if(!this.active)return;t.preventDefault();const e=ah(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&Ul(this,Oh,"m",Yh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;Ul(this,Oh,"m",Yh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Uh=function(t){$l(this,Bh,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},$h=function(){var t;Ul(this,Oh,"m",Uh).call(this,Gl.FULLSCREEN),this.container.classList.add(id),setTimeout((()=>{this.pdfViewer.scrollMode=Kl.PAGE,null!==Ul(this,jh,"f").spreadMode&&(this.pdfViewer.spreadMode=Yl.NONE),this.pdfViewer.currentPageNumber=Ul(this,jh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==Ul(this,jh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Pn.NONE})}),0),Ul(this,Oh,"m",Jh).call(this),Ul(this,Oh,"m",Xh).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Wh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(id),setTimeout((()=>{Ul(this,Oh,"m",ed).call(this),Ul(this,Oh,"m",Uh).call(this,Gl.NORMAL),this.pdfViewer.scrollMode=Ul(this,jh,"f").scrollMode,null!==Ul(this,jh,"f").spreadMode&&(this.pdfViewer.spreadMode=Ul(this,jh,"f").spreadMode),this.pdfViewer.currentScaleValue=Ul(this,jh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==Ul(this,jh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:Ul(this,jh,"f").annotationEditorMode}),$l(this,jh,null)}),0),Ul(this,Oh,"m",Zh).call(this),Ul(this,Oh,"m",Kh).call(this),Ul(this,Oh,"m",Yh).call(this),this.contextMenuOpen=!1},Gh=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()))},qh=function(){this.contextMenuOpen=!0},Xh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(sd),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(sd),delete this.controlsTimeout}),3e3)},Kh=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(sd),delete this.controlsTimeout)},Yh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Qh=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<=nd||n>=Math.PI-nd)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=nd&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Jh=function(){if(Ul(this,Hh,"f"))return;$l(this,Hh,new AbortController);const{signal:t}=Ul(this,Hh,"f"),e=Ul(this,Oh,"m",Qh).bind(this);window.addEventListener("mousemove",Ul(this,Oh,"m",Xh).bind(this),{signal:t}),window.addEventListener("mousedown",Ul(this,Oh,"m",Gh).bind(this),{signal:t}),window.addEventListener("wheel",Ul(this,Oh,"m",zh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",Ul(this,Oh,"m",Yh).bind(this),{signal:t}),window.addEventListener("contextmenu",Ul(this,Oh,"m",qh).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Zh=function(){var t;null===(t=Ul(this,Hh,"f"))||void 0===t||t.abort(),$l(this,Hh,null)},td=function(){Ul(this,Vh,"f")||($l(this,Vh,new AbortController),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?Ul(this,Oh,"m",$h).call(this):Ul(this,Oh,"m",Wh).call(this)}),{signal:Ul(this,Vh,"f").signal}))},ed=function(){var t;null===(t=Ul(this,Vh,"f"))||void 0===t||t.abort(),$l(this,Vh,null)};const ad={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Yl.UNKNOWN,scrollMode:Kl.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:Pn.NONE,pdfSlick:null},od=()=>{return(t=(t,e)=>Object.assign(Object.assign({},ad),{_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})}}))?b(t):b;var t};var ld,hd,dd,cd,ud,pd,gd,fd,md,bd,vd,wd,yd,Ad,_d,xd,Sd,Cd,Ed,Pd,Md,Td,kd,Id,Ld,Dd,Rd;class Nd{constructor({eventBus:t,slick:e,printDialog:i}){ld.add(this),hd.set(this,null),dd.set(this,null),cd.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return Fh.instance.supportsPrinting}get printing(){return!!Ul(this,hd,"f")}print(){return zl(this,void 0,void 0,(function*(){var t,e;if(this.supportsPrinting)if(this.printing)console.warn("Ignored pdf print because of a pending print job.");else{yield null===(t=this.printDialog)||void 0===t?void 0:t.open({close:()=>this.abort()});try{this.eventBus.dispatch("beforeprint",{source:this})}finally{if(this.printing){const t=Ul(this,hd,"f");yield t.renderPages((t=>{var e;return null===(e=this.printDialog)||void 0===e?void 0:e.progress(t)})).then((()=>t.performPrint())).catch((()=>{})).then((()=>{t===Ul(this,hd,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;Ul(this,hd,"f")&&(Ul(this,hd,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){$l(this,dd,new AbortController);const{signal:t}=Ul(this,dd,"f"),e={signal:t};this.eventBus._on("beforeprint",Ul(this,ld,"m",ud).bind(this),e),this.eventBus._on("afterprint",Ul(this,ld,"m",pd).bind(this),e),window.addEventListener("beforeprint",(()=>this.eventBus.dispatch("beforeprint",{source:window})),e),window.addEventListener("afterprint",(()=>this.eventBus.dispatch("afterprint",{source:window})),e),window.addEventListener("keydown",(t=>{80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey&&!window.chrome&&!window.opera||(this.print(),t.preventDefault(),t.stopImmediatePropagation())}),{signal:t,capture:!0})}unbindEvents(){var t;null===(t=Ul(this,dd,"f"))||void 0===t||t.abort(),$l(this,dd,null)}}hd=new WeakMap,dd=new WeakMap,cd=new WeakMap,ld=new WeakSet,ud=function(){Ul(this,hd,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?($l(this,cd,function(){const t=document.createElement("div");t.classList.add("pdfSlickPrintContainer"),document.body.append(t);const e=document.createElement("style");return e.textContent="\n@page {\n margin: 0;\n}\n\n.pdfSlickPrintContainer {\n display: none;\n}\n\n@media print {\n body {\n background: rgb(0 0 0 / 0) none;\n }\n\n body[data-pdfjsprinting] > *:not(.pdfSlickPrintContainer) {\n display: none;\n }\n\n body[data-pdfjsprinting] .pdfSlickPrintContainer {\n display: block;\n }\n\n .pdfSlickPrintContainer {\n height: 100%;\n }\n\n /* wrapper around (scaled) print canvas elements */\n .pdfSlickPrintContainer > .printedPage {\n page-break-after: always;\n page-break-inside: avoid;\n\n /* The wrapper always cover the whole page. */\n height: 100%;\n width: 100%;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage .xfaPage {\n position: absolute;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage {\n page-break-after: always;\n page-break-inside: avoid;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .pdfSlickPrintContainer > .printedPage :is(canvas, img) {\n /* The intrinsic canvas / image size will make sure that we fit the page. */\n max-width: 100%;\n max-height: 100%;\n\n direction: ltr;\n display: block;\n }\n}",document.body.append(e),{get element(){return t},remove:()=>{t.remove(),e.remove()}}}()),$l(this,hd,Fh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:Ul(this,cd,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),Ul(this,hd,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},pd=function(){var t,e,i;Ul(this,hd,"f")&&(Ul(this,hd,"f").destroy(),$l(this,hd,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=Ul(this,cd,"f"))||void 0===e||e.remove(),$l(this,cd,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class Fd{static create(){let t=document.querySelector("#printServiceDialog");if(!t){const e=(t,e,i)=>{const s=document.createElement(t);return Object.entries(e).forEach((([t,e])=>s.setAttribute(t,e))),s.append(...i),s};t=e("dialog",{id:"printServiceDialog",class:"pdfSlick-dialog",style:"min-width: 200px;"},[e("div",{class:"row"},[e("span",{"data-l10n-id":"pdfjs-print-progress-message"},["Preparing document for printing…"])]),e("div",{class:"row"},[e("progress",{value:"0",max:"100"},[]),e("span",{"data-l10n-id":"pdfjs-print-progress-percent","data-l10n-args":'{ "progress": 0 }',class:"relative-progress"},["0%"])]),e("div",{class:"buttonRow"},[e("button",{id:"printCancel",class:"dialogButton",type:"button"},[e("span",{"data-l10n-id":"pdfjs-print-progress-close-button"},["Cancel"])])])]),document.body.append(t)}return new Fd(t)}constructor(t){this.dialog=t}open(t){return zl(this,void 0,void 0,(function*(){const e=this.dialog.querySelector("#printCancel"),i=()=>{var s;this.dialog.removeEventListener("close",i),this.dialog.removeEventListener("cancel",i),null==e||e.removeEventListener("click",i),null===(s=null==t?void 0:t.close)||void 0===s||s.call(t),this.close()};this.dialog.addEventListener("close",i),this.dialog.addEventListener("cancel",i),null==e||e.addEventListener("click",i),this.dialog.showModal()}))}close(){this.dialog.close()}progress({index:t,total:e}){const i=Math.round(100*t/e),s=this.dialog.querySelector("progress"),n=this.dialog.querySelector(".relative-progress");s.value=i,n.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}}Tn.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 Od={"8.5x11":"Letter","8.5x14":"Legal"},Bd={"297x420":"A3","210x297":"A4"};function jd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class Vd{constructor({container:t,viewer:e,thumbs:i,store:s=od(),options:n,onError:r,printDialog:a}){var o,l,h,d,c,u,p,g,f,m,b,v,w,y,A;gd.add(this),fd.set(this,void 0),md.set(this,void 0),bd.set(this,void 0),vd.set(this,void 0),wd.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,yd.set(this,void 0),Ad.set(this,void 0),_d.set(this,void 0),xd.set(this,void 0),$l(this,md,t),$l(this,bd,e),$l(this,vd,i),$l(this,_d,r),this.l10n=null!==(o=null==n?void 0:n.l10n)&&void 0!==o?o:new Nl(navigator.language),this.downloadManager=new Dl,this.textLayerMode=null!==(l=null==n?void 0:n.textLayerMode)&&void 0!==l?l:Xl.ENABLE,$l(this,yd,null!==(h=null==n?void 0:n.annotationMode)&&void 0!==h?h:Mn.ENABLE_FORMS),$l(this,Ad,null!==(d=null==n?void 0:n.annotationEditorMode)&&void 0!==d?d:Pn.NONE),this.annotationEditorHighlightColors=null!==(c=null==n?void 0:n.annotationEditorHighlightColors)&&void 0!==c?c:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(u=null==n?void 0:n.removePageBorders)&&void 0!==u&&u,this.singlePageViewer=null!==(p=null==n?void 0:n.singlePageViewer)&&void 0!==p&&p,this.enablePrintAutoRotate=null!==(g=null==n?void 0:n.enablePrintAutoRotate)&&void 0!==g&&g,this.useOnlyCssZoom=null!==(f=null==n?void 0:n.useOnlyCssZoom)&&void 0!==f&&f,this.pageColors=null!==(m=null==n?void 0:n.pageColors)&&void 0!==m?m:null,this.maxCanvasPixels=null!==(b=null==n?void 0:n.maxCanvasPixels)&&void 0!==b?b:16777216,this.printResolution=null!==(v=null==n?void 0:n.printResolution)&&void 0!==v?v:96,this.thumbnailWidth=null!==(w=null==n?void 0:n.thumbnailWidth)&&void 0!==w?w:125,this.getDocumentParams=null!==(y=null==n?void 0:n.getDocumentParams)&&void 0!==y?y:{},!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 _=new gh;_.onIdle=this._cleanup.bind(this),_.isThumbnailViewEnabled=!0,$l(this,fd,_);const x=new Rl,S=new Ol({eventBus:x,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),C=new Fl({eventBus:x,linkService:S}),E=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:x,linkService:S,findController:C,renderingQueue:_,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:Ul(this,yd,"f"),annotationEditorMode:Ul(this,Ad,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),P=this.singlePageViewer?new Bl(E):new jl(E);_.setViewer(P),i&&(this.thumbnailViewer=new Dh({container:i,eventBus:x,linkService:S,renderingQueue:_,pageColors:this.pageColors,enableHWA:void 0,store:s,thumbnailWidth:this.thumbnailWidth}),_.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new rd({container:t,pdfViewer:P,eventBus:x})),this.eventBus=x,this.linkService=S,this.findController=C,this.viewer=P,this.linkService.setViewer(P),$l(this,wd,new Nd({eventBus:x,slick:this,printDialog:null!=a?a:Fd.create()}));const M=null!==(A=null==n?void 0:n.scaleValue)&&void 0!==A?A:"auto";this.store.setState({scaleValue:M})}loadDocument(t,e){return zl(this,void 0,void 0,(function*(){var i,s,n,r,a;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:Rn(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=Dn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(l.onProgress=e.onProgress);const h=yield l.promise;this.document=h,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(h)),Ul(this,gd,"m",Pd).call(this),yield Ul(this,gd,"m",Sd).call(this),this.store.setState({filename:o,numPages:h.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const d=yield h.getAttachments(),c=new Map(Object.keys(null!=d?d:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,d[t]])));this.store.setState({attachments:c}),yield Ul(this,gd,"m",Cd).call(this),this.forceRendering()}catch(t){Ul(this,_d,"f")&&Ul(this,_d,"f").call(this,t)}}))}forceRendering(t=!0){Ul(this,fd,"f").printing=!!Ul(this,wd,"f").printing,Ul(this,fd,"f").isThumbnailViewEnabled=t,Ul(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(){return zl(this,void 0,void 0,(function*(){var t,e;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(){return zl(this,void 0,void 0,(function*(){var t;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 Ul(this,wd,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){Ul(this,wd,"f").print()}unbindEvents(){var t;null===(t=Ul(this,xd,"f"))||void 0===t||t.abort(),$l(this,xd,null),Ul(this,wd,"f").unbindEvents()}_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(Pn.HIGHLIGHT),this.setAnnotationEditorParams([{type:En.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){hh(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){lh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){oh(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,_d=new WeakMap,xd=new WeakMap,gd=new WeakSet,Sd=function(){return zl(this,void 0,void 0,(function*(){var t;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)}))},Cd=function(){return zl(this,void 0,void 0,(function*(){const{info:t,contentLength:e}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then((t=>Ul(this,gd,"m",Ed).call(this,ih(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:kn.toDateObject(t.CreationDate),modificationDate:kn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},Ed=function(t,e){return zl(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=dh(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=jd(s,i,Od)||jd(n,i,Bd);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=jd(a,i,Bd),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}}))},Pd=function(){$l(this,xd,new AbortController);const{signal:t}=Ul(this,xd,"f"),e={signal:t};this.eventBus._on("pagesinit",Ul(this,gd,"m",Md).bind(this),e),this.eventBus._on("scalechanging",Ul(this,gd,"m",Ld).bind(this),e),this.eventBus._on("pagechanging",Ul(this,gd,"m",Dd).bind(this),e),this.eventBus._on("pagerendered",Ul(this,gd,"m",Rd).bind(this),e),this.eventBus._on("rotationchanging",Ul(this,gd,"m",Td).bind(this),e),this.eventBus._on("switchspreadmode",Ul(this,gd,"m",kd).bind(this),e),this.eventBus._on("switchscrollmode",Ul(this,gd,"m",Id).bind(this),e)},Md=function(t){return zl(this,arguments,void 0,(function*({source:t}){var e;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})}))},Td=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},kd=function({mode:t}){this.store.setState({spreadMode:t})},Id=function({mode:t}){this.store.setState({scrollMode:t})},Ld=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},Dd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},Rd=function({pageNumber:t,error:e}){var i;if(Ul(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 Hd=function(){},zd="undefined"!=typeof window,Ud=zd?e.useLayoutEffect:e.useEffect;function $d(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 Wd={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var Gd=zd&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],s=t[1],n=e.useState(Wd),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 Ud((function(){if(i)return o.observe(i),function(){o.disconnect()}}),[i]),[s,r]}:function(){return[Hd,Wd]};function qd({usePDFSlickStore:t,viewerRef:e,className:s}){const n=t((t=>t.pdfSlick)),r=t((t=>t.scaleValue)),[a,{width:o}]=Gd();return $d((()=>{o&&(!n||"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(n.viewer.currentScaleValue=r),null==n||n.viewer.update())}),0,[o]),i.jsx("div",{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 Xd({children:t,thumbsRef:e,usePDFSlickStore:n,className:r}){const a=n((t=>t.thumbnailViews)),o=n((t=>t.pdfSlick)),[l,{width:h}]=Gd();return $d((()=>{h&&(null==o||o.forceRendering())}),0,[h]),i.jsx("div",{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 Kd(t){return function(i,s){return function(t,i=w,s){const n=v(t.subscribe,t.getState,t.getInitialState,i,s);return e.useDebugValue(n),n}(t,i,s)}}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=Ql,t.PDFSlick=Vd,t.PDFSlickThumbnails=Xd,t.PDFSlickViewer=qd,t.PresentationModeState=Gl,t.ProgressBar=class{constructor(t){Ml.set(this,void 0),Tl.set(this,null),kl.set(this,0),Il.set(this,void 0),Ll.set(this,!0),$l(this,Ml,t.classList),$l(this,Il,t.style)}get percent(){return Ul(this,kl,"f")}set percent(t){var e,i,s;$l(this,kl,(e=t,i=0,s=100,Math.min(Math.max(e,i),s))),isNaN(t)?Ul(this,Ml,"f").add("indeterminate"):(Ul(this,Ml,"f").remove("indeterminate"),Ul(this,Il,"f").setProperty("--progressBar-percent",`${Ul(this,kl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&Ul(this,Il,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===Ul(this,kl,"f")||isNaN(Ul(this,kl,"f"))||(Ul(this,Tl,"f")&&clearTimeout(Ul(this,Tl,"f")),this.show(),$l(this,Tl,setTimeout((()=>{$l(this,Tl,null),this.hide()}),t)))}hide(){Ul(this,Ll,"f")&&($l(this,Ll,!1),Ul(this,Ml,"f").add("hidden"))}show(){Ul(this,Ll,"f")||($l(this,Ll,!0),Ul(this,Ml,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Wl,t.SCROLLBAR_PADDING=40,t.ScrollMode=Kl,t.SidebarView=ql,t.SpreadMode=Yl,t.TextLayerMode=Xl,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=ch,t.apiPageLayoutToViewerModes=function(t){let e=Kl.VERTICAL,i=Yl.NONE;switch(t){case"SinglePage":e=Kl.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Kl.PAGE;case"TwoColumnLeft":i=Yl.ODD;break;case"TwoPageRight":e=Kl.PAGE;case"TwoColumnRight":i=Yl.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return ql.NONE;case"UseThumbs":return ql.THUMBS;case"UseOutlines":return ql.OUTLINE;case"UseAttachments":return ql.ATTACHMENTS;case"UseOC":return ql.LAYERS}return ql.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=sh,t.binarySearchFirstItem=eh,t.calcRound=ph,t.create=od,t.createStore=Kd,t.docStyle=uh,t.floorToDivide=function(t,e){return t-t%e},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=ih,t.getVisibleElements=nh,t.initialState=ad,t.isPortraitOrientation=dh,t.isValidRotation=oh,t.isValidScrollMode=lh,t.isValidSpreadMode=hh,t.normalizeWheelEventDelta=ah,t.normalizeWheelEventDirection=rh,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 th.test(t)?e?t.replaceAll(th,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t},t.scrollIntoView=Jl,t.toggleCheckedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-checked",String(e)),null==i||i.classList.toggle("hidden",!e)},t.toggleExpandedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-expanded",String(e)),null==i||i.classList.toggle("hidden",!e)},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((()=>od()),[]),u=e.useMemo((()=>Kd(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 Vd({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:qd,PDFSlickThumbnails:Xd,error:h}},t.watchScroll=Zl}));
31
+ */
32
+ const y=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),x=[.001,0,0,.001,0,0],A=1.35,S=1,_=2,C=4,E=16,P=32,T=64,M=128,k=256,D={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},I="pdfjs_internal_editor_",L={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},R={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_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},N=1,F=2,B=0,O=1,j=2,U=3,V=3,H=4,z={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},$={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},W=1,G=2,q=3,X=4,Y=5,K={ERRORS:0,WARNINGS:1,INFOS:5},Q={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,rawFillPath:94},Z=0,J=1,tt=2,et=3,it=4;let nt=K.WARNINGS;function st(t){Number.isInteger(t)&&(nt=t)}function rt(){return nt}function at(t){nt>=K.INFOS&&console.info(`Info: ${t}`)}function ot(t){nt>=K.WARNINGS&&console.warn(`Warning: ${t}`)}function lt(t){throw new Error(t)}function ht(t,e){t||lt(e)}function dt(t,e=null,i=null){if(!t)return null;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 n=e?URL.parse(t,e):URL.parse(t);return function(t){switch(t?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(n)?n:null}function ct(t,e,i=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):i&&dt(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function ut(t,e,i,n=!1){return Object.defineProperty(t,e,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}const pt=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class gt extends pt{constructor(t,e){super(t,"PasswordException"),this.code=e}}class mt extends pt{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let ft=class extends pt{constructor(t){super(t,"InvalidPDFException")}},bt=class extends pt{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}};class vt extends pt{constructor(t){super(t,"FormatError")}}let wt=class extends pt{constructor(t){super(t,"AbortException")}};function yt(t){"object"==typeof t&&void 0!==t?.length||lt("Invalid argument for bytesToString");const e=t.length,i=8192;if(e<i)return String.fromCharCode.apply(null,t);const n=[];for(let s=0;s<e;s+=i){const r=Math.min(s+i,e),a=t.subarray(s,r);n.push(String.fromCharCode.apply(null,a))}return n.join("")}function xt(t){"string"!=typeof t&&lt("Invalid argument for stringToBytes");const e=t.length,i=new Uint8Array(e);for(let n=0;n<e;++n)i[n]=255&t.charCodeAt(n);return i}class At{static get isLittleEndian(){return ut(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return ut(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return ut(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return ut(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return ut(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return ut(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:e}=navigator;return ut(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){return ut(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const St=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));let _t=class{static makeHexColor(t,e,i){return`#${St[t]}${St[e]}${St[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}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 multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const n=t[i],s=t[i+1];t[i]=n*e[0]+s*e[2]+e[4],t[i+1]=n*e[1]+s*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const n=e[0],s=e[1],r=e[2],a=e[3],o=e[4],l=e[5];for(let e=0;e<6;e+=2){const h=t[i+e],d=t[i+e+1];t[i+e]=h*n+d*r+o,t[i+e+1]=h*s+d*a+l}}static applyInverseTransform(t,e){const i=t[0],n=t[1],s=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/s,t[1]=(-i*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/s}static axialAlignedBoundingBox(t,e,i){const n=e[0],s=e[1],r=e[2],a=e[3],o=e[4],l=e[5],h=t[0],d=t[1],c=t[2],u=t[3];let p=n*h+o,g=p,m=n*c+o,f=m,b=a*d+l,v=b,w=a*u+l,y=w;if(0!==s||0!==r){const t=s*h,e=s*c,i=r*d,n=r*u;p+=i,f+=i,m+=n,g+=n,b+=t,y+=t,w+=e,v+=e}i[0]=Math.min(i[0],p,m,g,f),i[1]=Math.min(i[1],b,w,v,y),i[2]=Math.max(i[2],p,m,g,f),i[3]=Math.max(i[3],b,w,v,y)}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,e){const i=t[0],n=t[1],s=t[2],r=t[3],a=i**2+n**2,o=i*s+n*r,l=s**2+r**2,h=(a+l)/2,d=Math.sqrt(h**2-(a*l-o**2));e[0]=Math.sqrt(h+d||1),e[1]=Math.sqrt(h-d||1)}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])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const s=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 s>r?null:[i,s,n,r]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,n,s){s[0]=Math.min(s[0],t,i),s[1]=Math.min(s[1],e,n),s[2]=Math.max(s[2],t,i),s[3]=Math.max(s[3],e,n)}static#t(t,e,i,n,s,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*n,g=d*(d*(d*s+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,n,s,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,n,s,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,n,s,r,a,o,(-h+p)/g,c),this.#t(t,e,i,n,s,r,a,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,n,s,r,a,o,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),this.#e(t,i,s,a,e,n,r,o,3*(3*(i-s)-t+a),6*(t-2*i+s),3*(i-t),l),this.#e(t,i,s,a,e,n,r,o,3*(3*(n-r)-e+o),6*(e-2*n+r),3*(n-e),l)}};let Ct=null,Et=null;function Pt(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),yt(t)}const Tt="pdfjs_internal_id_";function Mt(t,e,i){return Math.min(Math.max(t,e),i)}function kt(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(yt(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(i=>{i(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});class Dt{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};return function t(i){if(!i)return;let n=null;const s=i.name;if("#text"===s)n=i.value;else{if(!Dt.shouldBuildText(s))return;i?.attributes?.textContent?n=i.attributes.textContent:i.value&&(n=i.value)}if(null!==n&&e.push({str:n}),i.children)for(const e of i.children)t(e)}(t),i}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}let It=class{static setupStorage(t,e,i,n,s){const r=n.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==r.value&&(t.textContent=r.value),"print"===s)break;t.addEventListener("input",t=>{n.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"===s)break;t.addEventListener("change",t=>{n.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"===s)break;t.addEventListener("input",t=>{n.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,s=-1===i.selectedIndex?"":i[i.selectedIndex].value;n.setValue(e,{value:s})})}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:s}){const{attributes:r}=e,a=t instanceof HTMLAnchorElement;"radio"===r.type&&(r.name=`${r.name}-${n}`);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&&s.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,n=t.xfaHtml,s=t.intent||"display",r=document.createElement(n.name);n.attributes&&this.setAttributes({html:r,element:n,intent:s,linkService:i});const a="richText"!==s,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===n.children.length){if(n.value){const t=document.createTextNode(n.value);r.append(t),a&&Dt.shouldBuildText(n.name)&&l.push(t)}return{textDivs:l}}const h=[[n,-1,r]];for(;h.length>0;){const[t,n,r]=h.at(-1);if(n+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:s,linkService:i}),o.children?.length>0)h.push([o,-1,c]);else if(o.value){const t=document.createTextNode(o.value);a&&Dt.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 Lt="http://www.w3.org/2000/svg";let Rt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function Nt(t,e="text"){if(Ht(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,n)=>{const s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType=e,s.onreadystatechange=()=>{if(s.readyState===XMLHttpRequest.DONE)if(200!==s.status&&0!==s.status)n(new Error(s.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void i(s.response)}i(s.responseText)}},s.send(null)})}class Ft{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:s=0,offsetY:r=0,dontFlip:a=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=s,this.offsetY=r,i*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,c,u,p,g,m,f;switch((n%=360)<0&&(n+=360),n){case 180:h=-1,d=0,c=0,u=1;break;case 90:h=0,d=1,c=1,u=0;break;case 270:h=0,d=-1,c=-1,u=0;break;case 0:h=1,d=0,c=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+s,g=Math.abs(o-t[0])*i+r,m=(t[3]-t[1])*i,f=(t[2]-t[0])*i):(p=Math.abs(o-t[0])*i+s,g=Math.abs(l-t[1])*i+r,m=(t[2]-t[0])*i,f=(t[3]-t[1])*i),this.transform=[h*i,d*i,c*i,u*i,p-h*i*o-c*i*l,g-d*i*o-u*i*l],this.width=m,this.height=f}get rawDims(){const t=this.viewBox;return ut(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:n=this.offsetY,dontFlip:s=!1}={}){return new Ft({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}convertToViewportPoint(t,e){const i=[t,e];return _t.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];_t.applyTransform(e,this.transform);const i=[t[2],t[3]];return _t.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return _t.applyInverseTransform(i,this.transform),i}}let Bt=class extends pt{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Ot(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function jt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ut(t,e="document.pdf"){if("string"!=typeof t)return e;if(Ot(t))return ot('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),e;const i=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!i)return e;const n=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch{return t}},s=/\.pdf$/i,r=i.pathname.split("/").at(-1);if(s.test(r))return n(r);if(i.searchParams.size>0){const t=Array.from(i.searchParams.values()).reverse();for(const e of t)if(s.test(e))return n(e);const e=Array.from(i.searchParams.keys()).reverse();for(const t of e)if(s.test(t))return n(t)}if(i.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(t)return n(t[0])}return e}class Vt{started=Object.create(null);times=[];time(t){t in this.started&&ot(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||ot(`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:n,end:s}of this.times)t.push(`${i.padEnd(e)} ${s-n}ms\n`);return t.join("")}}function Ht(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function zt(t){t.preventDefault()}function $t(t){t.preventDefault(),t.stopPropagation()}let Wt=class{static#i;static toDateObject(t){if(t instanceof Date)return 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 n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let s=parseInt(e[3],10);s=s>=1&&s<=31?s: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,n,s,r,a,o))}};function Gt(t,{scale:e=1,rotation:i=0}){const{width:n,height:s}=t.attributes.style,r=[0,0,parseInt(n),parseInt(s)];return new Ft({viewBox:r,userUnit:1,scale:e,rotation:i})}function qt(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):(ot(`Not a valid color format: "${t}"`),[0,0,0])}function Xt(t){const{a:e,b:i,c:n,d:s,e:r,f:a}=t.getTransform();return[e,i,n,s,r,a]}function Yt(t){const{a:e,b:i,c:n,d:s,e:r,f:a}=t.getTransform().invertSelf();return[e,i,n,s,r,a]}function Kt(t,e,i=!1,n=!0){if(e instanceof Ft){const{pageWidth:n,pageHeight:s}=e.rawDims,{style:r}=t,a=At.isCSSRoundSupported,o=`var(--total-scale-factor) * ${n}px`,l=`var(--total-scale-factor) * ${s}px`,h=a?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,d=a?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;i&&e.rotation%180!=0?(r.width=d,r.height=h):(r.width=h,r.height=d)}n&&t.setAttribute("data-main-rotation",e.rotation)}let Qt=class t{constructor(){const{pixelRatio:e}=t;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(e,i,n,s,r=-1){let a=1/0,o=1/0,l=1/0;(n=t.capPixels(n,r))>0&&(a=Math.sqrt(n/(e*i))),-1!==s&&(o=s/e,l=s/i);const h=Math.min(a,o,l);return(this.sx>h||this.sy>h)&&(this.sx=h,this.sy=h,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}};const Zt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Jt{static get isDarkMode(){return ut(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function te(t,e){const i=t[0]/255,n=t[1]/255,s=t[2]/255,r=Math.max(i,n,s),a=Math.min(i,n,s),o=(r+a)/2;if(r===a)e[0]=e[1]=0;else{const t=r-a;switch(e[1]=o<.5?t/(r+a):t/(2-r-a),r){case i:e[0]=60*((n-s)/t+(n<s?6:0));break;case n:e[0]=60*((s-i)/t+2);break;case s:e[0]=60*((i-n)/t+4)}}e[2]=o}function ee(t,e){const i=t[0],n=t[1],s=t[2],r=(1-Math.abs(2*s-1))*n,a=r*(1-Math.abs(i/60%2-1)),o=s-r/2;switch(Math.floor(i/60)){case 0:e[0]=r+o,e[1]=a+o,e[2]=o;break;case 1:e[0]=a+o,e[1]=r+o,e[2]=o;break;case 2:e[0]=o,e[1]=r+o,e[2]=a+o;break;case 3:e[0]=o,e[1]=a+o,e[2]=r+o;break;case 4:e[0]=a+o,e[1]=o,e[2]=r+o;break;case 5:case 6:e[0]=r+o,e[1]=o,e[2]=a+o}}function ie(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function ne(t,e,i){ee(t,i),i.map(ie);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];ee(e,i),i.map(ie);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)}const se=new Map;function re({html:t,dir:e,className:i},n){const s=document.createDocumentFragment();if("string"==typeof t){const i=document.createElement("p");i.dir=e||"auto";const n=t.split(/(?:\r\n?|\n)/);for(let t=0,e=n.length;t<e;++t){const s=n[t];i.append(document.createTextNode(s)),t<e-1&&i.append(document.createElement("br"))}s.append(i)}else It.render({xfaHtml:t,div:s,intent:"richText"});s.firstChild.classList.add("richText",i),n.append(s)}function ae(t){const e=new Path2D;if(!t)return e;for(let i=0,n=t.length;i<n;)switch(t[i++]){case Z:e.moveTo(t[i++],t[i++]);break;case J:e.lineTo(t[i++],t[i++]);break;case tt:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case et:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case it:e.closePath();break;default:ot(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class oe{#n=null;#s=null;#r;#a=null;#o=null;#l=null;#h=null;#d=null;static#c=null;constructor(t){this.#r=t,oe.#c||=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",signature:"pdfjs-editor-remove-signature-button"})}render(){const t=this.#n=document.createElement("div");t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=this.#r._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",zt,{signal:e}),t.addEventListener("pointerdown",oe.#u,{signal:e}));const i=this.#a=document.createElement("div");i.className="buttons",t.append(i);const n=this.#r.toolbarPosition;if(n){const{style:e}=t,i="ltr"===this.#r._uiManager.direction?1-n[0]:n[0];e.insetInlineEnd=100*i+"%",e.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return this.#n}static#u(t){t.stopPropagation()}#p(t){this.#r._focusEventsAllowed=!1,$t(t)}#g(t){this.#r._focusEventsAllowed=!0,$t(t)}#m(t){const e=this.#r._uiManager._signal;return e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("focusin",this.#p.bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",this.#g.bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",zt,{signal:e}),!0)}hide(){this.#n.classList.add("hidden"),this.#s?.hideDropdown()}show(){this.#n.classList.remove("hidden"),this.#o?.shown(),this.#l?.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=this.#r,i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",oe.#c[t]),this.#m(i)&&i.addEventListener("click",t=>{e.delete()},{signal:e._signal}),this.#a.append(i)}get#f(){const t=document.createElement("div");return t.className="divider",t}async addAltText(t){const e=await t.render();this.#m(e),this.#a.append(e,this.#f),this.#o=t}addComment(t,e=null){if(this.#l)return;const i=t.renderForToolbar();if(!i)return;this.#m(i);const n=this.#h=this.#f;e?(this.#a.insertBefore(i,e),this.#a.insertBefore(n,e)):this.#a.append(i,n),this.#l=t,t.toolbar=this}addColorPicker(t){if(this.#s)return;this.#s=t;const e=t.renderButton();this.#m(e),this.#a.append(e,this.#f)}async addEditSignatureButton(t){const e=this.#d=await t.renderEditButton(this.#r);this.#m(e),this.#a.append(e,this.#f)}removeButton(t){if("comment"===t)this.#l?.removeToolbarCommentButton(),this.#l=null,this.#h?.remove(),this.#h=null}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e)}}async addButtonBefore(t,e,i){if(!e&&"comment"===t)return;const n=this.#a.querySelector(i);n&&"comment"===t&&this.addComment(e,n)}updateEditSignatureButton(t){this.#d&&(this.#d.title=t)}remove(){this.#n.remove(),this.#s?.destroy(),this.#s=null}}class le{#a=null;#n=null;#b;constructor(t){this.#b=t}#v(){const t=this.#n=document.createElement("div");t.className="editToolbar",t.setAttribute("role","toolbar");const e=this.#b._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",zt,{signal:e});const i=this.#a=document.createElement("div");return i.className="buttons",t.append(i),this.#b.hasCommentManager()&&this.#w("commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{this.#b.commentSelection("floating_button")}),this.#w("highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{this.#b.highlightSelection("floating_button")}),t}#y(t,e){let i=0,n=0;for(const s of t){const t=s.y+s.height;if(t<i)continue;const r=s.x+(e?s.width:0);t>i?(n=r,i=t):e?r>n&&(n=r):r<n&&(n=r)}return[e?1-n:n,i]}show(t,e,i){const[n,s]=this.#y(e,i),{style:r}=this.#n||=this.#v();t.append(this.#n),r.insetInlineEnd=100*n+"%",r.top=`calc(${100*s}% + var(--editor-toolbar-vert-offset))`}hide(){this.#n.remove()}#w(t,e,i,n){const s=document.createElement("button");s.classList.add("basic",t),s.tabIndex=0,s.setAttribute("data-l10n-id",e);const r=document.createElement("span");s.append(r),r.className="visuallyHidden",r.setAttribute("data-l10n-id",i);const a=this.#b._signal;a instanceof AbortSignal&&!a.aborted&&(s.addEventListener("contextmenu",zt,{signal:a}),s.addEventListener("click",n,{signal:a})),this.#a.append(s)}}function he(t,e,i){for(const n of i)e.addEventListener(n,t[n].bind(t))}class de{static#x=NaN;static#A=null;static#S=NaN;static#_=null;static initializeAndAddPointerId(t){(de.#A||=new Set).add(t)}static setPointer(t,e){de.#x||=e,de.#_??=t}static setTimeStamp(t){de.#S=t}static isSamePointerId(t){return de.#x===t}static isSamePointerIdOrRemove(t){return de.#x===t||(de.#A?.delete(t),!1)}static isSamePointerType(t){return de.#_===t}static isInitializedAndDifferentPointerType(t){return null!==de.#_&&!de.isSamePointerType(t)}static isSameTimeStamp(t){return de.#S===t}static isUsingMultiplePointers(){return de.#A?.size>=1}static clearPointerType(){de.#_=null}static clearPointerIds(){de.#x=NaN,de.#A=null}static clearTimeStamp(){de.#S=NaN}}class ce{#C=0;get id(){return`${I}${this.#C++}`}}class ue{#E=Pt();#C=0;#P=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 ut(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(t,e){this.#P||=new Map;let i=this.#P.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.#E}_${this.#C++}`,refCounter:0,isSvg:!1},"string"==typeof e?(i.url=e,t=await Nt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=ue._isSVGFittingCanvas,n=new FileReader,s=new Image,r=new Promise((t,r)=>{s.onload=()=>{i.bitmap=s,i.isSvg=!0,t()},n.onload=async()=>{const t=i.svgUrl=n.result;s.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},s.onerror=n.onerror=r});n.readAsDataURL(t),await r}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){ot(t),i=null}return this.#P.set(t,i),i&&this.#P.set(i.id,i),i}async getFromFile(t){const{lastModified:e,name:i,size:n,type:s}=t;return this.#T(`${e}_${i}_${n}_${s}`,t)}async getFromUrl(t){return this.#T(t,t)}async getFromBlob(t,e){const i=await e;return this.#T(t,i)}async getFromId(t){this.#P||=new Map;const e=this.#P.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.#P||=new Map;let i=this.#P.get(t);if(i?.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${this.#E}_${this.#C++}`,refCounter:1,isSvg:!1},this.#P.set(t,i),this.#P.set(i.id,i),i}getSvgUrl(t){const e=this.#P.get(t);return e?.isSvg?e.svgUrl:null}deleteId(t){this.#P||=new Map;const e=this.#P.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.#E}_`)}}class pe{#M=[];#k=!1;#D;#I=-1;constructor(t=128){this.#D=t}add({cmd:t,undo:e,post:i,mustExec:n,type:s=NaN,overwriteIfSameType:r=!1,keepUndo:a=!1}){if(n&&t(),this.#k)return;const o={cmd:t,undo:e,post:i,type:s};if(-1===this.#I)return this.#M.length>0&&(this.#M.length=0),this.#I=0,void this.#M.push(o);if(r&&this.#M[this.#I].type===s)return a&&(o.undo=this.#M[this.#I].undo),void(this.#M[this.#I]=o);const l=this.#I+1;l===this.#D?this.#M.splice(0,1):(this.#I=l,l<this.#M.length&&this.#M.splice(l)),this.#M.push(o)}undo(){if(-1===this.#I)return;this.#k=!0;const{undo:t,post:e}=this.#M[this.#I];t(),e?.(),this.#k=!1,this.#I-=1}redo(){if(this.#I<this.#M.length-1){this.#I+=1,this.#k=!0;const{cmd:t,post:e}=this.#M[this.#I];t(),e?.(),this.#k=!1}}hasSomethingToUndo(){return-1!==this.#I}hasSomethingToRedo(){return this.#I<this.#M.length-1}cleanType(t){if(-1!==this.#I){for(let e=this.#I;e>=0;e--)if(this.#M[e].type!==t)return this.#M.splice(e+1,this.#I-e),void(this.#I=e);this.#M.length=0,this.#I=-1}}destroy(){this.#M=null}}class ge{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=At.platform;for(const[i,n,s={}]of t)for(const t of i){const i=t.startsWith("mac+");e&&i?(this.callbacks.set(t.slice(4),{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1))):e||i||(this.callbacks.set(t,{callback:n,options:s}),this.allKeys.add(t.split("+").at(-1)))}}#L(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.#L(e));if(!i)return;const{callback:n,options:{bubbles:s=!1,args:r=[],checker:a=null}}=i;a&&!a(t,e)||(n.bind(t,...r,e)(),s||$t(e))}}class me{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",e.style.colorScheme="only light",document.body.append(e);for(const i of t.keys()){e.style.color=i;const n=window.getComputedStyle(e).color;t.set(i,qt(n))}e.remove()}(t),ut(this,"_colors",t)}convert(t){const e=qt(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 me._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?_t.makeHexColor(...e):t}}let fe=class t{#R=new AbortController;#N=null;#F=null;#B=new Map;#O=new Map;#j=null;#U=null;#V=null;#H=new pe;#z=null;#$=null;#W=null;#G=0;#q=new Set;#X=null;#Y=null;#K=new Set;_editorUndoBar=null;#Q=!1;#Z=!1;#J=!1;#tt=null;#et=null;#it=null;#nt=null;#st=!1;#rt=null;#at=new ce;#ot=!1;#lt=!1;#ht=!1;#dt=null;#ct=null;#ut=null;#pt=null;#gt=null;#mt=L.NONE;#ft=new Set;#bt=null;#vt=null;#wt=null;#yt=null;#xt=null;#At={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#St=[0,0];#_t=null;#Ct=null;#Et=null;#Pt=null;#Tt=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=t.prototype,i=t=>t.#Ct.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),n=(t,{target:e})=>{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},s=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return ut(this,"_keyboardManager",new ge([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["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:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Ct.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#Ct.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-s,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[s,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-s],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,s],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:i}]]))}constructor(t,e,i,n,s,r,a,o,l,h,d,c,u,p,g,m){const f=this._signal=this.#R.signal;this.#Ct=t,this.#Et=e,this.#Pt=i,this.#j=n,this.#z=s,this.#vt=r,this.#xt=o,this._eventBus=a,a._on("editingaction",this.onEditingAction.bind(this),{signal:f}),a._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),a._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),a._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),a._on("setpreference",this.onSetPreference.bind(this),{signal:f}),a._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:f}),window.addEventListener("pointerdown",()=>{this.#lt=!0},{capture:!0,signal:f}),window.addEventListener("pointerup",()=>{this.#lt=!1},{capture:!0,signal:f}),this.#Mt(),this.#kt(),this.#Dt(),this.#U=o.annotationStorage,this.#tt=o.filterFactory,this.#wt=l,this.#nt=h||null,this.#Q=d,this.#Z=c,this.#J=u,this.#gt=p||null,this.viewParameters={realScale:Rt.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==m,s?.setSidebarUiManager(this)}destroy(){this.#Tt?.resolve(),this.#Tt=null,this.#R?.abort(),this.#R=null,this._signal=null;for(const t of this.#O.values())t.destroy();this.#O.clear(),this.#B.clear(),this.#K.clear(),this.#pt?.clear(),this.#N=null,this.#ft.clear(),this.#H.destroy(),this.#j?.destroy(),this.#z?.destroy(),this.#vt?.destroy(),this.#rt?.hide(),this.#rt=null,this.#ut?.destroy(),this.#ut=null,this.#F=null,this.#et&&(clearTimeout(this.#et),this.#et=null),this.#_t&&(clearTimeout(this.#_t),this.#_t=null),this._editorUndoBar?.destroy(),this.#xt=null}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return this.#gt}get useNewAltTextFlow(){return this.#Z}get useNewAltTextWhenAddingImage(){return this.#J}get hcmFilter(){return ut(this,"hcmFilter",this.#wt?this.#tt.addHCMFilter(this.#wt.foreground,this.#wt.background):"none")}get direction(){return ut(this,"direction",getComputedStyle(this.#Ct).direction)}get _highlightColors(){return ut(this,"_highlightColors",this.#nt?new Map(this.#nt.split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return ut(this,"highlightColors",null);const e=new Map,i=!!this.#wt;for(const[n,s]of t){const t=n.endsWith("_HCM");i&&t?e.set(n.replace("_HCM",""),s):i||t||e.set(n,s)}return ut(this,"highlightColors",e)}get highlightColorNames(){return ut(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#W=t}setMainHighlightColorPicker(t){this.#ut=t}editAltText(t,e=!1){this.#j?.editAltText(this,t,e)}hasCommentManager(){return!!this.#z}editComment(t,e,i,n){this.#z?.showDialog(this,t,e,i,n)}selectComment(t,e){const i=this.#O.get(t),n=i?.getEditorByUID(e);n?.toggleComment(!0,!0)}updateComment(t){this.#z?.updateComment(t.getData())}updatePopupColor(t){this.#z?.updatePopupColor(t)}removeComment(t){this.#z?.removeComments([t.uid])}toggleComment(t,e,i=void 0){this.#z?.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){return t&&this.#z?.makeCommentColor(t,e)||null}getCommentDialogElement(){return this.#z?.dialogElement||null}async waitForEditorsRendered(t){if(this.#O.has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),n=i=>{i.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await i}getSignature(t){this.#vt?.getSignature({uiManager:this,editor:t})}get signatureManager(){return this.#vt}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.#J=e}onPageChanging({pageNumber:t}){this.#G=t-1}focusMainContainer(){this.#Ct.focus()}findParent(t,e){for(const i of this.#O.values()){const{x:n,y:s,width:r,height:a}=i.div.getBoundingClientRect();if(t>=n&&t<=n+r&&e>=s&&e<=s+a)return i}return null}disableUserSelect(t=!1){this.#Et.classList.toggle("noUserSelect",t)}addShouldRescale(t){this.#K.add(t)}removeShouldRescale(t){this.#K.delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Rt.PDF_TO_CSS_UNITS;for(const t of this.#K)t.onScaleChanging();this.#W?.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}#It({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t}#Lt(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const e of this.#O.values())if(e.hasTextLayer(t))return e;return null}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a}=i,o=i.toString(),l=this.#It(i).closest(".textLayer"),h=this.getSelectionBoxes(l);if(!h)return;i.empty();const d=this.#Lt(l),c=this.#mt===L.NONE,u=()=>{const i=d?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:h,anchorNode:n,anchorOffset:s,focusNode:r,focusOffset:a,text:o});c&&this.showAllEditors("highlight",!0,!0),e&&i?.editComment()};c?this.switchToMode(L.HIGHLIGHT,u):u()}commentSelection(t=""){this.highlightSelection(t,!0)}#Rt(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=this.#It(t).closest(".textLayer"),i=this.getSelectionBoxes(e);i&&(this.#rt||=new le(this),this.#rt.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#U)return null;const e=`${I}${t}`,i=this.#U.getRawValue(e);return i&&this.#U.remove(e),i}addToAnnotationStorage(t){t.isEmpty()||!this.#U||this.#U.has(t.id)||this.#U.setValue(t.id,t)}a11yAlert(t,e=null){const i=this.#Pt;i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}#Nt(){const t=document.getSelection();if(!t||t.isCollapsed)return void(this.#bt&&(this.#rt?.hide(),this.#bt=null,this.#Ft({hasSelectedText:!1})));const{anchorNode:e}=t;if(e===this.#bt)return;const i=this.#It(t).closest(".textLayer");if(i){if(this.#rt?.hide(),this.#bt=e,this.#Ft({hasSelectedText:!0}),(this.#mt===L.HIGHLIGHT||this.#mt===L.NONE)&&(this.#mt===L.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#st=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#mt===L.HIGHLIGHT?this.#Lt(i):null;if(t?.toggleDrawing(),this.#lt){const e=new AbortController,i=this.combinedSignal(e),n=i=>{"pointerup"===i.type&&0!==i.button||(e.abort(),t?.toggleDrawing(!0),"pointerup"===i.type&&this.#Bt("main_toolbar"))};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})}else t?.toggleDrawing(!0),this.#Bt("main_toolbar")}}else this.#bt&&(this.#rt?.hide(),this.#bt=null,this.#Ft({hasSelectedText:!1}))}#Bt(t=""){this.#mt===L.HIGHLIGHT?this.highlightSelection(t):this.#Q&&this.#Rt()}#Mt(){document.addEventListener("selectionchange",this.#Nt.bind(this),{signal:this._signal})}#Ot(){if(this.#it)return;this.#it=new AbortController;const t=this.combinedSignal(this.#it);window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})}#jt(){this.#it?.abort(),this.#it=null}blur(){if(this.isShiftKeyDown=!1,this.#st&&(this.#st=!1,this.#Bt("main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of this.#ft)if(e.div.contains(t)){this.#ct=[e,t],e._focusEventsAllowed=!1;break}}focus(){if(!this.#ct)return;const[t,e]=this.#ct;this.#ct=null,e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}#Dt(){if(this.#dt)return;this.#dt=new AbortController;const t=this.combinedSignal(this.#dt);window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})}#Ut(){this.#dt?.abort(),this.#dt=null}#Vt(){if(this.#$)return;this.#$=new AbortController;const t=this.combinedSignal(this.#$);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})}#Ht(){this.#$?.abort(),this.#$=null}#kt(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})}addEditListeners(){this.#Dt(),this.setEditingState(!0)}removeEditListeners(){this.#Ut(),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of this.#Y)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.#Y)if(i.isHandlingMimeForPasting(e.type))return i.paste(e,this.currentLayer),void t.preventDefault()}copy(t){if(t.preventDefault(),this.#N?.commitOrRemove(),!this.hasSelection)return;const e=[];for(const t of this.#ft){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.#Y)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 ot(`paste: "${t.message}".`)}if(!Array.isArray(i))return;this.unselectAll();const n=this.currentLayer;try{const t=[];for(const e of i){const i=await n.deserialize(e);if(!i)return;t.push(i)}const e=()=>{for(const e of t)this.#zt(e);this.#$t(t)},s=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:s,mustExec:!0})}catch(t){ot(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#mt===L.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,this.#st&&(this.#st=!1,this.#Bt("main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu")}}#Ft(t){Object.entries(t).some(([t,e])=>this.#At[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#At,t)}),this.#mt===L.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Wt([[R.HIGHLIGHT_FREE,!0]]))}#Wt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ot(),this.#Vt(),this.#Ft({isEditing:this.#mt!==L.NONE,isEmpty:this.#Gt(),hasSomethingToUndo:this.#H.hasSomethingToUndo(),hasSomethingToRedo:this.#H.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#jt(),this.#Ht(),this.#Ft({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!this.#Y){this.#Y=t;for(const t of this.#Y)this.#Wt(t.defaultPropertiesToUpdate)}}getId(){return this.#at.id}get currentLayer(){return this.#O.get(this.#G)}getLayer(t){return this.#O.get(t)}get currentPageIndex(){return this.#G}addLayer(t){this.#O.set(t.pageIndex,t),this.#ot?t.enable():t.disable()}removeLayer(t){this.#O.delete(t.pageIndex)}async updateMode(t,e=null,i=!1,n=!1,s=!1){if(this.#mt!==t&&(!this.#Tt||(await this.#Tt.promise,this.#Tt))){if(this.#Tt=Promise.withResolvers(),this.#W?.commitOrRemove(),this.#mt===L.POPUP&&this.#z?.hideSidebar(),this.#z?.destroyPopup(),this.#mt=t,t===L.NONE){this.setEditingState(!1),this.#qt();for(const t of this.#B.values())t.hideStandaloneCommentButton();return this._editorUndoBar?.hide(),this.toggleComment(null),void this.#Tt.resolve()}for(const t of this.#B.values())t.addStandaloneCommentButton();t===L.SIGNATURE&&await(this.#vt?.loadSignatures()),this.setEditingState(!0),await this.#Xt(),this.unselectAll();for(const e of this.#O.values())e.updateMode(t);if(t===L.POPUP){this.#F||=await this.#xt.getAnnotationsByType(new Set(this.#Y.map(t=>t._editorType)));const t=new Set,e=[];for(const i of this.#B.values()){const{annotationElementId:n,hasComment:s,deleted:r}=i;n&&t.add(n),s&&!r&&e.push(i.getData())}for(const i of this.#F){const{id:n,popupRef:s,contentsObj:r}=i;s&&r?.str&&!t.has(n)&&!this.#q.has(n)&&e.push(i)}this.#z?.showSidebar(e)}if(!e)return i&&this.addNewEditorFromKeyboard(),void this.#Tt.resolve();for(const t of this.#B.values())t.uid===e?(this.setSelected(t),s?t.editComment():n?t.enterInEditMode():t.focus()):t.unselect();this.#Tt.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==this.#mt&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(this.#Y){switch(t){case R.CREATE:return void this.currentLayer.addNewEditor(e);case R.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#yt||=new Map).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const i of this.#ft)i.updateParams(t,e);else for(const i of this.#Y)i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){for(const i of this.#B.values())i.editorType===t&&i.show(e);(this.#yt?.get(R.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Wt([[R.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(this.#ht!==t){this.#ht=t;for(const e of this.#O.values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}async#Xt(){if(!this.#ot){this.#ot=!0;const t=[];for(const e of this.#O.values())t.push(e.enable());await Promise.all(t);for(const t of this.#B.values())t.enable()}}#qt(){if(this.unselectAll(),this.#ot){this.#ot=!1;for(const t of this.#O.values())t.disable();for(const t of this.#B.values())t.disable()}}*getEditors(t){for(const e of this.#B.values())e.pageIndex===t&&(yield e)}getEditor(t){return this.#B.get(t)}addEditor(t){this.#B.set(t.id,t)}removeEditor(t){t.div.contains(document.activeElement)&&(this.#et&&clearTimeout(this.#et),this.#et=setTimeout(()=>{this.focusMainContainer(),this.#et=null},0)),this.#B.delete(t.id),t.annotationElementId&&this.#pt?.delete(t.annotationElementId),this.unselect(t),t.annotationElementId&&this.#q.has(t.annotationElementId)||this.#U?.remove(t.id)}addDeletedAnnotationElement(t){this.#q.add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return this.#q.has(t)}removeDeletedAnnotationElement(t){this.#q.delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}#zt(t){const e=this.#O.get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))}setActiveEditor(t){this.#N!==t&&(this.#N=t,t&&this.#Wt(t.propertiesToUpdate))}get#Yt(){let t=null;for(t of this.#ft);return t}updateUI(t){this.#Yt===t&&this.#Wt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Wt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#ft.has(t))return this.#ft.delete(t),t.unselect(),void this.#Ft({hasSelectedEditor:this.hasSelection});this.#ft.add(t),t.select(),this.#Wt(t.propertiesToUpdate),this.#Ft({hasSelectedEditor:!0})}setSelected(t){this.updateToolbar({mode:t.mode,editId:t.uid}),this.#W?.commitOrRemove();for(const e of this.#ft)e!==t&&e.unselect();this.#ft.clear(),this.#ft.add(t),t.select(),this.#Wt(t.propertiesToUpdate),this.#Ft({hasSelectedEditor:!0})}isSelected(t){return this.#ft.has(t)}get firstSelectedEditor(){return this.#ft.values().next().value}unselect(t){t.unselect(),this.#ft.delete(t),this.#Ft({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ft.size}get isEnterHandled(){return 1===this.#ft.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#H.undo(),this.#Ft({hasSomethingToUndo:this.#H.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Gt()}),this._editorUndoBar?.hide()}redo(){this.#H.redo(),this.#Ft({hasSomethingToUndo:!0,hasSomethingToRedo:this.#H.hasSomethingToRedo(),isEmpty:this.#Gt()})}addCommands(t){this.#H.add(t),this.#Ft({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Gt()})}cleanUndoStack(t){this.#H.cleanType(t)}#Gt(){if(0===this.#B.size)return!0;if(1===this.#B.size)for(const t of this.#B.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.#ft],i=()=>{for(const t of e)this.#zt(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.#N?.commitOrRemove()}hasSomethingToControl(){return this.#N||this.hasSelection}#$t(t){for(const t of this.#ft)t.unselect();this.#ft.clear();for(const e of t)e.isEmpty()||(this.#ft.add(e),e.select());this.#Ft({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#ft)t.commit();this.#$t(this.#B.values())}unselectAll(){if((!this.#N||(this.#N.commitOrRemove(),this.#mt===L.NONE))&&!this.#W?.commitOrRemove()&&this.hasSelection){for(const t of this.#ft)t.unselect();this.#ft.clear(),this.#Ft({hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;this.#St[0]+=t,this.#St[1]+=e;const[n,s]=this.#St,r=[...this.#ft];this.#_t&&clearTimeout(this.#_t),this.#_t=setTimeout(()=>{this.#_t=null,this.#St[0]=this.#St[1]=0,this.addCommands({cmd:()=>{for(const t of r)this.#B.has(t.id)&&(t.translateInPage(n,s),t.translationDone())},undo:()=>{for(const t of r)this.#B.has(t.id)&&(t.translateInPage(-n,-s),t.translationDone())},mustExec:!1})},1e3);for(const i of r)i.translateInPage(t,e),i.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#X=new Map;for(const t of this.#ft)this.#X.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#X)return!1;this.disableUserSelect(!1);const t=this.#X;this.#X=null;let e=!1;for(const[{x:i,y:n,pageIndex:s},r]of t)r.newX=i,r.newY=n,r.newPageIndex=s,e||=i!==r.savedX||n!==r.savedY||s!==r.savedPageIndex;if(!e)return!1;const i=(t,e,i,n)=>{if(this.#B.has(t.id)){const s=this.#O.get(n);s?t._setParentAndPosition(s,e,i):(t.pageIndex=n,t.x=e,t.y=i)}};return this.addCommands({cmd:()=>{for(const[e,{newX:n,newY:s,newPageIndex:r}]of t)i(e,n,s,r)},undo:()=>{for(const[e,{savedX:n,savedY:s,savedPageIndex:r}]of t)i(e,n,s,r)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#X)for(const i of this.#X.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.#ft.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#N===t}getActive(){return this.#N}getMode(){return this.#mt}isEditingMode(){return this.#mt!==L.NONE}get imageManager(){return ut(this,"imageManager",new ue)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let i=0,n=e.rangeCount;i<n;i++)if(!t.contains(e.getRangeAt(i).commonAncestorContainer))return null;const{x:i,y:n,width:s,height:r}=t.getBoundingClientRect();let a;switch(t.getAttribute("data-main-rotation")){case"90":a=(t,e,a,o)=>({x:(e-n)/r,y:1-(t+a-i)/s,width:o/r,height:a/s});break;case"180":a=(t,e,a,o)=>({x:1-(t+a-i)/s,y:1-(e+o-n)/r,width:a/s,height:o/r});break;case"270":a=(t,e,a,o)=>({x:1-(e+o-n)/r,y:(t-i)/s,width:o/r,height:a/s});break;default:a=(t,e,a,o)=>({x:(t-i)/s,y:(e-n)/r,width:a/s,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:n,height:s}of i.getClientRects())0!==n&&0!==s&&o.push(a(t,e,n,s))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(this.#V||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#V?.delete(t)}renderAnnotationElement(t){const e=this.#V?.get(t.data.id);if(!e)return;const i=this.#U.getRawValue(e);i&&(this.#mt!==L.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,i){const n=this.#pt?.get(t);n&&(n.setCanvas(e,i),this.#pt.delete(t))}addMissingCanvas(t,e){(this.#pt||=new Map).set(t,e)}};class be{#o=null;#Kt=!1;#Qt=null;#Zt=null;#Jt=null;#te=null;#ee=!1;#ie=null;#r=null;#ne=null;#se=null;#re=!1;static#ae=null;static _l10n=null;constructor(t){this.#r=t,this.#re=t._uiManager.useNewAltTextFlow,be.#ae||=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){be._l10n??=t}async render(){const t=this.#Qt=document.createElement("button");t.className="altText",t.tabIndex="0";const e=this.#Zt=document.createElement("span");t.append(e),this.#re?(t.classList.add("new"),t.setAttribute("data-l10n-id",be.#ae.missing),e.setAttribute("data-l10n-id",be.#ae["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",zt,{signal:i}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const n=t=>{t.preventDefault(),this.#r._uiManager.editAltText(this.#r),this.#re&&this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#oe}})};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#ee=!0,n(e))},{signal:i}),await this.#le(),t}get#oe(){return(this.#o?"added":null===this.#o&&this.guessedText&&"review")||"missing"}finish(){this.#Qt&&(this.#Qt.focus({focusVisible:this.#ee}),this.#ee=!1)}isEmpty(){return this.#re?null===this.#o:!this.#o&&!this.#Kt}hasData(){return this.#re?null!==this.#o||!!this.#ne:this.isEmpty()}get guessedText(){return this.#ne}async setGuessedText(t){null===this.#o&&(this.#ne=t,this.#se=await be._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t}),this.#le())}toggleAltTextBadge(t=!1){if(!this.#re||this.#o)return this.#ie?.remove(),void(this.#ie=null);if(!this.#ie){const t=this.#ie=document.createElement("div");t.className="noAltTextBadge",this.#r.div.append(t)}this.#ie.classList.toggle("hidden",!t)}serialize(t){let e=this.#o;return t||this.#ne!==e||(e=this.#se),{altText:e,decorative:this.#Kt,guessedText:this.#ne,textWithDisclaimer:this.#se}}get data(){return{altText:this.#o,decorative:this.#Kt}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:n,cancel:s=!1}){i&&(this.#ne=i,this.#se=n),this.#o===t&&this.#Kt===e||(s||(this.#o=t,this.#Kt=e),this.#le())}toggle(t=!1){this.#Qt&&(!t&&this.#te&&(clearTimeout(this.#te),this.#te=null),this.#Qt.disabled=!t)}shown(){this.#r._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#oe}})}destroy(){this.#Qt?.remove(),this.#Qt=null,this.#Zt=null,this.#Jt=null,this.#ie?.remove(),this.#ie=null}async#le(){const t=this.#Qt;if(!t)return;if(this.#re){if(t.classList.toggle("done",!!this.#o),t.setAttribute("data-l10n-id",be.#ae[this.#oe]),this.#Zt?.setAttribute("data-l10n-id",be.#ae[`${this.#oe}-label`]),!this.#o)return void this.#Jt?.remove()}else{if(!this.#o&&!this.#Kt)return t.classList.remove("done"),void this.#Jt?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Jt;if(!e){this.#Jt=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#r.id}`;const i=100,n=this.#r._uiManager._signal;n.addEventListener("abort",()=>{clearTimeout(this.#te),this.#te=null},{once:!0}),t.addEventListener("mouseenter",()=>{this.#te=setTimeout(()=>{this.#te=null,this.#Jt.classList.add("show"),this.#r._reportTelemetry({action:"alt_text_tooltip"})},i)},{signal:n}),t.addEventListener("mouseleave",()=>{this.#te&&(clearTimeout(this.#te),this.#te=null),this.#Jt?.classList.remove("show")},{signal:n})}this.#Kt?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.getElementForAltText();i?.setAttribute("aria-describedby",e.id)}}class ve{#he=null;#de=null;#ce=!1;#r=null;#ue=null;#pe=null;#ge=null;#me=null;#fe=!1;#be=null;constructor(t){this.#r=t}renderForToolbar(){const t=this.#de=document.createElement("button");return t.className="comment",this.#v(t,!1)}renderForStandalone(){const t=this.#he=document.createElement("button");t.className="annotationCommentButton";const e=this.#r.commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*("ltr"===this.#r._uiManager.direction?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=this.#r.commentButtonColor;n&&(i.backgroundColor=n)}return this.#v(t,!0)}focusButton(){setTimeout(()=>{(this.#he??this.#de)?.focus()},0)}onUpdatedColor(){if(!this.#he)return;const t=this.#r.commentButtonColor;t&&(this.#he.style.backgroundColor=t),this.#r._uiManager.updatePopupColor(this.#r)}get commentButtonWidth(){return(this.#he?.getBoundingClientRect().width??0)/this.#r.parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(this.#be)return this.#be;if(!this.#he)return null;const{x:t,y:e,height:i}=this.#he.getBoundingClientRect(),{x:n,y:s,width:r,height:a}=this.#r.parent.boundingClientRect;return[(t-n)/r,(e+i-s)/a]}set commentPopupPositionInLayer(t){this.#be=t}hasDefaultPopupPosition(){return null===this.#be}removeStandaloneCommentButton(){this.#he?.remove(),this.#he=null}removeToolbarCommentButton(){this.#de?.remove(),this.#de=null}setCommentButtonStates({selected:t,hasPopup:e}){this.#he&&(this.#he.classList.toggle("selected",t),this.#he.ariaExpanded=e)}#v(t,e){if(!this.#r._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[this.#r._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=this.#r._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",zt,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#r._focusEventsAllowed=!1,$t(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#r._focusEventsAllowed=!0,$t(t)},{capture:!0,signal:i})),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const n=e=>{e.preventDefault(),t===this.#de?this.edit():this.#r.toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(this.#ce=!0,n(e))},{signal:i}),t.addEventListener("pointerenter",()=>{this.#r.toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{this.#r.toggleComment(!1,!1)},{signal:i}),t}edit(t){const e=this.commentPopupPositionInLayer;let i,n;if(e)[i,n]=e;else{[i,n]=this.#r.commentButtonPosition;const{width:t,height:e,x:s,y:r}=this.#r;i=s+i*t,n=r+n*e}const s=this.#r.parent.boundingClientRect,{x:r,y:a,width:o,height:l}=s;this.#r._uiManager.editComment(this.#r,r+i*o,a+n*l,{...t,parentDimensions:s})}finish(){this.#de&&(this.#de.focus({focusVisible:this.#ce}),this.#ce=!1)}isDeleted(){return this.#fe||""===this.#ge}isEmpty(){return null===this.#ge}hasBeenEdited(){return this.isDeleted()||this.#ge!==this.#ue}serialize(){return this.data}get data(){return{text:this.#ge,richText:this.#pe,date:this.#me,deleted:this.isDeleted()}}set data(t){if(t!==this.#ge&&(this.#pe=null),null===t)return this.#ge="",void(this.#fe=!0);this.#ge=t,this.#me=new Date,this.#fe=!1}setInitialText(t,e=null){this.#ue=t,this.data=t,this.#me=null,this.#pe=e}shown(){}destroy(){this.#de?.remove(),this.#de=null,this.#he?.remove(),this.#he=null,this.#ge="",this.#pe=null,this.#me=null,this.#r=null,this.#ce=!1,this.#fe=!1}}let we=class t{#Ct;#ve=!1;#we=null;#ye;#xe;#Ae;#Se;#_e=null;#Ce;#Ee=null;#Pe;#Te=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:s=null,onPinchEnd:r=null,signal:a}){this.#Ct=t,this.#we=i,this.#ye=e,this.#xe=n,this.#Ae=s,this.#Se=r,this.#Pe=new AbortController,this.#Ce=AbortSignal.any([a,this.#Pe.signal]),t.addEventListener("touchstart",this.#Me.bind(this),{passive:!1,signal:this.#Ce})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Qt.pixelRatio}#Me(t){if(this.#ye?.())return;if(1===t.touches.length){if(this.#_e)return;const t=this.#_e=new AbortController,e=AbortSignal.any([this.#Ce,t.signal]),i=this.#Ct,n={capture:!0,signal:e,passive:!1},s=t=>{"touch"===t.pointerType&&(this.#_e?.abort(),this.#_e=null)};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&($t(t),s(t))},n),i.addEventListener("pointerup",s,n),void i.addEventListener("pointercancel",s,n)}if(!this.#Te){this.#Te=new AbortController;const t=AbortSignal.any([this.#Ce,this.#Te.signal]),e=this.#Ct,i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",this.#ke.bind(this),i);const n=this.#De.bind(this);e.addEventListener("touchend",n,i),e.addEventListener("touchcancel",n,i),i.capture=!0,e.addEventListener("pointerdown",$t,i),e.addEventListener("pointermove",$t,i),e.addEventListener("pointercancel",$t,i),e.addEventListener("pointerup",$t,i),this.#xe?.()}if($t(t),2!==t.touches.length||this.#we?.())return void(this.#Ee=null);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),this.#Ee={touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY}}#ke(e){if(!this.#Ee||2!==e.touches.length)return;$t(e);let[i,n]=e.touches;i.identifier>n.identifier&&([i,n]=[n,i]);const{screenX:s,screenY:r}=i,{screenX:a,screenY:o}=n,l=this.#Ee,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,m=a-s,f=o-r,b=Math.hypot(m,f)||1,v=Math.hypot(p,g)||1;if(!this.#ve&&Math.abs(v-b)<=t.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=s,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!this.#ve)return void(this.#ve=!0);const w=[(s+a)/2,(r+o)/2];this.#Ae?.(w,v,b)}#De(t){t.touches.length>=2||(this.#Te&&(this.#Te.abort(),this.#Te=null,this.#Se?.()),this.#Ee&&($t(t),this.#Ee=null,this.#ve=!1))}destroy(){this.#Pe?.abort(),this.#Pe=null,this.#_e?.abort(),this.#_e=null}};class ye{#Ie=null;#Le=null;#o=null;#l=null;#he=null;#Re=!1;#Ne=null;#Fe="";#Be=null;#Oe=null;#je=null;#Ue=null;#Ve=null;#He="";#ze=!1;#$e=null;#We=!1;#Ge=!1;#qe=!1;#Xe=null;#Ye=0;#Ke=0;#Qe=null;#Ze=null;isSelected=!1;_isCopy=!1;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#Je=!1;#ti=ye._zIndex++;static _borderLineWidth=-1;static _colorManager=new me;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=ye.prototype._resizeWithKeyboard,e=fe.TRANSLATE_SMALL,i=fe.TRANSLATE_BIG;return ut(this,"_resizerKeyboardManager",new ge([[["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"],ye.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,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:r}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[s,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}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return ut(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new xe({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(ye._l10n??=t,ye._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!==ye._borderLineWidth)return;const i=getComputedStyle(document.documentElement);ye._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){lt("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#Je}set _isDraggable(t){this.#Je=t,this.div?.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}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.#ti}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(this.#ei(),this.#Ue?.remove(),this.#Ue=null),this.parent=t}focusin(t){this._focusEventsAllowed&&(this.#ze?this.#ze=!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.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[s,r]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/s,this.y=(e+n)/r,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n),this._onTranslated()}#ii([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(t,e){this.#ii(this.parentDimensions,t,e)}translateInPage(t,e){this.#$e||=[this.x,this.y,this.width,this.height],this.#ii(this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){this.#$e||=[this.x,this.y,this.width,this.height];const{div:i,parentDimensions:[n,s]}=this;if(this.x+=t/n,this.y+=e/s,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.#$e&&(this.#$e[0]!==this.x||this.#$e[1]!==this.y)}get _hasBeenResized(){return!!this.#$e&&(this.#$e[2]!==this.width||this.#$e[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=ye,n=i/t,s=i/e;switch(this.rotation){case 90:return[-n,s];case 180:return[n,s];case 270:return[n,-s];default:return[-n,-s]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:s,y:r,width:a,height:o}=this;if(a*=i,o*=n,s*=i,r*=n,this._mustFixPosition)switch(t){case 0:s=Mt(s,0,i-a),r=Mt(r,0,n-o);break;case 90:s=Mt(s,0,i-o),r=Mt(r,a,n);break;case 180:s=Mt(s,a,i),r=Mt(r,o,n);break;case 270:s=Mt(s,o,i),r=Mt(r,0,n-a)}this.x=s/=i,this.y=r/=n;const[l,h]=this.getBaseTranslation();s+=l,r+=h,e.left=`${(100*s).toFixed(2)}%`,e.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static#ni(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 ye.#ni(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return ye.#ni(t,e,360-this.parentRotation)}#si(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(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}#ri(){if(this.#Be)return;this.#Be=document.createElement("div"),this.#Be.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.#Be.append(t),t.classList.add("resizer",i),t.setAttribute("data-resizer-name",i),t.addEventListener("pointerdown",this.#ai.bind(this,i),{signal:e}),t.addEventListener("contextmenu",zt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Be)}#ai(t,e){e.preventDefault();const{isMac:i}=At.platform;if(0!==e.button||e.ctrlKey&&i)return;this.#o?.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,this.#Oe=[e.screenX,e.screenY];const s=new AbortController,r=this._uiManager.combinedSignal(s);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#oi.bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",$t,{passive:!1,signal:r}),window.addEventListener("contextmenu",zt,{signal:r}),this.#je={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=()=>{s.abort(),this.parent.togglePointerEvents(!0),this.#o?.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=a,this.div.style.cursor=o,this.#li()};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})}#hi(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()}_onResized(){}#li(){if(!this.#je)return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=this.#je;this.#je=null;const s=this.x,r=this.y,a=this.width,o=this.height;s===t&&r===e&&a===i&&o===n||this.addCommands({cmd:this.#hi.bind(this,s,r,a,o),undo:this.#hi.bind(this,t,e,i,n),mustExec:!0})}static _round(t){return Math.round(1e4*t)/1e4}#oi(t,e){const[i,n]=this.parentDimensions,s=this.x,r=this.y,a=this.width,o=this.height,l=ye.MIN_SIZE/i,h=ye.MIN_SIZE/n,d=this.#si(this.rotation),c=(t,e)=>[d[0]*t+d[2]*e,d[1]*t+d[3]*e],u=this.#si(360-this.rotation);let p,g,m=!1,f=!1;switch(t){case"topLeft":m=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":m=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":f=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":m=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":m=!0,p=(t,e)=>[0,e],g=(t,e)=>[t,0];break;case"middleLeft":f=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const b=p(a,o),v=g(a,o);let w=c(...v);const y=ye._round(s+w[0]),x=ye._round(r+w[1]);let A,S,_=1,C=1;if(e.fromKeyboard)({deltaX:A,deltaY:S}=e);else{const{screenX:t,screenY:i}=e,[n,s]=this.#Oe;[A,S]=this.screenToPageTranslation(t-n,i-s),this.#Oe[0]=t,this.#Oe[1]=i}var E,P;if([A,S]=(E=A/i,P=S/n,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),m){const t=Math.hypot(a,o);_=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-A,v[1]-b[1]-S)/t,1/a,1/o),l/a,h/o)}else f?_=Mt(Math.abs(v[0]-b[0]-A),l,1)/a:C=Mt(Math.abs(v[1]-b[1]-S),h,1)/o;const T=ye._round(a*_),M=ye._round(o*C);w=c(...g(T,M));const k=y-w[0],D=x-w[1];this.#$e||=[this.x,this.y,this.width,this.height],this.width=T,this.height=M,this.x=k,this.y=D,this.setDims(),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#o?.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||this.#Ge)return this._editToolbar;this._editToolbar=new oe(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){this._editToolbar?.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){this._editToolbar?.removeButton("comment")}removeEditToolbar(){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()}createAltText(){return this.#o||(be.initialize(ye._l10n),this.#o=new be(this),this.#Ie&&(this.#o.data=this.#Ie,this.#Ie=null)),this.#o}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}focusCommentButton(){this.#l?.focusButton()}addCommentButton(){return this.canAddComment?this.#l||=new ve(this):null}addStandaloneCommentButton(){this._uiManager.hasCommentManager()&&(this.#he?this._uiManager.isEditingMode()&&this.#he.classList.remove("hidden"):this.hasComment&&(this.#he=this.#l.renderForStandalone(),this.div.append(this.#he)))}removeStandaloneCommentButton(){this.#l.removeStandaloneCommentButton(),this.#he=null}hideStandaloneCommentButton(){this.#he?.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:i,deleted:n}}=this.#l;return{text:e,richText:t,date:i,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){this.#l||=new ve(this),this.#l.data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e)return;if(this.#l||=new ve(this),this.#l.setInitialText(t,i),!this.annotationElementId)return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){return this.#l?.hasBeenEdited()}get hasDeletedComment(){return this.#l?.isDeleted()}get hasComment(){return!!this.#l&&!this.#l.isEmpty()&&!this.#l.isDeleted()}async editComment(t){this.#l||=new ve(this),this.#l.edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){this.#l.setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const e=180,i=100,[,,,n]=t.rect,[s]=this.pageDimensions,[r]=this.pageTranslation,a=r+s+1,o=n-i,l=a+e;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[a,o,l,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){this.#l.data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=this.#Re?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),this.#di();const[e,i]=this.parentDimensions;this.parentRotation%180!=0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[n,s]=this.getInitialTranslation();return this.translate(n,s),he(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Ze||=new we({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#ci.bind(this),onPinching:this.#ui.bind(this),onPinchEnd:this.#pi.bind(this),signal:this._uiManager._signal})),this.addStandaloneCommentButton(),this._uiManager._editorUndoBar?.hide(),t}#ci(){this.#je={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#o?.toggle(!1),this.parent.togglePointerEvents(!1)}#ui(t,e,i){let n=i/e*.7+1-.7;if(1===n)return;const s=this.#si(this.rotation),r=(t,e)=>[s[0]*t+s[2]*e,s[1]*t+s[3]*e],[a,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=ye.MIN_SIZE/a,p=ye.MIN_SIZE/o;n=Math.max(Math.min(n,1/d,1/c),u/d,p/c);const g=ye._round(d*n),m=ye._round(c*n);if(g===d&&m===c)return;this.#$e||=[l,h,d,c];const f=r(d/2,c/2),b=ye._round(l+f[0]),v=ye._round(h+f[1]),w=r(g/2,m/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=m,this.setDims(),this.fixAndSetPosition(),this._onResizing()}#pi(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#li()}pointerdown(t){const{isMac:e}=At.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(this.#ze=!0,this._isDraggable?this.#gi(t):this.#mi(t))}#mi(t){const{isMac:e}=At.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)}#gi(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,s=this._uiManager.combinedSignal(n),r={capture:!0,passive:!1,signal:s},a=t=>{n.abort(),this.#Ne=null,this.#ze=!1,this._uiManager.endDragSession()||this.#mi(t),i&&this._onStopDragging()};e&&(this.#Ye=t.clientX,this.#Ke=t.clientY,this.#Ne=t.pointerId,this.#Fe=t.pointerType,window.addEventListener("pointermove",t=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:e,clientY:n,pointerId:s}=t;if(s!==this.#Ne)return void $t(t);const[r,a]=this.screenToPageTranslation(e-this.#Ye,n-this.#Ke);this.#Ye=e,this.#Ke=n,this._uiManager.dragSelectedEditors(r,a)},r),window.addEventListener("touchmove",$t,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#Fe&&(this.#Ze||t.isPrimary)&&a(t),$t(t)},r));const o=t=>{this.#Ne&&this.#Ne!==t.pointerId?$t(t):a(t)};window.addEventListener("pointerup",o,{signal:s}),window.addEventListener("blur",o,{signal:s})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Xe&&clearTimeout(this.#Xe),this.#Xe=setTimeout(()=>{this.#Xe=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 n=this.parentScale,[s,r]=this.pageDimensions,[a,o]=this.pageTranslation,l=t/n,h=e/n,d=this.x*s,c=this.y*r,u=this.width*s,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,n,s,r]=t,a=s-i,o=r-n;switch(this.rotation){case 0:return[i,e-r,a,o];case 90:return[i,e-n,o,a];case 180:return[s,e-n,a,o];case 270:return[s,e-r,o,a];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&ye._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){this.#l?.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:n,deleted:s,richText:r},uid:a,pageIndex:o,creationDate:l,modificationDate:h}=this;return{id:a,pageIndex:o,rect:this.getPDFRect(),richText:r,contentsObj:{str:t},creationDate:l,modificationDate:i||h,popupRef:!s,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),this.#Ge=!0,!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),this.#Ge=!1,!0)}isInEditMode(){return this.#Ge}shouldGetKeyboardEvents(){return this.#qe}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:s,innerWidth:r}=window;return e<r&&n>0&&t<s&&i>0}#di(){if(this.#Ve||!this.div)return;this.#Ve=new AbortController;const t=this._uiManager.combinedSignal(this.#Ve);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})}rebuild(){this.#di()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:this._initialData?.popupRef||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,n.#Ie=t.accessibilityData,n._isCopy=t.isCopy||!1;const[s,r]=n.pageDimensions,[a,o,l,h]=n.getRectInCurrentCoords(t.rect,r);return n.x=a/s,n.y=o/r,n.width=l/s,n.height=h/r,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#Ve?.abort(),this.#Ve=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),this.#Xe&&(clearTimeout(this.#Xe),this.#Xe=null),this.#ei(),this.removeEditToolbar(),this.#Qe){for(const t of this.#Qe.values())clearTimeout(t);this.#Qe=null}this.parent=null,this.#Ze?.destroy(),this.#Ze=null,this.#Ue?.remove(),this.#Ue=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ri(),this.#Be.classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return"ltr"===this._uiManager.direction?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,s,r]=this.getPDFRect();return[ye._round(i+(s-i)*t),ye._round(n+(r-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return this.#l.commentPopupPositionInLayer}set commentPopupPosition(t){this.#l.commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return this.#l.hasDefaultPopupPosition()}get commentButtonWidth(){return this.#l.commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){this.#l?.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||"Enter"!==t.key)return;this._uiManager.setSelected(this),this.#je={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const e=this.#Be.children;if(!this.#Le){this.#Le=Array.from(e);const t=this.#fi.bind(this),i=this.#bi.bind(this),n=this._uiManager._signal;for(const e of this.#Le){const s=e.getAttribute("data-resizer-name");e.setAttribute("role","spinbutton"),e.addEventListener("keydown",t,{signal:n}),e.addEventListener("blur",i,{signal:n}),e.addEventListener("focus",this.#vi.bind(this,s),{signal:n}),e.setAttribute("data-l10n-id",ye._l10nResizer[s])}}const i=this.#Le[0];let n=0;for(const t of e){if(t===i)break;n++}const s=(360-this.rotation+this.parentRotation)%360/90*(this.#Le.length/4);if(s!==n){if(s<n)for(let t=0;t<n-s;t++)this.#Be.append(this.#Be.firstChild);else if(s>n)for(let t=0;t<s-n;t++)this.#Be.firstChild.before(this.#Be.lastChild);let t=0;for(const i of e){const e=this.#Le[t++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",ye._l10nResizer[e])}}this.#wi(0),this.#qe=!0,this.#Be.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#fi(t){ye._resizerKeyboardManager.exec(this,t)}#bi(t){this.#qe&&t.relatedTarget?.parentNode!==this.#Be&&this.#ei()}#vi(t){this.#He=this.#qe?t:""}#wi(t){if(this.#Le)for(const e of this.#Le)e.tabIndex=t}_resizeWithKeyboard(t,e){this.#qe&&this.#oi(this.#He,{deltaX:t,deltaY:e,fromKeyboard:!0})}#ei(){this.#qe=!1,this.#wi(-1),this.#li()}_stopResizingWithKeyboard(){this.#ei(),this.div.focus()}select(){this.isSelected&&this._editToolbar?this._editToolbar.show():(this.isSelected=!0,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()}))}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>this.div?.focus({preventScroll:!0}),0)}unselect(){this.isSelected&&(this.isSelected=!1,this.#Be?.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),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){"BUTTON"!==t.target.nodeName&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return this.#We}set isEditing(t){this.#We=t,this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}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.#Qe||=new Map;const{action:e}=t;let i=this.#Qe.get(e);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),this.#Qe.delete(e),0===this.#Qe.size&&(this.#Qe=null)},ye._telemetryTimeout),void this.#Qe.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.#Re=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#Re=!0}updateFakeAnnotationElement(t){if(this.#Ue||this.deleted)return this.deleted?(this.#Ue.remove(),void(this.#Ue=null)):void((this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&this.#Ue.updateEdited({rect:this.getPDFRect(),popup:this.comment}));this.#Ue=t.addFakeAnnotation(this)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;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 xe extends ye{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Ae=3285377520,Se=4294901760,_e=65535;class Ce{constructor(t){this.h1=t?4294967295&t:Ae,this.h2=t?4294967295&t:Ae}update(t){let e,i;if("string"==typeof t){e=new Uint8Array(2*t.length),i=0;for(let n=0,s=t.length;n<s;n++){const s=t.charCodeAt(n);s<=255?e[i++]=s:(e[i++]=s>>>8,e[i++]=255&s)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),i=e.byteLength}const n=i>>2,s=i-4*n,r=new Uint32Array(e.buffer,0,n);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<n;t++)1&t?(a=r[t],a=a*d&Se|a*u&_e,a=a<<15|a>>>17,a=a*c&Se|a*p&_e,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&Se|o*u&_e,o=o<<15|o>>>17,o=o*c&Se|o*p&_e,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(a=0,s){case 3:a^=e[4*n+2]<<16;case 2:a^=e[4*n+1]<<8;case 1:a^=e[4*n],a=a*d&Se|a*u&_e,a=a<<15|a>>>17,a=a*c&Se|a*p&_e,1&n?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&Se|36045*t&_e,e=4283543511*e&Se|(2950163797*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,t=444984403*t&Se|60499*t&_e,e=3301882366*e&Se|(3120437893*(e<<16|t>>>16)&Se)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ee=Object.freeze({map:null,hash:"",transfer:void 0});class Pe{#yi=!1;#xi=null;#Ai=null;#Si=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#Si.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#Si.get(t)}remove(t){const e=this.#Si.get(t);if(void 0!==e&&(e instanceof ye&&this.#Ai.delete(e.annotationElementId),this.#Si.delete(t),0===this.#Si.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(const t of this.#Si.values())if(t instanceof ye)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#Si.get(t);let n=!1;if(void 0!==i)for(const[t,s]of Object.entries(e))i[t]!==s&&(n=!0,i[t]=s);else n=!0,this.#Si.set(t,e);n&&this.#_i(),e instanceof ye&&((this.#Ai||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#Si.has(t)}get size(){return this.#Si.size}#_i(){this.#yi||(this.#yi=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#yi&&(this.#yi=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Te(this)}get serializable(){if(0===this.#Si.size)return Ee;const t=new Map,e=new Ce,i=[],n=Object.create(null);let s=!1;for(const[i,r]of this.#Si){const a=r instanceof ye?r.serialize(!1,n):r;a&&(t.set(i,a),e.update(`${i}:${JSON.stringify(a)}`),s||=!!a.bitmap)}if(s)for(const e of t.values())e.bitmap&&i.push(e.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Ee}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const s of this.#Si.values()){if(!(s instanceof ye)){s.popup&&(s.popup.deleted?n+=1:i+=1);continue}s.isCommentDeleted?n+=1:s.hasEditedComment&&(i+=1);const r=s.telemetryFinalData;if(!r)continue;const{type:a}=r;e.has(a)||e.set(a,Object.getPrototypeOf(s).constructor),t||=Object.create(null);const o=t[a]||=new Map;for(const[t,e]of Object.entries(r)){if("type"===t)continue;let i=o.get(t);i||(i=new Map,o.set(t,i));const n=i.get(e)??0;i.set(e,n+1)}}if((n>0||i>0)&&(t||=Object.create(null),t.comments={deleted:n,edited:i}),!t)return null;for(const[i,n]of e)t[i]=n.computeTelemetryFinalData(t[i]);return t}resetModifiedIds(){this.#xi=null}updateEditor(t,e){const i=this.#Ai?.get(t);return!!i&&(i.updateFromAnnotationLayer(e),!0)}getEditor(t){return this.#Ai?.get(t)||null}get modifiedIds(){if(this.#xi)return this.#xi;const t=[];if(this.#Ai)for(const e of this.#Ai.values())e.serialize()&&t.push(e.annotationElementId);return this.#xi={ids:new Set(t),hash:t.join(",")}}[Symbol.iterator](){return this.#Si.entries()}}class Te extends Pe{#Ci;constructor(t){super();const{map:e,hash:i,transfer:n}=t.serializable,s=structuredClone(e,n?{transfer:n}:null);this.#Ci={map:s,hash:i,transfer:n}}get print(){lt("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ci}get modifiedIds(){return ut(this,"modifiedIds",{ids:new Set,hash:""})}}class Me{#Ei=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.#Ei.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(t&&!this.#Ei.has(t.loadedName)){if(ht(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:n,style:s}=t,r=new FontFace(e,n,s);this.addNativeFontFace(r);try{await r.load(),this.#Ei.add(e),i?.(t)}catch{ot(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}lt("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 ot(`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 ut(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return ut(this,"isSyncFontLoadingSupported",y||At.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(ht(!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 ut(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 n(t,e,i,n){return t.substring(0,e)+n+t.substring(e+i)}let s,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=n(d,976,h.length,h);const c=1482184792;let u=i(d,16);for(s=0,r=h.length-3;s<r;s+=4)u=u-c+i(h,s)|0;var p;s<h.length&&(u=u-c+i(h+"XXX",s)|0),d=n(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 m=this._document.createElement("div");m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px";for(const e of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=e,m.append(t)}this._document.body.append(m),function t(e,i){if(++l>30)return ot("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,()=>{m.remove(),e.complete()})}}class ke{#Pi;constructor(t,e=null,i,n){this.compiledGlyphs=Object.create(null),this.#Pi=t,this._inspectFont=e,i&&Object.assign(this,i),n&&(this.charProcOperatorList=n)}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,${kt(this.data)});`;let e;if(this.cssFontInfo){let i=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(i+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${i}src:${t}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;return this._inspectFont?.(this,t),e}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(t){ot(`getPathGenerator - ignoring character: "${t}".`)}const s=ae(n);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=s}get black(){return this.#Pi.black}get bold(){return this.#Pi.bold}get disableFontFace(){return this.#Pi.disableFontFace??!1}get fontExtraProperties(){return this.#Pi.fontExtraProperties??!1}get isInvalidPDFjsFont(){return this.#Pi.isInvalidPDFjsFont}get isType3Font(){return this.#Pi.isType3Font}get italic(){return this.#Pi.italic}get missingFile(){return this.#Pi.missingFile}get remeasure(){return this.#Pi.remeasure}get vertical(){return this.#Pi.vertical}get ascent(){return this.#Pi.ascent}get defaultWidth(){return this.#Pi.defaultWidth}get descent(){return this.#Pi.descent}get bbox(){return this.#Pi.bbox}get fontMatrix(){return this.#Pi.fontMatrix}get fallbackName(){return this.#Pi.fallbackName}get loadedName(){return this.#Pi.loadedName}get mimetype(){return this.#Pi.mimetype}get name(){return this.#Pi.name}get data(){return this.#Pi.data}clearData(){this.#Pi.clearData()}get cssFontInfo(){return this.#Pi.cssFontInfo}get systemFontInfo(){return this.#Pi.systemFontInfo}get defaultVMetrics(){return this.#Pi.defaultVMetrics}}class De{#Ti;#Mi;#ki;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of De.strings){const r=e.encode(t[s]);i[s]=r,n+=4+r.length}const s=new ArrayBuffer(n),r=new Uint8Array(s),a=new DataView(s);let o=0;for(const t of De.strings){const e=i[t],n=e.length;a.setUint32(o,n),r.set(e,o+4),o+=4+n}return ht(o===s.byteLength,"CssFontInfo.write: Buffer overflow"),s}constructor(t){this.#Ti=t,this.#Mi=new DataView(this.#Ti),this.#ki=new TextDecoder}#Di(t){ht(t<De.strings.length,"Invalid string index");let e=0;for(let i=0;i<t;i++)e+=this.#Mi.getUint32(e)+4;const i=this.#Mi.getUint32(e);return this.#ki.decode(new Uint8Array(this.#Ti,e+4,i))}get fontFamily(){return this.#Di(0)}get fontWeight(){return this.#Di(1)}get italicAngle(){return this.#Di(2)}}class Ie{#Ti;#Mi;#ki;static strings=["css","loadedName","baseFontName","src"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of Ie.strings){const r=e.encode(t[s]);i[s]=r,n+=4+r.length}n+=4;let s,r,a=1+n;t.style&&(s=e.encode(t.style.style),r=e.encode(t.style.weight),a+=4+s.length+4+r.length);const o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o);let d=0;h.setUint8(d++,t.guessFallback?1:0),h.setUint32(d,0),d+=4,n=0;for(const t of Ie.strings){const e=i[t],s=e.length;n+=4+s,h.setUint32(d,s),l.set(e,d+4),d+=4+s}return h.setUint32(d-n-4,n),t.style&&(h.setUint32(d,s.length),l.set(s,d+4),d+=4+s.length,h.setUint32(d,r.length),l.set(r,d+4),d+=4+r.length),ht(d<=o.byteLength,"SubstitionInfo.write: Buffer overflow"),o.transferToFixedLength(d)}constructor(t){this.#Ti=t,this.#Mi=new DataView(this.#Ti),this.#ki=new TextDecoder}get guessFallback(){return 0!==this.#Mi.getUint8(0)}#Di(t){ht(t<Ie.strings.length,"Invalid string index");let e=5;for(let i=0;i<t;i++)e+=this.#Mi.getUint32(e)+4;const i=this.#Mi.getUint32(e);return this.#ki.decode(new Uint8Array(this.#Ti,e+4,i))}get css(){return this.#Di(0)}get loadedName(){return this.#Di(1)}get baseFontName(){return this.#Di(2)}get src(){return this.#Di(3)}get style(){let t=1;t+=4+this.#Mi.getUint32(t);const e=this.#Mi.getUint32(t),i=this.#ki.decode(new Uint8Array(this.#Ti,t+4,e));t+=4+e;const n=this.#Mi.getUint32(t);return{style:i,weight:this.#ki.decode(new Uint8Array(this.#Ti,t+4,n))}}}class Le{static bools=["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"];static numbers=["ascent","defaultWidth","descent"];static strings=["fallbackName","loadedName","mimetype","name"];static#Ii=Math.ceil(2*this.bools.length/8);static#Li=this.#Ii+8*this.numbers.length;static#Ri=this.#Li+1+8;static#Ni=this.#Ri+1+48;static#Fi=this.#Ni+1+6;#Ti;#ki;#Mi;constructor({data:t,extra:e}){this.#Ti=t,this.#ki=new TextDecoder,this.#Mi=new DataView(this.#Ti),e&&Object.assign(this,e)}#Bi(t){ht(t<Le.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=2*t%8,n=this.#Mi.getUint8(e)>>i&3;return 0===n?void 0:2===n}get black(){return this.#Bi(0)}get bold(){return this.#Bi(1)}get disableFontFace(){return this.#Bi(2)}get fontExtraProperties(){return this.#Bi(3)}get isInvalidPDFjsFont(){return this.#Bi(4)}get isType3Font(){return this.#Bi(5)}get italic(){return this.#Bi(6)}get missingFile(){return this.#Bi(7)}get remeasure(){return this.#Bi(8)}get vertical(){return this.#Bi(9)}#Oi(t){return ht(t<Le.numbers.length,"Invalid number index"),this.#Mi.getFloat64(Le.#Ii+8*t)}get ascent(){return this.#Oi(0)}get defaultWidth(){return this.#Oi(1)}get descent(){return this.#Oi(2)}get bbox(){let t=Le.#Li;if(0===this.#Mi.getUint8(t))return;t+=1;const e=[];for(let i=0;i<4;i++)e.push(this.#Mi.getInt16(t,!0)),t+=2;return e}get fontMatrix(){let t=Le.#Ri;if(0===this.#Mi.getUint8(t))return;t+=1;const e=[];for(let i=0;i<6;i++)e.push(this.#Mi.getFloat64(t,!0)),t+=8;return e}get defaultVMetrics(){let t=Le.#Ni;if(0===this.#Mi.getUint8(t))return;t+=1;const e=[];for(let i=0;i<3;i++)e.push(this.#Mi.getInt16(t,!0)),t+=2;return e}#Di(t){ht(t<Le.strings.length,"Invalid string index");let e=Le.#Fi+4;for(let i=0;i<t;i++)e+=this.#Mi.getUint32(e)+4;const i=this.#Mi.getUint32(e),n=new Uint8Array(i);return n.set(new Uint8Array(this.#Ti,e+4,i)),this.#ki.decode(n)}get fallbackName(){return this.#Di(0)}get loadedName(){return this.#Di(1)}get mimetype(){return this.#Di(2)}get name(){return this.#Di(3)}get data(){let t=Le.#Fi;t+=4+this.#Mi.getUint32(t);t+=4+this.#Mi.getUint32(t);t+=4+this.#Mi.getUint32(t);const e=this.#Mi.getUint32(t);if(0!==e)return new Uint8Array(this.#Ti,t+4,e)}clearData(){let t=Le.#Fi;t+=4+this.#Mi.getUint32(t);t+=4+this.#Mi.getUint32(t);t+=4+this.#Mi.getUint32(t);const e=this.#Mi.getUint32(t);new Uint8Array(this.#Ti,t+4,e).fill(0),this.#Mi.setUint32(t,0)}get cssFontInfo(){let t=Le.#Fi;t+=4+this.#Mi.getUint32(t);t+=4+this.#Mi.getUint32(t);const e=this.#Mi.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#Ti,t+4,e)),new De(i.buffer)}get systemFontInfo(){let t=Le.#Fi;t+=4+this.#Mi.getUint32(t);const e=this.#Mi.getUint32(t);if(0===e)return null;const i=new Uint8Array(e);return i.set(new Uint8Array(this.#Ti,t+4,e)),new Ie(i.buffer)}static write(t){const e=t.systemFontInfo?Ie.write(t.systemFontInfo):null,i=t.cssFontInfo?De.write(t.cssFontInfo):null,n=new TextEncoder,s={};let r=0;for(const e of Le.strings)s[e]=n.encode(t[e]),r+=4+s[e].length;const a=Le.#Fi+4+r+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0),o=new ArrayBuffer(a),l=new Uint8Array(o),h=new DataView(o);let d=0;const c=Le.bools.length;let u=0,p=0;for(let e=0;e<c;e++){const i=t[Le.bools[e]];u|=(void 0===i?0:i?2:1)<<p,p+=2,8!==p&&e!==c-1||(h.setUint8(d++,u),u=0,p=0)}ht(d===Le.#Ii,"FontInfo.write: Boolean properties offset mismatch");for(const e of Le.numbers)h.setFloat64(d,t[e]),d+=8;if(ht(d===Le.#Li,"FontInfo.write: Number properties offset mismatch"),t.bbox){h.setUint8(d++,4);for(const e of t.bbox)h.setInt16(d,e,!0),d+=2}else h.setUint8(d++,0),d+=8;if(ht(d===Le.#Ri,"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){h.setUint8(d++,6);for(const e of t.fontMatrix)h.setFloat64(d,e,!0),d+=8}else h.setUint8(d++,0),d+=48;if(ht(d===Le.#Ni,"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){h.setUint8(d++,1);for(const e of t.defaultVMetrics)h.setInt16(d,e,!0),d+=2}else h.setUint8(d++,0),d+=6;ht(d===Le.#Fi,"FontInfo.write: DefaultVMetrics properties offset mismatch"),h.setUint32(Le.#Fi,0),d+=4;for(const t of Le.strings){const e=s[t],i=e.length;h.setUint32(d,i),l.set(e,d+4),d+=4+i}if(h.setUint32(Le.#Fi,d-Le.#Fi-4),e){const t=e.byteLength;h.setUint32(d,t),ht(d+4+t<=o.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),l.set(new Uint8Array(e),d+4),d+=4+t}else h.setUint32(d,0),d+=4;if(i){const t=i.byteLength;h.setUint32(d,t),ht(d+4+t<=o.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),l.set(new Uint8Array(i),d+4),d+=4+t}else h.setUint32(d,0),d+=4;return void 0===t.data?(h.setUint32(d,0),d+=4):(h.setUint32(d,t.data.length),l.set(t.data,d+4),d+=4+t.data.length),ht(d<=o.byteLength,"FontInfo.write: Buffer overflow"),o.transferToFixedLength(d)}}class Re{static#ji=0;static#Ui=1;static#Vi=2;static#Hi=3;static#zi=4;static#$i=8;static#Wi=12;static#Gi=16;constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,i=null,n=[],s=[],r=[],a=[],o=null,l=null;switch(t[0]){case"RadialAxial":e="axial"===t[1]?1:2,i=t[2],r=t[3],1===e?n.push(...t[4],...t[5]):n.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,o=t[1],n=t[2],s=t[3],a=t[4]||[],i=t[6],l=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}const h=Math.floor(n.length/2),d=Math.floor(s.length/3),c=r.length,u=a.length;let p=0;for(const t of a)p+=1,p=4*Math.ceil(p/4),p+=4+4*t.coords.length,p+=4+4*t.colors.length,void 0!==t.verticesPerRow&&(p+=4);const g=new ArrayBuffer(20+8*h+3*d+8*c+(i?16:0)+(l?3:0)+p),m=new DataView(g),f=new Uint8Array(g);m.setUint8(Re.#ji,e),m.setUint8(Re.#Ui,i?1:0),m.setUint8(Re.#Vi,l?1:0),m.setUint8(Re.#Hi,o),m.setUint32(Re.#zi,h,!0),m.setUint32(Re.#$i,d,!0),m.setUint32(Re.#Wi,c,!0),m.setUint32(Re.#Gi,u,!0);let b=20;new Float32Array(g,b,2*h).set(n),b+=8*h,f.set(s,b),b+=3*d;for(const[t,e]of r)m.setFloat32(b,t,!0),b+=4,m.setUint32(b,parseInt(e.slice(1),16),!0),b+=4;if(i)for(const t of i)m.setFloat32(b,t,!0),b+=4;l&&(f.set(l,b),b+=3);for(let t=0;t<a.length;t++){const e=a[t];m.setUint8(b,e.type),b+=1,b=4*Math.ceil(b/4),m.setUint32(b,e.coords.length,!0),b+=4;new Int32Array(g,b,e.coords.length).set(e.coords),b+=4*e.coords.length,m.setUint32(b,e.colors.length,!0),b+=4;new Int32Array(g,b,e.colors.length).set(e.colors),b+=4*e.colors.length,void 0!==e.verticesPerRow&&(m.setUint32(b,e.verticesPerRow,!0),b+=4)}return g}getIR(){const t=this.view,e=this.data[Re.#ji],i=!!this.data[Re.#Ui],n=!!this.data[Re.#Vi],s=t.getUint32(Re.#zi,!0),r=t.getUint32(Re.#$i,!0),a=t.getUint32(Re.#Wi,!0),o=t.getUint32(Re.#Gi,!0);let l=20;const h=new Float32Array(this.buffer,l,2*s);l+=8*s;const d=new Uint8Array(this.buffer,l,3*r);l+=3*r;const c=[];for(let e=0;e<a;++e){const e=t.getFloat32(l,!0);l+=4;const i=t.getUint32(l,!0);l+=4,c.push([e,`#${i.toString(16).padStart(6,"0")}`])}let u=null;if(i){u=[];for(let e=0;e<4;++e)u.push(t.getFloat32(l,!0)),l+=4}let p=null;n&&(p=new Uint8Array(this.buffer,l,3),l+=3);const g=[];for(let e=0;e<o;++e){const e=t.getUint8(l);l+=1,l=4*Math.ceil(l/4);const i=t.getUint32(l,!0);l+=4;const n=new Int32Array(this.buffer,l,i);l+=4*i;const s=t.getUint32(l,!0);l+=4;const r=new Int32Array(this.buffer,l,s);l+=4*s;const a={type:e,coords:n,colors:r};e===F&&(a.verticesPerRow=t.getUint32(l,!0),l+=4),g.push(a)}if(1===e)return["RadialAxial","axial",u,c,Array.from(h.slice(0,2)),Array.from(h.slice(2,4)),null,null];if(2===e)return["RadialAxial","radial",u,c,[h[0],h[1]],[h[3],h[4]],h[2],h[5]];if(3===e){const t=this.data[Re.#Hi];let e=null;if(h.length>0){let t=h[0],i=h[0],n=h[1],s=h[1];for(let e=0;e<h.length;e+=2){const r=h[e],a=h[e+1];t=t>r?r:t,n=n>a?a:n,i=i<r?r:i,s=s<a?a:s}e=[t,n,i,s]}return["Mesh",t,h,d,g,e,u,p]}throw new Error(`Unsupported pattern kind: ${e}`)}}function Ne(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Fe=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Be=function(t,e,i){if(!Array.isArray(i)||i.length<2)return!1;const[n,s,...r]=i;if(!t(n)&&!Number.isInteger(n))return!1;if(!e(s))return!1;const a=r.length;let o=!0;switch(s.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return 0===a;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(4!==a)return!1;o=!1;break;default:return!1}for(const t of r)if(!("number"==typeof t||o&&null===t))return!1;return!0}.bind(null,Fe,t=>"object"==typeof t&&"string"==typeof t?.name);class Oe{#qi=new Map;#Xi=Promise.resolve();postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};this.#Xi.then(()=>{for(const[t]of this.#qi)t.call(this,i)})}addEventListener(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void ot("LoopbackPort - cannot use an `aborted` signal.");const r=()=>this.removeEventListener(t,e);n=()=>s.removeEventListener("abort",r),s.addEventListener("abort",r)}this.#qi.set(e,n)}removeEventListener(t,e){const i=this.#qi.get(e);i?.(),this.#qi.delete(e)}terminate(){for(const[,t]of this.#qi)t?.();this.#qi.clear()}}const je=1,Ue=2,Ve=1,He=2,ze=3,$e=4,We=5,Ge=6,qe=7,Xe=8;function Ye(){}function Ke(t){if(t instanceof wt||t instanceof ft||t instanceof gt||t instanceof bt||t instanceof mt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||lt('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new wt(t.message);case"InvalidPDFException":return new ft(t.message);case"PasswordException":return new gt(t.message,t.code);case"ResponseException":return new bt(t.message,t.status,t.missing);case"UnknownErrorException":return new mt(t.message,t.details)}return new mt(t.message,t.toString())}class Qe{#Yi=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.#Ki.bind(this),{signal:this.#Yi.signal})}#Ki({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void this.#Qi(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===je)i.resolve(t.data);else{if(t.callback!==Ue)throw new Error("Unexpected callback case");i.reject(Ke(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,n=t.sourceName,s=this.comObj;return void Promise.try(e,t.data).then(function(e){s.postMessage({sourceName:i,targetName:n,callback:je,callbackId:t.callbackId,data:e})},function(e){s.postMessage({sourceName:i,targetName:n,callback:Ue,callbackId:t.callbackId,reason:Ke(e)})})}t.streamId?this.#Zi(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 n=this.callbackId++,s=Promise.withResolvers();this.callbackCapabilities[n]=s;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(t){s.reject(t)}return s.promise}sendWithStream(t,e,i,n){const s=this.streamId++,r=this.sourceName,a=this.targetName,o=this.comObj;return new ReadableStream({start:i=>{const l=Promise.withResolvers();return this.streamControllers[s]={controller:i,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:r,targetName:a,action:t,streamId:s,data:e,desiredSize:i.desiredSize},n),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[s].pullCall=e,o.postMessage({sourceName:r,targetName:a,stream:Ge,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{ht(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[s].cancelCall=e,this.streamControllers[s].isClosed=!0,o.postMessage({sourceName:r,targetName:a,stream:Ve,streamId:s,reason:Ke(t)}),e.promise}},i)}#Zi(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=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),s.postMessage({sourceName:i,targetName:n,stream:$e,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:ze,streamId:e}),delete r.streamSinks[e])},error(t){ht(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:We,streamId:e,reason:Ke(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(){s.postMessage({sourceName:i,targetName:n,stream:Xe,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:Xe,streamId:e,reason:Ke(t)})})}#Qi(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,s=this.comObj,r=this.streamControllers[e],a=this.streamSinks[e];switch(t.stream){case Xe:t.success?r.startCall.resolve():r.startCall.reject(Ke(t.reason));break;case qe:t.success?r.pullCall.resolve():r.pullCall.reject(Ke(t.reason));break;case Ge:if(!a){s.postMessage({sourceName:i,targetName:n,stream:qe,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Ye).then(function(){s.postMessage({sourceName:i,targetName:n,stream:qe,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:qe,streamId:e,reason:Ke(t)})});break;case $e:if(ht(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case ze:if(ht(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#Ji(r,e);break;case We:ht(r,"error should have stream controller"),r.controller.error(Ke(t.reason)),this.#Ji(r,e);break;case He:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ke(t.reason)),this.#Ji(r,e);break;case Ve:if(!a)break;const o=Ke(t.reason);Promise.try(a.onCancel||Ye,o).then(function(){s.postMessage({sourceName:i,targetName:n,stream:He,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:He,streamId:e,reason:Ke(t)})}),a.sinkCapability.reject(o),a.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}}async#Ji(t,e){await Promise.allSettled([t.startCall?.promise,t.pullCall?.promise,t.cancelCall?.promise]),delete this.streamControllers[e]}destroy(){this.#Yi?.abort(),this.#Yi=null}}class Ze{#tn=!1;constructor({enableHWA:t=!1}){this.#tn=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.#tn})}}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){lt("Abstract method `_createCanvas` called.")}}class Je extends Ze{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}}class ti{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){lt("Abstract method `_fetch` called.")}}class ei extends ti{async _fetch(t){const e=await Nt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):xt(e)}}class ii{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,n,s){return"none"}destroy(t=!1){}}class ni extends ii{#en;#in;#nn;#sn;#rn;#an;#C=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#sn=t,this.#rn=e}get#P(){return this.#in||=new Map}get#on(){return this.#an||=new Map}get#ln(){if(!this.#nn){const t=this.#rn.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.#rn.createElementNS(Lt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#nn=this.#rn.createElementNS(Lt,"defs"),t.append(i),i.append(this.#nn),this.#rn.body.append(t)}return this.#nn}#hn(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 n=i.join(",");return[n,n,n]}const[e,i,n]=t,s=new Array(256),r=new Array(256),a=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255,r[t]=i[t]/255,a[t]=n[t]/255;return[s.join(","),r.join(","),a.join(",")]}#dn(t){if(void 0===this.#en){this.#en="";const t=this.#rn.URL;t!==this.#rn.baseURI&&(Ot(t)?ot('#createUrl: ignore "data:"-URL for performance reasons.'):this.#en=ct(t,""))}return`url(${this.#en}#${t})`}addFilter(t){if(!t)return"none";let e=this.#P.get(t);if(e)return e;const[i,n,s]=this.#hn(t),r=1===t.length?i:`${i}${n}${s}`;if(e=this.#P.get(r),e)return this.#P.set(t,e),e;const a=`g_${this.#sn}_transfer_map_${this.#C++}`,o=this.#dn(a);this.#P.set(t,o),this.#P.set(r,o);const l=this.#cn(a);return this.#un(i,n,s,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,n="base";let s=this.#on.get(n);if(s?.key===i)return s.url;if(s?(s.filter?.remove(),s.key=i,s.url="none",s.filter=null):(s={key:i,url:"none",filter:null},this.#on.set(n,s)),!t||!e)return s.url;const r=this.#pn(t);t=_t.makeHexColor(...r);const a=this.#pn(e);if(e=_t.makeHexColor(...a),this.#ln.style.color="","#000000"===t&&"#ffffff"===e||t===e)return s.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.#sn}_hcm_filter`,d=s.filter=this.#cn(h);this.#un(l,l,l,d),this.#gn(d);const c=(t,e)=>{const i=r[t]/255,n=a[t]/255,s=new Array(e+1);for(let t=0;t<=e;t++)s[t]=i+t/e*(n-i);return s.join(",")};return this.#un(c(0,5),c(1,5),c(2,5),d),s.url=this.#dn(h),s.url}addAlphaFilter(t){let e=this.#P.get(t);if(e)return e;const[i]=this.#hn([t]),n=`alpha_${i}`;if(e=this.#P.get(n),e)return this.#P.set(t,e),e;const s=`g_${this.#sn}_alpha_map_${this.#C++}`,r=this.#dn(s);this.#P.set(t,r),this.#P.set(n,r);const a=this.#cn(s);return this.#mn(i,a),r}addLuminosityFilter(t){let e,i,n=this.#P.get(t||"luminosity");if(n)return n;if(t?([e]=this.#hn([t]),i=`luminosity_${e}`):i="luminosity",n=this.#P.get(i),n)return this.#P.set(t,n),n;const s=`g_${this.#sn}_luminosity_map_${this.#C++}`,r=this.#dn(s);this.#P.set(t,r),this.#P.set(i,r);const a=this.#cn(s);return this.#fn(a),t&&this.#mn(e,a),r}addHighlightHCMFilter(t,e,i,n,s){const r=`${e}-${i}-${n}-${s}`;let a=this.#on.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.#on.set(t,a)),!e||!i)return a.url;const[o,l]=[e,i].map(this.#pn.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]=[n,s].map(this.#pn.bind(this));d<h&&([h,d,c,u]=[d,h,u,c]),this.#ln.style.color="";const p=(t,e,i)=>{const n=new Array(256),s=(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*s),i=r+t*a;for(let t=o;t<=e;t++)n[t]=i;o=e+1}for(let t=o;t<256;t++)n[t]=n[o-1];return n.join(",")},g=`g_${this.#sn}_hcm_${t}_filter`,m=a.filter=this.#cn(g);return this.#gn(m),this.#un(p(c[0],u[0],5),p(c[1],u[1],5),p(c[2],u[2],5),m),a.url=this.#dn(g),a.url}destroy(t=!1){t&&this.#an?.size||(this.#nn?.parentNode.parentNode.remove(),this.#nn=null,this.#in?.clear(),this.#in=null,this.#an?.clear(),this.#an=null,this.#C=0)}#fn(t){const e=this.#rn.createElementNS(Lt,"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)}#gn(t){const e=this.#rn.createElementNS(Lt,"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)}#cn(t){const e=this.#rn.createElementNS(Lt,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),this.#ln.append(e),e}#bn(t,e,i){const n=this.#rn.createElementNS(Lt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)}#un(t,e,i,n){const s=this.#rn.createElementNS(Lt,"feComponentTransfer");n.append(s),this.#bn(s,"feFuncR",t),this.#bn(s,"feFuncG",e),this.#bn(s,"feFuncB",i)}#mn(t,e){const i=this.#rn.createElementNS(Lt,"feComponentTransfer");e.append(i),this.#bn(i,"feFuncA",t)}#pn(t){return this.#ln.style.color=t,qt(getComputedStyle(this.#ln).getPropertyValue("color"))}}class si{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){lt("Abstract method `_fetch` called.")}}class ri extends si{async _fetch(t){const e=await Nt(t,"arraybuffer");return new Uint8Array(e)}}class ai{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){lt("Abstract method `_fetch` called.")}}class oi extends ai{async _fetch(t){const e=await Nt(t,"arraybuffer");return new Uint8Array(e)}}async function li(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}y&&ot("Please use the `legacy` build in Node.js environments.");class hi extends ii{}class di extends Ze{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:s&&"SCRIPT"===s.tagName.toUpperCase()&&s.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class ci extends ti{async _fetch(t){return li(t)}}class ui extends si{async _fetch(t){return li(t)}}class pi extends ai{async _fetch(t){return li(t)}}const gi="__forcedDependency",{floor:mi,ceil:fi}=Math;function bi(t,e,i,n,s,r){t[4*e+0]=Math.min(t[4*e+0],i),t[4*e+1]=Math.min(t[4*e+1],n),t[4*e+2]=Math.max(t[4*e+2],s),t[4*e+3]=Math.max(t[4*e+3],r)}const vi=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class wi{#vn;#wn;constructor(t,e){this.#vn=t,this.#wn=e}get length(){return this.#vn.length}isEmpty(t){return this.#vn[t]===vi}minX(t){return this.#wn[4*t+0]/256}minY(t){return this.#wn[4*t+1]/256}maxX(t){return(this.#wn[4*t+2]+1)/256}maxY(t){return(this.#wn[4*t+3]+1)/256}}const yi=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class xi{#yn={__proto__:null};#xn={__proto__:null,transform:[],moveText:[],sameLineText:[],[gi]:[]};#An=new Map;#Sn=[];#_n=[];#Cn=[[1,0,0,1,0,0]];#En=[-1/0,-1/0,1/0,1/0];#Pn=new Float64Array([1/0,1/0,-1/0,-1/0]);#Tn=-1;#Mn=new Set;#kn=new Map;#Dn=new Map;#In;#Ln;#Rn;#vn;#Nn;constructor(t,e,i=!1){this.#In=t.width,this.#Ln=t.height,this.#Fn(e),i&&(this.#Nn=new Map)}growOperationsCount(t){t>=this.#vn.length&&this.#Fn(t,this.#vn)}#Fn(t,e){const i=new ArrayBuffer(4*t);this.#Rn=new Uint8ClampedArray(i),this.#vn=new Uint32Array(i),e&&e.length>0?(this.#vn.set(e),this.#vn.fill(vi,e.length)):this.#vn.fill(vi)}save(t){return this.#yn={__proto__:this.#yn},this.#xn={__proto__:this.#xn,transform:{__proto__:this.#xn.transform},moveText:{__proto__:this.#xn.moveText},sameLineText:{__proto__:this.#xn.sameLineText},[gi]:{__proto__:this.#xn[gi]}},this.#En={__proto__:this.#En},this.#Sn.push(t),this}restore(t){const e=Object.getPrototypeOf(this.#yn);if(null===e)return this;this.#yn=e,this.#xn=Object.getPrototypeOf(this.#xn),this.#En=Object.getPrototypeOf(this.#En);const i=this.#Sn.pop();return void 0!==i&&(yi(this.#Nn,t)?.dependencies.add(i),this.#vn[t]=this.#vn[i]),this}recordOpenMarker(t){return this.#Sn.push(t),this}getOpenMarker(){return 0===this.#Sn.length?null:this.#Sn.at(-1)}recordCloseMarker(t){const e=this.#Sn.pop();return void 0!==e&&(yi(this.#Nn,t)?.dependencies.add(e),this.#vn[t]=this.#vn[e]),this}beginMarkedContent(t){return this.#_n.push(t),this}endMarkedContent(t){const e=this.#_n.pop();return void 0!==e&&(yi(this.#Nn,t)?.dependencies.add(e),this.#vn[t]=this.#vn[e]),this}pushBaseTransform(t){return this.#Cn.push(_t.multiplyByDOMMatrix(this.#Cn.at(-1),t.getTransform())),this}popBaseTransform(){return this.#Cn.length>1&&this.#Cn.pop(),this}recordSimpleData(t,e){return this.#yn[t]=e,this}recordIncrementalData(t,e){return this.#xn[t].push(e),this}resetIncrementalData(t,e){return this.#xn[t].length=0,this}recordNamedData(t,e){return this.#An.set(t,e),this}recordSimpleDataFromNamed(t,e,i){this.#yn[t]=this.#An.get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(gi,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in this.#yn&&this.recordFutureForcedDependency(e,this.#yn[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of this.#Mn)this.recordFutureForcedDependency(gi,t);return this}resetBBox(t){return this.#Tn!==t&&(this.#Tn=t,this.#Pn[0]=1/0,this.#Pn[1]=1/0,this.#Pn[2]=-1/0,this.#Pn[3]=-1/0),this}recordClipBox(t,e,i,n,s,r){const a=_t.multiplyByDOMMatrix(this.#Cn.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];_t.axialAlignedBoundingBox([i,s,n,r],a,o);const l=_t.intersect(this.#En,o);return l?(this.#En[0]=l[0],this.#En[1]=l[1],this.#En[2]=l[2],this.#En[3]=l[3]):(this.#En[0]=this.#En[1]=1/0,this.#En[2]=this.#En[3]=-1/0),this}recordBBox(t,e,i,n,s,r){const a=this.#En;if(a[0]===1/0)return this;const o=_t.multiplyByDOMMatrix(this.#Cn.at(-1),e.getTransform());if(a[0]===-1/0)return _t.axialAlignedBoundingBox([i,s,n,r],o,this.#Pn),this;const l=[1/0,1/0,-1/0,-1/0];return _t.axialAlignedBoundingBox([i,s,n,r],o,l),this.#Pn[0]=Math.min(this.#Pn[0],Math.max(l[0],a[0])),this.#Pn[1]=Math.min(this.#Pn[1],Math.max(l[1],a[1])),this.#Pn[2]=Math.max(this.#Pn[2],Math.min(l[2],a[2])),this.#Pn[3]=Math.max(this.#Pn[3],Math.min(l[3],a[3])),this}recordCharacterBBox(t,e,i,n=1,s=0,r=0,a){const o=i.bbox;let l,h;if(o&&(l=o[2]!==o[0]&&o[3]!==o[1]&&this.#Dn.get(i),!1!==l&&(h=[0,0,0,0],_t.axialAlignedBoundingBox(o,i.fontMatrix,h),1===n&&0===s&&0===r||_t.scaleMinMax([n,0,0,-n,s,r],h),l)))return this.recordBBox(t,e,h[0],h[2],h[1],h[3]);if(!a)return this.recordFullPageBBox(t);const d=a();return o&&h&&void 0===l&&(l=h[0]<=s-d.actualBoundingBoxLeft&&h[2]>=s+d.actualBoundingBoxRight&&h[1]<=r-d.actualBoundingBoxAscent&&h[3]>=r+d.actualBoundingBoxDescent,this.#Dn.set(i,l),l)?this.recordBBox(t,e,h[0],h[2],h[1],h[3]):this.recordBBox(t,e,s-d.actualBoundingBoxLeft,s+d.actualBoundingBoxRight,r-d.actualBoundingBoxAscent,r+d.actualBoundingBoxDescent)}recordFullPageBBox(t){return this.#Pn[0]=Math.max(0,this.#En[0]),this.#Pn[1]=Math.max(0,this.#En[1]),this.#Pn[2]=Math.min(this.#In,this.#En[2]),this.#Pn[3]=Math.min(this.#Ln,this.#En[3]),this}getSimpleIndex(t){return this.#yn[t]}recordDependencies(t,e){const i=this.#Mn,n=this.#yn,s=this.#xn;for(const t of e)t in this.#yn?i.add(n[t]):t in s&&s[t].forEach(i.add,i);return this}recordNamedDependency(t,e){return this.#An.has(e)&&this.#Mn.add(this.#An.get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[gi]),this.#Nn){const e=yi(this.#Nn,t),{dependencies:i}=e;this.#Mn.forEach(i.add,i),this.#Sn.forEach(i.add,i),this.#_n.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#Tn===t){const i=mi(256*this.#Pn[0]/this.#In),n=mi(256*this.#Pn[1]/this.#Ln),s=fi(256*this.#Pn[2]/this.#In),r=fi(256*this.#Pn[3]/this.#Ln);bi(this.#Rn,t,i,n,s,r);for(const e of this.#Mn)e!==t&&bi(this.#Rn,e,i,n,s,r);for(const e of this.#Sn)e!==t&&bi(this.#Rn,e,i,n,s,r);for(const e of this.#_n)e!==t&&bi(this.#Rn,e,i,n,s,r);e||(this.#Mn.clear(),this.#Tn=-1)}return this}recordShowTextOperation(t,e=!1){const i=Array.from(this.#Mn);this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const t of i)this.recordIncrementalData("sameLineText",t);return this}bboxToClipBoxDropOperation(t,e=!1){return this.#Tn===t&&(this.#Tn=-1,this.#En[0]=Math.max(this.#En[0],this.#Pn[0]),this.#En[1]=Math.max(this.#En[1],this.#Pn[1]),this.#En[2]=Math.min(this.#En[2],this.#Pn[2]),this.#En[3]=Math.min(this.#En[3],this.#Pn[3]),e||this.#Mn.clear()),this}_takePendingDependencies(){const t=this.#Mn;return this.#Mn=new Set,t}_extractOperation(t){const e=this.#kn.get(t);return this.#kn.delete(t),e}_pushPendingDependencies(t){for(const e of t)this.#Mn.add(e)}take(){return this.#Dn.clear(),new wi(this.#vn,this.#Rn)}takeDebugMetadata(){return this.#Nn}}class Ai{#Bn;#On;#jn;#Un=0;#Vn=0;constructor(t,e,i){if(t instanceof Ai&&t.#jn===!!i)return t;this.#Bn=t,this.#On=e,this.#jn=!!i}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#Vn++,this.#Bn.save(this.#On),this}restore(t){return this.#Vn>0&&(this.#Bn.restore(this.#On),this.#Vn--),this}recordOpenMarker(t){return this.#Un++,this}getOpenMarker(){return this.#Un>0?this.#On:this.#Bn.getOpenMarker()}recordCloseMarker(t){return this.#Un--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return this.#Bn.pushBaseTransform(t),this}popBaseTransform(){return this.#Bn.popBaseTransform(),this}recordSimpleData(t,e){return this.#Bn.recordSimpleData(t,this.#On),this}recordIncrementalData(t,e){return this.#Bn.recordIncrementalData(t,this.#On),this}resetIncrementalData(t,e){return this.#Bn.resetIncrementalData(t,this.#On),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return this.#Bn.recordSimpleDataFromNamed(t,e,this.#On),this}recordFutureForcedDependency(t,e){return this.#Bn.recordFutureForcedDependency(t,this.#On),this}inheritSimpleDataAsFutureForcedDependencies(t){return this.#Bn.inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return this.#Bn.inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return this.#jn||this.#Bn.resetBBox(this.#On),this}recordClipBox(t,e,i,n,s,r){return this.#jn||this.#Bn.recordClipBox(this.#On,e,i,n,s,r),this}recordBBox(t,e,i,n,s,r){return this.#jn||this.#Bn.recordBBox(this.#On,e,i,n,s,r),this}recordCharacterBBox(t,e,i,n,s,r,a){return this.#jn||this.#Bn.recordCharacterBBox(this.#On,e,i,n,s,r,a),this}recordFullPageBBox(t){return this.#jn||this.#Bn.recordFullPageBBox(this.#On),this}getSimpleIndex(t){return this.#Bn.getSimpleIndex(t)}recordDependencies(t,e){return this.#Bn.recordDependencies(this.#On,e),this}recordNamedDependency(t,e){return this.#Bn.recordNamedDependency(this.#On,e),this}recordOperation(t){return this.#Bn.recordOperation(this.#On,!0),this}recordShowTextOperation(t){return this.#Bn.recordShowTextOperation(this.#On,!0),this}bboxToClipBoxDropOperation(t){return this.#jn||this.#Bn.bboxToClipBoxDropOperation(this.#On,!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}}const Si=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],_i=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],Ci=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],Ei=["filter","fillColor","fillAlpha"],Pi=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],Ti=["transform"],Mi=["transform","fillColor"],ki="Fill",Di="Stroke",Ii="Shading";function Li(t,e){if(!e)return;const i=e[2]-e[0],n=e[3]-e[1],s=new Path2D;s.rect(e[0],e[1],i,n),t.clip(s)}class Ri{isModifyingCurrentTransform(){return!1}getPattern(){lt("Abstract method `getPattern` called.")}}class Ni extends Ri{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,n){let s;if(n===Di||n===ki){const r=e.current.getClippedPathBoundingBox(n,Xt(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=_t.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),Li(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),s=t.createPattern(l.canvas,"no-repeat");const d=new DOMMatrix(i);s.setTransform(d)}else Li(t,this._bbox),s=this._createGradient(t);return s}}function Fi(t,e,i,n,s,r,a,o){const l=e.coords,h=e.colors,d=t.data,c=4*t.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]+e.offsetX)*e.scaleX,g=(l[i+1]+e.offsetY)*e.scaleY,m=(l[n]+e.offsetX)*e.scaleX,f=(l[n+1]+e.offsetY)*e.scaleY,b=(l[s]+e.offsetX)*e.scaleX,v=(l[s+1]+e.offsetY)*e.scaleY;if(g>=v)return;const w=h[r],y=h[r+1],x=h[r+2],A=h[a],S=h[a+1],_=h[a+2],C=h[o],E=h[o+1],P=h[o+2],T=Math.round(g),M=Math.round(v);let k,D,I,L,R,N,F,B;for(let t=T;t<=M;t++){if(t<f){const e=t<g?0:(g-t)/(g-f);k=p-(p-m)*e,D=w-(w-A)*e,I=y-(y-S)*e,L=x-(x-_)*e}else{let e;e=t>v?1:f===v?0:(f-t)/(f-v),k=m-(m-b)*e,D=A-(A-C)*e,I=S-(S-E)*e,L=_-(_-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,B=x-(x-P)*e;const i=Math.round(Math.min(k,R)),n=Math.round(Math.max(k,R));let s=c*t+4*i;for(let t=i;t<=n;t++)e=(k-t)/(k-R),e<0?e=0:e>1&&(e=1),d[s++]=D-(D-N)*e|0,d[s++]=I-(I-F)*e|0,d[s++]=L-(L-B)*e|0,d[s++]=255}}function Bi(t,e,i){const n=e.coords,s=e.colors;let r,a;switch(e.type){case F:const o=e.verticesPerRow,l=Math.floor(n.length/o)-1,h=o-1;for(r=0;r<l;r++){let e=r*o;for(let r=0;r<h;r++,e++)Fi(t,i,n[e],n[e+1],n[e+o],s[e],s[e+1],s[e+o]),Fi(t,i,n[e+o+1],n[e+1],n[e+o],s[e+o+1],s[e+1],s[e+o])}break;case N:for(r=0,a=n.length;r<a;r+=3)Fi(t,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 Oi extends Ri{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,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*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:-n,offsetY:-s,scaleX:1/h,scaleY:1/d},u=o+4,p=l+4,g=i.getCanvas("mesh",u,p),m=g.context,f=m.createImageData(o,l);if(e){const t=f.data;for(let i=0,n=t.length;i<n;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)Bi(f,t,c);m.putImageData(f,2,2);return{canvas:g.canvas,offsetX:n-2*h,offsetY:s-2*d,scaleX:h,scaleY:d}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,n){Li(t,this._bbox);const s=new Float32Array(2);if(n===Ii)_t.singularValueDecompose2dScale(Xt(t),s);else if(this.matrix){_t.singularValueDecompose2dScale(this.matrix,s);const[t,i]=s;_t.singularValueDecompose2dScale(e.baseTransform,s),s[0]*=t,s[1]*=i}else _t.singularValueDecompose2dScale(e.baseTransform,s);const r=this._createMeshCanvas(s,n===Ii?null:this._background,e.cachedCanvases);return n!==Ii&&(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 ji extends Ri{getPattern(){return"hotpink"}}const Ui=1,Vi=2;class Hi{static MAX_PATTERN_SIZE=3e3;constructor(t,e,i,n){this.color=t[1],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.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t,e){const{bbox:i,operatorList:n,paintType:s,tilingType:r,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),at("TilingType: "+r);const d=i[0],c=i[1],u=i[2],p=i[3],g=u-d,m=p-c,f=new Float32Array(2);_t.singularValueDecompose2dScale(this.matrix,f);const[b,v]=f;_t.singularValueDecompose2dScale(this.baseTransform,f);const w=b*f[0],y=v*f[1];let x=g,A=m,S=!1,_=!1;const C=Math.ceil(l*w),E=Math.ceil(h*y);C>=Math.ceil(g*w)?x=l:S=!0,E>=Math.ceil(m*y)?A=h:_=!0;const P=this.getSizeAndScale(x,this.ctx.canvas.width,w),T=this.getSizeAndScale(A,this.ctx.canvas.height,y),M=t.cachedCanvases.getCanvas("pattern",P.size,T.size),k=M.context,D=o.createCanvasGraphics(k,e);if(D.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(D,s,a),k.translate(-P.scale*d,-T.scale*c),D.transform(0,P.scale,0,0,T.scale,0,0),k.save(),D.dependencyTracker?.save(),this.clipBbox(D,d,c,u,p),D.baseTransform=Xt(D.ctx),D.executeOperatorList(n),D.endDrawing(),D.dependencyTracker?.restore(),k.restore(),S||_){const e=M.canvas;S&&(x=l),_&&(A=h);const i=this.getSizeAndScale(x,this.ctx.canvas.width,w),n=this.getSizeAndScale(A,this.ctx.canvas.height,y),s=i.size,r=n.size,a=t.cachedCanvases.getCanvas("pattern-workaround",s,r),o=a.context,u=S?Math.floor(g/l):0,p=_?Math.floor(m/h):0;for(let t=0;t<=u;t++)for(let i=0;i<=p;i++)o.drawImage(e,s*t,r*i,s,r,0,0,s,r);return{canvas:a.canvas,scaleX:i.scale,scaleY:n.scale,offsetX:d,offsetY:c}}return{canvas:M.canvas,scaleX:P.scale,scaleY:T.scale,offsetX:d,offsetY:c}}getSizeAndScale(t,e,i){const n=Math.max(Hi.MAX_PATTERN_SIZE,e);let s=Math.ceil(t*i);return s>=n?s=n:i=s/t,{scale:i,size:s}}clipBbox(t,e,i,n,s){const r=n-e,a=s-i;t.ctx.rect(e,i,r,a),_t.axialAlignedBoundingBox([e,i,n,s],Xt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,s=t.current;switch(e){case Ui:const{fillStyle:t,strokeStyle:r}=this.ctx;n.fillStyle=s.fillColor=t,n.strokeStyle=s.strokeColor=r;break;case Vi:n.fillStyle=n.strokeStyle=i,s.fillColor=s.strokeColor=i;break;default:throw new vt(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,s){let r=i;n!==Ii&&(r=_t.transform(r,e.baseTransform),this.matrix&&(r=_t.transform(r,this.matrix)));const a=this.createPatternCanvas(e,s);let o=new DOMMatrix(r);o=o.translate(a.offsetX,a.offsetY),o=o.scale(1/a.scaleX,1/a.scaleY);const l=t.createPattern(a.canvas,"repeat");return l.setTransform(o),l}}function zi({src:t,srcPos:e=0,dest:i,width:n,height:s,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=At.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],d=n>>3,c=7&n,u=t.length;i=new Uint32Array(i.buffer);let p=0;for(let n=0;n<s;n++){for(const n=e+d;e<n;e++){const n=e<u?t[e]:255;i[p++]=128&n?h:l,i[p++]=64&n?h:l,i[p++]=32&n?h:l,i[p++]=16&n?h:l,i[p++]=8&n?h:l,i[p++]=4&n?h:l,i[p++]=2&n?h:l,i[p++]=1&n?h:l}if(0===c)continue;const n=e<u?t[e++]:255;for(let t=0;t<c;t++)i[p++]=n&1<<7-t?h:l}return{srcPos:e,destPos:p}}const $i=16,Wi=new DOMMatrix,Gi=new Float32Array(2),qi=new Float32Array([1/0,1/0,-1/0,-1/0]);class Xi{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let n;return void 0!==this.cache[t]?(n=this.cache[t],this.canvasFactory.reset(n,e,i)):(n=this.canvasFactory.create(e,i),this.cache[t]=n),n}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 Yi(t,e,i,n,s,r,a,o,l,h){const[d,c,u,p,g,m]=Xt(t);if(0===c&&0===u){const f=a*d+g,b=Math.round(f),v=o*p+m,w=Math.round(v),y=(a+l)*d+g,x=Math.abs(Math.round(y)-b)||1,A=(o+h)*p+m,S=Math.abs(Math.round(A)-w)||1;return t.setTransform(Math.sign(d),0,0,Math.sign(p),b,w),t.drawImage(e,i,n,s,r,0,0,x,S),t.setTransform(d,c,u,p,g,m),[x,S]}if(0===d&&0===p){const f=o*u+g,b=Math.round(f),v=a*c+m,w=Math.round(v),y=(o+h)*u+g,x=Math.abs(Math.round(y)-b)||1,A=(a+l)*c+m,S=Math.abs(Math.round(A)-w)||1;return t.setTransform(0,Math.sign(c),Math.sign(u),0,b,w),t.drawImage(e,i,n,s,r,0,0,S,x),t.setTransform(d,c,u,p,g,m),[S,x]}t.drawImage(e,i,n,s,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class Ki{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=x;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=B;textRise=0;fillColor="#000000";strokeColor="#000000";patternFill=!1;patternStroke=!1;fillAlpha=1;strokeAlpha=1;lineWidth=1;activeSMask=null;transferMaps="none";constructor(t,e,i){i?.(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=qi.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ki,e=null){const i=this.minMax.slice();if(t===Di){e||lt("Stroke bounding box must include transform."),_t.singularValueDecompose2dScale(e,Gi);const t=Gi[0]*this.lineWidth/2,n=Gi[1]*this.lineWidth/2;i[0]-=t,i[1]-=n,i[2]+=t,i[3]+=n}return i}updateClipFromPath(){const t=_t.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(qi,0)}getClippedPathBoundingBox(t=ki,e=null){return _t.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Qi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,n=e.width,s=i%$i,r=(i-s)/$i,a=0===s?r:r+1,o=t.createImageData(n,$i);let l,h=0;const d=e.data,c=o.data;let u,p,g,m;if(e.kind===z.GRAYSCALE_1BPP){const e=d.byteLength,i=new Uint32Array(c.buffer,0,c.byteLength>>2),m=i.length,f=n+7>>3,b=4294967295,v=At.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?$i:s,l=0,p=0;p<g;p++){const t=e-h;let s=0;const r=t>f?n:8*t-7,a=-8&r;let o=0,c=0;for(;s<a;s+=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(;s<r;s++)0===o&&(c=d[h++],o=128),i[l++]=c&o?b:v,o>>=1}for(;l<m;)i[l++]=0;t.putImageData(o,0,u*$i)}}else if(e.kind===z.RGBA_32BPP){for(p=0,m=n*$i*4,u=0;u<r;u++)c.set(d.subarray(h,h+m)),h+=m,t.putImageData(o,0,p),p+=$i;u<a&&(m=n*s*4,c.set(d.subarray(h,h+m)),t.putImageData(o,0,p))}else{if(e.kind!==z.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=$i,m=n*g,u=0;u<a;u++){for(u>=r&&(g=s,m=n*g),l=0,p=m;p--;)c[l++]=d[h++],c[l++]=d[h++],c[l++]=d[h++],c[l++]=255;t.putImageData(o,0,u*$i)}}}function Zi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,n=e.width,s=i%$i,r=(i-s)/$i,a=0===s?r:r+1,o=t.createImageData(n,$i);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?$i:s;({srcPos:l}=zi({src:h,srcPos:l,dest:d,width:n,height:i,nonBlackColor:0})),t.putImageData(o,0,e*$i)}}function Ji(t,e){const i=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const n of i)void 0!==t[n]&&(e[n]=t[n]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function tn(t){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 en(t,e){if(e)return!0;_t.singularValueDecompose2dScale(t,Gi);const i=Math.fround(Qt.pixelRatio*Rt.PDF_TO_CSS_UNITS);return Gi[0]<=i&&Gi[1]<=i}const nn=["butt","round","square"],sn=["miter","round","bevel"],rn={},an={};class on{constructor(t,e,i,n,s,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new Ki(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=n,this.filterFactory=s,this.groupStack=[],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 Xi(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,this.dependencyTracker=h??null}getObject(t,e,i=null){return"string"==typeof e?(this.dependencyTracker?.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const s=this.ctx.canvas.width,r=this.ctx.canvas.height,a=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,s,r),this.ctx.fillStyle=a,i){const t=this.cachedCanvases.getCanvas("transparent",s,r);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Xt(this.compositeCtx))}this.ctx.save(),tn(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=Xt(this.ctx)}executeOperatorList(t,e,i,n,s){const r=t.argsArray,a=t.fnArray;let o=e||0;const l=r.length;if(l===o)return o;const h=l-o>10&&"function"==typeof i,d=h?Date.now()+15:0;let c=0;const u=this.commonObjs,p=this.objs;let g,m;for(;;){if(void 0!==n&&o===n.nextBreakPoint)return n.breakIt(o,i),o;if(!s||s(o))if(g=a[o],m=r[o]??null,g!==Q.dependency)null===m?this[g](o):this[g](o,...m);else for(const t of m){this.dependencyTracker?.recordNamedData(t,o);const e=t.startsWith("g_")?u:p;if(!e.has(t))return e.get(t,i),o}if(o++,o===l)return o;if(h&&++c>10){if(Date.now()>d)return i(),o;c=0}}}#Hn(){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.#Hn(),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.#zn()}#zn(){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,n=t.height??t.displayHeight;let s,r,a=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,h=n,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),s=this.cachedCanvases.getCanvas(d,e,i),r=s.context,r.clearRect(0,0,e,i),r.drawImage(t,0,0,l,h,0,0,e,i),t=s.canvas,l=e,h=i,d="prescale1"===d?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t,e){const i=this.ctx,{width:n,height:s}=e,r=this.current.fillColor,a=this.current.patternFill,o=Xt(i);let l,h,d,c;if((e.bitmap||e.data)&&e.count>1){const i=e.bitmap||e.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),r]),l=this._cachedBitmapsMap.get(i),l||(l=new Map,this._cachedBitmapsMap.set(i,l));const n=l.get(h);if(n&&!a){const e=Math.round(Math.min(o[0],o[2])+o[4]),i=Math.round(Math.min(o[1],o[3])+o[5]);return this.dependencyTracker?.recordDependencies(t,Mi),{canvas:n,offsetX:e,offsetY:i}}d=n}d||(c=this.cachedCanvases.getCanvas("maskCanvas",n,s),Zi(c.context,e));let u=_t.transform(o,[1/n,0,0,-1/s,0,0]);u=_t.transform(u,[1,0,0,1,0,-s]);const p=qi.slice();_t.axialAlignedBoundingBox([0,0,n,s],u,p);const[g,m,f,b]=p,v=Math.round(f-g)||1,w=Math.round(b-m)||1,y=this.cachedCanvases.getCanvas("fillCanvas",v,w),x=y.context,A=g,S=m;x.translate(-A,-S),x.transform(...u),d||(d=this._scaleImage(c.canvas,Yt(x)),d=d.img,l&&a&&l.set(h,d)),x.imageSmoothingEnabled=en(Xt(x),e.interpolate),Yi(x,d,0,0,d.width,d.height,0,0,n,s),x.globalCompositeOperation="source-in";const _=_t.transform(Yt(x),[1,0,0,1,-A,-S]);return x.fillStyle=a?r.getPattern(i,this,_,ki,t):r,x.fillRect(0,0,n,s),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,y.canvas)),this.dependencyTracker?.recordDependencies(t,Mi),{canvas:y.canvas,offsetX:Math.round(A),offsetY:Math.round(S)}}setLineWidth(t,e){this.dependencyTracker?.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){this.dependencyTracker?.recordSimpleData("lineCap",t),this.ctx.lineCap=nn[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=sn[e]}setMiterLimit(t,e){this.dependencyTracker?.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){this.dependencyTracker?.recordSimpleData("dash",t);const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){for(const[i,n]of e)switch(i){case"LW":this.setLineWidth(t,n);break;case"LC":this.setLineCap(t,n);break;case"LJ":this.setLineJoin(t,n);break;case"ML":this.setMiterLimit(t,n);break;case"D":this.setDash(t,n[0],n[1]);break;case"RI":this.setRenderingIntent(t,n);break;case"FL":this.setFlatness(t,n);break;case"Font":this.setFont(t,n[0],n[1]);break;case"CA":this.dependencyTracker?.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=n;break;case"ca":this.dependencyTracker?.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=n;break;case"BM":this.dependencyTracker?.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=n;break;case"SMask":this.dependencyTracker?.recordSimpleData("SMask",t),this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.dependencyTracker?.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,s=this.cachedCanvases.getCanvas(n,e,i);this.suspendedCtx=this.ctx;const r=this.ctx=s.context;r.setTransform(this.suspendedCtx.getTransform()),Ji(this.suspendedCtx,r),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,n,s,r,a){e.transform(t,i,n,s,r,a),this.__originalTransform(t,i,n,s,r,a)},t.setTransform=function(t,i,n,s,r,a){e.setTransform(t,i,n,s,r,a),this.__originalSetTransform(t,i,n,s,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,n,s,r,a){e.bezierCurveTo(t,i,n,s,r,a),this.__originalBezierCurveTo(t,i,n,s,r,a)},t.rect=function(t,i,n,s){e.rect(t,i,n,s),this.__originalRect(t,i,n,s)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ji(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,n){const s=n[0],r=n[1],a=n[2]-s,o=n[3]-r;0!==a&&0!==o&&(this.genericComposeSMask(e.context,i,a,o,e.subtype,e.backdrop,e.transferMap,s,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,n,s,r,a,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(r)if(u<0||p<0||u+i>c.width||p+n>c.height){const t=this.cachedCanvases.getCanvas("maskExtension",i,n),e=t.context;e.drawImage(c,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=r,e.fillRect(0,0,i,n),e.globalCompositeOperation="source-over",c=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,i,n),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=r,t.fillRect(u,p,i,n),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===s&&a?e.filter=this.filterFactory.addAlphaFilter(a):"Luminosity"===s&&(e.filter=this.filterFactory.addLuminosityFilter(a));const g=new Path2D;g.rect(o,l,i,n),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(c,u,p,i,n,o,l,i,n),e.restore()}save(t){this.inSMaskMode&&Ji(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),this.dependencyTracker?.save(t)}restore(t){this.dependencyTracker?.restore(t),0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Ji(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}transform(t,e,i,n,s,r,a){this.dependencyTracker?.recordIncrementalData("transform",t),this.ctx.transform(e,i,n,s,r,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,n){let[s]=i;if(!n)return s||=i[0]=new Path2D,void this[e](t,s);if(null!==this.dependencyTracker){const i=e===Q.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-i,n[2]+i,n[1]-i,n[3]+i).recordDependencies(t,["transform"])}s instanceof Path2D||(s=i[0]=ae(s)),_t.axialAlignedBoundingBox(n,Xt(this.ctx),this.current.minMax),this[e](t,s),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){const n=this.ctx,s=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof s&&s?.getPattern){const i=s.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=s.getPattern(n,this,Yt(n),Di,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);this.dependencyTracker?.recordDependencies(t,Si),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Di,Xt(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){const n=this.ctx,s=this.current.fillColor;let r=!1;if(this.current.patternFill){const i=s.isModifyingCurrentTransform()?n.getTransform():null;if(this.dependencyTracker?.save(t),n.save(),n.fillStyle=s.getPattern(n,this,Yt(n),ki,t),i){const t=new Path2D;t.addPath(e,n.getTransform().invertSelf().multiplySelf(i)),e=t}r=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),this.dependencyTracker?.recordDependencies(t,_i),r&&(n.restore(),this.dependencyTracker?.restore(t)),i&&this.consumePath(t,e,a)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){this.ctx.fill(e),this.dependencyTracker?.recordDependencies(t,Ei).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=rn}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=an}beginText(t){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,this.dependencyTracker?.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;void 0!==e&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(void 0!==e){const t=new Path2D,n=i.getTransform().invertSelf();for(const{transform:i,x:s,y:r,fontSize:a,path:o}of e)o&&t.addPath(o,new DOMMatrix(i).preMultiplySelf(n).translate(s,r).scale(a,-a));i.clip(t)}delete this.pendingTextPaths}setCharSpacing(t,e){this.dependencyTracker?.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){this.dependencyTracker?.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){this.dependencyTracker?.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){this.dependencyTracker?.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){this.dependencyTracker?.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),s=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(s.fontMatrix=n.fontMatrix||x,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||ot("Invalid font matrix for font "+e),i<0?(i=-i,s.fontDirection=-1):s.fontDirection=1,this.current.font=n,this.current.fontSize=i,n.isType3Font)return;const r=n.loadedName||"sans-serif",a=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`;let o="normal";n.black?o="900":n.bold&&(o="bold");const l=n.italic?"italic":"normal";let h=i;i<16?h=16:i>100&&(h=100),this.current.fontSizeScale=i/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t,e){this.dependencyTracker?.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){this.dependencyTracker?.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){this.dependencyTracker?.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){this.dependencyTracker?.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){this.moveText(t,0,this.current.leading),this.dependencyTracker?.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}#$n(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n}paintChar(t,e,i,n,s,r){const a=this.ctx,o=this.current,l=o.font,h=o.textRenderingMode,d=o.fontSize/o.fontSizeScale,c=h&V,u=!!(h&H),p=o.patternFill&&!l.missingFile,g=o.patternStroke&&!l.missingFile;let m;if((l.disableFontFace||u||p||g)&&!l.missingFile&&(m=l.getPathGenerator(this.commonObjs,e)),m&&(l.disableFontFace||p||g)){let e;if(a.save(),a.translate(i,n),a.scale(d,-d),this.dependencyTracker?.recordCharacterBBox(t,a,l),c===B||c===j)if(s){e=a.getTransform(),a.setTransform(...s);const t=this.#$n(m,e,s);a.fill(t)}else a.fill(m);if(c===O||c===j)if(r){e||=a.getTransform(),a.setTransform(...r);const{a:t,b:i,c:n,d:s}=e,o=_t.inverseTransform(r),l=_t.transform([t,i,n,s,0,0],o);_t.singularValueDecompose2dScale(l,Gi),a.lineWidth*=Math.max(Gi[0],Gi[1])/d,a.stroke(this.#$n(m,e,r))}else a.lineWidth/=d,a.stroke(m);a.restore()}else c!==B&&c!==j||(a.fillText(e,i,n),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,n,()=>a.measureText(e))),c!==O&&c!==j||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,n,()=>a.measureText(e)).recordDependencies(t,Si),a.strokeText(e,i,n));if(u){(this.pendingTextPaths||=[]).push({transform:Xt(a),x:i,y:n,fontSize:d,path:m}),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,n)}}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 ut(this,"isFontSubpixelAAEnabled",i)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Pi).resetBBox(t),this.current.textRenderingMode&H&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,n=i.font;if(n.isType3Font)return this.showType3Text(t,e),void this.dependencyTracker?.recordShowTextOperation(t);const s=i.fontSize;if(0===s)return void this.dependencyTracker?.recordOperation(t);const r=this.ctx,a=i.fontSizeScale,o=i.charSpacing,l=i.wordSpacing,h=i.fontDirection,d=i.textHScale*h,c=e.length,u=n.vertical,p=u?1:-1,g=n.defaultVMetrics,m=s*i.fontMatrix[0],f=i.textRenderingMode===B&&!n.disableFontFace&&!i.patternFill;let b,v;if(r.save(),i.textMatrix&&r.transform(...i.textMatrix),r.translate(i.x,i.y+i.textRise),h>0?r.scale(d,-1):r.scale(d,1),i.patternFill){r.save();const e=i.fillColor.getPattern(r,this,Yt(r),ki,t);b=Xt(r),r.restore(),r.fillStyle=e}if(i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,Yt(r),Di,t);v=Xt(r),r.restore(),r.strokeStyle=e}let w=i.lineWidth;const y=i.textMatrixScale;if(0===y||0===w){const t=i.textRenderingMode&V;t!==O&&t!==j||(w=this.getSinglePixelWidth())}else w/=y;if(1!==a&&(r.scale(a,a),w/=a),r.lineWidth=w,n.isInvalidPDFjsFont){const n=[];let s=0;for(const t of e)n.push(t.unicode),s+=t.width;const a=n.join("");if(r.fillText(a,0,0),null!==this.dependencyTracker){const e=r.measureText(a);this.dependencyTracker.recordBBox(t,this.ctx,-e.actualBoundingBoxLeft,e.actualBoundingBoxRight,-e.actualBoundingBoxAscent,e.actualBoundingBoxDescent).recordShowTextOperation(t)}return i.x+=s*m*d,r.restore(),void this.compose()}let x,A=0;for(x=0;x<c;++x){const i=e[x];if("number"==typeof i){A+=p*i*s/1e3;continue}let d=!1;const c=(i.isSpace?l:0)+o,w=i.fontChar,y=i.accent;let S,_,C,E=i.width;if(u){const t=i.vmetric||g,e=-(i.vmetric?t[1]:.5*E)*m,n=t[2]*m;E=t?-t[0]:E,S=e/a,_=(A+n)/a}else S=A/a,_=0;if(n.remeasure&&E>0){C=r.measureText(w);const t=1e3*C.width/s*a;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;d=!0,r.save(),r.scale(e,1),S/=e}else E!==t&&(S+=(E-t)/2e3*s/a)}if(this.contentVisible&&(i.isInFont||n.missingFile))if(f&&!y)r.fillText(w,S,_),this.dependencyTracker?.recordCharacterBBox(t,r,C?{bbox:null}:n,s/a,S,_,()=>C??r.measureText(w));else if(this.paintChar(t,w,S,_,b,v),y){const e=S+s*y.offset.x/a,i=_-s*y.offset.y/a;this.paintChar(t,y.fontChar,e,i,b,v)}A+=u?E*m-c*h:E*m+c*h,d&&r.restore()}u?i.y-=A:i.x+=A*d,r.restore(),this.compose(),this.dependencyTracker?.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,n=this.current,s=n.font,r=n.fontSize,a=n.fontDirection,o=s.vertical?1:-1,l=n.charSpacing,h=n.wordSpacing,d=n.textHScale*a,c=n.fontMatrix||x,u=e.length;let p,g,m,f;if(n.textRenderingMode===U||0===r)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),n.textMatrix&&i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),i.scale(d,a);const b=this.dependencyTracker;for(this.dependencyTracker=b?new Ai(b,t):null,p=0;p<u;++p){if(g=e[p],"number"==typeof g){f=o*g*r/1e3,this.ctx.translate(f,0),n.x+=f*d;continue}const t=(g.isSpace?h:0)+l,a=s.charProcOperatorList[g.operatorListId];a?this.contentVisible&&(this.save(),i.scale(r,r),i.transform(...c),this.executeOperatorList(a),this.restore()):ot(`Type3 character "${g.operatorListId}" is not available.`);const u=[g.width,0];_t.applyTransform(u,c),m=u[0]*r+t,i.translate(m,0),n.x+=m*d}i.restore(),b&&(this.dependencyTracker=b)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,n,s,r,a){const o=new Path2D;o.rect(n,s,r-n,a-s),this.ctx.clip(o),this.dependencyTracker?.recordBBox(t,this.ctx,n,r,s,a).recordClipBox(t,this.ctx,n,r,s,a),this.endPath(t)}getColorN_Pattern(t,e){let i;if("TilingPattern"===e[0]){const t=this.baseTransform||Xt(this.ctx),n={createCanvasGraphics:(t,e)=>new on(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Ai(this.dependencyTracker,e,!0):null)};i=new Hi(e,this.ctx,n,t)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){this.dependencyTracker?.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){this.dependencyTracker?.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(t){switch(t[0]){case"RadialAxial":return new Ni(t);case"Mesh":return new Oi(t);case"Dummy":return new ji}throw new Error(`Unknown IR type: ${t[0]}`)}(this.getObject(t,e)),this.cachedPatterns.set(e,n)),i&&(n.matrix=i),n}shadingFill(t,e){if(!this.contentVisible)return;const i=this.ctx;this.save(t);const n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,Yt(i),Ii,t);const s=Yt(i);if(s){const{width:t,height:e}=i.canvas,n=qi.slice();_t.axialAlignedBoundingBox([0,0,t,e],s,n);const[r,a,o,l]=n;this.ctx.fillRect(r,a,o-r,l-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.dependencyTracker?.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Ti).recordDependencies(t,_i).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){lt("Should not call beginInlineImage")}beginImageData(){lt("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=Xt(this.ctx),i)){_t.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[e,n,s,r]=i,a=new Path2D;a.rect(e,n,s-e,r-n),this.ctx.clip(a),this.dependencyTracker?.recordClipBox(t,this.ctx,e,s,n,r),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;e.isolated||at("TODO: Support non-isolated groups."),e.knockout&&ot("Knockout groups not supported.");const n=Xt(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=qi.slice();_t.axialAlignedBoundingBox(e.bbox,Xt(i),s);const r=[0,0,i.canvas.width,i.canvas.height];s=_t.intersect(s,r)||[0,0,0,0];const a=Math.floor(s[0]),o=Math.floor(s[1]),l=Math.max(Math.ceil(s[2])-a,1),h=Math.max(Math.ceil(s[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(d,l,h),u=c.context;u.translate(-a,-o),u.transform(...n);let p=new Path2D;const[g,m,f,b]=e.bbox;if(p.rect(g,m,f-g,b-m),e.matrix){const t=new Path2D;t.addPath(p,new DOMMatrix(e.matrix)),p=t}u.clip(p),e.smask&&this.smaskStack.push({canvas:c.canvas,context:u,offsetX:a,offsetY:o,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),e.smask&&!this.dependencyTracker||(i.setTransform(1,0,0,1,0,0),i.translate(a,o),i.save()),Ji(i,u),this.ctx=u,this.dependencyTracker?.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,this.dependencyTracker?.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const e=Xt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const n=qi.slice();_t.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],e,n),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,i,n,s,r){if(this.#Hn(),tn(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const s=i[2]-i[0],a=i[3]-i[1];if(r&&this.annotationCanvasMap){(n=n.slice())[4]-=i[0],n[5]-=i[1],(i=i.slice())[0]=i[1]=0,i[2]=s,i[3]=a,_t.singularValueDecompose2dScale(Xt(this.ctx),Gi);const{viewportScale:t}=this,r=Math.ceil(s*this.outputScaleX*t),o=Math.ceil(a*this.outputScaleY*t);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Gi[0],0,0,-Gi[1],0,a*Gi[1]),tn(this.ctx)}else{tn(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],s,a),this.ctx.clip(e)}}this.current=new Ki(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...n),this.transform(t,...s)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),this.#zn(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){if(!this.contentVisible)return;const i=e.count;(e=this.getObject(t,e.data,e)).count=i;const n=this.ctx,s=this._createMaskCanvas(t,e),r=s.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(r,s.offsetX,s.offsetY),this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,s.offsetX,s.offsetX+r.width,s.offsetY,s.offsetY+r.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,n=0,s=0,r,a){if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const o=this.ctx;o.save();const l=Xt(o);o.transform(i,n,s,r,0,0);const h=this._createMaskCanvas(t,e);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]),this.dependencyTracker?.resetBBox(t);for(let e=0,d=a.length;e<d;e+=2){const d=_t.transform(l,[i,n,s,r,a[e],a[e+1]]);o.drawImage(h.canvas,d[4],d[5]),this.dependencyTracker?.recordBBox(t,this.ctx,d[4],d[4]+h.canvas.width,d[5],d[5]+h.canvas.height)}o.restore(),this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageMaskXObjectGroup(t,e){if(!this.contentVisible)return;const i=this.ctx,n=this.current.fillColor,s=this.current.patternFill;this.dependencyTracker?.resetBBox(t).recordDependencies(t,Mi);for(const r of e){const{data:e,width:a,height:o,transform:l}=r,h=this.cachedCanvases.getCanvas("maskCanvas",a,o),d=h.context;d.save();Zi(d,this.getObject(t,e,r)),d.globalCompositeOperation="source-in",d.fillStyle=s?n.getPattern(d,this,Yt(i),ki,t):n,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),Yi(i,h.canvas,0,0,a,o,0,-1,1,1),this.dependencyTracker?.recordBBox(t,i,0,a,0,o),i.restore()}this.compose(),this.dependencyTracker?.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);i?this.paintInlineImageXObject(t,i):ot("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,n,s){if(!this.contentVisible)return;const r=this.getObject(t,e);if(!r)return void ot("Dependent image isn't ready yet");const a=r.width,o=r.height,l=[];for(let t=0,e=s.length;t<e;t+=2)l.push({transform:[i,0,0,n,s[t],s[t+1]],x:0,y:0,w:a,h:o});this.paintInlineImageXObjectGroup(t,r,l)}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:n}=t,s=this.cachedCanvases.getCanvas("inlineImage",i,n),r=s.context;return r.filter=this.current.transferMaps,r.drawImage(e,0,0),r.filter="none",s.canvas}paintInlineImageXObject(t,e){if(!this.contentVisible)return;const i=e.width,n=e.height,s=this.ctx;this.save(t);const{filter:r}=s;let a;if("none"!==r&&""!==r&&(s.filter="none"),s.scale(1/i,-1/n),e.bitmap)a=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)a=e;else{const t=this.cachedCanvases.getCanvas("inlineImage",i,n).context;Qi(t,e),a=this.applyTransferMapsToCanvas(t)}const o=this._scaleImage(a,Yt(s));s.imageSmoothingEnabled=en(Xt(s),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,s,0,i,-n,0).recordDependencies(t,Ci).recordOperation(t),Yi(s,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,i,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){if(!this.contentVisible)return;const n=this.ctx;let s;if(e.bitmap)s=e.bitmap;else{const t=e.width,i=e.height,n=this.cachedCanvases.getCanvas("inlineImage",t,i).context;Qi(n,e),s=this.applyTransferMapsToCanvas(n)}this.dependencyTracker?.resetBBox(t);for(const e of i)n.save(),n.transform(...e.transform),n.scale(1,-1),Yi(n,s,e.x,e.y,e.w,e.h,0,-1,1,1),this.dependencyTracker?.recordBBox(t,n,0,1,-1,0),n.restore();this.dependencyTracker?.recordOperation(t),this.compose()}paintSolidColorImageMask(t){this.contentVisible&&(this.dependencyTracker?.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,_i).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){this.dependencyTracker?.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){this.dependencyTracker?.beginMarkedContent(t),"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){this.dependencyTracker?.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const s=this.ctx;this.pendingClip?(n||(this.pendingClip===an?s.clip(e,"evenodd"):s.clip(e)),this.pendingClip=null,this.dependencyTracker?.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):this.dependencyTracker?.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Xt(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]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:s}=this.ctx.getTransform();let r,a;if(0===i&&0===n){const i=Math.abs(e),n=Math.abs(s);if(i===n)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/n;else{const e=i*t,s=n*t;r=e<1?1/e:1,a=s<1?1/s:1}}else{const o=Math.abs(e*s-i*n),l=Math.hypot(e,i),h=Math.hypot(n,s);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,e){const{ctx:i,current:{lineWidth:n}}=this,[s,r]=this.getScaleForStroking();if(s===r)return i.lineWidth=(n||1)*s,void i.stroke(t);const a=i.getLineDash();e&&i.save(),i.scale(s,r),Wi.a=1/s,Wi.d=1/r;const o=new Path2D;if(o.addPath(t,Wi),a.length>0){const t=Math.max(s,r);i.setLineDash(a.map(e=>e/t)),i.lineDashOffset/=t}i.lineWidth=n||1,i.stroke(o),e&&i.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 Q)void 0!==on.prototype[t]&&(on.prototype[Q[t]]=on.prototype[t]);let ln=class{static#Wn=null;static#Gn="";static get workerPort(){return this.#Wn}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");this.#Wn=t}static get workerSrc(){return this.#Gn}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");this.#Gn=t}};class hn{#qn;#Xn;constructor({parsedData:t,rawData:e}){this.#qn=t,this.#Xn=e}getRaw(){return this.#Xn}get(t){return this.#qn.get(t)??null}[Symbol.iterator](){return this.#qn.entries()}}const dn=Symbol("INTERNAL");class cn{#Yn=!1;#Kn=!1;#Qn=!1;#Zn=!0;constructor(t,{name:e,intent:i,usage:n,rbGroups:s}){this.#Yn=!!(t&_),this.#Kn=!!(t&C),this.name=e,this.intent=i,this.usage=n,this.rbGroups=s}get visible(){if(this.#Qn)return this.#Zn;if(!this.#Zn)return!1;const{print:t,view:e}=this.usage;return this.#Yn?"OFF"!==e?.viewState:!this.#Kn||"OFF"!==t?.printState}_setVisible(t,e,i=!1){t!==dn&&lt("Internal method `_setVisible` called."),this.#Qn=i,this.#Zn=e}}class un{#Jn=null;#ts=new Map;#es=null;#is=null;constructor(t,e=_){if(this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,this.#is=t.order;for(const i of t.groups)this.#ts.set(i.id,new cn(e,i));if("OFF"===t.baseState)for(const t of this.#ts.values())t._setVisible(dn,!1);for(const e of t.on)this.#ts.get(e)._setVisible(dn,!0);for(const e of t.off)this.#ts.get(e)._setVisible(dn,!1);this.#es=this.getHash()}}#ns(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const e=t[n];let s;if(Array.isArray(e))s=this.#ns(e);else{if(!this.#ts.has(e))return ot(`Optional content group not found: ${e}`),!0;s=this.#ts.get(e).visible}switch(i){case"And":if(!s)return!1;break;case"Or":if(s)return!0;break;case"Not":return!s;default:return!0}}return"And"===i}isVisible(t){if(0===this.#ts.size)return!0;if(!t)return at("Optional content group not defined."),!0;if("OCG"===t.type)return this.#ts.has(t.id)?this.#ts.get(t.id).visible:(ot(`Optional content group not found: ${t.id}`),!0);if("OCMD"===t.type){if(t.expression)return this.#ns(t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!this.#ts.has(e))return ot(`Optional content group not found: ${e}`),!0;if(this.#ts.get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!this.#ts.has(e))return ot(`Optional content group not found: ${e}`),!0;if(!this.#ts.get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!this.#ts.has(e))return ot(`Optional content group not found: ${e}`),!0;if(!this.#ts.get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!this.#ts.has(e))return ot(`Optional content group not found: ${e}`),!0;if(this.#ts.get(e).visible)return!1}return!0}return ot(`Unknown optional content policy ${t.policy}.`),!0}return ot(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){const n=this.#ts.get(t);if(n){if(i&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const i of e)i!==t&&this.#ts.get(i)?._setVisible(dn,!1,!0);n._setVisible(dn,!!e,!0),this.#Jn=null}else ot(`Optional content group not found: ${t}`)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const t=this.#ts.get(n);if(t)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!t.visible,e)}}this.#Jn=null}get hasInitialVisibility(){return null===this.#es||this.getHash()===this.#es}getOrder(){return this.#ts.size?this.#is?this.#is.slice():[...this.#ts.keys()]:null}getGroup(t){return this.#ts.get(t)||null}getHash(){if(null!==this.#Jn)return this.#Jn;const t=new Ce;for(const[e,i]of this.#ts)t.update(`${e}:${i.visible}`);return this.#Jn=t.hexdigest()}[Symbol.iterator](){return this.#ts.entries()}}class pn{constructor(t,{disableRange:e=!1,disableStream:i=!1}){ht(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:s,progressiveDone:r,contentDispositionFilename:a}=t;if(this._queuedChunks=[],this._progressiveDone=r,this._contentDispositionFilename=a,s?.length>0){const t=s instanceof Uint8Array&&s.byteLength===s.buffer.byteLength?s.buffer:new Uint8Array(s).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=n,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{ht(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(){ht(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new gn(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new mn(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 gn{constructor(t,e,i=!1,n=null){this._stream=t,this._done=i||!1,this._filename=jt(n)?n:null,this._queuedChunks=e||[],this._loaded=0;for(const t of this._queuedChunks)this._loaded+=t.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=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 mn{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 fn(t,e){const i=new Headers;if(!t||!e||"object"!=typeof e)return i;for(const t in e){const n=e[t];void 0!==n&&i.append(t,n)}return i}function bn(t){return URL.parse(t)?.origin??null}function vn({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:n}){const s={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(r))return s;if(s.suggestedLength=r,r<=2*i)return s;if(n||!e)return s;if("bytes"!==t.get("Accept-Ranges"))return s;return"identity"!==(t.get("Content-Encoding")||"identity")||(s.allowRangeRequests=!0),s}function wn(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,i=n("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 s=n("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(i=s.exec(t));){let[,t,n,s]=i;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[n,s]}const r=[];for(let t=0;t<e.length&&t in e;++t){let[i,n]=e[t];n=a(n),i&&(n=unescape(n),0===t&&(n=o(n))),r.push(n)}return r.join("")}(t),i)return r(l(i));if(i=n("filename","i").exec(t),i){i=i[1];let t=a(i);return t=l(t),r(t)}function n(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function s(t,i){if(t){if(!/^[\x00-\xFF]+$/.test(i))return i;try{const n=new TextDecoder(t,{fatal:!0}),s=xt(i);i=n.decode(s),e=!1}catch{}}return i}function r(t){return e&&/[\x80-\xff]/.test(t)&&(t=s("utf-8",t),e&&(t=s("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:s(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,n){if("q"===i||"Q"===i)return s(e,n=(n=n.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{n=atob(n)}catch{}return s(e,n)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(jt(t))return t}return null}function yn(t,e){return new bt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function xn(t){return 200===t||206===t}function An(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Sn(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(ot(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class _n{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=fn(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ht(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Cn(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new En(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 Cn{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),n=e.url;fetch(n,An(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=bn(e.url),!xn(e.status))throw yn(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:s,suggestedLength:r}=vn({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=r||this._contentLength,this._filename=wn(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new wt("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:Sn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class En{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;const s=new Headers(t.headers);s.append("Range",`bytes=${e}-${i-1}`);const r=n.url;fetch(r,An(s,this._withCredentials,this._abortController)).then(e=>{const i=bn(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!xn(e.status))throw yn(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:Sn(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Pn{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=fn(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,n=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}`),n.expectedStatus=206):n.expectedStatus=200,e.responseType="arraybuffer",ht(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.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 n=i.xhr;if(n.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),4!==n.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===n.status&&this.isHttp)return void i.onError(n.status);const s=n.status||200;if(!(200===s&&206===i.expectedStatus)&&s!==i.expectedStatus)return void i.onError(n.status);const r=function(t){const e=t.response;return"string"!=typeof e?e:xt(e).buffer}(n);if(206===s){const t=n.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?i.onDone({begin:parseInt(e[1],10),chunk:r}):(ot('Missing or invalid "Content-Range" header.'),i.onError(0))}else r?i.onDone({begin:0,chunk:r}):i.onError(n.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 Tn{constructor(t){this._source=t,this._manager=new Pn(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 ht(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Mn(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new kn(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 Mn{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),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=bn(e.responseURL);const i=e.getAllResponseHeaders(),n=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...i]=t.split(": ");return[e,i.join(": ")]}):[]),{allowRangeRequests:s,suggestedLength:r}=vn({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=wn(n),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=yn(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 kn{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const t=bn(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??=yn(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 Dn=/^[a-z][a-z0-9\-+.]+:/i;class In{constructor(t){this.source=t,this.url=function(t){if(Dn.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),ht("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return ht(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Ln(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Rn(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 Ln{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=yn(0,this._url.href)),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 wt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Rn{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 n=t.source;this._isStreamingSupported=!n.disableStream;const s=process.getBuiltinModule("fs");this._setReadableStream(s.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 Nn=Symbol("INITIAL_DATA");class Fn{#ss=Object.create(null);#rs(t){return this.#ss[t]||={...Promise.withResolvers(),data:Nn}}get(t,e=null){if(e){const i=this.#rs(t);return i.promise.then(()=>e(i.data)),null}const i=this.#ss[t];if(!i||i.data===Nn)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=this.#ss[t];return!!e&&e.data!==Nn}delete(t){const e=this.#ss[t];return!(!e||e.data===Nn)&&(delete this.#ss[t],!0)}resolve(t,e=null){const i=this.#rs(t);i.data=e,i.resolve()}clear(){for(const t in this.#ss){const{data:e}=this.#ss[t];e?.bitmap?.close()}this.#ss=Object.create(null)}*[Symbol.iterator](){for(const t in this.#ss){const{data:e}=this.#ss[t];e!==Nn&&(yield[t,e])}}}let Bn=class t{#as=Promise.withResolvers();#Ct=null;#os=!1;#ls=!!globalThis.FontInspector?.enabled;#hs=null;#ds=null;#cs=0;#us=0;#ps=null;#gs=null;#ms=0;#fs=0;#bs=Object.create(null);#vs=[];#ws=null;#ys=[];#xs=new WeakMap;#As=null;static#Ss=new Map;static#_s=new Map;static#Cs=new WeakMap;static#Es=null;static#Ps=new Set;constructor({textContentSource:e,container:i,viewport:n}){if(e instanceof ReadableStream)this.#ws=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#ws=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#Ct=this.#gs=i,this.#fs=n.scale*Qt.pixelRatio,this.#ms=n.rotation,this.#ds={div:null,properties:null,ctx:null};const{pageWidth:s,pageHeight:r,pageX:a,pageY:o}=n.rawDims;this.#As=[1,0,0,-1,-a,o+r],this.#us=s,this.#cs=r,t.#Ts(),Kt(i,n),this.#as.promise.finally(()=>{t.#Ps.delete(this),this.#ds=null,this.#bs=null}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=At.platform;return ut(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#ps.read().then(({value:t,done:i})=>{i?this.#as.resolve():(this.#hs??=t.lang,Object.assign(this.#bs,t.styles),this.#Ms(t.items),e())},this.#as.reject)};return this.#ps=this.#ws.getReader(),t.#Ps.add(this),e(),this.#as.promise}update({viewport:e,onBefore:i=null}){const n=e.scale*Qt.pixelRatio,s=e.rotation;if(s!==this.#ms&&(i?.(),this.#ms=s,Kt(this.#gs,{rotation:s})),n!==this.#fs){i?.(),this.#fs=n;const e={div:null,properties:null,ctx:t.#ks(this.#hs)};for(const t of this.#ys)e.properties=this.#xs.get(t),e.div=t,this.#Ds(e)}}cancel(){const t=new wt("TextLayer task cancelled.");this.#ps?.cancel(t).catch(()=>{}),this.#ps=null,this.#as.reject(t)}get textDivs(){return this.#ys}get textContentItemsStr(){return this.#vs}#Ms(e){if(this.#os)return;this.#ds.ctx??=t.#ks(this.#hs);const i=this.#ys,n=this.#vs;for(const t of e){if(i.length>1e5)return ot("Ignoring additional textDivs for performance reasons."),void(this.#os=!0);if(void 0!==t.str)n.push(t.str),this.#Is(t);else if("beginMarkedContentProps"===t.type||"beginMarkedContent"===t.type){const e=this.#Ct;this.#Ct=document.createElement("span"),this.#Ct.classList.add("markedContent"),t.id&&this.#Ct.setAttribute("id",`${t.id}`),e.append(this.#Ct)}else"endMarkedContent"===t.type&&(this.#Ct=this.#Ct.parentNode)}}#Is(e){const i=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#ys.push(i);const s=_t.transform(this.#As,e.transform);let r=Math.atan2(s[1],s[0]);const a=this.#bs[e.fontName];a.vertical&&(r+=Math.PI/2);let o=this.#ls&&a.fontSubstitution||a.fontFamily;o=t.fontFamilyMap.get(o)||o;const l=Math.hypot(s[2],s[3]),h=l*t.#Ls(o,a,this.#hs);let d,c;0===r?(d=s[4],c=s[5]-h):(d=s[4]+h*Math.sin(r),c=s[5]-h*Math.cos(r));const u="calc(var(--total-scale-factor) *",p=i.style;this.#Ct===this.#gs?(p.left=`${(100*d/this.#us).toFixed(2)}%`,p.top=`${(100*c/this.#cs).toFixed(2)}%`):(p.left=`${u}${d.toFixed(2)}px)`,p.top=`${u}${c.toFixed(2)}px)`),p.fontSize=`${u}${(t.#Es*l).toFixed(2)}px)`,p.fontFamily=o,n.fontSize=l,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#ls&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==r&&(n.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&&(n.canvasWidth=a.vertical?e.height:e.width),this.#xs.set(i,n),this.#ds.div=i,this.#ds.properties=n,this.#Ds(this.#ds),n.hasText&&this.#Ct.append(i),n.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),this.#Ct.append(t)}}#Ds(e){const{div:i,properties:n,ctx:s}=e,{style:r}=i;let a="";if(t.#Es>1&&(a=`scale(${1/t.#Es})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=r,{canvasWidth:o,fontSize:l}=n;t.#Rs(s,l*this.#fs,e);const{width:h}=s.measureText(i.textContent);h>0&&(a=`scaleX(${o*this.#fs/h}) ${a}`)}0!==n.angle&&(a=`rotate(${n.angle}deg) ${a}`),a.length>0&&(r.transform=a)}static cleanup(){if(!(this.#Ps.size>0)){this.#Ss.clear();for(const{canvas:t}of this.#_s.values())t.remove();this.#_s.clear()}}static#ks(t=null){let e=this.#_s.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.#_s.set(t,e),this.#Cs.set(e,{size:0,family:""})}return e}static#Rs(t,e,i){const n=this.#Cs.get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)}static#Ts(){if(null!==this.#Es)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.#Es=t.getBoundingClientRect().height,t.remove()}static#Ls(t,e,i){const n=this.#Ss.get(t);if(n)return n;const s=this.#ks(i);s.canvas.width=s.canvas.height=30,this.#Rs(s,30,t);const r=s.measureText(""),a=r.fontBoundingBoxAscent,o=Math.abs(r.fontBoundingBoxDescent);s.canvas.width=s.canvas.height=0;let l=.8;return a?l=a/(a+o):(At.platform.isFirefox&&ot("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?l=e.ascent:e.descent&&(l=1+e.descent)),this.#Ss.set(t,l),l}};function On(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new jn,{docId:i}=e,n=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(y)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,s=t.data?function(t){if(y&&"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 xt(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 Un?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let d=t.worker instanceof zn?t.worker:null;const c=t.verbosity,u="string"!=typeof t.docBaseUrl||Ot(t.docBaseUrl)?null:t.docBaseUrl,p=Ne(t.cMapUrl),g=!1!==t.cMapPacked,m=t.CMapReaderFactory||(y?ci:ei),f=Ne(t.iccUrl),b=Ne(t.standardFontDataUrl),v=t.StandardFontDataFactory||(y?ui:ri),w=Ne(t.wasmUrl),x=t.WasmFactory||(y?pi:oi),A=!0!==t.stopAtErrors,S=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,_=!1!==t.isEvalSupported,C="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!y,E="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!y&&(At.platform.isFirefox||!globalThis.chrome),P=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:y,M=!0===t.fontExtraProperties,k=!0===t.enableXfa,D=t.ownerDocument||globalThis.document,I=!0===t.disableRange,L=!0===t.disableStream,R=!0===t.disableAutoFetch,N=!0===t.pdfBug,F=t.CanvasFactory||(y?di:Je),B=t.FilterFactory||(y?hi:ni),O=!0===t.enableHWA,j=!1!==t.useWasm,U=l?l.length:t.length??NaN,V="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!y&&!T,H="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(m===ei&&v===ri&&x===oi&&p&&b&&w&&Ht(p,document.baseURI)&&Ht(b,document.baseURI)&&Ht(w,document.baseURI));st(c);const z={canvasFactory:new F({ownerDocument:D,enableHWA:O}),filterFactory:new B({docId:i,ownerDocument:D}),cMapReaderFactory:H?null:new m({baseUrl:p,isCompressed:g}),standardFontDataFactory:H?null:new v({baseUrl:b}),wasmFactory:H?null:new x({baseUrl:w})};d||(d=zn.create({verbosity:c,port:ln.workerPort}),e._worker=d);const $={docId:i,apiVersion:"5.4.394",data:s,password:o,disableAutoFetch:R,rangeChunkSize:h,length:U,docBaseUrl:u,enableXfa:k,evaluatorOptions:{maxImageSize:S,disableFontFace:T,ignoreErrors:A,isEvalSupported:_,isOffscreenCanvasSupported:C,isImageDecoderSupported:E,canvasMaxAreaInBytes:P,fontExtraProperties:M,useSystemFonts:V,useWasm:j,useWorkerFetch:H,cMapUrl:p,iccUrl:f,standardFontDataUrl:b,wasmUrl:w}},W={ownerDocument:D,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:k}};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",$,s?[s.buffer]:null);let o;if(l)o=new pn(l,{disableRange:I,disableStream:L});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");const t=Ht(n)?_n:y?In:Tn;o=new t({url:n,length:U,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:I,disableStream:L})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const n=new Qe(i,t,d.port),s=new $n(n,e,o,W,z,O);e._transport=s,n.send("Ready",null)})}).catch(e._capability.reject),e}class jn{static#sn=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+jn.#sn++;destroyed=!1;onPassword=null;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}async getData(){return this._transport.getData()}}let Un=class{#as=Promise.withResolvers();#Ns=[];#Fs=[];#Bs=[];#Os=[];constructor(t,e,i=!1,n=null){this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n}addRangeListener(t){this.#Os.push(t)}addProgressListener(t){this.#Bs.push(t)}addProgressiveReadListener(t){this.#Fs.push(t)}addProgressiveDoneListener(t){this.#Ns.push(t)}onDataRange(t,e){for(const i of this.#Os)i(t,e)}onDataProgress(t,e){this.#as.promise.then(()=>{for(const i of this.#Bs)i(t,e)})}onDataProgressiveRead(t){this.#as.promise.then(()=>{for(const e of this.#Fs)e(t)})}onDataProgressiveDone(){this.#as.promise.then(()=>{for(const t of this.#Ns)t()})}transportReady(){this.#as.resolve()}requestDataRange(t,e){lt("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Vn{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 ut(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()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}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 Hn{#js=!1;constructor(t,e,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new Vt:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new Fn,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}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:n=0,dontFlip:s=!1}={}){return new Ft({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:s})}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 ut(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:n="display",annotationMode:s=D.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:c=!1,recordOperations:u=!1,operationsFilter:p=null}){this._stats?.time("Overall");const g=this._transport.getRenderingIntent(n,s,d,c),{renderingIntent:m,cacheKey:f}=g;this.#js=!1,o||=this._transport.getOptionalContentConfig(m);let b=this._intentStates.get(f);b||(b=Object.create(null),this._intentStates.set(f,b)),b.streamReaderCancelTimeout&&(clearTimeout(b.streamReaderCancelTimeout),b.streamReaderCancelTimeout=null);const v=!!(m&C);b.displayReadyCapability||(b.displayReadyCapability=Promise.withResolvers(),b.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(g));const w=Boolean(this._pdfBug&&globalThis.StepperManager?.enabled),y=!this.recordedBBoxes&&(u||w),x=t=>{if(b.renderTasks.delete(A),y){const t=A.gfx?.dependencyTracker.take();t&&(A.stepper&&A.stepper.setOperatorBBoxes(t,A.gfx.dependencyTracker.takeDebugMetadata()),u&&(this.recordedBBoxes=t))}v&&(this.#js=!0),this.#Us(),t?(A.capability.reject(t),this._abortOperatorList({intentState:b,reason:t instanceof Error?t:new Error(t)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new Gn({callback:x,params:{canvas:e,canvasContext:t,dependencyTracker:y?new xi(e,b.operatorList.length,w):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:b.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:p});(b.renderTasks||=new Set).add(A);const S=A.task;return Promise.all([b.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)x();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&m))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:t,optionalContentConfig:e}),A.operatorListChanged()}}).catch(x),S}getOperatorList({intent:t="display",annotationMode:e=D.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){const s=this._transport.getRenderingIntent(t,e,i,n,!0);let r,a=this._intentStates.get(s.cacheKey);return a||(a=Object.create(null),this._intentStates.set(s.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(s)),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=>Dt.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,i){const n=e.getReader(),s={items:[],styles:Object.create(null),lang:null};!function e(){n.read().then(function({value:i,done:n}){n?t(s):(s.lang??=i.lang,Object.assign(s.styles,i.styles),s.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.#js=!1,Promise.all(t)}cleanup(t=!1){this.#js=!0;const e=this.#Us();return t&&e&&(this._stats&&=new Vt),e}#Us(){if(!this.#js||this.destroyed)return!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.#js=!1,!0}_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,n=t.length;i<n;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.#Us()}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:s,transfer:r}=i,a=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:s,modifiedIds:n},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.#Us()}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 Bt){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 wt(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}}let zn=class t{#as=Promise.withResolvers();#Vs=null;#Wn=null;#Hs=null;static#zs=0;static#$s=!1;static#Ws=new WeakMap;static{y&&(this.#$s=!0,ln.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!i?.origin||"null"===i.origin)return!1;const n=new URL(e,i);return i.origin===n.origin},this._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},this.fromPort=t=>{var e;if(e="`PDFWorker.fromPort` - please use `PDFWorker.create` instead.",console.log("Deprecated API usage: "+e),!t?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");return this.create(t)}}constructor({name:e=null,port:i=null,verbosity:n=rt()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,i){if(t.#Ws.has(i))throw new Error("Cannot use more than one PDFWorker per port.");t.#Ws.set(i,this),this.#Gs(i)}else this.#qs()}get promise(){return this.#as.promise}#Xs(){this.#as.resolve(),this.#Vs.send("configure",{verbosity:this.verbosity})}get port(){return this.#Wn}get messageHandler(){return this.#Vs}#Gs(t){this.#Wn=t,this.#Vs=new Qe("main","worker",t),this.#Vs.on("ready",()=>{}),this.#Xs()}#qs(){if(t.#$s||t.#Ys)return void this.#Ks();let{workerSrc:e}=t;try{t._isSameOrigin(window.location,e)||(e=t._createCDNWrapper(new URL(e,window.location).href));const i=new Worker(e,{type:"module"}),n=new Qe("main","worker",i),s=()=>{r.abort(),n.destroy(),i.terminate(),this.destroyed?this.#as.reject(new Error("Worker was destroyed")):this.#Ks()},r=new AbortController;i.addEventListener("error",()=>{this.#Hs||s()},{signal:r.signal}),n.on("test",t=>{r.abort(),!this.destroyed&&t?(this.#Vs=n,this.#Wn=i,this.#Hs=i,this.#Xs()):s()}),n.on("ready",t=>{if(r.abort(),this.destroyed)s();else try{a()}catch{this.#Ks()}});const a=()=>{const t=new Uint8Array;n.send("test",t,[t.buffer])};return void a()}catch{at("The worker has been disabled.")}this.#Ks()}#Ks(){t.#$s||(ot("Setting up fake worker."),t.#$s=!0),t._setupFakeWorkerGlobal.then(e=>{if(this.destroyed)return void this.#as.reject(new Error("Worker was destroyed"));const i=new Oe;this.#Wn=i;const n="fake"+t.#zs++,s=new Qe(n+"_worker",n,i);e.setup(s,i),this.#Vs=new Qe(n,n+"_worker",i),this.#Xs()}).catch(t=>{this.#as.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){this.destroyed=!0,this.#Hs?.terminate(),this.#Hs=null,t.#Ws.delete(this.#Wn),this.#Wn=null,this.#Vs?.destroy(),this.#Vs=null}static create(e){const i=this.#Ws.get(e?.port);if(i){if(i._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return i}return new t(e)}static get workerSrc(){if(ln.workerSrc)return ln.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ys(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return ut(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ys)return this.#Ys;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class $n{#Qs=new Map;#Zs=new Map;#Js=new Map;#tr=new Map;#er=null;constructor(t,e,i,n,s,r){this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Fn,this.fontLoader=new Me({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=s.canvasFactory,this.filterFactory=s.filterFactory,this.cMapReaderFactory=s.cMapReaderFactory,this.standardFontDataFactory=s.standardFontDataFactory,this.wasmFactory=s.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=r,this.setupMessageHandler()}#ir(t,e=null){const i=this.#Qs.get(t);if(i)return i;const n=this.messageHandler.sendWithPromise(t,e);return this.#Qs.set(t,n),n}get annotationStorage(){return ut(this,"annotationStorage",new Pe)}getRenderingIntent(t,e=D.ENABLE,i=null,n=!1,s=!1){let r=_,a=Ee;switch(t){case"any":r=S;break;case"display":break;case"print":r=C;break;default:ot(`getRenderingIntent - invalid intent: ${t}`)}const o=r&C&&i instanceof Te?i:this.annotationStorage;switch(e){case D.DISABLE:r+=T;break;case D.ENABLE:break;case D.ENABLE_FORMS:r+=E;break;case D.ENABLE_STORAGE:r+=P,a=o.serializable;break;default:ot(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(r+=M),s&&(r+=k);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.#er?.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const e of this.#Zs.values())t.push(e._destroy());this.#Zs.clear(),this.#Js.clear(),this.#tr.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.#Qs.clear(),this.filterFactory.destroy(),Bn.cleanup(),this._networkStream?.cancelAllRequests(new wt("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)=>{ht(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():(ht(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:n,contentLength:s}=this._fullReader;return i&&n||(this._lastProgress&&e.onProgress?.(this._lastProgress),this._fullReader.onProgress=t=>{e.onProgress?.({loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:s}}),t.on("GetRangeReader",(t,e)=>{ht(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():(ht(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 Vn(t,this))}),t.on("DocException",t=>{e._capability.reject(Ke(t))}),t.on("PasswordRequest",t=>{this.#er=Promise.withResolvers();try{if(!e.onPassword)throw Ke(t);const i=t=>{t instanceof Error?this.#er.reject(t):this.#er.resolve({password:t})};e.onPassword(i,t.code)}catch(t){this.#er.reject(t)}return this.#er.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.#Zs.get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,i,n])=>{if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(i){case"Font":if("error"in n){const t=n.error;ot(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const s=new Le(n),r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new ke(s,r,n.extra,n.charProcOperatorList);this.fontLoader.bind(a).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>{!a.fontExtraProperties&&a.data&&a.clearData(),this.commonObjs.resolve(e,a)});break;case"CopyLocalImage":const{imageRef:o}=n;ht(o,"The imageRef must be defined.");for(const t of this.#Zs.values())for(const[,i]of t.objs)if(i?.ref===o)return i.dataLen?(this.commonObjs.resolve(e,structuredClone(i)),i.dataLen):null;break;case"FontPath":case"Image":this.commonObjs.resolve(e,n);break;case"Pattern":const l=new Re(n);this.commonObjs.resolve(e,l.getIR());break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([t,e,i,n])=>{if(this.destroyed)return;const s=this.#Zs.get(e);if(!s.objs.has(t))if(0!==s._intentStates.size)switch(i){case"Image":case"Pattern":s.objs.resolve(t,n);break;default:throw new Error(`Got unknown object type ${i}`)}else n?.bitmap?.close()}),t.on("DocProgress",t=>{this.destroyed||e.onProgress?.({loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&ot("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.#Js.get(e);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(i=>{if(this.destroyed)throw new Error("Transport destroyed");i.refStr&&this.#tr.set(i.refStr,t);const n=new Hn(e,i,this,this._params.pdfBug);return this.#Zs.set(e,n),n});return this.#Js.set(e,n),n}getPageIndex(t){return Fe(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.#ir("GetFieldObjects")}hasJSActions(){return this.#ir("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)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return this.#ir("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.#ir("GetOptionalContentConfig").then(e=>new un(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=this.#Qs.get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(t=>({info:t[0],metadata:t[1]?new hn(t[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#Qs.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.#Zs.values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),this.#Qs.clear(),this.filterFactory.destroy(!0),Bn.cleanup()}}cachedPageNumber(t){if(!Fe(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#tr.get(e)??null}}class Wn{#nr=null;onContinue=null;onError=null;constructor(t){this.#nr=t}get promise(){return this.#nr.capability.promise}cancel(t=0){this.#nr.cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=this.#nr.operatorList;if(!t)return!1;const{annotationCanvasMap:e}=this.#nr;return t.form||t.canvas&&e?.size>0}}class Gn{#sr=null;static#rr=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:s,operatorList:r,pageIndex:a,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:d=!1,pageColors:c=null,enableHWA:u=!1,operationsFilter:p=null}){this.callback=t,this.params=e,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=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 Wn(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.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=p}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){if(this.cancelled)return;if(this._canvas){if(Gn.#rr.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.");Gn.#rr.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{viewport:i,transform:n,background:s,dependencyTracker:r}=this.params,a=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new on(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,r),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:s}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(t=null,e=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#sr&&(window.cancelAnimationFrame(this.#sr),this.#sr=null),Gn.#rr.delete(this._canvas),t||=new Bt(`Rendering cancelled, page ${this._pageIndex+1}`,e),this.callback(t),this.task.onError?.(t)}operatorListChanged(){this.graphicsReady?(this.gfx.dependencyTracker?.growOperationsCount(this.operatorList.fnArray.length),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.#sr=window.requestAnimationFrame(()=>{this.#sr=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._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),Gn.#rr.delete(this._canvas),this.callback())))}}let qn=class t{#ar=null;#or=null;#lr;#hr=null;#dr=!1;#cr=!1;#r=null;#ur;#pr=null;#b=null;static#gr=null;static get _keyboardManager(){return ut(this,"_keyboardManager",new ge([[["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.#cr=!1,this.#r=e):this.#cr=!0,this.#b=e?._uiManager||i,this.#ur=this.#b._eventBus,this.#lr=e?.color?.toUpperCase()||this.#b?.highlightColors.values().next().value||"#FFFF98",t.#gr||=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.#ar=document.createElement("button");t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",this.#r&&(t.ariaControls=`${this.#r.id}_colorpicker_dropdown`);const e=this.#b._signal;t.addEventListener("click",this.#mr.bind(this),{signal:e}),t.addEventListener("keydown",this.#fr.bind(this),{signal:e});const i=this.#or=document.createElement("span");return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=this.#lr,t.append(i),t}renderMainDropdown(){const t=this.#hr=this.#br();return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}#br(){const e=document.createElement("div"),i=this.#b._signal;e.addEventListener("contextmenu",zt,{signal:i}),e.className="dropdown",e.role="listbox",e.ariaMultiSelectable="false",e.ariaOrientation="vertical",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),this.#r&&(e.id=`${this.#r.id}_colorpicker_dropdown`);for(const[n,s]of this.#b.highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",s),r.title=n,r.setAttribute("data-l10n-id",t.#gr[n]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=s,r.ariaSelected=s===this.#lr,r.addEventListener("click",this.#vr.bind(this,s),{signal:i}),e.append(r)}return e.addEventListener("keydown",this.#fr.bind(this),{signal:i}),e}#vr(t,e){e.stopPropagation(),this.#ur.dispatch("switchannotationeditorparams",{source:this,type:R.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)}_colorSelectFromKeyboard(t){if(t.target===this.#ar)return void this.#mr(t);const e=t.target.getAttribute("data-color");e&&this.#vr(e,t)}_moveToNext(t){this.#wr?t.target!==this.#ar?t.target.nextSibling?.focus():this.#hr.firstChild?.focus():this.#mr(t)}_moveToPrevious(t){t.target!==this.#hr?.firstChild&&t.target!==this.#ar?(this.#wr||this.#mr(t),t.target.previousSibling?.focus()):this.#wr&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#wr?this.#hr.firstChild?.focus():this.#mr(t)}_moveToEnd(t){this.#wr?this.#hr.lastChild?.focus():this.#mr(t)}#fr(e){t._keyboardManager.exec(this,e)}#mr(t){if(this.#wr)return void this.hideDropdown();if(this.#dr=0===t.detail,this.#pr||(this.#pr=new AbortController,window.addEventListener("pointerdown",this.#u.bind(this),{signal:this.#b.combinedSignal(this.#pr)})),this.#ar.ariaExpanded="true",this.#hr)return void this.#hr.classList.remove("hidden");const e=this.#hr=this.#br();this.#ar.append(e)}#u(t){this.#hr?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#hr?.classList.add("hidden"),this.#ar.ariaExpanded="false",this.#pr?.abort(),this.#pr=null}get#wr(){return this.#hr&&!this.#hr.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#cr||(this.#wr?(this.hideDropdown(),this.#ar.focus({preventScroll:!0,focusVisible:this.#dr})):this.#r?.unselect())}updateColor(t){if(this.#or&&(this.#or.style.backgroundColor=t),!this.#hr)return;const e=this.#b.highlightColors.values();for(const i of this.#hr.children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){this.#ar?.remove(),this.#ar=null,this.#or=null,this.#hr?.remove(),this.#hr=null}};class Xn{#yr=null;#r=null;#b=null;static#gr=null;constructor(t){this.#r=t,this.#b=t._uiManager,Xn.#gr||=Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"})}renderButton(){if(this.#yr)return this.#yr;const{editorType:t,colorType:e,color:i}=this.#r,n=this.#yr=document.createElement("input");return n.type="color",n.value=i||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",Xn.#gr[t]),n.addEventListener("input",()=>{this.#b.updateParams(e,n.value)},{signal:this.#b._signal}),n}update(t){this.#yr&&(this.#yr.value=t)}destroy(){this.#yr?.remove(),this.#yr=null}hideDropdown(){}}function Yn(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Kn(t){return Math.max(0,Math.min(255,255*t))}class Qn{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return[t=Kn(t),t,t]}static G_HTML([t]){const e=Yn(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(Kn)}static RGB_HTML(t){return`#${t.map(Yn).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[Kn(1-Math.min(1,t+n)),Kn(1-Math.min(1,i+n)),Kn(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,s=1-e,r=1-i;return["CMYK",n,s,r,Math.min(n,s,r)]}}class Zn{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){lt("Abstract method `_createSVG` called.")}}let Jn=class extends Zn{_createSVG(t){return document.createElementNS(Lt,t)}};const ts=new WeakSet,es=60*(new Date).getTimezoneOffset()*1e3;class is{static create(t){switch(t.data.annotationType){case $.LINK:return new rs(t);case $.TEXT:return new as(t);case $.WIDGET:switch(t.data.fieldType){case"Tx":return new ls(t);case"Btn":return t.data.radioButton?new cs(t):t.data.checkBox?new ds(t):new us(t);case"Ch":return new ps(t);case"Sig":return new hs(t)}return new os(t);case $.POPUP:return new gs(t);case $.FREETEXT:return new fs(t);case $.LINE:return new bs(t);case $.SQUARE:return new vs(t);case $.CIRCLE:return new ws(t);case $.POLYLINE:return new ys(t);case $.CARET:return new As(t);case $.INK:return new Ss(t);case $.POLYGON:return new xs(t);case $.HIGHLIGHT:return new _s(t);case $.UNDERLINE:return new Cs(t);case $.SQUIGGLY:return new Es(t);case $.STRIKEOUT:return new Ps(t);case $.STAMP:return new Ts(t);case $.FILEATTACHMENT:return new Ms(t);default:return new ns(t)}}}class ns{#xr=null;#Ar=!1;#Sr=null;constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!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.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!(!t?.str&&!e?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return ns._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){const{data:t}=this,e=this.annotationStorage?.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){const t=this.annotationStorage?.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:n}=this.data;let s=-1/0,r=-1/0;if(e?.length>=8){for(let t=0;t<e.length;t+=8)e[t+1]>r?(r=e[t+1],s=e[t+2]):e[t+1]===r&&(s=Math.max(s,e[t+2]));return[s,r]}if(i?.length>=1){for(const t of i)for(let e=0,i=t.length;e<i;e+=2)t[e+1]>r?(r=t[e+1],s=t[e]):t[e+1]===r&&(s=Math.max(s,t[e]));if(s!==1/0)return[s,r]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:n,pageX:s,pageY:r}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-s)/i,t[1]=100*(t[1]-r)/n,t}get commentText(){const{data:t}=this;return this.annotationStorage.getRawValue(`${I}${t.id}`)?.popup?.contents||t.contentsObj?.str||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${I}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){(this.#Sr?.popup||this.popup)?.remove(),this.#Sr=this.popup=null}updateEdited(t){if(!this.container)return;t.rect&&(this.#xr||={rect:this.data.rect.slice(0)});const{rect:e,popup:i}=t;e&&this.#_r(e);let n=this.#Sr?.popup||this.popup;!n&&i?.text&&(this._createPopup(i),n=this.#Sr.popup),n&&(n.updateEdited(t),i?.deleted&&(n.remove(),this.#Sr=null,this.popup=null))}resetEdited(){this.#xr&&(this.#_r(this.#xr.rect),this.#Sr?.popup.resetEdited(),this.#xr=null)}#_r(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:s,pageHeight:r,pageX:a,pageY:o}}}}=this;i?.splice(0,4,...t),e.left=100*(t[0]-a)/s+"%",e.top=100*(r-t[3]+o)/r+"%",0===n?(e.width=100*(t[2]-t[0])/s+"%",e.height=100*(t[3]-t[1])/r+"%"):this.setRotation(n)}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,s=document.createElement("section");s.setAttribute("data-annotation-id",e.id),this instanceof os||this instanceof rs||(s.tabIndex=0);const{style:r}=s;if(r.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(s.title=e.alternativeText),e.noRotate&&s.classList.add("norotate"),!e.rect||this instanceof gs){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,s),s}const{width:a,height:o}=this;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(--total-scale-factor)) / calc(${i}px * var(--total-scale-factor))`;r.borderRadius=e}else if(this instanceof cs){const t=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case W:r.borderStyle="solid";break;case G:r.borderStyle="dashed";break;case q:ot("Unimplemented border style: beveled");break;case X:ot("Unimplemented border style: inset");break;case Y:r.borderBottomStyle="solid"}const n=e.borderColor||null;n?(this.#Ar=!0,r.borderColor=_t.makeHexColor(0|n[0],0|n[1],0|n[2])):r.borderWidth=0}const l=_t.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}=n.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,s),s}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims;let{width:s,height:r}=this;t%180!=0&&([s,r]=[r,s]),e.style.width=100*s/i+"%",e.style.height=100*r/n+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,i)=>{const n=i.detail[t],s=n[0],r=n.slice(1);i.target.style[e]=Qn[`${s}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Qn[`${s}_rgb`](r)})};return ut(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 n of Object.keys(e.detail)){const s=t[n]||i[n];s?.(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,s]of Object.entries(e)){const r=i[n];if(r){r({detail:{[n]:s},target:t}),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,s]=this.data.rect.map(t=>Math.fround(t));if(8===t.length){const[r,a,o,l]=t.subarray(2,6);if(n===r&&s===a&&e===o&&i===l)return}const{style:r}=this.container;let a;if(this.#Ar){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=n-e,l=s-i,{svgFactory:h}=this,d=h.createElement("svg");d.classList.add("quadrilateralsContainer"),d.setAttribute("width",0),d.setAttribute("height",0),d.role="none";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,n=t.length;i<n;i+=8){const n=t[i],r=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,m=(s-r)/l,f=(n-d)/o,b=(r-c)/l;p.setAttribute("x",g),p.setAttribute("y",m),p.setAttribute("width",f),p.setAttribute("height",b),u.append(p),a?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${m}" width="${f}" height="${b}"/>`)}this.#Ar&&(a.push("</g></svg>')"),r.backgroundImage=a.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let i,n;t?(i={str:t.text},n=t.date):(i=e.contentsObj,n=e.modificationDate),this.#Sr=new gs({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]})}get hasPopupElement(){return!!(this.#Sr||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#Sr}render(){lt("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:t,id:s,exportValues:r}of n){if(-1===t)continue;if(s===e)continue;const n="string"==typeof r?r:null,a=document.querySelector(`[data-element-id="${s}"]`);!a||ts.has(a)?i.push({id:s,exportValue:n,domElement:a}):ot(`_getElementsByName - element not allowed: ${s}`)}return i}for(const n of document.getElementsByName(t)){const{exportValue:t}=n,s=n.getAttribute("data-element-id");s!==e&&(ts.has(n)&&i.push({id:s,exportValue:t,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 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,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}}class ss extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class rs extends ns{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 n=!1;return t.url?(e.addLinkAttributes(i,t.url,t.newWindow),n=!0):t.action?(this._bindNamedAction(i,t.action,t.overlaidText),n=!0):t.attachment?(this.#Cr(i,t.attachment,t.overlaidText,t.attachmentDest),n=!0):t.setOCGState?(this.#Er(i,t.setOCGState,t.overlaidText),n=!0):t.dest?(this._bindLink(i,t.dest,t.overlaidText),n=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,t),n=!0),t.resetForm?(this._bindResetFormAction(i,t.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&(this.contentElement=i,this.container.append(i)),this.container}#Pr(){this.container.setAttribute("data-internal-link","")}_bindLink(t,e,i=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&this.#Pr(),i&&(t.title=i)}_bindNamedAction(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),i&&(t.title=i),this.#Pr()}#Cr(t,e,i="",n=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:i&&(t.title=i),t.onclick=()=>(this.downloadManager?.openOrDownloadData(e.content,e.filename,n),!1),this.#Pr()}#Er(t,e,i=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),i&&(t.title=i),this.#Pr()}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(e.actions)){const s=i.get(n);s&&(t[s]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:n}}),!1))}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),this.#Pr()}_bindResetFormAction(t,e){const i=t.onclick;if(i||(t.href=this.linkService.getAnchorUrl("")),this.#Pr(),!this._fieldObjects)return ot('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(i||(t.onclick=()=>!1));t.onclick=()=>{i?.();const{fields:t,refs:n,include:s}=e,r=[];if(0!==t.length||0!==n.length){const e=new Set(n);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)===s&&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&&(ts.has(i)?i.dispatchEvent(new Event("resetform")):ot(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class as extends ns{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.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class os extends ns{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return At.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,s){i.includes("mouse")?t.addEventListener(i,t=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(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}s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:s(t)}})})}_setEventListeners(t,e,i,n){for(const[s,r]of i)("Action"===r||this.data.actions?.[r])&&("Focus"!==r&&"Blur"!==r||(e||={focused:!1}),this._setEventListener(t,e,s,r,n),"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":_t.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,s=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/(A*n))||1);r=Math.min(n,a(e/A))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,a(t/A))}s.fontSize=`calc(${r}px * var(--total-scale-factor))`,s.color=_t.makeHexColor(i[0],i[1],i[2]),null!==this.data.textAlignment&&(s.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class ls extends os{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}setPropertyOnSiblings(t,e,i,n){const s=this.annotationStorage;for(const r of this._getElementsByName(t.name,t.id))r.domElement&&(r.domElement[e]=i),s.setValue(r.id,{[n]:i})}render(){const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const n=t.getValue(e,{value:this.data.fieldValue});let s=n.value||"";const r=t.getValue(e,{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=this.data.password?"password":"text",i.setAttribute("value",a??s),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),ts.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:l,datetimeType:h,timeStep:d}=this.data,c=!!h&&this.enableScripting;l&&(i.title=l),this._setRequired(i,this.data.required),r&&(i.maxLength=r),i.addEventListener("input",n=>{t.setValue(e,{value:n.target.value}),this.setPropertyOnSiblings(i,"value",n.target.value,"value"),o.formattedValue=null}),i.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";i.value=o.userValue=e,o.formattedValue=null});let u=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;if(c&&(e.type=h,d&&(e.step=d)),o.userValue){const t=o.userValue;if(c)if("time"===h){const i=new Date(t),n=[i.getHours(),i.getMinutes(),i.getSeconds()];e.value=n.map(t=>t.toString().padStart(2,"0")).join(":")}else e.value=new Date(t-es).toISOString().split("date"===h?"T":".",1)[0];else e.value=t}o.lastCommittedValue=e.value,o.commitKey=1,this.data.actions?.Focus||(o.focused=!0)}),i.addEventListener("updatefromsandbox",i=>{this.showElementAndHideCanvas(i.target);const n={value(i){o.userValue=i.detail.value??"",c||t.setValue(e,{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);const s={formattedValue:n};c&&(s.value=n),t.setValue(e,s)},selRange(t){t.target.setSelectionRange(...t.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,t.setValue(e,{value:r}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:s.selectionStart,selEnd:s.selectionEnd}}))}};this._dispatchEventFromSandbox(n,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:n}=t.target;o.lastCommittedValue!==n&&(o.lastCommittedValue=n,o.userValue=n,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:n,willCommit:!0,commitKey:i,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const n=u;u=null,i.addEventListener("blur",t=>{if(!o.focused||!t.relatedTarget)return;this.data.actions?.Blur||(o.focused=!1);const{target:i}=t;let{value:s}=i;if(c){if(s&&"time"===h){const t=s.split(":").map(t=>parseInt(t,10));s=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),i.step=""}else s.includes("T")||(s=`${s}T00:00`),s=new Date(s).valueOf();i.type="text"}o.userValue=s,o.lastCommittedValue!==s&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:s,willCommit:!0,commitKey:o.commitKey,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}),n(t)}),this.data.actions?.Keystroke&&i.addEventListener("beforeinput",t=>{o.lastCommittedValue=null;const{data:i,target:n}=t,{value:s,selectionStart:r,selectionEnd:a}=n;let l=r,h=a;switch(t.inputType){case"deleteWordBackward":{const t=s.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=s.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: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"]],t=>t.target.value)}if(u&&i.addEventListener("blur",u),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(--total-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 hs extends os{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class ds extends os{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;"string"==typeof n&&(n="Off"!==n,t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const s=document.createElement("input");return ts.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="checkbox",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.setAttribute("exportValue",e.exportValue),s.tabIndex=0,s.addEventListener("change",n=>{const{name:s,checked:r}=n.target;for(const n of this._getElementsByName(s,i)){const i=r&&n.exportValue===e.exportValue;n.domElement&&(n.domElement.checked=i),t.setValue(n.id,{value:i})}t.setValue(i,{value:r})}),s.addEventListener("resetform",t=>{const i=e.defaultFieldValue||"Off";t.target.checked=i===e.exportValue}),this.enableScripting&&this.hasJSActions&&(s.addEventListener("updatefromsandbox",e=>{const n={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(i,{value:e.target.checked})}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class cs extends os{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 n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if("string"==typeof n&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const n of this._getElementsByName(e.fieldName,i))t.setValue(n.id,{value:!1});const s=document.createElement("input");if(ts.add(s),s.setAttribute("data-element-id",i),s.disabled=e.readOnly,this._setRequired(s,this.data.required),s.type="radio",s.name=e.fieldName,n&&s.setAttribute("checked",!0),s.tabIndex=0,s.addEventListener("change",e=>{const{name:n,checked:s}=e.target;for(const e of this._getElementsByName(n,i))t.setValue(e.id,{value:!1});t.setValue(i,{value:s})}),s.addEventListener("resetform",t=>{const i=e.defaultFieldValue;t.target.checked=null!=i&&i===e.buttonValue}),this.enableScripting&&this.hasJSActions){const n=e.buttonValue;s.addEventListener("updatefromsandbox",e=>{const s={value:e=>{const s=n===e.detail.value;for(const n of this._getElementsByName(e.target.name)){const e=s&&n.id===i;n.domElement&&(n.domElement.checked=e),t.setValue(n.id,{value:e})}}};this._dispatchEventFromSandbox(s,e)}),this._setEventListeners(s,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(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class us extends rs{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 ps extends os{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}),n=document.createElement("select");ts.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;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",t=>{const e=this.data.defaultFieldValue;for(const t of n.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),s=!1),n.append(e)}let r=null;if(s){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),n.prepend(t),r=()=>{t.remove(),n.removeEventListener("input",r),r=null},n.addEventListener("input",r)}const a=t=>{const e=t?"value":"textContent",{options:i,multiple:s}=n;return s?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?(n.addEventListener("updatefromsandbox",i=>{const s={value(i){r?.();const s=i.detail.value,l=new Set(Array.isArray(s)?s:[s]);for(const t of n.options)t.selected=l.has(t.value);t.setValue(e,{value:a(!0)}),o=a(!1)},multipleSelection(t){n.multiple=!0},remove(i){const s=n.options,r=i.detail.remove;if(s[r].selected=!1,n.remove(r),s.length>0){-1===Array.prototype.findIndex.call(s,t=>t.selected)&&(s[0].selected=!0)}t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},clear(i){for(;0!==n.length;)n.remove(0);t.setValue(e,{value:null,items:[]}),o=a(!1)},insert(i){const{index:s,displayValue:r,exportValue:h}=i.detail.insert,d=n.children[s],c=document.createElement("option");c.textContent=r,c.value=h,d?d.before(c):n.append(c),t.setValue(e,{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 t of s){const{displayValue:e,exportValue:i}=t,s=document.createElement("option");s.textContent=e,s.value=i,n.append(s)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:a(!0),items:l(i)}),o=a(!1)},indices(i){const n=new Set(i.detail.indices);for(const t of i.target.options)t.selected=n.has(t.index);t.setValue(e,{value:a(!0)}),o=a(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(s,i)}),n.addEventListener("input",i=>{const n=a(!0),s=a(!1);t.setValue(e,{value:n}),i.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:s,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"]],t=>t.target.value)):n.addEventListener("input",function(i){t.setValue(e,{value:a(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class gs extends ns{constructor(t){const{data:e,elements:i,parent:n}=t,s=!!n._commentManager;if(super(t,{isRenderable:!s&&ns._hasPopupData(e)}),this.elements=i,s&&ns._hasPopupData(e)){const t=this.popup=this.#Tr();for(const e of i)e.popup=t}else this.popup=null}#Tr(){return new ms({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,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,commentManager:this.parent._commentManager})}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=this.#Tr(),i=[];for(const t of this.elements)t.popup=e,t.container.ariaHasPopup="dialog",i.push(t.data.id),t.addHighlightArea();return this.container.setAttribute("aria-controls",i.map(t=>`${Tt}${t}`).join(",")),this.container}}class ms{#z=null;#Mr=this.#fr.bind(this);#kr=this.#Dr.bind(this);#Ir=this.#Lr.bind(this);#Rr=this.#Nr.bind(this);#Fr=null;#Ct=null;#Br=null;#Or=null;#jr=null;#Ur=null;#Vr=null;#Hr=!1;#zr=null;#$r=null;#I=null;#Wr=null;#Gr=null;#be=null;#qr=null;#pe=null;#Xr=null;#xr=null;#Yr=!1;#Kr=null;#Qr=null;constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:s,contentsObj:r,richText:a,parent:o,rect:l,parentRect:h,open:d,commentManager:c=null}){this.#Ct=t,this.#Xr=n,this.#Br=r,this.#pe=a,this.#Ur=o,this.#Fr=e,this.#qr=l,this.#Vr=h,this.#jr=i,this.#z=c,this.#Kr=i[0],this.#Or=Wt.toDateObject(s),this.trigger=i.flatMap(t=>t.getElementsToTriggerPopup()),c||(this.#Zr(),this.#Ct.hidden=!0,d&&this.#Nr())}#Zr(){if(this.#$r)return;this.#$r=new AbortController;const{signal:t}=this.#$r;for(const e of this.trigger)e.addEventListener("click",this.#Rr,{signal:t}),e.addEventListener("pointerenter",this.#Ir,{signal:t}),e.addEventListener("pointerleave",this.#kr,{signal:t}),e.classList.add("popupTriggerArea");for(const e of this.#jr)e.container?.addEventListener("keydown",this.#Mr,{signal:t})}#Jr(){const t=this.#jr.find(t=>t.hasCommentButton);t&&(this.#Gr=t._normalizePoint(t.commentButtonPosition))}renderCommentButton(){if(this.#Wr)return void(this.#Wr.parentNode||this.#Kr.container.after(this.#Wr));if(this.#Gr||this.#Jr(),!this.#Gr)return;const{signal:t}=this.#$r=new AbortController,e=this.#Kr.hasOwnCommentButton,i=()=>{this.#z.toggleCommentPopup(this,!0,void 0,!e)},n=()=>{this.#z.toggleCommentPopup(this,!1,!0,!e)},s=()=>{this.#z.toggleCommentPopup(this,!1,!1)};if(e){this.#Wr=this.#Kr.container;for(const e of this.trigger)e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.addEventListener("keydown",this.#Mr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),e.classList.add("popupTriggerArea")}else{const e=this.#Wr=document.createElement("button");e.className="annotationCommentButton";const r=this.#Kr.container;e.style.zIndex=r.style.zIndex+1,e.tabIndex=0,e.ariaHasPopup="dialog",e.ariaControls="commentPopup",e.setAttribute("data-l10n-id","pdfjs-show-comment-button"),this.#ta(),this.#ea(),e.addEventListener("keydown",this.#Mr,{signal:t}),e.addEventListener("click",i,{signal:t}),e.addEventListener("pointerenter",n,{signal:t}),e.addEventListener("pointerleave",s,{signal:t}),r.after(e)}}#ea(){if(this.#Kr.extraPopupElement&&!this.#Kr.editor)return;this.#Wr||this.renderCommentButton();const[t,e]=this.#Gr,{style:i}=this.#Wr;i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`}#ta(){this.#Kr.extraPopupElement||(this.#Wr||this.renderCommentButton(),this.#Wr.style.backgroundColor=this.commentButtonColor||"")}get commentButtonColor(){const{color:t,opacity:e}=this.#Kr.commentData;return t?this.#Ur._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{this.#Wr?.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}=this.#Kr.commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:n,modificationDate:s}}get elementBeforePopup(){return this.#Wr}get comment(){return this.#Qr||=this.#Kr.commentText,this.#Qr}set comment(t){t!==this.comment&&(this.#Kr.commentText=this.#Qr=t)}focus(){this.#Kr.container?.focus()}get parentBoundingClientRect(){return this.#Kr.layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){this.#Wr&&(this.#Wr.classList.toggle("selected",t),this.#Wr.ariaExpanded=e)}setSelectedCommentButton(t){this.#Wr.classList.toggle("selected",t)}get commentPopupPosition(){if(this.#be)return this.#be;const{x:t,y:e,height:i}=this.#Wr.getBoundingClientRect(),{x:n,y:s,width:r,height:a}=this.#Kr.layer.getBoundingClientRect();return[(t-n)/r,(e+i-s)/a]}set commentPopupPosition(t){this.#be=t}hasDefaultPopupPosition(){return null===this.#be}get commentButtonPosition(){return this.#Gr}get commentButtonWidth(){return this.#Wr.getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=this.#be||this.commentButtonPosition.map(t=>t/100),n=this.parentBoundingClientRect,{x:s,y:r,width:a,height:o}=n;this.#z.showDialog(null,this,s+e*a,r+i*o,{...t,parentDimensions:n})}render(){if(this.#zr)return;const t=this.#zr=document.createElement("div");if(t.className="popup",this.#Fr){const e=t.style.outlineColor=_t.makeHexColor(...this.#Fr);t.style.backgroundColor=`color-mix(in srgb, ${e} 30%, white)`}const e=document.createElement("span");if(e.className="header",this.#Xr?.str){const t=document.createElement("span");t.className="title",e.append(t),({dir:t.dir,str:t.textContent}=this.#Xr)}if(t.append(e),this.#Or){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#Or.valueOf()})),t.dateTime=this.#Or.toISOString(),e.append(t)}re({html:this.#ia||this.#Br.str,dir:this.#Br?.dir,className:"popupContent"},t),this.#Ct.append(t)}get#ia(){const t=this.#pe,e=this.#Br;return!t?.str||e?.str&&e.str!==t.str?null:this.#pe.html||null}get#na(){return this.#ia?.attributes?.style?.fontSize||0}get#sa(){return this.#ia?.attributes?.style?.color||null}#ra(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:this.#sa,fontSize:this.#na?`calc(${this.#na}px * var(--total-scale-factor))`:""}};for(const i of t.split("\n"))e.push({name:"span",value:i,attributes:n});return i}#fr(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&this.#Hr)&&this.#Nr()}updateEdited({rect:t,popup:e,deleted:i}){if(this.#z)return i?(this.remove(),this.#Qr=null):e&&(e.deleted?this.remove():(this.#ta(),this.#Qr=e.text)),void(t&&(this.#Gr=null,this.#Jr(),this.#ea()));i||e?.deleted?this.remove():(this.#Zr(),this.#xr||={contentsObj:this.#Br,richText:this.#pe},t&&(this.#I=null),e&&e.text&&(this.#pe=this.#ra(e.text),this.#Or=Wt.toDateObject(e.date),this.#Br=null),this.#zr?.remove(),this.#zr=null)}resetEdited(){this.#xr&&(({contentsObj:this.#Br,richText:this.#pe}=this.#xr),this.#xr=null,this.#zr?.remove(),this.#zr=null,this.#I=null)}remove(){if(this.#$r?.abort(),this.#$r=null,this.#zr?.remove(),this.#zr=null,this.#Yr=!1,this.#Hr=!1,this.#Wr?.remove(),this.#Wr=null,this.trigger)for(const t of this.trigger)t.classList.remove("popupTriggerArea")}#aa(){if(null!==this.#I)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:s}}}=this.#Ur;let r=!!this.#Vr,a=r?this.#Vr:this.#qr;for(const t of this.#jr)if(!a||null!==_t.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=_t.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.#I=[100*(h-n)/e,100*(d-s)/i];const{style:c}=this.#Ct;c.left=`${this.#I[0]}%`,c.top=`${this.#I[1]}%`}#Nr(){this.#z?this.#z.toggleCommentPopup(this,!1):(this.#Hr=!this.#Hr,this.#Hr?(this.#Lr(),this.#Ct.addEventListener("click",this.#Rr),this.#Ct.addEventListener("keydown",this.#Mr)):(this.#Dr(),this.#Ct.removeEventListener("click",this.#Rr),this.#Ct.removeEventListener("keydown",this.#Mr)))}#Lr(){this.#zr||this.render(),this.isVisible?this.#Hr&&this.#Ct.classList.add("focused"):(this.#aa(),this.#Ct.hidden=!1,this.#Ct.style.zIndex=parseInt(this.#Ct.style.zIndex)+1e3)}#Dr(){this.#Ct.classList.remove("focused"),!this.#Hr&&this.isVisible&&(this.#Ct.hidden=!0,this.#Ct.style.zIndex=parseInt(this.#Ct.style.zIndex)-1e3)}forceHide(){this.#Yr=this.isVisible,this.#Yr&&(this.#Ct.hidden=!0)}maybeShow(){this.#z||(this.#Zr(),this.#Yr&&(this.#zr||this.#Lr(),this.#Yr=!1,this.#Ct.hidden=!1))}get isVisible(){return!this.#z&&!1===this.#Ct.hidden}}class fs extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=L.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=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.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class bs extends ns{#oa=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=this.#oa=this.svgFactory.createElement("svg:line");return s.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),s.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),s.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),s.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),s.setAttribute("stroke-width",t.borderStyle.width||1),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),n.append(s),this.container.append(n),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#oa}addHighlightArea(){this.container.classList.add("highlightArea")}}class vs extends ns{#la=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#la=this.svgFactory.createElement("svg:rect");return r.setAttribute("x",s/2),r.setAttribute("y",s/2),r.setAttribute("width",e-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),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#la}addHighlightArea(){this.container.classList.add("highlightArea")}}class ws extends ns{#ha=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:i}=this,n=this.svgFactory.create(e,i,!0),s=t.borderStyle.width,r=this.#ha=this.svgFactory.createElement("svg:ellipse");return r.setAttribute("cx",e/2),r.setAttribute("cy",i/2),r.setAttribute("rx",e/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),!t.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#ha}addHighlightArea(){this.container.classList.add("highlightArea")}}class ys extends ns{#da=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:n},width:s,height:r}=this;if(!e)return this.container;const a=this.svgFactory.create(s,r,!0);let o=[];for(let i=0,n=e.length;i<n;i+=2){const n=e[i]-t[0],s=t[3]-e[i+1];o.push(`${n},${s}`)}o=o.join(" ");const l=this.#da=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),!n&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return this.#da}addHighlightArea(){this.container.classList.add("highlightArea")}}class xs extends ys{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class As extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class Ss extends ns{#ca=null;#ua=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?L.HIGHLIGHT:L.INK}#pa(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:n,popupRef:s}}=this,{transform:r,width:a,height:o}=this.#pa(e,t),l=this.svgFactory.create(a,o,!0),h=this.#ca=this.svgFactory.createElement("svg:g");l.append(h),h.setAttribute("stroke-width",n.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.#ua.push(e),e.setAttribute("points",i[t].join(",")),h.append(e)}return!s&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:i,rect:n}=t,s=this.#ca;if(e>=0&&s.setAttribute("stroke-width",e||1),i)for(let t=0,e=this.#ua.length;t<e;t++)this.#ua[t].setAttribute("points",i[t].join(","));if(n){const{transform:t,width:e,height:i}=this.#pa(this.data.rotation,n);s.parentElement.setAttribute("viewBox",`0 0 ${e} ${i}`),s.setAttribute("transform",t)}}getElementsToTriggerPopup(){return this.#ua}addHighlightArea(){this.container.classList.add("highlightArea")}}class _s extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=L.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Cs extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Es extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ps extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Ts extends ns{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=L.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Ms extends ns{#ga=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.#ma.bind(this)),this.#ga=i;const{isMac:n}=At.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(n?t.metaKey:t.ctrlKey)&&this.#ma()}),!e.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):i.classList.add("popupTriggerArea"),t.append(i),t}getElementsToTriggerPopup(){return this.#ga}addHighlightArea(){this.container.classList.add("highlightArea")}#ma(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}const ks=/\r\n?|\n/g;class Ds extends ye{#fa="";#ba=`${this.id}-editor`;#va=null;#na;_colorPicker=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const t=Ds.prototype,e=t=>t.isEmpty(),i=fe.TRANSLATE_SMALL,n=fe.TRANSLATE_BIG;return ut(this,"_keyboardManager",new ge([[["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:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,n],checker:e}]]))}static _type="freetext";static _editorType=L.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||Ds._defaultColor||ye._defaultLineColor,this.#na=t.fontSize||Ds._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){ye.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case R.FREETEXT_SIZE:Ds._defaultFontSize=e;break;case R.FREETEXT_COLOR:Ds._defaultColor=e}}updateParams(t,e){switch(t){case R.FREETEXT_SIZE:this.#wa(e);break;case R.FREETEXT_COLOR:this.#ta(e)}}static get defaultPropertiesToUpdate(){return[[R.FREETEXT_SIZE,Ds._defaultFontSize],[R.FREETEXT_COLOR,Ds._defaultColor||ye._defaultLineColor]]}get propertiesToUpdate(){return[[R.FREETEXT_SIZE,this.#na],[R.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Xn(this),[["colorPicker",this._colorPicker]]}get colorType(){return R.FREETEXT_COLOR}#wa(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-this.#na)*this.parentScale),this.#na=t,this.#ya()},i=this.#na;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}onUpdatedColor(){this.editorDiv.style.color=this.color,this._colorPicker?.update(this.color),super.onUpdatedColor()}#ta(t){const e=t=>{this.color=t,this.onUpdatedColor()},i=this.color;this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ds._internalPadding*t,-(Ds._internalPadding+this.#na)*t]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#va=new AbortController;const t=this._uiManager.combinedSignal(this.#va);return 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}),!0}disableEditMode(){return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#ba),this._isDraggable=!0,this.#va?.abort(),this.#va=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){this.width||(this.enableEditMode(),t&&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()}#xa(){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(Ds.#Aa(i)),e=i);return t.join("\n")}#ya(){const[t,e]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,n=e.style.display,s=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=n,e.classList.toggle("hidden",s)}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.#fa,e=this.#fa=this.#xa().trimEnd();if(t===e)return;const i=t=>{this.#fa=t,t?(this.#Sa(),this._uiManager.rebuild(this),this.#ya()):this.remove()};this.addCommands({cmd:()=>{i(e)},undo:()=>{i(t)},mustExec:!1}),this.#ya()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(t){Ds._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)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#ba),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.#na}px * var(--total-scale-factor))`,i.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[i,n]=this.parentDimensions;if(this.annotationElementId){const{position:s}=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+(s[0]-h)/o,u=e+this.height-(s[1]-d)/l;break;case 90:c=t+(s[0]-h)/o,u=e-(s[1]-d)/l,[r,a]=[a,-r];break;case 180:c=t-this.width+(s[0]-h)/o,u=e-(s[1]-d)/l,[r,a]=[-r,-a];break;case 270:c=t+(s[0]-h-this.height*l)/o,u=e+(s[1]-d-this.width*o)/l,[r,a]=[-a,r]}this.setAt(c*i,u*n,r,a)}else this._moveAfterPaste(t,e);this.#Sa(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Aa(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(ks,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const n=Ds.#_a(e.getData("text")||"").replaceAll(ks,"\n");if(!n)return;const s=window.getSelection();if(!s.rangeCount)return;this.editorDiv.normalize(),s.deleteFromDocument();const r=s.getRangeAt(0);if(!n.includes("\n"))return r.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),void s.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(ks,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Ds.#Aa(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(ks,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Ds.#Aa(i))}this.#fa=`${l.join("\n")}${n}${h.join("\n")}`,this.#Sa();const d=new Range;let c=Math.sumPrecise(l.map(t=>t.length));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}s.removeAllRanges(),s.addRange(d)}#Sa(){if(this.editorDiv.replaceChildren(),this.#fa)for(const t of this.#fa.split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}}#Ca(){return this.#fa.replaceAll(" "," ")}static#_a(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=Ds._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let n=null;if(t instanceof fs){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:s,rotation:r,id:a,popupRef:o,richText:l,contentsObj:h,creationDate:d,modificationDate:c},textContent:u,textPosition:p,parent:{page:{pageNumber:g}}}=t;if(!u||0===u.length)return null;n=t={annotationType:L.FREETEXT,color:Array.from(i),fontSize:e,value:u.join("\n"),position:p,pageIndex:g-1,rect:s.slice(0),rotation:r,annotationElementId:a,id:a,deleted:!1,popupRef:o,comment:h?.str||null,richText:l,creationDate:d,modificationDate:c}}const s=await super.deserialize(t,e,i);return s.#na=t.fontSize,s.color=_t.makeHexColor(...t.color),s.#fa=Ds.#_a(t.value),s._initialData=n,t.comment&&s.setCommentData(t),s}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const e=ye._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),i=Object.assign(super.serialize(t),{color:e,fontSize:this.#na,value:this.#Ca()});return this.addComment(i),t?(i.isCopy=!0,i):this.annotationElementId&&!this.#Ea(i)?null:(i.id=this.annotationElementId,i)}#Ea(t){const{value:e,fontSize:i,color:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==i||t.color.some((t,e)=>t!==n[e])||t.pageIndex!==s}renderAnnotationElement(t){const e=super.renderAnnotationElement(t);if(!e)return null;const{style:i}=e;i.fontSize=`calc(${this.#na}px * var(--total-scale-factor))`,i.color=this.color,e.replaceChildren();for(const t of this.#fa.split("\n")){const i=document.createElement("div");i.append(t?document.createTextNode(t):document.createElement("br")),e.append(i)}return t.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:this.#fa}}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Is{static PRECISION=1e-4;toSVGPath(){lt("Abstract method `toSVGPath` must be implemented.")}get box(){lt("Abstract getter `box` must be implemented.")}serialize(t,e){lt("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,n,s,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a]*n,r[a+1]=i+t[a+1]*s;return r}static _rescaleAndSwap(t,e,i,n,s,r){r||=new Float32Array(t.length);for(let a=0,o=t.length;a<o;a+=2)r[a]=e+t[a+1]*n,r[a+1]=i+t[a]*s;return r}static _translate(t,e,i,n){n||=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s+=2)n[s]=e+t[s],n[s+1]=i+t[s+1];return n}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,i,n,s){switch(s){case 90:return[1-e/i,t/n];case 180:return[1-t/i,1-e/n];case 270:return[e/i,1-t/n];default:return[t/i,e/n]}}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,n,s,r){return[(t+5*i)/6,(e+5*n)/6,(5*i+s)/6,(5*n+r)/6,(i+s)/2,(n+r)/2]}}class Ls{#Pa;#Ta=[];#Ma;#ka;#Da=[];#Ia=new Float32Array(18);#La;#Ra;#Na;#Fa;#Ba;#Oa;#ja=[];static#Ua=8;static#Va=2;static#Ha=Ls.#Ua+Ls.#Va;constructor({x:t,y:e},i,n,s,r,a=0){this.#Pa=i,this.#Oa=s*n,this.#ka=r,this.#Ia.set([NaN,NaN,NaN,NaN,t,e],6),this.#Ma=a,this.#Fa=Ls.#Ua*n,this.#Na=Ls.#Ha*n,this.#Ba=n,this.#ja.push(t,e)}isEmpty(){return isNaN(this.#Ia[8])}#za(){const t=this.#Ia.subarray(4,6),e=this.#Ia.subarray(16,18),[i,n,s,r]=this.#Pa;return[(this.#La+(t[0]-e[0])/2-i)/s,(this.#Ra+(t[1]-e[1])/2-n)/r,(this.#La+(e[0]-t[0])/2-i)/s,(this.#Ra+(e[1]-t[1])/2-n)/r]}add({x:t,y:e}){this.#La=t,this.#Ra=e;const[i,n,s,r]=this.#Pa;let[a,o,l,h]=this.#Ia.subarray(8,12);const d=t-l,c=e-h,u=Math.hypot(d,c);if(u<this.#Na)return!1;const p=u-this.#Fa,g=p/u,m=g*d,f=g*c;let b=a,v=o;a=l,o=h,l+=m,h+=f,this.#ja?.push(t,e);const w=m/p,y=-f/p*this.#Oa,x=w*this.#Oa;if(this.#Ia.set(this.#Ia.subarray(2,8),0),this.#Ia.set([l+y,h+x],4),this.#Ia.set(this.#Ia.subarray(14,18),12),this.#Ia.set([l-y,h-x],16),isNaN(this.#Ia[6]))return 0===this.#Da.length&&(this.#Ia.set([a+y,o+x],2),this.#Da.push(NaN,NaN,NaN,NaN,(a+y-i)/s,(o+x-n)/r),this.#Ia.set([a-y,o-x],14),this.#Ta.push(NaN,NaN,NaN,NaN,(a-y-i)/s,(o-x-n)/r)),this.#Ia.set([b,v,a,o,l,h],6),!this.isEmpty();this.#Ia.set([b,v,a,o,l,h],6);return Math.abs(Math.atan2(v-o,b-a)-Math.atan2(f,m))<Math.PI/2?([a,o,l,h]=this.#Ia.subarray(2,6),this.#Da.push(NaN,NaN,NaN,NaN,((a+l)/2-i)/s,((o+h)/2-n)/r),[a,o,b,v]=this.#Ia.subarray(14,18),this.#Ta.push(NaN,NaN,NaN,NaN,((b+a)/2-i)/s,((v+o)/2-n)/r),!0):([b,v,a,o,l,h]=this.#Ia.subarray(0,6),this.#Da.push(((b+5*a)/6-i)/s,((v+5*o)/6-n)/r,((5*a+l)/6-i)/s,((5*o+h)/6-n)/r,((a+l)/2-i)/s,((o+h)/2-n)/r),[l,h,a,o,b,v]=this.#Ia.subarray(12,18),this.#Ta.push(((b+5*a)/6-i)/s,((v+5*o)/6-n)/r,((5*a+l)/6-i)/s,((5*o+h)/6-n)/r,((a+l)/2-i)/s,((o+h)/2-n)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Da,e=this.#Ta;if(isNaN(this.#Ia[6])&&!this.isEmpty())return this.#$a();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.#Wa(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.#Ga(i),i.join(" ")}#$a(){const[t,e,i,n]=this.#Pa,[s,r,a,o]=this.#za();return`M${(this.#Ia[2]-t)/i} ${(this.#Ia[3]-e)/n} L${(this.#Ia[4]-t)/i} ${(this.#Ia[5]-e)/n} L${s} ${r} L${a} ${o} L${(this.#Ia[16]-t)/i} ${(this.#Ia[17]-e)/n} L${(this.#Ia[14]-t)/i} ${(this.#Ia[15]-e)/n} Z`}#Ga(t){const e=this.#Ta;t.push(`L${e[4]} ${e[5]} Z`)}#Wa(t){const[e,i,n,s]=this.#Pa,r=this.#Ia.subarray(4,6),a=this.#Ia.subarray(16,18),[o,l,h,d]=this.#za();t.push(`L${(r[0]-e)/n} ${(r[1]-i)/s} L${o} ${l} L${h} ${d} L${(a[0]-e)/n} ${(a[1]-i)/s}`)}newFreeDrawOutline(t,e,i,n,s,r){return new Rs(t,e,i,n,s,r)}getOutlines(){const t=this.#Da,e=this.#Ta,i=this.#Ia,[n,s,r,a]=this.#Pa,o=new Float32Array((this.#ja?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ja[t]-n)/r,o[t+1]=(this.#ja[t+1]-s)/a;if(o[o.length-2]=(this.#La-n)/r,o[o.length-1]=(this.#Ra-s)/a,isNaN(i[6])&&!this.isEmpty())return this.#qa(o);const l=new Float32Array(this.#Da.length+24+this.#Ta.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.#Xa(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.#Ya(l,h),this.newFreeDrawOutline(l,o,this.#Pa,this.#Ba,this.#Ma,this.#ka)}#qa(t){const e=this.#Ia,[i,n,s,r]=this.#Pa,[a,o,l,h]=this.#za(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/s,(e[3]-n)/r,NaN,NaN,NaN,NaN,(e[4]-i)/s,(e[5]-n)/r,NaN,NaN,NaN,NaN,a,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/s,(e[17]-n)/r,NaN,NaN,NaN,NaN,(e[14]-i)/s,(e[15]-n)/r],0),this.newFreeDrawOutline(d,t,this.#Pa,this.#Ba,this.#Ma,this.#ka)}#Ya(t,e){const i=this.#Ta;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#Xa(t,e){const i=this.#Ia.subarray(4,6),n=this.#Ia.subarray(16,18),[s,r,a,o]=this.#Pa,[l,h,d,c]=this.#za();return t.set([NaN,NaN,NaN,NaN,(i[0]-s)/a,(i[1]-r)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(n[0]-s)/a,(n[1]-r)/o],e),e+24}}class Rs extends Is{#Pa;#Ka=new Float32Array(4);#Ma;#ka;#ja;#Ba;#Qa;constructor(t,e,i,n,s,r){super(),this.#Qa=t,this.#ja=e,this.#Pa=i,this.#Ba=n,this.#Ma=s,this.#ka=r,this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],this.#Za(r);const[a,o,l,h]=this.#Ka;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.#Qa[4]} ${this.#Qa[5]}`];for(let e=6,i=this.#Qa.length;e<i;e+=6)isNaN(this.#Qa[e])?t.push(`L${this.#Qa[e+4]} ${this.#Qa[e+5]}`):t.push(`C${this.#Qa[e]} ${this.#Qa[e+1]} ${this.#Qa[e+2]} ${this.#Qa[e+3]} ${this.#Qa[e+4]} ${this.#Qa[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,n],s){const r=i-t,a=n-e;let o,l;switch(s){case 0:o=Is._rescale(this.#Qa,t,n,r,-a),l=Is._rescale(this.#ja,t,n,r,-a);break;case 90:o=Is._rescaleAndSwap(this.#Qa,t,e,r,a),l=Is._rescaleAndSwap(this.#ja,t,e,r,a);break;case 180:o=Is._rescale(this.#Qa,i,e,-r,a),l=Is._rescale(this.#ja,i,e,-r,a);break;case 270:o=Is._rescaleAndSwap(this.#Qa,i,n,-r,-a),l=Is._rescaleAndSwap(this.#ja,i,n,-r,-a)}return{outline:Array.from(o),points:[Array.from(l)]}}#Za(t){const e=this.#Qa;let i=e[4],n=e[5];const s=[i,n,i,n];let r=i,a=n,o=i,l=n;const h=t?Math.max:Math.min,d=new Float32Array(4);for(let t=6,c=e.length;t<c;t+=6){const c=e[t+4],u=e[t+5];isNaN(e[t])?(_t.pointBoundingBox(c,u,s),a>u?(r=c,a=u):a===u&&(r=h(r,c)),l<u?(o=c,l=u):l===u&&(o=h(o,c))):(d[0]=d[1]=1/0,d[2]=d[3]=-1/0,_t.bezierBoundingBox(i,n,...e.slice(t,t+6),d),_t.rectBoundingBox(d[0],d[1],d[2],d[3],s),a>d[1]?(r=d[0],a=d[1]):a===d[1]&&(r=h(r,d[0])),l<d[3]?(o=d[2],l=d[3]):l===d[3]&&(o=h(o,d[2]))),i=c,n=u}const c=this.#Ka;c[0]=s[0]-this.#Ma,c[1]=s[1]-this.#Ma,c[2]=s[2]-s[0]+2*this.#Ma,c[3]=s[3]-s[1]+2*this.#Ma,this.firstPoint=[r,a],this.lastPoint=[o,l]}get box(){return this.#Ka}newOutliner(t,e,i,n,s,r=0){return new Ls(t,e,i,n,s,r)}getNewOutline(t,e){const[i,n,s,r]=this.#Ka,[a,o,l,h]=this.#Pa,d=s*l,c=r*h,u=i*l+a,p=n*h+o,g=this.newOutliner({x:this.#ja[0]*d+u,y:this.#ja[1]*c+p},this.#Pa,this.#Ba,t,this.#ka,e??this.#Ma);for(let t=2;t<this.#ja.length;t+=2)g.add({x:this.#ja[t]*d+u,y:this.#ja[t+1]*c+p});return g.getOutlines()}}class Ns{#Pa;#Ja;#to;#eo=[];#io=[];constructor(t,e=0,i=0,n=!0){const s=[1/0,1/0,-1/0,-1/0],r=10**-4;for(const{x:i,y:n,width:a,height:o}of t){const t=Math.floor((i-e)/r)*r,l=Math.ceil((i+a+e)/r)*r,h=Math.floor((n-e)/r)*r,d=Math.ceil((n+o+e)/r)*r,c=[t,h,d,!0],u=[l,h,d,!1];this.#eo.push(c,u),_t.rectBoundingBox(t,h,l,d,s)}const a=s[2]-s[0]+2*i,o=s[3]-s[1]+2*i,l=s[0]-i,h=s[1]-i;let d=n?-1/0:1/0,c=1/0;const u=this.#eo.at(n?-1:-2),p=[u[0],u[2]];for(const t of this.#eo){const[e,i,s,r]=t;!r&&n?i<c?(c=i,d=e):i===c&&(d=Math.max(d,e)):r&&!n&&(i<c?(c=i,d=e):i===c&&(d=Math.min(d,e))),t[0]=(e-l)/a,t[1]=(i-h)/o,t[2]=(s-h)/o}this.#Pa=new Float32Array([l,h,a,o]),this.#Ja=[d,c],this.#to=p}getOutlines(){this.#eo.sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of this.#eo)e[3]?(t.push(...this.#no(e)),this.#so(e)):(this.#ro(e),t.push(...this.#no(e)));return this.#ao(t)}#ao(t){const e=[],i=new Set;for(const i of t){const[t,n,s]=i;e.push([t,n,i],[t,s,i])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let t=0,n=e.length;t<n;t+=2){const n=e[t][2],s=e[t+1][2];n.push(s),s.push(n),i.add(n),i.add(s)}const n=[];let s;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(s=[e,a],n.push(s);;){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&&(s.push(h,d,e,d===r?r:a),h=e),d=d===r?a:r}s.push(h,d)}return new Fs(n,this.#Pa,this.#Ja,this.#to)}#oo(t){const e=this.#io;let i=0,n=e.length-1;for(;i<=n;){const s=i+n>>1,r=e[s][0];if(r===t)return s;r<t?i=s+1:n=s-1}return n+1}#so([,t,e]){const i=this.#oo(t);this.#io.splice(i,0,[t,e])}#ro([,t,e]){const i=this.#oo(t);for(let n=i;n<this.#io.length;n++){const[i,s]=this.#io[n];if(i!==t)break;if(i===t&&s===e)return void this.#io.splice(n,1)}for(let n=i-1;n>=0;n--){const[i,s]=this.#io[n];if(i!==t)break;if(i===t&&s===e)return void this.#io.splice(n,1)}}#no(t){const[e,i,n]=t,s=[[e,i,n]],r=this.#oo(n);for(let t=0;t<r;t++){const[i,n]=this.#io[t];for(let t=0,r=s.length;t<r;t++){const[,a,o]=s[t];if(!(n<=a||o<=i))if(a>=i)if(o>n)s[t][1]=n;else{if(1===r)return[];s.splice(t,1),t--,r--}else s[t][2]=i,o>n&&s.push([e,n,o])}}return s}}class Fs extends Is{#Pa;#lo;constructor(t,e,i,n){super(),this.#lo=t,this.#Pa=e,this.firstPoint=i,this.lastPoint=n}toSVGPath(){const t=[];for(const e of this.#lo){let[i,n]=e;t.push(`M${i} ${n}`);for(let s=2;s<e.length;s+=2){const r=e[s],a=e[s+1];r===i?(t.push(`V${a}`),n=a):a===n&&(t.push(`H${r}`),i=r)}t.push("Z")}return t.join(" ")}serialize([t,e,i,n],s){const r=[],a=i-t,o=n-e;for(const e of this.#lo){const i=new Array(e.length);for(let s=0;s<e.length;s+=2)i[s]=t+e[s]*a,i[s+1]=n-e[s+1]*o;r.push(i)}return r}get box(){return this.#Pa}get classNamesForOutlining(){return["highlightOutline"]}}class Bs extends Ls{newFreeDrawOutline(t,e,i,n,s,r){return new Os(t,e,i,n,s,r)}}class Os extends Rs{newOutliner(t,e,i,n,s,r=0){return new Bs(t,e,i,n,s,r)}}class js extends ye{#ho=null;#do=0;#co;#uo=null;#s=null;#po=null;#go=null;#mo=0;#fo=null;#bo=null;#C=null;#vo=!1;#Ja=null;#to=null;#wo=null;#ge="";#Oa;#yo="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=L.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=js.prototype;return ut(this,"_keyboardManager",new ge([[["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||js._defaultColor,this.#Oa=t.thickness||js._defaultThickness,this.opacity=t.opacity||js._defaultOpacity,this.#co=t.boxes||null,this.#yo=t.methodOfCreation||"",this.#ge=t.text||"",this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",t.highlightId>-1?(this.#vo=!0,this.#xo(t),this.#Ao()):this.#co&&(this.#ho=t.anchorNode,this.#do=t.anchorOffset,this.#go=t.focusNode,this.#mo=t.focusOffset,this.#So(),this.#Ao(),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}get telemetryInitialData(){return{action:"added",type:this.#vo?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:this.#Oa,methodOfCreation:this.#yo}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#So(){const t=new Ns(this.#co,.001);this.#bo=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#bo.box;const e=new Ns(this.#co,.0025,.001,"ltr"===this._uiManager.direction);this.#po=e.getOutlines();const{firstPoint:i}=this.#bo;this.#Ja=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height];const{lastPoint:n}=this.#po;this.#to=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#xo({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#bo=t;if(this.#po=t.getNewOutline(this.#Oa/2+1.5,.0025),e>=0)this.#C=e,this.#uo=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#wo=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#po.box,path:{d:this.#po.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#C,{bbox:js.#_o(this.#bo.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#wo,{bbox:js.#_o(this.#po.box,e),path:{d:this.#po.toSVGPath()}})}const[n,s,r,a]=t.box;switch(this.rotation){case 0:this.x=n,this.y=s,this.width=r,this.height=a;break;case 90:{const[t,e]=this.parentDimensions;this.x=s,this.y=1-n,this.width=r*e/t,this.height=a*t/e;break}case 180:this.x=1-n,this.y=1-s,this.width=r,this.height=a;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-s,this.y=n,this.width=r*e/t,this.height=a*t/e;break}}const{firstPoint:o}=t;this.#Ja=[(o[0]-n)/r,(o[1]-s)/a];const{lastPoint:l}=this.#po;this.#to=[(l[0]-n)/r,(l[1]-s)/a]}static initialize(t,e){ye.initialize(t,e),js._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case R.HIGHLIGHT_COLOR:js._defaultColor=e;break;case R.HIGHLIGHT_THICKNESS:js._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#to}get commentButtonPosition(){return this.#Ja}updateParams(t,e){switch(t){case R.HIGHLIGHT_COLOR:this.#ta(e);break;case R.HIGHLIGHT_THICKNESS:this.#Co(e)}}static get defaultPropertiesToUpdate(){return[[R.HIGHLIGHT_COLOR,js._defaultColor],[R.HIGHLIGHT_THICKNESS,js._defaultThickness]]}get propertiesToUpdate(){return[[R.HIGHLIGHT_COLOR,this.color||js._defaultColor],[R.HIGHLIGHT_THICKNESS,this.#Oa||js._defaultThickness],[R.HIGHLIGHT_FREE,this.#vo]]}onUpdatedColor(){this.parent?.drawLayer.updateProperties(this.#C,{root:{fill:this.color,"fill-opacity":this.opacity}}),this.#s?.updateColor(this.color),super.onUpdatedColor()}#ta(t){const e=(t,e)=>{this.color=t,this.opacity=e,this.onUpdatedColor()},i=this.color,n=this.opacity;this.addCommands({cmd:e.bind(this,t,js._defaultOpacity),undo:e.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)}#Co(t){const e=this.#Oa,i=t=>{this.#Oa=t,this.#Eo(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:R.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",this.#s=new qn({editor:this})]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#Po())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#Po())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#To(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ao(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#To():t&&(this.#Ao(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#Eo(t){this.#vo&&(this.#xo({highlightOutlines:this.#bo.getNewOutline(t/2)}),this.fixAndSetPosition(),this.setDims())}#To(){null!==this.#C&&this.parent&&(this.parent.drawLayer.remove(this.#C),this.#C=null,this.parent.drawLayer.remove(this.#wo),this.#wo=null)}#Ao(t=this.parent){null===this.#C&&(({id:this.#C,clipPathId:this.#uo}=t.drawLayer.draw({bbox:this.#bo.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:this.#vo},path:{d:this.#bo.toSVGPath()}},!1,!0)),this.#wo=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#vo},bbox:this.#po.box,path:{d:this.#po.toSVGPath()}},this.#vo),this.#fo&&(this.#fo.style.clipPath=this.#uo))}static#_o([t,e,i,n],s){switch(s){case 90:return[1-e-n,t,n,i];case 180:return[1-t-i,1-e-n,i,n];case 270:return[e,1-t-i,n,i]}return[t,e,i,n]}rotate(t){const{drawLayer:e}=this.parent;let i;this.#vo?(t=(t-this.rotation+360)%360,i=js.#_o(this.#bo.box,t)):i=js.#_o([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#C,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#wo,{bbox:js.#_o(this.#po.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#ge&&(t.setAttribute("aria-label",this.#ge),t.setAttribute("role","mark")),this.#vo?t.classList.add("free"):this.div.addEventListener("keydown",this.#Mo.bind(this),{signal:this._uiManager._signal});const e=this.#fo=document.createElement("div");return t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#uo,this.setDims(),he(this,this.#fo,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#wo,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#wo,{rootClass:{hovered:!1}})}#Mo(t){js._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#ko(!0);break;case 1:case 3:this.#ko(!1)}}#ko(t){if(!this.#ho)return;const e=window.getSelection();t?e.setPosition(this.#ho,this.#do):e.setPosition(this.#go,this.#mo)}select(){super.select(),this.#wo&&this.parent?.drawLayer.updateProperties(this.#wo,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#wo&&(this.parent?.drawLayer.updateProperties(this.#wo,{rootClass:{selected:!1}}),this.#vo||this.#ko(!1))}get _mustFixPosition(){return!this.#vo}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#C,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#wo,{rootClass:{hidden:!t}}))}#Po(){return this.#vo?this.rotation:0}#Do(){if(this.#vo)return null;const[t,e]=this.pageDimensions,[i,n]=this.pageTranslation,s=this.#co,r=new Float32Array(8*s.length);let a=0;for(const{x:o,y:l,width:h,height:d}of s){const s=o*t+i,c=(1-l)*e+n;r[a]=r[a+4]=s,r[a+1]=r[a+3]=c,r[a+2]=r[a+6]=s+h*t,r[a+5]=r[a+7]=c-d*e,a+=8}return r}#Io(t){return this.#bo.serialize(t,this.#Po())}static startHighlighting(t,e,{target:i,x:n,y:s}){const{x:r,y:a,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#Lo(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",$t,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",zt,{signal:d}),i.addEventListener("pointermove",this.#Ro.bind(this,t),{signal:d}),this._freeHighlight=new Bs({x:n,y:s},[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#Ro(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#Lo(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 n=null;if(t instanceof _s){const{data:{quadPoints:e,rect:i,rotation:s,id:r,color:a,opacity:o,popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:L.HIGHLIGHT,color:Array.from(a),opacity:o,quadPoints:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}else if(t instanceof Ss){const{data:{inkLists:e,rect:i,rotation:s,id:r,color:a,borderStyle:{rawWidth:o},popupRef:l,richText:h,contentsObj:d,creationDate:c,modificationDate:u},parent:{page:{pageNumber:p}}}=t;n=t={annotationType:L.HIGHLIGHT,color:Array.from(a),thickness:o,inkLists:e,boxes:null,pageIndex:p-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:l,richText:h,comment:d?.str||null,creationDate:c,modificationDate:u}}const{color:s,quadPoints:r,inkLists:a,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=_t.makeHexColor(...s),l.opacity=o||1,a&&(l.#Oa=t.thickness),l._initialData=n,t.comment&&l.setCommentData(t);const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(r){const t=l.#co=[];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.#So(),l.#Ao(),l.rotate(l.rotation)}else if(a){l.#vo=!0;const t=a[0],i={x:t[0]-c,y:d-(t[1]-u)},n=new Bs(i,[0,0,h,d],1,l.#Oa/2,!0,.001);for(let e=0,s=t.length;e<s;e+=2)i.x=t[e]-c,i.y=d-(t[e+1]-u),n.add(i);const{id:s,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:n.toSVGPath()}},!0,!0);l.#xo({highlightOutlines:n.getOutlines(),highlightId:s,clipPathId:r}),l.#Ao(),l.rotate(l.parentRotation)}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=ye._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i=super.serialize(t);return Object.assign(i,{color:e,opacity:this.opacity,thickness:this.#Oa,quadPoints:this.#Do(),outlines:this.#Io(i.rect)}),this.addComment(i),this.annotationElementId&&!this.#Ea(i)?null:(i.id=this.annotationElementId,i)}#Ea(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,i)=>t!==e[i])}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}}class Us{#No=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))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){this.#No[t]=e}toSVGProperties(){const t=this.#No;return this.#No=Object.create(null),{root:t}}reset(){this.#No=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){lt("Not implemented")}}class Vs extends ye{#Fo=null;#Bo;_colorPicker=null;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#Oo=null;static#jo=null;static#Uo=null;static _INNER_MARGIN=3;constructor(t){super(t),this.#Bo=t.mustBeCommitted||!1,this._addOutlines(t)}onUpdatedColor(){this._colorPicker?.update(this.color),super.onUpdatedColor()}_addOutlines(t){t.drawOutlines&&(this.#Vo(t),this.#Ao())}#Vo({drawOutlines:t,drawId:e,drawingOptions:i}){this.#Fo=t,this._drawingOptions||=i,this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Ho(t,this.parent),this.#zo(t.box)}#Ho(t,e){const{id:i}=e.drawLayer.draw(Vs._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return i}static _mergeSVGProperties(t,e){const i=new Set(Object.keys(t));for(const[n,s]of Object.entries(e))i.has(n)?Object.assign(t[n],s):t[n]=s;return t}static getDefaultDrawingOptions(t){lt("Not implemented")}static get typesMap(){lt("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&&(Vs.#Oo.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,n]of this.typesMap)t.push([i,e[n]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[i,n]of this.constructor.typesMap)t.push([i,e[n]]);return t}_updateProperty(t,e,i){const n=this._drawingOptions,s=n[e],r=i=>{n.updateProperty(e,i);const s=this.#Fo.updateProperty(e,i);s&&this.#zo(s),this.parent?.drawLayer.updateProperties(this._drawId,n.toSVGProperties()),t===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:r.bind(this,i),undo:r.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,Vs._mergeSVGProperties(this.#Fo.getPathResizingSVGProperties(this.#$o()),{bbox:this.#Wo()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Vs._mergeSVGProperties(this.#Fo.getPathResizedSVGProperties(this.#$o()),{bbox:this.#Wo()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Wo()})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,Vs._mergeSVGProperties(this.#Fo.getPathTranslatedSVGProperties(this.#$o(),this.parentDimensions),{bbox:this.#Wo()}))}_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(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#Bo&&(this.#Bo=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#To(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#Ao(),this.#zo(this.#Fo.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#To()):t&&(this._uiManager.addShouldRescale(this),this.#Ao(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#To(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#Ao(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Ho(this.#Fo,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Go([t,e,i,n]){const{parentDimensions:[s,r],rotation:a}=this;switch(a){case 90:return[e,1-t,i*(r/s),n*(s/r)];case 180:return[1-t,1-e,i,n];case 270:return[1-e,t,i*(r/s),n*(s/r)];default:return[t,e,i,n]}}#$o(){const{x:t,y:e,width:i,height:n,parentDimensions:[s,r],rotation:a}=this;switch(a){case 90:return[1-e,t,i*(s/r),n*(r/s)];case 180:return[1-t,1-e,i,n];case 270:return[e,1-t,i*(s/r),n*(r/s)];default:return[t,e,i,n]}}#zo(t){[this.x,this.y,this.width,this.height]=this.#Go(t),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()}#Wo(){const{x:t,y:e,width:i,height:n,rotation:s,parentRotation:r,parentDimensions:[a,o]}=this;switch((4*s+r)/90){case 1:return[1-e-n,t,n,i];case 2:return[1-t-i,1-e-n,i,n];case 3:return[e,1-t-i,n,i];case 4:return[t,e-i*(a/o),n*(o/a),i*(a/o)];case 5:return[1-e,t,i*(a/o),n*(o/a)];case 6:return[1-t-n*(o/a),1-e,n*(o/a),i*(a/o)];case 7:return[e-i*(a/o),1-t-n*(o/a),i*(a/o),n*(o/a)];case 8:return[t-i,e-n,i,n];case 9:return[1-e,t-i,n,i];case 10:return[1-t,1-e,i,n];case 11:return[e-n,1-t,n,i];case 12:return[t-n*(o/a),e,n*(o/a),i*(a/o)];case 13:return[1-e-i*(a/o),t-n*(o/a),i*(a/o),n*(o/a)];case 14:return[1-t,1-e-i*(a/o),n*(o/a),i*(a/o)];case 15:return[e,1-t,i*(a/o),n*(o/a)];default:return[t,e,i,n]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Vs._mergeSVGProperties({bbox:this.#Wo()},this.#Fo.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#zo(this.#Fo.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const i=super.render();i.classList.add("draw");const n=document.createElement("div");return i.append(n),n.setAttribute("aria-hidden","true"),n.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),i}static createDrawerInstance(t,e,i,n,s){lt("Not implemented")}static startDrawing(t,e,i,n){const{target:s,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=n;if(de.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:d,height:c}=s.getBoundingClientRect(),u=Vs.#jo=new AbortController,p=t.combinedSignal(u);de.setPointer(l,o),window.addEventListener("pointerup",t=>{de.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{de.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{de.isSamePointerType(t.pointerType)&&(de.initializeAndAddPointerId(t.pointerId),Vs.#Oo.isCancellable()&&(Vs.#Oo.removeLastElement(),Vs.#Oo.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",zt,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",t=>{de.isSameTimeStamp(t.timeStamp)&&$t(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),Vs.#Oo?t.drawLayer.updateProperties(this._currentDrawId,Vs.#Oo.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),Vs.#Oo=this.createDrawerInstance(r,a,d,c,h),Vs.#Uo=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Vs.#Uo.toSVGProperties(),Vs.#Oo.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(de.isSameTimeStamp(t.timeStamp),!Vs.#Oo)return;const{offsetX:e,offsetY:i,pointerId:n}=t;de.isSamePointerId(n)&&(de.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Vs.#Oo.add(e,i)),de.setTimeStamp(t.timeStamp),$t(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Vs.#Oo=null,Vs.#Uo=null,de.clearPointerType(),de.clearTimeStamp()),Vs.#jo&&(Vs.#jo.abort(),Vs.#jo=null,de.clearPointerIds())}static _endDraw(t){const e=this._currentParent;if(e){if(e.toggleDrawing(!0),this._cleanup(!1),t?.target===e.div&&e.drawLayer.updateProperties(this._currentDrawId,Vs.#Oo.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=Vs.#Oo,i=this._currentDrawId,n=t.getLastElement();return void e.addCommands({cmd:()=>{e.drawLayer.updateProperties(i,t.setLastElement(n))},undo:()=>{e.drawLayer.updateProperties(i,t.removeLastElement())},mustExec:!1,type:R.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(R.DRAW_STEP),!Vs.#Oo.isEmpty()){const{pageDimensions:[i,n],scale:s}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Vs.#Oo.getOutlines(i*s,n*s,s,this._INNER_MARGIN),drawingOptions:Vs.#Uo,mustBeCommitted:!t});return this._cleanup(!0),r}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,n,s,r){lt("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:n,pageHeight:s,pageX:r,pageY:a}}=e.viewport,o=this.deserializeDraw(r,a,n,s,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#Vo({drawOutlines:o}),l.#Ao(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[n,s]=this.pageDimensions;return this.#Fo.serialize([e,i,n,s],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}}class Hs{#Ia=new Float64Array(6);#oa;#qo;#ms;#Oa;#ja;#Xo="";#Yo=0;#lo=new zs;#Ko;#Qo;constructor(t,e,i,n,s,r){this.#Ko=i,this.#Qo=n,this.#ms=s,this.#Oa=r,[t,e]=this.#Zo(t,e);const a=this.#oa=[NaN,NaN,NaN,NaN,t,e];this.#ja=[t,e],this.#qo=[{line:a,points:this.#ja}],this.#Ia.set(a,0)}updateProperty(t,e){"stroke-width"===t&&(this.#Oa=e)}#Zo(t,e){return Is._normalizePoint(t,e,this.#Ko,this.#Qo,this.#ms)}isEmpty(){return!this.#qo||0===this.#qo.length}isCancellable(){return this.#ja.length<=10}add(t,e){[t,e]=this.#Zo(t,e);const[i,n,s,r]=this.#Ia.subarray(2,6),a=t-s,o=e-r;return Math.hypot(this.#Ko*a,this.#Qo*o)<=2?null:(this.#ja.push(t,e),isNaN(i)?(this.#Ia.set([s,r,t,e],2),this.#oa.push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(this.#Ia[0])&&this.#oa.splice(6,6),this.#Ia.set([i,n,s,r,t,e],0),this.#oa.push(...Is.createBezierPoints(i,n,s,r,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ja.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,s){this.#Ko=i,this.#Qo=n,this.#ms=s,[t,e]=this.#Zo(t,e);const r=this.#oa=[NaN,NaN,NaN,NaN,t,e];this.#ja=[t,e];const a=this.#qo.at(-1);return a&&(a.line=new Float32Array(a.line),a.points=new Float32Array(a.points)),this.#qo.push({line:r,points:this.#ja}),this.#Ia.set(r,0),this.#Yo=0,this.toSVGPath(),null}getLastElement(){return this.#qo.at(-1)}setLastElement(t){return this.#qo?(this.#qo.push(t),this.#oa=t.line,this.#ja=t.points,this.#Yo=0,{path:{d:this.toSVGPath()}}):this.#lo.setLastElement(t)}removeLastElement(){if(!this.#qo)return this.#lo.removeLastElement();this.#qo.pop(),this.#Xo="";for(let t=0,e=this.#qo.length;t<e;t++){const{line:e,points:i}=this.#qo[t];this.#oa=e,this.#ja=i,this.#Yo=0,this.toSVGPath()}return{path:{d:this.#Xo}}}toSVGPath(){const t=Is.svgRound(this.#oa[4]),e=Is.svgRound(this.#oa[5]);if(2===this.#ja.length)return this.#Xo=`${this.#Xo} M ${t} ${e} Z`,this.#Xo;if(this.#ja.length<=6){const i=this.#Xo.lastIndexOf("M");this.#Xo=`${this.#Xo.slice(0,i)} M ${t} ${e}`,this.#Yo=6}if(4===this.#ja.length){const t=Is.svgRound(this.#oa[10]),e=Is.svgRound(this.#oa[11]);return this.#Xo=`${this.#Xo} L ${t} ${e}`,this.#Yo=12,this.#Xo}const i=[];0===this.#Yo&&(i.push(`M ${t} ${e}`),this.#Yo=6);for(let t=this.#Yo,e=this.#oa.length;t<e;t+=6){const[e,n,s,r,a,o]=this.#oa.slice(t,t+6).map(Is.svgRound);i.push(`C${e} ${n} ${s} ${r} ${a} ${o}`)}return this.#Xo+=i.join(" "),this.#Yo=this.#oa.length,this.#Xo}getOutlines(t,e,i,n){const s=this.#qo.at(-1);return s.line=new Float32Array(s.line),s.points=new Float32Array(s.points),this.#lo.build(this.#qo,t,e,i,this.#ms,this.#Oa,n),this.#Ia=null,this.#oa=null,this.#qo=null,this.#Xo=null,this.#lo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class zs extends Is{#Ka;#Jo=0;#Ma;#qo;#Ko;#Qo;#tl;#ms;#Oa;build(t,e,i,n,s,r,a){this.#Ko=e,this.#Qo=i,this.#tl=n,this.#ms=s,this.#Oa=r,this.#Ma=a??0,this.#qo=t,this.#el()}get thickness(){return this.#Oa}setLastElement(t){return this.#qo.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#qo.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#qo)if(t.push(`M${Is.svgRound(e[4])} ${Is.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Is.svgRound(e[10])} ${Is.svgRound(e[11])}`);else for(let i=6,n=e.length;i<n;i+=6){const[n,s,r,a,o,l]=e.subarray(i,i+6).map(Is.svgRound);t.push(`C${n} ${s} ${r} ${a} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,i,n],s){const r=[],a=[],[o,l,h,d]=this.#il();let c,u,p,g,m,f,b,v,w;switch(this.#ms){case 0:w=Is._rescale,c=t,u=e+n,p=i,g=-n,m=t+o*i,f=e+(1-l-d)*n,b=t+(o+h)*i,v=e+(1-l)*n;break;case 90:w=Is._rescaleAndSwap,c=t,u=e,p=i,g=n,m=t+l*i,f=e+o*n,b=t+(l+d)*i,v=e+(o+h)*n;break;case 180:w=Is._rescale,c=t+i,u=e,p=-i,g=n,m=t+(1-o-h)*i,f=e+l*n,b=t+(1-o)*i,v=e+(l+d)*n;break;case 270:w=Is._rescaleAndSwap,c=t+i,u=e+n,p=-i,g=-n,m=t+(1-l-d)*i,f=e+(1-o-h)*n,b=t+(1-l)*i,v=e+(1-o)*n}for(const{line:t,points:e}of this.#qo)r.push(w(t,c,u,p,g,s?new Array(t.length):null)),a.push(w(e,c,u,p,g,s?new Array(e.length):null));return{lines:r,points:a,rect:[m,f,b,v]}}static deserialize(t,e,i,n,s,{paths:{lines:r,points:a},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=Is._rescale,d=-t/i,c=e/n+1,u=1/i,p=-1/n;break;case 90:g=Is._rescaleAndSwap,d=-e/n,c=-t/i,u=1/n,p=1/i;break;case 180:g=Is._rescale,d=t/i+1,c=-e/n,u=-1/i,p=1/n;break;case 270:g=Is._rescaleAndSwap,d=e/n+1,c=t/i+1,u=-1/n,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[n,s,a,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,n,s],0);for(let r=4;r<e;r+=2){const e=t[r],l=t[r+1];i.set(Is.createBezierPoints(n,s,a,o,e,l),3*(r-2)),[n,s,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 m=new this.prototype.constructor;return m.build(h,i,n,1,o,l,s),m}#nl(t=this.#Oa){const e=this.#Ma+t/2*this.#tl;return this.#ms%180==0?[e/this.#Ko,e/this.#Qo]:[e/this.#Qo,e/this.#Ko]}#il(){const[t,e,i,n]=this.#Ka,[s,r]=this.#nl(0);return[t+s,e+r,i-2*s,n-2*r]}#el(){const t=this.#Ka=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#qo){if(e.length<=12){for(let i=4,n=e.length;i<n;i+=6)_t.pointBoundingBox(e[i],e[i+1],t);continue}let i=e[4],n=e[5];for(let s=6,r=e.length;s<r;s+=6){const[r,a,o,l,h,d]=e.subarray(s,s+6);_t.bezierBoundingBox(i,n,r,a,o,l,h,d,t),i=h,n=d}}const[e,i]=this.#nl();t[0]=Mt(t[0]-e,0,1),t[1]=Mt(t[1]-i,0,1),t[2]=Mt(t[2]+e,0,1),t[3]=Mt(t[3]+i,0,1),t[2]-=t[0],t[3]-=t[1]}get box(){return this.#Ka}updateProperty(t,e){return"stroke-width"===t?this.#Co(e):null}#Co(t){const[e,i]=this.#nl();this.#Oa=t;const[n,s]=this.#nl(),[r,a]=[n-e,s-i],o=this.#Ka;return o[0]-=r,o[1]-=a,o[2]+=2*r,o[3]+=2*a,o}updateParentDimensions([t,e],i){const[n,s]=this.#nl();this.#Ko=t,this.#Qo=e,this.#tl=i;const[r,a]=this.#nl(),o=r-n,l=a-s,h=this.#Ka;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Jo=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#Ka.map(Is.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Ka;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Is.svgRound(t)} ${Is.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#Ka;let i=0,n=0,s=0,r=0,a=0,o=0;switch(this.#Jo){case 90:n=e/t,s=-t/e,a=t;break;case 180:i=-1,r=-1,a=t,o=e;break;case 270:n=-e/t,s=t/e,o=e;break;default:return""}return`matrix(${i} ${n} ${s} ${r} ${Is.svgRound(a)} ${Is.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,n]){const[s,r]=this.#nl(),[a,o,l,h]=this.#Ka;if(Math.abs(l-s)<=Is.PRECISION||Math.abs(h-r)<=Is.PRECISION){const s=t+i/2-(a+l/2),r=e+n/2-(o+h/2);return{path:{"transform-origin":`${Is.svgRound(t)} ${Is.svgRound(e)}`,transform:`${this.rotationTransform} translate(${s} ${r})`}}}const d=(i-2*s)/(l-2*s),c=(n-2*r)/(h-2*r),u=l/i,p=h/n;return{path:{"transform-origin":`${Is.svgRound(a)} ${Is.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Is.svgRound(s)} ${Is.svgRound(r)}) scale(${d} ${c}) translate(${Is.svgRound(-s)} ${Is.svgRound(-r)})`}}}getPathResizedSVGProperties([t,e,i,n]){const[s,r]=this.#nl(),a=this.#Ka,[o,l,h,d]=a;if(a[0]=t,a[1]=e,a[2]=i,a[3]=n,Math.abs(h-s)<=Is.PRECISION||Math.abs(d-r)<=Is.PRECISION){const s=t+i/2-(o+h/2),r=e+n/2-(l+d/2);for(const{line:t,points:e}of this.#qo)Is._translate(t,s,r,t),Is._translate(e,s,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Is.svgRound(t)} ${Is.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*s)/(h-2*s),u=(n-2*r)/(d-2*r),p=-c*(o+s)+t+s,g=-u*(l+r)+e+r;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#qo)Is._rescale(t,p,g,c,u,t),Is._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Is.svgRound(t)} ${Is.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[n,s]=i,r=this.#Ka,a=t-r[0],o=e-r[1];if(this.#Ko===n&&this.#Qo===s)for(const{line:t,points:e}of this.#qo)Is._translate(t,a,o,t),Is._translate(e,a,o,e);else{const t=this.#Ko/n,e=this.#Qo/s;this.#Ko=n,this.#Qo=s;for(const{line:i,points:n}of this.#qo)Is._rescale(i,a,o,t,e,i),Is._rescale(n,a,o,t,e,n);r[2]*=t,r[3]*=e}return r[0]=t,r[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Is.svgRound(t)} ${Is.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Ka;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Is.svgRound(t[0])} ${Is.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class $s extends Us{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ye._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._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new $s(this._viewParameters);return t.updateAll(this),t}}class Ws extends Vs{static _type="ink";static _editorType=L.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){ye.initialize(t,e),this._defaultDrawingOptions=new $s(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return ut(this,"typesMap",new Map([[R.INK_THICKNESS,"stroke-width"],[R.INK_COLOR,"stroke"],[R.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,n,s){return new Hs(t,e,i,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,n,s,r){return zs.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){let n=null;if(t instanceof Ss){const{data:{inkLists:e,rect:i,rotation:s,id:r,color:a,opacity:o,borderStyle:{rawWidth:l},popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},parent:{page:{pageNumber:g}}}=t;n=t={annotationType:L.INK,color:Array.from(a),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:g-1,rect:i.slice(0),rotation:s,annotationElementId:r,id:r,deleted:!1,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}const s=await super.deserialize(t,e,i);return s._initialData=n,t.comment&&s.setCommentData(t),s}get toolbarButtons(){return this._colorPicker||=new Xn(this),[["colorPicker",this._colorPicker]]}get colorType(){return R.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}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=Ws.getDefaultDrawingOptions({stroke:_t.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}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":s,"stroke-width":r}}=this,a=Object.assign(super.serialize(t),{color:ye._colorManager.convert(n),opacity:s,thickness:r,paths:{lines:e,points:i}});return this.addComment(a),t?(a.isCopy=!0,a):this.annotationElementId&&!this.#Ea(a)?null:(a.id=this.annotationElementId,a)}#Ea(t){const{color:e,thickness:i,opacity:n,pageIndex:s}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,i)=>t!==e[i])||t.thickness!==i||t.opacity!==n||t.pageIndex!==s}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;const{points:e,rect:i}=this.serializeDraw(!1);return t.updateEdited({rect:i,thickness:this._drawingOptions["stroke-width"],points:e,popup:this.comment}),null}}class Gs extends zs{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}let qs=class{static#sl={maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16};static#rl(t,e,i,n){return n-=e,0===(i-=t)?n>0?0:4:1===i?n+6:2-n}static#al=new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]);static#ol(t,e,i,n,s,r,a){const o=this.#rl(i,n,s,r);for(let s=0;s<8;s++){const r=(-s+o-a+16)%8;if(0!==t[(i+this.#al[2*r])*e+(n+this.#al[2*r+1])])return r}return-1}static#ll(t,e,i,n,s,r,a){const o=this.#rl(i,n,s,r);for(let s=0;s<8;s++){const r=(s+o+a+16)%8;if(0!==t[(i+this.#al[2*r])*e+(n+this.#al[2*r+1])])return r}return-1}static#hl(t,e,i,n){const s=t.length,r=new Int32Array(s);for(let e=0;e<s;e++)r[e]=t[e]<=n?1:0;for(let t=1;t<i-1;t++)r[t*e]=r[t*e+e-1]=0;for(let t=0;t<e;t++)r[t]=r[e*i-1-t]=0;let a,o=1;const l=[];for(let t=1;t<i-1;t++){a=1;for(let i=1;i<e-1;i++){const n=t*e+i,s=r[n];if(0===s)continue;let h=t,d=i;if(1===s&&0===r[n-1])o+=1,d-=1;else{if(!(s>=1&&0===r[n+1])){1!==s&&(a=Math.abs(s));continue}o+=1,d+=1,s>1&&(a=s)}const c=[i,t],u=d===i+1,p={isHole:u,points:c,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===a){g=t;break}g?g.isHole?p.parent=u?g.parent:a:p.parent=u?a:g.parent:p.parent=u?a:0;const m=this.#ol(r,e,t,i,h,d,0);if(-1===m){r[n]=-o,1!==r[n]&&(a=Math.abs(r[n]));continue}let f=this.#al[2*m],b=this.#al[2*m+1];const v=t+f,w=i+b;h=v,d=w;let y=t,x=i;for(;;){const s=this.#ll(r,e,y,x,h,d,1);f=this.#al[2*s],b=this.#al[2*s+1];const l=y+f,u=x+b;c.push(u,l);const p=y*e+x;if(0===r[p+1]?r[p]=-o:1===r[p]&&(r[p]=o),l===t&&u===i&&y===v&&x===w){1!==r[n]&&(a=Math.abs(r[n]));break}h=y,d=x,y=l,x=u}}}return l}static#dl(t,e,i,n){if(i-e<=4){for(let s=e;s<i-2;s+=2)n.push(t[s],t[s+1]);return}const s=t[e],r=t[e+1],a=t[i-4]-s,o=t[i-3]-r,l=Math.hypot(a,o),h=a/l,d=o/l,c=h*r-d*s,u=o/a,p=1/l,g=Math.atan(u),m=Math.cos(g),f=Math.sin(g),b=p*(Math.abs(m)+Math.abs(f)),v=p*(1-b+b**2),w=Math.max(Math.atan(Math.abs(f+m)*v),Math.atan(Math.abs(f-m)*v));let y=0,x=e;for(let n=e+2;n<i-2;n+=2){const e=Math.abs(c-h*t[n+1]+d*t[n]);e>y&&(x=n,y=e)}y>(l*w)**2?(this.#dl(t,e,x+2,n),this.#dl(t,x,i,n)):n.push(s,r)}static#cl(t){const e=[],i=t.length;return this.#dl(t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e}static#ul(t,e,i,n,s,r){const a=new Float32Array(r**2),o=-2*n**2,l=r>>1;for(let t=0;t<r;t++){const e=(t-l)**2;for(let i=0;i<r;i++)a[t*r+i]=Math.exp((e+(i-l)**2)/o)}const h=new Float32Array(256),d=-2*s**2;for(let t=0;t<256;t++)h[t]=Math.exp(t**2/d);const c=t.length,u=new Uint8Array(c),p=new Uint32Array(256);for(let n=0;n<i;n++)for(let s=0;s<e;s++){const o=n*e+s,d=t[o];let c=0,g=0;for(let o=0;o<r;o++){const u=n+o-l;if(!(u<0||u>=i))for(let i=0;i<r;i++){const n=s+i-l;if(n<0||n>=e)continue;const p=t[u*e+n],m=a[o*r+i]*h[Math.abs(p-d)];c+=p*m,g+=m}}p[u[o]=Math.round(c/g)]++}return[u,p]}static#pl(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e}static#gl(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let n=-1/0,s=1/0;for(let e=0,r=i.length;e<r;e++){const r=i[e]=t[e<<2];n=Math.max(n,r),s=Math.min(s,r)}const r=255/(n-s);for(let t=0,e=i.length;t<e;t++)i[t]=(i[t]-s)*r;return i}static#ml(t){let e,i=-1/0,n=-1/0;const s=t.findIndex(t=>0!==t);let r=s,a=s;for(e=s;e<256;e++){const s=t[e];s>i&&(e-r>n&&(n=e-r,a=e-1),i=s,r=e)}for(e=a-1;e>=0&&!(t[e]>t[e+1]);e--);return e}static#fl(t){const e=t,{width:i,height:n}=t,{maxDim:s}=this.#sl;let r=i,a=n;if(i>s||n>s){let o=i,l=n,h=Math.log2(Math.max(i,n)/s);const d=Math.floor(h);h=h===d?d-1:d;for(let i=0;i<h;i++){r=Math.ceil(o/2),a=Math.ceil(l/2);const i=new OffscreenCanvas(r,a);i.getContext("2d").drawImage(t,0,0,o,l,0,0,r,a),o=r,l=a,t!==e&&t.close(),t=i.transferToImageBitmap()}const c=Math.min(s/r,s/a);r=Math.round(r*c),a=Math.round(a*c)}const o=new OffscreenCanvas(r,a).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,r,a),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,r,a);const l=o.getImageData(0,0,r,a).data;return[this.#gl(l),r,a]}static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:n},s,r,a,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const d=h.font=`${i} ${n} 200px ${e}`,{actualBoundingBoxLeft:c,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:m,fontBoundingBoxDescent:f,width:b}=h.measureText(t),v=1.5,w=Math.ceil(Math.max(Math.abs(c)+Math.abs(u)||0,b)*v),y=Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(m)+Math.abs(f)||200)*v);l=new OffscreenCanvas(w,y),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=d,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,w,y),h.fillStyle="black",h.fillText(t,.5*w/2,1.5*y/2);const x=this.#gl(h.getImageData(0,0,w,y).data),A=this.#pl(x),S=this.#ml(A),_=this.#hl(x,w,y,S);return this.processDrawnLines({lines:{curves:_,width:w,height:y},pageWidth:s,pageHeight:r,rotation:a,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,i,n,s){const[r,a,o]=this.#fl(t),[l,h]=this.#ul(r,a,o,Math.hypot(a,o)*this.#sl.sigmaSFactor,this.#sl.sigmaR,this.#sl.kernelSize),d=this.#ml(h),c=this.#hl(l,a,o,d);return this.processDrawnLines({lines:{curves:c,width:a,height:o},pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:s,mustSmooth:r,areContours:a}){n%180!=0&&([e,i]=[i,e]);const{curves:o,width:l,height:h}=t,d=t.thickness??0,c=[],u=Math.min(e/l,i/h),p=u/e,g=u/i,m=[];for(const{points:t}of o){const e=r?this.#cl(t):t;if(!e)continue;m.push(e);const i=e.length,n=new Float32Array(i),s=new Float32Array(3*(2===i?2:i-2));if(c.push({line:s,points:n}),2===i){n[0]=e[0]*p,n[1]=e[1]*g,s.set([NaN,NaN,NaN,NaN,n[0],n[1]],0);continue}let[a,o,l,h]=e;a*=p,o*=g,l*=p,h*=g,n.set([a,o,l,h],0),s.set([NaN,NaN,NaN,NaN,a,o],0);for(let t=4;t<i;t+=2){const i=n[t]=e[t]*p,r=n[t+1]=e[t+1]*g;s.set(Is.createBezierPoints(a,o,l,h,i,r),3*(t-2)),[a,o,l,h]=[l,h,i,r]}}if(0===c.length)return null;const f=a?new Gs:new zs;return f.build(c,e,i,1,n,a?0:d,s),{outline:f,newCurves:m,areContours:a,thickness:d,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:n,height:s}){let r,a=1/0,o=-1/0,l=0;for(const e of t){l+=e.length;for(let t=2,i=e.length;t<i;t++){const i=e[t]-e[t-2];a=Math.min(a,i),o=Math.max(o,i)}}r=a>=-128&&o<=127?Int8Array:a>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,d=8+3*h,c=new Uint32Array(d);let u=0;c[u++]=d*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*r.BYTES_PER_ELEMENT,c[u++]=0,c[u++]=n,c[u++]=s,c[u++]=e?0:1,c[u++]=Math.max(0,Math.floor(i??0)),c[u++]=h,c[u++]=r.BYTES_PER_ELEMENT;for(const e of t)c[u++]=e.length-2,c[u++]=e[0],c[u++]=e[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(c);const m=r.prototype.constructor;for(const e of t){const t=new m(e.length-2);for(let i=2,n=e.length;i<n;i++)t[i-2]=e[i]-e[i-2];g.write(t)}g.close();const f=await new Response(p.readable).arrayBuffer();return kt(new Uint8Array(f))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):xt(atob(e))),{readable:n,writable:s}=new DecompressionStream("deflate-raw"),r=s.getWriter();await r.ready,r.write(i).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const t of n)a||=new Uint8Array(new Uint32Array(t.buffer,0,4)[0]),a.set(t,o),o+=t.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const d=l[2],c=l[3],u=0===l[4],p=l[5],g=l[6],m=l[7],f=[],b=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let v;switch(m){case Int8Array.BYTES_PER_ELEMENT:v=new Int8Array(a.buffer,b);break;case Int16Array.BYTES_PER_ELEMENT:v=new Int16Array(a.buffer,b);break;case Int32Array.BYTES_PER_ELEMENT:v=new Int32Array(a.buffer,b)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],i=new Float32Array(e+2);f.push(i);for(let e=0;e<2;e++)i[e]=l[3*t+8+e+1];for(let t=0;t<e;t++)i[t+2]=i[t]+v[o++]}return{areContours:u,thickness:p,outlines:f,width:d,height:c}}catch(t){return ot(`decompressSignature: ${t}`),null}var e}};class Xs extends Us{constructor(){super(),super.updateProperties({fill:ye._defaultLineColor,"stroke-width":0})}clone(){const t=new Xs;return t.updateAll(this),t}}class Ys extends $s{constructor(t){super(t),super.updateProperties({stroke:ye._defaultLineColor,"stroke-width":1})}clone(){const t=new Ys(this._viewParameters);return t.updateAll(this),t}}class Ks extends Vs{#bl=!1;#vl=null;#wl=null;#yl=null;static _type="signature";static _editorType=L.SIGNATURE;static _defaultDrawingOptions=null;constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),this._willKeepAspectRatio=!0,this.#wl=t.signatureData||null,this.#vl=null,this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){ye.initialize(t,e),this._defaultDrawingOptions=new Xs,this._defaultDrawnSignatureOptions=new Ys(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return ut(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!this.#vl}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}render(){if(this.div)return this.div;let t,e;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,t=this.x,e=this.y),super.render(),null===this._drawId)if(this.#wl){const{lines:t,mustSmooth:e,areContours:i,description:n,uuid:s,heightInPage:r}=this.#wl,{rawDims:{pageWidth:a,pageHeight:o},rotation:l}=this.parent.viewport,h=qs.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:Ks._INNER_MARGIN,mustSmooth:e,areContours:i});this.addSignature(h,r,n,s)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:this.#vl||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(t,e)),this.div}setUuid(t){this.#yl=t,this.addEditToolbar()}getUuid(){return this.#yl}get description(){return this.#vl}set description(t){this.#vl=t,this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{e?.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:i,width:n,height:s}=this.#wl,r=Math.max(n,s);return{areContours:e,outline:qs.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:i,width:n,height:s},pageWidth:r,pageHeight:r,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(t,e,i,n){const{x:s,y:r}=this,{outline:a}=this.#wl=t;let o;this.#bl=a instanceof Gs,this.description=i,this.#bl?o=Ks.getDefaultDrawingOptions():(o=Ks._defaultDrawnSignatureOptions.clone(),o.updateProperties({"stroke-width":a.thickness})),this._addOutlines({drawOutlines:a,drawingOptions:o});const[,l]=this.pageDimensions;let h=e/l;h=h>=1?.5:h,this.width*=h/this.height,this.width>=1&&(h*=.9/this.width,this.width=.9),this.height=h,this.setDims(),this.x=s,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return qs.process(t,e,i,n,Ks._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:s}=this.parent.viewport;return qs.extractContoursFromText(t,e,i,n,s,Ks._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return qs.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:Ks._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Ks.getDefaultDrawingOptions():(this._drawingOptions=Ks._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":e}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,s=Object.assign(super.serialize(t),{isSignature:!0,areContours:this.#bl,color:[0,0,0],thickness:this.#bl?0:n});return this.addComment(s),t?(s.paths={lines:e,points:i},s.uuid=this.#yl,s.isCopy=!0):s.lines=e,this.#vl&&(s.accessibilityData={type:"Figure",alt:this.#vl}),s}static deserializeDraw(t,e,i,n,s,r){return r.areContours?Gs.deserialize(t,e,i,n,s,r):zs.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){const n=await super.deserialize(t,e,i);return n.#bl=t.areContours,n.description=t.accessibilityData?.alt||"",n.#yl=t.uuid,n}}class Qs extends ye{#xl=null;#Al=null;#Sl=null;#_l=null;#Cl=null;#El="";#Pl=null;#Tl=!1;#Ml=null;#kl=!1;#Dl=!1;static _type="stamp";static _editorType=L.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#_l=t.bitmapUrl,this.#Cl=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){ye.initialize(t,e)}static isHandlingMimeForPasting(t){return Zt.includes(t)}static paste(t,e){e.pasteEditor({mode:L.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}}#Il(t,e=!1){t?(this.#xl=t.bitmap,e||(this.#Al=t.id,this.#kl=t.isSvg),t.file&&(this.#El=t.file.name),this.#Ll()):this.remove()}#Rl(){if(this.#Sl=null,this._uiManager.enableWaiting(!1),this.#Pl)if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#xl)this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#xl){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:n,width:s,height:r}=t||this.copyCanvas(null,null,!0).imageData,a=await i.guess({name:"altText",request:{data:n,width:s,height:r,channels:n.length/(s*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}#Nl(){if(this.#Al)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#Al).then(t=>this.#Il(t,!0)).finally(()=>this.#Rl());if(this.#_l){const t=this.#_l;return this.#_l=null,this._uiManager.enableWaiting(!0),void(this.#Sl=this._uiManager.imageManager.getFromUrl(t).then(t=>this.#Il(t)).finally(()=>this.#Rl()))}if(this.#Cl){const t=this.#Cl;return this.#Cl=null,this._uiManager.enableWaiting(!0),void(this.#Sl=this._uiManager.imageManager.getFromFile(t).then(t=>this.#Il(t)).finally(()=>this.#Rl()))}const t=document.createElement("input");t.type="file",t.accept=Zt.join(",");const e=this._uiManager._signal;this.#Sl=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.#Il(e)}else this.remove();i()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),i()},{signal:e})}).finally(()=>this.#Rl()),t.click()}remove(){this.#Al&&(this.#xl=null,this._uiManager.imageManager.deleteId(this.#Al),this.#Pl?.remove(),this.#Pl=null,this.#Ml&&(clearTimeout(this.#Ml),this.#Ml=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#Al&&null===this.#Pl&&this.#Nl(),this.isAttachedToDOM||this.parent.add(this))):this.#Al&&this.#Nl()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Sl||this.#xl||this.#_l||this.#Cl||this.#Al||this.#Tl)}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),this.#Tl||(this.#xl?this.#Ll():this.#Nl()),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:i,bitmap:n}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(this.#Al=i,n&&(this.#xl=n),this.#Tl=!1,this.#Ll())}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==this.#Ml&&clearTimeout(this.#Ml);this.#Ml=setTimeout(()=>{this.#Ml=null,this.#Fl()},200)}#Ll(){const{div:t}=this;let{width:e,height:i}=this.#xl;const[n,s]=this.pageDimensions,r=.75;if(this.width)e=this.width*n,i=this.height*s;else if(e>r*n||i>r*s){const t=Math.min(r*n/e,r*s/i);e*=t,i*=t}this._uiManager.enableWaiting(!1);const a=this.#Pl=document.createElement("canvas");a.setAttribute("role","img"),this.addContainer(a),this.width=e/n,this.height=i/s,this.setDims(),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(t.hidden=!1),this.#Fl(),this.#Dl||(this.parent.addUndoableEditor(this),this.#Dl=!0),this._reportTelemetry({action:"inserted_image"}),this.#El&&this.div.setAttribute("aria-description",this.#El),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")}copyCanvas(t,e,i=!1){t||(t=224);const{width:n,height:s}=this.#xl,r=new Qt;let a=this.#xl,o=n,l=s,h=null;if(e){if(n>e||s>e){const t=Math.min(e/n,e/s);o=Math.floor(n*t),l=Math.floor(s*t)}h=document.createElement("canvas");const t=h.width=Math.ceil(o*r.sx),i=h.height=Math.ceil(l*r.sy);this.#kl||(a=this.#Bl(t,i));const d=h.getContext("2d");d.filter=this._uiManager.hcmFilter;let c="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":Jt.isDarkMode&&(c="#8f8f9d",u="#42414d");const p=15,g=p*r.sx,m=p*r.sy,f=new OffscreenCanvas(2*g,2*m),b=f.getContext("2d");b.fillStyle=c,b.fillRect(0,0,2*g,2*m),b.fillStyle=u,b.fillRect(0,0,g,m),b.fillRect(g,m,g,m),d.fillStyle=d.createPattern(f,"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.#xl,n>t||s>t){const r=Math.min(t/n,t/s);e=Math.floor(n*r),i=Math.floor(s*r),this.#kl||(a=this.#Bl(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}}#Bl(t,e){const{width:i,height:n}=this.#xl;let s=i,r=n,a=this.#xl;for(;s>2*t||r>2*e;){const i=s,n=r;s>2*t&&(s=s>=16384?Math.floor(s/2)-1:Math.ceil(s/2)),r>2*e&&(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}#Fl(){const[t,e]=this.parentDimensions,{width:i,height:n}=this,s=new Qt,r=Math.ceil(i*t*s.sx),a=Math.ceil(n*e*s.sy),o=this.#Pl;if(!o||o.width===r&&o.height===a)return;o.width=r,o.height=a;const l=this.#kl?this.#xl:this.#Bl(r,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,r,a)}#Ol(t){if(t){if(this.#kl){const t=this._uiManager.imageManager.getSvgUrl(this.#Al);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#xl);return t.getContext("2d").drawImage(this.#xl,0,0),t.toDataURL()}if(this.#kl){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*Rt.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*Rt.PDF_TO_CSS_UNITS),s=new OffscreenCanvas(i,n);return s.getContext("2d").drawImage(this.#xl,0,0,this.#xl.width,this.#xl.height,0,0,i,n),s.transferToImageBitmap()}return structuredClone(this.#xl)}static async deserialize(t,e,i){let n=null,s=!1;if(t instanceof Ts){const{data:{rect:r,rotation:a,id:o,structParent:l,popupRef:h,richText:d,contentsObj:c,creationDate:u,modificationDate:p},container:g,parent:{page:{pageNumber:m}},canvas:f}=t;let b,v;f?(delete t.canvas,({id:b,bitmap:v}=i.imageManager.getFromCanvas(g.id,f)),f.remove()):(s=!0,t._hasNoCanvas=!0);const w=(await e._structTree.getAriaAttributes(`${Tt}${o}`))?.get("aria-label")||"";n=t={annotationType:L.STAMP,bitmapId:b,bitmap:v,pageIndex:m-1,rect:r.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:w},isSvg:!1,structParent:l,popupRef:h,richText:d,comment:c?.str||null,creationDate:u,modificationDate:p}}const r=await super.deserialize(t,e,i),{rect:a,bitmap:o,bitmapUrl:l,bitmapId:h,isSvg:d,accessibilityData:c}=t;s?(i.addMissingCanvas(t.id,r),r.#Tl=!0):h&&i.imageManager.isValidId(h)?(r.#Al=h,o&&(r.#xl=o)):r.#_l=l,r.#kl=d;const[u,p]=r.pageDimensions;return r.width=(a[2]-a[0])/u,r.height=(a[3]-a[1])/p,c&&(r.altTextData=c),r._initialData=n,t.comment&&r.setCommentData(t),r.#Dl=!!n,r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=Object.assign(super.serialize(t),{bitmapId:this.#Al,isSvg:this.#kl});if(this.addComment(i),t)return i.bitmapUrl=this.#Ol(!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:n,altText:s}=this.serializeAltText(!1);if(!n&&s&&(i.accessibilityData={type:"Figure",alt:s}),this.annotationElementId){const t=this.#Ea(i);return t.isSame?null:(t.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1,i.id=this.annotationElementId,delete i.bitmapId,i)}if(null===e)return i;e.stamps||=new Map;const r=this.#kl?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#Al)){if(this.#kl){const t=e.stamps.get(this.#Al);r>t.area&&(t.area=r,t.serialized.bitmap.close(),t.serialized.bitmap=this.#Ol(!1))}}else e.stamps.set(this.#Al,{area:r,serialized:i}),i.bitmap=this.#Ol(!1);return i}#Ea(t){const{pageIndex:e,accessibilityData:{altText:i}}=this._initialData,n=t.pageIndex===e,s=(t.accessibilityData?.alt||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&s,isSameAltText:s}}renderAnnotationElement(t){return this.deleted?(t.hide(),null):(t.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}let Zs=class t{#jl;#Ul=!1;#Vl=null;#Hl=null;#zl=null;#$l=new Map;#Wl=!1;#Gl=!1;#ql=!1;#Xl=null;#Yl=null;#Kl=null;#Ql=null;#Zl=null;#Jl=-1;#b;static _initialized=!1;static#Y=new Map([Ds,Ws,Qs,js,Ks].map(t=>[t._editorType,t]));constructor({uiManager:e,pageIndex:i,div:n,structTreeLayer:s,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#Y.values()];if(!t._initialized){t._initialized=!0;for(const t of c)t.initialize(d,e)}e.registerEditorTypes(c),this.#b=e,this.pageIndex=i,this.div=n,this.#jl=r,this.#Vl=a,this.viewport=h,this.#Kl=l,this.drawLayer=o,this._structTree=s,this.#b.addLayer(this)}get isEmpty(){return 0===this.#$l.size}get isInvisible(){return this.isEmpty&&this.#b.getMode()===L.NONE}updateToolbar(t){this.#b.updateToolbar(t)}updateMode(e=this.#b.getMode()){switch(this.#th(),e){case L.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case L.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case L.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;if(i.toggle("nonEditing",!1),e===L.POPUP)i.toggle("commentEditing",!0);else{i.toggle("commentEditing",!1);for(const n of t.#Y.values())i.toggle(`${n._type}Editing`,e===n._editorType)}this.div.hidden=!1}hasTextLayer(t){return t===this.#Kl?.div}setEditingState(t){this.#b.setEditingState(t)}addCommands(t){this.#b.addCommands(t)}cleanUndoStack(t){this.#b.cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){this.#Vl?.togglePointerEvents(t)}get#eh(){return 0!==this.#$l.size?this.#$l.values():this.#b.getEditors(this.pageIndex)}async enable(){this.#ql=!0,this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),this.#Zl?.abort(),this.#Zl=null;const t=new Set;for(const e of this.#eh)e.enableEditing(),e.show(!0),e.annotationElementId&&(this.#b.removeChangedExistingAnnotation(e),t.add(e.annotationElementId));const e=this.#Vl;if(e)for(const i of e.getEditableAnnotations()){if(i.hide(),this.#b.isDeletedAnnotationElement(i.data.id))continue;if(t.has(i.data.id))continue;const e=await this.deserialize(i);e&&(this.addOrRebuild(e),e.enableEditing())}this.#ql=!1,this.#b._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){if(this.#Gl=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),this.#Kl&&!this.#Zl){this.#Zl=new AbortController;const t=this.#b.combinedSignal(this.#Zl);this.#Kl.div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:i,timeStamp:n}=t;if(n-this.#Jl>500)return void(this.#Jl=n);this.#Jl=-1;const{classList:s}=this.div;s.toggle("getElements",!0);const r=document.elementsFromPoint(e,i);if(s.toggle("getElements",!1),!this.div.contains(r[0]))return;let a;const o=new RegExp(`^${I}[0-9]+$`);for(const t of r)if(o.test(t.id)){a=t.id;break}if(!a)return;const l=this.#$l.get(a);null===l?.annotationElementId&&(t.stopPropagation(),t.preventDefault(),l.dblclick(t))},{signal:t,capture:!0})}const e=this.#Vl,i=[];if(e){const t=new Map,n=new Map;for(const e of this.#eh)e.disableEditing(),e.annotationElementId?null===e.serialize()?(n.set(e.annotationElementId,e),this.getEditableAnnotation(e.annotationElementId)?.show(),e.remove()):t.set(e.annotationElementId,e):i.push(e);const s=e.getEditableAnnotations();for(const e of s){const{id:i}=e.data;if(this.#b.isDeletedAnnotationElement(i)){e.updateEdited({deleted:!0});continue}let s=n.get(i);s?(s.resetAnnotationElement(e),s.show(!1),e.show()):(s=t.get(i),s&&(this.#b.addChangedExistingAnnotation(s),s.renderAnnotationElement(e)&&s.show(!1)),e.show())}}this.#th(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of t.#Y.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),e?.updateFakeAnnotations(i),this.#Gl=!1}getEditableAnnotation(t){return this.#Vl?.getEditableAnnotation(t)||null}setActiveEditor(t){this.#b.getActive()!==t&&this.#b.setActiveEditor(t)}enableTextSelection(){if(this.div.tabIndex=-1,this.#Kl?.div&&!this.#Ql){this.#Ql=new AbortController;const t=this.#b.combinedSignal(this.#Ql);this.#Kl.div.addEventListener("pointerdown",this.#ih.bind(this),{signal:t}),this.#Kl.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#Kl?.div&&this.#Ql&&(this.#Ql.abort(),this.#Ql=null,this.#Kl.div.classList.remove("highlighting"))}#ih(t){this.#b.unselectAll();const{target:e}=t;if(e===this.#Kl.div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&this.#Kl.div.contains(e)){const{isMac:e}=At.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#b.showAllEditors("highlight",!0,!0),this.#Kl.div.classList.add("free"),this.toggleDrawing(),js.startHighlighting(this,"ltr"===this.#b.direction,{target:this.#Kl.div,x:t.x,y:t.y}),this.#Kl.div.addEventListener("pointerup",()=>{this.#Kl.div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:this.#b._signal}),t.preventDefault()}}enableClick(){if(this.#Hl)return;this.#Hl=new AbortController;const t=this.#b.combinedSignal(this.#Hl);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){this.#Hl?.abort(),this.#Hl=null}attach(t){this.#$l.set(t.id,t);const{annotationElementId:e}=t;e&&this.#b.isDeletedAnnotationElement(e)&&this.#b.removeDeletedAnnotationElement(t)}detach(t){this.#$l.delete(t.id),this.#jl?.removePointerInTextLayer(t.contentDiv),!this.#Gl&&t.annotationElementId&&this.#b.addDeletedAnnotationElement(t)}remove(t){this.detach(t),this.#b.removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){t.parent!==this&&(t.parent&&t.annotationElementId&&(this.#b.addDeletedAnnotationElement(t.annotationElementId),ye.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.#b.addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!this.#ql),this.#b.addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!this.#zl&&(t._focusEventsAllowed=!1,this.#zl=setTimeout(()=>{this.#zl=null,t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this.#b._signal}),e.focus())},0)),t._structTreeParentId=this.#jl?.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})}getEditorByUID(t){for(const e of this.#$l.values())if(e.uid===t)return e;return null}getNextId(){return this.#b.getId()}get#nh(){return t.#Y.get(this.#b.getMode())}combinedSignal(t){return this.#b.combinedSignal(t)}#sh(t){const e=this.#nh;return e?new e.prototype.constructor(t):null}canCreateNewEmptyEditor(){return this.#nh?.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await this.#b.updateMode(t.mode);const{offsetX:i,offsetY:n}=this.#rh(),s=this.getNextId(),r=this.#sh({parent:this,id:s,x:i,y:n,uiManager:this.#b,isCentered:!0,...e});r&&this.add(r)}async deserialize(e){return await(t.#Y.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#b))||null}createAndAddNewEditor(t,e,i={}){const n=this.getNextId(),s=this.#sh({parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:this.#b,isCentered:e,...i});return s&&this.add(s),s}get boundingClientRect(){return this.div.getBoundingClientRect()}#rh(){const{x:t,y:e,width:i,height:n}=this.boundingClientRect,s=Math.max(0,t),r=Math.max(0,e),a=(s+Math.min(window.innerWidth,t+i))/2-t,o=(r+Math.min(window.innerHeight,e+n))/2-e,[l,h]=this.viewport.rotation%180==0?[a,o]:[o,a];return{offsetX:l,offsetY:h}}addNewEditor(t={}){this.createAndAddNewEditor(this.#rh(),!0,t)}setSelected(t){this.#b.setSelected(t)}toggleSelected(t){this.#b.toggleSelected(t)}unselect(t){this.#b.unselect(t)}pointerup(t){const{isMac:e}=At.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(!this.#Wl)return;if(this.#Wl=!1,this.#nh?.isDrawer&&this.#nh.supportMultipleDrawings)return;if(!this.#Ul)return void(this.#Ul=!0);const i=this.#b.getMode();i!==L.STAMP&&i!==L.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#b.unselectAll()}pointerdown(t){if(this.#b.getMode()===L.HIGHLIGHT&&this.enableTextSelection(),this.#Wl)return void(this.#Wl=!1);const{isMac:e}=At.platform;if(0!==t.button||t.ctrlKey&&e)return;if(t.target!==this.div)return;if(this.#Wl=!0,this.#nh?.isDrawer)return void this.startDrawingSession(t);const i=this.#b.getActive();this.#Ul=!i||i.isEmpty()}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),this.#Xl)return void this.#nh.startDrawing(this,this.#b,!1,t);this.#b.setCurrentDrawingSession(this),this.#Xl=new AbortController;const e=this.#b.combinedSignal(this.#Xl);this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(this.#Yl=null,this.commitOrRemove())},{signal:e}),this.#nh.startDrawing(this,this.#b,!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&(this.#Yl=t))}this.#Yl&&setTimeout(()=>{this.#Yl?.focus(),this.#Yl=null},0)}endDrawingSession(t=!1){return this.#Xl?(this.#b.setCurrentDrawingSession(null),this.#Xl.abort(),this.#Xl=null,this.#Yl=null,this.#nh.endDrawing(t)):null}findNewParent(t,e,i){const n=this.#b.findParent(e,i);return null!==n&&n!==this&&(n.changeParent(t),!0)}commitOrRemove(){return!!this.#Xl&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#Xl&&this.#nh.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#b.getActive()?.parent===this&&(this.#b.commitOrRemove(),this.#b.setActiveEditor(null)),this.#zl&&(clearTimeout(this.#zl),this.#zl=null);for(const t of this.#$l.values())this.#jl?.removePointerInTextLayer(t.contentDiv),t.setParent(null),t.isAttachedToDOM=!1,t.div.remove();this.div=null,this.#$l.clear(),this.#b.removeLayer(this)}#th(){for(const t of this.#$l.values())t.isEmpty()&&t.remove()}render({viewport:t}){this.viewport=t,Kt(this.div,t);for(const t of this.#b.getEditors(this.pageIndex))this.add(t),t.rebuild();this.updateMode()}update({viewport:t}){this.#b.commitOrRemove(),this.#th();const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Kt(this.div,{rotation:i}),e!==i)for(const t of this.#$l.values())t.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return this.#b.viewParameters.realScale}};globalThis._pdfjsTestingUtils={HighlightOutliner:Ns},globalThis.pdfjsLib={AbortException:wt,AnnotationEditorLayer:Zs,AnnotationEditorParamsType:R,AnnotationEditorType:L,AnnotationEditorUIManager:fe,AnnotationLayer:class t{#jl=null;#ah=null;#U=null;#oh=new Map;#lh=null;#hh=null;#jr=[];#dh=!1;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:s,viewport:r,structTreeLayer:a,commentManager:o,linkService:l,annotationStorage:h}){this.div=t,this.#jl=e,this.#ah=i,this.#lh=a||null,this.#hh=l||null,this.#U=h||new Pe,this.page=s,this.viewport=r,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=o||null}hasEditableAnnotations(){return this.#oh.size>0}async render(t){const{annotations:e}=t,i=this.div;Kt(i,this.viewport);const n=new Map,s=[],r={data:null,layer:i,linkService:this.#hh,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Jn,annotationStorage:this.#U,enableComment:!0===t.enableComment,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===$.POPUP;if(e){const e=n.get(t.id);if(!e)continue;if(!this._commentManager){s.push(t);continue}r.elements=e}else if(t.rect[2]===t.rect[0]||t.rect[3]===t.rect[1])continue;r.data=t;const i=is.create(r);if(!i.isRenderable)continue;if(!e&&(this.#jr.push(i),t.popupRef)){const e=n.get(t.popupRef);e?e.push(i):n.set(t.popupRef,[i])}const a=i.render();t.hidden&&(a.style.visibility="hidden"),i._isEditable&&(this.#oh.set(i.data.id,i),this._annotationEditorUIManager?.renderAnnotationElement(i))}await this.#ch();for(const t of s){const e=r.elements=n.get(t.id);r.data=t;const i=is.create(r);if(!i.isRenderable)continue;const s=i.render();i.contentElement.id=`${Tt}${t.id}`,t.hidden&&(s.style.visibility="hidden"),e.at(-1).container.after(s)}this.#uh()}async#ch(){if(0===this.#jr.length)return;this.div.replaceChildren();const t=[];if(!this.#dh){this.#dh=!0;for(const{contentElement:e,data:{id:i}}of this.#jr){const n=e.id=`${Tt}${i}`;t.push(this.#lh?.getAriaAttributes(n).then(t=>{if(t)for(const[i,n]of t)e.setAttribute(i,n)}))}}this.#jr.sort(({data:{rect:[t,e,i,n]}},{data:{rect:[s,r,a,o]}})=>{if(t===i&&e===n)return 1;if(s===a&&r===o)return-1;const l=(e+n)/2,h=(r+o)/2;if(l>=o&&h<=e)return-1;if(h>=n&&l<=r)return 1;return(t+i)/2-(s+a)/2});const e=document.createDocumentFragment();for(const t of this.#jr)e.append(t.container),this._commentManager?(t.extraPopupElement?.popup||t.popup)?.renderCommentButton():t.extraPopupElement&&e.append(t.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),this.#jl)for(const t of this.#jr)this.#jl.addPointerInTextLayer(t.contentElement,!1)}async addLinkAnnotations(e){const i={data:null,layer:this.div,linkService:this.#hh,svgFactory:new Jn,parent:this};for(const n of e){n.borderStyle||=t._defaultBorderStyle,i.data=n;const e=is.create(i);e.isRenderable&&(e.render(),e.contentElement.id=`${Tt}${n.id}`,this.#jr.push(e))}await this.#ch()}update({viewport:t}){const e=this.div;this.viewport=t,Kt(e,{rotation:t.rotation}),this.#uh(),e.hidden=!1}#uh(){if(!this.#ah)return;const t=this.div;for(const[e,i]of this.#ah){const n=t.querySelector(`[data-annotation-id="${e}"]`);if(!n)continue;i.className="annotationContent";const{firstChild:s}=n;s?"CANVAS"===s.nodeName?s.replaceWith(i):s.classList.contains("annotationContent")?s.after(i):s.before(i):n.append(i);const r=this.#oh.get(e);r&&(r._hasNoCanvas?(this._annotationEditorUIManager?.setMissingCanvas(e,n.id,i),r._hasNoCanvas=!1):r.canvas=i)}this.#ah.clear()}getEditableAnnotations(){return Array.from(this.#oh.values())}getEditableAnnotation(t){return this.#oh.get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:n}=t,s=new ss({data:{id:i,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:this.#hh,annotationStorage:this.#U});return s.render(),s.contentElement.id=`${Tt}${i}`,s.createOrUpdatePopup(),this.#jr.push(s),s}removeAnnotation(t){const e=this.#jr.findIndex(e=>e.data.id===t);if(e<0)return;const[i]=this.#jr.splice(e,1);this.#jl?.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(0!==t.length){for(const e of t)e.updateFakeAnnotationElement(this);this.#ch()}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return ut(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:W,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},AnnotationMode:D,AnnotationType:$,applyOpacity:function(t,e,i,n){const s=255*(1-(n=Math.min(Math.max(n??1,0),1)));return[t=Math.round(t*n+s),e=Math.round(e*n+s),i=Math.round(i*n+s)]},build:"2cc809ade",ColorPicker:qn,createValidAbsoluteUrl:dt,CSSConstants:class{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),ut(this,"commentForegroundColor",qt(i))}},DOMSVGFactory:Jn,DrawLayer:class t{#Ur=null;#ph=new Map;#gh=new Map;static#C=0;constructor({pageIndex:t}){this.pageIndex=t}setParent(t){if(this.#Ur){if(this.#Ur!==t){if(this.#ph.size>0)for(const e of this.#ph.values())e.remove(),t.append(e);this.#Ur=t}}else this.#Ur=t}static get _svgFactory(){return ut(this,"_svgFactory",new Jn)}static#mh(t,[e,i,n,s]){const{style:r}=t;r.top=100*i+"%",r.left=100*e+"%",r.width=100*n+"%",r.height=100*s+"%"}#fh(){const e=t._svgFactory.create(1,1,!0);return this.#Ur.append(e),e.setAttribute("aria-hidden",!0),e}#bh(e,i){const n=t._svgFactory.createElement("clipPath");e.append(n);const s=`clip_${i}`;n.setAttribute("id",s),n.setAttribute("clipPathUnits","objectBoundingBox");const r=t._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${i}`),r.classList.add("clip"),s}#vh(t,e){for(const[i,n]of Object.entries(e))null===n?t.removeAttribute(i):t.setAttribute(i,n)}draw(e,i=!1,n=!1){const s=t.#C++,r=this.#fh(),a=t._svgFactory.createElement("defs");r.append(a);const o=t._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${s}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),i&&this.#gh.set(s,o);const h=n?this.#bh(a,l):null,d=t._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(r,e),this.#ph.set(s,r),{id:s,clipPathId:`url(#${h})`}}drawOutline(e,i){const n=t.#C++,s=this.#fh(),r=t._svgFactory.createElement("defs");s.append(r);const a=t._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${n}`;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}_${n}`,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 s=t._svgFactory.createElement("use");e.append(s),s.setAttribute("href",`#${o}`),s.setAttribute("stroke","none"),s.setAttribute("fill","black"),s.setAttribute("fill-rule","nonzero"),s.classList.add("mask")}const h=t._svgFactory.createElement("use");s.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const d=h.cloneNode();return s.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(s,e),this.#ph.set(n,s),n}finalizeDraw(t,e){this.#gh.delete(t),this.updateProperties(t,e)}updateProperties(e,i){if(!i)return;const{root:n,bbox:s,rootClass:r,path:a}=i,o="number"==typeof e?this.#ph.get(e):e;if(o){if(n&&this.#vh(o,n),s&&t.#mh(o,s),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.#vh(t,a)}}}updateParent(t,e){if(e===this)return;const i=this.#ph.get(t);i&&(e.#Ur.append(i),this.#ph.delete(t),e.#ph.set(t,i))}remove(t){this.#gh.delete(t),null!==this.#Ur&&(this.#ph.get(t).remove(),this.#ph.delete(t))}destroy(){this.#Ur=null;for(const t of this.#ph.values())t.remove();this.#ph.clear(),this.#gh.clear()}},FeatureTest:At,fetchData:Nt,findContrastColor:function(t,e){const i=t[0]+256*t[1]+65536*t[2]+16777216*e[0]+4294967296*e[1]+1099511627776*e[2];let n=se.get(i);if(n)return n;const s=new Float32Array(9),r=s.subarray(0,3),a=s.subarray(3,6);te(t,a);const o=s.subarray(6,9);te(e,o);const l=o[2]<.5,h=l?12:4.5;if(a[2]=l?Math.sqrt(a[2]):1-Math.sqrt(1-a[2]),ne(a,o,r)<h){let t,e;l?(t=a[2],e=1):(t=0,e=a[2]);const i=.005;for(;e-t>i;){const i=a[2]=(t+e)/2;l===ne(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return ee(a,r),n=_t.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),se.set(i,n),n},getDocument:On,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:Ut,getRGB:qt,getUuid:Pt,getXfaPageViewport:Gt,GlobalWorkerOptions:ln,ImageKind:z,InvalidPDFException:ft,isDataScheme:Ot,isPdfFile:jt,isValidExplicitDest:Be,MathClamp:Mt,noContextMenu:zt,normalizeUnicode:function(t){return Ct||(Ct=/([\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,Et=new Map([["ſt","ſt"]])),t.replaceAll(Ct,(t,e,i)=>e?e.normalize("NFKC"):Et.get(i))},OPS:Q,OutputScale:Qt,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Un,PDFDateString:Wt,PDFWorker:zn,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},PixelsPerInch:Rt,RenderingCancelledException:Bt,renderRichText:re,ResponseException:bt,setLayerDimensions:Kt,shadow:ut,SignatureExtractor:qs,stopEvent:$t,SupportedImageMimeTypes:Zt,TextLayer:Bn,TouchManager:we,updateUrlHash:ct,Util:_t,VerbosityLevel:K,version:"5.4.394",XfaLayer:It};
33
+ /**
34
+ * @licstart The following is the entire license notice for the
35
+ * JavaScript code in this page
36
+ *
37
+ * Copyright 2024 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
+ const{AbortException:Js,AnnotationEditorLayer:tr,AnnotationEditorParamsType:er,AnnotationEditorType:ir,AnnotationEditorUIManager:nr,AnnotationLayer:sr,AnnotationMode:rr,AnnotationType:ar,applyOpacity:or,build:lr,ColorPicker:hr,createValidAbsoluteUrl:dr,CSSConstants:cr,DOMSVGFactory:ur,DrawLayer:pr,FeatureTest:gr,fetchData:mr,findContrastColor:fr,getDocument:br,getFilenameFromUrl:vr,getPdfFilenameFromUrl:wr,getRGB:yr,getUuid:xr,getXfaPageViewport:Ar,GlobalWorkerOptions:Sr,ImageKind:_r,InvalidPDFException:Cr,isDataScheme:Er,isPdfFile:Pr,isValidExplicitDest:Tr,MathClamp:Mr,noContextMenu:kr,normalizeUnicode:Dr,OPS:Ir,OutputScale:Lr,PasswordResponses:Rr,PDFDataRangeTransport:Nr,PDFDateString:Fr,PDFWorker:Br,PermissionFlag:Or,PixelsPerInch:jr,RenderingCancelledException:Ur,renderRichText:Vr,ResponseException:Hr,setLayerDimensions:zr,shadow:$r,SignatureExtractor:Wr,stopEvent:Gr,SupportedImageMimeTypes:qr,TextLayer:Xr,TouchManager:Yr,updateUrlHash:Kr,Util:Qr,VerbosityLevel:Zr,version:Jr,XfaLayer:ta}=globalThis.pdfjsLib,ea={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},ia=0,na=1,sa=2,ra=3,aa=0,oa=1,la=2,ha={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},da={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function ca(t,e,i=!1){let n=t.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=t.offsetTop+t.clientTop,r=t.offsetLeft+t.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;if(e&&(void 0!==e.top&&(s+=e.top),void 0!==e.left)){if(i){const i=t.getBoundingClientRect().width,s=Mr((n.clientWidth-i)/2,20,400);r+=e.left-s}else r+=e.left;n.scrollLeft=r}n.scrollTop=s}function ua(t){const e=new Map;for(const[i,n]of new URLSearchParams(t))e.set(i.toLowerCase(),n);return e}const pa=/[\x00-\x1F]/g;function ga(t,e=!1){return pa.test(t)?e?t.replaceAll(pa,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t}function ma(t,e,i=0){let n=i,s=t.length-1;if(s<0||!e(t[s]))return t.length;if(e(t[n]))return n;for(;n<s;){const i=n+s>>1;e(t[i])?s=i:n=i+1}return n}function fa(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 n,s=0,r=1,a=1,o=1;for(;;){const t=s+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(s=t,r=e)}return n=i-s/r<a/o-i?i===t?[s,r]:[r,s]:i===t?[a,o]:[o,a],n}function ba(t,e){return t-t%e}function va(t){return Number.isInteger(t)&&t%90==0}function wa(t){return t.width<=t.height}new Promise(function(t){window.requestAnimationFrame(t)});const ya=document.documentElement.style;const xa=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}(),Aa=0,Sa=1,_a=2,Ca=3,Ea=4,Pa=5,Ta=6,Ma=7;function ka(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)?Aa:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?Sa:_a:function(t){return 3584==(65408&t)}(t)?Ma:160===t?Aa:Sa:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Ca:function(t){return t>=12448&&t<=12543}(t)?Ea:function(t){return t>=12352&&t<=12447}(t)?Pa:function(t){return t>=65376&&t<=65439}(t)?Ta:Sa}let Da;const Ia={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},La={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},Ra=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 Na;const Fa=/\p{M}+/gu,Ba=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,Oa=/([^\p{M}])\p{M}*$/u,ja=/^\p{M}*([^\p{M}])/u,Ua=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Va=new Map,Ha=new Map;let za=null,$a=null;function Wa(t,e={}){const i=[];let n;for(;null!==(n=Ua.exec(t));){let{index:t}=n;for(const e of n[0]){let n=Va.get(e);n||(n=e.normalize("NFD").length,Va.set(e,n)),i.push([n,t++])}}const s=i.length>0,r=e.ignoreDashEOL??!1;let a;if(!s&&za)a=za;else if(s&&$a)a=$a;else{const t=Object.keys(La).join(""),e=(Da||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",Da);a=new RegExp([`[${t}]`,`[${e}]`,`${"(?:゙|゚)"}\\n`,"\\p{M}+(?:-\\n)?",`${"\\p{Ll}-\\n(?=\\p{Ll})|\\p{Lu}-\\n(?=\\p{L})"}`,"\\S-\\n",`${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n`,"\\n",s?"[\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f]":"\\u0000"].map(t=>`(${t})`).join("|"),"gum"),s?$a=a:za=a}const o=[];for(;null!==(n=Fa.exec(t));)o.push([n[0].length,n.index]);let l=t.normalize("NFD");const h=[0,0];let d=0,c=0,u=0,p=0,g=0,m=!1;l=l.replace(a,(t,e,n,s,a,l,f,b,v,w,y)=>{if(y-=p,e){const t=La[e],i=t.length;for(let t=1;t<i;t++)h.push(y-u+t,u-t);return u-=i-1,t}if(n){let t=Ha.get(n);t||(t=n.normalize("NFKC"),Ha.set(n,t));const e=t.length;for(let t=1;t<e;t++)h.push(y-u+t,u-t);return u-=e-1,t}if(s)return m=!0,y+g===o[d]?.[1]?++d:(h.push(y-1-u+1,u-1),u-=1,p+=1),h.push(y-u+1,u),p+=1,g+=1,s.charAt(0);if(a){const t=a.endsWith("\n"),e=t?a.length-2:a.length;m=!0;let i=e;y+g===o[d]?.[1]&&(i-=o[d][0],++d);for(let t=1;t<=i;t++)h.push(y-1-u+t,u-t);return u-=i,p+=i,t?(y+=e-1,h.push(y-u+1,1+u),u+=1,p+=1,g+=1,a.slice(0,e)):a}if(l){if(r)return p+=1,g+=1,l.slice(0,-1);const t=l.length-2;return h.push(y-u+t,1+u),u+=1,p+=1,g+=1,l.slice(0,-2)}if(f)return p+=1,g+=1,f.slice(0,-1);if(b){const t=b.length-1;return h.push(y-u+t,u),p+=1,g+=1,b.slice(0,-1)}if(v)return h.push(y-u+1,u-1),u-=1,p+=1,g+=1," ";if(y+g===i[c]?.[1]){const t=i[c][0]-1;++c;for(let e=1;e<=t;e++)h.push(y-(u-e),u-e);u-=t,p+=t}return w}),h.push(l.length,u);const f=new Uint32Array(h.length>>1),b=new Int32Array(h.length>>1);for(let t=0,e=h.length;t<e;t+=2)f[t>>1]=h[t],b[t>>1]=h[t+1];return[l,[f,b],m]}function Ga(t,e,i){if(!t)return[e,i];const[n,s]=t,r=e,a=e+i-1;let o=ma(n,t=>t>=r);n[o]>r&&--o;let l=ma(n,t=>t>=a,o);n[l]>a&&--l;const h=r+s[o];return[h,a+s[l]+1-h]}class qa{#wh=null;#yh=!0;#xh=0;constructor({linkService:t,eventBus:e,updateMatchesCountOnProgress:i=!0}){this._linkService=t,this._eventBus=e,this.#yh=i,this.onIsPageVisible=null,this.#Ah(),e._on("find",this.#Sh.bind(this)),e._on("findbarclose",this.#_h.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.#wh}setDocument(t){this._pdfDocument&&this.#Ah(),t&&(this._pdfDocument=t,this._firstPageCapability.resolve())}#Sh(t){if(!t)return;const e=this._pdfDocument,{type:i}=t;(null===this.#wh||this.#Ch(t))&&(this._dirtyMatch=!0),this.#wh=t,"highlightallchange"!==i&&this.#Eh(Ia.PENDING),this._firstPageCapability.promise.then(()=>{if(!this._pdfDocument||e&&this._pdfDocument!==e)return;this.#xa();const t=!this._highlightMatches,n=!!this._findTimeout;this._findTimeout&&(clearTimeout(this._findTimeout),this._findTimeout=null),i?this._dirtyMatch?this.#Ph():"again"===i?(this.#Ph(),t&&this.#wh.highlightAll&&this.#Th()):"highlightallchange"===i?(n?this.#Ph():this._highlightMatches=!0,this.#Th()):this.#Ph():this._findTimeout=setTimeout(()=>{this.#Ph(),this._findTimeout=null},250)})}scrollMatchIntoView({element:t=null,selectedLeft:e=0,pageIndex:i=-1,matchIndex:n=-1}){if(!this._scrollMatches||!t)return;if(-1===n||n!==this._selected.matchIdx)return;if(-1===i||i!==this._selected.pageIdx)return;this._scrollMatches=!1;ca(t,{top:-50,left:e},!0)}#Ah(){this._highlightMatches=!1,this._scrollMatches=!1,this._pdfDocument=null,this._pageMatches=[],this._pageMatchesLength=[],this.#xh=0,this.#wh=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#Mh(){const{query:t}=this.#wh;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=Wa(t)),this._normalizedQuery):(t||[]).filter(t=>!!t).map(t=>Wa(t)[0])}#Ch(t){const e=t.query,i=this.#wh.query,n=typeof e;if(n!==typeof i)return!0;if("string"===n){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}#kh(t,e,i){let n=t.slice(0,e).match(Oa);if(n){const i=t.charCodeAt(e),s=n[1].charCodeAt(0);if(ka(i)===ka(s))return!1}if(n=t.slice(e+i).match(ja),n){const s=t.charCodeAt(e+i-1),r=n[1].charCodeAt(0);if(ka(s)===ka(r))return!1}return!0}#Dh(t,e){const{matchDiacritics:i}=this.#wh;let n=!1;const s="[ ]*";return(t=t.replaceAll(Ba,(t,s,r,a,o,l)=>s?`[ ]*\\${s}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?Ra.has(o.charCodeAt(0))?o:"":e?(n=!0,`${l}\\p{M}*`):l)).endsWith(s)&&(t=t.slice(0,t.length-4)),i&&e&&(Na||=String.fromCharCode(...Ra),n=!0,t=`${t}(?=[${Na}]|[^\\p{M}]|$)`),[n,t]}#Ih(t){if(!this.#wh)return;const e=this.#Mh;if(0===e.length)return;const i=this._pageContents[t],n=this.match(e,i,t),s=this._pageMatches[t]=[],r=this._pageMatchesLength[t]=[],a=this._pageDiffs[t];n?.forEach(({index:t,length:e})=>{const[i,n]=Ga(a,t,e);n&&(s.push(i),r.push(n))}),this.#wh.highlightAll&&this.#Lh(t),this._resumePageIdx===t&&(this._resumePageIdx=null,this.#Rh());const o=s.length;this._matchesCountTotal+=o,this.#yh?o>0&&this.#Nh():++this.#xh===this._linkService.pagesCount&&this.#Nh()}match(t,e,i){const n=this._hasDiacritics[i];let s=!1;if("string"==typeof t?[s,t]=this.#Dh(t,n):t=t.sort().reverse().map(t=>{const[e,i]=this.#Dh(t,n);return s||=e,`(${i})`}).join("|"),!t)return;const{caseSensitive:r,entireWord:a}=this.#wh;t=new RegExp(t,`g${s?"u":""}${r?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)a&&!this.#kh(e,l.index,l[0].length)||o.push({index:l.index,length:l[0].length});return o}#xa(){if(this._extractTextPromises.length>0)return;let t=Promise.resolve();const e={disableNormalization:!0},i=this._pdfDocument;for(let n=0,s=this._linkService.pagesCount;n<s;n++){const{promise:s,resolve:r}=Promise.withResolvers();this._extractTextPromises[n]=s,t=t.then(async()=>{i===this._pdfDocument?await i.getPage(n+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[n],this._pageDiffs[n],this._hasDiacritics[n]]=Wa(e.join("")),r()},t=>{console.error(`Unable to get text content for page ${n+1}`,t),this._pageContents[n]="",this._pageDiffs[n]=null,this._hasDiacritics[n]=!1,r()}):r()})}}#Lh(t){this._scrollMatches&&this._selected.pageIdx===t&&(this._linkService.page=t+1),this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:t})}#Th(){this._eventBus.dispatch("updatetextlayermatches",{source:this,pageIndex:-1})}#Ph(){const t=this.#wh.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.#xh=0,this._matchesCountTotal=0,this.#Th();for(let t=0;t<i;t++)this._pendingFindMatches.has(t)||(this._pendingFindMatches.add(t),this._extractTextPromises[t].then(()=>{this._pendingFindMatches.delete(t),this.#Ih(t)}))}if(0===this.#Mh.length)return void this.#Eh(Ia.FOUND);if(this._resumePageIdx)return;const n=this._offset;if(this._pagesToSearch=i,null!==n.matchIdx){const e=this._pageMatches[n.pageIdx].length;if(!t&&n.matchIdx+1<e||t&&n.matchIdx>0)return n.matchIdx=t?n.matchIdx-1:n.matchIdx+1,void this.#Fh(!0);this.#Bh(t)}this.#Rh()}#Oh(t){const e=this._offset,i=t.length,n=this.#wh.findPrevious;return i?(e.matchIdx=n?i-1:0,this.#Fh(!0),!0):(this.#Bh(n),!!(e.wrapped&&(e.matchIdx=null,this._pagesToSearch<0))&&(this.#Fh(!1),!0))}#Rh(){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.#Oh(t))}#Bh(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)}#Fh(t=!1){let e=Ia.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?Ia.WRAPPED:Ia.FOUND,-1!==t&&t!==this._selected.pageIdx&&this.#Lh(t)}this.#Eh(e,this.#wh.findPrevious),-1!==this._selected.pageIdx&&(this._scrollMatches=!0,this.#Lh(this._selected.pageIdx))}#_h(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.#Eh(Ia.FOUND),this._highlightMatches=!1,this.#Th())})}#jh(){const{pageIdx:t,matchIdx:e}=this._selected;let i=0,n=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>n)&&(i=n=0),{current:i,total:n}}#Nh(){this._eventBus.dispatch("updatefindmatchescount",{source:this,matchesCount:this.#jh()})}#Eh(t,e=!1){(this.#yh||this.#xh===this._linkService.pagesCount&&t!==Ia.PENDING)&&this._eventBus.dispatch("updatefindcontrolstate",{source:this,state:t,previous:e,entireWord:this.#wh?.entireWord??null,matchesCount:this.#jh(),rawQuery:this.#wh?.query??null})}}const Xa={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Ya{externalLinkEnabled=!0;constructor({eventBus:t,externalLinkTarget:e=null,externalLinkRel:i=null,ignoreDestinationZoom:n=!1}={}){this.eventBus=t,this.externalLinkTarget=e,this.externalLinkRel=i,this._ignoreDestinationZoom=n,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,n;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[s]=i;if(s&&"object"==typeof s){if(n=this.pdfDocument.cachedPageNumber(s),!n)try{n=await this.pdfDocument.getPageIndex(s)+1}catch{return void console.error(`goToDestination: "${s}" is not a valid page reference, for dest="${t}".`)}}else Number.isInteger(s)&&(n=s+1);if(!n||n<1||n>this.pagesCount)return void console.error(`goToDestination: "${n}" is not a valid page number, for dest="${t}".`);this.pdfHistory&&(this.pdfHistory.pushCurrentPosition(),this.pdfHistory.push({namedDest:e,explicitDest:i,pageNumber:n})),this.pdfViewer.scrollPageIntoView({pageNumber:n,destArray:i,ignoreDestinationZoom:this._ignoreDestinationZoom});const r=new AbortController;this.eventBus._on("textlayerrendered",t=>{t.pageNumber===n&&(t.source.textLayer.div.focus(),r.abort())},{signal:r.signal})}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.`)}goToXY(t,e,i,n={}){this.pdfViewer.scrollPageIntoView({pageNumber:t,destArray:[null,{name:"XYZ"},e,i],ignoreDestinationZoom:!0,...n})}addLinkAttributes(t,e,i=!1){if(!e||"string"!=typeof e)throw new Error('A valid "url" parameter must provided.');const n=i?Xa.BLANK:this.externalLinkTarget,s=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let r="";switch(n){case Xa.NONE:break;case Xa.SELF:r="_self";break;case Xa.BLANK:r="_blank";break;case Xa.PARENT:r="_parent";break;case Xa.TOP:r="_top"}t.target=r,t.rel="string"==typeof s?s:"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 n=ua(t);if(n.has("search")){const t=n.get("search").replaceAll('"',""),e="true"===n.get("phrase");this.eventBus.dispatch("findfromurlhash",{source:this,query:e?t:t.match(/\S+/g)})}if(n.has("page")&&(e=0|n.get("page")||1),n.has("zoom")){const t=n.get("zoom").split(","),e=t[0],s=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,s?s/100:e]}return i?this.pdfViewer.scrollPageIntoView({pageNumber:e||this.page,destArray:i,allowNegativeOffset:!0}):e&&(this.page=e),n.has("pagemode")&&this.eventBus.dispatch("pagemode",{source:this,mode:n.get("pagemode")}),void(n.has("nameddest")&&this.goToDestination(n.get("nameddest")))}i=unescape(t);try{i=JSON.parse(i),Array.isArray(i)||(i=i.toString())}catch{}"string"==typeof i||Tr(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))}}class Ka extends Ya{setDocument(t,e=null){}}class Qa{#Uh=null;#z=null;#Vh=!1;#Hh=null;#zh=null;#$h=!1;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:n=null,imageResourcesPath:s="",renderForms:r=!0,enableComment:a=!1,commentManager:o=null,enableScripting:l=!1,hasJSActionsPromise:h=null,fieldObjectsPromise:d=null,annotationCanvasMap:c=null,accessibilityManager:u=null,annotationEditorUIManager:p=null,onAppend:g=null}){this.pdfPage=t,this.linkService=e,this.downloadManager=i,this.imageResourcesPath=s,this.renderForms=r,this.annotationStorage=n,this.enableComment=a,this.#z=o,this.enableScripting=l,this._hasJSActionsPromise=h||Promise.resolve(!1),this._fieldObjectsPromise=d||Promise.resolve(null),this._annotationCanvasMap=c,this._accessibilityManager=u,this._annotationEditorUIManager=p,this.#Hh=g,this.annotationLayer=null,this.div=null,this._cancelled=!1,this._eventBus=e.eventBus}async render({viewport:t,intent:e="display",structTreeLayer:i=null}){if(this.div){if(this._cancelled||!this.annotationLayer)return;return void this.annotationLayer.update({viewport:t.clone({dontFlip:!0})})}const[n,s,r]=await Promise.all([this.pdfPage.getAnnotations({intent:e}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const a=this.div=document.createElement("div");if(a.className="annotationLayer",this.#Hh?.(a),this.#Wh(t,i),0===n.length)return this.#Uh=n,void zr(this.div,t);await this.annotationLayer.render({annotations:n,imageResourcesPath:this.imageResourcesPath,renderForms:this.renderForms,downloadManager:this.downloadManager,enableComment:this.enableComment,enableScripting:this.enableScripting,hasJSActions:s,fieldObjects:r}),this.#Uh=n,this.linkService.isInPresentationMode&&this.#Gh(ra),this.#zh||(this.#zh=new AbortController,this._eventBus?._on("presentationmodechanged",t=>{this.#Gh(t.state)},{signal:this.#zh.signal}))}#Wh(t,e){this.annotationLayer=new sr({div:this.div,accessibilityManager:this._accessibilityManager,annotationCanvasMap:this._annotationCanvasMap,annotationEditorUIManager:this._annotationEditorUIManager,annotationStorage:this.annotationStorage,page:this.pdfPage,viewport:t.clone({dontFlip:!0}),structTreeLayer:e,commentManager:this.#z,linkService:this.linkService})}cancel(){this._cancelled=!0,this.#zh?.abort(),this.#zh=null}hide(t=!1){this.#Vh=!t,this.div&&(this.div.hidden=!0)}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}async injectLinkAnnotations(t){if(null===this.#Uh)throw new Error("`render` method must be called before `injectLinkAnnotations`.");if(this._cancelled||this.#$h)return;this.#$h=!0;const e=this.#Uh.length?this.#qh(t):t;e.length&&(await this.annotationLayer.addLinkAnnotations(e),this.#Vh||(this.div.hidden=!1))}#Gh(t){if(!this.div)return;let e=!1;switch(t){case ra:e=!0;break;case na:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}#qh(t){function e(t){if(!t.quadPoints)return[t.rect];const e=[];for(let i=2,n=t.quadPoints.length;i<n;i+=8){const n=t.quadPoints[i],s=t.quadPoints[i+1],r=t.quadPoints[i+2],a=t.quadPoints[i+3];e.push([r,a,n,s])}return e}function i(t,i){const n=[],s=e(t),r=e(i);for(const t of s)for(const e of r){const i=Qr.intersect(t,e);i&&n.push(i)}return n}function n(t){let e=0;for(const i of t)e+=Math.abs((i[2]-i[0])*(i[3]-i[1]));return e}return t.filter(t=>{let s;for(const r of this.#Uh){if(r.annotationType!==ar.LINK||!r.url)continue;const a=i(r,t);if(0!==a.length&&(s??=n(e(t)),n(a)/s>.5))return!1}return!0})}}function Za(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 Ja{#Xh=new WeakMap;downloadData(t,e,i){Za(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const n=Pr(e)?"application/pdf":"";return this.downloadData(t,e,n),!1}download(t,e,i){let n;if(t)n=URL.createObjectURL(new Blob([t],{type:"application/pdf"}));else{if(!dr(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);n=e+"#pdfjs.action=download"}Za(n,i)}}const to="event",eo="timeout";class io{#qi=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.#qi[t];if(!i||0===i.length)return;let n;for(const{listener:s,external:r,once:a}of i.slice(0))a&&this._off(t,s),r?(n||=[]).push(s):s(e);if(n){for(const t of n)t(e);n=null}}_on(t,e,i=null){let n=null;if(i?.signal instanceof AbortSignal){const{signal:s}=i;if(s.aborted)return void console.error("Cannot use an `aborted` signal.");const r=()=>this._off(t,e);n=()=>s.removeEventListener("abort",r),s.addEventListener("abort",r)}(this.#qi[t]||=[]).push({listener:e,external:!0===i?.external,once:!0===i?.once,rmAbort:n})}_off(t,e,i=null){const n=this.#qi[t];if(n)for(let t=0,i=n.length;t<i;t++){const i=n[t];if(i.listener===e)return i.rmAbort?.(),void n.splice(t,1)}}}class no{constructor(t){this.value=t}valueOf(){return this.value}}class so extends no{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class ro extends no{constructor(t,e={}){super(t),this.opts=e}toString(t){if(t)try{return t.memoizeIntlObject(Intl.NumberFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return this.value.toString(10)}}class ao extends no{static supportsValue(t){if("number"==typeof t)return!0;if(t instanceof Date)return!0;if(t instanceof no)return ao.supportsValue(t.valueOf());if("Temporal"in globalThis){const e=globalThis.Temporal;if(t instanceof e.Instant||t instanceof e.PlainDateTime||t instanceof e.PlainDate||t instanceof e.PlainMonthDay||t instanceof e.PlainTime||t instanceof e.PlainYearMonth)return!0}return!1}constructor(t,e={}){t instanceof ao?(e={...t.opts,...e},t=t.value):t instanceof no&&(t=t.valueOf()),"object"==typeof t&&"calendarId"in t&&void 0===e.calendar&&(e={...e,calendar:t.calendarId}),super(t),this.opts=e}[Symbol.toPrimitive](t){return"string"===t?this.toString():this.toNumber()}toNumber(){const t=this.value;if("number"==typeof t)return t;if(t instanceof Date)return t.getTime();if("epochMilliseconds"in t)return t.epochMilliseconds;if("toZonedDateTime"in t)return t.toZonedDateTime("UTC").epochMilliseconds;throw new TypeError("Unwrapping a non-number value as a number")}toString(t){if(t)try{return t.memoizeIntlObject(Intl.DateTimeFormat,this.opts).format(this.value)}catch(e){t.reportError(e)}return"number"==typeof this.value||this.value instanceof Date?new Date(this.value).toISOString():this.value.toString()}}function oo(t,e,i){if(i===e)return!0;if(i instanceof ro&&e instanceof ro&&i.value===e.value)return!0;if(e instanceof ro&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function lo(t,e,i){return e[i]?po(t,e[i].value):(t.reportError(new RangeError("No default")),new so)}function ho(t,e){const i=[],n=Object.create(null);for(const s of e)"narg"===s.type?n[s.name]=co(t,s.value):i.push(co(t,s));return{positional:i,named:n}}function co(t,e){switch(e.type){case"str":return e.value;case"num":return new ro(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 so(`$${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 so(`$${e}`);i=t.args[e]}if(i instanceof no)return i;switch(typeof i){case"string":return i;case"number":return new ro(i);case"object":if(ao.supportsValue(i))return new ao(i);default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new so(`$${e}`)}}(t,e);case"mesg":return function(t,{name:e,attr:i}){const n=t.bundle._messages.get(e);if(!n)return t.reportError(new ReferenceError(`Unknown message: ${e}`)),new so(e);if(i){const s=n.attributes[i];return s?po(t,s):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new so(`${e}.${i}`))}if(n.value)return po(t,n.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new so(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:n}){const s=`-${e}`,r=t.bundle._terms.get(s);if(!r)return t.reportError(new ReferenceError(`Unknown term: ${s}`)),new so(s);if(i){const e=r.attributes[i];if(e){t.params=ho(t,n).named;const i=po(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new so(`${s}.${i}`)}t.params=ho(t,n).named;const a=po(t,r.value);return t.params=null,a}(t,e);case"func":return function(t,{name:e,args:i}){let n=t.bundle._functions[e];if(!n)return t.reportError(new ReferenceError(`Unknown function: ${e}()`)),new so(`${e}()`);if("function"!=typeof n)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new so(`${e}()`);try{let e=ho(t,i);return n(e.positional,e.named)}catch(i){return t.reportError(i),new so(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:n}){let s=co(t,e);if(s instanceof so)return lo(t,i,n);for(const e of i){if(oo(t,s,co(t,e.key)))return po(t,e.value)}return lo(t,i,n)}(t,e);default:return new so}}function uo(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new so;t.dirty.add(e);const i=[],n=t.bundle._useIsolating&&e.length>1;for(const s of e)if("string"!=typeof s){if(t.placeables++,t.placeables>100)throw t.dirty.delete(e),new RangeError(`Too many placeables expanded: ${t.placeables}, max allowed is 100`);n&&i.push("⁨"),i.push(co(t,s).toString(t)),n&&i.push("⁩")}else i.push(t.bundle._transform(s));return t.dirty.delete(e),i.join("")}function po(t,e){return"string"==typeof e?t.bundle._transform(e):uo(t,e)}class go{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 n=JSON.stringify(e);return i[n]||(i[n]=new t(this.bundle.locales,e)),i[n]}}function mo(t,e){const i=Object.create(null);for(const[n,s]of Object.entries(t))e.includes(n)&&(i[n]=s.valueOf());return i}const fo=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function bo(t,e){let i=t[0];if(i instanceof so)return new so(`NUMBER(${i.valueOf()})`);if(i instanceof ro)return new ro(i.valueOf(),{...i.opts,...mo(e,fo)});if(i instanceof ao)return new ro(i.toNumber(),{...mo(e,fo)});throw new TypeError("Invalid argument to NUMBER")}const vo=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function wo(t,e){let i=t[0];if(i instanceof so)return new so(`DATETIME(${i.valueOf()})`);if(i instanceof ao||i instanceof ro)return new ao(i,mo(e,vo));throw new TypeError("Invalid argument to DATETIME")}const yo=new Map;class xo{constructor(t,{functions:e,useIsolating:i=!0,transform:n=t=>t}={}){this._terms=new Map,this._messages=new Map,this.locales=Array.isArray(t)?t:[t],this._functions={NUMBER:bo,DATETIME:wo,...e},this._useIsolating=i,this._transform=n,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=yo.get(e);return void 0===i&&(i=new Map,yo.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 n=0;n<t.body.length;n++){let s=t.body[n];if(s.id.startsWith("-")){if(!1===e&&this._terms.has(s.id)){i.push(new Error(`Attempt to override an existing term: "${s.id}"`));continue}this._terms.set(s.id,s)}else{if(!1===e&&this._messages.has(s.id)){i.push(new Error(`Attempt to override an existing message: "${s.id}"`));continue}this._messages.set(s.id,s)}}return i}formatPattern(t,e=null,i=null){if("string"==typeof t)return this._transform(t);let n=new go(this,i,e);try{return uo(n,t).toString(n)}catch(t){if(n.errors&&t instanceof Error)return n.errors.push(t),(new so).toString(n);throw t}}}const Ao=/^(-?[a-zA-Z][\w-]*) *= */gm,So=/\.([a-zA-Z][\w-]*) *= */y,_o=/\*?\[/y,Co=/(-?[0-9]+(?:\.([0-9]+))?)/y,Eo=/([a-zA-Z][\w-]*)/y,Po=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,To=/^[A-Z][A-Z0-9_-]*$/,Mo=/([^{}\n\r]+)/y,ko=/([^\\"\n\r]*)/y,Do=/\\([\\"])/y,Io=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Lo=/^\n+/,Ro=/ +$/,No=/ *\r?\n/g,Fo=/( *)$/,Bo=/{\s*/y,Oo=/\s*}/y,jo=/\[\s*/y,Uo=/\s*] */y,Vo=/\s*\(\s*/y,Ho=/\s*->\s*/y,zo=/\s*:\s*/y,$o=/\s*,?\s*/y,Wo=/\s+/y;class Go{constructor(t){this.body=[],Ao.lastIndex=0;let e=0;for(;;){let i=Ao.exec(t);if(null===i)break;e=Ao.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 n(i,n){if(t[e]===i)return e++,!0;if(n)throw new n(`Expected ${i}`);return!1}function s(t,n){if(i(t))return e=t.lastIndex,!0;if(n)throw new n(`Expected ${t.toString()}`);return!1}function r(i){i.lastIndex=e;let n=i.exec(t);if(null===n)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,n}function a(t){return r(t)[1]}function o(t){let e=l(),n=function(){let t=Object.create(null);for(;i(So);){let e=a(So),i=l();if(null===i)throw new SyntaxError("Expected attribute value");t[e]=i}return t}();if(null===e&&0===Object.keys(n).length)throw new SyntaxError("Expected message value or attributes");return{id:t,value:e,attributes:n}}function l(){let n;if(i(Mo)&&(n=a(Mo)),"{"===t[e]||"}"===t[e])return h(n?[n]:[],1/0);let s=b();return s?n?h([n,s],s.length):(s.value=v(s.value,Lo),h([s],s.length)):n?v(n,Ro):null}function h(n=[],s){for(;;){if(i(Mo)){n.push(a(Mo));continue}if("{"===t[e]){n.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let r=b();if(!r)break;n.push(r),s=Math.min(s,r.length)}let r=n.length-1,o=n[r];"string"==typeof o&&(n[r]=v(o,Ro));let l=[];for(let t of n)t instanceof qo&&(t=t.value.slice(0,t.value.length-s)),t&&l.push(t);return l}function d(){s(Bo,SyntaxError);let t=c();if(s(Oo))return t;if(s(Ho)){let e=function(){let t,e=[],s=0;for(;i(_o);){n("*")&&(t=s);let i=p(),r=l();if(null===r)throw new SyntaxError("Expected variant value");e[s++]={key:i,value:r}}if(0===s)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return s(Oo,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(Po)){let[,i,n,a=null]=r(Po);if("$"===i)return{type:"var",name:n};if(s(Vo)){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()),s($o)}}();if("-"===i)return{type:"term",name:n,attr:a,args:r};if(To.test(n))return{type:"func",name:n,args:r};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:n,attr:a,args:[]}:{type:"mesg",name:n,attr:a}}return g()}function u(){let t=c();return"mesg"!==t.type?t:s(zo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return s(jo,SyntaxError),t=i(Co)?m():{type:"str",value:a(Eo)},s(Uo,SyntaxError),t}function g(){if(i(Co))return m();if('"'===t[e])return function(){n('"',SyntaxError);let i="";for(;;){if(i+=a(ko),"\\"!==t[e]){if(n('"'))return{type:"str",value:i};throw new SyntaxError("Unclosed string literal")}i+=f()}}();throw new SyntaxError("Invalid expression")}function m(){let[,t,e=""]=r(Co),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function f(){if(i(Do))return a(Do);if(i(Io)){let[,t,e]=r(Io),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(s(Wo),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(No,"\n"),i=Fo.exec(t)[1].length;return new qo(e,i)}}}class qo{constructor(t,e){this.value=t,this.length=e}}const Xo=/<|&#?\w+;/,Yo={"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"]},Ko={"http://www.w3.org/1999/xhtml":{global:["title","aria-description","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 Qo(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(Xo.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 n=tl(e,i);t.replaceChild(n,i);continue}if(nl(i)){const e=el(i);t.replaceChild(e,i);continue}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(il(i),i)}e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;Jo(e,t)}function Zo(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function Jo(t,e){const i=e.hasAttribute("data-l10n-attrs")?e.getAttribute("data-l10n-attrs").split(",").map(t=>t.trim()):null;for(const n of Array.from(e.attributes))sl(n.name,e,i)&&!Zo(t.attributes,n.name)&&e.removeAttribute(n.name);if(t.attributes)for(const n of Array.from(t.attributes))sl(n.name,e,i)&&e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function tl(t,e){const i=e.getAttribute("data-l10n-name"),n=t.querySelector(`[data-l10n-name="${i}"]`);if(!n)return console.warn(`An element named "${i}" wasn't found in the source.`),il(e);if(n.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 (${n.localName}).`),il(e);t.removeChild(n);return rl(e,n.cloneNode(!1))}function el(t){const e=t.ownerDocument.createElement(t.localName);return rl(t,e)}function il(t){return t.ownerDocument.createTextNode(t.textContent)}function nl(t){const e=Yo[t.namespaceURI];return e&&e.includes(t.localName)}function sl(t,e,i=null){if(i&&i.includes(t))return!0;const n=Ko[e.namespaceURI];if(!n)return!1;const s=t.toLowerCase(),r=e.localName;if(n.global.includes(s))return!0;if(!n[r])return!1;if(n[r].includes(s))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===r&&"value"===s){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function rl(t,e){return e.textContent=t.textContent,Jo(t,e),e}class al extends Array{static from(t){return t instanceof this?t:new this(t)}}class ol extends al{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 ll{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 n=!1;for await(const s of this.bundles){n=!0;const r=cl(e,s,t,i);if(0===r.size)break;if("undefined"!=typeof console){const t=s.locales[0],e=Array.from(r).join(", ");console.warn(`[fluent] Missing translations in ${t}: ${e}`)}}return n||"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,dl)}formatValues(t){return this.formatWithFallback(t,hl)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=ol.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function hl(t,e,i,n){return i.value?t.formatPattern(i.value,n,e):null}function dl(t,e,i,n){const s={value:null,attributes:null};i.value&&(s.value=t.formatPattern(i.value,n,e));let r=Object.keys(i.attributes);if(r.length>0){s.attributes=new Array(r.length);for(let[a,o]of r.entries()){let r=t.formatPattern(i.attributes[o],n,e);s.attributes[a]={name:o,value:r}}}return s}function cl(t,e,i,n){const s=[],r=new Set;return i.forEach(({id:i,args:a},o)=>{if(void 0!==n[o])return;let l=e.getMessage(i);if(l){if(s.length=0,n[o]=t(e,s,l,a),s.length>0&&"undefined"!=typeof console){const t=e.locales[0],n=s.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${n}.`)}}else r.add(i)}),r}const ul="data-l10n-id",pl="data-l10n-args",gl=`[${ul}]`;class ml extends ll{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:[ul,pl]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(ul,e),i?t.setAttribute(pl,JSON.stringify(i)):t.removeAttribute(pl),t}getAttributes(t){return{id:t.getAttribute(ul),args:JSON.parse(t.getAttribute(pl)||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(ul)&&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]&&Qo(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(gl));return"function"==typeof t.hasAttribute&&t.hasAttribute(ul)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(ul),args:JSON.parse(t.getAttribute(pl)||null)}}}class fl{#Yh;#jr;#hs;#Kh;constructor({lang:t,isRTL:e},i=null){this.#hs=fl.#Qh(t),this.#Kh=i,this.#Yh=e??fl.#Zh(this.#hs)?"rtl":"ltr"}_setL10n(t){this.#Kh=t}getLanguage(){return this.#hs}getDirection(){return this.#Yh}async get(t,e=null,i){if(Array.isArray(t)){t=t.map(t=>({id:t}));return(await this.#Kh.formatMessages(t)).map(t=>t.value)}const n=await this.#Kh.formatMessages([{id:t,args:e}]);return n[0]?.value||i}async translate(t){(this.#jr||=new Set).add(t);try{this.#Kh.connectRoot(t),await this.#Kh.translateRoots()}catch{}}async translateOnce(t){try{await this.#Kh.translateElements([t])}catch(t){console.error("translateOnce:",t)}}async destroy(){if(this.#jr){for(const t of this.#jr)this.#Kh.disconnectRoot(t);this.#jr.clear(),this.#jr=null}this.#Kh.pauseObserving()}pause(){this.#Kh.pauseObserving()}resume(){this.#Kh.resumeObserving()}static#Qh(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#Zh(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function bl(){const{isAndroid:t,isLinux:e,isMac:i,isWindows:n}=gr.platform;return e?"linux":n?"windows":i?"macos":t?"android":"other"}function vl(t,e){const i=new Go(e),n=new xo(t,{functions:{PLATFORM:bl}}),s=n.addResource(i);return s.length&&console.error("L10n errors",s),n}class wl extends fl{constructor(t){super({lang:t});const e=t?wl.#Jh.bind(wl,"en-us",this.getLanguage()):wl.#td.bind(wl,this.getLanguage());this._setL10n(new ml([],e))}static async*#Jh(t,e){const{baseURL:i,paths:n}=await this.#ed(),s=[e];if(t!==e){const i=e.split("-",1)[0];i!==e&&s.push(i),s.push(t)}const r=s.map(t=>[t,this.#id(t,i,n)]);for(const[t,e]of r){const i=await e;i?yield i:"en-us"===t&&(yield this.#nd(t))}}static async#id(t,e,i){const n=i[t];if(!n)return null;const s=new URL(n,e);return vl(t,await mr(s,"text"))}static async#ed(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await mr(t,"json");return{baseURL:t.substring(0,t.lastIndexOf("/")+1)||"./",paths:e}}catch{}return{baseURL:"./",paths:Object.create(null)}}static async*#td(t){yield this.#nd(t)}static async#nd(t){return vl(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-color-picker-free-text-input =\n .title = Change text color\npdfjs-editor-free-text-button-label = Text\npdfjs-editor-ink-button =\n .title = Draw\npdfjs-editor-color-picker-ink-input =\n .title = Change drawing color\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-comment-floating-button =\n .title = Comment\n .aria-label = Comment\npdfjs-comment-floating-button-label = Comment\npdfjs-editor-comment-button =\n .title = Comment\n .aria-label = Comment\npdfjs-editor-comment-button-label = Comment\npdfjs-editor-signature-button =\n .title = Add signature\npdfjs-editor-signature-button-label = Add signature\npdfjs-editor-highlight-editor =\n .aria-label = Highlight editor\npdfjs-editor-ink-editor =\n .aria-label = Drawing editor\npdfjs-editor-signature-editor1 =\n .aria-description = Signature editor: { $description }\npdfjs-editor-stamp-editor =\n .aria-label = Image editor\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-remove-signature-button =\n .title = Remove signature\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-editor-add-signature-container =\n .aria-label = Signature controls and saved signatures\npdfjs-editor-signature-add-signature-button =\n .title = Add new signature\npdfjs-editor-signature-add-signature-button-label = Add new signature\npdfjs-editor-add-saved-signature-button =\n .title = Saved signature: { $description }\npdfjs-free-text2 =\n .aria-label = Text Editor\n .default-content = Start typing…\npdfjs-editor-comments-sidebar-title =\n { $count ->\n [one] Comment\n *[other] Comments\n }\npdfjs-editor-comments-sidebar-close-button =\n .title = Close the sidebar\n .aria-label = Close the sidebar\npdfjs-editor-comments-sidebar-close-button-label = Close the sidebar\npdfjs-editor-comments-sidebar-no-comments1 = See something noteworthy? Highlight it and leave a comment.\npdfjs-editor-comments-sidebar-no-comments-link = Learn more\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-highlight-added-alert = Highlight added\npdfjs-editor-freetext-added-alert = Text added\npdfjs-editor-ink-added-alert = Drawing added\npdfjs-editor-stamp-added-alert = Image added\npdfjs-editor-signature-added-alert = Signature added\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-signature = Signature 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\npdfjs-editor-add-signature-dialog-label = This modal allows the user to create a signature to add to a PDF document. The user can edit the name (which also serves as the alt text), and optionally save the signature for repeated use.\npdfjs-editor-add-signature-dialog-title = Add a signature\npdfjs-editor-add-signature-type-button = Type\n .title = Type\npdfjs-editor-add-signature-draw-button = Draw\n .title = Draw\npdfjs-editor-add-signature-image-button = Image\n .title = Image\npdfjs-editor-add-signature-type-input =\n .aria-label = Type your signature\n .placeholder = Type your signature\npdfjs-editor-add-signature-draw-placeholder = Draw your signature\npdfjs-editor-add-signature-draw-thickness-range-label = Thickness\npdfjs-editor-add-signature-draw-thickness-range =\n .title = Drawing thickness: { $thickness }\npdfjs-editor-add-signature-image-placeholder = Drag a file here to upload\npdfjs-editor-add-signature-image-browse-link =\n { PLATFORM() ->\n [macos] Or choose image files\n *[other] Or browse image files\n }\npdfjs-editor-add-signature-description-label = Description (alt text)\npdfjs-editor-add-signature-description-input =\n .title = Description (alt text)\npdfjs-editor-add-signature-description-default-when-drawing = Signature\npdfjs-editor-add-signature-clear-button-label = Clear signature\npdfjs-editor-add-signature-clear-button =\n .title = Clear signature\npdfjs-editor-add-signature-save-checkbox = Save signature\npdfjs-editor-add-signature-save-warning-message = You’ve reached the limit of 5 saved signatures. Remove one to save more.\npdfjs-editor-add-signature-image-upload-error-title = Couldn’t upload image\npdfjs-editor-add-signature-image-upload-error-description = Check your network connection or try another image.\npdfjs-editor-add-signature-image-no-data-error-title = Can’t convert this image into a signature\npdfjs-editor-add-signature-image-no-data-error-description = Please try uploading a different image.\npdfjs-editor-add-signature-error-close-button = Close\npdfjs-editor-add-signature-cancel-button = Cancel\npdfjs-editor-add-signature-add-button = Add\npdfjs-editor-delete-signature-button1 =\n .title = Remove saved signature\npdfjs-editor-delete-signature-button-label1 = Remove saved signature\npdfjs-editor-add-signature-edit-button-label = Edit description\npdfjs-editor-edit-signature-dialog-title = Edit description\npdfjs-editor-edit-signature-update-button = Update\npdfjs-show-comment-button =\n .title = Show comment\npdfjs-editor-edit-comment-popup-button-label = Edit comment\npdfjs-editor-edit-comment-popup-button =\n .title = Edit comment\npdfjs-editor-delete-comment-popup-button-label = Remove comment\npdfjs-editor-delete-comment-popup-button =\n .title = Remove comment\npdfjs-editor-edit-comment-dialog-title-when-editing = Edit comment\npdfjs-editor-edit-comment-dialog-save-button-when-editing = Update\npdfjs-editor-edit-comment-dialog-title-when-adding = Add comment\npdfjs-editor-edit-comment-dialog-save-button-when-adding = Add\npdfjs-editor-edit-comment-dialog-text-input =\n .placeholder = Start typing…\npdfjs-editor-edit-comment-dialog-cancel-button = Cancel\npdfjs-editor-add-comment-button =\n .title = Add comment')}}function yl(){return document.location.hash}class xl{#Vl=null;#sd=null;#Hh=null;#lh=null;#Kl=null;#b;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new wl,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#b=t.uiManager,this.#Vl=t.annotationLayer||null,this.#Kl=t.textLayer||null,this.#sd=t.drawLayer||null,this.#Hh=t.onAppend||null,this.#lh=t.structTreeLayer||null}async render({viewport:t,intent: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 n=this.div=document.createElement("div");n.className="annotationEditorLayer",n.hidden=!0,n.dir=this.#b.direction,this.#Hh?.(n),this.annotationEditorLayer=new tr({uiManager:this.#b,div:n,structTreeLayer:this.#lh,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#Vl,textLayer:this.#Kl,drawLayer:this.#sd});const s={viewport:i,div:n,annotations:null,intent:e};this.annotationEditorLayer.render(s),this.show()}cancel(){this._cancelled=!0,this.div&&this.annotationEditorLayer.destroy()}hide(){this.div&&(this.annotationEditorLayer.pause(!0),this.div.hidden=!0)}show(){this.div&&!this.annotationEditorLayer.isInvisible&&(this.div.hidden=!1,this.annotationEditorLayer.pause(!1))}}{var Al=new Map;const{maxTouchPoints:t,platform:e,userAgent:i}=navigator,n=/Android/.test(i);(/\b(iPad|iPhone|iPod)(?=;)/.test(i)||"MacIntel"===e&&t>1||n)&&Al.set("maxCanvasPixels",5242880),n&&Al.set("useSystemFonts",!1)}const Sl=1,_l=2,Cl=4,El=8,Pl=16,Tl=128,Ml={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},kl={allowedGlobalEvents:{value:null,kind:Sl},canvasMaxAreaInBytes:{value:-1,kind:Sl+Cl},isInAutomation:{value:!1,kind:Sl},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Sl},maxCanvasDim:{value:32767,kind:Sl+_l},nimbusDataStr:{value:"",kind:Sl},supportsCaretBrowsingMode:{value:!1,kind:Sl},supportsDocumentFonts:{value:!0,kind:Sl},supportsIntegratedFind:{value:!1,kind:Sl},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Sl},supportsMouseWheelZoomMetaKey:{value:!0,kind:Sl},supportsPinchToZoom:{value:!0,kind:Sl},supportsPrinting:{value:!0,kind:Sl},toolbarDensity:{value:0,kind:Sl+Pl},altTextLearnMoreUrl:{value:"",kind:_l+Tl},annotationEditorMode:{value:0,kind:_l+Tl},annotationMode:{value:2,kind:_l+Tl},capCanvasAreaFactor:{value:200,kind:_l+Tl},commentLearnMoreUrl:{value:"",kind:_l+Tl},cursorToolOnLoad:{value:0,kind:_l+Tl},debuggerSrc:{value:"./debugger.mjs",kind:_l},defaultZoomDelay:{value:400,kind:_l+Tl},defaultZoomValue:{value:"",kind:_l+Tl},disableHistory:{value:!1,kind:_l},disablePageLabels:{value:!1,kind:_l+Tl},enableAltText:{value:!1,kind:_l+Tl},enableAltTextModelDownload:{value:!0,kind:_l+Tl+Pl},enableAutoLinking:{value:!0,kind:_l+Tl},enableComment:{value:!1,kind:_l+Tl},enableDetailCanvas:{value:!0,kind:_l},enableGuessAltText:{value:!0,kind:_l+Tl+Pl},enableHighlightFloatingButton:{value:!1,kind:_l+Tl},enableNewAltTextWhenAddingImage:{value:!0,kind:_l+Tl},enableOptimizedPartialRendering:{value:!1,kind:_l+Tl},enablePermissions:{value:!1,kind:_l+Tl},enablePrintAutoRotate:{value:!0,kind:_l+Tl},enableScripting:{value:!0,kind:_l+Tl},enableSignatureEditor:{value:!1,kind:_l+Tl},enableUpdatedAddImage:{value:!1,kind:_l+Tl},externalLinkRel:{value:"noopener noreferrer nofollow",kind:_l},externalLinkTarget:{value:0,kind:_l+Tl},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F,yellow_HCM=#FFFFCC,green_HCM=#53FFBC,blue_HCM=#80EBFF,pink_HCM=#F6B8FF,red_HCM=#C50043",kind:_l+Tl},historyUpdateUrl:{value:!1,kind:_l+Tl},ignoreDestinationZoom:{value:!1,kind:_l+Tl},imageResourcesPath:{value:"./images/",kind:_l},maxCanvasPixels:{value:2**25,kind:_l},minDurationToUpdateCanvas:{value:500,kind:_l},forcePageColors:{value:!1,kind:_l+Tl},pageColorsBackground:{value:"Canvas",kind:_l+Tl},pageColorsForeground:{value:"CanvasText",kind:_l+Tl},pdfBugEnabled:{value:!1,kind:_l+Tl},printResolution:{value:150,kind:_l},sidebarViewOnLoad:{value:-1,kind:_l+Tl},scrollModeOnLoad:{value:-1,kind:_l+Tl},spreadModeOnLoad:{value:-1,kind:_l+Tl},textLayerMode:{value:1,kind:_l+Tl},viewerCssTheme:{value:0,kind:_l+Tl},viewOnLoad:{value:0,kind:_l+Tl},cMapPacked:{value:!0,kind:Cl},cMapUrl:{value:"../web/cmaps/",kind:Cl},disableAutoFetch:{value:!1,kind:Cl+Tl},disableFontFace:{value:!1,kind:Cl+Tl},disableRange:{value:!1,kind:Cl+Tl},disableStream:{value:!1,kind:Cl+Tl},docBaseUrl:{value:"",kind:Cl},enableHWA:{value:!0,kind:Cl+_l+Tl},enableXfa:{value:!0,kind:Cl+Tl},fontExtraProperties:{value:!1,kind:Cl},iccUrl:{value:"../web/iccs/",kind:Cl},isEvalSupported:{value:!0,kind:Cl},isOffscreenCanvasSupported:{value:!0,kind:Cl},maxImageSize:{value:-1,kind:Cl},pdfBug:{value:!1,kind:Cl},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Cl},useSystemFonts:{value:void 0,kind:Cl,type:Ml.BOOLEAN+Ml.UNDEFINED},verbosity:{value:1,kind:Cl},wasmUrl:{value:"../web/wasm/",kind:Cl},workerPort:{value:null,kind:El},workerSrc:{value:"../build/pdf.worker.mjs",kind:El}};kl.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:_l},kl.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:_l},kl.enableFakeMLManager={value:!0,kind:_l},kl.disablePreferences={value:!1,kind:_l};class Dl{static eventBus;static#rd=new Map;static{for(const t in kl)this.#rd.set(t,kl[t].value);for(const[t,e]of Al)this.#rd.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.#rd.get(t)}static getAll(t=null,e=!1){const i=Object.create(null);for(const n in kl){const s=kl[n];(!t||t&s.kind)&&(i[n]=e?s.value:this.#rd.get(n))}return i}static set(t,e){this.setAll({[t]:e})}static setAll(t,e=!1){let i;this._hasInvokedSet||=!0;for(const n in t){const s=kl[n],r=t[n];if(!s||!(typeof r==typeof s.value||Ml[(typeof r).toUpperCase()]&s.type))continue;const{kind:a}=s;(!e||a&Sl||a&Tl)&&(this.eventBus&&a&Pl&&(i||=new Map).set(n,r),this.#rd.set(n,r))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}function Il({width:t,height:e,left:i,top:n},s){if(0===t||0===e)return null;const r=s.textLayer.div.getBoundingClientRect(),a=s.getPagePoint(i-r.left,n-r.top),o=s.getPagePoint(i-r.left+t,n-r.top+e);return Qr.normalizeRect([a[0],a[1],o[0],o[1]])}function Ll(t,e){const i=t.getClientRects();if(1===i.length)return{rect:Il(i[0],e)};const n=[1/0,1/0,-1/0,-1/0],s=[];let r=0;for(const t of i){const i=Il(t,e);null!==i&&(s[r]=s[r+4]=i[0],s[r+1]=s[r+3]=i[3],s[r+2]=s[r+6]=i[2],s[r+5]=s[r+7]=i[1],Qr.rectBoundingBox(...i,n),r+=8)}return{quadPoints:s,rect:n}}function Rl(t,e){let i=t;do{if(i.nodeType===Node.TEXT_NODE){const t=i.textContent.length;if(e<=t)return[i,e];e-=t}else if(i.firstChild){i=i.firstChild;continue}for(;!i.nextSibling&&i!==t;)i=i.parentNode;i!==t&&(i=i.nextSibling)}while(i!==t);throw new Error("Offset is bigger than container's contents length.")}class Nl{static#ad=0;static#i;static findLinks(t){this.#i??=/\b(?:https?:\/\/|mailto:|www\.)(?:[\S--[\p{P}<>]]|\/|[\S--[\[\]]]+[\S--[\p{P}<>]])+|\b[\S--[@\p{Ps}\p{Pe}<>]]+@([\S--[\p{P}<>]]+(?:\.[\S--[\p{P}<>]]+)+)/gmv;const[e,i]=Wa(t,{ignoreDashEOL:!0}),n=e.matchAll(this.#i),s=[];for(const t of n){const[e,n]=t;let r;if(e.startsWith("www.")||e.startsWith("http://")||e.startsWith("https://"))r=e;else{if(!URL.canParse(`http://${n}`))continue;r=e.startsWith("mailto:")?e:`mailto:${e}`}const a=dr(r,null,{addDefaultProtocol:!0});if(a){const[n,r]=Ga(i,t.index,e.length);s.push({url:a.href,index:n,length:r})}}return s}static processLinks(t){return this.findLinks(t._textHighlighter.textContentItemsStr.join("\n")).map(e=>function({url:t,index:e,length:i},n,s){const r=n._textHighlighter,[{begin:a,end:o}]=r._convertMatches([e],[i]),l=new Range;return l.setStart(...Rl(r.textDivs[a.divIdx],a.offset)),l.setEnd(...Rl(r.textDivs[o.divIdx],o.offset)),{id:`inferred_link_${s}`,unsafeUrl:t,url:t,annotationType:ar.LINK,rotation:0,...Ll(l,n),borderStyle:null}}(e,t,this.#ad++))}}class Fl{#od=null;#ld=0;#hd=null;#dd=ea.INITIAL;#cd=null;#ud=0;#pd=null;canvas=null;div=null;enableOptimizedPartialRendering=!1;eventBus=null;id=null;pageColors=null;recordedBBoxes=null;renderingQueue=null;renderTask=null;resume=null;constructor(t){this.eventBus=t.eventBus,this.id=t.id,this.pageColors=t.pageColors||null,this.renderingQueue=t.renderingQueue,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.#ld=t.minDurationToUpdateCanvas??500}get renderingState(){return this.#dd}set renderingState(t){if(t!==this.#dd)switch(this.#dd=t,this.#od&&(clearTimeout(this.#od),this.#od=null),t){case ea.PAUSED:this.div.classList.remove("loading"),this.#ud=0,this.#cd?.(!1);break;case ea.RUNNING:this.div.classList.add("loadingIcon"),this.#od=setTimeout(()=>{this.div.classList.add("loading"),this.#od=null},0),this.#ud=Date.now();break;case ea.INITIAL:case ea.FINISHED:this.div.classList.remove("loadingIcon","loading"),this.#ud=0}}_createCanvas(t,e=!1){const{pageColors:i}=this,n=!(!i?.background||!i?.foreground),s=this.canvas,r=!s&&!n&&!e;let a=this.canvas=document.createElement("canvas");return this.#cd=e=>{if(r){let i=this.#pd;if(!e&&this.#ld>0){if(Date.now()-this.#ud<this.#ld)return;i||(i=this.#pd=a,a=this.canvas=a.cloneNode(!1),t(a))}if(i){return a.getContext("2d",{alpha:!1}).drawImage(i,0,0),void(e?this.#gd():this.#ud=Date.now())}return t(a),void(this.#cd=null)}e&&(s?(s.replaceWith(a),s.width=s.height=0):t(a))},{canvas:a,prevCanvas:s}}#md=t=>{if(this.#cd?.(!1),this.renderingQueue&&!this.renderingQueue.isHighestPriority(this))return this.renderingState=ea.PAUSED,void(this.resume=()=>{this.renderingState=ea.RUNNING,t()});t()};_resetCanvas(){const{canvas:t}=this;t&&(t.remove(),t.width=t.height=0,this.canvas=null,this.#gd())}#gd(){this.#pd&&(this.#pd.width=this.#pd.height=0,this.#pd=null)}async _drawCanvas(t,e,i){const n=this.renderTask=this.pdfPage.render(t);n.onContinue=this.#md,n.onError=t=>{t instanceof Ur&&(e(),this.#hd=null)};let s=null;try{await n.promise,this.#cd?.(!0)}catch(t){if(t instanceof Ur)return;s=t,this.#cd?.(!0)}finally{this.#hd=s,n===this.renderTask&&(this.renderTask=null,this.enableOptimizedPartialRendering&&(this.recordedBBoxes??=n.recordedBBoxes))}if(this.renderingState=ea.FINISHED,i(n),s)throw s}cancelRendering({cancelExtraDelay:t=0}={}){this.renderTask&&(this.renderTask.cancel(t),this.renderTask=null),this.resume=null}dispatchPageRender(){this.eventBus.dispatch("pagerender",{source:this,pageNumber:this.id})}dispatchPageRendered(t,e){this.eventBus.dispatch("pagerendered",{source:this,pageNumber:this.id,cssTransform:t,isDetailView:e,timestamp:performance.now(),error:this.#hd})}}class Bl{#sd=null;constructor(t){this.pageIndex=t.pageIndex}async render({intent:t="display"}){"display"!==t||this.#sd||this._cancelled||(this.#sd=new pr({pageIndex:this.pageIndex}))}cancel(){this._cancelled=!0,this.#sd&&(this.#sd.destroy(),this.#sd=null)}setParent(t){this.#sd?.setParent(t)}getDrawLayer(){return this.#sd}}class Ol extends Fl{#fd=null;renderingCancelled=!1;constructor({pageView:t}){super(t),this.pageView=t,this.renderingId="detail"+this.id,this.div=t.div}setPdfPage(t){this.pageView.setPdfPage(t)}get pdfPage(){return this.pageView.pdfPage}get renderingState(){return super.renderingState}set renderingState(t){this.renderingCancelled=!1,super.renderingState=t}reset({keepCanvas:t=!1}={}){const e=this.renderingCancelled||this.renderingState===ea.RUNNING||this.renderingState===ea.PAUSED;this.cancelRendering(),this.renderingState=ea.INITIAL,this.renderingCancelled=e,t||this._resetCanvas()}#bd(t){if(!this.#fd)return!0;const e=this.#fd.minX,i=this.#fd.minY,n=this.#fd.width+e,s=this.#fd.height+i;if(t.minX<e||t.minY<i||t.maxX>n||t.maxY>s)return!0;const{width:r,height:a,scale:o}=this.pageView.viewport;if(this.#fd.scale!==o)return!0;const l=t.minX-e,h=n-t.maxX,d=t.minY-i,c=s-t.maxY;return e>0&&h/l>3||n<r&&l/h>3||i>0&&c/d>3||s<a&&d/c>3}update({visibleArea:t=null,underlyingViewUpdated:e=!1}={}){if(e)return this.cancelRendering(),void(this.renderingState=ea.INITIAL);if(!this.#bd(t))return;const{viewport:i,maxCanvasPixels:n,capCanvasAreaFactor:s}=this.pageView,r=t.maxX-t.minX,a=t.maxY-t.minY,o=r*a*Lr.pixelRatio**2,l=(Math.sqrt(Lr.capPixels(n,s)/o)-1)/2;let h=Math.min(1,l);h<0&&(h=0);const d=r*h,c=a*h,u=Math.max(0,t.minX-d),p=Math.min(i.width,t.maxX+d),g=Math.max(0,t.minY-c),m=p-u,f=Math.min(i.height,t.maxY+c)-g;this.#fd={minX:u,minY:g,width:m,height:f,scale:i.scale},this.reset({keepCanvas:!0})}_getRenderingContext(t,e){const i=this.pageView._getRenderingContext(t,e,!1),n=this.pdfPage.recordedBBoxes;if(!n||!this.enableOptimizedPartialRendering)return i;const{viewport:{width:s,height:r}}=this.pageView,{width:a,height:o,minX:l,minY:h}=this.#fd,d=l/s,c=h/r,u=(l+a)/s,p=(h+o)/r;return{...i,operationsFilter:t=>!n.isEmpty(t)&&(n.minX(t)<=u&&n.maxX(t)>=d&&n.minY(t)<=p&&n.maxY(t)>=c)}}async draw(){if(this.pageView.detailView!==this)return;const t=this.pageView.renderingState===ea.FINISHED||this.renderingState===ea.FINISHED;this.renderingState!==ea.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:e,pdfPage:i,viewport:n}=this.pageView;if(!i)throw this.renderingState=ea.FINISHED,new Error("pdfPage is not loaded");this.renderingState=ea.RUNNING;const s=this.pageView._ensureCanvasWrapper(),{canvas:r,prevCanvas:a}=this._createCanvas(t=>{"CANVAS"===s.firstElementChild?.tagName?s.firstElementChild.after(t):s.prepend(t)},t);r.ariaHidden=!0,this.enableOptimizedPartialRendering&&(r.className="detailView");const{width:o,height:l}=n,h=this.#fd,{pixelRatio:d}=Lr,c=[d,0,0,d,-h.minX*d,-h.minY*d];r.width=h.width*d,r.height=h.height*d;const{style:u}=r;u.width=100*h.width/o+"%",u.height=100*h.height/l+"%",u.top=100*h.minY/l+"%",u.left=100*h.minX/o+"%";const p=this._drawCanvas(this._getRenderingContext(r,c),()=>{this.canvas?.remove(),this.canvas=a},()=>{this.dispatchPageRendered(!1,!0)});return e.setAttribute("data-loaded",!0),this.dispatchPageRender(),p}}const jl={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},Ul=new Set(["math","merror","mfrac","mi","mmultiscripts","mn","mo","mover","mpadded","mprescripts","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msubsup","msup","mtable","mtd","mtext","mtr","munder","munderover","semantics"]),Vl="http://www.w3.org/1998/Math/MathML";class Hl{static get sanitizer(){return $r(this,"sanitizer",gr.isSanitizerSupported?new Sanitizer({elements:[...Ul].map(t=>({name:t,namespace:Vl})),replaceWithChildrenElements:[{name:"maction",namespace:Vl}],attributes:["dir","displaystyle","mathbackground","mathcolor","mathsize","scriptlevel","encoding","display","linethickness","intent","arg","form","fence","separator","lspace","rspace","stretchy","symmetric","maxsize","minsize","largeop","movablelimits","width","height","depth","voffset","accent","accentunder","columnspan","rowspan"],comments:!1}):null)}}const zl=/^H(\d+)$/;class $l{#vd;#wd=null;#yd;#xd=new Map;#Ad;#Sd=null;constructor(t,e){this.#vd=t.getStructTree(),this.#Ad=e}async render(){if(this.#yd)return this.#yd;const{promise:t,resolve:e,reject:i}=Promise.withResolvers();this.#yd=t;try{this.#wd=this.#_d(await this.#vd)}catch(t){i(t)}return this.#vd=null,this.#wd?.classList.add("structTree"),e(this.#wd),t}async getAriaAttributes(t){try{return await this.render(),this.#xd.get(t)}catch{}return null}hide(){this.#wd&&!this.#wd.hidden&&(this.#wd.hidden=!0)}show(){this.#wd?.hidden&&(this.#wd.hidden=!1)}#Cd(t,e){const{alt:i,id:n,lang:s}=t;if(void 0!==i){let n=!1;const s=ga(i);for(const e of t.children)if("annotation"===e.type){let t=this.#xd.get(e.id);t||(t=new Map,this.#xd.set(e.id,t)),t.set("aria-label",s),n=!0}n||e.setAttribute("aria-label",s)}void 0!==n&&e.setAttribute("aria-owns",n),void 0!==s&&e.setAttribute("lang",ga(s,!0))}#Ed(t,e){const{alt:i,bbox:n,children:s}=t,r=s?.[0];if(!this.#Ad||!i||!n||"content"!==r?.type)return!1;const{id:a}=r;if(!a)return!1;e.setAttribute("aria-owns",a);const o=document.createElement("span");(this.#Sd||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",ga(i));const{pageHeight:l,pageX:h,pageY:d}=this.#Ad,c="calc(var(--total-scale-factor) *",{style:u}=o;return u.width=`${c}${n[2]-n[0]}px)`,u.height=`${c}${n[3]-n[1]}px)`,u.left=`${c}${n[0]-h}px)`,u.top=`${c}${l-n[3]+d}px)`,!0}addElementsToTextLayer(){if(this.#Sd){for(const[t,e]of this.#Sd)document.getElementById(t)?.append(e);this.#Sd.clear(),this.#Sd=null}}#_d(t){if(!t)return null;let e;if("role"in t){const{role:i}=t;e=Ul.has(i)?document.createElementNS(Vl,i):document.createElement("span");const n=i.match(zl);if(n?(e.setAttribute("role","heading"),e.setAttribute("aria-level",n[1])):jl[i]&&e.setAttribute("role",jl[i]),"Figure"===i&&this.#Ed(t,e))return e;"Formula"===i&&(t.mathML&&Hl.sanitizer&&e.setHTML(t.mathML,{sanitizer:Hl.sanitizer}),t.mathML||1!==t.children.length||"math"===t.children[0].role||(e=document.createElementNS(Vl,"math")))}if(e||=document.createElement("span"),this.#Cd(t,e),t.children)if(1===t.children.length&&"id"in t.children[0])this.#Cd(t.children[0],e);else for(const i of t.children)e.append(this.#_d(i));return e}}class Wl{#Pd=!1;#Td=null;#Md=new Map;#kd=new Map;setTextMapping(t){this.#Td=t}static#Dd(t,e){const i=t.getBoundingClientRect(),n=e.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;if(a<=o&&h>=r)return-1;if(h<=s&&a>=l)return 1;return i.x+i.width/2-(n.x+n.width/2)}enable(){if(this.#Pd)throw new Error("TextAccessibilityManager is already enabled.");if(!this.#Td)throw new Error("Text divs and strings have not been set.");if(this.#Pd=!0,this.#Td=this.#Td.slice(),this.#Td.sort(Wl.#Dd),this.#Md.size>0){const t=this.#Td;for(const[e,i]of this.#Md){document.getElementById(e)?this.#Id(e,t[i]):this.#Md.delete(e)}}for(const[t,e]of this.#kd)this.addPointerInTextLayer(t,e);this.#kd.clear()}disable(){this.#Pd&&(this.#kd.clear(),this.#Td=null,this.#Pd=!1)}removePointerInTextLayer(t){if(!this.#Pd)return void this.#kd.delete(t);const e=this.#Td;if(!e||0===e.length)return;const{id:i}=t,n=this.#Md.get(i);if(void 0===n)return;const s=e[n];this.#Md.delete(i);let r=s.getAttribute("aria-owns");r?.includes(i)&&(r=r.split(" ").filter(t=>t!==i).join(" "),r?s.setAttribute("aria-owns",r):(s.removeAttribute("aria-owns"),s.setAttribute("role","presentation")))}#Id(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.#Pd)return this.#kd.set(t,e),null;e&&this.removePointerInTextLayer(t);const n=this.#Td;if(!n||0===n.length)return null;const s=ma(n,e=>Wl.#Dd(t,e)<0),r=Math.max(0,s-1),a=n[r];this.#Id(i,a),this.#Md.set(i,r);const o=a.parentNode;return o?.classList.contains("markedContent")?o.id:null}moveElementInDOM(t,e,i,n){const s=this.addPointerInTextLayer(i,n);if(!t.hasChildNodes())return t.append(e),s;const r=Array.from(t.childNodes).filter(t=>t!==e);if(0===r.length)return s;const a=ma(r,t=>Wl.#Dd(e,t)<0);return 0===a?r[0].before(e):r[a-1].after(e),s}}class Gl{#zh=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.#zh||(this.#zh=new AbortController,this.eventBus._on("updatetextlayermatches",t=>{t.pageIndex!==this.pageIdx&&-1!==t.pageIndex||this._updateMatches()},{signal:this.#zh.signal})),this._updateMatches()}disable(){this.enabled&&(this.enabled=!1,this.#zh?.abort(),this.#zh=null,this._updateMatches(!0))}_convertMatches(t,e){if(!t)return[];const{textContentItemsStr:i}=this;let n=0,s=0;const r=i.length-1,a=[];for(let o=0,l=t.length;o<l;o++){let l=t[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+=e[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(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:n,textDivs:s}=this,r=i===e.selected.pageIdx,a=e.selected.matchIdx;let o=null;const l={offset:void 0};function h(t,e){const i=t.divIdx;return s[i].textContent="",d(i,0,t.offset,e)}function d(t,e,i,r){let a=s[t];if(a.nodeType===Node.TEXT_NODE){const e=document.createElement("span");a.before(e),e.append(a),s[t]=e,a=e}const o=n[t].substring(e,i),l=document.createTextNode(o);if(r){const t=document.createElement("span");if(t.className=`${r} appended`,t.append(l),a.append(t),r.includes("selected")){const{left:e}=t.getClientRects()[0];return e-a.getBoundingClientRect().left}return 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 n=c;n<u;n++){const c=t[n],u=c.begin;if(u.divIdx===p&&u.offset===g)continue;p=u.divIdx,g=u.offset;const m=c.end,f=r&&n===a,b=f?" 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===m.divIdx)v=d(u.divIdx,u.offset,m.offset,"highlight"+b);else{v=d(u.divIdx,u.offset,l.offset,"highlight begin"+b);for(let t=u.divIdx+1,e=m.divIdx;t<e;t++)s[t].className="highlight middle"+b;h(m,"highlight end"+b)}o=m,f&&e.scrollMatchIntoView({element:s[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:n}=this,{textContentItemsStr:s,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=s[e],t.className=""}a=t.end.divIdx+1}if(!e?.highlightMatches||t)return;const o=e.pageMatches[n]||null,l=e.pageMatchesLength[n]||null;this.matches=this._convertMatches(o,l),this._renderMatches(this.matches)}}class ql{#Ld=!1;#Hh=null;#Rd=!1;#Kl=null;static#Nd=new Map;static#Fd=null;constructor({pdfPage:t,highlighter:e=null,accessibilityManager:i=null,enablePermissions:n=!1,onAppend:s=null}){this.pdfPage=t,this.highlighter=e,this.accessibilityManager=i,this.#Ld=!0===n,this.#Hh=s,this.div=document.createElement("div"),this.div.tabIndex=0,this.div.className="textLayer"}async render({viewport:t,textContentParams:e=null}){if(this.#Rd&&this.#Kl)return this.#Kl.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#Kl=new Xr({textContentSource:this.pdfPage.streamTextContent(e||{includeMarkedContent:!0,disableNormalization:!0}),container:this.div,viewport:t});const{textDivs:i,textContentItemsStr:n}=this.#Kl;this.highlighter?.setTextMapping(i,n),this.accessibilityManager?.setTextMapping(i),await this.#Kl.render(),this.#Rd=!0;const s=document.createElement("div");s.className="endOfContent",this.div.append(s),this.#Bd(s),this.#Hh?.(this.div),this.highlighter?.enable(),this.accessibilityManager?.enable()}hide(){!this.div.hidden&&this.#Rd&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Rd&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#Kl?.cancel(),this.#Kl=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),ql.#Od(this.div)}#Bd(t){const{div:e}=this;e.addEventListener("mousedown",()=>{e.classList.add("selecting")}),e.addEventListener("copy",t=>{if(!this.#Ld){const e=document.getSelection();t.clipboardData.setData("text/plain",ga(Dr(e.toString())))}Gr(t)}),ql.#Nd.set(e,t),ql.#jd()}static#Od(t){this.#Nd.delete(t),0===this.#Nd.size&&(this.#Fd?.abort(),this.#Fd=null)}static#jd(){if(this.#Fd)return;this.#Fd=new AbortController;const{signal:t}=this.#Fd,e=(t,e)=>{e.append(t),t.style.width="",t.style.height="",e.classList.remove("selecting")};let i=!1;var n,s;document.addEventListener("pointerdown",()=>{i=!0},{signal:t}),document.addEventListener("pointerup",()=>{i=!1,this.#Nd.forEach(e)},{signal:t}),window.addEventListener("blur",()=>{i=!1,this.#Nd.forEach(e)},{signal:t}),document.addEventListener("keyup",()=>{i||this.#Nd.forEach(e)},{signal:t}),document.addEventListener("selectionchange",()=>{const t=document.getSelection();if(0===t.rangeCount)return void this.#Nd.forEach(e);const i=new Set;for(let e=0;e<t.rangeCount;e++){const n=t.getRangeAt(e);for(const t of this.#Nd.keys())!i.has(t)&&n.intersectsNode(t)&&i.add(t)}for(const[t,n]of this.#Nd)i.has(t)?t.classList.add("selecting"):e(n,t);if(n??="none"===getComputedStyle(this.#Nd.values().next().value).getPropertyValue("-moz-user-select"),n)return;const r=t.getRangeAt(0),a=s&&(0===r.compareBoundaryPoints(Range.END_TO_END,s)||0===r.compareBoundaryPoints(Range.START_TO_END,s));let o=a?r.startContainer:r.endContainer;if(o.nodeType===Node.TEXT_NODE&&(o=o.parentNode),!a&&0===r.endOffset)do{for(;!o.previousSibling;)o=o.parentNode;o=o.previousSibling}while(!o.childNodes.length);const l=o.parentElement?.closest(".textLayer"),h=this.#Nd.get(l);h&&(h.style.width=l.style.width,h.style.height=l.style.height,o.parentElement.insertBefore(h,a?o:o.nextSibling)),s=r.cloneRange()},{signal:t})}}class Xl{constructor({pdfPage:t,annotationStorage:e=null,linkService:i,xfaHtml:n=null}){this.pdfPage=t,this.annotationStorage=e,this.linkService=i,this.xfaHtml=n,this.div=null,this._cancelled=!1}async render({viewport:t,intent: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,ta.render(i)}const i=await this.pdfPage.getXfa();if(this._cancelled||!i)return{textDivs:[]};const n={viewport:t.clone({dontFlip:!0}),div:this.div,xfaHtml:i,annotationStorage:this.annotationStorage,linkService:this.linkService,intent:e};return this.div?ta.update(n):(this.div=document.createElement("div"),n.div=this.div,ta.render(n))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Yl={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Ka}},Kl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class Ql extends Fl{#Ud=rr.ENABLE_FORMS;#Vd=null;#z=null;#Hd=!0;#zd=!1;#We=!1;#$d=null;#Wd=!1;#Gd=null;#qd=null;#Xd=1;#Yd=1;#Kd=oa;#Qd=1;#Zd={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#Jd=[null,null,null,null];constructor(t){super(t);const e=t.container,i=t.defaultViewport;this.renderingId="page"+this.id,this.#$d=t.layerProperties||Yl,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.#Kd=t.textLayerMode??oa,this.#Ud=t.annotationMode??rr.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??Dl.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||Dl.get("maxCanvasDim"),this.capCanvasAreaFactor=t.capCanvasAreaFactor??Dl.get("capCanvasAreaFactor"),this.#Hd=!1!==t.enableAutoLinking,this.#z=t.commentManager||null,this.l10n=t.l10n,this.l10n||=new wl,this._isStandalone=!this.renderingQueue?.hasViewer(),this._container=e,this._annotationCanvasMap=null,this.annotationLayer=null,this.annotationEditorLayer=null,this.textLayer=null,this.xfaLayer=null,this.structTreeLayer=null,this.drawLayer=null,this.detailView=null;const n=document.createElement("div");if(n.className="page",n.setAttribute("data-page-number",this.id),n.setAttribute("role","region"),n.setAttribute("data-l10n-id","pdfjs-page-landmark"),n.setAttribute("data-l10n-args",JSON.stringify({page:this.id})),this.div=n,this.#tc(),e?.append(n),this._isStandalone){e?.style.setProperty("--scale-factor",this.scale*jr.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.#Zd.initialOptionalContent=t.hasInitialVisibility)}),t.l10n||this.l10n.translate(this.div)}}#ec(t,e){const i=Kl.get(e),n=this.#Jd[i];if(this.#Jd[i]=t,n)n.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#Jd[e];if(i)return void i.after(t)}this.div.prepend(t)}}#tc(){const{div:t,viewport:e}=this;if(e.userUnit!==this.#Qd&&(1!==e.userUnit?t.style.setProperty("--user-unit",e.userUnit):t.style.removeProperty("--user-unit"),this.#Qd=e.userUnit),this.pdfPage){if(this.#qd===e.rotation)return;this.#qd=e.rotation}zr(t,e,!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*jr.PDF_TO_CSS_UNITS,rotation:e}),this.#tc(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return $r(this,"_textHighlighter",new Gl({pageIndex:this.id-1,eventBus:this.eventBus,findController:this.#$d.findController}))}#ic(t,e){this.eventBus.dispatch(t,{source:this,pageNumber:this.id,error:e})}async#nc(){let t=null;try{await this.annotationLayer.render({viewport:this.viewport,intent:"display",structTreeLayer:this.structTreeLayer})}catch(e){console.error("#renderAnnotationLayer:",e),t=e}finally{this.#ic("annotationlayerrendered",t)}}async#sc(){let t=null;try{await this.annotationEditorLayer.render({viewport:this.viewport,intent:"display"})}catch(e){console.error("#renderAnnotationEditorLayer:",e),t=e}finally{this.#ic("annotationeditorlayerrendered",t)}}async#rc(){try{await this.drawLayer.render({intent:"display"})}catch(t){console.error("#renderDrawLayer:",t)}}async#ac(){let t=null;try{const t=await this.xfaLayer.render({viewport:this.viewport,intent:"display"});t?.textDivs&&this._textHighlighter&&this.#oc(t.textDivs)}catch(e){console.error("#renderXfaLayer:",e),t=e}finally{this.xfaLayer?.div&&(this.l10n.pause(),this.#ec(this.xfaLayer.div,"xfaLayer"),this.l10n.resume()),this.#ic("xfalayerrendered",t)}}async#lc(){if(!this.textLayer)return;let t=null;try{await this.textLayer.render({viewport:this.viewport})}catch(e){if(e instanceof Js)return;console.error("#renderTextLayer:",e),t=e}this.#ic("textlayerrendered",t),this.#hc()}async#hc(){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#oc(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()}async#dc(t){try{if(await t,!this.annotationLayer)return;await this.annotationLayer.injectLinkAnnotations(Nl.processLinks(this))}catch(t){console.error("#injectLinkAnnotations:",t)}}_resetCanvas(){super._resetCanvas(),this.#Gd=null}reset({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,keepCanvasWrapper:s=!1,preserveDetailViewState:r=!1}={}){const a=this.pdfPage?._pdfBug??!1;this.cancelRendering({keepAnnotationLayer:t,keepAnnotationEditorLayer:e,keepXfaLayer:i,keepTextLayer:n}),this.renderingState=ea.INITIAL;const o=this.div,l=o.childNodes,h=t&&this.annotationLayer?.div||null,d=e&&this.annotationEditorLayer?.div||null,c=i&&this.xfaLayer?.div||null,u=n&&this.textLayer?.div||null,p=s&&this.#Vd||null;for(let t=l.length-1;t>=0;t--){const e=l[t];switch(e){case h:case d:case c:case u:case p:continue}if(a&&e.classList.contains("pdfBugGroupsLayer"))continue;e.remove();const i=this.#Jd.indexOf(e);i>=0&&(this.#Jd[i]=null)}o.removeAttribute("data-loaded"),h&&this.annotationLayer.hide(),d&&this.annotationEditorLayer.hide(),c&&this.xfaLayer.hide(),u&&this.textLayer.hide(),this.structTreeLayer?.hide(),!s&&this.#Vd&&(this.#Vd=null,this._resetCanvas()),r||(this.detailView?.reset({keepCanvas:s}),s||(this.detailView=null))}toggleEditingMode(t){this.#We=t,this.hasEditableAnnotations()&&this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0})}updateVisibleArea(t){this.enableDetailCanvas&&(this.#Wd&&this.maxCanvasPixels>0&&t?(this.detailView??=new Ol({pageView:this,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering}),this.detailView.update({visibleArea:t})):this.detailView&&(this.detailView.reset(),this.detailView=null))}update({scale:t=0,rotation:e=null,optionalContentConfigPromise:i=null,drawingDelay:n=-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.#Zd.initialOptionalContent=t.hasInitialVisibility)})),this.#Zd.directDrawing=!0;const s=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*jr.PDF_TO_CSS_UNITS,rotation:s}),this.#tc(),this._isStandalone&&this._container?.style.setProperty("--scale-factor",this.viewport.scale),this.#cc(),this.canvas){const t=this.#zd&&this.#Wd,e=n>=0&&n<1e3;if(e||t)return e&&!t&&this.renderingState!==ea.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:n}),this.renderingState=ea.FINISHED,this.#Zd.directDrawing=!1),this.cssTransform({redrawAnnotationLayer:!0,redrawAnnotationEditorLayer:!0,redrawXfaLayer:!0,redrawTextLayer:!e,hideTextLayer:e}),void(e||(this.detailView?.update({underlyingViewUpdated:!0}),this.dispatchPageRendered(!0,!1)))}this.cssTransform({}),this.reset({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,keepCanvasWrapper:!0,preserveDetailViewState:!0}),this.detailView?.update({underlyingViewUpdated:!0})}#cc(){const{width:t,height:e}=this.viewport,i=this.outputScale=new Lr;if(0===this.maxCanvasPixels){const t=1/this.scale;i.sx*=t,i.sy*=t,this.#Wd=!0}else if(this.#Wd=i.limitCanvas(t,e,this.maxCanvasPixels,this.maxCanvasDim,this.capCanvasAreaFactor),this.#Wd&&this.enableDetailCanvas){const t=this.enableOptimizedPartialRendering?4:2;i.sx/=t,i.sy/=t}}cancelRendering({keepAnnotationLayer:t=!1,keepAnnotationEditorLayer:e=!1,keepXfaLayer:i=!1,keepTextLayer:n=!1,cancelExtraDelay:s=0}={}){super.cancelRendering({cancelExtraDelay:s}),!this.textLayer||n&&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({redrawAnnotationLayer:t=!1,redrawAnnotationEditorLayer:e=!1,redrawXfaLayer:i=!1,redrawTextLayer:n=!1,hideTextLayer:s=!1}){const{canvas:r}=this;if(!r)return;const a=this.#Gd;if(this.viewport!==a){const t=(360+this.viewport.rotation-a.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,n=i/e,s=e/i;r.style.transform=`rotate(${t}deg) scale(${n},${s})`}else r.style.transform=0===t?"":`rotate(${t}deg)`}t&&this.annotationLayer&&this.#nc(),e&&this.annotationEditorLayer&&(this.drawLayer&&this.#rc(),this.#sc()),i&&this.xfaLayer&&this.#ac(),this.textLayer&&(s?(this.textLayer.hide(),this.structTreeLayer?.hide()):n&&this.#lc())}get width(){return this.viewport.width}get height(){return this.viewport.height}getPagePoint(t,e){return this.viewport.convertToPdfPoint(t,e)}_ensureCanvasWrapper(){let t=this.#Vd;return t||(t=this.#Vd=document.createElement("div"),t.classList.add("canvasWrapper"),this.#ec(t,"canvasWrapper")),t}_getRenderingContext(t,e,i){return{canvas:t,transform:e,viewport:this.viewport,annotationMode:this.#Ud,optionalContentConfigPromise:this._optionalContentConfigPromise,annotationCanvasMap:this._annotationCanvasMap,pageColors:this.pageColors,isEditing:this.#We,recordOperations:i}}async draw(){this.renderingState!==ea.INITIAL&&(console.error("Must be in new state before drawing"),this.reset());const{div:t,l10n:e,pdfPage:i,viewport:n}=this;if(!i)throw this.renderingState=ea.FINISHED,new Error("pdfPage is not loaded");this.renderingState=ea.RUNNING;const s=this._ensureCanvasWrapper();if(this.textLayer||this.#Kd===aa||i.isPureXfa||(this._accessibilityManager||=new Wl,this.textLayer=new ql({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#Kd===la,onAppend:t=>{this.l10n.pause(),this.#ec(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#Ud!==rr.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:n,enableComment:s,enableScripting:r,fieldObjectsPromise:a,hasJSActionsPromise:o,linkService:l}=this.#$d;this._annotationCanvasMap||=new Map,this.annotationLayer=new Qa({pdfPage:i,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#Ud===rr.ENABLE_FORMS,linkService:l,downloadManager:n,enableComment:s,enableScripting:r,hasJSActionsPromise:o,fieldObjectsPromise:a,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,commentManager:this.#z,onAppend:t=>{this.#ec(t,"annotationLayer")}})}const{width:r,height:a}=n;this.#Gd=n;const{canvas:o,prevCanvas:l}=this._createCanvas(t=>{s.prepend(t)});o.setAttribute("role","presentation"),this.outputScale||this.#cc();const{outputScale:h}=this;this.#zd=this.#Wd;const d=fa(h.sx),c=fa(h.sy),u=o.width=ba(xa(r*h.sx),d[0]),p=o.height=ba(xa(a*h.sy),c[0]),g=ba(xa(r),d[1]),m=ba(xa(a),c[1]);h.sx=u/g,h.sy=p/m,this.#Xd!==d[1]&&(t.style.setProperty("--scale-round-x",`${d[1]}px`),this.#Xd=d[1]),this.#Yd!==c[1]&&(t.style.setProperty("--scale-round-y",`${c[1]}px`),this.#Yd=c[1]);const f=this.enableOptimizedPartialRendering&&this.#zd&&!this.recordedBBoxes,b=h.scaled?[h.sx,0,0,h.sy,0,0]:null,v=this._drawCanvas(this._getRenderingContext(o,b,f),()=>{l?.remove(),this._resetCanvas()},t=>{this.#Zd.regularAnnotations=!t.separateAnnots,this.dispatchPageRendered(!1,!1)}).then(async()=>{if(this.renderingState!==ea.FINISHED)return;this.structTreeLayer||=new $l(i,n.rawDims);const t=this.#lc();this.annotationLayer&&(await this.#nc(),this.#Hd&&this.annotationLayer&&this.textLayer&&await this.#dc(t));const{annotationEditorUIManager:r}=this.#$d;r&&(this.drawLayer||=new Bl({pageIndex:this.id}),await this.#rc(),this.drawLayer.setParent(s),(this.annotationLayer||this.#Ud===rr.DISABLE)&&(this.annotationEditorLayer||=new xl({uiManager:r,pdfPage:i,l10n:e,structTreeLayer:this.structTreeLayer,accessibilityManager:this._accessibilityManager,annotationLayer:this.annotationLayer?.annotationLayer,textLayer:this.textLayer,drawLayer:this.drawLayer.getDrawLayer(),onAppend:t=>{this.#ec(t,"annotationEditorLayer")}}),this.#sc()))});if(i.isPureXfa){if(!this.xfaLayer){const{annotationStorage:t,linkService:e}=this.#$d;this.xfaLayer=new Xl({pdfPage:i,annotationStorage:t,linkService:e})}this.#ac()}return t.setAttribute("data-loaded",!0),this.dispatchPageRender(),v}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.#Zd;return t&&e&&i?this.canvas:null}}class Zl{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 Jl{#uc=null;#pc=null;#gc=null;#zh=null;#ur=null;#mc=null;#xt=null;#fc=null;#bc=!1;#vc=null;#wc=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#ur=t,this.#mc=e,this.#gc=i}setViewer(t){this.#fc=t}async setDocument(t){if(this.#xt&&await this.#yc(),this.#xt=t,!t)return;const[e,i,n]=await Promise.all([t.getFieldObjects(),t.getCalculationOrderIds(),t.getJSActions()]);if(!e&&!n)return void await this.#yc();if(t!==this.#xt)return;try{this.#vc=this.#xc()}catch(t){return console.error("setDocument:",t),void await this.#yc()}const s=this.#ur;this.#zh=new AbortController;const{signal:r}=this.#zh;s._on("updatefromsandbox",t=>{t?.source===window&&this.#Ac(t.detail)},{signal:r}),s._on("dispatcheventinsandbox",t=>{this.#vc?.dispatchEventInSandbox(t.detail)},{signal:r}),s._on("pagechanging",({pageNumber:t,previous:e})=>{t!==e&&(this.#Sc(e),this.#_c(t))},{signal:r}),s._on("pagerendered",({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#fc.currentPageNumber&&this.#_c(t)},{signal:r}),s._on("pagesdestroy",async()=>{await this.#Sc(this.#fc.currentPageNumber),await(this.#vc?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#uc?.resolve()},{signal:r});try{const r=await this.#gc(t);if(t!==this.#xt)return;await this.#vc.createSandbox({objects:e,calculationOrder:i,appInfo:{platform:navigator.platform,language:navigator.language},docInfo:{...r,actions:n}}),s.dispatch("sandboxcreated",{source:this})}catch(t){return console.error("setDocument:",t),void await this.#yc()}await(this.#vc?.dispatchEventInSandbox({id:"doc",name:"Open"})),await this.#_c(this.#fc.currentPageNumber,!0),Promise.resolve().then(()=>{t===this.#xt&&(this.#bc=!0)})}async dispatchWillSave(){return this.#vc?.dispatchEventInSandbox({id:"doc",name:"WillSave"})}async dispatchDidSave(){return this.#vc?.dispatchEventInSandbox({id:"doc",name:"DidSave"})}async dispatchWillPrint(){if(this.#vc){await(this.#wc?.promise),this.#wc=Promise.withResolvers();try{await this.#vc.dispatchEventInSandbox({id:"doc",name:"WillPrint"})}catch(t){throw this.#wc.resolve(),this.#wc=null,t}await this.#wc.promise}}async dispatchDidPrint(){return this.#vc?.dispatchEventInSandbox({id:"doc",name:"DidPrint"})}get destroyPromise(){return this.#pc?.promise||null}get ready(){return this.#bc}get _pageOpenPending(){return $r(this,"_pageOpenPending",new Set)}get _visitedPages(){return $r(this,"_visitedPages",new Map)}async#Ac(t){const e=this.#fc,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:n,siblings:s,command:r,value:a}=t;if(!n){switch(r){case"clear":console.clear();break;case"error":console.error(a);break;case"layout":if(!i){const t=function(t){let e=ha.VERTICAL,i=da.NONE;switch(t){case"SinglePage":e=ha.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=ha.PAGE;case"TwoColumnLeft":i=da.ODD;break;case"TwoPageRight":e=ha.PAGE;case"TwoColumnRight":i=da.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.#ur.dispatch("print",{source:this});break;case"println":console.log(a);break;case"zoom":i||(e.currentScaleValue=a);break;case"SaveAs":this.#ur.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.#wc?.resolve(),this.#wc=null}return}if(i&&t.focus)return;delete t.id,delete t.siblings;const o=s?[n,...s]:[n];for(const e of o){const i=document.querySelector(`[data-element-id="${e}"]`);i?i.dispatchEvent(new CustomEvent("updatefromsandbox",{detail:t})):this.#xt?.annotationStorage.setValue(e,t)}}async#_c(t,e=!1){const i=this.#xt,n=this._visitedPages;if(e&&(this.#uc=Promise.withResolvers()),!this.#uc)return;const s=this.#fc.getPageView(t-1);if(s?.renderingState!==ea.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const r=(async()=>{const e=await(n.has(t)?null:s.pdfPage?.getJSActions());i===this.#xt&&await(this.#vc?.dispatchEventInSandbox({id:"page",name:"PageOpen",pageNumber:t,actions:e}))})();n.set(t,r)}async#Sc(t){const e=this.#xt,i=this._visitedPages;if(!this.#uc)return;if(this._pageOpenPending.has(t))return;const n=i.get(t);n&&(i.set(t,null),await n,e===this.#xt&&await(this.#vc?.dispatchEventInSandbox({id:"page",name:"PageClose",pageNumber:t})))}#xc(){if(this.#pc=Promise.withResolvers(),this.#vc)throw new Error("#initScripting: Scripting already exists.");return this.#mc.createScripting()}async#yc(){if(!this.#vc)return this.#xt=null,void this.#pc?.resolve();this.#uc&&(await Promise.race([this.#uc.promise,new Promise(t=>{setTimeout(t,1e3)})]).catch(()=>{}),this.#uc=null),this.#xt=null;try{await this.#vc.destroySandbox()}catch{}this.#wc?.reject(new Error("Scripting destroyed.")),this.#wc=null,this.#zh?.abort(),this.#zh=null,this._pageOpenPending.clear(),this._visitedPages.clear(),this.#vc=null,this.#bc=!1,this.#pc?.resolve()}}let th=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,n=!1,s=!1){const r=t.views,a=r.length;if(0===a)return null;for(let t=0;t<a;t++){const e=r[t].view;if(!this.isViewFinished(e))return e}if(!s)for(let t=0;t<a;t++){const{detailView:e}=r[t].view;if(e&&!this.isViewFinished(e))return e}const o=t.first.id,l=t.last.id;if(l-o+1>a){const n=t.ids;for(let t=1,s=l-o;t<s;t++){const s=i?o+t:l-t;if(n.has(s))continue;const r=e[s-1];if(!this.isViewFinished(r))return r}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||n&&(h+=i?1:-1,d=e[h],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===ea.FINISHED}renderView(t){switch(t.renderingState){case ea.FINISHED:return!1;case ea.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case ea.RUNNING:this.highestPriorityPage=t.renderingId;break;case ea.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof Ur||console.error("renderView:",t)})}return!0}};const eh=1e4,ih=5e3,nh=250;function sh(t){return Object.values(ir).includes(t)&&t!==ir.DISABLE}class rh{#Cc=new Set;#Ec=0;constructor(t){this.#Ec=t}push(t){const e=this.#Cc;e.has(t)&&e.delete(t),e.add(t),e.size>this.#Ec&&this.#Pc()}resize(t,e=null){this.#Ec=t;const i=this.#Cc;if(e){const t=i.size;let n=1;for(const s of i)if(e.has(s.id)&&(i.delete(s),i.add(s)),++n>t)break}for(;i.size>this.#Ec;)this.#Pc()}has(t){return this.#Cc.has(t)}[Symbol.iterator](){return this.#Cc.keys()}#Pc(){const t=this.#Cc.keys().next().value;t?.destroy(),this.#Cc.delete(t)}}class ah{#Ti=null;#j=null;#Tc=null;#Mc=ir.NONE;#kc=null;#Ud=rr.ENABLE_FORMS;#z=null;#Dc=null;#Ic=null;#tn=!1;#Q=!1;#Ld=!1;#Z=!1;#J=!1;#Hd=!0;#zh=null;#ld=0;#gt=null;#Lc=!0;#Rc=null;#Nc=null;#Fc=null;#Bc=!1;#Oc=null;#jc=!1;#Uc=0;#Vc=new ResizeObserver(this.#Hc.bind(this));#zc=null;#$c=null;#vt=null;#Wc=!0;#Kd=oa;#Pt=null;constructor(t){const e="5.4.394";if(Jr!==e)throw new Error(`The API version "${Jr}" does not match the Viewer version "${e}".`);if(this.container=t.container,this.viewer=t.viewer||t.container.firstElementChild,this.#Pt=t.viewerAlert||null,"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.#Vc.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Ka,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#j=t.altTextManager||null,this.#z=t.commentManager||null,this.#vt=t.signatureManager||null,this.#Ic=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#Kd=t.textLayerMode??oa,this.#Ud=t.annotationMode??rr.ENABLE_FORMS,this.#Mc=t.annotationEditorMode??ir.NONE,this.#Tc=t.annotationEditorHighlightColors||null,this.#Q=!0===t.enableHighlightFloatingButton,this.#Z=!0===t.enableUpdatedAddImage,this.#J=!0===t.enableNewAltTextWhenAddingImage,this.imageResourcesPath=t.imageResourcesPath||"",this.enablePrintAutoRotate=t.enablePrintAutoRotate||!1,this.removePageBorders=t.removePageBorders||!1,this.maxCanvasPixels=t.maxCanvasPixels,this.maxCanvasDim=t.maxCanvasDim,this.capCanvasAreaFactor=t.capCanvasAreaFactor,this.enableDetailCanvas=t.enableDetailCanvas??!0,this.enableOptimizedPartialRendering=t.enableOptimizedPartialRendering??!1,this.l10n=t.l10n,this.l10n||=new wl,this.#Ld=t.enablePermissions||!1,this.pageColors=t.pageColors||null,this.#gt=t.mlManager||null,this.#tn=t.enableHWA||!1,this.#Wc=!1!==t.supportsPinchToZoom,this.#Hd=!1!==t.enableAutoLinking,this.#ld=t.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new th,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",()=>{this.#Vc.disconnect(),this.#Vc=null},{once:!0}),this.scroll=function(t,e,i){const n=function(i){r||(r=window.requestAnimationFrame(function(){r=null;const i=t.scrollLeft,n=s.lastX;i!==n&&(s.right=i>n),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:n};let r=null;return t.addEventListener("scroll",n,{useCapture:!0,signal:i}),i?.addEventListener("abort",()=>window.cancelAnimationFrame(r),{once:!0}),s}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=ia,this._resetView(),this.removePageBorders&&this.viewer.classList.add("removePageBorders"),this.#Gc(),this.eventBus._on("thumbnailrendered",({pageNumber:t,pdfPage:e})=>{const i=this._pages[t-1];this.#Ti.has(i)||e?.cleanup()}),t.l10n||this.l10n.translate(this.container)}get printingAllowed(){return this.#Lc}get pagesCount(){return this._pages.length}getPageView(t){return this._pages[t]}getCachedPageViews(){return new Set(this.#Ti)}get pageViewsReady(){return this._pages.every(t=>t?.pdfPage)}get renderForms(){return this.#Ud===rr.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.#qc(),!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.#qc(),!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.#Xc(t,{noScroll:!1})}get currentScaleValue(){return this._currentScaleValue}set currentScaleValue(t){this.pdfDocument&&this.#Xc(t,{noScroll:!1})}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!va(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.#Xc(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 $r(this,"_layerProperties",{get annotationEditorUIManager(){return t.#kc},get annotationStorage(){return t.pdfDocument?.annotationStorage},get downloadManager(){return t.downloadManager},get enableComment(){return!!t.#z},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}})}#Yc(t){const e={annotationEditorMode:this.#Mc,annotationMode:this.#Ud,textLayerMode:this.#Kd};return t?(this.#Lc=t.includes(Or.PRINT_HIGH_QUALITY)||t.includes(Or.PRINT),this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#Lc}),t.includes(Or.COPY)||this.#Kd!==oa||(e.textLayerMode=la),t.includes(Or.MODIFY_CONTENTS)||(e.annotationEditorMode=ir.DISABLE),t.includes(Or.MODIFY_ANNOTATIONS)||t.includes(Or.FILL_INTERACTIVE_FORMS)||this.#Ud!==rr.ENABLE_FORMS||(e.annotationMode=rr.ENABLE),e):(this.#Lc=!0,this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#Lc}),e)}async#Kc(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:AbortSignal.any([t,i.signal])}),await Promise.race([this._onePageRenderedCapability.promise,e.promise]),i.abort()}async getAllText(){const t=[],e=[];for(let i=1,n=this.pdfDocument.numPages;i<=n;++i){if(this.#jc)return null;e.length=0;const n=await this.pdfDocument.getPage(i),{items:s}=await n.getTextContent();for(const t of s)t.str&&e.push(t.str),t.hasEOL&&e.push("\n");t.push(ga(e.join("")))}return t.join("\n")}#Qc(t,e){const i=document.getSelection(),{focusNode:n,anchorNode:s}=i;if(s&&n&&i.containsNode(this.#Oc)){if(this.#Bc||t===la)return void Gr(e);this.#Bc=!0;const{classList:i}=this.viewer;i.add("copyAll");const n=new AbortController;window.addEventListener("keydown",t=>this.#jc="Escape"===t.key,{signal:n.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.#Bc=!1,this.#jc=!1,n.abort(),i.remove("copyAll")}),Gr(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.#kc?.destroy(),this.#kc=null,this.#Mc=ir.NONE,this.#Lc=!0),this.pdfDocument=t,!t)return;const e=t.numPages,i=t.getPage(1),n=t.getOptionalContentConfig({intent:"display"}),s=this.#Ld?t.getPermissions():Promise.resolve(),{eventBus:r,pageColors:a,viewer:o}=this;this.#zh=new AbortController;const{signal:l}=this.#zh;if(e>eh){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=ha.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.#Ti.push(e)},{signal:l});const h=t=>{t.cssTransform||t.isDetailView||(this._onePageRenderedCapability.resolve({timestamp:t.timestamp}),r._off("pagerendered",h))};r._on("pagerendered",h,{signal:l}),Promise.all([i,s]).then(([i,s])=>{if(t!==this.pdfDocument)return;this._firstPageCapability.resolve(i),this._optionalContentConfigPromise=n;const{annotationEditorMode:h,annotationMode:d,textLayerMode:c}=this.#Yc(s);if(c!==aa){const t=this.#Oc=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if(h!==ir.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):sh(e)?(this.#kc=new nr(this.container,o,this.#Pt,this.#j,this.#z,this.#vt,r,t,a,this.#Tc,this.#Q,this.#Z,this.#J,this.#gt,this.#Ic,this.#Wc),r.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#kc}),e!==ir.NONE&&(this.#Zc(e),this.#kc.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===ha.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*jr.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 Ql({container:u,eventBus:r,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:n,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,pageColors:a,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#tn,enableAutoLinking:this.#Hd,minDurationToUpdateCanvas:this.#ld,commentManager:this.#z});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===ha.PAGE?this.#Jc():this._spreadMode!==da.NONE&&this._updateSpreadMode(),r._on("annotationeditorlayerrendered",t=>{this.#kc&&r.dispatch("annotationeditormodechanged",{source:this,mode:this.#Mc})},{once:!0,signal:l}),this.#Kc(l).then(async()=>{if(t!==this.pdfDocument)return;if(this.findController?.setDocument(t),this._scriptingManager?.setDocument(t),this.#Oc&&document.addEventListener("copy",this.#Qc.bind(this,c),{signal:l}),t.loadingParams.disableAutoFetch||e>ih)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let n=2;n<=e;++n){const e=t.getPage(n).then(t=>{const e=this._pages[n-1];e.pdfPage||e.setPdfPage(t),0===--i&&this._pagesCapability.resolve()},t=>{console.error(`Unable to get page ${n} to initialize viewer`,t),0===--i&&this._pagesCapability.resolve()});n%nh===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.#Ti=new rh(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=ha.VERTICAL,this._previousScrollMode=ha.UNKNOWN,this._spreadMode=da.NONE,this.#zc={previousPageNumber:1,scrollDown:!0,pages:[]},this.#zh?.abort(),this.#zh=null,this.viewer.textContent="",this._updateScrollMode(),this.viewer.removeAttribute("lang"),this.#Oc?.remove(),this.#Oc=null,this.#tu(),this.#eu()}#Jc(){if(this._scrollMode!==ha.PAGE)throw new Error("#ensurePageViewVisible: Invalid scrollMode value.");const t=this._currentPageNumber,e=this.#zc,i=this.viewer;if(i.textContent="",e.pages.length=0,this._spreadMode!==da.NONE||this.isInPresentationMode){const n=new Set,s=this._spreadMode-1;-1===s?n.add(t-1):t%2!==s?(n.add(t-1),n.add(t)):(n.add(t-2),n.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 n){const i=this._pages[t];i&&(r.append(i.div),e.pages.push(i))}i.append(r)}else{const n=this._pages[t-1];i.append(n.div),e.pages.push(n)}e.scrollDown=t>=e.previousPageNumber,e.previousPageNumber=t}_scrollUpdate(){0!==this.pagesCount&&(this.#Rc&&clearTimeout(this.#Rc),this.#Rc=setTimeout(()=>{this.#Rc=null,this.update()},100),this.update())}#iu(t,e=null){const{div:i,id:n}=t;if(this._currentPageNumber!==n&&this._setCurrentPageNumber(n),this._scrollMode===ha.PAGE&&(this.#Jc(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,n=t+i.clientWidth,{scrollLeft:s,clientWidth:r}=this.container;(this._scrollMode===ha.HORIZONTAL||t<s||n>s+r)&&(e={left:0,top:0})}ca(i,e),!this._currentScaleValue&&this._location&&(this._location=null)}#nu(t){return t===this._currentScale||Math.abs(t-this._currentScale)<1e-15}#su(t,e,{noScroll:i=!1,preset:n=!1,drawingDelay:s=-1,origin:r=null}){if(this._currentScaleValue=e.toString(),this.#nu(t))return void(n&&this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:e}));this.viewer.style.setProperty("--scale-factor",t*jr.PDF_TO_CSS_UNITS);const a=s>=0&&s<1e3;this.refresh(!0,{scale:t,drawingDelay:a?s:-1}),a&&(this.#$c=setTimeout(()=>{this.#$c=null,this.refresh()},s));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,n]=this.containerTopLeft;this.container.scrollLeft+=(r[0]-n)*e,this.container.scrollTop+=(r[1]-i)*e}}this.eventBus.dispatch("scalechanging",{source:this,scale:t,presetValue:n?e:void 0}),this.defaultRenderingQueue&&this.update()}get#ru(){return this._spreadMode!==da.NONE&&this._scrollMode!==ha.HORIZONTAL?2:1}#Xc(t,e){let i=parseFloat(t);if(i>0)e.preset=!1,this.#su(i,t,e);else{const n=this._pages[this._currentPageNumber-1];if(!n)return;let s=40,r=5;this.isInPresentationMode?(s=r=4,this._spreadMode!==da.NONE&&(s*=2)):this.removePageBorders?s=r=0:this._scrollMode===ha.HORIZONTAL&&([s,r]=[r,s]);const a=(this.container.clientWidth-s)/n.width*n.scale/this.#ru,o=(this.container.clientHeight-r)/n.height*n.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=wa(n)?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.#su(i,t,e)}}#qc(){const t=this._pages[this._currentPageNumber-1];this.isInPresentationMode&&this.#Xc(this._currentScaleValue,{noScroll:!0}),this.#iu(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:n=!1,center:s=null}){if(!this.pdfDocument)return;const r=Number.isInteger(t)&&this._pages[t-1];if(!r)return void console.error(`scrollPageIntoView: "${t}" is not a valid pageNumber parameter.`);if(this.isInPresentationMode||!e)return void this._setCurrentPageNumber(t,!0);let a,o,l=0,h=0,d=0,c=0;const u=r.rotation%180!=0,p=(u?r.height:r.width)/r.scale/jr.PDF_TO_CSS_UNITS,g=(u?r.width:r.height)/r.scale/jr.PDF_TO_CSS_UNITS;let m=0;switch(e[1].name){case"XYZ":l=e[2],h=e[3],m=e[4],l=null!==l?l:0,h=null!==h?h:g;break;case"Fit":case"FitB":m="page-fit";break;case"FitH":case"FitBH":h=e[2],m="page-width",null===h&&this._location?(l=this._location.left,h=this._location.top):("number"!=typeof h||h<0)&&(h=g);break;case"FitV":case"FitBV":l=e[2],d=p,c=g,m="page-height";break;case"FitR":l=e[2],h=e[3],d=e[4]-l,c=e[5]-h;let t=40,i=5;this.removePageBorders&&(t=i=0),a=(this.container.clientWidth-t)/d/jr.PDF_TO_CSS_UNITS,o=(this.container.clientHeight-i)/c/jr.PDF_TO_CSS_UNITS,m=Math.min(Math.abs(a),Math.abs(o));break;default:return void console.error(`scrollPageIntoView: "${e[1].name}" is not a valid destination type.`)}if(n||(m&&m!==this._currentScale?this.currentScaleValue=m:0===this._currentScale&&(this.currentScaleValue="auto")),"page-fit"===m&&!e[4])return void this.#iu(r);const f=[r.viewport.convertToViewportPoint(l,h),r.viewport.convertToViewportPoint(l+d,h+c)];let b=Math.min(f[0][0],f[1][0]),v=Math.min(f[0][1],f[1][1]);s?("both"!==s&&"vertical"!==s||(v-=(this.container.clientHeight-Math.abs(f[1][1]-f[0][1]))/2),"both"!==s&&"horizontal"!==s||(b-=(this.container.clientWidth-Math.abs(f[1][0]-f[0][0]))/2)):i||(b=Math.max(b,0),v=Math.max(v,0)),this.#iu(r,{left:b,top:v})}_updateLocation(t){const e=this._currentScale,i=this._currentScaleValue,n=parseFloat(i)===e?Math.round(1e4*e)/100:i,s=t.id,r=this._pages[s-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=${s}`;this.isInPresentationMode||(d+=`&zoom=${n},${l},${h}`),this._location={pageNumber:s,scale:n,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 n=Math.max(10,2*i+1);this.#Ti.resize(n,t.ids);for(const{view:t,visibleArea:i}of e)t.updateVisibleArea(i);for(const e of this.#Ti)t.ids.has(e.id)||e.updateVisibleArea(null);this.renderingQueue.renderHighestPriority(t);const s=this._spreadMode===da.NONE&&(this._scrollMode===ha.PAGE||this._scrollMode===ha.VERTICAL),r=this._currentPageNumber;let a=!1;for(const t of e){if(t.percent<100)break;if(t.id===r&&s){a=!0;break}}this._setCurrentPageNumber(a?r:e[0].id),this._updateLocation(t.first),this.eventBus.dispatch("updateviewarea",{source:this,location:this._location})}#au(){const t=this._getVisiblePages(),e=[],{ids:i,views:n}=t;for(const t of n){const{view:n}=t;n.hasEditableAnnotations()?e.push(t):i.delete(n.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===ra}get isChangingPresentationMode(){return this.presentationModeState===sa}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===ha.PAGE?this.#zc.pages:this._pages,e=this._scrollMode===ha.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!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=ma(e,n?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,n=i+e.clientWidth;return s?i<l:n>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!n&&(u=function(t,e,i){if(t<2)return t;let n=e[t].div,s=n.offsetTop+n.clientTop;s>=i&&(n=e[t-1].div,s=n.offsetTop+n.clientTop);for(let i=t-2;i>=0&&(n=e[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)t=i;return t}(u,e,r));let p=n?l:-1;for(let t=u;t<c;t++){const i=e[t],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,m=s.clientHeight,f=c+g,b=u+m;if(-1===p)b>=a&&(p=b);else if((n?c:u)>p)break;if(b<=r||u>=a||f<=o||c>=l)continue;const v=Math.max(0,r-u),w=Math.max(0,o-c),y=v+Math.max(0,b-a),x=(g-(w+Math.max(0,f-l)))/g,A=(m-y)/m*x*100|0;h.push({id:i.id,x:c,y:u,visibleArea:100===A?null:{minX:w,minY:v,maxX:Math.min(f,l)-c,maxY:Math.min(b,a)-u},view:i,percent:A,widthPercent:100*x|0}),d.add(i.id)}const g=h[0],m=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:m,views:h,ids:d}}({scrollEl:this.container,views:t,sortByVisibility:!0,horizontal:e,rtl:i})}cleanup(){for(const t of this._pages)t.renderingState!==ea.FINISHED&&t.reset()}_cancelRendering(){for(const t of this._pages)t.cancelRendering()}async#ou(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}}#lu(t){if(1===t.first?.id)return!0;if(t.last?.id===this.pagesCount)return!1;switch(this._scrollMode){case ha.PAGE:return this.#zc.scrollDown;case ha.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#lu(e),n=this._spreadMode!==da.NONE&&this._scrollMode!==ha.HORIZONTAL,s=null!==this.#$c||null!==this.#Rc&&e.views.some(t=>t.detailView?.renderingCancelled),r=this.renderingQueue.getHighestPriority(e,this._pages,i,n,s);return!!r&&(this.#ou(r).then(()=>{this.renderingQueue.renderView(r)}),!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}),n=wa(i);if(void 0===t)t=n;else if(this.enablePrintAutoRotate&&n!==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(ha).includes(t)&&t!==ha.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>eh||(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===ha.HORIZONTAL),i.classList.toggle("scrollWrapped",e===ha.WRAPPED),this.pdfDocument&&t&&(e===ha.PAGE?this.#Jc():this._previousScrollMode===ha.PAGE&&this._updateSpreadMode(),this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Xc(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(da).includes(t)&&t!==da.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===ha.PAGE)this.#Jc();else if(e.textContent="",this._spreadMode===da.NONE)for(const t of this._pages)e.append(t.div);else{const t=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",e.append(n)):s%2===t&&(n=n.cloneNode(!1),e.append(n)),n.append(i[s].div)}t&&(this._currentScaleValue&&isNaN(this._currentScaleValue)&&this.#Xc(this._currentScaleValue,{noScroll:!0}),this._setCurrentPageNumber(t,!0),this.update())}_getPageAdvance(t,e=!1){switch(this._scrollMode){case ha.WRAPPED:{const{views:i}=this._getVisiblePages(),n=new Map;for(const{id:t,y:e,percent:s,widthPercent:r}of i){if(0===s||r<100)continue;let i=n.get(e);i||n.set(e,i||=[]),i.push(t)}for(const i of n.values()){const n=i.indexOf(t);if(-1===n)continue;const s=i.length;if(1===s)break;if(e)for(let e=n-1,s=0;e>=s;e--){const n=i[e],s=i[e+1]-1;if(n<s)return t-s}else for(let e=n+1,r=s;e<r;e++){const n=i[e],s=i[e-1]+1;if(n>s)return s-t}if(e){const e=i[0];if(e<t)return t-e+1}else{const e=i[s-1];if(e>t)return e-t+1}break}break}case ha.HORIZONTAL:break;case ha.PAGE:case ha.VERTICAL:{if(this._spreadMode===da.NONE)break;const i=this._spreadMode-1;if(e&&t%2!==i)break;if(!e&&t%2===i)break;const{views:n}=this._getVisiblePages(),s=e?t-1:t+1;for(const{id:t,percent:e,widthPercent:i}of n)if(t===s){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:n}){if(null===i&&null===e)throw new Error("Invalid updateScale options: either `steps` or `scaleFactor` must be provided.");if(!this.pdfDocument)return;let s=this._currentScale;if(e>0&&1!==e)s=Math.round(s*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{s=e(10*(s*t).toFixed(2))/10}while(--i>0)}s=Mr(s,.1,10),this.#Xc(s,{noScroll:!1,drawingDelay:t,origin:n})}increaseScale(t={}){this.updateScale({...t,steps:t.steps??1})}decreaseScale(t={}){this.updateScale({...t,steps:-(t.steps??1)})}#Gc(t=this.container.clientHeight){t!==this.#Uc&&(this.#Uc=t,ya.setProperty("--viewer-container-height",`${t}px`))}#Hc(t){for(const e of t)if(e.target===this.container){this.#Gc(Math.floor(e.borderBoxSize[0].blockSize)),this.#Dc=null;break}}get containerTopLeft(){return this.#Dc||=[this.container.offsetTop,this.container.offsetLeft]}#tu(){null!==this.#$c&&(clearTimeout(this.#$c),this.#$c=null),null!==this.#Rc&&(clearTimeout(this.#Rc),this.#Rc=null)}#eu(){this.#Nc?.abort(),this.#Nc=null,null!==this.#Fc&&(clearTimeout(this.#Fc),this.#Fc=null)}#Zc(t){switch(t){case ir.STAMP:this.#gt?.loadModel("altText");break;case ir.SIGNATURE:this.#vt?.loadSignatures()}}get annotationEditorMode(){return this.#kc?this.#Mc:ir.DISABLE}set annotationEditorMode({mode:t,editId:e=null,isFromKeyboard:i=!1,mustEnterInEditMode:n=!1,editComment:s=!1}){if(!this.#kc)throw new Error("The AnnotationEditor is not enabled.");if(this.#Mc===t)return;if(!sh(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;this.#Zc(t);const{eventBus:r,pdfDocument:a}=this,o=async()=>{this.#eu(),this.#Mc=t,await this.#kc.updateMode(t,e,i,n,s),t===this.#Mc&&a===this.pdfDocument&&r.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===ir.NONE||this.#Mc===ir.NONE){const e=t!==ir.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds(),this.cleanup();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#au();if(e&&i){this.#eu(),this.#Nc=new AbortController;const t=AbortSignal.any([this.#zh.signal,this.#Nc.signal]);return void r._on("pagerendered",({pageNumber:t})=>{i.delete(t),0===i.size&&(this.#Fc=setTimeout(o,0))},{signal:t})}}o()}refresh(t=!1,e=Object.create(null)){if(this.pdfDocument){for(const t of this._pages)t.update(e);this.#tu(),t||this.update()}}}class oh extends ah{_resetView(){super._resetView(),this._scrollMode=ha.PAGE,this._spreadMode=da.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}function lh(t,e,i,n){return new(i||(i=Promise))(function(s,r){function a(t){try{l(n.next(t))}catch(t){r(t)}}function o(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(a,o)}l((n=n.apply(t,e||[])).next())})}function hh(t,e,i,n){if("a"===i&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?n:"a"===i?n.call(t):n?n.value:e.get(t)}function dh(t,e,i,n,s){if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s?s.value=i:e.set(t,i),i}var ch,uh,ph,gh,mh;globalThis.pdfjsViewer={AnnotationLayerBuilder:Qa,DownloadManager:Ja,EventBus:io,FindState:Ia,GenericL10n:wl,LinkTarget:Xa,parseQueryString:ua,PDFFindController:qa,PDFHistory:class{#zh=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 n=""!==this._fingerprint&&this._fingerprint!==t;this._fingerprint=t,this._updateUrl=!0===i,this._initialized=!0,this.#hu();const s=window.history.state;if(this._popStateInProgress=!1,this._blockHashChange=0,this._currentHash=yl(),this._numPositionUpdates=0,this._uid=this._maxUid=0,this._destination=null,this._position=null,!this.#du(s,!0)||e){const{hash:t,page:i,rotation:s}=this.#cu(!0);return!t||n||e?void this.#uu(null,!0):void this.#uu({hash:t,page:i,rotation:s},!0)}const r=s.destination;this.#pu(r,s.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.#gu(),this._initialized=!1,this.#mu()),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.#fu(i)&&(null!==i||this._destination))return void console.error(`PDFHistory.push: "${i}" is not a valid pageNumber parameter.`);const n=t||JSON.stringify(e);if(!n)return;let s=!1;if(this._destination&&(function(t,e){if("string"!=typeof t||"string"!=typeof e)return!1;if(t===e)return!0;if(ua(t).get("nameddest")===e)return!0;return!1}(this._destination.hash,n)||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 n in t)if(!i(t[n],e[n]))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 n=0,s=t.length;n<s;n++)if(!i(t[n],e[n]))return!1;return!0}(this._destination.dest,e))){if(this._destination.page)return;s=!0}this._popStateInProgress&&!s||(this.#uu({dest:e,hash:n,page:i,rotation:this.linkService.rotation},s),this._popStateInProgress||(this._popStateInProgress=!0,Promise.resolve().then(()=>{this._popStateInProgress=!1})))}pushPage(t){this._initialized&&(this.#fu(t)?this._destination?.page!==t&&(this._popStateInProgress||(this.#uu({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.#bu()}back(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#du(t)&&t.uid>0&&window.history.back()}forward(){if(!this._initialized||this._popStateInProgress)return;const t=window.history.state;this.#du(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}#uu(t,e=!1){const i=e||!this._destination,n={fingerprint:this._fingerprint,uid:i?this._uid:this._uid+1,destination:t};let s;if(this.#pu(t,n.uid),this._updateUrl&&t?.hash){const{href:e,protocol:i}=document.location;"file:"!==i&&(s=Kr(e,t.hash))}i?window.history.replaceState(n,"",s):window.history.pushState(n,"",s)}#bu(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.#uu(e);if(this._destination.temporary)return void this.#uu(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.#uu(e,i)}#fu(t){return Number.isInteger(t)&&t>0&&t<=this.linkService.pagesCount}#du(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)}#pu(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}#cu(t=!1){const e=unescape(yl()).substring(1),i=ua(e),n=i.get("nameddest")||"";let s=0|i.get("page");return(!this.#fu(s)||t&&n.length>0)&&(s=null),{hash:e,page:s,rotation:this.linkService.rotation}}#vu({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.#bu(!0),this._updateViewareaTimeout=null},1e3))}#wu({state:t}){const e=yl(),i=this._currentHash!==e;if(this._currentHash=e,!t){this._uid++;const{hash:t,page:e,rotation:i}=this.#cu();return void this.#uu({hash:t,page:e,rotation:i},!0)}if(!this.#du(t))return;this._popStateInProgress=!0,i&&(this._blockHashChange++,async function({target:t,name:e,delay:i=0}){if("object"!=typeof t||!(Number.isInteger(i)&&i>=0))throw new Error("waitOnEventOrTimeout - invalid parameters.");const{promise:n,resolve:s}=Promise.withResolvers(),r=new AbortController;function a(t){r.abort(),clearTimeout(o),s(t)}t[t instanceof io?"_on":"addEventListener"](e,a.bind(null,to),{signal:r.signal});const o=setTimeout(a.bind(null,eo),i);return n}({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));const n=t.destination;this.#pu(n,t.uid,!0),va(n.rotation)&&(this.linkService.rotation=n.rotation),n.dest?this.linkService.goToDestination(n.dest):n.hash?this.linkService.setHash(n.hash):n.page&&(this.linkService.page=n.page),Promise.resolve().then(()=>{this._popStateInProgress=!1})}#gu(){this._destination&&!this._destination.temporary||this.#bu()}#hu(){if(this.#zh)return;this.#zh=new AbortController;const{signal:t}=this.#zh;this.eventBus._on("updateviewarea",this.#vu.bind(this),{signal:t}),window.addEventListener("popstate",this.#wu.bind(this),{signal:t}),window.addEventListener("pagehide",this.#gu.bind(this),{signal:t})}#mu(){this.#zh?.abort(),this.#zh=null}},PDFLinkService:Ya,PDFPageView:Ql,PDFScriptingManager:class extends Jl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})}),t.externalServices||={createScripting:()=>new Zl(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const{info:e,metadata:i,contentDispositionFilename:n,contentLength:s}=await t.getMetadata();return{...e,baseURL:"",filesize:s||(await t.getDownloadInfo()).length,filename:n||wr(""),metadata:i?.getRaw(),authors:i?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}},PDFSinglePageViewer:oh,PDFViewer:ah,ProgressBar:class{#yu=null;#xu=null;#Au=0;#Su=null;#Zn=!0;constructor(t){this.#yu=t.classList,this.#Su=t.style}get percent(){return this.#Au}set percent(t){this.#Au=Mr(t,0,100),isNaN(t)?this.#yu.add("indeterminate"):(this.#yu.remove("indeterminate"),this.#Su.setProperty("--progressBar-percent",`${this.#Au}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#Su.setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===this.#Au||isNaN(this.#Au)||(this.#xu&&clearTimeout(this.#xu),this.show(),this.#xu=setTimeout(()=>{this.#xu=null,this.hide()},t))}hide(){this.#Zn&&(this.#Zn=!1,this.#yu.add("hidden"))}show(){this.#Zn||(this.#Zn=!0,this.#yu.remove("hidden"))}},RenderingStates:ea,ScrollMode:ha,SimpleLinkService:Ka,SpreadMode:da,StructTreeLayerBuilder:$l,TextLayerBuilder:ql,XfaLayerBuilder:Xl},"function"==typeof SuppressedError&&SuppressedError;const fh={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},bh={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},vh={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},wh={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},yh={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},xh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Ah(t,e,i=!1){let n=t.offsetParent;if(!n)return void console.error("offsetParent is not set -- cannot scroll");let s=t.offsetTop+t.clientTop,r=t.offsetLeft+t.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;if(e&&(void 0!==e.top&&(s+=e.top),void 0!==e.left)){if(i){const i=t.getBoundingClientRect().width,s=Mt((n.clientWidth-i)/2,20,400);r+=e.left-s}else r+=e.left;n.scrollLeft=r}n.scrollTop=s}function Sh(t,e,i=void 0){const n=function(i){r||(r=window.requestAnimationFrame(function(){r=null;const i=t.scrollLeft,n=s.lastX;i!==n&&(s.right=i>n),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:n};let r=null;return t.addEventListener("scroll",n,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",()=>window.cancelAnimationFrame(r),{once:!0}),s}const _h=/[\x00-\x1F]/g;function Ch(t,e,i=0){let n=i,s=t.length-1;if(s<0||!e(t[s]))return t.length;if(e(t[n]))return n;for(;n<s;){const i=n+s>>1;e(t[i])?s=i:n=i+1}return n}function Eh({view:t,userUnit:e,rotate:i}){const[n,s,r,a]=t,o=i%180!=0,l=(r-n)/72*e,h=(a-s)/72*e;return{width:o?h:l,height:o?l:h}}function Ph(t,e,i){if(t<2)return t;let n=e[t].div,s=n.offsetTop+n.clientTop;s>=i&&(n=e[t-1].div,s=n.offsetTop+n.clientTop);for(let i=t-2;i>=0&&(n=e[i].div,!(n.offsetTop+n.clientTop+n.clientHeight<=s));--i)t=i;return t}function Th({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:n=!1,rtl:s=!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=Ch(e,n?function(t){const e=t.div,i=e.offsetLeft+e.clientLeft,n=i+e.clientWidth;return s?i<l:n>o}:function(t){const e=t.div;return e.offsetTop+e.clientTop+e.clientHeight>r});u>0&&u<c&&!n&&(u=Ph(u,e,r));let p=n?l:-1;for(let t=u;t<c;t++){const i=e[t],s=i.div,c=s.offsetLeft+s.clientLeft,u=s.offsetTop+s.clientTop,g=s.clientWidth,m=s.clientHeight,f=c+g,b=u+m;if(-1===p)b>=a&&(p=b);else if((n?c:u)>p)break;if(b<=r||u>=a||f<=o||c>=l)continue;const v=Math.max(0,r-u),w=Math.max(0,o-c),y=v+Math.max(0,b-a),x=(g-(w+Math.max(0,f-l)))/g,A=(m-y)/m*x*100|0;h.push({id:i.id,x:c,y:u,visibleArea:100===A?null:{minX:w,minY:v,maxX:Math.min(f,l)-c,maxY:Math.min(b,a)-u},view:i,percent:A,widthPercent:100*x|0}),d.add(i.id)}const g=h[0],m=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:m,views:h,ids:d}}function Mh(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 kh(t){const e=t.deltaMode;let i=Mh(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function Dh(t){return Number.isInteger(t)&&t%90==0}function Ih(t){return Number.isInteger(t)&&Object.values(yh).includes(t)&&t!==yh.UNKNOWN}function Lh(t){return Number.isInteger(t)&&Object.values(xh).includes(t)&&t!==xh.UNKNOWN}function Rh(t){return t.width<=t.height}const Nh=new Promise(function(t){window.requestAnimationFrame(t)}),Fh=document.documentElement.style;ch=new WeakMap,uh=new WeakMap,ph=new WeakMap,gh=new WeakMap,mh=new WeakMap;const Bh=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}();class Oh{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){var e;this.idleTimeout&&(clearTimeout(this.idleTimeout),this.idleTimeout=null),this.pdfViewer.forceRendering(t)||this.isThumbnailViewEnabled&&(null===(e=this.pdfThumbnailViewer)||void 0===e?void 0:e.forceRendering())||this.printing||this.onIdle&&(this.idleTimeout=setTimeout(this.onIdle.bind(this),3e4))}getHighestPriority(t,e,i,n=!1,s=!1){const r=t.views,a=r.length;if(0===a)return null;for(let t=0;t<a;t++){const e=r[t].view;if(!this.isViewFinished(e))return e}if(!s)for(let t=0;t<a;t++){const{detailView:e}=r[t].view;if(e&&!this.isViewFinished(e))return e}const o=t.first.id,l=t.last.id;if(l-o+1>a){const n=t.ids;for(let t=1,s=l-o;t<s;t++){const s=i?o+t:l-t;if(n.has(s))continue;const r=e[s-1];if(!this.isViewFinished(r))return r}}let h=i?l:o-2,d=e[h];return d&&!this.isViewFinished(d)||n&&(h+=i?1:-1,d=e[h],d&&!this.isViewFinished(d))?d:null}isViewFinished(t){return t.renderingState===fh.FINISHED}renderView(t){switch(t.renderingState){case fh.FINISHED:return!1;case fh.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case fh.RUNNING:this.highestPriorityPage=t.renderingId;break;case fh.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof Bt||console.error("renderView:",t)})}return!0}}var jh,Uh,Vh,Hh,zh,$h,Wh,Gh;function qh(t){t.width=0,t.height=0}class Xh{static getCanvas(t,e){const i=dh(this,jh,hh(this,jh,"f",Uh)||document.createElement("canvas"),0,Uh);i.width=t,i.height=e;const n=i.getContext("2d",{alpha:!1});return n.save(),n.fillStyle="rgb(255, 255, 255)",n.fillRect(0,0,t,e),n.restore(),[i,i.getContext("2d")]}static destroyCanvas(){hh(this,jh,"f",Uh)&&qh(hh(this,jh,"f",Uh)),dh(this,jh,null,0,Uh)}}jh=Xh,Uh={value:null};class Yh{constructor({container:t,eventBus:e,id:i,defaultViewport:n,optionalContentConfigPromise:s,linkService:r,renderingQueue:a,maxCanvasPixels:o,maxCanvasDim:l,pageColors:h,enableHWA:d,store:c,thumbnailWidth:u}){Vh.add(this),this.id=i,this.renderingId="thumbnail"+i,this.pageLabel=null,this.pdfPage=null,this.rotation=0,this.viewport=n,this.pdfPageRotate=n.rotation,this._optionalContentConfigPromise=s||null,this.maxCanvasPixels=null!=o?o:33554432,this.maxCanvasDim=l||32767,this.pageColors=h||null,this.enableHWA=d||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=a,this.renderTask=null,this.renderingState=fh.INITIAL,this.resume=null,this.store=c,this.thumbnailWidth=u,this.loaded=!1;const p=document.createElement("div");p.className="thumbnail pdfSlickThumbHolder",p.setAttribute("data-page-number",this.id.toString()),this.div=p,hh(this,Vh,"m",Hh).call(this),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=fh.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,hh(this,Vh,"m",Hh).call(this)}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}draw(){return lh(this,void 0,void 0,function*(){if(this.renderingState!==fh.INITIAL)return void console.error("Must be in new state before drawing");const{pageColors:t,pdfPage:e}=this;if(!e)throw this.renderingState=fh.FINISHED,new Error("pdfPage is not loaded");this.renderingState=fh.RUNNING;const{ctx:i,canvas:n,transform:s}=hh(this,Vh,"m",zh).call(this,2),r={canvas:n,canvasContext:i,transform:s,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:t},a=this.renderTask=e.render(r);a.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=fh.PAUSED,void(this.resume=()=>{this.renderingState=fh.RUNNING,t()});t()};let o=null;try{yield a.promise}catch(t){if(t instanceof Bt)return void qh(n);o=t}finally{a===this.renderTask&&(this.renderTask=null)}if(this.renderingState=fh.FINISHED,hh(this,Vh,"m",$h).call(this,n),qh(n),this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:e}),o)throw o})}setImage(t){if(this.renderingState!==fh.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:n}=t;e&&(this.pdfPage||this.setPdfPage(i),n<this.scale||(this.renderingState=fh.FINISHED,hh(this,Vh,"m",$h).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var Kh,Qh,Zh,Jh,td,ed,id;Vh=new WeakSet,Hh=function(){const{width:t,height:e}=this.viewport,i=t/e;this.canvasWidth=this.thumbnailWidth,this.canvasHeight=this.canvasWidth/i|0,this.scale=this.canvasWidth/t;const{style:n}=this.div;n.setProperty("--thumbnail-width",`${this.canvasWidth}px`),n.setProperty("--thumbnail-height",`${this.canvasHeight}px`)},zh=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),n=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),s=new Qt,r=t*this.canvasWidth,a=t*this.canvasHeight;s.limitCanvas(r,a,this.maxCanvasPixels,this.maxCanvasDim),i.width=r*s.sx|0,i.height=a*s.sy|0;return{ctx:n,canvas:i,transform:s.scaled?[s.sx,0,0,s.sy,0,0]:null}},$h=function(t){if(this.renderingState!==fh.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=hh(this,Vh,"m",Gh).call(this,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},Wh=function(t){const e=t.width<<3,i=t.height<<3,n=new Qt;return n.sx=n.sy=1,n.limitCanvas(e,i,this.maxCanvasPixels,this.maxCanvasDim),[e*n.sx|0,i*n.sy|0]},Gh=function(t){const{ctx:e,canvas:i}=hh(this,Vh,"m",zh).call(this,1,!0);if(t.width<=2*i.width)return e.drawImage(t,0,0,t.width,t.height,0,0,i.width,i.height),i;let[n,s]=hh(this,Vh,"m",Wh).call(this,i);const[r,a]=Xh.getCanvas(n,s);for(;n>t.width||s>t.height;)n>>=1,s>>=1;for(a.drawImage(t,0,0,t.width,t.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 e.drawImage(r,0,0,n,s,0,0,i.width,i.height),i};const nd="selected";class sd{constructor({container:t,eventBus:e,linkService:i,renderingQueue:n,maxCanvasPixels:s,maxCanvasDim:r,pageColors:a,abortSignal:o,enableHWA:l,store:h,thumbnailWidth:d}){Kh.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=n,this.maxCanvasPixels=s||33554432,this.maxCanvasDim=r||32767,this.pageColors=a||null,this.enableHWA=l||!1,this.store=h,this.thumbnailWidth=d,this.scroll=Sh(this.container,hh(this,Kh,"m",Qh).bind(this),o),hh(this,Kh,"m",Jh).call(this)}getThumbnail(t){return this._thumbnails[t]}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(nd),e.div.classList.add(nd)}const{first:i,last:n,views:s}=hh(this,Kh,"m",Zh).call(this);if(s.length>0){let r=!1;if(t<=i.id||t>=n.id)r=!0;else for(const{id:e,percent:i}of s)if(e===t){r=i<100;break}r&&Ah(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Dh(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!==fh.FINISHED&&t.reset();Xh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(hh(this,Kh,"m",td).call(this),hh(this,Kh,"m",Jh).call(this)),this.pdfDocument=t,!t)return;const e=t.getPage(1),i=t.getOptionalContentConfig({intent:"display"});e.then(e=>{var n;const s=t.numPages,r=e.getViewport({scale:1});for(let t=1;t<=s;++t){const e=new Yh({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:r.clone(),optionalContentConfigPromise:i,linkService:this.linkService,renderingQueue:this.renderingQueue,maxCanvasPixels:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableHWA:this.enableHWA,store:this.store,thumbnailWidth:this.thumbnailWidth});this._thumbnails.push(e)}null===(n=this._thumbnails[0])||void 0===n||n.setPdfPage(e);this._thumbnails[this._currentPageNumber-1].div.classList.add(nd),this.store.getState()._setThumbnailsViews(this._thumbnails)}).catch(t=>{console.error("Unable to initialize thumbnail viewer",t)})}setPageLabels(t){var e,i;if(this.pdfDocument){t?Array.isArray(t)&&this.pdfDocument.numPages===t.length?this._pageLabels=t:(this._pageLabels=null,console.error("PDFThumbnailViewer_setPageLabels: Invalid page labels.")):this._pageLabels=null;for(let t=0,n=this._thumbnails.length;t<n;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=hh(this,Kh,"m",Zh).call(this),e=hh(this,Kh,"m",id).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e,!1,!0);return!!i&&(hh(this,Kh,"m",ed).call(this,i).then(()=>{this.renderingQueue.renderView(i)}),!0)}}Kh=new WeakSet,Qh=function(){this.renderingQueue.renderHighestPriority()},Zh=function(){return Th({scrollEl:this.container,views:this._thumbnails})},Jh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},td=function(){for(const t of this._thumbnails)t.cancelRendering()},ed=function(t){return lh(this,void 0,void 0,function*(){if(t.pdfPage)return t.pdfPage;try{const e=yield this.pdfDocument.getPage(t.id);return t.pdfPage||t.setPdfPage(e),e}catch(t){return console.error("Unable to get page for thumb view",t),null}})},id=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};let rd=null;class ad{constructor({pdfDocument:t,pagesOverview:e,printContainer:i,printResolution:n,printAnnotationStoragePromise:s=null}){this.pdfDocument=t,this.pagesOverview=e,this.printContainer=i,this._printResolution=n||150,this._optionalContentConfigPromise=t.getOptionalContentConfig({intent:"print"}),this._printAnnotationStoragePromise=s||Promise.resolve(),this.currentPage=-1,this.scratchCanvas=document.createElement("canvas")}layout(){this.throwIfInactive();const t=document.querySelector("body");t.setAttribute("data-pdfjsprinting","true");const{width:e,height:i}=this.pagesOverview[0];this.pagesOverview.every(t=>t.width===e&&t.height===i)||console.warn("Not all pages have the same size. The printed result may be incorrect!"),this.pageStyleSheet=document.createElement("style"),this.pageStyleSheet.textContent=`@page { size: ${e}pt ${i}pt;}`,t.append(this.pageStyleSheet)}destroy(){if(rd!==this)return;this.printContainer.textContent="";document.querySelector("body").removeAttribute("data-pdfjsprinting"),this.pageStyleSheet&&(this.pageStyleSheet.remove(),this.pageStyleSheet=null),this.scratchCanvas.width=this.scratchCanvas.height=0,this.scratchCanvas=null,rd=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,n=new Ka,s=Math.round(100*Rt.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:n,xfaHtml:r}),o=Gt(r,{scale:s});a.render({viewport:o,intent:"print"}),i.append(a.div)}}(this.printContainer,this.pdfDocument),Promise.resolve();const e=this.pagesOverview.length,i=(n,s)=>{if(this.throwIfInactive(),++this.currentPage>=e)return t({index:e,total:e}),void n();const r=this.currentPage;t({index:r,total:e}),function(t,e,i,n,s,r,a){const o=t.scratchCanvas,l=s/Rt.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([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:n.rotation}),intent:"print",annotationMode:D.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise.catch(t=>{throw t instanceof Bt||console.error(t),t})})}(this,this.pdfDocument,r+1,this.pagesOverview[r],this._printResolution,this._optionalContentConfigPromise,this._printAnnotationStoragePromise).then(this.useRenderedPage.bind(this)).then(function(){i(n,s)},s)};return new Promise(i)}useRenderedPage(){this.throwIfInactive();const t=document.createElement("img");this.scratchCanvas.toBlob(e=>{t.src=URL.createObjectURL(e)});const e=document.createElement("div");e.className="printedPage",e.append(t),this.printContainer.append(e);const{promise:i,resolve:n,reject:s}=Promise.withResolvers();return t.onload=n,t.onerror=s,i.catch(()=>{}).then(()=>{URL.revokeObjectURL(t.src)}),i}performPrint(){return this.throwIfInactive(),new Promise(t=>{setTimeout(()=>{this.active?(window.print(),setTimeout(t,20)):t()},0)})}get active(){return this===rd}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const od={instance:{supportsPrinting:!0,createPrintService(t){if(rd)throw new Error("The print service is created and active.");return rd=new ad(t)}}};var ld,hd,dd,cd,ud,pd,gd,md,fd,bd,vd,wd,yd,xd,Ad,Sd,_d,Cd,Ed;const Pd="pdfPresentationMode",Td="pdfPresentationModeControls",Md=Math.PI/6;class kd{constructor({container:t,pdfViewer:e,eventBus:i}){ld.add(this),hd.set(this,bh.UNKNOWN),dd.set(this,null),cd.set(this,null),ud.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 lh(this,void 0,void 0,function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;hh(this,ld,"m",Cd).call(this),hh(this,ld,"m",gd).call(this,bh.CHANGING);const i=t.requestFullscreen();dh(this,dd,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null}),e.spreadMode===xh.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),hh(this,dd,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==L.DISABLE&&(hh(this,dd,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){hh(this,ld,"m",Ed).call(this),hh(this,ld,"m",gd).call(this,bh.NORMAL)}return!1})}get active(){return hh(this,hd,"f")===bh.CHANGING||hh(this,hd,"f")===bh.FULLSCREEN}}hd=new WeakMap,dd=new WeakMap,cd=new WeakMap,ud=new WeakMap,ld=new WeakSet,pd=function(t){if(!this.active)return;t.preventDefault();const e=kh(t),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&hh(this,ld,"m",xd).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;hh(this,ld,"m",xd).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},gd=function(t){dh(this,hd,t),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},md=function(){var t;hh(this,ld,"m",gd).call(this,bh.FULLSCREEN),this.container.classList.add(Pd),setTimeout(()=>{this.pdfViewer.scrollMode=yh.PAGE,null!==hh(this,dd,"f").spreadMode&&(this.pdfViewer.spreadMode=xh.NONE),this.pdfViewer.currentPageNumber=hh(this,dd,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==hh(this,dd,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:L.NONE})},0),hh(this,ld,"m",Sd).call(this),hh(this,ld,"m",wd).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},fd=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Pd),setTimeout(()=>{hh(this,ld,"m",Ed).call(this),hh(this,ld,"m",gd).call(this,bh.NORMAL),this.pdfViewer.scrollMode=hh(this,dd,"f").scrollMode,null!==hh(this,dd,"f").spreadMode&&(this.pdfViewer.spreadMode=hh(this,dd,"f").spreadMode),this.pdfViewer.currentScaleValue=hh(this,dd,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==hh(this,dd,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:hh(this,dd,"f").annotationEditorMode}),dh(this,dd,null)},0),hh(this,ld,"m",_d).call(this),hh(this,ld,"m",yd).call(this),hh(this,ld,"m",xd).call(this),this.contextMenuOpen=!1},bd=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()))},vd=function(){this.contextMenuOpen=!0},wd=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(Td),this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(Td),delete this.controlsTimeout},3e3)},yd=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(Td),delete this.controlsTimeout)},xd=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Ad=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,n=this.touchSwipeState.endY-this.touchSwipeState.startY,s=Math.abs(Math.atan2(n,i));Math.abs(i)>50&&(s<=Md||s>=Math.PI-Md)?e=i:Math.abs(n)>50&&Math.abs(s-Math.PI/2)<=Md&&(e=n),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Sd=function(){if(hh(this,ud,"f"))return;dh(this,ud,new AbortController);const{signal:t}=hh(this,ud,"f"),e=hh(this,ld,"m",Ad).bind(this);window.addEventListener("mousemove",hh(this,ld,"m",wd).bind(this),{signal:t}),window.addEventListener("mousedown",hh(this,ld,"m",bd).bind(this),{signal:t}),window.addEventListener("wheel",hh(this,ld,"m",pd).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",hh(this,ld,"m",xd).bind(this),{signal:t}),window.addEventListener("contextmenu",hh(this,ld,"m",vd).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},_d=function(){var t;null===(t=hh(this,ud,"f"))||void 0===t||t.abort(),dh(this,ud,null)},Cd=function(){hh(this,cd,"f")||(dh(this,cd,new AbortController),window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?hh(this,ld,"m",md).call(this):hh(this,ld,"m",fd).call(this)},{signal:hh(this,cd,"f").signal}))},Ed=function(){var t;null===(t=hh(this,cd,"f"))||void 0===t||t.abort(),dh(this,cd,null)};const Dd={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:xh.UNKNOWN,scrollMode:yh.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:L.NONE,pdfSlick:null},Id=()=>{return(t=(t,e)=>Object.assign(Object.assign({},Dd),{_setThumbnailView:(i,n)=>{const s=new Map(e().thumbnails),r=new Map(e().thumbnailViews),{canvasWidth:a,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=n;r.set(i,n),s.set(i,{pageNumber:i,width:a,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:r,thumbnails:s})},_setThumbnailsViews:e=>{const i=new Map(e.map(t=>[t.id,t])),n=new Map(e.map(t=>{const{canvasWidth:e,canvasHeight:i,scale:n,rotation:s,loaded:r,pageLabel:a,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:n,rotation:s,loaded:r,pageLabel:a,src:o}]}));t({thumbnailViews:i,thumbnails:n})}}))?b(t):b;var t};var Ld,Rd,Nd,Fd,Bd,Od,jd,Ud,Vd,Hd,zd,$d,Wd,Gd,qd,Xd,Yd,Kd,Qd,Zd,Jd,tc,ec,ic,nc,sc,rc;class ac{constructor({eventBus:t,slick:e,printDialog:i}){Ld.add(this),Rd.set(this,null),Nd.set(this,null),Fd.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return od.instance.supportsPrinting}get printing(){return!!hh(this,Rd,"f")}print(){return lh(this,void 0,void 0,function*(){var t,e;if(this.supportsPrinting)if(this.printing)console.warn("Ignored pdf print because of a pending print job.");else{yield null===(t=this.printDialog)||void 0===t?void 0:t.open({close:()=>this.abort()});try{this.eventBus.dispatch("beforeprint",{source:this})}finally{if(this.printing){const t=hh(this,Rd,"f");yield t.renderPages(t=>{var e;return null===(e=this.printDialog)||void 0===e?void 0:e.progress(t)}).then(()=>t.performPrint()).catch(()=>{}).then(()=>{t===hh(this,Rd,"f")&&this.abort()})}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}})}abort(){var t;hh(this,Rd,"f")&&(hh(this,Rd,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){dh(this,Nd,new AbortController);const{signal:t}=hh(this,Nd,"f"),e={signal:t};this.eventBus._on("beforeprint",hh(this,Ld,"m",Bd).bind(this),e),this.eventBus._on("afterprint",hh(this,Ld,"m",Od).bind(this),e),window.addEventListener("beforeprint",()=>this.eventBus.dispatch("beforeprint",{source:window}),e),window.addEventListener("afterprint",()=>this.eventBus.dispatch("afterprint",{source:window}),e),window.addEventListener("keydown",t=>{80!==t.keyCode||!t.ctrlKey&&!t.metaKey||t.altKey||t.shiftKey&&!window.chrome&&!window.opera||(this.print(),t.preventDefault(),t.stopImmediatePropagation())},{signal:t,capture:!0})}unbindEvents(){var t;null===(t=hh(this,Nd,"f"))||void 0===t||t.abort(),dh(this,Nd,null)}}Rd=new WeakMap,Nd=new WeakMap,Fd=new WeakMap,Ld=new WeakSet,Bd=function(){hh(this,Rd,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(dh(this,Fd,function(){const t=document.createElement("div");t.classList.add("pdfSlickPrintContainer"),document.body.append(t);const e=document.createElement("style");return e.textContent="\n@page {\n margin: 0;\n}\n\n.pdfSlickPrintContainer {\n display: none;\n}\n\n@media print {\n body {\n background: rgb(0 0 0 / 0) none;\n }\n\n body[data-pdfjsprinting] > *:not(.pdfSlickPrintContainer) {\n display: none;\n }\n\n body[data-pdfjsprinting] .pdfSlickPrintContainer {\n display: block;\n }\n\n .pdfSlickPrintContainer {\n height: 100%;\n }\n\n /* wrapper around (scaled) print canvas elements */\n .pdfSlickPrintContainer > .printedPage {\n page-break-after: always;\n page-break-inside: avoid;\n\n /* The wrapper always cover the whole page. */\n height: 100%;\n width: 100%;\n\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage .xfaPage {\n position: absolute;\n }\n\n .pdfSlickPrintContainer > .xfaPrintedPage {\n page-break-after: always;\n page-break-inside: avoid;\n width: 100%;\n height: 100%;\n position: relative;\n }\n\n .pdfSlickPrintContainer > .printedPage :is(canvas, img) {\n /* The intrinsic canvas / image size will make sure that we fit the page. */\n max-width: 100%;\n max-height: 100%;\n\n direction: ltr;\n display: block;\n }\n}",document.body.append(e),{get element(){return t},remove:()=>{t.remove(),e.remove()}}}()),dh(this,Rd,od.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:hh(this,Fd,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null})),this.slick.forceRendering(),hh(this,Rd,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then(t=>{window.alert(t)}))},Od=function(){var t,e,i;hh(this,Rd,"f")&&(hh(this,Rd,"f").destroy(),dh(this,Rd,null),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=hh(this,Fd,"f"))||void 0===e||e.remove(),dh(this,Fd,null),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class oc{static create(){let t=document.querySelector("#printServiceDialog");if(!t){const e=(t,e,i)=>{const n=document.createElement(t);return Object.entries(e).forEach(([t,e])=>n.setAttribute(t,e)),n.append(...i),n};t=e("dialog",{id:"printServiceDialog",class:"pdfSlick-dialog",style:"min-width: 200px;"},[e("div",{class:"row"},[e("span",{"data-l10n-id":"pdfjs-print-progress-message"},["Preparing document for printing…"])]),e("div",{class:"row"},[e("progress",{value:"0",max:"100"},[]),e("span",{"data-l10n-id":"pdfjs-print-progress-percent","data-l10n-args":'{ "progress": 0 }',class:"relative-progress"},["0%"])]),e("div",{class:"buttonRow"},[e("button",{id:"printCancel",class:"dialogButton",type:"button"},[e("span",{"data-l10n-id":"pdfjs-print-progress-close-button"},["Cancel"])])])]),document.body.append(t)}return new oc(t)}constructor(t){this.dialog=t}open(t){return lh(this,void 0,void 0,function*(){const e=this.dialog.querySelector("#printCancel"),i=()=>{var n;this.dialog.removeEventListener("close",i),this.dialog.removeEventListener("cancel",i),null==e||e.removeEventListener("click",i),null===(n=null==t?void 0:t.close)||void 0===n||n.call(t),this.close()};this.dialog.addEventListener("close",i),this.dialog.addEventListener("cancel",i),null==e||e.addEventListener("click",i),this.dialog.showModal()})}close(){this.dialog.close()}progress({index:t,total:e}){const i=Math.round(100*t/e),n=this.dialog.querySelector("progress"),s=this.dialog.querySelector(".relative-progress");n.value=i,s.setAttribute("data-l10n-args",JSON.stringify({progress:i}))}}ln.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:s&&"SCRIPT"===s.tagName.toUpperCase()&&s.src||new URL("index.js",document.baseURI).href).toString();const lc={"8.5x11":"Letter","8.5x14":"Legal"},hc={"297x420":"A3","210x297":"A4"};function dc(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}class cc{constructor({container:t,viewer:e,thumbs:i,store:n=Id(),options:s,onError:r,printDialog:a}){var o,l,h,d,c,u,p,g,m,f,b,v,w,y,x,A,S,_,C,E,P,T;jd.add(this),Ud.set(this,void 0),Vd.set(this,void 0),Hd.set(this,void 0),zd.set(this,void 0),$d.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,Wd.set(this,void 0),Gd.set(this,void 0),qd.set(this,void 0),Xd.set(this,void 0),dh(this,Vd,t),dh(this,Hd,e),dh(this,zd,i),dh(this,qd,r),this.l10n=null!==(o=null==s?void 0:s.l10n)&&void 0!==o?o:new wl(navigator.language),this.downloadManager=new Ja,this.textLayerMode=null!==(l=null==s?void 0:s.textLayerMode)&&void 0!==l?l:wh.ENABLE,dh(this,Wd,null!==(h=null==s?void 0:s.annotationMode)&&void 0!==h?h:D.ENABLE_FORMS),dh(this,Gd,null!==(d=null==s?void 0:s.annotationEditorMode)&&void 0!==d?d:L.NONE),this.annotationEditorHighlightColors=null!==(c=null==s?void 0:s.annotationEditorHighlightColors)&&void 0!==c?c:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(u=null==s?void 0:s.removePageBorders)&&void 0!==u&&u,this.singlePageViewer=null!==(p=null==s?void 0:s.singlePageViewer)&&void 0!==p&&p,this.enablePrintAutoRotate=null!==(g=null==s?void 0:s.enablePrintAutoRotate)&&void 0!==g&&g,this.useOnlyCssZoom=null!==(m=null==s?void 0:s.useOnlyCssZoom)&&void 0!==m&&m,this.pageColors=null!==(f=null==s?void 0:s.pageColors)&&void 0!==f?f:null,this.maxCanvasPixels=null!==(b=null==s?void 0:s.maxCanvasPixels)&&void 0!==b?b:Math.pow(2,24),this.maxCanvasDim=null!==(v=null==s?void 0:s.maxCanvasDim)&&void 0!==v?v:32767,this.capCanvasAreaFactor=null!==(w=null==s?void 0:s.capCanvasAreaFactor)&&void 0!==w?w:200,this.printResolution=null!==(y=null==s?void 0:s.printResolution)&&void 0!==y?y:96,this.thumbnailWidth=null!==(x=null==s?void 0:s.thumbnailWidth)&&void 0!==x?x:125,this.enableHWA=null!==(A=null==s?void 0:s.enableHWA)&&void 0!==A&&A,this.enableDetailCanvas=null===(S=null==s?void 0:s.enableDetailCanvas)||void 0===S||S,this.enableOptimizedPartialRendering=null!==(_=null==s?void 0:s.enableOptimizedPartialRendering)&&void 0!==_&&_,this.minDurationToUpdateCanvas=null!==(C=null==s?void 0:s.minDurationToUpdateCanvas)&&void 0!==C?C:500,this.getDocumentParams=null!==(E=null==s?void 0:s.getDocumentParams)&&void 0!==E?E:{},!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=n;const M=new Oh;M.onIdle=this._cleanup.bind(this),M.isThumbnailViewEnabled=!0,dh(this,Ud,M);const k=new io,I=new Ya({eventBus:k,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),R=new qa({eventBus:k,linkService:I}),N=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:k,linkService:I,findController:R,renderingQueue:M,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:hh(this,Wd,"f"),annotationEditorMode:hh(this,Gd,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/",enableHWA:this.enableHWA,enableDetailCanvas:this.enableDetailCanvas,enableOptimizedPartialRendering:this.enableOptimizedPartialRendering,minDurationToUpdateCanvas:this.minDurationToUpdateCanvas,maxCanvasPixels:!0===this.useOnlyCssZoom?0:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,capCanvasAreaFactor:this.capCanvasAreaFactor}),F=this.singlePageViewer?new oh(N):new ah(N);M.setViewer(F),i&&(this.thumbnailViewer=new sd({container:i,eventBus:k,linkService:I,renderingQueue:M,maxCanvasPixels:!0===this.useOnlyCssZoom?0:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableHWA:this.enableHWA,store:n,thumbnailWidth:this.thumbnailWidth,abortSignal:null===(P=hh(this,Xd,"f"))||void 0===P?void 0:P.signal}),M.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new kd({container:t,pdfViewer:F,eventBus:k})),this.eventBus=k,this.linkService=I,this.findController=R,this.viewer=F,this.linkService.setViewer(F),dh(this,$d,new ac({eventBus:k,slick:this,printDialog:null!=a?a:oc.create()}));const B=null!==(T=null==s?void 0:s.scaleValue)&&void 0!==T?T:"auto";this.store.setState({scaleValue:B})}loadDocument(t,e){return lh(this,void 0,void 0,function*(){var i,n,s,r,a;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===(n=this.viewer)||void 0===n||n.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!==(s=null==e?void 0:e.filename)&&void 0!==s?s:Ut(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=o;const l=On(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(l.onProgress=e.onProgress);const h=yield l.promise;this.document=h,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(a=this.thumbnailViewer)||void 0===a||a.setDocument(h)),hh(this,jd,"m",Zd).call(this),yield hh(this,jd,"m",Yd).call(this),this.store.setState({filename:o,numPages:h.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const d=yield h.getAttachments(),c=new Map(Object.keys(null!=d?d:{}).sort((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())).map(t=>[t,d[t]]));this.store.setState({attachments:c}),yield hh(this,jd,"m",Kd).call(this),this.forceRendering()}catch(t){hh(this,qd,"f")&&hh(this,qd,"f").call(this,t)}})}forceRendering(t=!0){hh(this,Ud,"f").printing=!!hh(this,$d,"f").printing,hh(this,Ud,"f").isThumbnailViewEnabled=t,hh(this,Ud,"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(){return lh(this,void 0,void 0,function*(){var t,e;const i=this.url,{filename:n}=this;try{const e=(yield this.document.getData()).slice(0),s=new Blob([e],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(s,i,n)}catch(t){yield null===(e=this.downloadManager)||void 0===e?void 0:e.download(null,i,n)}})}save(){return lh(this,void 0,void 0,function*(){var t;const e=this.url,{filename:i}=this;try{const n=(yield this.document.saveDocument()).slice(0),s=new Blob([n],{type:"application/pdf"});yield null===(t=this.downloadManager)||void 0===t?void 0:t.download(s,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 hh(this,$d,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){hh(this,$d,"f").print()}unbindEvents(){var t;null===(t=hh(this,Xd,"f"))||void 0===t||t.abort(),dh(this,Xd,null),hh(this,$d,"f").unbindEvents()}_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(L.HIGHLIGHT),this.setAnnotationEditorParams([{type:R.HIGHLIGHT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){Lh(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){Ih(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){Dh(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)}}Ud=new WeakMap,Vd=new WeakMap,Hd=new WeakMap,zd=new WeakMap,$d=new WeakMap,Wd=new WeakMap,Gd=new WeakMap,qd=new WeakMap,Xd=new WeakMap,jd=new WeakSet,Yd=function(){return lh(this,void 0,void 0,function*(){var t;const e=this.document,i=null!==(t=yield e.getPageLabels())&&void 0!==t?t:[],n=i.length;let s=0,r=0;for(let t=0;t<n;t++){const e=i[t];if(e===(t+1).toString())s++;else{if(""!==e)break;r++}}if(s>=n||r>=n)return;const{viewer:a,thumbnailViewer:o}=this;a.setPageLabels(i),null==o||o.setPageLabels(i)})},Kd=function(){return lh(this,void 0,void 0,function*(){const{info:t,contentLength:e}=yield this.document.getMetadata(),i=yield this.document.getPage(this.store.getState().pageNumber).then(t=>hh(this,jd,"m",Qd).call(this,Eh(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:Wt.toDateObject(t.CreationDate),modificationDate:Wt.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})})},Qd=function(t,e){return lh(this,void 0,void 0,function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=Rh(t);let n={width:Math.round(100*t.width)/100,height:Math.round(100*t.height)/100},s={width:Math.round(25.4*t.width*10)/10,height:Math.round(25.4*t.height*10)/10},r=dc(n,i,lc)||dc(s,i,hc);if(!(r||Number.isInteger(s.width)&&Number.isInteger(s.height))){const e={width:25.4*t.width,height:25.4*t.height},a={width:Math.round(s.width),height:Math.round(s.height)};Math.abs(e.width-a.width)<.1&&Math.abs(e.height-a.height)<.1&&(r=dc(a,i,hc),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,d]=yield Promise.all([n,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}})},Zd=function(){dh(this,Xd,new AbortController);const{signal:t}=hh(this,Xd,"f"),e={signal:t};this.eventBus._on("pagesinit",hh(this,jd,"m",Jd).bind(this),e),this.eventBus._on("scalechanging",hh(this,jd,"m",nc).bind(this),e),this.eventBus._on("pagechanging",hh(this,jd,"m",sc).bind(this),e),this.eventBus._on("pagerendered",hh(this,jd,"m",rc).bind(this),e),this.eventBus._on("rotationchanging",hh(this,jd,"m",tc).bind(this),e),this.eventBus._on("switchspreadmode",hh(this,jd,"m",ec).bind(this),e),this.eventBus._on("switchscrollmode",hh(this,jd,"m",ic).bind(this),e)},Jd=function(t){return lh(this,arguments,void 0,function*({source:t}){var e;const i=yield null===(e=this.document)||void 0===e?void 0:e.getOutline(),n=this.store.getState().scaleValue;t.currentScaleValue=null!=n?n:"auto",this.store.setState({documentOutline:i,pageNumber:1,scaleValue:n,pagesReady:!0})})},tc=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},ec=function({mode:t}){this.store.setState({spreadMode:t})},ic=function({mode:t}){this.store.setState({scrollMode:t})},nc=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},sc=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},rc=function({pageNumber:t,error:e}){var i;if(hh(this,zd,"f")){const e=this.viewer.getPageView(t-1),n=null===(i=this.thumbnailViewer)||void 0===i?void 0:i.getThumbnail(t-1);e&&n&&n.setImage(e)}};var uc=function(){},pc="undefined"!=typeof window,gc=pc?e.useLayoutEffect:e.useEffect;function mc(t,i,n){void 0===n&&(n=[]);var s=function(t,i){var n=e.useRef(!1),s=e.useRef(),r=e.useRef(t),a=e.useCallback(function(){return n.current},[]),o=e.useCallback(function(){n.current=!1,s.current&&clearTimeout(s.current),s.current=setTimeout(function(){n.current=!0,r.current()},i)},[i]),l=e.useCallback(function(){n.current=null,s.current&&clearTimeout(s.current)},[]);return e.useEffect(function(){r.current=t},[t]),e.useEffect(function(){return o(),l},[i]),[a,l,o]}(t,i),r=s[0],a=s[1],o=s[2];return e.useEffect(o,n),[r,a]}var fc={x:0,y:0,width:0,height:0,top:0,left:0,bottom:0,right:0};var bc=pc&&void 0!==window.ResizeObserver?function(){var t=e.useState(null),i=t[0],n=t[1],s=e.useState(fc),r=s[0],a=s[1],o=e.useMemo(function(){return new window.ResizeObserver(function(t){if(t[0]){var e=t[0].contentRect,i=e.x,n=e.y,s=e.width,r=e.height,o=e.top,l=e.left,h=e.bottom,d=e.right;a({x:i,y:n,width:s,height:r,top:o,left:l,bottom:h,right:d})}})},[]);return gc(function(){if(i)return o.observe(i),function(){o.disconnect()}},[i]),[n,r]}:function(){return[uc,fc]};function vc({usePDFSlickStore:t,viewerRef:e,className:n}){const s=t(t=>t.pdfSlick),r=t(t=>t.scaleValue),[a,{width:o}]=bc();return mc(()=>{o&&(!s||"auto"!==r&&"page-fit"!==r&&"page-width"!==r||(s.viewer.currentScaleValue=r),null==s||s.viewer.update())},0,[o]),i.jsx("div",{ref:t=>{e(t),a(t)},id:"viewerContainer",className:`pdfSlickContainer ${null!=n?n:""}`,style:{position:"absolute",inset:0,overflow:"auto"},children:i.jsx("div",{id:"viewer",className:"pdfSlickViewer pdfViewer"})})}function wc({children:t,thumbsRef:e,usePDFSlickStore:s,className:r}){const a=s(t=>t.thumbnailViews),o=s(t=>t.pdfSlick),[l,{width:h}]=bc();return mc(()=>{h&&(null==o||o.forceRendering())},0,[h]),i.jsx("div",{ref:t=>{e(t),l(t)},className:r,style:{position:"absolute",overflow:"auto",inset:0},children:Array.from(a).map(([e,i])=>{var s;return n.createPortal(t({pageNumber:e,width:i.canvasWidth,height:i.canvasHeight,scale:i.scale,src:null!==(s=null==i?void 0:i.src)&&void 0!==s?s:null,rotation:i.rotation,pageLabel:i.pageLabel,loaded:i.loaded}),i.div)})})}function yc(t){return function(i,n){return function(t,i=w,n){const s=v(t.subscribe,t.getState,t.getInitialState,i,n);return e.useDebugValue(s),s}(t,i,n)}}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.PDFSlick=cc,t.PDFSlickThumbnails=wc,t.PDFSlickViewer=vc,t.PresentationModeState=bh,t.ProgressBar=class{constructor(t){ch.set(this,void 0),uh.set(this,null),ph.set(this,0),gh.set(this,void 0),mh.set(this,!0),dh(this,ch,t.classList),dh(this,gh,t.style)}get percent(){return hh(this,ph,"f")}set percent(t){dh(this,ph,Mt(t,0,100)),isNaN(t)?hh(this,ch,"f").add("indeterminate"):(hh(this,ch,"f").remove("indeterminate"),hh(this,gh,"f").setProperty("--progressBar-percent",`${hh(this,ph,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&hh(this,gh,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===hh(this,ph,"f")||isNaN(hh(this,ph,"f"))||(hh(this,uh,"f")&&clearTimeout(hh(this,uh,"f")),this.show(),dh(this,uh,setTimeout(()=>{dh(this,uh,null),this.hide()},t)))}hide(){hh(this,mh,"f")&&(dh(this,mh,!1),hh(this,ch,"f").add("hidden"))}show(){hh(this,mh,"f")||(dh(this,mh,!0),hh(this,ch,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=fh,t.SCROLLBAR_PADDING=40,t.ScrollMode=yh,t.SidebarView=vh,t.SpreadMode=xh,t.TextLayerMode=wh,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=Nh,t.apiPageLayoutToViewerModes=function(t){let e=yh.VERTICAL,i=xh.NONE;switch(t){case"SinglePage":e=yh.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=yh.PAGE;case"TwoColumnLeft":i=xh.ODD;break;case"TwoPageRight":e=yh.PAGE;case"TwoColumnRight":i=xh.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return vh.NONE;case"UseThumbs":return vh.THUMBS;case"UseOutlines":return vh.OUTLINE;case"UseAttachments":return vh.ATTACHMENTS;case"UseOC":return vh.LAYERS}return vh.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 n,s=0,r=1,a=1,o=1;for(;;){const t=s+a,e=r+o;if(e>8)break;i<=t/e?(a=t,o=e):(s=t,r=e)}return n=i-s/r<a/o-i?i===t?[s,r]:[r,s]:i===t?[a,o]:[o,a],n},t.backtrackBeforeAllVisibleElements=Ph,t.binarySearchFirstItem=Ch,t.calcRound=Bh,t.create=Id,t.createStore=yc,t.docStyle=Fh,t.floorToDivide=function(t,e){return t-t%e},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=Eh,t.getVisibleElements=Th,t.initialState=Dd,t.isPortraitOrientation=Rh,t.isValidRotation=Dh,t.isValidScrollMode=Ih,t.isValidSpreadMode=Lh,t.normalizeWheelEventDelta=kh,t.normalizeWheelEventDirection=Mh,t.parseQueryString=function(t){const e=new Map;for(const[i,n]of new URLSearchParams(t))e.set(i.toLowerCase(),n);return e},t.removeNullCharacters=function(t,e=!1){return _h.test(t)?e?t.replaceAll(_h,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t},t.scrollIntoView=Ah,t.toggleCheckedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-checked",String(e)),null==i||i.classList.toggle("hidden",!e)},t.toggleExpandedBtn=function(t,e,i=null){t.classList.toggle("toggled",e),t.setAttribute("aria-expanded",String(e)),null==i||i.classList.toggle("hidden",!e)},t.usePDFSlick=(t,i)=>{const[n,s]=e.useState(!1),[r,a]=e.useState(null),[o,l]=e.useState(null),[h,d]=e.useState(null),c=e.useMemo(()=>Id(),[]),u=e.useMemo(()=>yc(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 cc({container:r,thumbs:o,store:c,options:i,onError:t=>d(t)});e.loadDocument(t,i).then(()=>{s(!0)}),c.setState({pdfSlick:e})}return()=>{}},[t,r]),{isDocumentLoaded:n,viewerRef:p,thumbsRef:g,usePDFSlickStore:u,store:c,PDFSlickViewer:vc,PDFSlickThumbnails:wc,error:h}},t.watchScroll=Sh});