diff --git "a/assets/PaperReaderView-BI-diHx0.js" "b/assets/PaperReaderView-BI-diHx0.js" new file mode 100644--- /dev/null +++ "b/assets/PaperReaderView-BI-diHx0.js" @@ -0,0 +1,12 @@ +var Fp=Object.defineProperty;var Fd=c=>{throw TypeError(c)};var Dp=(c,t,e)=>t in c?Fp(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var Y=(c,t,e)=>Dp(c,typeof t!="symbol"?t+"":t,e),Bc=(c,t,e)=>t.has(c)||Fd("Cannot "+e);var r=(c,t,e)=>(Bc(c,t,"read from private field"),e?e.call(c):t.get(c)),A=(c,t,e)=>t.has(c)?Fd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,e),p=(c,t,e,s)=>(Bc(c,t,"write to private field"),s?s.call(c,e):t.set(c,e),e),m=(c,t,e)=>(Bc(c,t,"access private method"),e);var we=(c,t,e,s)=>({set _(i){p(c,t,i,e)},get _(){return r(c,t,s)}});import{_ as _l,N as Np,r as R,j as k,O as Tc,L as Qa,X as Op,c as du,n as Hp,Q as jp}from"./index-DxnSsCPb.js";import{u as Bp}from"./useQuery-DEE9grJB.js";import{e as $p,f as zp}from"./chatLaunch-Br3HZtqf.js";import{G as Gp}from"./github-BLfbl85d.js";import{E as Up}from"./external-link-DG-yMfwx.js";import{A as Wp,u as Vp,a as qp}from"./ArtifactWorkspace-rhI362JW.js";import{b as Xp}from"./usePapers-Bm_wWfRF.js";import{c as Yp}from"./chat-DU3GOumt.js";import{s as Yc}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as Kp}from"./ChatView-CEqcHigX.js";import"./chevron-down-ABx5iuRb.js";import"./papers-DGlL7Q8N.js";import"./katex.min-BSBacQyE.js";import"./hover-card-C0tdqTeN.js";import"./github-d4UhOz6_.js";import"./PaperPreviewLink-BSsRaO7m.js";import"./index-tT3sKWIF.js";import"./file-text-BUfOfDMN.js";import"./useInfiniteQuery-DDp8A6P0.js";import"./chatPrompts-CDY3UGU1.js";import"./openrouter-X7G4CaJv.js";var Ja={};Ja.d=(c,t)=>{for(var e in t)Ja.o(t,e)&&!Ja.o(c,e)&&Object.defineProperty(c,e,{enumerable:!0,get:t[e]})};Ja.o=(c,t)=>Object.prototype.hasOwnProperty.call(c,t);var Q=globalThis.pdfjsLib={};Ja.d(Q,{AbortException:()=>gr,AnnotationEditorLayer:()=>od,AnnotationEditorParamsType:()=>K,AnnotationEditorType:()=>tt,AnnotationEditorUIManager:()=>cr,AnnotationLayer:()=>Xm,AnnotationMode:()=>xi,ColorPicker:()=>lc,DOMSVGFactory:()=>Pd,DrawLayer:()=>dd,FeatureTest:()=>xe,GlobalWorkerOptions:()=>mi,ImageKind:()=>Pl,InvalidPDFException:()=>fu,MissingPDFException:()=>pr,OPS:()=>as,OutputScale:()=>th,PDFDataRangeTransport:()=>hf,PDFDateString:()=>_d,PDFWorker:()=>Rr,PasswordResponses:()=>tg,PermissionFlag:()=>Zp,PixelsPerInch:()=>Zi,RenderingCancelledException:()=>vd,TextLayer:()=>Rh,UnexpectedResponseException:()=>Lc,Util:()=>$,VerbosityLevel:()=>Rc,XfaLayer:()=>uf,build:()=>Rm,createValidAbsoluteUrl:()=>ng,fetchData:()=>Ic,getDocument:()=>ym,getFilenameFromUrl:()=>fg,getPdfFilenameFromUrl:()=>pg,getXfaPageViewport:()=>gg,isDataScheme:()=>Fc,isPdfFile:()=>wd,noContextMenu:()=>is,normalizeUnicode:()=>hg,setLayerDimensions:()=>lr,shadow:()=>ot,version:()=>Tm});const ve=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),uu=[1,0,0,1,0,0],Kc=[.001,0,0,.001,0,0],Qp=1e7,$c=1.35,Ue={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},xi={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Jp="pdfjs_internal_editor_",tt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},K={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35},Zp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},fe={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Pl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},qt={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,WIDGET:20},La={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Rc={ERRORS:0,WARNINGS:1,INFOS:5},as={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},tg={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Pc=Rc.WARNINGS;function eg(c){Number.isInteger(c)&&(Pc=c)}function sg(){return Pc}function kc(c){Pc>=Rc.INFOS&&console.log(`Info: ${c}`)}function nt(c){Pc>=Rc.WARNINGS&&console.log(`Warning: ${c}`)}function Ct(c){throw new Error(c)}function Qt(c,t){c||Ct(t)}function ig(c){switch(c==null?void 0:c.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function ng(c,t=null,e=null){if(!c)return null;try{if(e&&typeof c=="string"){if(e.addDefaultProtocol&&c.startsWith("www.")){const i=c.match(/\./g);(i==null?void 0:i.length)>=2&&(c=`http://${c}`)}if(e.tryConvertEncoding)try{c=cg(c)}catch{}}const s=t?new URL(c,t):new URL(c);if(ig(s))return s}catch{}return null}function ot(c,t,e,s=!1){return Object.defineProperty(c,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const nn=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Qc extends nn{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Jc extends nn{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class fu extends nn{constructor(t){super(t,"InvalidPDFException")}}class pr extends nn{constructor(t){super(t,"MissingPDFException")}}class Lc extends nn{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class rg extends nn{constructor(t){super(t,"FormatError")}}class gr extends nn{constructor(t){super(t,"AbortException")}}function pu(c){(typeof c!="object"||(c==null?void 0:c.length)===void 0)&&Ct("Invalid argument for bytesToString");const t=c.length,e=8192;if(t>24&255,c>>16&255,c>>8&255,c&255)}function Ad(c){const t=Object.create(null);for(const[e,s]of c)t[e]=s;return t}function og(){const c=new Uint8Array(4);return c[0]=1,new Uint32Array(c.buffer,0,1)[0]===1}function lg(){try{return new Function(""),!0}catch{return!1}}class xe{static get isLittleEndian(){return ot(this,"isLittleEndian",og())}static get isEvalSupported(){return ot(this,"isEvalSupported",lg())}static get isOffscreenCanvasSupported(){return ot(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get platform(){return typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.platform)=="string"?ot(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:typeof(navigator==null?void 0:navigator.userAgent)=="string"&&navigator.userAgent.includes("Firefox")}):ot(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){var t,e;return ot(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const zc=Array.from(Array(256).keys(),c=>c.toString(16).padStart(2,"0"));var Ai,kl,Zc;class ${static makeHexColor(t,e,s){return`#${zc[t]}${zc[e]}${zc[s]}`}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 applyTransform(t,e){const s=t[0]*e[0]+t[1]*e[2]+e[4],i=t[0]*e[1]+t[1]*e[3]+e[5];return[s,i]}static applyInverseTransform(t,e){const s=e[0]*e[3]-e[1]*e[2],i=(t[0]*e[3]-t[1]*e[2]+e[2]*e[5]-e[4]*e[3])/s,n=(-t[0]*e[1]+t[1]*e[0]+e[4]*e[1]-e[5]*e[0])/s;return[i,n]}static getAxialAlignedBoundingBox(t,e){const s=this.applyTransform(t,e),i=this.applyTransform(t.slice(2,4),e),n=this.applyTransform([t[0],t[3]],e),a=this.applyTransform([t[2],t[1]],e);return[Math.min(s[0],i[0],n[0],a[0]),Math.min(s[1],i[1],n[1],a[1]),Math.max(s[0],i[0],n[0],a[0]),Math.max(s[1],i[1],n[1],a[1])]}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t){const e=[t[0],t[2],t[1],t[3]],s=t[0]*e[0]+t[1]*e[2],i=t[0]*e[1]+t[1]*e[3],n=t[2]*e[0]+t[3]*e[2],a=t[2]*e[1]+t[3]*e[3],o=(s+a)/2,l=Math.sqrt((s+a)**2-4*(s*a-n*i))/2,h=o+l||1,d=o-l||1;return[Math.sqrt(h),Math.sqrt(d)]}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 n=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),a=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return n>a?null:[s,n,i,a]}static bezierBoundingBox(t,e,s,i,n,a,o,l,h){return 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)):h=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],m(this,Ai,Zc).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),h),m(this,Ai,Zc).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),h),h}}Ai=new WeakSet,kl=function(t,e,s,i,n,a,o,l,h,d){if(h<=0||h>=1)return;const u=1-h,f=h*h,g=f*h,b=u*(u*(u*t+3*h*e)+3*f*s)+g*i,y=u*(u*(u*n+3*h*a)+3*f*o)+g*l;d[0]=Math.min(d[0],b),d[1]=Math.min(d[1],y),d[2]=Math.max(d[2],b),d[3]=Math.max(d[3],y)},Zc=function(t,e,s,i,n,a,o,l,h,d,u,f){if(Math.abs(h)<1e-12){Math.abs(d)>=1e-12&&m(this,Ai,kl).call(this,t,e,s,i,n,a,o,l,-u/d,f);return}const g=d**2-4*u*h;if(g<0)return;const b=Math.sqrt(g),y=2*h;m(this,Ai,kl).call(this,t,e,s,i,n,a,o,l,(-d+b)/y,f),m(this,Ai,kl).call(this,t,e,s,i,n,a,o,l,(-d-b)/y,f)},A($,Ai);function cg(c){return decodeURIComponent(escape(c))}let Gc=null,Dd=null;function hg(c){return Gc||(Gc=/([\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,Dd=new Map([["ſt","ſt"]])),c.replaceAll(Gc,(t,e,s)=>e?e.normalize("NFKC"):Dd.get(s))}function dg(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const c=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(c);else for(let t=0;t<32;t++)c[t]=Math.floor(Math.random()*255);return pu(c)}const yd="pdfjs_internal_id_",$s={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};function ug(c){return Uint8Array.prototype.toBase64?c.toBase64():btoa(pu(c))}const Gs="http://www.w3.org/2000/svg",hn=class hn{};Y(hn,"CSS",96),Y(hn,"PDF",72),Y(hn,"PDF_TO_CSS_UNITS",hn.CSS/hn.PDF);let Zi=hn;async function Ic(c,t="text"){if(Da(c,document.baseURI)){const e=await fetch(c);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",c,!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 Al{constructor({viewBox:t,scale:e,rotation:s,offsetX:i=0,offsetY:n=0,dontFlip:a=!1}){this.viewBox=t,this.scale=e,this.rotation=s,this.offsetX=i,this.offsetY=n;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:h=-1,d=0,u=0,f=1;break;case 90:h=0,d=1,u=1,f=0;break;case 270:h=0,d=-1,u=-1,f=0;break;case 0:h=1,d=0,u=0,f=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}a&&(u=-u,f=-f);let g,b,y,w;h===0?(g=Math.abs(l-t[1])*e+i,b=Math.abs(o-t[0])*e+n,y=(t[3]-t[1])*e,w=(t[2]-t[0])*e):(g=Math.abs(o-t[0])*e+i,b=Math.abs(l-t[1])*e+n,y=(t[2]-t[0])*e,w=(t[3]-t[1])*e),this.transform=[h*e,d*e,u*e,f*e,g-h*e*o-u*e*l,b-d*e*o-f*e*l],this.width=y,this.height=w}get rawDims(){const{viewBox:t}=this;return ot(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:n=!1}={}){return new Al({viewBox:this.viewBox.slice(),scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){return $.applyTransform([t,e],this.transform)}convertToViewportRectangle(t){const e=$.applyTransform([t[0],t[1]],this.transform),s=$.applyTransform([t[2],t[3]],this.transform);return[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){return $.applyInverseTransform([t,e],this.transform)}}class vd extends nn{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Fc(c){const t=c.length;let e=0;for(;e=1&&i<=12?i-1:0;let n=parseInt(e[3],10);n=n>=1&&n<=31?n:1;let a=parseInt(e[4],10);a=a>=0&&a<=23?a:0;let 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 d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(a+=d,o+=u):h==="+"&&(a-=d,o-=u),new Date(Date.UTC(s,i,n,a,o,l))}}so=new WeakMap,A(_d,so);function gg(c,{scale:t=1,rotation:e=0}){const{width:s,height:i}=c.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new Al({viewBox:n,scale:t,rotation:e})}function Ed(c){if(c.startsWith("#")){const t=parseInt(c.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return c.startsWith("rgb(")?c.slice(4,-1).split(",").map(t=>parseInt(t)):c.startsWith("rgba(")?c.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(nt(`Not a valid color format: "${c}"`),[0,0,0])}function mg(c){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of c.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;c.set(e,Ed(s))}t.remove()}function It(c){const{a:t,b:e,c:s,d:i,e:n,f:a}=c.getTransform();return[t,e,s,i,n,a]}function zs(c){const{a:t,b:e,c:s,d:i,e:n,f:a}=c.getTransform().invertSelf();return[t,e,s,i,n,a]}function lr(c,t,e=!1,s=!0){if(t instanceof Al){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=c,o=xe.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,h=`var(--scale-factor) * ${n}px`,d=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=o?`round(down, ${h}, var(--scale-round-y, 1px))`:`calc(${h})`;!e||t.rotation%180===0?(a.width=d,a.height=u):(a.width=u,a.height=d)}s&&c.setAttribute("data-main-rotation",t.rotation)}class th{constructor(){const t=window.devicePixelRatio||1;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}}var Ci,un,os,fn,io,no,hc,gu,Ce,mu,bu,Ll,Au,sh;const Us=class Us{constructor(t){A(this,Ce);A(this,Ci,null);A(this,un,null);A(this,os);A(this,fn,null);A(this,io,null);p(this,os,t),r(Us,no)||p(Us,no,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"}))}render(){const t=p(this,Ci,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,os)._uiManager._signal;t.addEventListener("contextmenu",is,{signal:e}),t.addEventListener("pointerdown",m(Us,hc,gu),{signal:e});const s=p(this,fn,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,os).toolbarPosition;if(i){const{style:n}=t,a=r(this,os)._uiManager.direction==="ltr"?1-i[0]:i[0];n.insetInlineEnd=`${100*a}%`,n.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return m(this,Ce,Au).call(this),t}get div(){return r(this,Ci)}hide(){var t;r(this,Ci).classList.add("hidden"),(t=r(this,un))==null||t.hideDropdown()}show(){var t;r(this,Ci).classList.remove("hidden"),(t=r(this,io))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,Ce,Ll).call(this,e),r(this,fn).prepend(e,r(this,Ce,sh)),p(this,io,t)}addColorPicker(t){p(this,un,t);const e=t.renderButton();m(this,Ce,Ll).call(this,e),r(this,fn).prepend(e,r(this,Ce,sh))}remove(){var t;r(this,Ci).remove(),(t=r(this,un))==null||t.destroy(),p(this,un,null)}};Ci=new WeakMap,un=new WeakMap,os=new WeakMap,fn=new WeakMap,io=new WeakMap,no=new WeakMap,hc=new WeakSet,gu=function(t){t.stopPropagation()},Ce=new WeakSet,mu=function(t){r(this,os)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},bu=function(t){r(this,os)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},Ll=function(t){const e=r(this,os)._uiManager._signal;t.addEventListener("focusin",m(this,Ce,mu).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,Ce,bu).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",is,{signal:e})},Au=function(){const{editorType:t,_uiManager:e}=r(this,os),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",r(Us,no)[t]),m(this,Ce,Ll).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,fn).append(s)},sh=function(){const t=document.createElement("div");return t.className="divider",t},A(Us,hc),A(Us,no,null);let eh=Us;var ro,pn,gn,en,yu,vu,wu;class bg{constructor(t){A(this,en);A(this,ro,null);A(this,pn,null);A(this,gn);p(this,gn,t)}show(t,e,s){const[i,n]=m(this,en,vu).call(this,e,s),{style:a}=r(this,pn)||p(this,pn,m(this,en,yu).call(this));t.append(r(this,pn)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,pn).remove()}}ro=new WeakMap,pn=new WeakMap,gn=new WeakMap,en=new WeakSet,yu=function(){const t=p(this,pn,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",is,{signal:r(this,gn)._signal});const e=p(this,ro,document.createElement("div"));return e.className="buttons",t.append(e),m(this,en,wu).call(this),t},vu=function(t,e){let s=0,i=0;for(const n of t){const a=n.y+n.height;if(as){i=o,s=a;continue}e?o>i&&(i=o):o{r(this,gn).highlightSelection("floating_button")},{signal:s}),r(this,ro).append(t)};function rc(c,t,e){for(const s of e)t.addEventListener(s,c[s].bind(c))}function Ag(c){return Math.round(Math.min(255,Math.max(1,255*c))).toString(16).padStart(2,"0")}var dc;class yg{constructor(){A(this,dc,0)}get id(){return`${Jp}${we(this,dc)._++}`}}dc=new WeakMap;var Lr,ao,ge,Mr,Ml;const Ld=class Ld{constructor(){A(this,Mr);A(this,Lr,dg());A(this,ao,0);A(this,ge,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,',s=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),i=new Image;i.src=t;const n=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 ot(this,"_isSVGFittingCanvas",n)}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return m(this,Mr,Ml).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return m(this,Mr,Ml).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,Mr,Ml).call(this,t,s)}async getFromId(t){r(this,ge)||p(this,ge,new Map);const e=r(this,ge).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){r(this,ge)||p(this,ge,new Map);let s=r(this,ge).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_${r(this,Lr)}_${we(this,ao)._++}`,refCounter:1,isSvg:!1},r(this,ge).set(t,s),r(this,ge).set(s.id,s),s}getSvgUrl(t){const e=r(this,ge).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,ge)||p(this,ge,new Map);const e=r(this,ge).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:s}=e;if(!e.url&&!e.file){const n=new OffscreenCanvas(s.width,s.height);n.getContext("bitmaprenderer").transferFromImageBitmap(s),e.blobPromise=n.convertToBlob()}(i=s.close)==null||i.call(s),e.bitmap=null}isValidId(t){return t.startsWith(`image_${r(this,Lr)}_`)}};Lr=new WeakMap,ao=new WeakMap,ge=new WeakMap,Mr=new WeakSet,Ml=async function(t,e){r(this,ge)||p(this,ge,new Map);let s=r(this,ge).get(t);if(s===null)return null;if(s!=null&&s.bitmap)return s.refCounter+=1,s;try{s||(s={bitmap:null,id:`image_${r(this,Lr)}_${we(this,ao)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Ic(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=Ld._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((h,d)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,h()},a.onload=async()=>{const u=s.svgUrl=a.result;o.src=await n?`${u}#svgView(preserveAspectRatio(none))`:u},o.onerror=a.onerror=d});a.readAsDataURL(i),await l}else s.bitmap=await createImageBitmap(i);s.refCounter=1}catch(i){console.error(i),s=null}return r(this,ge).set(t,s),s&&r(this,ge).set(s.id,s),s};let ih=Ld;var se,Ti,oo,ie;class vg{constructor(t=128){A(this,se,[]);A(this,Ti,!1);A(this,oo);A(this,ie,-1);p(this,oo,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,Ti))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,ie)===-1){r(this,se).length>0&&(r(this,se).length=0),p(this,ie,0),r(this,se).push(l);return}if(a&&r(this,se)[r(this,ie)].type===n){o&&(l.undo=r(this,se)[r(this,ie)].undo),r(this,se)[r(this,ie)]=l;return}const h=r(this,ie)+1;h===r(this,oo)?r(this,se).splice(0,1):(p(this,ie,h),hn===e[a]))return fc._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?$.makeHexColor(...e):t}};Y(fc,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let nh=fc;var Ir,Ne,Xt,le,Fr,Vs,Dr,ls,Ri,Nr,mn,Es,cs,bn,lo,co,Or,ho,Ss,Pi,Hr,ki,xs,pc,Li,uo,Mi,An,fo,po,ne,pt,qs,yn,go,mo,Ii,Cs,Xs,bo,Ye,F,Il,rh,Eu,Su,Fl,xu,Cu,Tu,ah,Ru,oh,lh,Pu,_e,Ei,ku,Lu,ch,Mu,Na,hh;const Cr=class Cr{constructor(t,e,s,i,n,a,o,l,h,d,u){A(this,F);A(this,Ir,new AbortController);A(this,Ne,null);A(this,Xt,new Map);A(this,le,new Map);A(this,Fr,null);A(this,Vs,null);A(this,Dr,null);A(this,ls,new vg);A(this,Ri,null);A(this,Nr,0);A(this,mn,new Set);A(this,Es,null);A(this,cs,null);A(this,bn,new Set);A(this,lo,!1);A(this,co,!1);A(this,Or,!1);A(this,ho,null);A(this,Ss,null);A(this,Pi,null);A(this,Hr,null);A(this,ki,!1);A(this,xs,null);A(this,pc,new yg);A(this,Li,!1);A(this,uo,!1);A(this,Mi,null);A(this,An,null);A(this,fo,null);A(this,po,null);A(this,ne,tt.NONE);A(this,pt,new Set);A(this,qs,null);A(this,yn,null);A(this,go,null);A(this,mo,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});A(this,Ii,[0,0]);A(this,Cs,null);A(this,Xs,null);A(this,bo,null);A(this,Ye,null);const f=this._signal=r(this,Ir).signal;p(this,Xs,t),p(this,bo,e),p(this,Fr,s),this._eventBus=i,i._on("editingaction",this.onEditingAction.bind(this),{signal:f}),i._on("pagechanging",this.onPageChanging.bind(this),{signal:f}),i._on("scalechanging",this.onScaleChanging.bind(this),{signal:f}),i._on("rotationchanging",this.onRotationChanging.bind(this),{signal:f}),i._on("setpreference",this.onSetPreference.bind(this),{signal:f}),i._on("switchannotationeditorparams",g=>this.updateParams(g.type,g.value),{signal:f}),m(this,F,xu).call(this),m(this,F,Pu).call(this),m(this,F,ah).call(this),p(this,Vs,n.annotationStorage),p(this,ho,n.filterFactory),p(this,yn,a),p(this,Hr,o||null),p(this,lo,l),p(this,co,h),p(this,Or,d),p(this,po,u||null),this.viewParameters={realScale:Zi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=Cr.prototype,e=a=>r(a,Xs).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,n=this.TRANSLATE_BIG;return ot(this,"_keyboardManager",new yl([[["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)&&r(a,Xs).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,Xs).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:[-n,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[i,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-i],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,i],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}]]))}destroy(){var t,e,s,i;(t=r(this,Ye))==null||t.resolve(),p(this,Ye,null),(e=r(this,Ir))==null||e.abort(),p(this,Ir,null),this._signal=null;for(const n of r(this,le).values())n.destroy();r(this,le).clear(),r(this,Xt).clear(),r(this,bn).clear(),p(this,Ne,null),r(this,pt).clear(),r(this,ls).destroy(),(s=r(this,Fr))==null||s.destroy(),(i=r(this,xs))==null||i.hide(),p(this,xs,null),r(this,Ss)&&(clearTimeout(r(this,Ss)),p(this,Ss,null)),r(this,Cs)&&(clearTimeout(r(this,Cs)),p(this,Cs,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,po)}get useNewAltTextFlow(){return r(this,co)}get useNewAltTextWhenAddingImage(){return r(this,Or)}get hcmFilter(){return ot(this,"hcmFilter",r(this,yn)?r(this,ho).addHCMFilter(r(this,yn).foreground,r(this,yn).background):"none")}get direction(){return ot(this,"direction",getComputedStyle(r(this,Xs)).direction)}get highlightColors(){return ot(this,"highlightColors",r(this,Hr)?new Map(r(this,Hr).split(",").map(t=>t.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return ot(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}setMainHighlightColorPicker(t){p(this,fo,t)}editAltText(t,e=!1){var s;(s=r(this,Fr))==null||s.editAltText(this,t,e)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Or,e);break}}onPageChanging({pageNumber:t}){p(this,Nr,t-1)}focusMainContainer(){r(this,Xs).focus()}findParent(t,e){for(const s of r(this,le).values()){const{x:i,y:n,width:a,height:o}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+o)return s}return null}disableUserSelect(t=!1){r(this,bo).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,bn).add(t)}removeShouldRescale(t){r(this,bn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Zi.PDF_TO_CSS_UNITS;for(const e of r(this,bn))e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t=""){const e=document.getSelection();if(!e||e.isCollapsed)return;const{anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a}=e,o=e.toString(),h=m(this,F,Il).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(h);if(!d)return;e.empty();const u=m(this,F,rh).call(this,h),f=r(this,ne)===tt.NONE,g=()=>{u==null||u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:d,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:o}),f&&this.showAllEditors("highlight",!0,!0)};if(f){this.switchToMode(tt.HIGHLIGHT,g);return}g()}addToAnnotationStorage(t){!t.isEmpty()&&r(this,Vs)&&!r(this,Vs).has(t.id)&&r(this,Vs).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,ki)&&(p(this,ki,!1),m(this,F,Fl).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,pt))if(e.div.contains(t)){p(this,An,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,An))return;const[t,e]=r(this,An);p(this,An,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,F,ah).call(this),m(this,F,oh).call(this)}removeEditListeners(){m(this,F,Ru).call(this),m(this,F,lh).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,cs))if(s.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const s of r(this,cs))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Ne))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,pt)){const n=i.serialize(!0);n&&e.push(n)}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 n of e.items)for(const a of r(this,cs))if(a.isHandlingMimeForPasting(n.type)){a.paste(n,this.currentLayer);return}let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){nt(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const h=await i.deserialize(l);if(!h)return;n.push(h)}const a=()=>{for(const l of n)m(this,F,ch).call(this,l);m(this,F,hh).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){nt(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,ne)!==tt.NONE&&!this.isEditorHandlingKeyboard&&Cr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,ki)&&(p(this,ki,!1),m(this,F,Fl).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}}setEditingState(t){t?(m(this,F,Cu).call(this),m(this,F,oh).call(this),m(this,F,_e).call(this,{isEditing:r(this,ne)!==tt.NONE,isEmpty:m(this,F,Na).call(this),hasSomethingToUndo:r(this,ls).hasSomethingToUndo(),hasSomethingToRedo:r(this,ls).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,F,Tu).call(this),m(this,F,lh).call(this),m(this,F,_e).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,cs)){p(this,cs,t);for(const e of r(this,cs))m(this,F,Ei).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,pc).id}get currentLayer(){return r(this,le).get(r(this,Nr))}getLayer(t){return r(this,le).get(t)}get currentPageIndex(){return r(this,Nr)}addLayer(t){r(this,le).set(t.pageIndex,t),r(this,Li)?t.enable():t.disable()}removeLayer(t){r(this,le).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(r(this,ne)!==t&&!(r(this,Ye)&&(await r(this,Ye).promise,!r(this,Ye)))){if(p(this,Ye,Promise.withResolvers()),p(this,ne,t),t===tt.NONE){this.setEditingState(!1),m(this,F,Lu).call(this),r(this,Ye).resolve();return}this.setEditingState(!0),await m(this,F,ku).call(this),this.unselectAll();for(const i of r(this,le).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),r(this,Ye).resolve();return}for(const i of r(this,Xt).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();r(this,Ye).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,ne)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,cs)){switch(t){case K.CREATE:this.currentLayer.addNewEditor();return;case K.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,fo))==null||s.updateColor(e);break;case K.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,go)||p(this,go,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,pt))i.updateParams(t,e);for(const i of r(this,cs))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,Xt).values())a.editorType===t&&a.show(e);(((n=r(this,go))==null?void 0:n.get(K.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,F,Ei).call(this,[[K.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,uo)!==t){p(this,uo,t);for(const e of r(this,le).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,Xt).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,Xt).get(t)}addEditor(t){r(this,Xt).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,Ss)&&clearTimeout(r(this,Ss)),p(this,Ss,setTimeout(()=>{this.focusMainContainer(),p(this,Ss,null)},0))),r(this,Xt).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,mn).has(t.annotationElementId))&&((e=r(this,Vs))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,mn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,mn).has(t)}removeDeletedAnnotationElement(t){r(this,mn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Ne)!==t&&(p(this,Ne,t),t&&m(this,F,Ei).call(this,t.propertiesToUpdate))}updateUI(t){r(this,F,Mu)===t&&m(this,F,Ei).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,pt).has(t)){r(this,pt).delete(t),t.unselect(),m(this,F,_e).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,pt).add(t),t.select(),m(this,F,Ei).call(this,t.propertiesToUpdate),m(this,F,_e).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,pt))e!==t&&e.unselect();r(this,pt).clear(),r(this,pt).add(t),t.select(),m(this,F,Ei).call(this,t.propertiesToUpdate),m(this,F,_e).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,pt).has(t)}get firstSelectedEditor(){return r(this,pt).values().next().value}unselect(t){t.unselect(),r(this,pt).delete(t),m(this,F,_e).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,pt).size!==0}get isEnterHandled(){return r(this,pt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,ls).undo(),m(this,F,_e).call(this,{hasSomethingToUndo:r(this,ls).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,F,Na).call(this)})}redo(){r(this,ls).redo(),m(this,F,_e).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,ls).hasSomethingToRedo(),isEmpty:m(this,F,Na).call(this)})}addCommands(t){r(this,ls).add(t),m(this,F,_e).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,F,Na).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,pt)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)m(this,F,ch).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Ne))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Ne)||this.hasSelection}selectAll(){for(const t of r(this,pt))t.commit();m(this,F,hh).call(this,r(this,Xt).values())}unselectAll(){if(!(r(this,Ne)&&(r(this,Ne).commitOrRemove(),r(this,ne)!==tt.NONE))&&this.hasSelection){for(const t of r(this,pt))t.unselect();r(this,pt).clear(),m(this,F,_e).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,Ii)[0]+=t,r(this,Ii)[1]+=e;const[i,n]=r(this,Ii),a=[...r(this,pt)],o=1e3;r(this,Cs)&&clearTimeout(r(this,Cs)),p(this,Cs,setTimeout(()=>{p(this,Cs,null),r(this,Ii)[0]=r(this,Ii)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,Xt).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,Xt).has(l.id)&&l.translateInPage(-i,-n)},mustExec:!1})},o));for(const l of a)l.translateInPage(t,e)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,Es,new Map);for(const t of r(this,pt))r(this,Es).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,Es))return!1;this.disableUserSelect(!1);const t=r(this,Es);p(this,Es,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},o]of t)o.newX=i,o.newY=n,o.newPageIndex=a,e||(e=i!==o.savedX||n!==o.savedY||a!==o.savedPageIndex);if(!e)return!1;const s=(i,n,a,o)=>{if(r(this,Xt).has(i.id)){const l=r(this,le).get(o);l?i._setParentAndPosition(l,n,a):(i.pageIndex=o,i.x=n,i.y=a)}};return this.addCommands({cmd:()=>{for(const[i,{newX:n,newY:a,newPageIndex:o}]of t)s(i,n,a,o)},undo:()=>{for(const[i,{savedX:n,savedY:a,savedPageIndex:o}]of t)s(i,n,a,o)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(r(this,Es))for(const s of r(this,Es).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())||r(this,pt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Ne)===t}getActive(){return r(this,Ne)}getMode(){return r(this,ne)}get imageManager(){return ot(this,"imageManager",new ih)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,d=e.rangeCount;h({x:(d-i)/a,y:1-(h+u-s)/n,width:f/a,height:u/n});break;case"180":o=(h,d,u,f)=>({x:1-(h+u-s)/n,y:1-(d+f-i)/a,width:u/n,height:f/a});break;case"270":o=(h,d,u,f)=>({x:1-(d+f-i)/a,y:(h-s)/n,width:f/a,height:u/n});break;default:o=(h,d,u,f)=>({x:(h-s)/n,y:(d-i)/a,width:u/n,height:f/a});break}const l=[];for(let h=0,d=e.rangeCount;h{f.type==="pointerup"&&f.button!==0||(h.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&m(this,F,Fl).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}},Fl=function(t=""){r(this,ne)===tt.HIGHLIGHT?this.highlightSelection(t):r(this,lo)&&m(this,F,Eu).call(this)},xu=function(){document.addEventListener("selectionchange",m(this,F,Su).bind(this),{signal:this._signal})},Cu=function(){if(r(this,Pi))return;p(this,Pi,new AbortController);const t=this.combinedSignal(r(this,Pi));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Tu=function(){var t;(t=r(this,Pi))==null||t.abort(),p(this,Pi,null)},ah=function(){if(r(this,Mi))return;p(this,Mi,new AbortController);const t=this.combinedSignal(r(this,Mi));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Ru=function(){var t;(t=r(this,Mi))==null||t.abort(),p(this,Mi,null)},oh=function(){if(r(this,Ri))return;p(this,Ri,new AbortController);const t=this.combinedSignal(r(this,Ri));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})},lh=function(){var t;(t=r(this,Ri))==null||t.abort(),p(this,Ri,null)},Pu=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},_e=function(t){Object.entries(t).some(([s,i])=>r(this,mo)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,mo),t)}),r(this,ne)===tt.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,F,Ei).call(this,[[K.HIGHLIGHT_FREE,!0]]))},Ei=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},ku=async function(){if(!r(this,Li)){p(this,Li,!0);const t=[];for(const e of r(this,le).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,Xt).values())e.enable()}},Lu=function(){if(this.unselectAll(),r(this,Li)){p(this,Li,!1);for(const t of r(this,le).values())t.disable();for(const t of r(this,Xt).values())t.disable()}},ch=function(t){const e=r(this,le).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Mu=function(){let t=null;for(t of r(this,pt));return t},Na=function(){if(r(this,Xt).size===0)return!0;if(r(this,Xt).size===1)for(const t of r(this,Xt).values())return t.isEmpty();return!1},hh=function(t){for(const e of r(this,pt))e.unselect();r(this,pt).clear();for(const e of t)e.isEmpty()||(r(this,pt).add(e),e.select());m(this,F,_e).call(this,{hasSelectedEditor:this.hasSelection})},Y(Cr,"TRANSLATE_SMALL",1),Y(Cr,"TRANSLATE_BIG",10);let cr=Cr;var re,Ts,hs,jr,Rs,Oe,Br,Ps,ke,Ys,vn,ks,Fi,vs,Oa,Dl;const Ee=class Ee{constructor(t){A(this,vs);A(this,re,null);A(this,Ts,!1);A(this,hs,null);A(this,jr,null);A(this,Rs,null);A(this,Oe,null);A(this,Br,!1);A(this,Ps,null);A(this,ke,null);A(this,Ys,null);A(this,vn,null);A(this,ks,!1);p(this,ke,t),p(this,ks,t._uiManager.useNewAltTextFlow),r(Ee,Fi)||p(Ee,Fi,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){Ee._l10n??(Ee._l10n=t)}async render(){const t=p(this,hs,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,jr,document.createElement("span"));t.append(e),r(this,ks)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(Ee,Fi).missing),e.setAttribute("data-l10n-id",r(Ee,Fi)["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=r(this,ke)._uiManager._signal;t.addEventListener("contextmenu",is,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,ke)._uiManager.editAltText(r(this,ke)),r(this,ks)&&r(this,ke)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,vs,Oa)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Br,!0),i(n))},{signal:s}),await m(this,vs,Dl).call(this),t}finish(){r(this,hs)&&(r(this,hs).focus({focusVisible:r(this,Br)}),p(this,Br,!1))}isEmpty(){return r(this,ks)?r(this,re)===null:!r(this,re)&&!r(this,Ts)}hasData(){return r(this,ks)?r(this,re)!==null||!!r(this,Ys):this.isEmpty()}get guessedText(){return r(this,Ys)}async setGuessedText(t){r(this,re)===null&&(p(this,Ys,t),p(this,vn,await Ee._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,vs,Dl).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,ks)||r(this,re)){(e=r(this,Ps))==null||e.remove(),p(this,Ps,null);return}if(!r(this,Ps)){const s=p(this,Ps,document.createElement("div"));s.className="noAltTextBadge",r(this,ke).div.append(s)}r(this,Ps).classList.toggle("hidden",!t)}serialize(t){let e=r(this,re);return!t&&r(this,Ys)===e&&(e=r(this,vn)),{altText:e,decorative:r(this,Ts),guessedText:r(this,Ys),textWithDisclaimer:r(this,vn)}}get data(){return{altText:r(this,re),decorative:r(this,Ts)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,Ys,s),p(this,vn,i)),!(r(this,re)===t&&r(this,Ts)===e)&&(n||(p(this,re,t),p(this,Ts,e)),m(this,vs,Dl).call(this))}toggle(t=!1){r(this,hs)&&(!t&&r(this,Oe)&&(clearTimeout(r(this,Oe)),p(this,Oe,null)),r(this,hs).disabled=!t)}shown(){r(this,ke)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,vs,Oa)}})}destroy(){var t,e;(t=r(this,hs))==null||t.remove(),p(this,hs,null),p(this,jr,null),p(this,Rs,null),(e=r(this,Ps))==null||e.remove(),p(this,Ps,null)}};re=new WeakMap,Ts=new WeakMap,hs=new WeakMap,jr=new WeakMap,Rs=new WeakMap,Oe=new WeakMap,Br=new WeakMap,Ps=new WeakMap,ke=new WeakMap,Ys=new WeakMap,vn=new WeakMap,ks=new WeakMap,Fi=new WeakMap,vs=new WeakSet,Oa=function(){return r(this,re)&&"added"||r(this,re)===null&&this.guessedText&&"review"||"missing"},Dl=async function(){var i,n,a;const t=r(this,hs);if(!t)return;if(r(this,ks)){if(t.classList.toggle("done",!!r(this,re)),t.setAttribute("data-l10n-id",r(Ee,Fi)[r(this,vs,Oa)]),(i=r(this,jr))==null||i.setAttribute("data-l10n-id",r(Ee,Fi)[`${r(this,vs,Oa)}-label`]),!r(this,re)){(n=r(this,Rs))==null||n.remove();return}}else{if(!r(this,re)&&!r(this,Ts)){t.classList.remove("done"),(a=r(this,Rs))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,Rs);if(!e){p(this,Rs,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,ke).id}`;const o=100,l=r(this,ke)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,Oe)),p(this,Oe,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,Oe,setTimeout(()=>{p(this,Oe,null),r(this,Rs).classList.add("show"),r(this,ke)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var h;r(this,Oe)&&(clearTimeout(r(this,Oe)),p(this,Oe,null)),(h=r(this,Rs))==null||h.classList.remove("show")},{signal:l})}r(this,Ts)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,re)),e.parentNode||t.append(e);const s=r(this,ke).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},A(Ee,Fi,null),Y(Ee,"_l10n",null);let ac=Ee;var wn,ds,Lt,$r,_n,ce,En,Di,Ao,Sn,Ni,yo,xn,Ks,Ls,zr,Gr,Ke,vo,gc,it,dh,wo,uh,fh,Iu,Fu,ph,gh,mh,Du,bh,Nu,Ou,Hu,Ah,Ha;const ft=class ft{constructor(t){A(this,it);A(this,wn,null);A(this,ds,null);A(this,Lt,null);A(this,$r,!1);A(this,_n,!1);A(this,ce,null);A(this,En,null);A(this,Di,null);A(this,Ao,"");A(this,Sn,!1);A(this,Ni,null);A(this,yo,!1);A(this,xn,!1);A(this,Ks,!1);A(this,Ls,null);A(this,zr,0);A(this,Gr,0);A(this,Ke,null);Y(this,"_editToolbar",null);Y(this,"_initialOptions",Object.create(null));Y(this,"_initialData",null);Y(this,"_isVisible",!0);Y(this,"_uiManager",null);Y(this,"_focusEventsAllowed",!0);A(this,vo,!1);A(this,gc,ft._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;const{rotation:e,rawDims:{pageWidth:s,pageHeight:i,pageX:n,pageY:a}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[s,i],this.pageTranslation=[n,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=ft.prototype._resizeWithKeyboard,e=cr.TRANSLATE_SMALL,s=cr.TRANSLATE_BIG;return ot(this,"_resizerKeyboardManager",new yl([[["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"],ft.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return ot(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new wg({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(ft._l10n??(ft._l10n=t),ft._l10nResizer||(ft._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"})),ft._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ft._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){Ct("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,vo)}set _isDraggable(t){var e;p(this,vo,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=r(this,gc)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,it,Ha).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,Sn)?p(this,Sn,!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.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}translate(t,e){m(this,it,dh).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,Ni)||p(this,Ni,[this.x,this.y]),m(this,it,dh).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,Ni)||p(this,Ni,[this.x,this.y]);const[s,i]=this.parentDimensions;if(this.x+=t/s,this.y+=e/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:h,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,h,d)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:n,y:a}=this;const[o,l]=this.getBaseTranslation();n+=o,a+=l,this.div.style.left=`${(100*n).toFixed(2)}%`,this.div.style.top=`${(100*a).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!r(this,Ni)&&(r(this,Ni)[0]!==this.x||r(this,Ni)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ft,i=s/t,n=s/e;switch(this.rotation){case 90:return[-i,n];case 180:return[i,n];case 270:return[i,-n];default:return[-i,-n]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const[e,s]=this.pageDimensions;let{x:i,y:n,width:a,height:o}=this;if(a*=e,o*=s,i*=e,n*=s,this._mustFixPosition)switch(t){case 0:i=Math.max(0,Math.min(e-a,i)),n=Math.max(0,Math.min(s-o,n));break;case 90:i=Math.max(0,Math.min(e-o,i)),n=Math.min(s,Math.max(a,n));break;case 180:i=Math.min(e,Math.max(a,i)),n=Math.min(s,Math.max(o,n));break;case 270:i=Math.min(e,Math.max(o,i)),n=Math.max(0,Math.min(s-a,n));break}this.x=i/=e,this.y=n/=s;const[l,h]=this.getBaseTranslation();i+=l,n+=h;const{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*n).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var s;return m(s=ft,wo,uh).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=ft,wo,uh).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;this.div.style.width=`${(100*t/s).toFixed(2)}%`,r(this,_n)||(this.div.style.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!r(this,_n)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,_n)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,Lt))==null||t.finish()}async addEditToolbar(){return this._editToolbar||r(this,xn)?this._editToolbar:(this._editToolbar=new eh(this),this.div.append(this._editToolbar.render()),r(this,Lt)&&await this._editToolbar.addAltText(r(this,Lt)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=r(this,Lt))==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()}async addAltTextButton(){r(this,Lt)||(ac.initialize(ft._l10n),p(this,Lt,new ac(this)),r(this,wn)&&(r(this,Lt).data=r(this,wn),p(this,wn,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,Lt))==null?void 0:t.data}set altTextData(t){r(this,Lt)&&(r(this,Lt).data=t)}get guessedAltText(){var t;return(t=r(this,Lt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,Lt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,Lt))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,Lt)&&!r(this,Lt).isEmpty()}hasAltTextData(){var t;return((t=r(this,Lt))==null?void 0:t.hasData())??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=r(this,$r)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,it,bh).call(this);const[t,e]=this.parentDimensions;this.parentRotation%180!==0&&(this.div.style.maxWidth=`${(100*e/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/e).toFixed(2)}%`);const[s,i]=this.getInitialTranslation();return this.translate(s,i),rc(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=xe.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,Sn,!0),this._isDraggable){m(this,it,Du).call(this,t);return}m(this,it,mh).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){r(this,Ls)&&clearTimeout(r(this,Ls)),p(this,Ls,setTimeout(()=>{var t;p(this,Ls,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[o,l]=this.pageTranslation,h=t/i,d=e/i,u=this.x*n,f=this.y*a,g=this.width*n,b=this.height*a;switch(s){case 0:return[u+h+o,a-f-d-b+l,u+h+g+o,a-f-d+l];case 90:return[u+d+o,a-f+h+l,u+d+b+o,a-f+h+g+l];case 180:return[u-h-g+o,a-f+d+l,u-h+o,a-f+d+b+l];case 270:return[u-d-b+o,a-f-h-g+l,u-d+o,a-f-h+l];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,o=n-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[n,e-i,o,l];case 270:return[n,e-a,l,o];default:throw new Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){p(this,xn,!0)}disableEditMode(){p(this,xn,!1)}isInEditMode(){return r(this,xn)}shouldGetKeyboardEvents(){return r(this,Ks)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,it,bh).call(this)}rotate(t){}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){Ct("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s});i.rotation=t.rotation,p(i,wn,t.accessibilityData);const[n,a]=i.pageDimensions,[o,l,h,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=h/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=r(this,Di))==null||t.abort(),p(this,Di,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,Ls)&&(clearTimeout(r(this,Ls)),p(this,Ls,null)),m(this,it,Ha).call(this),this.removeEditToolbar(),r(this,Ke)){for(const e of r(this,Ke).values())clearTimeout(e);p(this,Ke,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,it,Iu).call(this),r(this,ce).classList.remove("hidden"),rc(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,En,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,ce).children;if(!r(this,ds)){p(this,ds,Array.from(e));const a=m(this,it,Nu).bind(this),o=m(this,it,Ou).bind(this),l=this._uiManager._signal;for(const h of r(this,ds)){const d=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",a,{signal:l}),h.addEventListener("blur",o,{signal:l}),h.addEventListener("focus",m(this,it,Hu).bind(this,d),{signal:l}),h.setAttribute("data-l10n-id",ft._l10nResizer[d])}}const s=r(this,ds)[0];let i=0;for(const a of e){if(a===s)break;i++}const n=(360-this.rotation+this.parentRotation)%360/90*(r(this,ds).length/4);if(n!==i){if(ni)for(let o=0;o{var i,n;(i=this.div)!=null&&i.classList.contains("selectedEditor")&&((n=this._editToolbar)==null||n.show())});return}(e=this._editToolbar)==null||e.show(),(s=r(this,Lt))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=r(this,ce))==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(),(n=r(this,Lt))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,yo)}set isEditing(t){p(this,yo,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,_n,!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){r(this,Ke)||p(this,Ke,new Map);const{action:s}=t;let i=r(this,Ke).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,Ke).delete(s),r(this,Ke).size===0&&p(this,Ke,null)},ft._telemetryTimeout),r(this,Ke).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,$r,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,$r,!0)}renderAnnotationElement(t){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()}};wn=new WeakMap,ds=new WeakMap,Lt=new WeakMap,$r=new WeakMap,_n=new WeakMap,ce=new WeakMap,En=new WeakMap,Di=new WeakMap,Ao=new WeakMap,Sn=new WeakMap,Ni=new WeakMap,yo=new WeakMap,xn=new WeakMap,Ks=new WeakMap,Ls=new WeakMap,zr=new WeakMap,Gr=new WeakMap,Ke=new WeakMap,vo=new WeakMap,gc=new WeakMap,it=new WeakSet,dh=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},wo=new WeakSet,uh=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]}},fh=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]}},Iu=function(){if(r(this,ce))return;p(this,ce,document.createElement("div")),r(this,ce).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");r(this,ce).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,it,Fu).bind(this,s),{signal:e}),i.addEventListener("contextmenu",is,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,ce))},Fu=function(t,e){var b;e.preventDefault();const{isMac:s}=xe.platform;if(e.button!==0||e.ctrlKey&&s)return;(b=r(this,Lt))==null||b.toggle(!1);const i=this._isDraggable;this._isDraggable=!1;const n=new AbortController,a=this._uiManager.combinedSignal(n);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",m(this,it,gh).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",is,{signal:a});const o=this.x,l=this.y,h=this.width,d=this.height,u=this.parent.div.style.cursor,f=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const g=()=>{var y;n.abort(),this.parent.togglePointerEvents(!0),(y=r(this,Lt))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=f,m(this,it,ph).call(this,o,l,h,d)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},ph=function(t,e,s,i){const n=this.x,a=this.y,o=this.width,l=this.height;n===t&&a===e&&o===s&&l===i||this.addCommands({cmd:()=>{this.width=o,this.height=l,this.x=n,this.y=a;const[h,d]=this.parentDimensions;this.setDims(h*o,d*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[h,d]=this.parentDimensions;this.setDims(h*s,d*i),this.fixAndSetPosition()},mustExec:!0})},gh=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,h=ft.MIN_SIZE/s,d=ft.MIN_SIZE/i,u=D=>Math.round(D*1e4)/1e4,f=m(this,it,fh).call(this,this.rotation),g=(D,j)=>[f[0]*D+f[2]*j,f[1]*D+f[3]*j],b=m(this,it,fh).call(this,360-this.rotation),y=(D,j)=>[b[0]*D+b[2]*j,b[1]*D+b[3]*j];let w,v,_=!1,S=!1;switch(t){case"topLeft":_=!0,w=(D,j)=>[0,0],v=(D,j)=>[D,j];break;case"topMiddle":w=(D,j)=>[D/2,0],v=(D,j)=>[D/2,j];break;case"topRight":_=!0,w=(D,j)=>[D,0],v=(D,j)=>[0,j];break;case"middleRight":S=!0,w=(D,j)=>[D,j/2],v=(D,j)=>[0,j/2];break;case"bottomRight":_=!0,w=(D,j)=>[D,j],v=(D,j)=>[0,0];break;case"bottomMiddle":w=(D,j)=>[D/2,j],v=(D,j)=>[D/2,0];break;case"bottomLeft":_=!0,w=(D,j)=>[0,j],v=(D,j)=>[D,0];break;case"middleLeft":S=!0,w=(D,j)=>[0,j/2],v=(D,j)=>[D,j/2];break}const E=w(o,l),T=v(o,l);let C=g(...T);const x=u(n+C[0]),P=u(a+C[1]);let M=1,O=1,[L,V]=this.screenToPageTranslation(e.movementX,e.movementY);if([L,V]=y(L/s,V/i),_){const D=Math.hypot(o,l);M=O=Math.max(Math.min(Math.hypot(T[0]-E[0]-L,T[1]-E[1]-V)/D,1/o,1/l),h/o,d/l)}else S?M=Math.max(h,Math.min(1,Math.abs(T[0]-E[0]-L)))/o:O=Math.max(d,Math.min(1,Math.abs(T[1]-E[1]-V)))/l;const G=u(o*M),z=u(l*O);C=g(...v(G,z));const q=x-C[0],W=P-C[1];this.width=G,this.height=z,this.x=q,this.y=W,this.setDims(s*G,i*z),this.fixAndSetPosition()},mh=function(t){const{isMac:e}=xe.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Du=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();const s=new AbortController,i=this._uiManager.combinedSignal(s);if(e){this.div.classList.add("moving"),p(this,zr,t.clientX),p(this,Gr,t.clientY);const a=o=>{const{clientX:l,clientY:h}=o,[d,u]=this.screenToPageTranslation(l-r(this,zr),h-r(this,Gr));p(this,zr,l),p(this,Gr,h),this._uiManager.dragSelectedEditors(d,u)};window.addEventListener("pointermove",a,{passive:!0,capture:!0,signal:i})}const n=()=>{s.abort(),e&&this.div.classList.remove("moving"),p(this,Sn,!1),this._uiManager.endDragSession()||m(this,it,mh).call(this,t)};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})},bh=function(){if(r(this,Di)||!this.div)return;p(this,Di,new AbortController);const t=this._uiManager.combinedSignal(r(this,Di));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Nu=function(t){ft._resizerKeyboardManager.exec(this,t)},Ou=function(t){var e;r(this,Ks)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,ce)&&m(this,it,Ha).call(this)},Hu=function(t){p(this,Ao,r(this,Ks)?t:"")},Ah=function(t){if(r(this,ds))for(const e of r(this,ds))e.tabIndex=t},Ha=function(){if(p(this,Ks,!1),m(this,it,Ah).call(this,-1),r(this,En)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,En);m(this,it,ph).call(this,t,e,s,i),p(this,En,null)}},A(ft,wo),Y(ft,"_l10n",null),Y(ft,"_l10nResizer",null),Y(ft,"_borderLineWidth",-1),Y(ft,"_colorManager",new nh),Y(ft,"_zIndex",1),Y(ft,"_telemetryTimeout",1e3);let mt=ft;class wg extends mt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Hd=3285377520,Xe=4294901760,_s=65535;class ju{constructor(t){this.h1=t?t&4294967295:Hd,this.h2=t?t&4294967295:Hd}update(t){let e,s;if(typeof t=="string"){e=new Uint8Array(t.length*2),s=0;for(let y=0,w=t.length;y>>8,e[s++]=v&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,n=s-i*4,a=new Uint32Array(e.buffer,0,i);let o=0,l=0,h=this.h1,d=this.h2;const u=3432918353,f=461845907,g=u&_s,b=f&_s;for(let y=0;y>>17,o=o*f&Xe|o*b&_s,h^=o,h=h<<13|h>>>19,h=h*5+3864292196):(l=a[y],l=l*u&Xe|l*g&_s,l=l<<15|l>>>17,l=l*f&Xe|l*b&_s,d^=l,d=d<<13|d>>>19,d=d*5+3864292196);switch(o=0,n){case 3:o^=e[i*4+2]<<16;case 2:o^=e[i*4+1]<<8;case 1:o^=e[i*4],o=o*u&Xe|o*g&_s,o=o<<15|o>>>17,o=o*f&Xe|o*b&_s,i&1?h^=o:d^=o}this.h1=h,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&Xe|t*36045&_s,e=e*4283543511&Xe|((e<<16|t>>>16)*2950163797&Xe)>>>16,t^=e>>>1,t=t*444984403&Xe|t*60499&_s,e=e*3301882366&Xe|((e<<16|t>>>16)*3120437893&Xe)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const yh=Object.freeze({map:null,hash:"",transfer:void 0});var Cn,Tn,ae,mc,Bu;class Sd{constructor(){A(this,mc);A(this,Cn,!1);A(this,Tn,null);A(this,ae,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,ae).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,ae).get(t)}remove(t){if(r(this,ae).delete(t),r(this,ae).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,ae).values())if(e instanceof mt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,ae).get(t);let i=!1;if(s!==void 0)for(const[n,a]of Object.entries(e))s[n]!==a&&(i=!0,s[n]=a);else i=!0,r(this,ae).set(t,e);i&&m(this,mc,Bu).call(this),e instanceof mt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,ae).has(t)}getAll(){return r(this,ae).size>0?Ad(r(this,ae)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,ae).size}resetModified(){r(this,Cn)&&(p(this,Cn,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new $u(this)}get serializable(){if(r(this,ae).size===0)return yh;const t=new Map,e=new ju,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,ae)){const l=o instanceof mt?o.serialize(!1,i):o;l&&(t.set(a,l),e.update(`${a}:${JSON.stringify(l)}`),n||(n=!!l.bitmap))}if(n)for(const a of t.values())a.bitmap&&s.push(a.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:s}:yh}get editorStats(){let t=null;const e=new Map;for(const s of r(this,ae).values()){if(!(s instanceof mt))continue;const i=s.telemetryFinalData;if(!i)continue;const{type:n}=i;e.has(n)||e.set(n,Object.getPrototypeOf(s).constructor),t||(t=Object.create(null));const a=t[n]||(t[n]=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 d=h.get(l)??0;h.set(l,d+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,Tn,null)}get modifiedIds(){if(r(this,Tn))return r(this,Tn);const t=[];for(const e of r(this,ae).values())!(e instanceof mt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,Tn,{ids:new Set(t),hash:t.join(",")})}}Cn=new WeakMap,Tn=new WeakMap,ae=new WeakMap,mc=new WeakSet,Bu=function(){r(this,Cn)||(p(this,Cn,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var _o;class $u extends Sd{constructor(e){super();A(this,_o);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);p(this,_o,{map:a,hash:i,transfer:n})}get print(){Ct("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,_o)}get modifiedIds(){return ot(this,"modifiedIds",{ids:new Set,hash:""})}}_o=new WeakMap;var Ur;class _g{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){A(this,Ur,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(),r(this,Ur).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,Ur).has(t.loadedName))){if(Qt(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:s,src:i,style:n}=t,a=new FontFace(s,i,n);this.addNativeFontFace(a);try{await a.load(),r(this,Ur).add(s),e==null||e(t)}catch{nt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}Ct("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 nt(`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 ot(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){let t=!1;return(ve||typeof navigator<"u"&&typeof(navigator==null?void 0:navigator.userAgent)=="string"&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(t=!0),ot(this,"isSyncFontLoadingSupported",t)}_queueLoadingCallback(t){function e(){for(Qt(!i.done,"completeRequest() cannot be called twice."),i.done=!0;s.length>0&&s[0].done;){const n=s.shift();setTimeout(n.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 ot(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function s(E,T){return E.charCodeAt(T)<<24|E.charCodeAt(T+1)<<16|E.charCodeAt(T+2)<<8|E.charCodeAt(T+3)&255}function i(E,T,C,x){const P=E.substring(0,T),M=E.substring(T+C);return P+x+M}let n,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let h=0;function d(E,T){if(++h>30){nt("Load test font never loaded."),T();return}if(l.font="30px "+E,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){T();return}setTimeout(d.bind(null,E,T))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const b=16,y=1482184792;let w=s(f,b);for(n=0,a=u.length-3;n{S.remove(),e.complete()})}}Ur=new WeakMap;class Eg{constructor(t,{disableFontFace:e=!1,inspectFont:s=null}){this.compiledGlyphs=Object.create(null);for(const i in t)this[i]=t[i];this.disableFontFace=e===!0,this._inspectFont=s}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,${ug(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];let s;try{s=t.get(this.loadedName+"_path_"+e)}catch(n){nt(`getPathGenerator - ignoring character: "${n}".`)}if(!Array.isArray(s)||s.length===0)return this.compiledGlyphs[e]=function(n,a){};const i=[];for(let n=0,a=s.length;ng.bezierCurveTo(o,l,h,d,u,f)),n+=6}break;case $s.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.moveTo(o,l)),n+=2}break;case $s.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(h=>h.lineTo(o,l)),n+=2}break;case $s.QUADRATIC_CURVE_TO:{const[o,l,h,d]=s.slice(n,n+4);i.push(u=>u.quadraticCurveTo(o,l,h,d)),n+=4}break;case $s.RESTORE:i.push(o=>o.restore());break;case $s.SAVE:i.push(o=>o.save());break;case $s.SCALE:Qt(i.length===2,"Scale command is only valid at the third position.");break;case $s.TRANSFORM:{const[o,l,h,d,u,f]=s.slice(n,n+6);i.push(g=>g.transform(o,l,h,d,u,f)),n+=6}break;case $s.TRANSLATE:{const[o,l]=s.slice(n,n+2);i.push(h=>h.translate(o,l)),n+=2}break}return this.compiledGlyphs[e]=function(a,o){i[0](a),i[1](a),a.scale(o,-o);for(let l=2,h=i.length;l({cMapData:s,isCompressed:this.isCompressed})).catch(s=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){Ct("Abstract method `_fetch` called.")}}class Uu extends Gu{async _fetch(t){const e=await Ic(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Mc(e)}}class Wu{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,s,i,n){return"none"}destroy(t=!1){}}var Rn,Pn,Ms,Qs,me,bc,kn,H,pe,Ar,yr,Nl,vr,Vu,vh,wr,ja,Ba,wh,$a;class xg extends Wu{constructor({docId:e,ownerDocument:s=globalThis.document}){super();A(this,H);A(this,Rn);A(this,Pn);A(this,Ms);A(this,Qs);A(this,me);A(this,bc);A(this,kn,0);p(this,Qs,e),p(this,me,s)}addFilter(e){if(!e)return"none";let s=r(this,H,pe).get(e);if(s)return s;const[i,n,a]=m(this,H,Nl).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,H,pe).get(o),s)return r(this,H,pe).set(e,s),s;const l=`g_${r(this,Qs)}_transfer_map_${we(this,kn)._++}`,h=m(this,H,vr).call(this,l);r(this,H,pe).set(e,h),r(this,H,pe).set(o,h);const d=m(this,H,wr).call(this,l);return m(this,H,Ba).call(this,i,n,a,d),h}addHCMFilter(e,s){var b;const i=`${e}-${s}`,n="base";let a=r(this,H,Ar).get(n);if((a==null?void 0:a.key)===i||(a?((b=a.filter)==null||b.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,H,Ar).set(n,a)),!e||!s))return a.url;const o=m(this,H,$a).call(this,e);e=$.makeHexColor(...o);const l=m(this,H,$a).call(this,s);if(s=$.makeHexColor(...l),r(this,H,yr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const h=new Array(256);for(let y=0;y<=255;y++){const w=y/255;h[y]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const d=h.join(","),u=`g_${r(this,Qs)}_hcm_filter`,f=a.filter=m(this,H,wr).call(this,u);m(this,H,Ba).call(this,d,d,d,f),m(this,H,vh).call(this,f);const g=(y,w)=>{const v=o[y]/255,_=l[y]/255,S=new Array(w+1);for(let E=0;E<=w;E++)S[E]=v+E/w*(_-v);return S.join(",")};return m(this,H,Ba).call(this,g(0,5),g(1,5),g(2,5),f),a.url=m(this,H,vr).call(this,u),a.url}addAlphaFilter(e){let s=r(this,H,pe).get(e);if(s)return s;const[i]=m(this,H,Nl).call(this,[e]),n=`alpha_${i}`;if(s=r(this,H,pe).get(n),s)return r(this,H,pe).set(e,s),s;const a=`g_${r(this,Qs)}_alpha_map_${we(this,kn)._++}`,o=m(this,H,vr).call(this,a);r(this,H,pe).set(e,o),r(this,H,pe).set(n,o);const l=m(this,H,wr).call(this,a);return m(this,H,wh).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,H,pe).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=m(this,H,Nl).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,H,pe).get(n),s)return r(this,H,pe).set(e,s),s;const a=`g_${r(this,Qs)}_luminosity_map_${we(this,kn)._++}`,o=m(this,H,vr).call(this,a);r(this,H,pe).set(e,o),r(this,H,pe).set(n,o);const l=m(this,H,wr).call(this,a);return m(this,H,Vu).call(this,l),e&&m(this,H,wh).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var _;const o=`${s}-${i}-${n}-${a}`;let l=r(this,H,Ar).get(e);if((l==null?void 0:l.key)===o||(l?((_=l.filter)==null||_.remove(),l.key=o,l.url="none",l.filter=null):(l={key:o,url:"none",filter:null},r(this,H,Ar).set(e,l)),!s||!i))return l.url;const[h,d]=[s,i].map(m(this,H,$a).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,b]=[n,a].map(m(this,H,$a).bind(this));f{const C=new Array(256),x=(f-u)/T,P=S/255,M=(E-S)/(255*T);let O=0;for(let L=0;L<=T;L++){const V=Math.round(u+L*x),G=P+L*M;for(let z=O;z<=V;z++)C[z]=G;O=V+1}for(let L=O;L<256;L++)C[L]=C[O-1];return C.join(",")},w=`g_${r(this,Qs)}_hcm_${e}_filter`,v=l.filter=m(this,H,wr).call(this,w);return m(this,H,vh).call(this,v),m(this,H,Ba).call(this,y(g[0],b[0],5),y(g[1],b[1],5),y(g[2],b[2],5),v),l.url=m(this,H,vr).call(this,w),l.url}destroy(e=!1){e&&r(this,H,Ar).size!==0||(r(this,Ms)&&(r(this,Ms).parentNode.parentNode.remove(),p(this,Ms,null)),r(this,Pn)&&(r(this,Pn).clear(),p(this,Pn,null)),p(this,kn,0))}}Rn=new WeakMap,Pn=new WeakMap,Ms=new WeakMap,Qs=new WeakMap,me=new WeakMap,bc=new WeakMap,kn=new WeakMap,H=new WeakSet,pe=function(){return r(this,Pn)||p(this,Pn,new Map)},Ar=function(){return r(this,bc)||p(this,bc,new Map)},yr=function(){if(!r(this,Ms)){const e=r(this,me).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=r(this,me).createElementNS(Gs,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Ms,r(this,me).createElementNS(Gs,"defs")),e.append(i),i.append(r(this,Ms)),r(this,me).body.append(e)}return r(this,Ms)},Nl=function(e){if(e.length===1){const h=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=h[f]/255;const u=d.join(",");return[u,u,u]}const[s,i,n]=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]=n[h]/255;return[a.join(","),o.join(","),l.join(",")]},vr=function(e){if(r(this,Rn)===void 0){p(this,Rn,"");const s=r(this,me).URL;s!==r(this,me).baseURI&&(Fc(s)?nt('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,Rn,s.split("#",1)[0]))}return`url(${r(this,Rn)}#${e})`},Vu=function(e){const s=r(this,me).createElementNS(Gs,"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)},vh=function(e){const s=r(this,me).createElementNS(Gs,"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)},wr=function(e){const s=r(this,me).createElementNS(Gs,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,H,yr).append(s),s},ja=function(e,s,i){const n=r(this,me).createElementNS(Gs,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Ba=function(e,s,i,n){const a=r(this,me).createElementNS(Gs,"feComponentTransfer");n.append(a),m(this,H,ja).call(this,a,"feFuncR",e),m(this,H,ja).call(this,a,"feFuncG",s),m(this,H,ja).call(this,a,"feFuncB",i)},wh=function(e,s){const i=r(this,me).createElementNS(Gs,"feComponentTransfer");s.append(i),m(this,H,ja).call(this,i,"feFuncA",e)},$a=function(e){return r(this,H,yr).style.color=e,Ed(getComputedStyle(r(this,H,yr)).getPropertyValue("color"))};class qu{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){Ct("Abstract method `_fetch` called.")}}class Xu extends qu{async _fetch(t){const e=await Ic(t,"arraybuffer");return new Uint8Array(e)}}if(ve){var _h=Promise.withResolvers(),Za=null;(async()=>{const t=await _l(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await _l(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await _l(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await _l(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]);let n,a;return new Map(Object.entries({fs:t,http:e,https:s,url:i,canvas:n,path2d:a}))})().then(t=>{Za=t,_h.resolve()},t=>{nt(`loadPackages: ${t}`),Za=new Map,_h.resolve()})}class tn{static get promise(){return _h.promise}static get(t){return Za==null?void 0:Za.get(t)}}async function Yu(c){const e=await tn.get("fs").promises.readFile(c);return new Uint8Array(e)}class Cg extends Wu{}class Tg extends zu{_createCanvas(t,e){return tn.get("canvas").createCanvas(t,e)}}class Rg extends Gu{async _fetch(t){return Yu(t)}}class Pg extends qu{async _fetch(t){return Yu(t)}}const Se={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function Eh(c,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),c.clip(i)}class xd{getPattern(){Ct("Abstract method `getPattern` called.")}}class kg extends xd{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 n;if(i===Se.STROKE||i===Se.FILL){const a=e.current.getClippedPathBoundingBox(i,It(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),d=h.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-a[0],-a[1]),s=$.transform(s,[1,0,0,1,a[0],a[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),Eh(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),n=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(s);n.setTransform(u)}else Eh(t,this._bbox),n=this._createGradient(t);return n}}function Uc(c,t,e,s,i,n,a,o){const l=t.coords,h=t.colors,d=c.data,u=c.width*4;let f;l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f),l[s+1]>l[i+1]&&(f=s,s=i,i=f,f=a,a=o,o=f),l[e+1]>l[s+1]&&(f=e,e=s,s=f,f=n,n=a,a=f);const g=(l[e]+t.offsetX)*t.scaleX,b=(l[e+1]+t.offsetY)*t.scaleY,y=(l[s]+t.offsetX)*t.scaleX,w=(l[s+1]+t.offsetY)*t.scaleY,v=(l[i]+t.offsetX)*t.scaleX,_=(l[i+1]+t.offsetY)*t.scaleY;if(b>=_)return;const S=h[n],E=h[n+1],T=h[n+2],C=h[a],x=h[a+1],P=h[a+2],M=h[o],O=h[o+1],L=h[o+2],V=Math.round(b),G=Math.round(_);let z,q,W,D,j,Rt,Et,St;for(let ut=V;ut<=G;ut++){if(ut_?J=1:w===_?J=0:J=(w-ut)/(w-_),z=y-(y-v)*J,q=C-(C-M)*J,W=x-(x-O)*J,D=P-(P-L)*J}let ht;ut_?ht=1:ht=(b-ut)/(b-_),j=g-(g-v)*ht,Rt=S-(S-M)*ht,Et=E-(E-O)*ht,St=T-(T-L)*ht;const Ht=Math.round(Math.min(z,j)),ue=Math.round(Math.max(z,j));let et=u*ut+Ht*4;for(let J=Ht;J<=ue;J++)ht=(z-J)/(z-j),ht<0?ht=0:ht>1&&(ht=1),d[et++]=q-(q-Rt)*ht|0,d[et++]=W-(W-Et)*ht|0,d[et++]=D-(D-St)*ht|0,d[et++]=255}}function Lg(c,t,e){const s=t.coords,i=t.colors;let n,a;switch(t.type){case"lattice":const o=t.verticesPerRow,l=Math.floor(s.length/o)-1,h=o-1;for(n=0;n=O?E=l:C=!0,M>=L?T=h:x=!0;const V=this.getSizeAndScale(E,this.ctx.canvas.width,_),G=this.getSizeAndScale(T,this.ctx.canvas.height,S),z=t.cachedCanvases.getCanvas("pattern",V.size,G.size),q=z.context,W=o.createCanvasGraphics(q);if(W.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(W,i,a),q.translate(-V.scale*d,-G.scale*u),W.transform(V.scale,0,0,G.scale,0,0),q.save(),this.clipBbox(W,d,u,f,g),W.baseTransform=It(W.ctx),W.executeOperatorList(s),W.endDrawing(),q.restore(),C||x){const D=z.canvas;C&&(E=l),x&&(T=h);const j=this.getSizeAndScale(E,this.ctx.canvas.width,_),Rt=this.getSizeAndScale(T,this.ctx.canvas.height,S),Et=j.size,St=Rt.size,ut=t.cachedCanvases.getCanvas("pattern-workaround",Et,St),ht=ut.context,Ht=C?Math.floor(b/l):0,ue=x?Math.floor(y/h):0;for(let et=0;et<=Ht;et++)for(let J=0;J<=ue;J++)ht.drawImage(D,Et*et,St*J,Et,St,0,0,Et,St);return{canvas:ut.canvas,scaleX:j.scale,scaleY:Rt.scale,offsetX:d,offsetY:u}}return{canvas:z.canvas,scaleX:V.scale,scaleY:G.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(Ac.MAX_PATTERN_SIZE,e);let n=Math.ceil(t*s);return n>=i?n=i:s=n/t,{scale:s,size:n}}clipBbox(t,e,s,i,n){const a=i-e,o=n-s;t.ctx.rect(e,s,a,o),t.current.updateRectMinMax(It(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case jd.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case jd.UNCOLORED:const o=$.makeHexColor(s[0],s[1],s[2]);i.fillStyle=o,i.strokeStyle=o,n.fillColor=o,n.strokeColor=o;break;default:throw new rg(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==Se.SHADING&&(n=$.transform(n,e.baseTransform),this.matrix&&(n=$.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let o=new DOMMatrix(n);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}};Y(Ac,"MAX_PATTERN_SIZE",3e3);let Sh=Ac;function Dg({src:c,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=xe.isLittleEndian?4278190080:255,[l,h]=a?[n,o]:[o,n],d=s>>3,u=s&7,f=c.length;e=new Uint32Array(e.buffer);let g=0;for(let b=0;b{c.save=c.__originalSave,c.restore=c.__originalRestore,c.rotate=c.__originalRotate,c.scale=c.__originalScale,c.translate=c.__originalTranslate,c.transform=c.__originalTransform,c.setTransform=c.__originalSetTransform,c.resetTransform=c.__originalResetTransform,c.clip=c.__originalClip,c.moveTo=c.__originalMoveTo,c.lineTo=c.__originalLineTo,c.bezierCurveTo=c.__originalBezierCurveTo,c.rect=c.__originalRect,c.closePath=c.__originalClosePath,c.beginPath=c.__originalBeginPath,delete c._removeMirroring},c.save=function(){t.save(),this.__originalSave()},c.restore=function(){t.restore(),this.__originalRestore()},c.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},c.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},c.transform=function(s,i,n,a,o,l){t.transform(s,i,n,a,o,l),this.__originalTransform(s,i,n,a,o,l)},c.setTransform=function(s,i,n,a,o,l){t.setTransform(s,i,n,a,o,l),this.__originalSetTransform(s,i,n,a,o,l)},c.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},c.rotate=function(s){t.rotate(s),this.__originalRotate(s)},c.clip=function(s){t.clip(s),this.__originalClip(s)},c.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},c.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},c.bezierCurveTo=function(e,s,i,n,a,o){t.bezierCurveTo(e,s,i,n,a,o),this.__originalBezierCurveTo(e,s,i,n,a,o)},c.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},c.closePath=function(){t.closePath(),this.__originalClosePath()},c.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Hg{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 El(c,t,e,s,i,n,a,o,l,h){const[d,u,f,g,b,y]=It(c);if(u===0&&f===0){const _=a*d+b,S=Math.round(_),E=o*g+y,T=Math.round(E),C=(a+l)*d+b,x=Math.abs(Math.round(C)-S)||1,P=(o+h)*g+y,M=Math.abs(Math.round(P)-T)||1;return c.setTransform(Math.sign(d),0,0,Math.sign(g),S,T),c.drawImage(t,e,s,i,n,0,0,x,M),c.setTransform(d,u,f,g,b,y),[x,M]}if(d===0&&g===0){const _=o*f+b,S=Math.round(_),E=a*u+y,T=Math.round(E),C=(o+h)*f+b,x=Math.abs(Math.round(C)-S)||1,P=(a+l)*u+y,M=Math.abs(Math.round(P)-T)||1;return c.setTransform(0,Math.sign(u),Math.sign(f),0,S,T),c.drawImage(t,e,s,i,n,0,0,M,x),c.setTransform(d,u,f,g,b,y),[M,x]}c.drawImage(t,e,s,i,n,a,o,l,h);const w=Math.hypot(d,u),v=Math.hypot(f,g);return[w*l,v*h]}function jg(c){const{width:t,height:e}=c;if(t>Gd||e>Gd)return null;const s=1e3,i=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),n=t+1;let a=new Uint8Array(n*(e+1)),o,l,h;const d=t+7&-8;let u=new Uint8Array(d*e),f=0;for(const v of c.data){let _=128;for(;_>0;)u[f++]=v&_?0:255,_>>=1}let g=0;for(f=0,u[f]!==0&&(a[0]=1,++g),l=1;l>2)+(u[f+1]?4:0)+(u[f-d+1]?8:0),i[v]&&(a[h+l]=i[v],++g),f++;if(u[f-d]!==u[f]&&(a[h+l]=u[f]?2:4,++g),g>s)return null}for(f=d*(e-1),h=o*n,u[f]!==0&&(a[h]=8,++g),l=1;ls)return null;const b=new Int32Array([0,n,-1,0,-n,0,0,0,1]),y=new Path2D;for(o=0;g&&o<=e;o++){let v=o*n;const _=v+t;for(;v<_&&!a[v];)v++;if(v===_)continue;y.moveTo(v%n,o);const S=v;let E=a[v];do{const T=b[E];do v+=T;while(!a[v]);const C=a[v];C!==5&&C!==10?(E=C,a[v]=0):(E=C&51*E>>4,a[v]&=E>>2|E<<2),y.lineTo(v%n,v/n|0),a[v]||--g}while(S!==v);--o}return u=null,a=null,function(v){v.save(),v.scale(1/t,-1/e),v.translate(0,-e),v.fill(y),v.beginPath(),v.restore()}}class Ud{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=uu,this.textMatrixScale=1,this.fontMatrix=Kc,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=fe.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,t,e])}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t}setCurrentPoint(t,e){this.x=t,this.y=e}updatePathMinMax(t,e,s){[e,s]=$.applyTransform([e,s],t),this.minX=Math.min(this.minX,e),this.minY=Math.min(this.minY,s),this.maxX=Math.max(this.maxX,e),this.maxY=Math.max(this.maxY,s)}updateRectMinMax(t,e){const s=$.applyTransform(e,t),i=$.applyTransform(e.slice(2),t),n=$.applyTransform([e[0],e[3]],t),a=$.applyTransform([e[2],e[1]],t);this.minX=Math.min(this.minX,s[0],i[0],n[0],a[0]),this.minY=Math.min(this.minY,s[1],i[1],n[1],a[1]),this.maxX=Math.max(this.maxX,s[0],i[0],n[0],a[0]),this.maxY=Math.max(this.maxY,s[1],i[1],n[1],a[1])}updateScalingPathMinMax(t,e){$.scaleMinMax(t,e),this.minX=Math.min(this.minX,e[0]),this.minY=Math.min(this.minY,e[1]),this.maxX=Math.max(this.maxX,e[2]),this.maxY=Math.max(this.maxY,e[3])}updateCurvePathMinMax(t,e,s,i,n,a,o,l,h,d){const u=$.bezierBoundingBox(e,s,i,n,a,o,l,h,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=Se.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===Se.STROKE){e||Ct("Stroke bounding box must include transform.");const i=$.singularValueDecompose2dScale(e),n=i[0]*this.lineWidth/2,a=i[1]*this.lineWidth/2;s[0]-=n,s[1]-=a,s[2]+=n,s[3]+=a}return s}updateClipFromPath(){const t=$.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(t){this.clipBox=t,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(t=Se.FILL,e=null){return $.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Wd(c,t){if(typeof ImageData<"u"&&t instanceof ImageData){c.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Ie,n=(e-i)/Ie,a=i===0?n:n+1,o=c.createImageData(s,Ie);let l=0,h;const d=t.data,u=o.data;let f,g,b,y;if(t.kind===Pl.GRAYSCALE_1BPP){const w=d.byteLength,v=new Uint32Array(u.buffer,0,u.byteLength>>2),_=v.length,S=s+7>>3,E=4294967295,T=xe.isLittleEndian?4278190080:255;for(f=0;fS?s:C*8-7,M=P&-8;let O=0,L=0;for(;x>=1}for(;h<_;)v[h++]=0;c.putImageData(o,0,f*Ie)}}else if(t.kind===Pl.RGBA_32BPP){for(g=0,y=s*Ie*4,f=0;f=n&&(b=i,y=s*b),h=0,g=y;g--;)u[h++]=d[l++],u[h++]=d[l++],u[h++]=d[l++],u[h++]=255;c.putImageData(o,0,f*Ie)}else throw new Error(`bad image kind: ${t.kind}`)}function Vd(c,t){if(t.bitmap){c.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Ie,n=(e-i)/Ie,a=i===0?n:n+1,o=c.createImageData(s,Ie);let l=0;const h=t.data,d=o.data;for(let u=0;uzd&&typeof s=="function",d=h?Date.now()+Ng:0;let u=0;const f=this.commonObjs,g=this.objs;let b;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(b=a[o],b!==as.dependency)this[b].apply(this,n[o]);else for(const y of n[o]){const w=y.startsWith("g_")?f:g;if(!w.has(y))return w.get(y,s),o}if(o++,o===l)return o;if(h&&++u>zd){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){m(this,sn,xh).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(),m(this,sn,Ch).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n=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",d,u;for(;n>2&&o>1||a>2&&l>1;){let f=o,g=l;n>2&&o>1&&(f=o>=16384?Math.floor(o/2)-1||1:Math.ceil(o/2),n/=o/f),a>2&&l>1&&(g=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l)/2,a/=l/g),d=this.cachedCanvases.getCanvas(h,f,g),u=d.context,u.clearRect(0,0,f,g),u.drawImage(t,0,0,o,l,0,0,f,g),t=d.canvas,o=f,l=g,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:o,paintHeight:l}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,o=It(e);let l,h,d,u;if((t.bitmap||t.data)&&t.count>1){const P=t.bitmap||t.data.buffer;h=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(P),l||(l=new Map,this._cachedBitmapsMap.set(P,l));const M=l.get(h);if(M&&!a){const O=Math.round(Math.min(o[0],o[2])+o[4]),L=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:M,offsetX:O,offsetY:L}}d=M}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Vd(u.context,t));let f=$.transform(o,[1/s,0,0,-1/i,0,0]);f=$.transform(f,[1,0,0,1,0,-i]);const[g,b,y,w]=$.getAxialAlignedBoundingBox([0,0,s,i],f),v=Math.round(y-g)||1,_=Math.round(w-b)||1,S=this.cachedCanvases.getCanvas("fillCanvas",v,_),E=S.context,T=g,C=b;E.translate(-T,-C),E.transform(...f),d||(d=this._scaleImage(u.canvas,zs(E)),d=d.img,l&&a&&l.set(h,d)),E.imageSmoothingEnabled=qd(It(E),t.interpolate),El(E,d,0,0,d.width,d.height,0,0,s,i),E.globalCompositeOperation="source-in";const x=$.transform(zs(E),[1,0,0,1,-T,-C]);return E.fillStyle=a?n.getPattern(e,this,x,Se.FILL):n,E.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(h,S.canvas)),{canvas:S.canvas,offsetX:Math.round(T),offsetY:Math.round(C)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Bg[t]}setLineJoin(t){this.ctx.lineJoin=$g[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;s.setLineDash!==void 0&&(s.setLineDash(t),s.lineDashOffset=e)}setRenderingIntent(t){}setFlatness(t){}setGState(t){for(const[e,s]of t)switch(e){case"LW":this.setLineWidth(s);break;case"LC":this.setLineCap(s);break;case"LJ":this.setLineJoin(s);break;case"ML":this.setMiterLimit(s);break;case"D":this.setDash(s[0],s[1]);break;case"RI":this.setRenderingIntent(s);break;case"FL":this.setFlatness(s);break;case"Font":this.setFont(s[0],s[1]);break;case"CA":this.current.strokeAlpha=s;break;case"ca":this.current.fillAlpha=s,this.ctx.globalAlpha=s;break;case"BM":this.ctx.globalCompositeOperation=s;break;case"SMask":this.current.activeSMask=s?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(s);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const t=this.ctx.canvas.width,e=this.ctx.canvas.height,s="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(s,t,e);this.suspendedCtx=this.ctx,this.ctx=i.context;const n=this.ctx;n.setTransform(...It(this.suspendedCtx)),Ma(this.suspendedCtx,n),Og(n,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Ma(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 n=i[0],a=i[1],o=i[2]-n,l=i[3]-a;o===0||l===0||(this.genericComposeSMask(e.context,s,o,l,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,o,l,h,d,u){let f=t.canvas,g=l-d,b=h-u;if(a){const w=$.makeHexColor(...a);if(g<0||b<0||g+s>f.width||b+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),_=v.context;_.drawImage(f,-g,-b),_.globalCompositeOperation="destination-atop",_.fillStyle=w,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",f=v.canvas,g=b=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(g,b,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=w,t.fillRect(g,b,s,i),t.restore()}}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),n==="Alpha"&&o?e.filter=this.filterFactory.addAlphaFilter(o):n==="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(f,g,b,s,i,l,h,s,i),e.restore()}save(){this.inSMaskMode?(Ma(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){this.stateStack.length===0&&this.inSMaskMode&&this.endSMaskMode(),this.stateStack.length!==0&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),Ma(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(t,e,s,i,n,a){this.ctx.transform(t,e,s,i,n,a),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,s){const i=this.ctx,n=this.current;let a=n.x,o=n.y,l,h;const d=It(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let g=0,b=0,y=t.length;g$d&&(h=$d),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${o} ${h}px ${a}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t,e,s,i,n,a){this.current.textMatrix=[t,e,s,i,n,a],this.current.textMatrixScale=Math.hypot(t,e),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i){const n=this.ctx,a=this.current,o=a.font,l=a.textRenderingMode,h=a.fontSize/a.fontSizeScale,d=l&fe.FILL_STROKE_MASK,u=!!(l&fe.ADD_TO_PATH_FLAG),f=a.patternFill&&!o.missingFile;let g;(o.disableFontFace||u||f)&&(g=o.getPathGenerator(this.commonObjs,t)),o.disableFontFace||f?(n.save(),n.translate(e,s),n.beginPath(),g(n,h),i&&n.setTransform(...i),(d===fe.FILL||d===fe.FILL_STROKE)&&n.fill(),(d===fe.STROKE||d===fe.FILL_STROKE)&&n.stroke(),n.restore()):((d===fe.FILL||d===fe.FILL_STROKE)&&n.fillText(t,e,s),(d===fe.STROKE||d===fe.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:It(n),x:e,y:s,fontSize:h,addToPath:g})}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i0&&e[i]<255){s=!0;break}return ot(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(i===0)return;const n=this.ctx,a=e.fontSizeScale,o=e.charSpacing,l=e.wordSpacing,h=e.fontDirection,d=e.textHScale*h,u=t.length,f=s.vertical,g=f?1:-1,b=s.defaultVMetrics,y=i*e.fontMatrix[0],w=e.textRenderingMode===fe.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),h>0?n.scale(d,-1):n.scale(d,1);let v;if(e.patternFill){n.save();const C=e.fillColor.getPattern(n,this,zs(n),Se.FILL);v=It(n),n.restore(),n.fillStyle=C}let _=e.lineWidth;const S=e.textMatrixScale;if(S===0||_===0){const C=e.textRenderingMode&fe.FILL_STROKE_MASK;(C===fe.STROKE||C===fe.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=S;if(a!==1&&(n.scale(a,a),_/=a),n.lineWidth=_,s.isInvalidPDFjsFont){const C=[];let x=0;for(const P of t)C.push(P.unicode),x+=P.width;n.fillText(C.join(""),0,0),e.x+=x*y*d,n.restore(),this.compose();return}let E=0,T;for(T=0;T0){const q=n.measureText(M).width*1e3/i*a;if(Gnew Md(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Sh(t,s,this.ctx,n,i)}else e=this._getPattern(t[1],t[2]);return e}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t,e,s){this.ctx.strokeStyle=this.current.strokeColor=$.makeHexColor(t,e,s)}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent"}setFillRGBColor(t,e,s){this.ctx.fillStyle=this.current.fillColor=$.makeHexColor(t,e,s),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e=null){let s;return this.cachedPatterns.has(t)?s=this.cachedPatterns.get(t):(s=Fg(this.getObject(t)),this.cachedPatterns.set(t,s)),e&&(s.matrix=e),s}shadingFill(t){if(!this.contentVisible)return;const e=this.ctx;this.save();const s=this._getPattern(t);e.fillStyle=s.getPattern(e,this,zs(e),Se.SHADING);const i=zs(e);if(i){const{width:n,height:a}=e.canvas,[o,l,h,d]=$.getAxialAlignedBoundingBox([0,0,n,a],i);this.ctx.fillRect(o,l,h-o,d-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Ct("Should not call beginInlineImage")}beginImageData(){Ct("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=It(this.ctx),e)){const s=e[2]-e[0],i=e[3]-e[1];this.ctx.rect(e[0],e[1],s,i),this.current.updateRectMinMax(It(this.ctx),e),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const e=this.ctx;t.isolated||kc("TODO: Support non-isolated groups."),t.knockout&&nt("Knockout groups not supported.");const s=It(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=$.getAxialAlignedBoundingBox(t.bbox,It(e));const n=[0,0,e.canvas.width,e.canvas.height];i=$.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),o=Math.floor(i[1]),l=Math.max(Math.ceil(i[2])-a,1),h=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,h]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,h),f=u.context;f.translate(-a,-o),f.transform(...s),t.smask?this.smaskStack.push({canvas:u.canvas,context:f,offsetX:a,offsetY:o,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,o),e.save()),Ma(e,f),this.ctx=f,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(e),this.groupLevel++}endGroup(t){if(!this.contentVisible)return;this.groupLevel--;const e=this.ctx,s=this.groupStack.pop();if(this.ctx=s,this.ctx.imageSmoothingEnabled=!1,t.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const i=It(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...i);const n=$.getAxialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],i);this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(t,e,s,i,n){if(m(this,sn,xh).call(this),Sl(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const a=e[2]-e[0],o=e[3]-e[1];if(n&&this.annotationCanvasMap){s=s.slice(),s[4]-=e[0],s[5]-=e[1],e=e.slice(),e[0]=e[1]=0,e[2]=a,e[3]=o;const[l,h]=$.singularValueDecompose2dScale(It(this.ctx)),{viewportScale:d}=this,u=Math.ceil(a*this.outputScaleX*d),f=Math.ceil(o*this.outputScaleY*d);this.annotationCanvas=this.canvasFactory.create(u,f);const{canvas:g,context:b}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=b,this.ctx.save(),this.ctx.setTransform(l,0,0,-h,0,o*h),Sl(this.ctx)}else Sl(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new Ud(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,sn,Ch).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t){if(!this.contentVisible)return;const e=t.count;t=this.getObject(t.data,t),t.count=e;const s=this.ctx,i=this.processingType3;if(i&&(i.compiled===void 0&&(i.compiled=jg(t)),i.compiled)){i.compiled(s);return}const n=this._createMaskCanvas(t),a=n.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(a,n.offsetX,n.offsetY),s.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,s=0,i=0,n,a){if(!this.contentVisible)return;t=this.getObject(t.data,t);const o=this.ctx;o.save();const l=It(o);o.transform(e,s,i,n,0,0);const h=this._createMaskCanvas(t);o.setTransform(1,0,0,1,h.offsetX-l[4],h.offsetY-l[5]);for(let d=0,u=a.length;du?d/u:1,o=h>u?h/u:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=o}return this._cachedScaleForStroking}rescaleAndStroke(t){const{ctx:e}=this,{lineWidth:s}=this.current,[i,n]=this.getScaleForStroking();if(e.lineWidth=s||1,i===1&&n===1){e.stroke();return}const a=e.getLineDash();if(t&&e.save(),e.scale(i,n),a.length>0){const o=Math.max(i,n);e.setLineDash(a.map(l=>l/o)),e.lineDashOffset/=o}e.stroke(),t&&e.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};sn=new WeakSet,xh=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)},Ch=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}}};let Tr=Md;for(const c in as)Tr.prototype[c]!==void 0&&(Tr.prototype[as[c]]=Tr.prototype[c]);var So,xo;class mi{static get workerPort(){return r(this,So)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,So,t)}static get workerSrc(){return r(this,xo)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,xo,t)}}So=new WeakMap,xo=new WeakMap,A(mi,So,null),A(mi,xo,"");const xl={DATA:1,ERROR:2},Ut={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function De(c){switch(c instanceof Error||typeof c=="object"&&c!==null||Ct('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),c.name){case"AbortException":return new gr(c.message);case"MissingPDFException":return new pr(c.message);case"PasswordException":return new Qc(c.message,c.code);case"UnexpectedResponseException":return new Lc(c.message,c.status);case"UnknownErrorException":return new Jc(c.message,c.details);default:return new Jc(c.message,c.toString())}}var Wr,ss,Ku,Qu,Ju,Ol;class za{constructor(t,e,s){A(this,ss);A(this,Wr,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",m(this,ss,Ku).bind(this),{signal:r(this,Wr).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++,n=Promise.withResolvers();this.callbackCapabilities[i]=n;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:i,data:e},s)}catch(a){n.reject(a)}return n.promise}sendWithStream(t,e,s,i){const n=this.streamId++,a=this.sourceName,o=this.targetName,l=this.comObj;return new ReadableStream({start:h=>{const d=Promise.withResolvers();return this.streamControllers[n]={controller:h,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:h.desiredSize},i),d.promise},pull:h=>{const d=Promise.withResolvers();return this.streamControllers[n].pullCall=d,l.postMessage({sourceName:a,targetName:o,stream:Ut.PULL,streamId:n,desiredSize:h.desiredSize}),d.promise},cancel:h=>{Qt(h instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[n].cancelCall=d,this.streamControllers[n].isClosed=!0,l.postMessage({sourceName:a,targetName:o,stream:Ut.CANCEL,streamId:n,reason:De(h)}),d.promise}},s)}destroy(){var t;(t=r(this,Wr))==null||t.abort(),p(this,Wr,null)}}Wr=new WeakMap,ss=new WeakSet,Ku=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,ss,Ju).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===xl.DATA)i.resolve(t.data);else if(t.callback===xl.ERROR)i.reject(De(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,n=this.comObj;new Promise(function(a){a(e(t.data))}).then(function(a){n.postMessage({sourceName:s,targetName:i,callback:xl.DATA,callbackId:t.callbackId,data:a})},function(a){n.postMessage({sourceName:s,targetName:i,callback:xl.ERROR,callbackId:t.callbackId,reason:De(a)})});return}if(t.streamId){m(this,ss,Qu).call(this,t);return}e(t.data)},Qu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(h,d=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:Ut.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Ut.CLOSE,streamId:e}),delete a.streamSinks[e])},error(h){Qt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Ut.ERROR,streamId:e,reason:De(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,new Promise(function(h){h(o(t.data,l))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Ut.START_COMPLETE,streamId:e,success:!0})},function(h){n.postMessage({sourceName:s,targetName:i,stream:Ut.START_COMPLETE,streamId:e,reason:De(h)})})},Ju=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],o=this.streamSinks[e];switch(t.stream){case Ut.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(De(t.reason));break;case Ut.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(De(t.reason));break;case Ut.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Ut.PULL_COMPLETE,streamId:e,success:!0});break}o.desiredSize<=0&&t.desiredSize>0&&o.sinkCapability.resolve(),o.desiredSize=t.desiredSize,new Promise(function(l){var h;l((h=o.onPull)==null?void 0:h.call(o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Ut.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Ut.PULL_COMPLETE,streamId:e,reason:De(l)})});break;case Ut.ENQUEUE:if(Qt(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Ut.CLOSE:if(Qt(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,ss,Ol).call(this,a,e);break;case Ut.ERROR:Qt(a,"error should have stream controller"),a.controller.error(De(t.reason)),m(this,ss,Ol).call(this,a,e);break;case Ut.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(De(t.reason)),m(this,ss,Ol).call(this,a,e);break;case Ut.CANCEL:if(!o)break;new Promise(function(l){var h;l((h=o.onCancel)==null?void 0:h.call(o,De(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Ut.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Ut.CANCEL_COMPLETE,streamId:e,reason:De(l)})}),o.sinkCapability.reject(De(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Ol=async function(t,e){var s,i,n;await Promise.allSettled([(s=t.startCall)==null?void 0:s.promise,(i=t.pullCall)==null?void 0:i.promise,(n=t.cancelCall)==null?void 0:n.promise]),delete this.streamControllers[e]};var Ln,Co;class Gg{constructor({parsedData:t,rawData:e}){A(this,Ln);A(this,Co);p(this,Ln,t),p(this,Co,e)}getRaw(){return r(this,Co)}get(t){return r(this,Ln).get(t)??null}getAll(){return Ad(r(this,Ln))}has(t){return r(this,Ln).has(t)}}Ln=new WeakMap,Co=new WeakMap;const _r=Symbol("INTERNAL");var To,Ro,Po,Vr;class Ug{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){A(this,To,!1);A(this,Ro,!1);A(this,Po,!1);A(this,Vr,!0);p(this,To,!!(t&Ue.DISPLAY)),p(this,Ro,!!(t&Ue.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,Po))return r(this,Vr);if(!r(this,Vr))return!1;const{print:t,view:e}=this.usage;return r(this,To)?(e==null?void 0:e.viewState)!=="OFF":r(this,Ro)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==_r&&Ct("Internal method `_setVisible` called."),p(this,Po,s),p(this,Vr,e)}}To=new WeakMap,Ro=new WeakMap,Po=new WeakMap,Vr=new WeakMap;var Oi,gt,qr,Xr,ko,Th;class Wg{constructor(t,e=Ue.DISPLAY){A(this,ko);A(this,Oi,null);A(this,gt,new Map);A(this,qr,null);A(this,Xr,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Xr,t.order);for(const s of t.groups)r(this,gt).set(s.id,new Ug(e,s));if(t.baseState==="OFF")for(const s of r(this,gt).values())s._setVisible(_r,!1);for(const s of t.on)r(this,gt).get(s)._setVisible(_r,!0);for(const s of t.off)r(this,gt).get(s)._setVisible(_r,!1);p(this,qr,this.getHash())}}isVisible(t){if(r(this,gt).size===0)return!0;if(!t)return kc("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,gt).has(t.id)?r(this,gt).get(t.id).visible:(nt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,ko,Th).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,gt).has(e))return nt(`Optional content group not found: ${e}`),!0;if(r(this,gt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,gt).has(e))return nt(`Optional content group not found: ${e}`),!0;if(!r(this,gt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,gt).has(e))return nt(`Optional content group not found: ${e}`),!0;if(!r(this,gt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,gt).has(e))return nt(`Optional content group not found: ${e}`),!0;if(r(this,gt).get(e).visible)return!1}return!0}return nt(`Unknown optional content policy ${t.policy}.`),!0}return nt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=r(this,gt).get(t);if(!i){nt(`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&&((n=r(this,gt).get(o))==null||n._setVisible(_r,!1,!0));i._setVisible(_r,!!e,!0),p(this,Oi,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 n=r(this,gt).get(i);if(n)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!n.visible,e);break}}p(this,Oi,null)}get hasInitialVisibility(){return r(this,qr)===null||this.getHash()===r(this,qr)}getOrder(){return r(this,gt).size?r(this,Xr)?r(this,Xr).slice():[...r(this,gt).keys()]:null}getGroups(){return r(this,gt).size>0?Ad(r(this,gt)):null}getGroup(t){return r(this,gt).get(t)||null}getHash(){if(r(this,Oi)!==null)return r(this,Oi);const t=new ju;for(const[e,s]of r(this,gt))t.update(`${e}:${s.visible}`);return p(this,Oi,t.hexdigest())}}Oi=new WeakMap,gt=new WeakMap,qr=new WeakMap,Xr=new WeakMap,ko=new WeakSet,Th=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i0){const l=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).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(n){return n._begin!==t?!1:(n._enqueue(s),!0)});Qt(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,n;t.total===void 0?(s=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||s.call(e,{loaded:t.loaded}):(n=(i=this._fullRequestReader)==null?void 0:i.onProgress)==null||n.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(){Qt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new qg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Xg(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 qg{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=wd(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.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 Xg{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 Yg(c){let t=!0,e=s("filename\\*","i").exec(c);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=h(d),n(d)}if(e=a(c),e){const d=h(e);return n(d)}if(e=s("filename","i").exec(c),e){e=e[1];let d=o(e);return d=h(d),n(d)}function s(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function i(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(d,{fatal:!0}),g=Mc(u);u=f.decode(g),t=!1}catch{}}return u}function n(d){return t&&/[\x80-\xff]/.test(d)&&(d=i("utf-8",d),t&&(d=i("iso-8859-1",d))),d}function a(d){const u=[];let f;const g=s("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=g.exec(d))!==null;){let[,y,w,v]=f;if(y=parseInt(y,10),y in u){if(y===0)break;continue}u[y]=[w,v]}const b=[];for(let y=0;y{if(!Zu(n.status))throw Dc(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const a=n.headers,{allowRangeRequests:o,suggestedLength:l}=Td({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=Rd(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new gr("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:ef(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class Qg{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 n=new Headers(t.headers);n.append("Range",`bytes=${e}-${s-1}`);const a=i.url;fetch(a,tf(n,this._withCredentials,this._abortController)).then(o=>{if(!Zu(o.status))throw Dc(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:ef(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Wc=200,Vc=206;function Jg(c){const t=c.response;return typeof t!="string"?t:Mc(t).buffer}class Zg{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Cd(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(t,e,s){const i={begin:t,end:e};for(const n in s)i[n]=s[n];return this.request(i)}requestFull(t){return this.request(t)}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[n,a]of this.headers)e.setRequestHeader(n,a);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),i.expectedStatus=Vc):i.expectedStatus=Wc,e.responseType="arraybuffer",t.onError&&(e.onerror=function(n){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){var l,h,d;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){(l=s.onError)==null||l.call(s,i.status);return}const n=i.status||Wc;if(!(n===Wc&&s.expectedStatus===Vc)&&n!==s.expectedStatus){(h=s.onError)==null||h.call(s,i.status);return}const o=Jg(i);if(n===Vc){const u=i.getResponseHeader("Content-Range"),f=/bytes (\d+)-(\d+)\/(\d+)/.exec(u);s.onDone({begin:parseInt(f[1],10),chunk:o})}else o?s.onDone({begin:0,chunk:o}):(d=s.onError)==null||d.call(s,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 tm{constructor(t){this._source=t,this._manager=new Zg(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 Qt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new em(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new sm(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 em{constructor(t,e){this._manager=t;const s={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._fullRequestId=t.requestFull(s),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),s=new Headers(e.getAllResponseHeaders().trim().split(/[\r\n]+/).map(a=>{const[o,...l]=a.split(": ");return[o,l.join(": ")]})),{allowRangeRequests:i,suggestedLength:n}=Td({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Rd(s),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=Dc(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(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 sm{constructor(t,e,s){this._manager=t;const i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._requestId=t.requestRange(e,s,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_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=Dc(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 im=/^[a-z][a-z0-9\-+.]+:/i;function nm(c){if(im.test(c))return new URL(c);const t=tn.get("url");return new URL(t.pathToFileURL(c))}function sf(c,t,e){return c.protocol==="http:"?tn.get("http").request(c,{headers:t},e):tn.get("https").request(c,{headers:t},e)}class rm{constructor(t){this.source=t,this.url=nm(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=Cd(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 Qt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new lm(this):new am(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new cm(this,t,e):new om(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 nf{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()}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 gr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class rf{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const e=t.source;this._isStreamingSupported=!e.disableStream}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)}}class am extends nf{constructor(t){super(t);const e=Object.fromEntries(t.headers),s=i=>{if(i.statusCode===404){const l=new pr(`Missing PDF "${this._url}".`);this._storedError=l,this._headersCapability.reject(l);return}this._headersCapability.resolve(),this._setReadableStream(i);const n=new Headers(this._readableStream.headers),{allowRangeRequests:a,suggestedLength:o}=Td({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Rd(n)};this._request=sf(this._url,e,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class om extends rf{constructor(t,e,s){super(t);const i=Object.fromEntries(t.headers);i.Range=`bytes=${e}-${s-1}`;const n=a=>{if(a.statusCode===404){const o=new pr(`Missing PDF "${this._url}".`);this._storedError=o;return}this._setReadableStream(a)};this._request=sf(this._url,i,n),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class lm extends nf{constructor(t){super(t);const e=tn.get("fs");e.promises.lstat(this._url).then(s=>{this._contentLength=s.size,this._setReadableStream(e.createReadStream(this._url)),this._headersCapability.resolve()},s=>{s.code==="ENOENT"&&(s=new pr(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class cm extends rf{constructor(t,e,s){super(t);const i=tn.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const hm=1e5,Re=30,dm=.8;var cu,Hi,Le,Lo,Mo,Mn,Js,Io,Fo,In,Yr,Kr,ji,Qr,Do,Jr,Fn,No,Oo,Ot,Dn,Nn,Ho,Bi,Zr,vi,af,of,Ph,Ve,Hl,kh,lf,cf;let Rh=(Ot=class{constructor({textContentSource:t,container:e,viewport:s}){A(this,vi);A(this,Hi,Promise.withResolvers());A(this,Le,null);A(this,Lo,!1);A(this,Mo,!!((cu=globalThis.FontInspector)!=null&&cu.enabled));A(this,Mn,null);A(this,Js,null);A(this,Io,0);A(this,Fo,0);A(this,In,null);A(this,Yr,null);A(this,Kr,0);A(this,ji,0);A(this,Qr,Object.create(null));A(this,Do,[]);A(this,Jr,null);A(this,Fn,[]);A(this,No,new WeakMap);A(this,Oo,null);var l;if(t instanceof ReadableStream)p(this,Jr,t);else if(typeof t=="object")p(this,Jr,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Le,p(this,Yr,e)),p(this,ji,s.scale*(globalThis.devicePixelRatio||1)),p(this,Kr,s.rotation),p(this,Js,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;p(this,Oo,[1,0,0,-1,-a,o+n]),p(this,Fo,i),p(this,Io,n),m(l=Ot,Ve,lf).call(l),lr(e,s),r(this,Hi).promise.finally(()=>{r(Ot,Zr).delete(this),p(this,Js,null),p(this,Qr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=xe.platform;return ot(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{r(this,In).read().then(({value:e,done:s})=>{if(s){r(this,Hi).resolve();return}r(this,Mn)??p(this,Mn,e.lang),Object.assign(r(this,Qr),e.styles),m(this,vi,af).call(this,e.items),t()},r(this,Hi).reject)};return p(this,In,r(this,Jr).getReader()),r(Ot,Zr).add(this),t(),r(this,Hi).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,Kr)&&(e==null||e(),p(this,Kr,i),lr(r(this,Yr),{rotation:i})),s!==r(this,ji)){e==null||e(),p(this,ji,s);const a={div:null,properties:null,ctx:m(n=Ot,Ve,Hl).call(n,r(this,Mn))};for(const o of r(this,Fn))a.properties=r(this,No).get(o),a.div=o,m(this,vi,Ph).call(this,a)}}cancel(){var e;const t=new gr("TextLayer task cancelled.");(e=r(this,In))==null||e.cancel(t).catch(()=>{}),p(this,In,null),r(this,Hi).reject(t)}get textDivs(){return r(this,Fn)}get textContentItemsStr(){return r(this,Do)}static cleanup(){if(!(r(this,Zr).size>0)){r(this,Dn).clear();for(const{canvas:t}of r(this,Nn).values())t.remove();r(this,Nn).clear()}}},Hi=new WeakMap,Le=new WeakMap,Lo=new WeakMap,Mo=new WeakMap,Mn=new WeakMap,Js=new WeakMap,Io=new WeakMap,Fo=new WeakMap,In=new WeakMap,Yr=new WeakMap,Kr=new WeakMap,ji=new WeakMap,Qr=new WeakMap,Do=new WeakMap,Jr=new WeakMap,Fn=new WeakMap,No=new WeakMap,Oo=new WeakMap,Dn=new WeakMap,Nn=new WeakMap,Ho=new WeakMap,Bi=new WeakMap,Zr=new WeakMap,vi=new WeakSet,af=function(t){var i,n;if(r(this,Lo))return;(n=r(this,Js)).ctx??(n.ctx=m(i=Ot,Ve,Hl).call(i,r(this,Mn)));const e=r(this,Fn),s=r(this,Do);for(const a of t){if(e.length>hm){nt("Ignoring additional textDivs for performance reasons."),p(this,Lo,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,Le);p(this,Le,document.createElement("span")),r(this,Le).classList.add("markedContent"),a.id!==null&&r(this,Le).setAttribute("id",`${a.id}`),o.append(r(this,Le))}else a.type==="endMarkedContent"&&p(this,Le,r(this,Le).parentNode);continue}s.push(a.str),m(this,vi,of).call(this,a)}},of=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,Fn).push(e);const i=$.transform(r(this,Oo),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,Qr)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,Mo)&&a.fontSubstitution||a.fontFamily;o=Ot.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),h=l*m(y=Ot,Ve,cf).call(y,o,r(this,Mn));let d,u;n===0?(d=i[4],u=i[5]-h):(d=i[4]+h*Math.sin(n),u=i[5]-h*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;r(this,Le)===r(this,Yr)?(g.left=`${(100*d/r(this,Fo)).toFixed(2)}%`,g.top=`${(100*u/r(this,Io)).toFixed(2)}%`):(g.left=`${f}${d.toFixed(2)}px)`,g.top=`${f}${u.toFixed(2)}px)`),g.fontSize=`${f}${(r(Ot,Bi)*l).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,Mo)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let b=!1;if(t.str.length>1)b=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const w=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);w!==v&&Math.max(w,v)/Math.min(w,v)>1.5&&(b=!0)}if(b&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,No).set(e,s),r(this,Js).div=e,r(this,Js).properties=s,m(this,vi,Ph).call(this,r(this,Js)),s.hasText&&r(this,Le).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),r(this,Le).append(w)}},Ph=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(r(Ot,Bi)>1&&(a=`scale(${1/r(Ot,Bi)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=n,{canvasWidth:h,fontSize:d}=s;m(o=Ot,Ve,kh).call(o,i,d*r(this,ji),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${h*r(this,ji)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)},Ve=new WeakSet,Hl=function(t=null){let e=r(this,Nn).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}),r(this,Nn).set(t,e),r(this,Ho).set(e,{size:0,family:""})}return e},kh=function(t,e,s){const i=r(this,Ho).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},lf=function(){if(r(this,Bi)!==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,Bi,t.getBoundingClientRect().height),t.remove()},cf=function(t,e){const s=r(this,Dn).get(t);if(s)return s;const i=m(this,Ve,Hl).call(this,e);i.canvas.width=i.canvas.height=Re,m(this,Ve,kh).call(this,i,Re,t);const n=i.measureText("");let a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(a){const d=a/(a+o);return r(this,Dn).set(t,d),i.canvas.width=i.canvas.height=0,d}i.strokeStyle="red",i.clearRect(0,0,Re,Re),i.strokeText("g",0,0);let l=i.getImageData(0,0,Re,Re).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/Re);break}i.clearRect(0,0,Re,Re),i.strokeText("A",0,Re),l=i.getImageData(0,0,Re,Re).data,a=0;for(let d=0,u=l.length;d0){a=Re-Math.floor(d/4/Re);break}i.canvas.width=i.canvas.height=0;const h=a?a/(a+o):dm;return r(this,Dn).set(t,h),h},A(Ot,Ve),A(Ot,Dn,new Map),A(Ot,Nn,new Map),A(Ot,Ho,new WeakMap),A(Ot,Bi,null),A(Ot,Zr,new Set),Ot);class eo{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};function i(n){var l;if(!n)return;let a=null;const o=n.name;if(o==="#text")a=n.value;else if(eo.shouldBuildText(o))(l=n==null?void 0:n.attributes)!=null&&l.textContent?a=n.attributes.textContent:n.value&&(a=n.value);else return;if(a!==null&&e.push({str:a}),!!n.children)for(const h of n.children)i(h)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const um=65536,fm=100,pm=5e3,gm=ve?Tg:Sg,mm=ve?Rg:Uu,bm=ve?Cg:xg,Am=ve?Pg:Xu;function ym(c={}){typeof c=="string"||c instanceof URL?c={url:c}:(c instanceof ArrayBuffer||ArrayBuffer.isView(c))&&(c={data:c});const t=new Lh,{docId:e}=t,s=c.url?vm(c.url):null,i=c.data?wm(c.data):null,n=c.httpHeaders||null,a=c.withCredentials===!0,o=c.password??null,l=c.range instanceof hf?c.range:null,h=Number.isInteger(c.rangeChunkSize)&&c.rangeChunkSize>0?c.rangeChunkSize:um;let d=c.worker instanceof Rr?c.worker:null;const u=c.verbosity,f=typeof c.docBaseUrl=="string"&&!Fc(c.docBaseUrl)?c.docBaseUrl:null,g=typeof c.cMapUrl=="string"?c.cMapUrl:null,b=c.cMapPacked!==!1,y=c.CMapReaderFactory||mm,w=typeof c.standardFontDataUrl=="string"?c.standardFontDataUrl:null,v=c.StandardFontDataFactory||Am,_=c.stopAtErrors!==!0,S=Number.isInteger(c.maxImageSize)&&c.maxImageSize>-1?c.maxImageSize:-1,E=c.isEvalSupported!==!1,T=typeof c.isOffscreenCanvasSupported=="boolean"?c.isOffscreenCanvasSupported:!ve,C=typeof c.isChrome=="boolean"?c.isChrome:!xe.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),x=Number.isInteger(c.canvasMaxAreaInBytes)?c.canvasMaxAreaInBytes:-1,P=typeof c.disableFontFace=="boolean"?c.disableFontFace:ve,M=c.fontExtraProperties===!0,O=c.enableXfa===!0,L=c.ownerDocument||globalThis.document,V=c.disableRange===!0,G=c.disableStream===!0,z=c.disableAutoFetch===!0,q=c.pdfBug===!0,W=c.CanvasFactory||gm,D=c.FilterFactory||bm,j=c.enableHWA===!0,Rt=l?l.length:c.length??NaN,Et=typeof c.useSystemFonts=="boolean"?c.useSystemFonts:!ve&&!P,St=typeof c.useWorkerFetch=="boolean"?c.useWorkerFetch:y===Uu&&v===Xu&&g&&w&&Da(g,document.baseURI)&&Da(w,document.baseURI);c.canvasFactory&&Od("`canvasFactory`-instance option, please use `CanvasFactory` instead."),c.filterFactory&&Od("`filterFactory`-instance option, please use `FilterFactory` instead.");const ut=null;eg(u);const ht={canvasFactory:new W({ownerDocument:L,enableHWA:j}),filterFactory:new D({docId:e,ownerDocument:L}),cMapReaderFactory:St?null:new y({baseUrl:g,isCompressed:b}),standardFontDataFactory:St?null:new v({baseUrl:w})};if(!d){const et={verbosity:u,port:mi.workerPort};d=et.port?Rr.fromPort(et):new Rr(et),t._worker=d}const Ht={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:z,rangeChunkSize:h,length:Rt,docBaseUrl:f,enableXfa:O,evaluatorOptions:{maxImageSize:S,disableFontFace:P,ignoreErrors:_,isEvalSupported:E,isOffscreenCanvasSupported:T,isChrome:C,canvasMaxAreaInBytes:x,fontExtraProperties:M,useSystemFonts:Et,cMapUrl:St?g:null,standardFontDataUrl:St?w:null}},ue={disableFontFace:P,fontExtraProperties:M,ownerDocument:L,pdfBug:q,styleElement:ut,loadingParams:{disableAutoFetch:z,enableXfa:O}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const et=d.messageHandler.sendWithPromise("GetDocRequest",Ht,i?[i.buffer]:null);let J;if(l)J=new Vg(l,{disableRange:V,disableStream:G});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let $t;ve?$t=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&Da(s)?Yd:rm:$t=Da(s)?Yd:tm,J=new $t({url:s,length:Rt,httpHeaders:n,withCredentials:a,rangeChunkSize:h,disableRange:V,disableStream:G})}return et.then($t=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Zt=new za(e,$t,d.port),ct=new xm(Zt,t,J,ue,ht);t._transport=ct,Zt.send("Ready",null)})}).catch(t._capability.reject),t}function vm(c){if(c instanceof URL)return c.href;try{return new URL(c,window.location).href}catch{if(ve&&typeof c=="string")return c}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function wm(c){if(ve&&typeof Buffer<"u"&&c instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(c instanceof Uint8Array&&c.byteLength===c.buffer.byteLength)return c;if(typeof c=="string")return Mc(c);if(c instanceof ArrayBuffer||ArrayBuffer.isView(c)||typeof c=="object"&&!isNaN(c==null?void 0:c.length))return new Uint8Array(c);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Kd(c){return typeof c=="object"&&Number.isInteger(c==null?void 0:c.num)&&c.num>=0&&Number.isInteger(c==null?void 0:c.gen)&&c.gen>=0}var yc;const vc=class vc{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${we(vc,yc)._++}`,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){var t,e,s;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(i){throw(s=this._worker)!=null&&s.port&&delete this._worker._pendingDestroy,i}this._transport=null,this._worker&&(this._worker.destroy(),this._worker=null)}};yc=new WeakMap,A(vc,yc,0);let Lh=vc,hf=class{constructor(t,e,s=!1,i=null){this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(t){this._rangeListeners.push(t)}addProgressListener(t){this._progressListeners.push(t)}addProgressiveReadListener(t){this._progressiveReadListeners.push(t)}addProgressiveDoneListener(t){this._progressiveDoneListeners.push(t)}onDataRange(t,e){for(const s of this._rangeListeners)s(t,e)}onDataProgress(t,e){this._readyCapability.promise.then(()=>{for(const s of this._progressListeners)s(t,e)})}onDataProgressiveRead(t){this._readyCapability.promise.then(()=>{for(const e of this._progressiveReadListeners)e(t)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(const t of this._progressiveDoneListeners)t()})}transportReady(){this._readyCapability.resolve()}requestDataRange(t,e){Ct("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class _m{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 ot(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}var $i,Zs,ts,Er,jl;class Em{constructor(t,e,s,i=!1){A(this,ts);A(this,$i,null);A(this,Zs,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Nd:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new df,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:s=0,offsetY:i=0,dontFlip:n=!1}={}){return new Al({viewBox:this.view,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return ot(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,viewport:e,intent:s="display",annotationMode:i=xi.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:d=null,isEditing:u=!1}){var E,T;(E=this._stats)==null||E.time("Overall");const f=this._transport.getRenderingIntent(s,i,d,u),{renderingIntent:g,cacheKey:b}=f;p(this,Zs,!1),m(this,ts,jl).call(this),o||(o=this._transport.getOptionalContentConfig(g));let y=this._intentStates.get(b);y||(y=Object.create(null),this._intentStates.set(b,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const w=!!(g&Ue.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(T=this._stats)==null||T.time("Page Request"),this._pumpOperatorList(f));const v=C=>{var x;y.renderTasks.delete(_),(this._maybeCleanupAfterRender||w)&&p(this,Zs,!0),m(this,ts,Er).call(this,!w),C?(_.capability.reject(C),this._abortOperatorList({intentState:y,reason:C instanceof Error?C:new Error(C)})):_.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(x=globalThis.Stats)!=null&&x.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new Ih({callback:v,params:{canvasContext:t,viewport:e,transform:n,background:a},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:y.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:h});(y.renderTasks||(y.renderTasks=new Set)).add(_);const S=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([C,x])=>{var P;if(this.destroyed){v();return}if((P=this._stats)==null||P.time("Rendering"),!(x.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:C,optionalContentConfig:x}),_.operatorListChanged()}).catch(v),S}getOperatorList({intent:t="display",annotationMode:e=xi.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var h;function n(){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=n,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=>eo.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){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),n()},i)}const a=e.getReader(),o={items:[],styles:Object.create(null),lang:null};n()})}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,Zs,!1),m(this,ts,jl).call(this),Promise.all(t)}cleanup(t=!1){p(this,Zs,!0);const e=m(this,ts,Er).call(this,!1);return t&&e&&this._stats&&(this._stats=new Nd),e}_startRenderPage(t,e){var i,n;const s=this._intentStates.get(e);s&&((i=this._stats)==null||i.timeEnd("Page Request"),(n=s.displayReadyCapability)==null||n.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s{l.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),d())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();m(this,ts,Er).call(this,!0)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};d()}_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 vd){let i=fm;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 gr(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[i,n]of this._intentStates)if(n===t){this._intentStates.delete(i);break}this.cleanup()}}}get stats(){return this._stats}}$i=new WeakMap,Zs=new WeakMap,ts=new WeakSet,Er=function(t=!1){if(m(this,ts,jl).call(this),!r(this,Zs)||this.destroyed)return!1;if(t)return p(this,$i,setTimeout(()=>{p(this,$i,null),m(this,ts,Er).call(this,!1)},pm)),!1;for(const{renderTasks:e,operatorList:s}of this._intentStates.values())if(e.size>0||!s.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,Zs,!1),!0},jl=function(){r(this,$i)&&(clearTimeout(r(this,$i)),p(this,$i,null))};var ti,wc;class Sm{constructor(){A(this,ti,new Map);A(this,wc,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,wc).then(()=>{for(const[i]of r(this,ti))i.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((s==null?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted){nt("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}r(this,ti).set(e,i)}removeEventListener(t,e){const s=r(this,ti).get(e);s==null||s(),r(this,ti).delete(e)}terminate(){for(const[,t]of r(this,ti))t==null||t();r(this,ti).clear()}}ti=new WeakMap,wc=new WeakMap;var _c,On,Hn,ta,Bl,ea,$l;const Tt=class Tt{constructor({name:t=null,port:e=null,verbosity:s=sg()}={}){A(this,ta);var i;if(this.name=t,this.destroyed=!1,this.verbosity=s,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,e){if((i=r(Tt,Hn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(Tt,Hn)||p(Tt,Hn,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return ve?Promise.all([tn.promise,this._readyCapability.promise]):this._readyCapability.promise}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(t){this._port=t,this._messageHandler=new za("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,ta,Bl).call(this)}_initialize(){if(r(Tt,On)||r(Tt,ea,$l)){this._setupFakeWorker();return}let{workerSrc:t}=Tt;try{Tt._isSameOrigin(window.location.href,t)||(t=Tt._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new za("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},n=new AbortController;e.addEventListener("error",()=>{this._webWorker||i()},{signal:n.signal}),s.on("test",o=>{if(n.abort(),this.destroyed||!o){i();return}this._messageHandler=s,this._port=e,this._webWorker=e,m(this,ta,Bl).call(this)}),s.on("ready",o=>{if(n.abort(),this.destroyed){i();return}try{a()}catch{this._setupFakeWorker()}});const a=()=>{const o=new Uint8Array;s.send("test",o,[o.buffer])};a();return}catch{kc("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){r(Tt,On)||(nt("Setting up fake worker."),p(Tt,On,!0)),Tt._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new Sm;this._port=e;const s=`fake${we(Tt,_c)._++}`,i=new za(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new za(s,s+"_worker",e),m(this,ta,Bl).call(this)}).catch(t=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${t.message}".`))})}destroy(){var t;this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),(t=r(Tt,Hn))==null||t.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(t){var s;if(!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");const e=(s=r(this,Hn))==null?void 0:s.get(t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new Tt(t)}static get workerSrc(){if(mi.workerSrc)return mi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ot(this,"_setupFakeWorkerGlobal",(async()=>r(this,ea,$l)?r(this,ea,$l):(await import(this.workerSrc)).WorkerMessageHandler)())}};_c=new WeakMap,On=new WeakMap,Hn=new WeakMap,ta=new WeakSet,Bl=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},ea=new WeakSet,$l=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},A(Tt,ea),A(Tt,_c,0),A(Tt,On,!1),A(Tt,Hn),ve&&(p(Tt,On,!0),mi.workerSrc||(mi.workerSrc="./pdf.worker.mjs")),Tt._isSameOrigin=(t,e)=>{let s;try{if(s=new URL(t),!s.origin||s.origin==="null")return!1}catch{return!1}const i=new URL(e,s);return s.origin===i.origin},Tt._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Rr=Tt;var ei,Is,sa,ia,Fs,jn,Ga;class xm{constructor(t,e,s,i,n){A(this,jn);A(this,ei,new Map);A(this,Is,new Map);A(this,sa,new Map);A(this,ia,new Map);A(this,Fs,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new df,this.fontLoader=new _g({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=n.canvasFactory,this.filterFactory=n.filterFactory,this.cMapReaderFactory=n.cMapReaderFactory,this.standardFontDataFactory=n.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}get annotationStorage(){return ot(this,"annotationStorage",new Sd)}getRenderingIntent(t,e=xi.ENABLE,s=null,i=!1,n=!1){let a=Ue.DISPLAY,o=yh;switch(t){case"any":a=Ue.ANY;break;case"display":break;case"print":a=Ue.PRINT;break;default:nt(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Ue.PRINT&&s instanceof $u?s:this.annotationStorage;switch(e){case xi.DISABLE:a+=Ue.ANNOTATIONS_DISABLE;break;case xi.ENABLE:break;case xi.ENABLE_FORMS:a+=Ue.ANNOTATIONS_FORMS;break;case xi.ENABLE_STORAGE:a+=Ue.ANNOTATIONS_STORAGE,o=l.serializable;break;default:nt(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Ue.IS_EDITING),n&&(a+=Ue.OPLIST);const{ids:h,hash:d}=l.modifiedIds,u=[a,o.hash,d];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:h}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,Fs))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,Is).values())t.push(i._destroy());r(this,Is).clear(),r(this,sa).clear(),r(this,ia).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var i;this.commonObjs.clear(),this.fontLoader.clear(),r(this,ei).clear(),this.filterFactory.destroy(),Rh.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new gr("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(s,i)=>{Qt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=n=>{this._lastProgress={loaded:n.loaded,total:n.total}},i.onPull=()=>{this._fullReader.read().then(function({value:n,done:a}){if(a){i.close();return}Qt(n instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(n),1,[n])}).catch(n=>{i.error(n)})},i.onCancel=n=>{this._fullReader.cancel(n),i.ready.catch(a=>{if(!this.destroyed)throw a})}}),t.on("ReaderHeadersReady",async s=>{var o;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:a}=this._fullReader;return(!i||!n)&&(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:n,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{Qt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(s.begin,s.end);if(!n){i.close();return}i.onPull=()=>{n.read().then(function({value:a,done:o}){if(o){i.close();return}Qt(a instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),i.enqueue(new Uint8Array(a),1,[a])}).catch(a=>{i.error(a)})},i.onCancel=a=>{n.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 _m(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Qc(s.message,s.code);break;case"InvalidPDFException":i=new fu(s.message);break;case"MissingPDFException":i=new pr(s.message);break;case"UnexpectedResponseException":i=new Lc(s.message,s.status);break;case"UnknownErrorException":i=new Jc(s.message,s.details);break;default:Ct("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,Fs,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,Fs).reject(n):r(this,Fs).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,Fs).reject(n)}}else r(this,Fs).reject(new Qc(s.message,s.code));return r(this,Fs).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;r(this,Is).get(s.pageIndex)._startRenderPage(s.transparency,s.cacheKey)}),t.on("commonobj",([s,i,n])=>{var a;if(this.destroyed||this.commonObjs.has(s))return null;switch(i){case"Font":const{disableFontFace:o,fontExtraProperties:l,pdfBug:h}=this._params;if("error"in n){const g=n.error;nt(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const d=h&&((a=globalThis.FontInspector)!=null&&a.enabled)?(g,b)=>globalThis.FontInspector.fontAdded(g,b):null,u=new Eg(n,{disableFontFace:o,inspectFont:d});this.fontLoader.bind(u).catch(()=>t.sendWithPromise("FontFallback",{id:s})).finally(()=>{!l&&u.data&&(u.data=null),this.commonObjs.resolve(s,u)});break;case"CopyLocalImage":const{imageRef:f}=n;Qt(f,"The imageRef must be defined.");for(const g of r(this,Is).values())for(const[,b]of g.objs)if((b==null?void 0:b.ref)===f)return b.dataLen?(this.commonObjs.resolve(s,structuredClone(b)),b.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(s,n);break;default:throw new Error(`Got unknown common object type ${i}`)}return null}),t.on("obj",([s,i,n,a])=>{var l;if(this.destroyed)return;const o=r(this,Is).get(i);if(!o.objs.has(s)){if(o._intentStates.size===0){(l=a==null?void 0:a.bitmap)==null||l.close();return}switch(n){case"Image":o.objs.resolve(s,a),(a==null?void 0:a.dataLen)>Qp&&(o._maybeCleanupAfterRender=!0);break;case"Pattern":o.objs.resolve(s,a);break;default:throw new Error(`Got unknown object type ${n}`)}}}),t.on("DocProgress",s=>{var i;this.destroyed||(i=e.onProgress)==null||i.call(e,{loaded:s.loaded,total:s.total})}),t.on("FetchBuiltInCMap",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(s)}),t.on("FetchStandardFontData",async s=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(s)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var s;this.annotationStorage.size<=0&&nt("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=r(this,sa).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&r(this,ia).set(n.refStr,t);const a=new Em(e,n,this,this._params.pdfBug);return r(this,Is).set(e,a),a});return r(this,sa).set(e,i),i}getPageIndex(t){return Kd(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 m(this,jn,Ga).call(this,"GetFieldObjects")}hasJSActions(){return m(this,jn,Ga).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)}getDocJSActions(){return m(this,jn,Ga).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 m(this,jn,Ga).call(this,"GetOptionalContentConfig").then(e=>new Wg(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,ei).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(i=>{var n,a;return{info:i[0],metadata:i[1]?new Gg(i[1]):null,contentDispositionFilename:((n=this._fullReader)==null?void 0:n.filename)??null,contentLength:((a=this._fullReader)==null?void 0:a.contentLength)??null}});return r(this,ei).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 r(this,Is).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,ei).clear(),this.filterFactory.destroy(!0),Rh.cleanup()}}cachedPageNumber(t){if(!Kd(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,ia).get(e)??null}}ei=new WeakMap,Is=new WeakMap,sa=new WeakMap,ia=new WeakMap,Fs=new WeakMap,jn=new WeakSet,Ga=function(t,e=null){const s=r(this,ei).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,ei).set(t,i),i};const Cl=Symbol("INITIAL_DATA");var us,jo,Mh;class df{constructor(){A(this,jo);A(this,us,Object.create(null))}get(t,e=null){if(e){const i=m(this,jo,Mh).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,us)[t];if(!s||s.data===Cl)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,us)[t];return!!e&&e.data!==Cl}resolve(t,e=null){const s=m(this,jo,Mh).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,us)){const{data:s}=r(this,us)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,us,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,us)){const{data:e}=r(this,us)[t];e!==Cl&&(yield[t,e])}}}us=new WeakMap,jo=new WeakSet,Mh=function(t){var e;return(e=r(this,us))[t]||(e[t]={...Promise.withResolvers(),data:Cl})};var zi;class Cm{constructor(t){A(this,zi,null);p(this,zi,t),this.onContinue=null}get promise(){return r(this,zi).capability.promise}cancel(t=0){r(this,zi).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,zi).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,zi);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}zi=new WeakMap;var Gi,Bn;const dn=class dn{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:h,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null}){A(this,Gi,null);this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=o,this.canvasFactory=l,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Cm(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvasContext.canvas}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var o,l;if(this.cancelled)return;if(this._canvas){if(r(dn,Bn).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.");r(dn,Bn).add(this._canvas)}this._pdfBug&&((o=globalThis.StepperManager)!=null&&o.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:s,viewport:i,transform:n,background:a}=this.params;this.gfx=new Tr(s,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:a}),this.operatorListIdx=0,this.graphicsReady=!0,(l=this.graphicsReadyCallback)==null||l.call(this)}cancel(t=null,e=0){var s;this.running=!1,this.cancelled=!0,(s=this.gfx)==null||s.endDrawing(),r(this,Gi)&&(window.cancelAnimationFrame(r(this,Gi)),p(this,Gi,null)),r(dn,Bn).delete(this._canvas),this.callback(t||new vd(`Rendering cancelled, page ${this._pageIndex+1}`,e))}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,Gi,window.requestAnimationFrame(()=>{p(this,Gi,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),r(dn,Bn).delete(this._canvas),this.callback())))}};Gi=new WeakMap,Bn=new WeakMap,A(dn,Bn,new WeakSet);let Ih=dn;const Tm="4.8.69",Rm="3634dab10";function Qd(c){return Math.floor(Math.max(0,Math.min(1,c))*255).toString(16).padStart(2,"0")}function Ia(c){return Math.max(0,Math.min(255,255*c))}class Jd{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=Ia(t),[t,t,t]}static G_HTML([t]){const e=Qd(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(Ia)}static RGB_HTML(t){return`#${t.map(Qd).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[Ia(1-Math.min(1,t+i)),Ia(1-Math.min(1,s+i)),Ia(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,n=1-e,a=1-s,o=Math.min(i,n,a);return["CMYK",i,n,a,o]}}class Pm{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){Ct("Abstract method `_createSVG` called.")}}class Pd extends Pm{_createSVG(t){return document.createElementNS(Gs,t)}}class uf{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(a.value!==null&&(t.textContent=a.value),n==="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"),n==="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),n==="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:n}){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&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var u,f;const e=t.annotationStorage,s=t.linkService,i=t.xfaHtml,n=t.intent||"display",a=document.createElement(i.name);i.attributes&&this.setAttributes({html:a,element:i,intent:n,linkService:s});const o=n!=="richText",l=t.div;if(l.append(a),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;l.style.transform=g}o&&l.setAttribute("class","xfaLayer xfaFont");const h=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&eo.shouldBuildText(i.name)&&h.push(g)}return{textDivs:h}}const d=[[i,-1,a]];for(;d.length>0;){const[g,b,y]=d.at(-1);if(b+1===g.children.length){d.pop();continue}const w=g.children[++d.at(-1)[1]];if(w===null)continue;const{name:v}=w;if(v==="#text"){const S=document.createTextNode(w.value);h.push(S),y.append(S);continue}const _=(u=w==null?void 0:w.attributes)!=null&&u.xmlns?document.createElementNS(w.attributes.xmlns,v):document.createElement(v);if(y.append(_),w.attributes&&this.setAttributes({html:_,element:w,storage:e,intent:n,linkService:s}),((f=w.children)==null?void 0:f.length)>0)d.push([w,-1,_]);else if(w.value){const S=document.createTextNode(w.value);o&&eo.shouldBuildText(v)&&h.push(S),_.append(S)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.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 vl=1e3,km=9,hr=new WeakSet;function bi(c){return{width:c[2]-c[0],height:c[3]-c[1]}}class Lm{static create(t){switch(t.data.annotationType){case qt.LINK:return new ff(t);case qt.TEXT:return new Mm(t);case qt.WIDGET:switch(t.data.fieldType){case"Tx":return new Im(t);case"Btn":return t.data.radioButton?new mf(t):t.data.checkBox?new Dm(t):new Nm(t);case"Ch":return new Om(t);case"Sig":return new Fm(t)}return new mr(t);case qt.POPUP:return new Dh(t);case qt.FREETEXT:return new wf(t);case qt.LINE:return new jm(t);case qt.SQUARE:return new Bm(t);case qt.CIRCLE:return new $m(t);case qt.POLYLINE:return new _f(t);case qt.CARET:return new Gm(t);case qt.INK:return new kd(t);case qt.POLYGON:return new zm(t);case qt.HIGHLIGHT:return new Ef(t);case qt.UNDERLINE:return new Um(t);case qt.SQUIGGLY:return new Wm(t);case qt.STRIKEOUT:return new Vm(t);case qt.STAMP:return new Sf(t);case qt.FILEATTACHMENT:return new qm(t);default:return new Bt(t)}}}var $n,na,ra,Bo,Fh;const Id=class Id{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){A(this,Bo);A(this,$n,null);A(this,na,!1);A(this,ra,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.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({titleObj:t,contentsObj:e,richText:s}){return!!(t!=null&&t.str||e!=null&&e.str||s!=null&&s.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Id._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,$n)||p(this,$n,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,Bo,Fh).call(this,e),(s=r(this,ra))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,$n)&&(m(this,Bo,Fh).call(this,r(this,$n).rect),(t=r(this,ra))==null||t.popup.resetEdited(),p(this,$n,null))}_createContainer(t){const{data:e,parent:{page:s,viewport:i}}=this,n=document.createElement("section");n.setAttribute("data-annotation-id",e.id),this instanceof mr||(n.tabIndex=vl);const{style:a}=n;if(a.zIndex=this.parent.zIndex++,e.alternativeText&&(n.title=e.alternativeText),e.noRotate&&n.classList.add("norotate"),!e.rect||this instanceof Dh){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,n),n}const{width:o,height:l}=bi(e.rect);if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const y=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(y>0||w>0){const _=`calc(${y}px * var(--scale-factor)) / calc(${w}px * var(--scale-factor))`;a.borderRadius=_}else if(this instanceof mf){const _=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case La.SOLID:a.borderStyle="solid";break;case La.DASHED:a.borderStyle="dashed";break;case La.BEVELED:nt("Unimplemented border style: beveled");break;case La.INSET:nt("Unimplemented border style: inset");break;case La.UNDERLINE:a.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(p(this,na,!0),a.borderColor=$.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):a.borderWidth=0}const h=$.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:d,pageHeight:u,pageX:f,pageY:g}=i.rawDims;a.left=`${100*(h[0]-f)/d}%`,a.top=`${100*(h[1]-g)/u}%`;const{rotation:b}=e;return e.hasOwnCanvas||b===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(b,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims,{width:n,height:a}=bi(this.data.rect);let o,l;t%180===0?(o=100*n/s,l=100*a/i):(o=100*a/s,l=100*n/i),e.style.width=`${o}%`,e.style.height=`${l}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,s,i)=>{const n=i.detail[e],a=n[0],o=n.slice(1);i.target.style[s]=Jd[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Jd[`${a}_rgb`](o)})};return ot(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 n=t[i]||s[i];n==null||n(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,n]of Object.entries(e)){const a=s[i];if(a){const o={detail:{[i]:n},target:t};a(o),delete e[i]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,s,i,n]=this.data.rect.map(y=>Math.fround(y));if(t.length===8){const[y,w,v,_]=t.subarray(2,6);if(i===y&&n===w&&e===v&&s===_)return}const{style:a}=this.container;let o;if(r(this,na)){const{borderColor:y,borderWidth:w}=a;a.borderWidth=0,o=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}const l=i-e,h=n-s,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0);const f=d.createElement("defs");u.append(f);const g=d.createElement("clipPath"),b=`clippath_${this.data.id}`;g.setAttribute("id",b),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let y=2,w=t.length;y`)}r(this,na)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${b})`}_createPopup(){const{data:t}=this,e=p(this,ra,new Dh({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){Ct("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:n,id:a,exportValues:o}of i){if(n===-1||a===e)continue;const l=typeof o=="string"?o:null,h=document.querySelector(`[data-element-id="${a}"]`);if(h&&!hr.has(h)){nt(`_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:n}=i,a=i.getAttribute("data-element-id");a!==e&&hr.has(i)&&s.push({id:a,exportValue:n,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})})}};$n=new WeakMap,na=new WeakMap,ra=new WeakMap,Bo=new WeakSet,Fh=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:o,pageY:l}}}}=this;s==null||s.splice(0,4,...t);const{width:h,height:d}=bi(t);e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*h/n}%`,e.height=`${100*d/a}%`):this.setRotation(i)};let Bt=Id;var We,an,pf,gf;class ff extends Bt{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});A(this,We);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:s}=this,i=document.createElement("a");i.setAttribute("data-element-id",e.id);let n=!1;return e.url?(s.addLinkAttributes(i,e.url,e.newWindow),n=!0):e.action?(this._bindNamedAction(i,e.action),n=!0):e.attachment?(m(this,We,pf).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(m(this,We,gf).call(this,i,e.setOCGState),n=!0):e.dest?(this._bindLink(i,e.dest),n=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(i,e),n=!0),e.resetForm?(this._bindResetFormAction(i,e.resetForm),n=!0):this.isTooltipOnly&&!n&&(this._bindLink(i,""),n=!0)),this.container.classList.add("linkAnnotation"),n&&this.container.append(i),this.container}_bindLink(e,s){e.href=this.linkService.getDestinationHash(s),e.onclick=()=>(s&&this.linkService.goToDestination(s),!1),(s||s==="")&&m(this,We,an).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,We,an).call(this)}_bindJSAction(e,s){e.href=this.linkService.getAnchorUrl("");const i=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const n of Object.keys(s.actions)){const a=i.get(n);a&&(e[a]=()=>{var o;return(o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:s.id,name:n}}),!1})}e.onclick||(e.onclick=()=>!1),m(this,We,an).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),m(this,We,an).call(this),!this._fieldObjects){nt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),i||(e.onclick=()=>!1);return}e.onclick=()=>{var u;i==null||i();const{fields:n,refs:a,include:o}=s,l=[];if(n.length!==0||a.length!==0){const f=new Set(a);for(const g of n){const b=this._fieldObjects[g]||[];for(const{id:y}of b)f.add(y)}for(const g of Object.values(this._fieldObjects))for(const b of g)f.has(b.id)===o&&l.push(b)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const h=this.annotationStorage,d=[];for(const f of l){const{id:g}=f;switch(d.push(g),f.type){case"text":{const y=f.defaultValue||"";h.setValue(g,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;h.setValue(g,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";h.setValue(g,{value:y});break}default:continue}const b=document.querySelector(`[data-element-id="${g}"]`);if(b){if(!hr.has(b)){nt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}We=new WeakSet,an=function(){this.container.setAttribute("data-internal-link","")},pf=function(e,s,i=null){e.href=this.linkService.getAnchorUrl(""),s.description&&(e.title=s.description),e.onclick=()=>{var n;return(n=this.downloadManager)==null||n.openOrDownloadData(s.content,s.filename,i),!1},m(this,We,an).call(this)},gf=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,We,an).call(this)};class Mm 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 mr 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 xe.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){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:n(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}n&&((o=this.linkService.eventBus)==null||o.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(a)}}))})}_setEventListeners(t,e,s,i){var n,a,o;for(const[l,h]of s)(h==="Action"||(n=this.data.actions)!=null&&n[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":$.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||km,n=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),d=Math.round(h/($c*i))||1,u=h/d;a=Math.min(i,l(u/$c))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(h/$c))}n.fontSize=`calc(${a}px * var(--scale-factor))`,n.color=$.makeHexColor(s[0],s[1],s[2]),this.data.textAlignment!==null&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class Im extends mr{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 n=this.annotationStorage;for(const a of this._getElementsByName(t.name,t.id))a.domElement&&(a.domElement[e]=s),n.setValue(a.id,{[i]:s})}render(){var i,n;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 d={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="text",s.setAttribute("value",h??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),hr.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=vl,this._setRequired(s,this.data.required),l&&(s.maxLength=l),s.addEventListener("input",f=>{t.setValue(e,{value:f.target.value}),this.setPropertyOnSiblings(s,"value",f.target.value,"value"),d.formattedValue=null}),s.addEventListener("resetform",f=>{const g=this.data.defaultFieldValue??"";s.value=d.userValue=g,d.formattedValue=null});let u=f=>{const{formattedValue:g}=d;g!=null&&(f.target.value=g),f.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){s.addEventListener("focus",g=>{var y;if(d.focused)return;const{target:b}=g;d.userValue&&(b.value=d.userValue),d.lastCommittedValue=b.value,d.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const b={value(y){d.userValue=y.detail.value??"",t.setValue(e,{value:d.userValue.toString()}),y.target.value=d.userValue},formattedValue(y){const{formattedValue:w}=y.detail;d.formattedValue=w,w!=null&&y.target!==document.activeElement&&(y.target.value=w),t.setValue(e,{formattedValue:w})},selRange(y){y.target.setSelectionRange(...y.detail.selRange)},charLimit:y=>{var S;const{charLimit:w}=y.detail,{target:v}=y;if(w===0){v.removeAttribute("maxLength");return}v.setAttribute("maxLength",w);let _=d.userValue;!_||_.length<=w||(_=_.slice(0,w),v.value=d.userValue=_,t.setValue(e,{value:_}),(S=this.linkService.eventBus)==null||S.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,willCommit:!0,commitKey:1,selStart:v.selectionStart,selEnd:v.selectionEnd}}))}};this._dispatchEventFromSandbox(b,g)}),s.addEventListener("keydown",g=>{var w;d.commitKey=1;let b=-1;if(g.key==="Escape"?b=0:g.key==="Enter"&&!this.data.multiLine?b=2:g.key==="Tab"&&(d.commitKey=3),b===-1)return;const{value:y}=g.target;d.lastCommittedValue!==y&&(d.lastCommittedValue=y,d.userValue=y,(w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:y,willCommit:!0,commitKey:b,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}}))});const f=u;u=null,s.addEventListener("blur",g=>{var y,w;if(!d.focused||!g.relatedTarget)return;(y=this.data.actions)!=null&&y.Blur||(d.focused=!1);const{value:b}=g.target;d.userValue=b,d.lastCommittedValue!==b&&((w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:b,willCommit:!0,commitKey:d.commitKey,selStart:g.target.selectionStart,selEnd:g.target.selectionEnd}})),f(g)}),(n=this.data.actions)!=null&&n.Keystroke&&s.addEventListener("beforeinput",g=>{var T;d.lastCommittedValue=null;const{data:b,target:y}=g,{value:w,selectionStart:v,selectionEnd:_}=y;let S=v,E=_;switch(g.inputType){case"deleteWordBackward":{const C=w.substring(0,v).match(/\w*[^\w]*$/);C&&(S-=C[0].length);break}case"deleteWordForward":{const C=w.substring(v).match(/^[^\w]*\w*/);C&&(E+=C[0].length);break}case"deleteContentBackward":v===_&&(S-=1);break;case"deleteContentForward":v===_&&(E+=1);break}g.preventDefault(),(T=this.linkService.eventBus)==null||T.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,change:b||"",willCommit:!1,selStart:S,selEnd:E}})}),this._setEventListeners(s,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],g=>g.target.value)}if(u&&s.addEventListener("blur",u),this.data.comb){const g=(this.data.rect[2]-this.data.rect[0])/l;s.classList.add("comb"),s.style.letterSpacing=`calc(${g}px * var(--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 Fm extends mr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Dm extends mr{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 n=document.createElement("input");return hr.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="checkbox",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.setAttribute("exportValue",e.exportValue),n.tabIndex=vl,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const h of this._getElementsByName(o,s)){const d=l&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=d),t.setValue(h.id,{value:d})}t.setValue(s,{value:l})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue||"Off";a.target.checked=o===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.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(n,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(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class mf extends mr{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 n=document.createElement("input");if(hr.add(n),n.setAttribute("data-element-id",s),n.disabled=e.readOnly,this._setRequired(n,this.data.required),n.type="radio",n.name=e.fieldName,i&&n.setAttribute("checked",!0),n.tabIndex=vl,n.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})}),n.addEventListener("resetform",a=>{const o=e.defaultFieldValue;a.target.checked=o!=null&&o===e.buttonValue}),this.enableScripting&&this.hasJSActions){const a=e.buttonValue;n.addEventListener("updatefromsandbox",o=>{const l={value:h=>{const d=a===h.detail.value;for(const u of this._getElementsByName(h.target.name)){const f=d&&u.id===s;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(n,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(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Nm extends ff{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 Om extends mr{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");hr.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=vl;let n=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",d=>{const u=this.data.defaultFieldValue;for(const f of i.options)f.selected=f.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,s.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),n=!1),i.append(u)}let a=null;if(n){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),i.prepend(d),a=()=>{d.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const o=d=>{const u=d?"value":"textContent",{options:f,multiple:g}=i;return g?Array.prototype.filter.call(f,b=>b.selected).map(b=>b[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const h=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",d=>{const u={value(f){a==null||a();const g=f.detail.value,b=new Set(Array.isArray(g)?g:[g]);for(const y of i.options)y.selected=b.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,b=f.detail.remove;g[b].selected=!1,i.remove(b),g.length>0&&Array.prototype.findIndex.call(g,w=>w.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},clear(f){for(;i.length!==0;)i.remove(0);t.setValue(e,{value:null,items:[]}),l=o(!1)},insert(f){const{index:g,displayValue:b,exportValue:y}=f.detail.insert,w=i.children[g],v=document.createElement("option");v.textContent=b,v.value=y,w?w.before(v):i.append(v),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const b of g){const{displayValue:y,exportValue:w}=b,v=document.createElement("option");v.textContent=y,v.value=w,i.append(v)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:o(!0),items:h(f)}),l=o(!1)},indices(f){const g=new Set(f.detail.indices);for(const b of f.target.options)b.selected=g.has(b.index);t.setValue(e,{value:o(!0)}),l=o(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),i.addEventListener("input",d=>{var g;const u=o(!0),f=o(!1);t.setValue(e,{value:u}),d.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:l,change:f,changeEx:u,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"]],d=>d.target.value)):i.addEventListener("input",function(d){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 Dh extends Bt{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Bt._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Hm({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),e=[];for(const s of this.elements)s.popup=t,s.container.ariaHasPopup="dialog",e.push(s.data.id),s.addHighlightArea();return this.container.setAttribute("aria-controls",e.map(s=>`${yd}${s}`).join(",")),this.container}}var aa,Ec,Sc,oa,zn,Nt,si,la,$o,zo,ca,ii,fs,ni,Go,ri,Uo,Gn,Un,yt,zl,Nh,bf,Af,yf,vf,Gl,Ul,Oh;class Hm{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:h,parentRect:d,open:u}){A(this,yt);A(this,aa,m(this,yt,yf).bind(this));A(this,Ec,m(this,yt,Oh).bind(this));A(this,Sc,m(this,yt,Ul).bind(this));A(this,oa,m(this,yt,Gl).bind(this));A(this,zn,null);A(this,Nt,null);A(this,si,null);A(this,la,null);A(this,$o,null);A(this,zo,null);A(this,ca,null);A(this,ii,!1);A(this,fs,null);A(this,ni,null);A(this,Go,null);A(this,ri,null);A(this,Uo,null);A(this,Gn,null);A(this,Un,!1);var f;p(this,Nt,t),p(this,Uo,i),p(this,si,a),p(this,ri,o),p(this,zo,l),p(this,zn,e),p(this,Go,h),p(this,ca,d),p(this,$o,s),p(this,la,_d.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,oa)),g.addEventListener("mouseenter",r(this,Sc)),g.addEventListener("mouseleave",r(this,Ec)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",r(this,aa));r(this,Nt).hidden=!0,u&&m(this,yt,Gl).call(this)}render(){if(r(this,fs))return;const t=p(this,fs,document.createElement("div"));if(t.className="popup",r(this,zn)){const n=t.style.outlineColor=$.makeHexColor(...r(this,zn));CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?t.style.backgroundColor=`color-mix(in srgb, ${n} 30%, white)`:t.style.backgroundColor=$.makeHexColor(...r(this,zn).map(o=>Math.floor(.7*(255-o)+o)))}const e=document.createElement("span");e.className="header";const s=document.createElement("h1");if(e.append(s),{dir:s.dir,str:s.textContent}=r(this,Uo),t.append(e),r(this,la)){const n=document.createElement("span");n.classList.add("popupDate"),n.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),n.setAttribute("data-l10n-args",JSON.stringify({dateObj:r(this,la).valueOf()})),e.append(n)}const i=r(this,yt,zl);if(i)uf.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,si));t.append(n)}r(this,Nt).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 n=0,a=i.length;n{a.key==="Enter"&&(n?a.metaKey:a.ctrlKey)&&m(this,Qo,Hh).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,Ko)}addHighlightArea(){this.container.classList.add("highlightArea")}}Ko=new WeakMap,Qo=new WeakSet,Hh=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var Jo,Wn,Vn,Zo,ur,xf,jh,hu;let Xm=(hu=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o}){A(this,ur);A(this,Jo,null);A(this,Wn,null);A(this,Vn,new Map);A(this,Zo,null);this.div=t,p(this,Jo,e),p(this,Wn,s),p(this,Zo,o||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return r(this,Vn).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;lr(s,this.viewport);const i=new Map,n={data:null,layer:s,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Pd,annotationStorage:t.annotationStorage||new Sd,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===qt.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=bi(o.rect);if(u<=0||f<=0)continue}n.data=o;const h=Lm.create(n);if(!h.isRenderable)continue;if(!l&&o.popupRef){const u=i.get(o.popupRef);u?u.push(h):i.set(o.popupRef,[h])}const d=h.render();o.hidden&&(d.style.visibility="hidden"),await m(this,ur,xf).call(this,d,o.id),h._isEditable&&(r(this,Vn).set(h.data.id,h),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(h))}m(this,ur,jh).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,lr(e,{rotation:t.rotation}),m(this,ur,jh).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Vn).values())}getEditableAnnotation(t){return r(this,Vn).get(t)}},Jo=new WeakMap,Wn=new WeakMap,Vn=new WeakMap,Zo=new WeakMap,ur=new WeakSet,xf=async function(t,e){var a,o;const s=t.firstChild||t,i=s.id=`${yd}${e}`,n=await((a=r(this,Zo))==null?void 0:a.getAriaAttributes(i));if(n)for(const[l,h]of n)s.setAttribute(l,h);this.div.append(t),(o=r(this,Jo))==null||o.moveElementInDOM(this.div,t,s,!1)},jh=function(){if(!r(this,Wn))return;const t=this.div;for(const[e,s]of r(this,Wn)){const i=t.querySelector(`[data-annotation-id="${e}"]`);if(!i)continue;s.className="annotationContent";const{firstChild:n}=i;n?n.nodeName==="CANVAS"?n.replaceWith(s):n.classList.contains("annotationContent")?n.after(s):n.before(s):i.append(s)}r(this,Wn).clear()},hu);const Tl=/\r\n?|\n/g;var ps,He,tl,qn,je,Vt,Cf,Tf,Rf,Wl,yi,Vl,ql,Pf,$h,kf;const _t=class _t extends mt{constructor(e){super({...e,name:"freeTextEditor"});A(this,Vt);A(this,ps);A(this,He,"");A(this,tl,`${this.id}-editor`);A(this,qn,null);A(this,je);p(this,ps,e.color||_t._defaultColor||mt._defaultLineColor),p(this,je,e.fontSize||_t._defaultFontSize)}static get _keyboardManager(){const e=_t.prototype,s=a=>a.isEmpty(),i=cr.TRANSLATE_SMALL,n=cr.TRANSLATE_BIG;return ot(this,"_keyboardManager",new yl([[["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:[-n,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[i,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[n,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:s}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,i],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,n],checker:s}]]))}static initialize(e,s){mt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case K.FREETEXT_SIZE:_t._defaultFontSize=s;break;case K.FREETEXT_COLOR:_t._defaultColor=s;break}}updateParams(e,s){switch(e){case K.FREETEXT_SIZE:m(this,Vt,Cf).call(this,s);break;case K.FREETEXT_COLOR:m(this,Vt,Tf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.FREETEXT_SIZE,_t._defaultFontSize],[K.FREETEXT_COLOR,_t._defaultColor||mt._defaultLineColor]]}get propertiesToUpdate(){return[[K.FREETEXT_SIZE,r(this,je)],[K.FREETEXT_COLOR,r(this,ps)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-_t._internalPadding*e,-(_t._internalPadding+r(this,je))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(tt.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,qn,new AbortController);const e=this._uiManager.combinedSignal(r(this,qn));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})}disableEditMode(){var e;this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",r(this,tl)),this._isDraggable=!0,(e=r(this,qn))==null||e.abort(),p(this,qn,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(){var e;this.width||(this.enableEditMode(),this.editorDiv.focus(),(e=this._initialOptions)!=null&&e.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=r(this,He),s=p(this,He,m(this,Vt,Rf).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,He,n),!n){this.remove();return}m(this,Vt,ql).call(this),this._uiManager.rebuild(this),m(this,Vt,Wl).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,Vt,Wl).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){_t._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",r(this,tl)),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(${r(this,je)}px * var(--scale-factor))`,i.color=r(this,ps),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),rc(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,h]=this.getInitialTranslation();[l,h]=this.pageTranslationToScreen(l,h);const[d,u]=this.pageDimensions,[f,g]=this.pageTranslation;let b,y;switch(this.rotation){case 0:b=e+(o[0]-f)/d,y=s+this.height-(o[1]-g)/u;break;case 90:b=e+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[h,-l];break;case 180:b=e-this.width+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,h]=[-l,-h];break;case 270:b=e+(o[0]-f-this.height*u)/d,y=s+(o[1]-g-this.width*d)/u,[l,h]=[-h,l];break}this.setAt(b*n,y*a,l,h)}else this.setAt(e*n,s*a,this.width*n,this.height*a);m(this,Vt,ql).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var b,y,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=m(b=_t,yi,$h).call(b,s.getData("text")||"").replaceAll(Tl,` +`);if(!n)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!n.includes(` +`)){o.insertNode(document.createTextNode(n)),this.editorDiv.normalize(),a.collapseToStart();return}const{startContainer:l,startOffset:h}=o,d=[],u=[];if(l.nodeType===Node.TEXT_NODE){const v=l.parentElement;if(u.push(l.nodeValue.slice(h).replaceAll(Tl,"")),v!==this.editorDiv){let _=d;for(const S of this.editorDiv.childNodes){if(S===v){_=u;continue}_.push(m(y=_t,yi,Vl).call(y,S))}}d.push(l.nodeValue.slice(0,h).replaceAll(Tl,""))}else if(l===this.editorDiv){let v=d,_=0;for(const S of this.editorDiv.childNodes)_++===h&&(v=u),v.push(m(w=_t,yi,Vl).call(w,S))}p(this,He,`${d.join(` +`)}${n}${u.join(` +`)}`),m(this,Vt,ql).call(this);const f=new Range;let g=d.reduce((v,_)=>v+_.length,0);for(const{firstChild:v}of this.editorDiv.childNodes)if(v.nodeType===Node.TEXT_NODE){const _=v.nodeValue.length;if(g<=_){f.setStart(v,g),f.setEnd(v,g);break}g-=_}a.removeAllRanges(),a.addRange(f)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var o;let n=null;if(e instanceof wf){const{data:{defaultAppearanceData:{fontSize:l,fontColor:h},rect:d,rotation:u,id:f,popupRef:g},textContent:b,textPosition:y,parent:{page:{pageNumber:w}}}=e;if(!b||b.length===0)return null;n=e={annotationType:tt.FREETEXT,color:Array.from(h),fontSize:l,value:b.join(` +`),position:y,pageIndex:w-1,rect:d.slice(0),rotation:u,id:f,deleted:!1,popupRef:g}}const a=await super.deserialize(e,s,i);return p(a,je,e.fontSize),p(a,ps,$.makeHexColor(...e.color)),p(a,He,m(o=_t,yi,$h).call(o,e.value)),a.annotationElementId=e.id||null,a._initialData=n,a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=_t._internalPadding*this.parentScale,i=this.getRect(s,s),n=mt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,ps)),a={annotationType:tt.FREETEXT,color:n,fontSize:r(this,je),value:m(this,Vt,Pf).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!m(this,Vt,kf).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e);if(this.deleted)return s;const{style:i}=s;i.fontSize=`calc(${r(this,je)}px * var(--scale-factor))`,i.color=r(this,ps),s.replaceChildren();for(const a of r(this,He).split(` +`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=_t._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,He)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};ps=new WeakMap,He=new WeakMap,tl=new WeakMap,qn=new WeakMap,je=new WeakMap,Vt=new WeakSet,Cf=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,je))*this.parentScale),p(this,je,n),m(this,Vt,Wl).call(this)},i=r(this,je);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Tf=function(e){const s=n=>{p(this,ps,this.editorDiv.style.color=n)},i=r(this,ps);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Rf=function(){var i;const e=[];this.editorDiv.normalize();let s=null;for(const n of this.editorDiv.childNodes)(s==null?void 0:s.nodeType)===Node.TEXT_NODE&&n.nodeName==="BR"||(e.push(m(i=_t,yi,Vl).call(i,n)),s=n);return e.join(` +`)},Wl=function(){const[e,s]=this.parentDimensions;let i;if(this.isAttachedToDOM)i=this.div.getBoundingClientRect();else{const{currentLayer:n,div:a}=this,o=a.style.display,l=a.classList.contains("hidden");a.classList.remove("hidden"),a.style.display="hidden",n.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()},yi=new WeakSet,Vl=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Tl,"")},ql=function(){if(this.editorDiv.replaceChildren(),!!r(this,He))for(const e of r(this,He).split(` +`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Pf=function(){return r(this,He).replaceAll(" "," ")},$h=function(e){return e.replaceAll(" "," ")},kf=function(e){const{value:s,fontSize:i,color:n,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==s||e.fontSize!==i||e.color.some((o,l)=>o!==n[l])||e.pageIndex!==a},A(_t,yi),Y(_t,"_freeTextDefaultContent",""),Y(_t,"_internalPadding",0),Y(_t,"_defaultColor",null),Y(_t,"_defaultFontSize",10),Y(_t,"_type","freetext"),Y(_t,"_editorType",tt.FREETEXT);let Bh=_t;class Lf{toSVGPath(){Ct("Abstract method `toSVGPath` must be implemented.")}get box(){Ct("Abstract getter `box` must be implemented.")}serialize(t,e){Ct("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){Ct("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){Ct("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var Be,gs,ha,da,Ds,rt,Xn,Yn,el,sl,ua,fa,Ui,il,xc,Cc,Jt,Ua,Mf,If,Ff,Df,Nf,Of;const Ws=class Ws{constructor({x:t,y:e},s,i,n,a,o=0){A(this,Jt);A(this,Be);A(this,gs,[]);A(this,ha);A(this,da);A(this,Ds,[]);A(this,rt,new Float64Array(18));A(this,Xn);A(this,Yn);A(this,el);A(this,sl);A(this,ua);A(this,fa);A(this,Ui,[]);p(this,Be,s),p(this,fa,n*i),p(this,da,a),r(this,rt).set([NaN,NaN,NaN,NaN,t,e],6),p(this,ha,o),p(this,sl,r(Ws,il)*i),p(this,el,r(Ws,Cc)*i),p(this,ua,i),r(this,Ui).push(t,e)}isEmpty(){return isNaN(r(this,rt)[8])}add({x:t,y:e}){var M;p(this,Xn,t),p(this,Yn,e);const[s,i,n,a]=r(this,Be);let[o,l,h,d]=r(this,rt).subarray(8,12);const u=t-h,f=e-d,g=Math.hypot(u,f);if(g=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 m(this,Jt,If).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Hf(t,e,s,i,n,a)}getOutlines(){var u;const t=r(this,Ds),e=r(this,gs),s=r(this,rt),[i,n,a,o]=r(this,Be),l=new Float64Array((((u=r(this,Ui))==null?void 0:u.length)??0)+2);for(let f=0,g=l.length-2;f=6;f-=6)for(let g=0;g<6;g+=2){if(isNaN(e[f+g])){h[d]=h[d+1]=NaN,d+=2;continue}h[d]=e[f+g],h[d+1]=e[f+g+1],d+=2}return m(this,Jt,Nf).call(this,h,d),this.newFreeDrawOutline(h,l,r(this,Be),r(this,ua),r(this,ha),r(this,da))}};Be=new WeakMap,gs=new WeakMap,ha=new WeakMap,da=new WeakMap,Ds=new WeakMap,rt=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,el=new WeakMap,sl=new WeakMap,ua=new WeakMap,fa=new WeakMap,Ui=new WeakMap,il=new WeakMap,xc=new WeakMap,Cc=new WeakMap,Jt=new WeakSet,Ua=function(){const t=r(this,rt).subarray(4,6),e=r(this,rt).subarray(16,18),[s,i,n,a]=r(this,Be);return[(r(this,Xn)+(t[0]-e[0])/2-s)/n,(r(this,Yn)+(t[1]-e[1])/2-i)/a,(r(this,Xn)+(e[0]-t[0])/2-s)/n,(r(this,Yn)+(e[1]-t[1])/2-i)/a]},Mf=function(){const[t,e,s,i]=r(this,Be),[n,a,o,l]=m(this,Jt,Ua).call(this);return`M${(r(this,rt)[2]-t)/s} ${(r(this,rt)[3]-e)/i} L${(r(this,rt)[4]-t)/s} ${(r(this,rt)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,rt)[16]-t)/s} ${(r(this,rt)[17]-e)/i} L${(r(this,rt)[14]-t)/s} ${(r(this,rt)[15]-e)/i} Z`},If=function(t){const e=r(this,gs);t.push(`L${e[4]} ${e[5]} Z`)},Ff=function(t){const[e,s,i,n]=r(this,Be),a=r(this,rt).subarray(4,6),o=r(this,rt).subarray(16,18),[l,h,d,u]=m(this,Jt,Ua).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${l} ${h} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},Df=function(t){const e=r(this,rt),[s,i,n,a]=r(this,Be),[o,l,h,d]=m(this,Jt,Ua).call(this),u=new Float64Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-s)/n,(e[3]-i)/a,NaN,NaN,NaN,NaN,(e[4]-s)/n,(e[5]-i)/a,NaN,NaN,NaN,NaN,o,l,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(e[16]-s)/n,(e[17]-i)/a,NaN,NaN,NaN,NaN,(e[14]-s)/n,(e[15]-i)/a],0),this.newFreeDrawOutline(u,t,r(this,Be),r(this,ua),r(this,ha),r(this,da))},Nf=function(t,e){const s=r(this,gs);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Of=function(t,e){const s=r(this,rt).subarray(4,6),i=r(this,rt).subarray(16,18),[n,a,o,l]=r(this,Be),[h,d,u,f]=m(this,Jt,Ua).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-a)/l],e),e+=24},A(Ws,il,8),A(Ws,xc,2),A(Ws,Cc,r(Ws,il)+r(Ws,xc));let oc=Ws;var pa,Kn,ai,nl,$e,rl,jt,Fe,Wa,Va,jf;class Hf extends Lf{constructor(e,s,i,n,a,o){super();A(this,Fe);A(this,pa);A(this,Kn,null);A(this,ai);A(this,nl);A(this,$e);A(this,rl);A(this,jt);p(this,jt,e),p(this,$e,s),p(this,pa,i),p(this,rl,n),p(this,ai,a),p(this,nl,o),m(this,Fe,jf).call(this,o);const{x:l,y:h,width:d,height:u}=r(this,Kn);for(let f=0,g=e.length;fe[0]-s[0]||e[1]-s[1]||e[2]-s[2]);const t=[];for(const e of r(this,Wi))e[3]?(t.push(...m(this,Te,zh).call(this,e)),m(this,Te,$f).call(this,e)):(m(this,Te,zf).call(this,e),t.push(...m(this,Te,zh).call(this,e)));return m(this,Te,Bf).call(this,t)}}al=new WeakMap,Wi=new WeakMap,ms=new WeakMap,Te=new WeakSet,Bf=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;a0;){const a=s.values().next().value;let[o,l,h,d,u]=a;s.delete(a);let f=o,g=l;for(n=[o,h],i.push(n);;){let b;if(s.has(d))b=d;else if(s.has(u))b=u;else break;s.delete(b),[o,l,h,d,u]=b,f!==o&&(n.push(f,g,o,g===l?l:h),f=o),g=g===l?h:l}n.push(f,g)}return new Ym(i,r(this,al))},Xl=function(t){const e=r(this,ms);let s=0,i=e.length-1;for(;s<=i;){const n=s+i>>1,a=e[n][0];if(a===t)return n;a=0;i--){const[n,a]=r(this,ms)[i];if(n!==t)break;if(n===t&&a===e){r(this,ms).splice(i,1);return}}},zh=function(t){const[e,s,i]=t,n=[[e,s,i]],a=m(this,Te,Xl).call(this,i);for(let o=0;o=l){if(g>h)n[d][1]=h;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,g>h&&n.push([e,h,g])}}}return n};var ol,ga;class Ym extends Lf{constructor(e,s){super();A(this,ol);A(this,ga);p(this,ga,e),p(this,ol,s)}toSVGPath(){const e=[];for(const s of r(this,ga)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a-1?(p(this,Me,!0),m(this,Z,Yl).call(this,e),m(this,Z,ln).call(this)):r(this,oi)&&(p(this,ya,e.anchorNode),p(this,ul,e.anchorOffset),p(this,fl,e.focusNode),p(this,pl,e.focusOffset),m(this,Z,qh).call(this),m(this,Z,ln).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=dt.prototype;return ot(this,"_keyboardManager",new yl([[["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:r(this,Me)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,Je),methodOfCreation:r(this,gl)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,s){var i;mt.initialize(e,s),dt._defaultColor||(dt._defaultColor=((i=s.highlightColors)==null?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case K.HIGHLIGHT_DEFAULT_COLOR:dt._defaultColor=s;break;case K.HIGHLIGHT_THICKNESS:dt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,wa)}updateParams(e,s){switch(e){case K.HIGHLIGHT_COLOR:m(this,Z,Uf).call(this,s);break;case K.HIGHLIGHT_THICKNESS:m(this,Z,Wf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.HIGHLIGHT_DEFAULT_COLOR,dt._defaultColor],[K.HIGHLIGHT_THICKNESS,dt._defaultThickness]]}get propertiesToUpdate(){return[[K.HIGHLIGHT_COLOR,this.color||dt._defaultColor],[K.HIGHLIGHT_THICKNESS,r(this,Je)||dt._defaultThickness],[K.HIGHLIGHT_FREE,r(this,Me)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,va,new lc({editor:this})),e.addColorPicker(r(this,va))),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(m(this,Z,qa).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,Z,qa).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,Z,Xh).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,Z,ln).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,Z,Xh).call(this):e&&(m(this,Z,ln).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 n,a,o;const{drawLayer:s}=this.parent;let i;r(this,Me)?(e=(e-this.rotation+360)%360,i=m(n=dt,es,Sr).call(n,r(this,ys).box,e)):i=m(a=dt,es,Sr).call(a,this,e),s.rotate(r(this,be),e),s.rotate(r(this,Kt),e),s.updateBox(r(this,be),i),s.updateBox(r(this,Kt),m(o=dt,es,Sr).call(o,r(this,Qe).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,_a)&&(e.setAttribute("aria-label",r(this,_a)),e.setAttribute("role","mark")),r(this,Me)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,Z,qf).bind(this),{signal:this._uiManager._signal});const s=p(this,Zn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,Jn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),rc(this,r(this,Zn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(r(this,Kt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(r(this,Kt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,Z,Kl).call(this,!0);break;case 1:case 3:m(this,Z,Kl).call(this,!1);break}}select(){var e,s;super.select(),r(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Kt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,Kt),"selected"))}unselect(){var e;super.unselect(),r(this,Kt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Kt),"selected"),r(this,Me)||m(this,Z,Kl).call(this,!1))}get _mustFixPosition(){return!r(this,Me)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,be),e),this.parent.drawLayer.show(r(this,Kt),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:h,height:d}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),g=y=>{y.preventDefault(),y.stopPropagation()},b=y=>{u.abort(),m(this,es,Qf).call(this,e,y)};window.addEventListener("blur",b,{signal:f}),window.addEventListener("pointerup",b,{signal:f}),window.addEventListener("pointerdown",g,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",is,{signal:f}),i.addEventListener("pointermove",m(this,es,Kf).bind(this,e),{signal:f}),this._freeHighlight=new Gh({x:n,y:a},[o,l,h,d],e.scale,this._defaultThickness/2,s,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static async deserialize(e,s,i){var y,w,v,_;let n=null;if(e instanceof Ef){const{data:{quadPoints:S,rect:E,rotation:T,id:C,color:x,opacity:P,popupRef:M},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(x),opacity:P,quadPoints:S,boxes:null,pageIndex:O-1,rect:E.slice(0),rotation:T,id:C,deleted:!1,popupRef:M}}else if(e instanceof kd){const{data:{inkLists:S,rect:E,rotation:T,id:C,color:x,borderStyle:{rawWidth:P},popupRef:M},parent:{page:{pageNumber:O}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(x),thickness:P,inkLists:S,boxes:null,pageIndex:O-1,rect:E.slice(0),rotation:T,id:C,deleted:!1,popupRef:M}}const{color:a,quadPoints:o,inkLists:l,opacity:h}=e,d=await super.deserialize(e,s,i);d.color=$.makeHexColor(...a),p(d,li,h||1),l&&p(d,Je,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,f]=d.pageDimensions,[g,b]=d.pageTranslation;if(o){const S=p(d,oi,[]);for(let E=0;E=0)p(this,be,s),p(this,Jn,i),this.parent.drawLayer.finalizeLine(s,e),p(this,Kt,this.parent.drawLayer.drawOutline(r(this,Qe)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,be),e),this.parent.drawLayer.updateBox(r(this,be),m(u=dt,es,Sr).call(u,r(this,ys).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,Kt),r(this,Qe)),this.parent.drawLayer.updateBox(r(this,Kt),m(f=dt,es,Sr).call(f,r(this,Qe).box,g))}const{x:a,y:o,width:l,height:h}=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=h;break;case 90:{const[g,b]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*b/g,this.height=h*g/b;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=h;break;case 270:{const[g,b]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*b/g,this.height=h*g/b;break}}const{lastPoint:d}=r(this,Qe).box;p(this,wa,[(d[0]-a)/l,(d[1]-o)/h])},Uf=function(e){const s=(a,o)=>{var l,h,d;this.color=a,(l=this.parent)==null||l.drawLayer.changeColor(r(this,be),a),(h=r(this,va))==null||h.updateColor(a),p(this,li,o),(d=this.parent)==null||d.drawLayer.changeOpacity(r(this,be),o)},i=this.color,n=r(this,li);this.addCommands({cmd:s.bind(this,e,dt._defaultOpacity),undo:s.bind(this,i,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},Wf=function(e){const s=r(this,Je),i=n=>{p(this,Je,n),m(this,Z,Vf).call(this,n)};this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Vf=function(e){if(!r(this,Me))return;m(this,Z,Yl).call(this,{highlightOutlines:r(this,ys).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},Xh=function(){r(this,be)===null||!this.parent||(this.parent.drawLayer.remove(r(this,be)),p(this,be,null),this.parent.drawLayer.remove(r(this,Kt)),p(this,Kt,null))},ln=function(e=this.parent){r(this,be)===null&&({id:we(this,be)._,clipPathId:we(this,Jn)._}=e.drawLayer.draw(r(this,ys),this.color,r(this,li)),p(this,Kt,e.drawLayer.drawOutline(r(this,Qe))),r(this,Zn)&&(r(this,Zn).style.clipPath=r(this,Jn)))},es=new WeakSet,Sr=function({x:e,y:s,width:i,height:n},a){switch(a){case 90:return{x:1-s-n,y:e,width:n,height:i};case 180:return{x:1-e-i,y:1-s-n,width:i,height:n};case 270:return{x:s,y:1-e-i,width:n,height:i}}return{x:e,y:s,width:i,height:n}},qf=function(e){dt._keyboardManager.exec(this,e)},Kl=function(e){if(!r(this,ya))return;const s=window.getSelection();e?s.setPosition(r(this,ya),r(this,ul)):s.setPosition(r(this,fl),r(this,pl))},qa=function(){return r(this,Me)?this.rotation:0},Xf=function(){if(r(this,Me))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,a=r(this,oi),o=new Float32Array(a.length*8);let l=0;for(const{x:h,y:d,width:u,height:f}of a){const g=h*e+i,b=(1-d-f)*s+n;o[l]=o[l+4]=g,o[l+1]=o[l+3]=b,o[l+2]=o[l+6]=g+u*e,o[l+5]=o[l+7]=b+f*s,l+=8}return o},Yf=function(e){return r(this,ys).serialize(e,m(this,Z,qa).call(this))},Kf=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Qf=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=""},Jf=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},A(dt,es),Y(dt,"_defaultColor",null),Y(dt,"_defaultOpacity",1),Y(dt,"_defaultThickness",12),Y(dt,"_type","highlight"),Y(dt,"_editorType",tt.HIGHLIGHT),Y(dt,"_freeHighlightId",-1),Y(dt,"_freeHighlight",null),Y(dt,"_freeHighlightClipId","");let cc=dt;var tr,er,Ns,ci,Ze,sr,ir,nr,hi,Ea,rr,ar,qi,I,Zf,tp,ep,sp,Kh,ip,Qh,np,rp,ap,op,lp,cn,Jh,Zh,td,Ql,Jl,xr,ed,Zl,wi,cp,sd,hp,dp,id,tc,Xa;const kt=class kt extends mt{constructor(e){super({...e,name:"inkEditor"});A(this,I);A(this,tr,0);A(this,er,0);A(this,Ns,null);A(this,ci,new Path2D);A(this,Ze,!1);A(this,sr,null);A(this,ir,!1);A(this,nr,!1);A(this,hi,null);A(this,Ea,null);A(this,rr,0);A(this,ar,0);A(this,qi,null);this.color=e.color||null,this.thickness=e.thickness||null,this.opacity=e.opacity||null,this.paths=[],this.bezierPath2D=[],this.allRawPaths=[],this.currentPath=[],this.scaleFactor=1,this.translationX=this.translationY=0,this.x=0,this.y=0,this._willKeepAspectRatio=!0}static initialize(e,s){mt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case K.INK_THICKNESS:kt._defaultThickness=s;break;case K.INK_COLOR:kt._defaultColor=s;break;case K.INK_OPACITY:kt._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case K.INK_THICKNESS:m(this,I,Zf).call(this,s);break;case K.INK_COLOR:m(this,I,tp).call(this,s);break;case K.INK_OPACITY:m(this,I,ep).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[K.INK_THICKNESS,kt._defaultThickness],[K.INK_COLOR,kt._defaultColor||mt._defaultLineColor],[K.INK_OPACITY,Math.round(kt._defaultOpacity*100)]]}get propertiesToUpdate(){return[[K.INK_THICKNESS,this.thickness||kt._defaultThickness],[K.INK_COLOR,this.color||kt._defaultColor||mt._defaultLineColor],[K.INK_OPACITY,Math.round(100*(this.opacity??kt._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,I,Ql).call(this),m(this,I,Jl).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,I,xr).call(this)),m(this,I,Xa).call(this)))}remove(){var e;this.canvas!==null&&(this.isEmpty()||this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,r(this,Ns)&&(clearTimeout(r(this,Ns)),p(this,Ns,null)),(e=r(this,hi))==null||e.disconnect(),p(this,hi,null),super.remove())}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&e===null&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){const[e,s]=this.parentDimensions,i=this.width*e,n=this.height*s;this.setDimensions(i,n)}enableEditMode(){r(this,Ze)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,m(this,I,Jh).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,I,Zh).call(this))}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return this.paths.length===0||this.paths.length===1&&this.paths[0].length===0}commit(){r(this,Ze)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,Ze,!0),this.div.classList.add("disabled"),m(this,I,Xa).call(this,!0),this.select(),this.parent.addInkEditorIfNeeded(!0),this.moveInDOM(),this.div.focus({preventScroll:!0}))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),this.enableEditMode())}canvasPointerdown(e){e.button!==0||!this.isInEditMode()||r(this,Ze)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,I,ip).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,I,Qh).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,I,td).call(this,e)}canvasPointerleave(e){m(this,I,td).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,Ze)}render(){if(this.div)return this.div;let e,s;this.width&&(e=this.x,s=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");const[i,n,a,o]=m(this,I,sp).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),m(this,I,Ql).call(this),this.width){const[l,h]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*h),this.setAt(e*l,s*h,this.width*l,this.height*h),p(this,nr,!0),m(this,I,xr).call(this),this.setDims(this.width*l,this.height*h),m(this,I,cn).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,I,Jl).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,rr)===i&&r(this,ar)===n)return;p(this,rr,i),p(this,ar,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,Ze)&&m(this,I,ed).call(this,e,s),m(this,I,xr).call(this),m(this,I,cn).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var w,v,_;if(e instanceof kd)return null;const n=await super.deserialize(e,s,i);n.thickness=e.thickness,n.color=$.makeHexColor(...e.color),n.opacity=e.opacity;const[a,o]=n.pageDimensions,l=n.width*a,h=n.height*o,d=n.parentScale,u=e.thickness/2;p(n,Ze,!0),p(n,rr,Math.round(l)),p(n,ar,Math.round(h));const{paths:f,rect:g,rotation:b}=e;for(let{bezier:S}of f){S=m(w=kt,wi,hp).call(w,S,g,b);const E=[];n.paths.push(E);let T=d*(S[0]-u),C=d*(S[1]-u);for(let P=2,M=S.length;P{this.thickness=n,m(this,I,Xa).call(this)},i=this.thickness;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},tp=function(e){const s=n=>{this.color=n,m(this,I,cn).call(this)},i=this.color;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},ep=function(e){const s=n=>{this.opacity=n,m(this,I,cn).call(this)};e/=100;const i=this.opacity;this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:K.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},sp=function(){const{parentRotation:e,parentDimensions:[s,i]}=this;switch(e){case 90:return[0,i,i,s];case 180:return[s,i,s,i];case 270:return[s,0,i,s];default:return[0,0,s,i]}},Kh=function(){const{ctx:e,color:s,opacity:i,thickness:n,parentScale:a,scaleFactor:o}=this;e.lineWidth=n*a/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${s}${Ag(i)}`},ip=function(e,s){this.canvas.addEventListener("contextmenu",is,{signal:this._uiManager._signal}),m(this,I,Zh).call(this),p(this,sr,new AbortController);const i=this._uiManager.combinedSignal(r(this,sr));this.canvas.addEventListener("pointerleave",this.canvasPointerleave.bind(this),{signal:i}),this.canvas.addEventListener("pointermove",this.canvasPointermove.bind(this),{signal:i}),this.canvas.addEventListener("pointerup",this.canvasPointerup.bind(this),{signal:i}),this.isEditing=!0,r(this,nr)||(p(this,nr,!0),m(this,I,xr).call(this),this.thickness||(this.thickness=kt._defaultThickness),this.color||(this.color=kt._defaultColor||mt._defaultLineColor),this.opacity??(this.opacity=kt._defaultOpacity)),this.currentPath.push([e,s]),p(this,ir,!1),m(this,I,Kh).call(this),p(this,qi,()=>{m(this,I,ap).call(this),r(this,qi)&&window.requestAnimationFrame(r(this,qi))}),window.requestAnimationFrame(r(this,qi))},Qh=function(e,s){const[i,n]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===i&&s===n)return;const a=this.currentPath;let o=r(this,ci);if(a.push([e,s]),p(this,ir,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(p(this,ci,o=new Path2D),o.moveTo(...a[0])),m(this,I,op).call(this,o,...a.at(-3),...a.at(-2),e,s)},np=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,ci).lineTo(...e)},rp=function(e,s){p(this,qi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,I,Qh).call(this,e,s),m(this,I,np).call(this);let i;if(this.currentPath.length!==1)i=m(this,I,lp).call(this);else{const h=[e,s];i=[[h,h.slice(),h.slice(),h]]}const n=r(this,ci),a=this.currentPath;this.currentPath=[],p(this,ci,new Path2D);const o=()=>{this.allRawPaths.push(a),this.paths.push(i),this.bezierPath2D.push(n),this._uiManager.rebuild(this)},l=()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),this.paths.length===0?this.remove():(this.canvas||(m(this,I,Ql).call(this),m(this,I,Jl).call(this)),m(this,I,Xa).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},ap=function(){if(!r(this,ir))return;p(this,ir,!1);const e=Math.ceil(this.thickness*this.parentScale),s=this.currentPath.slice(-3),i=s.map(o=>o[0]),n=s.map(o=>o[1]);Math.min(...i)-e,Math.max(...i)+e,Math.min(...n)-e,Math.max(...n)+e;const{ctx:a}=this;a.save(),a.clearRect(0,0,this.canvas.width,this.canvas.height);for(const o of this.bezierPath2D)a.stroke(o);a.stroke(r(this,ci)),a.restore()},op=function(e,s,i,n,a,o,l){const h=(s+n)/2,d=(i+a)/2,u=(n+o)/2,f=(a+l)/2;e.bezierCurveTo(h+2*(n-h)/3,d+2*(a-d)/3,u+2*(n-u)/3,f+2*(a-f)/3,u,f)},lp=function(){const e=this.currentPath;if(e.length<=2)return[[e[0],e[0],e.at(-1),e.at(-1)]];const s=[];let i,[n,a]=e[0];for(i=1;i{p(this,Ns,null),this.canvas.removeEventListener("contextmenu",is)},10)),m(this,I,rp).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Ql=function(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")},Jl=function(){p(this,hi,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,hi).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,hi))==null||e.disconnect(),p(this,hi,null)},{once:!0})},xr=function(){if(!r(this,nr))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,I,Zl).call(this)},ed=function(e,s){const i=m(this,I,tc).call(this),n=(e-i)/r(this,er),a=(s-i)/r(this,tr);this.scaleFactor=Math.min(n,a)},Zl=function(){const e=m(this,I,tc).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},wi=new WeakSet,cp=function(e){const s=new Path2D;for(let i=0,n=e.length;i`image/${s}`))}static get supportedTypesStr(){return ot(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,s){s.pasteEditor(tt.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:n,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,l=await i.guess({name:"altText",request:{data:n,width:a,height:o,channels:n.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,s;r(this,he)&&(p(this,Mt,null),this._uiManager.imageManager.deleteId(r(this,he)),(e=r(this,Os))==null||e.remove(),p(this,Os,null),(s=r(this,ui))==null||s.disconnect(),p(this,ui,null),r(this,Hs)&&(clearTimeout(r(this,Hs)),p(this,Hs,null))),super.remove()}rebuild(){if(!this.parent){r(this,he)&&m(this,at,ec).call(this);return}super.rebuild(),this.div!==null&&(r(this,he)&&r(this,Os)===null&&m(this,at,ec).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,Xi)||r(this,Mt)||r(this,di)||r(this,Yi)||r(this,he))}get isResizable(){return!0}render(){if(this.div)return this.div;let e,s;if(this.width&&(e=this.x,s=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),r(this,Mt)?m(this,at,rd).call(this):m(this,at,ec).call(this),this.width&&!this.annotationElementId){const[i,n]=this.parentDimensions;this.setAt(e*i,s*n,this.width*i,this.height*n)}return this.div}copyCanvas(e,s,i=!1){var g;e||(e=224);const{width:n,height:a}=r(this,Mt),o=new th;let l=r(this,Mt),h=n,d=a,u=null;if(s){if(n>s||a>s){const P=Math.min(s/n,s/a);h=Math.floor(n*P),d=Math.floor(a*P)}u=document.createElement("canvas");const b=u.width=Math.ceil(h*o.sx),y=u.height=Math.ceil(d*o.sy);r(this,ze)||(l=m(this,at,sc).call(this,b,y));const w=u.getContext("2d");w.filter=this._uiManager.hcmFilter;let v="white",_="#cfcfd8";this._uiManager.hcmFilter!=="none"?_="black":(g=window.matchMedia)!=null&&g.call(window,"(prefers-color-scheme: dark)").matches&&(v="#8f8f9d",_="#42414d");const S=15,E=S*o.sx,T=S*o.sy,C=new OffscreenCanvas(E*2,T*2),x=C.getContext("2d");x.fillStyle=v,x.fillRect(0,0,E*2,T*2),x.fillStyle=_,x.fillRect(0,0,E,T),x.fillRect(E,T,E,T),w.fillStyle=w.createPattern(C,"repeat"),w.fillRect(0,0,b,y),w.drawImage(l,0,0,l.width,l.height,0,0,b,y)}let f=null;if(i){let b,y;if(o.symmetric&&l.widthe||a>e){const _=Math.min(e/n,e/a);b=Math.floor(n*_),y=Math.floor(a*_),r(this,ze)||(l=m(this,at,sc).call(this,b,y))}const v=new OffscreenCanvas(b,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,b,y),f={width:b,height:y,data:v.getImageData(0,0,b,y).data}}return{canvas:u,width:h,height:d,imageData:f}}getImageForAltText(){return r(this,Os)}static async deserialize(e,s,i){var y;let n=null;if(e instanceof Sf){const{data:{rect:w,rotation:v,id:_,structParent:S,popupRef:E},container:T,parent:{page:{pageNumber:C}}}=e,x=T.querySelector("canvas"),P=i.imageManager.getFromCanvas(T.id,x);x.remove();const M=((y=await s._structTree.getAriaAttributes(`${yd}${_}`))==null?void 0:y.get("aria-label"))||"";n=e={annotationType:tt.STAMP,bitmapId:P.id,bitmap:P.bitmap,pageIndex:C-1,rect:w.slice(0),rotation:v,id:_,deleted:!1,accessibilityData:{decorative:!1,altText:M},isSvg:!1,structParent:S,popupRef:E}}const a=await super.deserialize(e,s,i),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:d,isSvg:u,accessibilityData:f}=e;d&&i.imageManager.isValidId(d)?(p(a,he,d),l&&p(a,Mt,l)):p(a,di,h),p(a,ze,u);const[g,b]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/b,a.annotationElementId=e.id||null,f&&(a.altTextData=f),a._initialData=n,p(a,xa,!!n),a}serialize(e=!1,s=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i={annotationType:tt.STAMP,bitmapId:r(this,he),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,ze),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,at,ic).call(this,!0),i.accessibilityData=this.serializeAltText(!0),i;const{decorative:n,altText:a}=this.serializeAltText(!1);if(!n&&a&&(i.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const l=m(this,at,pp).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=r(this,ze)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,he)))s.stamps.set(r(this,he),{area:o,serialized:i}),i.bitmap=m(this,at,ic).call(this,!1);else if(r(this,ze)){const l=s.stamps.get(r(this,he));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,at,ic).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Mt=new WeakMap,he=new WeakMap,Xi=new WeakMap,di=new WeakMap,Yi=new WeakMap,Sa=new WeakMap,Os=new WeakMap,ui=new WeakMap,Hs=new WeakMap,ze=new WeakMap,xa=new WeakMap,at=new WeakSet,Ya=function(e,s=!1){if(!e){this.remove();return}p(this,Mt,e.bitmap),s||(p(this,he,e.id),p(this,ze,e.isSvg)),e.file&&p(this,Sa,e.file.name),m(this,at,rd).call(this)},Ka=function(){if(p(this,Xi,null),this._uiManager.enableWaiting(!1),!!r(this,Os)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Mt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Mt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},ec=function(){if(r(this,he)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,he)).then(i=>m(this,at,Ya).call(this,i,!0)).finally(()=>m(this,at,Ka).call(this));return}if(r(this,di)){const i=r(this,di);p(this,di,null),this._uiManager.enableWaiting(!0),p(this,Xi,this._uiManager.imageManager.getFromUrl(i).then(n=>m(this,at,Ya).call(this,n)).finally(()=>m(this,at,Ka).call(this)));return}if(r(this,Yi)){const i=r(this,Yi);p(this,Yi,null),this._uiManager.enableWaiting(!0),p(this,Xi,this._uiManager.imageManager.getFromFile(i).then(n=>m(this,at,Ya).call(this,n)).finally(()=>m(this,at,Ka).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=to.supportedTypesStr;const s=this._uiManager._signal;p(this,Xi,new Promise(i=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const n=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),m(this,at,Ya).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,at,Ka).call(this))),e.click()},rd=function(){const{div:e}=this;let{width:s,height:i}=r(this,Mt);const[n,a]=this.pageDimensions,o=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>o*n||i>o*a){const u=Math.min(o*n/s,o*a/i);s*=u,i*=u}const[l,h]=this.parentDimensions;this.setDims(s*l/n,i*h/a),this._uiManager.enableWaiting(!1);const d=p(this,Os,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,at,ad).call(this,s,i),m(this,at,fp).call(this),r(this,xa)||(this.parent.addUndoableEditor(this),p(this,xa,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,Sa)&&d.setAttribute("aria-label",r(this,Sa))},up=function(e,s){var o;const[i,n]=this.parentDimensions;this.width=e/i,this.height=s/n,(o=this._initialOptions)!=null&&o.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,r(this,Hs)!==null&&clearTimeout(r(this,Hs)),p(this,Hs,setTimeout(()=>{p(this,Hs,null),m(this,at,ad).call(this,e,s)},200))},sc=function(e,s){const{width:i,height:n}=r(this,Mt);let a=i,o=n,l=r(this,Mt);for(;a>2*e||o>2*s;){const h=a,d=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 u=new OffscreenCanvas(a,o);u.getContext("2d").drawImage(l,0,0,h,d,0,0,a,o),l=u.transferToImageBitmap()}return l},ad=function(e,s){const i=new th,n=Math.ceil(e*i.sx),a=Math.ceil(s*i.sy),o=r(this,Os);if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=r(this,ze)?r(this,Mt):m(this,at,sc).call(this,n,a),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,n,a)},ic=function(e){if(e){if(r(this,ze)){const n=this._uiManager.imageManager.getSvgUrl(r(this,he));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Mt),s.getContext("2d").drawImage(r(this,Mt),0,0),s.toDataURL()}if(r(this,ze)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Zi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Zi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Mt),0,0,r(this,Mt).width,r(this,Mt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Mt))},fp=function(){this._uiManager._signal&&(p(this,ui,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,at,up).call(this,s.width,s.height)})),r(this,ui).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,ui))==null||e.disconnect(),p(this,ui,null)},{once:!0}))},pp=function(e){var h;const{rect:s,pageIndex:i,accessibilityData:{altText:n}}=this._initialData,a=e.rect.every((d,u)=>Math.abs(d-s[u])<1),o=e.pageIndex===i,l=(((h=e.accessibilityData)==null?void 0:h.alt)||"")===n;return{isSame:a&&o&&l,isSameAltText:l}},Y(to,"_type","stamp"),Y(to,"_editorType",tt.STAMP);let nd=to;var or,Ca,js,Ki,fi,Ge,Qi,Ta,Ra,Ae,pi,U,Ji,de,gp,ld,cd,hd,nc;const rs=class rs{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:h,l10n:d}){A(this,de);A(this,or);A(this,Ca,!1);A(this,js,null);A(this,Ki,null);A(this,fi,null);A(this,Ge,new Map);A(this,Qi,!1);A(this,Ta,!1);A(this,Ra,!1);A(this,Ae,null);A(this,pi,null);A(this,U);const u=[...r(rs,Ji).values()];if(!rs._initialized){rs._initialized=!0;for(const f of u)f.initialize(d,t)}t.registerEditorTypes(u),p(this,U,t),this.pageIndex=e,this.div=s,p(this,or,n),p(this,js,a),this.viewport=h,p(this,Ae,l),this.drawLayer=o,this._structTree=i,r(this,U).addLayer(this)}get isEmpty(){return r(this,Ge).size===0}get isInvisible(){return this.isEmpty&&r(this,U).getMode()===tt.NONE}updateToolbar(t){r(this,U).updateToolbar(t)}updateMode(t=r(this,U).getMode()){switch(m(this,de,nc).call(this),t){case tt.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case tt.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case tt.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 r(rs,Ji).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,Ae))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,U).getMode()!==tt.INK)return;if(!t){for(const s of r(this,Ge).values())if(s.isEmpty()){s.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}setEditingState(t){r(this,U).setEditingState(t)}addCommands(t){r(this,U).addCommands(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=r(this,js))==null||e.div.classList.toggle("disabled",!t)}async enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);const t=new Set;for(const s of r(this,Ge).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,U).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,js))return;const e=r(this,js).getEditableAnnotations();for(const s of e){if(s.hide(),r(this,U).isDeletedAnnotationElement(s.data.id)||t.has(s.data.id))continue;const i=await this.deserialize(s);i&&(this.addOrRebuild(i),i.enableEditing())}}disable(){var i;p(this,Ra,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,Ge).values())if(n.disableEditing(),!!n.annotationElementId){if(n.serialize()!==null){t.set(n.annotationElementId,n);continue}else e.set(n.annotationElementId,n);(i=this.getEditableAnnotation(n.annotationElementId))==null||i.show(),n.remove()}if(r(this,js)){const n=r(this,js).getEditableAnnotations();for(const a of n){const{id:o}=a.data;if(r(this,U).isDeletedAnnotationElement(o))continue;let l=e.get(o);if(l){l.resetAnnotationElement(a),l.show(!1),a.show();continue}l=t.get(o),l&&(r(this,U).addChangedExistingAnnotation(l),l.renderAnnotationElement(a)&&l.show(!1)),a.show()}}m(this,de,nc).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(rs,Ji).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,Ra,!1)}getEditableAnnotation(t){var e;return((e=r(this,js))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){r(this,U).getActive()!==t&&r(this,U).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=r(this,Ae))!=null&&t.div&&!r(this,pi)){p(this,pi,new AbortController);const e=r(this,U).combinedSignal(r(this,pi));r(this,Ae).div.addEventListener("pointerdown",m(this,de,gp).bind(this),{signal:e}),r(this,Ae).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,Ae))!=null&&t.div&&r(this,pi)&&(r(this,pi).abort(),p(this,pi,null),r(this,Ae).div.classList.remove("highlighting"))}enableClick(){if(r(this,Ki))return;p(this,Ki,new AbortController);const t=r(this,U).combinedSignal(r(this,Ki));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t}),this.div.addEventListener("pointerup",this.pointerup.bind(this),{signal:t})}disableClick(){var t;(t=r(this,Ki))==null||t.abort(),p(this,Ki,null)}attach(t){r(this,Ge).set(t.id,t);const{annotationElementId:e}=t;e&&r(this,U).isDeletedAnnotationElement(e)&&r(this,U).removeDeletedAnnotationElement(t)}detach(t){var e;r(this,Ge).delete(t.id),(e=r(this,or))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,Ra)&&t.annotationElementId&&r(this,U).addDeletedAnnotationElement(t)}remove(t){this.detach(t),r(this,U).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1,r(this,Ta)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,U).addDeletedAnnotationElement(t.annotationElementId),mt.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),r(this,U).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(),r(this,U).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var s;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!r(this,fi)&&(t._focusEventsAllowed=!1,p(this,fi,setTimeout(()=>{p(this,fi,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:r(this,U)._signal}),e.focus())},0))),t._structTreeParentId=(s=r(this,or))==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 r(this,U).getId()}combinedSignal(t){return r(this,U).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=r(this,de,ld))==null?void 0:t.canCreateNewEmptyEditor()}pasteEditor(t,e){r(this,U).updateToolbar(t),r(this,U).updateMode(t);const{offsetX:s,offsetY:i}=m(this,de,hd).call(this),n=this.getNextId(),a=m(this,de,cd).call(this,{parent:this,id:n,x:s,y:i,uiManager:r(this,U),isCentered:!0,...e});a&&this.add(a)}async deserialize(t){var e;return await((e=r(rs,Ji).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,r(this,U)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=m(this,de,cd).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:r(this,U),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(){this.createAndAddNewEditor(m(this,de,hd).call(this),!0)}setSelected(t){r(this,U).setSelected(t)}toggleSelected(t){r(this,U).toggleSelected(t)}unselect(t){r(this,U).unselect(t)}pointerup(t){const{isMac:e}=xe.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,Qi)){if(p(this,Qi,!1),!r(this,Ca)){p(this,Ca,!0);return}if(r(this,U).getMode()===tt.STAMP){r(this,U).unselectAll();return}this.createAndAddNewEditor(t,!1)}}pointerdown(t){if(r(this,U).getMode()===tt.HIGHLIGHT&&this.enableTextSelection(),r(this,Qi)){p(this,Qi,!1);return}const{isMac:e}=xe.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,Qi,!0);const s=r(this,U).getActive();p(this,Ca,!s||s.isEmpty())}findNewParent(t,e,s){const i=r(this,U).findParent(e,s);return i===null||i===this?!1:(i.changeParent(t),!0)}destroy(){var t,e;((t=r(this,U).getActive())==null?void 0:t.parent)===this&&(r(this,U).commitOrRemove(),r(this,U).setActiveEditor(null)),r(this,fi)&&(clearTimeout(r(this,fi)),p(this,fi,null));for(const s of r(this,Ge).values())(e=r(this,or))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,Ge).clear(),r(this,U).removeLayer(this)}render({viewport:t}){this.viewport=t,lr(this.div,t);for(const e of r(this,U).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){r(this,U).commitOrRemove(),m(this,de,nc).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,lr(this.div,{rotation:s}),e!==s)for(const i of r(this,Ge).values())i.rotate(s);this.addInkEditorIfNeeded(!1)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return r(this,U).viewParameters.realScale}};or=new WeakMap,Ca=new WeakMap,js=new WeakMap,Ki=new WeakMap,fi=new WeakMap,Ge=new WeakMap,Qi=new WeakMap,Ta=new WeakMap,Ra=new WeakMap,Ae=new WeakMap,pi=new WeakMap,U=new WeakMap,Ji=new WeakMap,de=new WeakSet,gp=function(t){r(this,U).unselectAll();const{target:e}=t;if(e===r(this,Ae).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&r(this,Ae).div.contains(e)){const{isMac:s}=xe.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,U).showAllEditors("highlight",!0,!0),r(this,Ae).div.classList.add("free"),this.toggleDrawing(),cc.startHighlighting(this,r(this,U).direction==="ltr",{target:r(this,Ae).div,x:t.x,y:t.y}),r(this,Ae).div.addEventListener("pointerup",()=>{r(this,Ae).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:r(this,U)._signal}),t.preventDefault()}},ld=function(){return r(rs,Ji).get(r(this,U).getMode())},cd=function(t){const e=r(this,de,ld);return e?new e.prototype.constructor(t):null},hd=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),o=Math.min(window.innerWidth,t+s),l=Math.min(window.innerHeight,e+i),h=(n+o)/2-t,d=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[h,d]:[d,h];return{offsetX:u,offsetY:f}},nc=function(){p(this,Ta,!0);for(const t of r(this,Ge).values())t.isEmpty()&&t.remove();p(this,Ta,!1)},Y(rs,"_initialized",!1),A(rs,Ji,new Map([Bh,Yh,nd,cc].map(t=>[t._editorType,t])));let od=rs;var Bs,ml,Wt,gi,bl,ud,fr,fd,mp;const oe=class oe{constructor({pageIndex:t}){A(this,fr);A(this,Bs,null);A(this,ml,0);A(this,Wt,new Map);A(this,gi,new Map);this.pageIndex=t}setParent(t){if(!r(this,Bs)){p(this,Bs,t);return}if(r(this,Bs)!==t){if(r(this,Wt).size>0)for(const e of r(this,Wt).values())e.remove(),t.append(e);p(this,Bs,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new Pd)}draw(t,e,s,i=!1){const n=we(this,ml)._++,a=m(this,fr,fd).call(this,t.box);a.classList.add(...t.classNamesForDrawing);const o=oe._svgFactory.createElement("defs");a.append(o);const l=oe._svgFactory.createElement("path");o.append(l);const h=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",h),l.setAttribute("d",t.toSVGPath()),i&&r(this,gi).set(n,l);const d=m(this,fr,mp).call(this,o,h),u=oe._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${h}`),r(this,Wt).set(n,a),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=we(this,ml)._++,s=m(this,fr,fd).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=oe._svgFactory.createElement("defs");s.append(i);const n=oe._svgFactory.createElement("path");i.append(n);const a=`path_p${this.pageIndex}_${e}`;n.setAttribute("id",a),n.setAttribute("d",t.toSVGPath()),n.setAttribute("vector-effect","non-scaling-stroke");let o;if(t.mustRemoveSelfIntersections){const d=oe._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=oe._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=oe._svgFactory.createElement("use");d.append(f),f.setAttribute("href",`#${a}`),f.setAttribute("stroke","none"),f.setAttribute("fill","black"),f.setAttribute("fill-rule","nonzero"),f.classList.add("mask")}const l=oe._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const h=l.cloneNode();return s.append(h),l.classList.add("mainOutline"),h.classList.add("secondaryOutline"),r(this,Wt).set(e,s),e}finalizeLine(t,e){const s=r(this,gi).get(t);r(this,gi).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Wt).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){r(this,gi).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=oe,bl,ud).call(s,r(this,Wt).get(t),e)}show(t,e){r(this,Wt).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Wt).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Wt).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Wt).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Wt).get(t).classList.add(e)}removeClass(t,e){r(this,Wt).get(t).classList.remove(e)}getSVGRoot(t){return r(this,Wt).get(t)}remove(t){r(this,gi).delete(t),r(this,Bs)!==null&&(r(this,Wt).get(t).remove(),r(this,Wt).delete(t))}destroy(){p(this,Bs,null);for(const t of r(this,Wt).values())t.remove();r(this,Wt).clear(),r(this,gi).clear()}};Bs=new WeakMap,ml=new WeakMap,Wt=new WeakMap,gi=new WeakMap,bl=new WeakSet,ud=function(t,{x:e=0,y:s=0,width:i=1,height:n=1}={}){const{style:a}=t;a.top=`${100*s}%`,a.left=`${100*e}%`,a.width=`${100*i}%`,a.height=`${100*n}%`},fr=new WeakSet,fd=function(t){var s;const e=oe._svgFactory.create(1,1,!0);return r(this,Bs).append(e),e.setAttribute("aria-hidden",!0),m(s=oe,bl,ud).call(s,e,t),e},mp=function(t,e){const s=oe._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=oe._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},A(oe,bl);let dd=oe;Q.AbortException;Q.AnnotationEditorLayer;Q.AnnotationEditorParamsType;Q.AnnotationEditorType;Q.AnnotationEditorUIManager;var bp=Q.AnnotationLayer,Ap=Q.AnnotationMode;Q.ColorPicker;Q.DOMSVGFactory;Q.DrawLayer;Q.FeatureTest;var Nc=Q.GlobalWorkerOptions;Q.ImageKind;Q.InvalidPDFException;Q.MissingPDFException;Q.OPS;Q.OutputScale;var Qm=Q.PDFDataRangeTransport;Q.PDFDateString;Q.PDFWorker;Q.PasswordResponses;Q.PermissionFlag;Q.PixelsPerInch;Q.RenderingCancelledException;var yp=Q.TextLayer;Q.UnexpectedResponseException;Q.Util;Q.VerbosityLevel;Q.XfaLayer;Q.build;Q.createValidAbsoluteUrl;Q.fetchData;var vp=Q.getDocument;Q.getFilenameFromUrl;Q.getPdfFilenameFromUrl;Q.getXfaPageViewport;Q.isDataScheme;Q.isPdfFile;Q.noContextMenu;Q.normalizeUnicode;Q.setLayerDimensions;Q.shadow;var pd=Q.version;const Jm=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:bp,AnnotationMode:Ap,GlobalWorkerOptions:Nc,PDFDataRangeTransport:Qm,TextLayer:yp,getDocument:vp,version:pd},Symbol.toStringTag,{value:"Module"}));var ee=function(c,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s{wt(this.pdfDocument),wt(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{wt(Array.isArray(e));const s=e[0];new Promise(i=>{wt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{wt(!1)}):typeof s=="number"?i(s):wt(!1)}).then(i=>{const n=i+1;wt(this.pdfViewer),wt(n>=1&&n<=this.pagesCount),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:i,pageNumber:n})})})}navigateTo(t){this.goToDestination(t)}goToPage(t){const e=t-1;wt(this.pdfViewer),wt(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||wb,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const su={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Oc=typeof window<"u",Ep=Oc&&window.location.protocol==="file:";function Eb(c){return typeof c<"u"}function rn(c){return Eb(c)&&c!==null}function Sb(c){return typeof c=="string"}function xb(c){return c instanceof ArrayBuffer}function Cb(c){return wt(Oc),c instanceof Blob}function gd(c){return Sb(c)&&/^data:/.test(c)}function iu(c){wt(gd(c));const[t="",e=""]=c.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function Tb(){return Oc&&window.devicePixelRatio||1}const Sp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function nu(){ye(!Ep,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${Sp}`)}function Rb(){ye(!Ep,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${Sp}`)}function dr(c){c!=null&&c.cancel&&c.cancel()}function md(c,t){return Object.defineProperty(c,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(c,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(c,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(c,"originalHeight",{get(){return this.view[3]},configurable:!0}),c}function Pb(c){return c.name==="RenderingCancelledException"}function kb(c){return new Promise((t,e)=>{const s=new FileReader;s.onload=()=>{if(!s.result)return e(new Error("Error while reading a file."));t(s.result)},s.onerror=i=>{if(!i.target)return e(new Error("Error while reading a file."));const{error:n}=i.target;if(!n)return e(new Error("Error while reading a file."));switch(n.code){case n.NOT_FOUND_ERR:return e(new Error("Error while reading a file: File not found."));case n.SECURITY_ERR:return e(new Error("Error while reading a file: Security error."));case n.ABORT_ERR:return e(new Error("Error while reading a file: Aborted."));default:return e(new Error("Error while reading a file."))}},s.readAsArrayBuffer(c)})}function Lb(c,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return c}}function Pa(){return R.useReducer(Lb,{value:void 0,error:void 0})}var Mb=function(c,t,e,s){function i(n){return n instanceof e?n:new e(function(a){a(n)})}return new(e||(e=Promise))(function(n,a){function o(d){try{h(s.next(d))}catch(u){a(u)}}function l(d){try{h(s.throw(d))}catch(u){a(u)}}function h(d){d.done?n(d.value):i(d.value).then(o,l)}h((s=s.apply(c,t||[])).next())})},ru=function(c,t){var e={};for(var s in c)Object.prototype.hasOwnProperty.call(c,s)&&t.indexOf(s)<0&&(e[s]=c[s]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(c);i{switch(t){case su.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");c(e);break}case su.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");c(e);break}}};function au(c){return typeof c=="object"&&c!==null&&("data"in c||"range"in c||"url"in c)}const Db=R.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:h,imageResourcesPath:d,loading:u="Loading PDF…",noData:f="No PDF file specified.",onItemClick:g,onLoadError:b,onLoadProgress:y,onLoadSuccess:w,onPassword:v=Fb,onSourceError:_,onSourceSuccess:S,options:E,renderMode:T,rotate:C}=t,x=ru(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[P,M]=Pa(),{value:O,error:L}=P,[V,G]=Pa(),{value:z,error:q}=V,W=R.useRef(new _b),D=R.useRef([]),j=R.useRef(void 0),Rt=R.useRef(void 0);l&&l!==j.current&&au(l)&&(ye(!Pr(l,j.current),`File prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.`),j.current=l),E&&E!==Rt.current&&(ye(!Pr(E,Rt.current),`Options prop passed to changed, but it's equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.`),Rt.current=E);const Et=R.useRef({scrollPageIntoView:lt=>{const{dest:vt,pageNumber:Ft,pageIndex:Dt=Ft-1}=lt;if(g){g({dest:vt,pageIndex:Dt,pageNumber:Ft});return}const ws=D.current[Dt];if(ws){ws.scrollIntoView();return}ye(!1,`An internal link leading to page ${Ft} was clicked, but neither was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to and handle navigating by yourself or ensure that all pages are rendered within .`)}});R.useImperativeHandle(e,()=>({linkService:W,pages:D,viewer:Et}),[]);function St(){S&&S()}function ut(){L&&(ye(!1,L.toString()),_&&_(L))}function ht(){M({type:"RESET"})}R.useEffect(ht,[l,M]);const Ht=R.useCallback(()=>Mb(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return gd(l)?{data:iu(l)}:(nu(),{url:l});if(l instanceof Ib)return{range:l};if(xb(l))return{data:l};if(Oc&&Cb(l))return{data:yield kb(l)};if(wt(typeof l=="object"),wt(au(l)),"url"in l&&typeof l.url=="string"){if(gd(l.url)){const{url:lt}=l,vt=ru(l,["url"]),Ft=iu(lt);return Object.assign({data:Ft},vt)}nu()}return l}),[l]);R.useEffect(()=>{const lt=wl(Ht());return lt.promise.then(vt=>{M({type:"RESOLVE",value:vt})}).catch(vt=>{M({type:"REJECT",error:vt})}),()=>{dr(lt)}},[Ht,M]),R.useEffect(()=>{if(!(typeof O>"u")){if(O===!1){ut();return}St()}},[O]);function ue(){z&&(w&&w(z),D.current=new Array(z.numPages),W.current.setDocument(z))}function et(){q&&(ye(!1,q.toString()),b&&b(q))}R.useEffect(function(){G({type:"RESET"})},[G,O]),R.useEffect(function(){if(!O)return;const vt=E?Object.assign(Object.assign({},O),E):O,Ft=vp(vt);y&&(Ft.onProgress=y),v&&(Ft.onPassword=v);const Dt=Ft,ws=Dt.promise.then(B=>{G({type:"RESOLVE",value:B})}).catch(B=>{Dt.destroyed||G({type:"REJECT",error:B})});return()=>{ws.finally(()=>Dt.destroy())}},[E,G,O]),R.useEffect(()=>{if(!(typeof z>"u")){if(z===!1){et();return}ue()}},[z]),R.useEffect(function(){W.current.setViewer(Et.current),W.current.setExternalLinkRel(a),W.current.setExternalLinkTarget(o)},[a,o]);const J=R.useCallback((lt,vt)=>{D.current[lt]=vt},[]),$t=R.useCallback(lt=>{delete D.current[lt]},[]),Zt=R.useMemo(()=>({imageResourcesPath:d,linkService:W.current,onItemClick:g,pdf:z,registerPage:J,renderMode:T,rotate:C,unregisterPage:$t}),[d,g,z,J,T,C,$t]),ct=R.useMemo(()=>wp(x,()=>z),[x,z]);function ns(){return k.jsx(_p.Provider,{value:Zt,children:s})}function qe(){return l?z==null?k.jsx(kr,{type:"loading",children:typeof u=="function"?u():u}):z===!1?k.jsx(kr,{type:"error",children:typeof n=="function"?n():n}):ns():k.jsx(kr,{type:"no-data",children:typeof f=="function"?f():f})}return k.jsx("div",Object.assign({className:Tc("react-pdf__Document",i),ref:h,style:{"--scale-factor":"1"}},ct,{children:qe()}))});function xp(){return R.useContext(_p)}function Cp(){for(var c=[],t=0;tjb(t),[t]),s=R.useMemo(()=>!Hc(t)||Pp(t)?null:t.children.map((i,n)=>k.jsx(Lp,{node:i},n)),[t]);return k.jsx("span",Object.assign({className:c},e,{children:s}))}function jc(){return R.useContext(Tp)}function Bb(){const c=jc();wt(c);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=c,[s,i]=Pa(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=c;function h(){n&&e&&e(n)}function d(){a&&(ye(!1,a.toString()),t&&t(a))}return R.useEffect(function(){i({type:"RESET"})},[i,l]),R.useEffect(function(){if(o||!l)return;const f=wl(l.getStructTree()),g=f;return f.promise.then(b=>{i({type:"RESOLVE",value:b})}).catch(b=>{i({type:"REJECT",error:b})}),()=>dr(g)},[o,l,i]),R.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}h()}},[n]),n?k.jsx(Lp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const ou=Ap;function $b(c){const t=jc();wt(t);const e=Object.assign(Object.assign({},t),c),{_className:s,canvasBackground:i,devicePixelRatio:n=Tb(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:h,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:g}=c;wt(l);const b=R.useRef(null);function y(){l&&o&&o(md(l,f))}function w(E){Pb(E)||(ye(!1,E.toString()),a&&a(E))}const v=R.useMemo(()=>l.getViewport({scale:f*n,rotation:u}),[n,l,u,f]),_=R.useMemo(()=>l.getViewport({scale:f,rotation:u}),[l,u,f]);R.useEffect(function(){if(!l)return;l.cleanup();const{current:T}=b;if(!T)return;T.width=v.width,T.height=v.height,T.style.width=`${Math.floor(_.width)}px`,T.style.height=`${Math.floor(_.height)}px`,T.style.visibility="hidden";const C={annotationMode:h?ou.ENABLE_FORMS:ou.ENABLE,canvasContext:T.getContext("2d",{alpha:!1}),viewport:v};i&&(C.background=i);const x=l.render(C),P=x;return x.promise.then(()=>{T.style.visibility="",y()}).catch(w),()=>dr(P)},[i,l,h,v,_]);const S=R.useCallback(()=>{const{current:E}=b;E&&(E.width=0,E.height=0)},[]);return R.useEffect(()=>S,[S]),k.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:Cp(g,b),style:{display:"block",userSelect:"none"},children:d?k.jsx(Bb,{}):null})}function zb(c){return"str"in c}function Gb(){const c=jc();wt(c);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:h,scale:d}=c;wt(a);const[u,f]=Pa(),{value:g,error:b}=u,y=R.useRef(null);ye(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10)===1,"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");function w(){g&&s&&s(g)}function v(){b&&(ye(!1,b.toString()),e&&e(b))}R.useEffect(function(){f({type:"RESET"})},[a,f]),R.useEffect(function(){if(!a)return;const P=wl(a.getTextContent()),M=P;return P.promise.then(O=>{f({type:"RESOLVE",value:O})}).catch(O=>{f({type:"REJECT",error:O})}),()=>dr(M)},[a,f]),R.useEffect(()=>{if(g!==void 0){if(g===!1){v();return}w()}},[g]);const _=R.useCallback(()=>{n&&n()},[n]),S=R.useCallback(x=>{ye(!1,x.toString()),i&&i(x)},[i]);function E(){const x=y.current;x&&x.classList.add("selecting")}function T(){const x=y.current;x&&x.classList.remove("selecting")}const C=R.useMemo(()=>a.getViewport({scale:d,rotation:h}),[a,h,d]);return R.useLayoutEffect(function(){if(!a||!g)return;const{current:P}=y;if(!P)return;P.innerHTML="";const M=a.streamTextContent({includeMarkedContent:!0}),O={container:P,textContentSource:M,viewport:C},L=new yp(O),V=L;return L.render().then(()=>{const G=document.createElement("div");G.className="endOfContent",P.append(G);const z=P.querySelectorAll('[role="presentation"]');if(t){let q=0;g.items.forEach((W,D)=>{if(!zb(W))return;const j=z[q];if(!j)return;const Rt=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:D},W));j.innerHTML=Rt,q+=W.str&&W.hasEOL?2:1})}_()}).catch(S),()=>dr(V)},[t,S,_,a,o,l,g,C]),k.jsx("div",{className:Tc("react-pdf__Page__textContent","textLayer"),onMouseUp:T,onMouseDown:E,ref:y})}function Ub(){const c=xp(),t=jc();wt(t);const e=Object.assign(Object.assign({},c),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:a,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:l,page:h,pdf:d,renderForms:u,rotate:f,scale:g=1}=e;wt(d),wt(h),wt(i);const[b,y]=Pa(),{value:w,error:v}=b,_=R.useRef(null);ye(Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10)===1,"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");function S(){w&&a&&a(w)}function E(){v&&(ye(!1,v.toString()),n&&n(v))}R.useEffect(function(){y({type:"RESET"})},[y,h]),R.useEffect(function(){if(!h)return;const M=wl(h.getAnnotations()),O=M;return M.promise.then(L=>{y({type:"RESOLVE",value:L})}).catch(L=>{y({type:"REJECT",error:L})}),()=>{dr(O)}},[y,h]),R.useEffect(()=>{if(w!==void 0){if(w===!1){E();return}S()}},[w]);function T(){l&&l()}function C(P){ye(!1,`${P}`),o&&o(P)}const x=R.useMemo(()=>h.getViewport({scale:g,rotation:f}),[h,f,g]);return R.useEffect(function(){if(!d||!h||!i||!w)return;const{current:M}=_;if(!M)return;const O=x.clone({dontFlip:!0}),L={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:M,l10n:null,page:h,structTreeLayer:null,viewport:O},V={annotations:w,annotationStorage:d.annotationStorage,div:M,imageResourcesPath:s,linkService:i,page:h,renderForms:u,viewport:O};M.innerHTML="";try{new bp(L).render(V),T()}catch(G){C(G)}return()=>{}},[w,s,i,h,d,u,x]),k.jsx("div",{className:Tc("react-pdf__Page__annotations","annotationLayer"),ref:_})}var Wb=function(c,t){var e={};for(var s in c)Object.prototype.hasOwnProperty.call(c,s)&&t.indexOf(s)<0&&(e[s]=c[s]);if(c!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(c);i{if(!ct)return null;let Pt=1;const Gt=Ht??lu;if(et||g){const br=ct.getViewport({scale:1,rotation:Ft});et?Pt=et/br.width:g&&(Pt=g/br.height)}return Gt*Pt},[g,ct,Ft,Ht,et]);R.useEffect(function(){return()=>{rn(lt)&&i&&ue&&ue(lt)}},[i,D,lt,ue]);function ws(){if(P){if(!ct||!Dt)return;P(md(ct,Dt))}if(i&&j){if(!rn(lt)||!qe.current)return;j(lt,qe.current)}}function B(){ns&&(ye(!1,ns.toString()),x&&x(ns))}R.useEffect(function(){Zt({type:"RESET"})},[Zt,D,lt]),R.useEffect(function(){if(!D||!vt)return;const Gt=wl(D.getPage(vt)),br=Gt;return Gt.promise.then(ka=>{Zt({type:"RESOLVE",value:ka})}).catch(ka=>{Zt({type:"REJECT",error:ka})}),()=>dr(br)},[Zt,D,vt]),R.useEffect(()=>{if(ct!==void 0){if(ct===!1){B();return}ws()}},[ct,Dt]);const X=R.useMemo(()=>ct&&rn(lt)&&vt&&rn(Ft)&&rn(Dt)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:_,onGetStructTreeError:S,onGetStructTreeSuccess:E,onGetTextError:T,onGetTextSuccess:C,onRenderAnnotationLayerError:M,onRenderAnnotationLayerSuccess:O,onRenderError:L,onRenderSuccess:V,onRenderTextLayerError:G,onRenderTextLayerSuccess:z,page:ct,pageIndex:lt,pageNumber:vt,renderForms:Et,renderTextLayer:ut,rotate:Ft,scale:Dt}:null,[s,n,d,u,v,_,S,E,T,C,M,O,L,V,G,z,ct,lt,vt,Et,ut,Ft,Dt]),bt=R.useMemo(()=>wp(J,()=>ct&&(Dt?md(ct,Dt):void 0)),[J,ct,Dt]),xt=`${lt}@${Dt}/${Ft}`;function zt(){switch(St){case"custom":return wt(h),k.jsx(h,{},`${xt}_custom`);case"none":return null;case"canvas":default:return k.jsx($b,{canvasRef:a},`${xt}_canvas`)}}function te(){return ut?k.jsx(Gb,{},`${xt}_text`):null}function _i(){return Rt?k.jsx(Ub,{},`${xt}_annotations`):null}function N(){return k.jsxs(Tp.Provider,{value:X,children:[zt(),te(),_i(),o]})}function st(){return vt?D===null||ct===void 0||ct===null?k.jsx(kr,{type:"loading",children:typeof y=="function"?y():y}):D===!1||ct===!1?k.jsx(kr,{type:"error",children:typeof f=="function"?f():f}):N():k.jsx(kr,{type:"no-data",children:typeof w=="function"?w():w})}return k.jsx("div",Object.assign({className:Tc(s,l),"data-page-number":vt,ref:Cp(b,qe),style:{"--scale-factor":`${Dt}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},bt,{children:st()}))}Rb();Nc.workerSrc="pdf.worker.mjs";const qb="/assets/pdf.worker.min-GB3t0DcA.js";Nc.workerSrc=qb;function Xb(){if(!Nc.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(pd!=="4.8.69")throw new Error(`PDF runtime version mismatch (${pd}).`)}const Yb=280,Kb=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","A"]);function Qb({enabled:c,pagesRoot:t,routeId:e,paperVersion:s,numPages:i,resetKey:n,onSelect:a,onError:o}){const l=R.useRef(!1),h=R.useRef(!1),d=R.useRef(""),u=R.useRef(0),f=R.useRef(0),g=R.useRef(""),b=R.useRef(a),y=R.useRef(o);b.current=a,y.current=o,R.useEffect(()=>{l.current=!1,h.current=!1,d.current="",g.current="",window.clearTimeout(u.current),cancelAnimationFrame(f.current),f.current=0},[e,s,n]),R.useEffect(()=>{if(!c){l.current=!1,h.current=!1,window.clearTimeout(u.current),cancelAnimationFrame(f.current),f.current=0;return}const w=()=>{var M,O;const x=$p({selection:window.getSelection(),pagesRoot:t.current,routeId:e,paperVersion:s,numPages:i});if(!x.ok){x.error&&((M=y.current)==null||M.call(y,x.error));return}const P=zp(x.selection);P!==d.current&&(d.current=P,(O=b.current)==null||O.call(b,x.selection))},v=()=>{window.clearTimeout(u.current),cancelAnimationFrame(f.current),f.current=requestAnimationFrame(()=>{f.current=0,w()})},_=x=>{const P=t.current;!P||!x.isPrimary||x.pointerType==="mouse"&&x.button!==0||!(x.target instanceof Node)||!P.contains(x.target)||(l.current=!0,h.current=!1,d.current="",window.clearTimeout(u.current),cancelAnimationFrame(f.current),f.current=0)},S=x=>{!l.current||!x.isPrimary||(l.current=!1,v())},E=x=>{!l.current||!x.isPrimary||(l.current=!1,h.current=!0,g.current="",window.clearTimeout(u.current),cancelAnimationFrame(f.current),f.current=0)},T=x=>{var L,V;const P=t.current;if(!P||l.current||!(x.target instanceof Node&&!!((V=(L=x.target instanceof Element?x.target:x.target.parentElement)==null?void 0:L.closest)!=null&&V.call(L,".textLayer")&&P.contains(x.target))))return;const O=(x.key==="a"||x.key==="A")&&(x.metaKey||x.ctrlKey);(x.shiftKey||Kb.has(x.key)||O)&&(h.current=!1,d.current="",v())},C=()=>{if(l.current||h.current)return;const x=window.getSelection(),P=x&&x.rangeCount===1?`${x.toString()}\0${x.anchorNode?1:0}\0${x.focusNode?1:0}`:"";g.current=P,window.clearTimeout(u.current),u.current=window.setTimeout(()=>{g.current===P&&w()},Yb)};return document.addEventListener("pointerdown",_,!0),document.addEventListener("pointerup",S,!0),document.addEventListener("pointercancel",E,!0),document.addEventListener("keyup",T,!0),document.addEventListener("selectionchange",C),()=>{document.removeEventListener("pointerdown",_,!0),document.removeEventListener("pointerup",S,!0),document.removeEventListener("pointercancel",E,!0),document.removeEventListener("keyup",T,!0),document.removeEventListener("selectionchange",C),window.clearTimeout(u.current),cancelAnimationFrame(f.current)}},[c,i,t,s,e])}function Jb({paperTitle:c,paperHref:t,resources:e,page:s,pages:i,zoomPercent:n,searchOpen:a,searchQuery:o,searchMatch:l,searchCount:h,searching:d,onPage:u,onZoomIn:f,onZoomOut:g,onToggleSearch:b,onCloseSearch:y,onSearchQuery:w,onSearch:v}){const _=R.useRef(null);R.useLayoutEffect(()=>{const E=_.current,T=document.querySelector(".app-header .brand-mark");if(!E||!T)return;const C=()=>{const P=T.getBoundingClientRect().left-E.getBoundingClientRect().left;E.style.setProperty("--reader-title-inset",`${Math.max(10,P)}px`)};C();const x=new ResizeObserver(C);return x.observe(E),x.observe(T),()=>x.disconnect()},[]);const S=E=>{E.preventDefault();const T=Number(new FormData(E.currentTarget).get("page"));Number.isInteger(T)&&u(T)};return k.jsxs("div",{ref:_,className:"pdf-toolbar","aria-label":"PDF controls",children:[k.jsxs("div",{className:"pdf-toolbar-paper",children:[k.jsx(Qa,{className:"pdf-toolbar-back",to:t,"aria-label":"Back",children:"← Back"}),k.jsx(Qa,{className:"pdf-toolbar-title",to:t,title:c,"aria-label":`${c} — open paper page`,children:c}),(e==null?void 0:e.repository)&&k.jsxs("a",{className:"pdf-toolbar-resource",href:e.repository.href,target:"_blank",rel:"noopener noreferrer",title:"Official GitHub repository","aria-label":"Open official GitHub repository",children:[k.jsx(Gp,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),k.jsxs("span",{"aria-label":`${e.repository.stars} GitHub stars`,children:["★ ",e.repository.stars.toLocaleString()]})]}),(e==null?void 0:e.projectPage)&&k.jsxs("a",{className:"pdf-toolbar-resource",href:e.projectPage.href,target:"_blank",rel:"noopener noreferrer",title:e.projectPage.href,"aria-label":`Open project page at ${e.projectPage.label}`,children:[k.jsx(Up,{size:14,strokeWidth:1.8,"aria-hidden":"true"}),k.jsx("span",{children:e.projectPage.label})]}),(e==null?void 0:e.huggingFace)&&k.jsxs("a",{className:"pdf-toolbar-resource",href:e.huggingFace.href,target:"_blank",rel:"noopener noreferrer","aria-label":`Open ${e.huggingFace.count} Hugging Face ${e.huggingFace.count===1?"artifact":"artifacts"}`,children:[k.jsx("span",{"aria-hidden":"true",children:"🤗"}),k.jsxs("span",{children:[e.huggingFace.count," HF ",e.huggingFace.count===1?"artifact":"artifacts"]})]})]}),k.jsxs("div",{className:"pdf-toolbar-controls",children:[k.jsxs("div",{className:"pdf-toolbar-group",children:[k.jsx("button",{type:"button",onClick:()=>u(s-1),disabled:s<=1,"aria-label":"Previous page",children:"←"}),k.jsxs("form",{onSubmit:S,className:"pdf-page-form",children:[k.jsx("label",{className:"sr-only",htmlFor:"pdf-current-page",children:"Current page"}),k.jsx("input",{id:"pdf-current-page",name:"page",type:"number",min:1,max:i||1,defaultValue:s,"aria-label":`Page ${s} of ${i||"unknown"}`},s),k.jsxs("span",{"aria-hidden":"true",children:["/ ",i||"—"]})]}),k.jsx("button",{type:"button",onClick:()=>u(s+1),disabled:!i||s>=i,"aria-label":"Next page",children:"→"})]}),k.jsxs("div",{className:"pdf-toolbar-group",children:[k.jsx("button",{type:"button",onClick:g,"aria-label":"Zoom out",children:"−"}),k.jsxs("span",{className:"pdf-zoom-value","aria-live":"polite",children:[n,"%"]}),k.jsx("button",{type:"button",onClick:f,"aria-label":"Zoom in",children:"+"}),k.jsx("button",{type:"button",onClick:b,"aria-expanded":a,"aria-controls":"pdf-search-controls",children:"Search"})]})]}),a&&k.jsxs("div",{id:"pdf-search-controls",className:"pdf-search-controls",children:[k.jsx("label",{className:"sr-only",htmlFor:"pdf-search-input",children:"Search document"}),k.jsx("input",{id:"pdf-search-input",autoFocus:!0,value:o,onChange:E=>w(E.target.value),placeholder:"Search document"}),k.jsx("span",{role:"status",children:d?"Searching…":o?`${h?l+1:0} of ${h}`:""}),k.jsx("button",{type:"button",onClick:()=>v(-1),disabled:!h,"aria-label":"Previous match",children:"↑"}),k.jsx("button",{type:"button",onClick:()=>v(1),disabled:!h,"aria-label":"Next match",children:"↓"}),k.jsx("button",{type:"button",onClick:y,"aria-label":"Close search",title:"Close search",children:k.jsx(Op,{size:16,"aria-hidden":"true"})})]})]})}function Zb(c){const t=c.message.toLowerCase();return t.includes("password")?"This PDF is encrypted and cannot be opened in the reader.":t.includes("worker")?"The PDF renderer could not start.":t.includes("invalid")||t.includes("format")?"The source returned an invalid or unsupported PDF.":t.includes("cors")||t.includes("fetch")||t.includes("network")?"The PDF source could not be loaded in this browser.":"The PDF could not be loaded from its source."}function Fa(c){return c.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]??t)}function tA(c,t,e){const s=t.trim().toLocaleLowerCase();if(!s)return Fa(c);const i=c.toLocaleLowerCase(),n=`pdf-search-highlight${e?" is-active":""}`;let a=0,o=i.indexOf(s);if(o<0)return Fa(c);let l="";for(;o>=0;)l+=Fa(c.slice(a,o)),l+=`${Fa(c.slice(o,o+s.length))}`,a=o+s.length,o=i.indexOf(s,a);return l+Fa(c.slice(a))}function eA({page:c,width:t,searchQuery:e,activeSearchPage:s}){const i=R.useRef(null),[n,a]=R.useState(c<=2);return R.useEffect(()=>{const o=i.current;if(!o)return;const l=new IntersectionObserver(([h])=>a(h.isIntersecting),{rootMargin:"120% 0px"});return l.observe(o),()=>l.disconnect()},[]),k.jsx("div",{ref:i,className:"pdf-page","data-page":c,style:{minHeight:Math.round(t*1.35)},children:n&&k.jsx(Vb,{pageNumber:c,width:t,devicePixelRatio:Math.min(window.devicePixelRatio||1,2),renderTextLayer:!0,renderAnnotationLayer:!0,loading:null,customTextRenderer:e?({str:o})=>tA(o,e,c===s):void 0})})}function sA({url:c,paperKey:t,paperTitle:e,paperHref:s,resources:i,initialPage:n=1,resizeActive:a=!1,selectionEnabled:o=!1,paperVersion:l="",onPaperSelection:h,onPaperSelectionError:d,onPageChange:u}){const f=R.useRef(null),g=R.useRef(null),b=R.useRef(null),y=R.useRef(null),w=R.useRef(0),v=R.useRef(!1),_=R.useRef(0),S=R.useRef(0),E=R.useRef(0),T=R.useRef(1),C=R.useRef(1),x=R.useRef(1),P=R.useRef(!1),[M,O]=R.useState(0),[L,V]=R.useState(0),[G,z]=R.useState(n),[q,W]=R.useState(700),[D,j]=R.useState(1),[Rt,Et]=R.useState(""),[St,ut]=R.useState(!1),[ht,Ht]=R.useState(""),[ue,et]=R.useState(!1),[J,$t]=R.useState([]),[Zt,ct]=R.useState(0),ns=Math.max(240,Math.round(q*D));Qb({enabled:o&&!!l,pagesRoot:b,routeId:t,paperVersion:l,numPages:L||void 0,resetKey:`${t}-${M}`,onSelect:h,onError:d}),R.useEffect(()=>{Xb()},[]),R.useEffect(()=>{var B;cancelAnimationFrame(S.current),window.clearTimeout(E.current),S.current=0,E.current=0,_.current=0,V(0),z(n),j(1),T.current=1,C.current=1,x.current=1,P.current=!1,(B=b.current)==null||B.style.setProperty("--pdf-live-scale","1"),Et(""),Ht(""),$t([])},[n,t,M]),R.useEffect(()=>{const B=g.current;if(!B)return;const X=()=>{var te;const xt=Math.max(240,B.clientWidth-10);a&&(P.current=!0);const zt=a||P.current;x.current=zt?xt/q:1,(te=b.current)==null||te.style.setProperty("--pdf-live-scale",String(x.current)),zt||W(xt)};X();const bt=new ResizeObserver(X);return bt.observe(B),()=>bt.disconnect()},[q,a]),R.useLayoutEffect(()=>{var X;if(T.current=D,(X=b.current)==null||X.style.setProperty("--pdf-live-scale",String(P.current?x.current:1)),!v.current)return;const B=g.current;B&&(B.scrollLeft=Math.max(0,(B.scrollWidth-B.clientWidth)/2)),v.current=!1},[ns,a,D]);const qe=R.useCallback(B=>{window.clearTimeout(E.current);const X=C.current,bt=B(X);C.current=bt,v.current=bt!==T.current,j(bt)},[]);R.useEffect(()=>{const B=g.current;if(!B)return;const X=bt=>{bt.ctrlKey&&(bt.preventDefault(),_.current+=bt.deltaY,!S.current&&(S.current=requestAnimationFrame(()=>{var te;const xt=_.current;_.current=0,S.current=0;const zt=Math.max(.5,Math.min(3,C.current*Math.exp(-xt*.002)));C.current=zt,(te=b.current)==null||te.style.setProperty("--pdf-live-scale",String(x.current*zt/T.current)),window.clearTimeout(E.current),E.current=window.setTimeout(()=>{v.current=zt!==T.current,j(C.current)},180)})))};return B.addEventListener("wheel",X,{passive:!1}),()=>{B.removeEventListener("wheel",X),cancelAnimationFrame(S.current),window.clearTimeout(E.current),S.current=0,E.current=0,_.current=0}},[]);const lt=R.useCallback(B=>{const X=Math.max(1,Math.min(L||1,B));z(X),u==null||u(X)},[u,L]),vt=R.useCallback(()=>{w.current+=1,ut(!1),Ht(""),$t([]),ct(0),et(!1)},[]);R.useEffect(()=>{const B=g.current;if(!B||!L)return;let X=0;const bt=()=>{cancelAnimationFrame(X),X=requestAnimationFrame(()=>{const xt=B.getBoundingClientRect().top+B.clientHeight/2;let zt=G,te=Number.POSITIVE_INFINITY;B.querySelectorAll("[data-page]").forEach(_i=>{const N=_i.getBoundingClientRect(),st=xt>=N.top&&xt<=N.bottom?0:Math.min(Math.abs(xt-N.top),Math.abs(xt-N.bottom));st{B.removeEventListener("scroll",bt),cancelAnimationFrame(X)}},[G,ns,L,lt]),R.useEffect(()=>{const B=X=>{(X.ctrlKey||X.metaKey)&&X.key.toLowerCase()==="f"?(X.preventDefault(),ut(!0)):X.key==="Escape"&&St&&(X.preventDefault(),vt())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[vt,St]),R.useEffect(()=>{const B=y.current,X=ht.trim().toLocaleLowerCase(),bt=++w.current;if(!B||!X){$t([]),ct(0),et(!1);return}et(!0);const xt=window.setTimeout(()=>void(async()=>{const zt=[];for(let te=1;te<=B.numPages;te+=1){if(w.current!==bt)return;const st=(await(await B.getPage(te)).getTextContent()).items.map(Gt=>"str"in Gt?Gt.str:"").join(" ").toLocaleLowerCase();let Pt=0;for(;(Pt=st.indexOf(X,Pt))>=0;)zt.push(te),Pt+=Math.max(1,X.length)}w.current===bt&&($t(zt),ct(0),et(!1),zt[0]&&Ft(zt[0]))})().catch(()=>{w.current===bt&&et(!1)}),180);return()=>window.clearTimeout(xt)},[ht,L]);const Ft=B=>{var bt,xt;const X=Math.max(1,Math.min(L||1,B));(xt=(bt=g.current)==null?void 0:bt.querySelector(`[data-page="${X}"]`))==null||xt.scrollIntoView({block:"start"}),lt(X)},Dt=B=>{if(!J.length)return;const X=(Zt+B+J.length)%J.length;ct(X),Ft(J[X])},ws=R.useMemo(()=>Array.from({length:L},(B,X)=>X+1),[L]);return k.jsxs("div",{ref:f,className:"pdf-viewer",children:[k.jsx(Jb,{paperTitle:e,paperHref:s,resources:i,page:G,pages:L,zoomPercent:Math.round(D*100),searchOpen:St,searchQuery:ht,searchMatch:Zt,searchCount:J.length,searching:ue,onPage:Ft,onZoomIn:()=>qe(B=>Math.min(3,B+.15)),onZoomOut:()=>qe(B=>Math.max(.5,B-.15)),onToggleSearch:()=>St?vt():ut(!0),onCloseSearch:vt,onSearchQuery:Ht,onSearch:Dt}),k.jsx("div",{ref:g,className:"pdf-scroll",role:"region","aria-label":"Paper PDF",children:Rt?k.jsxs("div",{className:"pdf-error",role:"alert",children:[k.jsx("p",{children:Rt}),k.jsxs("div",{children:[k.jsx("button",{type:"button",onClick:()=>O(B=>B+1),children:"Retry"})," ",k.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",children:"Open original PDF"})]})]}):k.jsx(Db,{file:c,loading:k.jsx("div",{className:"pdf-loading",role:"status",children:"Loading paper…"}),onLoadSuccess:B=>{y.current=B,V(B.numPages),Et("");const X=Math.max(1,Math.min(B.numPages,n));X>1&&requestAnimationFrame(()=>requestAnimationFrame(()=>{var bt,xt;(xt=(bt=g.current)==null?void 0:bt.querySelector(`[data-page="${X}"]`))==null||xt.scrollIntoView({block:"start"}),z(X),u==null||u(X)}))},onLoadError:B=>Et(Zb(B)),externalLinkTarget:"_blank",children:k.jsx("div",{ref:b,className:"pdf-pages",style:{"--pdf-live-scale":x.current},children:ws.map(B=>k.jsx(eA,{page:B,width:ns,searchQuery:ht.trim(),activeSearchPage:J[Zt]},B))})},`${t}-${M}`)})]})}const Mp=66,iA=240,bd="pwc:reader:split-ratio",Rl=c=>`pwc:reader:session:${c}`,qc=c=>`pwc:reader:assistant-collapsed:${c}`,Ip=c=>`pwc:reader:page:${c}`;function Xc(c){const t=Number(sessionStorage.getItem(Ip(c)));return Number.isInteger(t)&&t>0?t:1}function nA(){const c=Number(localStorage.getItem(bd));return Number.isFinite(c)&&c>=45&&c<=75?c:Mp}function rA(c){const t=Yc(c);if(!t)return null;const e=new URL(t);return(e.hostname==="arxiv.org"||e.hostname==="www.arxiv.org")&&e.pathname.startsWith("/pdf/")&&e.pathname.endsWith(".pdf")&&(e.pathname=e.pathname.slice(0,-4)),e.href}function aA(c){return new URL(c).hostname.replace(/^www\./,"")}function oA(c){if(!c)return{};const t={};for(const i of c.repositories??[]){if(!i.is_official)continue;const n=Yc(i.url);if(!n)continue;const a=new URL(n),o=a.pathname.split("/").filter(Boolean);if((a.hostname==="github.com"||a.hostname==="www.github.com")&&o.length>=2){t.repository={href:n,stars:i.num_stars||0};break}}const e=[...c.project_pages??[]].sort((i,n)=>Number(n.is_official)-Number(i.is_official));for(const i of e){const n=Yc(i.url);if(n){t.projectPage={href:n,label:aA(n)};break}}const s=c.hf_artifact_summary?c.hf_artifact_summary.model_count+c.hf_artifact_summary.dataset_count+c.hf_artifact_summary.space_count:new Set([...c.hf_models??[],...c.hf_datasets??[],...c.hf_spaces??[]]).size;return s>0&&c.arxiv_id&&(t.huggingFace={href:`https://huggingface.co/papers/${c.arxiv_id.replace(/v\d+$/i,"")}`,count:s}),t}function lA(){var xt,zt,te,_i;const{arxivId:c}=du(),t=Hp(c??"").replace(/v\d+$/i,""),e=Xp(t,!!t),s=Bp({queryKey:["chatAvailability"],queryFn:()=>Yp.getAvailability(),refetchInterval:3e4,retry:!1}),i=e.data,n=rA(i==null?void 0:i.url_pdf),a=oA(i),o=((xt=i==null?void 0:i.arxiv_id)==null?void 0:xt.replace(/v\d+$/i,""))||t,[l,h]=R.useState(()=>sessionStorage.getItem(Rl(t))||void 0),[d,u]=R.useState(nA),[f,g]=R.useState(()=>sessionStorage.getItem(qc(t))==="1"),[b,y]=R.useState("paper"),[w,v]=R.useState(),[_,S]=R.useState(""),[E,T]=R.useState(()=>Xc(t)),[C,x]=R.useState(0),[P,M]=R.useState(!1),[O,L]=R.useState(!1),V=R.useRef(null),G=R.useRef(null),z=R.useRef(null),q=R.useRef(null),W=R.useRef(!1),D=R.useRef(0),j=R.useRef(0),Rt=R.useRef(0),Et=R.useRef(d),St=R.useRef(Xc(t)),ut=R.useRef(i==null?void 0:i.version),Ht=Vp().reset,ue=R.useRef(`${t}:${l??"new"}`),et=C>=840;R.useEffect(()=>{const N=`${t}:${l??"new"}`;ue.current!==N&&(ue.current=N,Ht())},[l,Ht,t]),R.useEffect(()=>{i!=null&&i.version&&ut.current&&i.version!==ut.current&&(v(void 0),S("")),ut.current=i==null?void 0:i.version},[i==null?void 0:i.version]),R.useEffect(()=>{window.clearTimeout(D.current),L(!1);const N=sessionStorage.getItem(Rl(t));h(N||void 0),g(sessionStorage.getItem(qc(t))==="1"),y("paper"),v(void 0),S("");const st=Xc(t);St.current=st,T(st)},[t]),R.useEffect(()=>()=>{window.clearTimeout(D.current),cancelAnimationFrame(j.current)},[]),R.useLayoutEffect(()=>{const N=V.current;if(!N)return;const st=()=>x(N.clientWidth);st();const Pt=new ResizeObserver(st);return Pt.observe(N),()=>Pt.disconnect()},[i]),R.useEffect(()=>{if(!i)return;document.title=`${i.title} — Papers With Code reader`;let N=document.querySelector('meta[name="robots"]');const st=!N;N||(N=document.createElement("meta"),N.name="robots",document.head.appendChild(N));const Pt=N.content;N.content="noindex, nofollow";let Gt=document.querySelector('link[rel="canonical"]');const br=!Gt;Gt||(Gt=document.createElement("link"),Gt.rel="canonical",document.head.appendChild(Gt));const ka=Gt.href;return Gt.href=`${window.location.origin}/paper/${o}`,()=>{document.title="Papers With Code",st?N==null||N.remove():N&&(N.content=Pt),br?Gt==null||Gt.remove():Gt&&(Gt.href=ka)}},[o,i]);const J=R.useCallback(N=>{if(!C)return Math.max(45,Math.min(75,N));const st=480/C*100,Pt=100-360/C*100;return Math.max(st,Math.min(Pt,N))},[C]);R.useEffect(()=>u(N=>{const st=J(N);return Et.current=st,st}),[J]);const $t=N=>{const st=J(N);Et.current=st,u(st),localStorage.setItem(bd,String(st))},Zt=N=>{var Pt;const st=J(N);Et.current=st,G.current&&(G.current.style.width=`${st}%`),z.current&&(z.current.style.width=`${100-st}%`),(Pt=q.current)==null||Pt.setAttribute("aria-valuenow",String(Math.round(st)))},ct=N=>{Rt.current=N,!j.current&&(j.current=requestAnimationFrame(()=>{var Pt;j.current=0;const st=(Pt=V.current)==null?void 0:Pt.getBoundingClientRect();st!=null&&st.width&&Zt((Rt.current-st.left)/st.width*100)}))},ns=N=>{W.current=!0,M(!0),N.currentTarget.setPointerCapture(N.pointerId),ct(N.clientX)},qe=()=>{var N;if(W.current){if(j.current){cancelAnimationFrame(j.current),j.current=0;const st=(N=V.current)==null?void 0:N.getBoundingClientRect();st!=null&&st.width&&Zt((Rt.current-st.left)/st.width*100)}W.current=!1,u(Et.current),localStorage.setItem(bd,String(Et.current)),M(!1)}},lt=N=>{window.clearTimeout(D.current),L(!0),g(N),sessionStorage.setItem(qc(t),N?"1":"0"),D.current=window.setTimeout(()=>L(!1),iA+40)},vt=N=>{h(N),sessionStorage.setItem(Rl(t),N)},Ft=()=>{h(void 0),sessionStorage.removeItem(Rl(t)),v(void 0),S("")},Dt=((zt=s.data)==null?void 0:zt.paper_reader_selection_enabled)===!0,ws=N=>{v(N),S(`Selection from page ${N.page} added to chat`),et&&f&<(!1)},B=R.useCallback(N=>{v(N),N||S("")},[]),X=jp()&&((te=s.data)==null?void 0:te.paper_reader_chat_enabled)!==!1,bt=i&&X?k.jsx(Kp,{mode:"paper",routeSessionId:l,primaryPaper:{id:i.id,routeId:o,title:i.title},currentPage:()=>St.current,paperSelection:w,onPaperSelectionChange:B,onSessionId:vt,onReaderSubmit:()=>y("assistant"),onReaderNewChat:Ft}):k.jsx("div",{className:"reader-chat-unavailable",children:"Chat is not enabled for this preview."});return e.isLoading?k.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):e.error||!i?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Paper not found."}),k.jsx(Qa,{to:"/papers",children:"Browse papers"})]}):((_i=s.data)==null?void 0:_i.native_pdf_reader_enabled)===!1?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"The native reader is currently unavailable."}),k.jsx(Qa,{to:`/paper/${o}`,children:"Back to paper"})]}):i.source!=="arxiv"||!n?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Native reading is unavailable for this resource."}),k.jsx(Qa,{to:`/paper/${o}`,children:"Back to paper"})]}):k.jsxs("div",{className:"paper-reader-shell",children:[!et&&k.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[k.jsx("button",{type:"button",role:"tab","aria-selected":b==="paper",onClick:()=>y("paper"),children:"Paper"}),k.jsxs("button",{type:"button",role:"tab","aria-selected":b==="assistant","aria-label":w&&b!=="assistant"?"Chat, selection attached":"Chat",onClick:()=>y("assistant"),children:["Chat",w&&b!=="assistant"&&k.jsx("span",{className:"reader-tab-pending","aria-hidden":"true"})]})]}),k.jsx(qp,{variant:"reader",children:k.jsxs("div",{ref:V,className:`reader-workspace${et?" is-desktop":" is-tabs"}${f?" is-assistant-collapsed":""}${P?" is-resizing":""}`,"data-testid":"paper-chat-workspace",children:[k.jsx("section",{ref:G,className:`reader-paper-pane${!et&&b!=="paper"?" is-hidden":""}`,style:et?{width:f?"100%":`${d}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!et&&b!=="paper",children:k.jsx(sA,{url:n,paperKey:o,paperTitle:i.title,paperHref:`/paper/${o}`,resources:a,initialPage:E,resizeActive:P||O,selectionEnabled:Dt,paperVersion:i.version,onPaperSelection:ws,onPaperSelectionError:S,onPageChange:N=>{St.current=N,sessionStorage.setItem(Ip(t),String(N))}})}),et&&!f&&k.jsx("div",{ref:q,className:"reader-resize-handle",role:"separator","aria-label":"Resize paper and Chat panels","aria-orientation":"vertical","aria-valuemin":45,"aria-valuemax":75,"aria-valuenow":Math.round(d),tabIndex:0,onPointerDown:ns,onPointerMove:N=>{W.current&&ct(N.clientX)},onPointerUp:qe,onPointerCancel:qe,onLostPointerCapture:qe,onDoubleClick:()=>$t(Mp),onKeyDown:N=>{(N.key==="ArrowLeft"||N.key==="ArrowRight")&&(N.preventDefault(),$t(d+(N.key==="ArrowRight"?2:-2))),N.key==="Home"&&$t(45),N.key==="End"&&$t(75)}}),k.jsx("aside",{ref:z,id:"reader-chat-panel",className:`reader-assistant-pane${!et&&b!=="assistant"?" is-hidden":""}${et&&f?" is-collapsed":""}`,style:et?{width:f?0:`${100-d}%`}:void 0,role:"tabpanel","aria-label":"Chat","aria-hidden":!et&&b!=="assistant"||f,children:bt}),k.jsx("div",{className:"sr-only","aria-live":"polite",children:_}),et&&k.jsx("button",{type:"button",className:"reader-collapse-assistant","aria-controls":"reader-chat-panel","aria-expanded":!f,onClick:()=>lt(!f),children:f?"Open chat":"Hide chat"})]})})]})}function IA(){const{arxivId:c=""}=du();return k.jsx(Wp,{workspaceKey:`reader:${c}`,children:k.jsx(lA,{})})}export{IA as default,rA as directArxivPdfHref,oA as readerToolbarResources};