PageSourceSearch

https://norteapp.io/assets/vendor-pdf-B_Iox9OD.js

js norteapp.io collected 2026-10-08 12:18:28 UTC 388,619 bytes, 1 lines download raw bytes

1var t,e,s,i,n,a,r,o,l,h,c,d,u,p,g,f,m,v,w,b,A,_,y,x,S,k,M,E,C,T,R,P,I,D,L,N,F,W,O,B,H,$,z,j,G,V,U,q,X,Y,K,Q,J,Z,tt,et,st,it,nt,at,rt,ot,lt,ht,ct,dt,ut,pt,gt,ft,mt,vt,wt,bt,At,_t,yt,xt,St,kt,Mt,Et,Ct,Tt,Rt,Pt,It,Dt,Lt,Nt,Ft,Wt,Ot,Bt,Ht,$t,zt,jt,Gt,Vt,Ut,qt,Xt,Yt,Kt,Qt,Jt,Zt,te,ee,se,ie,ne,ae,re,oe,le,he,ce,de,ue,pe,ge,fe,me,ve,we,be,Ae,_e,ye,xe,Se,ke,Me,Ee,Ce,Te,Re,Pe,Ie,De,Le,Ne,Fe,We,Oe,Be,He,$e,ze,je,Ge,Ve,Ue,qe,Xe,Ye,Ke,Qe,Je,Ze,ts,es,ss,is,ns,as,rs,os,ls,hs,cs,ds,us,ps,gs,fs,ms,vs,ws,bs,As,_s,ys,xs,Ss,ks,Ms,Es,Cs,Ts,Rs,Ps,Is,Ds,Ls,Ns,Fs,Ws,Os,Bs,Hs,$s,zs,js,Gs,Vs,Us,qs,Xs,Ys,Ks,Qs,Js,Zs,ti,ei,si,ii,ni,ai,ri,oi,li,hi,ci,di,ui,pi,gi,fi,mi,vi,wi,bi,Ai,_i,yi,xi,Si,ki,Mi,Ei,Ci,Ti,Ri,Pi,Ii,Di,Li,Ni,Fi,Wi,Oi,Bi,Hi,$i,zi,ji,Gi,Vi,Ui,qi,Xi,Yi,Ki,Qi,Ji,Zi,tn,en,sn,nn,an,rn,on,ln,hn,cn,dn,un,pn,gn,fn,mn,vn,wn,bn,An,_n,yn,xn,Sn,kn,Mn,En,Cn,Tn,Rn,Pn,In,Dn,Ln,Nn,Fn,Wn,On,Bn,Hn,$n,zn,jn,Gn,Vn,Un,qn,Xn,Yn,Kn,Qn,Jn,Zn,ta,ea,sa,ia,na,aa,ra,oa,la,ha,ca,da,ua,pa,ga,fa,ma,va,wa,ba,Aa,_a,ya,xa,Sa,ka,Ma,Ea,Ca,Ta,Ra,Pa,Ia,Da,La,Na,Fa,Wa,Oa,Ba,Ha,$a,za,ja,Ga,Va,Ua,qa,Xa,Ya,Ka,Qa,Ja,Za,tr,er,sr,ir,nr,ar,rr,or,lr,hr,cr,dr,ur,pr,gr,fr,mr,vr,wr,br,Ar,_r,yr,xr,Sr,kr,Mr,Er,Cr,Tr,Rr,Pr,Ir,Dr,Lr,Nr,Fr,Wr,Or,Br,Hr,$r,zr,jr,Gr,Vr,Ur,qr,Xr,Yr,Kr,Qr,Jr,Zr,to,eo,so,io,no,ao,ro,oo,lo,ho,co,uo,po,go,fo,mo,vo,wo,bo,Ao,_o,yo,xo,So,ko,Mo,Eo,Co,To,Ro,Po,Io,Do,Lo,No,Fo,Wo,Oo,Bo,Ho,$o,zo,jo,Go,Vo,Uo,qo,Xo,Yo,Ko,Qo,Jo,Zo,tl,el,sl,il,nl,al,rl,ol,ll,hl,cl,dl,ul,pl,gl,fl,ml,vl,wl,bl,Al,_l,yl,xl,Sl,kl,Ml,El,Cl,Tl,Rl,Pl,Il,Dl,Ll,Nl,Fl,Wl,Ol,Bl,Hl,$l,zl,jl,Gl,Vl,Ul,ql,Xl,Yl,Kl,Ql,Jl,Zl,th,eh,sh,ih,nh,ah,rh,oh,lh,hh,ch,dh,uh,ph,gh,fh,mh,vh,wh,bh,Ah,_h,yh,xh,Sh,kh,Mh,Eh,Ch,Th,Rh,Ph,Ih,Dh,Lh,Nh,Fh,Wh,Oh,Bh,Hh,$h,zh,jh,Gh,Vh,Uh,qh,Xh,Yh,Kh,Qh,Jh,Zh,tc,ec,sc,ic,nc,ac,rc,oc,lc,hc,cc,dc,uc,pc,gc,fc,mc,vc,wc=Object.defineProperty,bc=t=>{throw TypeError(t)},Ac=(t,e,s)=>((t,e,s)=>e in t?wc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s),_c=(t,e,s)=>e.has(t)||bc("Cannot "+s),yc=(t,e,s)=>(_c(t,e,"read from private field"),s?s.call(t):e.get(t)),xc=(t,e,s)=>e.has(t)?bc("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,s),Sc=(t,e,s,i)=>(_c(t,e,"write to private field"),i?i.call(t,s):e.set(t,s),s),kc=(t,e,s)=>(_c(t,e,"access private method"),s),Mc=(t,e,s,i)=>({set _(i){Sc(t,e,i,s)},get _(){return yc(t,e,i)}});const Ec=!("object"!=typeof process||process+""!="[object process]"||process.versions.nw||process.versions.electron&&process.type&&"browser"!==process.type),Cc=[.001,0,0,.001,0,0],Tc=1.35,Rc=1,Pc=2,Ic=4,Dc=16,Lc=32,Nc=64,Fc=128,Wc=256,Oc={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Bc="pdfjs_internal_editor_",Hc={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,SIGNATURE:101,COMMENT:102},$c={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_THICKNESS:32,HIGHLIGHT_FREE:33,HIGHLIGHT_SHOW_ALL:34,DRAW_STEP:41},zc={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},jc=0,Gc=1,Vc=2,Uc=3,qc=3,Xc=4,Yc={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Kc={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,SOUND:18,MOVIE:19,WIDGET:20,SCREEN:21,PRINTERMARK:22,TRAPNET:23,WATERMARK:24,THREED:25,REDACT:26},Qc=1,Jc=2,Zc=3,td=4,ed=5,sd={ERRORS:0,WARNINGS:1,INFOS:5},id={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93,rawFillPath:94},nd=0,ad=1,rd=2,od=3,ld={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let hd=sd.WARNINGS;function cd(){return hd}function dd(t){}function ud(t){throw new Error(t)}function pd(t,e){t||ud(e)}function gd(t,e=null,s=null){if(!t)return null;if(s&&"string"==typeof t){if(s.addDefaultProtocol&&t.startsWith("www.")){const e=t.match(/\./g);(null==e?void 0:e.length)>=2&&(t=`http://${t}`)}
vendor: 9,157 bytes, line 1
1if(s.tryConvertEncoding)try{t=decodeURIComponent(escape(t))}catch{}}const i=e?URL.parse(t,e):URL.parse(t);return function(t){switch(null==t?void 0:t.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(i)?i:null}function fd(t,e,s=!1){const i=URL.parse(t);return i?(i.hash=e,i.href):s&&gd(t,"http://example.com")?t.split("#",1)[0]+""+(e?`#${e}`:""):""}function md(t,e,s,i=!1){return Object.defineProperty(t,e,{value:s,enumerable:!i,configurable:!0,writable:!1}),s}const vd=function(){function t(t,e){this.message=t,this.name=e}return t.prototype=new Error,t.constructor=t,t}();class wd extends vd{constructor(t,e){super(t,"PasswordException"),this.code=e}}class bd extends vd{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Ad extends vd{constructor(t){super(t,"InvalidPDFException")}}class _d extends vd{constructor(t,e,s){super(t,"ResponseException"),this.status=e,this.missing=s}}class yd extends vd{constructor(t){super(t,"FormatError")}}class xd extends vd{constructor(t){super(t,"AbortException")}}function Sd(t){"object"==typeof t&&void 0!==(null==t?void 0:t.length)||ud("Invalid argument for bytesToString");const e=t.length,s=8192;if(e<s)return String.fromCharCode.apply(null,t);const i=[];for(let n=0;n<e;n+=s){const a=Math.min(n+s,e),r=t.subarray(n,a);i.push(String.fromCharCode.apply(null,r))}return i.join("")}function kd(t){"string"!=typeof t&&ud("Invalid argument for stringToBytes");const e=t.length,s=new Uint8Array(e);for(let i=0;i<e;++i)s[i]=255&t.charCodeAt(i);return s}class Md{static get isLittleEndian(){return md(this,"isLittleEndian",function(){const t=new Uint8Array(4);return t[0]=1,1===new Uint32Array(t.buffer,0,1)[0]}())}static get isEvalSupported(){return md(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return md(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return md(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){const{platform:t,userAgent:e}=navigator;return md(this,"platform",{isAndroid:e.includes("Android"),isLinux:t.includes("Linux"),isMac:t.includes("Mac"),isWindows:t.includes("Win"),isFirefox:e.includes("Firefox")})}static get isCSSRoundSupported(){var t,e;return md(this,"isCSSRoundSupported",null==(e=null==(t=globalThis.CSS)?void 0:t.supports)?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Ed=Array.from(Array(256).keys(),t=>t.toString(16).padStart(2,"0"));class Cd{static makeHexColor(t,e,s){return`#${Ed[t]}${Ed[e]}${Ed[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,s=0){const i=t[s],n=t[s+1];t[s]=i*e[0]+n*e[2]+e[4],t[s+1]=i*e[1]+n*e[3]+e[5]}static applyTransformToBezier(t,e,s=0){const i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5];for(let h=0;h<6;h+=2){const e=t[s+h],c=t[s+h+1];t[s+h]=e*i+c*a+o,t[s+h+1]=e*n+c*r+l}}static applyInverseTransform(t,e){const s=t[0],i=t[1],n=e[0]*e[3]-e[1]*e[2];t[0]=(s*e[3]-i*e[2]+e[2]*e[5]-e[4]*e[3])/n,t[1]=(-s*e[1]+i*e[0]+e[4]*e[1]-e[5]*e[0])/n}static axialAlignedBoundingBox(t,e,s){const i=e[0],n=e[1],a=e[2],r=e[3],o=e[4],l=e[5],h=t[0],c=t[1],d=t[2],u=t[3];let p=i*h+o,g=p,f=i*d+o,m=f,v=r*c+l,w=v,b=r*u+l,A=b;if(0!==n||0!==a){const t=n*h,e=n*d,s=a*c,i=a*u;p+=s,m+=s,f+=i,g+=i,v+=t,A+=t,b+=e,w+=e}s[0]=Math.min(s[0],p,f,g,m),s[1]=Math.min(s[1],v,b,w,A),s[2]=Math.max(s[2],p,f,g,m),s[3]=Math.max(s[3],v,b,w,A)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const s=t[0],i=t[1],n=t[2],a=t[3],r=s**2+i**2,o=s*n+i*a,l=n**2+a**2,h=(r+l)/2,c=Math.sqrt(h**2-(r*l-o**2));e[0]=Math.sqrt(h+c||1),e[1]=Math.sqrt(h-c||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const s=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),i=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(s>i)return null;const 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 pointBoundingBox(t,e,s){s[0]=Math.min(s[0],t),s[1]=Math.min(s[1],e),s[2]=Math.max(s[2],t),s[3]=Math.max(s[3],e)}static rectBoundingBox(t,e,s,i,n){n[0]=Math.min(n[0],t,s),n[1]=Math.min(n[1],e,i),n[2]=Math.max(n[2],t,s),n[3]=Math.max(n[3],e,i)}static bezierBoundingBox(e,i,n,a,r,o,l,h,c){c[0]=Math.min(c[0],e,l),c[1]=Math.min(c[1],i,h),c[2]=Math.max(c[2],e,l),c[3]=Math.max(c[3],i,h),kc(this,t,s).call(this,e,n,r,l,i,a,o,h,3*(3*(n-r)-e+l),6*(e-2*n+r),3*(n-e),c),kc(this,t,s).call(this,e,n,r,l,i,a,o,h,3*(3*(a-o)-i+h),6*(i-2*a+o),3*(a-i),c)}}t=new WeakSet,e=function(t,e,s,i,n,a,r,o,l,h){if(l<=0||l>=1)return;const c=1-l,d=l*l,u=d*l,p=c*(c*(c*t+3*l*e)+3*d*s)+u*i,g=c*(c*(c*n+3*l*a)+3*d*r)+u*o;h[0]=Math.min(h[0],p),h[1]=Math.min(h[1],g),h[2]=Math.max(h[2],p),h[3]=Math.max(h[3],g)},s=function(s,i,n,a,r,o,l,h,c,d,u,p){if(Math.abs(c)<1e-12)return void(Math.abs(d)>=1e-12&&kc(this,t,e).call(this,s,i,n,a,r,o,l,h,-u/d,p));const g=d**2-4*u*c;if(g<0)return;const f=Math.sqrt(g),m=2*c;kc(this,t,e).call(this,s,i,n,a,r,o,l,h,(-d+f)/m,p),kc(this,t,e).call(this,s,i,n,a,r,o,l,h,(-d-f)/m,p)},xc(Cd,t);let Td=null,Rd=null;function Pd(t){return Td||(Td=/([\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,Rd=new Map([["ſt","ſt"]])),t.replaceAll(Td,(t,e,s)=>e?e.normalize("NFKC"):Rd.get(s))}function Id(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const t=new Uint8Array(32);return crypto.getRandomValues(t),Sd(t)}const Dd="pdfjs_internal_id_";function Ld(t,e,s){return Math.min(Math.max(t,e),s)}function Nd(t){return Uint8Array.prototype.toBase64?t.toBase64():btoa(Sd(t))}"function"!=typeof Promise.try&&(Promise.try=function(t,...e){return new Promise(s=>{s(t(...e))})}),"function"!=typeof Math.sumPrecise&&(Math.sumPrecise=function(t){return t.reduce((t,e)=>t+e,0)});const Fd="http://www.w3.org/2000/svg",Wd=class{};Ac(Wd,"CSS",96),Ac(Wd,"PDF",72),Ac(Wd,"PDF_TO_CSS_UNITS",Wd.CSS/Wd.PDF);let Od=Wd;async function Bd(t,e="text"){if(qd(t,document.baseURI)){const s=await fetch(t);if(!s.ok)throw new Error(s.statusText);switch(e){case"arraybuffer":return s.arrayBuffer();case"blob":return s.blob();case"json":return s.json()}return s.text()}return new Promise((s,i)=>{const n=new XMLHttpRequest;n.open("GET",t,!0),n.responseType=e,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE)if(200!==n.status&&0!==n.status)i(new Error(n.statusText));else{switch(e){case"arraybuffer":case"blob":case"json":return void s(n.response)}s(n.responseText)}},n.send(null)})}class Hd{constructor({viewBox:t,userUnit:e,scale:s,rotation:i,offsetX:n=0,offsetY:a=0,dontFlip:r=!1}){this.viewBox=t,this.userUnit=e,this.scale=s,this.rotation=i,this.offsetX=n,this.offsetY=a,s*=e;const o=(t[2]+t[0])/2,l=(t[3]+t[1])/2;let h,c,d,u,p,g,f,m;switch((i%=360)<0&&(i+=360),i){case 180:h=-1,c=0,d=0,u=1;break;case 90:h=0,c=1,d=1,u=0;break;case 270:h=0,c=-1,d=-1,u=0;break;case 0:h=1,c=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}r&&(d=-d,u=-u),0===h?(p=Math.abs(l-t[1])*s+n,g=Math.abs(o-t[0])*s+a,f=(t[3]-t[1])*s,m=(t[2]-t[0])*s):(p=Math.abs(o-t[0])*s+n,g=Math.abs(l-t[1])*s+a,f=(t[2]-t[0])*s,m=(t[3]-t[1])*s),this.transform=[h*s,c*s,d*s,u*s,p-h*s*o-d*s*l,g-c*s*o-u*s*l],this.width=f,this.height=m}get rawDims(){const t=this.viewBox;return md(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 Hd({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}convertToViewportPoint(t,e){const s=[t,e];return Cd.applyTransform(s,this.transform),s}convertToViewportRectangle(t){const e=[t[0],t[1]];Cd.applyTransform(e,this.transform);const s=[t[2],t[3]];return Cd.applyTransform(s,this.transform),[e[0],e[1],s[0],s[1]]}convertToPdfPoint(t,e){const s=[t,e];return Cd.applyInverseTransform(s,this.transform),s}}class $d extends vd{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function zd(t){const e=t.length;let s=0;for(;s<e&&""===t[s].trim();)s++;return"data:"===t.substring(s,s+5).toLowerCase()}
1function jd(t){return"string"==typeof t&&/\.pdf$/i.test(t)}function Gd(t){return[t]=t.split(/[#?]/,1),t.substring(t.lastIndexOf("/")+1)}function Vd(t,e="document.pdf"){if("string"!=typeof t)return e;if(zd(t))return e;const s=(t=>{try{return new URL(t)}catch{try{return new URL(decodeURIComponent(t))}catch{try{return new URL(t,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(t),"https://foo.bar")}catch{return null}}}}})(t);if(!s)return e;const i=t=>{try{let e=decodeURIComponent(t);return e.includes("/")?(e=e.split("/").at(-1),e.test(/^\.pdf$/i)?e:t):e}catch{return t}},n=/\.pdf$/i,a=s.pathname.split("/").at(-1);if(n.test(a))return i(a);if(s.searchParams.size>0){const t=Array.from(s.searchParams.values()).reverse();for(const s of t)if(n.test(s))return i(s);const e=Array.from(s.searchParams.keys()).reverse();for(const s of e)if(n.test(s))return i(s)}if(s.hash){const t=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(s.hash);if(t)return i(t[0])}return e}class Ud{constructor(){Ac(this,"started",Object.create(null)),Ac(this,"times",[])}time(t){this.started,this.started[t]=Date.now()}timeEnd(t){this.started,this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:s}of this.times)e=Math.max(s.length,e);for(const{name:s,start:i,end:n}of this.times)t.push(`${s.padEnd(e)} ${n-i}ms\n`);return t.join("")}}function qd(t,e){const s=e?URL.parse(t,e):URL.parse(t);return"http:"===(null==s?void 0:s.protocol)||"https:"===(null==s?void 0:s.protocol)}function Xd(t){t.preventDefault()}function Yd(t){t.preventDefault(),t.stopPropagation()}class Kd{static toDateObject(t){if(t instanceof Date)return t;if(!t||"string"!=typeof t)return null;yc(this,i)||Sc(this,i,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=yc(this,i).exec(t);if(!e)return null;const s=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let a=parseInt(e[3],10);a=a>=1&&a<=31?a:1;let r=parseInt(e[4],10);r=r>=0&&r<=23?r:0;let o=parseInt(e[5],10);o=o>=0&&o<=59?o:0;let l=parseInt(e[6],10);l=l>=0&&l<=59?l:0;const h=e[7]||"Z";let c=parseInt(e[8],10);c=c>=0&&c<=23?c:0;let d=parseInt(e[9],10)||0;return d=d>=0&&d<=59?d:0,"-"===h?(r+=c,o+=d):"+"===h&&(r-=c,o-=d),new Date(Date.UTC(s,n,a,r,o,l))}}function Qd(t,{scale:e=1,rotation:s=0}){const{width:i,height:n}=t.attributes.style,a=[0,0,parseInt(i),parseInt(n)];return new Hd({viewBox:a,userUnit:1,scale:e,rotation:s})}function Jd(t){if(t.startsWith("#")){const e=parseInt(t.slice(1),16);return[(16711680&e)>>16,(65280&e)>>8,255&e]}return t.startsWith("rgb(")?t.slice(4,-1).split(",").map(t=>parseInt(t)):t.startsWith("rgba(")?t.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):[0,0,0]}function Zd(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform();return[e,s,i,n,a,r]}function tu(t){const{a:e,b:s,c:i,d:n,e:a,f:r}=t.getTransform().invertSelf();return[e,s,i,n,a,r]}function eu(t,e,s=!1,i=!0){if(e instanceof Hd){const{pageWidth:i,pageHeight:n}=e.rawDims,{style:a}=t,r=Md.isCSSRoundSupported,o=`var(--total-scale-factor) * ${i}px`,l=`var(--total-scale-factor) * ${n}px`,h=r?`round(down, ${o}, var(--scale-round-x))`:`calc(${o})`,c=r?`round(down, ${l}, var(--scale-round-y))`:`calc(${l})`;s&&e.rotation%180!=0?(a.width=c,a.height=h):(a.width=h,a.height=c)}i&&t.setAttribute("data-main-rotation",e.rotation)}i=new WeakMap,xc(Kd,i);class su{constructor(){const{pixelRatio:t}=su;this.sx=t,this.sy=t}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,s,i,n=-1){let a=1/0,r=1/0,o=1/0;(s=su.capPixels(s,n))>0&&(a=Math.sqrt(s/(t*e))),-1!==i&&(r=i/t,o=i/e);const l=Math.min(a,r,o);return(this.sx>l||this.sy>l)&&(this.sx=l,this.sy=l,!0)}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const s=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,s):s}return t}}const iu=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"],nu=class t{constructor(e){xc(this,g),xc(this,n,null),xc(this,a,null),xc(this,r),xc(this,o,null),xc(this,l,null),xc(this,h,null),xc(this,c,null),Sc(this,r,e),yc(t,d)||Sc(t,d,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const e=Sc(this,n,document.createElement("div"));e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const s=yc(this,r)._uiManager._signal;e.addEventListener("contextmenu",Xd,{signal:s}),e.addEventListener("pointerdown",kc(t,u,p),{signal:s});const i=Sc(this,o,document.createElement("div"));i.className="buttons",e.append(i);const a=yc(this,r).toolbarPosition;if(a){const{style:t}=e,s="ltr"===yc(this,r)._uiManager.direction?1-a[0]:a[0];t.insetInlineEnd=100*s+"%",t.top=`calc(${100*a[1]}% + var(--editor-toolbar-vert-offset))`}return e}get div(){return yc(this,n)}hide(){var t;yc(this,n).classList.add("hidden"),null==(t=yc(this,a))||t.hideDropdown()}show(){var t,e;yc(this,n).classList.remove("hidden"),null==(t=yc(this,l))||t.shown(),null==(e=yc(this,h))||e.shown()}
1addDeleteButton(){const{editorType:e,_uiManager:s}=yc(this,r),i=document.createElement("button");i.className="delete",i.tabIndex=0,i.setAttribute("data-l10n-id",yc(t,d)[e]),kc(this,g,v).call(this,i),i.addEventListener("click",t=>{s.delete()},{signal:s._signal}),yc(this,o).append(i)}async addAltText(t){const e=await t.render();kc(this,g,v).call(this,e),yc(this,o).append(e,yc(this,g,w)),Sc(this,l,t)}addComment(t){if(yc(this,h))return;const e=t.render();e&&(kc(this,g,v).call(this,e),yc(this,o).prepend(e,yc(this,g,w)),Sc(this,h,t),t.toolbar=this)}addColorPicker(t){if(yc(this,a))return;Sc(this,a,t);const e=t.renderButton();kc(this,g,v).call(this,e),yc(this,o).append(e,yc(this,g,w))}async addEditSignatureButton(t){const e=Sc(this,c,await t.renderEditButton(yc(this,r)));kc(this,g,v).call(this,e),yc(this,o).append(e,yc(this,g,w))}async addButton(t,e){switch(t){case"colorPicker":this.addColorPicker(e);break;case"altText":await this.addAltText(e);break;case"editSignature":await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":this.addComment(e)}}updateEditSignatureButton(t){yc(this,c)&&(yc(this,c).title=t)}remove(){var t;yc(this,n).remove(),null==(t=yc(this,a))||t.destroy(),Sc(this,a,null)}};n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new WeakMap,l=new WeakMap,h=new WeakMap,c=new WeakMap,d=new WeakMap,u=new WeakSet,p=function(t){t.stopPropagation()},g=new WeakSet,f=function(t){yc(this,r)._focusEventsAllowed=!1,Yd(t)},m=function(t){yc(this,r)._focusEventsAllowed=!0,Yd(t)},v=function(t){const e=yc(this,r)._uiManager._signal;t.addEventListener("focusin",kc(this,g,f).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",kc(this,g,m).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",Xd,{signal:e})},w=function(){const t=document.createElement("div");return t.className="divider",t},xc(nu,u),xc(nu,d,null);let au=nu;class ru{constructor(t){xc(this,y),xc(this,b,null),xc(this,A,null),xc(this,_),Sc(this,_,t)}show(t,e,s){const[i,n]=kc(this,y,S).call(this,e,s),{style:a}=yc(this,A)||Sc(this,A,kc(this,y,x).call(this));t.append(yc(this,A)),a.insetInlineEnd=100*i+"%",a.top=`calc(${100*n}% + var(--editor-toolbar-vert-offset))`}hide(){yc(this,A).remove()}}function ou(t,e,s){for(const i of s)e.addEventListener(i,t[i].bind(t))}b=new WeakMap,A=new WeakMap,_=new WeakMap,y=new WeakSet,x=function(){const t=Sc(this,A,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar"),t.addEventListener("contextmenu",Xd,{signal:yc(this,_)._signal});const e=Sc(this,b,document.createElement("div"));return e.className="buttons",t.append(e),kc(this,y,k).call(this),t},S=function(t,e){let s=0,i=0;for(const n of t){const t=n.y+n.height;if(t<s)continue;const a=n.x+(e?n.width:0);t>s?(i=a,s=t):e?a>i&&(i=a):a<i&&(i=a)}return[e?1-i:i,s]},k=function(){const t=document.createElement("button");t.className="highlightButton",t.tabIndex=0,t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const e=document.createElement("span");t.append(e),e.className="visuallyHidden",e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const s=yc(this,_)._signal;t.addEventListener("contextmenu",Xd,{signal:s}),t.addEventListener("click",()=>{yc(this,_).highlightSelection("floating_button")},{signal:s}),yc(this,b).append(t)};class lu{constructor(){xc(this,M,0)}get id(){return`${Bc}${Mc(this,M)._++}`}}M=new WeakMap;const hu=class{constructor(){xc(this,R),xc(this,E,Id()),xc(this,C,0),xc(this,T,null)}static get _isSVGFittingCanvas(){const t=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),e=new Image;e.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>';return md(this,"_isSVGFittingCanvas",e.decode().then(()=>(t.drawImage(e,0,0,1,1,0,0,1,3),0===new Uint32Array(t.getImageData(0,0,1,1).data.buffer)[0])))}async getFromFile(t){const{lastModified:e,name:s,size:i,type:n}=t;return kc(this,R,P).call(this,`${e}_${s}_${i}_${n}`,t)}async getFromUrl(t){return kc(this,R,P).call(this,t,t)}async getFromBlob(t,e){const s=await e;return kc(this,R,P).call(this,t,s)}async getFromId(t){yc(this,T)||Sc(this,T,new Map);const e=yc(this,T).get(t);if(!e)return null;if(e.bitmap)return e.refCounter+=1,e;if(e.file)return this.getFromFile(e.file);if(e.blobPromise){const{blobPromise:t}=e;return delete e.blobPromise,this.getFromBlob(e.id,t)}return this.getFromUrl(e.url)}getFromCanvas(t,e){yc(this,T)||Sc(this,T,new Map);let s=yc(this,T).get(t);if(null==s?void 0: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_${yc(this,E)}_${Mc(this,C)._++}`,refCounter:1,isSvg:!1},yc(this,T).set(t,s),yc(this,T).set(s.id,s),s}getSvgUrl(t){const e=yc(this,T).get(t);return(null==e?void 0:e.isSvg)?e.svgUrl:null}deleteId(t){var e;yc(this,T)||Sc(this,T,new Map);const s=yc(this,T).get(t);if(!s)return;if(s.refCounter-=1,0!==s.refCounter)return;const{bitmap:i}=s;if(!s.url&&!s.file){const t=new OffscreenCanvas(i.width,i.height);t.getContext("bitmaprenderer").transferFromImageBitmap(i),s.blobPromise=t.convertToBlob()}null==(e=i.close)||e.call(i),s.bitmap=null}isValidId(t){return t.startsWith(`image_${yc(this,E)}_`)}};E=new WeakMap,C=new WeakMap,T=new WeakMap,R=new WeakSet,P=async function(t,e){yc(this,T)||Sc(this,T,new Map);let s=yc(this,T).get(t);if(null===s)return null;if(null==s?void 0:s.bitmap)return s.refCounter+=1,s;try{let t;if(s||(s={bitmap:null,id:`image_${yc(this,E)}_${Mc(this,C)._++}`,refCounter:0,isSvg:!1}),"string"==typeof e?(s.url=e,t=await Bd(e,"blob")):e instanceof File?t=s.file=e:e instanceof Blob&&(t=e),"image/svg+xml"===t.type){const e=hu._isSVGFittingCanvas,i=new FileReader,n=new Image,a=new Promise((t,a)=>{n.onload=()=>
1{s.bitmap=n,s.isSvg=!0,t()},i.onload=async()=>{const t=s.svgUrl=i.result;n.src=await e?`${t}#svgView(preserveAspectRatio(none))`:t},n.onerror=i.onerror=a});i.readAsDataURL(t),await a}else s.bitmap=await createImageBitmap(t);s.refCounter=1}catch(i){s=null}return yc(this,T).set(t,s),s&&yc(this,T).set(s.id,s),s};let cu=hu;class du{constructor(t=128){xc(this,I,[]),xc(this,D,!1),xc(this,L),xc(this,N,-1),Sc(this,L,t)}add({cmd:t,undo:e,post:s,mustExec:i,type:n=NaN,overwriteIfSameType:a=!1,keepUndo:r=!1}){if(i&&t(),yc(this,D))return;const o={cmd:t,undo:e,post:s,type:n};if(-1===yc(this,N))return yc(this,I).length>0&&(yc(this,I).length=0),Sc(this,N,0),void yc(this,I).push(o);if(a&&yc(this,I)[yc(this,N)].type===n)return r&&(o.undo=yc(this,I)[yc(this,N)].undo),void(yc(this,I)[yc(this,N)]=o);const l=yc(this,N)+1;l===yc(this,L)?yc(this,I).splice(0,1):(Sc(this,N,l),l<yc(this,I).length&&yc(this,I).splice(l)),yc(this,I).push(o)}undo(){if(-1===yc(this,N))return;Sc(this,D,!0);const{undo:t,post:e}=yc(this,I)[yc(this,N)];t(),null==e||e(),Sc(this,D,!1),Sc(this,N,yc(this,N)-1)}redo(){if(yc(this,N)<yc(this,I).length-1){Sc(this,N,yc(this,N)+1),Sc(this,D,!0);const{cmd:t,post:e}=yc(this,I)[yc(this,N)];t(),null==e||e(),Sc(this,D,!1)}}hasSomethingToUndo(){return-1!==yc(this,N)}hasSomethingToRedo(){return yc(this,N)<yc(this,I).length-1}cleanType(t){if(-1!==yc(this,N)){for(let e=yc(this,N);e>=0;e--)if(yc(this,I)[e].type!==t)return yc(this,I).splice(e+1,yc(this,N)-e),void Sc(this,N,e);yc(this,I).length=0,Sc(this,N,-1)}}destroy(){Sc(this,I,null)}}I=new WeakMap,D=new WeakMap,L=new WeakMap,N=new WeakMap;class uu{constructor(t){xc(this,F),this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=Md.platform;for(const[s,i,n={}]of t)for(const t of s){const s=t.startsWith("mac+");e&&s?(this.callbacks.set(t.slice(4),{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1))):e||s||(this.callbacks.set(t,{callback:i,options:n}),this.allKeys.add(t.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const s=this.callbacks.get(kc(this,F,W).call(this,e));if(!s)return;const{callback:i,options:{bubbles:n=!1,args:a=[],checker:r=null}}=s;r&&!r(t,e)||(i.bind(t,...a,e)(),n||Yd(e))}}F=new WeakSet,W=function(t){t.altKey&&this.buffer.push("alt"),t.ctrlKey&&this.buffer.push("ctrl"),t.metaKey&&this.buffer.push("meta"),t.shiftKey&&this.buffer.push("shift"),this.buffer.push(t.key);const e=this.buffer.join("+");return this.buffer.length=0,e};const pu=class t{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return function(t){const e=document.createElement("span");e.style.visibility="hidden",e.style.colorScheme="only light",document.body.append(e);for(const s of t.keys()){e.style.color=s;const i=window.getComputedStyle(e).color;t.set(s,Jd(i))}e.remove()}(t),md(this,"_colors",t)}convert(e){const s=Jd(e);if(!window.matchMedia("(forced-colors: active)").matches)return s;for(const[i,n]of this._colors)if(n.every((t,e)=>t===s[e]))return t._colorsMapping.get(i);return s}getHexCode(t){const e=this._colors.get(t);return e?Cd.makeHexColor(...e):t}};Ac(pu,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let gu=pu;const fu=class t{constructor(t,e,s,i,n,a,r,o,l,h,c,d,u,p,g,f){xc(this,Rt),xc(this,O,new AbortController),xc(this,B,null),xc(this,H,new Map),xc(this,$,new Map),xc(this,z,null),xc(this,j,null),xc(this,G,null),xc(this,V,new du),xc(this,U,null),xc(this,q,null),xc(this,X,null),xc(this,Y,0),xc(this,K,new Set),xc(this,Q,null),xc(this,J,null),xc(this,Z,new Set),Ac(this,"_editorUndoBar",null),xc(this,tt,!1),xc(this,et,!1),xc(this,st,!1),xc(this,it,null),xc(this,nt,null),xc(this,at,null),xc(this,rt,null),xc(this,ot,!1),xc(this,lt,null),xc(this,ht,new lu),xc(this,ct,!1),xc(this,dt,!1),xc(this,ut,null),xc(this,pt,null),xc(this,gt,null),xc(this,ft,null),xc(this,mt,null),xc(this,vt,Hc.NONE),xc(this,wt,new Set),xc(this,bt,null),xc(this,At,null),xc(this,_t,null),xc(this,yt,null),xc(this,xt,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1}),xc(this,St,[0,0]),xc(this,kt,null),xc(this,Mt,null),xc(this,Et,null),xc(this,Ct,null),xc(this,Tt,null);const m=this._signal=yc(this,O).signal;Sc(this,Mt,t),Sc(this,Et,e),Sc(this,Ct,s),Sc(this,z,i),Sc(this,U,n),Sc(this,At,a),this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:m}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),r._on("setpreference",this.onSetPreference.bind(this),{signal:m}),r._on("switchannotationeditorparams",t=>this.updateParams(t.type,t.value),{signal:m}),kc(this,Rt,Ft).call(this),kc(this,Rt,jt).call(this),kc(this,Rt,Bt).call(this),Sc(this,j,o.annotationStorage),Sc(this,it,o.filterFactory),Sc(this,_t,l),Sc(this,rt,h||null),Sc(this,tt,c),Sc(this,et,d),Sc(this,st,u),Sc(this,mt,p||null),this.viewParameters={realScale:Od.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=g||null,this._supportsPinchToZoom=!1!==f}static get _keyboardManager(){const e=t.prototype,s=t=>yc(t,Mt).contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&t.hasSomethingToControl(),i=(t,{target:e})=>
1{if(e instanceof HTMLInputElement){const{type:t}=e;return"text"!==t&&"number"!==t}return!0},n=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return md(this,"_keyboardManager",new uu([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],e.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:i}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:i}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&yc(t,Mt).contains(e)&&!t.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(t,{target:e})=>!(e instanceof HTMLButtonElement)&&yc(t,Mt).contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-n,0],checker:s}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:s}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[n,0],checker:s}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:s}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-n],checker:s}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:s}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,n],checker:s}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:s}]]))}destroy(){var t,e,s,i,n,a,r,o,l;null==(t=yc(this,Tt))||t.resolve(),Sc(this,Tt,null),null==(e=yc(this,O))||e.abort(),Sc(this,O,null),this._signal=null;for(const h of yc(this,$).values())h.destroy();yc(this,$).clear(),yc(this,H).clear(),yc(this,Z).clear(),null==(s=yc(this,ft))||s.clear(),Sc(this,B,null),yc(this,wt).clear(),yc(this,V).destroy(),null==(i=yc(this,z))||i.destroy(),null==(n=yc(this,U))||n.destroy(),null==(a=yc(this,At))||a.destroy(),null==(r=yc(this,lt))||r.hide(),Sc(this,lt,null),null==(o=yc(this,gt))||o.destroy(),Sc(this,gt,null),yc(this,nt)&&(clearTimeout(yc(this,nt)),Sc(this,nt,null)),yc(this,kt)&&(clearTimeout(yc(this,kt)),Sc(this,kt,null)),null==(l=this._editorUndoBar)||l.destroy()}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return yc(this,mt)}get useNewAltTextFlow(){return yc(this,et)}get useNewAltTextWhenAddingImage(){return yc(this,st)}get hcmFilter(){return md(this,"hcmFilter",yc(this,_t)?yc(this,it).addHCMFilter(yc(this,_t).foreground,yc(this,_t).background):"none")}get direction(){return md(this,"direction",getComputedStyle(yc(this,Mt)).direction)}get _highlightColors(){return md(this,"_highlightColors",yc(this,rt)?new Map(yc(this,rt).split(",").map(t=>((t=t.split("=").map(t=>t.trim()))[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return md(this,"highlightColors",null);const e=new Map,s=!!yc(this,_t);for(const[i,n]of t){const t=i.endsWith("_HCM");s&&t?e.set(i.replace("_HCM",""),n):s||t||e.set(i,n)}return md(this,"highlightColors",e)}get highlightColorNames(){return md(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),Sc(this,X,t)}setMainHighlightColorPicker(t){Sc(this,gt,t)}editAltText(t,e=!1){var s;null==(s=yc(this,z))||s.editAltText(this,t,e)}hasCommentManager(){return!!yc(this,U)}editComment(t,e){var s;null==(s=yc(this,U))||s.open(this,t,e)}getSignature(t){var e;null==(e=yc(this,At))||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return yc(this,At)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){if("enableNewAltTextWhenAddingImage"===t)Sc(this,st,e)}onPageChanging({pageNumber:t}){Sc(this,Y,t-1)}focusMainContainer(){yc(this,Mt).focus()}findParent(t,e){for(const s of yc(this,$).values()){const{x:i,y:n,width:a,height:r}=s.div.getBoundingClientRect();if(t>=i&&t<=i+a&&e>=n&&e<=n+r)return s}return null}disableUserSelect(t=!1){yc(this,Et).classList.toggle("noUserSelect",t)}addShouldRescale(t){yc(this,Z).add(t)}removeShouldRescale(t){yc(this,Z).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Od.PDF_TO_CSS_UNITS;for(const s of yc(this,Z))s.onScaleChanging();null==(e=yc(this,X))||e.onScaleChanging()}
1onRotationChanging({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,r=e.toString(),o=kc(this,Rt,Pt).call(this,e).closest(".textLayer"),l=this.getSelectionBoxes(o);if(!l)return;e.empty();const h=kc(this,Rt,It).call(this,o),c=yc(this,vt)===Hc.NONE,d=()=>{null==h||h.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:l,anchorNode:s,anchorOffset:i,focusNode:n,focusOffset:a,text:r}),c&&this.showAllEditors("highlight",!0,!0)};c?this.switchToMode(Hc.HIGHLIGHT,d):d()}addToAnnotationStorage(t){t.isEmpty()||!yc(this,j)||yc(this,j).has(t.id)||yc(this,j).setValue(t.id,t)}a11yAlert(t,e=null){const s=yc(this,Ct);s&&(s.setAttribute("data-l10n-id",t),e?s.setAttribute("data-l10n-args",JSON.stringify(e)):s.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,yc(this,ot)&&(Sc(this,ot,!1),kc(this,Rt,Nt).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of yc(this,wt))if(e.div.contains(t)){Sc(this,pt,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!yc(this,pt))return;const[t,e]=yc(this,pt);Sc(this,pt,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){kc(this,Rt,Bt).call(this),kc(this,Rt,$t).call(this)}removeEditListeners(){kc(this,Rt,Ht).call(this),kc(this,Rt,zt).call(this)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const s of yc(this,J))if(s.isHandlingMimeForPasting(e))return t.dataTransfer.dropEffect="copy",void t.preventDefault()}drop(t){for(const e of t.dataTransfer.items)for(const s of yc(this,J))if(s.isHandlingMimeForPasting(e.type))return s.paste(e,this.currentLayer),void t.preventDefault()}copy(t){var e;if(t.preventDefault(),null==(e=yc(this,B))||e.commitOrRemove(),!this.hasSelection)return;const s=[];for(const i of yc(this,wt)){const t=i.serialize(!0);t&&s.push(t)}0!==s.length&&t.clipboardData.setData("application/pdfjs",JSON.stringify(s))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const a of e.items)for(const t of yc(this,J))if(t.isHandlingMimeForPasting(a.type))return void t.paste(a,this.currentLayer);let s=e.getData("application/pdfjs");if(!s)return;try{s=JSON.parse(s)}catch(n){return void n.message}if(!Array.isArray(s))return;this.unselectAll();const i=this.currentLayer;try{const t=[];for(const a of s){const e=await i.deserialize(a);if(!e)return;t.push(e)}const e=()=>{for(const e of t)kc(this,Rt,Xt).call(this,e);kc(this,Rt,Qt).call(this,t)},n=()=>{for(const e of t)e.remove()};this.addCommands({cmd:e,undo:n,mustExec:!0})}catch(n){n.message}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),yc(this,vt)===Hc.NONE||this.isEditorHandlingKeyboard||t._keyboardManager.exec(this,e)}keyup(t){this.isShiftKeyDown&&"Shift"===t.key&&(this.isShiftKeyDown=!1,yc(this,ot)&&(Sc(this,ot,!1),kc(this,Rt,Nt).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")}}setEditingState(t){t?(kc(this,Rt,Wt).call(this),kc(this,Rt,$t).call(this),kc(this,Rt,Gt).call(this,{isEditing:yc(this,vt)!==Hc.NONE,isEmpty:kc(this,Rt,Kt).call(this),hasSomethingToUndo:yc(this,V).hasSomethingToUndo(),hasSomethingToRedo:yc(this,V).hasSomethingToRedo(),hasSelectedEditor:!1})):(kc(this,Rt,Ot).call(this),kc(this,Rt,zt).call(this),kc(this,Rt,Gt).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!yc(this,J)){Sc(this,J,t);for(const t of yc(this,J))kc(this,Rt,Vt).call(this,t.defaultPropertiesToUpdate)}}getId(){return yc(this,ht).id}get currentLayer(){return yc(this,$).get(yc(this,Y))}getLayer(t){return yc(this,$).get(t)}get currentPageIndex(){return yc(this,Y)}addLayer(t){yc(this,$).set(t.pageIndex,t),yc(this,ct)?t.enable():t.disable()}removeLayer(t){yc(this,$).delete(t.pageIndex)}async updateMode(t,e=null,s=!1,i=!1,n=!1){var a,r,o;if(yc(this,vt)!==t&&(!yc(this,Tt)||(await yc(this,Tt).promise,yc(this,Tt)))){if(Sc(this,Tt,Promise.withResolvers()),null==(a=yc(this,X))||a.commitOrRemove(),Sc(this,vt,t),t===
1Hc.NONE)return this.setEditingState(!1),kc(this,Rt,qt).call(this),null==(r=this._editorUndoBar)||r.hide(),void yc(this,Tt).resolve();t===Hc.SIGNATURE&&await(null==(o=yc(this,At))?void 0:o.loadSignatures()),this.setEditingState(!0),await kc(this,Rt,Ut).call(this),this.unselectAll();for(const e of yc(this,$).values())e.updateMode(t);if(!e)return s&&this.addNewEditorFromKeyboard(),void yc(this,Tt).resolve();for(const t of yc(this,H).values())t.annotationElementId===e||t.id===e?(this.setSelected(t),n?t.editComment():i&&t.enterInEditMode()):t.unselect();yc(this,Tt).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==yc(this,vt)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(yc(this,J)){switch(t){case $c.CREATE:return void this.currentLayer.addNewEditor(e);case $c.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(yc(this,yt)||Sc(this,yt,new Map)).set(t,e),this.showAllEditors("highlight",e)}if(this.hasSelection)for(const s of yc(this,wt))s.updateParams(t,e);else for(const s of yc(this,J))s.updateDefaultParams(t,e)}}showAllEditors(t,e,s=!1){var i;for(const n of yc(this,H).values())n.editorType===t&&n.show(e);((null==(i=yc(this,yt))?void 0:i.get($c.HIGHLIGHT_SHOW_ALL))??!0)!==e&&kc(this,Rt,Vt).call(this,[[$c.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(yc(this,dt)!==t){Sc(this,dt,t);for(const e of yc(this,$).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}getEditors(t){const e=[];for(const s of yc(this,H).values())s.pageIndex===t&&e.push(s);return e}getEditor(t){return yc(this,H).get(t)}addEditor(t){yc(this,H).set(t.id,t)}removeEditor(t){var e,s;t.div.contains(document.activeElement)&&(yc(this,nt)&&clearTimeout(yc(this,nt)),Sc(this,nt,setTimeout(()=>{this.focusMainContainer(),Sc(this,nt,null)},0))),yc(this,H).delete(t.id),t.annotationElementId&&(null==(e=yc(this,ft))||e.delete(t.annotationElementId)),this.unselect(t),t.annotationElementId&&yc(this,K).has(t.annotationElementId)||null==(s=yc(this,j))||s.remove(t.id)}addDeletedAnnotationElement(t){yc(this,K).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return yc(this,K).has(t)}removeDeletedAnnotationElement(t){yc(this,K).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){yc(this,B)!==t&&(Sc(this,B,t),t&&kc(this,Rt,Vt).call(this,t.propertiesToUpdate))}updateUI(t){yc(this,Rt,Yt)===t&&kc(this,Rt,Vt).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){kc(this,Rt,Vt).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(yc(this,wt).has(t))return yc(this,wt).delete(t),t.unselect(),void kc(this,Rt,Gt).call(this,{hasSelectedEditor:this.hasSelection});yc(this,wt).add(t),t.select(),kc(this,Rt,Vt).call(this,t.propertiesToUpdate),kc(this,Rt,Gt).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.id}),null==(e=yc(this,X))||e.commitOrRemove();for(const s of yc(this,wt))s!==t&&s.unselect();yc(this,wt).clear(),yc(this,wt).add(t),t.select(),kc(this,Rt,Vt).call(this,t.propertiesToUpdate),kc(this,Rt,Gt).call(this,{hasSelectedEditor:!0})}isSelected(t){return yc(this,wt).has(t)}get firstSelectedEditor(){return yc(this,wt).values().next().value}unselect(t){t.unselect(),yc(this,wt).delete(t),kc(this,Rt,Gt).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==yc(this,wt).size}get isEnterHandled(){return 1===yc(this,wt).size&&this.firstSelectedEditor.isEnterHandled}undo(){var t;yc(this,V).undo(),kc(this,Rt,Gt).call(this,{hasSomethingToUndo:yc(this,V).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:kc(this,Rt,Kt).call(this)}),null==(t=this._editorUndoBar)||t.hide()}redo(){yc(this,V).redo(),kc(this,Rt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:yc(this,V).hasSomethingToRedo(),isEmpty:kc(this,Rt,Kt).call(this)})}addCommands(t){yc(this,V).add(t),kc(this,Rt,Gt).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:kc(this,Rt,Kt).call(this)})}cleanUndoStack(t){yc(this,V).cleanType(t)}delete(){var t;this.commitOrRemove();const e=null==(t=this.currentLayer)?void 0:t.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const s=e?[e]:[...yc(this,wt)],i=()=>{for(const t of s)kc(this,Rt,Xt).call(this,t)};this.addCommands({cmd:()=>{var t;null==(t=this._editorUndoBar)||t.show(i,1===s.length?s[0].editorType:s.length);for(const e of s)e.remove()},undo:i,mustExec:!0})}commitOrRemove(){var t;null==(t=yc(this,B))||t.commitOrRemove()}hasSomethingToControl(){return yc(this,B)||this.hasSelection}selectAll(){for(const t of yc(this,wt))t.commit();kc(this,Rt,Qt).call(this,yc(this,H).values())}unselectAll(){var t;if((!yc(this,B)||(yc(this,B).commitOrRemove(),yc(this,vt)===Hc.NONE))&&!(null==(t=yc(this,X))?void 0:t.commitOrRemove())&&this.hasSelection){for(const t of yc(this,wt))t.unselect();yc(this,wt).clear(),kc(this,Rt,Gt).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,s=!1){if(s||this.commitOrRemove(),!this.hasSelection)return;yc(this,St)[0]+=t,yc(this,St)[1]+=e;const[i,n]=yc(this,St),a=[...yc(this,wt)];yc(this,kt)&&clearTimeout(yc(this,kt)),Sc(this,kt,setTimeout(()=>{Sc(this,kt,null),yc(this,St)[0]=yc(this,St)[1]=0,this.addCommands({cmd:()=>{for(const t of a)yc(this,H).has(t.id)&&(t.translateInPage(i,n),t.translationDone())},undo:()=>{for(const t of a)yc(this,H).has(t.id)&&(t.translateInPage(-i,-n),t.translationDone())},mustExec:!1})},1e3));for(const r of a)r.translateInPage(t,e),r.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),Sc(this,Q,new Map);for(const t of yc(this,wt))yc(this,Q).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!yc(this,Q))return!1;this.disableUserSelect(!1);const t=yc(this,Q);Sc(this,Q,null);let e=!1;for(const[{x:i,y:n,pageIndex:a},r]of t)r.newX=i,r.newY=n,r.newPageIndex=a,e||(e=i!==r.savedX||n!==r.savedY||a!==r.savedPageIndex);if(!e)return!1;const s=(t,e,s,i)=>{if(yc(this,H).has(t.id)){const n=yc(this,$).get(i);n?t._setParentAndPosition(n,e,s):(t.pageIndex=i,t.x=e,t.y=s)}};return this.addCommands({cmd:()=>{for(const[e,{newX:i,newY:n,newPageIndex:a}]of t)s(e,i,n,a)},undo:()=>{for(const[e,{savedX:i,savedY:n,savedPageIndex:a}]of t)s(e,i,n,a)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(yc(this,Q))for(const s of yc(this,Q).keys())s.drag(t,e)}rebuild(t){if(null===t.parent){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return(null==(t=this.getActive())?void 0:t.shouldGetKeyboardEvents())||1===yc(this,wt).size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return yc(this,B)===t}getActive(){return yc(this,B)}getMode(){return yc(this,vt)}get imageManager(){return md(this,"imageManager",new cu)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let l=0,h=e.rangeCount;l<h;
1l++)if(!t.contains(e.getRangeAt(l).commonAncestorContainer))return null;const{x:s,y:i,width:n,height:a}=t.getBoundingClientRect();let r;switch(t.getAttribute("data-main-rotation")){case"90":r=(t,e,r,o)=>({x:(e-i)/a,y:1-(t+r-s)/n,width:o/a,height:r/n});break;case"180":r=(t,e,r,o)=>({x:1-(t+r-s)/n,y:1-(e+o-i)/a,width:r/n,height:o/a});break;case"270":r=(t,e,r,o)=>({x:1-(e+o-i)/a,y:(t-s)/n,width:o/a,height:r/n});break;default:r=(t,e,r,o)=>({x:(t-s)/n,y:(e-i)/a,width:r/n,height:o/a})}const o=[];for(let l=0,h=e.rangeCount;l<h;l++){const t=e.getRangeAt(l);if(!t.collapsed)for(const{x:e,y:s,width:i,height:n}of t.getClientRects())0!==i&&0!==n&&o.push(r(e,s,i,n))}return 0===o.length?null:o}addChangedExistingAnnotation({annotationElementId:t,id:e}){(yc(this,G)||Sc(this,G,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;null==(e=yc(this,G))||e.delete(t)}renderAnnotationElement(t){var e;const s=null==(e=yc(this,G))?void 0:e.get(t.data.id);if(!s)return;const i=yc(this,j).getRawValue(s);i&&(yc(this,vt)!==Hc.NONE||i.hasBeenModified)&&i.renderAnnotationElement(t)}setMissingCanvas(t,e,s){var i;const n=null==(i=yc(this,ft))?void 0:i.get(t);n&&(n.setCanvas(e,s),yc(this,ft).delete(t))}addMissingCanvas(t,e){(yc(this,ft)||Sc(this,ft,new Map)).set(t,e)}};O=new WeakMap,B=new WeakMap,H=new WeakMap,$=new WeakMap,z=new WeakMap,j=new WeakMap,G=new WeakMap,V=new WeakMap,U=new WeakMap,q=new WeakMap,X=new WeakMap,Y=new WeakMap,K=new WeakMap,Q=new WeakMap,J=new WeakMap,Z=new WeakMap,tt=new WeakMap,et=new WeakMap,st=new WeakMap,it=new WeakMap,nt=new WeakMap,at=new WeakMap,rt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ht=new WeakMap,ct=new WeakMap,dt=new WeakMap,ut=new WeakMap,pt=new WeakMap,gt=new WeakMap,ft=new WeakMap,mt=new WeakMap,vt=new WeakMap,wt=new WeakMap,bt=new WeakMap,At=new WeakMap,_t=new WeakMap,yt=new WeakMap,xt=new WeakMap,St=new WeakMap,kt=new WeakMap,Mt=new WeakMap,Et=new WeakMap,Ct=new WeakMap,Tt=new WeakMap,Rt=new WeakSet,Pt=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},It=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const s of yc(this,$).values())if(s.hasTextLayer(t))return s;return null},Dt=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const e=kc(this,Rt,Pt).call(this,t).closest(".textLayer"),s=this.getSelectionBoxes(e);s&&(yc(this,lt)||Sc(this,lt,new ru(this)),yc(this,lt).show(e,s,"ltr"===this.direction))},Lt=function(){var t,e,s;const i=document.getSelection();if(!i||i.isCollapsed)return void(yc(this,bt)&&(null==(t=yc(this,lt))||t.hide(),Sc(this,bt,null),kc(this,Rt,Gt).call(this,{hasSelectedText:!1})));const{anchorNode:n}=i;if(n===yc(this,bt))return;const a=kc(this,Rt,Pt).call(this,i).closest(".textLayer");if(a){if(null==(s=yc(this,lt))||s.hide(),Sc(this,bt,n),kc(this,Rt,Gt).call(this,{hasSelectedText:!0}),(yc(this,vt)===Hc.HIGHLIGHT||yc(this,vt)===Hc.NONE)&&(yc(this,vt)===Hc.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),Sc(this,ot,this.isShiftKeyDown),!this.isShiftKeyDown)){const t=yc(this,vt)===Hc.HIGHLIGHT?kc(this,Rt,It).call(this,a):null;null==t||t.toggleDrawing();const e=new AbortController,s=this.combinedSignal(e),i=s=>{"pointerup"===s.type&&0!==s.button||(e.abort(),null==t||t.toggleDrawing(!0),"pointerup"===s.type&&kc(this,Rt,Nt).call(this,"main_toolbar"))};window.addEventListener("pointerup",i,{signal:s}),window.addEventListener("blur",i,{signal:s})}}else yc(this,bt)&&(null==(e=yc(this,lt))||e.hide(),Sc(this,bt,null),kc(this,Rt,Gt).call(this,{hasSelectedText:!1}))},Nt=function(t=""){yc(this,vt)===Hc.HIGHLIGHT?this.highlightSelection(t):yc(this,tt)&&kc(this,Rt,Dt).call(this)},Ft=function(){document.addEventListener("selectionchange",kc(this,Rt,Lt).bind(this),{signal:this._signal})},Wt=function(){if(yc(this,at))return;Sc(this,at,new AbortController);const t=this.combinedSignal(yc(this,at));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Ot=function(){var t;null==(t=yc(this,at))||t.abort(),Sc(this,at,null)},Bt=function(){if(yc(this,ut))return;Sc(this,ut,new AbortController);const t=this.combinedSignal(yc(this,ut));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Ht=function(){var t;null==(t=yc(this,ut))||t.abort(),Sc(this,ut,null)},$t=function(){if(yc(this,q))return;Sc(this,q,new AbortController);const t=this.combinedSignal(yc(this,q));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})},zt=function(){var t;null==(t=yc(this,q))||t.abort(),Sc(this,q,null)},jt=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Gt=function(t){Object.entries(t).some(([t,e])=>yc(this,xt)[t]!==e)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(yc(this,xt),t)}),yc(this,vt)===Hc.HIGHLIGHT&&!1===t.hasSelectedEditor&&kc(this,Rt,Vt).call(this,[[$c.HIGHLIGHT_FREE,!0]]))},Vt=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Ut=async function(){if(!yc(this,ct)){Sc(this,ct,!0);const t=[];for(const e of yc(this,$).values())t.push(e.enable());await Promise.all(t);for(const e of yc(this,H).values())e.enable()}},qt=function(){if(this.unselectAll(),yc(this,ct)){Sc(this,ct,!1);for(const t of yc(this,$).values())t.disable();for(const t of yc(this,H).values())t.disable()}},Xt=function(t){const e=yc(this,$).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Yt=function(){let t=null;for(t of yc(this,wt));return t},Kt=function(){if(0===yc(this,H).size)return!0;
1if(1===yc(this,H).size)for(const t of yc(this,H).values())return t.isEmpty();return!1},Qt=function(t){for(const e of yc(this,wt))e.unselect();yc(this,wt).clear();for(const e of t)e.isEmpty()||(yc(this,wt).add(e),e.select());kc(this,Rt,Gt).call(this,{hasSelectedEditor:this.hasSelection})},Ac(fu,"TRANSLATE_SMALL",1),Ac(fu,"TRANSLATE_BIG",10);let mu=fu;const vu=class t{constructor(e){xc(this,de),xc(this,Jt,null),xc(this,Zt,!1),xc(this,te,null),xc(this,ee,null),xc(this,se,null),xc(this,ie,null),xc(this,ne,!1),xc(this,ae,null),xc(this,re,null),xc(this,oe,null),xc(this,le,null),xc(this,he,!1),Sc(this,re,e),Sc(this,he,e._uiManager.useNewAltTextFlow),yc(t,ce)||Sc(t,ce,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(e){t._l10n??(t._l10n=e)}async render(){const e=Sc(this,te,document.createElement("button"));e.className="altText",e.tabIndex="0";const s=Sc(this,ee,document.createElement("span"));e.append(s),yc(this,he)?(e.classList.add("new"),e.setAttribute("data-l10n-id",yc(t,ce).missing),s.setAttribute("data-l10n-id",yc(t,ce)["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),s.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=yc(this,re)._uiManager._signal;e.addEventListener("contextmenu",Xd,{signal:i}),e.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:i});const n=t=>{t.preventDefault(),yc(this,re)._uiManager.editAltText(yc(this,re)),yc(this,he)&&yc(this,re)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:yc(this,de,ue)}})};return e.addEventListener("click",n,{capture:!0,signal:i}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(Sc(this,ne,!0),n(t))},{signal:i}),await kc(this,de,pe).call(this),e}finish(){yc(this,te)&&(yc(this,te).focus({focusVisible:yc(this,ne)}),Sc(this,ne,!1))}isEmpty(){return yc(this,he)?null===yc(this,Jt):!yc(this,Jt)&&!yc(this,Zt)}hasData(){return yc(this,he)?null!==yc(this,Jt)||!!yc(this,oe):this.isEmpty()}get guessedText(){return yc(this,oe)}async setGuessedText(e){null===yc(this,Jt)&&(Sc(this,oe,e),Sc(this,le,await t._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e})),kc(this,de,pe).call(this))}toggleAltTextBadge(t=!1){var e;if(!yc(this,he)||yc(this,Jt))return null==(e=yc(this,ae))||e.remove(),void Sc(this,ae,null);if(!yc(this,ae)){const t=Sc(this,ae,document.createElement("div"));t.className="noAltTextBadge",yc(this,re).div.append(t)}yc(this,ae).classList.toggle("hidden",!t)}serialize(t){let e=yc(this,Jt);return t||yc(this,oe)!==e||(e=yc(this,le)),{altText:e,decorative:yc(this,Zt),guessedText:yc(this,oe),textWithDisclaimer:yc(this,le)}}get data(){return{altText:yc(this,Jt),decorative:yc(this,Zt)}}set data({altText:t,decorative:e,guessedText:s,textWithDisclaimer:i,cancel:n=!1}){s&&(Sc(this,oe,s),Sc(this,le,i)),yc(this,Jt)===t&&yc(this,Zt)===e||(n||(Sc(this,Jt,t),Sc(this,Zt,e)),kc(this,de,pe).call(this))}toggle(t=!1){yc(this,te)&&(!t&&yc(this,ie)&&(clearTimeout(yc(this,ie)),Sc(this,ie,null)),yc(this,te).disabled=!t)}shown(){yc(this,re)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:yc(this,de,ue)}})}destroy(){var t,e;null==(t=yc(this,te))||t.remove(),Sc(this,te,null),Sc(this,ee,null),Sc(this,se,null),null==(e=yc(this,ae))||e.remove(),Sc(this,ae,null)}};Jt=new WeakMap,Zt=new WeakMap,te=new WeakMap,ee=new WeakMap,se=new WeakMap,ie=new WeakMap,ne=new WeakMap,ae=new WeakMap,re=new WeakMap,oe=new WeakMap,le=new WeakMap,he=new WeakMap,ce=new WeakMap,de=new WeakSet,ue=function(){return(yc(this,Jt)?"added":null===yc(this,Jt)&&this.guessedText&&"review")||"missing"},pe=async function(){var t,e,s;const i=yc(this,te);if(!i)return;if(yc(this,he)){if(i.classList.toggle("done",!!yc(this,Jt)),i.setAttribute("data-l10n-id",yc(vu,ce)[yc(this,de,ue)]),null==(t=yc(this,ee))||t.setAttribute("data-l10n-id",yc(vu,ce)[`${yc(this,de,ue)}-label`]),!yc(this,Jt))return void(null==(e=yc(this,se))||e.remove())}else{if(!yc(this,Jt)&&!yc(this,Zt))return i.classList.remove("done"),void(null==(s=yc(this,se))||s.remove());i.classList.add("done"),i.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let n=yc(this,se);if(!n){Sc(this,se,n=document.createElement("span")),n.className="tooltip",n.setAttribute("role","tooltip"),n.id=`alt-text-tooltip-${yc(this,re).id}`;const t=100,e=yc(this,re)._uiManager._signal;e.addEventListener("abort",()=>{clearTimeout(yc(this,ie)),Sc(this,ie,null)},{once:!0}),i.addEventListener("mouseenter",()=>{Sc(this,ie,setTimeout(()=>{Sc(this,ie,null),yc(this,se).classList.add("show"),yc(this,re)._reportTelemetry({action:"alt_text_tooltip"})},t))},{signal:e}),i.addEventListener("mouseleave",()=>{var t;yc(this,ie)&&(clearTimeout(yc(this,ie)),Sc(this,ie,null)),null==(t=yc(this,se))||t.classList.remove("show")},{signal:e})}yc(this,Zt)?n.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(n.removeAttribute("data-l10n-id"),n.textContent=yc(this,Jt)),n.parentNode||i.append(n);const a=yc(this,re).getElementForAltText();null==a||a.setAttribute("aria-describedby",n.id)},xc(vu,ce,null),Ac(vu,"_l10n",null);let wu=vu;class bu{constructor(t){xc(this,ge,null),xc(this,fe,!1),xc(this,me,null),xc(this,ve,null),xc(this,we,null),xc(this,be,null),xc(this,Ae,!1),Sc(this,me,t),this.toolbar=null}
1render(){if(!yc(this,me)._uiManager.hasCommentManager())return null;const t=Sc(this,ge,document.createElement("button"));t.className="comment",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-edit-comment-button");const e=yc(this,me)._uiManager._signal;t.addEventListener("contextmenu",Xd,{signal:e}),t.addEventListener("pointerdown",t=>t.stopPropagation(),{signal:e});const s=t=>{t.preventDefault(),this.edit()};return t.addEventListener("click",s,{capture:!0,signal:e}),t.addEventListener("keydown",e=>{e.target===t&&"Enter"===e.key&&(Sc(this,fe,!0),s(e))},{signal:e}),t}edit(){const{bottom:t,left:e,right:s}=yc(this,me).getClientDimensions(),i={top:t};"ltr"===yc(this,me)._uiManager.direction?i.right=s:i.left=e,yc(this,me)._uiManager.editComment(yc(this,me),i)}finish(){yc(this,ge)&&(yc(this,ge).focus({focusVisible:yc(this,fe)}),Sc(this,fe,!1))}isDeleted(){return yc(this,Ae)||""===yc(this,we)}hasBeenEdited(){return this.isDeleted()||yc(this,we)!==yc(this,ve)}serialize(){return this.data}get data(){return{text:yc(this,we),date:yc(this,be),deleted:yc(this,Ae)}}set data(t){if(null===t)return Sc(this,we,""),void Sc(this,Ae,!0);Sc(this,we,t),Sc(this,be,new Date),Sc(this,Ae,!1)}setInitialText(t){Sc(this,ve,t),this.data=t}toggle(t=!1){yc(this,ge)&&(yc(this,ge).disabled=!t)}shown(){}destroy(){var t;null==(t=yc(this,ge))||t.remove(),Sc(this,ge,null),Sc(this,we,""),Sc(this,be,null),Sc(this,me,null),Sc(this,fe,!1),Sc(this,Ae,!1)}}ge=new WeakMap,fe=new WeakMap,me=new WeakMap,ve=new WeakMap,we=new WeakMap,be=new WeakMap,Ae=new WeakMap;const Au=class{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:s=null,onPinchStart:i=null,onPinching:n=null,onPinchEnd:a=null,signal:r}){xc(this,De),xc(this,_e),xc(this,ye,!1),xc(this,xe,null),xc(this,Se),xc(this,ke),xc(this,Me),xc(this,Ee),xc(this,Ce,null),xc(this,Te),xc(this,Re,null),xc(this,Pe),xc(this,Ie,null),Sc(this,_e,t),Sc(this,xe,s),Sc(this,Se,e),Sc(this,ke,i),Sc(this,Me,n),Sc(this,Ee,a),Sc(this,Pe,new AbortController),Sc(this,Te,AbortSignal.any([r,yc(this,Pe).signal])),t.addEventListener("touchstart",kc(this,De,Le).bind(this),{passive:!1,signal:yc(this,Te)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/su.pixelRatio}destroy(){var t,e;null==(t=yc(this,Pe))||t.abort(),Sc(this,Pe,null),null==(e=yc(this,Ce))||e.abort(),Sc(this,Ce,null)}};_e=new WeakMap,ye=new WeakMap,xe=new WeakMap,Se=new WeakMap,ke=new WeakMap,Me=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,Te=new WeakMap,Re=new WeakMap,Pe=new WeakMap,Ie=new WeakMap,De=new WeakSet,Le=function(t){var e,s,i;if(null==(e=yc(this,Se))?void 0:e.call(this))return;if(1===t.touches.length){if(yc(this,Ce))return;const t=Sc(this,Ce,new AbortController),e=AbortSignal.any([yc(this,Te),t.signal]),s=yc(this,_e),i={capture:!0,signal:e,passive:!1},n=t=>{var e;"touch"===t.pointerType&&(null==(e=yc(this,Ce))||e.abort(),Sc(this,Ce,null))};return s.addEventListener("pointerdown",t=>{"touch"===t.pointerType&&(Yd(t),n(t))},i),s.addEventListener("pointerup",n,i),void s.addEventListener("pointercancel",n,i)}if(!yc(this,Ie)){Sc(this,Ie,new AbortController);const t=AbortSignal.any([yc(this,Te),yc(this,Ie).signal]),e=yc(this,_e),i={signal:t,capture:!1,passive:!1};e.addEventListener("touchmove",kc(this,De,Ne).bind(this),i);const n=kc(this,De,Fe).bind(this);e.addEventListener("touchend",n,i),e.addEventListener("touchcancel",n,i),i.capture=!0,e.addEventListener("pointerdown",Yd,i),e.addEventListener("pointermove",Yd,i),e.addEventListener("pointercancel",Yd,i),e.addEventListener("pointerup",Yd,i),null==(s=yc(this,ke))||s.call(this)}if(Yd(t),2!==t.touches.length||(null==(i=yc(this,xe))?void 0:i.call(this)))return void Sc(this,Re,null);let[n,a]=t.touches;n.identifier>a.identifier&&([n,a]=[a,n]),Sc(this,Re,{touch0X:n.screenX,touch0Y:n.screenY,touch1X:a.screenX,touch1Y:a.screenY})},Ne=function(t){var e;if(!yc(this,Re)||2!==t.touches.length)return;Yd(t);let[s,i]=t.touches;s.identifier>i.identifier&&([s,i]=[i,s]);const{screenX:n,screenY:a}=s,{screenX:r,screenY:o}=i,l=yc(this,Re),{touch0X:h,touch0Y:c,touch1X:d,touch1Y:u}=l,p=d-h,g=u-c,f=r-n,m=o-a,v=Math.hypot(f,m)||1,w=Math.hypot(p,g)||1;if(!yc(this,ye)&&Math.abs(w-v)<=Au.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(l.touch0X=n,l.touch0Y=a,l.touch1X=r,l.touch1Y=o,!yc(this,ye))return void Sc(this,ye,!0);const b=[(n+r)/2,(a+o)/2];null==(e=yc(this,Me))||e.call(this,b,w,v)},Fe=function(t){var e;t.touches.length>=2||(yc(this,Ie)&&(yc(this,Ie).abort(),Sc(this,Ie,null),null==(e=yc(this,Ee))||e.call(this)),yc(this,Re)&&(Yd(t),Sc(this,Re,null),Sc(this,ye,!1))
1)};let _u=Au;const yu=class t{constructor(e){xc(this,ls),xc(this,We,null),xc(this,Oe,null),xc(this,Be,null),xc(this,He,null),xc(this,$e,!1),xc(this,ze,null),xc(this,je,""),xc(this,Ge,!1),xc(this,Ve,null),xc(this,Ue,null),xc(this,qe,null),xc(this,Xe,null),xc(this,Ye,""),xc(this,Ke,!1),xc(this,Qe,null),xc(this,Je,!1),xc(this,Ze,!1),xc(this,ts,!1),xc(this,es,null),xc(this,ss,0),xc(this,is,0),xc(this,ns,null),xc(this,as,null),Ac(this,"isSelected",!1),Ac(this,"_isCopy",!1),Ac(this,"_editToolbar",null),Ac(this,"_initialOptions",Object.create(null)),Ac(this,"_initialData",null),Ac(this,"_isVisible",!0),Ac(this,"_uiManager",null),Ac(this,"_focusEventsAllowed",!0),xc(this,rs,!1),xc(this,os,t._zIndex++),this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null,this.annotationElementId=e.annotationElementId||null;const{rotation:s,rawDims:{pageWidth:i,pageHeight:n,pageX:a,pageY:r}}=this.parent.viewport;this.rotation=s,this.pageRotation=(360+s-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[a,r];const[o,l]=this.parentDimensions;this.x=e.x/o,this.y=e.y/l,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const e=t.prototype._resizeWithKeyboard,s=mu.TRANSLATE_SMALL,i=mu.TRANSLATE_BIG;return md(this,"_resizerKeyboardManager",new uu([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-s,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[s,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-s]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,s]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,i]}],[["Escape","mac+Escape"],t.prototype._stopResizingWithKeyboard]]))}get editorType(){return Object.getPrototypeOf(this).constructor._type}get mode(){return Object.getPrototypeOf(this).constructor._editorType}static get isDrawer(){return!1}static get _defaultLineColor(){return md(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new Su({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(e,s){if(t._l10n??(t._l10n=e),t._l10nResizer||(t._l10nResizer=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"})),-1!==t._borderLineWidth)return;const i=getComputedStyle(document.documentElement);t._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ud("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return yc(this,rs)}set _isDraggable(t){var e;Sc(this,rs,t),null==(e=this.div)||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/(2*t),this.y+=this.width*t/(2*e);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(2*t),this.y-=this.width*t/(2*e);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=yc(this,os)}setParent(t){null!==t?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):kc(this,ls,Cs).call(this),this.parent=t}focusin(t){this._focusEventsAllowed&&(yc(this,Ke)?Sc(this,Ke,!1):this.parent.setSelected(this))}focusout(t){var e;if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const s=t.relatedTarget;(null==s?void 0:s.closest(`#${this.id}`))||(t.preventDefault(),(null==(e=this.parent)?void 0:e.isMultipleSelection)||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,s,i){const[n,a]=this.parentDimensions;[s,i]=this.screenToPageTranslation(s,i),this.x=(t+s)/n,this.y=(e+i)/a,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[s,i]=this.parentDimensions;this.setAt(t*s,e*i,this.width*s,this.height*i),this._onTranslated()}translate(t,e){kc(this,ls,hs).call(this,this.parentDimensions,t,e)}translateInPage(t,e){yc(this,Qe)||Sc(this,Qe,[this.x,this.y,this.width,this.height]),
1kc(this,ls,hs).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){yc(this,Qe)||Sc(this,Qe,[this.x,this.y,this.width,this.height]);const{div:s,parentDimensions:[i,n]}=this;if(this.x+=t/i,this.y+=e/n,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:t,y:e}=this.div.getBoundingClientRect();this.parent.findNewParent(this,t,e)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:a,y:r}=this;const[o,l]=this.getBaseTranslation();a+=o,r+=l;const{style:h}=s;h.left=`${(100*a).toFixed(2)}%`,h.top=`${(100*r).toFixed(2)}%`,this._onTranslating(a,r),s.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!yc(this,Qe)&&(yc(this,Qe)[0]!==this.x||yc(this,Qe)[1]!==this.y)}get _hasBeenResized(){return!!yc(this,Qe)&&(yc(this,Qe)[2]!==this.width||yc(this,Qe)[3]!==this.height)}getBaseTranslation(){const[e,s]=this.parentDimensions,{_borderLineWidth:i}=t,n=i/e,a=i/s;switch(this.rotation){case 90:return[-n,a];case 180:return[n,a];case 270:return[n,-a];default:return[-n,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[s,i]}=this;let{x:n,y:a,width:r,height:o}=this;if(r*=s,o*=i,n*=s,a*=i,this._mustFixPosition)switch(t){case 0:n=Ld(n,0,s-r),a=Ld(a,0,i-o);break;case 90:n=Ld(n,0,s-o),a=Ld(a,r,i);break;case 180:n=Ld(n,r,s),a=Ld(a,o,i);break;case 270:n=Ld(n,o,s),a=Ld(a,0,i-r)}this.x=n/=s,this.y=a/=i;const[l,h]=this.getBaseTranslation();n+=l,a+=h,e.left=`${(100*n).toFixed(2)}%`,e.top=`${(100*a).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(e,s){var i;return kc(i=t,cs,ds).call(i,e,s,this.parentRotation)}pageTranslationToScreen(e,s){var i;return kc(i=t,cs,ds).call(i,e,s,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,s]}=this;return[e*t,s*t]}setDims(t,e){const[s,i]=this.parentDimensions,{style:n}=this.div;n.width=`${(100*t/s).toFixed(2)}%`,yc(this,Ge)||(n.height=`${(100*e/i).toFixed(2)}%`)}fixDims(){const{style:t}=this.div,{height:e,width:s}=t,i=s.endsWith("%"),n=!yc(this,Ge)&&e.endsWith("%");if(i&&n)return;const[a,r]=this.parentDimensions;i||(t.width=`${(100*parseFloat(s)/a).toFixed(2)}%`),yc(this,Ge)||n||(t.height=`${(100*parseFloat(e)/r).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(1e4*t)/1e4}_onResizing(){}altTextFinish(){var t;null==(t=yc(this,Be))||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||yc(this,Ze))return this._editToolbar;this._editToolbar=new au(this),this.div.append(this._editToolbar.render()),this._editToolbar.addButton("comment",this.addCommentButton());const{toolbarButtons:t}=this;if(t)for(const[e,s]of t)await this._editToolbar.addButton(e,s);return this._editToolbar.addButton("delete"),this._editToolbar}removeEditToolbar(){var t;this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,null==(t=yc(this,Be))||t.destroy())}addContainer(t){var e;const s=null==(e=this._editToolbar)?void 0:e.div;s?s.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return yc(this,Be)||(wu.initialize(t._l10n),Sc(this,Be,new wu(this)),yc(this,We)&&(yc(this,Be).data=yc(this,We),Sc(this,We,null))),yc(this,Be)}get altTextData(){var t;return null==(t=yc(this,Be))?void 0:t.data}set altTextData(t){yc(this,Be)&&(yc(this,Be).data=t)}get guessedAltText(){var t;return null==(t=yc(this,Be))?void 0:t.guessedText}async setGuessedAltText(t){var e;await(null==(e=yc(this,Be))?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return null==(e=yc(this,Be))?void 0:e.serialize(t)}hasAltText(){return!!yc(this,Be)&&!yc(this,Be).isEmpty()}hasAltTextData(){var t;return(null==(t=yc(this,Be))?void 0:t.hasData())??!1}addCommentButton(){return yc(this,He)?yc(this,He):Sc(this,He,new bu(this))}get commentColor(){return null}get comment(){const t=yc(this,He);return{text:t.data.text,date:t.data.date,deleted:t.isDeleted(),color:this.commentColor}}set comment(t){yc(this,He)||Sc(this,He,new bu(this)),yc(this,He).data=t}setCommentData(t){yc(this,He)||Sc(this,He,new bu(this)),yc(this,He).setInitialText(t)}get hasEditedComment(){var t;return null==(t=yc(this,He))?void 0:t.hasBeenEdited()}async editComment(){yc(this,He)||Sc(this,He,new bu(this)),yc(this,He).edit()}addComment(t){this.hasEditedComment&&(t.popup={contents:this.comment.text,deleted:this.comment.deleted})}render(){var t;const e=this.div=document.createElement("div");e.setAttribute("data-editor-rotation",(360-this.rotation)%360),e.className=this.name,e.setAttribute("id",this.id),e.tabIndex=yc(this,$e)?-1:0,e.setAttribute("role","application"),this.defaultL10nId&&e.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||e.classList.add("hidden"),this.setInForeground(),kc(this,ls,xs).call(this);const[s,i]=this.parentDimensions;this.parentRotation%180!=0&&(e.style.maxWidth=`${(100*i/s).toFixed(2)}%`,e.style.maxHeight=`${(100*s/i).toFixed(2)}%`);const[n,a]=this.getInitialTranslation();return this.translate(n,a),ou(this,e,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(yc(this,as)||Sc(this,as,new _u({container:e,isPinchingDisabled:()=>!this.isSelected,onPinchStart:kc(this,ls,ws).bind(this),onPinching:kc(this,ls,bs).bind(this),onPinchEnd:kc(this,ls,As).bind(this),signal:this._uiManager._signal}))),null==(t=this._uiManager._editorUndoBar)||t.hide(),e}pointerdown(t){const{isMac:e}=Md.platform;0!==t.button||t.ctrlKey&&e?t.preventDefault():(Sc(this,Ke,!0),this._isDraggable?kc(this,ls,ys).call(this,t):kc(this,ls,_s).call(this,t))}_onStartDragging(){}_onStopDragging(){}moveInDOM(){yc(this,es)&&clearTimeout(yc(this,es)),Sc(this,es,setTimeout(()=>{var t;Sc(this,es,null),null==(t=this.parent)||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,s){t.changeParent(this),this.x=e,this.y=s,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,s=this.rotation){const i=this.parentScale,[n,a]=this.pageDimensions,[r,o]=this.pageTranslation,l=t/i,h=e/i,c=this.x*n,d=this.y*a,u=this.width*n,p=this.height*a;switch(s){case 0:return[c+l+r,a-d-h-p+o,c+l+u+r,a-d-h+o];case 90:return[c+h+r,a-d+l+o,c+h+p+r,a-d+l+u+o];case 180:return[c-l-u+r,a-d+h+o,c-l+r,a-d+h+p+o];case 270:return[c-h-p+r,a-d-l-u+o,c-h+r,a-d-l+o];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[s,i,n,a]=t,r=n-s,o=a-i;switch(this.rotation){case 0:return[s,e-a,r,o];case 90:return[s,e-i,o,r];case 180:return[n,e-i,r,o];case 270:return[n,e-a,o,r];default:throw new Error("Invalid rotation")}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return!this.isInEditMode()&&(this.parent.setEditingState(!1),Sc(this,Ze,!0),!0)}disableEditMode(){return!!this.isInEditMode()&&(this.parent.setEditingState(!0),Sc(this,Ze,!1),!0)}isInEditMode(){return yc(this,Ze)}shouldGetKeyboardEvents(){return yc(this,ts)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:s,right:i}=this.getClientDimensions(),{innerHeight:n,innerWidth:a}=window;return e<a&&i>0&&t<n&&s>0}rebuild(){kc(this,ls,xs).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:(null==(t=this._initialData)?void 0:t.popupRef)||""}}serialize(t=!1,e=null){ud("An editor must be serializable")}static async deserialize(t,e,s){const i=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:s,annotationElementId:t.annotationElementId});i.rotation=t.rotation,Sc(i,We,t.accessibilityData),i._isCopy=t.isCopy||!1;const[n,a]=i.pageDimensions,[r,o,l,h]=i.getRectInCurrentCoords(t.rect,a);return i.x=r/n,i.y=o/a,i.width=l/n,i.height=h/a,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){var t,e;if(null==(t=yc(this,Xe))||t.abort(),Sc(this,Xe,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),yc(this,es)&&(clearTimeout(yc(this,es)),Sc(this,es,null)),kc(this,ls,Cs).call(this),this.removeEditToolbar(),yc(this,ns)){for(const t of yc(this,ns).values())clearTimeout(t);Sc(this,ns,null)}this.parent=null,null==(e=yc(this,as))||e.destroy(),Sc(this,as,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(kc(this,ls,ps).call(this),yc(this,Ve).classList.remove("hidden"))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),Sc(this,qe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const s=yc(this,Ve).children;if(!yc(this,Oe)){Sc(this,Oe,Array.from(s));const e=kc(this,ls,Ss).bind(this),i=kc(this,ls,ks).bind(this),n=this._uiManager._signal;for(const s of yc(this,Oe)){const a=s.getAttribute("data-resizer-name");s.setAttribute("role","spinbutton"),s.addEventListener("keydown",e,{signal:n}),s.addEventListener("blur",i,{signal:n}),s.addEventListener("focus",kc(this,ls,Ms).bind(this,a),{signal:n}),s.setAttribute("data-l10n-id",t._l10nResizer[a])}}const i=yc(this,Oe)[0];let n=0;for(const t of s){if(t===i)break;n++}const a=(360-this.rotation+this.parentRotation)%360/90*(yc(this,Oe).length/4);if(a!==n){if(a<n)for(let t=0;t<n-a;t++)yc(this,Ve).append(yc(this,Ve).firstChild);else if(a>n)for(let t=0;t<a-n;t++)yc(this,Ve).firstChild.before(yc(this,Ve).lastChild);let e=0;for(const i of s){const s=yc(this,Oe)[e++].getAttribute("data-resizer-name");i.setAttribute("data-l10n-id",t._l10nResizer[s])}}kc(this,ls,Es).call(this,0),Sc(this,ts,!0),yc(this,Ve).firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}_resizeWithKeyboard(t,e){yc(this,ts)&&kc(this,ls,vs).call(this,yc(this,Ye),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){kc(this,ls,Cs).call(this),this.div.focus()}select(){var t,e,s;this.isSelected&&this._editToolbar||(this.isSelected=!0,this.makeResizable(),null==(t=this.div)||t.classList.add("selectedEditor"),this._editToolbar?(null==(e=this._editToolbar)||e.show(),null==(s=yc(this,Be))||s.toggleAltTextBadge(!1)):this.addEditToolbar().then(()=>{var t,e;(null==(t=this.div)?void 0:t.classList.contains("selectedEditor"))&&(null==(e=this._editToolbar)||e.show())}))}unselect(){var t,e,s,i,n;this.isSelected&&(this.isSelected=!1,null==(t=yc(this,Ve))||t.classList.add("hidden"),null==(e=this.div)||e.classList.remove("selectedEditor"),(null==(s=this.div)?void 0:s.contains(document.activeElement))&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),null==(i=this._editToolbar)||i.hide(),null==(n=yc(this,Be))||n.toggleAltTextBadge(!0))}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.id})}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return yc(this,Je)}set isEditing(t){Sc(this,Je,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(t,e){Sc(this,Ge,!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(e,s=!1){if(s){yc(this,ns)||Sc(this,ns,new Map);const{action:s}=e;let i=yc(this,ns).get(s);return i&&clearTimeout(i),i=setTimeout(()=>{this._reportTelemetry(e),yc(this,ns).delete(s),0===yc(this,ns).size&&Sc(this,ns,null)},t._telemetryTimeout),void yc(this,ns).set(s,i)}e.type||(e.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),Sc(this,$e,!1)}disable(){this.div&&(this.div.tabIndex=-1),Sc(this,$e,!0)}renderAnnotationElement(t){let e=t.container.querySelector(".annotationContent");
1if(e){if("CANVAS"===e.nodeName){const t=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.before(e)}}else e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);return e}resetAnnotationElement(t){const{firstChild:e}=t.container;"DIV"===(null==e?void 0:e.nodeName)&&e.classList.contains("annotationContent")&&e.remove()}};We=new WeakMap,Oe=new WeakMap,Be=new WeakMap,He=new WeakMap,$e=new WeakMap,ze=new WeakMap,je=new WeakMap,Ge=new WeakMap,Ve=new WeakMap,Ue=new WeakMap,qe=new WeakMap,Xe=new WeakMap,Ye=new WeakMap,Ke=new WeakMap,Qe=new WeakMap,Je=new WeakMap,Ze=new WeakMap,ts=new WeakMap,es=new WeakMap,ss=new WeakMap,is=new WeakMap,ns=new WeakMap,as=new WeakMap,rs=new WeakMap,os=new WeakMap,ls=new WeakSet,hs=function([t,e],s,i){[s,i]=this.screenToPageTranslation(s,i),this.x+=s/t,this.y+=i/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},cs=new WeakSet,ds=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]}},us=function(t){switch(t){case 90:{const[t,e]=this.pageDimensions;return[0,-t/e,e/t,0]}case 180:return[-1,0,0,-1];case 270:{const[t,e]=this.pageDimensions;return[0,t/e,-e/t,0]}default:return[1,0,0,1]}},ps=function(){if(yc(this,Ve))return;Sc(this,Ve,document.createElement("div")),yc(this,Ve).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 t=document.createElement("div");yc(this,Ve).append(t),t.classList.add("resizer",s),t.setAttribute("data-resizer-name",s),t.addEventListener("pointerdown",kc(this,ls,gs).bind(this,s),{signal:e}),t.addEventListener("contextmenu",Xd,{signal:e}),t.tabIndex=-1}this.div.prepend(yc(this,Ve))},gs=function(t,e){var s;e.preventDefault();const{isMac:i}=Md.platform;if(0!==e.button||e.ctrlKey&&i)return;null==(s=yc(this,Be))||s.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,Sc(this,Ue,[e.screenX,e.screenY]);const a=new AbortController,r=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",kc(this,ls,vs).bind(this,t),{passive:!0,capture:!0,signal:r}),window.addEventListener("touchmove",Yd,{passive:!1,signal:r}),window.addEventListener("contextmenu",Xd,{signal:r}),Sc(this,qe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const o=this.parent.div.style.cursor,l=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var t;a.abort(),this.parent.togglePointerEvents(!0),null==(t=yc(this,Be))||t.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=o,this.div.style.cursor=l,kc(this,ls,ms).call(this)};window.addEventListener("pointerup",h,{signal:r}),window.addEventListener("blur",h,{signal:r})},fs=function(t,e,s,i){this.width=s,this.height=i,this.x=t,this.y=e;const[n,a]=this.parentDimensions;this.setDims(n*s,a*i),this.fixAndSetPosition(),this._onResized()},ms=function(){if(!yc(this,qe))return;const{savedX:t,savedY:e,savedWidth:s,savedHeight:i}=yc(this,qe);Sc(this,qe,null);const n=this.x,a=this.y,r=this.width,o=this.height;n===t&&a===e&&r===s&&o===i||this.addCommands({cmd:kc(this,ls,fs).bind(this,n,a,r,o),undo:kc(this,ls,fs).bind(this,t,e,s,i),mustExec:!0})},vs=function(t,e){const[s,i]=this.parentDimensions,n=this.x,a=this.y,r=this.width,o=this.height,l=yu.MIN_SIZE/s,h=yu.MIN_SIZE/i,c=kc(this,ls,us).call(this,this.rotation),d=(t,e)=>[c[0]*t+c[2]*e,c[1]*t+c[3]*e],u=kc(this,ls,us).call(this,360-this.rotation);let p,g,f=!1,m=!1;switch(t){case"topLeft":f=!0,p=(t,e)=>[0,0],g=(t,e)=>[t,e];break;case"topMiddle":p=(t,e)=>[t/2,0],g=(t,e)=>[t/2,e];break;case"topRight":f=!0,p=(t,e)=>[t,0],g=(t,e)=>[0,e];break;case"middleRight":m=!0,p=(t,e)=>[t,e/2],g=(t,e)=>[0,e/2];break;case"bottomRight":f=!0,p=(t,e)=>[t,e],g=(t,e)=>[0,0];break;case"bottomMiddle":p=(t,e)=>[t/2,e],g=(t,e)=>[t/2,0];break;case"bottomLeft":f=!0,p=(t,e)=>
1[0,e],g=(t,e)=>[t,0];break;case"middleLeft":m=!0,p=(t,e)=>[0,e/2],g=(t,e)=>[t,e/2]}const v=p(r,o),w=g(r,o);let b=d(...w);const A=yu._round(n+b[0]),_=yu._round(a+b[1]);let y,x,S=1,k=1;if(e.fromKeyboard)({deltaX:y,deltaY:x}=e);else{const{screenX:t,screenY:s}=e,[i,n]=yc(this,Ue);[y,x]=this.screenToPageTranslation(t-i,s-n),yc(this,Ue)[0]=t,yc(this,Ue)[1]=s}var M,E;if([y,x]=(M=y/s,E=x/i,[u[0]*M+u[2]*E,u[1]*M+u[3]*E]),f){const t=Math.hypot(r,o);S=k=Math.max(Math.min(Math.hypot(w[0]-v[0]-y,w[1]-v[1]-x)/t,1/r,1/o),l/r,h/o)}else m?S=Ld(Math.abs(w[0]-v[0]-y),l,1)/r:k=Ld(Math.abs(w[1]-v[1]-x),h,1)/o;const C=yu._round(r*S),T=yu._round(o*k);b=d(...g(C,T));const R=A-b[0],P=_-b[1];yc(this,Qe)||Sc(this,Qe,[this.x,this.y,this.width,this.height]),this.width=C,this.height=T,this.x=R,this.y=P,this.setDims(s*C,i*T),this.fixAndSetPosition(),this._onResizing()},ws=function(){var t;Sc(this,qe,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),null==(t=yc(this,Be))||t.toggle(!1),this.parent.togglePointerEvents(!1)},bs=function(t,e,s){let i=s/e*.7+1-.7;if(1===i)return;const n=kc(this,ls,us).call(this,this.rotation),a=(t,e)=>[n[0]*t+n[2]*e,n[1]*t+n[3]*e],[r,o]=this.parentDimensions,l=this.x,h=this.y,c=this.width,d=this.height,u=yu.MIN_SIZE/r,p=yu.MIN_SIZE/o;i=Math.max(Math.min(i,1/c,1/d),u/c,p/d);const g=yu._round(c*i),f=yu._round(d*i);if(g===c&&f===d)return;yc(this,Qe)||Sc(this,Qe,[l,h,c,d]);const m=a(c/2,d/2),v=yu._round(l+m[0]),w=yu._round(h+m[1]),b=a(g/2,f/2);this.x=v-b[0],this.y=w-b[1],this.width=g,this.height=f,this.setDims(r*g,o*f),this.fixAndSetPosition(),this._onResizing()},As=function(){var t;null==(t=yc(this,Be))||t.toggle(!0),this.parent.togglePointerEvents(!0),kc(this,ls,ms).call(this)},_s=function(t){const{isMac:e}=Md.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},ys=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let s=!1;const i=new AbortController,n=this._uiManager.combinedSignal(i),a={capture:!0,passive:!1,signal:n},r=t=>{i.abort(),Sc(this,ze,null),Sc(this,Ke,!1),this._uiManager.endDragSession()||kc(this,ls,_s).call(this,t),s&&this._onStopDragging()};e&&(Sc(this,ss,t.clientX),Sc(this,is,t.clientY),Sc(this,ze,t.pointerId),Sc(this,je,t.pointerType),window.addEventListener("pointermove",t=>{s||(s=!0,this._onStartDragging());const{clientX:e,clientY:i,pointerId:n}=t;if(n!==yc(this,ze))return void Yd(t);const[a,r]=this.screenToPageTranslation(e-yc(this,ss),i-yc(this,is));Sc(this,ss,e),Sc(this,is,i),this._uiManager.dragSelectedEditors(a,r)},a),window.addEventListener("touchmove",Yd,a),window.addEventListener("pointerdown",t=>{t.pointerType===yc(this,je)&&(yc(this,as)||t.isPrimary)&&r(t),Yd(t)},a));const o=t=>{yc(this,ze)&&yc(this,ze)!==t.pointerId?Yd(t):r(t)};window.addEventListener("pointerup",o,{signal:n}),window.addEventListener("blur",o,{signal:n})},xs=function(){if(yc(this,Xe)||!this.div)return;Sc(this,Xe,new AbortController);const t=this._uiManager.combinedSignal(yc(this,Xe));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Ss=function(t){yu._resizerKeyboardManager.exec(this,t)},ks=function(t){var e;yc(this,ts)&&(null==(e=t.relatedTarget)?void 0:e.parentNode)!==yc(this,Ve)&&kc(this,ls,Cs).call(this)},Ms=function(t){Sc(this,Ye,yc(this,ts)?t:"")},Es=function(t){if(yc(this,Oe))for(const e of yc(this,Oe))e.tabIndex=t},Cs=function(){Sc(this,ts,!1),kc(this,ls,Es).call(this,-1),kc(this,ls,ms).call(this)},xc(yu,cs),Ac(yu,"_l10n",null),Ac(yu,"_l10nResizer",null),Ac(yu,"_borderLineWidth",-1),Ac(yu,"_colorManager",new gu),Ac(yu,"_zIndex",1),Ac(yu,"_telemetryTimeout",1e3);let xu=yu;class Su extends xu{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const ku=3285377520,Mu=4294901760,Eu=65535;class Cu{constructor(t){this.h1=t?4294967295&t:ku,this.h2=t?4294967295&t:ku}update(t){let e,s;if("string"==typeof t){e=new Uint8Array(2*t.length),s=0;for(let i=0,n=t.length;i<n;i++){const n=t.charCodeAt(i);n<=255?e[s++]=n:(e[s++]=n>>>8,e[s++]=255&n)}}else{if(!ArrayBuffer.isView(t))throw new Error("Invalid data format, must be a string or TypedArray.");e=t.slice(),s=e.byteLength}const i=s>>2,n=s-4*i,a=new Uint32Array(e.buffer,0,i);let r=0,o=0,l=this.h1,h=this.h2;const c=3432918353,d=461845907,u=11601,p=13715;for(let g=0;g<i;g++)1&g?(r=a[g],r=r*c&Mu|r*u&Eu,r=r<<15|r>>>17,r=r*d&Mu|r*p&Eu,l^=r,l=l<<13|l>>>19,l=5*l+3864292196):(o=a[g],o=o*c&Mu|o*u&Eu,o=o<<15|o>>>17,o=o*d&Mu|o*p&Eu,h^=o,h=h<<13|h>>>19,h=5*h+3864292196);switch(r=0,n){case 3:r^=e[4*i+2]<<16;case 2:r^=e[4*i+1]<<8;case 1:r^=e[4*i],r=r*c&Mu|r*u&Eu,r=r<<15|r>>>17,r=r*d&Mu|r*p&Eu,1&i?l^=r:h^=r}this.h1=l,this.h2=h}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=3981806797*t&Mu|36045*t&Eu,e=4283543511*e&Mu|(2950163797*(e<<16|t>>>16)&Mu)>>>16,t^=e>>>1,t=444984403*t&Mu|60499*t&Eu,e=3301882366*e&Mu|(3120437893*(e<<16|t>>>16)&Mu)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Tu=Object.freeze({map:null,hash:"",transfer:void 0});class Ru{constructor(){xc(this,Is),xc(this,Ts,!1),xc(this,Rs,null),xc(this,Ps,new Map),this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const s=yc(this,Ps).get(t);return void 0===s?e:Object.assign(e,s)}getRawValue(t){return yc(this,Ps).get(t)}remove(t){if(yc(this,Ps).delete(t),0===yc(this,Ps).size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const t of yc(this,Ps).values())if(t instanceof xu)return;this.onAnnotationEditor(null)}}setValue(t,e){const s=yc(this,Ps).get(t);let i=!1;if(void 0!==s)for(const[n,a]of Object.entries(e))s[n]!==a&&(i=!0,s[n]=a);else i=!0,yc(this,Ps).set(t,e);i&&kc(this,Is,Ds).call(this),e instanceof xu&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(e.constructor._type)}has(t){return yc(this,Ps).has(t)}get size(){return yc(this,Ps).size}resetModified(){yc(this,Ts)&&(Sc(this,Ts,!1),"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Pu(this)}get serializable(){if(0===yc(this,Ps).size)return Tu;const t=new Map,e=new Cu,s=[],i=Object.create(null);let n=!1;for(const[a,r]of yc(this,Ps)){const s=r instanceof xu?r.serialize(!1,i):r;s&&(t.set(a,s),e.update(`${a}:${JSON.stringify(s)}`),n||(n=!!s.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}:Tu}get editorStats(){let t=null;const e=new Map;for(const s of yc(this,Ps).values()){if(!(s instanceof xu))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[t,e]of Object.entries(i)){if("type"===t)continue;let s=a.get(t);s||(s=new Map,a.set(t,s));const i=s.get(e)??0;s.set(e,i+1)}}for(const[s,i]of e)t[s]=i.computeTelemetryFinalData(t[s]);return t}resetModifiedIds(){Sc(this,Rs,null)}get modifiedIds(){if(yc(this,Rs))return yc(this,Rs);const t=[];for(const e of yc(this,Ps).values())e instanceof xu&&e.annotationElementId&&e.serialize()&&t.pu
1sh(e.annotationElementId);return Sc(this,Rs,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return yc(this,Ps).entries()}}Ts=new WeakMap,Rs=new WeakMap,Ps=new WeakMap,Is=new WeakSet,Ds=function(){yc(this,Ts)||(Sc(this,Ts,!0),"function"==typeof this.onSetModified&&this.onSetModified())};class Pu extends Ru{constructor(t){super(),xc(this,Ls);const{map:e,hash:s,transfer:i}=t.serializable,n=structuredClone(e,i?{transfer:i}:null);Sc(this,Ls,{map:n,hash:s,transfer:i})}get print(){ud("Should not call PrintAnnotationStorage.print")}get serializable(){return yc(this,Ls)}get modifiedIds(){return md(this,"modifiedIds",{ids:new Set,hash:""})}}Ls=new WeakMap;class Iu{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){xc(this,Ns,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(),yc(this,Ns).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:s}){if(t&&!yc(this,Ns).has(t.loadedName)){if(pd(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:e,src:i,style:n}=t,a=new FontFace(e,i,n);this.addNativeFontFace(a);try{await a.load(),yc(this,Ns).add(e),null==s||s(t)}catch{t.baseFontName,this.removeNativeFontFace(a)}return}ud("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo)return void(await this.loadSystemFont(t));if(this.isFontLoadingAPISupported){const e=t.createNativeFontFace();if(e){this.addNativeFontFace(e);try{await e.loaded}catch(s){throw e.family,t.disableFontFace=!0,s}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(e=>{const s=this._queueLoadingCallback(e);this._prepareFontLoadEvent(t,s)})}}get isFontLoadingAPISupported(){var t;return md(this,"isFontLoadingAPISupported",!!(null==(t=this._document)?void 0:t.fonts))}get isSyncFontLoadingSupported(){return md(this,"isSyncFontLoadingSupported",Ec||Md.platform.isFirefox)}_queueLoadingCallback(t){const{loadingRequests:e}=this,s={done:!1,complete:function(){for(pd(!s.done,"completeRequest() cannot be called twice."),s.done=!0;e.length>0&&e[0].done;){const t=e.shift();setTimeout(t.callback,0)}},callback:t};return e.push(s),s}get _loadTestFont(){return md(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(t,e){function s(t,e){return t.charCodeAt(e)<<24|t.charCodeAt(e+1)<<16|t.charCodeAt(e+2)<<8|255&t.charCodeAt(e+3)}function i(t,e,s,i){return t.substring(0,e)+i+t.substring(e+s)}let n,a;const r=this._document.createElement("canvas");r.width=1,r.height=1;const o=r.getContext("2d");let l=0;const h=`lt${Date.now()}${this.loadTestFontId++}`;let c=this._loadTestFont;c=i(c,976,h.length,h);const d=1482184792;let u=s(c,16);for(n=0,a=h.length-3;n<a;n+=4)u=u-d+s(h,n)|0;var p;n<h.length&&(u=u-d+s(h+"XXX",n)|0),c=i(c,16,4,(p=u,String.fromCharCode(p>>24&255,p>>16&255,p>>8&255,255&p)));const g=`@font-face {font-family:"${h}";src:${`url(data:font/opentype;base64,${btoa(c)});`}}`;this.insertRule(g);const f=this._document.createElement("div");f.style.visibility="hidden",f.style.width=f.style.height="10px",f.style.position="absolute",f.style.top=f.style.left="0px";for(const m of[t.loadedName,h]){const t=this._document.createElement("span");t.textContent="Hi",t.style.fontFamily=m,f.append(t)}this._document.body.append(f),function t(e,s){if(++l>30)return void s();o.font="30px "+e,o.fillText(".",0,20),o.getImageData(0,0,1,1).data[3]>0?s():setTimeout(t.bind(null,e,s))}(h,()=>{f.remove(),e.complete()})}}Ns=new WeakMap;class Du{constructor(t,e=null){this.compiledGlyphs=Object.create(null);for(const s in t)this[s]=t[s];this._inspectFont=e}createNativeFontFace(){var t;if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return null==(t=this._inspectFont)||t.call(this,this),e}createFontFaceRule(){var t;if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${Nd(this.data)});`;let s;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),s=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else s=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return null==(t=this._inspectFont)||t.call(this,this,e),s}getPathGenerator(t,e){if(void 0!==this.compiledGlyphs[e])return this.compiledGlyphs[e];const s=this.loadedName+"_path_"+e;let i;try{i=t.get(s)}catch(a){}const n=new Path2D(i||"");return this.fontExtraProperties||t.delete(s),this.compiledGlyphs[e]=n}}function Lu(t){if("string"!=typeof t)return null;if(t.endsWith("/"))return t;throw new Error(`Invalid factory url: "${t}" must include trailing slash.`)}const Nu=t=>"object"==typeof t&&Number.isInteger(null==t?void 0:t.num)&&t.num>=0&&Number.isInteger(null==t?void 0:t.gen)&&t.gen>=0,Fu=function(t,e,s){if(!Array.isArray(s)||s.length<2)return!1;const[i,n,...a]=s;
1if(!t(i)&&!Number.isInteger(i))return!1;if(!e(n))return!1;const r=a.length;let o=!0;switch(n.name){case"XYZ":if(r<2||r>3)return!1;break;case"Fit":case"FitB":return 0===r;case"FitH":case"FitBH":case"FitV":case"FitBV":if(r>1)return!1;break;case"FitR":if(4!==r)return!1;o=!1;break;default:return!1}for(const l of a)if(!("number"==typeof l||o&&null===l))return!1;return!0}.bind(null,Nu,t=>"object"==typeof t&&"string"==typeof(null==t?void 0:t.name));class Wu{constructor(){xc(this,Fs,new Map),xc(this,Ws,Promise.resolve())}postMessage(t,e){const s={data:structuredClone(t,e?{transfer:e}:null)};yc(this,Ws).then(()=>{for(const[t]of yc(this,Fs))t.call(this,s)})}addEventListener(t,e,s=null){let i=null;if((null==s?void 0:s.signal)instanceof AbortSignal){const{signal:n}=s;if(n.aborted)return;const a=()=>this.removeEventListener(t,e);i=()=>n.removeEventListener("abort",a),n.addEventListener("abort",a)}yc(this,Fs).set(e,i)}removeEventListener(t,e){const s=yc(this,Fs).get(e);null==s||s(),yc(this,Fs).delete(e)}terminate(){for(const[,t]of yc(this,Fs))null==t||t();yc(this,Fs).clear()}}Fs=new WeakMap,Ws=new WeakMap;const Ou=1,Bu=2,Hu=1,$u=2,zu=3,ju=4,Gu=5,Vu=6,Uu=7,qu=8;function Xu(){}function Yu(t){if(t instanceof xd||t instanceof Ad||t instanceof wd||t instanceof _d||t instanceof bd)return t;switch(t instanceof Error||"object"==typeof t&&null!==t||ud('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),t.name){case"AbortException":return new xd(t.message);case"InvalidPDFException":return new Ad(t.message);case"PasswordException":return new wd(t.message,t.code);case"ResponseException":return new _d(t.message,t.status,t.missing);case"UnknownErrorException":return new bd(t.message,t.details)}return new bd(t.message,t.toString())}class Ku{constructor(t,e,s){xc(this,Bs),xc(this,Os,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",kc(this,Bs,Hs).bind(this),{signal:yc(this,Os).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,r=this.targetName,o=this.comObj;return new ReadableStream({start:s=>{const l=Promise.withResolvers();return this.streamControllers[n]={controller:s,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},o.postMessage({sourceName:a,targetName:r,action:t,streamId:n,data:e,desiredSize:s.desiredSize},i),l.promise},pull:t=>{const e=Promise.withResolvers();return this.streamControllers[n].pullCall=e,o.postMessage({sourceName:a,targetName:r,stream:Vu,streamId:n,desiredSize:t.desiredSize}),e.promise},cancel:t=>{pd(t instanceof Error,"cancel must have a valid reason");const e=Promise.withResolvers();return this.streamControllers[n].cancelCall=e,this.streamControllers[n].isClosed=!0,o.postMessage({sourceName:a,targetName:r,stream:Hu,streamId:n,reason:Yu(t)}),e.promise}},s)}destroy(){var t;null==(t=yc(this,Os))||t.abort(),Sc(this,Os,null)}}Os=new WeakMap,Bs=new WeakSet,Hs=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream)return void kc(this,Bs,zs).call(this,t);if(t.callback){const e=t.callbackId,s=this.callbackCapabilities[e];if(!s)throw new Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===Ou)s.resolve(t.data);else{if(t.callback!==Bu)throw new Error("Unexpected callback case");s.reject(Yu(t.reason))}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;return void Promise.try(e,t.data).then(function(e){n.postMessage({sourceName:s,targetName:i,callback:Ou,callbackId:t.callbackId,data:e})},function(e){n.postMessage({sourceName:s,targetName:i,callback:Bu,callbackId:t.callbackId,reason:Yu(e)})})}t.streamId?kc(this,Bs,$s).call(this,t):e(t.data)},$s=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this,r=this.actionHandler[t.action],o={enqueue(t,a=1,r){if(this.isCancelled)return;const o=this.desiredSize;this.desiredSize-=a,o>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),n.postMessage({sourceName:s,targetName:i,stream:ju,streamId:e,chunk:t},r)},close(){this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:zu,streamId:e}),delete a.streamSinks[e])},error(t){pd(t instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,n.postMessage({sourceName:s,targetName:i,stream:Gu,streamId:e,reason:Yu(t)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};o.sinkCapability.resolve(),o.ready=o.sinkCapability.promise,this.streamSinks[e]=o,Promise.try(r,t.data,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:qu,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:qu,streamId:e,reason:Yu(t)})})},zs=function(t){const e=t.streamId,s=this.sourceName,i=t.sourceName,n=this.comObj,a=this.streamControllers[e],r=this.streamSinks[e];switch(t.stream){case qu:t.success?a.startCall.resolve():a.startCall.reject(Yu(t.reason));break;case Uu:t.success?a.pullCall.resolve():a.pullCall.reject(Yu(t.reason));break;case Vu:if(!r){n.postMessage({sourceName:s,targetName:i,stream:Uu,streamId:e,success:!0});break}r.desiredSize<=0&&t.desiredSize>0&&r.sinkCapability.resolve(),r.desiredSize=t.desiredSize,Promise.try(r.onPull||Xu).then(function(){n.postMessage({sourceName:s,targetName:i,stream:Uu,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:Uu,streamId:e,reason:Yu(t)})});break;case ju:if(pd(a,"enqueue should have stream controller"),a.isClosed)break;a.controller.enqueue(t.chunk);break;case zu:if(pd(a,"close should have stream controller"),a.isClosed)break;a.isClosed=!0,a.controller.close(),kc(this,Bs,js).call(this,a,e);break;case Gu:pd(a,"error should have stream controller"),a.controller.error(Yu(t.reason)),kc(this,Bs,js).call(this,a,e);break;case $u:t.success?a.cancelCall.resolve():a.cancelCall.reject(Yu(t.reason)),kc(this,Bs,js).call(this,a,e);break;case Hu:if(!r)break;const o=Yu(t.reason);Promise.try(r.onCancel||Xu,o).then(function(){n.postMessage({sourceName:s,targetName:i,stream:$u,streamId:e,success:!0})},function(t){n.postMessage({sourceName:s,targetName:i,stream:$u,streamId:e,reason:Yu(t)})}),r.sinkCapability.reject(o),r.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},js=async function(t,e){var s,i,n;await Promise.allSettled([null==(s=t.startCall)?void 0:s.promise,null==(i=t.pullCall)?void 0:i.promise,null==(n=t.cancelCall)?void 0:n.promise]),delete this.streamControllers[e]};class Qu{constructor({enableHWA:t=!1}){xc(this,Gs,!1),Sc(this,Gs,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const s=this._createCanvas(t,e);return{canvas:s,context:s.getContext("2d",{willReadFrequently:!yc(this,Gs)})}}reset(t,e,s){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||s<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=s}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ud("Abstract method `_createCanvas` called.")}}Gs=new WeakMap;class Ju extends Qu{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const s=this._document.createElement("canvas");return s.width=t,s.height=e,s}}class Zu{constructor({baseUrl:t=null,isCompressed:e=!0}){this.baseUrl=t,this.isCompressed=e}async fetch({name:t}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!t)throw new Error("CMap name must be specified.");const e=this.baseUrl+t+(this.isCompressed?".bcmap":"");return this._fetch(e).then(t=>({cMapData:t,isCompressed:this.isCompressed})).catch(t=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){ud("Abstract method `_fetch` called.")}}class tp extends Zu{async _fetch(t){const e=await Bd(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):kd(e)}}class ep{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){}}class sp extends ep{constructor({docId:t,ownerDocument:e=globalThis.document}){super(),xc(this,Js),xc(this,Vs),xc(this,Us),xc(this,qs),xc(this,Xs),xc(this,Ys),xc(this,Ks),xc(this,Qs,0),Sc(this,Xs,t),Sc(this,Ys,e)}addFilter(t){if(!t)return"none";let e=yc(this,Js,Zs).get(t);if(e)return e;const[s,i,n]=kc(this,Js,si).call(this,t),a=1===t.length?s:`${s}${i}${n}`;if(e=yc(this,Js,Zs).get(a),e)return yc(this,Js,Zs).set(t,e),e;const r=`g_${yc(this,Xs)}_transfer_map_${Mc(this,Qs)._++}`,o=kc(this,Js,ii).call(this,r);yc(this,Js,Zs).set(t,o),yc(this,Js,Zs).set(a,o);
1const l=kc(this,Js,ri).call(this,r);return kc(this,Js,li).call(this,s,i,n,l),o}addHCMFilter(t,e){var s;const i=`${t}-${e}`,n="base";let a=yc(this,Js,ti).get(n);if((null==a?void 0:a.key)===i)return a.url;if(a?(null==(s=a.filter)||s.remove(),a.key=i,a.url="none",a.filter=null):(a={key:i,url:"none",filter:null},yc(this,Js,ti).set(n,a)),!t||!e)return a.url;const r=kc(this,Js,ci).call(this,t);t=Cd.makeHexColor(...r);const o=kc(this,Js,ci).call(this,e);if(e=Cd.makeHexColor(...o),yc(this,Js,ei).style.color="","#000000"===t&&"#ffffff"===e||t===e)return a.url;const l=new Array(256);for(let p=0;p<=255;p++){const t=p/255;l[p]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const h=l.join(","),c=`g_${yc(this,Xs)}_hcm_filter`,d=a.filter=kc(this,Js,ri).call(this,c);kc(this,Js,li).call(this,h,h,h,d),kc(this,Js,ai).call(this,d);const u=(t,e)=>{const s=r[t]/255,i=o[t]/255,n=new Array(e+1);for(let a=0;a<=e;a++)n[a]=s+a/e*(i-s);return n.join(",")};return kc(this,Js,li).call(this,u(0,5),u(1,5),u(2,5),d),a.url=kc(this,Js,ii).call(this,c),a.url}addAlphaFilter(t){let e=yc(this,Js,Zs).get(t);if(e)return e;const[s]=kc(this,Js,si).call(this,[t]),i=`alpha_${s}`;if(e=yc(this,Js,Zs).get(i),e)return yc(this,Js,Zs).set(t,e),e;const n=`g_${yc(this,Xs)}_alpha_map_${Mc(this,Qs)._++}`,a=kc(this,Js,ii).call(this,n);yc(this,Js,Zs).set(t,a),yc(this,Js,Zs).set(i,a);const r=kc(this,Js,ri).call(this,n);return kc(this,Js,hi).call(this,s,r),a}addLuminosityFilter(t){let e,s,i=yc(this,Js,Zs).get(t||"luminosity");if(i)return i;if(t?([e]=kc(this,Js,si).call(this,[t]),s=`luminosity_${e}`):s="luminosity",i=yc(this,Js,Zs).get(s),i)return yc(this,Js,Zs).set(t,i),i;const n=`g_${yc(this,Xs)}_luminosity_map_${Mc(this,Qs)._++}`,a=kc(this,Js,ii).call(this,n);yc(this,Js,Zs).set(t,a),yc(this,Js,Zs).set(s,a);const r=kc(this,Js,ri).call(this,n);return kc(this,Js,ni).call(this,r),t&&kc(this,Js,hi).call(this,e,r),a}addHighlightHCMFilter(t,e,s,i,n){var a;const r=`${e}-${s}-${i}-${n}`;let o=yc(this,Js,ti).get(t);if((null==o?void 0:o.key)===r)return o.url;if(o?(null==(a=o.filter)||a.remove(),o.key=r,o.url="none",o.filter=null):(o={key:r,url:"none",filter:null},yc(this,Js,ti).set(t,o)),!e||!s)return o.url;const[l,h]=[e,s].map(kc(this,Js,ci).bind(this));let c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),d=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),[u,p]=[i,n].map(kc(this,Js,ci).bind(this));
1d<c&&([c,d,u,p]=[d,c,p,u]),yc(this,Js,ei).style.color="";const g=(t,e,s)=>{const i=new Array(256),n=(d-c)/s,a=t/255,r=(e-t)/(255*s);let o=0;for(let l=0;l<=s;l++){const t=Math.round(c+l*n),e=a+l*r;for(let s=o;s<=t;s++)i[s]=e;o=t+1}for(let l=o;l<256;l++)i[l]=i[o-1];return i.join(",")},f=`g_${yc(this,Xs)}_hcm_${t}_filter`,m=o.filter=kc(this,Js,ri).call(this,f);return kc(this,Js,ai).call(this,m),kc(this,Js,li).call(this,g(u[0],p[0],5),g(u[1],p[1],5),g(u[2],p[2],5),m),o.url=kc(this,Js,ii).call(this,f),o.url}destroy(t=!1){var e,s,i,n;t&&(null==(e=yc(this,Ks))?void 0:e.size)||(null==(s=yc(this,qs))||s.parentNode.parentNode.remove(),Sc(this,qs,null),null==(i=yc(this,Us))||i.clear(),Sc(this,Us,null),null==(n=yc(this,Ks))||n.clear(),Sc(this,Ks,null),Sc(this,Qs,0))}}Vs=new WeakMap,Us=new WeakMap,qs=new WeakMap,Xs=new WeakMap,Ys=new WeakMap,Ks=new WeakMap,Qs=new WeakMap,Js=new WeakSet,Zs=function(){return yc(this,Us)||Sc(this,Us,new Map)},ti=function(){return yc(this,Ks)||Sc(this,Ks,new Map)},ei=function(){if(!yc(this,qs)){const t=yc(this,Ys).createElement("div"),{style:e}=t;e.visibility="hidden",e.contain="strict",e.width=e.height=0,e.position="absolute",e.top=e.left=0,e.zIndex=-1;const s=yc(this,Ys).createElementNS(Fd,"svg");s.setAttribute("width",0),s.setAttribute("height",0),Sc(this,qs,yc(this,Ys).createElementNS(Fd,"defs")),t.append(s),s.append(yc(this,qs)),yc(this,Ys).body.append(t)}return yc(this,qs)},si=function(t){if(1===t.length){const e=t[0],s=new Array(256);for(let t=0;t<256;t++)s[t]=e[t]/255;const i=s.join(",");return[i,i,i]}const[e,s,i]=t,n=new Array(256),a=new Array(256),r=new Array(256);for(let o=0;o<256;o++)n[o]=e[o]/255,a[o]=s[o]/255,r[o]=i[o]/255;return[n.join(","),a.join(","),r.join(",")]},ii=function(t){if(void 0===yc(this,Vs)){Sc(this,Vs,"");const t=yc(this,Ys).URL;t!==yc(this,Ys).baseURI&&(zd(t)||Sc(this,Vs,fd(t,"")))}return`url(${yc(this,Vs)}#${t})`},ni=function(t){const e=yc(this,Ys).createElementNS(Fd,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),t.append(e)},ai=function(t){const e=yc(this,Ys).createElementNS(Fd,"feColorMatrix");e.setAttribute("type","matrix"),e.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),t.append(e)},ri=function(t){const e=yc(this,Ys).createElementNS(Fd,"filter");return e.setAttribute("color-interpolation-filters","sRGB"),e.setAttribute("id",t),yc(this,Js,ei).append(e),e},oi=function(t,e,s){const i=yc(this,Ys).createElementNS(Fd,e);i.setAttribute("type","discrete"),i.setAttribute("tableValues",s),t.append(i)},li=function(t,e,s,i){const n=yc(this,Ys).createElementNS(Fd,"feComponentTransfer");i.append(n),kc(this,Js,oi).call(this,n,"feFuncR",t),kc(this,Js,oi).call(this,n,"feFuncG",e),kc(this,Js,oi).call(this,n,"feFuncB",s)},hi=function(t,e){const s=yc(this,Ys).createElementNS(Fd,"feComponentTransfer");e.append(s),kc(this,Js,oi).call(this,s,"feFuncA",t)},ci=function(t){return yc(this,Js,ei).style.color=t,Jd(getComputedStyle(yc(this,Js,ei)).getPropertyValue("color"))};class ip{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!t)throw new Error("Font filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){ud("Abstract method `_fetch` called.")}}class np extends ip{async _fetch(t){const e=await Bd(t,"arraybuffer");return new Uint8Array(e)}}class ap{constructor({baseUrl:t=null}){this.baseUrl=t}async fetch({filename:t}){if(!this.baseUrl)throw new Error("Ensure that the `wasmUrl` API parameter is provided.");if(!t)throw new Error("Wasm filename must be specified.");const e=`${this.baseUrl}${t}`;return this._fetch(e).catch(t=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){ud("Abstract method `_fetch` called.")}}class rp extends ap{async _fetch(t){const e=await Bd(t,"arraybuffer");return new Uint8Array(e)}}async function op(t){const e=process.getBuiltinModule("fs"),s=await e.promises.readFile(t);return new Uint8Array(s)}class lp extends ep{}class hp extends Qu{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(t,e)}}class cp extends Zu{async _fetch(t){return op(t)}}class dp extends ip{async _fetch(t){return op(t)}}class up extends ap{async _fetch(t){return op(t)}}const pp="Fill",gp="Stroke",fp="Shading";function mp(t,e){if(!e)return;const s=e[2]-e[0],i=e[3]-e[1],n=new Path2D;n.rect(e[0],e[1],s,i),t.clip(n)}class vp{isModifyingCurrentTransform(){return!1}getPattern(){ud("Abstract method `getPattern` called.")}}class wp extends vp{constructor(t){super(),this._type=t[1],this._bbox=t[2],this._colorStops=t[3],this._p0=t[4],this._p1=t[5],this._r0=t[6],this._r1=t[7],this.matrix=null}_createGradient(t){let e;"axial"===this._type?e=t.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(e=t.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const s of this._colorStops)e.addColorStop(s[0],s[1]);return e}getPattern(t,e,s,i){let n;if(i===gp||i===pp){const a=e.current.getClippedPathBoundingBox(i,Zd(t))||[0,0,0,0],r=M
vendor: 23,607 bytes, line 1
1ath.ceil(a[2]-a[0])||1,o=Math.ceil(a[3]-a[1])||1,l=e.cachedCanvases.getCanvas("pattern",r,o),h=l.context;h.clearRect(0,0,h.canvas.width,h.canvas.height),h.beginPath(),h.rect(0,0,h.canvas.width,h.canvas.height),h.translate(-a[0],-a[1]),s=Cd.transform(s,[1,0,0,1,a[0],a[1]]),h.transform(...e.baseTransform),this.matrix&&h.transform(...this.matrix),mp(h,this._bbox),h.fillStyle=this._createGradient(h),h.fill(),n=t.createPattern(l.canvas,"no-repeat");const c=new DOMMatrix(s);n.setTransform(c)}else mp(t,this._bbox),n=this._createGradient(t);return n}}function bp(t,e,s,i,n,a,r,o){const l=e.coords,h=e.colors,c=t.data,d=4*t.width;let u;l[s+1]>l[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u),l[i+1]>l[n+1]&&(u=i,i=n,n=u,u=r,r=o,o=u),l[s+1]>l[i+1]&&(u=s,s=i,i=u,u=a,a=r,r=u);const p=(l[s]+e.offsetX)*e.scaleX,g=(l[s+1]+e.offsetY)*e.scaleY,f=(l[i]+e.offsetX)*e.scaleX,m=(l[i+1]+e.offsetY)*e.scaleY,v=(l[n]+e.offsetX)*e.scaleX,w=(l[n+1]+e.offsetY)*e.scaleY;if(g>=w)return;const b=h[a],A=h[a+1],_=h[a+2],y=h[r],x=h[r+1],S=h[r+2],k=h[o],M=h[o+1],E=h[o+2],C=Math.round(g),T=Math.round(w);let R,P,I,D,L,N,F,W;for(let O=C;O<=T;O++){if(O<m){const t=O<g?0:(g-O)/(g-m);R=p-(p-f)*t,P=b-(b-y)*t,I=A-(A-x)*t,D=_-(_-S)*t}else{let t;t=O>w?1:m===w?0:(m-O)/(m-w),R=f-(f-v)*t,P=y-(y-k)*t,I=x-(x-M)*t,D=S-(S-E)*t}let t;t=O<g?0:O>w?1:(g-O)/(g-w),L=p-(p-v)*t,N=b-(b-k)*t,F=A-(A-M)*t,W=_-(_-E)*t;const e=Math.round(Math.min(R,L)),s=Math.round(Math.max(R,L));let i=d*O+4*e;for(let n=e;n<=s;n++)t=(R-n)/(R-L),t<0?t=0:t>1&&(t=1),c[i++]=P-(P-N)*t|0,c[i++]=I-(I-F)*t|0,c[i++]=D-(D-W)*t|0,c[i++]=255}}function Ap(t,e,s){const i=e.coords,n=e.colors;let a,r;switch(e.type){case"lattice":const o=e.verticesPerRow,l=Math.floor(i.length/o)-1,h=o-1;for(a=0;a<l;a++){let e=a*o;for(let a=0;a<h;a++,e++)bp(t,s,i[e],i[e+1],i[e+o],n[e],n[e+1],n[e+o]),bp(t,s,i[e+o+1],i[e+1],i[e+o],n[e+o+1],n[e+1],n[e+o])}break;case"triangles":for(a=0,r=i.length;a<r;a+=3)bp(t,s,i[a],i[a+1],i[a+2],n[a],n[a+1],n[a+2]);break;default:throw new Error("illegal figure")}}class _p extends vp{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,s){const i=Math.floor(this._bounds[0]),n=Math.floor(this._bounds[1]),a=Math.ceil(this._bounds[2])-i,r=Math.ceil(this._bounds[3])-n,o=Math.min(Math.ceil(Math.abs(a*t[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(r*t[1]*1.1)),3e3),h=a/o,c=r/l,d={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-n,scaleX:1/h,scaleY:1/c},u=o+4,p=l+4,g=s.getCanvas("mesh",u,p),f=g.context,m=f.createImageData(o,l);if(e){const t=m.data;for(let s=0,i=t.length;s<i;s+=4)t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=255}for(const v of this._figures)Ap(m,v,d);f.putImageData(m,2,2);return{canvas:g.canvas,offsetX:i-2*h,offsetY:n-2*c,scaleX:h,scaleY:c}}isModifyingCurrentTransform(){return!0}getPattern(t,e,s,i){mp(t,this._bbox);const n=new Float32Array(2);if(i===fp)Cd.singularValueDecompose2dScale(Zd(t),n);else if(this.matrix){Cd.singularValueDecompose2dScale(this.matrix,n);const[t,s]=n;Cd.singularValueDecompose2dScale(e.baseTransform,n),n[0]*=t,n[1]*=s}else Cd.singularValueDecompose2dScale(e.baseTransform,n);const a=this._createMeshCanvas(n,i===fp?null:this._background,e.cachedCanvases);return i!==fp&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(a.offsetX,a.offsetY),t.scale(a.scaleX,a.scaleY),t.createPattern(a.canvas,"no-repeat")}}class yp extends vp{getPattern(){return"hotpink"}}const xp=1,Sp=2,kp=class t{constructor(t,e,s,i){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=s,this.baseTransform=i}createPatternCanvas(t){const{bbox:e,operatorList:s,paintType:i,tilingType:n,color:a,canvasGraphicsFactory:r}=this;let{xstep:o,ystep:l}=this;o=Math.abs(o),l=Math.abs(l);const h=e[0],c=e[1],d=e[2],u=e[3],p=d-h,g=u-c,f=new Float32Array(2);Cd.singularValueDecompose2dScale(this.matrix,f);const[m,v]=f;Cd.singularValueDecompose2dScale(this.baseTransform,f);const w=m*f[0],b=v*f[1];let A=p,_=g,y=!1,x=!1;const S=Math.ceil(o*w),k=Math.ceil(l*b);S>=Math.ceil(p*w)?A=o:y=!0,k>=Math.ceil(g*b)?_=l:x=!0;const M=this.getSizeAndScale(A,this.ctx.canvas.width,w),E=this.getSizeAndScale(_,this.ctx.canvas.height,b),C=t.cachedCanvases.getCanvas("pattern",M.size,E.size),T=C.context,R=r.createCanvasGraphics(T);if(R.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(R,i,a),T.translate(-M.scale*h,-E.scale*c),R.transform(M.scale,0,0,E.scale,0,0),T.save(),this.clipBbox(R,h,c,d,u),R.baseTransform=Zd(R.ctx),R.executeOperatorList(s),R.endDrawing(),T.restore(),y||x){const e=C.canvas;y&&(A=o),x&&(_=l);const s=this.getSizeAndScale(A,this.ctx.canvas.width,w),i=this.getSizeAndScale(_,this.ctx.canvas.height,b),n=s.size,a=i.size,r=t.cachedCanvases.getCanvas("pattern-workaround",n,a),d=r.context,u=y?Math.floor(p/o):0,f=x?Math.floor(g/l):0;for(let t=0;t<=u;t++)for(let s=0;s<=f;s++)d.drawImage(e,n*t,a*s,n,a,0,0,n,a);return{canvas:r.canvas,scaleX:s.scale,scaleY:i.scale,offsetX:h,offsetY:c}}return{canvas:C.canvas,scaleX:M.scale,scaleY:E.scale,offsetX:h,offsetY:c}}getSizeAndScale(e,s,i){const n=Math.max(t.MAX_PATTERN_SIZE,s);let a=Math.ceil(e*i);return a>=n?a=n:i=a/e,{scale:i,size:a}}clipBbox(t,e,s,i,n){const a=i-e,r=n-s;t.ctx.rect(e,s,a,r),Cd.axialAlignedBoundingBox([e,s,i,n],Zd(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,s){const i=t.ctx,n=t.current;switch(e){case xp:const{fillStyle:t,strokeStyle:a}=this.ctx;i.fillStyle=n.fillColor=t,i.strokeStyle=n.strokeColor=a;break;case Sp:i.fillStyle=i.strokeStyle=s,n.fillColor=n.strokeColor=s;break;default:throw new yd(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,s,i){let n=s;i!==fp&&(n=Cd.transform(n,e.baseTransform),this.matrix&&(n=Cd.transform(n,this.matrix)));const a=this.createPatternCanvas(e);let r=new DOMMatrix(n);r=r.translate(a.offsetX,a.offsetY),r=r.scale(1/a.scaleX,1/a.scaleY);const o=t.createPattern(a.canvas,"repeat");return o.setTransform(r),o}};Ac(kp,"MAX_PATTERN_SIZE",3e3);let Mp=kp;function Ep({src:t,srcPos:e=0,dest:s,width:i,height:n,nonBlackColor:a=4294967295,inverseDecode:r=!1}){const o=Md.isLittleEndian?4278190080:255,[l,h]=r?[a,o]:[o,a],c=i>>3,d=7&i,u=t.length;s=new Uint32Array(s.buffer);let p=0;for(let g=0;g<n;g++){for(const n=e+c;e<n;e++){const i=e<u?t[e]:255;s[p++]=128&i?h:l,s[p++]=64&i?h:l,s[p++]=32&i?h:l,s[p++]=16&i?h:l,s[p++]=8&i?h:l,s[p++]=4&i?h:l,s[p++]=2&i?h:l,s[p++]=1&i?h:l}if(0===d)continue;const i=e<u?t[e++]:255;for(let t=0;t<d;t++)s[p++]=i&1<<7-t?h:l}return{srcPos:e,destPos:p}}const Cp=16,Tp=new DOMMatrix,Rp=new Float32Array(2),Pp=new Float32Array([1/0,1/0,-1/0,-1/0]);class Ip{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,s){let i;return void 0!==this.cache[t]?(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 Dp(t,e,s,i,n,a,r,o,l,h){const[c,d,u,p,g,f]=Zd(t);if(0===d&&0===u){const m=r*c+g,v=Math.round(m),w=o*p+f,b=Math.round(w),A=(r+l)*c+g,_=Math.abs(Math.round(A)-v)||1,y=(o+h)*p+f,x=Math.abs(Math.round(y)-b)||1;return t.setTransform(Math.sign(c),0,0,Math.sign(p),v,b),t.drawImage(e,s,i,n,a,0,0,_,x),t.setTransform(c,d,u,p,g,f),[_,x]}if(0===c&&0===p){const m=o*u+g,v=Math.round(m),w=r*d+f,b=Math.round(w),A=(o+h)*u+g,_=Math.abs(Math.round(A)-v)||1,y=(r+l)*d+f,x=Math.abs(Math.round(y)-b)||1;return t.setTransform(0,Math.sign(d),Math.sign(u),0,v,b),t.drawImage(e,s,i,n,a,0,0,x,_),t.setTransform(c,d,u,p,g,f),[x,_]}t.drawImage(e,s,i,n,a,r,o,l,h);return[Math.hypot(c,d)*l,Math.hypot(u,p)*h]}class Lp{constructor(t,e){Ac(this,"alphaIsShape",!1),Ac(this,"fontSize",0),Ac(this,"fontSizeScale",1),Ac(this,"textMatrix",null),Ac(this,"textMatrixScale",1),Ac(this,"fontMatrix",Cc),Ac(this,"leading",0),Ac(this,"x",0),Ac(this,"y",0),Ac(this,"lineX",0),Ac(this,"lineY",0),Ac(this,"charSpacing",0),Ac(this,"wordSpacing",0),Ac(this,"textHScale",1),Ac(this,"textRenderingMode",jc),Ac(this,"textRise",0),Ac(this,"fillColor","#000000"),Ac(this,"strokeColor","#000000"),Ac(this,"patternFill",!1),Ac(this,"patternStroke",!1),Ac(this,"fillAlpha",1),Ac(this,"strokeAlpha",1),Ac(this,"lineWidth",1),Ac(this,"activeSMask",null),Ac(this,"transferMaps","none"),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=Pp.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=pp,e=null){const s=this.minMax.slice();if(t===gp){e||ud("Stroke bounding box must include transform."),Cd.singularValueDecompose2dScale(e,Rp);const t=Rp[0]*this.lineWidth/2,i=Rp[1]*this.lineWidth/2;s[0]-=t,s[1]-=i,s[2]+=t,s[3]+=i}return s}updateClipFromPath(){const t=Cd.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(t||[0,0,0,0])}isEmptyClip(){return this.minMax[0]===1/0}startNewPathAndClipBox(t){this.clipBox.set(t,0),this.minMax.set(Pp,0)}getClippedPathBoundingBox(t=pp,e=null){return Cd.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function Np(t,e){if(e instanceof ImageData)return void t.putImageData(e,0,0);const s=e.height,i=e.width,n=s%Cp,a=(s-n)/Cp,r=0===n?a:a+1,o=t.createImageData(i,Cp);let l,h=0;const c=e.data,d=o.data;let u,p,g,f;if(e.kind===Yc.GRAYSCALE_1BPP){const e=c.byteLength,s=new Uint32Array(d.buffer,0,d.byteLength>>2),f=s.length,m=i+7>>3,v=4294967295,w=Md.isLittleEndian?4278190080:255;for(u=0;u<r;u++){for(g=u<a?Cp:n,l=0,p=0;p<g;p++){const t=e-h;let n=0;const a=t>m?i:8*t-7,r=-8&a;let o=0,d=0;for(;n<r;n+=8)d=c[h++],s[l++]=128&d?v:w,s[l++]=64&d?v:w,s[l++]=32&d?v:w,s[l++]=16&d?v:w,s[l++]=8&d?v:w,s[l++]=4&d?v:w,s[l++]=2&d?v:w,s[l++]=1&d?v:w;for(;n<a;n++)0===o&&(d=c[h++],o=128),s[l++]=d&o?v:w,o>>=1}for(;l<f;)s[l++]=0;t.putImageData(o,0,u*Cp)}}else if(e.kind===Yc.RGBA_32BPP){for(p=0,f=i*Cp*4,u=0;u<a;u++)d.set(c.subarray(h,h+f)),h+=f,t.putImageData(o,0,p),p+=Cp;u<r&&(f=i*n*4,d.set(c.subarray(h,h+f)),t.putImageData(o,0,p))}else{if(e.kind!==Yc.RGB_24BPP)throw new Error(`bad image kind: ${e.kind}`);for(g=Cp,f=i*g,u=0;u<r;u++){for(u>=a&&(g=n,f=i*g),l=0,p=f;p--;)d[l++]=c[h++],d[l++]=c[h++],d[l++]=c[h++],d[l++]=255;t.putImageData(o,0,u*Cp)}}}function Fp(t,e){if(e.bitmap)return void t.drawImage(e.bitmap,0,0);const s=e.height,i=e.width,n=s%Cp,a=(s-n)/Cp,r=0===n?a:a+1,o=t.createImageData(i,Cp);let l=0;const h=e.data,c=o.data;for(let d=0;d<r;d++){const e=d<a?Cp:n;({srcPos:l}=Ep({src:h,srcPos:l,dest:c,width:i,height:e,nonBlackColor:0})),t.putImageData(o,0,d*Cp)}}function Wp(t,e){const s=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of s)void 0!==t[i]&&(e[i]=t[i]);void 0!==t.setLineDash&&(e.setLineDash(t.getLineDash()),e.lineDashOffset=t.lineDashOffset)}function Op(t){t.strokeStyle=t.fillStyle="#000000",t.fillRule="nonzero",t.globalAlpha=1,t.lineWidth=1,t.lineCap="butt",t.lineJoin="miter",t.miterLimit=10,t.globalCompositeOperation="source-over",t.font="10px sans-serif",void 0!==t.setLineDash&&(t.setLineDash([]),t.lineDashOffset=0);const{filter:e}=t;"none"!==e&&""!==e&&(t.filter="none")}function Bp(t,e){if(e)return!0;Cd.singularValueDecompose2dScale(t,Rp);const s=Math.fround(su.pixelRatio*Od.PDF_TO_CSS_UNITS);return Rp[0]<=s&&Rp[1]<=s}const Hp=["butt","round","square"],$p=["miter","round","bevel"],zp={},jp={};di=new WeakSet,ui=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)},pi=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==t){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},gi=function(t,e,s){const i=new Path2D;return i.addPath(t,new DOMMatrix(s).invertSelf().multiplySelf(e)),i};let Gp=class t{constructor(t,e,s,i,n,{optionalContentConfig:a,markedContentStack:r=null},o,l){xc(this,di),this.ctx=t,this.current=new Lp(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=s,this.canvasFactory=i,this.filterFactory=n,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=r||[],this.optionalContentConfig=a,this.cachedCanvases=new Ip(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=o,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(t,e=null){return"string"==typeof t?t.startsWith("g_")?this.commonObjs.get(t):this.objs.get(t):e}beginDrawing({transform:t,viewport:e,transparency:s=!1,background:i=null}){const n=this.ctx.canvas.width,a=this.ctx.canvas.height,r=this.ctx.fillStyle;if(this.ctx.fillStyle=i||"#ffffff",this.ctx.fillRect(0,0,n,a),this.ctx.fillStyle=r,s){const t=this.cachedCanvases.getCanvas("transparent",n,a);this.compositeCtx=this.ctx,this.transparentCanvas=t.canvas,this.ctx=t.context,this.ctx.save(),this.ctx.transform(...Zd(this.compositeCtx))}this.ctx.save(),Op(this.ctx),t&&(this.ctx.transform(...t),this.outputScaleX=t[0],this.outputScaleY=t[0]),this.ctx.transform(...e.transform),this.viewportScale=e.scale,this.baseTransform=Zd(this.ctx)}executeOperatorList(t,e,s,i){const n=t.argsArray,a=t.fnArray;let r=e||0;const o=n.length;if(o===r)return r;const l=o-r>10&&"function"==typeof s,h=l?Date.now()+15:0;let c=0;const d=this.commonObjs,u=this.objs;let p;for(;;){if(void 0!==i&&r===i.nextBreakPoint)return i.breakIt(r,s),r;if(p=a[r],p!==id.dependency)this[p].apply(this,n[r]);else for(const t of n[r]){const e=t.startsWith("g_")?d:u;if(!e.has(t))return e.get(t,s),r}if(r++,r===o)return r;if(l&&++c>10){if(Date.now()>h)return s(),r;c=0}}}endDrawing(){kc(this,di,ui).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),kc(this,di,pi).call(this)}_scaleImage(t,e){const s=t.width??t.displayWidth,i=t.height??t.displayHeight;let n,a,r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=s,h=i,c="prescale1";for(;r>2&&l>1||o>2&&h>1;){let e=l,s=h;r>2&&l>1&&(e=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/e),o>2&&h>1&&(s=h>=16384?Math.floor(h/2)-1||1:Math.ceil(h)/2,o/=h/s),n=this.cachedCanvases.getCanvas(c,e,s),a=n.context,a.clearRect(0,0,e,s),a.drawImage(t,0,0,l,h,0,0,e,s),t=n.canvas,l=e,h=s,c="prescale1"===c?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:h}}_createMaskCanvas(t){const e=this.ctx,{width:s,height:i}=t,n=this.current.fillColor,a=this.current.patternFill,r=Zd(e);let o,l,h,c;if((t.bitmap||t.data)&&t.count>1){const e=t.bitmap||t.data.buffer;l=JSON.stringify(a?r:[r.slice(0,4),n]),o=this._cachedBitmapsMap.get(e),o||(o=new Map,this._cachedBitmapsMap.set(e,o));const s=o.get(l);if(s&&!a){return{canvas:s,offsetX:Math.round(Math.min(r[0],r[2])+r[4]),offsetY:Math.round(Math.min(r[1],r[3])+r[5])}}h=s}h||(c=this.cachedCanvases.getCanvas("maskCanvas",s,i),Fp(c.context,t));let d=Cd.transform(r,[1/s,0,0,-1/i,0,0]);d=Cd.transform(d,[1,0,0,1,0,-i]);const u=Pp.slice();Cd.axialAlignedBoundingBox([0,0,s,i],d,u);const[p,g,f,m]=u,v=Math.round(f-p)||1,w=Math.round(m-g)||1,b=this.cachedCanvases.getCanvas("fillCanvas",v,w),A=b.context,_=p,y=g;A.translate(-_,-y),A.transform(...d),h||(h=this._scaleImage(c.canvas,tu(A)),h=h.img,o&&a&&o.set(l,h)),A.imageSmoothingEnabled=Bp(Zd(A),t.interpolate),Dp(A,h,0,0,h.width,h.height,0,0,s,i),A.globalCompositeOperation="source-in";const x=Cd.transform(tu(A),[1,0,0,1,-_,-y]);return A.fillStyle=a?n.getPattern(e,this,x,pp):n,A.fillRect(0,0,s,i),o&&!a&&(this.cachedCanvases.delete("fillCanvas"),o.set(l,b.canvas)),{canvas:b.canvas,offsetX:Math.round(_),offsetY:Math.round(y)}}setLineWidth(t){t!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=t,this.ctx.lineWidth=t}setLineCap(t){this.ctx.lineCap=Hp[t]}setLineJoin(t){this.ctx.lineJoin=$p[t]}setMiterLimit(t){this.ctx.miterLimit=t}setDash(t,e){const s=this.ctx;void 0!==s.setLineDash&&(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.ctx.globalAlpha=this.current.fillAlpha=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)}}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;const n=this.ctx=i.context;n.setTransform(this.suspendedCtx.getTransform()),Wp(this.suspendedCtx,n),function(t,e){if(t._removeMirroring)throw new Error("Context is already forwarding operations.");t.__originalSave=t.save,t.__originalRestore=t.restore,t.__originalRotate=t.rotate,t.__originalScale=t.scale,t.__originalTranslate=t.translate,t.__originalTransform=t.transform,t.__originalSetTransform=t.setTransform,t.__originalResetTransform=t.resetTransform,t.__originalClip=t.clip,t.__originalMoveTo=t.moveTo,t.__originalLineTo=t.lineTo,t.__originalBezierCurveTo=t.bezierCurveTo,t.__originalRect=t.rect,t.__originalClosePath=t.closePath,t.__originalBeginPath=t.beginPath,t._removeMirroring=()=>{t.save=t.__originalSave,t.restore=t.__originalRestore,t.rotate=t.__originalRotate,t.scale=t.__originalScale,t.translate=t.__originalTranslate,t.transform=t.__originalTransform,t.setTransform=t.__originalSetTransform,t.resetTransform=t.__originalResetTransform,t.clip=t.__originalClip,t.moveTo=t.__originalMoveTo,t.lineTo=t.__originalLineTo,t.bezierCurveTo=t.__originalBezierCurveTo,t.rect=t.__originalRect,t.closePath=t.__originalClosePath,t.beginPath=t.__originalBeginPath,delete t._removeMirroring},t.save=function(){e.save(),this.__originalSave()},t.restore=function(){e.restore(),this.__originalRestore()},t.translate=function(t,s){e.translate(t,s),this.__originalTranslate(t,s)},t.scale=function(t,s){e.scale(t,s),this.__originalScale(t,s)},t.transform=function(t,s,i,n,a,r){e.transform(t,s,i,n,a,r),this.__originalTransform(t,s,i,n,a,r)},t.setTransform=function(t,s,i,n,a,r){e.setTransform(t,s,i,n,a,r),this.__originalSetTransform(t,s,i,n,a,r)},t.resetTransform=function(){e.resetTransform(),this.__originalResetTransform()},t.rotate=function(t){e.rotate(t),this.__originalRotate(t)},t.clip=function(t){e.clip(t),this.__originalClip(t)},t.moveTo=function(t,s){e.moveTo(t,s),this.__originalMoveTo(t,s)},t.lineTo=function(t,s){e.lineTo(t,s),this.__originalLineTo(t,s)},t.bezierCurveTo=function(t,s,i,n,a,r){e.bezierCurveTo(t,s,i,n,a,r),this.__originalBezierCurveTo(t,s,i,n,a,r)},t.rect=function(t,s,i,n){e.rect(t,s,i,n),this.__originalRect(t,s,i,n)},t.closePath=function(){e.closePath(),this.__originalClosePath()},t.beginPath=function(){e.beginPath(),this.__originalBeginPath()}}(n,this.suspendedCtx),this.setGState([["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Wp(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],r=i[2]-n,o=i[3]-a;0!==r&&0!==o&&(this.genericComposeSMask(e.context,s,r,o,e.subtype,e.backdrop,e.transferMap,n,a,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(s.canvas,0,0),t.restore())}genericComposeSMask(t,e,s,i,n,a,r,o,l,h,c){let d=t.canvas,u=o-h,p=l-c;if(a)if(u<0||p<0||u+s>d.width||p+i>d.height){const t=this.cachedCanvases.getCanvas("maskExtension",s,i),e=t.context;e.drawImage(d,-u,-p),e.globalCompositeOperation="destination-atop",e.fillStyle=a,e.fillRect(0,0,s,i),e.globalCompositeOperation="source-over",d=t.canvas,u=p=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const e=new Path2D;e.rect(u,p,s,i),t.clip(e),t.globalCompositeOperation="destination-atop",t.fillStyle=a,t.fillRect(u,p,s,i),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),"Alpha"===n&&r?e.filter=this.filterFactory.addAlphaFilter(r):"Luminosity"===n&&(e.filter=this.filterFactory.addLuminosityFilter(r));const g=new Path2D;g.rect(o,l,s,i),e.clip(g),e.globalCompositeOperation="destination-in",e.drawImage(d,u,p,s,i,o,l,s,i),e.restore()}save(){this.inSMaskMode&&Wp(this.ctx,this.suspendedCtx),this.ctx.save();const t=this.current;this.stateStack.push(t),this.current=t.clone()}restore(){0!==this.stateStack.length?(this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Wp(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null):this.inSMaskMode&&this.endSMaskMode()}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){let[i]=e;if(!s)return i||(i=e[0]=new Path2D),void this[t](i);if(!(i instanceof Path2D)){const t=e[0]=new Path2D;for(let e=0,s=i.length;e<s;)switch(i[e++]){case nd:t.moveTo(i[e++],i[e++]);break;case ad:t.lineTo(i[e++],i[e++]);break;case rd:t.bezierCurveTo(i[e++],i[e++],i[e++],i[e++],i[e++],i[e++]);break;case od:t.closePath();break;default:dd(i[e-1])}i=t}Cd.axialAlignedBoundingBox(s,Zd(this.ctx),this.current.minMax),this[t](i)}closePath(){this.ctx.closePath()}stroke(t,e=!0){const s=this.ctx,i=this.current.strokeColor;if(s.globalAlpha=this.current.strokeAlpha,this.contentVisible)if("object"==typeof i&&(null==i?void 0:i.getPattern)){const e=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.strokeStyle=i.getPattern(s,this,tu(s),gp),e){const i=new Path2D;i.addPath(t,s.getTransform().invertSelf().multiplySelf(e)),t=i}
1this.rescaleAndStroke(t,!1),s.restore()}else this.rescaleAndStroke(t,!0);e&&this.consumePath(t,this.current.getClippedPathBoundingBox(gp,Zd(this.ctx))),s.globalAlpha=this.current.fillAlpha}closeStroke(t){this.stroke(t)}fill(t,e=!0){const s=this.ctx,i=this.current.fillColor;let n=!1;if(this.current.patternFill){const e=i.isModifyingCurrentTransform()?s.getTransform():null;if(s.save(),s.fillStyle=i.getPattern(s,this,tu(s),pp),e){const i=new Path2D;i.addPath(t,s.getTransform().invertSelf().multiplySelf(e)),t=i}n=!0}const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(s.fill(t,"evenodd"),this.pendingEOFill=!1):s.fill(t)),n&&s.restore(),e&&this.consumePath(t,a)}eoFill(t){this.pendingEOFill=!0,this.fill(t)}fillStroke(t){this.fill(t,!1),this.stroke(t,!1),this.consumePath(t)}eoFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}closeFillStroke(t){this.fillStroke(t)}closeEOFillStroke(t){this.pendingEOFill=!0,this.fillStroke(t)}endPath(t){this.consumePath(t)}rawFillPath(t){this.ctx.fill(t)}clip(){this.pendingClip=zp}eoClip(){this.pendingClip=jp}beginText(){this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const t=this.pendingTextPaths,e=this.ctx;if(void 0===t)return;const s=new Path2D,i=e.getTransform().invertSelf();for(const{transform:n,x:a,y:r,fontSize:o,path:l}of t)l&&s.addPath(l,new DOMMatrix(n).preMultiplySelf(i).translate(a,r).scale(o,-o));e.clip(s),delete this.pendingTextPaths}setCharSpacing(t){this.current.charSpacing=t}setWordSpacing(t){this.current.wordSpacing=t}setHScale(t){this.current.textHScale=t/100}setLeading(t){this.current.leading=-t}setFont(t,e){var s;const i=this.commonObjs.get(t),n=this.current;if(!i)throw new Error(`Can't find font for ${t}`);if(n.fontMatrix=i.fontMatrix||Cc,0===n.fontMatrix[0]||n.fontMatrix[3],e<0?(e=-e,n.fontDirection=-1):n.fontDirection=1,this.current.font=i,this.current.fontSize=e,i.isType3Font)return;const a=i.loadedName||"sans-serif",r=(null==(s=i.systemFontInfo)?void 0:s.css)||`"${a}", ${i.fallbackName}`;let o="normal";i.black?o="900":i.bold&&(o="bold");const l=i.italic?"italic":"normal";let h=e;e<16?h=16:e>100&&(h=100),this.current.fontSizeScale=e/h,this.ctx.font=`${l} ${o} ${h}px ${r}`}setTextRenderingMode(t){this.current.textRenderingMode=t}setTextRise(t){this.current.textRise=t}moveText(t,e){this.current.x=this.current.lineX+=t,this.current.y=this.current.lineY+=e}setLeadingMoveText(t,e){this.setLeading(-e),this.moveText(t,e)}setTextMatrix(t){const{current:e}=this;e.textMatrix=t,e.textMatrixScale=Math.hypot(t[0],t[1]),e.x=e.lineX=0,e.y=e.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(t,e,s,i,n){const a=this.ctx,r=this.current,o=r.font,l=r.textRenderingMode,h=r.fontSize/r.fontSizeScale,c=l&qc,d=!!(l&Xc),u=r.patternFill&&!o.missingFile,p=r.patternStroke&&!o.missingFile;let g;if((o.disableFontFace||d||u||p)&&!o.missingFile&&(g=o.getPathGenerator(this.commonObjs,t)),g&&(o.disableFontFace||u||p)){let t;if(a.save(),a.translate(e,s),a.scale(h,-h),c!==jc&&c!==Vc||(i?(t=a.getTransform(),a.setTransform(...i),a.fill(kc(this,di,gi).call(this,g,t,i))):a.fill(g)),c===Gc||c===Vc)if(n){t||(t=a.getTransform()),a.setTransform(...n);const{a:e,b:s,c:i,d:r}=t,o=Cd.inverseTransform(n),l=Cd.transform([e,s,i,r,0,0],o);Cd.singularValueDecompose2dScale(l,Rp),a.lineWidth*=Math.max(Rp[0],Rp[1])/h,a.stroke(kc(this,di,gi).call(this,g,t,n))}else a.lineWidth/=h,a.stroke(g);a.restore()}else c!==jc&&c!==Vc||a.fillText(t,e,s),c!==Gc&&c!==Vc||a.strokeText(t,e,s);if(d){(this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:Zd(a),x:e,y:s,fontSize:h,path:g})}}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let s=!1;for(let i=3;i<e.length;i+=4)if(e[i]>0&&e[i]<255){s=!0;break}return md(this,"isFontSubpixelAAEnabled",s)}showText(t){const e=this.current,s=e.font;if(s.isType3Font)return this.showType3Text(t);const i=e.fontSize;if(0===i)return;const n=this.ctx,a=e.fontSizeScale,r=e.charSpacing,o=e.wordSpacing,l=e.fontDirection,h=e.textHScale*l,c=t.length,d=s.vertical,u=d?1:-1,p=s.defaultVMetrics,g=i*e.fontMatrix[0],f=e.textRenderingMode===jc&&!s.disableFontFace&&!e.patternFill;let m,v;if(n.save(),e.textMatrix&&n.transform(...e.textMatrix),n.translate(e.x,e.y+e.textRise),l>0?n.scale(h,-1):n.scale(h,1),e.patternFill){n.save();const t=e.fillColor.getPattern(n,this,tu(n),pp);
vendor: 6,925 bytes, line 1
1m=Zd(n),n.restore(),n.fillStyle=t}if(e.patternStroke){n.save();const t=e.strokeColor.getPattern(n,this,tu(n),gp);v=Zd(n),n.restore(),n.strokeStyle=t}let w=e.lineWidth;const b=e.textMatrixScale;if(0===b||0===w){const t=e.textRenderingMode&qc;t!==Gc&&t!==Vc||(w=this.getSinglePixelWidth())}else w/=b;if(1!==a&&(n.scale(a,a),w/=a),n.lineWidth=w,s.isInvalidPDFjsFont){const s=[];let i=0;for(const e of t)s.push(e.unicode),i+=e.width;return n.fillText(s.join(""),0,0),e.x+=i*g*h,n.restore(),void this.compose()}let A,_=0;for(A=0;A<c;++A){const e=t[A];if("number"==typeof e){_+=u*e*i/1e3;continue}let h=!1;const c=(e.isSpace?o:0)+r,w=e.fontChar,b=e.accent;let y,x,S=e.width;if(d){const t=e.vmetric||p,s=-(e.vmetric?t[1]:.5*S)*g,i=t[2]*g;S=t?-t[0]:S,y=s/a,x=(_+i)/a}else y=_/a,x=0;if(s.remeasure&&S>0){const t=1e3*n.measureText(w).width/i*a;if(S<t&&this.isFontSubpixelAAEnabled){const e=S/t;h=!0,n.save(),n.scale(e,1),y/=e}else S!==t&&(y+=(S-t)/2e3*i/a)}if(this.contentVisible&&(e.isInFont||s.missingFile))if(f&&!b)n.fillText(w,y,x);else if(this.paintChar(w,y,x,m,v),b){const t=y+i*b.offset.x/a,e=x-i*b.offset.y/a;this.paintChar(b.fontChar,t,e,m,v)}_+=d?S*g-c*l:S*g+c*l,h&&n.restore()}d?e.y-=_:e.x+=_*h,n.restore(),this.compose()}showType3Text(t){const e=this.ctx,s=this.current,i=s.font,n=s.fontSize,a=s.fontDirection,r=i.vertical?1:-1,o=s.charSpacing,l=s.wordSpacing,h=s.textHScale*a,c=s.fontMatrix||Cc,d=t.length;let u,p,g,f;if(!(s.textRenderingMode===Uc)&&0!==n){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,e.save(),s.textMatrix&&e.transform(...s.textMatrix),e.translate(s.x,s.y+s.textRise),e.scale(h,a),u=0;u<d;++u){if(p=t[u],"number"==typeof p){f=r*p*n/1e3,this.ctx.translate(f,0),s.x+=f*h;continue}const a=(p.isSpace?l:0)+o,d=i.charProcOperatorList[p.operatorListId];d?this.contentVisible&&(this.save(),e.scale(n,n),e.transform(...c),this.executeOperatorList(d),this.restore()):dd(p.operatorListId);const m=[p.width,0];Cd.applyTransform(m,c),g=m[0]*n+a,e.translate(g,0),s.x+=g*h}e.restore()}}setCharWidth(t,e){}setCharWidthAndBounds(t,e,s,i,n,a){const r=new Path2D;r.rect(s,i,n-s,a-i),this.ctx.clip(r),this.endPath()}getColorN_Pattern(e){let s;if("TilingPattern"===e[0]){const i=this.baseTransform||Zd(this.ctx),n={createCanvasGraphics:e=>new t(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};s=new Mp(e,this.ctx,n,i)}else s=this._getPattern(e[1],e[2]);return s}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(t){this.ctx.strokeStyle=this.current.strokeColor=t,this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t){this.ctx.fillStyle=this.current.fillColor=t,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=function(t){switch(t[0]){case"RadialAxial":return new wp(t);case"Mesh":return new _p(t);case"Dummy":return new yp}throw new Error(`Unknown IR type: ${t[0]}`)}(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,tu(e),fp);const i=tu(e);if(i){const{width:t,height:s}=e.canvas,n=Pp.slice();Cd.axialAlignedBoundingBox([0,0,t,s],i,n);const[a,r,o,l]=n;this.ctx.fillRect(a,r,o-a,l-r)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){ud("Should not call beginInlineImage")}beginImageData(){ud("Should not call beginImageData")}paintFormXObjectBegin(t,e){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),t&&this.transform(...t),this.baseTransform=Zd(this.ctx),e)){Cd.axialAlignedBoundingBox(e,this.baseTransform,this.current.minMax);const[t,s,i,n]=e,a=new Path2D;a.rect(t,s,i-t,n-s),this.ctx.clip(a),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,t.knockout;const s=Zd(e);if(t.matrix&&e.transform(...t.matrix),!t.bbox)throw new Error("Bounding box is required.");let i=Pp.slice();Cd.axialAlignedBoundingBox(t.bbox,Zd(e),i);const n=[0,0,e.canvas.width,e.canvas.height];i=Cd.intersect(i,n)||[0,0,0,0];const a=Math.floor(i[0]),r=Math.floor(i[1]),o=Math.max(Math.ceil(i[2])-a,1),l=Math.max(Math.ceil(i[3])-r,1);this.current.startNewPathAndClipBox([0,0,o,l]);let h="groupAt"+this.groupLevel;t.smask&&(h+="_smask_"+this.smaskCounter++%2);const c=this.cachedCanvases.getCanvas(h,o,l),d=c.context;d.translate(-a,-r),d.transform(...s);let u=new Path2D;const[p,g,f,m]=t.bbox;if(u.rect(p,g,f-p,m-g),t.matrix){const e=new Path2D;e.addPath(u,new DOMMatrix(t.matrix)),u=e}d.clip(u),t.smask?this.smaskStack.push({canvas:c.canvas,context:d,offsetX:a,offsetY:r,subtype:t.smask.subtype,backdrop:t.smask.backdrop,transferMap:t.smask.transferMap||null,startTransformInverse:null}):(e.setTransform(1,0,0,1,0,0),e.translate(a,r),e.save()),Wp(e,d),this.ctx=d,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 t=Zd(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...t);const s=Pp.slice();Cd.axialAlignedBoundingBox([0,0,e.canvas.width,e.canvas.height],t,s),this.ctx.drawImage(e.canvas,0,0),this.ctx.restore(),this.compose(s)}}beginAnnotation(t,e,s,i,n){if(kc(this,di,ui).call(this),Op(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),e){const i=e[2]-e[0],a=e[3]-e[1];if(n&&this.annotationCanvasMap){(s=s.slice())[4]-=e[0],s[5]-=e[1],(e=e.slice())[0]=e[1]=0,e[2]=i,e[3]=a,Cd.singularValueDecompose2dScale(Zd(this.ctx),Rp);const{viewportScale:n}=this,r=Math.ceil(i*this.outputScaleX*n),o=Math.ceil(a*this.outputScaleY*n);this.annotationCanvas=this.canvasFactory.create(r,o);const{canvas:l,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(t,l),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(Rp[0],0,0,-Rp[1],0,a*Rp[1]),Op(this.ctx)}else{Op(this.ctx),this.endPath();const t=new Path2D;t.rect(e[0],e[1],i,a),this.ctx.clip(t)}}
1this.current=new Lp(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...s),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),kc(this,di,pi).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)).count=e;const s=this.ctx,i=this._createMaskCanvas(t),n=i.canvas;s.save(),s.setTransform(1,0,0,1,0,0),s.drawImage(n,i.offsetX,i.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 r=this.ctx;r.save();const o=Zd(r);r.transform(e,s,i,n,0,0);const l=this._createMaskCanvas(t);r.setTransform(1,0,0,1,l.offsetX-o[4],l.offsetY-o[5]);for(let h=0,c=a.length;h<c;h+=2){const t=Cd.transform(o,[e,s,i,n,a[h],a[h+1]]);r.drawImage(l.canvas,t[4],t[5])}r.restore(),this.compose()}paintImageMaskXObjectGroup(t){if(!this.contentVisible)return;const e=this.ctx,s=this.current.fillColor,i=this.current.patternFill;for(const n of t){const{data:t,width:a,height:r,transform:o}=n,l=this.cachedCanvases.getCanvas("maskCanvas",a,r),h=l.context;h.save();Fp(h,this.getObject(t,n)),h.globalCompositeOperation="source-in",h.fillStyle=i?s.getPattern(h,this,tu(e),pp):s,h.fillRect(0,0,a,r),h.restore(
vendor: 4,128 bytes, line 1
1),e.save(),e.transform(...o),e.scale(1,-1),Dp(e,l.canvas,0,0,a,r,0,-1,1,1),e.restore()}this.compose()}paintImageXObject(t){if(!this.contentVisible)return;const e=this.getObject(t);e&&this.paintInlineImageXObject(e)}paintImageXObjectRepeat(t,e,s,i){if(!this.contentVisible)return;const n=this.getObject(t);if(!n)return;const a=n.width,r=n.height,o=[];for(let l=0,h=i.length;l<h;l+=2)o.push({transform:[e,0,0,s,i[l],i[l+1]],x:0,y:0,w:a,h:r});this.paintInlineImageXObjectGroup(n,o)}applyTransferMapsToCanvas(t){return"none"!==this.current.transferMaps&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if("none"===this.current.transferMaps)return t.bitmap;const{bitmap:e,width:s,height:i}=t,n=this.cachedCanvases.getCanvas("inlineImage",s,i),a=n.context;return a.filter=this.current.transferMaps,a.drawImage(e,0,0),a.filter="none",n.canvas}paintInlineImageXObject(t){if(!this.contentVisible)return;const e=t.width,s=t.height,i=this.ctx;this.save();const{filter:n}=i;let a;if("none"!==n&&""!==n&&(i.filter="none"),i.scale(1/e,-1/s),t.bitmap)a=this.applyTransferMapsToBitmap(t);else if("function"==typeof HTMLElement&&t instanceof HTMLElement||!t.data)a=t;else{const i=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Np(i,t),a=this.applyTransferMapsToCanvas(i)}const r=this._scaleImage(a,tu(i));i.imageSmoothingEnabled=Bp(Zd(i),t.interpolate),Dp(i,r.img,0,0,r.paintWidth,r.paintHeight,0,-s,e,s),this.compose(),this.restore()}paintInlineImageXObjectGroup(t,e){if(!this.contentVisible)return;const s=this.ctx;let i;if(t.bitmap)i=t.bitmap;else{const e=t.width,s=t.height,n=this.cachedCanvases.getCanvas("inlineImage",e,s).context;Np(n,t),i=this.applyTransferMapsToCanvas(n)}for(const n of e)s.save(),s.transform(...n.transform),s.scale(1,-1),Dp(s,i,n.x,n.y,n.w,n.h,0,-1,1,1),s.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t){}markPointProps(t,e){}beginMarkedContent(t){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e){"OC"===t?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(e)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(t,e){const s=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const i=this.ctx;this.pendingClip&&(s||(this.pendingClip===jp?i.clip(t,"evenodd"):i.clip(t)),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=Zd(this.ctx);if(0===t[1]&&0===t[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),s=Math.hypot(t[0],t[2]),i=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(s,i)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:t}=this.current,{a:e,b:s,c:i,d:n}=this.ctx.getTransform();let a,r;if(0===s&&0===i){const s=Math.abs(e),i=Math.abs(n);if(s===i)if(0===t)a=r=1/s;else{const e=s*t;a=r=e<1?1/e:1}else if(0===t)a=1/s,r=1/i;else{const e=s*t,n=i*t;a=e<1?1/e:1,r=n<1?1/n:1}}else{const o=Math.abs(e*n-s*i),l=Math.hypot(e,s),h=Math.hypot(i,n);if(0===t)a=h/o,r=l/o;else{const e=t*o;a=h>e?h/e:1,r=l>e?l/e:1}}this._cachedScaleForStroking[0]=a,this._cachedScaleForStroking[1]=r}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:s,current:{lineWidth:i}}=this,[n,a]=this.getScaleForStroking();if(n===a)return s.lineWidth=(i||1)*n,void s.stroke(t);const r=s.getLineDash();e&&s.save(),s.scale(n,a),Tp.a=1/n,Tp.d=1/a;const o=new Path2D;if(o.addPath(t,Tp),r.length>0){const t=Math.max(n,a);s.setLineDash(r.map(e=>e/t)),s.lineDashOffset/=t}s.lineWidth=i||1,s.stroke(o),e&&s.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};
1for(const sm in id)void 0!==Gp.prototype[sm]&&(Gp.prototype[id[sm]]=Gp.prototype[sm]);class Vp{static get workerPort(){return yc(this,fi)}static set workerPort(t){if(!("undefined"!=typeof Worker&&t instanceof Worker)&&null!==t)throw new Error("Invalid `workerPort` type.");Sc(this,fi,t)}static get workerSrc(){return yc(this,mi)}static set workerSrc(t){if("string"!=typeof t)throw new Error("Invalid `workerSrc` type.");Sc(this,mi,t)}}fi=new WeakMap,mi=new WeakMap,xc(Vp,fi,null),xc(Vp,mi,"");class Up{constructor({parsedData:t,rawData:e}){xc(this,vi),xc(this,wi),Sc(this,vi,t),Sc(this,wi,e)}getRaw(){return yc(this,wi)}get(t){return yc(this,vi).get(t)??null}[Symbol.iterator](){return yc(this,vi).entries()}}vi=new WeakMap,wi=new WeakMap;const qp=Symbol("INTERNAL");class Xp{constructor(t,{name:e,intent:s,usage:i,rbGroups:n}){xc(this,bi,!1),xc(this,Ai,!1),xc(this,_i,!1),xc(this,yi,!0),Sc(this,bi,!!(t&Pc)),Sc(this,Ai,!!(t&Ic)),this.name=e,this.intent=s,this.usage=i,this.rbGroups=n}get visible(){if(yc(this,_i))return yc(this,yi);if(!yc(this,yi))return!1;const{print:t,view:e}=this.usage;return yc(this,bi)?"OFF"!==(null==e?void 0:e.viewState):!yc(this,Ai)||"OFF"!==(null==t?void 0:t.printState)}_setVisible(t,e,s=!1){t!==qp&&ud("Internal method `_setVisible` called."),Sc(this,_i,s),Sc(this,yi,e)}}bi=new WeakMap,Ai=new WeakMap,_i=new WeakMap,yi=new WeakMap;class Yp{constructor(t,e=Pc){if(xc(this,Ei),xc(this,xi,null),xc(this,Si,new Map),xc(this,ki,null),xc(this,Mi,null),this.renderingIntent=e,this.name=null,this.creator=null,null!==t){this.name=t.name,this.creator=t.creator,Sc(this,Mi,t.order);for(const s of t.groups)yc(this,Si).set(s.id,new Xp(e,s));if("OFF"===t.baseState)for(const t of yc(this,Si).values())t._setVisible(qp,!1);for(const e of t.on)yc(this,Si).get(e)._setVisible(qp,!0);for(const e of t.off)yc(this,Si).get(e)._setVisible(qp,!1);Sc(this,ki,this.getHash())}}isVisible(t){if(0===yc(this,Si).size)return!0;if(!t)return!0;if("OCG"===t.type)return yc(this,Si).has(t.id)?yc(this,Si).get(t.id).visible:(t.id,!0);if("OCMD"===t.type){if(t.expression)return kc(this,Ei,Ci).call(this,t.expression);if(!t.policy||"AnyOn"===t.policy){for(const e of t.ids){if(!yc(this,Si).has(e))return dd(),!0;if(yc(this,Si).get(e).visible)return!0}return!1}if("AllOn"===t.policy){for(const e of t.ids){if(!yc(this,Si).has(e))return dd(),!0;if(!yc(this,Si).get(e).visible)return!1}return!0}if("AnyOff"===t.policy){for(const e of t.ids){if(!yc(this,Si).has(e))return dd(),!0;if(!yc(this,Si).get(e).visible)return!0}return!1}if("AllOff"===t.policy){for(const e of t.ids){if(!yc(this,Si).has(e))return dd(),!0;if(yc(this,Si).get(e).visible)return!1}return!0}return t.policy,!0}return t.type,!0}setVisibility(t,e=!0,s=!0){var i;const n=yc(this,Si).get(t);if(n){if(s&&e&&n.rbGroups.length)for(const e of n.rbGroups)for(const s of e)s!==t&&(null==(i=yc(this,Si).get(s))||i._setVisible(qp,!1,!0));n._setVisible(qp,!!e,!0),Sc(this,xi,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 t=yc(this,Si).get(i);if(t)switch(s){case"ON":this.setVisibility(i,!0,e);break;case"OFF":this.setVisibility(i,!1,e);break;case"Toggle":this.setVisibility(i,!t.visible,e)}}Sc(this,xi,null)}get hasInitialVisibility(){return null===yc(this,ki)||this.getHash()===yc(this,ki)}getOrder(){return yc(this,Si).size?yc(this,Mi)?yc(this,Mi).slice():[...yc(this,Si).keys()]:null}getGroup(t){return yc(this,Si).get(t)||null}getHash(){if(null!==yc(this,xi))return yc(this,xi);const t=new Cu;for(const[e,s]of yc(this,Si))t.update(`${e}:${s.visible}`);return Sc(this,xi,t.hexdigest())}[Symbol.iterator](){return yc(this,Si).entries()}}xi=new WeakMap,Si=new WeakMap,ki=new WeakMap,Mi=new WeakMap,Ei=new WeakSet,Ci=function(t){const e=t.length;if(e<2)return!0;const s=t[0];for(let i=1;i<e;i++){const e=t[i];let n;if(Array.isArray(e))n=kc(this,Ei,Ci).call(this,e);else{if(!yc(this,Si).has(e))return dd(),!0;n=yc(this,Si).get(e).visible}switch(s){case"And":if(!n)return!1;break;case"Or":if(n)return!0;break;case"Not":return!n;default:return!0}}return"And"===s};class Kp{constructor(t,{disableRange:e=!1,disableStream:s=!1}){pd(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:i,initialData:n,progressiveDone:a,contentDispositionFilename:r}=t;if(this._queuedChunks=[],this._progressiveDone=a,this._contentDispositionFilename=r,(null==n?void 0:n.length)>0){const t=n instanceof Uint8Array&&n.byteLength===n.buffer.byteLength?n.buffer:new Uint8Array(n).buffer;this._queuedChunks.push(t)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!s,this._isRangeSupported=!e,this._contentLength=i,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((t,e)=>{this._onReceiveData({begin:t,chunk:e})}),t.addProgressListener((t,e)=>{this._onProgress({loaded:t,total:e})}),t.addProgressiveReadListener(t=>{this._onReceiveData({chunk:t})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const s=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(void 0===t)this._fullRequestReader?this._fullRequestReader._enqueue(s):this._queuedChunks.push(s);else{pd(this._rangeReaders.some(function(e){return e._begin===t&&(e._enqueue(s),!0)}),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}_onProgress(t){var e,s,i,n;void 0===t.total?null==(s=null==(e=this._rangeReaders[0])?void 0:e.onProgress)||s.call(e,{loaded:t.loaded}):null==(n=null==(i=this._fullRequestReader)?void 0:i.onProgress)||n.call(i,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;null==(t=this._fullRequestReader)||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){pd(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new Qp(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new Jp(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(s),s}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const s of this._rangeReaders.slice(0))s.cancel(t);this._pdfDataRangeTransport.abort()}}class Qp{constructor(t,e,s=!1,i=null){this._stream=t,this._done=s||!1,this._filename=jd(i)?i:null,this._queuedChunks=e||[],this._loaded=0;for(const n of this._queuedChunks)this._loaded+=n.byteLength;
vendor: 19,418 bytes, line 1
1this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length>0){this._requests.shift().resolve({value:t,done:!1})}else this._queuedChunks.push(t);this._loaded+=t.byteLength}}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0){return{value:this._queuedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Jp{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(0===this._requests.length)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Zp(t,e){const s=new Headers;if(!t||!e||"object"!=typeof e)return s;for(const i in e){const t=e[i];void 0!==t&&s.append(i,t)}return s}function tg(t){var e;return(null==(e=URL.parse(t))?void 0:e.origin)??null}function eg({responseHeaders:t,isHttp:e,rangeChunkSize:s,disableRange:i}){const n={allowRangeRequests:!1,suggestedLength:void 0},a=parseInt(t.get("Content-Length"),10);if(!Number.isInteger(a))return n;if(n.suggestedLength=a,a<=2*s)return n;if(i||!e)return n;if("bytes"!==t.get("Accept-Ranges"))return n;return"identity"!==(t.get("Content-Encoding")||"identity")||(n.allowRangeRequests=!0),n}function sg(t){const e=t.get("Content-Disposition");if(e){let t=function(t){let e=!0,s=i("filename\\*","i").exec(t);if(s){s=s[1];let t=r(s);return t=unescape(t),t=o(t),t=l(t),a(t)}if(s=function(t){const e=[];let s;const n=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(s=n.exec(t));){let[,t,i,n]=s;if(t=parseInt(t,10),t in e){if(0===t)break}else e[t]=[i,n]}const a=[];for(let i=0;i<e.length&&i in e;++i){let[t,s]=e[i];s=r(s),t&&(s=unescape(s),0===i&&(s=o(s))),a.push(s)}return a.join("")}(t),s)return a(l(s));if(s=i("filename","i").exec(t),s){s=s[1];let t=r(s);return t=l(t),a(t)}function i(t,e){return new RegExp("(?:^|;)\\s*"+t+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',e)}function n(t,s){if(t){if(!/^[\x00-\xFF]+$/.test(s))return s;try{const i=new TextDecoder(t,{fatal:!0}),n=kd(s);s=i.decode(n),e=!1}catch{}}return s}function a(t){return e&&/[\x80-\xff]/.test(t)&&(t=n("utf-8",t),e&&(t=n("iso-8859-1",t))),t}function r(t){if(t.startsWith('"')){const e=t.slice(1).split('\\"');for(let t=0;t<e.length;++t){const s=e[t].indexOf('"');-1!==s&&(e[t]=e[t].slice(0,s),e.length=t+1),e[t]=e[t].replaceAll(/\\(.)/g,"$1")}t=e.join('"')}return t}function o(t){const e=t.indexOf("'");return-1===e?t:n(t.slice(0,e),t.slice(e+1).replace(/^[^']*'/,""))}function l(t){return!t.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(t)?t:t.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(t,e,s,i){if("q"===s||"Q"===s)return n(e,i=(i=i.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,function(t,e){return String.fromCharCode(parseInt(e,16))}));try{i=atob(i)}catch{}return n(e,i)})}return""}(e);if(t.includes("%"))try{t=decodeURIComponent(t)}catch{}if(jd(t))return t}return null}function ig(t,e){return new _d(`Unexpected server response (${t}) while retrieving PDF "${e}".`,t,404===t||0===t&&e.startsWith("file:"))}function ng(t){return 200===t||206===t}function ag(t,e,s){return{method:"GET",headers:t,signal:s.signal,mode:"cors",credentials:e?"include":"same-origin",redirect:"follow"}}function rg(t){return t instanceof Uint8Array?t.buffer:t instanceof ArrayBuffer?t:new Uint8Array(t).buffer}class og{constructor(t){Ac(this,"_responseOrigin",null),this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=Zp(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return pd(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new lg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new hg(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class lg{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const s=new Headers(t.headers),i=e.url;fetch(i,ag(s,this._withCredentials,this._abortController)).then(e=>{if(t._responseOrigin=tg(e.url),!ng(e.status))throw ig(e.status,i);this._reader=e.body.getReader(),this._headersCapability.resolve();const s=e.headers,{allowRangeRequests:n,suggestedLength:a}=eg({responseHeaders:s,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=n,this._contentLength=a||this._contentLength,this._filename=sg(s),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new xd("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 t;await this._headersCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength}),{value:rg(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class hg{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,ag(n,this._withCredentials,this._abortController)).then(e=>{const s=tg(e.url);if(s!==t._responseOrigin)throw new Error(`Expected range response-origin "${s}" to match "${t._responseOrigin}".`);if(!ng(e.status))throw ig(e.status,a);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;await this._readCapability.promise;const{value:e,done:s}=await this._reader.read();return s?{value:e,done:s}:(this._loaded+=e.byteLength,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded}),{value:rg(e),done:!1})}cancel(t){var e;null==(e=this._reader)||e.cancel(t),this._abortController.abort()}}class cg{constructor({url:t,httpHeaders:e,withCredentials:s}){Ac(this,"_responseOrigin",null),this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=Zp(this.isHttp,e),this.withCredentials=s||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,s=this.currXhrId++,i=this.pendingRequests[s]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[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=206):i.expectedStatus=200,e.responseType="arraybuffer",pd(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,s),e.onprogress=this.onProgress.bind(this,s),i.onHeadersReceived=t.onHeadersReceived,i.onDone=t.onDone,i.onError=t.onError,i.onProgress=t.onProgress,e.send(null),s}onProgress(t,e){var s;const i=this.pendingRequests[t];i&&(null==(s=i.onProgress)||s.call(i,e))}onStateChange(t,e){const s=this.pendingRequests[t];if(!s)return;const i=s.xhr;if(i.readyState>=2&&s.onHeadersReceived&&(s.onHeadersReceived(),delete s.onHeadersReceived),4!==i.readyState)return;if(!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],0===i.status&&this.isHttp)return void s.onError(i.status);const n=i.status||200;if(!(200===n&&206===s.expectedStatus)&&n!==s.expectedStatus)return void s.onError(i.status);const a=function(t){const e=t.response;return"string"!=typeof e?e:kd(e).buffer}(i);if(206===n){const t=i.getResponseHeader("Content-Range"),e=/bytes (\d+)-(\d+)\/(\d+)/.exec(t);e?s.onDone({begin:parseInt(e[1],10),chunk:a}):s.onError(0)}else a?s.onDone({begin:0,chunk:a}):s.onError(i.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class dg{constructor(t){this._source=t,this._manager=new cg(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 pd(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new ug(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const s=new pg(this._manager,t,e);return s.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class ug{constructor(t,e){this._manager=t,this._url=e.url,this._fullRequestId=t.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._contentLength=e.length,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const t=this._fullRequestId,e=this._manager.getRequestXhr(t);this._manager._responseOrigin=tg(e.responseURL);const s=e.getAllResponseHeaders(),i=new Headers(s?s.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(t=>{const[e,...s]=t.split(": ");return[e,s.join(": ")]}):[]),{allowRangeRequests:n,suggestedLength:a}=eg({responseHeaders:i,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});n&&(this._isRangeSupported=!0),this._contentLength=a||this._contentLength,this._filename=sg(i),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t)if(this._requests.length>0){this._requests.shift().resolve({value:t.chunk,done:!1})}else this._cachedChunks.push(t.chunk);if(this._done=!0,!(this._cachedChunks.length>0)){for(const t of this._requests)t.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=ig(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;null==(e=this.onProgress)||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0){return{value:this._cachedChunks.shift(),done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class pg{constructor(t,e,s){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:s,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var t;const e=tg(null==(t=this._manager.getRequestXhr(this._requestId))?void 0:t.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;null==(t=this.onClosed)||t.call(this,this)}_onDone(t){const e=t.chunk;if(this._requests.length>0){this._requests.shift().resolve({value:e,done:!1})}else this._queuedChunk=e;this._done=!0;for(const s of this._requests)s.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=ig(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||null==(e=this.onProgress)||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const t=this._queuedChunk;return this._queuedChunk=null,{value:t,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const 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 gg=/^[a-z][a-z0-9\-+.]+:/i;class fg{constructor(t){this.source=t,this.url=function(t){if(gg.test(t))return new URL(t);const e=process.getBuiltinModule("url");return new URL(e.pathToFileURL(t))}(t.url),pd("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return(null==(t=this._fullRequestReader)?void 0:t._loaded)??0}getFullReader(){return pd(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new mg(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const s=new vg(this,t,e);return this._rangeRequestReaders.push(s),s}cancelAllRequests(t){var e;null==(e=this._fullRequestReader)||e.cancel(t);for(const s of this._rangeRequestReaders.slice(0))s.cancel(t)}}class mg{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const s=process.getBuiltinModule("fs");s.promises.lstat(this._url).then(t=>{this._contentLength=t.size,this._setReadableStream(s.createReadStream(this._url)),this._headersCapability.resolve()},t=>{"ENOENT"===t.code&&(t=ig(0,this._url.href)),this._storedError=t,this._headersCapability.reject(t)})}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded,total:this._contentLength});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new xd("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class vg{constructor(t,e,s){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const i=t.source;this._isStreamingSupported=!i.disableStream;const n=process.getBuiltinModule("fs");this._setReadableStream(n.createReadStream(this._url,{start:e,end:s-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var t;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();if(null===e)return this._readCapability=Promise.withResolvers(),this.read();this._loaded+=e.length,null==(t=this.onProgress)||t.call(this,{loaded:this._loaded});return{value:new Uint8Array(e).buffer,done:!1}}cancel(t){this._readableStream?this._readableStream.destroy(t):this._error(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",t=>{this._error(t)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const wg=Symbol("INITIAL_DATA");
1class bg{constructor(){xc(this,Ri),xc(this,Ti,Object.create(null))}get(t,e=null){if(e){const s=kc(this,Ri,Pi).call(this,t);return s.promise.then(()=>e(s.data)),null}const s=yc(this,Ti)[t];if(!s||s.data===wg)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return s.data}has(t){const e=yc(this,Ti)[t];return!!e&&e.data!==wg}delete(t){const e=yc(this,Ti)[t];return!(!e||e.data===wg)&&(delete yc(this,Ti)[t],!0)}resolve(t,e=null){const s=kc(this,Ri,Pi).call(this,t);s.data=e,s.resolve()}clear(){var t;for(const e in yc(this,Ti)){const{data:s}=yc(this,Ti)[e];null==(t=null==s?void 0:s.bitmap)||t.close()}Sc(this,Ti,Object.create(null))}*[Symbol.iterator](){for(const t in yc(this,Ti)){const{data:e}=yc(this,Ti)[t];e!==wg&&(yield[t,e])}}}Ti=new WeakMap,Ri=new WeakSet,Pi=function(t){var e;return(e=yc(this,Ti))[t]||(e[t]={...Promise.withResolvers(),data:wg})};const Ag=class t{constructor({textContentSource:e,container:s,viewport:i}){var n;if(xc(this,sn),xc(this,Di,Promise.withResolvers()),xc(this,Li,null),xc(this,Ni,!1),xc(this,Fi,!!(null==(Ii=globalThis.FontInspector)?void 0:Ii.enabled)),xc(this,Wi,null),xc(this,Oi,null),xc(this,Bi,0),xc(this,Hi,0),xc(this,$i,null),xc(this,zi,null),xc(this,ji,0),xc(this,Gi,0),xc(this,Vi,Object.create(null)),xc(this,Ui,[]),xc(this,qi,null),xc(this,Xi,[]),xc(this,Yi,new WeakMap),xc(this,Ki,null),e instanceof ReadableStream)Sc(this,qi,e);else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');Sc(this,qi,new ReadableStream({start(t){t.enqueue(e),t.close()}}))}Sc(this,Li,Sc(this,zi,s)),Sc(this,Gi,i.scale*su.pixelRatio),Sc(this,ji,i.rotation),Sc(this,Oi,{div:null,properties:null,ctx:null});const{pageWidth:a,pageHeight:r,pageX:o,pageY:l}=i.rawDims;Sc(this,Ki,[1,0,0,-1,-o,l+r]),Sc(this,Hi,a),Sc(this,Bi,r),kc(n=t,on,cn).call(n),eu(s,i),yc(this,Di).promise.finally(()=>{yc(t,en).delete(this),Sc(this,Oi,null),Sc(this,Vi,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=Md.platform;return md(this,"fontFamilyMap",new Map([["sans-serif",(t&&e?"Calibri, ":"")+"sans-serif"],["monospace",(t&&e?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{yc(this,$i).read().then(({value:t,done:s})=>{s?yc(this,Di).resolve():(yc(this,Wi)??Sc(this,Wi,t.lang),Object.assign(yc(this,Vi),t.styles),kc(this,sn,nn).call(this,t.items),e())},yc(this,Di).reject)};return Sc(this,$i,yc(this,qi).getReader()),yc(t,en).add(this),e(),yc(this,Di).promise}update({viewport:e,onBefore:s=null}){var i;const n=e.scale*su.pixelRatio,a=e.rotation;if(a!==yc(this,ji)&&(null==s||s(),Sc(this,ji,a),eu(yc(this,zi),{rotation:a})),n!==yc(this,Gi)){null==s||s(),Sc(this,Gi,n);const e={div:null,properties:null,ctx:kc(i=t,on,ln).call(i,yc(this,Wi))};for(const t of yc(this,Xi))e.properties=yc(this,Yi).get(t),e.div=t,kc(this,sn,rn).call(this,e)}}cancel(){var t;const e=new xd("TextLayer task cancelled.");null==(t=yc(this,$i))||t.cancel(e).catch(()=>{}),Sc(this,$i,null),yc(this,Di).reject(e)}get textDivs(){return yc(this,Xi)}get textContentItemsStr(){return yc(this,Ui)}static cleanup(){if(!(yc(this,en).size>0)){yc(this,Qi).clear();for(const{canvas:t}of yc(this,Ji).values())t.remove();yc(this,Ji).clear()}}};Di=new WeakMap,Li=new WeakMap,Ni=new WeakMap,Fi=new WeakMap,Wi=new WeakMap,Oi=new WeakMap,Bi=new WeakMap,Hi=new WeakMap,$i=new WeakMap,zi=new WeakMap,ji=new WeakMap,Gi=new WeakMap,Vi=new WeakMap,Ui=new WeakMap,qi=new WeakMap,Xi=new WeakMap,Yi=new WeakMap,Ki=new WeakMap,Qi=new WeakMap,Ji=new WeakMap,Zi=new WeakMap,tn=new WeakMap,en=new WeakMap,sn=new WeakSet,nn=function(t){var e,s;if(yc(this,Ni))return;(s=yc(this,Oi)).ctx??(s.ctx=kc(e=Ag,on,ln).call(e,yc(this,Wi)));const i=yc(this,Xi),n=yc(this,Ui);for(const a of t){if(i.length>1e5)return dd(),void Sc(this,Ni,!0);if(void 0!==a.str)n.push(a.str),kc(this,sn,an).call(this,a);else if("beginMarkedContentProps"===a.type||"beginMarkedContent"===a.type){const t=yc(this,Li);Sc(this,Li,document.createElement("span")),yc(this,Li).classList.add("markedContent"),a.id&&yc(this,Li).setAttribute("id",`${a.id}`),t.append(yc(this,Li))}else"endMarkedContent"===a.type&&Sc(this,Li,yc(this,Li).parentNode)}},an=function(t){var e;const s=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:""!==t.str,hasEOL:t.hasEOL,fontSize:0};yc(this,Xi).push(s);const n=Cd.transform(yc(this,Ki),t.transform);let a=Math.atan2(n[1],n[0]);const r=yc(this,Vi)[t.fontName];r.vertical&&(a+=Math.PI/2);let o=yc(this,Fi)&&r.fontSubstitution||r.fontFamily;o=Ag.fontFamilyMap.get(o)||o;const l=Math.hypot(n[2],n[3]),h=l*kc(e=Ag,on,dn).call(e,o,r,yc(this,Wi));let c,d;
10===a?(c=n[4],d=n[5]-h):(c=n[4]+h*Math.sin(a),d=n[5]-h*Math.cos(a));const u="calc(var(--total-scale-factor) *",p=s.style;yc(this,Li)===yc(this,zi)?(p.left=`${(100*c/yc(this,Hi)).toFixed(2)}%`,p.top=`${(100*d/yc(this,Bi)).toFixed(2)}%`):(p.left=`${u}${c.toFixed(2)}px)`,p.top=`${u}${d.toFixed(2)}px)`),p.fontSize=`${u}${(yc(Ag,tn)*l).toFixed(2)}px)`,p.fontFamily=o,i.fontSize=l,s.setAttribute("role","presentation"),s.textContent=t.str,s.dir=t.dir,yc(this,Fi)&&(s.dataset.fontName=r.fontSubstitutionLoadedName||t.fontName),0!==a&&(i.angle=a*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(" "!==t.str&&t.transform[0]!==t.transform[3]){const e=Math.abs(t.transform[0]),s=Math.abs(t.transform[3]);e!==s&&Math.max(e,s)/Math.min(e,s)>1.5&&(g=!0)}if(g&&(i.canvasWidth=r.vertical?t.height:t.width),yc(this,Yi).set(s,i),yc(this,Oi).div=s,yc(this,Oi).properties=i,kc(this,sn,rn).call(this,yc(this,Oi)),i.hasText&&yc(this,Li).append(s),i.hasEOL){const t=document.createElement("br");t.setAttribute("role","presentation"),yc(this,Li).append(t)}},rn=function(t){var e;const{div:s,properties:i,ctx:n}=t,{style:a}=s;let r="";if(yc(Ag,tn)>1&&(r=`scale(${1/yc(Ag,tn)})`),0!==i.canvasWidth&&i.hasText){const{fontFamily:t}=a,{canvasWidth:o,fontSize:l}=i;kc(e=Ag,on,hn).call(e,n,l*yc(this,Gi),t);const{width:h}=n.measureText(s.textContent);h>0&&(r=`scaleX(${o*yc(this,Gi)/h}) ${r}`)}0!==i.angle&&(r=`rotate(${i.angle}deg) ${r}`),r.length>0&&(a.transform=r)},on=new WeakSet,ln=function(t=null){let e=yc(this,Ji).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}),yc(this,Ji).set(t,e),yc(this,Zi).set(e,{size:0,family:""})}return e},hn=function(t,e,s){const i=yc(this,Zi).get(t);e===i.size&&s===i.family||(t.font=`${e}px ${s}`,i.size=e,i.family=s)},cn=function(){if(null!==yc(this,tn))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),Sc(this,tn,t.getBoundingClientRect().height),t.remove()},dn=function(t,e,s){const i=yc(this,Qi).get(t);if(i)return i;const n=kc(this,on,ln).call(this,s);n.canvas.width=n.canvas.height=30,kc(this,on,hn).call(this,n,30,t);const a=n.measureText(""),r=a.fontBoundingBoxAscent,o=Math.abs(a.fontBoundingBoxDescent);n.canvas.width=n.canvas.height=0;let l=.8;return r?l=r/(r+o):(Md.platform.isFirefox,e.ascent?l=e.ascent:e.descent&&(l=1+e.desce
vendor: 4,060 bytes, line 1
1nt)),yc(this,Qi).set(t,l),l},xc(Ag,on),xc(Ag,Qi,new Map),xc(Ag,Ji,new Map),xc(Ag,Zi,new WeakMap),xc(Ag,tn,null),xc(Ag,en,new Set);let _g=Ag;class yg{static textContent(t){const e=[],s={items:e,styles:Object.create(null)};return function t(s){var i;if(!s)return;let n=null;const a=s.name;if("#text"===a)n=s.value;else{if(!yg.shouldBuildText(a))return;(null==(i=null==s?void 0:s.attributes)?void 0:i.textContent)?n=s.attributes.textContent:s.value&&(n=s.value)}if(null!==n&&e.push({str:n}),s.children)for(const e of s.children)t(e)}(t),s}static shouldBuildText(t){return!("textarea"===t||"input"===t||"option"===t||"select"===t)}}function xg(t={}){"string"==typeof t||t instanceof URL?t={url:t}:(t instanceof ArrayBuffer||ArrayBuffer.isView(t))&&(t={data:t});const e=new kg,{docId:s}=e,i=t.url?function(t){if(t instanceof URL)return t.href;if("string"==typeof t){if(Ec)return t;const e=URL.parse(t,window.location);if(e)return e.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(t.url):null,n=t.data?function(t){if(Ec&&"undefined"!=typeof Buffer&&t instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength)return t;if("string"==typeof t)return kd(t);if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)||"object"==typeof t&&!isNaN(null==t?void 0:t.length))return new Uint8Array(t);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(t.data):null,a=t.httpHeaders||null,r=!0===t.withCredentials,o=t.password??null,l=t.range instanceof Mg?t.range:null,h=Number.isInteger(t.rangeChunkSize)&&t.rangeChunkSize>0?t.rangeChunkSize:65536;let c=t.worker instanceof Rg?t.worker:null;const d=t.verbosity,u="string"!=typeof t.docBaseUrl||zd(t.docBaseUrl)?null:t.docBaseUrl,p=Lu(t.cMapUrl),g=!1!==t.cMapPacked,f=t.CMapReaderFactory||(Ec?cp:tp),m=Lu(t.iccUrl),v=Lu(t.standardFontDataUrl),w=t.StandardFontDataFactory||(Ec?dp:np),b=Lu(t.wasmUrl),A=t.WasmFactory||(Ec?up:rp),_=!0!==t.stopAtErrors,y=Number.isInteger(t.maxImageSize)&&t.maxImageSize>-1?t.maxImageSize:-1,x=!1!==t.isEvalSupported,S="boolean"==typeof t.isOffscreenCanvasSupported?t.isOffscreenCanvasSupported:!Ec,k="boolean"==typeof t.isImageDecoderSupported?t.isImageDecoderSupported:!Ec&&(Md.platform.isFirefox||!globalThis.chrome),M=Number.isInteger(t.canvasMaxAreaInBytes)?t.canvasMaxAreaInBytes:-1,E="boolean"==typeof t.disableFontFace?t.disableFontFace:Ec,C=!0===t.fontExtraProperties,T=!0===t.enableXfa,R=t.ownerDocument||globalThis.document,P=!0===t.disableRange,I=!0===t.disableStream,D=!0===t.disableAutoFetch,L=!0===t.pdfBug,N=t.CanvasFactory||(Ec?hp:Ju),F=t.FilterFactory||(Ec?lp:sp),W=!0===t.enableHWA,O=!1!==t.useWasm,B=l?l.length:t.length??NaN,H="boolean"==typeof t.useSystemFonts?t.useSystemFonts:!Ec&&!E,$="boolean"==typeof t.useWorkerFetch?t.useWorkerFetch:!!(f===tp&&w===np&&A===rp&&p&&v&&b&&qd(p,document.baseURI)&&qd(v,document.baseURI)&&qd(b,document.baseURI));var z;z=d,Number.isInteger(z)&&(hd=z);const j={canvasFactory:new N({ownerDocument:R,enableHWA:W}),filterFactory:new F({docId:s,ownerDocument:R}),cMapReaderFactory:$?null:new f({baseUrl:p,isCompressed:g}),standardFontDataFactory:$?null:new w({baseUrl:v}),wasmFactory:$?null:new A({baseUrl:b})};c||(c=Rg.create({verbosity:d,port:Vp.workerPort}),e._worker=c);const G={docId:s,apiVersion:"5.4.54",data:n,password:o,disableAutoFetch:D,rangeChunkSize:h,length:B,docBaseUrl:u,enableXfa:T,evaluatorOptions:{maxImageSize:y,disableFontFace:E,ignoreErrors:_,isEvalSupported:x,isOffscreenCanvasSupported:S,isImageDecoderSupported:k,canvasMaxAreaInBytes:M,fontExtraProperties:C,useSystemFonts:H,useWasm:O,useWorkerFetch:$,cMapUrl:p,iccUrl:m,standardFontDataUrl:v,wasmUrl:b}},V={ownerDocument:R,pdfBug:L,styleElement:null,loadingParams:{disableAutoFetch:D,enableXfa:T}};return c.promise.then(function(){if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");
1const t=c.messageHandler.sendWithPromise("GetDocRequest",G,n?[n.buffer]:null);let o;if(l)o=new Kp(l,{disableRange:P,disableStream:I});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");const t=qd(i)?og:Ec?fg:dg;o=new t({url:i,length:B,httpHeaders:a,withCredentials:r,rangeChunkSize:h,disableRange:P,disableStream:I})}return t.then(t=>{if(e.destroyed)throw new Error("Loading aborted");if(c.destroyed)throw new Error("Worker was destroyed");const i=new Ku(s,t,c.port),n=new Pg(i,e,o,V,j,W);e._transport=n,i.send("Ready",null)})}).catch(e._capability.reject),e}const Sg=class t{constructor(){Ac(this,"_capability",Promise.withResolvers()),Ac(this,"_transport",null),Ac(this,"_worker",null),Ac(this,"docId","d"+Mc(t,un)._++),Ac(this,"destroyed",!1),Ac(this,"onPassword",null),Ac(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,s,i;this.destroyed=!0;try{(null==(t=this._worker)?void 0:t.port)&&(this._worker._pendingDestroy=!0),await(null==(e=this._transport)?void 0:e.destroy())}catch(n){throw(null==(s=this._worker)?void 0:s.port)&&delete this._worker._pendingDestroy,n}this._transport=null,null==(i=this._worker)||i.destroy(),this._worker=null}async getData(){return this._transport.getData()}};un=new WeakMap,xc(Sg,un,0);let kg=Sg;class Mg{constructor(t,e,s=!1,i=null){xc(this,pn,Promise.withResolvers()),xc(this,gn,[]),xc(this,fn,[]),xc(this,mn,[]),xc(this,vn,[]),this.length=t,this.initialData=e,this.progressiveDone=s,this.contentDispositionFilename=i}addRangeListener(t){yc(this,vn).push(t)}addProgressListener(t){yc(this,mn).push(t)}addProgressiveReadListener(t){yc(this,fn).push(t)}addProgressiveDoneListener(t){yc(this,gn).push(t)}onDataRange(t,e){for(const s of yc(this,vn))s(t,e)}onDataProgress(t,e){yc(this,pn).promise.then(()=>{for(const s of yc(this,mn))s(t,e)})}onDataProgressiveRead(t){yc(this,pn).promise.then(()=>{for(const e of yc(this,fn))e(t)})}onDataProgressiveDone(){yc(this,pn).promise.then(()=>{for(const t of yc(this,gn))t()})}transportReady(){yc(this,pn).resolve()}requestDataRange(t,e){ud("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}pn=new WeakMap,gn=new WeakMap,fn=new WeakMap,mn=new WeakMap,vn=new WeakMap;class Eg{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 md(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(t=!1){return this._transport.startCleanup(t||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(t){return this._transport.cachedPageNumber(t)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class Cg{constructor(t,e,s,i=!1){xc(this,bn),xc(this,wn,!1),this._pageIndex=t,this._pageInfo=e,this._transport=s,this._stats=i?new Ud:null,this._pdfBug=i,this.commonObjs=s.commonObjs,this.objs=new bg,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 Hd({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:s,offsetY:i,dontFlip:n})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}
1=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 md(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return(null==(t=this._transport._htmlForXfa)?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:s,intent:i="display",annotationMode:n=Oc.ENABLE,transform:a=null,background:r=null,optionalContentConfigPromise:o=null,annotationCanvasMap:l=null,pageColors:h=null,printAnnotationStorage:c=null,isEditing:d=!1}){var u,p;null==(u=this._stats)||u.time("Overall");const g=this._transport.getRenderingIntent(i,n,c,d),{renderingIntent:f,cacheKey:m}=g;Sc(this,wn,!1),o||(o=this._transport.getOptionalContentConfig(f));let v=this._intentStates.get(m);v||(v=Object.create(null),this._intentStates.set(m,v)),v.streamReaderCancelTimeout&&(clearTimeout(v.streamReaderCancelTimeout),v.streamReaderCancelTimeout=null);const w=!!(f&Ic);v.displayReadyCapability||(v.displayReadyCapability=Promise.withResolvers(),v.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(p=this._stats)||p.time("Page Request"),this._pumpOperatorList(g));const b=t=>{var e;v.renderTasks.delete(A),w&&Sc(this,wn,!0),kc(this,bn,An).call(this),t?(A.capability.reject(t),this._abortOperatorList({intentState:v,reason:t instanceof Error?t:new Error(t)})):A.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(null==(e=globalThis.Stats)?void 0:e.enabled)&&globalThis.Stats.add(this.pageNumber,this._stats))},A=new Lg({callback:b,params:{canvas:e,canvasContext:t,viewport:s,transform:a,background:r},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:l,operatorList:v.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!w,pdfBug:this._pdfBug,pageColors:h,enableHWA:this._transport.enableHWA});(v.renderTasks||(v.renderTasks=new Set)).add(A);const _=A.task;return Promise.all([v.displayReadyCapability.promise,o]).then(([t,e])=>{var s;if(this.destroyed)b();else{if(null==(s=this._stats)||s.time("Rendering"),!(e.renderingIntent&f))throw new Error("Mu
1st use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");A.initializeGraphics({transparency:t,optionalContentConfig:e}),A.operatorListChanged()}}).catch(b),_}getOperatorList({intent:t="display",annotationMode:e=Oc.ENABLE,printAnnotationStorage:s=null,isEditing:i=!1}={}){var n;const a=this._transport.getRenderingIntent(t,e,s,i,!0);let r,o=this._intentStates.get(a.cacheKey);return o||(o=Object.create(null),this._intentStates.set(a.cacheKey,o)),o.opListReadCapability||(r=Object.create(null),r.operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(r))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||(o.renderTasks=new Set)).add(r),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},null==(n=this._stats)||n.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:!0===t,disableNormalization:!0===e},{highWaterMark:100,size:t=>t.items.length})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(t=>yg.textContent(t));const e=this.streamTextContent(t);return new Promise(function(t,s){const i=e.getReader(),n={items:[],styles:Object.create(null),lang:null};!function e(){i.read().then(function({value:s,done:i}){i?t(n):(n.lang??(n.lang=s.lang),Object.assign(n.styles,s.styles),n.items.push(...s.items),e())},s)}()})}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(),Sc(this,wn,!1),Promise.all(t)}cleanup(t=!1){Sc(this,wn,!0);const e=kc(this,bn,An).call(this);return t&&e&&this._stats&&(this._stats=new Ud),e}_startRenderPage(t,e){var s,i;const n=this._intentStates.get(e);n&&(null==(s=this._stats)||s.timeEnd("Page Request"),null==(i=n.displayReadyCapability)||i.resolve(t))}_renderPageChunk(t,e){for(let s=0,i=t.length;s<i;s++)e.operatorList.fnArray.push(t.fnArray[s]),e.operatorList.argsArray.push(t.argsArray[s]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const s of e.renderTasks)s.operatorListChanged();t.lastChunk&&kc(this,bn,An).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:s,modifiedIds:i}){const{map:n,transfer:a}=s,r=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:n,modifiedIds:i},a).getReader(),o=this._intentStates.get(e);o.streamReader=r;const l=()=>{r.read().then(({value:t,done:e})=>{e?o.streamReader=null:this._transport.destroyed||(this._renderPageChunk(t,o),l())},t=>{if(o.streamReader=null,!this._transport.destroyed){if(o.operatorList){o.operatorList.lastChunk=!0;for(const t of o.renderTasks)t.operatorListChanged();kc(this,bn,An).call(this)}if(o.displayReadyCapability)o.displayReadyCapability.reject(t);else{if(!o.opListReadCapability)throw t;o.opListReadCapability.reject(t)}}})};l()}_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 $d){let s=100;return e.extraDelay>0&&e.extraDelay<1e3&&(s+=e.extraDelay),void(t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},s))}}if(t.streamReader.cancel(new xd(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[e,s]of this._intentStates)if(s===t){this._intentStates.delete(e);break}this.cleanup()}}}get stats(){return this._stats}}wn=new WeakMap,bn=new WeakSet,An=function(){if(!yc(this,wn)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),Sc(this,wn,!1),!0};const Tg=class t{constructor({name:e=null,port:s=null,verbosity:i=cd()}={}){if(xc(this,Cn),xc(this,_n,Promise.withResolvers()),xc(this,yn,null),xc(this,xn,null),xc(this,Sn,null),this.name=e,this.destroyed=!1,this.verbosity=i,s){if(yc(t,En).has(s))throw new Error("Cannot use more than one PDFWorker per port.");yc(t,En).set(s,this),kc(this,Cn,Rn).call(this,s)}else kc(this,Cn,Pn).call(this)}get promise(){return yc(this,_n).promise}get port(){return yc(this,xn)}get messageHandler(){return yc(this,yn)}destroy(){var e,s;this.destroyed=!0,null==(e=yc(this,Sn))||e.terminate(),Sc(this,Sn,null),yc(t,En).delete(yc(this,xn)),Sc(this,xn,null),null==(s=yc(this,yn))||s.destroy(),Sc(this,yn,null)}static create(e){const s=yc(this,En).get(null==e?void 0:e.port);
1if(s){if(s._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return s}return new t(e)}static get workerSrc(){if(Vp.workerSrc)return Vp.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return md(this,"_setupFakeWorkerGlobal",(async()=>{if(yc(this,Dn,Ln))return yc(this,Dn,Ln);return(await import(this.workerSrc)).WorkerMessageHandler})())}};_n=new WeakMap,yn=new WeakMap,xn=new WeakMap,Sn=new WeakMap,kn=new WeakMap,Mn=new WeakMap,En=new WeakMap,Cn=new WeakSet,Tn=function(){yc(this,_n).resolve(),yc(this,yn).send("configure",{verbosity:this.verbosity})},Rn=function(t){Sc(this,xn,t),Sc(this,yn,new Ku("main","worker",t)),yc(this,yn).on("ready",()=>{}),kc(this,Cn,Tn).call(this)},Pn=function(){if(yc(Tg,Mn)||yc(Tg,Dn,Ln))return void kc(this,Cn,In).call(this);let{workerSrc:t}=Tg;try{Tg._isSameOrigin(window.location,t)||(t=Tg._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),s=new Ku("main","worker",e),i=()=>{n.abort(),s.destroy(),e.terminate(),this.destroyed?yc(this,_n).reject(new Error("Worker was destroyed")):kc(this,Cn,In).call(this)},n=new AbortController;e.addEventListener("error",()=>{yc(this,Sn)||i()},{signal:n.signal}),s.on("test",t=>{n.abort(),!this.destroyed&&t?(Sc(this,yn,s),Sc(this,xn,e),Sc(this,Sn,e),kc(this,Cn,Tn).call(this)):i()}),s.on("ready",t=>{if(n.abort(),this.destroyed)i();else try{a()}catch{kc(this,Cn,In).call(this)}});const a=()=>{const t=new Uint8Array;s.send("test",t,[t.buffer])};return void a()}catch{}kc(this,Cn,In).call(this)},In=function(){yc(Tg,Mn)||Sc(Tg,Mn,!0),Tg._setupFakeWorkerGlobal.then(t=>{if(this.destroyed)return void yc(this,_n).reject(new Error("Worker was destroyed"));const e=new Wu;Sc(this,xn,e);const s="fake"+Mc(Tg,kn)._++,i=new Ku(s+"_worker",s,e);t.setup(i,e),Sc(this,yn,new Ku(s,s+"_worker",e)),kc(this,Cn,Tn).call(this)}).catch(t=>{yc(this,_n).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},Dn=new WeakSet,Ln=function(){var t;try{return(null==(t=globalThis.pdfjsWorker)?void 0:t.WorkerMessageHandler)||null}catch{return null}},xc(Tg,Dn),xc(Tg,kn,0),xc(Tg,Mn,!1),xc(Tg,En,new WeakMap),Ec&&(Sc(Tg,Mn,!0),Vp.workerSrc||(Vp.workerSrc="./pdf.worker.mjs")),Tg._isSameOrigin=(t,e)=>{const s=URL.parse(t);if(!(null==s?void 0:s.origin)||"null"===s.origin)return!1;const i=new URL(e,s);return s.origin===i.origin},Tg._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},Tg.fromPort=t=>{if(!(null==t?void 0:t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return Tg.create(t)};let Rg=Tg;class Pg{constructor(t,e,s,i,n,a){xc(this,Hn),xc(this,Nn,new Map),xc(this,Fn,new Map),xc(this,Wn,new Map),xc(this,On,new Map),xc(this,Bn,null),this.messageHandler=t,this.loadingTask=e,this.commonObjs=new bg,this.fontLoader=new Iu({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.wasmFactory=n.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=s,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=a,this.setupMessageHandler()}get annotationStorage(){return md(this,"annotationStorage",new Ru)}getRenderingIntent(t,e=Oc.ENABLE,s=null,i=!1,n=!1){let a=Pc,r=Tu;switch(t){case"any":a=Rc;break;case"display":break;case"print":a=Ic}const o=a&Ic&&s instanceof Pu?s:this.annotationStorage;switch(e){case Oc.DISABLE:a+=Nc;break;case Oc.ENABLE:break;case Oc.ENABLE_FORMS:a+=Dc;break;case Oc.ENABLE_STORAGE:a+=Lc,r=o.serializable}i&&(a+=Fc),n&&(a+=Wc);const{ids:l,hash:h}=o.modifiedIds;return{renderingIntent:a,cacheKey:[a,r.hash,h].join("_"),annotationStorageSerializable:r,modifiedIds:l}}destroy(){var t;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),null==(t=yc(this,Bn))||t.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const i of yc(this,Fn).values())e.push(i._destroy());yc(this,Fn).clear(),yc(this,Wn).clear(),yc(this,On).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();
1const s=this.messageHandler.sendWithPromise("Terminate",null);return e.push(s),Promise.all(e).then(()=>{var t,e;this.commonObjs.clear(),this.fontLoader.clear(),yc(this,Nn).clear(),this.filterFactory.destroy(),_g.cleanup(),null==(t=this._networkStream)||t.cancelAllRequests(new xd("Worker was terminated.")),null==(e=this.messageHandler)||e.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(t,e)=>{pd(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=t=>{this._lastProgress={loaded:t.loaded,total:t.total}},e.onPull=()=>{this._fullReader.read().then(function({value:t,done:s}){s?e.close():(pd(t instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{this._fullReader.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}}),t.on("ReaderHeadersReady",async t=>{var s;await this._fullReader.headersReady;const{isStreamingSupported:i,isRangeSupported:n,contentLength:a}=this._fullReader;return i&&n||(this._lastProgress&&(null==(s=e.onProgress)||s.call(e,this._lastProgress)),this._fullReader.onProgress=t=>{var s;null==(s=e.onProgress)||s.call(e,{loaded:t.loaded,total:t.total})}),{isStreamingSupported:i,isRangeSupported:n,contentLength:a}}),t.on("GetRangeReader",(t,e)=>{pd(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const s=this._networkStream.getRangeReader(t.begin,t.end);s?(e.onPull=()=>{s.read().then(function({value:t,done:s}){s?e.close():(pd(t instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),e.enqueue(new Uint8Array(t),1,[t]))}).catch(t=>{e.error(t)})},e.onCancel=t=>{s.cancel(t),e.ready.catch(t=>{if(!this.destroyed)throw t})}):e.close()}),t.on("GetDoc",({pdfInfo:t})=>{this._numPages=t.numPages,this._htmlForXfa=t.htmlForXfa,delete t.htmlForXfa,e._capability.resolve(new Eg(t,this))}),t.on("DocException",t=>{e._capability.reject(Yu(t))}),t.on("PasswordRequest",t=>{Sc(this,Bn,Promise.withResolvers());try{if(!e.onPassword)throw Yu(t);const s=t=>{t instanceof Error?yc(this,Bn).reject(t):yc(this,Bn).resolve({password:t})};e.onPassword(s,t.code)}catch(s){yc(this,Bn).reject(s)}return yc(this,Bn).promise}),t.on("DataLoaded",t=>{var s;null==(s=e.onProgress)||s.call(e,{loaded:t.length,total:t.length}),this.downloadInfoCapability.resolve(t)}),t.on("StartRenderPage",t=>{if(this.destroyed)return;yc(this,Fn).get(t.pageIndex)._startRenderPage(t.transparency,t.cacheKey)}),t.on("commonobj",([e,s,i])=>{var n;if(this.destroyed)return null;if(this.commonObjs.has(e))return null;switch(s){case"Font":if("error"in i){const t=i.error;this.commonObjs.resolve(e,t);break}const a=this._params.pdfBug&&(null==(n=globalThis.FontInspector)?void 0:n.enabled)?(t,e)=>globalThis.FontInspector.fontAdded(t,e):null,r=new Du(i,a);this.fontLoader.bind(r).catch(()=>t.sendWithPromise("FontFallback",{id:e})).finally(()=>
1{!r.fontExtraProperties&&r.data&&(r.data=null),this.commonObjs.resolve(e,r)});break;case"CopyLocalImage":const{imageRef:o}=i;pd(o,"The imageRef must be defined.");for(const t of yc(this,Fn).values())for(const[,s]of t.objs)if((null==s?void 0:s.ref)===o)return s.dataLen?(this.commonObjs.resolve(e,structuredClone(s)),s.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(e,i);break;default:throw new Error(`Got unknown common object type ${s}`)}return null}),t.on("obj",([t,e,s,i])=>{var n;if(this.destroyed)return;const a=yc(this,Fn).get(e);if(!a.objs.has(t))if(0!==a._intentStates.size)switch(s){case"Image":case"Pattern":a.objs.resolve(t,i);break;default:throw new Error(`Got unknown object type ${s}`)}else null==(n=null==i?void 0:i.bitmap)||n.close()}),t.on("DocProgress",t=>{var s;this.destroyed||null==(s=e.onProgress)||s.call(e,{loaded:t.loaded,total:t.total})}),t.on("FetchBinaryData",async t=>{if(this.destroyed)throw new Error("Worker was destroyed.");const e=this[t.type];if(!e)throw new Error(`${t.type} not initialized, see the \`useWorkerFetch\` parameter.`);return e.fetch(t)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var t;this.annotationStorage.size;const{map:e,transfer:s}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:(null==(t=this._fullReader)?void 0:t.filename)??null},s).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=yc(this,Wn).get(e);if(s)return s;const i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(s=>{if(this.destroyed)throw new Error("Transport destroyed");s.refStr&&yc(this,On).set(s.refStr,t);const i=new Cg(e,s,this,this._params.pdfBug);return yc(this,Fn).set(e,i),i});return yc(this,Wn).set(e,i),i}getPageIndex(t){return Nu(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 kc(this,Hn,$n).call(this,"GetFieldObjects")}hasJSActions(){return kc(this,Hn,$n).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return"string"!=typeof t?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return kc(this,Hn,$n).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 kc(this,Hn,$n).call(this,"GetOptionalContentConfig").then(e=>new Yp(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=yc(this,Nn).get(t);if(e)return e;const s=this.messageHandler.sendWithPromise(t,null).then(t=>{var e,s;return{info:t[0],metadata:t[1]?new Up(t[1]):null,contentDispositionFilename:(null==(e=this._fullReader)?void 0:e.filename)??null,contentLength:(null==(s=this._fullReader)?void 0:s.contentLength)??null}});return yc(this,Nn).set(t,s),s}
1getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const t of yc(this,Fn).values()){if(!t.cleanup())throw new Error(`startCleanup: Page ${t.pageNumber} is currently rendering.`)}this.commonObjs.clear(),t||this.fontLoader.clear(),yc(this,Nn).clear(),this.filterFactory.destroy(!0),_g.cleanup()}}cachedPageNumber(t){if(!Nu(t))return null;const e=0===t.gen?`${t.num}R`:`${t.num}R${t.gen}`;return yc(this,On).get(e)??null}}Nn=new WeakMap,Fn=new WeakMap,Wn=new WeakMap,On=new WeakMap,Bn=new WeakMap,Hn=new WeakSet,$n=function(t,e=null){const s=yc(this,Nn).get(t);if(s)return s;const i=this.messageHandler.sendWithPromise(t,e);return yc(this,Nn).set(t,i),i};class Ig{constructor(t){xc(this,zn,null),Ac(this,"onContinue",null),Ac(this,"onError",null),Sc(this,zn,t)}get promise(){return yc(this,zn).capability.promise}cancel(t=0){yc(this,zn).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=yc(this,zn).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=yc(this,zn);return t.form||t.canvas&&(null==e?void 0:e.size)>0}}zn=new WeakMap;const Dg=class t{constructor({callback:t,params:e,objs:s,commonObjs:i,annotationCanvasMap:n,operatorList:a,pageIndex:r,canvasFactory:o,filterFactory:l,useRequestAnimationFrame:h=!1,pdfBug:c=!1,pageColors:d=null,enableHWA:u=!1}){xc(this,jn,null),this.callback=t,this.params=e,this.objs=s,this.commonObjs=i,this.annotationCanvasMap=n,this.operatorListIdx=null,this.operatorList=a,this._pageIndex=r,this.canvasFactory=o,this.filterFactory=l,this._pdfBug=c,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===h&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new Ig(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=e.canvas,this._canvasContext=e.canvas?null:e.canvasContext,this._enableHWA=u}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:e=!1,optionalContentConfig:s}){var i,n;if(this.cancelled)return;if(this._canvas){if(yc(t,Gn).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.");yc(t,Gn).add(this._canvas)}this._pdfBug&&(null==(i=globalThis.StepperManager)?void 0:i.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:a,transform:r,background:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Gp(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:s},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:
1a,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,null==(n=this.graphicsReadyCallback)||n.call(this)}cancel(e=null,s=0){var i,n,a;this.running=!1,this.cancelled=!0,null==(i=this.gfx)||i.endDrawing(),yc(this,jn)&&(window.cancelAnimationFrame(yc(this,jn)),Sc(this,jn,null)),yc(t,Gn).delete(this._canvas),e||(e=new $d(`Rendering cancelled, page ${this._pageIndex+1}`,s)),this.callback(e),null==(a=(n=this.task).onError)||a.call(n,e)}operatorListChanged(){var t;this.graphicsReady?(null==(t=this.stepper)||t.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound)}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?Sc(this,jn,window.requestAnimationFrame(()=>{Sc(this,jn,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(),yc(t,Gn).delete(this._canvas),this.callback())))}};jn=new WeakMap,Gn=new WeakMap,xc(Dg,Gn,new WeakSet);let Lg=Dg;const Ng="5.4.54",Fg="295fb3ec4",Wg=class t{constructor({editor:e=null,uiManager:s=null}){var i,n;xc(this,sa),xc(this,Vn,null),xc(this,Un,null),xc(this,qn),xc(this,Xn,null),xc(this,Yn,!1),xc(this,Kn,!1),xc(this,Qn,null),xc(this,Jn),xc(this,Zn,null),xc(this,ta,null),e?(Sc(this,Kn,!1),Sc(this,Qn,e)):Sc(this,Kn,!0),Sc(this,ta,(null==e?void 0:e._uiManager)||s),Sc(this,Jn,yc(this,ta)._eventBus),Sc(this,qn,(null==(i=null==e?void 0:e.color)?void 0:i.toUpperCase())||(null==(n=yc(this,ta))?void 0:n.highlightColors.values().next().value)||"#FFFF98"),yc(t,ea)||Sc(t,ea,Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"}))}static get _keyboardManager(){return md(this,"_keyboardManager",new uu([[["Escape","mac+Escape"],t.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],t.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],t.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],t.prototype._moveToPrevious],[["Home","mac+Home"],t.prototype._moveToBeginning],[["End","mac+End"],t.prototype._moveToEnd]]))}renderButton(){const t=Sc(this,Vn,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",yc(this,Qn)&&(t.ariaControls=`${yc(this,Qn).id}_colorpicker_dropdown`);const e=yc(this,ta)._signal;t.addEventListener("click",kc(this,sa,ra).bind(this),{signal:e}),t.addEventListener("keydown",kc(this,sa,aa).bind(this),{signal:e});const s=Sc(this,Un,document.createElement("span"));return s.className="swatch",s.ariaHidden="true",s.style.backgroundColor=yc(this,qn),t.append(s),t}renderMainDropdown(){const t=Sc(this,Xn,kc(this,sa,ia).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===yc(this,Vn))return void kc(this,sa,ra).call(this,t);const e=t.target.getAttribute("data-color");e&&kc(this,sa,na).call(this,e,t)}_moveToNext(t){var e,s;yc(this,sa,la)?t.target!==yc(this,Vn)?null==(s=t.target.nextSibling)||s.focus():null==(e=yc(this,Xn).firstChild)||e.focus():kc(this,sa,ra).call(this,t)}_moveToPrevious(t){var e,s;t.target!==(null==(e=yc(this,Xn))?void 0:e.firstChild)&&t.target!==yc(this,Vn)?(yc(this,sa,la)||kc(this,sa,ra).call(this,t),null==(s=t.target.previousSibling)||s.focus()):yc(this,sa,la)&&this._hideDropdownFromKeyboard()}_moveToBeginning(t){var e;yc(this,sa,la)?null==(e=yc(this,Xn).firstChild)||e.focus():kc(this,sa,ra).call(this,t)}_moveToEnd(t){var e;yc(this,sa,la)?null==(e=yc(this,Xn).lastChild)||e.focus():kc(this,sa,ra).call(this,t)}hideDropdown(){var t,e;null==(t=yc(this,Xn))||t.classList.add("hidden"),yc(this,Vn).ariaExpanded="false",null==(e=yc(this,Zn))||e.abort(),Sc(this,Zn,null)}_hideDropdownFromKeyboard(){var t;yc(this,Kn)||(yc(this,sa,la)?(this.hideDropdown(),yc(this,Vn).focus({preventScroll:!0,focusVisible:yc(this,Yn)})):null==(t=yc(this,Qn))||t.unselect())}updateColor(t){if(yc(this,Un)&&(yc(this,Un).style.backgroundColor=t),!yc(this,Xn))return;const e=yc(this,ta).highlightColors.values();for(const s of yc(this,Xn).children)s.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;null==(t=yc(this,Vn))||t.remove(),Sc(this,Vn,null),Sc(this,Un,null),null==(e=yc(this,Xn))||e.remove(),Sc(this,Xn,null)}};Vn=new WeakMap,Un=new WeakMap,qn=new WeakMap,Xn=new WeakMap,Yn=new WeakMap,Kn=new WeakMap,Qn=new WeakMap,Jn=new WeakMap,Zn=new WeakMap,ta=new WeakMap,ea=new WeakMap,sa=new WeakSet,ia=function(){const t=document.createElement("div"),e=yc(this,ta)._signal;t.addEventListener("contextmenu",Xd,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),yc(this,Qn)&&(t.id=`${yc(this,Qn).id}_colorpicker_dropdown`);for(const[s,i]of yc(this,ta).highlightColors){const n=document.createElement("button");n.tabIndex="0",n.role="option",n.setAttribute("data-color",i),n.title=s,n.setAttribute("data-l10n-id",yc(Wg,ea)[s]);const a=document.createElement("span");n.append(a),a.className="swatch",a.style.backgroundColor=i,n.ariaSelected=i===yc(this,qn),n.addEventListener("click",kc(this,sa,na).bind(this,i),{signal:e}),t.append(n)}return t.addEventListener("keydown",kc(this,sa,aa).bind(this),{signal:e}),t},na=function(t,e){e.stopPropagation(),yc(this,Jn).dispatch("switchannotationeditorparams",{source:this,type:$c.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},aa=function(t){Wg._keyboardManager.exec(this,t)},ra=function(t){if(yc(this,sa,la))return void this.hideDropdown();if(Sc(this,Yn,0===t.detail),yc(this,Zn)||(Sc(this,Zn,new AbortController),window.addEventListener("pointerdown",kc(this,sa,oa).bind(this),{signal:yc(this,ta).combinedSignal(yc(this,Zn))})),yc(this,Vn).ariaExpanded="true",yc(this,Xn))return void yc(this,Xn).classList.remove("hidden");const e=Sc(this,Xn,kc(this,sa,ia).call(this));yc(this,Vn).append(e)},oa=function(t){var e;(null==(e=yc(this,Xn))?void 0:e.contains(t.target))||this.hideDropdown()}
vendor: 6,479 bytes, line 1
1,la=function(){return yc(this,Xn)&&!yc(this,Xn).classList.contains("hidden")},xc(Wg,ea,null);let Og=Wg;const Bg=class t{constructor(e){xc(this,ha,null),xc(this,ca,null),xc(this,da,null),Sc(this,ca,e),Sc(this,da,e._uiManager),yc(t,ua)||Sc(t,ua,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(yc(this,ha))return yc(this,ha);const{editorType:e,colorType:s,colorValue:i}=yc(this,ca),n=Sc(this,ha,document.createElement("input"));return n.type="color",n.value=i||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",yc(t,ua)[e]),n.addEventListener("input",()=>{yc(this,da).updateParams(s,n.value)},{signal:yc(this,da)._signal}),n}update(t){yc(this,ha)&&(yc(this,ha).value=t)}destroy(){var t;null==(t=yc(this,ha))||t.remove(),Sc(this,ha,null)}hideDropdown(){}};ha=new WeakMap,ca=new WeakMap,da=new WeakMap,ua=new WeakMap,xc(Bg,ua,null);let Hg=Bg;function $g(t){return Math.floor(255*Math.max(0,Math.min(1,t))).toString(16).padStart(2,"0")}function zg(t){return Math.max(0,Math.min(255,255*t))}class jg{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=zg(t),t,t]}static G_HTML([t]){const e=$g(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(zg)}static RGB_HTML(t){return`#${t.map($g).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[zg(1-Math.min(1,t+i)),zg(1-Math.min(1,s+i)),zg(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;return["CMYK",i,n,a,Math.min(i,n,a)]}}class Gg{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("string"!=typeof t)throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){ud("Abstract method `_createSVG` called.")}}class Vg extends Gg{_createSVG(t){return document.createElementNS(Fd,t)}}class Ug{static setupStorage(t,e,s,i,n){const a=i.getValue(e,{value:null});switch(s.name){case"textarea":if(null!==a.value&&(t.textContent=a.value),"print"===n)break;t.addEventListener("input",t=>{i.setValue(e,{value:t.target.value})});break;case"input":if("radio"===s.attributes.type||"checkbox"===s.attributes.type){if(a.value===s.attributes.xfaOn?t.setAttribute("checked",!0):a.value===s.attributes.xfaOff&&t.removeAttribute("checked"),"print"===n)break;t.addEventListener("change",t=>{i.setValue(e,{value:t.target.checked?t.target.getAttribute("xfaOn"):t.target.getAttribute("xfaOff")})})}else{if(null!==a.value&&t.setAttribute("value",a.value),"print"===n)break;t.addEventListener("input",t=>{i.setValue(e,{value:t.target.value})})}break;case"select":if(null!==a.value){t.setAttribute("value",a.value);for(const t of s.children)t.attributes.value===a.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected}t.addEventListener("input",t=>{const s=t.target.options,n=-1===s.selectedIndex?"":s[s.selectedIndex].value;i.setValue(e,{value:n})})}}static setAttributes({html:t,element:e,storage:s=null,intent:i,linkService:n}){const{attributes:a}=e,r=t instanceof HTMLAnchorElement;"radio"===a.type&&(a.name=`${a.name}-${i}`);for(const[o,l]of Object.entries(a))if(null!=l)switch(o){case"class":l.length&&t.setAttribute(o,l.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",l);break;case"style":Object.assign(t.style,l);break;case"textContent":t.textContent=l;break;default:(!r||"href"!==o&&"newWindow"!==o)&&t.setAttribute(o,l)}r&&n.addLinkAttributes(t,a.href,a.newWindow),s&&a.dataId&&this.setupStorage(t,a.dataId,e,s)}static render(t){var e,s;const i=t.annotationStorage,n=t.linkService,a=t.xfaHtml,r=t.intent||"display",o=document.createElement(a.name);a.attributes&&this.setAttributes({html:o,element:a,intent:r,linkService:n});const l="richText"!==r,h=t.div;if(h.append(o),t.viewport){const e=`matrix(${t.viewport.transform.join(",")})`;h.style.transform=e}l&&h.setAttribute("class","xfaLayer xfaFont");const c=[];if(0===a.children.length){if(a.value){const t=document.createTextNode(a.value);o.append(t),l&&yg.shouldBuildText(a.name)&&c.push(t)}return{textDivs:c}}const d=[[a,-1,o]];for(;d.length>0;){const[t,a,o]=d.at(-1);if(a+1===t.children.length){d.pop();continue}const h=t.children[++d.at(-1)[1]];if(null===h)continue;const{name:u}=h;if("#text"===u){const t=document.createTextNode(h.value);c.push(t),o.append(t);continue}const p=(null==(e=null==h?void 0:h.attributes)?void 0:e.xmlns)?document.createElementNS(h.attributes.xmlns,u):document.createElement(u);if(o.append(p),h.attributes&&this.setAttributes({html:p,element:h,storage:i,intent:r,linkService:n}),(null==(s=h.children)?void 0:s.length)>0)d.push([h,-1,p]);else if(h.value){const t=document.createTextNode(h.value);l&&yg.shouldBuildText(u)&&c.push(t),p.append(t)}}for(const u of h.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))u.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 qg=new WeakSet,Xg=60*(new Date).getTimezoneOffset()*1e3;class Yg{static create(t){switch(t.data.annotationType){case Kc.LINK:return new Qg(t);case Kc.TEXT:return new Jg(t);case Kc.WIDGET:switch(t.data.fieldType){case"Tx":return new tf(t);case"Btn":return t.data.radioButton?new nf(t):t.data.checkBox?new sf(t):new af(t);case"Ch":return new rf(t);case"Sig":return new ef(t)}return new Zg(t);case Kc.POPUP:return new of(t);case Kc.FREETEXT:return new hf(t);case Kc.LINE:return new cf(t);case Kc.SQUARE:return new df(t);case Kc.CIRCLE:return new uf(t);case Kc.POLYLINE:return new pf(t);case Kc.CARET:return new ff(t);case Kc.INK:return new mf(t);case Kc.POLYGON:return new gf(t);case Kc.HIGHLIGHT:return new vf(t);case Kc.UNDERLINE:return new wf(t);case Kc.SQUIGGLY:return new bf(t);case Kc.STRIKEOUT:return new Af(t);case Kc.STAMP:return new _f(t);
1case Kc.FILEATTACHMENT:return new yf(t);default:return new Kg(t)}}}pa=new WeakMap,ga=new WeakMap,fa=new WeakMap,ma=new WeakSet,va=function(t){const{container:{style:e},data:{rect:s,rotation:i},parent:{viewport:{rawDims:{pageWidth:n,pageHeight:a,pageX:r,pageY:o}}}}=this;null==s||s.splice(0,4,...t),e.left=100*(t[0]-r)/n+"%",e.top=100*(a-t[3]+o)/a+"%",0===i?(e.width=100*(t[2]-t[0])/n+"%",e.height=100*(t[3]-t[1])/a+"%"):this.setRotation(i)};let Kg=class t{constructor(t,{isRenderable:e=!1,ignoreBorder:s=!1,createQuadrilaterals:i=!1}={}){xc(this,ma),xc(this,pa,null),xc(this,ga,!1),xc(this,fa,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({contentsObj:t,richText:e}){return!(!(null==t?void 0:t.str)&&!(null==e?void 0:e.str))}get _isEditable(){return this.data.isEditable}get hasPopupData(){return t._hasPopupData(this.data)}updateEdited(t){var e;if(!this.container)return;t.rect&&(yc(this,pa)||Sc(this,pa,{rect:this.data.rect.slice(0)}));const{rect:s,popup:i}=t;s&&kc(this,ma,va).call(this,s);let n=(null==(e=yc(this,fa))?void 0:e.popup)||this.popup;!n&&(null==i?void 0:i.text)&&(this._createPopup(i),n=yc(this,fa).popup),n&&(n.updateEdited(t),(null==i?void 0:i.deleted)&&(n.remove(),Sc(this,fa,null),this.popup=null))}resetEdited(){var t;yc(this,pa)&&(kc(this,ma,va).call(this,yc(this,pa).rect),null==(t=yc(this,fa))||t.popup.resetEdited(),Sc(this,pa,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 Zg||this instanceof Qg||(n.tabIndex=0);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 of){const{rotation:t}=e;return e.hasOwnCanvas||0===t||this.setRotation(t,n),n}const{width:r,height:o}=this;if(!t&&e.borderStyle.width>0){a.borderWidth=`${e.borderStyle.width}px`;const t=e.borderStyle.horizontalCornerRadius,s=e.borderStyle.verticalCornerRadius;if(t>0||s>0){const e=`calc(${t}px * var(--total-scale-factor)) / calc(${s}px * var(--total-scale-factor))`;a.borderRadius=e}else if(this instanceof nf){const t=`calc(${r}px * var(--total-scale-factor)) / calc(${o}px * var(--total-scale-factor))`;a.borderRadius=t}switch(e.borderStyle.style){case Qc:a.borderStyle="solid";break;case Jc:a.borderStyle="dashed";break;case Zc:case td:break;case ed:a.borderBottomStyle="solid"}const i=e.borderColor||null;i?(Sc(this,ga,!0),a.borderColor=Cd.makeHexColor(0|i[0],0|i[1],0|i[2])):a.borderWidth=0}const l=Cd.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:h,pageHeight:c,pageX:d,pageY:u}=i.rawDims;a.left=100*(l[0]-d)/h+"%",a.top=100*(l[1]-u)/c+"%";const{rotation:p}=e;return e.hasOwnCanvas||0===p?(a.width=100*r/h+"%",a.height=100*o/c+"%"):this.setRotation(p,n),n}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:s,pageHeight:i}=this.parent.viewport.rawDims;let{width:n,height:a}=this;t%180!=0&&([n,a]=[a,n]),e.style.width=100*n/s+"%",e.style.height=100*a/i+"%",e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(t,e,s)=>{const i=s.detail[t],n=i[0],a=i.slice(1);s.target.style[e]=jg[`${n}_HTML`](a),this.annotationStorage.setValue(this.data.id,{[e]:jg[`${n}_rgb`](a)})};return md(this,"_commonActions",{display:t=>{const{display:e}=t.detail,s=e%2==1;this.container.style.visibility=s?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:s,noPrint:1===e||2===e})},print:t=>{this.annotationStorage.setValue(this.data.id,{noPrint:!t.detail.print})},hidden:t=>{const{hidden:e}=t.detail;this.container.style.visibility=e?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:e,noView:e})},focus:t=>{setTimeout(()=>
1t.target.focus({preventScroll:!1}),0)},userName:t=>{t.target.title=t.detail.userName},readonly:t=>{t.target.disabled=t.detail.readonly},required:t=>{this._setRequired(t.target,t.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:t=>{const e=t.detail.rotation;this.setRotation(e),this.annotationStorage.setValue(this.data.id,{rotation:e})}})}_dispatchEventFromSandbox(t,e){const s=this._commonActions;for(const i of Object.keys(e.detail)){const n=t[i]||s[i];null==n||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){a({detail:{[i]:n},target:t}),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(t=>Math.fround(t));if(8===t.length){const[a,r,o,l]=t.subarray(2,6);if(i===a&&n===r&&e===o&&s===l)return}const{style:a}=this.container;let r;if(yc(this,ga)){const{borderColor:t,borderWidth:e}=a;a.borderWidth=0,r=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${t}" stroke-width="${e}">`],this.container.classList.add("hasBorder")}const o=i-e,l=n-s,{svgFactory:h}=this,c=h.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0),c.role="none";const d=h.createElement("defs");c.append(d);const u=h.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let g=2,f=t.length;g<f;g+=8){const s=t[g],i=t[g+1],a=t[g+2],c=t[g+3],d=h.createElement("rect"),p=(a-e)/o,f=(n-i)/l,m=(s-a)/o,v=(i-c)/l;d.setAttribute("x",p),d.setAttribute("y",f),d.setAttribute("width",m),d.setAttribute("height",v),u.append(d),null==r||r.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${f}" width="${m}" height="${v}"/>`)}yc(this,ga)&&(r.push("</g></svg>')"),a.backgroundImage=r.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(t=null){const{data:e}=this;let s,i;t?(s={str:t.text},i=t.date):(s=e.contentsObj,i=e.modificationDate);const n=Sc(this,fa,new of({data:{color:e.color,titleObj:e.titleObj,modificationDate:i,contentsObj:s,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}));this.parent.div.append(n.render())}get hasPopupElement(){return!!(yc(this,fa)||this.popup||this.data.popupRef)}render(){ud("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const s=[];if(this._fieldObjects){const i=this._fieldObjects[t];if(i)for(const{page:t,id:n,exportValues:a}of i){if(-1===t)continue;if(n===e)continue;const i="string"==typeof a?a:null,r=document.querySelector(`[data-element-id="${n}"]`);!r||qg.has(r)?s.push({id:n,exportValue:i,domElement:r}):dd()}return s}for(const i of document.getElementsByName(t)){const{exportValue:t}=i,n=i.getAttribute("data-element-id");n!==e&&(qg.has(i)&&s.push({id:n,exportValue:t,domElement:i}))}return s}show(){var t;this.container&&(this.container.hidden=!1),null==(t=this.popup)||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),null==(t=this.popup)||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;null==(s=this.linkService.eventBus)||s.dispatch("switchannotationeditormode",{source:this,mode:t,editId:e,mustEnterInEditMode:!0})})}get width(){return this.data.rect[2]-this.data.rect[0]}get height(){return this.data.rect[3]-this.data.rect[1]}};class Qg extends Kg{constructor(t,e=null){super(t,{isRenderable:!0,ignoreBorder:!!(null==e?void 0:e.ignoreBorder),createQuadrilaterals:!0}),xc(this,wa),this.isTooltipOnly=t.data.isTooltipOnly}render(){const{data:t,linkService:e}=this,s=document.createElement("a");s.setAttribute("data-element-id",t.id);let i=!1;return t.url?(e.addLinkAttributes(s,t.url,t.newWindow),i=!0):t.action?(this._bindNamedAction(s,t.action,t.overlaidText),i=!0):t.attachment?(kc(this,wa,Aa).call(this,s,t.attachment,t.overlaidText,t.attachmentDest),i=!0):t.setOCGState?(kc(this,wa,_a).call(this,s,t.setOCGState,t.overlaidText),i=!0):t.dest?(this._bindLink(s,t.dest,t.overlaidText),i=!0):(t.actions&&(t.actions.Action||t.actions["Mouse Up"]||t.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(s,t),i=!0),t.resetForm?(this._bindResetFormAction(s,t.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(s,""),i=!0)),this.container.classList.add("linkA
1nnotation"),i&&this.container.append(s),this.container}_bindLink(t,e,s=""){t.href=this.linkService.getDestinationHash(e),t.onclick=()=>(e&&this.linkService.goToDestination(e),!1),(e||""===e)&&kc(this,wa,ba).call(this),s&&(t.title=s)}_bindNamedAction(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeNamedAction(e),!1),s&&(t.title=s),kc(this,wa,ba).call(this)}_bindJSAction(t,e){t.href=this.linkService.getAnchorUrl("");const s=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const i of Object.keys(e.actions)){const n=s.get(i);n&&(t[n]=()=>{var t;return null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e.id,name:i}}),!1})}e.overlaidText&&(t.title=e.overlaidText),t.onclick||(t.onclick=()=>!1),kc(this,wa,ba).call(this)}_bindResetFormAction(t,e){const s=t.onclick;s||(t.href=this.linkService.getAnchorUrl("")),kc(this,wa,ba).call(this),this._fieldObjects?t.onclick=()=>{var t;null==s||s();const{fields:i,refs:n,include:a}=e,r=[];if(0!==i.length||0!==n.length){const t=new Set(n);for(const e of i){const s=this._fieldObjects[e]||[];for(const{id:e}of s)t.add(e)}for(const e of Object.values(this._fieldObjects))for(const s of e)t.has(s.id)===a&&r.push(s)}else for(const e of Object.values(this._fieldObjects))r.push(...e);const o=this.annotationStorage,l=[];for(const e of r){const{id:t}=e;switch(l.push(t),e.type){case"text":{const s=e.defaultValue||"";o.setValue(t,{value:s});break}case"checkbox":case"radiobutton":{const s=e.defaultValue===e.exportValues;o.setValue(t,{value:s});break}case"combobox":case"listbox":{const s=e.defaultValue||"";o.setValue(t,{value:s});break}default:continue}const s=document.querySelector(`[data-element-id="${t}"]`);s&&(qg.has(s)?s.dispatchEvent(new Event("resetform")):dd())}return this.enableScripting&&(null==(t=this.linkService.eventBus)||t.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:l,name:"ResetForm"}})),!1}:s||(t.onclick=()=>!1)}}wa=new WeakSet,ba=function(){this.container.setAttribute("data-internal-link","")},Aa=function(t,e,s="",i=null){t.href=this.linkService.getAnchorUrl(""),e.description?t.title=e.description:s&&(t.title=s),t.onclick=()=>{var t;return null==(t=this.downloadManager)||t.openOrDownloadData(e.content,e.filename,i),!1},kc(this,wa,ba).call(this)},_a=function(t,e,s=""){t.href=this.linkService.getAnchorUrl(""),t.onclick=()=>(this.linkService.executeSetOCGState(e),!1),s&&(t.title=s),kc(this,wa,ba).call(this)};class Jg extends Kg{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 Zg extends Kg{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&("CANVAS"===(null==(e=t.previousSibling)?void 0:e.nodeName)&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return Md.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,s,i,n){s.includes("mouse")?t.addEventListener(s,t=>{var e;null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t),shift:t.shiftKey,modifier:this._getKeyModifier(t)}})}):t.addEventListener(s,t=>{var a;if("blur"===s){if(!e.focused||!t.relatedTarget)return;e.focused=!1}else if("focus"===s){if(e.focused)return;e.focused=!0}n&&(null==(a=this.linkService.eventBus)||a.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:n(t)}}))})}_setEventListeners(t,e,s,i){var n,a,r;for(const[o,l]of s)("Action"===l||(null==(n=this.data.actions)?void 0:n[l]))&&("Focus"!==l&&"Blur"!==l||e||(e={focused:!1}),this._setEventListener(t,e,o,l,i),"Focus"!==l||(null==(a=this.data.actions)?void 0:a.Blur)?"Blur"!==l||(null==(r=this.data.actions)?void 0:r.Focus)||this._setEventListener(t,e,"focus","Focus",null):this._setEventListener(t,e,"blur","Blur",null))}
vendor: 4,498 bytes, line 1
1_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=null===e?"transparent":Cd.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:s}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,n=t.style;let a;const r=t=>Math.round(10*t)/10;if(this.data.multiLine){const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2),e=t/(Math.round(t/(Tc*i))||1);a=Math.min(i,r(e/Tc))}else{const t=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(i,r(t/Tc))}n.fontSize=`calc(${a}px * var(--total-scale-factor))`,n.color=Cd.makeHexColor(s[0],s[1],s[2]),null!==this.data.textAlignment&&(n.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class tf extends Zg{constructor(t){super(t,{isRenderable:t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue})}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 t,e;const s=this.annotationStorage,i=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const a=s.getValue(i,{value:this.data.fieldValue});let r=a.value||"";const o=s.getValue(i,{charLimit:this.data.maxLen}).charLimit;o&&r.length>o&&(r=r.slice(0,o));let l=a.formattedValue||(null==(t=this.data.textContent)?void 0:t.join("\n"))||null;l&&this.data.comb&&(l=l.replaceAll(/\s+/g,""));const h={userValue:r,formattedValue:l,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=l??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type=this.data.password?"password":"text",n.setAttribute("value",l??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),qg.add(n),n.setAttribute("data-element-id",i),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=0;const{datetimeFormat:c,datetimeType:d,timeStep:u}=this.data,p=!!d&&this.enableScripting;c&&(n.title=c),this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",t=>{s.setValue(i,{value:t.target.value}),this.setPropertyOnSiblings(n,"value",t.target.value,"value"),h.formattedValue=null}),n.addEventListener("resetform",t=>{const e=this.data.defaultFieldValue??"";n.value=h.userValue=e,h.formattedValue=null});let g=t=>{const{formattedValue:e}=h;null!=e&&(t.target.value=e),t.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",t=>{var e;if(h.focused)return;const{target:s}=t;if(p&&(s.type=d,u&&(s.step=u)),h.userValue){const t=h.userValue;if(p)if("time"===d){const e=new Date(t),i=[e.getHours(),e.getMinutes(),e.getSeconds()];s.value=i.map(t=>t.toString().padStart(2,"0")).join(":")}else s.value=new Date(t-Xg).toISOString().split("date"===d?"T":".",1)[0];else s.value=t}h.lastCommittedValue=s.value,h.commitKey=1,(null==(e=this.data.actions)?void 0:e.Focus)||(h.focused=!0)}),n.addEventListener("updatefromsandbox",t=>{this.showElementAndHideCanvas(t.target);const e={value(t){h.userValue=t.detail.value??"",p||s.setValue(i,{value:h.userValue.toString()}),t.target.value=h.userValue},formattedValue(t){const{formattedValue:e}=t.detail;h.formattedValue=e,null!=e&&t.target!==document.activeElement&&(t.target.value=e);const n={formattedValue:e};p&&(n.value=e),s.setValue(i,n)},selRange(t){t.target.setSelectionRange(...t.detail.selRange)},charLimit:t=>{var e;const{charLimit:n}=t.detail,{target:a}=t;if(0===n)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",n);let r=h.userValue;!r||r.length<=n||(r=r.slice(0,n),a.value=h.userValue=r,s.setValue(i,{value:r}),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(e,t)}),n.addEventListener("keydown",t=>{var e;h.commitKey=1;let s=-1;if("Escape"===t.key?s=0:"Enter"!==t.key||this.data.multiLine?"Tab"===t.key&&(h.commitKey=3):s=2,-1===s)return;const{value:n}=t.target;h.lastCommittedValue!==n&&(h.lastCommittedValue=n,h.userValue=n,null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:n,willCommit:!0,
1commitKey:s,selStart:t.target.selectionStart,selEnd:t.target.selectionEnd}}))});const t=g;g=null,n.addEventListener("blur",e=>{var s,n;if(!h.focused||!e.relatedTarget)return;(null==(s=this.data.actions)?void 0:s.Blur)||(h.focused=!1);const{target:a}=e;let{value:r}=a;if(p){if(r&&"time"===d){const t=r.split(":").map(t=>parseInt(t,10));r=new Date(2e3,0,1,t[0],t[1],t[2]||0).valueOf(),a.step=""}else r=new Date(r).valueOf();a.type="text"}h.userValue=r,h.lastCommittedValue!==r&&(null==(n=this.linkService.eventBus)||n.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:r,willCommit:!0,commitKey:h.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})),t(e)}),(null==(e=this.data.actions)?void 0:e.Keystroke)&&n.addEventListener("beforeinput",t=>{var e;h.lastCommittedValue=null;const{data:s,target:n}=t,{value:a,selectionStart:r,selectionEnd:o}=n;let l=r,c=o;switch(t.inputType){case"deleteWordBackward":{const t=a.substring(0,r).match(/\w*[^\w]*$/);t&&(l-=t[0].length);break}
vendor: 8,364 bytes, line 1
1case"deleteWordForward":{const t=a.substring(r).match(/^[^\w]*\w*/);t&&(c+=t[0].length);break}case"deleteContentBackward":r===o&&(l-=1);break;case"deleteContentForward":r===o&&(c+=1)}t.preventDefault(),null==(e=this.linkService.eventBus)||e.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i,name:"Keystroke",value:a,change:s||"",willCommit:!1,selStart:l,selEnd:c}})}),this._setEventListeners(n,h,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.value)}if(g&&n.addEventListener("blur",g),this.data.comb){const t=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${t}px * var(--total-scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class ef extends Zg{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class sf extends Zg{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;"string"==typeof i&&(i="Off"!==i,t.setValue(s,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const n=document.createElement("input");return qg.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=0,n.addEventListener("change",i=>{const{name:n,checked:a}=i.target;for(const r of this._getElementsByName(n,s)){const s=a&&r.exportValue===e.exportValue;r.domElement&&(r.domElement.checked=s),t.setValue(r.id,{value:s})}t.setValue(s,{value:a})}),n.addEventListener("resetform",t=>{const s=e.defaultFieldValue||"Off";t.target.checked=s===e.exportValue}),this.enableScripting&&this.hasJSActions&&(n.addEventListener("updatefromsandbox",e=>{const i={value(e){e.target.checked="Off"!==e.detail.value,t.setValue(s,{value:e.target.checked})}};this._dispatchEventFromSandbox(i,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class nf extends Zg{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("string"==typeof i&&(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(qg.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=0,n.addEventListener("change",e=>{const{name:i,checked:n}=e.target;for(const a of this._getElementsByName(i,s))t.setValue(a.id,{value:!1});t.setValue(s,{value:n})}),n.addEventListener("resetform",t=>{const s=e.defaultFieldValue;t.target.checked=null!=s&&s===e.buttonValue}),this.enableScripting&&this.hasJSActions){const i=e.buttonValue;n.addEventListener("updatefromsandbox",e=>{const n={value:e=>{const n=i===e.detail.value;for(const i of this._getElementsByName(e.target.name)){const e=n&&i.id===s;i.domElement&&(i.domElement.checked=e),t.setValue(i.id,{value:e})}}};this._dispatchEventFromSandbox(n,e)}),this._setEventListeners(n,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],t=>t.target.checked)}return this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class af extends Qg{constructor(t){super(t,{ignoreBorder:t.data.hasAppearance})}render(){const t=super.render();t.classList.add("buttonWidgetAnnotation","pushButton");const e=t.lastChild;return this.enableScripting&&this.hasJSActions&&e&&(this._setDefaultPropertiesFromJS(e),e.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({},t)})),t}}class rf extends Zg{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");qg.add(i),i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=0;let 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",t=>{const e=this.data.defaultFieldValue;for(const s of i.options)s.selected=s.value===e});for(const h of this.data.options){const t=document.createElement("option");t.textContent=h.displayValue,t.value=h.exportValue,s.value.includes(h.exportValue)&&(t.setAttribute("selected",!0),n=!1),i.append(t)}let a=null;if(n){const t=document.createElement("option");t.value=" ",t.setAttribute("hidden",!0),t.setAttribute("selected",!0),i.prepend(t),a=()=>{t.remove(),i.removeEventListener("input",a),a=null},i.addEventListener("input",a)}const r=t=>{const e=t?"value":"textContent",{options:s,multiple:n}=i;return n?Array.prototype.filter.call(s,t=>t.selected).map(t=>t[e]):-1===s.selectedIndex?null:s[s.selectedIndex][e]};let o=r(!1);const l=t=>{const e=t.target.options;return Array.prototype.map.call(e,t=>({displayValue:t.textContent,exportValue:t.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",s=>{const n={value(s){null==a||a();const n=s.detail.value,l=new Set(Array.isArray(n)?n:[n]);for(const t of i.options)t.selected=l.has(t.value);t.setValue(e,{value:r(!0)}),o=r(!1)},multipleSelection(t){i.multiple=!0},remove(s){const n=i.options,a=s.detail.remove;if(n[a].selected=!1,i.remove(a),n.length>0){-1===Array.prototype.findIndex.call(n,t=>t.selected)&&(n[0].selected=!0)}t.setValue(e,{value:r(!0),items:l(s)}),o=r(!1)},clear(s){for(;0!==i.length;)i.remove(0);t.setValue(e,{value:null,items:[]}),o=r(!1)},insert(s){const{index:n,displayValue:a,exportValue:h}=s.detail.insert,c=i.children[n],d=document.createElement("option");d.textContent=a,d.value=h,c?c.before(d):i.append(d),t.setValue(e,{value:r(!0),items:l(s)}),o=r(!1)},items(s){const{items:n}=s.detail;for(;0!==i.length;)i.remove(0);for(const t of n){const{displayValue:e,exportValue:s}=t,n=document.createElement("option");n.textContent=e,n.value=s,i.append(n)}i.options.length>0&&(i.options[0].selected=!0),t.setValue(e,{value:r(!0),items:l(s)}),o=r(!1)},indices(s){const i=new Set(s.detail.indices);for(const t of s.target.options)t.selected=i.has(t.index);t.setValue(e,{value:r(!0)}),o=r(!1)},editable(t){t.target.disabled=!t.detail.editable}};this._dispatchEventFromSandbox(n,s)}),i.addEventListener("input",s=>{var i;const n=r(!0),a=r(!1);t.setValue(e,{value:n}),s.preventDefault(),null==(i=this.linkService.eventBus)||i.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:o,change:a,changeEx:n,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"]],t=>t.target.value)):i.addEventListener("input",function(s){t.setValue(e,{value:r(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class of extends Kg{constructor(t){const{data:e,elements:s}=t;super(t,{isRenderable:Kg._hasPopupData(e)}),this.elements=s,this.popup=null}render(){const{container:t}=this;t.classList.add("popupAnnotation"),t.role="comment";
1const e=this.popup=new lf({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),s=[];for(const i of this.elements)i.popup=e,i.container.ariaHasPopup="dialog",s.push(i.data.id),i.addHighlightArea();return this.container.setAttribute("aria-controls",s.map(t=>`${Dd}${t}`).join(",")),this.container}}class lf{constructor({container:t,color:e,elements:s,titleObj:i,modificationDate:n,contentsObj:a,richText:r,parent:o,rect:l,parentRect:h,open:c}){xc(this,za),xc(this,ya,kc(this,za,Xa).bind(this)),xc(this,xa,kc(this,za,Ja).bind(this)),xc(this,Sa,kc(this,za,Qa).bind(this)),xc(this,ka,kc(this,za,Ka).bind(this)),xc(this,Ma,null),xc(this,Ea,null),xc(this,Ca,null),xc(this,Ta,null),xc(this,Ra,null),xc(this,Pa,null),xc(this,Ia,null),xc(this,Da,!1),xc(this,La,null),xc(this,Na,null),xc(this,Fa,null),xc(this,Wa,null),xc(this,Oa,null),xc(this,Ba,null),xc(this,Ha,null),xc(this,$a,!1),Sc(this,Ea,t),Sc(this,Ba,i),Sc(this,Ca,a),Sc(this,Oa,r),Sc(this,Pa,o),Sc(this,Ma,e),Sc(this,Wa,l),Sc(this,Ia,h),Sc(this,Ra,s),Sc(this,Ta,Kd.toDateObject(n)),this.trigger=s.flatMap(t=>t.getElementsToTriggerPopup()),kc(this,za,ja).call(this),yc(this,Ea).hidden=!0,c&&kc(this,za,Ka).call(this)}render(){var t;if(yc(this,La))return;const e=Sc(this,La,document.createElement("div"));if(e.className="popup",yc(this,Ma)){const t=e.style.outlineColor=Cd.makeHexColor(...yc(this,Ma));e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`}const s=document.createElement("span");if(s.className="header",null==(t=yc(this,Ba))?void 0:t.str){const t=document.createElement("span");t.className="title",s.append(t),({dir:t.dir,str:t.textContent}=yc(this,Ba))}if(e.append(s),yc(this,Ta)){const t=document.createElement("time");t.className="popupDate",t.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),t.setAttribute("data-l10n-args",JSON.stringify({dateObj:yc(this,Ta).valueOf()})),t.dateTime=yc(this,Ta).toISOString(),s.append(t)}const i=yc(this,za,Ga);if(i)Ug.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(yc(this,Ca));e.append(t)}yc(this,Ea).append(e)}_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;++n){const t=i[n];s.append(document.createTextNode(t)),n<a-1&&s.append(document.createElement("br"))}return s}updateEdited({rect:t,popup:e,deleted:s}){var i;s||(null==e?void 0:e.deleted)?this.remove():(kc(this,za,ja).call(this),yc(this,Ha)||Sc(this,Ha,{contentsObj:yc(this,Ca),richText:yc(this,Oa)}),t&&Sc(this,Fa,null),e&&(Sc(this,Oa,kc(this,za,qa).call(this,e.text)),Sc(this,Ta,Kd.toDateObject(e.date)),Sc(this,Ca,null)),null==(i=yc(this,La))||i.remove(),Sc(this,La,null))}resetEdited(){var t;yc(this,Ha)&&(({contentsObj:Mc(this,Ca)._,richText:Mc(this,Oa)._}=yc(this,Ha)),Sc(this,Ha,null),null==(t=yc(this,La))||t.remove(),Sc(this,La,null),Sc(this,Fa,null))}remove(){var t,e;null==(t=yc(this,Na))||t.abort(),Sc(this,Na,null),null==(e=yc(this,La))||e.remove(),Sc(this,La,null),Sc(this,$a,!1),Sc(this,Da,!1);for(const s of this.trigger)s.classList.remove("popupTriggerArea")}forceHide(){Sc(this,$a,this.isVisible),yc(this,$a)&&(yc(this,Ea).hidden=!0)}maybeShow(){kc(this,za,ja).call(this),yc(this,$a)&&(yc(this,La)||kc(this,za,Qa).call(this),Sc(this,$a,!1),yc(this,Ea).hidden=!1)}get isVisible(){return!1===yc(this,Ea).hidden}}ya=new WeakMap,xa=new WeakMap,Sa=new WeakMap,ka=new WeakMap,Ma=new WeakMap,Ea=new WeakMap,Ca=new WeakMap,Ta=new WeakMap,Ra=new WeakMap,Pa=new WeakMap,Ia=new WeakMap,Da=new WeakMap,La=new WeakMap,Na=new WeakMap,Fa=new WeakMap,Wa=new WeakMap,Oa=new WeakMap,Ba=new WeakMap,Ha=new WeakMap,$a=new WeakMap,za=new WeakSet,ja=function(){var t;if(yc(this,Na))return;Sc(this,Na,new AbortController);const{signal:e}=yc(this,Na);for(const s of this.trigger)s.addEventListener("click",yc(this,ka),{signal:e}),s.addEventListener("mouseenter",yc(this,Sa),{signal:e}),s.addEventListener("mouseleave",yc(this,xa),{signal:e}),s.classList.add("popupTriggerArea");for(const s of yc(this,Ra))null==(t=s.container)||t.addEventListener("keydown",yc(this,ya),{signal:e})},Ga=function(){const t=yc(this,Oa),e=yc(this,Ca);return!(null==t?void 0:t.str)||(null==e?void 0:e.str)&&e.str!==t.str?null:yc(this,Oa).html||null},Va=function(){var t,e,s;return(null==(s=null==(e=null==(t=yc(this,za,Ga))?void 0:t.attributes)?void 0:e.style)?void 0:s.fontSize)||0},Ua=function(){var t,e,s;return(null==(s=null==(e=null==(t=yc(this,za,Ga))?void 0:t.attributes)?void 0:e.style)?void 0:s.color)||null},qa=function(t){const e=[],s={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},i={style:{color:yc(this,za,Ua),fontSize:yc(this,za,Va)?`calc(${yc(this,za,Va)}px * var(--total-scale-factor))`:""}};for(const n of t.split("\n"))e.push({name:"span",value:n,attributes:i});return s},Xa=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||("Enter"===t.key||"Escape"===t.key&&yc(this,Da))&&kc(this,za,Ka).call(this)},Ya=function(){if(null!==yc(this,Fa))return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:s,pageX:i,pageY:n}}}=yc(this,Pa);let a=!!yc(this,Ia),r=yc(this,a?Ia:Wa);for(const u of yc(this,Ra))if(!r||null!==Cd.intersect(u.data.rect,r)){r=u.data.rect,a=!0;break}const o=Cd.normalizeRect([r[0],t[3]-r[1]+t[1],r[2],t[3]-r[3]+t[1]]),l=a?r[2]-r[0]+5:0,h=o[0]+l,c=o[1];Sc(this,Fa,[100*(h-i)/e,100*(c-n)/s]);const{style:d}=yc(this,Ea);d.left=`${yc(this,Fa)[0]}%`,d.top=`${yc(this,Fa)[1]}%`},Ka=function(){Sc(this,Da,!yc(this,Da)),yc(this,Da)?(kc(this,za,Qa).call(this),yc(this,Ea).addEventListener("click",yc(this,ka)),yc(this,Ea).addEventListener("keydown",yc(this,ya))):(kc(this,za,Ja).call(this),yc(this,Ea).removeEventListener("click",yc(this,ka)),yc(this,Ea).removeEventListener("keydown",yc(this,ya)))},Qa=function(){yc(this,La)||this.render(),this.isVisible?yc(this,Da)&&yc(this,Ea).classList.add("focused"):(kc(this,za,Ya).call(this),yc(this,Ea).hidden=!1,yc(this,Ea).style.zIndex=parseInt(yc(this,Ea).style.zIndex)+1e3)},Ja=function(){yc(this,Ea).classList.remove("focused"),!yc(this,Da)&&this.isVisible&&(yc(this,Ea).hidden=!0,yc(this,Ea).style.zIndex=parseInt(yc(this,Ea).style.zIndex)-1e3)};class hf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=Hc.FREETEXT}
1render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const s=document.createElement("span");s.textContent=e,t.append(s)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class cf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),xc(this,Za,null)}render(){this.container.classList.add("lineAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=Sc(this,Za,this.svgFactory.createElement("svg:line"));return n.setAttribute("x1",t.rect[2]-t.lineCoordinates[0]),n.setAttribute("y1",t.rect[3]-t.lineCoordinates[1]),n.setAttribute("x2",t.rect[2]-t.lineCoordinates[2]),n.setAttribute("y2",t.rect[3]-t.lineCoordinates[3]),n.setAttribute("stroke-width",t.borderStyle.width||1),n.setAttribute("stroke","transparent"),n.setAttribute("fill","transparent"),i.append(n),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return yc(this,Za)}addHighlightArea(){this.container.classList.add("highlightArea")}}Za=new WeakMap;class df extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),xc(this,tr,null)}render(){this.container.classList.add("squareAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=Sc(this,tr,this.svgFactory.createElement("svg:rect"));return a.setAttribute("x",n/2),a.setAttribute("y",n/2),a.setAttribute("width",e-n),a.setAttribute("height",s-n),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return yc(this,tr)}addHighlightArea(){this.container.classList.add("highlightArea")}}tr=new WeakMap;class uf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),xc(this,er,null)}render(){this.container.classList.add("circleAnnotation");const{data:t,width:e,height:s}=this,i=this.svgFactory.create(e,s,!0),n=t.borderStyle.width,a=Sc(this,er,this.svgFactory.createElement("svg:ellipse"));return a.setAttribute("cx",e/2),a.setAttribute("cy",s/2),a.setAttribute("rx",e/2-n/2),a.setAttribute("ry",s/2-n/2),a.setAttribute("stroke-width",n||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),i.append(a),this.container.append(i),!t.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return yc(this,er)}addHighlightArea(){this.container.classList.add("highlightArea")}}er=new WeakMap;class pf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),xc(this,sr,null),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,vertices:e,borderStyle:s,popupRef:i},width:n,height:a}=this;if(!e)return this.container;const r=this.svgFactory.create(n,a,!0);let o=[];for(let h=0,c=e.length;h<c;h+=2){const s=e[h]-t[0],i=t[3]-e[h+1];o.push(`${s},${i}`)}o=o.join(" ");const l=Sc(this,sr,this.svgFactory.createElement(this.svgElementName));return l.setAttribute("points",o),l.setAttribute("stroke-width",s.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!i&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return yc(this,sr)}addHighlightArea(){this.container.classList.add("highlightArea")}}sr=new WeakMap;class gf extends pf{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class ff extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class mf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),xc(this,ar),xc(this,ir,null),xc(this,nr,[]),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Hc.HIGHLIGHT:Hc.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:t,rotation:e,inkLists:s,borderStyle:i,popupRef:n}}=this,{transform:a,width:r,height:o}=kc(this,ar,rr).call(this,e,t),l=this.svgFactory.create(r,o,!0),h=Sc(this,ir,this.svgFactory.createElement("svg:g"));l.append(h),h.setAttribute("stroke-width",i.width||1),h.setAttribute("stroke-linecap","round"),h.setAttribute("stroke-linejoin","round"),h.setAttribute("stroke-miterlimit",10),h.setAttribute("stroke","transparent"),h.setAttribute("fill","transparent"),h.setAttribute("transform",a);for(let c=0,d=s.length;c<d;c++){const t=this.svgFactory.createElement(this.svgElementName);yc(this,nr).push(t),t.setAttribute("points",s[c].join(",")),h.append(t)}return!n&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(t){super.updateEdited(t);const{thickness:e,points:s,rect:i}=t,n=yc(this,ir);if(e>=0&&n.setAttribute("stroke-width",e||1),s)for(let a=0,r=yc(this,nr).length;a<r;a++)yc(this,nr)[a].setAttribute("points",s[a].join(","));if(i){const{transform:t,width:e,height:s}=kc(this,ar,rr).call(this,this.data.rotation,i);n.parentElement.setAttribute("viewBox",`0 0 ${e} ${s}`),n.setAttribute("transform",t)}}getElementsToTriggerPopup(){return yc(this,nr)}addHighlightArea(){this.container.classList.add("highlightArea")}}ir=new WeakMap,nr=new WeakMap,ar=new WeakSet,rr=function(t,e){switch(t){case 90:return{transform:`rotate(90) translate(${-e[0]},${e[1]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};case 180:return{transform:`rotate(180) translate(${-e[2]},${e[1]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]};case 270:return{transform:`rotate(270) translate(${-e[2]},${e[3]}) scale(1,-1)`,width:e[3]-e[1],height:e[2]-e[0]};default:return{transform:`translate(${-e[0]},${e[3]}) scale(1,-1)`,width:e[2]-e[0],height:e[3]-e[1]}}};class vf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Hc.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const e=document.createElement("mark");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}
1class wf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class bf extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),t){const e=document.createElement("u");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class Af extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),t){const e=document.createElement("s");e.classList.add("overlaidText"),e.textContent=t,this.container.append(e)}return this.container}}class _f extends Kg{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Hc.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class yf extends Kg{constructor(t){var e;super(t,{isRenderable:!0}),xc(this,lr),xc(this,or,null);const{file:s}=this.data;this.filename=s.filename,this.content=s.content,null==(e=this.linkService.eventBus)||e.dispatch("fileattachmentannotation",{source:this,...s})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:t,data:e}=this;let s;e.hasAppearance||0===e.fillAlpha?s=document.createElement("div"):(s=document.createElement("img"),s.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(e.name)?"paperclip":"pushpin"}.svg`,e.fillAlpha&&e.fillAlpha<1&&(s.style=`filter: opacity(${Math.round(100*e.fillAlpha)}%);`)),s.addEventListener("dblclick",kc(this,lr,hr).bind(this)),Sc(this,or,s);const{isMac:i}=Md.platform;return t.addEventListener("keydown",t=>{"Enter"===t.key&&(i?t.metaKey:t.ctrlKey)&&kc(this,lr,hr).call(this)}),!e.popupRef&&this.hasPopupData?this._createPopup():s.classList.add("popupTriggerArea"),t.append(s),t}getElementsToTriggerPopup(){return yc(this,or)}addHighlightArea(){this.container.classList.add("highlightArea")}}or=new WeakMap,lr=new WeakSet,hr=function(){var t;null==(t=this.downloadManager)||t.openOrDownloadData(this.content,this.filename)};cr=new WeakMap,dr=new WeakMap,ur=new WeakMap,pr=new WeakMap,gr=new WeakSet,fr=async function(t,e,s){var i,n;const a=t.firstChild||t,r=a.id=`${Dd}${e}`,o=await(null==(i=yc(this,pr))?void 0:i.getAriaAttributes(r));if(o)for(const[l,h]of o)a.setAttribute(l,h);s?s.at(-1).container.after(t):(this.div.append(t),null==(n=yc(this,cr))||n.moveElementInDOM(this.div,t,a,!1))},mr=function(){var t;if(!yc(this,dr))return;const e=this.div;for(const[s,i]of yc(this,dr)){const n=e.querySelector(`[data-annotation-id="${s}"]`);if(!n)continue;i.className="annotationContent";const{firstChild:a}=n;a?"CANVAS"===a.nodeName?a.replaceWith(i):a.classList.contains("annotationContent")?a.after(i):a.before(i):n.append(i);const r=yc(this,ur).get(s);r&&(r._hasNoCanvas?(null==(t=this._annotationEditorUIManager)||t.setMissingCanvas(s,n.id,i),r._hasNoCanvas=!1):r.canvas=i)}yc(this,dr).clear()};let xf=class t{constructor({div:t,accessibilityManager:e,annotationCanvasMap:s,annotationEditorUIManager:i,page:n,viewport:a,structTreeLayer:r}){xc(this,gr),xc(this,cr,null),xc(this,dr,null),xc(this,ur,new Map),xc(this,pr,null),this.div=t,Sc(this,cr,e),Sc(this,dr,s),Sc(this,pr,r||null),this.page=n,this.viewport=a,this.zIndex=0,this._annotationEditorUIManager=i}hasEditableAnnotations(){return yc(this,ur).size>0}async render(t){var e;const{annotations:s}=t,i=this.div;eu(i,this.viewport);const n=new Map,a={data:null,layer:i,linkService:t.linkService,downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:!1!==t.renderForms,svgFactory:new Vg,annotationStorage:t.annotationStorage||new Ru,enableScripting:!0===t.enableScripting,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const r of s){if(r.noHTML)continue;const t=r.annotationType===Kc.POPUP;if(t){const t=n.get(r.id);if(!t)continue;a.elements=t}else if(r.rect[2]===r.rect[0]||r.rect[3]===r.rect[1])continue;a.data=r;const s=Yg.create(a);if(!s.isRenderable)continue;if(!t&&r.popupRef){const t=n.get(r.popupRef);t?t.push(s):n.set(r.popupRef,[s])}const i=s.render();r.hidden&&(i.style.visibility="hidden"),await kc(this,gr,fr).call(this,i,r.id,a.elements),s._isEditable&&(yc(this,ur).set(s.data.id,s),null==(e=this._annotationEditorUIManager)||e.renderAnnotationElement(s))}kc(this,gr,mr).call(this)}async addLinkAnnotations(e,s){const i={data:null,layer:this.div,linkService:s,svgFactory:new Vg,parent:this};for(const n of e){n.borderStyle||(n.borderStyle=t._defaultBorderStyle),i.data=n;const e=Yg.create(i);if(!e.isRenderable)continue;const s=e.render();await kc(this,gr,fr).call(this,s,n.id,null)}}update({viewport:t}){const e=this.div;this.viewport=t,eu(e,{rotation:t.rotation}),kc(this,gr,mr).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(yc(this,ur).values())}getEditableAnnotation(t){return yc(this,ur).get(t)}static get _defaultBorderStyle(){return md(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:Qc,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};const Sf=/\r\n?|\n/g,kf=class t extends xu{constructor(e){super({...e,name:"freeTextEditor"}),xc(this,yr),xc(this,vr),xc(this,wr,""),xc(this,br,`${this.id}-editor`),xc(this,Ar,null),xc(this,_r),Ac(this,"_colorPicker",null),Sc(this,vr,e.color||t._defaultColor||xu._defaultLineColor),Sc(this,_r,e.fontSize||t._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert")}static get _keyboardManager(){const e=t.prototype,s=t=>t.isEmpty(),i=mu.TRANSLATE_SMALL,n=mu.TRANSLATE_BIG;return md(this,"_keyboardManager",new uu([[["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(t,e){xu.initialize(t,e);const s=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(s.getPropertyValue("--freetext-padding"))}
1static updateDefaultParams(e,s){switch(e){case $c.FREETEXT_SIZE:t._defaultFontSize=s;break;case $c.FREETEXT_COLOR:t._defaultColor=s}}updateParams(t,e){switch(t){case $c.FREETEXT_SIZE:kc(this,yr,xr).call(this,e);break;case $c.FREETEXT_COLOR:kc(this,yr,Sr).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$c.FREETEXT_SIZE,t._defaultFontSize],[$c.FREETEXT_COLOR,t._defaultColor||xu._defaultLineColor]]}get propertiesToUpdate(){return[[$c.FREETEXT_SIZE,yc(this,_r)],[$c.FREETEXT_COLOR,yc(this,vr)]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Hg(this)),[["colorPicker",this._colorPicker]]}get colorType(){return $c.FREETEXT_COLOR}get colorValue(){return yc(this,vr)}_translateEmpty(t,e){this._uiManager.translateSelectedEditors(t,e,!0)}getInitialTranslation(){const e=this.parentScale;return[-t._internalPadding*e,-(t._internalPadding+yc(this,_r))*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),Sc(this,Ar,new AbortController);const t=this._uiManager.combinedSignal(yc(this,Ar));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:t}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:t}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:t}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:t}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:t}),!0}disableEditMode(){var t;return!!super.disableEditMode()&&(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",yc(this,br)),this._isDraggable=!0,null==(t=yc(this,Ar))||t.abort(),Sc(this,Ar,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0)}focusin(t){this._focusEventsAllowed&&(super.focusin(t),t.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(t){var e;this.width||(this.enableEditMode(),t&&this.editorDiv.focus(),(null==(e=this._initialOptions)?void 0: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 t=yc(this,wr),e=Sc(this,wr,kc(this,yr,kr).call(this).trimEnd());if(t===e)return;const s=t=>{Sc(this,wr,t),t?(kc(this,yr,Tr).call(this),this._uiManager.rebuild(this),kc(this,yr,Mr).call(this)):this.remove()};this.addCommands({cmd:()=>{s(e)},undo:()=>{s(t)},mustExec:!1}),kc(this,yr,Mr).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(t){t.target===this.div&&"Enter"===t.key&&(this.enterInEditMode(),t.preventDefault())}editorDivKeydown(e){t._keyboardManager.exec(this,e)}editorDivFocus(t){this.isEditing=!0}editorDivBlur(t){this.isEditing=!1}editorDivInput(t){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let t,e;(this._isCopy||this.annotationElementId)&&(t=this.x,e=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",yc(this,br)),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:s}=this.editorDiv;if(s.fontSize=`calc(${yc(this,_r)}px * var(--total-scale-factor))`,s.color=yc(this,vr),this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[s,i]=this.parentDimensions;
1if(this.annotationElementId){const{position:n}=this._initialData;let[a,r]=this.getInitialTranslation();[a,r]=this.pageTranslationToScreen(a,r);const[o,l]=this.pageDimensions,[h,c]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=t+(n[0]-h)/o,u=e+this.height-(n[1]-c)/l;break;case 90:d=t+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[r,-a];break;case 180:d=t-this.width+(n[0]-h)/o,u=e-(n[1]-c)/l,[a,r]=[-a,-r];break;case 270:d=t+(n[0]-h-this.height*l)/o,u=e+(n[1]-c-this.width*o)/l,[a,r]=[-r,a]}this.setAt(d*s,u*i,a,r)}else this._moveAfterPaste(t,e);kc(this,yr,Tr).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var s,i,n;const a=e.clipboardData||window.clipboardData,{types:r}=a;if(1===r.length&&"text/plain"===r[0])return;e.preventDefault();const o=kc(s=t,Er,Pr).call(s,a.getData("text")||"").replaceAll(Sf,"\n");if(!o)return;const l=window.getSelection();if(!l.rangeCount)return;this.editorDiv.normalize(),l.deleteFromDocument();const h=l.getRangeAt(0);if(!o.includes("\n"))return h.insertNode(document.createTextNode(o)),this.editorDiv.normalize(),void l.collapseToStart();const{startContainer:c,startOffset:d}=h,u=[],p=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(p.push(c.nodeValue.slice(d).replaceAll(Sf,"")),e!==this.editorDiv){let s=u;for(const n of this.editorDiv.childNodes)n!==e?s.push(kc(i=t,Er,Cr).call(i,n)):s=p}u.push(c.nodeValue.slice(0,d).replaceAll(Sf,""))}else if(c===this.editorDiv){let e=u,s=0;for(const i of this.editorDiv.childNodes)s++===d&&(e=p),e.push(kc(n=t,Er,Cr).call(n,i))}Sc(this,wr,`${u.join("\n")}${o}${p.join("\n")}`),kc(this,yr,Tr).call(this);const g=new Range;let f=Math.sumPrecise(u.map(t=>t.length));for(const{firstChild:t}of this.editorDiv.childNodes)if(t.nodeType===Node.TEXT_NODE){const e=t.nodeValue.length;if(f<=e){g.setStart(t,f),g.setEnd(t,f);break}f-=e}l.removeAllRanges(),l.addRange(g)}get contentDiv(){return this.editorDiv}static async deserialize(e,s,i){var n;let a=null;if(e instanceof hf){const{data:{defaultAppearanceData:{fontSize:t,fontColor:s},rect:i,rotation:n,id:r,popupRef:o,contentsObj:l},textContent:h,textPosition:c,parent:{page:{pageNumber:d}}}=e;if(!h||0===h.length)return null;a=e={annotationType:Hc.FREETEXT,color:Array.from(s),fontSize:t,value:h.join("\n"),position:c,pageIndex:d-1,rect:i.slice(0),rotation:n,annotationElementId:r,id:r,deleted:!1,popupRef:o,comment:(null==l?void 0:l.str)||null}}const r=await super.deserialize(e,s,i);return Sc(r,_r,e.fontSize),Sc(r,vr,Cd.makeHexColor(...e.color)),Sc(r,wr,kc(n=t,Er,Pr).call(n,e.value)),r._initialData=a,e.comment&&r.setCommentData(e.comment),r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s=t._internalPadding*this.parentScale,i=this.getRect(s,s),n=xu._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:yc(this,vr)),a={annotationType:Hc.FREETEXT,color:n,fontSize:yc(this,_r),value:kc(this,yr,Rr).call(this),pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),e?(a.isCopy=!0,a):this.annotationElementId&&!kc(this,yr,Ir).call(this,a)?null:(a.id=this.annotationElementId,a)}renderAnnotationElement(e){const s=super.renderAnnotationElement(e),{style:i}=s;i.fontSize=`calc(${yc(this,_r)}px * var(--total-scale-factor))`,i.color=yc(this,vr),s.replaceChildren();for(const t of yc(this,wr).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),s.append(e)}const n=t._internalPadding*this.parentScale,a={rect:this.getRect(n,n)};return a.popup=this.hasEditedComment?this.comment:{text:yc(this,wr)},e.updateEdited(a),s}resetAnnotationElement(t){super.resetAnnotationElement(t),t.resetEdited()}};vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Ar=new WeakMap,_r=new WeakMap,yr=new WeakSet,xr=function(t){const e=t=>{this.editorDiv.style.fontSize=`calc(${t}px * var(--total-scale-factor))`,this.translate(0,-(t-yc(this,_r))*this.parentScale),Sc(this,_r,t),kc(this,yr,Mr).call(this)},s=yc(this,_r);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$c.FREETEXT_S
1IZE,overwriteIfSameType:!0,keepUndo:!0})},Sr=function(t){const e=t=>{var e;Sc(this,vr,this.editorDiv.style.color=t),null==(e=this._colorPicker)||e.update(t)},s=yc(this,vr);this.addCommands({cmd:e.bind(this,t),undo:e.bind(this,s),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$c.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},kr=function(){var t;const e=[];this.editorDiv.normalize();let s=null;for(const i of this.editorDiv.childNodes)(null==s?void 0:s.nodeType)===Node.TEXT_NODE&&"BR"===i.nodeName||(e.push(kc(t=kf,Er,Cr).call(t,i)),s=i);return e.join("\n")},Mr=function(){const[t,e]=this.parentDimensions;let s;if(this.isAttachedToDOM)s=this.div.getBoundingClientRect();else{const{currentLayer:t,div:e}=this,i=e.style.display,n=e.classList.contains("hidden");e.classList.remove("hidden"),e.style.display="hidden",t.div.append(this.div),s=e.getBoundingClientRect(),e.remove(),e.style.display=i,e.classList.toggle("hidden",n)}this.rotation%180==this.parentRotation%180?(this.width=s.width/t,this.height=s.height/e):(this.width=s.height/t,this.height=s.width/e),this.fixAndSetPosition()},Er=new WeakSet,Cr=function(t){return(t.nodeType===Node.TEXT_NODE?t.nodeValue:t.innerText).replaceAll(Sf,"")},Tr=function(){if(this.editorDiv.replaceChildren(),yc(this,wr))for(const t of yc(this,wr).split("\n")){const e=document.createElement("div");e.append(t?document.createTextNode(t):document.createElement("br")),this.editorDiv.append(e)}},Rr=function(){return yc(this,wr).replaceAll(" "," ")},Pr=function(t){return t.replaceAll(" "," ")},Ir=function(t){const{value:e,fontSize:s,color:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||t.value!==e||t.fontSize!==s||t.color.some((t,e)=>t!==i[e])||t.pageIndex!==n},xc(kf,Er),Ac(kf,"_freeTextDefaultContent",""),Ac(kf,"_internalPadding",0),Ac(kf,"_defaultColor",null),Ac(kf,"_defaultFontSize",10),Ac(kf,"_type","freetext"),Ac(kf,"_editorType",Hc.FREETEXT);let Mf=kf;class Ef{toSVGPath(){ud("Abstract method `toSVGPath` must be implemented.")}get box(){ud("Abstract getter `box` must be implemented.")}serialize(t,e){ud("Abstract method `serialize` must be implemented.")}static _rescale(t,e,s,i,n,a){a||(a=new Float32Array(t.length));for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r]*i,a[r+1]=s+t[r+1]*n;return a}static _rescaleAndSwap(t,e,s,i,n,a){a||(a=new Float32Array(t.length));for(let r=0,o=t.length;r<o;r+=2)a[r]=e+t[r+1]*i,a[r+1]=s+t[r]*n;return a}static _translate(t,e,s,i){i||(i=new Float32Array(t.length));for(let n=0,a=t.length;n<a;n+=2)i[n]=e+t[n],i[n+1]=s+t[n+1];return i}static svgRound(t){return Math.round(1e4*t)}static _normalizePoint(t,e,s,i,n){switch(n){case 90:return[1-e/s,t/i];case 180:return[1-t/s,1-e/i];case 270:return[e/s,1-t/i];default:return[t/s,e/i]}}static _normalizePagePoint(t,e,s){switch(s){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,s,i,n,a){return[(t+5*s)/6,(e+5*i)/6,(5*s+n)/6,(5*i+a)/6,(s+n)/2,(i+a)/2]}}Ac(Ef,"PRECISION",1e-4);const Cf=class t{constructor({x:e,y:s},i,n,a,r,o=0){xc(this,Yr),xc(this,Dr),xc(this,Lr,[]),xc(this,Nr),xc(this,Fr),xc(this,Wr,[]),xc(this,Or,new Float32Array(18)),xc(this,Br),xc(this,Hr),xc(this,$r),xc(this,zr),xc(this,jr),xc(this,Gr),xc(this,Vr,[]),Sc(this,Dr,i),Sc(this,Gr,a*n),Sc(this,Fr,r),yc(this,Or).set([NaN,NaN,NaN,NaN,e,s],6),Sc(this,Nr,o),Sc(this,zr,yc(t,Ur)*n),Sc(this,$r,yc(t,Xr)*n),Sc(this,jr,n),yc(this,Vr).push(e,s)}isEmpty(){return isNaN(yc(this,Or)[8])}add({x:t,y:e}){var s;Sc(this,Br,t),Sc(this,Hr,e);const[i,n,a,r]=yc(this,Dr);let[o,l,h,c]=yc(this,Or).subarray(8,12);const d=t-h,u=e-c,p=Math.hypot(d,u);if(p<yc(this,$r))return!1;const g=p-yc(this,zr),f=g/p,m=f*d,v=f*u;let w=o,b=l;o=h,l=c,h+=m,c+=v,null==(s=yc(this,Vr))||s.push(t,e);const A=m/g,_=-v/g*yc(this,Gr),y=A*yc(this,Gr);if(yc(this,Or).set(yc(this,Or).subarray(2,8),0),yc(this,Or).set([h+_,c+y],4),yc(this,Or).set(yc(this,Or).subarray(14,18),12),yc(this,Or).set([h-_,c-y],16),isNaN(yc(this,Or)[6]))return 0===yc(this,Wr).length&&(yc(this,Or).set([o+_,l+y],2),yc(this,Wr).push(NaN,NaN,NaN,NaN,(o+_-i)/a,(l+y-n)/r),yc(this,Or).set([o-_,l-y],14),yc(this,Lr).push(NaN,NaN,NaN,NaN,(o-_-i)/a,(l-y-n)/r)),yc(this,Or).set([w,b,o,l,h,c],6),!this.isEmpty();yc(this,Or).set([w,b,o,l,h,c],6);return Math.abs(Math.atan2(b-l,w-o)-Math.atan2(v,m))<Math.PI/2?([o,l,h,c]=yc(this,Or).subarray(2,6),yc(this,Wr).push(NaN,NaN,NaN,NaN,((o+
1h)/2-i)/a,((l+c)/2-n)/r),[o,l,w,b]=yc(this,Or).subarray(14,18),yc(this,Lr).push(NaN,NaN,NaN,NaN,((w+o)/2-i)/a,((b+l)/2-n)/r),!0):([w,b,o,l,h,c]=yc(this,Or).subarray(0,6),yc(this,Wr).push(((w+5*o)/6-i)/a,((b+5*l)/6-n)/r,((5*o+h)/6-i)/a,((5*l+c)/6-n)/r,((o+h)/2-i)/a,((l+c)/2-n)/r),[h,c,o,l,w,b]=yc(this,Or).subarray(12,18),yc(this,Lr).push(((w+5*o)/6-i)/a,((b+5*l)/6-n)/r,((5*o+h)/6-i)/a,((5*l+c)/6-n)/r,((o+h)/2-i)/a,((l+c)/2-n)/r),!0)}toSVGPath(){if(this.isEmpty())return"";const t=yc(this,Wr),e=yc(this,Lr);if(isNaN(yc(this,Or)[6])&&!this.isEmpty())return kc(this,Yr,Qr).call(this);const s=[];s.push(`M${t[4]} ${t[5]}`);for(let i=6;i<t.length;i+=6)isNaN(t[i])?s.push(`L${t[i+4]} ${t[i+5]}`):s.push(`C${t[i]} ${t[i+1]} ${t[i+2]} ${t[i+3]} ${t[i+4]} ${t[i+5]}`);kc(this,Yr,Zr).call(this,s);for(let i=e.length-6;i>=6;i-=6)isNaN(e[i])?s.push(`L${e[i+4]} ${e[i+5]}`):s.push(`C${e[i]} ${e[i+1]} ${e[i+2]} ${e[i+3]} ${e[i+4]} ${e[i+5]}`);return kc(this,Yr,Jr).call(this,s),s.join(" ")}newFreeDrawOutline(t,e,s,i,n,a){return new Rf(t,e,s,i,n,a)}getOutlines(){var t;const e=yc(this,Wr),s=yc(this,Lr),i=yc(this,Or),[n,a,r,o]=yc(this,Dr),l=new Float32Array(((null==(t=yc(this,Vr))?void 0:t.length)??0)+2);for(let d=0,u=l.length-2;d<u;d+=2)l[d]=(yc(this,Vr)[d]-n)/r,l[d+1]=(yc(this,Vr)[d+1]-a)/o;if(l[l.length-2]=(yc(this,Br)-n)/r,l[l.length-1]=(yc(this,Hr)-a)/o,isNaN(i[6])&&!this.isEmpty())return kc(this,Yr,to).call(this,l);const h=new Float32Array(yc(this,Wr).length+24+yc(this,Lr).length);let c=e.length;for(let d=0;d<c;d+=2)isNaN(e[d])?h[d]=h[d+1]=NaN:(h[d]=e[d],h[d+1]=e[d+1]);c=kc(this,Yr,so).call(this,h,c);for(let d=s.length-6;d>=6;d-=6)for(let t=0;t<6;t+=2)isNaN(s[d+t])?(h[c]=h[c+1]=NaN,c+=2):(h[c]=s[d+t],h[c+1]=s[d+t+1],c+=2);return kc(this,Yr,eo).call(this,h,c),this.newFreeDrawOutline(h,l,yc(this,Dr),yc(this,jr),yc(this,Nr),yc(this,Fr))}};Dr=new WeakMap,Lr=new WeakMap,Nr=new WeakMap,Fr=new WeakMap,Wr=new WeakMap,Or=new WeakMap,Br=new WeakMap,Hr=new WeakMap,$r=new WeakMap,zr=new WeakMap,jr=new WeakMap,Gr=new WeakMap,Vr=new WeakMap,Ur=new WeakMap,qr=new WeakMap,Xr=new WeakMap,Yr=new WeakSet,Kr=function(){const t=yc(this,Or).subarray(4,6),e=yc(this,Or).subarray(16,18),[s,i,n,a]=yc(this,Dr);return[(yc(this,Br)+(t[0]-e[0])/2-s)/n,(yc(this,Hr)+(t[1]-e[1])/2-i)/a,(yc(this,Br)+(e[0]-t[0])/2-s)/n,(yc(this,Hr)+(e[1]-t[1])/2-i)/a]},Qr=function(){const[t,e,s,i]=yc(this,Dr),[n,a,r,o]=kc(this,Yr,Kr).call(this);return`M${(yc(this,Or)[2]-t)/s} ${(yc(this,Or)[3]-e)/i} L${(yc(this,Or)[4]-t)/s} ${(yc(this,Or)[5]-e)/i} L${n} ${a} L${r} ${o} L${(yc(this,Or)[16]-t)/s} ${(yc(this,Or)[17]-e)/i} L${(yc(this,Or)[14]-t)/s} ${(yc(this,Or)[15]-e)/i} Z`},Jr=function(t){const e=yc(this,Lr);t.push(`L${e[4]} ${e[5]} Z`)},Zr=function(t){const[e,s,i,n]=yc(this,Dr),a=yc(this,Or).subarray(4,6),r=yc(this,Or).subarray(16,18),[o,l,h,c]=kc(this,Yr,Kr).call(this);t.push(`L${(a[0]-e)/i} ${(a[1]-s)/n} L${o} ${l} L${h} ${c} L${(r[0]-e)/i} ${(r[1]-s)/n}`)},to=function(t){const e=yc(this,Or),[s,i,n,a]=yc(this,Dr),[r,o,l,h]=kc(this,Yr,Kr).call(this),c=new Float32Array(36);return c.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,r,o,NaN,NaN,NaN,NaN,l,h,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(c,t,yc(this,Dr),yc(this,jr),yc(this,Nr),yc(this,Fr))},eo=function(t,e){const s=yc(this,Lr);return t.set([NaN,NaN,NaN,NaN,s[4],s[5]],e),e+6},so=function(t,e){const s=yc(this,Or).subarray(4,6),i=yc(this,Or).subarray(16,18),[n,a,r,o]=yc(this,Dr),[l,h,c,d]=kc(this,Yr,Kr).call(this);return t.set([NaN,NaN,NaN,NaN,(s[0]-n)/r,(s[1]-a)/o,NaN,NaN,NaN,NaN,l,h,NaN,NaN,NaN,NaN,c,d,NaN,NaN,NaN,NaN,(i[0]-n)/r,(i[1]-a)/o],e),e+24},xc(Cf,Ur,8),xc(Cf,qr,2),xc(Cf,Xr,yc(Cf,Ur)+yc(Cf,qr));let Tf=Cf;class Rf extends Ef{constructor(t,e,s,i,n,a){super(),xc(this,co),xc(this,io),xc(this,no,new Float32Array(4)),xc(this,ao),xc(this,ro),xc(this,oo),xc(this,lo),xc(this,ho),Sc(this,ho,t),Sc(this,oo,e),Sc(this,io,s),Sc(this,lo,i),Sc(this,ao,n),Sc(this,ro,a),this.lastPoint=[NaN,NaN],kc(this,co,uo).call(this,a);const[r,o,l,h]=yc(this,no);for(let c=0,d=t.length;c<d;c+=2)t[c]=(t[c]-r)/l,t[c+1]=(t[c+1]-o)/h;for(let c=0,d=e.length;c<d;c+=2)e[c]=(e[c]-r)/l,e[c+1]=(e[c+1]-o)/h}toSVGPath(){const t=[`M${yc(this,ho)[4]} ${yc(this,ho)[5]}`];for(let e=6,s=yc(this,ho).length;e<s;e+=6)isNaN(yc(this,ho)[e])?t.push(`L${yc(this,ho)[e+4]} ${yc(this,ho)[e+5]}`):t.push(`C${yc(this,ho)[e]} ${yc(this,ho)[e+1]} ${yc(this,ho)[e+2]} ${yc(this,ho)[e+3]} ${yc(this,ho)[e+4]} ${yc(this,ho)[e+5]}`);return t.push("Z"),t.join(" ")}serialize([t,e,s,i],n){const a=s-t,r=i-e;let o,l;switch(n){case 0:o=Ef._rescale(yc(this,ho),t,i,a,-r),l=Ef._rescale(yc(this,oo),t,i,a,-r);break;case 90:o=Ef._rescaleAndSwap(yc(this,ho),t,e,a,r),l=Ef._rescaleAndSwap(yc(this,oo),t,e,a,r);break;case 180:o=Ef._rescale(yc(this,ho),s,e,-a,r),l=Ef._rescale(yc(this,oo),s,e,-a,r);break;case 270:o=Ef._rescaleAndSwap(yc(this,ho),s,i,-a,-r),l=Ef._rescaleAndSwap(yc(this,oo),s,i,-a,-r)}return{outline:Array.from(o),points:[Array.from(l)]}}get box(){return yc(this,no)}newOutliner(t,e,s,i,n,a=0){return new Tf(t,e,s,i,n,a)}getNewOutline(t,e){const[s,i,n,a]=yc(this,no),[r,o,l,h]=yc(this,io),c=n*l,d=a*h,u=s*l+r,p=i*h+o,g=this.newOutliner({x:yc(this,oo)[0]*c+u,y:yc(this,oo)[1]*d+p},yc(this,io),yc(this,lo),t,yc(this,ro),e??yc(this,ao));for(let f=2;f<yc(this,oo).length;f+=2)g.add({x:yc(this,oo)[f]*c+u,y:yc(this,oo)[f+1]*d+p});return g.getOutlines()}}io=new WeakMap,no=new WeakMap,ao=new WeakMap,ro=new WeakMap,oo=new WeakMap,lo=new WeakMap,ho=new WeakMap,co=new WeakSet,uo=function(t){const e=yc(this,ho);let s=e[4],i=e[5];const n=[s,i,s,i];let a=s,r=i;const o=t?Math.max:Math.min;for(let h=6,c=e.length;h<c;h+=6){const t=e[h+4],l=e[h+5];if(isNaN(e[h]))Cd.pointBoundingBox(t,l,n),r<l?(a=t,r=l):r===l&&(a=o(a,t));else{const t=[1/0,1/0,-1/0,-1/0];Cd.bezierBoundingBox(s,i,...e.slice(h,h+6),t),Cd.rectBoundingBox(...t,n),r<t[3]?(a=t[2],r=t[3]):r===t[3]&&(a=o(a,t[2]))}s=t,i=l}const l=yc(this,no);l[0]=n[0]-yc(this,ao),l[1]=n[1]-yc(this,ao),l[2]=n[2]-n[0]+2*yc(this,ao),l[3]=n[3]-n[1]+2*yc(this,ao),this.lastPoint=[a,r]};class Pf{constructor(t,e=0,s=0,i=!0){xc(this,vo),xc(this,po),xc(this,go),xc(this,fo,[]),xc(this,mo,[]);const n=[1/0,1/0,-1/0,-1/0],a=10**-4;for(const{x:u,y:p,width:g,height:f}of t){const t=Math.floor((u-e)/a)*a,s=Math.ceil((u+g+e)/a)*a,i=Math.floor((p-e)/a)*a,r=Math.ceil((p+f+e)/a)*a,o=[t,i,r,!0],l=[s,i,r,!1];yc(this,fo).push(o,l),Cd.rectBoundingBox(t,i,s,r,n)}const r=n[2]-n[0]+2*s,o=n[3]-n[1]+2*s,l=n[0]-s,h=n[1]-s,c=yc(this,fo).at(i?-1:-2),d=[c[0],c[2]];for(const u of yc(this,fo)){const[t,e,s]=u;u[0]=(t-l)/r,u[1]=(e-h)/o,u[2]=(s-h)/o}Sc(this,po,new Float32Array([l,h,r,o])),Sc(this,go,d)}getOutlines(){yc(this,fo).sort((t,e)=>t[0]-e[0]||t[1]-e[1]||t[2]-e[2]);const t=[];for(const e of yc(this,fo))e[3]?(t.push(...kc(this,vo,yo).call(this,e)),kc(this,vo,Ao).call(this,e)):(kc(this,vo,_o).call(this,e),t.push(...kc(this,vo,yo).call(this,e)));return kc(this,vo,wo).call(this,t)}}po=new WeakMap,go=new WeakMap,fo=new WeakMap,mo=new WeakMap,vo=new WeakSet,wo=function(t){const e=[],s=new Set;for(const a of t){const[t,s,i]=a;e.push([t,s,a],[t,i,a])}e.sort((t,e)=>t[1]-e[1]||t[0]-e[0]);for(let a=0,r=e.length;a<r;a+=2){const t=e[a][2],i=e[a+1][2];t.push(i),i.push(t),s.add(t),s.add(i)}const i=[];let n;for(;s.size>0;){const t=s.values().next().value;let[e,a,r,o,l]=t;s.delete(t);let h=e,c=a;for(n=[e,r],i.push(n);;){let t;if(s.has(o))t=o;else{if(!s.has(l))break;t=l}s.delete(t),[e,a,r,o,l]=t,h!==e&&(n.push(h,c,e,c===a?a:r),h=e),c=c===a?r:a}n.push(h,c)}return new If(i,yc(this,po),yc(this,go))},bo=function(t){const e=yc(this,mo);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<t?s=n+1:i=n-1}return i+1},Ao=function([,t,e]){const s=kc(this,vo,bo).call(this,t);yc(this,mo).splice(s,0,[t,e])},_o=function([,t,e]){const s=kc(this,vo,bo).call(this,t);for(let i=s;i<yc(this,mo).length;i++){const[s,n]=yc(this,mo)[i];if(s!==t)break;
1if(s===t&&n===e)return void yc(this,mo).splice(i,1)}for(let i=s-1;i>=0;i--){const[s,n]=yc(this,mo)[i];if(s!==t)break;if(s===t&&n===e)return void yc(this,mo).splice(i,1)}},yo=function(t){const[e,s,i]=t,n=[[e,s,i]],a=kc(this,vo,bo).call(this,i);for(let r=0;r<a;r++){const[t,s]=yc(this,mo)[r];for(let i=0,a=n.length;i<a;i++){const[,r,o]=n[i];if(!(s<=r||o<=t))if(r>=t)if(o>s)n[i][1]=s;else{if(1===a)return[];n.splice(i,1),i--,a--}else n[i][2]=t,o>s&&n.push([e,s,o])}}return n};class If extends Ef{constructor(t,e,s){super(),xc(this,xo),xc(this,So),Sc(this,So,t),Sc(this,xo,e),this.lastPoint=s}toSVGPath(){const t=[];for(const e of yc(this,So)){let[s,i]=e;t.push(`M${s} ${i}`);for(let n=2;n<e.length;n+=2){const a=e[n],r=e[n+1];a===s?(t.push(`V${r}`),i=r):r===i&&(t.push(`H${a}`),s=a)}t.push("Z")}return t.join(" ")}serialize([t,e,s,i],n){const a=[],r=s-t,o=i-e;for(const l of yc(this,So)){const e=new Array(l.length);for(let s=0;s<l.length;s+=2)e[s]=t+l[s]*r,e[s+1]=i-l[s+1]*o;a.push(e)}return a}get box(){return yc(this,xo)}get classNamesForOutlining(){return["highlightOutline"]}}xo=new WeakMap,So=new WeakMap;class Df extends Tf{newFreeDrawOutline(t,e,s,i,n,a){return new Lf(t,e,s,i,n,a)}}class Lf extends Rf{newOutliner(t,e,s,i,n,a=0){return new Df(t,e,s,i,n,a)}}const Nf=class t extends xu{constructor(e){super({...e,name:"highlightEditor"}),xc(this,jo),xc(this,ko,null),xc(this,Mo,0),xc(this,Eo),xc(this,Co,null),xc(this,To,null),xc(this,Ro,null),xc(this,Po,null),xc(this,Io,0),xc(this,Do,null),xc(this,Lo,null),xc(this,No,null),xc(this,Fo,!1),xc(this,Wo,null),xc(this,Oo),xc(this,Bo,null),xc(this,Ho,""),xc(this,$o),xc(this,zo,""),this.color=e.color||t._defaultColor,Sc(this,$o,e.thickness||t._defaultThickness),Sc(this,Oo,e.opacity||t._defaultOpacity),Sc(this,Eo,e.boxes||null),Sc(this,zo,e.methodOfCreation||""),Sc(this,Ho,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>
vendor: 14,120 bytes, line 1
1-1?(Sc(this,Fo,!0),kc(this,jo,Vo).call(this,e),kc(this,jo,Ko).call(this)):yc(this,Eo)&&(Sc(this,ko,e.anchorNode),Sc(this,Mo,e.anchorOffset),Sc(this,Po,e.focusNode),Sc(this,Io,e.focusOffset),kc(this,jo,Go).call(this),kc(this,jo,Ko).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=t.prototype;return md(this,"_keyboardManager",new uu([[["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:yc(this,Fo)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:yc(this,$o),methodOfCreation:yc(this,zo)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}get commentColor(){return this.color}static computeTelemetryFinalData(t){return{numberOfColors:t.get("color").size}}static initialize(e,s){var i;xu.initialize(e,s),t._defaultColor||(t._defaultColor=(null==(i=s.highlightColors)?void 0:i.values().next().value)||"#fff066")}static updateDefaultParams(e,s){switch(e){case $c.HIGHLIGHT_COLOR:t._defaultColor=s;break;case $c.HIGHLIGHT_THICKNESS:t._defaultThickness=s}}translateInPage(t,e){}get toolbarPosition(){return yc(this,Wo)}updateParams(t,e){switch(t){case $c.HIGHLIGHT_COLOR:kc(this,jo,Uo).call(this,e);break;case $c.HIGHLIGHT_THICKNESS:kc(this,jo,qo).call(this,e)}}static get defaultPropertiesToUpdate(){return[[$c.HIGHLIGHT_COLOR,t._defaultColor],[$c.HIGHLIGHT_THICKNESS,t._defaultThickness]]}get propertiesToUpdate(){return[[$c.HIGHLIGHT_COLOR,this.color||t._defaultColor],[$c.HIGHLIGHT_THICKNESS,yc(this,$o)||t._defaultThickness],[$c.HIGHLIGHT_FREE,yc(this,Fo)]]}get toolbarButtons(){if(this._uiManager.highlightColors){return[["colorPicker",Sc(this,To,new Og({editor:this}))]]}return super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(kc(this,jo,el).call(this))}getBaseTranslation(){return[0,0]}getRect(t,e){return super.getRect(t,e,kc(this,jo,el).call(this))}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),t&&this.div.focus()}remove(){kc(this,jo,Yo).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(kc(this,jo,Ko).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let s=!1;this.parent&&!t?kc(this,jo,Yo).call(this):t&&(kc(this,jo,Ko).call(this,t),s=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),this.show(this._isVisible),s&&this.select()}rotate(e){var s,i,n;const{drawLayer:a}=this.parent;let r;yc(this,Fo)?(e=(e-this.rotation+360)%360,r=kc(s=t,Qo,Jo).call(s,yc(this,Lo).box,e)):r=kc(i=t,Qo,Jo).call(i,[this.x,this.y,this.width,this.height],e),a.updateProperties(yc(this,No),{bbox:r,root:{"data-main-rotation":e}}),a.updateProperties(yc(this,Bo),{bbox:kc(n=t,Qo,Jo).call(n,yc(this,Ro).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const t=super.render();yc(this,Ho)&&(t.setAttribute("aria-label",yc(this,Ho)),t.setAttribute("role","mark")),yc(this,Fo)?t.classList.add("free"):this.div.addEventListener("keydown",kc(this,jo,Zo).bind(this),{signal:this._uiManager._signal});const e=Sc(this,Do,document.createElement("div"));t.append(e),e.setAttribute("aria-hidden","true"),e.className="internal",e.style.clipPath=yc(this,Co);const[s,i]=this.parentDimensions;return this.setDims(this.width*s,this.height*i),ou(this,yc(this,Do),["pointerover","pointerleave"]),this.enableEditing(),t}pointerover(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(yc(this,Bo),{rootClass:{hovered:!0}})}pointerleave(){var t;this.isSelected||null==(t=this.parent)||t.drawLayer.updateProperties(yc(this,Bo),{rootClass:{hovered:!1}})}_moveCaret(t){switch(this.parent.unselect(this),t){case 0:case 2:kc(this,jo,tl).call(this,!0);break;case 1:case 3:kc(this,jo,tl).call(this,!1)}}select(){var t;super.select(),yc(this,Bo)&&(null==(t=this.parent)||t.drawLayer.updateProperties(yc(this,Bo),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var t;super.unselect(),yc(this,Bo)&&(null==(t=this.parent)||t.drawLayer.updateProperties(yc(this,Bo),{rootClass:{selected:!1}}),yc(this,Fo)||kc(this,jo,tl).call(this,!1))}get _mustFixPosition(){return!yc(this,Fo)}show(t=this._isVisible){super.show(t),this.parent&&(this.parent.drawLayer.updateProperties(yc(this,No),{rootClass:{hidden:!t}}),this.parent.drawLayer.updateProperties(yc(this,Bo),{rootClass:{hidden:!t}}))}static startHighlighting(t,e,{target:s,x:i,y:n}){const{x:a,y:r,width:o,height:l}=s.getBoundingClientRect(),h=new AbortController,c=t.combinedSignal(h),d=e=>{h.abort(),kc(this,Qo,al).call(this,t,e)};window.addEventListener("blur",d,{signal:c}),window.addEventListener("pointerup",d,{signal:c}),window.addEventListener("pointerdown",Yd,{capture:!0,passive:!1,signal:c}),window.addEventListener("contextmenu",Xd,{signal:c}),s.addEventListener("pointermove",kc(this,Qo,nl).bind(this,t),{signal:c}),this._freeHighlight=new Df({x:i,y:n},[a,r,o,l],t.scale,this._defaultThickness/2,e,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static async deserialize(t,e,s){var i,n,a,r;let o=null;if(t instanceof vf){const{data:{quadPoints:e,rect:s,rotation:i,id:n,color:a,opacity:r,popupRef:l,contentsObj:h},parent:{page:{pageNumber:c}}}=t;o=t={annotationType:Hc.HIGHLIGHT,color:Array.from(a),opacity:r,quadPoints:e,boxes:null,pageIndex:c-1,rect:s.slice(0),rotation:i,annotationElementId:n,id:n,deleted:!1,popupRef:l,comment:(null==h?void 0:h.str)||null}}else if(t instanceof mf){const{data:{inkLists:e,rect:s,rotation:i,id:n,color:a,borderStyle:{rawWidth:r},popupRef:l,contentsObj:h},parent:{page:{pageNumber:c}}}=t;o=t={annotationType:Hc.HIGHLIGHT,color:Array.from(a),thickness:r,inkLists:e,boxes:null,pageIndex:c-1,rect:s.slice(0),rotation:i,annotationElementId:n,id:n,deleted:!1,popupRef:l,comment:(null==h?void 0:h.str)||null}}const{color:l,quadPoints:h,inkLists:c,opacity:d}=t,u=await super.deserialize(t,e,s);u.color=Cd.makeHexColor(...l),Sc(u,Oo,d||1),c&&Sc(u,$o,t.thickness),u._initialData=o,t.comment&&u.setCommentData(t.comment);const[p,g]=u.pageDimensions,[f,m]=u.pageTranslation;if(h){const t=Sc(u,Eo,[]);for(let e=0;e<h.length;e+=8)t.push({x:(h[e]-f)/p,y:1-(h[e+1]-m)/g,width:(h[e+2]-h[e])/p,height:(h[e+1]-h[e+5])/g});kc(i=u,jo,Go).call(i),kc(n=u,jo,Ko).call(n),u.rotate(u.rotation)}else if(c){Sc(u,Fo,!0);const t=c[0],s={x:t[0]-f,y:g-(t[1]-m)},i=new Df(s,[0,0,p,g],1,yc(u,$o)/2,!0,.001);for(let e=0,a=t.length;e<a;e+=2)s.x=t[e]-f,s.y=g-(t[e+1]-m),i.add(s);const{id:n,clipPathId:o}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:u.color,"fill-opacity":u._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:i.toSVGPath()}},!0,!0);kc(a=u,jo,Vo).call(a,{highlightOutlines:i.getOutlines(),highlightId:n,clipPathId:o}),kc(r=u,jo,Ko).call(r),u.rotate(u.parentRotation)}return u}serialize(t=!1){if(this.isEmpty()||t)return null;if(this.deleted)return this.serializeDeleted();const e=this.getRect(0,0),s=xu._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),i={annotationType:Hc.HIGHLIGHT,color:s,opacity:yc(this,Oo),thickness:yc(this,$o),quadPoints:kc(this,jo,sl).call(this),outlines:kc(this,jo,il).call(this,e),pageIndex:this.pageIndex,rect:e,rotation:kc(this,jo,el).call(this),structTreeParentId:this._structTreeParentId};return this.addComment(i),this.annotationElementId&&!kc(this,jo,rl).call(this,i)?null:(i.id=this.annotationElementId,i)}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}static canCreateNewEmptyEditor(){return!1}};ko=new WeakMap,Mo=new WeakMap,Eo=new WeakMap,Co=new WeakMap,To=new WeakMap,Ro=new WeakMap,Po=new WeakMap,Io=new WeakMap,Do=new WeakMap,Lo=new WeakMap,No=new WeakMap,Fo=new WeakMap,Wo=new WeakMap,Oo=new WeakMap,Bo=new WeakMap,Ho=new WeakMap,$o=new WeakMap,zo=new WeakMap,jo=new WeakSet,Go=function(){const t=new Pf(yc(this,Eo),.001);Sc(this,Lo,t.getOutlines()),[this.x,this.y,this.width,this.height]=yc(this,Lo).box;const e=new Pf(yc(this,Eo),.0025,.001,"ltr"===this._uiManager.direction);Sc(this,Ro,e.getOutlines());const{lastPoint:s}=yc(this,Ro);Sc(this,Wo,[(s[0]-this.x)/this.width,(s[1]-this.y)/this.height])},Vo=function({highlightOutlines:t,highlightId:e,clipPathId:s}){var i,n;Sc(this,Lo,t);if(Sc(this,Ro,t.getNewOutline(yc(this,$o)/2+1.5,.0025)),e>=0)Sc(this,No,e),Sc(this,Co,s),this.parent.drawLayer.finalizeDraw(e,{bbox:t.box,path:{d:t.toSVGPath()}}),Sc(this,Bo,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:yc(this,Ro).box,path:{d:yc(this,Ro).toSVGPath()}},!0));else if(this.parent){const e=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(yc(this,No),{bbox:kc(i=Nf,Qo,Jo).call(i,yc(this,Lo).box,(e-this.rotation+360)%360),path:{d:t.toSVGPath()}}),this.parent.drawLayer.updateProperties(yc(this,Bo),{bbox:kc(n=Nf,Qo,Jo).call(n,yc(this,Ro).box,e),path:{d:yc(this,Ro).toSVGPath()}})}const[a,r,o,l]=t.box;switch(this.rotation){case 0:this.x=a,this.y=r,this.width=o,this.height=l;break;case 90:{const[t,e]=this.parentDimensions;this.x=r,this.y=1-a,this.width=o*e/t,this.height=l*t/e;break}case 180:this.x=1-a,this.y=1-r,this.width=o,this.height=l;break;case 270:{const[t,e]=this.parentDimensions;this.x=1-r,this.y=a,this.width=o*e/t,this.height=l*t/e;break}}const{lastPoint:h}=yc(this,Ro);Sc(this,Wo,[(h[0]-a)/o,(h[1]-r)/l])},Uo=function(t){const e=(t,e)=>{var s,i;this.color=t,Sc(this,Oo,e),null==(s=this.parent)||s.drawLayer.updateProperties(yc(this,No),{root:{fill:t,"fill-opacity":e}}),null==(i=yc(this,To))||i.updateColor(t)},s=this.color,i=yc(this,Oo);this.addCommands({cmd:e.bind(this,t,Nf._defaultOpacity),undo:e.bind(this,s,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$c.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(t)},!0)},qo=function(t){const e=yc(this,$o),s=t=>{Sc(this,$o,t),kc(this,jo,Xo).call(this,t)};this.addCommands({cmd:s.bind(this,t),undo:s.bind(this,e),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:$c.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:t},!0)},Xo=function(t){if(!yc(this,Fo))return;kc(this,jo,Vo).call(this,{highlightOutlines:yc(this,Lo).getNewOutline(t/2)}),this.fixAndSetPosition();const[e,s]=this.parentDimensions;this.setDims(this.width*e,this.height*s)},Yo=function(){null!==yc(this,No)&&this.parent&&(this.parent.drawLayer.remove(yc(this,No)),Sc(this,No,null),this.parent.drawLayer.remove(yc(this,Bo)),Sc(this,Bo,null))},Ko=function(t=this.parent){null===yc(this,No)&&(({id:Mc(this,No)._,clipPathId:Mc(this,Co)._}=t.drawLayer.draw({bbox:yc(this,Lo).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":yc(this,Oo)},rootClass:{highlight:!0,free:yc(this,Fo)},path:{d:yc(this,Lo).toSVGPath()}},!1,!0)),Sc(this,Bo,t.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:yc(this,Fo)},bbox:yc(this,Ro).box,path:{d:yc(this,Ro).toSVGPath()}},yc(this,Fo))),yc(this,Do)&&(yc(this,Do).style.clipPath=yc(this,Co)))},Qo=new WeakSet,Jo=function([t,e,s,i],n){switch(n){case 90:return[1-e-i,t,i,s];case 180:return[1-t-s,1-e-i,s,i];case 270:return[e,1-t-s,i,s]}return[t,e,s,i]},Zo=function(t){Nf._keyboardManager.exec(this,t)},tl=function(t){if(!yc(this,ko))return;const e=window.getSelection();t?e.setPosition(yc(this,ko),yc(this,Mo)):e.setPosition(yc(this,Po),yc(this,Io))},el=function(){return yc(this,Fo)?this.rotation:0},sl=function(){if(yc(this,Fo))return null;const[t,e]=this.pageDimensions,[s,i]=this.pageTranslation,n=yc(this,Eo),a=new Float32Array(8*n.length);let r=0;for(const{x:o,y:l,width:h,height:c}of n){const n=o*t+s,d=(1-l)*e+i;a[r]=a[r+4]=n,a[r+1]=a[r+3]=d,a[r+2]=a[r+6]=n+h*t,a[r+5]=a[r+7]=d-c*e,r+=8}return a},il=function(t){return yc(this,Lo).serialize(t,kc(this,jo,el).call(this))},nl=function(t,e){this._freeHighlight.add(e)&&t.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},al=function(t,e){this._freeHighlight.isEmpty()?t.drawLayer.remove(this._freeHighlightId):t.createAndAddNewEditor(e,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},rl=function(t){const{color:e}=this._initialData;return this.hasEditedComment||t.color.some((t,s)=>t!==e[s])},xc(Nf,Qo),Ac(Nf,"_defaultColor",null),Ac(Nf,"_defaultOpacity",1),Ac(Nf,"_defaultThickness",12),Ac(Nf,"_type","highlight"),Ac(Nf,"_editorType",Hc.HIGHLIGHT),Ac(Nf,"_freeHighlightId",-1),Ac(Nf,"_freeHighlight",null),Ac(Nf,"_freeHighlightClipId","");let Ff=Nf;class Wf{constructor(){xc(this,ol,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,s]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,s)}updateSVGProperty(t,e){yc(this,ol)[t]=e}toSVGProperties(){const t=yc(this,ol);return Sc(this,ol,Object.create(null)),{root:t}}reset(){Sc(this,ol,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){ud("Not implemented")}}ol=new WeakMap;const Of=class t extends xu{constructor(t){super(t),xc(this,vl),xc(this,ll,null),xc(this,hl),Ac(this,"_colorPicker",null),Ac(this,"_drawId",null),Sc(this,hl,t.mustBeCommitted||!1),this._addOutlines(t)}
1_addOutlines(t){t.drawOutlines&&(kc(this,vl,wl).call(this,t),kc(this,vl,_l).call(this))}static _mergeSVGProperties(t,e){const s=new Set(Object.keys(t));for(const[i,n]of Object.entries(e))s.has(i)?Object.assign(t[i],n):t[i]=n;return t}static getDefaultDrawingOptions(t){ud("Not implemented")}static get typesMap(){ud("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,s){const i=this.typesMap.get(e);i&&this._defaultDrawingOptions.updateProperty(i,s),this._currentParent&&(yc(t,cl).updateProperty(i,s),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(t,e){const s=this.constructor.typesMap.get(t);s&&this._updateProperty(t,s,e)}static get defaultPropertiesToUpdate(){const t=[],e=this._defaultDrawingOptions;for(const[s,i]of this.typesMap)t.push([s,e[i]]);return t}get propertiesToUpdate(){const t=[],{_drawingOptions:e}=this;for(const[s,i]of this.constructor.typesMap)t.push([s,e[i]]);return t}_updateProperty(t,e,s){const i=this._drawingOptions,n=i[e],a=s=>{var n,a;i.updateProperty(e,s);const r=yc(this,ll).updateProperty(e,s);r&&kc(this,vl,Sl).call(this,r),null==(n=this.parent)||n.drawLayer.updateProperties(this._drawId,i.toSVGProperties()),t===this.colorType&&(null==(a=this._colorPicker)||a.update(s))};this.addCommands({cmd:a.bind(this,s),undo:a.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:t,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(yc(this,ll).getPathResizingSVGProperties(kc(this,vl,xl).call(this)),{bbox:kc(this,vl,kl).call(this)}))}_onResized(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(yc(this,ll).getPathResizedSVGProperties(kc(this,vl,xl).call(this)),{bbox:kc(this,vl,kl).call(this)}))}_onTranslating(t,e){var s;null==(s=this.parent)||s.drawLayer.updateProperties(this._drawId,{bbox:kc(this,vl,kl).call(this)})}_onTranslated(){var e;null==(e=this.parent)||e.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties(yc(this,ll).getPathTranslatedSVGProperties(kc(this,vl,xl).call(this),this.parentDimensions),{bbox:kc(this,vl,kl).call(this)}))}_onStartDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var t;null==(t=this.parent)||t.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(t){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,yc(this,hl)&&(Sc(this,hl,!1),this.commit(),this.parent.setSelected(this),t&&this.isOnScreen&&this.div.focus())}remove(){kc(this,vl,Al).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(kc(this,vl,_l).call(this),kc(this,vl,Sl).call(this,yc(this,ll).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(t){var e;let s=!1;this.parent&&!t?(this._uiManager.removeShouldRescale(this),kc(this,vl,Al).call(this)):t&&(this._uiManager.addShouldRescale(this),kc(this,vl,_l).call(this,t),s=!this.parent&&(null==(e=this.div)?void 0:e.classList.contains("selectedEditor"))),super.setParent(t),s&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,t._mergeSVGProperties({bbox:kc(this,vl,kl).call(this)},yc(this,ll).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&kc(this,vl,Sl).call(this,yc(this,ll).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let t,e;this._isCopy&&(t=this.x,e=this.y);const s=super.render();s.classList.add("draw");const i=document.createElement("div");s.append(i),i.setAttribute("aria-hidden","true"),i.className="internal";const[n,a]=this.parentDimensions;return this.setDims(this.width*n,this.height*a),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(t,e),s}static createDrawerInstance(t,e,s,i,n){ud("Not implemented")}static startDrawing(e,s,i,n){var a;const{target:r,offsetX:o,offsetY:l,pointerId:h,pointerType:c}=n;if(yc(t,gl)&&yc(t,gl)!==c)return;const{viewport:{rotation:d}}=e,{width:u,height:p}=r.getBoundingClientRect(),g=Sc(t,dl,new AbortController),f=e.combinedSignal(g);yc(t,pl)||Sc(t,pl,h),yc(t,gl)??Sc(t,gl,c),window.addEventListener("pointerup",e=>{var s;yc(t,pl)===e.pointerId?this._endDraw(e):null==(s=yc(t,fl))||s.delete(e.pointerId)},{signal:f}),window.addEventListener("pointercancel",e=>{var s;yc(t,pl)===e.pointerId?this._currentParent.endDrawingSession():null==(s=yc(t,fl))||s.delete(e.pointerId)},{signal:f}),window.addEventListener("pointerdown",e=>{yc(t,gl)===e.pointerType&&((yc(t,fl)||Sc(t,fl,new Set)).add(e.pointerId),yc(t,cl).isCancellable()&&(yc(t,cl).removeLastElement(),yc(t,cl).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",Xd,{signal:f}),r.addEventListener("pointermove",this._drawMove.bind(this),{signal:f}),r.addEventListener("touchmove",e=>{e.timeStamp===yc(t,ml)&&Yd(e)},{signal:f}),e.toggleDrawing(),null==(a=s._editorUndoBar)||a.hide(),yc(t,cl)?e.drawLayer.updateProperties(this._currentDrawId,yc(t,cl).startNew(o,l,u,p,d)):(s.updateUIForDefaultProperties(this),Sc(t,cl,this.createDrawerInstance(o,l,u,p,d)),Sc(t,ul,this.getDefaultDrawingOptions()),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(yc(t,ul).toSVGProperties(),yc(t,cl).defaultSVGProperties),!0,!1)))}static _drawMove(e){var s;if(Sc(t,ml,-1),!yc(t,cl))return;const{offsetX:i,offsetY:n,pointerId:a}=e;yc(t,pl)===a&&((null==(s=yc(t,fl))?void 0:s.size)>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,yc(t,cl).add(i,n)),Sc(t,ml,e.timeStamp),Yd(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,Sc(t,cl,null),Sc(t,ul,null),Sc(t,gl,null),Sc(t,ml,NaN)),yc(t,dl)&&(yc(t,dl).abort(),Sc(t,dl,null),Sc(t,pl,NaN),Sc(t,fl,null))}static _endDraw(e){const s=this._currentParent;if(s){if(s.toggleDrawing(!0),this._cleanup(!1),(null==e?void 0:e.target)===s.div&&s.drawLayer.updateProperties(this._currentDrawId,yc(t,cl).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=yc(t,cl),i=this._currentDrawId,n=e.getLastElement();return void s.addCommands({cmd:()=>{s.drawLayer.updateProperties(i,e.setLastElement(n))},undo:()=>{s.drawLayer.updateProperties(i,e.removeLastElement())},mustExec:!1,type:$c.DRAW_STEP})}this.endDrawing(!1)}}static endDrawing(e){const s=this._currentParent;if(!s)return null;if(s.toggleDrawing(!0),s.cleanUndoStack($c.DRAW_STEP),!yc(t,cl).isEmpty()){const{pageDimensions:[i,n],scale:a}=s,r=s.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:yc(t,cl).getOutlines(i*a,n*a,a,this._INNER_MARGIN),drawingOptions:yc(t,ul),mustBeCommitted:!e});return this._cleanup(!0),r}return s.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(t){}static deserializeDraw(t,e,s,i,n,a){ud("Not implemented")}static async deserialize(t,e,s){var i,n;const{rawDims:{pageWidth:a,pageHeight:r,pageX:o,pageY:l}}=e.viewport,h=this.deserializeDraw(o,l,a,r,this._INNER_MARGIN,t),c=await super.deserialize(t,e,s);return c.createDrawingOptions(t),kc(i=c,vl,wl).call(i,{drawOutlines:h}),kc(n=c,vl,_l).call(n),c.onScaleChanging(),c.rotate(),c}serializeDraw(t){const[e,s]=this.pageTranslation,[i,n]=this.pageDimensions;return yc(this,ll).serialize([e,s,i,n],t)}renderAnnotationElement(t){return t.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}};ll=new WeakMap,hl=new WeakMap,cl=new WeakMap,dl=new WeakMap,ul=new WeakMap,pl=new WeakMap,gl=new WeakMap,fl=new WeakMap,ml=new WeakMap,vl=new WeakSet,wl=function({drawOutlines:t,drawId:e,drawingOptions:s}){Sc(this,ll,t),this._drawingOptions||(this._drawingOptions=s),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),e>=0?(this._drawId=e,this.parent.drawLayer.finalizeDraw(e,t.defaultProperties)):this._drawId=kc(this,vl,bl).call(this,t,this.parent),kc(this,vl,Sl).call(this,t.box)},bl=function(t,e){const{id:s}=e.drawLayer.draw(Of._mergeSVGProperties(this._drawingOptions.toSVGProperties(),t.defaultSVGProperties),!1,!1);return s},Al=function(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},_l=function(t=this.parent){null!==this._drawId&&this.parent===t||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=kc(this,vl,bl).call(this,yc(this,ll),t)):this.parent.drawLayer.updateParent(this._drawId,t.drawLayer))},yl=function([t,e,s,i]){const{parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[e,1-t,s*(a/n),i*(n/a)];case 180:return[1-t,1-e,s,i];case 270:return[1-e,t,s*(a/n),i*(n/a)];default:return[t,e,s,i]}},xl=function(){const{x:t,y:e,width:s,height:i,parentDimensions:[n,a],rotation:r}=this;switch(r){case 90:return[1-e,t,s*(n/a),i*(a/n)];case 180:return[1-t,1-e,s,i];case 270:return[e,1-t,s*(n/a),i*(a/n)];default:return[t,e,s,i]}},Sl=function(t){if([this.x,this.y,this.width,this.height]=kc(this,vl,yl).call(this,t),this.div){this.fixAndSetPosition();const[t,e]=this.parentDimensions;this.setDims(this.width*t,this.height*e)}this._onResized()},kl=function(){const{x:t,y:e,width:s,height:i,rotation:n,parentRotation:a,parentDimensions:[r,o]}=this;switch((4*n+a)/90){case 1:return[1-e-i,t,i,s];case 2:return[1-t-s,1-e-i,s,i];case 3:return[e,1-t-s,i,s];case 4:return[t,e-s*(r/o),i*(o/r),s*(r/o)];case 5:return[1-e,t,s*(r/o),i*(o/r)];case 6:return[1-t-i*(o/r),1-e,i*(o/r),s*(r/o)];case 7:return[e-s*(r/o),1-t-i*(o/r),s*(r/o),i*(o/r)];case 8:return[t-s,e-i,s,i];case 9:return[1-e,t-s,i,s];case 10:return[1-t,1-e,s,i];case 11:return[e-i,1-t,i,s];case 12:return[t-i*(o/r),e,i*(o/r),s*(r/o)];case 13:return[1-e-s*(r/o),t-i*(o/r),s*(r/o),i*(o/r)];case 14:return[1-t,1-e-s*(r/o),i*(o/r),s*(r/o)];case 15:return[e,1-t,s*(r/o),i*(o/r)];default:return[t,e,s,i]}},Ac(Of,"_currentDrawId",-1),Ac(Of,"_currentParent",null),xc(Of,cl,null),xc(Of,dl,null),xc(Of,ul,null),xc(Of,pl,NaN),xc(Of,gl,null),xc(Of,fl,null),xc(Of,ml,NaN),Ac(Of,"_INNER_MARGIN",3);let Bf=Of;class Hf{constructor(t,e,s,i,n,a){xc(this,Wl),xc(this,Ml,new Float64Array(6)),xc(this,El),xc(this,Cl),xc(this,Tl),xc(this,Rl),xc(this,Pl),xc(this,Il,""),xc(this,Dl,0),xc(this,Ll,new $f),xc(this,Nl),xc(this,Fl),Sc(this,Nl,s),Sc(this,Fl,i),Sc(this,Tl,n),Sc(this,Rl,a),[t,e]=kc(this,Wl,Ol).call(this,t,e);const r=Sc(this,El,[NaN,NaN,NaN,NaN,t,e]);Sc(this,Pl,[t,e]),Sc(this,Cl,[{line:r,points:yc(this,Pl)}]),yc(this,Ml).set(r,0)}updateProperty(t,e){"stroke-width"===t&&Sc(this,Rl,e)}isEmpty(){return!yc(this,Cl)||0===yc(this,Cl).length}isCancellable(){return yc(this,Pl).length<=10}add(t,e){[t,e]=kc(this,Wl,Ol).call(this,t,e);const[s,i,n,a]=yc(this,Ml).subarray(2,6),r=t-n,o=e-a;return Math.hypot(yc(this,Nl)*r,yc(this,Fl)*o)<=2?null:(yc(this,Pl).push(t,e),isNaN(s)?(yc(this,Ml).set([n,a,t,e],2),yc(this,El).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(yc(this,Ml)[0])&&yc(this,El).splice(6,6),yc(this,Ml).set([s,i,n,a,t,e],0),yc(this,El).push(...Ef.createBezierPoints(s,i,n,a,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const s=this.add(t,e);return s||(2===yc(this,Pl).length?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,s,i,n){Sc(this,Nl,s),Sc(this,Fl,i),Sc(this,Tl,n),[t,e]=kc(this,Wl,Ol).call(this,t,e);const a=Sc(this,El,[NaN,NaN,NaN,NaN,t,e]);Sc(this,Pl,[t,e]);const r=yc(this,Cl).at(-1);return r&&(r.line=new Float32Array(r.line),r.points=new Float32Array(r.points)),yc(this,Cl).push({line:a,points:yc(this,Pl)}),yc(this,Ml).set(a,0),Sc(this,Dl,0),this.toSVGPath(),null}getLastElement(){return yc(this,Cl).at(-1)}setLastElement(t){return yc(this,Cl)?(yc(this,Cl).push(t),Sc(this,El,t.line),Sc(this,Pl,t.points),Sc(this,Dl,0),{path:{d:this.toSVGPath()}}):yc(this,Ll).setLastElement(t)}removeLastElement(){if(!yc(this,Cl))return yc(this,Ll).removeLastElement();yc(this,Cl).pop(),Sc(this,Il,"");for(let t=0,e=yc(this,Cl).length;t<e;t++){const{line:e,points:s}=yc(this,Cl)[t];Sc(this,El,e),Sc(this,Pl,s),Sc(this,Dl,0),this.toSVGPath()}return{path:{d:yc(this,Il)}}}toSVGPath(){const t=Ef.svgRound(yc(this,El)[4]),e=Ef.svgRound(yc(this,El)[5]);if(2===yc(this,Pl).length)return Sc(this,Il,`${yc(this,Il)} M ${t} ${e} Z`),yc(this,Il);if(yc(this,Pl).length<=6){const s=yc(this,Il).lastIndexOf("M");Sc(this,Il,`${yc(this,Il).slice(0,s)} M ${t} ${e}`),Sc(this,Dl,6)}if(4===yc(this,Pl).length){const t=Ef.svgRound(yc(this,El)[10]),e=Ef.svgRound(yc(this,El)[11]);return Sc(this,Il,`${yc(this,Il)} L ${t} ${e}`),Sc(this,Dl,12),yc(this,Il)}const s=[];0===yc(this,Dl)&&(s.push(`M ${t} ${e}`),Sc(this,Dl,6));for(let i=yc(this,Dl),n=yc(this,El).length;i<n;i+=6){const[t,e,n,a,r,o]=yc(this,El).slice(i,i+6).map(Ef.svgRound);s.push(`C${t} ${e} ${n} ${a} ${r} ${o}`)}return Sc(this,Il,yc(this,Il)+s.join(" ")),Sc(this,Dl,yc(this,El).length),yc(this,Il)}getOutlines(t,e,s,i){const n=yc(this,Cl).at(-1);return n.line=new Float32Array(n.line),n.points=new Float32Array(n.points),yc(this,Ll).build(yc(this,Cl),t,e,s,yc(this,Tl),yc(this,Rl),i),Sc(this,Ml,null),Sc(this,El,null),Sc(this,Cl,null),Sc(this,Il,null),yc(this,Ll)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Ml=new WeakMap,El=new WeakMap,Cl=new WeakMap,Tl=new WeakMap,Rl=new WeakMap,Pl=new WeakMap,Il=new WeakMap,Dl=new WeakMap,Ll=new WeakMap,Nl=new WeakMap,Fl=new WeakMap,Wl=new WeakSet,Ol=function(t,e){return Ef._normalizePoint(t,e,yc(this,Nl),yc(this,Fl),yc(this,Tl))};
1class $f extends Ef{constructor(){super(...arguments),xc(this,Xl),xc(this,Bl),xc(this,Hl,0),xc(this,$l),xc(this,zl),xc(this,jl),xc(this,Gl),xc(this,Vl),xc(this,Ul),xc(this,ql)}build(t,e,s,i,n,a,r){Sc(this,jl,e),Sc(this,Gl,s),Sc(this,Vl,i),Sc(this,Ul,n),Sc(this,ql,a),Sc(this,$l,r??0),Sc(this,zl,t),kc(this,Xl,Ql).call(this)}get thickness(){return yc(this,ql)}setLastElement(t){return yc(this,zl).push(t),{path:{d:this.toSVGPath()}}}removeLastElement(){return yc(this,zl).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const t=[];for(const{line:e}of yc(this,zl))if(t.push(`M${Ef.svgRound(e[4])} ${Ef.svgRound(e[5])}`),6!==e.length)if(12===e.length&&isNaN(e[6]))t.push(`L${Ef.svgRound(e[10])} ${Ef.svgRound(e[11])}`);else for(let s=6,i=e.length;s<i;s+=6){const[i,n,a,r,o,l]=e.subarray(s,s+6).map(Ef.svgRound);t.push(`C${i} ${n} ${a} ${r} ${o} ${l}`)}else t.push("Z");return t.join("")}serialize([t,e,s,i],n){const a=[],r=[],[o,l,h,c]=kc(this,Xl,Kl).call(this);let d,u,p,g,f,m,v,w,b;switch(yc(this,Ul)){case 0:b=Ef._rescale,d=t,u=e+i,p=s,g=-i,f=t+o*s,m=e+(1-l-c)*i,v=t+(o+h)*s,w=e+(1-l)*i;break;case 90:b=Ef._rescaleAndSwap,d=t,u=e,p=s,g=i,f=t+l*s,m=e+o*i,v=t+(l+c)*s,w=e+(o+h)*i;break;case 180:b=Ef._rescale,d=t+s,u=e,p=-s,g=i,f=t+(1-o-h)*s,m=e+l*i,v=t+(1-o)*s,w=e+(l+c)*i;break;case 270:b=Ef._rescaleAndSwap,d=t+s,u=e+i,p=-s,g=-i,f=t+(1-l-c)*s,m=e+(1-o-h)*i,v=t+(1-l)*s,w=e+(1-o)*i}for(const{line:A,points:_}of yc(this,zl))a.push(b(A,d,u,p,g,n?new Array(A.length):null)),r.push(b(_,d,u,p,g,n?new Array(_.length):null));return{lines:a,points:r,rect:[f,m,v,w]}}static deserialize(t,e,s,i,n,{paths:{lines:a,points:r},rotation:o,thickness:l}){const h=[];let c,d,u,p,g;switch(o){case 0:g=Ef._rescale,c=-t/s,d=e/i+1,u=1/s,p=-1/i;break;case 90:g=Ef._rescaleAndSwap,c=-e/i,d=-t/s,u=1/i,p=1/s;break;case 180:g=Ef._rescale,c=t/s+1,d=-e/i,u=-1/s,p=1/i;break;case 270:g=Ef._rescaleAndSwap,c=e/i+1,d=t/s+1,u=-1/i,p=-1/s}if(!a){a=[];for(const t of r){const e=t.length;if(2===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1]]));continue}if(4===e){a.push(new Float32Array([NaN,NaN,NaN,NaN,t[0],t[1],NaN,NaN,NaN,NaN,t[2],t[3]]));continue}const s=new Float32Array(3*(e-2));a.push(s);let[i,n,r,o]=t.subarray(0,4);s.set([NaN,NaN,NaN,NaN,i,n],0);for(let a=4;a<e;a+=2){const e=t[a],l=t[a+1];s.set(Ef.createBezierPoints(i,n,r,o,e,l),3*(a-2)),[i,n,r,o]=[r,o,e,l]}}}for(let m=0,v=a.length;m<v;m++)h.push({line:g(a[m].map(t=>t??NaN),c,d,u,p),points:g(r[m].map(t=>t??NaN),c,d,u,p)});const f=new this.prototype.constructor;return f.build(h,s,i,1,o,l,n),f}get box(){return yc(this,Bl)}updateProperty(t,e){return"stroke-width"===t?kc(this,Xl,Jl).call(this,e):null}updateParentDimensions([t,e],s){const[i,n]=kc(this,Xl,Yl).call(this);Sc(this,jl,t),Sc(this,Gl,e),Sc(this,Vl,s);const[a,r]=kc(this,Xl,Yl).call(this),o=a-i,l=r-n,h=yc(this,Bl);return h[0]-=o,h[1]-=l,h[2]+=2*o,h[3]+=2*l,h}updateRotation(t){return Sc(this,Hl,t),{path:{transform:this.rotationTransform}}}get viewBox(){return yc(this,Bl).map(Ef.svgRound).join(" ")}get defaultProperties(){const[t,e]=yc(this,Bl);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ef.svgRound(t)} ${Ef.svgRound(e)}`}}}get rotationTransform(){const[,,t,e]=yc(this,Bl);let s=0,i=0,n=0,a=0,r=0,o=0;switch(yc(this,Hl)){case 90:i=e/t,n=-t/e,r=t;break;case 180:s=-1,a=-1,r=t,o=e;break;case 270:i=-e/t,n=t/e,o=e;break;default:return""}return`matrix(${s} ${i} ${n} ${a} ${Ef.svgRound(r)} ${Ef.svgRound(o)})`}getPathResizingSVGProperties([t,e,s,i]){const[n,a]=kc(this,Xl,Yl).call(this),[r,o,l,h]=yc(this,Bl);if(Math.abs(l-n)<=Ef.PRECISION||Math.abs(h-a)<=Ef.PRECISION){const n=t+s/2-(r+l/2),a=e+i/2-(o+h/2);return{path:{"transform-origin":`${Ef.svgRound(t)} ${Ef.svgRound(e)}`,transform:`${this.rotationTransform} translate(${n} ${a})`}}}const c=(s-2*n)/(l-2*n),d=(i-2*a)/(h-2*a),u=l/s,p=h/i;return{path:{"transform-origin":`${Ef.svgRound(r)} ${Ef.svgRound(o)}`,transform:`${this.rotationTransform} scale(${u} ${p}) translate(${Ef.svgRound(n)} ${Ef.svgRound(a)}) scale(${c} ${d}) translate(${Ef.svgRound(-n)} ${Ef.svgRound(-a)})`}}}getPathResizedSVGProperties([t,e,s,i]){const[n,a]=kc(this,Xl,Yl).call(this),r=yc(this,Bl),[o,l,h,c]=r;if(r[0]=t,r[1]=e,r[2]=s,r[3]=i,Math.abs(h-n)<=Ef.PRECISION||Math.abs(c-a)<=Ef.PRECISION){const n=t+s/2-(o+h
1/2),a=e+i/2-(l+c/2);for(const{line:t,points:e}of yc(this,zl))Ef._translate(t,n,a,t),Ef._translate(e,n,a,e);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ef.svgRound(t)} ${Ef.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(s-2*n)/(h-2*n),u=(i-2*a)/(c-2*a),p=-d*(o+n)+t+n,g=-u*(l+a)+e+a;if(1!==d||1!==u||0!==p||0!==g)for(const{line:f,points:m}of yc(this,zl))Ef._rescale(f,p,g,d,u,f),Ef._rescale(m,p,g,d,u,m);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${Ef.svgRound(t)} ${Ef.svgRound(e)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([t,e],s){const[i,n]=s,a=yc(this,Bl),r=t-a[0],o=e-a[1];if(yc(this,jl)===i&&yc(this,Gl)===n)for(const{line:l,points:h}of yc(this,zl))Ef._translate(l,r,o,l),Ef._translate(h,r,o,h);else{const t=yc(this,jl)/i,e=yc(this,Gl)/n;Sc(this,jl,i),Sc(this,Gl,n);for(const{line:s,points:i}of yc(this,zl))Ef._rescale(s,r,o,t,e,s),Ef._rescale(i,r,o,t,e,i);a[2]*=t,a[3]*=e}return a[0]=t,a[1]=e,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${Ef.svgRound(t)} ${Ef.svgRound(e)}`}}}get defaultSVGProperties(){const t=yc(this,Bl);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${Ef.svgRound(t[0])} ${Ef.svgRound(t[1])}`,transform:this.rotationTransform||null},bbox:t}}}Bl=new WeakMap,Hl=new WeakMap,$l=new WeakMap,zl=new WeakMap,jl=new WeakMap,Gl=new WeakMap,Vl=new WeakMap,Ul=new WeakMap,ql=new WeakMap,Xl=new WeakSet,Yl=function(t=yc(this,ql)){const e=yc(this,$l)+t/2*yc(this,Vl);return yc(this,Ul)%180==0?[e/yc(this,jl),e/yc(this,Gl)]:[e/yc(this,Gl),e/yc(this,jl)]},Kl=function(){const[t,e,s,i]=yc(this,Bl),[n,a]=kc(this,Xl,Yl).call(this,0);return[t+n,e+a,s-2*n,i-2*a]},Ql=function(){const t=Sc(this,Bl,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:i}of yc(this,zl)){if(i.length<=12){for(let e=4,s=i.length;e<s;e+=6)Cd.pointBoundingBox(i[e],i[e+1],t);continue}let e=i[4],s=i[5];for(let n=6,a=i.length;n<a;n+=6){const[a,r,o,l,h,c]=i.subarray(n,n+6);Cd.bezierBoundingBox(e,s,a,r,o,l,h,c,t),e=h,s=c}}const[e,s]=kc(this,Xl,Yl).call(this);t[0]=Ld(t[0]-e,0,1),t[1]=Ld(t[1]-s,0,1),t[2]=Ld(t[2]+e,0,1),t[3]=Ld(t[3]+s,0,1),t[2]-=t[0],t[3]-=t[1]},Jl=function(t){const[e,s]=kc(this,Xl,Yl).call(this);Sc(this,ql,t);const[i,n]=kc(this,Xl,Yl).call(this),[a,r]=[i-e,n-s],o=yc(this,Bl);return o[0]-=a,o[1]-=r,o[2]+=2*a,o[3]+=2*r,o};class zf extends Wf{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:xu._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){"stroke-width"===t&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new zf(this._viewParameters);return t.updateAll(this),t}}const jf=class t extends Bf{constructor(t){super({...t,name:"inkEditor"}),xc(this,Zl),this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(t,e){xu.initialize(t,e),this._defaultDrawingOptions=new zf(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!0}static get typesMap(){return md(this,"typesMap",new Map([[$c.INK_THICKNESS,"stroke-width"],[$c.INK_COLOR,"stroke"],[$c.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(t,e,s,i,n){return new Hf(t,e,s,i,n,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(t,e,s,i,n,a){return $f.deserialize(t,e,s,i,n,a)}static async deserialize(t,e,s){let i=null;if(t instanceof mf){const{data:{inkLists:e,rect:s,rotation:n,id:a,color:r,opacity:o,borderStyle:{rawWidth:l},popupRef:h,contentsObj:c},parent:{page:{pageNumber:d}}}=t;i=t={annotationType:Hc.INK,color:Array.from(r),thickness:l,opacity:o,paths:{points:e},boxes:null,pageIndex:d-1,rect:s.slice(0),rotation:n,annotationElementId:a,id:a,deleted:!1,popupRef:h,comment:(null==c?void 0:c.str)||null}}const n=await super.deserialize(t,e,s);return n._initialData=i,t.comment&&n.setCommentData(t.comment),n}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Hg(this)),[["colorPicker",this._colorPicker]]}get colorType(){return $c.INK_COLOR}get colorValue(){return this._drawingOptions.stroke}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:t,_drawingOptions:e,parent:s}=this;e.updateSVGProperty("stroke-width"),s.drawLayer.updateProperties(t,e.toSVGProperties())}static onScaleChangingWhenDrawing(){const t=this._currentParent;t&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),t.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:s,opacity:i}){this._drawingOptions=t.getDefaultDrawingOptions({stroke:Cd.makeHexColor(...e),"stroke-width":s,"stroke-opacity":i})}serialize(t=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{stroke:n,"stroke-opacity":a,"stroke-width":r}}=this,o={annotationType:Hc.INK,color:xu._colorManager.convert(n),opacity:a,thickness:r,paths:{lines:e,points:s},pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(o),t?(o.isCopy=!0,o):this.annotationElementId&&!kc(this,Zl,th).call(this,o)?null:(o.id=this.annotationElementId,o)}renderAnnotationElement(t){const{points:e,rect:s}=this.serializeDraw(!1),i={rect:s,thickness:this._drawingOptions["stroke-width"],points:e};return this.hasEditedComment&&(i.popup=this.comment),t.updateEdited(i),null}};Zl=new WeakSet,th=function(t){const{color:e,thickness:s,opacity:i,pageIndex:n}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||t.color.some((t,s)=>t!==e[s])||t.thickness!==s||t.opacity!==i||t.pageIndex!==n},Ac(jf,"_type","ink"),Ac(jf,"_editorType",Hc.INK),Ac(jf,"_defaultDrawingOptions",null);let Gf=jf;class Vf extends $f{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}class Uf{static extractContoursFromText(t,{fontFamily:e,fontStyle:s,fontWeight:i},n,a,r,o){let l=new OffscreenCanvas(1,1),h=l.getContext("2d",{alpha:!1});const c=h.font=`${s} ${i} 200px ${e}`,{actualBoundingBoxLeft:d,actualBoundingBoxRight:u,actualBoundingBoxAscent:p,actualBoundingBoxDescent:g,fontBoundingBoxAscent:f,fontBoundingBoxDescent:m,width:v}=h.measureText(t),w=1.5,b=Math.ceil(Math.max(Math.abs(d)+Math.abs(u)||0,v)*w),A=
vendor: 9,245 bytes, line 1
1Math.ceil(Math.max(Math.abs(p)+Math.abs(g)||200,Math.abs(f)+Math.abs(m)||200)*w);l=new OffscreenCanvas(b,A),h=l.getContext("2d",{alpha:!0,willReadFrequently:!0}),h.font=c,h.filter="grayscale(1)",h.fillStyle="white",h.fillRect(0,0,b,A),h.fillStyle="black",h.fillText(t,.5*b/2,1.5*A/2);const _=kc(this,sh,uh).call(this,h.getImageData(0,0,b,A).data),y=kc(this,sh,dh).call(this,_),x=kc(this,sh,ph).call(this,y),S=kc(this,sh,oh).call(this,_,b,A,x);return this.processDrawnLines({lines:{curves:S,width:b,height:A},pageWidth:n,pageHeight:a,rotation:r,innerMargin:o,mustSmooth:!0,areContours:!0})}static process(t,e,s,i,n){const[a,r,o]=kc(this,sh,gh).call(this,t),[l,h]=kc(this,sh,ch).call(this,a,r,o,Math.hypot(r,o)*yc(this,eh).sigmaSFactor,yc(this,eh).sigmaR,yc(this,eh).kernelSize),c=kc(this,sh,ph).call(this,h),d=kc(this,sh,oh).call(this,l,r,o,c);return this.processDrawnLines({lines:{curves:d,width:r,height:o},pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:s,rotation:i,innerMargin:n,mustSmooth:a,areContours:r}){i%180!=0&&([e,s]=[s,e]);const{curves:o,width:l,height:h}=t,c=t.thickness??0,d=[],u=Math.min(e/l,s/h),p=u/e,g=u/s,f=[];for(const{points:v}of o){const t=a?kc(this,sh,hh).call(this,v):v;if(!t)continue;f.push(t);const e=t.length,s=new Float32Array(e),i=new Float32Array(3*(2===e?2:e-2));if(d.push({line:i,points:s}),2===e){s[0]=t[0]*p,s[1]=t[1]*g,i.set([NaN,NaN,NaN,NaN,s[0],s[1]],0);continue}let[n,r,o,l]=t;n*=p,r*=g,o*=p,l*=g,s.set([n,r,o,l],0),i.set([NaN,NaN,NaN,NaN,n,r],0);for(let a=4;a<e;a+=2){const e=s[a]=t[a]*p,h=s[a+1]=t[a+1]*g;i.set(Ef.createBezierPoints(n,r,o,l,e,h),3*(a-2)),[n,r,o,l]=[o,l,e,h]}}if(0===d.length)return null;const m=r?new Vf:new $f;return m.build(d,e,s,1,i,r?0:c,n),{outline:m,newCurves:f,areContours:r,thickness:c,width:l,height:h}}static async compressSignature({outlines:t,areContours:e,thickness:s,width:i,height:n}){let a,r=1/0,o=-1/0,l=0;for(const v of t){l+=v.length;for(let t=2,e=v.length;t<e;t++){const e=v[t]-v[t-2];r=Math.min(r,e),o=Math.max(o,e)}}a=r>=-128&&o<=127?Int8Array:r>=-32768&&o<=32767?Int16Array:Int32Array;const h=t.length,c=8+3*h,d=new Uint32Array(c);let u=0;d[u++]=c*Uint32Array.BYTES_PER_ELEMENT+(l-2*h)*a.BYTES_PER_ELEMENT,d[u++]=0,d[u++]=i,d[u++]=n,d[u++]=e?0:1,d[u++]=Math.max(0,Math.floor(s??0)),d[u++]=h,d[u++]=a.BYTES_PER_ELEMENT;for(const v of t)d[u++]=v.length-2,d[u++]=v[0],d[u++]=v[1];const p=new CompressionStream("deflate-raw"),g=p.writable.getWriter();await g.ready,g.write(d);const f=a.prototype.constructor;for(const v of t){const t=new f(v.length-2);for(let e=2,s=v.length;e<s;e++)t[e-2]=v[e]-v[e-2];g.write(t)}g.close();const m=await new Response(p.readable).arrayBuffer();return Nd(new Uint8Array(m))}static async decompressSignature(t){try{const s=(e=t,Uint8Array.fromBase64?Uint8Array.fromBase64(e):kd(atob(e))),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),a=n.getWriter();await a.ready,a.write(s).then(async()=>{await a.ready,await a.close()}).catch(()=>{});let r=null,o=0;for await(const t of i)r||(r=new Uint8Array(new Uint32Array(t.buffer,0,4)[0])),r.set(t,o),o+=t.length;const l=new Uint32Array(r.buffer,0,r.length>>2),h=l[1];if(0!==h)throw new Error(`Invalid version: ${h}`);const c=l[2],d=l[3],u=0===l[4],p=l[5],g=l[6],f=l[7],m=[],v=(8+3*g)*Uint32Array.BYTES_PER_ELEMENT;let w;switch(f){case Int8Array.BYTES_PER_ELEMENT:w=new Int8Array(r.buffer,v);break;case Int16Array.BYTES_PER_ELEMENT:w=new Int16Array(r.buffer,v);break;case Int32Array.BYTES_PER_ELEMENT:w=new Int32Array(r.buffer,v)}o=0;for(let t=0;t<g;t++){const e=l[3*t+8],s=new Float32Array(e+2);m.push(s);for(let i=0;i<2;i++)s[i]=l[3*t+8+i+1];for(let t=0;t<e;t++)s[t+2]=s[t]+w[o++]}return{areContours:u,thickness:p,outlines:m,width:c,height:d}}catch(s){return null}var e}}eh=new WeakMap,sh=new WeakSet,ih=function(t,e,s,i){return i-=e,0===(s-=t)?i>0?0:4:1===s?i+6:2-i},nh=new WeakMap,ah=function(t,e,s,i,n,a,r){const o=kc(this,sh,ih).call(this,s,i,n,a);for(let l=0;l<8;l++){const n=(-l+o-r+16)%8;if(0!==t[(s+yc(this,nh)[2*n])*e+(i+yc(this,nh)[2*n+1])])return n}return-1},rh=function(t,e,s,i,n,a,r){const o=kc(this,sh,ih).call(this,s,i,n,a);for(let l=0;l<8;l++){const n=(l+o+r+16)%8;if(0!==t[(s+yc(this,nh)[2*n])*e+(i+yc(this,nh)[2*n+1])])return n}return-1},oh=function(t,e,s,i){const n=t.length,a=new Int32Array(n);for(let h=0;h<n;h++)a[h]=t[h]<=i?1:0;for(let h=1;h<s-1;h++)a[h*e]=a[h*e+e-1]=0;for(let h=0;h<e;h++)a[h]=a[e*s-1-h]=0;let r,o=1;const l=[];for(let h=1;h<s-1;h++){r=1;for(let t=1;t<e-1;t++){const s=h*e+t,i=a[s];if(0===i)continue;let n=h,c=t;if(1===i&&0===a[s-1])o+=1,c-=1;else{if(!(i>=1&&0===a[s+1])){1!==i&&(r=Math.abs(i));continue}o+=1,c+=1,i>1&&(r=i)}const d=[t,h],u=c===t+1,p={isHole:u,points:d,id:o,parent:0};let g;l.push(p);for(const t of l)if(t.id===r){g=t;break}g?g.isHole?p.parent=u?g.parent:r:p.parent=u?r:g.parent:p.parent=u?r:0;const f=kc(this,sh,ah).call(this,a,e,h,t,n,c,0);if(-1===f){a[s]=-o,1!==a[s]&&(r=Math.abs(a[s]));continue}let m=yc(this,nh)[2*f],v=yc(this,nh)[2*f+1];const w=h+m,b=t+v;n=w,c=b;let A=h,_=t;for(;;){const i=kc(this,sh,rh).call(this,a,e,A,_,n,c,1);m=yc(this,nh)[2*i],v=yc(this,nh)[2*i+1];const l=A+m,u=_+v;d.push(u,l);const p=A*e+_;if(0===a[p+1]?a[p]=-o:1===a[p]&&(a[p]=o),l===h&&u===t&&A===w&&_===b){1!==a[s]&&(r=Math.abs(a[s]));break}n=A,c=_,A=l,_=u}}}return l},lh=function(t,e,s,i){if(s-e<=4){for(let n=e;n<s-2;n+=2)i.push(t[n],t[n+1]);return}const n=t[e],a=t[e+1],r=t[s-4]-n,o=t[s-3]-a,l=Math.hypot(r,o),h=r/l,c=o/l,d=h*a-c*n,u=o/r,p=1/l,g=Math.atan(u),f=Math.cos(g),m=Math.sin(g),v=p*(Math.abs(f)+Math.abs(m)),w=p*(1-v+v**2),b=Math.max(Math.atan(Math.abs(m+f)*w),Math.atan(Math.abs(m-f)*w));let A=0,_=e;for(let y=e+2;y<s-2;y+=2){const e=Math.abs(d-h*t[y+1]+c*t[y]);e>A&&(_=y,A=e)}A>(l*b)**2?(kc(this,sh,lh).call(this,t,e,_+2,i),kc(this,sh,lh).call(this,t,_,s,i)):i.push(n,a)},hh=function(t){const e=[],s=t.length;return kc(this,sh,lh).call(this,t,0,s,e),e.push(t[s-2],t[s-1]),e.length<=4?null:e},ch=function(t,e,s,i,n,a){const r=new Float32Array(a**2),o=-2*i**2,l=a>>1;for(let g=0;g<a;g++){const t=(g-l)**2;for(let e=0;e<a;e++)r[g*a+e]=Math.exp((t+(e-l)**2)/o)}const h=new Float32Array(256),c=-2*n**2;for(let g=0;g<256;g++)h[g]=Math.exp(g**2/c);const d=t.length,u=new Uint8Array(d),p=new Uint32Array(256);for(let g=0;g<s;g++)for(let i=0;i<e;i++){const n=g*e+i,o=t[n];let c=0,d=0;for(let u=0;u<a;u++){const n=g+u-l;if(!(n<0||n>=s))for(let s=0;s<a;s++){const p=i+s-l;if(p<0||p>=e)continue;const g=t[n*e+p],f=r[u*a+s]*h[Math.abs(g-o)];c+=g*f,d+=f}}p[u[n]=Math.round(c/d)]++}return[u,p]},dh=function(t){const e=new Uint32Array(256);for(const s of t)e[s]++;return e},uh=function(t){const e=t.length,s=new Uint8ClampedArray(e>>2);let i=-1/0,n=1/0;for(let r=0,o=s.length;r<o;r++){const e=s[r]=t[r<<2];i=Math.max(i,e),n=Math.min(n,e)}const a=255/(i-n);for(let r=0,o=s.length;r<o;r++)s[r]=(s[r]-n)*a;return s},ph=function(t){let e,s=-1/0,i=-1/0;const n=t.findIndex(t=>0!==t);let a=n,r=n;for(e=n;e<256;e++){const n=t[e];n>s&&(e-a>i&&(i=e-a,r=e-1),s=n,a=e)}for(e=r-1;e>=0&&!(t[e]>t[e+1]);e--);return e},gh=function(t){const e=t,{width:s,height:i}=t,{maxDim:n}=yc(this,eh);let a=s,r=i;if(s>n||i>n){let o=s,l=i,h=Math.log2(Math.max(s,i)/n);const c=Math.floor(h);h=h===c?c-1:c;for(let s=0;s<h;s++){a=Math.ceil(o/2),r=Math.ceil(l/2);const s=new OffscreenCanvas(a,r);s.getContext("2d").drawImage(t,0,0,o,l,0,0,a,r),o=a,l=r,t!==e&&t.close(),t=s.transferToImageBitmap()}const d=Math.min(n/a,n/r);a=Math.round(a*d),r=Math.round(r*d)}const o=new OffscreenCanvas(a,r).getContext("2d",{willReadFrequently:!0});o.fillStyle="white",o.fillRect(0,0,a,r),o.filter="grayscale(1)",o.drawImage(t,0,0,t.width,t.height,0,0,a,r);const l=o.getImageData(0,0,a,r).data;return[kc(this,sh,uh).call(this,l),a,r]},xc(Uf,sh),xc(Uf,eh,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),xc(Uf,nh,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class qf extends Wf{constructor(){super(),super.updateProperties({fill:xu._defaultLineColor,"stroke-width":0})}clone(){const t=new qf;return t.updateAll(this),t}}class Xf extends zf{constructor(t){super(t),super.updateProperties({stroke:xu._defaultLineColor,"stroke-width":1})}clone(){const t=new Xf(this._viewParameters);return t.updateAll(this),t}}const Yf=class t extends Bf{constructor(t){super({...t,mustBeCommitted:!0,name:"signatureEditor"}),xc(this,fh,!1),xc(this,mh,null),xc(this,vh,null),xc(this,wh,null),this._willKeepAspectRatio=!0,Sc(this,vh,t.signatureData||null),Sc(this,mh,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(t,e){xu.initialize(t,e),this._defaultDrawingOptions=new qf,this._defaultDrawnSignatureOptions=new Xf(e.viewParameters)}static getDefaultDrawingOptions(t){const e=this._defaultDrawingOptions.clone();return e.updateProperties(t),e}static get supportMultipleDrawings(){return!1}static get typesMap(){return md(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!yc(this,mh)}}static computeTelemetryFinalData(t){const e=t.get("hasDescription");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){null!==this._drawId&&super.onScaleChanging()}
1render(){if(this.div)return this.div;let e,s;const{_isCopy:i}=this;if(i&&(this._isCopy=!1,e=this.x,s=this.y),super.render(),null===this._drawId)if(yc(this,vh)){const{lines:e,mustSmooth:s,areContours:i,description:n,uuid:a,heightInPage:r}=yc(this,vh),{rawDims:{pageWidth:o,pageHeight:l},rotation:h}=this.parent.viewport,c=Uf.processDrawnLines({lines:e,pageWidth:o,pageHeight:l,rotation:h,innerMargin:t._INNER_MARGIN,mustSmooth:s,areContours:i});this.addSignature(c,r,n,a)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:yc(this,mh)||""}));return i&&(this._isCopy=!0,this._moveAfterPaste(e,s)),this.div}setUuid(t){Sc(this,wh,t),this.addEditToolbar()}getUuid(){return yc(this,wh)}get description(){return yc(this,mh)}set description(t){Sc(this,mh,t),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:t})),super.addEditToolbar().then(e=>{null==e||e.updateEditSignatureButton(t)}))}getSignaturePreview(){const{newCurves:t,areContours:e,thickness:s,width:i,height:n}=yc(this,vh),a=Math.max(i,n);return{areContours:e,outline:Uf.processDrawnLines({lines:{curves:t.map(t=>({points:t})),thickness:s,width:i,height:n},pageWidth:a,pageHeight:a,rotation:0,innerMargin:0,mustSmooth:!1,areContours:e}).outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,s,i,n){const{x:a,y:r}=this,{outline:o}=Sc(this,vh,e);let l;Sc(this,fh,o instanceof Vf),this.description=i,yc(this,fh)?l=t.getDefaultDrawingOptions():(l=t._defaultDrawnSignatureOptions.clone(),l.updateProperties({"stroke-width":o.thickness})),this._addOutlines({drawOutlines:o,drawingOptions:l});const[h,c]=this.parentDimensions,[,d]=this.pageDimensions;let u=s/d;u=u>=1?.5:u,this.width*=u/this.height,this.width>=1&&(u*=.9/this.width,this.width=.9),this.height=u,this.setDims(
1h*this.width,c*this.height),this.x=a,this.y=r,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(n),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!n,hasDescription:!!i}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Uf.process(e,s,i,n,t._INNER_MARGIN)}getFromText(e,s){const{rawDims:{pageWidth:i,pageHeight:n},rotation:a}=this.parent.viewport;return Uf.extractContoursFromText(e,s,i,n,a,t._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:s,pageHeight:i},rotation:n}=this.parent.viewport;return Uf.processDrawnLines({lines:e,pageWidth:s,pageHeight:i,rotation:n,innerMargin:t._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:s}){e?this._drawingOptions=t.getDefaultDrawingOptions():(this._drawingOptions=t._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":s}))}serialize(t=!1){if(this.isEmpty())return null;const{lines:e,points:s,rect:i}=this.serializeDraw(t),{_drawingOptions:{"stroke-width":n}}=this,a={annotationType:Hc.SIGNATURE,isSignature:!0,areContours:yc(this,fh),color:[0,0,0],thickness:yc(this,fh)?0:n,pageIndex:this.pageIndex,rect:i,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return this.addComment(a),t?(a.paths={lines:e,points:s},a.uuid=yc(this,wh),a.isCopy=!0):a.lines=e,yc(this,mh)&&(a.accessibilityData={type:"Figure",alt:yc(this,mh)}),a}static deserializeDraw(t,e,s,i,n,a){return a.areContours?Vf.deserialize(t,e,s,i,n,a):$f.deserialize(t,e,s,i,n,a)}static async deserialize(t,e,s){var i;const n=await super.deserialize(t,e,s);return Sc(n,fh,t.areContours),n.description=(null==(i=t.accessibilityData)?void 0:i.alt)||"",Sc(n,wh,t.uuid),n}};fh=new WeakMap,mh=new WeakMap,vh=new WeakMap,wh=new WeakMap,Ac(Yf,"_type","signature"),Ac(Yf,"_editorType",Hc.SIGNATURE),Ac(Yf,"_defaultDrawingOptions",null);let Kf=Yf;class Qf extends xu{constructor(t){super({...t,name:"stampEditor"}),xc(this,Rh),xc(this,bh,null),xc(this,Ah,null),xc(this,_h,null),xc(this,yh,null),xc(this,xh,null),xc(this,Sh,""),xc(this,kh,null),xc(this,Mh,!1),xc(this,Eh,null),xc(this,Ch,!1),xc(this,Th,!1),Sc(this,yh,t.bitmapUrl),Sc(this,xh,t.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(t,e){xu.initialize(t,e)}static isHandlingMimeForPasting(t){return iu.includes(t)}static paste(t,e){e.pasteEditor({mode:Hc.STAMP},{bitmapFile:t.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var t;return{type:"stamp",hasAltText:!!(null==(t=this.altTextData)?void 0:t.altText)}}static computeTelemetryFinalData(t){const e=t.get("hasAltText");return{hasAltText:e.get(!0)??0,hasNoAltText:e.get(!1)??0}}async mlGuessAltText(t=null,e=!0){if(this.hasAltTextData())return null;const{mlManager:s}=this._uiManager;if(!s)throw new Error("No ML.");if(!(await s.isEnabledFor("altText")))throw new Error("ML isn't enabled for alt text.");const{data:i,width:n,height:a}=t||this.copyCanvas(null,null,!0).imageData,r=await s.guess({name:"altText",request:{data:i,width:n,height:a,channels:i.length/(n*a)}});if(!r)throw new Error("No response from the AI service.");if(r.error)throw new Error("Error from the AI service.");if(r.cancel)return null;if(!r.output)throw new Error("No valid response from the AI service.");const o=r.output;return await this.setGuessedAltText(o),e&&!this.hasAltTextData()&&(this.altTextData={alt:o,decorative:!1}),o}remove(){var t;yc(this,Ah)&&(Sc(this,bh,null),this._uiManager.imageManager.deleteId(yc(this,Ah)),null==(t=yc(this,kh))||t.remove(),Sc(this,kh,null),yc(this,Eh)&&(clearTimeout(yc(this,Eh)),Sc(this,Eh,null))),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(yc(this,Ah)&&null===yc(this,kh)&&kc(this,Rh,Dh).call(this),this.isAttachedToDOM||this.parent.add(this))):yc(this,Ah)&&kc(this,Rh,Dh).call(this)}onceAdded(t){this._isDraggable=!0,t&&this.div.focus()}isEmpty(){return!(yc(this,_h)||yc(this,bh)||yc(this,yh)||yc(this,xh)||yc(this,Ah)||yc(this,Mh))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}
1render(){if(this.div)return this.div;let t,e;return this._isCopy&&(t=this.x,e=this.y),super.render(),this.div.hidden=!0,this.createAltText(),yc(this,Mh)||(yc(this,bh)?kc(this,Rh,Lh).call(this):kc(this,Rh,Dh).call(this)),this._isCopy&&this._moveAfterPaste(t,e),this._uiManager.addShouldRescale(this),this.div}setCanvas(t,e){const{id:s,bitmap:i}=this._uiManager.imageManager.getFromCanvas(t,e);e.remove(),s&&this._uiManager.imageManager.isValidId(s)&&(Sc(this,Ah,s),i&&Sc(this,bh,i),Sc(this,Mh,!1),kc(this,Rh,Lh).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;null!==yc(this,Eh)&&clearTimeout(yc(this,Eh));Sc(this,Eh,setTimeout(()=>{Sc(this,Eh,null),kc(this,Rh,Fh).call(this)},200))}copyCanvas(t,e,s=!1){var i;t||(t=224);const{width:n,height:a}=yc(this,bh),r=new su;let o=yc(this,bh),l=n,h=a,c=null;if(e){if(n>e||a>e){const t=Math.min(e/n,e/a);l=Math.floor(n*t),h=Math.floor(a*t)}c=document.createElement("canvas");const t=c.width=Math.ceil(l*r.sx),s=c.height=Math.ceil(h*r.sy);yc(this,Ch)||(o=kc(this,Rh,Nh).call(this,t,s));const d=c.getContext("2d");d.filter=this._uiManager.hcmFilter;let u="white",p="#cfcfd8";"none"!==this._uiManager.hcmFilter?p="black":(null==(i=window.matchMedia)?void 0:i.call(window,"(prefers-color-scheme: dark)").matches)&&(u="#8f8f9d",p="#42414d");const g=15,f=g*r.sx,m=g*r.sy,v=new OffscreenCanvas(2*f,2*m),w=v.getContext("2d");w.fillStyle=u,w.fillRect(0,0,2*f,2*m),w.fillStyle=p,w.fillRect(0,0,f,m),w.fillRect(f,m,f,m),d.fillStyle=d.createPattern(v,"repeat"),d.fillRect(0,0,t,s),d.drawImage(o,0,0,o.width,o.height,0,0,t,s)}let d=null;if(s){let e,s;if(r.symmetric&&o.width<t&&o.height<t)e=o.width,s=o.height;else if(o=yc(this,bh),n>t||a>t){const i=Math.min(t/n,t/a);e=Math.floor(n*i),s=Math.floor(a*i),yc(this,Ch)||(o=kc(this,Rh,Nh).call(this,e,s))}const i=new OffscreenCanvas(e,s).getContext("2d",{willReadFrequently:!0});i.drawImage(o,0,0,o.width,o.height,0,0,e,s),d={width:e,height:s,data:i.getImageData(0,0,e,s).data}}return{canvas:c,width:l,height:h,imageData:d}}static async deserialize(t,e,s){var i;let n=null,a=!1;if(t instanceof _f){const{data:{rect:r,rotation:o,id:l,structParent:h,popupRef:c,contentsObj:d},container:u,parent:{page:{pageNumber:p}},canvas:g}=t;let f,m;g?(delete t.canvas,({id:f,bitmap:m}=s.imageManager.getFromCanvas(u.id,g)),g.remove()):(a=!0,t._hasNoCanvas=!0);const v=(null==(i=await e._structTree.getAriaAttributes(`${Dd}${l}`))?void 0:i.get("aria-label"))||"";n=t={annotationType:Hc.STAMP,bitmapId:f,bitmap:m,pageIndex:p-1,rect:r.slice(0),rotation:o,annotationElementId:l,id:l,deleted:!1,accessibilityData:{decorative:!1,altText:v},isSvg:!1,structParent:h,popupRef:c,comment:(null==d?void 0:d.str)||null}}const r=await super.deserialize(t,e,s),{rect:o,bitmap:l,bitmapUrl:h,bitmapId:c,isSvg:d,accessibilityData:u}=t;a?(s.addMissingCanvas(t.id,r),Sc(r,Mh,!0)):c&&s.imageManager.isValidId(c)?(Sc(r,Ah,c),l&&Sc(r,bh,l)):Sc(r,yh,h),Sc(r,Ch,d);const[p,g]=r.pageDimensions;return r.width=(o[2]-o[0])/p,r.height=(o[3]-o[1])/g,u&&(r.altTextData=u),r._initialData=n,t.comment&&r.setCommentData(t.comment),Sc(r,Th,!!n),r}serialize(t=!1,e=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const s={annotationType:Hc.STAMP,bitmapId:yc(this,Ah),pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:yc(this,Ch),structTreeParentId:this._structTreeParentId};if(this.addComment(s),t)return s.bitmapUrl=kc(this,Rh,Wh).call(this,!0),s.accessibilityData=this.serializeAltText(!0),s.isCopy=!0,s;const{decorative:i,altText:n}=this.serializeAltText(!1);if(!i&&n&&(s.accessibilityData={type:"Figure",alt:n}),this.annotationElementId){const t=kc(this,Rh,Oh).call(this,s);if(t.isSame)return null;t.isSameAltText?delete s.accessibilityData:s.accessibilityData.structParent=this._initialData.structParent??-1}if(s.id=this.annotationElementId,null===e)return s;e.stamps||(e.stamps=new Map);const a=yc(this,Ch)?(s.rect[2]-s.rect[0])*(s.rect[3]-s.rect[1]):null;if(e.stamps.has(yc(this,Ah))){if(yc(this,Ch)){const t=e.stamps.get(yc(this,Ah));a>t.area&&(t.area=a,t.serialized.bitmap.close(),t.serialized.bitmap=kc(this,Rh,Wh).call(this,!1))}}else e.stamps.set(yc(this,Ah),{area:a,serialized:s}),s.bitmap=kc(this,Rh,Wh).call(this,!1);return s}renderAnnotationElement(t){const e={rect:this.getRect(0,0)};return this.hasEditedComment&&(e.popup=this.comment),t.updateEdited(e),null}}bh=new WeakMap,Ah=new WeakMap,_h=new WeakMap,yh=new WeakMap,xh=new WeakMap,Sh=new WeakMap,kh=new WeakMap,Mh=new WeakMap,Eh=new WeakMap,Ch=new WeakMap,Th=new WeakMap,Rh=new WeakSet,Ph=function(t,e=!1){t?(Sc(this,bh,t.bitmap),e||(Sc(this,Ah,t.id),Sc(this,Ch,t.isSvg)),t.file&&Sc(this,Sh,t.file.name),kc(this,Rh,Lh).call(this)):this.remove()},Ih=function(){if(Sc(this,_h,null),this._uiManager.enableWaiting(!1),yc(this,kh))if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&yc(this,bh))this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});else{if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&yc(this,bh)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Dh=function(){if(yc(this,Ah))return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(yc(this,Ah)).then(t=>kc(this,Rh,Ph).call(this,t,!0)).finally(()=>kc(this,Rh,Ih).call(this));if(yc(this,yh)){const t=yc(this,yh);return Sc(this,yh,null),this._uiManager.enableWaiting(!0),void Sc(this,_h,this._uiManager.imageManager.getFromUrl(t).then(t=>kc(this,Rh,Ph).call(this,t)).finally(()=>kc(this,Rh,Ih).call(this)))}if(yc(this,xh)){const t=yc(this,xh);return Sc(this,xh,null),this._uiManager.enableWaiting(!0),void Sc(this,_h,this._uiManager.imageManager.getFromFile(t).then(t=>kc(this,Rh,Ph).call(this,t)).finally(()=>kc(this,Rh,Ih).call(this)))}const t=document.createElement("input");t.type="file",t.accept=iu.join(",");const e=this._uiManager._signal;Sc(this,_h,new Promise(s=>{t.addEventListener("change",async()=>
1{if(t.files&&0!==t.files.length){this._uiManager.enableWaiting(!0);const e=await this._uiManager.imageManager.getFromFile(t.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),kc(this,Rh,Ph).call(this,e)}else this.remove();s()},{signal:e}),t.addEventListener("cancel",()=>{this.remove(),s()},{signal:e})}).finally(()=>kc(this,Rh,Ih).call(this))),t.click()},Lh=function(){var t;const{div:e}=this;let{width:s,height:i}=yc(this,bh);const[n,a]=this.pageDimensions,r=.75;if(this.width)s=this.width*n,i=this.height*a;else if(s>r*n||i>r*a){const t=Math.min(r*n/s,r*a/i);s*=t,i*=t}const[o,l]=this.parentDimensions;this.setDims(s*o/n,i*l/a),this._uiManager.enableWaiting(!1);const h=Sc(this,kh,document.createElement("canvas"));h.setAttribute("role","img"),this.addContainer(h),this.width=s/n,this.height=i/a,(null==(t=this._initialOptions)?void 0:t.isCentered)?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),kc(this,Rh,Fh).call(this),yc(this,Th)||(this.parent.addUndoableEditor(this),Sc(this,Th,!0)),this._reportTelemetry({action:"inserted_image"}),yc(this,Sh)&&this.div.setAttribute("aria-description",yc(this,Sh)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Nh=function(t,e){const{width:s,height:i}=yc(this,bh);let n=s,a=i,r=yc(this,bh);for(;n>2*t||a>2*e;){const s=n,i=a;n>2*t&&(n=n>=16384?Math.floor(n/2)-1:Math.ceil(n/2)),a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2));const o=new OffscreenCanvas(n,a);o.getContext("2d").drawImage(r,0,0,s,i,0,0,n,a),r=o.transferToImageBitmap()}return r},Fh=function(){const[t,e]=this.parentDimensions,{width:s,height:i}=this,n=new su,a=Math.ceil(s*t*n.sx),r=Math.ceil(i*e*n.sy),o=yc(this,kh);if(!o||o.width===a&&o.height===r)return;o.width=a,o.height=r;const l=yc(this,Ch)?yc(this,bh):kc(this,Rh,Nh).call(this,a,r),h=o.getContext("2d");h.filter=this._uiManager.hcmFilter,h.drawImage(l,0,0,l.width,l.height,0,0,a,r)},Wh=function(t){if(t){if(yc(this,Ch)){const t=this._uiManager.imageManager.getSvgUrl(yc(this,Ah));if(t)return t}const t=document.createElement("canvas");({width:t.width,height:t.height}=yc(this,bh));return t.getContext("2d").drawImage(yc(this,bh),0,0),t.toDataURL()}if(yc(this,Ch)){const[t,e]=this.pageDimensions,s=Math.round(this.width*t*Od.PDF_TO_CSS_UNITS),i=Math.round(this.height*e*Od.PDF_TO_CSS_UNITS),n=new OffscreenCanvas(s,i);return n.getContext("2d").drawImage(yc(this,bh),0,0,yc(this,bh).width,yc(this,bh).height,0,0,s,i),n.transferToImageBitmap()}return structuredClone(yc(this,bh))},Oh=function(t){var e;const{pageIndex:s,accessibilityData:{altText:i}}=this._initialData,n=t.pageIndex===s,a=((null==(e=t.accessibilityData)?void 0:e.alt)||"")===i;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&n&&a,isSameAltText:a}},Ac(Qf,"_type","stamp"),Ac(Qf,"_editorType",Hc.STAMP);const Jf=class t{constructor({uiManager:e,pageIndex:s,div:i,structTreeLayer:n,accessibilityManager:a,annotationLayer:r,drawLayer:o,textLayer:l,viewport:h,l10n:c}){xc(this,sc),xc(this,Bh),xc(this,Hh,!1),xc(this,$h,null),xc(this,zh,null),xc(this,jh,null),xc(this,Gh,new Map),xc(this,Vh,!1),xc(this,Uh,!1),xc(this,qh,!1),xc(this,Xh,null),xc(this,Yh,null),xc(this,Kh,null),xc(this,Qh,null),xc(this,Jh,null),xc(this,Zh,-1),xc(this,tc);const d=[...yc(t,ec).values()];if(!t._initialized){t._initialized=!0;for(const t of d)t.initialize(c,e)}e.registerEditorTypes(d),Sc(this,tc,e),this.pageIndex=s,this.div=i,Sc(this,Bh,a),Sc(this,$h,r),this.viewport=h,Sc(this,Kh,l),this.drawLayer=o,this._structTree=n,yc(this,tc).addLayer(this)}get isEmpty(){return 0===yc(this,Gh).size}get isInvisible(){return this.isEmpty&&yc(this,tc).getMode()===Hc.NONE}updateToolbar(t){yc(this,tc).updateToolbar(t)}updateMode(e=yc(this,tc).getMode()){switch(kc(this,sc,oc).call(this),e){case Hc.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Hc.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Hc.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:s}=this.div;for(const i of yc(t,ec).values())s.toggle(`${i._type}Editing`,e===i._editorType);this.div.hidden=!1}hasTextLayer(t){var e;return t===(null==(e=yc(this,Kh))?void 0:e.div)}setEditingState(t){yc(this,tc).setEditingState(t)}addCommands(t){yc(this,tc).addCommands(t)}cleanUndoStack(t){yc(this,tc).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;null==(e=yc(this,$h))||e.div.classList.toggle("disabled",!t)}async enable(){var t;Sc(this,qh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),null==(t=yc(this,Jh))||t.abort(),Sc(this,Jh,null);const e=new Set;for(const i of yc(this,Gh).values())i.enableEditing(),i.show(!0),i.annotationElementId&&(yc(this,tc).removeChangedExistingAnnotation(i),e.add(i.annotationElementId));if(!yc(this,$h))return void Sc(this,qh,!1);const s=yc(this,$h).getEditableAnnotations();for(const i of s){if(i.hide(),yc(this,tc).isDeletedAnnotationElement(i.data.id))continue;if(e.has(i.data.id))continue;const t=await this.deserialize(i);t&&(this.addOrRebuild(t),t.enableEditing())}Sc(this,qh,!1)}disable(){var e;if(Sc(this,Uh,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),yc(this,Kh)&&!yc(this,Jh)){Sc(this,Jh,new AbortController);const t=yc(this,tc).combinedSignal(yc(this,Jh));yc(this,Kh).div.addEventListener("pointerdown",t=>{const{clientX:e,clientY:s,timeStamp:i}=t;if(i-yc(this,Zh)>500)return void Sc(this,Zh,i);Sc(this,Zh,-1);const{classList:n}=this.div;n.toggle("getElements",!0);const a=document.elementsFromPoint(e,s);if(n.toggle("getElements",!1),!this.div.contains(a[0]))return;let r;const o=new RegExp(`^${Bc}[0-9]+$`);for(const h of a)if(o.test(h.id)){r=h.id;break}if(!r)return;const l=yc(this,Gh).get(r);null===(null==l?void 0:l.annotationElementId)&&(t.stopPropagation(),t.preventDefault(),l.dblclick())},{signal:t,capture:!0})}const s=new Map,i=new Map;for(const t of yc(this,Gh).values())t.disableEditing(),t.annotationElementId&&(null===t.serialize()?(i.set(t.annotationElementId,t),null==(e=this.getEditableAnnotation(t.annotationElementId))||e.show(),t.remove()):s.set(t.annotationElementId,t));if(yc(this,$h)){const t=yc(this,$h).getEditableAnnotations();for(const e of t){const{id:t}=e.data;if(yc(this,tc).isDeletedAnnotationElement(t)){e.updateEdited({deleted:!0}
1);continue}let n=i.get(t);n?(n.resetAnnotationElement(e),n.show(!1),e.show()):(n=s.get(t),n&&(yc(this,tc).addChangedExistingAnnotation(n),n.renderAnnotationElement(e)&&n.show(!1)),e.show())}}kc(this,sc,oc).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const a of yc(t,ec).values())n.remove(`${a._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),Sc(this,Uh,!1)}getEditableAnnotation(t){var e;return(null==(e=yc(this,$h))?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){yc(this,tc).getActive()!==t&&yc(this,tc).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(null==(t=yc(this,Kh))?void 0:t.div)&&!yc(this,Qh)){Sc(this,Qh,new AbortController);const t=yc(this,tc).combinedSignal(yc(this,Qh));yc(this,Kh).div.addEventListener("pointerdown",kc(this,sc,ic).bind(this),{signal:t}),yc(this,Kh).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(null==(t=yc(this,Kh))?void 0:t.div)&&yc(this,Qh)&&(yc(this,Qh).abort(),Sc(this,Qh,null),yc(this,Kh).div.classList.remove("highlighting"))}enableClick(){if(yc(this,zh))return;Sc(this,zh,new AbortController);const t=yc(this,tc).combinedSignal(yc(this,zh));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;null==(t=yc(this,zh))||t.abort(),Sc(this,zh,null)}attach(t){yc(this,Gh).set(t.id,t);const{annotationElementId:e}=t;e&&yc(this,tc).isDeletedAnnotationElement(e)&&yc(this,tc).removeDeletedAnnotationElement(t)}detach(t){var e;yc(this,Gh).delete(t.id),null==(e=yc(this,Bh))||e.removePointerInTextLayer(t.contentDiv),!yc(this,Uh)&&t.annotationElementId&&yc(this,tc).addDeletedAnnotationElement(t)}remove(t){this.detach(t),yc(this,tc).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(yc(this,tc).addDeletedAnnotationElement(t.annotationElementId),xu.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),null==(e=t.parent)||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),yc(this,tc).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!yc(this,qh)),yc(this,tc).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var e;if(!t.isAttachedToDOM)return;const{activeElement:s}=document;t.div.contains(s)&&!yc(this,jh)&&(t._focusEventsAllowed=!1,Sc(this,jh,setTimeout(()=>{Sc(this,jh,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:yc(this,tc)._signal}),s.focus())},0))),t._structTreeParentId=null==(e=yc(this,Bh))?void 0:e.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){this.addCommands({cmd:()=>t._uiManager.rebuild(t),undo:()=>{t.remove()},mustExec:!1})}getNextId(){return yc(this,tc).getId()}combinedSignal(t){return yc(this,tc).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return null==(t=yc(this,sc,nc))?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await yc(this,tc).updateMode(t.mode);const{offsetX:s,offsetY:i}=kc(this,sc,rc).call(this),n=this.getNextId(),a=kc(this,sc,ac).call(this,{parent:this,id:n,x:s,y:i,uiManager:yc(this,tc),isCentered:!0,...e});a&&this.add(a)}async deserialize(e){var s;return await(null==(s=yc(t,ec).get(e.annotationType??e.annotationEditorType))?void 0:s.deserialize(e,this,yc(this,tc)))||null}createAndAddNewEditor(t,e,s={}){const i=this.getNextId(),n=kc(this,sc,ac).call(this,{parent:this,id:i,x:t.offsetX,y:t.offsetY,uiManager:yc(this,tc),isCentered:e,...s});return n&&this.add(n),n}addNewEditor(t={}){this.createAndAddNewEditor(kc(this,sc,rc).call(this),!0,t)}setSelected(t){yc(this,tc).setSelected(t)}toggleSelected(t){yc(this,tc).toggleSelected(t)}unselect(t){yc(this,tc).unselect(t)}pointerup(t){var e;const{isMac:s}=Md.platform;if(0!==t.button||t.ctrlKey&&s)return;if(t.target!==this.div)return;if(!yc(this,Vh))return;if(Sc(this,Vh,!1),(null==(e=yc(this,sc,nc))?void 0:e.isDrawer)&&yc(this,sc,nc).supportMultipleDrawings)return;if(!yc(this,Hh))return void Sc(this,Hh,!0);const i=yc(this,tc).getMode();i!==Hc.STAMP&&i!==Hc.SIGNATURE?this.createAndAddNewEditor(t,!1):yc(this,tc).unselectAll()}pointerdown(t){var e;if(yc(this,tc).getMode()===Hc.HIGHLIGHT&&this.enableTextSelection(),yc(this,Vh))return void Sc(this,Vh,!1);const{isMac:s}=Md.platform;if(0!==t.button||t.ctrlKey&&s)return;if(t.target!==this.div)return;if(Sc(this,Vh,!0),null==(e=yc(this,sc,nc))?void 0:e.isDrawer)return void this.startDrawingSession(t);const i=yc(this,tc).getActive();Sc(this,Hh,!i||i.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),yc(this,Xh))return void yc(this,sc,nc).startDrawing(this,yc(this,tc),!1,t);yc(this,tc).setCurrentDrawingSession(this),Sc(this,Xh,new AbortController);const e=yc(this,tc).combinedSignal(yc(this,Xh));this.div.addEventListener("blur",({relatedTarget:t})=>{t&&!this.div.contains(t)&&(Sc(this,Yh,null),this.commitOrRemove())},{signal:e}),yc(this,sc,nc).startDrawing(this,yc(this,tc),!1,t)}pause(t){if(t){const{activeElement:t}=document;return void(this.div.contains(t)&&Sc(this,Yh,t))}yc(this,Yh)&&setTimeout(()=>{var t;
1null==(t=yc(this,Yh))||t.focus(),Sc(this,Yh,null)},0)}endDrawingSession(t=!1){return yc(this,Xh)?(yc(this,tc).setCurrentDrawingSession(null),yc(this,Xh).abort(),Sc(this,Xh,null),Sc(this,Yh,null),yc(this,sc,nc).endDrawing(t)):null}findNewParent(t,e,s){const i=yc(this,tc).findParent(e,s);return null!==i&&i!==this&&(i.changeParent(t),!0)}commitOrRemove(){return!!yc(this,Xh)&&(this.endDrawingSession(),!0)}onScaleChanging(){yc(this,Xh)&&yc(this,sc,nc).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),(null==(t=yc(this,tc).getActive())?void 0:t.parent)===this&&(yc(this,tc).commitOrRemove(),yc(this,tc).setActiveEditor(null)),yc(this,jh)&&(clearTimeout(yc(this,jh)),Sc(this,jh,null));for(const s of yc(this,Gh).values())null==(e=yc(this,Bh))||e.removePointerInTextLayer(s.contentDiv),s.setParent(null),s.isAttachedToDOM=!1,s.div.remove();this.div=null,yc(this,Gh).clear(),yc(this,tc).removeLayer(this)}render({viewport:t}){this.viewport=t,eu(this.div,t);for(const e of yc(this,tc).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){yc(this,tc).commitOrRemove(),kc(this,sc,oc).call(this);const e=this.viewport.rotation,s=t.rotation;if(this.viewport=t,eu(this.div,{rotation:s}),e!==s)for(const i of yc(this,Gh).values())i.rotate(s)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return yc(this,tc).viewParameters.realScale}};Bh=new WeakMap,Hh=new WeakMap,$h=new WeakMap,zh=new WeakMap,jh=new WeakMap,Gh=new WeakMap,Vh=new WeakMap,Uh=new WeakMap,qh=new WeakMap,Xh=new WeakMap,Yh=new WeakMap,Kh=new WeakMap,Qh=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,tc=new WeakMap,ec=new WeakMap,sc=new WeakSet,ic=function(t){yc(this,tc).unselectAll();const{target:e}=t;if(e===yc(this,Kh).div||("img"===e.getAttribute("role")||e.classList.contains("endOfContent"))&&yc(this,Kh).div.contains(e)){const{isMac:e}=Md.platform;if(0!==t.button||t.ctrlKey&&e)return;yc(this,tc).showAllEditors("highlight",!0,!0),yc(this,Kh).div.classList.add("free"),this.toggleDrawing(),Ff.startHighlighting(this,"ltr"===yc(this,tc).direction,{target:yc(this,Kh).div,x:t.x,y:t.y}),yc(this,Kh).div.addEventListener("pointerup",()=>{yc(this,Kh).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:yc(this,tc)._signal}),t.preventDefault()}},nc=function(){return yc(Jf,ec).get(yc(this,tc).getMode())},ac=function(t){const e=yc(this,sc,nc);return e?new e.prototype.constructor(t):null},rc=function(){const{x:t,y:e,width:s,height:i}=this.div.getBoundingClientRect(),n=Math.max(0,t),a=Math.max(0,e),r=(n+Math.min(window.innerWidth,t+s))/2-t,o=(a+Math.min(window.innerHeight,e+i))/2-e,[l,h]=this.viewport.rotation%180==0?[r,o]:[o,r];return{offsetX:l,offsetY:h}},oc=function(){for(const t of yc(this,Gh).values())t.isEmpty()&&t.remove()},Ac(Jf,"_initialized",!1),xc(Jf,ec,new Map([Mf,Gf,Qf,Ff,Kf].map(t=>[t._editorType,t])));let Zf=Jf;const tm=class t{constructor({pageIndex:t}){xc(this,gc),xc(this,lc,null),xc(this,hc,new Map),xc(this,cc,new Map),this.pageIndex=t}setParent(t){if(yc(this,lc)){if(yc(this,lc)!==t){if(yc(this,hc).size>0)for(const e of yc(this,hc).values())e.remove(),t.append(e);Sc(this,lc,t)}}else Sc(this,lc,t)}static get _svgFactory(){return md(this,"_svgFactory",new Vg)}draw(e,s=!1,i=!1){const n=Mc(t,dc)._++,a=kc(this,gc,fc).call(this),r=t._svgFactory.createElement("defs");a.append(r);const o=t._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${n}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke"),s&&yc(this,cc).set(n,o);const h=i?kc(this,gc,mc).call(this,r,l):null,c=t._svgFactory.createElement("use");return a.append(c),c.setAttribute("href",`#${l}`),this.updateProperties(a,e),yc(this,hc).set(n,a),{id:n,clipPathId:`url(#${h})`}}drawOutline(e,s){const i=Mc(t,dc)._++,n=kc(this,gc,fc).call(this),a=t._svgFactory.createElement("defs");n.append(a);const r=t._svgFactory.createElement("path");a.append(r);const o=`path_p${this.pageIndex}_${i}`;let l;if(r.setAttribute("id",o),r.setAttribute("vector-effect","non-scaling-stroke"),s){const e=t._svgFactory.createElement("mask");a.append(e),l=`mask_p${this.pageIndex}_${i}`,e.setAttribute("id",l),e.setAttribute("maskUnits","objectBoundingBox");const s=t._svgFactory.createElement("rect");e.append(s),s.setAttribute("width","1"),s.setAttribute("height","1"),s.setAttribute("fill","white");const n=t._svgFactory.createElement("use");e.append(n),n.setAttribute("href",`#${o}`),n.setAttribute("stroke","none"),n.setAttribute("fill","black"),n.setAttribute("fill-rule","nonzero"),n.classList.add("mask")}const h=t._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${o}`),l&&h.setAttribute("mask",`url(#${l})`);const c=h.cloneNode();return n.append(c),h.classList.add("mainOutline"),c.classList.add("secondaryOutline"),this.updateProperties(n,e),yc(this,hc).set(i,n),i}finalizeDraw(t,e){yc(this,cc).delete(t),this.updateProperties(t,e)}updateProperties(e,s){var i;if(!s)return;const{root:n,bbox:a,rootClass:r,path:o}=s,l="number"==typeof e?yc(this,hc).get(e):e;if(l){if(n&&kc(this,gc,vc).call(this,l,n),a&&kc(i=t,uc,pc).call(i,l,a),r){const{classList:t}=l;for(const[e,s]of Object.entries(r))t.toggle(e,s)}if(o){const t=l.firstChild.firstChild;kc(this,gc,vc).call(this,t,o)}}}updateParent(t,e){if(e===this)return;const s=yc(this,hc).get(t);s&&(yc(e,lc).append(s),yc(this,hc).delete(t),yc(e,hc).set(t,s))}remove(t){yc(this,cc).delete(t),null!==yc(this,lc)&&(yc(this,hc).get(t).remove(),yc(this,hc).delete(t))}destroy(){Sc(this,lc,null);for(const t of yc(this,hc).values())t.remove();yc(this,hc).clear(),yc(this,cc).clear()}};lc=new WeakMap,hc=new WeakMap,cc=new WeakMap,dc=new WeakMap,uc=new WeakSet,pc=function(t,[e,s,i,n]){const{style:a}=t;a.top=100*s+"%",a.left=100*e+"%",a.width=100*i+"%",a.height=100*n+"%"},gc=new WeakSet,fc=function(){const t=tm._svgFactory.create(1,1,!0);return yc(this,lc).append(t),t.setAttribute("aria-hidden",!0),t},mc=function(t,e){const s=tm._svgFactory.createElement("clipPath");t.append(s);const i=`clip_${e}`;s.setAttribute("id",i),s.setAttribute("clipPathUnits","objectBoundingBox");const n=tm._svgFactory.createElement("use");return s.append(n),n.setAttribute("href",`#${e}`),n.classList.add("clip"),i},vc=function(t,e){for(const[s,i]of Object.entries(e))null===i?t.removeAttribute(s):t.setAttribute(s,i)},xc(tm,uc),xc(tm,dc,0);let em=tm;globalThis._pdfjsTestingUtils={HighlightOutliner:Pf},globalThis.pdfjsLib={AbortException:xd,AnnotationEditorLayer:Zf,AnnotationEditorParamsType:$c,AnnotationEditorType:Hc,AnnotationEditorUIManager:mu,AnnotationLayer:xf,AnnotationMode:Oc,AnnotationType:Kc,build:Fg,ColorPicker:Og,createValidAbsoluteUrl:gd,DOMSVGFactory:Vg,DrawLayer:em,FeatureTest:Md,fetchData:Bd,getDocument:xg,getFilenameFromUrl:Gd,getPdfFilenameFromUrl:Vd,getRGB:Jd,getUuid:Id,getXfaPageViewport:Qd,GlobalWorkerOptions:Vp,ImageKind:Yc,InvalidPDFException:Ad,isDataScheme:zd,isPdfFile:jd,isValidExplicitDest:Fu,MathClamp:Ld,noContextMenu:Xd,normalizeUnicode:Pd,OPS:id,OutputScale:su,PasswordResponses:ld,PDFDataRangeTransport:Mg,PDFDateString:Kd,PDFWorker:Rg,PermissionFlag:zc,PixelsPerInch:Od,RenderingCancelledException:$d,ResponseException:_d,setLayerDimensions:eu,shadow:md,SignatureExtractor:Uf,stopEvent:Yd,SupportedImageMimeTypes:iu,TextLayer:_g,TouchManager:_u,updateUrlHash:fd,Util:Cd,VerbosityLevel:sd,version:Ng,XfaLayer:Ug};export{xd as AbortException,Zf as AnnotationEditorLayer,$c as AnnotationEditorParamsType,Hc as AnnotationEditorType,mu as AnnotationEditorUIManager,xf as AnnotationLayer,Oc as AnnotationMode,Kc as AnnotationType,Og as ColorPicker,Vg as DOMSVGFactory,em as DrawLayer,Md as FeatureTest,Vp as GlobalWorkerOptions,Yc as ImageKind,Ad as InvalidPDFException,Ld as MathClamp,id as OPS,su as OutputScale,Mg as PDFDataRangeTransport,Kd as PDFDateString,Rg as PDFWorker,ld as PasswordResponses,zc as PermissionFlag,Od as PixelsPerInch,$d as RenderingCancelledException,_d as ResponseException,Uf as SignatureExtractor,iu as SupportedImageMimeTypes,_g as TextLayer,_u as TouchManager,Cd as Util,sd as VerbosityLevel,Ug as XfaLayer,Fg as build,gd as createValidAbsoluteUrl,Bd as fetchData,xg as getDocument,Gd as getFilenameFromUrl,Vd as getPdfFilenameFromUrl,Jd as getRGB,Id as getUuid,Qd as getXfaPageViewport,zd as isDataScheme,jd as isPdfFile,Fu as isValidExplicitDest,Xd as noContextMenu,Pd as normalizeUnicode,eu as setLayerDimensions,md as shadow,Yd as stopEvent,fd as updateUrlHash,Ng as version};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.