diff --git "a/assets/PaperReaderView-DPwmVUpH.js" "b/assets/PaperReaderView-DPwmVUpH.js" new file mode 100644--- /dev/null +++ "b/assets/PaperReaderView-DPwmVUpH.js" @@ -0,0 +1,12 @@ +var Ip=Object.defineProperty;var Md=h=>{throw TypeError(h)};var Fp=(h,t,e)=>t in h?Ip(h,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):h[t]=e;var K=(h,t,e)=>Fp(h,typeof t!="symbol"?t+"":t,e),jh=(h,t,e)=>t.has(h)||Md("Cannot "+e);var r=(h,t,e)=>(jh(h,t,"read from private field"),e?e.call(h):t.get(h)),b=(h,t,e)=>t.has(h)?Md("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(h):t.set(h,e),p=(h,t,e,s)=>(jh(h,t,"write to private field"),s?s.call(h,e):t.set(h,e),e),m=(h,t,e)=>(jh(h,t,"access private method"),e);var fe=(h,t,e,s)=>({set _(i){p(h,t,i,e)},get _(){return r(h,t,s)}});import{_ as yl,N as Dp,r as R,j as k,O as xh,L as Cl,X as Op,c as Np,n as Hp,u as jp,Q as Bp}from"./index-M9q--a7F.js";import{u as $p}from"./useQuery-D0d1gRNy.js";import{G as zp}from"./github-BpuYyVUf.js";import{E as Gp}from"./external-link-Dkt_S7Wo.js";import{a as Up}from"./usePapers-Dc-ANOWv.js";import{c as Wp}from"./chat-B6rQneG5.js";import{s as Xh}from"./safeExternalHref-CkBrsh84.js";import{ChatExperience as Vp}from"./ChatView-DG8X6lu5.js";import"./useInfiniteQuery-DOdtCB-k.js";import"./papers-euMnHik1.js";import"./ChatMessage-DKhbZFxH.js";import"./chatSessions-DZeB8mv0.js";import"./chevron-down-B_46egqq.js";import"./katex.min-BSBacQyE.js";import"./hover-card-CWR5bsak.js";import"./github-BIcC_jAZ.js";import"./PaperPreviewLink-D5mRgYz5.js";import"./index-mMN8jnWF.js";import"./file-text-BsJUN2HC.js";import"./chatPrompts-CDY3UGU1.js";import"./openrouter-aicG2TIp.js";var Va={};Va.d=(h,t)=>{for(var e in t)Va.o(t,e)&&!Va.o(h,e)&&Object.defineProperty(h,e,{enumerable:!0,get:t[e]})};Va.o=(h,t)=>Object.prototype.hasOwnProperty.call(h,t);var J=globalThis.pdfjsLib={};Va.d(J,{AbortException:()=>hr,AnnotationEditorLayer:()=>ad,AnnotationEditorParamsType:()=>Q,AnnotationEditorType:()=>tt,AnnotationEditorUIManager:()=>ir,AnnotationLayer:()=>Um,AnnotationMode:()=>Ai,ColorPicker:()=>ah,DOMSVGFactory:()=>Td,DrawLayer:()=>cd,FeatureTest:()=>be,GlobalWorkerOptions:()=>hi,ImageKind:()=>Tl,InvalidPDFException:()=>cu,MissingPDFException:()=>lr,OPS:()=>Je,OutputScale:()=>Zh,PDFDataRangeTransport:()=>of,PDFDateString:()=>vd,PDFWorker:()=>Er,PasswordResponses:()=>Kp,PermissionFlag:()=>Yp,PixelsPerInch:()=>Vi,RenderingCancelledException:()=>Ad,TextLayer:()=>Tc,UnexpectedResponseException:()=>Ph,Util:()=>$,VerbosityLevel:()=>Ch,XfaLayer:()=>hf,build:()=>Sm,createValidAbsoluteUrl:()=>tg,fetchData:()=>Lh,getDocument:()=>gm,getFilenameFromUrl:()=>hg,getPdfFilenameFromUrl:()=>cg,getXfaPageViewport:()=>dg,isDataScheme:()=>Mh,isPdfFile:()=>yd,noContextMenu:()=>Ke,normalizeUnicode:()=>ag,setLayerDimensions:()=>sr,shadow:()=>ot,version:()=>Em});const ue=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),hu=[1,0,0,1,0,0],Yh=[.001,0,0,.001,0,0],qp=1e7,Bh=1.35,Ne={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Ai={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Xp="pdfjs_internal_editor_",tt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Q={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},Yp={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},re={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},Tl={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Bt={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},Ca={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},Ch={ERRORS:0,WARNINGS:1,INFOS:5},Je={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},Kp={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Th=Ch.WARNINGS;function Qp(h){Number.isInteger(h)&&(Th=h)}function Jp(){return Th}function Rh(h){Th>=Ch.INFOS&&console.log(`Info: ${h}`)}function st(h){Th>=Ch.WARNINGS&&console.log(`Warning: ${h}`)}function _t(h){throw new Error(h)}function Ut(h,t){h||_t(t)}function Zp(h){switch(h==null?void 0:h.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function tg(h,t=null,e=null){if(!h)return null;try{if(e&&typeof h=="string"){if(e.addDefaultProtocol&&h.startsWith("www.")){const i=h.match(/\./g);(i==null?void 0:i.length)>=2&&(h=`http://${h}`)}if(e.tryConvertEncoding)try{h=rg(h)}catch{}}const s=t?new URL(h,t):new URL(h);if(Zp(s))return s}catch{}return null}function ot(h,t,e,s=!1){return Object.defineProperty(h,t,{value:e,enumerable:!s,configurable:!0,writable:!1}),e}const Ki=function(){function t(e,s){this.message=e,this.name=s}return t.prototype=new Error,t.constructor=t,t}();class Kh extends Ki{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Qh extends Ki{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class cu extends Ki{constructor(t){super(t,"InvalidPDFException")}}class lr extends Ki{constructor(t){super(t,"MissingPDFException")}}class Ph extends Ki{constructor(t,e){super(t,"UnexpectedResponseException"),this.status=e}}class eg extends Ki{constructor(t){super(t,"FormatError")}}class hr extends Ki{constructor(t){super(t,"AbortException")}}function du(h){(typeof h!="object"||(h==null?void 0:h.length)===void 0)&&_t("Invalid argument for bytesToString");const t=h.length,e=8192;if(t>24&255,h>>16&255,h>>8&255,h&255)}function md(h){const t=Object.create(null);for(const[e,s]of h)t[e]=s;return t}function ig(){const h=new Uint8Array(4);return h[0]=1,new Uint32Array(h.buffer,0,1)[0]===1}function ng(){try{return new Function(""),!0}catch{return!1}}class be{static get isLittleEndian(){return ot(this,"isLittleEndian",ig())}static get isEvalSupported(){return ot(this,"isEvalSupported",ng())}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 $h=Array.from(Array(256).keys(),h=>h.toString(16).padStart(2,"0"));var di,Rl,Jh;class ${static makeHexColor(t,e,s){return`#${$h[t]}${$h[e]}${$h[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,c=o+l||1,d=o-l||1;return[Math.sqrt(c),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,c){return c?(c[0]=Math.min(c[0],t,o),c[1]=Math.min(c[1],e,l),c[2]=Math.max(c[2],t,o),c[3]=Math.max(c[3],e,l)):c=[Math.min(t,o),Math.min(e,l),Math.max(t,o),Math.max(e,l)],m(this,di,Jh).call(this,t,s,n,o,e,i,a,l,3*(-t+3*(s-n)+o),6*(t-2*s+n),3*(s-t),c),m(this,di,Jh).call(this,t,s,n,o,e,i,a,l,3*(-e+3*(i-a)+l),6*(e-2*i+a),3*(i-e),c),c}}di=new WeakSet,Rl=function(t,e,s,i,n,a,o,l,c,d){if(c<=0||c>=1)return;const u=1-c,f=c*c,g=f*c,A=u*(u*(u*t+3*c*e)+3*f*s)+g*i,y=u*(u*(u*n+3*c*a)+3*f*o)+g*l;d[0]=Math.min(d[0],A),d[1]=Math.min(d[1],y),d[2]=Math.max(d[2],A),d[3]=Math.max(d[3],y)},Jh=function(t,e,s,i,n,a,o,l,c,d,u,f){if(Math.abs(c)<1e-12){Math.abs(d)>=1e-12&&m(this,di,Rl).call(this,t,e,s,i,n,a,o,l,-u/d,f);return}const g=d**2-4*u*c;if(g<0)return;const A=Math.sqrt(g),y=2*c;m(this,di,Rl).call(this,t,e,s,i,n,a,o,l,(-d+A)/y,f),m(this,di,Rl).call(this,t,e,s,i,n,a,o,l,(-d-A)/y,f)},b($,di);function rg(h){return decodeURIComponent(escape(h))}let zh=null,Id=null;function ag(h){return zh||(zh=/([\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,Id=new Map([["ſt","ſt"]])),h.replaceAll(zh,(t,e,s)=>e?e.normalize("NFKC"):Id.get(s))}function og(){if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.randomUUID)=="function")return crypto.randomUUID();const h=new Uint8Array(32);if(typeof crypto<"u"&&typeof(crypto==null?void 0:crypto.getRandomValues)=="function")crypto.getRandomValues(h);else for(let t=0;t<32;t++)h[t]=Math.floor(Math.random()*255);return du(h)}const bd="pdfjs_internal_id_",Fs={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 lg(h){return Uint8Array.prototype.toBase64?h.toBase64():btoa(du(h))}const Os="http://www.w3.org/2000/svg",nn=class nn{};K(nn,"CSS",96),K(nn,"PDF",72),K(nn,"PDF_TO_CSS_UNITS",nn.CSS/nn.PDF);let Vi=nn;async function Lh(h,t="text"){if(ka(h,document.baseURI)){const e=await fetch(h);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",h,!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 ul{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 c,d,u,f;switch(s%=360,s<0&&(s+=360),s){case 180:c=-1,d=0,u=0,f=1;break;case 90:c=0,d=1,u=1,f=0;break;case 270:c=0,d=-1,u=-1,f=0;break;case 0:c=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,A,y,w;c===0?(g=Math.abs(l-t[1])*e+i,A=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,A=Math.abs(l-t[1])*e+n,y=(t[2]-t[0])*e,w=(t[3]-t[1])*e),this.transform=[c*e,d*e,u*e,f*e,g-c*e*o-u*e*l,A-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 ul({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 Ad extends Ki{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function Mh(h){const t=h.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 c=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,c==="-"?(a+=d,o+=u):c==="+"&&(a-=d,o-=u),new Date(Date.UTC(s,i,n,a,o,l))}}Ka=new WeakMap,b(vd,Ka);function dg(h,{scale:t=1,rotation:e=0}){const{width:s,height:i}=h.attributes.style,n=[0,0,parseInt(s),parseInt(i)];return new ul({viewBox:n,scale:t,rotation:e})}function wd(h){if(h.startsWith("#")){const t=parseInt(h.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return h.startsWith("rgb(")?h.slice(4,-1).split(",").map(t=>parseInt(t)):h.startsWith("rgba(")?h.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(st(`Not a valid color format: "${h}"`),[0,0,0])}function ug(h){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const e of h.keys()){t.style.color=e;const s=window.getComputedStyle(t).color;h.set(e,wd(s))}t.remove()}function Pt(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform();return[t,e,s,i,n,a]}function Ds(h){const{a:t,b:e,c:s,d:i,e:n,f:a}=h.getTransform().invertSelf();return[t,e,s,i,n,a]}function sr(h,t,e=!1,s=!0){if(t instanceof ul){const{pageWidth:i,pageHeight:n}=t.rawDims,{style:a}=h,o=be.isCSSRoundSupported,l=`var(--scale-factor) * ${i}px`,c=`var(--scale-factor) * ${n}px`,d=o?`round(down, ${l}, var(--scale-round-x, 1px))`:`calc(${l})`,u=o?`round(down, ${c}, var(--scale-round-y, 1px))`:`calc(${c})`;!e||t.rotation%180===0?(a.width=d,a.height=u):(a.width=u,a.height=d)}s&&h.setAttribute("data-main-rotation",t.rotation)}class Zh{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 yi,an,Ze,on,Qa,Ja,lh,uu,Ae,fu,pu,Pl,gu,ec;const Ns=class Ns{constructor(t){b(this,Ae);b(this,yi,null);b(this,an,null);b(this,Ze);b(this,on,null);b(this,Qa,null);p(this,Ze,t),r(Ns,Ja)||p(Ns,Ja,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,yi,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=r(this,Ze)._uiManager._signal;t.addEventListener("contextmenu",Ke,{signal:e}),t.addEventListener("pointerdown",m(Ns,lh,uu),{signal:e});const s=p(this,on,document.createElement("div"));s.className="buttons",t.append(s);const i=r(this,Ze).toolbarPosition;if(i){const{style:n}=t,a=r(this,Ze)._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,Ae,gu).call(this),t}get div(){return r(this,yi)}hide(){var t;r(this,yi).classList.add("hidden"),(t=r(this,an))==null||t.hideDropdown()}show(){var t;r(this,yi).classList.remove("hidden"),(t=r(this,Qa))==null||t.shown()}async addAltText(t){const e=await t.render();m(this,Ae,Pl).call(this,e),r(this,on).prepend(e,r(this,Ae,ec)),p(this,Qa,t)}addColorPicker(t){p(this,an,t);const e=t.renderButton();m(this,Ae,Pl).call(this,e),r(this,on).prepend(e,r(this,Ae,ec))}remove(){var t;r(this,yi).remove(),(t=r(this,an))==null||t.destroy(),p(this,an,null)}};yi=new WeakMap,an=new WeakMap,Ze=new WeakMap,on=new WeakMap,Qa=new WeakMap,Ja=new WeakMap,lh=new WeakSet,uu=function(t){t.stopPropagation()},Ae=new WeakSet,fu=function(t){r(this,Ze)._focusEventsAllowed=!1,t.preventDefault(),t.stopPropagation()},pu=function(t){r(this,Ze)._focusEventsAllowed=!0,t.preventDefault(),t.stopPropagation()},Pl=function(t){const e=r(this,Ze)._uiManager._signal;t.addEventListener("focusin",m(this,Ae,fu).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",m(this,Ae,pu).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Ke,{signal:e})},gu=function(){const{editorType:t,_uiManager:e}=r(this,Ze),s=document.createElement("button");s.className="delete",s.tabIndex=0,s.setAttribute("data-l10n-id",r(Ns,Ja)[t]),m(this,Ae,Pl).call(this,s),s.addEventListener("click",i=>{e.delete()},{signal:e._signal}),r(this,on).append(s)},ec=function(){const t=document.createElement("div");return t.className="divider",t},b(Ns,lh),b(Ns,Ja,null);let tc=Ns;var Za,ln,hn,Xi,mu,bu,Au;class fg{constructor(t){b(this,Xi);b(this,Za,null);b(this,ln,null);b(this,hn);p(this,hn,t)}show(t,e,s){const[i,n]=m(this,Xi,bu).call(this,e,s),{style:a}=r(this,ln)||p(this,ln,m(this,Xi,mu).call(this));t.append(r(this,ln)),a.insetInlineEnd=`${100*i}%`,a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){r(this,ln).remove()}}Za=new WeakMap,ln=new WeakMap,hn=new WeakMap,Xi=new WeakSet,mu=function(){const t=p(this,ln,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Ke,{signal:r(this,hn)._signal});const e=p(this,Za,document.createElement("div"));return e.className="buttons",t.append(e),m(this,Xi,Au).call(this),t},bu=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,hn).highlightSelection("floating_button")},{signal:s}),r(this,Za).append(t)};function ih(h,t,e){for(const s of e)t.addEventListener(s,h[s].bind(h))}function pg(h){return Math.round(Math.min(255,Math.max(1,255*h))).toString(16).padStart(2,"0")}var hh;class gg{constructor(){b(this,hh,0)}get id(){return`${Xp}${fe(this,hh)._++}`}}hh=new WeakMap;var Cr,to,oe,Tr,kl;const Pd=class Pd{constructor(){b(this,Tr);b(this,Cr,og());b(this,to,0);b(this,oe,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,Tr,kl).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return m(this,Tr,kl).call(this,t,t)}async getFromBlob(t,e){const s=await e;return m(this,Tr,kl).call(this,t,s)}async getFromId(t){r(this,oe)||p(this,oe,new Map);const e=r(this,oe).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,oe)||p(this,oe,new Map);let s=r(this,oe).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,Cr)}_${fe(this,to)._++}`,refCounter:1,isSvg:!1},r(this,oe).set(t,s),r(this,oe).set(s.id,s),s}getSvgUrl(t){const e=r(this,oe).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var i;r(this,oe)||p(this,oe,new Map);const e=r(this,oe).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,Cr)}_`)}};Cr=new WeakMap,to=new WeakMap,oe=new WeakMap,Tr=new WeakSet,kl=async function(t,e){r(this,oe)||p(this,oe,new Map);let s=r(this,oe).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,Cr)}_${fe(this,to)._++}`,refCounter:0,isSvg:!1});let i;if(typeof e=="string"?(s.url=e,i=await Lh(e,"blob")):e instanceof File?i=s.file=e:e instanceof Blob&&(i=e),i.type==="image/svg+xml"){const n=Pd._isSVGFittingCanvas,a=new FileReader,o=new Image,l=new Promise((c,d)=>{o.onload=()=>{s.bitmap=o,s.isSvg=!0,c()},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,oe).set(t,s),s&&r(this,oe).set(s.id,s),s};let sc=Pd;var Xt,vi,eo,Yt;class mg{constructor(t=128){b(this,Xt,[]);b(this,vi,!1);b(this,eo);b(this,Yt,-1);p(this,eo,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:o=!1}){if(i&&t(),r(this,vi))return;const l={cmd:t,undo:e,post:s,type:n};if(r(this,Yt)===-1){r(this,Xt).length>0&&(r(this,Xt).length=0),p(this,Yt,0),r(this,Xt).push(l);return}if(a&&r(this,Xt)[r(this,Yt)].type===n){o&&(l.undo=r(this,Xt)[r(this,Yt)].undo),r(this,Xt)[r(this,Yt)]=l;return}const c=r(this,Yt)+1;c===r(this,eo)?r(this,Xt).splice(0,1):(p(this,Yt,c),cn===e[a]))return dh._colorsMapping.get(s);return e}getHexCode(t){const e=this._colors.get(t);return e?$.makeHexColor(...e):t}};K(dh,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let ic=dh;var Rr,Pe,$t,te,Pr,js,kr,ts,wi,Lr,cn,gs,es,dn,so,io,Mr,no,ms,_i,Ir,Ei,bs,uh,Si,ro,xi,un,ao,oo,Kt,ft,Bs,fn,lo,ho,Ci,As,$s,co,ze,I,Ll,nc,vu,wu,Ml,_u,Eu,Su,rc,xu,ac,oc,Cu,pe,mi,Tu,Ru,lc,Pu,La,hc;const wr=class wr{constructor(t,e,s,i,n,a,o,l,c,d,u){b(this,I);b(this,Rr,new AbortController);b(this,Pe,null);b(this,$t,new Map);b(this,te,new Map);b(this,Pr,null);b(this,js,null);b(this,kr,null);b(this,ts,new mg);b(this,wi,null);b(this,Lr,0);b(this,cn,new Set);b(this,gs,null);b(this,es,null);b(this,dn,new Set);b(this,so,!1);b(this,io,!1);b(this,Mr,!1);b(this,no,null);b(this,ms,null);b(this,_i,null);b(this,Ir,null);b(this,Ei,!1);b(this,bs,null);b(this,uh,new gg);b(this,Si,!1);b(this,ro,!1);b(this,xi,null);b(this,un,null);b(this,ao,null);b(this,oo,null);b(this,Kt,tt.NONE);b(this,ft,new Set);b(this,Bs,null);b(this,fn,null);b(this,lo,null);b(this,ho,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});b(this,Ci,[0,0]);b(this,As,null);b(this,$s,null);b(this,co,null);b(this,ze,null);const f=this._signal=r(this,Rr).signal;p(this,$s,t),p(this,co,e),p(this,Pr,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,I,_u).call(this),m(this,I,Cu).call(this),m(this,I,rc).call(this),p(this,js,n.annotationStorage),p(this,no,n.filterFactory),p(this,fn,a),p(this,Ir,o||null),p(this,so,l),p(this,io,c),p(this,Mr,d),p(this,oo,u||null),this.viewParameters={realScale:Vi.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}static get _keyboardManager(){const t=wr.prototype,e=a=>r(a,$s).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 fl([[["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,$s).contains(o)&&!a.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(a,{target:o})=>!(o instanceof HTMLButtonElement)&&r(a,$s).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,ze))==null||t.resolve(),p(this,ze,null),(e=r(this,Rr))==null||e.abort(),p(this,Rr,null),this._signal=null;for(const n of r(this,te).values())n.destroy();r(this,te).clear(),r(this,$t).clear(),r(this,dn).clear(),p(this,Pe,null),r(this,ft).clear(),r(this,ts).destroy(),(s=r(this,Pr))==null||s.destroy(),(i=r(this,bs))==null||i.hide(),p(this,bs,null),r(this,ms)&&(clearTimeout(r(this,ms)),p(this,ms,null)),r(this,As)&&(clearTimeout(r(this,As)),p(this,As,null))}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return r(this,oo)}get useNewAltTextFlow(){return r(this,io)}get useNewAltTextWhenAddingImage(){return r(this,Mr)}get hcmFilter(){return ot(this,"hcmFilter",r(this,fn)?r(this,no).addHCMFilter(r(this,fn).foreground,r(this,fn).background):"none")}get direction(){return ot(this,"direction",getComputedStyle(r(this,$s)).direction)}get highlightColors(){return ot(this,"highlightColors",r(this,Ir)?new Map(r(this,Ir).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,ao,t)}editAltText(t,e=!1){var s;(s=r(this,Pr))==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,Mr,e);break}}onPageChanging({pageNumber:t}){p(this,Lr,t-1)}focusMainContainer(){r(this,$s).focus()}findParent(t,e){for(const s of r(this,te).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,co).classList.toggle("noUserSelect",t)}addShouldRescale(t){r(this,dn).add(t)}removeShouldRescale(t){r(this,dn).delete(t)}onScaleChanging({scale:t}){this.commitOrRemove(),this.viewParameters.realScale=t*Vi.PDF_TO_CSS_UNITS;for(const e of r(this,dn))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(),c=m(this,I,Ll).call(this,e).closest(".textLayer"),d=this.getSelectionBoxes(c);if(!d)return;e.empty();const u=m(this,I,nc).call(this,c),f=r(this,Kt)===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,js)&&!r(this,js).has(t.id)&&r(this,js).setValue(t.id,t)}blur(){if(this.isShiftKeyDown=!1,r(this,Ei)&&(p(this,Ei,!1),m(this,I,Ml).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of r(this,ft))if(e.div.contains(t)){p(this,un,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!r(this,un))return;const[t,e]=r(this,un);p(this,un,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){m(this,I,rc).call(this),m(this,I,ac).call(this)}removeEditListeners(){m(this,I,xu).call(this),m(this,I,oc).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of r(this,es))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,es))if(s.isHandlingMimeForPasting(e.type)){s.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var s;if(t.preventDefault(),(s=r(this,Pe))==null||s.commitOrRemove(),!this.hasSelection)return;const e=[];for(const i of r(this,ft)){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,es))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){st(`paste: "${n.message}".`);return}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const n=[];for(const l of s){const c=await i.deserialize(l);if(!c)return;n.push(c)}const a=()=>{for(const l of n)m(this,I,lc).call(this,l);m(this,I,hc).call(this,n)},o=()=>{for(const l of n)l.remove()};this.addCommands({cmd:a,undo:o,mustExec:!0})}catch(n){st(`paste: "${n.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),r(this,Kt)!==tt.NONE&&!this.isEditorHandlingKeyboard&&wr._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,r(this,Ei)&&(p(this,Ei,!1),m(this,I,Ml).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,I,Eu).call(this),m(this,I,ac).call(this),m(this,I,pe).call(this,{isEditing:r(this,Kt)!==tt.NONE,isEmpty:m(this,I,La).call(this),hasSomethingToUndo:r(this,ts).hasSomethingToUndo(),hasSomethingToRedo:r(this,ts).hasSomethingToRedo(),hasSelectedEditor:!1})):(m(this,I,Su).call(this),m(this,I,oc).call(this),m(this,I,pe).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!r(this,es)){p(this,es,t);for(const e of r(this,es))m(this,I,mi).call(this,e.defaultPropertiesToUpdate)}}getId(){return r(this,uh).id}get currentLayer(){return r(this,te).get(r(this,Lr))}getLayer(t){return r(this,te).get(t)}get currentPageIndex(){return r(this,Lr)}addLayer(t){r(this,te).set(t.pageIndex,t),r(this,Si)?t.enable():t.disable()}removeLayer(t){r(this,te).delete(t.pageIndex)}async updateMode(t,e=null,s=!1){if(r(this,Kt)!==t&&!(r(this,ze)&&(await r(this,ze).promise,!r(this,ze)))){if(p(this,ze,Promise.withResolvers()),p(this,Kt,t),t===tt.NONE){this.setEditingState(!1),m(this,I,Ru).call(this),r(this,ze).resolve();return}this.setEditingState(!0),await m(this,I,Tu).call(this),this.unselectAll();for(const i of r(this,te).values())i.updateMode(t);if(!e){s&&this.addNewEditorFromKeyboard(),r(this,ze).resolve();return}for(const i of r(this,$t).values())i.annotationElementId===e?(this.setSelected(i),i.enterInEditMode()):i.unselect();r(this,ze).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t!==r(this,Kt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:t})}updateParams(t,e){var s;if(r(this,es)){switch(t){case Q.CREATE:this.currentLayer.addNewEditor();return;case Q.HIGHLIGHT_DEFAULT_COLOR:(s=r(this,ao))==null||s.updateColor(e);break;case Q.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(r(this,lo)||p(this,lo,new Map)).set(t,e),this.showAllEditors("highlight",e);break}for(const i of r(this,ft))i.updateParams(t,e);for(const i of r(this,es))i.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var n;for(const a of r(this,$t).values())a.editorType===t&&a.show(e);(((n=r(this,lo))==null?void 0:n.get(Q.HIGHLIGHT_SHOW_ALL))??!0)!==e&&m(this,I,mi).call(this,[[Q.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(r(this,ro)!==t){p(this,ro,t);for(const e of r(this,te).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of r(this,$t).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return r(this,$t).get(t)}addEditor(t){r(this,$t).set(t.id,t)}removeEditor(t){var e;t.div.contains(document.activeElement)&&(r(this,ms)&&clearTimeout(r(this,ms)),p(this,ms,setTimeout(()=>{this.focusMainContainer(),p(this,ms,null)},0))),r(this,$t).delete(t.id),this.unselect(t),(!t.annotationElementId||!r(this,cn).has(t.annotationElementId))&&((e=r(this,js))==null||e.remove(t.id))}addDeletedAnnotationElement(t){r(this,cn).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return r(this,cn).has(t)}removeDeletedAnnotationElement(t){r(this,cn).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){r(this,Pe)!==t&&(p(this,Pe,t),t&&m(this,I,mi).call(this,t.propertiesToUpdate))}updateUI(t){r(this,I,Pu)===t&&m(this,I,mi).call(this,t.propertiesToUpdate)}toggleSelected(t){if(r(this,ft).has(t)){r(this,ft).delete(t),t.unselect(),m(this,I,pe).call(this,{hasSelectedEditor:this.hasSelection});return}r(this,ft).add(t),t.select(),m(this,I,mi).call(this,t.propertiesToUpdate),m(this,I,pe).call(this,{hasSelectedEditor:!0})}setSelected(t){for(const e of r(this,ft))e!==t&&e.unselect();r(this,ft).clear(),r(this,ft).add(t),t.select(),m(this,I,mi).call(this,t.propertiesToUpdate),m(this,I,pe).call(this,{hasSelectedEditor:!0})}isSelected(t){return r(this,ft).has(t)}get firstSelectedEditor(){return r(this,ft).values().next().value}unselect(t){t.unselect(),r(this,ft).delete(t),m(this,I,pe).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return r(this,ft).size!==0}get isEnterHandled(){return r(this,ft).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){r(this,ts).undo(),m(this,I,pe).call(this,{hasSomethingToUndo:r(this,ts).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:m(this,I,La).call(this)})}redo(){r(this,ts).redo(),m(this,I,pe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:r(this,ts).hasSomethingToRedo(),isEmpty:m(this,I,La).call(this)})}addCommands(t){r(this,ts).add(t),m(this,I,pe).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:m(this,I,La).call(this)})}delete(){if(this.commitOrRemove(),!this.hasSelection)return;const t=[...r(this,ft)],e=()=>{for(const i of t)i.remove()},s=()=>{for(const i of t)m(this,I,lc).call(this,i)};this.addCommands({cmd:e,undo:s,mustExec:!0})}commitOrRemove(){var t;(t=r(this,Pe))==null||t.commitOrRemove()}hasSomethingToControl(){return r(this,Pe)||this.hasSelection}selectAll(){for(const t of r(this,ft))t.commit();m(this,I,hc).call(this,r(this,$t).values())}unselectAll(){if(!(r(this,Pe)&&(r(this,Pe).commitOrRemove(),r(this,Kt)!==tt.NONE))&&this.hasSelection){for(const t of r(this,ft))t.unselect();r(this,ft).clear(),m(this,I,pe).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;r(this,Ci)[0]+=t,r(this,Ci)[1]+=e;const[i,n]=r(this,Ci),a=[...r(this,ft)],o=1e3;r(this,As)&&clearTimeout(r(this,As)),p(this,As,setTimeout(()=>{p(this,As,null),r(this,Ci)[0]=r(this,Ci)[1]=0,this.addCommands({cmd:()=>{for(const l of a)r(this,$t).has(l.id)&&l.translateInPage(i,n)},undo:()=>{for(const l of a)r(this,$t).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,gs,new Map);for(const t of r(this,ft))r(this,gs).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!r(this,gs))return!1;this.disableUserSelect(!1);const t=r(this,gs);p(this,gs,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,$t).has(i.id)){const l=r(this,te).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,gs))for(const s of r(this,gs).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,ft).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return r(this,Pe)===t}getActive(){return r(this,Pe)}getMode(){return r(this,Kt)}get imageManager(){return ot(this,"imageManager",new sc)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let c=0,d=e.rangeCount;c({x:(d-i)/a,y:1-(c+u-s)/n,width:f/a,height:u/n});break;case"180":o=(c,d,u,f)=>({x:1-(c+u-s)/n,y:1-(d+f-i)/a,width:u/n,height:f/a});break;case"270":o=(c,d,u,f)=>({x:1-(d+f-i)/a,y:(c-s)/n,width:f/a,height:u/n});break;default:o=(c,d,u,f)=>({x:(c-s)/n,y:(d-i)/a,width:u/n,height:f/a});break}const l=[];for(let c=0,d=e.rangeCount;c{f.type==="pointerup"&&f.button!==0||(c.abort(),l==null||l.toggleDrawing(!0),f.type==="pointerup"&&m(this,I,Ml).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}},Ml=function(t=""){r(this,Kt)===tt.HIGHLIGHT?this.highlightSelection(t):r(this,so)&&m(this,I,vu).call(this)},_u=function(){document.addEventListener("selectionchange",m(this,I,wu).bind(this),{signal:this._signal})},Eu=function(){if(r(this,_i))return;p(this,_i,new AbortController);const t=this.combinedSignal(r(this,_i));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Su=function(){var t;(t=r(this,_i))==null||t.abort(),p(this,_i,null)},rc=function(){if(r(this,xi))return;p(this,xi,new AbortController);const t=this.combinedSignal(r(this,xi));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},xu=function(){var t;(t=r(this,xi))==null||t.abort(),p(this,xi,null)},ac=function(){if(r(this,wi))return;p(this,wi,new AbortController);const t=this.combinedSignal(r(this,wi));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})},oc=function(){var t;(t=r(this,wi))==null||t.abort(),p(this,wi,null)},Cu=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},pe=function(t){Object.entries(t).some(([s,i])=>r(this,ho)[s]!==i)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(r(this,ho),t)}),r(this,Kt)===tt.HIGHLIGHT&&t.hasSelectedEditor===!1&&m(this,I,mi).call(this,[[Q.HIGHLIGHT_FREE,!0]]))},mi=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Tu=async function(){if(!r(this,Si)){p(this,Si,!0);const t=[];for(const e of r(this,te).values())t.push(e.enable());await Promise.all(t);for(const e of r(this,$t).values())e.enable()}},Ru=function(){if(this.unselectAll(),r(this,Si)){p(this,Si,!1);for(const t of r(this,te).values())t.disable();for(const t of r(this,$t).values())t.disable()}},lc=function(t){const e=r(this,te).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Pu=function(){let t=null;for(t of r(this,ft));return t},La=function(){if(r(this,$t).size===0)return!0;if(r(this,$t).size===1)for(const t of r(this,$t).values())return t.isEmpty();return!1},hc=function(t){for(const e of r(this,ft))e.unselect();r(this,ft).clear();for(const e of t)e.isEmpty()||(r(this,ft).add(e),e.select());m(this,I,pe).call(this,{hasSelectedEditor:this.hasSelection})},K(wr,"TRANSLATE_SMALL",1),K(wr,"TRANSLATE_BIG",10);let ir=wr;var Qt,ys,ss,Fr,vs,ke,Dr,ws,Ee,zs,pn,_s,Ti,us,Ma,Il;const ge=class ge{constructor(t){b(this,us);b(this,Qt,null);b(this,ys,!1);b(this,ss,null);b(this,Fr,null);b(this,vs,null);b(this,ke,null);b(this,Dr,!1);b(this,ws,null);b(this,Ee,null);b(this,zs,null);b(this,pn,null);b(this,_s,!1);p(this,Ee,t),p(this,_s,t._uiManager.useNewAltTextFlow),r(ge,Ti)||p(ge,Ti,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){ge._l10n??(ge._l10n=t)}async render(){const t=p(this,ss,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,Fr,document.createElement("span"));t.append(e),r(this,_s)?(t.classList.add("new"),t.setAttribute("data-l10n-id",r(ge,Ti).missing),e.setAttribute("data-l10n-id",r(ge,Ti)["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,Ee)._uiManager._signal;t.addEventListener("contextmenu",Ke,{signal:s}),t.addEventListener("pointerdown",n=>n.stopPropagation(),{signal:s});const i=n=>{n.preventDefault(),r(this,Ee)._uiManager.editAltText(r(this,Ee)),r(this,_s)&&r(this,Ee)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:r(this,us,Ma)}})};return t.addEventListener("click",i,{capture:!0,signal:s}),t.addEventListener("keydown",n=>{n.target===t&&n.key==="Enter"&&(p(this,Dr,!0),i(n))},{signal:s}),await m(this,us,Il).call(this),t}finish(){r(this,ss)&&(r(this,ss).focus({focusVisible:r(this,Dr)}),p(this,Dr,!1))}isEmpty(){return r(this,_s)?r(this,Qt)===null:!r(this,Qt)&&!r(this,ys)}hasData(){return r(this,_s)?r(this,Qt)!==null||!!r(this,zs):this.isEmpty()}get guessedText(){return r(this,zs)}async setGuessedText(t){r(this,Qt)===null&&(p(this,zs,t),p(this,pn,await ge._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),m(this,us,Il).call(this))}toggleAltTextBadge(t=!1){var e;if(!r(this,_s)||r(this,Qt)){(e=r(this,ws))==null||e.remove(),p(this,ws,null);return}if(!r(this,ws)){const s=p(this,ws,document.createElement("div"));s.className="noAltTextBadge",r(this,Ee).div.append(s)}r(this,ws).classList.toggle("hidden",!t)}serialize(t){let e=r(this,Qt);return!t&&r(this,zs)===e&&(e=r(this,pn)),{altText:e,decorative:r(this,ys),guessedText:r(this,zs),textWithDisclaimer:r(this,pn)}}get data(){return{altText:r(this,Qt),decorative:r(this,ys)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(p(this,zs,s),p(this,pn,i)),!(r(this,Qt)===t&&r(this,ys)===e)&&(n||(p(this,Qt,t),p(this,ys,e)),m(this,us,Il).call(this))}toggle(t=!1){r(this,ss)&&(!t&&r(this,ke)&&(clearTimeout(r(this,ke)),p(this,ke,null)),r(this,ss).disabled=!t)}shown(){r(this,Ee)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:r(this,us,Ma)}})}destroy(){var t,e;(t=r(this,ss))==null||t.remove(),p(this,ss,null),p(this,Fr,null),p(this,vs,null),(e=r(this,ws))==null||e.remove(),p(this,ws,null)}};Qt=new WeakMap,ys=new WeakMap,ss=new WeakMap,Fr=new WeakMap,vs=new WeakMap,ke=new WeakMap,Dr=new WeakMap,ws=new WeakMap,Ee=new WeakMap,zs=new WeakMap,pn=new WeakMap,_s=new WeakMap,Ti=new WeakMap,us=new WeakSet,Ma=function(){return r(this,Qt)&&"added"||r(this,Qt)===null&&this.guessedText&&"review"||"missing"},Il=async function(){var i,n,a;const t=r(this,ss);if(!t)return;if(r(this,_s)){if(t.classList.toggle("done",!!r(this,Qt)),t.setAttribute("data-l10n-id",r(ge,Ti)[r(this,us,Ma)]),(i=r(this,Fr))==null||i.setAttribute("data-l10n-id",r(ge,Ti)[`${r(this,us,Ma)}-label`]),!r(this,Qt)){(n=r(this,vs))==null||n.remove();return}}else{if(!r(this,Qt)&&!r(this,ys)){t.classList.remove("done"),(a=r(this,vs))==null||a.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=r(this,vs);if(!e){p(this,vs,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${r(this,Ee).id}`;const o=100,l=r(this,Ee)._uiManager._signal;l.addEventListener("abort",()=>{clearTimeout(r(this,ke)),p(this,ke,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,ke,setTimeout(()=>{p(this,ke,null),r(this,vs).classList.add("show"),r(this,Ee)._reportTelemetry({action:"alt_text_tooltip"})},o))},{signal:l}),t.addEventListener("mouseleave",()=>{var c;r(this,ke)&&(clearTimeout(r(this,ke)),p(this,ke,null)),(c=r(this,vs))==null||c.classList.remove("show")},{signal:l})}r(this,ys)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=r(this,Qt)),e.parentNode||t.append(e);const s=r(this,Ee).getImageForAltText();s==null||s.setAttribute("aria-describedby",e.id)},b(ge,Ti,null),K(ge,"_l10n",null);let nh=ge;var gn,is,Tt,Or,mn,ee,bn,Ri,uo,An,Pi,fo,yn,Gs,Es,Nr,Hr,Ge,po,fh,et,cc,go,dc,uc,ku,Lu,fc,pc,gc,Mu,mc,Iu,Fu,Du,bc,Ia;const ut=class ut{constructor(t){b(this,et);b(this,gn,null);b(this,is,null);b(this,Tt,null);b(this,Or,!1);b(this,mn,!1);b(this,ee,null);b(this,bn,null);b(this,Ri,null);b(this,uo,"");b(this,An,!1);b(this,Pi,null);b(this,fo,!1);b(this,yn,!1);b(this,Gs,!1);b(this,Es,null);b(this,Nr,0);b(this,Hr,0);b(this,Ge,null);K(this,"_editToolbar",null);K(this,"_initialOptions",Object.create(null));K(this,"_initialData",null);K(this,"_isVisible",!0);K(this,"_uiManager",null);K(this,"_focusEventsAllowed",!0);b(this,po,!1);b(this,fh,ut._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=ut.prototype._resizeWithKeyboard,e=ir.TRANSLATE_SMALL,s=ir.TRANSLATE_BIG;return ot(this,"_resizerKeyboardManager",new fl([[["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"],ut.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 bg({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(ut._l10n??(ut._l10n=t),ut._l10nResizer||(ut._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"})),ut._borderLineWidth!==-1)return;const s=getComputedStyle(document.documentElement);ut._borderLineWidth=parseFloat(s.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){_t("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return r(this,po)}set _isDraggable(t){var e;p(this,po,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,fh)}setParent(t){t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):m(this,et,Ia).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(r(this,An)?p(this,An,!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,et,cc).call(this,this.parentDimensions,t,e)}translateInPage(t,e){r(this,Pi)||p(this,Pi,[this.x,this.y]),m(this,et,cc).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}drag(t,e){r(this,Pi)||p(this,Pi,[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:c,y:d}=this.div.getBoundingClientRect();this.parent.findNewParent(this,c,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,Pi)&&(r(this,Pi)[0]!==this.x||r(this,Pi)[1]!==this.y)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:s}=ut,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,c]=this.getBaseTranslation();i+=l,n+=c;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=ut,go,dc).call(s,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var s;return m(s=ut,go,dc).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,mn)||(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,mn)&&e.endsWith("%");if(i&&n)return;const[a,o]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),!r(this,mn)&&!n&&(t.height=`${(100*parseFloat(e)/o).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}altTextFinish(){var t;(t=r(this,Tt))==null||t.finish()}async addEditToolbar(){return this._editToolbar||r(this,yn)?this._editToolbar:(this._editToolbar=new tc(this),this.div.append(this._editToolbar.render()),r(this,Tt)&&await this._editToolbar.addAltText(r(this,Tt)),this._editToolbar)}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,(t=r(this,Tt))==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,Tt)||(nh.initialize(ut._l10n),p(this,Tt,new nh(this)),r(this,gn)&&(r(this,Tt).data=r(this,gn),p(this,gn,null)),await this.addEditToolbar())}get altTextData(){var t;return(t=r(this,Tt))==null?void 0:t.data}set altTextData(t){r(this,Tt)&&(r(this,Tt).data=t)}get guessedAltText(){var t;return(t=r(this,Tt))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=r(this,Tt))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=r(this,Tt))==null?void 0:e.serialize(t)}hasAltText(){return!!r(this,Tt)&&!r(this,Tt).isEmpty()}hasAltTextData(){var t;return((t=r(this,Tt))==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,Or)?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),m(this,et,mc).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),ih(this,this.div,["pointerdown"]),this.div}pointerdown(t){const{isMac:e}=be.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,An,!0),this._isDraggable){m(this,et,Mu).call(this,t);return}m(this,et,gc).call(this,t)}get isSelected(){return this._uiManager.isSelected(this)}moveInDOM(){r(this,Es)&&clearTimeout(r(this,Es)),p(this,Es,setTimeout(()=>{var t;p(this,Es,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,c=t/i,d=e/i,u=this.x*n,f=this.y*a,g=this.width*n,A=this.height*a;switch(s){case 0:return[u+c+o,a-f-d-A+l,u+c+g+o,a-f-d+l];case 90:return[u+d+o,a-f+c+l,u+d+A+o,a-f+c+g+l];case 180:return[u-c-g+o,a-f+d+l,u-c+o,a-f+d+A+l];case 270:return[u-d-A+o,a-f-c-g+l,u-d+o,a-f-c+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,yn,!0)}disableEditMode(){p(this,yn,!1)}isInEditMode(){return r(this,yn)}shouldGetKeyboardEvents(){return r(this,Gs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){m(this,et,mc).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){_t("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,gn,t.accessibilityData);const[n,a]=i.pageDimensions,[o,l,c,d]=i.getRectInCurrentCoords(t.rect,a);return i.x=o/n,i.y=l/a,i.width=c/n,i.height=d/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t;if((t=r(this,Ri))==null||t.abort(),p(this,Ri,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),r(this,Es)&&(clearTimeout(r(this,Es)),p(this,Es,null)),m(this,et,Ia).call(this),this.removeEditToolbar(),r(this,Ge)){for(const e of r(this,Ge).values())clearTimeout(e);p(this,Ge,null)}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(m(this,et,ku).call(this),r(this,ee).classList.remove("hidden"),ih(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,bn,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=r(this,ee).children;if(!r(this,is)){p(this,is,Array.from(e));const a=m(this,et,Iu).bind(this),o=m(this,et,Fu).bind(this),l=this._uiManager._signal;for(const c of r(this,is)){const d=c.getAttribute("data-resizer-name");c.setAttribute("role","spinbutton"),c.addEventListener("keydown",a,{signal:l}),c.addEventListener("blur",o,{signal:l}),c.addEventListener("focus",m(this,et,Du).bind(this,d),{signal:l}),c.setAttribute("data-l10n-id",ut._l10nResizer[d])}}const s=r(this,is)[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,is).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,Tt))==null||s.toggleAltTextBadge(!1)}unselect(){var t,e,s,i,n;(t=r(this,ee))==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,Tt))==null||n.toggleAltTextBadge(!0)}updateParams(t,e){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return r(this,fo)}set isEditing(t){p(this,fo,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){p(this,mn,!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,Ge)||p(this,Ge,new Map);const{action:s}=t;let i=r(this,Ge).get(s);i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(t),r(this,Ge).delete(s),r(this,Ge).size===0&&p(this,Ge,null)},ut._telemetryTimeout),r(this,Ge).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,Or,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Or,!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()}};gn=new WeakMap,is=new WeakMap,Tt=new WeakMap,Or=new WeakMap,mn=new WeakMap,ee=new WeakMap,bn=new WeakMap,Ri=new WeakMap,uo=new WeakMap,An=new WeakMap,Pi=new WeakMap,fo=new WeakMap,yn=new WeakMap,Gs=new WeakMap,Es=new WeakMap,Nr=new WeakMap,Hr=new WeakMap,Ge=new WeakMap,po=new WeakMap,fh=new WeakMap,et=new WeakSet,cc=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this.fixAndSetPosition()},go=new WeakSet,dc=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]}},uc=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]}},ku=function(){if(r(this,ee))return;p(this,ee,document.createElement("div")),r(this,ee).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,ee).append(i),i.classList.add("resizer",s),i.setAttribute("data-resizer-name",s),i.addEventListener("pointerdown",m(this,et,Lu).bind(this,s),{signal:e}),i.addEventListener("contextmenu",Ke,{signal:e}),i.tabIndex=-1}this.div.prepend(r(this,ee))},Lu=function(t,e){var A;e.preventDefault();const{isMac:s}=be.platform;if(e.button!==0||e.ctrlKey&&s)return;(A=r(this,Tt))==null||A.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,et,pc).bind(this,t),{passive:!0,capture:!0,signal:a}),window.addEventListener("contextmenu",Ke,{signal:a});const o=this.x,l=this.y,c=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,Tt))==null||y.toggle(!0),this._isDraggable=i,this.parent.div.style.cursor=u,this.div.style.cursor=f,m(this,et,fc).call(this,o,l,c,d)};window.addEventListener("pointerup",g,{signal:a}),window.addEventListener("blur",g,{signal:a})},fc=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[c,d]=this.parentDimensions;this.setDims(c*o,d*l),this.fixAndSetPosition()},undo:()=>{this.width=s,this.height=i,this.x=t,this.y=e;const[c,d]=this.parentDimensions;this.setDims(c*s,d*i),this.fixAndSetPosition()},mustExec:!0})},pc=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,o=this.width,l=this.height,c=ut.MIN_SIZE/s,d=ut.MIN_SIZE/i,u=O=>Math.round(O*1e4)/1e4,f=m(this,et,uc).call(this,this.rotation),g=(O,z)=>[f[0]*O+f[2]*z,f[1]*O+f[3]*z],A=m(this,et,uc).call(this,360-this.rotation),y=(O,z)=>[A[0]*O+A[2]*z,A[1]*O+A[3]*z];let w,v,_=!1,S=!1;switch(t){case"topLeft":_=!0,w=(O,z)=>[0,0],v=(O,z)=>[O,z];break;case"topMiddle":w=(O,z)=>[O/2,0],v=(O,z)=>[O/2,z];break;case"topRight":_=!0,w=(O,z)=>[O,0],v=(O,z)=>[0,z];break;case"middleRight":S=!0,w=(O,z)=>[O,z/2],v=(O,z)=>[0,z/2];break;case"bottomRight":_=!0,w=(O,z)=>[O,z],v=(O,z)=>[0,0];break;case"bottomMiddle":w=(O,z)=>[O/2,z],v=(O,z)=>[O/2,0];break;case"bottomLeft":_=!0,w=(O,z)=>[0,z],v=(O,z)=>[O,0];break;case"middleLeft":S=!0,w=(O,z)=>[0,z/2],v=(O,z)=>[O,z/2];break}const E=w(o,l),x=v(o,l);let C=g(...x);const T=u(n+C[0]),P=u(a+C[1]);let L=1,F=1,[D,Y]=this.screenToPageTranslation(e.movementX,e.movementY);if([D,Y]=y(D/s,Y/i),_){const O=Math.hypot(o,l);L=F=Math.max(Math.min(Math.hypot(x[0]-E[0]-D,x[1]-E[1]-Y)/O,1/o,1/l),c/o,d/l)}else S?L=Math.max(c,Math.min(1,Math.abs(x[0]-E[0]-D)))/o:F=Math.max(d,Math.min(1,Math.abs(x[1]-E[1]-Y)))/l;const W=u(o*L),G=u(l*F);C=g(...v(W,G));const V=T-C[0],q=P-C[1];this.width=W,this.height=G,this.x=V,this.y=q,this.setDims(s*W,i*G),this.fixAndSetPosition()},gc=function(t){const{isMac:e}=be.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Mu=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,Nr,t.clientX),p(this,Hr,t.clientY);const a=o=>{const{clientX:l,clientY:c}=o,[d,u]=this.screenToPageTranslation(l-r(this,Nr),c-r(this,Hr));p(this,Nr,l),p(this,Hr,c),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,An,!1),this._uiManager.endDragSession()||m(this,et,gc).call(this,t)};window.addEventListener("pointerup",n,{signal:i}),window.addEventListener("blur",n,{signal:i})},mc=function(){if(r(this,Ri)||!this.div)return;p(this,Ri,new AbortController);const t=this._uiManager.combinedSignal(r(this,Ri));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Iu=function(t){ut._resizerKeyboardManager.exec(this,t)},Fu=function(t){var e;r(this,Gs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==r(this,ee)&&m(this,et,Ia).call(this)},Du=function(t){p(this,uo,r(this,Gs)?t:"")},bc=function(t){if(r(this,is))for(const e of r(this,is))e.tabIndex=t},Ia=function(){if(p(this,Gs,!1),m(this,et,bc).call(this,-1),r(this,bn)){const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=r(this,bn);m(this,et,fc).call(this,t,e,s,i),p(this,bn,null)}},b(ut,go),K(ut,"_l10n",null),K(ut,"_l10nResizer",null),K(ut,"_borderLineWidth",-1),K(ut,"_colorManager",new ic),K(ut,"_zIndex",1),K(ut,"_telemetryTimeout",1e3);let gt=ut;class bg extends gt{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Od=3285377520,$e=4294901760,ps=65535;class Ou{constructor(t){this.h1=t?t&4294967295:Od,this.h2=t?t&4294967295:Od}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,c=this.h1,d=this.h2;const u=3432918353,f=461845907,g=u&ps,A=f&ps;for(let y=0;y>>17,o=o*f&$e|o*A&ps,c^=o,c=c<<13|c>>>19,c=c*5+3864292196):(l=a[y],l=l*u&$e|l*g&ps,l=l<<15|l>>>17,l=l*f&$e|l*A&ps,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&$e|o*g&ps,o=o<<15|o>>>17,o=o*f&$e|o*A&ps,i&1?c^=o:d^=o}this.h1=c,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&$e|t*36045&ps,e=e*4283543511&$e|((e<<16|t>>>16)*2950163797&$e)>>>16,t^=e>>>1,t=t*444984403&$e|t*60499&ps,e=e*3301882366&$e|((e<<16|t>>>16)*3120437893&$e)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Ac=Object.freeze({map:null,hash:"",transfer:void 0});var vn,wn,Jt,ph,Nu;class _d{constructor(){b(this,ph);b(this,vn,!1);b(this,wn,null);b(this,Jt,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=r(this,Jt).get(t);return s===void 0?e:Object.assign(e,s)}getRawValue(t){return r(this,Jt).get(t)}remove(t){if(r(this,Jt).delete(t),r(this,Jt).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function"){for(const e of r(this,Jt).values())if(e instanceof gt)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=r(this,Jt).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,Jt).set(t,e);i&&m(this,ph,Nu).call(this),e instanceof gt&&typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type)}has(t){return r(this,Jt).has(t)}getAll(){return r(this,Jt).size>0?md(r(this,Jt)):null}setAll(t){for(const[e,s]of Object.entries(t))this.setValue(e,s)}get size(){return r(this,Jt).size}resetModified(){r(this,vn)&&(p(this,vn,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new Hu(this)}get serializable(){if(r(this,Jt).size===0)return Ac;const t=new Map,e=new Ou,s=[],i=Object.create(null);let n=!1;for(const[a,o]of r(this,Jt)){const l=o instanceof gt?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}:Ac}get editorStats(){let t=null;const e=new Map;for(const s of r(this,Jt).values()){if(!(s instanceof gt))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 c=a.get(o);c||(c=new Map,a.set(o,c));const d=c.get(l)??0;c.set(l,d+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){p(this,wn,null)}get modifiedIds(){if(r(this,wn))return r(this,wn);const t=[];for(const e of r(this,Jt).values())!(e instanceof gt)||!e.annotationElementId||!e.serialize()||t.push(e.annotationElementId);return p(this,wn,{ids:new Set(t),hash:t.join(",")})}}vn=new WeakMap,wn=new WeakMap,Jt=new WeakMap,ph=new WeakSet,Nu=function(){r(this,vn)||(p(this,vn,!0),typeof this.onSetModified=="function"&&this.onSetModified())};var mo;class Hu extends _d{constructor(e){super();b(this,mo);const{map:s,hash:i,transfer:n}=e.serializable,a=structuredClone(s,n?{transfer:n}:null);p(this,mo,{map:a,hash:i,transfer:n})}get print(){_t("Should not call PrintAnnotationStorage.print")}get serializable(){return r(this,mo)}get modifiedIds(){return ot(this,"modifiedIds",{ids:new Set,hash:""})}}mo=new WeakMap;var jr;class Ag{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){b(this,jr,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,jr).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,_inspectFont:e}){if(!(!t||r(this,jr).has(t.loadedName))){if(Ut(!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,jr).add(s),e==null||e(t)}catch{st(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(a)}return}_t("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const s=t.createNativeFontFace();if(s){this.addNativeFontFace(s);try{await s.loaded}catch(i){throw st(`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(ue||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(Ut(!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,x){return E.charCodeAt(x)<<24|E.charCodeAt(x+1)<<16|E.charCodeAt(x+2)<<8|E.charCodeAt(x+3)&255}function i(E,x,C,T){const P=E.substring(0,x),L=E.substring(x+C);return P+T+L}let n,a;const o=this._document.createElement("canvas");o.width=1,o.height=1;const l=o.getContext("2d");let c=0;function d(E,x){if(++c>30){st("Load test font never loaded."),x();return}if(l.font="30px "+E,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){x();return}setTimeout(d.bind(null,E,x))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=i(f,976,u.length,u);const A=16,y=1482184792;let w=s(f,A);for(n=0,a=u.length-3;n{S.remove(),e.complete()})}}jr=new WeakMap;class yg{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,${lg(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){st(`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,c,d,u,f)),n+=6}break;case Fs.MOVE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.moveTo(o,l)),n+=2}break;case Fs.LINE_TO:{const[o,l]=s.slice(n,n+2);i.push(c=>c.lineTo(o,l)),n+=2}break;case Fs.QUADRATIC_CURVE_TO:{const[o,l,c,d]=s.slice(n,n+4);i.push(u=>u.quadraticCurveTo(o,l,c,d)),n+=4}break;case Fs.RESTORE:i.push(o=>o.restore());break;case Fs.SAVE:i.push(o=>o.save());break;case Fs.SCALE:Ut(i.length===2,"Scale command is only valid at the third position.");break;case Fs.TRANSFORM:{const[o,l,c,d,u,f]=s.slice(n,n+6);i.push(g=>g.transform(o,l,c,d,u,f)),n+=6}break;case Fs.TRANSLATE:{const[o,l]=s.slice(n,n+2);i.push(c=>c.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,c=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){_t("Abstract method `_fetch` called.")}}class $u extends Bu{async _fetch(t){const e=await Lh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):kh(e)}}class zu{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 _n,En,Ss,Us,le,gh,Sn,j,ae,fr,pr,Fl,gr,Gu,yc,mr,Fa,Da,vc,Oa;class wg extends zu{constructor({docId:e,ownerDocument:s=globalThis.document}){super();b(this,j);b(this,_n);b(this,En);b(this,Ss);b(this,Us);b(this,le);b(this,gh);b(this,Sn,0);p(this,Us,e),p(this,le,s)}addFilter(e){if(!e)return"none";let s=r(this,j,ae).get(e);if(s)return s;const[i,n,a]=m(this,j,Fl).call(this,e),o=e.length===1?i:`${i}${n}${a}`;if(s=r(this,j,ae).get(o),s)return r(this,j,ae).set(e,s),s;const l=`g_${r(this,Us)}_transfer_map_${fe(this,Sn)._++}`,c=m(this,j,gr).call(this,l);r(this,j,ae).set(e,c),r(this,j,ae).set(o,c);const d=m(this,j,mr).call(this,l);return m(this,j,Da).call(this,i,n,a,d),c}addHCMFilter(e,s){var A;const i=`${e}-${s}`,n="base";let a=r(this,j,fr).get(n);if((a==null?void 0:a.key)===i||(a?((A=a.filter)==null||A.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},r(this,j,fr).set(n,a)),!e||!s))return a.url;const o=m(this,j,Oa).call(this,e);e=$.makeHexColor(...o);const l=m(this,j,Oa).call(this,s);if(s=$.makeHexColor(...l),r(this,j,pr).style.color="",e==="#000000"&&s==="#ffffff"||e===s)return a.url;const c=new Array(256);for(let y=0;y<=255;y++){const w=y/255;c[y]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const d=c.join(","),u=`g_${r(this,Us)}_hcm_filter`,f=a.filter=m(this,j,mr).call(this,u);m(this,j,Da).call(this,d,d,d,f),m(this,j,yc).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,j,Da).call(this,g(0,5),g(1,5),g(2,5),f),a.url=m(this,j,gr).call(this,u),a.url}addAlphaFilter(e){let s=r(this,j,ae).get(e);if(s)return s;const[i]=m(this,j,Fl).call(this,[e]),n=`alpha_${i}`;if(s=r(this,j,ae).get(n),s)return r(this,j,ae).set(e,s),s;const a=`g_${r(this,Us)}_alpha_map_${fe(this,Sn)._++}`,o=m(this,j,gr).call(this,a);r(this,j,ae).set(e,o),r(this,j,ae).set(n,o);const l=m(this,j,mr).call(this,a);return m(this,j,vc).call(this,i,l),o}addLuminosityFilter(e){let s=r(this,j,ae).get(e||"luminosity");if(s)return s;let i,n;if(e?([i]=m(this,j,Fl).call(this,[e]),n=`luminosity_${i}`):n="luminosity",s=r(this,j,ae).get(n),s)return r(this,j,ae).set(e,s),s;const a=`g_${r(this,Us)}_luminosity_map_${fe(this,Sn)._++}`,o=m(this,j,gr).call(this,a);r(this,j,ae).set(e,o),r(this,j,ae).set(n,o);const l=m(this,j,mr).call(this,a);return m(this,j,Gu).call(this,l),e&&m(this,j,vc).call(this,i,l),o}addHighlightHCMFilter(e,s,i,n,a){var _;const o=`${s}-${i}-${n}-${a}`;let l=r(this,j,fr).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,j,fr).set(e,l)),!s||!i))return l.url;const[c,d]=[s,i].map(m(this,j,Oa).bind(this));let u=Math.round(.2126*c[0]+.7152*c[1]+.0722*c[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,A]=[n,a].map(m(this,j,Oa).bind(this));f{const C=new Array(256),T=(f-u)/x,P=S/255,L=(E-S)/(255*x);let F=0;for(let D=0;D<=x;D++){const Y=Math.round(u+D*T),W=P+D*L;for(let G=F;G<=Y;G++)C[G]=W;F=Y+1}for(let D=F;D<256;D++)C[D]=C[F-1];return C.join(",")},w=`g_${r(this,Us)}_hcm_${e}_filter`,v=l.filter=m(this,j,mr).call(this,w);return m(this,j,yc).call(this,v),m(this,j,Da).call(this,y(g[0],A[0],5),y(g[1],A[1],5),y(g[2],A[2],5),v),l.url=m(this,j,gr).call(this,w),l.url}destroy(e=!1){e&&r(this,j,fr).size!==0||(r(this,Ss)&&(r(this,Ss).parentNode.parentNode.remove(),p(this,Ss,null)),r(this,En)&&(r(this,En).clear(),p(this,En,null)),p(this,Sn,0))}}_n=new WeakMap,En=new WeakMap,Ss=new WeakMap,Us=new WeakMap,le=new WeakMap,gh=new WeakMap,Sn=new WeakMap,j=new WeakSet,ae=function(){return r(this,En)||p(this,En,new Map)},fr=function(){return r(this,gh)||p(this,gh,new Map)},pr=function(){if(!r(this,Ss)){const e=r(this,le).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,le).createElementNS(Os,"svg");i.setAttribute("width",0),i.setAttribute("height",0),p(this,Ss,r(this,le).createElementNS(Os,"defs")),e.append(i),i.append(r(this,Ss)),r(this,le).body.append(e)}return r(this,Ss)},Fl=function(e){if(e.length===1){const c=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=c[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 c=0;c<256;c++)a[c]=s[c]/255,o[c]=i[c]/255,l[c]=n[c]/255;return[a.join(","),o.join(","),l.join(",")]},gr=function(e){if(r(this,_n)===void 0){p(this,_n,"");const s=r(this,le).URL;s!==r(this,le).baseURI&&(Mh(s)?st('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,_n,s.split("#",1)[0]))}return`url(${r(this,_n)}#${e})`},Gu=function(e){const s=r(this,le).createElementNS(Os,"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)},yc=function(e){const s=r(this,le).createElementNS(Os,"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)},mr=function(e){const s=r(this,le).createElementNS(Os,"filter");return s.setAttribute("color-interpolation-filters","sRGB"),s.setAttribute("id",e),r(this,j,pr).append(s),s},Fa=function(e,s,i){const n=r(this,le).createElementNS(Os,s);n.setAttribute("type","discrete"),n.setAttribute("tableValues",i),e.append(n)},Da=function(e,s,i,n){const a=r(this,le).createElementNS(Os,"feComponentTransfer");n.append(a),m(this,j,Fa).call(this,a,"feFuncR",e),m(this,j,Fa).call(this,a,"feFuncG",s),m(this,j,Fa).call(this,a,"feFuncB",i)},vc=function(e,s){const i=r(this,le).createElementNS(Os,"feComponentTransfer");s.append(i),m(this,j,Fa).call(this,i,"feFuncA",e)},Oa=function(e){return r(this,j,pr).style.color=e,wd(getComputedStyle(r(this,j,pr)).getPropertyValue("color"))};class Uu{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){_t("Abstract method `_fetch` called.")}}class Wu extends Uu{async _fetch(t){const e=await Lh(t,"arraybuffer");return new Uint8Array(e)}}if(ue){var wc=Promise.withResolvers(),qa=null;(async()=>{const t=await yl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),e=await yl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),s=await yl(()=>import("./__vite-browser-external-BIHI7g3E.js"),[]),i=await yl(()=>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=>{qa=t,wc.resolve()},t=>{st(`loadPackages: ${t}`),qa=new Map,wc.resolve()})}class qi{static get promise(){return wc.promise}static get(t){return qa==null?void 0:qa.get(t)}}async function Vu(h){const e=await qi.get("fs").promises.readFile(h);return new Uint8Array(e)}class _g extends zu{}class Eg extends ju{_createCanvas(t,e){return qi.get("canvas").createCanvas(t,e)}}class Sg extends Bu{async _fetch(t){return Vu(t)}}class xg extends Uu{async _fetch(t){return Vu(t)}}const me={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function _c(h,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),h.clip(i)}class Ed{getPattern(){_t("Abstract method `getPattern` called.")}}class Cg extends Ed{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===me.STROKE||i===me.FILL){const a=e.current.getClippedPathBoundingBox(i,Pt(t))||[0,0,0,0],o=Math.ceil(a[2]-a[0])||1,l=Math.ceil(a[3]-a[1])||1,c=e.cachedCanvases.getCanvas("pattern",o,l),d=c.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),_c(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),n=t.createPattern(c.canvas,"no-repeat");const u=new DOMMatrix(s);n.setTransform(u)}else _c(t,this._bbox),n=this._createGradient(t);return n}}function Gh(h,t,e,s,i,n,a,o){const l=t.coords,c=t.colors,d=h.data,u=h.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,A=(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(A>=_)return;const S=c[n],E=c[n+1],x=c[n+2],C=c[a],T=c[a+1],P=c[a+2],L=c[o],F=c[o+1],D=c[o+2],Y=Math.round(A),W=Math.round(_);let G,V,q,O,z,St,It,Ft;for(let ht=Y;ht<=W;ht++){if(ht_?X=1:w===_?X=0:X=(w-ht)/(w-_),G=y-(y-v)*X,V=C-(C-L)*X,q=T-(T-F)*X,O=P-(P-D)*X}let at;ht_?at=1:at=(A-ht)/(A-_),z=g-(g-v)*at,St=S-(S-L)*at,It=E-(E-F)*at,Ft=x-(x-D)*at;const N=Math.round(Math.min(G,z)),lt=Math.round(Math.max(G,z));let nt=u*ht+N*4;for(let X=N;X<=lt;X++)at=(G-X)/(G-z),at<0?at=0:at>1&&(at=1),d[nt++]=V-(V-St)*at|0,d[nt++]=q-(q-It)*at|0,d[nt++]=O-(O-Ft)*at|0,d[nt++]=255}}function Tg(h,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,c=o-1;for(n=0;n=F?E=l:C=!0,L>=D?x=c:T=!0;const Y=this.getSizeAndScale(E,this.ctx.canvas.width,_),W=this.getSizeAndScale(x,this.ctx.canvas.height,S),G=t.cachedCanvases.getCanvas("pattern",Y.size,W.size),V=G.context,q=o.createCanvasGraphics(V);if(q.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(q,i,a),V.translate(-Y.scale*d,-W.scale*u),q.transform(Y.scale,0,0,W.scale,0,0),V.save(),this.clipBbox(q,d,u,f,g),q.baseTransform=Pt(q.ctx),q.executeOperatorList(s),q.endDrawing(),V.restore(),C||T){const O=G.canvas;C&&(E=l),T&&(x=c);const z=this.getSizeAndScale(E,this.ctx.canvas.width,_),St=this.getSizeAndScale(x,this.ctx.canvas.height,S),It=z.size,Ft=St.size,ht=t.cachedCanvases.getCanvas("pattern-workaround",It,Ft),at=ht.context,N=C?Math.floor(A/l):0,lt=T?Math.floor(y/c):0;for(let nt=0;nt<=N;nt++)for(let X=0;X<=lt;X++)at.drawImage(O,It*nt,Ft*X,It,Ft,0,0,It,Ft);return{canvas:ht.canvas,scaleX:z.scale,scaleY:St.scale,offsetX:d,offsetY:u}}return{canvas:G.canvas,scaleX:Y.scale,scaleY:W.scale,offsetX:d,offsetY:u}}getSizeAndScale(t,e,s){const i=Math.max(mh.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(Pt(t.ctx),[e,s,i,n]),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case Nd.COLORED:const a=this.ctx;i.fillStyle=a.fillStyle,i.strokeStyle=a.strokeStyle,n.fillColor=a.fillStyle,n.strokeColor=a.strokeStyle;break;case Nd.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 eg(`Unsupported paint type: ${e}`)}}getPattern(t,e,s,i){let n=s;i!==me.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}};K(mh,"MAX_PATTERN_SIZE",3e3);let Ec=mh;function Lg({src:h,srcPos:t=0,dest:e,width:s,height:i,nonBlackColor:n=4294967295,inverseDecode:a=!1}){const o=be.isLittleEndian?4278190080:255,[l,c]=a?[n,o]:[o,n],d=s>>3,u=s&7,f=h.length;e=new Uint32Array(e.buffer);let g=0;for(let A=0;A{h.save=h.__originalSave,h.restore=h.__originalRestore,h.rotate=h.__originalRotate,h.scale=h.__originalScale,h.translate=h.__originalTranslate,h.transform=h.__originalTransform,h.setTransform=h.__originalSetTransform,h.resetTransform=h.__originalResetTransform,h.clip=h.__originalClip,h.moveTo=h.__originalMoveTo,h.lineTo=h.__originalLineTo,h.bezierCurveTo=h.__originalBezierCurveTo,h.rect=h.__originalRect,h.closePath=h.__originalClosePath,h.beginPath=h.__originalBeginPath,delete h._removeMirroring},h.save=function(){t.save(),this.__originalSave()},h.restore=function(){t.restore(),this.__originalRestore()},h.translate=function(s,i){t.translate(s,i),this.__originalTranslate(s,i)},h.scale=function(s,i){t.scale(s,i),this.__originalScale(s,i)},h.transform=function(s,i,n,a,o,l){t.transform(s,i,n,a,o,l),this.__originalTransform(s,i,n,a,o,l)},h.setTransform=function(s,i,n,a,o,l){t.setTransform(s,i,n,a,o,l),this.__originalSetTransform(s,i,n,a,o,l)},h.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},h.rotate=function(s){t.rotate(s),this.__originalRotate(s)},h.clip=function(s){t.clip(s),this.__originalClip(s)},h.moveTo=function(e,s){t.moveTo(e,s),this.__originalMoveTo(e,s)},h.lineTo=function(e,s){t.lineTo(e,s),this.__originalLineTo(e,s)},h.bezierCurveTo=function(e,s,i,n,a,o){t.bezierCurveTo(e,s,i,n,a,o),this.__originalBezierCurveTo(e,s,i,n,a,o)},h.rect=function(e,s,i,n){t.rect(e,s,i,n),this.__originalRect(e,s,i,n)},h.closePath=function(){t.closePath(),this.__originalClosePath()},h.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class Fg{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 vl(h,t,e,s,i,n,a,o,l,c){const[d,u,f,g,A,y]=Pt(h);if(u===0&&f===0){const _=a*d+A,S=Math.round(_),E=o*g+y,x=Math.round(E),C=(a+l)*d+A,T=Math.abs(Math.round(C)-S)||1,P=(o+c)*g+y,L=Math.abs(Math.round(P)-x)||1;return h.setTransform(Math.sign(d),0,0,Math.sign(g),S,x),h.drawImage(t,e,s,i,n,0,0,T,L),h.setTransform(d,u,f,g,A,y),[T,L]}if(d===0&&g===0){const _=o*f+A,S=Math.round(_),E=a*u+y,x=Math.round(E),C=(o+c)*f+A,T=Math.abs(Math.round(C)-S)||1,P=(a+l)*u+y,L=Math.abs(Math.round(P)-x)||1;return h.setTransform(0,Math.sign(u),Math.sign(f),0,S,x),h.drawImage(t,e,s,i,n,0,0,L,T),h.setTransform(d,u,f,g,A,y),[L,T]}h.drawImage(t,e,s,i,n,a,o,l,c);const w=Math.hypot(d,u),v=Math.hypot(f,g);return[w*l,v*c]}function Dg(h){const{width:t,height:e}=h;if(t>$d||e>$d)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,c;const d=t+7&-8;let u=new Uint8Array(d*e),f=0;for(const v of h.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[c+l]=i[v],++g),f++;if(u[f-d]!==u[f]&&(a[c+l]=u[f]?2:4,++g),g>s)return null}for(f=d*(e-1),c=o*n,u[f]!==0&&(a[c]=8,++g),l=1;ls)return null;const A=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 x=A[E];do v+=x;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 zd{constructor(t,e){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=hu,this.textMatrixScale=1,this.fontMatrix=Yh,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=re.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,c,d){const u=$.bezierBoundingBox(e,s,i,n,a,o,l,c,d);d||this.updateRectMinMax(t,u)}getPathBoundingBox(t=me.FILL,e=null){const s=[this.minX,this.minY,this.maxX,this.maxY];if(t===me.STROKE){e||_t("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=me.FILL,e=null){return $.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Gd(h,t){if(typeof ImageData<"u"&&t instanceof ImageData){h.putImageData(t,0,0);return}const e=t.height,s=t.width,i=e%Ce,n=(e-i)/Ce,a=i===0?n:n+1,o=h.createImageData(s,Ce);let l=0,c;const d=t.data,u=o.data;let f,g,A,y;if(t.kind===Tl.GRAYSCALE_1BPP){const w=d.byteLength,v=new Uint32Array(u.buffer,0,u.byteLength>>2),_=v.length,S=s+7>>3,E=4294967295,x=be.isLittleEndian?4278190080:255;for(f=0;fS?s:C*8-7,L=P&-8;let F=0,D=0;for(;T>=1}for(;c<_;)v[c++]=0;h.putImageData(o,0,f*Ce)}}else if(t.kind===Tl.RGBA_32BPP){for(g=0,y=s*Ce*4,f=0;f=n&&(A=i,y=s*A),c=0,g=y;g--;)u[c++]=d[l++],u[c++]=d[l++],u[c++]=d[l++],u[c++]=255;h.putImageData(o,0,f*Ce)}else throw new Error(`bad image kind: ${t.kind}`)}function Ud(h,t){if(t.bitmap){h.drawImage(t.bitmap,0,0);return}const e=t.height,s=t.width,i=e%Ce,n=(e-i)/Ce,a=i===0?n:n+1,o=h.createImageData(s,Ce);let l=0;const c=t.data,d=o.data;for(let u=0;uBd&&typeof s=="function",d=c?Date.now()+Mg:0;let u=0;const f=this.commonObjs,g=this.objs;let A;for(;;){if(i!==void 0&&o===i.nextBreakPoint)return i.breakIt(o,s),o;if(A=a[o],A!==Je.dependency)this[A].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(c&&++u>Bd){if(Date.now()>d)return s(),o;u=0}}}endDrawing(){m(this,Yi,Sc).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,Yi,xc).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,c="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(c,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,c=c==="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=Pt(e);let l,c,d,u;if((t.bitmap||t.data)&&t.count>1){const P=t.bitmap||t.data.buffer;c=JSON.stringify(a?o:[o.slice(0,4),n]),l=this._cachedBitmapsMap.get(P),l||(l=new Map,this._cachedBitmapsMap.set(P,l));const L=l.get(c);if(L&&!a){const F=Math.round(Math.min(o[0],o[2])+o[4]),D=Math.round(Math.min(o[1],o[3])+o[5]);return{canvas:L,offsetX:F,offsetY:D}}d=L}d||(u=this.cachedCanvases.getCanvas("maskCanvas",s,i),Ud(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,A,y,w]=$.getAxialAlignedBoundingBox([0,0,s,i],f),v=Math.round(y-g)||1,_=Math.round(w-A)||1,S=this.cachedCanvases.getCanvas("fillCanvas",v,_),E=S.context,x=g,C=A;E.translate(-x,-C),E.transform(...f),d||(d=this._scaleImage(u.canvas,Ds(E)),d=d.img,l&&a&&l.set(c,d)),E.imageSmoothingEnabled=Wd(Pt(E),t.interpolate),vl(E,d,0,0,d.width,d.height,0,0,s,i),E.globalCompositeOperation="source-in";const T=$.transform(Ds(E),[1,0,0,1,-x,-C]);return E.fillStyle=a?n.getPattern(e,this,T,me.FILL):n,E.fillRect(0,0,s,i),l&&!a&&(this.cachedCanvases.delete("fillCanvas"),l.set(c,S.canvas)),{canvas:S.canvas,offsetX:Math.round(x),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=Og[t]}setLineJoin(t){this.ctx.lineJoin=Ng[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(...Pt(this.suspendedCtx)),Ta(this.suspendedCtx,n),Ig(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(),Ta(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,c,d,u){let f=t.canvas,g=l-d,A=c-u;if(a){const w=$.makeHexColor(...a);if(g<0||A<0||g+s>f.width||A+i>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",s,i),_=v.context;_.drawImage(f,-g,-A),_.globalCompositeOperation="destination-atop",_.fillStyle=w,_.fillRect(0,0,s,i),_.globalCompositeOperation="source-over",f=v.canvas,g=A=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(g,A,s,i),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=w,t.fillRect(g,A,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,c,s,i),e.clip(y),e.globalCompositeOperation="destination-in",e.drawImage(f,g,A,s,i,l,c,s,i),e.restore()}save(){this.inSMaskMode?(Ta(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(),Ta(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,c;const d=Pt(i),u=d[0]===0&&d[3]===0||d[1]===0&&d[2]===0,f=u?s.slice(0):null;for(let g=0,A=0,y=t.length;gjd&&(c=jd),this.current.fontSizeScale=e/c,this.ctx.font=`${l} ${o} ${c}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,c=a.fontSize/a.fontSizeScale,d=l&re.FILL_STROKE_MASK,u=!!(l&re.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,c),i&&n.setTransform(...i),(d===re.FILL||d===re.FILL_STROKE)&&n.fill(),(d===re.STROKE||d===re.FILL_STROKE)&&n.stroke(),n.restore()):((d===re.FILL||d===re.FILL_STROKE)&&n.fillText(t,e,s),(d===re.STROKE||d===re.FILL_STROKE)&&n.strokeText(t,e,s)),u&&(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Pt(n),x:e,y:s,fontSize:c,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,c=e.fontDirection,d=e.textHScale*c,u=t.length,f=s.vertical,g=f?1:-1,A=s.defaultVMetrics,y=i*e.fontMatrix[0],w=e.textRenderingMode===re.FILL&&!s.disableFontFace&&!e.patternFill;n.save(),n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),c>0?n.scale(d,-1):n.scale(d,1);let v;if(e.patternFill){n.save();const C=e.fillColor.getPattern(n,this,Ds(n),me.FILL);v=Pt(n),n.restore(),n.fillStyle=C}let _=e.lineWidth;const S=e.textMatrixScale;if(S===0||_===0){const C=e.textRenderingMode&re.FILL_STROKE_MASK;(C===re.STROKE||C===re.FILL_STROKE)&&(_=this.getSinglePixelWidth())}else _/=S;if(a!==1&&(n.scale(a,a),_/=a),n.lineWidth=_,s.isInvalidPDFjsFont){const C=[];let T=0;for(const P of t)C.push(P.unicode),T+=P.width;n.fillText(C.join(""),0,0),e.x+=T*y*d,n.restore(),this.compose();return}let E=0,x;for(x=0;x0){const V=n.measureText(L).width*1e3/i*a;if(Wnew kd(a,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};e=new Ec(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=kg(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,Ds(e),me.SHADING);const i=Ds(e);if(i){const{width:n,height:a}=e.canvas,[o,l,c,d]=$.getAxialAlignedBoundingBox([0,0,n,a],i);this.ctx.fillRect(o,l,c-o,d-l)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){_t("Should not call beginInlineImage")}beginImageData(){_t("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Pt(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(Pt(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||Rh("TODO: Support non-isolated groups."),t.knockout&&st("Knockout groups not supported.");const s=Pt(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=$.getAxialAlignedBoundingBox(t.bbox,Pt(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),c=Math.max(Math.ceil(i[3])-o,1);this.current.startNewPathAndClipBox([0,0,l,c]);let d="groupAt"+this.groupLevel;t.smask&&(d+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(d,l,c),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()),Ta(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=Pt(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,Yi,Sc).call(this),wl(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,c]=$.singularValueDecompose2dScale(Pt(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:A}=this.annotationCanvas;this.annotationCanvasMap.set(t,g),this.annotationCanvas.savedCtx=this.ctx,this.ctx=A,this.ctx.save(),this.ctx.setTransform(l,0,0,-c,0,o*c),wl(this.ctx)}else wl(this.ctx),this.endPath(),this.ctx.rect(e[0],e[1],a,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new zd(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),m(this,Yi,xc).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=Dg(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=Pt(o);o.transform(e,s,i,n,0,0);const c=this._createMaskCanvas(t);o.setTransform(1,0,0,1,c.offsetX-l[4],c.offsetY-l[5]);for(let d=0,u=a.length;du?d/u:1,o=c>u?c/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}};Yi=new WeakSet,Sc=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)},xc=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 _r=kd;for(const h in Je)_r.prototype[h]!==void 0&&(_r.prototype[Je[h]]=_r.prototype[h]);var Ao,yo;class hi{static get workerPort(){return r(this,Ao)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Ao,t)}static get workerSrc(){return r(this,yo)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,yo,t)}}Ao=new WeakMap,yo=new WeakMap,b(hi,Ao,null),b(hi,yo,"");const _l={DATA:1,ERROR:2},Nt={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function Re(h){switch(h instanceof Error||typeof h=="object"&&h!==null||_t('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),h.name){case"AbortException":return new hr(h.message);case"MissingPDFException":return new lr(h.message);case"PasswordException":return new Kh(h.message,h.code);case"UnexpectedResponseException":return new Ph(h.message,h.status);case"UnknownErrorException":return new Qh(h.message,h.details);default:return new Qh(h.message,h.toString())}}var Br,Ye,qu,Xu,Yu,Dl;class Na{constructor(t,e,s){b(this,Ye);b(this,Br,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,Ye,qu).bind(this),{signal:r(this,Br).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:c=>{const d=Promise.withResolvers();return this.streamControllers[n]={controller:c,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},l.postMessage({sourceName:a,targetName:o,action:t,streamId:n,data:e,desiredSize:c.desiredSize},i),d.promise},pull:c=>{const d=Promise.withResolvers();return this.streamControllers[n].pullCall=d,l.postMessage({sourceName:a,targetName:o,stream:Nt.PULL,streamId:n,desiredSize:c.desiredSize}),d.promise},cancel:c=>{Ut(c 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:Nt.CANCEL,streamId:n,reason:Re(c)}),d.promise}},s)}destroy(){var t;(t=r(this,Br))==null||t.abort(),p(this,Br,null)}}Br=new WeakMap,Ye=new WeakSet,qu=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){m(this,Ye,Yu).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===_l.DATA)i.resolve(t.data);else if(t.callback===_l.ERROR)i.reject(Re(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const s=this.sourceName,i=t.sourceName,n=this.comObj;new Promise(function(a){a(e(t.data))}).then(function(a){n.postMessage({sourceName:s,targetName:i,callback:_l.DATA,callbackId:t.callbackId,data:a})},function(a){n.postMessage({sourceName:s,targetName:i,callback:_l.ERROR,callbackId:t.callbackId,reason:Re(a)})});return}if(t.streamId){m(this,Ye,Xu).call(this,t);return}e(t.data)},Xu=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,o=this.actionHandler[t.action],l={enqueue(c,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:Nt.ENQUEUE,streamId:e,chunk:c},u)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Nt.CLOSE,streamId:e}),delete a.streamSinks[e])},error(c){Ut(c instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Nt.ERROR,streamId:e,reason:Re(c)}))},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(c){c(o(t.data,l))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Nt.START_COMPLETE,streamId:e,success:!0})},function(c){n.postMessage({sourceName:s,targetName:i,stream:Nt.START_COMPLETE,streamId:e,reason:Re(c)})})},Yu=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 Nt.START_COMPLETE:t.success?a.startCall.resolve():a.startCall.reject(Re(t.reason));break;case Nt.PULL_COMPLETE:t.success?a.pullCall.resolve():a.pullCall.reject(Re(t.reason));break;case Nt.PULL:if(!o){n.postMessage({sourceName:s,targetName:i,stream:Nt.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 c;l((c=o.onPull)==null?void 0:c.call(o))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Nt.PULL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Nt.PULL_COMPLETE,streamId:e,reason:Re(l)})});break;case Nt.ENQUEUE:if(Ut(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case Nt.CLOSE:if(Ut(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),m(this,Ye,Dl).call(this,a,e);break;case Nt.ERROR:Ut(a,"error should have stream controller"),a.controller.error(Re(t.reason)),m(this,Ye,Dl).call(this,a,e);break;case Nt.CANCEL_COMPLETE:t.success?a.cancelCall.resolve():a.cancelCall.reject(Re(t.reason)),m(this,Ye,Dl).call(this,a,e);break;case Nt.CANCEL:if(!o)break;new Promise(function(l){var c;l((c=o.onCancel)==null?void 0:c.call(o,Re(t.reason)))}).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Nt.CANCEL_COMPLETE,streamId:e,success:!0})},function(l){n.postMessage({sourceName:s,targetName:i,stream:Nt.CANCEL_COMPLETE,streamId:e,reason:Re(l)})}),o.sinkCapability.reject(Re(t.reason)),o.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Dl=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 xn,vo;class jg{constructor({parsedData:t,rawData:e}){b(this,xn);b(this,vo);p(this,xn,t),p(this,vo,e)}getRaw(){return r(this,vo)}get(t){return r(this,xn).get(t)??null}getAll(){return md(r(this,xn))}has(t){return r(this,xn).has(t)}}xn=new WeakMap,vo=new WeakMap;const br=Symbol("INTERNAL");var wo,_o,Eo,$r;class Bg{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){b(this,wo,!1);b(this,_o,!1);b(this,Eo,!1);b(this,$r,!0);p(this,wo,!!(t&Ne.DISPLAY)),p(this,_o,!!(t&Ne.PRINT)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(r(this,Eo))return r(this,$r);if(!r(this,$r))return!1;const{print:t,view:e}=this.usage;return r(this,wo)?(e==null?void 0:e.viewState)!=="OFF":r(this,_o)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,s=!1){t!==br&&_t("Internal method `_setVisible` called."),p(this,Eo,s),p(this,$r,e)}}wo=new WeakMap,_o=new WeakMap,Eo=new WeakMap,$r=new WeakMap;var ki,pt,zr,Gr,So,Cc;class $g{constructor(t,e=Ne.DISPLAY){b(this,So);b(this,ki,null);b(this,pt,new Map);b(this,zr,null);b(this,Gr,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,Gr,t.order);for(const s of t.groups)r(this,pt).set(s.id,new Bg(e,s));if(t.baseState==="OFF")for(const s of r(this,pt).values())s._setVisible(br,!1);for(const s of t.on)r(this,pt).get(s)._setVisible(br,!0);for(const s of t.off)r(this,pt).get(s)._setVisible(br,!1);p(this,zr,this.getHash())}}isVisible(t){if(r(this,pt).size===0)return!0;if(!t)return Rh("Optional content group not defined."),!0;if(t.type==="OCG")return r(this,pt).has(t.id)?r(this,pt).get(t.id).visible:(st(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return m(this,So,Cc).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,pt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(!r(this,pt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!r(this,pt).has(e))return st(`Optional content group not found: ${e}`),!0;if(r(this,pt).get(e).visible)return!1}return!0}return st(`Unknown optional content policy ${t.policy}.`),!0}return st(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,s=!0){var n;const i=r(this,pt).get(t);if(!i){st(`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,pt).get(o))==null||n._setVisible(br,!1,!0));i._setVisible(br,!!e,!0),p(this,ki,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,pt).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,ki,null)}get hasInitialVisibility(){return r(this,zr)===null||this.getHash()===r(this,zr)}getOrder(){return r(this,pt).size?r(this,Gr)?r(this,Gr).slice():[...r(this,pt).keys()]:null}getGroups(){return r(this,pt).size>0?md(r(this,pt)):null}getGroup(t){return r(this,pt).get(t)||null}getHash(){if(r(this,ki)!==null)return r(this,ki);const t=new Ou;for(const[e,s]of r(this,pt))t.update(`${e}:${s.visible}`);return p(this,ki,t.hexdigest())}}ki=new WeakMap,pt=new WeakMap,zr=new WeakMap,Gr=new WeakMap,So=new WeakSet,Cc=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,c)=>{this._onReceiveData({begin:l,chunk:c})}),t.addProgressListener((l,c)=>{this._onProgress({loaded:l,total:c})}),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)});Ut(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(){Ut(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Gg(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Ug(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 Gg{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=yd(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 Ug{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 Wg(h){let t=!0,e=s("filename\\*","i").exec(h);if(e){e=e[1];let d=o(e);return d=unescape(d),d=l(d),d=c(d),n(d)}if(e=a(h),e){const d=c(e);return n(d)}if(e=s("filename","i").exec(h),e){e=e[1];let d=o(e);return d=c(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=kh(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 A=[];for(let y=0;y{if(!Ku(n.status))throw Ih(n.status,i);this._reader=n.body.getReader(),this._headersCapability.resolve();const a=n.headers,{allowRangeRequests:o,suggestedLength:l}=xd({responseHeaders:a,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=o,this._contentLength=l||this._contentLength,this._filename=Cd(a),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new hr("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:Ju(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,Qu(n,this._withCredentials,this._abortController)).then(o=>{if(!Ku(o.status))throw Ih(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:Ju(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const Uh=200,Wh=206;function Xg(h){const t=h.response;return typeof t!="string"?t:kh(t).buffer}class Yg{constructor({url:t,httpHeaders:e,withCredentials:s}){this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Sd(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=Wh):i.expectedStatus=Uh,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,c,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||Uh;if(!(n===Uh&&s.expectedStatus===Wh)&&n!==s.expectedStatus){(c=s.onError)==null||c.call(s,i.status);return}const o=Xg(i);if(n===Wh){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 Kg{constructor(t){this._source=t,this._manager=new Yg(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 Ut(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Qg(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new Jg(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 Qg{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}=xd({responseHeaders:s,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=n||this._contentLength,this._filename=Cd(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=Ih(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 Jg{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=Ih(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 Zg=/^[a-z][a-z0-9\-+.]+:/i;function tm(h){if(Zg.test(h))return new URL(h);const t=qi.get("url");return new URL(t.pathToFileURL(h))}function Zu(h,t,e){return h.protocol==="http:"?qi.get("http").request(h,{headers:t},e):qi.get("https").request(h,{headers:t},e)}class em{constructor(t){this.source=t,this.url=tm(t.url),this.isHttp=this.url.protocol==="http:"||this.url.protocol==="https:",this.isFsUrl=this.url.protocol==="file:",this.headers=Sd(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 Ut(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new nm(this):new sm(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=this.isFsUrl?new rm(this,t,e):new im(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 tf{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 hr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ef{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 sm extends tf{constructor(t){super(t);const e=Object.fromEntries(t.headers),s=i=>{if(i.statusCode===404){const l=new lr(`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}=xd({responseHeaders:n,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Cd(n)};this._request=Zu(this._url,e,s),this._request.on("error",i=>{this._storedError=i,this._headersCapability.reject(i)}),this._request.end()}}class im extends ef{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 lr(`Missing PDF "${this._url}".`);this._storedError=o;return}this._setReadableStream(a)};this._request=Zu(this._url,i,n),this._request.on("error",a=>{this._storedError=a}),this._request.end()}}class nm extends tf{constructor(t){super(t);const e=qi.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 lr(`Missing PDF "${this._url}".`)),this._storedError=s,this._headersCapability.reject(s)})}}class rm extends ef{constructor(t,e,s){super(t);const i=qi.get("fs");this._setReadableStream(i.createReadStream(this._url,{start:e,end:s-1}))}}const am=1e5,we=30,om=.8;var ou,Li,Se,xo,Co,Cn,Ws,To,Ro,Tn,Ur,Wr,Mi,Vr,Po,qr,Rn,ko,Lo,Mt,Pn,kn,Mo,Ii,Xr,fi,sf,nf,Rc,je,Ol,Pc,rf,af;let Tc=(Mt=class{constructor({textContentSource:t,container:e,viewport:s}){b(this,fi);b(this,Li,Promise.withResolvers());b(this,Se,null);b(this,xo,!1);b(this,Co,!!((ou=globalThis.FontInspector)!=null&&ou.enabled));b(this,Cn,null);b(this,Ws,null);b(this,To,0);b(this,Ro,0);b(this,Tn,null);b(this,Ur,null);b(this,Wr,0);b(this,Mi,0);b(this,Vr,Object.create(null));b(this,Po,[]);b(this,qr,null);b(this,Rn,[]);b(this,ko,new WeakMap);b(this,Lo,null);var l;if(t instanceof ReadableStream)p(this,qr,t);else if(typeof t=="object")p(this,qr,new ReadableStream({start(c){c.enqueue(t),c.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Se,p(this,Ur,e)),p(this,Mi,s.scale*(globalThis.devicePixelRatio||1)),p(this,Wr,s.rotation),p(this,Ws,{div:null,properties:null,ctx:null});const{pageWidth:i,pageHeight:n,pageX:a,pageY:o}=s.rawDims;p(this,Lo,[1,0,0,-1,-a,o+n]),p(this,Ro,i),p(this,To,n),m(l=Mt,je,rf).call(l),sr(e,s),r(this,Li).promise.finally(()=>{r(Mt,Xr).delete(this),p(this,Ws,null),p(this,Vr,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=be.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,Tn).read().then(({value:e,done:s})=>{if(s){r(this,Li).resolve();return}r(this,Cn)??p(this,Cn,e.lang),Object.assign(r(this,Vr),e.styles),m(this,fi,sf).call(this,e.items),t()},r(this,Li).reject)};return p(this,Tn,r(this,qr).getReader()),r(Mt,Xr).add(this),t(),r(this,Li).promise}update({viewport:t,onBefore:e=null}){var n;const s=t.scale*(globalThis.devicePixelRatio||1),i=t.rotation;if(i!==r(this,Wr)&&(e==null||e(),p(this,Wr,i),sr(r(this,Ur),{rotation:i})),s!==r(this,Mi)){e==null||e(),p(this,Mi,s);const a={div:null,properties:null,ctx:m(n=Mt,je,Ol).call(n,r(this,Cn))};for(const o of r(this,Rn))a.properties=r(this,ko).get(o),a.div=o,m(this,fi,Rc).call(this,a)}}cancel(){var e;const t=new hr("TextLayer task cancelled.");(e=r(this,Tn))==null||e.cancel(t).catch(()=>{}),p(this,Tn,null),r(this,Li).reject(t)}get textDivs(){return r(this,Rn)}get textContentItemsStr(){return r(this,Po)}static cleanup(){if(!(r(this,Xr).size>0)){r(this,Pn).clear();for(const{canvas:t}of r(this,kn).values())t.remove();r(this,kn).clear()}}},Li=new WeakMap,Se=new WeakMap,xo=new WeakMap,Co=new WeakMap,Cn=new WeakMap,Ws=new WeakMap,To=new WeakMap,Ro=new WeakMap,Tn=new WeakMap,Ur=new WeakMap,Wr=new WeakMap,Mi=new WeakMap,Vr=new WeakMap,Po=new WeakMap,qr=new WeakMap,Rn=new WeakMap,ko=new WeakMap,Lo=new WeakMap,Pn=new WeakMap,kn=new WeakMap,Mo=new WeakMap,Ii=new WeakMap,Xr=new WeakMap,fi=new WeakSet,sf=function(t){var i,n;if(r(this,xo))return;(n=r(this,Ws)).ctx??(n.ctx=m(i=Mt,je,Ol).call(i,r(this,Cn)));const e=r(this,Rn),s=r(this,Po);for(const a of t){if(e.length>am){st("Ignoring additional textDivs for performance reasons."),p(this,xo,!0);return}if(a.str===void 0){if(a.type==="beginMarkedContentProps"||a.type==="beginMarkedContent"){const o=r(this,Se);p(this,Se,document.createElement("span")),r(this,Se).classList.add("markedContent"),a.id!==null&&r(this,Se).setAttribute("id",`${a.id}`),o.append(r(this,Se))}else a.type==="endMarkedContent"&&p(this,Se,r(this,Se).parentNode);continue}s.push(a.str),m(this,fi,nf).call(this,a)}},nf=function(t){var y;const e=document.createElement("span"),s={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};r(this,Rn).push(e);const i=$.transform(r(this,Lo),t.transform);let n=Math.atan2(i[1],i[0]);const a=r(this,Vr)[t.fontName];a.vertical&&(n+=Math.PI/2);let o=r(this,Co)&&a.fontSubstitution||a.fontFamily;o=Mt.fontFamilyMap.get(o)||o;const l=Math.hypot(i[2],i[3]),c=l*m(y=Mt,je,af).call(y,o,r(this,Cn));let d,u;n===0?(d=i[4],u=i[5]-c):(d=i[4]+c*Math.sin(n),u=i[5]-c*Math.cos(n));const f="calc(var(--scale-factor)*",g=e.style;r(this,Se)===r(this,Ur)?(g.left=`${(100*d/r(this,Ro)).toFixed(2)}%`,g.top=`${(100*u/r(this,To)).toFixed(2)}%`):(g.left=`${f}${d.toFixed(2)}px)`,g.top=`${f}${u.toFixed(2)}px)`),g.fontSize=`${f}${(r(Mt,Ii)*l).toFixed(2)}px)`,g.fontFamily=o,s.fontSize=l,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,r(this,Co)&&(e.dataset.fontName=a.fontSubstitutionLoadedName||t.fontName),n!==0&&(s.angle=n*(180/Math.PI));let A=!1;if(t.str.length>1)A=!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&&(A=!0)}if(A&&(s.canvasWidth=a.vertical?t.height:t.width),r(this,ko).set(e,s),r(this,Ws).div=e,r(this,Ws).properties=s,m(this,fi,Rc).call(this,r(this,Ws)),s.hasText&&r(this,Se).append(e),s.hasEOL){const w=document.createElement("br");w.setAttribute("role","presentation"),r(this,Se).append(w)}},Rc=function(t){var o;const{div:e,properties:s,ctx:i}=t,{style:n}=e;let a="";if(r(Mt,Ii)>1&&(a=`scale(${1/r(Mt,Ii)})`),s.canvasWidth!==0&&s.hasText){const{fontFamily:l}=n,{canvasWidth:c,fontSize:d}=s;m(o=Mt,je,Pc).call(o,i,d*r(this,Mi),l);const{width:u}=i.measureText(e.textContent);u>0&&(a=`scaleX(${c*r(this,Mi)/u}) ${a}`)}s.angle!==0&&(a=`rotate(${s.angle}deg) ${a}`),a.length>0&&(n.transform=a)},je=new WeakSet,Ol=function(t=null){let e=r(this,kn).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,kn).set(t,e),r(this,Mo).set(e,{size:0,family:""})}return e},Pc=function(t,e,s){const i=r(this,Mo).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},rf=function(){if(r(this,Ii)!==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,Ii,t.getBoundingClientRect().height),t.remove()},af=function(t,e){const s=r(this,Pn).get(t);if(s)return s;const i=m(this,je,Ol).call(this,e);i.canvas.width=i.canvas.height=we,m(this,je,Pc).call(this,i,we,t);const n=i.measureText("");let a=n.fontBoundingBoxAscent,o=Math.abs(n.fontBoundingBoxDescent);if(a){const d=a/(a+o);return r(this,Pn).set(t,d),i.canvas.width=i.canvas.height=0,d}i.strokeStyle="red",i.clearRect(0,0,we,we),i.strokeText("g",0,0);let l=i.getImageData(0,0,we,we).data;o=0;for(let d=l.length-1-3;d>=0;d-=4)if(l[d]>0){o=Math.ceil(d/4/we);break}i.clearRect(0,0,we,we),i.strokeText("A",0,we),l=i.getImageData(0,0,we,we).data,a=0;for(let d=0,u=l.length;d0){a=we-Math.floor(d/4/we);break}i.canvas.width=i.canvas.height=0;const c=a?a/(a+o):om;return r(this,Pn).set(t,c),c},b(Mt,je),b(Mt,Pn,new Map),b(Mt,kn,new Map),b(Mt,Mo,new WeakMap),b(Mt,Ii,null),b(Mt,Xr,new Set),Mt);class Ya{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(Ya.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 c of n.children)i(c)}return i(t),s}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}const lm=65536,hm=100,cm=5e3,dm=ue?Eg:vg,um=ue?Sg:$u,fm=ue?_g:wg,pm=ue?xg:Wu;function gm(h={}){typeof h=="string"||h instanceof URL?h={url:h}:(h instanceof ArrayBuffer||ArrayBuffer.isView(h))&&(h={data:h});const t=new kc,{docId:e}=t,s=h.url?mm(h.url):null,i=h.data?bm(h.data):null,n=h.httpHeaders||null,a=h.withCredentials===!0,o=h.password??null,l=h.range instanceof of?h.range:null,c=Number.isInteger(h.rangeChunkSize)&&h.rangeChunkSize>0?h.rangeChunkSize:lm;let d=h.worker instanceof Er?h.worker:null;const u=h.verbosity,f=typeof h.docBaseUrl=="string"&&!Mh(h.docBaseUrl)?h.docBaseUrl:null,g=typeof h.cMapUrl=="string"?h.cMapUrl:null,A=h.cMapPacked!==!1,y=h.CMapReaderFactory||um,w=typeof h.standardFontDataUrl=="string"?h.standardFontDataUrl:null,v=h.StandardFontDataFactory||pm,_=h.stopAtErrors!==!0,S=Number.isInteger(h.maxImageSize)&&h.maxImageSize>-1?h.maxImageSize:-1,E=h.isEvalSupported!==!1,x=typeof h.isOffscreenCanvasSupported=="boolean"?h.isOffscreenCanvasSupported:!ue,C=typeof h.isChrome=="boolean"?h.isChrome:!be.platform.isFirefox&&typeof window<"u"&&!!(window!=null&&window.chrome),T=Number.isInteger(h.canvasMaxAreaInBytes)?h.canvasMaxAreaInBytes:-1,P=typeof h.disableFontFace=="boolean"?h.disableFontFace:ue,L=h.fontExtraProperties===!0,F=h.enableXfa===!0,D=h.ownerDocument||globalThis.document,Y=h.disableRange===!0,W=h.disableStream===!0,G=h.disableAutoFetch===!0,V=h.pdfBug===!0,q=h.CanvasFactory||dm,O=h.FilterFactory||fm,z=h.enableHWA===!0,St=l?l.length:h.length??NaN,It=typeof h.useSystemFonts=="boolean"?h.useSystemFonts:!ue&&!P,Ft=typeof h.useWorkerFetch=="boolean"?h.useWorkerFetch:y===$u&&v===Wu&&g&&w&&ka(g,document.baseURI)&&ka(w,document.baseURI);h.canvasFactory&&Dd("`canvasFactory`-instance option, please use `CanvasFactory` instead."),h.filterFactory&&Dd("`filterFactory`-instance option, please use `FilterFactory` instead.");const ht=null;Qp(u);const at={canvasFactory:new q({ownerDocument:D,enableHWA:z}),filterFactory:new O({docId:e,ownerDocument:D}),cMapReaderFactory:Ft?null:new y({baseUrl:g,isCompressed:A}),standardFontDataFactory:Ft?null:new v({baseUrl:w})};if(!d){const nt={verbosity:u,port:hi.workerPort};d=nt.port?Er.fromPort(nt):new Er(nt),t._worker=d}const N={docId:e,apiVersion:"4.8.69",data:i,password:o,disableAutoFetch:G,rangeChunkSize:c,length:St,docBaseUrl:f,enableXfa:F,evaluatorOptions:{maxImageSize:S,disableFontFace:P,ignoreErrors:_,isEvalSupported:E,isOffscreenCanvasSupported:x,isChrome:C,canvasMaxAreaInBytes:T,fontExtraProperties:L,useSystemFonts:It,cMapUrl:Ft?g:null,standardFontDataUrl:Ft?w:null}},lt={disableFontFace:P,fontExtraProperties:L,ownerDocument:D,pdfBug:V,styleElement:ht,loadingParams:{disableAutoFetch:G,enableXfa:F}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const nt=d.messageHandler.sendWithPromise("GetDocRequest",N,i?[i.buffer]:null);let X;if(l)X=new zg(l,{disableRange:Y,disableStream:W});else if(!i){if(!s)throw new Error("getDocument - no `url` parameter provided.");let Vt;ue?Vt=typeof fetch<"u"&&typeof Response<"u"&&"body"in Response.prototype&&ka(s)?qd:em:Vt=ka(s)?qd:Kg,X=new Vt({url:s,length:St,httpHeaders:n,withCredentials:a,rangeChunkSize:c,disableRange:Y,disableStream:W})}return nt.then(Vt=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const ne=new Na(e,Vt,d.port),mt=new wm(ne,t,X,lt,at);t._transport=mt,ne.send("Ready",null)})}).catch(t._capability.reject),t}function mm(h){if(h instanceof URL)return h.href;try{return new URL(h,window.location).href}catch{if(ue&&typeof h=="string")return h}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function bm(h){if(ue&&typeof Buffer<"u"&&h instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(h instanceof Uint8Array&&h.byteLength===h.buffer.byteLength)return h;if(typeof h=="string")return kh(h);if(h instanceof ArrayBuffer||ArrayBuffer.isView(h)||typeof h=="object"&&!isNaN(h==null?void 0:h.length))return new Uint8Array(h);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Xd(h){return typeof h=="object"&&Number.isInteger(h==null?void 0:h.num)&&h.num>=0&&Number.isInteger(h==null?void 0:h.gen)&&h.gen>=0}var bh;const Ah=class Ah{constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${fe(Ah,bh)._++}`,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)}};bh=new WeakMap,b(Ah,bh,0);let kc=Ah,of=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){_t("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}};class Am{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 Fi,Vs,qe,Ar,Nl;class ym{constructor(t,e,s,i=!1){b(this,qe);b(this,Fi,null);b(this,Vs,!1);this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Fd:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new lf,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 ul({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=Ai.ENABLE,transform:n=null,background:a=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:c=null,printAnnotationStorage:d=null,isEditing:u=!1}){var E,x;(E=this._stats)==null||E.time("Overall");const f=this._transport.getRenderingIntent(s,i,d,u),{renderingIntent:g,cacheKey:A}=f;p(this,Vs,!1),m(this,qe,Nl).call(this),o||(o=this._transport.getOptionalContentConfig(g));let y=this._intentStates.get(A);y||(y=Object.create(null),this._intentStates.set(A,y)),y.streamReaderCancelTimeout&&(clearTimeout(y.streamReaderCancelTimeout),y.streamReaderCancelTimeout=null);const w=!!(g&Ne.PRINT);y.displayReadyCapability||(y.displayReadyCapability=Promise.withResolvers(),y.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(x=this._stats)==null||x.time("Page Request"),this._pumpOperatorList(f));const v=C=>{var T;y.renderTasks.delete(_),(this._maybeCleanupAfterRender||w)&&p(this,Vs,!0),m(this,qe,Ar).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"),(T=globalThis.Stats)!=null&&T.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},_=new Mc({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:c});(y.renderTasks||(y.renderTasks=new Set)).add(_);const S=_.task;return Promise.all([y.displayReadyCapability.promise,o]).then(([C,T])=>{var P;if(this.destroyed){v();return}if((P=this._stats)==null||P.time("Rendering"),!(T.renderingIntent&g))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");_.initializeGraphics({transparency:C,optionalContentConfig:T}),_.operatorListChanged()}).catch(v),S}getOperatorList({intent:t="display",annotationMode:e=Ai.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var c;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},(c=this._stats)==null||c.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=>Ya.textContent(s));const e=this.streamTextContent(t);return new Promise(function(s,i){function n(){a.read().then(function({value:l,done:c}){if(c){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,Vs,!1),m(this,qe,Nl).call(this),Promise.all(t)}cleanup(t=!1){p(this,Vs,!0);const e=m(this,qe,Ar).call(this,!1);return t&&e&&this._stats&&(this._stats=new Fd),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){c.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,c),d())},u=>{if(c.streamReader=null,!this._transport.destroyed){if(c.operatorList){c.operatorList.lastChunk=!0;for(const f of c.renderTasks)f.operatorListChanged();m(this,qe,Ar).call(this,!0)}if(c.displayReadyCapability)c.displayReadyCapability.reject(u);else if(c.opListReadCapability)c.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 Ad){let i=hm;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 hr(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}}Fi=new WeakMap,Vs=new WeakMap,qe=new WeakSet,Ar=function(t=!1){if(m(this,qe,Nl).call(this),!r(this,Vs)||this.destroyed)return!1;if(t)return p(this,Fi,setTimeout(()=>{p(this,Fi,null),m(this,qe,Ar).call(this,!1)},cm)),!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,Vs,!1),!0},Nl=function(){r(this,Fi)&&(clearTimeout(r(this,Fi)),p(this,Fi,null))};var qs,yh;class vm{constructor(){b(this,qs,new Map);b(this,yh,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};r(this,yh).then(()=>{for(const[i]of r(this,qs))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){st("LoopbackPort - cannot use an `aborted` signal.");return}const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}r(this,qs).set(e,i)}removeEventListener(t,e){const s=r(this,qs).get(e);s==null||s(),r(this,qs).delete(e)}terminate(){for(const[,t]of r(this,qs))t==null||t();r(this,qs).clear()}}qs=new WeakMap,yh=new WeakMap;var vh,Ln,Mn,Yr,Hl,Kr,jl;const Et=class Et{constructor({name:t=null,port:e=null,verbosity:s=Jp()}={}){b(this,Yr);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(Et,Mn))!=null&&i.has(e))throw new Error("Cannot use more than one PDFWorker per port.");(r(Et,Mn)||p(Et,Mn,new WeakMap)).set(e,this),this._initializeFromPort(e);return}this._initialize()}get promise(){return ue?Promise.all([qi.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 Na("main","worker",t),this._messageHandler.on("ready",function(){}),m(this,Yr,Hl).call(this)}_initialize(){if(r(Et,Ln)||r(Et,Kr,jl)){this._setupFakeWorker();return}let{workerSrc:t}=Et;try{Et._isSameOrigin(window.location.href,t)||(t=Et._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Na("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,Yr,Hl).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{Rh("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){r(Et,Ln)||(st("Setting up fake worker."),p(Et,Ln,!0)),Et._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){this._readyCapability.reject(new Error("Worker was destroyed"));return}const e=new vm;this._port=e;const s=`fake${fe(Et,vh)._++}`,i=new Na(s+"_worker",s,e);t.setup(i,e),this._messageHandler=new Na(s,s+"_worker",e),m(this,Yr,Hl).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(Et,Mn))==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,Mn))==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 Et(t)}static get workerSrc(){if(hi.workerSrc)return hi.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return ot(this,"_setupFakeWorkerGlobal",(async()=>r(this,Kr,jl)?r(this,Kr,jl):(await import(this.workerSrc)).WorkerMessageHandler)())}};vh=new WeakMap,Ln=new WeakMap,Mn=new WeakMap,Yr=new WeakSet,Hl=function(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})},Kr=new WeakSet,jl=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},b(Et,Kr),b(Et,vh,0),b(Et,Ln,!1),b(Et,Mn),ue&&(p(Et,Ln,!0),hi.workerSrc||(hi.workerSrc="./pdf.worker.mjs")),Et._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},Et._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))};let Er=Et;var Xs,xs,Qr,Jr,Cs,In,Ha;class wm{constructor(t,e,s,i,n){b(this,In);b(this,Xs,new Map);b(this,xs,new Map);b(this,Qr,new Map);b(this,Jr,new Map);b(this,Cs,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new lf,this.fontLoader=new Ag({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 _d)}getRenderingIntent(t,e=Ai.ENABLE,s=null,i=!1,n=!1){let a=Ne.DISPLAY,o=Ac;switch(t){case"any":a=Ne.ANY;break;case"display":break;case"print":a=Ne.PRINT;break;default:st(`getRenderingIntent - invalid intent: ${t}`)}const l=a&Ne.PRINT&&s instanceof Hu?s:this.annotationStorage;switch(e){case Ai.DISABLE:a+=Ne.ANNOTATIONS_DISABLE;break;case Ai.ENABLE:break;case Ai.ENABLE_FORMS:a+=Ne.ANNOTATIONS_FORMS;break;case Ai.ENABLE_STORAGE:a+=Ne.ANNOTATIONS_STORAGE,o=l.serializable;break;default:st(`getRenderingIntent - invalid annotationMode: ${e}`)}i&&(a+=Ne.IS_EDITING),n&&(a+=Ne.OPLIST);const{ids:c,hash:d}=l.modifiedIds,u=[a,o.hash,d];return{renderingIntent:a,cacheKey:u.join("_"),annotationStorageSerializable:o,modifiedIds:c}}destroy(){var s;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(s=r(this,Cs))==null||s.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const i of r(this,xs).values())t.push(i._destroy());r(this,xs).clear(),r(this,Qr).clear(),r(this,Jr).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,Xs).clear(),this.filterFactory.destroy(),Tc.cleanup(),(i=this._networkStream)==null||i.cancelAllRequests(new hr("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)=>{Ut(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}Ut(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 c;(c=e.onProgress)==null||c.call(e,{loaded:l.loaded,total:l.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(s,i)=>{Ut(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}Ut(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 Am(s,this))}),t.on("DocException",function(s){let i;switch(s.name){case"PasswordException":i=new Kh(s.message,s.code);break;case"InvalidPDFException":i=new cu(s.message);break;case"MissingPDFException":i=new lr(s.message);break;case"UnexpectedResponseException":i=new Ph(s.message,s.status);break;case"UnknownErrorException":i=new Qh(s.message,s.details);break;default:_t("DocException - expected a valid Error.")}e._capability.reject(i)}),t.on("PasswordRequest",s=>{if(p(this,Cs,Promise.withResolvers()),e.onPassword){const i=n=>{n instanceof Error?r(this,Cs).reject(n):r(this,Cs).resolve({password:n})};try{e.onPassword(i,s.code)}catch(n){r(this,Cs).reject(n)}}else r(this,Cs).reject(new Kh(s.message,s.code));return r(this,Cs).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,xs).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:c}=this._params;if("error"in n){const g=n.error;st(`Error during font loading: ${g}`),this.commonObjs.resolve(s,g);break}const d=c&&((a=globalThis.FontInspector)!=null&&a.enabled)?(g,A)=>globalThis.FontInspector.fontAdded(g,A):null,u=new yg(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;Ut(f,"The imageRef must be defined.");for(const g of r(this,xs).values())for(const[,A]of g.objs)if((A==null?void 0:A.ref)===f)return A.dataLen?(this.commonObjs.resolve(s,structuredClone(A)),A.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,xs).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&&st("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,Qr).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,Jr).set(n.refStr,t);const a=new ym(e,n,this,this._params.pdfBug);return r(this,xs).set(e,a),a});return r(this,Qr).set(e,i),i}getPageIndex(t){return Xd(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,In,Ha).call(this,"GetFieldObjects")}hasJSActions(){return m(this,In,Ha).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,In,Ha).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,In,Ha).call(this,"GetOptionalContentConfig").then(e=>new $g(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=r(this,Xs).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 jg(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,Xs).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,xs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),r(this,Xs).clear(),this.filterFactory.destroy(!0),Tc.cleanup()}}cachedPageNumber(t){if(!Xd(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return r(this,Jr).get(e)??null}}Xs=new WeakMap,xs=new WeakMap,Qr=new WeakMap,Jr=new WeakMap,Cs=new WeakMap,In=new WeakSet,Ha=function(t,e=null){const s=r(this,Xs).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return r(this,Xs).set(t,i),i};const El=Symbol("INITIAL_DATA");var ns,Io,Lc;class lf{constructor(){b(this,Io);b(this,ns,Object.create(null))}get(t,e=null){if(e){const i=m(this,Io,Lc).call(this,t);return i.promise.then(()=>e(i.data)),null}const s=r(this,ns)[t];if(!s||s.data===El)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=r(this,ns)[t];return!!e&&e.data!==El}resolve(t,e=null){const s=m(this,Io,Lc).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in r(this,ns)){const{data:s}=r(this,ns)[e];(t=s==null?void 0:s.bitmap)==null||t.close()}p(this,ns,Object.create(null))}*[Symbol.iterator](){for(const t in r(this,ns)){const{data:e}=r(this,ns)[t];e!==El&&(yield[t,e])}}}ns=new WeakMap,Io=new WeakSet,Lc=function(t){var e;return(e=r(this,ns))[t]||(e[t]={...Promise.withResolvers(),data:El})};var Di;class _m{constructor(t){b(this,Di,null);p(this,Di,t),this.onContinue=null}get promise(){return r(this,Di).capability.promise}cancel(t=0){r(this,Di).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=r(this,Di).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=r(this,Di);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}Di=new WeakMap;var Oi,Fn;const rn=class rn{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:o,canvasFactory:l,filterFactory:c,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null}){b(this,Oi,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=c,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 _m(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(rn,Fn).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(rn,Fn).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 _r(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,Oi)&&(window.cancelAnimationFrame(r(this,Oi)),p(this,Oi,null)),r(rn,Fn).delete(this._canvas),this.callback(t||new Ad(`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,Oi,window.requestAnimationFrame(()=>{p(this,Oi,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(rn,Fn).delete(this._canvas),this.callback())))}};Oi=new WeakMap,Fn=new WeakMap,b(rn,Fn,new WeakSet);let Mc=rn;const Em="4.8.69",Sm="3634dab10";function Yd(h){return Math.floor(Math.max(0,Math.min(1,h))*255).toString(16).padStart(2,"0")}function Ra(h){return Math.max(0,Math.min(255,255*h))}class Kd{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=Ra(t),[t,t,t]}static G_HTML([t]){const e=Yd(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(Ra)}static RGB_HTML(t){return`#${t.map(Yd).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[Ra(1-Math.min(1,t+i)),Ra(1-Math.min(1,s+i)),Ra(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 xm{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){_t("Abstract method `_createSVG` called.")}}class Td extends xm{_createSVG(t){return document.createElementNS(Os,t)}}class hf{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,c=l.selectedIndex===-1?"":l[l.selectedIndex].value;i.setValue(e,{value:c})});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,c]of Object.entries(a))if(c!=null)switch(l){case"class":c.length&&t.setAttribute(l,c.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",c);break;case"style":Object.assign(t.style,c);break;case"textContent":t.textContent=c;break;default:(!o||l!=="href"&&l!=="newWindow")&&t.setAttribute(l,c)}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 c=[];if(i.children.length===0){if(i.value){const g=document.createTextNode(i.value);a.append(g),o&&Ya.shouldBuildText(i.name)&&c.push(g)}return{textDivs:c}}const d=[[i,-1,a]];for(;d.length>0;){const[g,A,y]=d.at(-1);if(A+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);c.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&&Ya.shouldBuildText(v)&&c.push(S),_.append(S)}}for(const g of l.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:c}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const pl=1e3,Cm=9,nr=new WeakSet;function ci(h){return{width:h[2]-h[0],height:h[3]-h[1]}}class Tm{static create(t){switch(t.data.annotationType){case Bt.LINK:return new cf(t);case Bt.TEXT:return new Rm(t);case Bt.WIDGET:switch(t.data.fieldType){case"Tx":return new Pm(t);case"Btn":return t.data.radioButton?new ff(t):t.data.checkBox?new Lm(t):new Mm(t);case"Ch":return new Im(t);case"Sig":return new km(t)}return new cr(t);case Bt.POPUP:return new Fc(t);case Bt.FREETEXT:return new Af(t);case Bt.LINE:return new Dm(t);case Bt.SQUARE:return new Om(t);case Bt.CIRCLE:return new Nm(t);case Bt.POLYLINE:return new yf(t);case Bt.CARET:return new jm(t);case Bt.INK:return new Rd(t);case Bt.POLYGON:return new Hm(t);case Bt.HIGHLIGHT:return new vf(t);case Bt.UNDERLINE:return new Bm(t);case Bt.SQUIGGLY:return new $m(t);case Bt.STRIKEOUT:return new zm(t);case Bt.STAMP:return new wf(t);case Bt.FILEATTACHMENT:return new Gm(t);default:return new Ot(t)}}}var Dn,Zr,ta,Fo,Ic;const Ld=class Ld{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){b(this,Fo);b(this,Dn,null);b(this,Zr,!1);b(this,ta,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 Ld._hasPopupData(this.data)}updateEdited(t){var s;if(!this.container)return;r(this,Dn)||p(this,Dn,{rect:this.data.rect.slice(0)});const{rect:e}=t;e&&m(this,Fo,Ic).call(this,e),(s=r(this,ta))==null||s.popup.updateEdited(t)}resetEdited(){var t;r(this,Dn)&&(m(this,Fo,Ic).call(this,r(this,Dn).rect),(t=r(this,ta))==null||t.popup.resetEdited(),p(this,Dn,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 cr||(n.tabIndex=pl);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 Fc){const{rotation:y}=e;return!e.hasOwnCanvas&&y!==0&&this.setRotation(y,n),n}const{width:o,height:l}=ci(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 ff){const _=`calc(${o}px * var(--scale-factor)) / calc(${l}px * var(--scale-factor))`;a.borderRadius=_}switch(e.borderStyle.style){case Ca.SOLID:a.borderStyle="solid";break;case Ca.DASHED:a.borderStyle="dashed";break;case Ca.BEVELED:st("Unimplemented border style: beveled");break;case Ca.INSET:st("Unimplemented border style: inset");break;case Ca.UNDERLINE:a.borderBottomStyle="solid";break}const v=e.borderColor||null;v?(p(this,Zr,!0),a.borderColor=$.makeHexColor(v[0]|0,v[1]|0,v[2]|0)):a.borderWidth=0}const c=$.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*(c[0]-f)/d}%`,a.top=`${100*(c[1]-g)/u}%`;const{rotation:A}=e;return e.hasOwnCanvas||A===0?(a.width=`${100*o/d}%`,a.height=`${100*l/u}%`):this.setRotation(A,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}=ci(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]=Kd[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[s]:Kd[`${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,Zr)){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,c=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"),A=`clippath_${this.data.id}`;g.setAttribute("id",A),g.setAttribute("clipPathUnits","objectBoundingBox"),f.append(g);for(let y=2,w=t.length;y`)}r(this,Zr)&&(o.push("')"),a.backgroundImage=o.join("")),this.container.append(u),this.container.style.clipPath=`url(#${A})`}_createPopup(){const{data:t}=this,e=p(this,ta,new Fc({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]}));this.parent.div.append(e.render())}render(){_t("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const 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,c=document.querySelector(`[data-element-id="${a}"]`);if(c&&!nr.has(c)){st(`_getElementsByName - element not allowed: ${a}`);continue}s.push({id:a,exportValue:l,domElement:c})}return s}for(const i of document.getElementsByName(t)){const{exportValue:n}=i,a=i.getAttribute("data-element-id");a!==e&&nr.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})})}};Dn=new WeakMap,Zr=new WeakMap,ta=new WeakMap,Fo=new WeakSet,Ic=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:c,height:d}=ci(t);e.left=`${100*(t[0]-o)/n}%`,e.top=`${100*(a-t[3]+l)/a}%`,i===0?(e.width=`${100*c/n}%`,e.height=`${100*d/a}%`):this.setRotation(i)};let Ot=Ld;var He,Zi,df,uf;class cf extends Ot{constructor(e,s=null){super(e,{isRenderable:!0,ignoreBorder:!!(s!=null&&s.ignoreBorder),createQuadrilaterals:!0});b(this,He);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,He,df).call(this,i,e.attachment,e.attachmentDest),n=!0):e.setOCGState?(m(this,He,uf).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,He,Zi).call(this)}_bindNamedAction(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(s),!1),m(this,He,Zi).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,He,Zi).call(this)}_bindResetFormAction(e,s){const i=e.onclick;if(i||(e.href=this.linkService.getAnchorUrl("")),m(this,He,Zi).call(this),!this._fieldObjects){st('_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 A=this._fieldObjects[g]||[];for(const{id:y}of A)f.add(y)}for(const g of Object.values(this._fieldObjects))for(const A of g)f.has(A.id)===o&&l.push(A)}else for(const f of Object.values(this._fieldObjects))l.push(...f);const c=this.annotationStorage,d=[];for(const f of l){const{id:g}=f;switch(d.push(g),f.type){case"text":{const y=f.defaultValue||"";c.setValue(g,{value:y});break}case"checkbox":case"radiobutton":{const y=f.defaultValue===f.exportValues;c.setValue(g,{value:y});break}case"combobox":case"listbox":{const y=f.defaultValue||"";c.setValue(g,{value:y});break}default:continue}const A=document.querySelector(`[data-element-id="${g}"]`);if(A){if(!nr.has(A)){st(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;A.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}}}He=new WeakSet,Zi=function(){this.container.setAttribute("data-internal-link","")},df=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,He,Zi).call(this)},uf=function(e,s){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(s),!1),m(this,He,Zi).call(this)};class Rm extends Ot{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 cr extends Ot{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 be.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,c]of s)(c==="Action"||(n=this.data.actions)!=null&&n[c])&&((c==="Focus"||c==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,l,c,i),c==="Focus"&&!((a=this.data.actions)!=null&&a.Blur)?this._setEventListener(t,e,"blur","Blur",null):c==="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||Cm,n=t.style;let a;const o=2,l=c=>Math.round(10*c)/10;if(this.data.multiLine){const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o),d=Math.round(c/(Bh*i))||1,u=c/d;a=Math.min(i,l(u/Bh))}else{const c=Math.abs(this.data.rect[3]-this.data.rect[1]-o);a=Math.min(i,l(c/Bh))}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 Pm extends cr{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 c=a.formattedValue||((i=this.data.textContent)==null?void 0:i.join(` +`))||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const d={userValue:o,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(s=document.createElement("textarea"),s.textContent=c??o,this.data.doNotScroll&&(s.style.overflowY="hidden")):(s=document.createElement("input"),s.type="text",s.setAttribute("value",c??o),this.data.doNotScroll&&(s.style.overflowX="hidden")),this.data.hasOwnCanvas&&(s.hidden=!0),nr.add(s),s.setAttribute("data-element-id",e),s.disabled=this.data.readOnly,s.name=this.data.fieldName,s.tabIndex=pl,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:A}=g;d.userValue&&(A.value=d.userValue),d.lastCommittedValue=A.value,d.commitKey=1,(y=this.data.actions)!=null&&y.Focus||(d.focused=!0)}),s.addEventListener("updatefromsandbox",g=>{this.showElementAndHideCanvas(g.target);const A={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(A,g)}),s.addEventListener("keydown",g=>{var w;d.commitKey=1;let A=-1;if(g.key==="Escape"?A=0:g.key==="Enter"&&!this.data.multiLine?A=2:g.key==="Tab"&&(d.commitKey=3),A===-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:A,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:A}=g.target;d.userValue=A,d.lastCommittedValue!==A&&((w=this.linkService.eventBus)==null||w.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,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 x;d.lastCommittedValue=null;const{data:A,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(),(x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:w,change:A||"",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 km extends cr{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class Lm extends cr{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 nr.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=pl,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s)){const d=l&&c.exportValue===e.exportValue;c.domElement&&(c.domElement.checked=d),t.setValue(c.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 ff extends cr{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(nr.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=pl,n.addEventListener("change",a=>{const{name:o,checked:l}=a.target;for(const c of this._getElementsByName(o,s))t.setValue(c.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:c=>{const d=a===c.detail.value;for(const u of this._getElementsByName(c.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 Mm extends cf{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 Im extends cr{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");nr.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=pl;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,A=>A.selected).map(A=>A[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let l=o(!1);const c=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,A=new Set(Array.isArray(g)?g:[g]);for(const y of i.options)y.selected=A.has(y.value);t.setValue(e,{value:o(!0)}),l=o(!1)},multipleSelection(f){i.multiple=!0},remove(f){const g=i.options,A=f.detail.remove;g[A].selected=!1,i.remove(A),g.length>0&&Array.prototype.findIndex.call(g,w=>w.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:o(!0),items:c(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:A,exportValue:y}=f.detail.insert,w=i.children[g],v=document.createElement("option");v.textContent=A,v.value=y,w?w.before(v):i.append(v),t.setValue(e,{value:o(!0),items:c(f)}),l=o(!1)},items(f){const{items:g}=f.detail;for(;i.length!==0;)i.remove(0);for(const A of g){const{displayValue:y,exportValue:w}=A,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:c(f)}),l=o(!1)},indices(f){const g=new Set(f.detail.indices);for(const A of f.target.options)A.selected=g.has(A.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 Fc extends Ot{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Ot._hasPopupData(e)}),this.elements=s,this.popup=null}render(){this.container.classList.add("popupAnnotation");const t=this.popup=new Fm({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=>`${bd}${s}`).join(",")),this.container}}var ea,wh,_h,sa,On,Lt,Ys,ia,Do,Oo,na,Ks,rs,Qs,No,Js,Ho,Nn,Hn,yt,Bl,Dc,pf,gf,mf,bf,$l,zl,Oc;class Fm{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:o,parent:l,rect:c,parentRect:d,open:u}){b(this,yt);b(this,ea,m(this,yt,mf).bind(this));b(this,wh,m(this,yt,Oc).bind(this));b(this,_h,m(this,yt,zl).bind(this));b(this,sa,m(this,yt,$l).bind(this));b(this,On,null);b(this,Lt,null);b(this,Ys,null);b(this,ia,null);b(this,Do,null);b(this,Oo,null);b(this,na,null);b(this,Ks,!1);b(this,rs,null);b(this,Qs,null);b(this,No,null);b(this,Js,null);b(this,Ho,null);b(this,Nn,null);b(this,Hn,!1);var f;p(this,Lt,t),p(this,Ho,i),p(this,Ys,a),p(this,Js,o),p(this,Oo,l),p(this,On,e),p(this,No,c),p(this,na,d),p(this,Do,s),p(this,ia,vd.toDateObject(n)),this.trigger=s.flatMap(g=>g.getElementsToTriggerPopup());for(const g of this.trigger)g.addEventListener("click",r(this,sa)),g.addEventListener("mouseenter",r(this,_h)),g.addEventListener("mouseleave",r(this,wh)),g.classList.add("popupTriggerArea");for(const g of s)(f=g.container)==null||f.addEventListener("keydown",r(this,ea));r(this,Lt).hidden=!0,u&&m(this,yt,$l).call(this)}render(){if(r(this,rs))return;const t=p(this,rs,document.createElement("div"));if(t.className="popup",r(this,On)){const n=t.style.outlineColor=$.makeHexColor(...r(this,On));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,On).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,Ho),t.append(e),r(this,ia)){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,ia).valueOf()})),e.append(n)}const i=r(this,yt,Bl);if(i)hf.render({xfaHtml:i,intent:"richText",div:t}),t.lastChild.classList.add("richText","popupContent");else{const n=this._formatContents(r(this,Ys));t.append(n)}r(this,Lt).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,Wo,Nc).call(this)}),!s.popupRef&&this.hasPopupData?this._createPopup():i.classList.add("popupTriggerArea"),e.append(i),e}getElementsToTriggerPopup(){return r(this,Uo)}addHighlightArea(){this.container.classList.add("highlightArea")}}Uo=new WeakMap,Wo=new WeakSet,Nc=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};var Vo,jn,Bn,qo,ar,_f,Hc,lu;let Um=(lu=class{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:o}){b(this,ar);b(this,Vo,null);b(this,jn,null);b(this,Bn,new Map);b(this,qo,null);this.div=t,p(this,Vo,e),p(this,jn,s),p(this,qo,o||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return r(this,Bn).size>0}async render(t){var a;const{annotations:e}=t,s=this.div;sr(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 Td,annotationStorage:t.annotationStorage||new _d,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===Bt.POPUP;if(l){const u=i.get(o.id);if(!u)continue;n.elements=u}else{const{width:u,height:f}=ci(o.rect);if(u<=0||f<=0)continue}n.data=o;const c=Tm.create(n);if(!c.isRenderable)continue;if(!l&&o.popupRef){const u=i.get(o.popupRef);u?u.push(c):i.set(o.popupRef,[c])}const d=c.render();o.hidden&&(d.style.visibility="hidden"),await m(this,ar,_f).call(this,d,o.id),c._isEditable&&(r(this,Bn).set(c.data.id,c),(a=this._annotationEditorUIManager)==null||a.renderAnnotationElement(c))}m(this,ar,Hc).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,sr(e,{rotation:t.rotation}),m(this,ar,Hc).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(r(this,Bn).values())}getEditableAnnotation(t){return r(this,Bn).get(t)}},Vo=new WeakMap,jn=new WeakMap,Bn=new WeakMap,qo=new WeakMap,ar=new WeakSet,_f=async function(t,e){var a,o;const s=t.firstChild||t,i=s.id=`${bd}${e}`,n=await((a=r(this,qo))==null?void 0:a.getAriaAttributes(i));if(n)for(const[l,c]of n)s.setAttribute(l,c);this.div.append(t),(o=r(this,Vo))==null||o.moveElementInDOM(this.div,t,s,!1)},Hc=function(){if(!r(this,jn))return;const t=this.div;for(const[e,s]of r(this,jn)){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,jn).clear()},lu);const Sl=/\r\n?|\n/g;var as,Le,Xo,$n,Me,jt,Ef,Sf,xf,Gl,ui,Ul,Wl,Cf,Bc,Tf;const wt=class wt extends gt{constructor(e){super({...e,name:"freeTextEditor"});b(this,jt);b(this,as);b(this,Le,"");b(this,Xo,`${this.id}-editor`);b(this,$n,null);b(this,Me);p(this,as,e.color||wt._defaultColor||gt._defaultLineColor),p(this,Me,e.fontSize||wt._defaultFontSize)}static get _keyboardManager(){const e=wt.prototype,s=a=>a.isEmpty(),i=ir.TRANSLATE_SMALL,n=ir.TRANSLATE_BIG;return ot(this,"_keyboardManager",new fl([[["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){gt.initialize(e,s);const i=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(i.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,s){switch(e){case Q.FREETEXT_SIZE:wt._defaultFontSize=s;break;case Q.FREETEXT_COLOR:wt._defaultColor=s;break}}updateParams(e,s){switch(e){case Q.FREETEXT_SIZE:m(this,jt,Ef).call(this,s);break;case Q.FREETEXT_COLOR:m(this,jt,Sf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Q.FREETEXT_SIZE,wt._defaultFontSize],[Q.FREETEXT_COLOR,wt._defaultColor||gt._defaultLineColor]]}get propertiesToUpdate(){return[[Q.FREETEXT_SIZE,r(this,Me)],[Q.FREETEXT_COLOR,r(this,as)]]}_translateEmpty(e,s){this._uiManager.translateSelectedEditors(e,s,!0)}getInitialTranslation(){const e=this.parentScale;return[-wt._internalPadding*e,-(wt._internalPadding+r(this,Me))*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,$n,new AbortController);const e=this._uiManager.combinedSignal(r(this,$n));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,Xo)),this._isDraggable=!0,(e=r(this,$n))==null||e.abort(),p(this,$n,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,Le),s=p(this,Le,m(this,jt,xf).call(this).trimEnd());if(e===s)return;const i=n=>{if(p(this,Le,n),!n){this.remove();return}m(this,jt,Wl).call(this),this._uiManager.rebuild(this),m(this,jt,Gl).call(this)};this.addCommands({cmd:()=>{i(s)},undo:()=>{i(e)},mustExec:!1}),m(this,jt,Gl).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){wt._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,Xo)),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,Me)}px * var(--scale-factor))`,i.color=r(this,as),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),ih(this,this.div,["dblclick","keydown"]),this.width){const[n,a]=this.parentDimensions;if(this.annotationElementId){const{position:o}=this._initialData;let[l,c]=this.getInitialTranslation();[l,c]=this.pageTranslationToScreen(l,c);const[d,u]=this.pageDimensions,[f,g]=this.pageTranslation;let A,y;switch(this.rotation){case 0:A=e+(o[0]-f)/d,y=s+this.height-(o[1]-g)/u;break;case 90:A=e+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,c]=[c,-l];break;case 180:A=e-this.width+(o[0]-f)/d,y=s-(o[1]-g)/u,[l,c]=[-l,-c];break;case 270:A=e+(o[0]-f-this.height*u)/d,y=s+(o[1]-g-this.width*d)/u,[l,c]=[-c,l];break}this.setAt(A*n,y*a,l,c)}else this.setAt(e*n,s*a,this.width*n,this.height*a);m(this,jt,Wl).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var A,y,w;const s=e.clipboardData||window.clipboardData,{types:i}=s;if(i.length===1&&i[0]==="text/plain")return;e.preventDefault();const n=m(A=wt,ui,Bc).call(A,s.getData("text")||"").replaceAll(Sl,` +`);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:c}=o,d=[],u=[];if(l.nodeType===Node.TEXT_NODE){const v=l.parentElement;if(u.push(l.nodeValue.slice(c).replaceAll(Sl,"")),v!==this.editorDiv){let _=d;for(const S of this.editorDiv.childNodes){if(S===v){_=u;continue}_.push(m(y=wt,ui,Ul).call(y,S))}}d.push(l.nodeValue.slice(0,c).replaceAll(Sl,""))}else if(l===this.editorDiv){let v=d,_=0;for(const S of this.editorDiv.childNodes)_++===c&&(v=u),v.push(m(w=wt,ui,Ul).call(w,S))}p(this,Le,`${d.join(` +`)}${n}${u.join(` +`)}`),m(this,jt,Wl).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 Af){const{data:{defaultAppearanceData:{fontSize:l,fontColor:c},rect:d,rotation:u,id:f,popupRef:g},textContent:A,textPosition:y,parent:{page:{pageNumber:w}}}=e;if(!A||A.length===0)return null;n=e={annotationType:tt.FREETEXT,color:Array.from(c),fontSize:l,value:A.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,Me,e.fontSize),p(a,as,$.makeHexColor(...e.color)),p(a,Le,m(o=wt,ui,Bc).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=wt._internalPadding*this.parentScale,i=this.getRect(s,s),n=gt._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:r(this,as)),a={annotationType:tt.FREETEXT,color:n,fontSize:r(this,Me),value:m(this,jt,Cf).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!m(this,jt,Tf).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,Me)}px * var(--scale-factor))`,i.color=r(this,as),s.replaceChildren();for(const a of r(this,Le).split(` +`)){const o=document.createElement("div");o.append(a?document.createTextNode(a):document.createElement("br")),s.append(o)}const n=wt._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(n,n),popupContent:r(this,Le)}),s}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};as=new WeakMap,Le=new WeakMap,Xo=new WeakMap,$n=new WeakMap,Me=new WeakMap,jt=new WeakSet,Ef=function(e){const s=n=>{this.editorDiv.style.fontSize=`calc(${n}px * var(--scale-factor))`,this.translate(0,-(n-r(this,Me))*this.parentScale),p(this,Me,n),m(this,jt,Gl).call(this)},i=r(this,Me);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},Sf=function(e){const s=n=>{p(this,as,this.editorDiv.style.color=n)},i=r(this,as);this.addCommands({cmd:s.bind(this,e),undo:s.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Q.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},xf=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=wt,ui,Ul).call(i,n)),s=n);return e.join(` +`)},Gl=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()},ui=new WeakSet,Ul=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Sl,"")},Wl=function(){if(this.editorDiv.replaceChildren(),!!r(this,Le))for(const e of r(this,Le).split(` +`)){const s=document.createElement("div");s.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(s)}},Cf=function(){return r(this,Le).replaceAll(" "," ")},Bc=function(e){return e.replaceAll(" "," ")},Tf=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},b(wt,ui),K(wt,"_freeTextDefaultContent",""),K(wt,"_internalPadding",0),K(wt,"_defaultColor",null),K(wt,"_defaultFontSize",10),K(wt,"_type","freetext"),K(wt,"_editorType",tt.FREETEXT);let jc=wt;class Rf{toSVGPath(){_t("Abstract method `toSVGPath` must be implemented.")}get box(){_t("Abstract getter `box` must be implemented.")}serialize(t,e){_t("Abstract method `serialize` must be implemented.")}get classNamesForDrawing(){_t("Abstract getter `classNamesForDrawing` must be implemented.")}get classNamesForOutlining(){_t("Abstract getter `classNamesForOutlining` must be implemented.")}get mustRemoveSelfIntersections(){return!1}}var Ie,os,ra,aa,Ts,it,zn,Gn,Yo,Ko,oa,la,Ni,Qo,Eh,Sh,Wt,ja,Pf,kf,Lf,Mf,If,Ff;const Hs=class Hs{constructor({x:t,y:e},s,i,n,a,o=0){b(this,Wt);b(this,Ie);b(this,os,[]);b(this,ra);b(this,aa);b(this,Ts,[]);b(this,it,new Float64Array(18));b(this,zn);b(this,Gn);b(this,Yo);b(this,Ko);b(this,oa);b(this,la);b(this,Ni,[]);p(this,Ie,s),p(this,la,n*i),p(this,aa,a),r(this,it).set([NaN,NaN,NaN,NaN,t,e],6),p(this,ra,o),p(this,Ko,r(Hs,Qo)*i),p(this,Yo,r(Hs,Sh)*i),p(this,oa,i),r(this,Ni).push(t,e)}isEmpty(){return isNaN(r(this,it)[8])}add({x:t,y:e}){var L;p(this,zn,t),p(this,Gn,e);const[s,i,n,a]=r(this,Ie);let[o,l,c,d]=r(this,it).subarray(8,12);const u=t-c,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,Wt,kf).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Df(t,e,s,i,n,a)}getOutlines(){var u;const t=r(this,Ts),e=r(this,os),s=r(this,it),[i,n,a,o]=r(this,Ie),l=new Float64Array((((u=r(this,Ni))==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])){c[d]=c[d+1]=NaN,d+=2;continue}c[d]=e[f+g],c[d+1]=e[f+g+1],d+=2}return m(this,Wt,If).call(this,c,d),this.newFreeDrawOutline(c,l,r(this,Ie),r(this,oa),r(this,ra),r(this,aa))}};Ie=new WeakMap,os=new WeakMap,ra=new WeakMap,aa=new WeakMap,Ts=new WeakMap,it=new WeakMap,zn=new WeakMap,Gn=new WeakMap,Yo=new WeakMap,Ko=new WeakMap,oa=new WeakMap,la=new WeakMap,Ni=new WeakMap,Qo=new WeakMap,Eh=new WeakMap,Sh=new WeakMap,Wt=new WeakSet,ja=function(){const t=r(this,it).subarray(4,6),e=r(this,it).subarray(16,18),[s,i,n,a]=r(this,Ie);return[(r(this,zn)+(t[0]-e[0])/2-s)/n,(r(this,Gn)+(t[1]-e[1])/2-i)/a,(r(this,zn)+(e[0]-t[0])/2-s)/n,(r(this,Gn)+(e[1]-t[1])/2-i)/a]},Pf=function(){const[t,e,s,i]=r(this,Ie),[n,a,o,l]=m(this,Wt,ja).call(this);return`M${(r(this,it)[2]-t)/s} ${(r(this,it)[3]-e)/i} L${(r(this,it)[4]-t)/s} ${(r(this,it)[5]-e)/i} L${n} ${a} L${o} ${l} L${(r(this,it)[16]-t)/s} ${(r(this,it)[17]-e)/i} L${(r(this,it)[14]-t)/s} ${(r(this,it)[15]-e)/i} Z`},kf=function(t){const e=r(this,os);t.push(`L${e[4]} ${e[5]} Z`)},Lf=function(t){const[e,s,i,n]=r(this,Ie),a=r(this,it).subarray(4,6),o=r(this,it).subarray(16,18),[l,c,d,u]=m(this,Wt,ja).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${l} ${c} L${d} ${u} L${(o[0]-e)/i} ${(o[1]-s)/n}`)},Mf=function(t){const e=r(this,it),[s,i,n,a]=r(this,Ie),[o,l,c,d]=m(this,Wt,ja).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,c,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,Ie),r(this,oa),r(this,ra),r(this,aa))},If=function(t,e){const s=r(this,os);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+=6},Ff=function(t,e){const s=r(this,it).subarray(4,6),i=r(this,it).subarray(16,18),[n,a,o,l]=r(this,Ie),[c,d,u,f]=m(this,Wt,ja).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/o,(s[1]-a)/l,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(i[0]-n)/o,(i[1]-a)/l],e),e+=24},b(Hs,Qo,8),b(Hs,Eh,2),b(Hs,Sh,r(Hs,Qo)+r(Hs,Eh));let rh=Hs;var ha,Un,Zs,Jo,Fe,Zo,Dt,Te,Ba,$a,Of;class Df extends Rf{constructor(e,s,i,n,a,o){super();b(this,Te);b(this,ha);b(this,Un,null);b(this,Zs);b(this,Jo);b(this,Fe);b(this,Zo);b(this,Dt);p(this,Dt,e),p(this,Fe,s),p(this,ha,i),p(this,Zo,n),p(this,Zs,a),p(this,Jo,o),m(this,Te,Of).call(this,o);const{x:l,y:c,width:d,height:u}=r(this,Un);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,Hi))e[3]?(t.push(...m(this,ye,$c).call(this,e)),m(this,ye,Hf).call(this,e)):(m(this,ye,jf).call(this,e),t.push(...m(this,ye,$c).call(this,e)));return m(this,ye,Nf).call(this,t)}}tl=new WeakMap,Hi=new WeakMap,ls=new WeakMap,ye=new WeakSet,Nf=function(t){const e=[],s=new Set;for(const a of t){const[o,l,c]=a;e.push([o,l,a],[o,c,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,c,d,u]=a;s.delete(a);let f=o,g=l;for(n=[o,c],i.push(n);;){let A;if(s.has(d))A=d;else if(s.has(u))A=u;else break;s.delete(A),[o,l,c,d,u]=A,f!==o&&(n.push(f,g,o,g===l?l:c),f=o),g=g===l?c:l}n.push(f,g)}return new Wm(i,r(this,tl))},Vl=function(t){const e=r(this,ls);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,ls)[i];if(n!==t)break;if(n===t&&a===e){r(this,ls).splice(i,1);return}}},$c=function(t){const[e,s,i]=t,n=[[e,s,i]],a=m(this,ye,Vl).call(this,i);for(let o=0;o=l){if(g>c)n[d][1]=c;else{if(u===1)return[];n.splice(d,1),d--,u--}continue}n[d][2]=l,g>c&&n.push([e,c,g])}}}return n};var el,ca;class Wm extends Rf{constructor(e,s){super();b(this,el);b(this,ca);p(this,ca,e),p(this,el,s)}toSVGPath(){const e=[];for(const s of r(this,ca)){let[i,n]=s;e.push(`M${i} ${n}`);for(let a=2;a-1?(p(this,xe,!0),m(this,Z,ql).call(this,e),m(this,Z,en).call(this)):r(this,ti)&&(p(this,pa,e.anchorNode),p(this,al,e.anchorOffset),p(this,ol,e.focusNode),p(this,ll,e.focusOffset),m(this,Z,Vc).call(this),m(this,Z,en).call(this),this.rotate(this.rotation))}static get _keyboardManager(){const e=dt.prototype;return ot(this,"_keyboardManager",new fl([[["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,xe)?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:r(this,We),methodOfCreation:r(this,hl)}}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;gt.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 Q.HIGHLIGHT_DEFAULT_COLOR:dt._defaultColor=s;break;case Q.HIGHLIGHT_THICKNESS:dt._defaultThickness=s;break}}translateInPage(e,s){}get toolbarPosition(){return r(this,ma)}updateParams(e,s){switch(e){case Q.HIGHLIGHT_COLOR:m(this,Z,$f).call(this,s);break;case Q.HIGHLIGHT_THICKNESS:m(this,Z,zf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Q.HIGHLIGHT_DEFAULT_COLOR,dt._defaultColor],[Q.HIGHLIGHT_THICKNESS,dt._defaultThickness]]}get propertiesToUpdate(){return[[Q.HIGHLIGHT_COLOR,this.color||dt._defaultColor],[Q.HIGHLIGHT_THICKNESS,r(this,We)||dt._defaultThickness],[Q.HIGHLIGHT_FREE,r(this,xe)]]}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(p(this,ga,new ah({editor:this})),e.addColorPicker(r(this,ga))),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,za).call(this))}getBaseTranslation(){return[0,0]}getRect(e,s){return super.getRect(e,s,m(this,Z,za).call(this))}onceAdded(){this.annotationElementId||this.parent.addUndoableEditor(this),this.div.focus()}remove(){m(this,Z,qc).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(m(this,Z,en).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var i;let s=!1;this.parent&&!e?m(this,Z,qc).call(this):e&&(m(this,Z,en).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,xe)?(e=(e-this.rotation+360)%360,i=m(n=dt,Xe,yr).call(n,r(this,ds).box,e)):i=m(a=dt,Xe,yr).call(a,this,e),s.rotate(r(this,he),e),s.rotate(r(this,Gt),e),s.updateBox(r(this,he),i),s.updateBox(r(this,Gt),m(o=dt,Xe,yr).call(o,r(this,Ue).box,e))}render(){if(this.div)return this.div;const e=super.render();r(this,ba)&&(e.setAttribute("aria-label",r(this,ba)),e.setAttribute("role","mark")),r(this,xe)?e.classList.add("free"):this.div.addEventListener("keydown",m(this,Z,Uf).bind(this),{signal:this._uiManager._signal});const s=p(this,qn,document.createElement("div"));e.append(s),s.setAttribute("aria-hidden","true"),s.className="internal",s.style.clipPath=r(this,Vn);const[i,n]=this.parentDimensions;return this.setDims(this.width*i,this.height*n),ih(this,r(this,qn),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent.drawLayer.addClass(r(this,Gt),"hovered")}pointerleave(){this.isSelected||this.parent.drawLayer.removeClass(r(this,Gt),"hovered")}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:m(this,Z,Xl).call(this,!0);break;case 1:case 3:m(this,Z,Xl).call(this,!1);break}}select(){var e,s;super.select(),r(this,Gt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Gt),"hovered"),(s=this.parent)==null||s.drawLayer.addClass(r(this,Gt),"selected"))}unselect(){var e;super.unselect(),r(this,Gt)&&((e=this.parent)==null||e.drawLayer.removeClass(r(this,Gt),"selected"),r(this,xe)||m(this,Z,Xl).call(this,!1))}get _mustFixPosition(){return!r(this,xe)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(r(this,he),e),this.parent.drawLayer.show(r(this,Gt),e))}static startHighlighting(e,s,{target:i,x:n,y:a}){const{x:o,y:l,width:c,height:d}=i.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),g=y=>{y.preventDefault(),y.stopPropagation()},A=y=>{u.abort(),m(this,Xe,Xf).call(this,e,y)};window.addEventListener("blur",A,{signal:f}),window.addEventListener("pointerup",A,{signal:f}),window.addEventListener("pointerdown",g,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Ke,{signal:f}),i.addEventListener("pointermove",m(this,Xe,qf).bind(this,e),{signal:f}),this._freeHighlight=new zc({x:n,y:a},[o,l,c,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 vf){const{data:{quadPoints:S,rect:E,rotation:x,id:C,color:T,opacity:P,popupRef:L},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),opacity:P,quadPoints:S,boxes:null,pageIndex:F-1,rect:E.slice(0),rotation:x,id:C,deleted:!1,popupRef:L}}else if(e instanceof Rd){const{data:{inkLists:S,rect:E,rotation:x,id:C,color:T,borderStyle:{rawWidth:P},popupRef:L},parent:{page:{pageNumber:F}}}=e;n=e={annotationType:tt.HIGHLIGHT,color:Array.from(T),thickness:P,inkLists:S,boxes:null,pageIndex:F-1,rect:E.slice(0),rotation:x,id:C,deleted:!1,popupRef:L}}const{color:a,quadPoints:o,inkLists:l,opacity:c}=e,d=await super.deserialize(e,s,i);d.color=$.makeHexColor(...a),p(d,ei,c||1),l&&p(d,We,e.thickness),d.annotationElementId=e.id||null,d._initialData=n;const[u,f]=d.pageDimensions,[g,A]=d.pageTranslation;if(o){const S=p(d,ti,[]);for(let E=0;E=0)p(this,he,s),p(this,Vn,i),this.parent.drawLayer.finalizeLine(s,e),p(this,Gt,this.parent.drawLayer.drawOutline(r(this,Ue)));else if(this.parent){const g=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(r(this,he),e),this.parent.drawLayer.updateBox(r(this,he),m(u=dt,Xe,yr).call(u,r(this,ds).box,(g-this.rotation+360)%360)),this.parent.drawLayer.updateLine(r(this,Gt),r(this,Ue)),this.parent.drawLayer.updateBox(r(this,Gt),m(f=dt,Xe,yr).call(f,r(this,Ue).box,g))}const{x:a,y:o,width:l,height:c}=e.box;switch(this.rotation){case 0:this.x=a,this.y=o,this.width=l,this.height=c;break;case 90:{const[g,A]=this.parentDimensions;this.x=o,this.y=1-a,this.width=l*A/g,this.height=c*g/A;break}case 180:this.x=1-a,this.y=1-o,this.width=l,this.height=c;break;case 270:{const[g,A]=this.parentDimensions;this.x=1-o,this.y=a,this.width=l*A/g,this.height=c*g/A;break}}const{lastPoint:d}=r(this,Ue).box;p(this,ma,[(d[0]-a)/l,(d[1]-o)/c])},$f=function(e){const s=(a,o)=>{var l,c,d;this.color=a,(l=this.parent)==null||l.drawLayer.changeColor(r(this,he),a),(c=r(this,ga))==null||c.updateColor(a),p(this,ei,o),(d=this.parent)==null||d.drawLayer.changeOpacity(r(this,he),o)},i=this.color,n=r(this,ei);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:Q.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)},zf=function(e){const s=r(this,We),i=n=>{p(this,We,n),m(this,Z,Gf).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:Q.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Gf=function(e){if(!r(this,xe))return;m(this,Z,ql).call(this,{highlightOutlines:r(this,ds).getNewOutline(e/2)}),this.fixAndSetPosition();const[s,i]=this.parentDimensions;this.setDims(this.width*s,this.height*i)},qc=function(){r(this,he)===null||!this.parent||(this.parent.drawLayer.remove(r(this,he)),p(this,he,null),this.parent.drawLayer.remove(r(this,Gt)),p(this,Gt,null))},en=function(e=this.parent){r(this,he)===null&&({id:fe(this,he)._,clipPathId:fe(this,Vn)._}=e.drawLayer.draw(r(this,ds),this.color,r(this,ei)),p(this,Gt,e.drawLayer.drawOutline(r(this,Ue))),r(this,qn)&&(r(this,qn).style.clipPath=r(this,Vn)))},Xe=new WeakSet,yr=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}},Uf=function(e){dt._keyboardManager.exec(this,e)},Xl=function(e){if(!r(this,pa))return;const s=window.getSelection();e?s.setPosition(r(this,pa),r(this,al)):s.setPosition(r(this,ol),r(this,ll))},za=function(){return r(this,xe)?this.rotation:0},Wf=function(){if(r(this,xe))return null;const[e,s]=this.pageDimensions,[i,n]=this.pageTranslation,a=r(this,ti),o=new Float32Array(a.length*8);let l=0;for(const{x:c,y:d,width:u,height:f}of a){const g=c*e+i,A=(1-d-f)*s+n;o[l]=o[l+4]=g,o[l+1]=o[l+3]=A,o[l+2]=o[l+6]=g+u*e,o[l+5]=o[l+7]=A+f*s,l+=8}return o},Vf=function(e){return r(this,ds).serialize(e,m(this,Z,za).call(this))},qf=function(e,s){this._freeHighlight.add(s)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)},Xf=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=""},Yf=function(e){const{color:s}=this._initialData;return e.color.some((i,n)=>i!==s[n])},b(dt,Xe),K(dt,"_defaultColor",null),K(dt,"_defaultOpacity",1),K(dt,"_defaultThickness",12),K(dt,"_type","highlight"),K(dt,"_editorType",tt.HIGHLIGHT),K(dt,"_freeHighlightId",-1),K(dt,"_freeHighlight",null),K(dt,"_freeHighlightClipId","");let oh=dt;var Xn,Yn,Rs,si,Ve,Kn,Qn,Jn,ii,Aa,Zn,tr,Bi,M,Kf,Qf,Jf,Zf,Yc,tp,Kc,ep,sp,ip,np,rp,sn,Qc,Jc,Zc,Yl,Kl,vr,td,Ql,pi,ap,ed,op,lp,sd,Jl,Ga;const Ct=class Ct extends gt{constructor(e){super({...e,name:"inkEditor"});b(this,M);b(this,Xn,0);b(this,Yn,0);b(this,Rs,null);b(this,si,new Path2D);b(this,Ve,!1);b(this,Kn,null);b(this,Qn,!1);b(this,Jn,!1);b(this,ii,null);b(this,Aa,null);b(this,Zn,0);b(this,tr,0);b(this,Bi,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){gt.initialize(e,s)}static updateDefaultParams(e,s){switch(e){case Q.INK_THICKNESS:Ct._defaultThickness=s;break;case Q.INK_COLOR:Ct._defaultColor=s;break;case Q.INK_OPACITY:Ct._defaultOpacity=s/100;break}}updateParams(e,s){switch(e){case Q.INK_THICKNESS:m(this,M,Kf).call(this,s);break;case Q.INK_COLOR:m(this,M,Qf).call(this,s);break;case Q.INK_OPACITY:m(this,M,Jf).call(this,s);break}}static get defaultPropertiesToUpdate(){return[[Q.INK_THICKNESS,Ct._defaultThickness],[Q.INK_COLOR,Ct._defaultColor||gt._defaultLineColor],[Q.INK_OPACITY,Math.round(Ct._defaultOpacity*100)]]}get propertiesToUpdate(){return[[Q.INK_THICKNESS,this.thickness||Ct._defaultThickness],[Q.INK_COLOR,this.color||Ct._defaultColor||gt._defaultLineColor],[Q.INK_OPACITY,Math.round(100*(this.opacity??Ct._defaultOpacity))]]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.canvas||(m(this,M,Yl).call(this),m(this,M,Kl).call(this)),this.isAttachedToDOM||(this.parent.add(this),m(this,M,vr).call(this)),m(this,M,Ga).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,Rs)&&(clearTimeout(r(this,Rs)),p(this,Rs,null)),(e=r(this,ii))==null||e.disconnect(),p(this,ii,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,Ve)||this.canvas===null||(super.enableEditMode(),this._isDraggable=!1,m(this,M,Qc).call(this))}disableEditMode(){!this.isInEditMode()||this.canvas===null||(super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),m(this,M,Jc).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,Ve)||(super.commit(),this.isEditing=!1,this.disableEditMode(),this.setInForeground(),p(this,Ve,!0),this.div.classList.add("disabled"),m(this,M,Ga).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,Ve)||(this.setInForeground(),e.preventDefault(),this.div.contains(document.activeElement)||this.div.focus({preventScroll:!0}),m(this,M,tp).call(this,e.offsetX,e.offsetY))}canvasPointermove(e){e.preventDefault(),m(this,M,Kc).call(this,e.offsetX,e.offsetY)}canvasPointerup(e){e.preventDefault(),m(this,M,Zc).call(this,e)}canvasPointerleave(e){m(this,M,Zc).call(this,e)}get isResizable(){return!this.isEmpty()&&r(this,Ve)}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,M,Zf).call(this);if(this.setAt(i,n,0,0),this.setDims(a,o),m(this,M,Yl).call(this),this.width){const[l,c]=this.parentDimensions;this.setAspectRatio(this.width*l,this.height*c),this.setAt(e*l,s*c,this.width*l,this.height*c),p(this,Jn,!0),m(this,M,vr).call(this),this.setDims(this.width*l,this.height*c),m(this,M,sn).call(this),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return m(this,M,Kl).call(this),this.div}setDimensions(e,s){const i=Math.round(e),n=Math.round(s);if(r(this,Zn)===i&&r(this,tr)===n)return;p(this,Zn,i),p(this,tr,n),this.canvas.style.visibility="hidden";const[a,o]=this.parentDimensions;this.width=e/a,this.height=s/o,this.fixAndSetPosition(),r(this,Ve)&&m(this,M,td).call(this,e,s),m(this,M,vr).call(this),m(this,M,sn).call(this),this.canvas.style.visibility="visible",this.fixDims()}static async deserialize(e,s,i){var w,v,_;if(e instanceof Rd)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,c=n.height*o,d=n.parentScale,u=e.thickness/2;p(n,Ve,!0),p(n,Zn,Math.round(l)),p(n,tr,Math.round(c));const{paths:f,rect:g,rotation:A}=e;for(let{bezier:S}of f){S=m(w=Ct,pi,op).call(w,S,g,A);const E=[];n.paths.push(E);let x=d*(S[0]-u),C=d*(S[1]-u);for(let P=2,L=S.length;P{this.thickness=n,m(this,M,Ga).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:Q.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})},Qf=function(e){const s=n=>{this.color=n,m(this,M,sn).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:Q.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})},Jf=function(e){const s=n=>{this.opacity=n,m(this,M,sn).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:Q.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})},Zf=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]}},Yc=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}${pg(i)}`},tp=function(e,s){this.canvas.addEventListener("contextmenu",Ke,{signal:this._uiManager._signal}),m(this,M,Jc).call(this),p(this,Kn,new AbortController);const i=this._uiManager.combinedSignal(r(this,Kn));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,Jn)||(p(this,Jn,!0),m(this,M,vr).call(this),this.thickness||(this.thickness=Ct._defaultThickness),this.color||(this.color=Ct._defaultColor||gt._defaultLineColor),this.opacity??(this.opacity=Ct._defaultOpacity)),this.currentPath.push([e,s]),p(this,Qn,!1),m(this,M,Yc).call(this),p(this,Bi,()=>{m(this,M,ip).call(this),r(this,Bi)&&window.requestAnimationFrame(r(this,Bi))}),window.requestAnimationFrame(r(this,Bi))},Kc=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,si);if(a.push([e,s]),p(this,Qn,!0),a.length<=2){o.moveTo(...a[0]),o.lineTo(e,s);return}a.length===3&&(p(this,si,o=new Path2D),o.moveTo(...a[0])),m(this,M,np).call(this,o,...a.at(-3),...a.at(-2),e,s)},ep=function(){if(this.currentPath.length===0)return;const e=this.currentPath.at(-1);r(this,si).lineTo(...e)},sp=function(e,s){p(this,Bi,null),e=Math.min(Math.max(e,0),this.canvas.width),s=Math.min(Math.max(s,0),this.canvas.height),m(this,M,Kc).call(this,e,s),m(this,M,ep).call(this);let i;if(this.currentPath.length!==1)i=m(this,M,rp).call(this);else{const c=[e,s];i=[[c,c.slice(),c.slice(),c]]}const n=r(this,si),a=this.currentPath;this.currentPath=[],p(this,si,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,M,Yl).call(this),m(this,M,Kl).call(this)),m(this,M,Ga).call(this))};this.addCommands({cmd:o,undo:l,mustExec:!0})},ip=function(){if(!r(this,Qn))return;p(this,Qn,!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,si)),a.restore()},np=function(e,s,i,n,a,o,l){const c=(s+n)/2,d=(i+a)/2,u=(n+o)/2,f=(a+l)/2;e.bezierCurveTo(c+2*(n-c)/3,d+2*(a-d)/3,u+2*(n-u)/3,f+2*(a-f)/3,u,f)},rp=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,Rs,null),this.canvas.removeEventListener("contextmenu",Ke)},10)),m(this,M,sp).call(this,e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()},Yl=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")},Kl=function(){p(this,ii,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&this.setDimensions(s.width,s.height)})),r(this,ii).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,ii))==null||e.disconnect(),p(this,ii,null)},{once:!0})},vr=function(){if(!r(this,Jn))return;const[e,s]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*s),m(this,M,Ql).call(this)},td=function(e,s){const i=m(this,M,Jl).call(this),n=(e-i)/r(this,Yn),a=(s-i)/r(this,Xn);this.scaleFactor=Math.min(n,a)},Ql=function(){const e=m(this,M,Jl).call(this)/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)},pi=new WeakSet,ap=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 c=l.output;return await this.setGuessedAltText(c),s&&!this.hasAltTextData()&&(this.altTextData={alt:c,decorative:!1}),c}remove(){var e,s;r(this,se)&&(p(this,Rt,null),this._uiManager.imageManager.deleteId(r(this,se)),(e=r(this,Ps))==null||e.remove(),p(this,Ps,null),(s=r(this,ri))==null||s.disconnect(),p(this,ri,null),r(this,ks)&&(clearTimeout(r(this,ks)),p(this,ks,null))),super.remove()}rebuild(){if(!this.parent){r(this,se)&&m(this,rt,Zl).call(this);return}super.rebuild(),this.div!==null&&(r(this,se)&&r(this,Ps)===null&&m(this,rt,Zl).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(r(this,$i)||r(this,Rt)||r(this,ni)||r(this,zi)||r(this,se))}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,Rt)?m(this,rt,nd).call(this):m(this,rt,Zl).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,Rt),o=new Zh;let l=r(this,Rt),c=n,d=a,u=null;if(s){if(n>s||a>s){const P=Math.min(s/n,s/a);c=Math.floor(n*P),d=Math.floor(a*P)}u=document.createElement("canvas");const A=u.width=Math.ceil(c*o.sx),y=u.height=Math.ceil(d*o.sy);r(this,De)||(l=m(this,rt,th).call(this,A,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,x=S*o.sy,C=new OffscreenCanvas(E*2,x*2),T=C.getContext("2d");T.fillStyle=v,T.fillRect(0,0,E*2,x*2),T.fillStyle=_,T.fillRect(0,0,E,x),T.fillRect(E,x,E,x),w.fillStyle=w.createPattern(C,"repeat"),w.fillRect(0,0,A,y),w.drawImage(l,0,0,l.width,l.height,0,0,A,y)}let f=null;if(i){let A,y;if(o.symmetric&&l.widthe||a>e){const _=Math.min(e/n,e/a);A=Math.floor(n*_),y=Math.floor(a*_),r(this,De)||(l=m(this,rt,th).call(this,A,y))}const v=new OffscreenCanvas(A,y).getContext("2d",{willReadFrequently:!0});v.drawImage(l,0,0,l.width,l.height,0,0,A,y),f={width:A,height:y,data:v.getImageData(0,0,A,y).data}}return{canvas:u,width:c,height:d,imageData:f}}getImageForAltText(){return r(this,Ps)}static async deserialize(e,s,i){var y;let n=null;if(e instanceof wf){const{data:{rect:w,rotation:v,id:_,structParent:S,popupRef:E},container:x,parent:{page:{pageNumber:C}}}=e,T=x.querySelector("canvas"),P=i.imageManager.getFromCanvas(x.id,T);T.remove();const L=((y=await s._structTree.getAriaAttributes(`${bd}${_}`))==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:L},isSvg:!1,structParent:S,popupRef:E}}const a=await super.deserialize(e,s,i),{rect:o,bitmap:l,bitmapUrl:c,bitmapId:d,isSvg:u,accessibilityData:f}=e;d&&i.imageManager.isValidId(d)?(p(a,se,d),l&&p(a,Rt,l)):p(a,ni,c),p(a,De,u);const[g,A]=a.pageDimensions;return a.width=(o[2]-o[0])/g,a.height=(o[3]-o[1])/A,a.annotationElementId=e.id||null,f&&(a.altTextData=f),a._initialData=n,p(a,va,!!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,se),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:r(this,De),structTreeParentId:this._structTreeParentId};if(e)return i.bitmapUrl=m(this,rt,eh).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,rt,dp).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,De)?(i.rect[2]-i.rect[0])*(i.rect[3]-i.rect[1]):null;if(!s.stamps.has(r(this,se)))s.stamps.set(r(this,se),{area:o,serialized:i}),i.bitmap=m(this,rt,eh).call(this,!1);else if(r(this,De)){const l=s.stamps.get(r(this,se));o>l.area&&(l.area=o,l.serialized.bitmap.close(),l.serialized.bitmap=m(this,rt,eh).call(this,!1))}return i}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}};Rt=new WeakMap,se=new WeakMap,$i=new WeakMap,ni=new WeakMap,zi=new WeakMap,ya=new WeakMap,Ps=new WeakMap,ri=new WeakMap,ks=new WeakMap,De=new WeakMap,va=new WeakMap,rt=new WeakSet,Ua=function(e,s=!1){if(!e){this.remove();return}p(this,Rt,e.bitmap),s||(p(this,se,e.id),p(this,De,e.isSvg)),e.file&&p(this,ya,e.file.name),m(this,rt,nd).call(this)},Wa=function(){if(p(this,$i,null),this._uiManager.enableWaiting(!1),!!r(this,Ps)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Rt)){this._editToolbar.hide(),this._uiManager.editAltText(this,!0);return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&r(this,Rt)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Zl=function(){if(r(this,se)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(r(this,se)).then(i=>m(this,rt,Ua).call(this,i,!0)).finally(()=>m(this,rt,Wa).call(this));return}if(r(this,ni)){const i=r(this,ni);p(this,ni,null),this._uiManager.enableWaiting(!0),p(this,$i,this._uiManager.imageManager.getFromUrl(i).then(n=>m(this,rt,Ua).call(this,n)).finally(()=>m(this,rt,Wa).call(this)));return}if(r(this,zi)){const i=r(this,zi);p(this,zi,null),this._uiManager.enableWaiting(!0),p(this,$i,this._uiManager.imageManager.getFromFile(i).then(n=>m(this,rt,Ua).call(this,n)).finally(()=>m(this,rt,Wa).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Xa.supportedTypesStr;const s=this._uiManager._signal;p(this,$i,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,rt,Ua).call(this,n)}i()},{signal:s}),e.addEventListener("cancel",()=>{this.remove(),i()},{signal:s})}).finally(()=>m(this,rt,Wa).call(this))),e.click()},nd=function(){const{div:e}=this;let{width:s,height:i}=r(this,Rt);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,c]=this.parentDimensions;this.setDims(s*l/n,i*c/a),this._uiManager.enableWaiting(!1);const d=p(this,Ps,document.createElement("canvas"));d.setAttribute("role","img"),this.addContainer(d),(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),m(this,rt,rd).call(this,s,i),m(this,rt,cp).call(this),r(this,va)||(this.parent.addUndoableEditor(this),p(this,va,!0)),this._reportTelemetry({action:"inserted_image"}),r(this,ya)&&d.setAttribute("aria-label",r(this,ya))},hp=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,ks)!==null&&clearTimeout(r(this,ks)),p(this,ks,setTimeout(()=>{p(this,ks,null),m(this,rt,rd).call(this,e,s)},200))},th=function(e,s){const{width:i,height:n}=r(this,Rt);let a=i,o=n,l=r(this,Rt);for(;a>2*e||o>2*s;){const c=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,c,d,0,0,a,o),l=u.transferToImageBitmap()}return l},rd=function(e,s){const i=new Zh,n=Math.ceil(e*i.sx),a=Math.ceil(s*i.sy),o=r(this,Ps);if(!o||o.width===n&&o.height===a)return;o.width=n,o.height=a;const l=r(this,De)?r(this,Rt):m(this,rt,th).call(this,n,a),c=o.getContext("2d");c.filter=this._uiManager.hcmFilter,c.drawImage(l,0,0,l.width,l.height,0,0,n,a)},eh=function(e){if(e){if(r(this,De)){const n=this._uiManager.imageManager.getSvgUrl(r(this,se));if(n)return n}const s=document.createElement("canvas");return{width:s.width,height:s.height}=r(this,Rt),s.getContext("2d").drawImage(r(this,Rt),0,0),s.toDataURL()}if(r(this,De)){const[s,i]=this.pageDimensions,n=Math.round(this.width*s*Vi.PDF_TO_CSS_UNITS),a=Math.round(this.height*i*Vi.PDF_TO_CSS_UNITS),o=new OffscreenCanvas(n,a);return o.getContext("2d").drawImage(r(this,Rt),0,0,r(this,Rt).width,r(this,Rt).height,0,0,n,a),o.transferToImageBitmap()}return structuredClone(r(this,Rt))},cp=function(){this._uiManager._signal&&(p(this,ri,new ResizeObserver(e=>{const s=e[0].contentRect;s.width&&s.height&&m(this,rt,hp).call(this,s.width,s.height)})),r(this,ri).observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{var e;(e=r(this,ri))==null||e.disconnect(),p(this,ri,null)},{once:!0}))},dp=function(e){var c;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=(((c=e.accessibilityData)==null?void 0:c.alt)||"")===n;return{isSame:a&&o&&l,isSameAltText:l}},K(Xa,"_type","stamp"),K(Xa,"_editorType",tt.STAMP);let id=Xa;var er,wa,Ls,Gi,ai,Oe,Ui,_a,Ea,ce,oi,U,Wi,ie,up,od,ld,hd,sh;const Qe=class Qe{constructor({uiManager:t,pageIndex:e,div:s,structTreeLayer:i,accessibilityManager:n,annotationLayer:a,drawLayer:o,textLayer:l,viewport:c,l10n:d}){b(this,ie);b(this,er);b(this,wa,!1);b(this,Ls,null);b(this,Gi,null);b(this,ai,null);b(this,Oe,new Map);b(this,Ui,!1);b(this,_a,!1);b(this,Ea,!1);b(this,ce,null);b(this,oi,null);b(this,U);const u=[...r(Qe,Wi).values()];if(!Qe._initialized){Qe._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,er,n),p(this,Ls,a),this.viewport=c,p(this,ce,l),this.drawLayer=o,this._structTree=i,r(this,U).addLayer(this)}get isEmpty(){return r(this,Oe).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,ie,sh).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(Qe,Wi).values())e.toggle(`${s._type}Editing`,t===s._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=r(this,ce))==null?void 0:e.div)}addInkEditorIfNeeded(t){if(r(this,U).getMode()!==tt.INK)return;if(!t){for(const s of r(this,Oe).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,Ls))==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,Oe).values())s.enableEditing(),s.show(!0),s.annotationElementId&&(r(this,U).removeChangedExistingAnnotation(s),t.add(s.annotationElementId));if(!r(this,Ls))return;const e=r(this,Ls).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,Ea,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1);const t=new Map,e=new Map;for(const n of r(this,Oe).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,Ls)){const n=r(this,Ls).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,ie,sh).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:s}=this.div;for(const n of r(Qe,Wi).values())s.remove(`${n._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),p(this,Ea,!1)}getEditableAnnotation(t){var e;return((e=r(this,Ls))==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,ce))!=null&&t.div&&!r(this,oi)){p(this,oi,new AbortController);const e=r(this,U).combinedSignal(r(this,oi));r(this,ce).div.addEventListener("pointerdown",m(this,ie,up).bind(this),{signal:e}),r(this,ce).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=r(this,ce))!=null&&t.div&&r(this,oi)&&(r(this,oi).abort(),p(this,oi,null),r(this,ce).div.classList.remove("highlighting"))}enableClick(){if(r(this,Gi))return;p(this,Gi,new AbortController);const t=r(this,U).combinedSignal(r(this,Gi));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,Gi))==null||t.abort(),p(this,Gi,null)}attach(t){r(this,Oe).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,Oe).delete(t.id),(e=r(this,er))==null||e.removePointerInTextLayer(t.contentDiv),!r(this,Ea)&&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,_a)||this.addInkEditorIfNeeded(!1)}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(r(this,U).addDeletedAnnotationElement(t.annotationElementId),gt.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,ai)&&(t._focusEventsAllowed=!1,p(this,ai,setTimeout(()=>{p(this,ai,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,er))==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,ie,od))==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,ie,hd).call(this),n=this.getNextId(),a=m(this,ie,ld).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(Qe,Wi).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,ie,ld).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,ie,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}=be.platform;if(!(t.button!==0||t.ctrlKey&&e)&&t.target===this.div&&r(this,Ui)){if(p(this,Ui,!1),!r(this,wa)){p(this,wa,!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,Ui)){p(this,Ui,!1);return}const{isMac:e}=be.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;p(this,Ui,!0);const s=r(this,U).getActive();p(this,wa,!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,ai)&&(clearTimeout(r(this,ai)),p(this,ai,null));for(const s of r(this,Oe).values())(e=r(this,er))==null||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,r(this,Oe).clear(),r(this,U).removeLayer(this)}render({viewport:t}){this.viewport=t,sr(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,ie,sh).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,sr(this.div,{rotation:s}),e!==s)for(const i of r(this,Oe).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}};er=new WeakMap,wa=new WeakMap,Ls=new WeakMap,Gi=new WeakMap,ai=new WeakMap,Oe=new WeakMap,Ui=new WeakMap,_a=new WeakMap,Ea=new WeakMap,ce=new WeakMap,oi=new WeakMap,U=new WeakMap,Wi=new WeakMap,ie=new WeakSet,up=function(t){r(this,U).unselectAll();const{target:e}=t;if(e===r(this,ce).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&r(this,ce).div.contains(e)){const{isMac:s}=be.platform;if(t.button!==0||t.ctrlKey&&s)return;r(this,U).showAllEditors("highlight",!0,!0),r(this,ce).div.classList.add("free"),this.toggleDrawing(),oh.startHighlighting(this,r(this,U).direction==="ltr",{target:r(this,ce).div,x:t.x,y:t.y}),r(this,ce).div.addEventListener("pointerup",()=>{r(this,ce).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:r(this,U)._signal}),t.preventDefault()}},od=function(){return r(Qe,Wi).get(r(this,U).getMode())},ld=function(t){const e=r(this,ie,od);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),c=(n+o)/2-t,d=(a+l)/2-e,[u,f]=this.viewport.rotation%180===0?[c,d]:[d,c];return{offsetX:u,offsetY:f}},sh=function(){p(this,_a,!0);for(const t of r(this,Oe).values())t.isEmpty()&&t.remove();p(this,_a,!1)},K(Qe,"_initialized",!1),b(Qe,Wi,new Map([jc,Xc,id,oh].map(t=>[t._editorType,t])));let ad=Qe;var Ms,cl,Ht,li,dl,dd,or,ud,fp;const Zt=class Zt{constructor({pageIndex:t}){b(this,or);b(this,Ms,null);b(this,cl,0);b(this,Ht,new Map);b(this,li,new Map);this.pageIndex=t}setParent(t){if(!r(this,Ms)){p(this,Ms,t);return}if(r(this,Ms)!==t){if(r(this,Ht).size>0)for(const e of r(this,Ht).values())e.remove(),t.append(e);p(this,Ms,t)}}static get _svgFactory(){return ot(this,"_svgFactory",new Td)}draw(t,e,s,i=!1){const n=fe(this,cl)._++,a=m(this,or,ud).call(this,t.box);a.classList.add(...t.classNamesForDrawing);const o=Zt._svgFactory.createElement("defs");a.append(o);const l=Zt._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("d",t.toSVGPath()),i&&r(this,li).set(n,l);const d=m(this,or,fp).call(this,o,c),u=Zt._svgFactory.createElement("use");return a.append(u),a.setAttribute("fill",e),a.setAttribute("fill-opacity",s),u.setAttribute("href",`#${c}`),r(this,Ht).set(n,a),{id:n,clipPathId:`url(#${d})`}}drawOutline(t){const e=fe(this,cl)._++,s=m(this,or,ud).call(this,t.box);s.classList.add(...t.classNamesForOutlining);const i=Zt._svgFactory.createElement("defs");s.append(i);const n=Zt._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=Zt._svgFactory.createElement("mask");i.append(d),o=`mask_p${this.pageIndex}_${e}`,d.setAttribute("id",o),d.setAttribute("maskUnits","objectBoundingBox");const u=Zt._svgFactory.createElement("rect");d.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const f=Zt._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=Zt._svgFactory.createElement("use");s.append(l),l.setAttribute("href",`#${a}`),o&&l.setAttribute("mask",`url(#${o})`);const c=l.cloneNode();return s.append(c),l.classList.add("mainOutline"),c.classList.add("secondaryOutline"),r(this,Ht).set(e,s),e}finalizeLine(t,e){const s=r(this,li).get(t);r(this,li).delete(t),this.updateBox(t,e.box),s.setAttribute("d",e.toSVGPath())}updateLine(t,e){r(this,Ht).get(t).firstChild.firstChild.setAttribute("d",e.toSVGPath())}updatePath(t,e){r(this,li).get(t).setAttribute("d",e.toSVGPath())}updateBox(t,e){var s;m(s=Zt,dl,dd).call(s,r(this,Ht).get(t),e)}show(t,e){r(this,Ht).get(t).classList.toggle("hidden",!e)}rotate(t,e){r(this,Ht).get(t).setAttribute("data-main-rotation",e)}changeColor(t,e){r(this,Ht).get(t).setAttribute("fill",e)}changeOpacity(t,e){r(this,Ht).get(t).setAttribute("fill-opacity",e)}addClass(t,e){r(this,Ht).get(t).classList.add(e)}removeClass(t,e){r(this,Ht).get(t).classList.remove(e)}getSVGRoot(t){return r(this,Ht).get(t)}remove(t){r(this,li).delete(t),r(this,Ms)!==null&&(r(this,Ht).get(t).remove(),r(this,Ht).delete(t))}destroy(){p(this,Ms,null);for(const t of r(this,Ht).values())t.remove();r(this,Ht).clear(),r(this,li).clear()}};Ms=new WeakMap,cl=new WeakMap,Ht=new WeakMap,li=new WeakMap,dl=new WeakSet,dd=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}%`},or=new WeakSet,ud=function(t){var s;const e=Zt._svgFactory.create(1,1,!0);return r(this,Ms).append(e),e.setAttribute("aria-hidden",!0),m(s=Zt,dl,dd).call(s,e,t),e},fp=function(t,e){const s=Zt._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=Zt._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},b(Zt,dl);let cd=Zt;J.AbortException;J.AnnotationEditorLayer;J.AnnotationEditorParamsType;J.AnnotationEditorType;J.AnnotationEditorUIManager;var pp=J.AnnotationLayer,gp=J.AnnotationMode;J.ColorPicker;J.DOMSVGFactory;J.DrawLayer;J.FeatureTest;var Fh=J.GlobalWorkerOptions;J.ImageKind;J.InvalidPDFException;J.MissingPDFException;J.OPS;J.OutputScale;var qm=J.PDFDataRangeTransport;J.PDFDateString;J.PDFWorker;J.PasswordResponses;J.PermissionFlag;J.PixelsPerInch;J.RenderingCancelledException;var mp=J.TextLayer;J.UnexpectedResponseException;J.Util;J.VerbosityLevel;J.XfaLayer;J.build;J.createValidAbsoluteUrl;J.fetchData;var bp=J.getDocument;J.getFilenameFromUrl;J.getPdfFilenameFromUrl;J.getXfaPageViewport;J.isDataScheme;J.isPdfFile;J.noContextMenu;J.normalizeUnicode;J.setLayerDimensions;J.shadow;var fd=J.version;const Xm=Object.freeze(Object.defineProperty({__proto__:null,AnnotationLayer:pp,AnnotationMode:gp,GlobalWorkerOptions:Fh,PDFDataRangeTransport:qm,TextLayer:mp,getDocument:bp,version:fd},Symbol.toStringTag,{value:"Module"}));var qt=function(h,t,e){if(e||arguments.length===2)for(var s=0,i=t.length,n;s{vt(this.pdfDocument),vt(t),typeof t=="string"?this.pdfDocument.getDestination(t).then(e):Array.isArray(t)?e(t):t.then(e)}).then(e=>{vt(Array.isArray(e));const s=e[0];new Promise(i=>{vt(this.pdfDocument),s instanceof Object?this.pdfDocument.getPageIndex(s).then(n=>{i(n)}).catch(()=>{vt(!1)}):typeof s=="number"?i(s):vt(!1)}).then(i=>{const n=i+1;vt(this.pdfViewer),vt(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;vt(this.pdfViewer),vt(t>=1&&t<=this.pagesCount),this.pdfViewer.scrollPageIntoView({pageIndex:e,pageNumber:t})}addLinkAttributes(t,e,s){t.href=e,t.rel=this.externalLinkRel||bb,t.target=s?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}const tu={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},Dh=typeof window<"u",vp=Dh&&window.location.protocol==="file:";function yb(h){return typeof h<"u"}function Ji(h){return yb(h)&&h!==null}function vb(h){return typeof h=="string"}function wb(h){return h instanceof ArrayBuffer}function _b(h){return vt(Dh),h instanceof Blob}function pd(h){return vb(h)&&/^data:/.test(h)}function eu(h){vt(pd(h));const[t="",e=""]=h.split(",");return t.split(";").indexOf("base64")!==-1?atob(e):unescape(e)}function Eb(){return Dh&&window.devicePixelRatio||1}const wp="On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.";function su(){de(!vp,`Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. ${wp}`)}function Sb(){de(!vp,`Loading PDF.js worker may not work on protocols other than HTTP/HTTPS. ${wp}`)}function rr(h){h!=null&&h.cancel&&h.cancel()}function gd(h,t){return Object.defineProperty(h,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(h,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(h,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(h,"originalHeight",{get(){return this.view[3]},configurable:!0}),h}function xb(h){return h.name==="RenderingCancelledException"}function Cb(h){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(h)})}function Tb(h,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 h}}function Sa(){return R.useReducer(Tb,{value:void 0,error:void 0})}var Rb=function(h,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{c(s.next(d))}catch(u){a(u)}}function l(d){try{c(s.throw(d))}catch(u){a(u)}}function c(d){d.done?n(d.value):i(d.value).then(o,l)}c((s=s.apply(h,t||[])).next())})},iu=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i{switch(t){case tu.NEED_PASSWORD:{const e=prompt("Enter the password to open this PDF file.");h(e);break}case tu.INCORRECT_PASSWORD:{const e=prompt("Invalid password. Please try again.");h(e);break}}};function nu(h){return typeof h=="object"&&h!==null&&("data"in h||"range"in h||"url"in h)}const Lb=R.forwardRef(function(t,e){var{children:s,className:i,error:n="Failed to load PDF file.",externalLinkRel:a,externalLinkTarget:o,file:l,inputRef:c,imageResourcesPath:d,loading:u="Loading PDF…",noData:f="No PDF file specified.",onItemClick:g,onLoadError:A,onLoadProgress:y,onLoadSuccess:w,onPassword:v=kb,onSourceError:_,onSourceSuccess:S,options:E,renderMode:x,rotate:C}=t,T=iu(t,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);const[P,L]=Sa(),{value:F,error:D}=P,[Y,W]=Sa(),{value:G,error:V}=Y,q=R.useRef(new Ab),O=R.useRef([]),z=R.useRef(void 0),St=R.useRef(void 0);l&&l!==z.current&&nu(l)&&(de(!Sr(l,z.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.`),z.current=l),E&&E!==St.current&&(de(!Sr(E,St.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.`),St.current=E);const It=R.useRef({scrollPageIntoView:bt=>{const{dest:kt,pageNumber:H,pageIndex:B=H-1}=bt;if(g){g({dest:kt,pageIndex:B,pageNumber:H});return}const ct=O.current[B];if(ct){ct.scrollIntoView();return}de(!1,`An internal link leading to page ${H} 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:q,pages:O,viewer:It}),[]);function Ft(){S&&S()}function ht(){D&&(de(!1,D.toString()),_&&_(D))}function at(){L({type:"RESET"})}R.useEffect(at,[l,L]);const N=R.useCallback(()=>Rb(this,void 0,void 0,function*(){if(!l)return null;if(typeof l=="string")return pd(l)?{data:eu(l)}:(su(),{url:l});if(l instanceof Pb)return{range:l};if(wb(l))return{data:l};if(Dh&&_b(l))return{data:yield Cb(l)};if(vt(typeof l=="object"),vt(nu(l)),"url"in l&&typeof l.url=="string"){if(pd(l.url)){const{url:bt}=l,kt=iu(l,["url"]),H=eu(bt);return Object.assign({data:H},kt)}su()}return l}),[l]);R.useEffect(()=>{const bt=gl(N());return bt.promise.then(kt=>{L({type:"RESOLVE",value:kt})}).catch(kt=>{L({type:"REJECT",error:kt})}),()=>{rr(bt)}},[N,L]),R.useEffect(()=>{if(!(typeof F>"u")){if(F===!1){ht();return}Ft()}},[F]);function lt(){G&&(w&&w(G),O.current=new Array(G.numPages),q.current.setDocument(G))}function nt(){V&&(de(!1,V.toString()),A&&A(V))}R.useEffect(function(){W({type:"RESET"})},[W,F]),R.useEffect(function(){if(!F)return;const kt=E?Object.assign(Object.assign({},F),E):F,H=bp(kt);y&&(H.onProgress=y),v&&(H.onPassword=v);const B=H,ct=B.promise.then(xt=>{W({type:"RESOLVE",value:xt})}).catch(xt=>{B.destroyed||W({type:"REJECT",error:xt})});return()=>{ct.finally(()=>B.destroy())}},[E,W,F]),R.useEffect(()=>{if(!(typeof G>"u")){if(G===!1){nt();return}lt()}},[G]),R.useEffect(function(){q.current.setViewer(It.current),q.current.setExternalLinkRel(a),q.current.setExternalLinkTarget(o)},[a,o]);const X=R.useCallback((bt,kt)=>{O.current[bt]=kt},[]),Vt=R.useCallback(bt=>{delete O.current[bt]},[]),ne=R.useMemo(()=>({imageResourcesPath:d,linkService:q.current,onItemClick:g,pdf:G,registerPage:X,renderMode:x,rotate:C,unregisterPage:Vt}),[d,g,G,X,x,C,Vt]),mt=R.useMemo(()=>Ap(T,()=>G),[T,G]);function fs(){return k.jsx(yp.Provider,{value:ne,children:s})}function Is(){return l?G==null?k.jsx(xr,{type:"loading",children:typeof u=="function"?u():u}):G===!1?k.jsx(xr,{type:"error",children:typeof n=="function"?n():n}):fs():k.jsx(xr,{type:"no-data",children:typeof f=="function"?f():f})}return k.jsx("div",Object.assign({className:xh("react-pdf__Document",i),ref:c,style:{"--scale-factor":"1"}},mt,{children:Is()}))});function _p(){return R.useContext(yp)}function Ep(){for(var h=[],t=0;tDb(t),[t]),s=R.useMemo(()=>!Oh(t)||Cp(t)?null:t.children.map((i,n)=>k.jsx(Rp,{node:i},n)),[t]);return k.jsx("span",Object.assign({className:h},e,{children:s}))}function Nh(){return R.useContext(Sp)}function Ob(){const h=Nh();vt(h);const{onGetStructTreeError:t,onGetStructTreeSuccess:e}=h,[s,i]=Sa(),{value:n,error:a}=s,{customTextRenderer:o,page:l}=h;function c(){n&&e&&e(n)}function d(){a&&(de(!1,a.toString()),t&&t(a))}return R.useEffect(function(){i({type:"RESET"})},[i,l]),R.useEffect(function(){if(o||!l)return;const f=gl(l.getStructTree()),g=f;return f.promise.then(A=>{i({type:"RESOLVE",value:A})}).catch(A=>{i({type:"REJECT",error:A})}),()=>rr(g)},[o,l,i]),R.useEffect(()=>{if(n!==void 0){if(n===!1){d();return}c()}},[n]),n?k.jsx(Rp,{className:"react-pdf__Page__structTree structTree",node:n}):null}const ru=gp;function Nb(h){const t=Nh();vt(t);const e=Object.assign(Object.assign({},t),h),{_className:s,canvasBackground:i,devicePixelRatio:n=Eb(),onRenderError:a,onRenderSuccess:o,page:l,renderForms:c,renderTextLayer:d,rotate:u,scale:f}=e,{canvasRef:g}=h;vt(l);const A=R.useRef(null);function y(){l&&o&&o(gd(l,f))}function w(E){xb(E)||(de(!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:x}=A;if(!x)return;x.width=v.width,x.height=v.height,x.style.width=`${Math.floor(_.width)}px`,x.style.height=`${Math.floor(_.height)}px`,x.style.visibility="hidden";const C={annotationMode:c?ru.ENABLE_FORMS:ru.ENABLE,canvasContext:x.getContext("2d",{alpha:!1}),viewport:v};i&&(C.background=i);const T=l.render(C),P=T;return T.promise.then(()=>{x.style.visibility="",y()}).catch(w),()=>rr(P)},[i,l,c,v,_]);const S=R.useCallback(()=>{const{current:E}=A;E&&(E.width=0,E.height=0)},[]);return R.useEffect(()=>S,[S]),k.jsx("canvas",{className:`${s}__canvas`,dir:"ltr",ref:Ep(g,A),style:{display:"block",userSelect:"none"},children:d?k.jsx(Ob,{}):null})}function Hb(h){return"str"in h}function jb(){const h=Nh();vt(h);const{customTextRenderer:t,onGetTextError:e,onGetTextSuccess:s,onRenderTextLayerError:i,onRenderTextLayerSuccess:n,page:a,pageIndex:o,pageNumber:l,rotate:c,scale:d}=h;vt(a);const[u,f]=Sa(),{value:g,error:A}=u,y=R.useRef(null);de(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(){A&&(de(!1,A.toString()),e&&e(A))}R.useEffect(function(){f({type:"RESET"})},[a,f]),R.useEffect(function(){if(!a)return;const P=gl(a.getTextContent()),L=P;return P.promise.then(F=>{f({type:"RESOLVE",value:F})}).catch(F=>{f({type:"REJECT",error:F})}),()=>rr(L)},[a,f]),R.useEffect(()=>{if(g!==void 0){if(g===!1){v();return}w()}},[g]);const _=R.useCallback(()=>{n&&n()},[n]),S=R.useCallback(T=>{de(!1,T.toString()),i&&i(T)},[i]);function E(){const T=y.current;T&&T.classList.add("selecting")}function x(){const T=y.current;T&&T.classList.remove("selecting")}const C=R.useMemo(()=>a.getViewport({scale:d,rotation:c}),[a,c,d]);return R.useLayoutEffect(function(){if(!a||!g)return;const{current:P}=y;if(!P)return;P.innerHTML="";const L=a.streamTextContent({includeMarkedContent:!0}),F={container:P,textContentSource:L,viewport:C},D=new mp(F),Y=D;return D.render().then(()=>{const W=document.createElement("div");W.className="endOfContent",P.append(W);const G=P.querySelectorAll('[role="presentation"]');if(t){let V=0;g.items.forEach((q,O)=>{if(!Hb(q))return;const z=G[V];if(!z)return;const St=t(Object.assign({pageIndex:o,pageNumber:l,itemIndex:O},q));z.innerHTML=St,V+=q.str&&q.hasEOL?2:1})}_()}).catch(S),()=>rr(Y)},[t,S,_,a,o,l,g,C]),k.jsx("div",{className:xh("react-pdf__Page__textContent","textLayer"),onMouseUp:x,onMouseDown:E,ref:y})}function Bb(){const h=_p(),t=Nh();vt(t);const e=Object.assign(Object.assign({},h),t),{imageResourcesPath:s,linkService:i,onGetAnnotationsError:n,onGetAnnotationsSuccess:a,onRenderAnnotationLayerError:o,onRenderAnnotationLayerSuccess:l,page:c,pdf:d,renderForms:u,rotate:f,scale:g=1}=e;vt(d),vt(c),vt(i);const[A,y]=Sa(),{value:w,error:v}=A,_=R.useRef(null);de(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&&(de(!1,v.toString()),n&&n(v))}R.useEffect(function(){y({type:"RESET"})},[y,c]),R.useEffect(function(){if(!c)return;const L=gl(c.getAnnotations()),F=L;return L.promise.then(D=>{y({type:"RESOLVE",value:D})}).catch(D=>{y({type:"REJECT",error:D})}),()=>{rr(F)}},[y,c]),R.useEffect(()=>{if(w!==void 0){if(w===!1){E();return}S()}},[w]);function x(){l&&l()}function C(P){de(!1,`${P}`),o&&o(P)}const T=R.useMemo(()=>c.getViewport({scale:g,rotation:f}),[c,f,g]);return R.useEffect(function(){if(!d||!c||!i||!w)return;const{current:L}=_;if(!L)return;const F=T.clone({dontFlip:!0}),D={accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:L,l10n:null,page:c,structTreeLayer:null,viewport:F},Y={annotations:w,annotationStorage:d.annotationStorage,div:L,imageResourcesPath:s,linkService:i,page:c,renderForms:u,viewport:F};L.innerHTML="";try{new pp(D).render(Y),x()}catch(W){C(W)}return()=>{}},[w,s,i,c,d,u,T]),k.jsx("div",{className:xh("react-pdf__Page__annotations","annotationLayer"),ref:_})}var $b=function(h,t){var e={};for(var s in h)Object.prototype.hasOwnProperty.call(h,s)&&t.indexOf(s)<0&&(e[s]=h[s]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,s=Object.getOwnPropertySymbols(h);i{if(!mt)return null;let ur=1;const bl=N??au;if(nt||g){const Al=mt.getViewport({scale:1,rotation:H});nt?ur=nt/Al.width:g&&(ur=g/Al.height)}return bl*ur},[g,mt,H,N,nt]);R.useEffect(function(){return()=>{Ji(bt)&&i&<&<(bt)}},[i,O,bt,lt]);function ct(){if(P){if(!mt||!B)return;P(gd(mt,B))}if(i&&z){if(!Ji(bt)||!Is.current)return;z(bt,Is.current)}}function xt(){fs&&(de(!1,fs.toString()),T&&T(fs))}R.useEffect(function(){ne({type:"RESET"})},[ne,O,bt]),R.useEffect(function(){if(!O||!kt)return;const bl=gl(O.getPage(kt)),Al=bl;return bl.promise.then(Hh=>{ne({type:"RESOLVE",value:Hh})}).catch(Hh=>{ne({type:"REJECT",error:Hh})}),()=>rr(Al)},[ne,O,kt]),R.useEffect(()=>{if(mt!==void 0){if(mt===!1){xt();return}ct()}},[mt,B]);const ve=R.useMemo(()=>mt&&Ji(bt)&&kt&&Ji(H)&&Ji(B)?{_className:s,canvasBackground:n,customTextRenderer:d,devicePixelRatio:u,onGetAnnotationsError:v,onGetAnnotationsSuccess:_,onGetStructTreeError:S,onGetStructTreeSuccess:E,onGetTextError:x,onGetTextSuccess:C,onRenderAnnotationLayerError:L,onRenderAnnotationLayerSuccess:F,onRenderError:D,onRenderSuccess:Y,onRenderTextLayerError:W,onRenderTextLayerSuccess:G,page:mt,pageIndex:bt,pageNumber:kt,renderForms:It,renderTextLayer:ht,rotate:H,scale:B}:null,[s,n,d,u,v,_,S,E,x,C,L,F,D,Y,W,G,mt,bt,kt,It,ht,H,B]),Be=R.useMemo(()=>Ap(X,()=>mt&&(B?gd(mt,B):void 0)),[X,mt,B]),gi=`${bt}@${B}/${H}`;function Qi(){switch(Ft){case"custom":return vt(c),k.jsx(c,{},`${gi}_custom`);case"none":return null;case"canvas":default:return k.jsx(Nb,{canvasRef:a},`${gi}_canvas`)}}function dr(){return ht?k.jsx(jb,{},`${gi}_text`):null}function xa(){return St?k.jsx(Bb,{},`${gi}_annotations`):null}function ml(){return k.jsxs(Sp.Provider,{value:ve,children:[Qi(),dr(),xa(),o]})}function Mp(){return kt?O===null||mt===void 0||mt===null?k.jsx(xr,{type:"loading",children:typeof y=="function"?y():y}):O===!1||mt===!1?k.jsx(xr,{type:"error",children:typeof f=="function"?f():f}):ml():k.jsx(xr,{type:"no-data",children:typeof w=="function"?w():w})}return k.jsx("div",Object.assign({className:xh(s,l),"data-page-number":kt,ref:Ep(A,Is),style:{"--scale-factor":`${B}`,backgroundColor:n||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},Be,{children:Mp()}))}Sb();Fh.workerSrc="pdf.worker.mjs";const Gb="/assets/pdf.worker.min-GB3t0DcA.js";Fh.workerSrc=Gb;function Ub(){if(!Fh.workerSrc)throw new Error("The bundled PDF worker is not configured.");if(fd!=="4.8.69")throw new Error(`PDF runtime version mismatch (${fd}).`)}function Wb({paperTitle:h,paperHref:t,resources:e,page:s,pages:i,zoomPercent:n,searchOpen:a,searchQuery:o,searchMatch:l,searchCount:c,searching:d,onPage:u,onZoomIn:f,onZoomOut:g,onToggleSearch:A,onCloseSearch:y,onSearchQuery:w,onSearch:v}){const _=R.useRef(null);R.useLayoutEffect(()=>{const E=_.current,x=document.querySelector(".app-header .brand-mark");if(!E||!x)return;const C=()=>{const P=x.getBoundingClientRect().left-E.getBoundingClientRect().left;E.style.setProperty("--reader-title-inset",`${Math.max(10,P)}px`)};C();const T=new ResizeObserver(C);return T.observe(E),T.observe(x),()=>T.disconnect()},[]);const S=E=>{E.preventDefault();const x=Number(new FormData(E.currentTarget).get("page"));Number.isInteger(x)&&u(x)};return k.jsxs("div",{ref:_,className:"pdf-toolbar","aria-label":"PDF controls",children:[k.jsxs("div",{className:"pdf-toolbar-paper",children:[k.jsx(Cl,{className:"pdf-toolbar-title",to:t,title:h,"aria-label":`${h} — open paper page`,children:h}),(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(zp,{size:15,strokeWidth:1.8,"aria-hidden":"true"}),k.jsx("span",{children:e.repository.label}),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(Gp,{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:A,"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?`${c?l+1:0} of ${c}`:""}),k.jsx("button",{type:"button",onClick:()=>v(-1),disabled:!c,"aria-label":"Previous match",children:"↑"}),k.jsx("button",{type:"button",onClick:()=>v(1),disabled:!c,"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 Vb(h){const t=h.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 Pa(h){return h.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]??t)}function qb(h,t,e){const s=t.trim().toLocaleLowerCase();if(!s)return Pa(h);const i=h.toLocaleLowerCase(),n=`pdf-search-highlight${e?" is-active":""}`;let a=0,o=i.indexOf(s);if(o<0)return Pa(h);let l="";for(;o>=0;)l+=Pa(h.slice(a,o)),l+=`${Pa(h.slice(o,o+s.length))}`,a=o+s.length,o=i.indexOf(s,a);return l+Pa(h.slice(a))}function Xb({page:h,width:t,searchQuery:e,activeSearchPage:s}){const i=R.useRef(null),[n,a]=R.useState(h<=2);return R.useEffect(()=>{const o=i.current;if(!o)return;const l=new IntersectionObserver(([c])=>a(c.isIntersecting),{rootMargin:"120% 0px"});return l.observe(o),()=>l.disconnect()},[]),k.jsx("div",{ref:i,className:"pdf-page","data-page":h,style:{minHeight:Math.round(t*1.35)},children:n&&k.jsx(zb,{pageNumber:h,width:t,devicePixelRatio:Math.min(window.devicePixelRatio||1,2),renderTextLayer:!0,renderAnnotationLayer:!0,loading:null,customTextRenderer:e?({str:o})=>qb(o,e,h===s):void 0})})}function Yb({url:h,paperKey:t,paperTitle:e,paperHref:s,resources:i,initialPage:n=1,resizeActive:a=!1,onPageChange:o}){const l=R.useRef(null),c=R.useRef(null),d=R.useRef(null),u=R.useRef(null),f=R.useRef(0),g=R.useRef(!1),A=R.useRef(0),y=R.useRef(0),w=R.useRef(0),v=R.useRef(1),_=R.useRef(1),[S,E]=R.useState(0),[x,C]=R.useState(0),[T,P]=R.useState(n),[L,F]=R.useState(700),[D,Y]=R.useState(700),[W,G]=R.useState(1),[V,q]=R.useState(""),[O,z]=R.useState(!1),[St,It]=R.useState(""),[Ft,ht]=R.useState(!1),[at,N]=R.useState([]),[lt,nt]=R.useState(0),X=Math.max(240,Math.round(L*W));R.useEffect(()=>{Ub()},[]),R.useEffect(()=>{var H;cancelAnimationFrame(y.current),window.clearTimeout(w.current),y.current=0,w.current=0,A.current=0,C(0),P(n),G(1),v.current=1,_.current=1,(H=d.current)==null||H.style.setProperty("--pdf-live-scale","1"),q(""),It(""),N([])},[n,t,S]),R.useEffect(()=>{const H=c.current;if(!H)return;const B=()=>{const xt=Math.max(240,H.clientWidth-10);Y(xt),a||F(xt)};B();const ct=new ResizeObserver(B);return ct.observe(H),()=>ct.disconnect()},[a]);const Vt=a?D/L:1;R.useLayoutEffect(()=>{var B;if(v.current=W,(B=d.current)==null||B.style.setProperty("--pdf-live-scale",String(Vt)),!g.current)return;const H=c.current;H&&(H.scrollLeft=Math.max(0,(H.scrollWidth-H.clientWidth)/2)),g.current=!1},[Vt,X,W]);const ne=R.useCallback(H=>{window.clearTimeout(w.current);const B=_.current,ct=H(B);_.current=ct,g.current=ct!==v.current,G(ct)},[]);R.useEffect(()=>{const H=c.current;if(!H)return;const B=ct=>{ct.ctrlKey&&(ct.preventDefault(),A.current+=ct.deltaY,!y.current&&(y.current=requestAnimationFrame(()=>{var Be;const xt=A.current;A.current=0,y.current=0;const ve=Math.max(.5,Math.min(3,_.current*Math.exp(-xt*.002)));_.current=ve,(Be=d.current)==null||Be.style.setProperty("--pdf-live-scale",String(Vt*ve/v.current)),window.clearTimeout(w.current),w.current=window.setTimeout(()=>{g.current=ve!==v.current,G(_.current)},180)})))};return H.addEventListener("wheel",B,{passive:!1}),()=>{H.removeEventListener("wheel",B),cancelAnimationFrame(y.current),window.clearTimeout(w.current),y.current=0,w.current=0,A.current=0}},[Vt]);const mt=R.useCallback(H=>{const B=Math.max(1,Math.min(x||1,H));P(B),o==null||o(B)},[o,x]),fs=R.useCallback(()=>{f.current+=1,z(!1),It(""),N([]),nt(0),ht(!1)},[]);R.useEffect(()=>{const H=c.current;if(!H||!x)return;let B=0;const ct=()=>{cancelAnimationFrame(B),B=requestAnimationFrame(()=>{const xt=H.getBoundingClientRect().top+H.clientHeight/2;let ve=T,Be=Number.POSITIVE_INFINITY;H.querySelectorAll("[data-page]").forEach(gi=>{const Qi=gi.getBoundingClientRect(),dr=xt>=Qi.top&&xt<=Qi.bottom?0:Math.min(Math.abs(xt-Qi.top),Math.abs(xt-Qi.bottom));dr{H.removeEventListener("scroll",ct),cancelAnimationFrame(B)}},[T,X,x,mt]),R.useEffect(()=>{const H=B=>{(B.ctrlKey||B.metaKey)&&B.key.toLowerCase()==="f"?(B.preventDefault(),z(!0)):B.key==="Escape"&&O&&(B.preventDefault(),fs())};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[fs,O]),R.useEffect(()=>{const H=u.current,B=St.trim().toLocaleLowerCase(),ct=++f.current;if(!H||!B){N([]),nt(0),ht(!1);return}ht(!0);const xt=window.setTimeout(()=>void(async()=>{const ve=[];for(let Be=1;Be<=H.numPages;Be+=1){if(f.current!==ct)return;const dr=(await(await H.getPage(Be)).getTextContent()).items.map(ml=>"str"in ml?ml.str:"").join(" ").toLocaleLowerCase();let xa=0;for(;(xa=dr.indexOf(B,xa))>=0;)ve.push(Be),xa+=Math.max(1,B.length)}f.current===ct&&(N(ve),nt(0),ht(!1),ve[0]&&Is(ve[0]))})().catch(()=>{f.current===ct&&ht(!1)}),180);return()=>window.clearTimeout(xt)},[St,x]);const Is=H=>{var ct,xt;const B=Math.max(1,Math.min(x||1,H));(xt=(ct=c.current)==null?void 0:ct.querySelector(`[data-page="${B}"]`))==null||xt.scrollIntoView({block:"start"}),mt(B)},bt=H=>{if(!at.length)return;const B=(lt+H+at.length)%at.length;nt(B),Is(at[B])},kt=R.useMemo(()=>Array.from({length:x},(H,B)=>B+1),[x]);return k.jsxs("div",{ref:l,className:"pdf-viewer",children:[k.jsx(Wb,{paperTitle:e,paperHref:s,resources:i,page:T,pages:x,zoomPercent:Math.round(W*100),searchOpen:O,searchQuery:St,searchMatch:lt,searchCount:at.length,searching:Ft,onPage:Is,onZoomIn:()=>ne(H=>Math.min(3,H+.15)),onZoomOut:()=>ne(H=>Math.max(.5,H-.15)),onToggleSearch:()=>O?fs():z(!0),onCloseSearch:fs,onSearchQuery:It,onSearch:bt}),k.jsx("div",{ref:c,className:"pdf-scroll",role:"region","aria-label":"Paper PDF",children:V?k.jsxs("div",{className:"pdf-error",role:"alert",children:[k.jsx("p",{children:V}),k.jsxs("div",{children:[k.jsx("button",{type:"button",onClick:()=>E(H=>H+1),children:"Retry"})," ",k.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",children:"Open original PDF"})]})]}):k.jsx(Lb,{file:h,loading:k.jsx("div",{className:"pdf-loading",role:"status",children:"Loading paper…"}),onLoadSuccess:H=>{u.current=H,C(H.numPages),q("");const B=Math.max(1,Math.min(H.numPages,n));B>1&&requestAnimationFrame(()=>requestAnimationFrame(()=>{var ct,xt;(xt=(ct=c.current)==null?void 0:ct.querySelector(`[data-page="${B}"]`))==null||xt.scrollIntoView({block:"start"}),P(B),o==null||o(B)}))},onLoadError:H=>q(Vb(H)),externalLinkTarget:"_blank",children:k.jsx("div",{ref:d,className:"pdf-pages",style:{"--pdf-live-scale":Vt},children:kt.map(H=>k.jsx(Xb,{page:H,width:X,searchQuery:St.trim(),activeSearchPage:at[lt]},H))})},`${t}-${S}`)})]})}const Pp=66,kp="pwc:reader:split-ratio",xl=h=>`pwc:reader:session:${h}`,Vh=h=>`pwc:reader:assistant-collapsed:${h}`,Lp=h=>`pwc:reader:page:${h}`;function qh(h){const t=Number(sessionStorage.getItem(Lp(h)));return Number.isInteger(t)&&t>0?t:1}function Kb(){const h=Number(localStorage.getItem(kp));return Number.isFinite(h)&&h>=45&&h<=75?h:Pp}function Qb(h){const t=Xh(h);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 Jb(h){return new URL(h).hostname.replace(/^www\./,"")}function Zb(h){if(!h)return{};const t={};for(const i of h.repositories??[]){if(!i.is_official)continue;const n=Xh(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,label:i.owner&&i.name?`${i.owner}/${i.name}`:`${o[0]}/${o[1].replace(/\.git$/,"")}`,stars:i.num_stars||0};break}}const e=[...h.project_pages??[]].sort((i,n)=>Number(n.is_official)-Number(i.is_official));for(const i of e){const n=Xh(i.url);if(n){t.projectPage={href:n,label:Jb(n)};break}}const s=h.hf_artifact_summary?h.hf_artifact_summary.model_count+h.hf_artifact_summary.dataset_count+h.hf_artifact_summary.space_count:new Set([...h.hf_models??[],...h.hf_datasets??[],...h.hf_spaces??[]]).size;return s>0&&h.arxiv_id&&(t.huggingFace={href:`https://huggingface.co/papers/${h.arxiv_id.replace(/v\d+$/i,"")}`,count:s}),t}function SA(){var Ft,ht,at;const{arxivId:h}=Np(),t=Hp(h??"").replace(/v\d+$/i,""),e=jp(),s=Up(t,!!t),i=$p({queryKey:["chatAvailability"],queryFn:()=>Wp.getAvailability(),refetchInterval:3e4,retry:!1}),n=s.data,a=Qb(n==null?void 0:n.url_pdf),o=Zb(n),l=((Ft=n==null?void 0:n.arxiv_id)==null?void 0:Ft.replace(/v\d+$/i,""))||t,[c,d]=R.useState(()=>sessionStorage.getItem(xl(t))||void 0),[u,f]=R.useState(Kb),[g,A]=R.useState(()=>sessionStorage.getItem(Vh(t))==="1"),[y,w]=R.useState("paper"),[v,_]=R.useState(()=>qh(t)),[S,E]=R.useState(0),[x,C]=R.useState(!1),T=R.useRef(null),P=R.useRef(!1),L=R.useRef(qh(t)),F=S>900&&S>=840;R.useEffect(()=>{h&&h!==t&&e(`/pdf/${t}`,{replace:!0})},[e,h,t]),R.useEffect(()=>{const N=sessionStorage.getItem(xl(t));d(N||void 0),A(sessionStorage.getItem(Vh(t))==="1"),w("paper");const lt=qh(t);L.current=lt,_(lt)},[t]),R.useLayoutEffect(()=>{const N=T.current;if(!N)return;const lt=()=>E(N.clientWidth);lt();const nt=new ResizeObserver(lt);return nt.observe(N),()=>nt.disconnect()},[n]),R.useEffect(()=>{if(!n)return;document.title=`${n.title} — Papers With Code reader`;let N=document.querySelector('meta[name="robots"]');const lt=!N;N||(N=document.createElement("meta"),N.name="robots",document.head.appendChild(N));const nt=N.content;N.content="noindex, nofollow";let X=document.querySelector('link[rel="canonical"]');const Vt=!X;X||(X=document.createElement("link"),X.rel="canonical",document.head.appendChild(X));const ne=X.href;return X.href=`${window.location.origin}/paper/${l}`,()=>{document.title="Papers With Code",lt?N==null||N.remove():N&&(N.content=nt),Vt?X==null||X.remove():X&&(X.href=ne)}},[l,n]);const D=R.useCallback(N=>{if(!S)return Math.max(45,Math.min(75,N));const lt=480/S*100,nt=100-360/S*100;return Math.max(lt,Math.min(nt,N))},[S]);R.useEffect(()=>f(N=>D(N)),[D]);const Y=N=>{const lt=D(N);f(lt),localStorage.setItem(kp,String(lt))},W=N=>{var nt;const lt=(nt=T.current)==null?void 0:nt.getBoundingClientRect();lt&&Y((N-lt.left)/lt.width*100)},G=N=>{P.current=!0,C(!0),N.currentTarget.setPointerCapture(N.pointerId),W(N.clientX)},V=()=>{P.current=!1,C(!1)},q=N=>{A(N),sessionStorage.setItem(Vh(t),N?"1":"0")},O=N=>{d(N),sessionStorage.setItem(xl(t),N)},z=()=>{d(void 0),sessionStorage.removeItem(xl(t))},St=Bp()&&((ht=i.data)==null?void 0:ht.paper_reader_chat_enabled)!==!1,It=n&&St?k.jsx(Vp,{mode:"paper",routeSessionId:c,primaryPaper:{id:n.id,routeId:l,title:n.title},currentPage:()=>L.current,onSessionId:O,onReaderSubmit:()=>w("assistant"),onReaderNewChat:z}):k.jsx("div",{className:"reader-chat-unavailable",children:"Chat is not enabled for this preview."});return s.isLoading?k.jsx("div",{className:"reader-status",role:"status",children:"Loading paper…"}):s.error||!n?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Paper not found."}),k.jsx(Cl,{to:"/papers",children:"Browse papers"})]}):((at=i.data)==null?void 0:at.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(Cl,{to:`/paper/${l}`,children:"Back to paper"})]}):n.source!=="arxiv"||!a?k.jsxs("div",{className:"reader-status",role:"alert",children:[k.jsx("p",{children:"Native reading is unavailable for this resource."}),k.jsx(Cl,{to:`/paper/${l}`,children:"Back to paper"})]}):k.jsxs("div",{className:"paper-reader-shell",children:[!F&&k.jsxs("div",{className:"reader-tabs",role:"tablist","aria-label":"Reader panels",children:[k.jsx("button",{type:"button",role:"tab","aria-selected":y==="paper",onClick:()=>w("paper"),children:"Paper"}),k.jsx("button",{type:"button",role:"tab","aria-selected":y==="assistant",onClick:()=>w("assistant"),children:"Chat"})]}),k.jsxs("div",{ref:T,className:`reader-workspace${F?" is-desktop":" is-tabs"}${g?" is-assistant-collapsed":""}`,children:[k.jsx("section",{className:`reader-paper-pane${!F&&y!=="paper"?" is-hidden":""}`,style:F?{width:g?"100%":`${u}%`}:void 0,role:"tabpanel","aria-label":"Paper","aria-hidden":!F&&y!=="paper",children:k.jsx(Yb,{url:a,paperKey:l,paperTitle:n.title,paperHref:`/paper/${l}`,resources:o,initialPage:v,resizeActive:x,onPageChange:N=>{L.current=N,sessionStorage.setItem(Lp(t),String(N))}})}),F&&!g&&k.jsx("div",{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(u),tabIndex:0,onPointerDown:G,onPointerMove:N=>{P.current&&W(N.clientX)},onPointerUp:V,onPointerCancel:V,onLostPointerCapture:V,onDoubleClick:()=>Y(Pp),onKeyDown:N=>{(N.key==="ArrowLeft"||N.key==="ArrowRight")&&(N.preventDefault(),Y(u+(N.key==="ArrowRight"?2:-2))),N.key==="Home"&&Y(45),N.key==="End"&&Y(75)}}),k.jsx("aside",{className:`reader-assistant-pane${!F&&y!=="assistant"||g?" is-hidden":""}`,style:F?{width:g?0:`${100-u}%`}:void 0,role:"tabpanel","aria-label":"Chat","aria-hidden":!F&&y!=="assistant"||g,children:It}),F&&k.jsx("button",{type:"button",className:"reader-collapse-assistant",onClick:()=>q(!g),children:g?"Chat":"Hide Chat"})]})]})}export{SA as default,Qb as directArxivPdfHref,Zb as readerToolbarResources};