@pdfslick/core 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):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickCore={})}(this,(function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;function i(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{l(s.next(t))}catch(t){a(t)}}function o(t){try{l(s.throw(t))}catch(t){a(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(r,o)}l((s=s.apply(t,e||[])).next())}))}function s(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 n(t,e,i,s,n){if("m"===s)throw new TypeError("Private method is not writable");if("a"===s&&!n)throw new TypeError("Private accessor was defined without a setter");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"a"===s?n.call(t,i):n?n.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).PDFSlickCore={})}(this,function(t){"use strict";var e="undefined"!=typeof document?document.currentScript:null;function i(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 n(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 s(t,e,i,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");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"a"===n?s.call(t,i):s?s.value=i:e.set(t,i),i}"function"==typeof SuppressedError&&SuppressedError;
2
2
  /**
3
3
  * @licstart The following is the entire license notice for the
4
4
  * JavaScript code in this page
@@ -19,4 +19,27 @@
19
19
  *
20
20
  * @licend The above is the entire license notice for the
21
21
  * JavaScript code in this page
22
- */var a={d:(t,e)=>{for(var i in e)a.o(e,i)&&!a.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},r=globalThis.pdfjsLib={};a.d(r,{AbortException:()=>vt,AnnotationEditorLayer:()=>hn,AnnotationEditorParamsType:()=>A,AnnotationEditorType:()=>y,AnnotationEditorUIManager:()=>se,AnnotationLayer:()=>Us,AnnotationMode:()=>w,ColorPicker:()=>Zs,DOMSVGFactory:()=>cs,DrawLayer:()=>dn,FeatureTest:()=>_t,GlobalWorkerOptions:()=>ci,ImageKind:()=>T,InvalidPDFException:()=>gt,MissingPDFException:()=>ft,OPS:()=>tt,OutputScale:()=>Xt,PDFDataRangeTransport:()=>Ki,PDFDateString:()=>zt,PDFWorker:()=>Zi,PasswordResponses:()=>et,PermissionFlag:()=>_,PixelsPerInch:()=>kt,RenderingCancelledException:()=>Dt,TextLayer:()=>ji,TouchManager:()=>ae,UnexpectedResponseException:()=>mt,Util:()=>St,VerbosityLevel:()=>Z,XfaLayer:()=>us,build:()=>rs,createValidAbsoluteUrl:()=>ht,fetchData:()=>It,getDocument:()=>Gi,getFilenameFromUrl:()=>Ft,getPdfFilenameFromUrl:()=>Ot,getXfaPageViewport:()=>Ut,isDataScheme:()=>Rt,isPdfFile:()=>Nt,noContextMenu:()=>Ht,normalizeUnicode:()=>Pt,setLayerDimensions:()=>qt,shadow:()=>dt,stopEvent:()=>Vt,version:()=>as});const o=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),l=[1,0,0,1,0,0],h=[.001,0,0,.001,0,0],d=1.35,c=1,u=2,p=4,g=16,f=32,m=64,b=128,v=256,w={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},y={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},A={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},_={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},x=0,S=1,C=2,E=3,P=3,M=4,T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},k=1,I=2,L=3,D=4,R=5,N=6,F=7,O=8,B=9,j=10,H=11,V=12,z=13,U=14,$=15,W=16,G=17,q=20,X=1,K=2,Y=3,Q=4,J=5,Z={ERRORS:0,WARNINGS:1,INFOS:5},tt={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},et={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let it=Z.WARNINGS;function st(t){Number.isInteger(t)&&(it=t)}function nt(){return it}function at(t){it>=Z.INFOS&&console.log(`Info: ${t}`)}function rt(t){it>=Z.WARNINGS&&console.log(`Warning: ${t}`)}function ot(t){throw new Error(t)}function lt(t,e){t||ot(e)}function ht(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 dt(t,e,i,s=!1){return Object.defineProperty(t,e,{value:i,enumerable:!s,configurable:!0,writable:!1}),i}const ct=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class ut extends ct{constructor(t,e){super(t,"PasswordException"),this.code=e}}class pt extends ct{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let gt=class extends ct{constructor(t){super(t,"InvalidPDFException")}},ft=class extends ct{constructor(t){super(t,"MissingPDFException")}},mt=class extends ct{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}};class bt extends ct{constructor(t){super(t,"FormatError")}}let vt=class extends ct{constructor(t){super(t,"AbortException")}};function wt(t){"object"==typeof t&&void 0!==t?.length||ot("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 a=Math.min(n+i,e),r=t.subarray(n,a);s.push(String.fromCharCode.apply(null,r))}return s.join("")}function yt(t){"string"!=typeof t&&ot("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 At(t){const e=Object.create(null);for(const[i,s]of t)e[i]=s;return e}class _t{static get isLittleEndian(){return dt(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return dt(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return dt(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return dt(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?dt(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):dt(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return dt(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const xt=Array.from(Array(256).keys(),(t=>t.toString(16).padStart(2,"0")));let St=class{static makeHexColor(t,e,i){return`#${xt[t]}${xt[e]}${xt[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),a=this.applyTransform([t[2],t[1]],e);return[Math.min(i[0],s[0],n[0],a[0]),Math.min(i[1],s[1],n[1],a[1]),Math.max(i[0],s[0],n[0],a[0]),Math.max(i[1],s[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static 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],a=t[2]*e[1]+t[3]*e[3],r=(i+a)/2,o=Math.sqrt((i+a)**2-4*(i*a-n*s))/2,l=r+o||1,h=r-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])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[i,n,s,a]}static#t(t,e,i,s,n,a,r,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*a)+3*c*r)+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,a,r,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,a,r,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,a,r,o,(-h+p)/g,c),this.#t(t,e,i,s,n,a,r,o,(-h-p)/g,c)}static bezierBoundingBox(t,e,i,s,n,a,r,o,l){return l?(l[0]=Math.min(l[0],t,r),l[1]=Math.min(l[1],e,o),l[2]=Math.max(l[2],t,r),l[3]=Math.max(l[3],e,o)):l=[Math.min(t,r),Math.min(e,o),Math.max(t,r),Math.max(e,o)],this.#e(t,i,n,r,e,s,a,o,3*(3*(i-n)-t+r),6*(t-2*i+n),3*(i-t),l),this.#e(t,i,n,r,e,s,a,o,3*(3*(s-a)-e+o),6*(e-2*s+a),3*(s-e),l),l}};let Ct=null,Et=null;function Pt(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)))}const Mt="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise((i=>{i(t(...e))}))});const Tt="http://www.w3.org/2000/svg";let kt=class{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF};async function It(t,e="text"){if(jt(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 Lt{constructor({viewBox:t,userUnit:e,scale:i,rotation:s,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=s,this.offsetX=n,this.offsetY=a,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.")}r&&(c=-c,u=-u),0===h?(p=Math.abs(l-t[1])*i+n,g=Math.abs(o-t[0])*i+a,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+a,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 dt(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 Lt({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:s,dontFlip:n})}convertToViewportPoint(t,e){return St.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=St.applyTransform([t[0],t[1]],this.transform),i=St.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){return St.applyInverseTransform([t,e],this.transform)}}let Dt=class extends ct{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function Rt(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function Nt(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ft(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Ot(t,e="document.pdf"){if("string"!=typeof t)return e;if(Rt(t))return rt('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 Bt{started=Object.create(null);times=[];time(t){t in this.started&&rt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||rt(`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 jt(t,e){try{const{protocol:i}=e?new URL(t,e):new URL(t);return"http:"===i||"https:"===i}catch{return!1}}function Ht(t){t.preventDefault()}function Vt(t){t.preventDefault(),t.stopPropagation()}let zt=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 a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let r=parseInt(e[5],10);r=r>=0&&r<=59?r: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?(a+=h,r+=d):"+"===l&&(a-=h,r-=d),new Date(Date.UTC(i,s,n,a,r,o))}};function Ut(t,{scale:e=1,rotation:i=0}){const{width:s,height:n}=t.attributes.style,a=[0,0,parseInt(s),parseInt(n)];return new Lt({viewBox:a,userUnit:1,scale:e,rotation:i})}function $t(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):(rt(`Not a valid color format: "${t}"`),[0,0,0])}function Wt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform();return[e,i,s,n,a,r]}function Gt(t){const{a:e,b:i,c:s,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,i,s,n,a,r]}function qt(t,e,i=!1,s=!0){if(e instanceof Lt){const{pageWidth:s,pageHeight:n}=e.rawDims,{style:a}=t,r=_t.isCSSRoundSupported,o=`var(--scale-factor) * ${s}px`,l=`var(--scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x, 1px))`:`calc(${o})`,d=r?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;i&&e.rotation%180!=0?(a.width=d,a.height=h):(a.width=h,a.height=d)}s&&t.setAttribute("data-main-rotation",e.rotation)}let Xt=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 Kt{#s=null;#n=null;#a;#r=null;#o=null;static#l=null;constructor(t){this.#a=t,Kt.#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.#a._uiManager._signal;t.addEventListener("contextmenu",Ht,{signal:e}),t.addEventListener("pointerdown",Kt.#h,{signal:e});const i=this.#r=document.createElement("div");i.className="buttons",t.append(i);const s=this.#a.toolbarPosition;if(s){const{style:e}=t,i="ltr"===this.#a._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.#a._focusEventsAllowed=!1,Vt(t)}#u(t){this.#a._focusEventsAllowed=!0,Vt(t)}#p(t){const e=this.#a._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",Ht,{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.#a,i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",Kt.#l[t]),this.#p(i),i.addEventListener("click",(t=>{e.delete()}),{signal:e._signal}),this.#r.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.#r.prepend(e,this.#g),this.#o=t}addColorPicker(t){this.#n=t;const e=t.renderButton();this.#p(e),this.#r.prepend(e,this.#g)}remove(){this.#s.remove(),this.#n?.destroy(),this.#n=null}}class Yt{#r=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",Ht,{signal:this.#f._signal});const e=this.#r=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 a=n.x+(e?n.width:0);t>i?(s=a,i=t):e?a>s&&(s=a):a<s&&(s=a)}return[e?1-s:s,i]}show(t,e,i){const[s,n]=this.#v(e,i),{style:a}=this.#s||=this.#m();t.append(this.#s),a.insetInlineEnd=100*s+"%",a.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",Ht,{signal:i}),t.addEventListener("click",(()=>{this.#f.highlightSelection("floating_button")}),{signal:i}),this.#r.append(t)}}function Qt(t,e,i){for(const s of i)e.addEventListener(s,t[s].bind(t))}class Jt{#w=0;get id(){return"pdfjs_internal_editor_"+this.#w++}}class Zt{#y=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),wt(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 dt(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 It(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Zt._isSVGFittingCanvas,s=new FileReader,n=new Image,a=new Promise(((t,a)=>{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=a}));s.readAsDataURL(t),await a}else i.bitmap=await createImageBitmap(t);i.refCounter=1}catch(t){rt(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 te{#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:a=!1,keepUndo:r=!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(a&&this.#x[this.#E].type===n)return r&&(o.undo=this.#x[this.#E].undo),void(this.#x[this.#E]=o);const l=this.#E+1;l===this.#C?this.#x.splice(0,1):(this.#E=l,l<this.#x.length&&this.#x.splice(l)),this.#x.push(o)}undo(){if(-1===this.#E)return;this.#S=!0;const{undo:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1,this.#E-=1}redo(){if(this.#E<this.#x.length-1){this.#E+=1,this.#S=!0;const{cmd:t,post:e}=this.#x[this.#E];t(),e?.(),this.#S=!1}}hasSomethingToUndo(){return-1!==this.#E}hasSomethingToRedo(){return this.#E<this.#x.length-1}cleanType(t){if(-1!==this.#E){for(let e=this.#E;e>=0;e--)if(this.#x[e].type!==t)return this.#x.splice(e+1,this.#E-e),void(this.#E=e);this.#x.length=0,this.#E=-1}}destroy(){this.#x=null}}class ee{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=_t.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:a=[],checker:r=null}}=i;r&&!r(t,e)||(s.bind(t,...a,e)(),n||Vt(e))}}class ie{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,$t(s))}e.remove()}(t),dt(this,"_colors",t)}convert(t){const e=$t(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 ie._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?St.makeHexColor(...e):t}}let se=class t{#M=new AbortController;#T=null;#k=new Map;#I=new Map;#L=null;#D=null;#R=null;#N=new te;#F=null;#O=null;#B=0;#j=new Set;#H=null;#V=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 Jt;#Z=!1;#tt=!1;#et=null;#it=null;#st=null;#nt=null;#at=y.NONE;#rt=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,a=this.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],e.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:s}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:s}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&t.#pt.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:i}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:i}]]))}constructor(t,e,i,s,n,a,r,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=a,this.#K=r||null,this.#U=o,this.#$=l,this.#W=h,this.#nt=d||null,this.viewParameters={realScale:kt.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.#rt.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 dt(this,"hcmFilter",this.#lt?this.#G.addHCMFilter(this.#lt.foreground,this.#lt.background):"none")}get direction(){return dt(this,"direction",getComputedStyle(this.#pt).direction)}get highlightColors(){return dt(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((t=>t.split("=").map((t=>t.trim()))))):null)}get highlightColorNames(){return dt(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:a,height:r}=i.div.getBoundingClientRect();if(t>=s&&t<=s+a&&e>=n&&e<=n+r)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*kt.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:a}=e,r=e.toString(),o=this.#wt(e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=this.#yt(o),d=this.#at===y.NONE,c=()=>{h?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:i,anchorOffset:s,focusNode:n,focusOffset:a,text:r}),d&&this.showAllEditors("highlight",!0,!0)};d?this.switchToMode(y.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 Yt(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.#at===y.HIGHLIGHT||this.#at===y.NONE)&&(this.#at===y.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#Y=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#at===y.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.#at===y.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.#rt)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.#V)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.#V)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.#rt){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.#V)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 rt(`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){rt(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#at===y.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.#at===y.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Lt([[A.HIGHLIGHT_FREE,!0]]))}#Lt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ct(),this.#Mt(),this.#xt({isEditing:this.#at!==y.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.#V){this.#V=t;for(const t of this.#V)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.#at!==t&&(!this.#ft||(await this.#ft.promise,this.#ft))){if(this.#ft=Promise.withResolvers(),this.#at=t,t===y.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.#at&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){if(this.#V){switch(t){case A.CREATE:return void this.currentLayer.addNewEditor();case A.HIGHLIGHT_DEFAULT_COLOR:this.#st?.updateColor(e);break;case A.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.#rt)i.updateParams(t,e);for(const i of this.#V)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(A.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Lt([[A.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.#rt);return t}updateUI(t){this.#Ft===t&&this.#Lt(t.propertiesToUpdate)}updateUIForDefaultProperties(t){this.#Lt(t.defaultPropertiesToUpdate)}toggleSelected(t){if(this.#rt.has(t))return this.#rt.delete(t),t.unselect(),void this.#xt({hasSelectedEditor:this.hasSelection});this.#rt.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}setSelected(t){this.#O?.commitOrRemove();for(const e of this.#rt)e!==t&&e.unselect();this.#rt.clear(),this.#rt.add(t),t.select(),this.#Lt(t.propertiesToUpdate),this.#xt({hasSelectedEditor:!0})}isSelected(t){return this.#rt.has(t)}get firstSelectedEditor(){return this.#rt.values().next().value}unselect(t){t.unselect(),this.#rt.delete(t),this.#xt({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#rt.size}get isEnterHandled(){return 1===this.#rt.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.#rt],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.#rt)t.unselect();this.#rt.clear();for(const e of t)e.isEmpty()||(this.#rt.add(e),e.select());this.#xt({hasSelectedEditor:this.hasSelection})}selectAll(){for(const t of this.#rt)t.commit();this.#It(this.#k.values())}unselectAll(){if((!this.#T||(this.#T.commitOrRemove(),this.#at===y.NONE))&&!this.#O?.commitOrRemove()&&this.hasSelection){for(const t of this.#rt)t.unselect();this.#rt.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,a=[...this.#rt];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 a)this.#k.has(t.id)&&t.translateInPage(s,n)},undo:()=>{for(const t of a)this.#k.has(t.id)&&t.translateInPage(-s,-n)},mustExec:!1})}),1e3);for(const i of a)i.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#H=new Map;for(const t of this.#rt)this.#H.set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#H)return!1;this.disableUserSelect(!1);const t=this.#H;this.#H=null;let e=!1;for(const[{x:i,y:s,pageIndex:n},a]of t)a.newX=i,a.newY=s,a.newPageIndex=n,e||=i!==a.savedX||s!==a.savedY||n!==a.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:a}]of t)i(e,s,n,a)},undo:()=>{for(const[e,{savedX:s,savedY:n,savedPageIndex:a}]of t)i(e,s,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(this.#H)for(const i of this.#H.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.#rt.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return this.#T===t}getActive(){return this.#T}getMode(){return this.#at}get imageManager(){return dt(this,"imageManager",new Zt)}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:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-s)/a,y:1-(t+r-i)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-i)/n,y:1-(e+o-s)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-s)/a,y:(t-i)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-i)/n,y:(e-s)/a,width:r/n,height:o/a})}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(r(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.#at!==y.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}};class ne{#o=null;#Ot=!1;#Bt=null;#jt=null;#Ht=null;#Vt=null;#zt=!1;#Ut=null;#a=null;#$t=null;#Wt=null;#Gt=!1;static#qt=null;static _l10n=null;constructor(t){this.#a=t,this.#Gt=t._uiManager.useNewAltTextFlow,ne.#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){ne._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",ne.#qt.missing),e.setAttribute("data-l10n-id",ne.#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.#a._uiManager._signal;t.addEventListener("contextmenu",Ht,{signal:i}),t.addEventListener("pointerdown",(t=>t.stopPropagation()),{signal:i});const s=t=>{t.preventDefault(),this.#a._uiManager.editAltText(this.#a),this.#Gt&&this.#a._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 ne._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.#a.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.#Vt&&(clearTimeout(this.#Vt),this.#Vt=null),this.#Bt.disabled=!t)}shown(){this.#a._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.#Ht=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",ne.#qt[this.#Xt]),this.#jt?.setAttribute("data-l10n-id",ne.#qt[`${this.#Xt}-label`]),!this.#o)return void this.#Ht?.remove()}else{if(!this.#o&&!this.#Ot)return t.classList.remove("done"),void this.#Ht?.remove();t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=this.#Ht;if(!e){this.#Ht=e=document.createElement("span"),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${this.#a.id}`;const i=100,s=this.#a._uiManager._signal;s.addEventListener("abort",(()=>{clearTimeout(this.#Vt),this.#Vt=null}),{once:!0}),t.addEventListener("mouseenter",(()=>{this.#Vt=setTimeout((()=>{this.#Vt=null,this.#Ht.classList.add("show"),this.#a._reportTelemetry({action:"alt_text_tooltip"})}),i)}),{signal:s}),t.addEventListener("mouseleave",(()=>{this.#Vt&&(clearTimeout(this.#Vt),this.#Vt=null),this.#Ht?.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.#a.getImageForAltText();i?.setAttribute("aria-describedby",e.id)}}let ae=class t{#pt;#Yt=!1;#Qt=null;#Jt;#Zt;#te;#ee;#ie;#se=null;#ne;#ae=null;constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:s=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){this.#pt=t,this.#Qt=i,this.#Jt=e,this.#Zt=s,this.#te=n,this.#ee=a,this.#ne=new AbortController,this.#ie=AbortSignal.any([r,this.#ne.signal]),t.addEventListener("touchstart",this.#re.bind(this),{passive:!1,signal:this.#ie})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return dt(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#re(t){if(this.#Jt?.()||t.touches.length<2)return;if(!this.#ae){this.#ae=new AbortController;const t=AbortSignal.any([this.#ie,this.#ae.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(Vt(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:a}=i,{screenX:r,screenY:o}=s,l=this.#se,{touch0X:h,touch0Y:d,touch1X:c,touch1Y:u}=l,p=c-h,g=u-d,f=r-n,m=o-a,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=a,l.touch1X=r,l.touch1Y=o,e.preventDefault(),!this.#Yt)return void(this.#Yt=!0);const w=[(n+r)/2,(a+o)/2];this.#te?.(w,v,b)}#le(t){this.#ae.abort(),this.#ae=null,this.#ee?.(),this.#se&&(t.preventDefault(),this.#se=null,this.#Yt=!1)}destroy(){this.#ne?.abort(),this.#ne=null}};class re{#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=re._zIndex++;static _borderLineWidth=-1;static _colorManager=new ie;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=re.prototype._resizeWithKeyboard,e=se.TRANSLATE_SMALL,i=se.TRANSLATE_BIG;return dt(this,"_resizerKeyboardManager",new ee([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],re.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:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,s],this.pageTranslation=[n,a];const[r,o]=this.parentDimensions;this.x=t.x/r,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 dt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new oe({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(re._l10n??=t,re._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!==re._borderLineWidth)return;const i=getComputedStyle(document.documentElement);re._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ot("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,a]=this.parentDimensions;[i,s]=this.screenToPageTranslation(i,s),this.x=(t+i)/n,this.y=(e+s)/a,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:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=i;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),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}=re,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:a,width:r,height:o}=this;if(r*=i,o*=s,n*=i,a*=s,this._mustFixPosition)switch(t){case 0:n=Math.max(0,Math.min(i-r,n)),a=Math.max(0,Math.min(s-o,a));break;case 90:n=Math.max(0,Math.min(i-o,n)),a=Math.min(s,Math.max(r,a));break;case 180:n=Math.min(i,Math.max(r,n)),a=Math.min(s,Math.max(o,a));break;case 270:n=Math.min(i,Math.max(o,n)),a=Math.max(0,Math.min(s-r,a))}this.x=n/=i,this.y=a/=s;const[l,h]=this.getBaseTranslation();n+=l,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).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 re.#Re(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return re.#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[a,r]=this.parentDimensions;s||(t.width=`${(100*parseFloat(i)/a).toFixed(2)}%`),this.#ge||n||(t.height=`${(100*parseFloat(e)/r).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",Ht,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#fe)}#Oe(t,e){e.preventDefault();const{isMac:i}=_t.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,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Be.bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",Vt,{passive:!1,signal:a}),window.addEventListener("contextmenu",Ht,{signal:a}),this.#be={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const r=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=r,this.div.style.cursor=o,this.#je()};window.addEventListener("pointerup",l,{signal:a}),window.addEventListener("blur",l,{signal:a})}#He(t,e,i,s){this.width=i,this.height=s,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*i,a*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,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===i&&o===s||this.addCommands({cmd:this.#He.bind(this,n,a,r,o),undo:this.#He.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,a=this.y,r=this.width,o=this.height,l=re.MIN_SIZE/i,h=re.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(r,o),v=g(r,o);let w=c(...v);const y=re._round(n+w[0]),A=re._round(a+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(r,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-_,v[1]-b[1]-x)/t,1/r,1/o),l/r,h/o)}else m?S=Math.max(l,Math.min(1,Math.abs(v[0]-b[0]-_)))/r:C=Math.max(h,Math.min(1,Math.abs(v[1]-b[1]-x)))/o;const M=re._round(r*S),T=re._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 Kt(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||(ne.initialize(re._l10n),this.#o=new ne(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.#Ve();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),Qt(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Te||=new ae({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),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,d=this.width,c=this.height,u=re.MIN_SIZE/r,p=re.MIN_SIZE/o;s=Math.max(Math.min(s,1/d,1/c),u/d,p/c);const g=re._round(d*s),f=re._round(c*s);if(g===d&&f===c)return;this.#Ae||=[l,h,d,c];const m=a(d/2,c/2),b=re._round(l+m[0]),v=re._round(h+m[1]),w=a(g/2,f/2);this.x=b-w[0],this.y=v-w[1],this.width=g,this.height=f,this.setDims(r*g,o*f),this.fixAndSetPosition(),this._onResizing()}#$e(){this.#o?.toggle(!0),this.parent.togglePointerEvents(!0),this.#je()}pointerdown(t){const{isMac:e}=_t.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}=_t.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),a={capture:!0,passive:!1,signal:n},r=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 Vt(t);const[a,r]=this.screenToPageTranslation(e-this.#Ee,s-this.#Pe);this.#Ee=e,this.#Pe=s,this._uiManager.dragSelectedEditors(a,r)}),a),window.addEventListener("touchmove",Vt,a),window.addEventListener("pointerdown",(t=>{t.pointerType===this.#pe&&(this.#Te||t.isPrimary)&&r(t),Vt(t)}),a));const o=t=>{this.#ue&&this.#ue!==t.pointerId?Vt(t):r(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,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/s,h=e/s,d=this.x*n,c=this.y*a,u=this.width*n,p=this.height*a;switch(i){case 0:return[d+l+r,a-c-h-p+o,d+l+u+r,a-c-h+o];case 90:return[d+h+r,a-c+l+o,d+h+p+r,a-c+l+u+o];case 180:return[d-l-u+r,a-c+h+o,d-l+r,a-c+h+p+o];case 270:return[d-h-p+r,a-c-l-u+o,d-h+r,a-c-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,s,n,a]=t,r=n-i,o=a-s;switch(this.rotation){case 0:return[i,e-a,r,o];case 90:return[i,e-s,o,r];case 180:return[n,e-s,r,o];case 270:return[n,e-a,o,r];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:a}=window;return e<a&&s>0&&t<n&&i>0}#Ve(){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.#Ve()}rotate(t){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(t=!1,e=null){ot("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,a]=s.pageDimensions,[r,o,l,h]=s.getRectInCurrentCoords(t.rect,a);return s.x=r/n,s.y=o/a,s.width=l/n,s.height=h/a,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"),Qt(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",re._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",re._l10nResizer[e])}}this.#Ye(0),this.#Se=!0,this.#fe.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#qe(t){re._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)}),re._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 oe extends re{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const le=3285377520,he=4294901760,de=65535;class ce{constructor(t){this.h1=t?4294967295&t:le,this.h2=t?4294967295&t:le}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,a=new Uint32Array(e.buffer,0,s);let r=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?(r=a[t],r=r*d&he|r*u&de,r=r<<15|r>>>17,r=r*c&he|r*p&de,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[t],o=o*d&he|o*u&de,o=o<<15|o>>>17,o=o*c&he|o*p&de,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*s+2]<<16;case 2:r^=e[4*s+1]<<8;case 1:r^=e[4*s],r=r*d&he|r*u&de,r=r<<15|r>>>17,r=r*c&he|r*p&de,1&s?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&he|36045*t&de,e=4283543511*e&he|(2950163797*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,t=444984403*t&he|60499*t&de,e=3301882366*e&he|(3120437893*(e<<16|t>>>16)&he)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ue=Object.freeze({map:null,hash:"",transfer:void 0});class pe{#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 re)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 re&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return this.#Ze.has(t)}getAll(){return this.#Ze.size>0?At(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 ge(this)}get serializable(){if(0===this.#Ze.size)return ue;const t=new Map,e=new ce,i=[],s=Object.create(null);let n=!1;for(const[i,a]of this.#Ze){const r=a instanceof re?a.serialize(!1,s):a;r&&(t.set(i,r),e.update(`${i}:${JSON.stringify(r)}`),n||=!!r.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}:ue}get editorStats(){let t=null;const e=new Map;for(const i of this.#Ze.values()){if(!(i instanceof re))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 a=t[n]||=new Map;for(const[t,e]of Object.entries(s)){if("type"===t)continue;let i=a.get(t);i||(i=new Map,a.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 re&&e.annotationElementId&&e.serialize()&&t.push(e.annotationElementId);return this.#Je={ids:new Set(t),hash:t.join(",")}}}class ge extends pe{#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(){ot("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ei}get modifiedIds(){return dt(this,"modifiedIds",{ids:new Set,hash:""})}}class fe{#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(lt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:s,style:n}=t,a=new FontFace(i,s,n);this.addNativeFontFace(a);try{await a.load(),this.#ii.add(i),e?.(t)}catch{rt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}}else ot("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 rt(`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 dt(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let t=!1;return(o||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),dt(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(lt(!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 dt(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,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.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,a=h.length-3;n<a;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 rt("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 me{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(wt(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){rt(`getPathGenerator - ignoring character: "${t}".`)}const n=new Path2D(s||"");return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=n}}const be=1,ve=2,we=1,ye=2,Ae=3,_e=4,xe=5,Se=6,Ce=7,Ee=8;function Pe(){}function Me(t){if(t instanceof vt||t instanceof gt||t instanceof ft||t instanceof ut||t instanceof mt||t instanceof pt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||ot('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new vt(t.message);case"InvalidPDFException":return new gt(t.message);case"MissingPDFException":return new ft(t.message);case"PasswordException":return new ut(t.message,t.code);case"UnexpectedResponseException":return new mt(t.message,t.status);case"UnknownErrorException":return new pt(t.message,t.details)}return new pt(t.message,t.toString())}class Te{#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.#ai(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===be)i.resolve(t.data);else{if(t.callback!==ve)throw new Error("Unexpected callback case");i.reject(Me(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:be,callbackId:t.callbackId,data:e})}),(function(e){n.postMessage({sourceName:i,targetName:s,callback:ve,callbackId:t.callbackId,reason:Me(e)})}))}else t.streamId?this.#ri(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++,a=this.sourceName,r=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:a,targetName:r,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:a,targetName:r,stream:Se,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{lt(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:a,targetName:r,stream:we,streamId:n,reason:Me(t)}),e.promise}},i)}#ri(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:i,targetName:s,stream:_e,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:Ae,streamId:e}),delete a.streamSinks[e])},error(t){lt(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:i,targetName:s,stream:xe,streamId:e,reason:Me(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(r,t.data,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ee,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ee,streamId:e,reason:Me(t)})}))}#ai(t){const e=t.streamId,i=this.sourceName,s=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case Ee:t.success?a.startCall.resolve():a.startCall.reject(Me(t.reason));break;case Ce:t.success?a.pullCall.resolve():a.pullCall.reject(Me(t.reason));break;case Se:if(!r){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Pe).then((function(){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:Ce,streamId:e,reason:Me(t)})}));break;case _e:if(lt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Ae:if(lt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),this.#oi(a,e);break;case xe:lt(a,"error should have stream controller"),a.controller.error(Me(t.reason)),this.#oi(a,e);break;case ye:t.success?a.cancelCall.resolve():a.cancelCall.reject(Me(t.reason)),this.#oi(a,e);break;case we:if(!r)break;const o=Me(t.reason);Promise.try(r.onCancel||Pe,o).then((function(){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,success:!0})}),(function(t){n.postMessage({sourceName:i,targetName:s,stream:ye,streamId:e,reason:Me(t)})})),r.sinkCapability.reject(o),r.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 ke{#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){ot("Abstract method `_createCanvas` called.")}}class Ie{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){ot("Abstract method `_fetch` called.")}}class Le extends Ie{async _fetch(t){const e=await It(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):yt(e)}}class De{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 Re{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){ot("Abstract method `_fetch` called.")}}class Ne extends Re{async _fetch(t){const e=await It(t,"arraybuffer");return new Uint8Array(e)}}async function Fe(t){const e=process.getBuiltinModule("fs"),i=await e.promises.readFile(t);return new Uint8Array(i)}o&&rt("Please use the `legacy` build in Node.js environments.");const Oe="Fill",Be="Stroke",je="Shading";function He(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 Ve{getPattern(){ot("Abstract method `getPattern` called.")}}class ze extends Ve{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===Be||s===Oe){const a=e.current.getClippedPathBoundingBox(s,Wt(t))||[0,0,0,0],r=Math.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,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(-a[0],-a[1]),i=St.transform(i,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),He(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 He(t,this._bbox),n=this._createGradient(t);return n}}function Ue(t,e,i,s,n,a,r,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=a,a=r,r=u),l[s+1]>l[n+1]&&(u=s,s=n,n=u,u=r,r=o,o=u),l[i+1]>l[s+1]&&(u=i,i=s,s=u,u=a,a=r,r=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[a],y=h[a+1],A=h[a+2],_=h[r],x=h[r+1],S=h[r+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 $e(t,e,i){const s=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)Ue(t,i,s[e],s[e+1],s[e+o],n[e],n[e+1],n[e+o]),Ue(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(a=0,r=s.length;a<r;a+=3)Ue(t,i,s[a],s[a+1],s[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class We extends Ve{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]),a=Math.ceil(this._bounds[2])-s,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,d=r/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)$e(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(He(t,this._bbox),s===je)n=St.singularValueDecompose2dScale(Wt(t));else if(n=St.singularValueDecompose2dScale(e.baseTransform),this.matrix){const t=St.singularValueDecompose2dScale(this.matrix);n=[n[0]*t[0],n[1]*t[1]]}const a=this._createMeshCanvas(n,s===je?null:this._background,e.cachedCanvases);return s!==je&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class Ge extends Ve{getPattern(){return"hotpink"}}const qe=1,Xe=2;class Ke{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:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l),at("TilingType: "+n);const h=e[0],d=e[1],c=e[2],u=e[3],p=c-h,g=u-d,f=St.singularValueDecompose2dScale(this.matrix),m=St.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=r.createCanvasGraphics(M);if(T.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(T,s,a),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=Wt(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,a=s.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),c=r.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,a*i,n,a,0,0,n,a);return{canvas:r.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(Ke.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 a=s-e,r=n-i;t.ctx.rect(e,i,a,r),t.current.updateRectMinMax(Wt(t.ctx),[e,i,s,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const s=t.ctx,n=t.current;switch(e){case qe:const t=this.ctx;s.fillStyle=t.fillStyle,s.strokeStyle=t.strokeStyle,n.fillColor=t.fillStyle,n.strokeColor=t.strokeStyle;break;case Xe:const a=St.makeHexColor(i[0],i[1],i[2]);s.fillStyle=a,s.strokeStyle=a,n.fillColor=a,n.strokeColor=a;break;default:throw new bt(`Unsupported paint type: ${e}`)}}getPattern(t,e,i,s){let n=i;s!==je&&(n=St.transform(n,e.baseTransform),this.matrix&&(n=St.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}}function Ye({src:t,srcPos:e=0,dest:i,width:s,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=_t.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],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 Qe=16;class Je{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 Ze(t,e,i,s,n,a,r,o,l,h){const[d,c,u,p,g,f]=Wt(t);if(0===c&&0===u){const m=r*d+g,b=Math.round(m),v=o*p+f,w=Math.round(v),y=(r+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,a,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=r*c+f,w=Math.round(v),y=(o+h)*u+g,A=Math.abs(Math.round(y)-b)||1,_=(r+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,a,0,0,x,A),t.setTransform(d,c,u,p,g,f),[x,A]}t.drawImage(e,i,s,n,a,r,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class ti{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=l,this.textMatrixScale=1,this.fontMatrix=h,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=x,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]=St.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=St.applyTransform(e,t),s=St.applyTransform(e.slice(2),t),n=St.applyTransform([e[0],e[3]],t),a=St.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,i[0],s[0],n[0],a[0]),this.minY=Math.min(this.minY,i[1],s[1],n[1],a[1]),this.maxX=Math.max(this.maxX,i[0],s[0],n[0],a[0]),this.maxY=Math.max(this.maxY,i[1],s[1],n[1],a[1])}updateScalingPathMinMax(t,e){St.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,a,r,o,l,h){const d=St.bezierBoundingBox(e,i,s,n,a,r,o,l,h);h||this.updateRectMinMax(t,d)}getPathBoundingBox(t=Oe,e=null){const i=[this.minX,this.minY,this.maxX,this.maxY];if(t===Be){e||ot("Stroke bounding box must include transform.");const t=St.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=St.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=Oe,e=null){return St.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function ei(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,s=e.width,n=i%Qe,a=(i-n)/Qe,r=0===n?a:a+1,o=t.createImageData(s,Qe);let l,h=0;const d=e.data,c=o.data;let u,p,g,f;if(e.kind===T.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=_t.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?Qe:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>m?s:8*t-7,r=-8&a;let o=0,c=0;for(;n<r;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<a;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*Qe)}}else if(e.kind===T.RGBA_32BPP){for(p=0,f=s*Qe*4,u=0;u<a;u++)c.set(d.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=Qe;u<r&&(f=s*n*4,c.set(d.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==T.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Qe,f=s*g,u=0;u<r;u++){for(u>=a&&(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*Qe)}}}function ii(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,s=e.width,n=i%Qe,a=(i-n)/Qe,r=0===n?a:a+1,o=t.createImageData(s,Qe);let l=0;const h=e.data,d=o.data;for(let e=0;e<r;e++){const i=e<a?Qe:n;({srcPos:l}=Ye({src:h,srcPos:l,dest:d,width:s,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Qe)}}function si(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 ni(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),!o){const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}}function ai(t,e){if(e)return!0;const i=St.singularValueDecompose2dScale(t);i[0]=Math.fround(i[0]),i[1]=Math.fround(i[1]);const s=Math.fround((globalThis.devicePixelRatio||1)*kt.PDF_TO_CSS_UNITS);return i[0]<=s&&i[1]<=s}const ri=["butt","round","square"],oi=["miter","round","bevel"],li={},hi={};class di{constructor(t,e,i,s,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){this.ctx=t,this.current=new ti(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=r||[],this.optionalContentConfig=a,this.cachedCanvases=new Je(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,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=s||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,i){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Wt(this.compositeCtx))}this.ctx.save(),ni(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=Wt(this.ctx)}executeOperatorList(t,e,i,s){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>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&&r===s.nextBreakPoint)return s.breakIt(r,i),r;if(p=a[r],p!==tt.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?c:u;if(!e.has(t))return e.get(t,i),r}if(r++,r===o)return r;if(l&&++d>10){if(Date.now()>h)return i(),r;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,a,r=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(;r>2&&l>1||o>2&&h>1;){let e=l,i=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=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),a=n.context,a.clearRect(0,0,e,i),a.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,a=this.current.patternFill,r=Wt(e);let o,l,h,d;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.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&&!a){return{canvas:i,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=i}h||(d=this.cachedCanvases.getCanvas("maskCanvas",i,s),ii(d.context,t));let c=St.transform(r,[1/i,0,0,-1/s,0,0]);c=St.transform(c,[1,0,0,1,0,-s]);const[u,p,g,f]=St.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,Gt(w)),h=h.img,o&&a&&o.set(l,h)),w.imageSmoothingEnabled=ai(Wt(w),t.interpolate),Ze(w,h,0,0,h.width,h.height,0,0,i,s),w.globalCompositeOperation="source-in";const _=St.transform(Gt(w),[1,0,0,1,-y,-A]);return w.fillStyle=a?n.getPattern(e,this,_,Oe):n,w.fillRect(0,0,i,s),o&&!a&&(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=ri[t]}setLineJoin(t){this.ctx.lineJoin=oi[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(...Wt(this.suspendedCtx)),si(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,a,r){e.transform(t,i,s,n,a,r),this.__originalTransform(t,i,s,n,a,r)},t.setTransform=function(t,i,s,n,a,r){e.setTransform(t,i,s,n,a,r),this.__originalSetTransform(t,i,s,n,a,r)},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,a,r){e.bezierCurveTo(t,i,s,n,a,r),this.__originalBezierCurveTo(t,i,s,n,a,r)},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(),si(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],a=s[1],r=s[2]-n,o=s[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,i,r,o,e.subtype,e.backdrop,e.transferMap,n,a,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,a,r,o,l,h,d){let c=t.canvas,u=o-h,p=l-d;if(a){const e=St.makeHexColor(...a);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&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));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?(si(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(),si(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,a){this.ctx.transform(t,e,i,s,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i){const s=this.ctx,n=this.current;let a,r,o=n.x,l=n.y;const h=Wt(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 tt.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 tt.moveTo:o=e[u++],l=e[u++],s.moveTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.lineTo:o=e[u++],l=e[u++],s.lineTo(o,l),d||n.updatePathMinMax(h,o,l);break;case tt.curveTo:a=o,r=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,a,r,e[u],e[u+1],e[u+2],e[u+3],o,l,c),u+=6;break;case tt.curveTo2:a=o,r=l,s.bezierCurveTo(o,l,e[u],e[u+1],e[u+2],e[u+3]),n.updateCurvePathMinMax(h,a,r,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 tt.curveTo3:a=o,r=l,o=e[u+2],l=e[u+3],s.bezierCurveTo(e[u],e[u+1],o,l,o,l),n.updateCurvePathMinMax(h,a,r,e[u],e[u+1],o,l,o,l,c),u+=4;break;case tt.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,Gt(e),Be),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,Gt(e),Oe),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=li}eoClip(){this.pendingClip=hi}beginText(){this.current.textMatrix=l,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:a,fontSize:r,path:o}of t)i.addPath(o,new DOMMatrix(e).preMultiplySelf(s).translate(n,a).scale(r,-r));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||h,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||rt("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",a=i.systemFontInfo?.css||`"${n}", ${i.fallbackName}`;let r="normal";i.black?r="900":i.bold&&(r="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} ${r} ${l}px ${a}`}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,a){this.current.textMatrix=[t,e,i,s,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#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 a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,d=l&P,c=!!(l&M),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||c||u||p)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||u||p){if(a.save(),a.translate(e,i),a.scale(h,-h),d===x||d===C)if(s){const t=a.getTransform();a.setTransform(...s),a.fill(this.#ci(g,t,s))}else a.fill(g);if(d===S||d===C)if(n){const t=a.getTransform();a.setTransform(...n),a.stroke(this.#ci(g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else d!==x&&d!==C||a.fillText(t,e,i),d!==S&&d!==C||a.strokeText(t,e,i);if(c){(this.pendingTextPaths||=[]).push({transform:Wt(a),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 dt(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,a=e.fontSizeScale,r=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===x&&!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,Gt(n),Oe);m=Wt(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,Gt(n),Be);b=Wt(n),n.restore(),n.strokeStyle=t}let v=e.lineWidth;const w=e.textMatrixScale;if(0===w||0===v){const t=e.textRenderingMode&P;t!==S&&t!==C||(v=this.getSinglePixelWidth())}else v/=w;if(1!==a&&(n.scale(a,a),v/=a),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)+r,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/a,x=(A+s)/a}else _=A/a,x=0;if(i.remeasure&&S>0){const t=1e3*n.measureText(v).width/s*a;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/a)}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/a,e=x-s*w.offset.y/a;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,a=i.fontDirection,r=s.vertical?1:-1,o=i.charSpacing,l=i.wordSpacing,d=i.textHScale*a,c=i.fontMatrix||h,u=t.length;let p,g,f,m;if(!(i.textRenderingMode===E)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),e.transform(...i.textMatrix),e.translate(i.x,i.y),e.scale(d,a),p=0;p<u;++p){if(g=t[p],"number"==typeof g){m=r*g*n/1e3,this.ctx.translate(m,0),i.x+=m*d;continue}const a=(g.isSpace?l:0)+o,h=s.charProcOperatorList[g.operatorListId];if(!h){rt(`Type3 character "${g.operatorListId}" is not available.`);continue}this.contentVisible&&(this.processingType3=g,this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(h),this.restore());f=St.applyTransform([g.width,0],c)[0]*n+a,e.translate(f,0),i.x+=f*d}e.restore(),this.processingType3=null}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,i,s,n,a){this.ctx.rect(i,s,n-i,a-s),this.ctx.clip(),this.endPath()}getColorN_Pattern(t){let e;if("TilingPattern"===t[0]){const i=t[1],s=this.baseTransform||Wt(this.ctx),n={createCanvasGraphics:t=>new di(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ke(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=St.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=St.makeHexColor(t,e,i),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let i;return this.cachedPatterns.has(t)?i=this.cachedPatterns.get(t):(i=function(t){switch(t[0]){case"RadialAxial":return new ze(t);case"Mesh":return new We(t);case"Dummy":return new Ge}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,Gt(e),je);const s=Gt(e);if(s){const{width:t,height:i}=e.canvas,[n,a,r,o]=St.getAxialAlignedBoundingBox([0,0,t,i],s);this.ctx.fillRect(n,a,r-n,o-a)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ot("Should not call beginInlineImage")}beginImageData(){ot("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Wt(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(Wt(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||at("TODO: Support non-isolated groups."),t.knockout&&rt("Knockout groups not supported.");const i=Wt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let s=St.getAxialAlignedBoundingBox(t.bbox,Wt(e));const n=[0,0,e.canvas.width,e.canvas.height];s=St.intersect(s,n)||[0,0,0,0];const a=Math.floor(s[0]),r=Math.floor(s[1]),o=Math.max(Math.ceil(s[2])-a,1),l=Math.max(Math.ceil(s[3])-r,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(-a,-r),c.transform(...i),t.smask?this.smaskStack.push({canvas:d.canvas,context:c,offsetX:a,offsetY:r,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(a,r),e.save()),si(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=Wt(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const i=St.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(),ni(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const s=e[2]-e[0],a=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]=a;const[n,r]=St.singularValueDecompose2dScale(Wt(this.ctx)),{viewportScale:o}=this,l=Math.ceil(s*this.outputScaleX*o),h=Math.ceil(a*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,-r,0,a*r),ni(this.ctx)}else ni(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],s,a),this.ctx.clip(),this.ctx.beginPath()}this.current=new ti(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 a,r,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),r=1;r<e;r++)d[c]!==d[c+1]&&(l[r]=d[c]?2:1,++u),c++;for(0!==d[c]&&(l[r]=2,++u),a=1;a<i;a++){c=a*h,o=a*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(r=1;r<e;r++)t=(t>>2)+(d[c+1]?4:0)+(d[c-h+1]?8:0),s[t]&&(l[o+r]=s[t],++u),c++;if(d[c-h]!==d[c]&&(l[o+r]=d[c]?2:4,++u),u>1e3)return null}for(c=h*(i-1),o=a*n,0!==d[c]&&(l[o]=8,++u),r=1;r<e;r++)d[c]!==d[c+1]&&(l[o+r]=d[c]?4:8,++u),c++;if(0!==d[c]&&(l[o+r]=4,++u),u>1e3)return null;const p=new Int32Array([0,n,-1,0,-n,0,0,0,1]),g=new Path2D;for(a=0;u&&a<=i;a++){let t=a*n;const i=t+e;for(;t<i&&!l[t];)t++;if(t===i)continue;g.moveTo(t%n,a);const s=t;let r=l[t];do{const e=p[r];do{t+=e}while(!l[t]);const i=l[t];5!==i&&10!==i?(r=i,l[t]=0):(r=i&51*r>>4,l[t]&=r>>2|r<<2),g.lineTo(t%n,t/n|0),l[t]||--u}while(s!==t);--a}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),a=n.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,n.offsetX,n.offsetY),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i=0,s=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const r=this.ctx;r.save();const o=Wt(r);r.transform(e,i,s,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let t=0,h=a.length;t<h;t+=2){const h=St.transform(o,[e,i,s,n,a[t],a[t+1]]),[d,c]=St.applyTransform([0,0],h);r.drawImage(l.canvas,d,c)}r.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:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();ii(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=s?i.getPattern(h,this,Gt(e),Oe):i,h.fillRect(0,0,a,r),h.restore(),e.save(),e.transform(...o),e.scale(1,-1),Ze(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e?this.paintInlineImageXObject(e):rt("Dependent image isn't ready yet")}paintImageXObjectRepeat(t,e,i,s){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return void rt("Dependent image isn't ready yet");const a=n.width,r=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:a,h:r});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),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,i=t.height,s=this.ctx;if(this.save(),!o){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;ei(s,t),n=this.applyTransferMapsToCanvas(s)}const a=this._scaleImage(n,Gt(s));s.imageSmoothingEnabled=ai(Wt(s),t.interpolate),Ze(s,a.img,0,0,a.paintWidth,a.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;ei(n,t),s=this.applyTransferMapsToCanvas(n)}for(const t of e)i.save(),i.transform(...t.transform),i.scale(1,-1),Ze(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===hi?i.clip("evenodd"):i.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),i.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Wt(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 a,r;if(0===i&&0===s){const i=Math.abs(e),s=Math.abs(n);if(i===s)if(0===t)a=r=1/i;else{const e=i*t;a=r=e<1?1/e:1}else if(0===t)a=1/i,r=1/s;else{const e=i*t,n=s*t;a=e<1?1/e:1,r=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)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}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 a=e.getLineDash();if(t&&e.save(),e.scale(s,n),a.length>0){const t=Math.max(s,n);e.setLineDash(a.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 tt)void 0!==di.prototype[t]&&(di.prototype[tt[t]]=di.prototype[t]);let ci=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 ui{#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 At(this.#gi)}has(t){return this.#gi.has(t)}}const pi=Symbol("INTERNAL");class gi{#mi=!1;#bi=!1;#vi=!1;#wi=!0;constructor(t,{name:e,intent:i,usage:s,rbGroups:n}){this.#mi=!!(t&u),this.#bi=!!(t&p),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!==pi&&ot("Internal method `_setVisible` called."),this.#vi=i,this.#wi=e}}class fi{#yi=null;#Ai=new Map;#_i=null;#xi=null;constructor(t,e=u){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 gi(e,i));if("OFF"===t.baseState)for(const t of this.#Ai.values())t._setVisible(pi,!1);for(const e of t.on)this.#Ai.get(e)._setVisible(pi,!0);for(const e of t.off)this.#Ai.get(e)._setVisible(pi,!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 rt(`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 at("Optional content group not defined."),!0;if("OCG"===t.type)return this.#Ai.has(t.id)?this.#Ai.get(t.id).visible:(rt(`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 rt(`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 rt(`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 rt(`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 rt(`Optional content group not found: ${e}`),!0;if(this.#Ai.get(e).visible)return!1}return!0}return rt(`Unknown optional content policy ${t.policy}.`),!0}return rt(`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(pi,!1,!0);s._setVisible(pi,!!e,!0),this.#yi=null}else rt(`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?At(this.#Ai):null}getGroup(t){return this.#Ai.get(t)||null}getHash(){if(null!==this.#yi)return this.#yi;const t=new ce;for(const[e,i]of this.#Ai)t.update(`${e}:${i.visible}`);return this.#yi=t.hexdigest()}}class mi{constructor(t,{disableRange:e=!1,disableStream:i=!1}){lt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:s,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,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{lt(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(){lt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new bi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new vi(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 bi{constructor(t,e,i=!1,s=null){this._stream=t,this._done=i||!1,this._filename=Nt(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 vi{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 wi(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 yi(t){try{return new URL(t).origin}catch{}return null}function Ai({responseHeaders:t,isHttp:e,rangeChunkSize:i,disableRange:s}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return n;if(n.suggestedLength=a,a<=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 _i(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=r(i);return t=unescape(t),t=o(t),t=l(t),a(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 a=[];for(let t=0;t<e.length&&t in e;++t){let[i,s]=e[t];s=r(s),i&&(s=unescape(s),0===t&&(s=o(s))),a.push(s)}return a.join("")}(t),i)return a(l(i));if(i=s("filename","i").exec(t),i){i=i[1];let t=r(i);return t=l(t),a(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=yt(i);i=s.decode(n),e=!1}catch{}}return i}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(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(Nt(t))return t}return null}function xi(t,e){return 404===t||0===t&&e.startsWith("file:")?new ft('Missing PDF "'+e+'".'):new mt(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t)}function Si(t){return 200===t||206===t}function Ci(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function Ei(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(rt(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class Pi{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=wi(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Mi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ti(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 Mi{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,Ci(i,this._withCredentials,this._abortController)).then((e=>{if(t._responseOrigin=yi(e.url),!Si(e.status))throw xi(e.status,s);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:n,suggestedLength:a}=Ai({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=_i(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new vt("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:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class Ti{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 a=s.url;fetch(a,Ci(n,this._withCredentials,this._abortController)).then((e=>{const i=yi(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!Si(e.status))throw xi(e.status,a);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:Ei(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class ki{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=wi(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",lt(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 a=function(t){const e=t.response;return"string"!=typeof e?e:yt(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:a}):(rt('Missing or invalid "Content-Range" header.'),i.onError(0))}else a?i.onDone({begin:0,chunk:a}):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 Ii{constructor(t){this._source=t,this._manager=new ki(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 lt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Li(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new Di(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 Li{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=yi(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:a}=Ai({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=_i(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=xi(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 Di{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=yi(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??=xi(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 Ri=/^[a-z][a-z0-9\-+.]+:/i;class Ni{constructor(t){this.source=t,this.url=function(t){if(Ri.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),lt("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return lt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Fi(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Oi(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 Fi{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 ft(`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 vt("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Oi{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 Bi=30;let ji=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=[];#Hi=new WeakMap;#Vi=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:a,pageX:r,pageY:o}=s.rawDims;this.#Vi=[1,0,0,-1,-r,o+a],this.#Ii=n,this.#ki=a,t.#qi(),qt(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}=_t.platform;return dt(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,qt(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.#Hi.get(t),e.div=t,this.#Yi(e)}}cancel(){const t=new vt("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 rt("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=St.transform(this.#Vi,e.transform);let a=Math.atan2(n[1],n[0]);const r=this.#Fi[e.fontName];r.vertical&&(a+=Math.PI/2);let o=this.#Pi&&r.fontSubstitution||r.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===a?(d=n[4],c=n[5]-h):(d=n[4]+h*Math.sin(a),c=n[5]-h*Math.cos(a));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=r.fontSubstitutionLoadedName||e.fontName),0!==a&&(s.angle=a*(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=r.vertical?e.height:e.width),this.#Hi.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:a}=i;let r="";if(t.#Wi>1&&(r=`scale(${1/t.#Wi})`),0!==s.canvasWidth&&s.hasText){const{fontFamily:e}=a,{canvasWidth:o,fontSize:l}=s;t.#Zi(n,l*this.#Ni,e);const{width:h}=n.measureText(i.textContent);h>0&&(r=`scaleX(${o*this.#Ni/h}) ${r}`)}0!==s.angle&&(r=`rotate(${s.angle}deg) ${r}`),r.length>0&&(a.transform=r)}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=Bi,this.#Zi(s,Bi,t);const n=s.measureText("");let a=n.fontBoundingBoxAscent,r=Math.abs(n.fontBoundingBoxDescent);if(a){const e=a/(a+r);return this.#zi.set(t,e),s.canvas.width=s.canvas.height=0,e}s.strokeStyle="red",s.clearRect(0,0,Bi,Bi),s.strokeText("g",0,0);let o=s.getImageData(0,0,Bi,Bi).data;r=0;for(let t=o.length-1-3;t>=0;t-=4)if(o[t]>0){r=Math.ceil(t/4/Bi);break}s.clearRect(0,0,Bi,Bi),s.strokeText("A",0,Bi),o=s.getImageData(0,0,Bi,Bi).data,a=0;for(let t=0,e=o.length;t<e;t+=4)if(o[t]>0){a=Bi-Math.floor(t/4/Bi);break}s.canvas.width=s.canvas.height=0;const l=a?a/(a+r):.8;return this.#zi.set(t,l),l}};class Hi{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(!Hi.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 Vi=65536,zi=o?class extends ke{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,i)}}:class extends ke{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}},Ui=o?class extends Ie{async _fetch(t){return Fe(t)}}:Le,$i=o?class extends De{}:class extends De{#ts;#es;#is;#ss;#ns;#as;#w=0;constructor({docId:t,ownerDocument:e=globalThis.document}){super(),this.#ss=t,this.#ns=e}get#A(){return this.#es||=new Map}get#rs(){return this.#as||=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(Tt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#is=this.#ns.createElementNS(Tt,"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),a=new Array(256),r=new Array(256);for(let t=0;t<256;t++)n[t]=e[t]/255,a[t]=i[t]/255,r[t]=s[t]/255;return[n.join(","),a.join(","),r.join(",")]}#hs(t){if(void 0===this.#ts){this.#ts="";const t=this.#ns.URL;t!==this.#ns.baseURI&&(Rt(t)?rt('#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),a=1===t.length?i:`${i}${s}${n}`;if(e=this.#A.get(a),e)return this.#A.set(t,e),e;const r=`g_${this.#ss}_transfer_map_${this.#w++}`,o=this.#hs(r);this.#A.set(t,o),this.#A.set(a,o);const l=this.#ds(r);return this.#cs(i,s,n,l),o}addHCMFilter(t,e){const i=`${t}-${e}`,s="base";let n=this.#rs.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.#rs.set(s,n)),!t||!e)return n.url;const a=this.#us(t);t=St.makeHexColor(...a);const r=this.#us(e);if(e=St.makeHexColor(...r),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=a[t]/255,s=r[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++}`,a=this.#hs(n);this.#A.set(t,a),this.#A.set(s,a);const r=this.#ds(n);return this.#gs(i,r),a}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++}`,a=this.#hs(n);this.#A.set(t,a),this.#A.set(i,a);const r=this.#ds(n);return this.#fs(r),t&&this.#gs(e,r),a}addHighlightHCMFilter(t,e,i,s,n){const a=`${e}-${i}-${s}-${n}`;let r=this.#rs.get(t);if(r?.key===a)return r.url;if(r?(r.filter?.remove(),r.key=a,r.url="none",r.filter=null):(r={key:a,url:"none",filter:null},this.#rs.set(t,r)),!e||!i)return r.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,a=t/255,r=(e-t)/(255*i);let o=0;for(let t=0;t<=i;t++){const e=Math.round(h+t*n),i=a+t*r;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=r.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),r.url=this.#hs(g),r.url}destroy(t=!1){t&&this.#as?.size||(this.#is?.parentNode.parentNode.remove(),this.#is=null,this.#es?.clear(),this.#es=null,this.#as?.clear(),this.#as=null,this.#w=0)}#fs(t){const e=this.#ns.createElementNS(Tt,"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(Tt,"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(Tt,"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(Tt,e);s.setAttribute("type","discrete"),s.setAttribute("tableValues",i),t.append(s)}#cs(t,e,i,s){const n=this.#ns.createElementNS(Tt,"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(Tt,"feComponentTransfer");e.append(i),this.#ms(i,"feFuncA",t)}#us(t){return this.#os.style.color=t,$t(getComputedStyle(this.#os).getPropertyValue("color"))}},Wi=o?class extends Re{async _fetch(t){return Fe(t)}}:Ne;function Gi(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Xi,{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(o&&"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(o&&"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 yt(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,a=t.httpHeaders||null,r=!0===t.withCredentials,l=t.password??null,h=t.range instanceof Ki?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:Vi;let c=t.worker instanceof Zi?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||Rt(t.docBaseUrl)?null:t.docBaseUrl,g="string"==typeof t.cMapUrl?t.cMapUrl:null,f=!1!==t.cMapPacked,m=t.CMapReaderFactory||Ui,b="string"==typeof t.standardFontDataUrl?t.standardFontDataUrl:null,v=t.StandardFontDataFactory||Wi,w=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,A=!1!==t.isEvalSupported,_="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!o,x="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!o&&(_t.platform.isFirefox||!globalThis.chrome),S=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,C="boolean"==typeof t.disableFontFace?t.disableFontFace:o,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||zi,R=t.FilterFactory||$i,N=!0===t.enableHWA,F=h?h.length:t.length??NaN,O="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!o&&!C,B="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:m===Le&&v===Ne&&g&&b&&jt(g,document.baseURI)&&jt(b,document.baseURI);st(u);const j={canvasFactory:new D({ownerDocument:M,enableHWA:N}),filterFactory:new R({docId:i,ownerDocument:M}),cMapReaderFactory:B?null:new m({baseUrl:g,isCompressed:f}),standardFontDataFactory:B?null:new v({baseUrl:b})};if(!c){const t={verbosity:u,port:ci.workerPort};c=t.port?Zi.fromPort(t):new Zi(t),e._worker=c}const H={docId:i,apiVersion:"4.10.38",data:n,password:l,disableAutoFetch:I,rangeChunkSize:d,length:F,docBaseUrl:p,enableXfa:P,evaluatorOptions:{maxImageSize:y,disableFontFace:C,ignoreErrors:w,isEvalSupported:A,isOffscreenCanvasSupported:_,isImageDecoderSupported:x,canvasMaxAreaInBytes:S,fontExtraProperties:E,useSystemFonts:O,cMapUrl:B?g:null,standardFontDataUrl:B?b:null}},V={disableFontFace:C,fontExtraProperties:E,ownerDocument:M,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:P}};return c.promise.then((function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",H,n?[n.buffer]:null);let l;if(h)l=new mi(h,{disableRange:T,disableStream:k});else if(!n){if(!s)throw new Error("getDocument - no `url` parameter provided.");let t;if(o)if(jt(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=Pi}else t=Ni;else t=jt(s)?Pi:Ii;l=new t({url:s,length:F,httpHeaders:a,withCredentials:r,rangeChunkSize:d,disableRange:T,disableStream:k})}return t.then((t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const s=new Te(i,t,c.port),n=new ts(s,e,l,V,j);e._transport=n,s.send("Ready",null)}))})).catch(e._capability.reject),e}function qi(t){return"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0}class Xi{static#ss=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+Xi.#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 Ki=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){ot("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Yi{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 dt(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 Qi{#bs=null;#vs=!1;constructor(t,e,i,s=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=s?new Bt:null,this._pdfBug=s,this.commonObjs=i.commonObjs,this.objs=new is,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 Lt({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 dt(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=w.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:r=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:g}=c;this.#vs=!1,this.#ws(),r||=this._transport.getOptionalContentConfig(u);let f=this._intentStates.get(g);f||(f=Object.create(null),this._intentStates.set(g,f)),f.streamReaderCancelTimeout&&(clearTimeout(f.streamReaderCancelTimeout),f.streamReaderCancelTimeout=null);const m=!!(u&p);f.displayReadyCapability||(f.displayReadyCapability=Promise.withResolvers(),f.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(c));const b=t=>{f.renderTasks.delete(v),(this._maybeCleanupAfterRender||m)&&(this.#vs=!0),this.#ys(!m),t?(v.capability.reject(t),this._abortOperatorList({intentState:f,reason:t instanceof Error?t:new Error(t)})):v.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},v=new ns({callback:b,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:o,operatorList:f.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!m,pdfBug:this._pdfBug,pageColors:l});(f.renderTasks||=new Set).add(v);const y=v.task;return Promise.all([f.displayReadyCapability.promise,r]).then((([t,e])=>{if(this.destroyed)b();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.");v.initializeGraphics({transparency:t,optionalContentConfig:e}),v.operatorListChanged()}})).catch(b),y}getOperatorList({intent:t="display",annotationMode:e=w.ENABLE,printAnnotationStorage:i=null,isEditing:s=!1}={}){const n=this._transport.getRenderingIntent(t,e,i,s,!0);let a,r=this._intentStates.get(n.cacheKey);return r||(r=Object.create(null),this._intentStates.set(n.cacheKey,r)),r.opListReadCapability||(a=Object.create(null),a.operatorListChanged=function(){r.operatorList.lastChunk&&(r.opListReadCapability.resolve(r.operatorList),r.renderTasks.delete(a))},r.opListReadCapability=Promise.withResolvers(),(r.renderTasks||=new Set).add(a),r.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(n)),r.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=>Hi.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 Bt),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:a}=i,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:s},a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.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 Dt){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 vt(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 Ji{#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 rt("LoopbackPort - cannot use an `aborted` signal.");const a=()=>this.removeEventListener(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}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 Zi=class t{static#xs=0;static#Ss=!1;static#Cs;static{o&&(this.#Ss=!0,ci.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=nt()}={}){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 Te("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 Te("main","worker",i),n=()=>{a.abort(),s.destroy(),i.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;i.addEventListener("error",(()=>{this._webWorker||n()}),{signal:a.signal}),s.on("test",(t=>{a.abort(),!this.destroyed&&t?(this._messageHandler=s,this._port=i,this._webWorker=i,this.#Es()):n()})),s.on("ready",(t=>{if(a.abort(),this.destroyed)n();else try{r()}catch{this._setupFakeWorker()}}));const r=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void r()}catch{at("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){t.#Ss||(rt("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 Ji;this._port=i;const s="fake"+t.#xs++,n=new Te(s+"_worker",s,i);e.setup(n,i),this._messageHandler=new Te(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(ci.workerSrc)return ci.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ps(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return dt(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ps)return this.#Ps;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class ts{#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 is,this.fontLoader=new fe({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 dt(this,"annotationStorage",new pe)}getRenderingIntent(t,e=w.ENABLE,i=null,s=!1,n=!1){let a=u,r=ue;switch(t){case"any":a=c;break;case"display":break;case"print":a=p;break;default:rt(`getRenderingIntent - invalid intent: ${t}`)}const o=a&p&&i instanceof ge?i:this.annotationStorage;switch(e){case w.DISABLE:a+=m;break;case w.ENABLE:break;case w.ENABLE_FORMS:a+=g;break;case w.ENABLE_STORAGE:a+=f,r=o.serializable;break;default:rt(`getRenderingIntent - invalid annotationMode: ${e}`)}s&&(a+=b),n&&(a+=v);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,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(),ji.cleanup(),this._networkStream?.cancelAllRequests(new vt("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)=>{lt(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():(lt(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)=>{lt(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():(lt(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 Yi(t,this))})),t.on("DocException",(t=>{e._capability.reject(Me(t))})),t.on("PasswordRequest",(t=>{this.#Ls=Promise.withResolvers();try{if(!e.onPassword)throw Me(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:a,pdfBug:r}=this._params;if("error"in s){const t=s.error;rt(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const o=r&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,l=new me(s,{disableFontFace:n,fontExtraProperties:a,inspectFont:o});this.fontLoader.bind(l).catch((()=>t.sendWithPromise("FontFallback",{id:e}))).finally((()=>{!a&&l.data&&(l.data=null),this.commonObjs.resolve(e,l)}));break;case"CopyLocalImage":const{imageRef:h}=s;lt(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&&rt("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 Qi(e,i,this,this._params.pdfBug);return this.#Ts.set(e,s),s}));return this.#ks.set(e,s),s}getPageIndex(t){return qi(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 fi(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 ui(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),ji.cleanup()}}cachedPageNumber(t){if(!qi(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#Is.get(e)??null}}const es=Symbol("INITIAL_DATA");class is{#Rs=Object.create(null);#Ns(t){return this.#Rs[t]||={...Promise.withResolvers(),data:es}}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===es)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!==es}delete(t){const e=this.#Rs[t];return!(!e||e.data===es)&&(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!==es&&(yield[t,e])}}}class ss{#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 ns{#Os=null;static#Bs=new WeakSet;constructor({callback:t,params:e,objs:i,commonObjs:s,annotationCanvasMap:n,operatorList:a,pageIndex:r,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=a,this._pageIndex=r,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 ss(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(ns.#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.");ns.#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:a}=this.params;this.gfx=new di(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:a}),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),ns.#Bs.delete(this._canvas),this.callback(t||new Dt(`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(),ns.#Bs.delete(this._canvas),this.callback())))}}const as="4.10.38",rs="f9bea397f";function os(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function ls(t){return Math.max(0,Math.min(255,255*t))}class hs{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=ls(t),t,t]}static G_HTML([t]){const e=os(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(ls)}static RGB_HTML(t){return`#${t.map(os).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[ls(1-Math.min(1,t+s)),ls(1-Math.min(1,i+s)),ls(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,a=1-i;return["CMYK",s,n,a,Math.min(s,n,a)]}}class ds{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){ot("Abstract method `_createSVG` called.")}}let cs=class extends ds{_createSVG(t){return document.createElementNS(Tt,t)}},us=class{static setupStorage(t,e,i,s,n){const a=s.getValue(e,{value:null});switch(i.name){case"textarea":if(null!==a.value&&(t.textContent=a.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(a.value===i.attributes.xfaOn?t.setAttribute("checked",!0):a.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!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",(t=>{s.setValue(e,{value:t.target.value})}))}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of i.children)t.attributes.value===a.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:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${s}`);for(const[e,i]of Object.entries(a))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:(!r||"href"!==e&&"newWindow"!==e)&&t.setAttribute(e,i)}r&&n.addLinkAttributes(t,a.href,a.newWindow),i&&a.dataId&&this.setupStorage(t,a.dataId,e,i)}static render(t){const e=t.annotationStorage,i=t.linkService,s=t.xfaHtml,n=t.intent||"display",a=document.createElement(s.name);s.attributes&&this.setAttributes({html:a,element:s,intent:n,linkService:i});const r="richText"!==n,o=t.div;if(o.append(a),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;o.style.transform=e}r&&o.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===s.children.length){if(s.value){const t=document.createTextNode(s.value);a.append(t),r&&Hi.shouldBuildText(s.name)&&l.push(t)}return{textDivs:l}}const h=[[s,-1,a]];for(;h.length>0;){const[t,s,a]=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),a.append(t);continue}const c=o?.attributes?.xmlns?document.createElementNS(o.attributes.xmlns,d):document.createElement(d);if(a.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);r&&Hi.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 ps=1e3,gs=new WeakSet;function fs(t){return{width:t[2]-t[0],height:t[3]-t[1]}}class ms{static create(t){switch(t.data.annotationType){case I:return new vs(t);case k:return new ws(t);case q:switch(t.data.fieldType){case"Tx":return new As(t);case"Btn":return t.data.radioButton?new Ss(t):t.data.checkBox?new xs(t):new Cs(t);case"Ch":return new Es(t);case"Sig":return new _s(t)}return new ys(t);case W:return new Ps(t);case L:return new Ts(t);case D:return new ks(t);case R:return new Is(t);case N:return new Ls(t);case O:return new Ds(t);case U:return new Ns(t);case $:return new Fs(t);case F:return new Rs(t);case B:return new Os(t);case j:return new Bs(t);case H:return new js(t);case V:return new Hs(t);case z:return new Vs(t);case G:return new zs(t);default:return new bs(t)}}}class bs{#js=null;#Hs=!1;#Vs=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 bs._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.#Vs?.popup.updateEdited(t)}resetEdited(){this.#js&&(this.#zs(this.#js.rect),this.#Vs?.popup.resetEdited(),this.#js=null)}#zs(t){const{container:{style:e},data:{rect:i,rotation:s},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;i?.splice(0,4,...t);const{width:l,height:h}=fs(t);e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===s?(e.width=100*l/n+"%",e.height=100*h/a+"%"):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 ys||(n.tabIndex=ps);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Ps){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=fs(e.rect);if(!t&&e.borderStyle.width>0){a.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))`;a.borderRadius=e}else if(this instanceof Ss){const t=`calc(${r}px * var(--scale-factor)) / calc(${o}px * var(--scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case X:a.borderStyle="solid";break;case K:a.borderStyle="dashed";break;case Y:rt("Unimplemented border style: beveled");break;case Q:rt("Unimplemented border style: inset");break;case J:a.borderBottomStyle="solid"}const s=e.borderColor||null;s?(this.#Hs=!0,a.borderColor=St.makeHexColor(0|s[0],0|s[1],0|s[2])):a.borderWidth=0}const l=St.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;a.left=100*(l[0]-c)/h+"%",a.top=100*(l[1]-u)/d+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.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:a}=fs(this.data.rect);let r,o;t%180==0?(r=100*n/i,o=100*a/s):(r=100*a/i,o=100*n/s),e.style.width=`${r}%`,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],a=s.slice(1);i.target.style[e]=hs[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:hs[`${n}_rgb`](a)})};return dt(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 a=i[s];if(a){a({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[a,r,o,l]=t.subarray(2,6);if(s===a&&n===r&&e===o&&i===l)return}const{style:a}=this.container;let r;if(this.#Hs){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${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],a=t[i+1],d=t[i+2],c=t[i+3],p=h.createElement("rect"),g=(d-e)/o,f=(n-a)/l,m=(s-d)/o,b=(a-c)/l;p.setAttribute("x",g),p.setAttribute("y",f),p.setAttribute("width",m),p.setAttribute("height",b),u.append(p),r?.push(`<rect vector-effect="non-scaling-stroke" x="${g}" y="${f}" width="${m}" height="${b}"/>`)}this.#Hs&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(d),this.container.style.clipPath=`url(#${p})`}_createPopup(){const{data:t}=this,e=this.#Vs=new Ps({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(){ot("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:a}of s){if(-1===t)continue;if(n===e)continue;const s="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||gs.has(r)?i.push({id:n,exportValue:s,domElement:r}):rt(`_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&&(gs.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 vs extends bs{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 rt('_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,a=[];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&&a.push(i)}else for(const t of Object.values(this._fieldObjects))a.push(...t);const r=this.annotationStorage,o=[];for(const t of a){const{id:e}=t;switch(o.push(e),t.type){case"text":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}case"checkbox":case"radiobutton":{const i=t.defaultValue===t.exportValues;r.setValue(e,{value:i});break}case"combobox":case"listbox":{const i=t.defaultValue||"";r.setValue(e,{value:i});break}default:continue}const i=document.querySelector(`[data-element-id="${e}"]`);i&&(gs.has(i)?i.dispatchEvent(new Event("resetform")):rt(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class ws extends bs{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 ys extends bs{render(){return this.container}showElementAndHideCanvas(t){this.data.hasOwnCanvas&&("CANVAS"===t.previousSibling?.nodeName&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return _t.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,a]of i)("Action"===a||this.data.actions?.[a])&&("Focus"!==a&&"Blur"!==a||(e||={focused:!1}),this._setEventListener(t,e,n,a,s),"Focus"!==a||this.data.actions?.Blur?"Blur"!==a||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":St.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 a;const r=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/(d*s))||1);a=Math.min(s,r(e/d))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(s,r(t/d))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=St.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 As extends ys{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 a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=i),n.setValue(a.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 a=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;a&&n.length>a&&(n=n.slice(0,a));let r=s.formattedValue||this.data.textContent?.join("\n")||null;r&&this.data.comb&&(r=r.replaceAll(/\s+/g,""));const o={userValue:n,formattedValue:r,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=r??n,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type="text",i.setAttribute("value",r??n),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),gs.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=ps,this._setRequired(i,this.data.required),a&&(i.maxLength=a),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 a=o.userValue;!a||a.length<=s||(a=a.slice(0,s),n.value=o.userValue=a,t.setValue(e,{value:a}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:a,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:a,selectionEnd:r}=s;let l=a,h=r;switch(t.inputType){case"deleteWordBackward":{const t=n.substring(0,a).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}case"deleteWordForward":{const t=n.substring(a).match(/^[^\w]*\w*/);t&&(h+=t[0].length);break}case"deleteContentBackward":a===r&&(l-=1);break;case"deleteContentForward":a===r&&(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])/a;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 _s extends ys{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class xs extends ys{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 gs.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=ps,n.addEventListener("change",(s=>{const{name:n,checked:a}=s.target;for(const s of this._getElementsByName(n,i)){const i=a&&s.exportValue===e.exportValue;s.domElement&&(s.domElement.checked=i),t.setValue(s.id,{value:i})}t.setValue(i,{value:a})})),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 Ss extends ys{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(gs.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=ps,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 Cs extends vs{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 Es extends ys{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");gs.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=ps;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 a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),s.prepend(t),a=()=>{t.remove(),s.removeEventListener("input",a),a=null},s.addEventListener("input",a)}const r=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=r(!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){a?.();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:r(!0)}),o=r(!1)},multipleSelection(t){s.multiple=!0},remove(i){const n=s.options,a=i.detail.remove;if(n[a].selected=!1,s.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,(t=>t.selected))&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(i)}),o=r(!1)},clear(i){for(;0!==s.length;)s.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(i){const{index:n,displayValue:a,exportValue:h}=i.detail.insert,d=s.children[n],c=document.createElement("option");c.textContent=a,c.value=h,d?d.before(c):s.append(c),t.setValue(e,{value:r(!0),items:l(i)}),o=r(!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:r(!0),items:l(i)}),o=r(!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:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,i)})),s.addEventListener("input",(i=>{const s=r(!0),n=r(!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:r(!0)})})),this.data.combo&&this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class Ps extends bs{constructor(t){const{data:e,elements:i}=t;super(t,{isRenderable:bs._hasPopupData(e)}),this.elements=i,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Ms({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=>`${Mt}${t}`)).join(",")),this.container}}class Ms{#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;#an=null;#rn=!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:a,richText:r,parent:o,rect:l,parentRect:h,open:d}){this.#pt=t,this.#dn=s,this.#en=a,this.#hn=r,this.#nn=o,this.#tn=e,this.#ln=l,this.#an=h,this.#sn=i,this.#in=zt.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=St.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=St.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)us.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.#rn)&&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 a=!!this.#an,r=a?this.#an:this.#ln;for(const t of this.#sn)if(!r||null!==St.intersect(t.data.rect,r)){r=t.data.rect,a=!0;break}const o=St.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[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.#rn=!this.#rn,this.#rn?(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.#rn&&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.#rn&&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 Ts extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=y.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 ks extends bs{#bn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const t=this.data,{width:e,height:i}=fs(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 Is extends bs{#vn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#vn=this.svgFactory.createElement("svg:rect");return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",i-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#vn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ls extends bs{#wn=null;constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const t=this.data,{width:e,height:i}=fs(t.rect),s=this.svgFactory.create(e,i,!0),n=t.borderStyle.width,a=this.#wn=this.svgFactory.createElement("svg:ellipse");return a.setAttribute("cx",e/2),a.setAttribute("cy",i/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",i/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),s.append(a),this.container.append(s),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#wn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Ds extends bs{#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:a}=fs(t),r=this.svgFactory.create(n,a,!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"),r.append(l),this.container.append(r),!s&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#yn}addHighlightArea(){this.container.classList.add("highlightArea")}}class Rs extends Ds{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ns extends bs{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 Fs extends bs{#An=null;#_n=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?y.HIGHLIGHT:y.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:a,width:r,height:o}=this.#xn(e,t),l=this.svgFactory.create(r,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",a);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 Os extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=y.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Bs extends bs{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 js extends bs{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 Hs extends bs{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 Vs extends bs{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=y.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 zs extends bs{#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}=_t.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 Us=class{#En=null;#Pn=null;#Mn=new Map;#Tn=null;constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:s,page:n,viewport:a,structTreeLayer:r}){this.div=t,this.#En=e,this.#Pn=i,this.#Tn=r||null,this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=s}hasEditableAnnotations(){return this.#Mn.size>0}async#kn(t,e){const i=t.firstChild||t,s=i.id=`${Mt}${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;qt(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 cs,annotationStorage:t.annotationStorage||new pe,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===W;if(e){const e=s.get(t.id);if(!e)continue;n.elements=e}else{const{width:e,height:i}=fs(t.rect);if(e<=0||i<=0)continue}n.data=t;const i=ms.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 a=i.render();t.hidden&&(a.style.visibility="hidden"),await this.#kn(a,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,qt(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 $s=/\r\n?|\n/g;class Ws extends re{#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=Ws.prototype,e=t=>t.isEmpty(),i=se.TRANSLATE_SMALL,s=se.TRANSLATE_BIG;return dt(this,"_keyboardManager",new ee([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],t.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],t.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],t._translateEmpty,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t._translateEmpty,{args:[-s,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t._translateEmpty,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t._translateEmpty,{args:[s,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t._translateEmpty,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t._translateEmpty,{args:[0,-s],checker:e}],[["ArrowDown","mac+ArrowDown"],t._translateEmpty,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t._translateEmpty,{args:[0,s],checker:e}]]))}static _type="freetext";static _editorType=y.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.#tn=t.color||Ws._defaultColor||re._defaultLineColor,this.#pn=t.fontSize||Ws._defaultFontSize}static initialize(t,e){re.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case A.FREETEXT_SIZE:Ws._defaultFontSize=e;break;case A.FREETEXT_COLOR:Ws._defaultColor=e}}updateParams(t,e){switch(t){case A.FREETEXT_SIZE:this.#Nn(e);break;case A.FREETEXT_COLOR:this.#Fn(e)}}static get defaultPropertiesToUpdate(){return[[A.FREETEXT_SIZE,Ws._defaultFontSize],[A.FREETEXT_COLOR,Ws._defaultColor||re._defaultLineColor]]}get propertiesToUpdate(){return[[A.FREETEXT_SIZE,this.#pn],[A.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:A.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:A.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-Ws._internalPadding*t,-(Ws._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(y.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(Ws.#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.#Hn(),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){Ws._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),Qt(this,this.div,["dblclick","keydown"]),this.width){const[i,s]=this.parentDimensions;if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);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,[a,r]=[r,-a];break;case 180:c=t-this.width+(n[0]-h)/o,u=e-(n[1]-d)/l,[a,r]=[-a,-r];break;case 270:c=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-d-this.width*o)/l,[a,r]=[-r,a]}this.setAt(c*i,u*s,a,r)}else this.setAt(t*i,e*s,this.width*i,this.height*s);this.#Hn(),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($s,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const s=Ws.#Vn(e.getData("text")||"").replaceAll($s,"\n");if(!s)return;const n=window.getSelection();if(!n.rangeCount)return;this.editorDiv.normalize(),n.deleteFromDocument();const a=n.getRangeAt(0);if(!s.includes("\n"))return a.insertNode(document.createTextNode(s)),this.editorDiv.normalize(),void n.collapseToStart();const{startContainer:r,startOffset:o}=a,l=[],h=[];if(r.nodeType===Node.TEXT_NODE){const t=r.parentElement;if(h.push(r.nodeValue.slice(o).replaceAll($s,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(Ws.#jn(i)):e=h}l.push(r.nodeValue.slice(0,o).replaceAll($s,""))}else if(r===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(Ws.#jn(i))}this.#Ln=`${l.join("\n")}${s}${h.join("\n")}`,this.#Hn();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)}#Hn(){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#Vn(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(t,e,i){let s=null;if(t instanceof Ts){const{data:{defaultAppearanceData:{fontSize:e,fontColor:i},rect:n,rotation:a,id:r,popupRef:o},textContent:l,textPosition:h,parent:{page:{pageNumber:d}}}=t;if(!l||0===l.length)return null;s=t={annotationType:y.FREETEXT,color:Array.from(i),fontSize:e,value:l.join("\n"),position:h,pageIndex:d-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,popupRef:o}}const n=await super.deserialize(t,e,i);return n.#pn=t.fontSize,n.#tn=St.makeHexColor(...t.color),n.#Ln=Ws.#Vn(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=Ws._internalPadding*this.parentScale,i=this.getRect(e,e),s=re._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#tn),n={annotationType:y.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=Ws._internalPadding*this.parentScale;return t.updateEdited({rect:this.getRect(s,s),popupContent:this.#Ln}),e}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}}class Gs{static PRECISION=1e-4;toSVGPath(){ot("Abstract method `toSVGPath` must be implemented.")}get box(){ot("Abstract getter `box` must be implemented.")}serialize(t,e){ot("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*s,a[r+1]=i+t[r+1]*n;return a}static _rescaleAndSwap(t,e,i,s,n,a){a||=new Float32Array(t.length);for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*s,a[r+1]=i+t[r]*n;return a}static _translate(t,e,i,s){s||=new Float32Array(t.length);for(let n=0,a=t.length;n<a;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,a){return[(t+5*i)/6,(e+5*s)/6,(5*i+n)/6,(5*s+a)/6,(i+n)/2,(s+a)/2]}}class qs{#$n;#Wn=[];#Gn;#qn;#Xn=[];#Kn=new Float32Array(18);#Yn;#Qn;#Jn;#Zn;#ta;#ea;#ia=[];static#sa=8;static#na=2;static#aa=qs.#sa+qs.#na;constructor({x:t,y:e},i,s,n,a,r=0){this.#$n=i,this.#ea=n*s,this.#qn=a,this.#Kn.set([NaN,NaN,NaN,NaN,t,e],6),this.#Gn=r,this.#Zn=qs.#sa*s,this.#Jn=qs.#aa*s,this.#ta=s,this.#ia.push(t,e)}isEmpty(){return isNaN(this.#Kn[8])}#ra(){const t=this.#Kn.subarray(4,6),e=this.#Kn.subarray(16,18),[i,s,n,a]=this.#$n;return[(this.#Yn+(t[0]-e[0])/2-i)/n,(this.#Qn+(t[1]-e[1])/2-s)/a,(this.#Yn+(e[0]-t[0])/2-i)/n,(this.#Qn+(e[1]-t[1])/2-s)/a]}add({x:t,y:e}){this.#Yn=t,this.#Qn=e;const[i,s,n,a]=this.#$n;let[r,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=r,v=o;r=l,o=h,l+=f,h+=m,this.#ia?.push(t,e);const w=f/p,y=-m/p*this.#ea,A=w*this.#ea;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([r+y,o+A],2),this.#Xn.push(NaN,NaN,NaN,NaN,(r+y-i)/n,(o+A-s)/a),this.#Kn.set([r-y,o-A],14),this.#Wn.push(NaN,NaN,NaN,NaN,(r-y-i)/n,(o-A-s)/a)),this.#Kn.set([b,v,r,o,l,h],6),!this.isEmpty();this.#Kn.set([b,v,r,o,l,h],6);return Math.abs(Math.atan2(v-o,b-r)-Math.atan2(m,f))<Math.PI/2?([r,o,l,h]=this.#Kn.subarray(2,6),this.#Xn.push(NaN,NaN,NaN,NaN,((r+l)/2-i)/n,((o+h)/2-s)/a),[r,o,b,v]=this.#Kn.subarray(14,18),this.#Wn.push(NaN,NaN,NaN,NaN,((b+r)/2-i)/n,((v+o)/2-s)/a),!0):([b,v,r,o,l,h]=this.#Kn.subarray(0,6),this.#Xn.push(((b+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),[l,h,r,o,b,v]=this.#Kn.subarray(12,18),this.#Wn.push(((b+5*r)/6-i)/n,((v+5*o)/6-s)/a,((5*r+l)/6-i)/n,((5*o+h)/6-s)/a,((r+l)/2-i)/n,((o+h)/2-s)/a),!0)}toSVGPath(){if(this.isEmpty())return"";const t=this.#Xn,e=this.#Wn;if(isNaN(this.#Kn[6])&&!this.isEmpty())return this.#oa();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.#la(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.#ha(i),i.join(" ")}#oa(){const[t,e,i,s]=this.#$n,[n,a,r,o]=this.#ra();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} ${a} L${r} ${o} L${(this.#Kn[16]-t)/i} ${(this.#Kn[17]-e)/s} L${(this.#Kn[14]-t)/i} ${(this.#Kn[15]-e)/s} Z`}#ha(t){const e=this.#Wn;t.push(`L${e[4]} ${e[5]} Z`)}#la(t){const[e,i,s,n]=this.#$n,a=this.#Kn.subarray(4,6),r=this.#Kn.subarray(16,18),[o,l,h,d]=this.#ra();t.push(`L${(a[0]-e)/s} ${(a[1]-i)/n} L${o} ${l} L${h} ${d} L${(r[0]-e)/s} ${(r[1]-i)/n}`)}newFreeDrawOutline(t,e,i,s,n,a){return new Xs(t,e,i,s,n,a)}getOutlines(){const t=this.#Xn,e=this.#Wn,i=this.#Kn,[s,n,a,r]=this.#$n,o=new Float32Array((this.#ia?.length??0)+2);for(let t=0,e=o.length-2;t<e;t+=2)o[t]=(this.#ia[t]-s)/a,o[t+1]=(this.#ia[t+1]-n)/r;if(o[o.length-2]=(this.#Yn-s)/a,o[o.length-1]=(this.#Qn-n)/r,isNaN(i[6])&&!this.isEmpty())return this.#da(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.#ca(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.#ua(l,h),this.newFreeDrawOutline(l,o,this.#$n,this.#ta,this.#Gn,this.#qn)}#da(t){const e=this.#Kn,[i,s,n,a]=this.#$n,[r,o,l,h]=this.#ra(),d=new Float32Array(36);return d.set([NaN,NaN,NaN,NaN,(e[2]-i)/n,(e[3]-s)/a,NaN,NaN,NaN,NaN,(e[4]-i)/n,(e[5]-s)/a,NaN,NaN,NaN,NaN,r,o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,(e[16]-i)/n,(e[17]-s)/a,NaN,NaN,NaN,NaN,(e[14]-i)/n,(e[15]-s)/a],0),this.newFreeDrawOutline(d,t,this.#$n,this.#ta,this.#Gn,this.#qn)}#ua(t,e){const i=this.#Wn;return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+6}#ca(t,e){const i=this.#Kn.subarray(4,6),s=this.#Kn.subarray(16,18),[n,a,r,o]=this.#$n,[l,h,d,c]=this.#ra();return t.set([NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,d,c,NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o],e),e+24}}class Xs extends Gs{#$n;#pa=new Float32Array(4);#Gn;#qn;#ia;#ta;#ga;constructor(t,e,i,s,n,a){super(),this.#ga=t,this.#ia=e,this.#$n=i,this.#ta=s,this.#Gn=n,this.#qn=a,this.lastPoint=[NaN,NaN],this.#fa(a);const[r,o,l,h]=this.#pa;for(let e=0,i=t.length;e<i;e+=2)t[e]=(t[e]-r)/l,t[e+1]=(t[e+1]-o)/h;for(let t=0,i=e.length;t<i;t+=2)e[t]=(e[t]-r)/l,e[t+1]=(e[t+1]-o)/h}toSVGPath(){const t=[`M${this.#ga[4]} ${this.#ga[5]}`];for(let e=6,i=this.#ga.length;e<i;e+=6)isNaN(this.#ga[e])?t.push(`L${this.#ga[e+4]} ${this.#ga[e+5]}`):t.push(`C${this.#ga[e]} ${this.#ga[e+1]} ${this.#ga[e+2]} ${this.#ga[e+3]} ${this.#ga[e+4]} ${this.#ga[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,i,s],n){const a=i-t,r=s-e;let o,l;switch(n){case 0:o=Gs._rescale(this.#ga,t,s,a,-r),l=Gs._rescale(this.#ia,t,s,a,-r);break;case 90:o=Gs._rescaleAndSwap(this.#ga,t,e,a,r),l=Gs._rescaleAndSwap(this.#ia,t,e,a,r);break;case 180:o=Gs._rescale(this.#ga,i,e,-a,r),l=Gs._rescale(this.#ia,i,e,-a,r);break;case 270:o=Gs._rescaleAndSwap(this.#ga,i,s,-a,-r),l=Gs._rescaleAndSwap(this.#ia,i,s,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}#fa(t){const e=this.#ga;let i=e[4],s=e[5],n=i,a=s,r=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]),a=Math.min(a,e[t+5]),r=Math.max(r,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=St.bezierBoundingBox(i,s,...e.slice(t,t+6));n=Math.min(n,c[0]),a=Math.min(a,c[1]),r=Math.max(r,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.#pa;c[0]=n-this.#Gn,c[1]=a-this.#Gn,c[2]=r-n+2*this.#Gn,c[3]=o-a+2*this.#Gn,this.lastPoint=[l,h]}get box(){return this.#pa}newOutliner(t,e,i,s,n,a=0){return new qs(t,e,i,s,n,a)}getNewOutline(t,e){const[i,s,n,a]=this.#pa,[r,o,l,h]=this.#$n,d=n*l,c=a*h,u=i*l+r,p=s*h+o,g=this.newOutliner({x:this.#ia[0]*d+u,y:this.#ia[1]*c+p},this.#$n,this.#ta,t,this.#qn,e??this.#Gn);for(let t=2;t<this.#ia.length;t+=2)g.add({x:this.#ia[t]*d+u,y:this.#ia[t+1]*c+p});return g.getOutlines()}}class Ks{#$n;#ma;#ba=[];#va=[];constructor(t,e=0,i=0,s=!0){let n=1/0,a=-1/0,r=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.#ba.push(g,f),n=Math.min(n,t),a=Math.max(a,c),r=Math.min(r,u),o=Math.max(o,p)}const h=a-n+2*i,d=o-r+2*i,c=n-i,u=r-i,p=this.#ba.at(s?-1:-2),g=[p[0],p[2]];for(const t of this.#ba){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.#ma=g}getOutlines(){this.#ba.sort(((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]));const t=[];for(const e of this.#ba)e[3]?(t.push(...this.#wa(e)),this.#ya(e)):(this.#Aa(e),t.push(...this.#wa(e)));return this.#_a(t)}#_a(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,a,r,o,l]=t;i.delete(t);let h=e,d=a;for(n=[e,r],s.push(n);;){let t;if(i.has(o))t=o;else{if(!i.has(l))break;t=l}i.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,d,e,d===a?a:r),h=e),d=d===a?r:a}n.push(h,d)}return new Ys(s,this.#$n,this.#ma)}#xa(t){const e=this.#va;let i=0,s=e.length-1;for(;i<=s;){const n=i+s>>1,a=e[n][0];if(a===t)return n;a<t?i=n+1:s=n-1}return s+1}#ya([,t,e]){const i=this.#xa(t);this.#va.splice(i,0,[t,e])}#Aa([,t,e]){const i=this.#xa(t);for(let s=i;s<this.#va.length;s++){const[i,n]=this.#va[s];if(i!==t)break;if(i===t&&n===e)return void this.#va.splice(s,1)}for(let s=i-1;s>=0;s--){const[i,n]=this.#va[s];if(i!==t)break;if(i===t&&n===e)return void this.#va.splice(s,1)}}#wa(t){const[e,i,s]=t,n=[[e,i,s]],a=this.#xa(s);for(let t=0;t<a;t++){const[i,s]=this.#va[t];for(let t=0,a=n.length;t<a;t++){const[,r,o]=n[t];if(!(s<=r||o<=i))if(r>=i)if(o>s)n[t][1]=s;else{if(1===a)return[];n.splice(t,1),t--,a--}else n[t][2]=i,o>s&&n.push([e,s,o])}}return n}}class Ys extends Gs{#$n;#Sa;constructor(t,e,i){super(),this.#Sa=t,this.#$n=e,this.lastPoint=i}toSVGPath(){const t=[];for(const e of this.#Sa){let[i,s]=e;t.push(`M${i} ${s}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===i?(t.push(`V${r}`),s=r):r===s&&(t.push(`H${a}`),i=a)}t.push("Z")}return t.join(" ")}serialize([t,e,i,s],n){const a=[],r=i-t,o=s-e;for(const e of this.#Sa){const i=new Array(e.length);for(let n=0;n<e.length;n+=2)i[n]=t+e[n]*r,i[n+1]=s-e[n+1]*o;a.push(i)}return a}get box(){return this.#$n}get classNamesForOutlining(){return["highlightOutline"]}}class Qs extends qs{newFreeDrawOutline(t,e,i,s,n,a){return new Js(t,e,i,s,n,a)}}class Js extends Xs{newOutliner(t,e,i,s,n,a=0){return new Qs(t,e,i,s,n,a)}}let Zs=class t{#Ca=null;#Ea=null;#Pa;#Ma=null;#Ta=!1;#ka=!1;#a=null;#Ia;#La=null;#f=null;#Da;static#Ra=null;static get _keyboardManager(){return dt(this,"_keyboardManager",new ee([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:i=null}){e?(this.#ka=!1,this.#Da=A.HIGHLIGHT_COLOR,this.#a=e):(this.#ka=!0,this.#Da=A.HIGHLIGHT_DEFAULT_COLOR),this.#f=e?._uiManager||i,this.#Ia=this.#f._eventBus,this.#Pa=e?.color||this.#f?.highlightColors.values().next().value||"#FFFF98",t.#Ra||=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.#Ca=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.#Na.bind(this),{signal:e}),t.addEventListener("keydown",this.#qs.bind(this),{signal:e});const i=this.#Ea=document.createElement("span");return i.className="swatch",i.setAttribute("aria-hidden",!0),i.style.backgroundColor=this.#Pa,t.append(i),t}renderMainDropdown(){const t=this.#Ma=this.#Fa();return t.setAttribute("aria-orientation","horizontal"),t.setAttribute("aria-labelledby","highlightColorPickerLabel"),t}#Fa(){const e=document.createElement("div"),i=this.#f._signal;e.addEventListener("contextmenu",Ht,{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 a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",n),a.title=s,a.setAttribute("data-l10n-id",t.#Ra[s]);const r=document.createElement("span");a.append(r),r.className="swatch",r.style.backgroundColor=n,a.setAttribute("aria-selected",n===this.#Pa),a.addEventListener("click",this.#Oa.bind(this,n),{signal:i}),e.append(a)}return e.addEventListener("keydown",this.#qs.bind(this),{signal:i}),e}#Oa(t,e){e.stopPropagation(),this.#Ia.dispatch("switchannotationeditorparams",{source:this,type:this.#Da,value:t})}_colorSelectFromKeyboard(t){if(t.target===this.#Ca)return void this.#Na(t);const e=t.target.getAttribute("data-color");e&&this.#Oa(e,t)}_moveToNext(t){this.#Ba?t.target!==this.#Ca?t.target.nextSibling?.focus():this.#Ma.firstChild?.focus():this.#Na(t)}_moveToPrevious(t){t.target!==this.#Ma?.firstChild&&t.target!==this.#Ca?(this.#Ba||this.#Na(t),t.target.previousSibling?.focus()):this.#Ba&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){this.#Ba?this.#Ma.firstChild?.focus():this.#Na(t)}_moveToEnd(t){this.#Ba?this.#Ma.lastChild?.focus():this.#Na(t)}#qs(e){t._keyboardManager.exec(this,e)}#Na(t){if(this.#Ba)return void this.hideDropdown();if(this.#Ta=0===t.detail,this.#La||(this.#La=new AbortController,window.addEventListener("pointerdown",this.#h.bind(this),{signal:this.#f.combinedSignal(this.#La)})),this.#Ma)return void this.#Ma.classList.remove("hidden");const e=this.#Ma=this.#Fa();this.#Ca.append(e)}#h(t){this.#Ma?.contains(t.target)||this.hideDropdown()}hideDropdown(){this.#Ma?.classList.add("hidden"),this.#La?.abort(),this.#La=null}get#Ba(){return this.#Ma&&!this.#Ma.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#ka||(this.#Ba?(this.hideDropdown(),this.#Ca.focus({preventScroll:!0,focusVisible:this.#Ta})):this.#a?.unselect())}updateColor(t){if(this.#Ea&&(this.#Ea.style.backgroundColor=t),!this.#Ma)return;const e=this.#f.highlightColors.values();for(const i of this.#Ma.children)i.setAttribute("aria-selected",e.next().value===t)}destroy(){this.#Ca?.remove(),this.#Ca=null,this.#Ea=null,this.#Ma?.remove(),this.#Ma=null}};class tn extends re{#ja=null;#Ha=0;#Va;#za=null;#n=null;#Ua=null;#$a=null;#Wa=0;#Ga=null;#qa=null;#w=null;#Xa=!1;#ma=null;#Ka;#Ya=null;#Qa="";#ea;#Ja="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=y.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=tn.prototype;return dt(this,"_keyboardManager",new ee([[["ArrowLeft","mac+ArrowLeft"],t._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],t._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],t._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],t._moveCaret,{args:[3]}]]))}constructor(t){super({...t,name:"highlightEditor"}),this.color=t.color||tn._defaultColor,this.#ea=t.thickness||tn._defaultThickness,this.#Ka=t.opacity||tn._defaultOpacity,this.#Va=t.boxes||null,this.#Ja=t.methodOfCreation||"",this.#Qa=t.text||"",this._isDraggable=!1,t.highlightId>-1?(this.#Xa=!0,this.#Za(t),this.#tr()):this.#Va&&(this.#ja=t.anchorNode,this.#Ha=t.anchorOffset,this.#$a=t.focusNode,this.#Wa=t.focusOffset,this.#er(),this.#tr(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Xa?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#ea,methodOfCreation:this.#Ja}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}#er(){const t=new Ks(this.#Va,.001);this.#qa=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#qa.box;const e=new Ks(this.#Va,.0025,.001,"ltr"===this._uiManager.direction);this.#Ua=e.getOutlines();const{lastPoint:i}=this.#Ua;this.#ma=[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height]}#Za({highlightOutlines:t,highlightId:e,clipPathId:i}){this.#qa=t;if(this.#Ua=t.getNewOutline(this.#ea/2+1.5,.0025),e>=0)this.#w=e,this.#za=i,this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),this.#Ya=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Ua.box,path:{d:this.#Ua.toSVGPath()}},!0);else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#w,{bbox:tn.#ir(this.#qa.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Ya,{bbox:tn.#ir(this.#Ua.box,e),path:{d:this.#Ua.toSVGPath()}})}const[s,n,a,r]=t.box;switch(this.rotation){case 0:this.x=s,this.y=n,this.width=a,this.height=r;break;case 90:{const[t,e]=this.parentDimensions;this.x=n,this.y=1-s,this.width=a*e/t,this.height=r*t/e;break}case 180:this.x=1-s,this.y=1-n,this.width=a,this.height=r;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-n,this.y=s,this.width=a*e/t,this.height=r*t/e;break}}const{lastPoint:o}=this.#Ua;this.#ma=[(o[0]-s)/a,(o[1]-n)/r]}static initialize(t,e){re.initialize(t,e),tn._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case A.HIGHLIGHT_DEFAULT_COLOR:tn._defaultColor=e;break;case A.HIGHLIGHT_THICKNESS:tn._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#ma}updateParams(t,e){switch(t){case A.HIGHLIGHT_COLOR:this.#Fn(e);break;case A.HIGHLIGHT_THICKNESS:this.#sr(e)}}static get defaultPropertiesToUpdate(){return[[A.HIGHLIGHT_DEFAULT_COLOR,tn._defaultColor],[A.HIGHLIGHT_THICKNESS,tn._defaultThickness]]}get propertiesToUpdate(){return[[A.HIGHLIGHT_COLOR,this.color||tn._defaultColor],[A.HIGHLIGHT_THICKNESS,this.#ea||tn._defaultThickness],[A.HIGHLIGHT_FREE,this.#Xa]]}#Fn(t){const e=(t,e)=>{this.color=t,this.#Ka=e,this.parent?.drawLayer.updateProperties(this.#w,{root:{fill:t,"fill-opacity":e}}),this.#n?.updateColor(t)},i=this.color,s=this.#Ka;this.addCommands({cmd:e.bind(this,t,tn._defaultOpacity),undo:e.bind(this,i,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(t)},!0)}#sr(t){const e=this.#ea,i=t=>{this.#ea=t,this.#nr(t)};this.addCommands({cmd:i.bind(this,t),undo:i.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:A.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 Zs({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.#ar())}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,this.#ar())}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){this.#rr(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#tr(),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?this.#rr():t&&(this.#tr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),this.show(this._isVisible),e&&this.select()}#nr(t){if(!this.#Xa)return;this.#Za({highlightOutlines:this.#qa.getNewOutline(t/2)}),this.fixAndSetPosition();const[e,i]=this.parentDimensions;this.setDims(this.width*e,this.height*i)}#rr(){null!==this.#w&&this.parent&&(this.parent.drawLayer.remove(this.#w),this.#w=null,this.parent.drawLayer.remove(this.#Ya),this.#Ya=null)}#tr(t=this.parent){null===this.#w&&(({id:this.#w,clipPathId:this.#za}=t.drawLayer.draw({bbox:this.#qa.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ka},rootClass:{highlight:!0,free:this.#Xa},path:{d:this.#qa.toSVGPath()}},!1,!0)),this.#Ya=t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Xa},bbox:this.#Ua.box,path:{d:this.#Ua.toSVGPath()}},this.#Xa),this.#Ga&&(this.#Ga.style.clipPath=this.#za))}static#ir([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.#Xa?(t=(t-this.rotation+360)%360,i=tn.#ir(this.#qa.box,t)):i=tn.#ir([this.x,this.y,this.width,this.height],t),e.updateProperties(this.#w,{bbox:i,root:{"data-main-rotation":t}}),e.updateProperties(this.#Ya,{bbox:tn.#ir(this.#Ua.box,t),root:{"data-main-rotation":t}})}render(){if(this.div)return this.div;const t=super.render();this.#Qa&&(t.setAttribute("aria-label",this.#Qa),t.setAttribute("role","mark")),this.#Xa?t.classList.add("free"):this.div.addEventListener("keydown",this.#or.bind(this),{signal:this._uiManager._signal});const e=this.#Ga=document.createElement("div");t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=this.#za;const[i,s]=this.parentDimensions;return this.setDims(this.width*i,this.height*s),Qt(this,this.#Ga,["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!1}})}#or(t){tn._keyboardManager.exec(this,t)}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:this.#lr(!0);break;case 1:case 3:this.#lr(!1)}}#lr(t){if(!this.#ja)return;const e=window.getSelection();t?e.setPosition(this.#ja,this.#Ha):e.setPosition(this.#$a,this.#Wa)}select(){super.select(),this.#Ya&&this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Ya&&(this.parent?.drawLayer.updateProperties(this.#Ya,{rootClass:{selected:!1}}),this.#Xa||this.#lr(!1))}get _mustFixPosition(){return!this.#Xa}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(this.#w,{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(this.#Ya,{rootClass:{hidden:!t}}))}#ar(){return this.#Xa?this.rotation:0}#hr(){if(this.#Xa)return null;const[t,e]=this.pageDimensions,[i,s]=this.pageTranslation,n=this.#Va,a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:d}of n){const n=o*t+i,c=(1-l)*e+s;a[r]=a[r+4]=n,a[r+1]=a[r+3]=c,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=c-d*e,r+=8}return a}#dr(t){return this.#qa.serialize(t,this.#ar())}static startHighlighting(t,e,{target:i,x:s,y:n}){const{x:a,y:r,width:o,height:l}=i.getBoundingClientRect(),h=new AbortController,d=t.combinedSignal(h),c=e=>{h.abort(),this.#cr(t,e)};window.addEventListener("blur",c,{signal:d}),window.addEventListener("pointerup",c,{signal:d}),window.addEventListener("pointerdown",Vt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Ht,{signal:d}),i.addEventListener("pointermove",this.#ur.bind(this,t),{signal:d}),this._freeHighlight=new Qs({x:s,y:n},[a,r,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#ur(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#cr(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 Os){const{data:{quadPoints:e,rect:i,rotation:n,id:a,color:r,opacity:o,popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(r),opacity:o,quadPoints:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}else if(t instanceof Fs){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,borderStyle:{rawWidth:o},popupRef:l},parent:{page:{pageNumber:h}}}=t;s=t={annotationType:y.HIGHLIGHT,color:Array.from(r),thickness:o,inkLists:e,boxes:null,pageIndex:h-1,rect:i.slice(0),rotation:n,id:a,deleted:!1,popupRef:l}}const{color:n,quadPoints:a,inkLists:r,opacity:o}=t,l=await super.deserialize(t,e,i);l.color=St.makeHexColor(...n),l.#Ka=o||1,r&&(l.#ea=t.thickness),l.annotationElementId=t.id||null,l._initialData=s;const[h,d]=l.pageDimensions,[c,u]=l.pageTranslation;if(a){const t=l.#Va=[];for(let e=0;e<a.length;e+=8)t.push({x:(a[e]-c)/h,y:1-(a[e+1]-u)/d,width:(a[e+2]-a[e])/h,height:(a[e+1]-a[e+5])/d});l.#er(),l.#tr(),l.rotate(l.rotation)}else if(r){l.#Xa=!0;const t=r[0],i={x:t[0]-c,y:d-(t[1]-u)},s=new Qs(i,[0,0,h,d],1,l.#ea/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:a}=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.#Za({highlightOutlines:s.getOutlines(),highlightId:n,clipPathId:a}),l.#tr()}return l}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),i=re._colorManager.convert(this.color),s={annotationType:y.HIGHLIGHT,color:i,opacity:this.#Ka,thickness:this.#ea,quadPoints:this.#hr(),outlines:this.#dr(e),pageIndex:this.pageIndex,rect:e,rotation:this.#ar(),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 en{#pr=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.#pr[t]=e}toSVGProperties(){const t=this.#pr;return this.#pr=Object.create(null),{root:t}}reset(){this.#pr=Object.create(null)}updateAll(t=this){this.updateProperties(t)}clone(){ot("Not implemented")}}class sn extends re{#gr=null;#fr;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#mr=null;static#br=null;static#vr=null;static#wr=NaN;static#yr=null;static#Ar=null;static#_r=NaN;static _INNER_MARGIN=3;constructor(t){super(t),this.#fr=t.mustBeCommitted||!1,t.drawOutlines&&(this.#xr(t),this.#tr())}#xr({drawOutlines:t,drawId:e,drawingOptions:i}){this.#gr=t,this._drawingOptions||=i,e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=this.#Sr(t,this.parent),this.#Cr(t.box)}#Sr(t,e){const{id:i}=e.drawLayer.draw(sn._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){ot("Not implemented")}static get typesMap(){ot("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&&(sn.#mr.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],a=t=>{s.updateProperty(e,t);const i=this.#gr.updateProperty(e,t);i&&this.#Cr(i),this.parent?.drawLayer.updateProperties(this._drawId,s.toSVGProperties())};this.addCommands({cmd:a.bind(this,i),undo:a.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,sn._mergeSVGProperties(this.#gr.getPathResizingSVGProperties(this.#Er()),{bbox:this.#Pr()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#gr.getPathResizedSVGProperties(this.#Er()),{bbox:this.#Pr()}))}_onTranslating(t,e){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#Pr(t,e)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties(this.#gr.getPathTranslatedSVGProperties(this.#Er(),this.parentDimensions),{bbox:this.#Pr()}))}_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.#fr&&(this.#fr=!1,this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){this.#rr(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#tr(),this.#Cr(this.#gr.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){let e=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),this.#rr()):t&&(this._uiManager.addShouldRescale(this),this.#tr(t),e=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(t),e&&this.select()}#rr(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#tr(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Sr(this.#gr,t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))}#Mr([t,e,i,s]){const{parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[e,1-t,i*(a/n),s*(n/a)];case 180:return[1-t,1-e,i,s];case 270:return[1-e,t,i*(a/n),s*(n/a)];default:return[t,e,i,s]}}#Er(){const{x:t,y:e,width:i,height:s,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,i*(n/a),s*(a/n)];case 180:return[1-t,1-e,i,s];case 270:return[e,1-t,i*(n/a),s*(a/n)];default:return[t,e,i,s]}}#Cr(t){if([this.x,this.y,this.width,this.height]=this.#Mr(t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()}#Pr(){const{x:t,y:e,width:i,height:s,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/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*(r/o),s*(o/r),i*(r/o)];case 5:return[1-e,t,i*(r/o),s*(o/r)];case 6:return[1-t-s*(o/r),1-e,s*(o/r),i*(r/o)];case 7:return[e-i*(r/o),1-t-s*(o/r),i*(r/o),s*(o/r)];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/r),e,s*(o/r),i*(r/o)];case 13:return[1-e-i*(r/o),t-s*(o/r),i*(r/o),s*(o/r)];case 14:return[1-t,1-e-i*(r/o),s*(o/r),i*(r/o)];case 15:return[e,1-t,i*(r/o),s*(o/r)];default:return[t,e,i,s]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,sn._mergeSVGProperties({bbox:this.#Pr()},this.#gr.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cr(this.#gr.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){ot("Not implemented")}static startDrawing(t,e,i,s){const{target:n,offsetX:a,offsetY:r,pointerId:o,pointerType:l}=s;if(sn.#yr&&sn.#yr!==l)return;const{viewport:{rotation:h}}=t,{width:d,height:c}=n.getBoundingClientRect(),u=sn.#br=new AbortController,p=t.combinedSignal(u);sn.#wr||=o,sn.#yr??=l,window.addEventListener("pointerup",(t=>{sn.#wr===t.pointerId?this._endDraw(t):sn.#Ar?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointercancel",(t=>{sn.#wr===t.pointerId?this._currentParent.endDrawingSession():sn.#Ar?.delete(t.pointerId)}),{signal:p}),window.addEventListener("pointerdown",(t=>{sn.#yr===t.pointerType&&((sn.#Ar||=new Set).add(t.pointerId),sn.#mr.isCancellable()&&(sn.#mr.removeLastElement(),sn.#mr.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Ht,{signal:p}),n.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),n.addEventListener("touchmove",(t=>{t.timeStamp===sn.#_r&&Vt(t)}),{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),sn.#mr?t.drawLayer.updateProperties(this._currentDrawId,sn.#mr.startNew(a,r,d,c,h)):(e.updateUIForDefaultProperties(this),sn.#mr=this.createDrawerInstance(a,r,d,c,h),sn.#vr=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(sn.#vr.toSVGProperties(),sn.#mr.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(sn.#_r=-1,!sn.#mr)return;const{offsetX:e,offsetY:i,pointerId:s}=t;sn.#wr===s&&(sn.#Ar?.size>=1?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,sn.#mr.add(e,i)),sn.#_r=t.timeStamp,Vt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,sn.#mr=null,sn.#vr=null,sn.#yr=null,sn.#_r=NaN),sn.#br&&(sn.#br.abort(),sn.#br=null,sn.#wr=NaN,sn.#Ar=null)}static _endDraw(t){const e=this._currentParent;if(e)if(e.toggleDrawing(!0),this._cleanup(!1),t&&e.drawLayer.updateProperties(this._currentDrawId,sn.#mr.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=sn.#mr,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:A.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(A.DRAW_STEP),!sn.#mr.isEmpty()){const{pageDimensions:[i,s],scale:n}=e,a=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:sn.#mr.getOutlines(i*n,s*n,n,this._INNER_MARGIN),drawingOptions:sn.#vr,mustBeCommitted:!t});return this._cleanup(!0),a}return e.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,i,s,n,a){ot("Not implemented")}static async deserialize(t,e,i){const{rawDims:{pageWidth:s,pageHeight:n,pageX:a,pageY:r}}=e.viewport,o=this.deserializeDraw(a,r,s,n,this._INNER_MARGIN,t),l=await super.deserialize(t,e,i);return l.createDrawingOptions(t),l.#xr({drawOutlines:o}),l.#tr(),l.onScaleChanging(),l.rotate(),l}serializeDraw(t){const[e,i]=this.pageTranslation,[s,n]=this.pageDimensions;return this.#gr.serialize([e,i,s,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class nn{#Kn=new Float64Array(6);#bn;#Tr;#Ri;#ea;#ia;#kr="";#Ir=0;#Sa=new an;#Lr;#Dr;constructor(t,e,i,s,n,a){this.#Lr=i,this.#Dr=s,this.#Ri=n,this.#ea=a,[t,e]=this.#Rr(t,e);const r=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ia=[t,e],this.#Tr=[{line:r,points:this.#ia}],this.#Kn.set(r,0)}updateProperty(t,e){"stroke-width"===t&&(this.#ea=e)}#Rr(t,e){return Gs._normalizePoint(t,e,this.#Lr,this.#Dr,this.#Ri)}isEmpty(){return!this.#Tr||0===this.#Tr.length}isCancellable(){return this.#ia.length<=10}add(t,e){[t,e]=this.#Rr(t,e);const[i,s,n,a]=this.#Kn.subarray(2,6),r=t-n,o=e-a;return Math.hypot(this.#Lr*r,this.#Dr*o)<=2?null:(this.#ia.push(t,e),isNaN(i)?(this.#Kn.set([n,a,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,a,t,e],0),this.#bn.push(...Gs.createBezierPoints(i,s,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(2===this.#ia.length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,s,n){this.#Lr=i,this.#Dr=s,this.#Ri=n,[t,e]=this.#Rr(t,e);const a=this.#bn=[NaN,NaN,NaN,NaN,t,e];this.#ia=[t,e];const r=this.#Tr.at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),this.#Tr.push({line:a,points:this.#ia}),this.#Kn.set(a,0),this.#Ir=0,this.toSVGPath(),null}getLastElement(){return this.#Tr.at(-1)}setLastElement(t){return this.#Tr?(this.#Tr.push(t),this.#bn=t.line,this.#ia=t.points,this.#Ir=0,{path:{d:this.toSVGPath()}}):this.#Sa.setLastElement(t)}removeLastElement(){if(!this.#Tr)return this.#Sa.removeLastElement();this.#Tr.pop(),this.#kr="";for(let t=0,e=this.#Tr.length;t<e;t++){const{line:e,points:i}=this.#Tr[t];this.#bn=e,this.#ia=i,this.#Ir=0,this.toSVGPath()}return{path:{d:this.#kr}}}toSVGPath(){const t=Gs.svgRound(this.#bn[4]),e=Gs.svgRound(this.#bn[5]);if(2===this.#ia.length)return this.#kr=`${this.#kr} M ${t} ${e} Z`,this.#kr;if(this.#ia.length<=6){const i=this.#kr.lastIndexOf("M");this.#kr=`${this.#kr.slice(0,i)} M ${t} ${e}`,this.#Ir=6}if(4===this.#ia.length){const t=Gs.svgRound(this.#bn[10]),e=Gs.svgRound(this.#bn[11]);return this.#kr=`${this.#kr} L ${t} ${e}`,this.#Ir=12,this.#kr}const i=[];0===this.#Ir&&(i.push(`M ${t} ${e}`),this.#Ir=6);for(let t=this.#Ir,e=this.#bn.length;t<e;t+=6){const[e,s,n,a,r,o]=this.#bn.slice(t,t+6).map(Gs.svgRound);i.push(`C${e} ${s} ${n} ${a} ${r} ${o}`)}return this.#kr+=i.join(" "),this.#Ir=this.#bn.length,this.#kr}getOutlines(t,e,i,s){const n=this.#Tr.at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),this.#Sa.build(this.#Tr,t,e,i,this.#Ri,this.#ea,s),this.#Kn=null,this.#bn=null,this.#Tr=null,this.#kr=null,this.#Sa}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class an extends Gs{#pa;#Nr=0;#Gn;#Tr;#Lr;#Dr;#Fr;#Ri;#ea;build(t,e,i,s,n,a,r){this.#Lr=e,this.#Dr=i,this.#Fr=s,this.#Ri=n,this.#ea=a,this.#Gn=r??0,this.#Tr=t,this.#Or()}setLastElement(t){return this.#Tr.push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#Tr.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of this.#Tr)if(t.push(`M${Gs.svgRound(e[4])} ${Gs.svgRound(e[5])}`),6!==e.length)if(12!==e.length)for(let i=6,s=e.length;i<s;i+=6){const[s,n,a,r,o,l]=e.subarray(i,i+6).map(Gs.svgRound);t.push(`C${s} ${n} ${a} ${r} ${o} ${l}`)}else t.push(`L${Gs.svgRound(e[10])} ${Gs.svgRound(e[11])}`);else t.push("Z");return t.join("")}serialize([t,e,i,s],n){const a=[],r=[],[o,l,h,d]=this.#Br();let c,u,p,g,f,m,b,v,w;switch(this.#Ri){case 0:w=Gs._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=Gs._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=Gs._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=Gs._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.#Tr)a.push(w(t,c,u,p,g,n?new Array(t.length):null)),r.push(w(e,c,u,p,g,n?new Array(e.length):null));return{lines:a,points:r,rect:[f,m,b,v]}}static deserialize(t,e,i,s,n,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let d,c,u,p,g;switch(o){case 0:g=Gs._rescale,d=-t/i,c=e/s+1,u=1/i,p=-1/s;break;case 90:g=Gs._rescaleAndSwap,d=-e/s,c=-t/i,u=1/s,p=1/i;break;case 180:g=Gs._rescale,d=t/i+1,c=-e/s,u=-1/i,p=1/s;break;case 270:g=Gs._rescaleAndSwap,d=e/s+1,c=t/i+1,u=-1/s,p=-1/i}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.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));a.push(i);let[s,n,r,o]=t.subarray(0,4);i.set([NaN,NaN,NaN,NaN,s,n],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];i.set(Gs.createBezierPoints(s,n,r,o,e,l),3*(a-2)),[s,n,r,o]=[r,o,e,l]}}}for(let t=0,e=a.length;t<e;t++)h.push({line:g(a[t].map((t=>t??NaN)),d,c,u,p),points:g(r[t].map((t=>t??NaN)),d,c,u,p)});const f=new an;return f.build(h,i,s,1,o,l,n),f}#jr(t=this.#ea){const e=this.#Gn+t/2*this.#Fr;return this.#Ri%180==0?[e/this.#Lr,e/this.#Dr]:[e/this.#Dr,e/this.#Lr]}#Br(){const[t,e,i,s]=this.#pa,[n,a]=this.#jr(0);return[t+n,e+a,i-2*n,s-2*a]}#Or(){const t=this.#pa=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:e}of this.#Tr){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,a=e.length;n<a;n+=6){const[a,r,o,l,h,d]=e.subarray(n,n+6);St.bezierBoundingBox(i,s,a,r,o,l,h,d,t),i=h,s=d}}const[e,i]=this.#jr();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.#pa}updateProperty(t,e){return"stroke-width"===t?this.#sr(e):null}#sr(t){const[e,i]=this.#jr();this.#ea=t;const[s,n]=this.#jr(),[a,r]=[s-e,n-i],o=this.#pa;return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o}updateParentDimensions([t,e],i){const[s,n]=this.#jr();this.#Lr=t,this.#Dr=e,this.#Fr=i;const[a,r]=this.#jr(),o=a-s,l=r-n,h=this.#pa;return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return this.#Nr=t,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#pa.map(Gs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#pa;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=this.#pa;let i=0,s=0,n=0,a=0,r=0,o=0;switch(this.#Nr){case 90:s=e/t,n=-t/e,r=t;break;case 180:i=-1,a=-1,r=t,o=e;break;case 270:s=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${i} ${s} ${n} ${a} ${Gs.svgRound(r)} ${Gs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,s]){const[n,a]=this.#jr(),[r,o,l,h]=this.#pa;if(Math.abs(l-n)<=Gs.PRECISION||Math.abs(h-a)<=Gs.PRECISION){const n=t+i/2-(r+l/2),a=e+s/2-(o+h/2);return{path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${a})`}}}const d=(i-2*n)/(l-2*n),c=(s-2*a)/(h-2*a),u=l/i,p=h/s;return{path:{"transform-origin":`${Gs.svgRound(r)} ${Gs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Gs.svgRound(n)} ${Gs.svgRound(a)}) scale(${d} ${c}) translate(${Gs.svgRound(-n)} ${Gs.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,i,s]){const[n,a]=this.#jr(),r=this.#pa,[o,l,h,d]=r;if(r[0]=t,r[1]=e,r[2]=i,r[3]=s,Math.abs(h-n)<=Gs.PRECISION||Math.abs(d-a)<=Gs.PRECISION){const n=t+i/2-(o+h/2),a=e+s/2-(l+d/2);for(const{line:t,points:e}of this.#Tr)Gs._translate(t,n,a,t),Gs._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const c=(i-2*n)/(h-2*n),u=(s-2*a)/(d-2*a),p=-c*(o+n)+t+n,g=-u*(l+a)+e+a;if(1!==c||1!==u||0!==p||0!==g)for(const{line:t,points:e}of this.#Tr)Gs._rescale(t,p,g,c,u,t),Gs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],i){const[s,n]=i,a=this.#pa,r=t-a[0],o=e-a[1];if(this.#Lr===s&&this.#Dr===n)for(const{line:t,points:e}of this.#Tr)Gs._translate(t,r,o,t),Gs._translate(e,r,o,e);else{const t=this.#Lr/s,e=this.#Dr/n;this.#Lr=s,this.#Dr=n;for(const{line:i,points:s}of this.#Tr)Gs._rescale(i,r,o,t,e,i),Gs._rescale(s,r,o,t,e,s);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Gs.svgRound(t)} ${Gs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#pa;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Gs.svgRound(t[0])} ${Gs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class rn extends en{#Hr;constructor(t){super(),this.#Hr=t,super.updateProperties({fill:"none",stroke:re._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.#Hr.realScale),super.updateSVGProperty(t,e)}clone(){const t=new rn(this.#Hr);return t.updateAll(this),t}}class on extends sn{static _type="ink";static _editorType=y.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(t,e){re.initialize(t,e),this._defaultDrawingOptions=new rn(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return dt(this,"typesMap",new Map([[A.INK_THICKNESS,"stroke-width"],[A.INK_COLOR,"stroke"],[A.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,s,n){return new nn(t,e,i,s,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,s,n,a){return an.deserialize(t,e,i,s,n,a)}static async deserialize(t,e,i){let s=null;if(t instanceof Fs){const{data:{inkLists:e,rect:i,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h},parent:{page:{pageNumber:d}}}=t;s=t={annotationType:y.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:i.slice(0),rotation:n,id:a,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=on.getDefaultDrawingOptions({stroke:St.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":a,"stroke-width":r}}=this,o={annotationType:y.INK,color:re._colorManager.convert(n),opacity:a,thickness:r,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 ln extends re{#Vr=null;#zr=null;#Ur=null;#$r=null;#Wr=null;#Gr="";#qr=null;#Xr=null;#Kr=!1;#Yr=!1;static _type="stamp";static _editorType=y.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#$r=t.bitmapUrl,this.#Wr=t.bitmapFile}static initialize(t,e){re.initialize(t,e)}static get supportedTypes(){return dt(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((t=>`image/${t}`)))}static get supportedTypesStr(){return dt(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(t){return this.supportedTypes.includes(t)}static paste(t,e){e.pasteEditor(y.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}}#Qr(t,e=!1){t?(this.#Vr=t.bitmap,e||(this.#zr=t.id,this.#Kr=t.isSvg),t.file&&(this.#Gr=t.file.name),this.#Jr()):this.remove()}#Zr(){if(this.#Ur=null,this._uiManager.enableWaiting(!1),this.#qr){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Vr)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Vr){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:a}=t||this.copyCanvas(null,null,!0).imageData,r=await i.guess({name:"altText",request:{data:s,width:n,height:a,channels:s.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}#to(){if(this.#zr)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#zr).then((t=>this.#Qr(t,!0))).finally((()=>this.#Zr()));if(this.#$r){const t=this.#$r;return this.#$r=null,this._uiManager.enableWaiting(!0),void(this.#Ur=this._uiManager.imageManager.getFromUrl(t).then((t=>this.#Qr(t))).finally((()=>this.#Zr())))}if(this.#Wr){const t=this.#Wr;return this.#Wr=null,this._uiManager.enableWaiting(!0),void(this.#Ur=this._uiManager.imageManager.getFromFile(t).then((t=>this.#Qr(t))).finally((()=>this.#Zr())))}const t=document.createElement("input");t.type="file",t.accept=ln.supportedTypesStr;const e=this._uiManager._signal;this.#Ur=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.#Qr(e)}else this.remove();i()}),{signal:e}),t.addEventListener("cancel",(()=>{this.remove(),i()}),{signal:e})})).finally((()=>this.#Zr())),t.click()}remove(){this.#zr&&(this.#Vr=null,this._uiManager.imageManager.deleteId(this.#zr),this.#qr?.remove(),this.#qr=null,this.#Xr&&(clearTimeout(this.#Xr),this.#Xr=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#zr&&null===this.#qr&&this.#to(),this.isAttachedToDOM||this.parent.add(this))):this.#zr&&this.#to()}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(this.#Ur||this.#Vr||this.#$r||this.#Wr||this.#zr)}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.#Vr?this.#Jr():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.#Xr&&clearTimeout(this.#Xr);this.#Xr=setTimeout((()=>{this.#Xr=null,this.#eo()}),200)}#Jr(){const{div:t}=this;let{width:e,height:i}=this.#Vr;const[s,n]=this.pageDimensions,a=.75;if(this.width)e=this.width*s,i=this.height*n;else if(e>a*s||i>a*n){const t=Math.min(a*s/e,a*n/i);e*=t,i*=t}const[r,o]=this.parentDimensions;this.setDims(e*r/s,i*o/n),this._uiManager.enableWaiting(!1);const l=this.#qr=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.#Yr||(this.parent.addUndoableEditor(this),this.#Yr=!0),this._reportTelemetry({action:"inserted_image"}),this.#Gr&&l.setAttribute("aria-label",this.#Gr)}copyCanvas(t,e,i=!1){t||(t=224);const{width:s,height:n}=this.#Vr,a=new Xt;let r=this.#Vr,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*a.sx),i=h.height=Math.ceil(l*a.sy);this.#Kr||(r=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*a.sx,f=p*a.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(r,0,0,r.width,r.height,0,0,t,i)}let d=null;if(i){let e,i;if(a.symmetric&&r.width<t&&r.height<t)e=r.width,i=r.height;else if(r=this.#Vr,s>t||n>t){const a=Math.min(t/s,t/n);e=Math.floor(s*a),i=Math.floor(n*a),this.#Kr||(r=this.#io(e,i))}const o=new OffscreenCanvas(e,i).getContext("2d",{willReadFrequently:!0});o.drawImage(r,0,0,r.width,r.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.#Vr;let n=i,a=s,r=this.#Vr;for(;n>2*t||a>2*e;){const i=n,s=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,i,s,0,0,n,a),r=o.transferToImageBitmap()}return r}#eo(){const[t,e]=this.parentDimensions,{width:i,height:s}=this,n=new Xt,a=Math.ceil(i*t*n.sx),r=Math.ceil(s*e*n.sy),o=this.#qr;if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=this.#Kr?this.#Vr:this.#io(a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)}getImageForAltText(){return this.#qr}#so(t){if(t){if(this.#Kr){const t=this._uiManager.imageManager.getSvgUrl(this.#zr);if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=this.#Vr);return t.getContext("2d").drawImage(this.#Vr,0,0),t.toDataURL()}if(this.#Kr){const[t,e]=this.pageDimensions,i=Math.round(this.width*t*kt.PDF_TO_CSS_UNITS),s=Math.round(this.height*e*kt.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(i,s);return n.getContext("2d").drawImage(this.#Vr,0,0,this.#Vr.width,this.#Vr.height,0,0,i,s),n.transferToImageBitmap()}return structuredClone(this.#Vr)}static async deserialize(t,e,i){let s=null;if(t instanceof Vs){const{data:{rect:n,rotation:a,id:r,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(`${Mt}${r}`))?.get("aria-label")||"";s=t={annotationType:y.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:d-1,rect:n.slice(0),rotation:a,id:r,deleted:!1,accessibilityData:{decorative:!1,altText:p},isSvg:!1,structParent:o,popupRef:l}}const n=await super.deserialize(t,e,i),{rect:a,bitmap:r,bitmapUrl:o,bitmapId:l,isSvg:h,accessibilityData:d}=t;l&&i.imageManager.isValidId(l)?(n.#zr=l,r&&(n.#Vr=r)):n.#$r=o,n.#Kr=h;const[c,u]=n.pageDimensions;return n.width=(a[2]-a[0])/c,n.height=(a[3]-a[1])/u,n.annotationElementId=t.id||null,d&&(n.altTextData=d),n._initialData=s,n.#Yr=!!s,n}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:y.STAMP,bitmapId:this.#zr,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kr,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 a=this.#Kr?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(e.stamps.has(this.#zr)){if(this.#Kr){const t=e.stamps.get(this.#zr);a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=this.#so(!1))}}else e.stamps.set(this.#zr,{area:a,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 hn=class t{#En;#no=!1;#ao=null;#ro=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#V=new Map([Ws,on,ln,tn].map((t=>[t._editorType,t])));constructor({uiManager:e,pageIndex:i,div:s,structTreeLayer:n,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:l,viewport:h,l10n:d}){const c=[...t.#V.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=a,this.#ao=r,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()===y.NONE}updateToolbar(t){this.#f.updateToolbar(t)}updateMode(e=this.#f.getMode()){switch(this.#mo(),e){case y.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case y.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case y.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.#V.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.#ao?.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.#ao)return void(this.#co=!1);const e=this.#ao.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.#ao){const t=this.#ao.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.#V.values())s.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#do=!1}getEditableAnnotation(t){return this.#ao?.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}=_t.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#f.showAllEditors("highlight",!0,!0),this.#go.div.classList.add("free"),this.toggleDrawing(),tn.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.#ro)return;this.#ro=new AbortController;const t=this.#f.combinedSignal(this.#ro);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.#ro?.abort(),this.#ro=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),re.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.#V.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(),a=this.#wo({parent:this,id:n,x:i,y:s,uiManager:this.#f,isCentered:!0,...e});a&&this.add(a)}async deserialize(e){return await(t.#V.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),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+i))/2-t,o=(a+Math.min(window.innerHeight,e+s))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];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}=_t.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()!==y.STAMP?this.createAndAddNewEditor(t,!1):this.#f.unselectAll():this.#no=!0))}pointerdown(t){if(this.#f.getMode()===y.HIGHLIGHT&&this.enableTextSelection(),this.#ho)return void(this.#ho=!1);const{isMac:e}=_t.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,qt(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,qt(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}},dn=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 dt(this,"_svgFactory",new cs)}static#xo(t,[e,i,s,n]){const{style:a}=t;a.top=100*i+"%",a.left=100*e+"%",a.width=100*s+"%",a.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 a=t._svgFactory.createElement("use");return s.append(a),a.setAttribute("href",`#${i}`),a.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++,a=this.#So(),r=t._svgFactory.createElement("defs");a.append(r);const o=t._svgFactory.createElement("path");r.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(r,l):null,d=t._svgFactory.createElement("use");return a.append(d),d.setAttribute("href",`#${l}`),this.updateProperties(a,e),this.#Ao.set(n,a),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,i){const s=this.#w++,n=this.#So(),a=t._svgFactory.createElement("defs");n.append(a);const r=t._svgFactory.createElement("path");a.append(r);const o=`path_p${this.pageIndex}_${s}`;let l;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),i){const e=t._svgFactory.createElement("mask");a.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:a,path:r}=i,o="number"==typeof e?this.#Ao.get(e):e;if(o){if(s&&this.#Eo(o,s),n&&t.#xo(o,n),a){const{classList:t}=o;for(const[e,i]of Object.entries(a))t.toggle(e,i)}if(r){const t=o.firstChild.firstChild;this.#Eo(t,r)}}}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:Ks};var cn=r.AnnotationEditorParamsType,un=r.AnnotationEditorType,pn=r.AnnotationMode,gn=r.GlobalWorkerOptions,fn=r.PDFDateString,mn=r.PixelsPerInch,bn=r.RenderingCancelledException,vn=r.getDocument,wn=r.getPdfFilenameFromUrl,yn=r.getXfaPageViewport,An={d:(t,e)=>{for(var i in e)An.o(e,i)&&!An.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},_n=globalThis.pdfjsViewer={};An.d(_n,{AnnotationLayerBuilder:()=>dr,DownloadManager:()=>ur,EventBus:()=>fr,FindState:()=>ea,GenericL10n:()=>Io,LinkTarget:()=>ma,PDFFindController:()=>fa,PDFHistory:()=>Do,PDFLinkService:()=>ba,PDFPageView:()=>el,PDFScriptingManager:()=>nl,PDFSinglePageViewer:()=>ul,PDFViewer:()=>cl,ProgressBar:()=>Un,RenderingStates:()=>xn,ScrollMode:()=>In,SimpleLinkService:()=>va,SpreadMode:()=>Ln,StructTreeLayerBuilder:()=>Xo,TextLayerBuilder:()=>Qo,XfaLayerBuilder:()=>Jo,parseQueryString:()=>Rn});const xn={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Sn=0,Cn=1,En=2,Pn=3,Mn=0,Tn=1,kn=2,In={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Ln={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Dn(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,a=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,a+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(a+=e.left,s.scrollLeft=a)),s.scrollTop=n}function Rn(t){const e=new Map;for(const[i,s]of new URLSearchParams(t))e.set(i.toLowerCase(),s);return e}const Nn=/[\x00-\x1F]/g;function Fn(t,e=!1){return Nn.test(t)?e?t.replaceAll(Nn,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t}function On(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 Bn(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,a=1,r=1,o=1;for(;;){const t=n+r,e=a+o;if(e>8)break;i<=t/e?(r=t,o=e):(n=t,a=e)}return s=i-n/a<r/o-i?i===t?[n,a]:[a,n]:i===t?[r,o]:[o,r],s}function jn(t,e){return t-t%e}function Hn(t){return Number.isInteger(t)&&t%90==0}function Vn(t){return t.width<=t.height}new Promise((function(t){window.requestAnimationFrame(t)}));const zn=document.documentElement.style;let Un=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 $n=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}(),Wn=0,Gn=1,qn=2,Xn=3,Kn=4,Yn=5,Qn=6,Jn=7;function Zn(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)?Wn:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?Gn:qn:function(t){return 3584==(65408&t)}(t)?Jn:160===t?Wn:Gn:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?Xn:function(t){return t>=12448&&t<=12543}(t)?Kn:function(t){return t>=12352&&t<=12447}(t)?Yn:function(t){return t>=65376&&t<=65439}(t)?Qn:Gn}let ta;const ea={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},ia={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},sa=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 aa=/\p{M}+/gu,ra=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,oa=/([^\p{M}])\p{M}*$/u,la=/^\p{M}*([^\p{M}])/u,ha=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,da=new Map,ca=new Map;let ua=null,pa=null;function ga(t){const e=[];let i,s;for(;null!==(i=ha.exec(t));){let{index:t}=i;for(const s of i[0]){let i=da.get(s);i||(i=s.normalize("NFD").length,da.set(s,i)),e.push([i,t++])}}if(0===e.length&&ua)s=ua;else if(e.length>0&&pa)s=pa;else{const t=`([${Object.keys(ia).join("")}])|([${ta||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",ta}])|(${"(?:゙|゚)"}\\n)|(\\p{M}+(?:-\\n)?)|(${"\\p{Ll}-\\n\\p{Lu}"})|(\\S-\\n)|(${"(?:\\p{Ideographic}|[぀-ヿ])"}\\n)|(\\n)`;s=0===e.length?ua=new RegExp(t+"|(\\u0000)","gum"):pa=new RegExp(t+"|([\\u1100-\\u1112\\ud7a4-\\ud7af\\ud84a\\ud84c\\ud850\\ud854\\ud857\\ud85f])","gum")}const n=[];for(;null!==(i=aa.exec(t));)n.push([i[0].length,i.index]);let a=t.normalize("NFD");const r=[0,0];let o=0,l=0,h=0,d=0,c=0,u=!1;a=a.replace(s,((t,i,s,a,p,g,f,m,b,v,w)=>{if(w-=d,i){const t=ia[i],e=t.length;for(let t=1;t<e;t++)r.push(w-h+t,h-t);return h-=e-1,t}if(s){let t=ca.get(s);t||(t=s.normalize("NFKC"),ca.set(s,t));const e=t.length;for(let t=1;t<e;t++)r.push(w-h+t,h-t);return h-=e-1,t}if(a)return u=!0,w+c===n[o]?.[1]?++o:(r.push(w-1-h+1,h-1),h-=1,d+=1),r.push(w-h+1,h),d+=1,c+=1,a.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++)r.push(w-1-h+t,h-t);return h-=i,d+=i,t?(w+=e-1,r.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 r.push(w-h+t,1+h),h+=1,d+=1,c+=1,f.slice(0,-2)}if(m){const t=m.length-1;return r.push(w-h+t,h),d+=1,c+=1,m.slice(0,-1)}if(b)return r.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++)r.push(w-(h-e),h-e);h-=t,d+=t}return v})),r.push(a.length,h);const p=new Uint32Array(r.length>>1),g=new Int32Array(r.length>>1);for(let t=0,e=r.length;t<e;t+=2)p[t>>1]=r[t],g[t>>1]=r[t+1];return[a,[p,g],u]}class fa{#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(ea.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.#Ho()):"highlightallchange"===i?(s?this.#jo():this._highlightMatches=!0,this.#Ho()):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;Dn(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#Vo(){const{query:t}=this.#Io;return"string"==typeof t?(t!==this._rawQuery&&(this._rawQuery=t,[this._normalizedQuery]=ga(t)),this._normalizedQuery):(t||[]).filter((t=>!!t)).map((t=>ga(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(oa);if(s){const i=t.charCodeAt(e),n=s[1].charCodeAt(0);if(Zn(i)===Zn(n))return!1}if(s=t.slice(e+i).match(la),s){const n=t.charCodeAt(e+i-1),a=s[1].charCodeAt(0);if(Zn(n)===Zn(a))return!1}return!0}#Uo(t,e){const{matchDiacritics:i}=this.#Io;let s=!1;const n="[ ]*";return(t=t.replaceAll(ra,((t,n,a,r,o,l)=>n?`[ ]*\\${n}[ ]*`:a?`[ ]*${a}[ ]*`:r?"[ ]+":i?o||l:o?sa.has(o.charCodeAt(0))?o:"":e?(s=!0,`${l}\\p{M}*`):l))).endsWith(n)&&(t=t.slice(0,t.length-4)),i&&e&&(na||=String.fromCharCode(...sa),s=!0,t=`${t}(?=[${na}]|[^\\p{M}]|$)`),[s,t]}#$o(t){const e=this.#Vo;if(0===e.length)return;const i=this._pageContents[t],s=this.match(e,i,t),n=this._pageMatches[t]=[],a=this._pageMatchesLength[t]=[],r=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,a=e,r=e+i-1;let o=On(s,(t=>t>=a));s[o]>a&&--o;let l=On(s,(t=>t>=r),o);s[l]>r&&--l;const h=a+n[o];return[h,r+n[l]+1-h]}(r,t,e);s&&(n.push(i),a.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:a,entireWord:r}=this.#Io;t=new RegExp(t,`g${n?"u":""}${a?"":"i"}`);const o=[];let l;for(;null!==(l=t.exec(e));)r&&!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]]=ga(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})}#Ho(){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.#Ho();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.#Vo.length)return void this.#Bo(ea.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=ea.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?ea.WRAPPED:ea.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(ea.FOUND),this._highlightMatches=!1,this.#Ho())}))}#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!==ea.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 ma={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class ba{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?ma.BLANK:this.externalLinkTarget,n=this.externalLinkRel;this.externalLinkEnabled?t.href=t.title=e:(t.href="",t.title=`Disabled: ${e}`,t.onclick=()=>!1);let a="";switch(s){case ma.NONE:break;case ma.SELF:a="_self";break;case ma.BLANK:a="_blank";break;case ma.PARENT:a="_parent";break;case ma.TOP:a="_top"}t.target=a,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=Rn(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||ba.#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 a=!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;a=!1;break;default:return!1}for(const t of s)if(!("number"==typeof t||a&&null===t))return!1;return!0}}class va extends ba{setDocument(t,e=null){}}const{AbortException:wa,AnnotationEditorLayer:ya,AnnotationEditorParamsType:Aa,AnnotationEditorType:_a,AnnotationEditorUIManager:xa,AnnotationLayer:Sa,AnnotationMode:Ca,build:Ea,ColorPicker:Pa,createValidAbsoluteUrl:Ma,DOMSVGFactory:Ta,DrawLayer:ka,FeatureTest:Ia,fetchData:La,getDocument:Da,getFilenameFromUrl:Ra,getPdfFilenameFromUrl:Na,getXfaPageViewport:Fa,GlobalWorkerOptions:Oa,ImageKind:Ba,InvalidPDFException:ja,isDataScheme:Ha,isPdfFile:Va,MissingPDFException:za,noContextMenu:Ua,normalizeUnicode:$a,OPS:Wa,OutputScale:Ga,PasswordResponses:qa,PDFDataRangeTransport:Xa,PDFDateString:Ka,PDFWorker:Ya,PermissionFlag:Qa,PixelsPerInch:Ja,RenderingCancelledException:Za,setLayerDimensions:tr,shadow:er,stopEvent:ir,TextLayer:sr,TouchManager:nr,UnexpectedResponseException:ar,Util:rr,VerbosityLevel:or,version:lr,XfaLayer:hr}=globalThis.pdfjsLib;class dr{#Zo=null;#tl=null;constructor({pdfPage:t,linkService:e,downloadManager:i,annotationStorage:s=null,imageResourcesPath:n="",renderForms:a=!0,enableScripting:r=!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=a,this.annotationStorage=s,this.enableScripting=r,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,a]=await Promise.all([this.pdfPage.getAnnotations({intent:i}),this._hasJSActionsPromise,this._fieldObjectsPromise]);if(this._cancelled)return;const r=this.div=document.createElement("div");r.className="annotationLayer",this.#Zo?.(r),0!==s.length?(this.annotationLayer=new Sa({div:r,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:a}),this.linkService.isInPresentationMode&&this.#el(Pn),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 Pn:e=!0;break;case Cn:break;default:return}for(const t of this.div.childNodes)t.hasAttribute("data-internal-link")||(t.inert=e)}}function cr(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 ur{#il=new WeakMap;downloadData(t,e,i){cr(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const s=Va(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(!Ma(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);s=e+"#pdfjs.action=download"}cr(s,i)}}const pr="event",gr="timeout";class fr{#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:a,once:r}of i.slice(0))r&&this._off(t,n),a?(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 a=()=>this._off(t,e);s=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}(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 mr{constructor(t){this.value=t}valueOf(){return this.value}}class br extends mr{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class vr extends mr{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 wr extends mr{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 yr(t,e,i){if(i===e)return!0;if(i instanceof vr&&e instanceof vr&&i.value===e.value)return!0;if(e instanceof vr&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function Ar(t,e,i){return e[i]?Cr(t,e[i].value):(t.reportError(new RangeError("No default")),new br)}function _r(t,e){const i=[],s=Object.create(null);for(const n of e)"narg"===n.type?s[n.name]=xr(t,n.value):i.push(xr(t,n));return{positional:i,named:s}}function xr(t,e){switch(e.type){case"str":return e.value;case"num":return new vr(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 br(`$${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 br(`$${e}`);i=t.args[e]}if(i instanceof mr)return i;switch(typeof i){case"string":return i;case"number":return new vr(i);case"object":if(i instanceof Date)return new wr(i.getTime());default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new br(`$${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 br(e);if(i){const n=s.attributes[i];return n?Cr(t,n):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new br(`${e}.${i}`))}if(s.value)return Cr(t,s.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new br(e)}(t,e);case"term":return function(t,{name:e,attr:i,args:s}){const n=`-${e}`,a=t.bundle._terms.get(n);if(!a)return t.reportError(new ReferenceError(`Unknown term: ${n}`)),new br(n);if(i){const e=a.attributes[i];if(e){t.params=_r(t,s).named;const i=Cr(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new br(`${n}.${i}`)}t.params=_r(t,s).named;const r=Cr(t,a.value);return t.params=null,r}(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 br(`${e}()`);if("function"!=typeof s)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new br(`${e}()`);try{let e=_r(t,i);return s(e.positional,e.named)}catch(i){return t.reportError(i),new br(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:s}){let n=xr(t,e);if(n instanceof br)return Ar(t,i,s);for(const e of i){if(yr(t,n,xr(t,e.key)))return Cr(t,e.value)}return Ar(t,i,s)}(t,e);default:return new br}}function Sr(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new br;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(xr(t,n).toString(t)),s&&i.push("⁩")}else i.push(t.bundle._transform(n));return t.dirty.delete(e),i.join("")}function Cr(t,e){return"string"==typeof e?t.bundle._transform(e):Sr(t,e)}class Er{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 Pr(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 Mr=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function Tr(t,e){let i=t[0];if(i instanceof br)return new br(`NUMBER(${i.valueOf()})`);if(i instanceof vr)return new vr(i.valueOf(),{...i.opts,...Pr(e,Mr)});if(i instanceof wr)return new vr(i.valueOf(),{...Pr(e,Mr)});throw new TypeError("Invalid argument to NUMBER")}const kr=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function Ir(t,e){let i=t[0];if(i instanceof br)return new br(`DATETIME(${i.valueOf()})`);if(i instanceof wr)return new wr(i.valueOf(),{...i.opts,...Pr(e,kr)});if(i instanceof vr)return new wr(i.valueOf(),{...Pr(e,kr)});throw new TypeError("Invalid argument to DATETIME")}const Lr=new Map;class Dr{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:Tr,DATETIME:Ir,...e},this._useIsolating=i,this._transform=s,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=Lr.get(e);return void 0===i&&(i=new Map,Lr.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 Er(this,i,e);try{return Sr(s,t).toString(s)}catch(t){if(s.errors&&t instanceof Error)return s.errors.push(t),(new br).toString(s);throw t}}}const Rr=/^(-?[a-zA-Z][\w-]*) *= */gm,Nr=/\.([a-zA-Z][\w-]*) *= */y,Fr=/\*?\[/y,Or=/(-?[0-9]+(?:\.([0-9]+))?)/y,Br=/([a-zA-Z][\w-]*)/y,jr=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,Hr=/^[A-Z][A-Z0-9_-]*$/,Vr=/([^{}\n\r]+)/y,zr=/([^\\"\n\r]*)/y,Ur=/\\([\\"])/y,$r=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,Wr=/^\n+/,Gr=/ +$/,qr=/ *\r?\n/g,Xr=/( *)$/,Kr=/{\s*/y,Yr=/\s*}/y,Qr=/\[\s*/y,Jr=/\s*] */y,Zr=/\s*\(\s*/y,to=/\s*->\s*/y,eo=/\s*:\s*/y,io=/\s*,?\s*/y,so=/\s+/y;class no{constructor(t){this.body=[],Rr.lastIndex=0;let e=0;for(;;){let i=Rr.exec(t);if(null===i)break;e=Rr.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 a(i){i.lastIndex=e;let s=i.exec(t);if(null===s)throw new SyntaxError(`Expected ${i.toString()}`);return e=i.lastIndex,s}function r(t){return a(t)[1]}function o(t){let e=l(),s=function(){let t=Object.create(null);for(;i(Nr);){let e=r(Nr),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(Vr)&&(s=r(Vr)),"{"===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,Wr),h([n],n.length)):s?v(s,Gr):null}function h(s=[],n){for(;;){if(i(Vr)){s.push(r(Vr));continue}if("{"===t[e]){s.push(d());continue}if("}"===t[e])throw new SyntaxError("Unbalanced closing brace");let a=b();if(!a)break;s.push(a),n=Math.min(n,a.length)}let a=s.length-1,o=s[a];"string"==typeof o&&(s[a]=v(o,Gr));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(Kr,SyntaxError);let t=c();if(n(Yr))return t;if(n(to)){let e=function(){let t,e=[],n=0;for(;i(Fr);){s("*")&&(t=n);let i=p(),a=l();if(null===a)throw new SyntaxError("Expected variant value");e[n++]={key:i,value:a}}if(0===n)return null;if(void 0===t)throw new SyntaxError("Expected default variant");return{variants:e,star:t}}();return n(Yr,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(jr)){let[,i,s,r=null]=a(jr);if("$"===i)return{type:"var",name:s};if(n(Zr)){let a=function(){let i=[];for(;;){switch(t[e]){case")":return e++,i;case void 0:throw new SyntaxError("Unclosed argument list")}i.push(u()),n(io)}}();if("-"===i)return{type:"term",name:s,attr:r,args:a};if(Hr.test(s))return{type:"func",name:s,args:a};throw new SyntaxError("Function names must be all upper-case")}return"-"===i?{type:"term",name:s,attr:r,args:[]}:{type:"mesg",name:s,attr:r}}return g()}function u(){let t=c();return"mesg"!==t.type?t:n(eo)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return n(Qr,SyntaxError),t=i(Or)?f():{type:"str",value:r(Br)},n(Jr,SyntaxError),t}function g(){if(i(Or))return f();if('"'===t[e])return function(){s('"',SyntaxError);let i="";for(;;){if(i+=r(zr),"\\"!==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=""]=a(Or),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function m(){if(i(Ur))return r(Ur);if(i($r)){let[,t,e]=a($r),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(so),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(qr,"\n"),i=Xr.exec(t)[1].length;return new ao(e,i)}}}class ao{constructor(t,e){this.value=t,this.length=e}}const ro=/<|&#?\w+;/,oo={"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"]},lo={"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 ho(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(ro.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=po(e,i);t.replaceChild(s,i)}else if(mo(i)){const e=go(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(fo(i),i);e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;uo(e,t)}function co(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function uo(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))bo(s.name,e,i)&&!co(t.attributes,s.name)&&e.removeAttribute(s.name);if(t.attributes)for(const s of Array.from(t.attributes))bo(s.name,e,i)&&e.getAttribute(s.name)!==s.value&&e.setAttribute(s.name,s.value)}function po(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.`),fo(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}).`),fo(e);t.removeChild(s);return vo(e,s.cloneNode(!1))}function go(t){const e=t.ownerDocument.createElement(t.localName);return vo(t,e)}function fo(t){return t.ownerDocument.createTextNode(t.textContent)}function mo(t){const e=oo[t.namespaceURI];return e&&e.includes(t.localName)}function bo(t,e,i=null){if(i&&i.includes(t))return!0;const s=lo[e.namespaceURI];if(!s)return!1;const n=t.toLowerCase(),a=e.localName;if(s.global.includes(n))return!0;if(!s[a])return!1;if(s[a].includes(n))return!0;if("http://www.w3.org/1999/xhtml"===e.namespaceURI&&"input"===a&&"value"===n){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t)return!0}return!1}function vo(t,e){return e.textContent=t.textContent,uo(t,e),e}class wo extends Array{static from(t){return t instanceof this?t:new this(t)}}class yo extends wo{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 Ao{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 a=So(e,n,t,i);if(0===a.size)break;if("undefined"!=typeof console){const t=n.locales[0],e=Array.from(a).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,xo)}formatValues(t){return this.formatWithFallback(t,_o)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=yo.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function _o(t,e,i,s){return i.value?t.formatPattern(i.value,s,e):null}function xo(t,e,i,s){const n={value:null,attributes:null};i.value&&(n.value=t.formatPattern(i.value,s,e));let a=Object.keys(i.attributes);if(a.length>0){n.attributes=new Array(a.length);for(let[r,o]of a.entries()){let a=t.formatPattern(i.attributes[o],s,e);n.attributes[r]={name:o,value:a}}}return n}function So(t,e,i,s){const n=[],a=new Set;return i.forEach((({id:i,args:r},o)=>{if(void 0!==s[o])return;let l=e.getMessage(i);if(l){if(n.length=0,s[o]=t(e,n,l,r),n.length>0&&"undefined"!=typeof console){const t=e.locales[0],s=n.join(", ");console.warn(`[fluent][resolver] errors in ${t}/${i}: ${s}.`)}}else a.add(i)})),a}const Co="data-l10n-id",Eo="data-l10n-args",Po=`[${Co}]`;class Mo extends Ao{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:[Co,Eo]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Co,e),i?t.setAttribute(Eo,JSON.stringify(i)):t.removeAttribute(Eo),t}getAttributes(t){return{id:t.getAttribute(Co),args:JSON.parse(t.getAttribute(Eo)||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(Co)&&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]&&ho(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Po));return"function"==typeof t.hasAttribute&&t.hasAttribute(Co)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Co),args:JSON.parse(t.getAttribute(Eo)||null)}}}class To{#sl;#sn;#Mi;#nl;constructor({lang:t,isRTL:e},i=null){this.#Mi=To.#al(t),this.#nl=i,this.#sl=e??To.#rl(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#al(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#rl(t){const e=t.split("-",1)[0];return["ar","he","fa","ps","ur"].includes(e)}}function ko(t,e){const i=new no(e),s=new Dr(t),n=s.addResource(i);return n.length&&console.error("L10n errors",n),s}class Io extends To{constructor(t){super({lang:t});const e=t?Io.#ol.bind(Io,"en-us",this.getLanguage()):Io.#ll.bind(Io,this.getLanguage());this._setL10n(new Mo([],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 ko(t,await La(n,"text"))}static async#hl(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await La(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 ko(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 Lo(){return document.location.hash}class Do{#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=Lo(),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 a=n.destination;this.#ml(a,n.uid,!0),void 0!==a.rotation&&(this._initialRotation=a.rotation),a.dest?(this._initialBookmark=JSON.stringify(a.dest),this._destination.page=null):a.hash?this._initialBookmark=a.hash:a.page&&(this._initialBookmark=`page=${a.page}`)}reset(){this._initialized&&(this.#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(Rn(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(Lo()).substring(1),i=Rn(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=Lo(),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(),a=new AbortController;function r(t){a.abort(),clearTimeout(o),n(t)}t[t instanceof fr?"_on":"addEventListener"](e,r.bind(null,pr),{signal:a.signal});const o=setTimeout(r.bind(null,gr),i);return s}({target:window,name:"hashchange",delay:1e3}).then((()=>{this._blockHashChange--})));const s=t.destination;this.#ml(s,t.uid,!0),Hn(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 Ro{#ao=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 Io,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#f=t.uiManager,this.#ao=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 ya({uiManager:this.#f,div:s,structTreeLayer:this.#Tn,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#ao,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 No=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)&&No.set("maxCanvasPixels",5242880),s&&No.set("useSystemFonts",!1)}const Fo=1,Oo=2,Bo=4,jo=8,Ho=16,Vo=128,zo={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},Uo={allowedGlobalEvents:{value:null,kind:Fo},canvasMaxAreaInBytes:{value:-1,kind:Fo+Bo},isInAutomation:{value:!1,kind:Fo},localeProperties:{value:{lang:navigator.language||"en-US"},kind:Fo},nimbusDataStr:{value:"",kind:Fo},supportsCaretBrowsingMode:{value:!1,kind:Fo},supportsDocumentFonts:{value:!0,kind:Fo},supportsIntegratedFind:{value:!1,kind:Fo},supportsMouseWheelZoomCtrlKey:{value:!0,kind:Fo},supportsMouseWheelZoomMetaKey:{value:!0,kind:Fo},supportsPinchToZoom:{value:!0,kind:Fo},toolbarDensity:{value:0,kind:Fo+Ho},altTextLearnMoreUrl:{value:"",kind:Oo+Vo},annotationEditorMode:{value:0,kind:Oo+Vo},annotationMode:{value:2,kind:Oo+Vo},cursorToolOnLoad:{value:0,kind:Oo+Vo},debuggerSrc:{value:"./debugger.mjs",kind:Oo},defaultZoomDelay:{value:400,kind:Oo+Vo},defaultZoomValue:{value:"",kind:Oo+Vo},disableHistory:{value:!1,kind:Oo},disablePageLabels:{value:!1,kind:Oo+Vo},enableAltText:{value:!1,kind:Oo+Vo},enableAltTextModelDownload:{value:!0,kind:Oo+Vo+Ho},enableGuessAltText:{value:!0,kind:Oo+Vo+Ho},enableHighlightFloatingButton:{value:!1,kind:Oo+Vo},enableNewAltTextWhenAddingImage:{value:!0,kind:Oo+Vo},enablePermissions:{value:!1,kind:Oo+Vo},enablePrintAutoRotate:{value:!0,kind:Oo+Vo},enableScripting:{value:!0,kind:Oo+Vo},enableUpdatedAddImage:{value:!1,kind:Oo+Vo},externalLinkRel:{value:"noopener noreferrer nofollow",kind:Oo},externalLinkTarget:{value:0,kind:Oo+Vo},highlightEditorColors:{value:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",kind:Oo+Vo},historyUpdateUrl:{value:!1,kind:Oo+Vo},ignoreDestinationZoom:{value:!1,kind:Oo+Vo},imageResourcesPath:{value:"./images/",kind:Oo},maxCanvasPixels:{value:2**25,kind:Oo},forcePageColors:{value:!1,kind:Oo+Vo},pageColorsBackground:{value:"Canvas",kind:Oo+Vo},pageColorsForeground:{value:"CanvasText",kind:Oo+Vo},pdfBugEnabled:{value:!1,kind:Oo+Vo},printResolution:{value:150,kind:Oo},sidebarViewOnLoad:{value:-1,kind:Oo+Vo},scrollModeOnLoad:{value:-1,kind:Oo+Vo},spreadModeOnLoad:{value:-1,kind:Oo+Vo},textLayerMode:{value:1,kind:Oo+Vo},viewOnLoad:{value:0,kind:Oo+Vo},cMapPacked:{value:!0,kind:Bo},cMapUrl:{value:"../web/cmaps/",kind:Bo},disableAutoFetch:{value:!1,kind:Bo+Vo},disableFontFace:{value:!1,kind:Bo+Vo},disableRange:{value:!1,kind:Bo+Vo},disableStream:{value:!1,kind:Bo+Vo},docBaseUrl:{value:"",kind:Bo},enableHWA:{value:!0,kind:Bo+Oo+Vo},enableXfa:{value:!0,kind:Bo+Vo},fontExtraProperties:{value:!1,kind:Bo},isEvalSupported:{value:!0,kind:Bo},isOffscreenCanvasSupported:{value:!0,kind:Bo},maxImageSize:{value:-1,kind:Bo},pdfBug:{value:!1,kind:Bo},standardFontDataUrl:{value:"../web/standard_fonts/",kind:Bo},useSystemFonts:{value:void 0,kind:Bo,type:zo.BOOLEAN+zo.UNDEFINED},verbosity:{value:1,kind:Bo},workerPort:{value:null,kind:jo},workerSrc:{value:"../build/pdf.worker.mjs",kind:jo}};Uo.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:Oo},Uo.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:Oo},Uo.viewerCssTheme={value:0,kind:Oo+Vo},Uo.enableFakeMLManager={value:!0,kind:Oo},Uo.disablePreferences={value:!1,kind:Oo};class $o{static eventBus;static#Sl=new Map;static{for(const t in Uo)this.#Sl.set(t,Uo[t].value);for(const[t,e]of No)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 Uo){const n=Uo[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=Uo[s],a=t[s];if(!n||!(typeof a==typeof n.value||zo[(typeof a).toUpperCase()]&n.type))continue;const{kind:r}=n;(!e||r&Fo||r&Vo)&&(this.eventBus&&r&Ho&&(i||=new Map).set(s,a),this.#Sl.set(s,a))}if(i)for(const[t,e]of i)this.eventBus.dispatch(t.toLowerCase(),{source:this,value:e})}}class Wo{#xl=null;constructor(t){this.pageIndex=t.pageIndex}async render(t="display"){"display"!==t||this.#xl||this._cancelled||(this.#xl=new ka({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 Go={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},qo=/^H(\d+)$/;class Xo{#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=Fn(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",Fn(n,!0))}#Dl(t,e){const{alt:i,bbox:s,children:n}=t,a=n?.[0];if(!this.#Tl||!i||!s||"content"!==a?.type)return!1;const{id:r}=a;if(!r)return!1;e.setAttribute("aria-owns",r);const o=document.createElement("span");(this.#kl||=new Map).set(r,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Fn(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(qo);if(s?(e.setAttribute("role","heading"),e.setAttribute("aria-level",s[1])):Go[i]&&e.setAttribute("role",Go[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 Ko{#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,a=i.y+i.height,r=i.y+i.height/2,o=s.y,l=s.y+s.height,h=s.y+s.height/2;if(r<=o&&h>=a)return-1;if(h<=n&&r>=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(Ko.#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 a=n.getAttribute("aria-owns");a?.includes(i)&&(a=a.split(" ").filter((t=>t!==i)).join(" "),a?n.setAttribute("aria-owns",a):(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=On(s,(e=>Ko.#Bl(t,e)<0)),a=Math.max(0,n-1),r=s[a];this.#jl(i,r),this.#Fl.set(i,a);const o=r.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 a=Array.from(t.childNodes).filter((t=>t!==e));if(0===a.length)return n;const r=i||e,o=On(a,(t=>Ko.#Bl(r,t)<0));return 0===o?a[0].before(e):a[o-1].after(e),n}}class Yo{#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 a=i.length-1,r=[];for(let o=0,l=t.length;o<l;o++){let l=t[o];for(;s!==a&&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!==a&&l>n+i[s].length;)n+=i[s].length,s++;h.end={divIdx:s,offset:l-n},r.push(h)}return r}_renderMatches(t){if(0===t.length)return;const{findController:e,pageIdx:i}=this,{textContentItemsStr:s,textDivs:n}=this,a=i===e.selected.pageIdx,r=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,a){let r=n[t];if(r.nodeType===Node.TEXT_NODE){const e=document.createElement("span");r.before(e),e.append(r),n[t]=e,r=e}const o=s[t].substring(e,i),l=document.createTextNode(o);if(a){const t=document.createElement("span");if(t.className=`${a} appended`,t.append(l),r.append(t),a.includes("selected")){const{left:e}=t.getClientRects()[0];return e-r.getBoundingClientRect().left}return 0}return r.append(l),0}let c=r,u=c+1;if(e.state.highlightAll)c=0,u=t.length;else if(!a)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=a&&s===r,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:r})}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:a}=this;let r=-1;for(const t of i){for(let e=Math.max(r,t.begin.divIdx),i=t.end.divIdx;e<=i;e++){const t=a[e];t.textContent=n[e],t.className=""}r=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 Qo{#Hl=!1;#Zo=null;#Vl=!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.#Hl=!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.#Vl&&this.#go)return this.#go.update({viewport:t,onBefore:this.hide.bind(this)}),void this.show();this.cancel(),this.#go=new sr({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.#Vl=!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.#Vl&&(this.highlighter?.disable(),this.div.hidden=!0)}show(){this.div.hidden&&this.#Vl&&(this.div.hidden=!1,this.highlighter?.enable())}cancel(){this.#go?.cancel(),this.#go=null,this.highlighter?.disable(),this.accessibilityManager?.disable(),Qo.#Wl(this.div)}#$l(t){const{div:e}=this;e.addEventListener("mousedown",(()=>{e.classList.add("selecting")})),e.addEventListener("copy",(t=>{if(!this.#Hl){const e=document.getSelection();t.clipboardData.setData("text/plain",Fn($a(e.toString())))}ir(t)})),Qo.#zl.set(e,t),Qo.#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 a=t.getRangeAt(0),r=n&&(0===a.compareBoundaryPoints(Range.END_TO_END,n)||0===a.compareBoundaryPoints(Range.START_TO_END,n));let o=r?a.startContainer:a.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,r?o:o.nextSibling)),n=a.cloneRange()}),{signal:t})}}class Jo{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,hr.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?hr.update(s):(this.div=document.createElement("div"),s.div=this.div,hr.render(s))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Zo={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new va}},tl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class el{#ql=Ca.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=xn.INITIAL;#nh=Tn;#ah={directDrawing:!0,initialOptionalContent:!0,regularAnnotations:!0};#rh=[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||Zo,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??Tn,this.#ql=t.annotationMode??Ca.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.maxCanvasPixels=t.maxCanvasPixels??$o.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 Io,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*Ja.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.#ah.initialOptionalContent=t.hasInitialVisibility)})),t.l10n||this.l10n.translate(this.div)}}#lh(t,e){const i=tl.get(e),s=this.#rh[i];if(this.#rh[i]=t,s)s.replaceWith(t);else{for(let e=i-1;e>=0;e--){const i=this.#rh[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 xn.PAUSED:this.div.classList.remove("loading");break;case xn.RUNNING:this.div.classList.add("loadingIcon"),this.#Ql=setTimeout((()=>{this.div.classList.add("loading"),this.#Ql=null}),0);break;case xn.INITIAL:case xn.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}tr(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*Ja.PDF_TO_CSS_UNITS,rotation:e}),this.#oh(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return er(this,"_textHighlighter",new Yo({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 wa)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=xn.INITIAL;const a=this.div,r=a.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=r.length-1;t>=0;t--){const e=r[t];switch(e){case o:case l:case h:case d:case c:continue}e.remove();const i=this.#rh.indexOf(e);i>=0&&(this.#rh[i]=null)}a.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.#ah.initialOptionalContent=t.hasInitialVisibility)}))),this.#ah.directDrawing=!0;const n=(this.rotation+this.pdfPageRotate)%360;if(this.viewport=this.viewport.clone({scale:this.scale*Ja.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!==xn.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:s}),this.renderingState=xn.FINISHED,this.#ah.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:a}=this;if(!a)return;const r=this.#Jl;if(this.viewport!==r){const t=(360+this.viewport.rotation-r.rotation)%360;if(90===t||270===t){const{width:e,height:i}=this.viewport,s=i/e,n=e/i;a.style.transform=`rotate(${t}deg) scale(${s},${n})`}else a.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 Za)this.#ih=null;else if(this.#ih=e,this.renderingState=xn.FINISHED,this.#ah.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!==xn.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=xn.FINISHED,new Error("pdfPage is not loaded");this.renderingState=xn.RUNNING;let a=this.#Xl;if(a||(a=this.#Xl=document.createElement("div"),a.classList.add("canvasWrapper"),this.#lh(a,"canvasWrapper")),this.textLayer||this.#nh===Mn||s.isPureXfa||(this._accessibilityManager||=new Ko,this.textLayer=new Qo({pdfPage:s,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#nh===kn,onAppend:t=>{this.l10n.pause(),this.#lh(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#ql!==Ca.DISABLE){const{annotationStorage:t,annotationEditorUIManager:e,downloadManager:i,enableScripting:n,fieldObjectsPromise:a,hasJSActionsPromise:r,linkService:o}=this.#Yl;this._annotationCanvasMap||=new Map,this.annotationLayer=new dr({pdfPage:s,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#ql===Ca.ENABLE_FORMS,linkService:o,downloadManager:i,enableScripting:n,hasJSActionsPromise:r,fieldObjectsPromise:a,annotationCanvasMap:this._annotationCanvasMap,accessibilityManager:this._accessibilityManager,annotationEditorUIManager:e,onAppend:t=>{this.#lh(t,"annotationLayer")}})}const{width:r,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 a.prepend(l),void(u=null);t&&(d?(d.replaceWith(l),d.width=d.height=0):a.prepend(l),u=null)};const p=l.getContext("2d",{alpha:!1,willReadFrequently:!this.#li}),g=this.outputScale=new Ga;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=r*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=Bn(g.sx),m=Bn(g.sy),b=l.width=jn($n(r*g.sx),f[0]),v=l.height=jn($n(o*g.sy),m[0]),w=jn($n(r),f[1]),y=jn($n(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=xn.PAUSED,void(this.resume=()=>{this.renderingState=xn.RUNNING,t()});t()};const x=_.promise.then((async()=>{u?.(!0),await this.#vh(_),this.structTreeLayer||=new Xo(s,n.rawDims),this.#fh(),this.annotationLayer&&await this.#dh();const{annotationEditorUIManager:t}=this.#Yl;t&&(this.drawLayer||=new Wo({pageIndex:this.id}),await this.#uh(),this.drawLayer.setParent(a),this.annotationEditorLayer||=new Ro({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 Za?(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 Jo({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.#ah;return t&&e&&i?this.canvas:null}}class il{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 sl{#wh=null;#yh=null;#Ah=null;#tl=null;#Ia=null;#_h=null;#xh=null;#Sh=null;#Ch=!1;#Eh=null;#Ph=null;constructor({eventBus:t,externalServices:e=null,docProperties:i=null}){this.#Ia=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.#Ia;this.#tl=new AbortController;const{signal:a}=this.#tl;n._on("updatefromsandbox",(t=>{t?.source===window&&this.#kh(t.detail)}),{signal:a}),n._on("dispatcheventinsandbox",(t=>{this.#Eh?.dispatchEventInSandbox(t.detail)}),{signal:a}),n._on("pagechanging",(({pageNumber:t,previous:e})=>{t!==e&&(this.#Ih(e),this.#Lh(t))}),{signal:a}),n._on("pagerendered",(({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#Sh.currentPageNumber&&this.#Lh(t)}),{signal:a}),n._on("pagesdestroy",(async()=>{await this.#Ih(this.#Sh.currentPageNumber),await(this.#Eh?.dispatchEventInSandbox({id:"doc",name:"WillClose"})),this.#wh?.resolve()}),{signal:a});try{const a=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:{...a,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 er(this,"_pageOpenPending",new Set)}get _visitedPages(){return er(this,"_visitedPages",new Map)}async#kh(t){const e=this.#Sh,i=e.isInPresentationMode||e.isChangingPresentationMode,{id:s,siblings:n,command:a,value:r}=t;if(!s){switch(a){case"clear":console.clear();break;case"error":console.error(r);break;case"layout":if(!i){const t=function(t){let e=In.VERTICAL,i=Ln.NONE;switch(t){case"SinglePage":e=In.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=In.PAGE;case"TwoColumnLeft":i=Ln.ODD;break;case"TwoPageRight":e=In.PAGE;case"TwoColumnRight":i=Ln.EVEN}return{scrollMode:e,spreadMode:i}}(r);e.spreadMode=t.spreadMode}break;case"page-num":e.currentPageNumber=r+1;break;case"print":await e.pagesPromise,this.#Ia.dispatch("print",{source:this});break;case"println":console.log(r);break;case"zoom":i||(e.currentScaleValue=r);break;case"SaveAs":this.#Ia.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!==xn.FINISHED)return void this._pageOpenPending.add(t);this._pageOpenPending.delete(t);const a=(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,a)}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 nl extends sl{constructor(t){t.externalServices||window.addEventListener("updatefromsandbox",(e=>{t.eventBus.dispatch("updatefromsandbox",{source:window,detail:e.detail})})),t.externalServices||={createScripting:()=>new il(t.sandboxBundleSrc)},t.docProperties||=t=>async function(t){const e="".split("#",1)[0];let{info:i,metadata:s,contentDispositionFilename:n,contentLength:a}=await t.getMetadata();if(!a){const{length:e}=await t.getDownloadInfo();a=e}return{...i,baseURL:e,filesize:a,filename:n||Na(""),metadata:s?.getRaw(),authors:s?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}}let al=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,a=n.length;if(0===a)return null;for(let t=0;t<a;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const r=t.first.id,o=t.last.id;if(o-r+1>a){const s=t.ids;for(let t=1,n=o-r;t<n;t++){const n=i?r+t:o-t;if(s.has(n))continue;const a=e[n-1];if(!this.isViewFinished(a))return a}}let l=i?o:r-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===xn.FINISHED}renderView(t){switch(t.renderingState){case xn.FINISHED:return!1;case xn.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case xn.RUNNING:this.highestPriorityPage=t.renderingId;break;case xn.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof Za||console.error("renderView:",t)}))}return!0}};const rl=1e4,ol=5e3,ll=250;function hl(t){return Object.values(_a).includes(t)&&t!==_a.DISABLE}class dl{#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 cl{#Fh=null;#L=null;#Oh=null;#Bh=_a.NONE;#jh=null;#ql=Ca.ENABLE_FORMS;#Hh=null;#Vh=null;#li=!1;#U=!1;#Hl=!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=Tn;constructor(t){const e="4.10.38";if(lr!==e)throw new Error(`The API version "${lr}" 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 va,this.downloadManager=t.downloadManager||null,this.findController=t.findController||null,this.#L=t.altTextManager||null,this.#Vh=t.editorUndoBar||null,this.findController&&(this.findController.onIsPageVisible=t=>this._getVisiblePages().ids.has(t)),this._scriptingManager=t.scriptingManager||null,this.#nh=t.textLayerMode??Tn,this.#ql=t.annotationMode??Ca.ENABLE_FORMS,this.#Bh=t.annotationEditorMode??_a.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 Io,this.#Hl=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 al,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){a||(a=window.requestAnimationFrame((function(){a=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const r=t.scrollTop,o=n.lastY;r!==o&&(n.down=r>o),n.lastY=r,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let a=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),i?.addEventListener("abort",(()=>window.cancelAnimationFrame(a)),{once:!0}),n}(this.container,this._scrollUpdate.bind(this),i),this.presentationModeState=Sn,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===Ca.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(!Hn(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 er(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(Qa.COPY)||this.#nh!==Tn||(e.textLayerMode=kn),t.includes(Qa.MODIFY_CONTENTS)||(e.annotationEditorMode=_a.DISABLE),t.includes(Qa.MODIFY_ANNOTATIONS)||t.includes(Qa.FILL_INTERACTIVE_FORMS)||this.#ql!==Ca.ENABLE_FORMS||(e.annotationMode=Ca.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(Fn(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===kn)return void ir(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")})),ir(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.#Hl?t.getPermissions():Promise.resolve(),{eventBus:a,pageColors:r,viewer:o}=this;this.#tl=new AbortController;const{signal:l}=this.#tl;if(e>rl){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=In.PAGE;a.dispatch("scrollmodechanged",{source:this,mode:t})}this._pagesCapability.promise.then((()=>{a.dispatch("pagesloaded",{source:this,pagesCount:e})}),(()=>{}));a._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}),a._off("pagerendered",h))};a._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!==Mn){const t=this.#Wh=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if("function"==typeof AbortSignal.any&&h!==_a.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):hl(e)?(this.#jh=new xa(this.container,o,this.#L,a,t,r,this.#Oh,this.#U,this.#$,this.#W,this.#nt,this.#Vh,this.#Jh),a.dispatch("annotationeditoruimanager",{source:this,uiManager:this.#jh}),e!==_a.NONE&&(e===_a.STAMP&&this.#nt?.loadModel("altText"),this.#jh.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===In.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*Ja.PDF_TO_CSS_UNITS});o.style.setProperty("--scale-factor",g.scale),r?.background&&o.style.setProperty("--page-bg-color",r.background),"CanvasText"!==r?.foreground&&"Canvas"!==r?.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 el({container:u,eventBus:a,id:t,scale:p,defaultViewport:g.clone(),optionalContentConfigPromise:s,renderingQueue:this.renderingQueue,textLayerMode:c,annotationMode:d,imageResourcesPath:this.imageResourcesPath,maxCanvasPixels:this.maxCanvasPixels,pageColors:r,l10n:this.l10n,layerProperties:this._layerProperties,enableHWA:this.#li});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===In.PAGE?this.#ad():this._spreadMode!==Ln.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&&a.dispatch("annotationeditormodechanged",{source:this,mode:this.#Bh}),t.loadingParams.disableAutoFetch||e>ol)return void this._pagesCapability.resolve();let i=e-1;if(i<=0)this._pagesCapability.resolve();else for(let s=2;s<=e;++s){const e=t.getPage(s).then((t=>{const e=this._pages[s-1];e.pdfPage||e.setPdfPage(t),0==--i&&this._pagesCapability.resolve()}),(t=>{console.error(`Unable to get page ${s} to initialize viewer`,t),0==--i&&this._pagesCapability.resolve()}));s%ll==0&&await e}})),a.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 dl(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=In.VERTICAL,this._previousScrollMode=In.UNKNOWN,this._spreadMode=Ln.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.#rd()}#ad(){if(this._scrollMode!==In.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!==Ln.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 a=document.createElement("div");if(a.className="spread",this.isInPresentationMode){const t=document.createElement("div");t.className="dummyPage",a.append(t)}for(const t of s){const i=this._pages[t];i&&(a.append(i.div),e.pages.push(i))}i.append(a)}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===In.PAGE&&(this.#ad(),this.update()),!e&&!this.isInPresentationMode){const t=i.offsetLeft+i.clientLeft,s=t+i.clientWidth,{scrollLeft:n,clientWidth:a}=this.container;(this._scrollMode===In.HORIZONTAL||t<n||s>n+a)&&(e={left:0,top:0})}Dn(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:a=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*Ja.PDF_TO_CSS_UNITS);const r=n>=0&&n<1e3;this.refresh(!0,{scale:t,drawingDelay:r?n:-1}),r&&(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(a)){const e=t/o-1,[i,s]=this.containerTopLeft;this.container.scrollLeft+=(a[0]-s)*e,this.container.scrollTop+=(a[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!==Ln.NONE&&this._scrollMode!==In.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,a=5;this.isInPresentationMode?(n=a=4,this._spreadMode!==Ln.NONE&&(n*=2)):this.removePageBorders?n=a=0:this._scrollMode===In.HORIZONTAL&&([n,a]=[a,n]);const r=(this.container.clientWidth-n)/s.width*s.scale/this.#dd,o=(this.container.clientHeight-a)/s.height*s.scale;switch(t){case"page-actual":i=1;break;case"page-width":i=r;break;case"page-height":i=o;break;case"page-fit":i=Math.min(r,o);break;case"auto":const e=Vn(s)?r:Math.min(o,r);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 a,r,o=0,l=0,h=0,d=0;const c=n.rotation%180!=0,u=(c?n.height:n.width)/n.scale/Ja.PDF_TO_CSS_UNITS,p=(c?n.width:n.height)/n.scale/Ja.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),a=(this.container.clientWidth-t)/h/Ja.PDF_TO_CSS_UNITS,r=(this.container.clientHeight-i)/d/Ja.PDF_TO_CSS_UNITS,g=Math.min(Math.abs(a),Math.abs(r));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,a=this._pages[n-1],r=this.container,o=a.getPagePoint(r.scrollLeft-t.x,r.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===Ln.NONE&&(this._scrollMode===In.PAGE||this._scrollMode===In.VERTICAL),a=this._currentPageNumber;let r=!1;for(const t of e){if(t.percent<100)break;if(t.id===a&&n){r=!0;break}}this._setCurrentPageNumber(r?a: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===Pn}get isChangingPresentationMode(){return this.presentationModeState===En}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===In.PAGE?this.#Yh.pages:this._pages,e=this._scrollMode===In.HORIZONTAL,i=e&&this._isContainerRtl;return function({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth,h=[],d=new Set,c=e.length;let u=On(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>a});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,a));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>=r&&(p=b);else if((s?c:u)>p)break;if(b<=a||u>=r||m<=o||c>=l)continue;const v=Math.max(0,a-u)+Math.max(0,b-r),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!==xn.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 In.PAGE:return this.#Yh.scrollDown;case In.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#pd(e),s=this._spreadMode!==Ln.NONE&&this._scrollMode!==In.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=Vn(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(In).includes(t)&&t!==In.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>rl||(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===In.HORIZONTAL),i.classList.toggle("scrollWrapped",e===In.WRAPPED),this.pdfDocument&&t&&(e===In.PAGE?this.#ad():this._previousScrollMode===In.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(Ln).includes(t)&&t!==Ln.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===In.PAGE)this.#ad();else if(e.textContent="",this._spreadMode===Ln.NONE)for(const t of this._pages)e.append(t.div);else{const t=this._spreadMode-1;let s=null;for(let n=0,a=i.length;n<a;++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 In.WRAPPED:{const{views:i}=this._getVisiblePages(),s=new Map;for(const{id:t,y:e,percent:n,widthPercent:a}of i){if(0===n||a<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,a=n;e<a;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 In.HORIZONTAL:break;case In.PAGE:case In.VERTICAL:{if(this._spreadMode===Ln.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,zn.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.#Hh=null;break}}get containerTopLeft(){return this.#Hh||=[this.container.offsetTop,this.container.offsetLeft]}#rd(){this.#zh?.abort(),this.#zh=null,null!==this.#Uh&&(clearTimeout(this.#Uh),this.#Uh=null)}get annotationEditorMode(){return this.#jh?this.#Bh:_a.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(!hl(t))throw new Error(`Invalid AnnotationEditor mode: ${t}`);if(!this.pdfDocument)return;t===_a.STAMP&&this.#nt?.loadModel("altText");const{eventBus:s}=this,n=()=>{this.#rd(),this.#Bh=t,this.#jh.updateMode(t,e,i),s.dispatch("annotationeditormodechanged",{source:this,mode:t})};if(t===_a.NONE||this.#Bh===_a.NONE){const e=t!==_a.NONE;e||this.pdfDocument.annotationStorage.resetModifiedIds();for(const t of this._pages)t.toggleEditingMode(e);const i=this.#cd();if(e&&i){this.#rd(),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 ul extends cl{_resetView(){super._resetView(),this._scrollMode=In.PAGE,this._spreadMode=Ln.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var pl,gl,fl,ml,bl,vl=_n.DownloadManager,wl=_n.EventBus,yl=_n.GenericL10n,Al=_n.PDFFindController,_l=_n.PDFLinkService,xl=_n.PDFSinglePageViewer,Sl=_n.PDFViewer,Cl=_n.SimpleLinkService,El=_n.XfaLayerBuilder;const Pl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Ml={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},Tl={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},kl={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},Il={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Ll={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};class Dl{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}}function Rl(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,a=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,a+=s.offsetLeft,s=s.offsetParent,!s)return;e&&(void 0!==e.top&&(n+=e.top),void 0!==e.left&&(a+=e.left,s.scrollLeft=a)),s.scrollTop=n}function Nl(t,e,i=void 0){const s=function(i){a||(a=window.requestAnimationFrame((function(){a=null;const i=t.scrollLeft,s=n.lastX;i!==s&&(n.right=i>s),n.lastX=i;const r=t.scrollTop,o=n.lastY;r!==o&&(n.down=r>o),n.lastY=r,e(n)})))},n={right:!0,down:!0,lastX:t.scrollLeft,lastY:t.scrollTop,_eventHandler:s};let a=null;return t.addEventListener("scroll",s,{useCapture:!0,signal:i}),null==i||i.addEventListener("abort",(()=>window.cancelAnimationFrame(a)),{once:!0}),n}const Fl=/[\x00-\x1F]/g;function Ol(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 Bl({view:t,userUnit:e,rotate:i}){const[s,n,a,r]=t,o=i%180!=0,l=(a-s)/72*e,h=(r-n)/72*e;return{width:o?h:l,height:o?l:h}}function jl(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 Hl({scrollEl:t,views:e,sortByVisibility:i=!1,horizontal:s=!1,rtl:n=!1}){const a=t.scrollTop,r=a+t.clientHeight,o=t.scrollLeft,l=o+t.clientWidth;const h=[],d=new Set,c=e.length;let u=Ol(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>a});u>0&&u<c&&!s&&(u=jl(u,e,a));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>=r&&(p=b);else if((s?c:u)>p)break;if(b<=a||u>=r||m<=o||c>=l)continue;const v=Math.max(0,a-u)+Math.max(0,b-r),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 Vl(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 zl(t){const e=t.deltaMode;let i=Vl(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function Ul(t){return Number.isInteger(t)&&t%90==0}function $l(t){return Number.isInteger(t)&&Object.values(Il).includes(t)&&t!==Il.UNKNOWN}function Wl(t){return Number.isInteger(t)&&Object.values(Ll).includes(t)&&t!==Ll.UNKNOWN}function Gl(t){return t.width<=t.height}const ql=new Promise((function(t){window.requestAnimationFrame(t)})),Xl=document.documentElement.style;pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,bl=new WeakMap;const Kl=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 Yl{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,a=n.length;if(0===a)return null;for(let t=0;t<a;t++){const e=n[t].view;if(!this.isViewFinished(e))return e}const r=t.first.id,o=t.last.id;if(o-r+1>a){const s=t.ids;for(let t=1,n=o-r;t<n;t++){const n=i?r+t:o-t;if(s.has(n))continue;const a=e[n-1];if(!this.isViewFinished(a))return a}}let l=i?o:r-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===Pl.FINISHED}renderView(t){switch(t.renderingState){case Pl.FINISHED:return!1;case Pl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Pl.RUNNING:this.highestPriorityPage=t.renderingId;break;case Pl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally((()=>{this.renderHighestPriority()})).catch((t=>{t instanceof bn||console.error("renderView:",t)}))}return!0}}var Ql,Jl,Zl,th,eh,ih,sh,nh;class ah{static getCanvas(t,e){const i=n(this,Ql,s(this,Ql,"f",Jl)||document.createElement("canvas"),"f",Jl);i.width=t,i.height=e;const a=i.getContext("2d",{alpha:!1});return a.save(),a.fillStyle="rgb(255, 255, 255)",a.fillRect(0,0,t,e),a.restore(),[i,i.getContext("2d")]}static destroyCanvas(){const t=s(this,Ql,"f",Jl);t&&(t.width=0,t.height=0),n(this,Ql,null,"f",Jl)}}Ql=ah,Jl={value:null};class rh{constructor({container:t,eventBus:e,id:i,defaultViewport:n,optionalContentConfigPromise:a,linkService:r,renderingQueue:o,pageColors:l,enableHWA:h,store:d,thumbnailWidth:c}){Zl.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=a||null,this.pageColors=l||null,this.enableHWA=h||!1,this.eventBus=e,this.linkService=r,this.renderingQueue=o,this.renderTask=null,this.renderingState=Pl.INITIAL,this.resume=null,this.store=d,this.thumbnailWidth=c,this.loaded=!1;const u=document.createElement("div");u.className="thumbnail pdfSlickThumbHolder",u.setAttribute("data-page-number",this.id.toString()),this.div=u,s(this,Zl,"m",th).call(this),t.append(u)}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=Pl.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,s(this,Zl,"m",th).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 i(this,void 0,void 0,(function*(){if(this.renderingState!==Pl.INITIAL)return void console.error("Must be in new state before drawing");const{pdfPage:t}=this;if(!t)throw this.renderingState=Pl.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Pl.RUNNING;const{ctx:e,canvas:i,transform:n}=s(this,Zl,"m",eh).call(this,2),a={canvasContext:e,transform:n,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:this.pageColors},r=this.renderTask=t.render(a);r.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Pl.PAUSED,void(this.resume=()=>{this.renderingState=Pl.RUNNING,t()});t()};const o=r.promise.then((()=>s(this,Zl,"m",sh).call(this,r,i)),(t=>s(this,Zl,"m",sh).call(this,r,i,t)));return o.finally((()=>{i.width=0,i.height=0,this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:this.pdfPage})})),o}))}setImage(t){if(this.renderingState!==Pl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:n}=t;e&&(this.pdfPage||this.setPdfPage(i),n<this.scale||(this.renderingState=Pl.FINISHED,s(this,Zl,"m",ih).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var oh,lh,hh,dh,ch,uh,ph;Zl=new WeakSet,th=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`)},eh=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),s=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),n=new Dl;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}},ih=function(t){if(this.renderingState!==Pl.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=s(this,Zl,"m",nh).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},sh=function(t,e){return i(this,arguments,void 0,(function*(t,e,i=null){if(t===this.renderTask&&(this.renderTask=null),!(i instanceof bn)&&(this.renderingState=Pl.FINISHED,s(this,Zl,"m",ih).call(this,e),i))throw i}))},nh=function(t){const{ctx:e,canvas:i}=s(this,Zl,"m",eh).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=i.width<<3,a=i.height<<3;const[r,o]=ah.getCanvas(n,a);for(;n>t.width||a>t.height;)n>>=1,a>>=1;for(o.drawImage(t,0,0,t.width,t.height,0,0,n,a);n>2*i.width;)o.drawImage(r,0,0,n,a,0,0,n>>1,a>>1),n>>=1,a>>=1;return e.drawImage(r,0,0,n,a,0,0,i.width,i.height),i};const gh="selected";class fh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:n,pageColors:a,abortSignal:r,enableHWA:o,store:l,thumbnailWidth:h}){oh.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=n,this.pageColors=a||null,this.enableHWA=o||!1,this.store=l,this.thumbnailWidth=h,this.scroll=Nl(this.container,s(this,oh,"m",lh).bind(this),r),s(this,oh,"m",dh).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(gh),e.div.classList.add(gh)}const{first:i,last:n,views:a}=s(this,oh,"m",hh).call(this);if(a.length>0){let s=!1;if(t<=i.id||t>=n.id)s=!0;else for(const{id:e,percent:i}of a)if(e===t){s=i<100;break}s&&Rl(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!Ul(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!==Pl.FINISHED&&t.reset();ah.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(s(this,oh,"m",ch).call(this),s(this,oh,"m",dh).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,a=e.getViewport({scale:1});for(let t=1;t<=n;++t){const e=new rh({container:this.container,eventBus:this.eventBus,id:t,defaultViewport:a.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(gh),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=s(this,oh,"m",hh).call(this),e=s(this,oh,"m",ph).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e);return!!i&&(s(this,oh,"m",uh).call(this,i).then((()=>{this.renderingQueue.renderView(i)})),!0)}}oh=new WeakSet,lh=function(){this.renderingQueue.renderHighestPriority()},hh=function(){return Hl({scrollEl:this.container,views:this._thumbnails})},dh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},ch=function(){for(const t of this._thumbnails)t.cancelRendering()},uh=function(t){return i(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}}))},ph=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 mh=null;class bh{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(mh!==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,mh=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,s=new Cl,n=Math.round(100*mn.PDF_TO_CSS_UNITS)/100;for(const a of null==i?void 0:i.children){const i=document.createElement("div");i.className="xfaPrintedPage",t.append(i);const r=new El({pdfPage:null,annotationStorage:e.annotationStorage,linkService:s,xfaHtml:a}),o=yn(a,{scale:n});r.render(o,"print"),i.append(r.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 a=this.currentPage;t({index:a,total:e}),function(t,e,i,s,n,a,r){const o=t.scratchCanvas,l=n/mn.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),r]).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:pn.ENABLE_STORAGE,optionalContentConfigPromise:a,printAnnotationStorage:e};return t.render(i).promise.catch((t=>{throw t instanceof bn||console.error(t),t}))}))}(this,this.pdfDocument,a+1,this.pagesOverview[a],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===mh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const vh={instance:{supportsPrinting:!0,createPrintService(t){if(mh)throw new Error("The print service is created and active.");return mh=new bh(t)}}};var wh,yh,Ah,_h,xh,Sh,Ch,Eh,Ph,Mh,Th,kh,Ih,Lh,Dh,Rh,Nh,Fh,Oh;const Bh="pdfPresentationMode",jh="pdfPresentationModeControls",Hh=Math.PI/6;class Vh{constructor({container:t,pdfViewer:e,eventBus:i}){wh.add(this),yh.set(this,Ml.UNKNOWN),Ah.set(this,null),_h.set(this,null),xh.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 i(this,void 0,void 0,(function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;s(this,wh,"m",Fh).call(this),s(this,wh,"m",Ch).call(this,Ml.CHANGING);const i=t.requestFullscreen();n(this,Ah,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null},"f"),e.spreadMode===Ll.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),s(this,Ah,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==un.DISABLE&&(s(this,Ah,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){s(this,wh,"m",Oh).call(this),s(this,wh,"m",Ch).call(this,Ml.NORMAL)}return!1}))}get active(){return s(this,yh,"f")===Ml.CHANGING||s(this,yh,"f")===Ml.FULLSCREEN}}yh=new WeakMap,Ah=new WeakMap,_h=new WeakMap,xh=new WeakMap,wh=new WeakSet,Sh=function(t){if(!this.active)return;t.preventDefault();const e=zl(t),i=Date.now(),n=this.mouseScrollTimeStamp;if(!(i>n&&i-n<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&s(this,wh,"m",Lh).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;s(this,wh,"m",Lh).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Ch=function(t){n(this,yh,t,"f"),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Eh=function(){var t;s(this,wh,"m",Ch).call(this,Ml.FULLSCREEN),this.container.classList.add(Bh),setTimeout((()=>{this.pdfViewer.scrollMode=Il.PAGE,null!==s(this,Ah,"f").spreadMode&&(this.pdfViewer.spreadMode=Ll.NONE),this.pdfViewer.currentPageNumber=s(this,Ah,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==s(this,Ah,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:un.NONE})}),0),s(this,wh,"m",Rh).call(this),s(this,wh,"m",kh).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Ph=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(Bh),setTimeout((()=>{s(this,wh,"m",Oh).call(this),s(this,wh,"m",Ch).call(this,Ml.NORMAL),this.pdfViewer.scrollMode=s(this,Ah,"f").scrollMode,null!==s(this,Ah,"f").spreadMode&&(this.pdfViewer.spreadMode=s(this,Ah,"f").spreadMode),this.pdfViewer.currentScaleValue=s(this,Ah,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==s(this,Ah,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:s(this,Ah,"f").annotationEditorMode}),n(this,Ah,null,"f")}),0),s(this,wh,"m",Nh).call(this),s(this,wh,"m",Ih).call(this),s(this,wh,"m",Lh).call(this),this.contextMenuOpen=!1},Mh=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()))},Th=function(){this.contextMenuOpen=!0},kh=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(jh),this.controlsTimeout=setTimeout((()=>{this.container.classList.remove(jh),delete this.controlsTimeout}),3e3)},Ih=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(jh),delete this.controlsTimeout)},Lh=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},Dh=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<=Hh||n>=Math.PI-Hh)?e=i:Math.abs(s)>50&&Math.abs(n-Math.PI/2)<=Hh&&(e=s),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},Rh=function(){if(s(this,xh,"f"))return;n(this,xh,new AbortController,"f");const{signal:t}=s(this,xh,"f"),e=s(this,wh,"m",Dh).bind(this);window.addEventListener("mousemove",s(this,wh,"m",kh).bind(this),{signal:t}),window.addEventListener("mousedown",s(this,wh,"m",Mh).bind(this),{signal:t}),window.addEventListener("wheel",s(this,wh,"m",Sh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",s(this,wh,"m",Lh).bind(this),{signal:t}),window.addEventListener("contextmenu",s(this,wh,"m",Th).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},Nh=function(){var t;null===(t=s(this,xh,"f"))||void 0===t||t.abort(),n(this,xh,null,"f")},Fh=function(){s(this,_h,"f")||(n(this,_h,new AbortController,"f"),window.addEventListener("fullscreenchange",(()=>{document.fullscreenElement?s(this,wh,"m",Eh).call(this):s(this,wh,"m",Ph).call(this)}),{signal:s(this,_h,"f").signal}))},Oh=function(){var t;null===(t=s(this,_h,"f"))||void 0===t||t.abort(),n(this,_h,null,"f")};const zh=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,a={setState:s,getState:n,getInitialState:()=>r,subscribe:t=>(i.add(t),()=>i.delete(t))},r=e=t(s,n,a);return a},Uh={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:Ll.UNKNOWN,scrollMode:Il.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:un.NONE,pdfSlick:null},$h=()=>{return(t=(t,e)=>Object.assign(Object.assign({},Uh),{_setThumbnailView:(i,s)=>{const n=new Map(e().thumbnails),a=new Map(e().thumbnailViews),{canvasWidth:r,canvasHeight:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u=null}=s;a.set(i,s),n.set(i,{pageNumber:i,width:r,height:o,scale:l,rotation:h,loaded:d,pageLabel:c,src:u}),t({thumbnailViews:a,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:a,pageLabel:r,src:o=null}=t;return[t.id,{pageNumber:t.id,width:e,height:i,scale:s,rotation:n,loaded:a,pageLabel:r,src:o}]})));t({thumbnailViews:i,thumbnails:s})}}))?zh(t):zh;var t};var Wh,Gh,qh,Xh,Kh,Yh,Qh,Jh,Zh,td,ed,id,sd,nd,ad,rd,od,ld,hd,dd,cd,ud,pd,gd,fd,md,bd;class vd{constructor({eventBus:t,slick:e,printDialog:i}){Wh.add(this),Gh.set(this,null),qh.set(this,null),Xh.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return vh.instance.supportsPrinting}get printing(){return!!s(this,Gh,"f")}print(){return i(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=s(this,Gh,"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===s(this,Gh,"f")&&this.abort()}))}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}}))}abort(){var t;s(this,Gh,"f")&&(s(this,Gh,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){n(this,qh,new AbortController,"f");const{signal:t}=s(this,qh,"f"),e={signal:t};this.eventBus._on("beforeprint",s(this,Wh,"m",Kh).bind(this),e),this.eventBus._on("afterprint",s(this,Wh,"m",Yh).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=s(this,qh,"f"))||void 0===t||t.abort(),n(this,qh,null,"f")}}Gh=new WeakMap,qh=new WeakMap,Xh=new WeakMap,Wh=new WeakSet,Kh=function(){s(this,Gh,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(n(this,Xh,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()}}}(),"f"),n(this,Gh,vh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:s(this,Xh,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null}),"f"),this.slick.forceRendering(),s(this,Gh,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then((t=>{window.alert(t)})))},Yh=function(){var t,e,i;s(this,Gh,"f")&&(s(this,Gh,"f").destroy(),n(this,Gh,null,"f"),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=s(this,Xh,"f"))||void 0===e||e.remove(),n(this,Xh,null,"f"),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class wd{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 wd(t)}constructor(t){this.dialog=t}open(t){return i(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}))}}gn.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:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href).toString();const yd={"8.5x11":"Letter","8.5x14":"Legal"},Ad={"297x420":"A3","210x297":"A4"};function _d(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}Jh=new WeakMap,Zh=new WeakMap,td=new WeakMap,ed=new WeakMap,id=new WeakMap,sd=new WeakMap,nd=new WeakMap,ad=new WeakMap,rd=new WeakMap,Qh=new WeakSet,od=function(){return i(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,a=0;for(let t=0;t<s;t++){const e=i[t];if(e===(t+1).toString())n++;else{if(""!==e)break;a++}}if(n>=s||a>=s)return;const{viewer:r,thumbnailViewer:o}=this;r.setPageLabels(i),null==o||o.setPageLabels(i)}))},ld=function(){return i(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=>s(this,Qh,"m",hd).call(this,Bl(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:fn.toDateObject(t.CreationDate),modificationDate:fn.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})}))},hd=function(t,e){return i(this,void 0,void 0,(function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=Gl(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},a=_d(s,i,yd)||_d(n,i,Ad);if(!(a||Number.isInteger(n.width)&&Number.isInteger(n.height))){const e={width:25.4*t.width,height:25.4*t.height},r={width:Math.round(n.width),height:Math.round(n.height)};Math.abs(e.width-r.width)<.1&&Math.abs(e.height-r.height)<.1&&(a=_d(r,i,Ad),a&&(s={width:Math.round(r.width/25.4*100)/100,height:Math.round(r.height/25.4*100)/100},n=r))}const[{width:r,height:o},l,h,d]=yield Promise.all([s,this.l10n.get("document_properties_page_size_unit_inches",null),a&&this.l10n.get(`document_properties_page_size_name_${a.toLowerCase()}`,null),this.l10n.get("document_properties_page_size_orientation_"+(i?"portrait":"landscape"),null)]);return{width:r.toLocaleString(),height:o.toLocaleString(),unit:l,name:h,orientation:d}}))},dd=function(){n(this,rd,new AbortController,"f");const{signal:t}=s(this,rd,"f"),e={signal:t};this.eventBus._on("pagesinit",s(this,Qh,"m",cd).bind(this),e),this.eventBus._on("scalechanging",s(this,Qh,"m",fd).bind(this),e),this.eventBus._on("pagechanging",s(this,Qh,"m",md).bind(this),e),this.eventBus._on("pagerendered",s(this,Qh,"m",bd).bind(this),e),this.eventBus._on("rotationchanging",s(this,Qh,"m",ud).bind(this),e),this.eventBus._on("switchspreadmode",s(this,Qh,"m",pd).bind(this),e),this.eventBus._on("switchscrollmode",s(this,Qh,"m",gd).bind(this),e)},cd=function(t){return i(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})}))},ud=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},pd=function({mode:t}){this.store.setState({spreadMode:t})},gd=function({mode:t}){this.store.setState({scrollMode:t})},fd=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},md=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},bd=function({pageNumber:t,error:e}){var i;if(s(this,ed,"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)}},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=Dl,t.PDFSlick=class{constructor({container:t,viewer:e,thumbs:i,store:a=$h(),options:r,onError:o,printDialog:l}){var h,d,c,u,p,g,f,m,b,v,w,y,A,_,x;Qh.add(this),Jh.set(this,void 0),Zh.set(this,void 0),td.set(this,void 0),ed.set(this,void 0),id.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,sd.set(this,void 0),nd.set(this,void 0),ad.set(this,void 0),rd.set(this,void 0),n(this,Zh,t,"f"),n(this,td,e,"f"),n(this,ed,i,"f"),n(this,ad,o,"f"),this.l10n=null!==(h=null==r?void 0:r.l10n)&&void 0!==h?h:new yl(navigator.language),this.downloadManager=new vl,this.textLayerMode=null!==(d=null==r?void 0:r.textLayerMode)&&void 0!==d?d:kl.ENABLE,n(this,sd,null!==(c=null==r?void 0:r.annotationMode)&&void 0!==c?c:pn.ENABLE_FORMS,"f"),n(this,nd,null!==(u=null==r?void 0:r.annotationEditorMode)&&void 0!==u?u:un.NONE,"f"),this.annotationEditorHighlightColors=null!==(p=null==r?void 0:r.annotationEditorHighlightColors)&&void 0!==p?p:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(g=null==r?void 0:r.removePageBorders)&&void 0!==g&&g,this.singlePageViewer=null!==(f=null==r?void 0:r.singlePageViewer)&&void 0!==f&&f,this.enablePrintAutoRotate=null!==(m=null==r?void 0:r.enablePrintAutoRotate)&&void 0!==m&&m,this.useOnlyCssZoom=null!==(b=null==r?void 0:r.useOnlyCssZoom)&&void 0!==b&&b,this.pageColors=null!==(v=null==r?void 0:r.pageColors)&&void 0!==v?v:null,this.maxCanvasPixels=null!==(w=null==r?void 0:r.maxCanvasPixels)&&void 0!==w?w:16777216,this.printResolution=null!==(y=null==r?void 0:r.printResolution)&&void 0!==y?y:96,this.thumbnailWidth=null!==(A=null==r?void 0:r.thumbnailWidth)&&void 0!==A?A:125,this.getDocumentParams=null!==(_=null==r?void 0:r.getDocumentParams)&&void 0!==_?_:{},!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=a;const S=new Yl;S.onIdle=this._cleanup.bind(this),S.isThumbnailViewEnabled=!0,n(this,Jh,S,"f");const C=new wl,E=new _l({eventBus:C,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),P=new Al({eventBus:C,linkService:E}),M=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:C,linkService:E,findController:P,renderingQueue:S,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:s(this,sd,"f"),annotationEditorMode:s(this,nd,"f"),removePageBorders:this.removePageBorders,imageResourcesPath:"/images/"}),T=this.singlePageViewer?new xl(M):new Sl(M);S.setViewer(T),i&&(this.thumbnailViewer=new fh({container:i,eventBus:C,linkService:E,renderingQueue:S,pageColors:this.pageColors,enableHWA:void 0,store:a,thumbnailWidth:this.thumbnailWidth}),S.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new Vh({container:t,pdfViewer:T,eventBus:C})),this.eventBus=C,this.linkService=E,this.findController=P,this.viewer=T,this.linkService.setViewer(T),n(this,id,new vd({eventBus:C,slick:this,printDialog:null!=l?l:wd.create()}),"f");const k=null!==(x=null==r?void 0:r.scaleValue)&&void 0!==x?x:"auto";this.store.setState({scaleValue:k})}loadDocument(t,e){return i(this,void 0,void 0,(function*(){var i,n,a,r,o;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 l=null!==(a=null==e?void 0:e.filename)&&void 0!==a?a:wn(null===(r=this.url)||void 0===r?void 0:r.toString());this.filename=l;const h=vn(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(h.onProgress=e.onProgress);const d=yield h.promise;this.document=d,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(o=this.thumbnailViewer)||void 0===o||o.setDocument(d)),s(this,Qh,"m",dd).call(this),yield s(this,Qh,"m",od).call(this),this.store.setState({filename:l,numPages:d.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const c=yield d.getAttachments(),u=new Map(Object.keys(null!=c?c:{}).sort(((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase()))).map((t=>[t,c[t]])));this.store.setState({attachments:u}),yield s(this,Qh,"m",ld).call(this),this.forceRendering()}catch(t){s(this,ad,"f")&&s(this,ad,"f").call(this,t)}}))}forceRendering(t=!0){s(this,Jh,"f").printing=!!s(this,id,"f").printing,s(this,Jh,"f").isThumbnailViewEnabled=t,s(this,Jh,"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 i(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 i(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 s(this,id,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){s(this,id,"f").print()}unbindEvents(){var t;null===(t=s(this,rd,"f"))||void 0===t||t.abort(),n(this,rd,null,"f"),s(this,id,"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(un.HIGHLIGHT),this.setAnnotationEditorParams([{type:cn.HIGHLIGHT_DEFAULT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){Wl(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){$l(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){Ul(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)}},t.PresentationModeState=Ml,t.ProgressBar=class{constructor(t){pl.set(this,void 0),gl.set(this,null),fl.set(this,0),ml.set(this,void 0),bl.set(this,!0),n(this,pl,t.classList,"f"),n(this,ml,t.style,"f")}get percent(){return s(this,fl,"f")}set percent(t){var e,i,a;n(this,fl,(e=t,i=0,a=100,Math.min(Math.max(e,i),a)),"f"),isNaN(t)?s(this,pl,"f").add("indeterminate"):(s(this,pl,"f").remove("indeterminate"),s(this,ml,"f").setProperty("--progressBar-percent",`${s(this,fl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&s(this,ml,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===s(this,fl,"f")||isNaN(s(this,fl,"f"))||(s(this,gl,"f")&&clearTimeout(s(this,gl,"f")),this.show(),n(this,gl,setTimeout((()=>{n(this,gl,null,"f"),this.hide()}),t),"f"))}hide(){s(this,bl,"f")&&(n(this,bl,!1,"f"),s(this,pl,"f").add("hidden"))}show(){s(this,bl,"f")||(n(this,bl,!0,"f"),s(this,pl,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Pl,t.SCROLLBAR_PADDING=40,t.ScrollMode=Il,t.SidebarView=Tl,t.SpreadMode=Ll,t.TextLayerMode=kl,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=ql,t.apiPageLayoutToViewerModes=function(t){let e=Il.VERTICAL,i=Ll.NONE;switch(t){case"SinglePage":e=Il.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Il.PAGE;case"TwoColumnLeft":i=Ll.ODD;break;case"TwoPageRight":e=Il.PAGE;case"TwoColumnRight":i=Ll.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return Tl.NONE;case"UseThumbs":return Tl.THUMBS;case"UseOutlines":return Tl.OUTLINE;case"UseAttachments":return Tl.ATTACHMENTS;case"UseOC":return Tl.LAYERS}return Tl.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,a=1,r=1,o=1;for(;;){const t=n+r,e=a+o;if(e>8)break;i<=t/e?(r=t,o=e):(n=t,a=e)}return s=i-n/a<r/o-i?i===t?[n,a]:[a,n]:i===t?[r,o]:[o,r],s},t.backtrackBeforeAllVisibleElements=jl,t.binarySearchFirstItem=Ol,t.calcRound=Kl,t.create=$h,t.docStyle=Xl,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=Bl,t.getVisibleElements=Hl,t.initialState=Uh,t.isPortraitOrientation=Gl,t.isValidRotation=Ul,t.isValidScrollMode=$l,t.isValidSpreadMode=Wl,t.normalizeWheelEventDelta=zl,t.normalizeWheelEventDirection=Vl,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 Fl.test(t)?e?t.replaceAll(Fl,(t=>"\0"===t?"":" ")):t.replaceAll("\0",""):t},t.scrollIntoView=Rl,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.watchScroll=Nl}));
22
+ */
23
+ const r=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),a=[.001,0,0,.001,0,0],o=1.35,l=1,h=2,d=4,c=16,u=32,p=64,g=128,m=256,f={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},b="pdfjs_internal_editor_",v={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},w={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},y=1,x=2,A=0,_=1,S=2,C=3,E=3,P=4,T={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},M={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},k=1,D=2,I=3,L=4,R=5,N={ERRORS:0,WARNINGS:1,INFOS:5},F={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},B=0,O=1,j=2,U=3,H=4;let V=N.WARNINGS;function z(t){Number.isInteger(t)&&(V=t)}function $(){return V}function W(t){V>=N.INFOS&&console.info(`Info: ${t}`)}function G(t){V>=N.WARNINGS&&console.warn(`Warning: ${t}`)}function q(t){throw new Error(t)}function X(t,e){t||q(e)}function Y(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 K(t,e,i=!1){const n=URL.parse(t);return n?(n.hash=e,n.href):i&&Y(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function Q(t,e,i,n=!1){return Object.defineProperty(t,e,{value:i,enumerable:!n,configurable:!0,writable:!1}),i}const Z=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class J extends Z{constructor(t,e){super(t,"PasswordException"),this.code=e}}class tt extends Z{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}let et=class extends Z{constructor(t){super(t,"InvalidPDFException")}},it=class extends Z{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}};class nt extends Z{constructor(t){super(t,"FormatError")}}let st=class extends Z{constructor(t){super(t,"AbortException")}};function rt(t){"object"==typeof t&&void 0!==t?.length||q("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 at(t){"string"!=typeof t&&q("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 ot{static get isLittleEndian(){return Q(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return Q(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Q(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Q(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get isFloat16ArraySupported(){return Q(this,"isFloat16ArraySupported","undefined"!=typeof Float16Array)}static get isSanitizerSupported(){return Q(this,"isSanitizerSupported","undefined"!=typeof Sanitizer)}static get platform(){const{platform:t,userAgent:e}=navigator;return Q(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 Q(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const lt=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));let ht=class{static makeHexColor(t,e,i){return`#${lt[t]}${lt[e]}${lt[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 dt=null,ct=null;function ut(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),rt(t)}const pt="pdfjs_internal_id_";function gt(t,e,i){return Math.min(Math.max(t,e),i)}function mt(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(rt(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 ft{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(!ft.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 bt=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&&ft.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&&ft.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 vt="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 yt(t,e="text"){if(Pt(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 xt{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 Q(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 xt({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 ht.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];ht.applyTransform(e,this.transform);const i=[t[2],t[3]];return ht.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return ht.applyInverseTransform(i,this.transform),i}}let At=class extends Z{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}};function _t(t){const e=t.length;let i=0;for(;i<e&&""===t[i].trim();)i++;return"data:"===t.substring(i,i+5).toLowerCase()}function St(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Ct(t,e="document.pdf"){if("string"!=typeof t)return e;if(_t(t))return G('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 Et{started=Object.create(null);times=[];time(t){t in this.started&&G(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||G(`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 Pt(t,e){const i=e?URL.parse(t,e):URL.parse(t);return"http:"===i?.protocol||"https:"===i?.protocol}function Tt(t){t.preventDefault()}function Mt(t){t.preventDefault(),t.stopPropagation()}let kt=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 Dt(t,{scale:e=1,rotation:i=0}){const{width:n,height:s}=t.attributes.style,r=[0,0,parseInt(n),parseInt(s)];return new xt({viewBox:r,userUnit:1,scale:e,rotation:i})}function It(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):(G(`Not a valid color format: "${t}"`),[0,0,0])}function Lt(t){const{a:e,b:i,c:n,d:s,e:r,f:a}=t.getTransform();return[e,i,n,s,r,a]}function Rt(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 Nt(t,e,i=!1,n=!0){if(e instanceof xt){const{pageWidth:n,pageHeight:s}=e.rawDims,{style:r}=t,a=ot.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 Ft=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 Bt=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class Ot{static get isDarkMode(){return Q(this,"isDarkMode",!!window?.matchMedia?.("(prefers-color-scheme: dark)").matches)}}function jt(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 Ut(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 Ht(t){return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function Vt(t,e,i){Ut(t,i),i.map(Ht);const n=.2126*i[0]+.7152*i[1]+.0722*i[2];Ut(e,i),i.map(Ht);const s=.2126*i[0]+.7152*i[1]+.0722*i[2];return n>s?(n+.05)/(s+.05):(s+.05)/(n+.05)}const zt=new Map;function $t({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 bt.render({xfaHtml:t,div:s,intent:"richText"});s.firstChild.classList.add("richText",i),n.append(s)}function Wt(t){const e=new Path2D;if(!t)return e;for(let i=0,n=t.length;i<n;)switch(t[i++]){case B:e.moveTo(t[i++],t[i++]);break;case O:e.lineTo(t[i++],t[i++]);break;case j:e.bezierCurveTo(t[i++],t[i++],t[i++],t[i++],t[i++],t[i++]);break;case U:e.quadraticCurveTo(t[i++],t[i++],t[i++],t[i++]);break;case H:e.closePath();break;default:G(`Unrecognized drawing path operator: ${t[i-1]}`)}return e}class Gt{#n=null;#s=null;#r;#a=null;#o=null;#l=null;#h=null;#d=null;static#c=null;constructor(t){this.#r=t,Gt.#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",Tt,{signal:e}),t.addEventListener("pointerdown",Gt.#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,Mt(t)}#g(t){this.#r._focusEventsAllowed=!0,Mt(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",Tt,{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",Gt.#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 qt{#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",Tt,{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",Tt,{signal:a}),s.addEventListener("click",n,{signal:a})),this.#a.append(s)}}function Xt(t,e,i){for(const n of i)e.addEventListener(n,t[n].bind(t))}class Yt{static#x=NaN;static#A=null;static#_=NaN;static#S=null;static initializeAndAddPointerId(t){(Yt.#A||=new Set).add(t)}static setPointer(t,e){Yt.#x||=e,Yt.#S??=t}static setTimeStamp(t){Yt.#_=t}static isSamePointerId(t){return Yt.#x===t}static isSamePointerIdOrRemove(t){return Yt.#x===t||(Yt.#A?.delete(t),!1)}static isSamePointerType(t){return Yt.#S===t}static isInitializedAndDifferentPointerType(t){return null!==Yt.#S&&!Yt.isSamePointerType(t)}static isSameTimeStamp(t){return Yt.#_===t}static isUsingMultiplePointers(){return Yt.#A?.size>=1}static clearPointerType(){Yt.#S=null}static clearPointerIds(){Yt.#x=NaN,Yt.#A=null}static clearTimeStamp(){Yt.#_=NaN}}class Kt{#C=0;get id(){return`${b}${this.#C++}`}}class Qt{#E=ut();#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 Q(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 yt(e,"blob")):e instanceof File?t=i.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=Qt._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){G(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 Zt{#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 Jt{constructor(t){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ot.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||Mt(e))}}class te{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,It(n))}e.remove()}(t),Q(this,"_colors",t)}convert(t){const e=It(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 te._colorsMapping.get(t);return e}getHexCode(t){const e=this._colors.get(t);return e?ht.makeHexColor(...e):t}}let ee=class t{#R=new AbortController;#N=null;#F=null;#B=new Map;#O=new Map;#j=null;#U=null;#H=null;#V=new Zt;#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 Kt;#ot=!1;#lt=!1;#ht=!1;#dt=null;#ct=null;#ut=null;#pt=null;#gt=null;#mt=v.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};#_t=[0,0];#St=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 Q(this,"_keyboardManager",new Jt([[["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:wt.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.#V.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.#St&&(clearTimeout(this.#St),this.#St=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 Q(this,"hcmFilter",this.#wt?this.#tt.addHCMFilter(this.#wt.foreground,this.#wt.background):"none")}get direction(){return Q(this,"direction",getComputedStyle(this.#Ct).direction)}get _highlightColors(){return Q(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 Q(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 Q(this,"highlightColors",e)}get highlightColorNames(){return Q(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*wt.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===v.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(v.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 qt(this),this.#rt.show(e,i,"ltr"===this.direction))}getAndRemoveDataFromAnnotationStorage(t){if(!this.#U)return null;const e=`${b}${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===v.HIGHLIGHT||this.#mt===v.NONE)&&(this.#mt===v.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#st=this.isShiftKeyDown,!this.isShiftKeyDown)){const t=this.#mt===v.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===v.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}#Ht(){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})}#Vt(){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 G(`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){G(`paste: "${t.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#mt===v.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===v.HIGHLIGHT&&!1===t.hasSelectedEditor&&this.#Wt([[w.HIGHLIGHT_FREE,!0]]))}#Wt(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})}setEditingState(t){t?(this.#Ot(),this.#Ht(),this.#Ft({isEditing:this.#mt!==v.NONE,isEmpty:this.#Gt(),hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:this.#V.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#jt(),this.#Vt(),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===v.POPUP&&this.#z?.hideSidebar(),this.#z?.destroyPopup(),this.#mt=t,t===v.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===v.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===v.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 w.CREATE:return void this.currentLayer.addNewEditor(e);case w.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(w.HIGHLIGHT_SHOW_ALL)??!0)!==e&&this.#Wt([[w.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.#V.undo(),this.#Ft({hasSomethingToUndo:this.#V.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Gt()}),this._editorUndoBar?.hide()}redo(){this.#V.redo(),this.#Ft({hasSomethingToUndo:!0,hasSomethingToRedo:this.#V.hasSomethingToRedo(),isEmpty:this.#Gt()})}addCommands(t){this.#V.add(t),this.#Ft({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Gt()})}cleanUndoStack(t){this.#V.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===v.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.#_t[0]+=t,this.#_t[1]+=e;const[n,s]=this.#_t,r=[...this.#ft];this.#St&&clearTimeout(this.#St),this.#St=setTimeout(()=>{this.#St=null,this.#_t[0]=this.#_t[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!==v.NONE}get imageManager(){return Q(this,"imageManager",new Qt)}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.#H||=new Map).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){this.#H?.delete(t)}renderAnnotationElement(t){const e=this.#H?.get(t.data.id);if(!e)return;const i=this.#U.getRawValue(e);i&&(this.#mt!==v.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 ie{#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,ie.#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){ie._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",ie.#ae.missing),e.setAttribute("data-l10n-id",ie.#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",Tt,{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 ie._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",ie.#ae[this.#oe]),this.#Zt?.setAttribute("data-l10n-id",ie.#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 ne{#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",Tt,{signal:i}),e&&(t.addEventListener("focusin",t=>{this.#r._focusEventsAllowed=!1,Mt(t)},{capture:!0,signal:i}),t.addEventListener("focusout",t=>{this.#r._focusEventsAllowed=!0,Mt(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 se=class t{#Ct;#ve=!1;#we=null;#ye;#xe;#Ae;#_e;#Se=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.#_e=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/Ft.pixelRatio}#Me(t){if(this.#ye?.())return;if(1===t.touches.length){if(this.#Se)return;const t=this.#Se=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.#Se?.abort(),this.#Se=null)};return i.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Mt(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",Mt,i),e.addEventListener("pointermove",Mt,i),e.addEventListener("pointercancel",Mt,i),e.addEventListener("pointerup",Mt,i),this.#xe?.()}if(Mt(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;Mt(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.#_e?.()),this.#Ee&&(Mt(t),this.#Ee=null,this.#ve=!1))}destroy(){this.#Pe?.abort(),this.#Pe=null,this.#Se?.abort(),this.#Se=null}};class re{#Ie=null;#Le=null;#o=null;#l=null;#he=null;#Re=!1;#Ne=null;#Fe="";#Be=null;#Oe=null;#je=null;#Ue=null;#He=null;#Ve="";#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=re._zIndex++;static _borderLineWidth=-1;static _colorManager=new te;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const t=re.prototype._resizeWithKeyboard,e=ee.TRANSLATE_SMALL,i=ee.TRANSLATE_BIG;return Q(this,"_resizerKeyboardManager",new Jt([[["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"],re.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 Q(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ae({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(re._l10n??=t,re._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!==re._borderLineWidth)return;const i=getComputedStyle(document.documentElement);re._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){q("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}=re,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=gt(s,0,i-a),r=gt(r,0,n-o);break;case 90:s=gt(s,0,i-o),r=gt(r,a,n);break;case 180:s=gt(s,a,i),r=gt(r,o,n);break;case 270:s=gt(s,o,i),r=gt(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 re.#ni(t,e,this.parentRotation)}pageTranslationToScreen(t,e){return re.#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",Tt,{signal:e}),t.tabIndex=-1}this.div.prepend(this.#Be)}#ai(t,e){e.preventDefault();const{isMac:i}=ot.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",Mt,{passive:!1,signal:r}),window.addEventListener("contextmenu",Tt,{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=re.MIN_SIZE/i,h=re.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=re._round(s+w[0]),x=re._round(r+w[1]);let A,_,S=1,C=1;if(e.fromKeyboard)({deltaX:A,deltaY:_}=e);else{const{screenX:t,screenY:i}=e,[n,s]=this.#Oe;[A,_]=this.screenToPageTranslation(t-n,i-s),this.#Oe[0]=t,this.#Oe[1]=i}var E,P;if([A,_]=(E=A/i,P=_/n,[u[0]*E+u[2]*P,u[1]*E+u[3]*P]),m){const t=Math.hypot(a,o);S=C=Math.max(Math.min(Math.hypot(v[0]-b[0]-A,v[1]-b[1]-_)/t,1/a,1/o),l/a,h/o)}else f?S=gt(Math.abs(v[0]-b[0]-A),l,1)/a:C=gt(Math.abs(v[1]-b[1]-_),h,1)/o;const T=re._round(a*S),M=re._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 Gt(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||(ie.initialize(re._l10n),this.#o=new ie(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 ne(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 ne(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 ne(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 ne(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),Xt(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#Ze||=new se({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=re.MIN_SIZE/a,p=re.MIN_SIZE/o;n=Math.max(Math.min(n,1/d,1/c),u/d,p/c);const g=re._round(d*n),m=re._round(c*n);if(g===d&&m===c)return;this.#$e||=[l,h,d,c];const f=r(d/2,c/2),b=re._round(l+f[0]),v=re._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}=ot.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}=ot.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 Mt(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",Mt,r),window.addEventListener("pointerdown",t=>{t.pointerType===this.#Fe&&(this.#Ze||t.isPrimary)&&a(t),Mt(t)},r));const o=t=>{this.#Ne&&this.#Ne!==t.pointerId?Mt(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&&re._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.#He||!this.div)return;this.#He=new AbortController;const t=this._uiManager.combinedSignal(this.#He);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.#He?.abort(),this.#He=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[re._round(i+(s-i)*t),re._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",re._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",re._l10nResizer[e])}}this.#wi(0),this.#qe=!0,this.#Be.firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}#fi(t){re._resizerKeyboardManager.exec(this,t)}#bi(t){this.#qe&&t.relatedTarget?.parentNode!==this.#Be&&this.#ei()}#vi(t){this.#Ve=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.#Ve,{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)},re._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 ae extends re{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const oe=3285377520,le=4294901760,he=65535;class de{constructor(t){this.h1=t?4294967295&t:oe,this.h2=t?4294967295&t:oe}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&le|a*u&he,a=a<<15|a>>>17,a=a*c&le|a*p&he,l^=a,l=l<<13|l>>>19,l=5*l+3864292196):(o=r[t],o=o*d&le|o*u&he,o=o<<15|o>>>17,o=o*c&le|o*p&he,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&le|a*u&he,a=a<<15|a>>>17,a=a*c&le|a*p&he,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&le|36045*t&he,e=4283543511*e&le|(2950163797*(e<<16|t>>>16)&le)>>>16,t^=e>>>1,t=444984403*t&le|60499*t&he,e=3301882366*e&le|(3120437893*(e<<16|t>>>16)&le)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const ce=Object.freeze({map:null,hash:"",transfer:void 0});class ue{#yi=!1;#xi=null;#Ai=null;#_i=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=this.#_i.get(t);return void 0===i?e:Object.assign(e,i)}getRawValue(t){return this.#_i.get(t)}remove(t){const e=this.#_i.get(t);if(void 0!==e&&(e instanceof re&&this.#Ai.delete(e.annotationElementId),this.#_i.delete(t),0===this.#_i.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor)){for(const t of this.#_i.values())if(t instanceof re)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=this.#_i.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.#_i.set(t,e);n&&this.#Si(),e instanceof re&&((this.#Ai||=new Map).set(e.annotationElementId,e),"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type))}has(t){return this.#_i.has(t)}get size(){return this.#_i.size}#Si(){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 pe(this)}get serializable(){if(0===this.#_i.size)return ce;const t=new Map,e=new de,i=[],n=Object.create(null);let s=!1;for(const[i,r]of this.#_i){const a=r instanceof re?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}:ce}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const s of this.#_i.values()){if(!(s instanceof re)){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.#_i.entries()}}class pe extends ue{#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(){q("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#Ci}get modifiedIds(){return Q(this,"modifiedIds",{ids:new Set,hash:""})}}class ge{#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(X(!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{G(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(r)}return}q("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 G(`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 Q(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){return Q(this,"isSyncFontLoadingSupported",r||ot.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,i={done:!1,complete:function(){for(X(!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 Q(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 G("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 me{#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,${mt(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){G(`getPathGenerator - ignoring character: "${t}".`)}const s=Wt(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 fe{#Ti;#Mi;#ki;static strings=["fontFamily","fontWeight","italicAngle"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of fe.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 fe.strings){const e=i[t],n=e.length;a.setUint32(o,n),r.set(e,o+4),o+=4+n}return X(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){X(t<fe.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 be{#Ti;#Mi;#ki;static strings=["css","loadedName","baseFontName","src"];static write(t){const e=new TextEncoder,i={};let n=0;for(const s of be.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 be.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),X(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){X(t<be.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 ve{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){X(t<ve.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 X(t<ve.numbers.length,"Invalid number index"),this.#Mi.getFloat64(ve.#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=ve.#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=ve.#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=ve.#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){X(t<ve.strings.length,"Invalid string index");let e=ve.#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=ve.#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=ve.#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=ve.#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 fe(i.buffer)}get systemFontInfo(){let t=ve.#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 be(i.buffer)}static write(t){const e=t.systemFontInfo?be.write(t.systemFontInfo):null,i=t.cssFontInfo?fe.write(t.cssFontInfo):null,n=new TextEncoder,s={};let r=0;for(const e of ve.strings)s[e]=n.encode(t[e]),r+=4+s[e].length;const a=ve.#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=ve.bools.length;let u=0,p=0;for(let e=0;e<c;e++){const i=t[ve.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)}X(d===ve.#Ii,"FontInfo.write: Boolean properties offset mismatch");for(const e of ve.numbers)h.setFloat64(d,t[e]),d+=8;if(X(d===ve.#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(X(d===ve.#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(X(d===ve.#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;X(d===ve.#Fi,"FontInfo.write: DefaultVMetrics properties offset mismatch"),h.setUint32(ve.#Fi,0),d+=4;for(const t of ve.strings){const e=s[t],i=e.length;h.setUint32(d,i),l.set(e,d+4),d+=4+i}if(h.setUint32(ve.#Fi,d-ve.#Fi-4),e){const t=e.byteLength;h.setUint32(d,t),X(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),X(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),X(d<=o.byteLength,"FontInfo.write: Buffer overflow"),o.transferToFixedLength(d)}}class we{static#ji=0;static#Ui=1;static#Hi=2;static#Vi=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(we.#ji,e),m.setUint8(we.#Ui,i?1:0),m.setUint8(we.#Hi,l?1:0),m.setUint8(we.#Vi,o),m.setUint32(we.#zi,h,!0),m.setUint32(we.#$i,d,!0),m.setUint32(we.#Wi,c,!0),m.setUint32(we.#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[we.#ji],i=!!this.data[we.#Ui],n=!!this.data[we.#Hi],s=t.getUint32(we.#zi,!0),r=t.getUint32(we.#$i,!0),a=t.getUint32(we.#Wi,!0),o=t.getUint32(we.#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===x&&(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[we.#Vi];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 ye(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const xe=t=>"object"==typeof t&&Number.isInteger(t?.num)&&t.num>=0&&Number.isInteger(t?.gen)&&t.gen>=0,Ae=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,xe,t=>"object"==typeof t&&"string"==typeof t?.name);class _e{#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 G("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 Se=1,Ce=2,Ee=1,Pe=2,Te=3,Me=4,ke=5,De=6,Ie=7,Le=8;function Re(){}function Ne(t){if(t instanceof st||t instanceof et||t instanceof J||t instanceof it||t instanceof tt)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||q('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new st(t.message);case"InvalidPDFException":return new et(t.message);case"PasswordException":return new J(t.message,t.code);case"ResponseException":return new it(t.message,t.status,t.missing);case"UnknownErrorException":return new tt(t.message,t.details)}return new tt(t.message,t.toString())}class Fe{#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===Se)i.resolve(t.data);else{if(t.callback!==Ce)throw new Error("Unexpected callback case");i.reject(Ne(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:Se,callbackId:t.callbackId,data:e})},function(e){s.postMessage({sourceName:i,targetName:n,callback:Ce,callbackId:t.callbackId,reason:Ne(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:De,streamId:s,desiredSize:t.desiredSize}),e.promise},cancel:t=>{X(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:Ee,streamId:s,reason:Ne(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:Me,streamId:e,chunk:t},a)},close(){this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:Te,streamId:e}),delete r.streamSinks[e])},error(t){X(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,s.postMessage({sourceName:i,targetName:n,stream:ke,streamId:e,reason:Ne(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:Le,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:Le,streamId:e,reason:Ne(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 Le:t.success?r.startCall.resolve():r.startCall.reject(Ne(t.reason));break;case Ie:t.success?r.pullCall.resolve():r.pullCall.reject(Ne(t.reason));break;case De:if(!a){s.postMessage({sourceName:i,targetName:n,stream:Ie,streamId:e,success:!0});break}a.desiredSize<=0&&t.desiredSize>0&&a.sinkCapability.resolve(),a.desiredSize=t.desiredSize,Promise.try(a.onPull||Re).then(function(){s.postMessage({sourceName:i,targetName:n,stream:Ie,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:Ie,streamId:e,reason:Ne(t)})});break;case Me:if(X(r,"enqueue should have stream controller"),r.isClosed)break;r.controller.enqueue(t.chunk);break;case Te:if(X(r,"close should have stream controller"),r.isClosed)break;r.isClosed=!0,r.controller.close(),this.#Ji(r,e);break;case ke:X(r,"error should have stream controller"),r.controller.error(Ne(t.reason)),this.#Ji(r,e);break;case Pe:t.success?r.cancelCall.resolve():r.cancelCall.reject(Ne(t.reason)),this.#Ji(r,e);break;case Ee:if(!a)break;const o=Ne(t.reason);Promise.try(a.onCancel||Re,o).then(function(){s.postMessage({sourceName:i,targetName:n,stream:Pe,streamId:e,success:!0})},function(t){s.postMessage({sourceName:i,targetName:n,stream:Pe,streamId:e,reason:Ne(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 Be{#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){q("Abstract method `_createCanvas` called.")}}class Oe extends Be{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 je{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){q("Abstract method `_fetch` called.")}}class Ue extends je{async _fetch(t){const e=await yt(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):at(e)}}class He{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 Ve extends He{#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(vt,"svg");i.setAttribute("width",0),i.setAttribute("height",0),this.#nn=this.#rn.createElementNS(vt,"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&&(_t(t)?G('#createUrl: ignore "data:"-URL for performance reasons.'):this.#en=K(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=ht.makeHexColor(...r);const a=this.#pn(e);if(e=ht.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(vt,"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(vt,"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(vt,"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(vt,e);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),t.append(n)}#un(t,e,i,n){const s=this.#rn.createElementNS(vt,"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(vt,"feComponentTransfer");e.append(i),this.#bn(i,"feFuncA",t)}#pn(t){return this.#ln.style.color=t,It(getComputedStyle(this.#ln).getPropertyValue("color"))}}class ze{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){q("Abstract method `_fetch` called.")}}class $e extends ze{async _fetch(t){const e=await yt(t,"arraybuffer");return new Uint8Array(e)}}class We{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){q("Abstract method `_fetch` called.")}}class Ge extends We{async _fetch(t){const e=await yt(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)}r&&G("Please use the `legacy` build in Node.js environments.");class Xe extends He{}class Ye extends Be{_createCanvas(t,i){return process.getBuiltinModule("module").createRequire("undefined"==typeof document&&"undefined"==typeof location?require("url").pathToFileURL(__filename).href:"undefined"==typeof document?location.href:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,i)}}class Ke extends je{async _fetch(t){return qe(t)}}class Qe extends ze{async _fetch(t){return qe(t)}}class Ze extends We{async _fetch(t){return qe(t)}}const Je="__forcedDependency",{floor:ti,ceil:ei}=Math;function ii(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 ni=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class si{#vn;#wn;constructor(t,e){this.#vn=t,this.#wn=e}get length(){return this.#vn.length}isEmpty(t){return this.#vn[t]===ni}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 ri=(t,e)=>{if(!t)return;let i=t.get(e);return i||(i={dependencies:new Set,isRenderingOperation:!1},t.set(e,i)),i};class ai{#yn={__proto__:null};#xn={__proto__:null,transform:[],moveText:[],sameLineText:[],[Je]:[]};#An=new Map;#_n=[];#Sn=[];#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(ni,e.length)):this.#vn.fill(ni)}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},[Je]:{__proto__:this.#xn[Je]}},this.#En={__proto__:this.#En},this.#_n.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.#_n.pop();return void 0!==i&&(ri(this.#Nn,t)?.dependencies.add(i),this.#vn[t]=this.#vn[i]),this}recordOpenMarker(t){return this.#_n.push(t),this}getOpenMarker(){return 0===this.#_n.length?null:this.#_n.at(-1)}recordCloseMarker(t){const e=this.#_n.pop();return void 0!==e&&(ri(this.#Nn,t)?.dependencies.add(e),this.#vn[t]=this.#vn[e]),this}beginMarkedContent(t){return this.#Sn.push(t),this}endMarkedContent(t){const e=this.#Sn.pop();return void 0!==e&&(ri(this.#Nn,t)?.dependencies.add(e),this.#vn[t]=this.#vn[e]),this}pushBaseTransform(t){return this.#Cn.push(ht.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(Je,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(Je,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=ht.multiplyByDOMMatrix(this.#Cn.at(-1),e.getTransform()),o=[1/0,1/0,-1/0,-1/0];ht.axialAlignedBoundingBox([i,s,n,r],a,o);const l=ht.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=ht.multiplyByDOMMatrix(this.#Cn.at(-1),e.getTransform());if(a[0]===-1/0)return ht.axialAlignedBoundingBox([i,s,n,r],o,this.#Pn),this;const l=[1/0,1/0,-1/0,-1/0];return ht.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],ht.axialAlignedBoundingBox(o,i.fontMatrix,h),1===n&&0===s&&0===r||ht.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,[Je]),this.#Nn){const e=ri(this.#Nn,t),{dependencies:i}=e;this.#Mn.forEach(i.add,i),this.#_n.forEach(i.add,i),this.#Sn.forEach(i.add,i),i.delete(t),e.isRenderingOperation=!0}if(this.#Tn===t){const i=ti(256*this.#Pn[0]/this.#In),n=ti(256*this.#Pn[1]/this.#Ln),s=ei(256*this.#Pn[2]/this.#In),r=ei(256*this.#Pn[3]/this.#Ln);ii(this.#Rn,t,i,n,s,r);for(const e of this.#Mn)e!==t&&ii(this.#Rn,e,i,n,s,r);for(const e of this.#_n)e!==t&&ii(this.#Rn,e,i,n,s,r);for(const e of this.#Sn)e!==t&&ii(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 si(this.#vn,this.#Rn)}takeDebugMetadata(){return this.#Nn}}class oi{#Bn;#On;#jn;#Un=0;#Hn=0;constructor(t,e,i){if(t instanceof oi&&t.#jn===!!i)return t;this.#Bn=t,this.#On=e,this.#jn=!!i}growOperationsCount(){throw new Error("Unreachable")}save(t){return this.#Hn++,this.#Bn.save(this.#On),this}restore(t){return this.#Hn>0&&(this.#Bn.restore(this.#On),this.#Hn--),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 li=["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],hi=["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],di=["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],ci=["filter","fillColor","fillAlpha"],ui=["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],pi=["transform"],gi=["transform","fillColor"],mi="Fill",fi="Stroke",bi="Shading";function vi(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 wi{isModifyingCurrentTransform(){return!1}getPattern(){q("Abstract method `getPattern` called.")}}class yi extends wi{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===fi||n===mi){const r=e.current.getClippedPathBoundingBox(n,Lt(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=ht.transform(i,[1,0,0,1,r[0],r[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),vi(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 vi(t,this._bbox),s=this._createGradient(t);return s}}function xi(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],_=h[a+1],S=h[a+2],C=h[o],E=h[o+1],P=h[o+2],T=Math.round(g),M=Math.round(v);let k,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-_)*e,L=x-(x-S)*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=_-(_-E)*e,L=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,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 Ai(t,e,i){const n=e.coords,s=e.colors;let r,a;switch(e.type){case x: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++)xi(t,i,n[e],n[e+1],n[e+o],s[e],s[e+1],s[e+o]),xi(t,i,n[e+o+1],n[e+1],n[e+o],s[e+o+1],s[e+1],s[e+o])}break;case y:for(r=0,a=n.length;r<a;r+=3)xi(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 _i extends wi{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)Ai(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){vi(t,this._bbox);const s=new Float32Array(2);if(n===bi)ht.singularValueDecompose2dScale(Lt(t),s);else if(this.matrix){ht.singularValueDecompose2dScale(this.matrix,s);const[t,i]=s;ht.singularValueDecompose2dScale(e.baseTransform,s),s[0]*=t,s[1]*=i}else ht.singularValueDecompose2dScale(e.baseTransform,s);const r=this._createMeshCanvas(s,n===bi?null:this._background,e.cachedCanvases);return n!==bi&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(r.offsetX,r.offsetY),t.scale(r.scaleX,r.scaleY),t.createPattern(r.canvas,"no-repeat")}}class Si extends wi{getPattern(){return"hotpink"}}const Ci=1,Ei=2;class Pi{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),W("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);ht.singularValueDecompose2dScale(this.matrix,f);const[b,v]=f;ht.singularValueDecompose2dScale(this.baseTransform,f);const w=b*f[0],y=v*f[1];let x=g,A=m,_=!1,S=!1;const C=Math.ceil(l*w),E=Math.ceil(h*y);C>=Math.ceil(g*w)?x=l:_=!0,E>=Math.ceil(m*y)?A=h:S=!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=Lt(D.ctx),D.executeOperatorList(n),D.endDrawing(),D.dependencyTracker?.restore(),k.restore(),_||S){const e=M.canvas;_&&(x=l),S&&(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=_?Math.floor(g/l):0,p=S?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(Pi.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),ht.axialAlignedBoundingBox([e,i,n,s],Lt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,s=t.current;switch(e){case Ci:const{fillStyle:t,strokeStyle:r}=this.ctx;n.fillStyle=s.fillColor=t,n.strokeStyle=s.strokeColor=r;break;case Ei:n.fillStyle=n.strokeStyle=i,s.fillColor=s.strokeColor=i;break;default:throw new nt(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,s){let r=i;n!==bi&&(r=ht.transform(r,e.baseTransform),this.matrix&&(r=ht.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 Ti({src:t,srcPos:e=0,dest:i,width:n,height:s,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=ot.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 Mi=16,ki=new DOMMatrix,Di=new Float32Array(2),Ii=new Float32Array([1/0,1/0,-1/0,-1/0]);class Li{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 Ri(t,e,i,n,s,r,a,o,l,h){const[d,c,u,p,g,m]=Lt(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,_=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,_),t.setTransform(d,c,u,p,g,m),[x,_]}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,_=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,_,x),t.setTransform(d,c,u,p,g,m),[_,x]}t.drawImage(e,i,n,s,r,a,o,l,h);return[Math.hypot(d,c)*l,Math.hypot(u,p)*h]}class Ni{alphaIsShape=!1;fontSize=0;fontSizeScale=1;textMatrix=null;textMatrixScale=1;fontMatrix=a;leading=0;x=0;y=0;lineX=0;lineY=0;charSpacing=0;wordSpacing=0;textHScale=1;textRenderingMode=A;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=Ii.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=mi,e=null){const i=this.minMax.slice();if(t===fi){e||q("Stroke bounding box must include transform."),ht.singularValueDecompose2dScale(e,Di);const t=Di[0]*this.lineWidth/2,n=Di[1]*this.lineWidth/2;i[0]-=t,i[1]-=n,i[2]+=t,i[3]+=n}return i}updateClipFromPath(){const t=ht.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(Ii,0)}getClippedPathBoundingBox(t=mi,e=null){return ht.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Fi(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const i=e.height,n=e.width,s=i%Mi,r=(i-s)/Mi,a=0===s?r:r+1,o=t.createImageData(n,Mi);let l,h=0;const d=e.data,c=o.data;let u,p,g,m;if(e.kind===T.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=ot.isLittleEndian?4278190080:255;for(u=0;u<a;u++){for(g=u<r?Mi: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*Mi)}}else if(e.kind===T.RGBA_32BPP){for(p=0,m=n*Mi*4,u=0;u<r;u++)c.set(d.subarray(h,h+m)),h+=m,t.putImageData(o,0,p),p+=Mi;u<a&&(m=n*s*4,c.set(d.subarray(h,h+m)),t.putImageData(o,0,p))}else{if(e.kind!==T.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Mi,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*Mi)}}}function Bi(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const i=e.height,n=e.width,s=i%Mi,r=(i-s)/Mi,a=0===s?r:r+1,o=t.createImageData(n,Mi);let l=0;const h=e.data,d=o.data;for(let e=0;e<a;e++){const i=e<r?Mi:s;({srcPos:l}=Ti({src:h,srcPos:l,dest:d,width:n,height:i,nonBlackColor:0})),t.putImageData(o,0,e*Mi)}}function Oi(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 ji(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 Ui(t,e){if(e)return!0;ht.singularValueDecompose2dScale(t,Di);const i=Math.fround(Ft.pixelRatio*wt.PDF_TO_CSS_UNITS);return Di[0]<=i&&Di[1]<=i}const Hi=["butt","round","square"],Vi=["miter","round","bevel"],zi={},$i={};class Wi{constructor(t,e,i,n,s,{optionalContentConfig:r,markedContentStack:a=null},o,l,h){this.ctx=t,this.current=new Ni(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 Li(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(...Lt(this.compositeCtx))}this.ctx.save(),ji(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=Lt(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!==F.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}}}#Vn(){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.#Vn(),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=Lt(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,gi),{canvas:n,offsetX:e,offsetY:i}}d=n}d||(c=this.cachedCanvases.getCanvas("maskCanvas",n,s),Bi(c.context,e));let u=ht.transform(o,[1/n,0,0,-1/s,0,0]);u=ht.transform(u,[1,0,0,1,0,-s]);const p=Ii.slice();ht.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,_=m;x.translate(-A,-_),x.transform(...u),d||(d=this._scaleImage(c.canvas,Rt(x)),d=d.img,l&&a&&l.set(h,d)),x.imageSmoothingEnabled=Ui(Lt(x),e.interpolate),Ri(x,d,0,0,d.width,d.height,0,0,n,s),x.globalCompositeOperation="source-in";const S=ht.transform(Rt(x),[1,0,0,1,-A,-_]);return x.fillStyle=a?r.getPattern(i,this,S,mi,t):r,x.fillRect(0,0,n,s),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,y.canvas)),this.dependencyTracker?.recordDependencies(t,gi),{canvas:y.canvas,offsetX:Math.round(A),offsetY:Math.round(_)}}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=Hi[e]}setLineJoin(t,e){this.dependencyTracker?.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Vi[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()),Oi(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(),Oi(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&&Oi(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&&Oi(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===F.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]=Wt(s)),ht.axialAlignedBoundingBox(n,Lt(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,Rt(n),fi,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,li),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(fi,Lt(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,Rt(n),mi,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,hi),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,ci).recordOperation(t)}clip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=zi}eoClip(t){this.dependencyTracker?.recordFutureForcedDependency("clipMode",t),this.pendingClip=$i}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||a,0!==s.fontMatrix[0]&&0!==s.fontMatrix[3]||G("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",o=n.systemFontInfo?.css||`"${r}", ${n.fallbackName}`;let l="normal";n.black?l="900":n.bold&&(l="bold");const h=n.italic?"italic":"normal";let d=i;i<16?d=16:i>100&&(d=100),this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${l} ${d}px ${o}`}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&E,u=!!(h&P),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===A||c===S)if(s){e=a.getTransform(),a.setTransform(...s);const t=this.#$n(m,e,s);a.fill(t)}else a.fill(m);if(c===_||c===S)if(r){e||=a.getTransform(),a.setTransform(...r);const{a:t,b:i,c:n,d:s}=e,o=ht.inverseTransform(r),l=ht.transform([t,i,n,s,0,0],o);ht.singularValueDecompose2dScale(l,Di),a.lineWidth*=Math.max(Di[0],Di[1])/d,a.stroke(this.#$n(m,e,r))}else a.lineWidth/=d,a.stroke(m);a.restore()}else c!==A&&c!==S||(a.fillText(e,i,n),this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,n,()=>a.measureText(e))),c!==_&&c!==S||(this.dependencyTracker&&this.dependencyTracker?.recordCharacterBBox(t,a,l,d,i,n,()=>a.measureText(e)).recordDependencies(t,li),a.strokeText(e,i,n));if(u){(this.pendingTextPaths||=[]).push({transform:Lt(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 Q(this,"isFontSubpixelAAEnabled",i)}showText(t,e){this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,ui).resetBBox(t),this.current.textRenderingMode&P&&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===A&&!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,Rt(r),mi,t);b=Lt(r),r.restore(),r.fillStyle=e}if(i.patternStroke){r.save();const e=i.strokeColor.getPattern(r,this,Rt(r),fi,t);v=Lt(r),r.restore(),r.strokeStyle=e}let w=i.lineWidth;const y=i.textMatrixScale;if(0===y||0===w){const t=i.textRenderingMode&E;t!==_&&t!==S||(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,C=0;for(x=0;x<c;++x){const i=e[x];if("number"==typeof i){C+=p*i*s/1e3;continue}let d=!1;const c=(i.isSpace?l:0)+o,w=i.fontChar,y=i.accent;let A,_,S,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,A=e/a,_=(C+n)/a}else A=C/a,_=0;if(n.remeasure&&E>0){S=r.measureText(w);const t=1e3*S.width/s*a;if(E<t&&this.isFontSubpixelAAEnabled){const e=E/t;d=!0,r.save(),r.scale(e,1),A/=e}else E!==t&&(A+=(E-t)/2e3*s/a)}if(this.contentVisible&&(i.isInFont||n.missingFile))if(f&&!y)r.fillText(w,A,_),this.dependencyTracker?.recordCharacterBBox(t,r,S?{bbox:null}:n,s/a,A,_,()=>S??r.measureText(w));else if(this.paintChar(t,w,A,_,b,v),y){const e=A+s*y.offset.x/a,i=_-s*y.offset.y/a;this.paintChar(t,y.fontChar,e,i,b,v)}C+=u?E*m-c*h:E*m+c*h,d&&r.restore()}u?i.y-=C:i.x+=C*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,o=n.fontDirection,l=s.vertical?1:-1,h=n.charSpacing,d=n.wordSpacing,c=n.textHScale*o,u=n.fontMatrix||a,p=e.length;let g,m,f,b;if(n.textRenderingMode===C||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(c,o);const v=this.dependencyTracker;for(this.dependencyTracker=v?new oi(v,t):null,g=0;g<p;++g){if(m=e[g],"number"==typeof m){b=l*m*r/1e3,this.ctx.translate(b,0),n.x+=b*c;continue}const t=(m.isSpace?d:0)+h,a=s.charProcOperatorList[m.operatorListId];a?this.contentVisible&&(this.save(),i.scale(r,r),i.transform(...u),this.executeOperatorList(a),this.restore()):G(`Type3 character "${m.operatorListId}" is not available.`);const o=[m.width,0];ht.applyTransform(o,u),f=o[0]*r+t,i.translate(f,0),n.x+=f*c}i.restore(),v&&(this.dependencyTracker=v)}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||Lt(this.ctx),n={createCanvasGraphics:(t,e)=>new Wi(t,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new oi(this.dependencyTracker,e,!0):null)};i=new Pi(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 yi(t);case"Mesh":return new _i(t);case"Dummy":return new Si}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,Rt(i),bi,t);const s=Rt(i);if(s){const{width:t,height:e}=i.canvas,n=Ii.slice();ht.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,pi).recordDependencies(t,hi).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){q("Should not call beginInlineImage")}beginImageData(){q("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=Lt(this.ctx),i)){ht.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||W("TODO: Support non-isolated groups."),e.knockout&&G("Knockout groups not supported.");const n=Lt(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let s=Ii.slice();ht.axialAlignedBoundingBox(e.bbox,Lt(i),s);const r=[0,0,i.canvas.width,i.canvas.height];s=ht.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()),Oi(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=Lt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...e);const n=Ii.slice();ht.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.#Vn(),ji(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,ht.singularValueDecompose2dScale(Lt(this.ctx),Di);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(Di[0],0,0,-Di[1],0,a*Di[1]),ji(this.ctx)}else{ji(this.ctx),this.endPath(t);const e=new Path2D;e.rect(i[0],i[1],s,a),this.ctx.clip(e)}}this.current=new Ni(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=Lt(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=ht.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,gi);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();Bi(d,this.getObject(t,e,r)),d.globalCompositeOperation="source-in",d.fillStyle=s?n.getPattern(d,this,Rt(i),mi,t):n,d.fillRect(0,0,a,o),d.restore(),i.save(),i.transform(...l),i.scale(1,-1),Ri(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):G("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 G("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;Fi(t,e),a=this.applyTransferMapsToCanvas(t)}const o=this._scaleImage(a,Rt(s));s.imageSmoothingEnabled=Ui(Lt(s),e.interpolate),this.dependencyTracker?.resetBBox(t).recordBBox(t,s,0,i,-n,0).recordDependencies(t,di).recordOperation(t),Ri(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;Fi(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),Ri(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,hi).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===$i?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=Lt(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),ki.a=1/s,ki.d=1/r;const o=new Path2D;if(o.addPath(t,ki),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 F)void 0!==Wi.prototype[t]&&(Wi.prototype[F[t]]=Wi.prototype[t]);let Gi=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 qi{#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 Xi=Symbol("INTERNAL");class Yi{#Yn=!1;#Kn=!1;#Qn=!1;#Zn=!0;constructor(t,{name:e,intent:i,usage:n,rbGroups:s}){this.#Yn=!!(t&h),this.#Kn=!!(t&d),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!==Xi&&q("Internal method `_setVisible` called."),this.#Qn=i,this.#Zn=e}}class Ki{#Jn=null;#ts=new Map;#es=null;#is=null;constructor(t,e=h){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 Yi(e,i));if("OFF"===t.baseState)for(const t of this.#ts.values())t._setVisible(Xi,!1);for(const e of t.on)this.#ts.get(e)._setVisible(Xi,!0);for(const e of t.off)this.#ts.get(e)._setVisible(Xi,!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 G(`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 W("Optional content group not defined."),!0;if("OCG"===t.type)return this.#ts.has(t.id)?this.#ts.get(t.id).visible:(G(`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 G(`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 G(`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 G(`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 G(`Optional content group not found: ${e}`),!0;if(this.#ts.get(e).visible)return!1}return!0}return G(`Unknown optional content policy ${t.policy}.`),!0}return G(`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(Xi,!1,!0);n._setVisible(Xi,!!e,!0),this.#Jn=null}else G(`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 de;for(const[e,i]of this.#ts)t.update(`${e}:${i.visible}`);return this.#Jn=t.hexdigest()}[Symbol.iterator](){return this.#ts.entries()}}class Qi{constructor(t,{disableRange:e=!1,disableStream:i=!1}){X(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{X(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(){X(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Zi(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new Ji(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 Zi{constructor(t,e,i=!1,n=null){this._stream=t,this._done=i||!1,this._filename=St(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 Ji{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 tn(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 en(t){return URL.parse(t)?.origin??null}function nn({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 sn(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=at(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(St(t))return t}return null}function rn(t,e){return new it(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function an(t){return 200===t||206===t}function on(t,e,i){return{method:"GET",headers:t,signal:i.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function ln(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:(G(`getArrayBuffer - unexpected data format: ${t}`),new Uint8Array(t).buffer)}class hn{_responseOrigin=null;constructor(t){this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=tn(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return X(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new dn(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new cn(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 dn{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,on(i,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=en(e.url),!an(e.status))throw rn(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();const i=e.headers,{allowRangeRequests:s,suggestedLength:r}=nn({responseHeaders:i,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=s,this._contentLength=r||this._contentLength,this._filename=sn(i),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new st("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:ln(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class cn{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,on(s,this._withCredentials,this._abortController)).then(e=>{const i=en(e.url);if(i!==t._responseOrigin)throw new Error(`Expected range response-origin "${i}" to match "${t._responseOrigin}".`);if(!an(e.status))throw rn(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:ln(t),done:!1})}cancel(t){this._reader?.cancel(t),this._abortController.abort()}}class un{_responseOrigin=null;constructor({url:t,httpHeaders:e,withCredentials:i}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=tn(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",X(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:at(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}):(G('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 pn{constructor(t){this._source=t,this._manager=new un(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 X(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new gn(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new mn(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 gn{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=en(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}=nn({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});s&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=sn(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=rn(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 mn{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=en(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??=rn(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 fn=/^[a-z][a-z0-9\-+.]+:/i;class bn{constructor(t){this.source=t,this.url=function(t){if(fn.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),X("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return X(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new vn(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new wn(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 vn{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=rn(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 st("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class wn{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 yn=Symbol("INITIAL_DATA");class xn{#ss=Object.create(null);#rs(t){return this.#ss[t]||={...Promise.withResolvers(),data:yn}}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===yn)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!==yn}delete(t){const e=this.#ss[t];return!(!e||e.data===yn)&&(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!==yn&&(yield[t,e])}}}let An=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#_s=new Map;static#Ss=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*Ft.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(),Nt(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}=ot.platform;return Q(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*Ft.pixelRatio,s=e.rotation;if(s!==this.#ms&&(i?.(),this.#ms=s,Nt(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 st("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 G("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=ht.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.#_s.clear();for(const{canvas:t}of this.#Ss.values())t.remove();this.#Ss.clear()}}static#ks(t=null){let e=this.#Ss.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.#Ss.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.#_s.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):(ot.platform.isFirefox&&G("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.#_s.set(t,l),l}};function _n(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new Sn,{docId:i}=e,n=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(r)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(r&&"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 at(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,a=t.httpHeaders||null,o=!0===t.withCredentials,l=t.password??null,h=t.range instanceof Cn?t.range:null,d=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof Tn?t.worker:null;const u=t.verbosity,p="string"!=typeof t.docBaseUrl||_t(t.docBaseUrl)?null:t.docBaseUrl,g=ye(t.cMapUrl),m=!1!==t.cMapPacked,f=t.CMapReaderFactory||(r?Ke:Ue),b=ye(t.iccUrl),v=ye(t.standardFontDataUrl),w=t.StandardFontDataFactory||(r?Qe:$e),y=ye(t.wasmUrl),x=t.WasmFactory||(r?Ze:Ge),A=!0!==t.stopAtErrors,_=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,S=!1!==t.isEvalSupported,C="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!r,E="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!r&&(ot.platform.isFirefox||!globalThis.chrome),P=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,T="boolean"==typeof t.disableFontFace?t.disableFontFace:r,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||(r?Ye:Oe),B=t.FilterFactory||(r?Xe:Ve),O=!0===t.enableHWA,j=!1!==t.useWasm,U=h?h.length:t.length??NaN,H="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!r&&!T,V="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===Ue&&w===$e&&x===Ge&&g&&v&&y&&Pt(g,document.baseURI)&&Pt(v,document.baseURI)&&Pt(y,document.baseURI));z(u);const $={canvasFactory:new F({ownerDocument:D,enableHWA:O}),filterFactory:new B({docId:i,ownerDocument:D}),cMapReaderFactory:V?null:new f({baseUrl:g,isCompressed:m}),standardFontDataFactory:V?null:new w({baseUrl:v}),wasmFactory:V?null:new x({baseUrl:y})};c||(c=Tn.create({verbosity:u,port:Gi.workerPort}),e._worker=c);const W={docId:i,apiVersion:"5.4.394",data:s,password:l,disableAutoFetch:R,rangeChunkSize:d,length:U,docBaseUrl:p,enableXfa:k,evaluatorOptions:{maxImageSize:_,disableFontFace:T,ignoreErrors:A,isEvalSupported:S,isOffscreenCanvasSupported:C,isImageDecoderSupported:E,canvasMaxAreaInBytes:P,fontExtraProperties:M,useSystemFonts:H,useWasm:j,useWorkerFetch:V,cMapUrl:g,iccUrl:b,standardFontDataUrl:v,wasmUrl:y}},G={ownerDocument:D,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:R,enableXfa:k}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const t=c.messageHandler.sendWithPromise("GetDocRequest",W,s?[s.buffer]:null);let l;if(h)l=new Qi(h,{disableRange:I,disableStream:L});else if(!s){if(!n)throw new Error("getDocument - no `url` parameter provided.");const t=Pt(n)?hn:r?bn:pn;l=new t({url:n,length:U,httpHeaders:a,withCredentials:o,rangeChunkSize:d,disableRange:I,disableStream:L})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const n=new Fe(i,t,c.port),s=new Mn(n,e,l,G,$,O);e._transport=s,n.send("Ready",null)})}).catch(e._capability.reject),e}class Sn{static#sn=0;_capability=Promise.withResolvers();_transport=null;_worker=null;docId="d"+Sn.#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 Cn=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){q("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class En{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 Q(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 Pn{#js=!1;constructor(t,e,i,n=!1){this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new Et:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new xn,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 xt({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 Q(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=f.ENABLE,transform:r=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:u=!1,recordOperations:p=!1,operationsFilter:g=null}){this._stats?.time("Overall");const m=this._transport.getRenderingIntent(n,s,c,u),{renderingIntent:b,cacheKey:v}=m;this.#js=!1,o||=this._transport.getOptionalContentConfig(b);let w=this._intentStates.get(v);w||(w=Object.create(null),this._intentStates.set(v,w)),w.streamReaderCancelTimeout&&(clearTimeout(w.streamReaderCancelTimeout),w.streamReaderCancelTimeout=null);const y=!!(b&d);w.displayReadyCapability||(w.displayReadyCapability=Promise.withResolvers(),w.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(m));const x=Boolean(this._pdfBug&&globalThis.StepperManager?.enabled),A=!this.recordedBBoxes&&(p||x),_=t=>{if(w.renderTasks.delete(S),A){const t=S.gfx?.dependencyTracker.take();t&&(S.stepper&&S.stepper.setOperatorBBoxes(t,S.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=t))}y&&(this.#js=!0),this.#Us(),t?(S.capability.reject(t),this._abortOperatorList({intentState:w,reason:t instanceof Error?t:new Error(t)})):S.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},S=new Dn({callback:_,params:{canvas:e,canvasContext:t,dependencyTracker:A?new ai(e,w.operatorList.length,x):null,viewport:i,transform:r,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:w.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!y,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA,operationsFilter:g});(w.renderTasks||=new Set).add(S);const C=S.task;return Promise.all([w.displayReadyCapability.promise,o]).then(([t,e])=>{if(this.destroyed)_();else{if(this._stats?.time("Rendering"),!(e.renderingIntent&b))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");S.initializeGraphics({transparency:t,optionalContentConfig:e}),S.operatorListChanged()}}).catch(_),C}getOperatorList({intent:t="display",annotationMode:e=f.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=>ft.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 Et),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 At){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 st(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 Tn=class t{#as=Promise.withResolvers();#Hs=null;#Wn=null;#Vs=null;static#zs=0;static#$s=!1;static#Ws=new WeakMap;static{r&&(this.#$s=!0,Gi.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=$()}={}){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.#Hs.send("configure",{verbosity:this.verbosity})}get port(){return this.#Wn}get messageHandler(){return this.#Hs}#Gs(t){this.#Wn=t,this.#Hs=new Fe("main","worker",t),this.#Hs.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 Fe("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.#Vs||s()},{signal:r.signal}),n.on("test",t=>{r.abort(),!this.destroyed&&t?(this.#Hs=n,this.#Wn=i,this.#Vs=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{W("The worker has been disabled.")}this.#Ks()}#Ks(){t.#$s||(G("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 _e;this.#Wn=i;const n="fake"+t.#zs++,s=new Fe(n+"_worker",n,i);e.setup(s,i),this.#Hs=new Fe(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.#Vs?.terminate(),this.#Vs=null,t.#Ws.delete(this.#Wn),this.#Wn=null,this.#Hs?.destroy(),this.#Hs=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(Gi.workerSrc)return Gi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#Ys(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Q(this,"_setupFakeWorkerGlobal",(async()=>{if(this.#Ys)return this.#Ys;return(await import(this.workerSrc)).WorkerMessageHandler})())}};class Mn{#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 xn,this.fontLoader=new ge({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 Q(this,"annotationStorage",new ue)}getRenderingIntent(t,e=f.ENABLE,i=null,n=!1,s=!1){let r=h,a=ce;switch(t){case"any":r=l;break;case"display":break;case"print":r=d;break;default:G(`getRenderingIntent - invalid intent: ${t}`)}const o=r&d&&i instanceof pe?i:this.annotationStorage;switch(e){case f.DISABLE:r+=p;break;case f.ENABLE:break;case f.ENABLE_FORMS:r+=c;break;case f.ENABLE_STORAGE:r+=u,a=o.serializable;break;default:G(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(r+=g),s&&(r+=m);const{ids:b,hash:v}=o.modifiedIds;return{renderingIntent:r,cacheKey:[r,a.hash,v].join("_"),annotationStorageSerializable:a,modifiedIds:b}}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(),An.cleanup(),this._networkStream?.cancelAllRequests(new st("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)=>{X(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():(X(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)=>{X(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():(X(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 En(t,this))}),t.on("DocException",t=>{e._capability.reject(Ne(t))}),t.on("PasswordRequest",t=>{this.#er=Promise.withResolvers();try{if(!e.onPassword)throw Ne(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;G(`Error during font loading: ${t}`),this.commonObjs.resolve(e,t);break}const s=new ve(n),r=this._params.pdfBug&&globalThis.FontInspector?.enabled?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,a=new me(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;X(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 we(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&&G("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 Pn(e,i,this,this._params.pdfBug);return this.#Zs.set(e,n),n});return this.#Js.set(e,n),n}getPageIndex(t){return xe(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 Ki(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 qi(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),An.cleanup()}}cachedPageNumber(t){if(!xe(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return this.#tr.get(e)??null}}class kn{#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 Dn{#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 kn(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(Dn.#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.");Dn.#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 Wi(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),Dn.#rr.delete(this._canvas),t||=new At(`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(),Dn.#rr.delete(this._canvas),this.callback())))}}let In=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 Q(this,"_keyboardManager",new Jt([[["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",Tt,{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:w.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 Ln{#yr=null;#r=null;#b=null;static#gr=null;constructor(t){this.#r=t,this.#b=t._uiManager,Ln.#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",Ln.#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 Rn(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function Nn(t){return Math.max(0,Math.min(255,255*t))}class Fn{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=Nn(t),t,t]}static G_HTML([t]){const e=Rn(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(Nn)}static RGB_HTML(t){return`#${t.map(Rn).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[Nn(1-Math.min(1,t+n)),Nn(1-Math.min(1,i+n)),Nn(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 Bn{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){q("Abstract method `_createSVG` called.")}}let On=class extends Bn{_createSVG(t){return document.createElementNS(vt,t)}};const jn=new WeakSet,Un=60*(new Date).getTimezoneOffset()*1e3;class Hn{static create(t){switch(t.data.annotationType){case M.LINK:return new $n(t);case M.TEXT:return new Wn(t);case M.WIDGET:switch(t.data.fieldType){case"Tx":return new qn(t);case"Btn":return t.data.radioButton?new Kn(t):t.data.checkBox?new Yn(t):new Qn(t);case"Ch":return new Zn(t);case"Sig":return new Xn(t)}return new Gn(t);case M.POPUP:return new Jn(t);case M.FREETEXT:return new es(t);case M.LINE:return new is(t);case M.SQUARE:return new ns(t);case M.CIRCLE:return new ss(t);case M.POLYLINE:return new rs(t);case M.CARET:return new os(t);case M.INK:return new ls(t);case M.POLYGON:return new as(t);case M.HIGHLIGHT:return new hs(t);case M.UNDERLINE:return new ds(t);case M.SQUIGGLY:return new cs(t);case M.STRIKEOUT:return new us(t);case M.STAMP:return new ps(t);case M.FILEATTACHMENT:return new gs(t);default:return new Vn(t)}}}class Vn{#xr=null;#Ar=!1;#_r=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 Vn._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(`${b}${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(`${b}${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.#_r?.popup||this.popup)?.remove(),this.#_r=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.#Sr(e);let n=this.#_r?.popup||this.popup;!n&&i?.text&&(this._createPopup(i),n=this.#_r.popup),n&&(n.updateEdited(t),i?.deleted&&(n.remove(),this.#_r=null,this.popup=null))}resetEdited(){this.#xr&&(this.#Sr(this.#xr.rect),this.#_r?.popup.resetEdited(),this.#xr=null)}#Sr(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 Gn||this instanceof $n||(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 Jn){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 Kn){const t=`calc(${a}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;r.borderRadius=t}switch(e.borderStyle.style){case k:r.borderStyle="solid";break;case D:r.borderStyle="dashed";break;case I:G("Unimplemented border style: beveled");break;case L:G("Unimplemented border style: inset");break;case R:r.borderBottomStyle="solid"}const n=e.borderColor||null;n?(this.#Ar=!0,r.borderColor=ht.makeHexColor(0|n[0],0|n[1],0|n[2])):r.borderWidth=0}const l=ht.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]=Fn[`${s}_HTML`](r),this.annotationStorage.setValue(this.data.id,{[e]:Fn[`${s}_rgb`](r)})};return Q(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.#_r=new Jn({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.#_r||this.popup||this.data.popupRef)}get extraPopupElement(){return this.#_r}render(){q("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||jn.has(a)?i.push({id:s,exportValue:n,domElement:a}):G(`_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&&(jn.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 zn extends Vn{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 $n extends Vn{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 G('_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&&(jn.has(i)?i.dispatchEvent(new Event("resetform")):G(`_bindResetFormAction - element not allowed: ${e}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:o,name:"ResetForm"}}),!1}}}class Wn extends Vn{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 Gn extends Vn{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,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":ht.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/(o*n))||1);r=Math.min(n,a(e/o))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);r=Math.min(n,a(t/o))}s.fontSize=`calc(${r}px * var(--total-scale-factor))`,s.color=ht.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 qn extends Gn{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),jn.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-Un).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 Xn extends Gn{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Yn extends Gn{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 jn.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 Kn extends Gn{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(jn.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 Qn extends $n{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 Zn extends Gn{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");jn.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 Jn extends Vn{constructor(t){const{data:e,elements:i,parent:n}=t,s=!!n._commentManager;if(super(t,{isRenderable:!s&&Vn._hasPopupData(e)}),this.elements=i,s&&Vn._hasPopupData(e)){const t=this.popup=this.#Tr();for(const e of i)e.popup=t}else this.popup=null}#Tr(){return new ts({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=>`${pt}${t}`).join(",")),this.container}}class ts{#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;#Hr=null;#Vr=!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.#Hr=h,this.#jr=i,this.#z=c,this.#Kr=i[0],this.#Or=kt.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=ht.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)}$t({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.#Vr)&&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=kt.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.#Vr=!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.#Hr,a=r?this.#Hr:this.#qr;for(const t of this.#jr)if(!a||null!==ht.intersect(t.data.rect,a)){a=t.data.rect,r=!0;break}const o=ht.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.#Vr=!this.#Vr,this.#Vr?(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.#Vr&&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.#Vr&&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 es extends Vn{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=v.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 is extends Vn{#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 ns extends Vn{#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 ss extends Vn{#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 rs extends Vn{#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 as extends rs{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class os extends Vn{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 ls extends Vn{#ca=null;#ua=[];constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?v.HIGHLIGHT:v.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 hs extends Vn{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=v.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 ds extends Vn{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 cs extends Vn{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 us extends Vn{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 ps extends Vn{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=v.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 gs extends Vn{#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}=ot.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 ms=/\r\n?|\n/g;class fs extends re{#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=fs.prototype,e=t=>t.isEmpty(),i=ee.TRANSLATE_SMALL,n=ee.TRANSLATE_BIG;return Q(this,"_keyboardManager",new Jt([[["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=v.FREETEXT;constructor(t){super({...t,name:"freeTextEditor"}),this.color=t.color||fs._defaultColor||re._defaultLineColor,this.#na=t.fontSize||fs._defaultFontSize,this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static initialize(t,e){re.initialize(t,e);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(t,e){switch(t){case w.FREETEXT_SIZE:fs._defaultFontSize=e;break;case w.FREETEXT_COLOR:fs._defaultColor=e}}updateParams(t,e){switch(t){case w.FREETEXT_SIZE:this.#wa(e);break;case w.FREETEXT_COLOR:this.#ta(e)}}static get defaultPropertiesToUpdate(){return[[w.FREETEXT_SIZE,fs._defaultFontSize],[w.FREETEXT_COLOR,fs._defaultColor||re._defaultLineColor]]}get propertiesToUpdate(){return[[w.FREETEXT_SIZE,this.#na],[w.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||=new Ln(this),[["colorPicker",this._colorPicker]]}get colorType(){return w.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:w.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:w.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const t=this.parentScale;return[-fs._internalPadding*t,-(fs._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(fs.#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.#_a(),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){fs._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.#_a(),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(ms,"")}editorDivPaste(t){const e=t.clipboardData||window.clipboardData,{types:i}=e;if(1===i.length&&"text/plain"===i[0])return;t.preventDefault();const n=fs.#Sa(e.getData("text")||"").replaceAll(ms,"\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(ms,"")),t!==this.editorDiv){let e=l;for(const i of this.editorDiv.childNodes)i!==t?e.push(fs.#Aa(i)):e=h}l.push(a.nodeValue.slice(0,o).replaceAll(ms,""))}else if(a===this.editorDiv){let t=l,e=0;for(const i of this.editorDiv.childNodes)e++===o&&(t=h),t.push(fs.#Aa(i))}this.#fa=`${l.join("\n")}${n}${h.join("\n")}`,this.#_a();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)}#_a(){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#Sa(t){return t.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}getPDFRect(){const t=fs._internalPadding*this.parentScale;return this.getRect(t,t)}static async deserialize(t,e,i){let n=null;if(t instanceof es){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:v.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=ht.makeHexColor(...t.color),s.#fa=fs.#Sa(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=re._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 bs{static PRECISION=1e-4;toSVGPath(){q("Abstract method `toSVGPath` must be implemented.")}get box(){q("Abstract getter `box` must be implemented.")}serialize(t,e){q("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 vs{#Pa;#Ta=[];#Ma;#ka;#Da=[];#Ia=new Float32Array(18);#La;#Ra;#Na;#Fa;#Ba;#Oa;#ja=[];static#Ua=8;static#Ha=2;static#Va=vs.#Ua+vs.#Ha;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=vs.#Ua*n,this.#Na=vs.#Va*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 ws(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 ws extends bs{#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=bs._rescale(this.#Qa,t,n,r,-a),l=bs._rescale(this.#ja,t,n,r,-a);break;case 90:o=bs._rescaleAndSwap(this.#Qa,t,e,r,a),l=bs._rescaleAndSwap(this.#ja,t,e,r,a);break;case 180:o=bs._rescale(this.#Qa,i,e,-r,a),l=bs._rescale(this.#ja,i,e,-r,a);break;case 270:o=bs._rescaleAndSwap(this.#Qa,i,n,-r,-a),l=bs._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])?(ht.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,ht.bezierBoundingBox(i,n,...e.slice(t,t+6),d),ht.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 vs(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 ys{#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),ht.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 xs(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 xs extends bs{#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 As extends vs{newFreeDrawOutline(t,e,i,n,s,r){return new _s(t,e,i,n,s,r)}}class _s extends ws{newOutliner(t,e,i,n,s,r=0){return new As(t,e,i,n,s,r)}}class Ss extends re{#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=v.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const t=Ss.prototype;return Q(this,"_keyboardManager",new Jt([[["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||Ss._defaultColor,this.#Oa=t.thickness||Ss._defaultThickness,this.opacity=t.opacity||Ss._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.#_o(),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}}#_o(){const t=new ys(this.#co,.001);this.#bo=t.getOutlines(),[this.x,this.y,this.width,this.height]=this.#bo.box;const e=new ys(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:Ss.#So(this.#bo.box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#wo,{bbox:Ss.#So(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){re.initialize(t,e),Ss._defaultColor||=e.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(t,e){switch(t){case w.HIGHLIGHT_COLOR:Ss._defaultColor=e;break;case w.HIGHLIGHT_THICKNESS:Ss._defaultThickness=e}}translateInPage(t,e){}get toolbarPosition(){return this.#to}get commentButtonPosition(){return this.#Ja}updateParams(t,e){switch(t){case w.HIGHLIGHT_COLOR:this.#ta(e);break;case w.HIGHLIGHT_THICKNESS:this.#Co(e)}}static get defaultPropertiesToUpdate(){return[[w.HIGHLIGHT_COLOR,Ss._defaultColor],[w.HIGHLIGHT_THICKNESS,Ss._defaultThickness]]}get propertiesToUpdate(){return[[w.HIGHLIGHT_COLOR,this.color||Ss._defaultColor],[w.HIGHLIGHT_THICKNESS,this.#Oa||Ss._defaultThickness],[w.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,Ss._defaultOpacity),undo:e.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:w.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:w.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 In({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#So([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=Ss.#So(this.#bo.box,t)):i=Ss.#So([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:Ss.#So(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(),Xt(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){Ss._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",Mt,{capture:!0,passive:!1,signal:d}),window.addEventListener("contextmenu",Tt,{signal:d}),i.addEventListener("pointermove",this.#Ro.bind(this,t),{signal:d}),this._freeHighlight=new As({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 hs){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:v.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 ls){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:v.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=ht.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.#_o(),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 As(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=re._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 Cs{#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(){q("Not implemented")}}class Es extends re{#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.#Ho(t),this.#Ao())}#Ho({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.#Vo(t,this.parent),this.#zo(t.box)}#Vo(t,e){const{id:i}=e.drawLayer.draw(Es._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){q("Not implemented")}static get typesMap(){q("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&&(Es.#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,Es._mergeSVGProperties(this.#Fo.getPathResizingSVGProperties(this.#$o()),{bbox:this.#Wo()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,Es._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,Es._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.#Vo(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,Es._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){q("Not implemented")}static startDrawing(t,e,i,n){const{target:s,offsetX:r,offsetY:a,pointerId:o,pointerType:l}=n;if(Yt.isInitializedAndDifferentPointerType(l))return;const{viewport:{rotation:h}}=t,{width:d,height:c}=s.getBoundingClientRect(),u=Es.#jo=new AbortController,p=t.combinedSignal(u);Yt.setPointer(l,o),window.addEventListener("pointerup",t=>{Yt.isSamePointerIdOrRemove(t.pointerId)&&this._endDraw(t)},{signal:p}),window.addEventListener("pointercancel",t=>{Yt.isSamePointerIdOrRemove(t.pointerId)&&this._currentParent.endDrawingSession()},{signal:p}),window.addEventListener("pointerdown",t=>{Yt.isSamePointerType(t.pointerType)&&(Yt.initializeAndAddPointerId(t.pointerId),Es.#Oo.isCancellable()&&(Es.#Oo.removeLastElement(),Es.#Oo.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:p}),window.addEventListener("contextmenu",Tt,{signal:p}),s.addEventListener("pointermove",this._drawMove.bind(this),{signal:p}),s.addEventListener("touchmove",t=>{Yt.isSameTimeStamp(t.timeStamp)&&Mt(t)},{signal:p}),t.toggleDrawing(),e._editorUndoBar?.hide(),Es.#Oo?t.drawLayer.updateProperties(this._currentDrawId,Es.#Oo.startNew(r,a,d,c,h)):(e.updateUIForDefaultProperties(this),Es.#Oo=this.createDrawerInstance(r,a,d,c,h),Es.#Uo=this.getDefaultDrawingOptions(),this._currentParent=t,({id:this._currentDrawId}=t.drawLayer.draw(this._mergeSVGProperties(Es.#Uo.toSVGProperties(),Es.#Oo.defaultSVGProperties),!0,!1)))}static _drawMove(t){if(Yt.isSameTimeStamp(t.timeStamp),!Es.#Oo)return;const{offsetX:e,offsetY:i,pointerId:n}=t;Yt.isSamePointerId(n)&&(Yt.isUsingMultiplePointers()?this._endDraw(t):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,Es.#Oo.add(e,i)),Yt.setTimeStamp(t.timeStamp),Mt(t)))}static _cleanup(t){t&&(this._currentDrawId=-1,this._currentParent=null,Es.#Oo=null,Es.#Uo=null,Yt.clearPointerType(),Yt.clearTimeStamp()),Es.#jo&&(Es.#jo.abort(),Es.#jo=null,Yt.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,Es.#Oo.end(t.offsetX,t.offsetY)),this.supportMultipleDrawings){const t=Es.#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:w.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(t){const e=this._currentParent;if(!e)return null;if(e.toggleDrawing(!0),e.cleanUndoStack(w.DRAW_STEP),!Es.#Oo.isEmpty()){const{pageDimensions:[i,n],scale:s}=e,r=e.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:Es.#Oo.getOutlines(i*s,n*s,s,this._INNER_MARGIN),drawingOptions:Es.#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){q("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.#Ho({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 Ps{#Ia=new Float64Array(6);#oa;#qo;#ms;#Oa;#ja;#Xo="";#Yo=0;#lo=new Ts;#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 bs._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(...bs.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=bs.svgRound(this.#oa[4]),e=bs.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=bs.svgRound(this.#oa[10]),e=bs.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(bs.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 Ts extends bs{#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${bs.svgRound(e[4])} ${bs.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${bs.svgRound(e[10])} ${bs.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(bs.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=bs._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=bs._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=bs._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=bs._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=bs._rescale,d=-t/i,c=e/n+1,u=1/i,p=-1/n;break;case 90:g=bs._rescaleAndSwap,d=-e/n,c=-t/i,u=1/n,p=1/i;break;case 180:g=bs._rescale,d=t/i+1,c=-e/n,u=-1/i,p=1/n;break;case 270:g=bs._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(bs.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)ht.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);ht.bezierBoundingBox(i,n,r,a,o,l,h,d,t),i=h,n=d}}const[e,i]=this.#nl();t[0]=gt(t[0]-e,0,1),t[1]=gt(t[1]-i,0,1),t[2]=gt(t[2]+e,0,1),t[3]=gt(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(bs.svgRound).join(" ")}get defaultProperties(){const[t,e]=this.#Ka;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bs.svgRound(t)} ${bs.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} ${bs.svgRound(a)} ${bs.svgRound(o)})`}getPathResizingSVGProperties([t,e,i,n]){const[s,r]=this.#nl(),[a,o,l,h]=this.#Ka;if(Math.abs(l-s)<=bs.PRECISION||Math.abs(h-r)<=bs.PRECISION){const s=t+i/2-(a+l/2),r=e+n/2-(o+h/2);return{path:{"transform-origin":`${bs.svgRound(t)} ${bs.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":`${bs.svgRound(a)} ${bs.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${bs.svgRound(s)} ${bs.svgRound(r)}) scale(${d} ${c}) translate(${bs.svgRound(-s)} ${bs.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)<=bs.PRECISION||Math.abs(d-r)<=bs.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)bs._translate(t,s,r,t),bs._translate(e,s,r,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bs.svgRound(t)} ${bs.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)bs._rescale(t,p,g,c,u,t),bs._rescale(e,p,g,c,u,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${bs.svgRound(t)} ${bs.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)bs._translate(t,a,o,t),bs._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)bs._rescale(i,a,o,t,e,i),bs._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":`${bs.svgRound(t)} ${bs.svgRound(e)}`}}}get defaultSVGProperties(){const t=this.#Ka;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${bs.svgRound(t[0])} ${bs.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}class Ms extends Cs{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:re._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 Ms(this._viewParameters);return t.updateAll(this),t}}class ks extends Es{static _type="ink";static _editorType=v.INK;static _defaultDrawingOptions=null;constructor(t){super({...t,name:"inkEditor"}),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){re.initialize(t,e),this._defaultDrawingOptions=new Ms(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return Q(this,"typesMap",new Map([[w.INK_THICKNESS,"stroke-width"],[w.INK_COLOR,"stroke"],[w.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,i,n,s){return new Ps(t,e,i,n,s,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,i,n,s,r){return Ts.deserialize(t,e,i,n,s,r)}static async deserialize(t,e,i){let n=null;if(t instanceof ls){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:v.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 Ln(this),[["colorPicker",this._colorPicker]]}get colorType(){return w.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=ks.getDefaultDrawingOptions({stroke:ht.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:re._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 Ds extends Ts{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}let Is=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),_=this.#ml(A),S=this.#hl(x,w,y,_);return this.processDrawnLines({lines:{curves:S,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(bs.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 Ds:new Ts;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 mt(new Uint8Array(f))}static async decompressSignature(t){try{const i=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):at(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 G(`decompressSignature: ${t}`),null}var e}};class Ls extends Cs{constructor(){super(),super.updateProperties({fill:re._defaultLineColor,"stroke-width":0})}clone(){const t=new Ls;return t.updateAll(this),t}}class Rs extends Ms{constructor(t){super(t),super.updateProperties({stroke:re._defaultLineColor,"stroke-width":1})}clone(){const t=new Rs(this._viewParameters);return t.updateAll(this),t}}class Ns extends Es{#bl=!1;#vl=null;#wl=null;#yl=null;static _type="signature";static _editorType=v.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){re.initialize(t,e),this._defaultDrawingOptions=new Ls,this._defaultDrawnSignatureOptions=new Rs(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return Q(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=Is.processDrawnLines({lines:t,pageWidth:a,pageHeight:o,rotation:l,innerMargin:Ns._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:Is.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 Ds,this.description=i,this.#bl?o=Ns.getDefaultDrawingOptions():(o=Ns._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 Is.process(t,e,i,n,Ns._INNER_MARGIN)}getFromText(t,e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:s}=this.parent.viewport;return Is.extractContoursFromText(t,e,i,n,s,Ns._INNER_MARGIN)}getDrawnSignature(t){const{rawDims:{pageWidth:e,pageHeight:i},rotation:n}=this.parent.viewport;return Is.processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:Ns._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:t,thickness:e}){t?this._drawingOptions=Ns.getDefaultDrawingOptions():(this._drawingOptions=Ns._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?Ds.deserialize(t,e,i,n,s,r):Ts.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 Fs extends re{#xl=null;#Al=null;#_l=null;#Sl=null;#Cl=null;#El="";#Pl=null;#Tl=!1;#Ml=null;#kl=!1;#Dl=!1;static _type="stamp";static _editorType=v.STAMP;constructor(t){super({...t,name:"stampEditor"}),this.#Sl=t.bitmapUrl,this.#Cl=t.bitmapFile,this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){re.initialize(t,e)}static isHandlingMimeForPasting(t){return Bt.includes(t)}static paste(t,e){e.pasteEditor({mode:v.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.#_l=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.#Sl){const t=this.#Sl;return this.#Sl=null,this._uiManager.enableWaiting(!0),void(this.#_l=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.#_l=this._uiManager.imageManager.getFromFile(t).then(t=>this.#Il(t)).finally(()=>this.#Rl()))}const t=document.createElement("input");t.type="file",t.accept=Bt.join(",");const e=this._uiManager._signal;this.#_l=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.#_l||this.#xl||this.#Sl||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 Ft;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":Ot.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 Ft,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*wt.PDF_TO_CSS_UNITS),n=Math.round(this.height*e*wt.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 ps){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,w;f?(delete t.canvas,({id:b,bitmap:w}=i.imageManager.getFromCanvas(g.id,f)),f.remove()):(s=!0,t._hasNoCanvas=!0);const y=(await e._structTree.getAriaAttributes(`${pt}${o}`))?.get("aria-label")||"";n=t={annotationType:v.STAMP,bitmapId:b,bitmap:w,pageIndex:m-1,rect:r.slice(0),rotation:a,annotationElementId:o,id:o,deleted:!1,accessibilityData:{decorative:!1,altText:y},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.#Sl=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 Bs=class t{#jl;#Ul=!1;#Hl=null;#Vl=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([fs,ks,Fs,Ss,Ns].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.#Hl=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()===v.NONE}updateToolbar(t){this.#b.updateToolbar(t)}updateMode(e=this.#b.getMode()){switch(this.#th(),e){case v.NONE:return this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case v.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case v.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===v.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.#Hl?.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.#Hl;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(`^${b}[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.#Hl,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.#Hl?.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}=ot.platform;if(0!==t.button||t.ctrlKey&&e)return;this.#b.showAllEditors("highlight",!0,!0),this.#Kl.div.classList.add("free"),this.toggleDrawing(),Ss.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.#Vl)return;this.#Vl=new AbortController;const t=this.#b.combinedSignal(this.#Vl);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.#Vl?.abort(),this.#Vl=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),re.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}=ot.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!==v.STAMP&&i!==v.SIGNATURE?this.createAndAddNewEditor(t,!1):this.#b.unselectAll()}pointerdown(t){if(this.#b.getMode()===v.HIGHLIGHT&&this.enableTextSelection(),this.#Wl)return void(this.#Wl=!1);const{isMac:e}=ot.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,Nt(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,Nt(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:ys},globalThis.pdfjsLib={AbortException:st,AnnotationEditorLayer:Bs,AnnotationEditorParamsType:w,AnnotationEditorType:v,AnnotationEditorUIManager:ee,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 ue,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;Nt(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 On,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===M.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=Hn.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=Hn.create(r);if(!i.isRenderable)continue;const s=i.render();i.contentElement.id=`${pt}${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=`${pt}${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 On,parent:this};for(const n of e){n.borderStyle||=t._defaultBorderStyle,i.data=n;const e=Hn.create(i);e.isRenderable&&(e.render(),e.contentElement.id=`${pt}${n.id}`,this.#jr.push(e))}await this.#ch()}update({viewport:t}){const e=this.div;this.viewport=t,Nt(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 zn({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=`${pt}${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 Q(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:k,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}},AnnotationMode:f,AnnotationType:M,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:In,createValidAbsoluteUrl:Y,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(),Q(this,"commentForegroundColor",It(i))}},DOMSVGFactory:On,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 Q(this,"_svgFactory",new On)}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:ot,fetchData:yt,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=zt.get(i);if(n)return n;const s=new Float32Array(9),r=s.subarray(0,3),a=s.subarray(3,6);jt(t,a);const o=s.subarray(6,9);jt(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]),Vt(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===Vt(a,o,r)<h?t=i:e=i}a[2]=l?e:t}return Ut(a,r),n=ht.makeHexColor(Math.round(255*r[0]),Math.round(255*r[1]),Math.round(255*r[2])),zt.set(i,n),n},getDocument:_n,getFilenameFromUrl:function(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)},getPdfFilenameFromUrl:Ct,getRGB:It,getUuid:ut,getXfaPageViewport:Dt,GlobalWorkerOptions:Gi,ImageKind:T,InvalidPDFException:et,isDataScheme:_t,isPdfFile:St,isValidExplicitDest:Ae,MathClamp:gt,noContextMenu:Tt,normalizeUnicode:function(t){return dt||(dt=/([\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,ct=new Map([["ſt","ſt"]])),t.replaceAll(dt,(t,e,i)=>e?e.normalize("NFKC"):ct.get(i))},OPS:F,OutputScale:Ft,PasswordResponses:{NEED_PASSWORD:1,INCORRECT_PASSWORD:2},PDFDataRangeTransport:Cn,PDFDateString:kt,PDFWorker:Tn,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:wt,RenderingCancelledException:At,renderRichText:$t,ResponseException:it,setLayerDimensions:Nt,shadow:Q,SignatureExtractor:Is,stopEvent:Mt,SupportedImageMimeTypes:Bt,TextLayer:An,TouchManager:se,updateUrlHash:K,Util:ht,VerbosityLevel:N,version:"5.4.394",XfaLayer:bt};
24
+ /**
25
+ * @licstart The following is the entire license notice for the
26
+ * JavaScript code in this page
27
+ *
28
+ * Copyright 2024 Mozilla Foundation
29
+ *
30
+ * Licensed under the Apache License, Version 2.0 (the "License");
31
+ * you may not use this file except in compliance with the License.
32
+ * You may obtain a copy of the License at
33
+ *
34
+ * http://www.apache.org/licenses/LICENSE-2.0
35
+ *
36
+ * Unless required by applicable law or agreed to in writing, software
37
+ * distributed under the License is distributed on an "AS IS" BASIS,
38
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
+ * See the License for the specific language governing permissions and
40
+ * limitations under the License.
41
+ *
42
+ * @licend The above is the entire license notice for the
43
+ * JavaScript code in this page
44
+ */
45
+ const{AbortException:Os,AnnotationEditorLayer:js,AnnotationEditorParamsType:Us,AnnotationEditorType:Hs,AnnotationEditorUIManager:Vs,AnnotationLayer:zs,AnnotationMode:$s,AnnotationType:Ws,applyOpacity:Gs,build:qs,ColorPicker:Xs,createValidAbsoluteUrl:Ys,CSSConstants:Ks,DOMSVGFactory:Qs,DrawLayer:Zs,FeatureTest:Js,fetchData:tr,findContrastColor:er,getDocument:ir,getFilenameFromUrl:nr,getPdfFilenameFromUrl:sr,getRGB:rr,getUuid:ar,getXfaPageViewport:or,GlobalWorkerOptions:lr,ImageKind:hr,InvalidPDFException:dr,isDataScheme:cr,isPdfFile:ur,isValidExplicitDest:pr,MathClamp:gr,noContextMenu:mr,normalizeUnicode:fr,OPS:br,OutputScale:vr,PasswordResponses:wr,PDFDataRangeTransport:yr,PDFDateString:xr,PDFWorker:Ar,PermissionFlag:_r,PixelsPerInch:Sr,RenderingCancelledException:Cr,renderRichText:Er,ResponseException:Pr,setLayerDimensions:Tr,shadow:Mr,SignatureExtractor:kr,stopEvent:Dr,SupportedImageMimeTypes:Ir,TextLayer:Lr,TouchManager:Rr,updateUrlHash:Nr,Util:Fr,VerbosityLevel:Br,version:Or,XfaLayer:jr}=globalThis.pdfjsLib,Ur={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Hr=0,Vr=1,zr=2,$r=3,Wr=0,Gr=1,qr=2,Xr={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},Yr={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function Kr(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=gr((n.clientWidth-i)/2,20,400);r+=e.left-s}else r+=e.left;n.scrollLeft=r}n.scrollTop=s}function Qr(t){const e=new Map;for(const[i,n]of new URLSearchParams(t))e.set(i.toLowerCase(),n);return e}const Zr=/[\x00-\x1F]/g;function Jr(t,e=!1){return Zr.test(t)?e?t.replaceAll(Zr,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t}function ta(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 ea(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 ia(t,e){return t-t%e}function na(t){return Number.isInteger(t)&&t%90==0}function sa(t){return t.width<=t.height}new Promise(function(t){window.requestAnimationFrame(t)});const ra=document.documentElement.style;const aa=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}(),oa=0,la=1,ha=2,da=3,ca=4,ua=5,pa=6,ga=7;function ma(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)?oa:function(t){return t>=97&&t<=122||t>=65&&t<=90}(t)||function(t){return t>=48&&t<=57}(t)||95===t?la:ha:function(t){return 3584==(65408&t)}(t)?ga:160===t?oa:la:function(t){return t>=13312&&t<=40959||t>=63744&&t<=64255}(t)?da:function(t){return t>=12448&&t<=12543}(t)?ca:function(t){return t>=12352&&t<=12447}(t)?ua:function(t){return t>=65376&&t<=65439}(t)?pa:la}let fa;const ba={FOUND:0,NOT_FOUND:1,WRAPPED:2,PENDING:3},va={"‐":"-","‘":"'","’":"'","‚":"'","‛":"'","“":'"',"”":'"',"„":'"',"‟":'"',"¼":"1/4","½":"1/2","¾":"3/4"},wa=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 ya;const xa=/\p{M}+/gu,Aa=/([.*+?^${}()|[\]\\])|(\p{P})|(\s+)|(\p{M})|(\p{L})/gu,_a=/([^\p{M}])\p{M}*$/u,Sa=/^\p{M}*([^\p{M}])/u,Ca=/[\uAC00-\uD7AF\uFA6C\uFACF-\uFAD1\uFAD5-\uFAD7]+/g,Ea=new Map,Pa=new Map;let Ta=null,Ma=null;function ka(t,e={}){const i=[];let n;for(;null!==(n=Ca.exec(t));){let{index:t}=n;for(const e of n[0]){let n=Ea.get(e);n||(n=e.normalize("NFD").length,Ea.set(e,n)),i.push([n,t++])}}const s=i.length>0,r=e.ignoreDashEOL??!1;let a;if(!s&&Ta)a=Ta;else if(s&&Ma)a=Ma;else{const t=Object.keys(va).join(""),e=(fa||=" ¨ª¯²-µ¸-º¼-¾IJ-ijĿ-ŀʼnſDŽ-njDZ-dzʰ-ʸ˘-˝ˠ-ˤʹͺ;΄-΅·ϐ-ϖϰ-ϲϴ-ϵϹևٵ-ٸक़-य़ড়-ঢ়য়ਲ਼ਸ਼ਖ਼-ਜ਼ਫ਼ଡ଼-ଢ଼ำຳໜ-ໝ༌གྷཌྷདྷབྷཛྷཀྵჼᴬ-ᴮᴰ-ᴺᴼ-ᵍᵏ-ᵪᵸᶛ-ᶿẚ-ẛάέήίόύώΆ᾽-῁ΈΉ῍-῏ΐΊ῝-῟ΰΎ῭-`ΌΏ´-῾ - ‑‗․-… ″-‴‶-‷‼‾⁇-⁉⁗ ⁰-ⁱ⁴-₎ₐ-ₜ₨℀-℃℅-ℇ℉-ℓℕ-№ℙ-ℝ℠-™ℤΩℨK-ℭℯ-ℱℳ-ℹ℻-⅀ⅅ-ⅉ⅐-ⅿ↉∬-∭∯-∰〈-〉①-⓪⨌⩴-⩶⫝̸ⱼ-ⱽⵯ⺟⻳⼀-⿕ 〶〸-〺゛-゜ゟヿㄱ-ㆎ㆒-㆟㈀-㈞㈠-㉇㉐-㉾㊀-㏿ꚜ-ꚝꝰꟲ-ꟴꟸ-ꟹꭜ-ꭟꭩ豈-嗀塚晴凞-羽蘒諸逸-都飯-舘並-龎ff-stﬓ-ﬗיִײַ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-﷼︐-︙︰-﹄﹇-﹒﹔-﹦﹨-﹫ﹰ-ﹲﹴﹶ-ﻼ!-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵ¢-₩",fa);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?Ma=a:Ta=a}const o=[];for(;null!==(n=xa.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=va[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=Pa.get(n);t||(t=n.normalize("NFKC"),Pa.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 Da(t,e,i){if(!t)return[e,i];const[n,s]=t,r=e,a=e+i-1;let o=ta(n,t=>t>=r);n[o]>r&&--o;let l=ta(n,t=>t>=a,o);n[l]>a&&--l;const h=r+s[o];return[h,a+s[l]+1-h]}class Ia{#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.#_h.bind(this)),e._on("findbarclose",this.#Sh.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())}#_h(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(ba.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;Kr(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]=ka(t)),this._normalizedQuery):(t||[]).filter(t=>!!t).map(t=>ka(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(_a);if(n){const i=t.charCodeAt(e),s=n[1].charCodeAt(0);if(ma(i)===ma(s))return!1}if(n=t.slice(e+i).match(Sa),n){const s=t.charCodeAt(e+i-1),r=n[1].charCodeAt(0);if(ma(s)===ma(r))return!1}return!0}#Dh(t,e){const{matchDiacritics:i}=this.#wh;let n=!1;const s="[ ]*";return(t=t.replaceAll(Aa,(t,s,r,a,o,l)=>s?`[ ]*\\${s}[ ]*`:r?`[ ]*${r}[ ]*`:a?"[ ]+":i?o||l:o?wa.has(o.charCodeAt(0))?o:"":e?(n=!0,`${l}\\p{M}*`):l)).endsWith(s)&&(t=t.slice(0,t.length-4)),i&&e&&(ya||=String.fromCharCode(...wa),n=!0,t=`${t}(?=[${ya}]|[^\\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]=Da(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]]=ka(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(ba.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=ba.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?ba.WRAPPED:ba.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))}#Sh(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(ba.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!==ba.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 La={NONE:0,SELF:1,BLANK:2,PARENT:3,TOP:4};class Ra{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?La.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 La.NONE:break;case La.SELF:r="_self";break;case La.BLANK:r="_blank";break;case La.PARENT:r="_parent";break;case La.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=Qr(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||pr(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 Na extends Ra{setDocument(t,e=null){}}class Fa{#Uh=null;#z=null;#Hh=!1;#Vh=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.#Vh=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.#Vh?.(a),this.#Wh(t,i),0===n.length)return this.#Uh=n,void Tr(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($r),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 zs({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.#Hh=!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.#Hh||(this.div.hidden=!1))}#Gh(t){if(!this.div)return;let e=!1;switch(t){case $r:e=!0;break;case Vr: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=Fr.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!==Ws.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 Ba(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 Oa{#Xh=new WeakMap;downloadData(t,e,i){Ba(URL.createObjectURL(new Blob([t],{type:i})),e)}openOrDownloadData(t,e,i=null){const n=ur(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(!Ys(e,"http://example.com"))return void console.error(`download - not a valid URL: ${e}`);n=e+"#pdfjs.action=download"}Ba(n,i)}}const ja="event",Ua="timeout";class Ha{#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 Va{constructor(t){this.value=t}valueOf(){return this.value}}class za extends Va{constructor(t="???"){super(t)}toString(t){return`{${this.value}}`}}class $a extends Va{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 Wa extends Va{static supportsValue(t){if("number"==typeof t)return!0;if(t instanceof Date)return!0;if(t instanceof Va)return Wa.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 Wa?(e={...t.opts,...e},t=t.value):t instanceof Va&&(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 Ga(t,e,i){if(i===e)return!0;if(i instanceof $a&&e instanceof $a&&i.value===e.value)return!0;if(e instanceof $a&&"string"==typeof i){if(i===t.memoizeIntlObject(Intl.PluralRules,e.opts).select(e.value))return!0}return!1}function qa(t,e,i){return e[i]?Qa(t,e[i].value):(t.reportError(new RangeError("No default")),new za)}function Xa(t,e){const i=[],n=Object.create(null);for(const s of e)"narg"===s.type?n[s.name]=Ya(t,s.value):i.push(Ya(t,s));return{positional:i,named:n}}function Ya(t,e){switch(e.type){case"str":return e.value;case"num":return new $a(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 za(`$${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 za(`$${e}`);i=t.args[e]}if(i instanceof Va)return i;switch(typeof i){case"string":return i;case"number":return new $a(i);case"object":if(Wa.supportsValue(i))return new Wa(i);default:return t.reportError(new TypeError(`Variable type not supported: $${e}, ${typeof i}`)),new za(`$${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 za(e);if(i){const s=n.attributes[i];return s?Qa(t,s):(t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new za(`${e}.${i}`))}if(n.value)return Qa(t,n.value);return t.reportError(new ReferenceError(`No value: ${e}`)),new za(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 za(s);if(i){const e=r.attributes[i];if(e){t.params=Xa(t,n).named;const i=Qa(t,e);return t.params=null,i}return t.reportError(new ReferenceError(`Unknown attribute: ${i}`)),new za(`${s}.${i}`)}t.params=Xa(t,n).named;const a=Qa(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 za(`${e}()`);if("function"!=typeof n)return t.reportError(new TypeError(`Function ${e}() is not callable`)),new za(`${e}()`);try{let e=Xa(t,i);return n(e.positional,e.named)}catch(i){return t.reportError(i),new za(`${e}()`)}}(t,e);case"select":return function(t,{selector:e,variants:i,star:n}){let s=Ya(t,e);if(s instanceof za)return qa(t,i,n);for(const e of i){if(Ga(t,s,Ya(t,e.key)))return Qa(t,e.value)}return qa(t,i,n)}(t,e);default:return new za}}function Ka(t,e){if(t.dirty.has(e))return t.reportError(new RangeError("Cyclic reference")),new za;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(Ya(t,s).toString(t)),n&&i.push("⁩")}else i.push(t.bundle._transform(s));return t.dirty.delete(e),i.join("")}function Qa(t,e){return"string"==typeof e?t.bundle._transform(e):Ka(t,e)}class Za{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 Ja(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 to=["unitDisplay","currencyDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits"];function eo(t,e){let i=t[0];if(i instanceof za)return new za(`NUMBER(${i.valueOf()})`);if(i instanceof $a)return new $a(i.valueOf(),{...i.opts,...Ja(e,to)});if(i instanceof Wa)return new $a(i.toNumber(),{...Ja(e,to)});throw new TypeError("Invalid argument to NUMBER")}const io=["dateStyle","timeStyle","fractionalSecondDigits","dayPeriod","hour12","weekday","era","year","month","day","hour","minute","second","timeZoneName"];function no(t,e){let i=t[0];if(i instanceof za)return new za(`DATETIME(${i.valueOf()})`);if(i instanceof Wa||i instanceof $a)return new Wa(i,Ja(e,io));throw new TypeError("Invalid argument to DATETIME")}const so=new Map;class ro{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:eo,DATETIME:no,...e},this._useIsolating=i,this._transform=n,this._intls=function(t){const e=Array.isArray(t)?t.join(" "):t;let i=so.get(e);return void 0===i&&(i=new Map,so.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 Za(this,i,e);try{return Ka(n,t).toString(n)}catch(t){if(n.errors&&t instanceof Error)return n.errors.push(t),(new za).toString(n);throw t}}}const ao=/^(-?[a-zA-Z][\w-]*) *= */gm,oo=/\.([a-zA-Z][\w-]*) *= */y,lo=/\*?\[/y,ho=/(-?[0-9]+(?:\.([0-9]+))?)/y,co=/([a-zA-Z][\w-]*)/y,uo=/([$-])?([a-zA-Z][\w-]*)(?:\.([a-zA-Z][\w-]*))?/y,po=/^[A-Z][A-Z0-9_-]*$/,go=/([^{}\n\r]+)/y,mo=/([^\\"\n\r]*)/y,fo=/\\([\\"])/y,bo=/\\u([a-fA-F0-9]{4})|\\U([a-fA-F0-9]{6})/y,vo=/^\n+/,wo=/ +$/,yo=/ *\r?\n/g,xo=/( *)$/,Ao=/{\s*/y,_o=/\s*}/y,So=/\[\s*/y,Co=/\s*] */y,Eo=/\s*\(\s*/y,Po=/\s*->\s*/y,To=/\s*:\s*/y,Mo=/\s*,?\s*/y,ko=/\s+/y;class Do{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(oo);){let e=a(oo),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(go)&&(n=a(go)),"{"===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,vo),h([s],s.length)):n?v(n,wo):null}function h(n=[],s){for(;;){if(i(go)){n.push(a(go));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,wo));let l=[];for(let t of n)t instanceof Io&&(t=t.value.slice(0,t.value.length-s)),t&&l.push(t);return l}function d(){s(Ao,SyntaxError);let t=c();if(s(_o))return t;if(s(Po)){let e=function(){let t,e=[],s=0;for(;i(lo);){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(_o,SyntaxError),{type:"select",selector:t,...e}}throw new SyntaxError("Unclosed placeable")}function c(){if("{"===t[e])return d();if(i(uo)){let[,i,n,a=null]=r(uo);if("$"===i)return{type:"var",name:n};if(s(Eo)){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(Mo)}}();if("-"===i)return{type:"term",name:n,attr:a,args:r};if(po.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(To)?{type:"narg",name:t.name,value:g()}:t}function p(){let t;return s(So,SyntaxError),t=i(ho)?m():{type:"str",value:a(co)},s(Co,SyntaxError),t}function g(){if(i(ho))return m();if('"'===t[e])return function(){n('"',SyntaxError);let i="";for(;;){if(i+=a(mo),"\\"!==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(ho),i=e.length;return{type:"num",value:parseFloat(t),precision:i}}function f(){if(i(fo))return a(fo);if(i(bo)){let[,t,e]=r(bo),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(ko),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(yo,"\n"),i=xo.exec(t)[1].length;return new Io(e,i)}}}class Io{constructor(t,e){this.value=t,this.length=e}}const Lo=/<|&#?\w+;/,Ro={"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"]},No={"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 Fo(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(Lo.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=jo(e,i);t.replaceChild(n,i);continue}if(Vo(i)){const e=Uo(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(Ho(i),i)}e.textContent="",e.appendChild(t)}(e.content,t)}else t.textContent=i;Oo(e,t)}function Bo(t,e){if(!t)return!1;for(let i of t)if(i.name===e)return!0;return!1}function Oo(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))zo(n.name,e,i)&&!Bo(t.attributes,n.name)&&e.removeAttribute(n.name);if(t.attributes)for(const n of Array.from(t.attributes))zo(n.name,e,i)&&e.getAttribute(n.name)!==n.value&&e.setAttribute(n.name,n.value)}function jo(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.`),Ho(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}).`),Ho(e);t.removeChild(n);return $o(e,n.cloneNode(!1))}function Uo(t){const e=t.ownerDocument.createElement(t.localName);return $o(t,e)}function Ho(t){return t.ownerDocument.createTextNode(t.textContent)}function Vo(t){const e=Ro[t.namespaceURI];return e&&e.includes(t.localName)}function zo(t,e,i=null){if(i&&i.includes(t))return!0;const n=No[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 $o(t,e){return e.textContent=t.textContent,Oo(t,e),e}class Wo extends Array{static from(t){return t instanceof this?t:new this(t)}}class Go extends Wo{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 qo{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=Ko(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,Yo)}formatValues(t){return this.formatWithFallback(t,Xo)}async formatValue(t,e){const[i]=await this.formatValues([{id:t,args:e}]);return i}handleEvent(){this.onChange()}onChange(t=!1){this.bundles=Go.from(this.generateBundles(this.resourceIds)),t&&this.bundles.touchNext(2)}}function Xo(t,e,i,n){return i.value?t.formatPattern(i.value,n,e):null}function Yo(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 Ko(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 Qo="data-l10n-id",Zo="data-l10n-args",Jo=`[${Qo}]`;class tl extends qo{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:[Qo,Zo]}}onChange(t=!1){super.onChange(t),this.roots&&this.translateRoots()}setAttributes(t,e,i){return t.setAttribute(Qo,e),i?t.setAttribute(Zo,JSON.stringify(i)):t.removeAttribute(Zo),t}getAttributes(t){return{id:t.getAttribute(Qo),args:JSON.parse(t.getAttribute(Zo)||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(Qo)&&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]&&Fo(t[i],e[i]);this.resumeObserving()}getTranslatables(t){const e=Array.from(t.querySelectorAll(Jo));return"function"==typeof t.hasAttribute&&t.hasAttribute(Qo)&&e.push(t),e}getKeysForElement(t){return{id:t.getAttribute(Qo),args:JSON.parse(t.getAttribute(Zo)||null)}}}class el{#Yh;#jr;#hs;#Kh;constructor({lang:t,isRTL:e},i=null){this.#hs=el.#Qh(t),this.#Kh=i,this.#Yh=e??el.#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 il(){const{isAndroid:t,isLinux:e,isMac:i,isWindows:n}=Js.platform;return e?"linux":n?"windows":i?"macos":t?"android":"other"}function nl(t,e){const i=new Do(e),n=new ro(t,{functions:{PLATFORM:il}}),s=n.addResource(i);return s.length&&console.error("L10n errors",s),n}class sl extends el{constructor(t){super({lang:t});const e=t?sl.#Jh.bind(sl,"en-us",this.getLanguage()):sl.#td.bind(sl,this.getLanguage());this._setL10n(new tl([],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 nl(t,await tr(s,"text"))}static async#ed(){try{const{href:t}=document.querySelector('link[type="application/l10n"]'),e=await tr(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 nl(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 rl(){return document.location.hash}class al{#Hl=null;#sd=null;#Vh=null;#lh=null;#Kl=null;#b;constructor(t){this.pdfPage=t.pdfPage,this.accessibilityManager=t.accessibilityManager,this.l10n=t.l10n,this.l10n||=new sl,this.annotationEditorLayer=null,this.div=null,this._cancelled=!1,this.#b=t.uiManager,this.#Hl=t.annotationLayer||null,this.#Kl=t.textLayer||null,this.#sd=t.drawLayer||null,this.#Vh=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.#Vh?.(n),this.annotationEditorLayer=new js({uiManager:this.#b,div:n,structTreeLayer:this.#lh,accessibilityManager:this.accessibilityManager,pageIndex:this.pdfPage.pageNumber-1,l10n:this.l10n,viewport:i,annotationLayer:this.#Hl,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 ol=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)&&ol.set("maxCanvasPixels",5242880),n&&ol.set("useSystemFonts",!1)}const ll=1,hl=2,dl=4,cl=8,ul=16,pl=128,gl={BOOLEAN:1,NUMBER:2,OBJECT:4,STRING:8,UNDEFINED:16},ml={allowedGlobalEvents:{value:null,kind:ll},canvasMaxAreaInBytes:{value:-1,kind:ll+dl},isInAutomation:{value:!1,kind:ll},localeProperties:{value:{lang:navigator.language||"en-US"},kind:ll},maxCanvasDim:{value:32767,kind:ll+hl},nimbusDataStr:{value:"",kind:ll},supportsCaretBrowsingMode:{value:!1,kind:ll},supportsDocumentFonts:{value:!0,kind:ll},supportsIntegratedFind:{value:!1,kind:ll},supportsMouseWheelZoomCtrlKey:{value:!0,kind:ll},supportsMouseWheelZoomMetaKey:{value:!0,kind:ll},supportsPinchToZoom:{value:!0,kind:ll},supportsPrinting:{value:!0,kind:ll},toolbarDensity:{value:0,kind:ll+ul},altTextLearnMoreUrl:{value:"",kind:hl+pl},annotationEditorMode:{value:0,kind:hl+pl},annotationMode:{value:2,kind:hl+pl},capCanvasAreaFactor:{value:200,kind:hl+pl},commentLearnMoreUrl:{value:"",kind:hl+pl},cursorToolOnLoad:{value:0,kind:hl+pl},debuggerSrc:{value:"./debugger.mjs",kind:hl},defaultZoomDelay:{value:400,kind:hl+pl},defaultZoomValue:{value:"",kind:hl+pl},disableHistory:{value:!1,kind:hl},disablePageLabels:{value:!1,kind:hl+pl},enableAltText:{value:!1,kind:hl+pl},enableAltTextModelDownload:{value:!0,kind:hl+pl+ul},enableAutoLinking:{value:!0,kind:hl+pl},enableComment:{value:!1,kind:hl+pl},enableDetailCanvas:{value:!0,kind:hl},enableGuessAltText:{value:!0,kind:hl+pl+ul},enableHighlightFloatingButton:{value:!1,kind:hl+pl},enableNewAltTextWhenAddingImage:{value:!0,kind:hl+pl},enableOptimizedPartialRendering:{value:!1,kind:hl+pl},enablePermissions:{value:!1,kind:hl+pl},enablePrintAutoRotate:{value:!0,kind:hl+pl},enableScripting:{value:!0,kind:hl+pl},enableSignatureEditor:{value:!1,kind:hl+pl},enableUpdatedAddImage:{value:!1,kind:hl+pl},externalLinkRel:{value:"noopener noreferrer nofollow",kind:hl},externalLinkTarget:{value:0,kind:hl+pl},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:hl+pl},historyUpdateUrl:{value:!1,kind:hl+pl},ignoreDestinationZoom:{value:!1,kind:hl+pl},imageResourcesPath:{value:"./images/",kind:hl},maxCanvasPixels:{value:2**25,kind:hl},minDurationToUpdateCanvas:{value:500,kind:hl},forcePageColors:{value:!1,kind:hl+pl},pageColorsBackground:{value:"Canvas",kind:hl+pl},pageColorsForeground:{value:"CanvasText",kind:hl+pl},pdfBugEnabled:{value:!1,kind:hl+pl},printResolution:{value:150,kind:hl},sidebarViewOnLoad:{value:-1,kind:hl+pl},scrollModeOnLoad:{value:-1,kind:hl+pl},spreadModeOnLoad:{value:-1,kind:hl+pl},textLayerMode:{value:1,kind:hl+pl},viewerCssTheme:{value:0,kind:hl+pl},viewOnLoad:{value:0,kind:hl+pl},cMapPacked:{value:!0,kind:dl},cMapUrl:{value:"../web/cmaps/",kind:dl},disableAutoFetch:{value:!1,kind:dl+pl},disableFontFace:{value:!1,kind:dl+pl},disableRange:{value:!1,kind:dl+pl},disableStream:{value:!1,kind:dl+pl},docBaseUrl:{value:"",kind:dl},enableHWA:{value:!0,kind:dl+hl+pl},enableXfa:{value:!0,kind:dl+pl},fontExtraProperties:{value:!1,kind:dl},iccUrl:{value:"../web/iccs/",kind:dl},isEvalSupported:{value:!0,kind:dl},isOffscreenCanvasSupported:{value:!0,kind:dl},maxImageSize:{value:-1,kind:dl},pdfBug:{value:!1,kind:dl},standardFontDataUrl:{value:"../web/standard_fonts/",kind:dl},useSystemFonts:{value:void 0,kind:dl,type:gl.BOOLEAN+gl.UNDEFINED},verbosity:{value:1,kind:dl},wasmUrl:{value:"../web/wasm/",kind:dl},workerPort:{value:null,kind:cl},workerSrc:{value:"../build/pdf.worker.mjs",kind:cl}};ml.defaultUrl={value:"compressed.tracemonkey-pldi-09.pdf",kind:hl},ml.sandboxBundleSrc={value:"../build/pdf.sandbox.mjs",kind:hl},ml.enableFakeMLManager={value:!0,kind:hl},ml.disablePreferences={value:!1,kind:hl};class fl{static eventBus;static#rd=new Map;static{for(const t in ml)this.#rd.set(t,ml[t].value);for(const[t,e]of ol)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 ml){const s=ml[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=ml[n],r=t[n];if(!s||!(typeof r==typeof s.value||gl[(typeof r).toUpperCase()]&s.type))continue;const{kind:a}=s;(!e||a&ll||a&pl)&&(this.eventBus&&a&ul&&(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 bl({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 Fr.normalizeRect([a[0],a[1],o[0],o[1]])}function vl(t,e){const i=t.getClientRects();if(1===i.length)return{rect:bl(i[0],e)};const n=[1/0,1/0,-1/0,-1/0],s=[];let r=0;for(const t of i){const i=bl(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],Fr.rectBoundingBox(...i,n),r+=8)}return{quadPoints:s,rect:n}}function wl(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 yl{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]=ka(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=Ys(r,null,{addDefaultProtocol:!0});if(a){const[n,r]=Da(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(...wl(r.textDivs[a.divIdx],a.offset)),l.setEnd(...wl(r.textDivs[o.divIdx],o.offset)),{id:`inferred_link_${s}`,unsafeUrl:t,url:t,annotationType:Ws.LINK,rotation:0,...vl(l,n),borderStyle:null}}(e,t,this.#ad++))}}class xl{#od=null;#ld=0;#hd=null;#dd=Ur.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 Ur.PAUSED:this.div.classList.remove("loading"),this.#ud=0,this.#cd?.(!1);break;case Ur.RUNNING:this.div.classList.add("loadingIcon"),this.#od=setTimeout(()=>{this.div.classList.add("loading"),this.#od=null},0),this.#ud=Date.now();break;case Ur.INITIAL:case Ur.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=Ur.PAUSED,void(this.resume=()=>{this.renderingState=Ur.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 Cr&&(e(),this.#hd=null)};let s=null;try{await n.promise,this.#cd?.(!0)}catch(t){if(t instanceof Cr)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=Ur.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 Al{#sd=null;constructor(t){this.pageIndex=t.pageIndex}async render({intent:t="display"}){"display"!==t||this.#sd||this._cancelled||(this.#sd=new Zs({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 _l extends xl{#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===Ur.RUNNING||this.renderingState===Ur.PAUSED;this.cancelRendering(),this.renderingState=Ur.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=Ur.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*vr.pixelRatio**2,l=(Math.sqrt(vr.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===Ur.FINISHED||this.renderingState===Ur.FINISHED;this.renderingState!==Ur.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=Ur.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Ur.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}=vr,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 Sl={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},Cl=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"]),El="http://www.w3.org/1998/Math/MathML";class Pl{static get sanitizer(){return Mr(this,"sanitizer",Js.isSanitizerSupported?new Sanitizer({elements:[...Cl].map(t=>({name:t,namespace:El})),replaceWithChildrenElements:[{name:"maction",namespace:El}],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 Tl=/^H(\d+)$/;class Ml{#vd;#wd=null;#yd;#xd=new Map;#Ad;#_d=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.#Sd(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=Jr(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",Jr(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.#_d||=new Map).set(a,o),o.setAttribute("role","img"),o.setAttribute("aria-label",Jr(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.#_d){for(const[t,e]of this.#_d)document.getElementById(t)?.append(e);this.#_d.clear(),this.#_d=null}}#Sd(t){if(!t)return null;let e;if("role"in t){const{role:i}=t;e=Cl.has(i)?document.createElementNS(El,i):document.createElement("span");const n=i.match(Tl);if(n?(e.setAttribute("role","heading"),e.setAttribute("aria-level",n[1])):Sl[i]&&e.setAttribute("role",Sl[i]),"Figure"===i&&this.#Ed(t,e))return e;"Formula"===i&&(t.mathML&&Pl.sanitizer&&e.setHTML(t.mathML,{sanitizer:Pl.sanitizer}),t.mathML||1!==t.children.length||"math"===t.children[0].role||(e=document.createElementNS(El,"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.#Sd(i));return e}}class kl{#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(kl.#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=ta(n,e=>kl.#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=ta(r,t=>kl.#Dd(e,t)<0);return 0===a?r[0].before(e):r[a-1].after(e),s}}class Dl{#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 Il{#Ld=!1;#Vh=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.#Vh=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 Lr({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.#Vh?.(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(),Il.#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",Jr(fr(e.toString())))}Dr(t)}),Il.#Nd.set(e,t),Il.#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 Ll{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,jr.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?jr.update(n):(this.div=document.createElement("div"),n.div=this.div,jr.render(n))}cancel(){this._cancelled=!0}hide(){this.div&&(this.div.hidden=!0)}}const Rl={annotationEditorUIManager:null,annotationStorage:null,downloadManager:null,enableScripting:!1,fieldObjectsPromise:null,findController:null,hasJSActionsPromise:null,get linkService(){return new Na}},Nl=new Map([["canvasWrapper",0],["textLayer",1],["annotationLayer",2],["annotationEditorLayer",3],["xfaLayer",3]]);class Fl extends xl{#Ud=$s.ENABLE_FORMS;#Hd=null;#z=null;#Vd=!0;#zd=!1;#We=!1;#$d=null;#Wd=!1;#Gd=null;#qd=null;#Xd=1;#Yd=1;#Kd=Gr;#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||Rl,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??Gr,this.#Ud=t.annotationMode??$s.ENABLE_FORMS,this.imageResourcesPath=t.imageResourcesPath||"",this.enableDetailCanvas=t.enableDetailCanvas??!0,this.maxCanvasPixels=t.maxCanvasPixels??fl.get("maxCanvasPixels"),this.maxCanvasDim=t.maxCanvasDim||fl.get("maxCanvasDim"),this.capCanvasAreaFactor=t.capCanvasAreaFactor??fl.get("capCanvasAreaFactor"),this.#Vd=!1!==t.enableAutoLinking,this.#z=t.commentManager||null,this.l10n=t.l10n,this.l10n||=new sl,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*Sr.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=Nl.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}Tr(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*Sr.PDF_TO_CSS_UNITS,rotation:e}),this.#tc(),this.reset()}destroy(){this.reset(),this.pdfPage?.cleanup()}hasEditableAnnotations(){return!!this.annotationLayer?.hasEditableAnnotations()}get _textHighlighter(){return Mr(this,"_textHighlighter",new Dl({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 Os)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(yl.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=Ur.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.#Hd||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.#Hd&&(this.#Hd=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 _l({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*Sr.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!==Ur.FINISHED&&(this.cancelRendering({keepAnnotationLayer:!0,keepAnnotationEditorLayer:!0,keepXfaLayer:!0,keepTextLayer:!0,cancelExtraDelay:n}),this.renderingState=Ur.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 vr;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.#Hd;return t||(t=this.#Hd=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!==Ur.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=Ur.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Ur.RUNNING;const s=this._ensureCanvasWrapper();if(this.textLayer||this.#Kd===Wr||i.isPureXfa||(this._accessibilityManager||=new kl,this.textLayer=new Il({pdfPage:i,highlighter:this._textHighlighter,accessibilityManager:this._accessibilityManager,enablePermissions:this.#Kd===qr,onAppend:t=>{this.l10n.pause(),this.#ec(t,"textLayer"),this.l10n.resume()}})),!this.annotationLayer&&this.#Ud!==$s.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 Fa({pdfPage:i,annotationStorage:t,imageResourcesPath:this.imageResourcesPath,renderForms:this.#Ud===$s.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=ea(h.sx),c=ea(h.sy),u=o.width=ia(aa(r*h.sx),d[0]),p=o.height=ia(aa(a*h.sy),c[0]),g=ia(aa(r),d[1]),m=ia(aa(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!==Ur.FINISHED)return;this.structTreeLayer||=new Ml(i,n.rawDims);const t=this.#lc();this.annotationLayer&&(await this.#nc(),this.#Vd&&this.annotationLayer&&this.textLayer&&await this.#dc(t));const{annotationEditorUIManager:r}=this.#$d;r&&(this.drawLayer||=new Al({pageIndex:this.id}),await this.#rc(),this.drawLayer.setParent(s),(this.annotationLayer||this.#Ud===$s.DISABLE)&&(this.annotationEditorLayer||=new al({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 Ll({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 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 Ol{#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.#_c(e),this.#Sc(t))},{signal:r}),s._on("pagerendered",({pageNumber:t})=>{this._pageOpenPending.has(t)&&t===this.#fc.currentPageNumber&&this.#Sc(t)},{signal:r}),s._on("pagesdestroy",async()=>{await this.#_c(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.#Sc(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 Mr(this,"_pageOpenPending",new Set)}get _visitedPages(){return Mr(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=Xr.VERTICAL,i=Yr.NONE;switch(t){case"SinglePage":e=Xr.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=Xr.PAGE;case"TwoColumnLeft":i=Yr.ODD;break;case"TwoPageRight":e=Xr.PAGE;case"TwoColumnRight":i=Yr.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#Sc(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!==Ur.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#_c(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 jl=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===Ur.FINISHED}renderView(t){switch(t.renderingState){case Ur.FINISHED:return!1;case Ur.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Ur.RUNNING:this.highestPriorityPage=t.renderingId;break;case Ur.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof Cr||console.error("renderView:",t)})}return!0}};const Ul=1e4,Hl=5e3,Vl=250;function zl(t){return Object.values(Hs).includes(t)&&t!==Hs.DISABLE}class $l{#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 Wl{#Ti=null;#j=null;#Tc=null;#Mc=Hs.NONE;#kc=null;#Ud=$s.ENABLE_FORMS;#z=null;#Dc=null;#Ic=null;#tn=!1;#Q=!1;#Ld=!1;#Z=!1;#J=!1;#Vd=!0;#zh=null;#ld=0;#gt=null;#Lc=!0;#Rc=null;#Nc=null;#Fc=null;#Bc=!1;#Oc=null;#jc=!1;#Uc=0;#Hc=new ResizeObserver(this.#Vc.bind(this));#zc=null;#$c=null;#vt=null;#Wc=!0;#Kd=Gr;#Pt=null;constructor(t){const e="5.4.394";if(Or!==e)throw new Error(`The API version "${Or}" 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.#Hc.observe(this.container),this.eventBus=t.eventBus,this.linkService=t.linkService||new Na,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??Gr,this.#Ud=t.annotationMode??$s.ENABLE_FORMS,this.#Mc=t.annotationEditorMode??Hs.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 sl,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.#Vd=!1!==t.enableAutoLinking,this.#ld=t.minDurationToUpdateCanvas??500,this.defaultRenderingQueue=!t.renderingQueue,this.defaultRenderingQueue?(this.renderingQueue=new jl,this.renderingQueue.setViewer(this)):this.renderingQueue=t.renderingQueue;const{abortSignal:i}=t;i?.addEventListener("abort",()=>{this.#Hc.disconnect(),this.#Hc=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=Hr,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===$s.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(!na(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 Mr(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(_r.PRINT_HIGH_QUALITY)||t.includes(_r.PRINT),this.eventBus.dispatch("printingallowed",{source:this,isAllowed:this.#Lc}),t.includes(_r.COPY)||this.#Kd!==Gr||(e.textLayerMode=qr),t.includes(_r.MODIFY_CONTENTS)||(e.annotationEditorMode=Hs.DISABLE),t.includes(_r.MODIFY_ANNOTATIONS)||t.includes(_r.FILL_INTERACTIVE_FORMS)||this.#Ud!==$s.ENABLE_FORMS||(e.annotationMode=$s.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(Jr(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===qr)return void Dr(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")}),Dr(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=Hs.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>Ul){console.warn("Forcing PAGE-scrolling for performance reasons, given the length of the document.");const t=this._scrollMode=Xr.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!==Wr){const t=this.#Oc=document.createElement("div");t.id="hiddenCopyElement",o.before(t)}if(h!==Hs.DISABLE){const e=h;t.isPureXfa?console.warn("Warning: XFA-editing is not implemented."):zl(e)?(this.#kc=new Vs(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!==Hs.NONE&&(this.#Zc(e),this.#kc.updateMode(e))):console.error(`Invalid AnnotationEditor mode: ${e}`)}const u=this._scrollMode===Xr.PAGE?null:o,p=this.currentScale,g=i.getViewport({scale:p*Sr.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 Fl({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.#Vd,minDurationToUpdateCanvas:this.#ld,commentManager:this.#z});this._pages.push(e)}this._pages[0]?.setPdfPage(i),this._scrollMode===Xr.PAGE?this.#Jc():this._spreadMode!==Yr.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>Hl)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%Vl===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 $l(10),this._location=null,this._pagesRotation=0,this._optionalContentConfigPromise=null,this._firstPageCapability=Promise.withResolvers(),this._onePageRenderedCapability=Promise.withResolvers(),this._pagesCapability=Promise.withResolvers(),this._scrollMode=Xr.VERTICAL,this._previousScrollMode=Xr.UNKNOWN,this._spreadMode=Yr.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!==Xr.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!==Yr.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===Xr.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===Xr.HORIZONTAL||t<s||n>s+r)&&(e={left:0,top:0})}Kr(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*Sr.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!==Yr.NONE&&this._scrollMode!==Xr.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!==Yr.NONE&&(s*=2)):this.removePageBorders?s=r=0:this._scrollMode===Xr.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=sa(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/Sr.PDF_TO_CSS_UNITS,g=(u?r.width:r.height)/r.scale/Sr.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/Sr.PDF_TO_CSS_UNITS,o=(this.container.clientHeight-i)/c/Sr.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===Yr.NONE&&(this._scrollMode===Xr.PAGE||this._scrollMode===Xr.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===$r}get isChangingPresentationMode(){return this.presentationModeState===zr}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===Xr.PAGE?this.#zc.pages:this._pages,e=this._scrollMode===Xr.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=ta(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!==Ur.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 Xr.PAGE:return this.#zc.scrollDown;case Xr.HORIZONTAL:return this.scroll.right}return this.scroll.down}forceRendering(t){const e=t||this._getVisiblePages(),i=this.#lu(e),n=this._spreadMode!==Yr.NONE&&this._scrollMode!==Xr.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=sa(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(Xr).includes(t)&&t!==Xr.UNKNOWN}(t))throw new Error(`Invalid scroll mode: ${t}`);this.pagesCount>Ul||(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===Xr.HORIZONTAL),i.classList.toggle("scrollWrapped",e===Xr.WRAPPED),this.pdfDocument&&t&&(e===Xr.PAGE?this.#Jc():this._previousScrollMode===Xr.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(Yr).includes(t)&&t!==Yr.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===Xr.PAGE)this.#Jc();else if(e.textContent="",this._spreadMode===Yr.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 Xr.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 Xr.HORIZONTAL:break;case Xr.PAGE:case Xr.VERTICAL:{if(this._spreadMode===Yr.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=gr(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,ra.setProperty("--viewer-container-height",`${t}px`))}#Vc(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 Hs.STAMP:this.#gt?.loadModel("altText");break;case Hs.SIGNATURE:this.#vt?.loadSignatures()}}get annotationEditorMode(){return this.#kc?this.#Mc:Hs.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(!zl(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===Hs.NONE||this.#Mc===Hs.NONE){const e=t!==Hs.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 Gl extends Wl{_resetView(){super._resetView(),this._scrollMode=Xr.PAGE,this._spreadMode=Yr.NONE}set scrollMode(t){}_updateScrollMode(){}set spreadMode(t){}_updateSpreadMode(){}}var ql,Xl,Yl,Kl,Ql;globalThis.pdfjsViewer={AnnotationLayerBuilder:Fa,DownloadManager:Oa,EventBus:Ha,FindState:ba,GenericL10n:sl,LinkTarget:La,parseQueryString:Qr,PDFFindController:Ia,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=rl(),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(Qr(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=Nr(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(rl()).substring(1),i=Qr(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=rl(),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 Ha?"_on":"addEventListener"](e,a.bind(null,ja),{signal:r.signal});const o=setTimeout(a.bind(null,Ua),i);return n}({target:window,name:"hashchange",delay:1e3}).then(()=>{this._blockHashChange--}));const n=t.destination;this.#pu(n,t.uid,!0),na(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:Ra,PDFPageView:Fl,PDFScriptingManager:class extends Ol{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{info:e,metadata:i,contentDispositionFilename:n,contentLength:s}=await t.getMetadata();return{...e,baseURL:"",filesize:s||(await t.getDownloadInfo()).length,filename:n||sr(""),metadata:i?.getRaw(),authors:i?.get("dc:creator"),numPages:t.numPages,URL:""}}(t),super(t)}},PDFSinglePageViewer:Gl,PDFViewer:Wl,ProgressBar:class{#yu=null;#xu=null;#Au=0;#_u=null;#Zn=!0;constructor(t){this.#yu=t.classList,this.#_u=t.style}get percent(){return this.#Au}set percent(t){this.#Au=gr(t,0,100),isNaN(t)?this.#yu.add("indeterminate"):(this.#yu.remove("indeterminate"),this.#_u.setProperty("--progressBar-percent",`${this.#Au}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&this.#_u.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:Ur,ScrollMode:Xr,SimpleLinkService:Na,SpreadMode:Yr,StructTreeLayerBuilder:Ml,TextLayerBuilder:Il,XfaLayerBuilder:Ll};const Zl={INITIAL:0,RUNNING:1,PAUSED:2,FINISHED:3},Jl={UNKNOWN:0,NORMAL:1,CHANGING:2,FULLSCREEN:3},th={UNKNOWN:-1,NONE:0,THUMBS:1,OUTLINE:2,ATTACHMENTS:3,LAYERS:4},eh={DISABLE:0,ENABLE:1,ENABLE_PERMISSIONS:2},ih={UNKNOWN:-1,VERTICAL:0,HORIZONTAL:1,WRAPPED:2,PAGE:3},nh={UNKNOWN:-1,NONE:0,ODD:1,EVEN:2};function sh(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=gt((n.clientWidth-i)/2,20,400);r+=e.left-s}else r+=e.left;n.scrollLeft=r}n.scrollTop=s}function rh(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 ah=/[\x00-\x1F]/g;function oh(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 lh({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 hh(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 dh({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=oh(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=hh(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 ch(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 uh(t){const e=t.deltaMode;let i=ch(t);return e===WheelEvent.DOM_DELTA_PIXEL?i/=900:e===WheelEvent.DOM_DELTA_LINE&&(i/=30),i}function ph(t){return Number.isInteger(t)&&t%90==0}function gh(t){return Number.isInteger(t)&&Object.values(ih).includes(t)&&t!==ih.UNKNOWN}function mh(t){return Number.isInteger(t)&&Object.values(nh).includes(t)&&t!==nh.UNKNOWN}function fh(t){return t.width<=t.height}const bh=new Promise(function(t){window.requestAnimationFrame(t)}),vh=document.documentElement.style;ql=new WeakMap,Xl=new WeakMap,Yl=new WeakMap,Kl=new WeakMap,Ql=new WeakMap;const wh=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 yh{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===Zl.FINISHED}renderView(t){switch(t.renderingState){case Zl.FINISHED:return!1;case Zl.PAUSED:this.highestPriorityPage=t.renderingId,t.resume();break;case Zl.RUNNING:this.highestPriorityPage=t.renderingId;break;case Zl.INITIAL:this.highestPriorityPage=t.renderingId,t.draw().finally(()=>{this.renderHighestPriority()}).catch(t=>{t instanceof At||console.error("renderView:",t)})}return!0}}var xh,Ah,_h,Sh,Ch,Eh,Ph,Th;function Mh(t){t.width=0,t.height=0}class kh{static getCanvas(t,e){const i=s(this,xh,n(this,xh,"f",Ah)||document.createElement("canvas"),"f",Ah);i.width=t,i.height=e;const r=i.getContext("2d",{alpha:!1});return r.save(),r.fillStyle="rgb(255, 255, 255)",r.fillRect(0,0,t,e),r.restore(),[i,i.getContext("2d")]}static destroyCanvas(){n(this,xh,"f",Ah)&&Mh(n(this,xh,"f",Ah)),s(this,xh,null,"f",Ah)}}xh=kh,Ah={value:null};class Dh{constructor({container:t,eventBus:e,id:i,defaultViewport:s,optionalContentConfigPromise:r,linkService:a,renderingQueue:o,maxCanvasPixels:l,maxCanvasDim:h,pageColors:d,enableHWA:c,store:u,thumbnailWidth:p}){_h.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=r||null,this.maxCanvasPixels=null!=l?l:33554432,this.maxCanvasDim=h||32767,this.pageColors=d||null,this.enableHWA=c||!1,this.eventBus=e,this.linkService=a,this.renderingQueue=o,this.renderTask=null,this.renderingState=Zl.INITIAL,this.resume=null,this.store=u,this.thumbnailWidth=p,this.loaded=!1;const g=document.createElement("div");g.className="thumbnail pdfSlickThumbHolder",g.setAttribute("data-page-number",this.id.toString()),this.div=g,n(this,_h,"m",Sh).call(this),t.append(g)}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=Zl.INITIAL,this.div.removeAttribute("data-loaded"),this.loaded=!1,n(this,_h,"m",Sh).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 i(this,void 0,void 0,function*(){if(this.renderingState!==Zl.INITIAL)return void console.error("Must be in new state before drawing");const{pageColors:t,pdfPage:e}=this;if(!e)throw this.renderingState=Zl.FINISHED,new Error("pdfPage is not loaded");this.renderingState=Zl.RUNNING;const{ctx:i,canvas:s,transform:r}=n(this,_h,"m",Ch).call(this,2),a={canvas:s,canvasContext:i,transform:r,viewport:this.viewport.clone({scale:2*this.scale}),optionalContentConfigPromise:this._optionalContentConfigPromise,pageColors:t},o=this.renderTask=e.render(a);o.onContinue=t=>{if(!this.renderingQueue.isHighestPriority(this))return this.renderingState=Zl.PAUSED,void(this.resume=()=>{this.renderingState=Zl.RUNNING,t()});t()};let l=null;try{yield o.promise}catch(t){if(t instanceof At)return void Mh(s);l=t}finally{o===this.renderTask&&(this.renderTask=null)}if(this.renderingState=Zl.FINISHED,n(this,_h,"m",Eh).call(this,s),Mh(s),this.eventBus.dispatch("thumbnailrendered",{source:this,pageNumber:this.id,pdfPage:e}),l)throw l})}setImage(t){if(this.renderingState!==Zl.INITIAL)return;const{thumbnailCanvas:e,pdfPage:i,scale:s}=t;e&&(this.pdfPage||this.setPdfPage(i),s<this.scale||(this.renderingState=Zl.FINISHED,n(this,_h,"m",Eh).call(this,e)))}setPageLabel(t){this.pageLabel="string"==typeof t?t:null}}var Ih,Lh,Rh,Nh,Fh,Bh,Oh;_h=new WeakSet,Sh=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`)},Ch=function(t=1,e=this.enableHWA){const i=document.createElement("canvas"),n=i.getContext("2d",{alpha:!1,willReadFrequently:!e}),s=new Ft,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}},Eh=function(t){if(this.renderingState!==Zl.FINISHED)throw new Error("#convertCanvasToImage: Rendering has not finished.");const e=n(this,_h,"m",Th).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},Ph=function(t){const e=t.width<<3,i=t.height<<3,n=new Ft;return n.sx=n.sy=1,n.limitCanvas(e,i,this.maxCanvasPixels,this.maxCanvasDim),[e*n.sx|0,i*n.sy|0]},Th=function(t){const{ctx:e,canvas:i}=n(this,_h,"m",Ch).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,r]=n(this,_h,"m",Ph).call(this,i);const[a,o]=kh.getCanvas(s,r);for(;s>t.width||r>t.height;)s>>=1,r>>=1;for(o.drawImage(t,0,0,t.width,t.height,0,0,s,r);s>2*i.width;)o.drawImage(a,0,0,s,r,0,0,s>>1,r>>1),s>>=1,r>>=1;return e.drawImage(a,0,0,s,r,0,0,i.width,i.height),i};const jh="selected";class Uh{constructor({container:t,eventBus:e,linkService:i,renderingQueue:s,maxCanvasPixels:r,maxCanvasDim:a,pageColors:o,abortSignal:l,enableHWA:h,store:d,thumbnailWidth:c}){Ih.add(this),this.container=t,this.eventBus=e,this.linkService=i,this.renderingQueue=s,this.maxCanvasPixels=r||33554432,this.maxCanvasDim=a||32767,this.pageColors=o||null,this.enableHWA=h||!1,this.store=d,this.thumbnailWidth=c,this.scroll=rh(this.container,n(this,Ih,"m",Lh).bind(this),l),n(this,Ih,"m",Nh).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(jh),e.div.classList.add(jh)}const{first:i,last:s,views:r}=n(this,Ih,"m",Rh).call(this);if(r.length>0){let n=!1;if(t<=i.id||t>=s.id)n=!0;else for(const{id:e,percent:i}of r)if(e===t){n=i<100;break}n&&sh(e.div,{top:-19})}this._currentPageNumber=t}get pagesRotation(){return this._pagesRotation}set pagesRotation(t){if(!ph(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!==Zl.FINISHED&&t.reset();kh.destroyCanvas()}setDocument(t){if(this.pdfDocument&&(n(this,Ih,"m",Fh).call(this),n(this,Ih,"m",Nh).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 Dh({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(jh),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=n(this,Ih,"m",Rh).call(this),e=n(this,Ih,"m",Oh).call(this,t),i=this.renderingQueue.getHighestPriority(t,this._thumbnails,e,!1,!0);return!!i&&(n(this,Ih,"m",Bh).call(this,i).then(()=>{this.renderingQueue.renderView(i)}),!0)}}Ih=new WeakSet,Lh=function(){this.renderingQueue.renderHighestPriority()},Rh=function(){return dh({scrollEl:this.container,views:this._thumbnails})},Nh=function(){this._thumbnails=[],this._currentPageNumber=1,this._pageLabels=null,this._pagesRotation=0,this.container.textContent=""},Fh=function(){for(const t of this._thumbnails)t.cancelRendering()},Bh=function(t){return i(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}})},Oh=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 Hh=null;class Vh{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(Hh!==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,Hh=null}renderPages(t){if(this.pdfDocument.isPureXfa)return function(t,e){const i=e.allXfaHtml,n=new Na,s=Math.round(100*wt.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 Ll({pdfPage:null,annotationStorage:e.annotationStorage,linkService:n,xfaHtml:r}),o=Dt(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/wt.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:f.ENABLE_STORAGE,optionalContentConfigPromise:r,printAnnotationStorage:e};return t.render(i).promise.catch(t=>{throw t instanceof At||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===Hh}throwIfInactive(){if(!this.active)throw new Error("This print request was cancelled or completed.")}}const zh={instance:{supportsPrinting:!0,createPrintService(t){if(Hh)throw new Error("The print service is created and active.");return Hh=new Vh(t)}}};var $h,Wh,Gh,qh,Xh,Yh,Kh,Qh,Zh,Jh,td,ed,id,nd,sd,rd,ad,od,ld;const hd="pdfPresentationMode",dd="pdfPresentationModeControls",cd=Math.PI/6;class ud{constructor({container:t,pdfViewer:e,eventBus:i}){$h.add(this),Wh.set(this,Jl.UNKNOWN),Gh.set(this,null),qh.set(this,null),Xh.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 i(this,void 0,void 0,function*(){const{container:t,pdfViewer:e}=this;if(this.active||!e.pagesCount||!t.requestFullscreen)return!1;n(this,$h,"m",od).call(this),n(this,$h,"m",Kh).call(this,Jl.CHANGING);const i=t.requestFullscreen();s(this,Gh,{pageNumber:e.currentPageNumber,scaleValue:e.currentScaleValue,scrollMode:e.scrollMode,spreadMode:null,annotationEditorMode:null},"f"),e.spreadMode===nh.NONE||e.pageViewsReady&&e.hasEqualPageSizes||(console.warn("Ignoring Spread modes when entering PresentationMode, since the document may contain varying page sizes."),n(this,Gh,"f").spreadMode=e.spreadMode),e.annotationEditorMode!==v.DISABLE&&(n(this,Gh,"f").annotationEditorMode=e.annotationEditorMode);try{return yield i,e.focus(),!0}catch(t){n(this,$h,"m",ld).call(this),n(this,$h,"m",Kh).call(this,Jl.NORMAL)}return!1})}get active(){return n(this,Wh,"f")===Jl.CHANGING||n(this,Wh,"f")===Jl.FULLSCREEN}}Wh=new WeakMap,Gh=new WeakMap,qh=new WeakMap,Xh=new WeakMap,$h=new WeakSet,Yh=function(t){if(!this.active)return;t.preventDefault();const e=uh(t),i=Date.now(),s=this.mouseScrollTimeStamp;if(!(i>s&&i-s<50)&&((this.mouseScrollDelta>0&&e<0||this.mouseScrollDelta<0&&e>0)&&n(this,$h,"m",nd).call(this),this.mouseScrollDelta+=e,Math.abs(this.mouseScrollDelta)>=.1)){const t=this.mouseScrollDelta;n(this,$h,"m",nd).call(this);(t>0?this.pdfViewer.previousPage():this.pdfViewer.nextPage())&&(this.mouseScrollTimeStamp=i)}},Kh=function(t){s(this,Wh,t,"f"),this.eventBus.dispatch("presentationmodechanged",{source:this,state:t})},Qh=function(){var t;n(this,$h,"m",Kh).call(this,Jl.FULLSCREEN),this.container.classList.add(hd),setTimeout(()=>{this.pdfViewer.scrollMode=ih.PAGE,null!==n(this,Gh,"f").spreadMode&&(this.pdfViewer.spreadMode=nh.NONE),this.pdfViewer.currentPageNumber=n(this,Gh,"f").pageNumber,this.pdfViewer.currentScaleValue="page-fit",null!==n(this,Gh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:v.NONE})},0),n(this,$h,"m",rd).call(this),n(this,$h,"m",ed).call(this),this.contextMenuOpen=!1,null===(t=document.getSelection())||void 0===t||t.empty()},Zh=function(){const t=this.pdfViewer.currentPageNumber;this.container.classList.remove(hd),setTimeout(()=>{n(this,$h,"m",ld).call(this),n(this,$h,"m",Kh).call(this,Jl.NORMAL),this.pdfViewer.scrollMode=n(this,Gh,"f").scrollMode,null!==n(this,Gh,"f").spreadMode&&(this.pdfViewer.spreadMode=n(this,Gh,"f").spreadMode),this.pdfViewer.currentScaleValue=n(this,Gh,"f").scaleValue,this.pdfViewer.currentPageNumber=t,null!==n(this,Gh,"f").annotationEditorMode&&(this.pdfViewer.annotationEditorMode={mode:n(this,Gh,"f").annotationEditorMode}),s(this,Gh,null,"f")},0),n(this,$h,"m",ad).call(this),n(this,$h,"m",id).call(this),n(this,$h,"m",nd).call(this),this.contextMenuOpen=!1},Jh=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()))},td=function(){this.contextMenuOpen=!0},ed=function(){this.controlsTimeout?clearTimeout(this.controlsTimeout):this.container.classList.add(dd),this.controlsTimeout=setTimeout(()=>{this.container.classList.remove(dd),delete this.controlsTimeout},3e3)},id=function(){this.controlsTimeout&&(clearTimeout(this.controlsTimeout),this.container.classList.remove(dd),delete this.controlsTimeout)},nd=function(){this.mouseScrollTimeStamp=0,this.mouseScrollDelta=0},sd=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<=cd||s>=Math.PI-cd)?e=i:Math.abs(n)>50&&Math.abs(s-Math.PI/2)<=cd&&(e=n),e>0?this.pdfViewer.previousPage():e<0&&this.pdfViewer.nextPage()}},rd=function(){if(n(this,Xh,"f"))return;s(this,Xh,new AbortController,"f");const{signal:t}=n(this,Xh,"f"),e=n(this,$h,"m",sd).bind(this);window.addEventListener("mousemove",n(this,$h,"m",ed).bind(this),{signal:t}),window.addEventListener("mousedown",n(this,$h,"m",Jh).bind(this),{signal:t}),window.addEventListener("wheel",n(this,$h,"m",Yh).bind(this),{passive:!1,signal:t}),window.addEventListener("keydown",n(this,$h,"m",nd).bind(this),{signal:t}),window.addEventListener("contextmenu",n(this,$h,"m",td).bind(this),{signal:t}),window.addEventListener("touchstart",e,{signal:t}),window.addEventListener("touchmove",e,{signal:t}),window.addEventListener("touchend",e,{signal:t})},ad=function(){var t;null===(t=n(this,Xh,"f"))||void 0===t||t.abort(),s(this,Xh,null,"f")},od=function(){n(this,qh,"f")||(s(this,qh,new AbortController,"f"),window.addEventListener("fullscreenchange",()=>{document.fullscreenElement?n(this,$h,"m",Qh).call(this):n(this,$h,"m",Zh).call(this)},{signal:n(this,qh,"f").signal}))},ld=function(){var t;null===(t=n(this,qh,"f"))||void 0===t||t.abort(),s(this,qh,null,"f")};const pd=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},gd={isDocumentLoaded:!1,pagesReady:!1,url:null,numPages:0,pageNumber:0,scale:0,scaleValue:"auto",pagesRotation:0,spreadMode:nh.UNKNOWN,scrollMode:ih.UNKNOWN,documentOutline:null,attachments:new Map,thumbnails:new Map,thumbnailViews:new Map,annotationEditorMode:v.NONE,pdfSlick:null},md=()=>{return(t=(t,e)=>Object.assign(Object.assign({},gd),{_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})}}))?pd(t):pd;var t};var fd,bd,vd,wd,yd,xd,Ad,_d,Sd,Cd,Ed,Pd,Td,Md,kd,Dd,Id,Ld,Rd,Nd,Fd,Bd,Od,jd,Ud,Hd,Vd;class zd{constructor({eventBus:t,slick:e,printDialog:i}){fd.add(this),bd.set(this,null),vd.set(this,null),wd.set(this,null),this.eventBus=t,this.slick=e,this.printDialog=null!=i?i:null,this.bindEvents()}get supportsPrinting(){return zh.instance.supportsPrinting}get printing(){return!!n(this,bd,"f")}print(){return i(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=n(this,bd,"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===n(this,bd,"f")&&this.abort()})}else console.error("Expected print service to be initialized."),null===(e=this.printDialog)||void 0===e||e.close()}}})}abort(){var t;n(this,bd,"f")&&(n(this,bd,"f").destroy(),null===(t=this.printDialog)||void 0===t||t.close(),this.eventBus.dispatch("afterprint",{source:this}))}bindEvents(){s(this,vd,new AbortController,"f");const{signal:t}=n(this,vd,"f"),e={signal:t};this.eventBus._on("beforeprint",n(this,fd,"m",yd).bind(this),e),this.eventBus._on("afterprint",n(this,fd,"m",xd).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=n(this,vd,"f"))||void 0===t||t.abort(),s(this,vd,null,"f")}}bd=new WeakMap,vd=new WeakMap,wd=new WeakMap,fd=new WeakSet,yd=function(){n(this,bd,"f")||this.supportsPrinting&&(this.slick.viewer.pageViewsReady?(s(this,wd,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()}}}(),"f"),s(this,bd,zh.instance.createPrintService({pdfDocument:this.slick.document,pagesOverview:this.slick.viewer.getPagesOverview(),printContainer:n(this,wd,"f").element,printResolution:this.slick.printResolution,optionalContentConfigPromise:null,printAnnotationStoragePromise:null}),"f"),this.slick.forceRendering(),n(this,bd,"f").layout()):this.slick.l10n.get("printing_not_ready",null).then(t=>{window.alert(t)}))},xd=function(){var t,e,i;n(this,bd,"f")&&(n(this,bd,"f").destroy(),s(this,bd,null,"f"),null===(t=this.printDialog)||void 0===t||t.close(),null===(e=n(this,wd,"f"))||void 0===e||e.remove(),s(this,wd,null,"f"),null===(i=this.slick.document)||void 0===i||i.annotationStorage.resetModified()),this.slick.forceRendering()};class $d{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 $d(t)}constructor(t){this.dialog=t}open(t){return i(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}))}}Gi.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:e&&"SCRIPT"===e.tagName.toUpperCase()&&e.src||new URL("index.js",document.baseURI).href).toString();const Wd={"8.5x11":"Letter","8.5x14":"Legal"},Gd={"297x420":"A3","210x297":"A4"};function qd(t,e,i){return i[`${e?t.width:t.height}x${e?t.height:t.width}`]}_d=new WeakMap,Sd=new WeakMap,Cd=new WeakMap,Ed=new WeakMap,Pd=new WeakMap,Td=new WeakMap,Md=new WeakMap,kd=new WeakMap,Dd=new WeakMap,Ad=new WeakSet,Id=function(){return i(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)})},Ld=function(){return i(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=>n(this,Ad,"m",Rd).call(this,lh(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:kt.toDateObject(t.CreationDate),modificationDate:kt.toDateObject(t.ModDate),isLinearized:t.IsLinearized,pageSize:i})})},Rd=function(t,e){return i(this,void 0,void 0,function*(){if(!t)return;e%180!=0&&(t={width:t.height,height:t.width});const i=fh(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=qd(n,i,Wd)||qd(s,i,Gd);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=qd(a,i,Gd),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}})},Nd=function(){s(this,Dd,new AbortController,"f");const{signal:t}=n(this,Dd,"f"),e={signal:t};this.eventBus._on("pagesinit",n(this,Ad,"m",Fd).bind(this),e),this.eventBus._on("scalechanging",n(this,Ad,"m",Ud).bind(this),e),this.eventBus._on("pagechanging",n(this,Ad,"m",Hd).bind(this),e),this.eventBus._on("pagerendered",n(this,Ad,"m",Vd).bind(this),e),this.eventBus._on("rotationchanging",n(this,Ad,"m",Bd).bind(this),e),this.eventBus._on("switchspreadmode",n(this,Ad,"m",Od).bind(this),e),this.eventBus._on("switchscrollmode",n(this,Ad,"m",jd).bind(this),e)},Fd=function(t){return i(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})})},Bd=function({pagesRotation:t,pageNumber:e}){this.store.setState({pagesRotation:t}),this.thumbnailViewer&&(this.thumbnailViewer.pagesRotation=t),this.forceRendering(),this.viewer.currentPageNumber=e},Od=function({mode:t}){this.store.setState({spreadMode:t})},jd=function({mode:t}){this.store.setState({scrollMode:t})},Ud=function({scale:t,presetValue:e}){this.store.setState({scale:t,scaleValue:e}),this.viewer.update()},Hd=function({pageNumber:t}){var e;null===(e=this.thumbnailViewer)||void 0===e||e.scrollThumbnailIntoView(t),this.store.setState({pageNumber:t})},Vd=function({pageNumber:t,error:e}){var i;if(n(this,Ed,"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)}},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=class{constructor({container:t,viewer:e,thumbs:i,store:r=md(),options:a,onError:o,printDialog:l}){var h,d,c,u,p,g,m,b,w,y,x,A,_,S,C,E,P,T,M,k,D,I;Ad.add(this),_d.set(this,void 0),Sd.set(this,void 0),Cd.set(this,void 0),Ed.set(this,void 0),Pd.set(this,void 0),this.downloadManager=null,this.findController=null,this.pdfPresentationMode=null,this.document=null,Td.set(this,void 0),Md.set(this,void 0),kd.set(this,void 0),Dd.set(this,void 0),s(this,Sd,t,"f"),s(this,Cd,e,"f"),s(this,Ed,i,"f"),s(this,kd,o,"f"),this.l10n=null!==(h=null==a?void 0:a.l10n)&&void 0!==h?h:new sl(navigator.language),this.downloadManager=new Oa,this.textLayerMode=null!==(d=null==a?void 0:a.textLayerMode)&&void 0!==d?d:eh.ENABLE,s(this,Td,null!==(c=null==a?void 0:a.annotationMode)&&void 0!==c?c:f.ENABLE_FORMS,"f"),s(this,Md,null!==(u=null==a?void 0:a.annotationEditorMode)&&void 0!==u?u:v.NONE,"f"),this.annotationEditorHighlightColors=null!==(p=null==a?void 0:a.annotationEditorHighlightColors)&&void 0!==p?p:"yellow=#FFFF98,green=#53FFBC,blue=#80EBFF,pink=#FFCBE6,red=#FF4F5F",this.removePageBorders=null!==(g=null==a?void 0:a.removePageBorders)&&void 0!==g&&g,this.singlePageViewer=null!==(m=null==a?void 0:a.singlePageViewer)&&void 0!==m&&m,this.enablePrintAutoRotate=null!==(b=null==a?void 0:a.enablePrintAutoRotate)&&void 0!==b&&b,this.useOnlyCssZoom=null!==(w=null==a?void 0:a.useOnlyCssZoom)&&void 0!==w&&w,this.pageColors=null!==(y=null==a?void 0:a.pageColors)&&void 0!==y?y:null,this.maxCanvasPixels=null!==(x=null==a?void 0:a.maxCanvasPixels)&&void 0!==x?x:Math.pow(2,24),this.maxCanvasDim=null!==(A=null==a?void 0:a.maxCanvasDim)&&void 0!==A?A:32767,this.capCanvasAreaFactor=null!==(_=null==a?void 0:a.capCanvasAreaFactor)&&void 0!==_?_:200,this.printResolution=null!==(S=null==a?void 0:a.printResolution)&&void 0!==S?S:96,this.thumbnailWidth=null!==(C=null==a?void 0:a.thumbnailWidth)&&void 0!==C?C:125,this.enableHWA=null!==(E=null==a?void 0:a.enableHWA)&&void 0!==E&&E,this.enableDetailCanvas=null===(P=null==a?void 0:a.enableDetailCanvas)||void 0===P||P,this.enableOptimizedPartialRendering=null!==(T=null==a?void 0:a.enableOptimizedPartialRendering)&&void 0!==T&&T,this.minDurationToUpdateCanvas=null!==(M=null==a?void 0:a.minDurationToUpdateCanvas)&&void 0!==M?M:500,this.getDocumentParams=null!==(k=null==a?void 0:a.getDocumentParams)&&void 0!==k?k:{},!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=r;const L=new yh;L.onIdle=this._cleanup.bind(this),L.isThumbnailViewEnabled=!0,s(this,_d,L,"f");const R=new Ha,N=new Ra({eventBus:R,externalLinkTarget:2,externalLinkRel:"noopener noreferrer nofollow",ignoreDestinationZoom:!1}),F=new Ia({eventBus:R,linkService:N}),B=Object.assign(Object.assign({container:t},e&&{viewer:e}),{eventBus:R,linkService:N,findController:F,renderingQueue:L,textLayerMode:this.textLayerMode,annotationEditorHighlightColors:this.annotationEditorHighlightColors,l10n:this.l10n,annotationMode:n(this,Td,"f"),annotationEditorMode:n(this,Md,"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}),O=this.singlePageViewer?new Gl(B):new Wl(B);L.setViewer(O),i&&(this.thumbnailViewer=new Uh({container:i,eventBus:R,linkService:N,renderingQueue:L,maxCanvasPixels:!0===this.useOnlyCssZoom?0:this.maxCanvasPixels,maxCanvasDim:this.maxCanvasDim,pageColors:this.pageColors,enableHWA:this.enableHWA,store:r,thumbnailWidth:this.thumbnailWidth,abortSignal:null===(D=n(this,Dd,"f"))||void 0===D?void 0:D.signal}),L.setThumbnailViewer(this.thumbnailViewer)),document.fullscreenEnabled&&(this.pdfPresentationMode=new ud({container:t,pdfViewer:O,eventBus:R})),this.eventBus=R,this.linkService=N,this.findController=F,this.viewer=O,this.linkService.setViewer(O),s(this,Pd,new zd({eventBus:R,slick:this,printDialog:null!=l?l:$d.create()}),"f");const j=null!==(I=null==a?void 0:a.scaleValue)&&void 0!==I?I:"auto";this.store.setState({scaleValue:j})}loadDocument(t,e){return i(this,void 0,void 0,function*(){var i,s,r,a,o;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 l=null!==(r=null==e?void 0:e.filename)&&void 0!==r?r:Ct(null===(a=this.url)||void 0===a?void 0:a.toString());this.filename=l;const h=_n(Object.assign(Object.assign({},this.getDocumentParams),{url:this.url,isEvalSupported:!1}));(null==e?void 0:e.onProgress)&&(h.onProgress=e.onProgress);const d=yield h.promise;this.document=d,this.viewer.setDocument(this.document),this.linkService.setDocument(this.document),this.thumbnailViewer&&(null===(o=this.thumbnailViewer)||void 0===o||o.setDocument(d)),n(this,Ad,"m",Nd).call(this),yield n(this,Ad,"m",Id).call(this),this.store.setState({filename:l,numPages:d.numPages,pageNumber:1,isDocumentLoaded:!0,url:t.toString()});const c=yield d.getAttachments(),u=new Map(Object.keys(null!=c?c:{}).sort((t,e)=>t.toLowerCase().localeCompare(e.toLowerCase())).map(t=>[t,c[t]]));this.store.setState({attachments:u}),yield n(this,Ad,"m",Ld).call(this),this.forceRendering()}catch(t){n(this,kd,"f")&&n(this,kd,"f").call(this,t)}})}forceRendering(t=!0){n(this,_d,"f").printing=!!n(this,Pd,"f").printing,n(this,_d,"f").isThumbnailViewEnabled=t,n(this,_d,"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 i(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 i(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 n(this,Pd,"f").supportsPrinting}requestPresentationMode(){var t;null===(t=this.pdfPresentationMode)||void 0===t||t.request()}triggerPrinting(){n(this,Pd,"f").print()}unbindEvents(){var t;null===(t=n(this,Dd,"f"))||void 0===t||t.abort(),s(this,Dd,null,"f"),n(this,Pd,"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(v.HIGHLIGHT),this.setAnnotationEditorParams([{type:w.HIGHLIGHT_COLOR,value:t}]),this.store.setState({highlightDefaultColor:t})}setSpreadMode(t){mh(t)&&(this.viewer.spreadMode=t,this.dispatch("switchspreadmode",{mode:t}))}setScrollMode(t){gh(t)&&(this.viewer.scrollMode=t,this.dispatch("switchscrollmode",{mode:t}))}setRotation(t){ph(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)}},t.PresentationModeState=Jl,t.ProgressBar=class{constructor(t){ql.set(this,void 0),Xl.set(this,null),Yl.set(this,0),Kl.set(this,void 0),Ql.set(this,!0),s(this,ql,t.classList,"f"),s(this,Kl,t.style,"f")}get percent(){return n(this,Yl,"f")}set percent(t){s(this,Yl,gt(t,0,100),"f"),isNaN(t)?n(this,ql,"f").add("indeterminate"):(n(this,ql,"f").remove("indeterminate"),n(this,Kl,"f").setProperty("--progressBar-percent",`${n(this,Yl,"f")}%`))}setWidth(t){if(!t)return;const e=t.parentNode.offsetWidth-t.offsetWidth;e>0&&n(this,Kl,"f").setProperty("--progressBar-end-offset",`${e}px`)}setDisableAutoFetch(t=5e3){100===n(this,Yl,"f")||isNaN(n(this,Yl,"f"))||(n(this,Xl,"f")&&clearTimeout(n(this,Xl,"f")),this.show(),s(this,Xl,setTimeout(()=>{s(this,Xl,null,"f"),this.hide()},t),"f"))}hide(){n(this,Ql,"f")&&(s(this,Ql,!1,"f"),n(this,ql,"f").add("hidden"))}show(){n(this,Ql,"f")||(s(this,Ql,!0,"f"),n(this,ql,"f").remove("hidden"))}},t.RendererType={CANVAS:"canvas",SVG:"svg"},t.RenderingStates=Zl,t.SCROLLBAR_PADDING=40,t.ScrollMode=ih,t.SidebarView=th,t.SpreadMode=nh,t.TextLayerMode=eh,t.UNKNOWN_SCALE=0,t.VERTICAL_PADDING=5,t.animationStarted=bh,t.apiPageLayoutToViewerModes=function(t){let e=ih.VERTICAL,i=nh.NONE;switch(t){case"SinglePage":e=ih.PAGE;break;case"OneColumn":break;case"TwoPageLeft":e=ih.PAGE;case"TwoColumnLeft":i=nh.ODD;break;case"TwoPageRight":e=ih.PAGE;case"TwoColumnRight":i=nh.EVEN}return{scrollMode:e,spreadMode:i}},t.apiPageModeToSidebarView=function(t){switch(t){case"UseNone":return th.NONE;case"UseThumbs":return th.THUMBS;case"UseOutlines":return th.OUTLINE;case"UseAttachments":return th.ATTACHMENTS;case"UseOC":return th.LAYERS}return th.NONE},t.approximateFraction=function(t){if(Math.floor(t)===t)return[t,1];const e=1/t;if(e>8)return[1,8];if(Math.floor(e)===e)return[1,e];const i=t>1?e:t;let 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=hh,t.binarySearchFirstItem=oh,t.calcRound=wh,t.create=md,t.docStyle=vh,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=lh,t.getVisibleElements=dh,t.initialState=gd,t.isPortraitOrientation=fh,t.isValidRotation=ph,t.isValidScrollMode=gh,t.isValidSpreadMode=mh,t.normalizeWheelEventDelta=uh,t.normalizeWheelEventDirection=ch,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 ah.test(t)?e?t.replaceAll(ah,t=>"\0"===t?"":" "):t.replaceAll("\0",""):t},t.scrollIntoView=sh,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.watchScroll=rh});