MindMap/frontend/dist/assets/pdf-e6f26e66.js

13 lines
408 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var FA=Object.defineProperty;var NA=(u,t,e)=>t in u?FA(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e;var k=(u,t,e)=>(NA(u,typeof t!="symbol"?t+"":t,e),e),dp=(u,t,e)=>{if(!t.has(u))throw TypeError("Cannot "+e)};var n=(u,t,e)=>(dp(u,t,"read from private field"),e?e.call(u):t.get(u)),d=(u,t,e)=>{if(t.has(u))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(u):t.set(u,e)},p=(u,t,e,s)=>(dp(u,t,"write to private field"),s?s.call(u,e):t.set(u,e),e);var St=(u,t,e,s)=>({set _(i){p(u,t,i,e)},get _(){return n(u,t,s)}}),b=(u,t,e)=>(dp(u,t,"access private method"),e);import{_ as OA}from"./index-a09f7810.js";const ie=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),wp=[.001,0,0,.001,0,0],up=1.35,Pe={ANY:1,DISPLAY:2,PRINT:4,SAVE:8,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},ki={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Em="pdfjs_internal_editor_",$={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},X={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},BA={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Ot={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_ADD_TO_PATH:4,STROKE_ADD_TO_PATH:5,FILL_STROKE_ADD_TO_PATH:6,ADD_TO_PATH:7,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},wd={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},wt={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},da={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ep={ERRORS:0,WARNINGS:1,INFOS:5},Fl={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},ud={moveTo:0,lineTo:1,curveTo:2,closePath:3},HA={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let sp=ep.WARNINGS;function $A(u){Number.isInteger(u)&&(sp=u)}function zA(){return sp}function ip(u){sp>=ep.INFOS&&console.log(`Info: ${u}`)}function z(u){sp>=ep.WARNINGS&&console.log(`Warning: ${u}`)}function st(u){throw new Error(u)}function _t(u,t){u||st(t)}function GA(u){switch(u==null?void 0:u.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function Cm(u,t=null,e=null){if(!u)return null;if(e&&typeof u=="string"){if(e.addDefaultProtocol&&u.startsWith("www.")){const i=u.match(/\./g);(i==null?void 0:i.length)>=2&&(u=`http://${u}`)}if(e.tryConvertEncoding)try{u=XA(u)}catch{}}const s=t?URL.parse(u,t):URL.parse(u);return GA(s)?s:null}function Tm(u,t,e=!1){const s=URL.parse(u);return s?(s.hash=t,s.href):e&&Cm(u,"http://example.com")?u.split("#",1)[0]+`${t?`#${t}`:""}`:""}function V(u,t,e,s=!1){return Object.defineProperty(u,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const la=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class sm extends la{constructor(t,e){super(t,"PasswordException"),this.code=e}}class fp extends la{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class vp extends la{constructor(t){super(t,"InvalidPDFException")}}class Kd extends la{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class UA extends la{constructor(t){super(t,"FormatError")}}class kn extends la{constructor(t){super(t,"AbortException")}}function xm(u){(typeof u!="object"||(u==null?void 0:u.length)===void 0)&&st("Invalid argument for bytesToString");const t=u.length,e=8192;if(t<e)return String.fromCharCode.apply(null,u);const s=[];for(let i=0;i<t;i+=e){const r=Math.min(i+e,t),a=u.subarray(i,r);s.push(String.fromCharCode.apply(null,a))}return s.join("")}function ad(u){typeof u!="string"&&st("Invalid argument for stringToBytes");const t=u.length,e=new Uint8Array(t);for(let s=0;s<t;++s)e[s]=u.charCodeAt(s)&255;return e}function jA(u){return String.fromCharCode(u>>24&255,u>>16&255,u>>8&255,u&255)}function VA(){const u=new Uint8Array(4);return u[0]=1,new Uint32Array(u.buffer,0,1)[0]===1}function WA(){try{return new Function(""),!0}catch{return!1}}class Wt{static get isLittleEndian(){return V(this,"isLittleEndian",VA())}static get isEvalSupported(){return V(this,"isEvalSupported",WA())}static get isOffscreenCanvasSupported(){return V(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return V(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return V(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(){var t,e;return V(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const pp=Array.from(Array(256).keys(),u=>u.toString(16).padStart(2,"0"));var Sa,vd,Hl,_p;class I{static makeHexColor(t,e,s){return`#${pp[t]}${pp[e]}${pp[s]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let s;t[0]?(t[0]<0&&(s=e[0],e[0]=e[2],e[2]=s),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[3],e[3]*=t[3]):(s=e[0],e[0]=e[1],e[1]=s,s=e[2],e[2]=e[3],e[3]=s,t[1]<0&&(s=e[1],e[1]=e[3],e[3]=s),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(s=e[0],e[0]=e[2],e[2]=s),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,s=0){const i=t[s],r=t[s+1];t[s]=i*e[0]+r*e[2]+e[4],t[s+1]=i*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5];for(let c=0;c<6;c+=2){const f=t[s+c],g=t[s+c+1];t[s+c]=f*i+g*a+l,t[s+c+1]=f*r+g*o+h}}static applyInverseTransform(t,e){const s=t[0],i=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,s){const i=e[0],r=e[1],a=e[2],o=e[3],l=e[4],h=e[5],c=t[0],f=t[1],g=t[2],m=t[3];let A=i*c+l,y=A,v=i*g+l,w=v,S=o*f+h,_=S,E=o*m+h,C=E;if(r!==0||a!==0){const T=r*c,x=r*g,P=a*f,M=a*m;A+=P,w+=P,v+=M,y+=M,S+=T,C+=T,E+=x,_+=x}s[0]=Math.min(s[0],A,v,y,w),s[1]=Math.min(s[1],S,E,_,C),s[2]=Math.max(s[2],A,v,y,w),s[3]=Math.max(s[3],S,E,_,C)}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 s=t[0],i=t[1],r=t[2],a=t[3],o=s**2+i**2,l=s*r+i*a,h=r**2+a**2,c=(o+h)/2,f=Math.sqrt(c**2-(o*h-l**2));e[0]=Math.sqrt(c+f||1),e[1]=Math.sqrt(c-f||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 s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>a?null:[s,r,i,a]}static pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,r){r[0]=Math.min(r[0],t,s),r[1]=Math.min(r[1],e,i),r[2]=Math.max(r[2],t,s),r[3]=Math.max(r[3],e,i)}static bezierBoundingBox(t,e,s,i,r,a,o,l,h){h[0]=Math.min(h[0],t,o),h[1]=Math.min(h[1],e,l),h[2]=Math.max(h[2],t,o),h[3]=Math.max(h[3],e,l),b(this,Hl,_p).call(this,t,s,r,o,e,i,a,l,3*(-t+3*(s-r)+o),6*(t-2*s+r),3*(s-t),h),b(this,Hl,_p).call(this,t,s,r,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h)}}Sa=new WeakSet,vd=function(t,e,s,i,r,a,o,l,h,c){if(h<=0||h>=1)return;const f=1-h,g=h*h,m=g*h,A=f*(f*(f*t+3*h*e)+3*g*s)+m*i,y=f*(f*(f*r+3*h*a)+3*g*o)+m*l;c[0]=Math.min(c[0],A),c[1]=Math.min(c[1],y),c[2]=Math.max(c[2],A),c[3]=Math.max(c[3],y)},Hl=new WeakSet,_p=function(t,e,s,i,r,a,o,l,h,c,f,g){if(Math.abs(h)<1e-12){Math.abs(c)>=1e-12&&b(this,Sa,vd).call(this,t,e,s,i,r,a,o,l,-f/c,g);return}const m=c**2-4*f*h;if(m<0)return;const A=Math.sqrt(m),y=2*h;b(this,Sa,vd).call(this,t,e,s,i,r,a,o,l,(-c+A)/y,g),b(this,Sa,vd).call(this,t,e,s,i,r,a,o,l,(-c-A)/y,g)},d(I,Sa),d(I,Hl);function XA(u){return decodeURIComponent(escape(u))}let gp=null,im=null;function qA(u){return gp||(gp=/([\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,im=new Map([["ſt","ſt"]])),u.replaceAll(gp,(t,e,s)=>e?e.normalize("NFKC"):im.get(s))}function km(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const u=new Uint8Array(32);return crypto.getRandomValues(u),xm(u)}const Hg="pdfjs_internal_id_";function YA(u,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[s,i,...r]=e;if(!u(s)&&!Number.isInteger(s)||!t(i))return!1;const a=r.length;let o=!0;switch(i.name){case"XYZ":if(a<2||a>3)return!1;break;case"Fit":case"FitB":return a===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(a>1)return!1;break;case"FitR":if(a!==4)return!1;o=!1;break;default:return!1}for(const l of r)if(!(typeof l=="number"||o&&l===null))return!1;return!0}function ne(u,t,e){return Math.min(Math.max(u,t),e)}function Pm(u){return Uint8Array.prototype.toBase64?u.toBase64():btoa(xm(u))}function KA(u){return Uint8Array.fromBase64?Uint8Array.fromBase64(u):ad(atob(u))}typeof Promise.try!="function"&&(Promise.try=function(u,...t){return new Promise(e=>{e(u(...t))})});typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(u){return u.reduce((t,e)=>t+e,0)});const Is="http://www.w3.org/2000/svg",Fn=class Fn{};k(Fn,"CSS",96),k(Fn,"PDF",72),k(Fn,"PDF_TO_CSS_UNITS",Fn.CSS/Fn.PDF);let Pn=Fn;async function od(u,t="text"){if(gl(u,document.baseURI)){const e=await fetch(u);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,s)=>{const i=new XMLHttpRequest;i.open("GET",u,!0),i.responseType=t,i.onreadystatechange=()=>{if(i.readyState===XMLHttpRequest.DONE){if(i.status===200||i.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(i.response);return}e(i.responseText);return}s(new Error(i.statusText))}},i.send(null)})}class ld{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:r=0,offsetY:a=0,dontFlip:o=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=r,this.offsetY=a,s*=e;const l=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let c,f,g,m;switch(i%=360,i<0&&(i+=360),i){case 180:c=-1,f=0,g=0,m=1;break;case 90:c=0,f=1,g=1,m=0;break;case 270:c=0,f=-1,g=-1,m=0;break;case 0:c=1,f=0,g=0,m=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(g=-g,m=-m);let A,y,v,w;c===0?(A=Math.abs(h-t[1])*s+r,y=Math.abs(l-t[0])*s+a,v=(t[3]-t[1])*s,w=(t[2]-t[0])*s):(A=Math.abs(l-t[0])*s+r,y=Math.abs(h-t[1])*s+a,v=(t[2]-t[0])*s,w=(t[3]-t[1])*s),this.transform=[c*s,f*s,g*s,m*s,A-c*s*l-g*s*h,y-f*s*l-m*s*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return V(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:s=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new ld({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}convertToViewportPoint(t,e){const s=[t,e];return I.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];I.applyTransform(e,this.transform);const s=[t[2],t[3]];return I.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return I.applyInverseTransform(s,this.transform),s}}class $g extends la{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function np(u){const t=u.length;let e=0;for(;e<t&&u[e].trim()==="";)e++;return u.substring(e,e+5).toLowerCase()==="data:"}function zg(u){return typeof u=="string"&&/\.pdf$/i.test(u)}function QA(u){return[u]=u.split(/[#?]/,1),u.substring(u.lastIndexOf("/")+1)}function JA(u,t="document.pdf"){if(typeof u!="string")return t;if(np(u))return z('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const s=(o=>{try{return new URL(o)}catch{try{return new URL(decodeURIComponent(o))}catch{try{return new URL(o,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(o),"https://foo.bar")}catch{return null}}}}})(u);if(!s)return t;const i=o=>{try{let l=decodeURIComponent(o);return l.includes("/")?(l=l.split("/").at(-1),l.test(/^\.pdf$/i)?l:o):l}catch{return o}},r=/\.pdf$/i,a=s.pathname.split("/").at(-1);if(r.test(a))return i(a);if(s.searchParams.size>0){const o=Array.from(s.searchParams.values()).reverse();for(const h of o)if(r.test(h))return i(h);const l=Array.from(s.searchParams.keys()).reverse();for(const h of l)if(r.test(h))return i(h)}if(s.hash){const l=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(l)return i(l[0])}return t}class nm{constructor(){k(this,"started",Object.create(null));k(this,"times",[])}time(t){t in this.started&&z(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||z(`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:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:r}of this.times)t.push(`${s.padEnd(e)} ${r-i}ms
`);return t.join("")}}function gl(u,t){const e=t?URL.parse(u,t):URL.parse(u);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function je(u){u.preventDefault()}function vt(u){u.preventDefault(),u.stopPropagation()}function ZA(u){console.log("Deprecated API usage: "+u)}var $l;class Qd{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;n(this,$l)||p(this,$l,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=n(this,$l).exec(t);if(!e)return null;const s=parseInt(e[1],10);let i=parseInt(e[2],10);i=i>=1&&i<=12?i-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let f=parseInt(e[9],10)||0;return f=f>=0&&f<=59?f:0,h==="-"?(a+=c,o+=f):h==="+"&&(a-=c,o-=f),new Date(Date.UTC(s,i,r,a,o,l))}}$l=new WeakMap,d(Qd,$l,void 0);function ty(u,{scale:t=1,rotation:e=0}){const{width:s,height:i}=u.attributes.style,r=[0,0,parseInt(s),parseInt(i)];return new ld({viewBox:r,userUnit:1,scale:t,rotation:e})}function rp(u){if(u.startsWith("#")){const t=parseInt(u.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return u.startsWith("rgb(")?u.slice(4,-1).split(",").map(t=>parseInt(t)):u.startsWith("rgba(")?u.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(z(`Not a valid color format: "${u}"`),[0,0,0])}function ey(u){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of u.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;u.set(e,rp(s))}t.remove()}function dt(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform();return[t,e,s,i,r,a]}function os(u){const{a:t,b:e,c:s,d:i,e:r,f:a}=u.getTransform().invertSelf();return[t,e,s,i,r,a]}function ra(u,t,e=!1,s=!0){if(t instanceof ld){const{pageWidth:i,pageHeight:r}=t.rawDims,{style:a}=u,o=Wt.isCSSRoundSupported,l=`var(--total-scale-factor) * ${i}px`,h=`var(--total-scale-factor) * ${r}px`,c=o?`round(down, ${l}, var(--scale-round-x))`:`calc(${l})`,f=o?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=c,a.height=f):(a.width=f,a.height=c)}s&&u.setAttribute("data-main-rotation",t.rotation)}class Ds{constructor(){const{pixelRatio:t}=Ds;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,r=-1){let a=1/0,o=1/0,l=1/0;s=Ds.capPixels(s,r),s>0&&(a=Math.sqrt(s/(t*e))),i!==-1&&(o=i/t,l=i/e);const h=Math.min(a,o,l);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const Sp=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];var Pi,Mi,Ie,Hs,zl,Ea,Ca,Gl,ou,Mm,lu,Rm,hu,Dm,Ri,ua,Bn,ml;const Os=class Os{constructor(t){d(this,lu);d(this,hu);d(this,Ri);d(this,Bn);d(this,Pi,null);d(this,Mi,null);d(this,Ie,void 0);d(this,Hs,null);d(this,zl,null);d(this,Ea,null);d(this,Ca,null);p(this,Ie,t),n(Os,Gl)||p(Os,Gl,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=p(this,Pi,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=n(this,Ie)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",je,{signal:e}),t.addEventListener("pointerdown",b(Os,ou,Mm),{signal:e}));const s=p(this,Hs,document.createElement("div"));s.className="buttons",t.append(s);const i=n(this,Ie).toolbarPosition;if(i){const{style:r}=t,a=n(this,Ie)._uiManager.direction==="ltr"?1-i[0]:i[0];r.insetInlineEnd=`${100*a}%`,r.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return n(this,Pi)}hide(){var t;n(this,Pi).classList.add("hidden"),(t=n(this,Mi))==null||t.hideDropdown()}show(){var t,e;n(this,Pi).classList.remove("hidden"),(t=n(this,zl))==null||t.shown(),(e=n(this,Ea))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=n(this,Ie),s=document.createElement("button");s.classList.add("basic","deleteButton"),s.tabIndex=0,s.setAttribute("data-l10n-id",n(Os,Gl)[t]),b(this,Ri,ua).call(this,s)&&s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),n(this,Hs).append(s)}async addAltText(t){const e=await t.render();b(this,Ri,ua).call(this,e),n(this,Hs).append(e,n(this,Bn,ml)),p(this,zl,t)}addComment(t){if(n(this,Ea))return;const e=t.render();e&&(b(this,Ri,ua).call(this,e),n(this,Hs).append(e,n(this,Bn,ml)),p(this,Ea,t),t.toolbar=this)}addColorPicker(t){if(n(this,Mi))return;p(this,Mi,t);const e=t.renderButton();b(this,Ri,ua).call(this,e),n(this,Hs).append(e,n(this,Bn,ml))}async addEditSignatureButton(t){const e=p(this,Ca,await t.renderEditButton(n(this,Ie)));b(this,Ri,ua).call(this,e),n(this,Hs).append(e,n(this,Bn,ml))}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e);break}}updateEditSignatureButton(t){n(this,Ca)&&(n(this,Ca).title=t)}remove(){var t;n(this,Pi).remove(),(t=n(this,Mi))==null||t.destroy(),p(this,Mi,null)}};Pi=new WeakMap,Mi=new WeakMap,Ie=new WeakMap,Hs=new WeakMap,zl=new WeakMap,Ea=new WeakMap,Ca=new WeakMap,Gl=new WeakMap,ou=new WeakSet,Mm=function(t){t.stopPropagation()},lu=new WeakSet,Rm=function(t){n(this,Ie)._focusEventsAllowed=!1,vt(t)},hu=new WeakSet,Dm=function(t){n(this,Ie)._focusEventsAllowed=!0,vt(t)},Ri=new WeakSet,ua=function(t){const e=n(this,Ie)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",b(this,lu,Rm).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",b(this,hu,Dm).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",je,{signal:e}),!0)},Bn=new WeakSet,ml=function(){const t=document.createElement("div");return t.className="divider",t},d(Os,ou),d(Os,Gl,null);let Ep=Os;var Ul,Hn,$s,cu,Lm,du,Im,jl,Cp;class sy{constructor(t){d(this,cu);d(this,du);d(this,jl);d(this,Ul,null);d(this,Hn,null);d(this,$s,void 0);p(this,$s,t)}show(t,e,s){const[i,r]=b(this,du,Im).call(this,e,s),{style:a}=n(this,Hn)||p(this,Hn,b(this,cu,Lm).call(this));t.append(n(this,Hn)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){n(this,Hn).remove()}}Ul=new WeakMap,Hn=new WeakMap,$s=new WeakMap,cu=new WeakSet,Lm=function(){const t=p(this,Hn,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=n(this,$s)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",je,{signal:e});const s=p(this,Ul,document.createElement("div"));return s.className="buttons",t.append(s),n(this,$s).hasCommentManager()&&b(this,jl,Cp).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{n(this,$s).commentSelection("floating_button")}),b(this,jl,Cp).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{n(this,$s).highlightSelection("floating_button")}),t},du=new WeakSet,Im=function(t,e){let s=0,i=0;for(const r of t){const a=r.y+r.height;if(a<s)continue;const o=r.x+(e?r.width:0);if(a>s){i=o,s=a;continue}e?o>i&&(i=o):o<i&&(i=o)}return[e?1-i:i,s]},jl=new WeakSet,Cp=function(t,e,s,i){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const a=document.createElement("span");r.append(a),a.className="visuallyHidden",a.setAttribute("data-l10n-id",s);const o=n(this,$s)._signal;o instanceof AbortSignal&&!o.aborted&&(r.addEventListener("contextmenu",je,{signal:o}),r.addEventListener("click",i,{signal:o})),n(this,Ul).append(r)};function Fm(u,t,e){for(const s of e)t.addEventListener(s,u[s].bind(u))}var uu;class iy{constructor(){d(this,uu,0)}get id(){return`${Em}${St(this,uu)._++}`}}uu=new WeakMap;var Ta,Vl,qt,xa,_d;const Yg=class Yg{constructor(){d(this,xa);d(this,Ta,km());d(this,Vl,0);d(this,qt,null)}static get _isSVGFittingCanvas(){const t='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>',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const r=i.decode().then(()=>(s.drawImage(i,0,0,1,1,0,0,1,3),new Uint32Array(s.getImageData(0,0,1,1).data.buffer)[0]===0));return V(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:r}=t;return b(this,xa,_d).call(this,`${e}_${s}_${i}_${r}`,t)}async getFromUrl(t){return b(this,xa,_d).call(this,t,t)}async getFromBlob(t,e){const s=await e;return b(this,xa,_d).call(this,t,s)}async getFromId(t){n(this,qt)||p(this,qt,new Map);const e=n(this,qt).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:s}=e;return delete e.blobPromise,this.getFromBlob(e.id,s)}return this.getFromUrl(e.url)}getFromCanvas(t,e){n(this,qt)||p(this,qt,new Map);let s=n(this,qt).get(t);if(s!=null&&s.bitmap)return s.refCounter+=1,s;const i=new OffscreenCanvas(e.width,e.height);return i.getContext("2d").drawImage(e,0,0),s={bitmap:i.transferToImageBitmap(),id:`image_${n(this,Ta)}_${St(this,Vl)._++}`,refCounter:1,isSvg:!1},n(this,qt).set(t,s),n(this,qt).set(s.id,s),s}getSvgUrl(t){const e=n(this,qt).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;n(this,qt)||p(this,qt,new Map);const e=n(this,qt).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(s.width,s.height);r.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=r.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${n(this,Ta)}_`)}};Ta=new WeakMap,Vl=new WeakMap,qt=new WeakMap,xa=new WeakSet,_d=async function(t,e){n(this,qt)||p(this,qt,new Map);let s=n(this,qt).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${n(this,Ta)}_${St(this,Vl)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await od(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const r=Yg._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,c)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const f=s.svgUrl=a.result;o.src=await r?`${f}#svgView(preserveAspectRatio(none))`:f},o.onerror=a.onerror=c});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){z(i),s=null}return n(this,qt).set(t,s),s&&n(this,qt).set(s.id,s),s};let Tp=Yg;var gt,Di,Wl,ht;class ny{constructor(t=128){d(this,gt,[]);d(this,Di,!1);d(this,Wl,void 0);d(this,ht,-1);p(this,Wl,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:r=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),n(this,Di))return;const l={cmd:t,undo:e,post:s,type:r};if(n(this,ht)===-1){n(this,gt).length>0&&(n(this,gt).length=0),p(this,ht,0),n(this,gt).push(l);return}if(a&&n(this,gt)[n(this,ht)].type===r){o&&(l.undo=n(this,gt)[n(this,ht)].undo),n(this,gt)[n(this,ht)]=l;return}const h=n(this,ht)+1;h===n(this,Wl)?n(this,gt).splice(0,1):(p(this,ht,h),h<n(this,gt).length&&n(this,gt).splice(h)),n(this,gt).push(l)}undo(){if(n(this,ht)===-1)return;p(this,Di,!0);const{undo:t,post:e}=n(this,gt)[n(this,ht)];t(),e==null||e(),p(this,Di,!1),p(this,ht,n(this,ht)-1)}redo(){if(n(this,ht)<n(this,gt).length-1){p(this,ht,n(this,ht)+1),p(this,Di,!0);const{cmd:t,post:e}=n(this,gt)[n(this,ht)];t(),e==null||e(),p(this,Di,!1)}}hasSomethingToUndo(){return n(this,ht)!==-1}hasSomethingToRedo(){return n(this,ht)<n(this,gt).length-1}cleanType(t){if(n(this,ht)!==-1){for(let e=n(this,ht);e>=0;e--)if(n(this,gt)[e].type!==t){n(this,gt).splice(e+1,n(this,ht)-e),p(this,ht,e);return}n(this,gt).length=0,p(this,ht,-1)}}destroy(){p(this,gt,null)}}gt=new WeakMap,Di=new WeakMap,Wl=new WeakMap,ht=new WeakMap;var fu,Nm;class hd{constructor(t){d(this,fu);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Wt.platform;for(const[s,i,r={}]of t)for(const a of s){const o=a.startsWith("mac+");e&&o?(this.callbacks.set(a.slice(4),{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1))):!e&&!o&&(this.callbacks.set(a,{callback:i,options:r}),this.allKeys.add(a.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(b(this,fu,Nm).call(this,e));if(!s)return;const{callback:i,options:{bubbles:r=!1,args:a=[],checker:o=null}}=s;o&&!o(t,e)||(i.bind(t,...a,e)(),r||vt(e))}}fu=new WeakSet,Nm=function(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};const pu=class pu{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return ey(t),V(this,"_colors",t)}convert(t){const e=rp(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[s,i]of this._colors)if(i.every((r,a)=>r===e[a]))return pu._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?I.makeHexColor(...e):t}};k(pu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let xp=pu;var ka,ue,Pa,Ct,Bt,Ma,zs,Ra,Fe,Gs,Li,Ii,Da,$n,cs,Ne,zn,Xl,ql,La,Yl,ds,Fi,Ia,Ni,us,gu,Oi,Fa,Kl,Bi,Gn,Na,Hi,Ql,Tt,Q,Us,$i,zi,Jl,Oa,Zl,Gi,fs,js,th,eh,Oe,Ba,Sd,sh,kp,mu,Om,bu,Bm,Un,bl,Au,Hm,yu,$m,wu,zm,ih,Pp,vu,Gm,nh,Mp,rh,Rp,_u,Um,Ht,Qt,qe,Fs,Su,jm,Eu,Vm,ah,Dp,Cu,Wm,jn,Al,oh,Lp;const wa=class wa{constructor(t,e,s,i,r,a,o,l,h,c,f,g,m,A,y,v){d(this,Ba);d(this,sh);d(this,mu);d(this,bu);d(this,Un);d(this,Au);d(this,yu);d(this,wu);d(this,ih);d(this,vu);d(this,nh);d(this,rh);d(this,_u);d(this,Ht);d(this,qe);d(this,Su);d(this,Eu);d(this,ah);d(this,Cu);d(this,jn);d(this,oh);d(this,ka,new AbortController);d(this,ue,null);d(this,Pa,null);d(this,Ct,new Map);d(this,Bt,new Map);d(this,Ma,null);d(this,zs,null);d(this,Ra,null);d(this,Fe,new ny);d(this,Gs,null);d(this,Li,null);d(this,Ii,null);d(this,Da,0);d(this,$n,new Set);d(this,cs,null);d(this,Ne,null);d(this,zn,new Set);k(this,"_editorUndoBar",null);d(this,Xl,!1);d(this,ql,!1);d(this,La,!1);d(this,Yl,null);d(this,ds,null);d(this,Fi,null);d(this,Ia,null);d(this,Ni,!1);d(this,us,null);d(this,gu,new iy);d(this,Oi,!1);d(this,Fa,!1);d(this,Kl,!1);d(this,Bi,null);d(this,Gn,null);d(this,Na,null);d(this,Hi,null);d(this,Ql,null);d(this,Tt,$.NONE);d(this,Q,new Set);d(this,Us,null);d(this,$i,null);d(this,zi,null);d(this,Jl,null);d(this,Oa,null);d(this,Zl,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});d(this,Gi,[0,0]);d(this,fs,null);d(this,js,null);d(this,th,null);d(this,eh,null);d(this,Oe,null);const w=this._signal=n(this,ka).signal;p(this,js,t),p(this,th,e),p(this,eh,s),p(this,Ma,i),p(this,Gs,r),p(this,$i,a),p(this,Oa,l),this._eventBus=o,o._on("editingaction",this.onEditingAction.bind(this),{signal:w}),o._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),o._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),o._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),o._on("setpreference",this.onSetPreference.bind(this),{signal:w}),o._on("switchannotationeditorparams",S=>this.updateParams(S.type,S.value),{signal:w}),window.addEventListener("pointerdown",()=>{p(this,Fa,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{p(this,Fa,!1)},{capture:!0,signal:w}),b(this,Au,Hm).call(this),b(this,_u,Um).call(this),b(this,ih,Pp).call(this),p(this,zs,l.annotationStorage),p(this,Yl,l.filterFactory),p(this,zi,h),p(this,Ia,c||null),p(this,Xl,f),p(this,ql,g),p(this,La,m),p(this,Ql,A||null),this.viewParameters={realScale:Pn.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=y||null,this._supportsPinchToZoom=v!==!1}static get _keyboardManager(){const t=wa.prototype,e=a=>n(a,js).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&a.hasSomethingToControl(),s=(a,{target:o})=>{if(o instanceof HTMLInputElement){const{type:l}=o;return l!=="text"&&l!=="number"}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return V(this,"_keyboardManager",new hd([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:s}],[["ctrl+z","mac+meta+z"],t.undo,{checker:s}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.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"],t.delete,{checker:s}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,js).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&n(a,js).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-i,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,s,i,r,a,o,l,h;(t=n(this,Oe))==null||t.resolve(),p(this,Oe,null),(e=n(this,ka))==null||e.abort(),p(this,ka,null),this._signal=null;for(const c of n(this,Bt).values())c.destroy();n(this,Bt).clear(),n(this,Ct).clear(),n(this,zn).clear(),(s=n(this,Hi))==null||s.clear(),p(this,ue,null),n(this,Q).clear(),n(this,Fe).destroy(),(i=n(this,Ma))==null||i.destroy(),(r=n(this,Gs))==null||r.destroy(),(a=n(this,$i))==null||a.destroy(),(o=n(this,us))==null||o.hide(),p(this,us,null),(l=n(this,Na))==null||l.destroy(),p(this,Na,null),p(this,Pa,null),n(this,ds)&&(clearTimeout(n(this,ds)),p(this,ds,null)),n(this,fs)&&(clearTimeout(n(this,fs)),p(this,fs,null)),(h=this._editorUndoBar)==null||h.destroy(),p(this,Oa,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return n(this,Ql)}get useNewAltTextFlow(){return n(this,ql)}get useNewAltTextWhenAddingImage(){return n(this,La)}get hcmFilter(){return V(this,"hcmFilter",n(this,zi)?n(this,Yl).addHCMFilter(n(this,zi).foreground,n(this,zi).background):"none")}get direction(){return V(this,"direction",getComputedStyle(n(this,js)).direction)}get _highlightColors(){return V(this,"_highlightColors",n(this,Ia)?new Map(n(this,Ia).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return V(this,"highlightColors",null);const e=new Map,s=!!n(this,zi);for(const[i,r]of t){const a=i.endsWith("_HCM");if(s&&a){e.set(i.replace("_HCM",""),r);continue}!s&&!a&&e.set(i,r)}return V(this,"highlightColors",e)}get highlightColorNames(){return V(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),p(this,Ii,t)}setMainHighlightColorPicker(t){p(this,Na,t)}editAltText(t,e=!1){var s;(s=n(this,Ma))==null||s.editAltText(this,t,e)}hasCommentManager(){return!!n(this,Gs)}editComment(t,e){var s;(s=n(this,Gs))==null||s.open(this,t,e)}getSignature(t){var e;(e=n(this,$i))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return n(this,$i)}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}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,La,e);break}}onPageChanging({pageNumber:t}){p(this,Da,t-1)}focusMainContainer(){n(this,js).focus()}findParent(t,e){for(const s of n(this,Bt).values()){const{x:i,y:r,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=r&&e<=r+o)return s}return null}disableUserSelect(t=!1){n(this,th).classList.toggle("noUserSelect",t)}addShouldRescale(t){n(this,zn).add(t)}removeShouldRescale(t){n(this,zn).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Pn.PDF_TO_CSS_UNITS;for(const s of n(this,zn))s.onScaleChanging();(e=n(this,Ii))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const s=document.getSelection();if(!s||s.isCollapsed)return;const{anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o}=s,l=s.toString(),c=b(this,Ba,Sd).call(this,s).closest(".textLayer"),f=this.getSelectionBoxes(c);if(!f)return;s.empty();const g=b(this,sh,kp).call(this,c),m=n(this,Tt)===$.NONE,A=()=>{const y=g==null?void 0:g.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:f,anchorNode:i,anchorOffset:r,focusNode:a,focusOffset:o,text:l});m&&this.showAllEditors("highlight",!0,!0),e&&(y==null||y.editComment())};if(m){this.switchToMode($.HIGHLIGHT,A);return}A()}commentSelection(t=""){this.highlightSelection(t,!0)}addToAnnotationStorage(t){!t.isEmpty()&&n(this,zs)&&!n(this,zs).has(t.id)&&n(this,zs).setValue(t.id,t)}a11yAlert(t,e=null){const s=n(this,eh);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,n(this,Ni)&&(p(this,Ni,!1),b(this,Un,bl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of n(this,Q))if(e.div.contains(t)){p(this,Gn,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!n(this,Gn))return;const[t,e]=n(this,Gn);p(this,Gn,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){b(this,ih,Pp).call(this),b(this,nh,Mp).call(this)}removeEditListeners(){b(this,vu,Gm).call(this),b(this,rh,Rp).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of n(this,Ne))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of n(this,Ne))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=n(this,ue))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of n(this,Q)){const r=i.serialize(!0);r&&e.push(r)}e.length!==0&&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 r of e.items)for(const a of n(this,Ne))if(a.isHandlingMimeForPasting(r.type)){a.paste(r,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(r){z(`paste: "${r.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const r=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;r.push(h)}const a=()=>{for(const l of r)b(this,ah,Dp).call(this,l);b(this,oh,Lp).call(this,r)},o=()=>{for(const l of r)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(r){z(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),n(this,Tt)!==$.NONE&&!this.isEditorHandlingKeyboard&&wa._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,n(this,Ni)&&(p(this,Ni,!1),b(this,Un,bl).call(this,"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");break}}setEditingState(t){t?(b(this,yu,$m).call(this),b(this,nh,Mp).call(this),b(this,Ht,Qt).call(this,{isEditing:n(this,Tt)!==$.NONE,isEmpty:b(this,jn,Al).call(this),hasSomethingToUndo:n(this,Fe).hasSomethingToUndo(),hasSomethingToRedo:n(this,Fe).hasSomethingToRedo(),hasSelectedEditor:!1})):(b(this,wu,zm).call(this),b(this,rh,Rp).call(this),b(this,Ht,Qt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!n(this,Ne)){p(this,Ne,t);for(const e of n(this,Ne))b(this,qe,Fs).call(this,e.defaultPropertiesToUpdate)}}getId(){return n(this,gu).id}get currentLayer(){return n(this,Bt).get(n(this,Da))}getLayer(t){return n(this,Bt).get(t)}get currentPageIndex(){return n(this,Da)}addLayer(t){n(this,Bt).set(t.pageIndex,t),n(this,Oi)?t.enable():t.disable()}removeLayer(t){n(this,Bt).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,r=!1){var a,o,l,h,c;if(n(this,Tt)!==t&&!(n(this,Oe)&&(await n(this,Oe).promise,!n(this,Oe)))){if(p(this,Oe,Promise.withResolvers()),(a=n(this,Ii))==null||a.commitOrRemove(),n(this,Tt)===$.POPUP&&((o=n(this,Gs))==null||o.hideSidebar()),p(this,Tt,t),t===$.NONE){this.setEditingState(!1),b(this,Eu,Vm).call(this),(l=this._editorUndoBar)==null||l.hide(),n(this,Oe).resolve();return}t===$.SIGNATURE&&await((h=n(this,$i))==null?void 0:h.loadSignatures()),t===$.POPUP&&(n(this,Pa)||p(this,Pa,await n(this,Oa).getAnnotationsByType(new Set(n(this,Ne).map(f=>f._editorType)))),(c=n(this,Gs))==null||c.showSidebar(n(this,Pa))),this.setEditingState(!0),await b(this,Su,jm).call(this),this.unselectAll();for(const f of n(this,Bt).values())f.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),n(this,Oe).resolve();return}for(const f of n(this,Ct).values())f.annotationElementId===e||f.id===e?(this.setSelected(f),r?f.editComment():i&&f.enterInEditMode()):f.unselect();n(this,Oe).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==n(this,Tt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(n(this,Ne)){switch(t){case X.CREATE:this.currentLayer.addNewEditor(e);return;case X.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(n(this,Jl)||p(this,Jl,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const s of n(this,Q))s.updateParams(t,e);else for(const s of n(this,Ne))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var r;for(const a of n(this,Ct).values())a.editorType===t&&a.show(e);(((r=n(this,Jl))==null?void 0:r.get(X.HIGHLIGHT_SHOW_ALL))??!0)!==e&&b(this,qe,Fs).call(this,[[X.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(n(this,Kl)!==t){p(this,Kl,t);for(const e of n(this,Bt).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of n(this,Ct).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return n(this,Ct).get(t)}addEditor(t){n(this,Ct).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(n(this,ds)&&clearTimeout(n(this,ds)),p(this,ds,setTimeout(()=>{this.focusMainContainer(),p(this,ds,null)},0))),n(this,Ct).delete(t.id),t.annotationElementId&&((e=n(this,Hi))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!n(this,$n).has(t.annotationElementId))&&((s=n(this,zs))==null||s.remove(t.id))}addDeletedAnnotationElement(t){n(this,$n).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return n(this,$n).has(t)}removeDeletedAnnotationElement(t){n(this,$n).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){n(this,ue)!==t&&(p(this,ue,t),t&&b(this,qe,Fs).call(this,t.propertiesToUpdate))}updateUI(t){n(this,Cu,Wm)===t&&b(this,qe,Fs).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){b(this,qe,Fs).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(n(this,Q).has(t)){n(this,Q).delete(t),t.unselect(),b(this,Ht,Qt).call(this,{hasSelectedEditor:this.hasSelection});return}n(this,Q).add(t),t.select(),b(this,qe,Fs).call(this,t.propertiesToUpdate),b(this,Ht,Qt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),(e=n(this,Ii))==null||e.commitOrRemove();for(const s of n(this,Q))s!==t&&s.unselect();n(this,Q).clear(),n(this,Q).add(t),t.select(),b(this,qe,Fs).call(this,t.propertiesToUpdate),b(this,Ht,Qt).call(this,{hasSelectedEditor:!0})}isSelected(t){return n(this,Q).has(t)}get firstSelectedEditor(){return n(this,Q).values().next().value}unselect(t){t.unselect(),n(this,Q).delete(t),b(this,Ht,Qt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return n(this,Q).size!==0}get isEnterHandled(){return n(this,Q).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;n(this,Fe).undo(),b(this,Ht,Qt).call(this,{hasSomethingToUndo:n(this,Fe).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:b(this,jn,Al).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){n(this,Fe).redo(),b(this,Ht,Qt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:n(this,Fe).hasSomethingToRedo(),isEmpty:b(this,jn,Al).call(this)})}addCommands(t){n(this,Fe).add(t),b(this,Ht,Qt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:b(this,jn,Al).call(this)})}cleanUndoStack(t){n(this,Fe).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...n(this,Q)],s=()=>{var a;(a=this._editorUndoBar)==null||a.show(i,e.length===1?e[0].editorType:e.length);for(const o of e)o.remove()},i=()=>{for(const a of e)b(this,ah,Dp).call(this,a)};this.addCommands({cmd:s,undo:i,mustExec:!0})}commitOrRemove(){var t;(t=n(this,ue))==null||t.commitOrRemove()}hasSomethingToControl(){return n(this,ue)||this.hasSelection}selectAll(){for(const t of n(this,Q))t.commit();b(this,oh,Lp).call(this,n(this,Ct).values())}unselectAll(){var t;if(!(n(this,ue)&&(n(this,ue).commitOrRemove(),n(this,Tt)!==$.NONE))&&!((t=n(this,Ii))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of n(this,Q))e.unselect();n(this,Q).clear(),b(this,Ht,Qt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;n(this,Gi)[0]+=t,n(this,Gi)[1]+=e;const[i,r]=n(this,Gi),a=[...n(this,Q)],o=1e3;n(this,fs)&&clearTimeout(n(this,fs)),p(this,fs,setTimeout(()=>{p(this,fs,null),n(this,Gi)[0]=n(this,Gi)[1]=0,this.addCommands({cmd:()=>{for(const l of a)n(this,Ct).has(l.id)&&(l.translateInPage(i,r),l.translationDone())},undo:()=>{for(const l of a)n(this,Ct).has(l.id)&&(l.translateInPage(-i,-r),l.translationDone())},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e),l.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,cs,new Map);for(const t of n(this,Q))n(this,cs).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!n(this,cs))return!1;this.disableUserSelect(!1);const t=n(this,cs);p(this,cs,null);let e=!1;for(const[{x:i,y:r,pageIndex:a},o]of t)o.newX=i,o.newY=r,o.newPageIndex=a,e||(e=i!==o.savedX||r!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,r,a,o)=>{if(n(this,Ct).has(i.id)){const l=n(this,Bt).get(o);l?i._setParentAndPosition(l,r,a):(i.pageIndex=o,i.x=r,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:r,newY:a,newPageIndex:o}]of t)s(i,r,a,o)},undo:()=>{for(const[i,{savedX:r,savedY:a,savedPageIndex:o}]of t)s(i,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(n(this,cs))for(const s of n(this,cs).keys())s.drag(t,e)}rebuild(t){if(t.parent===null){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(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||n(this,Q).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return n(this,ue)===t}getActive(){return n(this,ue)}getMode(){return n(this,Tt)}get imageManager(){return V(this,"imageManager",new Tp)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,c=e.rangeCount;h<c;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:s,y:i,width:r,height:a}=t.getBoundingClientRect();let o;switch(t.getAttribute("data-main-rotation")){case"90":o=(h,c,f,g)=>({x:(c-i)/a,y:1-(h+f-s)/r,width:g/a,height:f/r});break;case"180":o=(h,c,f,g)=>({x:1-(h+f-s)/r,y:1-(c+g-i)/a,width:f/r,height:g/a});break;case"270":o=(h,c,f,g)=>({x:1-(c+g-i)/a,y:(h-s)/r,width:g/a,height:f/r});break;default:o=(h,c,f,g)=>({x:(h-s)/r,y:(c-i)/a,width:f/r,height:g/a});break}const l=[];for(let h=0,c=e.rangeCount;h<c;h++){const f=e.getRangeAt(h);if(!f.collapsed)for(const{x:g,y:m,width:A,height:y}of f.getClientRects())A===0||y===0||l.push(o(g,m,A,y))}return l.length===0?null:l}addChangedExistingAnnotation({annotationElementId:t,id:e}){(n(this,Ra)||p(this,Ra,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=n(this,Ra))==null||e.delete(t)}renderAnnotationElement(t){var i;const e=(i=n(this,Ra))==null?void 0:i.get(t.data.id);if(!e)return;const s=n(this,zs).getRawValue(e);s&&(n(this,Tt)===$.NONE&&!s.hasBeenModified||s.renderAnnotationElement(t))}setMissingCanvas(t,e,s){var r;const i=(r=n(this,Hi))==null?void 0:r.get(t);i&&(i.setCanvas(e,s),n(this,Hi).delete(t))}addMissingCanvas(t,e){(n(this,Hi)||p(this,Hi,new Map)).set(t,e)}};ka=new WeakMap,ue=new WeakMap,Pa=new WeakMap,Ct=new WeakMap,Bt=new WeakMap,Ma=new WeakMap,zs=new WeakMap,Ra=new WeakMap,Fe=new WeakMap,Gs=new WeakMap,Li=new WeakMap,Ii=new WeakMap,Da=new WeakMap,$n=new WeakMap,cs=new WeakMap,Ne=new WeakMap,zn=new WeakMap,Xl=new WeakMap,ql=new WeakMap,La=new WeakMap,Yl=new WeakMap,ds=new WeakMap,Fi=new WeakMap,Ia=new WeakMap,Ni=new WeakMap,us=new WeakMap,gu=new WeakMap,Oi=new WeakMap,Fa=new WeakMap,Kl=new WeakMap,Bi=new WeakMap,Gn=new WeakMap,Na=new WeakMap,Hi=new WeakMap,Ql=new WeakMap,Tt=new WeakMap,Q=new WeakMap,Us=new WeakMap,$i=new WeakMap,zi=new WeakMap,Jl=new WeakMap,Oa=new WeakMap,Zl=new WeakMap,Gi=new WeakMap,fs=new WeakMap,js=new WeakMap,th=new WeakMap,eh=new WeakMap,Oe=new WeakMap,Ba=new WeakSet,Sd=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},sh=new WeakSet,kp=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of n(this,Bt).values())if(s.hasTextLayer(t))return s;return null},mu=new WeakSet,Om=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const s=b(this,Ba,Sd).call(this,t).closest(".textLayer"),i=this.getSelectionBoxes(s);i&&(n(this,us)||p(this,us,new sy(this)),n(this,us).show(s,i,this.direction==="ltr"))},bu=new WeakSet,Bm=function(){var r,a,o;const t=document.getSelection();if(!t||t.isCollapsed){n(this,Us)&&((r=n(this,us))==null||r.hide(),p(this,Us,null),b(this,Ht,Qt).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===n(this,Us))return;const i=b(this,Ba,Sd).call(this,t).closest(".textLayer");if(!i){n(this,Us)&&((a=n(this,us))==null||a.hide(),p(this,Us,null),b(this,Ht,Qt).call(this,{hasSelectedText:!1}));return}if((o=n(this,us))==null||o.hide(),p(this,Us,e),b(this,Ht,Qt).call(this,{hasSelectedText:!0}),!(n(this,Tt)!==$.HIGHLIGHT&&n(this,Tt)!==$.NONE)&&(n(this,Tt)===$.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Ni,this.isShiftKeyDown),!this.isShiftKeyDown)){const l=n(this,Tt)===$.HIGHLIGHT?b(this,sh,kp).call(this,i):null;if(l==null||l.toggleDrawing(),n(this,Fa)){const h=new AbortController,c=this.combinedSignal(h),f=g=>{g.type==="pointerup"&&g.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),g.type==="pointerup"&&b(this,Un,bl).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:c}),window.addEventListener("blur",f,{signal:c})}else l==null||l.toggleDrawing(!0),b(this,Un,bl).call(this,"main_toolbar")}},Un=new WeakSet,bl=function(t=""){n(this,Tt)===$.HIGHLIGHT?this.highlightSelection(t):n(this,Xl)&&b(this,mu,Om).call(this)},Au=new WeakSet,Hm=function(){document.addEventListener("selectionchange",b(this,bu,Bm).bind(this),{signal:this._signal})},yu=new WeakSet,$m=function(){if(n(this,Fi))return;p(this,Fi,new AbortController);const t=this.combinedSignal(n(this,Fi));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},wu=new WeakSet,zm=function(){var t;(t=n(this,Fi))==null||t.abort(),p(this,Fi,null)},ih=new WeakSet,Pp=function(){if(n(this,Bi))return;p(this,Bi,new AbortController);const t=this.combinedSignal(n(this,Bi));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},vu=new WeakSet,Gm=function(){var t;(t=n(this,Bi))==null||t.abort(),p(this,Bi,null)},nh=new WeakSet,Mp=function(){if(n(this,Li))return;p(this,Li,new AbortController);const t=this.combinedSignal(n(this,Li));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})},rh=new WeakSet,Rp=function(){var t;(t=n(this,Li))==null||t.abort(),p(this,Li,null)},_u=new WeakSet,Um=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Ht=new WeakSet,Qt=function(t){Object.entries(t).some(([s,i])=>n(this,Zl)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(n(this,Zl),t)}),n(this,Tt)===$.HIGHLIGHT&&t.hasSelectedEditor===!1&&b(this,qe,Fs).call(this,[[X.HIGHLIGHT_FREE,!0]]))},qe=new WeakSet,Fs=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Su=new WeakSet,jm=async function(){if(!n(this,Oi)){p(this,Oi,!0);const t=[];for(const e of n(this,Bt).values())t.push(e.enable());await Promise.all(t);for(const e of n(this,Ct).values())e.enable()}},Eu=new WeakSet,Vm=function(){if(this.unselectAll(),n(this,Oi)){p(this,Oi,!1);for(const t of n(this,Bt).values())t.disable();for(const t of n(this,Ct).values())t.disable()}},ah=new WeakSet,Dp=function(t){const e=n(this,Bt).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Cu=new WeakSet,Wm=function(){let t=null;for(t of n(this,Q));return t},jn=new WeakSet,Al=function(){if(n(this,Ct).size===0)return!0;if(n(this,Ct).size===1)for(const t of n(this,Ct).values())return t.isEmpty();return!1},oh=new WeakSet,Lp=function(t){for(const e of n(this,Q))e.unselect();n(this,Q).clear();for(const e of t)e.isEmpty()||(n(this,Q).add(e),e.select());b(this,Ht,Qt).call(this,{hasSelectedEditor:this.hasSelection})},k(wa,"TRANSLATE_SMALL",1),k(wa,"TRANSLATE_BIG",10);let aa=wa;var Mt,ps,Ye,Ha,gs,fe,$a,ms,oe,Vs,Vn,bs,Ui,Wn,yl,za,Ed;const Jt=class Jt{constructor(t){d(this,Wn);d(this,za);d(this,Mt,null);d(this,ps,!1);d(this,Ye,null);d(this,Ha,null);d(this,gs,null);d(this,fe,null);d(this,$a,!1);d(this,ms,null);d(this,oe,null);d(this,Vs,null);d(this,Vn,null);d(this,bs,!1);p(this,oe,t),p(this,bs,t._uiManager.useNewAltTextFlow),n(Jt,Ui)||p(Jt,Ui,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){Jt._l10n??(Jt._l10n=t)}async render(){const t=p(this,Ye,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Ha,document.createElement("span"));t.append(e),n(this,bs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",n(Jt,Ui).missing),e.setAttribute("data-l10n-id",n(Jt,Ui)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const s=n(this,oe)._uiManager._signal;t.addEventListener("contextmenu",je,{signal:s}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:s});const i=r=>{r.preventDefault(),n(this,oe)._uiManager.editAltText(n(this,oe)),n(this,bs)&&n(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:n(this,Wn,yl)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,$a,!0),i(r))},{signal:s}),await b(this,za,Ed).call(this),t}finish(){n(this,Ye)&&(n(this,Ye).focus({focusVisible:n(this,$a)}),p(this,$a,!1))}isEmpty(){return n(this,bs)?n(this,Mt)===null:!n(this,Mt)&&!n(this,ps)}hasData(){return n(this,bs)?n(this,Mt)!==null||!!n(this,Vs):this.isEmpty()}get guessedText(){return n(this,Vs)}async setGuessedText(t){n(this,Mt)===null&&(p(this,Vs,t),p(this,Vn,await Jt._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),b(this,za,Ed).call(this))}toggleAltTextBadge(t=!1){var e;if(!n(this,bs)||n(this,Mt)){(e=n(this,ms))==null||e.remove(),p(this,ms,null);return}if(!n(this,ms)){const s=p(this,ms,document.createElement("div"));s.className="noAltTextBadge",n(this,oe).div.append(s)}n(this,ms).classList.toggle("hidden",!t)}serialize(t){let e=n(this,Mt);return!t&&n(this,Vs)===e&&(e=n(this,Vn)),{altText:e,decorative:n(this,ps),guessedText:n(this,Vs),textWithDisclaimer:n(this,Vn)}}get data(){return{altText:n(this,Mt),decorative:n(this,ps)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:r=!1}){s&&(p(this,Vs,s),p(this,Vn,i)),!(n(this,Mt)===t&&n(this,ps)===e)&&(r||(p(this,Mt,t),p(this,ps,e)),b(this,za,Ed).call(this))}toggle(t=!1){n(this,Ye)&&(!t&&n(this,fe)&&(clearTimeout(n(this,fe)),p(this,fe,null)),n(this,Ye).disabled=!t)}shown(){n(this,oe)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:n(this,Wn,yl)}})}destroy(){var t,e;(t=n(this,Ye))==null||t.remove(),p(this,Ye,null),p(this,Ha,null),p(this,gs,null),(e=n(this,ms))==null||e.remove(),p(this,ms,null)}};Mt=new WeakMap,ps=new WeakMap,Ye=new WeakMap,Ha=new WeakMap,gs=new WeakMap,fe=new WeakMap,$a=new WeakMap,ms=new WeakMap,oe=new WeakMap,Vs=new WeakMap,Vn=new WeakMap,bs=new WeakMap,Ui=new WeakMap,Wn=new WeakSet,yl=function(){return n(this,Mt)&&"added"||n(this,Mt)===null&&this.guessedText&&"review"||"missing"},za=new WeakSet,Ed=async function(){var i,r,a;const t=n(this,Ye);if(!t)return;if(n(this,bs)){if(t.classList.toggle("done",!!n(this,Mt)),t.setAttribute("data-l10n-id",n(Jt,Ui)[n(this,Wn,yl)]),(i=n(this,Ha))==null||i.setAttribute("data-l10n-id",n(Jt,Ui)[`${n(this,Wn,yl)}-label`]),!n(this,Mt)){(r=n(this,gs))==null||r.remove();return}}else{if(!n(this,Mt)&&!n(this,ps)){t.classList.remove("done"),(a=n(this,gs))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=n(this,gs);if(!e){p(this,gs,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${n(this,oe).id}`;const o=100,l=n(this,oe)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(n(this,fe)),p(this,fe,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,fe,setTimeout(()=>{p(this,fe,null),n(this,gs).classList.add("show"),n(this,oe)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;n(this,fe)&&(clearTimeout(n(this,fe)),p(this,fe,null)),(h=n(this,gs))==null||h.classList.remove("show")},{signal:l})}n(this,ps)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=n(this,Mt)),e.parentNode||t.append(e);const s=n(this,oe).getElementForAltText();s==null||s.setAttribute("aria-describedby",e.id)},d(Jt,Ui,null),k(Jt,"_l10n",null);let Jd=Jt;var As,Xn,Ke,lh,Ws,Ga,ji;class fd{constructor(t){d(this,As,null);d(this,Xn,!1);d(this,Ke,null);d(this,lh,null);d(this,Ws,null);d(this,Ga,null);d(this,ji,!1);p(this,Ke,t),this.toolbar=null}render(){if(!n(this,Ke)._uiManager.hasCommentManager())return null;const t=p(this,As,document.createElement("button"));t.className="comment",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const e=n(this,Ke)._uiManager._signal;if(!(e instanceof AbortSignal)||e.aborted)return t;t.addEventListener("contextmenu",je,{signal:e}),t.addEventListener("pointerdown",i=>i.stopPropagation(),{signal:e});const s=i=>{i.preventDefault(),this.edit()};return t.addEventListener("click",s,{capture:!0,signal:e}),t.addEventListener("keydown",i=>{i.target===t&&i.key==="Enter"&&(p(this,Xn,!0),s(i))},{signal:e}),t}edit(){const{bottom:t,left:e,right:s}=n(this,Ke).getClientDimensions(),i={top:t};n(this,Ke)._uiManager.direction==="ltr"?i.right=s:i.left=e,n(this,Ke)._uiManager.editComment(n(this,Ke),i)}finish(){n(this,As)&&(n(this,As).focus({focusVisible:n(this,Xn)}),p(this,Xn,!1))}isDeleted(){return n(this,ji)||n(this,Ws)===""}hasBeenEdited(){return this.isDeleted()||n(this,Ws)!==n(this,lh)}serialize(){return this.data}get data(){return{text:n(this,Ws),date:n(this,Ga),deleted:n(this,ji)}}set data(t){if(t===null){p(this,Ws,""),p(this,ji,!0);return}p(this,Ws,t),p(this,Ga,new Date),p(this,ji,!1)}setInitialText(t){p(this,lh,t),this.data=t}toggle(t=!1){n(this,As)&&(n(this,As).disabled=!t)}shown(){}destroy(){var t;(t=n(this,As))==null||t.remove(),p(this,As,null),p(this,Ws,""),p(this,Ga,null),p(this,Ke,null),p(this,Xn,!1),p(this,ji,!1)}}As=new WeakMap,Xn=new WeakMap,Ke=new WeakMap,lh=new WeakMap,Ws=new WeakMap,Ga=new WeakMap,ji=new WeakMap;var Ua,qn,hh,ch,dh,uh,fh,Xs,Yn,qs,Kn,Ys,Tu,Xm,xu,qm,ku,Ym;const Kg=class Kg{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:r=null,onPinchEnd:a=null,signal:o}){d(this,Tu);d(this,xu);d(this,ku);d(this,Ua,void 0);d(this,qn,!1);d(this,hh,null);d(this,ch,void 0);d(this,dh,void 0);d(this,uh,void 0);d(this,fh,void 0);d(this,Xs,null);d(this,Yn,void 0);d(this,qs,null);d(this,Kn,void 0);d(this,Ys,null);p(this,Ua,t),p(this,hh,s),p(this,ch,e),p(this,dh,i),p(this,uh,r),p(this,fh,a),p(this,Kn,new AbortController),p(this,Yn,AbortSignal.any([o,n(this,Kn).signal])),t.addEventListener("touchstart",b(this,Tu,Xm).bind(this),{passive:!1,signal:n(this,Yn)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/Ds.pixelRatio}destroy(){var t,e;(t=n(this,Kn))==null||t.abort(),p(this,Kn,null),(e=n(this,Xs))==null||e.abort(),p(this,Xs,null)}};Ua=new WeakMap,qn=new WeakMap,hh=new WeakMap,ch=new WeakMap,dh=new WeakMap,uh=new WeakMap,fh=new WeakMap,Xs=new WeakMap,Yn=new WeakMap,qs=new WeakMap,Kn=new WeakMap,Ys=new WeakMap,Tu=new WeakSet,Xm=function(t){var i,r,a;if((i=n(this,ch))!=null&&i.call(this))return;if(t.touches.length===1){if(n(this,Xs))return;const o=p(this,Xs,new AbortController),l=AbortSignal.any([n(this,Yn),o.signal]),h=n(this,Ua),c={capture:!0,signal:l,passive:!1},f=g=>{var m;g.pointerType==="touch"&&((m=n(this,Xs))==null||m.abort(),p(this,Xs,null))};h.addEventListener("pointerdown",g=>{g.pointerType==="touch"&&(vt(g),f(g))},c),h.addEventListener("pointerup",f,c),h.addEventListener("pointercancel",f,c);return}if(!n(this,Ys)){p(this,Ys,new AbortController);const o=AbortSignal.any([n(this,Yn),n(this,Ys).signal]),l=n(this,Ua),h={signal:o,capture:!1,passive:!1};l.addEventListener("touchmove",b(this,xu,qm).bind(this),h);const c=b(this,ku,Ym).bind(this);l.addEventListener("touchend",c,h),l.addEventListener("touchcancel",c,h),h.capture=!0,l.addEventListener("pointerdown",vt,h),l.addEventListener("pointermove",vt,h),l.addEventListener("pointercancel",vt,h),l.addEventListener("pointerup",vt,h),(r=n(this,dh))==null||r.call(this)}if(vt(t),t.touches.length!==2||(a=n(this,hh))!=null&&a.call(this)){p(this,qs,null);return}let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]),p(this,qs,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:s.screenX,touch1Y:s.screenY})},xu=new WeakSet,qm=function(t){var E;if(!n(this,qs)||t.touches.length!==2)return;vt(t);let[e,s]=t.touches;e.identifier>s.identifier&&([e,s]=[s,e]);const{screenX:i,screenY:r}=e,{screenX:a,screenY:o}=s,l=n(this,qs),{touch0X:h,touch0Y:c,touch1X:f,touch1Y:g}=l,m=f-h,A=g-c,y=a-i,v=o-r,w=Math.hypot(y,v)||1,S=Math.hypot(m,A)||1;if(!n(this,qn)&&Math.abs(S-w)<=Kg.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=i,l.touch0Y=r,l.touch1X=a,l.touch1Y=o,!n(this,qn)){p(this,qn,!0);return}const _=[(i+a)/2,(r+o)/2];(E=n(this,uh))==null||E.call(this,_,S,w)},ku=new WeakSet,Ym=function(t){var e;t.touches.length>=2||(n(this,Ys)&&(n(this,Ys).abort(),p(this,Ys,null),(e=n(this,fh))==null||e.call(this)),n(this,qs)&&(vt(t),p(this,qs,null),p(this,qn,!1)))};let Zd=Kg;var Qn,Qe,ot,$t,ja,Vi,ph,Jn,zt,Zn,Ks,Wi,gh,tr,pe,mh,er,Qs,ys,Va,Wa,Be,sr,bh,Pu,Ah,Ip,yh,Fp,Xa,Cd,Mu,Km,Ru,Qm,wh,Np,qa,Td,vh,Op,Du,Jm,Lu,Zm,Iu,tb,_h,Bp,Fu,eb,Sh,Hp,Nu,sb,Ou,ib,Bu,nb,Eh,$p,ir,wl;const G=class G{constructor(t){d(this,Ah);d(this,Xa);d(this,Mu);d(this,Ru);d(this,wh);d(this,qa);d(this,vh);d(this,Du);d(this,Lu);d(this,Iu);d(this,_h);d(this,Fu);d(this,Sh);d(this,Nu);d(this,Ou);d(this,Bu);d(this,Eh);d(this,ir);d(this,Qn,null);d(this,Qe,null);d(this,ot,null);d(this,$t,null);d(this,ja,!1);d(this,Vi,null);d(this,ph,"");d(this,Jn,!1);d(this,zt,null);d(this,Zn,null);d(this,Ks,null);d(this,Wi,null);d(this,gh,"");d(this,tr,!1);d(this,pe,null);d(this,mh,!1);d(this,er,!1);d(this,Qs,!1);d(this,ys,null);d(this,Va,0);d(this,Wa,0);d(this,Be,null);d(this,sr,null);k(this,"isSelected",!1);k(this,"_isCopy",!1);k(this,"_editToolbar",null);k(this,"_initialOptions",Object.create(null));k(this,"_initialData",null);k(this,"_isVisible",!0);k(this,"_uiManager",null);k(this,"_focusEventsAllowed",!0);d(this,bh,!1);d(this,Pu,G._zIndex++);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;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[r,a];const[o,l]=this.parentDimensions;this.x=t.x/o,this.y=t.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=G.prototype._resizeWithKeyboard,e=aa.TRANSLATE_SMALL,s=aa.TRANSLATE_BIG;return V(this,"_resizerKeyboardManager",new hd([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-s,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[s,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-s]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,s]}],[["Escape","mac+Escape"],G.prototype._stopResizingWithKeyboard]]))}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 V(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new ry({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(G._l10n??(G._l10n=t),G._l10nResizer||(G._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"})),G._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);G._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){st("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return n(this,bh)}set _isDraggable(t){var e;p(this,bh,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}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=n(this,Pu)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):b(this,ir,wl).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(n(this,tr)?p(this,tr,!1):this.parent.setSelected(this))}focusout(t){var s;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(s=this.parent)!=null&&s.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[r,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/r,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){b(this,Ah,Ip).call(this,this.parentDimensions,t,e)}translateInPage(t,e){n(this,pe)||p(this,pe,[this.x,this.y,this.width,this.height]),b(this,Ah,Ip).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){n(this,pe)||p(this,pe,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,r]}=this;if(this.x+=t/i,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:g}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,g)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:o}=this;const[l,h]=this.getBaseTranslation();a+=l,o+=h;const{style:c}=s;c.left=`${(100*a).toFixed(2)}%`,c.top=`${(100*o).toFixed(2)}%`,this._onTranslating(a,o),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!n(this,pe)&&(n(this,pe)[0]!==this.x||n(this,pe)[1]!==this.y)}get _hasBeenResized(){return!!n(this,pe)&&(n(this,pe)[2]!==this.width||n(this,pe)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=G,i=s/t,r=s/e;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:r,y:a,width:o,height:l}=this;if(o*=s,l*=i,r*=s,a*=i,this._mustFixPosition)switch(t){case 0:r=ne(r,0,s-o),a=ne(a,0,i-l);break;case 90:r=ne(r,0,s-l),a=ne(a,o,i);break;case 180:r=ne(r,o,s),a=ne(a,l,i);break;case 270:r=ne(r,l,s),a=ne(a,0,i-o);break}this.x=r/=s,this.y=a/=i;const[h,c]=this.getBaseTranslation();r+=h,a+=c,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return b(s=G,yh,Fp).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return b(s=G,yh,Fp).call(s,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions,{style:r}=this.div;r.width=`${(100*t/s).toFixed(2)}%`,n(this,Jn)||(r.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),r=!n(this,Jn)&&e.endsWith("%");if(i&&r)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!n(this,Jn)&&!r&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=n(this,ot))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||n(this,er))return this._editToolbar;this._editToolbar=new Ep(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=n(this,ot))==null||t.destroy())}addContainer(t){var s;const e=(s=this._editToolbar)==null?void 0:s.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return n(this,ot)||(Jd.initialize(G._l10n),p(this,ot,new Jd(this)),n(this,Qn)&&(n(this,ot).data=n(this,Qn),p(this,Qn,null))),n(this,ot)}get altTextData(){var t;return(t=n(this,ot))==null?void 0:t.data}set altTextData(t){n(this,ot)&&(n(this,ot).data=t)}get guessedAltText(){var t;return(t=n(this,ot))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=n(this,ot))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=n(this,ot))==null?void 0:e.serialize(t)}hasAltText(){return!!n(this,ot)&&!n(this,ot).isEmpty()}hasAltTextData(){var t;return((t=n(this,ot))==null?void 0:t.hasData())??!1}addCommentButton(){return n(this,$t)?n(this,$t):p(this,$t,new fd(this))}get commentColor(){return null}get comment(){const t=n(this,$t);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){n(this,$t)||p(this,$t,new fd(this)),n(this,$t).data=t}setCommentData(t){n(this,$t)||p(this,$t,new fd(this)),n(this,$t).setInitialText(t)}get hasEditedComment(){var t;return(t=n(this,$t))==null?void 0:t.hasBeenEdited()}async editComment(){n(this,$t)||p(this,$t,new fd(this)),n(this,$t).edit()}addComment(t){if(this.hasEditedComment){const[,,,i]=t.rect,[r]=this.pageDimensions,[a]=this.pageTranslation,o=a+r+1,l=i-100,h=o+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[o,l,h,i]}}}render(){var a;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=n(this,ja)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),b(this,Sh,Hp).call(this);const[e,s]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*s/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/s).toFixed(2)}%`);const[i,r]=this.getInitialTranslation();return this.translate(i,r),Fm(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(n(this,sr)||p(this,sr,new Zd({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:b(this,Du,Jm).bind(this),onPinching:b(this,Lu,Zm).bind(this),onPinchEnd:b(this,Iu,tb).bind(this),signal:this._uiManager._signal}))),(a=this._uiManager._editorUndoBar)==null||a.hide(),t}pointerdown(t){const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,tr,!0),this._isDraggable){b(this,Fu,eb).call(this,t);return}b(this,_h,Bp).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){n(this,ys)&&clearTimeout(n(this,ys)),p(this,ys,setTimeout(()=>{var t;p(this,ys,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[r,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,c=e/i,f=this.x*r,g=this.y*a,m=this.width*r,A=this.height*a;switch(s){case 0:return[f+h+o,a-g-c-A+l,f+h+m+o,a-g-c+l];case 90:return[f+c+o,a-g+h+l,f+c+A+o,a-g+h+m+l];case 180:return[f-h-m+o,a-g+c+l,f-h+o,a-g+c+A+l];case 270:return[f-c-A+o,a-g-h-m+l,f-c+o,a-g-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,r,a]=t,o=r-s,l=a-i;switch(this.rotation){case 0:return[s,e-a,o,l];case 90:return[s,e-i,l,o];case 180:return[r,e-i,o,l];case 270:return[r,e-a,l,o];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,er,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,er,!1),!0):!1}isInEditMode(){return n(this,er)}shouldGetKeyboardEvents(){return n(this,Qs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:r,innerWidth:a}=window;return e<a&&i>0&&t<r&&s>0}rebuild(){b(this,Sh,Hp).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){st("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId});i.rotation=t.rotation,p(i,Qn,t.accessibilityData),i._isCopy=t.isCopy||!1;const[r,a]=i.pageDimensions,[o,l,h,c]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/r,i.y=l/a,i.width=h/r,i.height=c/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e;if((t=n(this,Wi))==null||t.abort(),p(this,Wi,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),n(this,ys)&&(clearTimeout(n(this,ys)),p(this,ys,null)),b(this,ir,wl).call(this),this.removeEditToolbar(),n(this,Be)){for(const s of n(this,Be).values())clearTimeout(s);p(this,Be,null)}this.parent=null,(e=n(this,sr))==null||e.destroy(),p(this,sr,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(b(this,Mu,Km).call(this),n(this,zt).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=n(this,zt).children;if(!n(this,Qe)){p(this,Qe,Array.from(e));const a=b(this,Nu,sb).bind(this),o=b(this,Ou,ib).bind(this),l=this._uiManager._signal;for(const h of n(this,Qe)){const c=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",b(this,Bu,nb).bind(this,c),{signal:l}),h.setAttribute("data-l10n-id",G._l10nResizer[c])}}const s=n(this,Qe)[0];let i=0;for(const a of e){if(a===s)break;i++}const r=(360-this.rotation+this.parentRotation)%360/90*(n(this,Qe).length/4);if(r!==i){if(r<i)for(let o=0;o<i-r;o++)n(this,zt).append(n(this,zt).firstChild);else if(r>i)for(let o=0;o<r-i;o++)n(this,zt).firstChild.before(n(this,zt).lastChild);let a=0;for(const o of e){const h=n(this,Qe)[a++].getAttribute("data-resizer-name");o.setAttribute("data-l10n-id",G._l10nResizer[h])}}b(this,Eh,$p).call(this,0),p(this,Qs,!0),n(this,zt).firstChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){n(this,Qs)&&b(this,vh,Op).call(this,n(this,gh),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){b(this,ir,wl).call(this),this.div.focus()}select(){var t,e,s;if(!(this.isSelected&&this._editToolbar)){if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var i,r;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(s=n(this,ot))==null||s.toggleAltTextBadge(!1)}}unselect(){var t,e,s,i,r;this.isSelected&&(this.isSelected=!1,(t=n(this,zt))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(s=this.div)!=null&&s.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(i=this._editToolbar)==null||i.hide(),(r=n(this,ot))==null||r.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return n(this,mh)}set isEditing(t){p(this,mh,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,Jn,!0);const s=t/e,{style:i}=this.div;i.aspectRatio=s,i.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){n(this,Be)||p(this,Be,new Map);const{action:s}=t;let i=n(this,Be).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),n(this,Be).delete(s),n(this,Be).size===0&&p(this,Be,null)},G._telemetryTimeout),n(this,Be).set(s,i);return}t.type||(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),p(this,ja,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,ja,!0)}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const s=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),s.before(e)}return e}resetAnnotationElement(t){const{firstChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};Qn=new WeakMap,Qe=new WeakMap,ot=new WeakMap,$t=new WeakMap,ja=new WeakMap,Vi=new WeakMap,ph=new WeakMap,Jn=new WeakMap,zt=new WeakMap,Zn=new WeakMap,Ks=new WeakMap,Wi=new WeakMap,gh=new WeakMap,tr=new WeakMap,pe=new WeakMap,mh=new WeakMap,er=new WeakMap,Qs=new WeakMap,ys=new WeakMap,Va=new WeakMap,Wa=new WeakMap,Be=new WeakMap,sr=new WeakMap,bh=new WeakMap,Pu=new WeakMap,Ah=new WeakSet,Ip=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},yh=new WeakSet,Fp=function(t,e,s){switch(s){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Xa=new WeakSet,Cd=function(t){switch(t){case 90:{const[e,s]=this.pageDimensions;return[0,-e/s,s/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,s]=this.pageDimensions;return[0,e/s,-s/e,0]}default:return[1,0,0,1]}},Mu=new WeakSet,Km=function(){if(n(this,zt))return;p(this,zt,document.createElement("div")),n(this,zt).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 s of t){const i=document.createElement("div");n(this,zt).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",b(this,Ru,Qm).bind(this,s),{signal:e}),i.addEventListener("contextmenu",je,{signal:e}),i.tabIndex=-1}this.div.prepend(n(this,zt))},Ru=new WeakSet,Qm=function(t,e){var c;e.preventDefault();const{isMac:s}=Wt.platform;if(e.button!==0||e.ctrlKey&&s)return;(c=n(this,ot))==null||c.toggle(!1);const i=this._isDraggable;this._isDraggable=!1,p(this,Zn,[e.screenX,e.screenY]);const r=new AbortController,a=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",b(this,vh,Op).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("touchmove",vt,{passive:!1,signal:a}),window.addEventListener("contextmenu",je,{signal:a}),p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var f;r.abort(),this.parent.togglePointerEvents(!0),(f=n(this,ot))==null||f.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=o,this.div.style.cursor=l,b(this,qa,Td).call(this)};window.addEventListener("pointerup",h,{signal:a}),window.addEventListener("blur",h,{signal:a})},wh=new WeakSet,Np=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[r,a]=this.parentDimensions;this.setDims(r*s,a*i),this.fixAndSetPosition(),this._onResized()},qa=new WeakSet,Td=function(){if(!n(this,Ks))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=n(this,Ks);p(this,Ks,null);const r=this.x,a=this.y,o=this.width,l=this.height;r===t&&a===e&&o===s&&l===i||this.addCommands({cmd:b(this,wh,Np).bind(this,r,a,o,l),undo:b(this,wh,Np).bind(this,t,e,s,i),mustExec:!0})},vh=new WeakSet,Op=function(t,e){const[s,i]=this.parentDimensions,r=this.x,a=this.y,o=this.width,l=this.height,h=G.MIN_SIZE/s,c=G.MIN_SIZE/i,f=b(this,Xa,Cd).call(this,this.rotation),g=(B,N)=>[f[0]*B+f[2]*N,f[1]*B+f[3]*N],m=b(this,Xa,Cd).call(this,360-this.rotation),A=(B,N)=>[m[0]*B+m[2]*N,m[1]*B+m[3]*N];let y,v,w=!1,S=!1;switch(t){case"topLeft":w=!0,y=(B,N)=>[0,0],v=(B,N)=>[B,N];break;case"topMiddle":y=(B,N)=>[B/2,0],v=(B,N)=>[B/2,N];break;case"topRight":w=!0,y=(B,N)=>[B,0],v=(B,N)=>[0,N];break;case"middleRight":S=!0,y=(B,N)=>[B,N/2],v=(B,N)=>[0,N/2];break;case"bottomRight":w=!0,y=(B,N)=>[B,N],v=(B,N)=>[0,0];break;case"bottomMiddle":y=(B,N)=>[B/2,N],v=(B,N)=>[B/2,0];break;case"bottomLeft":w=!0,y=(B,N)=>[0,N],v=(B,N)=>[B,0];break;case"middleLeft":S=!0,y=(B,N)=>[0,N/2],v=(B,N)=>[B,N/2];break}const _=y(o,l),E=v(o,l);let C=g(...E);const T=G._round(r+C[0]),x=G._round(a+C[1]);let P=1,M=1,D,R;if(e.fromKeyboard)({deltaX:D,deltaY:R}=e);else{const{screenX:B,screenY:N}=e,[Pt,At]=n(this,Zn);[D,R]=this.screenToPageTranslation(B-Pt,N-At),n(this,Zn)[0]=B,n(this,Zn)[1]=N}if([D,R]=A(D/s,R/i),w){const B=Math.hypot(o,l);P=M=Math.max(Math.min(Math.hypot(E[0]-_[0]-D,E[1]-_[1]-R)/B,1/o,1/l),h/o,c/l)}else S?P=ne(Math.abs(E[0]-_[0]-D),h,1)/o:M=ne(Math.abs(E[1]-_[1]-R),c,1)/l;const H=G._round(o*P),U=G._round(l*M);C=g(...v(H,U));const W=T-C[0],Y=x-C[1];n(this,pe)||p(this,pe,[this.x,this.y,this.width,this.height]),this.width=H,this.height=U,this.x=W,this.y=Y,this.setDims(s*H,i*U),this.fixAndSetPosition(),this._onResizing()},Du=new WeakSet,Jm=function(){var t;p(this,Ks,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=n(this,ot))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Lu=new WeakSet,Zm=function(t,e,s){let r=.7*(s/e)+1-.7;if(r===1)return;const a=b(this,Xa,Cd).call(this,this.rotation),o=(T,x)=>[a[0]*T+a[2]*x,a[1]*T+a[3]*x],[l,h]=this.parentDimensions,c=this.x,f=this.y,g=this.width,m=this.height,A=G.MIN_SIZE/l,y=G.MIN_SIZE/h;r=Math.max(Math.min(r,1/g,1/m),A/g,y/m);const v=G._round(g*r),w=G._round(m*r);if(v===g&&w===m)return;n(this,pe)||p(this,pe,[c,f,g,m]);const S=o(g/2,m/2),_=G._round(c+S[0]),E=G._round(f+S[1]),C=o(v/2,w/2);this.x=_-C[0],this.y=E-C[1],this.width=v,this.height=w,this.setDims(l*v,h*w),this.fixAndSetPosition(),this._onResizing()},Iu=new WeakSet,tb=function(){var t;(t=n(this,ot))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),b(this,qa,Td).call(this)},_h=new WeakSet,Bp=function(t){const{isMac:e}=Wt.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Fu=new WeakSet,eb=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,r=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:r},o=h=>{i.abort(),p(this,Vi,null),p(this,tr,!1),this._uiManager.endDragSession()||b(this,_h,Bp).call(this,h),s&&this._onStopDragging()};e&&(p(this,Va,t.clientX),p(this,Wa,t.clientY),p(this,Vi,t.pointerId),p(this,ph,t.pointerType),window.addEventListener("pointermove",h=>{s||(s=!0,this._onStartDragging());const{clientX:c,clientY:f,pointerId:g}=h;if(g!==n(this,Vi)){vt(h);return}const[m,A]=this.screenToPageTranslation(c-n(this,Va),f-n(this,Wa));p(this,Va,c),p(this,Wa,f),this._uiManager.dragSelectedEditors(m,A)},a),window.addEventListener("touchmove",vt,a),window.addEventListener("pointerdown",h=>{h.pointerType===n(this,ph)&&(n(this,sr)||h.isPrimary)&&o(h),vt(h)},a));const l=h=>{if(!n(this,Vi)||n(this,Vi)===h.pointerId){o(h);return}vt(h)};window.addEventListener("pointerup",l,{signal:r}),window.addEventListener("blur",l,{signal:r})},Sh=new WeakSet,Hp=function(){if(n(this,Wi)||!this.div)return;p(this,Wi,new AbortController);const t=this._uiManager.combinedSignal(n(this,Wi));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Nu=new WeakSet,sb=function(t){G._resizerKeyboardManager.exec(this,t)},Ou=new WeakSet,ib=function(t){var e;n(this,Qs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==n(this,zt)&&b(this,ir,wl).call(this)},Bu=new WeakSet,nb=function(t){p(this,gh,n(this,Qs)?t:"")},Eh=new WeakSet,$p=function(t){if(n(this,Qe))for(const e of n(this,Qe))e.tabIndex=t},ir=new WeakSet,wl=function(){p(this,Qs,!1),b(this,Eh,$p).call(this,-1),b(this,qa,Td).call(this)},d(G,yh),k(G,"_l10n",null),k(G,"_l10nResizer",null),k(G,"_borderLineWidth",-1),k(G,"_colorManager",new xp),k(G,"_zIndex",1),k(G,"_telemetryTimeout",1e3);let rt=G;class ry extends rt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const rm=3285377520,De=4294901760,ls=65535;class rb{constructor(t){this.h1=t?t&4294967295:rm,this.h2=t?t&4294967295:rm}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,v=t.length;y<v;y++){const w=t.charCodeAt(y);w<=255?e[s++]=w:(e[s++]=w>>>8,e[s++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),s=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const i=s>>2,r=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,c=this.h2;const f=3432918353,g=461845907,m=f&ls,A=g&ls;for(let y=0;y<i;y++)y&1?(o=a[y],o=o*f&De|o*m&ls,o=o<<15|o>>>17,o=o*g&De|o*A&ls,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*f&De|l*m&ls,l=l<<15|l>>>17,l=l*g&De|l*A&ls,c^=l,c=c<<13|c>>>19,c=c*5+3864292196);switch(o=0,r){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*f&De|o*m&ls,o=o<<15|o>>>17,o=o*g&De|o*A&ls,i&1?h^=o:c^=o}this.h1=h,this.h2=c}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&De|t*36045&ls,e=e*4283543511&De|((e<<16|t>>>16)*2950163797&De)>>>16,t^=e>>>1,t=t*444984403&De|t*60499&ls,e=e*3301882366&De|((e<<16|t>>>16)*3120437893&De)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const zp=Object.freeze({map:null,hash:"",transfer:void 0});var nr,rr,Gt,Hu,ab;class Gg{constructor(){d(this,Hu);d(this,nr,!1);d(this,rr,null);d(this,Gt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=n(this,Gt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return n(this,Gt).get(t)}remove(t){if(n(this,Gt).delete(t),n(this,Gt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of n(this,Gt).values())if(e instanceof rt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=n(this,Gt).get(t);let i=!1;if(s!==void 0)for(const[r,a]of Object.entries(e))s[r]!==a&&(i=!0,s[r]=a);else i=!0,n(this,Gt).set(t,e);i&&b(this,Hu,ab).call(this),e instanceof rt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return n(this,Gt).has(t)}get size(){return n(this,Gt).size}resetModified(){n(this,nr)&&(p(this,nr,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new ob(this)}get serializable(){if(n(this,Gt).size===0)return zp;const t=new Map,e=new rb,s=[],i=Object.create(null);let r=!1;for(const[a,o]of n(this,Gt)){const l=o instanceof rt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),r||(r=!!l.bitmap))}if(r)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:zp}get editorStats(){let t=null;const e=new Map;for(const s of n(this,Gt).values()){if(!(s instanceof rt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:r}=i;e.has(r)||e.set(r,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const a=t[r]||(t[r]=new Map);for(const[o,l]of Object.entries(i)){if(o==="type")continue;let h=a.get(o);h||(h=new Map,a.set(o,h));const c=h.get(l)??0;h.set(l,c+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,rr,null)}get modifiedIds(){if(n(this,rr))return n(this,rr);const t=[];for(const e of n(this,Gt).values())!(e instanceof rt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,rr,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return n(this,Gt).entries()}}nr=new WeakMap,rr=new WeakMap,Gt=new WeakMap,Hu=new WeakSet,ab=function(){n(this,nr)||(p(this,nr,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var Ch;class ob extends Gg{constructor(e){super();d(this,Ch,void 0);const{map:s,hash:i,transfer:r}=e.serializable,a=structuredClone(s,r?{transfer:r}:null);p(this,Ch,{map:a,hash:i,transfer:r})}get print(){st("Should not call PrintAnnotationStorage.print")}get serializable(){return n(this,Ch)}get modifiedIds(){return V(this,"modifiedIds",{ids:new Set,hash:""})}}Ch=new WeakMap;var Ya;class ay{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){d(this,Ya,new Set);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(),n(this,Ya).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(!(!t||n(this,Ya).has(t.loadedName))){if(_t(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:i,src:r,style:a}=t,o=new FontFace(i,r,a);this.addNativeFontFace(o);try{await o.load(),n(this,Ya).add(i),s==null||s(t)}catch{z(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}st("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){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw z(`Failed to load font '${s.family}': '${i}'.`),t.disableFontFace=!0,i}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(s=>{const i=this._queueLoadingCallback(s);this._prepareFontLoadEvent(t,i)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return V(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return V(this,"isSyncFontLoadingSupported",ie||Wt.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(_t(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const r=s.shift();setTimeout(r.callback,0)}}const{loadingRequests:s}=this,i={done:!1,complete:e,callback:t};return s.push(i),i}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return V(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(E,C){return E.charCodeAt(C)<<24|E.charCodeAt(C+1)<<16|E.charCodeAt(C+2)<<8|E.charCodeAt(C+3)&255}function i(E,C,T,x){const P=E.substring(0,C),M=E.substring(C+T);return P+x+M}let r,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function c(E,C){if(++h>30){z("Load test font never loaded."),C();return}if(l.font="30px "+E,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(c.bind(null,E,C))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let g=this._loadTestFont;g=i(g,976,f.length,f);const A=16,y=1482184792;let v=s(g,A);for(r=0,a=f.length-3;r<a;r+=4)v=v-y+s(f,r)|0;r<f.length&&(v=v-y+s(f+"XXX",r)|0),g=i(g,A,4,jA(v));const w=`url(data:font/opentype;base64,${btoa(g)});`,S=`@font-face {font-family:"${f}";src:${w}}`;this.insertRule(S);const _=this._document.createElement("div");_.style.visibility="hidden",_.style.width=_.style.height="10px",_.style.position="absolute",_.style.top=_.style.left="0px";for(const E of[t.loadedName,f]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=E,_.append(C)}this._document.body.append(_),c(f,()=>{_.remove(),e.complete()})}}Ya=new WeakMap;class oy{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const s in t)this[s]=t[s];this._inspectFont=e}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const s={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(s.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,s)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var s;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${Pm(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{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}}`}return(s=this._inspectFont)==null||s.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){z(`getPathGenerator - ignoring character: "${a}".`)}const r=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=r}}function ly(u){if(u instanceof URL)return u.href;if(typeof u=="string"){if(ie)return u;const t=URL.parse(u,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function hy(u){if(ie&&typeof Buffer<"u"&&u instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(u instanceof Uint8Array&&u.byteLength===u.buffer.byteLength)return u;if(typeof u=="string")return ad(u);if(u instanceof ArrayBuffer||ArrayBuffer.isView(u)||typeof u=="object"&&!isNaN(u==null?void 0:u.length))return new Uint8Array(u);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function pd(u){if(typeof u!="string")return null;if(u.endsWith("/"))return u;throw new Error(`Invalid factory url: "${u}" must include trailing slash.`)}const Gp=u=>typeof u=="object"&&Number.isInteger(u==null?void 0:u.num)&&u.num>=0&&Number.isInteger(u==null?void 0:u.gen)&&u.gen>=0,cy=u=>typeof u=="object"&&typeof(u==null?void 0:u.name)=="string",dy=YA.bind(null,Gp,cy);var Js,$u;class uy{constructor(){d(this,Js,new Map);d(this,$u,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};n(this,$u).then(()=>{for(const[i]of n(this,Js))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:r}=s;if(r.aborted){z("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>r.removeEventListener("abort",a),r.addEventListener("abort",a)}n(this,Js).set(e,i)}removeEventListener(t,e){const s=n(this,Js).get(e);s==null||s(),n(this,Js).delete(e)}terminate(){for(const[,t]of n(this,Js))t==null||t();n(this,Js).clear()}}Js=new WeakMap,$u=new WeakMap;const gd={DATA:1,ERROR:2},yt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function am(){}function re(u){if(u instanceof kn||u instanceof vp||u instanceof sm||u instanceof Kd||u instanceof fp)return u;switch(u instanceof Error||typeof u=="object"&&u!==null||st('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),u.name){case"AbortException":return new kn(u.message);case"InvalidPDFException":return new vp(u.message);case"PasswordException":return new sm(u.message,u.code);case"ResponseException":return new Kd(u.message,u.status,u.missing);case"UnknownErrorException":return new fp(u.message,u.details)}return new fp(u.message,u.toString())}var Ka,zu,lb,Gu,hb,Uu,cb,Qa,xd;class vl{constructor(t,e,s){d(this,zu);d(this,Gu);d(this,Uu);d(this,Qa);d(this,Ka,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=s,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),s.addEventListener("message",b(this,zu,lb).bind(this),{signal:n(this,Ka).signal})}on(t,e){const s=this.actionHandler;if(s[t])throw new Error(`There is already an actionName called "${t}"`);s[t]=e}send(t,e,s){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},s)}sendWithPromise(t,e,s){const i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){r.reject(a)}return r.promise}sendWithStream(t,e,s,i){const r=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const c=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:c,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:r,data:e,desiredSize:h.desiredSize},i),c.promise},pull:h=>{const c=Promise.withResolvers();return this.streamControllers[r].pullCall=c,l.postMessage({sourceName:a,targetName:o,stream:yt.PULL,streamId:r,desiredSize:h.desiredSize}),c.promise},cancel:h=>{_t(h instanceof Error,"cancel must have a valid reason");const c=Promise.withResolvers();return this.streamControllers[r].cancelCall=c,this.streamControllers[r].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:yt.CANCEL,streamId:r,reason:re(h)}),c.promise}},s)}destroy(){var t;(t=n(this,Ka))==null||t.abort(),p(this,Ka,null)}}Ka=new WeakMap,zu=new WeakSet,lb=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){b(this,Uu,cb).call(this,t);return}if(t.callback){const s=t.callbackId,i=this.callbackCapabilities[s];if(!i)throw new Error(`Cannot resolve callback ${s}`);if(delete this.callbackCapabilities[s],t.callback===gd.DATA)i.resolve(t.data);else if(t.callback===gd.ERROR)i.reject(re(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(a){r.postMessage({sourceName:s,targetName:i,callback:gd.DATA,callbackId:t.callbackId,data:a})},function(a){r.postMessage({sourceName:s,targetName:i,callback:gd.ERROR,callbackId:t.callbackId,reason:re(a)})});return}if(t.streamId){b(this,Gu,hb).call(this,t);return}e(t.data)},Gu=new WeakSet,hb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,c=1,f){if(this.isCancelled)return;const g=this.desiredSize;this.desiredSize-=c,g>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:s,targetName:i,stream:yt.ENQUEUE,streamId:e,chunk:h},f)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:yt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){_t(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:s,targetName:i,stream:yt.ERROR,streamId:e,reason:re(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};l.sinkCapability.resolve(),l.ready=l.sinkCapability.promise,this.streamSinks[e]=l,Promise.try(o,t.data,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.START_COMPLETE,streamId:e,reason:re(h)})})},Uu=new WeakSet,cb=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,r=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case yt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(re(t.reason));break;case yt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(re(t.reason));break;case yt.PULL:if(!o){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,Promise.try(o.onPull||am).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.PULL_COMPLETE,streamId:e,reason:re(h)})});break;case yt.ENQUEUE:if(_t(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case yt.CLOSE:if(_t(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),b(this,Qa,xd).call(this,a,e);break;case yt.ERROR:_t(a,"error should have stream controller"),a.controller.error(re(t.reason)),b(this,Qa,xd).call(this,a,e);break;case yt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(re(t.reason)),b(this,Qa,xd).call(this,a,e);break;case yt.CANCEL:if(!o)break;const l=re(t.reason);Promise.try(o.onCancel||am,l).then(function(){r.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:s,targetName:i,stream:yt.CANCEL_COMPLETE,streamId:e,reason:re(h)})}),o.sinkCapability.reject(l),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Qa=new WeakSet,xd=async function(t,e){var s,i,r;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};var Th;class db{constructor({enableHWA:t=!1}){d(this,Th,!1);p(this,Th,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!n(this,Th)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){st("Abstract method `_createCanvas` called.")}}Th=new WeakMap;class fy extends db{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class ub{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(s=>({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){st("Abstract method `_fetch` called.")}}class om extends ub{async _fetch(t){const e=await od(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):ad(e)}}class fb{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,r){return"none"}destroy(t=!1){}}var ar,Ja,Zs,ti,Yt,or,lr,Rt,Xt,hr,_l,Xi,fa,Za,kd,qi,pa,ju,pb,xh,Up,Yi,ga,cr,Sl,dr,El,kh,jp,ur,Cl;class py extends fb{constructor({docId:e,ownerDocument:s=globalThis.document}){super();d(this,Rt);d(this,hr);d(this,Xi);d(this,Za);d(this,qi);d(this,ju);d(this,xh);d(this,Yi);d(this,cr);d(this,dr);d(this,kh);d(this,ur);d(this,ar,void 0);d(this,Ja,void 0);d(this,Zs,void 0);d(this,ti,void 0);d(this,Yt,void 0);d(this,or,void 0);d(this,lr,0);p(this,ti,e),p(this,Yt,s)}addFilter(e){if(!e)return"none";let s=n(this,Rt,Xt).get(e);if(s)return s;const[i,r,a]=b(this,Za,kd).call(this,e),o=e.length===1?i:`${i}${r}${a}`;if(s=n(this,Rt,Xt).get(o),s)return n(this,Rt,Xt).set(e,s),s;const l=`g_${n(this,ti)}_transfer_map_${St(this,lr)._++}`,h=b(this,qi,pa).call(this,l);n(this,Rt,Xt).set(e,h),n(this,Rt,Xt).set(o,h);const c=b(this,Yi,ga).call(this,l);return b(this,dr,El).call(this,i,r,a,c),h}addHCMFilter(e,s){var A;const i=`${e}-${s}`,r="base";let a=n(this,hr,_l).get(r);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},n(this,hr,_l).set(r,a)),!e||!s))return a.url;const o=b(this,ur,Cl).call(this,e);e=I.makeHexColor(...o);const l=b(this,ur,Cl).call(this,s);if(s=I.makeHexColor(...l),n(this,Xi,fa).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const v=y/255;h[y]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const c=h.join(","),f=`g_${n(this,ti)}_hcm_filter`,g=a.filter=b(this,Yi,ga).call(this,f);b(this,dr,El).call(this,c,c,c,g),b(this,xh,Up).call(this,g);const m=(y,v)=>{const w=o[y]/255,S=l[y]/255,_=new Array(v+1);for(let E=0;E<=v;E++)_[E]=w+E/v*(S-w);return _.join(",")};return b(this,dr,El).call(this,m(0,5),m(1,5),m(2,5),g),a.url=b(this,qi,pa).call(this,f),a.url}addAlphaFilter(e){let s=n(this,Rt,Xt).get(e);if(s)return s;const[i]=b(this,Za,kd).call(this,[e]),r=`alpha_${i}`;if(s=n(this,Rt,Xt).get(r),s)return n(this,Rt,Xt).set(e,s),s;const a=`g_${n(this,ti)}_alpha_map_${St(this,lr)._++}`,o=b(this,qi,pa).call(this,a);n(this,Rt,Xt).set(e,o),n(this,Rt,Xt).set(r,o);const l=b(this,Yi,ga).call(this,a);return b(this,kh,jp).call(this,i,l),o}addLuminosityFilter(e){let s=n(this,Rt,Xt).get(e||"luminosity");if(s)return s;let i,r;if(e?([i]=b(this,Za,kd).call(this,[e]),r=`luminosity_${i}`):r="luminosity",s=n(this,Rt,Xt).get(r),s)return n(this,Rt,Xt).set(e,s),s;const a=`g_${n(this,ti)}_luminosity_map_${St(this,lr)._++}`,o=b(this,qi,pa).call(this,a);n(this,Rt,Xt).set(e,o),n(this,Rt,Xt).set(r,o);const l=b(this,Yi,ga).call(this,a);return b(this,ju,pb).call(this,l),e&&b(this,kh,jp).call(this,i,l),o}addHighlightHCMFilter(e,s,i,r,a){var S;const o=`${s}-${i}-${r}-${a}`;let l=n(this,hr,_l).get(e);if((l==null?void 0:l.key)===o||(l?((S=l.filter)==null||S.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},n(this,hr,_l).set(e,l)),!s||!i))return l.url;const[h,c]=[s,i].map(b(this,ur,Cl).bind(this));let f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),g=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),[m,A]=[r,a].map(b(this,ur,Cl).bind(this));g<f&&([f,g,m,A]=[g,f,A,m]),n(this,Xi,fa).style.color="";const y=(_,E,C)=>{const T=new Array(256),x=(g-f)/C,P=_/255,M=(E-_)/(255*C);let D=0;for(let R=0;R<=C;R++){const H=Math.round(f+R*x),U=P+R*M;for(let W=D;W<=H;W++)T[W]=U;D=H+1}for(let R=D;R<256;R++)T[R]=T[D-1];return T.join(",")},v=`g_${n(this,ti)}_hcm_${e}_filter`,w=l.filter=b(this,Yi,ga).call(this,v);return b(this,xh,Up).call(this,w),b(this,dr,El).call(this,y(m[0],A[0],5),y(m[1],A[1],5),y(m[2],A[2],5),w),l.url=b(this,qi,pa).call(this,v),l.url}destroy(e=!1){var s,i,r,a;e&&((s=n(this,or))!=null&&s.size)||((i=n(this,Zs))==null||i.parentNode.parentNode.remove(),p(this,Zs,null),(r=n(this,Ja))==null||r.clear(),p(this,Ja,null),(a=n(this,or))==null||a.clear(),p(this,or,null),p(this,lr,0))}}ar=new WeakMap,Ja=new WeakMap,Zs=new WeakMap,ti=new WeakMap,Yt=new WeakMap,or=new WeakMap,lr=new WeakMap,Rt=new WeakSet,Xt=function(){return n(this,Ja)||p(this,Ja,new Map)},hr=new WeakSet,_l=function(){return n(this,or)||p(this,or,new Map)},Xi=new WeakSet,fa=function(){if(!n(this,Zs)){const e=n(this,Yt).createElement("div"),{style:s}=e;s.visibility="hidden",s.contain="strict",s.width=s.height=0,s.position="absolute",s.top=s.left=0,s.zIndex=-1;const i=n(this,Yt).createElementNS(Is,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Zs,n(this,Yt).createElementNS(Is,"defs")),e.append(i),i.append(n(this,Zs)),n(this,Yt).body.append(e)}return n(this,Zs)},Za=new WeakSet,kd=function(e){if(e.length===1){const h=e[0],c=new Array(256);for(let g=0;g<256;g++)c[g]=h[g]/255;const f=c.join(",");return[f,f,f]}const[s,i,r]=e,a=new Array(256),o=new Array(256),l=new Array(256);for(let h=0;h<256;h++)a[h]=s[h]/255,o[h]=i[h]/255,l[h]=r[h]/255;return[a.join(","),o.join(","),l.join(",")]},qi=new WeakSet,pa=function(e){if(n(this,ar)===void 0){p(this,ar,"");const s=n(this,Yt).URL;s!==n(this,Yt).baseURI&&(np(s)?z('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,ar,Tm(s,"")))}return`url(${n(this,ar)}#${e})`},ju=new WeakSet,pb=function(e){const s=n(this,Yt).createElementNS(Is,"feColorMatrix");s.setAttribute("type","matrix"),s.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"),e.append(s)},xh=new WeakSet,Up=function(e){const s=n(this,Yt).createElementNS(Is,"feColorMatrix");s.setAttribute("type","matrix"),s.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(s)},Yi=new WeakSet,ga=function(e){const s=n(this,Yt).createElementNS(Is,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),n(this,Xi,fa).append(s),s},cr=new WeakSet,Sl=function(e,s,i){const r=n(this,Yt).createElementNS(Is,s);r.setAttribute("type","discrete"),r.setAttribute("tableValues",i),e.append(r)},dr=new WeakSet,El=function(e,s,i,r){const a=n(this,Yt).createElementNS(Is,"feComponentTransfer");r.append(a),b(this,cr,Sl).call(this,a,"feFuncR",e),b(this,cr,Sl).call(this,a,"feFuncG",s),b(this,cr,Sl).call(this,a,"feFuncB",i)},kh=new WeakSet,jp=function(e,s){const i=n(this,Yt).createElementNS(Is,"feComponentTransfer");s.append(i),b(this,cr,Sl).call(this,i,"feFuncA",e)},ur=new WeakSet,Cl=function(e){return n(this,Xi,fa).style.color=e,rp(getComputedStyle(n(this,Xi,fa)).getPropertyValue("color"))};class gb{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(s=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){st("Abstract method `_fetch` called.")}}class lm extends gb{async _fetch(t){const e=await od(t,"arraybuffer");return new Uint8Array(e)}}class mb{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(s=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){st("Abstract method `_fetch` called.")}}class hm extends mb{async _fetch(t){const e=await od(t,"arraybuffer");return new Uint8Array(e)}}ie&&z("Please use the `legacy` build in Node.js environments.");async function Ug(u){const e=await process.getBuiltinModule("fs").promises.readFile(u);return new Uint8Array(e)}class gy extends fb{}class my extends db{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class by extends ub{async _fetch(t){return Ug(t)}}class Ay extends gb{async _fetch(t){return Ug(t)}}class yy extends mb{async _fetch(t){return Ug(t)}}const ca="__forcedDependency";var ge,Zt,to,ws,eo,ei,J,tt,si,me,Ki,so,Qi,Ji;class wy{constructor(t){d(this,ge,{__proto__:null});d(this,Zt,{__proto__:null,transform:[],moveText:[],sameLineText:[],[ca]:[]});d(this,to,new Map);d(this,ws,[]);d(this,eo,[]);d(this,ei,[[1,0,0,1,0,0]]);d(this,J,[-1/0,-1/0,1/0,1/0]);d(this,tt,new Float64Array([1/0,1/0,-1/0,-1/0]));d(this,si,-1);d(this,me,new Set);d(this,Ki,new Map);d(this,so,new Map);d(this,Qi,void 0);d(this,Ji,void 0);p(this,Qi,t.width),p(this,Ji,t.height)}save(t){return p(this,ge,{__proto__:n(this,ge)}),p(this,Zt,{__proto__:n(this,Zt),transform:{__proto__:n(this,Zt).transform},moveText:{__proto__:n(this,Zt).moveText},sameLineText:{__proto__:n(this,Zt).sameLineText},[ca]:{__proto__:n(this,Zt)[ca]}}),p(this,J,{__proto__:n(this,J)}),n(this,ws).push([t,null]),this}restore(t){const e=Object.getPrototypeOf(n(this,ge));if(e===null)return this;p(this,ge,e),p(this,Zt,Object.getPrototypeOf(n(this,Zt))),p(this,J,Object.getPrototypeOf(n(this,J)));const s=n(this,ws).pop();return s!==void 0&&(s[1]=t),this}recordOpenMarker(t){return n(this,ws).push([t,null]),this}getOpenMarker(){return n(this,ws).length===0?null:n(this,ws).at(-1)[0]}recordCloseMarker(t){const e=n(this,ws).pop();return e!==void 0&&(e[1]=t),this}beginMarkedContent(t){return n(this,eo).push([t,null]),this}endMarkedContent(t){const e=n(this,eo).pop();return e!==void 0&&(e[1]=t),this}pushBaseTransform(t){return n(this,ei).push(I.multiplyByDOMMatrix(n(this,ei).at(-1),t.getTransform())),this}popBaseTransform(){return n(this,ei).length>1&&n(this,ei).pop(),this}recordSimpleData(t,e){return n(this,ge)[t]=e,this}recordIncrementalData(t,e){return n(this,Zt)[t].push(e),this}resetIncrementalData(t,e){return n(this,Zt)[t].length=0,this}recordNamedData(t,e){return n(this,to).set(t,e),this}recordFutureForcedDependency(t,e){return this.recordIncrementalData(ca,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in n(this,ge)&&this.recordFutureForcedDependency(e,n(this,ge)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of n(this,me))this.recordFutureForcedDependency(ca,t);return this}resetBBox(t){return p(this,si,t),n(this,tt)[0]=1/0,n(this,tt)[1]=1/0,n(this,tt)[2]=-1/0,n(this,tt)[3]=-1/0,this}get hasPendingBBox(){return n(this,si)!==-1}recordClipBox(t,e,s,i,r,a){const o=I.multiplyByDOMMatrix(n(this,ei).at(-1),e.getTransform()),l=[1/0,1/0,-1/0,-1/0];I.axialAlignedBoundingBox([s,r,i,a],o,l);const h=I.intersect(n(this,J),l);return h?(n(this,J)[0]=h[0],n(this,J)[1]=h[1],n(this,J)[2]=h[2],n(this,J)[3]=h[3]):(n(this,J)[0]=n(this,J)[1]=1/0,n(this,J)[2]=n(this,J)[3]=-1/0),this}recordBBox(t,e,s,i,r,a){const o=n(this,J);if(o[0]===1/0)return this;const l=I.multiplyByDOMMatrix(n(this,ei).at(-1),e.getTransform());if(o[0]===-1/0)return I.axialAlignedBoundingBox([s,r,i,a],l,n(this,tt)),this;const h=[1/0,1/0,-1/0,-1/0];return I.axialAlignedBoundingBox([s,r,i,a],l,h),n(this,tt)[0]=Math.min(n(this,tt)[0],Math.max(h[0],o[0])),n(this,tt)[1]=Math.min(n(this,tt)[1],Math.max(h[1],o[1])),n(this,tt)[2]=Math.max(n(this,tt)[2],Math.min(h[2],o[2])),n(this,tt)[3]=Math.max(n(this,tt)[3],Math.min(h[3],o[3])),this}recordCharacterBBox(t,e,s,i=1,r=0,a=0,o){const l=s.bbox;let h,c;if(l&&(h=l[2]!==l[0]&&l[3]!==l[1]&&n(this,so).get(s),h!==!1&&(c=[0,0,0,0],I.axialAlignedBoundingBox(l,s.fontMatrix,c),(i!==1||r!==0||a!==0)&&I.scaleMinMax([i,0,0,-i,r,a],c),h)))return this.recordBBox(t,e,c[0],c[2],c[1],c[3]);if(!o)return this.recordFullPageBBox(t);const f=o();return l&&c&&h===void 0&&(h=c[0]<=r-f.actualBoundingBoxLeft&&c[2]>=r+f.actualBoundingBoxRight&&c[1]<=a-f.actualBoundingBoxAscent&&c[3]>=a+f.actualBoundingBoxDescent,n(this,so).set(s,h),h)?this.recordBBox(t,e,c[0],c[2],c[1],c[3]):this.recordBBox(t,e,r-f.actualBoundingBoxLeft,r+f.actualBoundingBoxRight,a-f.actualBoundingBoxAscent,a+f.actualBoundingBoxDescent)}recordFullPageBBox(t){return n(this,tt)[0]=Math.max(0,n(this,J)[0]),n(this,tt)[1]=Math.max(0,n(this,J)[1]),n(this,tt)[2]=Math.min(n(this,Qi),n(this,J)[2]),n(this,tt)[3]=Math.min(n(this,Ji),n(this,J)[3]),this}getSimpleIndex(t){return n(this,ge)[t]}recordDependencies(t,e){const s=n(this,me),i=n(this,ge),r=n(this,Zt);for(const a of e)a in n(this,ge)?s.add(i[a]):a in r&&r[a].forEach(s.add,s);return this}copyDependenciesFromIncrementalOperation(t,e){const s=n(this,Ki),i=n(this,me);for(const r of n(this,Zt)[e])s.get(r).dependencies.forEach(i.add,i.add(r));return this}recordNamedDependency(t,e){return n(this,to).has(e)&&n(this,me).add(n(this,to).get(e)),this}recordOperation(t,e=!1){this.recordDependencies(t,[ca]);const s=new Set(n(this,me)),i=n(this,ws).concat(n(this,eo)),r=n(this,si)===t?{minX:n(this,tt)[0],minY:n(this,tt)[1],maxX:n(this,tt)[2],maxY:n(this,tt)[3]}:null;return n(this,Ki).set(t,{bbox:r,pairs:i,dependencies:s}),e||p(this,si,-1),n(this,me).clear(),this}bboxToClipBoxDropOperation(t){return n(this,si)!==-1&&(p(this,si,-1),n(this,J)[0]=Math.max(n(this,J)[0],n(this,tt)[0]),n(this,J)[1]=Math.max(n(this,J)[1],n(this,tt)[1]),n(this,J)[2]=Math.min(n(this,J)[2],n(this,tt)[2]),n(this,J)[3]=Math.min(n(this,J)[3],n(this,tt)[3])),n(this,me).clear(),this}_takePendingDependencies(){const t=n(this,me);return p(this,me,new Set),t}_extractOperation(t){const e=n(this,Ki).get(t);return n(this,Ki).delete(t),e}_pushPendingDependencies(t){for(const e of t)n(this,me).add(e)}take(){return n(this,so).clear(),Array.from(n(this,Ki),([t,{bbox:e,pairs:s,dependencies:i}])=>(s.forEach(r=>r.forEach(i.add,i)),i.delete(t),{minX:((e==null?void 0:e.minX)??0)/n(this,Qi),maxX:((e==null?void 0:e.maxX)??n(this,Qi))/n(this,Qi),minY:((e==null?void 0:e.minY)??0)/n(this,Ji),maxY:((e==null?void 0:e.maxY)??n(this,Ji))/n(this,Ji),dependencies:Array.from(i).sort((r,a)=>r-a),idx:t}))}}ge=new WeakMap,Zt=new WeakMap,to=new WeakMap,ws=new WeakMap,eo=new WeakMap,ei=new WeakMap,J=new WeakMap,tt=new WeakMap,si=new WeakMap,me=new WeakMap,Ki=new WeakMap,so=new WeakMap,Qi=new WeakMap,Ji=new WeakMap;var K,ct,io,Zi,no;const Qg=class Qg{constructor(t,e){d(this,K,void 0);d(this,ct,void 0);d(this,io,0);d(this,Zi,void 0);d(this,no,0);if(t instanceof Qg)return t;p(this,K,t),p(this,Zi,t._takePendingDependencies()),p(this,ct,e)}save(t){return St(this,no)._++,n(this,K).save(n(this,ct)),this}restore(t){return n(this,no)>0&&(n(this,K).restore(n(this,ct)),St(this,no)._--),this}recordOpenMarker(t){return St(this,io)._++,this}getOpenMarker(){return n(this,io)>0?n(this,ct):n(this,K).getOpenMarker()}recordCloseMarker(t){return St(this,io)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return n(this,K).pushBaseTransform(t),this}popBaseTransform(){return n(this,K).popBaseTransform(),this}recordSimpleData(t,e){return n(this,K).recordSimpleData(t,n(this,ct)),this}recordIncrementalData(t,e){return n(this,K).recordIncrementalData(t,n(this,ct)),this}resetIncrementalData(t,e){return n(this,K).resetIncrementalData(t,n(this,ct)),this}recordNamedData(t,e){return this}recordFutureForcedDependency(t,e){return n(this,K).recordFutureForcedDependency(t,n(this,ct)),this}inheritSimpleDataAsFutureForcedDependencies(t){return n(this,K).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return n(this,K).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return n(this,K).hasPendingBBox||n(this,K).resetBBox(n(this,ct)),this}get hasPendingBBox(){return n(this,K).hasPendingBBox}recordClipBox(t,e,s,i,r,a){return n(this,K).recordClipBox(n(this,ct),e,s,i,r,a),this}recordBBox(t,e,s,i,r,a){return n(this,K).recordBBox(n(this,ct),e,s,i,r,a),this}recordCharacterBBox(t,e,s,i,r,a,o){return n(this,K).recordCharacterBBox(n(this,ct),e,s,i,r,a,o),this}recordFullPageBBox(t){return n(this,K).recordFullPageBBox(n(this,ct)),this}getSimpleIndex(t){return n(this,K).getSimpleIndex(t)}recordDependencies(t,e){return n(this,K).recordDependencies(n(this,ct),e),this}copyDependenciesFromIncrementalOperation(t,e){return n(this,K).copyDependenciesFromIncrementalOperation(n(this,ct),e),this}recordNamedDependency(t,e){return n(this,K).recordNamedDependency(n(this,ct),e),this}recordOperation(t){n(this,K).recordOperation(n(this,ct),!0);const e=n(this,K)._extractOperation(n(this,ct));for(const s of e.dependencies)n(this,Zi).add(s);return n(this,Zi).delete(n(this,ct)),n(this,Zi).delete(null),this}bboxToClipBoxDropOperation(t){return n(this,K).bboxToClipBoxDropOperation(n(this,ct)),this}recordNestedDependencies(){n(this,K)._pushPendingDependencies(n(this,Zi))}take(){throw new Error("Unreachable")}};K=new WeakMap,ct=new WeakMap,io=new WeakMap,Zi=new WeakMap,no=new WeakMap;let tu=Qg;const Le={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation"],transform:["transform"],transformAndFill:["transform","fillColor"]},Vt={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Vp(u,t){if(!t)return;const e=t[2]-t[0],s=t[3]-t[1],i=new Path2D;i.rect(t[0],t[1],e,s),u.clip(i)}class jg{isModifyingCurrentTransform(){return!1}getPattern(){st("Abstract method `getPattern` called.")}}class vy extends jg{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;this._type==="axial"?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):this._type==="radial"&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let r;if(i===Vt.STROKE||i===Vt.FILL){const a=e.current.getClippedPathBoundingBox(i,dt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,h=e.cachedCanvases.getCanvas("pattern",o,l),c=h.context;c.clearRect(0,0,c.canvas.width,c.canvas.height),c.beginPath(),c.rect(0,0,c.canvas.width,c.canvas.height),c.translate(-a[0],-a[1]),s=I.transform(s,[1,0,0,1,a[0],a[1]]),c.transform(...e.baseTransform),this.matrix&&c.transform(...this.matrix),Vp(c,this._bbox),c.fillStyle=this._createGradient(c),c.fill(),r=t.createPattern(h.canvas,"no-repeat");const f=new DOMMatrix(s);r.setTransform(f)}else Vp(t,this._bbox),r=this._createGradient(t);return r}}function mp(u,t,e,s,i,r,a,o){const l=t.coords,h=t.colors,c=u.data,f=u.width*4;let g;l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=r,r=a,a=g),l[s+1]>l[i+1]&&(g=s,s=i,i=g,g=a,a=o,o=g),l[e+1]>l[s+1]&&(g=e,e=s,s=g,g=r,r=a,a=g);const m=(l[e]+t.offsetX)*t.scaleX,A=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,v=(l[s+1]+t.offsetY)*t.scaleY,w=(l[i]+t.offsetX)*t.scaleX,S=(l[i+1]+t.offsetY)*t.scaleY;if(A>=S)return;const _=h[r],E=h[r+1],C=h[r+2],T=h[a],x=h[a+1],P=h[a+2],M=h[o],D=h[o+1],R=h[o+2],H=Math.round(A),U=Math.round(S);let W,Y,B,N,Pt,At,Re,as;for(let it=H;it<=U;it++){if(it<v){const pt=it<A?0:(A-it)/(A-v);W=m-(m-y)*pt,Y=_-(_-T)*pt,B=E-(E-x)*pt,N=C-(C-P)*pt}else{let pt;it>S?pt=1:v===S?pt=0:pt=(v-it)/(v-S),W=y-(y-w)*pt,Y=T-(T-M)*pt,B=x-(x-D)*pt,N=P-(P-R)*pt}let Z;it<A?Z=0:it>S?Z=1:Z=(A-it)/(A-S),Pt=m-(m-w)*Z,At=_-(_-M)*Z,Re=E-(E-D)*Z,as=C-(C-R)*Z;const Ls=Math.round(Math.min(W,Pt)),Ve=Math.round(Math.max(W,Pt));let We=f*it+Ls*4;for(let pt=Ls;pt<=Ve;pt++)Z=(W-pt)/(W-Pt),Z<0?Z=0:Z>1&&(Z=1),c[We++]=Y-(Y-At)*Z|0,c[We++]=B-(B-Re)*Z|0,c[We++]=N-(N-as)*Z|0,c[We++]=255}}function _y(u,t,e){const s=t.coords,i=t.colors;let r,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(r=0;r<l;r++){let c=r*o;for(let f=0;f<h;f++,c++)mp(u,e,s[c],s[c+1],s[c+o],i[c],i[c+1],i[c+o]),mp(u,e,s[c+o+1],s[c+1],s[c+o],i[c+o+1],i[c+1],i[c+o])}break;case"triangles":for(r=0,a=s.length;r<a;r+=3)mp(u,e,s[r],s[r+1],s[r+2],i[r],i[r+1],i[r+2]);break;default:throw new Error("illegal figure")}}class Sy extends jg{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,s){const o=Math.floor(this._bounds[0]),l=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-o,c=Math.ceil(this._bounds[3])-l,f=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),g=Math.min(Math.ceil(Math.abs(c*t[1]*1.1)),3e3),m=h/f,A=c/g,y={coords:this._coords,colors:this._colors,offsetX:-o,offsetY:-l,scaleX:1/m,scaleY:1/A},v=f+2*2,w=g+2*2,S=s.getCanvas("mesh",v,w),_=S.context,E=_.createImageData(f,g);if(e){const T=E.data;for(let x=0,P=T.length;x<P;x+=4)T[x]=e[0],T[x+1]=e[1],T[x+2]=e[2],T[x+3]=255}for(const T of this._figures)_y(E,T,y);return _.putImageData(E,2,2),{canvas:S.canvas,offsetX:o-2*m,offsetY:l-2*A,scaleX:m,scaleY:A}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){Vp(t,this._bbox);const r=new Float32Array(2);if(i===Vt.SHADING)I.singularValueDecompose2dScale(dt(t),r);else if(this.matrix){I.singularValueDecompose2dScale(this.matrix,r);const[o,l]=r;I.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=o,r[1]*=l}else I.singularValueDecompose2dScale(e.baseTransform,r);const a=this._createMeshCanvas(r,i===Vt.SHADING?null:this._background,e.cachedCanvases);return i!==Vt.SHADING&&(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 Ey extends jg{getPattern(){return"hotpink"}}function Cy(u){switch(u[0]){case"RadialAxial":return new vy(u);case"Mesh":return new Sy(u);case"Dummy":return new Ey}throw new Error(`Unknown IR type: ${u[0]}`)}const cm={COLORED:1,UNCOLORED:2},Vu=class Vu{constructor(t,e,s,i){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=s,this.baseTransform=i}createPatternCanvas(t){var Pt,At,Re,as;const{bbox:e,operatorList:s,paintType:i,tilingType:r,color:a,canvasGraphicsFactory:o}=this;let{xstep:l,ystep:h}=this;l=Math.abs(l),h=Math.abs(h),ip("TilingType: "+r);const c=e[0],f=e[1],g=e[2],m=e[3],A=g-c,y=m-f,v=new Float32Array(2);I.singularValueDecompose2dScale(this.matrix,v);const[w,S]=v;I.singularValueDecompose2dScale(this.baseTransform,v);const _=w*v[0],E=S*v[1];let C=A,T=y,x=!1,P=!1;const M=Math.ceil(l*_),D=Math.ceil(h*E),R=Math.ceil(A*_),H=Math.ceil(y*E);M>=R?C=l:x=!0,D>=H?T=h:P=!0;const U=this.getSizeAndScale(C,this.ctx.canvas.width,_),W=this.getSizeAndScale(T,this.ctx.canvas.height,E),Y=t.cachedCanvases.getCanvas("pattern",U.size,W.size),B=Y.context,N=o.createCanvasGraphics(B);if(N.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(N,i,a),B.translate(-U.scale*c,-W.scale*f),N.transform(0,U.scale,0,0,W.scale,0,0),B.save(),(Pt=N.dependencyTracker)==null||Pt.save(),this.clipBbox(N,c,f,g,m),N.baseTransform=dt(N.ctx),N.executeOperatorList(s),N.endDrawing(),(as=(At=N.dependencyTracker)==null?void 0:(Re=At.restore()).recordNestedDependencies)==null||as.call(Re),B.restore(),x||P){const it=Y.canvas;x&&(C=l),P&&(T=h);const Z=this.getSizeAndScale(C,this.ctx.canvas.width,_),Ls=this.getSizeAndScale(T,this.ctx.canvas.height,E),Ve=Z.size,We=Ls.size,pt=t.cachedCanvases.getCanvas("pattern-workaround",Ve,We),lp=pt.context,hp=x?Math.floor(A/l):0,cp=P?Math.floor(y/h):0;for(let Mn=0;Mn<=hp;Mn++)for(let Rn=0;Rn<=cp;Rn++)lp.drawImage(it,Ve*Mn,We*Rn,Ve,We,0,0,Ve,We);return{canvas:pt.canvas,scaleX:Z.scale,scaleY:Ls.scale,offsetX:c,offsetY:f}}return{canvas:Y.canvas,scaleX:U.scale,scaleY:W.scale,offsetX:c,offsetY:f}}getSizeAndScale(t,e,s){const i=Math.max(Vu.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*s);return r>=i?r=i:s=r/t,{scale:s,size:r}}clipBbox(t,e,s,i,r){const a=i-e,o=r-s;t.ctx.rect(e,s,a,o),I.axialAlignedBoundingBox([e,s,i,r],dt(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,r=t.current;switch(e){case cm.COLORED:const{fillStyle:a,strokeStyle:o}=this.ctx;i.fillStyle=r.fillColor=a,i.strokeStyle=r.strokeColor=o;break;case cm.UNCOLORED:i.fillStyle=i.strokeStyle=s,r.fillColor=r.strokeColor=s;break;default:throw new UA(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i){let r=s;i!==Vt.SHADING&&(r=I.transform(r,e.baseTransform),this.matrix&&(r=I.transform(r,this.matrix)));const a=this.createPatternCanvas(e);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}};k(Vu,"MAX_PATTERN_SIZE",3e3);let Wp=Vu;function Ty({src:u,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:r=4294967295,inverseDecode:a=!1}){const o=Wt.isLittleEndian?4278190080:255,[l,h]=a?[r,o]:[o,r],c=s>>3,f=s&7,g=u.length;e=new Uint32Array(e.buffer);let m=0;for(let A=0;A<i;A++){for(const v=t+c;t<v;t++){const w=t<g?u[t]:255;e[m++]=w&128?h:l,e[m++]=w&64?h:l,e[m++]=w&32?h:l,e[m++]=w&16?h:l,e[m++]=w&8?h:l,e[m++]=w&4?h:l,e[m++]=w&2?h:l,e[m++]=w&1?h:l}if(f===0)continue;const y=t<g?u[t++]:255;for(let v=0;v<f;v++)e[m++]=y&1<<7-v?h:l}return{srcPos:t,destPos:m}}const dm=16,um=100,xy=15,fm=10,ce=16,bp=new DOMMatrix,Me=new Float32Array(2),ya=new Float32Array([1/0,1/0,-1/0,-1/0]);function ky(u,t){if(u._removeMirroring)throw new Error("Context is already forwarding operations.");u.__originalSave=u.save,u.__originalRestore=u.restore,u.__originalRotate=u.rotate,u.__originalScale=u.scale,u.__originalTranslate=u.translate,u.__originalTransform=u.transform,u.__originalSetTransform=u.setTransform,u.__originalResetTransform=u.resetTransform,u.__originalClip=u.clip,u.__originalMoveTo=u.moveTo,u.__originalLineTo=u.lineTo,u.__originalBezierCurveTo=u.bezierCurveTo,u.__originalRect=u.rect,u.__originalClosePath=u.closePath,u.__originalBeginPath=u.beginPath,u._removeMirroring=()=>{u.save=u.__originalSave,u.restore=u.__originalRestore,u.rotate=u.__originalRotate,u.scale=u.__originalScale,u.translate=u.__originalTranslate,u.transform=u.__originalTransform,u.setTransform=u.__originalSetTransform,u.resetTransform=u.__originalResetTransform,u.clip=u.__originalClip,u.moveTo=u.__originalMoveTo,u.lineTo=u.__originalLineTo,u.bezierCurveTo=u.__originalBezierCurveTo,u.rect=u.__originalRect,u.closePath=u.__originalClosePath,u.beginPath=u.__originalBeginPath,delete u._removeMirroring},u.save=function(){t.save(),this.__originalSave()},u.restore=function(){t.restore(),this.__originalRestore()},u.translate=function(e,s){t.translate(e,s),this.__originalTranslate(e,s)},u.scale=function(e,s){t.scale(e,s),this.__originalScale(e,s)},u.transform=function(e,s,i,r,a,o){t.transform(e,s,i,r,a,o),this.__originalTransform(e,s,i,r,a,o)},u.setTransform=function(e,s,i,r,a,o){t.setTransform(e,s,i,r,a,o),this.__originalSetTransform(e,s,i,r,a,o)},u.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},u.rotate=function(e){t.rotate(e),this.__originalRotate(e)},u.clip=function(e){t.clip(e),this.__originalClip(e)},u.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},u.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},u.bezierCurveTo=function(e,s,i,r,a,o){t.bezierCurveTo(e,s,i,r,a,o),this.__originalBezierCurveTo(e,s,i,r,a,o)},u.rect=function(e,s,i,r){t.rect(e,s,i,r),this.__originalRect(e,s,i,r)},u.closePath=function(){t.closePath(),this.__originalClosePath()},u.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Py{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return this.cache[t]!==void 0?(i=this.cache[t],this.canvasFactory.reset(i,e,s)):(i=this.canvasFactory.create(e,s),this.cache[t]=i),i}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 md(u,t,e,s,i,r,a,o,l,h){const[c,f,g,m,A,y]=dt(u);if(f===0&&g===0){const S=a*c+A,_=Math.round(S),E=o*m+y,C=Math.round(E),T=(a+l)*c+A,x=Math.abs(Math.round(T)-_)||1,P=(o+h)*m+y,M=Math.abs(Math.round(P)-C)||1;return u.setTransform(Math.sign(c),0,0,Math.sign(m),_,C),u.drawImage(t,e,s,i,r,0,0,x,M),u.setTransform(c,f,g,m,A,y),[x,M]}if(c===0&&m===0){const S=o*g+A,_=Math.round(S),E=a*f+y,C=Math.round(E),T=(o+h)*g+A,x=Math.abs(Math.round(T)-_)||1,P=(a+l)*f+y,M=Math.abs(Math.round(P)-C)||1;return u.setTransform(0,Math.sign(f),Math.sign(g),0,_,C),u.drawImage(t,e,s,i,r,0,0,M,x),u.setTransform(c,f,g,m,A,y),[M,x]}u.drawImage(t,e,s,i,r,a,o,l,h);const v=Math.hypot(c,f),w=Math.hypot(g,m);return[v*l,w*h]}class pm{constructor(t,e,s){k(this,"alphaIsShape",!1);k(this,"fontSize",0);k(this,"fontSizeScale",1);k(this,"textMatrix",null);k(this,"textMatrixScale",1);k(this,"fontMatrix",wp);k(this,"leading",0);k(this,"x",0);k(this,"y",0);k(this,"lineX",0);k(this,"lineY",0);k(this,"charSpacing",0);k(this,"wordSpacing",0);k(this,"textHScale",1);k(this,"textRenderingMode",Ot.FILL);k(this,"textRise",0);k(this,"fillColor","#000000");k(this,"strokeColor","#000000");k(this,"patternFill",!1);k(this,"patternStroke",!1);k(this,"fillAlpha",1);k(this,"strokeAlpha",1);k(this,"lineWidth",1);k(this,"activeSMask",null);k(this,"transferMaps","none");s==null||s(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=ya.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=Vt.FILL,e=null){const s=this.minMax.slice();if(t===Vt.STROKE){e||st("Stroke bounding box must include transform."),I.singularValueDecompose2dScale(e,Me);const i=Me[0]*this.lineWidth/2,r=Me[1]*this.lineWidth/2;s[0]-=i,s[1]-=r,s[2]+=i,s[3]+=r}return s}updateClipFromPath(){const t=I.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(ya,0)}getClippedPathBoundingBox(t=Vt.FILL,e=null){return I.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function gm(u,t){if(t instanceof ImageData){u.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%ce,r=(e-i)/ce,a=i===0?r:r+1,o=u.createImageData(s,ce);let l=0,h;const c=t.data,f=o.data;let g,m,A,y;if(t.kind===wd.GRAYSCALE_1BPP){const v=c.byteLength,w=new Uint32Array(f.buffer,0,f.byteLength>>2),S=w.length,_=s+7>>3,E=4294967295,C=Wt.isLittleEndian?4278190080:255;for(g=0;g<a;g++){for(A=g<r?ce:i,h=0,m=0;m<A;m++){const T=v-l;let x=0;const P=T>_?s:T*8-7,M=P&-8;let D=0,R=0;for(;x<M;x+=8)R=c[l++],w[h++]=R&128?E:C,w[h++]=R&64?E:C,w[h++]=R&32?E:C,w[h++]=R&16?E:C,w[h++]=R&8?E:C,w[h++]=R&4?E:C,w[h++]=R&2?E:C,w[h++]=R&1?E:C;for(;x<P;x++)D===0&&(R=c[l++],D=128),w[h++]=R&D?E:C,D>>=1}for(;h<S;)w[h++]=0;u.putImageData(o,0,g*ce)}}else if(t.kind===wd.RGBA_32BPP){for(m=0,y=s*ce*4,g=0;g<r;g++)f.set(c.subarray(l,l+y)),l+=y,u.putImageData(o,0,m),m+=ce;g<a&&(y=s*i*4,f.set(c.subarray(l,l+y)),u.putImageData(o,0,m))}else if(t.kind===wd.RGB_24BPP)for(A=ce,y=s*A,g=0;g<a;g++){for(g>=r&&(A=i,y=s*A),h=0,m=y;m--;)f[h++]=c[l++],f[h++]=c[l++],f[h++]=c[l++],f[h++]=255;u.putImageData(o,0,g*ce)}else throw new Error(`bad image kind: ${t.kind}`)}function mm(u,t){if(t.bitmap){u.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%ce,r=(e-i)/ce,a=i===0?r:r+1,o=u.createImageData(s,ce);let l=0;const h=t.data,c=o.data;for(let f=0;f<a;f++){const g=f<r?ce:i;({srcPos:l}=Ty({src:h,srcPos:l,dest:c,width:s,height:g,nonBlackColor:0})),u.putImageData(o,0,f*ce)}}function dl(u,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const s of e)u[s]!==void 0&&(t[s]=u[s]);u.setLineDash!==void 0&&(t.setLineDash(u.getLineDash()),t.lineDashOffset=u.lineDashOffset)}function bd(u){u.strokeStyle=u.fillStyle="#000000",u.fillRule="nonzero",u.globalAlpha=1,u.lineWidth=1,u.lineCap="butt",u.lineJoin="miter",u.miterLimit=10,u.globalCompositeOperation="source-over",u.font="10px sans-serif",u.setLineDash!==void 0&&(u.setLineDash([]),u.lineDashOffset=0);const{filter:t}=u;t!=="none"&&t!==""&&(u.filter="none")}function bm(u,t){if(t)return!0;I.singularValueDecompose2dScale(u,Me);const e=Math.fround(Ds.pixelRatio*Pn.PDF_TO_CSS_UNITS);return Me[0]<=e&&Me[1]<=e}const My=["butt","round","square"],Ry=["miter","round","bevel"],Dy={},Am={};var Ph,Xp,Mh,qp,Rh,Yp;const Jg=class Jg{constructor(t,e,s,i,r,{optionalContentConfig:a,markedContentStack:o=null},l,h,c){d(this,Ph);d(this,Mh);d(this,Rh);this.ctx=t,this.current=new pm(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=r,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=o||[],this.optionalContentConfig=a,this.cachedCanvases=new Py(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=l,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=c??null}getObject(t,e,s=null){var i;return typeof e=="string"?((i=this.dependencyTracker)==null||i.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):s}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const r=this.ctx.canvas.width,a=this.ctx.canvas.height,o=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,r,a),this.ctx.fillStyle=o,s){const l=this.cachedCanvases.getCanvas("transparent",r,a);this.compositeCtx=this.ctx,this.transparentCanvas=l.canvas,this.ctx=l.context,this.ctx.save(),this.ctx.transform(...dt(this.compositeCtx))}this.ctx.save(),bd(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=dt(this.ctx)}executeOperatorList(t,e,s,i,r){var w;const a=t.argsArray,o=t.fnArray;let l=e||0;const h=a.length;if(h===l)return l;const c=h-l>fm&&typeof s=="function",f=c?Date.now()+xy:0;let g=0;const m=this.commonObjs,A=this.objs;let y,v;for(;;){if(i!==void 0&&l===i.nextBreakPoint)return i.breakIt(l,s),l;if(!r||r.has(l))if(y=o[l],v=a[l]??null,y!==Fl.dependency)v===null?this[y](l):this[y](l,...v);else for(const S of v){(w=this.dependencyTracker)==null||w.recordNamedData(S,l);const _=S.startsWith("g_")?m:A;if(!_.has(S))return _.get(S,s),l}if(l++,l===h)return l;if(c&&++g>fm){if(Date.now()>f)return s(),l;g=0}}}endDrawing(){b(this,Ph,Xp).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),b(this,Mh,qp).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),a=Math.max(Math.hypot(e[2],e[3]),1),o=s,l=i,h="prescale1",c,f;for(;r>2&&o>1||a>2&&l>1;){let g=o,m=l;r>2&&o>1&&(g=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),r/=o/g),a>2&&l>1&&(m=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/m),c=this.cachedCanvases.getCanvas(h,g,m),f=c.context,f.clearRect(0,0,g,m),f.drawImage(t,0,0,o,l,0,0,g,m),t=c.canvas,o=g,l=m,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t,e){var D,R;const s=this.ctx,{width:i,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,l=dt(s);let h,c,f,g;if((e.bitmap||e.data)&&e.count>1){const H=e.bitmap||e.data.buffer;c=JSON.stringify(o?l:[l.slice(0,4),a]),h=this._cachedBitmapsMap.get(H),h||(h=new Map,this._cachedBitmapsMap.set(H,h));const U=h.get(c);if(U&&!o){const W=Math.round(Math.min(l[0],l[2])+l[4]),Y=Math.round(Math.min(l[1],l[3])+l[5]);return(D=this.dependencyTracker)==null||D.recordDependencies(t,Le.transformAndFill),{canvas:U,offsetX:W,offsetY:Y}}f=U}f||(g=this.cachedCanvases.getCanvas("maskCanvas",i,r),mm(g.context,e));let m=I.transform(l,[1/i,0,0,-1/r,0,0]);m=I.transform(m,[1,0,0,1,0,-r]);const A=ya.slice();I.axialAlignedBoundingBox([0,0,i,r],m,A);const[y,v,w,S]=A,_=Math.round(w-y)||1,E=Math.round(S-v)||1,C=this.cachedCanvases.getCanvas("fillCanvas",_,E),T=C.context,x=y,P=v;T.translate(-x,-P),T.transform(...m),f||(f=this._scaleImage(g.canvas,os(T)),f=f.img,h&&o&&h.set(c,f)),T.imageSmoothingEnabled=bm(dt(T),e.interpolate),md(T,f,0,0,f.width,f.height,0,0,i,r),T.globalCompositeOperation="source-in";const M=I.transform(os(T),[1,0,0,1,-x,-P]);return T.fillStyle=o?a.getPattern(s,this,M,Vt.FILL):a,T.fillRect(0,0,i,r),h&&!o&&(this.cachedCanvases.delete("fillCanvas"),h.set(c,C.canvas)),(R=this.dependencyTracker)==null||R.recordDependencies(t,Le.transformAndFill),{canvas:C.canvas,offsetX:Math.round(x),offsetY:Math.round(P)}}setLineWidth(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineCap",t),this.ctx.lineCap=My[e]}setLineJoin(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("lineJoin",t),this.ctx.lineJoin=Ry[e]}setMiterLimit(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,s){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const i=this.ctx;i.setLineDash!==void 0&&(i.setLineDash(e),i.lineDashOffset=s)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var s,i,r,a,o;for(const[l,h]of e)switch(l){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(s=this.dependencyTracker)==null||s.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(i=this.dependencyTracker)==null||i.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(a=this.dependencyTracker)==null||a.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(o=this.dependencyTracker)==null||o.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}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,s=this.ctx.canvas.height,i="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(i,e,s);this.suspendedCtx=this.ctx;const a=this.ctx=r.context;a.setTransform(this.suspendedCtx.getTransform()),dl(this.suspendedCtx,a),ky(a,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(),dl(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,s=this.suspendedCtx;this.composeSMask(s,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,s,i){const r=i[0],a=i[1],o=i[2]-r,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,r,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,r,a,o,l,h,c,f){let g=t.canvas,m=l-c,A=h-f;if(a)if(m<0||A<0||m+s>g.width||A+i>g.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),w=v.context;w.drawImage(g,-m,-A),w.globalCompositeOperation="destination-atop",w.fillStyle=a,w.fillRect(0,0,s,i),w.globalCompositeOperation="source-over",g=v.canvas,m=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(m,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(m,A,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(o));const y=new Path2D;y.rect(l,h,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(g,m,A,s,i,l,h,s,i),e.restore()}save(t){var s;this.inSMaskMode&&dl(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(s=this.dependencyTracker)==null||s.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&dl(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,s,i,r,a,o){var l;(l=this.dependencyTracker)==null||l.recordIncrementalData("transform",t),this.ctx.transform(e,s,i,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s,i){let[r]=s;if(!i){r||(r=s[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const a=e===Fl.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,i[0]-a,i[2]+a,i[1]-a,i[3]+a).recordDependencies(t,["transform"])}if(!(r instanceof Path2D)){const a=s[0]=new Path2D;for(let o=0,l=r.length;o<l;)switch(r[o++]){case ud.moveTo:a.moveTo(r[o++],r[o++]);break;case ud.lineTo:a.lineTo(r[o++],r[o++]);break;case ud.curveTo:a.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);break;case ud.closePath:a.closePath();break;default:z(`Unrecognized drawing path operator: ${r[o-1]}`);break}r=a}I.axialAlignedBoundingBox(i,dt(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,s=!0){var a;const i=this.ctx,r=this.current.strokeColor;if(i.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const o=r.isModifyingCurrentTransform()?i.getTransform():null;if(i.save(),i.strokeStyle=r.getPattern(i,this,os(i),Vt.STROKE),o){const l=new Path2D;l.addPath(e,i.getTransform().invertSelf().multiplySelf(o)),e=l}this.rescaleAndStroke(e,!1),i.restore()}else this.rescaleAndStroke(e,!0);(a=this.dependencyTracker)==null||a.recordDependencies(t,Le.stroke),s&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(Vt.STROKE,dt(this.ctx))),i.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,s=!0){var h,c,f;const i=this.ctx,r=this.current.fillColor,a=this.current.patternFill;let o=!1;if(a){const g=r.isModifyingCurrentTransform()?i.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),i.save(),i.fillStyle=r.getPattern(i,this,os(i),Vt.FILL),g){const m=new Path2D;m.addPath(e,i.getTransform().invertSelf().multiplySelf(g)),e=m}o=!0}const l=this.current.getClippedPathBoundingBox();this.contentVisible&&l!==null&&(this.pendingEOFill?(i.fill(e,"evenodd"),this.pendingEOFill=!1):i.fill(e)),(c=this.dependencyTracker)==null||c.recordDependencies(t,Le.fill),o&&(i.restore(),(f=this.dependencyTracker)==null||f.restore(t)),s&&this.consumePath(t,e,l)}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){var s;this.ctx.fill(e),(s=this.dependencyTracker)==null||s.recordDependencies(t,Le.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Dy}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=Am}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,s=this.ctx;if(this.dependencyTracker){const{dependencyTracker:i}=this;e!==void 0&&i.recordFutureForcedDependency("textClip",i.getOpenMarker()).recordFutureForcedDependency("textClip",t),i.recordCloseMarker(t)}if(e!==void 0){const i=new Path2D,r=s.getTransform().invertSelf();for(const{transform:a,x:o,y:l,fontSize:h,path:c}of e)c&&i.addPath(c,new DOMMatrix(a).preMultiplySelf(r).translate(o,l).scale(h,-h));s.clip(i)}delete this.pendingTextPaths}setCharSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,s){var f,g;(f=this.dependencyTracker)==null||f.recordSimpleData("font",t).recordNamedDependency(t,e);const i=this.commonObjs.get(e),r=this.current;if(!i)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=i.fontMatrix||wp,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&z("Invalid font matrix for font "+e),s<0?(s=-s,r.fontDirection=-1):r.fontDirection=1,this.current.font=i,this.current.fontSize=s,i.isType3Font)return;const a=i.loadedName||"sans-serif",o=((g=i.systemFontInfo)==null?void 0:g.css)||`"${a}", ${i.fallbackName}`;let l="normal";i.black?l="900":i.bold&&(l="bold");const h=i.italic?"italic":"normal";let c=s;s<dm?c=dm:s>um&&(c=um),this.current.fontSizeScale=s/c,this.ctx.font=`${h} ${l} ${c}px ${o}`}setTextRenderingMode(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,s){var i;(i=this.dependencyTracker)==null||i.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=s}setLeadingMoveText(t,e,s){this.setLeading(t,-s),this.moveText(t,e,s)}setTextMatrix(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textMatrix",t);const{current:s}=this;s.textMatrix=e,s.textMatrixScale=Math.hypot(e[0],e[1]),s.x=s.lineX=0,s.y=s.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,s,i,r,a){var w,S,_,E;const o=this.ctx,l=this.current,h=l.font,c=l.textRenderingMode,f=l.fontSize/l.fontSizeScale,g=c&Ot.FILL_STROKE_MASK,m=!!(c&Ot.ADD_TO_PATH_FLAG),A=l.patternFill&&!h.missingFile,y=l.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||m||A||y)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||A||y)){o.save(),o.translate(s,i),o.scale(f,-f),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,o,h);let C;if(g===Ot.FILL||g===Ot.FILL_STROKE)if(r){C=o.getTransform(),o.setTransform(...r);const T=b(this,Rh,Yp).call(this,v,C,r);o.fill(T)}else o.fill(v);if(g===Ot.STROKE||g===Ot.FILL_STROKE)if(a){C||(C=o.getTransform()),o.setTransform(...a);const{a:T,b:x,c:P,d:M}=C,D=I.inverseTransform(a),R=I.transform([T,x,P,M,0,0],D);I.singularValueDecompose2dScale(R,Me),o.lineWidth*=Math.max(Me[0],Me[1])/f,o.stroke(b(this,Rh,Yp).call(this,v,C,a))}else o.lineWidth/=f,o.stroke(v);o.restore()}else(g===Ot.FILL||g===Ot.FILL_STROKE)&&(o.fillText(e,s,i),(S=this.dependencyTracker)==null||S.recordCharacterBBox(t,o,h,f,s,i,()=>o.measureText(e))),(g===Ot.STROKE||g===Ot.FILL_STROKE)&&(this.dependencyTracker&&((_=this.dependencyTracker)==null||_.recordCharacterBBox(t,o,h,f,s,i,()=>o.measureText(e)).recordDependencies(t,Le.stroke)),o.strokeText(e,s,i));m&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:dt(o),x:s,y:i,fontSize:f,path:v}),(E=this.dependencyTracker)==null||E.recordCharacterBBox(t,o,h,f,s,i))}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 s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return V(this,"isFontSubpixelAAEnabled",s)}showText(t,e){var P,M,D,R;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Le.showText).copyDependenciesFromIncrementalOperation(t,"sameLineText").resetBBox(t),this.current.textRenderingMode&Ot.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const s=this.current,i=s.font;if(i.isType3Font){this.showType3Text(t,e),(P=this.dependencyTracker)==null||P.recordOperation(t).recordIncrementalData("sameLineText",t);return}const r=s.fontSize;if(r===0){(M=this.dependencyTracker)==null||M.recordOperation(t);return}const a=this.ctx,o=s.fontSizeScale,l=s.charSpacing,h=s.wordSpacing,c=s.fontDirection,f=s.textHScale*c,g=e.length,m=i.vertical,A=m?1:-1,y=i.defaultVMetrics,v=r*s.fontMatrix[0],w=s.textRenderingMode===Ot.FILL&&!i.disableFontFace&&!s.patternFill;a.save(),s.textMatrix&&a.transform(...s.textMatrix),a.translate(s.x,s.y+s.textRise),c>0?a.scale(f,-1):a.scale(f,1);let S,_;if(s.patternFill){a.save();const H=s.fillColor.getPattern(a,this,os(a),Vt.FILL);S=dt(a),a.restore(),a.fillStyle=H}if(s.patternStroke){a.save();const H=s.strokeColor.getPattern(a,this,os(a),Vt.STROKE);_=dt(a),a.restore(),a.strokeStyle=H}let E=s.lineWidth;const C=s.textMatrixScale;if(C===0||E===0){const H=s.textRenderingMode&Ot.FILL_STROKE_MASK;(H===Ot.STROKE||H===Ot.FILL_STROKE)&&(E=this.getSinglePixelWidth())}else E/=C;if(o!==1&&(a.scale(o,o),E/=o),a.lineWidth=E,i.isInvalidPDFjsFont){const H=[];let U=0;for(const Y of e)H.push(Y.unicode),U+=Y.width;const W=H.join("");if(a.fillText(W,0,0),this.dependencyTracker!==null){const Y=a.measureText(W);this.dependencyTracker.recordBBox(t,this.ctx,-Y.actualBoundingBoxLeft,Y.actualBoundingBoxRight,-Y.actualBoundingBoxAscent,Y.actualBoundingBoxDescent).recordOperation(t).recordIncrementalData("sameLineText",t)}s.x+=U*v*f,a.restore(),this.compose();return}let T=0,x;for(x=0;x<g;++x){const H=e[x];if(typeof H=="number"){T+=A*H*r/1e3;continue}let U=!1;const W=(H.isSpace?h:0)+l,Y=H.fontChar,B=H.accent;let N,Pt,At=H.width;if(m){const it=H.vmetric||y,Z=-(H.vmetric?it[1]:At*.5)*v,Ls=it[2]*v;At=it?-it[0]:At,N=Z/o,Pt=(T+Ls)/o}else N=T/o,Pt=0;let Re;if(i.remeasure&&At>0){Re=a.measureText(Y);const it=Re.width*1e3/r*o;if(At<it&&this.isFontSubpixelAAEnabled){const Z=At/it;U=!0,a.save(),a.scale(Z,1),N/=Z}else At!==it&&(N+=(At-it)/2e3*r/o)}if(this.contentVisible&&(H.isInFont||i.missingFile)){if(w&&!B)a.fillText(Y,N,Pt),(D=this.dependencyTracker)==null||D.recordCharacterBBox(t,a,Re?{bbox:null}:i,r/o,N,Pt,()=>Re??a.measureText(Y));else if(this.paintChar(t,Y,N,Pt,S,_),B){const it=N+r*B.offset.x/o,Z=Pt-r*B.offset.y/o;this.paintChar(t,B.fontChar,it,Z,S,_)}}const as=m?At*v-W*c:At*v+W*c;T+=as,U&&a.restore()}m?s.y-=T:s.x+=T*f,a.restore(),this.compose(),(R=this.dependencyTracker)==null||R.recordOperation(t).recordIncrementalData("sameLineText",t)}showType3Text(t,e){const s=this.ctx,i=this.current,r=i.font,a=i.fontSize,o=i.fontDirection,l=r.vertical?1:-1,h=i.charSpacing,c=i.wordSpacing,f=i.textHScale*o,g=i.fontMatrix||wp,m=e.length,A=i.textRenderingMode===Ot.INVISIBLE;let y,v,w,S;if(A||a===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,s.save(),i.textMatrix&&s.transform(...i.textMatrix),s.translate(i.x,i.y+i.textRise),s.scale(f,o);const _=this.dependencyTracker;for(this.dependencyTracker=_?new tu(_,t):null,y=0;y<m;++y){if(v=e[y],typeof v=="number"){S=l*v*a/1e3,this.ctx.translate(S,0),i.x+=S*f;continue}const E=(v.isSpace?c:0)+h,C=r.charProcOperatorList[v.operatorListId];C?this.contentVisible&&(this.save(),s.scale(a,a),s.transform(...g),this.executeOperatorList(C),this.restore()):z(`Type3 character "${v.operatorListId}" is not available.`);const T=[v.width,0];I.applyTransform(T,g),w=T[0]*a+E,s.translate(w,0),i.x+=w*f}s.restore(),_&&(this.dependencyTracker.recordNestedDependencies(),this.dependencyTracker=_)}setCharWidth(t,e,s){}setCharWidthAndBounds(t,e,s,i,r,a,o){var h;const l=new Path2D;l.rect(i,r,a-i,o-r),this.ctx.clip(l),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,i,a,r,o).recordClipBox(t,this.ctx,i,a,r,o),this.endPath(t)}getColorN_Pattern(t,e){let s;if(e[0]==="TilingPattern"){const i=this.baseTransform||dt(this.ctx),r={createCanvasGraphics:a=>new Jg(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new tu(this.dependencyTracker,t):null)};s=new Wp(e,this.ctx,r,i)}else s=this._getPattern(t,e[1],e[2]);return s}setStrokeColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var s;(s=this.dependencyTracker)==null||s.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,s=null){let i;return this.cachedPatterns.has(e)?i=this.cachedPatterns.get(e):(i=Cy(this.getObject(t,e)),this.cachedPatterns.set(e,i)),s&&(i.matrix=s),i}shadingFill(t,e){var a;if(!this.contentVisible)return;const s=this.ctx;this.save(t);const i=this._getPattern(t,e);s.fillStyle=i.getPattern(s,this,os(s),Vt.SHADING);const r=os(s);if(r){const{width:o,height:l}=s.canvas,h=ya.slice();I.axialAlignedBoundingBox([0,0,o,l],r,h);const[c,f,g,m]=h;this.ctx.fillRect(c,f,g-c,m-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(a=this.dependencyTracker)==null||a.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Le.transform).recordDependencies(t,Le.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){st("Should not call beginInlineImage")}beginImageData(){st("Should not call beginImageData")}paintFormXObjectBegin(t,e,s){var i;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=dt(this.ctx),s)){I.axialAlignedBoundingBox(s,this.baseTransform,this.current.minMax);const[r,a,o,l]=s,h=new Path2D;h.rect(r,a,o-r,l-a),this.ctx.clip(h),(i=this.dependencyTracker)==null||i.recordClipBox(t,this.ctx,r,o,a,l),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var _;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const s=this.ctx;e.isolated||ip("TODO: Support non-isolated groups."),e.knockout&&z("Knockout groups not supported.");const i=dt(s);if(e.matrix&&s.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=ya.slice();I.axialAlignedBoundingBox(e.bbox,dt(s),r);const a=[0,0,s.canvas.width,s.canvas.height];r=I.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),l=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-o,1),c=Math.max(Math.ceil(r[3])-l,1);this.current.startNewPathAndClipBox([0,0,h,c]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);const g=this.cachedCanvases.getCanvas(f,h,c),m=g.context;m.translate(-o,-l),m.transform(...i);let A=new Path2D;const[y,v,w,S]=e.bbox;if(A.rect(y,v,w-y,S-v),e.matrix){const E=new Path2D;E.addPath(A,new DOMMatrix(e.matrix)),A=E}m.clip(A),e.smask&&this.smaskStack.push({canvas:g.canvas,context:m,offsetX:o,offsetY:l,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(s.setTransform(1,0,0,1,0,0),s.translate(o,l),s.save()),dl(s,m),this.ctx=m,(_=this.dependencyTracker)==null||_.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(s),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(s),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const s=this.ctx,i=this.groupStack.pop();if(this.ctx=i,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const a=dt(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...a);const o=ya.slice();I.axialAlignedBoundingBox([0,0,s.canvas.width,s.canvas.height],a,o),this.ctx.drawImage(s.canvas,0,0),this.ctx.restore(),this.compose(o)}}beginAnnotation(t,e,s,i,r,a){if(b(this,Ph,Xp).call(this),bd(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),s){const o=s[2]-s[0],l=s[3]-s[1];if(a&&this.annotationCanvasMap){i=i.slice(),i[4]-=s[0],i[5]-=s[1],s=s.slice(),s[0]=s[1]=0,s[2]=o,s[3]=l,I.singularValueDecompose2dScale(dt(this.ctx),Me);const{viewportScale:h}=this,c=Math.ceil(o*this.outputScaleX*h),f=Math.ceil(l*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(c,f);const{canvas:g,context:m}=this.annotationCanvas;this.annotationCanvasMap.set(e,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=m,this.ctx.save(),this.ctx.setTransform(Me[0],0,0,-Me[1],0,l*Me[1]),bd(this.ctx)}else{bd(this.ctx),this.endPath(t);const h=new Path2D;h.rect(s[0],s[1],o,l),this.ctx.clip(h)}}this.current=new pm(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...i),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),b(this,Mh,qp).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var o;if(!this.contentVisible)return;const s=e.count;e=this.getObject(t,e.data,e),e.count=s;const i=this.ctx,r=this._createMaskCanvas(t,e),a=r.canvas;i.save(),i.setTransform(1,0,0,1,0,0),i.drawImage(a,r.offsetX,r.offsetY),(o=this.dependencyTracker)==null||o.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+a.width,r.offsetY,r.offsetY+a.height).recordOperation(t),i.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s,i=0,r=0,a,o){var f,g,m;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const l=this.ctx;l.save();const h=dt(l);l.transform(s,i,r,a,0,0);const c=this._createMaskCanvas(t,e);l.setTransform(1,0,0,1,c.offsetX-h[4],c.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let A=0,y=o.length;A<y;A+=2){const v=I.transform(h,[s,i,r,a,o[A],o[A+1]]);l.drawImage(c.canvas,v[4],v[5]),(g=this.dependencyTracker)==null||g.recordBBox(t,this.ctx,v[4],v[4]+c.canvas.width,v[5],v[5]+c.canvas.height)}l.restore(),this.compose(),(m=this.dependencyTracker)==null||m.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var a,o,l;if(!this.contentVisible)return;const s=this.ctx,i=this.current.fillColor,r=this.current.patternFill;(a=this.dependencyTracker)==null||a.resetBBox(t).recordDependencies(t,Le.transformAndFill);for(const h of e){const{data:c,width:f,height:g,transform:m}=h,A=this.cachedCanvases.getCanvas("maskCanvas",f,g),y=A.context;y.save();const v=this.getObject(t,c,h);mm(y,v),y.globalCompositeOperation="source-in",y.fillStyle=r?i.getPattern(y,this,os(s),Vt.FILL):i,y.fillRect(0,0,f,g),y.restore(),s.save(),s.transform(...m),s.scale(1,-1),md(s,A.canvas,0,0,f,g,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,s,0,f,0,g),s.restore()}this.compose(),(l=this.dependencyTracker)==null||l.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const s=this.getObject(t,e);if(!s){z("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,s)}paintImageXObjectRepeat(t,e,s,i,r){if(!this.contentVisible)return;const a=this.getObject(t,e);if(!a){z("Dependent image isn't ready yet");return}const o=a.width,l=a.height,h=[];for(let c=0,f=r.length;c<f;c+=2)h.push({transform:[s,0,0,i,r[c],r[c+1]],x:0,y:0,w:o,h:l});this.paintInlineImageXObjectGroup(t,a,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:s,height:i}=t,r=this.cachedCanvases.getCanvas("inlineImage",s,i),a=r.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const s=e.width,i=e.height,r=this.ctx;this.save(t);const{filter:a}=r;a!=="none"&&a!==""&&(r.filter="none"),r.scale(1/s,-1/i);let o;if(e.bitmap)o=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)o=e;else{const f=this.cachedCanvases.getCanvas("inlineImage",s,i).context;gm(f,e),o=this.applyTransferMapsToCanvas(f)}const l=this._scaleImage(o,os(r));r.imageSmoothingEnabled=bm(dt(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,s,-i,0).recordDependencies(t,Le.imageXObject).recordOperation(t),md(r,l.img,0,0,l.paintWidth,l.paintHeight,0,-i,s,i),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,s){var a,o,l;if(!this.contentVisible)return;const i=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,c=e.height,g=this.cachedCanvases.getCanvas("inlineImage",h,c).context;gm(g,e),r=this.applyTransferMapsToCanvas(g)}(a=this.dependencyTracker)==null||a.resetBBox(t);for(const h of s)i.save(),i.transform(...h.transform),i.scale(1,-1),md(i,r,h.x,h.y,h.w,h.h,0,-1,1,1),(o=this.dependencyTracker)==null||o.recordBBox(t,i,0,1,-1,0),i.restore();(l=this.dependencyTracker)==null||l.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Le.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,s){}beginMarkedContent(t,e){var s;(s=this.dependencyTracker)==null||s.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,s){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(s)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,s){var a,o;const i=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(s);const r=this.ctx;this.pendingClip?(i||(this.pendingClip===Am?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(a=this.dependencyTracker)==null||a.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(o=this.dependencyTracker)==null||o.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=dt(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:r}=this.ctx.getTransform();let a,o;if(s===0&&i===0){const l=Math.abs(e),h=Math.abs(r);if(l===h)if(t===0)a=o=1/l;else{const c=l*t;a=o=c<1?1/c:1}else if(t===0)a=1/l,o=1/h;else{const c=l*t,f=h*t;a=c<1?1/c:1,o=f<1?1/f:1}}else{const l=Math.abs(e*r-s*i),h=Math.hypot(e,s),c=Math.hypot(i,r);if(t===0)a=c/l,o=h/l;else{const f=t*l;a=c>f?c/f:1,o=h>f?h/f:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[r,a]=this.getScaleForStroking();if(r===a){s.lineWidth=(i||1)*r,s.stroke(t);return}const o=s.getLineDash();e&&s.save(),s.scale(r,a),bp.a=1/r,bp.d=1/a;const l=new Path2D;if(l.addPath(t,bp),o.length>0){const h=Math.max(r,a);s.setLineDash(o.map(c=>c/h)),s.lineDashOffset/=h}s.lineWidth=i||1,s.stroke(l),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Ph=new WeakSet,Xp=function(){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)},Mh=new WeakSet,qp=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},Rh=new WeakSet,Yp=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let _a=Jg;for(const u in Fl)_a.prototype[u]!==void 0&&(_a.prototype[Fl[u]]=_a.prototype[u]);var Dh,Lh;class Ti{static get workerPort(){return n(this,Dh)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Dh,t)}static get workerSrc(){return n(this,Lh)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Lh,t)}}Dh=new WeakMap,Lh=new WeakMap,d(Ti,Dh,null),d(Ti,Lh,"");var ro,Ih;class Ly{constructor({parsedData:t,rawData:e}){d(this,ro,void 0);d(this,Ih,void 0);p(this,ro,t),p(this,Ih,e)}getRaw(){return n(this,Ih)}get(t){return n(this,ro).get(t)??null}[Symbol.iterator](){return n(this,ro).entries()}}ro=new WeakMap,Ih=new WeakMap;const ma=Symbol("INTERNAL");var Fh,Nh,Oh,ao;class Iy{constructor(t,{name:e,intent:s,usage:i,rbGroups:r}){d(this,Fh,!1);d(this,Nh,!1);d(this,Oh,!1);d(this,ao,!0);p(this,Fh,!!(t&Pe.DISPLAY)),p(this,Nh,!!(t&Pe.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=r}get visible(){if(n(this,Oh))return n(this,ao);if(!n(this,ao))return!1;const{print:t,view:e}=this.usage;return n(this,Fh)?(e==null?void 0:e.viewState)!=="OFF":n(this,Nh)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==ma&&st("Internal method `_setVisible` called."),p(this,Oh,s),p(this,ao,e)}}Fh=new WeakMap,Nh=new WeakMap,Oh=new WeakMap,ao=new WeakMap;var tn,et,oo,lo,Bh,Kp;class Fy{constructor(t,e=Pe.DISPLAY){d(this,Bh);d(this,tn,null);d(this,et,new Map);d(this,oo,null);d(this,lo,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,lo,t.order);for(const s of t.groups)n(this,et).set(s.id,new Iy(e,s));if(t.baseState==="OFF")for(const s of n(this,et).values())s._setVisible(ma,!1);for(const s of t.on)n(this,et).get(s)._setVisible(ma,!0);for(const s of t.off)n(this,et).get(s)._setVisible(ma,!1);p(this,oo,this.getHash())}}isVisible(t){if(n(this,et).size===0)return!0;if(!t)return ip("Optional content group not defined."),!0;if(t.type==="OCG")return n(this,et).has(t.id)?n(this,et).get(t.id).visible:(z(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return b(this,Bh,Kp).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!n(this,et).has(e))return z(`Optional content group not found: ${e}`),!0;if(n(this,et).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!n(this,et).has(e))return z(`Optional content group not found: ${e}`),!0;if(!n(this,et).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!n(this,et).has(e))return z(`Optional content group not found: ${e}`),!0;if(!n(this,et).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!n(this,et).has(e))return z(`Optional content group not found: ${e}`),!0;if(n(this,et).get(e).visible)return!1}return!0}return z(`Unknown optional content policy ${t.policy}.`),!0}return z(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var r;const i=n(this,et).get(t);if(!i){z(`Optional content group not found: ${t}`);return}if(s&&e&&i.rbGroups.length)for(const a of i.rbGroups)for(const o of a)o!==t&&((r=n(this,et).get(o))==null||r._setVisible(ma,!1,!0));i._setVisible(ma,!!e,!0),p(this,tn,null)}setOCGState({state:t,preserveRB:e}){let s;for(const i of t){switch(i){case"ON":case"OFF":case"Toggle":s=i;continue}const r=n(this,et).get(i);if(r)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!r.visible,e);break}}p(this,tn,null)}get hasInitialVisibility(){return n(this,oo)===null||this.getHash()===n(this,oo)}getOrder(){return n(this,et).size?n(this,lo)?n(this,lo).slice():[...n(this,et).keys()]:null}getGroup(t){return n(this,et).get(t)||null}getHash(){if(n(this,tn)!==null)return n(this,tn);const t=new rb;for(const[e,s]of n(this,et))t.update(`${e}:${s.visible}`);return p(this,tn,t.hexdigest())}[Symbol.iterator](){return n(this,et).entries()}}tn=new WeakMap,et=new WeakMap,oo=new WeakMap,lo=new WeakMap,Bh=new WeakSet,Kp=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const r=t[i];let a;if(Array.isArray(r))a=b(this,Bh,Kp).call(this,r);else if(n(this,et).has(r))a=n(this,et).get(r).visible;else return z(`Optional content group not found: ${r}`),!0;switch(s){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return s==="And"};class Ny{constructor(t,{disableRange:e=!1,disableStream:s=!1}){_t(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:r,progressiveDone:a,contentDispositionFilename:o}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=o,(r==null?void 0:r.length)>0){const l=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(l)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((l,h)=>{this._onReceiveData({begin:l,chunk:h})}),t.addProgressListener((l,h)=>{this._onProgress({loaded:l,total:h})}),t.addProgressiveReadListener(l=>{this._onReceiveData({chunk:l})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{const i=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(s),!0)});_t(i,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,s,i,r;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(r=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||r.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){_t(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Oy(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new By(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class Oy{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=zg(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class By{constructor(t,e,s){this._stream=t,this._begin=e,this._end=s,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Hy(u){let t=!0,e=s("filename\\*","i").exec(u);if(e){e=e[1];let c=o(e);return c=unescape(c),c=l(c),c=h(c),r(c)}if(e=a(u),e){const c=h(e);return r(c)}if(e=s("filename","i").exec(u),e){e=e[1];let c=o(e);return c=h(c),r(c)}function s(c,f){return new RegExp("(?:^|;)\\s*"+c+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function i(c,f){if(c){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const g=new TextDecoder(c,{fatal:!0}),m=ad(f);f=g.decode(m),t=!1}catch{}}return f}function r(c){return t&&/[\x80-\xff]/.test(c)&&(c=i("utf-8",c),t&&(c=i("iso-8859-1",c))),c}function a(c){const f=[];let g;const m=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(g=m.exec(c))!==null;){let[,y,v,w]=g;if(y=parseInt(y,10),y in f){if(y===0)break;continue}f[y]=[v,w]}const A=[];for(let y=0;y<f.length&&y in f;++y){let[v,w]=f[y];w=o(w),v&&(w=unescape(w),y===0&&(w=l(w))),A.push(w)}return A.join("")}function o(c){if(c.startsWith('"')){const f=c.slice(1).split('\\"');for(let g=0;g<f.length;++g){const m=f[g].indexOf('"');m!==-1&&(f[g]=f[g].slice(0,m),f.length=g+1),f[g]=f[g].replaceAll(/\\(.)/g,"$1")}c=f.join('"')}return c}function l(c){const f=c.indexOf("'");if(f===-1)return c;const g=c.slice(0,f),A=c.slice(f+1).replace(/^[^']*'/,"");return i(g,A)}function h(c){return!c.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(c)?c:c.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,g,m,A){if(m==="q"||m==="Q")return A=A.replaceAll("_"," "),A=A.replaceAll(/=([0-9a-fA-F]{2})/g,function(y,v){return String.fromCharCode(parseInt(v,16))}),i(g,A);try{A=atob(A)}catch{}return i(g,A)})}return""}function bb(u,t){const e=new Headers;if(!u||!t||typeof t!="object")return e;for(const s in t){const i=t[s];i!==void 0&&e.append(s,i)}return e}function ap(u){var t;return((t=URL.parse(u))==null?void 0:t.origin)??null}function Ab({responseHeaders:u,isHttp:t,rangeChunkSize:e,disableRange:s}){const i={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(u.get("Content-Length"),10);return!Number.isInteger(r)||(i.suggestedLength=r,r<=2*e)||s||!t||u.get("Accept-Ranges")!=="bytes"||(u.get("Content-Encoding")||"identity")!=="identity"||(i.allowRangeRequests=!0),i}function yb(u){const t=u.get("Content-Disposition");if(t){let e=Hy(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(zg(e))return e}return null}function cd(u,t){return new Kd(`Unexpected server response (${u}) while retrieving PDF "${t}".`,u,u===404||u===0&&t.startsWith("file:"))}function wb(u){return u===200||u===206}function vb(u,t,e){return{method:"GET",headers:u,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function _b(u){return u instanceof Uint8Array?u.buffer:u instanceof ArrayBuffer?u:(z(`getArrayBuffer - unexpected data format: ${u}`),new Uint8Array(u).buffer)}class $y{constructor(t){k(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=bb(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return _t(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new zy(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Gy(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class zy{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 s=new Headers(t.headers),i=e.url;fetch(i,vb(s,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=ap(r.url),!wb(r.status))throw cd(r.status,i);this._reader=r.body.getReader(),this._headersCapability.resolve();const a=r.headers,{allowRangeRequests:o,suggestedLength:l}=Ab({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=yb(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new kn("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(){var s;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:_b(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Gy{constructor(t,e,s){this._stream=t,this._reader=null,this._loaded=0;const i=t.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,vb(r,this._withCredentials,this._abortController)).then(o=>{const l=ap(o.url);if(l!==t._responseOrigin)throw new Error(`Expected range response-origin "${l}" to match "${t._responseOrigin}".`);if(!wb(o.status))throw cd(o.status,a);this._readCapability.resolve(),this._reader=o.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:_b(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Ap=200,yp=206;function Uy(u){const t=u.response;return typeof t!="string"?t:ad(t).buffer}class jy{constructor({url:t,httpHeaders:e,withCredentials:s}){k(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=bb(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,a]of this.headers)e.setRequestHeader(r,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=yp):i.expectedStatus=Ap,e.responseType="arraybuffer",_t(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var i;const s=this.pendingRequests[t];s&&((i=s.onProgress)==null||i.call(s,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),i.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],i.status===0&&this.isHttp){s.onError(i.status);return}const r=i.status||Ap;if(!(r===Ap&&s.expectedStatus===yp)&&r!==s.expectedStatus){s.onError(i.status);return}const o=Uy(i);if(r===yp){const l=i.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(l);h?s.onDone({begin:parseInt(h[1],10),chunk:o}):(z('Missing or invalid "Content-Range" header.'),s.onError(0))}else o?s.onDone({begin:0,chunk:o}):s.onError(i.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 Vy{constructor(t){this._source=t,this._manager=new jy(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 _t(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Wy(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Xy(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Wy{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=ap(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(o=>{const[l,...h]=o.split(": ");return[l,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:a}=Ab({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=yb(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=cd(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Xy{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,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(){var e;const t=ap((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=cd(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,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 e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const qy=/^[a-z][a-z0-9\-+.]+:/i;function Yy(u){if(qy.test(u))return new URL(u);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(u))}class Ky{constructor(t){this.source=t,this.url=Yy(t.url),_t(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return _t(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Qy(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Jy(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class Qy{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 s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(i=>{this._contentLength=i.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},i=>{i.code==="ENOENT"&&(i=cd(0,this._url.href)),this._storedError=i,this._headersCapability.reject(i)})}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(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new kn("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Jy{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var s;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(s=this.onProgress)==null||s.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(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",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const ul=Symbol("INITIAL_DATA");var be,Hh,Qp;class Sb{constructor(){d(this,Hh);d(this,be,Object.create(null))}get(t,e=null){if(e){const i=b(this,Hh,Qp).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=n(this,be)[t];if(!s||s.data===ul)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=n(this,be)[t];return!!e&&e.data!==ul}delete(t){const e=n(this,be)[t];return!e||e.data===ul?!1:(delete n(this,be)[t],!0)}resolve(t,e=null){const s=b(this,Hh,Qp).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in n(this,be)){const{data:s}=n(this,be)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,be,Object.create(null))}*[Symbol.iterator](){for(const t in n(this,be)){const{data:e}=n(this,be)[t];e!==ul&&(yield[t,e])}}}be=new WeakMap,Hh=new WeakSet,Qp=function(t){var e;return(e=n(this,be))[t]||(e[t]={...Promise.withResolvers(),data:ul})};const Zy=1e5,ym=30;var Sm,en,le,$h,zh,fr,ii,Gh,Uh,pr,ho,co,sn,uo,jh,fo,gr,Vh,Wh,po,mr,Xh,nn,go,Wu,Eb,Xu,Cb,qh,Jp,mo,Pd,Yh,Zp,qu,Tb,Yu,xb;const ut=class ut{constructor({textContentSource:t,container:e,viewport:s}){d(this,Wu);d(this,Xu);d(this,qh);d(this,en,Promise.withResolvers());d(this,le,null);d(this,$h,!1);d(this,zh,!!((Sm=globalThis.FontInspector)!=null&&Sm.enabled));d(this,fr,null);d(this,ii,null);d(this,Gh,0);d(this,Uh,0);d(this,pr,null);d(this,ho,null);d(this,co,0);d(this,sn,0);d(this,uo,Object.create(null));d(this,jh,[]);d(this,fo,null);d(this,gr,[]);d(this,Vh,new WeakMap);d(this,Wh,null);var l;if(t instanceof ReadableStream)p(this,fo,t);else if(typeof t=="object")p(this,fo,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,le,p(this,ho,e)),p(this,sn,s.scale*Ds.pixelRatio),p(this,co,s.rotation),p(this,ii,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:r,pageX:a,pageY:o}=s.rawDims;p(this,Wh,[1,0,0,-1,-a,o+r]),p(this,Uh,i),p(this,Gh,r),b(l=ut,qu,Tb).call(l),ra(e,s),n(this,en).promise.finally(()=>{n(ut,go).delete(this),p(this,ii,null),p(this,uo,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Wt.platform;return V(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{n(this,pr).read().then(({value:e,done:s})=>{if(s){n(this,en).resolve();return}n(this,fr)??p(this,fr,e.lang),Object.assign(n(this,uo),e.styles),b(this,Wu,Eb).call(this,e.items),t()},n(this,en).reject)};return p(this,pr,n(this,fo).getReader()),n(ut,go).add(this),t(),n(this,en).promise}update({viewport:t,onBefore:e=null}){var r;const s=t.scale*Ds.pixelRatio,i=t.rotation;if(i!==n(this,co)&&(e==null||e(),p(this,co,i),ra(n(this,ho),{rotation:i})),s!==n(this,sn)){e==null||e(),p(this,sn,s);const a={div:null,properties:null,ctx:b(r=ut,mo,Pd).call(r,n(this,fr))};for(const o of n(this,gr))a.properties=n(this,Vh).get(o),a.div=o,b(this,qh,Jp).call(this,a)}}cancel(){var e;const t=new kn("TextLayer task cancelled.");(e=n(this,pr))==null||e.cancel(t).catch(()=>{}),p(this,pr,null),n(this,en).reject(t)}get textDivs(){return n(this,gr)}get textContentItemsStr(){return n(this,jh)}static cleanup(){if(!(n(this,go).size>0)){n(this,po).clear();for(const{canvas:t}of n(this,mr).values())t.remove();n(this,mr).clear()}}};en=new WeakMap,le=new WeakMap,$h=new WeakMap,zh=new WeakMap,fr=new WeakMap,ii=new WeakMap,Gh=new WeakMap,Uh=new WeakMap,pr=new WeakMap,ho=new WeakMap,co=new WeakMap,sn=new WeakMap,uo=new WeakMap,jh=new WeakMap,fo=new WeakMap,gr=new WeakMap,Vh=new WeakMap,Wh=new WeakMap,po=new WeakMap,mr=new WeakMap,Xh=new WeakMap,nn=new WeakMap,go=new WeakMap,Wu=new WeakSet,Eb=function(t){var i,r;if(n(this,$h))return;(r=n(this,ii)).ctx??(r.ctx=b(i=ut,mo,Pd).call(i,n(this,fr)));const e=n(this,gr),s=n(this,jh);for(const a of t){if(e.length>Zy){z("Ignoring additional textDivs for performance reasons."),p(this,$h,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=n(this,le);p(this,le,document.createElement("span")),n(this,le).classList.add("markedContent"),a.id&&n(this,le).setAttribute("id",`${a.id}`),o.append(n(this,le))}else a.type==="endMarkedContent"&&p(this,le,n(this,le).parentNode);continue}s.push(a.str),b(this,Xu,Cb).call(this,a)}},Xu=new WeakSet,Cb=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};n(this,gr).push(e);const i=I.transform(n(this,Wh),t.transform);let r=Math.atan2(i[1],i[0]);const a=n(this,uo)[t.fontName];a.vertical&&(r+=Math.PI/2);let o=n(this,zh)&&a.fontSubstitution||a.fontFamily;o=ut.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*b(y=ut,Yu,xb).call(y,o,a,n(this,fr));let c,f;r===0?(c=i[4],f=i[5]-h):(c=i[4]+h*Math.sin(r),f=i[5]-h*Math.cos(r));const g="calc(var(--total-scale-factor) *",m=e.style;n(this,le)===n(this,ho)?(m.left=`${(100*c/n(this,Uh)).toFixed(2)}%`,m.top=`${(100*f/n(this,Gh)).toFixed(2)}%`):(m.left=`${g}${c.toFixed(2)}px)`,m.top=`${g}${f.toFixed(2)}px)`),m.fontSize=`${g}${(n(ut,nn)*l).toFixed(2)}px)`,m.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,n(this,zh)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),r!==0&&(s.angle=r*(180/Math.PI));let A=!1;if(t.str.length>1)A=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const v=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);v!==w&&Math.max(v,w)/Math.min(v,w)>1.5&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),n(this,Vh).set(e,s),n(this,ii).div=e,n(this,ii).properties=s,b(this,qh,Jp).call(this,n(this,ii)),s.hasText&&n(this,le).append(e),s.hasEOL){const v=document.createElement("br");v.setAttribute("role","presentation"),n(this,le).append(v)}},qh=new WeakSet,Jp=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:r}=e;let a="";if(n(ut,nn)>1&&(a=`scale(${1/n(ut,nn)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=r,{canvasWidth:h,fontSize:c}=s;b(o=ut,Yh,Zp).call(o,i,c*n(this,sn),l);const{width:f}=i.measureText(e.textContent);f>0&&(a=`scaleX(${h*n(this,sn)/f}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(r.transform=a)},mo=new WeakSet,Pd=function(t=null){let e=n(this,mr).get(t||(t=""));if(!e){const s=document.createElement("canvas");s.className="hiddenCanvasElement",s.lang=t,document.body.append(s),e=s.getContext("2d",{alpha:!1,willReadFrequently:!0}),n(this,mr).set(t,e),n(this,Xh).set(e,{size:0,family:""})}return e},Yh=new WeakSet,Zp=function(t,e,s){const i=n(this,Xh).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},qu=new WeakSet,Tb=function(){if(n(this,nn)!==null)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),p(this,nn,t.getBoundingClientRect().height),t.remove()},Yu=new WeakSet,xb=function(t,e,s){const i=n(this,po).get(t);if(i)return i;const r=b(this,mo,Pd).call(this,s);r.canvas.width=r.canvas.height=ym,b(this,Yh,Zp).call(this,r,ym,t);const a=r.measureText(""),o=a.fontBoundingBoxAscent,l=Math.abs(a.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return o?h=o/(o+l):(Wt.platform.isFirefox&&z("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),n(this,po).set(t,h),h},d(ut,mo),d(ut,Yh),d(ut,qu),d(ut,Yu),d(ut,po,new Map),d(ut,mr,new Map),d(ut,Xh,new WeakMap),d(ut,nn,null),d(ut,go,new Set);let Nl=ut;class Ol{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(r){var l;if(!r)return;let a=null;const o=r.name;if(o==="#text")a=r.value;else if(Ol.shouldBuildText(o))(l=r==null?void 0:r.attributes)!=null&&l.textContent?a=r.attributes.textContent:r.value&&(a=r.value);else return;if(a!==null&&e.push({str:a}),!!r.children)for(const h of r.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const tw=100;function ew(u={}){typeof u=="string"||u instanceof URL?u={url:u}:(u instanceof ArrayBuffer||ArrayBuffer.isView(u))&&(u={data:u});const t=new tg,{docId:e}=t,s=u.url?ly(u.url):null,i=u.data?hy(u.data):null,r=u.httpHeaders||null,a=u.withCredentials===!0,o=u.password??null,l=u.range instanceof kb?u.range:null,h=Number.isInteger(u.rangeChunkSize)&&u.rangeChunkSize>0?u.rangeChunkSize:2**16;let c=u.worker instanceof Bl?u.worker:null;const f=u.verbosity,g=typeof u.docBaseUrl=="string"&&!np(u.docBaseUrl)?u.docBaseUrl:null,m=pd(u.cMapUrl),A=u.cMapPacked!==!1,y=u.CMapReaderFactory||(ie?by:om),v=pd(u.iccUrl),w=pd(u.standardFontDataUrl),S=u.StandardFontDataFactory||(ie?Ay:lm),_=pd(u.wasmUrl),E=u.WasmFactory||(ie?yy:hm),C=u.stopAtErrors!==!0,T=Number.isInteger(u.maxImageSize)&&u.maxImageSize>-1?u.maxImageSize:-1,x=u.isEvalSupported!==!1,P=typeof u.isOffscreenCanvasSupported=="boolean"?u.isOffscreenCanvasSupported:!ie,M=typeof u.isImageDecoderSupported=="boolean"?u.isImageDecoderSupported:!ie&&(Wt.platform.isFirefox||!globalThis.chrome),D=Number.isInteger(u.canvasMaxAreaInBytes)?u.canvasMaxAreaInBytes:-1,R=typeof u.disableFontFace=="boolean"?u.disableFontFace:ie,H=u.fontExtraProperties===!0,U=u.enableXfa===!0,W=u.ownerDocument||globalThis.document,Y=u.disableRange===!0,B=u.disableStream===!0,N=u.disableAutoFetch===!0,Pt=u.pdfBug===!0,At=u.CanvasFactory||(ie?my:fy),Re=u.FilterFactory||(ie?gy:py),as=u.enableHWA===!0,it=u.useWasm!==!1,Z=l?l.length:u.length??NaN,Ls=typeof u.useSystemFonts=="boolean"?u.useSystemFonts:!ie&&!R,Ve=typeof u.useWorkerFetch=="boolean"?u.useWorkerFetch:!!(y===om&&S===lm&&E===hm&&m&&w&&_&&gl(m,document.baseURI)&&gl(w,document.baseURI)&&gl(_,document.baseURI)),We=null;$A(f);const pt={canvasFactory:new At({ownerDocument:W,enableHWA:as}),filterFactory:new Re({docId:e,ownerDocument:W}),cMapReaderFactory:Ve?null:new y({baseUrl:m,isCompressed:A}),standardFontDataFactory:Ve?null:new S({baseUrl:w}),wasmFactory:Ve?null:new E({baseUrl:_})};c||(c=Bl.create({verbosity:f,port:Ti.workerPort}),t._worker=c);const lp={docId:e,apiVersion:"5.4.149",data:i,password:o,disableAutoFetch:N,rangeChunkSize:h,length:Z,docBaseUrl:g,enableXfa:U,evaluatorOptions:{maxImageSize:T,disableFontFace:R,ignoreErrors:C,isEvalSupported:x,isOffscreenCanvasSupported:P,isImageDecoderSupported:M,canvasMaxAreaInBytes:D,fontExtraProperties:H,useSystemFonts:Ls,useWasm:it,useWorkerFetch:Ve,cMapUrl:m,iccUrl:v,standardFontDataUrl:w,wasmUrl:_}},hp={ownerDocument:W,pdfBug:Pt,styleElement:We,loadingParams:{disableAutoFetch:N,enableXfa:U}};return c.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const cp=c.messageHandler.sendWithPromise("GetDocRequest",lp,i?[i.buffer]:null);let Mn;if(l)Mn=new Ny(l,{disableRange:Y,disableStream:B});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");const Rn=gl(s)?$y:ie?Ky:Vy;Mn=new Rn({url:s,length:Z,httpHeaders:r,withCredentials:a,rangeChunkSize:h,disableRange:Y,disableStream:B})}return cp.then(Rn=>{if(t.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const em=new vl(e,Rn,c.port),IA=new nw(em,t,Mn,hp,pt,as);t._transport=IA,em.send("Ready",null)})}).catch(t._capability.reject),t}var Ku;const Qu=class Qu{constructor(){k(this,"_capability",Promise.withResolvers());k(this,"_transport",null);k(this,"_worker",null);k(this,"docId",`d${St(Qu,Ku)._++}`);k(this,"destroyed",!1);k(this,"onPassword",null);k(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,r}this._transport=null,(i=this._worker)==null||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Ku=new WeakMap,d(Qu,Ku,0);let tg=Qu;var br,Kh,Qh,Jh,Zh;class kb{constructor(t,e,s=!1,i=null){d(this,br,Promise.withResolvers());d(this,Kh,[]);d(this,Qh,[]);d(this,Jh,[]);d(this,Zh,[]);this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){n(this,Zh).push(t)}addProgressListener(t){n(this,Jh).push(t)}addProgressiveReadListener(t){n(this,Qh).push(t)}addProgressiveDoneListener(t){n(this,Kh).push(t)}onDataRange(t,e){for(const s of n(this,Zh))s(t,e)}onDataProgress(t,e){n(this,br).promise.then(()=>{for(const s of n(this,Jh))s(t,e)})}onDataProgressiveRead(t){n(this,br).promise.then(()=>{for(const e of n(this,Qh))e(t)})}onDataProgressiveDone(){n(this,br).promise.then(()=>{for(const t of n(this,Kh))t()})}transportReady(){n(this,br).resolve()}requestDataRange(t,e){st("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}br=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap;class sw{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 V(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()}}var ni,Ar,Tl;class iw{constructor(t,e,s,i=!1){d(this,Ar);d(this,ni,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new nm:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new Sb,this._intentStates=new Map,this.destroyed=!1,this.recordedGroups=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:s=0,offsetY:i=0,dontFlip:r=!1}={}){return new ld({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:r})}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 V(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:r=ki.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:l=null,annotationCanvasMap:h=null,pageColors:c=null,printAnnotationStorage:f=null,isEditing:g=!1,recordOperations:m=!1,filteredOperationIndexes:A=null}){var P,M,D;(P=this._stats)==null||P.time("Overall");const y=this._transport.getRenderingIntent(i,r,f,g),{renderingIntent:v,cacheKey:w}=y;p(this,ni,!1),l||(l=this._transport.getOptionalContentConfig(v));let S=this._intentStates.get(w);S||(S=Object.create(null),this._intentStates.set(w,S)),S.streamReaderCancelTimeout&&(clearTimeout(S.streamReaderCancelTimeout),S.streamReaderCancelTimeout=null);const _=!!(v&Pe.PRINT);S.displayReadyCapability||(S.displayReadyCapability=Promise.withResolvers(),S.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(M=this._stats)==null||M.time("Page Request"),this._pumpOperatorList(y));const E=!this.recordedGroups&&(m||this._pdfBug&&((D=globalThis.StepperManager)==null?void 0:D.enabled)),C=R=>{var H,U,W;if(S.renderTasks.delete(T),E){const Y=(H=T.gfx)==null?void 0:H.dependencyTracker.take();Y?((U=T.stepper)==null||U.setOperatorGroups(Y),m&&(this.recordedGroups=Y)):m&&(this.recordedGroups=[])}_&&p(this,ni,!0),b(this,Ar,Tl).call(this),R?(T.capability.reject(R),this._abortOperatorList({intentState:S,reason:R instanceof Error?R:new Error(R)})):T.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(W=globalThis.Stats)!=null&&W.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},T=new eg({callback:C,params:{canvas:e,canvasContext:t,dependencyTracker:E?new wy(e):null,viewport:s,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:S.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!_,pdfBug:this._pdfBug,pageColors:c,enableHWA:this._transport.enableHWA,filteredOperationIndexes:A});(S.renderTasks||(S.renderTasks=new Set)).add(T);const x=T.task;return Promise.all([S.displayReadyCapability.promise,l]).then(([R,H])=>{var U;if(this.destroyed){C();return}if((U=this._stats)==null||U.time("Rendering"),!(H.renderingIntent&v))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");T.initializeGraphics({transparency:R,optionalContentConfig:H}),T.operatorListChanged()}).catch(C),x}getOperatorList({intent:t="display",annotationMode:e=ki.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function r(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(l))}const a=this._transport.getRenderingIntent(t,e,s,i,!0);let o=this._intentStates.get(a.cacheKey);o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o));let l;return o.opListReadCapability||(l=Object.create(null),l.operatorListChanged=r,o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(l),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(a)),o.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(i){return i.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(s=>Ol.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function r(){a.read().then(function({value:l,done:h}){if(h){s(o);return}o.lang??(o.lang=l.lang),Object.assign(o.styles,l.styles),o.items.push(...l.items),r()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};r()})}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 s of e.renderTasks)t.push(s.completed),s.cancel();return this.objs.clear(),p(this,ni,!1),Promise.all(t)}cleanup(t=!1){p(this,ni,!0);const e=b(this,Ar,Tl).call(this);return t&&e&&this._stats&&(this._stats=new nm),e}_startRenderPage(t,e){var i,r;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(r=s.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&b(this,Ar,Tl).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:r,transfer:a}=s,l=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:i},a).getReader(),h=this._intentStates.get(e);h.streamReader=l;const c=()=>{l.read().then(({value:f,done:g})=>{if(g){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,h),c())},f=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const g of h.renderTasks)g.operatorListChanged();b(this,Ar,Tl).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(f);else if(h.opListReadCapability)h.opListReadCapability.reject(f);else throw f}})};c()}_abortOperatorList({intentState:t,reason:e,force:s=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!s){if(t.renderTasks.size>0)return;if(e instanceof $g){let i=tw;e.extraDelay>0&&e.extraDelay<1e3&&(i+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},i);return}}if(t.streamReader.cancel(new kn(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,r]of this._intentStates)if(r===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}ni=new WeakMap,Ar=new WeakSet,Tl=function(){if(!n(this,ni)||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(),p(this,ni,!1),!0};var rn,Je,ri,yr,Ju,wr,vr,bo,Md,Zu,Pb,tf,Mb,_r,xl,Ao,Rd;const at=class at{constructor({name:t=null,port:e=null,verbosity:s=zA()}={}){d(this,bo);d(this,Zu);d(this,tf);d(this,_r);d(this,rn,Promise.withResolvers());d(this,Je,null);d(this,ri,null);d(this,yr,null);if(this.name=t,this.destroyed=!1,this.verbosity=s,e){if(n(at,vr).has(e))throw new Error("Cannot use more than one PDFWorker per port.");n(at,vr).set(e,this),b(this,Zu,Pb).call(this,e)}else b(this,tf,Mb).call(this)}get promise(){return n(this,rn).promise}get port(){return n(this,ri)}get messageHandler(){return n(this,Je)}destroy(){var t,e;this.destroyed=!0,(t=n(this,yr))==null||t.terminate(),p(this,yr,null),n(at,vr).delete(n(this,ri)),p(this,ri,null),(e=n(this,Je))==null||e.destroy(),p(this,Je,null)}static create(t){const e=n(this,vr).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new at(t)}static get workerSrc(){if(Ti.workerSrc)return Ti.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return V(this,"_setupFakeWorkerGlobal",(async()=>n(this,Ao,Rd)?n(this,Ao,Rd):(await OA(()=>import(this.workerSrc),[])).WorkerMessageHandler)())}};rn=new WeakMap,Je=new WeakMap,ri=new WeakMap,yr=new WeakMap,Ju=new WeakMap,wr=new WeakMap,vr=new WeakMap,bo=new WeakSet,Md=function(){n(this,rn).resolve(),n(this,Je).send("configure",{verbosity:this.verbosity})},Zu=new WeakSet,Pb=function(t){p(this,ri,t),p(this,Je,new vl("main","worker",t)),n(this,Je).on("ready",()=>{}),b(this,bo,Md).call(this)},tf=new WeakSet,Mb=function(){if(n(at,wr)||n(at,Ao,Rd)){b(this,_r,xl).call(this);return}let{workerSrc:t}=at;try{at._isSameOrigin(window.location,t)||(t=at._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new vl("main","worker",e),i=()=>{r.abort(),s.destroy(),e.terminate(),this.destroyed?n(this,rn).reject(new Error("Worker was destroyed")):b(this,_r,xl).call(this)},r=new AbortController;e.addEventListener("error",()=>{n(this,yr)||i()},{signal:r.signal}),s.on("test",o=>{if(r.abort(),this.destroyed||!o){i();return}p(this,Je,s),p(this,ri,e),p(this,yr,e),b(this,bo,Md).call(this)}),s.on("ready",o=>{if(r.abort(),this.destroyed){i();return}try{a()}catch{b(this,_r,xl).call(this)}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{ip("The worker has been disabled.")}b(this,_r,xl).call(this)},_r=new WeakSet,xl=function(){n(at,wr)||(z("Setting up fake worker."),p(at,wr,!0)),at._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){n(this,rn).reject(new Error("Worker was destroyed"));return}const e=new uy;p(this,ri,e);const s=`fake${St(at,Ju)._++}`,i=new vl(s+"_worker",s,e);t.setup(i,e),p(this,Je,new vl(s,s+"_worker",e)),b(this,bo,Md).call(this)}).catch(t=>{n(this,rn).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Ao=new WeakSet,Rd=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},d(at,Ao),d(at,Ju,0),d(at,wr,!1),d(at,vr,new WeakMap),ie&&(p(at,wr,!0),Ti.workerSrc||(Ti.workerSrc="./pdf.worker.mjs")),at._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(s!=null&&s.origin)||s.origin==="null")return!1;const i=new URL(e,s);return s.origin===i.origin},at._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},at.fromPort=t=>{if(ZA("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return at.create(t)};let Bl=at;var ai,vs,yo,wo,oi,Sr,kl;class nw{constructor(t,e,s,i,r,a){d(this,Sr);d(this,ai,new Map);d(this,vs,new Map);d(this,yo,new Map);d(this,wo,new Map);d(this,oi,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new Sb,this.fontLoader=new ay({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return V(this,"annotationStorage",new Gg)}getRenderingIntent(t,e=ki.ENABLE,s=null,i=!1,r=!1){let a=Pe.DISPLAY,o=zp;switch(t){case"any":a=Pe.ANY;break;case"display":break;case"print":a=Pe.PRINT;break;default:z(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Pe.PRINT&&s instanceof ob?s:this.annotationStorage;switch(e){case ki.DISABLE:a+=Pe.ANNOTATIONS_DISABLE;break;case ki.ENABLE:break;case ki.ENABLE_FORMS:a+=Pe.ANNOTATIONS_FORMS;break;case ki.ENABLE_STORAGE:a+=Pe.ANNOTATIONS_STORAGE,o=l.serializable;break;default:z(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Pe.IS_EDITING),r&&(a+=Pe.OPLIST);const{ids:h,hash:c}=l.modifiedIds,f=[a,o.hash,c];return{renderingIntent:a,cacheKey:f.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=n(this,oi))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of n(this,vs).values())t.push(i._destroy());n(this,vs).clear(),n(this,yo).clear(),n(this,wo).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i,r;this.commonObjs.clear(),this.fontLoader.clear(),n(this,ai).clear(),this.filterFactory.destroy(),Nl.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new kn("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{_t(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},i.onPull=()=>{this._fullReader.read().then(function({value:r,done:a}){if(a){i.close();return}_t(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{i.error(r)})},i.onCancel=r=>{this._fullReader.cancel(r),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:r,contentLength:a}=this._fullReader;return(!i||!r)&&(this._lastProgress&&((o=e.onProgress)==null||o.call(e,this._lastProgress)),this._fullReader.onProgress=l=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:r,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{_t(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(s.begin,s.end);if(!r){i.close();return}i.onPull=()=>{r.read().then(function({value:a,done:o}){if(o){i.close();return}_t(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{r.cancel(a),i.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("GetDoc",({pdfInfo:s})=>{this._numPages=s.numPages,this._htmlForXfa=s.htmlForXfa,delete s.htmlForXfa,e._capability.resolve(new sw(s,this))}),t.on("DocException",s=>{e._capability.reject(re(s))}),t.on("PasswordRequest",s=>{p(this,oi,Promise.withResolvers());try{if(!e.onPassword)throw re(s);const i=r=>{r instanceof Error?n(this,oi).reject(r):n(this,oi).resolve({password:r})};e.onPassword(i,s.code)}catch(i){n(this,oi).reject(i)}return n(this,oi).promise}),t.on("DataLoaded",s=>{var i;(i=e.onProgress)==null||i.call(e,{loaded:s.length,total:s.length}),this.downloadInfoCapability.resolve(s)}),t.on("StartRenderPage",s=>{if(this.destroyed)return;n(this,vs).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,r])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":if("error"in r){const c=r.error;z(`Error during font loading: ${c}`),this.commonObjs.resolve(s,c);break}const o=this._params.pdfBug&&((a=globalThis.FontInspector)!=null&&a.enabled)?(c,f)=>globalThis.FontInspector.fontAdded(c,f):null,l=new oy(r,o);this.fontLoader.bind(l).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l.fontExtraProperties&&l.data&&(l.data=null),this.commonObjs.resolve(s,l)});break;case"CopyLocalImage":const{imageRef:h}=r;_t(h,"The imageRef must be defined.");for(const c of n(this,vs).values())for(const[,f]of c.objs)if((f==null?void 0:f.ref)===h)return f.dataLen?(this.commonObjs.resolve(s,structuredClone(f)),f.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,r);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,r,a])=>{var l;if(this.destroyed)return;const o=n(this,vs).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(r){case"Image":case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBinaryData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");const i=this[s.type];if(!i)throw new Error(`${s.type} not initialized, see the \`useWorkerFetch\` parameter.`);return i.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&z("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:((s=this._fullReader)==null?void 0:s.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,s=n(this,yo).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&n(this,wo).set(r.refStr,t);const a=new iw(e,r,this,this._params.pdfBug);return n(this,vs).set(e,a),a});return n(this,yo).set(e,i),i}getPageIndex(t){return Gp(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 b(this,Sr,kl).call(this,"GetFieldObjects")}hasJSActions(){return b(this,Sr,kl).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?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 b(this,Sr,kl).call(this,"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 b(this,Sr,kl).call(this,"GetOptionalContentConfig").then(e=>new Fy(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=n(this,ai).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var r,a;return{info:i[0],metadata:i[1]?new Ly(i[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return n(this,ai).set(t,s),s}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of n(this,vs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),n(this,ai).clear(),this.filterFactory.destroy(!0),Nl.cleanup()}}cachedPageNumber(t){if(!Gp(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return n(this,wo).get(e)??null}}ai=new WeakMap,vs=new WeakMap,yo=new WeakMap,wo=new WeakMap,oi=new WeakMap,Sr=new WeakSet,kl=function(t,e=null){const s=n(this,ai).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return n(this,ai).set(t,i),i};var an;class rw{constructor(t){d(this,an,null);k(this,"onContinue",null);k(this,"onError",null);p(this,an,t)}get promise(){return n(this,an).capability.promise}cancel(t=0){n(this,an).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=n(this,an).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=n(this,an);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}an=new WeakMap;var on,Er;const Nn=class Nn{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:r,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:c=!1,pdfBug:f=!1,pageColors:g=null,enableHWA:m=!1,filteredOperationIndexes:A=null}){d(this,on,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=f,this.pageColors=g,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=c===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new rw(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=m,this._dependencyTracker=e.dependencyTracker,this._filteredOperationIndexes=A}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var l,h;if(this.cancelled)return;if(this._canvas){if(n(Nn,Er).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.");n(Nn,Er).add(this._canvas)}this._pdfBug&&((l=globalThis.StepperManager)!=null&&l.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:s,transform:i,background:r,dependencyTracker:a}=this.params,o=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new _a(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,a),this.gfx.beginDrawing({transform:i,viewport:s,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var s,i,r;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),n(this,on)&&(window.cancelAnimationFrame(n(this,on)),p(this,on,null)),n(Nn,Er).delete(this._canvas),t||(t=new $g(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(i=this.task).onError)==null||r.call(i,t)}operatorListChanged(){var t;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.stepper)==null||t.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,on,window.requestAnimationFrame(()=>{p(this,on,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._filteredOperationIndexes),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),n(Nn,Er).delete(this._canvas),this.callback())))}};on=new WeakMap,Er=new WeakMap,d(Nn,Er,new WeakSet);let eg=Nn;const aw="5.4.149",ow="9e2e9e209";var Ae,Cr,vo,xt,tc,_o,li,ec,ln,Ze,sc,ic,sg,nc,ig,rc,ng,hi,Dn,ef,Rb,_s,xi;const ae=class ae{constructor({editor:t=null,uiManager:e=null}){d(this,ic);d(this,nc);d(this,rc);d(this,hi);d(this,ef);d(this,_s);d(this,Ae,null);d(this,Cr,null);d(this,vo,void 0);d(this,xt,null);d(this,tc,!1);d(this,_o,!1);d(this,li,null);d(this,ec,void 0);d(this,ln,null);d(this,Ze,null);var s,i;t?(p(this,_o,!1),p(this,li,t)):p(this,_o,!0),p(this,Ze,(t==null?void 0:t._uiManager)||e),p(this,ec,n(this,Ze)._eventBus),p(this,vo,((s=t==null?void 0:t.color)==null?void 0:s.toUpperCase())||((i=n(this,Ze))==null?void 0:i.highlightColors.values().next().value)||"#FFFF98"),n(ae,sc)||p(ae,sc,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"}))}static get _keyboardManager(){return V(this,"_keyboardManager",new hd([[["Escape","mac+Escape"],ae.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ae.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ae.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ae.prototype._moveToPrevious],[["Home","mac+Home"],ae.prototype._moveToBeginning],[["End","mac+End"],ae.prototype._moveToEnd]]))}renderButton(){const t=p(this,Ae,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",n(this,li)&&(t.ariaControls=`${n(this,li).id}_colorpicker_dropdown`);const e=n(this,Ze)._signal;t.addEventListener("click",b(this,hi,Dn).bind(this),{signal:e}),t.addEventListener("keydown",b(this,rc,ng).bind(this),{signal:e});const s=p(this,Cr,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=n(this,vo),t.append(s),t}renderMainDropdown(){const t=p(this,xt,b(this,ic,sg).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===n(this,Ae)){b(this,hi,Dn).call(this,t);return}const e=t.target.getAttribute("data-color");e&&b(this,nc,ig).call(this,e,t)}_moveToNext(t){var e,s;if(!n(this,_s,xi)){b(this,hi,Dn).call(this,t);return}if(t.target===n(this,Ae)){(e=n(this,xt).firstChild)==null||e.focus();return}(s=t.target.nextSibling)==null||s.focus()}_moveToPrevious(t){var e,s;if(t.target===((e=n(this,xt))==null?void 0:e.firstChild)||t.target===n(this,Ae)){n(this,_s,xi)&&this._hideDropdownFromKeyboard();return}n(this,_s,xi)||b(this,hi,Dn).call(this,t),(s=t.target.previousSibling)==null||s.focus()}_moveToBeginning(t){var e;if(!n(this,_s,xi)){b(this,hi,Dn).call(this,t);return}(e=n(this,xt).firstChild)==null||e.focus()}_moveToEnd(t){var e;if(!n(this,_s,xi)){b(this,hi,Dn).call(this,t);return}(e=n(this,xt).lastChild)==null||e.focus()}hideDropdown(){var t,e;(t=n(this,xt))==null||t.classList.add("hidden"),n(this,Ae).ariaExpanded="false",(e=n(this,ln))==null||e.abort(),p(this,ln,null)}_hideDropdownFromKeyboard(){var t;if(!n(this,_o)){if(!n(this,_s,xi)){(t=n(this,li))==null||t.unselect();return}this.hideDropdown(),n(this,Ae).focus({preventScroll:!0,focusVisible:n(this,tc)})}}updateColor(t){if(n(this,Cr)&&(n(this,Cr).style.backgroundColor=t),!n(this,xt))return;const e=n(this,Ze).highlightColors.values();for(const s of n(this,xt).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=n(this,Ae))==null||t.remove(),p(this,Ae,null),p(this,Cr,null),(e=n(this,xt))==null||e.remove(),p(this,xt,null)}};Ae=new WeakMap,Cr=new WeakMap,vo=new WeakMap,xt=new WeakMap,tc=new WeakMap,_o=new WeakMap,li=new WeakMap,ec=new WeakMap,ln=new WeakMap,Ze=new WeakMap,sc=new WeakMap,ic=new WeakSet,sg=function(){const t=document.createElement("div"),e=n(this,Ze)._signal;t.addEventListener("contextmenu",je,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),n(this,li)&&(t.id=`${n(this,li).id}_colorpicker_dropdown`);for(const[s,i]of n(this,Ze).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",i),r.title=s,r.setAttribute("data-l10n-id",n(ae,sc)[s]);const a=document.createElement("span");r.append(a),a.className="swatch",a.style.backgroundColor=i,r.ariaSelected=i===n(this,vo),r.addEventListener("click",b(this,nc,ig).bind(this,i),{signal:e}),t.append(r)}return t.addEventListener("keydown",b(this,rc,ng).bind(this),{signal:e}),t},nc=new WeakSet,ig=function(t,e){e.stopPropagation(),n(this,ec).dispatch("switchannotationeditorparams",{source:this,type:X.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},rc=new WeakSet,ng=function(t){ae._keyboardManager.exec(this,t)},hi=new WeakSet,Dn=function(t){if(n(this,_s,xi)){this.hideDropdown();return}if(p(this,tc,t.detail===0),n(this,ln)||(p(this,ln,new AbortController),window.addEventListener("pointerdown",b(this,ef,Rb).bind(this),{signal:n(this,Ze).combinedSignal(n(this,ln))})),n(this,Ae).ariaExpanded="true",n(this,xt)){n(this,xt).classList.remove("hidden");return}const e=p(this,xt,b(this,ic,sg).call(this));n(this,Ae).append(e)},ef=new WeakSet,Rb=function(t){var e;(e=n(this,xt))!=null&&e.contains(t.target)||this.hideDropdown()},_s=new WeakSet,xi=function(){return n(this,xt)&&!n(this,xt).classList.contains("hidden")},d(ae,sc,null);let eu=ae;var Ss,ac,So,oc;const On=class On{constructor(t){d(this,Ss,null);d(this,ac,null);d(this,So,null);p(this,ac,t),p(this,So,t._uiManager),n(On,oc)||p(On,oc,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(n(this,Ss))return n(this,Ss);const{editorType:t,colorType:e,colorValue:s}=n(this,ac),i=p(this,Ss,document.createElement("input"));return i.type="color",i.value=s||"#000000",i.className="basicColorPicker",i.tabIndex=0,i.setAttribute("data-l10n-id",n(On,oc)[t]),i.addEventListener("input",()=>{n(this,So).updateParams(e,i.value)},{signal:n(this,So)._signal}),i}update(t){n(this,Ss)&&(n(this,Ss).value=t)}destroy(){var t;(t=n(this,Ss))==null||t.remove(),p(this,Ss,null)}hideDropdown(){}};Ss=new WeakMap,ac=new WeakMap,So=new WeakMap,oc=new WeakMap,d(On,oc,null);let su=On;function wm(u){return Math.floor(Math.max(0,Math.min(1,u))*255).toString(16).padStart(2,"0")}function fl(u){return Math.max(0,Math.min(255,255*u))}class vm{static CMYK_G([t,e,s,i]){return["G",1-Math.min(1,.3*t+.59*s+.11*e+i)]}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=fl(t),[t,t,t]}static G_HTML([t]){const e=wm(t);return`#${e}${e}${e}`}static RGB_G([t,e,s]){return["G",.3*t+.59*e+.11*s]}static RGB_rgb(t){return t.map(fl)}static RGB_HTML(t){return`#${t.map(wm).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,s,i]){return["RGB",1-Math.min(1,t+i),1-Math.min(1,s+i),1-Math.min(1,e+i)]}static CMYK_rgb([t,e,s,i]){return[fl(1-Math.min(1,t+i)),fl(1-Math.min(1,s+i)),fl(1-Math.min(1,e+i))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,s]){const i=1-t,r=1-e,a=1-s,o=Math.min(i,r,a);return["CMYK",i,r,a,o]}}class lw{create(t,e,s=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),s||(i.setAttribute("width",`${t}px`),i.setAttribute("height",`${e}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${t} ${e}`),i}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){st("Abstract method `_createSVG` called.")}}class iu extends lw{_createSVG(t){return document.createElementNS(Is,t)}}class Db{static setupStorage(t,e,s,i,r){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})});break;case"input":if(s.attributes.type==="radio"||s.attributes.type==="checkbox"){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",o=>{i.setValue(e,{value:o.target.checked?o.target.getAttribute("xfaOn"):o.target.getAttribute("xfaOff")})})}else{if(a.value!==null&&t.setAttribute("value",a.value),r==="print")break;t.addEventListener("input",o=>{i.setValue(e,{value:o.target.value})})}break;case"select":if(a.value!==null){t.setAttribute("value",a.value);for(const o of s.children)o.attributes.value===a.value?o.attributes.selected=!0:o.attributes.hasOwnProperty("selected")&&delete o.attributes.selected}t.addEventListener("input",o=>{const l=o.target.options,h=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:r}){const{attributes:a}=e,o=t instanceof HTMLAnchorElement;a.type==="radio"&&(a.name=`${a.name}-${i}`);for(const[l,h]of Object.entries(a))if(h!=null)switch(l){case"class":h.length&&t.setAttribute(l,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,h)}o&&r.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var f,g;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,r=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:r,linkService:s});const o=r!=="richText",l=t.div;if(l.append(a),t.viewport){const m=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=m}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const m=document.createTextNode(i.value);a.append(m),o&&Ol.shouldBuildText(i.name)&&h.push(m)}return{textDivs:h}}const c=[[i,-1,a]];for(;c.length>0;){const[m,A,y]=c.at(-1);if(A+1===m.children.length){c.pop();continue}const v=m.children[++c.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const _=document.createTextNode(v.value);h.push(_),y.append(_);continue}const S=(f=v==null?void 0:v.attributes)!=null&&f.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(y.append(S),v.attributes&&this.setAttributes({html:S,element:v,storage:e,intent:r,linkService:s}),((g=v.children)==null?void 0:g.length)>0)c.push([v,-1,S]);else if(v.value){const _=document.createTextNode(v.value);o&&Ol.shouldBuildText(w)&&h.push(_),S.append(_)}}for(const m of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))m.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const hw=9,oa=new WeakSet,cw=new Date().getTimezoneOffset()*60*1e3;class _m{static create(t){switch(t.data.annotationType){case wt.LINK:return new Vg(t);case wt.TEXT:return new dw(t);case wt.WIDGET:switch(t.data.fieldType){case"Tx":return new uw(t);case"Btn":return t.data.radioButton?new Nb(t):t.data.checkBox?new pw(t):new gw(t);case"Ch":return new mw(t);case"Sig":return new fw(t)}return new ha(t);case wt.POPUP:return new ag(t);case wt.FREETEXT:return new Ub(t);case wt.LINE:return new Aw(t);case wt.SQUARE:return new yw(t);case wt.CIRCLE:return new ww(t);case wt.POLYLINE:return new jb(t);case wt.CARET:return new _w(t);case wt.INK:return new Wg(t);case wt.POLYGON:return new vw(t);case wt.HIGHLIGHT:return new Vb(t);case wt.UNDERLINE:return new Sw(t);case wt.SQUIGGLY:return new Ew(t);case wt.STRIKEOUT:return new Cw(t);case wt.STAMP:return new Wb(t);case wt.FILEATTACHMENT:return new Tw(t);default:return new bt(t)}}}var Tr,Eo,ci,sf,Lb,lc,rg;const Zg=class Zg{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){d(this,sf);d(this,lc);d(this,Tr,null);d(this,Eo,!1);d(this,ci,null);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,e&&(this.container=this._createContainer(s)),i&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Zg._hasPopupData(this.data)}get hasCommentButton(){return this.enableComment&&this._isEditable&&this.hasPopupElement}get commentButtonPosition(){const{quadPoints:t,rect:e}=this.data;let s=-1/0,i=-1/0;if((t==null?void 0:t.length)>=8){for(let r=0;r<t.length;r+=8)t[r+1]>i?(i=t[r+1],s=t[r+2]):t[r+1]===i&&(s=Math.max(s,t[r+2]));return[s,i]}return e?[e[2],e[3]]:null}get commentButtonColor(){if(!this.data.color)return null;const[t,e,s]=this.data.color,r=255*(1-(this.data.opacity??1));return b(this,sf,Lb).call(this,Math.min(t+r,255),Math.min(e+r,255),Math.min(s+r,255))}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:s,pageHeight:i,pageX:r,pageY:a}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/s,t[1]=100*(t[1]-a)/i,t}updateEdited(t){var r;if(!this.container)return;t.rect&&(n(this,Tr)||p(this,Tr,{rect:this.data.rect.slice(0)}));const{rect:e,popup:s}=t;e&&b(this,lc,rg).call(this,e);let i=((r=n(this,ci))==null?void 0:r.popup)||this.popup;!i&&(s!=null&&s.text)&&(this._createPopup(s),i=n(this,ci).popup),i&&(i.updateEdited(t),s!=null&&s.deleted&&(i.remove(),p(this,ci,null),this.popup=null))}resetEdited(){var t;n(this,Tr)&&(b(this,lc,rg).call(this,n(this,Tr).rect),(t=n(this,ci))==null||t.popup.resetEdited(),p(this,Tr,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof ha)&&!(this instanceof Vg)&&(r.tabIndex=0);const{style:a}=r;if(a.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof ag){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,r),r}const{width:o,height:l}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(y>0||v>0){const S=`calc(${y}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;a.borderRadius=S}else if(this instanceof Nb){const S=`calc(${o}px * var(--total-scale-factor)) / calc(${l}px * var(--total-scale-factor))`;a.borderRadius=S}switch(e.borderStyle.style){case da.SOLID:a.borderStyle="solid";break;case da.DASHED:a.borderStyle="dashed";break;case da.BEVELED:z("Unimplemented border style: beveled");break;case da.INSET:z("Unimplemented border style: inset");break;case da.UNDERLINE:a.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(p(this,Eo,!0),a.borderColor=I.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):a.borderWidth=0}const h=I.normalizeRect([e.rect[0],s.view[3]-e.rect[1]+s.view[1],e.rect[2],s.view[3]-e.rect[3]+s.view[1]]),{pageWidth:c,pageHeight:f,pageX:g,pageY:m}=i.rawDims;a.left=`${100*(h[0]-g)/c}%`,a.top=`${100*(h[1]-m)/f}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/c}%`,a.height=`${100*l/f}%`):this.setRotation(A,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:r,height:a}=this;t%180!==0&&([r,a]=[a,r]),e.style.width=`${100*r/s}%`,e.style.height=`${100*a/i}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const r=i.detail[e],a=r[0],o=r.slice(1);i.target.style[s]=vm[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:vm[`${a}_rgb`](o)})};return V(this,"_commonActions",{display:e=>{const{display:s}=e.detail,i=s%2===1;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:i,noPrint:s===1||s===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:s}=e.detail;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:s,noView:s})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{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:e=>{const s=e.detail.rotation;this.setRotation(s),this.annotationStorage.setValue(this.data.id,{rotation:s})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const r=t[i]||s[i];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const s=this._commonActions;for(const[i,r]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:r},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,r]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,v,w,S]=t.subarray(2,6);if(i===y&&r===v&&e===w&&s===S)return}const{style:a}=this.container;let o;if(n(this,Eo)){const{borderColor:y,borderWidth:v}=a;a.borderWidth=0,o=["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="${y}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const l=i-e,h=r-s,{svgFactory:c}=this,f=c.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0),f.role="none";const g=c.createElement("defs");f.append(g);const m=c.createElement("clipPath"),A=`clippath_${this.data.id}`;m.setAttribute("id",A),m.setAttribute("clipPathUnits","objectBoundingBox"),g.append(m);for(let y=2,v=t.length;y<v;y+=8){const w=t[y],S=t[y+1],_=t[y+2],E=t[y+3],C=c.createElement("rect"),T=(_-e)/l,x=(r-S)/h,P=(w-_)/l,M=(S-E)/h;C.setAttribute("x",T),C.setAttribute("y",x),C.setAttribute("width",P),C.setAttribute("height",M),m.append(C),o==null||o.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${x}" width="${P}" height="${M}"/>`)}n(this,Eo)&&(o.push("</g></svg>')"),a.backgroundImage=o.join("")),this.container.append(f),this.container.style.clipPath=`url(#${A})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate);const r=p(this,ci,new ag({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,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]}));this.parent.div.append(r.render())}get hasPopupElement(){return!!(n(this,ci)||this.popup||this.data.popupRef)}render(){st("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:r,id:a,exportValues:o}of i){if(r===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!oa.has(h)){z(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:h})}return s}for(const i of document.getElementsByName(t)){const{exportValue:r}=i,a=i.getAttribute("data-element-id");a!==e&&oa.has(i)&&s.push({id:a,exportValue:r,domElement:i})}return s}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.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",()=>{var s;(s=this.linkService.eventBus)==null||s.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]}};Tr=new WeakMap,Eo=new WeakMap,ci=new WeakMap,sf=new WeakSet,Lb=function(t,e,s){t/=255,e/=255,s/=255;const i=Math.max(t,e,s),r=Math.min(t,e,s),a=(i+r)/2,o=((1+Math.sqrt(a))/2*100).toFixed(2);if(i===r)return`hsl(0, 0%, ${o}%)`;const l=i-r;let h;i===t?h=(e-s)/l+(e<s?6:0):i===e?h=(s-t)/l+2:h=(t-e)/l+4,h=(h*60).toFixed(2);const c=(l/(1-Math.abs(2*a-1))*100).toFixed(2);return`hsl(${h}, ${c}%, ${o}%)`},lc=new WeakSet,rg=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t),e.left=`${100*(t[0]-o)/r}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/a}%`):this.setRotation(i)};let bt=Zg;var di,Ln,nf,Ib,rf,Fb;class Vg extends bt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});d(this,di);d(this,nf);d(this,rf);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let r=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(i,e.action,e.overlaidText),r=!0):e.attachment?(b(this,nf,Ib).call(this,i,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(b(this,rf,Fb).call(this,i,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(i,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),r=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(i,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(i),this.container}_bindLink(e,s,i=""){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&b(this,di,Ln).call(this),i&&(e.title=i)}_bindNamedAction(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),i&&(e.title=i),b(this,di,Ln).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(s.actions)){const a=i.get(r);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:r}}),!1})}s.overlaidText&&(e.title=s.overlaidText),e.onclick||(e.onclick=()=>!1),b(this,di,Ln).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),b(this,di,Ln).call(this),!this._fieldObjects){z('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var f;i==null||i();const{fields:r,refs:a,include:o}=s,l=[];if(r.length!==0||a.length!==0){const g=new Set(a);for(const m of r){const A=this._fieldObjects[m]||[];for(const{id:y}of A)g.add(y)}for(const m of Object.values(this._fieldObjects))for(const A of m)g.has(A.id)===o&&l.push(A)}else for(const g of Object.values(this._fieldObjects))l.push(...g);const h=this.annotationStorage,c=[];for(const g of l){const{id:m}=g;switch(c.push(m),g.type){case"text":{const y=g.defaultValue||"";h.setValue(m,{value:y});break}case"checkbox":case"radiobutton":{const y=g.defaultValue===g.exportValues;h.setValue(m,{value:y});break}case"combobox":case"listbox":{const y=g.defaultValue||"";h.setValue(m,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${m}"]`);if(A){if(!oa.has(A)){z(`_bindResetFormAction - element not allowed: ${m}`);continue}}else continue;A.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:c,name:"ResetForm"}})),!1}}}di=new WeakSet,Ln=function(){this.container.setAttribute("data-internal-link","")},nf=new WeakSet,Ib=function(e,s,i="",r=null){e.href=this.linkService.getAnchorUrl(""),s.description?e.title=s.description:i&&(e.title=i),e.onclick=()=>{var a;return(a=this.downloadManager)==null||a.openOrDownloadData(s.content,s.filename,r),!1},b(this,di,Ln).call(this)},rf=new WeakSet,Fb=function(e,s,i=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),i&&(e.title=i),b(this,di,Ln).call(this)};class dw extends bt{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 ha extends bt{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Wt.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,r){s.includes("mouse")?t.addEventListener(s,a=>{var o;(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a),shift:a.shiftKey,modifier:this._getKeyModifier(a)}})}):t.addEventListener(s,a=>{var o;if(s==="blur"){if(!e.focused||!a.relatedTarget)return;e.focused=!1}else if(s==="focus"){if(e.focused)return;e.focused=!0}r&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(a)}}))})}_setEventListeners(t,e,s,i){var r,a,o;for(const[l,h]of s)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,h,i),h==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((o=this.data.actions)!=null&&o.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":I.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||hw,r=t.style;let a;const o=2,l=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o),c=Math.round(h/(up*i))||1,f=h/c;a=Math.min(i,l(f/up))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/up))}r.fontSize=`calc(${a}px * var(--total-scale-factor))`,r.color=I.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class uw extends ha{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,s,i){const r=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),r.setValue(a.id,{[i]:s})}render(){var i,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let s=null;if(this.renderForms){const a=t.getValue(e,{value:this.data.fieldValue});let o=a.value||"";const l=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;l&&o.length>l&&(o=o.slice(0,l));let h=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(`
`))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const c={userValue:o,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=h??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type=this.data.password?"password":"text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),oa.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=0;const{datetimeFormat:f,datetimeType:g,timeStep:m}=this.data,A=!!g&&this.enableScripting;f&&(s.title=f),this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(s,"value",v.target.value,"value"),c.formattedValue=null}),s.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";s.value=c.userValue=w,c.formattedValue=null});let y=v=>{const{formattedValue:w}=c;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",w=>{var _;if(c.focused)return;const{target:S}=w;if(A&&(S.type=g,m&&(S.step=m)),c.userValue){const E=c.userValue;if(A)if(g==="time"){const C=new Date(E),T=[C.getHours(),C.getMinutes(),C.getSeconds()];S.value=T.map(x=>x.toString().padStart(2,"0")).join(":")}else S.value=new Date(E-cw).toISOString().split(g==="date"?"T":".",1)[0];else S.value=E}c.lastCommittedValue=S.value,c.commitKey=1,(_=this.data.actions)!=null&&_.Focus||(c.focused=!0)}),s.addEventListener("updatefromsandbox",w=>{this.showElementAndHideCanvas(w.target);const S={value(_){c.userValue=_.detail.value??"",A||t.setValue(e,{value:c.userValue.toString()}),_.target.value=c.userValue},formattedValue(_){const{formattedValue:E}=_.detail;c.formattedValue=E,E!=null&&_.target!==document.activeElement&&(_.target.value=E);const C={formattedValue:E};A&&(C.value=E),t.setValue(e,C)},selRange(_){_.target.setSelectionRange(..._.detail.selRange)},charLimit:_=>{var x;const{charLimit:E}=_.detail,{target:C}=_;if(E===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",E);let T=c.userValue;!T||T.length<=E||(T=T.slice(0,E),C.value=c.userValue=T,t.setValue(e,{value:T}),(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(S,w)}),s.addEventListener("keydown",w=>{var E;c.commitKey=1;let S=-1;if(w.key==="Escape"?S=0:w.key==="Enter"&&!this.data.multiLine?S=2:w.key==="Tab"&&(c.commitKey=3),S===-1)return;const{value:_}=w.target;c.lastCommittedValue!==_&&(c.lastCommittedValue=_,c.userValue=_,(E=this.linkService.eventBus)==null||E.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:S,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=y;y=null,s.addEventListener("blur",w=>{var E,C;if(!c.focused||!w.relatedTarget)return;(E=this.data.actions)!=null&&E.Blur||(c.focused=!1);const{target:S}=w;let{value:_}=S;if(A){if(_&&g==="time"){const T=_.split(":").map(x=>parseInt(x,10));_=new Date(2e3,0,1,T[0],T[1],T[2]||0).valueOf(),S.step=""}else _=new Date(_).valueOf();S.type="text"}c.userValue=_,c.lastCommittedValue!==_&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:c.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&s.addEventListener("beforeinput",w=>{var M;c.lastCommittedValue=null;const{data:S,target:_}=w,{value:E,selectionStart:C,selectionEnd:T}=_;let x=C,P=T;switch(w.inputType){case"deleteWordBackward":{const D=E.substring(0,C).match(/\w*[^\w]*$/);D&&(x-=D[0].length);break}case"deleteWordForward":{const D=E.substring(C).match(/^[^\w]*\w*/);D&&(P+=D[0].length);break}case"deleteContentBackward":C===T&&(x-=1);break;case"deleteContentForward":C===T&&(P+=1);break}w.preventDefault(),(M=this.linkService.eventBus)==null||M.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,change:S||"",willCommit:!1,selStart:x,selEnd:P}})}),this._setEventListeners(s,c,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(y&&s.addEventListener("blur",y),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${w}px * var(--total-scale-factor) - 1ch)`}}else s=document.createElement("div"),s.textContent=this.data.fieldValue,s.style.verticalAlign="middle",s.style.display="table-cell",this.data.hasOwnCanvas&&(s.hidden=!0);return this._setTextStyle(s),this._setBackgroundColor(s),this._setDefaultPropertiesFromJS(s),this.container.append(s),this.container}}class fw extends ha{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class pw extends ha{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.exportValue===e.fieldValue}).value;typeof i=="string"&&(i=i!=="Off",t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return oa.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const c=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=c),t.setValue(h.id,{value:c})}t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",a=>{const o={value(l){l.target.checked=l.detail.value!=="Off",t.setValue(s,{value:l.target.checked})}};this._dispatchEventFromSandbox(o,a)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],a=>a.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class Nb extends ha{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,s=e.id;let i=t.getValue(s,{value:e.fieldValue===e.buttonValue}).value;if(typeof i=="string"&&(i=i!==e.buttonValue,t.setValue(s,{value:i})),i)for(const a of this._getElementsByName(e.fieldName,s))t.setValue(a.id,{value:!1});const r=document.createElement("input");if(oa.add(r),r.setAttribute("data-element-id",s),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s))t.setValue(h.id,{value:!1});t.setValue(s,{value:l})}),r.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;r.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const c=a===h.detail.value;for(const f of this._getElementsByName(h.target.name)){const g=c&&f.id===s;f.domElement&&(f.domElement.checked=g),t.setValue(f.id,{value:g})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class gw extends Vg{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",s=>{this._dispatchEventFromSandbox({},s)})),t}}class mw extends ha{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,s=t.getValue(e,{value:this.data.fieldValue}),i=document.createElement("select");oa.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",c=>{const f=this.data.defaultFieldValue;for(const g of i.options)g.selected=g.value===f});for(const c of this.data.options){const f=document.createElement("option");f.textContent=c.displayValue,f.value=c.exportValue,s.value.includes(c.exportValue)&&(f.setAttribute("selected",!0),r=!1),i.append(f)}let a=null;if(r){const c=document.createElement("option");c.value=" ",c.setAttribute("hidden",!0),c.setAttribute("selected",!0),i.prepend(c),a=()=>{c.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=c=>{const f=c?"value":"textContent",{options:g,multiple:m}=i;return m?Array.prototype.filter.call(g,A=>A.selected).map(A=>A[f]):g.selectedIndex===-1?null:g[g.selectedIndex][f]};let l=o(!1);const h=c=>{const f=c.target.options;return Array.prototype.map.call(f,g=>({displayValue:g.textContent,exportValue:g.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",c=>{const f={value(g){a==null||a();const m=g.detail.value,A=new Set(Array.isArray(m)?m:[m]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(g){i.multiple=!0},remove(g){const m=i.options,A=g.detail.remove;m[A].selected=!1,i.remove(A),m.length>0&&Array.prototype.findIndex.call(m,v=>v.selected)===-1&&(m[0].selected=!0),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},clear(g){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(g){const{index:m,displayValue:A,exportValue:y}=g.detail.insert,v=i.children[m],w=document.createElement("option");w.textContent=A,w.value=y,v?v.before(w):i.append(w),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},items(g){const{items:m}=g.detail;for(;i.length!==0;)i.remove(0);for(const A of m){const{displayValue:y,exportValue:v}=A,w=document.createElement("option");w.textContent=y,w.value=v,i.append(w)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(g)}),l=o(!1)},indices(g){const m=new Set(g.detail.indices);for(const A of g.target.options)A.selected=m.has(A.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(g){g.target.disabled=!g.detail.editable}};this._dispatchEventFromSandbox(f,c)}),i.addEventListener("input",c=>{var m;const f=o(!0),g=o(!1);t.setValue(e,{value:f}),c.preventDefault(),(m=this.linkService.eventBus)==null||m.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:g,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],c=>c.target.value)):i.addEventListener("input",function(c){t.setValue(e,{value:o(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class ag extends bt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:bt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";const e=this.popup=new bw({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,eventBus:this.linkService.eventBus}),s=[];for(const i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(i=>`${Hg}${i}`).join(",")),this.container}}var xr,af,of,kr,Co,ft,ui,hn,fi,hc,cc,To,Es,ye,pi,gi,dc,cn,xo,uc,mi,ko,Pr,dn,Po,Dd,lf,Ob,hf,Bb,Mo,Ld,fc,og,cf,Hb,df,$b,uf,zb,ff,Gb,Ro,Id,Do,Fd,pc,lg;class bw{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:r,contentsObj:a,richText:o,parent:l,rect:h,parentRect:c,open:f,eventBus:g=null}){d(this,Po);d(this,lf);d(this,hf);d(this,Mo);d(this,fc);d(this,cf);d(this,df);d(this,uf);d(this,ff);d(this,Ro);d(this,Do);d(this,pc);d(this,xr,b(this,uf,zb).bind(this));d(this,af,b(this,pc,lg).bind(this));d(this,of,b(this,Do,Fd).bind(this));d(this,kr,b(this,Ro,Id).bind(this));d(this,Co,null);d(this,ft,null);d(this,ui,null);d(this,hn,null);d(this,fi,null);d(this,hc,null);d(this,cc,null);d(this,To,null);d(this,Es,!1);d(this,ye,null);d(this,pi,null);d(this,gi,null);d(this,dc,null);d(this,cn,null);d(this,xo,null);d(this,uc,null);d(this,mi,null);d(this,ko,null);d(this,Pr,null);d(this,dn,!1);p(this,ft,t),p(this,ko,i),p(this,ui,a),p(this,mi,o),p(this,cc,l),p(this,Co,e),p(this,uc,h),p(this,To,c),p(this,fi,s),p(this,hc,g),p(this,hn,Qd.toDateObject(r)),this.trigger=s.flatMap(m=>m.getElementsToTriggerPopup()),b(this,Po,Dd).call(this),n(this,ft).hidden=!0,f&&b(this,Ro,Id).call(this)}render(){var i;if(n(this,ye))return;const t=p(this,ye,document.createElement("div"));if(t.className="popup",n(this,Co)){const r=t.style.outlineColor=I.makeHexColor(...n(this,Co));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(i=n(this,ko))!=null&&i.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=n(this,ko)}if(t.append(e),n(this,hn)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:n(this,hn).valueOf()})),r.dateTime=n(this,hn).toISOString(),e.append(r)}const s=n(this,Mo,Ld);if(s)Db.render({xfaHtml:s,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const r=this._formatContents(n(this,ui));t.append(r)}n(this,ft).append(t)}_formatContents({str:t,dir:e}){const s=document.createElement("p");s.classList.add("popupContent"),s.dir=e;const i=t.split(/(?:\r\n?|\n)/);for(let r=0,a=i.length;r<a;++r){const o=i[r];s.append(document.createTextNode(o)),r<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popup:e,deleted:s}){var i;if(s||e!=null&&e.deleted){this.remove();return}b(this,Po,Dd).call(this),n(this,Pr)||p(this,Pr,{contentsObj:n(this,ui),richText:n(this,mi)}),t&&p(this,gi,null),e&&(p(this,mi,b(this,df,$b).call(this,e.text)),p(this,hn,Qd.toDateObject(e.date)),p(this,ui,null)),(i=n(this,ye))==null||i.remove(),p(this,ye,null)}resetEdited(){var t;n(this,Pr)&&({contentsObj:St(this,ui)._,richText:St(this,mi)._}=n(this,Pr),p(this,Pr,null),(t=n(this,ye))==null||t.remove(),p(this,ye,null),p(this,gi,null))}remove(){var t,e;(t=n(this,pi))==null||t.abort(),p(this,pi,null),(e=n(this,ye))==null||e.remove(),p(this,ye,null),p(this,dn,!1),p(this,Es,!1);for(const s of this.trigger)s.classList.remove("popupTriggerArea")}forceHide(){p(this,dn,this.isVisible),n(this,dn)&&(n(this,ft).hidden=!0)}maybeShow(){b(this,Po,Dd).call(this),n(this,dn)&&(n(this,ye)||b(this,Do,Fd).call(this),p(this,dn,!1),n(this,ft).hidden=!1)}get isVisible(){return n(this,ft).hidden===!1}}xr=new WeakMap,af=new WeakMap,of=new WeakMap,kr=new WeakMap,Co=new WeakMap,ft=new WeakMap,ui=new WeakMap,hn=new WeakMap,fi=new WeakMap,hc=new WeakMap,cc=new WeakMap,To=new WeakMap,Es=new WeakMap,ye=new WeakMap,pi=new WeakMap,gi=new WeakMap,dc=new WeakMap,cn=new WeakMap,xo=new WeakMap,uc=new WeakMap,mi=new WeakMap,ko=new WeakMap,Pr=new WeakMap,dn=new WeakMap,Po=new WeakSet,Dd=function(){var e;if(n(this,pi))return;p(this,pi,new AbortController);const{signal:t}=n(this,pi);for(const s of this.trigger)s.addEventListener("click",n(this,kr),{signal:t}),s.addEventListener("mouseenter",n(this,of),{signal:t}),s.addEventListener("mouseleave",n(this,af),{signal:t}),s.classList.add("popupTriggerArea");for(const s of n(this,fi))(e=s.container)==null||e.addEventListener("keydown",n(this,xr),{signal:t});b(this,hf,Bb).call(this)},lf=new WeakSet,Ob=function(){const t=n(this,fi).find(e=>e.hasCommentButton);t&&(p(this,cn,t._normalizePoint(t.commentButtonPosition)),p(this,xo,t.commentButtonColor))},hf=new WeakSet,Bb=function(){if(n(this,dc)||(n(this,cn)||b(this,lf,Ob).call(this),!n(this,cn)))return;const t=p(this,dc,document.createElement("button"));t.className="annotationCommentButton";const e=n(this,fi)[0].container;t.style.zIndex=e.style.zIndex+1,t.tabIndex=0;const{signal:s}=n(this,pi);t.addEventListener("hover",n(this,kr),{signal:s}),t.addEventListener("keydown",n(this,xr),{signal:s}),t.addEventListener("click",()=>{var o;const[{data:{id:r},annotationEditorType:a}]=n(this,fi);(o=n(this,hc))==null||o.dispatch("switchannotationeditormode",{source:this,editId:r,mode:a,editComment:!0})},{signal:s});const{style:i}=t;i.left=`calc(${n(this,cn)[0]}%)`,i.top=`calc(${n(this,cn)[1]}% - var(--comment-button-dim))`,n(this,xo)&&(i.backgroundColor=n(this,xo)),e.after(t)},Mo=new WeakSet,Ld=function(){const t=n(this,mi),e=n(this,ui);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&n(this,mi).html||null},fc=new WeakSet,og=function(){var t,e,s;return((s=(e=(t=n(this,Mo,Ld))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.fontSize)||0},cf=new WeakSet,Hb=function(){var t,e,s;return((s=(e=(t=n(this,Mo,Ld))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:s.color)||null},df=new WeakSet,$b=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:n(this,cf,Hb),fontSize:n(this,fc,og)?`calc(${n(this,fc,og)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
`))e.push({name:"span",value:r,attributes:i});return s},uf=new WeakSet,zb=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&n(this,Es))&&b(this,Ro,Id).call(this)},ff=new WeakSet,Gb=function(){if(n(this,gi)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:r}}}=n(this,cc);let a=!!n(this,To),o=a?n(this,To):n(this,uc);for(const A of n(this,fi))if(!o||I.intersect(A.data.rect,o)!==null){o=A.data.rect,a=!0;break}const l=I.normalizeRect([o[0],t[3]-o[1]+t[1],o[2],t[3]-o[3]+t[1]]),h=5,c=a?o[2]-o[0]+h:0,f=l[0]+c,g=l[1];p(this,gi,[100*(f-i)/e,100*(g-r)/s]);const{style:m}=n(this,ft);m.left=`${n(this,gi)[0]}%`,m.top=`${n(this,gi)[1]}%`},Ro=new WeakSet,Id=function(){p(this,Es,!n(this,Es)),n(this,Es)?(b(this,Do,Fd).call(this),n(this,ft).addEventListener("click",n(this,kr)),n(this,ft).addEventListener("keydown",n(this,xr))):(b(this,pc,lg).call(this),n(this,ft).removeEventListener("click",n(this,kr)),n(this,ft).removeEventListener("keydown",n(this,xr)))},Do=new WeakSet,Fd=function(){n(this,ye)||this.render(),this.isVisible?n(this,Es)&&n(this,ft).classList.add("focused"):(b(this,ff,Gb).call(this),n(this,ft).hidden=!1,n(this,ft).style.zIndex=parseInt(n(this,ft).style.zIndex)+1e3)},pc=new WeakSet,lg=function(){n(this,ft).classList.remove("focused"),!(n(this,Es)||!this.isVisible)&&(n(this,ft).hidden=!0,n(this,ft).style.zIndex=parseInt(n(this,ft).style.zIndex)-1e3)};class Ub extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=$.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 s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var gc;class Aw extends bt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});d(this,gc,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=p(this,gc,this.svgFactory.createElement("svg:line"));return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,gc)}addHighlightArea(){this.container.classList.add("highlightArea")}}gc=new WeakMap;var mc;class yw extends bt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});d(this,mc,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,mc,this.svgFactory.createElement("svg:rect"));return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",s-a),o.setAttribute("height",i-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,mc)}addHighlightArea(){this.container.classList.add("highlightArea")}}mc=new WeakMap;var bc;class ww extends bt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});d(this,bc,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:s,height:i}=this,r=this.svgFactory.create(s,i,!0),a=e.borderStyle.width,o=p(this,bc,this.svgFactory.createElement("svg:ellipse"));return o.setAttribute("cx",s/2),o.setAttribute("cy",i/2),o.setAttribute("rx",s/2-a/2),o.setAttribute("ry",i/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,bc)}addHighlightArea(){this.container.classList.add("highlightArea")}}bc=new WeakMap;var Ac;class jb extends bt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});d(this,Ac,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:s,borderStyle:i,popupRef:r},width:a,height:o}=this;if(!s)return this.container;const l=this.svgFactory.create(a,o,!0);let h=[];for(let f=0,g=s.length;f<g;f+=2){const m=s[f]-e[0],A=e[3]-s[f+1];h.push(`${m},${A}`)}h=h.join(" ");const c=p(this,Ac,this.svgFactory.createElement(this.svgElementName));return c.setAttribute("points",h),c.setAttribute("stroke-width",i.width||1),c.setAttribute("stroke","transparent"),c.setAttribute("fill","transparent"),l.append(c),this.container.append(l),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return n(this,Ac)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ac=new WeakMap;class vw extends jb{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class _w extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}var yc,Mr,wc,hg;class Wg extends bt{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});d(this,wc);d(this,yc,null);d(this,Mr,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?$.HIGHLIGHT:$.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:s,inkLists:i,borderStyle:r,popupRef:a}}=this,{transform:o,width:l,height:h}=b(this,wc,hg).call(this,s,e),c=this.svgFactory.create(l,h,!0),f=p(this,yc,this.svgFactory.createElement("svg:g"));c.append(f),f.setAttribute("stroke-width",r.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",o);for(let g=0,m=i.length;g<m;g++){const A=this.svgFactory.createElement(this.svgElementName);n(this,Mr).push(A),A.setAttribute("points",i[g].join(",")),f.append(A)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(c),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:s,points:i,rect:r}=e,a=n(this,yc);if(s>=0&&a.setAttribute("stroke-width",s||1),i)for(let o=0,l=n(this,Mr).length;o<l;o++)n(this,Mr)[o].setAttribute("points",i[o].join(","));if(r){const{transform:o,width:l,height:h}=b(this,wc,hg).call(this,this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${l} ${h}`),a.setAttribute("transform",o)}}getElementsToTriggerPopup(){return n(this,Mr)}addHighlightArea(){this.container.classList.add("highlightArea")}get commentButtonPosition(){const{inkLists:e,rect:s}=this.data;if((e==null?void 0:e.length)>=1){let i=-1/0,r=-1/0;for(const a of e)for(let o=0,l=a.length;o<l;o+=2)a[o+1]>r?(r=a[o+1],i=a[o]):a[o+1]===r&&(i=Math.max(i,a[o]));if(i!==1/0)return[i,r]}return s?[s[2],s[3]]:null}}yc=new WeakMap,Mr=new WeakMap,wc=new WeakSet,hg=function(e,s){switch(e){case 90:return{transform:`rotate(90) translate(${-s[0]},${s[1]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};case 180:return{transform:`rotate(180) translate(${-s[2]},${s[1]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]};case 270:return{transform:`rotate(270) translate(${-s[2]},${s[3]}) scale(1,-1)`,width:s[3]-s[1],height:s[2]-s[0]};default:return{transform:`translate(${-s[0]},${s[3]}) scale(1,-1)`,width:s[2]-s[0],height:s[3]-s[1]}}};class Vb extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=$.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const s=document.createElement("mark");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Sw extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Ew extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const s=document.createElement("u");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Cw extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const s=document.createElement("s");s.classList.add("overlaidText"),s.textContent=t,this.container.append(s)}return this.container}}class Wb extends bt{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=$.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}var vc,_c,cg;class Tw extends bt{constructor(e){var i;super(e,{isRenderable:!0});d(this,_c);d(this,vc,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,(i=this.linkService.eventBus)==null||i.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:s}=this;let i;s.hasAppearance||s.fillAlpha===0?i=document.createElement("div"):(i=document.createElement("img"),i.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(s.name)?"paperclip":"pushpin"}.svg`,s.fillAlpha&&s.fillAlpha<1&&(i.style=`filter: opacity(${Math.round(s.fillAlpha*100)}%);`)),i.addEventListener("dblclick",b(this,_c,cg).bind(this)),p(this,vc,i);const{isMac:r}=Wt.platform;return e.addEventListener("keydown",a=>{a.key==="Enter"&&(r?a.metaKey:a.ctrlKey)&&b(this,_c,cg).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return n(this,vc)}addHighlightArea(){this.container.classList.add("highlightArea")}}vc=new WeakMap,_c=new WeakSet,cg=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var Sc,Rr,un,Ec,Cc,ug,Tc,fg;const tm=class tm{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:r,viewport:a,structTreeLayer:o}){d(this,Cc);d(this,Tc);d(this,Sc,null);d(this,Rr,null);d(this,un,new Map);d(this,Ec,null);this.div=t,p(this,Sc,e),p(this,Rr,s),p(this,Ec,o||null),this.page=r,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return n(this,un).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;ra(s,this.viewport);const i=new Map,r={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new iu,annotationStorage:t.annotationStorage||new Gg,enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const o of e){if(o.noHTML)continue;const l=o.annotationType===wt.POPUP;if(l){const f=i.get(o.id);if(!f)continue;r.elements=f}else if(o.rect[2]===o.rect[0]||o.rect[3]===o.rect[1])continue;r.data=o;const h=_m.create(r);if(!h.isRenderable)continue;if(!l&&o.popupRef){const f=i.get(o.popupRef);f?f.push(h):i.set(o.popupRef,[h])}const c=h.render();o.hidden&&(c.style.visibility="hidden"),await b(this,Cc,ug).call(this,c,o.id,r.elements),h._isEditable&&(n(this,un).set(h.data.id,h),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(h))}b(this,Tc,fg).call(this)}async addLinkAnnotations(t,e){const s={data:null,layer:this.div,linkService:e,svgFactory:new iu,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=tm._defaultBorderStyle),s.data=i;const r=_m.create(s);if(!r.isRenderable)continue;const a=r.render();await b(this,Cc,ug).call(this,a,i.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,ra(e,{rotation:t.rotation}),b(this,Tc,fg).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(n(this,un).values())}getEditableAnnotation(t){return n(this,un).get(t)}static get _defaultBorderStyle(){return V(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:da.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Sc=new WeakMap,Rr=new WeakMap,un=new WeakMap,Ec=new WeakMap,Cc=new WeakSet,ug=async function(t,e,s){var o,l;const i=t.firstChild||t,r=i.id=`${Hg}${e}`,a=await((o=n(this,Ec))==null?void 0:o.getAriaAttributes(r));if(a)for(const[h,c]of a)i.setAttribute(h,c);s?s.at(-1).container.after(t):(this.div.append(t),(l=n(this,Sc))==null||l.moveElementInDOM(this.div,t,i,!1))},Tc=new WeakSet,fg=function(){var e;if(!n(this,Rr))return;const t=this.div;for(const[s,i]of n(this,Rr)){const r=t.querySelector(`[data-annotation-id="${s}"]`);if(!r)continue;i.className="annotationContent";const{firstChild:a}=r;a?a.nodeName==="CANVAS"?a.replaceWith(i):a.classList.contains("annotationContent")?a.after(i):a.before(i):r.append(i);const o=n(this,un).get(s);o&&(o._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(s,r.id,i),o._hasNoCanvas=!1):o.canvas=i)}n(this,Rr).clear()};let dg=tm;const Ad=/\r\n?|\n/g;var He,we,xc,Dr,ve,pf,Xb,gf,qb,mf,Yb,Lo,Nd,Io,Od,Fo,Bd,bf,Kb,kc,gg,Af,Qb;const nt=class nt extends rt{constructor(e){super({...e,name:"freeTextEditor"});d(this,pf);d(this,gf);d(this,mf);d(this,Lo);d(this,Fo);d(this,bf);d(this,Af);d(this,He,void 0);d(this,we,"");d(this,xc,`${this.id}-editor`);d(this,Dr,null);d(this,ve,void 0);k(this,"_colorPicker",null);p(this,He,e.color||nt._defaultColor||rt._defaultLineColor),p(this,ve,e.fontSize||nt._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=nt.prototype,s=a=>a.isEmpty(),i=aa.TRANSLATE_SMALL,r=aa.TRANSLATE_BIG;return V(this,"_keyboardManager",new hd([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-i,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:s}]]))}static initialize(e,s){rt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case X.FREETEXT_SIZE:nt._defaultFontSize=s;break;case X.FREETEXT_COLOR:nt._defaultColor=s;break}}updateParams(e,s){switch(e){case X.FREETEXT_SIZE:b(this,pf,Xb).call(this,s);break;case X.FREETEXT_COLOR:b(this,gf,qb).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[X.FREETEXT_SIZE,nt._defaultFontSize],[X.FREETEXT_COLOR,nt._defaultColor||rt._defaultLineColor]]}get propertiesToUpdate(){return[[X.FREETEXT_SIZE,n(this,ve)],[X.FREETEXT_COLOR,n(this,He)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new su(this)),[["colorPicker",this._colorPicker]]}get colorType(){return X.FREETEXT_COLOR}get colorValue(){return n(this,He)}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-nt._internalPadding*e,-(nt._internalPadding+n(this,ve))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(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"),p(this,Dr,new AbortController);const e=this._uiManager.combinedSignal(n(this,Dr));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",n(this,xc)),this._isDraggable=!0,(e=n(this,Dr))==null||e.abort(),p(this,Dr,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var s;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(s=this._initialOptions)!=null&&s.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()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=n(this,we),s=p(this,we,b(this,mf,Yb).call(this).trimEnd());if(e===s)return;const i=r=>{if(p(this,we,r),!r){this.remove();return}b(this,Fo,Bd).call(this),this._uiManager.rebuild(this),b(this,Lo,Nd).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),b(this,Lo,Nd).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){nt._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,s;(this._isCopy||this.annotationElementId)&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",n(this,xc)),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(${n(this,ve)}px * var(--total-scale-factor))`,i.color=n(this,He),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[r,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[c,f]=this.pageDimensions,[g,m]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-g)/c,y=s+this.height-(o[1]-m)/f;break;case 90:A=e+(o[0]-g)/c,y=s-(o[1]-m)/f,[l,h]=[h,-l];break;case 180:A=e-this.width+(o[0]-g)/c,y=s-(o[1]-m)/f,[l,h]=[-l,-h];break;case 270:A=e+(o[0]-g-this.height*f)/c,y=s+(o[1]-m-this.width*c)/f,[l,h]=[-h,l];break}this.setAt(A*r,y*a,l,h)}else this._moveAfterPaste(e,s);b(this,Fo,Bd).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,v;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const r=b(A=nt,kc,gg).call(A,s.getData("text")||"").replaceAll(Ad,`
`);if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes(`
`)){o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,c=[],f=[];if(l.nodeType===Node.TEXT_NODE){const w=l.parentElement;if(f.push(l.nodeValue.slice(h).replaceAll(Ad,"")),w!==this.editorDiv){let S=c;for(const _ of this.editorDiv.childNodes){if(_===w){S=f;continue}S.push(b(y=nt,Io,Od).call(y,_))}}c.push(l.nodeValue.slice(0,h).replaceAll(Ad,""))}else if(l===this.editorDiv){let w=c,S=0;for(const _ of this.editorDiv.childNodes)S++===h&&(w=f),w.push(b(v=nt,Io,Od).call(v,_))}p(this,we,`${c.join(`
`)}${r}${f.join(`
`)}`),b(this,Fo,Bd).call(this);const g=new Range;let m=Math.sumPrecise(c.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const S=w.nodeValue.length;if(m<=S){g.setStart(w,m),g.setEnd(w,m);break}m-=S}a.removeAllRanges(),a.addRange(g)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=nt._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,s,i){var o;let r=null;if(e instanceof Ub){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:c,rotation:f,id:g,popupRef:m,contentsObj:A},textContent:y,textPosition:v,parent:{page:{pageNumber:w}}}=e;if(!y||y.length===0)return null;r=e={annotationType:$.FREETEXT,color:Array.from(h),fontSize:l,value:y.join(`
`),position:v,pageIndex:w-1,rect:c.slice(0),rotation:f,annotationElementId:g,id:g,deleted:!1,popupRef:m,comment:(A==null?void 0:A.str)||null}}const a=await super.deserialize(e,s,i);return p(a,ve,e.fontSize),p(a,He,I.makeHexColor(...e.color)),p(a,we,b(o=nt,kc,gg).call(o,e.value)),a._initialData=r,e.comment&&a.setCommentData(e.comment),a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=this.getPDFRect(),i=rt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:n(this,He)),r={annotationType:$.FREETEXT,color:i,fontSize:n(this,ve),value:b(this,bf,Kb).call(this),pageIndex:this.pageIndex,rect:s,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(r),e?(r.isCopy=!0,r):this.annotationElementId&&!b(this,Af,Qb).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(!s)return null;const{style:i}=s;i.fontSize=`calc(${n(this,ve)}px * var(--total-scale-factor))`,i.color=n(this,He),s.replaceChildren();for(const a of n(this,we).split(`
`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const r={rect:this.getPDFRect()};return r.popup=this.hasEditedComment?this.comment:{text:n(this,we)},e.updateEdited(r),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};He=new WeakMap,we=new WeakMap,xc=new WeakMap,Dr=new WeakMap,ve=new WeakMap,pf=new WeakSet,Xb=function(e){const s=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-n(this,ve))*this.parentScale),p(this,ve,r),b(this,Lo,Nd).call(this)},i=n(this,ve);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},gf=new WeakSet,qb=function(e){const s=r=>{var a;p(this,He,this.editorDiv.style.color=r),(a=this._colorPicker)==null||a.update(r)},i=n(this,He);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},mf=new WeakSet,Yb=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const r of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(b(i=nt,Io,Od).call(i,r)),s=r);return e.join(`
`)},Lo=new WeakSet,Nd=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:r,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",r.div.append(this.div),i=a.getBoundingClientRect(),a.remove(),a.style.display=o,a.classList.toggle("hidden",l)}this.rotation%180===this.parentRotation%180?(this.width=i.width/e,this.height=i.height/s):(this.width=i.height/e,this.height=i.width/s),this.fixAndSetPosition()},Io=new WeakSet,Od=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Ad,"")},Fo=new WeakSet,Bd=function(){if(this.editorDiv.replaceChildren(),!!n(this,we))for(const e of n(this,we).split(`
`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},bf=new WeakSet,Kb=function(){return n(this,we).replaceAll(" "," ")},kc=new WeakSet,gg=function(e){return e.replaceAll(" "," ")},Af=new WeakSet,Qb=function(e){const{value:s,fontSize:i,color:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==r[l])||e.pageIndex!==a},d(nt,Io),d(nt,kc),k(nt,"_freeTextDefaultContent",""),k(nt,"_internalPadding",0),k(nt,"_defaultColor",null),k(nt,"_defaultFontSize",10),k(nt,"_type","freetext"),k(nt,"_editorType",$.FREETEXT);let pg=nt;class L{toSVGPath(){st("Abstract method `toSVGPath` must be implemented.")}get box(){st("Abstract getter `box` must be implemented.")}serialize(t,e){st("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o]*i,a[o+1]=s+t[o+1]*r;return a}static _rescaleAndSwap(t,e,s,i,r,a){a||(a=new Float32Array(t.length));for(let o=0,l=t.length;o<l;o+=2)a[o]=e+t[o+1]*i,a[o+1]=s+t[o]*r;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let r=0,a=t.length;r<a;r+=2)i[r]=e+t[r],i[r+1]=s+t[r+1];return i}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,s,i,r){switch(r){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){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,s,i,r,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+r)/6,(5*i+a)/6,(s+r)/2,(i+a)/2]}}k(L,"PRECISION",1e-4);var _e,ts,No,Oo,Cs,j,Lr,Ir,Pc,Mc,Bo,Ho,fn,Rc,yf,wf,Fr,Pl,vf,Jb,_f,Zb,Sf,tA,Ef,eA,Cf,sA,Tf,iA;const Bs=class Bs{constructor({x:t,y:e},s,i,r,a,o=0){d(this,Fr);d(this,vf);d(this,_f);d(this,Sf);d(this,Ef);d(this,Cf);d(this,Tf);d(this,_e,void 0);d(this,ts,[]);d(this,No,void 0);d(this,Oo,void 0);d(this,Cs,[]);d(this,j,new Float32Array(18));d(this,Lr,void 0);d(this,Ir,void 0);d(this,Pc,void 0);d(this,Mc,void 0);d(this,Bo,void 0);d(this,Ho,void 0);d(this,fn,[]);p(this,_e,s),p(this,Ho,r*i),p(this,Oo,a),n(this,j).set([NaN,NaN,NaN,NaN,t,e],6),p(this,No,o),p(this,Mc,n(Bs,Rc)*i),p(this,Pc,n(Bs,wf)*i),p(this,Bo,i),n(this,fn).push(t,e)}isEmpty(){return isNaN(n(this,j)[8])}add({x:t,y:e}){var M;p(this,Lr,t),p(this,Ir,e);const[s,i,r,a]=n(this,_e);let[o,l,h,c]=n(this,j).subarray(8,12);const f=t-h,g=e-c,m=Math.hypot(f,g);if(m<n(this,Pc))return!1;const A=m-n(this,Mc),y=A/m,v=y*f,w=y*g;let S=o,_=l;o=h,l=c,h+=v,c+=w,(M=n(this,fn))==null||M.push(t,e);const E=-w/A,C=v/A,T=E*n(this,Ho),x=C*n(this,Ho);return n(this,j).set(n(this,j).subarray(2,8),0),n(this,j).set([h+T,c+x],4),n(this,j).set(n(this,j).subarray(14,18),12),n(this,j).set([h-T,c-x],16),isNaN(n(this,j)[6])?(n(this,Cs).length===0&&(n(this,j).set([o+T,l+x],2),n(this,Cs).push(NaN,NaN,NaN,NaN,(o+T-s)/r,(l+x-i)/a),n(this,j).set([o-T,l-x],14),n(this,ts).push(NaN,NaN,NaN,NaN,(o-T-s)/r,(l-x-i)/a)),n(this,j).set([S,_,o,l,h,c],6),!this.isEmpty()):(n(this,j).set([S,_,o,l,h,c],6),Math.abs(Math.atan2(_-l,S-o)-Math.atan2(w,v))<Math.PI/2?([o,l,h,c]=n(this,j).subarray(2,6),n(this,Cs).push(NaN,NaN,NaN,NaN,((o+h)/2-s)/r,((l+c)/2-i)/a),[o,l,S,_]=n(this,j).subarray(14,18),n(this,ts).push(NaN,NaN,NaN,NaN,((S+o)/2-s)/r,((_+l)/2-i)/a),!0):([S,_,o,l,h,c]=n(this,j).subarray(0,6),n(this,Cs).push(((S+5*o)/6-s)/r,((_+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),[h,c,o,l,S,_]=n(this,j).subarray(12,18),n(this,ts).push(((S+5*o)/6-s)/r,((_+5*l)/6-i)/a,((5*o+h)/6-s)/r,((5*l+c)/6-i)/a,((o+h)/2-s)/r,((l+c)/2-i)/a),!0))}toSVGPath(){if(this.isEmpty())return"";const t=n(this,Cs),e=n(this,ts);if(isNaN(n(this,j)[6])&&!this.isEmpty())return b(this,vf,Jb).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);b(this,Sf,tA).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return b(this,_f,Zb).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,r,a){return new nA(t,e,s,i,r,a)}getOutlines(){var f;const t=n(this,Cs),e=n(this,ts),s=n(this,j),[i,r,a,o]=n(this,_e),l=new Float32Array((((f=n(this,fn))==null?void 0:f.length)??0)+2);for(let g=0,m=l.length-2;g<m;g+=2)l[g]=(n(this,fn)[g]-i)/a,l[g+1]=(n(this,fn)[g+1]-r)/o;if(l[l.length-2]=(n(this,Lr)-i)/a,l[l.length-1]=(n(this,Ir)-r)/o,isNaN(s[6])&&!this.isEmpty())return b(this,Ef,eA).call(this,l);const h=new Float32Array(n(this,Cs).length+24+n(this,ts).length);let c=t.length;for(let g=0;g<c;g+=2){if(isNaN(t[g])){h[g]=h[g+1]=NaN;continue}h[g]=t[g],h[g+1]=t[g+1]}c=b(this,Tf,iA).call(this,h,c);for(let g=e.length-6;g>=6;g-=6)for(let m=0;m<6;m+=2){if(isNaN(e[g+m])){h[c]=h[c+1]=NaN,c+=2;continue}h[c]=e[g+m],h[c+1]=e[g+m+1],c+=2}return b(this,Cf,sA).call(this,h,c),this.newFreeDrawOutline(h,l,n(this,_e),n(this,Bo),n(this,No),n(this,Oo))}};_e=new WeakMap,ts=new WeakMap,No=new WeakMap,Oo=new WeakMap,Cs=new WeakMap,j=new WeakMap,Lr=new WeakMap,Ir=new WeakMap,Pc=new WeakMap,Mc=new WeakMap,Bo=new WeakMap,Ho=new WeakMap,fn=new WeakMap,Rc=new WeakMap,yf=new WeakMap,wf=new WeakMap,Fr=new WeakSet,Pl=function(){const t=n(this,j).subarray(4,6),e=n(this,j).subarray(16,18),[s,i,r,a]=n(this,_e);return[(n(this,Lr)+(t[0]-e[0])/2-s)/r,(n(this,Ir)+(t[1]-e[1])/2-i)/a,(n(this,Lr)+(e[0]-t[0])/2-s)/r,(n(this,Ir)+(e[1]-t[1])/2-i)/a]},vf=new WeakSet,Jb=function(){const[t,e,s,i]=n(this,_e),[r,a,o,l]=b(this,Fr,Pl).call(this);return`M${(n(this,j)[2]-t)/s} ${(n(this,j)[3]-e)/i} L${(n(this,j)[4]-t)/s} ${(n(this,j)[5]-e)/i} L${r} ${a} L${o} ${l} L${(n(this,j)[16]-t)/s} ${(n(this,j)[17]-e)/i} L${(n(this,j)[14]-t)/s} ${(n(this,j)[15]-e)/i} Z`},_f=new WeakSet,Zb=function(t){const e=n(this,ts);t.push(`L${e[4]} ${e[5]} Z`)},Sf=new WeakSet,tA=function(t){const[e,s,i,r]=n(this,_e),a=n(this,j).subarray(4,6),o=n(this,j).subarray(16,18),[l,h,c,f]=b(this,Fr,Pl).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/r} L${l} ${h} L${c} ${f} L${(o[0]-e)/i} ${(o[1]-s)/r}`)},Ef=new WeakSet,eA=function(t){const e=n(this,j),[s,i,r,a]=n(this,_e),[o,l,h,c]=b(this,Fr,Pl).call(this),f=new Float32Array(36);return f.set([NaN,NaN,NaN,NaN,(e[2]-s)/r,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/r,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,(e[16]-s)/r,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/r,(e[15]-i)/a],0),this.newFreeDrawOutline(f,t,n(this,_e),n(this,Bo),n(this,No),n(this,Oo))},Cf=new WeakSet,sA=function(t,e){const s=n(this,ts);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Tf=new WeakSet,iA=function(t,e){const s=n(this,j).subarray(4,6),i=n(this,j).subarray(16,18),[r,a,o,l]=n(this,_e),[h,c,f,g]=b(this,Fr,Pl).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-r)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,c,NaN,NaN,NaN,NaN,f,g,NaN,NaN,NaN,NaN,(i[0]-r)/o,(i[1]-a)/l],e),e+=24},d(Bs,Rc,8),d(Bs,yf,2),d(Bs,wf,n(Bs,Rc)+n(Bs,yf));let nu=Bs;var $o,Nr,bi,Dc,Se,Lc,mt,xf,rA;class nA extends L{constructor(e,s,i,r,a,o){super();d(this,xf);d(this,$o,void 0);d(this,Nr,new Float32Array(4));d(this,bi,void 0);d(this,Dc,void 0);d(this,Se,void 0);d(this,Lc,void 0);d(this,mt,void 0);p(this,mt,e),p(this,Se,s),p(this,$o,i),p(this,Lc,r),p(this,bi,a),p(this,Dc,o),this.lastPoint=[NaN,NaN],b(this,xf,rA).call(this,o);const[l,h,c,f]=n(this,Nr);for(let g=0,m=e.length;g<m;g+=2)e[g]=(e[g]-l)/c,e[g+1]=(e[g+1]-h)/f;for(let g=0,m=s.length;g<m;g+=2)s[g]=(s[g]-l)/c,s[g+1]=(s[g+1]-h)/f}toSVGPath(){const e=[`M${n(this,mt)[4]} ${n(this,mt)[5]}`];for(let s=6,i=n(this,mt).length;s<i;s+=6){if(isNaN(n(this,mt)[s])){e.push(`L${n(this,mt)[s+4]} ${n(this,mt)[s+5]}`);continue}e.push(`C${n(this,mt)[s]} ${n(this,mt)[s+1]} ${n(this,mt)[s+2]} ${n(this,mt)[s+3]} ${n(this,mt)[s+4]} ${n(this,mt)[s+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,s,i,r],a){const o=i-e,l=r-s;let h,c;switch(a){case 0:h=L._rescale(n(this,mt),e,r,o,-l),c=L._rescale(n(this,Se),e,r,o,-l);break;case 90:h=L._rescaleAndSwap(n(this,mt),e,s,o,l),c=L._rescaleAndSwap(n(this,Se),e,s,o,l);break;case 180:h=L._rescale(n(this,mt),i,s,-o,l),c=L._rescale(n(this,Se),i,s,-o,l);break;case 270:h=L._rescaleAndSwap(n(this,mt),i,r,-o,-l),c=L._rescaleAndSwap(n(this,Se),i,r,-o,-l);break}return{outline:Array.from(h),points:[Array.from(c)]}}get box(){return n(this,Nr)}newOutliner(e,s,i,r,a,o=0){return new nu(e,s,i,r,a,o)}getNewOutline(e,s){const[i,r,a,o]=n(this,Nr),[l,h,c,f]=n(this,$o),g=a*c,m=o*f,A=i*c+l,y=r*f+h,v=this.newOutliner({x:n(this,Se)[0]*g+A,y:n(this,Se)[1]*m+y},n(this,$o),n(this,Lc),e,n(this,Dc),s??n(this,bi));for(let w=2;w<n(this,Se).length;w+=2)v.add({x:n(this,Se)[w]*g+A,y:n(this,Se)[w+1]*m+y});return v.getOutlines()}}$o=new WeakMap,Nr=new WeakMap,bi=new WeakMap,Dc=new WeakMap,Se=new WeakMap,Lc=new WeakMap,mt=new WeakMap,xf=new WeakSet,rA=function(e){const s=n(this,mt);let i=s[4],r=s[5];const a=[i,r,i,r];let o=i,l=r;const h=e?Math.max:Math.min;for(let f=6,g=s.length;f<g;f+=6){const m=s[f+4],A=s[f+5];if(isNaN(s[f]))I.pointBoundingBox(m,A,a),l<A?(o=m,l=A):l===A&&(o=h(o,m));else{const y=[1/0,1/0,-1/0,-1/0];I.bezierBoundingBox(i,r,...s.slice(f,f+6),y),I.rectBoundingBox(...y,a),l<y[3]?(o=y[2],l=y[3]):l===y[3]&&(o=h(o,y[2]))}i=m,r=A}const c=n(this,Nr);c[0]=a[0]-n(this,bi),c[1]=a[1]-n(this,bi),c[2]=a[2]-a[0]+2*n(this,bi),c[3]=a[3]-a[1]+2*n(this,bi),this.lastPoint=[o,l]};var Ic,Fc,pn,es,kf,aA,zo,Hd,Pf,oA,Mf,lA,Nc,bg;class mg{constructor(t,e=0,s=0,i=!0){d(this,kf);d(this,zo);d(this,Pf);d(this,Mf);d(this,Nc);d(this,Ic,void 0);d(this,Fc,void 0);d(this,pn,[]);d(this,es,[]);const r=[1/0,1/0,-1/0,-1/0],o=10**-4;for(const{x:A,y,width:v,height:w}of t){const S=Math.floor((A-e)/o)*o,_=Math.ceil((A+v+e)/o)*o,E=Math.floor((y-e)/o)*o,C=Math.ceil((y+w+e)/o)*o,T=[S,E,C,!0],x=[_,E,C,!1];n(this,pn).push(T,x),I.rectBoundingBox(S,E,_,C,r)}const l=r[2]-r[0]+2*s,h=r[3]-r[1]+2*s,c=r[0]-s,f=r[1]-s,g=n(this,pn).at(i?-1:-2),m=[g[0],g[2]];for(const A of n(this,pn)){const[y,v,w]=A;A[0]=(y-c)/l,A[1]=(v-f)/h,A[2]=(w-f)/h}p(this,Ic,new Float32Array([c,f,l,h])),p(this,Fc,m)}getOutlines(){n(this,pn).sort((e,s)=>e[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of n(this,pn))e[3]?(t.push(...b(this,Nc,bg).call(this,e)),b(this,Pf,oA).call(this,e)):(b(this,Mf,lA).call(this,e),t.push(...b(this,Nc,bg).call(this,e)));return b(this,kf,aA).call(this,t)}}Ic=new WeakMap,Fc=new WeakMap,pn=new WeakMap,es=new WeakMap,kf=new WeakSet,aA=function(t){const e=[],s=new Set;for(const a of t){const[o,l,h]=a;e.push([o,l,a],[o,h,a])}e.sort((a,o)=>a[1]-o[1]||a[0]-o[0]);for(let a=0,o=e.length;a<o;a+=2){const l=e[a][2],h=e[a+1][2];l.push(h),h.push(l),s.add(l),s.add(h)}const i=[];let r;for(;s.size>0;){const a=s.values().next().value;let[o,l,h,c,f]=a;s.delete(a);let g=o,m=l;for(r=[o,h],i.push(r);;){let A;if(s.has(c))A=c;else if(s.has(f))A=f;else break;s.delete(A),[o,l,h,c,f]=A,g!==o&&(r.push(g,m,o,m===l?l:h),g=o),m=m===l?h:l}r.push(g,m)}return new xw(i,n(this,Ic),n(this,Fc))},zo=new WeakSet,Hd=function(t){const e=n(this,es);let s=0,i=e.length-1;for(;s<=i;){const r=s+i>>1,a=e[r][0];if(a===t)return r;a<t?s=r+1:i=r-1}return i+1},Pf=new WeakSet,oA=function([,t,e]){const s=b(this,zo,Hd).call(this,t);n(this,es).splice(s,0,[t,e])},Mf=new WeakSet,lA=function([,t,e]){const s=b(this,zo,Hd).call(this,t);for(let i=s;i<n(this,es).length;i++){const[r,a]=n(this,es)[i];if(r!==t)break;if(r===t&&a===e){n(this,es).splice(i,1);return}}for(let i=s-1;i>=0;i--){const[r,a]=n(this,es)[i];if(r!==t)break;if(r===t&&a===e){n(this,es).splice(i,1);return}}},Nc=new WeakSet,bg=function(t){const[e,s,i]=t,r=[[e,s,i]],a=b(this,zo,Hd).call(this,i);for(let o=0;o<a;o++){const[l,h]=n(this,es)[o];for(let c=0,f=r.length;c<f;c++){const[,g,m]=r[c];if(!(h<=g||m<=l)){if(g>=l){if(m>h)r[c][1]=h;else{if(f===1)return[];r.splice(c,1),c--,f--}continue}r[c][2]=l,m>h&&r.push([e,h,m])}}}return r};var Oc,Go;class xw extends L{constructor(e,s,i){super();d(this,Oc,void 0);d(this,Go,void 0);p(this,Go,e),p(this,Oc,s),this.lastPoint=i}toSVGPath(){const e=[];for(const s of n(this,Go)){let[i,r]=s;e.push(`M${i} ${r}`);for(let a=2;a<s.length;a+=2){const o=s[a],l=s[a+1];o===i?(e.push(`V${l}`),r=l):l===r&&(e.push(`H${o}`),i=o)}e.push("Z")}return e.join(" ")}serialize([e,s,i,r],a){const o=[],l=i-e,h=r-s;for(const c of n(this,Go)){const f=new Array(c.length);for(let g=0;g<c.length;g+=2)f[g]=e+c[g]*l,f[g+1]=r-c[g+1]*h;o.push(f)}return o}get box(){return n(this,Oc)}get classNamesForOutlining(){return["highlightOutline"]}}Oc=new WeakMap,Go=new WeakMap;class Ag extends nu{newFreeDrawOutline(t,e,s,i,r,a){return new kw(t,e,s,i,r,a)}}class kw extends nA{newOutliner(t,e,s,i,r,a=0){return new Ag(t,e,s,i,r,a)}}var Uo,Bc,Ai,Or,Hc,he,$c,zc,Br,$e,Ee,Ut,jo,yi,Kt,Vo,ze,Gc,Uc,yg,Wo,$d,Rf,hA,Df,cA,Lf,dA,jc,wg,wi,In,gn,ba,If,uA,Xo,zd,Hr,Ml,Ff,fA,Nf,pA,Of,gA,Bf,mA,Hf,bA;const q=class q extends rt{constructor(e){super({...e,name:"highlightEditor"});d(this,Uc);d(this,Wo);d(this,Rf);d(this,Df);d(this,Lf);d(this,jc);d(this,wi);d(this,If);d(this,Xo);d(this,Hr);d(this,Ff);d(this,Nf);d(this,Hf);d(this,Uo,null);d(this,Bc,0);d(this,Ai,void 0);d(this,Or,null);d(this,Hc,null);d(this,he,null);d(this,$c,null);d(this,zc,0);d(this,Br,null);d(this,$e,null);d(this,Ee,null);d(this,Ut,!1);d(this,jo,null);d(this,yi,void 0);d(this,Kt,null);d(this,Vo,"");d(this,ze,void 0);d(this,Gc,"");this.color=e.color||q._defaultColor,p(this,ze,e.thickness||q._defaultThickness),p(this,yi,e.opacity||q._defaultOpacity),p(this,Ai,e.boxes||null),p(this,Gc,e.methodOfCreation||""),p(this,Vo,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(p(this,Ut,!0),b(this,Wo,$d).call(this,e),b(this,wi,In).call(this)):n(this,Ai)&&(p(this,Uo,e.anchorNode),p(this,Bc,e.anchorOffset),p(this,$c,e.focusNode),p(this,zc,e.focusOffset),b(this,Uc,yg).call(this),b(this,wi,In).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=q.prototype;return V(this,"_keyboardManager",new hd([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}get telemetryInitialData(){return{action:"added",type:n(this,Ut)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:n(this,ze),methodOfCreation:n(this,Gc)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}get commentColor(){return this.color}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;rt.initialize(e,s),q._defaultColor||(q._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case X.HIGHLIGHT_COLOR:q._defaultColor=s;break;case X.HIGHLIGHT_THICKNESS:q._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return n(this,jo)}updateParams(e,s){switch(e){case X.HIGHLIGHT_COLOR:b(this,Rf,hA).call(this,s);break;case X.HIGHLIGHT_THICKNESS:b(this,Df,cA).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[X.HIGHLIGHT_COLOR,q._defaultColor],[X.HIGHLIGHT_THICKNESS,q._defaultThickness]]}get propertiesToUpdate(){return[[X.HIGHLIGHT_COLOR,this.color||q._defaultColor],[X.HIGHLIGHT_THICKNESS,n(this,ze)||q._defaultThickness],[X.HIGHLIGHT_FREE,n(this,Ut)]]}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,Hc,new eu({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(b(this,Hr,Ml).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,b(this,Hr,Ml).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){b(this,jc,wg).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,wi,In).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?b(this,jc,wg).call(this):e&&(b(this,wi,In).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),s&&this.select()}rotate(e){var r,a,o;const{drawLayer:s}=this.parent;let i;n(this,Ut)?(e=(e-this.rotation+360)%360,i=b(r=q,gn,ba).call(r,n(this,$e).box,e)):i=b(a=q,gn,ba).call(a,[this.x,this.y,this.width,this.height],e),s.updateProperties(n(this,Ee),{bbox:i,root:{"data-main-rotation":e}}),s.updateProperties(n(this,Kt),{bbox:b(o=q,gn,ba).call(o,n(this,he).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();n(this,Vo)&&(e.setAttribute("aria-label",n(this,Vo)),e.setAttribute("role","mark")),n(this,Ut)?e.classList.add("free"):this.div.addEventListener("keydown",b(this,If,uA).bind(this),{signal:this._uiManager._signal});const s=p(this,Br,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=n(this,Or);const[i,r]=this.parentDimensions;return this.setDims(this.width*i,this.height*r),Fm(this,n(this,Br),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Kt),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(n(this,Kt),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:b(this,Xo,zd).call(this,!0);break;case 1:case 3:b(this,Xo,zd).call(this,!1);break}}select(){var e;super.select(),n(this,Kt)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,Kt),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),n(this,Kt)&&((e=this.parent)==null||e.drawLayer.updateProperties(n(this,Kt),{rootClass:{selected:!1}}),n(this,Ut)||b(this,Xo,zd).call(this,!1))}get _mustFixPosition(){return!n(this,Ut)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(n(this,Ee),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(n(this,Kt),{rootClass:{hidden:!e}}))}static startHighlighting(e,s,{target:i,x:r,y:a}){const{x:o,y:l,width:h,height:c}=i.getBoundingClientRect(),f=new AbortController,g=e.combinedSignal(f),m=A=>{f.abort(),b(this,Bf,mA).call(this,e,A)};window.addEventListener("blur",m,{signal:g}),window.addEventListener("pointerup",m,{signal:g}),window.addEventListener("pointerdown",vt,{capture:!0,passive:!1,signal:g}),window.addEventListener("contextmenu",je,{signal:g}),i.addEventListener("pointermove",b(this,Of,gA).bind(this,e),{signal:g}),this._freeHighlight=new Ag({x:r,y:a},[o,l,h,c],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.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 async deserialize(e,s,i){var y,v,w,S;let r=null;if(e instanceof Vb){const{data:{quadPoints:_,rect:E,rotation:C,id:T,color:x,opacity:P,popupRef:M,contentsObj:D},parent:{page:{pageNumber:R}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(x),opacity:P,quadPoints:_,boxes:null,pageIndex:R-1,rect:E.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:M,comment:(D==null?void 0:D.str)||null}}else if(e instanceof Wg){const{data:{inkLists:_,rect:E,rotation:C,id:T,color:x,borderStyle:{rawWidth:P},popupRef:M,contentsObj:D},parent:{page:{pageNumber:R}}}=e;r=e={annotationType:$.HIGHLIGHT,color:Array.from(x),thickness:P,inkLists:_,boxes:null,pageIndex:R-1,rect:E.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:M,comment:(D==null?void 0:D.str)||null}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,c=await super.deserialize(e,s,i);c.color=I.makeHexColor(...a),p(c,yi,h||1),l&&p(c,ze,e.thickness),c._initialData=r,e.comment&&c.setCommentData(e.comment);const[f,g]=c.pageDimensions,[m,A]=c.pageTranslation;if(o){const _=p(c,Ai,[]);for(let E=0;E<o.length;E+=8)_.push({x:(o[E]-m)/f,y:1-(o[E+1]-A)/g,width:(o[E+2]-o[E])/f,height:(o[E+1]-o[E+5])/g});b(y=c,Uc,yg).call(y),b(v=c,wi,In).call(v),c.rotate(c.rotation)}else if(l){p(c,Ut,!0);const _=l[0],E={x:_[0]-m,y:g-(_[1]-A)},C=new Ag(E,[0,0,f,g],1,n(c,ze)/2,!0,.001);for(let P=0,M=_.length;P<M;P+=2)E.x=_[P]-m,E.y=g-(_[P+1]-A),C.add(E);const{id:T,clipPathId:x}=s.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:c.color,"fill-opacity":c._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);b(w=c,Wo,$d).call(w,{highlightOutlines:C.getOutlines(),highlightId:T,clipPathId:x}),b(S=c,wi,In).call(S),c.rotate(c.parentRotation)}return c}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const s=this.getPDFRect(),i=rt._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),r={annotationType:$.HIGHLIGHT,color:i,opacity:n(this,yi),thickness:n(this,ze),quadPoints:b(this,Ff,fA).call(this),outlines:b(this,Nf,pA).call(this,s),pageIndex:this.pageIndex,rect:s,rotation:b(this,Hr,Ml).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(r),this.annotationElementId&&!b(this,Hf,bA).call(this,r)?null:(r.id=this.annotationElementId,r)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const s={rect:this.getPDFRect()};return this.hasEditedComment&&(s.popup=this.comment),e.updateEdited(s),null}static canCreateNewEmptyEditor(){return!1}};Uo=new WeakMap,Bc=new WeakMap,Ai=new WeakMap,Or=new WeakMap,Hc=new WeakMap,he=new WeakMap,$c=new WeakMap,zc=new WeakMap,Br=new WeakMap,$e=new WeakMap,Ee=new WeakMap,Ut=new WeakMap,jo=new WeakMap,yi=new WeakMap,Kt=new WeakMap,Vo=new WeakMap,ze=new WeakMap,Gc=new WeakMap,Uc=new WeakSet,yg=function(){const e=new mg(n(this,Ai),.001);p(this,$e,e.getOutlines()),[this.x,this.y,this.width,this.height]=n(this,$e).box;const s=new mg(n(this,Ai),.0025,.001,this._uiManager.direction==="ltr");p(this,he,s.getOutlines());const{lastPoint:i}=n(this,he);p(this,jo,[(i[0]-this.x)/this.width,(i[1]-this.y)/this.height])},Wo=new WeakSet,$d=function({highlightOutlines:e,highlightId:s,clipPathId:i}){var f,g;p(this,$e,e);const r=1.5;if(p(this,he,e.getNewOutline(n(this,ze)/2+r,.0025)),s>=0)p(this,Ee,s),p(this,Or,i),this.parent.drawLayer.finalizeDraw(s,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,Kt,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:n(this,he).box,path:{d:n(this,he).toSVGPath()}},!0));else if(this.parent){const m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(n(this,Ee),{bbox:b(f=q,gn,ba).call(f,n(this,$e).box,(m-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(n(this,Kt),{bbox:b(g=q,gn,ba).call(g,n(this,he).box,m),path:{d:n(this,he).toSVGPath()}})}const[a,o,l,h]=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[m,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/m,this.height=h*m/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[m,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/m,this.height=h*m/A;break}}const{lastPoint:c}=n(this,he);p(this,jo,[(c[0]-a)/l,(c[1]-o)/h])},Rf=new WeakSet,hA=function(e){const s=(a,o)=>{var l,h;this.color=a,p(this,yi,o),(l=this.parent)==null||l.drawLayer.updateProperties(n(this,Ee),{root:{fill:a,"fill-opacity":o}}),(h=n(this,Hc))==null||h.updateColor(a)},i=this.color,r=n(this,yi);this.addCommands({cmd:s.bind(this,e,q._defaultOpacity),undo:s.bind(this,i,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Df=new WeakSet,cA=function(e){const s=n(this,ze),i=r=>{p(this,ze,r),b(this,Lf,dA).call(this,r)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:X.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Lf=new WeakSet,dA=function(e){if(!n(this,Ut))return;b(this,Wo,$d).call(this,{highlightOutlines:n(this,$e).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},jc=new WeakSet,wg=function(){n(this,Ee)===null||!this.parent||(this.parent.drawLayer.remove(n(this,Ee)),p(this,Ee,null),this.parent.drawLayer.remove(n(this,Kt)),p(this,Kt,null))},wi=new WeakSet,In=function(e=this.parent){n(this,Ee)===null&&({id:St(this,Ee)._,clipPathId:St(this,Or)._}=e.drawLayer.draw({bbox:n(this,$e).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":n(this,yi)},rootClass:{highlight:!0,free:n(this,Ut)},path:{d:n(this,$e).toSVGPath()}},!1,!0),p(this,Kt,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:n(this,Ut)},bbox:n(this,he).box,path:{d:n(this,he).toSVGPath()}},n(this,Ut))),n(this,Br)&&(n(this,Br).style.clipPath=n(this,Or)))},gn=new WeakSet,ba=function([e,s,i,r],a){switch(a){case 90:return[1-s-r,e,r,i];case 180:return[1-e-i,1-s-r,i,r];case 270:return[s,1-e-i,r,i]}return[e,s,i,r]},If=new WeakSet,uA=function(e){q._keyboardManager.exec(this,e)},Xo=new WeakSet,zd=function(e){if(!n(this,Uo))return;const s=window.getSelection();e?s.setPosition(n(this,Uo),n(this,Bc)):s.setPosition(n(this,$c),n(this,zc))},Hr=new WeakSet,Ml=function(){return n(this,Ut)?this.rotation:0},Ff=new WeakSet,fA=function(){if(n(this,Ut))return null;const[e,s]=this.pageDimensions,[i,r]=this.pageTranslation,a=n(this,Ai),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:c,width:f,height:g}of a){const m=h*e+i,A=(1-c)*s+r;o[l]=o[l+4]=m,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=m+f*e,o[l+5]=o[l+7]=A-g*s,l+=8}return o},Nf=new WeakSet,pA=function(e){return n(this,$e).serialize(e,b(this,Hr,Ml).call(this))},Of=new WeakSet,gA=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Bf=new WeakSet,mA=function(e,s){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(s,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Hf=new WeakSet,bA=function(e){const{color:s}=this._initialData;return this.hasEditedComment||e.color.some((i,r)=>i!==s[r])},d(q,gn),d(q,Of),d(q,Bf),k(q,"_defaultColor",null),k(q,"_defaultOpacity",1),k(q,"_defaultThickness",12),k(q,"_type","highlight"),k(q,"_editorType",$.HIGHLIGHT),k(q,"_freeHighlightId",-1),k(q,"_freeHighlight",null),k(q,"_freeHighlightClipId","");let ru=q;var $r;class AA{constructor(){d(this,$r,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){n(this,$r)[t]=e}toSVGProperties(){const t=n(this,$r);return p(this,$r,Object.create(null)),{root:t}}reset(){p(this,$r,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){st("Not implemented")}}$r=new WeakMap;var Ce,qo,Dt,zr,Gr,mn,bn,An,Ur,Vc,vg,Wc,_g,Xc,Sg,jr,Rl,$f,yA,Yo,Gd,Vr,Dl,yn,Aa;const F=class F extends rt{constructor(e){super(e);d(this,Vc);d(this,Wc);d(this,Xc);d(this,jr);d(this,$f);d(this,Yo);d(this,Vr);d(this,yn);d(this,Ce,null);d(this,qo,void 0);k(this,"_colorPicker",null);k(this,"_drawId",null);p(this,qo,e.mustBeCommitted||!1),this._addOutlines(e)}_addOutlines(e){e.drawOutlines&&(b(this,Vc,vg).call(this,e),b(this,jr,Rl).call(this))}static _mergeSVGProperties(e,s){const i=new Set(Object.keys(e));for(const[r,a]of Object.entries(s))i.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){st("Not implemented")}static get typesMap(){st("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(n(F,Dt).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,s){const i=this.constructor.typesMap.get(e);i&&this._updateProperty(e,i,s)}static get defaultPropertiesToUpdate(){const e=[],s=this._defaultDrawingOptions;for(const[i,r]of this.typesMap)e.push([i,s[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:s}=this;for(const[i,r]of this.constructor.typesMap)e.push([i,s[r]]);return e}_updateProperty(e,s,i){const r=this._drawingOptions,a=r[s],o=l=>{var c,f;r.updateProperty(s,l);const h=n(this,Ce).updateProperty(s,l);h&&b(this,Vr,Dl).call(this,h),(c=this.parent)==null||c.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType&&((f=this._colorPicker)==null||f.update(l))};this.addCommands({cmd:o.bind(this,i),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,F._mergeSVGProperties(n(this,Ce).getPathResizingSVGProperties(b(this,Yo,Gd).call(this)),{bbox:b(this,yn,Aa).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,F._mergeSVGProperties(n(this,Ce).getPathResizedSVGProperties(b(this,Yo,Gd).call(this)),{bbox:b(this,yn,Aa).call(this)}))}_onTranslating(e,s){var i;(i=this.parent)==null||i.drawLayer.updateProperties(this._drawId,{bbox:b(this,yn,Aa).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,F._mergeSVGProperties(n(this,Ce).getPathTranslatedSVGProperties(b(this,Yo,Gd).call(this),this.parentDimensions),{bbox:b(this,yn,Aa).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.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(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,n(this,qo)&&(p(this,qo,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){b(this,Xc,Sg).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(b(this,jr,Rl).call(this),b(this,Vr,Dl).call(this,n(this,Ce).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),b(this,Xc,Sg).call(this)):e&&(this._uiManager.addShouldRescale(this),b(this,jr,Rl).call(this,e),s=!this.parent&&((i=this.div)==null?void 0:i.classList.contains("selectedEditor"))),super.setParent(e),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,F._mergeSVGProperties({bbox:b(this,yn,Aa).call(this)},n(this,Ce).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&b(this,Vr,Dl).call(this,n(this,Ce).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,s;this._isCopy&&(e=this.x,s=this.y);const i=super.render();i.classList.add("draw");const r=document.createElement("div");i.append(r),r.setAttribute("aria-hidden","true"),r.className="internal";const[a,o]=this.parentDimensions;return this.setDims(this.width*a,this.height*o),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,s),i}static createDrawerInstance(e,s,i,r,a){st("Not implemented")}static startDrawing(e,s,i,r){var v;const{target:a,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=r;if(n(F,bn)&&n(F,bn)!==c)return;const{viewport:{rotation:f}}=e,{width:g,height:m}=a.getBoundingClientRect(),A=p(F,zr,new AbortController),y=e.combinedSignal(A);if(n(F,mn)||p(F,mn,h),n(F,bn)??p(F,bn,c),window.addEventListener("pointerup",w=>{var S;n(F,mn)===w.pointerId?this._endDraw(w):(S=n(F,An))==null||S.delete(w.pointerId)},{signal:y}),window.addEventListener("pointercancel",w=>{var S;n(F,mn)===w.pointerId?this._currentParent.endDrawingSession():(S=n(F,An))==null||S.delete(w.pointerId)},{signal:y}),window.addEventListener("pointerdown",w=>{n(F,bn)===w.pointerType&&((n(F,An)||p(F,An,new Set)).add(w.pointerId),n(F,Dt).isCancellable()&&(n(F,Dt).removeLastElement(),n(F,Dt).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:y}),window.addEventListener("contextmenu",je,{signal:y}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:y}),a.addEventListener("touchmove",w=>{w.timeStamp===n(F,Ur)&&vt(w)},{signal:y}),e.toggleDrawing(),(v=s._editorUndoBar)==null||v.hide(),n(F,Dt)){e.drawLayer.updateProperties(this._currentDrawId,n(F,Dt).startNew(o,l,g,m,f));return}s.updateUIForDefaultProperties(this),p(F,Dt,this.createDrawerInstance(o,l,g,m,f)),p(F,Gr,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(n(F,Gr).toSVGProperties(),n(F,Dt).defaultSVGProperties),!0,!1)}static _drawMove(e){var a;if(p(F,Ur,-1),!n(F,Dt))return;const{offsetX:s,offsetY:i,pointerId:r}=e;if(n(F,mn)===r){if(((a=n(F,An))==null?void 0:a.size)>=1){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,n(F,Dt).add(s,i)),p(F,Ur,e.timeStamp),vt(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(F,Dt,null),p(F,Gr,null),p(F,bn,null),p(F,Ur,NaN)),n(F,zr)&&(n(F,zr).abort(),p(F,zr,null),p(F,mn,NaN),p(F,An,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,n(F,Dt).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const i=n(F,Dt),r=this._currentDrawId,a=i.getLastElement();s.addCommands({cmd:()=>{s.drawLayer.updateProperties(r,i.setLastElement(a))},undo:()=>{s.drawLayer.updateProperties(r,i.removeLastElement())},mustExec:!1,type:X.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack(X.DRAW_STEP),!n(F,Dt).isEmpty()){const{pageDimensions:[i,r],scale:a}=s,o=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:n(F,Dt).getOutlines(i*a,r*a,a,this._INNER_MARGIN),drawingOptions:n(F,Gr),mustBeCommitted:!e});return this._cleanup(!0),o}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,s,i,r,a,o){st("Not implemented")}static async deserialize(e,s,i){var f,g;const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:l}}=s.viewport,h=this.deserializeDraw(o,l,r,a,this._INNER_MARGIN,e),c=await super.deserialize(e,s,i);return c.createDrawingOptions(e),b(f=c,Vc,vg).call(f,{drawOutlines:h}),b(g=c,jr,Rl).call(g),c.onScaleChanging(),c.rotate(),c}serializeDraw(e){const[s,i]=this.pageTranslation,[r,a]=this.pageDimensions;return n(this,Ce).serialize([s,i,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};Ce=new WeakMap,qo=new WeakMap,Dt=new WeakMap,zr=new WeakMap,Gr=new WeakMap,mn=new WeakMap,bn=new WeakMap,An=new WeakMap,Ur=new WeakMap,Vc=new WeakSet,vg=function({drawOutlines:e,drawId:s,drawingOptions:i}){p(this,Ce,e),this._drawingOptions||(this._drawingOptions=i),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),s>=0?(this._drawId=s,this.parent.drawLayer.finalizeDraw(s,e.defaultProperties)):this._drawId=b(this,Wc,_g).call(this,e,this.parent),b(this,Vr,Dl).call(this,e.box)},Wc=new WeakSet,_g=function(e,s){const{id:i}=s.drawLayer.draw(F._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return i},Xc=new WeakSet,Sg=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},jr=new WeakSet,Rl=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=b(this,Wc,_g).call(this,n(this,Ce),e)}},$f=new WeakSet,yA=function([e,s,i,r]){const{parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[s,1-e,i*(o/a),r*(a/o)];case 180:return[1-e,1-s,i,r];case 270:return[1-s,e,i*(o/a),r*(a/o)];default:return[e,s,i,r]}},Yo=new WeakSet,Gd=function(){const{x:e,y:s,width:i,height:r,parentDimensions:[a,o],rotation:l}=this;switch(l){case 90:return[1-s,e,i*(a/o),r*(o/a)];case 180:return[1-e,1-s,i,r];case 270:return[s,1-e,i*(a/o),r*(o/a)];default:return[e,s,i,r]}},Vr=new WeakSet,Dl=function(e){if([this.x,this.y,this.width,this.height]=b(this,$f,yA).call(this,e),this.div){this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)}this._onResized()},yn=new WeakSet,Aa=function(){const{x:e,y:s,width:i,height:r,rotation:a,parentRotation:o,parentDimensions:[l,h]}=this;switch((a*4+o)/90){case 1:return[1-s-r,e,r,i];case 2:return[1-e-i,1-s-r,i,r];case 3:return[s,1-e-i,r,i];case 4:return[e,s-i*(l/h),r*(h/l),i*(l/h)];case 5:return[1-s,e,i*(l/h),r*(h/l)];case 6:return[1-e-r*(h/l),1-s,r*(h/l),i*(l/h)];case 7:return[s-i*(l/h),1-e-r*(h/l),i*(l/h),r*(h/l)];case 8:return[e-i,s-r,i,r];case 9:return[1-s,e-i,r,i];case 10:return[1-e,1-s,i,r];case 11:return[s-r,1-e,r,i];case 12:return[e-r*(h/l),s,r*(h/l),i*(l/h)];case 13:return[1-s-i*(l/h),e-r*(h/l),i*(l/h),r*(h/l)];case 14:return[1-e,1-s-i*(l/h),r*(h/l),i*(l/h)];case 15:return[s,1-e,i*(l/h),r*(h/l)];default:return[e,s,i,r]}},k(F,"_currentDrawId",-1),k(F,"_currentParent",null),d(F,Dt,null),d(F,zr,null),d(F,Gr,null),d(F,mn,NaN),d(F,bn,null),d(F,An,null),d(F,Ur,NaN),k(F,"_INNER_MARGIN",3);let au=F;var Ts,Lt,It,Wr,Ko,te,jt,Ge,Xr,qr,Yr,Qo,Ud;class Pw{constructor(t,e,s,i,r,a){d(this,Qo);d(this,Ts,new Float64Array(6));d(this,Lt,void 0);d(this,It,void 0);d(this,Wr,void 0);d(this,Ko,void 0);d(this,te,void 0);d(this,jt,"");d(this,Ge,0);d(this,Xr,new dd);d(this,qr,void 0);d(this,Yr,void 0);p(this,qr,s),p(this,Yr,i),p(this,Wr,r),p(this,Ko,a),[t,e]=b(this,Qo,Ud).call(this,t,e);const o=p(this,Lt,[NaN,NaN,NaN,NaN,t,e]);p(this,te,[t,e]),p(this,It,[{line:o,points:n(this,te)}]),n(this,Ts).set(o,0)}updateProperty(t,e){t==="stroke-width"&&p(this,Ko,e)}isEmpty(){return!n(this,It)||n(this,It).length===0}isCancellable(){return n(this,te).length<=10}add(t,e){[t,e]=b(this,Qo,Ud).call(this,t,e);const[s,i,r,a]=n(this,Ts).subarray(2,6),o=t-r,l=e-a;return Math.hypot(n(this,qr)*o,n(this,Yr)*l)<=2?null:(n(this,te).push(t,e),isNaN(s)?(n(this,Ts).set([r,a,t,e],2),n(this,Lt).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(n(this,Ts)[0])&&n(this,Lt).splice(6,6),n(this,Ts).set([s,i,r,a,t,e],0),n(this,Lt).push(...L.createBezierPoints(s,i,r,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(n(this,te).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,r){p(this,qr,s),p(this,Yr,i),p(this,Wr,r),[t,e]=b(this,Qo,Ud).call(this,t,e);const a=p(this,Lt,[NaN,NaN,NaN,NaN,t,e]);p(this,te,[t,e]);const o=n(this,It).at(-1);return o&&(o.line=new Float32Array(o.line),o.points=new Float32Array(o.points)),n(this,It).push({line:a,points:n(this,te)}),n(this,Ts).set(a,0),p(this,Ge,0),this.toSVGPath(),null}getLastElement(){return n(this,It).at(-1)}setLastElement(t){return n(this,It)?(n(this,It).push(t),p(this,Lt,t.line),p(this,te,t.points),p(this,Ge,0),{path:{d:this.toSVGPath()}}):n(this,Xr).setLastElement(t)}removeLastElement(){if(!n(this,It))return n(this,Xr).removeLastElement();n(this,It).pop(),p(this,jt,"");for(let t=0,e=n(this,It).length;t<e;t++){const{line:s,points:i}=n(this,It)[t];p(this,Lt,s),p(this,te,i),p(this,Ge,0),this.toSVGPath()}return{path:{d:n(this,jt)}}}toSVGPath(){const t=L.svgRound(n(this,Lt)[4]),e=L.svgRound(n(this,Lt)[5]);if(n(this,te).length===2)return p(this,jt,`${n(this,jt)} M ${t} ${e} Z`),n(this,jt);if(n(this,te).length<=6){const i=n(this,jt).lastIndexOf("M");p(this,jt,`${n(this,jt).slice(0,i)} M ${t} ${e}`),p(this,Ge,6)}if(n(this,te).length===4){const i=L.svgRound(n(this,Lt)[10]),r=L.svgRound(n(this,Lt)[11]);return p(this,jt,`${n(this,jt)} L ${i} ${r}`),p(this,Ge,12),n(this,jt)}const s=[];n(this,Ge)===0&&(s.push(`M ${t} ${e}`),p(this,Ge,6));for(let i=n(this,Ge),r=n(this,Lt).length;i<r;i+=6){const[a,o,l,h,c,f]=n(this,Lt).slice(i,i+6).map(L.svgRound);s.push(`C${a} ${o} ${l} ${h} ${c} ${f}`)}return p(this,jt,n(this,jt)+s.join(" ")),p(this,Ge,n(this,Lt).length),n(this,jt)}getOutlines(t,e,s,i){const r=n(this,It).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),n(this,Xr).build(n(this,It),t,e,s,n(this,Wr),n(this,Ko),i),p(this,Ts,null),p(this,Lt,null),p(this,It,null),p(this,jt,null),n(this,Xr)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ts=new WeakMap,Lt=new WeakMap,It=new WeakMap,Wr=new WeakMap,Ko=new WeakMap,te=new WeakMap,jt=new WeakMap,Ge=new WeakMap,Xr=new WeakMap,qr=new WeakMap,Yr=new WeakMap,Qo=new WeakSet,Ud=function(t,e){return L._normalizePoint(t,e,n(this,qr),n(this,Yr),n(this,Wr))};var ee,qc,Yc,Te,xs,ks,Jo,Zo,Kr,ss,Ns,zf,wA,Gf,vA,Uf,_A;class dd extends L{constructor(){super(...arguments);d(this,ss);d(this,zf);d(this,Gf);d(this,Uf);d(this,ee,void 0);d(this,qc,0);d(this,Yc,void 0);d(this,Te,void 0);d(this,xs,void 0);d(this,ks,void 0);d(this,Jo,void 0);d(this,Zo,void 0);d(this,Kr,void 0)}build(e,s,i,r,a,o,l){p(this,xs,s),p(this,ks,i),p(this,Jo,r),p(this,Zo,a),p(this,Kr,o),p(this,Yc,l??0),p(this,Te,e),b(this,Gf,vA).call(this)}get thickness(){return n(this,Kr)}setLastElement(e){return n(this,Te).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return n(this,Te).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:s}of n(this,Te)){if(e.push(`M${L.svgRound(s[4])} ${L.svgRound(s[5])}`),s.length===6){e.push("Z");continue}if(s.length===12&&isNaN(s[6])){e.push(`L${L.svgRound(s[10])} ${L.svgRound(s[11])}`);continue}for(let i=6,r=s.length;i<r;i+=6){const[a,o,l,h,c,f]=s.subarray(i,i+6).map(L.svgRound);e.push(`C${a} ${o} ${l} ${h} ${c} ${f}`)}}return e.join("")}serialize([e,s,i,r],a){const o=[],l=[],[h,c,f,g]=b(this,zf,wA).call(this);let m,A,y,v,w,S,_,E,C;switch(n(this,Zo)){case 0:C=L._rescale,m=e,A=s+r,y=i,v=-r,w=e+h*i,S=s+(1-c-g)*r,_=e+(h+f)*i,E=s+(1-c)*r;break;case 90:C=L._rescaleAndSwap,m=e,A=s,y=i,v=r,w=e+c*i,S=s+h*r,_=e+(c+g)*i,E=s+(h+f)*r;break;case 180:C=L._rescale,m=e+i,A=s,y=-i,v=r,w=e+(1-h-f)*i,S=s+c*r,_=e+(1-h)*i,E=s+(c+g)*r;break;case 270:C=L._rescaleAndSwap,m=e+i,A=s+r,y=-i,v=-r,w=e+(1-c-g)*i,S=s+(1-h-f)*r,_=e+(1-c)*i,E=s+(1-h)*r;break}for(const{line:T,points:x}of n(this,Te))o.push(C(T,m,A,y,v,a?new Array(T.length):null)),l.push(C(x,m,A,y,v,a?new Array(x.length):null));return{lines:o,points:l,rect:[w,S,_,E]}}static deserialize(e,s,i,r,a,{paths:{lines:o,points:l},rotation:h,thickness:c}){const f=[];let g,m,A,y,v;switch(h){case 0:v=L._rescale,g=-e/i,m=s/r+1,A=1/i,y=-1/r;break;case 90:v=L._rescaleAndSwap,g=-s/r,m=-e/i,A=1/r,y=1/i;break;case 180:v=L._rescale,g=e/i+1,m=-s/r,A=-1/i,y=1/r;break;case 270:v=L._rescaleAndSwap,g=s/r+1,m=e/i+1,A=-1/r,y=-1/i;break}if(!o){o=[];for(const S of l){const _=S.length;if(_===2){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1]]));continue}if(_===4){o.push(new Float32Array([NaN,NaN,NaN,NaN,S[0],S[1],NaN,NaN,NaN,NaN,S[2],S[3]]));continue}const E=new Float32Array(3*(_-2));o.push(E);let[C,T,x,P]=S.subarray(0,4);E.set([NaN,NaN,NaN,NaN,C,T],0);for(let M=4;M<_;M+=2){const D=S[M],R=S[M+1];E.set(L.createBezierPoints(C,T,x,P,D,R),(M-2)*3),[C,T,x,P]=[x,P,D,R]}}}for(let S=0,_=o.length;S<_;S++)f.push({line:v(o[S].map(E=>E??NaN),g,m,A,y),points:v(l[S].map(E=>E??NaN),g,m,A,y)});const w=new this.prototype.constructor;return w.build(f,i,r,1,h,c,a),w}get box(){return n(this,ee)}updateProperty(e,s){return e==="stroke-width"?b(this,Uf,_A).call(this,s):null}updateParentDimensions([e,s],i){const[r,a]=b(this,ss,Ns).call(this);p(this,xs,e),p(this,ks,s),p(this,Jo,i);const[o,l]=b(this,ss,Ns).call(this),h=o-r,c=l-a,f=n(this,ee);return f[0]-=h,f[1]-=c,f[2]+=2*h,f[3]+=2*c,f}updateRotation(e){return p(this,qc,e),{path:{transform:this.rotationTransform}}}get viewBox(){return n(this,ee).map(L.svgRound).join(" ")}get defaultProperties(){const[e,s]=n(this,ee);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`}}}get rotationTransform(){const[,,e,s]=n(this,ee);let i=0,r=0,a=0,o=0,l=0,h=0;switch(n(this,qc)){case 90:r=s/e,a=-e/s,l=e;break;case 180:i=-1,o=-1,l=e,h=s;break;case 270:r=-s/e,a=e/s,h=s;break;default:return""}return`matrix(${i} ${r} ${a} ${o} ${L.svgRound(l)} ${L.svgRound(h)})`}getPathResizingSVGProperties([e,s,i,r]){const[a,o]=b(this,ss,Ns).call(this),[l,h,c,f]=n(this,ee);if(Math.abs(c-a)<=L.PRECISION||Math.abs(f-o)<=L.PRECISION){const v=e+i/2-(l+c/2),w=s+r/2-(h+f/2);return{path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const g=(i-2*a)/(c-2*a),m=(r-2*o)/(f-2*o),A=c/i,y=f/r;return{path:{"transform-origin":`${L.svgRound(l)} ${L.svgRound(h)}`,transform:`${this.rotationTransform} scale(${A} ${y}) translate(${L.svgRound(a)} ${L.svgRound(o)}) scale(${g} ${m}) translate(${L.svgRound(-a)} ${L.svgRound(-o)})`}}}getPathResizedSVGProperties([e,s,i,r]){const[a,o]=b(this,ss,Ns).call(this),l=n(this,ee),[h,c,f,g]=l;if(l[0]=e,l[1]=s,l[2]=i,l[3]=r,Math.abs(f-a)<=L.PRECISION||Math.abs(g-o)<=L.PRECISION){const w=e+i/2-(h+f/2),S=s+r/2-(c+g/2);for(const{line:_,points:E}of n(this,Te))L._translate(_,w,S,_),L._translate(E,w,S,E);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const m=(i-2*a)/(f-2*a),A=(r-2*o)/(g-2*o),y=-m*(h+a)+e+a,v=-A*(c+o)+s+o;if(m!==1||A!==1||y!==0||v!==0)for(const{line:w,points:S}of n(this,Te))L._rescale(w,y,v,m,A,w),L._rescale(S,y,v,m,A,S);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,s],i){const[r,a]=i,o=n(this,ee),l=e-o[0],h=s-o[1];if(n(this,xs)===r&&n(this,ks)===a)for(const{line:c,points:f}of n(this,Te))L._translate(c,l,h,c),L._translate(f,l,h,f);else{const c=n(this,xs)/r,f=n(this,ks)/a;p(this,xs,r),p(this,ks,a);for(const{line:g,points:m}of n(this,Te))L._rescale(g,l,h,c,f,g),L._rescale(m,l,h,c,f,m);o[2]*=c,o[3]*=f}return o[0]=e,o[1]=s,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${L.svgRound(e)} ${L.svgRound(s)}`}}}get defaultSVGProperties(){const e=n(this,ee);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${L.svgRound(e[0])} ${L.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}ee=new WeakMap,qc=new WeakMap,Yc=new WeakMap,Te=new WeakMap,xs=new WeakMap,ks=new WeakMap,Jo=new WeakMap,Zo=new WeakMap,Kr=new WeakMap,ss=new WeakSet,Ns=function(e=n(this,Kr)){const s=n(this,Yc)+e/2*n(this,Jo);return n(this,Zo)%180===0?[s/n(this,xs),s/n(this,ks)]:[s/n(this,ks),s/n(this,xs)]},zf=new WeakSet,wA=function(){const[e,s,i,r]=n(this,ee),[a,o]=b(this,ss,Ns).call(this,0);return[e+a,s+o,i-2*a,r-2*o]},Gf=new WeakSet,vA=function(){const e=p(this,ee,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of n(this,Te)){if(r.length<=12){for(let l=4,h=r.length;l<h;l+=6)I.pointBoundingBox(r[l],r[l+1],e);continue}let a=r[4],o=r[5];for(let l=6,h=r.length;l<h;l+=6){const[c,f,g,m,A,y]=r.subarray(l,l+6);I.bezierBoundingBox(a,o,c,f,g,m,A,y,e),a=A,o=y}}const[s,i]=b(this,ss,Ns).call(this);e[0]=ne(e[0]-s,0,1),e[1]=ne(e[1]-i,0,1),e[2]=ne(e[2]+s,0,1),e[3]=ne(e[3]+i,0,1),e[2]-=e[0],e[3]-=e[1]},Uf=new WeakSet,_A=function(e){const[s,i]=b(this,ss,Ns).call(this);p(this,Kr,e);const[r,a]=b(this,ss,Ns).call(this),[o,l]=[r-s,a-i],h=n(this,ee);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h};class op extends AA{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:rt._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new op(this._viewParameters);return t.updateAll(this),t}}var jf,SA;const va=class va extends au{constructor(e){super({...e,name:"inkEditor"});d(this,jf);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,s){rt.initialize(e,s),this._defaultDrawingOptions=new op(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!0}static get typesMap(){return V(this,"typesMap",new Map([[X.INK_THICKNESS,"stroke-width"],[X.INK_COLOR,"stroke"],[X.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,s,i,r,a){return new Pw(e,s,i,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,s,i,r,a,o){return dd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){let r=null;if(e instanceof Wg){const{data:{inkLists:o,rect:l,rotation:h,id:c,color:f,opacity:g,borderStyle:{rawWidth:m},popupRef:A,contentsObj:y},parent:{page:{pageNumber:v}}}=e;r=e={annotationType:$.INK,color:Array.from(f),thickness:m,opacity:g,paths:{points:o},boxes:null,pageIndex:v-1,rect:l.slice(0),rotation:h,annotationElementId:c,id:c,deleted:!1,popupRef:A,comment:(y==null?void 0:y.str)||null}}const a=await super.deserialize(e,s,i);return a._initialData=r,e.comment&&a.setCommentData(e.comment),a}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new su(this)),[["colorPicker",this._colorPicker]]}get colorType(){return X.INK_COLOR}get colorValue(){return this._drawingOptions.stroke}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:s,parent:i}=this;s.updateSVGProperty("stroke-width"),i.drawLayer.updateProperties(e,s.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=va.getDefaultDrawingOptions({stroke:I.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:s,points:i,rect:r}=this.serializeDraw(e),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":l}}=this,h={annotationType:$.INK,color:rt._colorManager.convert(a),opacity:o,thickness:l,paths:{lines:s,points:i},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(h),e?(h.isCopy=!0,h):this.annotationElementId&&!b(this,jf,SA).call(this,h)?null:(h.id=this.annotationElementId,h)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:s,rect:i}=this.serializeDraw(!1),r={rect:i,thickness:this._drawingOptions["stroke-width"],points:s};return this.hasEditedComment&&(r.popup=this.comment),e.updateEdited(r),null}};jf=new WeakSet,SA=function(e){const{color:s,thickness:i,opacity:r,pageIndex:a}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((o,l)=>o!==s[l])||e.thickness!==i||e.opacity!==r||e.pageIndex!==a},k(va,"_type","ink"),k(va,"_editorType",$.INK),k(va,"_defaultDrawingOptions",null);let Eg=va;class Cg extends dd{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const yd=8,pl=3;var Qr,Kc,Tg,is,Vf,EA,Wf,CA,Qc,xg,tl,jd,Xf,TA,qf,xA,Yf,kA,Jc,kg,Zc,Pg,Kf,PA;class kt{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},r,a,o,l){let h=new OffscreenCanvas(1,1),c=h.getContext("2d",{alpha:!1});const f=200,g=c.font=`${s} ${i} ${f}px ${e}`,{actualBoundingBoxLeft:m,actualBoundingBoxRight:A,actualBoundingBoxAscent:y,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:S,width:_}=c.measureText(t),E=1.5,C=Math.ceil(Math.max(Math.abs(m)+Math.abs(A)||0,_)*E),T=Math.ceil(Math.max(Math.abs(y)+Math.abs(v)||f,Math.abs(w)+Math.abs(S)||f)*E);h=new OffscreenCanvas(C,T),c=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),c.font=g,c.filter="grayscale(1)",c.fillStyle="white",c.fillRect(0,0,C,T),c.fillStyle="black",c.fillText(t,C*(E-1)/2,T*(3-E)/2);const x=b(this,Jc,kg).call(this,c.getImageData(0,0,C,T).data),P=b(this,Yf,kA).call(this,x),M=b(this,Zc,Pg).call(this,P),D=b(this,Qc,xg).call(this,x,C,T,M);return this.processDrawnLines({lines:{curves:D,width:C,height:T},pageWidth:r,pageHeight:a,rotation:o,innerMargin:l,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,r){const[a,o,l]=b(this,Kf,PA).call(this,t),[h,c]=b(this,qf,xA).call(this,a,o,l,Math.hypot(o,l)*n(this,Qr).sigmaSFactor,n(this,Qr).sigmaR,n(this,Qr).kernelSize),f=b(this,Zc,Pg).call(this,c),g=b(this,Qc,xg).call(this,h,o,l,f);return this.processDrawnLines({lines:{curves:g,width:o,height:l},pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:r,mustSmooth:a,areContours:o}){i%180!==0&&([e,s]=[s,e]);const{curves:l,width:h,height:c}=t,f=t.thickness??0,g=[],m=Math.min(e/h,s/c),A=m/e,y=m/s,v=[];for(const{points:S}of l){const _=a?b(this,Xf,TA).call(this,S):S;if(!_)continue;v.push(_);const E=_.length,C=new Float32Array(E),T=new Float32Array(3*(E===2?2:E-2));if(g.push({line:T,points:C}),E===2){C[0]=_[0]*A,C[1]=_[1]*y,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[x,P,M,D]=_;x*=A,P*=y,M*=A,D*=y,C.set([x,P,M,D],0),T.set([NaN,NaN,NaN,NaN,x,P],0);for(let R=4;R<E;R+=2){const H=C[R]=_[R]*A,U=C[R+1]=_[R+1]*y;T.set(L.createBezierPoints(x,P,M,D,H,U),(R-2)*3),[x,P,M,D]=[M,D,H,U]}}if(g.length===0)return null;const w=o?new Cg:new dd;return w.build(g,e,s,1,i,o?0:f,r),{outline:w,newCurves:v,areContours:o,thickness:f,width:h,height:c}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:r}){let a=1/0,o=-1/0,l=0;for(const _ of t){l+=_.length;for(let E=2,C=_.length;E<C;E++){const T=_[E]-_[E-2];a=Math.min(a,T),o=Math.max(o,T)}}let h;a>=-128&&o<=127?h=Int8Array:a>=-32768&&o<=32767?h=Int16Array:h=Int32Array;const c=t.length,f=yd+pl*c,g=new Uint32Array(f);let m=0;g[m++]=f*Uint32Array.BYTES_PER_ELEMENT+(l-2*c)*h.BYTES_PER_ELEMENT,g[m++]=0,g[m++]=i,g[m++]=r,g[m++]=e?0:1,g[m++]=Math.max(0,Math.floor(s??0)),g[m++]=c,g[m++]=h.BYTES_PER_ELEMENT;for(const _ of t)g[m++]=_.length-2,g[m++]=_[0],g[m++]=_[1];const A=new CompressionStream("deflate-raw"),y=A.writable.getWriter();await y.ready,y.write(g);const v=h.prototype.constructor;for(const _ of t){const E=new v(_.length-2);for(let C=2,T=_.length;C<T;C++)E[C-2]=_[C]-_[C-2];y.write(E)}y.close();const w=await new Response(A.readable).arrayBuffer(),S=new Uint8Array(w);return Pm(S)}static async decompressSignature(t){try{const e=KA(t),{readable:s,writable:i}=new DecompressionStream("deflate-raw"),r=i.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let a=null,o=0;for await(const _ of s)a||(a=new Uint8Array(new Uint32Array(_.buffer,0,4)[0])),a.set(_,o),o+=_.length;const l=new Uint32Array(a.buffer,0,a.length>>2),h=l[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const c=l[2],f=l[3],g=l[4]===0,m=l[5],A=l[6],y=l[7],v=[],w=(yd+pl*A)*Uint32Array.BYTES_PER_ELEMENT;let S;switch(y){case Int8Array.BYTES_PER_ELEMENT:S=new Int8Array(a.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:S=new Int16Array(a.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:S=new Int32Array(a.buffer,w);break}o=0;for(let _=0;_<A;_++){const E=l[pl*_+yd],C=new Float32Array(E+2);v.push(C);for(let T=0;T<pl-1;T++)C[T]=l[pl*_+yd+T+1];for(let T=0;T<E;T++)C[T+2]=C[T]+S[o++]}return{areContours:g,thickness:m,outlines:v,width:c,height:f}}catch(e){return z(`decompressSignature: ${e}`),null}}}Qr=new WeakMap,Kc=new WeakSet,Tg=function(t,e,s,i){return s-=t,i-=e,s===0?i>0?0:4:s===1?i+6:2-i},is=new WeakMap,Vf=new WeakSet,EA=function(t,e,s,i,r,a,o){const l=b(this,Kc,Tg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(-h+l-o+16)%8,f=n(this,is)[2*c],g=n(this,is)[2*c+1];if(t[(s+f)*e+(i+g)]!==0)return c}return-1},Wf=new WeakSet,CA=function(t,e,s,i,r,a,o){const l=b(this,Kc,Tg).call(this,s,i,r,a);for(let h=0;h<8;h++){const c=(h+l+o+16)%8,f=n(this,is)[2*c],g=n(this,is)[2*c+1];if(t[(s+f)*e+(i+g)]!==0)return c}return-1},Qc=new WeakSet,xg=function(t,e,s,i){const r=t.length,a=new Int32Array(r);for(let c=0;c<r;c++)a[c]=t[c]<=i?1:0;for(let c=1;c<s-1;c++)a[c*e]=a[c*e+e-1]=0;for(let c=0;c<e;c++)a[c]=a[e*s-1-c]=0;let o=1,l;const h=[];for(let c=1;c<s-1;c++){l=1;for(let f=1;f<e-1;f++){const g=c*e+f,m=a[g];if(m===0)continue;let A=c,y=f;if(m===1&&a[g-1]===0)o+=1,y-=1;else if(m>=1&&a[g+1]===0)o+=1,y+=1,m>1&&(l=m);else{m!==1&&(l=Math.abs(m));continue}const v=[f,c],w=y===f+1,S={isHole:w,points:v,id:o,parent:0};h.push(S);let _;for(const R of h)if(R.id===l){_=R;break}_?_.isHole?S.parent=w?_.parent:l:S.parent=w?l:_.parent:S.parent=w?l:0;const E=b(this,Vf,EA).call(this,a,e,c,f,A,y,0);if(E===-1){a[g]=-o,a[g]!==1&&(l=Math.abs(a[g]));continue}let C=n(this,is)[2*E],T=n(this,is)[2*E+1];const x=c+C,P=f+T;A=x,y=P;let M=c,D=f;for(;;){const R=b(this,Wf,CA).call(this,a,e,M,D,A,y,1);C=n(this,is)[2*R],T=n(this,is)[2*R+1];const H=M+C,U=D+T;v.push(U,H);const W=M*e+D;if(a[W+1]===0?a[W]=-o:a[W]===1&&(a[W]=o),H===c&&U===f&&M===x&&D===P){a[g]!==1&&(l=Math.abs(a[g]));break}else A=M,y=D,M=H,D=U}}}return h},tl=new WeakSet,jd=function(t,e,s,i){if(s-e<=4){for(let x=e;x<s-2;x+=2)i.push(t[x],t[x+1]);return}const r=t[e],a=t[e+1],o=t[s-4]-r,l=t[s-3]-a,h=Math.hypot(o,l),c=o/h,f=l/h,g=c*a-f*r,m=l/o,A=1/h,y=Math.atan(m),v=Math.cos(y),w=Math.sin(y),S=A*(Math.abs(v)+Math.abs(w)),_=A*(1-S+S**2),E=Math.max(Math.atan(Math.abs(w+v)*_),Math.atan(Math.abs(w-v)*_));let C=0,T=e;for(let x=e+2;x<s-2;x+=2){const P=Math.abs(g-c*t[x+1]+f*t[x]);P>C&&(T=x,C=P)}C>(h*E)**2?(b(this,tl,jd).call(this,t,e,T+2,i),b(this,tl,jd).call(this,t,T,s,i)):i.push(r,a)},Xf=new WeakSet,TA=function(t){const e=[],s=t.length;return b(this,tl,jd).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},qf=new WeakSet,xA=function(t,e,s,i,r,a){const o=new Float32Array(a**2),l=-2*i**2,h=a>>1;for(let y=0;y<a;y++){const v=(y-h)**2;for(let w=0;w<a;w++)o[y*a+w]=Math.exp((v+(w-h)**2)/l)}const c=new Float32Array(256),f=-2*r**2;for(let y=0;y<256;y++)c[y]=Math.exp(y**2/f);const g=t.length,m=new Uint8Array(g),A=new Uint32Array(256);for(let y=0;y<s;y++)for(let v=0;v<e;v++){const w=y*e+v,S=t[w];let _=0,E=0;for(let T=0;T<a;T++){const x=y+T-h;if(!(x<0||x>=s))for(let P=0;P<a;P++){const M=v+P-h;if(M<0||M>=e)continue;const D=t[x*e+M],R=o[T*a+P]*c[Math.abs(D-S)];_+=D*R,E+=R}}const C=m[w]=Math.round(_/E);A[C]++}return[m,A]},Yf=new WeakSet,kA=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},Jc=new WeakSet,kg=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,r=1/0;for(let o=0,l=s.length;o<l;o++){const h=s[o]=t[o<<2];i=Math.max(i,h),r=Math.min(r,h)}const a=255/(i-r);for(let o=0,l=s.length;o<l;o++)s[o]=(s[o]-r)*a;return s},Zc=new WeakSet,Pg=function(t){let e,s=-1/0,i=-1/0;const r=t.findIndex(l=>l!==0);let a=r,o=r;for(e=r;e<256;e++){const l=t[e];l>s&&(e-a>i&&(i=e-a,o=e-1),s=l,a=e)}for(e=o-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Kf=new WeakSet,PA=function(t){const e=t,{width:s,height:i}=t,{maxDim:r}=n(this,Qr);let a=s,o=i;if(s>r||i>r){let g=s,m=i,A=Math.log2(Math.max(s,i)/r);const y=Math.floor(A);A=A===y?y-1:y;for(let w=0;w<A;w++){a=Math.ceil(g/2),o=Math.ceil(m/2);const S=new OffscreenCanvas(a,o);S.getContext("2d").drawImage(t,0,0,g,m,0,0,a,o),g=a,m=o,t!==e&&t.close(),t=S.transferToImageBitmap()}const v=Math.min(r/a,r/o);a=Math.round(a*v),o=Math.round(o*v)}const h=new OffscreenCanvas(a,o).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,a,o),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,a,o);const c=h.getImageData(0,0,a,o).data;return[b(this,Jc,kg).call(this,c),a,o]},d(kt,Kc),d(kt,Vf),d(kt,Wf),d(kt,Qc),d(kt,tl),d(kt,Xf),d(kt,qf),d(kt,Yf),d(kt,Jc),d(kt,Zc),d(kt,Kf),d(kt,Qr,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),d(kt,is,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class Xg extends AA{constructor(){super(),super.updateProperties({fill:rt._defaultLineColor,"stroke-width":0})}clone(){const t=new Xg;return t.updateAll(this),t}}class qg extends op{constructor(t){super(t),super.updateProperties({stroke:rt._defaultLineColor,"stroke-width":1})}clone(){const t=new qg(this._viewParameters);return t.updateAll(this),t}}var wn,Ps,vn,Jr;const de=class de extends au{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});d(this,wn,!1);d(this,Ps,null);d(this,vn,null);d(this,Jr,null);this._willKeepAspectRatio=!0,p(this,vn,e.signatureData||null),p(this,Ps,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,s){rt.initialize(e,s),this._defaultDrawingOptions=new Xg,this._defaultDrawnSignatureOptions=new qg(s.viewParameters)}static getDefaultDrawingOptions(e){const s=this._defaultDrawingOptions.clone();return s.updateProperties(e),s}static get supportMultipleDrawings(){return!1}static get typesMap(){return V(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!n(this,Ps)}}static computeTelemetryFinalData(e){const s=e.get("hasDescription");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),this._drawId===null)if(n(this,vn)){const{lines:r,mustSmooth:a,areContours:o,description:l,uuid:h,heightInPage:c}=n(this,vn),{rawDims:{pageWidth:f,pageHeight:g},rotation:m}=this.parent.viewport,A=kt.processDrawnLines({lines:r,pageWidth:f,pageHeight:g,rotation:m,innerMargin:de._INNER_MARGIN,mustSmooth:a,areContours:o});this.addSignature(A,c,l,h)}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:n(this,Ps)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(e){p(this,Jr,e),this.addEditToolbar()}getUuid(){return n(this,Jr)}get description(){return n(this,Ps)}set description(e){p(this,Ps,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(s=>{s==null||s.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:s,thickness:i,width:r,height:a}=n(this,vn),o=Math.max(r,a),l=kt.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:i,width:r,height:a},pageWidth:o,pageHeight:o,rotation:0,innerMargin:0,mustSmooth:!1,areContours:s});return{areContours:s,outline:l.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,r){const{x:a,y:o}=this,{outline:l}=p(this,vn,e);p(this,wn,l instanceof Cg),this.description=i;let h;n(this,wn)?h=de.getDefaultDrawingOptions():(h=de._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":l.thickness})),this._addOutlines({drawOutlines:l,drawingOptions:h});const[c,f]=this.parentDimensions,[,g]=this.pageDimensions;let m=s/g;m=m>=1?.5:m,this.width*=m/this.height,this.width>=1&&(m*=.9/this.width,this.width=.9),this.height=m,this.setDims(c*this.width,f*this.height),this.x=a,this.y=o,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return kt.process(e,s,i,r,de._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:r},rotation:a}=this.parent.viewport;return kt.extractContoursFromText(e,s,i,r,a,de._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:r}=this.parent.viewport;return kt.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:r,innerMargin:de._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=de.getDefaultDrawingOptions():(this._drawingOptions=de._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:s,points:i,rect:r}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":a}}=this,o={annotationType:$.SIGNATURE,isSignature:!0,areContours:n(this,wn),color:[0,0,0],thickness:n(this,wn)?0:a,pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(o),e?(o.paths={lines:s,points:i},o.uuid=n(this,Jr),o.isCopy=!0):o.lines=s,n(this,Ps)&&(o.accessibilityData={type:"Figure",alt:n(this,Ps)}),o}static deserializeDraw(e,s,i,r,a,o){return o.areContours?Cg.deserialize(e,s,i,r,a,o):dd.deserialize(e,s,i,r,a,o)}static async deserialize(e,s,i){var a;const r=await super.deserialize(e,s,i);return p(r,wn,e.areContours),r.description=((a=e.accessibilityData)==null?void 0:a.alt)||"",p(r,Jr,e.uuid),r}};wn=new WeakMap,Ps=new WeakMap,vn=new WeakMap,Jr=new WeakMap,k(de,"_type","signature"),k(de,"_editorType",$.SIGNATURE),k(de,"_defaultDrawingOptions",null);let Mg=de;var lt,Ft,_n,vi,Sn,el,_i,Zr,Ms,xe,sl,ta,Ll,ea,Il,il,Vd,nl,Wd,rl,Xd,td,Dg,al,qd,Qf,MA;class Rg extends rt{constructor(e){super({...e,name:"stampEditor"});d(this,ta);d(this,ea);d(this,il);d(this,nl);d(this,rl);d(this,td);d(this,al);d(this,Qf);d(this,lt,null);d(this,Ft,null);d(this,_n,null);d(this,vi,null);d(this,Sn,null);d(this,el,"");d(this,_i,null);d(this,Zr,!1);d(this,Ms,null);d(this,xe,!1);d(this,sl,!1);p(this,vi,e.bitmapUrl),p(this,Sn,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,s){rt.initialize(e,s)}static isHandlingMimeForPasting(e){return Sp.includes(e)}static paste(e,s){s.pasteEditor({mode:$.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const s=e.get("hasAltText");return{hasAltText:s.get(!0)??0,hasNoAltText:s.get(!1)??0}}async mlGuessAltText(e=null,s=!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:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!l)throw new Error("No response from the AI service.");if(l.error)throw new Error("Error from the AI service.");if(l.cancel)return null;if(!l.output)throw new Error("No valid response from the AI service.");const h=l.output;return await this.setGuessedAltText(h),s&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;n(this,Ft)&&(p(this,lt,null),this._uiManager.imageManager.deleteId(n(this,Ft)),(e=n(this,_i))==null||e.remove(),p(this,_i,null),n(this,Ms)&&(clearTimeout(n(this,Ms)),p(this,Ms,null))),super.remove()}rebuild(){if(!this.parent){n(this,Ft)&&b(this,il,Vd).call(this);return}super.rebuild(),this.div!==null&&(n(this,Ft)&&n(this,_i)===null&&b(this,il,Vd).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(n(this,_n)||n(this,lt)||n(this,vi)||n(this,Sn)||n(this,Ft)||n(this,Zr))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;return this._isCopy&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.createAltText(),n(this,Zr)||(n(this,lt)?b(this,nl,Wd).call(this):b(this,il,Vd).call(this)),this._isCopy&&this._moveAfterPaste(e,s),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,s){const{id:i,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,s);s.remove(),i&&this._uiManager.imageManager.isValidId(i)&&(p(this,Ft,i),r&&p(this,lt,r),p(this,Zr,!1),b(this,nl,Wd).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;n(this,Ms)!==null&&clearTimeout(n(this,Ms)),p(this,Ms,setTimeout(()=>{p(this,Ms,null),b(this,td,Dg).call(this)},200))}copyCanvas(e,s,i=!1){var m;e||(e=224);const{width:r,height:a}=n(this,lt),o=new Ds;let l=n(this,lt),h=r,c=a,f=null;if(s){if(r>s||a>s){const P=Math.min(s/r,s/a);h=Math.floor(r*P),c=Math.floor(a*P)}f=document.createElement("canvas");const A=f.width=Math.ceil(h*o.sx),y=f.height=Math.ceil(c*o.sy);n(this,xe)||(l=b(this,rl,Xd).call(this,A,y));const v=f.getContext("2d");v.filter=this._uiManager.hcmFilter;let w="white",S="#cfcfd8";this._uiManager.hcmFilter!=="none"?S="black":(m=window.matchMedia)!=null&&m.call(window,"(prefers-color-scheme: dark)").matches&&(w="#8f8f9d",S="#42414d");const _=15,E=_*o.sx,C=_*o.sy,T=new OffscreenCanvas(E*2,C*2),x=T.getContext("2d");x.fillStyle=w,x.fillRect(0,0,E*2,C*2),x.fillStyle=S,x.fillRect(0,0,E,C),x.fillRect(E,C,E,C),v.fillStyle=v.createPattern(T,"repeat"),v.fillRect(0,0,A,y),v.drawImage(l,0,0,l.width,l.height,0,0,A,y)}let g=null;if(i){let A,y;if(o.symmetric&&l.width<e&&l.height<e)A=l.width,y=l.height;else if(l=n(this,lt),r>e||a>e){const S=Math.min(e/r,e/a);A=Math.floor(r*S),y=Math.floor(a*S),n(this,xe)||(l=b(this,rl,Xd).call(this,A,y))}const w=new OffscreenCanvas(A,y).getContext("2d",{willReadFrequently:!0});w.drawImage(l,0,0,l.width,l.height,0,0,A,y),g={width:A,height:y,data:w.getImageData(0,0,A,y).data}}return{canvas:f,width:h,height:c,imageData:g}}static async deserialize(e,s,i){var v;let r=null,a=!1;if(e instanceof Wb){const{data:{rect:w,rotation:S,id:_,structParent:E,popupRef:C,contentsObj:T},container:x,parent:{page:{pageNumber:P}},canvas:M}=e;let D,R;M?(delete e.canvas,{id:D,bitmap:R}=i.imageManager.getFromCanvas(x.id,M),M.remove()):(a=!0,e._hasNoCanvas=!0);const H=((v=await s._structTree.getAriaAttributes(`${Hg}${_}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:$.STAMP,bitmapId:D,bitmap:R,pageIndex:P-1,rect:w.slice(0),rotation:S,annotationElementId:_,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:H},isSvg:!1,structParent:E,popupRef:C,comment:(T==null?void 0:T.str)||null}}const o=await super.deserialize(e,s,i),{rect:l,bitmap:h,bitmapUrl:c,bitmapId:f,isSvg:g,accessibilityData:m}=e;a?(i.addMissingCanvas(e.id,o),p(o,Zr,!0)):f&&i.imageManager.isValidId(f)?(p(o,Ft,f),h&&p(o,lt,h)):p(o,vi,c),p(o,xe,g);const[A,y]=o.pageDimensions;return o.width=(l[2]-l[0])/A,o.height=(l[3]-l[1])/y,m&&(o.altTextData=m),o._initialData=r,e.comment&&o.setCommentData(e.comment),p(o,sl,!!r),o}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:$.STAMP,bitmapId:n(this,Ft),pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,isSvg:n(this,xe),structTreeParentId:this._structTreeParentId};if(this.addComment(i),e)return i.bitmapUrl=b(this,al,qd).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i.isCopy=!0,i;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=b(this,Qf,MA).call(this,i);if(l.isSame)return null;l.isSameAltText?delete i.accessibilityData:i.accessibilityData.structParent=this._initialData.structParent??-1}if(i.id=this.annotationElementId,s===null)return i;s.stamps||(s.stamps=new Map);const o=n(this,xe)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(n(this,Ft)))s.stamps.set(n(this,Ft),{area:o,serialized:i}),i.bitmap=b(this,al,qd).call(this,!1);else if(n(this,xe)){const l=s.stamps.get(n(this,Ft));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=b(this,al,qd).call(this,!1))}return i}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const s={rect:this.getPDFRect()};return this.hasEditedComment&&(s.popup=this.comment),e.updateEdited(s),null}}lt=new WeakMap,Ft=new WeakMap,_n=new WeakMap,vi=new WeakMap,Sn=new WeakMap,el=new WeakMap,_i=new WeakMap,Zr=new WeakMap,Ms=new WeakMap,xe=new WeakMap,sl=new WeakMap,ta=new WeakSet,Ll=function(e,s=!1){if(!e){this.remove();return}p(this,lt,e.bitmap),s||(p(this,Ft,e.id),p(this,xe,e.isSvg)),e.file&&p(this,el,e.file.name),b(this,nl,Wd).call(this)},ea=new WeakSet,Il=function(){if(p(this,_n,null),this._uiManager.enableWaiting(!1),!!n(this,_i)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,lt)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&n(this,lt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},il=new WeakSet,Vd=function(){if(n(this,Ft)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(n(this,Ft)).then(i=>b(this,ta,Ll).call(this,i,!0)).finally(()=>b(this,ea,Il).call(this));return}if(n(this,vi)){const i=n(this,vi);p(this,vi,null),this._uiManager.enableWaiting(!0),p(this,_n,this._uiManager.imageManager.getFromUrl(i).then(r=>b(this,ta,Ll).call(this,r)).finally(()=>b(this,ea,Il).call(this)));return}if(n(this,Sn)){const i=n(this,Sn);p(this,Sn,null),this._uiManager.enableWaiting(!0),p(this,_n,this._uiManager.imageManager.getFromFile(i).then(r=>b(this,ta,Ll).call(this,r)).finally(()=>b(this,ea,Il).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Sp.join(",");const s=this._uiManager._signal;p(this,_n,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),b(this,ta,Ll).call(this,r)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>b(this,ea,Il).call(this))),e.click()},nl=new WeakSet,Wd=function(){var f;const{div:e}=this;let{width:s,height:i}=n(this,lt);const[r,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*r,i=this.height*a;else if(s>o*r||i>o*a){const g=Math.min(o*r/s,o*a/i);s*=g,i*=g}const[l,h]=this.parentDimensions;this.setDims(s*l/r,i*h/a),this._uiManager.enableWaiting(!1);const c=p(this,_i,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=s/r,this.height=i/a,(f=this._initialOptions)!=null&&f.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),b(this,td,Dg).call(this),n(this,sl)||(this.parent.addUndoableEditor(this),p(this,sl,!0)),this._reportTelemetry({action:"inserted_image"}),n(this,el)&&this.div.setAttribute("aria-description",n(this,el)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},rl=new WeakSet,Xd=function(e,s){const{width:i,height:r}=n(this,lt);let a=i,o=r,l=n(this,lt);for(;a>2*e||o>2*s;){const h=a,c=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*s&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const f=new OffscreenCanvas(a,o);f.getContext("2d").drawImage(l,0,0,h,c,0,0,a,o),l=f.transferToImageBitmap()}return l},td=new WeakSet,Dg=function(){const[e,s]=this.parentDimensions,{width:i,height:r}=this,a=new Ds,o=Math.ceil(i*e*a.sx),l=Math.ceil(r*s*a.sy),h=n(this,_i);if(!h||h.width===o&&h.height===l)return;h.width=o,h.height=l;const c=n(this,xe)?n(this,lt):b(this,rl,Xd).call(this,o,l),f=h.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(c,0,0,c.width,c.height,0,0,o,l)},al=new WeakSet,qd=function(e){if(e){if(n(this,xe)){const r=this._uiManager.imageManager.getSvgUrl(n(this,Ft));if(r)return r}const s=document.createElement("canvas");return{width:s.width,height:s.height}=n(this,lt),s.getContext("2d").drawImage(n(this,lt),0,0),s.toDataURL()}if(n(this,xe)){const[s,i]=this.pageDimensions,r=Math.round(this.width*s*Pn.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Pn.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(r,a);return o.getContext("2d").drawImage(n(this,lt),0,0,n(this,lt).width,n(this,lt).height,0,0,r,a),o.transferToImageBitmap()}return structuredClone(n(this,lt))},Qf=new WeakSet,MA=function(e){var o;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,r=e.pageIndex===s,a=(((o=e.accessibilityData)==null?void 0:o.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}},k(Rg,"_type","stamp"),k(Rg,"_editorType",$.STAMP);var sa,ol,Rs,En,Si,ke,Cn,ll,ia,ns,Ei,Nt,Ci,Tn,hl,O,xn,Jf,RA,Ue,hs,ed,Ig,sd,Fg,cl,Yd;const Xe=class Xe{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:r,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:c}){d(this,Jf);d(this,Ue);d(this,ed);d(this,sd);d(this,cl);d(this,sa,void 0);d(this,ol,!1);d(this,Rs,null);d(this,En,null);d(this,Si,null);d(this,ke,new Map);d(this,Cn,!1);d(this,ll,!1);d(this,ia,!1);d(this,ns,null);d(this,Ei,null);d(this,Nt,null);d(this,Ci,null);d(this,Tn,null);d(this,hl,-1);d(this,O,void 0);const f=[...n(Xe,xn).values()];if(!Xe._initialized){Xe._initialized=!0;for(const g of f)g.initialize(c,t)}t.registerEditorTypes(f),p(this,O,t),this.pageIndex=e,this.div=s,p(this,sa,r),p(this,Rs,a),this.viewport=h,p(this,Nt,l),this.drawLayer=o,this._structTree=i,n(this,O).addLayer(this)}get isEmpty(){return n(this,ke).size===0}get isInvisible(){return this.isEmpty&&n(this,O).getMode()===$.NONE}updateToolbar(t){n(this,O).updateToolbar(t)}updateMode(t=n(this,O).getMode()){switch(b(this,cl,Yd).call(this),t){case $.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case $.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case $.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;for(const s of n(Xe,xn).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=n(this,Nt))==null?void 0:e.div)}setEditingState(t){n(this,O).setEditingState(t)}addCommands(t){n(this,O).addCommands(t)}cleanUndoStack(t){n(this,O).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=n(this,Rs))==null||e.div.classList.toggle("disabled",!t)}async enable(){var s;p(this,ia,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),(s=n(this,Tn))==null||s.abort(),p(this,Tn,null);const t=new Set;for(const i of n(this,ke).values())i.enableEditing(),i.show(!0),i.annotationElementId&&(n(this,O).removeChangedExistingAnnotation(i),t.add(i.annotationElementId));if(!n(this,Rs)){p(this,ia,!1);return}const e=n(this,Rs).getEditableAnnotations();for(const i of e){if(i.hide(),n(this,O).isDeletedAnnotationElement(i.data.id)||t.has(i.data.id))continue;const r=await this.deserialize(i);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,ia,!1)}disable(){var i;if(p(this,ll,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),n(this,Nt)&&!n(this,Tn)){p(this,Tn,new AbortController);const r=n(this,O).combinedSignal(n(this,Tn));n(this,Nt).div.addEventListener("pointerdown",a=>{const{clientX:l,clientY:h,timeStamp:c}=a,f=n(this,hl);if(c-f>500){p(this,hl,c);return}p(this,hl,-1);const{classList:g}=this.div;g.toggle("getElements",!0);const m=document.elementsFromPoint(l,h);if(g.toggle("getElements",!1),!this.div.contains(m[0]))return;let A;const y=new RegExp(`^${Em}[0-9]+$`);for(const w of m)if(y.test(w.id)){A=w.id;break}if(!A)return;const v=n(this,ke).get(A);(v==null?void 0:v.annotationElementId)===null&&(a.stopPropagation(),a.preventDefault(),v.dblclick())},{signal:r,capture:!0})}const t=new Map,e=new Map;for(const r of n(this,ke).values())if(r.disableEditing(),!!r.annotationElementId){if(r.serialize()!==null){t.set(r.annotationElementId,r);continue}else e.set(r.annotationElementId,r);(i=this.getEditableAnnotation(r.annotationElementId))==null||i.show(),r.remove()}if(n(this,Rs)){const r=n(this,Rs).getEditableAnnotations();for(const a of r){const{id:o}=a.data;if(n(this,O).isDeletedAnnotationElement(o)){a.updateEdited({deleted:!0});continue}let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(n(this,O).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}b(this,cl,Yd).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const r of n(Xe,xn).values())s.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,ll,!1)}getEditableAnnotation(t){var e;return((e=n(this,Rs))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){n(this,O).getActive()!==t&&n(this,O).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=n(this,Nt))!=null&&t.div&&!n(this,Ci)){p(this,Ci,new AbortController);const e=n(this,O).combinedSignal(n(this,Ci));n(this,Nt).div.addEventListener("pointerdown",b(this,Jf,RA).bind(this),{signal:e}),n(this,Nt).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=n(this,Nt))!=null&&t.div&&n(this,Ci)&&(n(this,Ci).abort(),p(this,Ci,null),n(this,Nt).div.classList.remove("highlighting"))}enableClick(){if(n(this,En))return;p(this,En,new AbortController);const t=n(this,O).combinedSignal(n(this,En));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(){var t;(t=n(this,En))==null||t.abort(),p(this,En,null)}attach(t){n(this,ke).set(t.id,t);const{annotationElementId:e}=t;e&&n(this,O).isDeletedAnnotationElement(e)&&n(this,O).removeDeletedAnnotationElement(t)}detach(t){var e;n(this,ke).delete(t.id),(e=n(this,sa))==null||e.removePointerInTextLayer(t.contentDiv),!n(this,ll)&&t.annotationElementId&&n(this,O).addDeletedAnnotationElement(t)}remove(t){this.detach(t),n(this,O).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(n(this,O).addDeletedAnnotationElement(t.annotationElementId),rt.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.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),n(this,O).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!n(this,ia)),n(this,O).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!n(this,Si)&&(t._focusEventsAllowed=!1,p(this,Si,setTimeout(()=>{p(this,Si,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:n(this,O)._signal}),e.focus())},0))),t._structTreeParentId=(s=n(this,sa))==null?void 0:s.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),s=()=>{t.remove()};this.addCommands({cmd:e,undo:s,mustExec:!1})}getNextId(){return n(this,O).getId()}combinedSignal(t){return n(this,O).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=n(this,Ue,hs))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await n(this,O).updateMode(t.mode);const{offsetX:s,offsetY:i}=b(this,sd,Fg).call(this),r=this.getNextId(),a=b(this,ed,Ig).call(this,{parent:this,id:r,x:s,y:i,uiManager:n(this,O),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=n(Xe,xn).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,n(this,O)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),r=b(this,ed,Ig).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:n(this,O),isCentered:e,...s});return r&&this.add(r),r}addNewEditor(t={}){this.createAndAddNewEditor(b(this,sd,Fg).call(this),!0,t)}setSelected(t){n(this,O).setSelected(t)}toggleSelected(t){n(this,O).toggleSelected(t)}unselect(t){n(this,O).unselect(t)}pointerup(t){var i;const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!n(this,Cn)||(p(this,Cn,!1),(i=n(this,Ue,hs))!=null&&i.isDrawer&&n(this,Ue,hs).supportMultipleDrawings))return;if(!n(this,ol)){p(this,ol,!0);return}const s=n(this,O).getMode();if(s===$.STAMP||s===$.SIGNATURE){n(this,O).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var i;if(n(this,O).getMode()===$.HIGHLIGHT&&this.enableTextSelection(),n(this,Cn)){p(this,Cn,!1);return}const{isMac:e}=Wt.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,Cn,!0),(i=n(this,Ue,hs))!=null&&i.isDrawer){this.startDrawingSession(t);return}const s=n(this,O).getActive();p(this,ol,!s||s.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),n(this,ns)){n(this,Ue,hs).startDrawing(this,n(this,O),!1,t);return}n(this,O).setCurrentDrawingSession(this),p(this,ns,new AbortController);const e=n(this,O).combinedSignal(n(this,ns));this.div.addEventListener("blur",({relatedTarget:s})=>{s&&!this.div.contains(s)&&(p(this,Ei,null),this.commitOrRemove())},{signal:e}),n(this,Ue,hs).startDrawing(this,n(this,O),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,Ei,e);return}n(this,Ei)&&setTimeout(()=>{var e;(e=n(this,Ei))==null||e.focus(),p(this,Ei,null)},0)}endDrawingSession(t=!1){return n(this,ns)?(n(this,O).setCurrentDrawingSession(null),n(this,ns).abort(),p(this,ns,null),p(this,Ei,null),n(this,Ue,hs).endDrawing(t)):null}findNewParent(t,e,s){const i=n(this,O).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}commitOrRemove(){return n(this,ns)?(this.endDrawingSession(),!0):!1}onScaleChanging(){n(this,ns)&&n(this,Ue,hs).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=n(this,O).getActive())==null?void 0:t.parent)===this&&(n(this,O).commitOrRemove(),n(this,O).setActiveEditor(null)),n(this,Si)&&(clearTimeout(n(this,Si)),p(this,Si,null));for(const s of n(this,ke).values())(e=n(this,sa))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,n(this,ke).clear(),n(this,O).removeLayer(this)}render({viewport:t}){this.viewport=t,ra(this.div,t);for(const e of n(this,O).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){n(this,O).commitOrRemove(),b(this,cl,Yd).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,ra(this.div,{rotation:s}),e!==s)for(const i of n(this,ke).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return n(this,O).viewParameters.realScale}};sa=new WeakMap,ol=new WeakMap,Rs=new WeakMap,En=new WeakMap,Si=new WeakMap,ke=new WeakMap,Cn=new WeakMap,ll=new WeakMap,ia=new WeakMap,ns=new WeakMap,Ei=new WeakMap,Nt=new WeakMap,Ci=new WeakMap,Tn=new WeakMap,hl=new WeakMap,O=new WeakMap,xn=new WeakMap,Jf=new WeakSet,RA=function(t){n(this,O).unselectAll();const{target:e}=t;if(e===n(this,Nt).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&n(this,Nt).div.contains(e)){const{isMac:s}=Wt.platform;if(t.button!==0||t.ctrlKey&&s)return;n(this,O).showAllEditors("highlight",!0,!0),n(this,Nt).div.classList.add("free"),this.toggleDrawing(),ru.startHighlighting(this,n(this,O).direction==="ltr",{target:n(this,Nt).div,x:t.x,y:t.y}),n(this,Nt).div.addEventListener("pointerup",()=>{n(this,Nt).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:n(this,O)._signal}),t.preventDefault()}},Ue=new WeakSet,hs=function(){return n(Xe,xn).get(n(this,O).getMode())},ed=new WeakSet,Ig=function(t){const e=n(this,Ue,hs);return e?new e.prototype.constructor(t):null},sd=new WeakSet,Fg=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(r+o)/2-t,c=(a+l)/2-e,[f,g]=this.viewport.rotation%180===0?[h,c]:[c,h];return{offsetX:f,offsetY:g}},cl=new WeakSet,Yd=function(){for(const t of n(this,ke).values())t.isEmpty()&&t.remove()},k(Xe,"_initialized",!1),d(Xe,xn,new Map([pg,Eg,Rg,ru,Mg].map(t=>[t._editorType,t])));let Lg=Xe;var rs,se,na,id,Zf,DA,nd,Og,tp,LA,rd,Bg;const Et=class Et{constructor({pageIndex:t}){d(this,nd);d(this,tp);d(this,rd);d(this,rs,null);d(this,se,new Map);d(this,na,new Map);this.pageIndex=t}setParent(t){if(!n(this,rs)){p(this,rs,t);return}if(n(this,rs)!==t){if(n(this,se).size>0)for(const e of n(this,se).values())e.remove(),t.append(e);p(this,rs,t)}}static get _svgFactory(){return V(this,"_svgFactory",new iu)}draw(t,e=!1,s=!1){const i=St(Et,id)._++,r=b(this,nd,Og).call(this),a=Et._svgFactory.createElement("defs");r.append(a);const o=Et._svgFactory.createElement("path");a.append(o);const l=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),e&&n(this,na).set(i,o);const h=s?b(this,tp,LA).call(this,a,l):null,c=Et._svgFactory.createElement("use");return r.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(r,t),n(this,se).set(i,r),{id:i,clipPathId:`url(#${h})`}}drawOutline(t,e){const s=St(Et,id)._++,i=b(this,nd,Og).call(this),r=Et._svgFactory.createElement("defs");i.append(r);const a=Et._svgFactory.createElement("path");r.append(a);const o=`path_p${this.pageIndex}_${s}`;a.setAttribute("id",o),a.setAttribute("vector-effect","non-scaling-stroke");let l;if(e){const f=Et._svgFactory.createElement("mask");r.append(f),l=`mask_p${this.pageIndex}_${s}`,f.setAttribute("id",l),f.setAttribute("maskUnits","objectBoundingBox");const g=Et._svgFactory.createElement("rect");f.append(g),g.setAttribute("width","1"),g.setAttribute("height","1"),g.setAttribute("fill","white");const m=Et._svgFactory.createElement("use");f.append(m),m.setAttribute("href",`#${o}`),m.setAttribute("stroke","none"),m.setAttribute("fill","black"),m.setAttribute("fill-rule","nonzero"),m.classList.add("mask")}const h=Et._svgFactory.createElement("use");i.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return i.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(i,t),n(this,se).set(s,i),s}finalizeDraw(t,e){n(this,na).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var l;if(!e)return;const{root:s,bbox:i,rootClass:r,path:a}=e,o=typeof t=="number"?n(this,se).get(t):t;if(o){if(s&&b(this,rd,Bg).call(this,o,s),i&&b(l=Et,Zf,DA).call(l,o,i),r){const{classList:h}=o;for(const[c,f]of Object.entries(r))h.toggle(c,f)}if(a){const c=o.firstChild.firstChild;b(this,rd,Bg).call(this,c,a)}}}updateParent(t,e){if(e===this)return;const s=n(this,se).get(t);s&&(n(e,rs).append(s),n(this,se).delete(t),n(e,se).set(t,s))}remove(t){n(this,na).delete(t),n(this,rs)!==null&&(n(this,se).get(t).remove(),n(this,se).delete(t))}destroy(){p(this,rs,null);for(const t of n(this,se).values())t.remove();n(this,se).clear(),n(this,na).clear()}};rs=new WeakMap,se=new WeakMap,na=new WeakMap,id=new WeakMap,Zf=new WeakSet,DA=function(t,[e,s,i,r]){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*r}%`},nd=new WeakSet,Og=function(){const t=Et._svgFactory.create(1,1,!0);return n(this,rs).append(t),t.setAttribute("aria-hidden",!0),t},tp=new WeakSet,LA=function(t,e){const s=Et._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const r=Et._svgFactory.createElement("use");return s.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),i},rd=new WeakSet,Bg=function(t,e){for(const[s,i]of Object.entries(e))i===null?t.removeAttribute(s):t.setAttribute(s,i)},d(Et,Zf),d(Et,id,0);let Ng=Et;globalThis._pdfjsTestingUtils={HighlightOutliner:mg};globalThis.pdfjsLib={AbortException:kn,AnnotationEditorLayer:Lg,AnnotationEditorParamsType:X,AnnotationEditorType:$,AnnotationEditorUIManager:aa,AnnotationLayer:dg,AnnotationMode:ki,AnnotationType:wt,build:ow,ColorPicker:eu,createValidAbsoluteUrl:Cm,DOMSVGFactory:iu,DrawLayer:Ng,FeatureTest:Wt,fetchData:od,getDocument:ew,getFilenameFromUrl:QA,getPdfFilenameFromUrl:JA,getRGB:rp,getUuid:km,getXfaPageViewport:ty,GlobalWorkerOptions:Ti,ImageKind:wd,InvalidPDFException:vp,isDataScheme:np,isPdfFile:zg,isValidExplicitDest:dy,MathClamp:ne,noContextMenu:je,normalizeUnicode:qA,OPS:Fl,OutputScale:Ds,PasswordResponses:HA,PDFDataRangeTransport:kb,PDFDateString:Qd,PDFWorker:Bl,PermissionFlag:BA,PixelsPerInch:Pn,RenderingCancelledException:$g,ResponseException:Kd,setLayerDimensions:ra,shadow:V,SignatureExtractor:kt,stopEvent:vt,SupportedImageMimeTypes:Sp,TextLayer:Nl,TouchManager:Zd,updateUrlHash:Tm,Util:I,VerbosityLevel:ep,version:aw,XfaLayer:Db};export{kn as AbortException,Lg as AnnotationEditorLayer,X as AnnotationEditorParamsType,$ as AnnotationEditorType,aa as AnnotationEditorUIManager,dg as AnnotationLayer,ki as AnnotationMode,wt as AnnotationType,eu as ColorPicker,iu as DOMSVGFactory,Ng as DrawLayer,Wt as FeatureTest,Ti as GlobalWorkerOptions,wd as ImageKind,vp as InvalidPDFException,ne as MathClamp,Fl as OPS,Ds as OutputScale,kb as PDFDataRangeTransport,Qd as PDFDateString,Bl as PDFWorker,HA as PasswordResponses,BA as PermissionFlag,Pn as PixelsPerInch,$g as RenderingCancelledException,Kd as ResponseException,kt as SignatureExtractor,Sp as SupportedImageMimeTypes,Nl as TextLayer,Zd as TouchManager,I as Util,ep as VerbosityLevel,Db as XfaLayer,ow as build,Cm as createValidAbsoluteUrl,od as fetchData,ew as getDocument,QA as getFilenameFromUrl,JA as getPdfFilenameFromUrl,rp as getRGB,km as getUuid,ty as getXfaPageViewport,np as isDataScheme,zg as isPdfFile,dy as isValidExplicitDest,je as noContextMenu,qA as normalizeUnicode,ra as setLayerDimensions,V as shadow,vt as stopEvent,Tm as updateUrlHash,aw as version};