@ninesstudios/whiteboard 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,30 +1,30 @@
1
- (function(Et,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],B):(Et=typeof globalThis<"u"?globalThis:Et||self,B(Et.Whiteboard={},Et.React,Et.ReactDOM))})(this,(function(Et,B,Se){"use strict";var Vx=Object.defineProperty;var yv=Et=>{throw TypeError(Et)};var Gx=(Et,B,Se)=>B in Et?Vx(Et,B,{enumerable:!0,configurable:!0,writable:!0,value:Se}):Et[B]=Se;var $=(Et,B,Se)=>Gx(Et,typeof B!="symbol"?B+"":B,Se),Bm=(Et,B,Se)=>B.has(Et)||yv("Cannot "+Se);var s=(Et,B,Se)=>(Bm(Et,B,"read from private field"),Se?Se.call(Et):B.get(Et)),v=(Et,B,Se)=>B.has(Et)?yv("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(Et):B.set(Et,Se),p=(Et,B,Se,kr)=>(Bm(Et,B,"write to private field"),kr?kr.call(Et,Se):B.set(Et,Se),Se),A=(Et,B,Se)=>(Bm(Et,B,"access private method"),Se);var Xe=(Et,B,Se,kr)=>({set _(Kp){p(Et,B,Kp,Se)},get _(){return s(Et,B,kr)}});var Fs,bp,jm,Lh,jr,zr,Sn,En,Nh,Ur,El,xl,Fh,Uf,vv,ri,wv,Av,sh,Ou,Bh,$o,js,zs,Sv,Ev,zm,Wo,Vo,Cl,Go,Hf,_l,jh,gi,Tl,yp,ke,Hr,zh,we,$f,xv,Pl,Xi,kl,xe,Ue,Ml,xn,Rl,Cn,mi,$r,Wr,Dl,Vr,as,_n,Yo,Uh,Hh,Ol,$h,ls,Gr,Il,Yr,cs,Vf,Xr,Ll,Wh,qr,Xo,Nl,Kr,Vh,Ie,Yt,Us,Jr,Zr,Gh,Fl,Yh,Qr,hs,Hs,Xh,qh,Tn,q,vp,Um,Cv,_v,Iu,Tv,Pv,kv,Hm,Mv,Rv,Dv,Ov,Mi,Tr,Iv,Lv,$m,Nv,Lu,Wm,Ke,ds,Bn,jl,us,qi,zl,fs,Ii,$s,qo,ps,to,jn,Nu,wp,oi,Pn,Ko,le,Kh,Jo,zn,Zo,Qo,ta,Jh,Vm,Ul,ea,Zh,Qh,td,ed,id,Ws,ia,Vs,na,Gs,eo,Fv,Bv,jv,sa,Un,ge,ne,Ys,Hl,io,nd,ai,ra,Xs,kn,no,sd,oa,Ki,rd,aa,qs,gs,$l,Wl,Mn,la,od,Gf,ht,Gm,ad,Ym,Ap,zv,Uv,Xm,Sp,qm,Hv,$v,Wv,Km,Vv,Jm,Gv,Yv,Xv,Zm,Fu,ca,ha,Ks,li,Yf,qv,ld,Vl,Kt,Gl,Yl,cd,Xl,Ep,so,ms,da,ua,Bu,Jl,Zl,Ql,tc,Ji,bs,hd,Jt,Ce,es,xp,ju,dd,ud,fd,pd,gd,md,bd,yd,ec,Js,Xf,ic,Rn,Kv,Jv,Zv,Cp,vd,fa,nc,Zs,Qs,bi,pa,ga,et,Ai,zu,rh,_p,oh,Qv,Qm,ah,Uu,Hu,tb,$u,sc,ro,Li,Ni,ma,Hn,ba,tr,Xt,Zt,er,Fi,wd,rc,ya,va,ir,yi,ys,Ad,eb,se,_e,$n,oc,ac,Wn,ib,nb,sb,Sd,Ed,lc,xd,Cd,_d,Td,cc,oo,Qt,hc,dc,Pd,rb,Zi,kd,ob,cv,ao,Qi,Md,Rd,wa,nr,Dd,Od,Aa,Id,uc,lo,fc,Ld,pc,Sa,Nd,Fd,gc,Ea,Bd,mc,bc,sr,tw,ew,ab,tn,Tp,lb,iw,nw,Kf,xa,jd,zd,Ud,Hd,rr,Ca,Wu,co,Vn,or,_a,Zf,Ta,Pa,Ci,Pp,sw,rw,Vu,yc,kp,ar,vs,vc,wc,lr,ka,Gu,ho,uo,Ma,en,Da,Ac,He,$d,Sc,cr,Wd,fo,Gn,Vd,te,cb,hb,db,ll,ow,Do,ws,Gd,Ec,Yd,Ia,xc,Dn,Xd,ub,nn,cl,aw,lw,qd,fb,sn,po,Qf,tp,Cc,_c,Te,As,go,La,Tc,Pc,Ss,rn,hr,dr,Pe,ur,mo,Kd,fr,kc,Na,bo,Je,yo,wt,Mp,pb,gb,mb,Rp,bb,cw,hw,dw,uw,Dp,Op,yb,Jd,Zd,Qd,tu,eu,Fa,iu,vb,nu,su,wb,Ba,ja,Mc,vo,ru,za,on,ou,pr,Ip,Ab,an,au,Ua,ln,Le,fw,pw,gw,Lp,gr,Np,Fp,mw,Sb,bw,cn,Yn,Rc,Dc,Es,Tt,Ha,$a,lu,cu,Oc,Ic,wo,hu,ep,ip,$e,Yu,yw,vw,ww,Aw,Sw,Ew,Lc,Wa,br,du,hn,uu,Me,np,xw,fu,pu,gu,Ao,Xn,_i,Cw,Bp,_w,Tw,Eb,mu,Nc,Fc,bu,yr,Va,yu,ji,vu,wu,Ga,dn,un,hi,Bc,jc,vi,zc,On,Au,At,xb,jp,Pw,kw,Mw,Cb,hl,In,lh,Rw,zp,Up,Dw,Ow,Iw,Lw,Nw,Ya,fn,Uc,Ze,Xa,qa,It,_b,Tb,Pb,Xu,Fw,Hp,qu,ch,xs,Qe,ti,Ka,Hc,Ti,di,Ln,Ja,Za,Qa,$c,$p,Pi,Su,Eu,pn,Cs,_s,Wc,Vc,tl,ui,Pr,Bw,jw,zw,sp,Uw,el,Vt,kb,qn,Hw,$w,Mb,Wp,Ww,Vw,Gw,Rb,Db,Yw,So,Ts,Eo,il,be,ei,xo,vr,Co,Yc,wr,nl,Ps,mn,Xc,Lt,Ku,Ju,Vp,Gp,Yp,Ob,Xp,Xw,sl,qc,_o,To,Ar,zi,Po,Kc,Jc,Kn,Sr,ii,Er,ko,Zc,ot,Mo,re,Ib,qw,Rs,Lb,Nb,qp,Zn,ki,rl,xu,rp,Kw,ks,Fb,Jw,Bb;var kr=typeof document<"u"?document.currentScript:null;function Kp(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const Ds=Kp(B);var Zu={exports:{}},dl={};/*
1
+ (function(At,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],B):(At=typeof globalThis<"u"?globalThis:At||self,B(At.Whiteboard={},At.React,At.ReactDOM))})(this,(function(At,B,Se){"use strict";var Yx=Object.defineProperty;var wv=At=>{throw TypeError(At)};var Xx=(At,B,Se)=>B in At?Yx(At,B,{enumerable:!0,configurable:!0,writable:!0,value:Se}):At[B]=Se;var W=(At,B,Se)=>Xx(At,typeof B!="symbol"?B+"":B,Se),jm=(At,B,Se)=>B.has(At)||wv("Cannot "+Se);var s=(At,B,Se)=>(jm(At,B,"read from private field"),Se?Se.call(At):B.get(At)),y=(At,B,Se)=>B.has(At)?wv("Cannot add the same private member more than once"):B instanceof WeakSet?B.add(At):B.set(At,Se),g=(At,B,Se,Pr)=>(jm(At,B,"write to private field"),Pr?Pr.call(At,Se):B.set(At,Se),Se),S=(At,B,Se)=>(jm(At,B,"access private method"),Se);var Ge=(At,B,Se,Pr)=>({set _(Kp){g(At,B,Kp,Se)},get _(){return s(At,B,Pr)}});var Ns,bp,zm,Bh,Br,jr,En,xn,jh,zr,kl,Ml,zh,Hf,Av,si,Sv,Ev,lh,Iu,Uh,Vo,Bs,js,xv,Cv,Um,Go,Yo,Rl,Xo,$f,Dl,Hh,pi,Ol,yp,Re,Ur,$h,Ae,Wf,_v,Il,Ji,Ll,xe,ze,Nl,Cn,Fl,_n,gi,Hr,$r,Bl,Wr,os,Tn,qo,Wh,Vh,jl,Gh,as,Vr,zl,Gr,ls,Gf,Yr,Ul,Yh,Xr,Ko,Hl,qr,Xh,Le,Yt,zs,Kr,Jr,qh,$l,Kh,Zr,cs,Us,Jh,Zh,Pn,q,vp,Hm,Tv,Pv,Lu,kv,Mv,Rv,$m,Dv,Ov,Iv,Lv,Ri,_r,Nv,Fv,Wm,Bv,Nu,Vm,Xe,hs,Bn,Vl,ds,Zi,Gl,us,Li,Hs,Jo,fs,Qr,jn,Fu,wp,ri,kn,Zo,ce,Qh,Qo,zn,ta,ea,ia,td,Gm,Yl,na,ed,id,nd,sd,rd,$s,sa,Ws,ra,Vs,to,jv,zv,Uv,oa,Un,ge,se,Gs,Xl,eo,od,oi,aa,Ys,Mn,io,ad,la,Qi,ld,ca,Xs,ps,ql,Kl,Rn,ha,cd,Yf,ht,Ym,hd,Xm,Ap,Hv,$v,qm,Sp,Km,Wv,Vv,Gv,Jm,Yv,Zm,Xv,qv,Kv,Qm,Bu,da,ua,qs,ai,Xf,Jv,dd,Jl,Kt,Zl,Ql,ud,tc,Ep,no,gs,fa,pa,ju,nc,sc,rc,oc,tn,ms,fd,Jt,Ce,ts,xp,zu,pd,gd,md,bd,yd,vd,wd,Ad,ac,Ks,qf,lc,Dn,Zv,Qv,tw,Cp,Sd,ga,cc,Js,Zs,mi,ma,ba,et,Ai,Uu,ch,_p,hh,ew,tb,dh,Hu,$u,eb,Wu,hc,so,Ni,Fi,ya,Hn,va,Qs,Xt,Zt,tr,Bi,Ed,dc,wa,Aa,er,bi,bs,xd,ib,re,_e,$n,uc,fc,Wn,nb,sb,rb,Cd,_d,pc,Td,Pd,kd,Md,gc,ro,Qt,mc,bc,Rd,ob,en,Dd,ab,hv,oo,nn,Od,Id,Sa,ir,Ld,Nd,Ea,Fd,yc,ao,vc,Bd,wc,xa,jd,zd,Ac,Ca,Ud,Sc,Ec,nr,iw,nw,lb,sn,Tp,cb,sw,rw,Jf,_a,Hd,$d,Wd,Vd,sr,Ta,Vu,lo,Vn,rr,Pa,Qf,ka,Ma,Ci,Pp,ow,aw,Gu,xc,kp,or,ys,Cc,_c,ar,Ra,Yu,co,ho,Da,rn,Ia,Tc,Ue,Gd,Pc,lr,Yd,uo,Gn,Xd,te,hb,db,ub,fl,lw,Io,vs,qd,kc,Kd,Na,Mc,On,Jd,fb,on,pl,cw,hw,Zd,pb,an,fo,tp,ep,Rc,Dc,Te,ws,po,Fa,Oc,Ic,As,ln,cr,hr,Pe,dr,go,Qd,ur,Lc,Ba,mo,qe,bo,vt,Mp,gb,mb,bb,Rp,yb,dw,uw,fw,pw,Dp,Op,vb,tu,eu,iu,nu,su,ja,ru,wb,ou,au,Ab,za,Ua,Nc,yo,lu,Ha,cn,cu,fr,Ip,Sb,hn,hu,$a,dn,Ne,gw,mw,bw,Lp,pr,Np,Fp,yw,Eb,vw,un,Yn,Fc,Bc,Ss,_t,Wa,Va,du,uu,jc,zc,vo,fu,ip,np,He,Xu,ww,Aw,Sw,Ew,xw,Cw,Uc,Ga,mr,pu,fn,gu,De,sp,_w,mu,bu,yu,wo,Xn,_i,Tw,Bp,Pw,kw,xb,vu,Hc,$c,wu,br,Ya,Au,zi,Su,Eu,Xa,pn,gn,ci,Wc,Vc,yi,Gc,In,xu,wt,Cb,jp,Mw,Rw,Dw,_b,gl,Ln,uh,Ow,zp,Up,Iw,Lw,Nw,Fw,Bw,qa,mn,Yc,Ke,Ka,Ja,Dt,Tb,Pb,kb,qu,jw,Hp,Ku,fh,Es,Je,Ze,Za,Xc,Ti,hi,Nn,Qa,tl,el,qc,$p,Pi,Cu,_u,bn,xs,Cs,Kc,Jc,il,di,Tr,zw,Uw,Hw,rp,$w,nl,Wt,Mb,qn,Ww,Vw,Rb,Wp,Gw,Yw,Xw,Db,Ob,qw,Ao,_s,So,sl,be,Qe,Eo,yr,xo,Qc,vr,rl,Ts,vn,th,Ot,Ju,Zu,Vp,Gp,Yp,Ib,Xp,Kw,ol,eh,Co,_o,wr,Ui,To,ih,nh,Kn,Ar,ti,Sr,Po,sh,ot,ko,oe,Lb,Jw,Ms,Nb,Fb,qp,Zn,ki,al,Tu,op,Zw,Ps,Bb,Qw,jb;var Pr=typeof document<"u"?document.currentScript:null;function Kp(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,i.get?i:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const Rs=Kp(B);var Qu={exports:{}},ml={};/*
2
2
  object-assign
3
3
  (c) Sindre Sorhus
4
4
  @license MIT
5
- */var Jp,jb;function zb(){if(jb)return Jp;jb=1;var a=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function i(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function n(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var o={},l=0;l<10;l++)o["_"+String.fromCharCode(l)]=l;var c=Object.getOwnPropertyNames(o).map(function(d){return o[d]});if(c.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(d){h[d]=d}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Jp=n()?Object.assign:function(r,o){for(var l,c=i(r),h,d=1;d<arguments.length;d++){l=Object(arguments[d]);for(var f in l)t.call(l,f)&&(c[f]=l[f]);if(a){h=a(l);for(var u=0;u<h.length;u++)e.call(l,h[u])&&(c[h[u]]=l[h[u]])}}return c},Jp}/** @license React v17.0.2
5
+ */var Jp,zb;function Ub(){if(zb)return Jp;zb=1;var a=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,e=Object.prototype.propertyIsEnumerable;function i(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function n(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var o={},l=0;l<10;l++)o["_"+String.fromCharCode(l)]=l;var c=Object.getOwnPropertyNames(o).map(function(d){return o[d]});if(c.join("")!=="0123456789")return!1;var h={};return"abcdefghijklmnopqrst".split("").forEach(function(d){h[d]=d}),Object.keys(Object.assign({},h)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return Jp=n()?Object.assign:function(r,o){for(var l,c=i(r),h,d=1;d<arguments.length;d++){l=Object(arguments[d]);for(var u in l)t.call(l,u)&&(c[u]=l[u]);if(a){h=a(l);for(var f=0;f<h.length;f++)e.call(l,h[f])&&(c[h[f]]=l[h[f]])}}return c},Jp}/** @license React v17.0.2
6
6
  * react-jsx-runtime.production.min.js
7
7
  *
8
8
  * Copyright (c) Facebook, Inc. and its affiliates.
9
9
  *
10
10
  * This source code is licensed under the MIT license found in the
11
11
  * LICENSE file in the root directory of this source tree.
12
- */var Ub;function Zw(){if(Ub)return dl;Ub=1,zb();var a=B,t=60103;if(dl.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var e=Symbol.for;t=e("react.element"),dl.Fragment=e("react.fragment")}var i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,r={key:!0,ref:!0,__self:!0,__source:!0};function o(l,c,h){var d,f={},u=null,g=null;h!==void 0&&(u=""+h),c.key!==void 0&&(u=""+c.key),c.ref!==void 0&&(g=c.ref);for(d in c)n.call(c,d)&&!r.hasOwnProperty(d)&&(f[d]=c[d]);if(l&&l.defaultProps)for(d in c=l.defaultProps,c)f[d]===void 0&&(f[d]=c[d]);return{$$typeof:t,type:l,key:u,ref:g,props:f,_owner:i.current}}return dl.jsx=o,dl.jsxs=o,dl}var Zp={};/** @license React v17.0.2
12
+ */var Hb;function tA(){if(Hb)return ml;Hb=1,Ub();var a=B,t=60103;if(ml.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var e=Symbol.for;t=e("react.element"),ml.Fragment=e("react.fragment")}var i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n=Object.prototype.hasOwnProperty,r={key:!0,ref:!0,__self:!0,__source:!0};function o(l,c,h){var d,u={},f=null,p=null;h!==void 0&&(f=""+h),c.key!==void 0&&(f=""+c.key),c.ref!==void 0&&(p=c.ref);for(d in c)n.call(c,d)&&!r.hasOwnProperty(d)&&(u[d]=c[d]);if(l&&l.defaultProps)for(d in c=l.defaultProps,c)u[d]===void 0&&(u[d]=c[d]);return{$$typeof:t,type:l,key:f,ref:p,props:u,_owner:i.current}}return ml.jsx=o,ml.jsxs=o,ml}var Zp={};/** @license React v17.0.2
13
13
  * react-jsx-runtime.development.js
14
14
  *
15
15
  * Copyright (c) Facebook, Inc. and its affiliates.
16
16
  *
17
17
  * This source code is licensed under the MIT license found in the
18
18
  * LICENSE file in the root directory of this source tree.
19
- */var Hb;function Qw(){return Hb||(Hb=1,(function(a){process.env.NODE_ENV!=="production"&&(function(){var t=B,e=zb(),i=60103,n=60106;a.Fragment=60107;var r=60108,o=60114,l=60109,c=60110,h=60112,d=60113,f=60120,u=60115,g=60116,b=60121,m=60122,w=60117,y=60129,x=60131;if(typeof Symbol=="function"&&Symbol.for){var E=Symbol.for;i=E("react.element"),n=E("react.portal"),a.Fragment=E("react.fragment"),r=E("react.strict_mode"),o=E("react.profiler"),l=E("react.provider"),c=E("react.context"),h=E("react.forward_ref"),d=E("react.suspense"),f=E("react.suspense_list"),u=E("react.memo"),g=E("react.lazy"),b=E("react.block"),m=E("react.server.block"),w=E("react.fundamental"),E("react.scope"),E("react.opaque.id"),y=E("react.debug_trace_mode"),E("react.offscreen"),x=E("react.legacy_hidden")}var _=typeof Symbol=="function"&&Symbol.iterator,C="@@iterator";function T(R){if(R===null||typeof R!="object")return null;var W=_&&R[_]||R[C];return typeof W=="function"?W:null}var D=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(R){{for(var W=arguments.length,Q=new Array(W>1?W-1:0),ut=1;ut<W;ut++)Q[ut-1]=arguments[ut];O("error",R,Q)}}function O(R,W,Q){{var ut=D.ReactDebugCurrentFrame,zt=ut.getStackAddendum();zt!==""&&(W+="%s",Q=Q.concat([zt]));var Ft=Q.map(function(Pt){return""+Pt});Ft.unshift("Warning: "+W),Function.prototype.apply.call(console[R],console,Ft)}}var H=!1;function N(R){return!!(typeof R=="string"||typeof R=="function"||R===a.Fragment||R===o||R===y||R===r||R===d||R===f||R===x||H||typeof R=="object"&&R!==null&&(R.$$typeof===g||R.$$typeof===u||R.$$typeof===l||R.$$typeof===c||R.$$typeof===h||R.$$typeof===w||R.$$typeof===b||R[0]===m))}function lt(R,W,Q){var ut=W.displayName||W.name||"";return R.displayName||(ut!==""?Q+"("+ut+")":Q)}function G(R){return R.displayName||"Context"}function K(R){if(R==null)return null;if(typeof R.tag=="number"&&j("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof R=="function")return R.displayName||R.name||null;if(typeof R=="string")return R;switch(R){case a.Fragment:return"Fragment";case n:return"Portal";case o:return"Profiler";case r:return"StrictMode";case d:return"Suspense";case f:return"SuspenseList"}if(typeof R=="object")switch(R.$$typeof){case c:var W=R;return G(W)+".Consumer";case l:var Q=R;return G(Q._context)+".Provider";case h:return lt(R,R.render,"ForwardRef");case u:return K(R.type);case b:return K(R._render);case g:{var ut=R,zt=ut._payload,Ft=ut._init;try{return K(Ft(zt))}catch{return null}}}return null}var rt=0,tt,J,ct,Dt,Ot,jt,vt;function Ct(){}Ct.__reactDisabledLog=!0;function Ae(){{if(rt===0){tt=console.log,J=console.info,ct=console.warn,Dt=console.error,Ot=console.group,jt=console.groupCollapsed,vt=console.groupEnd;var R={configurable:!0,enumerable:!0,value:Ct,writable:!0};Object.defineProperties(console,{info:R,log:R,warn:R,error:R,group:R,groupCollapsed:R,groupEnd:R})}rt++}}function Nt(){{if(rt--,rt===0){var R={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:e({},R,{value:tt}),info:e({},R,{value:J}),warn:e({},R,{value:ct}),error:e({},R,{value:Dt}),group:e({},R,{value:Ot}),groupCollapsed:e({},R,{value:jt}),groupEnd:e({},R,{value:vt})})}rt<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var he=D.ReactCurrentDispatcher,St;function Ui(R,W,Q){{if(St===void 0)try{throw Error()}catch(zt){var ut=zt.stack.trim().match(/\n( *(at )?)/);St=ut&&ut[1]||""}return`
20
- `+St+R}}var Hi=!1,Ne;{var wi=typeof WeakMap=="function"?WeakMap:Map;Ne=new wi}function st(R,W){if(!R||Hi)return"";{var Q=Ne.get(R);if(Q!==void 0)return Q}var ut;Hi=!0;var zt=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ft;Ft=he.current,he.current=null,Ae();try{if(W){var Pt=function(){throw Error()};if(Object.defineProperty(Pt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pt,[])}catch(Wi){ut=Wi}Reflect.construct(R,[],Pt)}else{try{Pt.call()}catch(Wi){ut=Wi}R.call(Pt.prototype)}}else{try{throw Error()}catch(Wi){ut=Wi}R()}}catch(Wi){if(Wi&&ut&&typeof Wi.stack=="string"){for(var xt=Wi.stack.split(`
21
- `),Be=ut.stack.split(`
22
- `),de=xt.length-1,fe=Be.length-1;de>=1&&fe>=0&&xt[de]!==Be[fe];)fe--;for(;de>=1&&fe>=0;de--,fe--)if(xt[de]!==Be[fe]){if(de!==1||fe!==1)do if(de--,fe--,fe<0||xt[de]!==Be[fe]){var $i=`
23
- `+xt[de].replace(" at new "," at ");return typeof R=="function"&&Ne.set(R,$i),$i}while(de>=1&&fe>=0);break}}}finally{Hi=!1,he.current=Ft,Nt(),Error.prepareStackTrace=zt}var Nn=R?R.displayName||R.name:"",Ru=Nn?Ui(Nn):"";return typeof R=="function"&&Ne.set(R,Ru),Ru}function Ve(R,W,Q){return st(R,!1)}function nt(R){var W=R.prototype;return!!(W&&W.isReactComponent)}function Fe(R,W,Q){if(R==null)return"";if(typeof R=="function")return st(R,nt(R));if(typeof R=="string")return Ui(R);switch(R){case d:return Ui("Suspense");case f:return Ui("SuspenseList")}if(typeof R=="object")switch(R.$$typeof){case h:return Ve(R.render);case u:return Fe(R.type,W,Q);case b:return Ve(R._render);case g:{var ut=R,zt=ut._payload,Ft=ut._init;try{return Fe(Ft(zt),W,Q)}catch{}}}return""}var bn={},Qn=D.ReactDebugCurrentFrame;function Ms(R){if(R){var W=R._owner,Q=Fe(R.type,R._source,W?W.type:null);Qn.setExtraStackFrame(Q)}else Qn.setExtraStackFrame(null)}function Dm(R,W,Q,ut,zt){{var Ft=Function.call.bind(Object.prototype.hasOwnProperty);for(var Pt in R)if(Ft(R,Pt)){var xt=void 0;try{if(typeof R[Pt]!="function"){var Be=Error((ut||"React class")+": "+Q+" type `"+Pt+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof R[Pt]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Be.name="Invariant Violation",Be}xt=R[Pt](W,Pt,ut,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(de){xt=de}xt&&!(xt instanceof Error)&&(Ms(zt),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ut||"React class",Q,Pt,typeof xt),Ms(null)),xt instanceof Error&&!(xt.message in bn)&&(bn[xt.message]=!0,Ms(zt),j("Failed %s type: %s",Q,xt.message),Ms(null))}}}var Cu=D.ReactCurrentOwner,Ge=Object.prototype.hasOwnProperty,op={key:!0,ref:!0,__self:!0,__source:!0},Qc,_u;function ap(R){if(Ge.call(R,"ref")){var W=Object.getOwnPropertyDescriptor(R,"ref").get;if(W&&W.isReactWarning)return!1}return R.ref!==void 0}function lp(R){if(Ge.call(R,"key")){var W=Object.getOwnPropertyDescriptor(R,"key").get;if(W&&W.isReactWarning)return!1}return R.key!==void 0}function th(R,W){typeof R.ref=="string"&&Cu.current}function cp(R,W){{var Q=function(){Qc||(Qc=!0,j("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};Q.isReactWarning=!0,Object.defineProperty(R,"key",{get:Q,configurable:!0})}}function oe(R,W){{var Q=function(){_u||(_u=!0,j("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};Q.isReactWarning=!0,Object.defineProperty(R,"ref",{get:Q,configurable:!0})}}var Tu=function(R,W,Q,ut,zt,Ft,Pt){var xt={$$typeof:i,type:R,key:W,ref:Q,props:Pt,_owner:Ft};return xt._store={},Object.defineProperty(xt._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(xt,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ut}),Object.defineProperty(xt,"_source",{configurable:!1,enumerable:!1,writable:!1,value:zt}),Object.freeze&&(Object.freeze(xt.props),Object.freeze(xt)),xt};function yn(R,W,Q,ut,zt){{var Ft,Pt={},xt=null,Be=null;Q!==void 0&&(xt=""+Q),lp(W)&&(xt=""+W.key),ap(W)&&(Be=W.ref,th(W,zt));for(Ft in W)Ge.call(W,Ft)&&!op.hasOwnProperty(Ft)&&(Pt[Ft]=W[Ft]);if(R&&R.defaultProps){var de=R.defaultProps;for(Ft in de)Pt[Ft]===void 0&&(Pt[Ft]=de[Ft])}if(xt||Be){var fe=typeof R=="function"?R.displayName||R.name||"Unknown":R;xt&&cp(Pt,fe),Be&&oe(Pt,fe)}return Tu(R,xt,Be,zt,ut,Cu.current,Pt)}}var eh=D.ReactCurrentOwner,Re=D.ReactDebugCurrentFrame;function ts(R){if(R){var W=R._owner,Q=Fe(R.type,R._source,W?W.type:null);Re.setExtraStackFrame(Q)}else Re.setExtraStackFrame(null)}var xr;xr=!1;function ih(R){return typeof R=="object"&&R!==null&&R.$$typeof===i}function hp(){{if(eh.current){var R=K(eh.current.type);if(R)return`
19
+ */var $b;function eA(){return $b||($b=1,(function(a){process.env.NODE_ENV!=="production"&&(function(){var t=B,e=Ub(),i=60103,n=60106;a.Fragment=60107;var r=60108,o=60114,l=60109,c=60110,h=60112,d=60113,u=60120,f=60115,p=60116,m=60121,b=60122,v=60117,w=60129,_=60131;if(typeof Symbol=="function"&&Symbol.for){var A=Symbol.for;i=A("react.element"),n=A("react.portal"),a.Fragment=A("react.fragment"),r=A("react.strict_mode"),o=A("react.profiler"),l=A("react.provider"),c=A("react.context"),h=A("react.forward_ref"),d=A("react.suspense"),u=A("react.suspense_list"),f=A("react.memo"),p=A("react.lazy"),m=A("react.block"),b=A("react.server.block"),v=A("react.fundamental"),A("react.scope"),A("react.opaque.id"),w=A("react.debug_trace_mode"),A("react.offscreen"),_=A("react.legacy_hidden")}var C=typeof Symbol=="function"&&Symbol.iterator,x="@@iterator";function P(D){if(D===null||typeof D!="object")return null;var V=C&&D[C]||D[x];return typeof V=="function"?V:null}var R=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function N(D){{for(var V=arguments.length,Q=new Array(V>1?V-1:0),dt=1;dt<V;dt++)Q[dt-1]=arguments[dt];z("error",D,Q)}}function z(D,V,Q){{var dt=R.ReactDebugCurrentFrame,jt=dt.getStackAddendum();jt!==""&&(V+="%s",Q=Q.concat([jt]));var Vt=Q.map(function(Tt){return""+Tt});Vt.unshift("Warning: "+V),Function.prototype.apply.call(console[D],console,Vt)}}var H=!1;function I(D){return!!(typeof D=="string"||typeof D=="function"||D===a.Fragment||D===o||D===w||D===r||D===d||D===u||D===_||H||typeof D=="object"&&D!==null&&(D.$$typeof===p||D.$$typeof===f||D.$$typeof===l||D.$$typeof===c||D.$$typeof===h||D.$$typeof===v||D.$$typeof===m||D[0]===b))}function ct(D,V,Q){var dt=V.displayName||V.name||"";return D.displayName||(dt!==""?Q+"("+dt+")":Q)}function j(D){return D.displayName||"Context"}function K(D){if(D==null)return null;if(typeof D.tag=="number"&&N("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof D=="function")return D.displayName||D.name||null;if(typeof D=="string")return D;switch(D){case a.Fragment:return"Fragment";case n:return"Portal";case o:return"Profiler";case r:return"StrictMode";case d:return"Suspense";case u:return"SuspenseList"}if(typeof D=="object")switch(D.$$typeof){case c:var V=D;return j(V)+".Consumer";case l:var Q=D;return j(Q._context)+".Provider";case h:return ct(D,D.render,"ForwardRef");case f:return K(D.type);case m:return K(D._render);case p:{var dt=D,jt=dt._payload,Vt=dt._init;try{return K(Vt(jt))}catch{return null}}}return null}var st=0,tt,J,lt,It,Rt,Bt,St;function xt(){}xt.__reactDisabledLog=!0;function ye(){{if(st===0){tt=console.log,J=console.info,lt=console.warn,It=console.error,Rt=console.group,Bt=console.groupCollapsed,St=console.groupEnd;var D={configurable:!0,enumerable:!0,value:xt,writable:!0};Object.defineProperties(console,{info:D,log:D,warn:D,error:D,group:D,groupCollapsed:D,groupEnd:D})}st++}}function Lt(){{if(st--,st===0){var D={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:e({},D,{value:tt}),info:e({},D,{value:J}),warn:e({},D,{value:lt}),error:e({},D,{value:It}),group:e({},D,{value:Rt}),groupCollapsed:e({},D,{value:Bt}),groupEnd:e({},D,{value:St})})}st<0&&N("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=R.ReactCurrentDispatcher,Nt;function Hi(D,V,Q){{if(Nt===void 0)try{throw Error()}catch(jt){var dt=jt.stack.trim().match(/\n( *(at )?)/);Nt=dt&&dt[1]||""}return`
20
+ `+Nt+D}}var ke=!1,vi;{var wi=typeof WeakMap=="function"?WeakMap:Map;vi=new wi}function it(D,V){if(!D||ke)return"";{var Q=vi.get(D);if(Q!==void 0)return Q}var dt;ke=!0;var jt=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Vt;Vt=ee.current,ee.current=null,ye();try{if(V){var Tt=function(){throw Error()};if(Object.defineProperty(Tt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Tt,[])}catch(Mi){dt=Mi}Reflect.construct(D,[],Tt)}else{try{Tt.call()}catch(Mi){dt=Mi}D.call(Tt.prototype)}}else{try{throw Error()}catch(Mi){dt=Mi}D()}}catch(Mi){if(Mi&&dt&&typeof Mi.stack=="string"){for(var Et=Mi.stack.split(`
21
+ `),Fe=dt.stack.split(`
22
+ `),de=Et.length-1,fe=Fe.length-1;de>=1&&fe>=0&&Et[de]!==Fe[fe];)fe--;for(;de>=1&&fe>=0;de--,fe--)if(Et[de]!==Fe[fe]){if(de!==1||fe!==1)do if(de--,fe--,fe<0||Et[de]!==Fe[fe]){var Yi=`
23
+ `+Et[de].replace(" at new "," at ");return typeof D=="function"&&vi.set(D,Yi),Yi}while(de>=1&&fe>=0);break}}}finally{ke=!1,ee.current=Vt,Lt(),Error.prepareStackTrace=jt}var Qn=D?D.displayName||D.name:"",dl=Qn?Hi(Qn):"";return typeof D=="function"&&vi.set(D,dl),dl}function $i(D,V,Q){return it(D,!1)}function rt(D){var V=D.prototype;return!!(V&&V.isReactComponent)}function We(D,V,Q){if(D==null)return"";if(typeof D=="function")return it(D,rt(D));if(typeof D=="string")return Hi(D);switch(D){case d:return Hi("Suspense");case u:return Hi("SuspenseList")}if(typeof D=="object")switch(D.$$typeof){case h:return $i(D.render);case f:return We(D.type,V,Q);case m:return $i(D._render);case p:{var dt=D,jt=dt._payload,Vt=dt._init;try{return We(Vt(jt),V,Q)}catch{}}}return""}var Wi={},Vi=R.ReactDebugCurrentFrame;function ks(D){if(D){var V=D._owner,Q=We(D.type,D._source,V?V.type:null);Vi.setExtraStackFrame(Q)}else Vi.setExtraStackFrame(null)}function ll(D,V,Q,dt,jt){{var Vt=Function.call.bind(Object.prototype.hasOwnProperty);for(var Tt in D)if(Vt(D,Tt)){var Et=void 0;try{if(typeof D[Tt]!="function"){var Fe=Error((dt||"React class")+": "+Q+" type `"+Tt+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof D[Tt]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Fe.name="Invariant Violation",Fe}Et=D[Tt](V,Tt,dt,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(de){Et=de}Et&&!(Et instanceof Error)&&(ks(jt),N("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",dt||"React class",Q,Tt,typeof Et),ks(null)),Et instanceof Error&&!(Et.message in Wi)&&(Wi[Et.message]=!0,ks(jt),N("Failed %s type: %s",Q,Et.message),ks(null))}}}var Mo=R.ReactCurrentOwner,Pu=Object.prototype.hasOwnProperty,ap={key:!0,ref:!0,__self:!0,__source:!0},ei,ku;function Mu(D){if(Pu.call(D,"ref")){var V=Object.getOwnPropertyDescriptor(D,"ref").get;if(V&&V.isReactWarning)return!1}return D.ref!==void 0}function lp(D){if(Pu.call(D,"key")){var V=Object.getOwnPropertyDescriptor(D,"key").get;if(V&&V.isReactWarning)return!1}return D.key!==void 0}function cp(D,V){typeof D.ref=="string"&&Mo.current}function hp(D,V){{var Q=function(){ei||(ei=!0,N("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",V))};Q.isReactWarning=!0,Object.defineProperty(D,"key",{get:Q,configurable:!0})}}function rh(D,V){{var Q=function(){ku||(ku=!0,N("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",V))};Q.isReactWarning=!0,Object.defineProperty(D,"ref",{get:Q,configurable:!0})}}var dp=function(D,V,Q,dt,jt,Vt,Tt){var Et={$$typeof:i,type:D,key:V,ref:Q,props:Tt,_owner:Vt};return Et._store={},Object.defineProperty(Et._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Et,"_self",{configurable:!1,enumerable:!1,writable:!1,value:dt}),Object.defineProperty(Et,"_source",{configurable:!1,enumerable:!1,writable:!1,value:jt}),Object.freeze&&(Object.freeze(Et.props),Object.freeze(Et)),Et};function ae(D,V,Q,dt,jt){{var Vt,Tt={},Et=null,Fe=null;Q!==void 0&&(Et=""+Q),lp(V)&&(Et=""+V.key),Mu(V)&&(Fe=V.ref,cp(V,jt));for(Vt in V)Pu.call(V,Vt)&&!ap.hasOwnProperty(Vt)&&(Tt[Vt]=V[Vt]);if(D&&D.defaultProps){var de=D.defaultProps;for(Vt in de)Tt[Vt]===void 0&&(Tt[Vt]=de[Vt])}if(Et||Fe){var fe=typeof D=="function"?D.displayName||D.name||"Unknown":D;Et&&hp(Tt,fe),Fe&&rh(Tt,fe)}return dp(D,Et,Fe,jt,dt,Mo.current,Tt)}}var cl=R.ReactCurrentOwner,Gi=R.ReactDebugCurrentFrame;function Er(D){if(D){var V=D._owner,Q=We(D.type,D._source,V?V.type:null);Gi.setExtraStackFrame(Q)}else Gi.setExtraStackFrame(null)}var Me;Me=!1;function Ro(D){return typeof D=="object"&&D!==null&&D.$$typeof===i}function Do(){{if(cl.current){var D=K(cl.current.type);if(D)return`
24
24
 
25
- Check the render method of \``+R+"`."}return""}}function Ro(R){return""}var Pu={};function ku(R){{var W=hp();if(!W){var Q=typeof R=="string"?R:R.displayName||R.name;Q&&(W=`
25
+ Check the render method of \``+D+"`."}return""}}function up(D){return""}var fp={};function Oo(D){{var V=Do();if(!V){var Q=typeof D=="string"?D:D.displayName||D.name;Q&&(V=`
26
26
 
27
- Check the top-level render call using <`+Q+">.")}return W}}function dp(R,W){{if(!R._store||R._store.validated||R.key!=null)return;R._store.validated=!0;var Q=ku(W);if(Pu[Q])return;Pu[Q]=!0;var ut="";R&&R._owner&&R._owner!==eh.current&&(ut=" It was passed a child from "+K(R._owner.type)+"."),ts(R),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,ut),ts(null)}}function up(R,W){{if(typeof R!="object")return;if(Array.isArray(R))for(var Q=0;Q<R.length;Q++){var ut=R[Q];ih(ut)&&dp(ut,W)}else if(ih(R))R._store&&(R._store.validated=!0);else if(R){var zt=T(R);if(typeof zt=="function"&&zt!==R.entries)for(var Ft=zt.call(R),Pt;!(Pt=Ft.next()).done;)ih(Pt.value)&&dp(Pt.value,W)}}}function fp(R){{var W=R.type;if(W==null||typeof W=="string")return;var Q;if(typeof W=="function")Q=W.propTypes;else if(typeof W=="object"&&(W.$$typeof===h||W.$$typeof===u))Q=W.propTypes;else return;if(Q){var ut=K(W);Dm(Q,R.props,"prop",ut,R)}else if(W.PropTypes!==void 0&&!xr){xr=!0;var zt=K(W);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",zt||"Unknown")}typeof W.getDefaultProps=="function"&&!W.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Cr(R){{for(var W=Object.keys(R.props),Q=0;Q<W.length;Q++){var ut=W[Q];if(ut!=="children"&&ut!=="key"){ts(R),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ut),ts(null);break}}R.ref!==null&&(ts(R),j("Invalid attribute `ref` supplied to `React.Fragment`."),ts(null))}}function Mu(R,W,Q,ut,zt,Ft){{var Pt=N(R);if(!Pt){var xt="";(R===void 0||typeof R=="object"&&R!==null&&Object.keys(R).length===0)&&(xt+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Be=Ro();Be?xt+=Be:xt+=hp();var de;R===null?de="null":Array.isArray(R)?de="array":R!==void 0&&R.$$typeof===i?(de="<"+(K(R.type)||"Unknown")+" />",xt=" Did you accidentally export a JSX literal instead of a component?"):de=typeof R,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",de,xt)}var fe=yn(R,W,Q,zt,Ft);if(fe==null)return fe;if(Pt){var $i=W.children;if($i!==void 0)if(ut)if(Array.isArray($i)){for(var Nn=0;Nn<$i.length;Nn++)up($i[Nn],R);Object.freeze&&Object.freeze($i)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else up($i,R)}return R===a.Fragment?Cr(fe):fp(fe),fe}}function Om(R,W,Q){return Mu(R,W,Q,!0)}function ol(R,W,Q){return Mu(R,W,Q,!1)}var pp=ol,gp=Om;a.jsx=pp,a.jsxs=gp})()})(Zp)),Zp}var $b;function tA(){return $b||($b=1,process.env.NODE_ENV==="production"?Zu.exports=Zw():Zu.exports=Qw()),Zu.exports}var M=tA(),Qu={exports:{}},Qp={};/**
27
+ Check the top-level render call using <`+Q+">.")}return V}}function Ru(D,V){{if(!D._store||D._store.validated||D.key!=null)return;D._store.validated=!0;var Q=Oo(V);if(fp[Q])return;fp[Q]=!0;var dt="";D&&D._owner&&D._owner!==cl.current&&(dt=" It was passed a child from "+K(D._owner.type)+"."),Er(D),N('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,dt),Er(null)}}function oh(D,V){{if(typeof D!="object")return;if(Array.isArray(D))for(var Q=0;Q<D.length;Q++){var dt=D[Q];Ro(dt)&&Ru(dt,V)}else if(Ro(D))D._store&&(D._store.validated=!0);else if(D){var jt=P(D);if(typeof jt=="function"&&jt!==D.entries)for(var Vt=jt.call(D),Tt;!(Tt=Vt.next()).done;)Ro(Tt.value)&&Ru(Tt.value,V)}}}function Dm(D){{var V=D.type;if(V==null||typeof V=="string")return;var Q;if(typeof V=="function")Q=V.propTypes;else if(typeof V=="object"&&(V.$$typeof===h||V.$$typeof===f))Q=V.propTypes;else return;if(Q){var dt=K(V);ll(Q,D.props,"prop",dt,D)}else if(V.PropTypes!==void 0&&!Me){Me=!0;var jt=K(V);N("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",jt||"Unknown")}typeof V.getDefaultProps=="function"&&!V.getDefaultProps.isReactClassApproved&&N("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Om(D){{for(var V=Object.keys(D.props),Q=0;Q<V.length;Q++){var dt=V[Q];if(dt!=="children"&&dt!=="key"){Er(D),N("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",dt),Er(null);break}}D.ref!==null&&(Er(D),N("Invalid attribute `ref` supplied to `React.Fragment`."),Er(null))}}function Du(D,V,Q,dt,jt,Vt){{var Tt=I(D);if(!Tt){var Et="";(D===void 0||typeof D=="object"&&D!==null&&Object.keys(D).length===0)&&(Et+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Fe=up();Fe?Et+=Fe:Et+=Do();var de;D===null?de="null":Array.isArray(D)?de="array":D!==void 0&&D.$$typeof===i?(de="<"+(K(D.type)||"Unknown")+" />",Et=" Did you accidentally export a JSX literal instead of a component?"):de=typeof D,N("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",de,Et)}var fe=ae(D,V,Q,jt,Vt);if(fe==null)return fe;if(Tt){var Yi=V.children;if(Yi!==void 0)if(dt)if(Array.isArray(Yi)){for(var Qn=0;Qn<Yi.length;Qn++)oh(Yi[Qn],D);Object.freeze&&Object.freeze(Yi)}else N("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else oh(Yi,D)}return D===a.Fragment?Om(fe):Dm(fe),fe}}function xr(D,V,Q){return Du(D,V,Q,!0)}function pp(D,V,Q){return Du(D,V,Q,!1)}var Im=pp,hl=xr;a.jsx=Im,a.jsxs=hl})()})(Zp)),Zp}var Wb;function iA(){return Wb||(Wb=1,process.env.NODE_ENV==="production"?Qu.exports=tA():Qu.exports=eA()),Qu.exports}var M=iA(),tf={exports:{}},Qp={};/**
28
28
  * @license React
29
29
  * use-sync-external-store-shim.production.js
30
30
  *
@@ -32,7 +32,7 @@ Check the top-level render call using <`+Q+">.")}return W}}function dp(R,W){{if(
32
32
  *
33
33
  * This source code is licensed under the MIT license found in the
34
34
  * LICENSE file in the root directory of this source tree.
35
- */var Wb;function eA(){if(Wb)return Qp;Wb=1;var a=B;function t(f,u){return f===u&&(f!==0||1/f===1/u)||f!==f&&u!==u}var e=typeof Object.is=="function"?Object.is:t,i=a.useState,n=a.useEffect,r=a.useLayoutEffect,o=a.useDebugValue;function l(f,u){var g=u(),b=i({inst:{value:g,getSnapshot:u}}),m=b[0].inst,w=b[1];return r(function(){m.value=g,m.getSnapshot=u,c(m)&&w({inst:m})},[f,g,u]),n(function(){return c(m)&&w({inst:m}),f(function(){c(m)&&w({inst:m})})},[f]),o(g),g}function c(f){var u=f.getSnapshot;f=f.value;try{var g=u();return!e(f,g)}catch{return!0}}function h(f,u){return u()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:l;return Qp.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:d,Qp}var tg={};/**
35
+ */var Vb;function nA(){if(Vb)return Qp;Vb=1;var a=B;function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var e=typeof Object.is=="function"?Object.is:t,i=a.useState,n=a.useEffect,r=a.useLayoutEffect,o=a.useDebugValue;function l(u,f){var p=f(),m=i({inst:{value:p,getSnapshot:f}}),b=m[0].inst,v=m[1];return r(function(){b.value=p,b.getSnapshot=f,c(b)&&v({inst:b})},[u,p,f]),n(function(){return c(b)&&v({inst:b}),u(function(){c(b)&&v({inst:b})})},[u]),o(p),p}function c(u){var f=u.getSnapshot;u=u.value;try{var p=f();return!e(u,p)}catch{return!0}}function h(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:l;return Qp.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:d,Qp}var tg={};/**
36
36
  * @license React
37
37
  * use-sync-external-store-shim.development.js
38
38
  *
@@ -40,7 +40,7 @@ Check the top-level render call using <`+Q+">.")}return W}}function dp(R,W){{if(
40
40
  *
41
41
  * This source code is licensed under the MIT license found in the
42
42
  * LICENSE file in the root directory of this source tree.
43
- */var Vb;function iA(){return Vb||(Vb=1,process.env.NODE_ENV!=="production"&&(function(){function a(g,b){return g===b&&(g!==0||1/g===1/b)||g!==g&&b!==b}function t(g,b){d||n.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=b();if(!f){var w=b();r(m,w)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),f=!0)}w=o({inst:{value:m,getSnapshot:b}});var y=w[0].inst,x=w[1];return c(function(){y.value=m,y.getSnapshot=b,e(y)&&x({inst:y})},[g,m,b]),l(function(){return e(y)&&x({inst:y}),g(function(){e(y)&&x({inst:y})})},[g]),h(m),m}function e(g){var b=g.getSnapshot;g=g.value;try{var m=b();return!r(g,m)}catch{return!0}}function i(g,b){return b()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=B,r=typeof Object.is=="function"?Object.is:a,o=n.useState,l=n.useEffect,c=n.useLayoutEffect,h=n.useDebugValue,d=!1,f=!1,u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?i:t;tg.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:u,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),tg}var Gb;function eg(){return Gb||(Gb=1,process.env.NODE_ENV==="production"?Qu.exports=eA():Qu.exports=iA()),Qu.exports}eg();var tf={exports:{}},ig={};/**
43
+ */var Gb;function sA(){return Gb||(Gb=1,process.env.NODE_ENV!=="production"&&(function(){function a(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}function t(p,m){d||n.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var b=m();if(!u){var v=m();r(b,v)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}v=o({inst:{value:b,getSnapshot:m}});var w=v[0].inst,_=v[1];return c(function(){w.value=b,w.getSnapshot=m,e(w)&&_({inst:w})},[p,b,m]),l(function(){return e(w)&&_({inst:w}),p(function(){e(w)&&_({inst:w})})},[p]),h(b),b}function e(p){var m=p.getSnapshot;p=p.value;try{var b=m();return!r(p,b)}catch{return!0}}function i(p,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=B,r=typeof Object.is=="function"?Object.is:a,o=n.useState,l=n.useEffect,c=n.useLayoutEffect,h=n.useDebugValue,d=!1,u=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?i:t;tg.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),tg}var Yb;function eg(){return Yb||(Yb=1,process.env.NODE_ENV==="production"?tf.exports=nA():tf.exports=sA()),tf.exports}eg();var ef={exports:{}},ig={};/**
44
44
  * @license React
45
45
  * use-sync-external-store-shim/with-selector.production.js
46
46
  *
@@ -48,7 +48,7 @@ Check the top-level render call using <`+Q+">.")}return W}}function dp(R,W){{if(
48
48
  *
49
49
  * This source code is licensed under the MIT license found in the
50
50
  * LICENSE file in the root directory of this source tree.
51
- */var Yb;function nA(){if(Yb)return ig;Yb=1;var a=B,t=eg();function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var i=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,r=a.useRef,o=a.useEffect,l=a.useMemo,c=a.useDebugValue;return ig.useSyncExternalStoreWithSelector=function(h,d,f,u,g){var b=r(null);if(b.current===null){var m={hasValue:!1,value:null};b.current=m}else m=b.current;b=l(function(){function y(T){if(!x){if(x=!0,E=T,T=u(T),g!==void 0&&m.hasValue){var D=m.value;if(g(D,T))return _=D}return _=T}if(D=_,i(E,T))return D;var j=u(T);return g!==void 0&&g(D,j)?(E=T,D):(E=T,_=j)}var x=!1,E,_,C=f===void 0?null:f;return[function(){return y(d())},C===null?void 0:function(){return y(C())}]},[d,f,u,g]);var w=n(h,b[0],b[1]);return o(function(){m.hasValue=!0,m.value=w},[w]),c(w),w},ig}var ng={};/**
51
+ */var Xb;function rA(){if(Xb)return ig;Xb=1;var a=B,t=eg();function e(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}var i=typeof Object.is=="function"?Object.is:e,n=t.useSyncExternalStore,r=a.useRef,o=a.useEffect,l=a.useMemo,c=a.useDebugValue;return ig.useSyncExternalStoreWithSelector=function(h,d,u,f,p){var m=r(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=l(function(){function w(P){if(!_){if(_=!0,A=P,P=f(P),p!==void 0&&b.hasValue){var R=b.value;if(p(R,P))return C=R}return C=P}if(R=C,i(A,P))return R;var N=f(P);return p!==void 0&&p(R,N)?(A=P,R):(A=P,C=N)}var _=!1,A,C,x=u===void 0?null:u;return[function(){return w(d())},x===null?void 0:function(){return w(x())}]},[d,u,f,p]);var v=n(h,m[0],m[1]);return o(function(){b.hasValue=!0,b.value=v},[v]),c(v),v},ig}var ng={};/**
52
52
  * @license React
53
53
  * use-sync-external-store-shim/with-selector.development.js
54
54
  *
@@ -56,23 +56,23 @@ Check the top-level render call using <`+Q+">.")}return W}}function dp(R,W){{if(
56
56
  *
57
57
  * This source code is licensed under the MIT license found in the
58
58
  * LICENSE file in the root directory of this source tree.
59
- */var Xb;function sA(){return Xb||(Xb=1,process.env.NODE_ENV!=="production"&&(function(){function a(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=B,e=eg(),i=typeof Object.is=="function"?Object.is:a,n=e.useSyncExternalStore,r=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;ng.useSyncExternalStoreWithSelector=function(h,d,f,u,g){var b=r(null);if(b.current===null){var m={hasValue:!1,value:null};b.current=m}else m=b.current;b=l(function(){function y(T){if(!x){if(x=!0,E=T,T=u(T),g!==void 0&&m.hasValue){var D=m.value;if(g(D,T))return _=D}return _=T}if(D=_,i(E,T))return D;var j=u(T);return g!==void 0&&g(D,j)?(E=T,D):(E=T,_=j)}var x=!1,E,_,C=f===void 0?null:f;return[function(){return y(d())},C===null?void 0:function(){return y(C())}]},[d,f,u,g]);var w=n(h,b[0],b[1]);return o(function(){m.hasValue=!0,m.value=w},[w]),c(w),w},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),ng}var qb;function rA(){return qb||(qb=1,process.env.NODE_ENV==="production"?tf.exports=nA():tf.exports=sA()),tf.exports}var oA=rA();function aA(a){a()}let Kb=aA;const lA=a=>Kb=a,cA=()=>Kb,Jb=Symbol.for("react-redux-context"),Zb=typeof globalThis<"u"?globalThis:{};function hA(){var a;if(!Ds.createContext)return{};const t=(a=Zb[Jb])!=null?a:Zb[Jb]=new Map;let e=t.get(Ds.createContext);return e||(e=Ds.createContext(null),process.env.NODE_ENV!=="production"&&(e.displayName="ReactRedux"),t.set(Ds.createContext,e)),e}const Mr=hA();function sg(a=Mr){return function(){const e=B.useContext(a);if(process.env.NODE_ENV!=="production"&&!e)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return e}}const Qb=sg();let ty=()=>{throw new Error("uSES not initialized!")};const dA=a=>{ty=a},uA=(a,t)=>a===t;function fA(a=Mr){const t=a===Mr?Qb:sg(a);return function(i,n={}){const{equalityFn:r=uA,stabilityCheck:o=void 0,noopCheck:l=void 0}=typeof n=="function"?{equalityFn:n}:n;if(process.env.NODE_ENV!=="production"){if(!i)throw new Error("You must pass a selector to useSelector");if(typeof i!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof r!="function")throw new Error("You must pass a function as an equality function to useSelector")}const{store:c,subscription:h,getServerState:d,stabilityCheck:f,noopCheck:u}=t(),g=B.useRef(!0),b=B.useCallback({[i.name](w){const y=i(w);if(process.env.NODE_ENV!=="production"){const x=typeof o>"u"?f:o;if(x==="always"||x==="once"&&g.current){const _=i(w);if(!r(y,_)){let C;try{throw new Error}catch(T){({stack:C}=T)}console.warn("Selector "+(i.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
60
- Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:w,selected:y,selected2:_,stack:C})}}const E=typeof l>"u"?u:l;if((E==="always"||E==="once"&&g.current)&&y===w){let _;try{throw new Error}catch(C){({stack:_}=C)}console.warn("Selector "+(i.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
61
- Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:_})}g.current&&(g.current=!1)}return y}}[i.name],[i,f,o]),m=ty(h.addNestedSub,c.getState,d||c.getState,b,r);return B.useDebugValue(m),m}}const ni=fA();var ef={exports:{}},Ut={};/** @license React v16.13.1
59
+ */var qb;function oA(){return qb||(qb=1,process.env.NODE_ENV!=="production"&&(function(){function a(h,d){return h===d&&(h!==0||1/h===1/d)||h!==h&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=B,e=eg(),i=typeof Object.is=="function"?Object.is:a,n=e.useSyncExternalStore,r=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;ng.useSyncExternalStoreWithSelector=function(h,d,u,f,p){var m=r(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=l(function(){function w(P){if(!_){if(_=!0,A=P,P=f(P),p!==void 0&&b.hasValue){var R=b.value;if(p(R,P))return C=R}return C=P}if(R=C,i(A,P))return R;var N=f(P);return p!==void 0&&p(R,N)?(A=P,R):(A=P,C=N)}var _=!1,A,C,x=u===void 0?null:u;return[function(){return w(d())},x===null?void 0:function(){return w(x())}]},[d,u,f,p]);var v=n(h,m[0],m[1]);return o(function(){b.hasValue=!0,b.value=v},[v]),c(v),v},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),ng}var Kb;function aA(){return Kb||(Kb=1,process.env.NODE_ENV==="production"?ef.exports=rA():ef.exports=oA()),ef.exports}var lA=aA();function cA(a){a()}let Jb=cA;const hA=a=>Jb=a,dA=()=>Jb,Zb=Symbol.for("react-redux-context"),Qb=typeof globalThis<"u"?globalThis:{};function uA(){var a;if(!Rs.createContext)return{};const t=(a=Qb[Zb])!=null?a:Qb[Zb]=new Map;let e=t.get(Rs.createContext);return e||(e=Rs.createContext(null),process.env.NODE_ENV!=="production"&&(e.displayName="ReactRedux"),t.set(Rs.createContext,e)),e}const kr=uA();function sg(a=kr){return function(){const e=B.useContext(a);if(process.env.NODE_ENV!=="production"&&!e)throw new Error("could not find react-redux context value; please ensure the component is wrapped in a <Provider>");return e}}const ty=sg();let ey=()=>{throw new Error("uSES not initialized!")};const fA=a=>{ey=a},pA=(a,t)=>a===t;function gA(a=kr){const t=a===kr?ty:sg(a);return function(i,n={}){const{equalityFn:r=pA,stabilityCheck:o=void 0,noopCheck:l=void 0}=typeof n=="function"?{equalityFn:n}:n;if(process.env.NODE_ENV!=="production"){if(!i)throw new Error("You must pass a selector to useSelector");if(typeof i!="function")throw new Error("You must pass a function as a selector to useSelector");if(typeof r!="function")throw new Error("You must pass a function as an equality function to useSelector")}const{store:c,subscription:h,getServerState:d,stabilityCheck:u,noopCheck:f}=t(),p=B.useRef(!0),m=B.useCallback({[i.name](v){const w=i(v);if(process.env.NODE_ENV!=="production"){const _=typeof o>"u"?u:o;if(_==="always"||_==="once"&&p.current){const C=i(v);if(!r(w,C)){let x;try{throw new Error}catch(P){({stack:x}=P)}console.warn("Selector "+(i.name||"unknown")+` returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
60
+ Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization`,{state:v,selected:w,selected2:C,stack:x})}}const A=typeof l>"u"?f:l;if((A==="always"||A==="once"&&p.current)&&w===v){let C;try{throw new Error}catch(x){({stack:C}=x)}console.warn("Selector "+(i.name||"unknown")+` returned the root state when called. This can lead to unnecessary rerenders.
61
+ Selectors that return the entire state are almost certainly a mistake, as they will cause a rerender whenever *anything* in state changes.`,{stack:C})}p.current&&(p.current=!1)}return w}}[i.name],[i,u,o]),b=ey(h.addNestedSub,c.getState,d||c.getState,m,r);return B.useDebugValue(b),b}}const ii=gA();var nf={exports:{}},zt={};/** @license React v16.13.1
62
62
  * react-is.production.min.js
63
63
  *
64
64
  * Copyright (c) Facebook, Inc. and its affiliates.
65
65
  *
66
66
  * This source code is licensed under the MIT license found in the
67
67
  * LICENSE file in the root directory of this source tree.
68
- */var ey;function pA(){if(ey)return Ut;ey=1;var a=typeof Symbol=="function"&&Symbol.for,t=a?Symbol.for("react.element"):60103,e=a?Symbol.for("react.portal"):60106,i=a?Symbol.for("react.fragment"):60107,n=a?Symbol.for("react.strict_mode"):60108,r=a?Symbol.for("react.profiler"):60114,o=a?Symbol.for("react.provider"):60109,l=a?Symbol.for("react.context"):60110,c=a?Symbol.for("react.async_mode"):60111,h=a?Symbol.for("react.concurrent_mode"):60111,d=a?Symbol.for("react.forward_ref"):60112,f=a?Symbol.for("react.suspense"):60113,u=a?Symbol.for("react.suspense_list"):60120,g=a?Symbol.for("react.memo"):60115,b=a?Symbol.for("react.lazy"):60116,m=a?Symbol.for("react.block"):60121,w=a?Symbol.for("react.fundamental"):60117,y=a?Symbol.for("react.responder"):60118,x=a?Symbol.for("react.scope"):60119;function E(C){if(typeof C=="object"&&C!==null){var T=C.$$typeof;switch(T){case t:switch(C=C.type,C){case c:case h:case i:case r:case n:case f:return C;default:switch(C=C&&C.$$typeof,C){case l:case d:case b:case g:case o:return C;default:return T}}case e:return T}}}function _(C){return E(C)===h}return Ut.AsyncMode=c,Ut.ConcurrentMode=h,Ut.ContextConsumer=l,Ut.ContextProvider=o,Ut.Element=t,Ut.ForwardRef=d,Ut.Fragment=i,Ut.Lazy=b,Ut.Memo=g,Ut.Portal=e,Ut.Profiler=r,Ut.StrictMode=n,Ut.Suspense=f,Ut.isAsyncMode=function(C){return _(C)||E(C)===c},Ut.isConcurrentMode=_,Ut.isContextConsumer=function(C){return E(C)===l},Ut.isContextProvider=function(C){return E(C)===o},Ut.isElement=function(C){return typeof C=="object"&&C!==null&&C.$$typeof===t},Ut.isForwardRef=function(C){return E(C)===d},Ut.isFragment=function(C){return E(C)===i},Ut.isLazy=function(C){return E(C)===b},Ut.isMemo=function(C){return E(C)===g},Ut.isPortal=function(C){return E(C)===e},Ut.isProfiler=function(C){return E(C)===r},Ut.isStrictMode=function(C){return E(C)===n},Ut.isSuspense=function(C){return E(C)===f},Ut.isValidElementType=function(C){return typeof C=="string"||typeof C=="function"||C===i||C===h||C===r||C===n||C===f||C===u||typeof C=="object"&&C!==null&&(C.$$typeof===b||C.$$typeof===g||C.$$typeof===o||C.$$typeof===l||C.$$typeof===d||C.$$typeof===w||C.$$typeof===y||C.$$typeof===x||C.$$typeof===m)},Ut.typeOf=E,Ut}var Ht={};/** @license React v16.13.1
68
+ */var iy;function mA(){if(iy)return zt;iy=1;var a=typeof Symbol=="function"&&Symbol.for,t=a?Symbol.for("react.element"):60103,e=a?Symbol.for("react.portal"):60106,i=a?Symbol.for("react.fragment"):60107,n=a?Symbol.for("react.strict_mode"):60108,r=a?Symbol.for("react.profiler"):60114,o=a?Symbol.for("react.provider"):60109,l=a?Symbol.for("react.context"):60110,c=a?Symbol.for("react.async_mode"):60111,h=a?Symbol.for("react.concurrent_mode"):60111,d=a?Symbol.for("react.forward_ref"):60112,u=a?Symbol.for("react.suspense"):60113,f=a?Symbol.for("react.suspense_list"):60120,p=a?Symbol.for("react.memo"):60115,m=a?Symbol.for("react.lazy"):60116,b=a?Symbol.for("react.block"):60121,v=a?Symbol.for("react.fundamental"):60117,w=a?Symbol.for("react.responder"):60118,_=a?Symbol.for("react.scope"):60119;function A(x){if(typeof x=="object"&&x!==null){var P=x.$$typeof;switch(P){case t:switch(x=x.type,x){case c:case h:case i:case r:case n:case u:return x;default:switch(x=x&&x.$$typeof,x){case l:case d:case m:case p:case o:return x;default:return P}}case e:return P}}}function C(x){return A(x)===h}return zt.AsyncMode=c,zt.ConcurrentMode=h,zt.ContextConsumer=l,zt.ContextProvider=o,zt.Element=t,zt.ForwardRef=d,zt.Fragment=i,zt.Lazy=m,zt.Memo=p,zt.Portal=e,zt.Profiler=r,zt.StrictMode=n,zt.Suspense=u,zt.isAsyncMode=function(x){return C(x)||A(x)===c},zt.isConcurrentMode=C,zt.isContextConsumer=function(x){return A(x)===l},zt.isContextProvider=function(x){return A(x)===o},zt.isElement=function(x){return typeof x=="object"&&x!==null&&x.$$typeof===t},zt.isForwardRef=function(x){return A(x)===d},zt.isFragment=function(x){return A(x)===i},zt.isLazy=function(x){return A(x)===m},zt.isMemo=function(x){return A(x)===p},zt.isPortal=function(x){return A(x)===e},zt.isProfiler=function(x){return A(x)===r},zt.isStrictMode=function(x){return A(x)===n},zt.isSuspense=function(x){return A(x)===u},zt.isValidElementType=function(x){return typeof x=="string"||typeof x=="function"||x===i||x===h||x===r||x===n||x===u||x===f||typeof x=="object"&&x!==null&&(x.$$typeof===m||x.$$typeof===p||x.$$typeof===o||x.$$typeof===l||x.$$typeof===d||x.$$typeof===v||x.$$typeof===w||x.$$typeof===_||x.$$typeof===b)},zt.typeOf=A,zt}var Ut={};/** @license React v16.13.1
69
69
  * react-is.development.js
70
70
  *
71
71
  * Copyright (c) Facebook, Inc. and its affiliates.
72
72
  *
73
73
  * This source code is licensed under the MIT license found in the
74
74
  * LICENSE file in the root directory of this source tree.
75
- */var iy;function gA(){return iy||(iy=1,process.env.NODE_ENV!=="production"&&(function(){var a=typeof Symbol=="function"&&Symbol.for,t=a?Symbol.for("react.element"):60103,e=a?Symbol.for("react.portal"):60106,i=a?Symbol.for("react.fragment"):60107,n=a?Symbol.for("react.strict_mode"):60108,r=a?Symbol.for("react.profiler"):60114,o=a?Symbol.for("react.provider"):60109,l=a?Symbol.for("react.context"):60110,c=a?Symbol.for("react.async_mode"):60111,h=a?Symbol.for("react.concurrent_mode"):60111,d=a?Symbol.for("react.forward_ref"):60112,f=a?Symbol.for("react.suspense"):60113,u=a?Symbol.for("react.suspense_list"):60120,g=a?Symbol.for("react.memo"):60115,b=a?Symbol.for("react.lazy"):60116,m=a?Symbol.for("react.block"):60121,w=a?Symbol.for("react.fundamental"):60117,y=a?Symbol.for("react.responder"):60118,x=a?Symbol.for("react.scope"):60119;function E(st){return typeof st=="string"||typeof st=="function"||st===i||st===h||st===r||st===n||st===f||st===u||typeof st=="object"&&st!==null&&(st.$$typeof===b||st.$$typeof===g||st.$$typeof===o||st.$$typeof===l||st.$$typeof===d||st.$$typeof===w||st.$$typeof===y||st.$$typeof===x||st.$$typeof===m)}function _(st){if(typeof st=="object"&&st!==null){var Ve=st.$$typeof;switch(Ve){case t:var nt=st.type;switch(nt){case c:case h:case i:case r:case n:case f:return nt;default:var Fe=nt&&nt.$$typeof;switch(Fe){case l:case d:case b:case g:case o:return Fe;default:return Ve}}case e:return Ve}}}var C=c,T=h,D=l,j=o,O=t,H=d,N=i,lt=b,G=g,K=e,rt=r,tt=n,J=f,ct=!1;function Dt(st){return ct||(ct=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),Ot(st)||_(st)===c}function Ot(st){return _(st)===h}function jt(st){return _(st)===l}function vt(st){return _(st)===o}function Ct(st){return typeof st=="object"&&st!==null&&st.$$typeof===t}function Ae(st){return _(st)===d}function Nt(st){return _(st)===i}function he(st){return _(st)===b}function St(st){return _(st)===g}function Ui(st){return _(st)===e}function Hi(st){return _(st)===r}function Ne(st){return _(st)===n}function wi(st){return _(st)===f}Ht.AsyncMode=C,Ht.ConcurrentMode=T,Ht.ContextConsumer=D,Ht.ContextProvider=j,Ht.Element=O,Ht.ForwardRef=H,Ht.Fragment=N,Ht.Lazy=lt,Ht.Memo=G,Ht.Portal=K,Ht.Profiler=rt,Ht.StrictMode=tt,Ht.Suspense=J,Ht.isAsyncMode=Dt,Ht.isConcurrentMode=Ot,Ht.isContextConsumer=jt,Ht.isContextProvider=vt,Ht.isElement=Ct,Ht.isForwardRef=Ae,Ht.isFragment=Nt,Ht.isLazy=he,Ht.isMemo=St,Ht.isPortal=Ui,Ht.isProfiler=Hi,Ht.isStrictMode=Ne,Ht.isSuspense=wi,Ht.isValidElementType=E,Ht.typeOf=_})()),Ht}var ny;function mA(){return ny||(ny=1,process.env.NODE_ENV==="production"?ef.exports=pA():ef.exports=gA()),ef.exports}var rg,sy;function bA(){if(sy)return rg;sy=1;var a=mA(),t={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},e={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},n={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},r={};r[a.ForwardRef]=i,r[a.Memo]=n;function o(b){return a.isMemo(b)?n:r[b.$$typeof]||t}var l=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,u=Object.prototype;function g(b,m,w){if(typeof m!="string"){if(u){var y=f(m);y&&y!==u&&g(b,y,w)}var x=c(m);h&&(x=x.concat(h(m)));for(var E=o(b),_=o(m),C=0;C<x.length;++C){var T=x[C];if(!e[T]&&!(w&&w[T])&&!(_&&_[T])&&!(E&&E[T])){var D=d(m,T);try{l(b,T,D)}catch{}}}}return b}return rg=g,rg}bA();var nf={exports:{}},$t={};/**
75
+ */var ny;function bA(){return ny||(ny=1,process.env.NODE_ENV!=="production"&&(function(){var a=typeof Symbol=="function"&&Symbol.for,t=a?Symbol.for("react.element"):60103,e=a?Symbol.for("react.portal"):60106,i=a?Symbol.for("react.fragment"):60107,n=a?Symbol.for("react.strict_mode"):60108,r=a?Symbol.for("react.profiler"):60114,o=a?Symbol.for("react.provider"):60109,l=a?Symbol.for("react.context"):60110,c=a?Symbol.for("react.async_mode"):60111,h=a?Symbol.for("react.concurrent_mode"):60111,d=a?Symbol.for("react.forward_ref"):60112,u=a?Symbol.for("react.suspense"):60113,f=a?Symbol.for("react.suspense_list"):60120,p=a?Symbol.for("react.memo"):60115,m=a?Symbol.for("react.lazy"):60116,b=a?Symbol.for("react.block"):60121,v=a?Symbol.for("react.fundamental"):60117,w=a?Symbol.for("react.responder"):60118,_=a?Symbol.for("react.scope"):60119;function A(it){return typeof it=="string"||typeof it=="function"||it===i||it===h||it===r||it===n||it===u||it===f||typeof it=="object"&&it!==null&&(it.$$typeof===m||it.$$typeof===p||it.$$typeof===o||it.$$typeof===l||it.$$typeof===d||it.$$typeof===v||it.$$typeof===w||it.$$typeof===_||it.$$typeof===b)}function C(it){if(typeof it=="object"&&it!==null){var $i=it.$$typeof;switch($i){case t:var rt=it.type;switch(rt){case c:case h:case i:case r:case n:case u:return rt;default:var We=rt&&rt.$$typeof;switch(We){case l:case d:case m:case p:case o:return We;default:return $i}}case e:return $i}}}var x=c,P=h,R=l,N=o,z=t,H=d,I=i,ct=m,j=p,K=e,st=r,tt=n,J=u,lt=!1;function It(it){return lt||(lt=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),Rt(it)||C(it)===c}function Rt(it){return C(it)===h}function Bt(it){return C(it)===l}function St(it){return C(it)===o}function xt(it){return typeof it=="object"&&it!==null&&it.$$typeof===t}function ye(it){return C(it)===d}function Lt(it){return C(it)===i}function ee(it){return C(it)===m}function Nt(it){return C(it)===p}function Hi(it){return C(it)===e}function ke(it){return C(it)===r}function vi(it){return C(it)===n}function wi(it){return C(it)===u}Ut.AsyncMode=x,Ut.ConcurrentMode=P,Ut.ContextConsumer=R,Ut.ContextProvider=N,Ut.Element=z,Ut.ForwardRef=H,Ut.Fragment=I,Ut.Lazy=ct,Ut.Memo=j,Ut.Portal=K,Ut.Profiler=st,Ut.StrictMode=tt,Ut.Suspense=J,Ut.isAsyncMode=It,Ut.isConcurrentMode=Rt,Ut.isContextConsumer=Bt,Ut.isContextProvider=St,Ut.isElement=xt,Ut.isForwardRef=ye,Ut.isFragment=Lt,Ut.isLazy=ee,Ut.isMemo=Nt,Ut.isPortal=Hi,Ut.isProfiler=ke,Ut.isStrictMode=vi,Ut.isSuspense=wi,Ut.isValidElementType=A,Ut.typeOf=C})()),Ut}var sy;function yA(){return sy||(sy=1,process.env.NODE_ENV==="production"?nf.exports=mA():nf.exports=bA()),nf.exports}var rg,ry;function vA(){if(ry)return rg;ry=1;var a=yA(),t={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},e={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},i={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},n={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},r={};r[a.ForwardRef]=i,r[a.Memo]=n;function o(m){return a.isMemo(m)?n:r[m.$$typeof]||t}var l=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,u=Object.getPrototypeOf,f=Object.prototype;function p(m,b,v){if(typeof b!="string"){if(f){var w=u(b);w&&w!==f&&p(m,w,v)}var _=c(b);h&&(_=_.concat(h(b)));for(var A=o(m),C=o(b),x=0;x<_.length;++x){var P=_[x];if(!e[P]&&!(v&&v[P])&&!(C&&C[P])&&!(A&&A[P])){var R=d(b,P);try{l(m,P,R)}catch{}}}}return m}return rg=p,rg}vA();var sf={exports:{}},Ht={};/**
76
76
  * @license React
77
77
  * react-is.production.min.js
78
78
  *
@@ -80,7 +80,7 @@ Selectors that return the entire state are almost certainly a mistake, as they w
80
80
  *
81
81
  * This source code is licensed under the MIT license found in the
82
82
  * LICENSE file in the root directory of this source tree.
83
- */var ry;function yA(){if(ry)return $t;ry=1;var a=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),b;b=Symbol.for("react.module.reference");function m(w){if(typeof w=="object"&&w!==null){var y=w.$$typeof;switch(y){case a:switch(w=w.type,w){case e:case n:case i:case h:case d:return w;default:switch(w=w&&w.$$typeof,w){case l:case o:case c:case u:case f:case r:return w;default:return y}}case t:return y}}}return $t.ContextConsumer=o,$t.ContextProvider=r,$t.Element=a,$t.ForwardRef=c,$t.Fragment=e,$t.Lazy=u,$t.Memo=f,$t.Portal=t,$t.Profiler=n,$t.StrictMode=i,$t.Suspense=h,$t.SuspenseList=d,$t.isAsyncMode=function(){return!1},$t.isConcurrentMode=function(){return!1},$t.isContextConsumer=function(w){return m(w)===o},$t.isContextProvider=function(w){return m(w)===r},$t.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===a},$t.isForwardRef=function(w){return m(w)===c},$t.isFragment=function(w){return m(w)===e},$t.isLazy=function(w){return m(w)===u},$t.isMemo=function(w){return m(w)===f},$t.isPortal=function(w){return m(w)===t},$t.isProfiler=function(w){return m(w)===n},$t.isStrictMode=function(w){return m(w)===i},$t.isSuspense=function(w){return m(w)===h},$t.isSuspenseList=function(w){return m(w)===d},$t.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===e||w===n||w===i||w===h||w===d||w===g||typeof w=="object"&&w!==null&&(w.$$typeof===u||w.$$typeof===f||w.$$typeof===r||w.$$typeof===o||w.$$typeof===c||w.$$typeof===b||w.getModuleId!==void 0)},$t.typeOf=m,$t}var Wt={};/**
83
+ */var oy;function wA(){if(oy)return Ht;oy=1;var a=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),m;m=Symbol.for("react.module.reference");function b(v){if(typeof v=="object"&&v!==null){var w=v.$$typeof;switch(w){case a:switch(v=v.type,v){case e:case n:case i:case h:case d:return v;default:switch(v=v&&v.$$typeof,v){case l:case o:case c:case f:case u:case r:return v;default:return w}}case t:return w}}}return Ht.ContextConsumer=o,Ht.ContextProvider=r,Ht.Element=a,Ht.ForwardRef=c,Ht.Fragment=e,Ht.Lazy=f,Ht.Memo=u,Ht.Portal=t,Ht.Profiler=n,Ht.StrictMode=i,Ht.Suspense=h,Ht.SuspenseList=d,Ht.isAsyncMode=function(){return!1},Ht.isConcurrentMode=function(){return!1},Ht.isContextConsumer=function(v){return b(v)===o},Ht.isContextProvider=function(v){return b(v)===r},Ht.isElement=function(v){return typeof v=="object"&&v!==null&&v.$$typeof===a},Ht.isForwardRef=function(v){return b(v)===c},Ht.isFragment=function(v){return b(v)===e},Ht.isLazy=function(v){return b(v)===f},Ht.isMemo=function(v){return b(v)===u},Ht.isPortal=function(v){return b(v)===t},Ht.isProfiler=function(v){return b(v)===n},Ht.isStrictMode=function(v){return b(v)===i},Ht.isSuspense=function(v){return b(v)===h},Ht.isSuspenseList=function(v){return b(v)===d},Ht.isValidElementType=function(v){return typeof v=="string"||typeof v=="function"||v===e||v===n||v===i||v===h||v===d||v===p||typeof v=="object"&&v!==null&&(v.$$typeof===f||v.$$typeof===u||v.$$typeof===r||v.$$typeof===o||v.$$typeof===c||v.$$typeof===m||v.getModuleId!==void 0)},Ht.typeOf=b,Ht}var $t={};/**
84
84
  * @license React
85
85
  * react-is.development.js
86
86
  *
@@ -88,24 +88,24 @@ Selectors that return the entire state are almost certainly a mistake, as they w
88
88
  *
89
89
  * This source code is licensed under the MIT license found in the
90
90
  * LICENSE file in the root directory of this source tree.
91
- */var oy;function vA(){return oy||(oy=1,process.env.NODE_ENV!=="production"&&(function(){var a=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),u=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),b=!1,m=!1,w=!1,y=!1,x=!1,E;E=Symbol.for("react.module.reference");function _(nt){return!!(typeof nt=="string"||typeof nt=="function"||nt===e||nt===n||x||nt===i||nt===h||nt===d||y||nt===g||b||m||w||typeof nt=="object"&&nt!==null&&(nt.$$typeof===u||nt.$$typeof===f||nt.$$typeof===r||nt.$$typeof===o||nt.$$typeof===c||nt.$$typeof===E||nt.getModuleId!==void 0))}function C(nt){if(typeof nt=="object"&&nt!==null){var Fe=nt.$$typeof;switch(Fe){case a:var bn=nt.type;switch(bn){case e:case n:case i:case h:case d:return bn;default:var Qn=bn&&bn.$$typeof;switch(Qn){case l:case o:case c:case u:case f:case r:return Qn;default:return Fe}}case t:return Fe}}}var T=o,D=r,j=a,O=c,H=e,N=u,lt=f,G=t,K=n,rt=i,tt=h,J=d,ct=!1,Dt=!1;function Ot(nt){return ct||(ct=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function jt(nt){return Dt||(Dt=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function vt(nt){return C(nt)===o}function Ct(nt){return C(nt)===r}function Ae(nt){return typeof nt=="object"&&nt!==null&&nt.$$typeof===a}function Nt(nt){return C(nt)===c}function he(nt){return C(nt)===e}function St(nt){return C(nt)===u}function Ui(nt){return C(nt)===f}function Hi(nt){return C(nt)===t}function Ne(nt){return C(nt)===n}function wi(nt){return C(nt)===i}function st(nt){return C(nt)===h}function Ve(nt){return C(nt)===d}Wt.ContextConsumer=T,Wt.ContextProvider=D,Wt.Element=j,Wt.ForwardRef=O,Wt.Fragment=H,Wt.Lazy=N,Wt.Memo=lt,Wt.Portal=G,Wt.Profiler=K,Wt.StrictMode=rt,Wt.Suspense=tt,Wt.SuspenseList=J,Wt.isAsyncMode=Ot,Wt.isConcurrentMode=jt,Wt.isContextConsumer=vt,Wt.isContextProvider=Ct,Wt.isElement=Ae,Wt.isForwardRef=Nt,Wt.isFragment=he,Wt.isLazy=St,Wt.isMemo=Ui,Wt.isPortal=Hi,Wt.isProfiler=Ne,Wt.isStrictMode=wi,Wt.isSuspense=st,Wt.isSuspenseList=Ve,Wt.isValidElementType=_,Wt.typeOf=C})()),Wt}var ay;function wA(){return ay||(ay=1,process.env.NODE_ENV==="production"?nf.exports=yA():nf.exports=vA()),nf.exports}wA();function AA(){const a=cA();let t=null,e=null;return{clear(){t=null,e=null},notify(){a(()=>{let i=t;for(;i;)i.callback(),i=i.next})},get(){let i=[],n=t;for(;n;)i.push(n),n=n.next;return i},subscribe(i){let n=!0,r=e={callback:i,next:null,prev:e};return r.prev?r.prev.next=r:t=r,function(){!n||t===null||(n=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:t=r.next)}}}}const ly={notify(){},get:()=>[]};function SA(a,t){let e,i=ly,n=0,r=!1;function o(m){d();const w=i.subscribe(m);let y=!1;return()=>{y||(y=!0,w(),f())}}function l(){i.notify()}function c(){b.onStateChange&&b.onStateChange()}function h(){return r}function d(){n++,e||(e=a.subscribe(c),i=AA())}function f(){n--,e&&n===0&&(e(),e=void 0,i.clear(),i=ly)}function u(){r||(r=!0,d())}function g(){r&&(r=!1,f())}const b={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:h,trySubscribe:u,tryUnsubscribe:g,getListeners:()=>i};return b}const EA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?Ds.useLayoutEffect:Ds.useEffect;function xA({store:a,context:t,children:e,serverState:i,stabilityCheck:n="once",noopCheck:r="once"}){const o=Ds.useMemo(()=>{const h=SA(a);return{store:a,subscription:h,getServerState:i?()=>i:void 0,stabilityCheck:n,noopCheck:r}},[a,i,n,r]),l=Ds.useMemo(()=>a.getState(),[a]);EA(()=>{const{subscription:h}=o;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),l!==a.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[o,l]);const c=t||Mr;return Ds.createElement(c.Provider,{value:o},e)}function cy(a=Mr){const t=a===Mr?Qb:sg(a);return function(){const{store:i}=t();return i}}const hy=cy();function CA(a=Mr){const t=a===Mr?hy:cy(a);return function(){return t().dispatch}}const og=CA();dA(oA.useSyncExternalStoreWithSelector),lA(Se.unstable_batchedUpdates);const _A={en:{pointer:"Pointer",text:"Text",image:"Image",pencil:"Pencil",rectangle:"Rectangle",circle:"Circle",eraser:"Eraser",fitToView:"Fit to view",exportAsPng:"Export as PNG",toggleGrid:"Toggle Grid",moreShapes:"More Shapes",triangle:"Triangle",diamond:"Diamond",star:"Star",heart:"Heart",hexagon:"Hexagon",octagon:"Octagon",arrow:"Arrow",fontSize:"Font Size",fontColor:"Font Color",layerOrder:"Layer Order",bringToFront:"Bring to Front",sendToBack:"Send to Back",brushColor:"Brush Color",brushSize:"Brush Size",strokeColor:"Stroke Color",fillColor:"Fill Color",strokeWidth:"Stroke Width",language:"Language",english:"English",turkish:"Turkish",trash:"Trash",confirmClear:"Are you sure you want to clear the whiteboard?",cancel:"Cancel",clear:"Clear",deletePdf:"Delete PDF",prevPage:"Previous Page",nextPage:"Next Page",page:"Page",of:"of"},tr:{pointer:"İşaretçi",text:"Metin",image:"Resim",pencil:"Kalem",rectangle:"Dikdörtgen",circle:"Daire",eraser:"Silgi",fitToView:"Ekrana sığdır",exportAsPng:"PNG olarak dışa aktar",toggleGrid:"Izgarayı Aç/Kapat",moreShapes:"Daha Fazla Şekil",triangle:"Üçgen",diamond:"Elmas",star:"Yıldız",heart:"Kalp",hexagon:"Altıgen",octagon:"Sekizgen",arrow:"Ok",fontSize:"Yazı Boyutu",fontColor:"Yazı Rengi",layerOrder:"Katman Sırası",bringToFront:"Öne Getir",sendToBack:"Arkaya Gönder",brushColor:"Fırça Rengi",brushSize:"Fırça Boyutu",strokeColor:"Çizgi Rengi",fillColor:"Dolgu Rengi",strokeWidth:"Çizgi Kalınlığı",language:"Dil",english:"İngilizce",turkish:"Türkçe",trash:"Çöp Kutusu",confirmClear:"Tahtayı temizlemek istediğinizden emin misiniz?",cancel:"İptal",clear:"Temizle",deletePdf:"PDF'i Sil",prevPage:"Önceki Sayfa",nextPage:"Sonraki Sayfa",page:"Sayfa",of:"/"}},dy=B.createContext(void 0),uy="whiteboard-language",TA=()=>{const a=navigator.language;return a&&a.startsWith("tr")?"tr":"en"},PA=()=>{const a=localStorage.getItem(uy);return a&&(a==="en"||a==="tr")?a:TA()},kA=({children:a})=>{const[t,e]=B.useState(PA);B.useEffect(()=>{localStorage.setItem(uy,t)},[t]);const i=r=>_A[t][r]||r,n=r=>{e(r)};return M.jsx(dy.Provider,{value:{language:t,t:i,changeLanguage:n},children:a})},hh=()=>{const a=B.useContext(dy);if(!a)throw new Error("useLanguage must be used within a LanguageProvider");return a};function qe(a){for(var t=arguments.length,e=Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];if(process.env.NODE_ENV!=="production"){var n=BA[a],r=n?typeof n=="function"?n.apply(null,e):n:"unknown error nr: "+a;throw Error("[Immer] "+r)}throw Error("[Immer] minified error nr: "+a+(e.length?" "+e.map((function(o){return"'"+o+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Rr(a){return!!a&&!!a[pe]}function Os(a){var t;return!!a&&((function(e){if(!e||typeof e!="object")return!1;var i=Object.getPrototypeOf(e);if(i===null)return!0;var n=Object.hasOwnProperty.call(i,"constructor")&&i.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===jA})(a)||Array.isArray(a)||!!a[Sy]||!!(!((t=a.constructor)===null||t===void 0)&&t[Sy])||ag(a)||lg(a))}function Oo(a,t,e){e===void 0&&(e=!1),ul(a)===0?(e?Object.keys:gl)(a).forEach((function(i){e&&typeof i=="symbol"||t(i,a[i],a)})):a.forEach((function(i,n){return t(n,i,a)}))}function ul(a){var t=a[pe];return t?t.i>3?t.i-4:t.i:Array.isArray(a)?1:ag(a)?2:lg(a)?3:0}function fl(a,t){return ul(a)===2?a.has(t):Object.prototype.hasOwnProperty.call(a,t)}function MA(a,t){return ul(a)===2?a.get(t):a[t]}function fy(a,t,e){var i=ul(a);i===2?a.set(t,e):i===3?a.add(e):a[t]=e}function py(a,t){return a===t?a!==0||1/a==1/t:a!=a&&t!=t}function ag(a){return NA&&a instanceof Map}function lg(a){return FA&&a instanceof Set}function Dr(a){return a.o||a.t}function cg(a){if(Array.isArray(a))return Array.prototype.slice.call(a);var t=Ey(a);delete t[pe];for(var e=gl(t),i=0;i<e.length;i++){var n=e[i],r=t[n];r.writable===!1&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(t[n]={configurable:!0,writable:!0,enumerable:r.enumerable,value:a[n]})}return Object.create(Object.getPrototypeOf(a),t)}function hg(a,t){return t===void 0&&(t=!1),dg(a)||Rr(a)||!Os(a)||(ul(a)>1&&(a.set=a.add=a.clear=a.delete=RA),Object.freeze(a),t&&Oo(a,(function(e,i){return hg(i,!0)}),!0)),a}function RA(){qe(2)}function dg(a){return a==null||typeof a!="object"||Object.isFrozen(a)}function is(a){var t=wg[a];return t||qe(18,a),t}function DA(a,t){wg[a]||(wg[a]=t)}function ug(){return process.env.NODE_ENV==="production"||pl||qe(0),pl}function fg(a,t){t&&(is("Patches"),a.u=[],a.s=[],a.v=t)}function sf(a){pg(a),a.p.forEach(OA),a.p=null}function pg(a){a===pl&&(pl=a.l)}function gy(a){return pl={p:[],l:pl,h:a,m:!0,_:0}}function OA(a){var t=a[pe];t.i===0||t.i===1?t.j():t.g=!0}function gg(a,t){t._=t.p.length;var e=t.p[0],i=a!==void 0&&a!==e;return t.h.O||is("ES5").S(t,a,i),i?(e[pe].P&&(sf(t),qe(4)),Os(a)&&(a=rf(t,a),t.l||of(t,a)),t.u&&is("Patches").M(e[pe].t,a,t.u,t.s)):a=rf(t,e,[]),sf(t),t.u&&t.v(t.u,t.s),a!==Ay?a:void 0}function rf(a,t,e){if(dg(t))return t;var i=t[pe];if(!i)return Oo(t,(function(l,c){return my(a,i,t,l,c,e)}),!0),t;if(i.A!==a)return t;if(!i.P)return of(a,i.t,!0),i.t;if(!i.I){i.I=!0,i.A._--;var n=i.i===4||i.i===5?i.o=cg(i.k):i.o,r=n,o=!1;i.i===3&&(r=new Set(n),n.clear(),o=!0),Oo(r,(function(l,c){return my(a,i,n,l,c,e,o)})),of(a,n,!1),e&&a.u&&is("Patches").N(i,e,a.u,a.s)}return i.o}function my(a,t,e,i,n,r,o){if(process.env.NODE_ENV!=="production"&&n===e&&qe(5),Rr(n)){var l=rf(a,n,r&&t&&t.i!==3&&!fl(t.R,i)?r.concat(i):void 0);if(fy(e,i,l),!Rr(l))return;a.m=!1}else o&&e.add(n);if(Os(n)&&!dg(n)){if(!a.h.D&&a._<1)return;rf(a,n),t&&t.A.l||of(a,n)}}function of(a,t,e){e===void 0&&(e=!1),!a.l&&a.h.D&&a.m&&hg(t,e)}function mg(a,t){var e=a[pe];return(e?Dr(e):a)[t]}function by(a,t){if(t in a)for(var e=Object.getPrototypeOf(a);e;){var i=Object.getOwnPropertyDescriptor(e,t);if(i)return i;e=Object.getPrototypeOf(e)}}function Or(a){a.P||(a.P=!0,a.l&&Or(a.l))}function bg(a){a.o||(a.o=cg(a.t))}function yg(a,t,e){var i=ag(t)?is("MapSet").F(t,e):lg(t)?is("MapSet").T(t,e):a.O?(function(n,r){var o=Array.isArray(n),l={i:o?1:0,A:r?r.A:ug(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},c=l,h=dh;o&&(c=[l],h=uh);var d=Proxy.revocable(c,h),f=d.revoke,u=d.proxy;return l.k=u,l.j=f,u})(t,e):is("ES5").J(t,e);return(e?e.A:ug()).p.push(i),i}function IA(a){return Rr(a)||qe(22,a),(function t(e){if(!Os(e))return e;var i,n=e[pe],r=ul(e);if(n){if(!n.P&&(n.i<4||!is("ES5").K(n)))return n.t;n.I=!0,i=yy(e,r),n.I=!1}else i=yy(e,r);return Oo(i,(function(o,l){n&&MA(n.t,o)===l||fy(i,o,t(l))})),r===3?new Set(i):i})(a)}function yy(a,t){switch(t){case 2:return new Map(a);case 3:return Array.from(a)}return cg(a)}function LA(){function a(o,l){var c=r[o];return c?c.enumerable=l:r[o]=c={configurable:!0,enumerable:l,get:function(){var h=this[pe];return process.env.NODE_ENV!=="production"&&n(h),dh.get(h,o)},set:function(h){var d=this[pe];process.env.NODE_ENV!=="production"&&n(d),dh.set(d,o,h)}},c}function t(o){for(var l=o.length-1;l>=0;l--){var c=o[l][pe];if(!c.P)switch(c.i){case 5:i(c)&&Or(c);break;case 4:e(c)&&Or(c)}}}function e(o){for(var l=o.t,c=o.k,h=gl(c),d=h.length-1;d>=0;d--){var f=h[d];if(f!==pe){var u=l[f];if(u===void 0&&!fl(l,f))return!0;var g=c[f],b=g&&g[pe];if(b?b.t!==u:!py(g,u))return!0}}var m=!!l[pe];return h.length!==gl(l).length+(m?0:1)}function i(o){var l=o.k;if(l.length!==o.t.length)return!0;var c=Object.getOwnPropertyDescriptor(l,l.length-1);if(c&&!c.get)return!0;for(var h=0;h<l.length;h++)if(!l.hasOwnProperty(h))return!0;return!1}function n(o){o.g&&qe(3,JSON.stringify(Dr(o)))}var r={};DA("ES5",{J:function(o,l){var c=Array.isArray(o),h=(function(f,u){if(f){for(var g=Array(u.length),b=0;b<u.length;b++)Object.defineProperty(g,""+b,a(b,!0));return g}var m=Ey(u);delete m[pe];for(var w=gl(m),y=0;y<w.length;y++){var x=w[y];m[x]=a(x,f||!!m[x].enumerable)}return Object.create(Object.getPrototypeOf(u),m)})(c,o),d={i:c?5:4,A:l?l.A:ug(),P:!1,I:!1,R:{},l,t:o,k:h,o:null,g:!1,C:!1};return Object.defineProperty(h,pe,{value:d,writable:!0}),h},S:function(o,l,c){c?Rr(l)&&l[pe].A===o&&t(o.p):(o.u&&(function h(d){if(d&&typeof d=="object"){var f=d[pe];if(f){var u=f.t,g=f.k,b=f.R,m=f.i;if(m===4)Oo(g,(function(_){_!==pe&&(u[_]!==void 0||fl(u,_)?b[_]||h(g[_]):(b[_]=!0,Or(f)))})),Oo(u,(function(_){g[_]!==void 0||fl(g,_)||(b[_]=!1,Or(f))}));else if(m===5){if(i(f)&&(Or(f),b.length=!0),g.length<u.length)for(var w=g.length;w<u.length;w++)b[w]=!1;else for(var y=u.length;y<g.length;y++)b[y]=!0;for(var x=Math.min(g.length,u.length),E=0;E<x;E++)g.hasOwnProperty(E)||(b[E]=!0),b[E]===void 0&&h(g[E])}}}})(o.p[0]),t(o.p))},K:function(o){return o.i===4?e(o):i(o)}})}var vy,pl,vg=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",NA=typeof Map<"u",FA=typeof Set<"u",wy=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Ay=vg?Symbol.for("immer-nothing"):((vy={})["immer-nothing"]=!0,vy),Sy=vg?Symbol.for("immer-draftable"):"__$immer_draftable",pe=vg?Symbol.for("immer-state"):"__$immer_state",BA={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(a){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+a},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(a){return"Cannot apply patch, path doesn't resolve: "+a},16:'Sets cannot have "replace" patches.',17:function(a){return"Unsupported patch operation: "+a},18:function(a){return"The plugin for '"+a+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+a+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(a){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+a+"'"},22:function(a){return"'current' expects a draft, got: "+a},23:function(a){return"'original' expects a draft, got: "+a},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},jA=""+Object.prototype.constructor,gl=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:Object.getOwnPropertyNames,Ey=Object.getOwnPropertyDescriptors||function(a){var t={};return gl(a).forEach((function(e){t[e]=Object.getOwnPropertyDescriptor(a,e)})),t},wg={},dh={get:function(a,t){if(t===pe)return a;var e=Dr(a);if(!fl(e,t))return(function(n,r,o){var l,c=by(r,o);return c?"value"in c?c.value:(l=c.get)===null||l===void 0?void 0:l.call(n.k):void 0})(a,e,t);var i=e[t];return a.I||!Os(i)?i:i===mg(a.t,t)?(bg(a),a.o[t]=yg(a.A.h,i,a)):i},has:function(a,t){return t in Dr(a)},ownKeys:function(a){return Reflect.ownKeys(Dr(a))},set:function(a,t,e){var i=by(Dr(a),t);if(i!=null&&i.set)return i.set.call(a.k,e),!0;if(!a.P){var n=mg(Dr(a),t),r=n==null?void 0:n[pe];if(r&&r.t===e)return a.o[t]=e,a.R[t]=!1,!0;if(py(e,n)&&(e!==void 0||fl(a.t,t)))return!0;bg(a),Or(a)}return a.o[t]===e&&(e!==void 0||t in a.o)||Number.isNaN(e)&&Number.isNaN(a.o[t])||(a.o[t]=e,a.R[t]=!0),!0},deleteProperty:function(a,t){return mg(a.t,t)!==void 0||t in a.t?(a.R[t]=!1,bg(a),Or(a)):delete a.R[t],a.o&&delete a.o[t],!0},getOwnPropertyDescriptor:function(a,t){var e=Dr(a),i=Reflect.getOwnPropertyDescriptor(e,t);return i&&{writable:!0,configurable:a.i!==1||t!=="length",enumerable:i.enumerable,value:e[t]}},defineProperty:function(){qe(11)},getPrototypeOf:function(a){return Object.getPrototypeOf(a.t)},setPrototypeOf:function(){qe(12)}},uh={};Oo(dh,(function(a,t){uh[a]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),uh.deleteProperty=function(a,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&qe(13),uh.set.call(this,a,t,void 0)},uh.set=function(a,t,e){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&qe(14),dh.set.call(this,a[0],t,e,a[0])};var zA=(function(){function a(e){var i=this;this.O=wy,this.D=!0,this.produce=function(n,r,o){if(typeof n=="function"&&typeof r!="function"){var l=r;r=n;var c=i;return function(m){var w=this;m===void 0&&(m=l);for(var y=arguments.length,x=Array(y>1?y-1:0),E=1;E<y;E++)x[E-1]=arguments[E];return c.produce(m,(function(_){var C;return(C=r).call.apply(C,[w,_].concat(x))}))}}var h;if(typeof r!="function"&&qe(6),o!==void 0&&typeof o!="function"&&qe(7),Os(n)){var d=gy(i),f=yg(i,n,void 0),u=!0;try{h=r(f),u=!1}finally{u?sf(d):pg(d)}return typeof Promise<"u"&&h instanceof Promise?h.then((function(m){return fg(d,o),gg(m,d)}),(function(m){throw sf(d),m})):(fg(d,o),gg(h,d))}if(!n||typeof n!="object"){if((h=r(n))===void 0&&(h=n),h===Ay&&(h=void 0),i.D&&hg(h,!0),o){var g=[],b=[];is("Patches").M(n,h,g,b),o(g,b)}return h}qe(21,n)},this.produceWithPatches=function(n,r){if(typeof n=="function")return function(h){for(var d=arguments.length,f=Array(d>1?d-1:0),u=1;u<d;u++)f[u-1]=arguments[u];return i.produceWithPatches(h,(function(g){return n.apply(void 0,[g].concat(f))}))};var o,l,c=i.produce(n,r,(function(h,d){o=h,l=d}));return typeof Promise<"u"&&c instanceof Promise?c.then((function(h){return[h,o,l]})):[c,o,l]},typeof(e==null?void 0:e.useProxies)=="boolean"&&this.setUseProxies(e.useProxies),typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze)}var t=a.prototype;return t.createDraft=function(e){Os(e)||qe(8),Rr(e)&&(e=IA(e));var i=gy(this),n=yg(this,e,void 0);return n[pe].C=!0,pg(i),n},t.finishDraft=function(e,i){var n=e&&e[pe];process.env.NODE_ENV!=="production"&&(n&&n.C||qe(9),n.I&&qe(10));var r=n.A;return fg(r,i),gg(void 0,r)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!wy&&qe(20),this.O=e},t.applyPatches=function(e,i){var n;for(n=i.length-1;n>=0;n--){var r=i[n];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}n>-1&&(i=i.slice(n+1));var o=is("Patches").$;return Rr(e)?o(e,i):this.produce(e,(function(l){return o(l,i)}))},a})(),Vi=new zA,xy=Vi.produce;Vi.produceWithPatches.bind(Vi),Vi.setAutoFreeze.bind(Vi),Vi.setUseProxies.bind(Vi),Vi.applyPatches.bind(Vi),Vi.createDraft.bind(Vi),Vi.finishDraft.bind(Vi);function fh(a){"@babel/helpers - typeof";return fh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},fh(a)}function UA(a,t){if(fh(a)!="object"||!a)return a;var e=a[Symbol.toPrimitive];if(e!==void 0){var i=e.call(a,t);if(fh(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(a)}function HA(a){var t=UA(a,"string");return fh(t)=="symbol"?t:t+""}function $A(a,t,e){return(t=HA(t))in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function Cy(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(a,n).enumerable})),e.push.apply(e,i)}return e}function _y(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Cy(Object(e),!0).forEach(function(i){$A(a,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):Cy(Object(e)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(e,i))})}return a}function fi(a){return"Minified Redux error #"+a+"; visit https://redux.js.org/Errors?code="+a+" for the full message or use the non-minified dev environment for full errors. "}var Ty=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),Ag=function(){return Math.random().toString(36).substring(7).split("").join(".")},Io={INIT:"@@redux/INIT"+Ag(),REPLACE:"@@redux/REPLACE"+Ag(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Ag()}};function Py(a){if(typeof a!="object"||a===null)return!1;for(var t=a;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(a)===t}function WA(a){if(a===void 0)return"undefined";if(a===null)return"null";var t=typeof a;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(a))return"array";if(YA(a))return"date";if(GA(a))return"error";var e=VA(a);switch(e){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return e}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}function VA(a){return typeof a.constructor=="function"?a.constructor.name:null}function GA(a){return a instanceof Error||typeof a.message=="string"&&a.constructor&&typeof a.constructor.stackTraceLimit=="number"}function YA(a){return a instanceof Date?!0:typeof a.toDateString=="function"&&typeof a.getDate=="function"&&typeof a.setDate=="function"}function Lo(a){var t=typeof a;return process.env.NODE_ENV!=="production"&&(t=WA(a)),t}function ky(a,t,e){var i;if(typeof t=="function"&&typeof e=="function"||typeof e=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?fi(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof e>"u"&&(e=t,t=void 0),typeof e<"u"){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?fi(1):"Expected the enhancer to be a function. Instead, received: '"+Lo(e)+"'");return e(ky)(a,t)}if(typeof a!="function")throw new Error(process.env.NODE_ENV==="production"?fi(2):"Expected the root reducer to be a function. Instead, received: '"+Lo(a)+"'");var n=a,r=t,o=[],l=o,c=!1;function h(){l===o&&(l=o.slice())}function d(){if(c)throw new Error(process.env.NODE_ENV==="production"?fi(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function f(m){if(typeof m!="function")throw new Error(process.env.NODE_ENV==="production"?fi(4):"Expected the listener to be a function. Instead, received: '"+Lo(m)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?fi(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");var w=!0;return h(),l.push(m),function(){if(w){if(c)throw new Error(process.env.NODE_ENV==="production"?fi(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");w=!1,h();var x=l.indexOf(m);l.splice(x,1),o=null}}}function u(m){if(!Py(m))throw new Error(process.env.NODE_ENV==="production"?fi(7):"Actions must be plain objects. Instead, the actual type was: '"+Lo(m)+"'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");if(typeof m.type>"u")throw new Error(process.env.NODE_ENV==="production"?fi(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(c)throw new Error(process.env.NODE_ENV==="production"?fi(9):"Reducers may not dispatch actions.");try{c=!0,r=n(r,m)}finally{c=!1}for(var w=o=l,y=0;y<w.length;y++){var x=w[y];x()}return m}function g(m){if(typeof m!="function")throw new Error(process.env.NODE_ENV==="production"?fi(10):"Expected the nextReducer to be a function. Instead, received: '"+Lo(m));n=m,u({type:Io.REPLACE})}function b(){var m,w=f;return m={subscribe:function(x){if(typeof x!="object"||x===null)throw new Error(process.env.NODE_ENV==="production"?fi(11):"Expected the observer to be an object. Instead, received: '"+Lo(x)+"'");function E(){x.next&&x.next(d())}E();var _=w(E);return{unsubscribe:_}}},m[Ty]=function(){return this},m}return u({type:Io.INIT}),i={dispatch:u,subscribe:f,getState:d,replaceReducer:g},i[Ty]=b,i}function My(a){typeof console<"u"&&typeof console.error=="function"&&console.error(a);try{throw new Error(a)}catch{}}function XA(a,t,e,i){var n=Object.keys(t),r=e&&e.type===Io.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(n.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Py(a))return"The "+r+' has unexpected type of "'+Lo(a)+'". Expected argument to be an object with the following '+('keys: "'+n.join('", "')+'"');var o=Object.keys(a).filter(function(l){return!t.hasOwnProperty(l)&&!i[l]});if(o.forEach(function(l){i[l]=!0}),!(e&&e.type===Io.REPLACE)&&o.length>0)return"Unexpected "+(o.length>1?"keys":"key")+" "+('"'+o.join('", "')+'" found in '+r+". ")+"Expected to find one of the known reducer keys instead: "+('"'+n.join('", "')+'". Unexpected keys will be ignored.')}function qA(a){Object.keys(a).forEach(function(t){var e=a[t],i=e(void 0,{type:Io.INIT});if(typeof i>"u")throw new Error(process.env.NODE_ENV==="production"?fi(12):'The slice reducer for key "'+t+`" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof e(void 0,{type:Io.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?fi(13):'The slice reducer for key "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle '"+Io.INIT+`' or other actions in "redux/*" `)+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}function KA(a){for(var t=Object.keys(a),e={},i=0;i<t.length;i++){var n=t[i];process.env.NODE_ENV!=="production"&&typeof a[n]>"u"&&My('No reducer provided for key "'+n+'"'),typeof a[n]=="function"&&(e[n]=a[n])}var r=Object.keys(e),o;process.env.NODE_ENV!=="production"&&(o={});var l;try{qA(e)}catch(c){l=c}return function(h,d){if(h===void 0&&(h={}),l)throw l;if(process.env.NODE_ENV!=="production"){var f=XA(h,e,d,o);f&&My(f)}for(var u=!1,g={},b=0;b<r.length;b++){var m=r[b],w=e[m],y=h[m],x=w(y,d);if(typeof x>"u"){var E=d&&d.type;throw new Error(process.env.NODE_ENV==="production"?fi(14):"When called with an action of type "+(E?'"'+String(E)+'"':"(unknown type)")+', the slice reducer for key "'+m+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.')}g[m]=x,u=u||x!==y}return u=u||r.length!==Object.keys(h).length,u?g:h}}function af(){for(var a=arguments.length,t=new Array(a),e=0;e<a;e++)t[e]=arguments[e];return t.length===0?function(i){return i}:t.length===1?t[0]:t.reduce(function(i,n){return function(){return i(n.apply(void 0,arguments))}})}function JA(){for(var a=arguments.length,t=new Array(a),e=0;e<a;e++)t[e]=arguments[e];return function(i){return function(){var n=i.apply(void 0,arguments),r=function(){throw new Error(process.env.NODE_ENV==="production"?fi(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},l=t.map(function(c){return c(o)});return r=af.apply(void 0,l)(n.dispatch),_y(_y({},n),{},{dispatch:r})}}}function Ry(a){var t=function(i){var n=i.dispatch,r=i.getState;return function(o){return function(l){return typeof l=="function"?l(n,r,a):o(l)}}};return t}var Sg=Ry();Sg.withExtraArgument=Ry;var Dy=(function(){var a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},a(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");a(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ZA=function(a,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(h){return function(d){return c([h,d])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(r=h[0]&2?n.return:h[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,h[1])).done)return r;switch(n=0,r&&(h=[h[0]&2,r.value]),h[0]){case 0:case 1:r=h;break;case 4:return e.label++,{value:h[1],done:!1};case 5:e.label++,n=h[1],h=[0];continue;case 7:h=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!r||h[1]>r[0]&&h[1]<r[3])){e.label=h[1];break}if(h[0]===6&&e.label<r[1]){e.label=r[1],r=h;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(h);break}r[2]&&e.ops.pop(),e.trys.pop();continue}h=t.call(a,e)}catch(d){h=[6,d],n=0}finally{i=r=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}},ml=function(a,t){for(var e=0,i=t.length,n=a.length;e<i;e++,n++)a[n]=t[e];return a},QA=Object.defineProperty,t1=Object.defineProperties,e1=Object.getOwnPropertyDescriptors,Oy=Object.getOwnPropertySymbols,i1=Object.prototype.hasOwnProperty,n1=Object.prototype.propertyIsEnumerable,Iy=function(a,t,e){return t in a?QA(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e},Ir=function(a,t){for(var e in t||(t={}))i1.call(t,e)&&Iy(a,e,t[e]);if(Oy)for(var i=0,n=Oy(t);i<n.length;i++){var e=n[i];n1.call(t,e)&&Iy(a,e,t[e])}return a},Eg=function(a,t){return t1(a,e1(t))},s1=function(a,t,e){return new Promise(function(i,n){var r=function(c){try{l(e.next(c))}catch(h){n(h)}},o=function(c){try{l(e.throw(c))}catch(h){n(h)}},l=function(c){return c.done?i(c.value):Promise.resolve(c.value).then(r,o)};l((e=e.apply(a,t)).next())})},r1=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?af:af.apply(null,arguments)};function Ly(a){if(typeof a!="object"||a===null)return!1;var t=Object.getPrototypeOf(a);if(t===null)return!0;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return t===e}var o1=function(a){return a&&typeof a.match=="function"};function Lr(a,t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(t){var r=t.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Ir(Ir({type:a,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:a,payload:i[0]}}return e.toString=function(){return""+a},e.type=a,e.match=function(i){return i.type===a},e}function a1(a){return typeof a=="function"&&"type"in a&&o1(a)}function l1(a){var t=a?(""+a).split("/"):[],e=t[t.length-1]||"actionCreator";return'Detected an action creator with type "'+(a||"unknown")+`" being dispatched.
92
- Make sure you're calling the action creator before dispatching, i.e. \`dispatch(`+e+"())` instead of `dispatch("+e+")`. This is necessary even if the action has no payload."}function c1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(i){return function(n){return i(n)}}};var t=a.isActionCreator,e=t===void 0?a1:t;return function(){return function(i){return function(n){return e(n)&&console.warn(l1(n.type)),i(n)}}}}function Ny(a,t){var e=0;return{measureTime:function(i){var n=Date.now();try{return i()}finally{var r=Date.now();e+=r-n}},warnIfExceeded:function(){e>a&&console.warn(t+" took "+e+"ms, which is more than the warning threshold of "+a+`ms.
91
+ */var ay;function AA(){return ay||(ay=1,process.env.NODE_ENV!=="production"&&(function(){var a=Symbol.for("react.element"),t=Symbol.for("react.portal"),e=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),n=Symbol.for("react.profiler"),r=Symbol.for("react.provider"),o=Symbol.for("react.context"),l=Symbol.for("react.server_context"),c=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),d=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),m=!1,b=!1,v=!1,w=!1,_=!1,A;A=Symbol.for("react.module.reference");function C(rt){return!!(typeof rt=="string"||typeof rt=="function"||rt===e||rt===n||_||rt===i||rt===h||rt===d||w||rt===p||m||b||v||typeof rt=="object"&&rt!==null&&(rt.$$typeof===f||rt.$$typeof===u||rt.$$typeof===r||rt.$$typeof===o||rt.$$typeof===c||rt.$$typeof===A||rt.getModuleId!==void 0))}function x(rt){if(typeof rt=="object"&&rt!==null){var We=rt.$$typeof;switch(We){case a:var Wi=rt.type;switch(Wi){case e:case n:case i:case h:case d:return Wi;default:var Vi=Wi&&Wi.$$typeof;switch(Vi){case l:case o:case c:case f:case u:case r:return Vi;default:return We}}case t:return We}}}var P=o,R=r,N=a,z=c,H=e,I=f,ct=u,j=t,K=n,st=i,tt=h,J=d,lt=!1,It=!1;function Rt(rt){return lt||(lt=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 18+.")),!1}function Bt(rt){return It||(It=!0,console.warn("The ReactIs.isConcurrentMode() alias has been deprecated, and will be removed in React 18+.")),!1}function St(rt){return x(rt)===o}function xt(rt){return x(rt)===r}function ye(rt){return typeof rt=="object"&&rt!==null&&rt.$$typeof===a}function Lt(rt){return x(rt)===c}function ee(rt){return x(rt)===e}function Nt(rt){return x(rt)===f}function Hi(rt){return x(rt)===u}function ke(rt){return x(rt)===t}function vi(rt){return x(rt)===n}function wi(rt){return x(rt)===i}function it(rt){return x(rt)===h}function $i(rt){return x(rt)===d}$t.ContextConsumer=P,$t.ContextProvider=R,$t.Element=N,$t.ForwardRef=z,$t.Fragment=H,$t.Lazy=I,$t.Memo=ct,$t.Portal=j,$t.Profiler=K,$t.StrictMode=st,$t.Suspense=tt,$t.SuspenseList=J,$t.isAsyncMode=Rt,$t.isConcurrentMode=Bt,$t.isContextConsumer=St,$t.isContextProvider=xt,$t.isElement=ye,$t.isForwardRef=Lt,$t.isFragment=ee,$t.isLazy=Nt,$t.isMemo=Hi,$t.isPortal=ke,$t.isProfiler=vi,$t.isStrictMode=wi,$t.isSuspense=it,$t.isSuspenseList=$i,$t.isValidElementType=C,$t.typeOf=x})()),$t}var ly;function SA(){return ly||(ly=1,process.env.NODE_ENV==="production"?sf.exports=wA():sf.exports=AA()),sf.exports}SA();function EA(){const a=dA();let t=null,e=null;return{clear(){t=null,e=null},notify(){a(()=>{let i=t;for(;i;)i.callback(),i=i.next})},get(){let i=[],n=t;for(;n;)i.push(n),n=n.next;return i},subscribe(i){let n=!0,r=e={callback:i,next:null,prev:e};return r.prev?r.prev.next=r:t=r,function(){!n||t===null||(n=!1,r.next?r.next.prev=r.prev:e=r.prev,r.prev?r.prev.next=r.next:t=r.next)}}}}const cy={notify(){},get:()=>[]};function xA(a,t){let e,i=cy,n=0,r=!1;function o(b){d();const v=i.subscribe(b);let w=!1;return()=>{w||(w=!0,v(),u())}}function l(){i.notify()}function c(){m.onStateChange&&m.onStateChange()}function h(){return r}function d(){n++,e||(e=a.subscribe(c),i=EA())}function u(){n--,e&&n===0&&(e(),e=void 0,i.clear(),i=cy)}function f(){r||(r=!0,d())}function p(){r&&(r=!1,u())}const m={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:h,trySubscribe:f,tryUnsubscribe:p,getListeners:()=>i};return m}const CA=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?Rs.useLayoutEffect:Rs.useEffect;function _A({store:a,context:t,children:e,serverState:i,stabilityCheck:n="once",noopCheck:r="once"}){const o=Rs.useMemo(()=>{const h=xA(a);return{store:a,subscription:h,getServerState:i?()=>i:void 0,stabilityCheck:n,noopCheck:r}},[a,i,n,r]),l=Rs.useMemo(()=>a.getState(),[a]);CA(()=>{const{subscription:h}=o;return h.onStateChange=h.notifyNestedSubs,h.trySubscribe(),l!==a.getState()&&h.notifyNestedSubs(),()=>{h.tryUnsubscribe(),h.onStateChange=void 0}},[o,l]);const c=t||kr;return Rs.createElement(c.Provider,{value:o},e)}function hy(a=kr){const t=a===kr?ty:sg(a);return function(){const{store:i}=t();return i}}const dy=hy();function TA(a=kr){const t=a===kr?dy:hy(a);return function(){return t().dispatch}}const og=TA();fA(lA.useSyncExternalStoreWithSelector),hA(Se.unstable_batchedUpdates);const PA={en:{pointer:"Pointer",text:"Text",image:"Image",pencil:"Pencil",rectangle:"Rectangle",circle:"Circle",eraser:"Eraser",fitToView:"Fit to view",exportAsPng:"Export as PNG",toggleGrid:"Toggle Grid",moreShapes:"More Shapes",triangle:"Triangle",diamond:"Diamond",star:"Star",heart:"Heart",hexagon:"Hexagon",octagon:"Octagon",arrow:"Arrow",fontSize:"Font Size",fontColor:"Font Color",layerOrder:"Layer Order",bringToFront:"Bring to Front",sendToBack:"Send to Back",brushColor:"Brush Color",brushSize:"Brush Size",strokeColor:"Stroke Color",fillColor:"Fill Color",strokeWidth:"Stroke Width",language:"Language",english:"English",turkish:"Turkish",trash:"Trash",confirmClear:"Are you sure you want to clear the whiteboard?",cancel:"Cancel",clear:"Clear",deletePdf:"Delete PDF",prevPage:"Previous Page",nextPage:"Next Page",page:"Page",of:"of",lockText:"Whiteboard drawing is only for moderator"},tr:{pointer:"İşaretçi",text:"Metin",image:"Resim",pencil:"Kalem",rectangle:"Dikdörtgen",circle:"Daire",eraser:"Silgi",fitToView:"Ekrana sığdır",exportAsPng:"PNG olarak dışa aktar",toggleGrid:"Izgarayı Aç/Kapat",moreShapes:"Daha Fazla Şekil",triangle:"Üçgen",diamond:"Elmas",star:"Yıldız",heart:"Kalp",hexagon:"Altıgen",octagon:"Sekizgen",arrow:"Ok",fontSize:"Yazı Boyutu",fontColor:"Yazı Rengi",layerOrder:"Katman Sırası",bringToFront:"Öne Getir",sendToBack:"Arkaya Gönder",brushColor:"Fırça Rengi",brushSize:"Fırça Boyutu",strokeColor:"Çizgi Rengi",fillColor:"Dolgu Rengi",strokeWidth:"Çizgi Kalınlığı",language:"Dil",english:"İngilizce",turkish:"Türkçe",trash:"Çöp Kutusu",confirmClear:"Tahtayı temizlemek istediğinizden emin misiniz?",cancel:"İptal",clear:"Temizle",deletePdf:"PDF'i Sil",prevPage:"Önceki Sayfa",nextPage:"Sonraki Sayfa",page:"Sayfa",of:"/",lockText:"Tahta çizimi sadece moderatör için"}},uy=B.createContext(void 0),fy="whiteboard-language",kA=()=>{const a=navigator.language;return a&&a.startsWith("tr")?"tr":"en"},MA=()=>{const a=localStorage.getItem(fy);return a&&(a==="en"||a==="tr")?a:kA()},RA=({children:a})=>{const[t,e]=B.useState(MA);B.useEffect(()=>{localStorage.setItem(fy,t)},[t]);const i=r=>PA[t][r]||r,n=r=>{e(r)};return M.jsx(uy.Provider,{value:{language:t,t:i,changeLanguage:n},children:a})},bl=()=>{const a=B.useContext(uy);if(!a)throw new Error("useLanguage must be used within a LanguageProvider");return a};function Ye(a){for(var t=arguments.length,e=Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];if(process.env.NODE_ENV!=="production"){var n=zA[a],r=n?typeof n=="function"?n.apply(null,e):n:"unknown error nr: "+a;throw Error("[Immer] "+r)}throw Error("[Immer] minified error nr: "+a+(e.length?" "+e.map((function(o){return"'"+o+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function Mr(a){return!!a&&!!a[pe]}function Ds(a){var t;return!!a&&((function(e){if(!e||typeof e!="object")return!1;var i=Object.getPrototypeOf(e);if(i===null)return!0;var n=Object.hasOwnProperty.call(i,"constructor")&&i.constructor;return n===Object||typeof n=="function"&&Function.toString.call(n)===UA})(a)||Array.isArray(a)||!!a[Ey]||!!(!((t=a.constructor)===null||t===void 0)&&t[Ey])||ag(a)||lg(a))}function Lo(a,t,e){e===void 0&&(e=!1),yl(a)===0?(e?Object.keys:Al)(a).forEach((function(i){e&&typeof i=="symbol"||t(i,a[i],a)})):a.forEach((function(i,n){return t(n,i,a)}))}function yl(a){var t=a[pe];return t?t.i>3?t.i-4:t.i:Array.isArray(a)?1:ag(a)?2:lg(a)?3:0}function vl(a,t){return yl(a)===2?a.has(t):Object.prototype.hasOwnProperty.call(a,t)}function DA(a,t){return yl(a)===2?a.get(t):a[t]}function py(a,t,e){var i=yl(a);i===2?a.set(t,e):i===3?a.add(e):a[t]=e}function gy(a,t){return a===t?a!==0||1/a==1/t:a!=a&&t!=t}function ag(a){return BA&&a instanceof Map}function lg(a){return jA&&a instanceof Set}function Rr(a){return a.o||a.t}function cg(a){if(Array.isArray(a))return Array.prototype.slice.call(a);var t=xy(a);delete t[pe];for(var e=Al(t),i=0;i<e.length;i++){var n=e[i],r=t[n];r.writable===!1&&(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(t[n]={configurable:!0,writable:!0,enumerable:r.enumerable,value:a[n]})}return Object.create(Object.getPrototypeOf(a),t)}function hg(a,t){return t===void 0&&(t=!1),dg(a)||Mr(a)||!Ds(a)||(yl(a)>1&&(a.set=a.add=a.clear=a.delete=OA),Object.freeze(a),t&&Lo(a,(function(e,i){return hg(i,!0)}),!0)),a}function OA(){Ye(2)}function dg(a){return a==null||typeof a!="object"||Object.isFrozen(a)}function es(a){var t=wg[a];return t||Ye(18,a),t}function IA(a,t){wg[a]||(wg[a]=t)}function ug(){return process.env.NODE_ENV==="production"||wl||Ye(0),wl}function fg(a,t){t&&(es("Patches"),a.u=[],a.s=[],a.v=t)}function rf(a){pg(a),a.p.forEach(LA),a.p=null}function pg(a){a===wl&&(wl=a.l)}function my(a){return wl={p:[],l:wl,h:a,m:!0,_:0}}function LA(a){var t=a[pe];t.i===0||t.i===1?t.j():t.g=!0}function gg(a,t){t._=t.p.length;var e=t.p[0],i=a!==void 0&&a!==e;return t.h.O||es("ES5").S(t,a,i),i?(e[pe].P&&(rf(t),Ye(4)),Ds(a)&&(a=of(t,a),t.l||af(t,a)),t.u&&es("Patches").M(e[pe].t,a,t.u,t.s)):a=of(t,e,[]),rf(t),t.u&&t.v(t.u,t.s),a!==Sy?a:void 0}function of(a,t,e){if(dg(t))return t;var i=t[pe];if(!i)return Lo(t,(function(l,c){return by(a,i,t,l,c,e)}),!0),t;if(i.A!==a)return t;if(!i.P)return af(a,i.t,!0),i.t;if(!i.I){i.I=!0,i.A._--;var n=i.i===4||i.i===5?i.o=cg(i.k):i.o,r=n,o=!1;i.i===3&&(r=new Set(n),n.clear(),o=!0),Lo(r,(function(l,c){return by(a,i,n,l,c,e,o)})),af(a,n,!1),e&&a.u&&es("Patches").N(i,e,a.u,a.s)}return i.o}function by(a,t,e,i,n,r,o){if(process.env.NODE_ENV!=="production"&&n===e&&Ye(5),Mr(n)){var l=of(a,n,r&&t&&t.i!==3&&!vl(t.R,i)?r.concat(i):void 0);if(py(e,i,l),!Mr(l))return;a.m=!1}else o&&e.add(n);if(Ds(n)&&!dg(n)){if(!a.h.D&&a._<1)return;of(a,n),t&&t.A.l||af(a,n)}}function af(a,t,e){e===void 0&&(e=!1),!a.l&&a.h.D&&a.m&&hg(t,e)}function mg(a,t){var e=a[pe];return(e?Rr(e):a)[t]}function yy(a,t){if(t in a)for(var e=Object.getPrototypeOf(a);e;){var i=Object.getOwnPropertyDescriptor(e,t);if(i)return i;e=Object.getPrototypeOf(e)}}function Dr(a){a.P||(a.P=!0,a.l&&Dr(a.l))}function bg(a){a.o||(a.o=cg(a.t))}function yg(a,t,e){var i=ag(t)?es("MapSet").F(t,e):lg(t)?es("MapSet").T(t,e):a.O?(function(n,r){var o=Array.isArray(n),l={i:o?1:0,A:r?r.A:ug(),P:!1,I:!1,R:{},l:r,t:n,k:null,o:null,j:null,C:!1},c=l,h=ph;o&&(c=[l],h=gh);var d=Proxy.revocable(c,h),u=d.revoke,f=d.proxy;return l.k=f,l.j=u,f})(t,e):es("ES5").J(t,e);return(e?e.A:ug()).p.push(i),i}function NA(a){return Mr(a)||Ye(22,a),(function t(e){if(!Ds(e))return e;var i,n=e[pe],r=yl(e);if(n){if(!n.P&&(n.i<4||!es("ES5").K(n)))return n.t;n.I=!0,i=vy(e,r),n.I=!1}else i=vy(e,r);return Lo(i,(function(o,l){n&&DA(n.t,o)===l||py(i,o,t(l))})),r===3?new Set(i):i})(a)}function vy(a,t){switch(t){case 2:return new Map(a);case 3:return Array.from(a)}return cg(a)}function FA(){function a(o,l){var c=r[o];return c?c.enumerable=l:r[o]=c={configurable:!0,enumerable:l,get:function(){var h=this[pe];return process.env.NODE_ENV!=="production"&&n(h),ph.get(h,o)},set:function(h){var d=this[pe];process.env.NODE_ENV!=="production"&&n(d),ph.set(d,o,h)}},c}function t(o){for(var l=o.length-1;l>=0;l--){var c=o[l][pe];if(!c.P)switch(c.i){case 5:i(c)&&Dr(c);break;case 4:e(c)&&Dr(c)}}}function e(o){for(var l=o.t,c=o.k,h=Al(c),d=h.length-1;d>=0;d--){var u=h[d];if(u!==pe){var f=l[u];if(f===void 0&&!vl(l,u))return!0;var p=c[u],m=p&&p[pe];if(m?m.t!==f:!gy(p,f))return!0}}var b=!!l[pe];return h.length!==Al(l).length+(b?0:1)}function i(o){var l=o.k;if(l.length!==o.t.length)return!0;var c=Object.getOwnPropertyDescriptor(l,l.length-1);if(c&&!c.get)return!0;for(var h=0;h<l.length;h++)if(!l.hasOwnProperty(h))return!0;return!1}function n(o){o.g&&Ye(3,JSON.stringify(Rr(o)))}var r={};IA("ES5",{J:function(o,l){var c=Array.isArray(o),h=(function(u,f){if(u){for(var p=Array(f.length),m=0;m<f.length;m++)Object.defineProperty(p,""+m,a(m,!0));return p}var b=xy(f);delete b[pe];for(var v=Al(b),w=0;w<v.length;w++){var _=v[w];b[_]=a(_,u||!!b[_].enumerable)}return Object.create(Object.getPrototypeOf(f),b)})(c,o),d={i:c?5:4,A:l?l.A:ug(),P:!1,I:!1,R:{},l,t:o,k:h,o:null,g:!1,C:!1};return Object.defineProperty(h,pe,{value:d,writable:!0}),h},S:function(o,l,c){c?Mr(l)&&l[pe].A===o&&t(o.p):(o.u&&(function h(d){if(d&&typeof d=="object"){var u=d[pe];if(u){var f=u.t,p=u.k,m=u.R,b=u.i;if(b===4)Lo(p,(function(C){C!==pe&&(f[C]!==void 0||vl(f,C)?m[C]||h(p[C]):(m[C]=!0,Dr(u)))})),Lo(f,(function(C){p[C]!==void 0||vl(p,C)||(m[C]=!1,Dr(u))}));else if(b===5){if(i(u)&&(Dr(u),m.length=!0),p.length<f.length)for(var v=p.length;v<f.length;v++)m[v]=!1;else for(var w=f.length;w<p.length;w++)m[w]=!0;for(var _=Math.min(p.length,f.length),A=0;A<_;A++)p.hasOwnProperty(A)||(m[A]=!0),m[A]===void 0&&h(p[A])}}}})(o.p[0]),t(o.p))},K:function(o){return o.i===4?e(o):i(o)}})}var wy,wl,vg=typeof Symbol<"u"&&typeof Symbol("x")=="symbol",BA=typeof Map<"u",jA=typeof Set<"u",Ay=typeof Proxy<"u"&&Proxy.revocable!==void 0&&typeof Reflect<"u",Sy=vg?Symbol.for("immer-nothing"):((wy={})["immer-nothing"]=!0,wy),Ey=vg?Symbol.for("immer-draftable"):"__$immer_draftable",pe=vg?Symbol.for("immer-state"):"__$immer_state",zA={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(a){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+a},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(a){return"Cannot apply patch, path doesn't resolve: "+a},16:'Sets cannot have "replace" patches.',17:function(a){return"Unsupported patch operation: "+a},18:function(a){return"The plugin for '"+a+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+a+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(a){return"produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+a+"'"},22:function(a){return"'current' expects a draft, got: "+a},23:function(a){return"'original' expects a draft, got: "+a},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},UA=""+Object.prototype.constructor,Al=typeof Reflect<"u"&&Reflect.ownKeys?Reflect.ownKeys:Object.getOwnPropertySymbols!==void 0?function(a){return Object.getOwnPropertyNames(a).concat(Object.getOwnPropertySymbols(a))}:Object.getOwnPropertyNames,xy=Object.getOwnPropertyDescriptors||function(a){var t={};return Al(a).forEach((function(e){t[e]=Object.getOwnPropertyDescriptor(a,e)})),t},wg={},ph={get:function(a,t){if(t===pe)return a;var e=Rr(a);if(!vl(e,t))return(function(n,r,o){var l,c=yy(r,o);return c?"value"in c?c.value:(l=c.get)===null||l===void 0?void 0:l.call(n.k):void 0})(a,e,t);var i=e[t];return a.I||!Ds(i)?i:i===mg(a.t,t)?(bg(a),a.o[t]=yg(a.A.h,i,a)):i},has:function(a,t){return t in Rr(a)},ownKeys:function(a){return Reflect.ownKeys(Rr(a))},set:function(a,t,e){var i=yy(Rr(a),t);if(i!=null&&i.set)return i.set.call(a.k,e),!0;if(!a.P){var n=mg(Rr(a),t),r=n==null?void 0:n[pe];if(r&&r.t===e)return a.o[t]=e,a.R[t]=!1,!0;if(gy(e,n)&&(e!==void 0||vl(a.t,t)))return!0;bg(a),Dr(a)}return a.o[t]===e&&(e!==void 0||t in a.o)||Number.isNaN(e)&&Number.isNaN(a.o[t])||(a.o[t]=e,a.R[t]=!0),!0},deleteProperty:function(a,t){return mg(a.t,t)!==void 0||t in a.t?(a.R[t]=!1,bg(a),Dr(a)):delete a.R[t],a.o&&delete a.o[t],!0},getOwnPropertyDescriptor:function(a,t){var e=Rr(a),i=Reflect.getOwnPropertyDescriptor(e,t);return i&&{writable:!0,configurable:a.i!==1||t!=="length",enumerable:i.enumerable,value:e[t]}},defineProperty:function(){Ye(11)},getPrototypeOf:function(a){return Object.getPrototypeOf(a.t)},setPrototypeOf:function(){Ye(12)}},gh={};Lo(ph,(function(a,t){gh[a]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),gh.deleteProperty=function(a,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&Ye(13),gh.set.call(this,a,t,void 0)},gh.set=function(a,t,e){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&Ye(14),ph.set.call(this,a[0],t,e,a[0])};var HA=(function(){function a(e){var i=this;this.O=Ay,this.D=!0,this.produce=function(n,r,o){if(typeof n=="function"&&typeof r!="function"){var l=r;r=n;var c=i;return function(b){var v=this;b===void 0&&(b=l);for(var w=arguments.length,_=Array(w>1?w-1:0),A=1;A<w;A++)_[A-1]=arguments[A];return c.produce(b,(function(C){var x;return(x=r).call.apply(x,[v,C].concat(_))}))}}var h;if(typeof r!="function"&&Ye(6),o!==void 0&&typeof o!="function"&&Ye(7),Ds(n)){var d=my(i),u=yg(i,n,void 0),f=!0;try{h=r(u),f=!1}finally{f?rf(d):pg(d)}return typeof Promise<"u"&&h instanceof Promise?h.then((function(b){return fg(d,o),gg(b,d)}),(function(b){throw rf(d),b})):(fg(d,o),gg(h,d))}if(!n||typeof n!="object"){if((h=r(n))===void 0&&(h=n),h===Sy&&(h=void 0),i.D&&hg(h,!0),o){var p=[],m=[];es("Patches").M(n,h,p,m),o(p,m)}return h}Ye(21,n)},this.produceWithPatches=function(n,r){if(typeof n=="function")return function(h){for(var d=arguments.length,u=Array(d>1?d-1:0),f=1;f<d;f++)u[f-1]=arguments[f];return i.produceWithPatches(h,(function(p){return n.apply(void 0,[p].concat(u))}))};var o,l,c=i.produce(n,r,(function(h,d){o=h,l=d}));return typeof Promise<"u"&&c instanceof Promise?c.then((function(h){return[h,o,l]})):[c,o,l]},typeof(e==null?void 0:e.useProxies)=="boolean"&&this.setUseProxies(e.useProxies),typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze)}var t=a.prototype;return t.createDraft=function(e){Ds(e)||Ye(8),Mr(e)&&(e=NA(e));var i=my(this),n=yg(this,e,void 0);return n[pe].C=!0,pg(i),n},t.finishDraft=function(e,i){var n=e&&e[pe];process.env.NODE_ENV!=="production"&&(n&&n.C||Ye(9),n.I&&Ye(10));var r=n.A;return fg(r,i),gg(void 0,r)},t.setAutoFreeze=function(e){this.D=e},t.setUseProxies=function(e){e&&!Ay&&Ye(20),this.O=e},t.applyPatches=function(e,i){var n;for(n=i.length-1;n>=0;n--){var r=i[n];if(r.path.length===0&&r.op==="replace"){e=r.value;break}}n>-1&&(i=i.slice(n+1));var o=es("Patches").$;return Mr(e)?o(e,i):this.produce(e,(function(l){return o(l,i)}))},a})(),Xi=new HA,Cy=Xi.produce;Xi.produceWithPatches.bind(Xi),Xi.setAutoFreeze.bind(Xi),Xi.setUseProxies.bind(Xi),Xi.applyPatches.bind(Xi),Xi.createDraft.bind(Xi),Xi.finishDraft.bind(Xi);function mh(a){"@babel/helpers - typeof";return mh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mh(a)}function $A(a,t){if(mh(a)!="object"||!a)return a;var e=a[Symbol.toPrimitive];if(e!==void 0){var i=e.call(a,t);if(mh(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(a)}function WA(a){var t=$A(a,"string");return mh(t)=="symbol"?t:t+""}function VA(a,t,e){return(t=WA(t))in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function _y(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(a,n).enumerable})),e.push.apply(e,i)}return e}function Ty(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?_y(Object(e),!0).forEach(function(i){VA(a,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):_y(Object(e)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(e,i))})}return a}function ui(a){return"Minified Redux error #"+a+"; visit https://redux.js.org/Errors?code="+a+" for the full message or use the non-minified dev environment for full errors. "}var Py=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),Ag=function(){return Math.random().toString(36).substring(7).split("").join(".")},No={INIT:"@@redux/INIT"+Ag(),REPLACE:"@@redux/REPLACE"+Ag(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+Ag()}};function ky(a){if(typeof a!="object"||a===null)return!1;for(var t=a;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(a)===t}function GA(a){if(a===void 0)return"undefined";if(a===null)return"null";var t=typeof a;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(a))return"array";if(qA(a))return"date";if(XA(a))return"error";var e=YA(a);switch(e){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return e}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}function YA(a){return typeof a.constructor=="function"?a.constructor.name:null}function XA(a){return a instanceof Error||typeof a.message=="string"&&a.constructor&&typeof a.constructor.stackTraceLimit=="number"}function qA(a){return a instanceof Date?!0:typeof a.toDateString=="function"&&typeof a.getDate=="function"&&typeof a.setDate=="function"}function Fo(a){var t=typeof a;return process.env.NODE_ENV!=="production"&&(t=GA(a)),t}function My(a,t,e){var i;if(typeof t=="function"&&typeof e=="function"||typeof e=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?ui(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof e>"u"&&(e=t,t=void 0),typeof e<"u"){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?ui(1):"Expected the enhancer to be a function. Instead, received: '"+Fo(e)+"'");return e(My)(a,t)}if(typeof a!="function")throw new Error(process.env.NODE_ENV==="production"?ui(2):"Expected the root reducer to be a function. Instead, received: '"+Fo(a)+"'");var n=a,r=t,o=[],l=o,c=!1;function h(){l===o&&(l=o.slice())}function d(){if(c)throw new Error(process.env.NODE_ENV==="production"?ui(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return r}function u(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?ui(4):"Expected the listener to be a function. Instead, received: '"+Fo(b)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?ui(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");var v=!0;return h(),l.push(b),function(){if(v){if(c)throw new Error(process.env.NODE_ENV==="production"?ui(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");v=!1,h();var _=l.indexOf(b);l.splice(_,1),o=null}}}function f(b){if(!ky(b))throw new Error(process.env.NODE_ENV==="production"?ui(7):"Actions must be plain objects. Instead, the actual type was: '"+Fo(b)+"'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");if(typeof b.type>"u")throw new Error(process.env.NODE_ENV==="production"?ui(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(c)throw new Error(process.env.NODE_ENV==="production"?ui(9):"Reducers may not dispatch actions.");try{c=!0,r=n(r,b)}finally{c=!1}for(var v=o=l,w=0;w<v.length;w++){var _=v[w];_()}return b}function p(b){if(typeof b!="function")throw new Error(process.env.NODE_ENV==="production"?ui(10):"Expected the nextReducer to be a function. Instead, received: '"+Fo(b));n=b,f({type:No.REPLACE})}function m(){var b,v=u;return b={subscribe:function(_){if(typeof _!="object"||_===null)throw new Error(process.env.NODE_ENV==="production"?ui(11):"Expected the observer to be an object. Instead, received: '"+Fo(_)+"'");function A(){_.next&&_.next(d())}A();var C=v(A);return{unsubscribe:C}}},b[Py]=function(){return this},b}return f({type:No.INIT}),i={dispatch:f,subscribe:u,getState:d,replaceReducer:p},i[Py]=m,i}function Ry(a){typeof console<"u"&&typeof console.error=="function"&&console.error(a);try{throw new Error(a)}catch{}}function KA(a,t,e,i){var n=Object.keys(t),r=e&&e.type===No.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(n.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!ky(a))return"The "+r+' has unexpected type of "'+Fo(a)+'". Expected argument to be an object with the following '+('keys: "'+n.join('", "')+'"');var o=Object.keys(a).filter(function(l){return!t.hasOwnProperty(l)&&!i[l]});if(o.forEach(function(l){i[l]=!0}),!(e&&e.type===No.REPLACE)&&o.length>0)return"Unexpected "+(o.length>1?"keys":"key")+" "+('"'+o.join('", "')+'" found in '+r+". ")+"Expected to find one of the known reducer keys instead: "+('"'+n.join('", "')+'". Unexpected keys will be ignored.')}function JA(a){Object.keys(a).forEach(function(t){var e=a[t],i=e(void 0,{type:No.INIT});if(typeof i>"u")throw new Error(process.env.NODE_ENV==="production"?ui(12):'The slice reducer for key "'+t+`" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof e(void 0,{type:No.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?ui(13):'The slice reducer for key "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle '"+No.INIT+`' or other actions in "redux/*" `)+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.")})}function ZA(a){for(var t=Object.keys(a),e={},i=0;i<t.length;i++){var n=t[i];process.env.NODE_ENV!=="production"&&typeof a[n]>"u"&&Ry('No reducer provided for key "'+n+'"'),typeof a[n]=="function"&&(e[n]=a[n])}var r=Object.keys(e),o;process.env.NODE_ENV!=="production"&&(o={});var l;try{JA(e)}catch(c){l=c}return function(h,d){if(h===void 0&&(h={}),l)throw l;if(process.env.NODE_ENV!=="production"){var u=KA(h,e,d,o);u&&Ry(u)}for(var f=!1,p={},m=0;m<r.length;m++){var b=r[m],v=e[b],w=h[b],_=v(w,d);if(typeof _>"u"){var A=d&&d.type;throw new Error(process.env.NODE_ENV==="production"?ui(14):"When called with an action of type "+(A?'"'+String(A)+'"':"(unknown type)")+', the slice reducer for key "'+b+'" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.')}p[b]=_,f=f||_!==w}return f=f||r.length!==Object.keys(h).length,f?p:h}}function lf(){for(var a=arguments.length,t=new Array(a),e=0;e<a;e++)t[e]=arguments[e];return t.length===0?function(i){return i}:t.length===1?t[0]:t.reduce(function(i,n){return function(){return i(n.apply(void 0,arguments))}})}function QA(){for(var a=arguments.length,t=new Array(a),e=0;e<a;e++)t[e]=arguments[e];return function(i){return function(){var n=i.apply(void 0,arguments),r=function(){throw new Error(process.env.NODE_ENV==="production"?ui(15):"Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.")},o={getState:n.getState,dispatch:function(){return r.apply(void 0,arguments)}},l=t.map(function(c){return c(o)});return r=lf.apply(void 0,l)(n.dispatch),Ty(Ty({},n),{},{dispatch:r})}}}function Dy(a){var t=function(i){var n=i.dispatch,r=i.getState;return function(o){return function(l){return typeof l=="function"?l(n,r,a):o(l)}}};return t}var Sg=Dy();Sg.withExtraArgument=Dy;var Oy=(function(){var a=function(t,e){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,n){i.__proto__=n}||function(i,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(i[r]=n[r])},a(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");a(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),t1=function(a,t){var e={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},i,n,r,o;return o={next:l(0),throw:l(1),return:l(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(h){return function(d){return c([h,d])}}function c(h){if(i)throw new TypeError("Generator is already executing.");for(;e;)try{if(i=1,n&&(r=h[0]&2?n.return:h[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,h[1])).done)return r;switch(n=0,r&&(h=[h[0]&2,r.value]),h[0]){case 0:case 1:r=h;break;case 4:return e.label++,{value:h[1],done:!1};case 5:e.label++,n=h[1],h=[0];continue;case 7:h=e.ops.pop(),e.trys.pop();continue;default:if(r=e.trys,!(r=r.length>0&&r[r.length-1])&&(h[0]===6||h[0]===2)){e=0;continue}if(h[0]===3&&(!r||h[1]>r[0]&&h[1]<r[3])){e.label=h[1];break}if(h[0]===6&&e.label<r[1]){e.label=r[1],r=h;break}if(r&&e.label<r[2]){e.label=r[2],e.ops.push(h);break}r[2]&&e.ops.pop(),e.trys.pop();continue}h=t.call(a,e)}catch(d){h=[6,d],n=0}finally{i=r=0}if(h[0]&5)throw h[1];return{value:h[0]?h[1]:void 0,done:!0}}},Sl=function(a,t){for(var e=0,i=t.length,n=a.length;e<i;e++,n++)a[n]=t[e];return a},e1=Object.defineProperty,i1=Object.defineProperties,n1=Object.getOwnPropertyDescriptors,Iy=Object.getOwnPropertySymbols,s1=Object.prototype.hasOwnProperty,r1=Object.prototype.propertyIsEnumerable,Ly=function(a,t,e){return t in a?e1(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e},Or=function(a,t){for(var e in t||(t={}))s1.call(t,e)&&Ly(a,e,t[e]);if(Iy)for(var i=0,n=Iy(t);i<n.length;i++){var e=n[i];r1.call(t,e)&&Ly(a,e,t[e])}return a},Eg=function(a,t){return i1(a,n1(t))},o1=function(a,t,e){return new Promise(function(i,n){var r=function(c){try{l(e.next(c))}catch(h){n(h)}},o=function(c){try{l(e.throw(c))}catch(h){n(h)}},l=function(c){return c.done?i(c.value):Promise.resolve(c.value).then(r,o)};l((e=e.apply(a,t)).next())})},a1=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?lf:lf.apply(null,arguments)};function Ny(a){if(typeof a!="object"||a===null)return!1;var t=Object.getPrototypeOf(a);if(t===null)return!0;for(var e=t;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return t===e}var l1=function(a){return a&&typeof a.match=="function"};function Ir(a,t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(t){var r=t.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Or(Or({type:a,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:a,payload:i[0]}}return e.toString=function(){return""+a},e.type=a,e.match=function(i){return i.type===a},e}function c1(a){return typeof a=="function"&&"type"in a&&l1(a)}function h1(a){var t=a?(""+a).split("/"):[],e=t[t.length-1]||"actionCreator";return'Detected an action creator with type "'+(a||"unknown")+`" being dispatched.
92
+ Make sure you're calling the action creator before dispatching, i.e. \`dispatch(`+e+"())` instead of `dispatch("+e+")`. This is necessary even if the action has no payload."}function d1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(i){return function(n){return i(n)}}};var t=a.isActionCreator,e=t===void 0?c1:t;return function(){return function(i){return function(n){return e(n)&&console.warn(h1(n.type)),i(n)}}}}function Fy(a,t){var e=0;return{measureTime:function(i){var n=Date.now();try{return i()}finally{var r=Date.now();e+=r-n}},warnIfExceeded:function(){e>a&&console.warn(t+" took "+e+"ms, which is more than the warning threshold of "+a+`ms.
93
93
  If your state or actions are very large, you may want to disable the middleware as it might cause too much of a slowdown in development mode. See https://redux-toolkit.js.org/api/getDefaultMiddleware for instructions.
94
- It is disabled in production builds, so you don't need to worry about that.`)}}}var h1=(function(a){Dy(t,a);function t(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=a.apply(this,e)||this;return Object.setPrototypeOf(n,t.prototype),n}return Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return a.prototype.concat.apply(this,e)},t.prototype.prepend=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.length===1&&Array.isArray(e[0])?new(t.bind.apply(t,ml([void 0],e[0].concat(this)))):new(t.bind.apply(t,ml([void 0],e.concat(this))))},t})(Array),d1=(function(a){Dy(t,a);function t(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=a.apply(this,e)||this;return Object.setPrototypeOf(n,t.prototype),n}return Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return a.prototype.concat.apply(this,e)},t.prototype.prepend=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.length===1&&Array.isArray(e[0])?new(t.bind.apply(t,ml([void 0],e[0].concat(this)))):new(t.bind.apply(t,ml([void 0],e.concat(this))))},t})(Array);function xg(a){return Os(a)?xy(a,function(){}):a}var u1=process.env.NODE_ENV==="production",Fy="Invariant failed";function By(a,t){if(!a)throw u1?new Error(Fy):new Error(Fy+": "+(t||""))}function f1(a,t,e,i){return JSON.stringify(a,p1(t,i),e)}function p1(a,t){var e=[],i=[];return t||(t=function(n,r){return e[0]===r?"[Circular ~]":"[Circular ~."+i.slice(0,e.indexOf(r)).join(".")+"]"}),function(n,r){if(e.length>0){var o=e.indexOf(this);~o?e.splice(o+1):e.push(this),~o?i.splice(o,1/0,n):i.push(n),~e.indexOf(r)&&(r=t.call(this,n,r))}else e.push(r);return a==null?r:a.call(this,n,r)}}function g1(a){return typeof a!="object"||a==null||Object.isFrozen(a)}function m1(a,t,e){var i=jy(a,t,e);return{detectMutations:function(){return zy(a,t,i,e)}}}function jy(a,t,e,i,n){t===void 0&&(t=[]),i===void 0&&(i=""),n===void 0&&(n=new Set);var r={value:e};if(!a(e)&&!n.has(e)){n.add(e),r.children={};for(var o in e){var l=i?i+"."+o:o;t.length&&t.indexOf(l)!==-1||(r.children[o]=jy(a,t,e[o],l))}}return r}function zy(a,t,e,i,n,r){t===void 0&&(t=[]),n===void 0&&(n=!1),r===void 0&&(r="");var o=e?e.value:void 0,l=o===i;if(n&&!l&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(a(o)||a(i))return{wasMutated:!1};var c={};for(var h in e.children)c[h]=!0;for(var h in i)c[h]=!0;var d=t.length>0,f=function(g){var b=r?r+"."+g:g;if(d){var m=t.some(function(y){return y instanceof RegExp?y.test(b):b===y});if(m)return"continue"}var w=zy(a,t,e.children[g],i[g],l,b);if(w.wasMutated)return{value:w}};for(var h in c){var u=f(h);if(typeof u=="object")return u.value}return{wasMutated:!1}}function b1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(c){return function(h){return c(h)}}};var t=a.isImmutable,e=t===void 0?g1:t,i=a.ignoredPaths,n=a.warnAfter,r=n===void 0?32:n,o=a.ignore;i=i||o;var l=m1.bind(null,e,i);return function(c){var h=c.getState,d=h(),f=l(d),u;return function(g){return function(b){var m=Ny(r,"ImmutableStateInvariantMiddleware");m.measureTime(function(){d=h(),u=f.detectMutations(),f=l(d),By(!u.wasMutated,"A state mutation was detected between dispatches, in the path '"+(u.path||"")+"'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)")});var w=g(b);return m.measureTime(function(){d=h(),u=f.detectMutations(),f=l(d),u.wasMutated&&By(!u.wasMutated,"A state mutation was detected inside a dispatch, in the path: "+(u.path||"")+". Take a look at the reducer(s) handling the action "+f1(b)+". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)")}),m.warnIfExceeded(),w}}}}function Uy(a){var t=typeof a;return a==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(a)||Ly(a)}function Cg(a,t,e,i,n,r){t===void 0&&(t=""),e===void 0&&(e=Uy),n===void 0&&(n=[]);var o;if(!e(a))return{keyPath:t||"<root>",value:a};if(typeof a!="object"||a===null||r!=null&&r.has(a))return!1;for(var l=i!=null?i(a):Object.entries(a),c=n.length>0,h=function(w,y){var x=t?t+"."+w:w;if(c){var E=n.some(function(_){return _ instanceof RegExp?_.test(x):x===_});if(E)return"continue"}if(!e(y))return{value:{keyPath:x,value:y}};if(typeof y=="object"&&(o=Cg(y,x,e,i,n,r),o))return{value:o}},d=0,f=l;d<f.length;d++){var u=f[d],g=u[0],b=u[1],m=h(g,b);if(typeof m=="object")return m.value}return r&&Hy(a)&&r.add(a),!1}function Hy(a){if(!Object.isFrozen(a))return!1;for(var t=0,e=Object.values(a);t<e.length;t++){var i=e[t];if(!(typeof i!="object"||i===null)&&!Hy(i))return!1}return!0}function y1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(E){return function(_){return E(_)}}};var t=a.isSerializable,e=t===void 0?Uy:t,i=a.getEntries,n=a.ignoredActions,r=n===void 0?[]:n,o=a.ignoredActionPaths,l=o===void 0?["meta.arg","meta.baseQueryMeta"]:o,c=a.ignoredPaths,h=c===void 0?[]:c,d=a.warnAfter,f=d===void 0?32:d,u=a.ignoreState,g=u===void 0?!1:u,b=a.ignoreActions,m=b===void 0?!1:b,w=a.disableCache,y=w===void 0?!1:w,x=!y&&WeakSet?new WeakSet:void 0;return function(E){return function(_){return function(C){var T=_(C),D=Ny(f,"SerializableStateInvariantMiddleware");return!m&&!(r.length&&r.indexOf(C.type)!==-1)&&D.measureTime(function(){var j=Cg(C,"",e,i,l,x);if(j){var O=j.keyPath,H=j.value;console.error("A non-serializable value was detected in an action, in the path: `"+O+"`. Value:",H,`
95
- Take a look at the logic that dispatched this action: `,C,`
94
+ It is disabled in production builds, so you don't need to worry about that.`)}}}var u1=(function(a){Oy(t,a);function t(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=a.apply(this,e)||this;return Object.setPrototypeOf(n,t.prototype),n}return Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return a.prototype.concat.apply(this,e)},t.prototype.prepend=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.length===1&&Array.isArray(e[0])?new(t.bind.apply(t,Sl([void 0],e[0].concat(this)))):new(t.bind.apply(t,Sl([void 0],e.concat(this))))},t})(Array),f1=(function(a){Oy(t,a);function t(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];var n=a.apply(this,e)||this;return Object.setPrototypeOf(n,t.prototype),n}return Object.defineProperty(t,Symbol.species,{get:function(){return t},enumerable:!1,configurable:!0}),t.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return a.prototype.concat.apply(this,e)},t.prototype.prepend=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return e.length===1&&Array.isArray(e[0])?new(t.bind.apply(t,Sl([void 0],e[0].concat(this)))):new(t.bind.apply(t,Sl([void 0],e.concat(this))))},t})(Array);function xg(a){return Ds(a)?Cy(a,function(){}):a}var p1=process.env.NODE_ENV==="production",By="Invariant failed";function jy(a,t){if(!a)throw p1?new Error(By):new Error(By+": "+(t||""))}function g1(a,t,e,i){return JSON.stringify(a,m1(t,i),e)}function m1(a,t){var e=[],i=[];return t||(t=function(n,r){return e[0]===r?"[Circular ~]":"[Circular ~."+i.slice(0,e.indexOf(r)).join(".")+"]"}),function(n,r){if(e.length>0){var o=e.indexOf(this);~o?e.splice(o+1):e.push(this),~o?i.splice(o,1/0,n):i.push(n),~e.indexOf(r)&&(r=t.call(this,n,r))}else e.push(r);return a==null?r:a.call(this,n,r)}}function b1(a){return typeof a!="object"||a==null||Object.isFrozen(a)}function y1(a,t,e){var i=zy(a,t,e);return{detectMutations:function(){return Uy(a,t,i,e)}}}function zy(a,t,e,i,n){t===void 0&&(t=[]),i===void 0&&(i=""),n===void 0&&(n=new Set);var r={value:e};if(!a(e)&&!n.has(e)){n.add(e),r.children={};for(var o in e){var l=i?i+"."+o:o;t.length&&t.indexOf(l)!==-1||(r.children[o]=zy(a,t,e[o],l))}}return r}function Uy(a,t,e,i,n,r){t===void 0&&(t=[]),n===void 0&&(n=!1),r===void 0&&(r="");var o=e?e.value:void 0,l=o===i;if(n&&!l&&!Number.isNaN(i))return{wasMutated:!0,path:r};if(a(o)||a(i))return{wasMutated:!1};var c={};for(var h in e.children)c[h]=!0;for(var h in i)c[h]=!0;var d=t.length>0,u=function(p){var m=r?r+"."+p:p;if(d){var b=t.some(function(w){return w instanceof RegExp?w.test(m):m===w});if(b)return"continue"}var v=Uy(a,t,e.children[p],i[p],l,m);if(v.wasMutated)return{value:v}};for(var h in c){var f=u(h);if(typeof f=="object")return f.value}return{wasMutated:!1}}function v1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(c){return function(h){return c(h)}}};var t=a.isImmutable,e=t===void 0?b1:t,i=a.ignoredPaths,n=a.warnAfter,r=n===void 0?32:n,o=a.ignore;i=i||o;var l=y1.bind(null,e,i);return function(c){var h=c.getState,d=h(),u=l(d),f;return function(p){return function(m){var b=Fy(r,"ImmutableStateInvariantMiddleware");b.measureTime(function(){d=h(),f=u.detectMutations(),u=l(d),jy(!f.wasMutated,"A state mutation was detected between dispatches, in the path '"+(f.path||"")+"'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)")});var v=p(m);return b.measureTime(function(){d=h(),f=u.detectMutations(),u=l(d),f.wasMutated&&jy(!f.wasMutated,"A state mutation was detected inside a dispatch, in the path: "+(f.path||"")+". Take a look at the reducer(s) handling the action "+g1(m)+". (https://redux.js.org/style-guide/style-guide#do-not-mutate-state)")}),b.warnIfExceeded(),v}}}}function Hy(a){var t=typeof a;return a==null||t==="string"||t==="boolean"||t==="number"||Array.isArray(a)||Ny(a)}function Cg(a,t,e,i,n,r){t===void 0&&(t=""),e===void 0&&(e=Hy),n===void 0&&(n=[]);var o;if(!e(a))return{keyPath:t||"<root>",value:a};if(typeof a!="object"||a===null||r!=null&&r.has(a))return!1;for(var l=i!=null?i(a):Object.entries(a),c=n.length>0,h=function(v,w){var _=t?t+"."+v:v;if(c){var A=n.some(function(C){return C instanceof RegExp?C.test(_):_===C});if(A)return"continue"}if(!e(w))return{value:{keyPath:_,value:w}};if(typeof w=="object"&&(o=Cg(w,_,e,i,n,r),o))return{value:o}},d=0,u=l;d<u.length;d++){var f=u[d],p=f[0],m=f[1],b=h(p,m);if(typeof b=="object")return b.value}return r&&$y(a)&&r.add(a),!1}function $y(a){if(!Object.isFrozen(a))return!1;for(var t=0,e=Object.values(a);t<e.length;t++){var i=e[t];if(!(typeof i!="object"||i===null)&&!$y(i))return!1}return!0}function w1(a){if(a===void 0&&(a={}),process.env.NODE_ENV==="production")return function(){return function(A){return function(C){return A(C)}}};var t=a.isSerializable,e=t===void 0?Hy:t,i=a.getEntries,n=a.ignoredActions,r=n===void 0?[]:n,o=a.ignoredActionPaths,l=o===void 0?["meta.arg","meta.baseQueryMeta"]:o,c=a.ignoredPaths,h=c===void 0?[]:c,d=a.warnAfter,u=d===void 0?32:d,f=a.ignoreState,p=f===void 0?!1:f,m=a.ignoreActions,b=m===void 0?!1:m,v=a.disableCache,w=v===void 0?!1:v,_=!w&&WeakSet?new WeakSet:void 0;return function(A){return function(C){return function(x){var P=C(x),R=Fy(u,"SerializableStateInvariantMiddleware");return!b&&!(r.length&&r.indexOf(x.type)!==-1)&&R.measureTime(function(){var N=Cg(x,"",e,i,l,_);if(N){var z=N.keyPath,H=N.value;console.error("A non-serializable value was detected in an action, in the path: `"+z+"`. Value:",H,`
95
+ Take a look at the logic that dispatched this action: `,x,`
96
96
  (See https://redux.js.org/faq/actions#why-should-type-be-a-string-or-at-least-serializable-why-should-my-action-types-be-constants)`,`
97
- (To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),g||(D.measureTime(function(){var j=E.getState(),O=Cg(j,"",e,i,h,x);if(O){var H=O.keyPath,N=O.value;console.error("A non-serializable value was detected in the state, in the path: `"+H+"`. Value:",N,`
98
- Take a look at the reducer(s) handling this action type: `+C.type+`.
99
- (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),D.warnIfExceeded()),T}}}}function lf(a){return typeof a=="boolean"}function v1(){return function(t){return w1(t)}}function w1(a){a===void 0&&(a={});var t=a.thunk,e=t===void 0?!0:t,i=a.immutableCheck,n=i===void 0?!0:i,r=a.serializableCheck,o=r===void 0?!0:r,l=a.actionCreatorCheck,c=l===void 0?!0:l,h=new h1;if(e&&(lf(e)?h.push(Sg):h.push(Sg.withExtraArgument(e.extraArgument))),process.env.NODE_ENV!=="production"){if(n){var d={};lf(n)||(d=n),h.unshift(b1(d))}if(o){var f={};lf(o)||(f=o),h.push(y1(f))}if(c){var u={};lf(c)||(u=c),h.unshift(c1(u))}}return h}var _g=process.env.NODE_ENV==="production";function A1(a){var t=v1(),e=a||{},i=e.reducer,n=i===void 0?void 0:i,r=e.middleware,o=r===void 0?t():r,l=e.devTools,c=l===void 0?!0:l,h=e.preloadedState,d=h===void 0?void 0:h,f=e.enhancers,u=f===void 0?void 0:f,g;if(typeof n=="function")g=n;else if(Ly(n))g=KA(n);else throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');var b=o;if(typeof b=="function"&&(b=b(t),!_g&&!Array.isArray(b)))throw new Error("when using a middleware builder function, an array of middleware must be returned");if(!_g&&b.some(function(_){return typeof _!="function"}))throw new Error("each middleware provided to configureStore must be a function");var m=JA.apply(void 0,b),w=af;c&&(w=r1(Ir({trace:!_g},typeof c=="object"&&c)));var y=new d1(m),x=y;Array.isArray(u)?x=ml([m],u):typeof u=="function"&&(x=u(y));var E=w.apply(void 0,x);return ky(g,d,E)}function $y(a){var t={},e=[],i,n={addCase:function(r,o){if(process.env.NODE_ENV!=="production"){if(e.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}var l=typeof r=="string"?r:r.type;if(!l)throw new Error("`builder.addCase` cannot be called with an empty action type");if(l in t)throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");return t[l]=o,n},addMatcher:function(r,o){if(process.env.NODE_ENV!=="production"&&i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return e.push({matcher:r,reducer:o}),n},addDefaultCase:function(r){if(process.env.NODE_ENV!=="production"&&i)throw new Error("`builder.addDefaultCase` can only be called once");return i=r,n}};return a(n),[t,e,i]}function S1(a){return typeof a=="function"}var Wy=!1;function E1(a,t,e,i){e===void 0&&(e=[]),process.env.NODE_ENV!=="production"&&typeof t=="object"&&(Wy||(Wy=!0,console.warn("The object notation for `createReducer` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer")));var n=typeof t=="function"?$y(t):[t,e,i],r=n[0],o=n[1],l=n[2],c;if(S1(a))c=function(){return xg(a())};else{var h=xg(a);c=function(){return h}}function d(f,u){f===void 0&&(f=c());var g=ml([r[u.type]],o.filter(function(b){var m=b.matcher;return m(u)}).map(function(b){var m=b.reducer;return m}));return g.filter(function(b){return!!b}).length===0&&(g=[l]),g.reduce(function(b,m){if(m)if(Rr(b)){var w=b,y=m(w,u);return y===void 0?b:y}else{if(Os(b))return xy(b,function(x){return m(x,u)});var y=m(b,u);if(y===void 0){if(b===null)return b;throw Error("A case reducer on a non-draftable value must not return undefined")}return y}return b},f)}return d.getInitialState=c,d}var Vy=!1;function x1(a,t){return a+"/"+t}function C1(a){var t=a.name;typeof process<"u"&&process.env.NODE_ENV==="development"&&a.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");var e=typeof a.initialState=="function"?a.initialState:xg(a.initialState),i=a.reducers||{},n=Object.keys(i),r={},o={},l={};n.forEach(function(d){var f=i[d],u=x1(t,d),g,b;"reducer"in f?(g=f.reducer,b=f.prepare):g=f,r[d]=g,o[u]=g,l[d]=b?Lr(u,b):Lr(u)});function c(){process.env.NODE_ENV!=="production"&&typeof a.extraReducers=="object"&&(Vy||(Vy=!0,console.warn("The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice")));var d=typeof a.extraReducers=="function"?$y(a.extraReducers):[a.extraReducers],f=d[0],u=f===void 0?{}:f,g=d[1],b=g===void 0?[]:g,m=d[2],w=m===void 0?void 0:m,y=Ir(Ir({},u),o);return E1(e,function(x){for(var E in y)x.addCase(E,y[E]);for(var _=0,C=b;_<C.length;_++){var T=C[_];x.addMatcher(T.matcher,T.reducer)}w&&x.addDefaultCase(w)})}var h;return{name:t,reducer:function(d,f){return h||(h=c()),h(d,f)},actions:l,caseReducers:r,getInitialState:function(){return h||(h=c()),h.getInitialState()}}}var _1="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",T1=function(a){a===void 0&&(a=21);for(var t="",e=a;e--;)t+=_1[Math.random()*64|0];return t},P1=["name","message","stack","code"],Tg=(function(){function a(t,e){this.payload=t,this.meta=e}return a})(),Gy=(function(){function a(t,e){this.payload=t,this.meta=e}return a})(),k1=function(a){if(typeof a=="object"&&a!==null){for(var t={},e=0,i=P1;e<i.length;e++){var n=i[e];typeof a[n]=="string"&&(t[n]=a[n])}return t}return{message:String(a)}};(function(){function a(t,e,i){var n=Lr(t+"/fulfilled",function(d,f,u,g){return{payload:d,meta:Eg(Ir({},g||{}),{arg:u,requestId:f,requestStatus:"fulfilled"})}}),r=Lr(t+"/pending",function(d,f,u){return{payload:void 0,meta:Eg(Ir({},u||{}),{arg:f,requestId:d,requestStatus:"pending"})}}),o=Lr(t+"/rejected",function(d,f,u,g,b){return{payload:g,error:(i&&i.serializeError||k1)(d||"Rejected"),meta:Eg(Ir({},b||{}),{arg:u,requestId:f,rejectedWithValue:!!g,requestStatus:"rejected",aborted:(d==null?void 0:d.name)==="AbortError",condition:(d==null?void 0:d.name)==="ConditionError"})}}),l=!1,c=typeof AbortController<"u"?AbortController:(function(){function d(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return d.prototype.abort=function(){process.env.NODE_ENV!=="production"&&(l||(l=!0,console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.")))},d})();function h(d){return function(f,u,g){var b=i!=null&&i.idGenerator?i.idGenerator(d):T1(),m=new c,w;function y(E){w=E,m.abort()}var x=(function(){return s1(this,null,function(){var E,_,C,T,D,j,O;return ZA(this,function(H){switch(H.label){case 0:return H.trys.push([0,4,,5]),T=(E=i==null?void 0:i.condition)==null?void 0:E.call(i,d,{getState:u,extra:g}),R1(T)?[4,T]:[3,2];case 1:T=H.sent(),H.label=2;case 2:if(T===!1||m.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return D=new Promise(function(N,lt){return m.signal.addEventListener("abort",function(){return lt({name:"AbortError",message:w||"Aborted"})})}),f(r(b,d,(_=i==null?void 0:i.getPendingMeta)==null?void 0:_.call(i,{requestId:b,arg:d},{getState:u,extra:g}))),[4,Promise.race([D,Promise.resolve(e(d,{dispatch:f,getState:u,extra:g,requestId:b,signal:m.signal,abort:y,rejectWithValue:function(N,lt){return new Tg(N,lt)},fulfillWithValue:function(N,lt){return new Gy(N,lt)}})).then(function(N){if(N instanceof Tg)throw N;return N instanceof Gy?n(N.payload,b,d,N.meta):n(N,b,d)})])];case 3:return C=H.sent(),[3,5];case 4:return j=H.sent(),C=j instanceof Tg?o(null,b,d,j.payload,j.meta):o(j,b,d),[3,5];case 5:return O=i&&!i.dispatchConditionRejection&&o.match(C)&&C.meta.condition,O||f(C),[2,C]}})})})();return Object.assign(x,{abort:y,requestId:b,arg:d,unwrap:function(){return x.then(M1)}})}}return Object.assign(h,{pending:r,rejected:o,fulfilled:n,typePrefix:t})}return a.withTypes=function(){return a},a})();function M1(a){if(a.meta&&a.meta.rejectedWithValue)throw a.payload;if(a.error)throw a.error;return a.payload}function R1(a){return a!==null&&typeof a=="object"&&typeof a.then=="function"}var Pg="listenerMiddleware";Lr(Pg+"/add"),Lr(Pg+"/removeAll"),Lr(Pg+"/remove");var Yy;typeof queueMicrotask=="function"&&queueMicrotask.bind(typeof window<"u"?window:typeof global<"u"?global:globalThis),LA();const D1={grid:{size:20,color:"#ccc",enabled:!0},toolbar:{selectedTool:"pointer"},toolProperties:{pencil:{strokeColor:"#000000",lineWidth:4},rectangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},circle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},triangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},diamond:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},star:{strokeColor:"#000000",fillColor:"#ffff00",lineWidth:2},heart:{strokeColor:"#000000",fillColor:"#ff6b6b",lineWidth:2},hexagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},octagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},arrow:{strokeColor:"#000000",fillColor:"#000000",lineWidth:2},text:{fontSize:16,fontColor:"#000000"}},elements:[],selectedElementIds:[],viewport:{panX:0,panY:0,zoom:1},watermark:{text:"Nines Studios",url:"https://github.com/huzeyfecoskun",visible:!0},lock:{isLocked:!1,text:"Whiteboard drawing is only for moderator"}};function O1(a){const t=[],e=new Set;for(const i of a){const n=i==null?void 0:i.id;if(n==null){t.push(i);continue}e.has(n)||(e.add(n),t.push(i))}return t}const kg=C1({name:"whiteboard",initialState:D1,reducers:{toggleGrid(a){a.grid.enabled=!a.grid.enabled},setGridSize(a,t){a.grid.size=t.payload},setGridColor(a,t){a.grid.color=t.payload},setSelectedTool(a,t){a.toolbar.selectedTool=t.payload},setToolProperty(a,t){const{tool:e,property:i,value:n}=t.payload;a.toolProperties[e]&&(a.toolProperties[e][i]=n)},addElement(a,t){const e=t.payload,i=e==null?void 0:e.id;i!=null&&a.elements.some(r=>(r==null?void 0:r.id)===i)||a.elements.push(e)},updateElement(a,t){const{id:e,updates:i}=t.payload,n=a.elements.findIndex(r=>r.id===e);n!==-1&&(a.elements[n]={...a.elements[n],...i})},updateElements(a,t){t.payload.forEach(({id:i,updates:n})=>{const r=a.elements.findIndex(o=>o.id===i);r!==-1&&(a.elements[r]={...a.elements[r],...n})})},removeElement(a,t){const e=t.payload;a.elements=a.elements.filter(i=>i.id!==e),a.selectedElementIds=a.selectedElementIds.filter(i=>i!==e)},setSelectedElements(a,t){a.selectedElementIds=t.payload},clearElements(a){a.elements=[],a.selectedElementIds=[]},setElements(a,t){const e=Array.isArray(t.payload)?t.payload:[];a.elements=O1(e),a.selectedElementIds=[]},setPan(a,t){a.viewport.panX=t.payload.x,a.viewport.panY=t.payload.y},setZoom(a,t){a.viewport.zoom=Math.max(.1,Math.min(5,t.payload))},setPdf(a,t){t.payload?a.pdf={url:t.payload}:a.pdf=void 0},resetViewport(a){a.viewport.panX=0,a.viewport.panY=0,a.viewport.zoom=1},bringToFront(a,t){const e=t.payload,i=a.elements.findIndex(n=>n.id===e);if(i!==-1&&i<a.elements.length-1){const[n]=a.elements.splice(i,1);a.elements.push(n)}},sendToBack(a,t){const e=t.payload,i=a.elements.findIndex(n=>n.id===e);if(i>0){const[n]=a.elements.splice(i,1);a.elements.unshift(n)}},fitToView(a,t){const{canvasWidth:e,canvasHeight:i,padding:n=50}=t.payload,r=a.elements;if(r.length===0){a.viewport.panX=0,a.viewport.panY=0,a.viewport.zoom=1;return}let o=1/0,l=1/0,c=-1/0,h=-1/0;if(r.forEach(C=>{const T=D=>D??0;if(C.type==="rectangle"){const D=T(C.x),j=T(C.y),O=T(C.width),H=T(C.height);o=Math.min(o,D),l=Math.min(l,j),c=Math.max(c,D+O),h=Math.max(h,j+H)}else if(C.type==="circle"){const D=T(C.centerX),j=T(C.centerY),O=T(C.radius);o=Math.min(o,D-O),l=Math.min(l,j-O),c=Math.max(c,D+O),h=Math.max(h,j+O)}else if(C.type==="pencil"&&C.points&&C.points.length>0)C.points.forEach(D=>{o=Math.min(o,D.x),l=Math.min(l,D.y),c=Math.max(c,D.x),h=Math.max(h,D.y)});else if(C.type==="triangle"||C.type==="diamond"||C.type==="hexagon"||C.type==="octagon"){const D=T(C.x),j=T(C.y),O=T(C.width),H=T(C.height);o=Math.min(o,D),l=Math.min(l,j),c=Math.max(c,D+O),h=Math.max(h,j+H)}else if(C.type==="star"||C.type==="heart"){const D=T(C.centerX),j=T(C.centerY),O=T(C.size);o=Math.min(o,D-O),l=Math.min(l,j-O),c=Math.max(c,D+O),h=Math.max(h,j+O)}else if(C.type==="arrow"){const D=T(C.startX),j=T(C.startY),O=T(C.endX),H=T(C.endY);o=Math.min(o,D,O),l=Math.min(l,j,H),c=Math.max(c,D,O),h=Math.max(h,j,H)}}),o===1/0)return;const d=c-o,f=h-l;if(d<=0||f<=0)return;const u=e-n*2,g=i-n*2,b=u/d,m=g/f,w=Math.min(b,m,5),y=(o+c)/2,x=(l+h)/2,E=e/2-y*w,_=i/2-x*w;a.viewport.zoom=Math.max(.1,w),a.viewport.panX=E,a.viewport.panY=_},setLocked(a,t){a.lock.isLocked=t.payload,t.payload&&(a.toolbar.selectedTool="pointer",a.selectedElementIds=[])},setWatermarkEnabled(a,t){a.watermark.visible=t.payload},setWatermarkText(a,t){a.watermark.text=t.payload}}}),{toggleGrid:I1,setGridSize:qx,setGridColor:Kx,setSelectedTool:Fn,setToolProperty:L1,addElement:Ri,updateElement:cf,updateElements:Xy,removeElement:N1,setSelectedElements:Is,clearElements:ph,setElements:Mg,setPan:No,setZoom:gh,resetViewport:Jx,fitToView:F1,bringToFront:B1,sendToBack:j1,setLocked:qy,setWatermarkEnabled:z1,setWatermarkText:U1,setPdf:Rg}=kg.actions,H1=kg.actions,Ky=kg.reducer,$1=new Set(["rectangle","circle","pencil","triangle","diamond","star","heart","hexagon","octagon","arrow","image","text"]),W1=new Set(["strokeColor","fillColor","lineWidth","fontSize","fontColor","textColor"]),V1=a=>{var t,e;if(!a||typeof a.type!="string"||a.type.startsWith("@@redux/"))return!1;if(a.type==="whiteboard/addElement"){const i=(t=a==null?void 0:a.payload)==null?void 0:t.type;return typeof i=="string"&&$1.has(i)}if(a.type==="whiteboard/removeElement"||a.type==="whiteboard/clearElements"||a.type==="whiteboard/setPdf"||a.type==="whiteboard/bringToFront"||a.type==="whiteboard/sendToBack")return!0;if(a.type==="whiteboard/setToolProperty"){const{tool:i,property:n}=(a==null?void 0:a.payload)??{};return typeof i!="string"||typeof n!="string"?!1:W1.has(n)}if(a.type==="whiteboard/updateElement")return Jy((e=a==null?void 0:a.payload)==null?void 0:e.updates);if(a.type==="whiteboard/updateElements"){const i=a==null?void 0:a.payload;return Array.isArray(i)?i.some(n=>Jy(n.updates)):!1}return!1},Jy=a=>{if(!a||typeof a!="object")return!1;const t=e=>Object.prototype.hasOwnProperty.call(a,e);return!!(t("text")||t("fontSize")||t("fontColor")||t("textColor")||t("strokeColor")||t("fillColor")||t("lineWidth")||t("x")||t("y")||t("width")||t("height")||t("centerX")||t("centerY")||t("radius")||t("size")||t("startX")||t("startY")||t("endX")||t("endY")||t("points")||t("src"))},G1=a=>t=>e=>i=>{var r;const n=e(i);return!((r=i.meta)!=null&&r.fromRemote)&&a&&a.current&&V1(i)&&a.current(i,t.getState()),n},Dg=({preloadedState:a,actionHandlerRef:t}={})=>A1({reducer:{whiteboard:Ky},middleware:e=>e().concat(G1(t)),preloadedState:a}),Y1=Dg(),X1=()=>{const a=ni(t=>t.whiteboard.watermark);return M.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:M.jsx("div",{className:"wb-watermark",children:a.text})})};var Zy={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qy=B.createContext&&B.createContext(Zy),q1=["attr","size","title"];function K1(a,t){if(a==null)return{};var e=J1(a,t),i,n;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(a);for(n=0;n<r.length;n++)i=r[n],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(a,i)&&(e[i]=a[i])}return e}function J1(a,t){if(a==null)return{};var e={};for(var i in a)if(Object.prototype.hasOwnProperty.call(a,i)){if(t.indexOf(i)>=0)continue;e[i]=a[i]}return e}function hf(){return hf=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i])}return a},hf.apply(this,arguments)}function t0(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(a,n).enumerable})),e.push.apply(e,i)}return e}function df(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?t0(Object(e),!0).forEach(function(i){Z1(a,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):t0(Object(e)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(e,i))})}return a}function Z1(a,t,e){return t=Q1(t),t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function Q1(a){var t=tS(a,"string");return typeof t=="symbol"?t:t+""}function tS(a,t){if(typeof a!="object"||!a)return a;var e=a[Symbol.toPrimitive];if(e!==void 0){var i=e.call(a,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(a)}function e0(a){return a&&a.map((t,e)=>B.createElement(t.tag,df({key:e},t.attr),e0(t.child)))}function ee(a){return t=>B.createElement(eS,hf({attr:df({},a.attr)},t),e0(a.child))}function eS(a){var t=e=>{var{attr:i,size:n,title:r}=a,o=K1(a,q1),l=n||e.size||"1em",c;return e.className&&(c=e.className),a.className&&(c=(c?c+" ":"")+a.className),B.createElement("svg",hf({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},e.attr,i,o,{className:c,style:df(df({color:a.color||e.color},e.style),a.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),r&&B.createElement("title",null,r),a.children)};return Qy!==void 0?B.createElement(Qy.Consumer,null,e=>t(e)):t(Zy)}function iS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 32H32A32 32 0 0 0 0 64v384a32 32 0 0 0 32 32h384a32 32 0 0 0 32-32V64a32 32 0 0 0-32-32zm-32 64v128H256V96zm-192 0v128H64V96zM64 416V288h128v128zm192 0V288h128v128z"},child:[]}]})(a)}function nS(a){return ee({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(a)}function sS(a){return ee({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(a)}function rS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"},child:[]}]})(a)}function oS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(a)}function aS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.941 273.941c18.745-18.745 18.745-49.137 0-67.882l-160-160c-18.745-18.745-49.136-18.746-67.883 0l-256 256c-18.745 18.745-18.745 49.137 0 67.882l96 96A48.004 48.004 0 0 0 144 480h356c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12H355.883l142.058-142.059zm-302.627-62.627l137.373 137.373L265.373 416H150.628l-80-80 124.686-124.686z"},child:[]}]})(a)}function lS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"},child:[]}]})(a)}function cS(a){return ee({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(a)}function hS(a){return ee({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"},child:[]}]})(a)}function dS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"},child:[]}]})(a)}function uS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(a)}function fS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(a)}function pS(a){return ee({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M302.189 329.126H196.105l55.831 135.993c3.889 9.428-.555 19.999-9.444 23.999l-49.165 21.427c-9.165 4-19.443-.571-23.332-9.714l-53.053-129.136-86.664 89.138C18.729 472.71 0 463.554 0 447.977V18.299C0 1.899 19.921-6.096 30.277 5.443l284.412 292.542c11.472 11.179 3.007 31.141-12.5 31.141z"},child:[]}]})(a)}function gS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"},child:[]}]})(a)}function mS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"},child:[]}]})(a)}function bS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(a)}function yS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(a)}function vS(a){return ee({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(a)}function i0(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"},child:[]}]})(a)}const wS=({text:a,shifted:t})=>M.jsxs("div",{className:`wb-lock-indicator ${t?"wb-shifted":""}`,children:[M.jsx(fS,{}),M.jsx("span",{children:a||"Locked"})]});function AS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"},child:[]}]})(a)}function SS(a){return ee({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M284.3 11.7c-15.6-15.6-40.9-15.6-56.6 0l-216 216c-15.6 15.6-15.6 40.9 0 56.6l216 216c15.6 15.6 40.9 15.6 56.6 0l216-216c15.6-15.6 15.6-40.9 0-56.6l-216-216z"},child:[]}]})(a)}function ES(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"},child:[]}]})(a)}function xS(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z"},child:[]}]})(a)}function CS(a){return ee({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l128 0 0 352c0 17.7 14.3 32 32 32s32-14.3 32-32l0-352 128 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 32 32 32z"},child:[]}]})(a)}function _S(a){return ee({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144c0-44.2 35.8-80 80-80c31.9 0 59.4 18.6 72.3 45.7c7.6 16 26.7 22.8 42.6 15.2s22.8-26.7 15.2-42.6C331 33.7 281.5 0 224 0C144.5 0 80 64.5 80 144l0 48-16 0c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-192c0-35.3-28.7-64-64-64l-240 0 0-48z"},child:[]}]})(a)}function TS(a){return ee({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M8.5.134a1 1 0 0 0-1 0l-6 3.577a1 1 0 0 0-.5.866v6.846a1 1 0 0 0 .5.866l6 3.577a1 1 0 0 0 1 0l6-3.577a1 1 0 0 0 .5-.866V4.577a1 1 0 0 0-.5-.866z"},child:[]}]})(a)}function PS(a){return ee({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.107 0a.5.5 0 0 1 .353.146l4.394 4.394a.5.5 0 0 1 .146.353v6.214a.5.5 0 0 1-.146.353l-4.394 4.394a.5.5 0 0 1-.353.146H4.893a.5.5 0 0 1-.353-.146L.146 11.46A.5.5 0 0 1 0 11.107V4.893a.5.5 0 0 1 .146-.353L4.54.146A.5.5 0 0 1 4.893 0z"},child:[]}]})(a)}const kS=({onClose:a,onConfirm:t})=>{const{t:e}=hh(),[i,n]=B.useState(!1),r=()=>{n(!0),setTimeout(a,300)},o=()=>{n(!0),setTimeout(t,300)};return Se.createPortal(M.jsx("div",{className:`wb-confirm-popup-overlay ${i?"wb-closing":""}`,children:M.jsxs("div",{className:"wb-confirm-popup",children:[M.jsx("p",{children:e("confirmClear")}),M.jsxs("div",{className:"wb-actions",children:[M.jsx("button",{onClick:r,children:e("cancel")}),M.jsx("button",{onClick:o,children:e("clear")})]})]})}),document.body)},MS=({mode:a="user",onImageUpload:t,onPdfSelected:e})=>{const i=og(),{t:n,language:r,changeLanguage:o}=hh(),l=ni(G=>G.whiteboard.toolbar.selectedTool),c=ni(G=>G.whiteboard.lock.isLocked),h=ni(G=>G.whiteboard.viewport),[d,f]=B.useState(!1),[u,g]=B.useState(!1),[b,m]=B.useState(!1),w=B.useRef(null),y=B.useRef(null),x=B.useRef(null),E=B.useRef(null),_=B.useRef(null),C=B.useRef(null),T=async G=>{var tt;const K=(tt=G.target.files)==null?void 0:tt[0];if(!K)return;const rt=(J,ct)=>{const Dt=(window.innerWidth/2-h.panX)/h.zoom,Ot=(window.innerHeight/2-h.panY)/h.zoom;return{x:Dt-J/2,y:Ot-ct/2}};if(t)try{const J=URL.createObjectURL(K),ct=new Image;ct.onload=async()=>{const Dt=ct.width,Ot=ct.height;URL.revokeObjectURL(J);try{const jt=await t(K),vt=Date.now().toString(),{x:Ct,y:Ae}=rt(Dt,Ot);i(Ri({id:vt,type:"image",x:Ct,y:Ae,width:Dt,height:Ot,src:jt})),i(Fn("pointer")),i(Is([vt]))}catch(jt){console.error("Image upload failed:",jt)}},ct.src=J}catch(J){console.error("Error processing image:",J)}else{const J=URL.createObjectURL(K),ct=new Image;ct.onload=()=>{const Dt=Date.now().toString(),{x:Ot,y:jt}=rt(ct.width,ct.height);i(Ri({id:Dt,type:"image",x:Ot,y:jt,width:ct.width,height:ct.height,src:J})),i(Fn("pointer")),i(Is([Dt]))},ct.src=J}G.target.value=""},D=G=>{var rt;const K=(rt=G.target.files)==null?void 0:rt[0];K&&e&&e(K),G.target.value=""};B.useEffect(()=>{const G=K=>{const rt=K.target;w.current&&!w.current.contains(rt)&&y.current&&!y.current.contains(rt)&&f(!1),E.current&&!E.current.contains(rt)&&x.current&&!x.current.contains(rt)&&g(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[]);const j=()=>{m(!0)},O=()=>{i(Fn("pointer")),i(Is([])),i(ph()),m(!1)},H=[{name:"triangle",icon:M.jsx(mS,{style:{transform:"rotate(-30deg)"}})},{name:"diamond",icon:M.jsx(SS,{})},{name:"star",icon:M.jsx(vS,{})},{name:"heart",icon:M.jsx(dS,{})},{name:"hexagon",icon:M.jsx(TS,{})},{name:"octagon",icon:M.jsx(PS,{})},{name:"arrow",icon:M.jsx(AS,{})}],N=G=>{i(Fn(G)),f(!1)},lt=G=>{o(G),g(!1)};return M.jsxs("div",{className:"wb-toolbar",children:[M.jsx("button",{className:l==="pointer"?"wb-active":"",onClick:()=>i(Fn("pointer")),title:n("pointer"),disabled:c,children:M.jsx(pS,{})}),M.jsx("button",{className:l==="text"?"wb-active":"",onClick:()=>i(Fn("text")),title:n("text"),disabled:c,children:M.jsx(CS,{})}),M.jsx("button",{onClick:()=>{var G;return(G=_.current)==null?void 0:G.click()},title:n("image"),disabled:c,children:M.jsx(uS,{})}),M.jsx("input",{type:"file",ref:_,style:{display:"none"},accept:"image/*",onChange:T}),M.jsx("button",{onClick:()=>{var G;return(G=C.current)==null?void 0:G.click()},title:"PDF",disabled:c,children:M.jsx(cS,{})}),M.jsx("input",{type:"file",ref:C,style:{display:"none"},accept:"application/pdf",onChange:D}),M.jsx("button",{className:l==="pencil"?"wb-active":"",onClick:()=>i(Fn("pencil")),title:n("pencil"),disabled:c,children:M.jsx(gS,{})}),M.jsx("button",{className:l==="rectangle"?"wb-active":"",onClick:()=>i(Fn("rectangle")),title:n("rectangle"),disabled:c,children:M.jsx(yS,{})}),M.jsx("button",{className:l==="circle"?"wb-active":"",onClick:()=>i(Fn("circle")),title:n("circle"),disabled:c,children:M.jsx(rS,{})}),M.jsxs("div",{className:"wb-ellipsis-container",children:[M.jsx("button",{ref:y,className:H.some(G=>G.name===l)?"wb-active":"",onClick:()=>f(!d),title:n("moreShapes"),disabled:c,children:M.jsx(ES,{})}),d&&M.jsxs("div",{className:"wb-shapes-popup",ref:w,children:[M.jsx("div",{className:"wb-shapes-popup-header",children:n("moreShapes")}),M.jsx("div",{className:"wb-shapes-popup-grid",children:H.map(G=>M.jsx("button",{className:l===G.name?"wb-active":"",onClick:()=>N(G.name),title:n(G.name),children:G.icon},G.name))})]})]}),M.jsx("button",{className:l==="eraser"?"wb-active":"",onClick:()=>i(Fn("eraser")),title:n("eraser"),disabled:c,children:M.jsx(aS,{})}),M.jsx("button",{onClick:j,title:n("trash"),disabled:c,children:M.jsx(i0,{})}),M.jsxs("div",{className:"wb-language-container",children:[M.jsx("button",{ref:x,onClick:()=>g(!u),title:n("language"),children:M.jsx(hS,{})}),u&&M.jsxs("div",{className:"wb-language-popup",ref:E,children:[M.jsx("div",{className:"wb-language-popup-header",children:n("language")}),M.jsxs("div",{className:"wb-language-options",children:[M.jsxs("button",{className:r==="en"?"wb-active":"",onClick:()=>lt("en"),children:["🇺🇸 ",n("english")]}),M.jsxs("button",{className:r==="tr"?"wb-active":"",onClick:()=>lt("tr"),children:["🇹🇷 ",n("turkish")]})]})]})]}),a==="moderator"&&M.jsx("button",{onClick:()=>i(qy(!c)),title:c?"Unlock":"Lock",style:{color:c?"red":"inherit"},children:c?M.jsx(xS,{}):M.jsx(_S,{})}),b&&M.jsx(kS,{onConfirm:O,onClose:()=>m(!1)})]})},RS=({shifted:a})=>{const t=og(),{t:e}=hh(),i=ni(u=>u.whiteboard.toolbar.selectedTool),n=ni(u=>u.whiteboard.toolProperties),r=ni(u=>u.whiteboard.selectedElementIds||[]),o=ni(u=>u.whiteboard.elements),l=r.length>0?o.find(u=>u.id===r[0]):null,c=(u,g,b)=>{t(L1({tool:u,property:g,value:b}))},h=(u,g)=>{if(r.length>0){const b=r.map(m=>({id:m,updates:{[u]:g}}));t(Xy(b))}},d=()=>{r.forEach(u=>{t(B1(u))})},f=()=>{[...r].reverse().forEach(u=>{t(j1(u))})};if(i==="pointer"&&l&&l.type==="text")return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontSize")}),M.jsxs("select",{className:"font-size-selector",value:l.fontSize||16,onChange:u=>h("fontSize",parseInt(u.target.value)),children:[M.jsx("option",{value:"12",children:"12 px"}),M.jsx("option",{value:"14",children:"14 px"}),M.jsx("option",{value:"16",children:"16 px"}),M.jsx("option",{value:"18",children:"18 px"}),M.jsx("option",{value:"24",children:"24 px"}),M.jsx("option",{value:"32",children:"32 px"}),M.jsx("option",{value:"48",children:"48 px"}),M.jsx("option",{value:"64",children:"64 px"}),M.jsx("option",{value:"72",children:"72 px"})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontColor")}),M.jsx("input",{type:"color",value:l.fontColor||"#000000",onChange:u=>h("fontColor",u.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("layerOrder")}),M.jsxs("div",{className:"wb-layer-buttons",children:[M.jsx("button",{onClick:d,title:e("bringToFront"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),M.jsx("button",{onClick:f,title:e("sendToBack"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]});if(i==="pointer"&&l){const u=["rectangle","circle","triangle","diamond","star","heart","hexagon","octagon","arrow"].includes(l.type),g=l.type==="pencil";return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[u&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeColor")}),M.jsx("input",{type:"color",value:l.strokeColor,onChange:b=>h("strokeColor",b.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fillColor")}),M.jsx("input",{type:"color",value:l.fillColor,onChange:b=>h("fillColor",b.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeWidth")}),M.jsxs("select",{className:"stroke-width-selector",value:l.lineWidth,onChange:b=>h("lineWidth",parseInt(b.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"})]})]})]}),g&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushColor")}),M.jsx("input",{type:"color",value:l.strokeColor,onChange:b=>h("strokeColor",b.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushSize")}),M.jsxs("select",{className:"brush-size-selector",value:l.lineWidth,onChange:b=>h("lineWidth",parseInt(b.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"}),M.jsx("option",{value:"16",children:"16 px"})]})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("layerOrder")}),M.jsxs("div",{className:"wb-layer-buttons",children:[M.jsx("button",{onClick:d,title:e("bringToFront"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),M.jsx("button",{onClick:f,title:e("sendToBack"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]})}return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[i==="text"&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontSize")}),M.jsxs("select",{className:"font-size-selector",value:n.text.fontSize,onChange:u=>c("text","fontSize",parseInt(u.target.value)),children:[M.jsx("option",{value:"12",children:"12 px"}),M.jsx("option",{value:"14",children:"14 px"}),M.jsx("option",{value:"16",children:"16 px"}),M.jsx("option",{value:"18",children:"18 px"}),M.jsx("option",{value:"24",children:"24 px"}),M.jsx("option",{value:"32",children:"32 px"}),M.jsx("option",{value:"48",children:"48 px"}),M.jsx("option",{value:"64",children:"64 px"}),M.jsx("option",{value:"72",children:"72 px"})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontColor")}),M.jsx("input",{type:"color",value:n.text.fontColor,onChange:u=>c("text","fontColor",u.target.value)})]})]}),i==="pencil"&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushColor")}),M.jsx("input",{type:"color",value:n.pencil.strokeColor,onChange:u=>c("pencil","strokeColor",u.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushSize")}),M.jsxs("select",{className:"brush-size-selector",value:n.pencil.lineWidth,onChange:u=>c("pencil","lineWidth",parseInt(u.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"}),M.jsx("option",{value:"16",children:"16 px"})]})]})]}),(i==="rectangle"||i==="circle"||i==="triangle"||i==="diamond"||i==="star"||i==="heart"||i==="hexagon"||i==="octagon"||i==="arrow")&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeColor")}),M.jsx("input",{type:"color",value:n[i].strokeColor,onChange:u=>c(i,"strokeColor",u.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fillColor")}),M.jsx("input",{type:"color",value:n[i].fillColor,onChange:u=>c(i,"fillColor",u.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeWidth")}),M.jsxs("select",{className:"stroke-width-selector",value:n[i].lineWidth,onChange:u=>c(i,"lineWidth",parseInt(u.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"})]})]})]})]})},DS=({onFitToView:a,onExport:t,onToggleGrid:e})=>{const{t:i}=hh();return M.jsxs("div",{className:"wb-canvas-tools",children:[M.jsx("button",{onClick:e,title:i("toggleGrid"),children:M.jsx(iS,{})}),M.jsx("button",{onClick:a,title:i("fitToView"),children:M.jsx(lS,{})}),M.jsx("button",{onClick:t,title:i("exportAsPng"),children:M.jsx(bS,{})})]})},OS=({currentPage:a,totalPages:t,onPrevPage:e,onNextPage:i,onDelete:n,onDownload:r})=>{const{t:o}=hh();return t<=0?null:M.jsxs("div",{className:"wb-pdf-navigation",children:[n&&M.jsxs(M.Fragment,{children:[M.jsx("button",{className:"wb-pdf-nav-button wb-pdf-delete",onClick:n,title:o("deletePdf"),children:M.jsx(i0,{})}),M.jsx("div",{className:"wb-pdf-separator"})]}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:e,disabled:a<=1,title:o("prevPage"),children:M.jsx(nS,{})}),M.jsxs("div",{className:"wb-pdf-page-info",children:[o("page")," ",a," ",o("of")," ",t]}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:i,disabled:a>=t,title:o("nextPage"),children:M.jsx(sS,{})}),r&&M.jsxs(M.Fragment,{children:[M.jsx("div",{className:"wb-pdf-separator"}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:r,title:o("downloadPdf"),children:M.jsx(oS,{})})]})]})},Si=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Og=[.001,0,0,.001,0,0],Ig=1.35,Gi={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Nr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},mh="pdfjs_internal_editor_",mt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},Mt={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},IS={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Lg={TRIANGLES:1,LATTICE:2},je={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},uf={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},De={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},bl={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},ff={ERRORS:0,WARNINGS:1,INFOS:5},bh={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},yh={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},LS={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let pf=ff.WARNINGS;function NS(a){Number.isInteger(a)&&(pf=a)}function FS(){return pf}function gf(a){pf>=ff.INFOS&&console.info(`Info: ${a}`)}function pt(a){pf>=ff.WARNINGS&&console.warn(`Warning: ${a}`)}function ie(a){throw new Error(a)}function Rt(a,t){a||ie(t)}function BS(a){switch(a==null?void 0:a.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function n0(a,t=null,e=null){if(!a)return null;if(e&&typeof a=="string"){if(e.addDefaultProtocol&&a.startsWith("www.")){const n=a.match(/\./g);(n==null?void 0:n.length)>=2&&(a=`http://${a}`)}if(e.tryConvertEncoding)try{a=$S(a)}catch{}}const i=t?URL.parse(a,t):URL.parse(a);return BS(i)?i:null}function s0(a,t,e=!1){const i=URL.parse(a);return i?(i.hash=t,i.href):e&&n0(a,"http://example.com")?a.split("#",1)[0]+`${t?`#${t}`:""}`:""}function gt(a,t,e,i=!1){return Object.defineProperty(a,t,{value:e,enumerable:!i,configurable:!0,writable:!1}),e}const Fo=(function(){function t(e,i){this.message=e,this.name=i}return t.prototype=new Error,t.constructor=t,t})();class r0 extends Fo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ng extends Fo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Fg extends Fo{constructor(t){super(t,"InvalidPDFException")}}class mf extends Fo{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class jS extends Fo{constructor(t){super(t,"FormatError")}}class Fr extends Fo{constructor(t){super(t,"AbortException")}}function o0(a){(typeof a!="object"||(a==null?void 0:a.length)===void 0)&&ie("Invalid argument for bytesToString");const t=a.length,e=8192;if(t<e)return String.fromCharCode.apply(null,a);const i=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),o=a.subarray(n,r);i.push(String.fromCharCode.apply(null,o))}return i.join("")}function vh(a){typeof a!="string"&&ie("Invalid argument for stringToBytes");const t=a.length,e=new Uint8Array(t);for(let i=0;i<t;++i)e[i]=a.charCodeAt(i)&255;return e}function zS(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}function US(){const a=new Uint8Array(4);return a[0]=1,new Uint32Array(a.buffer,0,1)[0]===1}function HS(){try{return new Function(""),!0}catch{return!1}}class ze{static get isLittleEndian(){return gt(this,"isLittleEndian",US())}static get isEvalSupported(){return gt(this,"isEvalSupported",HS())}static get isOffscreenCanvasSupported(){return gt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return gt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return gt(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return gt(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return gt(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 gt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Bg=Array.from(Array(256).keys(),a=>a.toString(16).padStart(2,"0"));class Z{static makeHexColor(t,e,i){return`#${Bg[t]}${Bg[e]}${Bg[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const n=t[i],r=t[i+1];t[i]=n*e[0]+r*e[2]+e[4],t[i+1]=n*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const n=e[0],r=e[1],o=e[2],l=e[3],c=e[4],h=e[5];for(let d=0;d<6;d+=2){const f=t[i+d],u=t[i+d+1];t[i+d]=f*n+u*o+c,t[i+d+1]=f*r+u*l+h}}static applyInverseTransform(t,e){const i=t[0],n=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){const n=e[0],r=e[1],o=e[2],l=e[3],c=e[4],h=e[5],d=t[0],f=t[1],u=t[2],g=t[3];let b=n*d+c,m=b,w=n*u+c,y=w,x=l*f+h,E=x,_=l*g+h,C=_;if(r!==0||o!==0){const T=r*d,D=r*u,j=o*f,O=o*g;b+=j,y+=j,w+=O,m+=O,x+=T,C+=T,_+=D,E+=D}i[0]=Math.min(i[0],b,w,m,y),i[1]=Math.min(i[1],x,_,E,C),i[2]=Math.max(i[2],b,w,m,y),i[3]=Math.max(i[3],x,_,E,C)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],n=t[1],r=t[2],o=t[3],l=i**2+n**2,c=i*r+n*o,h=r**2+o**2,d=(l+h)/2,f=Math.sqrt(d**2-(l*h-c**2));e[0]=Math.sqrt(d+f||1),e[1]=Math.sqrt(d-f||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),o=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>o?null:[i,r,n,o]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,n,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,n),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,n)}static bezierBoundingBox(t,e,i,n,r,o,l,c,h){h[0]=Math.min(h[0],t,l),h[1]=Math.min(h[1],e,c),h[2]=Math.max(h[2],t,l),h[3]=Math.max(h[3],e,c),A(this,Fs,jm).call(this,t,i,r,l,e,n,o,c,3*(-t+3*(i-r)+l),6*(t-2*i+r),3*(i-t),h),A(this,Fs,jm).call(this,t,i,r,l,e,n,o,c,3*(-e+3*(n-o)+c),6*(e-2*n+o),3*(n-e),h)}}Fs=new WeakSet,bp=function(t,e,i,n,r,o,l,c,h,d){if(h<=0||h>=1)return;const f=1-h,u=h*h,g=u*h,b=f*(f*(f*t+3*h*e)+3*u*i)+g*n,m=f*(f*(f*r+3*h*o)+3*u*l)+g*c;d[0]=Math.min(d[0],b),d[1]=Math.min(d[1],m),d[2]=Math.max(d[2],b),d[3]=Math.max(d[3],m)},jm=function(t,e,i,n,r,o,l,c,h,d,f,u){if(Math.abs(h)<1e-12){Math.abs(d)>=1e-12&&A(this,Fs,bp).call(this,t,e,i,n,r,o,l,c,-f/d,u);return}const g=d**2-4*f*h;if(g<0)return;const b=Math.sqrt(g),m=2*h;A(this,Fs,bp).call(this,t,e,i,n,r,o,l,c,(-d+b)/m,u),A(this,Fs,bp).call(this,t,e,i,n,r,o,l,c,(-d-b)/m,u)},v(Z,Fs);function $S(a){return decodeURIComponent(escape(a))}let jg=null,a0=null;function WS(a){return jg||(jg=/([\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,a0=new Map([["ſt","ſt"]])),a.replaceAll(jg,(t,e,i)=>e?e.normalize("NFKC"):a0.get(i))}function l0(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const a=new Uint8Array(32);return crypto.getRandomValues(a),o0(a)}const yl="pdfjs_internal_id_";function VS(a,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[i,n,...r]=e;if(!a(i)&&!Number.isInteger(i)||!t(n))return!1;const o=r.length;let l=!0;switch(n.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(o!==4)return!1;l=!1;break;default:return!1}for(const c of r)if(!(typeof c=="number"||l&&c===null))return!1;return!0}function Ei(a,t,e){return Math.min(Math.max(a,t),e)}function c0(a){return Uint8Array.prototype.toBase64?a.toBase64():btoa(o0(a))}function GS(a){return Uint8Array.fromBase64?Uint8Array.fromBase64(a):vh(atob(a))}typeof Promise.try!="function"&&(Promise.try=function(a,...t){return new Promise(e=>{e(a(...t))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(a){return a.reduce((t,e)=>t+e,0)});class wh{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};function n(r){var c;if(!r)return;let o=null;const l=r.name;if(l==="#text")o=r.value;else if(wh.shouldBuildText(l))(c=r==null?void 0:r.attributes)!=null&&c.textContent?o=r.attributes.textContent:r.value&&(o=r.value);else return;if(o!==null&&e.push({str:o}),!!r.children)for(const h of r.children)n(h)}return n(t),i}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class h0{static setupStorage(t,e,i,n,r){const o=n.getValue(e,{value:null});switch(i.name){case"textarea":if(o.value!==null&&(t.textContent=o.value),r==="print")break;t.addEventListener("input",l=>{n.setValue(e,{value:l.target.value})});break;case"input":if(i.attributes.type==="radio"||i.attributes.type==="checkbox"){if(o.value===i.attributes.xfaOn?t.setAttribute("checked",!0):o.value===i.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",l=>{n.setValue(e,{value:l.target.checked?l.target.getAttribute("xfaOn"):l.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&t.setAttribute("value",o.value),r==="print")break;t.addEventListener("input",l=>{n.setValue(e,{value:l.target.value})})}break;case"select":if(o.value!==null){t.setAttribute("value",o.value);for(const l of i.children)l.attributes.value===o.value?l.attributes.selected=!0:l.attributes.hasOwnProperty("selected")&&delete l.attributes.selected}t.addEventListener("input",l=>{const c=l.target.options,h=c.selectedIndex===-1?"":c[c.selectedIndex].value;n.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:r}){const{attributes:o}=e,l=t instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${n}`);for(const[c,h]of Object.entries(o))if(h!=null)switch(c){case"class":h.length&&t.setAttribute(c,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!l||c!=="href"&&c!=="newWindow")&&t.setAttribute(c,h)}l&&r.addLinkAttributes(t,o.href,o.newWindow),i&&o.dataId&&this.setupStorage(t,o.dataId,e,i)}static render(t){var f,u;const e=t.annotationStorage,i=t.linkService,n=t.xfaHtml,r=t.intent||"display",o=document.createElement(n.name);n.attributes&&this.setAttributes({html:o,element:n,intent:r,linkService:i});const l=r!=="richText",c=t.div;if(c.append(o),t.viewport){const g=`matrix(${t.viewport.transform.join(",")})`;c.style.transform=g}l&&c.setAttribute("class","xfaLayer xfaFont");const h=[];if(n.children.length===0){if(n.value){const g=document.createTextNode(n.value);o.append(g),l&&wh.shouldBuildText(n.name)&&h.push(g)}return{textDivs:h}}const d=[[n,-1,o]];for(;d.length>0;){const[g,b,m]=d.at(-1);if(b+1===g.children.length){d.pop();continue}const w=g.children[++d.at(-1)[1]];if(w===null)continue;const{name:y}=w;if(y==="#text"){const E=document.createTextNode(w.value);h.push(E),m.append(E);continue}const x=(f=w==null?void 0:w.attributes)!=null&&f.xmlns?document.createElementNS(w.attributes.xmlns,y):document.createElement(y);if(m.append(x),w.attributes&&this.setAttributes({html:x,element:w,storage:e,intent:r,linkService:i}),((u=w.children)==null?void 0:u.length)>0)d.push([w,-1,x]);else if(w.value){const E=document.createTextNode(w.value);l&&wh.shouldBuildText(y)&&h.push(E),x.append(E)}}for(const g of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))g.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Ls="http://www.w3.org/2000/svg",Ho=class Ho{};$(Ho,"CSS",96),$(Ho,"PDF",72),$(Ho,"PDF_TO_CSS_UNITS",Ho.CSS/Ho.PDF);let Br=Ho;async function Ah(a,t="text"){if(Eh(a,document.baseURI)){const e=await fetch(a);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,i)=>{const n=new XMLHttpRequest;n.open("GET",a,!0),n.responseType=t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(n.response);return}e(n.responseText);return}i(new Error(n.statusText))}},n.send(null)})}class Sh{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:r=0,offsetY:o=0,dontFlip:l=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=r,this.offsetY=o,i*=e;const c=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let d,f,u,g;switch(n%=360,n<0&&(n+=360),n){case 180:d=-1,f=0,u=0,g=1;break;case 90:d=0,f=1,u=1,g=0;break;case 270:d=0,f=-1,u=-1,g=0;break;case 0:d=1,f=0,u=0,g=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}l&&(u=-u,g=-g);let b,m,w,y;d===0?(b=Math.abs(h-t[1])*i+r,m=Math.abs(c-t[0])*i+o,w=(t[3]-t[1])*i,y=(t[2]-t[0])*i):(b=Math.abs(c-t[0])*i+r,m=Math.abs(h-t[1])*i+o,w=(t[2]-t[0])*i,y=(t[3]-t[1])*i),this.transform=[d*i,f*i,u*i,g*i,b-d*i*c-u*i*h,m-f*i*c-g*i*h],this.width=w,this.height=y}get rawDims(){const t=this.viewBox;return gt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:r=!1}={}){return new Sh({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:r})}convertToViewportPoint(t,e){const i=[t,e];return Z.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Z.applyTransform(e,this.transform);const i=[t[2],t[3]];return Z.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Z.applyInverseTransform(i,this.transform),i}}class zg extends Fo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function bf(a){const t=a.length;let e=0;for(;e<t&&a[e].trim()==="";)e++;return a.substring(e,e+5).toLowerCase()==="data:"}function Ug(a){return typeof a=="string"&&/\.pdf$/i.test(a)}function YS(a){return[a]=a.split(/[#?]/,1),a.substring(a.lastIndexOf("/")+1)}function XS(a,t="document.pdf"){if(typeof a!="string")return t;if(bf(a))return pt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const i=(l=>{try{return new URL(l)}catch{try{return new URL(decodeURIComponent(l))}catch{try{return new URL(l,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(l),"https://foo.bar")}catch{return null}}}}})(a);if(!i)return t;const n=l=>{try{let c=decodeURIComponent(l);return c.includes("/")?(c=c.split("/").at(-1),c.test(/^\.pdf$/i)?c:l):c}catch{return l}},r=/\.pdf$/i,o=i.pathname.split("/").at(-1);if(r.test(o))return n(o);if(i.searchParams.size>0){const l=Array.from(i.searchParams.values()).reverse();for(const h of l)if(r.test(h))return n(h);const c=Array.from(i.searchParams.keys()).reverse();for(const h of c)if(r.test(h))return n(h)}if(i.hash){const c=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(c)return n(c[0])}return t}class d0{constructor(){$(this,"started",Object.create(null));$(this,"times",[])}time(t){t in this.started&&pt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||pt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:n,end:r}of this.times)t.push(`${i.padEnd(e)} ${r-n}ms
100
- `);return t.join("")}}function Eh(a,t){const e=t?URL.parse(a,t):URL.parse(a);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function vn(a){a.preventDefault()}function Ee(a){a.preventDefault(),a.stopPropagation()}function qS(a){console.log("Deprecated API usage: "+a)}class yf{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;s(this,Lh)||p(this,Lh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=s(this,Lh).exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(e[4],10);o=o>=0&&o<=23?o:0;let l=parseInt(e[5],10);l=l>=0&&l<=59?l:0;let c=parseInt(e[6],10);c=c>=0&&c<=59?c:0;const h=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let f=parseInt(e[9],10)||0;return f=f>=0&&f<=59?f:0,h==="-"?(o+=d,l+=f):h==="+"&&(o-=d,l-=f),new Date(Date.UTC(i,n,r,o,l,c))}}Lh=new WeakMap,v(yf,Lh);function KS(a,{scale:t=1,rotation:e=0}){const{width:i,height:n}=a.attributes.style,r=[0,0,parseInt(i),parseInt(n)];return new Sh({viewBox:r,userUnit:1,scale:t,rotation:e})}function xh(a){if(a.startsWith("#")){const t=parseInt(a.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return a.startsWith("rgb(")?a.slice(4,-1).split(",").map(t=>parseInt(t)):a.startsWith("rgba(")?a.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(pt(`Not a valid color format: "${a}"`),[0,0,0])}function JS(a){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of a.keys()){t.style.color=e;const i=window.getComputedStyle(t).color;a.set(e,xh(i))}t.remove()}function ye(a){const{a:t,b:e,c:i,d:n,e:r,f:o}=a.getTransform();return[t,e,i,n,r,o]}function ns(a){const{a:t,b:e,c:i,d:n,e:r,f:o}=a.getTransform().invertSelf();return[t,e,i,n,r,o]}function Bo(a,t,e=!1,i=!0){if(t instanceof Sh){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:o}=a,l=ze.isCSSRoundSupported,c=`var(--total-scale-factor) * ${n}px`,h=`var(--total-scale-factor) * ${r}px`,d=l?`round(down, ${c}, var(--scale-round-x))`:`calc(${c})`,f=l?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(o.width=d,o.height=f):(o.width=f,o.height=d)}i&&a.setAttribute("data-main-rotation",t.rotation)}class ss{constructor(){const{pixelRatio:t}=ss;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,n,r=-1){let o=1/0,l=1/0,c=1/0;i=ss.capPixels(i,r),i>0&&(o=Math.sqrt(i/(t*e))),n!==-1&&(l=n/t,c=n/e);const h=Math.min(o,l,c);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Hg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class ZS{static get isDarkMode(){var t;return gt(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class QS{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),gt(this,"commentForegroundColor",xh(i))}}function tE(a,t,e,i){i=Math.min(Math.max(i??1,0),1);const n=255*(1-i);return a=Math.round(a*i+n),t=Math.round(t*i+n),e=Math.round(e*i+n),[a,t,e]}function u0(a,t){const e=a[0]/255,i=a[1]/255,n=a[2]/255,r=Math.max(e,i,n),o=Math.min(e,i,n),l=(r+o)/2;if(r===o)t[0]=t[1]=0;else{const c=r-o;switch(t[1]=l<.5?c/(r+o):c/(2-r-o),r){case e:t[0]=((i-n)/c+(i<n?6:0))*60;break;case i:t[0]=((n-e)/c+2)*60;break;case n:t[0]=((e-i)/c+4)*60;break}}t[2]=l}function $g(a,t){const e=a[0],i=a[1],n=a[2],r=(1-Math.abs(2*n-1))*i,o=r*(1-Math.abs(e/60%2-1)),l=n-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+l,t[1]=o+l,t[2]=l;break;case 1:t[0]=o+l,t[1]=r+l,t[2]=l;break;case 2:t[0]=l,t[1]=r+l,t[2]=o+l;break;case 3:t[0]=l,t[1]=o+l,t[2]=r+l;break;case 4:t[0]=o+l,t[1]=l,t[2]=r+l;break;case 5:case 6:t[0]=r+l,t[1]=l,t[2]=o+l;break}}function f0(a){return a<=.03928?a/12.92:((a+.055)/1.055)**2.4}function p0(a,t,e){$g(a,e),e.map(f0);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];$g(t,e),e.map(f0);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return i>n?(i+.05)/(n+.05):(n+.05)/(i+.05)}const g0=new Map;function eE(a,t){const e=a[0]+a[1]*256+a[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let i=g0.get(e);if(i)return i;const n=new Float32Array(9),r=n.subarray(0,3),o=n.subarray(3,6);u0(a,o);const l=n.subarray(6,9);u0(t,l);const c=l[2]<.5,h=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),p0(o,l,r)<h){let d,f;c?(d=o[2],f=1):(d=0,f=o[2]);const u=.005;for(;f-d>u;){const g=o[2]=(d+f)/2;c===p0(o,l,r)<h?d=g:f=g}o[2]=c?f:d}return $g(o,r),i=Z.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),g0.set(e,i),i}function m0({html:a,dir:t,className:e},i){const n=document.createDocumentFragment();if(typeof a=="string"){const r=document.createElement("p");r.dir=t||"auto";const o=a.split(/(?:\r\n?|\n)/);for(let l=0,c=o.length;l<c;++l){const h=o[l];r.append(document.createTextNode(h)),l<c-1&&r.append(document.createElement("br"))}n.append(r)}else h0.render({xfaHtml:a,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),i.append(n)}function b0(a){const t=new Path2D;if(!a)return t;for(let e=0,i=a.length;e<i;)switch(a[e++]){case yh.moveTo:t.moveTo(a[e++],a[e++]);break;case yh.lineTo:t.lineTo(a[e++],a[e++]);break;case yh.curveTo:t.bezierCurveTo(a[e++],a[e++],a[e++],a[e++],a[e++],a[e++]);break;case yh.quadraticCurveTo:t.quadraticCurveTo(a[e++],a[e++],a[e++],a[e++]);break;case yh.closePath:t.closePath();break;default:pt(`Unrecognized drawing path operator: ${a[e-1]}`);break}return t}const Bs=class Bs{constructor(t){v(this,ri);v(this,jr,null);v(this,zr,null);v(this,Sn);v(this,En,null);v(this,Nh,null);v(this,Ur,null);v(this,El,null);v(this,xl,null);p(this,Sn,t),s(Bs,Fh)||p(Bs,Fh,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=p(this,jr,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=s(this,Sn)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",vn,{signal:e}),t.addEventListener("pointerdown",A(Bs,Uf,vv),{signal:e}));const i=p(this,En,document.createElement("div"));i.className="buttons",t.append(i);const n=s(this,Sn).toolbarPosition;if(n){const{style:r}=t,o=s(this,Sn)._uiManager.direction==="ltr"?1-n[0]:n[0];r.insetInlineEnd=`${100*o}%`,r.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return s(this,jr)}hide(){var t;s(this,jr).classList.add("hidden"),(t=s(this,zr))==null||t.hideDropdown()}show(){var t,e;s(this,jr).classList.remove("hidden"),(t=s(this,Nh))==null||t.shown(),(e=s(this,Ur))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=s(this,Sn),i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",s(Bs,Fh)[t]),A(this,ri,sh).call(this,i)&&i.addEventListener("click",n=>{e.delete()},{signal:e._signal}),s(this,En).append(i)}async addAltText(t){const e=await t.render();A(this,ri,sh).call(this,e),s(this,En).append(e,s(this,ri,Ou)),p(this,Nh,t)}addComment(t,e=null){if(s(this,Ur))return;const i=t.renderForToolbar();if(!i)return;A(this,ri,sh).call(this,i);const n=p(this,El,s(this,ri,Ou));e?(s(this,En).insertBefore(i,e),s(this,En).insertBefore(n,e)):s(this,En).append(i,n),p(this,Ur,t),t.toolbar=this}addColorPicker(t){if(s(this,zr))return;p(this,zr,t);const e=t.renderButton();A(this,ri,sh).call(this,e),s(this,En).append(e,s(this,ri,Ou))}async addEditSignatureButton(t){const e=p(this,xl,await t.renderEditButton(s(this,Sn)));A(this,ri,sh).call(this,e),s(this,En).append(e,s(this,ri,Ou))}removeButton(t){var e,i;switch(t){case"comment":(e=s(this,Ur))==null||e.removeToolbarCommentButton(),p(this,Ur,null),(i=s(this,El))==null||i.remove(),p(this,El,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,i){if(!e&&t==="comment")return;const n=s(this,En).querySelector(i);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){s(this,xl)&&(s(this,xl).title=t)}remove(){var t;s(this,jr).remove(),(t=s(this,zr))==null||t.destroy(),p(this,zr,null)}};jr=new WeakMap,zr=new WeakMap,Sn=new WeakMap,En=new WeakMap,Nh=new WeakMap,Ur=new WeakMap,El=new WeakMap,xl=new WeakMap,Fh=new WeakMap,Uf=new WeakSet,vv=function(t){t.stopPropagation()},ri=new WeakSet,wv=function(t){s(this,Sn)._focusEventsAllowed=!1,Ee(t)},Av=function(t){s(this,Sn)._focusEventsAllowed=!0,Ee(t)},sh=function(t){const e=s(this,Sn)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",A(this,ri,wv).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",A(this,ri,Av).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",vn,{signal:e}),!0)},Ou=function(){const t=document.createElement("div");return t.className="divider",t},v(Bs,Uf),v(Bs,Fh,null);let Wg=Bs;class iE{constructor(t){v(this,zs);v(this,Bh,null);v(this,$o,null);v(this,js);p(this,js,t)}show(t,e,i){const[n,r]=A(this,zs,Ev).call(this,e,i),{style:o}=s(this,$o)||p(this,$o,A(this,zs,Sv).call(this));t.append(s(this,$o)),o.insetInlineEnd=`${100*n}%`,o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){s(this,$o).remove()}}Bh=new WeakMap,$o=new WeakMap,js=new WeakMap,zs=new WeakSet,Sv=function(){const t=p(this,$o,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=s(this,js)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",vn,{signal:e});const i=p(this,Bh,document.createElement("div"));return i.className="buttons",t.append(i),s(this,js).hasCommentManager()&&A(this,zs,zm).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{s(this,js).commentSelection("floating_button")}),A(this,zs,zm).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{s(this,js).highlightSelection("floating_button")}),t},Ev=function(t,e){let i=0,n=0;for(const r of t){const o=r.y+r.height;if(o<i)continue;const l=r.x+(e?r.width:0);if(o>i){n=l,i=o;continue}e?l>n&&(n=l):l<n&&(n=l)}return[e?1-n:n,i]},zm=function(t,e,i,n){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const o=document.createElement("span");r.append(o),o.className="visuallyHidden",o.setAttribute("data-l10n-id",i);const l=s(this,js)._signal;l instanceof AbortSignal&&!l.aborted&&(r.addEventListener("contextmenu",vn,{signal:l}),r.addEventListener("click",n,{signal:l})),s(this,Bh).append(r)};function y0(a,t,e){for(const i of e)t.addEventListener(i,a[i].bind(a))}const qt=class qt{static initializeAndAddPointerId(t){(s(qt,Vo)||p(qt,Vo,new Set)).add(t)}static setPointer(t,e){s(qt,Wo)||p(qt,Wo,e),s(qt,Go)??p(qt,Go,t)}static setTimeStamp(t){p(qt,Cl,t)}static isSamePointerId(t){return s(qt,Wo)===t}static isSamePointerIdOrRemove(t){var e;return s(qt,Wo)===t?!0:((e=s(qt,Vo))==null||e.delete(t),!1)}static isSamePointerType(t){return s(qt,Go)===t}static isInitializedAndDifferentPointerType(t){return s(qt,Go)!==null&&!qt.isSamePointerType(t)}static isSameTimeStamp(t){return s(qt,Cl)===t}static isUsingMultiplePointers(){var t;return((t=s(qt,Vo))==null?void 0:t.size)>=1}static clearPointerType(){p(qt,Go,null)}static clearPointerIds(){p(qt,Wo,NaN),p(qt,Vo,null)}static clearTimeStamp(){p(qt,Cl,NaN)}};Wo=new WeakMap,Vo=new WeakMap,Cl=new WeakMap,Go=new WeakMap,v(qt,Wo,NaN),v(qt,Vo,null),v(qt,Cl,NaN),v(qt,Go,null);let pi=qt;class nE{constructor(){v(this,Hf,0)}get id(){return`${mh}${Xe(this,Hf)._++}`}}Hf=new WeakMap;const _m=class _m{constructor(){v(this,Tl);v(this,_l,l0());v(this,jh,0);v(this,gi,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src=t;const r=n.decode().then(()=>(i.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0]===0));return gt(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:i,size:n,type:r}=t;return A(this,Tl,yp).call(this,`${e}_${i}_${n}_${r}`,t)}async getFromUrl(t){return A(this,Tl,yp).call(this,t,t)}async getFromBlob(t,e){const i=await e;return A(this,Tl,yp).call(this,t,i)}async getFromId(t){s(this,gi)||p(this,gi,new Map);const e=s(this,gi).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:i}=e;return delete e.blobPromise,this.getFromBlob(e.id,i)}return this.getFromUrl(e.url)}getFromCanvas(t,e){s(this,gi)||p(this,gi,new Map);let i=s(this,gi).get(t);if(i!=null&&i.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${s(this,_l)}_${Xe(this,jh)._++}`,refCounter:1,isSvg:!1},s(this,gi).set(t,i),s(this,gi).set(i.id,i),i}getSvgUrl(t){const e=s(this,gi).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var n;s(this,gi)||p(this,gi,new Map);const e=s(this,gi).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:i}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(i.width,i.height);r.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=r.convertToBlob()}(n=i.close)==null||n.call(i),e.bitmap=null}isValidId(t){return t.startsWith(`image_${s(this,_l)}_`)}};_l=new WeakMap,jh=new WeakMap,gi=new WeakMap,Tl=new WeakSet,yp=async function(t,e){s(this,gi)||p(this,gi,new Map);let i=s(this,gi).get(t);if(i===null)return null;if(i!=null&&i.bitmap)return i.refCounter+=1,i;try{i||(i={bitmap:null,id:`image_${s(this,_l)}_${Xe(this,jh)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(i.url=e,n=await Ah(e,"blob")):e instanceof File?n=i.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=_m._isSVGFittingCanvas,o=new FileReader,l=new Image,c=new Promise((h,d)=>{l.onload=()=>{i.bitmap=l,i.isSvg=!0,h()},o.onload=async()=>{const f=i.svgUrl=o.result;l.src=await r?`${f}#svgView(preserveAspectRatio(none))`:f},l.onerror=o.onerror=d});o.readAsDataURL(n),await c}else i.bitmap=await createImageBitmap(n);i.refCounter=1}catch(n){pt(n),i=null}return s(this,gi).set(t,i),i&&s(this,gi).set(i.id,i),i};let Vg=_m;class sE{constructor(t=128){v(this,ke,[]);v(this,Hr,!1);v(this,zh);v(this,we,-1);p(this,zh,t)}add({cmd:t,undo:e,post:i,mustExec:n,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:l=!1}){if(n&&t(),s(this,Hr))return;const c={cmd:t,undo:e,post:i,type:r};if(s(this,we)===-1){s(this,ke).length>0&&(s(this,ke).length=0),p(this,we,0),s(this,ke).push(c);return}if(o&&s(this,ke)[s(this,we)].type===r){l&&(c.undo=s(this,ke)[s(this,we)].undo),s(this,ke)[s(this,we)]=c;return}const h=s(this,we)+1;h===s(this,zh)?s(this,ke).splice(0,1):(p(this,we,h),h<s(this,ke).length&&s(this,ke).splice(h)),s(this,ke).push(c)}undo(){if(s(this,we)===-1)return;p(this,Hr,!0);const{undo:t,post:e}=s(this,ke)[s(this,we)];t(),e==null||e(),p(this,Hr,!1),p(this,we,s(this,we)-1)}redo(){if(s(this,we)<s(this,ke).length-1){p(this,we,s(this,we)+1),p(this,Hr,!0);const{cmd:t,post:e}=s(this,ke)[s(this,we)];t(),e==null||e(),p(this,Hr,!1)}}hasSomethingToUndo(){return s(this,we)!==-1}hasSomethingToRedo(){return s(this,we)<s(this,ke).length-1}cleanType(t){if(s(this,we)!==-1){for(let e=s(this,we);e>=0;e--)if(s(this,ke)[e].type!==t){s(this,ke).splice(e+1,s(this,we)-e),p(this,we,e);return}s(this,ke).length=0,p(this,we,-1)}}destroy(){p(this,ke,null)}}ke=new WeakMap,Hr=new WeakMap,zh=new WeakMap,we=new WeakMap;class Ch{constructor(t){v(this,$f);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=ze.platform;for(const[i,n,r={}]of t)for(const o of i){const l=o.startsWith("mac+");e&&l?(this.callbacks.set(o.slice(4),{callback:n,options:r}),this.allKeys.add(o.split("+").at(-1))):!e&&!l&&(this.callbacks.set(o,{callback:n,options:r}),this.allKeys.add(o.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(A(this,$f,xv).call(this,e));if(!i)return;const{callback:n,options:{bubbles:r=!1,args:o=[],checker:l=null}}=i;l&&!l(t,e)||(n.bind(t,...o,e)(),r||Ee(e))}}$f=new WeakSet,xv=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 Wf=class Wf{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return JS(t),gt(this,"_colors",t)}convert(t){const e=xh(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,n]of this._colors)if(n.every((r,o)=>r===e[o]))return Wf._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?Z.makeHexColor(...e):t}};$(Wf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Gg=Wf;const Bl=class Bl{constructor(t,e,i,n,r,o,l,c,h,d,f,u,g,b,m,w){v(this,q);v(this,Pl,new AbortController);v(this,Xi,null);v(this,kl,null);v(this,xe,new Map);v(this,Ue,new Map);v(this,Ml,null);v(this,xn,null);v(this,Rl,null);v(this,Cn,new sE);v(this,mi,null);v(this,$r,null);v(this,Wr,null);v(this,Dl,0);v(this,Vr,new Set);v(this,as,null);v(this,_n,null);v(this,Yo,new Set);$(this,"_editorUndoBar",null);v(this,Uh,!1);v(this,Hh,!1);v(this,Ol,!1);v(this,$h,null);v(this,ls,null);v(this,Gr,null);v(this,Il,null);v(this,Yr,!1);v(this,cs,null);v(this,Vf,new nE);v(this,Xr,!1);v(this,Ll,!1);v(this,Wh,!1);v(this,qr,null);v(this,Xo,null);v(this,Nl,null);v(this,Kr,null);v(this,Vh,null);v(this,Ie,mt.NONE);v(this,Yt,new Set);v(this,Us,null);v(this,Jr,null);v(this,Zr,null);v(this,Gh,null);v(this,Fl,null);v(this,Yh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});v(this,Qr,[0,0]);v(this,hs,null);v(this,Hs,null);v(this,Xh,null);v(this,qh,null);v(this,Tn,null);const y=this._signal=s(this,Pl).signal;p(this,Hs,t),p(this,Xh,e),p(this,qh,i),p(this,Ml,n),p(this,mi,r),p(this,Jr,o),p(this,Fl,c),this._eventBus=l,l._on("editingaction",this.onEditingAction.bind(this),{signal:y}),l._on("pagechanging",this.onPageChanging.bind(this),{signal:y}),l._on("scalechanging",this.onScaleChanging.bind(this),{signal:y}),l._on("rotationchanging",this.onRotationChanging.bind(this),{signal:y}),l._on("setpreference",this.onSetPreference.bind(this),{signal:y}),l._on("switchannotationeditorparams",x=>this.updateParams(x.type,x.value),{signal:y}),window.addEventListener("pointerdown",()=>{p(this,Ll,!0)},{capture:!0,signal:y}),window.addEventListener("pointerup",()=>{p(this,Ll,!1)},{capture:!0,signal:y}),A(this,q,Tv).call(this),A(this,q,Ov).call(this),A(this,q,Hm).call(this),p(this,xn,c.annotationStorage),p(this,$h,c.filterFactory),p(this,Zr,h),p(this,Il,d||null),p(this,Uh,f),p(this,Hh,u),p(this,Ol,g),p(this,Vh,b||null),this.viewParameters={realScale:Br.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=m||null,this._supportsPinchToZoom=w!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Bl.prototype,e=o=>s(o,Hs).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),i=(o,{target:l})=>{if(l instanceof HTMLInputElement){const{type:c}=l;return c!=="text"&&c!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return gt(this,"_keyboardManager",new Ch([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.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"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(o,{target:l})=>!(l instanceof HTMLButtonElement)&&s(o,Hs).contains(l)&&!o.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(o,{target:l})=>!(l instanceof HTMLButtonElement)&&s(o,Hs).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,i,n,r,o,l,c,h;(t=s(this,Tn))==null||t.resolve(),p(this,Tn,null),(e=s(this,Pl))==null||e.abort(),p(this,Pl,null),this._signal=null;for(const d of s(this,Ue).values())d.destroy();s(this,Ue).clear(),s(this,xe).clear(),s(this,Yo).clear(),(i=s(this,Kr))==null||i.clear(),p(this,Xi,null),s(this,Yt).clear(),s(this,Cn).destroy(),(n=s(this,Ml))==null||n.destroy(),(r=s(this,mi))==null||r.destroy(),(o=s(this,Jr))==null||o.destroy(),(l=s(this,cs))==null||l.hide(),p(this,cs,null),(c=s(this,Nl))==null||c.destroy(),p(this,Nl,null),p(this,kl,null),s(this,ls)&&(clearTimeout(s(this,ls)),p(this,ls,null)),s(this,hs)&&(clearTimeout(s(this,hs)),p(this,hs,null)),(h=this._editorUndoBar)==null||h.destroy(),p(this,Fl,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return s(this,Vh)}get useNewAltTextFlow(){return s(this,Hh)}get useNewAltTextWhenAddingImage(){return s(this,Ol)}get hcmFilter(){return gt(this,"hcmFilter",s(this,Zr)?s(this,$h).addHCMFilter(s(this,Zr).foreground,s(this,Zr).background):"none")}get direction(){return gt(this,"direction",getComputedStyle(s(this,Hs)).direction)}get _highlightColors(){return gt(this,"_highlightColors",s(this,Il)?new Map(s(this,Il).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return gt(this,"highlightColors",null);const e=new Map,i=!!s(this,Zr);for(const[n,r]of t){const o=n.endsWith("_HCM");if(i&&o){e.set(n.replace("_HCM",""),r);continue}!i&&!o&&e.set(n,r)}return gt(this,"highlightColors",e)}get highlightColorNames(){return gt(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,t=>t.reverse())):null)}getNonHCMColor(t){if(!this._highlightColors)return t;const e=this.highlightColorNames.get(t);return this._highlightColors.get(e)||t}getNonHCMColorName(t){return this.highlightColorNames.get(t)||t}setCurrentDrawingSession(t){t?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),p(this,Wr,t)}setMainHighlightColorPicker(t){p(this,Nl,t)}editAltText(t,e=!1){var i;(i=s(this,Ml))==null||i.editAltText(this,t,e)}hasCommentManager(){return!!s(this,mi)}editComment(t,e,i,n){var r;(r=s(this,mi))==null||r.showDialog(this,t,e,i,n)}selectComment(t,e){const i=s(this,Ue).get(t),n=i==null?void 0:i.getEditorByUID(e);n==null||n.toggleComment(!0,!0)}updateComment(t){var e;(e=s(this,mi))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=s(this,mi))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=s(this,mi))==null||e.removeComments([t.uid])}toggleComment(t,e,i=void 0){var n;(n=s(this,mi))==null||n.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){var i;return t&&((i=s(this,mi))==null?void 0:i.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=s(this,mi))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(s(this,Ue).has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),n=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await i}getSignature(t){var e;(e=s(this,Jr))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return s(this,Jr)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":p(this,Ol,e);break}}onPageChanging({pageNumber:t}){p(this,Dl,t-1)}focusMainContainer(){s(this,Hs).focus()}findParent(t,e){for(const i of s(this,Ue).values()){const{x:n,y:r,width:o,height:l}=i.div.getBoundingClientRect();if(t>=n&&t<=n+o&&e>=r&&e<=r+l)return i}return null}disableUserSelect(t=!1){s(this,Xh).classList.toggle("noUserSelect",t)}addShouldRescale(t){s(this,Yo).add(t)}removeShouldRescale(t){s(this,Yo).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Br.PDF_TO_CSS_UNITS;for(const i of s(this,Yo))i.onScaleChanging();(e=s(this,Wr))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:l}=i,c=i.toString(),d=A(this,q,vp).call(this,i).closest(".textLayer"),f=this.getSelectionBoxes(d);if(!f)return;i.empty();const u=A(this,q,Um).call(this,d),g=s(this,Ie)===mt.NONE,b=()=>{const m=u==null?void 0:u.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:f,anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:l,text:c});g&&this.showAllEditors("highlight",!0,!0),e&&(m==null||m.editComment())};if(g){this.switchToMode(mt.HIGHLIGHT,b);return}b()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!s(this,xn))return null;const e=`${mh}${t}`,i=s(this,xn).getRawValue(e);return i&&s(this,xn).remove(e),i}addToAnnotationStorage(t){!t.isEmpty()&&s(this,xn)&&!s(this,xn).has(t.id)&&s(this,xn).setValue(t.id,t)}a11yAlert(t,e=null){const i=s(this,qh);i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,s(this,Yr)&&(p(this,Yr,!1),A(this,q,Iu).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of s(this,Yt))if(e.div.contains(t)){p(this,Xo,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!s(this,Xo))return;const[t,e]=s(this,Xo);p(this,Xo,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){A(this,q,Hm).call(this),this.setEditingState(!0)}removeEditListeners(){A(this,q,Mv).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of s(this,_n))if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const i of s(this,_n))if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var i;if(t.preventDefault(),(i=s(this,Xi))==null||i.commitOrRemove(),!this.hasSelection)return;const e=[];for(const n of s(this,Yt)){const r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const o of s(this,_n))if(o.isHandlingMimeForPasting(r.type)){o.paste(r,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(r){pt(`paste: "${r.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();const n=this.currentLayer;try{const r=[];for(const c of i){const h=await n.deserialize(c);if(!h)return;r.push(h)}const o=()=>{for(const c of r)A(this,q,$m).call(this,c);A(this,q,Wm).call(this,r)},l=()=>{for(const c of r)c.remove()};this.addCommands({cmd:o,undo:l,mustExec:!0})}catch(r){pt(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),s(this,Ie)!==mt.NONE&&!this.isEditorHandlingKeyboard&&Bl._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,s(this,Yr)&&(p(this,Yr,!1),A(this,q,Iu).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(t){t?(A(this,q,Pv).call(this),A(this,q,Rv).call(this),A(this,q,Mi).call(this,{isEditing:s(this,Ie)!==mt.NONE,isEmpty:A(this,q,Lu).call(this),hasSomethingToUndo:s(this,Cn).hasSomethingToUndo(),hasSomethingToRedo:s(this,Cn).hasSomethingToRedo(),hasSelectedEditor:!1})):(A(this,q,kv).call(this),A(this,q,Dv).call(this),A(this,q,Mi).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!s(this,_n)){p(this,_n,t);for(const e of s(this,_n))A(this,q,Tr).call(this,e.defaultPropertiesToUpdate)}}getId(){return s(this,Vf).id}get currentLayer(){return s(this,Ue).get(s(this,Dl))}getLayer(t){return s(this,Ue).get(t)}get currentPageIndex(){return s(this,Dl)}addLayer(t){s(this,Ue).set(t.pageIndex,t),s(this,Xr)?t.enable():t.disable()}removeLayer(t){s(this,Ue).delete(t.pageIndex)}async updateMode(t,e=null,i=!1,n=!1,r=!1,o=!1){var l,c,h,d,f,u;if(s(this,Ie)!==t&&!(s(this,Tn)&&(await s(this,Tn).promise,!s(this,Tn)))){if(p(this,Tn,Promise.withResolvers()),(l=s(this,Wr))==null||l.commitOrRemove(),s(this,Ie)===mt.POPUP&&((c=s(this,mi))==null||c.hideSidebar()),(h=s(this,mi))==null||h.destroyPopup(),p(this,Ie,t),t===mt.NONE){this.setEditingState(!1),A(this,q,Lv).call(this);for(const g of s(this,xe).values())g.hideStandaloneCommentButton();(d=this._editorUndoBar)==null||d.hide(),this.toggleComment(null),s(this,Tn).resolve();return}for(const g of s(this,xe).values())g.addStandaloneCommentButton();t===mt.SIGNATURE&&await((f=s(this,Jr))==null?void 0:f.loadSignatures()),i&&pi.clearPointerType(),this.setEditingState(!0),await A(this,q,Iv).call(this),this.unselectAll();for(const g of s(this,Ue).values())g.updateMode(t);if(t===mt.POPUP){s(this,kl)||p(this,kl,await s(this,Fl).getAnnotationsByType(new Set(s(this,_n).map(m=>m._editorType))));const g=new Set,b=[];for(const m of s(this,xe).values()){const{annotationElementId:w,hasComment:y,deleted:x}=m;w&&g.add(w),y&&!x&&b.push(m.getData())}for(const m of s(this,kl)){const{id:w,popupRef:y,contentsObj:x}=m;y&&(x!=null&&x.str)&&!g.has(w)&&!s(this,Vr).has(w)&&b.push(m)}(u=s(this,mi))==null||u.showSidebar(b)}if(!e){n&&this.addNewEditorFromKeyboard(),s(this,Tn).resolve();return}for(const g of s(this,xe).values())g.uid===e?(this.setSelected(g),o?g.editComment():r?g.enterInEditMode():g.focus()):g.unselect();s(this,Tn).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==s(this,Ie)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(s(this,_n)){switch(t){case Mt.CREATE:this.currentLayer.addNewEditor(e);return;case Mt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(s(this,Gh)||p(this,Gh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const i of s(this,Yt))i.updateParams(t,e);else for(const i of s(this,_n))i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){var r;for(const o of s(this,xe).values())o.editorType===t&&o.show(e);(((r=s(this,Gh))==null?void 0:r.get(Mt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&A(this,q,Tr).call(this,[[Mt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(s(this,Wh)!==t){p(this,Wh,t);for(const e of s(this,Ue).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of s(this,xe).values())e.pageIndex===t&&(yield e)}getEditor(t){return s(this,xe).get(t)}addEditor(t){s(this,xe).set(t.id,t)}removeEditor(t){var e,i;t.div.contains(document.activeElement)&&(s(this,ls)&&clearTimeout(s(this,ls)),p(this,ls,setTimeout(()=>{this.focusMainContainer(),p(this,ls,null)},0))),s(this,xe).delete(t.id),t.annotationElementId&&((e=s(this,Kr))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!s(this,Vr).has(t.annotationElementId))&&((i=s(this,xn))==null||i.remove(t.id))}addDeletedAnnotationElement(t){s(this,Vr).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return s(this,Vr).has(t)}removeDeletedAnnotationElement(t){s(this,Vr).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){s(this,Xi)!==t&&(p(this,Xi,t),t&&A(this,q,Tr).call(this,t.propertiesToUpdate))}updateUI(t){s(this,q,Nv)===t&&A(this,q,Tr).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){A(this,q,Tr).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(s(this,Yt).has(t)){s(this,Yt).delete(t),t.unselect(),A(this,q,Mi).call(this,{hasSelectedEditor:this.hasSelection});return}s(this,Yt).add(t),t.select(),A(this,q,Tr).call(this,t.propertiesToUpdate),A(this,q,Mi).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=s(this,Wr))==null||e.commitOrRemove();for(const i of s(this,Yt))i!==t&&i.unselect();s(this,Yt).clear(),s(this,Yt).add(t),t.select(),A(this,q,Tr).call(this,t.propertiesToUpdate),A(this,q,Mi).call(this,{hasSelectedEditor:!0})}isSelected(t){return s(this,Yt).has(t)}get firstSelectedEditor(){return s(this,Yt).values().next().value}unselect(t){t.unselect(),s(this,Yt).delete(t),A(this,q,Mi).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return s(this,Yt).size!==0}get isEnterHandled(){return s(this,Yt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;s(this,Cn).undo(),A(this,q,Mi).call(this,{hasSomethingToUndo:s(this,Cn).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:A(this,q,Lu).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){s(this,Cn).redo(),A(this,q,Mi).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:s(this,Cn).hasSomethingToRedo(),isEmpty:A(this,q,Lu).call(this)})}addCommands(t){s(this,Cn).add(t),A(this,q,Mi).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:A(this,q,Lu).call(this)})}cleanUndoStack(t){s(this,Cn).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...s(this,Yt)],i=()=>{var o;(o=this._editorUndoBar)==null||o.show(n,e.length===1?e[0].editorType:e.length);for(const l of e)l.remove()},n=()=>{for(const o of e)A(this,q,$m).call(this,o)};this.addCommands({cmd:i,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=s(this,Xi))==null||t.commitOrRemove()}hasSomethingToControl(){return s(this,Xi)||this.hasSelection}selectAll(){for(const t of s(this,Yt))t.commit();A(this,q,Wm).call(this,s(this,xe).values())}unselectAll(){var t;if(!(s(this,Xi)&&(s(this,Xi).commitOrRemove(),s(this,Ie)!==mt.NONE))&&!((t=s(this,Wr))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of s(this,Yt))e.unselect();s(this,Yt).clear(),A(this,q,Mi).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;s(this,Qr)[0]+=t,s(this,Qr)[1]+=e;const[n,r]=s(this,Qr),o=[...s(this,Yt)],l=1e3;s(this,hs)&&clearTimeout(s(this,hs)),p(this,hs,setTimeout(()=>{p(this,hs,null),s(this,Qr)[0]=s(this,Qr)[1]=0,this.addCommands({cmd:()=>{for(const c of o)s(this,xe).has(c.id)&&(c.translateInPage(n,r),c.translationDone())},undo:()=>{for(const c of o)s(this,xe).has(c.id)&&(c.translateInPage(-n,-r),c.translationDone())},mustExec:!1})},l));for(const c of o)c.translateInPage(t,e),c.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),p(this,as,new Map);for(const t of s(this,Yt))s(this,as).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!s(this,as))return!1;this.disableUserSelect(!1);const t=s(this,as);p(this,as,null);let e=!1;for(const[{x:n,y:r,pageIndex:o},l]of t)l.newX=n,l.newY=r,l.newPageIndex=o,e||(e=n!==l.savedX||r!==l.savedY||o!==l.savedPageIndex);if(!e)return!1;const i=(n,r,o,l)=>{if(s(this,xe).has(n.id)){const c=s(this,Ue).get(l);c?n._setParentAndPosition(c,r,o):(n.pageIndex=l,n.x=r,n.y=o)}};return this.addCommands({cmd:()=>{for(const[n,{newX:r,newY:o,newPageIndex:l}]of t)i(n,r,o,l)},undo:()=>{for(const[n,{savedX:r,savedY:o,savedPageIndex:l}]of t)i(n,r,o,l)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(s(this,as))for(const i of s(this,as).keys())i.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||s(this,Yt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return s(this,Xi)===t}getActive(){return s(this,Xi)}getMode(){return s(this,Ie)}isEditingMode(){return s(this,Ie)!==mt.NONE}get imageManager(){return gt(this,"imageManager",new Vg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,d=e.rangeCount;h<d;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:i,y:n,width:r,height:o}=t.getBoundingClientRect();let l;switch(t.getAttribute("data-main-rotation")){case"90":l=(h,d,f,u)=>({x:(d-n)/o,y:1-(h+f-i)/r,width:u/o,height:f/r});break;case"180":l=(h,d,f,u)=>({x:1-(h+f-i)/r,y:1-(d+u-n)/o,width:f/r,height:u/o});break;case"270":l=(h,d,f,u)=>({x:1-(d+u-n)/o,y:(h-i)/r,width:u/o,height:f/r});break;default:l=(h,d,f,u)=>({x:(h-i)/r,y:(d-n)/o,width:f/r,height:u/o});break}const c=[];for(let h=0,d=e.rangeCount;h<d;h++){const f=e.getRangeAt(h);if(!f.collapsed)for(const{x:u,y:g,width:b,height:m}of f.getClientRects())b===0||m===0||c.push(l(u,g,b,m))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:t,id:e}){(s(this,Rl)||p(this,Rl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=s(this,Rl))==null||e.delete(t)}renderAnnotationElement(t){var n;const e=(n=s(this,Rl))==null?void 0:n.get(t.data.id);if(!e)return;const i=s(this,xn).getRawValue(e);i&&(s(this,Ie)===mt.NONE&&!i.hasBeenModified||i.renderAnnotationElement(t))}setMissingCanvas(t,e,i){var r;const n=(r=s(this,Kr))==null?void 0:r.get(t);n&&(n.setCanvas(e,i),s(this,Kr).delete(t))}addMissingCanvas(t,e){(s(this,Kr)||p(this,Kr,new Map)).set(t,e)}};Pl=new WeakMap,Xi=new WeakMap,kl=new WeakMap,xe=new WeakMap,Ue=new WeakMap,Ml=new WeakMap,xn=new WeakMap,Rl=new WeakMap,Cn=new WeakMap,mi=new WeakMap,$r=new WeakMap,Wr=new WeakMap,Dl=new WeakMap,Vr=new WeakMap,as=new WeakMap,_n=new WeakMap,Yo=new WeakMap,Uh=new WeakMap,Hh=new WeakMap,Ol=new WeakMap,$h=new WeakMap,ls=new WeakMap,Gr=new WeakMap,Il=new WeakMap,Yr=new WeakMap,cs=new WeakMap,Vf=new WeakMap,Xr=new WeakMap,Ll=new WeakMap,Wh=new WeakMap,qr=new WeakMap,Xo=new WeakMap,Nl=new WeakMap,Kr=new WeakMap,Vh=new WeakMap,Ie=new WeakMap,Yt=new WeakMap,Us=new WeakMap,Jr=new WeakMap,Zr=new WeakMap,Gh=new WeakMap,Fl=new WeakMap,Yh=new WeakMap,Qr=new WeakMap,hs=new WeakMap,Hs=new WeakMap,Xh=new WeakMap,qh=new WeakMap,Tn=new WeakMap,q=new WeakSet,vp=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Um=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of s(this,Ue).values())if(i.hasTextLayer(t))return i;return null},Cv=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const i=A(this,q,vp).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(i);n&&(s(this,cs)||p(this,cs,new iE(this)),s(this,cs).show(i,n,this.direction==="ltr"))},_v=function(){var r,o,l;const t=document.getSelection();if(!t||t.isCollapsed){s(this,Us)&&((r=s(this,cs))==null||r.hide(),p(this,Us,null),A(this,q,Mi).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===s(this,Us))return;const n=A(this,q,vp).call(this,t).closest(".textLayer");if(!n){s(this,Us)&&((o=s(this,cs))==null||o.hide(),p(this,Us,null),A(this,q,Mi).call(this,{hasSelectedText:!1}));return}if((l=s(this,cs))==null||l.hide(),p(this,Us,e),A(this,q,Mi).call(this,{hasSelectedText:!0}),!(s(this,Ie)!==mt.HIGHLIGHT&&s(this,Ie)!==mt.NONE)&&(s(this,Ie)===mt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),p(this,Yr,this.isShiftKeyDown),!this.isShiftKeyDown)){const c=s(this,Ie)===mt.HIGHLIGHT?A(this,q,Um).call(this,n):null;if(c==null||c.toggleDrawing(),s(this,Ll)){const h=new AbortController,d=this.combinedSignal(h),f=u=>{u.type==="pointerup"&&u.button!==0||(h.abort(),c==null||c.toggleDrawing(!0),u.type==="pointerup"&&A(this,q,Iu).call(this,"main_toolbar"))};window.addEventListener("pointerup",f,{signal:d}),window.addEventListener("blur",f,{signal:d})}else c==null||c.toggleDrawing(!0),A(this,q,Iu).call(this,"main_toolbar")}},Iu=function(t=""){s(this,Ie)===mt.HIGHLIGHT?this.highlightSelection(t):s(this,Uh)&&A(this,q,Cv).call(this)},Tv=function(){document.addEventListener("selectionchange",A(this,q,_v).bind(this),{signal:this._signal})},Pv=function(){if(s(this,Gr))return;p(this,Gr,new AbortController);const t=this.combinedSignal(s(this,Gr));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},kv=function(){var t;(t=s(this,Gr))==null||t.abort(),p(this,Gr,null)},Hm=function(){if(s(this,qr))return;p(this,qr,new AbortController);const t=this.combinedSignal(s(this,qr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Mv=function(){var t;(t=s(this,qr))==null||t.abort(),p(this,qr,null)},Rv=function(){if(s(this,$r))return;p(this,$r,new AbortController);const t=this.combinedSignal(s(this,$r));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})},Dv=function(){var t;(t=s(this,$r))==null||t.abort(),p(this,$r,null)},Ov=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Mi=function(t){Object.entries(t).some(([i,n])=>s(this,Yh)[i]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(s(this,Yh),t)}),s(this,Ie)===mt.HIGHLIGHT&&t.hasSelectedEditor===!1&&A(this,q,Tr).call(this,[[Mt.HIGHLIGHT_FREE,!0]]))},Tr=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Iv=async function(){if(!s(this,Xr)){p(this,Xr,!0);const t=[];for(const e of s(this,Ue).values())t.push(e.enable());await Promise.all(t);for(const e of s(this,xe).values())e.enable()}},Lv=function(){if(this.unselectAll(),s(this,Xr)){p(this,Xr,!1);for(const t of s(this,Ue).values())t.disable();for(const t of s(this,xe).values())t.disable()}},$m=function(t){const e=s(this,Ue).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Nv=function(){let t=null;for(t of s(this,Yt));return t},Lu=function(){if(s(this,xe).size===0)return!0;if(s(this,xe).size===1)for(const t of s(this,xe).values())return t.isEmpty();return!1},Wm=function(t){for(const e of s(this,Yt))e.unselect();s(this,Yt).clear();for(const e of t)e.isEmpty()||(s(this,Yt).add(e),e.select());A(this,q,Mi).call(this,{hasSelectedEditor:this.hasSelection})},$(Bl,"TRANSLATE_SMALL",1),$(Bl,"TRANSLATE_BIG",10);let jo=Bl;const xi=class xi{constructor(t){v(this,jn);v(this,Ke,null);v(this,ds,!1);v(this,Bn,null);v(this,jl,null);v(this,us,null);v(this,qi,null);v(this,zl,!1);v(this,fs,null);v(this,Ii,null);v(this,$s,null);v(this,qo,null);v(this,ps,!1);p(this,Ii,t),p(this,ps,t._uiManager.useNewAltTextFlow),s(xi,to)||p(xi,to,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){xi._l10n??(xi._l10n=t)}async render(){const t=p(this,Bn,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=p(this,jl,document.createElement("span"));t.append(e),s(this,ps)?(t.classList.add("new"),t.setAttribute("data-l10n-id",s(xi,to).missing),e.setAttribute("data-l10n-id",s(xi,to)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=s(this,Ii)._uiManager._signal;t.addEventListener("contextmenu",vn,{signal:i}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});const n=r=>{r.preventDefault(),s(this,Ii)._uiManager.editAltText(s(this,Ii)),s(this,ps)&&s(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:s(this,jn,Nu)}})};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,zl,!0),n(r))},{signal:i}),await A(this,jn,wp).call(this),t}finish(){s(this,Bn)&&(s(this,Bn).focus({focusVisible:s(this,zl)}),p(this,zl,!1))}isEmpty(){return s(this,ps)?s(this,Ke)===null:!s(this,Ke)&&!s(this,ds)}hasData(){return s(this,ps)?s(this,Ke)!==null||!!s(this,$s):this.isEmpty()}get guessedText(){return s(this,$s)}async setGuessedText(t){s(this,Ke)===null&&(p(this,$s,t),p(this,qo,await xi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),A(this,jn,wp).call(this))}toggleAltTextBadge(t=!1){var e;if(!s(this,ps)||s(this,Ke)){(e=s(this,fs))==null||e.remove(),p(this,fs,null);return}if(!s(this,fs)){const i=p(this,fs,document.createElement("div"));i.className="noAltTextBadge",s(this,Ii).div.append(i)}s(this,fs).classList.toggle("hidden",!t)}serialize(t){let e=s(this,Ke);return!t&&s(this,$s)===e&&(e=s(this,qo)),{altText:e,decorative:s(this,ds),guessedText:s(this,$s),textWithDisclaimer:s(this,qo)}}get data(){return{altText:s(this,Ke),decorative:s(this,ds)}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:n,cancel:r=!1}){i&&(p(this,$s,i),p(this,qo,n)),!(s(this,Ke)===t&&s(this,ds)===e)&&(r||(p(this,Ke,t),p(this,ds,e)),A(this,jn,wp).call(this))}toggle(t=!1){s(this,Bn)&&(!t&&s(this,qi)&&(clearTimeout(s(this,qi)),p(this,qi,null)),s(this,Bn).disabled=!t)}shown(){s(this,Ii)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:s(this,jn,Nu)}})}destroy(){var t,e;(t=s(this,Bn))==null||t.remove(),p(this,Bn,null),p(this,jl,null),p(this,us,null),(e=s(this,fs))==null||e.remove(),p(this,fs,null)}};Ke=new WeakMap,ds=new WeakMap,Bn=new WeakMap,jl=new WeakMap,us=new WeakMap,qi=new WeakMap,zl=new WeakMap,fs=new WeakMap,Ii=new WeakMap,$s=new WeakMap,qo=new WeakMap,ps=new WeakMap,to=new WeakMap,jn=new WeakSet,Nu=function(){return s(this,Ke)&&"added"||s(this,Ke)===null&&this.guessedText&&"review"||"missing"},wp=async function(){var n,r,o;const t=s(this,Bn);if(!t)return;if(s(this,ps)){if(t.classList.toggle("done",!!s(this,Ke)),t.setAttribute("data-l10n-id",s(xi,to)[s(this,jn,Nu)]),(n=s(this,jl))==null||n.setAttribute("data-l10n-id",s(xi,to)[`${s(this,jn,Nu)}-label`]),!s(this,Ke)){(r=s(this,us))==null||r.remove();return}}else{if(!s(this,Ke)&&!s(this,ds)){t.classList.remove("done"),(o=s(this,us))==null||o.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=s(this,us);if(!e){p(this,us,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${s(this,Ii).id}`;const l=100,c=s(this,Ii)._uiManager._signal;c.addEventListener("abort",()=>{clearTimeout(s(this,qi)),p(this,qi,null)},{once:!0}),t.addEventListener("mouseenter",()=>{p(this,qi,setTimeout(()=>{p(this,qi,null),s(this,us).classList.add("show"),s(this,Ii)._reportTelemetry({action:"alt_text_tooltip"})},l))},{signal:c}),t.addEventListener("mouseleave",()=>{var h;s(this,qi)&&(clearTimeout(s(this,qi)),p(this,qi,null)),(h=s(this,us))==null||h.classList.remove("show")},{signal:c})}s(this,ds)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=s(this,Ke)),e.parentNode||t.append(e);const i=s(this,Ii).getElementForAltText();i==null||i.setAttribute("aria-describedby",e.id)},v(xi,to,null),$(xi,"_l10n",null);let vf=xi;class wf{constructor(t){v(this,Jh);v(this,oi,null);v(this,Pn,null);v(this,Ko,!1);v(this,le,null);v(this,Kh,null);v(this,Jo,null);v(this,zn,null);v(this,Zo,null);v(this,Qo,!1);v(this,ta,null);p(this,le,t)}renderForToolbar(){const t=p(this,Pn,document.createElement("button"));return t.className="comment",A(this,Jh,Vm).call(this,t,!1)}renderForStandalone(){const t=p(this,oi,document.createElement("button"));t.className="annotationCommentButton";const e=s(this,le).commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*(s(this,le)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=s(this,le).commentButtonColor;n&&(i.backgroundColor=n)}return A(this,Jh,Vm).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=s(this,oi)??s(this,Pn))==null||t.focus()},0)}onUpdatedColor(){if(!s(this,oi))return;const t=s(this,le).commentButtonColor;t&&(s(this,oi).style.backgroundColor=t),s(this,le)._uiManager.updatePopupColor(s(this,le))}get commentButtonWidth(){var t;return(((t=s(this,oi))==null?void 0:t.getBoundingClientRect().width)??0)/s(this,le).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(s(this,ta))return s(this,ta);if(!s(this,oi))return null;const{x:t,y:e,height:i}=s(this,oi).getBoundingClientRect(),{x:n,y:r,width:o,height:l}=s(this,le).parent.boundingClientRect;return[(t-n)/o,(e+i-r)/l]}set commentPopupPositionInLayer(t){p(this,ta,t)}hasDefaultPopupPosition(){return s(this,ta)===null}removeStandaloneCommentButton(){var t;(t=s(this,oi))==null||t.remove(),p(this,oi,null)}removeToolbarCommentButton(){var t;(t=s(this,Pn))==null||t.remove(),p(this,Pn,null)}setCommentButtonStates({selected:t,hasPopup:e}){s(this,oi)&&(s(this,oi).classList.toggle("selected",t),s(this,oi).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let i,n;if(e)[i,n]=e;else{[i,n]=s(this,le).commentButtonPosition;const{width:d,height:f,x:u,y:g}=s(this,le);i=u+i*d,n=g+n*f}const r=s(this,le).parent.boundingClientRect,{x:o,y:l,width:c,height:h}=r;s(this,le)._uiManager.editComment(s(this,le),o+i*c,l+n*h,{...t,parentDimensions:r})}finish(){s(this,Pn)&&(s(this,Pn).focus({focusVisible:s(this,Ko)}),p(this,Ko,!1))}isDeleted(){return s(this,Qo)||s(this,zn)===""}isEmpty(){return s(this,zn)===null}hasBeenEdited(){return this.isDeleted()||s(this,zn)!==s(this,Kh)}serialize(){return this.data}get data(){return{text:s(this,zn),richText:s(this,Jo),date:s(this,Zo),deleted:this.isDeleted()}}set data(t){if(t!==s(this,zn)&&p(this,Jo,null),t===null){p(this,zn,""),p(this,Qo,!0);return}p(this,zn,t),p(this,Zo,new Date),p(this,Qo,!1)}setInitialText(t,e=null){p(this,Kh,t),this.data=t,p(this,Zo,null),p(this,Jo,e)}shown(){}destroy(){var t,e;(t=s(this,Pn))==null||t.remove(),p(this,Pn,null),(e=s(this,oi))==null||e.remove(),p(this,oi,null),p(this,zn,""),p(this,Jo,null),p(this,Zo,null),p(this,le,null),p(this,Ko,!1),p(this,Qo,!1)}}oi=new WeakMap,Pn=new WeakMap,Ko=new WeakMap,le=new WeakMap,Kh=new WeakMap,Jo=new WeakMap,zn=new WeakMap,Zo=new WeakMap,Qo=new WeakMap,ta=new WeakMap,Jh=new WeakSet,Vm=function(t,e){if(!s(this,le)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[s(this,le)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=s(this,le)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",vn,{signal:i}),e&&(t.addEventListener("focusin",r=>{s(this,le)._focusEventsAllowed=!1,Ee(r)},{capture:!0,signal:i}),t.addEventListener("focusout",r=>{s(this,le)._focusEventsAllowed=!0,Ee(r)},{capture:!0,signal:i})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});const n=r=>{r.preventDefault(),t===s(this,Pn)?this.edit():s(this,le).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(p(this,Ko,!0),n(r))},{signal:i}),t.addEventListener("pointerenter",()=>{s(this,le).toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{s(this,le).toggleComment(!1,!1)},{signal:i}),t};const Tm=class Tm{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:r=null,onPinchEnd:o=null,signal:l}){v(this,eo);v(this,Ul);v(this,ea,!1);v(this,Zh,null);v(this,Qh);v(this,td);v(this,ed);v(this,id);v(this,Ws,null);v(this,ia);v(this,Vs,null);v(this,na);v(this,Gs,null);p(this,Ul,t),p(this,Zh,i),p(this,Qh,e),p(this,td,n),p(this,ed,r),p(this,id,o),p(this,na,new AbortController),p(this,ia,AbortSignal.any([l,s(this,na).signal])),t.addEventListener("touchstart",A(this,eo,Fv).bind(this),{passive:!1,signal:s(this,ia)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ss.pixelRatio}destroy(){var t,e;(t=s(this,na))==null||t.abort(),p(this,na,null),(e=s(this,Ws))==null||e.abort(),p(this,Ws,null)}};Ul=new WeakMap,ea=new WeakMap,Zh=new WeakMap,Qh=new WeakMap,td=new WeakMap,ed=new WeakMap,id=new WeakMap,Ws=new WeakMap,ia=new WeakMap,Vs=new WeakMap,na=new WeakMap,Gs=new WeakMap,eo=new WeakSet,Fv=function(t){var n,r,o;if((n=s(this,Qh))!=null&&n.call(this))return;if(t.touches.length===1){if(s(this,Ws))return;const l=p(this,Ws,new AbortController),c=AbortSignal.any([s(this,ia),l.signal]),h=s(this,Ul),d={capture:!0,signal:c,passive:!1},f=u=>{var g;u.pointerType==="touch"&&((g=s(this,Ws))==null||g.abort(),p(this,Ws,null))};h.addEventListener("pointerdown",u=>{u.pointerType==="touch"&&(Ee(u),f(u))},d),h.addEventListener("pointerup",f,d),h.addEventListener("pointercancel",f,d);return}if(!s(this,Gs)){p(this,Gs,new AbortController);const l=AbortSignal.any([s(this,ia),s(this,Gs).signal]),c=s(this,Ul),h={signal:l,capture:!1,passive:!1};c.addEventListener("touchmove",A(this,eo,Bv).bind(this),h);const d=A(this,eo,jv).bind(this);c.addEventListener("touchend",d,h),c.addEventListener("touchcancel",d,h),h.capture=!0,c.addEventListener("pointerdown",Ee,h),c.addEventListener("pointermove",Ee,h),c.addEventListener("pointercancel",Ee,h),c.addEventListener("pointerup",Ee,h),(r=s(this,td))==null||r.call(this)}if(Ee(t),t.touches.length!==2||(o=s(this,Zh))!=null&&o.call(this)){p(this,Vs,null);return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),p(this,Vs,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY})},Bv=function(t){var _;if(!s(this,Vs)||t.touches.length!==2)return;Ee(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:n,screenY:r}=e,{screenX:o,screenY:l}=i,c=s(this,Vs),{touch0X:h,touch0Y:d,touch1X:f,touch1Y:u}=c,g=f-h,b=u-d,m=o-n,w=l-r,y=Math.hypot(m,w)||1,x=Math.hypot(g,b)||1;if(!s(this,ea)&&Math.abs(x-y)<=Tm.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=n,c.touch0Y=r,c.touch1X=o,c.touch1Y=l,!s(this,ea)){p(this,ea,!0);return}const E=[(n+o)/2,(r+l)/2];(_=s(this,ed))==null||_.call(this,E,x,y)},jv=function(t){var e;t.touches.length>=2||(s(this,Gs)&&(s(this,Gs).abort(),p(this,Gs,null),(e=s(this,id))==null||e.call(this)),s(this,Vs)&&(Ee(t),p(this,Vs,null),p(this,ea,!1)))};let Af=Tm;const bt=class bt{constructor(t){v(this,ht);v(this,sa,null);v(this,Un,null);v(this,ge,null);v(this,ne,null);v(this,Ys,null);v(this,Hl,!1);v(this,io,null);v(this,nd,"");v(this,ai,null);v(this,ra,null);v(this,Xs,null);v(this,kn,null);v(this,no,null);v(this,sd,"");v(this,oa,!1);v(this,Ki,null);v(this,rd,!1);v(this,aa,!1);v(this,qs,!1);v(this,gs,null);v(this,$l,0);v(this,Wl,0);v(this,Mn,null);v(this,la,null);$(this,"isSelected",!1);$(this,"_isCopy",!1);$(this,"_editToolbar",null);$(this,"_initialOptions",Object.create(null));$(this,"_initialData",null);$(this,"_isVisible",!0);$(this,"_uiManager",null);$(this,"_focusEventsAllowed",!0);v(this,od,!1);v(this,Gf,bt._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[r,o];const[l,c]=this.parentDimensions;this.x=t.x/l,this.y=t.y/c,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=bt.prototype._resizeWithKeyboard,e=jo.TRANSLATE_SMALL,i=jo.TRANSLATE_BIG;return gt(this,"_resizerKeyboardManager",new Ch([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],bt.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 gt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new rE({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(bt._l10n??(bt._l10n=t),bt._l10nResizer||(bt._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"})),bt._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);bt._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ie("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return s(this,od)}set _isDraggable(t){var e;p(this,od,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=s(this,Gf)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(A(this,ht,Fu).call(this),(e=s(this,kn))==null||e.remove(),p(this,kn,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(s(this,oa)?p(this,oa,!1):this.parent.setSelected(this))}focusout(t){var i;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(i=this.parent)!=null&&i.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[r,o]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/r,this.y=(e+n)/o,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n),this._onTranslated()}translate(t,e){A(this,ht,Gm).call(this,this.parentDimensions,t,e)}translateInPage(t,e){s(this,Ki)||p(this,Ki,[this.x,this.y,this.width,this.height]),A(this,ht,Gm).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){s(this,Ki)||p(this,Ki,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[n,r]}=this;if(this.x+=t/n,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:f,y:u}=this.div.getBoundingClientRect();this.parent.findNewParent(this,f,u)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:l}=this;const[c,h]=this.getBaseTranslation();o+=c,l+=h;const{style:d}=i;d.left=`${(100*o).toFixed(2)}%`,d.top=`${(100*l).toFixed(2)}%`,this._onTranslating(o,l),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!s(this,Ki)&&(s(this,Ki)[0]!==this.x||s(this,Ki)[1]!==this.y)}get _hasBeenResized(){return!!s(this,Ki)&&(s(this,Ki)[2]!==this.width||s(this,Ki)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=bt,n=i/t,r=i/e;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:r,y:o,width:l,height:c}=this;if(l*=i,c*=n,r*=i,o*=n,this._mustFixPosition)switch(t){case 0:r=Ei(r,0,i-l),o=Ei(o,0,n-c);break;case 90:r=Ei(r,0,i-c),o=Ei(o,l,n);break;case 180:r=Ei(r,l,i),o=Ei(o,c,n);break;case 270:r=Ei(r,c,i),o=Ei(o,0,n-l);break}this.x=r/=i,this.y=o/=n;const[h,d]=this.getBaseTranslation();r+=h,o+=d,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var i;return A(i=bt,ad,Ym).call(i,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var i;return A(i=bt,ad,Ym).call(i,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=s(this,ge))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||s(this,aa))return this._editToolbar;this._editToolbar=new Wg(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=s(this,ge))==null||e.destroy()}addContainer(t){var i;const e=(i=this._editToolbar)==null?void 0:i.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return s(this,ge)||(vf.initialize(bt._l10n),p(this,ge,new vf(this)),s(this,sa)&&(s(this,ge).data=s(this,sa),p(this,sa,null))),s(this,ge)}get altTextData(){var t;return(t=s(this,ge))==null?void 0:t.data}set altTextData(t){s(this,ge)&&(s(this,ge).data=t)}get guessedAltText(){var t;return(t=s(this,ge))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=s(this,ge))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=s(this,ge))==null?void 0:e.serialize(t)}hasAltText(){return!!s(this,ge)&&!s(this,ge).isEmpty()}hasAltTextData(){var t;return((t=s(this,ge))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=s(this,ne))==null||t.focusButton()}addCommentButton(){return this.canAddComment?s(this,ne)||p(this,ne,new wf(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(s(this,Ys)){this._uiManager.isEditingMode()&&s(this,Ys).classList.remove("hidden");return}this.hasComment&&(p(this,Ys,s(this,ne).renderForStandalone()),this.div.append(s(this,Ys)))}}removeStandaloneCommentButton(){s(this,ne).removeStandaloneCommentButton(),p(this,Ys,null)}hideStandaloneCommentButton(){var t;(t=s(this,Ys))==null||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:i,deleted:n}}=s(this,ne);return{text:e,richText:t,date:i,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){s(this,ne)||p(this,ne,new wf(this)),s(this,ne).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(s(this,ne)||p(this,ne,new wf(this)),s(this,ne).setInitialText(t,i),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){var t;return(t=s(this,ne))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=s(this,ne))==null?void 0:t.isDeleted()}get hasComment(){return!!s(this,ne)&&!s(this,ne).isEmpty()&&!s(this,ne).isDeleted()}async editComment(t){s(this,ne)||p(this,ne,new wf(this)),s(this,ne).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){s(this,ne).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,n]=t.rect,[r]=this.pageDimensions,[o]=this.pageTranslation,l=o+r+1,c=n-100,h=l+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[l,c,h,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){s(this,ne).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var o;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=s(this,Hl)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),A(this,ht,Jm).call(this);const[e,i]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),y0(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(s(this,la)||p(this,la,new Af({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:A(this,ht,Hv).bind(this),onPinching:A(this,ht,$v).bind(this),onPinchEnd:A(this,ht,Wv).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(o=this._uiManager._editorUndoBar)==null||o.hide(),t}pointerdown(t){const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(p(this,oa,!0),this._isDraggable){A(this,ht,Vv).call(this,t);return}A(this,ht,Km).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){s(this,gs)&&clearTimeout(s(this,gs)),p(this,gs,setTimeout(()=>{var t;p(this,gs,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const n=this.parentScale,[r,o]=this.pageDimensions,[l,c]=this.pageTranslation,h=t/n,d=e/n,f=this.x*r,u=this.y*o,g=this.width*r,b=this.height*o;switch(i){case 0:return[f+h+l,o-u-d-b+c,f+h+g+l,o-u-d+c];case 90:return[f+d+l,o-u+h+c,f+d+b+l,o-u+h+g+c];case 180:return[f-h-g+l,o-u+d+c,f-h+l,o-u+d+b+c];case 270:return[f-d-b+l,o-u-h-g+c,f-d+l,o-u-h+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,n,r,o]=t,l=r-i,c=o-n;switch(this.rotation){case 0:return[i,e-o,l,c];case 90:return[i,e-n,c,l];case 180:return[r,e-n,l,c];case 270:return[r,e-o,c,l];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&bt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=s(this,ne))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:n,deleted:r,richText:o},uid:l,pageIndex:c,creationDate:h,modificationDate:d}=this;return{id:l,pageIndex:c,rect:this.getPDFRect(),richText:o,contentsObj:{str:t},creationDate:h,modificationDate:i||d,popupRef:!r,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),p(this,aa,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),p(this,aa,!1),!0):!1}isInEditMode(){return s(this,aa)}shouldGetKeyboardEvents(){return s(this,qs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:r,innerWidth:o}=window;return e<o&&n>0&&t<r&&i>0}rebuild(){A(this,ht,Jm).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var i;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((i=this._initialData)==null?void 0:i.popupRef)||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,p(n,sa,t.accessibilityData),n._isCopy=t.isCopy||!1;const[r,o]=n.pageDimensions,[l,c,h,d]=n.getRectInCurrentCoords(t.rect,o);return n.x=l/r,n.y=c/o,n.width=h/r,n.height=d/o,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,i;if((t=s(this,no))==null||t.abort(),p(this,no,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),s(this,gs)&&(clearTimeout(s(this,gs)),p(this,gs,null)),A(this,ht,Fu).call(this),this.removeEditToolbar(),s(this,Mn)){for(const n of s(this,Mn).values())clearTimeout(n);p(this,Mn,null)}this.parent=null,(e=s(this,la))==null||e.destroy(),p(this,la,null),(i=s(this,kn))==null||i.remove(),p(this,kn,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(A(this,ht,zv).call(this),s(this,ai).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,r,o]=this.getPDFRect();return[bt._round(i+(r-i)*t),bt._round(n+(o-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return s(this,ne).commentPopupPositionInLayer}set commentPopupPosition(t){s(this,ne).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return s(this,ne).hasDefaultPopupPosition()}get commentButtonWidth(){return s(this,ne).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=s(this,ne))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),p(this,Xs,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=s(this,ai).children;if(!s(this,Un)){p(this,Un,Array.from(e));const o=A(this,ht,Gv).bind(this),l=A(this,ht,Yv).bind(this),c=this._uiManager._signal;for(const h of s(this,Un)){const d=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",o,{signal:c}),h.addEventListener("blur",l,{signal:c}),h.addEventListener("focus",A(this,ht,Xv).bind(this,d),{signal:c}),h.setAttribute("data-l10n-id",bt._l10nResizer[d])}}const i=s(this,Un)[0];let n=0;for(const o of e){if(o===i)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(s(this,Un).length/4);if(r!==n){if(r<n)for(let l=0;l<n-r;l++)s(this,ai).append(s(this,ai).firstElementChild);else if(r>n)for(let l=0;l<r-n;l++)s(this,ai).firstElementChild.before(s(this,ai).lastElementChild);let o=0;for(const l of e){const h=s(this,Un)[o++].getAttribute("data-resizer-name");l.setAttribute("data-l10n-id",bt._l10nResizer[h])}}A(this,ht,Zm).call(this,0),p(this,qs,!0),s(this,ai).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){s(this,qs)&&A(this,ht,qm).call(this,s(this,sd),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){A(this,ht,Fu).call(this),this.div.focus()}select(){var t,e,i;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var n,r;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(i=s(this,ge))==null||i.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,i,n,r;this.isSelected&&(this.isSelected=!1,(t=s(this,ai))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(i=this.div)!=null&&i.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(n=this._editToolbar)==null||n.hide(),(r=s(this,ge))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return s(this,rd)}set isEditing(t){p(this,rd,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){s(this,Mn)||p(this,Mn,new Map);const{action:i}=t;let n=s(this,Mn).get(i);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),s(this,Mn).delete(i),s(this,Mn).size===0&&p(this,Mn,null)},bt._telemetryTimeout),s(this,Mn).set(i,n);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),p(this,Hl,!1)}disable(){this.div&&(this.div.tabIndex=-1),p(this,Hl,!0)}updateFakeAnnotationElement(t){if(!s(this,kn)&&!this.deleted){p(this,kn,t.addFakeAnnotation(this));return}if(this.deleted){s(this,kn).remove(),p(this,kn,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&s(this,kn).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const i=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),i.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};sa=new WeakMap,Un=new WeakMap,ge=new WeakMap,ne=new WeakMap,Ys=new WeakMap,Hl=new WeakMap,io=new WeakMap,nd=new WeakMap,ai=new WeakMap,ra=new WeakMap,Xs=new WeakMap,kn=new WeakMap,no=new WeakMap,sd=new WeakMap,oa=new WeakMap,Ki=new WeakMap,rd=new WeakMap,aa=new WeakMap,qs=new WeakMap,gs=new WeakMap,$l=new WeakMap,Wl=new WeakMap,Mn=new WeakMap,la=new WeakMap,od=new WeakMap,Gf=new WeakMap,ht=new WeakSet,Gm=function([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},ad=new WeakSet,Ym=function(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Ap=function(t){switch(t){case 90:{const[e,i]=this.pageDimensions;return[0,-e/i,i/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,i]=this.pageDimensions;return[0,e/i,-i/e,0]}default:return[1,0,0,1]}},zv=function(){if(s(this,ai))return;p(this,ai,document.createElement("div")),s(this,ai).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const n=document.createElement("div");s(this,ai).append(n),n.classList.add("resizer",i),n.setAttribute("data-resizer-name",i),n.addEventListener("pointerdown",A(this,ht,Uv).bind(this,i),{signal:e}),n.addEventListener("contextmenu",vn,{signal:e}),n.tabIndex=-1}this.div.prepend(s(this,ai))},Uv=function(t,e){var d;e.preventDefault();const{isMac:i}=ze.platform;if(e.button!==0||e.ctrlKey&&i)return;(d=s(this,ge))==null||d.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,p(this,ra,[e.screenX,e.screenY]);const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",A(this,ht,qm).bind(this,t),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",Ee,{passive:!1,signal:o}),window.addEventListener("contextmenu",vn,{signal:o}),p(this,Xs,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const l=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var f;r.abort(),this.parent.togglePointerEvents(!0),(f=s(this,ge))==null||f.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=l,this.div.style.cursor=c,A(this,ht,Sp).call(this)};window.addEventListener("pointerup",h,{signal:o}),window.addEventListener("blur",h,{signal:o})},Xm=function(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Sp=function(){if(!s(this,Xs))return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=s(this,Xs);p(this,Xs,null);const r=this.x,o=this.y,l=this.width,c=this.height;r===t&&o===e&&l===i&&c===n||this.addCommands({cmd:A(this,ht,Xm).bind(this,r,o,l,c),undo:A(this,ht,Xm).bind(this,t,e,i,n),mustExec:!0})},qm=function(t,e){const[i,n]=this.parentDimensions,r=this.x,o=this.y,l=this.width,c=this.height,h=bt.MIN_SIZE/i,d=bt.MIN_SIZE/n,f=A(this,ht,Ap).call(this,this.rotation),u=(tt,J)=>[f[0]*tt+f[2]*J,f[1]*tt+f[3]*J],g=A(this,ht,Ap).call(this,360-this.rotation),b=(tt,J)=>[g[0]*tt+g[2]*J,g[1]*tt+g[3]*J];let m,w,y=!1,x=!1;switch(t){case"topLeft":y=!0,m=(tt,J)=>[0,0],w=(tt,J)=>[tt,J];break;case"topMiddle":m=(tt,J)=>[tt/2,0],w=(tt,J)=>[tt/2,J];break;case"topRight":y=!0,m=(tt,J)=>[tt,0],w=(tt,J)=>[0,J];break;case"middleRight":x=!0,m=(tt,J)=>[tt,J/2],w=(tt,J)=>[0,J/2];break;case"bottomRight":y=!0,m=(tt,J)=>[tt,J],w=(tt,J)=>[0,0];break;case"bottomMiddle":m=(tt,J)=>[tt/2,J],w=(tt,J)=>[tt/2,0];break;case"bottomLeft":y=!0,m=(tt,J)=>[0,J],w=(tt,J)=>[tt,0];break;case"middleLeft":x=!0,m=(tt,J)=>[0,J/2],w=(tt,J)=>[tt,J/2];break}const E=m(l,c),_=w(l,c);let C=u(..._);const T=bt._round(r+C[0]),D=bt._round(o+C[1]);let j=1,O=1,H,N;if(e.fromKeyboard)({deltaX:H,deltaY:N}=e);else{const{screenX:tt,screenY:J}=e,[ct,Dt]=s(this,ra);[H,N]=this.screenToPageTranslation(tt-ct,J-Dt),s(this,ra)[0]=tt,s(this,ra)[1]=J}if([H,N]=b(H/i,N/n),y){const tt=Math.hypot(l,c);j=O=Math.max(Math.min(Math.hypot(_[0]-E[0]-H,_[1]-E[1]-N)/tt,1/l,1/c),h/l,d/c)}else x?j=Ei(Math.abs(_[0]-E[0]-H),h,1)/l:O=Ei(Math.abs(_[1]-E[1]-N),d,1)/c;const lt=bt._round(l*j),G=bt._round(c*O);C=u(...w(lt,G));const K=T-C[0],rt=D-C[1];s(this,Ki)||p(this,Ki,[this.x,this.y,this.width,this.height]),this.width=lt,this.height=G,this.x=K,this.y=rt,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Hv=function(){var t;p(this,Xs,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=s(this,ge))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},$v=function(t,e,i){let r=.7*(i/e)+1-.7;if(r===1)return;const o=A(this,ht,Ap).call(this,this.rotation),l=(T,D)=>[o[0]*T+o[2]*D,o[1]*T+o[3]*D],[c,h]=this.parentDimensions,d=this.x,f=this.y,u=this.width,g=this.height,b=bt.MIN_SIZE/c,m=bt.MIN_SIZE/h;r=Math.max(Math.min(r,1/u,1/g),b/u,m/g);const w=bt._round(u*r),y=bt._round(g*r);if(w===u&&y===g)return;s(this,Ki)||p(this,Ki,[d,f,u,g]);const x=l(u/2,g/2),E=bt._round(d+x[0]),_=bt._round(f+x[1]),C=l(w/2,y/2);this.x=E-C[0],this.y=_-C[1],this.width=w,this.height=y,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Wv=function(){var t;(t=s(this,ge))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),A(this,ht,Sp).call(this)},Km=function(t){const{isMac:e}=ze.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Vv=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,r=this._uiManager.combinedSignal(n),o={capture:!0,passive:!1,signal:r},l=h=>{n.abort(),p(this,io,null),p(this,oa,!1),this._uiManager.endDragSession()||A(this,ht,Km).call(this,h),i&&this._onStopDragging()};e&&(p(this,$l,t.clientX),p(this,Wl,t.clientY),p(this,io,t.pointerId),p(this,nd,t.pointerType),window.addEventListener("pointermove",h=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:d,clientY:f,pointerId:u}=h;if(u!==s(this,io)){Ee(h);return}const[g,b]=this.screenToPageTranslation(d-s(this,$l),f-s(this,Wl));p(this,$l,d),p(this,Wl,f),this._uiManager.dragSelectedEditors(g,b)},o),window.addEventListener("touchmove",Ee,o),window.addEventListener("pointerdown",h=>{h.pointerType===s(this,nd)&&(s(this,la)||h.isPrimary)&&l(h),Ee(h)},o));const c=h=>{if(!s(this,io)||s(this,io)===h.pointerId){l(h);return}Ee(h)};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})},Jm=function(){if(s(this,no)||!this.div)return;p(this,no,new AbortController);const t=this._uiManager.combinedSignal(s(this,no));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Gv=function(t){bt._resizerKeyboardManager.exec(this,t)},Yv=function(t){var e;s(this,qs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==s(this,ai)&&A(this,ht,Fu).call(this)},Xv=function(t){p(this,sd,s(this,qs)?t:"")},Zm=function(t){if(s(this,Un))for(const e of s(this,Un))e.tabIndex=t},Fu=function(){p(this,qs,!1),A(this,ht,Zm).call(this,-1),A(this,ht,Sp).call(this)},v(bt,ad),$(bt,"_l10n",null),$(bt,"_l10nResizer",null),$(bt,"_borderLineWidth",-1),$(bt,"_colorManager",new Gg),$(bt,"_zIndex",1),$(bt,"_telemetryTimeout",1e3);let ae=bt;class rE extends ae{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const v0=3285377520,wn=4294901760,rs=65535;class w0{constructor(t){this.h1=t?t&4294967295:v0,this.h2=t?t&4294967295:v0}update(t){let e,i;if(typeof t=="string"){e=new Uint8Array(t.length*2),i=0;for(let m=0,w=t.length;m<w;m++){const y=t.charCodeAt(m);y<=255?e[i++]=y:(e[i++]=y>>>8,e[i++]=y&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),i=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=i>>2,r=i-n*4,o=new Uint32Array(e.buffer,0,n);let l=0,c=0,h=this.h1,d=this.h2;const f=3432918353,u=461845907,g=f&rs,b=u&rs;for(let m=0;m<n;m++)m&1?(l=o[m],l=l*f&wn|l*g&rs,l=l<<15|l>>>17,l=l*u&wn|l*b&rs,h^=l,h=h<<13|h>>>19,h=h*5+3864292196):(c=o[m],c=c*f&wn|c*g&rs,c=c<<15|c>>>17,c=c*u&wn|c*b&rs,d^=c,d=d<<13|d>>>19,d=d*5+3864292196);switch(l=0,r){case 3:l^=e[n*4+2]<<16;case 2:l^=e[n*4+1]<<8;case 1:l^=e[n*4],l=l*f&wn|l*g&rs,l=l<<15|l>>>17,l=l*u&wn|l*b&rs,n&1?h^=l:d^=l}this.h1=h,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&wn|t*36045&rs,e=e*4283543511&wn|((e<<16|t>>>16)*2950163797&wn)>>>16,t^=e>>>1,t=t*444984403&wn|t*60499&rs,e=e*3301882366&wn|((e<<16|t>>>16)*3120437893&wn)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Yg=Object.freeze({map:null,hash:"",transfer:void 0});class Xg{constructor(){v(this,Yf);v(this,ca,!1);v(this,ha,null);v(this,Ks,null);v(this,li,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=s(this,li).get(t);return i===void 0?e:Object.assign(e,i)}getRawValue(t){return s(this,li).get(t)}remove(t){const e=s(this,li).get(t);if(e!==void 0&&(e instanceof ae&&s(this,Ks).delete(e.annotationElementId),s(this,li).delete(t),s(this,li).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const i of s(this,li).values())if(i instanceof ae)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=s(this,li).get(t);let n=!1;if(i!==void 0)for(const[r,o]of Object.entries(e))i[r]!==o&&(n=!0,i[r]=o);else n=!0,s(this,li).set(t,e);n&&A(this,Yf,qv).call(this),e instanceof ae&&((s(this,Ks)||p(this,Ks,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return s(this,li).has(t)}get size(){return s(this,li).size}resetModified(){s(this,ca)&&(p(this,ca,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new A0(this)}get serializable(){if(s(this,li).size===0)return Yg;const t=new Map,e=new w0,i=[],n=Object.create(null);let r=!1;for(const[o,l]of s(this,li)){const c=l instanceof ae?l.serialize(!1,n):l;c&&(t.set(o,c),e.update(`${o}:${JSON.stringify(c)}`),r||(r=!!c.bitmap))}if(r)for(const o of t.values())o.bitmap&&i.push(o.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Yg}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const r of s(this,li).values()){if(!(r instanceof ae)){r.popup&&(r.popup.deleted?n+=1:i+=1);continue}r.isCommentDeleted?n+=1:r.hasEditedComment&&(i+=1);const o=r.telemetryFinalData;if(!o)continue;const{type:l}=o;e.has(l)||e.set(l,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const c=t[l]||(t[l]=new Map);for(const[h,d]of Object.entries(o)){if(h==="type")continue;let f=c.get(h);f||(f=new Map,c.set(h,f));const u=f.get(d)??0;f.set(d,u+1)}}if((n>0||i>0)&&(t||(t=Object.create(null)),t.comments={deleted:n,edited:i}),!t)return null;for(const[r,o]of e)t[r]=o.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){p(this,ha,null)}updateEditor(t,e){var n;const i=(n=s(this,Ks))==null?void 0:n.get(t);return i?(i.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=s(this,Ks))==null?void 0:e.get(t))||null}get modifiedIds(){if(s(this,ha))return s(this,ha);const t=[];if(s(this,Ks))for(const e of s(this,Ks).values())e.serialize()&&t.push(e.annotationElementId);return p(this,ha,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return s(this,li).entries()}}ca=new WeakMap,ha=new WeakMap,Ks=new WeakMap,li=new WeakMap,Yf=new WeakSet,qv=function(){s(this,ca)||(p(this,ca,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class A0 extends Xg{constructor(e){super();v(this,ld);const{map:i,hash:n,transfer:r}=e.serializable,o=structuredClone(i,r?{transfer:r}:null);p(this,ld,{map:o,hash:n,transfer:r})}get print(){ie("Should not call PrintAnnotationStorage.print")}get serializable(){return s(this,ld)}get modifiedIds(){return gt(this,"modifiedIds",{ids:new Set,hash:""})}}ld=new WeakMap;class oE{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){v(this,Vl,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(),s(this,Vl).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||s(this,Vl).has(t.loadedName))){if(Rt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:o}=t,l=new FontFace(n,r,o);this.addNativeFontFace(l);try{await l.load(),s(this,Vl).add(n),i==null||i(t)}catch{pt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}ie("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const i=t.createNativeFontFace();if(i){this.addNativeFontFace(i);try{await i.loaded}catch(n){throw pt(`Failed to load font '${i.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(i=>{const n=this._queueLoadingCallback(i);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return gt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return gt(this,"isSyncFontLoadingSupported",Si||ze.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Rt(!n.done,"completeRequest() cannot be called twice."),n.done=!0;i.length>0&&i[0].done;){const r=i.shift();setTimeout(r.callback,0)}}const{loadingRequests:i}=this,n={done:!1,complete:e,callback:t};return i.push(n),n}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return gt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function i(_,C){return _.charCodeAt(C)<<24|_.charCodeAt(C+1)<<16|_.charCodeAt(C+2)<<8|_.charCodeAt(C+3)&255}function n(_,C,T,D){const j=_.substring(0,C),O=_.substring(C+T);return j+D+O}let r,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;function d(_,C){if(++h>30){pt("Load test font never loaded."),C();return}if(c.font="30px "+_,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){C();return}setTimeout(d.bind(null,_,C))}const f=`lt${Date.now()}${this.loadTestFontId++}`;let u=this._loadTestFont;u=n(u,976,f.length,f);const b=16,m=1482184792;let w=i(u,b);for(r=0,o=f.length-3;r<o;r+=4)w=w-m+i(f,r)|0;r<f.length&&(w=w-m+i(f+"XXX",r)|0),u=n(u,b,4,zS(w));const y=`url(data:font/opentype;base64,${btoa(u)});`,x=`@font-face {font-family:"${f}";src:${y}}`;this.insertRule(x);const E=this._document.createElement("div");E.style.visibility="hidden",E.style.width=E.style.height="10px",E.style.position="absolute",E.style.top=E.style.left="0px";for(const _ of[t.loadedName,f]){const C=this._document.createElement("span");C.textContent="Hi",C.style.fontFamily=_,E.append(C)}this._document.body.append(E),d(f,()=>{E.remove(),e.complete()})}}Vl=new WeakMap;class aE{constructor(t,e=null,i,n){v(this,Kt);this.compiledGlyphs=Object.create(null),p(this,Kt,t),this._inspectFont=e,i&&Object.assign(this,i),n&&(this.charProcOperatorList=n)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,i)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var i;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${c0(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(i=this._inspectFont)==null||i.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(o){pt(`getPathGenerator - ignoring character: "${o}".`)}const r=b0(n==null?void 0:n.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=r}get black(){return s(this,Kt).black}get bold(){return s(this,Kt).bold}get disableFontFace(){return s(this,Kt).disableFontFace??!1}set disableFontFace(t){gt(this,"disableFontFace",!!t)}get fontExtraProperties(){return s(this,Kt).fontExtraProperties??!1}get isInvalidPDFjsFont(){return s(this,Kt).isInvalidPDFjsFont}get isType3Font(){return s(this,Kt).isType3Font}get italic(){return s(this,Kt).italic}get missingFile(){return s(this,Kt).missingFile}get remeasure(){return s(this,Kt).remeasure}get vertical(){return s(this,Kt).vertical}get ascent(){return s(this,Kt).ascent}get defaultWidth(){return s(this,Kt).defaultWidth}get descent(){return s(this,Kt).descent}get bbox(){return s(this,Kt).bbox}set bbox(t){gt(this,"bbox",t)}get fontMatrix(){return s(this,Kt).fontMatrix}get fallbackName(){return s(this,Kt).fallbackName}get loadedName(){return s(this,Kt).loadedName}get mimetype(){return s(this,Kt).mimetype}get name(){return s(this,Kt).name}get data(){return s(this,Kt).data}clearData(){s(this,Kt).clearData()}get cssFontInfo(){return s(this,Kt).cssFontInfo}get systemFontInfo(){return s(this,Kt).systemFontInfo}get defaultVMetrics(){return s(this,Kt).defaultVMetrics}}Kt=new WeakMap;const ql=class ql{constructor(t){v(this,Xl);v(this,Gl);v(this,Yl);v(this,cd);p(this,Gl,t),p(this,Yl,new DataView(s(this,Gl))),p(this,cd,new TextDecoder)}static write(t){const e=new TextEncoder,i={};let n=0;for(const h of ql.strings){const d=e.encode(t[h]);i[h]=d,n+=4+d.length}const r=new ArrayBuffer(n),o=new Uint8Array(r),l=new DataView(r);let c=0;for(const h of ql.strings){const d=i[h],f=d.length;l.setUint32(c,f),o.set(d,c+4),c+=4+f}return Rt(c===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return A(this,Xl,Ep).call(this,0)}get fontWeight(){return A(this,Xl,Ep).call(this,1)}get italicAngle(){return A(this,Xl,Ep).call(this,2)}};Gl=new WeakMap,Yl=new WeakMap,cd=new WeakMap,Xl=new WeakSet,Ep=function(t){Rt(t<ql.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=s(this,Yl).getUint32(e)+4;const i=s(this,Yl).getUint32(e);return s(this,cd).decode(new Uint8Array(s(this,Gl),e+4,i))},$(ql,"strings",["fontFamily","fontWeight","italicAngle"]);let Sf=ql;const Kl=class Kl{constructor(t){v(this,ua);v(this,so);v(this,ms);v(this,da);p(this,so,t),p(this,ms,new DataView(s(this,so))),p(this,da,new TextDecoder)}static write(t){const e=new TextEncoder,i={};let n=0;for(const u of Kl.strings){const g=e.encode(t[u]);i[u]=g,n+=4+g.length}n+=4;let r,o,l=1+n;t.style&&(r=e.encode(t.style.style),o=e.encode(t.style.weight),l+=4+r.length+4+o.length);const c=new ArrayBuffer(l),h=new Uint8Array(c),d=new DataView(c);let f=0;d.setUint8(f++,t.guessFallback?1:0),d.setUint32(f,0),f+=4,n=0;for(const u of Kl.strings){const g=i[u],b=g.length;n+=4+b,d.setUint32(f,b),h.set(g,f+4),f+=4+b}return d.setUint32(f-n-4,n),t.style&&(d.setUint32(f,r.length),h.set(r,f+4),f+=4+r.length,d.setUint32(f,o.length),h.set(o,f+4),f+=4+o.length),Rt(f<=c.byteLength,"SubstitionInfo.write: Buffer overflow"),c.transferToFixedLength(f)}get guessFallback(){return s(this,ms).getUint8(0)!==0}get css(){return A(this,ua,Bu).call(this,0)}get loadedName(){return A(this,ua,Bu).call(this,1)}get baseFontName(){return A(this,ua,Bu).call(this,2)}get src(){return A(this,ua,Bu).call(this,3)}get style(){let t=1;t+=4+s(this,ms).getUint32(t);const e=s(this,ms).getUint32(t),i=s(this,da).decode(new Uint8Array(s(this,so),t+4,e));t+=4+e;const n=s(this,ms).getUint32(t),r=s(this,da).decode(new Uint8Array(s(this,so),t+4,n));return{style:i,weight:r}}};so=new WeakMap,ms=new WeakMap,da=new WeakMap,ua=new WeakSet,Bu=function(t){Rt(t<Kl.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=s(this,ms).getUint32(e)+4;const i=s(this,ms).getUint32(e);return s(this,da).decode(new Uint8Array(s(this,so),e+4,i))},$(Kl,"strings",["css","loadedName","baseFontName","src"]);let Ef=Kl;const yt=class yt{constructor({data:t,extra:e}){v(this,Ce);v(this,bs);v(this,hd);v(this,Jt);p(this,bs,t),p(this,hd,new TextDecoder),p(this,Jt,new DataView(s(this,bs))),e&&Object.assign(this,e)}get black(){return A(this,Ce,es).call(this,0)}get bold(){return A(this,Ce,es).call(this,1)}get disableFontFace(){return A(this,Ce,es).call(this,2)}get fontExtraProperties(){return A(this,Ce,es).call(this,3)}get isInvalidPDFjsFont(){return A(this,Ce,es).call(this,4)}get isType3Font(){return A(this,Ce,es).call(this,5)}get italic(){return A(this,Ce,es).call(this,6)}get missingFile(){return A(this,Ce,es).call(this,7)}get remeasure(){return A(this,Ce,es).call(this,8)}get vertical(){return A(this,Ce,es).call(this,9)}get ascent(){return A(this,Ce,xp).call(this,0)}get defaultWidth(){return A(this,Ce,xp).call(this,1)}get descent(){return A(this,Ce,xp).call(this,2)}get bbox(){let t=s(yt,Zl);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<4;n++)i.push(s(this,Jt).getInt16(t,!0)),t+=2;return i}get fontMatrix(){let t=s(yt,Ql);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<6;n++)i.push(s(this,Jt).getFloat64(t,!0)),t+=8;return i}get defaultVMetrics(){let t=s(yt,tc);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<3;n++)i.push(s(this,Jt).getInt16(t,!0)),t+=2;return i}get fallbackName(){return A(this,Ce,ju).call(this,0)}get loadedName(){return A(this,Ce,ju).call(this,1)}get mimetype(){return A(this,Ce,ju).call(this,2)}get name(){return A(this,Ce,ju).call(this,3)}get data(){let t=s(yt,Ji);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);t+=4+n;const r=s(this,Jt).getUint32(t);if(r!==0)return new Uint8Array(s(this,bs),t+4,r)}clearData(){let t=s(yt,Ji);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);t+=4+n;const r=s(this,Jt).getUint32(t);new Uint8Array(s(this,bs),t+4,r).fill(0),s(this,Jt).setUint32(t,0)}get cssFontInfo(){let t=s(yt,Ji);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);if(n===0)return null;const r=new Uint8Array(n);return r.set(new Uint8Array(s(this,bs),t+4,n)),new Sf(r.buffer)}get systemFontInfo(){let t=s(yt,Ji);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);if(i===0)return null;const n=new Uint8Array(i);return n.set(new Uint8Array(s(this,bs),t+4,i)),new Ef(n.buffer)}static write(t){const e=t.systemFontInfo?Ef.write(t.systemFontInfo):null,i=t.cssFontInfo?Sf.write(t.cssFontInfo):null,n=new TextEncoder,r={};let o=0;for(const m of yt.strings)r[m]=n.encode(t[m]),o+=4+r[m].length;const l=s(yt,Ji)+4+o+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0),c=new ArrayBuffer(l),h=new Uint8Array(c),d=new DataView(c);let f=0;const u=yt.bools.length;let g=0,b=0;for(let m=0;m<u;m++){const w=t[yt.bools[m]];g|=(w===void 0?0:w?2:1)<<b,b+=2,(b===8||m===u-1)&&(d.setUint8(f++,g),g=0,b=0)}Rt(f===s(yt,Jl),"FontInfo.write: Boolean properties offset mismatch");for(const m of yt.numbers)d.setFloat64(f,t[m]),f+=8;if(Rt(f===s(yt,Zl),"FontInfo.write: Number properties offset mismatch"),t.bbox){d.setUint8(f++,4);for(const m of t.bbox)d.setInt16(f,m,!0),f+=2}else d.setUint8(f++,0),f+=8;if(Rt(f===s(yt,Ql),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){d.setUint8(f++,6);for(const m of t.fontMatrix)d.setFloat64(f,m,!0),f+=8}else d.setUint8(f++,0),f+=48;if(Rt(f===s(yt,tc),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){d.setUint8(f++,1);for(const m of t.defaultVMetrics)d.setInt16(f,m,!0),f+=2}else d.setUint8(f++,0),f+=6;Rt(f===s(yt,Ji),"FontInfo.write: DefaultVMetrics properties offset mismatch"),d.setUint32(s(yt,Ji),0),f+=4;for(const m of yt.strings){const w=r[m],y=w.length;d.setUint32(f,y),h.set(w,f+4),f+=4+y}if(d.setUint32(s(yt,Ji),f-s(yt,Ji)-4),!e)d.setUint32(f,0),f+=4;else{const m=e.byteLength;d.setUint32(f,m),Rt(f+4+m<=c.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),f+4),f+=4+m}if(!i)d.setUint32(f,0),f+=4;else{const m=i.byteLength;d.setUint32(f,m),Rt(f+4+m<=c.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(i),f+4),f+=4+m}return t.data===void 0?(d.setUint32(f,0),f+=4):(d.setUint32(f,t.data.length),h.set(t.data,f+4),f+=4+t.data.length),Rt(f<=c.byteLength,"FontInfo.write: Buffer overflow"),c.transferToFixedLength(f)}};Jl=new WeakMap,Zl=new WeakMap,Ql=new WeakMap,tc=new WeakMap,Ji=new WeakMap,bs=new WeakMap,hd=new WeakMap,Jt=new WeakMap,Ce=new WeakSet,es=function(t){Rt(t<yt.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=t*2%8,n=s(this,Jt).getUint8(e)>>i&3;return n===0?void 0:n===2},xp=function(t){return Rt(t<yt.numbers.length,"Invalid number index"),s(this,Jt).getFloat64(s(yt,Jl)+t*8)},ju=function(t){Rt(t<yt.strings.length,"Invalid string index");let e=s(yt,Ji)+4;for(let r=0;r<t;r++)e+=s(this,Jt).getUint32(e)+4;const i=s(this,Jt).getUint32(e),n=new Uint8Array(i);return n.set(new Uint8Array(s(this,bs),e+4,i)),s(this,hd).decode(n)},$(yt,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),$(yt,"numbers",["ascent","defaultWidth","descent"]),$(yt,"strings",["fallbackName","loadedName","mimetype","name"]),v(yt,Jl,Math.ceil(yt.bools.length*2/8)),v(yt,Zl,s(yt,Jl)+yt.numbers.length*8),v(yt,Ql,s(yt,Zl)+1+8),v(yt,tc,s(yt,Ql)+1+48),v(yt,Ji,s(yt,tc)+1+6);let qg=yt;const ce=class ce{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,i=null,n=[],r=[],o=[],l=[],c=null,h=null;switch(t[0]){case"RadialAxial":e=t[1]==="axial"?1:2,i=t[2],o=t[3],e===1?n.push(...t[4],...t[5]):n.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,c=t[1],n=t[2],r=t[3],l=t[4]||[],i=t[6],h=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}const d=Math.floor(n.length/2),f=Math.floor(r.length/3),u=o.length,g=l.length;let b=0;for(const C of l)b+=1,b=Math.ceil(b/4)*4,b+=4+C.coords.length*4,b+=4+C.colors.length*4,C.verticesPerRow!==void 0&&(b+=4);const m=20+d*8+f*3+u*8+(i?16:0)+(h?3:0)+b,w=new ArrayBuffer(m),y=new DataView(w),x=new Uint8Array(w);y.setUint8(s(ce,dd),e),y.setUint8(s(ce,ud),i?1:0),y.setUint8(s(ce,fd),h?1:0),y.setUint8(s(ce,pd),c),y.setUint32(s(ce,gd),d,!0),y.setUint32(s(ce,md),f,!0),y.setUint32(s(ce,bd),u,!0),y.setUint32(s(ce,yd),g,!0);let E=20;new Float32Array(w,E,d*2).set(n),E+=d*8,x.set(r,E),E+=f*3;for(const[C,T]of o)y.setFloat32(E,C,!0),E+=4,y.setUint32(E,parseInt(T.slice(1),16),!0),E+=4;if(i)for(const C of i)y.setFloat32(E,C,!0),E+=4;h&&(x.set(h,E),E+=3);for(let C=0;C<l.length;C++){const T=l[C];y.setUint8(E,T.type),E+=1,E=Math.ceil(E/4)*4,y.setUint32(E,T.coords.length,!0),E+=4,new Int32Array(w,E,T.coords.length).set(T.coords),E+=T.coords.length*4,y.setUint32(E,T.colors.length,!0),E+=4,new Int32Array(w,E,T.colors.length).set(T.colors),E+=T.colors.length*4,T.verticesPerRow!==void 0&&(y.setUint32(E,T.verticesPerRow,!0),E+=4)}return w}getIR(){const t=this.view,e=this.data[s(ce,dd)],i=!!this.data[s(ce,ud)],n=!!this.data[s(ce,fd)],r=t.getUint32(s(ce,gd),!0),o=t.getUint32(s(ce,md),!0),l=t.getUint32(s(ce,bd),!0),c=t.getUint32(s(ce,yd),!0);let h=20;const d=new Float32Array(this.buffer,h,r*2);h+=r*8;const f=new Uint8Array(this.buffer,h,o*3);h+=o*3;const u=[];for(let w=0;w<l;++w){const y=t.getFloat32(h,!0);h+=4;const x=t.getUint32(h,!0);h+=4,u.push([y,`#${x.toString(16).padStart(6,"0")}`])}let g=null;if(i){g=[];for(let w=0;w<4;++w)g.push(t.getFloat32(h,!0)),h+=4}let b=null;n&&(b=new Uint8Array(this.buffer,h,3),h+=3);const m=[];for(let w=0;w<c;++w){const y=t.getUint8(h);h+=1,h=Math.ceil(h/4)*4;const x=t.getUint32(h,!0);h+=4;const E=new Int32Array(this.buffer,h,x);h+=x*4;const _=t.getUint32(h,!0);h+=4;const C=new Int32Array(this.buffer,h,_);h+=_*4;const T={type:y,coords:E,colors:C};y===Lg.LATTICE&&(T.verticesPerRow=t.getUint32(h,!0),h+=4),m.push(T)}if(e===1)return["RadialAxial","axial",g,u,Array.from(d.slice(0,2)),Array.from(d.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",g,u,[d[0],d[1]],[d[3],d[4]],d[2],d[5]];if(e===3){const w=this.data[s(ce,pd)];let y=null;if(d.length>0){let x=d[0],E=d[0],_=d[1],C=d[1];for(let T=0;T<d.length;T+=2){const D=d[T],j=d[T+1];x=x>D?D:x,_=_>j?j:_,E=E<D?D:E,C=C<j?j:C}y=[x,_,E,C]}return["Mesh",w,d,f,m,y,g,b]}throw new Error(`Unsupported pattern kind: ${e}`)}};dd=new WeakMap,ud=new WeakMap,fd=new WeakMap,pd=new WeakMap,gd=new WeakMap,md=new WeakMap,bd=new WeakMap,yd=new WeakMap,v(ce,dd,0),v(ce,ud,1),v(ce,fd,2),v(ce,pd,3),v(ce,gd,4),v(ce,md,8),v(ce,bd,12),v(ce,yd,16);let Kg=ce;class lE{constructor(t){v(this,ec);p(this,ec,t)}static write(t){let e,i;return ze.isFloat16ArraySupported?(i=new ArrayBuffer(t.length*2),e=new Float16Array(i)):(i=new ArrayBuffer(t.length*4),e=new Float32Array(i)),e.set(t),i}get path(){return ze.isFloat16ArraySupported?new Float16Array(s(this,ec)):new Float32Array(s(this,ec))}}ec=new WeakMap;function cE(a){if(a instanceof URL)return a.href;if(typeof a=="string"){if(Si)return a;const t=URL.parse(a,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function hE(a){if(Si&&typeof Buffer<"u"&&a instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength)return a;if(typeof a=="string")return vh(a);if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||typeof a=="object"&&!isNaN(a==null?void 0:a.length))return new Uint8Array(a);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function xf(a){if(typeof a!="string")return null;if(a.endsWith("/"))return a;throw new Error(`Invalid factory url: "${a}" must include trailing slash.`)}const Jg=a=>typeof a=="object"&&Number.isInteger(a==null?void 0:a.num)&&a.num>=0&&Number.isInteger(a==null?void 0:a.gen)&&a.gen>=0,dE=a=>typeof a=="object"&&typeof(a==null?void 0:a.name)=="string",uE=VS.bind(null,Jg,dE);class fE{constructor(){v(this,Js,new Map);v(this,Xf,Promise.resolve())}postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};s(this,Xf).then(()=>{for(const[n]of s(this,Js))n.call(this,i)})}addEventListener(t,e,i=null){let n=null;if((i==null?void 0:i.signal)instanceof AbortSignal){const{signal:r}=i;if(r.aborted){pt("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(t,e);n=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}s(this,Js).set(e,n)}removeEventListener(t,e){const i=s(this,Js).get(e);i==null||i(),s(this,Js).delete(e)}terminate(){for(const[,t]of s(this,Js))t==null||t();s(this,Js).clear()}}Js=new WeakMap,Xf=new WeakMap;const Cf={DATA:1,ERROR:2},Oe={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function S0(){}function Di(a){if(a instanceof Fr||a instanceof Fg||a instanceof r0||a instanceof mf||a instanceof Ng)return a;switch(a instanceof Error||typeof a=="object"&&a!==null||ie('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),a.name){case"AbortException":return new Fr(a.message);case"InvalidPDFException":return new Fg(a.message);case"PasswordException":return new r0(a.message,a.code);case"ResponseException":return new mf(a.message,a.status,a.missing);case"UnknownErrorException":return new Ng(a.message,a.details)}return new Ng(a.message,a.toString())}class _h{constructor(t,e,i){v(this,Rn);v(this,ic,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",A(this,Rn,Kv).bind(this),{signal:s(this,ic).signal})}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const n=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(o){r.reject(o)}return r.promise}sendWithStream(t,e,i,n){const r=this.streamId++,o=this.sourceName,l=this.targetName,c=this.comObj;return new ReadableStream({start:h=>{const d=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:o,targetName:l,action:t,streamId:r,data:e,desiredSize:h.desiredSize},n),d.promise},pull:h=>{const d=Promise.withResolvers();return this.streamControllers[r].pullCall=d,c.postMessage({sourceName:o,targetName:l,stream:Oe.PULL,streamId:r,desiredSize:h.desiredSize}),d.promise},cancel:h=>{Rt(h instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[r].cancelCall=d,this.streamControllers[r].isClosed=!0,c.postMessage({sourceName:o,targetName:l,stream:Oe.CANCEL,streamId:r,reason:Di(h)}),d.promise}},i)}destroy(){var t;(t=s(this,ic))==null||t.abort(),p(this,ic,null)}}ic=new WeakMap,Rn=new WeakSet,Kv=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){A(this,Rn,Zv).call(this,t);return}if(t.callback){const i=t.callbackId,n=this.callbackCapabilities[i];if(!n)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],t.callback===Cf.DATA)n.resolve(t.data);else if(t.callback===Cf.ERROR)n.reject(Di(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,n=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(o){r.postMessage({sourceName:i,targetName:n,callback:Cf.DATA,callbackId:t.callbackId,data:o})},function(o){r.postMessage({sourceName:i,targetName:n,callback:Cf.ERROR,callbackId:t.callbackId,reason:Di(o)})});return}if(t.streamId){A(this,Rn,Jv).call(this,t);return}e(t.data)},Jv=function(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,r=this.comObj,o=this,l=this.actionHandler[t.action],c={enqueue(h,d=1,f){if(this.isCancelled)return;const u=this.desiredSize;this.desiredSize-=d,u>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:n,stream:Oe.ENQUEUE,streamId:e,chunk:h},f)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:n,stream:Oe.CLOSE,streamId:e}),delete o.streamSinks[e])},error(h){Rt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:n,stream:Oe.ERROR,streamId:e,reason:Di(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[e]=c,Promise.try(l,t.data,c).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Oe.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Oe.START_COMPLETE,streamId:e,reason:Di(h)})})},Zv=function(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,r=this.comObj,o=this.streamControllers[e],l=this.streamSinks[e];switch(t.stream){case Oe.START_COMPLETE:t.success?o.startCall.resolve():o.startCall.reject(Di(t.reason));break;case Oe.PULL_COMPLETE:t.success?o.pullCall.resolve():o.pullCall.reject(Di(t.reason));break;case Oe.PULL:if(!l){r.postMessage({sourceName:i,targetName:n,stream:Oe.PULL_COMPLETE,streamId:e,success:!0});break}l.desiredSize<=0&&t.desiredSize>0&&l.sinkCapability.resolve(),l.desiredSize=t.desiredSize,Promise.try(l.onPull||S0).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Oe.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Oe.PULL_COMPLETE,streamId:e,reason:Di(h)})});break;case Oe.ENQUEUE:if(Rt(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(t.chunk);break;case Oe.CLOSE:if(Rt(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),A(this,Rn,Cp).call(this,o,e);break;case Oe.ERROR:Rt(o,"error should have stream controller"),o.controller.error(Di(t.reason)),A(this,Rn,Cp).call(this,o,e);break;case Oe.CANCEL_COMPLETE:t.success?o.cancelCall.resolve():o.cancelCall.reject(Di(t.reason)),A(this,Rn,Cp).call(this,o,e);break;case Oe.CANCEL:if(!l)break;const c=Di(t.reason);Promise.try(l.onCancel||S0,c).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Oe.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Oe.CANCEL_COMPLETE,streamId:e,reason:Di(h)})}),l.sinkCapability.reject(c),l.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Cp=async function(t,e){var i,n,r;await Promise.allSettled([(i=t.startCall)==null?void 0:i.promise,(n=t.pullCall)==null?void 0:n.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};class E0{constructor({enableHWA:t=!1}){v(this,vd,!1);p(this,vd,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!s(this,vd)})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ie("Abstract method `_createCanvas` called.")}}vd=new WeakMap;class pE extends E0{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class x0{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(i=>({cMapData:i,isCompressed:this.isCompressed})).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){ie("Abstract method `_fetch` called.")}}class C0 extends x0{async _fetch(t){const e=await Ah(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):vh(e)}}class _0{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,n,r){return"none"}destroy(t=!1){}}class gE extends _0{constructor({docId:e,ownerDocument:i=globalThis.document}){super();v(this,et);v(this,fa);v(this,nc);v(this,Zs);v(this,Qs);v(this,bi);v(this,pa);v(this,ga,0);p(this,Qs,e),p(this,bi,i)}addFilter(e){if(!e)return"none";let i=s(this,et,Ai).get(e);if(i)return i;const[n,r,o]=A(this,et,_p).call(this,e),l=e.length===1?n:`${n}${r}${o}`;if(i=s(this,et,Ai).get(l),i)return s(this,et,Ai).set(e,i),i;const c=`g_${s(this,Qs)}_transfer_map_${Xe(this,ga)._++}`,h=A(this,et,oh).call(this,c);s(this,et,Ai).set(e,h),s(this,et,Ai).set(l,h);const d=A(this,et,ah).call(this,c);return A(this,et,Hu).call(this,n,r,o,d),h}addHCMFilter(e,i){var b;const n=`${e}-${i}`,r="base";let o=s(this,et,zu).get(r);if((o==null?void 0:o.key)===n||(o?((b=o.filter)==null||b.remove(),o.key=n,o.url="none",o.filter=null):(o={key:n,url:"none",filter:null},s(this,et,zu).set(r,o)),!e||!i))return o.url;const l=A(this,et,$u).call(this,e);e=Z.makeHexColor(...l);const c=A(this,et,$u).call(this,i);if(i=Z.makeHexColor(...c),s(this,et,rh).style.color="",e==="#000000"&&i==="#ffffff"||e===i)return o.url;const h=new Array(256);for(let m=0;m<=255;m++){const w=m/255;h[m]=w<=.03928?w/12.92:((w+.055)/1.055)**2.4}const d=h.join(","),f=`g_${s(this,Qs)}_hcm_filter`,u=o.filter=A(this,et,ah).call(this,f);A(this,et,Hu).call(this,d,d,d,u),A(this,et,Qm).call(this,u);const g=(m,w)=>{const y=l[m]/255,x=c[m]/255,E=new Array(w+1);for(let _=0;_<=w;_++)E[_]=y+_/w*(x-y);return E.join(",")};return A(this,et,Hu).call(this,g(0,5),g(1,5),g(2,5),u),o.url=A(this,et,oh).call(this,f),o.url}addAlphaFilter(e){let i=s(this,et,Ai).get(e);if(i)return i;const[n]=A(this,et,_p).call(this,[e]),r=`alpha_${n}`;if(i=s(this,et,Ai).get(r),i)return s(this,et,Ai).set(e,i),i;const o=`g_${s(this,Qs)}_alpha_map_${Xe(this,ga)._++}`,l=A(this,et,oh).call(this,o);s(this,et,Ai).set(e,l),s(this,et,Ai).set(r,l);const c=A(this,et,ah).call(this,o);return A(this,et,tb).call(this,n,c),l}addLuminosityFilter(e){let i=s(this,et,Ai).get(e||"luminosity");if(i)return i;let n,r;if(e?([n]=A(this,et,_p).call(this,[e]),r=`luminosity_${n}`):r="luminosity",i=s(this,et,Ai).get(r),i)return s(this,et,Ai).set(e,i),i;const o=`g_${s(this,Qs)}_luminosity_map_${Xe(this,ga)._++}`,l=A(this,et,oh).call(this,o);s(this,et,Ai).set(e,l),s(this,et,Ai).set(r,l);const c=A(this,et,ah).call(this,o);return A(this,et,Qv).call(this,c),e&&A(this,et,tb).call(this,n,c),l}addHighlightHCMFilter(e,i,n,r,o){var x;const l=`${i}-${n}-${r}-${o}`;let c=s(this,et,zu).get(e);if((c==null?void 0:c.key)===l||(c?((x=c.filter)==null||x.remove(),c.key=l,c.url="none",c.filter=null):(c={key:l,url:"none",filter:null},s(this,et,zu).set(e,c)),!i||!n))return c.url;const[h,d]=[i,n].map(A(this,et,$u).bind(this));let f=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),u=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[g,b]=[r,o].map(A(this,et,$u).bind(this));u<f&&([f,u,g,b]=[u,f,b,g]),s(this,et,rh).style.color="";const m=(E,_,C)=>{const T=new Array(256),D=(u-f)/C,j=E/255,O=(_-E)/(255*C);let H=0;for(let N=0;N<=C;N++){const lt=Math.round(f+N*D),G=j+N*O;for(let K=H;K<=lt;K++)T[K]=G;H=lt+1}for(let N=H;N<256;N++)T[N]=T[H-1];return T.join(",")},w=`g_${s(this,Qs)}_hcm_${e}_filter`,y=c.filter=A(this,et,ah).call(this,w);return A(this,et,Qm).call(this,y),A(this,et,Hu).call(this,m(g[0],b[0],5),m(g[1],b[1],5),m(g[2],b[2],5),y),c.url=A(this,et,oh).call(this,w),c.url}destroy(e=!1){var i,n,r,o;e&&((i=s(this,pa))!=null&&i.size)||((n=s(this,Zs))==null||n.parentNode.parentNode.remove(),p(this,Zs,null),(r=s(this,nc))==null||r.clear(),p(this,nc,null),(o=s(this,pa))==null||o.clear(),p(this,pa,null),p(this,ga,0))}}fa=new WeakMap,nc=new WeakMap,Zs=new WeakMap,Qs=new WeakMap,bi=new WeakMap,pa=new WeakMap,ga=new WeakMap,et=new WeakSet,Ai=function(){return s(this,nc)||p(this,nc,new Map)},zu=function(){return s(this,pa)||p(this,pa,new Map)},rh=function(){if(!s(this,Zs)){const e=s(this,bi).createElement("div"),{style:i}=e;i.visibility="hidden",i.contain="strict",i.width=i.height=0,i.position="absolute",i.top=i.left=0,i.zIndex=-1;const n=s(this,bi).createElementNS(Ls,"svg");n.setAttribute("width",0),n.setAttribute("height",0),p(this,Zs,s(this,bi).createElementNS(Ls,"defs")),e.append(n),n.append(s(this,Zs)),s(this,bi).body.append(e)}return s(this,Zs)},_p=function(e){if(e.length===1){const h=e[0],d=new Array(256);for(let u=0;u<256;u++)d[u]=h[u]/255;const f=d.join(",");return[f,f,f]}const[i,n,r]=e,o=new Array(256),l=new Array(256),c=new Array(256);for(let h=0;h<256;h++)o[h]=i[h]/255,l[h]=n[h]/255,c[h]=r[h]/255;return[o.join(","),l.join(","),c.join(",")]},oh=function(e){if(s(this,fa)===void 0){p(this,fa,"");const i=s(this,bi).URL;i!==s(this,bi).baseURI&&(bf(i)?pt('#createUrl: ignore "data:"-URL for performance reasons.'):p(this,fa,s0(i,"")))}return`url(${s(this,fa)}#${e})`},Qv=function(e){const i=s(this,bi).createElementNS(Ls,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(i)},Qm=function(e){const i=s(this,bi).createElementNS(Ls,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(i)},ah=function(e){const i=s(this,bi).createElementNS(Ls,"filter");return i.setAttribute("color-interpolation-filters","sRGB"),i.setAttribute("id",e),s(this,et,rh).append(i),i},Uu=function(e,i,n){const r=s(this,bi).createElementNS(Ls,i);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},Hu=function(e,i,n,r){const o=s(this,bi).createElementNS(Ls,"feComponentTransfer");r.append(o),A(this,et,Uu).call(this,o,"feFuncR",e),A(this,et,Uu).call(this,o,"feFuncG",i),A(this,et,Uu).call(this,o,"feFuncB",n)},tb=function(e,i){const n=s(this,bi).createElementNS(Ls,"feComponentTransfer");i.append(n),A(this,et,Uu).call(this,n,"feFuncA",e)},$u=function(e){return s(this,et,rh).style.color=e,xh(getComputedStyle(s(this,et,rh)).getPropertyValue("color"))};class T0{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(i=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){ie("Abstract method `_fetch` called.")}}class P0 extends T0{async _fetch(t){const e=await Ah(t,"arraybuffer");return new Uint8Array(e)}}class k0{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(i=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){ie("Abstract method `_fetch` called.")}}class M0 extends k0{async _fetch(t){const e=await Ah(t,"arraybuffer");return new Uint8Array(e)}}Si&&pt("Please use the `legacy` build in Node.js environments.");async function Zg(a){const e=await process.getBuiltinModule("fs").promises.readFile(a);return new Uint8Array(e)}class mE extends _0{}class bE extends E0{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:kr&&kr.tagName.toUpperCase()==="SCRIPT"&&kr.src||new URL("whiteboard.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class yE extends x0{async _fetch(t){return Zg(t)}}class vE extends T0{async _fetch(t){return Zg(t)}}class wE extends k0{async _fetch(t){return Zg(t)}}const vl="__forcedDependency",{floor:R0,ceil:D0}=Math;function _f(a,t,e,i,n,r){a[t*4+0]=Math.min(a[t*4+0],e),a[t*4+1]=Math.min(a[t*4+1],i),a[t*4+2]=Math.max(a[t*4+2],n),a[t*4+3]=Math.max(a[t*4+3],r)}const Qg=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class AE{constructor(t,e){v(this,sc);v(this,ro);p(this,sc,t),p(this,ro,e)}get length(){return s(this,sc).length}isEmpty(t){return s(this,sc)[t]===Qg}minX(t){return s(this,ro)[t*4+0]/256}minY(t){return s(this,ro)[t*4+1]/256}maxX(t){return(s(this,ro)[t*4+2]+1)/256}maxY(t){return(s(this,ro)[t*4+3]+1)/256}}sc=new WeakMap,ro=new WeakMap;const Tf=(a,t)=>{if(!a)return;let e=a.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},a.set(t,e)),e};class SE{constructor(t,e,i=!1){v(this,Ad);v(this,Li,{__proto__:null});v(this,Ni,{__proto__:null,transform:[],moveText:[],sameLineText:[],[vl]:[]});v(this,ma,new Map);v(this,Hn,[]);v(this,ba,[]);v(this,tr,[[1,0,0,1,0,0]]);v(this,Xt,[-1/0,-1/0,1/0,1/0]);v(this,Zt,new Float64Array([1/0,1/0,-1/0,-1/0]));v(this,er,-1);v(this,Fi,new Set);v(this,wd,new Map);v(this,rc,new Map);v(this,ya);v(this,va);v(this,ir);v(this,yi);v(this,ys);p(this,ya,t.width),p(this,va,t.height),A(this,Ad,eb).call(this,e),i&&p(this,ys,new Map)}growOperationsCount(t){t>=s(this,yi).length&&A(this,Ad,eb).call(this,t,s(this,yi))}save(t){return p(this,Li,{__proto__:s(this,Li)}),p(this,Ni,{__proto__:s(this,Ni),transform:{__proto__:s(this,Ni).transform},moveText:{__proto__:s(this,Ni).moveText},sameLineText:{__proto__:s(this,Ni).sameLineText},[vl]:{__proto__:s(this,Ni)[vl]}}),p(this,Xt,{__proto__:s(this,Xt)}),s(this,Hn).push(t),this}restore(t){var n;const e=Object.getPrototypeOf(s(this,Li));if(e===null)return this;p(this,Li,e),p(this,Ni,Object.getPrototypeOf(s(this,Ni))),p(this,Xt,Object.getPrototypeOf(s(this,Xt)));const i=s(this,Hn).pop();return i!==void 0&&((n=Tf(s(this,ys),t))==null||n.dependencies.add(i),s(this,yi)[t]=s(this,yi)[i]),this}recordOpenMarker(t){return s(this,Hn).push(t),this}getOpenMarker(){return s(this,Hn).length===0?null:s(this,Hn).at(-1)}recordCloseMarker(t){var i;const e=s(this,Hn).pop();return e!==void 0&&((i=Tf(s(this,ys),t))==null||i.dependencies.add(e),s(this,yi)[t]=s(this,yi)[e]),this}beginMarkedContent(t){return s(this,ba).push(t),this}endMarkedContent(t){var i;const e=s(this,ba).pop();return e!==void 0&&((i=Tf(s(this,ys),t))==null||i.dependencies.add(e),s(this,yi)[t]=s(this,yi)[e]),this}pushBaseTransform(t){return s(this,tr).push(Z.multiplyByDOMMatrix(s(this,tr).at(-1),t.getTransform())),this}popBaseTransform(){return s(this,tr).length>1&&s(this,tr).pop(),this}recordSimpleData(t,e){return s(this,Li)[t]=e,this}recordIncrementalData(t,e){return s(this,Ni)[t].push(e),this}resetIncrementalData(t,e){return s(this,Ni)[t].length=0,this}recordNamedData(t,e){return s(this,ma).set(t,e),this}recordSimpleDataFromNamed(t,e,i){s(this,Li)[t]=s(this,ma).get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(vl,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in s(this,Li)&&this.recordFutureForcedDependency(e,s(this,Li)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of s(this,Fi))this.recordFutureForcedDependency(vl,t);return this}resetBBox(t){return s(this,er)!==t&&(p(this,er,t),s(this,Zt)[0]=1/0,s(this,Zt)[1]=1/0,s(this,Zt)[2]=-1/0,s(this,Zt)[3]=-1/0),this}recordClipBox(t,e,i,n,r,o){const l=Z.multiplyByDOMMatrix(s(this,tr).at(-1),e.getTransform()),c=[1/0,1/0,-1/0,-1/0];Z.axialAlignedBoundingBox([i,r,n,o],l,c);const h=Z.intersect(s(this,Xt),c);return h?(s(this,Xt)[0]=h[0],s(this,Xt)[1]=h[1],s(this,Xt)[2]=h[2],s(this,Xt)[3]=h[3]):(s(this,Xt)[0]=s(this,Xt)[1]=1/0,s(this,Xt)[2]=s(this,Xt)[3]=-1/0),this}recordBBox(t,e,i,n,r,o){const l=s(this,Xt);if(l[0]===1/0)return this;const c=Z.multiplyByDOMMatrix(s(this,tr).at(-1),e.getTransform());if(l[0]===-1/0)return Z.axialAlignedBoundingBox([i,r,n,o],c,s(this,Zt)),this;const h=[1/0,1/0,-1/0,-1/0];return Z.axialAlignedBoundingBox([i,r,n,o],c,h),s(this,Zt)[0]=Math.min(s(this,Zt)[0],Math.max(h[0],l[0])),s(this,Zt)[1]=Math.min(s(this,Zt)[1],Math.max(h[1],l[1])),s(this,Zt)[2]=Math.max(s(this,Zt)[2],Math.min(h[2],l[2])),s(this,Zt)[3]=Math.max(s(this,Zt)[3],Math.min(h[3],l[3])),this}recordCharacterBBox(t,e,i,n=1,r=0,o=0,l){const c=i.bbox;let h,d;if(c&&(h=c[2]!==c[0]&&c[3]!==c[1]&&s(this,rc).get(i),h!==!1&&(d=[0,0,0,0],Z.axialAlignedBoundingBox(c,i.fontMatrix,d),(n!==1||r!==0||o!==0)&&Z.scaleMinMax([n,0,0,-n,r,o],d),h)))return this.recordBBox(t,e,d[0],d[2],d[1],d[3]);if(!l)return this.recordFullPageBBox(t);const f=l();return c&&d&&h===void 0&&(h=d[0]<=r-f.actualBoundingBoxLeft&&d[2]>=r+f.actualBoundingBoxRight&&d[1]<=o-f.actualBoundingBoxAscent&&d[3]>=o+f.actualBoundingBoxDescent,s(this,rc).set(i,h),h)?this.recordBBox(t,e,d[0],d[2],d[1],d[3]):this.recordBBox(t,e,r-f.actualBoundingBoxLeft,r+f.actualBoundingBoxRight,o-f.actualBoundingBoxAscent,o+f.actualBoundingBoxDescent)}recordFullPageBBox(t){return s(this,Zt)[0]=Math.max(0,s(this,Xt)[0]),s(this,Zt)[1]=Math.max(0,s(this,Xt)[1]),s(this,Zt)[2]=Math.min(s(this,ya),s(this,Xt)[2]),s(this,Zt)[3]=Math.min(s(this,va),s(this,Xt)[3]),this}getSimpleIndex(t){return s(this,Li)[t]}recordDependencies(t,e){const i=s(this,Fi),n=s(this,Li),r=s(this,Ni);for(const o of e)o in s(this,Li)?i.add(n[o]):o in r&&r[o].forEach(i.add,i);return this}recordNamedDependency(t,e){return s(this,ma).has(e)&&s(this,Fi).add(s(this,ma).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[vl]),s(this,ys)){const i=Tf(s(this,ys),t),{dependencies:n}=i;s(this,Fi).forEach(n.add,n),s(this,Hn).forEach(n.add,n),s(this,ba).forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}if(s(this,er)===t){const i=R0(s(this,Zt)[0]*256/s(this,ya)),n=R0(s(this,Zt)[1]*256/s(this,va)),r=D0(s(this,Zt)[2]*256/s(this,ya)),o=D0(s(this,Zt)[3]*256/s(this,va));_f(s(this,ir),t,i,n,r,o);for(const l of s(this,Fi))l!==t&&_f(s(this,ir),l,i,n,r,o);for(const l of s(this,Hn))l!==t&&_f(s(this,ir),l,i,n,r,o);for(const l of s(this,ba))l!==t&&_f(s(this,ir),l,i,n,r,o);e||(s(this,Fi).clear(),p(this,er,-1))}return this}recordShowTextOperation(t,e=!1){const i=Array.from(s(this,Fi));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of i)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){return s(this,er)===t&&(p(this,er,-1),s(this,Xt)[0]=Math.max(s(this,Xt)[0],s(this,Zt)[0]),s(this,Xt)[1]=Math.max(s(this,Xt)[1],s(this,Zt)[1]),s(this,Xt)[2]=Math.min(s(this,Xt)[2],s(this,Zt)[2]),s(this,Xt)[3]=Math.min(s(this,Xt)[3],s(this,Zt)[3]),e||s(this,Fi).clear()),this}_takePendingDependencies(){const t=s(this,Fi);return p(this,Fi,new Set),t}_extractOperation(t){const e=s(this,wd).get(t);return s(this,wd).delete(t),e}_pushPendingDependencies(t){for(const e of t)s(this,Fi).add(e)}take(){return s(this,rc).clear(),new AE(s(this,yi),s(this,ir))}takeDebugMetadata(){return s(this,ys)}}Li=new WeakMap,Ni=new WeakMap,ma=new WeakMap,Hn=new WeakMap,ba=new WeakMap,tr=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,er=new WeakMap,Fi=new WeakMap,wd=new WeakMap,rc=new WeakMap,ya=new WeakMap,va=new WeakMap,ir=new WeakMap,yi=new WeakMap,ys=new WeakMap,Ad=new WeakSet,eb=function(t,e){const i=new ArrayBuffer(t*4);p(this,ir,new Uint8ClampedArray(i)),p(this,yi,new Uint32Array(i)),e&&e.length>0?(s(this,yi).set(e),s(this,yi).fill(Qg,e.length)):s(this,yi).fill(Qg)};const Pm=class Pm{constructor(t,e,i){v(this,se);v(this,_e);v(this,$n);v(this,oc,0);v(this,ac,0);if(t instanceof Pm&&s(t,$n)===!!i)return t;p(this,se,t),p(this,_e,e),p(this,$n,!!i)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Xe(this,ac)._++,s(this,se).save(s(this,_e)),this}restore(t){return s(this,ac)>0&&(s(this,se).restore(s(this,_e)),Xe(this,ac)._--),this}recordOpenMarker(t){return Xe(this,oc)._++,this}getOpenMarker(){return s(this,oc)>0?s(this,_e):s(this,se).getOpenMarker()}recordCloseMarker(t){return Xe(this,oc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return s(this,se).pushBaseTransform(t),this}popBaseTransform(){return s(this,se).popBaseTransform(),this}recordSimpleData(t,e){return s(this,se).recordSimpleData(t,s(this,_e)),this}recordIncrementalData(t,e){return s(this,se).recordIncrementalData(t,s(this,_e)),this}resetIncrementalData(t,e){return s(this,se).resetIncrementalData(t,s(this,_e)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return s(this,se).recordSimpleDataFromNamed(t,e,s(this,_e)),this}recordFutureForcedDependency(t,e){return s(this,se).recordFutureForcedDependency(t,s(this,_e)),this}inheritSimpleDataAsFutureForcedDependencies(t){return s(this,se).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return s(this,se).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return s(this,$n)||s(this,se).resetBBox(s(this,_e)),this}recordClipBox(t,e,i,n,r,o){return s(this,$n)||s(this,se).recordClipBox(s(this,_e),e,i,n,r,o),this}recordBBox(t,e,i,n,r,o){return s(this,$n)||s(this,se).recordBBox(s(this,_e),e,i,n,r,o),this}recordCharacterBBox(t,e,i,n,r,o,l){return s(this,$n)||s(this,se).recordCharacterBBox(s(this,_e),e,i,n,r,o,l),this}recordFullPageBBox(t){return s(this,$n)||s(this,se).recordFullPageBBox(s(this,_e)),this}getSimpleIndex(t){return s(this,se).getSimpleIndex(t)}recordDependencies(t,e){return s(this,se).recordDependencies(s(this,_e),e),this}recordNamedDependency(t,e){return s(this,se).recordNamedDependency(s(this,_e),e),this}recordOperation(t){return s(this,se).recordOperation(s(this,_e),!0),this}recordShowTextOperation(t){return s(this,se).recordShowTextOperation(s(this,_e),!0),this}bboxToClipBoxDropOperation(t){return s(this,$n)||s(this,se).bboxToClipBoxDropOperation(s(this,_e),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};se=new WeakMap,_e=new WeakMap,$n=new WeakMap,oc=new WeakMap,ac=new WeakMap;let Pf=Pm;const An={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},si={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function tm(a,t){if(!t)return;const e=t[2]-t[0],i=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,i),a.clip(n)}class em{isModifyingCurrentTransform(){return!1}getPattern(){ie("Abstract method `getPattern` called.")}}class EE extends em{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}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}_createGradient(t,e=null){let i,n=this._p0,r=this._p1;if(e&&(n=n.slice(),r=r.slice(),Z.applyTransform(n,e),Z.applyTransform(r,e)),this._type==="axial")i=t.createLinearGradient(n[0],n[1],r[0],r[1]);else if(this._type==="radial"){let o=this._r0,l=this._r1;if(e){const c=new Float32Array(2);Z.singularValueDecompose2dScale(e,c),o*=c[0],l*=c[0]}i=t.createRadialGradient(n[0],n[1],o,r[0],r[1],l)}for(const o of this._colorStops)i.addColorStop(o[0],o[1]);return i}getPattern(t,e,i,n){let r;if(n===si.STROKE||n===si.FILL){if(this.isOriginBased()){let u=Z.transform(i,e.baseTransform);this.matrix&&(u=Z.transform(u,this.matrix));const g=.001,b=Math.hypot(u[0],u[1]),m=Math.hypot(u[2],u[3]),w=(u[0]*u[2]+u[1]*u[3])/(b*m);if(Math.abs(w)<g)if(this.isRadial()){if(Math.abs(b-m)<g)return this._createGradient(t,u)}else return this._createGradient(t,u)}const o=e.current.getClippedPathBoundingBox(n,ye(t))||[0,0,0,0],l=Math.ceil(o[2]-o[0])||1,c=Math.ceil(o[3]-o[1])||1,h=e.cachedCanvases.getCanvas("pattern",l,c),d=h.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-o[0],-o[1]),i=Z.transform(i,[1,0,0,1,o[0],o[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),tm(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),r=t.createPattern(h.canvas,"no-repeat");const f=new DOMMatrix(i);r.setTransform(f)}else tm(t,this._bbox),r=this._createGradient(t);return r}}function im(a,t,e,i,n,r,o,l){const c=t.coords,h=t.colors,d=a.data,f=a.width*4;let u;c[e+1]>c[i+1]&&(u=e,e=i,i=u,u=r,r=o,o=u),c[i+1]>c[n+1]&&(u=i,i=n,n=u,u=o,o=l,l=u),c[e+1]>c[i+1]&&(u=e,e=i,i=u,u=r,r=o,o=u);const g=(c[e]+t.offsetX)*t.scaleX,b=(c[e+1]+t.offsetY)*t.scaleY,m=(c[i]+t.offsetX)*t.scaleX,w=(c[i+1]+t.offsetY)*t.scaleY,y=(c[n]+t.offsetX)*t.scaleX,x=(c[n+1]+t.offsetY)*t.scaleY;if(b>=x)return;const E=h[r],_=h[r+1],C=h[r+2],T=h[o],D=h[o+1],j=h[o+2],O=h[l],H=h[l+1],N=h[l+2],lt=Math.round(b),G=Math.round(x);let K,rt,tt,J,ct,Dt,Ot,jt;for(let vt=lt;vt<=G;vt++){if(vt<w){const St=vt<b?0:(b-vt)/(b-w);K=g-(g-m)*St,rt=E-(E-T)*St,tt=_-(_-D)*St,J=C-(C-j)*St}else{let St;vt>x?St=1:w===x?St=0:St=(w-vt)/(w-x),K=m-(m-y)*St,rt=T-(T-O)*St,tt=D-(D-H)*St,J=j-(j-N)*St}let Ct;vt<b?Ct=0:vt>x?Ct=1:Ct=(b-vt)/(b-x),ct=g-(g-y)*Ct,Dt=E-(E-O)*Ct,Ot=_-(_-H)*Ct,jt=C-(C-N)*Ct;const Ae=Math.round(Math.min(K,ct)),Nt=Math.round(Math.max(K,ct));let he=f*vt+Ae*4;for(let St=Ae;St<=Nt;St++)Ct=(K-St)/(K-ct),Ct<0?Ct=0:Ct>1&&(Ct=1),d[he++]=rt-(rt-Dt)*Ct|0,d[he++]=tt-(tt-Ot)*Ct|0,d[he++]=J-(J-jt)*Ct|0,d[he++]=255}}function xE(a,t,e){const i=t.coords,n=t.colors;let r,o;switch(t.type){case Lg.LATTICE:const l=t.verticesPerRow,c=Math.floor(i.length/l)-1,h=l-1;for(r=0;r<c;r++){let d=r*l;for(let f=0;f<h;f++,d++)im(a,e,i[d],i[d+1],i[d+l],n[d],n[d+1],n[d+l]),im(a,e,i[d+l+1],i[d+1],i[d+l],n[d+l+1],n[d+1],n[d+l])}break;case Lg.TRIANGLES:for(r=0,o=i.length;r<o;r+=3)im(a,e,i[r],i[r+1],i[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class CE extends em{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const l=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-l,d=Math.ceil(this._bounds[3])-c,f=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),u=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3),g=h/f,b=d/u,m={coords:this._coords,colors:this._colors,offsetX:-l,offsetY:-c,scaleX:1/g,scaleY:1/b},w=f+4,y=u+4,x=i.getCanvas("mesh",w,y),E=x.context,_=E.createImageData(f,u);if(e){const T=_.data;for(let D=0,j=T.length;D<j;D+=4)T[D]=e[0],T[D+1]=e[1],T[D+2]=e[2],T[D+3]=255}for(const T of this._figures)xE(_,T,m);return E.putImageData(_,2,2),{canvas:x.canvas,offsetX:l-2*g,offsetY:c-2*b,scaleX:g,scaleY:b}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,n){tm(t,this._bbox);const r=new Float32Array(2);if(n===si.SHADING)Z.singularValueDecompose2dScale(ye(t),r);else if(this.matrix){Z.singularValueDecompose2dScale(this.matrix,r);const[l,c]=r;Z.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=c}else Z.singularValueDecompose2dScale(e.baseTransform,r);const o=this._createMeshCanvas(r,n===si.SHADING?null:this._background,e.cachedCanvases);return n!==si.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(o.offsetX,o.offsetY),t.scale(o.scaleX,o.scaleY),t.createPattern(o.canvas,"no-repeat")}}class _E extends em{getPattern(){return"hotpink"}}function TE(a){switch(a[0]){case"RadialAxial":return new EE(a);case"Mesh":return new CE(a);case"Dummy":return new _E}throw new Error(`Unknown IR type: ${a[0]}`)}const O0={COLORED:1,UNCOLORED:2},qf=class qf{constructor(t,e,i,n){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t,e){var Dt,Ot;const{bbox:i,operatorList:n,paintType:r,tilingType:o,color:l,canvasGraphicsFactory:c}=this;let{xstep:h,ystep:d}=this;h=Math.abs(h),d=Math.abs(d),gf("TilingType: "+o);const f=i[0],u=i[1],g=i[2],b=i[3],m=g-f,w=b-u,y=new Float32Array(2);Z.singularValueDecompose2dScale(this.matrix,y);const[x,E]=y;Z.singularValueDecompose2dScale(this.baseTransform,y);const _=x*y[0],C=E*y[1];let T=m,D=w,j=!1,O=!1;const H=Math.ceil(h*_),N=Math.ceil(d*C),lt=Math.ceil(m*_),G=Math.ceil(w*C);H>=lt?T=h:j=!0,N>=G?D=d:O=!0;const K=this.getSizeAndScale(T,this.ctx.canvas.width,_),rt=this.getSizeAndScale(D,this.ctx.canvas.height,C),tt=t.cachedCanvases.getCanvas("pattern",K.size,rt.size),J=tt.context,ct=c.createCanvasGraphics(J,e);if(ct.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(ct,r,l),J.translate(-K.scale*f,-rt.scale*u),ct.transform(0,K.scale,0,0,rt.scale,0,0),J.save(),(Dt=ct.dependencyTracker)==null||Dt.save(),this.clipBbox(ct,f,u,g,b),ct.baseTransform=ye(ct.ctx),ct.executeOperatorList(n),ct.endDrawing(),(Ot=ct.dependencyTracker)==null||Ot.restore(),J.restore(),j||O){const jt=tt.canvas;j&&(T=h),O&&(D=d);const vt=this.getSizeAndScale(T,this.ctx.canvas.width,_),Ct=this.getSizeAndScale(D,this.ctx.canvas.height,C),Ae=vt.size,Nt=Ct.size,he=t.cachedCanvases.getCanvas("pattern-workaround",Ae,Nt),St=he.context,Ui=j?Math.floor(m/h):0,Hi=O?Math.floor(w/d):0;for(let Ne=0;Ne<=Ui;Ne++)for(let wi=0;wi<=Hi;wi++)St.drawImage(jt,Ae*Ne,Nt*wi,Ae,Nt,0,0,Ae,Nt);return{canvas:he.canvas,scaleX:vt.scale,scaleY:Ct.scale,offsetX:f,offsetY:u}}return{canvas:tt.canvas,scaleX:K.scale,scaleY:rt.scale,offsetX:f,offsetY:u}}getSizeAndScale(t,e,i){const n=Math.max(qf.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*i);return r>=n?r=n:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,n,r){const o=n-e,l=r-i;t.ctx.rect(e,i,o,l),Z.axialAlignedBoundingBox([e,i,n,r],ye(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,r=t.current;switch(e){case O0.COLORED:const{fillStyle:o,strokeStyle:l}=this.ctx;n.fillStyle=r.fillColor=o,n.strokeStyle=r.strokeColor=l;break;case O0.UNCOLORED:n.fillStyle=n.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new jS(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,r){let o=i;n!==si.SHADING&&(o=Z.transform(o,e.baseTransform),this.matrix&&(o=Z.transform(o,this.matrix)));const l=this.createPatternCanvas(e,r);let c=new DOMMatrix(o);c=c.translate(l.offsetX,l.offsetY),c=c.scale(1/l.scaleX,1/l.scaleY);const h=t.createPattern(l.canvas,"repeat");return h.setTransform(c),h}};$(qf,"MAX_PATTERN_SIZE",3e3);let nm=qf;function PE({src:a,srcPos:t=0,dest:e,width:i,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const l=ze.isLittleEndian?4278190080:255,[c,h]=o?[r,l]:[l,r],d=i>>3,f=i&7,u=a.length;e=new Uint32Array(e.buffer);let g=0;for(let b=0;b<n;b++){for(const w=t+d;t<w;t++){const y=t<u?a[t]:255;e[g++]=y&128?h:c,e[g++]=y&64?h:c,e[g++]=y&32?h:c,e[g++]=y&16?h:c,e[g++]=y&8?h:c,e[g++]=y&4?h:c,e[g++]=y&2?h:c,e[g++]=y&1?h:c}if(f===0)continue;const m=t<u?a[t++]:255;for(let w=0;w<f;w++)e[g++]=m&1<<7-w?h:c}return{srcPos:t,destPos:g}}const I0=16,L0=100,kE=15,N0=10,Oi=16,sm=new DOMMatrix,Yi=new Float32Array(2),wl=new Float32Array([1/0,1/0,-1/0,-1/0]);function ME(a,t){if(a._removeMirroring)throw new Error("Context is already forwarding operations.");a.__originalSave=a.save,a.__originalRestore=a.restore,a.__originalRotate=a.rotate,a.__originalScale=a.scale,a.__originalTranslate=a.translate,a.__originalTransform=a.transform,a.__originalSetTransform=a.setTransform,a.__originalResetTransform=a.resetTransform,a.__originalClip=a.clip,a.__originalMoveTo=a.moveTo,a.__originalLineTo=a.lineTo,a.__originalBezierCurveTo=a.bezierCurveTo,a.__originalRect=a.rect,a.__originalClosePath=a.closePath,a.__originalBeginPath=a.beginPath,a._removeMirroring=()=>{a.save=a.__originalSave,a.restore=a.__originalRestore,a.rotate=a.__originalRotate,a.scale=a.__originalScale,a.translate=a.__originalTranslate,a.transform=a.__originalTransform,a.setTransform=a.__originalSetTransform,a.resetTransform=a.__originalResetTransform,a.clip=a.__originalClip,a.moveTo=a.__originalMoveTo,a.lineTo=a.__originalLineTo,a.bezierCurveTo=a.__originalBezierCurveTo,a.rect=a.__originalRect,a.closePath=a.__originalClosePath,a.beginPath=a.__originalBeginPath,delete a._removeMirroring},a.save=function(){t.save(),this.__originalSave()},a.restore=function(){t.restore(),this.__originalRestore()},a.translate=function(e,i){t.translate(e,i),this.__originalTranslate(e,i)},a.scale=function(e,i){t.scale(e,i),this.__originalScale(e,i)},a.transform=function(e,i,n,r,o,l){t.transform(e,i,n,r,o,l),this.__originalTransform(e,i,n,r,o,l)},a.setTransform=function(e,i,n,r,o,l){t.setTransform(e,i,n,r,o,l),this.__originalSetTransform(e,i,n,r,o,l)},a.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},a.rotate=function(e){t.rotate(e),this.__originalRotate(e)},a.clip=function(e){t.clip(e),this.__originalClip(e)},a.moveTo=function(e,i){t.moveTo(e,i),this.__originalMoveTo(e,i)},a.lineTo=function(e,i){t.lineTo(e,i),this.__originalLineTo(e,i)},a.bezierCurveTo=function(e,i,n,r,o,l){t.bezierCurveTo(e,i,n,r,o,l),this.__originalBezierCurveTo(e,i,n,r,o,l)},a.rect=function(e,i,n,r){t.rect(e,i,n,r),this.__originalRect(e,i,n,r)},a.closePath=function(){t.closePath(),this.__originalClosePath()},a.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class RE{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let n;return this.cache[t]!==void 0?(n=this.cache[t],this.canvasFactory.reset(n,e,i)):(n=this.canvasFactory.create(e,i),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function kf(a,t,e,i,n,r,o,l,c,h){const[d,f,u,g,b,m]=ye(a);if(f===0&&u===0){const x=o*d+b,E=Math.round(x),_=l*g+m,C=Math.round(_),T=(o+c)*d+b,D=Math.abs(Math.round(T)-E)||1,j=(l+h)*g+m,O=Math.abs(Math.round(j)-C)||1;return a.setTransform(Math.sign(d),0,0,Math.sign(g),E,C),a.drawImage(t,e,i,n,r,0,0,D,O),a.setTransform(d,f,u,g,b,m),[D,O]}if(d===0&&g===0){const x=l*u+b,E=Math.round(x),_=o*f+m,C=Math.round(_),T=(l+h)*u+b,D=Math.abs(Math.round(T)-E)||1,j=(o+c)*f+m,O=Math.abs(Math.round(j)-C)||1;return a.setTransform(0,Math.sign(f),Math.sign(u),0,E,C),a.drawImage(t,e,i,n,r,0,0,O,D),a.setTransform(d,f,u,g,b,m),[O,D]}a.drawImage(t,e,i,n,r,o,l,c,h);const w=Math.hypot(d,f),y=Math.hypot(u,g);return[w*c,y*h]}class F0{constructor(t,e,i){$(this,"alphaIsShape",!1);$(this,"fontSize",0);$(this,"fontSizeScale",1);$(this,"textMatrix",null);$(this,"textMatrixScale",1);$(this,"fontMatrix",Og);$(this,"leading",0);$(this,"x",0);$(this,"y",0);$(this,"lineX",0);$(this,"lineY",0);$(this,"charSpacing",0);$(this,"wordSpacing",0);$(this,"textHScale",1);$(this,"textRenderingMode",je.FILL);$(this,"textRise",0);$(this,"fillColor","#000000");$(this,"strokeColor","#000000");$(this,"patternFill",!1);$(this,"patternStroke",!1);$(this,"fillAlpha",1);$(this,"strokeAlpha",1);$(this,"lineWidth",1);$(this,"activeSMask",null);$(this,"transferMaps","none");i==null||i(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=wl.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=si.FILL,e=null){const i=this.minMax.slice();if(t===si.STROKE){e||ie("Stroke bounding box must include transform."),Z.singularValueDecompose2dScale(e,Yi);const n=Yi[0]*this.lineWidth/2,r=Yi[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}updateClipFromPath(){const t=Z.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(wl,0)}getClippedPathBoundingBox(t=si.FILL,e=null){return Z.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function B0(a,t){if(t instanceof ImageData){a.putImageData(t,0,0);return}const e=t.height,i=t.width,n=e%Oi,r=(e-n)/Oi,o=n===0?r:r+1,l=a.createImageData(i,Oi);let c=0,h;const d=t.data,f=l.data;let u,g,b,m;if(t.kind===uf.GRAYSCALE_1BPP){const w=d.byteLength,y=new Uint32Array(f.buffer,0,f.byteLength>>2),x=y.length,E=i+7>>3,_=4294967295,C=ze.isLittleEndian?4278190080:255;for(u=0;u<o;u++){for(b=u<r?Oi:n,h=0,g=0;g<b;g++){const T=w-c;let D=0;const j=T>E?i:T*8-7,O=j&-8;let H=0,N=0;for(;D<O;D+=8)N=d[c++],y[h++]=N&128?_:C,y[h++]=N&64?_:C,y[h++]=N&32?_:C,y[h++]=N&16?_:C,y[h++]=N&8?_:C,y[h++]=N&4?_:C,y[h++]=N&2?_:C,y[h++]=N&1?_:C;for(;D<j;D++)H===0&&(N=d[c++],H=128),y[h++]=N&H?_:C,H>>=1}for(;h<x;)y[h++]=0;a.putImageData(l,0,u*Oi)}}else if(t.kind===uf.RGBA_32BPP){for(g=0,m=i*Oi*4,u=0;u<r;u++)f.set(d.subarray(c,c+m)),c+=m,a.putImageData(l,0,g),g+=Oi;u<o&&(m=i*n*4,f.set(d.subarray(c,c+m)),a.putImageData(l,0,g))}else if(t.kind===uf.RGB_24BPP)for(b=Oi,m=i*b,u=0;u<o;u++){for(u>=r&&(b=n,m=i*b),h=0,g=m;g--;)f[h++]=d[c++],f[h++]=d[c++],f[h++]=d[c++],f[h++]=255;a.putImageData(l,0,u*Oi)}else throw new Error(`bad image kind: ${t.kind}`)}function j0(a,t){if(t.bitmap){a.drawImage(t.bitmap,0,0);return}const e=t.height,i=t.width,n=e%Oi,r=(e-n)/Oi,o=n===0?r:r+1,l=a.createImageData(i,Oi);let c=0;const h=t.data,d=l.data;for(let f=0;f<o;f++){const u=f<r?Oi:n;({srcPos:c}=PE({src:h,srcPos:c,dest:d,width:i,height:u,nonBlackColor:0})),a.putImageData(l,0,f*Oi)}}function Th(a,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of e)a[i]!==void 0&&(t[i]=a[i]);a.setLineDash!==void 0&&(t.setLineDash(a.getLineDash()),t.lineDashOffset=a.lineDashOffset)}function Mf(a){a.strokeStyle=a.fillStyle="#000000",a.fillRule="nonzero",a.globalAlpha=1,a.lineWidth=1,a.lineCap="butt",a.lineJoin="miter",a.miterLimit=10,a.globalCompositeOperation="source-over",a.font="10px sans-serif",a.setLineDash!==void 0&&(a.setLineDash([]),a.lineDashOffset=0);const{filter:t}=a;t!=="none"&&t!==""&&(a.filter="none")}function z0(a,t){if(t)return!0;Z.singularValueDecompose2dScale(a,Yi);const e=Math.fround(ss.pixelRatio*Br.PDF_TO_CSS_UNITS);return Yi[0]<=e&&Yi[1]<=e}const DE=["butt","round","square"],OE=["miter","round","bevel"],IE={},U0={},km=class km{constructor(t,e,i,n,r,{optionalContentConfig:o,markedContentStack:l=null},c,h,d){v(this,Wn);this.ctx=t,this.current=new F0(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=n,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=l||[],this.optionalContentConfig=o,this.cachedCanvases=new RE(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=c,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=d??null}getObject(t,e,i=null){var n;return typeof e=="string"?((n=this.dependencyTracker)==null||n.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const r=this.ctx.canvas.width,o=this.ctx.canvas.height,l=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,o),this.ctx.fillStyle=l,i){const c=this.cachedCanvases.getCanvas("transparent",r,o);this.compositeCtx=this.ctx,this.transparentCanvas=c.canvas,this.ctx=c.context,this.ctx.save(),this.ctx.transform(...ye(this.compositeCtx))}this.ctx.save(),Mf(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=ye(this.ctx)}executeOperatorList(t,e,i,n,r){var y;const o=t.argsArray,l=t.fnArray;let c=e||0;const h=o.length;if(h===c)return c;const d=h-c>N0&&typeof i=="function",f=d?Date.now()+kE:0;let u=0;const g=this.commonObjs,b=this.objs;let m,w;for(;;){if(n!==void 0&&c===n.nextBreakPoint)return n.breakIt(c,i),c;if(!r||r(c))if(m=l[c],w=o[c]??null,m!==bh.dependency)w===null?this[m](c):this[m](c,...w);else for(const x of w){(y=this.dependencyTracker)==null||y.recordNamedData(x,c);const E=x.startsWith("g_")?g:b;if(!E.has(x))return E.get(x,i),c}if(c++,c===h)return c;if(d&&++u>N0){if(Date.now()>f)return i(),c;u=0}}}endDrawing(){A(this,Wn,ib).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),A(this,Wn,nb).call(this)}_scaleImage(t,e){const i=t.width??t.displayWidth,n=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,c=n,h="prescale1",d,f;for(;r>2&&l>1||o>2&&c>1;){let u=l,g=c;r>2&&l>1&&(u=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/u),o>2&&c>1&&(g=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/g),d=this.cachedCanvases.getCanvas(h,u,g),f=d.context,f.clearRect(0,0,u,g),f.drawImage(t,0,0,l,c,0,0,u,g),t=d.canvas,l=u,c=g,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:c}}_createMaskCanvas(t,e){var H,N;const i=this.ctx,{width:n,height:r}=e,o=this.current.fillColor,l=this.current.patternFill,c=ye(i);let h,d,f,u;if((e.bitmap||e.data)&&e.count>1){const lt=e.bitmap||e.data.buffer;d=JSON.stringify(l?c:[c.slice(0,4),o]),h=this._cachedBitmapsMap.get(lt),h||(h=new Map,this._cachedBitmapsMap.set(lt,h));const G=h.get(d);if(G&&!l){const K=Math.round(Math.min(c[0],c[2])+c[4]),rt=Math.round(Math.min(c[1],c[3])+c[5]);return(H=this.dependencyTracker)==null||H.recordDependencies(t,An.transformAndFill),{canvas:G,offsetX:K,offsetY:rt}}f=G}f||(u=this.cachedCanvases.getCanvas("maskCanvas",n,r),j0(u.context,e));let g=Z.transform(c,[1/n,0,0,-1/r,0,0]);g=Z.transform(g,[1,0,0,1,0,-r]);const b=wl.slice();Z.axialAlignedBoundingBox([0,0,n,r],g,b);const[m,w,y,x]=b,E=Math.round(y-m)||1,_=Math.round(x-w)||1,C=this.cachedCanvases.getCanvas("fillCanvas",E,_),T=C.context,D=m,j=w;T.translate(-D,-j),T.transform(...g),f||(f=this._scaleImage(u.canvas,ns(T)),f=f.img,h&&l&&h.set(d,f)),T.imageSmoothingEnabled=z0(ye(T),e.interpolate),kf(T,f,0,0,f.width,f.height,0,0,n,r),T.globalCompositeOperation="source-in";const O=Z.transform(ns(T),[1,0,0,1,-D,-j]);return T.fillStyle=l?o.getPattern(i,this,O,si.FILL,t):o,T.fillRect(0,0,n,r),h&&!l&&(this.cachedCanvases.delete("fillCanvas"),h.set(d,C.canvas)),(N=this.dependencyTracker)==null||N.recordDependencies(t,An.transformAndFill),{canvas:C.canvas,offsetX:Math.round(D),offsetY:Math.round(j)}}setLineWidth(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineCap",t),this.ctx.lineCap=DE[e]}setLineJoin(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineJoin",t),this.ctx.lineJoin=OE[e]}setMiterLimit(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var i,n,r,o,l;for(const[c,h]of e)switch(c){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(i=this.dependencyTracker)==null||i.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(n=this.dependencyTracker)==null||n.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(o=this.dependencyTracker)==null||o.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(l=this.dependencyTracker)==null||l.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,i);this.suspendedCtx=this.ctx;const o=this.ctx=r.context;o.setTransform(this.suspendedCtx.getTransform()),Th(this.suspendedCtx,o),ME(o,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Th(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,n){const r=n[0],o=n[1],l=n[2]-r,c=n[3]-o;l===0||c===0||(this.genericComposeSMask(e.context,i,l,c,e.subtype,e.backdrop,e.transferMap,r,o,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,n,r,o,l,c,h,d,f){let u=t.canvas,g=c-d,b=h-f;if(o)if(g<0||b<0||g+i>u.width||b+n>u.height){const w=this.cachedCanvases.getCanvas("maskExtension",i,n),y=w.context;y.drawImage(u,-g,-b),y.globalCompositeOperation="destination-atop",y.fillStyle=o,y.fillRect(0,0,i,n),y.globalCompositeOperation="source-over",u=w.canvas,g=b=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const w=new Path2D;w.rect(g,b,i,n),t.clip(w),t.globalCompositeOperation="destination-atop",t.fillStyle=o,t.fillRect(g,b,i,n),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&l?e.filter=this.filterFactory.addAlphaFilter(l):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(l));const m=new Path2D;m.rect(c,h,i,n),e.clip(m),e.globalCompositeOperation="destination-in",e.drawImage(u,g,b,i,n,c,h,i,n),e.restore()}save(t){var i;this.inSMaskMode&&Th(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(i=this.dependencyTracker)==null||i.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Th(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,n,r,o,l){var c;(c=this.dependencyTracker)==null||c.recordIncrementalData("transform",t),this.ctx.transform(e,i,n,r,o,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,n){let[r]=i;if(!n){r||(r=i[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===bh.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-o,n[2]+o,n[1]-o,n[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=i[0]=b0(r)),Z.axialAlignedBoundingBox(n,ye(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){var o;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const l=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,ns(n),si.STROKE,t),l){const c=new Path2D;c.addPath(e,n.getTransform().invertSelf().multiplySelf(l)),e=c}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,An.stroke),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(si.STROKE,ye(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){var h,d,f;const n=this.ctx,r=this.current.fillColor,o=this.current.patternFill;let l=!1;if(o){const u=r.isModifyingCurrentTransform()?n.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),n.save(),n.fillStyle=r.getPattern(n,this,ns(n),si.FILL,t),u){const g=new Path2D;g.addPath(e,n.getTransform().invertSelf().multiplySelf(u)),e=g}l=!0}const c=this.current.getClippedPathBoundingBox();this.contentVisible&&c!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),(d=this.dependencyTracker)==null||d.recordDependencies(t,An.fill),l&&(n.restore(),(f=this.dependencyTracker)==null||f.restore(t)),i&&this.consumePath(t,e,c)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,An.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=IE}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=U0}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,r=i.getTransform().invertSelf();for(const{transform:o,x:l,y:c,fontSize:h,path:d}of e)d&&n.addPath(d,new DOMMatrix(o).preMultiplySelf(r).translate(l,c).scale(h,-h));i.clip(n)}delete this.pendingTextPaths}setCharSpacing(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){var f,u;(f=this.dependencyTracker)==null||f.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||Og,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&pt("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=i,n.isType3Font)return;const o=n.loadedName||"sans-serif",l=((u=n.systemFontInfo)==null?void 0:u.css)||`"${o}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const h=n.italic?"italic":"normal";let d=i;i<I0?d=I0:i>L0&&(d=L0),this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${c} ${d}px ${l}`}setTextRenderingMode(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,i,n,r,o){var y,x,E,_;const l=this.ctx,c=this.current,h=c.font,d=c.textRenderingMode,f=c.fontSize/c.fontSizeScale,u=d&je.FILL_STROKE_MASK,g=!!(d&je.ADD_TO_PATH_FLAG),b=c.patternFill&&!h.missingFile,m=c.patternStroke&&!h.missingFile;let w;if((h.disableFontFace||g||b||m)&&!h.missingFile&&(w=h.getPathGenerator(this.commonObjs,e)),w&&(h.disableFontFace||b||m)){l.save(),l.translate(i,n),l.scale(f,-f),(y=this.dependencyTracker)==null||y.recordCharacterBBox(t,l,h);let C;if(u===je.FILL||u===je.FILL_STROKE)if(r){C=l.getTransform(),l.setTransform(...r);const T=A(this,Wn,sb).call(this,w,C,r);l.fill(T)}else l.fill(w);if(u===je.STROKE||u===je.FILL_STROKE)if(o){C||(C=l.getTransform()),l.setTransform(...o);const{a:T,b:D,c:j,d:O}=C,H=Z.inverseTransform(o),N=Z.transform([T,D,j,O,0,0],H);Z.singularValueDecompose2dScale(N,Yi),l.lineWidth*=Math.max(Yi[0],Yi[1])/f,l.stroke(A(this,Wn,sb).call(this,w,C,o))}else l.lineWidth/=f,l.stroke(w);l.restore()}else(u===je.FILL||u===je.FILL_STROKE)&&(l.fillText(e,i,n),(x=this.dependencyTracker)==null||x.recordCharacterBBox(t,l,h,f,i,n,()=>l.measureText(e))),(u===je.STROKE||u===je.FILL_STROKE)&&(this.dependencyTracker&&((E=this.dependencyTracker)==null||E.recordCharacterBBox(t,l,h,f,i,n,()=>l.measureText(e)).recordDependencies(t,An.stroke)),l.strokeText(e,i,n));g&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:ye(l),x:i,y:n,fontSize:f,path:w}),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,l,h,f,i,n))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){i=!0;break}return gt(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var N,lt,G,K;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,An.showText).resetBBox(t),this.current.textRenderingMode&je.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,n=i.font;if(n.isType3Font){this.showType3Text(t,e),(N=this.dependencyTracker)==null||N.recordShowTextOperation(t);return}const r=i.fontSize;if(r===0){(lt=this.dependencyTracker)==null||lt.recordOperation(t);return}const o=this.ctx,l=i.fontSizeScale,c=i.charSpacing,h=i.wordSpacing,d=i.fontDirection,f=i.textHScale*d,u=e.length,g=n.vertical,b=g?1:-1,m=n.defaultVMetrics,w=r*i.fontMatrix[0],y=i.textRenderingMode===je.FILL&&!n.disableFontFace&&!i.patternFill;o.save(),i.textMatrix&&o.transform(...i.textMatrix),o.translate(i.x,i.y+i.textRise),d>0?o.scale(f,-1):o.scale(f,1);let x,E;const _=i.textRenderingMode&je.FILL_STROKE_MASK,C=_===je.FILL||_===je.FILL_STROKE,T=_===je.STROKE||_===je.FILL_STROKE;if(C&&i.patternFill){o.save();const rt=i.fillColor.getPattern(o,this,ns(o),si.FILL,t);x=ye(o),o.restore(),o.fillStyle=rt}if(T&&i.patternStroke){o.save();const rt=i.strokeColor.getPattern(o,this,ns(o),si.STROKE,t);E=ye(o),o.restore(),o.strokeStyle=rt}let D=i.lineWidth;const j=i.textMatrixScale;if(j===0||D===0?T&&(D=this.getSinglePixelWidth()):D/=j,l!==1&&(o.scale(l,l),D/=l),o.lineWidth=D,n.isInvalidPDFjsFont){const rt=[];let tt=0;for(const ct of e)rt.push(ct.unicode),tt+=ct.width;const J=rt.join("");if(o.fillText(J,0,0),this.dependencyTracker!==null){const ct=o.measureText(J);this.dependencyTracker.recordBBox(t,this.ctx,-ct.actualBoundingBoxLeft,ct.actualBoundingBoxRight,-ct.actualBoundingBoxAscent,ct.actualBoundingBoxDescent).recordShowTextOperation(t)}i.x+=tt*w*f,o.restore(),this.compose();return}let O=0,H;for(H=0;H<u;++H){const rt=e[H];if(typeof rt=="number"){O+=b*rt*r/1e3;continue}let tt=!1;const J=(rt.isSpace?h:0)+c,ct=rt.fontChar,Dt=rt.accent;let Ot,jt,vt=rt.width;if(g){const Nt=rt.vmetric||m,he=-(rt.vmetric?Nt[1]:vt*.5)*w,St=Nt[2]*w;vt=Nt?-Nt[0]:vt,Ot=he/l,jt=(O+St)/l}else Ot=O/l,jt=0;let Ct;if(n.remeasure&&vt>0){Ct=o.measureText(ct);const Nt=Ct.width*1e3/r*l;if(vt<Nt&&this.isFontSubpixelAAEnabled){const he=vt/Nt;tt=!0,o.save(),o.scale(he,1),Ot/=he}else vt!==Nt&&(Ot+=(vt-Nt)/2e3*r/l)}if(this.contentVisible&&(rt.isInFont||n.missingFile)){if(y&&!Dt)o.fillText(ct,Ot,jt),(G=this.dependencyTracker)==null||G.recordCharacterBBox(t,o,Ct?{bbox:null}:n,r/l,Ot,jt,()=>Ct??o.measureText(ct));else if(this.paintChar(t,ct,Ot,jt,x,E),Dt){const Nt=Ot+r*Dt.offset.x/l,he=jt-r*Dt.offset.y/l;this.paintChar(t,Dt.fontChar,Nt,he,x,E)}}const Ae=g?vt*w-J*d:vt*w+J*d;O+=Ae,tt&&o.restore()}g?i.y-=O:i.x+=O*f,o.restore(),this.compose(),(K=this.dependencyTracker)==null||K.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,n=this.current,r=n.font,o=n.fontSize,l=n.fontDirection,c=r.vertical?1:-1,h=n.charSpacing,d=n.wordSpacing,f=n.textHScale*l,u=n.fontMatrix||Og,g=e.length,b=n.textRenderingMode===je.INVISIBLE;let m,w,y,x;if(b||o===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),n.textMatrix&&i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),i.scale(f,l);const E=this.dependencyTracker;for(this.dependencyTracker=E?new Pf(E,t):null,m=0;m<g;++m){if(w=e[m],typeof w=="number"){x=c*w*o/1e3,this.ctx.translate(x,0),n.x+=x*f;continue}const _=(w.isSpace?d:0)+h,C=r.charProcOperatorList[w.operatorListId];C?this.contentVisible&&(this.save(),i.scale(o,o),i.transform(...u),this.executeOperatorList(C),this.restore()):pt(`Type3 character "${w.operatorListId}" is not available.`);const T=[w.width,0];Z.applyTransform(T,u),y=T[0]*o+_,i.translate(y,0),n.x+=y*f}i.restore(),E&&(this.dependencyTracker=E)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,n,r,o,l){var h;const c=new Path2D;c.rect(n,r,o-n,l-r),this.ctx.clip(c),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,n,o,r,l).recordClipBox(t,this.ctx,n,o,r,l),this.endPath(t)}getColorN_Pattern(t,e){let i;if(e[0]==="TilingPattern"){const n=this.baseTransform||ye(this.ctx),r={createCanvasGraphics:(o,l)=>new km(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new Pf(this.dependencyTracker,l,!0):null)};i=new nm(e,this.ctx,r,n)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=TE(this.getObject(t,e)),this.cachedPatterns.set(e,n)),i&&(n.matrix=i),n}shadingFill(t,e){var o;if(!this.contentVisible)return;const i=this.ctx;this.save(t);const n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,ns(i),si.SHADING,t);const r=ns(i);if(r){const{width:l,height:c}=i.canvas,h=wl.slice();Z.axialAlignedBoundingBox([0,0,l,c],r,h);const[d,f,u,g]=h;this.ctx.fillRect(d,f,u-d,g-f)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,An.transform).recordDependencies(t,An.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){ie("Should not call beginInlineImage")}beginImageData(){ie("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){var n;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=ye(this.ctx),i)){Z.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[r,o,l,c]=i,h=new Path2D;h.rect(r,o,l-r,c-o),this.ctx.clip(h),(n=this.dependencyTracker)==null||n.recordClipBox(t,this.ctx,r,l,o,c),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var E;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;e.isolated||gf("TODO: Support non-isolated groups."),e.knockout&&pt("Knockout groups not supported.");const n=ye(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=wl.slice();Z.axialAlignedBoundingBox(e.bbox,ye(i),r);const o=[0,0,i.canvas.width,i.canvas.height];r=Z.intersect(r,o)||[0,0,0,0];const l=Math.floor(r[0]),c=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-l,1),d=Math.max(Math.ceil(r[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);let f="groupAt"+this.groupLevel;e.smask&&(f+="_smask_"+this.smaskCounter++%2);const u=this.cachedCanvases.getCanvas(f,h,d),g=u.context;g.translate(-l,-c),g.transform(...n);let b=new Path2D;const[m,w,y,x]=e.bbox;if(b.rect(m,w,y-m,x-w),e.matrix){const _=new Path2D;_.addPath(b,new DOMMatrix(e.matrix)),b=_}g.clip(b),e.smask&&this.smaskStack.push({canvas:u.canvas,context:g,offsetX:l,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,c),i.save()),Th(i,g),this.ctx=g,(E=this.dependencyTracker)==null||E.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const o=ye(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=wl.slice();Z.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],o,l),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(l)}}beginAnnotation(t,e,i,n,r,o){if(A(this,Wn,ib).call(this),Mf(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const l=i[2]-i[0],c=i[3]-i[1];if(o&&this.annotationCanvasMap){n=n.slice(),n[4]-=i[0],n[5]-=i[1],i=i.slice(),i[0]=i[1]=0,i[2]=l,i[3]=c,Z.singularValueDecompose2dScale(ye(this.ctx),Yi);const{viewportScale:h}=this,d=Math.ceil(l*this.outputScaleX*h),f=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,f);const{canvas:u,context:g}=this.annotationCanvas;this.annotationCanvasMap.set(e,u),this.annotationCanvas.savedCtx=this.ctx,this.ctx=g,this.ctx.save(),this.ctx.setTransform(Yi[0],0,0,-Yi[1],0,c*Yi[1]),Mf(this.ctx)}else{Mf(this.ctx),this.endPath(t);const h=new Path2D;h.rect(i[0],i[1],l,c),this.ctx.clip(h)}}this.current=new F0(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...n),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),A(this,Wn,nb).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const i=e.count;e=this.getObject(t,e.data,e),e.count=i;const n=this.ctx,r=this._createMaskCanvas(t,e),o=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,r.offsetX,r.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+o.width,r.offsetY,r.offsetY+o.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,n=0,r=0,o,l){var f,u,g;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const c=this.ctx;c.save();const h=ye(c);c.transform(i,n,r,o,0,0);const d=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),(f=this.dependencyTracker)==null||f.resetBBox(t);for(let b=0,m=l.length;b<m;b+=2){const w=Z.transform(h,[i,n,r,o,l[b],l[b+1]]);c.drawImage(d.canvas,w[4],w[5]),(u=this.dependencyTracker)==null||u.recordBBox(t,this.ctx,w[4],w[4]+d.canvas.width,w[5],w[5]+d.canvas.height)}c.restore(),this.compose(),(g=this.dependencyTracker)==null||g.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var o,l,c;if(!this.contentVisible)return;const i=this.ctx,n=this.current.fillColor,r=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,An.transformAndFill);for(const h of e){const{data:d,width:f,height:u,transform:g}=h,b=this.cachedCanvases.getCanvas("maskCanvas",f,u),m=b.context;m.save();const w=this.getObject(t,d,h);j0(m,w),m.globalCompositeOperation="source-in",m.fillStyle=r?n.getPattern(m,this,ns(i),si.FILL,t):n,m.fillRect(0,0,f,u),m.restore(),i.save(),i.transform(...g),i.scale(1,-1),kf(i,b.canvas,0,0,f,u,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,f,0,u),i.restore()}this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);if(!i){pt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,i)}paintImageXObjectRepeat(t,e,i,n,r){if(!this.contentVisible)return;const o=this.getObject(t,e);if(!o){pt("Dependent image isn't ready yet");return}const l=o.width,c=o.height,h=[];for(let d=0,f=r.length;d<f;d+=2)h.push({transform:[i,0,0,n,r[d],r[d+1]],x:0,y:0,w:l,h:c});this.paintInlineImageXObjectGroup(t,o,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:i,height:n}=t,r=this.cachedCanvases.getCanvas("inlineImage",i,n),o=r.context;return o.filter=this.current.transferMaps,o.drawImage(e,0,0),o.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const i=e.width,n=e.height,r=this.ctx;this.save(t);const{filter:o}=r;o!=="none"&&o!==""&&(r.filter="none"),r.scale(1/i,-1/n);let l;if(e.bitmap)l=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)l=e;else{const f=this.cachedCanvases.getCanvas("inlineImage",i,n).context;B0(f,e),l=this.applyTransferMapsToCanvas(f)}const c=this._scaleImage(l,ns(r));r.imageSmoothingEnabled=z0(ye(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,i,-n,0).recordDependencies(t,An.imageXObject).recordOperation(t),kf(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-n,i,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){var o,l,c;if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,d=e.height,u=this.cachedCanvases.getCanvas("inlineImage",h,d).context;B0(u,e),r=this.applyTransferMapsToCanvas(u)}(o=this.dependencyTracker)==null||o.resetBBox(t);for(const h of i)n.save(),n.transform(...h.transform),n.scale(1,-1),kf(n,r,h.x,h.y,h.w,h.h,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(t,n,0,1,-1,0),n.restore();(c=this.dependencyTracker)==null||c.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,An.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){var o,l;const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===U0?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(o=this.dependencyTracker)==null||o.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(l=this.dependencyTracker)==null||l.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ye(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:r}=this.ctx.getTransform();let o,l;if(i===0&&n===0){const c=Math.abs(e),h=Math.abs(r);if(c===h)if(t===0)o=l=1/c;else{const d=c*t;o=l=d<1?1/d:1}else if(t===0)o=1/c,l=1/h;else{const d=c*t,f=h*t;o=d<1?1/d:1,l=f<1?1/f:1}}else{const c=Math.abs(e*r-i*n),h=Math.hypot(e,i),d=Math.hypot(n,r);if(t===0)o=d/c,l=h/c;else{const f=t*c;o=d>f?d/f:1,l=h>f?h/f:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=l}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:n}}=this,[r,o]=this.getScaleForStroking();if(r===o){i.lineWidth=(n||1)*r,i.stroke(t);return}const l=i.getLineDash();e&&i.save(),i.scale(r,o),sm.a=1/r,sm.d=1/o;const c=new Path2D;if(c.addPath(t,sm),l.length>0){const h=Math.max(r,o);i.setLineDash(l.map(d=>d/h)),i.lineDashOffset/=h}i.lineWidth=n||1,i.stroke(c),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Wn=new WeakSet,ib=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)},nb=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},sb=function(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n};let Al=km;for(const a in bh)Al.prototype[a]!==void 0&&(Al.prototype[bh[a]]=Al.prototype[a]);class os{static get workerPort(){return s(this,Sd)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");p(this,Sd,t)}static get workerSrc(){return s(this,Ed)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");p(this,Ed,t)}}Sd=new WeakMap,Ed=new WeakMap,v(os,Sd,null),v(os,Ed,"");class LE{constructor({parsedData:t,rawData:e}){v(this,lc);v(this,xd);p(this,lc,t),p(this,xd,e)}getRaw(){return s(this,xd)}get(t){return s(this,lc).get(t)??null}[Symbol.iterator](){return s(this,lc).entries()}}lc=new WeakMap,xd=new WeakMap;const Sl=Symbol("INTERNAL");class NE{constructor(t,{name:e,intent:i,usage:n,rbGroups:r}){v(this,Cd,!1);v(this,_d,!1);v(this,Td,!1);v(this,cc,!0);p(this,Cd,!!(t&Gi.DISPLAY)),p(this,_d,!!(t&Gi.PRINT)),this.name=e,this.intent=i,this.usage=n,this.rbGroups=r}get visible(){if(s(this,Td))return s(this,cc);if(!s(this,cc))return!1;const{print:t,view:e}=this.usage;return s(this,Cd)?(e==null?void 0:e.viewState)!=="OFF":s(this,_d)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,i=!1){t!==Sl&&ie("Internal method `_setVisible` called."),p(this,Td,i),p(this,cc,e)}}Cd=new WeakMap,_d=new WeakMap,Td=new WeakMap,cc=new WeakMap;class FE{constructor(t,e=Gi.DISPLAY){v(this,Pd);v(this,oo,null);v(this,Qt,new Map);v(this,hc,null);v(this,dc,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,p(this,dc,t.order);for(const i of t.groups)s(this,Qt).set(i.id,new NE(e,i));if(t.baseState==="OFF")for(const i of s(this,Qt).values())i._setVisible(Sl,!1);for(const i of t.on)s(this,Qt).get(i)._setVisible(Sl,!0);for(const i of t.off)s(this,Qt).get(i)._setVisible(Sl,!1);p(this,hc,this.getHash())}}isVisible(t){if(s(this,Qt).size===0)return!0;if(!t)return gf("Optional content group not defined."),!0;if(t.type==="OCG")return s(this,Qt).has(t.id)?s(this,Qt).get(t.id).visible:(pt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return A(this,Pd,rb).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(s(this,Qt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!s(this,Qt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!s(this,Qt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(s(this,Qt).get(e).visible)return!1}return!0}return pt(`Unknown optional content policy ${t.policy}.`),!0}return pt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){var r;const n=s(this,Qt).get(t);if(!n){pt(`Optional content group not found: ${t}`);return}if(i&&e&&n.rbGroups.length)for(const o of n.rbGroups)for(const l of o)l!==t&&((r=s(this,Qt).get(l))==null||r._setVisible(Sl,!1,!0));n._setVisible(Sl,!!e,!0),p(this,oo,null)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const r=s(this,Qt).get(n);if(r)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!r.visible,e);break}}p(this,oo,null)}get hasInitialVisibility(){return s(this,hc)===null||this.getHash()===s(this,hc)}getOrder(){return s(this,Qt).size?s(this,dc)?s(this,dc).slice():[...s(this,Qt).keys()]:null}getGroup(t){return s(this,Qt).get(t)||null}getHash(){if(s(this,oo)!==null)return s(this,oo);const t=new w0;for(const[e,i]of s(this,Qt))t.update(`${e}:${i.visible}`);return p(this,oo,t.hexdigest())}[Symbol.iterator](){return s(this,Qt).entries()}}oo=new WeakMap,Qt=new WeakMap,hc=new WeakMap,dc=new WeakMap,Pd=new WeakSet,rb=function(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const r=t[n];let o;if(Array.isArray(r))o=A(this,Pd,rb).call(this,r);else if(s(this,Qt).has(r))o=s(this,Qt).get(r).visible;else return pt(`Optional content group not found: ${r}`),!0;switch(i){case"And":if(!o)return!1;break;case"Or":if(o)return!0;break;case"Not":return!o;default:return!0}}return i==="And"};class BE{constructor(t,{disableRange:e=!1,disableStream:i=!1}){Rt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:r,progressiveDone:o,contentDispositionFilename:l}=t;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=l,(r==null?void 0:r.length)>0){const c=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(c)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((c,h)=>{this._onReceiveData({begin:c,chunk:h})}),t.addProgressListener((c,h)=>{this._onProgress({loaded:c,total:h})}),t.addProgressiveReadListener(c=>{this._onReceiveData({chunk:c})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{const n=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(i),!0)});Rt(n,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,i,n,r;t.total===void 0?(i=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||i.call(e,{loaded:t.loaded}):(r=(n=this._fullRequestReader)==null?void 0:n.onProgress)==null||r.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Rt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new jE(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new zE(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeReaders.slice(0))i.cancel(t);this._pdfDataRangeTransport.abort()}}class jE{constructor(t,e,i=!1,n=null){this._stream=t,this._done=i||!1,this._filename=Ug(n)?n:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class zE{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function UE(a){let t=!0,e=i("filename\\*","i").exec(a);if(e){e=e[1];let d=l(e);return d=unescape(d),d=c(d),d=h(d),r(d)}if(e=o(a),e){const d=h(e);return r(d)}if(e=i("filename","i").exec(a),e){e=e[1];let d=l(e);return d=h(d),r(d)}function i(d,f){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',f)}function n(d,f){if(d){if(!/^[\x00-\xFF]+$/.test(f))return f;try{const u=new TextDecoder(d,{fatal:!0}),g=vh(f);f=u.decode(g),t=!1}catch{}}return f}function r(d){return t&&/[\x80-\xff]/.test(d)&&(d=n("utf-8",d),t&&(d=n("iso-8859-1",d))),d}function o(d){const f=[];let u;const g=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(u=g.exec(d))!==null;){let[,m,w,y]=u;if(m=parseInt(m,10),m in f){if(m===0)break;continue}f[m]=[w,y]}const b=[];for(let m=0;m<f.length&&m in f;++m){let[w,y]=f[m];y=l(y),w&&(y=unescape(y),m===0&&(y=c(y))),b.push(y)}return b.join("")}function l(d){if(d.startsWith('"')){const f=d.slice(1).split('\\"');for(let u=0;u<f.length;++u){const g=f[u].indexOf('"');g!==-1&&(f[u]=f[u].slice(0,g),f.length=u+1),f[u]=f[u].replaceAll(/\\(.)/g,"$1")}d=f.join('"')}return d}function c(d){const f=d.indexOf("'");if(f===-1)return d;const u=d.slice(0,f),b=d.slice(f+1).replace(/^[^']*'/,"");return n(u,b)}function h(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(f,u,g,b){if(g==="q"||g==="Q")return b=b.replaceAll("_"," "),b=b.replaceAll(/=([0-9a-fA-F]{2})/g,function(m,w){return String.fromCharCode(parseInt(w,16))}),n(u,b);try{b=atob(b)}catch{}return n(u,b)})}return""}function H0(a,t){const e=new Headers;if(!a||!t||typeof t!="object")return e;for(const i in t){const n=t[i];n!==void 0&&e.append(i,n)}return e}function Rf(a){var t;return((t=URL.parse(a))==null?void 0:t.origin)??null}function $0({responseHeaders:a,isHttp:t,rangeChunkSize:e,disableRange:i}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(a.get("Content-Length"),10);return!Number.isInteger(r)||(n.suggestedLength=r,r<=2*e)||i||!t||a.get("Accept-Ranges")!=="bytes"||(a.get("Content-Encoding")||"identity")!=="identity"||(n.allowRangeRequests=!0),n}function W0(a){const t=a.get("Content-Disposition");if(t){let e=UE(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ug(e))return e}return null}function Ph(a,t){return new mf(`Unexpected server response (${a}) while retrieving PDF "${t}".`,a,a===404||a===0&&t.startsWith("file:"))}function V0(a){return a===200||a===206}function G0(a,t,e){return{method:"GET",headers:a,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Y0(a){return a instanceof Uint8Array?a.buffer:a instanceof ArrayBuffer?a:(pt(`getArrayBuffer - unexpected data format: ${a}`),new Uint8Array(a).buffer)}class HE{constructor(t){$(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=H0(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Rt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new $E(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new WE(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class $E{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),n=e.url;fetch(n,G0(i,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=Rf(r.url),!V0(r.status))throw Ph(r.status,n);this._reader=r.body.getReader(),this._headersCapability.resolve();const o=r.headers,{allowRangeRequests:l,suggestedLength:c}=$0({responseHeaders:o,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=l,this._contentLength=c||this._contentLength,this._filename=W0(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Fr("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 i;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded,total:this._contentLength}),{value:Y0(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class WE{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`);const o=n.url;fetch(o,G0(r,this._withCredentials,this._abortController)).then(l=>{const c=Rf(l.url);if(c!==t._responseOrigin)throw new Error(`Expected range response-origin "${c}" to match "${t._responseOrigin}".`);if(!V0(l.status))throw Ph(l.status,o);this._readCapability.resolve(),this._reader=l.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var i;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded}),{value:Y0(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const rm=200,om=206;function VE(a){const t=a.response;return typeof t!="string"?t:vh(t).buffer}class GE{constructor({url:t,httpHeaders:e,withCredentials:i}){$(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=H0(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,n=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,o]of this.headers)e.setRequestHeader(r,o);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),n.expectedStatus=om):n.expectedStatus=rm,e.responseType="arraybuffer",Rt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){var n;const i=this.pendingRequests[t];i&&((n=i.onProgress)==null||n.call(i,e))}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const n=i.xhr;if(n.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),n.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],n.status===0&&this.isHttp){i.onError(n.status);return}const r=n.status||rm;if(!(r===rm&&i.expectedStatus===om)&&r!==i.expectedStatus){i.onError(n.status);return}const l=VE(n);if(r===om){const c=n.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);h?i.onDone({begin:parseInt(h[1],10),chunk:l}):(pt('Missing or invalid "Content-Range" header.'),i.onError(0))}else l?i.onDone({begin:0,chunk:l}):i.onError(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class YE{constructor(t){this._source=t,this._manager=new GE(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 Rt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new XE(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new qE(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class XE{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=Rf(e.responseURL);const i=e.getAllResponseHeaders(),n=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(l=>{const[c,...h]=l.split(": ");return[c,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:o}=$0({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=W0(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Ph(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class qE{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var e;const t=Rf((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=Ph(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const KE=/^[a-z][a-z0-9\-+.]+:/i;function JE(a){if(KE.test(a))return new URL(a);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(a))}class ZE{constructor(t){this.source=t,this.url=JE(t.url),Rt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Rt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new QE(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new tx(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class QE{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(n=>{this._contentLength=n.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},n=>{n.code==="ENOENT"&&(n=Ph(0,this._url.href)),this._storedError=n,this._headersCapability.reject(n)})}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 i;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Fr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class tx{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const n=t.source;this._isStreamingSupported=!n.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var i;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const kh=Symbol("INITIAL_DATA");class X0{constructor(){v(this,kd);v(this,Zi,Object.create(null))}get(t,e=null){if(e){const n=A(this,kd,ob).call(this,t);return n.promise.then(()=>e(n.data)),null}const i=s(this,Zi)[t];if(!i||i.data===kh)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=s(this,Zi)[t];return!!e&&e.data!==kh}delete(t){const e=s(this,Zi)[t];return!e||e.data===kh?!1:(delete s(this,Zi)[t],!0)}resolve(t,e=null){const i=A(this,kd,ob).call(this,t);i.data=e,i.resolve()}clear(){var t;for(const e in s(this,Zi)){const{data:i}=s(this,Zi)[e];(t=i==null?void 0:i.bitmap)==null||t.close()}p(this,Zi,Object.create(null))}*[Symbol.iterator](){for(const t in s(this,Zi)){const{data:e}=s(this,Zi)[t];e!==kh&&(yield[t,e])}}}Zi=new WeakMap,kd=new WeakSet,ob=function(t){var e;return(e=s(this,Zi))[t]||(e[t]={...Promise.withResolvers(),data:kh})};const ex=1e5,q0=30,ci=class ci{constructor({textContentSource:t,container:e,viewport:i}){v(this,sr);v(this,ao,Promise.withResolvers());v(this,Qi,null);v(this,Md,!1);v(this,Rd,!!((cv=globalThis.FontInspector)!=null&&cv.enabled));v(this,wa,null);v(this,nr,null);v(this,Dd,0);v(this,Od,0);v(this,Aa,null);v(this,Id,null);v(this,uc,0);v(this,lo,0);v(this,fc,Object.create(null));v(this,Ld,[]);v(this,pc,null);v(this,Sa,[]);v(this,Nd,new WeakMap);v(this,Fd,null);var c;if(t instanceof ReadableStream)p(this,pc,t);else if(typeof t=="object")p(this,pc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');p(this,Qi,p(this,Id,e)),p(this,lo,i.scale*ss.pixelRatio),p(this,uc,i.rotation),p(this,nr,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:o,pageY:l}=i.rawDims;p(this,Fd,[1,0,0,-1,-o,l+r]),p(this,Od,n),p(this,Dd,r),A(c=ci,tn,iw).call(c),e.style.setProperty("--min-font-size",s(ci,mc)),Bo(e,i),s(this,ao).promise.finally(()=>{s(ci,bc).delete(this),p(this,nr,null),p(this,fc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=ze.platform;return gt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{s(this,Aa).read().then(({value:e,done:i})=>{if(i){s(this,ao).resolve();return}s(this,wa)??p(this,wa,e.lang),Object.assign(s(this,fc),e.styles),A(this,sr,tw).call(this,e.items),t()},s(this,ao).reject)};return p(this,Aa,s(this,pc).getReader()),s(ci,bc).add(this),t(),s(this,ao).promise}update({viewport:t,onBefore:e=null}){var r;const i=t.scale*ss.pixelRatio,n=t.rotation;if(n!==s(this,uc)&&(e==null||e(),p(this,uc,n),Bo(s(this,Id),{rotation:n})),i!==s(this,lo)){e==null||e(),p(this,lo,i);const o={div:null,properties:null,ctx:A(r=ci,tn,Tp).call(r,s(this,wa))};for(const l of s(this,Sa))o.properties=s(this,Nd).get(l),o.div=l,A(this,sr,ab).call(this,o)}}cancel(){var e;const t=new Fr("TextLayer task cancelled.");(e=s(this,Aa))==null||e.cancel(t).catch(()=>{}),p(this,Aa,null),s(this,ao).reject(t)}get textDivs(){return s(this,Sa)}get textContentItemsStr(){return s(this,Ld)}static cleanup(){if(!(s(this,bc).size>0)){s(this,gc).clear();for(const{canvas:t}of s(this,Ea).values())t.remove();s(this,Ea).clear()}}};ao=new WeakMap,Qi=new WeakMap,Md=new WeakMap,Rd=new WeakMap,wa=new WeakMap,nr=new WeakMap,Dd=new WeakMap,Od=new WeakMap,Aa=new WeakMap,Id=new WeakMap,uc=new WeakMap,lo=new WeakMap,fc=new WeakMap,Ld=new WeakMap,pc=new WeakMap,Sa=new WeakMap,Nd=new WeakMap,Fd=new WeakMap,gc=new WeakMap,Ea=new WeakMap,Bd=new WeakMap,mc=new WeakMap,bc=new WeakMap,sr=new WeakSet,tw=function(t){var n,r;if(s(this,Md))return;(r=s(this,nr)).ctx??(r.ctx=A(n=ci,tn,Tp).call(n,s(this,wa)));const e=s(this,Sa),i=s(this,Ld);for(const o of t){if(e.length>ex){pt("Ignoring additional textDivs for performance reasons."),p(this,Md,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const l=s(this,Qi);p(this,Qi,document.createElement("span")),s(this,Qi).classList.add("markedContent"),o.id&&s(this,Qi).setAttribute("id",`${o.id}`),l.append(s(this,Qi))}else o.type==="endMarkedContent"&&p(this,Qi,s(this,Qi).parentNode);continue}i.push(o.str),A(this,sr,ew).call(this,o)}},ew=function(t){var b;const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};s(this,Sa).push(e);const n=Z.transform(s(this,Fd),t.transform);let r=Math.atan2(n[1],n[0]);const o=s(this,fc)[t.fontName];o.vertical&&(r+=Math.PI/2);let l=s(this,Rd)&&o.fontSubstitution||o.fontFamily;l=ci.fontFamilyMap.get(l)||l;const c=Math.hypot(n[2],n[3]),h=c*A(b=ci,tn,nw).call(b,l,o,s(this,wa));let d,f;r===0?(d=n[4],f=n[5]-h):(d=n[4]+h*Math.sin(r),f=n[5]-h*Math.cos(r));const u=e.style;u.left=`${(100*d/s(this,Od)).toFixed(2)}%`,u.top=`${(100*f/s(this,Dd)).toFixed(2)}%`,u.setProperty("--font-height",`${c.toFixed(2)}px`),u.fontFamily=l,i.fontSize=c,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,s(this,Rd)&&(e.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),r!==0&&(i.angle=r*(180/Math.PI));let g=!1;if(t.str.length>1)g=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const m=Math.abs(t.transform[0]),w=Math.abs(t.transform[3]);m!==w&&Math.max(m,w)/Math.min(m,w)>1.5&&(g=!0)}if(g&&(i.canvasWidth=o.vertical?t.height:t.width),s(this,Nd).set(e,i),s(this,nr).div=e,s(this,nr).properties=i,A(this,sr,ab).call(this,s(this,nr)),i.hasText&&s(this,Qi).append(e),i.hasEOL){const m=document.createElement("br");m.setAttribute("role","presentation"),s(this,Qi).append(m)}},ab=function(t){var o;const{div:e,properties:i,ctx:n}=t,{style:r}=e;if(i.canvasWidth!==0&&i.hasText){const{fontFamily:l}=r,{canvasWidth:c,fontSize:h}=i;A(o=ci,tn,lb).call(o,n,h*s(this,lo),l);const{width:d}=n.measureText(e.textContent);d>0&&r.setProperty("--scale-x",c*s(this,lo)/d)}i.angle!==0&&r.setProperty("--rotate",`${i.angle}deg`)},tn=new WeakSet,Tp=function(t=null){let e=s(this,Ea).get(t||(t=""));if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),s(this,Ea).set(t,e),s(this,Bd).set(e,{size:0,family:""})}return e},lb=function(t,e,i){const n=s(this,Bd).get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)},iw=function(){if(s(this,mc)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),p(this,mc,t.getBoundingClientRect().height),t.remove()},nw=function(t,e,i){const n=s(this,gc).get(t);if(n)return n;const r=A(this,tn,Tp).call(this,i);r.canvas.width=r.canvas.height=q0,A(this,tn,lb).call(this,r,q0,t);const o=r.measureText(""),l=o.fontBoundingBoxAscent,c=Math.abs(o.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return l?h=l/(l+c):(ze.platform.isFirefox&&pt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),s(this,gc).set(t,h),h},v(ci,tn),v(ci,gc,new Map),v(ci,Ea,new Map),v(ci,Bd,new WeakMap),v(ci,mc,null),v(ci,bc,new Set);let Mh=ci;const ix=100;function K0(a={}){typeof a=="string"||a instanceof URL?a={url:a}:(a instanceof ArrayBuffer||ArrayBuffer.isView(a))&&(a={data:a});const t=new am,{docId:e}=t,i=a.url?cE(a.url):null,n=a.data?hE(a.data):null,r=a.httpHeaders||null,o=a.withCredentials===!0,l=a.password??null,c=a.range instanceof J0?a.range:null,h=Number.isInteger(a.rangeChunkSize)&&a.rangeChunkSize>0?a.rangeChunkSize:2**16;let d=a.worker instanceof Rh?a.worker:null;const f=a.verbosity,u=typeof a.docBaseUrl=="string"&&!bf(a.docBaseUrl)?a.docBaseUrl:null,g=xf(a.cMapUrl),b=a.cMapPacked!==!1,m=a.CMapReaderFactory||(Si?yE:C0),w=xf(a.iccUrl),y=xf(a.standardFontDataUrl),x=a.StandardFontDataFactory||(Si?vE:P0),E=xf(a.wasmUrl),_=a.WasmFactory||(Si?wE:M0),C=a.stopAtErrors!==!0,T=Number.isInteger(a.maxImageSize)&&a.maxImageSize>-1?a.maxImageSize:-1,D=a.isEvalSupported!==!1,j=typeof a.isOffscreenCanvasSupported=="boolean"?a.isOffscreenCanvasSupported:!Si,O=typeof a.isImageDecoderSupported=="boolean"?a.isImageDecoderSupported:!Si&&(ze.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(a.canvasMaxAreaInBytes)?a.canvasMaxAreaInBytes:-1,N=typeof a.disableFontFace=="boolean"?a.disableFontFace:Si,lt=a.fontExtraProperties===!0,G=a.enableXfa===!0,K=a.ownerDocument||globalThis.document,rt=a.disableRange===!0,tt=a.disableStream===!0,J=a.disableAutoFetch===!0,ct=a.pdfBug===!0,Dt=a.CanvasFactory||(Si?bE:pE),Ot=a.FilterFactory||(Si?mE:gE),jt=a.enableHWA===!0,vt=a.useWasm!==!1,Ct=c?c.length:a.length??NaN,Ae=typeof a.useSystemFonts=="boolean"?a.useSystemFonts:!Si&&!N,Nt=typeof a.useWorkerFetch=="boolean"?a.useWorkerFetch:!!(m===C0&&x===P0&&_===M0&&g&&y&&E&&Eh(g,document.baseURI)&&Eh(y,document.baseURI)&&Eh(E,document.baseURI)),he=null;NS(f);const St={canvasFactory:new Dt({ownerDocument:K,enableHWA:jt}),filterFactory:new Ot({docId:e,ownerDocument:K}),cMapReaderFactory:Nt?null:new m({baseUrl:g,isCompressed:b}),standardFontDataFactory:Nt?null:new x({baseUrl:y}),wasmFactory:Nt?null:new _({baseUrl:E})};d||(d=Rh.create({verbosity:f,port:os.workerPort}),t._worker=d);const Ui={docId:e,apiVersion:"5.4.530",data:n,password:l,disableAutoFetch:J,rangeChunkSize:h,length:Ct,docBaseUrl:u,enableXfa:G,evaluatorOptions:{maxImageSize:T,disableFontFace:N,ignoreErrors:C,isEvalSupported:D,isOffscreenCanvasSupported:j,isImageDecoderSupported:O,canvasMaxAreaInBytes:H,fontExtraProperties:lt,useSystemFonts:Ae,useWasm:vt,useWorkerFetch:Nt,cMapUrl:g,iccUrl:w,standardFontDataUrl:y,wasmUrl:E}},Hi={ownerDocument:K,pdfBug:ct,styleElement:he,loadingParams:{disableAutoFetch:J,enableXfa:G}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Ne=d.messageHandler.sendWithPromise("GetDocRequest",Ui,n?[n.buffer]:null);let wi;if(c)wi=new BE(c,{disableRange:rt,disableStream:tt});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");const st=Eh(i)?HE:Si?ZE:YE;wi=new st({url:i,length:Ct,httpHeaders:r,withCredentials:o,rangeChunkSize:h,disableRange:rt,disableStream:tt})}return Ne.then(st=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const Ve=new _h(e,st,d.port),nt=new rx(Ve,t,wi,Hi,St,jt);t._transport=nt,Ve.send("Ready",null)})}).catch(t._capability.reject),t}const Jf=class Jf{constructor(){$(this,"_capability",Promise.withResolvers());$(this,"_transport",null);$(this,"_worker",null);$(this,"docId",`d${Xe(Jf,Kf)._++}`);$(this,"destroyed",!1);$(this,"onPassword",null);$(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,i,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(i=this._worker)!=null&&i.port&&delete this._worker._pendingDestroy,r}this._transport=null,(n=this._worker)==null||n.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Kf=new WeakMap,v(Jf,Kf,0);let am=Jf;class J0{constructor(t,e,i=!1,n=null){v(this,xa,Promise.withResolvers());v(this,jd,[]);v(this,zd,[]);v(this,Ud,[]);v(this,Hd,[]);this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n}addRangeListener(t){s(this,Hd).push(t)}addProgressListener(t){s(this,Ud).push(t)}addProgressiveReadListener(t){s(this,zd).push(t)}addProgressiveDoneListener(t){s(this,jd).push(t)}onDataRange(t,e){for(const i of s(this,Hd))i(t,e)}onDataProgress(t,e){s(this,xa).promise.then(()=>{for(const i of s(this,Ud))i(t,e)})}onDataProgressiveRead(t){s(this,xa).promise.then(()=>{for(const e of s(this,zd))e(t)})}onDataProgressiveDone(){s(this,xa).promise.then(()=>{for(const t of s(this,jd))t()})}transportReady(){s(this,xa).resolve()}requestDataRange(t,e){ie("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}xa=new WeakMap,jd=new WeakMap,zd=new WeakMap,Ud=new WeakMap,Hd=new WeakMap;class nx{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 gt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}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 sx{constructor(t,e,i,n=!1){v(this,Ca);v(this,rr,!1);this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new d0:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new X0,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}={}){return new Sh({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return gt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:n="display",annotationMode:r=Nr.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:c=null,annotationCanvasMap:h=null,pageColors:d=null,printAnnotationStorage:f=null,isEditing:u=!1,recordOperations:g=!1,operationsFilter:b=null}){var O,H,N;(O=this._stats)==null||O.time("Overall");const m=this._transport.getRenderingIntent(n,r,f,u),{renderingIntent:w,cacheKey:y}=m;p(this,rr,!1),c||(c=this._transport.getOptionalContentConfig(w));let x=this._intentStates.get(y);x||(x=Object.create(null),this._intentStates.set(y,x)),x.streamReaderCancelTimeout&&(clearTimeout(x.streamReaderCancelTimeout),x.streamReaderCancelTimeout=null);const E=!!(w&Gi.PRINT);x.displayReadyCapability||(x.displayReadyCapability=Promise.withResolvers(),x.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(H=this._stats)==null||H.time("Page Request"),this._pumpOperatorList(m));const _=!!(this._pdfBug&&((N=globalThis.StepperManager)!=null&&N.enabled)),C=!this.recordedBBoxes&&(g||_),T=lt=>{var G,K;if(x.renderTasks.delete(D),C){const rt=(G=D.gfx)==null?void 0:G.dependencyTracker.take();rt&&(D.stepper&&D.stepper.setOperatorBBoxes(rt,D.gfx.dependencyTracker.takeDebugMetadata()),g&&(this.recordedBBoxes=rt))}E&&p(this,rr,!0),A(this,Ca,Wu).call(this),lt?(D.capability.reject(lt),this._abortOperatorList({intentState:x,reason:lt instanceof Error?lt:new Error(lt)})):D.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(K=globalThis.Stats)!=null&&K.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},D=new lm({callback:T,params:{canvas:e,canvasContext:t,dependencyTracker:C?new SE(e,x.operatorList.length,_):null,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:x.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!E,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:b});(x.renderTasks||(x.renderTasks=new Set)).add(D);const j=D.task;return Promise.all([x.displayReadyCapability.promise,c]).then(([lt,G])=>{var K;if(this.destroyed){T();return}if((K=this._stats)==null||K.time("Rendering"),!(G.renderingIntent&w))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");D.initializeGraphics({transparency:lt,optionalContentConfig:G}),D.operatorListChanged()}).catch(T),j}getOperatorList({intent:t="display",annotationMode:e=Nr.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){var h;function r(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(c))}const o=this._transport.getRenderingIntent(t,e,i,n,!0);let l=this._intentStates.get(o.cacheKey);l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l));let c;return l.opListReadCapability||(c=Object.create(null),c.operatorListChanged=r,l.opListReadCapability=Promise.withResolvers(),(l.renderTasks||(l.renderTasks=new Set)).add(c),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(o)),l.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>wh.textContent(i));const e=this.streamTextContent(t);return new Promise(function(i,n){function r(){o.read().then(function({value:c,done:h}){if(h){i(l);return}l.lang??(l.lang=c.lang),Object.assign(l.styles,c.styles),l.items.push(...c.items),r()},n)}const o=e.getReader(),l={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),p(this,rr,!1),Promise.all(t)}cleanup(t=!1){p(this,rr,!0);const e=A(this,Ca,Wu).call(this);return t&&e&&this._stats&&(this._stats=new d0),e}_startRenderPage(t,e){var n,r;const i=this._intentStates.get(e);i&&((n=this._stats)==null||n.timeEnd("Page Request"),(r=i.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let i=0,n=t.length;i<n;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&A(this,Ca,Wu).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:r,transfer:o}=i,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:n},o).getReader(),h=this._intentStates.get(e);h.streamReader=c;const d=()=>{c.read().then(({value:f,done:u})=>{if(u){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(f,h),d())},f=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const u of h.renderTasks)u.operatorListChanged();A(this,Ca,Wu).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(f);else if(h.opListReadCapability)h.opListReadCapability.reject(f);else throw f}})};d()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof zg){let n=ix;e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n);return}}if(t.streamReader.cancel(new Fr(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,r]of this._intentStates)if(r===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}}rr=new WeakMap,Ca=new WeakSet,Wu=function(){if(!s(this,rr)||this.destroyed)return!1;for(const{renderTasks:t,operatorList:e}of this._intentStates.values())if(t.size>0||!e.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),p(this,rr,!1),!0};const me=class me{constructor({name:t=null,port:e=null,verbosity:i=FS()}={}){v(this,Ci);v(this,co,Promise.withResolvers());v(this,Vn,null);v(this,or,null);v(this,_a,null);if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(s(me,Pa).has(e))throw new Error("Cannot use more than one PDFWorker per port.");s(me,Pa).set(e,this),A(this,Ci,sw).call(this,e)}else A(this,Ci,rw).call(this)}get promise(){return s(this,co).promise}get port(){return s(this,or)}get messageHandler(){return s(this,Vn)}destroy(){var t,e;this.destroyed=!0,(t=s(this,_a))==null||t.terminate(),p(this,_a,null),s(me,Pa).delete(s(this,or)),p(this,or,null),(e=s(this,Vn))==null||e.destroy(),p(this,Vn,null)}static create(t){const e=s(this,Pa).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new me(t)}static get workerSrc(){if(os.workerSrc)return os.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return gt(this,"_setupFakeWorkerGlobal",(async()=>s(this,yc,kp)?s(this,yc,kp):(await import(this.workerSrc)).WorkerMessageHandler)())}};co=new WeakMap,Vn=new WeakMap,or=new WeakMap,_a=new WeakMap,Zf=new WeakMap,Ta=new WeakMap,Pa=new WeakMap,Ci=new WeakSet,Pp=function(){s(this,co).resolve(),s(this,Vn).send("configure",{verbosity:this.verbosity})},sw=function(t){p(this,or,t),p(this,Vn,new _h("main","worker",t)),s(this,Vn).on("ready",()=>{}),A(this,Ci,Pp).call(this)},rw=function(){if(s(me,Ta)||s(me,yc,kp)){A(this,Ci,Vu).call(this);return}let{workerSrc:t}=me;try{me._isSameOrigin(window.location,t)||(t=me._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new _h("main","worker",e),n=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?s(this,co).reject(new Error("Worker was destroyed")):A(this,Ci,Vu).call(this)},r=new AbortController;e.addEventListener("error",()=>{s(this,_a)||n()},{signal:r.signal}),i.on("test",l=>{if(r.abort(),this.destroyed||!l){n();return}p(this,Vn,i),p(this,or,e),p(this,_a,e),A(this,Ci,Pp).call(this)}),i.on("ready",l=>{if(r.abort(),this.destroyed){n();return}try{o()}catch{A(this,Ci,Vu).call(this)}});const o=()=>{const l=new Uint8Array;i.send("test",l,[l.buffer])};o();return}catch{gf("The worker has been disabled.")}A(this,Ci,Vu).call(this)},Vu=function(){s(me,Ta)||(pt("Setting up fake worker."),p(me,Ta,!0)),me._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){s(this,co).reject(new Error("Worker was destroyed"));return}const e=new fE;p(this,or,e);const i=`fake${Xe(me,Zf)._++}`,n=new _h(i+"_worker",i,e);t.setup(n,e),p(this,Vn,new _h(i,i+"_worker",e)),A(this,Ci,Pp).call(this)}).catch(t=>{s(this,co).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},yc=new WeakSet,kp=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},v(me,yc),v(me,Zf,0),v(me,Ta,!1),v(me,Pa,new WeakMap),Si&&(p(me,Ta,!0),os.workerSrc||(os.workerSrc="./pdf.worker.mjs")),me._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!(i!=null&&i.origin)||i.origin==="null")return!1;const n=new URL(e,i);return i.origin===n.origin},me._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},me.fromPort=t=>{if(qS("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return me.create(t)};let Rh=me;class rx{constructor(t,e,i,n,r,o){v(this,ka);v(this,ar,new Map);v(this,vs,new Map);v(this,vc,new Map);v(this,wc,new Map);v(this,lr,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new X0,this.fontLoader=new oE({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=o,this.setupMessageHandler()}get annotationStorage(){return gt(this,"annotationStorage",new Xg)}getRenderingIntent(t,e=Nr.ENABLE,i=null,n=!1,r=!1){let o=Gi.DISPLAY,l=Yg;switch(t){case"any":o=Gi.ANY;break;case"display":break;case"print":o=Gi.PRINT;break;default:pt(`getRenderingIntent - invalid intent: ${t}`)}const c=o&Gi.PRINT&&i instanceof A0?i:this.annotationStorage;switch(e){case Nr.DISABLE:o+=Gi.ANNOTATIONS_DISABLE;break;case Nr.ENABLE:break;case Nr.ENABLE_FORMS:o+=Gi.ANNOTATIONS_FORMS;break;case Nr.ENABLE_STORAGE:o+=Gi.ANNOTATIONS_STORAGE,l=c.serializable;break;default:pt(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(o+=Gi.IS_EDITING),r&&(o+=Gi.OPLIST);const{ids:h,hash:d}=c.modifiedIds,f=[o,l.hash,d];return{renderingIntent:o,cacheKey:f.join("_"),annotationStorageSerializable:l,modifiedIds:h}}destroy(){var i;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(i=s(this,lr))==null||i.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const n of s(this,vs).values())t.push(n._destroy());s(this,vs).clear(),s(this,vc).clear(),s(this,wc).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var n,r;this.commonObjs.clear(),this.fontLoader.clear(),s(this,ar).clear(),this.filterFactory.destroy(),Mh.cleanup(),(n=this._networkStream)==null||n.cancelAllRequests(new Fr("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,n)=>{Rt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},n.onPull=()=>{this._fullReader.read().then(function({value:r,done:o}){if(o){n.close();return}Rt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{this._fullReader.cancel(r),n.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("ReaderHeadersReady",async i=>{var l;await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:o}=this._fullReader;return(!n||!r)&&(this._lastProgress&&((l=e.onProgress)==null||l.call(e,this._lastProgress)),this._fullReader.onProgress=c=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:c.loaded,total:c.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:o}}),t.on("GetRangeReader",(i,n)=>{Rt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(i.begin,i.end);if(!r){n.close();return}n.onPull=()=>{r.read().then(function({value:o,done:l}){if(l){n.close();return}Rt(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{n.error(o)})},n.onCancel=o=>{r.cancel(o),n.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("GetDoc",({pdfInfo:i})=>{this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new nx(i,this))}),t.on("DocException",i=>{e._capability.reject(Di(i))}),t.on("PasswordRequest",i=>{p(this,lr,Promise.withResolvers());try{if(!e.onPassword)throw Di(i);const n=r=>{r instanceof Error?s(this,lr).reject(r):s(this,lr).resolve({password:r})};e.onPassword(n,i.code)}catch(n){s(this,lr).reject(n)}return s(this,lr).promise}),t.on("DataLoaded",i=>{var n;(n=e.onProgress)==null||n.call(e,{loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",i=>{if(this.destroyed)return;s(this,vs).get(i.pageIndex)._startRenderPage(i.transparency,i.cacheKey)}),t.on("commonobj",([i,n,r])=>{var o;if(this.destroyed||this.commonObjs.has(i))return null;switch(n){case"Font":if("error"in r){const u=r.error;pt(`Error during font loading: ${u}`),this.commonObjs.resolve(i,u);break}const l=new qg(r),c=this._params.pdfBug&&((o=globalThis.FontInspector)!=null&&o.enabled)?(u,g)=>globalThis.FontInspector.fontAdded(u,g):null,h=new aE(l,c,r.extra,r.charProcOperatorList);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:i})).finally(()=>{!h.fontExtraProperties&&h.data&&h.clearData(),this.commonObjs.resolve(i,h)});break;case"CopyLocalImage":const{imageRef:d}=r;Rt(d,"The imageRef must be defined.");for(const u of s(this,vs).values())for(const[,g]of u.objs)if((g==null?void 0:g.ref)===d)return g.dataLen?(this.commonObjs.resolve(i,structuredClone(g)),g.dataLen):null;break;case"FontPath":this.commonObjs.resolve(i,new lE(r));break;case"Image":this.commonObjs.resolve(i,r);break;case"Pattern":const f=new Kg(r);this.commonObjs.resolve(i,f.getIR());break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([i,n,r,o])=>{var c;if(this.destroyed)return;const l=s(this,vs).get(n);if(!l.objs.has(i)){if(l._intentStates.size===0){(c=o==null?void 0:o.bitmap)==null||c.close();return}switch(r){case"Image":case"Pattern":l.objs.resolve(i,o);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",i=>{var n;this.destroyed||(n=e.onProgress)==null||n.call(e,{loaded:i.loaded,total:i.total})}),t.on("FetchBinaryData",async i=>{if(this.destroyed)throw new Error("Worker was destroyed.");const n=this[i.type];if(!n)throw new Error(`${i.type} not initialized, see the \`useWorkerFetch\` parameter.`);return n.fetch(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var i;this.annotationStorage.size<=0&&pt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((i=this._fullReader)==null?void 0:i.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=s(this,vc).get(e);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&s(this,wc).set(r.refStr,t);const o=new sx(e,r,this,this._params.pdfBug);return s(this,vs).set(e,o),o});return s(this,vc).set(e,n),n}getPageIndex(t){return Jg(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 A(this,ka,Gu).call(this,"GetFieldObjects")}hasJSActions(){return A(this,ka,Gu).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return A(this,ka,Gu).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 A(this,ka,Gu).call(this,"GetOptionalContentConfig").then(e=>new FE(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=s(this,ar).get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(n=>{var r,o;return{info:n[0],metadata:n[1]?new LE(n[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null,hasStructTree:n[2]}});return s(this,ar).set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of s(this,vs).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),s(this,ar).clear(),this.filterFactory.destroy(!0),Mh.cleanup()}}cachedPageNumber(t){if(!Jg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return s(this,wc).get(e)??null}}ar=new WeakMap,vs=new WeakMap,vc=new WeakMap,wc=new WeakMap,lr=new WeakMap,ka=new WeakSet,Gu=function(t,e=null){const i=s(this,ar).get(t);if(i)return i;const n=this.messageHandler.sendWithPromise(t,e);return s(this,ar).set(t,n),n};class ox{constructor(t){v(this,ho,null);$(this,"onContinue",null);$(this,"onError",null);p(this,ho,t)}get promise(){return s(this,ho).capability.promise}cancel(t=0){s(this,ho).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=s(this,ho).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=s(this,ho);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}ho=new WeakMap;const Ra=class Ra{constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:r,operatorList:o,pageIndex:l,canvasFactory:c,filterFactory:h,useRequestAnimationFrame:d=!1,pdfBug:f=!1,pageColors:u=null,enableHWA:g=!1,operationsFilter:b=null}){v(this,uo,null);this.callback=t,this.params=e,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=l,this.canvasFactory=c,this.filterFactory=h,this._pdfBug=f,this.pageColors=u,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new ox(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=g,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=b}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(s(Ra,Ma).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.");s(Ra,Ma).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:i,transform:n,background:r,dependencyTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Al(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,o),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var i,n,r;this.running=!1,this.cancelled=!0,(i=this.gfx)==null||i.endDrawing(),s(this,uo)&&(window.cancelAnimationFrame(s(this,uo)),p(this,uo,null)),s(Ra,Ma).delete(this._canvas),t||(t=new zg(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(n=this.task).onError)==null||r.call(n,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?p(this,uo,window.requestAnimationFrame(()=>{p(this,uo,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),s(Ra,Ma).delete(this._canvas),this.callback())))}};uo=new WeakMap,Ma=new WeakMap,v(Ra,Ma,new WeakSet);let lm=Ra;const Z0="5.4.530",ax="50cc4adac",Bi=class Bi{constructor({editor:t=null,uiManager:e=null}){v(this,te);v(this,en,null);v(this,Da,null);v(this,Ac);v(this,He,null);v(this,$d,!1);v(this,Sc,!1);v(this,cr,null);v(this,Wd);v(this,fo,null);v(this,Gn,null);var i,n;t?(p(this,Sc,!1),p(this,cr,t)):p(this,Sc,!0),p(this,Gn,(t==null?void 0:t._uiManager)||e),p(this,Wd,s(this,Gn)._eventBus),p(this,Ac,((i=t==null?void 0:t.color)==null?void 0:i.toUpperCase())||((n=s(this,Gn))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),s(Bi,Vd)||p(Bi,Vd,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 gt(this,"_keyboardManager",new Ch([[["Escape","mac+Escape"],Bi.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],Bi.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],Bi.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],Bi.prototype._moveToPrevious],[["Home","mac+Home"],Bi.prototype._moveToBeginning],[["End","mac+End"],Bi.prototype._moveToEnd]]))}renderButton(){const t=p(this,en,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",s(this,cr)&&(t.ariaControls=`${s(this,cr).id}_colorpicker_dropdown`);const e=s(this,Gn)._signal;t.addEventListener("click",A(this,te,ll).bind(this),{signal:e}),t.addEventListener("keydown",A(this,te,db).bind(this),{signal:e});const i=p(this,Da,document.createElement("span"));return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=s(this,Ac),t.append(i),t}renderMainDropdown(){const t=p(this,He,A(this,te,cb).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===s(this,en)){A(this,te,ll).call(this,t);return}const e=t.target.getAttribute("data-color");e&&A(this,te,hb).call(this,e,t)}_moveToNext(t){var e,i;if(!s(this,te,Do)){A(this,te,ll).call(this,t);return}if(t.target===s(this,en)){(e=s(this,He).firstElementChild)==null||e.focus();return}(i=t.target.nextSibling)==null||i.focus()}_moveToPrevious(t){var e,i;if(t.target===((e=s(this,He))==null?void 0:e.firstElementChild)||t.target===s(this,en)){s(this,te,Do)&&this._hideDropdownFromKeyboard();return}s(this,te,Do)||A(this,te,ll).call(this,t),(i=t.target.previousSibling)==null||i.focus()}_moveToBeginning(t){var e;if(!s(this,te,Do)){A(this,te,ll).call(this,t);return}(e=s(this,He).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!s(this,te,Do)){A(this,te,ll).call(this,t);return}(e=s(this,He).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=s(this,He))==null||t.classList.add("hidden"),s(this,en).ariaExpanded="false",(e=s(this,fo))==null||e.abort(),p(this,fo,null)}_hideDropdownFromKeyboard(){var t;if(!s(this,Sc)){if(!s(this,te,Do)){(t=s(this,cr))==null||t.unselect();return}this.hideDropdown(),s(this,en).focus({preventScroll:!0,focusVisible:s(this,$d)})}}updateColor(t){if(s(this,Da)&&(s(this,Da).style.backgroundColor=t),!s(this,He))return;const e=s(this,Gn).highlightColors.values();for(const i of s(this,He).children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=s(this,en))==null||t.remove(),p(this,en,null),p(this,Da,null),(e=s(this,He))==null||e.remove(),p(this,He,null)}};en=new WeakMap,Da=new WeakMap,Ac=new WeakMap,He=new WeakMap,$d=new WeakMap,Sc=new WeakMap,cr=new WeakMap,Wd=new WeakMap,fo=new WeakMap,Gn=new WeakMap,Vd=new WeakMap,te=new WeakSet,cb=function(){const t=document.createElement("div"),e=s(this,Gn)._signal;t.addEventListener("contextmenu",vn,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),s(this,cr)&&(t.id=`${s(this,cr).id}_colorpicker_dropdown`);for(const[i,n]of s(this,Gn).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=i,r.setAttribute("data-l10n-id",s(Bi,Vd)[i]);const o=document.createElement("span");r.append(o),o.className="swatch",o.style.backgroundColor=n,r.ariaSelected=n===s(this,Ac),r.addEventListener("click",A(this,te,hb).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",A(this,te,db).bind(this),{signal:e}),t},hb=function(t,e){e.stopPropagation(),s(this,Wd).dispatch("switchannotationeditorparams",{source:this,type:Mt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},db=function(t){Bi._keyboardManager.exec(this,t)},ll=function(t){if(s(this,te,Do)){this.hideDropdown();return}if(p(this,$d,t.detail===0),s(this,fo)||(p(this,fo,new AbortController),window.addEventListener("pointerdown",A(this,te,ow).bind(this),{signal:s(this,Gn).combinedSignal(s(this,fo))})),s(this,en).ariaExpanded="true",s(this,He)){s(this,He).classList.remove("hidden");return}const e=p(this,He,A(this,te,cb).call(this));s(this,en).append(e)},ow=function(t){var e;(e=s(this,He))!=null&&e.contains(t.target)||this.hideDropdown()},Do=function(){return s(this,He)&&!s(this,He).classList.contains("hidden")},v(Bi,Vd,null);let Df=Bi;const Oa=class Oa{constructor(t){v(this,ws,null);v(this,Gd,null);v(this,Ec,null);p(this,Gd,t),p(this,Ec,t._uiManager),s(Oa,Yd)||p(Oa,Yd,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(s(this,ws))return s(this,ws);const{editorType:t,colorType:e,color:i}=s(this,Gd),n=p(this,ws,document.createElement("input"));return n.type="color",n.value=i||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",s(Oa,Yd)[t]),n.addEventListener("input",()=>{s(this,Ec).updateParams(e,n.value)},{signal:s(this,Ec)._signal}),n}update(t){s(this,ws)&&(s(this,ws).value=t)}destroy(){var t;(t=s(this,ws))==null||t.remove(),p(this,ws,null)}hideDropdown(){}};ws=new WeakMap,Gd=new WeakMap,Ec=new WeakMap,Yd=new WeakMap,v(Oa,Yd,null);let Of=Oa;function Q0(a){return Math.floor(Math.max(0,Math.min(1,a))*255).toString(16).padStart(2,"0")}function Dh(a){return Math.max(0,Math.min(255,255*a))}class tv{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Dh(t),[t,t,t]}static G_HTML([t]){const e=Q0(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Dh)}static RGB_HTML(t){return`#${t.map(Q0).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[Dh(1-Math.min(1,t+n)),Dh(1-Math.min(1,i+n)),Dh(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,r=1-e,o=1-i,l=Math.min(n,r,o);return["CMYK",n,r,o,l]}}class lx{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){ie("Abstract method `_createSVG` called.")}}class If extends lx{_createSVG(t){return document.createElementNS(Ls,t)}}const cx=9,zo=new WeakSet,hx=new Date().getTimezoneOffset()*60*1e3;class cm{static create(t){switch(t.data.annotationType){case De.LINK:return new hm(t);case De.TEXT:return new ux(t);case De.WIDGET:switch(t.data.fieldType){case"Tx":return new fx(t);case"Btn":return t.data.radioButton?new ev(t):t.data.checkBox?new gx(t):new mx(t);case"Ch":return new bx(t);case"Sig":return new px(t)}return new Uo(t);case De.POPUP:return new dm(t);case De.FREETEXT:return new iv(t);case De.LINE:return new vx(t);case De.SQUARE:return new wx(t);case De.CIRCLE:return new Ax(t);case De.POLYLINE:return new nv(t);case De.CARET:return new Ex(t);case De.INK:return new um(t);case De.POLYGON:return new Sx(t);case De.HIGHLIGHT:return new sv(t);case De.UNDERLINE:return new xx(t);case De.SQUIGGLY:return new Cx(t);case De.STRIKEOUT:return new _x(t);case De.STAMP:return new rv(t);case De.FILEATTACHMENT:return new Tx(t);default:return new ve(t)}}}const Mm=class Mm{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!1}={}){v(this,Xd);v(this,Ia,null);v(this,xc,!1);v(this,Dn,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Mm._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var i;const{data:t}=this,e=(i=this.annotationStorage)==null?void 0:i.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var l;const t=(l=this.annotationStorage)==null?void 0:l.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:n}=this.data;let r=-1/0,o=-1/0;if((e==null?void 0:e.length)>=8){for(let c=0;c<e.length;c+=8)e[c+1]>o?(o=e[c+1],r=e[c+2]):e[c+1]===o&&(r=Math.max(r,e[c+2]));return[r,o]}if((i==null?void 0:i.length)>=1){for(const c of i)for(let h=0,d=c.length;h<d;h+=2)c[h+1]>o?(o=c[h+1],r=c[h]):c[h+1]===o&&(r=Math.max(r,c[h]));if(r!==1/0)return[r,o]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:o}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-o)/n,t}get commentText(){var e,i,n;const{data:t}=this;return((i=(e=this.annotationStorage.getRawValue(`${mh}${t.id}`))==null?void 0:e.popup)==null?void 0:i.contents)||((n=t.contentsObj)==null?void 0:n.str)||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${mh}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=s(this,Dn))==null?void 0:t.popup)||this.popup)==null||e.remove(),p(this,Dn,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(s(this,Ia)||p(this,Ia,{rect:this.data.rect.slice(0)}));const{rect:e,popup:i}=t;e&&A(this,Xd,ub).call(this,e);let n=((r=s(this,Dn))==null?void 0:r.popup)||this.popup;!n&&(i!=null&&i.text)&&(this._createPopup(i),n=s(this,Dn).popup),n&&(n.updateEdited(t),i!=null&&i.deleted&&(n.remove(),p(this,Dn,null),this.popup=null))}resetEdited(){var t;s(this,Ia)&&(A(this,Xd,ub).call(this,s(this,Ia).rect),(t=s(this,Dn))==null||t.popup.resetEdited(),p(this,Ia,null))}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof Uo)&&!(this instanceof hm)&&(r.tabIndex=0);const{style:o}=r;if(o.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof dm){const{rotation:m}=e;return!e.hasOwnCanvas&&m!==0&&this.setRotation(m,r),r}const{width:l,height:c}=this;if(!t&&e.borderStyle.width>0){o.borderWidth=`${e.borderStyle.width}px`;const m=e.borderStyle.horizontalCornerRadius,w=e.borderStyle.verticalCornerRadius;if(m>0||w>0){const x=`calc(${m}px * var(--total-scale-factor)) / calc(${w}px * var(--total-scale-factor))`;o.borderRadius=x}else if(this instanceof ev){const x=`calc(${l}px * var(--total-scale-factor)) / calc(${c}px * var(--total-scale-factor))`;o.borderRadius=x}switch(e.borderStyle.style){case bl.SOLID:o.borderStyle="solid";break;case bl.DASHED:o.borderStyle="dashed";break;case bl.BEVELED:pt("Unimplemented border style: beveled");break;case bl.INSET:pt("Unimplemented border style: inset");break;case bl.UNDERLINE:o.borderBottomStyle="solid";break}const y=e.borderColor||null;y?(p(this,xc,!0),o.borderColor=Z.makeHexColor(y[0]|0,y[1]|0,y[2]|0)):o.borderWidth=0}const h=Z.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:d,pageHeight:f,pageX:u,pageY:g}=n.rawDims;o.left=`${100*(h[0]-u)/d}%`,o.top=`${100*(h[1]-g)/f}%`;const{rotation:b}=e;return e.hasOwnCanvas||b===0?(o.width=`${100*l/d}%`,o.height=`${100*c/f}%`):this.setRotation(b,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims;let{width:r,height:o}=this;t%180!==0&&([r,o]=[o,r]),e.style.width=`${100*r/i}%`,e.style.height=`${100*o/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,i,n)=>{const r=n.detail[e],o=r[0],l=r.slice(1);n.target.style[i]=tv[`${o}_HTML`](l),this.annotationStorage.setValue(this.data.id,{[i]:tv[`${o}_rgb`](l)})};return gt(this,"_commonActions",{display:e=>{const{display:i}=e.detail,n=i%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:i===1||i===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:i}=e.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const i=e.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||i[n];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,r]of Object.entries(e)){const o=i[n];if(o){const l={detail:{[n]:r},target:t};o(l),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,r]=this.data.rect.map(m=>Math.fround(m));if(t.length===8){const[m,w,y,x]=t.subarray(2,6);if(n===m&&r===w&&e===y&&i===x)return}const{style:o}=this.container;let l;if(s(this,xc)){const{borderColor:m,borderWidth:w}=o;o.borderWidth=0,l=["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="${m}" stroke-width="${w}">`],this.container.classList.add("hasBorder")}const c=n-e,h=r-i,{svgFactory:d}=this,f=d.createElement("svg");f.classList.add("quadrilateralsContainer"),f.setAttribute("width",0),f.setAttribute("height",0),f.role="none";const u=d.createElement("defs");f.append(u);const g=d.createElement("clipPath"),b=`clippath_${this.data.id}`;g.setAttribute("id",b),g.setAttribute("clipPathUnits","objectBoundingBox"),u.append(g);for(let m=2,w=t.length;m<w;m+=8){const y=t[m],x=t[m+1],E=t[m+2],_=t[m+3],C=d.createElement("rect"),T=(E-e)/c,D=(r-x)/h,j=(y-E)/c,O=(x-_)/h;C.setAttribute("x",T),C.setAttribute("y",D),C.setAttribute("width",j),C.setAttribute("height",O),g.append(C),l==null||l.push(`<rect vector-effect="non-scaling-stroke" x="${T}" y="${D}" width="${j}" height="${O}"/>`)}s(this,xc)&&(l.push("</g></svg>')"),o.backgroundImage=l.join("")),this.container.append(f),this.container.style.clipPath=`url(#${b})`}_createPopup(t=null){const{data:e}=this;let i,n;t?(i={str:t.text},n=t.date):(i=e.contentsObj,n=e.modificationDate),p(this,Dn,new dm({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(s(this,Dn)||this.popup||this.data.popupRef)}get extraPopupElement(){return s(this,Dn)}render(){ie("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:r,id:o,exportValues:l}of n){if(r===-1||o===e)continue;const c=typeof l=="string"?l:null,h=document.querySelector(`[data-element-id="${o}"]`);if(h&&!zo.has(h)){pt(`_getElementsByName - element not allowed: ${o}`);continue}i.push({id:o,exportValue:c,domElement:h})}return i}for(const n of document.getElementsByName(t)){const{exportValue:r}=n,o=n.getAttribute("data-element-id");o!==e&&zo.has(n)&&i.push({id:o,exportValue:r,domElement:n})}return i}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var i;(i=this.linkService.eventBus)==null||i.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]}};Ia=new WeakMap,xc=new WeakMap,Dn=new WeakMap,Xd=new WeakSet,ub=function(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:l,pageY:c}}}}=this;i==null||i.splice(0,4,...t),e.left=`${100*(t[0]-l)/r}%`,e.top=`${100*(o-t[3]+c)/o}%`,n===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/o}%`):this.setRotation(n)};let ve=Mm;class dx extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class hm extends ve{constructor(e,i=null){super(e,{isRenderable:!0,ignoreBorder:!!(i!=null&&i.ignoreBorder),createQuadrilaterals:!0});v(this,nn);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:i}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(i.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(A(this,nn,aw).call(this,n,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(A(this,nn,lw).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=n,this.container.append(n)),this.container}_bindLink(e,i,n=""){e.href=this.linkService.getDestinationHash(i),e.onclick=()=>(i&&this.linkService.goToDestination(i),!1),(i||i==="")&&A(this,nn,cl).call(this),n&&(e.title=n)}_bindNamedAction(e,i,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(i),!1),n&&(e.title=n),A(this,nn,cl).call(this)}_bindJSAction(e,i){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(i.actions)){const o=n.get(r);o&&(e[o]=()=>{var l;return(l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i.id,name:r}}),!1})}i.overlaidText&&(e.title=i.overlaidText),e.onclick||(e.onclick=()=>!1),A(this,nn,cl).call(this)}_bindResetFormAction(e,i){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),A(this,nn,cl).call(this),!this._fieldObjects){pt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{var f;n==null||n();const{fields:r,refs:o,include:l}=i,c=[];if(r.length!==0||o.length!==0){const u=new Set(o);for(const g of r){const b=this._fieldObjects[g]||[];for(const{id:m}of b)u.add(m)}for(const g of Object.values(this._fieldObjects))for(const b of g)u.has(b.id)===l&&c.push(b)}else for(const u of Object.values(this._fieldObjects))c.push(...u);const h=this.annotationStorage,d=[];for(const u of c){const{id:g}=u;switch(d.push(g),u.type){case"text":{const m=u.defaultValue||"";h.setValue(g,{value:m});break}case"checkbox":case"radiobutton":{const m=u.defaultValue===u.exportValues;h.setValue(g,{value:m});break}case"combobox":case"listbox":{const m=u.defaultValue||"";h.setValue(g,{value:m});break}default:continue}const b=document.querySelector(`[data-element-id="${g}"]`);if(b){if(!zo.has(b)){pt(`_bindResetFormAction - element not allowed: ${g}`);continue}}else continue;b.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((f=this.linkService.eventBus)==null||f.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}nn=new WeakSet,cl=function(){this.container.setAttribute("data-internal-link","")},aw=function(e,i,n="",r=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:n&&(e.title=n),e.onclick=()=>{var o;return(o=this.downloadManager)==null||o.openOrDownloadData(i.content,i.filename,r),!1},A(this,nn,cl).call(this)},lw=function(e,i,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(i),!1),n&&(e.title=n),A(this,nn,cl).call(this)};class ux extends ve{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class Uo extends ve{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return ze.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,r){i.includes("mouse")?t.addEventListener(i,o=>{var l;(l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):t.addEventListener(i,o=>{var l;if(i==="blur"){if(!e.focused||!o.relatedTarget)return;e.focused=!1}else if(i==="focus"){if(e.focused)return;e.focused=!0}r&&((l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(o)}}))})}_setEventListeners(t,e,i,n){var r,o,l;for(const[c,h]of i)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,c,h,n),h==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((l=this.data.actions)!=null&&l.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":Z.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||cx,r=t.style;let o;const l=2,c=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-l),d=Math.round(h/(Ig*n))||1,f=h/d;o=Math.min(n,c(f/Ig))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-l);o=Math.min(n,c(h/Ig))}r.fontSize=`calc(${o}px * var(--total-scale-factor))`,r.color=Z.makeHexColor(i[0],i[1],i[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class fx extends Uo{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,n){const r=this.annotationStorage;for(const o of this._getElementsByName(t.name,t.id))o.domElement&&(o.domElement[e]=i),r.setValue(o.id,{[n]:i})}render(){var n,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const o=t.getValue(e,{value:this.data.fieldValue});let l=o.value||"";const c=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;c&&l.length>c&&(l=l.slice(0,c));let h=o.formattedValue||((n=this.data.textContent)==null?void 0:n.join(`
101
- `))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const d={userValue:l,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=h??l,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",h??l),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),zo.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:f,datetimeType:u,timeStep:g}=this.data,b=!!u&&this.enableScripting;f&&(i.title=f),this._setRequired(i,this.data.required),c&&(i.maxLength=c),i.addEventListener("input",w=>{t.setValue(e,{value:w.target.value}),this.setPropertyOnSiblings(i,"value",w.target.value,"value"),d.formattedValue=null}),i.addEventListener("resetform",w=>{const y=this.data.defaultFieldValue??"";i.value=d.userValue=y,d.formattedValue=null});let m=w=>{const{formattedValue:y}=d;y!=null&&(w.target.value=y),w.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",y=>{var E;if(d.focused)return;const{target:x}=y;if(b&&(x.type=u,g&&(x.step=g)),d.userValue){const _=d.userValue;if(b)if(u==="time"){const C=new Date(_),T=[C.getHours(),C.getMinutes(),C.getSeconds()];x.value=T.map(D=>D.toString().padStart(2,"0")).join(":")}else x.value=new Date(_-hx).toISOString().split(u==="date"?"T":".",1)[0];else x.value=_}d.lastCommittedValue=x.value,d.commitKey=1,(E=this.data.actions)!=null&&E.Focus||(d.focused=!0)}),i.addEventListener("updatefromsandbox",y=>{this.showElementAndHideCanvas(y.target);const x={value(E){d.userValue=E.detail.value??"",b||t.setValue(e,{value:d.userValue.toString()}),E.target.value=d.userValue},formattedValue(E){const{formattedValue:_}=E.detail;d.formattedValue=_,_!=null&&E.target!==document.activeElement&&(E.target.value=_);const C={formattedValue:_};b&&(C.value=_),t.setValue(e,C)},selRange(E){E.target.setSelectionRange(...E.detail.selRange)},charLimit:E=>{var D;const{charLimit:_}=E.detail,{target:C}=E;if(_===0){C.removeAttribute("maxLength");return}C.setAttribute("maxLength",_);let T=d.userValue;!T||T.length<=_||(T=T.slice(0,_),C.value=d.userValue=T,t.setValue(e,{value:T}),(D=this.linkService.eventBus)==null||D.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:T,willCommit:!0,commitKey:1,selStart:C.selectionStart,selEnd:C.selectionEnd}}))}};this._dispatchEventFromSandbox(x,y)}),i.addEventListener("keydown",y=>{var _;d.commitKey=1;let x=-1;if(y.key==="Escape"?x=0:y.key==="Enter"&&!this.data.multiLine?x=2:y.key==="Tab"&&(d.commitKey=3),x===-1)return;const{value:E}=y.target;d.lastCommittedValue!==E&&(d.lastCommittedValue=E,d.userValue=E,(_=this.linkService.eventBus)==null||_.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:x,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}}))});const w=m;m=null,i.addEventListener("blur",y=>{var _,C;if(!d.focused||!y.relatedTarget)return;(_=this.data.actions)!=null&&_.Blur||(d.focused=!1);const{target:x}=y;let{value:E}=x;if(b){if(E&&u==="time"){const T=E.split(":").map(D=>parseInt(D,10));E=new Date(2e3,0,1,T[0],T[1],T[2]||0).valueOf(),x.step=""}else E.includes("T")||(E=`${E}T00:00`),E=new Date(E).valueOf();x.type="text"}d.userValue=E,d.lastCommittedValue!==E&&((C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:E,willCommit:!0,commitKey:d.commitKey,selStart:y.target.selectionStart,selEnd:y.target.selectionEnd}})),w(y)}),(r=this.data.actions)!=null&&r.Keystroke&&i.addEventListener("beforeinput",y=>{var O;d.lastCommittedValue=null;const{data:x,target:E}=y,{value:_,selectionStart:C,selectionEnd:T}=E;let D=C,j=T;switch(y.inputType){case"deleteWordBackward":{const H=_.substring(0,C).match(/\w*[^\w]*$/);H&&(D-=H[0].length);break}case"deleteWordForward":{const H=_.substring(C).match(/^[^\w]*\w*/);H&&(j+=H[0].length);break}case"deleteContentBackward":C===T&&(D-=1);break;case"deleteContentForward":C===T&&(j+=1);break}y.preventDefault(),(O=this.linkService.eventBus)==null||O.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:_,change:x||"",willCommit:!1,selStart:D,selEnd:j}})}),this._setEventListeners(i,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],y=>y.target.value)}if(m&&i.addEventListener("blur",m),this.data.comb){const y=(this.data.rect[2]-this.data.rect[0])/c;i.classList.add("comb"),i.style.letterSpacing=`calc(${y}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class px extends Uo{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class gx extends Uo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;typeof n=="string"&&(n=n!=="Off",t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return zo.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",o=>{const{name:l,checked:c}=o.target;for(const h of this._getElementsByName(l,i)){const d=c&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=d),t.setValue(h.id,{value:d})}t.setValue(i,{value:c})}),r.addEventListener("resetform",o=>{const l=e.defaultFieldValue||"Off";o.target.checked=l===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",o=>{const l={value(c){c.target.checked=c.detail.value!=="Off",t.setValue(i,{value:c.target.checked})}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class ev extends Uo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if(typeof n=="string"&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const o of this._getElementsByName(e.fieldName,i))t.setValue(o.id,{value:!1});const r=document.createElement("input");if(zo.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",o=>{const{name:l,checked:c}=o.target;for(const h of this._getElementsByName(l,i))t.setValue(h.id,{value:!1});t.setValue(i,{value:c})}),r.addEventListener("resetform",o=>{const l=e.defaultFieldValue;o.target.checked=l!=null&&l===e.buttonValue}),this.enableScripting&&this.hasJSActions){const o=e.buttonValue;r.addEventListener("updatefromsandbox",l=>{const c={value:h=>{const d=o===h.detail.value;for(const f of this._getElementsByName(h.target.name)){const u=d&&f.id===i;f.domElement&&(f.domElement.checked=u),t.setValue(f.id,{value:u})}}};this._dispatchEventFromSandbox(c,l)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class mx extends hm{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",i=>{this._dispatchEventFromSandbox({},i)})),t}}class bx extends Uo{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");zo.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",d=>{const f=this.data.defaultFieldValue;for(const u of n.options)u.selected=u.value===f});for(const d of this.data.options){const f=document.createElement("option");f.textContent=d.displayValue,f.value=d.exportValue,i.value.includes(d.exportValue)&&(f.setAttribute("selected",!0),r=!1),n.append(f)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),n.prepend(d),o=()=>{d.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}const l=d=>{const f=d?"value":"textContent",{options:u,multiple:g}=n;return g?Array.prototype.filter.call(u,b=>b.selected).map(b=>b[f]):u.selectedIndex===-1?null:u[u.selectedIndex][f]};let c=l(!1);const h=d=>{const f=d.target.options;return Array.prototype.map.call(f,u=>({displayValue:u.textContent,exportValue:u.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",d=>{const f={value(u){o==null||o();const g=u.detail.value,b=new Set(Array.isArray(g)?g:[g]);for(const m of n.options)m.selected=b.has(m.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(u){n.multiple=!0},remove(u){const g=n.options,b=u.detail.remove;g[b].selected=!1,n.remove(b),g.length>0&&Array.prototype.findIndex.call(g,w=>w.selected)===-1&&(g[0].selected=!0),t.setValue(e,{value:l(!0),items:h(u)}),c=l(!1)},clear(u){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(u){const{index:g,displayValue:b,exportValue:m}=u.detail.insert,w=n.children[g],y=document.createElement("option");y.textContent=b,y.value=m,w?w.before(y):n.append(y),t.setValue(e,{value:l(!0),items:h(u)}),c=l(!1)},items(u){const{items:g}=u.detail;for(;n.length!==0;)n.remove(0);for(const b of g){const{displayValue:m,exportValue:w}=b,y=document.createElement("option");y.textContent=m,y.value=w,n.append(y)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(u)}),c=l(!1)},indices(u){const g=new Set(u.detail.indices);for(const b of u.target.options)b.selected=g.has(b.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(u){u.target.disabled=!u.detail.editable}};this._dispatchEventFromSandbox(f,d)}),n.addEventListener("input",d=>{var g;const f=l(!0),u=l(!1);t.setValue(e,{value:f}),d.preventDefault(),(g=this.linkService.eventBus)==null||g.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:u,changeEx:f,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):n.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class dm extends ve{constructor(e){const{data:i,elements:n,parent:r}=e,o=!!r._commentManager;super(e,{isRenderable:!o&&ve._hasPopupData(i)});v(this,qd);if(this.elements=n,o&&ve._hasPopupData(i)){const l=this.popup=A(this,qd,fb).call(this);for(const c of n)c.popup=l}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const i=this.popup=A(this,qd,fb).call(this),n=[];for(const r of this.elements)r.popup=i,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(r=>`${yl}${r}`).join(",")),this.container}}qd=new WeakSet,fb=function(){return new yx({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class yx{constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:r,contentsObj:o,richText:l,parent:c,rect:h,parentRect:d,open:f,commentManager:u=null}){v(this,wt);v(this,sn,null);v(this,po,A(this,wt,dw).bind(this));v(this,Qf,A(this,wt,yb).bind(this));v(this,tp,A(this,wt,Op).bind(this));v(this,Cc,A(this,wt,Dp).bind(this));v(this,_c,null);v(this,Te,null);v(this,As,null);v(this,go,null);v(this,La,null);v(this,Tc,null);v(this,Pc,null);v(this,Ss,!1);v(this,rn,null);v(this,hr,null);v(this,dr,null);v(this,Pe,null);v(this,ur,null);v(this,mo,null);v(this,Kd,null);v(this,fr,null);v(this,kc,null);v(this,Na,null);v(this,bo,!1);v(this,Je,null);v(this,yo,null);p(this,Te,t),p(this,kc,n),p(this,As,o),p(this,fr,l),p(this,Tc,c),p(this,_c,e),p(this,Kd,h),p(this,Pc,d),p(this,La,i),p(this,sn,u),p(this,Je,i[0]),p(this,go,yf.toDateObject(r)),this.trigger=i.flatMap(g=>g.getElementsToTriggerPopup()),u||(A(this,wt,Mp).call(this),s(this,Te).hidden=!0,f&&A(this,wt,Dp).call(this))}renderCommentButton(){if(s(this,Pe)){s(this,Pe).parentNode||s(this,Je).container.after(s(this,Pe));return}if(s(this,ur)||A(this,wt,pb).call(this),!s(this,ur))return;const{signal:t}=p(this,hr,new AbortController),e=s(this,Je).hasOwnCommentButton,i=()=>{s(this,sn).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{s(this,sn).toggleCommentPopup(this,!1,!0,!e)},r=()=>{s(this,sn).toggleCommentPopup(this,!1,!1)};if(e){p(this,Pe,s(this,Je).container);for(const o of this.trigger)o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.addEventListener("keydown",s(this,po),{signal:t}),o.addEventListener("click",i,{signal:t}),o.addEventListener("pointerenter",n,{signal:t}),o.addEventListener("pointerleave",r,{signal:t}),o.classList.add("popupTriggerArea")}else{const o=p(this,Pe,document.createElement("button"));o.className="annotationCommentButton";const l=s(this,Je).container;o.style.zIndex=l.style.zIndex+1,o.tabIndex=0,o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.setAttribute("data-l10n-id","pdfjs-show-comment-button"),A(this,wt,mb).call(this),A(this,wt,gb).call(this),o.addEventListener("keydown",s(this,po),{signal:t}),o.addEventListener("click",i,{signal:t}),o.addEventListener("pointerenter",n,{signal:t}),o.addEventListener("pointerleave",r,{signal:t}),l.after(o)}}get commentButtonColor(){const{color:t,opacity:e}=s(this,Je).commentData;return t?s(this,Tc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=s(this,Pe))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:n,modificationDate:r}=s(this,Je).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:n,modificationDate:r}}get elementBeforePopup(){return s(this,Pe)}get comment(){return s(this,yo)||p(this,yo,s(this,Je).commentText),s(this,yo)}set comment(t){t!==this.comment&&(s(this,Je).commentText=p(this,yo,t))}focus(){var t;(t=s(this,Je).container)==null||t.focus()}get parentBoundingClientRect(){return s(this,Je).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){s(this,Pe)&&(s(this,Pe).classList.toggle("selected",t),s(this,Pe).ariaExpanded=e)}setSelectedCommentButton(t){s(this,Pe).classList.toggle("selected",t)}get commentPopupPosition(){if(s(this,mo))return s(this,mo);const{x:t,y:e,height:i}=s(this,Pe).getBoundingClientRect(),{x:n,y:r,width:o,height:l}=s(this,Je).layer.getBoundingClientRect();return[(t-n)/o,(e+i-r)/l]}set commentPopupPosition(t){p(this,mo,t)}hasDefaultPopupPosition(){return s(this,mo)===null}get commentButtonPosition(){return s(this,ur)}get commentButtonWidth(){return s(this,Pe).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=s(this,mo)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:o,width:l,height:c}=n;s(this,sn).showDialog(null,this,r+e*l,o+i*c,{...t,parentDimensions:n})}render(){var i,n;if(s(this,rn))return;const t=p(this,rn,document.createElement("div"));if(t.className="popup",s(this,_c)){const r=t.style.outlineColor=Z.makeHexColor(...s(this,_c));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(i=s(this,kc))!=null&&i.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=s(this,kc)}if(t.append(e),s(this,go)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:s(this,go).valueOf()})),r.dateTime=s(this,go).toISOString(),e.append(r)}m0({html:s(this,wt,Rp)||s(this,As).str,dir:(n=s(this,As))==null?void 0:n.dir,className:"popupContent"},t),s(this,Te).append(t)}updateEdited({rect:t,popup:e,deleted:i}){var n;if(s(this,sn)){i?(this.remove(),p(this,yo,null)):e&&(e.deleted?this.remove():(A(this,wt,mb).call(this),p(this,yo,e.text))),t&&(p(this,ur,null),A(this,wt,pb).call(this),A(this,wt,gb).call(this));return}if(i||e!=null&&e.deleted){this.remove();return}A(this,wt,Mp).call(this),s(this,Na)||p(this,Na,{contentsObj:s(this,As),richText:s(this,fr)}),t&&p(this,dr,null),e&&e.text&&(p(this,fr,A(this,wt,hw).call(this,e.text)),p(this,go,yf.toDateObject(e.date)),p(this,As,null)),(n=s(this,rn))==null||n.remove(),p(this,rn,null)}resetEdited(){var t;s(this,Na)&&({contentsObj:Xe(this,As)._,richText:Xe(this,fr)._}=s(this,Na),p(this,Na,null),(t=s(this,rn))==null||t.remove(),p(this,rn,null),p(this,dr,null))}remove(){var t,e,i;if((t=s(this,hr))==null||t.abort(),p(this,hr,null),(e=s(this,rn))==null||e.remove(),p(this,rn,null),p(this,bo,!1),p(this,Ss,!1),(i=s(this,Pe))==null||i.remove(),p(this,Pe,null),this.trigger)for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){p(this,bo,this.isVisible),s(this,bo)&&(s(this,Te).hidden=!0)}maybeShow(){s(this,sn)||(A(this,wt,Mp).call(this),s(this,bo)&&(s(this,rn)||A(this,wt,Op).call(this),p(this,bo,!1),s(this,Te).hidden=!1))}get isVisible(){return s(this,sn)?!1:s(this,Te).hidden===!1}}sn=new WeakMap,po=new WeakMap,Qf=new WeakMap,tp=new WeakMap,Cc=new WeakMap,_c=new WeakMap,Te=new WeakMap,As=new WeakMap,go=new WeakMap,La=new WeakMap,Tc=new WeakMap,Pc=new WeakMap,Ss=new WeakMap,rn=new WeakMap,hr=new WeakMap,dr=new WeakMap,Pe=new WeakMap,ur=new WeakMap,mo=new WeakMap,Kd=new WeakMap,fr=new WeakMap,kc=new WeakMap,Na=new WeakMap,bo=new WeakMap,Je=new WeakMap,yo=new WeakMap,wt=new WeakSet,Mp=function(){var e;if(s(this,hr))return;p(this,hr,new AbortController);const{signal:t}=s(this,hr);for(const i of this.trigger)i.addEventListener("click",s(this,Cc),{signal:t}),i.addEventListener("pointerenter",s(this,tp),{signal:t}),i.addEventListener("pointerleave",s(this,Qf),{signal:t}),i.classList.add("popupTriggerArea");for(const i of s(this,La))(e=i.container)==null||e.addEventListener("keydown",s(this,po),{signal:t})},pb=function(){const t=s(this,La).find(e=>e.hasCommentButton);t&&p(this,ur,t._normalizePoint(t.commentButtonPosition))},gb=function(){if(s(this,Je).extraPopupElement&&!s(this,Je).editor)return;s(this,Pe)||this.renderCommentButton();const[t,e]=s(this,ur),{style:i}=s(this,Pe);i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`},mb=function(){s(this,Je).extraPopupElement||(s(this,Pe)||this.renderCommentButton(),s(this,Pe).style.backgroundColor=this.commentButtonColor||"")},Rp=function(){const t=s(this,fr),e=s(this,As);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&s(this,fr).html||null},bb=function(){var t,e,i;return((i=(e=(t=s(this,wt,Rp))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:i.fontSize)||0},cw=function(){var t,e,i;return((i=(e=(t=s(this,wt,Rp))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:i.color)||null},hw=function(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:s(this,wt,cw),fontSize:s(this,wt,bb)?`calc(${s(this,wt,bb)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
102
- `))e.push({name:"span",value:r,attributes:n});return i},dw=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&s(this,Ss))&&A(this,wt,Dp).call(this)},uw=function(){if(s(this,dr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:r}}}=s(this,Tc);let o=!!s(this,Pc),l=o?s(this,Pc):s(this,Kd);for(const b of s(this,La))if(!l||Z.intersect(b.data.rect,l)!==null){l=b.data.rect,o=!0;break}const c=Z.normalizeRect([l[0],t[3]-l[1]+t[1],l[2],t[3]-l[3]+t[1]]),d=o?l[2]-l[0]+5:0,f=c[0]+d,u=c[1];p(this,dr,[100*(f-n)/e,100*(u-r)/i]);const{style:g}=s(this,Te);g.left=`${s(this,dr)[0]}%`,g.top=`${s(this,dr)[1]}%`},Dp=function(){if(s(this,sn)){s(this,sn).toggleCommentPopup(this,!1);return}p(this,Ss,!s(this,Ss)),s(this,Ss)?(A(this,wt,Op).call(this),s(this,Te).addEventListener("click",s(this,Cc)),s(this,Te).addEventListener("keydown",s(this,po))):(A(this,wt,yb).call(this),s(this,Te).removeEventListener("click",s(this,Cc)),s(this,Te).removeEventListener("keydown",s(this,po)))},Op=function(){s(this,rn)||this.render(),this.isVisible?s(this,Ss)&&s(this,Te).classList.add("focused"):(A(this,wt,uw).call(this),s(this,Te).hidden=!1,s(this,Te).style.zIndex=parseInt(s(this,Te).style.zIndex)+1e3)},yb=function(){s(this,Te).classList.remove("focused"),!(s(this,Ss)||!this.isVisible)&&(s(this,Te).hidden=!0,s(this,Te).style.zIndex=parseInt(s(this,Te).style.zIndex)-1e3)};class iv extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=mt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class vx extends ve{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,Jd,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=p(this,Jd,this.svgFactory.createElement("svg:line"));return o.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),o.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),o.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),o.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),o.setAttribute("stroke-width",e.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,Jd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Jd=new WeakMap;class wx extends ve{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,Zd,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=e.borderStyle.width,l=p(this,Zd,this.svgFactory.createElement("svg:rect"));return l.setAttribute("x",o/2),l.setAttribute("y",o/2),l.setAttribute("width",i-o),l.setAttribute("height",n-o),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,Zd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Zd=new WeakMap;class Ax extends ve{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,Qd,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=e.borderStyle.width,l=p(this,Qd,this.svgFactory.createElement("svg:ellipse"));return l.setAttribute("cx",i/2),l.setAttribute("cy",n/2),l.setAttribute("rx",i/2-o/2),l.setAttribute("ry",n/2-o/2),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,Qd)}addHighlightArea(){this.container.classList.add("highlightArea")}}Qd=new WeakMap;class nv extends ve{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,tu,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:i,borderStyle:n,popupRef:r},width:o,height:l}=this;if(!i)return this.container;const c=this.svgFactory.create(o,l,!0);let h=[];for(let f=0,u=i.length;f<u;f+=2){const g=i[f]-e[0],b=e[3]-i[f+1];h.push(`${g},${b}`)}h=h.join(" ");const d=p(this,tu,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",h),d.setAttribute("stroke-width",n.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),c.append(d),this.container.append(c),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,tu)}addHighlightArea(){this.container.classList.add("highlightArea")}}tu=new WeakMap;class Sx extends nv{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Ex extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class um extends ve{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});v(this,iu);v(this,eu,null);v(this,Fa,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?mt.HIGHLIGHT:mt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:i,inkLists:n,borderStyle:r,popupRef:o}}=this,{transform:l,width:c,height:h}=A(this,iu,vb).call(this,i,e),d=this.svgFactory.create(c,h,!0),f=p(this,eu,this.svgFactory.createElement("svg:g"));d.append(f),f.setAttribute("stroke-width",r.width||1),f.setAttribute("stroke-linecap","round"),f.setAttribute("stroke-linejoin","round"),f.setAttribute("stroke-miterlimit",10),f.setAttribute("stroke","transparent"),f.setAttribute("fill","transparent"),f.setAttribute("transform",l);for(let u=0,g=n.length;u<g;u++){const b=this.svgFactory.createElement(this.svgElementName);s(this,Fa).push(b),b.setAttribute("points",n[u].join(",")),f.append(b)}return!o&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(d),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:i,points:n,rect:r}=e,o=s(this,eu);if(i>=0&&o.setAttribute("stroke-width",i||1),n)for(let l=0,c=s(this,Fa).length;l<c;l++)s(this,Fa)[l].setAttribute("points",n[l].join(","));if(r){const{transform:l,width:c,height:h}=A(this,iu,vb).call(this,this.data.rotation,r);o.parentElement.setAttribute("viewBox",`0 0 ${c} ${h}`),o.setAttribute("transform",l)}}getElementsToTriggerPopup(){return s(this,Fa)}addHighlightArea(){this.container.classList.add("highlightArea")}}eu=new WeakMap,Fa=new WeakMap,iu=new WeakSet,vb=function(e,i){switch(e){case 90:return{transform:`rotate(90) translate(${-i[0]},${i[1]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};case 180:return{transform:`rotate(180) translate(${-i[2]},${i[1]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]};case 270:return{transform:`rotate(270) translate(${-i[2]},${i[3]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};default:return{transform:`translate(${-i[0]},${i[3]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]}}};class sv extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=mt.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const i=document.createElement("mark");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class xx extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class Cx extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class _x extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const i=document.createElement("s");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class rv extends ve{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=mt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Tx extends ve{constructor(e){var n;super(e,{isRenderable:!0});v(this,su);v(this,nu,null);const{file:i}=this.data;this.filename=i.filename,this.content=i.content,(n=this.linkService.eventBus)==null||n.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:i}=this;let n;i.hasAppearance||i.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(i.fillAlpha*100)}%);`)),n.addEventListener("dblclick",A(this,su,wb).bind(this)),p(this,nu,n);const{isMac:r}=ze.platform;return e.addEventListener("keydown",o=>{o.key==="Enter"&&(r?o.metaKey:o.ctrlKey)&&A(this,su,wb).call(this)}),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return s(this,nu)}addHighlightArea(){this.container.classList.add("highlightArea")}}nu=new WeakMap,su=new WeakSet,wb=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};const Rm=class Rm{constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:r,viewport:o,structTreeLayer:l,commentManager:c,linkService:h,annotationStorage:d}){v(this,pr);v(this,Ba,null);v(this,ja,null);v(this,Mc,null);v(this,vo,new Map);v(this,ru,null);v(this,za,null);v(this,on,[]);v(this,ou,!1);this.div=t,p(this,Ba,e),p(this,ja,i),p(this,ru,l||null),p(this,za,h||null),p(this,Mc,d||new Xg),this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=c||null}hasEditableAnnotations(){return s(this,vo).size>0}async render(t){var l;const{annotations:e}=t,i=this.div;Bo(i,this.viewport);const n=new Map,r=[],o={data:null,layer:i,linkService:s(this,za),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new If,annotationStorage:s(this,Mc),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const h=c.annotationType===De.POPUP;if(h){const u=n.get(c.id);if(!u)continue;if(!this._commentManager){r.push(c);continue}o.elements=u}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=cm.create(o);if(!d.isRenderable)continue;if(!h&&(s(this,on).push(d),c.popupRef)){const u=n.get(c.popupRef);u?u.push(d):n.set(c.popupRef,[d])}const f=d.render();c.hidden&&(f.style.visibility="hidden"),d._isEditable&&(s(this,vo).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await A(this,pr,Ip).call(this);for(const c of r){const h=o.elements=n.get(c.id);o.data=c;const d=cm.create(o);if(!d.isRenderable)continue;const f=d.render();d.contentElement.id=`${yl}${c.id}`,c.hidden&&(f.style.visibility="hidden"),h.at(-1).container.after(f)}A(this,pr,Ab).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:s(this,za),svgFactory:new If,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=Rm._defaultBorderStyle),e.data=i;const n=cm.create(e);n.isRenderable&&(n.render(),n.contentElement.id=`${yl}${i.id}`,s(this,on).push(n))}await A(this,pr,Ip).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,Bo(e,{rotation:t.rotation}),A(this,pr,Ab).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(s(this,vo).values())}getEditableAnnotation(t){return s(this,vo).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:n}=t,r=new dx({data:{id:i,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:s(this,za),annotationStorage:s(this,Mc)});return r.render(),r.contentElement.id=`${yl}${i}`,r.createOrUpdatePopup(),s(this,on).push(r),r}removeAnnotation(t){var n;const e=s(this,on).findIndex(r=>r.data.id===t);if(e<0)return;const[i]=s(this,on).splice(e,1);(n=s(this,Ba))==null||n.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);A(this,pr,Ip).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return gt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:bl.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};Ba=new WeakMap,ja=new WeakMap,Mc=new WeakMap,vo=new WeakMap,ru=new WeakMap,za=new WeakMap,on=new WeakMap,ou=new WeakMap,pr=new WeakSet,Ip=async function(){var i,n,r;if(s(this,on).length===0)return;this.div.replaceChildren();const t=[];if(!s(this,ou)){p(this,ou,!0);for(const{contentElement:o,data:{id:l}}of s(this,on)){const c=o.id=`${yl}${l}`;t.push((i=s(this,ru))==null?void 0:i.getAriaAttributes(c).then(h=>{if(h)for(const[d,f]of h)o.setAttribute(d,f)}))}}s(this,on).sort(({data:{rect:[o,l,c,h]}},{data:{rect:[d,f,u,g]}})=>{if(o===c&&l===h)return 1;if(d===u&&f===g)return-1;const b=h,m=l,w=(l+h)/2,y=g,x=f,E=(f+g)/2;if(w>=y&&E<=m)return-1;if(E>=b&&w<=x)return 1;const _=(o+c)/2,C=(d+u)/2;return _-C});const e=document.createDocumentFragment();for(const o of s(this,on))e.append(o.container),this._commentManager?(r=((n=o.extraPopupElement)==null?void 0:n.popup)||o.popup)==null||r.renderCommentButton():o.extraPopupElement&&e.append(o.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),s(this,Ba))for(const o of s(this,on))s(this,Ba).addPointerInTextLayer(o.contentElement,!1)},Ab=function(){var e;if(!s(this,ja))return;const t=this.div;for(const[i,n]of s(this,ja)){const r=t.querySelector(`[data-annotation-id="${i}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:o}=r;o?o.nodeName==="CANVAS"?o.replaceWith(n):o.classList.contains("annotationContent")?o.after(n):o.before(n):r.append(n);const l=s(this,vo).get(i);l&&(l._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(i,r.id,n),l._hasNoCanvas=!1):l.canvas=n)}s(this,ja).clear()};let fm=Rm;const Lf=/\r\n?|\n/g,ue=class ue extends ae{constructor(e){super({...e,name:"freeTextEditor"});v(this,Le);v(this,an,"");v(this,au,`${this.id}-editor`);v(this,Ua,null);v(this,ln);$(this,"_colorPicker",null);this.color=e.color||ue._defaultColor||ae._defaultLineColor,p(this,ln,e.fontSize||ue._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static get _keyboardManager(){const e=ue.prototype,i=o=>o.isEmpty(),n=jo.TRANSLATE_SMALL,r=jo.TRANSLATE_BIG;return gt(this,"_keyboardManager",new Ch([[["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:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:i}]]))}static initialize(e,i){ae.initialize(e,i);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,i){switch(e){case Mt.FREETEXT_SIZE:ue._defaultFontSize=i;break;case Mt.FREETEXT_COLOR:ue._defaultColor=i;break}}updateParams(e,i){switch(e){case Mt.FREETEXT_SIZE:A(this,Le,fw).call(this,i);break;case Mt.FREETEXT_COLOR:A(this,Le,pw).call(this,i);break}}static get defaultPropertiesToUpdate(){return[[Mt.FREETEXT_SIZE,ue._defaultFontSize],[Mt.FREETEXT_COLOR,ue._defaultColor||ae._defaultLineColor]]}get propertiesToUpdate(){return[[Mt.FREETEXT_SIZE,s(this,ln)],[Mt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Of(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Mt.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,i){this._uiManager.translateSelectedEditors(e,i,!0)}getInitialTranslation(){const e=this.parentScale;return[-ue._internalPadding*e,-(ue._internalPadding+s(this,ln))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),p(this,Ua,new AbortController);const e=this._uiManager.combinedSignal(s(this,Ua));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",s(this,au)),this._isDraggable=!0,(e=s(this,Ua))==null||e.abort(),p(this,Ua,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var i;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(i=this._initialOptions)!=null&&i.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=s(this,an),i=p(this,an,A(this,Le,gw).call(this).trimEnd());if(e===i)return;const n=r=>{if(p(this,an,r),!r){this.remove();return}A(this,Le,Fp).call(this),this._uiManager.rebuild(this),A(this,Le,Lp).call(this)};this.addCommands({cmd:()=>{n(i)},undo:()=>{n(e)},mustExec:!1}),A(this,Le,Lp).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){ue._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,i;(this._isCopy||this.annotationElementId)&&(e=this.x,i=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",s(this,au)),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:n}=this.editorDiv;if(n.fontSize=`calc(${s(this,ln)}px * var(--total-scale-factor))`,n.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,o]=this.parentDimensions;if(this.annotationElementId){const{position:l}=this._initialData;let[c,h]=this.getInitialTranslation();[c,h]=this.pageTranslationToScreen(c,h);const[d,f]=this.pageDimensions,[u,g]=this.pageTranslation;let b,m;switch(this.rotation){case 0:b=e+(l[0]-u)/d,m=i+this.height-(l[1]-g)/f;break;case 90:b=e+(l[0]-u)/d,m=i-(l[1]-g)/f,[c,h]=[h,-c];break;case 180:b=e-this.width+(l[0]-u)/d,m=i-(l[1]-g)/f,[c,h]=[-c,-h];break;case 270:b=e+(l[0]-u-this.height*f)/d,m=i+(l[1]-g-this.width*d)/f,[c,h]=[-h,c];break}this.setAt(b*r,m*o,c,h)}else this._moveAfterPaste(e,i);A(this,Le,Fp).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var b,m,w;const i=e.clipboardData||window.clipboardData,{types:n}=i;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=A(b=ue,gr,Sb).call(b,i.getData("text")||"").replaceAll(Lf,`
97
+ (To allow non-serializable values see: https://redux-toolkit.js.org/usage/usage-guide#working-with-non-serializable-data)`)}}),p||(R.measureTime(function(){var N=A.getState(),z=Cg(N,"",e,i,h,_);if(z){var H=z.keyPath,I=z.value;console.error("A non-serializable value was detected in the state, in the path: `"+H+"`. Value:",I,`
98
+ Take a look at the reducer(s) handling this action type: `+x.type+`.
99
+ (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)`)}}),R.warnIfExceeded()),P}}}}function cf(a){return typeof a=="boolean"}function A1(){return function(t){return S1(t)}}function S1(a){a===void 0&&(a={});var t=a.thunk,e=t===void 0?!0:t,i=a.immutableCheck,n=i===void 0?!0:i,r=a.serializableCheck,o=r===void 0?!0:r,l=a.actionCreatorCheck,c=l===void 0?!0:l,h=new u1;if(e&&(cf(e)?h.push(Sg):h.push(Sg.withExtraArgument(e.extraArgument))),process.env.NODE_ENV!=="production"){if(n){var d={};cf(n)||(d=n),h.unshift(v1(d))}if(o){var u={};cf(o)||(u=o),h.push(w1(u))}if(c){var f={};cf(c)||(f=c),h.unshift(d1(f))}}return h}var _g=process.env.NODE_ENV==="production";function E1(a){var t=A1(),e=a||{},i=e.reducer,n=i===void 0?void 0:i,r=e.middleware,o=r===void 0?t():r,l=e.devTools,c=l===void 0?!0:l,h=e.preloadedState,d=h===void 0?void 0:h,u=e.enhancers,f=u===void 0?void 0:u,p;if(typeof n=="function")p=n;else if(Ny(n))p=ZA(n);else throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');var m=o;if(typeof m=="function"&&(m=m(t),!_g&&!Array.isArray(m)))throw new Error("when using a middleware builder function, an array of middleware must be returned");if(!_g&&m.some(function(C){return typeof C!="function"}))throw new Error("each middleware provided to configureStore must be a function");var b=QA.apply(void 0,m),v=lf;c&&(v=a1(Or({trace:!_g},typeof c=="object"&&c)));var w=new f1(b),_=w;Array.isArray(f)?_=Sl([b],f):typeof f=="function"&&(_=f(w));var A=v.apply(void 0,_);return My(p,d,A)}function Wy(a){var t={},e=[],i,n={addCase:function(r,o){if(process.env.NODE_ENV!=="production"){if(e.length>0)throw new Error("`builder.addCase` should only be called before calling `builder.addMatcher`");if(i)throw new Error("`builder.addCase` should only be called before calling `builder.addDefaultCase`")}var l=typeof r=="string"?r:r.type;if(!l)throw new Error("`builder.addCase` cannot be called with an empty action type");if(l in t)throw new Error("`builder.addCase` cannot be called with two reducers for the same action type");return t[l]=o,n},addMatcher:function(r,o){if(process.env.NODE_ENV!=="production"&&i)throw new Error("`builder.addMatcher` should only be called before calling `builder.addDefaultCase`");return e.push({matcher:r,reducer:o}),n},addDefaultCase:function(r){if(process.env.NODE_ENV!=="production"&&i)throw new Error("`builder.addDefaultCase` can only be called once");return i=r,n}};return a(n),[t,e,i]}function x1(a){return typeof a=="function"}var Vy=!1;function C1(a,t,e,i){e===void 0&&(e=[]),process.env.NODE_ENV!=="production"&&typeof t=="object"&&(Vy||(Vy=!0,console.warn("The object notation for `createReducer` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createReducer")));var n=typeof t=="function"?Wy(t):[t,e,i],r=n[0],o=n[1],l=n[2],c;if(x1(a))c=function(){return xg(a())};else{var h=xg(a);c=function(){return h}}function d(u,f){u===void 0&&(u=c());var p=Sl([r[f.type]],o.filter(function(m){var b=m.matcher;return b(f)}).map(function(m){var b=m.reducer;return b}));return p.filter(function(m){return!!m}).length===0&&(p=[l]),p.reduce(function(m,b){if(b)if(Mr(m)){var v=m,w=b(v,f);return w===void 0?m:w}else{if(Ds(m))return Cy(m,function(_){return b(_,f)});var w=b(m,f);if(w===void 0){if(m===null)return m;throw Error("A case reducer on a non-draftable value must not return undefined")}return w}return m},u)}return d.getInitialState=c,d}var Gy=!1;function _1(a,t){return a+"/"+t}function T1(a){var t=a.name;typeof process<"u"&&process.env.NODE_ENV==="development"&&a.initialState===void 0&&console.error("You must provide an `initialState` value that is not `undefined`. You may have misspelled `initialState`");var e=typeof a.initialState=="function"?a.initialState:xg(a.initialState),i=a.reducers||{},n=Object.keys(i),r={},o={},l={};n.forEach(function(d){var u=i[d],f=_1(t,d),p,m;"reducer"in u?(p=u.reducer,m=u.prepare):p=u,r[d]=p,o[f]=p,l[d]=m?Ir(f,m):Ir(f)});function c(){process.env.NODE_ENV!=="production"&&typeof a.extraReducers=="object"&&(Gy||(Gy=!0,console.warn("The object notation for `createSlice.extraReducers` is deprecated, and will be removed in RTK 2.0. Please use the 'builder callback' notation instead: https://redux-toolkit.js.org/api/createSlice")));var d=typeof a.extraReducers=="function"?Wy(a.extraReducers):[a.extraReducers],u=d[0],f=u===void 0?{}:u,p=d[1],m=p===void 0?[]:p,b=d[2],v=b===void 0?void 0:b,w=Or(Or({},f),o);return C1(e,function(_){for(var A in w)_.addCase(A,w[A]);for(var C=0,x=m;C<x.length;C++){var P=x[C];_.addMatcher(P.matcher,P.reducer)}v&&_.addDefaultCase(v)})}var h;return{name:t,reducer:function(d,u){return h||(h=c()),h(d,u)},actions:l,caseReducers:r,getInitialState:function(){return h||(h=c()),h.getInitialState()}}}var P1="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",k1=function(a){a===void 0&&(a=21);for(var t="",e=a;e--;)t+=P1[Math.random()*64|0];return t},M1=["name","message","stack","code"],Tg=(function(){function a(t,e){this.payload=t,this.meta=e}return a})(),Yy=(function(){function a(t,e){this.payload=t,this.meta=e}return a})(),R1=function(a){if(typeof a=="object"&&a!==null){for(var t={},e=0,i=M1;e<i.length;e++){var n=i[e];typeof a[n]=="string"&&(t[n]=a[n])}return t}return{message:String(a)}};(function(){function a(t,e,i){var n=Ir(t+"/fulfilled",function(d,u,f,p){return{payload:d,meta:Eg(Or({},p||{}),{arg:f,requestId:u,requestStatus:"fulfilled"})}}),r=Ir(t+"/pending",function(d,u,f){return{payload:void 0,meta:Eg(Or({},f||{}),{arg:u,requestId:d,requestStatus:"pending"})}}),o=Ir(t+"/rejected",function(d,u,f,p,m){return{payload:p,error:(i&&i.serializeError||R1)(d||"Rejected"),meta:Eg(Or({},m||{}),{arg:f,requestId:u,rejectedWithValue:!!p,requestStatus:"rejected",aborted:(d==null?void 0:d.name)==="AbortError",condition:(d==null?void 0:d.name)==="ConditionError"})}}),l=!1,c=typeof AbortController<"u"?AbortController:(function(){function d(){this.signal={aborted:!1,addEventListener:function(){},dispatchEvent:function(){return!1},onabort:function(){},removeEventListener:function(){},reason:void 0,throwIfAborted:function(){}}}return d.prototype.abort=function(){process.env.NODE_ENV!=="production"&&(l||(l=!0,console.info("This platform does not implement AbortController. \nIf you want to use the AbortController to react to `abort` events, please consider importing a polyfill like 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'.")))},d})();function h(d){return function(u,f,p){var m=i!=null&&i.idGenerator?i.idGenerator(d):k1(),b=new c,v;function w(A){v=A,b.abort()}var _=(function(){return o1(this,null,function(){var A,C,x,P,R,N,z;return t1(this,function(H){switch(H.label){case 0:return H.trys.push([0,4,,5]),P=(A=i==null?void 0:i.condition)==null?void 0:A.call(i,d,{getState:f,extra:p}),O1(P)?[4,P]:[3,2];case 1:P=H.sent(),H.label=2;case 2:if(P===!1||b.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};return R=new Promise(function(I,ct){return b.signal.addEventListener("abort",function(){return ct({name:"AbortError",message:v||"Aborted"})})}),u(r(m,d,(C=i==null?void 0:i.getPendingMeta)==null?void 0:C.call(i,{requestId:m,arg:d},{getState:f,extra:p}))),[4,Promise.race([R,Promise.resolve(e(d,{dispatch:u,getState:f,extra:p,requestId:m,signal:b.signal,abort:w,rejectWithValue:function(I,ct){return new Tg(I,ct)},fulfillWithValue:function(I,ct){return new Yy(I,ct)}})).then(function(I){if(I instanceof Tg)throw I;return I instanceof Yy?n(I.payload,m,d,I.meta):n(I,m,d)})])];case 3:return x=H.sent(),[3,5];case 4:return N=H.sent(),x=N instanceof Tg?o(null,m,d,N.payload,N.meta):o(N,m,d),[3,5];case 5:return z=i&&!i.dispatchConditionRejection&&o.match(x)&&x.meta.condition,z||u(x),[2,x]}})})})();return Object.assign(_,{abort:w,requestId:m,arg:d,unwrap:function(){return _.then(D1)}})}}return Object.assign(h,{pending:r,rejected:o,fulfilled:n,typePrefix:t})}return a.withTypes=function(){return a},a})();function D1(a){if(a.meta&&a.meta.rejectedWithValue)throw a.payload;if(a.error)throw a.error;return a.payload}function O1(a){return a!==null&&typeof a=="object"&&typeof a.then=="function"}var Pg="listenerMiddleware";Ir(Pg+"/add"),Ir(Pg+"/removeAll"),Ir(Pg+"/remove");var Xy;typeof queueMicrotask=="function"&&queueMicrotask.bind(typeof window<"u"?window:typeof global<"u"?global:globalThis),FA();const I1={grid:{size:20,color:"#ccc",enabled:!0},toolbar:{selectedTool:"pointer"},toolProperties:{pencil:{strokeColor:"#000000",lineWidth:4},rectangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},circle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},triangle:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},diamond:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},star:{strokeColor:"#000000",fillColor:"#ffff00",lineWidth:2},heart:{strokeColor:"#000000",fillColor:"#ff6b6b",lineWidth:2},hexagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},octagon:{strokeColor:"#000000",fillColor:"#ffffff",lineWidth:2},arrow:{strokeColor:"#000000",fillColor:"#000000",lineWidth:2},text:{fontSize:16,fontColor:"#000000"}},elements:[],selectedElementIds:[],viewport:{panX:0,panY:0,zoom:1},watermark:{text:"Nines Studios",url:"https://github.com/huzeyfecoskun",visible:!0},lock:{isLocked:!1,text:null}};function L1(a){const t=[],e=new Set;for(const i of a){const n=i==null?void 0:i.id;if(n==null){t.push(i);continue}e.has(n)||(e.add(n),t.push(i))}return t}const kg=T1({name:"whiteboard",initialState:I1,reducers:{toggleGrid(a){a.grid.enabled=!a.grid.enabled},setGridSize(a,t){a.grid.size=t.payload},setGridColor(a,t){a.grid.color=t.payload},setSelectedTool(a,t){a.toolbar.selectedTool=t.payload},setToolProperty(a,t){const{tool:e,property:i,value:n}=t.payload;a.toolProperties[e]&&(a.toolProperties[e][i]=n)},addElement(a,t){const e=t.payload,i=e==null?void 0:e.id;i!=null&&a.elements.some(r=>(r==null?void 0:r.id)===i)||a.elements.push(e)},updateElement(a,t){const{id:e,updates:i}=t.payload,n=a.elements.findIndex(r=>r.id===e);n!==-1&&(a.elements[n]={...a.elements[n],...i})},updateElements(a,t){t.payload.forEach(({id:i,updates:n})=>{const r=a.elements.findIndex(o=>o.id===i);r!==-1&&(a.elements[r]={...a.elements[r],...n})})},removeElement(a,t){const e=t.payload;a.elements=a.elements.filter(i=>i.id!==e),a.selectedElementIds=a.selectedElementIds.filter(i=>i!==e)},setSelectedElements(a,t){a.selectedElementIds=t.payload},clearElements(a){a.elements=[],a.selectedElementIds=[]},setElements(a,t){const e=Array.isArray(t.payload)?t.payload:[];a.elements=L1(e),a.selectedElementIds=[]},setPan(a,t){a.viewport.panX=t.payload.x,a.viewport.panY=t.payload.y},setZoom(a,t){a.viewport.zoom=Math.max(.1,Math.min(5,t.payload))},setPdf(a,t){t.payload?a.pdf={url:t.payload}:a.pdf=void 0},resetViewport(a){a.viewport.panX=0,a.viewport.panY=0,a.viewport.zoom=1},bringToFront(a,t){const e=t.payload,i=a.elements.findIndex(n=>n.id===e);if(i!==-1&&i<a.elements.length-1){const[n]=a.elements.splice(i,1);a.elements.push(n)}},sendToBack(a,t){const e=t.payload,i=a.elements.findIndex(n=>n.id===e);if(i>0){const[n]=a.elements.splice(i,1);a.elements.unshift(n)}},fitToView(a,t){const{canvasWidth:e,canvasHeight:i,padding:n=50}=t.payload,r=a.elements;if(r.length===0){a.viewport.panX=0,a.viewport.panY=0,a.viewport.zoom=1;return}let o=1/0,l=1/0,c=-1/0,h=-1/0;if(r.forEach(x=>{const P=R=>R??0;if(x.type==="rectangle"){const R=P(x.x),N=P(x.y),z=P(x.width),H=P(x.height);o=Math.min(o,R),l=Math.min(l,N),c=Math.max(c,R+z),h=Math.max(h,N+H)}else if(x.type==="circle"){const R=P(x.centerX),N=P(x.centerY),z=P(x.radius);o=Math.min(o,R-z),l=Math.min(l,N-z),c=Math.max(c,R+z),h=Math.max(h,N+z)}else if(x.type==="pencil"&&x.points&&x.points.length>0)x.points.forEach(R=>{o=Math.min(o,R.x),l=Math.min(l,R.y),c=Math.max(c,R.x),h=Math.max(h,R.y)});else if(x.type==="triangle"||x.type==="diamond"||x.type==="hexagon"||x.type==="octagon"){const R=P(x.x),N=P(x.y),z=P(x.width),H=P(x.height);o=Math.min(o,R),l=Math.min(l,N),c=Math.max(c,R+z),h=Math.max(h,N+H)}else if(x.type==="star"||x.type==="heart"){const R=P(x.centerX),N=P(x.centerY),z=P(x.size);o=Math.min(o,R-z),l=Math.min(l,N-z),c=Math.max(c,R+z),h=Math.max(h,N+z)}else if(x.type==="arrow"){const R=P(x.startX),N=P(x.startY),z=P(x.endX),H=P(x.endY);o=Math.min(o,R,z),l=Math.min(l,N,H),c=Math.max(c,R,z),h=Math.max(h,N,H)}}),o===1/0)return;const d=c-o,u=h-l;if(d<=0||u<=0)return;const f=e-n*2,p=i-n*2,m=f/d,b=p/u,v=Math.min(m,b,5),w=(o+c)/2,_=(l+h)/2,A=e/2-w*v,C=i/2-_*v;a.viewport.zoom=Math.max(.1,v),a.viewport.panX=A,a.viewport.panY=C},setLocked(a,t){a.lock.isLocked=t.payload,t.payload&&(a.toolbar.selectedTool="pointer",a.selectedElementIds=[])},setWatermarkEnabled(a,t){a.watermark.visible=t.payload},setWatermarkText(a,t){a.watermark.text=t.payload}}}),{toggleGrid:N1,setGridSize:Jx,setGridColor:Zx,setSelectedTool:Fn,setToolProperty:F1,addElement:Di,updateElement:hf,updateElements:qy,removeElement:B1,setSelectedElements:Os,clearElements:bh,setElements:Mg,setPan:Bo,setZoom:yh,resetViewport:Qx,fitToView:j1,bringToFront:z1,sendToBack:U1,setLocked:Ky,setWatermarkEnabled:H1,setWatermarkText:$1,setPdf:Rg}=kg.actions,W1=kg.actions,Jy=kg.reducer,V1=new Set(["rectangle","circle","pencil","triangle","diamond","star","heart","hexagon","octagon","arrow","image","text"]),G1=new Set(["strokeColor","fillColor","lineWidth","fontSize","fontColor","textColor"]),Y1=a=>{var t,e;if(!a||typeof a.type!="string"||a.type.startsWith("@@redux/"))return!1;if(a.type==="whiteboard/addElement"){const i=(t=a==null?void 0:a.payload)==null?void 0:t.type;return typeof i=="string"&&V1.has(i)}if(a.type==="whiteboard/removeElement"||a.type==="whiteboard/clearElements"||a.type==="whiteboard/setPdf"||a.type==="whiteboard/bringToFront"||a.type==="whiteboard/sendToBack")return!0;if(a.type==="whiteboard/setToolProperty"){const{tool:i,property:n}=(a==null?void 0:a.payload)??{};return typeof i!="string"||typeof n!="string"?!1:G1.has(n)}if(a.type==="whiteboard/updateElement")return Zy((e=a==null?void 0:a.payload)==null?void 0:e.updates);if(a.type==="whiteboard/updateElements"){const i=a==null?void 0:a.payload;return Array.isArray(i)?i.some(n=>Zy(n.updates)):!1}return!1},Zy=a=>{if(!a||typeof a!="object")return!1;const t=e=>Object.prototype.hasOwnProperty.call(a,e);return!!(t("text")||t("fontSize")||t("fontColor")||t("textColor")||t("strokeColor")||t("fillColor")||t("lineWidth")||t("x")||t("y")||t("width")||t("height")||t("centerX")||t("centerY")||t("radius")||t("size")||t("startX")||t("startY")||t("endX")||t("endY")||t("points")||t("src"))},X1=a=>t=>e=>i=>{var r;const n=e(i);return!((r=i.meta)!=null&&r.fromRemote)&&a&&a.current&&Y1(i)&&a.current(i,t.getState()),n},Dg=({preloadedState:a,actionHandlerRef:t}={})=>E1({reducer:{whiteboard:Jy},middleware:e=>e().concat(X1(t)),preloadedState:a}),q1=Dg(),K1=()=>{const a=ii(t=>t.whiteboard.watermark);return M.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",children:M.jsx("div",{className:"wb-watermark",children:a.text})})};var Qy={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},t0=B.createContext&&B.createContext(Qy),J1=["attr","size","title"];function Z1(a,t){if(a==null)return{};var e=Q1(a,t),i,n;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(a);for(n=0;n<r.length;n++)i=r[n],!(t.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(a,i)&&(e[i]=a[i])}return e}function Q1(a,t){if(a==null)return{};var e={};for(var i in a)if(Object.prototype.hasOwnProperty.call(a,i)){if(t.indexOf(i)>=0)continue;e[i]=a[i]}return e}function df(){return df=Object.assign?Object.assign.bind():function(a){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(a[i]=e[i])}return a},df.apply(this,arguments)}function e0(a,t){var e=Object.keys(a);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(a);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(a,n).enumerable})),e.push.apply(e,i)}return e}function uf(a){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?e0(Object(e),!0).forEach(function(i){tS(a,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(e)):e0(Object(e)).forEach(function(i){Object.defineProperty(a,i,Object.getOwnPropertyDescriptor(e,i))})}return a}function tS(a,t,e){return t=eS(t),t in a?Object.defineProperty(a,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):a[t]=e,a}function eS(a){var t=iS(a,"string");return typeof t=="symbol"?t:t+""}function iS(a,t){if(typeof a!="object"||!a)return a;var e=a[Symbol.toPrimitive];if(e!==void 0){var i=e.call(a,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(a)}function i0(a){return a&&a.map((t,e)=>B.createElement(t.tag,uf({key:e},t.attr),i0(t.child)))}function ie(a){return t=>B.createElement(nS,df({attr:uf({},a.attr)},t),i0(a.child))}function nS(a){var t=e=>{var{attr:i,size:n,title:r}=a,o=Z1(a,J1),l=n||e.size||"1em",c;return e.className&&(c=e.className),a.className&&(c=(c?c+" ":"")+a.className),B.createElement("svg",df({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},e.attr,i,o,{className:c,style:uf(uf({color:a.color||e.color},e.style),a.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),r&&B.createElement("title",null,r),a.children)};return t0!==void 0?B.createElement(t0.Consumer,null,e=>t(e)):t(Qy)}function sS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 32H32A32 32 0 0 0 0 64v384a32 32 0 0 0 32 32h384a32 32 0 0 0 32-32V64a32 32 0 0 0-32-32zm-32 64v128H256V96zm-192 0v128H64V96zM64 416V288h128v128zm192 0V288h128v128z"},child:[]}]})(a)}function rS(a){return ie({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"},child:[]}]})(a)}function oS(a){return ie({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"},child:[]}]})(a)}function aS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"},child:[]}]})(a)}function lS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M216 0h80c13.3 0 24 10.7 24 24v168h87.7c17.8 0 26.7 21.5 14.1 34.1L269.7 378.3c-7.5 7.5-19.8 7.5-27.3 0L90.1 226.1c-12.6-12.6-3.7-34.1 14.1-34.1H192V24c0-13.3 10.7-24 24-24zm296 376v112c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V376c0-13.3 10.7-24 24-24h146.7l49 49c20.1 20.1 52.5 20.1 72.6 0l49-49H488c13.3 0 24 10.7 24 24zm-124 88c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20zm64 0c0-11-9-20-20-20s-20 9-20 20 9 20 20 20 20-9 20-20z"},child:[]}]})(a)}function cS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.941 273.941c18.745-18.745 18.745-49.137 0-67.882l-160-160c-18.745-18.745-49.136-18.746-67.883 0l-256 256c-18.745 18.745-18.745 49.137 0 67.882l96 96A48.004 48.004 0 0 0 144 480h356c6.627 0 12-5.373 12-12v-40c0-6.627-5.373-12-12-12H355.883l142.058-142.059zm-302.627-62.627l137.373 137.373L265.373 416H150.628l-80-80 124.686-124.686z"},child:[]}]})(a)}function hS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M0 180V56c0-13.3 10.7-24 24-24h124c6.6 0 12 5.4 12 12v40c0 6.6-5.4 12-12 12H64v84c0 6.6-5.4 12-12 12H12c-6.6 0-12-5.4-12-12zM288 44v40c0 6.6 5.4 12 12 12h84v84c0 6.6 5.4 12 12 12h40c6.6 0 12-5.4 12-12V56c0-13.3-10.7-24-24-24H300c-6.6 0-12 5.4-12 12zm148 276h-40c-6.6 0-12 5.4-12 12v84h-84c-6.6 0-12 5.4-12 12v40c0 6.6 5.4 12 12 12h124c13.3 0 24-10.7 24-24V332c0-6.6-5.4-12-12-12zM160 468v-40c0-6.6-5.4-12-12-12H64v-84c0-6.6-5.4-12-12-12H12c-6.6 0-12 5.4-12 12v124c0 13.3 10.7 24 24 24h124c6.6 0 12-5.4 12-12z"},child:[]}]})(a)}function dS(a){return ie({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M181.9 256.1c-5-16-4.9-46.9-2-46.9 8.4 0 7.6 36.9 2 46.9zm-1.7 47.2c-7.7 20.2-17.3 43.3-28.4 62.7 18.3-7 39-17.2 62.9-21.9-12.7-9.6-24.9-23.4-34.5-40.8zM86.1 428.1c0 .8 13.2-5.4 34.9-40.2-6.7 6.3-29.1 24.5-34.9 40.2zM248 160h136v328c0 13.3-10.7 24-24 24H24c-13.3 0-24-10.7-24-24V24C0 10.7 10.7 0 24 0h200v136c0 13.2 10.8 24 24 24zm-8 171.8c-20-12.2-33.3-29-42.7-53.8 4.5-18.5 11.6-46.6 6.2-64.2-4.7-29.4-42.4-26.5-47.8-6.8-5 18.3-.4 44.1 8.1 77-11.6 27.6-28.7 64.6-40.8 85.8-.1 0-.1.1-.2.1-27.1 13.9-73.6 44.5-54.5 68 5.6 6.9 16 10 21.5 10 17.9 0 35.7-18 61.1-61.8 25.8-8.5 54.1-19.1 79-23.2 21.7 11.8 47.1 19.5 64 19.5 29.2 0 31.2-32 19.7-43.4-13.9-13.6-54.3-9.7-73.6-7.2zM377 105L279 7c-4.5-4.5-10.6-7-17-7h-6v128h128v-6.1c0-6.3-2.5-12.4-7-16.9zm-74.1 255.3c4.1-2.7-2.5-11.9-42.8-9 37.1 15.8 42.8 9 42.8 9z"},child:[]}]})(a)}function uS(a){return ie({attr:{viewBox:"0 0 496 512"},child:[{tag:"path",attr:{d:"M336.5 160C322 70.7 287.8 8 248 8s-74 62.7-88.5 152h177zM152 256c0 22.2 1.2 43.5 3.3 64h185.3c2.1-20.5 3.3-41.8 3.3-64s-1.2-43.5-3.3-64H155.3c-2.1 20.5-3.3 41.8-3.3 64zm324.7-96c-28.6-67.9-86.5-120.4-158-141.6 24.4 33.8 41.2 84.7 50 141.6h108zM177.2 18.4C105.8 39.6 47.8 92.1 19.3 160h108c8.7-56.9 25.5-107.8 49.9-141.6zM487.4 192H372.7c2.1 21 3.3 42.5 3.3 64s-1.2 43-3.3 64h114.6c5.5-20.5 8.6-41.8 8.6-64s-3.1-43.5-8.5-64zM120 256c0-21.5 1.2-43 3.3-64H8.6C3.2 212.5 0 233.8 0 256s3.2 43.5 8.6 64h114.6c-2-21-3.2-42.5-3.2-64zm39.5 96c14.5 89.3 48.7 152 88.5 152s74-62.7 88.5-152h-177zm159.3 141.6c71.4-21.2 129.4-73.7 158-141.6h-108c-8.8 56.9-25.6 107.8-50 141.6zM19.3 352c28.6 67.9 86.5 120.4 158 141.6-24.4-33.8-41.2-84.7-50-141.6h-108z"},child:[]}]})(a)}function fS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"},child:[]}]})(a)}function pS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M464 448H48c-26.51 0-48-21.49-48-48V112c0-26.51 21.49-48 48-48h416c26.51 0 48 21.49 48 48v288c0 26.51-21.49 48-48 48zM112 120c-30.928 0-56 25.072-56 56s25.072 56 56 56 56-25.072 56-56-25.072-56-56-56zM64 384h384V272l-87.515-87.515c-4.686-4.686-12.284-4.686-16.971 0L208 320l-55.515-55.515c-4.686-4.686-12.284-4.686-16.971 0L64 336v48z"},child:[]}]})(a)}function gS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 224h-24v-72C376 68.2 307.8 0 224 0S72 68.2 72 152v72H48c-26.5 0-48 21.5-48 48v192c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V272c0-26.5-21.5-48-48-48zm-104 0H152v-72c0-39.7 32.3-72 72-72s72 32.3 72 72v72z"},child:[]}]})(a)}function mS(a){return ie({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M302.189 329.126H196.105l55.831 135.993c3.889 9.428-.555 19.999-9.444 23.999l-49.165 21.427c-9.165 4-19.443-.571-23.332-9.714l-53.053-129.136-86.664 89.138C18.729 472.71 0 463.554 0 447.977V18.299C0 1.899 19.921-6.096 30.277 5.443l284.412 292.542c11.472 11.179 3.007 31.141-12.5 31.141z"},child:[]}]})(a)}function bS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M497.9 142.1l-46.1 46.1c-4.7 4.7-12.3 4.7-17 0l-111-111c-4.7-4.7-4.7-12.3 0-17l46.1-46.1c18.7-18.7 49.1-18.7 67.9 0l60.1 60.1c18.8 18.7 18.8 49.1 0 67.9zM284.2 99.8L21.6 362.4.4 483.9c-2.9 16.4 11.4 30.6 27.8 27.8l121.5-21.3 262.6-262.6c4.7-4.7 4.7-12.3 0-17l-111-111c-4.8-4.7-12.4-4.7-17.1 0zM124.1 339.9c-5.5-5.5-5.5-14.3 0-19.8l154-154c5.5-5.5 14.3-5.5 19.8 0s5.5 14.3 0 19.8l-154 154c-5.5 5.5-14.3 5.5-19.8 0zM88 424h48v36.3l-64.5 11.3-31.1-31.1L51.7 376H88v48z"},child:[]}]})(a)}function yS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M424.4 214.7L72.4 6.6C43.8-10.3 0 6.1 0 47.9V464c0 37.5 40.7 60.1 72.4 41.3l352-208c31.4-18.5 31.5-64.1 0-82.6z"},child:[]}]})(a)}function vS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M433.941 129.941l-83.882-83.882A48 48 0 0 0 316.118 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h352c26.51 0 48-21.49 48-48V163.882a48 48 0 0 0-14.059-33.941zM224 416c-35.346 0-64-28.654-64-64 0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64zm96-304.52V212c0 6.627-5.373 12-12 12H76c-6.627 0-12-5.373-12-12V108c0-6.627 5.373-12 12-12h228.52c3.183 0 6.235 1.264 8.485 3.515l3.48 3.48A11.996 11.996 0 0 1 320 111.48z"},child:[]}]})(a)}function wS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M400 32H48C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48z"},child:[]}]})(a)}function AS(a){return ie({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M259.3 17.8L194 150.2 47.9 171.5c-26.2 3.8-36.7 36.1-17.7 54.6l105.7 103-25 145.5c-4.5 26.3 23.2 46 46.4 33.7L288 439.6l130.7 68.7c23.2 12.2 50.9-7.4 46.4-33.7l-25-145.5 105.7-103c19-18.5 8.5-50.8-17.7-54.6L382 150.2 316.7 17.8c-11.7-23.6-45.6-23.9-57.4 0z"},child:[]}]})(a)}function n0(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M432 32H312l-9.4-18.7A24 24 0 0 0 281.1 0H166.8a23.72 23.72 0 0 0-21.4 13.3L136 32H16A16 16 0 0 0 0 48v32a16 16 0 0 0 16 16h416a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM53.2 467a48 48 0 0 0 47.9 45h245.8a48 48 0 0 0 47.9-45L416 128H32z"},child:[]}]})(a)}const SS=({text:a,shifted:t})=>{const{t:e}=bl(),i=a??e("lockText")??"Locked";return M.jsxs("div",{className:`wb-lock-indicator ${t?"wb-shifted":""}`,children:[M.jsx(gS,{}),M.jsx("span",{children:i})]})};function ES(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"},child:[]}]})(a)}function xS(a){return ie({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M284.3 11.7c-15.6-15.6-40.9-15.6-56.6 0l-216 216c-15.6 15.6-15.6 40.9 0 56.6l216 216c15.6 15.6 40.9 15.6 56.6 0l216-216c15.6-15.6 15.6-40.9 0-56.6l-216-216z"},child:[]}]})(a)}function CS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M8 256a56 56 0 1 1 112 0A56 56 0 1 1 8 256zm160 0a56 56 0 1 1 112 0 56 56 0 1 1 -112 0zm216-56a56 56 0 1 1 0 112 56 56 0 1 1 0-112z"},child:[]}]})(a)}function _S(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144l0 48 160 0 0-48c0-44.2-35.8-80-80-80s-80 35.8-80 80zM80 192l0-48C80 64.5 144.5 0 224 0s144 64.5 144 144l0 48 16 0c35.3 0 64 28.7 64 64l0 192c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 256c0-35.3 28.7-64 64-64l16 0z"},child:[]}]})(a)}function TS(a){return ie({attr:{viewBox:"0 0 384 512"},child:[{tag:"path",attr:{d:"M32 32C14.3 32 0 46.3 0 64S14.3 96 32 96l128 0 0 352c0 17.7 14.3 32 32 32s32-14.3 32-32l0-352 128 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 32 32 32z"},child:[]}]})(a)}function PS(a){return ie({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M144 144c0-44.2 35.8-80 80-80c31.9 0 59.4 18.6 72.3 45.7c7.6 16 26.7 22.8 42.6 15.2s22.8-26.7 15.2-42.6C331 33.7 281.5 0 224 0C144.5 0 80 64.5 80 144l0 48-16 0c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-192c0-35.3-28.7-64-64-64l-240 0 0-48z"},child:[]}]})(a)}function kS(a){return ie({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{fillRule:"evenodd",d:"M8.5.134a1 1 0 0 0-1 0l-6 3.577a1 1 0 0 0-.5.866v6.846a1 1 0 0 0 .5.866l6 3.577a1 1 0 0 0 1 0l6-3.577a1 1 0 0 0 .5-.866V4.577a1 1 0 0 0-.5-.866z"},child:[]}]})(a)}function MS(a){return ie({attr:{fill:"currentColor",viewBox:"0 0 16 16"},child:[{tag:"path",attr:{d:"M11.107 0a.5.5 0 0 1 .353.146l4.394 4.394a.5.5 0 0 1 .146.353v6.214a.5.5 0 0 1-.146.353l-4.394 4.394a.5.5 0 0 1-.353.146H4.893a.5.5 0 0 1-.353-.146L.146 11.46A.5.5 0 0 1 0 11.107V4.893a.5.5 0 0 1 .146-.353L4.54.146A.5.5 0 0 1 4.893 0z"},child:[]}]})(a)}const RS=({onClose:a,onConfirm:t})=>{const{t:e}=bl(),[i,n]=B.useState(!1),r=()=>{n(!0),setTimeout(a,300)},o=()=>{n(!0),setTimeout(t,300)};return Se.createPortal(M.jsx("div",{className:`wb-confirm-popup-overlay ${i?"wb-closing":""}`,children:M.jsxs("div",{className:"wb-confirm-popup",children:[M.jsx("p",{children:e("confirmClear")}),M.jsxs("div",{className:"wb-actions",children:[M.jsx("button",{onClick:r,children:e("cancel")}),M.jsx("button",{onClick:o,children:e("clear")})]})]})}),document.body)},DS=({mode:a="user",onImageUpload:t,onPdfSelected:e})=>{const i=og(),{t:n,language:r,changeLanguage:o}=bl(),l=ii(j=>j.whiteboard.toolbar.selectedTool),c=ii(j=>j.whiteboard.lock.isLocked),h=ii(j=>j.whiteboard.viewport),[d,u]=B.useState(!1),[f,p]=B.useState(!1),[m,b]=B.useState(!1),v=B.useRef(null),w=B.useRef(null),_=B.useRef(null),A=B.useRef(null),C=B.useRef(null),x=B.useRef(null),P=async j=>{var tt;const K=(tt=j.target.files)==null?void 0:tt[0];if(!K)return;if(!K.type.startsWith("image/")){console.warn("Unsupported image format:",K.type||K.name),j.target.value="";return}const st=(J,lt)=>{const It=(window.innerWidth/2-h.panX)/h.zoom,Rt=(window.innerHeight/2-h.panY)/h.zoom;return{x:It-J/2,y:Rt-lt/2}};if(t)try{const J=URL.createObjectURL(K),lt=new Image;lt.onload=async()=>{const It=lt.width,Rt=lt.height;URL.revokeObjectURL(J);try{const Bt=await t(K),St=Date.now().toString(),{x:xt,y:ye}=st(It,Rt);i(Di({id:St,type:"image",x:xt,y:ye,width:It,height:Rt,src:Bt})),i(Fn("pointer")),i(Os([St]))}catch(Bt){console.error("Image upload failed:",Bt)}},lt.src=J}catch(J){console.error("Error processing image:",J)}else{const J=URL.createObjectURL(K),lt=new Image;lt.onload=()=>{const It=Date.now().toString(),{x:Rt,y:Bt}=st(lt.width,lt.height);i(Di({id:It,type:"image",x:Rt,y:Bt,width:lt.width,height:lt.height,src:J})),i(Fn("pointer")),i(Os([It]))},lt.src=J}j.target.value=""},R=j=>{var st;const K=(st=j.target.files)==null?void 0:st[0];K&&e&&e(K),j.target.value=""};B.useEffect(()=>{const j=K=>{const st=K.target;v.current&&!v.current.contains(st)&&w.current&&!w.current.contains(st)&&u(!1),A.current&&!A.current.contains(st)&&_.current&&!_.current.contains(st)&&p(!1)};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[]);const N=()=>{b(!0)},z=()=>{i(Fn("pointer")),i(Os([])),i(bh()),b(!1)},H=[{name:"triangle",icon:M.jsx(yS,{style:{transform:"rotate(-30deg)"}})},{name:"diamond",icon:M.jsx(xS,{})},{name:"star",icon:M.jsx(AS,{})},{name:"heart",icon:M.jsx(fS,{})},{name:"hexagon",icon:M.jsx(kS,{})},{name:"octagon",icon:M.jsx(MS,{})},{name:"arrow",icon:M.jsx(ES,{})}],I=j=>{i(Fn(j)),u(!1)},ct=j=>{o(j),p(!1)};return M.jsxs("div",{className:"wb-toolbar",children:[M.jsx("button",{className:l==="pointer"?"wb-active":"",onClick:()=>i(Fn("pointer")),title:n("pointer"),disabled:c,children:M.jsx(mS,{})}),M.jsx("button",{className:l==="text"?"wb-active":"",onClick:()=>i(Fn("text")),title:n("text"),disabled:c,children:M.jsx(TS,{})}),M.jsx("button",{onClick:()=>{var j;return(j=C.current)==null?void 0:j.click()},title:n("image"),disabled:c,children:M.jsx(pS,{})}),M.jsx("input",{type:"file",ref:C,style:{display:"none"},accept:"image/*",onChange:P}),M.jsx("button",{onClick:()=>{var j;return(j=x.current)==null?void 0:j.click()},title:"PDF",disabled:c,children:M.jsx(dS,{})}),M.jsx("input",{type:"file",ref:x,style:{display:"none"},accept:"application/pdf",onChange:R}),M.jsx("button",{className:l==="pencil"?"wb-active":"",onClick:()=>i(Fn("pencil")),title:n("pencil"),disabled:c,children:M.jsx(bS,{})}),M.jsx("button",{className:l==="rectangle"?"wb-active":"",onClick:()=>i(Fn("rectangle")),title:n("rectangle"),disabled:c,children:M.jsx(wS,{})}),M.jsx("button",{className:l==="circle"?"wb-active":"",onClick:()=>i(Fn("circle")),title:n("circle"),disabled:c,children:M.jsx(aS,{})}),M.jsxs("div",{className:"wb-ellipsis-container",children:[M.jsx("button",{ref:w,className:H.some(j=>j.name===l)?"wb-active":"",onClick:()=>u(!d),title:n("moreShapes"),disabled:c,children:M.jsx(CS,{})}),d&&M.jsxs("div",{className:"wb-shapes-popup",ref:v,children:[M.jsx("div",{className:"wb-shapes-popup-header",children:n("moreShapes")}),M.jsx("div",{className:"wb-shapes-popup-grid",children:H.map(j=>M.jsx("button",{className:l===j.name?"wb-active":"",onClick:()=>I(j.name),title:n(j.name),children:j.icon},j.name))})]})]}),M.jsx("button",{className:l==="eraser"?"wb-active":"",onClick:()=>i(Fn("eraser")),title:n("eraser"),disabled:c,children:M.jsx(cS,{})}),M.jsx("button",{onClick:N,title:n("trash"),disabled:c,children:M.jsx(n0,{})}),M.jsxs("div",{className:"wb-language-container",children:[M.jsx("button",{ref:_,onClick:()=>p(!f),title:n("language"),children:M.jsx(uS,{})}),f&&M.jsxs("div",{className:"wb-language-popup",ref:A,children:[M.jsx("div",{className:"wb-language-popup-header",children:n("language")}),M.jsxs("div",{className:"wb-language-options",children:[M.jsxs("button",{className:r==="en"?"wb-active":"",onClick:()=>ct("en"),children:["🇺🇸 ",n("english")]}),M.jsxs("button",{className:r==="tr"?"wb-active":"",onClick:()=>ct("tr"),children:["🇹🇷 ",n("turkish")]})]})]})]}),a==="moderator"&&M.jsx("button",{onClick:()=>i(Ky(!c)),title:c?"Unlock":"Lock",style:{color:c?"red":"inherit"},children:c?M.jsx(_S,{}):M.jsx(PS,{})}),m&&M.jsx(RS,{onConfirm:z,onClose:()=>b(!1)})]})},OS=({shifted:a})=>{const t=og(),{t:e}=bl(),i=ii(f=>f.whiteboard.toolbar.selectedTool),n=ii(f=>f.whiteboard.toolProperties),r=ii(f=>f.whiteboard.selectedElementIds||[]),o=ii(f=>f.whiteboard.elements),l=r.length>0?o.find(f=>f.id===r[0]):null,c=(f,p,m)=>{t(F1({tool:f,property:p,value:m}))},h=(f,p)=>{if(r.length>0){const m=r.map(b=>({id:b,updates:{[f]:p}}));t(qy(m))}},d=()=>{r.forEach(f=>{t(z1(f))})},u=()=>{[...r].reverse().forEach(f=>{t(U1(f))})};if(i==="pointer"&&l&&l.type==="text")return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontSize")}),M.jsxs("select",{className:"font-size-selector",value:l.fontSize||16,onChange:f=>h("fontSize",parseInt(f.target.value)),children:[M.jsx("option",{value:"12",children:"12 px"}),M.jsx("option",{value:"14",children:"14 px"}),M.jsx("option",{value:"16",children:"16 px"}),M.jsx("option",{value:"18",children:"18 px"}),M.jsx("option",{value:"24",children:"24 px"}),M.jsx("option",{value:"32",children:"32 px"}),M.jsx("option",{value:"48",children:"48 px"}),M.jsx("option",{value:"64",children:"64 px"}),M.jsx("option",{value:"72",children:"72 px"})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontColor")}),M.jsx("input",{type:"color",value:l.fontColor||"#000000",onChange:f=>h("fontColor",f.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("layerOrder")}),M.jsxs("div",{className:"wb-layer-buttons",children:[M.jsx("button",{onClick:d,title:e("bringToFront"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),M.jsx("button",{onClick:u,title:e("sendToBack"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]});if(i==="pointer"&&l){const f=["rectangle","circle","triangle","diamond","star","heart","hexagon","octagon","arrow"].includes(l.type),p=l.type==="pencil";return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[f&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeColor")}),M.jsx("input",{type:"color",value:l.strokeColor,onChange:m=>h("strokeColor",m.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fillColor")}),M.jsx("input",{type:"color",value:l.fillColor,onChange:m=>h("fillColor",m.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeWidth")}),M.jsxs("select",{className:"stroke-width-selector",value:l.lineWidth,onChange:m=>h("lineWidth",parseInt(m.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"})]})]})]}),p&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushColor")}),M.jsx("input",{type:"color",value:l.strokeColor,onChange:m=>h("strokeColor",m.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushSize")}),M.jsxs("select",{className:"brush-size-selector",value:l.lineWidth,onChange:m=>h("lineWidth",parseInt(m.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"}),M.jsx("option",{value:"16",children:"16 px"})]})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("layerOrder")}),M.jsxs("div",{className:"wb-layer-buttons",children:[M.jsx("button",{onClick:d,title:e("bringToFront"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"white"})]})}),M.jsx("button",{onClick:u,title:e("sendToBack"),children:M.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[M.jsx("rect",{x:"4",y:"4",width:"12",height:"12",rx:"1",fill:"#0066cc",stroke:"#0066cc"}),M.jsx("rect",{x:"8",y:"8",width:"12",height:"12",rx:"1",fill:"white"})]})})]})]})]})}return M.jsxs("div",{className:`wb-prop-tools ${a?"wb-shifted":""}`,children:[i==="text"&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontSize")}),M.jsxs("select",{className:"font-size-selector",value:n.text.fontSize,onChange:f=>c("text","fontSize",parseInt(f.target.value)),children:[M.jsx("option",{value:"12",children:"12 px"}),M.jsx("option",{value:"14",children:"14 px"}),M.jsx("option",{value:"16",children:"16 px"}),M.jsx("option",{value:"18",children:"18 px"}),M.jsx("option",{value:"24",children:"24 px"}),M.jsx("option",{value:"32",children:"32 px"}),M.jsx("option",{value:"48",children:"48 px"}),M.jsx("option",{value:"64",children:"64 px"}),M.jsx("option",{value:"72",children:"72 px"})]})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fontColor")}),M.jsx("input",{type:"color",value:n.text.fontColor,onChange:f=>c("text","fontColor",f.target.value)})]})]}),i==="pencil"&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushColor")}),M.jsx("input",{type:"color",value:n.pencil.strokeColor,onChange:f=>c("pencil","strokeColor",f.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("brushSize")}),M.jsxs("select",{className:"brush-size-selector",value:n.pencil.lineWidth,onChange:f=>c("pencil","lineWidth",parseInt(f.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"}),M.jsx("option",{value:"16",children:"16 px"})]})]})]}),(i==="rectangle"||i==="circle"||i==="triangle"||i==="diamond"||i==="star"||i==="heart"||i==="hexagon"||i==="octagon"||i==="arrow")&&M.jsxs(M.Fragment,{children:[M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeColor")}),M.jsx("input",{type:"color",value:n[i].strokeColor,onChange:f=>c(i,"strokeColor",f.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("fillColor")}),M.jsx("input",{type:"color",value:n[i].fillColor,onChange:f=>c(i,"fillColor",f.target.value)})]}),M.jsxs("div",{className:"wb-prop-tool-item",children:[M.jsx("span",{children:e("strokeWidth")}),M.jsxs("select",{className:"stroke-width-selector",value:n[i].lineWidth,onChange:f=>c(i,"lineWidth",parseInt(f.target.value)),children:[M.jsx("option",{value:"1",children:"1 px"}),M.jsx("option",{value:"2",children:"2 px"}),M.jsx("option",{value:"4",children:"4 px"}),M.jsx("option",{value:"8",children:"8 px"})]})]})]})]})},IS=({onFitToView:a,onExport:t,onToggleGrid:e})=>{const{t:i}=bl();return M.jsxs("div",{className:"wb-canvas-tools",children:[M.jsx("button",{onClick:e,title:i("toggleGrid"),children:M.jsx(sS,{})}),M.jsx("button",{onClick:a,title:i("fitToView"),children:M.jsx(hS,{})}),M.jsx("button",{onClick:t,title:i("exportAsPng"),children:M.jsx(vS,{})})]})},LS=({currentPage:a,totalPages:t,onPrevPage:e,onNextPage:i,onDelete:n,onDownload:r})=>{const{t:o}=bl();return t<=0?null:M.jsxs("div",{className:"wb-pdf-navigation",children:[n&&M.jsxs(M.Fragment,{children:[M.jsx("button",{className:"wb-pdf-nav-button wb-pdf-delete",onClick:n,title:o("deletePdf"),children:M.jsx(n0,{})}),M.jsx("div",{className:"wb-pdf-separator"})]}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:e,disabled:a<=1,title:o("prevPage"),children:M.jsx(rS,{})}),M.jsxs("div",{className:"wb-pdf-page-info",children:[o("page")," ",a," ",o("of")," ",t]}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:i,disabled:a>=t,title:o("nextPage"),children:M.jsx(oS,{})}),r&&M.jsxs(M.Fragment,{children:[M.jsx("div",{className:"wb-pdf-separator"}),M.jsx("button",{className:"wb-pdf-nav-button",onClick:r,title:o("downloadPdf"),children:M.jsx(lS,{})})]})]})},Si=typeof process=="object"&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&process.type!=="browser"),Og=[.001,0,0,.001,0,0],Ig=1.35,qi={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,IS_EDITING:128,OPLIST:256},Lr={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},vh="pdfjs_internal_editor_",mt={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15,POPUP:16,SIGNATURE:101,COMMENT:102},kt={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},NS={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Lg={TRIANGLES:1,LATTICE:2},Be={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},ff={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},Oe={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},El={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},pf={ERRORS:0,WARNINGS:1,INFOS:5},wh={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},Ah={moveTo:0,lineTo:1,curveTo:2,quadraticCurveTo:3,closePath:4},FS={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let gf=pf.WARNINGS;function BS(a){Number.isInteger(a)&&(gf=a)}function jS(){return gf}function mf(a){gf>=pf.INFOS&&console.info(`Info: ${a}`)}function pt(a){gf>=pf.WARNINGS&&console.warn(`Warning: ${a}`)}function ne(a){throw new Error(a)}function Mt(a,t){a||ne(t)}function zS(a){switch(a==null?void 0:a.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}function s0(a,t=null,e=null){if(!a)return null;if(e&&typeof a=="string"){if(e.addDefaultProtocol&&a.startsWith("www.")){const n=a.match(/\./g);(n==null?void 0:n.length)>=2&&(a=`http://${a}`)}if(e.tryConvertEncoding)try{a=VS(a)}catch{}}const i=t?URL.parse(a,t):URL.parse(a);return zS(i)?i:null}function r0(a,t,e=!1){const i=URL.parse(a);return i?(i.hash=t,i.href):e&&s0(a,"http://example.com")?a.split("#",1)[0]+`${t?`#${t}`:""}`:""}function gt(a,t,e,i=!1){return Object.defineProperty(a,t,{value:e,enumerable:!i,configurable:!0,writable:!1}),e}const jo=(function(){function t(e,i){this.message=e,this.name=i}return t.prototype=new Error,t.constructor=t,t})();class o0 extends jo{constructor(t,e){super(t,"PasswordException"),this.code=e}}class Ng extends jo{constructor(t,e){super(t,"UnknownErrorException"),this.details=e}}class Fg extends jo{constructor(t){super(t,"InvalidPDFException")}}class bf extends jo{constructor(t,e,i){super(t,"ResponseException"),this.status=e,this.missing=i}}class US extends jo{constructor(t){super(t,"FormatError")}}class Nr extends jo{constructor(t){super(t,"AbortException")}}function a0(a){(typeof a!="object"||(a==null?void 0:a.length)===void 0)&&ne("Invalid argument for bytesToString");const t=a.length,e=8192;if(t<e)return String.fromCharCode.apply(null,a);const i=[];for(let n=0;n<t;n+=e){const r=Math.min(n+e,t),o=a.subarray(n,r);i.push(String.fromCharCode.apply(null,o))}return i.join("")}function Sh(a){typeof a!="string"&&ne("Invalid argument for stringToBytes");const t=a.length,e=new Uint8Array(t);for(let i=0;i<t;++i)e[i]=a.charCodeAt(i)&255;return e}function HS(a){return String.fromCharCode(a>>24&255,a>>16&255,a>>8&255,a&255)}function $S(){const a=new Uint8Array(4);return a[0]=1,new Uint32Array(a.buffer,0,1)[0]===1}function WS(){try{return new Function(""),!0}catch{return!1}}class je{static get isLittleEndian(){return gt(this,"isLittleEndian",$S())}static get isEvalSupported(){return gt(this,"isEvalSupported",WS())}static get isOffscreenCanvasSupported(){return gt(this,"isOffscreenCanvasSupported",typeof OffscreenCanvas<"u")}static get isImageDecoderSupported(){return gt(this,"isImageDecoderSupported",typeof ImageDecoder<"u")}static get isFloat16ArraySupported(){return gt(this,"isFloat16ArraySupported",typeof Float16Array<"u")}static get isSanitizerSupported(){return gt(this,"isSanitizerSupported",typeof Sanitizer<"u")}static get platform(){const{platform:t,userAgent:e}=navigator;return gt(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 gt(this,"isCSSRoundSupported",(e=(t=globalThis.CSS)==null?void 0:t.supports)==null?void 0:e.call(t,"width: round(1.5px, 1px)"))}}const Bg=Array.from(Array(256).keys(),a=>a.toString(16).padStart(2,"0"));class Z{static makeHexColor(t,e,i){return`#${Bg[t]}${Bg[e]}${Bg[i]}`}static domMatrixToTransform(t){return[t.a,t.b,t.c,t.d,t.e,t.f]}static scaleMinMax(t,e){let i;t[0]?(t[0]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[0],e[2]*=t[0],t[3]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[3],e[3]*=t[3]):(i=e[0],e[0]=e[1],e[1]=i,i=e[2],e[2]=e[3],e[3]=i,t[1]<0&&(i=e[1],e[1]=e[3],e[3]=i),e[1]*=t[1],e[3]*=t[1],t[2]<0&&(i=e[0],e[0]=e[2],e[2]=i),e[0]*=t[2],e[2]*=t[2]),e[0]+=t[4],e[1]+=t[5],e[2]+=t[4],e[3]+=t[5]}static transform(t,e){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],t[0]*e[4]+t[2]*e[5]+t[4],t[1]*e[4]+t[3]*e[5]+t[5]]}static multiplyByDOMMatrix(t,e){return[t[0]*e.a+t[2]*e.b,t[1]*e.a+t[3]*e.b,t[0]*e.c+t[2]*e.d,t[1]*e.c+t[3]*e.d,t[0]*e.e+t[2]*e.f+t[4],t[1]*e.e+t[3]*e.f+t[5]]}static applyTransform(t,e,i=0){const n=t[i],r=t[i+1];t[i]=n*e[0]+r*e[2]+e[4],t[i+1]=n*e[1]+r*e[3]+e[5]}static applyTransformToBezier(t,e,i=0){const n=e[0],r=e[1],o=e[2],l=e[3],c=e[4],h=e[5];for(let d=0;d<6;d+=2){const u=t[i+d],f=t[i+d+1];t[i+d]=u*n+f*o+c,t[i+d+1]=u*r+f*l+h}}static applyInverseTransform(t,e){const i=t[0],n=t[1],r=e[0]*e[3]-e[1]*e[2];t[0]=(i*e[3]-n*e[2]+e[2]*e[5]-e[4]*e[3])/r,t[1]=(-i*e[1]+n*e[0]+e[4]*e[1]-e[5]*e[0])/r}static axialAlignedBoundingBox(t,e,i){const n=e[0],r=e[1],o=e[2],l=e[3],c=e[4],h=e[5],d=t[0],u=t[1],f=t[2],p=t[3];let m=n*d+c,b=m,v=n*f+c,w=v,_=l*u+h,A=_,C=l*p+h,x=C;if(r!==0||o!==0){const P=r*d,R=r*f,N=o*u,z=o*p;m+=N,w+=N,v+=z,b+=z,_+=P,x+=P,C+=R,A+=R}i[0]=Math.min(i[0],m,v,b,w),i[1]=Math.min(i[1],_,C,A,x),i[2]=Math.max(i[2],m,v,b,w),i[3]=Math.max(i[3],_,C,A,x)}static inverseTransform(t){const e=t[0]*t[3]-t[1]*t[2];return[t[3]/e,-t[1]/e,-t[2]/e,t[0]/e,(t[2]*t[5]-t[4]*t[3])/e,(t[4]*t[1]-t[5]*t[0])/e]}static singularValueDecompose2dScale(t,e){const i=t[0],n=t[1],r=t[2],o=t[3],l=i**2+n**2,c=i*r+n*o,h=r**2+o**2,d=(l+h)/2,u=Math.sqrt(d**2-(l*h-c**2));e[0]=Math.sqrt(d+u||1),e[1]=Math.sqrt(d-u||1)}static normalizeRect(t){const e=t.slice(0);return t[0]>t[2]&&(e[0]=t[2],e[2]=t[0]),t[1]>t[3]&&(e[1]=t[3],e[3]=t[1]),e}static intersect(t,e){const i=Math.max(Math.min(t[0],t[2]),Math.min(e[0],e[2])),n=Math.min(Math.max(t[0],t[2]),Math.max(e[0],e[2]));if(i>n)return null;const r=Math.max(Math.min(t[1],t[3]),Math.min(e[1],e[3])),o=Math.min(Math.max(t[1],t[3]),Math.max(e[1],e[3]));return r>o?null:[i,r,n,o]}static pointBoundingBox(t,e,i){i[0]=Math.min(i[0],t),i[1]=Math.min(i[1],e),i[2]=Math.max(i[2],t),i[3]=Math.max(i[3],e)}static rectBoundingBox(t,e,i,n,r){r[0]=Math.min(r[0],t,i),r[1]=Math.min(r[1],e,n),r[2]=Math.max(r[2],t,i),r[3]=Math.max(r[3],e,n)}static bezierBoundingBox(t,e,i,n,r,o,l,c,h){h[0]=Math.min(h[0],t,l),h[1]=Math.min(h[1],e,c),h[2]=Math.max(h[2],t,l),h[3]=Math.max(h[3],e,c),S(this,Ns,zm).call(this,t,i,r,l,e,n,o,c,3*(-t+3*(i-r)+l),6*(t-2*i+r),3*(i-t),h),S(this,Ns,zm).call(this,t,i,r,l,e,n,o,c,3*(-e+3*(n-o)+c),6*(e-2*n+o),3*(n-e),h)}}Ns=new WeakSet,bp=function(t,e,i,n,r,o,l,c,h,d){if(h<=0||h>=1)return;const u=1-h,f=h*h,p=f*h,m=u*(u*(u*t+3*h*e)+3*f*i)+p*n,b=u*(u*(u*r+3*h*o)+3*f*l)+p*c;d[0]=Math.min(d[0],m),d[1]=Math.min(d[1],b),d[2]=Math.max(d[2],m),d[3]=Math.max(d[3],b)},zm=function(t,e,i,n,r,o,l,c,h,d,u,f){if(Math.abs(h)<1e-12){Math.abs(d)>=1e-12&&S(this,Ns,bp).call(this,t,e,i,n,r,o,l,c,-u/d,f);return}const p=d**2-4*u*h;if(p<0)return;const m=Math.sqrt(p),b=2*h;S(this,Ns,bp).call(this,t,e,i,n,r,o,l,c,(-d+m)/b,f),S(this,Ns,bp).call(this,t,e,i,n,r,o,l,c,(-d-m)/b,f)},y(Z,Ns);function VS(a){return decodeURIComponent(escape(a))}let jg=null,l0=null;function GS(a){return jg||(jg=/([\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,l0=new Map([["ſt","ſt"]])),a.replaceAll(jg,(t,e,i)=>e?e.normalize("NFKC"):l0.get(i))}function c0(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const a=new Uint8Array(32);return crypto.getRandomValues(a),a0(a)}const xl="pdfjs_internal_id_";function YS(a,t,e){if(!Array.isArray(e)||e.length<2)return!1;const[i,n,...r]=e;if(!a(i)&&!Number.isInteger(i)||!t(n))return!1;const o=r.length;let l=!0;switch(n.name){case"XYZ":if(o<2||o>3)return!1;break;case"Fit":case"FitB":return o===0;case"FitH":case"FitBH":case"FitV":case"FitBV":if(o>1)return!1;break;case"FitR":if(o!==4)return!1;l=!1;break;default:return!1}for(const c of r)if(!(typeof c=="number"||l&&c===null))return!1;return!0}function Ei(a,t,e){return Math.min(Math.max(a,t),e)}function h0(a){return Uint8Array.prototype.toBase64?a.toBase64():btoa(a0(a))}function XS(a){return Uint8Array.fromBase64?Uint8Array.fromBase64(a):Sh(atob(a))}typeof Promise.try!="function"&&(Promise.try=function(a,...t){return new Promise(e=>{e(a(...t))})}),typeof Math.sumPrecise!="function"&&(Math.sumPrecise=function(a){return a.reduce((t,e)=>t+e,0)});class Eh{static textContent(t){const e=[],i={items:e,styles:Object.create(null)};function n(r){var c;if(!r)return;let o=null;const l=r.name;if(l==="#text")o=r.value;else if(Eh.shouldBuildText(l))(c=r==null?void 0:r.attributes)!=null&&c.textContent?o=r.attributes.textContent:r.value&&(o=r.value);else return;if(o!==null&&e.push({str:o}),!!r.children)for(const h of r.children)n(h)}return n(t),i}static shouldBuildText(t){return!(t==="textarea"||t==="input"||t==="option"||t==="select")}}class d0{static setupStorage(t,e,i,n,r){const o=n.getValue(e,{value:null});switch(i.name){case"textarea":if(o.value!==null&&(t.textContent=o.value),r==="print")break;t.addEventListener("input",l=>{n.setValue(e,{value:l.target.value})});break;case"input":if(i.attributes.type==="radio"||i.attributes.type==="checkbox"){if(o.value===i.attributes.xfaOn?t.setAttribute("checked",!0):o.value===i.attributes.xfaOff&&t.removeAttribute("checked"),r==="print")break;t.addEventListener("change",l=>{n.setValue(e,{value:l.target.checked?l.target.getAttribute("xfaOn"):l.target.getAttribute("xfaOff")})})}else{if(o.value!==null&&t.setAttribute("value",o.value),r==="print")break;t.addEventListener("input",l=>{n.setValue(e,{value:l.target.value})})}break;case"select":if(o.value!==null){t.setAttribute("value",o.value);for(const l of i.children)l.attributes.value===o.value?l.attributes.selected=!0:l.attributes.hasOwnProperty("selected")&&delete l.attributes.selected}t.addEventListener("input",l=>{const c=l.target.options,h=c.selectedIndex===-1?"":c[c.selectedIndex].value;n.setValue(e,{value:h})});break}}static setAttributes({html:t,element:e,storage:i=null,intent:n,linkService:r}){const{attributes:o}=e,l=t instanceof HTMLAnchorElement;o.type==="radio"&&(o.name=`${o.name}-${n}`);for(const[c,h]of Object.entries(o))if(h!=null)switch(c){case"class":h.length&&t.setAttribute(c,h.join(" "));break;case"dataId":break;case"id":t.setAttribute("data-element-id",h);break;case"style":Object.assign(t.style,h);break;case"textContent":t.textContent=h;break;default:(!l||c!=="href"&&c!=="newWindow")&&t.setAttribute(c,h)}l&&r.addLinkAttributes(t,o.href,o.newWindow),i&&o.dataId&&this.setupStorage(t,o.dataId,e,i)}static render(t){var u,f;const e=t.annotationStorage,i=t.linkService,n=t.xfaHtml,r=t.intent||"display",o=document.createElement(n.name);n.attributes&&this.setAttributes({html:o,element:n,intent:r,linkService:i});const l=r!=="richText",c=t.div;if(c.append(o),t.viewport){const p=`matrix(${t.viewport.transform.join(",")})`;c.style.transform=p}l&&c.setAttribute("class","xfaLayer xfaFont");const h=[];if(n.children.length===0){if(n.value){const p=document.createTextNode(n.value);o.append(p),l&&Eh.shouldBuildText(n.name)&&h.push(p)}return{textDivs:h}}const d=[[n,-1,o]];for(;d.length>0;){const[p,m,b]=d.at(-1);if(m+1===p.children.length){d.pop();continue}const v=p.children[++d.at(-1)[1]];if(v===null)continue;const{name:w}=v;if(w==="#text"){const A=document.createTextNode(v.value);h.push(A),b.append(A);continue}const _=(u=v==null?void 0:v.attributes)!=null&&u.xmlns?document.createElementNS(v.attributes.xmlns,w):document.createElement(w);if(b.append(_),v.attributes&&this.setAttributes({html:_,element:v,storage:e,intent:r,linkService:i}),((f=v.children)==null?void 0:f.length)>0)d.push([v,-1,_]);else if(v.value){const A=document.createTextNode(v.value);l&&Eh.shouldBuildText(w)&&h.push(A),_.append(A)}}for(const p of c.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))p.setAttribute("readOnly",!0);return{textDivs:h}}static update(t){const e=`matrix(${t.viewport.transform.join(",")})`;t.div.style.transform=e,t.div.hidden=!1}}const Is="http://www.w3.org/2000/svg",Wo=class Wo{};W(Wo,"CSS",96),W(Wo,"PDF",72),W(Wo,"PDF_TO_CSS_UNITS",Wo.CSS/Wo.PDF);let Fr=Wo;async function xh(a,t="text"){if(_h(a,document.baseURI)){const e=await fetch(a);if(!e.ok)throw new Error(e.statusText);switch(t){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"json":return e.json()}return e.text()}return new Promise((e,i)=>{const n=new XMLHttpRequest;n.open("GET",a,!0),n.responseType=t,n.onreadystatechange=()=>{if(n.readyState===XMLHttpRequest.DONE){if(n.status===200||n.status===0){switch(t){case"arraybuffer":case"blob":case"json":e(n.response);return}e(n.responseText);return}i(new Error(n.statusText))}},n.send(null)})}class Ch{constructor({viewBox:t,userUnit:e,scale:i,rotation:n,offsetX:r=0,offsetY:o=0,dontFlip:l=!1}){this.viewBox=t,this.userUnit=e,this.scale=i,this.rotation=n,this.offsetX=r,this.offsetY=o,i*=e;const c=(t[2]+t[0])/2,h=(t[3]+t[1])/2;let d,u,f,p;switch(n%=360,n<0&&(n+=360),n){case 180:d=-1,u=0,f=0,p=1;break;case 90:d=0,u=1,f=1,p=0;break;case 270:d=0,u=-1,f=-1,p=0;break;case 0:d=1,u=0,f=0,p=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}l&&(f=-f,p=-p);let m,b,v,w;d===0?(m=Math.abs(h-t[1])*i+r,b=Math.abs(c-t[0])*i+o,v=(t[3]-t[1])*i,w=(t[2]-t[0])*i):(m=Math.abs(c-t[0])*i+r,b=Math.abs(h-t[1])*i+o,v=(t[2]-t[0])*i,w=(t[3]-t[1])*i),this.transform=[d*i,u*i,f*i,p*i,m-d*i*c-f*i*h,b-u*i*c-p*i*h],this.width=v,this.height=w}get rawDims(){const t=this.viewBox;return gt(this,"rawDims",{pageWidth:t[2]-t[0],pageHeight:t[3]-t[1],pageX:t[0],pageY:t[1]})}clone({scale:t=this.scale,rotation:e=this.rotation,offsetX:i=this.offsetX,offsetY:n=this.offsetY,dontFlip:r=!1}={}){return new Ch({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:r})}convertToViewportPoint(t,e){const i=[t,e];return Z.applyTransform(i,this.transform),i}convertToViewportRectangle(t){const e=[t[0],t[1]];Z.applyTransform(e,this.transform);const i=[t[2],t[3]];return Z.applyTransform(i,this.transform),[e[0],e[1],i[0],i[1]]}convertToPdfPoint(t,e){const i=[t,e];return Z.applyInverseTransform(i,this.transform),i}}class zg extends jo{constructor(t,e=0){super(t,"RenderingCancelledException"),this.extraDelay=e}}function yf(a){const t=a.length;let e=0;for(;e<t&&a[e].trim()==="";)e++;return a.substring(e,e+5).toLowerCase()==="data:"}function Ug(a){return typeof a=="string"&&/\.pdf$/i.test(a)}function qS(a){return[a]=a.split(/[#?]/,1),a.substring(a.lastIndexOf("/")+1)}function KS(a,t="document.pdf"){if(typeof a!="string")return t;if(yf(a))return pt('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const i=(l=>{try{return new URL(l)}catch{try{return new URL(decodeURIComponent(l))}catch{try{return new URL(l,"https://foo.bar")}catch{try{return new URL(decodeURIComponent(l),"https://foo.bar")}catch{return null}}}}})(a);if(!i)return t;const n=l=>{try{let c=decodeURIComponent(l);return c.includes("/")?(c=c.split("/").at(-1),c.test(/^\.pdf$/i)?c:l):c}catch{return l}},r=/\.pdf$/i,o=i.pathname.split("/").at(-1);if(r.test(o))return n(o);if(i.searchParams.size>0){const l=Array.from(i.searchParams.values()).reverse();for(const h of l)if(r.test(h))return n(h);const c=Array.from(i.searchParams.keys()).reverse();for(const h of c)if(r.test(h))return n(h)}if(i.hash){const c=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i.exec(i.hash);if(c)return n(c[0])}return t}class u0{constructor(){W(this,"started",Object.create(null));W(this,"times",[])}time(t){t in this.started&&pt(`Timer is already running for ${t}`),this.started[t]=Date.now()}timeEnd(t){t in this.started||pt(`Timer has not been started for ${t}`),this.times.push({name:t,start:this.started[t],end:Date.now()}),delete this.started[t]}toString(){const t=[];let e=0;for(const{name:i}of this.times)e=Math.max(i.length,e);for(const{name:i,start:n,end:r}of this.times)t.push(`${i.padEnd(e)} ${r-n}ms
100
+ `);return t.join("")}}function _h(a,t){const e=t?URL.parse(a,t):URL.parse(a);return(e==null?void 0:e.protocol)==="http:"||(e==null?void 0:e.protocol)==="https:"}function wn(a){a.preventDefault()}function Ee(a){a.preventDefault(),a.stopPropagation()}function JS(a){console.log("Deprecated API usage: "+a)}class vf{static toDateObject(t){if(t instanceof Date)return t;if(!t||typeof t!="string")return null;s(this,Bh)||g(this,Bh,new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"));const e=s(this,Bh).exec(t);if(!e)return null;const i=parseInt(e[1],10);let n=parseInt(e[2],10);n=n>=1&&n<=12?n-1:0;let r=parseInt(e[3],10);r=r>=1&&r<=31?r:1;let o=parseInt(e[4],10);o=o>=0&&o<=23?o:0;let l=parseInt(e[5],10);l=l>=0&&l<=59?l:0;let c=parseInt(e[6],10);c=c>=0&&c<=59?c:0;const h=e[7]||"Z";let d=parseInt(e[8],10);d=d>=0&&d<=23?d:0;let u=parseInt(e[9],10)||0;return u=u>=0&&u<=59?u:0,h==="-"?(o+=d,l+=u):h==="+"&&(o-=d,l-=u),new Date(Date.UTC(i,n,r,o,l,c))}}Bh=new WeakMap,y(vf,Bh);function ZS(a,{scale:t=1,rotation:e=0}){const{width:i,height:n}=a.attributes.style,r=[0,0,parseInt(i),parseInt(n)];return new Ch({viewBox:r,userUnit:1,scale:t,rotation:e})}function Th(a){if(a.startsWith("#")){const t=parseInt(a.slice(1),16);return[(t&16711680)>>16,(t&65280)>>8,t&255]}return a.startsWith("rgb(")?a.slice(4,-1).split(",").map(t=>parseInt(t)):a.startsWith("rgba(")?a.slice(5,-1).split(",").map(t=>parseInt(t)).slice(0,3):(pt(`Not a valid color format: "${a}"`),[0,0,0])}function QS(a){const t=document.createElement("span");t.style.visibility="hidden",t.style.colorScheme="only light",document.body.append(t);for(const e of a.keys()){t.style.color=e;const i=window.getComputedStyle(t).color;a.set(e,Th(i))}t.remove()}function ve(a){const{a:t,b:e,c:i,d:n,e:r,f:o}=a.getTransform();return[t,e,i,n,r,o]}function is(a){const{a:t,b:e,c:i,d:n,e:r,f:o}=a.getTransform().invertSelf();return[t,e,i,n,r,o]}function zo(a,t,e=!1,i=!0){if(t instanceof Ch){const{pageWidth:n,pageHeight:r}=t.rawDims,{style:o}=a,l=je.isCSSRoundSupported,c=`var(--total-scale-factor) * ${n}px`,h=`var(--total-scale-factor) * ${r}px`,d=l?`round(down, ${c}, var(--scale-round-x))`:`calc(${c})`,u=l?`round(down, ${h}, var(--scale-round-y))`:`calc(${h})`;!e||t.rotation%180===0?(o.width=d,o.height=u):(o.width=u,o.height=d)}i&&a.setAttribute("data-main-rotation",t.rotation)}class ns{constructor(){const{pixelRatio:t}=ns;this.sx=t,this.sy=t}get scaled(){return this.sx!==1||this.sy!==1}get symmetric(){return this.sx===this.sy}limitCanvas(t,e,i,n,r=-1){let o=1/0,l=1/0,c=1/0;i=ns.capPixels(i,r),i>0&&(o=Math.sqrt(i/(t*e))),n!==-1&&(l=n/t,c=n/e);const h=Math.min(o,l,c);return this.sx>h||this.sy>h?(this.sx=h,this.sy=h,!0):!1}static get pixelRatio(){return globalThis.devicePixelRatio||1}static capPixels(t,e){if(e>=0){const i=Math.ceil(window.screen.availWidth*window.screen.availHeight*this.pixelRatio**2*(1+e/100));return t>0?Math.min(t,i):i}return t}}const Hg=["image/apng","image/avif","image/bmp","image/gif","image/jpeg","image/png","image/svg+xml","image/webp","image/x-icon"];class tE{static get isDarkMode(){var t;return gt(this,"isDarkMode",!!((t=window==null?void 0:window.matchMedia)!=null&&t.call(window,"(prefers-color-scheme: dark)").matches))}}class eE{static get commentForegroundColor(){const t=document.createElement("span");t.classList.add("comment","sidebar");const{style:e}=t;e.width=e.height="0",e.display="none",e.color="var(--comment-fg-color)",document.body.append(t);const{color:i}=window.getComputedStyle(t);return t.remove(),gt(this,"commentForegroundColor",Th(i))}}function iE(a,t,e,i){i=Math.min(Math.max(i??1,0),1);const n=255*(1-i);return a=Math.round(a*i+n),t=Math.round(t*i+n),e=Math.round(e*i+n),[a,t,e]}function f0(a,t){const e=a[0]/255,i=a[1]/255,n=a[2]/255,r=Math.max(e,i,n),o=Math.min(e,i,n),l=(r+o)/2;if(r===o)t[0]=t[1]=0;else{const c=r-o;switch(t[1]=l<.5?c/(r+o):c/(2-r-o),r){case e:t[0]=((i-n)/c+(i<n?6:0))*60;break;case i:t[0]=((n-e)/c+2)*60;break;case n:t[0]=((e-i)/c+4)*60;break}}t[2]=l}function $g(a,t){const e=a[0],i=a[1],n=a[2],r=(1-Math.abs(2*n-1))*i,o=r*(1-Math.abs(e/60%2-1)),l=n-r/2;switch(Math.floor(e/60)){case 0:t[0]=r+l,t[1]=o+l,t[2]=l;break;case 1:t[0]=o+l,t[1]=r+l,t[2]=l;break;case 2:t[0]=l,t[1]=r+l,t[2]=o+l;break;case 3:t[0]=l,t[1]=o+l,t[2]=r+l;break;case 4:t[0]=o+l,t[1]=l,t[2]=r+l;break;case 5:case 6:t[0]=r+l,t[1]=l,t[2]=o+l;break}}function p0(a){return a<=.03928?a/12.92:((a+.055)/1.055)**2.4}function g0(a,t,e){$g(a,e),e.map(p0);const i=.2126*e[0]+.7152*e[1]+.0722*e[2];$g(t,e),e.map(p0);const n=.2126*e[0]+.7152*e[1]+.0722*e[2];return i>n?(i+.05)/(n+.05):(n+.05)/(i+.05)}const m0=new Map;function nE(a,t){const e=a[0]+a[1]*256+a[2]*65536+t[0]*16777216+t[1]*4294967296+t[2]*1099511627776;let i=m0.get(e);if(i)return i;const n=new Float32Array(9),r=n.subarray(0,3),o=n.subarray(3,6);f0(a,o);const l=n.subarray(6,9);f0(t,l);const c=l[2]<.5,h=c?12:4.5;if(o[2]=c?Math.sqrt(o[2]):1-Math.sqrt(1-o[2]),g0(o,l,r)<h){let d,u;c?(d=o[2],u=1):(d=0,u=o[2]);const f=.005;for(;u-d>f;){const p=o[2]=(d+u)/2;c===g0(o,l,r)<h?d=p:u=p}o[2]=c?u:d}return $g(o,r),i=Z.makeHexColor(Math.round(r[0]*255),Math.round(r[1]*255),Math.round(r[2]*255)),m0.set(e,i),i}function b0({html:a,dir:t,className:e},i){const n=document.createDocumentFragment();if(typeof a=="string"){const r=document.createElement("p");r.dir=t||"auto";const o=a.split(/(?:\r\n?|\n)/);for(let l=0,c=o.length;l<c;++l){const h=o[l];r.append(document.createTextNode(h)),l<c-1&&r.append(document.createElement("br"))}n.append(r)}else d0.render({xfaHtml:a,div:n,intent:"richText"});n.firstElementChild.classList.add("richText",e),i.append(n)}function y0(a){const t=new Path2D;if(!a)return t;for(let e=0,i=a.length;e<i;)switch(a[e++]){case Ah.moveTo:t.moveTo(a[e++],a[e++]);break;case Ah.lineTo:t.lineTo(a[e++],a[e++]);break;case Ah.curveTo:t.bezierCurveTo(a[e++],a[e++],a[e++],a[e++],a[e++],a[e++]);break;case Ah.quadraticCurveTo:t.quadraticCurveTo(a[e++],a[e++],a[e++],a[e++]);break;case Ah.closePath:t.closePath();break;default:pt(`Unrecognized drawing path operator: ${a[e-1]}`);break}return t}const Fs=class Fs{constructor(t){y(this,si);y(this,Br,null);y(this,jr,null);y(this,En);y(this,xn,null);y(this,jh,null);y(this,zr,null);y(this,kl,null);y(this,Ml,null);g(this,En,t),s(Fs,zh)||g(Fs,zh,Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button",signature:"pdfjs-editor-remove-signature-button"}))}render(){const t=g(this,Br,document.createElement("div"));t.classList.add("editToolbar","hidden"),t.setAttribute("role","toolbar");const e=s(this,En)._uiManager._signal;e instanceof AbortSignal&&!e.aborted&&(t.addEventListener("contextmenu",wn,{signal:e}),t.addEventListener("pointerdown",S(Fs,Hf,Av),{signal:e}));const i=g(this,xn,document.createElement("div"));i.className="buttons",t.append(i);const n=s(this,En).toolbarPosition;if(n){const{style:r}=t,o=s(this,En)._uiManager.direction==="ltr"?1-n[0]:n[0];r.insetInlineEnd=`${100*o}%`,r.top=`calc(${100*n[1]}% + var(--editor-toolbar-vert-offset))`}return t}get div(){return s(this,Br)}hide(){var t;s(this,Br).classList.add("hidden"),(t=s(this,jr))==null||t.hideDropdown()}show(){var t,e;s(this,Br).classList.remove("hidden"),(t=s(this,jh))==null||t.shown(),(e=s(this,zr))==null||e.shown()}addDeleteButton(){const{editorType:t,_uiManager:e}=s(this,En),i=document.createElement("button");i.classList.add("basic","deleteButton"),i.tabIndex=0,i.setAttribute("data-l10n-id",s(Fs,zh)[t]),S(this,si,lh).call(this,i)&&i.addEventListener("click",n=>{e.delete()},{signal:e._signal}),s(this,xn).append(i)}async addAltText(t){const e=await t.render();S(this,si,lh).call(this,e),s(this,xn).append(e,s(this,si,Iu)),g(this,jh,t)}addComment(t,e=null){if(s(this,zr))return;const i=t.renderForToolbar();if(!i)return;S(this,si,lh).call(this,i);const n=g(this,kl,s(this,si,Iu));e?(s(this,xn).insertBefore(i,e),s(this,xn).insertBefore(n,e)):s(this,xn).append(i,n),g(this,zr,t),t.toolbar=this}addColorPicker(t){if(s(this,jr))return;g(this,jr,t);const e=t.renderButton();S(this,si,lh).call(this,e),s(this,xn).append(e,s(this,si,Iu))}async addEditSignatureButton(t){const e=g(this,Ml,await t.renderEditButton(s(this,En)));S(this,si,lh).call(this,e),s(this,xn).append(e,s(this,si,Iu))}removeButton(t){var e,i;switch(t){case"comment":(e=s(this,zr))==null||e.removeToolbarCommentButton(),g(this,zr,null),(i=s(this,kl))==null||i.remove(),g(this,kl,null);break}}async addButton(t,e){switch(t){case"colorPicker":e&&this.addColorPicker(e);break;case"altText":e&&await this.addAltText(e);break;case"editSignature":e&&await this.addEditSignatureButton(e);break;case"delete":this.addDeleteButton();break;case"comment":e&&this.addComment(e);break}}async addButtonBefore(t,e,i){if(!e&&t==="comment")return;const n=s(this,xn).querySelector(i);n&&t==="comment"&&this.addComment(e,n)}updateEditSignatureButton(t){s(this,Ml)&&(s(this,Ml).title=t)}remove(){var t;s(this,Br).remove(),(t=s(this,jr))==null||t.destroy(),g(this,jr,null)}};Br=new WeakMap,jr=new WeakMap,En=new WeakMap,xn=new WeakMap,jh=new WeakMap,zr=new WeakMap,kl=new WeakMap,Ml=new WeakMap,zh=new WeakMap,Hf=new WeakSet,Av=function(t){t.stopPropagation()},si=new WeakSet,Sv=function(t){s(this,En)._focusEventsAllowed=!1,Ee(t)},Ev=function(t){s(this,En)._focusEventsAllowed=!0,Ee(t)},lh=function(t){const e=s(this,En)._uiManager._signal;return!(e instanceof AbortSignal)||e.aborted?!1:(t.addEventListener("focusin",S(this,si,Sv).bind(this),{capture:!0,signal:e}),t.addEventListener("focusout",S(this,si,Ev).bind(this),{capture:!0,signal:e}),t.addEventListener("contextmenu",wn,{signal:e}),!0)},Iu=function(){const t=document.createElement("div");return t.className="divider",t},y(Fs,Hf),y(Fs,zh,null);let Wg=Fs;class sE{constructor(t){y(this,js);y(this,Uh,null);y(this,Vo,null);y(this,Bs);g(this,Bs,t)}show(t,e,i){const[n,r]=S(this,js,Cv).call(this,e,i),{style:o}=s(this,Vo)||g(this,Vo,S(this,js,xv).call(this));t.append(s(this,Vo)),o.insetInlineEnd=`${100*n}%`,o.top=`calc(${100*r}% + var(--editor-toolbar-vert-offset))`}hide(){s(this,Vo).remove()}}Uh=new WeakMap,Vo=new WeakMap,Bs=new WeakMap,js=new WeakSet,xv=function(){const t=g(this,Vo,document.createElement("div"));t.className="editToolbar",t.setAttribute("role","toolbar");const e=s(this,Bs)._signal;e instanceof AbortSignal&&!e.aborted&&t.addEventListener("contextmenu",wn,{signal:e});const i=g(this,Uh,document.createElement("div"));return i.className="buttons",t.append(i),s(this,Bs).hasCommentManager()&&S(this,js,Um).call(this,"commentButton","pdfjs-comment-floating-button","pdfjs-comment-floating-button-label",()=>{s(this,Bs).commentSelection("floating_button")}),S(this,js,Um).call(this,"highlightButton","pdfjs-highlight-floating-button1","pdfjs-highlight-floating-button-label",()=>{s(this,Bs).highlightSelection("floating_button")}),t},Cv=function(t,e){let i=0,n=0;for(const r of t){const o=r.y+r.height;if(o<i)continue;const l=r.x+(e?r.width:0);if(o>i){n=l,i=o;continue}e?l>n&&(n=l):l<n&&(n=l)}return[e?1-n:n,i]},Um=function(t,e,i,n){const r=document.createElement("button");r.classList.add("basic",t),r.tabIndex=0,r.setAttribute("data-l10n-id",e);const o=document.createElement("span");r.append(o),o.className="visuallyHidden",o.setAttribute("data-l10n-id",i);const l=s(this,Bs)._signal;l instanceof AbortSignal&&!l.aborted&&(r.addEventListener("contextmenu",wn,{signal:l}),r.addEventListener("click",n,{signal:l})),s(this,Uh).append(r)};function v0(a,t,e){for(const i of e)t.addEventListener(i,a[i].bind(a))}const qt=class qt{static initializeAndAddPointerId(t){(s(qt,Yo)||g(qt,Yo,new Set)).add(t)}static setPointer(t,e){s(qt,Go)||g(qt,Go,e),s(qt,Xo)??g(qt,Xo,t)}static setTimeStamp(t){g(qt,Rl,t)}static isSamePointerId(t){return s(qt,Go)===t}static isSamePointerIdOrRemove(t){var e;return s(qt,Go)===t?!0:((e=s(qt,Yo))==null||e.delete(t),!1)}static isSamePointerType(t){return s(qt,Xo)===t}static isInitializedAndDifferentPointerType(t){return s(qt,Xo)!==null&&!qt.isSamePointerType(t)}static isSameTimeStamp(t){return s(qt,Rl)===t}static isUsingMultiplePointers(){var t;return((t=s(qt,Yo))==null?void 0:t.size)>=1}static clearPointerType(){g(qt,Xo,null)}static clearPointerIds(){g(qt,Go,NaN),g(qt,Yo,null)}static clearTimeStamp(){g(qt,Rl,NaN)}};Go=new WeakMap,Yo=new WeakMap,Rl=new WeakMap,Xo=new WeakMap,y(qt,Go,NaN),y(qt,Yo,null),y(qt,Rl,NaN),y(qt,Xo,null);let fi=qt;class rE{constructor(){y(this,$f,0)}get id(){return`${vh}${Ge(this,$f)._++}`}}$f=new WeakMap;const _m=class _m{constructor(){y(this,Ol);y(this,Dl,c0());y(this,Hh,0);y(this,pi,null)}static get _isSVGFittingCanvas(){const t='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',i=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),n=new Image;n.src=t;const r=n.decode().then(()=>(i.drawImage(n,0,0,1,1,0,0,1,3),new Uint32Array(i.getImageData(0,0,1,1).data.buffer)[0]===0));return gt(this,"_isSVGFittingCanvas",r)}async getFromFile(t){const{lastModified:e,name:i,size:n,type:r}=t;return S(this,Ol,yp).call(this,`${e}_${i}_${n}_${r}`,t)}async getFromUrl(t){return S(this,Ol,yp).call(this,t,t)}async getFromBlob(t,e){const i=await e;return S(this,Ol,yp).call(this,t,i)}async getFromId(t){s(this,pi)||g(this,pi,new Map);const e=s(this,pi).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:i}=e;return delete e.blobPromise,this.getFromBlob(e.id,i)}return this.getFromUrl(e.url)}getFromCanvas(t,e){s(this,pi)||g(this,pi,new Map);let i=s(this,pi).get(t);if(i!=null&&i.bitmap)return i.refCounter+=1,i;const n=new OffscreenCanvas(e.width,e.height);return n.getContext("2d").drawImage(e,0,0),i={bitmap:n.transferToImageBitmap(),id:`image_${s(this,Dl)}_${Ge(this,Hh)._++}`,refCounter:1,isSvg:!1},s(this,pi).set(t,i),s(this,pi).set(i.id,i),i}getSvgUrl(t){const e=s(this,pi).get(t);return e!=null&&e.isSvg?e.svgUrl:null}deleteId(t){var n;s(this,pi)||g(this,pi,new Map);const e=s(this,pi).get(t);if(!e||(e.refCounter-=1,e.refCounter!==0))return;const{bitmap:i}=e;if(!e.url&&!e.file){const r=new OffscreenCanvas(i.width,i.height);r.getContext("bitmaprenderer").transferFromImageBitmap(i),e.blobPromise=r.convertToBlob()}(n=i.close)==null||n.call(i),e.bitmap=null}isValidId(t){return t.startsWith(`image_${s(this,Dl)}_`)}};Dl=new WeakMap,Hh=new WeakMap,pi=new WeakMap,Ol=new WeakSet,yp=async function(t,e){s(this,pi)||g(this,pi,new Map);let i=s(this,pi).get(t);if(i===null)return null;if(i!=null&&i.bitmap)return i.refCounter+=1,i;try{i||(i={bitmap:null,id:`image_${s(this,Dl)}_${Ge(this,Hh)._++}`,refCounter:0,isSvg:!1});let n;if(typeof e=="string"?(i.url=e,n=await xh(e,"blob")):e instanceof File?n=i.file=e:e instanceof Blob&&(n=e),n.type==="image/svg+xml"){const r=_m._isSVGFittingCanvas,o=new FileReader,l=new Image,c=new Promise((h,d)=>{l.onload=()=>{i.bitmap=l,i.isSvg=!0,h()},o.onload=async()=>{const u=i.svgUrl=o.result;l.src=await r?`${u}#svgView(preserveAspectRatio(none))`:u},l.onerror=o.onerror=d});o.readAsDataURL(n),await c}else i.bitmap=await createImageBitmap(n);i.refCounter=1}catch(n){pt(n),i=null}return s(this,pi).set(t,i),i&&s(this,pi).set(i.id,i),i};let Vg=_m;class oE{constructor(t=128){y(this,Re,[]);y(this,Ur,!1);y(this,$h);y(this,Ae,-1);g(this,$h,t)}add({cmd:t,undo:e,post:i,mustExec:n,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:l=!1}){if(n&&t(),s(this,Ur))return;const c={cmd:t,undo:e,post:i,type:r};if(s(this,Ae)===-1){s(this,Re).length>0&&(s(this,Re).length=0),g(this,Ae,0),s(this,Re).push(c);return}if(o&&s(this,Re)[s(this,Ae)].type===r){l&&(c.undo=s(this,Re)[s(this,Ae)].undo),s(this,Re)[s(this,Ae)]=c;return}const h=s(this,Ae)+1;h===s(this,$h)?s(this,Re).splice(0,1):(g(this,Ae,h),h<s(this,Re).length&&s(this,Re).splice(h)),s(this,Re).push(c)}undo(){if(s(this,Ae)===-1)return;g(this,Ur,!0);const{undo:t,post:e}=s(this,Re)[s(this,Ae)];t(),e==null||e(),g(this,Ur,!1),g(this,Ae,s(this,Ae)-1)}redo(){if(s(this,Ae)<s(this,Re).length-1){g(this,Ae,s(this,Ae)+1),g(this,Ur,!0);const{cmd:t,post:e}=s(this,Re)[s(this,Ae)];t(),e==null||e(),g(this,Ur,!1)}}hasSomethingToUndo(){return s(this,Ae)!==-1}hasSomethingToRedo(){return s(this,Ae)<s(this,Re).length-1}cleanType(t){if(s(this,Ae)!==-1){for(let e=s(this,Ae);e>=0;e--)if(s(this,Re)[e].type!==t){s(this,Re).splice(e+1,s(this,Ae)-e),g(this,Ae,e);return}s(this,Re).length=0,g(this,Ae,-1)}}destroy(){g(this,Re,null)}}Re=new WeakMap,Ur=new WeakMap,$h=new WeakMap,Ae=new WeakMap;class Ph{constructor(t){y(this,Wf);this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:e}=je.platform;for(const[i,n,r={}]of t)for(const o of i){const l=o.startsWith("mac+");e&&l?(this.callbacks.set(o.slice(4),{callback:n,options:r}),this.allKeys.add(o.split("+").at(-1))):!e&&!l&&(this.callbacks.set(o,{callback:n,options:r}),this.allKeys.add(o.split("+").at(-1)))}}exec(t,e){if(!this.allKeys.has(e.key))return;const i=this.callbacks.get(S(this,Wf,_v).call(this,e));if(!i)return;const{callback:n,options:{bubbles:r=!1,args:o=[],checker:l=null}}=i;l&&!l(t,e)||(n.bind(t,...o,e)(),r||Ee(e))}}Wf=new WeakSet,_v=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 Vf=class Vf{get _colors(){const t=new Map([["CanvasText",null],["Canvas",null]]);return QS(t),gt(this,"_colors",t)}convert(t){const e=Th(t);if(!window.matchMedia("(forced-colors: active)").matches)return e;for(const[i,n]of this._colors)if(n.every((r,o)=>r===e[o]))return Vf._colorsMapping.get(i);return e}getHexCode(t){const e=this._colors.get(t);return e?Z.makeHexColor(...e):t}};W(Vf,"_colorsMapping",new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]));let Gg=Vf;const Wl=class Wl{constructor(t,e,i,n,r,o,l,c,h,d,u,f,p,m,b,v){y(this,q);y(this,Il,new AbortController);y(this,Ji,null);y(this,Ll,null);y(this,xe,new Map);y(this,ze,new Map);y(this,Nl,null);y(this,Cn,null);y(this,Fl,null);y(this,_n,new oE);y(this,gi,null);y(this,Hr,null);y(this,$r,null);y(this,Bl,0);y(this,Wr,new Set);y(this,os,null);y(this,Tn,null);y(this,qo,new Set);W(this,"_editorUndoBar",null);y(this,Wh,!1);y(this,Vh,!1);y(this,jl,!1);y(this,Gh,null);y(this,as,null);y(this,Vr,null);y(this,zl,null);y(this,Gr,!1);y(this,ls,null);y(this,Gf,new rE);y(this,Yr,!1);y(this,Ul,!1);y(this,Yh,!1);y(this,Xr,null);y(this,Ko,null);y(this,Hl,null);y(this,qr,null);y(this,Xh,null);y(this,Le,mt.NONE);y(this,Yt,new Set);y(this,zs,null);y(this,Kr,null);y(this,Jr,null);y(this,qh,null);y(this,$l,null);y(this,Kh,{isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1});y(this,Zr,[0,0]);y(this,cs,null);y(this,Us,null);y(this,Jh,null);y(this,Zh,null);y(this,Pn,null);const w=this._signal=s(this,Il).signal;g(this,Us,t),g(this,Jh,e),g(this,Zh,i),g(this,Nl,n),g(this,gi,r),g(this,Kr,o),g(this,$l,c),this._eventBus=l,l._on("editingaction",this.onEditingAction.bind(this),{signal:w}),l._on("pagechanging",this.onPageChanging.bind(this),{signal:w}),l._on("scalechanging",this.onScaleChanging.bind(this),{signal:w}),l._on("rotationchanging",this.onRotationChanging.bind(this),{signal:w}),l._on("setpreference",this.onSetPreference.bind(this),{signal:w}),l._on("switchannotationeditorparams",_=>this.updateParams(_.type,_.value),{signal:w}),window.addEventListener("pointerdown",()=>{g(this,Ul,!0)},{capture:!0,signal:w}),window.addEventListener("pointerup",()=>{g(this,Ul,!1)},{capture:!0,signal:w}),S(this,q,kv).call(this),S(this,q,Lv).call(this),S(this,q,$m).call(this),g(this,Cn,c.annotationStorage),g(this,Gh,c.filterFactory),g(this,Jr,h),g(this,zl,d||null),g(this,Wh,u),g(this,Vh,f),g(this,jl,p),g(this,Xh,m||null),this.viewParameters={realScale:Fr.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=b||null,this._supportsPinchToZoom=v!==!1,r==null||r.setSidebarUiManager(this)}static get _keyboardManager(){const t=Wl.prototype,e=o=>s(o,Us).contains(document.activeElement)&&document.activeElement.tagName!=="BUTTON"&&o.hasSomethingToControl(),i=(o,{target:l})=>{if(l instanceof HTMLInputElement){const{type:c}=l;return c!=="text"&&c!=="number"}return!0},n=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return gt(this,"_keyboardManager",new Ph([[["ctrl+a","mac+meta+a"],t.selectAll,{checker:i}],[["ctrl+z","mac+meta+z"],t.undo,{checker:i}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],t.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"],t.delete,{checker:i}],[["Enter","mac+Enter"],t.addNewEditorFromKeyboard,{checker:(o,{target:l})=>!(l instanceof HTMLButtonElement)&&s(o,Us).contains(l)&&!o.isEnterHandled}],[[" ","mac+ "],t.addNewEditorFromKeyboard,{checker:(o,{target:l})=>!(l instanceof HTMLButtonElement)&&s(o,Us).contains(document.activeElement)}],[["Escape","mac+Escape"],t.unselectAll],[["ArrowLeft","mac+ArrowLeft"],t.translateSelectedEditors,{args:[-n,0],checker:e}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t.translateSelectedEditors,{args:[-r,0],checker:e}],[["ArrowRight","mac+ArrowRight"],t.translateSelectedEditors,{args:[n,0],checker:e}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t.translateSelectedEditors,{args:[r,0],checker:e}],[["ArrowUp","mac+ArrowUp"],t.translateSelectedEditors,{args:[0,-n],checker:e}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t.translateSelectedEditors,{args:[0,-r],checker:e}],[["ArrowDown","mac+ArrowDown"],t.translateSelectedEditors,{args:[0,n],checker:e}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t.translateSelectedEditors,{args:[0,r],checker:e}]]))}destroy(){var t,e,i,n,r,o,l,c,h;(t=s(this,Pn))==null||t.resolve(),g(this,Pn,null),(e=s(this,Il))==null||e.abort(),g(this,Il,null),this._signal=null;for(const d of s(this,ze).values())d.destroy();s(this,ze).clear(),s(this,xe).clear(),s(this,qo).clear(),(i=s(this,qr))==null||i.clear(),g(this,Ji,null),s(this,Yt).clear(),s(this,_n).destroy(),(n=s(this,Nl))==null||n.destroy(),(r=s(this,gi))==null||r.destroy(),(o=s(this,Kr))==null||o.destroy(),(l=s(this,ls))==null||l.hide(),g(this,ls,null),(c=s(this,Hl))==null||c.destroy(),g(this,Hl,null),g(this,Ll,null),s(this,as)&&(clearTimeout(s(this,as)),g(this,as,null)),s(this,cs)&&(clearTimeout(s(this,cs)),g(this,cs,null)),(h=this._editorUndoBar)==null||h.destroy(),g(this,$l,null)}combinedSignal(t){return AbortSignal.any([this._signal,t.signal])}get mlManager(){return s(this,Xh)}get useNewAltTextFlow(){return s(this,Vh)}get useNewAltTextWhenAddingImage(){return s(this,jl)}get hcmFilter(){return gt(this,"hcmFilter",s(this,Jr)?s(this,Gh).addHCMFilter(s(this,Jr).foreground,s(this,Jr).background):"none")}get direction(){return gt(this,"direction",getComputedStyle(s(this,Us)).direction)}get _highlightColors(){return gt(this,"_highlightColors",s(this,zl)?new Map(s(this,zl).split(",").map(t=>(t=t.split("=").map(e=>e.trim()),t[1]=t[1].toUpperCase(),t))):null)}get highlightColors(){const{_highlightColors:t}=this;if(!t)return gt(this,"highlightColors",null);const e=new Map,i=!!s(this,Jr);for(const[n,r]of t){const o=n.endsWith("_HCM");if(i&&o){e.set(n.replace("_HCM",""),r);continue}!i&&!o&&e.set(n,r)}return gt(this,"highlightColors",e)}get highlightColorNames(){return gt(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),g(this,$r,t)}setMainHighlightColorPicker(t){g(this,Hl,t)}editAltText(t,e=!1){var i;(i=s(this,Nl))==null||i.editAltText(this,t,e)}hasCommentManager(){return!!s(this,gi)}editComment(t,e,i,n){var r;(r=s(this,gi))==null||r.showDialog(this,t,e,i,n)}selectComment(t,e){const i=s(this,ze).get(t),n=i==null?void 0:i.getEditorByUID(e);n==null||n.toggleComment(!0,!0)}updateComment(t){var e;(e=s(this,gi))==null||e.updateComment(t.getData())}updatePopupColor(t){var e;(e=s(this,gi))==null||e.updatePopupColor(t)}removeComment(t){var e;(e=s(this,gi))==null||e.removeComments([t.uid])}toggleComment(t,e,i=void 0){var n;(n=s(this,gi))==null||n.toggleCommentPopup(t,e,i)}makeCommentColor(t,e){var i;return t&&((i=s(this,gi))==null?void 0:i.makeCommentColor(t,e))||null}getCommentDialogElement(){var t;return((t=s(this,gi))==null?void 0:t.dialogElement)||null}async waitForEditorsRendered(t){if(s(this,ze).has(t-1))return;const{resolve:e,promise:i}=Promise.withResolvers(),n=r=>{r.pageNumber===t&&(this._eventBus._off("editorsrendered",n),e())};this._eventBus.on("editorsrendered",n),await i}getSignature(t){var e;(e=s(this,Kr))==null||e.getSignature({uiManager:this,editor:t})}get signatureManager(){return s(this,Kr)}switchToMode(t,e){this._eventBus.on("annotationeditormodechanged",e,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:t})}setPreference(t,e){this._eventBus.dispatch("setpreference",{source:this,name:t,value:e})}onSetPreference({name:t,value:e}){switch(t){case"enableNewAltTextWhenAddingImage":g(this,jl,e);break}}onPageChanging({pageNumber:t}){g(this,Bl,t-1)}focusMainContainer(){s(this,Us).focus()}findParent(t,e){for(const i of s(this,ze).values()){const{x:n,y:r,width:o,height:l}=i.div.getBoundingClientRect();if(t>=n&&t<=n+o&&e>=r&&e<=r+l)return i}return null}disableUserSelect(t=!1){s(this,Jh).classList.toggle("noUserSelect",t)}addShouldRescale(t){s(this,qo).add(t)}removeShouldRescale(t){s(this,qo).delete(t)}onScaleChanging({scale:t}){var e;this.commitOrRemove(),this.viewParameters.realScale=t*Fr.PDF_TO_CSS_UNITS;for(const i of s(this,qo))i.onScaleChanging();(e=s(this,$r))==null||e.onScaleChanging()}onRotationChanging({pagesRotation:t}){this.commitOrRemove(),this.viewParameters.rotation=t}highlightSelection(t="",e=!1){const i=document.getSelection();if(!i||i.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:l}=i,c=i.toString(),d=S(this,q,vp).call(this,i).closest(".textLayer"),u=this.getSelectionBoxes(d);if(!u)return;i.empty();const f=S(this,q,Hm).call(this,d),p=s(this,Le)===mt.NONE,m=()=>{const b=f==null?void 0:f.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:t,boxes:u,anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:l,text:c});p&&this.showAllEditors("highlight",!0,!0),e&&(b==null||b.editComment())};if(p){this.switchToMode(mt.HIGHLIGHT,m);return}m()}commentSelection(t=""){this.highlightSelection(t,!0)}getAndRemoveDataFromAnnotationStorage(t){if(!s(this,Cn))return null;const e=`${vh}${t}`,i=s(this,Cn).getRawValue(e);return i&&s(this,Cn).remove(e),i}addToAnnotationStorage(t){!t.isEmpty()&&s(this,Cn)&&!s(this,Cn).has(t.id)&&s(this,Cn).setValue(t.id,t)}a11yAlert(t,e=null){const i=s(this,Zh);i&&(i.setAttribute("data-l10n-id",t),e?i.setAttribute("data-l10n-args",JSON.stringify(e)):i.removeAttribute("data-l10n-args"))}blur(){if(this.isShiftKeyDown=!1,s(this,Gr)&&(g(this,Gr,!1),S(this,q,Lu).call(this,"main_toolbar")),!this.hasSelection)return;const{activeElement:t}=document;for(const e of s(this,Yt))if(e.div.contains(t)){g(this,Ko,[e,t]),e._focusEventsAllowed=!1;break}}focus(){if(!s(this,Ko))return;const[t,e]=s(this,Ko);g(this,Ko,null),e.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:this._signal}),e.focus()}addEditListeners(){S(this,q,$m).call(this),this.setEditingState(!0)}removeEditListeners(){S(this,q,Dv).call(this),this.setEditingState(!1)}dragOver(t){for(const{type:e}of t.dataTransfer.items)for(const i of s(this,Tn))if(i.isHandlingMimeForPasting(e)){t.dataTransfer.dropEffect="copy",t.preventDefault();return}}drop(t){for(const e of t.dataTransfer.items)for(const i of s(this,Tn))if(i.isHandlingMimeForPasting(e.type)){i.paste(e,this.currentLayer),t.preventDefault();return}}copy(t){var i;if(t.preventDefault(),(i=s(this,Ji))==null||i.commitOrRemove(),!this.hasSelection)return;const e=[];for(const n of s(this,Yt)){const r=n.serialize(!0);r&&e.push(r)}e.length!==0&&t.clipboardData.setData("application/pdfjs",JSON.stringify(e))}cut(t){this.copy(t),this.delete()}async paste(t){t.preventDefault();const{clipboardData:e}=t;for(const r of e.items)for(const o of s(this,Tn))if(o.isHandlingMimeForPasting(r.type)){o.paste(r,this.currentLayer);return}let i=e.getData("application/pdfjs");if(!i)return;try{i=JSON.parse(i)}catch(r){pt(`paste: "${r.message}".`);return}if(!Array.isArray(i))return;this.unselectAll();const n=this.currentLayer;try{const r=[];for(const c of i){const h=await n.deserialize(c);if(!h)return;r.push(h)}const o=()=>{for(const c of r)S(this,q,Wm).call(this,c);S(this,q,Vm).call(this,r)},l=()=>{for(const c of r)c.remove()};this.addCommands({cmd:o,undo:l,mustExec:!0})}catch(r){pt(`paste: "${r.message}".`)}}keydown(t){!this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!0),s(this,Le)!==mt.NONE&&!this.isEditorHandlingKeyboard&&Wl._keyboardManager.exec(this,t)}keyup(t){this.isShiftKeyDown&&t.key==="Shift"&&(this.isShiftKeyDown=!1,s(this,Gr)&&(g(this,Gr,!1),S(this,q,Lu).call(this,"main_toolbar")))}onEditingAction({name:t}){switch(t){case"undo":case"redo":case"delete":case"selectAll":this[t]();break;case"highlightSelection":this.highlightSelection("context_menu");break;case"commentSelection":this.commentSelection("context_menu");break}}setEditingState(t){t?(S(this,q,Mv).call(this),S(this,q,Ov).call(this),S(this,q,Ri).call(this,{isEditing:s(this,Le)!==mt.NONE,isEmpty:S(this,q,Nu).call(this),hasSomethingToUndo:s(this,_n).hasSomethingToUndo(),hasSomethingToRedo:s(this,_n).hasSomethingToRedo(),hasSelectedEditor:!1})):(S(this,q,Rv).call(this),S(this,q,Iv).call(this),S(this,q,Ri).call(this,{isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(t){if(!s(this,Tn)){g(this,Tn,t);for(const e of s(this,Tn))S(this,q,_r).call(this,e.defaultPropertiesToUpdate)}}getId(){return s(this,Gf).id}get currentLayer(){return s(this,ze).get(s(this,Bl))}getLayer(t){return s(this,ze).get(t)}get currentPageIndex(){return s(this,Bl)}addLayer(t){s(this,ze).set(t.pageIndex,t),s(this,Yr)?t.enable():t.disable()}removeLayer(t){s(this,ze).delete(t.pageIndex)}async updateMode(t,e=null,i=!1,n=!1,r=!1,o=!1){var l,c,h,d,u,f;if(s(this,Le)!==t&&!(s(this,Pn)&&(await s(this,Pn).promise,!s(this,Pn)))){if(g(this,Pn,Promise.withResolvers()),(l=s(this,$r))==null||l.commitOrRemove(),s(this,Le)===mt.POPUP&&((c=s(this,gi))==null||c.hideSidebar()),(h=s(this,gi))==null||h.destroyPopup(),g(this,Le,t),t===mt.NONE){this.setEditingState(!1),S(this,q,Fv).call(this);for(const p of s(this,xe).values())p.hideStandaloneCommentButton();(d=this._editorUndoBar)==null||d.hide(),this.toggleComment(null),s(this,Pn).resolve();return}for(const p of s(this,xe).values())p.addStandaloneCommentButton();t===mt.SIGNATURE&&await((u=s(this,Kr))==null?void 0:u.loadSignatures()),i&&fi.clearPointerType(),this.setEditingState(!0),await S(this,q,Nv).call(this),this.unselectAll();for(const p of s(this,ze).values())p.updateMode(t);if(t===mt.POPUP){s(this,Ll)||g(this,Ll,await s(this,$l).getAnnotationsByType(new Set(s(this,Tn).map(b=>b._editorType))));const p=new Set,m=[];for(const b of s(this,xe).values()){const{annotationElementId:v,hasComment:w,deleted:_}=b;v&&p.add(v),w&&!_&&m.push(b.getData())}for(const b of s(this,Ll)){const{id:v,popupRef:w,contentsObj:_}=b;w&&(_!=null&&_.str)&&!p.has(v)&&!s(this,Wr).has(v)&&m.push(b)}(f=s(this,gi))==null||f.showSidebar(m)}if(!e){n&&this.addNewEditorFromKeyboard(),s(this,Pn).resolve();return}for(const p of s(this,xe).values())p.uid===e?(this.setSelected(p),o?p.editComment():r?p.enterInEditMode():p.focus()):p.unselect();s(this,Pn).resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(t){t.mode!==s(this,Le)&&this._eventBus.dispatch("switchannotationeditormode",{source:this,...t})}updateParams(t,e){if(s(this,Tn)){switch(t){case kt.CREATE:this.currentLayer.addNewEditor(e);return;case kt.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(s(this,qh)||g(this,qh,new Map)).set(t,e),this.showAllEditors("highlight",e);break}if(this.hasSelection)for(const i of s(this,Yt))i.updateParams(t,e);else for(const i of s(this,Tn))i.updateDefaultParams(t,e)}}showAllEditors(t,e,i=!1){var r;for(const o of s(this,xe).values())o.editorType===t&&o.show(e);(((r=s(this,qh))==null?void 0:r.get(kt.HIGHLIGHT_SHOW_ALL))??!0)!==e&&S(this,q,_r).call(this,[[kt.HIGHLIGHT_SHOW_ALL,e]])}enableWaiting(t=!1){if(s(this,Yh)!==t){g(this,Yh,t);for(const e of s(this,ze).values())t?e.disableClick():e.enableClick(),e.div.classList.toggle("waiting",t)}}*getEditors(t){for(const e of s(this,xe).values())e.pageIndex===t&&(yield e)}getEditor(t){return s(this,xe).get(t)}addEditor(t){s(this,xe).set(t.id,t)}removeEditor(t){var e,i;t.div.contains(document.activeElement)&&(s(this,as)&&clearTimeout(s(this,as)),g(this,as,setTimeout(()=>{this.focusMainContainer(),g(this,as,null)},0))),s(this,xe).delete(t.id),t.annotationElementId&&((e=s(this,qr))==null||e.delete(t.annotationElementId)),this.unselect(t),(!t.annotationElementId||!s(this,Wr).has(t.annotationElementId))&&((i=s(this,Cn))==null||i.remove(t.id))}addDeletedAnnotationElement(t){s(this,Wr).add(t.annotationElementId),this.addChangedExistingAnnotation(t),t.deleted=!0}isDeletedAnnotationElement(t){return s(this,Wr).has(t)}removeDeletedAnnotationElement(t){s(this,Wr).delete(t.annotationElementId),this.removeChangedExistingAnnotation(t),t.deleted=!1}setActiveEditor(t){s(this,Ji)!==t&&(g(this,Ji,t),t&&S(this,q,_r).call(this,t.propertiesToUpdate))}updateUI(t){s(this,q,Bv)===t&&S(this,q,_r).call(this,t.propertiesToUpdate)}updateUIForDefaultProperties(t){S(this,q,_r).call(this,t.defaultPropertiesToUpdate)}toggleSelected(t){if(s(this,Yt).has(t)){s(this,Yt).delete(t),t.unselect(),S(this,q,Ri).call(this,{hasSelectedEditor:this.hasSelection});return}s(this,Yt).add(t),t.select(),S(this,q,_r).call(this,t.propertiesToUpdate),S(this,q,Ri).call(this,{hasSelectedEditor:!0})}setSelected(t){var e;this.updateToolbar({mode:t.mode,editId:t.uid}),(e=s(this,$r))==null||e.commitOrRemove();for(const i of s(this,Yt))i!==t&&i.unselect();s(this,Yt).clear(),s(this,Yt).add(t),t.select(),S(this,q,_r).call(this,t.propertiesToUpdate),S(this,q,Ri).call(this,{hasSelectedEditor:!0})}isSelected(t){return s(this,Yt).has(t)}get firstSelectedEditor(){return s(this,Yt).values().next().value}unselect(t){t.unselect(),s(this,Yt).delete(t),S(this,q,Ri).call(this,{hasSelectedEditor:this.hasSelection})}get hasSelection(){return s(this,Yt).size!==0}get isEnterHandled(){return s(this,Yt).size===1&&this.firstSelectedEditor.isEnterHandled}undo(){var t;s(this,_n).undo(),S(this,q,Ri).call(this,{hasSomethingToUndo:s(this,_n).hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:S(this,q,Nu).call(this)}),(t=this._editorUndoBar)==null||t.hide()}redo(){s(this,_n).redo(),S(this,q,Ri).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:s(this,_n).hasSomethingToRedo(),isEmpty:S(this,q,Nu).call(this)})}addCommands(t){s(this,_n).add(t),S(this,q,Ri).call(this,{hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:S(this,q,Nu).call(this)})}cleanUndoStack(t){s(this,_n).cleanType(t)}delete(){var r;this.commitOrRemove();const t=(r=this.currentLayer)==null?void 0:r.endDrawingSession(!0);if(!this.hasSelection&&!t)return;const e=t?[t]:[...s(this,Yt)],i=()=>{var o;(o=this._editorUndoBar)==null||o.show(n,e.length===1?e[0].editorType:e.length);for(const l of e)l.remove()},n=()=>{for(const o of e)S(this,q,Wm).call(this,o)};this.addCommands({cmd:i,undo:n,mustExec:!0})}commitOrRemove(){var t;(t=s(this,Ji))==null||t.commitOrRemove()}hasSomethingToControl(){return s(this,Ji)||this.hasSelection}selectAll(){for(const t of s(this,Yt))t.commit();S(this,q,Vm).call(this,s(this,xe).values())}unselectAll(){var t;if(!(s(this,Ji)&&(s(this,Ji).commitOrRemove(),s(this,Le)!==mt.NONE))&&!((t=s(this,$r))!=null&&t.commitOrRemove())&&this.hasSelection){for(const e of s(this,Yt))e.unselect();s(this,Yt).clear(),S(this,q,Ri).call(this,{hasSelectedEditor:!1})}}translateSelectedEditors(t,e,i=!1){if(i||this.commitOrRemove(),!this.hasSelection)return;s(this,Zr)[0]+=t,s(this,Zr)[1]+=e;const[n,r]=s(this,Zr),o=[...s(this,Yt)],l=1e3;s(this,cs)&&clearTimeout(s(this,cs)),g(this,cs,setTimeout(()=>{g(this,cs,null),s(this,Zr)[0]=s(this,Zr)[1]=0,this.addCommands({cmd:()=>{for(const c of o)s(this,xe).has(c.id)&&(c.translateInPage(n,r),c.translationDone())},undo:()=>{for(const c of o)s(this,xe).has(c.id)&&(c.translateInPage(-n,-r),c.translationDone())},mustExec:!1})},l));for(const c of o)c.translateInPage(t,e),c.translationDone()}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),g(this,os,new Map);for(const t of s(this,Yt))s(this,os).set(t,{savedX:t.x,savedY:t.y,savedPageIndex:t.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!s(this,os))return!1;this.disableUserSelect(!1);const t=s(this,os);g(this,os,null);let e=!1;for(const[{x:n,y:r,pageIndex:o},l]of t)l.newX=n,l.newY=r,l.newPageIndex=o,e||(e=n!==l.savedX||r!==l.savedY||o!==l.savedPageIndex);if(!e)return!1;const i=(n,r,o,l)=>{if(s(this,xe).has(n.id)){const c=s(this,ze).get(l);c?n._setParentAndPosition(c,r,o):(n.pageIndex=l,n.x=r,n.y=o)}};return this.addCommands({cmd:()=>{for(const[n,{newX:r,newY:o,newPageIndex:l}]of t)i(n,r,o,l)},undo:()=>{for(const[n,{savedX:r,savedY:o,savedPageIndex:l}]of t)i(n,r,o,l)},mustExec:!0}),!0}dragSelectedEditors(t,e){if(s(this,os))for(const i of s(this,os).keys())i.drag(t,e)}rebuild(t){if(t.parent===null){const e=this.getLayer(t.pageIndex);e?(e.changeParent(t),e.addOrRebuild(t)):(this.addEditor(t),this.addToAnnotationStorage(t),t.rebuild())}else t.parent.addOrRebuild(t)}get isEditorHandlingKeyboard(){var t;return((t=this.getActive())==null?void 0:t.shouldGetKeyboardEvents())||s(this,Yt).size===1&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(t){return s(this,Ji)===t}getActive(){return s(this,Ji)}getMode(){return s(this,Le)}isEditingMode(){return s(this,Le)!==mt.NONE}get imageManager(){return gt(this,"imageManager",new Vg)}getSelectionBoxes(t){if(!t)return null;const e=document.getSelection();for(let h=0,d=e.rangeCount;h<d;h++)if(!t.contains(e.getRangeAt(h).commonAncestorContainer))return null;const{x:i,y:n,width:r,height:o}=t.getBoundingClientRect();let l;switch(t.getAttribute("data-main-rotation")){case"90":l=(h,d,u,f)=>({x:(d-n)/o,y:1-(h+u-i)/r,width:f/o,height:u/r});break;case"180":l=(h,d,u,f)=>({x:1-(h+u-i)/r,y:1-(d+f-n)/o,width:u/r,height:f/o});break;case"270":l=(h,d,u,f)=>({x:1-(d+f-n)/o,y:(h-i)/r,width:f/o,height:u/r});break;default:l=(h,d,u,f)=>({x:(h-i)/r,y:(d-n)/o,width:u/r,height:f/o});break}const c=[];for(let h=0,d=e.rangeCount;h<d;h++){const u=e.getRangeAt(h);if(!u.collapsed)for(const{x:f,y:p,width:m,height:b}of u.getClientRects())m===0||b===0||c.push(l(f,p,m,b))}return c.length===0?null:c}addChangedExistingAnnotation({annotationElementId:t,id:e}){(s(this,Fl)||g(this,Fl,new Map)).set(t,e)}removeChangedExistingAnnotation({annotationElementId:t}){var e;(e=s(this,Fl))==null||e.delete(t)}renderAnnotationElement(t){var n;const e=(n=s(this,Fl))==null?void 0:n.get(t.data.id);if(!e)return;const i=s(this,Cn).getRawValue(e);i&&(s(this,Le)===mt.NONE&&!i.hasBeenModified||i.renderAnnotationElement(t))}setMissingCanvas(t,e,i){var r;const n=(r=s(this,qr))==null?void 0:r.get(t);n&&(n.setCanvas(e,i),s(this,qr).delete(t))}addMissingCanvas(t,e){(s(this,qr)||g(this,qr,new Map)).set(t,e)}};Il=new WeakMap,Ji=new WeakMap,Ll=new WeakMap,xe=new WeakMap,ze=new WeakMap,Nl=new WeakMap,Cn=new WeakMap,Fl=new WeakMap,_n=new WeakMap,gi=new WeakMap,Hr=new WeakMap,$r=new WeakMap,Bl=new WeakMap,Wr=new WeakMap,os=new WeakMap,Tn=new WeakMap,qo=new WeakMap,Wh=new WeakMap,Vh=new WeakMap,jl=new WeakMap,Gh=new WeakMap,as=new WeakMap,Vr=new WeakMap,zl=new WeakMap,Gr=new WeakMap,ls=new WeakMap,Gf=new WeakMap,Yr=new WeakMap,Ul=new WeakMap,Yh=new WeakMap,Xr=new WeakMap,Ko=new WeakMap,Hl=new WeakMap,qr=new WeakMap,Xh=new WeakMap,Le=new WeakMap,Yt=new WeakMap,zs=new WeakMap,Kr=new WeakMap,Jr=new WeakMap,qh=new WeakMap,$l=new WeakMap,Kh=new WeakMap,Zr=new WeakMap,cs=new WeakMap,Us=new WeakMap,Jh=new WeakMap,Zh=new WeakMap,Pn=new WeakMap,q=new WeakSet,vp=function({anchorNode:t}){return t.nodeType===Node.TEXT_NODE?t.parentElement:t},Hm=function(t){const{currentLayer:e}=this;if(e.hasTextLayer(t))return e;for(const i of s(this,ze).values())if(i.hasTextLayer(t))return i;return null},Tv=function(){const t=document.getSelection();if(!t||t.isCollapsed)return;const i=S(this,q,vp).call(this,t).closest(".textLayer"),n=this.getSelectionBoxes(i);n&&(s(this,ls)||g(this,ls,new sE(this)),s(this,ls).show(i,n,this.direction==="ltr"))},Pv=function(){var r,o,l;const t=document.getSelection();if(!t||t.isCollapsed){s(this,zs)&&((r=s(this,ls))==null||r.hide(),g(this,zs,null),S(this,q,Ri).call(this,{hasSelectedText:!1}));return}const{anchorNode:e}=t;if(e===s(this,zs))return;const n=S(this,q,vp).call(this,t).closest(".textLayer");if(!n){s(this,zs)&&((o=s(this,ls))==null||o.hide(),g(this,zs,null),S(this,q,Ri).call(this,{hasSelectedText:!1}));return}if((l=s(this,ls))==null||l.hide(),g(this,zs,e),S(this,q,Ri).call(this,{hasSelectedText:!0}),!(s(this,Le)!==mt.HIGHLIGHT&&s(this,Le)!==mt.NONE)&&(s(this,Le)===mt.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),g(this,Gr,this.isShiftKeyDown),!this.isShiftKeyDown)){const c=s(this,Le)===mt.HIGHLIGHT?S(this,q,Hm).call(this,n):null;if(c==null||c.toggleDrawing(),s(this,Ul)){const h=new AbortController,d=this.combinedSignal(h),u=f=>{f.type==="pointerup"&&f.button!==0||(h.abort(),c==null||c.toggleDrawing(!0),f.type==="pointerup"&&S(this,q,Lu).call(this,"main_toolbar"))};window.addEventListener("pointerup",u,{signal:d}),window.addEventListener("blur",u,{signal:d})}else c==null||c.toggleDrawing(!0),S(this,q,Lu).call(this,"main_toolbar")}},Lu=function(t=""){s(this,Le)===mt.HIGHLIGHT?this.highlightSelection(t):s(this,Wh)&&S(this,q,Tv).call(this)},kv=function(){document.addEventListener("selectionchange",S(this,q,Pv).bind(this),{signal:this._signal})},Mv=function(){if(s(this,Vr))return;g(this,Vr,new AbortController);const t=this.combinedSignal(s(this,Vr));window.addEventListener("focus",this.focus.bind(this),{signal:t}),window.addEventListener("blur",this.blur.bind(this),{signal:t})},Rv=function(){var t;(t=s(this,Vr))==null||t.abort(),g(this,Vr,null)},$m=function(){if(s(this,Xr))return;g(this,Xr,new AbortController);const t=this.combinedSignal(s(this,Xr));window.addEventListener("keydown",this.keydown.bind(this),{signal:t}),window.addEventListener("keyup",this.keyup.bind(this),{signal:t})},Dv=function(){var t;(t=s(this,Xr))==null||t.abort(),g(this,Xr,null)},Ov=function(){if(s(this,Hr))return;g(this,Hr,new AbortController);const t=this.combinedSignal(s(this,Hr));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})},Iv=function(){var t;(t=s(this,Hr))==null||t.abort(),g(this,Hr,null)},Lv=function(){const t=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:t}),document.addEventListener("drop",this.drop.bind(this),{signal:t})},Ri=function(t){Object.entries(t).some(([i,n])=>s(this,Kh)[i]!==n)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(s(this,Kh),t)}),s(this,Le)===mt.HIGHLIGHT&&t.hasSelectedEditor===!1&&S(this,q,_r).call(this,[[kt.HIGHLIGHT_FREE,!0]]))},_r=function(t){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:t})},Nv=async function(){if(!s(this,Yr)){g(this,Yr,!0);const t=[];for(const e of s(this,ze).values())t.push(e.enable());await Promise.all(t);for(const e of s(this,xe).values())e.enable()}},Fv=function(){if(this.unselectAll(),s(this,Yr)){g(this,Yr,!1);for(const t of s(this,ze).values())t.disable();for(const t of s(this,xe).values())t.disable()}},Wm=function(t){const e=s(this,ze).get(t.pageIndex);e?e.addOrRebuild(t):(this.addEditor(t),this.addToAnnotationStorage(t))},Bv=function(){let t=null;for(t of s(this,Yt));return t},Nu=function(){if(s(this,xe).size===0)return!0;if(s(this,xe).size===1)for(const t of s(this,xe).values())return t.isEmpty();return!1},Vm=function(t){for(const e of s(this,Yt))e.unselect();s(this,Yt).clear();for(const e of t)e.isEmpty()||(s(this,Yt).add(e),e.select());S(this,q,Ri).call(this,{hasSelectedEditor:this.hasSelection})},W(Wl,"TRANSLATE_SMALL",1),W(Wl,"TRANSLATE_BIG",10);let Uo=Wl;const xi=class xi{constructor(t){y(this,jn);y(this,Xe,null);y(this,hs,!1);y(this,Bn,null);y(this,Vl,null);y(this,ds,null);y(this,Zi,null);y(this,Gl,!1);y(this,us,null);y(this,Li,null);y(this,Hs,null);y(this,Jo,null);y(this,fs,!1);g(this,Li,t),g(this,fs,t._uiManager.useNewAltTextFlow),s(xi,Qr)||g(xi,Qr,Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"}))}static initialize(t){xi._l10n??(xi._l10n=t)}async render(){const t=g(this,Bn,document.createElement("button"));t.className="altText",t.tabIndex="0";const e=g(this,Vl,document.createElement("span"));t.append(e),s(this,fs)?(t.classList.add("new"),t.setAttribute("data-l10n-id",s(xi,Qr).missing),e.setAttribute("data-l10n-id",s(xi,Qr)["missing-label"])):(t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const i=s(this,Li)._uiManager._signal;t.addEventListener("contextmenu",wn,{signal:i}),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});const n=r=>{r.preventDefault(),s(this,Li)._uiManager.editAltText(s(this,Li)),s(this,fs)&&s(this,Li)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:s(this,jn,Fu)}})};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(g(this,Gl,!0),n(r))},{signal:i}),await S(this,jn,wp).call(this),t}finish(){s(this,Bn)&&(s(this,Bn).focus({focusVisible:s(this,Gl)}),g(this,Gl,!1))}isEmpty(){return s(this,fs)?s(this,Xe)===null:!s(this,Xe)&&!s(this,hs)}hasData(){return s(this,fs)?s(this,Xe)!==null||!!s(this,Hs):this.isEmpty()}get guessedText(){return s(this,Hs)}async setGuessedText(t){s(this,Xe)===null&&(g(this,Hs,t),g(this,Jo,await xi._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:t})),S(this,jn,wp).call(this))}toggleAltTextBadge(t=!1){var e;if(!s(this,fs)||s(this,Xe)){(e=s(this,us))==null||e.remove(),g(this,us,null);return}if(!s(this,us)){const i=g(this,us,document.createElement("div"));i.className="noAltTextBadge",s(this,Li).div.append(i)}s(this,us).classList.toggle("hidden",!t)}serialize(t){let e=s(this,Xe);return!t&&s(this,Hs)===e&&(e=s(this,Jo)),{altText:e,decorative:s(this,hs),guessedText:s(this,Hs),textWithDisclaimer:s(this,Jo)}}get data(){return{altText:s(this,Xe),decorative:s(this,hs)}}set data({altText:t,decorative:e,guessedText:i,textWithDisclaimer:n,cancel:r=!1}){i&&(g(this,Hs,i),g(this,Jo,n)),!(s(this,Xe)===t&&s(this,hs)===e)&&(r||(g(this,Xe,t),g(this,hs,e)),S(this,jn,wp).call(this))}toggle(t=!1){s(this,Bn)&&(!t&&s(this,Zi)&&(clearTimeout(s(this,Zi)),g(this,Zi,null)),s(this,Bn).disabled=!t)}shown(){s(this,Li)._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:s(this,jn,Fu)}})}destroy(){var t,e;(t=s(this,Bn))==null||t.remove(),g(this,Bn,null),g(this,Vl,null),g(this,ds,null),(e=s(this,us))==null||e.remove(),g(this,us,null)}};Xe=new WeakMap,hs=new WeakMap,Bn=new WeakMap,Vl=new WeakMap,ds=new WeakMap,Zi=new WeakMap,Gl=new WeakMap,us=new WeakMap,Li=new WeakMap,Hs=new WeakMap,Jo=new WeakMap,fs=new WeakMap,Qr=new WeakMap,jn=new WeakSet,Fu=function(){return s(this,Xe)&&"added"||s(this,Xe)===null&&this.guessedText&&"review"||"missing"},wp=async function(){var n,r,o;const t=s(this,Bn);if(!t)return;if(s(this,fs)){if(t.classList.toggle("done",!!s(this,Xe)),t.setAttribute("data-l10n-id",s(xi,Qr)[s(this,jn,Fu)]),(n=s(this,Vl))==null||n.setAttribute("data-l10n-id",s(xi,Qr)[`${s(this,jn,Fu)}-label`]),!s(this,Xe)){(r=s(this,ds))==null||r.remove();return}}else{if(!s(this,Xe)&&!s(this,hs)){t.classList.remove("done"),(o=s(this,ds))==null||o.remove();return}t.classList.add("done"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let e=s(this,ds);if(!e){g(this,ds,e=document.createElement("span")),e.className="tooltip",e.setAttribute("role","tooltip"),e.id=`alt-text-tooltip-${s(this,Li).id}`;const l=100,c=s(this,Li)._uiManager._signal;c.addEventListener("abort",()=>{clearTimeout(s(this,Zi)),g(this,Zi,null)},{once:!0}),t.addEventListener("mouseenter",()=>{g(this,Zi,setTimeout(()=>{g(this,Zi,null),s(this,ds).classList.add("show"),s(this,Li)._reportTelemetry({action:"alt_text_tooltip"})},l))},{signal:c}),t.addEventListener("mouseleave",()=>{var h;s(this,Zi)&&(clearTimeout(s(this,Zi)),g(this,Zi,null)),(h=s(this,ds))==null||h.classList.remove("show")},{signal:c})}s(this,hs)?e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(e.removeAttribute("data-l10n-id"),e.textContent=s(this,Xe)),e.parentNode||t.append(e);const i=s(this,Li).getElementForAltText();i==null||i.setAttribute("aria-describedby",e.id)},y(xi,Qr,null),W(xi,"_l10n",null);let wf=xi;class Af{constructor(t){y(this,td);y(this,ri,null);y(this,kn,null);y(this,Zo,!1);y(this,ce,null);y(this,Qh,null);y(this,Qo,null);y(this,zn,null);y(this,ta,null);y(this,ea,!1);y(this,ia,null);g(this,ce,t)}renderForToolbar(){const t=g(this,kn,document.createElement("button"));return t.className="comment",S(this,td,Gm).call(this,t,!1)}renderForStandalone(){const t=g(this,ri,document.createElement("button"));t.className="annotationCommentButton";const e=s(this,ce).commentButtonPosition;if(e){const{style:i}=t;i.insetInlineEnd=`calc(${100*(s(this,ce)._uiManager.direction==="ltr"?1-e[0]:e[0])}% - var(--comment-button-dim))`,i.top=`calc(${100*e[1]}% - var(--comment-button-dim))`;const n=s(this,ce).commentButtonColor;n&&(i.backgroundColor=n)}return S(this,td,Gm).call(this,t,!0)}focusButton(){setTimeout(()=>{var t;(t=s(this,ri)??s(this,kn))==null||t.focus()},0)}onUpdatedColor(){if(!s(this,ri))return;const t=s(this,ce).commentButtonColor;t&&(s(this,ri).style.backgroundColor=t),s(this,ce)._uiManager.updatePopupColor(s(this,ce))}get commentButtonWidth(){var t;return(((t=s(this,ri))==null?void 0:t.getBoundingClientRect().width)??0)/s(this,ce).parent.boundingClientRect.width}get commentPopupPositionInLayer(){if(s(this,ia))return s(this,ia);if(!s(this,ri))return null;const{x:t,y:e,height:i}=s(this,ri).getBoundingClientRect(),{x:n,y:r,width:o,height:l}=s(this,ce).parent.boundingClientRect;return[(t-n)/o,(e+i-r)/l]}set commentPopupPositionInLayer(t){g(this,ia,t)}hasDefaultPopupPosition(){return s(this,ia)===null}removeStandaloneCommentButton(){var t;(t=s(this,ri))==null||t.remove(),g(this,ri,null)}removeToolbarCommentButton(){var t;(t=s(this,kn))==null||t.remove(),g(this,kn,null)}setCommentButtonStates({selected:t,hasPopup:e}){s(this,ri)&&(s(this,ri).classList.toggle("selected",t),s(this,ri).ariaExpanded=e)}edit(t){const e=this.commentPopupPositionInLayer;let i,n;if(e)[i,n]=e;else{[i,n]=s(this,ce).commentButtonPosition;const{width:d,height:u,x:f,y:p}=s(this,ce);i=f+i*d,n=p+n*u}const r=s(this,ce).parent.boundingClientRect,{x:o,y:l,width:c,height:h}=r;s(this,ce)._uiManager.editComment(s(this,ce),o+i*c,l+n*h,{...t,parentDimensions:r})}finish(){s(this,kn)&&(s(this,kn).focus({focusVisible:s(this,Zo)}),g(this,Zo,!1))}isDeleted(){return s(this,ea)||s(this,zn)===""}isEmpty(){return s(this,zn)===null}hasBeenEdited(){return this.isDeleted()||s(this,zn)!==s(this,Qh)}serialize(){return this.data}get data(){return{text:s(this,zn),richText:s(this,Qo),date:s(this,ta),deleted:this.isDeleted()}}set data(t){if(t!==s(this,zn)&&g(this,Qo,null),t===null){g(this,zn,""),g(this,ea,!0);return}g(this,zn,t),g(this,ta,new Date),g(this,ea,!1)}setInitialText(t,e=null){g(this,Qh,t),this.data=t,g(this,ta,null),g(this,Qo,e)}shown(){}destroy(){var t,e;(t=s(this,kn))==null||t.remove(),g(this,kn,null),(e=s(this,ri))==null||e.remove(),g(this,ri,null),g(this,zn,""),g(this,Qo,null),g(this,ta,null),g(this,ce,null),g(this,Zo,!1),g(this,ea,!1)}}ri=new WeakMap,kn=new WeakMap,Zo=new WeakMap,ce=new WeakMap,Qh=new WeakMap,Qo=new WeakMap,zn=new WeakMap,ta=new WeakMap,ea=new WeakMap,ia=new WeakMap,td=new WeakSet,Gm=function(t,e){if(!s(this,ce)._uiManager.hasCommentManager())return null;t.tabIndex="0",t.ariaHasPopup="dialog",e?(t.ariaControls="commentPopup",t.setAttribute("data-l10n-id","pdfjs-show-comment-button")):(t.ariaControlsElements=[s(this,ce)._uiManager.getCommentDialogElement()],t.setAttribute("data-l10n-id","pdfjs-editor-add-comment-button"));const i=s(this,ce)._uiManager._signal;if(!(i instanceof AbortSignal)||i.aborted)return t;t.addEventListener("contextmenu",wn,{signal:i}),e&&(t.addEventListener("focusin",r=>{s(this,ce)._focusEventsAllowed=!1,Ee(r)},{capture:!0,signal:i}),t.addEventListener("focusout",r=>{s(this,ce)._focusEventsAllowed=!0,Ee(r)},{capture:!0,signal:i})),t.addEventListener("pointerdown",r=>r.stopPropagation(),{signal:i});const n=r=>{r.preventDefault(),t===s(this,kn)?this.edit():s(this,ce).toggleComment(!0)};return t.addEventListener("click",n,{capture:!0,signal:i}),t.addEventListener("keydown",r=>{r.target===t&&r.key==="Enter"&&(g(this,Zo,!0),n(r))},{signal:i}),t.addEventListener("pointerenter",()=>{s(this,ce).toggleComment(!1,!0)},{signal:i}),t.addEventListener("pointerleave",()=>{s(this,ce).toggleComment(!1,!1)},{signal:i}),t};const Tm=class Tm{constructor({container:t,isPinchingDisabled:e=null,isPinchingStopped:i=null,onPinchStart:n=null,onPinching:r=null,onPinchEnd:o=null,signal:l}){y(this,to);y(this,Yl);y(this,na,!1);y(this,ed,null);y(this,id);y(this,nd);y(this,sd);y(this,rd);y(this,$s,null);y(this,sa);y(this,Ws,null);y(this,ra);y(this,Vs,null);g(this,Yl,t),g(this,ed,i),g(this,id,e),g(this,nd,n),g(this,sd,r),g(this,rd,o),g(this,ra,new AbortController),g(this,sa,AbortSignal.any([l,s(this,ra).signal])),t.addEventListener("touchstart",S(this,to,jv).bind(this),{passive:!1,signal:s(this,sa)})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return 35/ns.pixelRatio}destroy(){var t,e;(t=s(this,ra))==null||t.abort(),g(this,ra,null),(e=s(this,$s))==null||e.abort(),g(this,$s,null)}};Yl=new WeakMap,na=new WeakMap,ed=new WeakMap,id=new WeakMap,nd=new WeakMap,sd=new WeakMap,rd=new WeakMap,$s=new WeakMap,sa=new WeakMap,Ws=new WeakMap,ra=new WeakMap,Vs=new WeakMap,to=new WeakSet,jv=function(t){var n,r,o;if((n=s(this,id))!=null&&n.call(this))return;if(t.touches.length===1){if(s(this,$s))return;const l=g(this,$s,new AbortController),c=AbortSignal.any([s(this,sa),l.signal]),h=s(this,Yl),d={capture:!0,signal:c,passive:!1},u=f=>{var p;f.pointerType==="touch"&&((p=s(this,$s))==null||p.abort(),g(this,$s,null))};h.addEventListener("pointerdown",f=>{f.pointerType==="touch"&&(Ee(f),u(f))},d),h.addEventListener("pointerup",u,d),h.addEventListener("pointercancel",u,d);return}if(!s(this,Vs)){g(this,Vs,new AbortController);const l=AbortSignal.any([s(this,sa),s(this,Vs).signal]),c=s(this,Yl),h={signal:l,capture:!1,passive:!1};c.addEventListener("touchmove",S(this,to,zv).bind(this),h);const d=S(this,to,Uv).bind(this);c.addEventListener("touchend",d,h),c.addEventListener("touchcancel",d,h),h.capture=!0,c.addEventListener("pointerdown",Ee,h),c.addEventListener("pointermove",Ee,h),c.addEventListener("pointercancel",Ee,h),c.addEventListener("pointerup",Ee,h),(r=s(this,nd))==null||r.call(this)}if(Ee(t),t.touches.length!==2||(o=s(this,ed))!=null&&o.call(this)){g(this,Ws,null);return}let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]),g(this,Ws,{touch0X:e.screenX,touch0Y:e.screenY,touch1X:i.screenX,touch1Y:i.screenY})},zv=function(t){var C;if(!s(this,Ws)||t.touches.length!==2)return;Ee(t);let[e,i]=t.touches;e.identifier>i.identifier&&([e,i]=[i,e]);const{screenX:n,screenY:r}=e,{screenX:o,screenY:l}=i,c=s(this,Ws),{touch0X:h,touch0Y:d,touch1X:u,touch1Y:f}=c,p=u-h,m=f-d,b=o-n,v=l-r,w=Math.hypot(b,v)||1,_=Math.hypot(p,m)||1;if(!s(this,na)&&Math.abs(_-w)<=Tm.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(c.touch0X=n,c.touch0Y=r,c.touch1X=o,c.touch1Y=l,!s(this,na)){g(this,na,!0);return}const A=[(n+o)/2,(r+l)/2];(C=s(this,sd))==null||C.call(this,A,_,w)},Uv=function(t){var e;t.touches.length>=2||(s(this,Vs)&&(s(this,Vs).abort(),g(this,Vs,null),(e=s(this,rd))==null||e.call(this)),s(this,Ws)&&(Ee(t),g(this,Ws,null),g(this,na,!1)))};let Sf=Tm;const bt=class bt{constructor(t){y(this,ht);y(this,oa,null);y(this,Un,null);y(this,ge,null);y(this,se,null);y(this,Gs,null);y(this,Xl,!1);y(this,eo,null);y(this,od,"");y(this,oi,null);y(this,aa,null);y(this,Ys,null);y(this,Mn,null);y(this,io,null);y(this,ad,"");y(this,la,!1);y(this,Qi,null);y(this,ld,!1);y(this,ca,!1);y(this,Xs,!1);y(this,ps,null);y(this,ql,0);y(this,Kl,0);y(this,Rn,null);y(this,ha,null);W(this,"isSelected",!1);W(this,"_isCopy",!1);W(this,"_editToolbar",null);W(this,"_initialOptions",Object.create(null));W(this,"_initialData",null);W(this,"_isVisible",!0);W(this,"_uiManager",null);W(this,"_focusEventsAllowed",!0);y(this,cd,!1);y(this,Yf,bt._zIndex++);this.parent=t.parent,this.id=t.id,this.width=this.height=null,this.pageIndex=t.parent.pageIndex,this.name=t.name,this.div=null,this._uiManager=t.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=t.isCentered,this._structTreeParentId=null,this.annotationElementId=t.annotationElementId||null,this.creationDate=t.creationDate||new Date,this.modificationDate=t.modificationDate||null,this.canAddComment=!0;const{rotation:e,rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=e,this.pageRotation=(360+e-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[i,n],this.pageTranslation=[r,o];const[l,c]=this.parentDimensions;this.x=t.x/l,this.y=t.y/c,this.isAttachedToDOM=!1,this.deleted=!1}static get _resizerKeyboardManager(){const t=bt.prototype._resizeWithKeyboard,e=Uo.TRANSLATE_SMALL,i=Uo.TRANSLATE_BIG;return gt(this,"_resizerKeyboardManager",new Ph([[["ArrowLeft","mac+ArrowLeft"],t,{args:[-e,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],t,{args:[-i,0]}],[["ArrowRight","mac+ArrowRight"],t,{args:[e,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],t,{args:[i,0]}],[["ArrowUp","mac+ArrowUp"],t,{args:[0,-e]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],t,{args:[0,-i]}],[["ArrowDown","mac+ArrowDown"],t,{args:[0,e]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],t,{args:[0,i]}],[["Escape","mac+Escape"],bt.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 gt(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(t){const e=new aE({id:t.parent.getNextId(),parent:t.parent,uiManager:t._uiManager});e.annotationElementId=t.annotationElementId,e.deleted=!0,e._uiManager.addToAnnotationStorage(e)}static initialize(t,e){if(bt._l10n??(bt._l10n=t),bt._l10nResizer||(bt._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"})),bt._borderLineWidth!==-1)return;const i=getComputedStyle(document.documentElement);bt._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(t,e){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(t){return!1}static paste(t,e){ne("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return s(this,cd)}set _isDraggable(t){var e;g(this,cd,t),(e=this.div)==null||e.classList.toggle("draggable",t)}get uid(){return this.annotationElementId||this.id}get isEnterHandled(){return!0}center(){const[t,e]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*e/(t*2),this.y+=this.width*t/(e*2);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*e/(t*2),this.y-=this.width*t/(e*2);break;default:this.x-=this.width/2,this.y-=this.height/2;break}this.fixAndSetPosition()}addCommands(t){this._uiManager.addCommands(t)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=s(this,Yf)}setParent(t){var e;t!==null?(this.pageIndex=t.pageIndex,this.pageDimensions=t.pageDimensions):(S(this,ht,Bu).call(this),(e=s(this,Mn))==null||e.remove(),g(this,Mn,null)),this.parent=t}focusin(t){this._focusEventsAllowed&&(s(this,la)?g(this,la,!1):this.parent.setSelected(this))}focusout(t){var i;if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;const e=t.relatedTarget;e!=null&&e.closest(`#${this.id}`)||(t.preventDefault(),(i=this.parent)!=null&&i.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.isInEditMode()&&this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(t,e,i,n){const[r,o]=this.parentDimensions;[i,n]=this.screenToPageTranslation(i,n),this.x=(t+i)/r,this.y=(e+n)/o,this.fixAndSetPosition()}_moveAfterPaste(t,e){const[i,n]=this.parentDimensions;this.setAt(t*i,e*n,this.width*i,this.height*n),this._onTranslated()}translate(t,e){S(this,ht,Ym).call(this,this.parentDimensions,t,e)}translateInPage(t,e){s(this,Qi)||g(this,Qi,[this.x,this.y,this.width,this.height]),S(this,ht,Ym).call(this,this.pageDimensions,t,e),this.div.scrollIntoView({block:"nearest"})}translationDone(){this._onTranslated(this.x,this.y)}drag(t,e){s(this,Qi)||g(this,Qi,[this.x,this.y,this.width,this.height]);const{div:i,parentDimensions:[n,r]}=this;if(this.x+=t/n,this.y+=e/r,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:u,y:f}=this.div.getBoundingClientRect();this.parent.findNewParent(this,u,f)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:l}=this;const[c,h]=this.getBaseTranslation();o+=c,l+=h;const{style:d}=i;d.left=`${(100*o).toFixed(2)}%`,d.top=`${(100*l).toFixed(2)}%`,this._onTranslating(o,l),i.scrollIntoView({block:"nearest"})}_onTranslating(t,e){}_onTranslated(t,e){}get _hasBeenMoved(){return!!s(this,Qi)&&(s(this,Qi)[0]!==this.x||s(this,Qi)[1]!==this.y)}get _hasBeenResized(){return!!s(this,Qi)&&(s(this,Qi)[2]!==this.width||s(this,Qi)[3]!==this.height)}getBaseTranslation(){const[t,e]=this.parentDimensions,{_borderLineWidth:i}=bt,n=i/t,r=i/e;switch(this.rotation){case 90:return[-n,r];case 180:return[n,r];case 270:return[n,-r];default:return[-n,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(t=this.rotation){const{div:{style:e},pageDimensions:[i,n]}=this;let{x:r,y:o,width:l,height:c}=this;if(l*=i,c*=n,r*=i,o*=n,this._mustFixPosition)switch(t){case 0:r=Ei(r,0,i-l),o=Ei(o,0,n-c);break;case 90:r=Ei(r,0,i-c),o=Ei(o,l,n);break;case 180:r=Ei(r,l,i),o=Ei(o,c,n);break;case 270:r=Ei(r,c,i),o=Ei(o,0,n-l);break}this.x=r/=i,this.y=o/=n;const[h,d]=this.getBaseTranslation();r+=h,o+=d,e.left=`${(100*r).toFixed(2)}%`,e.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}screenToPageTranslation(t,e){var i;return S(i=bt,hd,Xm).call(i,t,e,this.parentRotation)}pageTranslationToScreen(t,e){var i;return S(i=bt,hd,Xm).call(i,t,e,360-this.parentRotation)}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:t,pageDimensions:[e,i]}=this;return[e*t,i*t]}setDims(){const{div:{style:t},width:e,height:i}=this;t.width=`${(100*e).toFixed(2)}%`,t.height=`${(100*i).toFixed(2)}%`}getInitialTranslation(){return[0,0]}_onResized(){}static _round(t){return Math.round(t*1e4)/1e4}_onResizing(){}altTextFinish(){var t;(t=s(this,ge))==null||t.finish()}get toolbarButtons(){return null}async addEditToolbar(){if(this._editToolbar||s(this,ca))return this._editToolbar;this._editToolbar=new Wg(this),this.div.append(this._editToolbar.render());const{toolbarButtons:t}=this;if(t)for(const[e,i]of t)await this._editToolbar.addButton(e,i);return this.hasComment||this._editToolbar.addButton("comment",this.addCommentButton()),this._editToolbar.addButton("delete"),this._editToolbar}addCommentButtonInToolbar(){var t;(t=this._editToolbar)==null||t.addButtonBefore("comment",this.addCommentButton(),".deleteButton")}removeCommentButtonFromToolbar(){var t;(t=this._editToolbar)==null||t.removeButton("comment")}removeEditToolbar(){var t,e;(t=this._editToolbar)==null||t.remove(),this._editToolbar=null,(e=s(this,ge))==null||e.destroy()}addContainer(t){var i;const e=(i=this._editToolbar)==null?void 0:i.div;e?e.before(t):this.div.append(t)}getClientDimensions(){return this.div.getBoundingClientRect()}createAltText(){return s(this,ge)||(wf.initialize(bt._l10n),g(this,ge,new wf(this)),s(this,oa)&&(s(this,ge).data=s(this,oa),g(this,oa,null))),s(this,ge)}get altTextData(){var t;return(t=s(this,ge))==null?void 0:t.data}set altTextData(t){s(this,ge)&&(s(this,ge).data=t)}get guessedAltText(){var t;return(t=s(this,ge))==null?void 0:t.guessedText}async setGuessedAltText(t){var e;await((e=s(this,ge))==null?void 0:e.setGuessedText(t))}serializeAltText(t){var e;return(e=s(this,ge))==null?void 0:e.serialize(t)}hasAltText(){return!!s(this,ge)&&!s(this,ge).isEmpty()}hasAltTextData(){var t;return((t=s(this,ge))==null?void 0:t.hasData())??!1}focusCommentButton(){var t;(t=s(this,se))==null||t.focusButton()}addCommentButton(){return this.canAddComment?s(this,se)||g(this,se,new Af(this)):null}addStandaloneCommentButton(){if(this._uiManager.hasCommentManager()){if(s(this,Gs)){this._uiManager.isEditingMode()&&s(this,Gs).classList.remove("hidden");return}this.hasComment&&(g(this,Gs,s(this,se).renderForStandalone()),this.div.append(s(this,Gs)))}}removeStandaloneCommentButton(){s(this,se).removeStandaloneCommentButton(),g(this,Gs,null)}hideStandaloneCommentButton(){var t;(t=s(this,Gs))==null||t.classList.add("hidden")}get comment(){const{data:{richText:t,text:e,date:i,deleted:n}}=s(this,se);return{text:e,richText:t,date:i,deleted:n,color:this.getNonHCMColor(),opacity:this.opacity??1}}set comment(t){s(this,se)||g(this,se,new Af(this)),s(this,se).data=t,this.hasComment?(this.removeCommentButtonFromToolbar(),this.addStandaloneCommentButton(),this._uiManager.updateComment(this)):(this.addCommentButtonInToolbar(),this.removeStandaloneCommentButton(),this._uiManager.removeComment(this))}setCommentData({comment:t,popupRef:e,richText:i}){if(!e||(s(this,se)||g(this,se,new Af(this)),s(this,se).setInitialText(t,i),!this.annotationElementId))return;const n=this._uiManager.getAndRemoveDataFromAnnotationStorage(this.annotationElementId);n&&this.updateFromAnnotationLayer(n)}get hasEditedComment(){var t;return(t=s(this,se))==null?void 0:t.hasBeenEdited()}get hasDeletedComment(){var t;return(t=s(this,se))==null?void 0:t.isDeleted()}get hasComment(){return!!s(this,se)&&!s(this,se).isEmpty()&&!s(this,se).isDeleted()}async editComment(t){s(this,se)||g(this,se,new Af(this)),s(this,se).edit(t)}toggleComment(t,e=void 0){this.hasComment&&this._uiManager.toggleComment(this,t,e)}setSelectedCommentButton(t){s(this,se).setSelectedButton(t)}addComment(t){if(this.hasEditedComment){const[,,,n]=t.rect,[r]=this.pageDimensions,[o]=this.pageTranslation,l=o+r+1,c=n-100,h=l+180;t.popup={contents:this.comment.text,deleted:this.comment.deleted,rect:[l,c,h,n]}}}updateFromAnnotationLayer({popup:{contents:t,deleted:e}}){s(this,se).data=e?null:t}get parentBoundingClientRect(){return this.parent.boundingClientRect}render(){var o;const t=this.div=document.createElement("div");t.setAttribute("data-editor-rotation",(360-this.rotation)%360),t.className=this.name,t.setAttribute("id",this.id),t.tabIndex=s(this,Xl)?-1:0,t.setAttribute("role","application"),this.defaultL10nId&&t.setAttribute("data-l10n-id",this.defaultL10nId),this._isVisible||t.classList.add("hidden"),this.setInForeground(),S(this,ht,Zm).call(this);const[e,i]=this.parentDimensions;this.parentRotation%180!==0&&(t.style.maxWidth=`${(100*i/e).toFixed(2)}%`,t.style.maxHeight=`${(100*e/i).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),v0(this,t,["keydown","pointerdown","dblclick"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(s(this,ha)||g(this,ha,new Sf({container:t,isPinchingDisabled:()=>!this.isSelected,onPinchStart:S(this,ht,Wv).bind(this),onPinching:S(this,ht,Vv).bind(this),onPinchEnd:S(this,ht,Gv).bind(this),signal:this._uiManager._signal}))),this.addStandaloneCommentButton(),(o=this._uiManager._editorUndoBar)==null||o.hide(),t}pointerdown(t){const{isMac:e}=je.platform;if(t.button!==0||t.ctrlKey&&e){t.preventDefault();return}if(g(this,la,!0),this._isDraggable){S(this,ht,Yv).call(this,t);return}S(this,ht,Jm).call(this,t)}_onStartDragging(){}_onStopDragging(){}moveInDOM(){s(this,ps)&&clearTimeout(s(this,ps)),g(this,ps,setTimeout(()=>{var t;g(this,ps,null),(t=this.parent)==null||t.moveEditorInDOM(this)},0))}_setParentAndPosition(t,e,i){t.changeParent(this),this.x=e,this.y=i,this.fixAndSetPosition(),this._onTranslated()}getRect(t,e,i=this.rotation){const n=this.parentScale,[r,o]=this.pageDimensions,[l,c]=this.pageTranslation,h=t/n,d=e/n,u=this.x*r,f=this.y*o,p=this.width*r,m=this.height*o;switch(i){case 0:return[u+h+l,o-f-d-m+c,u+h+p+l,o-f-d+c];case 90:return[u+d+l,o-f+h+c,u+d+m+l,o-f+h+p+c];case 180:return[u-h-p+l,o-f+d+c,u-h+l,o-f+d+m+c];case 270:return[u-d-m+l,o-f-h-p+c,u-d+l,o-f-h+c];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(t,e){const[i,n,r,o]=t,l=r-i,c=o-n;switch(this.rotation){case 0:return[i,e-o,l,c];case 90:return[i,e-n,c,l];case 180:return[r,e-n,l,c];case 270:return[r,e-o,c,l];default:throw new Error("Invalid rotation")}}getPDFRect(){return this.getRect(0,0)}getNonHCMColor(){return this.color&&bt._colorManager.convert(this._uiManager.getNonHCMColor(this.color))}onUpdatedColor(){var t;(t=s(this,se))==null||t.onUpdatedColor()}getData(){const{comment:{text:t,color:e,date:i,opacity:n,deleted:r,richText:o},uid:l,pageIndex:c,creationDate:h,modificationDate:d}=this;return{id:l,pageIndex:c,rect:this.getPDFRect(),richText:o,contentsObj:{str:t},creationDate:h,modificationDate:i||d,popupRef:!r,color:e,opacity:n}}onceAdded(t){}isEmpty(){return!1}enableEditMode(){return this.isInEditMode()?!1:(this.parent.setEditingState(!1),g(this,ca,!0),!0)}disableEditMode(){return this.isInEditMode()?(this.parent.setEditingState(!0),g(this,ca,!1),!0):!1}isInEditMode(){return s(this,ca)}shouldGetKeyboardEvents(){return s(this,Xs)}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:t,left:e,bottom:i,right:n}=this.getClientDimensions(),{innerHeight:r,innerWidth:o}=window;return e<o&&n>0&&t<r&&i>0}rebuild(){S(this,ht,Zm).call(this)}rotate(t){}resize(){}serializeDeleted(){var t;return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:((t=this._initialData)==null?void 0:t.popupRef)||""}}serialize(t=!1,e=null){var i;return{annotationType:this.mode,pageIndex:this.pageIndex,rect:this.getPDFRect(),rotation:this.rotation,structTreeParentId:this._structTreeParentId,popupRef:((i=this._initialData)==null?void 0:i.popupRef)||""}}static async deserialize(t,e,i){const n=new this.prototype.constructor({parent:e,id:e.getNextId(),uiManager:i,annotationElementId:t.annotationElementId,creationDate:t.creationDate,modificationDate:t.modificationDate});n.rotation=t.rotation,g(n,oa,t.accessibilityData),n._isCopy=t.isCopy||!1;const[r,o]=n.pageDimensions,[l,c,h,d]=n.getRectInCurrentCoords(t.rect,o);return n.x=l/r,n.y=c/o,n.width=h/r,n.height=d/o,n}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||this.serialize()!==null)}remove(){var t,e,i;if((t=s(this,io))==null||t.abort(),g(this,io,null),this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.hideCommentPopup(),s(this,ps)&&(clearTimeout(s(this,ps)),g(this,ps,null)),S(this,ht,Bu).call(this),this.removeEditToolbar(),s(this,Rn)){for(const n of s(this,Rn).values())clearTimeout(n);g(this,Rn,null)}this.parent=null,(e=s(this,ha))==null||e.destroy(),g(this,ha,null),(i=s(this,Mn))==null||i.remove(),g(this,Mn,null)}get isResizable(){return!1}makeResizable(){this.isResizable&&(S(this,ht,Hv).call(this),s(this,oi).classList.remove("hidden"))}get toolbarPosition(){return null}get commentButtonPosition(){return this._uiManager.direction==="ltr"?[1,0]:[0,0]}get commentButtonPositionInPage(){const{commentButtonPosition:[t,e]}=this,[i,n,r,o]=this.getPDFRect();return[bt._round(i+(r-i)*t),bt._round(n+(o-n)*(1-e))]}get commentButtonColor(){return this._uiManager.makeCommentColor(this.getNonHCMColor(),this.opacity)}get commentPopupPosition(){return s(this,se).commentPopupPositionInLayer}set commentPopupPosition(t){s(this,se).commentPopupPositionInLayer=t}hasDefaultPopupPosition(){return s(this,se).hasDefaultPopupPosition()}get commentButtonWidth(){return s(this,se).commentButtonWidth}get elementBeforePopup(){return this.div}setCommentButtonStates(t){var e;(e=s(this,se))==null||e.setCommentButtonStates(t)}keydown(t){if(!this.isResizable||t.target!==this.div||t.key!=="Enter")return;this._uiManager.setSelected(this),g(this,Ys,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const e=s(this,oi).children;if(!s(this,Un)){g(this,Un,Array.from(e));const o=S(this,ht,Xv).bind(this),l=S(this,ht,qv).bind(this),c=this._uiManager._signal;for(const h of s(this,Un)){const d=h.getAttribute("data-resizer-name");h.setAttribute("role","spinbutton"),h.addEventListener("keydown",o,{signal:c}),h.addEventListener("blur",l,{signal:c}),h.addEventListener("focus",S(this,ht,Kv).bind(this,d),{signal:c}),h.setAttribute("data-l10n-id",bt._l10nResizer[d])}}const i=s(this,Un)[0];let n=0;for(const o of e){if(o===i)break;n++}const r=(360-this.rotation+this.parentRotation)%360/90*(s(this,Un).length/4);if(r!==n){if(r<n)for(let l=0;l<n-r;l++)s(this,oi).append(s(this,oi).firstElementChild);else if(r>n)for(let l=0;l<r-n;l++)s(this,oi).firstElementChild.before(s(this,oi).lastElementChild);let o=0;for(const l of e){const h=s(this,Un)[o++].getAttribute("data-resizer-name");l.setAttribute("data-l10n-id",bt._l10nResizer[h])}}S(this,ht,Qm).call(this,0),g(this,Xs,!0),s(this,oi).firstElementChild.focus({focusVisible:!0}),t.preventDefault(),t.stopImmediatePropagation()}_resizeWithKeyboard(t,e){s(this,Xs)&&S(this,ht,Km).call(this,s(this,ad),{deltaX:t,deltaY:e,fromKeyboard:!0})}_stopResizingWithKeyboard(){S(this,ht,Bu).call(this),this.div.focus()}select(){var t,e,i;if(this.isSelected&&this._editToolbar){this._editToolbar.show();return}if(this.isSelected=!0,this.makeResizable(),(t=this.div)==null||t.classList.add("selectedEditor"),!this._editToolbar){this.addEditToolbar().then(()=>{var n,r;(n=this.div)!=null&&n.classList.contains("selectedEditor")&&((r=this._editToolbar)==null||r.show())});return}(e=this._editToolbar)==null||e.show(),(i=s(this,ge))==null||i.toggleAltTextBadge(!1)}focus(){this.div&&!this.div.contains(document.activeElement)&&setTimeout(()=>{var t;return(t=this.div)==null?void 0:t.focus({preventScroll:!0})},0)}unselect(){var t,e,i,n,r;this.isSelected&&(this.isSelected=!1,(t=s(this,oi))==null||t.classList.add("hidden"),(e=this.div)==null||e.classList.remove("selectedEditor"),(i=this.div)!=null&&i.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),(n=this._editToolbar)==null||n.hide(),(r=s(this,ge))==null||r.toggleAltTextBadge(!0),this.hideCommentPopup())}hideCommentPopup(){this.hasComment&&this._uiManager.toggleComment(null)}updateParams(t,e){}disableEditing(){}enableEditing(){}get canChangeContent(){return!1}enterInEditMode(){this.canChangeContent&&(this.enableEditMode(),this.div.focus())}dblclick(t){t.target.nodeName!=="BUTTON"&&(this.enterInEditMode(),this.parent.updateToolbar({mode:this.constructor._editorType,editId:this.uid}))}getElementForAltText(){return this.div}get contentDiv(){return this.div}get isEditing(){return s(this,ld)}set isEditing(t){g(this,ld,t),this.parent&&(t?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(t,e=!1){if(e){s(this,Rn)||g(this,Rn,new Map);const{action:i}=t;let n=s(this,Rn).get(i);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(t),s(this,Rn).delete(i),s(this,Rn).size===0&&g(this,Rn,null)},bt._telemetryTimeout),s(this,Rn).set(i,n);return}t.type||(t.type=this.editorType),this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:t}})}show(t=this._isVisible){this.div.classList.toggle("hidden",!t),this._isVisible=t}enable(){this.div&&(this.div.tabIndex=0),g(this,Xl,!1)}disable(){this.div&&(this.div.tabIndex=-1),g(this,Xl,!0)}updateFakeAnnotationElement(t){if(!s(this,Mn)&&!this.deleted){g(this,Mn,t.addFakeAnnotation(this));return}if(this.deleted){s(this,Mn).remove(),g(this,Mn,null);return}(this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized)&&s(this,Mn).updateEdited({rect:this.getPDFRect(),popup:this.comment})}renderAnnotationElement(t){if(this.deleted)return t.hide(),null;let e=t.container.querySelector(".annotationContent");if(!e)e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),t.container.prepend(e);else if(e.nodeName==="CANVAS"){const i=e;e=document.createElement("div"),e.classList.add("annotationContent",this.editorType),i.before(e)}return e}resetAnnotationElement(t){const{firstElementChild:e}=t.container;(e==null?void 0:e.nodeName)==="DIV"&&e.classList.contains("annotationContent")&&e.remove()}};oa=new WeakMap,Un=new WeakMap,ge=new WeakMap,se=new WeakMap,Gs=new WeakMap,Xl=new WeakMap,eo=new WeakMap,od=new WeakMap,oi=new WeakMap,aa=new WeakMap,Ys=new WeakMap,Mn=new WeakMap,io=new WeakMap,ad=new WeakMap,la=new WeakMap,Qi=new WeakMap,ld=new WeakMap,ca=new WeakMap,Xs=new WeakMap,ps=new WeakMap,ql=new WeakMap,Kl=new WeakMap,Rn=new WeakMap,ha=new WeakMap,cd=new WeakMap,Yf=new WeakMap,ht=new WeakSet,Ym=function([t,e],i,n){[i,n]=this.screenToPageTranslation(i,n),this.x+=i/t,this.y+=n/e,this._onTranslating(this.x,this.y),this.fixAndSetPosition()},hd=new WeakSet,Xm=function(t,e,i){switch(i){case 90:return[e,-t];case 180:return[-t,-e];case 270:return[-e,t];default:return[t,e]}},Ap=function(t){switch(t){case 90:{const[e,i]=this.pageDimensions;return[0,-e/i,i/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,i]=this.pageDimensions;return[0,e/i,-i/e,0]}default:return[1,0,0,1]}},Hv=function(){if(s(this,oi))return;g(this,oi,document.createElement("div")),s(this,oi).classList.add("resizers");const t=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],e=this._uiManager._signal;for(const i of t){const n=document.createElement("div");s(this,oi).append(n),n.classList.add("resizer",i),n.setAttribute("data-resizer-name",i),n.addEventListener("pointerdown",S(this,ht,$v).bind(this,i),{signal:e}),n.addEventListener("contextmenu",wn,{signal:e}),n.tabIndex=-1}this.div.prepend(s(this,oi))},$v=function(t,e){var d;e.preventDefault();const{isMac:i}=je.platform;if(e.button!==0||e.ctrlKey&&i)return;(d=s(this,ge))==null||d.toggle(!1);const n=this._isDraggable;this._isDraggable=!1,g(this,aa,[e.screenX,e.screenY]);const r=new AbortController,o=this._uiManager.combinedSignal(r);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",S(this,ht,Km).bind(this,t),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",Ee,{passive:!1,signal:o}),window.addEventListener("contextmenu",wn,{signal:o}),g(this,Ys,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height});const l=this.parent.div.style.cursor,c=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(e.target).cursor;const h=()=>{var u;r.abort(),this.parent.togglePointerEvents(!0),(u=s(this,ge))==null||u.toggle(!0),this._isDraggable=n,this.parent.div.style.cursor=l,this.div.style.cursor=c,S(this,ht,Sp).call(this)};window.addEventListener("pointerup",h,{signal:o}),window.addEventListener("blur",h,{signal:o})},qm=function(t,e,i,n){this.width=i,this.height=n,this.x=t,this.y=e,this.setDims(),this.fixAndSetPosition(),this._onResized()},Sp=function(){if(!s(this,Ys))return;const{savedX:t,savedY:e,savedWidth:i,savedHeight:n}=s(this,Ys);g(this,Ys,null);const r=this.x,o=this.y,l=this.width,c=this.height;r===t&&o===e&&l===i&&c===n||this.addCommands({cmd:S(this,ht,qm).bind(this,r,o,l,c),undo:S(this,ht,qm).bind(this,t,e,i,n),mustExec:!0})},Km=function(t,e){const[i,n]=this.parentDimensions,r=this.x,o=this.y,l=this.width,c=this.height,h=bt.MIN_SIZE/i,d=bt.MIN_SIZE/n,u=S(this,ht,Ap).call(this,this.rotation),f=(tt,J)=>[u[0]*tt+u[2]*J,u[1]*tt+u[3]*J],p=S(this,ht,Ap).call(this,360-this.rotation),m=(tt,J)=>[p[0]*tt+p[2]*J,p[1]*tt+p[3]*J];let b,v,w=!1,_=!1;switch(t){case"topLeft":w=!0,b=(tt,J)=>[0,0],v=(tt,J)=>[tt,J];break;case"topMiddle":b=(tt,J)=>[tt/2,0],v=(tt,J)=>[tt/2,J];break;case"topRight":w=!0,b=(tt,J)=>[tt,0],v=(tt,J)=>[0,J];break;case"middleRight":_=!0,b=(tt,J)=>[tt,J/2],v=(tt,J)=>[0,J/2];break;case"bottomRight":w=!0,b=(tt,J)=>[tt,J],v=(tt,J)=>[0,0];break;case"bottomMiddle":b=(tt,J)=>[tt/2,J],v=(tt,J)=>[tt/2,0];break;case"bottomLeft":w=!0,b=(tt,J)=>[0,J],v=(tt,J)=>[tt,0];break;case"middleLeft":_=!0,b=(tt,J)=>[0,J/2],v=(tt,J)=>[tt,J/2];break}const A=b(l,c),C=v(l,c);let x=f(...C);const P=bt._round(r+x[0]),R=bt._round(o+x[1]);let N=1,z=1,H,I;if(e.fromKeyboard)({deltaX:H,deltaY:I}=e);else{const{screenX:tt,screenY:J}=e,[lt,It]=s(this,aa);[H,I]=this.screenToPageTranslation(tt-lt,J-It),s(this,aa)[0]=tt,s(this,aa)[1]=J}if([H,I]=m(H/i,I/n),w){const tt=Math.hypot(l,c);N=z=Math.max(Math.min(Math.hypot(C[0]-A[0]-H,C[1]-A[1]-I)/tt,1/l,1/c),h/l,d/c)}else _?N=Ei(Math.abs(C[0]-A[0]-H),h,1)/l:z=Ei(Math.abs(C[1]-A[1]-I),d,1)/c;const ct=bt._round(l*N),j=bt._round(c*z);x=f(...v(ct,j));const K=P-x[0],st=R-x[1];s(this,Qi)||g(this,Qi,[this.x,this.y,this.width,this.height]),this.width=ct,this.height=j,this.x=K,this.y=st,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Wv=function(){var t;g(this,Ys,{savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height}),(t=s(this,ge))==null||t.toggle(!1),this.parent.togglePointerEvents(!1)},Vv=function(t,e,i){let r=.7*(i/e)+1-.7;if(r===1)return;const o=S(this,ht,Ap).call(this,this.rotation),l=(P,R)=>[o[0]*P+o[2]*R,o[1]*P+o[3]*R],[c,h]=this.parentDimensions,d=this.x,u=this.y,f=this.width,p=this.height,m=bt.MIN_SIZE/c,b=bt.MIN_SIZE/h;r=Math.max(Math.min(r,1/f,1/p),m/f,b/p);const v=bt._round(f*r),w=bt._round(p*r);if(v===f&&w===p)return;s(this,Qi)||g(this,Qi,[d,u,f,p]);const _=l(f/2,p/2),A=bt._round(d+_[0]),C=bt._round(u+_[1]),x=l(v/2,w/2);this.x=A-x[0],this.y=C-x[1],this.width=v,this.height=w,this.setDims(),this.fixAndSetPosition(),this._onResizing()},Gv=function(){var t;(t=s(this,ge))==null||t.toggle(!0),this.parent.togglePointerEvents(!0),S(this,ht,Sp).call(this)},Jm=function(t){const{isMac:e}=je.platform;t.ctrlKey&&!e||t.shiftKey||t.metaKey&&e?this.parent.toggleSelected(this):this.parent.setSelected(this)},Yv=function(t){const{isSelected:e}=this;this._uiManager.setUpDragSession();let i=!1;const n=new AbortController,r=this._uiManager.combinedSignal(n),o={capture:!0,passive:!1,signal:r},l=h=>{n.abort(),g(this,eo,null),g(this,la,!1),this._uiManager.endDragSession()||S(this,ht,Jm).call(this,h),i&&this._onStopDragging()};e&&(g(this,ql,t.clientX),g(this,Kl,t.clientY),g(this,eo,t.pointerId),g(this,od,t.pointerType),window.addEventListener("pointermove",h=>{i||(i=!0,this._uiManager.toggleComment(this,!0,!1),this._onStartDragging());const{clientX:d,clientY:u,pointerId:f}=h;if(f!==s(this,eo)){Ee(h);return}const[p,m]=this.screenToPageTranslation(d-s(this,ql),u-s(this,Kl));g(this,ql,d),g(this,Kl,u),this._uiManager.dragSelectedEditors(p,m)},o),window.addEventListener("touchmove",Ee,o),window.addEventListener("pointerdown",h=>{h.pointerType===s(this,od)&&(s(this,ha)||h.isPrimary)&&l(h),Ee(h)},o));const c=h=>{if(!s(this,eo)||s(this,eo)===h.pointerId){l(h);return}Ee(h)};window.addEventListener("pointerup",c,{signal:r}),window.addEventListener("blur",c,{signal:r})},Zm=function(){if(s(this,io)||!this.div)return;g(this,io,new AbortController);const t=this._uiManager.combinedSignal(s(this,io));this.div.addEventListener("focusin",this.focusin.bind(this),{signal:t}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:t})},Xv=function(t){bt._resizerKeyboardManager.exec(this,t)},qv=function(t){var e;s(this,Xs)&&((e=t.relatedTarget)==null?void 0:e.parentNode)!==s(this,oi)&&S(this,ht,Bu).call(this)},Kv=function(t){g(this,ad,s(this,Xs)?t:"")},Qm=function(t){if(s(this,Un))for(const e of s(this,Un))e.tabIndex=t},Bu=function(){g(this,Xs,!1),S(this,ht,Qm).call(this,-1),S(this,ht,Sp).call(this)},y(bt,hd),W(bt,"_l10n",null),W(bt,"_l10nResizer",null),W(bt,"_borderLineWidth",-1),W(bt,"_colorManager",new Gg),W(bt,"_zIndex",1),W(bt,"_telemetryTimeout",1e3);let le=bt;class aE extends le{constructor(t){super(t),this.annotationElementId=t.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const w0=3285377520,An=4294901760,ss=65535;class A0{constructor(t){this.h1=t?t&4294967295:w0,this.h2=t?t&4294967295:w0}update(t){let e,i;if(typeof t=="string"){e=new Uint8Array(t.length*2),i=0;for(let b=0,v=t.length;b<v;b++){const w=t.charCodeAt(b);w<=255?e[i++]=w:(e[i++]=w>>>8,e[i++]=w&255)}}else if(ArrayBuffer.isView(t))e=t.slice(),i=e.byteLength;else throw new Error("Invalid data format, must be a string or TypedArray.");const n=i>>2,r=i-n*4,o=new Uint32Array(e.buffer,0,n);let l=0,c=0,h=this.h1,d=this.h2;const u=3432918353,f=461845907,p=u&ss,m=f&ss;for(let b=0;b<n;b++)b&1?(l=o[b],l=l*u&An|l*p&ss,l=l<<15|l>>>17,l=l*f&An|l*m&ss,h^=l,h=h<<13|h>>>19,h=h*5+3864292196):(c=o[b],c=c*u&An|c*p&ss,c=c<<15|c>>>17,c=c*f&An|c*m&ss,d^=c,d=d<<13|d>>>19,d=d*5+3864292196);switch(l=0,r){case 3:l^=e[n*4+2]<<16;case 2:l^=e[n*4+1]<<8;case 1:l^=e[n*4],l=l*u&An|l*p&ss,l=l<<15|l>>>17,l=l*f&An|l*m&ss,n&1?h^=l:d^=l}this.h1=h,this.h2=d}hexdigest(){let t=this.h1,e=this.h2;return t^=e>>>1,t=t*3981806797&An|t*36045&ss,e=e*4283543511&An|((e<<16|t>>>16)*2950163797&An)>>>16,t^=e>>>1,t=t*444984403&An|t*60499&ss,e=e*3301882366&An|((e<<16|t>>>16)*3120437893&An)>>>16,t^=e>>>1,(t>>>0).toString(16).padStart(8,"0")+(e>>>0).toString(16).padStart(8,"0")}}const Yg=Object.freeze({map:null,hash:"",transfer:void 0});class Xg{constructor(){y(this,Xf);y(this,da,!1);y(this,ua,null);y(this,qs,null);y(this,ai,new Map);this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(t,e){const i=s(this,ai).get(t);return i===void 0?e:Object.assign(e,i)}getRawValue(t){return s(this,ai).get(t)}remove(t){const e=s(this,ai).get(t);if(e!==void 0&&(e instanceof le&&s(this,qs).delete(e.annotationElementId),s(this,ai).delete(t),s(this,ai).size===0&&this.resetModified(),typeof this.onAnnotationEditor=="function")){for(const i of s(this,ai).values())if(i instanceof le)return;this.onAnnotationEditor(null)}}setValue(t,e){const i=s(this,ai).get(t);let n=!1;if(i!==void 0)for(const[r,o]of Object.entries(e))i[r]!==o&&(n=!0,i[r]=o);else n=!0,s(this,ai).set(t,e);n&&S(this,Xf,Jv).call(this),e instanceof le&&((s(this,qs)||g(this,qs,new Map)).set(e.annotationElementId,e),typeof this.onAnnotationEditor=="function"&&this.onAnnotationEditor(e.constructor._type))}has(t){return s(this,ai).has(t)}get size(){return s(this,ai).size}resetModified(){s(this,da)&&(g(this,da,!1),typeof this.onResetModified=="function"&&this.onResetModified())}get print(){return new S0(this)}get serializable(){if(s(this,ai).size===0)return Yg;const t=new Map,e=new A0,i=[],n=Object.create(null);let r=!1;for(const[o,l]of s(this,ai)){const c=l instanceof le?l.serialize(!1,n):l;c&&(t.set(o,c),e.update(`${o}:${JSON.stringify(c)}`),r||(r=!!c.bitmap))}if(r)for(const o of t.values())o.bitmap&&i.push(o.bitmap);return t.size>0?{map:t,hash:e.hexdigest(),transfer:i}:Yg}get editorStats(){let t=null;const e=new Map;let i=0,n=0;for(const r of s(this,ai).values()){if(!(r instanceof le)){r.popup&&(r.popup.deleted?n+=1:i+=1);continue}r.isCommentDeleted?n+=1:r.hasEditedComment&&(i+=1);const o=r.telemetryFinalData;if(!o)continue;const{type:l}=o;e.has(l)||e.set(l,Object.getPrototypeOf(r).constructor),t||(t=Object.create(null));const c=t[l]||(t[l]=new Map);for(const[h,d]of Object.entries(o)){if(h==="type")continue;let u=c.get(h);u||(u=new Map,c.set(h,u));const f=u.get(d)??0;u.set(d,f+1)}}if((n>0||i>0)&&(t||(t=Object.create(null)),t.comments={deleted:n,edited:i}),!t)return null;for(const[r,o]of e)t[r]=o.computeTelemetryFinalData(t[r]);return t}resetModifiedIds(){g(this,ua,null)}updateEditor(t,e){var n;const i=(n=s(this,qs))==null?void 0:n.get(t);return i?(i.updateFromAnnotationLayer(e),!0):!1}getEditor(t){var e;return((e=s(this,qs))==null?void 0:e.get(t))||null}get modifiedIds(){if(s(this,ua))return s(this,ua);const t=[];if(s(this,qs))for(const e of s(this,qs).values())e.serialize()&&t.push(e.annotationElementId);return g(this,ua,{ids:new Set(t),hash:t.join(",")})}[Symbol.iterator](){return s(this,ai).entries()}}da=new WeakMap,ua=new WeakMap,qs=new WeakMap,ai=new WeakMap,Xf=new WeakSet,Jv=function(){s(this,da)||(g(this,da,!0),typeof this.onSetModified=="function"&&this.onSetModified())};class S0 extends Xg{constructor(e){super();y(this,dd);const{map:i,hash:n,transfer:r}=e.serializable,o=structuredClone(i,r?{transfer:r}:null);g(this,dd,{map:o,hash:n,transfer:r})}get print(){ne("Should not call PrintAnnotationStorage.print")}get serializable(){return s(this,dd)}get modifiedIds(){return gt(this,"modifiedIds",{ids:new Set,hash:""})}}dd=new WeakMap;class lE{constructor({ownerDocument:t=globalThis.document,styleElement:e=null}){y(this,Jl,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(),s(this,Jl).clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:t,disableFontFace:e,_inspectFont:i}){if(!(!t||s(this,Jl).has(t.loadedName))){if(Mt(!e,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:o}=t,l=new FontFace(n,r,o);this.addNativeFontFace(l);try{await l.load(),s(this,Jl).add(n),i==null||i(t)}catch{pt(`Cannot load system font: ${t.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(l)}return}ne("Not implemented: loadSystemFont without the Font Loading API.")}}async bind(t){if(t.attached||t.missingFile&&!t.systemFontInfo)return;if(t.attached=!0,t.systemFontInfo){await this.loadSystemFont(t);return}if(this.isFontLoadingAPISupported){const i=t.createNativeFontFace();if(i){this.addNativeFontFace(i);try{await i.loaded}catch(n){throw pt(`Failed to load font '${i.family}': '${n}'.`),t.disableFontFace=!0,n}}return}const e=t.createFontFaceRule();if(e){if(this.insertRule(e),this.isSyncFontLoadingSupported)return;await new Promise(i=>{const n=this._queueLoadingCallback(i);this._prepareFontLoadEvent(t,n)})}}get isFontLoadingAPISupported(){var e;const t=!!((e=this._document)!=null&&e.fonts);return gt(this,"isFontLoadingAPISupported",t)}get isSyncFontLoadingSupported(){return gt(this,"isSyncFontLoadingSupported",Si||je.platform.isFirefox)}_queueLoadingCallback(t){function e(){for(Mt(!n.done,"completeRequest() cannot be called twice."),n.done=!0;i.length>0&&i[0].done;){const r=i.shift();setTimeout(r.callback,0)}}const{loadingRequests:i}=this,n={done:!1,complete:e,callback:t};return i.push(n),n}get _loadTestFont(){const t=atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA==");return gt(this,"_loadTestFont",t)}_prepareFontLoadEvent(t,e){function i(C,x){return C.charCodeAt(x)<<24|C.charCodeAt(x+1)<<16|C.charCodeAt(x+2)<<8|C.charCodeAt(x+3)&255}function n(C,x,P,R){const N=C.substring(0,x),z=C.substring(x+P);return N+R+z}let r,o;const l=this._document.createElement("canvas");l.width=1,l.height=1;const c=l.getContext("2d");let h=0;function d(C,x){if(++h>30){pt("Load test font never loaded."),x();return}if(c.font="30px "+C,c.fillText(".",0,20),c.getImageData(0,0,1,1).data[3]>0){x();return}setTimeout(d.bind(null,C,x))}const u=`lt${Date.now()}${this.loadTestFontId++}`;let f=this._loadTestFont;f=n(f,976,u.length,u);const m=16,b=1482184792;let v=i(f,m);for(r=0,o=u.length-3;r<o;r+=4)v=v-b+i(u,r)|0;r<u.length&&(v=v-b+i(u+"XXX",r)|0),f=n(f,m,4,HS(v));const w=`url(data:font/opentype;base64,${btoa(f)});`,_=`@font-face {font-family:"${u}";src:${w}}`;this.insertRule(_);const A=this._document.createElement("div");A.style.visibility="hidden",A.style.width=A.style.height="10px",A.style.position="absolute",A.style.top=A.style.left="0px";for(const C of[t.loadedName,u]){const x=this._document.createElement("span");x.textContent="Hi",x.style.fontFamily=C,A.append(x)}this._document.body.append(A),d(u,()=>{A.remove(),e.complete()})}}Jl=new WeakMap;class cE{constructor(t,e=null,i,n){y(this,Kt);this.compiledGlyphs=Object.create(null),g(this,Kt,t),this._inspectFont=e,i&&Object.assign(this,i),n&&(this.charProcOperatorList=n)}createNativeFontFace(){var e;if(!this.data||this.disableFontFace)return null;let t;if(!this.cssFontInfo)t=new FontFace(this.loadedName,this.data,{});else{const i={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(i.style=`oblique ${this.cssFontInfo.italicAngle}deg`),t=new FontFace(this.cssFontInfo.fontFamily,this.data,i)}return(e=this._inspectFont)==null||e.call(this,this),t}createFontFaceRule(){var i;if(!this.data||this.disableFontFace)return null;const t=`url(data:${this.mimetype};base64,${h0(this.data)});`;let e;if(!this.cssFontInfo)e=`@font-face {font-family:"${this.loadedName}";src:${t}}`;else{let n=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(n+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${n}src:${t}}`}return(i=this._inspectFont)==null||i.call(this,this,t),e}getPathGenerator(t,e){if(this.compiledGlyphs[e]!==void 0)return this.compiledGlyphs[e];const i=this.loadedName+"_path_"+e;let n;try{n=t.get(i)}catch(o){pt(`getPathGenerator - ignoring character: "${o}".`)}const r=y0(n==null?void 0:n.path);return this.fontExtraProperties||t.delete(i),this.compiledGlyphs[e]=r}get black(){return s(this,Kt).black}get bold(){return s(this,Kt).bold}get disableFontFace(){return s(this,Kt).disableFontFace??!1}set disableFontFace(t){gt(this,"disableFontFace",!!t)}get fontExtraProperties(){return s(this,Kt).fontExtraProperties??!1}get isInvalidPDFjsFont(){return s(this,Kt).isInvalidPDFjsFont}get isType3Font(){return s(this,Kt).isType3Font}get italic(){return s(this,Kt).italic}get missingFile(){return s(this,Kt).missingFile}get remeasure(){return s(this,Kt).remeasure}get vertical(){return s(this,Kt).vertical}get ascent(){return s(this,Kt).ascent}get defaultWidth(){return s(this,Kt).defaultWidth}get descent(){return s(this,Kt).descent}get bbox(){return s(this,Kt).bbox}set bbox(t){gt(this,"bbox",t)}get fontMatrix(){return s(this,Kt).fontMatrix}get fallbackName(){return s(this,Kt).fallbackName}get loadedName(){return s(this,Kt).loadedName}get mimetype(){return s(this,Kt).mimetype}get name(){return s(this,Kt).name}get data(){return s(this,Kt).data}clearData(){s(this,Kt).clearData()}get cssFontInfo(){return s(this,Kt).cssFontInfo}get systemFontInfo(){return s(this,Kt).systemFontInfo}get defaultVMetrics(){return s(this,Kt).defaultVMetrics}}Kt=new WeakMap;const ec=class ec{constructor(t){y(this,tc);y(this,Zl);y(this,Ql);y(this,ud);g(this,Zl,t),g(this,Ql,new DataView(s(this,Zl))),g(this,ud,new TextDecoder)}static write(t){const e=new TextEncoder,i={};let n=0;for(const h of ec.strings){const d=e.encode(t[h]);i[h]=d,n+=4+d.length}const r=new ArrayBuffer(n),o=new Uint8Array(r),l=new DataView(r);let c=0;for(const h of ec.strings){const d=i[h],u=d.length;l.setUint32(c,u),o.set(d,c+4),c+=4+u}return Mt(c===r.byteLength,"CssFontInfo.write: Buffer overflow"),r}get fontFamily(){return S(this,tc,Ep).call(this,0)}get fontWeight(){return S(this,tc,Ep).call(this,1)}get italicAngle(){return S(this,tc,Ep).call(this,2)}};Zl=new WeakMap,Ql=new WeakMap,ud=new WeakMap,tc=new WeakSet,Ep=function(t){Mt(t<ec.strings.length,"Invalid string index");let e=0;for(let n=0;n<t;n++)e+=s(this,Ql).getUint32(e)+4;const i=s(this,Ql).getUint32(e);return s(this,ud).decode(new Uint8Array(s(this,Zl),e+4,i))},W(ec,"strings",["fontFamily","fontWeight","italicAngle"]);let Ef=ec;const ic=class ic{constructor(t){y(this,pa);y(this,no);y(this,gs);y(this,fa);g(this,no,t),g(this,gs,new DataView(s(this,no))),g(this,fa,new TextDecoder)}static write(t){const e=new TextEncoder,i={};let n=0;for(const f of ic.strings){const p=e.encode(t[f]);i[f]=p,n+=4+p.length}n+=4;let r,o,l=1+n;t.style&&(r=e.encode(t.style.style),o=e.encode(t.style.weight),l+=4+r.length+4+o.length);const c=new ArrayBuffer(l),h=new Uint8Array(c),d=new DataView(c);let u=0;d.setUint8(u++,t.guessFallback?1:0),d.setUint32(u,0),u+=4,n=0;for(const f of ic.strings){const p=i[f],m=p.length;n+=4+m,d.setUint32(u,m),h.set(p,u+4),u+=4+m}return d.setUint32(u-n-4,n),t.style&&(d.setUint32(u,r.length),h.set(r,u+4),u+=4+r.length,d.setUint32(u,o.length),h.set(o,u+4),u+=4+o.length),Mt(u<=c.byteLength,"SubstitionInfo.write: Buffer overflow"),c.transferToFixedLength(u)}get guessFallback(){return s(this,gs).getUint8(0)!==0}get css(){return S(this,pa,ju).call(this,0)}get loadedName(){return S(this,pa,ju).call(this,1)}get baseFontName(){return S(this,pa,ju).call(this,2)}get src(){return S(this,pa,ju).call(this,3)}get style(){let t=1;t+=4+s(this,gs).getUint32(t);const e=s(this,gs).getUint32(t),i=s(this,fa).decode(new Uint8Array(s(this,no),t+4,e));t+=4+e;const n=s(this,gs).getUint32(t),r=s(this,fa).decode(new Uint8Array(s(this,no),t+4,n));return{style:i,weight:r}}};no=new WeakMap,gs=new WeakMap,fa=new WeakMap,pa=new WeakSet,ju=function(t){Mt(t<ic.strings.length,"Invalid string index");let e=5;for(let n=0;n<t;n++)e+=s(this,gs).getUint32(e)+4;const i=s(this,gs).getUint32(e);return s(this,fa).decode(new Uint8Array(s(this,no),e+4,i))},W(ic,"strings",["css","loadedName","baseFontName","src"]);let xf=ic;const yt=class yt{constructor({data:t,extra:e}){y(this,Ce);y(this,ms);y(this,fd);y(this,Jt);g(this,ms,t),g(this,fd,new TextDecoder),g(this,Jt,new DataView(s(this,ms))),e&&Object.assign(this,e)}get black(){return S(this,Ce,ts).call(this,0)}get bold(){return S(this,Ce,ts).call(this,1)}get disableFontFace(){return S(this,Ce,ts).call(this,2)}get fontExtraProperties(){return S(this,Ce,ts).call(this,3)}get isInvalidPDFjsFont(){return S(this,Ce,ts).call(this,4)}get isType3Font(){return S(this,Ce,ts).call(this,5)}get italic(){return S(this,Ce,ts).call(this,6)}get missingFile(){return S(this,Ce,ts).call(this,7)}get remeasure(){return S(this,Ce,ts).call(this,8)}get vertical(){return S(this,Ce,ts).call(this,9)}get ascent(){return S(this,Ce,xp).call(this,0)}get defaultWidth(){return S(this,Ce,xp).call(this,1)}get descent(){return S(this,Ce,xp).call(this,2)}get bbox(){let t=s(yt,sc);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<4;n++)i.push(s(this,Jt).getInt16(t,!0)),t+=2;return i}get fontMatrix(){let t=s(yt,rc);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<6;n++)i.push(s(this,Jt).getFloat64(t,!0)),t+=8;return i}get defaultVMetrics(){let t=s(yt,oc);if(s(this,Jt).getUint8(t)===0)return;t+=1;const i=[];for(let n=0;n<3;n++)i.push(s(this,Jt).getInt16(t,!0)),t+=2;return i}get fallbackName(){return S(this,Ce,zu).call(this,0)}get loadedName(){return S(this,Ce,zu).call(this,1)}get mimetype(){return S(this,Ce,zu).call(this,2)}get name(){return S(this,Ce,zu).call(this,3)}get data(){let t=s(yt,tn);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);t+=4+n;const r=s(this,Jt).getUint32(t);if(r!==0)return new Uint8Array(s(this,ms),t+4,r)}clearData(){let t=s(yt,tn);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);t+=4+n;const r=s(this,Jt).getUint32(t);new Uint8Array(s(this,ms),t+4,r).fill(0),s(this,Jt).setUint32(t,0)}get cssFontInfo(){let t=s(yt,tn);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);t+=4+i;const n=s(this,Jt).getUint32(t);if(n===0)return null;const r=new Uint8Array(n);return r.set(new Uint8Array(s(this,ms),t+4,n)),new Ef(r.buffer)}get systemFontInfo(){let t=s(yt,tn);const e=s(this,Jt).getUint32(t);t+=4+e;const i=s(this,Jt).getUint32(t);if(i===0)return null;const n=new Uint8Array(i);return n.set(new Uint8Array(s(this,ms),t+4,i)),new xf(n.buffer)}static write(t){const e=t.systemFontInfo?xf.write(t.systemFontInfo):null,i=t.cssFontInfo?Ef.write(t.cssFontInfo):null,n=new TextEncoder,r={};let o=0;for(const b of yt.strings)r[b]=n.encode(t[b]),o+=4+r[b].length;const l=s(yt,tn)+4+o+4+(e?e.byteLength:0)+4+(i?i.byteLength:0)+4+(t.data?t.data.length:0),c=new ArrayBuffer(l),h=new Uint8Array(c),d=new DataView(c);let u=0;const f=yt.bools.length;let p=0,m=0;for(let b=0;b<f;b++){const v=t[yt.bools[b]];p|=(v===void 0?0:v?2:1)<<m,m+=2,(m===8||b===f-1)&&(d.setUint8(u++,p),p=0,m=0)}Mt(u===s(yt,nc),"FontInfo.write: Boolean properties offset mismatch");for(const b of yt.numbers)d.setFloat64(u,t[b]),u+=8;if(Mt(u===s(yt,sc),"FontInfo.write: Number properties offset mismatch"),t.bbox){d.setUint8(u++,4);for(const b of t.bbox)d.setInt16(u,b,!0),u+=2}else d.setUint8(u++,0),u+=8;if(Mt(u===s(yt,rc),"FontInfo.write: BBox properties offset mismatch"),t.fontMatrix){d.setUint8(u++,6);for(const b of t.fontMatrix)d.setFloat64(u,b,!0),u+=8}else d.setUint8(u++,0),u+=48;if(Mt(u===s(yt,oc),"FontInfo.write: FontMatrix properties offset mismatch"),t.defaultVMetrics){d.setUint8(u++,1);for(const b of t.defaultVMetrics)d.setInt16(u,b,!0),u+=2}else d.setUint8(u++,0),u+=6;Mt(u===s(yt,tn),"FontInfo.write: DefaultVMetrics properties offset mismatch"),d.setUint32(s(yt,tn),0),u+=4;for(const b of yt.strings){const v=r[b],w=v.length;d.setUint32(u,w),h.set(v,u+4),u+=4+w}if(d.setUint32(s(yt,tn),u-s(yt,tn)-4),!e)d.setUint32(u,0),u+=4;else{const b=e.byteLength;d.setUint32(u,b),Mt(u+4+b<=c.byteLength,"FontInfo.write: Buffer overflow at systemFontInfo"),h.set(new Uint8Array(e),u+4),u+=4+b}if(!i)d.setUint32(u,0),u+=4;else{const b=i.byteLength;d.setUint32(u,b),Mt(u+4+b<=c.byteLength,"FontInfo.write: Buffer overflow at cssFontInfo"),h.set(new Uint8Array(i),u+4),u+=4+b}return t.data===void 0?(d.setUint32(u,0),u+=4):(d.setUint32(u,t.data.length),h.set(t.data,u+4),u+=4+t.data.length),Mt(u<=c.byteLength,"FontInfo.write: Buffer overflow"),c.transferToFixedLength(u)}};nc=new WeakMap,sc=new WeakMap,rc=new WeakMap,oc=new WeakMap,tn=new WeakMap,ms=new WeakMap,fd=new WeakMap,Jt=new WeakMap,Ce=new WeakSet,ts=function(t){Mt(t<yt.bools.length,"Invalid boolean index");const e=Math.floor(t/4),i=t*2%8,n=s(this,Jt).getUint8(e)>>i&3;return n===0?void 0:n===2},xp=function(t){return Mt(t<yt.numbers.length,"Invalid number index"),s(this,Jt).getFloat64(s(yt,nc)+t*8)},zu=function(t){Mt(t<yt.strings.length,"Invalid string index");let e=s(yt,tn)+4;for(let r=0;r<t;r++)e+=s(this,Jt).getUint32(e)+4;const i=s(this,Jt).getUint32(e),n=new Uint8Array(i);return n.set(new Uint8Array(s(this,ms),e+4,i)),s(this,fd).decode(n)},W(yt,"bools",["black","bold","disableFontFace","fontExtraProperties","isInvalidPDFjsFont","isType3Font","italic","missingFile","remeasure","vertical"]),W(yt,"numbers",["ascent","defaultWidth","descent"]),W(yt,"strings",["fallbackName","loadedName","mimetype","name"]),y(yt,nc,Math.ceil(yt.bools.length*2/8)),y(yt,sc,s(yt,nc)+yt.numbers.length*8),y(yt,rc,s(yt,sc)+1+8),y(yt,oc,s(yt,rc)+1+48),y(yt,tn,s(yt,oc)+1+6);let qg=yt;const he=class he{constructor(t){this.buffer=t,this.view=new DataView(t),this.data=new Uint8Array(t)}static write(t){let e,i=null,n=[],r=[],o=[],l=[],c=null,h=null;switch(t[0]){case"RadialAxial":e=t[1]==="axial"?1:2,i=t[2],o=t[3],e===1?n.push(...t[4],...t[5]):n.push(t[4][0],t[4][1],t[6],t[5][0],t[5][1],t[7]);break;case"Mesh":e=3,c=t[1],n=t[2],r=t[3],l=t[4]||[],i=t[6],h=t[7];break;default:throw new Error(`Unsupported pattern type: ${t[0]}`)}const d=Math.floor(n.length/2),u=Math.floor(r.length/3),f=o.length,p=l.length;let m=0;for(const x of l)m+=1,m=Math.ceil(m/4)*4,m+=4+x.coords.length*4,m+=4+x.colors.length*4,x.verticesPerRow!==void 0&&(m+=4);const b=20+d*8+u*3+f*8+(i?16:0)+(h?3:0)+m,v=new ArrayBuffer(b),w=new DataView(v),_=new Uint8Array(v);w.setUint8(s(he,pd),e),w.setUint8(s(he,gd),i?1:0),w.setUint8(s(he,md),h?1:0),w.setUint8(s(he,bd),c),w.setUint32(s(he,yd),d,!0),w.setUint32(s(he,vd),u,!0),w.setUint32(s(he,wd),f,!0),w.setUint32(s(he,Ad),p,!0);let A=20;new Float32Array(v,A,d*2).set(n),A+=d*8,_.set(r,A),A+=u*3;for(const[x,P]of o)w.setFloat32(A,x,!0),A+=4,w.setUint32(A,parseInt(P.slice(1),16),!0),A+=4;if(i)for(const x of i)w.setFloat32(A,x,!0),A+=4;h&&(_.set(h,A),A+=3);for(let x=0;x<l.length;x++){const P=l[x];w.setUint8(A,P.type),A+=1,A=Math.ceil(A/4)*4,w.setUint32(A,P.coords.length,!0),A+=4,new Int32Array(v,A,P.coords.length).set(P.coords),A+=P.coords.length*4,w.setUint32(A,P.colors.length,!0),A+=4,new Int32Array(v,A,P.colors.length).set(P.colors),A+=P.colors.length*4,P.verticesPerRow!==void 0&&(w.setUint32(A,P.verticesPerRow,!0),A+=4)}return v}getIR(){const t=this.view,e=this.data[s(he,pd)],i=!!this.data[s(he,gd)],n=!!this.data[s(he,md)],r=t.getUint32(s(he,yd),!0),o=t.getUint32(s(he,vd),!0),l=t.getUint32(s(he,wd),!0),c=t.getUint32(s(he,Ad),!0);let h=20;const d=new Float32Array(this.buffer,h,r*2);h+=r*8;const u=new Uint8Array(this.buffer,h,o*3);h+=o*3;const f=[];for(let v=0;v<l;++v){const w=t.getFloat32(h,!0);h+=4;const _=t.getUint32(h,!0);h+=4,f.push([w,`#${_.toString(16).padStart(6,"0")}`])}let p=null;if(i){p=[];for(let v=0;v<4;++v)p.push(t.getFloat32(h,!0)),h+=4}let m=null;n&&(m=new Uint8Array(this.buffer,h,3),h+=3);const b=[];for(let v=0;v<c;++v){const w=t.getUint8(h);h+=1,h=Math.ceil(h/4)*4;const _=t.getUint32(h,!0);h+=4;const A=new Int32Array(this.buffer,h,_);h+=_*4;const C=t.getUint32(h,!0);h+=4;const x=new Int32Array(this.buffer,h,C);h+=C*4;const P={type:w,coords:A,colors:x};w===Lg.LATTICE&&(P.verticesPerRow=t.getUint32(h,!0),h+=4),b.push(P)}if(e===1)return["RadialAxial","axial",p,f,Array.from(d.slice(0,2)),Array.from(d.slice(2,4)),null,null];if(e===2)return["RadialAxial","radial",p,f,[d[0],d[1]],[d[3],d[4]],d[2],d[5]];if(e===3){const v=this.data[s(he,bd)];let w=null;if(d.length>0){let _=d[0],A=d[0],C=d[1],x=d[1];for(let P=0;P<d.length;P+=2){const R=d[P],N=d[P+1];_=_>R?R:_,C=C>N?N:C,A=A<R?R:A,x=x<N?N:x}w=[_,C,A,x]}return["Mesh",v,d,u,b,w,p,m]}throw new Error(`Unsupported pattern kind: ${e}`)}};pd=new WeakMap,gd=new WeakMap,md=new WeakMap,bd=new WeakMap,yd=new WeakMap,vd=new WeakMap,wd=new WeakMap,Ad=new WeakMap,y(he,pd,0),y(he,gd,1),y(he,md,2),y(he,bd,3),y(he,yd,4),y(he,vd,8),y(he,wd,12),y(he,Ad,16);let Kg=he;class hE{constructor(t){y(this,ac);g(this,ac,t)}static write(t){let e,i;return je.isFloat16ArraySupported?(i=new ArrayBuffer(t.length*2),e=new Float16Array(i)):(i=new ArrayBuffer(t.length*4),e=new Float32Array(i)),e.set(t),i}get path(){return je.isFloat16ArraySupported?new Float16Array(s(this,ac)):new Float32Array(s(this,ac))}}ac=new WeakMap;function dE(a){if(a instanceof URL)return a.href;if(typeof a=="string"){if(Si)return a;const t=URL.parse(a,window.location);if(t)return t.href}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}function uE(a){if(Si&&typeof Buffer<"u"&&a instanceof Buffer)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength)return a;if(typeof a=="string")return Sh(a);if(a instanceof ArrayBuffer||ArrayBuffer.isView(a)||typeof a=="object"&&!isNaN(a==null?void 0:a.length))return new Uint8Array(a);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}function Cf(a){if(typeof a!="string")return null;if(a.endsWith("/"))return a;throw new Error(`Invalid factory url: "${a}" must include trailing slash.`)}const Jg=a=>typeof a=="object"&&Number.isInteger(a==null?void 0:a.num)&&a.num>=0&&Number.isInteger(a==null?void 0:a.gen)&&a.gen>=0,fE=a=>typeof a=="object"&&typeof(a==null?void 0:a.name)=="string",pE=YS.bind(null,Jg,fE);class gE{constructor(){y(this,Ks,new Map);y(this,qf,Promise.resolve())}postMessage(t,e){const i={data:structuredClone(t,e?{transfer:e}:null)};s(this,qf).then(()=>{for(const[n]of s(this,Ks))n.call(this,i)})}addEventListener(t,e,i=null){let n=null;if((i==null?void 0:i.signal)instanceof AbortSignal){const{signal:r}=i;if(r.aborted){pt("LoopbackPort - cannot use an `aborted` signal.");return}const o=()=>this.removeEventListener(t,e);n=()=>r.removeEventListener("abort",o),r.addEventListener("abort",o)}s(this,Ks).set(e,n)}removeEventListener(t,e){const i=s(this,Ks).get(e);i==null||i(),s(this,Ks).delete(e)}terminate(){for(const[,t]of s(this,Ks))t==null||t();s(this,Ks).clear()}}Ks=new WeakMap,qf=new WeakMap;const _f={DATA:1,ERROR:2},Ie={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function E0(){}function Oi(a){if(a instanceof Nr||a instanceof Fg||a instanceof o0||a instanceof bf||a instanceof Ng)return a;switch(a instanceof Error||typeof a=="object"&&a!==null||ne('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),a.name){case"AbortException":return new Nr(a.message);case"InvalidPDFException":return new Fg(a.message);case"PasswordException":return new o0(a.message,a.code);case"ResponseException":return new bf(a.message,a.status,a.missing);case"UnknownErrorException":return new Ng(a.message,a.details)}return new Ng(a.message,a.toString())}class kh{constructor(t,e,i){y(this,Dn);y(this,lc,new AbortController);this.sourceName=t,this.targetName=e,this.comObj=i,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),i.addEventListener("message",S(this,Dn,Zv).bind(this),{signal:s(this,lc).signal})}on(t,e){const i=this.actionHandler;if(i[t])throw new Error(`There is already an actionName called "${t}"`);i[t]=e}send(t,e,i){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,data:e},i)}sendWithPromise(t,e,i){const n=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[n]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:t,callbackId:n,data:e},i)}catch(o){r.reject(o)}return r.promise}sendWithStream(t,e,i,n){const r=this.streamId++,o=this.sourceName,l=this.targetName,c=this.comObj;return new ReadableStream({start:h=>{const d=Promise.withResolvers();return this.streamControllers[r]={controller:h,startCall:d,pullCall:null,cancelCall:null,isClosed:!1},c.postMessage({sourceName:o,targetName:l,action:t,streamId:r,data:e,desiredSize:h.desiredSize},n),d.promise},pull:h=>{const d=Promise.withResolvers();return this.streamControllers[r].pullCall=d,c.postMessage({sourceName:o,targetName:l,stream:Ie.PULL,streamId:r,desiredSize:h.desiredSize}),d.promise},cancel:h=>{Mt(h instanceof Error,"cancel must have a valid reason");const d=Promise.withResolvers();return this.streamControllers[r].cancelCall=d,this.streamControllers[r].isClosed=!0,c.postMessage({sourceName:o,targetName:l,stream:Ie.CANCEL,streamId:r,reason:Oi(h)}),d.promise}},i)}destroy(){var t;(t=s(this,lc))==null||t.abort(),g(this,lc,null)}}lc=new WeakMap,Dn=new WeakSet,Zv=function({data:t}){if(t.targetName!==this.sourceName)return;if(t.stream){S(this,Dn,tw).call(this,t);return}if(t.callback){const i=t.callbackId,n=this.callbackCapabilities[i];if(!n)throw new Error(`Cannot resolve callback ${i}`);if(delete this.callbackCapabilities[i],t.callback===_f.DATA)n.resolve(t.data);else if(t.callback===_f.ERROR)n.reject(Oi(t.reason));else throw new Error("Unexpected callback case");return}const e=this.actionHandler[t.action];if(!e)throw new Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){const i=this.sourceName,n=t.sourceName,r=this.comObj;Promise.try(e,t.data).then(function(o){r.postMessage({sourceName:i,targetName:n,callback:_f.DATA,callbackId:t.callbackId,data:o})},function(o){r.postMessage({sourceName:i,targetName:n,callback:_f.ERROR,callbackId:t.callbackId,reason:Oi(o)})});return}if(t.streamId){S(this,Dn,Qv).call(this,t);return}e(t.data)},Qv=function(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,r=this.comObj,o=this,l=this.actionHandler[t.action],c={enqueue(h,d=1,u){if(this.isCancelled)return;const f=this.desiredSize;this.desiredSize-=d,f>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:i,targetName:n,stream:Ie.ENQUEUE,streamId:e,chunk:h},u)},close(){this.isCancelled||(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:n,stream:Ie.CLOSE,streamId:e}),delete o.streamSinks[e])},error(h){Mt(h instanceof Error,"error must have a valid reason"),!this.isCancelled&&(this.isCancelled=!0,r.postMessage({sourceName:i,targetName:n,stream:Ie.ERROR,streamId:e,reason:Oi(h)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:t.desiredSize,ready:null};c.sinkCapability.resolve(),c.ready=c.sinkCapability.promise,this.streamSinks[e]=c,Promise.try(l,t.data,c).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Ie.START_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Ie.START_COMPLETE,streamId:e,reason:Oi(h)})})},tw=function(t){const e=t.streamId,i=this.sourceName,n=t.sourceName,r=this.comObj,o=this.streamControllers[e],l=this.streamSinks[e];switch(t.stream){case Ie.START_COMPLETE:t.success?o.startCall.resolve():o.startCall.reject(Oi(t.reason));break;case Ie.PULL_COMPLETE:t.success?o.pullCall.resolve():o.pullCall.reject(Oi(t.reason));break;case Ie.PULL:if(!l){r.postMessage({sourceName:i,targetName:n,stream:Ie.PULL_COMPLETE,streamId:e,success:!0});break}l.desiredSize<=0&&t.desiredSize>0&&l.sinkCapability.resolve(),l.desiredSize=t.desiredSize,Promise.try(l.onPull||E0).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Ie.PULL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Ie.PULL_COMPLETE,streamId:e,reason:Oi(h)})});break;case Ie.ENQUEUE:if(Mt(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(t.chunk);break;case Ie.CLOSE:if(Mt(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),S(this,Dn,Cp).call(this,o,e);break;case Ie.ERROR:Mt(o,"error should have stream controller"),o.controller.error(Oi(t.reason)),S(this,Dn,Cp).call(this,o,e);break;case Ie.CANCEL_COMPLETE:t.success?o.cancelCall.resolve():o.cancelCall.reject(Oi(t.reason)),S(this,Dn,Cp).call(this,o,e);break;case Ie.CANCEL:if(!l)break;const c=Oi(t.reason);Promise.try(l.onCancel||E0,c).then(function(){r.postMessage({sourceName:i,targetName:n,stream:Ie.CANCEL_COMPLETE,streamId:e,success:!0})},function(h){r.postMessage({sourceName:i,targetName:n,stream:Ie.CANCEL_COMPLETE,streamId:e,reason:Oi(h)})}),l.sinkCapability.reject(c),l.isCancelled=!0,delete this.streamSinks[e];break;default:throw new Error("Unexpected stream case")}},Cp=async function(t,e){var i,n,r;await Promise.allSettled([(i=t.startCall)==null?void 0:i.promise,(n=t.pullCall)==null?void 0:n.promise,(r=t.cancelCall)==null?void 0:r.promise]),delete this.streamControllers[e]};class x0{constructor({enableHWA:t=!1}){y(this,Sd,!1);g(this,Sd,t)}create(t,e){if(t<=0||e<=0)throw new Error("Invalid canvas size");const i=this._createCanvas(t,e);return{canvas:i,context:i.getContext("2d",{willReadFrequently:!s(this,Sd)})}}reset(t,e,i){if(!t.canvas)throw new Error("Canvas is not specified");if(e<=0||i<=0)throw new Error("Invalid canvas size");t.canvas.width=e,t.canvas.height=i}destroy(t){if(!t.canvas)throw new Error("Canvas is not specified");t.canvas.width=0,t.canvas.height=0,t.canvas=null,t.context=null}_createCanvas(t,e){ne("Abstract method `_createCanvas` called.")}}Sd=new WeakMap;class mE extends x0{constructor({ownerDocument:t=globalThis.document,enableHWA:e=!1}){super({enableHWA:e}),this._document=t}_createCanvas(t,e){const i=this._document.createElement("canvas");return i.width=t,i.height=e,i}}class C0{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(i=>({cMapData:i,isCompressed:this.isCompressed})).catch(i=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${e}`)})}async _fetch(t){ne("Abstract method `_fetch` called.")}}class _0 extends C0{async _fetch(t){const e=await xh(t,this.isCompressed?"arraybuffer":"text");return e instanceof ArrayBuffer?new Uint8Array(e):Sh(e)}}class T0{addFilter(t){return"none"}addHCMFilter(t,e){return"none"}addAlphaFilter(t){return"none"}addLuminosityFilter(t){return"none"}addHighlightHCMFilter(t,e,i,n,r){return"none"}destroy(t=!1){}}class bE extends T0{constructor({docId:e,ownerDocument:i=globalThis.document}){super();y(this,et);y(this,ga);y(this,cc);y(this,Js);y(this,Zs);y(this,mi);y(this,ma);y(this,ba,0);g(this,Zs,e),g(this,mi,i)}addFilter(e){if(!e)return"none";let i=s(this,et,Ai).get(e);if(i)return i;const[n,r,o]=S(this,et,_p).call(this,e),l=e.length===1?n:`${n}${r}${o}`;if(i=s(this,et,Ai).get(l),i)return s(this,et,Ai).set(e,i),i;const c=`g_${s(this,Zs)}_transfer_map_${Ge(this,ba)._++}`,h=S(this,et,hh).call(this,c);s(this,et,Ai).set(e,h),s(this,et,Ai).set(l,h);const d=S(this,et,dh).call(this,c);return S(this,et,$u).call(this,n,r,o,d),h}addHCMFilter(e,i){var m;const n=`${e}-${i}`,r="base";let o=s(this,et,Uu).get(r);if((o==null?void 0:o.key)===n||(o?((m=o.filter)==null||m.remove(),o.key=n,o.url="none",o.filter=null):(o={key:n,url:"none",filter:null},s(this,et,Uu).set(r,o)),!e||!i))return o.url;const l=S(this,et,Wu).call(this,e);e=Z.makeHexColor(...l);const c=S(this,et,Wu).call(this,i);if(i=Z.makeHexColor(...c),s(this,et,ch).style.color="",e==="#000000"&&i==="#ffffff"||e===i)return o.url;const h=new Array(256);for(let b=0;b<=255;b++){const v=b/255;h[b]=v<=.03928?v/12.92:((v+.055)/1.055)**2.4}const d=h.join(","),u=`g_${s(this,Zs)}_hcm_filter`,f=o.filter=S(this,et,dh).call(this,u);S(this,et,$u).call(this,d,d,d,f),S(this,et,tb).call(this,f);const p=(b,v)=>{const w=l[b]/255,_=c[b]/255,A=new Array(v+1);for(let C=0;C<=v;C++)A[C]=w+C/v*(_-w);return A.join(",")};return S(this,et,$u).call(this,p(0,5),p(1,5),p(2,5),f),o.url=S(this,et,hh).call(this,u),o.url}addAlphaFilter(e){let i=s(this,et,Ai).get(e);if(i)return i;const[n]=S(this,et,_p).call(this,[e]),r=`alpha_${n}`;if(i=s(this,et,Ai).get(r),i)return s(this,et,Ai).set(e,i),i;const o=`g_${s(this,Zs)}_alpha_map_${Ge(this,ba)._++}`,l=S(this,et,hh).call(this,o);s(this,et,Ai).set(e,l),s(this,et,Ai).set(r,l);const c=S(this,et,dh).call(this,o);return S(this,et,eb).call(this,n,c),l}addLuminosityFilter(e){let i=s(this,et,Ai).get(e||"luminosity");if(i)return i;let n,r;if(e?([n]=S(this,et,_p).call(this,[e]),r=`luminosity_${n}`):r="luminosity",i=s(this,et,Ai).get(r),i)return s(this,et,Ai).set(e,i),i;const o=`g_${s(this,Zs)}_luminosity_map_${Ge(this,ba)._++}`,l=S(this,et,hh).call(this,o);s(this,et,Ai).set(e,l),s(this,et,Ai).set(r,l);const c=S(this,et,dh).call(this,o);return S(this,et,ew).call(this,c),e&&S(this,et,eb).call(this,n,c),l}addHighlightHCMFilter(e,i,n,r,o){var _;const l=`${i}-${n}-${r}-${o}`;let c=s(this,et,Uu).get(e);if((c==null?void 0:c.key)===l||(c?((_=c.filter)==null||_.remove(),c.key=l,c.url="none",c.filter=null):(c={key:l,url:"none",filter:null},s(this,et,Uu).set(e,c)),!i||!n))return c.url;const[h,d]=[i,n].map(S(this,et,Wu).bind(this));let u=Math.round(.2126*h[0]+.7152*h[1]+.0722*h[2]),f=Math.round(.2126*d[0]+.7152*d[1]+.0722*d[2]),[p,m]=[r,o].map(S(this,et,Wu).bind(this));f<u&&([u,f,p,m]=[f,u,m,p]),s(this,et,ch).style.color="";const b=(A,C,x)=>{const P=new Array(256),R=(f-u)/x,N=A/255,z=(C-A)/(255*x);let H=0;for(let I=0;I<=x;I++){const ct=Math.round(u+I*R),j=N+I*z;for(let K=H;K<=ct;K++)P[K]=j;H=ct+1}for(let I=H;I<256;I++)P[I]=P[H-1];return P.join(",")},v=`g_${s(this,Zs)}_hcm_${e}_filter`,w=c.filter=S(this,et,dh).call(this,v);return S(this,et,tb).call(this,w),S(this,et,$u).call(this,b(p[0],m[0],5),b(p[1],m[1],5),b(p[2],m[2],5),w),c.url=S(this,et,hh).call(this,v),c.url}destroy(e=!1){var i,n,r,o;e&&((i=s(this,ma))!=null&&i.size)||((n=s(this,Js))==null||n.parentNode.parentNode.remove(),g(this,Js,null),(r=s(this,cc))==null||r.clear(),g(this,cc,null),(o=s(this,ma))==null||o.clear(),g(this,ma,null),g(this,ba,0))}}ga=new WeakMap,cc=new WeakMap,Js=new WeakMap,Zs=new WeakMap,mi=new WeakMap,ma=new WeakMap,ba=new WeakMap,et=new WeakSet,Ai=function(){return s(this,cc)||g(this,cc,new Map)},Uu=function(){return s(this,ma)||g(this,ma,new Map)},ch=function(){if(!s(this,Js)){const e=s(this,mi).createElement("div"),{style:i}=e;i.visibility="hidden",i.contain="strict",i.width=i.height=0,i.position="absolute",i.top=i.left=0,i.zIndex=-1;const n=s(this,mi).createElementNS(Is,"svg");n.setAttribute("width",0),n.setAttribute("height",0),g(this,Js,s(this,mi).createElementNS(Is,"defs")),e.append(n),n.append(s(this,Js)),s(this,mi).body.append(e)}return s(this,Js)},_p=function(e){if(e.length===1){const h=e[0],d=new Array(256);for(let f=0;f<256;f++)d[f]=h[f]/255;const u=d.join(",");return[u,u,u]}const[i,n,r]=e,o=new Array(256),l=new Array(256),c=new Array(256);for(let h=0;h<256;h++)o[h]=i[h]/255,l[h]=n[h]/255,c[h]=r[h]/255;return[o.join(","),l.join(","),c.join(",")]},hh=function(e){if(s(this,ga)===void 0){g(this,ga,"");const i=s(this,mi).URL;i!==s(this,mi).baseURI&&(yf(i)?pt('#createUrl: ignore "data:"-URL for performance reasons.'):g(this,ga,r0(i,"")))}return`url(${s(this,ga)}#${e})`},ew=function(e){const i=s(this,mi).createElementNS(Is,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(i)},tb=function(e){const i=s(this,mi).createElementNS(Is,"feColorMatrix");i.setAttribute("type","matrix"),i.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(i)},dh=function(e){const i=s(this,mi).createElementNS(Is,"filter");return i.setAttribute("color-interpolation-filters","sRGB"),i.setAttribute("id",e),s(this,et,ch).append(i),i},Hu=function(e,i,n){const r=s(this,mi).createElementNS(Is,i);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)},$u=function(e,i,n,r){const o=s(this,mi).createElementNS(Is,"feComponentTransfer");r.append(o),S(this,et,Hu).call(this,o,"feFuncR",e),S(this,et,Hu).call(this,o,"feFuncG",i),S(this,et,Hu).call(this,o,"feFuncB",n)},eb=function(e,i){const n=s(this,mi).createElementNS(Is,"feComponentTransfer");i.append(n),S(this,et,Hu).call(this,n,"feFuncA",e)},Wu=function(e){return s(this,et,ch).style.color=e,Th(getComputedStyle(s(this,et,ch)).getPropertyValue("color"))};class P0{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(i=>{throw new Error(`Unable to load font data at: ${e}`)})}async _fetch(t){ne("Abstract method `_fetch` called.")}}class k0 extends P0{async _fetch(t){const e=await xh(t,"arraybuffer");return new Uint8Array(e)}}class M0{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(i=>{throw new Error(`Unable to load wasm data at: ${e}`)})}async _fetch(t){ne("Abstract method `_fetch` called.")}}class R0 extends M0{async _fetch(t){const e=await xh(t,"arraybuffer");return new Uint8Array(e)}}Si&&pt("Please use the `legacy` build in Node.js environments.");async function Zg(a){const e=await process.getBuiltinModule("fs").promises.readFile(a);return new Uint8Array(e)}class yE extends T0{}class vE extends x0{_createCanvas(t,e){return process.getBuiltinModule("module").createRequire(typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Pr&&Pr.tagName.toUpperCase()==="SCRIPT"&&Pr.src||new URL("whiteboard.umd.js",document.baseURI).href)("@napi-rs/canvas").createCanvas(t,e)}}class wE extends C0{async _fetch(t){return Zg(t)}}class AE extends P0{async _fetch(t){return Zg(t)}}class SE extends M0{async _fetch(t){return Zg(t)}}const Cl="__forcedDependency",{floor:D0,ceil:O0}=Math;function Tf(a,t,e,i,n,r){a[t*4+0]=Math.min(a[t*4+0],e),a[t*4+1]=Math.min(a[t*4+1],i),a[t*4+2]=Math.max(a[t*4+2],n),a[t*4+3]=Math.max(a[t*4+3],r)}const Qg=new Uint32Array(new Uint8Array([255,255,0,0]).buffer)[0];class EE{constructor(t,e){y(this,hc);y(this,so);g(this,hc,t),g(this,so,e)}get length(){return s(this,hc).length}isEmpty(t){return s(this,hc)[t]===Qg}minX(t){return s(this,so)[t*4+0]/256}minY(t){return s(this,so)[t*4+1]/256}maxX(t){return(s(this,so)[t*4+2]+1)/256}maxY(t){return(s(this,so)[t*4+3]+1)/256}}hc=new WeakMap,so=new WeakMap;const Pf=(a,t)=>{if(!a)return;let e=a.get(t);return e||(e={dependencies:new Set,isRenderingOperation:!1},a.set(t,e)),e};class xE{constructor(t,e,i=!1){y(this,xd);y(this,Ni,{__proto__:null});y(this,Fi,{__proto__:null,transform:[],moveText:[],sameLineText:[],[Cl]:[]});y(this,ya,new Map);y(this,Hn,[]);y(this,va,[]);y(this,Qs,[[1,0,0,1,0,0]]);y(this,Xt,[-1/0,-1/0,1/0,1/0]);y(this,Zt,new Float64Array([1/0,1/0,-1/0,-1/0]));y(this,tr,-1);y(this,Bi,new Set);y(this,Ed,new Map);y(this,dc,new Map);y(this,wa);y(this,Aa);y(this,er);y(this,bi);y(this,bs);g(this,wa,t.width),g(this,Aa,t.height),S(this,xd,ib).call(this,e),i&&g(this,bs,new Map)}growOperationsCount(t){t>=s(this,bi).length&&S(this,xd,ib).call(this,t,s(this,bi))}save(t){return g(this,Ni,{__proto__:s(this,Ni)}),g(this,Fi,{__proto__:s(this,Fi),transform:{__proto__:s(this,Fi).transform},moveText:{__proto__:s(this,Fi).moveText},sameLineText:{__proto__:s(this,Fi).sameLineText},[Cl]:{__proto__:s(this,Fi)[Cl]}}),g(this,Xt,{__proto__:s(this,Xt)}),s(this,Hn).push(t),this}restore(t){var n;const e=Object.getPrototypeOf(s(this,Ni));if(e===null)return this;g(this,Ni,e),g(this,Fi,Object.getPrototypeOf(s(this,Fi))),g(this,Xt,Object.getPrototypeOf(s(this,Xt)));const i=s(this,Hn).pop();return i!==void 0&&((n=Pf(s(this,bs),t))==null||n.dependencies.add(i),s(this,bi)[t]=s(this,bi)[i]),this}recordOpenMarker(t){return s(this,Hn).push(t),this}getOpenMarker(){return s(this,Hn).length===0?null:s(this,Hn).at(-1)}recordCloseMarker(t){var i;const e=s(this,Hn).pop();return e!==void 0&&((i=Pf(s(this,bs),t))==null||i.dependencies.add(e),s(this,bi)[t]=s(this,bi)[e]),this}beginMarkedContent(t){return s(this,va).push(t),this}endMarkedContent(t){var i;const e=s(this,va).pop();return e!==void 0&&((i=Pf(s(this,bs),t))==null||i.dependencies.add(e),s(this,bi)[t]=s(this,bi)[e]),this}pushBaseTransform(t){return s(this,Qs).push(Z.multiplyByDOMMatrix(s(this,Qs).at(-1),t.getTransform())),this}popBaseTransform(){return s(this,Qs).length>1&&s(this,Qs).pop(),this}recordSimpleData(t,e){return s(this,Ni)[t]=e,this}recordIncrementalData(t,e){return s(this,Fi)[t].push(e),this}resetIncrementalData(t,e){return s(this,Fi)[t].length=0,this}recordNamedData(t,e){return s(this,ya).set(t,e),this}recordSimpleDataFromNamed(t,e,i){s(this,Ni)[t]=s(this,ya).get(e)??i}recordFutureForcedDependency(t,e){return this.recordIncrementalData(Cl,e),this}inheritSimpleDataAsFutureForcedDependencies(t){for(const e of t)e in s(this,Ni)&&this.recordFutureForcedDependency(e,s(this,Ni)[e]);return this}inheritPendingDependenciesAsFutureForcedDependencies(){for(const t of s(this,Bi))this.recordFutureForcedDependency(Cl,t);return this}resetBBox(t){return s(this,tr)!==t&&(g(this,tr,t),s(this,Zt)[0]=1/0,s(this,Zt)[1]=1/0,s(this,Zt)[2]=-1/0,s(this,Zt)[3]=-1/0),this}recordClipBox(t,e,i,n,r,o){const l=Z.multiplyByDOMMatrix(s(this,Qs).at(-1),e.getTransform()),c=[1/0,1/0,-1/0,-1/0];Z.axialAlignedBoundingBox([i,r,n,o],l,c);const h=Z.intersect(s(this,Xt),c);return h?(s(this,Xt)[0]=h[0],s(this,Xt)[1]=h[1],s(this,Xt)[2]=h[2],s(this,Xt)[3]=h[3]):(s(this,Xt)[0]=s(this,Xt)[1]=1/0,s(this,Xt)[2]=s(this,Xt)[3]=-1/0),this}recordBBox(t,e,i,n,r,o){const l=s(this,Xt);if(l[0]===1/0)return this;const c=Z.multiplyByDOMMatrix(s(this,Qs).at(-1),e.getTransform());if(l[0]===-1/0)return Z.axialAlignedBoundingBox([i,r,n,o],c,s(this,Zt)),this;const h=[1/0,1/0,-1/0,-1/0];return Z.axialAlignedBoundingBox([i,r,n,o],c,h),s(this,Zt)[0]=Math.min(s(this,Zt)[0],Math.max(h[0],l[0])),s(this,Zt)[1]=Math.min(s(this,Zt)[1],Math.max(h[1],l[1])),s(this,Zt)[2]=Math.max(s(this,Zt)[2],Math.min(h[2],l[2])),s(this,Zt)[3]=Math.max(s(this,Zt)[3],Math.min(h[3],l[3])),this}recordCharacterBBox(t,e,i,n=1,r=0,o=0,l){const c=i.bbox;let h,d;if(c&&(h=c[2]!==c[0]&&c[3]!==c[1]&&s(this,dc).get(i),h!==!1&&(d=[0,0,0,0],Z.axialAlignedBoundingBox(c,i.fontMatrix,d),(n!==1||r!==0||o!==0)&&Z.scaleMinMax([n,0,0,-n,r,o],d),h)))return this.recordBBox(t,e,d[0],d[2],d[1],d[3]);if(!l)return this.recordFullPageBBox(t);const u=l();return c&&d&&h===void 0&&(h=d[0]<=r-u.actualBoundingBoxLeft&&d[2]>=r+u.actualBoundingBoxRight&&d[1]<=o-u.actualBoundingBoxAscent&&d[3]>=o+u.actualBoundingBoxDescent,s(this,dc).set(i,h),h)?this.recordBBox(t,e,d[0],d[2],d[1],d[3]):this.recordBBox(t,e,r-u.actualBoundingBoxLeft,r+u.actualBoundingBoxRight,o-u.actualBoundingBoxAscent,o+u.actualBoundingBoxDescent)}recordFullPageBBox(t){return s(this,Zt)[0]=Math.max(0,s(this,Xt)[0]),s(this,Zt)[1]=Math.max(0,s(this,Xt)[1]),s(this,Zt)[2]=Math.min(s(this,wa),s(this,Xt)[2]),s(this,Zt)[3]=Math.min(s(this,Aa),s(this,Xt)[3]),this}getSimpleIndex(t){return s(this,Ni)[t]}recordDependencies(t,e){const i=s(this,Bi),n=s(this,Ni),r=s(this,Fi);for(const o of e)o in s(this,Ni)?i.add(n[o]):o in r&&r[o].forEach(i.add,i);return this}recordNamedDependency(t,e){return s(this,ya).has(e)&&s(this,Bi).add(s(this,ya).get(e)),this}recordOperation(t,e=!1){if(this.recordDependencies(t,[Cl]),s(this,bs)){const i=Pf(s(this,bs),t),{dependencies:n}=i;s(this,Bi).forEach(n.add,n),s(this,Hn).forEach(n.add,n),s(this,va).forEach(n.add,n),n.delete(t),i.isRenderingOperation=!0}if(s(this,tr)===t){const i=D0(s(this,Zt)[0]*256/s(this,wa)),n=D0(s(this,Zt)[1]*256/s(this,Aa)),r=O0(s(this,Zt)[2]*256/s(this,wa)),o=O0(s(this,Zt)[3]*256/s(this,Aa));Tf(s(this,er),t,i,n,r,o);for(const l of s(this,Bi))l!==t&&Tf(s(this,er),l,i,n,r,o);for(const l of s(this,Hn))l!==t&&Tf(s(this,er),l,i,n,r,o);for(const l of s(this,va))l!==t&&Tf(s(this,er),l,i,n,r,o);e||(s(this,Bi).clear(),g(this,tr,-1))}return this}recordShowTextOperation(t,e=!1){const i=Array.from(s(this,Bi));this.recordOperation(t,e),this.recordIncrementalData("sameLineText",t);for(const n of i)this.recordIncrementalData("sameLineText",n);return this}bboxToClipBoxDropOperation(t,e=!1){return s(this,tr)===t&&(g(this,tr,-1),s(this,Xt)[0]=Math.max(s(this,Xt)[0],s(this,Zt)[0]),s(this,Xt)[1]=Math.max(s(this,Xt)[1],s(this,Zt)[1]),s(this,Xt)[2]=Math.min(s(this,Xt)[2],s(this,Zt)[2]),s(this,Xt)[3]=Math.min(s(this,Xt)[3],s(this,Zt)[3]),e||s(this,Bi).clear()),this}_takePendingDependencies(){const t=s(this,Bi);return g(this,Bi,new Set),t}_extractOperation(t){const e=s(this,Ed).get(t);return s(this,Ed).delete(t),e}_pushPendingDependencies(t){for(const e of t)s(this,Bi).add(e)}take(){return s(this,dc).clear(),new EE(s(this,bi),s(this,er))}takeDebugMetadata(){return s(this,bs)}}Ni=new WeakMap,Fi=new WeakMap,ya=new WeakMap,Hn=new WeakMap,va=new WeakMap,Qs=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,tr=new WeakMap,Bi=new WeakMap,Ed=new WeakMap,dc=new WeakMap,wa=new WeakMap,Aa=new WeakMap,er=new WeakMap,bi=new WeakMap,bs=new WeakMap,xd=new WeakSet,ib=function(t,e){const i=new ArrayBuffer(t*4);g(this,er,new Uint8ClampedArray(i)),g(this,bi,new Uint32Array(i)),e&&e.length>0?(s(this,bi).set(e),s(this,bi).fill(Qg,e.length)):s(this,bi).fill(Qg)};const Pm=class Pm{constructor(t,e,i){y(this,re);y(this,_e);y(this,$n);y(this,uc,0);y(this,fc,0);if(t instanceof Pm&&s(t,$n)===!!i)return t;g(this,re,t),g(this,_e,e),g(this,$n,!!i)}growOperationsCount(){throw new Error("Unreachable")}save(t){return Ge(this,fc)._++,s(this,re).save(s(this,_e)),this}restore(t){return s(this,fc)>0&&(s(this,re).restore(s(this,_e)),Ge(this,fc)._--),this}recordOpenMarker(t){return Ge(this,uc)._++,this}getOpenMarker(){return s(this,uc)>0?s(this,_e):s(this,re).getOpenMarker()}recordCloseMarker(t){return Ge(this,uc)._--,this}beginMarkedContent(t){return this}endMarkedContent(t){return this}pushBaseTransform(t){return s(this,re).pushBaseTransform(t),this}popBaseTransform(){return s(this,re).popBaseTransform(),this}recordSimpleData(t,e){return s(this,re).recordSimpleData(t,s(this,_e)),this}recordIncrementalData(t,e){return s(this,re).recordIncrementalData(t,s(this,_e)),this}resetIncrementalData(t,e){return s(this,re).resetIncrementalData(t,s(this,_e)),this}recordNamedData(t,e){return this}recordSimpleDataFromNamed(t,e,i){return s(this,re).recordSimpleDataFromNamed(t,e,s(this,_e)),this}recordFutureForcedDependency(t,e){return s(this,re).recordFutureForcedDependency(t,s(this,_e)),this}inheritSimpleDataAsFutureForcedDependencies(t){return s(this,re).inheritSimpleDataAsFutureForcedDependencies(t),this}inheritPendingDependenciesAsFutureForcedDependencies(){return s(this,re).inheritPendingDependenciesAsFutureForcedDependencies(),this}resetBBox(t){return s(this,$n)||s(this,re).resetBBox(s(this,_e)),this}recordClipBox(t,e,i,n,r,o){return s(this,$n)||s(this,re).recordClipBox(s(this,_e),e,i,n,r,o),this}recordBBox(t,e,i,n,r,o){return s(this,$n)||s(this,re).recordBBox(s(this,_e),e,i,n,r,o),this}recordCharacterBBox(t,e,i,n,r,o,l){return s(this,$n)||s(this,re).recordCharacterBBox(s(this,_e),e,i,n,r,o,l),this}recordFullPageBBox(t){return s(this,$n)||s(this,re).recordFullPageBBox(s(this,_e)),this}getSimpleIndex(t){return s(this,re).getSimpleIndex(t)}recordDependencies(t,e){return s(this,re).recordDependencies(s(this,_e),e),this}recordNamedDependency(t,e){return s(this,re).recordNamedDependency(s(this,_e),e),this}recordOperation(t){return s(this,re).recordOperation(s(this,_e),!0),this}recordShowTextOperation(t){return s(this,re).recordShowTextOperation(s(this,_e),!0),this}bboxToClipBoxDropOperation(t){return s(this,$n)||s(this,re).bboxToClipBoxDropOperation(s(this,_e),!0),this}take(){throw new Error("Unreachable")}takeDebugMetadata(){throw new Error("Unreachable")}};re=new WeakMap,_e=new WeakMap,$n=new WeakMap,uc=new WeakMap,fc=new WeakMap;let kf=Pm;const Sn={stroke:["path","transform","filter","strokeColor","strokeAlpha","lineWidth","lineCap","lineJoin","miterLimit","dash"],fill:["path","transform","filter","fillColor","fillAlpha","globalCompositeOperation","SMask"],imageXObject:["transform","SMask","filter","fillAlpha","strokeAlpha","globalCompositeOperation"],rawFillPath:["filter","fillColor","fillAlpha"],showText:["transform","leading","charSpacing","wordSpacing","hScale","textRise","moveText","textMatrix","font","fontObj","filter","fillColor","textRenderingMode","SMask","fillAlpha","strokeAlpha","globalCompositeOperation","sameLineText"],transform:["transform"],transformAndFill:["transform","fillColor"]},ni={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function tm(a,t){if(!t)return;const e=t[2]-t[0],i=t[3]-t[1],n=new Path2D;n.rect(t[0],t[1],e,i),a.clip(n)}class em{isModifyingCurrentTransform(){return!1}getPattern(){ne("Abstract method `getPattern` called.")}}class CE extends em{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}isOriginBased(){return this._p0[0]===0&&this._p0[1]===0&&(!this.isRadial()||this._p1[0]===0&&this._p1[1]===0)}isRadial(){return this._type==="radial"}_createGradient(t,e=null){let i,n=this._p0,r=this._p1;if(e&&(n=n.slice(),r=r.slice(),Z.applyTransform(n,e),Z.applyTransform(r,e)),this._type==="axial")i=t.createLinearGradient(n[0],n[1],r[0],r[1]);else if(this._type==="radial"){let o=this._r0,l=this._r1;if(e){const c=new Float32Array(2);Z.singularValueDecompose2dScale(e,c),o*=c[0],l*=c[0]}i=t.createRadialGradient(n[0],n[1],o,r[0],r[1],l)}for(const o of this._colorStops)i.addColorStop(o[0],o[1]);return i}getPattern(t,e,i,n){let r;if(n===ni.STROKE||n===ni.FILL){if(this.isOriginBased()){let f=Z.transform(i,e.baseTransform);this.matrix&&(f=Z.transform(f,this.matrix));const p=.001,m=Math.hypot(f[0],f[1]),b=Math.hypot(f[2],f[3]),v=(f[0]*f[2]+f[1]*f[3])/(m*b);if(Math.abs(v)<p)if(this.isRadial()){if(Math.abs(m-b)<p)return this._createGradient(t,f)}else return this._createGradient(t,f)}const o=e.current.getClippedPathBoundingBox(n,ve(t))||[0,0,0,0],l=Math.ceil(o[2]-o[0])||1,c=Math.ceil(o[3]-o[1])||1,h=e.cachedCanvases.getCanvas("pattern",l,c),d=h.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-o[0],-o[1]),i=Z.transform(i,[1,0,0,1,o[0],o[1]]),d.transform(...e.baseTransform),this.matrix&&d.transform(...this.matrix),tm(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),r=t.createPattern(h.canvas,"no-repeat");const u=new DOMMatrix(i);r.setTransform(u)}else tm(t,this._bbox),r=this._createGradient(t);return r}}function im(a,t,e,i,n,r,o,l){const c=t.coords,h=t.colors,d=a.data,u=a.width*4;let f;c[e+1]>c[i+1]&&(f=e,e=i,i=f,f=r,r=o,o=f),c[i+1]>c[n+1]&&(f=i,i=n,n=f,f=o,o=l,l=f),c[e+1]>c[i+1]&&(f=e,e=i,i=f,f=r,r=o,o=f);const p=(c[e]+t.offsetX)*t.scaleX,m=(c[e+1]+t.offsetY)*t.scaleY,b=(c[i]+t.offsetX)*t.scaleX,v=(c[i+1]+t.offsetY)*t.scaleY,w=(c[n]+t.offsetX)*t.scaleX,_=(c[n+1]+t.offsetY)*t.scaleY;if(m>=_)return;const A=h[r],C=h[r+1],x=h[r+2],P=h[o],R=h[o+1],N=h[o+2],z=h[l],H=h[l+1],I=h[l+2],ct=Math.round(m),j=Math.round(_);let K,st,tt,J,lt,It,Rt,Bt;for(let St=ct;St<=j;St++){if(St<v){const Nt=St<m?0:(m-St)/(m-v);K=p-(p-b)*Nt,st=A-(A-P)*Nt,tt=C-(C-R)*Nt,J=x-(x-N)*Nt}else{let Nt;St>_?Nt=1:v===_?Nt=0:Nt=(v-St)/(v-_),K=b-(b-w)*Nt,st=P-(P-z)*Nt,tt=R-(R-H)*Nt,J=N-(N-I)*Nt}let xt;St<m?xt=0:St>_?xt=1:xt=(m-St)/(m-_),lt=p-(p-w)*xt,It=A-(A-z)*xt,Rt=C-(C-H)*xt,Bt=x-(x-I)*xt;const ye=Math.round(Math.min(K,lt)),Lt=Math.round(Math.max(K,lt));let ee=u*St+ye*4;for(let Nt=ye;Nt<=Lt;Nt++)xt=(K-Nt)/(K-lt),xt<0?xt=0:xt>1&&(xt=1),d[ee++]=st-(st-It)*xt|0,d[ee++]=tt-(tt-Rt)*xt|0,d[ee++]=J-(J-Bt)*xt|0,d[ee++]=255}}function _E(a,t,e){const i=t.coords,n=t.colors;let r,o;switch(t.type){case Lg.LATTICE:const l=t.verticesPerRow,c=Math.floor(i.length/l)-1,h=l-1;for(r=0;r<c;r++){let d=r*l;for(let u=0;u<h;u++,d++)im(a,e,i[d],i[d+1],i[d+l],n[d],n[d+1],n[d+l]),im(a,e,i[d+l+1],i[d+1],i[d+l],n[d+l+1],n[d+1],n[d+l])}break;case Lg.TRIANGLES:for(r=0,o=i.length;r<o;r+=3)im(a,e,i[r],i[r+1],i[r+2],n[r],n[r+1],n[r+2]);break;default:throw new Error("illegal figure")}}class TE extends em{constructor(t){super(),this._coords=t[2],this._colors=t[3],this._figures=t[4],this._bounds=t[5],this._bbox=t[6],this._background=t[7],this.matrix=null}_createMeshCanvas(t,e,i){const l=Math.floor(this._bounds[0]),c=Math.floor(this._bounds[1]),h=Math.ceil(this._bounds[2])-l,d=Math.ceil(this._bounds[3])-c,u=Math.min(Math.ceil(Math.abs(h*t[0]*1.1)),3e3),f=Math.min(Math.ceil(Math.abs(d*t[1]*1.1)),3e3),p=h/u,m=d/f,b={coords:this._coords,colors:this._colors,offsetX:-l,offsetY:-c,scaleX:1/p,scaleY:1/m},v=u+4,w=f+4,_=i.getCanvas("mesh",v,w),A=_.context,C=A.createImageData(u,f);if(e){const P=C.data;for(let R=0,N=P.length;R<N;R+=4)P[R]=e[0],P[R+1]=e[1],P[R+2]=e[2],P[R+3]=255}for(const P of this._figures)_E(C,P,b);return A.putImageData(C,2,2),{canvas:_.canvas,offsetX:l-2*p,offsetY:c-2*m,scaleX:p,scaleY:m}}isModifyingCurrentTransform(){return!0}getPattern(t,e,i,n){tm(t,this._bbox);const r=new Float32Array(2);if(n===ni.SHADING)Z.singularValueDecompose2dScale(ve(t),r);else if(this.matrix){Z.singularValueDecompose2dScale(this.matrix,r);const[l,c]=r;Z.singularValueDecompose2dScale(e.baseTransform,r),r[0]*=l,r[1]*=c}else Z.singularValueDecompose2dScale(e.baseTransform,r);const o=this._createMeshCanvas(r,n===ni.SHADING?null:this._background,e.cachedCanvases);return n!==ni.SHADING&&(t.setTransform(...e.baseTransform),this.matrix&&t.transform(...this.matrix)),t.translate(o.offsetX,o.offsetY),t.scale(o.scaleX,o.scaleY),t.createPattern(o.canvas,"no-repeat")}}class PE extends em{getPattern(){return"hotpink"}}function kE(a){switch(a[0]){case"RadialAxial":return new CE(a);case"Mesh":return new TE(a);case"Dummy":return new PE}throw new Error(`Unknown IR type: ${a[0]}`)}const I0={COLORED:1,UNCOLORED:2},Kf=class Kf{constructor(t,e,i,n){this.color=t[1],this.operatorList=t[2],this.matrix=t[3],this.bbox=t[4],this.xstep=t[5],this.ystep=t[6],this.paintType=t[7],this.tilingType=t[8],this.ctx=e,this.canvasGraphicsFactory=i,this.baseTransform=n}createPatternCanvas(t,e){var It,Rt;const{bbox:i,operatorList:n,paintType:r,tilingType:o,color:l,canvasGraphicsFactory:c}=this;let{xstep:h,ystep:d}=this;h=Math.abs(h),d=Math.abs(d),mf("TilingType: "+o);const u=i[0],f=i[1],p=i[2],m=i[3],b=p-u,v=m-f,w=new Float32Array(2);Z.singularValueDecompose2dScale(this.matrix,w);const[_,A]=w;Z.singularValueDecompose2dScale(this.baseTransform,w);const C=_*w[0],x=A*w[1];let P=b,R=v,N=!1,z=!1;const H=Math.ceil(h*C),I=Math.ceil(d*x),ct=Math.ceil(b*C),j=Math.ceil(v*x);H>=ct?P=h:N=!0,I>=j?R=d:z=!0;const K=this.getSizeAndScale(P,this.ctx.canvas.width,C),st=this.getSizeAndScale(R,this.ctx.canvas.height,x),tt=t.cachedCanvases.getCanvas("pattern",K.size,st.size),J=tt.context,lt=c.createCanvasGraphics(J,e);if(lt.groupLevel=t.groupLevel,this.setFillAndStrokeStyleToContext(lt,r,l),J.translate(-K.scale*u,-st.scale*f),lt.transform(0,K.scale,0,0,st.scale,0,0),J.save(),(It=lt.dependencyTracker)==null||It.save(),this.clipBbox(lt,u,f,p,m),lt.baseTransform=ve(lt.ctx),lt.executeOperatorList(n),lt.endDrawing(),(Rt=lt.dependencyTracker)==null||Rt.restore(),J.restore(),N||z){const Bt=tt.canvas;N&&(P=h),z&&(R=d);const St=this.getSizeAndScale(P,this.ctx.canvas.width,C),xt=this.getSizeAndScale(R,this.ctx.canvas.height,x),ye=St.size,Lt=xt.size,ee=t.cachedCanvases.getCanvas("pattern-workaround",ye,Lt),Nt=ee.context,Hi=N?Math.floor(b/h):0,ke=z?Math.floor(v/d):0;for(let vi=0;vi<=Hi;vi++)for(let wi=0;wi<=ke;wi++)Nt.drawImage(Bt,ye*vi,Lt*wi,ye,Lt,0,0,ye,Lt);return{canvas:ee.canvas,scaleX:St.scale,scaleY:xt.scale,offsetX:u,offsetY:f}}return{canvas:tt.canvas,scaleX:K.scale,scaleY:st.scale,offsetX:u,offsetY:f}}getSizeAndScale(t,e,i){const n=Math.max(Kf.MAX_PATTERN_SIZE,e);let r=Math.ceil(t*i);return r>=n?r=n:i=r/t,{scale:i,size:r}}clipBbox(t,e,i,n,r){const o=n-e,l=r-i;t.ctx.rect(e,i,o,l),Z.axialAlignedBoundingBox([e,i,n,r],ve(t.ctx),t.current.minMax),t.clip(),t.endPath()}setFillAndStrokeStyleToContext(t,e,i){const n=t.ctx,r=t.current;switch(e){case I0.COLORED:const{fillStyle:o,strokeStyle:l}=this.ctx;n.fillStyle=r.fillColor=o,n.strokeStyle=r.strokeColor=l;break;case I0.UNCOLORED:n.fillStyle=n.strokeStyle=i,r.fillColor=r.strokeColor=i;break;default:throw new US(`Unsupported paint type: ${e}`)}}isModifyingCurrentTransform(){return!1}getPattern(t,e,i,n,r){let o=i;n!==ni.SHADING&&(o=Z.transform(o,e.baseTransform),this.matrix&&(o=Z.transform(o,this.matrix)));const l=this.createPatternCanvas(e,r);let c=new DOMMatrix(o);c=c.translate(l.offsetX,l.offsetY),c=c.scale(1/l.scaleX,1/l.scaleY);const h=t.createPattern(l.canvas,"repeat");return h.setTransform(c),h}};W(Kf,"MAX_PATTERN_SIZE",3e3);let nm=Kf;function ME({src:a,srcPos:t=0,dest:e,width:i,height:n,nonBlackColor:r=4294967295,inverseDecode:o=!1}){const l=je.isLittleEndian?4278190080:255,[c,h]=o?[r,l]:[l,r],d=i>>3,u=i&7,f=a.length;e=new Uint32Array(e.buffer);let p=0;for(let m=0;m<n;m++){for(const v=t+d;t<v;t++){const w=t<f?a[t]:255;e[p++]=w&128?h:c,e[p++]=w&64?h:c,e[p++]=w&32?h:c,e[p++]=w&16?h:c,e[p++]=w&8?h:c,e[p++]=w&4?h:c,e[p++]=w&2?h:c,e[p++]=w&1?h:c}if(u===0)continue;const b=t<f?a[t++]:255;for(let v=0;v<u;v++)e[p++]=b&1<<7-v?h:c}return{srcPos:t,destPos:p}}const L0=16,N0=100,RE=15,F0=10,Ii=16,sm=new DOMMatrix,Ki=new Float32Array(2),_l=new Float32Array([1/0,1/0,-1/0,-1/0]);function DE(a,t){if(a._removeMirroring)throw new Error("Context is already forwarding operations.");a.__originalSave=a.save,a.__originalRestore=a.restore,a.__originalRotate=a.rotate,a.__originalScale=a.scale,a.__originalTranslate=a.translate,a.__originalTransform=a.transform,a.__originalSetTransform=a.setTransform,a.__originalResetTransform=a.resetTransform,a.__originalClip=a.clip,a.__originalMoveTo=a.moveTo,a.__originalLineTo=a.lineTo,a.__originalBezierCurveTo=a.bezierCurveTo,a.__originalRect=a.rect,a.__originalClosePath=a.closePath,a.__originalBeginPath=a.beginPath,a._removeMirroring=()=>{a.save=a.__originalSave,a.restore=a.__originalRestore,a.rotate=a.__originalRotate,a.scale=a.__originalScale,a.translate=a.__originalTranslate,a.transform=a.__originalTransform,a.setTransform=a.__originalSetTransform,a.resetTransform=a.__originalResetTransform,a.clip=a.__originalClip,a.moveTo=a.__originalMoveTo,a.lineTo=a.__originalLineTo,a.bezierCurveTo=a.__originalBezierCurveTo,a.rect=a.__originalRect,a.closePath=a.__originalClosePath,a.beginPath=a.__originalBeginPath,delete a._removeMirroring},a.save=function(){t.save(),this.__originalSave()},a.restore=function(){t.restore(),this.__originalRestore()},a.translate=function(e,i){t.translate(e,i),this.__originalTranslate(e,i)},a.scale=function(e,i){t.scale(e,i),this.__originalScale(e,i)},a.transform=function(e,i,n,r,o,l){t.transform(e,i,n,r,o,l),this.__originalTransform(e,i,n,r,o,l)},a.setTransform=function(e,i,n,r,o,l){t.setTransform(e,i,n,r,o,l),this.__originalSetTransform(e,i,n,r,o,l)},a.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},a.rotate=function(e){t.rotate(e),this.__originalRotate(e)},a.clip=function(e){t.clip(e),this.__originalClip(e)},a.moveTo=function(e,i){t.moveTo(e,i),this.__originalMoveTo(e,i)},a.lineTo=function(e,i){t.lineTo(e,i),this.__originalLineTo(e,i)},a.bezierCurveTo=function(e,i,n,r,o,l){t.bezierCurveTo(e,i,n,r,o,l),this.__originalBezierCurveTo(e,i,n,r,o,l)},a.rect=function(e,i,n,r){t.rect(e,i,n,r),this.__originalRect(e,i,n,r)},a.closePath=function(){t.closePath(),this.__originalClosePath()},a.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}class OE{constructor(t){this.canvasFactory=t,this.cache=Object.create(null)}getCanvas(t,e,i){let n;return this.cache[t]!==void 0?(n=this.cache[t],this.canvasFactory.reset(n,e,i)):(n=this.canvasFactory.create(e,i),this.cache[t]=n),n}delete(t){delete this.cache[t]}clear(){for(const t in this.cache){const e=this.cache[t];this.canvasFactory.destroy(e),delete this.cache[t]}}}function Mf(a,t,e,i,n,r,o,l,c,h){const[d,u,f,p,m,b]=ve(a);if(u===0&&f===0){const _=o*d+m,A=Math.round(_),C=l*p+b,x=Math.round(C),P=(o+c)*d+m,R=Math.abs(Math.round(P)-A)||1,N=(l+h)*p+b,z=Math.abs(Math.round(N)-x)||1;return a.setTransform(Math.sign(d),0,0,Math.sign(p),A,x),a.drawImage(t,e,i,n,r,0,0,R,z),a.setTransform(d,u,f,p,m,b),[R,z]}if(d===0&&p===0){const _=l*f+m,A=Math.round(_),C=o*u+b,x=Math.round(C),P=(l+h)*f+m,R=Math.abs(Math.round(P)-A)||1,N=(o+c)*u+b,z=Math.abs(Math.round(N)-x)||1;return a.setTransform(0,Math.sign(u),Math.sign(f),0,A,x),a.drawImage(t,e,i,n,r,0,0,z,R),a.setTransform(d,u,f,p,m,b),[z,R]}a.drawImage(t,e,i,n,r,o,l,c,h);const v=Math.hypot(d,u),w=Math.hypot(f,p);return[v*c,w*h]}class B0{constructor(t,e,i){W(this,"alphaIsShape",!1);W(this,"fontSize",0);W(this,"fontSizeScale",1);W(this,"textMatrix",null);W(this,"textMatrixScale",1);W(this,"fontMatrix",Og);W(this,"leading",0);W(this,"x",0);W(this,"y",0);W(this,"lineX",0);W(this,"lineY",0);W(this,"charSpacing",0);W(this,"wordSpacing",0);W(this,"textHScale",1);W(this,"textRenderingMode",Be.FILL);W(this,"textRise",0);W(this,"fillColor","#000000");W(this,"strokeColor","#000000");W(this,"patternFill",!1);W(this,"patternStroke",!1);W(this,"fillAlpha",1);W(this,"strokeAlpha",1);W(this,"lineWidth",1);W(this,"activeSMask",null);W(this,"transferMaps","none");i==null||i(this),this.clipBox=new Float32Array([0,0,t,e]),this.minMax=_l.slice()}clone(){const t=Object.create(this);return t.clipBox=this.clipBox.slice(),t.minMax=this.minMax.slice(),t}getPathBoundingBox(t=ni.FILL,e=null){const i=this.minMax.slice();if(t===ni.STROKE){e||ne("Stroke bounding box must include transform."),Z.singularValueDecompose2dScale(e,Ki);const n=Ki[0]*this.lineWidth/2,r=Ki[1]*this.lineWidth/2;i[0]-=n,i[1]-=r,i[2]+=n,i[3]+=r}return i}updateClipFromPath(){const t=Z.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(_l,0)}getClippedPathBoundingBox(t=ni.FILL,e=null){return Z.intersect(this.clipBox,this.getPathBoundingBox(t,e))}}function j0(a,t){if(t instanceof ImageData){a.putImageData(t,0,0);return}const e=t.height,i=t.width,n=e%Ii,r=(e-n)/Ii,o=n===0?r:r+1,l=a.createImageData(i,Ii);let c=0,h;const d=t.data,u=l.data;let f,p,m,b;if(t.kind===ff.GRAYSCALE_1BPP){const v=d.byteLength,w=new Uint32Array(u.buffer,0,u.byteLength>>2),_=w.length,A=i+7>>3,C=4294967295,x=je.isLittleEndian?4278190080:255;for(f=0;f<o;f++){for(m=f<r?Ii:n,h=0,p=0;p<m;p++){const P=v-c;let R=0;const N=P>A?i:P*8-7,z=N&-8;let H=0,I=0;for(;R<z;R+=8)I=d[c++],w[h++]=I&128?C:x,w[h++]=I&64?C:x,w[h++]=I&32?C:x,w[h++]=I&16?C:x,w[h++]=I&8?C:x,w[h++]=I&4?C:x,w[h++]=I&2?C:x,w[h++]=I&1?C:x;for(;R<N;R++)H===0&&(I=d[c++],H=128),w[h++]=I&H?C:x,H>>=1}for(;h<_;)w[h++]=0;a.putImageData(l,0,f*Ii)}}else if(t.kind===ff.RGBA_32BPP){for(p=0,b=i*Ii*4,f=0;f<r;f++)u.set(d.subarray(c,c+b)),c+=b,a.putImageData(l,0,p),p+=Ii;f<o&&(b=i*n*4,u.set(d.subarray(c,c+b)),a.putImageData(l,0,p))}else if(t.kind===ff.RGB_24BPP)for(m=Ii,b=i*m,f=0;f<o;f++){for(f>=r&&(m=n,b=i*m),h=0,p=b;p--;)u[h++]=d[c++],u[h++]=d[c++],u[h++]=d[c++],u[h++]=255;a.putImageData(l,0,f*Ii)}else throw new Error(`bad image kind: ${t.kind}`)}function z0(a,t){if(t.bitmap){a.drawImage(t.bitmap,0,0);return}const e=t.height,i=t.width,n=e%Ii,r=(e-n)/Ii,o=n===0?r:r+1,l=a.createImageData(i,Ii);let c=0;const h=t.data,d=l.data;for(let u=0;u<o;u++){const f=u<r?Ii:n;({srcPos:c}=ME({src:h,srcPos:c,dest:d,width:i,height:f,nonBlackColor:0})),a.putImageData(l,0,u*Ii)}}function Mh(a,t){const e=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const i of e)a[i]!==void 0&&(t[i]=a[i]);a.setLineDash!==void 0&&(t.setLineDash(a.getLineDash()),t.lineDashOffset=a.lineDashOffset)}function Rf(a){a.strokeStyle=a.fillStyle="#000000",a.fillRule="nonzero",a.globalAlpha=1,a.lineWidth=1,a.lineCap="butt",a.lineJoin="miter",a.miterLimit=10,a.globalCompositeOperation="source-over",a.font="10px sans-serif",a.setLineDash!==void 0&&(a.setLineDash([]),a.lineDashOffset=0);const{filter:t}=a;t!=="none"&&t!==""&&(a.filter="none")}function U0(a,t){if(t)return!0;Z.singularValueDecompose2dScale(a,Ki);const e=Math.fround(ns.pixelRatio*Fr.PDF_TO_CSS_UNITS);return Ki[0]<=e&&Ki[1]<=e}const IE=["butt","round","square"],LE=["miter","round","bevel"],NE={},H0={},km=class km{constructor(t,e,i,n,r,{optionalContentConfig:o,markedContentStack:l=null},c,h,d){y(this,Wn);this.ctx=t,this.current=new B0(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=e,this.objs=i,this.canvasFactory=n,this.filterFactory=r,this.groupStack=[],this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=l||[],this.optionalContentConfig=o,this.cachedCanvases=new OE(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=c,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=h,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map,this.dependencyTracker=d??null}getObject(t,e,i=null){var n;return typeof e=="string"?((n=this.dependencyTracker)==null||n.recordNamedDependency(t,e),e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e)):i}beginDrawing({transform:t,viewport:e,transparency:i=!1,background:n=null}){const r=this.ctx.canvas.width,o=this.ctx.canvas.height,l=this.ctx.fillStyle;if(this.ctx.fillStyle=n||"#ffffff",this.ctx.fillRect(0,0,r,o),this.ctx.fillStyle=l,i){const c=this.cachedCanvases.getCanvas("transparent",r,o);this.compositeCtx=this.ctx,this.transparentCanvas=c.canvas,this.ctx=c.context,this.ctx.save(),this.ctx.transform(...ve(this.compositeCtx))}this.ctx.save(),Rf(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=ve(this.ctx)}executeOperatorList(t,e,i,n,r){var w;const o=t.argsArray,l=t.fnArray;let c=e||0;const h=o.length;if(h===c)return c;const d=h-c>F0&&typeof i=="function",u=d?Date.now()+RE:0;let f=0;const p=this.commonObjs,m=this.objs;let b,v;for(;;){if(n!==void 0&&c===n.nextBreakPoint)return n.breakIt(c,i),c;if(!r||r(c))if(b=l[c],v=o[c]??null,b!==wh.dependency)v===null?this[b](c):this[b](c,...v);else for(const _ of v){(w=this.dependencyTracker)==null||w.recordNamedData(_,c);const A=_.startsWith("g_")?p:m;if(!A.has(_))return A.get(_,i),c}if(c++,c===h)return c;if(d&&++f>F0){if(Date.now()>u)return i(),c;f=0}}}endDrawing(){S(this,Wn,nb).call(this),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const t of this._cachedBitmapsMap.values()){for(const e of t.values())typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement&&(e.width=e.height=0);t.clear()}this._cachedBitmapsMap.clear(),S(this,Wn,sb).call(this)}_scaleImage(t,e){const i=t.width??t.displayWidth,n=t.height??t.displayHeight;let r=Math.max(Math.hypot(e[0],e[1]),1),o=Math.max(Math.hypot(e[2],e[3]),1),l=i,c=n,h="prescale1",d,u;for(;r>2&&l>1||o>2&&c>1;){let f=l,p=c;r>2&&l>1&&(f=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),r/=l/f),o>2&&c>1&&(p=c>=16384?Math.floor(c/2)-1||1:Math.ceil(c)/2,o/=c/p),d=this.cachedCanvases.getCanvas(h,f,p),u=d.context,u.clearRect(0,0,f,p),u.drawImage(t,0,0,l,c,0,0,f,p),t=d.canvas,l=f,c=p,h=h==="prescale1"?"prescale2":"prescale1"}return{img:t,paintWidth:l,paintHeight:c}}_createMaskCanvas(t,e){var H,I;const i=this.ctx,{width:n,height:r}=e,o=this.current.fillColor,l=this.current.patternFill,c=ve(i);let h,d,u,f;if((e.bitmap||e.data)&&e.count>1){const ct=e.bitmap||e.data.buffer;d=JSON.stringify(l?c:[c.slice(0,4),o]),h=this._cachedBitmapsMap.get(ct),h||(h=new Map,this._cachedBitmapsMap.set(ct,h));const j=h.get(d);if(j&&!l){const K=Math.round(Math.min(c[0],c[2])+c[4]),st=Math.round(Math.min(c[1],c[3])+c[5]);return(H=this.dependencyTracker)==null||H.recordDependencies(t,Sn.transformAndFill),{canvas:j,offsetX:K,offsetY:st}}u=j}u||(f=this.cachedCanvases.getCanvas("maskCanvas",n,r),z0(f.context,e));let p=Z.transform(c,[1/n,0,0,-1/r,0,0]);p=Z.transform(p,[1,0,0,1,0,-r]);const m=_l.slice();Z.axialAlignedBoundingBox([0,0,n,r],p,m);const[b,v,w,_]=m,A=Math.round(w-b)||1,C=Math.round(_-v)||1,x=this.cachedCanvases.getCanvas("fillCanvas",A,C),P=x.context,R=b,N=v;P.translate(-R,-N),P.transform(...p),u||(u=this._scaleImage(f.canvas,is(P)),u=u.img,h&&l&&h.set(d,u)),P.imageSmoothingEnabled=U0(ve(P),e.interpolate),Mf(P,u,0,0,u.width,u.height,0,0,n,r),P.globalCompositeOperation="source-in";const z=Z.transform(is(P),[1,0,0,1,-R,-N]);return P.fillStyle=l?o.getPattern(i,this,z,ni.FILL,t):o,P.fillRect(0,0,n,r),h&&!l&&(this.cachedCanvases.delete("fillCanvas"),h.set(d,x.canvas)),(I=this.dependencyTracker)==null||I.recordDependencies(t,Sn.transformAndFill),{canvas:x.canvas,offsetX:Math.round(R),offsetY:Math.round(N)}}setLineWidth(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineWidth",t),e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineCap",t),this.ctx.lineCap=IE[e]}setLineJoin(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("lineJoin",t),this.ctx.lineJoin=LE[e]}setMiterLimit(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("miterLimit",t),this.ctx.miterLimit=e}setDash(t,e,i){var r;(r=this.dependencyTracker)==null||r.recordSimpleData("dash",t);const n=this.ctx;n.setLineDash!==void 0&&(n.setLineDash(e),n.lineDashOffset=i)}setRenderingIntent(t,e){}setFlatness(t,e){}setGState(t,e){var i,n,r,o,l;for(const[c,h]of e)switch(c){case"LW":this.setLineWidth(t,h);break;case"LC":this.setLineCap(t,h);break;case"LJ":this.setLineJoin(t,h);break;case"ML":this.setMiterLimit(t,h);break;case"D":this.setDash(t,h[0],h[1]);break;case"RI":this.setRenderingIntent(t,h);break;case"FL":this.setFlatness(t,h);break;case"Font":this.setFont(t,h[0],h[1]);break;case"CA":(i=this.dependencyTracker)==null||i.recordSimpleData("strokeAlpha",t),this.current.strokeAlpha=h;break;case"ca":(n=this.dependencyTracker)==null||n.recordSimpleData("fillAlpha",t),this.ctx.globalAlpha=this.current.fillAlpha=h;break;case"BM":(r=this.dependencyTracker)==null||r.recordSimpleData("globalCompositeOperation",t),this.ctx.globalCompositeOperation=h;break;case"SMask":(o=this.dependencyTracker)==null||o.recordSimpleData("SMask",t),this.current.activeSMask=h?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":(l=this.dependencyTracker)==null||l.recordSimpleData("filter",t),this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(h);break}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const t=this.inSMaskMode;this.current.activeSMask&&!t?this.beginSMaskMode():!this.current.activeSMask&&t&&this.endSMaskMode()}beginSMaskMode(t){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,i=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,i);this.suspendedCtx=this.ctx;const o=this.ctx=r.context;o.setTransform(this.suspendedCtx.getTransform()),Mh(this.suspendedCtx,o),DE(o,this.suspendedCtx),this.setGState(t,[["BM","source-over"]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),Mh(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(t){if(!this.current.activeSMask)return;t?(t[0]=Math.floor(t[0]),t[1]=Math.floor(t[1]),t[2]=Math.ceil(t[2]),t[3]=Math.ceil(t[3])):t=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const e=this.current.activeSMask,i=this.suspendedCtx;this.composeSMask(i,e,this.ctx,t),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(t,e,i,n){const r=n[0],o=n[1],l=n[2]-r,c=n[3]-o;l===0||c===0||(this.genericComposeSMask(e.context,i,l,c,e.subtype,e.backdrop,e.transferMap,r,o,e.offsetX,e.offsetY),t.save(),t.globalAlpha=1,t.globalCompositeOperation="source-over",t.setTransform(1,0,0,1,0,0),t.drawImage(i.canvas,0,0),t.restore())}genericComposeSMask(t,e,i,n,r,o,l,c,h,d,u){let f=t.canvas,p=c-d,m=h-u;if(o)if(p<0||m<0||p+i>f.width||m+n>f.height){const v=this.cachedCanvases.getCanvas("maskExtension",i,n),w=v.context;w.drawImage(f,-p,-m),w.globalCompositeOperation="destination-atop",w.fillStyle=o,w.fillRect(0,0,i,n),w.globalCompositeOperation="source-over",f=v.canvas,p=m=0}else{t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0);const v=new Path2D;v.rect(p,m,i,n),t.clip(v),t.globalCompositeOperation="destination-atop",t.fillStyle=o,t.fillRect(p,m,i,n),t.restore()}e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0),r==="Alpha"&&l?e.filter=this.filterFactory.addAlphaFilter(l):r==="Luminosity"&&(e.filter=this.filterFactory.addLuminosityFilter(l));const b=new Path2D;b.rect(c,h,i,n),e.clip(b),e.globalCompositeOperation="destination-in",e.drawImage(f,p,m,i,n,c,h,i,n),e.restore()}save(t){var i;this.inSMaskMode&&Mh(this.ctx,this.suspendedCtx),this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone(),(i=this.dependencyTracker)==null||i.save(t)}restore(t){var e;if((e=this.dependencyTracker)==null||e.restore(t),this.stateStack.length===0){this.inSMaskMode&&this.endSMaskMode();return}this.current=this.stateStack.pop(),this.ctx.restore(),this.inSMaskMode&&Mh(this.suspendedCtx,this.ctx),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}transform(t,e,i,n,r,o,l){var c;(c=this.dependencyTracker)==null||c.recordIncrementalData("transform",t),this.ctx.transform(e,i,n,r,o,l),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(t,e,i,n){let[r]=i;if(!n){r||(r=i[0]=new Path2D),this[e](t,r);return}if(this.dependencyTracker!==null){const o=e===wh.stroke?this.current.lineWidth/2:0;this.dependencyTracker.resetBBox(t).recordBBox(t,this.ctx,n[0]-o,n[2]+o,n[1]-o,n[3]+o).recordDependencies(t,["transform"])}r instanceof Path2D||(r=i[0]=y0(r)),Z.axialAlignedBoundingBox(n,ve(this.ctx),this.current.minMax),this[e](t,r),this._pathStartIdx=t}closePath(t){this.ctx.closePath()}stroke(t,e,i=!0){var o;const n=this.ctx,r=this.current.strokeColor;if(n.globalAlpha=this.current.strokeAlpha,this.contentVisible)if(typeof r=="object"&&(r!=null&&r.getPattern)){const l=r.isModifyingCurrentTransform()?n.getTransform():null;if(n.save(),n.strokeStyle=r.getPattern(n,this,is(n),ni.STROKE,t),l){const c=new Path2D;c.addPath(e,n.getTransform().invertSelf().multiplySelf(l)),e=c}this.rescaleAndStroke(e,!1),n.restore()}else this.rescaleAndStroke(e,!0);(o=this.dependencyTracker)==null||o.recordDependencies(t,Sn.stroke),i&&this.consumePath(t,e,this.current.getClippedPathBoundingBox(ni.STROKE,ve(this.ctx))),n.globalAlpha=this.current.fillAlpha}closeStroke(t,e){this.stroke(t,e)}fill(t,e,i=!0){var h,d,u;const n=this.ctx,r=this.current.fillColor,o=this.current.patternFill;let l=!1;if(o){const f=r.isModifyingCurrentTransform()?n.getTransform():null;if((h=this.dependencyTracker)==null||h.save(t),n.save(),n.fillStyle=r.getPattern(n,this,is(n),ni.FILL,t),f){const p=new Path2D;p.addPath(e,n.getTransform().invertSelf().multiplySelf(f)),e=p}l=!0}const c=this.current.getClippedPathBoundingBox();this.contentVisible&&c!==null&&(this.pendingEOFill?(n.fill(e,"evenodd"),this.pendingEOFill=!1):n.fill(e)),(d=this.dependencyTracker)==null||d.recordDependencies(t,Sn.fill),l&&(n.restore(),(u=this.dependencyTracker)==null||u.restore(t)),i&&this.consumePath(t,e,c)}eoFill(t,e){this.pendingEOFill=!0,this.fill(t,e)}fillStroke(t,e){this.fill(t,e,!1),this.stroke(t,e,!1),this.consumePath(t,e)}eoFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}closeFillStroke(t,e){this.fillStroke(t,e)}closeEOFillStroke(t,e){this.pendingEOFill=!0,this.fillStroke(t,e)}endPath(t,e){this.consumePath(t,e)}rawFillPath(t,e){var i;this.ctx.fill(e),(i=this.dependencyTracker)==null||i.recordDependencies(t,Sn.rawFillPath).recordOperation(t)}clip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=NE}eoClip(t){var e;(e=this.dependencyTracker)==null||e.recordFutureForcedDependency("clipMode",t),this.pendingClip=H0}beginText(t){var e;this.current.textMatrix=null,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0,(e=this.dependencyTracker)==null||e.recordOpenMarker(t).resetIncrementalData("sameLineText").resetIncrementalData("moveText",t)}endText(t){const e=this.pendingTextPaths,i=this.ctx;if(this.dependencyTracker){const{dependencyTracker:n}=this;e!==void 0&&n.recordFutureForcedDependency("textClip",n.getOpenMarker()).recordFutureForcedDependency("textClip",t),n.recordCloseMarker(t)}if(e!==void 0){const n=new Path2D,r=i.getTransform().invertSelf();for(const{transform:o,x:l,y:c,fontSize:h,path:d}of e)d&&n.addPath(d,new DOMMatrix(o).preMultiplySelf(r).translate(l,c).scale(h,-h));i.clip(n)}delete this.pendingTextPaths}setCharSpacing(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("charSpacing",t),this.current.charSpacing=e}setWordSpacing(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("wordSpacing",t),this.current.wordSpacing=e}setHScale(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("hScale",t),this.current.textHScale=e/100}setLeading(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("leading",t),this.current.leading=-e}setFont(t,e,i){var u,f;(u=this.dependencyTracker)==null||u.recordSimpleData("font",t).recordSimpleDataFromNamed("fontObj",e,t);const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||Og,(r.fontMatrix[0]===0||r.fontMatrix[3]===0)&&pt("Invalid font matrix for font "+e),i<0?(i=-i,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=i,n.isType3Font)return;const o=n.loadedName||"sans-serif",l=((f=n.systemFontInfo)==null?void 0:f.css)||`"${o}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const h=n.italic?"italic":"normal";let d=i;i<L0?d=L0:i>N0&&(d=N0),this.current.fontSizeScale=i/d,this.ctx.font=`${h} ${c} ${d}px ${l}`}setTextRenderingMode(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textRenderingMode",t),this.current.textRenderingMode=e}setTextRise(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("textRise",t),this.current.textRise=e}moveText(t,e,i){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordIncrementalData("moveText",t),this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=i}setLeadingMoveText(t,e,i){this.setLeading(t,-i),this.moveText(t,e,i)}setTextMatrix(t,e){var n;(n=this.dependencyTracker)==null||n.resetIncrementalData("sameLineText").recordSimpleData("textMatrix",t);const{current:i}=this;i.textMatrix=e,i.textMatrixScale=Math.hypot(e[0],e[1]),i.x=i.lineX=0,i.y=i.lineY=0}nextLine(t){var e;this.moveText(t,0,this.current.leading),(e=this.dependencyTracker)==null||e.recordIncrementalData("moveText",this.dependencyTracker.getSimpleIndex("leading")??t)}paintChar(t,e,i,n,r,o){var w,_,A,C;const l=this.ctx,c=this.current,h=c.font,d=c.textRenderingMode,u=c.fontSize/c.fontSizeScale,f=d&Be.FILL_STROKE_MASK,p=!!(d&Be.ADD_TO_PATH_FLAG),m=c.patternFill&&!h.missingFile,b=c.patternStroke&&!h.missingFile;let v;if((h.disableFontFace||p||m||b)&&!h.missingFile&&(v=h.getPathGenerator(this.commonObjs,e)),v&&(h.disableFontFace||m||b)){l.save(),l.translate(i,n),l.scale(u,-u),(w=this.dependencyTracker)==null||w.recordCharacterBBox(t,l,h);let x;if(f===Be.FILL||f===Be.FILL_STROKE)if(r){x=l.getTransform(),l.setTransform(...r);const P=S(this,Wn,rb).call(this,v,x,r);l.fill(P)}else l.fill(v);if(f===Be.STROKE||f===Be.FILL_STROKE)if(o){x||(x=l.getTransform()),l.setTransform(...o);const{a:P,b:R,c:N,d:z}=x,H=Z.inverseTransform(o),I=Z.transform([P,R,N,z,0,0],H);Z.singularValueDecompose2dScale(I,Ki),l.lineWidth*=Math.max(Ki[0],Ki[1])/u,l.stroke(S(this,Wn,rb).call(this,v,x,o))}else l.lineWidth/=u,l.stroke(v);l.restore()}else(f===Be.FILL||f===Be.FILL_STROKE)&&(l.fillText(e,i,n),(_=this.dependencyTracker)==null||_.recordCharacterBBox(t,l,h,u,i,n,()=>l.measureText(e))),(f===Be.STROKE||f===Be.FILL_STROKE)&&(this.dependencyTracker&&((A=this.dependencyTracker)==null||A.recordCharacterBBox(t,l,h,u,i,n,()=>l.measureText(e)).recordDependencies(t,Sn.stroke)),l.strokeText(e,i,n));p&&((this.pendingTextPaths||(this.pendingTextPaths=[])).push({transform:ve(l),x:i,y:n,fontSize:u,path:v}),(C=this.dependencyTracker)==null||C.recordCharacterBBox(t,l,h,u,i,n))}get isFontSubpixelAAEnabled(){const{context:t}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);t.scale(1.5,1),t.fillText("I",0,10);const e=t.getImageData(0,0,10,10).data;let i=!1;for(let n=3;n<e.length;n+=4)if(e[n]>0&&e[n]<255){i=!0;break}return gt(this,"isFontSubpixelAAEnabled",i)}showText(t,e){var I,ct,j,K;this.dependencyTracker&&(this.dependencyTracker.recordDependencies(t,Sn.showText).resetBBox(t),this.current.textRenderingMode&Be.ADD_TO_PATH_FLAG&&this.dependencyTracker.recordFutureForcedDependency("textClip",t).inheritPendingDependenciesAsFutureForcedDependencies());const i=this.current,n=i.font;if(n.isType3Font){this.showType3Text(t,e),(I=this.dependencyTracker)==null||I.recordShowTextOperation(t);return}const r=i.fontSize;if(r===0){(ct=this.dependencyTracker)==null||ct.recordOperation(t);return}const o=this.ctx,l=i.fontSizeScale,c=i.charSpacing,h=i.wordSpacing,d=i.fontDirection,u=i.textHScale*d,f=e.length,p=n.vertical,m=p?1:-1,b=n.defaultVMetrics,v=r*i.fontMatrix[0],w=i.textRenderingMode===Be.FILL&&!n.disableFontFace&&!i.patternFill;o.save(),i.textMatrix&&o.transform(...i.textMatrix),o.translate(i.x,i.y+i.textRise),d>0?o.scale(u,-1):o.scale(u,1);let _,A;const C=i.textRenderingMode&Be.FILL_STROKE_MASK,x=C===Be.FILL||C===Be.FILL_STROKE,P=C===Be.STROKE||C===Be.FILL_STROKE;if(x&&i.patternFill){o.save();const st=i.fillColor.getPattern(o,this,is(o),ni.FILL,t);_=ve(o),o.restore(),o.fillStyle=st}if(P&&i.patternStroke){o.save();const st=i.strokeColor.getPattern(o,this,is(o),ni.STROKE,t);A=ve(o),o.restore(),o.strokeStyle=st}let R=i.lineWidth;const N=i.textMatrixScale;if(N===0||R===0?P&&(R=this.getSinglePixelWidth()):R/=N,l!==1&&(o.scale(l,l),R/=l),o.lineWidth=R,n.isInvalidPDFjsFont){const st=[];let tt=0;for(const lt of e)st.push(lt.unicode),tt+=lt.width;const J=st.join("");if(o.fillText(J,0,0),this.dependencyTracker!==null){const lt=o.measureText(J);this.dependencyTracker.recordBBox(t,this.ctx,-lt.actualBoundingBoxLeft,lt.actualBoundingBoxRight,-lt.actualBoundingBoxAscent,lt.actualBoundingBoxDescent).recordShowTextOperation(t)}i.x+=tt*v*u,o.restore(),this.compose();return}let z=0,H;for(H=0;H<f;++H){const st=e[H];if(typeof st=="number"){z+=m*st*r/1e3;continue}let tt=!1;const J=(st.isSpace?h:0)+c,lt=st.fontChar,It=st.accent;let Rt,Bt,St=st.width;if(p){const Lt=st.vmetric||b,ee=-(st.vmetric?Lt[1]:St*.5)*v,Nt=Lt[2]*v;St=Lt?-Lt[0]:St,Rt=ee/l,Bt=(z+Nt)/l}else Rt=z/l,Bt=0;let xt;if(n.remeasure&&St>0){xt=o.measureText(lt);const Lt=xt.width*1e3/r*l;if(St<Lt&&this.isFontSubpixelAAEnabled){const ee=St/Lt;tt=!0,o.save(),o.scale(ee,1),Rt/=ee}else St!==Lt&&(Rt+=(St-Lt)/2e3*r/l)}if(this.contentVisible&&(st.isInFont||n.missingFile)){if(w&&!It)o.fillText(lt,Rt,Bt),(j=this.dependencyTracker)==null||j.recordCharacterBBox(t,o,xt?{bbox:null}:n,r/l,Rt,Bt,()=>xt??o.measureText(lt));else if(this.paintChar(t,lt,Rt,Bt,_,A),It){const Lt=Rt+r*It.offset.x/l,ee=Bt-r*It.offset.y/l;this.paintChar(t,It.fontChar,Lt,ee,_,A)}}const ye=p?St*v-J*d:St*v+J*d;z+=ye,tt&&o.restore()}p?i.y-=z:i.x+=z*u,o.restore(),this.compose(),(K=this.dependencyTracker)==null||K.recordShowTextOperation(t)}showType3Text(t,e){const i=this.ctx,n=this.current,r=n.font,o=n.fontSize,l=n.fontDirection,c=r.vertical?1:-1,h=n.charSpacing,d=n.wordSpacing,u=n.textHScale*l,f=n.fontMatrix||Og,p=e.length,m=n.textRenderingMode===Be.INVISIBLE;let b,v,w,_;if(m||o===0)return;this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,i.save(),n.textMatrix&&i.transform(...n.textMatrix),i.translate(n.x,n.y+n.textRise),i.scale(u,l);const A=this.dependencyTracker;for(this.dependencyTracker=A?new kf(A,t):null,b=0;b<p;++b){if(v=e[b],typeof v=="number"){_=c*v*o/1e3,this.ctx.translate(_,0),n.x+=_*u;continue}const C=(v.isSpace?d:0)+h,x=r.charProcOperatorList[v.operatorListId];x?this.contentVisible&&(this.save(),i.scale(o,o),i.transform(...f),this.executeOperatorList(x),this.restore()):pt(`Type3 character "${v.operatorListId}" is not available.`);const P=[v.width,0];Z.applyTransform(P,f),w=P[0]*o+C,i.translate(w,0),n.x+=w*u}i.restore(),A&&(this.dependencyTracker=A)}setCharWidth(t,e,i){}setCharWidthAndBounds(t,e,i,n,r,o,l){var h;const c=new Path2D;c.rect(n,r,o-n,l-r),this.ctx.clip(c),(h=this.dependencyTracker)==null||h.recordBBox(t,this.ctx,n,o,r,l).recordClipBox(t,this.ctx,n,o,r,l),this.endPath(t)}getColorN_Pattern(t,e){let i;if(e[0]==="TilingPattern"){const n=this.baseTransform||ve(this.ctx),r={createCanvasGraphics:(o,l)=>new km(o,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack},void 0,void 0,this.dependencyTracker?new kf(this.dependencyTracker,l,!0):null)};i=new nm(e,this.ctx,r,n)}else i=this._getPattern(t,e[1],e[2]);return i}setStrokeColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("strokeColor",t),this.current.strokeColor=this.getColorN_Pattern(t,e),this.current.patternStroke=!0}setFillColorN(t,...e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t),this.current.fillColor=this.getColorN_Pattern(t,e),this.current.patternFill=!0}setStrokeRGBColor(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor=e,this.current.patternStroke=!1}setStrokeTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("strokeColor",t),this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(t,e){var i;(i=this.dependencyTracker)==null||i.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor=e,this.current.patternFill=!1}setFillTransparent(t){var e;(e=this.dependencyTracker)==null||e.recordSimpleData("fillColor",t),this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(t,e,i=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=kE(this.getObject(t,e)),this.cachedPatterns.set(e,n)),i&&(n.matrix=i),n}shadingFill(t,e){var o;if(!this.contentVisible)return;const i=this.ctx;this.save(t);const n=this._getPattern(t,e);i.fillStyle=n.getPattern(i,this,is(i),ni.SHADING,t);const r=is(i);if(r){const{width:l,height:c}=i.canvas,h=_l.slice();Z.axialAlignedBoundingBox([0,0,l,c],r,h);const[d,u,f,p]=h;this.ctx.fillRect(d,u,f-d,p-u)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);(o=this.dependencyTracker)==null||o.resetBBox(t).recordFullPageBBox(t).recordDependencies(t,Sn.transform).recordDependencies(t,Sn.fill).recordOperation(t),this.compose(this.current.getClippedPathBoundingBox()),this.restore(t)}beginInlineImage(){ne("Should not call beginInlineImage")}beginImageData(){ne("Should not call beginImageData")}paintFormXObjectBegin(t,e,i){var n;if(this.contentVisible&&(this.save(t),this.baseTransformStack.push(this.baseTransform),e&&this.transform(t,...e),this.baseTransform=ve(this.ctx),i)){Z.axialAlignedBoundingBox(i,this.baseTransform,this.current.minMax);const[r,o,l,c]=i,h=new Path2D;h.rect(r,o,l-r,c-o),this.ctx.clip(h),(n=this.dependencyTracker)==null||n.recordClipBox(t,this.ctx,r,l,o,c),this.endPath(t)}}paintFormXObjectEnd(t){this.contentVisible&&(this.restore(t),this.baseTransform=this.baseTransformStack.pop())}beginGroup(t,e){var A;if(!this.contentVisible)return;this.save(t),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const i=this.ctx;e.isolated||mf("TODO: Support non-isolated groups."),e.knockout&&pt("Knockout groups not supported.");const n=ve(i);if(e.matrix&&i.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=_l.slice();Z.axialAlignedBoundingBox(e.bbox,ve(i),r);const o=[0,0,i.canvas.width,i.canvas.height];r=Z.intersect(r,o)||[0,0,0,0];const l=Math.floor(r[0]),c=Math.floor(r[1]),h=Math.max(Math.ceil(r[2])-l,1),d=Math.max(Math.ceil(r[3])-c,1);this.current.startNewPathAndClipBox([0,0,h,d]);let u="groupAt"+this.groupLevel;e.smask&&(u+="_smask_"+this.smaskCounter++%2);const f=this.cachedCanvases.getCanvas(u,h,d),p=f.context;p.translate(-l,-c),p.transform(...n);let m=new Path2D;const[b,v,w,_]=e.bbox;if(m.rect(b,v,w-b,_-v),e.matrix){const C=new Path2D;C.addPath(m,new DOMMatrix(e.matrix)),m=C}p.clip(m),e.smask&&this.smaskStack.push({canvas:f.canvas,context:p,offsetX:l,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}),(!e.smask||this.dependencyTracker)&&(i.setTransform(1,0,0,1,0,0),i.translate(l,c),i.save()),Mh(i,p),this.ctx=p,(A=this.dependencyTracker)==null||A.inheritSimpleDataAsFutureForcedDependencies(["fillAlpha","strokeAlpha","globalCompositeOperation"]).pushBaseTransform(i),this.setGState(t,[["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(i),this.groupLevel++}endGroup(t,e){var r;if(!this.contentVisible)return;this.groupLevel--;const i=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,(r=this.dependencyTracker)==null||r.popBaseTransform(),e.smask)this.tempSMask=this.smaskStack.pop(),this.restore(t),this.dependencyTracker&&this.ctx.restore();else{this.ctx.restore();const o=ve(this.ctx);this.restore(t),this.ctx.save(),this.ctx.setTransform(...o);const l=_l.slice();Z.axialAlignedBoundingBox([0,0,i.canvas.width,i.canvas.height],o,l),this.ctx.drawImage(i.canvas,0,0),this.ctx.restore(),this.compose(l)}}beginAnnotation(t,e,i,n,r,o){if(S(this,Wn,nb).call(this),Rf(this.ctx),this.ctx.save(),this.save(t),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),i){const l=i[2]-i[0],c=i[3]-i[1];if(o&&this.annotationCanvasMap){n=n.slice(),n[4]-=i[0],n[5]-=i[1],i=i.slice(),i[0]=i[1]=0,i[2]=l,i[3]=c,Z.singularValueDecompose2dScale(ve(this.ctx),Ki);const{viewportScale:h}=this,d=Math.ceil(l*this.outputScaleX*h),u=Math.ceil(c*this.outputScaleY*h);this.annotationCanvas=this.canvasFactory.create(d,u);const{canvas:f,context:p}=this.annotationCanvas;this.annotationCanvasMap.set(e,f),this.annotationCanvas.savedCtx=this.ctx,this.ctx=p,this.ctx.save(),this.ctx.setTransform(Ki[0],0,0,-Ki[1],0,c*Ki[1]),Rf(this.ctx)}else{Rf(this.ctx),this.endPath(t);const h=new Path2D;h.rect(i[0],i[1],l,c),this.ctx.clip(h)}}this.current=new B0(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(t,...n),this.transform(t,...r)}endAnnotation(t){this.annotationCanvas&&(this.ctx.restore(),S(this,Wn,sb).call(this),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(t,e){var l;if(!this.contentVisible)return;const i=e.count;e=this.getObject(t,e.data,e),e.count=i;const n=this.ctx,r=this._createMaskCanvas(t,e),o=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,r.offsetX,r.offsetY),(l=this.dependencyTracker)==null||l.resetBBox(t).recordBBox(t,this.ctx,r.offsetX,r.offsetX+o.width,r.offsetY,r.offsetY+o.height).recordOperation(t),n.restore(),this.compose()}paintImageMaskXObjectRepeat(t,e,i,n=0,r=0,o,l){var u,f,p;if(!this.contentVisible)return;e=this.getObject(t,e.data,e);const c=this.ctx;c.save();const h=ve(c);c.transform(i,n,r,o,0,0);const d=this._createMaskCanvas(t,e);c.setTransform(1,0,0,1,d.offsetX-h[4],d.offsetY-h[5]),(u=this.dependencyTracker)==null||u.resetBBox(t);for(let m=0,b=l.length;m<b;m+=2){const v=Z.transform(h,[i,n,r,o,l[m],l[m+1]]);c.drawImage(d.canvas,v[4],v[5]),(f=this.dependencyTracker)==null||f.recordBBox(t,this.ctx,v[4],v[4]+d.canvas.width,v[5],v[5]+d.canvas.height)}c.restore(),this.compose(),(p=this.dependencyTracker)==null||p.recordOperation(t)}paintImageMaskXObjectGroup(t,e){var o,l,c;if(!this.contentVisible)return;const i=this.ctx,n=this.current.fillColor,r=this.current.patternFill;(o=this.dependencyTracker)==null||o.resetBBox(t).recordDependencies(t,Sn.transformAndFill);for(const h of e){const{data:d,width:u,height:f,transform:p}=h,m=this.cachedCanvases.getCanvas("maskCanvas",u,f),b=m.context;b.save();const v=this.getObject(t,d,h);z0(b,v),b.globalCompositeOperation="source-in",b.fillStyle=r?n.getPattern(b,this,is(i),ni.FILL,t):n,b.fillRect(0,0,u,f),b.restore(),i.save(),i.transform(...p),i.scale(1,-1),Mf(i,m.canvas,0,0,u,f,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(t,i,0,u,0,f),i.restore()}this.compose(),(c=this.dependencyTracker)==null||c.recordOperation(t)}paintImageXObject(t,e){if(!this.contentVisible)return;const i=this.getObject(t,e);if(!i){pt("Dependent image isn't ready yet");return}this.paintInlineImageXObject(t,i)}paintImageXObjectRepeat(t,e,i,n,r){if(!this.contentVisible)return;const o=this.getObject(t,e);if(!o){pt("Dependent image isn't ready yet");return}const l=o.width,c=o.height,h=[];for(let d=0,u=r.length;d<u;d+=2)h.push({transform:[i,0,0,n,r[d],r[d+1]],x:0,y:0,w:l,h:c});this.paintInlineImageXObjectGroup(t,o,h)}applyTransferMapsToCanvas(t){return this.current.transferMaps!=="none"&&(t.filter=this.current.transferMaps,t.drawImage(t.canvas,0,0),t.filter="none"),t.canvas}applyTransferMapsToBitmap(t){if(this.current.transferMaps==="none")return t.bitmap;const{bitmap:e,width:i,height:n}=t,r=this.cachedCanvases.getCanvas("inlineImage",i,n),o=r.context;return o.filter=this.current.transferMaps,o.drawImage(e,0,0),o.filter="none",r.canvas}paintInlineImageXObject(t,e){var h;if(!this.contentVisible)return;const i=e.width,n=e.height,r=this.ctx;this.save(t);const{filter:o}=r;o!=="none"&&o!==""&&(r.filter="none"),r.scale(1/i,-1/n);let l;if(e.bitmap)l=this.applyTransferMapsToBitmap(e);else if(typeof HTMLElement=="function"&&e instanceof HTMLElement||!e.data)l=e;else{const u=this.cachedCanvases.getCanvas("inlineImage",i,n).context;j0(u,e),l=this.applyTransferMapsToCanvas(u)}const c=this._scaleImage(l,is(r));r.imageSmoothingEnabled=U0(ve(r),e.interpolate),(h=this.dependencyTracker)==null||h.resetBBox(t).recordBBox(t,r,0,i,-n,0).recordDependencies(t,Sn.imageXObject).recordOperation(t),Mf(r,c.img,0,0,c.paintWidth,c.paintHeight,0,-n,i,n),this.compose(),this.restore(t)}paintInlineImageXObjectGroup(t,e,i){var o,l,c;if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const h=e.width,d=e.height,f=this.cachedCanvases.getCanvas("inlineImage",h,d).context;j0(f,e),r=this.applyTransferMapsToCanvas(f)}(o=this.dependencyTracker)==null||o.resetBBox(t);for(const h of i)n.save(),n.transform(...h.transform),n.scale(1,-1),Mf(n,r,h.x,h.y,h.w,h.h,0,-1,1,1),(l=this.dependencyTracker)==null||l.recordBBox(t,n,0,1,-1,0),n.restore();(c=this.dependencyTracker)==null||c.recordOperation(t),this.compose()}paintSolidColorImageMask(t){var e;this.contentVisible&&((e=this.dependencyTracker)==null||e.resetBBox(t).recordBBox(t,this.ctx,0,1,0,1).recordDependencies(t,Sn.fill).recordOperation(t),this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(t,e){}markPointProps(t,e,i){}beginMarkedContent(t,e){var i;(i=this.dependencyTracker)==null||i.beginMarkedContent(t),this.markedContentStack.push({visible:!0})}beginMarkedContentProps(t,e,i){var n;(n=this.dependencyTracker)==null||n.beginMarkedContent(t),e==="OC"?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(i)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(t){var e;(e=this.dependencyTracker)==null||e.endMarkedContent(t),this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(t){}endCompat(t){}consumePath(t,e,i){var o,l;const n=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(i);const r=this.ctx;this.pendingClip?(n||(this.pendingClip===H0?r.clip(e,"evenodd"):r.clip(e)),this.pendingClip=null,(o=this.dependencyTracker)==null||o.bboxToClipBoxDropOperation(t).recordFutureForcedDependency("clipPath",t)):(l=this.dependencyTracker)==null||l.recordOperation(t),this.current.startNewPathAndClipBox(this.current.clipBox)}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const t=ve(this.ctx);if(t[1]===0&&t[2]===0)this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(t[0]),Math.abs(t[3]));else{const e=Math.abs(t[0]*t[3]-t[2]*t[1]),i=Math.hypot(t[0],t[2]),n=Math.hypot(t[1],t[3]);this._cachedGetSinglePixelWidth=Math.max(i,n)/e}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(this._cachedScaleForStroking[0]===-1){const{lineWidth:t}=this.current,{a:e,b:i,c:n,d:r}=this.ctx.getTransform();let o,l;if(i===0&&n===0){const c=Math.abs(e),h=Math.abs(r);if(c===h)if(t===0)o=l=1/c;else{const d=c*t;o=l=d<1?1/d:1}else if(t===0)o=1/c,l=1/h;else{const d=c*t,u=h*t;o=d<1?1/d:1,l=u<1?1/u:1}}else{const c=Math.abs(e*r-i*n),h=Math.hypot(e,i),d=Math.hypot(n,r);if(t===0)o=d/c,l=h/c;else{const u=t*c;o=d>u?d/u:1,l=h>u?h/u:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=l}return this._cachedScaleForStroking}rescaleAndStroke(t,e){const{ctx:i,current:{lineWidth:n}}=this,[r,o]=this.getScaleForStroking();if(r===o){i.lineWidth=(n||1)*r,i.stroke(t);return}const l=i.getLineDash();e&&i.save(),i.scale(r,o),sm.a=1/r,sm.d=1/o;const c=new Path2D;if(c.addPath(t,sm),l.length>0){const h=Math.max(r,o);i.setLineDash(l.map(d=>d/h)),i.lineDashOffset/=h}i.lineWidth=n||1,i.stroke(c),e&&i.restore()}isContentVisible(){for(let t=this.markedContentStack.length-1;t>=0;t--)if(!this.markedContentStack[t].visible)return!1;return!0}};Wn=new WeakSet,nb=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)},sb=function(){if(this.pageColors){const t=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if(t!=="none"){const e=this.ctx.filter;this.ctx.filter=t,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=e}}},rb=function(t,e,i){const n=new Path2D;return n.addPath(t,new DOMMatrix(i).invertSelf().multiplySelf(e)),n};let Tl=km;for(const a in wh)Tl.prototype[a]!==void 0&&(Tl.prototype[wh[a]]=Tl.prototype[a]);class rs{static get workerPort(){return s(this,Cd)}static set workerPort(t){if(!(typeof Worker<"u"&&t instanceof Worker)&&t!==null)throw new Error("Invalid `workerPort` type.");g(this,Cd,t)}static get workerSrc(){return s(this,_d)}static set workerSrc(t){if(typeof t!="string")throw new Error("Invalid `workerSrc` type.");g(this,_d,t)}}Cd=new WeakMap,_d=new WeakMap,y(rs,Cd,null),y(rs,_d,"");class FE{constructor({parsedData:t,rawData:e}){y(this,pc);y(this,Td);g(this,pc,t),g(this,Td,e)}getRaw(){return s(this,Td)}get(t){return s(this,pc).get(t)??null}[Symbol.iterator](){return s(this,pc).entries()}}pc=new WeakMap,Td=new WeakMap;const Pl=Symbol("INTERNAL");class BE{constructor(t,{name:e,intent:i,usage:n,rbGroups:r}){y(this,Pd,!1);y(this,kd,!1);y(this,Md,!1);y(this,gc,!0);g(this,Pd,!!(t&qi.DISPLAY)),g(this,kd,!!(t&qi.PRINT)),this.name=e,this.intent=i,this.usage=n,this.rbGroups=r}get visible(){if(s(this,Md))return s(this,gc);if(!s(this,gc))return!1;const{print:t,view:e}=this.usage;return s(this,Pd)?(e==null?void 0:e.viewState)!=="OFF":s(this,kd)?(t==null?void 0:t.printState)!=="OFF":!0}_setVisible(t,e,i=!1){t!==Pl&&ne("Internal method `_setVisible` called."),g(this,Md,i),g(this,gc,e)}}Pd=new WeakMap,kd=new WeakMap,Md=new WeakMap,gc=new WeakMap;class jE{constructor(t,e=qi.DISPLAY){y(this,Rd);y(this,ro,null);y(this,Qt,new Map);y(this,mc,null);y(this,bc,null);if(this.renderingIntent=e,this.name=null,this.creator=null,t!==null){this.name=t.name,this.creator=t.creator,g(this,bc,t.order);for(const i of t.groups)s(this,Qt).set(i.id,new BE(e,i));if(t.baseState==="OFF")for(const i of s(this,Qt).values())i._setVisible(Pl,!1);for(const i of t.on)s(this,Qt).get(i)._setVisible(Pl,!0);for(const i of t.off)s(this,Qt).get(i)._setVisible(Pl,!1);g(this,mc,this.getHash())}}isVisible(t){if(s(this,Qt).size===0)return!0;if(!t)return mf("Optional content group not defined."),!0;if(t.type==="OCG")return s(this,Qt).has(t.id)?s(this,Qt).get(t.id).visible:(pt(`Optional content group not found: ${t.id}`),!0);if(t.type==="OCMD"){if(t.expression)return S(this,Rd,ob).call(this,t.expression);if(!t.policy||t.policy==="AnyOn"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(s(this,Qt).get(e).visible)return!0}return!1}else if(t.policy==="AllOn"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!s(this,Qt).get(e).visible)return!1}return!0}else if(t.policy==="AnyOff"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(!s(this,Qt).get(e).visible)return!0}return!1}else if(t.policy==="AllOff"){for(const e of t.ids){if(!s(this,Qt).has(e))return pt(`Optional content group not found: ${e}`),!0;if(s(this,Qt).get(e).visible)return!1}return!0}return pt(`Unknown optional content policy ${t.policy}.`),!0}return pt(`Unknown group type ${t.type}.`),!0}setVisibility(t,e=!0,i=!0){var r;const n=s(this,Qt).get(t);if(!n){pt(`Optional content group not found: ${t}`);return}if(i&&e&&n.rbGroups.length)for(const o of n.rbGroups)for(const l of o)l!==t&&((r=s(this,Qt).get(l))==null||r._setVisible(Pl,!1,!0));n._setVisible(Pl,!!e,!0),g(this,ro,null)}setOCGState({state:t,preserveRB:e}){let i;for(const n of t){switch(n){case"ON":case"OFF":case"Toggle":i=n;continue}const r=s(this,Qt).get(n);if(r)switch(i){case"ON":this.setVisibility(n,!0,e);break;case"OFF":this.setVisibility(n,!1,e);break;case"Toggle":this.setVisibility(n,!r.visible,e);break}}g(this,ro,null)}get hasInitialVisibility(){return s(this,mc)===null||this.getHash()===s(this,mc)}getOrder(){return s(this,Qt).size?s(this,bc)?s(this,bc).slice():[...s(this,Qt).keys()]:null}getGroup(t){return s(this,Qt).get(t)||null}getHash(){if(s(this,ro)!==null)return s(this,ro);const t=new A0;for(const[e,i]of s(this,Qt))t.update(`${e}:${i.visible}`);return g(this,ro,t.hexdigest())}[Symbol.iterator](){return s(this,Qt).entries()}}ro=new WeakMap,Qt=new WeakMap,mc=new WeakMap,bc=new WeakMap,Rd=new WeakSet,ob=function(t){const e=t.length;if(e<2)return!0;const i=t[0];for(let n=1;n<e;n++){const r=t[n];let o;if(Array.isArray(r))o=S(this,Rd,ob).call(this,r);else if(s(this,Qt).has(r))o=s(this,Qt).get(r).visible;else return pt(`Optional content group not found: ${r}`),!0;switch(i){case"And":if(!o)return!1;break;case"Or":if(o)return!0;break;case"Not":return!o;default:return!0}}return i==="And"};class zE{constructor(t,{disableRange:e=!1,disableStream:i=!1}){Mt(t,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:n,initialData:r,progressiveDone:o,contentDispositionFilename:l}=t;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=l,(r==null?void 0:r.length)>0){const c=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(c)}this._pdfDataRangeTransport=t,this._isStreamingSupported=!i,this._isRangeSupported=!e,this._contentLength=n,this._fullRequestReader=null,this._rangeReaders=[],t.addRangeListener((c,h)=>{this._onReceiveData({begin:c,chunk:h})}),t.addProgressListener((c,h)=>{this._onProgress({loaded:c,total:h})}),t.addProgressiveReadListener(c=>{this._onReceiveData({chunk:c})}),t.addProgressiveDoneListener(()=>{this._onProgressiveDone()}),t.transportReady()}_onReceiveData({begin:t,chunk:e}){const i=e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer;if(t===void 0)this._fullRequestReader?this._fullRequestReader._enqueue(i):this._queuedChunks.push(i);else{const n=this._rangeReaders.some(function(r){return r._begin!==t?!1:(r._enqueue(i),!0)});Mt(n,"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}_onProgress(t){var e,i,n,r;t.total===void 0?(i=(e=this._rangeReaders[0])==null?void 0:e.onProgress)==null||i.call(e,{loaded:t.loaded}):(r=(n=this._fullRequestReader)==null?void 0:n.onProgress)==null||r.call(n,{loaded:t.loaded,total:t.total})}_onProgressiveDone(){var t;(t=this._fullRequestReader)==null||t.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(t){const e=this._rangeReaders.indexOf(t);e>=0&&this._rangeReaders.splice(e,1)}getFullReader(){Mt(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const t=this._queuedChunks;return this._queuedChunks=null,new UE(this,t,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new HE(this,t,e);return this._pdfDataRangeTransport.requestDataRange(t,e),this._rangeReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeReaders.slice(0))i.cancel(t);this._pdfDataRangeTransport.abort()}}class UE{constructor(t,e,i=!1,n=null){this._stream=t,this._done=i||!1,this._filename=Ug(n)?n:null,this._queuedChunks=e||[],this._loaded=0;for(const r of this._queuedChunks)this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),t._fullRequestReader=this,this.onProgress=null}_enqueue(t){this._done||(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunks.push(t),this._loaded+=t.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class HE{constructor(t,e,i){this._stream=t,this._begin=e,this._end=i,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(t){if(!this._done){if(this._requests.length===0)this._queuedChunk=t;else{this._requests.shift().resolve({value:t,done:!1});for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function $E(a){let t=!0,e=i("filename\\*","i").exec(a);if(e){e=e[1];let d=l(e);return d=unescape(d),d=c(d),d=h(d),r(d)}if(e=o(a),e){const d=h(e);return r(d)}if(e=i("filename","i").exec(a),e){e=e[1];let d=l(e);return d=h(d),r(d)}function i(d,u){return new RegExp("(?:^|;)\\s*"+d+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',u)}function n(d,u){if(d){if(!/^[\x00-\xFF]+$/.test(u))return u;try{const f=new TextDecoder(d,{fatal:!0}),p=Sh(u);u=f.decode(p),t=!1}catch{}}return u}function r(d){return t&&/[\x80-\xff]/.test(d)&&(d=n("utf-8",d),t&&(d=n("iso-8859-1",d))),d}function o(d){const u=[];let f;const p=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;(f=p.exec(d))!==null;){let[,b,v,w]=f;if(b=parseInt(b,10),b in u){if(b===0)break;continue}u[b]=[v,w]}const m=[];for(let b=0;b<u.length&&b in u;++b){let[v,w]=u[b];w=l(w),v&&(w=unescape(w),b===0&&(w=c(w))),m.push(w)}return m.join("")}function l(d){if(d.startsWith('"')){const u=d.slice(1).split('\\"');for(let f=0;f<u.length;++f){const p=u[f].indexOf('"');p!==-1&&(u[f]=u[f].slice(0,p),u.length=f+1),u[f]=u[f].replaceAll(/\\(.)/g,"$1")}d=u.join('"')}return d}function c(d){const u=d.indexOf("'");if(u===-1)return d;const f=d.slice(0,u),m=d.slice(u+1).replace(/^[^']*'/,"");return n(f,m)}function h(d){return!d.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(d)?d:d.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,function(u,f,p,m){if(p==="q"||p==="Q")return m=m.replaceAll("_"," "),m=m.replaceAll(/=([0-9a-fA-F]{2})/g,function(b,v){return String.fromCharCode(parseInt(v,16))}),n(f,m);try{m=atob(m)}catch{}return n(f,m)})}return""}function $0(a,t){const e=new Headers;if(!a||!t||typeof t!="object")return e;for(const i in t){const n=t[i];n!==void 0&&e.append(i,n)}return e}function Df(a){var t;return((t=URL.parse(a))==null?void 0:t.origin)??null}function W0({responseHeaders:a,isHttp:t,rangeChunkSize:e,disableRange:i}){const n={allowRangeRequests:!1,suggestedLength:void 0},r=parseInt(a.get("Content-Length"),10);return!Number.isInteger(r)||(n.suggestedLength=r,r<=2*e)||i||!t||a.get("Accept-Ranges")!=="bytes"||(a.get("Content-Encoding")||"identity")!=="identity"||(n.allowRangeRequests=!0),n}function V0(a){const t=a.get("Content-Disposition");if(t){let e=$E(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(Ug(e))return e}return null}function Rh(a,t){return new bf(`Unexpected server response (${a}) while retrieving PDF "${t}".`,a,a===404||a===0&&t.startsWith("file:"))}function G0(a){return a===200||a===206}function Y0(a,t,e){return{method:"GET",headers:a,signal:e.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function X0(a){return a instanceof Uint8Array?a.buffer:a instanceof ArrayBuffer?a:(pt(`getArrayBuffer - unexpected data format: ${a}`),new Uint8Array(a).buffer)}class WE{constructor(t){W(this,"_responseOrigin",null);this.source=t,this.isHttp=/^https?:/i.test(t.url),this.headers=$0(this.isHttp,t.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Mt(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new VE(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new GE(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class VE{constructor(t){this._stream=t,this._reader=null,this._loaded=0,this._filename=null;const e=t.source;this._withCredentials=e.withCredentials||!1,this._contentLength=e.length,this._headersCapability=Promise.withResolvers(),this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange;const i=new Headers(t.headers),n=e.url;fetch(n,Y0(i,this._withCredentials,this._abortController)).then(r=>{if(t._responseOrigin=Df(r.url),!G0(r.status))throw Rh(r.status,n);this._reader=r.body.getReader(),this._headersCapability.resolve();const o=r.headers,{allowRangeRequests:l,suggestedLength:c}=W0({responseHeaders:o,isHttp:t.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=l,this._contentLength=c||this._contentLength,this._filename=V0(o),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new Nr("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 i;await this._headersCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded,total:this._contentLength}),{value:X0(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}class GE{constructor(t,e,i){this._stream=t,this._reader=null,this._loaded=0;const n=t.source;this._withCredentials=n.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!n.disableStream,this._abortController=new AbortController;const r=new Headers(t.headers);r.append("Range",`bytes=${e}-${i-1}`);const o=n.url;fetch(o,Y0(r,this._withCredentials,this._abortController)).then(l=>{const c=Df(l.url);if(c!==t._responseOrigin)throw new Error(`Expected range response-origin "${c}" to match "${t._responseOrigin}".`);if(!G0(l.status))throw Rh(l.status,o);this._readCapability.resolve(),this._reader=l.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){var i;await this._readCapability.promise;const{value:t,done:e}=await this._reader.read();return e?{value:t,done:e}:(this._loaded+=t.byteLength,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded}),{value:X0(t),done:!1})}cancel(t){var e;(e=this._reader)==null||e.cancel(t),this._abortController.abort()}}const rm=200,om=206;function YE(a){const t=a.response;return typeof t!="string"?t:Sh(t).buffer}class XE{constructor({url:t,httpHeaders:e,withCredentials:i}){W(this,"_responseOrigin",null);this.url=t,this.isHttp=/^https?:/i.test(t),this.headers=$0(this.isHttp,e),this.withCredentials=i||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(t){const e=new XMLHttpRequest,i=this.currXhrId++,n=this.pendingRequests[i]={xhr:e};e.open("GET",this.url),e.withCredentials=this.withCredentials;for(const[r,o]of this.headers)e.setRequestHeader(r,o);return this.isHttp&&"begin"in t&&"end"in t?(e.setRequestHeader("Range",`bytes=${t.begin}-${t.end-1}`),n.expectedStatus=om):n.expectedStatus=rm,e.responseType="arraybuffer",Mt(t.onError,"Expected `onError` callback to be provided."),e.onerror=()=>{t.onError(e.status)},e.onreadystatechange=this.onStateChange.bind(this,i),e.onprogress=this.onProgress.bind(this,i),n.onHeadersReceived=t.onHeadersReceived,n.onDone=t.onDone,n.onError=t.onError,n.onProgress=t.onProgress,e.send(null),i}onProgress(t,e){var n;const i=this.pendingRequests[t];i&&((n=i.onProgress)==null||n.call(i,e))}onStateChange(t,e){const i=this.pendingRequests[t];if(!i)return;const n=i.xhr;if(n.readyState>=2&&i.onHeadersReceived&&(i.onHeadersReceived(),delete i.onHeadersReceived),n.readyState!==4||!(t in this.pendingRequests))return;if(delete this.pendingRequests[t],n.status===0&&this.isHttp){i.onError(n.status);return}const r=n.status||rm;if(!(r===rm&&i.expectedStatus===om)&&r!==i.expectedStatus){i.onError(n.status);return}const l=YE(n);if(r===om){const c=n.getResponseHeader("Content-Range"),h=/bytes (\d+)-(\d+)\/(\d+)/.exec(c);h?i.onDone({begin:parseInt(h[1],10),chunk:l}):(pt('Missing or invalid "Content-Range" header.'),i.onError(0))}else l?i.onDone({begin:0,chunk:l}):i.onError(n.status)}getRequestXhr(t){return this.pendingRequests[t].xhr}isPendingRequest(t){return t in this.pendingRequests}abortRequest(t){const e=this.pendingRequests[t].xhr;delete this.pendingRequests[t],e.abort()}}class qE{constructor(t){this._source=t,this._manager=new XE(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 Mt(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new KE(this._manager,this._source),this._fullRequestReader}getRangeReader(t,e){const i=new JE(this._manager,t,e);return i.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class KE{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=Df(e.responseURL);const i=e.getAllResponseHeaders(),n=new Headers(i?i.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map(l=>{const[c,...h]=l.split(": ");return[c,h.join(": ")]}):[]),{allowRangeRequests:r,suggestedLength:o}=W0({responseHeaders:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});r&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=V0(n),this._isRangeSupported&&this._manager.abortRequest(t),this._headersCapability.resolve()}_onDone(t){if(t&&(this._requests.length>0?this._requests.shift().resolve({value:t.chunk,done:!1}):this._cachedChunks.push(t.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(t){this._storedError=Rh(t,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(t){var e;(e=this.onProgress)==null||e.call(this,{loaded:t.loaded,total:t.lengthComputable?t.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0,this._headersCapability.reject(t);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class JE{constructor(t,e,i){this._manager=t,this._url=t.url,this._requestId=t.request({begin:e,end:i,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){var e;const t=Df((e=this._manager.getRequestXhr(this._requestId))==null?void 0:e.responseURL);t!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${t}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){var t;(t=this.onClosed)==null||t.call(this,this)}_onDone(t){const e=t.chunk;this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunk=e,this._done=!0;for(const i of this._requests)i.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(t){this._storedError??(this._storedError=Rh(t,this._url));for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(t){var e;this.isStreamingSupported||(e=this.onProgress)==null||e.call(this,{loaded:t.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(this._queuedChunk!==null){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const t=Promise.withResolvers();return this._requests.push(t),t.promise}cancel(t){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const ZE=/^[a-z][a-z0-9\-+.]+:/i;function QE(a){if(ZE.test(a))return new URL(a);const t=process.getBuiltinModule("url");return new URL(t.pathToFileURL(a))}class tx{constructor(t){this.source=t,this.url=QE(t.url),Mt(this.url.protocol==="file:","PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){var t;return((t=this._fullRequestReader)==null?void 0:t._loaded)??0}getFullReader(){return Mt(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new ex(this),this._fullRequestReader}getRangeReader(t,e){if(e<=this._progressiveDataLength)return null;const i=new ix(this,t,e);return this._rangeRequestReaders.push(i),i}cancelAllRequests(t){var e;(e=this._fullRequestReader)==null||e.cancel(t);for(const i of this._rangeRequestReaders.slice(0))i.cancel(t)}}class ex{constructor(t){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null;const e=t.source;this._contentLength=e.length,this._loaded=0,this._filename=null,this._disableRange=e.disableRange||!1,this._rangeChunkSize=e.rangeChunkSize,!this._rangeChunkSize&&!this._disableRange&&(this._disableRange=!0),this._isStreamingSupported=!e.disableStream,this._isRangeSupported=!e.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const i=process.getBuiltinModule("fs");i.promises.lstat(this._url).then(n=>{this._contentLength=n.size,this._setReadableStream(i.createReadStream(this._url)),this._headersCapability.resolve()},n=>{n.code==="ENOENT"&&(n=Rh(0,this._url.href)),this._storedError=n,this._headersCapability.reject(n)})}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 i;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new Nr("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class ix{constructor(t,e,i){this._url=t.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const n=t.source;this._isStreamingSupported=!n.disableStream;const r=process.getBuiltinModule("fs");this._setReadableStream(r.createReadStream(this._url,{start:e,end:i-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){var i;if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const t=this._readableStream.read();return t===null?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=t.length,(i=this.onProgress)==null||i.call(this,{loaded:this._loaded}),{value:new Uint8Array(t).buffer,done:!1})}cancel(t){if(!this._readableStream){this._error(t);return}this._readableStream.destroy(t)}_error(t){this._storedError=t,this._readCapability.resolve()}_setReadableStream(t){this._readableStream=t,t.on("readable",()=>{this._readCapability.resolve()}),t.on("end",()=>{t.destroy(),this._done=!0,this._readCapability.resolve()}),t.on("error",e=>{this._error(e)}),this._storedError&&this._readableStream.destroy(this._storedError)}}const Dh=Symbol("INITIAL_DATA");class q0{constructor(){y(this,Dd);y(this,en,Object.create(null))}get(t,e=null){if(e){const n=S(this,Dd,ab).call(this,t);return n.promise.then(()=>e(n.data)),null}const i=s(this,en)[t];if(!i||i.data===Dh)throw new Error(`Requesting object that isn't resolved yet ${t}.`);return i.data}has(t){const e=s(this,en)[t];return!!e&&e.data!==Dh}delete(t){const e=s(this,en)[t];return!e||e.data===Dh?!1:(delete s(this,en)[t],!0)}resolve(t,e=null){const i=S(this,Dd,ab).call(this,t);i.data=e,i.resolve()}clear(){var t;for(const e in s(this,en)){const{data:i}=s(this,en)[e];(t=i==null?void 0:i.bitmap)==null||t.close()}g(this,en,Object.create(null))}*[Symbol.iterator](){for(const t in s(this,en)){const{data:e}=s(this,en)[t];e!==Dh&&(yield[t,e])}}}en=new WeakMap,Dd=new WeakSet,ab=function(t){var e;return(e=s(this,en))[t]||(e[t]={...Promise.withResolvers(),data:Dh})};const nx=1e5,K0=30,li=class li{constructor({textContentSource:t,container:e,viewport:i}){y(this,nr);y(this,oo,Promise.withResolvers());y(this,nn,null);y(this,Od,!1);y(this,Id,!!((hv=globalThis.FontInspector)!=null&&hv.enabled));y(this,Sa,null);y(this,ir,null);y(this,Ld,0);y(this,Nd,0);y(this,Ea,null);y(this,Fd,null);y(this,yc,0);y(this,ao,0);y(this,vc,Object.create(null));y(this,Bd,[]);y(this,wc,null);y(this,xa,[]);y(this,jd,new WeakMap);y(this,zd,null);var c;if(t instanceof ReadableStream)g(this,wc,t);else if(typeof t=="object")g(this,wc,new ReadableStream({start(h){h.enqueue(t),h.close()}}));else throw new Error('No "textContentSource" parameter specified.');g(this,nn,g(this,Fd,e)),g(this,ao,i.scale*ns.pixelRatio),g(this,yc,i.rotation),g(this,ir,{div:null,properties:null,ctx:null});const{pageWidth:n,pageHeight:r,pageX:o,pageY:l}=i.rawDims;g(this,zd,[1,0,0,-1,-o,l+r]),g(this,Nd,n),g(this,Ld,r),S(c=li,sn,sw).call(c),e.style.setProperty("--min-font-size",s(li,Sc)),zo(e,i),s(this,oo).promise.finally(()=>{s(li,Ec).delete(this),g(this,ir,null),g(this,vc,null)}).catch(()=>{})}static get fontFamilyMap(){const{isWindows:t,isFirefox:e}=je.platform;return gt(this,"fontFamilyMap",new Map([["sans-serif",`${t&&e?"Calibri, ":""}sans-serif`],["monospace",`${t&&e?"Lucida Console, ":""}monospace`]]))}render(){const t=()=>{s(this,Ea).read().then(({value:e,done:i})=>{if(i){s(this,oo).resolve();return}s(this,Sa)??g(this,Sa,e.lang),Object.assign(s(this,vc),e.styles),S(this,nr,iw).call(this,e.items),t()},s(this,oo).reject)};return g(this,Ea,s(this,wc).getReader()),s(li,Ec).add(this),t(),s(this,oo).promise}update({viewport:t,onBefore:e=null}){var r;const i=t.scale*ns.pixelRatio,n=t.rotation;if(n!==s(this,yc)&&(e==null||e(),g(this,yc,n),zo(s(this,Fd),{rotation:n})),i!==s(this,ao)){e==null||e(),g(this,ao,i);const o={div:null,properties:null,ctx:S(r=li,sn,Tp).call(r,s(this,Sa))};for(const l of s(this,xa))o.properties=s(this,jd).get(l),o.div=l,S(this,nr,lb).call(this,o)}}cancel(){var e;const t=new Nr("TextLayer task cancelled.");(e=s(this,Ea))==null||e.cancel(t).catch(()=>{}),g(this,Ea,null),s(this,oo).reject(t)}get textDivs(){return s(this,xa)}get textContentItemsStr(){return s(this,Bd)}static cleanup(){if(!(s(this,Ec).size>0)){s(this,Ac).clear();for(const{canvas:t}of s(this,Ca).values())t.remove();s(this,Ca).clear()}}};oo=new WeakMap,nn=new WeakMap,Od=new WeakMap,Id=new WeakMap,Sa=new WeakMap,ir=new WeakMap,Ld=new WeakMap,Nd=new WeakMap,Ea=new WeakMap,Fd=new WeakMap,yc=new WeakMap,ao=new WeakMap,vc=new WeakMap,Bd=new WeakMap,wc=new WeakMap,xa=new WeakMap,jd=new WeakMap,zd=new WeakMap,Ac=new WeakMap,Ca=new WeakMap,Ud=new WeakMap,Sc=new WeakMap,Ec=new WeakMap,nr=new WeakSet,iw=function(t){var n,r;if(s(this,Od))return;(r=s(this,ir)).ctx??(r.ctx=S(n=li,sn,Tp).call(n,s(this,Sa)));const e=s(this,xa),i=s(this,Bd);for(const o of t){if(e.length>nx){pt("Ignoring additional textDivs for performance reasons."),g(this,Od,!0);return}if(o.str===void 0){if(o.type==="beginMarkedContentProps"||o.type==="beginMarkedContent"){const l=s(this,nn);g(this,nn,document.createElement("span")),s(this,nn).classList.add("markedContent"),o.id&&s(this,nn).setAttribute("id",`${o.id}`),l.append(s(this,nn))}else o.type==="endMarkedContent"&&g(this,nn,s(this,nn).parentNode);continue}i.push(o.str),S(this,nr,nw).call(this,o)}},nw=function(t){var m;const e=document.createElement("span"),i={angle:0,canvasWidth:0,hasText:t.str!=="",hasEOL:t.hasEOL,fontSize:0};s(this,xa).push(e);const n=Z.transform(s(this,zd),t.transform);let r=Math.atan2(n[1],n[0]);const o=s(this,vc)[t.fontName];o.vertical&&(r+=Math.PI/2);let l=s(this,Id)&&o.fontSubstitution||o.fontFamily;l=li.fontFamilyMap.get(l)||l;const c=Math.hypot(n[2],n[3]),h=c*S(m=li,sn,rw).call(m,l,o,s(this,Sa));let d,u;r===0?(d=n[4],u=n[5]-h):(d=n[4]+h*Math.sin(r),u=n[5]-h*Math.cos(r));const f=e.style;f.left=`${(100*d/s(this,Nd)).toFixed(2)}%`,f.top=`${(100*u/s(this,Ld)).toFixed(2)}%`,f.setProperty("--font-height",`${c.toFixed(2)}px`),f.fontFamily=l,i.fontSize=c,e.setAttribute("role","presentation"),e.textContent=t.str,e.dir=t.dir,s(this,Id)&&(e.dataset.fontName=o.fontSubstitutionLoadedName||t.fontName),r!==0&&(i.angle=r*(180/Math.PI));let p=!1;if(t.str.length>1)p=!0;else if(t.str!==" "&&t.transform[0]!==t.transform[3]){const b=Math.abs(t.transform[0]),v=Math.abs(t.transform[3]);b!==v&&Math.max(b,v)/Math.min(b,v)>1.5&&(p=!0)}if(p&&(i.canvasWidth=o.vertical?t.height:t.width),s(this,jd).set(e,i),s(this,ir).div=e,s(this,ir).properties=i,S(this,nr,lb).call(this,s(this,ir)),i.hasText&&s(this,nn).append(e),i.hasEOL){const b=document.createElement("br");b.setAttribute("role","presentation"),s(this,nn).append(b)}},lb=function(t){var o;const{div:e,properties:i,ctx:n}=t,{style:r}=e;if(i.canvasWidth!==0&&i.hasText){const{fontFamily:l}=r,{canvasWidth:c,fontSize:h}=i;S(o=li,sn,cb).call(o,n,h*s(this,ao),l);const{width:d}=n.measureText(e.textContent);d>0&&r.setProperty("--scale-x",c*s(this,ao)/d)}i.angle!==0&&r.setProperty("--rotate",`${i.angle}deg`)},sn=new WeakSet,Tp=function(t=null){let e=s(this,Ca).get(t||(t=""));if(!e){const i=document.createElement("canvas");i.className="hiddenCanvasElement",i.lang=t,document.body.append(i),e=i.getContext("2d",{alpha:!1,willReadFrequently:!0}),s(this,Ca).set(t,e),s(this,Ud).set(e,{size:0,family:""})}return e},cb=function(t,e,i){const n=s(this,Ud).get(t);e===n.size&&i===n.family||(t.font=`${e}px ${i}`,n.size=e,n.family=i)},sw=function(){if(s(this,Sc)!==null)return;const t=document.createElement("div");t.style.opacity=0,t.style.lineHeight=1,t.style.fontSize="1px",t.style.position="absolute",t.textContent="X",document.body.append(t),g(this,Sc,t.getBoundingClientRect().height),t.remove()},rw=function(t,e,i){const n=s(this,Ac).get(t);if(n)return n;const r=S(this,sn,Tp).call(this,i);r.canvas.width=r.canvas.height=K0,S(this,sn,cb).call(this,r,K0,t);const o=r.measureText(""),l=o.fontBoundingBoxAscent,c=Math.abs(o.fontBoundingBoxDescent);r.canvas.width=r.canvas.height=0;let h=.8;return l?h=l/(l+c):(je.platform.isFirefox&&pt("Enable the `dom.textMetrics.fontBoundingBox.enabled` preference in `about:config` to improve TextLayer rendering."),e.ascent?h=e.ascent:e.descent&&(h=1+e.descent)),s(this,Ac).set(t,h),h},y(li,sn),y(li,Ac,new Map),y(li,Ca,new Map),y(li,Ud,new WeakMap),y(li,Sc,null),y(li,Ec,new Set);let Oh=li;const sx=100;function J0(a={}){typeof a=="string"||a instanceof URL?a={url:a}:(a instanceof ArrayBuffer||ArrayBuffer.isView(a))&&(a={data:a});const t=new am,{docId:e}=t,i=a.url?dE(a.url):null,n=a.data?uE(a.data):null,r=a.httpHeaders||null,o=a.withCredentials===!0,l=a.password??null,c=a.range instanceof Z0?a.range:null,h=Number.isInteger(a.rangeChunkSize)&&a.rangeChunkSize>0?a.rangeChunkSize:2**16;let d=a.worker instanceof Ih?a.worker:null;const u=a.verbosity,f=typeof a.docBaseUrl=="string"&&!yf(a.docBaseUrl)?a.docBaseUrl:null,p=Cf(a.cMapUrl),m=a.cMapPacked!==!1,b=a.CMapReaderFactory||(Si?wE:_0),v=Cf(a.iccUrl),w=Cf(a.standardFontDataUrl),_=a.StandardFontDataFactory||(Si?AE:k0),A=Cf(a.wasmUrl),C=a.WasmFactory||(Si?SE:R0),x=a.stopAtErrors!==!0,P=Number.isInteger(a.maxImageSize)&&a.maxImageSize>-1?a.maxImageSize:-1,R=a.isEvalSupported!==!1,N=typeof a.isOffscreenCanvasSupported=="boolean"?a.isOffscreenCanvasSupported:!Si,z=typeof a.isImageDecoderSupported=="boolean"?a.isImageDecoderSupported:!Si&&(je.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(a.canvasMaxAreaInBytes)?a.canvasMaxAreaInBytes:-1,I=typeof a.disableFontFace=="boolean"?a.disableFontFace:Si,ct=a.fontExtraProperties===!0,j=a.enableXfa===!0,K=a.ownerDocument||globalThis.document,st=a.disableRange===!0,tt=a.disableStream===!0,J=a.disableAutoFetch===!0,lt=a.pdfBug===!0,It=a.CanvasFactory||(Si?vE:mE),Rt=a.FilterFactory||(Si?yE:bE),Bt=a.enableHWA===!0,St=a.useWasm!==!1,xt=c?c.length:a.length??NaN,ye=typeof a.useSystemFonts=="boolean"?a.useSystemFonts:!Si&&!I,Lt=typeof a.useWorkerFetch=="boolean"?a.useWorkerFetch:!!(b===_0&&_===k0&&C===R0&&p&&w&&A&&_h(p,document.baseURI)&&_h(w,document.baseURI)&&_h(A,document.baseURI)),ee=null;BS(u);const Nt={canvasFactory:new It({ownerDocument:K,enableHWA:Bt}),filterFactory:new Rt({docId:e,ownerDocument:K}),cMapReaderFactory:Lt?null:new b({baseUrl:p,isCompressed:m}),standardFontDataFactory:Lt?null:new _({baseUrl:w}),wasmFactory:Lt?null:new C({baseUrl:A})};d||(d=Ih.create({verbosity:u,port:rs.workerPort}),t._worker=d);const Hi={docId:e,apiVersion:"5.4.530",data:n,password:l,disableAutoFetch:J,rangeChunkSize:h,length:xt,docBaseUrl:f,enableXfa:j,evaluatorOptions:{maxImageSize:P,disableFontFace:I,ignoreErrors:x,isEvalSupported:R,isOffscreenCanvasSupported:N,isImageDecoderSupported:z,canvasMaxAreaInBytes:H,fontExtraProperties:ct,useSystemFonts:ye,useWasm:St,useWorkerFetch:Lt,cMapUrl:p,iccUrl:v,standardFontDataUrl:w,wasmUrl:A}},ke={ownerDocument:K,pdfBug:lt,styleElement:ee,loadingParams:{disableAutoFetch:J,enableXfa:j}};return d.promise.then(function(){if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const vi=d.messageHandler.sendWithPromise("GetDocRequest",Hi,n?[n.buffer]:null);let wi;if(c)wi=new zE(c,{disableRange:st,disableStream:tt});else if(!n){if(!i)throw new Error("getDocument - no `url` parameter provided.");const it=_h(i)?WE:Si?tx:qE;wi=new it({url:i,length:xt,httpHeaders:r,withCredentials:o,rangeChunkSize:h,disableRange:st,disableStream:tt})}return vi.then(it=>{if(t.destroyed)throw new Error("Loading aborted");if(d.destroyed)throw new Error("Worker was destroyed");const $i=new kh(e,it,d.port),rt=new ax($i,t,wi,ke,Nt,Bt);t._transport=rt,$i.send("Ready",null)})}).catch(t._capability.reject),t}const Zf=class Zf{constructor(){W(this,"_capability",Promise.withResolvers());W(this,"_transport",null);W(this,"_worker",null);W(this,"docId",`d${Ge(Zf,Jf)._++}`);W(this,"destroyed",!1);W(this,"onPassword",null);W(this,"onProgress",null)}get promise(){return this._capability.promise}async destroy(){var t,e,i,n;this.destroyed=!0;try{(t=this._worker)!=null&&t.port&&(this._worker._pendingDestroy=!0),await((e=this._transport)==null?void 0:e.destroy())}catch(r){throw(i=this._worker)!=null&&i.port&&delete this._worker._pendingDestroy,r}this._transport=null,(n=this._worker)==null||n.destroy(),this._worker=null}async getData(){return this._transport.getData()}};Jf=new WeakMap,y(Zf,Jf,0);let am=Zf;class Z0{constructor(t,e,i=!1,n=null){y(this,_a,Promise.withResolvers());y(this,Hd,[]);y(this,$d,[]);y(this,Wd,[]);y(this,Vd,[]);this.length=t,this.initialData=e,this.progressiveDone=i,this.contentDispositionFilename=n}addRangeListener(t){s(this,Vd).push(t)}addProgressListener(t){s(this,Wd).push(t)}addProgressiveReadListener(t){s(this,$d).push(t)}addProgressiveDoneListener(t){s(this,Hd).push(t)}onDataRange(t,e){for(const i of s(this,Vd))i(t,e)}onDataProgress(t,e){s(this,_a).promise.then(()=>{for(const i of s(this,Wd))i(t,e)})}onDataProgressiveRead(t){s(this,_a).promise.then(()=>{for(const e of s(this,$d))e(t)})}onDataProgressiveDone(){s(this,_a).promise.then(()=>{for(const t of s(this,Hd))t()})}transportReady(){s(this,_a).resolve()}requestDataRange(t,e){ne("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}_a=new WeakMap,Hd=new WeakMap,$d=new WeakMap,Wd=new WeakMap,Vd=new WeakMap;class rx{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 gt(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(t){return this._transport.getPage(t)}getPageIndex(t){return this._transport.getPageIndex(t)}getDestinations(){return this._transport.getDestinations()}getDestination(t){return this._transport.getDestination(t)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getAnnotationsByType(t,e){return this._transport.getAnnotationsByType(t,e)}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getOptionalContentConfig(e)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}extractPages(t){return this._transport.extractPages(t)}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 ox{constructor(t,e,i,n=!1){y(this,Ta);y(this,sr,!1);this._pageIndex=t,this._pageInfo=e,this._transport=i,this._stats=n?new u0:null,this._pdfBug=n,this.commonObjs=i.commonObjs,this.objs=new q0,this._intentStates=new Map,this.destroyed=!1,this.recordedBBoxes=null}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:t,rotation:e=this.rotate,offsetX:i=0,offsetY:n=0,dontFlip:r=!1}={}){return new Ch({viewBox:this.view,userUnit:this.userUnit,scale:t,rotation:e,offsetX:i,offsetY:n,dontFlip:r})}getAnnotations({intent:t="display"}={}){const{renderingIntent:e}=this._transport.getRenderingIntent(t);return this._transport.getAnnotations(this._pageIndex,e)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return gt(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){var t;return((t=this._transport._htmlForXfa)==null?void 0:t.children[this._pageIndex])||null}render({canvasContext:t,canvas:e=t.canvas,viewport:i,intent:n="display",annotationMode:r=Lr.ENABLE,transform:o=null,background:l=null,optionalContentConfigPromise:c=null,annotationCanvasMap:h=null,pageColors:d=null,printAnnotationStorage:u=null,isEditing:f=!1,recordOperations:p=!1,operationsFilter:m=null}){var z,H,I;(z=this._stats)==null||z.time("Overall");const b=this._transport.getRenderingIntent(n,r,u,f),{renderingIntent:v,cacheKey:w}=b;g(this,sr,!1),c||(c=this._transport.getOptionalContentConfig(v));let _=this._intentStates.get(w);_||(_=Object.create(null),this._intentStates.set(w,_)),_.streamReaderCancelTimeout&&(clearTimeout(_.streamReaderCancelTimeout),_.streamReaderCancelTimeout=null);const A=!!(v&qi.PRINT);_.displayReadyCapability||(_.displayReadyCapability=Promise.withResolvers(),_.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(H=this._stats)==null||H.time("Page Request"),this._pumpOperatorList(b));const C=!!(this._pdfBug&&((I=globalThis.StepperManager)!=null&&I.enabled)),x=!this.recordedBBoxes&&(p||C),P=ct=>{var j,K;if(_.renderTasks.delete(R),x){const st=(j=R.gfx)==null?void 0:j.dependencyTracker.take();st&&(R.stepper&&R.stepper.setOperatorBBoxes(st,R.gfx.dependencyTracker.takeDebugMetadata()),p&&(this.recordedBBoxes=st))}A&&g(this,sr,!0),S(this,Ta,Vu).call(this),ct?(R.capability.reject(ct),this._abortOperatorList({intentState:_,reason:ct instanceof Error?ct:new Error(ct)})):R.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),(K=globalThis.Stats)!=null&&K.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},R=new lm({callback:P,params:{canvas:e,canvasContext:t,dependencyTracker:x?new xE(e,_.operatorList.length,C):null,viewport:i,transform:o,background:l},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:h,operatorList:_.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!A,pdfBug:this._pdfBug,pageColors:d,enableHWA:this._transport.enableHWA,operationsFilter:m});(_.renderTasks||(_.renderTasks=new Set)).add(R);const N=R.task;return Promise.all([_.displayReadyCapability.promise,c]).then(([ct,j])=>{var K;if(this.destroyed){P();return}if((K=this._stats)==null||K.time("Rendering"),!(j.renderingIntent&v))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");R.initializeGraphics({transparency:ct,optionalContentConfig:j}),R.operatorListChanged()}).catch(P),N}getOperatorList({intent:t="display",annotationMode:e=Lr.ENABLE,printAnnotationStorage:i=null,isEditing:n=!1}={}){var h;function r(){l.operatorList.lastChunk&&(l.opListReadCapability.resolve(l.operatorList),l.renderTasks.delete(c))}const o=this._transport.getRenderingIntent(t,e,i,n,!0);let l=this._intentStates.get(o.cacheKey);l||(l=Object.create(null),this._intentStates.set(o.cacheKey,l));let c;return l.opListReadCapability||(c=Object.create(null),c.operatorListChanged=r,l.opListReadCapability=Promise.withResolvers(),(l.renderTasks||(l.renderTasks=new Set)).add(c),l.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},(h=this._stats)==null||h.time("Page Request"),this._pumpOperatorList(o)),l.opListReadCapability.promise}streamTextContent({includeMarkedContent:t=!1,disableNormalization:e=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:t===!0,disableNormalization:e===!0},{highWaterMark:100,size(n){return n.items.length}})}getTextContent(t={}){if(this._transport._htmlForXfa)return this.getXfa().then(i=>Eh.textContent(i));const e=this.streamTextContent(t);return new Promise(function(i,n){function r(){o.read().then(function({value:c,done:h}){if(h){i(l);return}l.lang??(l.lang=c.lang),Object.assign(l.styles,c.styles),l.items.push(...c.items),r()},n)}const o=e.getReader(),l={items:[],styles:Object.create(null),lang:null};r()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const t=[];for(const e of this._intentStates.values())if(this._abortOperatorList({intentState:e,reason:new Error("Page was destroyed."),force:!0}),!e.opListReadCapability)for(const i of e.renderTasks)t.push(i.completed),i.cancel();return this.objs.clear(),g(this,sr,!1),Promise.all(t)}cleanup(t=!1){g(this,sr,!0);const e=S(this,Ta,Vu).call(this);return t&&e&&this._stats&&(this._stats=new u0),e}_startRenderPage(t,e){var n,r;const i=this._intentStates.get(e);i&&((n=this._stats)==null||n.timeEnd("Page Request"),(r=i.displayReadyCapability)==null||r.resolve(t))}_renderPageChunk(t,e){for(let i=0,n=t.length;i<n;i++)e.operatorList.fnArray.push(t.fnArray[i]),e.operatorList.argsArray.push(t.argsArray[i]);e.operatorList.lastChunk=t.lastChunk,e.operatorList.separateAnnots=t.separateAnnots;for(const i of e.renderTasks)i.operatorListChanged();t.lastChunk&&S(this,Ta,Vu).call(this)}_pumpOperatorList({renderingIntent:t,cacheKey:e,annotationStorageSerializable:i,modifiedIds:n}){const{map:r,transfer:o}=i,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:t,cacheKey:e,annotationStorage:r,modifiedIds:n},o).getReader(),h=this._intentStates.get(e);h.streamReader=c;const d=()=>{c.read().then(({value:u,done:f})=>{if(f){h.streamReader=null;return}this._transport.destroyed||(this._renderPageChunk(u,h),d())},u=>{if(h.streamReader=null,!this._transport.destroyed){if(h.operatorList){h.operatorList.lastChunk=!0;for(const f of h.renderTasks)f.operatorListChanged();S(this,Ta,Vu).call(this)}if(h.displayReadyCapability)h.displayReadyCapability.reject(u);else if(h.opListReadCapability)h.opListReadCapability.reject(u);else throw u}})};d()}_abortOperatorList({intentState:t,reason:e,force:i=!1}){if(t.streamReader){if(t.streamReaderCancelTimeout&&(clearTimeout(t.streamReaderCancelTimeout),t.streamReaderCancelTimeout=null),!i){if(t.renderTasks.size>0)return;if(e instanceof zg){let n=sx;e.extraDelay>0&&e.extraDelay<1e3&&(n+=e.extraDelay),t.streamReaderCancelTimeout=setTimeout(()=>{t.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:t,reason:e,force:!0})},n);return}}if(t.streamReader.cancel(new Nr(e.message)).catch(()=>{}),t.streamReader=null,!this._transport.destroyed){for(const[n,r]of this._intentStates)if(r===t){this._intentStates.delete(n);break}this.cleanup()}}}get stats(){return this._stats}}sr=new WeakMap,Ta=new WeakSet,Vu=function(){if(!s(this,sr)||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(),g(this,sr,!1),!0};const me=class me{constructor({name:t=null,port:e=null,verbosity:i=jS()}={}){y(this,Ci);y(this,lo,Promise.withResolvers());y(this,Vn,null);y(this,rr,null);y(this,Pa,null);if(this.name=t,this.destroyed=!1,this.verbosity=i,e){if(s(me,Ma).has(e))throw new Error("Cannot use more than one PDFWorker per port.");s(me,Ma).set(e,this),S(this,Ci,ow).call(this,e)}else S(this,Ci,aw).call(this)}get promise(){return s(this,lo).promise}get port(){return s(this,rr)}get messageHandler(){return s(this,Vn)}destroy(){var t,e;this.destroyed=!0,(t=s(this,Pa))==null||t.terminate(),g(this,Pa,null),s(me,Ma).delete(s(this,rr)),g(this,rr,null),(e=s(this,Vn))==null||e.destroy(),g(this,Vn,null)}static create(t){const e=s(this,Ma).get(t==null?void 0:t.port);if(e){if(e._pendingDestroy)throw new Error("PDFWorker.create - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return e}return new me(t)}static get workerSrc(){if(rs.workerSrc)return rs.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get _setupFakeWorkerGlobal(){return gt(this,"_setupFakeWorkerGlobal",(async()=>s(this,xc,kp)?s(this,xc,kp):(await import(this.workerSrc)).WorkerMessageHandler)())}};lo=new WeakMap,Vn=new WeakMap,rr=new WeakMap,Pa=new WeakMap,Qf=new WeakMap,ka=new WeakMap,Ma=new WeakMap,Ci=new WeakSet,Pp=function(){s(this,lo).resolve(),s(this,Vn).send("configure",{verbosity:this.verbosity})},ow=function(t){g(this,rr,t),g(this,Vn,new kh("main","worker",t)),s(this,Vn).on("ready",()=>{}),S(this,Ci,Pp).call(this)},aw=function(){if(s(me,ka)||s(me,xc,kp)){S(this,Ci,Gu).call(this);return}let{workerSrc:t}=me;try{me._isSameOrigin(window.location,t)||(t=me._createCDNWrapper(new URL(t,window.location).href));const e=new Worker(t,{type:"module"}),i=new kh("main","worker",e),n=()=>{r.abort(),i.destroy(),e.terminate(),this.destroyed?s(this,lo).reject(new Error("Worker was destroyed")):S(this,Ci,Gu).call(this)},r=new AbortController;e.addEventListener("error",()=>{s(this,Pa)||n()},{signal:r.signal}),i.on("test",l=>{if(r.abort(),this.destroyed||!l){n();return}g(this,Vn,i),g(this,rr,e),g(this,Pa,e),S(this,Ci,Pp).call(this)}),i.on("ready",l=>{if(r.abort(),this.destroyed){n();return}try{o()}catch{S(this,Ci,Gu).call(this)}});const o=()=>{const l=new Uint8Array;i.send("test",l,[l.buffer])};o();return}catch{mf("The worker has been disabled.")}S(this,Ci,Gu).call(this)},Gu=function(){s(me,ka)||(pt("Setting up fake worker."),g(me,ka,!0)),me._setupFakeWorkerGlobal.then(t=>{if(this.destroyed){s(this,lo).reject(new Error("Worker was destroyed"));return}const e=new gE;g(this,rr,e);const i=`fake${Ge(me,Qf)._++}`,n=new kh(i+"_worker",i,e);t.setup(n,e),g(this,Vn,new kh(i,i+"_worker",e)),S(this,Ci,Pp).call(this)}).catch(t=>{s(this,lo).reject(new Error(`Setting up fake worker failed: "${t.message}".`))})},xc=new WeakSet,kp=function(){var t;try{return((t=globalThis.pdfjsWorker)==null?void 0:t.WorkerMessageHandler)||null}catch{return null}},y(me,xc),y(me,Qf,0),y(me,ka,!1),y(me,Ma,new WeakMap),Si&&(g(me,ka,!0),rs.workerSrc||(rs.workerSrc="./pdf.worker.mjs")),me._isSameOrigin=(t,e)=>{const i=URL.parse(t);if(!(i!=null&&i.origin)||i.origin==="null")return!1;const n=new URL(e,i);return i.origin===n.origin},me._createCDNWrapper=t=>{const e=`await import("${t}");`;return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},me.fromPort=t=>{if(JS("`PDFWorker.fromPort` - please use `PDFWorker.create` instead."),!(t!=null&&t.port))throw new Error("PDFWorker.fromPort - invalid method signature.");return me.create(t)};let Ih=me;class ax{constructor(t,e,i,n,r,o){y(this,Ra);y(this,or,new Map);y(this,ys,new Map);y(this,Cc,new Map);y(this,_c,new Map);y(this,ar,null);this.messageHandler=t,this.loadingTask=e,this.commonObjs=new q0,this.fontLoader=new lE({ownerDocument:n.ownerDocument,styleElement:n.styleElement}),this.loadingParams=n.loadingParams,this._params=n,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.wasmFactory=r.wasmFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=i,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.enableHWA=o,this.setupMessageHandler()}get annotationStorage(){return gt(this,"annotationStorage",new Xg)}getRenderingIntent(t,e=Lr.ENABLE,i=null,n=!1,r=!1){let o=qi.DISPLAY,l=Yg;switch(t){case"any":o=qi.ANY;break;case"display":break;case"print":o=qi.PRINT;break;default:pt(`getRenderingIntent - invalid intent: ${t}`)}const c=o&qi.PRINT&&i instanceof S0?i:this.annotationStorage;switch(e){case Lr.DISABLE:o+=qi.ANNOTATIONS_DISABLE;break;case Lr.ENABLE:break;case Lr.ENABLE_FORMS:o+=qi.ANNOTATIONS_FORMS;break;case Lr.ENABLE_STORAGE:o+=qi.ANNOTATIONS_STORAGE,l=c.serializable;break;default:pt(`getRenderingIntent - invalid annotationMode: ${e}`)}n&&(o+=qi.IS_EDITING),r&&(o+=qi.OPLIST);const{ids:h,hash:d}=c.modifiedIds,u=[o,l.hash,d];return{renderingIntent:o,cacheKey:u.join("_"),annotationStorageSerializable:l,modifiedIds:h}}destroy(){var i;if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),(i=s(this,ar))==null||i.reject(new Error("Worker was destroyed during onPassword callback"));const t=[];for(const n of s(this,ys).values())t.push(n._destroy());s(this,ys).clear(),s(this,Cc).clear(),s(this,_c).clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const e=this.messageHandler.sendWithPromise("Terminate",null);return t.push(e),Promise.all(t).then(()=>{var n,r;this.commonObjs.clear(),this.fontLoader.clear(),s(this,or).clear(),this.filterFactory.destroy(),Oh.cleanup(),(n=this._networkStream)==null||n.cancelAllRequests(new Nr("Worker was terminated.")),(r=this.messageHandler)==null||r.destroy(),this.messageHandler=null,this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:t,loadingTask:e}=this;t.on("GetReader",(i,n)=>{Mt(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=r=>{this._lastProgress={loaded:r.loaded,total:r.total}},n.onPull=()=>{this._fullReader.read().then(function({value:r,done:o}){if(o){n.close();return}Mt(r instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(r),1,[r])}).catch(r=>{n.error(r)})},n.onCancel=r=>{this._fullReader.cancel(r),n.ready.catch(o=>{if(!this.destroyed)throw o})}}),t.on("ReaderHeadersReady",async i=>{var l;await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:o}=this._fullReader;return(!n||!r)&&(this._lastProgress&&((l=e.onProgress)==null||l.call(e,this._lastProgress)),this._fullReader.onProgress=c=>{var h;(h=e.onProgress)==null||h.call(e,{loaded:c.loaded,total:c.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:o}}),t.on("GetRangeReader",(i,n)=>{Mt(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const r=this._networkStream.getRangeReader(i.begin,i.end);if(!r){n.close();return}n.onPull=()=>{r.read().then(function({value:o,done:l}){if(l){n.close();return}Mt(o instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),n.enqueue(new Uint8Array(o),1,[o])}).catch(o=>{n.error(o)})},n.onCancel=o=>{r.cancel(o),n.ready.catch(l=>{if(!this.destroyed)throw l})}}),t.on("GetDoc",({pdfInfo:i})=>{this._numPages=i.numPages,this._htmlForXfa=i.htmlForXfa,delete i.htmlForXfa,e._capability.resolve(new rx(i,this))}),t.on("DocException",i=>{e._capability.reject(Oi(i))}),t.on("PasswordRequest",i=>{g(this,ar,Promise.withResolvers());try{if(!e.onPassword)throw Oi(i);const n=r=>{r instanceof Error?s(this,ar).reject(r):s(this,ar).resolve({password:r})};e.onPassword(n,i.code)}catch(n){s(this,ar).reject(n)}return s(this,ar).promise}),t.on("DataLoaded",i=>{var n;(n=e.onProgress)==null||n.call(e,{loaded:i.length,total:i.length}),this.downloadInfoCapability.resolve(i)}),t.on("StartRenderPage",i=>{if(this.destroyed)return;s(this,ys).get(i.pageIndex)._startRenderPage(i.transparency,i.cacheKey)}),t.on("commonobj",([i,n,r])=>{var o;if(this.destroyed||this.commonObjs.has(i))return null;switch(n){case"Font":if("error"in r){const f=r.error;pt(`Error during font loading: ${f}`),this.commonObjs.resolve(i,f);break}const l=new qg(r),c=this._params.pdfBug&&((o=globalThis.FontInspector)!=null&&o.enabled)?(f,p)=>globalThis.FontInspector.fontAdded(f,p):null,h=new cE(l,c,r.extra,r.charProcOperatorList);this.fontLoader.bind(h).catch(()=>t.sendWithPromise("FontFallback",{id:i})).finally(()=>{!h.fontExtraProperties&&h.data&&h.clearData(),this.commonObjs.resolve(i,h)});break;case"CopyLocalImage":const{imageRef:d}=r;Mt(d,"The imageRef must be defined.");for(const f of s(this,ys).values())for(const[,p]of f.objs)if((p==null?void 0:p.ref)===d)return p.dataLen?(this.commonObjs.resolve(i,structuredClone(p)),p.dataLen):null;break;case"FontPath":this.commonObjs.resolve(i,new hE(r));break;case"Image":this.commonObjs.resolve(i,r);break;case"Pattern":const u=new Kg(r);this.commonObjs.resolve(i,u.getIR());break;default:throw new Error(`Got unknown common object type ${n}`)}return null}),t.on("obj",([i,n,r,o])=>{var c;if(this.destroyed)return;const l=s(this,ys).get(n);if(!l.objs.has(i)){if(l._intentStates.size===0){(c=o==null?void 0:o.bitmap)==null||c.close();return}switch(r){case"Image":case"Pattern":l.objs.resolve(i,o);break;default:throw new Error(`Got unknown object type ${r}`)}}}),t.on("DocProgress",i=>{var n;this.destroyed||(n=e.onProgress)==null||n.call(e,{loaded:i.loaded,total:i.total})}),t.on("FetchBinaryData",async i=>{if(this.destroyed)throw new Error("Worker was destroyed.");const n=this[i.type];if(!n)throw new Error(`${i.type} not initialized, see the \`useWorkerFetch\` parameter.`);return n.fetch(i)})}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){var i;this.annotationStorage.size<=0&&pt("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:t,transfer:e}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:t,filename:((i=this._fullReader)==null?void 0:i.filename)??null},e).finally(()=>{this.annotationStorage.resetModified()})}extractPages(t){return this.messageHandler.sendWithPromise("ExtractPages",{pageInfos:t})}getPage(t){if(!Number.isInteger(t)||t<=0||t>this._numPages)return Promise.reject(new Error("Invalid page request."));const e=t-1,i=s(this,Cc).get(e);if(i)return i;const n=this.messageHandler.sendWithPromise("GetPage",{pageIndex:e}).then(r=>{if(this.destroyed)throw new Error("Transport destroyed");r.refStr&&s(this,_c).set(r.refStr,t);const o=new ox(e,r,this,this._params.pdfBug);return s(this,ys).set(e,o),o});return s(this,Cc).set(e,n),n}getPageIndex(t){return Jg(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 S(this,Ra,Yu).call(this,"GetFieldObjects")}hasJSActions(){return S(this,Ra,Yu).call(this,"HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(t){return typeof t!="string"?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:t})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getAnnotationsByType(t,e){return this.messageHandler.sendWithPromise("GetAnnotationsByType",{types:t,pageIndexesToSkip:e})}getDocJSActions(){return S(this,Ra,Yu).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 S(this,Ra,Yu).call(this,"GetOptionalContentConfig").then(e=>new jE(e,t))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const t="GetMetadata",e=s(this,or).get(t);if(e)return e;const i=this.messageHandler.sendWithPromise(t,null).then(n=>{var r,o;return{info:n[0],metadata:n[1]?new FE(n[1]):null,contentDispositionFilename:((r=this._fullReader)==null?void 0:r.filename)??null,contentLength:((o=this._fullReader)==null?void 0:o.contentLength)??null,hasStructTree:n[2]}});return s(this,or).set(t,i),i}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(t=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of s(this,ys).values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),t||this.fontLoader.clear(),s(this,or).clear(),this.filterFactory.destroy(!0),Oh.cleanup()}}cachedPageNumber(t){if(!Jg(t))return null;const e=t.gen===0?`${t.num}R`:`${t.num}R${t.gen}`;return s(this,_c).get(e)??null}}or=new WeakMap,ys=new WeakMap,Cc=new WeakMap,_c=new WeakMap,ar=new WeakMap,Ra=new WeakSet,Yu=function(t,e=null){const i=s(this,or).get(t);if(i)return i;const n=this.messageHandler.sendWithPromise(t,e);return s(this,or).set(t,n),n};class lx{constructor(t){y(this,co,null);W(this,"onContinue",null);W(this,"onError",null);g(this,co,t)}get promise(){return s(this,co).capability.promise}cancel(t=0){s(this,co).cancel(null,t)}get separateAnnots(){const{separateAnnots:t}=s(this,co).operatorList;if(!t)return!1;const{annotationCanvasMap:e}=s(this,co);return t.form||t.canvas&&(e==null?void 0:e.size)>0}}co=new WeakMap;const Oa=class Oa{constructor({callback:t,params:e,objs:i,commonObjs:n,annotationCanvasMap:r,operatorList:o,pageIndex:l,canvasFactory:c,filterFactory:h,useRequestAnimationFrame:d=!1,pdfBug:u=!1,pageColors:f=null,enableHWA:p=!1,operationsFilter:m=null}){y(this,ho,null);this.callback=t,this.params=e,this.objs=i,this.commonObjs=n,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=l,this.canvasFactory=c,this.filterFactory=h,this._pdfBug=u,this.pageColors=f,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=d===!0&&typeof window<"u",this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new lx(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=p,this._dependencyTracker=e.dependencyTracker,this._operationsFilter=m}get completed(){return this.capability.promise.catch(function(){})}initializeGraphics({transparency:t=!1,optionalContentConfig:e}){var c,h;if(this.cancelled)return;if(this._canvas){if(s(Oa,Da).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.");s(Oa,Da).add(this._canvas)}this._pdfBug&&((c=globalThis.StepperManager)!=null&&c.enabled)&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{viewport:i,transform:n,background:r,dependencyTracker:o}=this.params,l=this._canvasContext||this._canvas.getContext("2d",{alpha:!1,willReadFrequently:!this._enableHWA});this.gfx=new Tl(l,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:e},this.annotationCanvasMap,this.pageColors,o),this.gfx.beginDrawing({transform:n,viewport:i,transparency:t,background:r}),this.operatorListIdx=0,this.graphicsReady=!0,(h=this.graphicsReadyCallback)==null||h.call(this)}cancel(t=null,e=0){var i,n,r;this.running=!1,this.cancelled=!0,(i=this.gfx)==null||i.endDrawing(),s(this,ho)&&(window.cancelAnimationFrame(s(this,ho)),g(this,ho,null)),s(Oa,Da).delete(this._canvas),t||(t=new zg(`Rendering cancelled, page ${this._pageIndex+1}`,e)),this.callback(t),(r=(n=this.task).onError)==null||r.call(n,t)}operatorListChanged(){var t,e;if(!this.graphicsReady){this.graphicsReadyCallback||(this.graphicsReadyCallback=this._continueBound);return}(t=this.gfx.dependencyTracker)==null||t.growOperationsCount(this.operatorList.fnArray.length),(e=this.stepper)==null||e.updateOperatorList(this.operatorList),!this.running&&this._continue()}_continue(){this.running=!0,!this.cancelled&&(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?g(this,ho,window.requestAnimationFrame(()=>{g(this,ho,null),this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper,this._operationsFilter),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),s(Oa,Da).delete(this._canvas),this.callback())))}};ho=new WeakMap,Da=new WeakMap,y(Oa,Da,new WeakSet);let lm=Oa;const Q0="5.4.530",cx="50cc4adac",ji=class ji{constructor({editor:t=null,uiManager:e=null}){y(this,te);y(this,rn,null);y(this,Ia,null);y(this,Tc);y(this,Ue,null);y(this,Gd,!1);y(this,Pc,!1);y(this,lr,null);y(this,Yd);y(this,uo,null);y(this,Gn,null);var i,n;t?(g(this,Pc,!1),g(this,lr,t)):g(this,Pc,!0),g(this,Gn,(t==null?void 0:t._uiManager)||e),g(this,Yd,s(this,Gn)._eventBus),g(this,Tc,((i=t==null?void 0:t.color)==null?void 0:i.toUpperCase())||((n=s(this,Gn))==null?void 0:n.highlightColors.values().next().value)||"#FFFF98"),s(ji,Xd)||g(ji,Xd,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 gt(this,"_keyboardManager",new Ph([[["Escape","mac+Escape"],ji.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ji.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ji.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ji.prototype._moveToPrevious],[["Home","mac+Home"],ji.prototype._moveToBeginning],[["End","mac+End"],ji.prototype._moveToEnd]]))}renderButton(){const t=g(this,rn,document.createElement("button"));t.className="colorPicker",t.tabIndex="0",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),t.ariaHasPopup="true",s(this,lr)&&(t.ariaControls=`${s(this,lr).id}_colorpicker_dropdown`);const e=s(this,Gn)._signal;t.addEventListener("click",S(this,te,fl).bind(this),{signal:e}),t.addEventListener("keydown",S(this,te,ub).bind(this),{signal:e});const i=g(this,Ia,document.createElement("span"));return i.className="swatch",i.ariaHidden="true",i.style.backgroundColor=s(this,Tc),t.append(i),t}renderMainDropdown(){const t=g(this,Ue,S(this,te,hb).call(this));return t.ariaOrientation="horizontal",t.ariaLabelledBy="highlightColorPickerLabel",t}_colorSelectFromKeyboard(t){if(t.target===s(this,rn)){S(this,te,fl).call(this,t);return}const e=t.target.getAttribute("data-color");e&&S(this,te,db).call(this,e,t)}_moveToNext(t){var e,i;if(!s(this,te,Io)){S(this,te,fl).call(this,t);return}if(t.target===s(this,rn)){(e=s(this,Ue).firstElementChild)==null||e.focus();return}(i=t.target.nextSibling)==null||i.focus()}_moveToPrevious(t){var e,i;if(t.target===((e=s(this,Ue))==null?void 0:e.firstElementChild)||t.target===s(this,rn)){s(this,te,Io)&&this._hideDropdownFromKeyboard();return}s(this,te,Io)||S(this,te,fl).call(this,t),(i=t.target.previousSibling)==null||i.focus()}_moveToBeginning(t){var e;if(!s(this,te,Io)){S(this,te,fl).call(this,t);return}(e=s(this,Ue).firstElementChild)==null||e.focus()}_moveToEnd(t){var e;if(!s(this,te,Io)){S(this,te,fl).call(this,t);return}(e=s(this,Ue).lastElementChild)==null||e.focus()}hideDropdown(){var t,e;(t=s(this,Ue))==null||t.classList.add("hidden"),s(this,rn).ariaExpanded="false",(e=s(this,uo))==null||e.abort(),g(this,uo,null)}_hideDropdownFromKeyboard(){var t;if(!s(this,Pc)){if(!s(this,te,Io)){(t=s(this,lr))==null||t.unselect();return}this.hideDropdown(),s(this,rn).focus({preventScroll:!0,focusVisible:s(this,Gd)})}}updateColor(t){if(s(this,Ia)&&(s(this,Ia).style.backgroundColor=t),!s(this,Ue))return;const e=s(this,Gn).highlightColors.values();for(const i of s(this,Ue).children)i.ariaSelected=e.next().value===t.toUpperCase()}destroy(){var t,e;(t=s(this,rn))==null||t.remove(),g(this,rn,null),g(this,Ia,null),(e=s(this,Ue))==null||e.remove(),g(this,Ue,null)}};rn=new WeakMap,Ia=new WeakMap,Tc=new WeakMap,Ue=new WeakMap,Gd=new WeakMap,Pc=new WeakMap,lr=new WeakMap,Yd=new WeakMap,uo=new WeakMap,Gn=new WeakMap,Xd=new WeakMap,te=new WeakSet,hb=function(){const t=document.createElement("div"),e=s(this,Gn)._signal;t.addEventListener("contextmenu",wn,{signal:e}),t.className="dropdown",t.role="listbox",t.ariaMultiSelectable="false",t.ariaOrientation="vertical",t.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown"),s(this,lr)&&(t.id=`${s(this,lr).id}_colorpicker_dropdown`);for(const[i,n]of s(this,Gn).highlightColors){const r=document.createElement("button");r.tabIndex="0",r.role="option",r.setAttribute("data-color",n),r.title=i,r.setAttribute("data-l10n-id",s(ji,Xd)[i]);const o=document.createElement("span");r.append(o),o.className="swatch",o.style.backgroundColor=n,r.ariaSelected=n===s(this,Tc),r.addEventListener("click",S(this,te,db).bind(this,n),{signal:e}),t.append(r)}return t.addEventListener("keydown",S(this,te,ub).bind(this),{signal:e}),t},db=function(t,e){e.stopPropagation(),s(this,Yd).dispatch("switchannotationeditorparams",{source:this,type:kt.HIGHLIGHT_COLOR,value:t}),this.updateColor(t)},ub=function(t){ji._keyboardManager.exec(this,t)},fl=function(t){if(s(this,te,Io)){this.hideDropdown();return}if(g(this,Gd,t.detail===0),s(this,uo)||(g(this,uo,new AbortController),window.addEventListener("pointerdown",S(this,te,lw).bind(this),{signal:s(this,Gn).combinedSignal(s(this,uo))})),s(this,rn).ariaExpanded="true",s(this,Ue)){s(this,Ue).classList.remove("hidden");return}const e=g(this,Ue,S(this,te,hb).call(this));s(this,rn).append(e)},lw=function(t){var e;(e=s(this,Ue))!=null&&e.contains(t.target)||this.hideDropdown()},Io=function(){return s(this,Ue)&&!s(this,Ue).classList.contains("hidden")},y(ji,Xd,null);let Of=ji;const La=class La{constructor(t){y(this,vs,null);y(this,qd,null);y(this,kc,null);g(this,qd,t),g(this,kc,t._uiManager),s(La,Kd)||g(La,Kd,Object.freeze({freetext:"pdfjs-editor-color-picker-free-text-input",ink:"pdfjs-editor-color-picker-ink-input"}))}renderButton(){if(s(this,vs))return s(this,vs);const{editorType:t,colorType:e,color:i}=s(this,qd),n=g(this,vs,document.createElement("input"));return n.type="color",n.value=i||"#000000",n.className="basicColorPicker",n.tabIndex=0,n.setAttribute("data-l10n-id",s(La,Kd)[t]),n.addEventListener("input",()=>{s(this,kc).updateParams(e,n.value)},{signal:s(this,kc)._signal}),n}update(t){s(this,vs)&&(s(this,vs).value=t)}destroy(){var t;(t=s(this,vs))==null||t.remove(),g(this,vs,null)}hideDropdown(){}};vs=new WeakMap,qd=new WeakMap,kc=new WeakMap,Kd=new WeakMap,y(La,Kd,null);let If=La;function tv(a){return Math.floor(Math.max(0,Math.min(1,a))*255).toString(16).padStart(2,"0")}function Lh(a){return Math.max(0,Math.min(255,255*a))}class ev{static CMYK_G([t,e,i,n]){return["G",1-Math.min(1,.3*t+.59*i+.11*e+n)]}static G_CMYK([t]){return["CMYK",0,0,0,1-t]}static G_RGB([t]){return["RGB",t,t,t]}static G_rgb([t]){return t=Lh(t),[t,t,t]}static G_HTML([t]){const e=tv(t);return`#${e}${e}${e}`}static RGB_G([t,e,i]){return["G",.3*t+.59*e+.11*i]}static RGB_rgb(t){return t.map(Lh)}static RGB_HTML(t){return`#${t.map(tv).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([t,e,i,n]){return["RGB",1-Math.min(1,t+n),1-Math.min(1,i+n),1-Math.min(1,e+n)]}static CMYK_rgb([t,e,i,n]){return[Lh(1-Math.min(1,t+n)),Lh(1-Math.min(1,i+n)),Lh(1-Math.min(1,e+n))]}static CMYK_HTML(t){const e=this.CMYK_RGB(t).slice(1);return this.RGB_HTML(e)}static RGB_CMYK([t,e,i]){const n=1-t,r=1-e,o=1-i,l=Math.min(n,r,o);return["CMYK",n,r,o,l]}}class hx{create(t,e,i=!1){if(t<=0||e<=0)throw new Error("Invalid SVG dimensions");const n=this._createSVG("svg:svg");return n.setAttribute("version","1.1"),i||(n.setAttribute("width",`${t}px`),n.setAttribute("height",`${e}px`)),n.setAttribute("preserveAspectRatio","none"),n.setAttribute("viewBox",`0 0 ${t} ${e}`),n}createElement(t){if(typeof t!="string")throw new Error("Invalid SVG element type");return this._createSVG(t)}_createSVG(t){ne("Abstract method `_createSVG` called.")}}class Lf extends hx{_createSVG(t){return document.createElementNS(Is,t)}}const dx=9,Ho=new WeakSet,ux=new Date().getTimezoneOffset()*60*1e3;class cm{static create(t){switch(t.data.annotationType){case Oe.LINK:return new hm(t);case Oe.TEXT:return new px(t);case Oe.WIDGET:switch(t.data.fieldType){case"Tx":return new gx(t);case"Btn":return t.data.radioButton?new iv(t):t.data.checkBox?new bx(t):new yx(t);case"Ch":return new vx(t);case"Sig":return new mx(t)}return new $o(t);case Oe.POPUP:return new dm(t);case Oe.FREETEXT:return new nv(t);case Oe.LINE:return new Ax(t);case Oe.SQUARE:return new Sx(t);case Oe.CIRCLE:return new Ex(t);case Oe.POLYLINE:return new sv(t);case Oe.CARET:return new Cx(t);case Oe.INK:return new um(t);case Oe.POLYGON:return new xx(t);case Oe.HIGHLIGHT:return new rv(t);case Oe.UNDERLINE:return new _x(t);case Oe.SQUIGGLY:return new Tx(t);case Oe.STRIKEOUT:return new Px(t);case Oe.STAMP:return new ov(t);case Oe.FILEATTACHMENT:return new kx(t);default:return new we(t)}}}const Mm=class Mm{constructor(t,{isRenderable:e=!1,ignoreBorder:i=!1,createQuadrilaterals:n=!1}={}){y(this,Jd);y(this,Na,null);y(this,Mc,!1);y(this,On,null);this.isRenderable=e,this.data=t.data,this.layer=t.layer,this.linkService=t.linkService,this.downloadManager=t.downloadManager,this.imageResourcesPath=t.imageResourcesPath,this.renderForms=t.renderForms,this.svgFactory=t.svgFactory,this.annotationStorage=t.annotationStorage,this.enableComment=t.enableComment,this.enableScripting=t.enableScripting,this.hasJSActions=t.hasJSActions,this._fieldObjects=t.fieldObjects,this.parent=t.parent,this.hasOwnCommentButton=!1,e&&(this.contentElement=this.container=this._createContainer(i)),n&&this._createQuadrilaterals()}static _hasPopupData({contentsObj:t,richText:e}){return!!(t!=null&&t.str||e!=null&&e.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Mm._hasPopupData(this.data)||this.enableComment&&!!this.commentText}get commentData(){var i;const{data:t}=this,e=(i=this.annotationStorage)==null?void 0:i.getEditor(t.id);return e?e.getData():t}get hasCommentButton(){return this.enableComment&&this.hasPopupElement}get commentButtonPosition(){var l;const t=(l=this.annotationStorage)==null?void 0:l.getEditor(this.data.id);if(t)return t.commentButtonPositionInPage;const{quadPoints:e,inkLists:i,rect:n}=this.data;let r=-1/0,o=-1/0;if((e==null?void 0:e.length)>=8){for(let c=0;c<e.length;c+=8)e[c+1]>o?(o=e[c+1],r=e[c+2]):e[c+1]===o&&(r=Math.max(r,e[c+2]));return[r,o]}if((i==null?void 0:i.length)>=1){for(const c of i)for(let h=0,d=c.length;h<d;h+=2)c[h+1]>o?(o=c[h+1],r=c[h]):c[h+1]===o&&(r=Math.max(r,c[h]));if(r!==1/0)return[r,o]}return n?[n[2],n[3]]:null}_normalizePoint(t){const{page:{view:e},viewport:{rawDims:{pageWidth:i,pageHeight:n,pageX:r,pageY:o}}}=this.parent;return t[1]=e[3]-t[1]+e[1],t[0]=100*(t[0]-r)/i,t[1]=100*(t[1]-o)/n,t}get commentText(){var e,i,n;const{data:t}=this;return((i=(e=this.annotationStorage.getRawValue(`${vh}${t.id}`))==null?void 0:e.popup)==null?void 0:i.contents)||((n=t.contentsObj)==null?void 0:n.str)||""}set commentText(t){const{data:e}=this,i={deleted:!t,contents:t||""};this.annotationStorage.updateEditor(e.id,{popup:i})||this.annotationStorage.setValue(`${vh}${e.id}`,{id:e.id,annotationType:e.annotationType,pageIndex:this.parent.page._pageIndex,popup:i,popupRef:e.popupRef,modificationDate:new Date}),t||this.removePopup()}removePopup(){var t,e;(e=((t=s(this,On))==null?void 0:t.popup)||this.popup)==null||e.remove(),g(this,On,this.popup=null)}updateEdited(t){var r;if(!this.container)return;t.rect&&(s(this,Na)||g(this,Na,{rect:this.data.rect.slice(0)}));const{rect:e,popup:i}=t;e&&S(this,Jd,fb).call(this,e);let n=((r=s(this,On))==null?void 0:r.popup)||this.popup;!n&&(i!=null&&i.text)&&(this._createPopup(i),n=s(this,On).popup),n&&(n.updateEdited(t),i!=null&&i.deleted&&(n.remove(),g(this,On,null),this.popup=null))}resetEdited(){var t;s(this,Na)&&(S(this,Jd,fb).call(this,s(this,Na).rect),(t=s(this,On))==null||t.popup.resetEdited(),g(this,Na,null))}_createContainer(t){const{data:e,parent:{page:i,viewport:n}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",e.id),!(this instanceof $o)&&!(this instanceof hm)&&(r.tabIndex=0);const{style:o}=r;if(o.zIndex=this.parent.zIndex,this.parent.zIndex+=2,e.alternativeText&&(r.title=e.alternativeText),e.noRotate&&r.classList.add("norotate"),!e.rect||this instanceof dm){const{rotation:b}=e;return!e.hasOwnCanvas&&b!==0&&this.setRotation(b,r),r}const{width:l,height:c}=this;if(!t&&e.borderStyle.width>0){o.borderWidth=`${e.borderStyle.width}px`;const b=e.borderStyle.horizontalCornerRadius,v=e.borderStyle.verticalCornerRadius;if(b>0||v>0){const _=`calc(${b}px * var(--total-scale-factor)) / calc(${v}px * var(--total-scale-factor))`;o.borderRadius=_}else if(this instanceof iv){const _=`calc(${l}px * var(--total-scale-factor)) / calc(${c}px * var(--total-scale-factor))`;o.borderRadius=_}switch(e.borderStyle.style){case El.SOLID:o.borderStyle="solid";break;case El.DASHED:o.borderStyle="dashed";break;case El.BEVELED:pt("Unimplemented border style: beveled");break;case El.INSET:pt("Unimplemented border style: inset");break;case El.UNDERLINE:o.borderBottomStyle="solid";break}const w=e.borderColor||null;w?(g(this,Mc,!0),o.borderColor=Z.makeHexColor(w[0]|0,w[1]|0,w[2]|0)):o.borderWidth=0}const h=Z.normalizeRect([e.rect[0],i.view[3]-e.rect[1]+i.view[1],e.rect[2],i.view[3]-e.rect[3]+i.view[1]]),{pageWidth:d,pageHeight:u,pageX:f,pageY:p}=n.rawDims;o.left=`${100*(h[0]-f)/d}%`,o.top=`${100*(h[1]-p)/u}%`;const{rotation:m}=e;return e.hasOwnCanvas||m===0?(o.width=`${100*l/d}%`,o.height=`${100*c/u}%`):this.setRotation(m,r),r}setRotation(t,e=this.container){if(!this.data.rect)return;const{pageWidth:i,pageHeight:n}=this.parent.viewport.rawDims;let{width:r,height:o}=this;t%180!==0&&([r,o]=[o,r]),e.style.width=`${100*r/i}%`,e.style.height=`${100*o/n}%`,e.setAttribute("data-main-rotation",(360-t)%360)}get _commonActions(){const t=(e,i,n)=>{const r=n.detail[e],o=r[0],l=r.slice(1);n.target.style[i]=ev[`${o}_HTML`](l),this.annotationStorage.setValue(this.data.id,{[i]:ev[`${o}_rgb`](l)})};return gt(this,"_commonActions",{display:e=>{const{display:i}=e.detail,n=i%2===1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:i===1||i===2})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:i}=e.detail;this.container.style.visibility=i?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:i,noView:i})},focus:e=>{setTimeout(()=>e.target.focus({preventScroll:!1}),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:e=>{t("bgColor","backgroundColor",e)},fillColor:e=>{t("fillColor","backgroundColor",e)},fgColor:e=>{t("fgColor","color",e)},textColor:e=>{t("textColor","color",e)},borderColor:e=>{t("borderColor","borderColor",e)},strokeColor:e=>{t("strokeColor","borderColor",e)},rotation:e=>{const i=e.detail.rotation;this.setRotation(i),this.annotationStorage.setValue(this.data.id,{rotation:i})}})}_dispatchEventFromSandbox(t,e){const i=this._commonActions;for(const n of Object.keys(e.detail)){const r=t[n]||i[n];r==null||r(e)}}_setDefaultPropertiesFromJS(t){if(!this.enableScripting)return;const e=this.annotationStorage.getRawValue(this.data.id);if(!e)return;const i=this._commonActions;for(const[n,r]of Object.entries(e)){const o=i[n];if(o){const l={detail:{[n]:r},target:t};o(l),delete e[n]}}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:t}=this.data;if(!t)return;const[e,i,n,r]=this.data.rect.map(b=>Math.fround(b));if(t.length===8){const[b,v,w,_]=t.subarray(2,6);if(n===b&&r===v&&e===w&&i===_)return}const{style:o}=this.container;let l;if(s(this,Mc)){const{borderColor:b,borderWidth:v}=o;o.borderWidth=0,l=["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="${b}" stroke-width="${v}">`],this.container.classList.add("hasBorder")}const c=n-e,h=r-i,{svgFactory:d}=this,u=d.createElement("svg");u.classList.add("quadrilateralsContainer"),u.setAttribute("width",0),u.setAttribute("height",0),u.role="none";const f=d.createElement("defs");u.append(f);const p=d.createElement("clipPath"),m=`clippath_${this.data.id}`;p.setAttribute("id",m),p.setAttribute("clipPathUnits","objectBoundingBox"),f.append(p);for(let b=2,v=t.length;b<v;b+=8){const w=t[b],_=t[b+1],A=t[b+2],C=t[b+3],x=d.createElement("rect"),P=(A-e)/c,R=(r-_)/h,N=(w-A)/c,z=(_-C)/h;x.setAttribute("x",P),x.setAttribute("y",R),x.setAttribute("width",N),x.setAttribute("height",z),p.append(x),l==null||l.push(`<rect vector-effect="non-scaling-stroke" x="${P}" y="${R}" width="${N}" height="${z}"/>`)}s(this,Mc)&&(l.push("</g></svg>')"),o.backgroundImage=l.join("")),this.container.append(u),this.container.style.clipPath=`url(#${m})`}_createPopup(t=null){const{data:e}=this;let i,n;t?(i={str:t.text},n=t.date):(i=e.contentsObj,n=e.modificationDate),g(this,On,new dm({data:{color:e.color,titleObj:e.titleObj,modificationDate:n,contentsObj:i,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation,noRotate:!0},linkService:this.linkService,parent:this.parent,elements:[this]}))}get hasPopupElement(){return!!(s(this,On)||this.popup||this.data.popupRef)}get extraPopupElement(){return s(this,On)}render(){ne("Abstract method `AnnotationElement.render` called")}_getElementsByName(t,e=null){const i=[];if(this._fieldObjects){const n=this._fieldObjects[t];if(n)for(const{page:r,id:o,exportValues:l}of n){if(r===-1||o===e)continue;const c=typeof l=="string"?l:null,h=document.querySelector(`[data-element-id="${o}"]`);if(h&&!Ho.has(h)){pt(`_getElementsByName - element not allowed: ${o}`);continue}i.push({id:o,exportValue:c,domElement:h})}return i}for(const n of document.getElementsByName(t)){const{exportValue:r}=n,o=n.getAttribute("data-element-id");o!==e&&Ho.has(n)&&i.push({id:o,exportValue:r,domElement:n})}return i}show(){var t;this.container&&(this.container.hidden=!1),(t=this.popup)==null||t.maybeShow()}hide(){var t;this.container&&(this.container.hidden=!0),(t=this.popup)==null||t.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const t=this.getElementsToTriggerPopup();if(Array.isArray(t))for(const e of t)e.classList.add("highlightArea");else t.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:t,data:{id:e}}=this;this.container.addEventListener("dblclick",()=>{var i;(i=this.linkService.eventBus)==null||i.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]}};Na=new WeakMap,Mc=new WeakMap,On=new WeakMap,Jd=new WeakSet,fb=function(t){const{container:{style:e},data:{rect:i,rotation:n},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:l,pageY:c}}}}=this;i==null||i.splice(0,4,...t),e.left=`${100*(t[0]-l)/r}%`,e.top=`${100*(o-t[3]+c)/o}%`,n===0?(e.width=`${100*(t[2]-t[0])/r}%`,e.height=`${100*(t[3]-t[1])/o}%`):this.setRotation(n)};let we=Mm;class fx extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.editor=t.editor}render(){return this.container.className="editorAnnotation",this.container}createOrUpdatePopup(){const{editor:t}=this;t.hasComment&&this._createPopup(t.comment)}get hasCommentButton(){return this.enableComment&&this.editor.hasComment}get commentButtonPosition(){return this.editor.commentButtonPositionInPage}get commentText(){return this.editor.comment.text}set commentText(t){this.editor.comment=t,t||this.removePopup()}get commentData(){return this.editor.getData()}remove(){this.parent.removeAnnotation(this.data.id),this.container.remove(),this.container=null,this.removePopup()}}class hm extends we{constructor(e,i=null){super(e,{isRenderable:!0,ignoreBorder:!!(i!=null&&i.ignoreBorder),createQuadrilaterals:!0});y(this,on);this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:i}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(i.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action,e.overlaidText),r=!0):e.attachment?(S(this,on,cw).call(this,n,e.attachment,e.overlaidText,e.attachmentDest),r=!0):e.setOCGState?(S(this,on,hw).call(this,n,e.setOCGState,e.overlaidText),r=!0):e.dest?(this._bindLink(n,e.dest,e.overlaidText),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&(this.contentElement=n,this.container.append(n)),this.container}_bindLink(e,i,n=""){e.href=this.linkService.getDestinationHash(i),e.onclick=()=>(i&&this.linkService.goToDestination(i),!1),(i||i==="")&&S(this,on,pl).call(this),n&&(e.title=n)}_bindNamedAction(e,i,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(i),!1),n&&(e.title=n),S(this,on,pl).call(this)}_bindJSAction(e,i){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(i.actions)){const o=n.get(r);o&&(e[o]=()=>{var l;return(l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:i.id,name:r}}),!1})}i.overlaidText&&(e.title=i.overlaidText),e.onclick||(e.onclick=()=>!1),S(this,on,pl).call(this)}_bindResetFormAction(e,i){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),S(this,on,pl).call(this),!this._fieldObjects){pt('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),n||(e.onclick=()=>!1);return}e.onclick=()=>{var u;n==null||n();const{fields:r,refs:o,include:l}=i,c=[];if(r.length!==0||o.length!==0){const f=new Set(o);for(const p of r){const m=this._fieldObjects[p]||[];for(const{id:b}of m)f.add(b)}for(const p of Object.values(this._fieldObjects))for(const m of p)f.has(m.id)===l&&c.push(m)}else for(const f of Object.values(this._fieldObjects))c.push(...f);const h=this.annotationStorage,d=[];for(const f of c){const{id:p}=f;switch(d.push(p),f.type){case"text":{const b=f.defaultValue||"";h.setValue(p,{value:b});break}case"checkbox":case"radiobutton":{const b=f.defaultValue===f.exportValues;h.setValue(p,{value:b});break}case"combobox":case"listbox":{const b=f.defaultValue||"";h.setValue(p,{value:b});break}default:continue}const m=document.querySelector(`[data-element-id="${p}"]`);if(m){if(!Ho.has(m)){pt(`_bindResetFormAction - element not allowed: ${p}`);continue}}else continue;m.dispatchEvent(new Event("resetform"))}return this.enableScripting&&((u=this.linkService.eventBus)==null||u.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:d,name:"ResetForm"}})),!1}}}on=new WeakSet,pl=function(){this.container.setAttribute("data-internal-link","")},cw=function(e,i,n="",r=null){e.href=this.linkService.getAnchorUrl(""),i.description?e.title=i.description:n&&(e.title=n),e.onclick=()=>{var o;return(o=this.downloadManager)==null||o.openOrDownloadData(i.content,i.filename,r),!1},S(this,on,pl).call(this)},hw=function(e,i,n=""){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(i),!1),n&&(e.title=n),S(this,on,pl).call(this)};class px extends we{constructor(t){super(t,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const t=document.createElement("img");return t.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",t.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),t.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(t),this.container}}class $o extends we{render(){return this.container}showElementAndHideCanvas(t){var e;this.data.hasOwnCanvas&&(((e=t.previousSibling)==null?void 0:e.nodeName)==="CANVAS"&&(t.previousSibling.hidden=!0),t.hidden=!1)}_getKeyModifier(t){return je.platform.isMac?t.metaKey:t.ctrlKey}_setEventListener(t,e,i,n,r){i.includes("mouse")?t.addEventListener(i,o=>{var l;(l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(o),shift:o.shiftKey,modifier:this._getKeyModifier(o)}})}):t.addEventListener(i,o=>{var l;if(i==="blur"){if(!e.focused||!o.relatedTarget)return;e.focused=!1}else if(i==="focus"){if(e.focused)return;e.focused=!0}r&&((l=this.linkService.eventBus)==null||l.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:n,value:r(o)}}))})}_setEventListeners(t,e,i,n){var r,o,l;for(const[c,h]of i)(h==="Action"||(r=this.data.actions)!=null&&r[h])&&((h==="Focus"||h==="Blur")&&(e||(e={focused:!1})),this._setEventListener(t,e,c,h,n),h==="Focus"&&!((o=this.data.actions)!=null&&o.Blur)?this._setEventListener(t,e,"blur","Blur",null):h==="Blur"&&!((l=this.data.actions)!=null&&l.Focus)&&this._setEventListener(t,e,"focus","Focus",null))}_setBackgroundColor(t){const e=this.data.backgroundColor||null;t.style.backgroundColor=e===null?"transparent":Z.makeHexColor(e[0],e[1],e[2])}_setTextStyle(t){const e=["left","center","right"],{fontColor:i}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||dx,r=t.style;let o;const l=2,c=h=>Math.round(10*h)/10;if(this.data.multiLine){const h=Math.abs(this.data.rect[3]-this.data.rect[1]-l),d=Math.round(h/(Ig*n))||1,u=h/d;o=Math.min(n,c(u/Ig))}else{const h=Math.abs(this.data.rect[3]-this.data.rect[1]-l);o=Math.min(n,c(h/Ig))}r.fontSize=`calc(${o}px * var(--total-scale-factor))`,r.color=Z.makeHexColor(i[0],i[1],i[2]),this.data.textAlignment!==null&&(r.textAlign=e[this.data.textAlignment])}_setRequired(t,e){e?t.setAttribute("required",!0):t.removeAttribute("required"),t.setAttribute("aria-required",e)}}class gx extends $o{constructor(t){const e=t.renderForms||t.data.hasOwnCanvas||!t.data.hasAppearance&&!!t.data.fieldValue;super(t,{isRenderable:e})}setPropertyOnSiblings(t,e,i,n){const r=this.annotationStorage;for(const o of this._getElementsByName(t.name,t.id))o.domElement&&(o.domElement[e]=i),r.setValue(o.id,{[n]:i})}render(){var n,r;const t=this.annotationStorage,e=this.data.id;this.container.classList.add("textWidgetAnnotation");let i=null;if(this.renderForms){const o=t.getValue(e,{value:this.data.fieldValue});let l=o.value||"";const c=t.getValue(e,{charLimit:this.data.maxLen}).charLimit;c&&l.length>c&&(l=l.slice(0,c));let h=o.formattedValue||((n=this.data.textContent)==null?void 0:n.join(`
101
+ `))||null;h&&this.data.comb&&(h=h.replaceAll(/\s+/g,""));const d={userValue:l,formattedValue:h,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(i=document.createElement("textarea"),i.textContent=h??l,this.data.doNotScroll&&(i.style.overflowY="hidden")):(i=document.createElement("input"),i.type=this.data.password?"password":"text",i.setAttribute("value",h??l),this.data.doNotScroll&&(i.style.overflowX="hidden")),this.data.hasOwnCanvas&&(i.hidden=!0),Ho.add(i),this.contentElement=i,i.setAttribute("data-element-id",e),i.disabled=this.data.readOnly,i.name=this.data.fieldName,i.tabIndex=0;const{datetimeFormat:u,datetimeType:f,timeStep:p}=this.data,m=!!f&&this.enableScripting;u&&(i.title=u),this._setRequired(i,this.data.required),c&&(i.maxLength=c),i.addEventListener("input",v=>{t.setValue(e,{value:v.target.value}),this.setPropertyOnSiblings(i,"value",v.target.value,"value"),d.formattedValue=null}),i.addEventListener("resetform",v=>{const w=this.data.defaultFieldValue??"";i.value=d.userValue=w,d.formattedValue=null});let b=v=>{const{formattedValue:w}=d;w!=null&&(v.target.value=w),v.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){i.addEventListener("focus",w=>{var A;if(d.focused)return;const{target:_}=w;if(m&&(_.type=f,p&&(_.step=p)),d.userValue){const C=d.userValue;if(m)if(f==="time"){const x=new Date(C),P=[x.getHours(),x.getMinutes(),x.getSeconds()];_.value=P.map(R=>R.toString().padStart(2,"0")).join(":")}else _.value=new Date(C-ux).toISOString().split(f==="date"?"T":".",1)[0];else _.value=C}d.lastCommittedValue=_.value,d.commitKey=1,(A=this.data.actions)!=null&&A.Focus||(d.focused=!0)}),i.addEventListener("updatefromsandbox",w=>{this.showElementAndHideCanvas(w.target);const _={value(A){d.userValue=A.detail.value??"",m||t.setValue(e,{value:d.userValue.toString()}),A.target.value=d.userValue},formattedValue(A){const{formattedValue:C}=A.detail;d.formattedValue=C,C!=null&&A.target!==document.activeElement&&(A.target.value=C);const x={formattedValue:C};m&&(x.value=C),t.setValue(e,x)},selRange(A){A.target.setSelectionRange(...A.detail.selRange)},charLimit:A=>{var R;const{charLimit:C}=A.detail,{target:x}=A;if(C===0){x.removeAttribute("maxLength");return}x.setAttribute("maxLength",C);let P=d.userValue;!P||P.length<=C||(P=P.slice(0,C),x.value=d.userValue=P,t.setValue(e,{value:P}),(R=this.linkService.eventBus)==null||R.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:P,willCommit:!0,commitKey:1,selStart:x.selectionStart,selEnd:x.selectionEnd}}))}};this._dispatchEventFromSandbox(_,w)}),i.addEventListener("keydown",w=>{var C;d.commitKey=1;let _=-1;if(w.key==="Escape"?_=0:w.key==="Enter"&&!this.data.multiLine?_=2:w.key==="Tab"&&(d.commitKey=3),_===-1)return;const{value:A}=w.target;d.lastCommittedValue!==A&&(d.lastCommittedValue=A,d.userValue=A,(C=this.linkService.eventBus)==null||C.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:_,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}}))});const v=b;b=null,i.addEventListener("blur",w=>{var C,x;if(!d.focused||!w.relatedTarget)return;(C=this.data.actions)!=null&&C.Blur||(d.focused=!1);const{target:_}=w;let{value:A}=_;if(m){if(A&&f==="time"){const P=A.split(":").map(R=>parseInt(R,10));A=new Date(2e3,0,1,P[0],P[1],P[2]||0).valueOf(),_.step=""}else A.includes("T")||(A=`${A}T00:00`),A=new Date(A).valueOf();_.type="text"}d.userValue=A,d.lastCommittedValue!==A&&((x=this.linkService.eventBus)==null||x.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:A,willCommit:!0,commitKey:d.commitKey,selStart:w.target.selectionStart,selEnd:w.target.selectionEnd}})),v(w)}),(r=this.data.actions)!=null&&r.Keystroke&&i.addEventListener("beforeinput",w=>{var z;d.lastCommittedValue=null;const{data:_,target:A}=w,{value:C,selectionStart:x,selectionEnd:P}=A;let R=x,N=P;switch(w.inputType){case"deleteWordBackward":{const H=C.substring(0,x).match(/\w*[^\w]*$/);H&&(R-=H[0].length);break}case"deleteWordForward":{const H=C.substring(x).match(/^[^\w]*\w*/);H&&(N+=H[0].length);break}case"deleteContentBackward":x===P&&(R-=1);break;case"deleteContentForward":x===P&&(N+=1);break}w.preventDefault(),(z=this.linkService.eventBus)==null||z.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:C,change:_||"",willCommit:!1,selStart:R,selEnd:N}})}),this._setEventListeners(i,d,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],w=>w.target.value)}if(b&&i.addEventListener("blur",b),this.data.comb){const w=(this.data.rect[2]-this.data.rect[0])/c;i.classList.add("comb"),i.style.letterSpacing=`calc(${w}px * var(--total-scale-factor) - 1ch)`}}else i=document.createElement("div"),i.textContent=this.data.fieldValue,i.style.verticalAlign="middle",i.style.display="table-cell",this.data.hasOwnCanvas&&(i.hidden=!0);return this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class mx extends $o{constructor(t){super(t,{isRenderable:!!t.data.hasOwnCanvas})}}class bx extends $o{constructor(t){super(t,{isRenderable:t.renderForms})}render(){const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.exportValue===e.fieldValue}).value;typeof n=="string"&&(n=n!=="Off",t.setValue(i,{value:n})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const r=document.createElement("input");return Ho.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.setAttribute("exportValue",e.exportValue),r.tabIndex=0,r.addEventListener("change",o=>{const{name:l,checked:c}=o.target;for(const h of this._getElementsByName(l,i)){const d=c&&h.exportValue===e.exportValue;h.domElement&&(h.domElement.checked=d),t.setValue(h.id,{value:d})}t.setValue(i,{value:c})}),r.addEventListener("resetform",o=>{const l=e.defaultFieldValue||"Off";o.target.checked=l===e.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",o=>{const l={value(c){c.target.checked=c.detail.value!=="Off",t.setValue(i,{value:c.target.checked})}};this._dispatchEventFromSandbox(l,o)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],o=>o.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class iv extends $o{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const t=this.annotationStorage,e=this.data,i=e.id;let n=t.getValue(i,{value:e.fieldValue===e.buttonValue}).value;if(typeof n=="string"&&(n=n!==e.buttonValue,t.setValue(i,{value:n})),n)for(const o of this._getElementsByName(e.fieldName,i))t.setValue(o.id,{value:!1});const r=document.createElement("input");if(Ho.add(r),r.setAttribute("data-element-id",i),r.disabled=e.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=e.fieldName,n&&r.setAttribute("checked",!0),r.tabIndex=0,r.addEventListener("change",o=>{const{name:l,checked:c}=o.target;for(const h of this._getElementsByName(l,i))t.setValue(h.id,{value:!1});t.setValue(i,{value:c})}),r.addEventListener("resetform",o=>{const l=e.defaultFieldValue;o.target.checked=l!=null&&l===e.buttonValue}),this.enableScripting&&this.hasJSActions){const o=e.buttonValue;r.addEventListener("updatefromsandbox",l=>{const c={value:h=>{const d=o===h.detail.value;for(const u of this._getElementsByName(h.target.name)){const f=d&&u.id===i;u.domElement&&(u.domElement.checked=f),t.setValue(u.id,{value:f})}}};this._dispatchEventFromSandbox(c,l)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],l=>l.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class yx extends hm{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",i=>{this._dispatchEventFromSandbox({},i)})),t}}class vx extends $o{constructor(t){super(t,{isRenderable:t.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const t=this.annotationStorage,e=this.data.id,i=t.getValue(e,{value:this.data.fieldValue}),n=document.createElement("select");Ho.add(n),n.setAttribute("data-element-id",e),n.disabled=this.data.readOnly,this._setRequired(n,this.data.required),n.name=this.data.fieldName,n.tabIndex=0;let r=this.data.combo&&this.data.options.length>0;this.data.combo||(n.size=this.data.options.length,this.data.multiSelect&&(n.multiple=!0)),n.addEventListener("resetform",d=>{const u=this.data.defaultFieldValue;for(const f of n.options)f.selected=f.value===u});for(const d of this.data.options){const u=document.createElement("option");u.textContent=d.displayValue,u.value=d.exportValue,i.value.includes(d.exportValue)&&(u.setAttribute("selected",!0),r=!1),n.append(u)}let o=null;if(r){const d=document.createElement("option");d.value=" ",d.setAttribute("hidden",!0),d.setAttribute("selected",!0),n.prepend(d),o=()=>{d.remove(),n.removeEventListener("input",o),o=null},n.addEventListener("input",o)}const l=d=>{const u=d?"value":"textContent",{options:f,multiple:p}=n;return p?Array.prototype.filter.call(f,m=>m.selected).map(m=>m[u]):f.selectedIndex===-1?null:f[f.selectedIndex][u]};let c=l(!1);const h=d=>{const u=d.target.options;return Array.prototype.map.call(u,f=>({displayValue:f.textContent,exportValue:f.value}))};return this.enableScripting&&this.hasJSActions?(n.addEventListener("updatefromsandbox",d=>{const u={value(f){o==null||o();const p=f.detail.value,m=new Set(Array.isArray(p)?p:[p]);for(const b of n.options)b.selected=m.has(b.value);t.setValue(e,{value:l(!0)}),c=l(!1)},multipleSelection(f){n.multiple=!0},remove(f){const p=n.options,m=f.detail.remove;p[m].selected=!1,n.remove(m),p.length>0&&Array.prototype.findIndex.call(p,v=>v.selected)===-1&&(p[0].selected=!0),t.setValue(e,{value:l(!0),items:h(f)}),c=l(!1)},clear(f){for(;n.length!==0;)n.remove(0);t.setValue(e,{value:null,items:[]}),c=l(!1)},insert(f){const{index:p,displayValue:m,exportValue:b}=f.detail.insert,v=n.children[p],w=document.createElement("option");w.textContent=m,w.value=b,v?v.before(w):n.append(w),t.setValue(e,{value:l(!0),items:h(f)}),c=l(!1)},items(f){const{items:p}=f.detail;for(;n.length!==0;)n.remove(0);for(const m of p){const{displayValue:b,exportValue:v}=m,w=document.createElement("option");w.textContent=b,w.value=v,n.append(w)}n.options.length>0&&(n.options[0].selected=!0),t.setValue(e,{value:l(!0),items:h(f)}),c=l(!1)},indices(f){const p=new Set(f.detail.indices);for(const m of f.target.options)m.selected=p.has(m.index);t.setValue(e,{value:l(!0)}),c=l(!1)},editable(f){f.target.disabled=!f.detail.editable}};this._dispatchEventFromSandbox(u,d)}),n.addEventListener("input",d=>{var p;const u=l(!0),f=l(!1);t.setValue(e,{value:u}),d.preventDefault(),(p=this.linkService.eventBus)==null||p.dispatch("dispatcheventinsandbox",{source:this,detail:{id:e,name:"Keystroke",value:c,change:f,changeEx:u,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(n,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],d=>d.target.value)):n.addEventListener("input",function(d){t.setValue(e,{value:l(!0)})}),this.data.combo&&this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class dm extends we{constructor(e){const{data:i,elements:n,parent:r}=e,o=!!r._commentManager;super(e,{isRenderable:!o&&we._hasPopupData(i)});y(this,Zd);if(this.elements=n,o&&we._hasPopupData(i)){const l=this.popup=S(this,Zd,pb).call(this);for(const c of n)c.popup=l}else this.popup=null}render(){const{container:e}=this;e.classList.add("popupAnnotation"),e.role="comment";const i=this.popup=S(this,Zd,pb).call(this),n=[];for(const r of this.elements)r.popup=i,r.container.ariaHasPopup="dialog",n.push(r.data.id),r.addHighlightArea();return this.container.setAttribute("aria-controls",n.map(r=>`${xl}${r}`).join(",")),this.container}}Zd=new WeakSet,pb=function(){return new wx({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate||this.data.creationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open,commentManager:this.parent._commentManager})};class wx{constructor({container:t,color:e,elements:i,titleObj:n,modificationDate:r,contentsObj:o,richText:l,parent:c,rect:h,parentRect:d,open:u,commentManager:f=null}){y(this,vt);y(this,an,null);y(this,fo,S(this,vt,fw).bind(this));y(this,tp,S(this,vt,vb).bind(this));y(this,ep,S(this,vt,Op).bind(this));y(this,Rc,S(this,vt,Dp).bind(this));y(this,Dc,null);y(this,Te,null);y(this,ws,null);y(this,po,null);y(this,Fa,null);y(this,Oc,null);y(this,Ic,null);y(this,As,!1);y(this,ln,null);y(this,cr,null);y(this,hr,null);y(this,Pe,null);y(this,dr,null);y(this,go,null);y(this,Qd,null);y(this,ur,null);y(this,Lc,null);y(this,Ba,null);y(this,mo,!1);y(this,qe,null);y(this,bo,null);g(this,Te,t),g(this,Lc,n),g(this,ws,o),g(this,ur,l),g(this,Oc,c),g(this,Dc,e),g(this,Qd,h),g(this,Ic,d),g(this,Fa,i),g(this,an,f),g(this,qe,i[0]),g(this,po,vf.toDateObject(r)),this.trigger=i.flatMap(p=>p.getElementsToTriggerPopup()),f||(S(this,vt,Mp).call(this),s(this,Te).hidden=!0,u&&S(this,vt,Dp).call(this))}renderCommentButton(){if(s(this,Pe)){s(this,Pe).parentNode||s(this,qe).container.after(s(this,Pe));return}if(s(this,dr)||S(this,vt,gb).call(this),!s(this,dr))return;const{signal:t}=g(this,cr,new AbortController),e=s(this,qe).hasOwnCommentButton,i=()=>{s(this,an).toggleCommentPopup(this,!0,void 0,!e)},n=()=>{s(this,an).toggleCommentPopup(this,!1,!0,!e)},r=()=>{s(this,an).toggleCommentPopup(this,!1,!1)};if(e){g(this,Pe,s(this,qe).container);for(const o of this.trigger)o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.addEventListener("keydown",s(this,fo),{signal:t}),o.addEventListener("click",i,{signal:t}),o.addEventListener("pointerenter",n,{signal:t}),o.addEventListener("pointerleave",r,{signal:t}),o.classList.add("popupTriggerArea")}else{const o=g(this,Pe,document.createElement("button"));o.className="annotationCommentButton";const l=s(this,qe).container;o.style.zIndex=l.style.zIndex+1,o.tabIndex=0,o.ariaHasPopup="dialog",o.ariaControls="commentPopup",o.setAttribute("data-l10n-id","pdfjs-show-comment-button"),S(this,vt,bb).call(this),S(this,vt,mb).call(this),o.addEventListener("keydown",s(this,fo),{signal:t}),o.addEventListener("click",i,{signal:t}),o.addEventListener("pointerenter",n,{signal:t}),o.addEventListener("pointerleave",r,{signal:t}),l.after(o)}}get commentButtonColor(){const{color:t,opacity:e}=s(this,qe).commentData;return t?s(this,Oc)._commentManager.makeCommentColor(t,e):null}focusCommentButton(){setTimeout(()=>{var t;(t=s(this,Pe))==null||t.focus()},0)}getData(){const{richText:t,color:e,opacity:i,creationDate:n,modificationDate:r}=s(this,qe).commentData;return{contentsObj:{str:this.comment},richText:t,color:e,opacity:i,creationDate:n,modificationDate:r}}get elementBeforePopup(){return s(this,Pe)}get comment(){return s(this,bo)||g(this,bo,s(this,qe).commentText),s(this,bo)}set comment(t){t!==this.comment&&(s(this,qe).commentText=g(this,bo,t))}focus(){var t;(t=s(this,qe).container)==null||t.focus()}get parentBoundingClientRect(){return s(this,qe).layer.getBoundingClientRect()}setCommentButtonStates({selected:t,hasPopup:e}){s(this,Pe)&&(s(this,Pe).classList.toggle("selected",t),s(this,Pe).ariaExpanded=e)}setSelectedCommentButton(t){s(this,Pe).classList.toggle("selected",t)}get commentPopupPosition(){if(s(this,go))return s(this,go);const{x:t,y:e,height:i}=s(this,Pe).getBoundingClientRect(),{x:n,y:r,width:o,height:l}=s(this,qe).layer.getBoundingClientRect();return[(t-n)/o,(e+i-r)/l]}set commentPopupPosition(t){g(this,go,t)}hasDefaultPopupPosition(){return s(this,go)===null}get commentButtonPosition(){return s(this,dr)}get commentButtonWidth(){return s(this,Pe).getBoundingClientRect().width/this.parentBoundingClientRect.width}editComment(t){const[e,i]=s(this,go)||this.commentButtonPosition.map(h=>h/100),n=this.parentBoundingClientRect,{x:r,y:o,width:l,height:c}=n;s(this,an).showDialog(null,this,r+e*l,o+i*c,{...t,parentDimensions:n})}render(){var i,n;if(s(this,ln))return;const t=g(this,ln,document.createElement("div"));if(t.className="popup",s(this,Dc)){const r=t.style.outlineColor=Z.makeHexColor(...s(this,Dc));t.style.backgroundColor=`color-mix(in srgb, ${r} 30%, white)`}const e=document.createElement("span");if(e.className="header",(i=s(this,Lc))!=null&&i.str){const r=document.createElement("span");r.className="title",e.append(r),{dir:r.dir,str:r.textContent}=s(this,Lc)}if(t.append(e),s(this,po)){const r=document.createElement("time");r.className="popupDate",r.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),r.setAttribute("data-l10n-args",JSON.stringify({dateObj:s(this,po).valueOf()})),r.dateTime=s(this,po).toISOString(),e.append(r)}b0({html:s(this,vt,Rp)||s(this,ws).str,dir:(n=s(this,ws))==null?void 0:n.dir,className:"popupContent"},t),s(this,Te).append(t)}updateEdited({rect:t,popup:e,deleted:i}){var n;if(s(this,an)){i?(this.remove(),g(this,bo,null)):e&&(e.deleted?this.remove():(S(this,vt,bb).call(this),g(this,bo,e.text))),t&&(g(this,dr,null),S(this,vt,gb).call(this),S(this,vt,mb).call(this));return}if(i||e!=null&&e.deleted){this.remove();return}S(this,vt,Mp).call(this),s(this,Ba)||g(this,Ba,{contentsObj:s(this,ws),richText:s(this,ur)}),t&&g(this,hr,null),e&&e.text&&(g(this,ur,S(this,vt,uw).call(this,e.text)),g(this,po,vf.toDateObject(e.date)),g(this,ws,null)),(n=s(this,ln))==null||n.remove(),g(this,ln,null)}resetEdited(){var t;s(this,Ba)&&({contentsObj:Ge(this,ws)._,richText:Ge(this,ur)._}=s(this,Ba),g(this,Ba,null),(t=s(this,ln))==null||t.remove(),g(this,ln,null),g(this,hr,null))}remove(){var t,e,i;if((t=s(this,cr))==null||t.abort(),g(this,cr,null),(e=s(this,ln))==null||e.remove(),g(this,ln,null),g(this,mo,!1),g(this,As,!1),(i=s(this,Pe))==null||i.remove(),g(this,Pe,null),this.trigger)for(const n of this.trigger)n.classList.remove("popupTriggerArea")}forceHide(){g(this,mo,this.isVisible),s(this,mo)&&(s(this,Te).hidden=!0)}maybeShow(){s(this,an)||(S(this,vt,Mp).call(this),s(this,mo)&&(s(this,ln)||S(this,vt,Op).call(this),g(this,mo,!1),s(this,Te).hidden=!1))}get isVisible(){return s(this,an)?!1:s(this,Te).hidden===!1}}an=new WeakMap,fo=new WeakMap,tp=new WeakMap,ep=new WeakMap,Rc=new WeakMap,Dc=new WeakMap,Te=new WeakMap,ws=new WeakMap,po=new WeakMap,Fa=new WeakMap,Oc=new WeakMap,Ic=new WeakMap,As=new WeakMap,ln=new WeakMap,cr=new WeakMap,hr=new WeakMap,Pe=new WeakMap,dr=new WeakMap,go=new WeakMap,Qd=new WeakMap,ur=new WeakMap,Lc=new WeakMap,Ba=new WeakMap,mo=new WeakMap,qe=new WeakMap,bo=new WeakMap,vt=new WeakSet,Mp=function(){var e;if(s(this,cr))return;g(this,cr,new AbortController);const{signal:t}=s(this,cr);for(const i of this.trigger)i.addEventListener("click",s(this,Rc),{signal:t}),i.addEventListener("pointerenter",s(this,ep),{signal:t}),i.addEventListener("pointerleave",s(this,tp),{signal:t}),i.classList.add("popupTriggerArea");for(const i of s(this,Fa))(e=i.container)==null||e.addEventListener("keydown",s(this,fo),{signal:t})},gb=function(){const t=s(this,Fa).find(e=>e.hasCommentButton);t&&g(this,dr,t._normalizePoint(t.commentButtonPosition))},mb=function(){if(s(this,qe).extraPopupElement&&!s(this,qe).editor)return;s(this,Pe)||this.renderCommentButton();const[t,e]=s(this,dr),{style:i}=s(this,Pe);i.left=`calc(${t}%)`,i.top=`calc(${e}% - var(--comment-button-dim))`},bb=function(){s(this,qe).extraPopupElement||(s(this,Pe)||this.renderCommentButton(),s(this,Pe).style.backgroundColor=this.commentButtonColor||"")},Rp=function(){const t=s(this,ur),e=s(this,ws);return t!=null&&t.str&&(!(e!=null&&e.str)||e.str===t.str)&&s(this,ur).html||null},yb=function(){var t,e,i;return((i=(e=(t=s(this,vt,Rp))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:i.fontSize)||0},dw=function(){var t,e,i;return((i=(e=(t=s(this,vt,Rp))==null?void 0:t.attributes)==null?void 0:e.style)==null?void 0:i.color)||null},uw=function(t){const e=[],i={str:t,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:e}]}},n={style:{color:s(this,vt,dw),fontSize:s(this,vt,yb)?`calc(${s(this,vt,yb)}px * var(--total-scale-factor))`:""}};for(const r of t.split(`
102
+ `))e.push({name:"span",value:r,attributes:n});return i},fw=function(t){t.altKey||t.shiftKey||t.ctrlKey||t.metaKey||(t.key==="Enter"||t.key==="Escape"&&s(this,As))&&S(this,vt,Dp).call(this)},pw=function(){if(s(this,hr)!==null)return;const{page:{view:t},viewport:{rawDims:{pageWidth:e,pageHeight:i,pageX:n,pageY:r}}}=s(this,Oc);let o=!!s(this,Ic),l=o?s(this,Ic):s(this,Qd);for(const m of s(this,Fa))if(!l||Z.intersect(m.data.rect,l)!==null){l=m.data.rect,o=!0;break}const c=Z.normalizeRect([l[0],t[3]-l[1]+t[1],l[2],t[3]-l[3]+t[1]]),d=o?l[2]-l[0]+5:0,u=c[0]+d,f=c[1];g(this,hr,[100*(u-n)/e,100*(f-r)/i]);const{style:p}=s(this,Te);p.left=`${s(this,hr)[0]}%`,p.top=`${s(this,hr)[1]}%`},Dp=function(){if(s(this,an)){s(this,an).toggleCommentPopup(this,!1);return}g(this,As,!s(this,As)),s(this,As)?(S(this,vt,Op).call(this),s(this,Te).addEventListener("click",s(this,Rc)),s(this,Te).addEventListener("keydown",s(this,fo))):(S(this,vt,vb).call(this),s(this,Te).removeEventListener("click",s(this,Rc)),s(this,Te).removeEventListener("keydown",s(this,fo)))},Op=function(){s(this,ln)||this.render(),this.isVisible?s(this,As)&&s(this,Te).classList.add("focused"):(S(this,vt,pw).call(this),s(this,Te).hidden=!1,s(this,Te).style.zIndex=parseInt(s(this,Te).style.zIndex)+1e3)},vb=function(){s(this,Te).classList.remove("focused"),!(s(this,As)||!this.isVisible)&&(s(this,Te).hidden=!0,s(this,Te).style.zIndex=parseInt(s(this,Te).style.zIndex)-1e3)};class nv extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.textContent=t.data.textContent,this.textPosition=t.data.textPosition,this.annotationEditorType=mt.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const t=this.contentElement=document.createElement("div");t.classList.add("annotationTextContent"),t.setAttribute("role","comment");for(const e of this.textContent){const i=document.createElement("span");i.textContent=e,t.append(i)}this.container.append(t)}return!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class Ax extends we{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,tu,null)}render(){this.container.classList.add("lineAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=g(this,tu,this.svgFactory.createElement("svg:line"));return o.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),o.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),o.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),o.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),o.setAttribute("stroke-width",e.borderStyle.width||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,tu)}addHighlightArea(){this.container.classList.add("highlightArea")}}tu=new WeakMap;class Sx extends we{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,eu,null)}render(){this.container.classList.add("squareAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=e.borderStyle.width,l=g(this,eu,this.svgFactory.createElement("svg:rect"));return l.setAttribute("x",o/2),l.setAttribute("y",o/2),l.setAttribute("width",i-o),l.setAttribute("height",n-o),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,eu)}addHighlightArea(){this.container.classList.add("highlightArea")}}eu=new WeakMap;class Ex extends we{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,iu,null)}render(){this.container.classList.add("circleAnnotation");const{data:e,width:i,height:n}=this,r=this.svgFactory.create(i,n,!0),o=e.borderStyle.width,l=g(this,iu,this.svgFactory.createElement("svg:ellipse"));return l.setAttribute("cx",i/2),l.setAttribute("cy",n/2),l.setAttribute("rx",i/2-o/2),l.setAttribute("ry",n/2-o/2),l.setAttribute("stroke-width",o||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),r.append(l),this.container.append(r),!e.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,iu)}addHighlightArea(){this.container.classList.add("highlightArea")}}iu=new WeakMap;class sv extends we{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,nu,null);this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:i,borderStyle:n,popupRef:r},width:o,height:l}=this;if(!i)return this.container;const c=this.svgFactory.create(o,l,!0);let h=[];for(let u=0,f=i.length;u<f;u+=2){const p=i[u]-e[0],m=e[3]-i[u+1];h.push(`${p},${m}`)}h=h.join(" ");const d=g(this,nu,this.svgFactory.createElement(this.svgElementName));return d.setAttribute("points",h),d.setAttribute("stroke-width",n.width||1),d.setAttribute("stroke","transparent"),d.setAttribute("fill","transparent"),c.append(d),this.container.append(c),!r&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}getElementsToTriggerPopup(){return s(this,nu)}addHighlightArea(){this.container.classList.add("highlightArea")}}nu=new WeakMap;class xx extends sv{constructor(t){super(t),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Cx extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container}}class um extends we{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0});y(this,ru);y(this,su,null);y(this,ja,[]);this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType=this.data.it==="InkHighlight"?mt.HIGHLIGHT:mt.INK}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:i,inkLists:n,borderStyle:r,popupRef:o}}=this,{transform:l,width:c,height:h}=S(this,ru,wb).call(this,i,e),d=this.svgFactory.create(c,h,!0),u=g(this,su,this.svgFactory.createElement("svg:g"));d.append(u),u.setAttribute("stroke-width",r.width||1),u.setAttribute("stroke-linecap","round"),u.setAttribute("stroke-linejoin","round"),u.setAttribute("stroke-miterlimit",10),u.setAttribute("stroke","transparent"),u.setAttribute("fill","transparent"),u.setAttribute("transform",l);for(let f=0,p=n.length;f<p;f++){const m=this.svgFactory.createElement(this.svgElementName);s(this,ja).push(m),m.setAttribute("points",n[f].join(",")),u.append(m)}return!o&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.append(d),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:i,points:n,rect:r}=e,o=s(this,su);if(i>=0&&o.setAttribute("stroke-width",i||1),n)for(let l=0,c=s(this,ja).length;l<c;l++)s(this,ja)[l].setAttribute("points",n[l].join(","));if(r){const{transform:l,width:c,height:h}=S(this,ru,wb).call(this,this.data.rotation,r);o.parentElement.setAttribute("viewBox",`0 0 ${c} ${h}`),o.setAttribute("transform",l)}}getElementsToTriggerPopup(){return s(this,ja)}addHighlightArea(){this.container.classList.add("highlightArea")}}su=new WeakMap,ja=new WeakMap,ru=new WeakSet,wb=function(e,i){switch(e){case 90:return{transform:`rotate(90) translate(${-i[0]},${i[1]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};case 180:return{transform:`rotate(180) translate(${-i[2]},${i[1]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]};case 270:return{transform:`rotate(270) translate(${-i[2]},${i[3]}) scale(1,-1)`,width:i[3]-i[1],height:i[2]-i[0]};default:return{transform:`translate(${-i[0]},${i[3]}) scale(1,-1)`,width:i[2]-i[0],height:i[3]-i[1]}}};class rv extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=mt.HIGHLIGHT}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),t){const i=document.createElement("mark");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class _x extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("underlineAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class Tx extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("squigglyAnnotation"),t){const i=document.createElement("u");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class Px extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){const{data:{overlaidText:t,popupRef:e}}=this;if(!e&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this.container.classList.add("strikeoutAnnotation"),t){const i=document.createElement("s");i.classList.add("overlaidText"),i.textContent=t,this.container.append(i)}return this.container}}class ov extends we{constructor(t){super(t,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=mt.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&(this.hasOwnCommentButton=!0,this._createPopup()),this._editOnDoubleClick(),this.container}}class kx extends we{constructor(e){var n;super(e,{isRenderable:!0});y(this,au);y(this,ou,null);const{file:i}=this.data;this.filename=i.filename,this.content=i.content,(n=this.linkService.eventBus)==null||n.dispatch("fileattachmentannotation",{source:this,...i})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:i}=this;let n;i.hasAppearance||i.fillAlpha===0?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(i.name)?"paperclip":"pushpin"}.svg`,i.fillAlpha&&i.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(i.fillAlpha*100)}%);`)),n.addEventListener("dblclick",S(this,au,Ab).bind(this)),g(this,ou,n);const{isMac:r}=je.platform;return e.addEventListener("keydown",o=>{o.key==="Enter"&&(r?o.metaKey:o.ctrlKey)&&S(this,au,Ab).call(this)}),!i.popupRef&&this.hasPopupData?(this.hasOwnCommentButton=!0,this._createPopup()):n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return s(this,ou)}addHighlightArea(){this.container.classList.add("highlightArea")}}ou=new WeakMap,au=new WeakSet,Ab=function(){var e;(e=this.downloadManager)==null||e.openOrDownloadData(this.content,this.filename)};const Rm=class Rm{constructor({div:t,accessibilityManager:e,annotationCanvasMap:i,annotationEditorUIManager:n,page:r,viewport:o,structTreeLayer:l,commentManager:c,linkService:h,annotationStorage:d}){y(this,fr);y(this,za,null);y(this,Ua,null);y(this,Nc,null);y(this,yo,new Map);y(this,lu,null);y(this,Ha,null);y(this,cn,[]);y(this,cu,!1);this.div=t,g(this,za,e),g(this,Ua,i),g(this,lu,l||null),g(this,Ha,h||null),g(this,Nc,d||new Xg),this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=n,this._commentManager=c||null}hasEditableAnnotations(){return s(this,yo).size>0}async render(t){var l;const{annotations:e}=t,i=this.div;zo(i,this.viewport);const n=new Map,r=[],o={data:null,layer:i,linkService:s(this,Ha),downloadManager:t.downloadManager,imageResourcesPath:t.imageResourcesPath||"",renderForms:t.renderForms!==!1,svgFactory:new Lf,annotationStorage:s(this,Nc),enableComment:t.enableComment===!0,enableScripting:t.enableScripting===!0,hasJSActions:t.hasJSActions,fieldObjects:t.fieldObjects,parent:this,elements:null};for(const c of e){if(c.noHTML)continue;const h=c.annotationType===Oe.POPUP;if(h){const f=n.get(c.id);if(!f)continue;if(!this._commentManager){r.push(c);continue}o.elements=f}else if(c.rect[2]===c.rect[0]||c.rect[3]===c.rect[1])continue;o.data=c;const d=cm.create(o);if(!d.isRenderable)continue;if(!h&&(s(this,cn).push(d),c.popupRef)){const f=n.get(c.popupRef);f?f.push(d):n.set(c.popupRef,[d])}const u=d.render();c.hidden&&(u.style.visibility="hidden"),d._isEditable&&(s(this,yo).set(d.data.id,d),(l=this._annotationEditorUIManager)==null||l.renderAnnotationElement(d))}await S(this,fr,Ip).call(this);for(const c of r){const h=o.elements=n.get(c.id);o.data=c;const d=cm.create(o);if(!d.isRenderable)continue;const u=d.render();d.contentElement.id=`${xl}${c.id}`,c.hidden&&(u.style.visibility="hidden"),h.at(-1).container.after(u)}S(this,fr,Sb).call(this)}async addLinkAnnotations(t){const e={data:null,layer:this.div,linkService:s(this,Ha),svgFactory:new Lf,parent:this};for(const i of t){i.borderStyle||(i.borderStyle=Rm._defaultBorderStyle),e.data=i;const n=cm.create(e);n.isRenderable&&(n.render(),n.contentElement.id=`${xl}${i.id}`,s(this,cn).push(n))}await S(this,fr,Ip).call(this)}update({viewport:t}){const e=this.div;this.viewport=t,zo(e,{rotation:t.rotation}),S(this,fr,Sb).call(this),e.hidden=!1}getEditableAnnotations(){return Array.from(s(this,yo).values())}getEditableAnnotation(t){return s(this,yo).get(t)}addFakeAnnotation(t){const{div:e}=this,{id:i,rotation:n}=t,r=new fx({data:{id:i,rect:t.getPDFRect(),rotation:n},editor:t,layer:e,parent:this,enableComment:!!this._commentManager,linkService:s(this,Ha),annotationStorage:s(this,Nc)});return r.render(),r.contentElement.id=`${xl}${i}`,r.createOrUpdatePopup(),s(this,cn).push(r),r}removeAnnotation(t){var n;const e=s(this,cn).findIndex(r=>r.data.id===t);if(e<0)return;const[i]=s(this,cn).splice(e,1);(n=s(this,za))==null||n.removePointerInTextLayer(i.contentElement)}updateFakeAnnotations(t){if(t.length!==0){for(const e of t)e.updateFakeAnnotationElement(this);S(this,fr,Ip).call(this)}}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}static get _defaultBorderStyle(){return gt(this,"_defaultBorderStyle",Object.freeze({width:1,rawWidth:1,style:El.SOLID,dashArray:[3],horizontalCornerRadius:0,verticalCornerRadius:0}))}};za=new WeakMap,Ua=new WeakMap,Nc=new WeakMap,yo=new WeakMap,lu=new WeakMap,Ha=new WeakMap,cn=new WeakMap,cu=new WeakMap,fr=new WeakSet,Ip=async function(){var i,n,r;if(s(this,cn).length===0)return;this.div.replaceChildren();const t=[];if(!s(this,cu)){g(this,cu,!0);for(const{contentElement:o,data:{id:l}}of s(this,cn)){const c=o.id=`${xl}${l}`;t.push((i=s(this,lu))==null?void 0:i.getAriaAttributes(c).then(h=>{if(h)for(const[d,u]of h)o.setAttribute(d,u)}))}}s(this,cn).sort(({data:{rect:[o,l,c,h]}},{data:{rect:[d,u,f,p]}})=>{if(o===c&&l===h)return 1;if(d===f&&u===p)return-1;const m=h,b=l,v=(l+h)/2,w=p,_=u,A=(u+p)/2;if(v>=w&&A<=b)return-1;if(A>=m&&v<=_)return 1;const C=(o+c)/2,x=(d+f)/2;return C-x});const e=document.createDocumentFragment();for(const o of s(this,cn))e.append(o.container),this._commentManager?(r=((n=o.extraPopupElement)==null?void 0:n.popup)||o.popup)==null||r.renderCommentButton():o.extraPopupElement&&e.append(o.extraPopupElement.render());if(this.div.append(e),await Promise.all(t),s(this,za))for(const o of s(this,cn))s(this,za).addPointerInTextLayer(o.contentElement,!1)},Sb=function(){var e;if(!s(this,Ua))return;const t=this.div;for(const[i,n]of s(this,Ua)){const r=t.querySelector(`[data-annotation-id="${i}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:o}=r;o?o.nodeName==="CANVAS"?o.replaceWith(n):o.classList.contains("annotationContent")?o.after(n):o.before(n):r.append(n);const l=s(this,yo).get(i);l&&(l._hasNoCanvas?((e=this._annotationEditorUIManager)==null||e.setMissingCanvas(i,r.id,n),l._hasNoCanvas=!1):l.canvas=n)}s(this,Ua).clear()};let fm=Rm;const Nf=/\r\n?|\n/g,ue=class ue extends le{constructor(e){super({...e,name:"freeTextEditor"});y(this,Ne);y(this,hn,"");y(this,hu,`${this.id}-editor`);y(this,$a,null);y(this,dn);W(this,"_colorPicker",null);this.color=e.color||ue._defaultColor||le._defaultLineColor,g(this,dn,e.fontSize||ue._defaultFontSize),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-freetext-added-alert"),this.canAddComment=!1}static get _keyboardManager(){const e=ue.prototype,i=o=>o.isEmpty(),n=Uo.TRANSLATE_SMALL,r=Uo.TRANSLATE_BIG;return gt(this,"_keyboardManager",new Ph([[["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:[-n,0],checker:i}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:i}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:i}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:i}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:i}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:i}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:i}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:i}]]))}static initialize(e,i){le.initialize(e,i);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,i){switch(e){case kt.FREETEXT_SIZE:ue._defaultFontSize=i;break;case kt.FREETEXT_COLOR:ue._defaultColor=i;break}}updateParams(e,i){switch(e){case kt.FREETEXT_SIZE:S(this,Ne,gw).call(this,i);break;case kt.FREETEXT_COLOR:S(this,Ne,mw).call(this,i);break}}static get defaultPropertiesToUpdate(){return[[kt.FREETEXT_SIZE,ue._defaultFontSize],[kt.FREETEXT_COLOR,ue._defaultColor||le._defaultLineColor]]}get propertiesToUpdate(){return[[kt.FREETEXT_SIZE,s(this,dn)],[kt.FREETEXT_COLOR,this.color]]}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new If(this)),[["colorPicker",this._colorPicker]]}get colorType(){return kt.FREETEXT_COLOR}onUpdatedColor(){var e;this.editorDiv.style.color=this.color,(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_translateEmpty(e,i){this._uiManager.translateSelectedEditors(e,i,!0)}getInitialTranslation(){const e=this.parentScale;return[-ue._internalPadding*e,-(ue._internalPadding+s(this,dn))*e]}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(!super.enableEditMode())return!1;this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),g(this,$a,new AbortController);const e=this._uiManager.combinedSignal(s(this,$a));return this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e}),!0}disableEditMode(){var e;return super.disableEditMode()?(this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",s(this,hu)),this._isDraggable=!0,(e=s(this,$a))==null||e.abort(),g(this,$a,null),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"),!0):!1}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){var i;this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),(i=this._initialOptions)!=null&&i.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||this.editorDiv.innerText.trim()===""}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=s(this,hn),i=g(this,hn,S(this,Ne,bw).call(this).trimEnd());if(e===i)return;const n=r=>{if(g(this,hn,r),!r){this.remove();return}S(this,Ne,Fp).call(this),this._uiManager.rebuild(this),S(this,Ne,Lp).call(this)};this.addCommands({cmd:()=>{n(i)},undo:()=>{n(e)},mustExec:!1}),S(this,Ne,Lp).call(this)}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}keydown(e){e.target===this.div&&e.key==="Enter"&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){ue._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}get canChangeContent(){return!0}render(){if(this.div)return this.div;let e,i;(this._isCopy||this.annotationElementId)&&(e=this.x,i=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",s(this,hu)),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:n}=this.editorDiv;if(n.fontSize=`calc(${s(this,dn)}px * var(--total-scale-factor))`,n.color=this.color,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),this._isCopy||this.annotationElementId){const[r,o]=this.parentDimensions;if(this.annotationElementId){const{position:l}=this._initialData;let[c,h]=this.getInitialTranslation();[c,h]=this.pageTranslationToScreen(c,h);const[d,u]=this.pageDimensions,[f,p]=this.pageTranslation;let m,b;switch(this.rotation){case 0:m=e+(l[0]-f)/d,b=i+this.height-(l[1]-p)/u;break;case 90:m=e+(l[0]-f)/d,b=i-(l[1]-p)/u,[c,h]=[h,-c];break;case 180:m=e-this.width+(l[0]-f)/d,b=i-(l[1]-p)/u,[c,h]=[-c,-h];break;case 270:m=e+(l[0]-f-this.height*u)/d,b=i+(l[1]-p-this.width*d)/u,[c,h]=[-h,c];break}this.setAt(m*r,b*o,c,h)}else this._moveAfterPaste(e,i);S(this,Ne,Fp).call(this),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}editorDivPaste(e){var m,b,v;const i=e.clipboardData||window.clipboardData,{types:n}=i;if(n.length===1&&n[0]==="text/plain")return;e.preventDefault();const r=S(m=ue,pr,Eb).call(m,i.getData("text")||"").replaceAll(Nf,`
103
103
  `);if(!r)return;const o=window.getSelection();if(!o.rangeCount)return;this.editorDiv.normalize(),o.deleteFromDocument();const l=o.getRangeAt(0);if(!r.includes(`
104
- `)){l.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),o.collapseToStart();return}const{startContainer:c,startOffset:h}=l,d=[],f=[];if(c.nodeType===Node.TEXT_NODE){const y=c.parentElement;if(f.push(c.nodeValue.slice(h).replaceAll(Lf,"")),y!==this.editorDiv){let x=d;for(const E of this.editorDiv.childNodes){if(E===y){x=f;continue}x.push(A(m=ue,gr,Np).call(m,E))}}d.push(c.nodeValue.slice(0,h).replaceAll(Lf,""))}else if(c===this.editorDiv){let y=d,x=0;for(const E of this.editorDiv.childNodes)x++===h&&(y=f),y.push(A(w=ue,gr,Np).call(w,E))}p(this,an,`${d.join(`
105
- `)}${r}${f.join(`
106
- `)}`),A(this,Le,Fp).call(this);const u=new Range;let g=Math.sumPrecise(d.map(y=>y.length));for(const{firstChild:y}of this.editorDiv.childNodes)if(y.nodeType===Node.TEXT_NODE){const x=y.nodeValue.length;if(g<=x){u.setStart(y,g),u.setEnd(y,g);break}g-=x}o.removeAllRanges(),o.addRange(u)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=ue._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,i,n){var l;let r=null;if(e instanceof iv){const{data:{defaultAppearanceData:{fontSize:c,fontColor:h},rect:d,rotation:f,id:u,popupRef:g,richText:b,contentsObj:m,creationDate:w,modificationDate:y},textContent:x,textPosition:E,parent:{page:{pageNumber:_}}}=e;if(!x||x.length===0)return null;r=e={annotationType:mt.FREETEXT,color:Array.from(h),fontSize:c,value:x.join(`
107
- `),position:E,pageIndex:_-1,rect:d.slice(0),rotation:f,annotationElementId:u,id:u,deleted:!1,popupRef:g,comment:(m==null?void 0:m.str)||null,richText:b,creationDate:w,modificationDate:y}}const o=await super.deserialize(e,i,n);return p(o,ln,e.fontSize),o.color=Z.makeHexColor(...e.color),p(o,an,A(l=ue,gr,Sb).call(l,e.value)),o._initialData=r,e.comment&&o.setCommentData(e),o}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=ae._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:i,fontSize:s(this,ln),value:A(this,Le,mw).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!A(this,Le,bw).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){const i=super.renderAnnotationElement(e);if(!i)return null;const{style:n}=i;n.fontSize=`calc(${s(this,ln)}px * var(--total-scale-factor))`,n.color=this.color,i.replaceChildren();for(const r of s(this,an).split(`
108
- `)){const o=document.createElement("div");o.append(r?document.createTextNode(r):document.createElement("br")),i.append(o)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:s(this,an)}}),i}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};an=new WeakMap,au=new WeakMap,Ua=new WeakMap,ln=new WeakMap,Le=new WeakSet,fw=function(e){const i=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-s(this,ln))*this.parentScale),p(this,ln,r),A(this,Le,Lp).call(this)},n=s(this,ln);this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},pw=function(e){const i=r=>{this.color=r,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},gw=function(){var n;const e=[];this.editorDiv.normalize();let i=null;for(const r of this.editorDiv.childNodes)(i==null?void 0:i.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(A(n=ue,gr,Np).call(n,r)),i=r);return e.join(`
109
- `)},Lp=function(){const[e,i]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:r,div:o}=this,l=o.style.display,c=o.classList.contains("hidden");o.classList.remove("hidden"),o.style.display="hidden",r.div.append(this.div),n=o.getBoundingClientRect(),o.remove(),o.style.display=l,o.classList.toggle("hidden",c)}this.rotation%180===this.parentRotation%180?(this.width=n.width/e,this.height=n.height/i):(this.width=n.height/e,this.height=n.width/i),this.fixAndSetPosition()},gr=new WeakSet,Np=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Lf,"")},Fp=function(){if(this.editorDiv.replaceChildren(),!!s(this,an))for(const e of s(this,an).split(`
110
- `)){const i=document.createElement("div");i.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(i)}},mw=function(){return s(this,an).replaceAll(" "," ")},Sb=function(e){return e.replaceAll(" "," ")},bw=function(e){const{value:i,fontSize:n,color:r,pageIndex:o}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==i||e.fontSize!==n||e.color.some((l,c)=>l!==r[c])||e.pageIndex!==o},v(ue,gr),$(ue,"_freeTextDefaultContent",""),$(ue,"_internalPadding",0),$(ue,"_defaultColor",null),$(ue,"_defaultFontSize",10),$(ue,"_type","freetext"),$(ue,"_editorType",mt.FREETEXT);let pm=ue;class it{toSVGPath(){ie("Abstract method `toSVGPath` must be implemented.")}get box(){ie("Abstract getter `box` must be implemented.")}serialize(t,e){ie("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,n,r,o){o||(o=new Float32Array(t.length));for(let l=0,c=t.length;l<c;l+=2)o[l]=e+t[l]*n,o[l+1]=i+t[l+1]*r;return o}static _rescaleAndSwap(t,e,i,n,r,o){o||(o=new Float32Array(t.length));for(let l=0,c=t.length;l<c;l+=2)o[l]=e+t[l+1]*n,o[l+1]=i+t[l]*r;return o}static _translate(t,e,i,n){n||(n=new Float32Array(t.length));for(let r=0,o=t.length;r<o;r+=2)n[r]=e+t[r],n[r+1]=i+t[r+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,i,n,r){switch(r){case 90:return[1-e/i,t/n];case 180:return[1-t/i,1-e/n];case 270:return[e/i,1-t/n];default:return[t/i,e/n]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,n,r,o){return[(t+5*i)/6,(e+5*n)/6,(5*i+r)/6,(5*n+o)/6,(i+r)/2,(n+o)/2]}}$(it,"PRECISION",1e-4);const mr=class mr{constructor({x:t,y:e},i,n,r,o,l=0){v(this,$e);v(this,cn);v(this,Yn,[]);v(this,Rc);v(this,Dc);v(this,Es,[]);v(this,Tt,new Float32Array(18));v(this,Ha);v(this,$a);v(this,lu);v(this,cu);v(this,Oc);v(this,Ic);v(this,wo,[]);p(this,cn,i),p(this,Ic,r*n),p(this,Dc,o),s(this,Tt).set([NaN,NaN,NaN,NaN,t,e],6),p(this,Rc,l),p(this,cu,s(mr,hu)*n),p(this,lu,s(mr,ip)*n),p(this,Oc,n),s(this,wo).push(t,e)}isEmpty(){return isNaN(s(this,Tt)[8])}add({x:t,y:e}){var O;p(this,Ha,t),p(this,$a,e);const[i,n,r,o]=s(this,cn);let[l,c,h,d]=s(this,Tt).subarray(8,12);const f=t-h,u=e-d,g=Math.hypot(f,u);if(g<s(this,lu))return!1;const b=g-s(this,cu),m=b/g,w=m*f,y=m*u;let x=l,E=c;l=h,c=d,h+=w,d+=y,(O=s(this,wo))==null||O.push(t,e);const _=-y/b,C=w/b,T=_*s(this,Ic),D=C*s(this,Ic);return s(this,Tt).set(s(this,Tt).subarray(2,8),0),s(this,Tt).set([h+T,d+D],4),s(this,Tt).set(s(this,Tt).subarray(14,18),12),s(this,Tt).set([h-T,d-D],16),isNaN(s(this,Tt)[6])?(s(this,Es).length===0&&(s(this,Tt).set([l+T,c+D],2),s(this,Es).push(NaN,NaN,NaN,NaN,(l+T-i)/r,(c+D-n)/o),s(this,Tt).set([l-T,c-D],14),s(this,Yn).push(NaN,NaN,NaN,NaN,(l-T-i)/r,(c-D-n)/o)),s(this,Tt).set([x,E,l,c,h,d],6),!this.isEmpty()):(s(this,Tt).set([x,E,l,c,h,d],6),Math.abs(Math.atan2(E-c,x-l)-Math.atan2(y,w))<Math.PI/2?([l,c,h,d]=s(this,Tt).subarray(2,6),s(this,Es).push(NaN,NaN,NaN,NaN,((l+h)/2-i)/r,((c+d)/2-n)/o),[l,c,x,E]=s(this,Tt).subarray(14,18),s(this,Yn).push(NaN,NaN,NaN,NaN,((x+l)/2-i)/r,((E+c)/2-n)/o),!0):([x,E,l,c,h,d]=s(this,Tt).subarray(0,6),s(this,Es).push(((x+5*l)/6-i)/r,((E+5*c)/6-n)/o,((5*l+h)/6-i)/r,((5*c+d)/6-n)/o,((l+h)/2-i)/r,((c+d)/2-n)/o),[h,d,l,c,x,E]=s(this,Tt).subarray(12,18),s(this,Yn).push(((x+5*l)/6-i)/r,((E+5*c)/6-n)/o,((5*l+h)/6-i)/r,((5*c+d)/6-n)/o,((l+h)/2-i)/r,((c+d)/2-n)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const t=s(this,Es),e=s(this,Yn);if(isNaN(s(this,Tt)[6])&&!this.isEmpty())return A(this,$e,yw).call(this);const i=[];i.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?i.push(`L${t[n+4]} ${t[n+5]}`):i.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);A(this,$e,ww).call(this,i);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?i.push(`L${e[n+4]} ${e[n+5]}`):i.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return A(this,$e,vw).call(this,i),i.join(" ")}newFreeDrawOutline(t,e,i,n,r,o){return new ov(t,e,i,n,r,o)}getOutlines(){var f;const t=s(this,Es),e=s(this,Yn),i=s(this,Tt),[n,r,o,l]=s(this,cn),c=new Float32Array((((f=s(this,wo))==null?void 0:f.length)??0)+2);for(let u=0,g=c.length-2;u<g;u+=2)c[u]=(s(this,wo)[u]-n)/o,c[u+1]=(s(this,wo)[u+1]-r)/l;if(c[c.length-2]=(s(this,Ha)-n)/o,c[c.length-1]=(s(this,$a)-r)/l,isNaN(i[6])&&!this.isEmpty())return A(this,$e,Aw).call(this,c);const h=new Float32Array(s(this,Es).length+24+s(this,Yn).length);let d=t.length;for(let u=0;u<d;u+=2){if(isNaN(t[u])){h[u]=h[u+1]=NaN;continue}h[u]=t[u],h[u+1]=t[u+1]}d=A(this,$e,Ew).call(this,h,d);for(let u=e.length-6;u>=6;u-=6)for(let g=0;g<6;g+=2){if(isNaN(e[u+g])){h[d]=h[d+1]=NaN,d+=2;continue}h[d]=e[u+g],h[d+1]=e[u+g+1],d+=2}return A(this,$e,Sw).call(this,h,d),this.newFreeDrawOutline(h,c,s(this,cn),s(this,Oc),s(this,Rc),s(this,Dc))}};cn=new WeakMap,Yn=new WeakMap,Rc=new WeakMap,Dc=new WeakMap,Es=new WeakMap,Tt=new WeakMap,Ha=new WeakMap,$a=new WeakMap,lu=new WeakMap,cu=new WeakMap,Oc=new WeakMap,Ic=new WeakMap,wo=new WeakMap,hu=new WeakMap,ep=new WeakMap,ip=new WeakMap,$e=new WeakSet,Yu=function(){const t=s(this,Tt).subarray(4,6),e=s(this,Tt).subarray(16,18),[i,n,r,o]=s(this,cn);return[(s(this,Ha)+(t[0]-e[0])/2-i)/r,(s(this,$a)+(t[1]-e[1])/2-n)/o,(s(this,Ha)+(e[0]-t[0])/2-i)/r,(s(this,$a)+(e[1]-t[1])/2-n)/o]},yw=function(){const[t,e,i,n]=s(this,cn),[r,o,l,c]=A(this,$e,Yu).call(this);return`M${(s(this,Tt)[2]-t)/i} ${(s(this,Tt)[3]-e)/n} L${(s(this,Tt)[4]-t)/i} ${(s(this,Tt)[5]-e)/n} L${r} ${o} L${l} ${c} L${(s(this,Tt)[16]-t)/i} ${(s(this,Tt)[17]-e)/n} L${(s(this,Tt)[14]-t)/i} ${(s(this,Tt)[15]-e)/n} Z`},vw=function(t){const e=s(this,Yn);t.push(`L${e[4]} ${e[5]} Z`)},ww=function(t){const[e,i,n,r]=s(this,cn),o=s(this,Tt).subarray(4,6),l=s(this,Tt).subarray(16,18),[c,h,d,f]=A(this,$e,Yu).call(this);t.push(`L${(o[0]-e)/n} ${(o[1]-i)/r} L${c} ${h} L${d} ${f} L${(l[0]-e)/n} ${(l[1]-i)/r}`)},Aw=function(t){const e=s(this,Tt),[i,n,r,o]=s(this,cn),[l,c,h,d]=A(this,$e,Yu).call(this),f=new Float32Array(36);return f.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-n)/o,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-n)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-n)/o,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-n)/o],0),this.newFreeDrawOutline(f,t,s(this,cn),s(this,Oc),s(this,Rc),s(this,Dc))},Sw=function(t,e){const i=s(this,Yn);return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6},Ew=function(t,e){const i=s(this,Tt).subarray(4,6),n=s(this,Tt).subarray(16,18),[r,o,l,c]=s(this,cn),[h,d,f,u]=A(this,$e,Yu).call(this);return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/l,(i[1]-o)/c,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,f,u,NaN,NaN,NaN,NaN,(n[0]-r)/l,(n[1]-o)/c],e),e+=24},v(mr,hu,8),v(mr,ep,2),v(mr,ip,s(mr,hu)+s(mr,ep));let Nf=mr;class ov extends it{constructor(e,i,n,r,o,l){super();v(this,np);v(this,Lc);v(this,Wa,new Float32Array(4));v(this,br);v(this,du);v(this,hn);v(this,uu);v(this,Me);p(this,Me,e),p(this,hn,i),p(this,Lc,n),p(this,uu,r),p(this,br,o),p(this,du,l),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],A(this,np,xw).call(this,l);const[c,h,d,f]=s(this,Wa);for(let u=0,g=e.length;u<g;u+=2)e[u]=(e[u]-c)/d,e[u+1]=(e[u+1]-h)/f;for(let u=0,g=i.length;u<g;u+=2)i[u]=(i[u]-c)/d,i[u+1]=(i[u+1]-h)/f}toSVGPath(){const e=[`M${s(this,Me)[4]} ${s(this,Me)[5]}`];for(let i=6,n=s(this,Me).length;i<n;i+=6){if(isNaN(s(this,Me)[i])){e.push(`L${s(this,Me)[i+4]} ${s(this,Me)[i+5]}`);continue}e.push(`C${s(this,Me)[i]} ${s(this,Me)[i+1]} ${s(this,Me)[i+2]} ${s(this,Me)[i+3]} ${s(this,Me)[i+4]} ${s(this,Me)[i+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,i,n,r],o){const l=n-e,c=r-i;let h,d;switch(o){case 0:h=it._rescale(s(this,Me),e,r,l,-c),d=it._rescale(s(this,hn),e,r,l,-c);break;case 90:h=it._rescaleAndSwap(s(this,Me),e,i,l,c),d=it._rescaleAndSwap(s(this,hn),e,i,l,c);break;case 180:h=it._rescale(s(this,Me),n,i,-l,c),d=it._rescale(s(this,hn),n,i,-l,c);break;case 270:h=it._rescaleAndSwap(s(this,Me),n,r,-l,-c),d=it._rescaleAndSwap(s(this,hn),n,r,-l,-c);break}return{outline:Array.from(h),points:[Array.from(d)]}}get box(){return s(this,Wa)}newOutliner(e,i,n,r,o,l=0){return new Nf(e,i,n,r,o,l)}getNewOutline(e,i){const[n,r,o,l]=s(this,Wa),[c,h,d,f]=s(this,Lc),u=o*d,g=l*f,b=n*d+c,m=r*f+h,w=this.newOutliner({x:s(this,hn)[0]*u+b,y:s(this,hn)[1]*g+m},s(this,Lc),s(this,uu),e,s(this,du),i??s(this,br));for(let y=2;y<s(this,hn).length;y+=2)w.add({x:s(this,hn)[y]*u+b,y:s(this,hn)[y+1]*g+m});return w.getOutlines()}}Lc=new WeakMap,Wa=new WeakMap,br=new WeakMap,du=new WeakMap,hn=new WeakMap,uu=new WeakMap,Me=new WeakMap,np=new WeakSet,xw=function(e){const i=s(this,Me);let n=i[4],r=i[5];const o=[n,r,n,r];let l=n,c=r,h=n,d=r;const f=e?Math.max:Math.min,u=new Float32Array(4);for(let b=6,m=i.length;b<m;b+=6){const w=i[b+4],y=i[b+5];isNaN(i[b])?(Z.pointBoundingBox(w,y,o),c>y?(l=w,c=y):c===y&&(l=f(l,w)),d<y?(h=w,d=y):d===y&&(h=f(h,w))):(u[0]=u[1]=1/0,u[2]=u[3]=-1/0,Z.bezierBoundingBox(n,r,...i.slice(b,b+6),u),Z.rectBoundingBox(u[0],u[1],u[2],u[3],o),c>u[1]?(l=u[0],c=u[1]):c===u[1]&&(l=f(l,u[0])),d<u[3]?(h=u[2],d=u[3]):d===u[3]&&(h=f(h,u[2]))),n=w,r=y}const g=s(this,Wa);g[0]=o[0]-s(this,br),g[1]=o[1]-s(this,br),g[2]=o[2]-o[0]+2*s(this,br),g[3]=o[3]-o[1]+2*s(this,br),this.firstPoint=[l,c],this.lastPoint=[h,d]};class gm{constructor(t,e=0,i=0,n=!0){v(this,_i);v(this,fu);v(this,pu);v(this,gu);v(this,Ao,[]);v(this,Xn,[]);const r=[1/0,1/0,-1/0,-1/0],o=10**-4;for(const{x:m,y:w,width:y,height:x}of t){const E=Math.floor((m-e)/o)*o,_=Math.ceil((m+y+e)/o)*o,C=Math.floor((w-e)/o)*o,T=Math.ceil((w+x+e)/o)*o,D=[E,C,T,!0],j=[_,C,T,!1];s(this,Ao).push(D,j),Z.rectBoundingBox(E,C,_,T,r)}const l=r[2]-r[0]+2*i,c=r[3]-r[1]+2*i,h=r[0]-i,d=r[1]-i;let f=n?-1/0:1/0,u=1/0;const g=s(this,Ao).at(n?-1:-2),b=[g[0],g[2]];for(const m of s(this,Ao)){const[w,y,x,E]=m;!E&&n?y<u?(u=y,f=w):y===u&&(f=Math.max(f,w)):E&&!n&&(y<u?(u=y,f=w):y===u&&(f=Math.min(f,w))),m[0]=(w-h)/l,m[1]=(y-d)/c,m[2]=(x-d)/c}p(this,fu,new Float32Array([h,d,l,c])),p(this,pu,[f,u]),p(this,gu,b)}getOutlines(){s(this,Ao).sort((e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2]);const t=[];for(const e of s(this,Ao))e[3]?(t.push(...A(this,_i,Eb).call(this,e)),A(this,_i,_w).call(this,e)):(A(this,_i,Tw).call(this,e),t.push(...A(this,_i,Eb).call(this,e)));return A(this,_i,Cw).call(this,t)}}fu=new WeakMap,pu=new WeakMap,gu=new WeakMap,Ao=new WeakMap,Xn=new WeakMap,_i=new WeakSet,Cw=function(t){const e=[],i=new Set;for(const o of t){const[l,c,h]=o;e.push([l,c,o],[l,h,o])}e.sort((o,l)=>o[1]-l[1]||o[0]-l[0]);for(let o=0,l=e.length;o<l;o+=2){const c=e[o][2],h=e[o+1][2];c.push(h),h.push(c),i.add(c),i.add(h)}const n=[];let r;for(;i.size>0;){const o=i.values().next().value;let[l,c,h,d,f]=o;i.delete(o);let u=l,g=c;for(r=[l,h],n.push(r);;){let b;if(i.has(d))b=d;else if(i.has(f))b=f;else break;i.delete(b),[l,c,h,d,f]=b,u!==l&&(r.push(u,g,l,g===c?c:h),u=l),g=g===c?h:c}r.push(u,g)}return new Px(n,s(this,fu),s(this,pu),s(this,gu))},Bp=function(t){const e=s(this,Xn);let i=0,n=e.length-1;for(;i<=n;){const r=i+n>>1,o=e[r][0];if(o===t)return r;o<t?i=r+1:n=r-1}return n+1},_w=function([,t,e]){const i=A(this,_i,Bp).call(this,t);s(this,Xn).splice(i,0,[t,e])},Tw=function([,t,e]){const i=A(this,_i,Bp).call(this,t);for(let n=i;n<s(this,Xn).length;n++){const[r,o]=s(this,Xn)[n];if(r!==t)break;if(r===t&&o===e){s(this,Xn).splice(n,1);return}}for(let n=i-1;n>=0;n--){const[r,o]=s(this,Xn)[n];if(r!==t)break;if(r===t&&o===e){s(this,Xn).splice(n,1);return}}},Eb=function(t){const[e,i,n]=t,r=[[e,i,n]],o=A(this,_i,Bp).call(this,n);for(let l=0;l<o;l++){const[c,h]=s(this,Xn)[l];for(let d=0,f=r.length;d<f;d++){const[,u,g]=r[d];if(!(h<=u||g<=c)){if(u>=c){if(g>h)r[d][1]=h;else{if(f===1)return[];r.splice(d,1),d--,f--}continue}r[d][2]=c,g>h&&r.push([e,h,g])}}}return r};class Px extends it{constructor(e,i,n,r){super();v(this,mu);v(this,Nc);p(this,Nc,e),p(this,mu,i),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const i of s(this,Nc)){let[n,r]=i;e.push(`M${n} ${r}`);for(let o=2;o<i.length;o+=2){const l=i[o],c=i[o+1];l===n?(e.push(`V${c}`),r=c):c===r&&(e.push(`H${l}`),n=l)}e.push("Z")}return e.join(" ")}serialize([e,i,n,r],o){const l=[],c=n-e,h=r-i;for(const d of s(this,Nc)){const f=new Array(d.length);for(let u=0;u<d.length;u+=2)f[u]=e+d[u]*c,f[u+1]=r-d[u+1]*h;l.push(f)}return l}get box(){return s(this,mu)}get classNamesForOutlining(){return["highlightOutline"]}}mu=new WeakMap,Nc=new WeakMap;class mm extends Nf{newFreeDrawOutline(t,e,i,n,r,o){return new kx(t,e,i,n,r,o)}}class kx extends ov{newOutliner(t,e,i,n,r,o=0){return new mm(t,e,i,n,r,o)}}const Bt=class Bt extends ae{constructor(e){super({...e,name:"highlightEditor"});v(this,At);v(this,Fc,null);v(this,bu,0);v(this,yr);v(this,Va,null);v(this,yu,null);v(this,ji,null);v(this,vu,null);v(this,wu,0);v(this,Ga,null);v(this,dn,null);v(this,un,null);v(this,hi,!1);v(this,Bc,null);v(this,jc,null);v(this,vi,null);v(this,zc,"");v(this,On);v(this,Au,"");this.color=e.color||Bt._defaultColor,p(this,On,e.thickness||Bt._defaultThickness),this.opacity=e.opacity||Bt._defaultOpacity,p(this,yr,e.boxes||null),p(this,Au,e.methodOfCreation||""),p(this,zc,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(p(this,hi,!0),A(this,At,jp).call(this,e),A(this,At,hl).call(this)):s(this,yr)&&(p(this,Fc,e.anchorNode),p(this,bu,e.anchorOffset),p(this,vu,e.focusNode),p(this,wu,e.focusOffset),A(this,At,xb).call(this),A(this,At,hl).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=Bt.prototype;return gt(this,"_keyboardManager",new Ch([[["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:s(this,hi)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:s(this,On),methodOfCreation:s(this,Au)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,i){var n;ae.initialize(e,i),Bt._defaultColor||(Bt._defaultColor=((n=i.highlightColors)==null?void 0:n.values().next().value)||"#fff066")}static updateDefaultParams(e,i){switch(e){case Mt.HIGHLIGHT_COLOR:Bt._defaultColor=i;break;case Mt.HIGHLIGHT_THICKNESS:Bt._defaultThickness=i;break}}translateInPage(e,i){}get toolbarPosition(){return s(this,jc)}get commentButtonPosition(){return s(this,Bc)}updateParams(e,i){switch(e){case Mt.HIGHLIGHT_COLOR:A(this,At,Pw).call(this,i);break;case Mt.HIGHLIGHT_THICKNESS:A(this,At,kw).call(this,i);break}}static get defaultPropertiesToUpdate(){return[[Mt.HIGHLIGHT_COLOR,Bt._defaultColor],[Mt.HIGHLIGHT_THICKNESS,Bt._defaultThickness]]}get propertiesToUpdate(){return[[Mt.HIGHLIGHT_COLOR,this.color||Bt._defaultColor],[Mt.HIGHLIGHT_THICKNESS,s(this,On)||Bt._defaultThickness],[Mt.HIGHLIGHT_FREE,s(this,hi)]]}onUpdatedColor(){var e,i;(e=this.parent)==null||e.drawLayer.updateProperties(s(this,un),{root:{fill:this.color,"fill-opacity":this.opacity}}),(i=s(this,yu))==null||i.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",p(this,yu,new Df({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(A(this,At,Up).call(this))}getBaseTranslation(){return[0,0]}getRect(e,i){return super.getRect(e,i,A(this,At,Up).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){A(this,At,Cb).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(A(this,At,hl).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let i=!1;this.parent&&!e?A(this,At,Cb).call(this):e&&(A(this,At,hl).call(this,e),i=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),i&&this.select()}rotate(e){var r,o,l;const{drawLayer:i}=this.parent;let n;s(this,hi)?(e=(e-this.rotation+360)%360,n=A(r=Bt,In,lh).call(r,s(this,dn).box,e)):n=A(o=Bt,In,lh).call(o,[this.x,this.y,this.width,this.height],e),i.updateProperties(s(this,un),{bbox:n,root:{"data-main-rotation":e}}),i.updateProperties(s(this,vi),{bbox:A(l=Bt,In,lh).call(l,s(this,ji).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();s(this,zc)&&(e.setAttribute("aria-label",s(this,zc)),e.setAttribute("role","mark")),s(this,hi)?e.classList.add("free"):this.div.addEventListener("keydown",A(this,At,Rw).bind(this),{signal:this._uiManager._signal});const i=p(this,Ga,document.createElement("div"));return e.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",i.style.clipPath=s(this,Va),this.setDims(),y0(this,s(this,Ga),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(s(this,vi),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(s(this,vi),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:A(this,At,zp).call(this,!0);break;case 1:case 3:A(this,At,zp).call(this,!1);break}}select(){var e;super.select(),s(this,vi)&&((e=this.parent)==null||e.drawLayer.updateProperties(s(this,vi),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),s(this,vi)&&((e=this.parent)==null||e.drawLayer.updateProperties(s(this,vi),{rootClass:{selected:!1}}),s(this,hi)||A(this,At,zp).call(this,!1))}get _mustFixPosition(){return!s(this,hi)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(s(this,un),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(s(this,vi),{rootClass:{hidden:!e}}))}static startHighlighting(e,i,{target:n,x:r,y:o}){const{x:l,y:c,width:h,height:d}=n.getBoundingClientRect(),f=new AbortController,u=e.combinedSignal(f),g=b=>{f.abort(),A(this,In,Lw).call(this,e,b)};window.addEventListener("blur",g,{signal:u}),window.addEventListener("pointerup",g,{signal:u}),window.addEventListener("pointerdown",Ee,{capture:!0,passive:!1,signal:u}),window.addEventListener("contextmenu",vn,{signal:u}),n.addEventListener("pointermove",A(this,In,Iw).bind(this,e),{signal:u}),this._freeHighlight=new mm({x:r,y:o},[l,c,h,d],e.scale,this._defaultThickness/2,i,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,i,n){var m,w,y,x;let r=null;if(e instanceof sv){const{data:{quadPoints:E,rect:_,rotation:C,id:T,color:D,opacity:j,popupRef:O,richText:H,contentsObj:N,creationDate:lt,modificationDate:G},parent:{page:{pageNumber:K}}}=e;r=e={annotationType:mt.HIGHLIGHT,color:Array.from(D),opacity:j,quadPoints:E,boxes:null,pageIndex:K-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:O,richText:H,comment:(N==null?void 0:N.str)||null,creationDate:lt,modificationDate:G}}else if(e instanceof um){const{data:{inkLists:E,rect:_,rotation:C,id:T,color:D,borderStyle:{rawWidth:j},popupRef:O,richText:H,contentsObj:N,creationDate:lt,modificationDate:G},parent:{page:{pageNumber:K}}}=e;r=e={annotationType:mt.HIGHLIGHT,color:Array.from(D),thickness:j,inkLists:E,boxes:null,pageIndex:K-1,rect:_.slice(0),rotation:C,annotationElementId:T,id:T,deleted:!1,popupRef:O,richText:H,comment:(N==null?void 0:N.str)||null,creationDate:lt,modificationDate:G}}const{color:o,quadPoints:l,inkLists:c,opacity:h}=e,d=await super.deserialize(e,i,n);d.color=Z.makeHexColor(...o),d.opacity=h||1,c&&p(d,On,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[f,u]=d.pageDimensions,[g,b]=d.pageTranslation;if(l){const E=p(d,yr,[]);for(let _=0;_<l.length;_+=8)E.push({x:(l[_]-g)/f,y:1-(l[_+1]-b)/u,width:(l[_+2]-l[_])/f,height:(l[_+1]-l[_+5])/u});A(m=d,At,xb).call(m),A(w=d,At,hl).call(w),d.rotate(d.rotation)}else if(c){p(d,hi,!0);const E=c[0],_={x:E[0]-g,y:u-(E[1]-b)},C=new mm(_,[0,0,f,u],1,s(d,On)/2,!0,.001);for(let j=0,O=E.length;j<O;j+=2)_.x=E[j]-g,_.y=u-(E[j+1]-b),C.add(_);const{id:T,clipPathId:D}=i.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:C.toSVGPath()}},!0,!0);A(y=d,At,jp).call(y,{highlightOutlines:C.getOutlines(),highlightId:T,clipPathId:D}),A(x=d,At,hl).call(x),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const i=ae._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:i,opacity:this.opacity,thickness:s(this,On),quadPoints:A(this,At,Dw).call(this),outlines:A(this,At,Ow).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!A(this,At,Nw).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};Fc=new WeakMap,bu=new WeakMap,yr=new WeakMap,Va=new WeakMap,yu=new WeakMap,ji=new WeakMap,vu=new WeakMap,wu=new WeakMap,Ga=new WeakMap,dn=new WeakMap,un=new WeakMap,hi=new WeakMap,Bc=new WeakMap,jc=new WeakMap,vi=new WeakMap,zc=new WeakMap,On=new WeakMap,Au=new WeakMap,At=new WeakSet,xb=function(){const e=new gm(s(this,yr),.001);p(this,dn,e.getOutlines()),[this.x,this.y,this.width,this.height]=s(this,dn).box;const i=new gm(s(this,yr),.0025,.001,this._uiManager.direction==="ltr");p(this,ji,i.getOutlines());const{firstPoint:n}=s(this,dn);p(this,Bc,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=s(this,ji);p(this,jc,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},jp=function({highlightOutlines:e,highlightId:i,clipPathId:n}){var u,g;if(p(this,dn,e),p(this,ji,e.getNewOutline(s(this,On)/2+1.5,.0025)),i>=0)p(this,un,i),p(this,Va,n),this.parent.drawLayer.finalizeDraw(i,{bbox:e.box,path:{d:e.toSVGPath()}}),p(this,vi,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:s(this,ji).box,path:{d:s(this,ji).toSVGPath()}},!0));else if(this.parent){const b=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(s(this,un),{bbox:A(u=Bt,In,lh).call(u,s(this,dn).box,(b-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(s(this,vi),{bbox:A(g=Bt,In,lh).call(g,s(this,ji).box,b),path:{d:s(this,ji).toSVGPath()}})}const[o,l,c,h]=e.box;switch(this.rotation){case 0:this.x=o,this.y=l,this.width=c,this.height=h;break;case 90:{const[b,m]=this.parentDimensions;this.x=l,this.y=1-o,this.width=c*m/b,this.height=h*b/m;break}case 180:this.x=1-o,this.y=1-l,this.width=c,this.height=h;break;case 270:{const[b,m]=this.parentDimensions;this.x=1-l,this.y=o,this.width=c*m/b,this.height=h*b/m;break}}const{firstPoint:d}=e;p(this,Bc,[(d[0]-o)/c,(d[1]-l)/h]);const{lastPoint:f}=s(this,ji);p(this,jc,[(f[0]-o)/c,(f[1]-l)/h])},Pw=function(e){const i=(o,l)=>{this.color=o,this.opacity=l,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:i.bind(this,e,Bt._defaultOpacity),undo:i.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},kw=function(e){const i=s(this,On),n=r=>{p(this,On,r),A(this,At,Mw).call(this,r)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Mt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Mw=function(e){s(this,hi)&&(A(this,At,jp).call(this,{highlightOutlines:s(this,dn).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},Cb=function(){s(this,un)===null||!this.parent||(this.parent.drawLayer.remove(s(this,un)),p(this,un,null),this.parent.drawLayer.remove(s(this,vi)),p(this,vi,null))},hl=function(e=this.parent){s(this,un)===null&&({id:Xe(this,un)._,clipPathId:Xe(this,Va)._}=e.drawLayer.draw({bbox:s(this,dn).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:s(this,hi)},path:{d:s(this,dn).toSVGPath()}},!1,!0),p(this,vi,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:s(this,hi)},bbox:s(this,ji).box,path:{d:s(this,ji).toSVGPath()}},s(this,hi))),s(this,Ga)&&(s(this,Ga).style.clipPath=s(this,Va)))},In=new WeakSet,lh=function([e,i,n,r],o){switch(o){case 90:return[1-i-r,e,r,n];case 180:return[1-e-n,1-i-r,n,r];case 270:return[i,1-e-n,r,n]}return[e,i,n,r]},Rw=function(e){Bt._keyboardManager.exec(this,e)},zp=function(e){if(!s(this,Fc))return;const i=window.getSelection();e?i.setPosition(s(this,Fc),s(this,bu)):i.setPosition(s(this,vu),s(this,wu))},Up=function(){return s(this,hi)?this.rotation:0},Dw=function(){if(s(this,hi))return null;const[e,i]=this.pageDimensions,[n,r]=this.pageTranslation,o=s(this,yr),l=new Float32Array(o.length*8);let c=0;for(const{x:h,y:d,width:f,height:u}of o){const g=h*e+n,b=(1-d)*i+r;l[c]=l[c+4]=g,l[c+1]=l[c+3]=b,l[c+2]=l[c+6]=g+f*e,l[c+5]=l[c+7]=b-u*i,c+=8}return l},Ow=function(e){return s(this,dn).serialize(e,A(this,At,Up).call(this))},Iw=function(e,i){this._freeHighlight.add(i)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Lw=function(e,i){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(i,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Nw=function(e){const{color:i}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==i[r])},v(Bt,In),$(Bt,"_defaultColor",null),$(Bt,"_defaultOpacity",1),$(Bt,"_defaultThickness",12),$(Bt,"_type","highlight"),$(Bt,"_editorType",mt.HIGHLIGHT),$(Bt,"_freeHighlightId",-1),$(Bt,"_freeHighlight",null),$(Bt,"_freeHighlightClipId","");let Ff=Bt;class av{constructor(){v(this,Ya,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){s(this,Ya)[t]=e}toSVGProperties(){const t=s(this,Ya);return p(this,Ya,Object.create(null)),{root:t}}reset(){p(this,Ya,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){ie("Not implemented")}}Ya=new WeakMap;const kt=class kt extends ae{constructor(e){super(e);v(this,It);v(this,fn,null);v(this,Uc);$(this,"_colorPicker",null);$(this,"_drawId",null);p(this,Uc,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(A(this,It,_b).call(this,e),A(this,It,Xu).call(this))}static _mergeSVGProperties(e,i){const n=new Set(Object.keys(e));for(const[r,o]of Object.entries(i))n.has(r)?Object.assign(e[r],o):e[r]=o;return e}static getDefaultDrawingOptions(e){ie("Not implemented")}static get typesMap(){ie("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,i){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,i),this._currentParent&&(s(kt,Ze).updateProperty(n,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,i){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,i)}static get defaultPropertiesToUpdate(){const e=[],i=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,i[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:i}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,i[r]]);return e}_updateProperty(e,i,n){const r=this._drawingOptions,o=r[i],l=c=>{var d;r.updateProperty(i,c);const h=s(this,fn).updateProperty(i,c);h&&A(this,It,qu).call(this,h),(d=this.parent)==null||d.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:l.bind(this,n),undo:l.bind(this,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,kt._mergeSVGProperties(s(this,fn).getPathResizingSVGProperties(A(this,It,Hp).call(this)),{bbox:A(this,It,ch).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,kt._mergeSVGProperties(s(this,fn).getPathResizedSVGProperties(A(this,It,Hp).call(this)),{bbox:A(this,It,ch).call(this)}))}_onTranslating(e,i){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:A(this,It,ch).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,kt._mergeSVGProperties(s(this,fn).getPathTranslatedSVGProperties(A(this,It,Hp).call(this),this.parentDimensions),{bbox:A(this,It,ch).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,s(this,Uc)&&(p(this,Uc,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){A(this,It,Pb).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(A(this,It,Xu).call(this),A(this,It,qu).call(this,s(this,fn).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let i=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),A(this,It,Pb).call(this)):e&&(this._uiManager.addShouldRescale(this),A(this,It,Xu).call(this,e),i=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),i&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,kt._mergeSVGProperties({bbox:A(this,It,ch).call(this)},s(this,fn).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&A(this,It,qu).call(this,s(this,fn).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,i;this._isCopy&&(e=this.x,i=this.y);const n=super.render();n.classList.add("draw");const r=document.createElement("div");return n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,i),n}static createDrawerInstance(e,i,n,r,o){ie("Not implemented")}static startDrawing(e,i,n,r){var w;const{target:o,offsetX:l,offsetY:c,pointerId:h,pointerType:d}=r;if(pi.isInitializedAndDifferentPointerType(d))return;const{viewport:{rotation:f}}=e,{width:u,height:g}=o.getBoundingClientRect(),b=p(kt,Xa,new AbortController),m=e.combinedSignal(b);if(pi.setPointer(d,h),window.addEventListener("pointerup",y=>{pi.isSamePointerIdOrRemove(y.pointerId)&&this._endDraw(y)},{signal:m}),window.addEventListener("pointercancel",y=>{pi.isSamePointerIdOrRemove(y.pointerId)&&this._currentParent.endDrawingSession()},{signal:m}),window.addEventListener("pointerdown",y=>{pi.isSamePointerType(y.pointerType)&&(pi.initializeAndAddPointerId(y.pointerId),s(kt,Ze).isCancellable()&&(s(kt,Ze).removeLastElement(),s(kt,Ze).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",vn,{signal:m}),o.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),o.addEventListener("touchmove",y=>{pi.isSameTimeStamp(y.timeStamp)&&Ee(y)},{signal:m}),e.toggleDrawing(),(w=i._editorUndoBar)==null||w.hide(),s(kt,Ze)){e.drawLayer.updateProperties(this._currentDrawId,s(kt,Ze).startNew(l,c,u,g,f));return}i.updateUIForDefaultProperties(this),p(kt,Ze,this.createDrawerInstance(l,c,u,g,f)),p(kt,qa,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(s(kt,qa).toSVGProperties(),s(kt,Ze).defaultSVGProperties),!0,!1)}static _drawMove(e){if(pi.isSameTimeStamp(e.timeStamp),!s(kt,Ze))return;const{offsetX:i,offsetY:n,pointerId:r}=e;if(pi.isSamePointerId(r)){if(pi.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,s(kt,Ze).add(i,n)),pi.setTimeStamp(e.timeStamp),Ee(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,p(kt,Ze,null),p(kt,qa,null),pi.clearTimeStamp()),s(kt,Xa)&&(s(kt,Xa).abort(),p(kt,Xa,null),pi.clearPointerIds())}static _endDraw(e){const i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===i.div&&i.drawLayer.updateProperties(this._currentDrawId,s(kt,Ze).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=s(kt,Ze),r=this._currentDrawId,o=n.getLastElement();i.addCommands({cmd:()=>{i.drawLayer.updateProperties(r,n.setLastElement(o))},undo:()=>{i.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:Mt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(Mt.DRAW_STEP),!s(kt,Ze).isEmpty()){const{pageDimensions:[n,r],scale:o}=i,l=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:s(kt,Ze).getOutlines(n*o,r*o,o,this._INNER_MARGIN),drawingOptions:s(kt,qa),mustBeCommitted:!e});return this._cleanup(!0),l}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,i,n,r,o,l){ie("Not implemented")}static async deserialize(e,i,n){var f,u;const{rawDims:{pageWidth:r,pageHeight:o,pageX:l,pageY:c}}=i.viewport,h=this.deserializeDraw(l,c,r,o,this._INNER_MARGIN,e),d=await super.deserialize(e,i,n);return d.createDrawingOptions(e),A(f=d,It,_b).call(f,{drawOutlines:h}),A(u=d,It,Xu).call(u),d.onScaleChanging(),d.rotate(),d}serializeDraw(e){const[i,n]=this.pageTranslation,[r,o]=this.pageDimensions;return s(this,fn).serialize([i,n,r,o],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};fn=new WeakMap,Uc=new WeakMap,Ze=new WeakMap,Xa=new WeakMap,qa=new WeakMap,It=new WeakSet,_b=function({drawOutlines:e,drawId:i,drawingOptions:n}){p(this,fn,e),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),i>=0?(this._drawId=i,this.parent.drawLayer.finalizeDraw(i,e.defaultProperties)):this._drawId=A(this,It,Tb).call(this,e,this.parent),A(this,It,qu).call(this,e.box)},Tb=function(e,i){const{id:n}=i.drawLayer.draw(kt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},Pb=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},Xu=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=A(this,It,Tb).call(this,s(this,fn),e)}},Fw=function([e,i,n,r]){const{parentDimensions:[o,l],rotation:c}=this;switch(c){case 90:return[i,1-e,n*(l/o),r*(o/l)];case 180:return[1-e,1-i,n,r];case 270:return[1-i,e,n*(l/o),r*(o/l)];default:return[e,i,n,r]}},Hp=function(){const{x:e,y:i,width:n,height:r,parentDimensions:[o,l],rotation:c}=this;switch(c){case 90:return[1-i,e,n*(o/l),r*(l/o)];case 180:return[1-e,1-i,n,r];case 270:return[i,1-e,n*(o/l),r*(l/o)];default:return[e,i,n,r]}},qu=function(e){[this.x,this.y,this.width,this.height]=A(this,It,Fw).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},ch=function(){const{x:e,y:i,width:n,height:r,rotation:o,parentRotation:l,parentDimensions:[c,h]}=this;switch((o*4+l)/90){case 1:return[1-i-r,e,r,n];case 2:return[1-e-n,1-i-r,n,r];case 3:return[i,1-e-n,r,n];case 4:return[e,i-n*(c/h),r*(h/c),n*(c/h)];case 5:return[1-i,e,n*(c/h),r*(h/c)];case 6:return[1-e-r*(h/c),1-i,r*(h/c),n*(c/h)];case 7:return[i-n*(c/h),1-e-r*(h/c),n*(c/h),r*(h/c)];case 8:return[e-n,i-r,n,r];case 9:return[1-i,e-n,r,n];case 10:return[1-e,1-i,n,r];case 11:return[i-r,1-e,r,n];case 12:return[e-r*(h/c),i,r*(h/c),n*(c/h)];case 13:return[1-i-n*(c/h),e-r*(h/c),n*(c/h),r*(h/c)];case 14:return[1-e,1-i-n*(c/h),r*(h/c),n*(c/h)];case 15:return[i,1-e,n*(c/h),r*(h/c)];default:return[e,i,n,r]}},$(kt,"_currentDrawId",-1),$(kt,"_currentParent",null),v(kt,Ze,null),v(kt,Xa,null),v(kt,qa,null),$(kt,"_INNER_MARGIN",3);let Bf=kt;class Mx{constructor(t,e,i,n,r,o){v(this,$c);v(this,xs,new Float64Array(6));v(this,Qe);v(this,ti);v(this,Ka);v(this,Hc);v(this,Ti);v(this,di,"");v(this,Ln,0);v(this,Ja,new Oh);v(this,Za);v(this,Qa);p(this,Za,i),p(this,Qa,n),p(this,Ka,r),p(this,Hc,o),[t,e]=A(this,$c,$p).call(this,t,e);const l=p(this,Qe,[NaN,NaN,NaN,NaN,t,e]);p(this,Ti,[t,e]),p(this,ti,[{line:l,points:s(this,Ti)}]),s(this,xs).set(l,0)}updateProperty(t,e){t==="stroke-width"&&p(this,Hc,e)}isEmpty(){return!s(this,ti)||s(this,ti).length===0}isCancellable(){return s(this,Ti).length<=10}add(t,e){[t,e]=A(this,$c,$p).call(this,t,e);const[i,n,r,o]=s(this,xs).subarray(2,6),l=t-r,c=e-o;return Math.hypot(s(this,Za)*l,s(this,Qa)*c)<=2?null:(s(this,Ti).push(t,e),isNaN(i)?(s(this,xs).set([r,o,t,e],2),s(this,Qe).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(s(this,xs)[0])&&s(this,Qe).splice(6,6),s(this,xs).set([i,n,r,o,t,e],0),s(this,Qe).push(...it.createBezierPoints(i,n,r,o,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(s(this,Ti).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,r){p(this,Za,i),p(this,Qa,n),p(this,Ka,r),[t,e]=A(this,$c,$p).call(this,t,e);const o=p(this,Qe,[NaN,NaN,NaN,NaN,t,e]);p(this,Ti,[t,e]);const l=s(this,ti).at(-1);return l&&(l.line=new Float32Array(l.line),l.points=new Float32Array(l.points)),s(this,ti).push({line:o,points:s(this,Ti)}),s(this,xs).set(o,0),p(this,Ln,0),this.toSVGPath(),null}getLastElement(){return s(this,ti).at(-1)}setLastElement(t){return s(this,ti)?(s(this,ti).push(t),p(this,Qe,t.line),p(this,Ti,t.points),p(this,Ln,0),{path:{d:this.toSVGPath()}}):s(this,Ja).setLastElement(t)}removeLastElement(){if(!s(this,ti))return s(this,Ja).removeLastElement();s(this,ti).pop(),p(this,di,"");for(let t=0,e=s(this,ti).length;t<e;t++){const{line:i,points:n}=s(this,ti)[t];p(this,Qe,i),p(this,Ti,n),p(this,Ln,0),this.toSVGPath()}return{path:{d:s(this,di)}}}toSVGPath(){const t=it.svgRound(s(this,Qe)[4]),e=it.svgRound(s(this,Qe)[5]);if(s(this,Ti).length===2)return p(this,di,`${s(this,di)} M ${t} ${e} Z`),s(this,di);if(s(this,Ti).length<=6){const n=s(this,di).lastIndexOf("M");p(this,di,`${s(this,di).slice(0,n)} M ${t} ${e}`),p(this,Ln,6)}if(s(this,Ti).length===4){const n=it.svgRound(s(this,Qe)[10]),r=it.svgRound(s(this,Qe)[11]);return p(this,di,`${s(this,di)} L ${n} ${r}`),p(this,Ln,12),s(this,di)}const i=[];s(this,Ln)===0&&(i.push(`M ${t} ${e}`),p(this,Ln,6));for(let n=s(this,Ln),r=s(this,Qe).length;n<r;n+=6){const[o,l,c,h,d,f]=s(this,Qe).slice(n,n+6).map(it.svgRound);i.push(`C${o} ${l} ${c} ${h} ${d} ${f}`)}return p(this,di,s(this,di)+i.join(" ")),p(this,Ln,s(this,Qe).length),s(this,di)}getOutlines(t,e,i,n){const r=s(this,ti).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),s(this,Ja).build(s(this,ti),t,e,i,s(this,Ka),s(this,Hc),n),p(this,xs,null),p(this,Qe,null),p(this,ti,null),p(this,di,null),s(this,Ja)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}xs=new WeakMap,Qe=new WeakMap,ti=new WeakMap,Ka=new WeakMap,Hc=new WeakMap,Ti=new WeakMap,di=new WeakMap,Ln=new WeakMap,Ja=new WeakMap,Za=new WeakMap,Qa=new WeakMap,$c=new WeakSet,$p=function(t,e){return it._normalizePoint(t,e,s(this,Za),s(this,Qa),s(this,Ka))};class Oh extends it{constructor(){super(...arguments);v(this,ui);v(this,Pi);v(this,Su,0);v(this,Eu);v(this,pn);v(this,Cs);v(this,_s);v(this,Wc);v(this,Vc);v(this,tl)}build(e,i,n,r,o,l,c){p(this,Cs,i),p(this,_s,n),p(this,Wc,r),p(this,Vc,o),p(this,tl,l),p(this,Eu,c??0),p(this,pn,e),A(this,ui,jw).call(this)}get thickness(){return s(this,tl)}setLastElement(e){return s(this,pn).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return s(this,pn).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:i}of s(this,pn)){if(e.push(`M${it.svgRound(i[4])} ${it.svgRound(i[5])}`),i.length===6){e.push("Z");continue}if(i.length===12&&isNaN(i[6])){e.push(`L${it.svgRound(i[10])} ${it.svgRound(i[11])}`);continue}for(let n=6,r=i.length;n<r;n+=6){const[o,l,c,h,d,f]=i.subarray(n,n+6).map(it.svgRound);e.push(`C${o} ${l} ${c} ${h} ${d} ${f}`)}}return e.join("")}serialize([e,i,n,r],o){const l=[],c=[],[h,d,f,u]=A(this,ui,Bw).call(this);let g,b,m,w,y,x,E,_,C;switch(s(this,Vc)){case 0:C=it._rescale,g=e,b=i+r,m=n,w=-r,y=e+h*n,x=i+(1-d-u)*r,E=e+(h+f)*n,_=i+(1-d)*r;break;case 90:C=it._rescaleAndSwap,g=e,b=i,m=n,w=r,y=e+d*n,x=i+h*r,E=e+(d+u)*n,_=i+(h+f)*r;break;case 180:C=it._rescale,g=e+n,b=i,m=-n,w=r,y=e+(1-h-f)*n,x=i+d*r,E=e+(1-h)*n,_=i+(d+u)*r;break;case 270:C=it._rescaleAndSwap,g=e+n,b=i+r,m=-n,w=-r,y=e+(1-d-u)*n,x=i+(1-h-f)*r,E=e+(1-d)*n,_=i+(1-h)*r;break}for(const{line:T,points:D}of s(this,pn))l.push(C(T,g,b,m,w,o?new Array(T.length):null)),c.push(C(D,g,b,m,w,o?new Array(D.length):null));return{lines:l,points:c,rect:[y,x,E,_]}}static deserialize(e,i,n,r,o,{paths:{lines:l,points:c},rotation:h,thickness:d}){const f=[];let u,g,b,m,w;switch(h){case 0:w=it._rescale,u=-e/n,g=i/r+1,b=1/n,m=-1/r;break;case 90:w=it._rescaleAndSwap,u=-i/r,g=-e/n,b=1/r,m=1/n;break;case 180:w=it._rescale,u=e/n+1,g=-i/r,b=-1/n,m=1/r;break;case 270:w=it._rescaleAndSwap,u=i/r+1,g=e/n+1,b=-1/r,m=-1/n;break}if(!l){l=[];for(const x of c){const E=x.length;if(E===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1]]));continue}if(E===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,x[0],x[1],NaN,NaN,NaN,NaN,x[2],x[3]]));continue}const _=new Float32Array(3*(E-2));l.push(_);let[C,T,D,j]=x.subarray(0,4);_.set([NaN,NaN,NaN,NaN,C,T],0);for(let O=4;O<E;O+=2){const H=x[O],N=x[O+1];_.set(it.createBezierPoints(C,T,D,j,H,N),(O-2)*3),[C,T,D,j]=[D,j,H,N]}}}for(let x=0,E=l.length;x<E;x++)f.push({line:w(l[x].map(_=>_??NaN),u,g,b,m),points:w(c[x].map(_=>_??NaN),u,g,b,m)});const y=new this.prototype.constructor;return y.build(f,n,r,1,h,d,o),y}get box(){return s(this,Pi)}updateProperty(e,i){return e==="stroke-width"?A(this,ui,zw).call(this,i):null}updateParentDimensions([e,i],n){const[r,o]=A(this,ui,Pr).call(this);p(this,Cs,e),p(this,_s,i),p(this,Wc,n);const[l,c]=A(this,ui,Pr).call(this),h=l-r,d=c-o,f=s(this,Pi);return f[0]-=h,f[1]-=d,f[2]+=2*h,f[3]+=2*d,f}updateRotation(e){return p(this,Su,e),{path:{transform:this.rotationTransform}}}get viewBox(){return s(this,Pi).map(it.svgRound).join(" ")}get defaultProperties(){const[e,i]=s(this,Pi);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${it.svgRound(e)} ${it.svgRound(i)}`}}}get rotationTransform(){const[,,e,i]=s(this,Pi);let n=0,r=0,o=0,l=0,c=0,h=0;switch(s(this,Su)){case 90:r=i/e,o=-e/i,c=e;break;case 180:n=-1,l=-1,c=e,h=i;break;case 270:r=-i/e,o=e/i,h=i;break;default:return""}return`matrix(${n} ${r} ${o} ${l} ${it.svgRound(c)} ${it.svgRound(h)})`}getPathResizingSVGProperties([e,i,n,r]){const[o,l]=A(this,ui,Pr).call(this),[c,h,d,f]=s(this,Pi);if(Math.abs(d-o)<=it.PRECISION||Math.abs(f-l)<=it.PRECISION){const w=e+n/2-(c+d/2),y=i+r/2-(h+f/2);return{path:{"transform-origin":`${it.svgRound(e)} ${it.svgRound(i)}`,transform:`${this.rotationTransform} translate(${w} ${y})`}}}const u=(n-2*o)/(d-2*o),g=(r-2*l)/(f-2*l),b=d/n,m=f/r;return{path:{"transform-origin":`${it.svgRound(c)} ${it.svgRound(h)}`,transform:`${this.rotationTransform} scale(${b} ${m}) translate(${it.svgRound(o)} ${it.svgRound(l)}) scale(${u} ${g}) translate(${it.svgRound(-o)} ${it.svgRound(-l)})`}}}getPathResizedSVGProperties([e,i,n,r]){const[o,l]=A(this,ui,Pr).call(this),c=s(this,Pi),[h,d,f,u]=c;if(c[0]=e,c[1]=i,c[2]=n,c[3]=r,Math.abs(f-o)<=it.PRECISION||Math.abs(u-l)<=it.PRECISION){const y=e+n/2-(h+f/2),x=i+r/2-(d+u/2);for(const{line:E,points:_}of s(this,pn))it._translate(E,y,x,E),it._translate(_,y,x,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${it.svgRound(e)} ${it.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const g=(n-2*o)/(f-2*o),b=(r-2*l)/(u-2*l),m=-g*(h+o)+e+o,w=-b*(d+l)+i+l;if(g!==1||b!==1||m!==0||w!==0)for(const{line:y,points:x}of s(this,pn))it._rescale(y,m,w,g,b,y),it._rescale(x,m,w,g,b,x);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${it.svgRound(e)} ${it.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,i],n){const[r,o]=n,l=s(this,Pi),c=e-l[0],h=i-l[1];if(s(this,Cs)===r&&s(this,_s)===o)for(const{line:d,points:f}of s(this,pn))it._translate(d,c,h,d),it._translate(f,c,h,f);else{const d=s(this,Cs)/r,f=s(this,_s)/o;p(this,Cs,r),p(this,_s,o);for(const{line:u,points:g}of s(this,pn))it._rescale(u,c,h,d,f,u),it._rescale(g,c,h,d,f,g);l[2]*=d,l[3]*=f}return l[0]=e,l[1]=i,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${it.svgRound(e)} ${it.svgRound(i)}`}}}get defaultSVGProperties(){const e=s(this,Pi);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${it.svgRound(e[0])} ${it.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Pi=new WeakMap,Su=new WeakMap,Eu=new WeakMap,pn=new WeakMap,Cs=new WeakMap,_s=new WeakMap,Wc=new WeakMap,Vc=new WeakMap,tl=new WeakMap,ui=new WeakSet,Pr=function(e=s(this,tl)){const i=s(this,Eu)+e/2*s(this,Wc);return s(this,Vc)%180===0?[i/s(this,Cs),i/s(this,_s)]:[i/s(this,_s),i/s(this,Cs)]},Bw=function(){const[e,i,n,r]=s(this,Pi),[o,l]=A(this,ui,Pr).call(this,0);return[e+o,i+l,n-2*o,r-2*l]},jw=function(){const e=p(this,Pi,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of s(this,pn)){if(r.length<=12){for(let c=4,h=r.length;c<h;c+=6)Z.pointBoundingBox(r[c],r[c+1],e);continue}let o=r[4],l=r[5];for(let c=6,h=r.length;c<h;c+=6){const[d,f,u,g,b,m]=r.subarray(c,c+6);Z.bezierBoundingBox(o,l,d,f,u,g,b,m,e),o=b,l=m}}const[i,n]=A(this,ui,Pr).call(this);e[0]=Ei(e[0]-i,0,1),e[1]=Ei(e[1]-n,0,1),e[2]=Ei(e[2]+i,0,1),e[3]=Ei(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},zw=function(e){const[i,n]=A(this,ui,Pr).call(this);p(this,tl,e);const[r,o]=A(this,ui,Pr).call(this),[l,c]=[r-i,o-n],h=s(this,Pi);return h[0]-=l,h[1]-=c,h[2]+=2*l,h[3]+=2*c,h};class jf extends av{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:ae._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new jf(this._viewParameters);return t.updateAll(this),t}}const Gc=class Gc extends Bf{constructor(e){super({...e,name:"inkEditor"});v(this,sp);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,i){ae.initialize(e,i),this._defaultDrawingOptions=new jf(i.viewParameters)}static getDefaultDrawingOptions(e){const i=this._defaultDrawingOptions.clone();return i.updateProperties(e),i}static get supportMultipleDrawings(){return!0}static get typesMap(){return gt(this,"typesMap",new Map([[Mt.INK_THICKNESS,"stroke-width"],[Mt.INK_COLOR,"stroke"],[Mt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,i,n,r,o){return new Mx(e,i,n,r,o,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,i,n,r,o,l){return Oh.deserialize(e,i,n,r,o,l)}static async deserialize(e,i,n){let r=null;if(e instanceof um){const{data:{inkLists:l,rect:c,rotation:h,id:d,color:f,opacity:u,borderStyle:{rawWidth:g},popupRef:b,richText:m,contentsObj:w,creationDate:y,modificationDate:x},parent:{page:{pageNumber:E}}}=e;r=e={annotationType:mt.INK,color:Array.from(f),thickness:g,opacity:u,paths:{points:l},boxes:null,pageIndex:E-1,rect:c.slice(0),rotation:h,annotationElementId:d,id:d,deleted:!1,popupRef:b,richText:m,comment:(w==null?void 0:w.str)||null,creationDate:y,modificationDate:x}}const o=await super.deserialize(e,i,n);return o._initialData=r,e.comment&&o.setCommentData(e),o}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new Of(this)),[["colorPicker",this._colorPicker]]}get colorType(){return Mt.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:i,parent:n}=this;i.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,i.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:i,opacity:n}){this._drawingOptions=Gc.getDefaultDrawingOptions({stroke:Z.makeHexColor(...e),"stroke-width":i,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:i,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":o,"stroke-width":l}}=this,c=Object.assign(super.serialize(e),{color:ae._colorManager.convert(r),opacity:o,thickness:l,paths:{lines:i,points:n}});return this.addComment(c),e?(c.isCopy=!0,c):this.annotationElementId&&!A(this,sp,Uw).call(this,c)?null:(c.id=this.annotationElementId,c)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:i,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:i,popup:this.comment}),null}};sp=new WeakSet,Uw=function(e){const{color:i,thickness:n,opacity:r,pageIndex:o}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((l,c)=>l!==i[c])||e.thickness!==n||e.opacity!==r||e.pageIndex!==o},$(Gc,"_type","ink"),$(Gc,"_editorType",mt.INK),$(Gc,"_defaultDrawingOptions",null);let bm=Gc;class ym extends Oh{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const zf=8,Ih=3;class Ns{static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:n},r,o,l,c){let h=new OffscreenCanvas(1,1),d=h.getContext("2d",{alpha:!1});const f=200,u=d.font=`${i} ${n} ${f}px ${e}`,{actualBoundingBoxLeft:g,actualBoundingBoxRight:b,actualBoundingBoxAscent:m,actualBoundingBoxDescent:w,fontBoundingBoxAscent:y,fontBoundingBoxDescent:x,width:E}=d.measureText(t),_=1.5,C=Math.ceil(Math.max(Math.abs(g)+Math.abs(b)||0,E)*_),T=Math.ceil(Math.max(Math.abs(m)+Math.abs(w)||f,Math.abs(y)+Math.abs(x)||f)*_);h=new OffscreenCanvas(C,T),d=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),d.font=u,d.filter="grayscale(1)",d.fillStyle="white",d.fillRect(0,0,C,T),d.fillStyle="black",d.fillText(t,C*(_-1)/2,T*(3-_)/2);const D=A(this,Vt,Rb).call(this,d.getImageData(0,0,C,T).data),j=A(this,Vt,Gw).call(this,D),O=A(this,Vt,Db).call(this,j),H=A(this,Vt,Mb).call(this,D,C,T,O);return this.processDrawnLines({lines:{curves:H,width:C,height:T},pageWidth:r,pageHeight:o,rotation:l,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(t,e,i,n,r){const[o,l,c]=A(this,Vt,Yw).call(this,t),[h,d]=A(this,Vt,Vw).call(this,o,l,c,Math.hypot(l,c)*s(this,el).sigmaSFactor,s(this,el).sigmaR,s(this,el).kernelSize),f=A(this,Vt,Db).call(this,d),u=A(this,Vt,Mb).call(this,h,l,c,f);return this.processDrawnLines({lines:{curves:u,width:l,height:c},pageWidth:e,pageHeight:i,rotation:n,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:r,mustSmooth:o,areContours:l}){n%180!==0&&([e,i]=[i,e]);const{curves:c,width:h,height:d}=t,f=t.thickness??0,u=[],g=Math.min(e/h,i/d),b=g/e,m=g/i,w=[];for(const{points:x}of c){const E=o?A(this,Vt,Ww).call(this,x):x;if(!E)continue;w.push(E);const _=E.length,C=new Float32Array(_),T=new Float32Array(3*(_===2?2:_-2));if(u.push({line:T,points:C}),_===2){C[0]=E[0]*b,C[1]=E[1]*m,T.set([NaN,NaN,NaN,NaN,C[0],C[1]],0);continue}let[D,j,O,H]=E;D*=b,j*=m,O*=b,H*=m,C.set([D,j,O,H],0),T.set([NaN,NaN,NaN,NaN,D,j],0);for(let N=4;N<_;N+=2){const lt=C[N]=E[N]*b,G=C[N+1]=E[N+1]*m;T.set(it.createBezierPoints(D,j,O,H,lt,G),(N-2)*3),[D,j,O,H]=[O,H,lt,G]}}if(u.length===0)return null;const y=l?new ym:new Oh;return y.build(u,e,i,1,n,l?0:f,r),{outline:y,newCurves:w,areContours:l,thickness:f,width:h,height:d}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:n,height:r}){let o=1/0,l=-1/0,c=0;for(const E of t){c+=E.length;for(let _=2,C=E.length;_<C;_++){const T=E[_]-E[_-2];o=Math.min(o,T),l=Math.max(l,T)}}let h;o>=-128&&l<=127?h=Int8Array:o>=-32768&&l<=32767?h=Int16Array:h=Int32Array;const d=t.length,f=zf+Ih*d,u=new Uint32Array(f);let g=0;u[g++]=f*Uint32Array.BYTES_PER_ELEMENT+(c-2*d)*h.BYTES_PER_ELEMENT,u[g++]=0,u[g++]=n,u[g++]=r,u[g++]=e?0:1,u[g++]=Math.max(0,Math.floor(i??0)),u[g++]=d,u[g++]=h.BYTES_PER_ELEMENT;for(const E of t)u[g++]=E.length-2,u[g++]=E[0],u[g++]=E[1];const b=new CompressionStream("deflate-raw"),m=b.writable.getWriter();await m.ready,m.write(u);const w=h.prototype.constructor;for(const E of t){const _=new w(E.length-2);for(let C=2,T=E.length;C<T;C++)_[C-2]=E[C]-E[C-2];m.write(_)}m.close();const y=await new Response(b.readable).arrayBuffer(),x=new Uint8Array(y);return c0(x)}static async decompressSignature(t){try{const e=GS(t),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let o=null,l=0;for await(const E of i)o||(o=new Uint8Array(new Uint32Array(E.buffer,0,4)[0])),o.set(E,l),l+=E.length;const c=new Uint32Array(o.buffer,0,o.length>>2),h=c[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const d=c[2],f=c[3],u=c[4]===0,g=c[5],b=c[6],m=c[7],w=[],y=(zf+Ih*b)*Uint32Array.BYTES_PER_ELEMENT;let x;switch(m){case Int8Array.BYTES_PER_ELEMENT:x=new Int8Array(o.buffer,y);break;case Int16Array.BYTES_PER_ELEMENT:x=new Int16Array(o.buffer,y);break;case Int32Array.BYTES_PER_ELEMENT:x=new Int32Array(o.buffer,y);break}l=0;for(let E=0;E<b;E++){const _=c[Ih*E+zf],C=new Float32Array(_+2);w.push(C);for(let T=0;T<Ih-1;T++)C[T]=c[Ih*E+zf+T+1];for(let T=0;T<_;T++)C[T+2]=C[T]+x[l++]}return{areContours:u,thickness:g,outlines:w,width:d,height:f}}catch(e){return pt(`decompressSignature: ${e}`),null}}}el=new WeakMap,Vt=new WeakSet,kb=function(t,e,i,n){return i-=t,n-=e,i===0?n>0?0:4:i===1?n+6:2-n},qn=new WeakMap,Hw=function(t,e,i,n,r,o,l){const c=A(this,Vt,kb).call(this,i,n,r,o);for(let h=0;h<8;h++){const d=(-h+c-l+16)%8,f=s(this,qn)[2*d],u=s(this,qn)[2*d+1];if(t[(i+f)*e+(n+u)]!==0)return d}return-1},$w=function(t,e,i,n,r,o,l){const c=A(this,Vt,kb).call(this,i,n,r,o);for(let h=0;h<8;h++){const d=(h+c+l+16)%8,f=s(this,qn)[2*d],u=s(this,qn)[2*d+1];if(t[(i+f)*e+(n+u)]!==0)return d}return-1},Mb=function(t,e,i,n){const r=t.length,o=new Int32Array(r);for(let d=0;d<r;d++)o[d]=t[d]<=n?1:0;for(let d=1;d<i-1;d++)o[d*e]=o[d*e+e-1]=0;for(let d=0;d<e;d++)o[d]=o[e*i-1-d]=0;let l=1,c;const h=[];for(let d=1;d<i-1;d++){c=1;for(let f=1;f<e-1;f++){const u=d*e+f,g=o[u];if(g===0)continue;let b=d,m=f;if(g===1&&o[u-1]===0)l+=1,m-=1;else if(g>=1&&o[u+1]===0)l+=1,m+=1,g>1&&(c=g);else{g!==1&&(c=Math.abs(g));continue}const w=[f,d],y=m===f+1,x={isHole:y,points:w,id:l,parent:0};h.push(x);let E;for(const N of h)if(N.id===c){E=N;break}E?E.isHole?x.parent=y?E.parent:c:x.parent=y?c:E.parent:x.parent=y?c:0;const _=A(this,Vt,Hw).call(this,o,e,d,f,b,m,0);if(_===-1){o[u]=-l,o[u]!==1&&(c=Math.abs(o[u]));continue}let C=s(this,qn)[2*_],T=s(this,qn)[2*_+1];const D=d+C,j=f+T;b=D,m=j;let O=d,H=f;for(;;){const N=A(this,Vt,$w).call(this,o,e,O,H,b,m,1);C=s(this,qn)[2*N],T=s(this,qn)[2*N+1];const lt=O+C,G=H+T;w.push(G,lt);const K=O*e+H;if(o[K+1]===0?o[K]=-l:o[K]===1&&(o[K]=l),lt===d&&G===f&&O===D&&H===j){o[u]!==1&&(c=Math.abs(o[u]));break}else b=O,m=H,O=lt,H=G}}}return h},Wp=function(t,e,i,n){if(i-e<=4){for(let D=e;D<i-2;D+=2)n.push(t[D],t[D+1]);return}const r=t[e],o=t[e+1],l=t[i-4]-r,c=t[i-3]-o,h=Math.hypot(l,c),d=l/h,f=c/h,u=d*o-f*r,g=c/l,b=1/h,m=Math.atan(g),w=Math.cos(m),y=Math.sin(m),x=b*(Math.abs(w)+Math.abs(y)),E=b*(1-x+x**2),_=Math.max(Math.atan(Math.abs(y+w)*E),Math.atan(Math.abs(y-w)*E));let C=0,T=e;for(let D=e+2;D<i-2;D+=2){const j=Math.abs(u-d*t[D+1]+f*t[D]);j>C&&(T=D,C=j)}C>(h*_)**2?(A(this,Vt,Wp).call(this,t,e,T+2,n),A(this,Vt,Wp).call(this,t,T,i,n)):n.push(r,o)},Ww=function(t){const e=[],i=t.length;return A(this,Vt,Wp).call(this,t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e},Vw=function(t,e,i,n,r,o){const l=new Float32Array(o**2),c=-2*n**2,h=o>>1;for(let m=0;m<o;m++){const w=(m-h)**2;for(let y=0;y<o;y++)l[m*o+y]=Math.exp((w+(y-h)**2)/c)}const d=new Float32Array(256),f=-2*r**2;for(let m=0;m<256;m++)d[m]=Math.exp(m**2/f);const u=t.length,g=new Uint8Array(u),b=new Uint32Array(256);for(let m=0;m<i;m++)for(let w=0;w<e;w++){const y=m*e+w,x=t[y];let E=0,_=0;for(let T=0;T<o;T++){const D=m+T-h;if(!(D<0||D>=i))for(let j=0;j<o;j++){const O=w+j-h;if(O<0||O>=e)continue;const H=t[D*e+O],N=l[T*o+j]*d[Math.abs(H-x)];E+=H*N,_+=N}}const C=g[y]=Math.round(E/_);b[C]++}return[g,b]},Gw=function(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e},Rb=function(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let n=-1/0,r=1/0;for(let l=0,c=i.length;l<c;l++){const h=i[l]=t[l<<2];n=Math.max(n,h),r=Math.min(r,h)}const o=255/(n-r);for(let l=0,c=i.length;l<c;l++)i[l]=(i[l]-r)*o;return i},Db=function(t){let e,i=-1/0,n=-1/0;const r=t.findIndex(c=>c!==0);let o=r,l=r;for(e=r;e<256;e++){const c=t[e];c>i&&(e-o>n&&(n=e-o,l=e-1),i=c,o=e)}for(e=l-1;e>=0&&!(t[e]>t[e+1]);e--);return e},Yw=function(t){const e=t,{width:i,height:n}=t,{maxDim:r}=s(this,el);let o=i,l=n;if(i>r||n>r){let u=i,g=n,b=Math.log2(Math.max(i,n)/r);const m=Math.floor(b);b=b===m?m-1:m;for(let y=0;y<b;y++){o=Math.ceil(u/2),l=Math.ceil(g/2);const x=new OffscreenCanvas(o,l);x.getContext("2d").drawImage(t,0,0,u,g,0,0,o,l),u=o,g=l,t!==e&&t.close(),t=x.transferToImageBitmap()}const w=Math.min(r/o,r/l);o=Math.round(o*w),l=Math.round(l*w)}const h=new OffscreenCanvas(o,l).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,o,l),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,o,l);const d=h.getImageData(0,0,o,l).data;return[A(this,Vt,Rb).call(this,d),o,l]},v(Ns,Vt),v(Ns,el,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),v(Ns,qn,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class vm extends av{constructor(){super(),super.updateProperties({fill:ae._defaultLineColor,"stroke-width":0})}clone(){const t=new vm;return t.updateAll(this),t}}class wm extends jf{constructor(t){super(t),super.updateProperties({stroke:ae._defaultLineColor,"stroke-width":1})}clone(){const t=new wm(this._viewParameters);return t.updateAll(this),t}}const gn=class gn extends Bf{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});v(this,So,!1);v(this,Ts,null);v(this,Eo,null);v(this,il,null);this._willKeepAspectRatio=!0,p(this,Eo,e.signatureData||null),p(this,Ts,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,i){ae.initialize(e,i),this._defaultDrawingOptions=new vm,this._defaultDrawnSignatureOptions=new wm(i.viewParameters)}static getDefaultDrawingOptions(e){const i=this._defaultDrawingOptions.clone();return i.updateProperties(e),i}static get supportMultipleDrawings(){return!1}static get typesMap(){return gt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!s(this,Ts)}}static computeTelemetryFinalData(e){const i=e.get("hasDescription");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,i;const{_isCopy:n}=this;if(n&&(this._isCopy=!1,e=this.x,i=this.y),super.render(),this._drawId===null)if(s(this,Eo)){const{lines:r,mustSmooth:o,areContours:l,description:c,uuid:h,heightInPage:d}=s(this,Eo),{rawDims:{pageWidth:f,pageHeight:u},rotation:g}=this.parent.viewport,b=Ns.processDrawnLines({lines:r,pageWidth:f,pageHeight:u,rotation:g,innerMargin:gn._INNER_MARGIN,mustSmooth:o,areContours:l});this.addSignature(b,d,c,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:s(this,Ts)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,i)),this.div}setUuid(e){p(this,il,e),this.addEditToolbar()}getUuid(){return s(this,il)}get description(){return s(this,Ts)}set description(e){p(this,Ts,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(i=>{i==null||i.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:i,thickness:n,width:r,height:o}=s(this,Eo),l=Math.max(r,o),c=Ns.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:n,width:r,height:o},pageWidth:l,pageHeight:l,rotation:0,innerMargin:0,mustSmooth:!1,areContours:i});return{areContours:i,outline:c.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,i,n,r){const{x:o,y:l}=this,{outline:c}=p(this,Eo,e);p(this,So,c instanceof ym),this.description=n;let h;s(this,So)?h=gn.getDefaultDrawingOptions():(h=gn._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":c.thickness})),this._addOutlines({drawOutlines:c,drawingOptions:h});const[,d]=this.pageDimensions;let f=i/d;f=f>=1?.5:f,this.width*=f/this.height,this.width>=1&&(f*=.9/this.width,this.width=.9),this.height=f,this.setDims(),this.x=o,this.y=l,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!n}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:r}=this.parent.viewport;return Ns.process(e,i,n,r,gn._INNER_MARGIN)}getFromText(e,i){const{rawDims:{pageWidth:n,pageHeight:r},rotation:o}=this.parent.viewport;return Ns.extractContoursFromText(e,i,n,r,o,gn._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:r}=this.parent.viewport;return Ns.processDrawnLines({lines:e,pageWidth:i,pageHeight:n,rotation:r,innerMargin:gn._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:i}){e?this._drawingOptions=gn.getDefaultDrawingOptions():(this._drawingOptions=gn._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":i}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:i,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,o=Object.assign(super.serialize(e),{isSignature:!0,areContours:s(this,So),color:[0,0,0],thickness:s(this,So)?0:r});return this.addComment(o),e?(o.paths={lines:i,points:n},o.uuid=s(this,il),o.isCopy=!0):o.lines=i,s(this,Ts)&&(o.accessibilityData={type:"Figure",alt:s(this,Ts)}),o}static deserializeDraw(e,i,n,r,o,l){return l.areContours?ym.deserialize(e,i,n,r,o,l):Oh.deserialize(e,i,n,r,o,l)}static async deserialize(e,i,n){var o;const r=await super.deserialize(e,i,n);return p(r,So,e.areContours),r.description=((o=e.accessibilityData)==null?void 0:o.alt)||"",p(r,il,e.uuid),r}};So=new WeakMap,Ts=new WeakMap,Eo=new WeakMap,il=new WeakMap,$(gn,"_type","signature"),$(gn,"_editorType",mt.SIGNATURE),$(gn,"_defaultDrawingOptions",null);let Am=gn;class Sm extends ae{constructor(e){super({...e,name:"stampEditor"});v(this,Lt);v(this,be,null);v(this,ei,null);v(this,xo,null);v(this,vr,null);v(this,Co,null);v(this,Yc,"");v(this,wr,null);v(this,nl,!1);v(this,Ps,null);v(this,mn,!1);v(this,Xc,!1);p(this,vr,e.bitmapUrl),p(this,Co,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,i){ae.initialize(e,i)}static isHandlingMimeForPasting(e){return Hg.includes(e)}static paste(e,i){i.pasteEditor({mode:mt.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const i=e.get("hasAltText");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}async mlGuessAltText(e=null,i=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:o,height:l}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:r,width:o,height:l,channels:r.length/(o*l)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const h=c.output;return await this.setGuessedAltText(h),i&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;s(this,ei)&&(p(this,be,null),this._uiManager.imageManager.deleteId(s(this,ei)),(e=s(this,wr))==null||e.remove(),p(this,wr,null),s(this,Ps)&&(clearTimeout(s(this,Ps)),p(this,Ps,null))),super.remove()}rebuild(){if(!this.parent){s(this,ei)&&A(this,Lt,Vp).call(this);return}super.rebuild(),this.div!==null&&(s(this,ei)&&s(this,wr)===null&&A(this,Lt,Vp).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(s(this,xo)||s(this,be)||s(this,vr)||s(this,Co)||s(this,ei)||s(this,nl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,i;return this._isCopy&&(e=this.x,i=this.y),super.render(),this.div.hidden=!0,this.createAltText(),s(this,nl)||(s(this,be)?A(this,Lt,Gp).call(this):A(this,Lt,Vp).call(this)),this._isCopy&&this._moveAfterPaste(e,i),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,i){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,i);i.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(p(this,ei,n),r&&p(this,be,r),p(this,nl,!1),A(this,Lt,Gp).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;s(this,Ps)!==null&&clearTimeout(s(this,Ps)),p(this,Ps,setTimeout(()=>{p(this,Ps,null),A(this,Lt,Ob).call(this)},200))}copyCanvas(e,i,n=!1){e||(e=224);const{width:r,height:o}=s(this,be),l=new ss;let c=s(this,be),h=r,d=o,f=null;if(i){if(r>i||o>i){const D=Math.min(i/r,i/o);h=Math.floor(r*D),d=Math.floor(o*D)}f=document.createElement("canvas");const g=f.width=Math.ceil(h*l.sx),b=f.height=Math.ceil(d*l.sy);s(this,mn)||(c=A(this,Lt,Yp).call(this,g,b));const m=f.getContext("2d");m.filter=this._uiManager.hcmFilter;let w="white",y="#cfcfd8";this._uiManager.hcmFilter!=="none"?y="black":ZS.isDarkMode&&(w="#8f8f9d",y="#42414d");const x=15,E=x*l.sx,_=x*l.sy,C=new OffscreenCanvas(E*2,_*2),T=C.getContext("2d");T.fillStyle=w,T.fillRect(0,0,E*2,_*2),T.fillStyle=y,T.fillRect(0,0,E,_),T.fillRect(E,_,E,_),m.fillStyle=m.createPattern(C,"repeat"),m.fillRect(0,0,g,b),m.drawImage(c,0,0,c.width,c.height,0,0,g,b)}let u=null;if(n){let g,b;if(l.symmetric&&c.width<e&&c.height<e)g=c.width,b=c.height;else if(c=s(this,be),r>e||o>e){const y=Math.min(e/r,e/o);g=Math.floor(r*y),b=Math.floor(o*y),s(this,mn)||(c=A(this,Lt,Yp).call(this,g,b))}const w=new OffscreenCanvas(g,b).getContext("2d",{willReadFrequently:!0});w.drawImage(c,0,0,c.width,c.height,0,0,g,b),u={width:g,height:b,data:w.getImageData(0,0,g,b).data}}return{canvas:f,width:h,height:d,imageData:u}}static async deserialize(e,i,n){var w;let r=null,o=!1;if(e instanceof rv){const{data:{rect:y,rotation:x,id:E,structParent:_,popupRef:C,richText:T,contentsObj:D,creationDate:j,modificationDate:O},container:H,parent:{page:{pageNumber:N}},canvas:lt}=e;let G,K;lt?(delete e.canvas,{id:G,bitmap:K}=n.imageManager.getFromCanvas(H.id,lt),lt.remove()):(o=!0,e._hasNoCanvas=!0);const rt=((w=await i._structTree.getAriaAttributes(`${yl}${E}`))==null?void 0:w.get("aria-label"))||"";r=e={annotationType:mt.STAMP,bitmapId:G,bitmap:K,pageIndex:N-1,rect:y.slice(0),rotation:x,annotationElementId:E,id:E,deleted:!1,accessibilityData:{decorative:!1,altText:rt},isSvg:!1,structParent:_,popupRef:C,richText:T,comment:(D==null?void 0:D.str)||null,creationDate:j,modificationDate:O}}const l=await super.deserialize(e,i,n),{rect:c,bitmap:h,bitmapUrl:d,bitmapId:f,isSvg:u,accessibilityData:g}=e;o?(n.addMissingCanvas(e.id,l),p(l,nl,!0)):f&&n.imageManager.isValidId(f)?(p(l,ei,f),h&&p(l,be,h)):p(l,vr,d),p(l,mn,u);const[b,m]=l.pageDimensions;return l.width=(c[2]-c[0])/b,l.height=(c[3]-c[1])/m,g&&(l.altTextData=g),l._initialData=r,e.comment&&l.setCommentData(e),p(l,Xc,!!r),l}serialize(e=!1,i=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=Object.assign(super.serialize(e),{bitmapId:s(this,ei),isSvg:s(this,mn)});if(this.addComment(n),e)return n.bitmapUrl=A(this,Lt,Xp).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;const{decorative:r,altText:o}=this.serializeAltText(!1);if(!r&&o&&(n.accessibilityData={type:"Figure",alt:o}),this.annotationElementId){const c=A(this,Lt,Xw).call(this,n);return c.isSame?null:(c.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1,n.id=this.annotationElementId,delete n.bitmapId,n)}if(i===null)return n;i.stamps||(i.stamps=new Map);const l=s(this,mn)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!i.stamps.has(s(this,ei)))i.stamps.set(s(this,ei),{area:l,serialized:n}),n.bitmap=A(this,Lt,Xp).call(this,!1);else if(s(this,mn)){const c=i.stamps.get(s(this,ei));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=A(this,Lt,Xp).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}be=new WeakMap,ei=new WeakMap,xo=new WeakMap,vr=new WeakMap,Co=new WeakMap,Yc=new WeakMap,wr=new WeakMap,nl=new WeakMap,Ps=new WeakMap,mn=new WeakMap,Xc=new WeakMap,Lt=new WeakSet,Ku=function(e,i=!1){if(!e){this.remove();return}p(this,be,e.bitmap),i||(p(this,ei,e.id),p(this,mn,e.isSvg)),e.file&&p(this,Yc,e.file.name),A(this,Lt,Gp).call(this)},Ju=function(){if(p(this,xo,null),this._uiManager.enableWaiting(!1),!!s(this,wr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&s(this,be)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&s(this,be)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Vp=function(){if(s(this,ei)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(s(this,ei)).then(n=>A(this,Lt,Ku).call(this,n,!0)).finally(()=>A(this,Lt,Ju).call(this));return}if(s(this,vr)){const n=s(this,vr);p(this,vr,null),this._uiManager.enableWaiting(!0),p(this,xo,this._uiManager.imageManager.getFromUrl(n).then(r=>A(this,Lt,Ku).call(this,r)).finally(()=>A(this,Lt,Ju).call(this)));return}if(s(this,Co)){const n=s(this,Co);p(this,Co,null),this._uiManager.enableWaiting(!0),p(this,xo,this._uiManager.imageManager.getFromFile(n).then(r=>A(this,Lt,Ku).call(this,r)).finally(()=>A(this,Lt,Ju).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Hg.join(",");const i=this._uiManager._signal;p(this,xo,new Promise(n=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),A(this,Lt,Ku).call(this,r)}n()},{signal:i}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:i})}).finally(()=>A(this,Lt,Ju).call(this))),e.click()},Gp=function(){var h;const{div:e}=this;let{width:i,height:n}=s(this,be);const[r,o]=this.pageDimensions,l=.75;if(this.width)i=this.width*r,n=this.height*o;else if(i>l*r||n>l*o){const d=Math.min(l*r/i,l*o/n);i*=d,n*=d}this._uiManager.enableWaiting(!1);const c=p(this,wr,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=i/r,this.height=n/o,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),A(this,Lt,Ob).call(this),s(this,Xc)||(this.parent.addUndoableEditor(this),p(this,Xc,!0)),this._reportTelemetry({action:"inserted_image"}),s(this,Yc)&&this.div.setAttribute("aria-description",s(this,Yc)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Yp=function(e,i){const{width:n,height:r}=s(this,be);let o=n,l=r,c=s(this,be);for(;o>2*e||l>2*i;){const h=o,d=l;o>2*e&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2)),l>2*i&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const f=new OffscreenCanvas(o,l);f.getContext("2d").drawImage(c,0,0,h,d,0,0,o,l),c=f.transferToImageBitmap()}return c},Ob=function(){const[e,i]=this.parentDimensions,{width:n,height:r}=this,o=new ss,l=Math.ceil(n*e*o.sx),c=Math.ceil(r*i*o.sy),h=s(this,wr);if(!h||h.width===l&&h.height===c)return;h.width=l,h.height=c;const d=s(this,mn)?s(this,be):A(this,Lt,Yp).call(this,l,c),f=h.getContext("2d");f.filter=this._uiManager.hcmFilter,f.drawImage(d,0,0,d.width,d.height,0,0,l,c)},Xp=function(e){if(e){if(s(this,mn)){const r=this._uiManager.imageManager.getSvgUrl(s(this,ei));if(r)return r}const i=document.createElement("canvas");return{width:i.width,height:i.height}=s(this,be),i.getContext("2d").drawImage(s(this,be),0,0),i.toDataURL()}if(s(this,mn)){const[i,n]=this.pageDimensions,r=Math.round(this.width*i*Br.PDF_TO_CSS_UNITS),o=Math.round(this.height*n*Br.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(r,o);return l.getContext("2d").drawImage(s(this,be),0,0,s(this,be).width,s(this,be).height,0,0,r,o),l.transferToImageBitmap()}return structuredClone(s(this,be))},Xw=function(e){var l;const{pageIndex:i,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===i,o=(((l=e.accessibilityData)==null?void 0:l.alt)||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&o,isSameAltText:o}},$(Sm,"_type","stamp"),$(Sm,"_editorType",mt.STAMP);const Jn=class Jn{constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:n,accessibilityManager:r,annotationLayer:o,drawLayer:l,textLayer:c,viewport:h,l10n:d}){v(this,re);v(this,sl);v(this,qc,!1);v(this,_o,null);v(this,To,null);v(this,Ar,null);v(this,zi,new Map);v(this,Po,!1);v(this,Kc,!1);v(this,Jc,!1);v(this,Kn,null);v(this,Sr,null);v(this,ii,null);v(this,Er,null);v(this,ko,null);v(this,Zc,-1);v(this,ot);const f=[...s(Jn,Mo).values()];if(!Jn._initialized){Jn._initialized=!0;for(const u of f)u.initialize(d,t)}t.registerEditorTypes(f),p(this,ot,t),this.pageIndex=e,this.div=i,p(this,sl,r),p(this,_o,o),this.viewport=h,p(this,ii,c),this.drawLayer=l,this._structTree=n,s(this,ot).addLayer(this)}get isEmpty(){return s(this,zi).size===0}get isInvisible(){return this.isEmpty&&s(this,ot).getMode()===mt.NONE}updateToolbar(t){s(this,ot).updateToolbar(t)}updateMode(t=s(this,ot).getMode()){switch(A(this,re,qp).call(this),t){case mt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case mt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case mt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===mt.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const i of s(Jn,Mo).values())e.toggle(`${i._type}Editing`,t===i._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=s(this,ii))==null?void 0:e.div)}setEditingState(t){s(this,ot).setEditingState(t)}addCommands(t){s(this,ot).addCommands(t)}cleanUndoStack(t){s(this,ot).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=s(this,_o))==null||e.togglePointerEvents(t)}async enable(){var i;p(this,Jc,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(i=s(this,ko))==null||i.abort(),p(this,ko,null);const t=new Set;for(const n of s(this,re,Ib))n.enableEditing(),n.show(!0),n.annotationElementId&&(s(this,ot).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));const e=s(this,_o);if(e)for(const n of e.getEditableAnnotations()){if(n.hide(),s(this,ot).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}p(this,Jc,!1),s(this,ot)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var n;if(p(this,Kc,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),s(this,ii)&&!s(this,ko)){p(this,ko,new AbortController);const r=s(this,ot).combinedSignal(s(this,ko));s(this,ii).div.addEventListener("pointerdown",o=>{const{clientX:c,clientY:h,timeStamp:d}=o,f=s(this,Zc);if(d-f>500){p(this,Zc,d);return}p(this,Zc,-1);const{classList:u}=this.div;u.toggle("getElements",!0);const g=document.elementsFromPoint(c,h);if(u.toggle("getElements",!1),!this.div.contains(g[0]))return;let b;const m=new RegExp(`^${mh}[0-9]+$`);for(const y of g)if(m.test(y.id)){b=y.id;break}if(!b)return;const w=s(this,zi).get(b);(w==null?void 0:w.annotationElementId)===null&&(o.stopPropagation(),o.preventDefault(),w.dblclick(o))},{signal:r,capture:!0})}const t=s(this,_o),e=[];if(t){const r=new Map,o=new Map;for(const c of s(this,re,Ib)){if(c.disableEditing(),!c.annotationElementId){e.push(c);continue}if(c.serialize()!==null){r.set(c.annotationElementId,c);continue}else o.set(c.annotationElementId,c);(n=this.getEditableAnnotation(c.annotationElementId))==null||n.show(),c.remove()}const l=t.getEditableAnnotations();for(const c of l){const{id:h}=c.data;if(s(this,ot).isDeletedAnnotationElement(h)){c.updateEdited({deleted:!0});continue}let d=o.get(h);if(d){d.resetAnnotationElement(c),d.show(!1),c.show();continue}d=r.get(h),d&&(s(this,ot).addChangedExistingAnnotation(d),d.renderAnnotationElement(c)&&d.show(!1)),c.show()}}A(this,re,qp).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of s(Jn,Mo).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),p(this,Kc,!1)}getEditableAnnotation(t){var e;return((e=s(this,_o))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){s(this,ot).getActive()!==t&&s(this,ot).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=s(this,ii))!=null&&t.div&&!s(this,Er)){p(this,Er,new AbortController);const e=s(this,ot).combinedSignal(s(this,Er));s(this,ii).div.addEventListener("pointerdown",A(this,re,qw).bind(this),{signal:e}),s(this,ii).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=s(this,ii))!=null&&t.div&&s(this,Er)&&(s(this,Er).abort(),p(this,Er,null),s(this,ii).div.classList.remove("highlighting"))}enableClick(){if(s(this,To))return;p(this,To,new AbortController);const t=s(this,ot).combinedSignal(s(this,To));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=s(this,To))==null||t.abort(),p(this,To,null)}attach(t){s(this,zi).set(t.id,t);const{annotationElementId:e}=t;e&&s(this,ot).isDeletedAnnotationElement(e)&&s(this,ot).removeDeletedAnnotationElement(t)}detach(t){var e;s(this,zi).delete(t.id),(e=s(this,sl))==null||e.removePointerInTextLayer(t.contentDiv),!s(this,Kc)&&t.annotationElementId&&s(this,ot).addDeletedAnnotationElement(t)}remove(t){this.detach(t),s(this,ot).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(s(this,ot).addDeletedAnnotationElement(t),ae.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),s(this,ot).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!s(this,Jc)),s(this,ot).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var i;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!s(this,Ar)&&(t._focusEventsAllowed=!1,p(this,Ar,setTimeout(()=>{p(this,Ar,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:s(this,ot)._signal}),e.focus())},0))),t._structTreeParentId=(i=s(this,sl))==null?void 0:i.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),i=()=>{t.remove()};this.addCommands({cmd:e,undo:i,mustExec:!1})}getEditorByUID(t){for(const e of s(this,zi).values())if(e.uid===t)return e;return null}getNextId(){return s(this,ot).getId()}combinedSignal(t){return s(this,ot).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=s(this,re,Rs))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await s(this,ot).updateMode(t.mode);const{offsetX:i,offsetY:n}=A(this,re,Nb).call(this),r=this.getNextId(),o=A(this,re,Lb).call(this,{parent:this,id:r,x:i,y:n,uiManager:s(this,ot),isCentered:!0,...e});o&&this.add(o)}async deserialize(t){var e;return await((e=s(Jn,Mo).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,s(this,ot)))||null}createAndAddNewEditor(t,e,i={}){const n=this.getNextId(),r=A(this,re,Lb).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:s(this,ot),isCentered:e,...i});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(A(this,re,Nb).call(this),!0,t)}setSelected(t){s(this,ot).setSelected(t)}toggleSelected(t){s(this,ot).toggleSelected(t)}unselect(t){s(this,ot).unselect(t)}pointerup(t){var n;const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!s(this,Po)||(p(this,Po,!1),(n=s(this,re,Rs))!=null&&n.isDrawer&&s(this,re,Rs).supportMultipleDrawings))return;if(!s(this,qc)){p(this,qc,!0);return}const i=s(this,ot).getMode();if(i===mt.STAMP||i===mt.SIGNATURE){s(this,ot).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var n;if(s(this,ot).getMode()===mt.HIGHLIGHT&&this.enableTextSelection(),s(this,Po)){p(this,Po,!1);return}const{isMac:e}=ze.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(p(this,Po,!0),(n=s(this,re,Rs))!=null&&n.isDrawer){this.startDrawingSession(t);return}const i=s(this,ot).getActive();p(this,qc,!i||i.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),s(this,Kn)){s(this,re,Rs).startDrawing(this,s(this,ot),!1,t);return}s(this,ot).setCurrentDrawingSession(this),p(this,Kn,new AbortController);const e=s(this,ot).combinedSignal(s(this,Kn));this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(p(this,Sr,null),this.commitOrRemove())},{signal:e}),s(this,re,Rs).startDrawing(this,s(this,ot),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&p(this,Sr,e);return}s(this,Sr)&&setTimeout(()=>{var e;(e=s(this,Sr))==null||e.focus(),p(this,Sr,null)},0)}endDrawingSession(t=!1){return s(this,Kn)?(s(this,ot).setCurrentDrawingSession(null),s(this,Kn).abort(),p(this,Kn,null),p(this,Sr,null),s(this,re,Rs).endDrawing(t)):null}findNewParent(t,e,i){const n=s(this,ot).findParent(e,i);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return s(this,Kn)?(this.endDrawingSession(),!0):!1}onScaleChanging(){s(this,Kn)&&s(this,re,Rs).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=s(this,ot).getActive())==null?void 0:t.parent)===this&&(s(this,ot).commitOrRemove(),s(this,ot).setActiveEditor(null)),s(this,Ar)&&(clearTimeout(s(this,Ar)),p(this,Ar,null));for(const i of s(this,zi).values())(e=s(this,sl))==null||e.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,s(this,zi).clear(),s(this,ot).removeLayer(this)}render({viewport:t}){this.viewport=t,Bo(this.div,t);for(const e of s(this,ot).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){s(this,ot).commitOrRemove(),A(this,re,qp).call(this);const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,Bo(this.div,{rotation:i}),e!==i)for(const n of s(this,zi).values())n.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return s(this,ot).viewParameters.realScale}};sl=new WeakMap,qc=new WeakMap,_o=new WeakMap,To=new WeakMap,Ar=new WeakMap,zi=new WeakMap,Po=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,Kn=new WeakMap,Sr=new WeakMap,ii=new WeakMap,Er=new WeakMap,ko=new WeakMap,Zc=new WeakMap,ot=new WeakMap,Mo=new WeakMap,re=new WeakSet,Ib=function(){return s(this,zi).size!==0?s(this,zi).values():s(this,ot).getEditors(this.pageIndex)},qw=function(t){s(this,ot).unselectAll();const{target:e}=t;if(e===s(this,ii).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&s(this,ii).div.contains(e)){const{isMac:i}=ze.platform;if(t.button!==0||t.ctrlKey&&i)return;s(this,ot).showAllEditors("highlight",!0,!0),s(this,ii).div.classList.add("free"),this.toggleDrawing(),Ff.startHighlighting(this,s(this,ot).direction==="ltr",{target:s(this,ii).div,x:t.x,y:t.y}),s(this,ii).div.addEventListener("pointerup",()=>{s(this,ii).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:s(this,ot)._signal}),t.preventDefault()}},Rs=function(){return s(Jn,Mo).get(s(this,ot).getMode())},Lb=function(t){const e=s(this,re,Rs);return e?new e.prototype.constructor(t):null},Nb=function(){const{x:t,y:e,width:i,height:n}=this.boundingClientRect,r=Math.max(0,t),o=Math.max(0,e),l=Math.min(window.innerWidth,t+i),c=Math.min(window.innerHeight,e+n),h=(r+l)/2-t,d=(o+c)/2-e,[f,u]=this.viewport.rotation%180===0?[h,d]:[d,h];return{offsetX:f,offsetY:u}},qp=function(){for(const t of s(this,zi).values())t.isEmpty()&&t.remove()},$(Jn,"_initialized",!1),v(Jn,Mo,new Map([pm,bm,Sm,Ff,Am].map(t=>[t._editorType,t])));let Em=Jn;const We=class We{constructor({pageIndex:t}){v(this,ks);v(this,Zn,null);v(this,ki,new Map);v(this,rl,new Map);this.pageIndex=t}setParent(t){if(!s(this,Zn)){p(this,Zn,t);return}if(s(this,Zn)!==t){if(s(this,ki).size>0)for(const e of s(this,ki).values())e.remove(),t.append(e);p(this,Zn,t)}}static get _svgFactory(){return gt(this,"_svgFactory",new If)}draw(t,e=!1,i=!1){const n=Xe(We,xu)._++,r=A(this,ks,Fb).call(this),o=We._svgFactory.createElement("defs");r.append(o);const l=We._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke"),e&&s(this,rl).set(n,l);const h=i?A(this,ks,Jw).call(this,o,c):null,d=We._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${c}`),this.updateProperties(r,t),s(this,ki).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const i=Xe(We,xu)._++,n=A(this,ks,Fb).call(this),r=We._svgFactory.createElement("defs");n.append(r);const o=We._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke");let c;if(e){const f=We._svgFactory.createElement("mask");r.append(f),c=`mask_p${this.pageIndex}_${i}`,f.setAttribute("id",c),f.setAttribute("maskUnits","objectBoundingBox");const u=We._svgFactory.createElement("rect");f.append(u),u.setAttribute("width","1"),u.setAttribute("height","1"),u.setAttribute("fill","white");const g=We._svgFactory.createElement("use");f.append(g),g.setAttribute("href",`#${l}`),g.setAttribute("stroke","none"),g.setAttribute("fill","black"),g.setAttribute("fill-rule","nonzero"),g.classList.add("mask")}const h=We._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${l}`),c&&h.setAttribute("mask",`url(#${c})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,t),s(this,ki).set(i,n),i}finalizeDraw(t,e){s(this,rl).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var c;if(!e)return;const{root:i,bbox:n,rootClass:r,path:o}=e,l=typeof t=="number"?s(this,ki).get(t):t;if(l){if(i&&A(this,ks,Bb).call(this,l,i),n&&A(c=We,rp,Kw).call(c,l,n),r){const{classList:h}=l;for(const[d,f]of Object.entries(r))h.toggle(d,f)}if(o){const d=l.firstElementChild.firstElementChild;A(this,ks,Bb).call(this,d,o)}}}updateParent(t,e){if(e===this)return;const i=s(this,ki).get(t);i&&(s(e,Zn).append(i),s(this,ki).delete(t),s(e,ki).set(t,i))}remove(t){s(this,rl).delete(t),s(this,Zn)!==null&&(s(this,ki).get(t).remove(),s(this,ki).delete(t))}destroy(){p(this,Zn,null);for(const t of s(this,ki).values())t.remove();s(this,ki).clear(),s(this,rl).clear()}};Zn=new WeakMap,ki=new WeakMap,rl=new WeakMap,xu=new WeakMap,rp=new WeakSet,Kw=function(t,[e,i,n,r]){const{style:o}=t;o.top=`${100*i}%`,o.left=`${100*e}%`,o.width=`${100*n}%`,o.height=`${100*r}%`},ks=new WeakSet,Fb=function(){const t=We._svgFactory.create(1,1,!0);return s(this,Zn).append(t),t.setAttribute("aria-hidden",!0),t},Jw=function(t,e){const i=We._svgFactory.createElement("clipPath");t.append(i);const n=`clip_${e}`;i.setAttribute("id",n),i.setAttribute("clipPathUnits","objectBoundingBox");const r=We._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),n},Bb=function(t,e){for(const[i,n]of Object.entries(e))n===null?t.removeAttribute(i):t.setAttribute(i,n)},v(We,rp),v(We,xu,0);let xm=We;globalThis._pdfjsTestingUtils={HighlightOutliner:gm},globalThis.pdfjsLib={AbortException:Fr,AnnotationEditorLayer:Em,AnnotationEditorParamsType:Mt,AnnotationEditorType:mt,AnnotationEditorUIManager:jo,AnnotationLayer:fm,AnnotationMode:Nr,AnnotationType:De,applyOpacity:tE,build:ax,ColorPicker:Df,createValidAbsoluteUrl:n0,CSSConstants:QS,DOMSVGFactory:If,DrawLayer:xm,FeatureTest:ze,fetchData:Ah,findContrastColor:eE,getDocument:K0,getFilenameFromUrl:YS,getPdfFilenameFromUrl:XS,getRGB:xh,getUuid:l0,getXfaPageViewport:KS,GlobalWorkerOptions:os,ImageKind:uf,InvalidPDFException:Fg,isDataScheme:bf,isPdfFile:Ug,isValidExplicitDest:uE,MathClamp:Ei,noContextMenu:vn,normalizeUnicode:WS,OPS:bh,OutputScale:ss,PasswordResponses:LS,PDFDataRangeTransport:J0,PDFDateString:yf,PDFWorker:Rh,PermissionFlag:IS,PixelsPerInch:Br,RenderingCancelledException:zg,renderRichText:m0,ResponseException:mf,setLayerDimensions:Bo,shadow:gt,SignatureExtractor:Ns,stopEvent:Ee,SupportedImageMimeTypes:Hg,TextLayer:Mh,TouchManager:Af,updateUrlHash:s0,Util:Z,VerbosityLevel:ff,version:Z0,XfaLayer:h0},os.workerSrc=`//unpkg.com/pdfjs-dist@${Z0}/build/pdf.worker.min.mjs`;const Cm=B.forwardRef(({watermark:a,isLocked:t,lockText:e,onLockChange:i,isWatermarkEnabled:n,watermarkText:r,mode:o,initialElements:l,onAfterMount:c,onImageUpload:h},d)=>{var mv;const f=B.useRef(null),u=og(),g=hy(),b=ni(S=>S.whiteboard.grid),m=ni(S=>S.whiteboard.toolbar.selectedTool),w=ni(S=>S.whiteboard.elements),y=ni(S=>S.whiteboard.viewport),x=ni(S=>S.whiteboard.toolProperties),E=ni(S=>S.whiteboard.selectedElementIds||[]),_=ni(S=>S.whiteboard.lock),C=_.isLocked,T=ni(S=>S.whiteboard.pdf),[D,j]=B.useState(!1),[O,H]=B.useState({x:0,y:0}),[N,lt]=B.useState({x:0,y:0}),[G,K]=B.useState([]),[rt,tt]=B.useState(!1),[J,ct]=B.useState({}),[Dt,Ot]=B.useState(!1),[jt,vt]=B.useState(!1),[Ct,Ae]=B.useState(!1),[Nt,he]=B.useState({x:0,y:0}),[St,Ui]=B.useState({x:0,y:0,initialZoom:1,initialPan:{x:0,y:0}}),[Hi,Ne]=B.useState(!1),[wi,st]=B.useState({x:0,y:0}),[Ve,nt]=B.useState(""),[Fe,bn]=B.useState(null),Qn=B.useRef(null),Ms=B.useRef(null),[Dm,Cu]=B.useState(!1),[Ge,op]=B.useState(null),[Qc,_u]=B.useState(null),[ap,lp]=B.useState(null),[th,cp]=B.useState(!1),[oe,Tu]=B.useState(null),[yn,eh]=B.useState(null),[Re,ts]=B.useState([]),[xr,ih]=B.useState(1),hp=50,Ro=B.useRef(null),Pu=B.useCallback(async S=>{try{if(Ro.current)try{Ro.current.destroy()}catch(F){console.warn("Error destroying previous PDF:",F)}const k=await K0(S).promise;Ro.current=k,eh(k);const I=[];let L=0;for(let F=1;F<=k.numPages;F++){const z=(await k.getPage(F)).getViewport({scale:1.5});I.push({pageIndex:F,x:L,y:0,width:z.width,height:z.height}),L+=z.width+hp}if(ts(I),ih(1),I.length>0){const F=I[0],U=f.current;if(U){const at=(U.height-80)/F.height,V=Math.min(at,1.2),X=F.width*V,dt=(U.width-X)/2-F.x*V,ft=40;u(gh(V)),u(No({x:dt,y:ft}))}}}catch(P){console.error("Error loading PDF from URL:",P)}},[u]);B.useEffect(()=>{T!=null&&T.url?Pu(T.url):(Ro.current&&(Ro.current.destroy(),Ro.current=null),eh(null),ts([]))},[T==null?void 0:T.url,Pu]);const ku=B.useCallback(async S=>{try{let P="";h?P=await h(S):P=URL.createObjectURL(S),u(Rg(P)),u(ph())}catch(P){console.error("Error loading PDF:",P)}},[u,h]),dp=B.useCallback(()=>{u(Rg(void 0)),u(ph())},[u]),up=B.useCallback(()=>{if(T!=null&&T.url){const S=document.createElement("a");S.href=T.url,S.download="document.pdf",document.body.appendChild(S),S.click(),document.body.removeChild(S)}},[T]),fp=B.useCallback(async S=>{console.log("Rendering PDF page start:",S.pageIndex);try{const P=await yn.getPage(S.pageIndex);console.log("Got page object:",S.pageIndex);const k=P.getViewport({scale:1.5}),I=document.createElement("canvas"),L=I.getContext("2d");return I.width=k.width,I.height=k.height,L&&(console.log("Starting render task:",S.pageIndex),await P.render({canvasContext:L,viewport:k}).promise,console.log("Finished render task:",S.pageIndex)),I}catch(P){return console.error("Error rendering PDF page:",P),null}},[yn]),Cr=B.useCallback(async S=>{console.log("ensurePageRendered called for:",S),ts(k=>{const L=[...k].find(F=>F.pageIndex===S);return L&&!L.canvas&&console.log("Page needs rendering (in setter):",S),k});const P=S-1;if(Re[P])if(Re[P].canvas)console.log("Page already has canvas:",S);else{console.log("Triggering renderPdfPage for:",S);const k=await fp(Re[P]);k?(console.log("Setting canvas to state for:",S),ts(I=>{const L=[...I];return L[P]={...L[P],canvas:k},L}),Nn.current&&(console.log("Forcing redrawRef"),Nn.current())):console.error("Render returned null for:",S)}else console.log("Page not found in pdfPages:",P)},[Re,fp]),Mu=B.useCallback(S=>{if(S<1||!yn||S>yn.numPages)return;ih(S);const P=Re.find(k=>k.pageIndex===S);if(P){const k=f.current;if(k){const I=-P.x+(k.width/y.zoom-P.width)/2;u(No({x:I*y.zoom,y:50*y.zoom}))}Cr(S),S>1&&Cr(S-1),S<yn.numPages&&Cr(S+1)}},[Re,yn,y.zoom,u,Cr]);B.useEffect(()=>{Re.length>0&&(Cr(1),Re.length>1&&Cr(2))},[yn,Re.length,Cr]);const Om=B.useCallback(S=>{Fe&&S.trim()&&(Qn.current&&clearTimeout(Qn.current),Qn.current=setTimeout(()=>{Fe&&S!==Ms.current&&(Ms.current=S,u(cf({id:Fe,updates:{text:S}})))},150))},[u,Fe]);B.useEffect(()=>()=>{Qn.current&&clearTimeout(Qn.current)},[]),B.useImperativeHandle(d,()=>({canvas:f.current,applyAction:S=>{u({...S,meta:{...S.meta,fromRemote:!0}})},getElems:()=>g.getState().whiteboard.elements,getElements:()=>g.getState().whiteboard.elements,setElems:S=>{u({...Mg(S),meta:{fromRemote:!0}})},setElements:S=>{u({...Mg(S),meta:{fromRemote:!0}})},clearElems:()=>{u({...ph(),meta:{fromRemote:!0}})},clearElements:()=>{u({...ph(),meta:{fromRemote:!0}})},setPdf:S=>{u({...Rg(S),meta:{fromRemote:!0}})}})),B.useEffect(()=>{t!==void 0&&u(qy(t))},[t,u]),B.useEffect(()=>{i&&i(C)},[C,i]);const ol=ni(S=>S.whiteboard.watermark);B.useEffect(()=>{n!==void 0&&n!==ol.visible&&u(z1(n))},[n,ol.visible,u]),B.useEffect(()=>{r!==void 0&&r!==ol.text&&u(U1(r))},[r,ol.text,u]),B.useEffect(()=>{l&&l.length>0&&u(Mg(l))},[u]),B.useEffect(()=>{c&&setTimeout(()=>{c()},0)},[]);const pp=B.useCallback((S,P,k)=>{const I=S.canvas,L=I.width,F=I.height,U=Math.floor(-y.panX/y.zoom/P)*P,z=Math.floor(-y.panY/y.zoom/P)*P,Y=Math.ceil((L/y.zoom-y.panX/y.zoom)/P)*P,at=Math.ceil((F/y.zoom-y.panY/y.zoom)/P)*P;S.strokeStyle=k,S.lineWidth=.5/y.zoom;for(let V=U;V<=Y;V+=P)S.beginPath(),S.moveTo(V,z),S.lineTo(V,at),S.stroke();for(let V=z;V<=at;V+=P)S.beginPath(),S.moveTo(U,V),S.lineTo(Y,V),S.stroke()},[y]),gp=B.useCallback((S,P,k)=>{const I=Math.min(P.x,k.x),L=Math.min(P.y,k.y),F=Math.abs(k.x-P.x),U=Math.abs(k.y-P.y);S.strokeStyle="#0066cc",S.lineWidth=1,S.setLineDash([5,5]),S.strokeRect(I,L,F,U),S.fillStyle="rgba(0, 102, 204, 0.1)",S.fillRect(I,L,F,U),S.setLineDash([])},[]),R=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,fillColor:U="#000",strokeColor:z="#000",lineWidth:Y=2}=P;S.fillStyle=U,S.fillRect(k,I,L,F),S.strokeStyle=z,S.lineWidth=Y,S.strokeRect(k,I,L,F)},[]),W=B.useCallback((S,P)=>{const{centerX:k=0,centerY:I=0,radius:L=0,fillColor:F="#000",strokeColor:U="#000",lineWidth:z=2}=P;S.beginPath(),S.arc(k,I,L,0,Math.PI*2),S.fillStyle=F,S.fill(),S.strokeStyle=U,S.lineWidth=z,S.stroke()},[]),Q=B.useCallback((S,P)=>{const{points:k=[],strokeColor:I="#000",lineWidth:L=2}=P;if(!(k.length<2)){S.strokeStyle=I,S.lineWidth=L,S.lineCap="round",S.lineJoin="round",S.beginPath(),S.moveTo(k[0].x,k[0].y);for(let F=1;F<k.length;F++)k[F]&&S.lineTo(k[F].x,k[F].y);S.stroke()}},[]),ut=B.useCallback((S,P)=>{const{x:k=0,y:I=0,text:L="",fontSize:F=16,fontColor:U="#000"}=P;S.font=`${F}px sans-serif`,S.fillStyle=U,S.textBaseline="top",S.fillText(L,k,I)},[]),zt=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,fillColor:U="#fff",strokeColor:z="#000",lineWidth:Y=2}=P;S.beginPath(),S.moveTo(k+L/2,I),S.lineTo(k+L,I+F),S.lineTo(k,I+F),S.closePath(),S.fillStyle=U,S.fill(),S.strokeStyle=z,S.lineWidth=Y,S.stroke()},[]),Ft=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,fillColor:U="#fff",strokeColor:z="#000",lineWidth:Y=2}=P;S.beginPath(),S.moveTo(k+L/2,I),S.lineTo(k+L,I+F/2),S.lineTo(k+L/2,I+F),S.lineTo(k,I+F/2),S.closePath(),S.fillStyle=U,S.fill(),S.strokeStyle=z,S.lineWidth=Y,S.stroke()},[]),Pt=B.useCallback((S,P)=>{const{centerX:k=0,centerY:I=0,size:L=0,fillColor:F="#ffff00",strokeColor:U="#000",lineWidth:z=2}=P,Y=5,at=L,V=L/2;S.beginPath();for(let X=0;X<Y*2;X++){const dt=X%2===0?at:V,ft=Math.PI/Y*X-Math.PI/2,_t=k+Math.cos(ft)*dt,Gt=I+Math.sin(ft)*dt;X===0?S.moveTo(_t,Gt):S.lineTo(_t,Gt)}S.closePath(),S.fillStyle=F,S.fill(),S.strokeStyle=U,S.lineWidth=z,S.stroke()},[]),xt=B.useCallback((S,P)=>{const{centerX:k=0,centerY:I=0,size:L=0,fillColor:F="#ff6b6b",strokeColor:U="#000",lineWidth:z=2}=P;S.beginPath();const Y=I-L/2;S.moveTo(k,Y+L/4),S.bezierCurveTo(k-L/2,Y,k-L,Y+L/2,k,I+L/2),S.bezierCurveTo(k+L,Y+L/2,k+L/2,Y,k,Y+L/4),S.fillStyle=F,S.fill(),S.strokeStyle=U,S.lineWidth=z,S.stroke()},[]),Be=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,fillColor:U="#fff",strokeColor:z="#000",lineWidth:Y=2}=P,at=k+L/2,V=I+F/2,X=L/2,dt=F/2;S.beginPath();for(let ft=0;ft<6;ft++){const _t=Math.PI/3*ft-Math.PI/2,Gt=at+Math.cos(_t)*X,Ye=V+Math.sin(_t)*dt;ft===0?S.moveTo(Gt,Ye):S.lineTo(Gt,Ye)}S.closePath(),S.fillStyle=U,S.fill(),S.strokeStyle=z,S.lineWidth=Y,S.stroke()},[]),de=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,fillColor:U="#fff",strokeColor:z="#000",lineWidth:Y=2}=P,at=k+L/2,V=I+F/2,X=L/2,dt=F/2;S.beginPath();for(let ft=0;ft<8;ft++){const _t=Math.PI/4*ft-Math.PI/2,Gt=at+Math.cos(_t)*X,Ye=V+Math.sin(_t)*dt;ft===0?S.moveTo(Gt,Ye):S.lineTo(Gt,Ye)}S.closePath(),S.fillStyle=U,S.fill(),S.strokeStyle=z,S.lineWidth=Y,S.stroke()},[]),fe=B.useCallback((S,P)=>{const{startX:k=0,startY:I=0,endX:L=0,endY:F=0,fillColor:U="#000",strokeColor:z="#000",lineWidth:Y=2}=P,at=15,V=Math.atan2(F-I,L-k);S.beginPath(),S.moveTo(k,I),S.lineTo(L,F),S.strokeStyle=z,S.lineWidth=Y,S.stroke(),S.beginPath(),S.moveTo(L,F),S.lineTo(L-at*Math.cos(V-Math.PI/6),F-at*Math.sin(V-Math.PI/6)),S.lineTo(L-at*Math.cos(V+Math.PI/6),F-at*Math.sin(V+Math.PI/6)),S.closePath(),S.fillStyle=U,S.fill()},[]),$i=B.useRef({}),Nn=B.useRef(null),Ru=B.useCallback((S,P)=>{const{x:k=0,y:I=0,width:L=0,height:F=0,src:U=""}=P;try{if($i.current[U]){const z=$i.current[U];if(z.complete&&z.naturalWidth>0)try{S.drawImage(z,k,I,L,F)}catch(Y){console.error("Failed to draw cached image:",Y)}}else{const z=new Image;z.onload=()=>{$i.current[U]=z,Nn.current&&Nn.current()},z.onerror=Y=>{console.error("Failed to load image:",U,Y)},z.src=U,$i.current[U]=z}}catch(z){console.error("Error in drawImage:",z)}},[]),Wi=B.useCallback((S,P)=>{switch(P.type){case"rectangle":R(S,P);break;case"circle":W(S,P);break;case"pencil":Q(S,P);break;case"text":ut(S,P);break;case"triangle":zt(S,P);break;case"diamond":Ft(S,P);break;case"star":Pt(S,P);break;case"heart":xt(S,P);break;case"hexagon":Be(S,P);break;case"octagon":de(S,P);break;case"arrow":fe(S,P);break;case"image":Ru(S,P);break}},[R,W,Q,ut,zt,Ft,Pt,xt,Be,de,fe,Ru]),Dx=B.useCallback(()=>{const S=f.current;if(!S)return;const P=document.createElement("canvas");P.width=S.width,P.height=S.height;const k=P.getContext("2d");if(!k)return;k.fillStyle="#ffffff",k.fillRect(0,0,P.width,P.height),k.save(),k.translate(y.panX,y.panY),k.scale(y.zoom,y.zoom),Re.length>0&&Re.forEach(F=>{F.canvas&&k.drawImage(F.canvas,F.x,F.y,F.width,F.height)}),w.forEach(F=>{Wi(k,F)}),k.restore();const I=P.toDataURL("image/png"),L=document.createElement("a");L.download=`whiteboard-${Date.now()}.png`,L.href=I,L.click()},[y,w,Wi,Re]),Ox=B.useCallback(()=>{const S=f.current;if(S){if(yn&&Re.length>0){const P=Re[xr-1];if(P){const I=S.width-100,L=S.height-100,F=I/P.width,U=L/P.height,z=Math.min(F,U,5),Y=P.x+P.width/2,at=P.y+P.height/2,V=S.width/2-Y*z,X=S.height/2-at*z;u(gh(Math.max(.1,z))),u(No({x:V,y:X}));return}}u(F1({canvasWidth:S.width,canvasHeight:S.height,padding:50}))}},[u,yn,Re,xr]),Ix=B.useCallback(()=>{u(I1())},[u]),hv=(S,P,k,I,L,F)=>{const U=S-k,z=P-I,Y=L-k,at=F-I,V=U*Y+z*at,X=Y*Y+at*at;let dt=-1;X!==0&&(dt=V/X);let ft,_t;dt<0?(ft=k,_t=I):dt>1?(ft=L,_t=F):(ft=k+dt*Y,_t=I+dt*at);const Gt=S-ft,Ye=P-_t;return Math.sqrt(Gt*Gt+Ye*Ye)},Im=B.useCallback((S,P)=>{for(let k=w.length-1;k>=0;k--){const I=w[k],L=I.x??0,F=I.y??0,U=I.width??0,z=I.height??0,Y=I.centerX??0,at=I.centerY??0,V=I.radius??0;if(I.type==="rectangle"){if(S>=L&&S<=L+U&&P>=F&&P<=F+z)return I}else if(I.type==="circle"){if(Math.sqrt(Math.pow(S-Y,2)+Math.pow(P-at,2))<=V)return I}else if(I.type==="pencil"){const dt=I.points??[];for(let ft=1;ft<dt.length;ft++){const _t=dt[ft-1],Gt=dt[ft];if(!_t||!Gt)continue;if(hv(S,P,_t.x,_t.y,Gt.x,Gt.y)<=5)return I}}else if(I.type==="text"){const X=I.fontSize||16,ft=(I.text||"").length*X*.6,_t=X;if(S>=L&&S<=L+ft&&P>=F&&P<=F+_t)return I}else if(I.type==="triangle"||I.type==="diamond"||I.type==="hexagon"||I.type==="octagon"){if(S>=L&&S<=L+U&&P>=F&&P<=F+z)return I}else if(I.type==="star"||I.type==="heart"){const X=Math.sqrt(Math.pow(S-Y,2)+Math.pow(P-at,2)),dt=I.size??0;if(X<=dt)return I}else if(I.type==="arrow"){const dt=I.startX??0,ft=I.startY??0,_t=I.endX??0,Gt=I.endY??0;if(hv(S,P,dt,ft,_t,Gt)<=10)return I}else if(I.type==="image"&&S>=L&&S<=L+U&&P>=F&&P<=F+z)return I}return null},[w]),nh=B.useCallback(S=>{let P=0,k=0,I=0,L=0;if(S.type==="rectangle"||S.type==="image"||S.type==="text"||S.type==="triangle"||S.type==="diamond"||S.type==="hexagon"||S.type==="octagon")if(P=S.x??0,k=S.y??0,S.type==="text"){const F=S.fontSize||16;I=(S.text||"").length*F*.6,L=F}else I=S.width??0,L=S.height??0;else if(S.type==="circle"){const F=S.radius??0;P=(S.centerX??0)-F,k=(S.centerY??0)-F,I=F*2,L=F*2}else if(S.type==="star"||S.type==="heart"){const F=S.size??0;P=(S.centerX??0)-F,k=(S.centerY??0)-F,I=F*2,L=F*2}else if(S.type==="pencil"&&S.points&&S.points.length>0){const F=Math.min(...S.points.map(at=>at.x)),U=Math.max(...S.points.map(at=>at.x)),z=Math.min(...S.points.map(at=>at.y)),Y=Math.max(...S.points.map(at=>at.y));P=F,k=z,I=U-F,L=Y-z}else if(S.type==="arrow")return null;return{x:P,y:k,w:I,h:L}},[]),mp=B.useCallback(S=>{const P=[];if(S.type==="arrow")return P.push({type:"start",x:S.startX??0,y:S.startY??0}),P.push({type:"end",x:S.endX??0,y:S.endY??0}),P;const k=nh(S);if(!k)return[];const{x:I,y:L,w:F,h:U}=k;return P.push({type:"nw",x:I,y:L}),P.push({type:"ne",x:I+F,y:L}),P.push({type:"se",x:I+F,y:L+U}),P.push({type:"sw",x:I,y:L+U}),P.push({type:"n",x:I+F/2,y:L}),P.push({type:"s",x:I+F/2,y:L+U}),P.push({type:"e",x:I+F,y:L+U/2}),P.push({type:"w",x:I,y:L+U/2}),P},[nh]),dv=B.useCallback((S,P,k,I)=>{const L=mp(k),F=10/I;for(const U of L)if(Math.abs(S-U.x)<=F&&Math.abs(P-U.y)<=F)return U.type;return null},[mp]),uv=B.useCallback((S,P)=>{S.strokeStyle="#0066cc",S.lineWidth=1/y.zoom,S.setLineDash([5/y.zoom,5/y.zoom]);const k=nh(P);k?S.strokeRect(k.x-4/y.zoom,k.y-4/y.zoom,k.w+8/y.zoom,k.h+8/y.zoom):P.type,S.setLineDash([]);const I=mp(P),L=8/y.zoom;S.fillStyle="#ffffff",S.strokeStyle="#0066cc",S.lineWidth=1/y.zoom;for(const F of I)S.fillRect(F.x-L/2,F.y-L/2,L,L),S.strokeRect(F.x-L/2,F.y-L/2,L,L)},[y.zoom,nh,mp]),_r=B.useCallback(()=>{const S=f.current;if(!S)return;const P=S.getContext("2d");if(P)try{P.clearRect(0,0,S.width,S.height),P.save(),P.translate(y.panX,y.panY),P.scale(y.zoom,y.zoom),b.enabled&&pp(P,b.size,b.color),Re.length>0&&Re.forEach(k=>{if(P.fillStyle="white",P.shadowColor="rgba(0,0,0,0.2)",P.shadowBlur=10,P.shadowOffsetX=2,P.shadowOffsetY=2,P.fillRect(k.x,k.y,k.width,k.height),P.shadowColor="transparent",P.shadowBlur=0,P.shadowOffsetX=0,P.shadowOffsetY=0,k.canvas)P.drawImage(k.canvas,k.x,k.y,k.width,k.height);else{P.fillStyle="#f5f5f5",P.fillRect(k.x,k.y,k.width,k.height),P.fillStyle="#999",P.font="20px sans-serif",P.fillText("Loading...",k.x+20,k.y+40);const I=-y.panX/y.zoom,L=P.canvas.width/y.zoom;k.x+k.width>I&&k.x<I+L}}),w.forEach(k=>{try{Wi(P,k),E.includes(k.id)&&uv(P,k)}catch(I){console.error("Error drawing element:",k.id,I)}}),th&&oe&&(P.fillStyle="rgba(0, 102, 204, 0.1)",P.strokeStyle="#0066cc",P.lineWidth=1/y.zoom,P.fillRect(oe.startX,oe.startY,oe.width,oe.height),P.strokeRect(oe.startX,oe.startY,oe.width,oe.height)),P.restore()}catch(k){console.error("Error redrawing canvas:",k);try{P.restore()}catch{}}},[b,pp,w,Wi,E,uv,y,th,oe,Re]);B.useEffect(()=>{Nn.current=_r},[_r]),B.useEffect(()=>{const S=f.current;if(!S)return;const P=S.parentElement;if(!P)return;const k=()=>{const L=P.getBoundingClientRect();S.width=L.width,S.height=L.height,_r()};k();const I=new ResizeObserver(()=>{k()});return I.observe(P),()=>{I.disconnect()}},[_r]),B.useEffect(()=>{_r()},[_r]),B.useEffect(()=>{const S=k=>{k.target.tagName==="INPUT"||k.target.tagName==="TEXTAREA"||k.code==="Space"&&!k.repeat&&(k.preventDefault(),Ot(!0))},P=k=>{k.target.tagName==="INPUT"||k.target.tagName==="TEXTAREA"||k.code==="Space"&&(k.preventDefault(),Ot(!1),vt(!1),Ae(!1))};return window.addEventListener("keydown",S),window.addEventListener("keyup",P),()=>{window.removeEventListener("keydown",S),window.removeEventListener("keyup",P)}},[]);const al=B.useCallback((S,P)=>({x:(S-y.panX)/y.zoom,y:(P-y.panY)/y.zoom}),[y]);B.useEffect(()=>{const S=f.current;if(!S||!D)return;const P=S.getContext("2d");if(P){if(_r(),P.save(),P.translate(y.panX,y.panY),P.scale(y.zoom,y.zoom),m==="pointer")gp(P,O,N);else if(m==="rectangle"){const k=Math.min(O.x,N.x),I=Math.min(O.y,N.y),L=Math.abs(N.x-O.x),F=Math.abs(N.y-O.y);R(P,{id:"preview",type:"rectangle",x:k,y:I,width:L,height:F,fillColor:x.rectangle.fillColor,lineWidth:x.rectangle.lineWidth})}else if(m==="circle"){const k=O.x,I=O.y,L=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));W(P,{id:"preview",type:"circle",centerX:k,centerY:I,radius:L,strokeColor:x.circle.strokeColor,fillColor:x.circle.fillColor,lineWidth:x.circle.lineWidth})}else if(m==="pencil")Q(P,{id:"preview",type:"pencil",points:G,strokeColor:x.pencil.strokeColor,lineWidth:x.pencil.lineWidth});else if(m==="triangle"){const k=Math.min(O.x,N.x),I=Math.min(O.y,N.y),L=Math.abs(N.x-O.x),F=Math.abs(N.y-O.y);zt(P,{id:"preview",type:"triangle",x:k,y:I,width:L,height:F,fillColor:x.triangle.fillColor,lineWidth:x.triangle.lineWidth})}else if(m==="diamond"){const k=Math.min(O.x,N.x),I=Math.min(O.y,N.y),L=Math.abs(N.x-O.x),F=Math.abs(N.y-O.y);Ft(P,{id:"preview",type:"diamond",x:k,y:I,width:L,height:F,fillColor:x.diamond.fillColor,lineWidth:x.diamond.lineWidth})}else if(m==="star"){const k=O.x,I=O.y,L=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));Pt(P,{id:"preview",type:"star",centerX:k,centerY:I,size:L,fillColor:x.star.fillColor,lineWidth:x.star.lineWidth})}else if(m==="heart"){const k=O.x,I=O.y,L=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));xt(P,{id:"preview",type:"heart",centerX:k,centerY:I,size:L,fillColor:x.heart.fillColor,lineWidth:x.heart.lineWidth})}else if(m==="hexagon"){const k=Math.min(O.x,N.x),I=Math.min(O.y,N.y),L=Math.abs(N.x-O.x),F=Math.abs(N.y-O.y);Be(P,{id:"preview",type:"hexagon",x:k,y:I,width:L,height:F,fillColor:x.hexagon.fillColor,lineWidth:x.hexagon.lineWidth})}else if(m==="octagon"){const k=Math.min(O.x,N.x),I=Math.min(O.y,N.y),L=Math.abs(N.x-O.x),F=Math.abs(N.y-O.y);de(P,{id:"preview",type:"octagon",x:k,y:I,width:L,height:F,fillColor:x.octagon.fillColor,lineWidth:x.octagon.lineWidth})}else m==="arrow"&&fe(P,{id:"preview",type:"arrow",startX:O.x,startY:O.y,endX:N.x,endY:N.y,fillColor:x.arrow.fillColor,lineWidth:x.arrow.lineWidth});P.restore()}},[D,m,O,N,G,_r,gp,R,W,Q,zt,Ft,Pt,xt,Be,de,fe,y,x]);const Lx=S=>{const P=f.current;if(!P)return;const k=P.getBoundingClientRect(),I=S.clientX-k.left,L=S.clientY-k.top;if(Hi)return;if(Dt){S.preventDefault(),S.button===0?(vt(!0),he({x:I-y.panX,y:L-y.panY})):S.button===2&&(Ae(!0),Ui({x:I,y:L,initialZoom:y.zoom,initialPan:{x:y.panX,y:y.panY}}));return}if(C)return;const{x:F,y:U}=al(I,L);if(m==="pointer"){const z=Im(F,U);let Y=null;if(E.length===1){const at=E[0],V=w.find(X=>X.id===at);if(V){const X=dv(F,U,V,y.zoom);X&&(Y={element:V,handle:X})}}if(Y){Cu(!0),op(Y.handle),_u({x:F,y:U}),lp(JSON.parse(JSON.stringify(Y.element)));return}if(z){const at=E.includes(z.id);let V=E;if(S.shiftKey?(at?V=E.filter(X=>X!==z.id):V=[...E,z.id],u(Is(V))):at||(V=[z.id],u(Is(V))),V.length>0){tt(!0),H({x:F,y:U});const X={};V.forEach(dt=>{const ft=w.find(_t=>_t.id===dt);ft&&(X[dt]={...ft})}),ct(X)}}else{S.shiftKey||u(Is([])),cp(!0);const{x:at,y:V}=al(I,L);Tu({startX:at,startY:V,width:0,height:0})}}else if(m==="text"){const z=Date.now().toString();u(Ri({id:z,type:"text",x:F,y:U,text:"Text",fontSize:x.text.fontSize,fontColor:x.text.fontColor})),u(Fn("pointer")),u(Is([z])),bn(z),nt("Text"),st({x:F,y:U}),Ne(!0)}else if(m==="eraser"){const z=Im(F,U);z&&u(N1(z.id))}else u(Is([])),j(!0),H({x:F,y:U}),lt({x:F,y:U}),m==="pencil"&&K([{x:F,y:U}])},Nx=S=>{const P=f.current;if(!P)return;const k=P.getBoundingClientRect(),I=S.clientX-k.left,L=S.clientY-k.top;if(jt){u(No({x:I-Nt.x,y:L-Nt.y}));return}if(Ct){const z=St.y-L,at=St.initialZoom*(1+z*.005),V=Math.max(.1,Math.min(at,5)),X=(St.x-St.initialPan.x)/St.initialZoom,dt=(St.y-St.initialPan.y)/St.initialZoom,ft=St.x-X*V,_t=St.y-dt*V;u(gh(V)),u(No({x:ft,y:_t}));return}if(C)return;const{x:F,y:U}=al(I,L);if(th&&oe){const z=F-oe.startX,Y=U-oe.startY;Tu({...oe,width:z,height:Y});return}if(rt&&E.length>0){const z=F-O.x,Y=U-O.y,at=[];E.forEach(V=>{const X=J[V];if(!X)return;let dt={};if(X.type==="rectangle")dt={x:(X.x??0)+z,y:(X.y??0)+Y};else if(X.type==="circle")dt={centerX:(X.centerX??0)+z,centerY:(X.centerY??0)+Y};else if(X.type==="pencil"){const ft=X.points||[];if(ft.length===0)return;dt={points:ft.map(_t=>({x:_t.x+z,y:_t.y+Y}))}}else X.type==="text"?dt={x:(X.x??0)+z,y:(X.y??0)+Y}:X.type==="triangle"||X.type==="diamond"||X.type==="hexagon"||X.type==="octagon"?dt={x:(X.x??0)+z,y:(X.y??0)+Y}:X.type==="star"||X.type==="heart"?dt={centerX:(X.centerX??0)+z,centerY:(X.centerY??0)+Y}:X.type==="arrow"?dt={startX:(X.startX??0)+z,startY:(X.startY??0)+Y,endX:(X.endX??0)+z,endY:(X.endY??0)+Y}:X.type==="image"&&(dt={x:(X.x??0)+z,y:(X.y??0)+Y});at.push({id:V,updates:dt})}),at.length>0&&u(Xy(at));return}if(Dm&&ap&&Qc&&Ge){let z={};const Y=F-Qc.x,at=U-Qc.y,V=ap;if(V.type==="arrow")Ge==="start"?z={startX:(V.startX??0)+Y,startY:(V.startY??0)+at}:Ge==="end"&&(z={endX:(V.endX??0)+Y,endY:(V.endY??0)+at});else if(V.type==="circle"||V.type==="star"||V.type==="heart"){const X=V.radius||V.size||0,dt=Ge.includes("e"),ft=Ge.includes("s"),_t=Ge.includes("w"),Gt=Ge.includes("n");let Ye=0;dt&&(Ye+=Y),_t&&(Ye-=Y),ft&&(Ye+=at),Gt&&(Ye-=at);const Du=Math.max(5,X+Ye);V.type==="circle"?z={radius:Du}:z={size:Du}}else if(V.type==="pencil"&&V.points){const X=nh(V);if(X){const{x:dt,y:ft,w:_t,h:Gt}=X;let Ye=dt,Du=ft,Nm=_t,Fm=Gt;Ge.includes("e")&&(Nm=Math.max(5,_t+Y)),Ge.includes("w")&&(Nm=Math.max(5,_t-Y),Ye=dt+Y),Ge.includes("s")&&(Fm=Math.max(5,Gt+at)),Ge.includes("n")&&(Fm=Math.max(5,Gt-at),Du=ft+at);const $x=Nm/_t,Wx=Fm/Gt;z={points:V.points.map(bv=>({x:Ye+(bv.x-dt)*$x,y:Du+(bv.y-ft)*Wx}))}}}else{let X=V.x??0,dt=V.y??0,ft=V.width??0,_t=V.height??0;if(Ge.includes("e")&&(ft=Math.max(5,(V.width??0)+Y)),Ge.includes("w")){const Gt=(V.width??0)-Y;Gt>5&&(ft=Gt,X=(V.x??0)+Y)}if(Ge.includes("s")&&(_t=Math.max(5,(V.height??0)+at)),Ge.includes("n")){const Gt=(V.height??0)-at;Gt>5&&(_t=Gt,dt=(V.y??0)+at)}z={x:X,y:dt,width:ft,height:_t}}Object.keys(z).length>0&&u(cf({id:V.id,updates:z}));return}D&&(lt({x:F,y:U}),m==="pencil"&&K(z=>[...z,{x:F,y:U}]))},fv=()=>{if(jt||Ct){vt(!1),Ae(!1);return}if(C){tt(!1),j(!1);return}if(rt&&tt(!1),th&&oe){const S=oe.width>0?oe.startX:oe.startX+oe.width,P=oe.height>0?oe.startY:oe.startY+oe.height,k=Math.abs(oe.width),I=Math.abs(oe.height),L=[];w.forEach(F=>{const U=nh(F);U&&U.x<S+k&&U.x+U.w>S&&U.y<P+I&&U.y+U.h>P&&L.push(F.id)}),L.length>0&&u(Is(L))}if(j(!1),tt(!1),Cu(!1),cp(!1),Tu(null),op(null),lp(null),K([]),H({x:0,y:0}),ct({}),_u(null),vt(!1),!!D){if(m==="pointer")_r();else if(m==="rectangle"){const S=Math.min(O.x,N.x),P=Math.min(O.y,N.y),k=Math.abs(N.x-O.x),I=Math.abs(N.y-O.y);k>0&&I>0&&u(Ri({id:Date.now().toString(),type:"rectangle",x:S,y:P,width:k,height:I,strokeColor:x.rectangle.strokeColor,fillColor:x.rectangle.fillColor,lineWidth:x.rectangle.lineWidth}))}else if(m==="circle"){const S=O.x,P=O.y,k=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));k>0&&u(Ri({id:Date.now().toString(),type:"circle",centerX:S,centerY:P,radius:k,strokeColor:x.circle.strokeColor,fillColor:x.circle.fillColor,lineWidth:x.circle.lineWidth}))}else if(m==="pencil")G.length>1&&u(Ri({id:Date.now().toString(),type:"pencil",points:[...G],strokeColor:x.pencil.strokeColor,lineWidth:x.pencil.lineWidth})),K([]);else if(m==="triangle"){const S=Math.min(O.x,N.x),P=Math.min(O.y,N.y),k=Math.abs(N.x-O.x),I=Math.abs(N.y-O.y);k>0&&I>0&&u(Ri({id:Date.now().toString(),type:"triangle",x:S,y:P,width:k,height:I,strokeColor:x.triangle.strokeColor,fillColor:x.triangle.fillColor,lineWidth:x.triangle.lineWidth}))}else if(m==="diamond"){const S=Math.min(O.x,N.x),P=Math.min(O.y,N.y),k=Math.abs(N.x-O.x),I=Math.abs(N.y-O.y);k>0&&I>0&&u(Ri({id:Date.now().toString(),type:"diamond",x:S,y:P,width:k,height:I,strokeColor:x.diamond.strokeColor,fillColor:x.diamond.fillColor,lineWidth:x.diamond.lineWidth}))}else if(m==="star"){const S=O.x,P=O.y,k=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));k>0&&u(Ri({id:Date.now().toString(),type:"star",centerX:S,centerY:P,size:k,strokeColor:x.star.strokeColor,fillColor:x.star.fillColor,lineWidth:x.star.lineWidth}))}else if(m==="heart"){const S=O.x,P=O.y,k=Math.sqrt(Math.pow(N.x-O.x,2)+Math.pow(N.y-O.y,2));k>0&&u(Ri({id:Date.now().toString(),type:"heart",centerX:S,centerY:P,size:k,strokeColor:x.heart.strokeColor,fillColor:x.heart.fillColor,lineWidth:x.heart.lineWidth}))}else if(m==="hexagon"){const S=Math.min(O.x,N.x),P=Math.min(O.y,N.y),k=Math.abs(N.x-O.x),I=Math.abs(N.y-O.y);k>0&&I>0&&u(Ri({id:Date.now().toString(),type:"hexagon",x:S,y:P,width:k,height:I,strokeColor:x.hexagon.strokeColor,fillColor:x.hexagon.fillColor,lineWidth:x.hexagon.lineWidth}))}else if(m==="octagon"){const S=Math.min(O.x,N.x),P=Math.min(O.y,N.y),k=Math.abs(N.x-O.x),I=Math.abs(N.y-O.y);k>0&&I>0&&u(Ri({id:Date.now().toString(),type:"octagon",x:S,y:P,width:k,height:I,strokeColor:x.octagon.strokeColor,fillColor:x.octagon.fillColor,lineWidth:x.octagon.lineWidth}))}else if(m==="arrow"){const S=N.x-O.x,P=N.y-O.y;Math.sqrt(S*S+P*P)>5&&u(Ri({id:Date.now().toString(),type:"arrow",startX:O.x,startY:O.y,endX:N.x,endY:N.y,strokeColor:x.arrow.strokeColor,fillColor:x.arrow.fillColor,lineWidth:x.arrow.lineWidth}))}j(!1)}},Fx=S=>{if(S.ctrlKey||S.metaKey){S.preventDefault();const P=f.current;if(!P)return;const k=P.getBoundingClientRect(),I=S.clientX-k.left,L=S.clientY-k.top,F=(I-y.panX)/y.zoom,U=(L-y.panY)/y.zoom,z=-S.deltaY,Y=.1,at=z>0?y.zoom*(1+Y):y.zoom/(1+Y),V=Math.min(Math.max(at,.1),5),X=I-F*V,dt=L-U*V;u(gh(V)),u(No({x:X,y:dt}))}else{S.preventDefault();const P=f.current;if(!P)return;const k=P.getBoundingClientRect(),I=S.clientX-k.left,L=S.clientY-k.top,F=(I-y.panX)/y.zoom,U=(L-y.panY)/y.zoom,z=.001;let Y=1;S.deltaMode===1?Y=1-S.deltaY*.05:Y=1-S.deltaY*z;const at=y.zoom*Y,V=Math.min(Math.max(at,.1),5),X=I-F*V,dt=L-U*V;u(gh(V)),u(No({x:X,y:dt}))}},Bx=S=>{Dt&&S.preventDefault()},jx=(S,P,k)=>{bn(S.id),nt(S.text||""),st({x:S.x||P,y:S.y||k}),Ms.current=S.text||"",Ne(!0)},zx=()=>{if(Dt)return jt?"grabbing":Ct?"ns-resize":"grab";if(C)return"default";if(E.length===1&&!D&&m==="pointer"){const S=w.find(P=>P.id===E[0]);if(S){const P=dv(N.x,N.y,S,y.zoom);if(P)return P==="n"||P==="s"?"ns-resize":P==="e"||P==="w"?"ew-resize":P==="ne"||P==="sw"?"nesw-resize":P==="nw"||P==="se"?"nwse-resize":"pointer"}}return"default"},[pv,gv]=B.useState({propTools:!1,lockIndicator:!1});B.useEffect(()=>{const S=()=>{if(window.innerWidth<=768){gv({propTools:!1,lockIndicator:!1});return}const P=document.getElementById("wb-canvas-container");if(!P)return;const k=P.querySelector(".wb-toolbar"),I=P.querySelector(".wb-prop-tools"),L=P.querySelector(".wb-lock-indicator");let F=!1,U=!1;if(k){const z=k.getBoundingClientRect();if(I){const Y=I.getBoundingClientRect();z.bottom>Y.top-10&&(F=!0)}if(L){const Y=L.getBoundingClientRect();z.top<Y.bottom+10&&(U=!0)}}gv({propTools:F,lockIndicator:U})};return S(),window.addEventListener("resize",S),()=>{window.removeEventListener("resize",S)}},[m,C,E]);const Lm=B.useCallback(async(S,P,k)=>{if(S.type==="application/pdf"){await ku(S);return}try{let I="";h?I=await h(S):I=URL.createObjectURL(S);const L=new Image;L.onload=()=>{const F=L.width/L.height,U=200,z=U/F;u(Ri({id:Date.now().toString(),type:"image",x:P-U/2,y:k-z/2,width:U,height:z,src:I}))},L.src=I}catch(I){console.error("Failed to upload image:",I)}},[ku,h,u]);B.useEffect(()=>{const S=P=>{if(!(P.target.tagName==="INPUT"||P.target.tagName==="TEXTAREA")&&!C&&P.clipboardData&&P.clipboardData.files.length>0){const k=P.clipboardData.files[0];if(k.type.startsWith("image/")||k.type==="application/pdf"){P.preventDefault();const I=f.current;if(I){const L=I.getBoundingClientRect(),F=L.width/2,U=L.height/2,{x:z,y:Y}=al(F,U);Lm(k,z,Y)}}}};return window.addEventListener("paste",S),()=>window.removeEventListener("paste",S)},[C,al,Lm]);const Ux=S=>{S.preventDefault()},Hx=S=>{if(S.preventDefault(),!C&&S.dataTransfer.files&&S.dataTransfer.files.length>0){const P=S.dataTransfer.files[0];if(P.type.startsWith("image/")||P.type==="application/pdf"){const k=f.current;if(k){const I=k.getBoundingClientRect(),L=S.clientX-I.left,F=S.clientY-I.top,{x:U,y:z}=al(L,F);Lm(P,U,z)}}}};return M.jsxs("div",{id:"wb-canvas-container",style:{backgroundColor:"#fff",position:"relative",width:"100%",height:"100%"},onDragOver:Ux,onDrop:Hx,children:[M.jsx("canvas",{ref:f,onMouseDown:Lx,onMouseMove:Nx,onMouseUp:fv,onMouseLeave:fv,onWheel:Fx,onDoubleClick:S=>{if(C)return;const P=f.current;if(!P)return;const k=P.getBoundingClientRect(),I=S.clientX-k.left,L=S.clientY-k.top,{x:F,y:U}=al(I,L),z=Im(F,U);z&&z.type==="text"&&jx(z,F,U)},onContextMenu:Bx,style:{cursor:zx()}}),C&&M.jsx(wS,{text:e||a&&((mv=a.lock)==null?void 0:mv.text)||_.text,shifted:pv.lockIndicator}),Hi&&M.jsx("input",{type:"text",value:Ve,onChange:S=>{const P=S.target.value;nt(P),Om(P)},onKeyDown:S=>{S.key==="Enter"&&Ve.trim()?(Fe&&(u(cf({id:Fe,updates:{text:Ve}})),Ms.current=Ve),Ne(!1),nt(""),bn(null)):S.key==="Escape"&&(Ne(!1),nt(""),bn(null))},onBlur:()=>{Ve.trim()&&Fe&&(u(cf({id:Fe,updates:{text:Ve}})),Ms.current=Ve),Ne(!1),nt(""),bn(null)},onMouseDown:S=>S.stopPropagation(),autoFocus:!0,style:{position:"absolute",left:wi.x*y.zoom+y.panX,top:wi.y*y.zoom+y.panY,fontSize:x.text.fontSize*y.zoom,color:x.text.fontColor,background:"white",border:"2px solid #0066cc",outline:"none",fontFamily:"sans-serif",minWidth:"150px",padding:"4px 8px",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"}}),M.jsx(DS,{onFitToView:Ox,onExport:Dx,onToggleGrid:Ix}),M.jsx(MS,{mode:o,onImageUpload:h,onPdfSelected:ku}),yn&&M.jsx(OS,{currentPage:xr,totalPages:yn.numPages,onPrevPage:()=>Mu(xr-1),onNextPage:()=>Mu(xr+1),onDelete:dp,onDownload:up}),M.jsx(RS,{shifted:pv.propTools}),ol.visible&&M.jsx(X1,{})]})});Cm.displayName="InternalWhiteboard";class Rx extends B.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,e){console.error("Whiteboard Error:",t,e)}render(){return this.state.hasError?M.jsxs("div",{style:{padding:"20px",textAlign:"center",background:"#fff1f0",border:"1px solid #ffa39e",borderRadius:"4px",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[M.jsx("h3",{children:"Something went wrong in Whiteboard"}),M.jsx("button",{onClick:()=>this.setState({hasError:!1}),style:{marginTop:"10px",padding:"8px 16px",cursor:"pointer",background:"#fff",border:"1px solid #d9d9d9",borderRadius:"2px"},children:"Try Again"})]}):this.props.children}}const lv=B.forwardRef((a,t)=>{const{store:e,onAction:i,...n}=a,r=B.useRef(i);B.useEffect(()=>{r.current=i},[i]);const o=B.useMemo(()=>e??Dg({actionHandlerRef:r}),[e]);return M.jsx(Rx,{children:M.jsx(xA,{store:o,children:M.jsx(kA,{children:M.jsx(Cm,{ref:t,...n})})})})});lv.displayName="Whiteboard",Et.WhiteboardComponent=Cm,Et.createWhiteboardStore=Dg,Et.default=lv,Et.store=Y1,Et.whiteboardActions=H1,Et.whiteboardReducer=Ky,Object.defineProperties(Et,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
104
+ `)){l.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),o.collapseToStart();return}const{startContainer:c,startOffset:h}=l,d=[],u=[];if(c.nodeType===Node.TEXT_NODE){const w=c.parentElement;if(u.push(c.nodeValue.slice(h).replaceAll(Nf,"")),w!==this.editorDiv){let _=d;for(const A of this.editorDiv.childNodes){if(A===w){_=u;continue}_.push(S(b=ue,pr,Np).call(b,A))}}d.push(c.nodeValue.slice(0,h).replaceAll(Nf,""))}else if(c===this.editorDiv){let w=d,_=0;for(const A of this.editorDiv.childNodes)_++===h&&(w=u),w.push(S(v=ue,pr,Np).call(v,A))}g(this,hn,`${d.join(`
105
+ `)}${r}${u.join(`
106
+ `)}`),S(this,Ne,Fp).call(this);const f=new Range;let p=Math.sumPrecise(d.map(w=>w.length));for(const{firstChild:w}of this.editorDiv.childNodes)if(w.nodeType===Node.TEXT_NODE){const _=w.nodeValue.length;if(p<=_){f.setStart(w,p),f.setEnd(w,p);break}p-=_}o.removeAllRanges(),o.addRange(f)}get contentDiv(){return this.editorDiv}getPDFRect(){const e=ue._internalPadding*this.parentScale;return this.getRect(e,e)}static async deserialize(e,i,n){var l;let r=null;if(e instanceof nv){const{data:{defaultAppearanceData:{fontSize:c,fontColor:h},rect:d,rotation:u,id:f,popupRef:p,richText:m,contentsObj:b,creationDate:v,modificationDate:w},textContent:_,textPosition:A,parent:{page:{pageNumber:C}}}=e;if(!_||_.length===0)return null;r=e={annotationType:mt.FREETEXT,color:Array.from(h),fontSize:c,value:_.join(`
107
+ `),position:A,pageIndex:C-1,rect:d.slice(0),rotation:u,annotationElementId:f,id:f,deleted:!1,popupRef:p,comment:(b==null?void 0:b.str)||null,richText:m,creationDate:v,modificationDate:w}}const o=await super.deserialize(e,i,n);return g(o,dn,e.fontSize),o.color=Z.makeHexColor(...e.color),g(o,hn,S(l=ue,pr,Eb).call(l,e.value)),o._initialData=r,e.comment&&o.setCommentData(e),o}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const i=le._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.color),n=Object.assign(super.serialize(e),{color:i,fontSize:s(this,dn),value:S(this,Ne,yw).call(this)});return this.addComment(n),e?(n.isCopy=!0,n):this.annotationElementId&&!S(this,Ne,vw).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){const i=super.renderAnnotationElement(e);if(!i)return null;const{style:n}=i;n.fontSize=`calc(${s(this,dn)}px * var(--total-scale-factor))`,n.color=this.color,i.replaceChildren();for(const r of s(this,hn).split(`
108
+ `)){const o=document.createElement("div");o.append(r?document.createTextNode(r):document.createElement("br")),i.append(o)}return e.updateEdited({rect:this.getPDFRect(),popup:this._uiManager.hasCommentManager()||this.hasEditedComment?this.comment:{text:s(this,hn)}}),i}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}};hn=new WeakMap,hu=new WeakMap,$a=new WeakMap,dn=new WeakMap,Ne=new WeakSet,gw=function(e){const i=r=>{this.editorDiv.style.fontSize=`calc(${r}px * var(--total-scale-factor))`,this.translate(0,-(r-s(this,dn))*this.parentScale),g(this,dn,r),S(this,Ne,Lp).call(this)},n=s(this,dn);this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:kt.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})},mw=function(e){const i=r=>{this.color=r,this.onUpdatedColor()},n=this.color;this.addCommands({cmd:i.bind(this,e),undo:i.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:kt.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})},bw=function(){var n;const e=[];this.editorDiv.normalize();let i=null;for(const r of this.editorDiv.childNodes)(i==null?void 0:i.nodeType)===Node.TEXT_NODE&&r.nodeName==="BR"||(e.push(S(n=ue,pr,Np).call(n,r)),i=r);return e.join(`
109
+ `)},Lp=function(){const[e,i]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:r,div:o}=this,l=o.style.display,c=o.classList.contains("hidden");o.classList.remove("hidden"),o.style.display="hidden",r.div.append(this.div),n=o.getBoundingClientRect(),o.remove(),o.style.display=l,o.classList.toggle("hidden",c)}this.rotation%180===this.parentRotation%180?(this.width=n.width/e,this.height=n.height/i):(this.width=n.height/e,this.height=n.width/i),this.fixAndSetPosition()},pr=new WeakSet,Np=function(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(Nf,"")},Fp=function(){if(this.editorDiv.replaceChildren(),!!s(this,hn))for(const e of s(this,hn).split(`
110
+ `)){const i=document.createElement("div");i.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(i)}},yw=function(){return s(this,hn).replaceAll(" "," ")},Eb=function(e){return e.replaceAll(" "," ")},vw=function(e){const{value:i,fontSize:n,color:r,pageIndex:o}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||e.value!==i||e.fontSize!==n||e.color.some((l,c)=>l!==r[c])||e.pageIndex!==o},y(ue,pr),W(ue,"_freeTextDefaultContent",""),W(ue,"_internalPadding",0),W(ue,"_defaultColor",null),W(ue,"_defaultFontSize",10),W(ue,"_type","freetext"),W(ue,"_editorType",mt.FREETEXT);let pm=ue;class nt{toSVGPath(){ne("Abstract method `toSVGPath` must be implemented.")}get box(){ne("Abstract getter `box` must be implemented.")}serialize(t,e){ne("Abstract method `serialize` must be implemented.")}static _rescale(t,e,i,n,r,o){o||(o=new Float32Array(t.length));for(let l=0,c=t.length;l<c;l+=2)o[l]=e+t[l]*n,o[l+1]=i+t[l+1]*r;return o}static _rescaleAndSwap(t,e,i,n,r,o){o||(o=new Float32Array(t.length));for(let l=0,c=t.length;l<c;l+=2)o[l]=e+t[l+1]*n,o[l+1]=i+t[l]*r;return o}static _translate(t,e,i,n){n||(n=new Float32Array(t.length));for(let r=0,o=t.length;r<o;r+=2)n[r]=e+t[r],n[r+1]=i+t[r+1];return n}static svgRound(t){return Math.round(t*1e4)}static _normalizePoint(t,e,i,n,r){switch(r){case 90:return[1-e/i,t/n];case 180:return[1-t/i,1-e/n];case 270:return[e/i,1-t/n];default:return[t/i,e/n]}}static _normalizePagePoint(t,e,i){switch(i){case 90:return[1-e,t];case 180:return[1-t,1-e];case 270:return[e,1-t];default:return[t,e]}}static createBezierPoints(t,e,i,n,r,o){return[(t+5*i)/6,(e+5*n)/6,(5*i+r)/6,(5*n+o)/6,(i+r)/2,(n+o)/2]}}W(nt,"PRECISION",1e-4);const gr=class gr{constructor({x:t,y:e},i,n,r,o,l=0){y(this,He);y(this,un);y(this,Yn,[]);y(this,Fc);y(this,Bc);y(this,Ss,[]);y(this,_t,new Float32Array(18));y(this,Wa);y(this,Va);y(this,du);y(this,uu);y(this,jc);y(this,zc);y(this,vo,[]);g(this,un,i),g(this,zc,r*n),g(this,Bc,o),s(this,_t).set([NaN,NaN,NaN,NaN,t,e],6),g(this,Fc,l),g(this,uu,s(gr,fu)*n),g(this,du,s(gr,np)*n),g(this,jc,n),s(this,vo).push(t,e)}isEmpty(){return isNaN(s(this,_t)[8])}add({x:t,y:e}){var z;g(this,Wa,t),g(this,Va,e);const[i,n,r,o]=s(this,un);let[l,c,h,d]=s(this,_t).subarray(8,12);const u=t-h,f=e-d,p=Math.hypot(u,f);if(p<s(this,du))return!1;const m=p-s(this,uu),b=m/p,v=b*u,w=b*f;let _=l,A=c;l=h,c=d,h+=v,d+=w,(z=s(this,vo))==null||z.push(t,e);const C=-w/m,x=v/m,P=C*s(this,zc),R=x*s(this,zc);return s(this,_t).set(s(this,_t).subarray(2,8),0),s(this,_t).set([h+P,d+R],4),s(this,_t).set(s(this,_t).subarray(14,18),12),s(this,_t).set([h-P,d-R],16),isNaN(s(this,_t)[6])?(s(this,Ss).length===0&&(s(this,_t).set([l+P,c+R],2),s(this,Ss).push(NaN,NaN,NaN,NaN,(l+P-i)/r,(c+R-n)/o),s(this,_t).set([l-P,c-R],14),s(this,Yn).push(NaN,NaN,NaN,NaN,(l-P-i)/r,(c-R-n)/o)),s(this,_t).set([_,A,l,c,h,d],6),!this.isEmpty()):(s(this,_t).set([_,A,l,c,h,d],6),Math.abs(Math.atan2(A-c,_-l)-Math.atan2(w,v))<Math.PI/2?([l,c,h,d]=s(this,_t).subarray(2,6),s(this,Ss).push(NaN,NaN,NaN,NaN,((l+h)/2-i)/r,((c+d)/2-n)/o),[l,c,_,A]=s(this,_t).subarray(14,18),s(this,Yn).push(NaN,NaN,NaN,NaN,((_+l)/2-i)/r,((A+c)/2-n)/o),!0):([_,A,l,c,h,d]=s(this,_t).subarray(0,6),s(this,Ss).push(((_+5*l)/6-i)/r,((A+5*c)/6-n)/o,((5*l+h)/6-i)/r,((5*c+d)/6-n)/o,((l+h)/2-i)/r,((c+d)/2-n)/o),[h,d,l,c,_,A]=s(this,_t).subarray(12,18),s(this,Yn).push(((_+5*l)/6-i)/r,((A+5*c)/6-n)/o,((5*l+h)/6-i)/r,((5*c+d)/6-n)/o,((l+h)/2-i)/r,((c+d)/2-n)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const t=s(this,Ss),e=s(this,Yn);if(isNaN(s(this,_t)[6])&&!this.isEmpty())return S(this,He,ww).call(this);const i=[];i.push(`M${t[4]} ${t[5]}`);for(let n=6;n<t.length;n+=6)isNaN(t[n])?i.push(`L${t[n+4]} ${t[n+5]}`):i.push(`C${t[n]} ${t[n+1]} ${t[n+2]} ${t[n+3]} ${t[n+4]} ${t[n+5]}`);S(this,He,Sw).call(this,i);for(let n=e.length-6;n>=6;n-=6)isNaN(e[n])?i.push(`L${e[n+4]} ${e[n+5]}`):i.push(`C${e[n]} ${e[n+1]} ${e[n+2]} ${e[n+3]} ${e[n+4]} ${e[n+5]}`);return S(this,He,Aw).call(this,i),i.join(" ")}newFreeDrawOutline(t,e,i,n,r,o){return new av(t,e,i,n,r,o)}getOutlines(){var u;const t=s(this,Ss),e=s(this,Yn),i=s(this,_t),[n,r,o,l]=s(this,un),c=new Float32Array((((u=s(this,vo))==null?void 0:u.length)??0)+2);for(let f=0,p=c.length-2;f<p;f+=2)c[f]=(s(this,vo)[f]-n)/o,c[f+1]=(s(this,vo)[f+1]-r)/l;if(c[c.length-2]=(s(this,Wa)-n)/o,c[c.length-1]=(s(this,Va)-r)/l,isNaN(i[6])&&!this.isEmpty())return S(this,He,Ew).call(this,c);const h=new Float32Array(s(this,Ss).length+24+s(this,Yn).length);let d=t.length;for(let f=0;f<d;f+=2){if(isNaN(t[f])){h[f]=h[f+1]=NaN;continue}h[f]=t[f],h[f+1]=t[f+1]}d=S(this,He,Cw).call(this,h,d);for(let f=e.length-6;f>=6;f-=6)for(let p=0;p<6;p+=2){if(isNaN(e[f+p])){h[d]=h[d+1]=NaN,d+=2;continue}h[d]=e[f+p],h[d+1]=e[f+p+1],d+=2}return S(this,He,xw).call(this,h,d),this.newFreeDrawOutline(h,c,s(this,un),s(this,jc),s(this,Fc),s(this,Bc))}};un=new WeakMap,Yn=new WeakMap,Fc=new WeakMap,Bc=new WeakMap,Ss=new WeakMap,_t=new WeakMap,Wa=new WeakMap,Va=new WeakMap,du=new WeakMap,uu=new WeakMap,jc=new WeakMap,zc=new WeakMap,vo=new WeakMap,fu=new WeakMap,ip=new WeakMap,np=new WeakMap,He=new WeakSet,Xu=function(){const t=s(this,_t).subarray(4,6),e=s(this,_t).subarray(16,18),[i,n,r,o]=s(this,un);return[(s(this,Wa)+(t[0]-e[0])/2-i)/r,(s(this,Va)+(t[1]-e[1])/2-n)/o,(s(this,Wa)+(e[0]-t[0])/2-i)/r,(s(this,Va)+(e[1]-t[1])/2-n)/o]},ww=function(){const[t,e,i,n]=s(this,un),[r,o,l,c]=S(this,He,Xu).call(this);return`M${(s(this,_t)[2]-t)/i} ${(s(this,_t)[3]-e)/n} L${(s(this,_t)[4]-t)/i} ${(s(this,_t)[5]-e)/n} L${r} ${o} L${l} ${c} L${(s(this,_t)[16]-t)/i} ${(s(this,_t)[17]-e)/n} L${(s(this,_t)[14]-t)/i} ${(s(this,_t)[15]-e)/n} Z`},Aw=function(t){const e=s(this,Yn);t.push(`L${e[4]} ${e[5]} Z`)},Sw=function(t){const[e,i,n,r]=s(this,un),o=s(this,_t).subarray(4,6),l=s(this,_t).subarray(16,18),[c,h,d,u]=S(this,He,Xu).call(this);t.push(`L${(o[0]-e)/n} ${(o[1]-i)/r} L${c} ${h} L${d} ${u} L${(l[0]-e)/n} ${(l[1]-i)/r}`)},Ew=function(t){const e=s(this,_t),[i,n,r,o]=s(this,un),[l,c,h,d]=S(this,He,Xu).call(this),u=new Float32Array(36);return u.set([NaN,NaN,NaN,NaN,(e[2]-i)/r,(e[3]-n)/o,NaN,NaN,NaN,NaN,(e[4]-i)/r,(e[5]-n)/o,NaN,NaN,NaN,NaN,l,c,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(e[16]-i)/r,(e[17]-n)/o,NaN,NaN,NaN,NaN,(e[14]-i)/r,(e[15]-n)/o],0),this.newFreeDrawOutline(u,t,s(this,un),s(this,jc),s(this,Fc),s(this,Bc))},xw=function(t,e){const i=s(this,Yn);return t.set([NaN,NaN,NaN,NaN,i[4],i[5]],e),e+=6},Cw=function(t,e){const i=s(this,_t).subarray(4,6),n=s(this,_t).subarray(16,18),[r,o,l,c]=s(this,un),[h,d,u,f]=S(this,He,Xu).call(this);return t.set([NaN,NaN,NaN,NaN,(i[0]-r)/l,(i[1]-o)/c,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,u,f,NaN,NaN,NaN,NaN,(n[0]-r)/l,(n[1]-o)/c],e),e+=24},y(gr,fu,8),y(gr,ip,2),y(gr,np,s(gr,fu)+s(gr,ip));let Ff=gr;class av extends nt{constructor(e,i,n,r,o,l){super();y(this,sp);y(this,Uc);y(this,Ga,new Float32Array(4));y(this,mr);y(this,pu);y(this,fn);y(this,gu);y(this,De);g(this,De,e),g(this,fn,i),g(this,Uc,n),g(this,gu,r),g(this,mr,o),g(this,pu,l),this.firstPoint=[NaN,NaN],this.lastPoint=[NaN,NaN],S(this,sp,_w).call(this,l);const[c,h,d,u]=s(this,Ga);for(let f=0,p=e.length;f<p;f+=2)e[f]=(e[f]-c)/d,e[f+1]=(e[f+1]-h)/u;for(let f=0,p=i.length;f<p;f+=2)i[f]=(i[f]-c)/d,i[f+1]=(i[f+1]-h)/u}toSVGPath(){const e=[`M${s(this,De)[4]} ${s(this,De)[5]}`];for(let i=6,n=s(this,De).length;i<n;i+=6){if(isNaN(s(this,De)[i])){e.push(`L${s(this,De)[i+4]} ${s(this,De)[i+5]}`);continue}e.push(`C${s(this,De)[i]} ${s(this,De)[i+1]} ${s(this,De)[i+2]} ${s(this,De)[i+3]} ${s(this,De)[i+4]} ${s(this,De)[i+5]}`)}return e.push("Z"),e.join(" ")}serialize([e,i,n,r],o){const l=n-e,c=r-i;let h,d;switch(o){case 0:h=nt._rescale(s(this,De),e,r,l,-c),d=nt._rescale(s(this,fn),e,r,l,-c);break;case 90:h=nt._rescaleAndSwap(s(this,De),e,i,l,c),d=nt._rescaleAndSwap(s(this,fn),e,i,l,c);break;case 180:h=nt._rescale(s(this,De),n,i,-l,c),d=nt._rescale(s(this,fn),n,i,-l,c);break;case 270:h=nt._rescaleAndSwap(s(this,De),n,r,-l,-c),d=nt._rescaleAndSwap(s(this,fn),n,r,-l,-c);break}return{outline:Array.from(h),points:[Array.from(d)]}}get box(){return s(this,Ga)}newOutliner(e,i,n,r,o,l=0){return new Ff(e,i,n,r,o,l)}getNewOutline(e,i){const[n,r,o,l]=s(this,Ga),[c,h,d,u]=s(this,Uc),f=o*d,p=l*u,m=n*d+c,b=r*u+h,v=this.newOutliner({x:s(this,fn)[0]*f+m,y:s(this,fn)[1]*p+b},s(this,Uc),s(this,gu),e,s(this,pu),i??s(this,mr));for(let w=2;w<s(this,fn).length;w+=2)v.add({x:s(this,fn)[w]*f+m,y:s(this,fn)[w+1]*p+b});return v.getOutlines()}}Uc=new WeakMap,Ga=new WeakMap,mr=new WeakMap,pu=new WeakMap,fn=new WeakMap,gu=new WeakMap,De=new WeakMap,sp=new WeakSet,_w=function(e){const i=s(this,De);let n=i[4],r=i[5];const o=[n,r,n,r];let l=n,c=r,h=n,d=r;const u=e?Math.max:Math.min,f=new Float32Array(4);for(let m=6,b=i.length;m<b;m+=6){const v=i[m+4],w=i[m+5];isNaN(i[m])?(Z.pointBoundingBox(v,w,o),c>w?(l=v,c=w):c===w&&(l=u(l,v)),d<w?(h=v,d=w):d===w&&(h=u(h,v))):(f[0]=f[1]=1/0,f[2]=f[3]=-1/0,Z.bezierBoundingBox(n,r,...i.slice(m,m+6),f),Z.rectBoundingBox(f[0],f[1],f[2],f[3],o),c>f[1]?(l=f[0],c=f[1]):c===f[1]&&(l=u(l,f[0])),d<f[3]?(h=f[2],d=f[3]):d===f[3]&&(h=u(h,f[2]))),n=v,r=w}const p=s(this,Ga);p[0]=o[0]-s(this,mr),p[1]=o[1]-s(this,mr),p[2]=o[2]-o[0]+2*s(this,mr),p[3]=o[3]-o[1]+2*s(this,mr),this.firstPoint=[l,c],this.lastPoint=[h,d]};class gm{constructor(t,e=0,i=0,n=!0){y(this,_i);y(this,mu);y(this,bu);y(this,yu);y(this,wo,[]);y(this,Xn,[]);const r=[1/0,1/0,-1/0,-1/0],o=10**-4;for(const{x:b,y:v,width:w,height:_}of t){const A=Math.floor((b-e)/o)*o,C=Math.ceil((b+w+e)/o)*o,x=Math.floor((v-e)/o)*o,P=Math.ceil((v+_+e)/o)*o,R=[A,x,P,!0],N=[C,x,P,!1];s(this,wo).push(R,N),Z.rectBoundingBox(A,x,C,P,r)}const l=r[2]-r[0]+2*i,c=r[3]-r[1]+2*i,h=r[0]-i,d=r[1]-i;let u=n?-1/0:1/0,f=1/0;const p=s(this,wo).at(n?-1:-2),m=[p[0],p[2]];for(const b of s(this,wo)){const[v,w,_,A]=b;!A&&n?w<f?(f=w,u=v):w===f&&(u=Math.max(u,v)):A&&!n&&(w<f?(f=w,u=v):w===f&&(u=Math.min(u,v))),b[0]=(v-h)/l,b[1]=(w-d)/c,b[2]=(_-d)/c}g(this,mu,new Float32Array([h,d,l,c])),g(this,bu,[u,f]),g(this,yu,m)}getOutlines(){s(this,wo).sort((e,i)=>e[0]-i[0]||e[1]-i[1]||e[2]-i[2]);const t=[];for(const e of s(this,wo))e[3]?(t.push(...S(this,_i,xb).call(this,e)),S(this,_i,Pw).call(this,e)):(S(this,_i,kw).call(this,e),t.push(...S(this,_i,xb).call(this,e)));return S(this,_i,Tw).call(this,t)}}mu=new WeakMap,bu=new WeakMap,yu=new WeakMap,wo=new WeakMap,Xn=new WeakMap,_i=new WeakSet,Tw=function(t){const e=[],i=new Set;for(const o of t){const[l,c,h]=o;e.push([l,c,o],[l,h,o])}e.sort((o,l)=>o[1]-l[1]||o[0]-l[0]);for(let o=0,l=e.length;o<l;o+=2){const c=e[o][2],h=e[o+1][2];c.push(h),h.push(c),i.add(c),i.add(h)}const n=[];let r;for(;i.size>0;){const o=i.values().next().value;let[l,c,h,d,u]=o;i.delete(o);let f=l,p=c;for(r=[l,h],n.push(r);;){let m;if(i.has(d))m=d;else if(i.has(u))m=u;else break;i.delete(m),[l,c,h,d,u]=m,f!==l&&(r.push(f,p,l,p===c?c:h),f=l),p=p===c?h:c}r.push(f,p)}return new Mx(n,s(this,mu),s(this,bu),s(this,yu))},Bp=function(t){const e=s(this,Xn);let i=0,n=e.length-1;for(;i<=n;){const r=i+n>>1,o=e[r][0];if(o===t)return r;o<t?i=r+1:n=r-1}return n+1},Pw=function([,t,e]){const i=S(this,_i,Bp).call(this,t);s(this,Xn).splice(i,0,[t,e])},kw=function([,t,e]){const i=S(this,_i,Bp).call(this,t);for(let n=i;n<s(this,Xn).length;n++){const[r,o]=s(this,Xn)[n];if(r!==t)break;if(r===t&&o===e){s(this,Xn).splice(n,1);return}}for(let n=i-1;n>=0;n--){const[r,o]=s(this,Xn)[n];if(r!==t)break;if(r===t&&o===e){s(this,Xn).splice(n,1);return}}},xb=function(t){const[e,i,n]=t,r=[[e,i,n]],o=S(this,_i,Bp).call(this,n);for(let l=0;l<o;l++){const[c,h]=s(this,Xn)[l];for(let d=0,u=r.length;d<u;d++){const[,f,p]=r[d];if(!(h<=f||p<=c)){if(f>=c){if(p>h)r[d][1]=h;else{if(u===1)return[];r.splice(d,1),d--,u--}continue}r[d][2]=c,p>h&&r.push([e,h,p])}}}return r};class Mx extends nt{constructor(e,i,n,r){super();y(this,vu);y(this,Hc);g(this,Hc,e),g(this,vu,i),this.firstPoint=n,this.lastPoint=r}toSVGPath(){const e=[];for(const i of s(this,Hc)){let[n,r]=i;e.push(`M${n} ${r}`);for(let o=2;o<i.length;o+=2){const l=i[o],c=i[o+1];l===n?(e.push(`V${c}`),r=c):c===r&&(e.push(`H${l}`),n=l)}e.push("Z")}return e.join(" ")}serialize([e,i,n,r],o){const l=[],c=n-e,h=r-i;for(const d of s(this,Hc)){const u=new Array(d.length);for(let f=0;f<d.length;f+=2)u[f]=e+d[f]*c,u[f+1]=r-d[f+1]*h;l.push(u)}return l}get box(){return s(this,vu)}get classNamesForOutlining(){return["highlightOutline"]}}vu=new WeakMap,Hc=new WeakMap;class mm extends Ff{newFreeDrawOutline(t,e,i,n,r,o){return new Rx(t,e,i,n,r,o)}}class Rx extends av{newOutliner(t,e,i,n,r,o=0){return new mm(t,e,i,n,r,o)}}const Ft=class Ft extends le{constructor(e){super({...e,name:"highlightEditor"});y(this,wt);y(this,$c,null);y(this,wu,0);y(this,br);y(this,Ya,null);y(this,Au,null);y(this,zi,null);y(this,Su,null);y(this,Eu,0);y(this,Xa,null);y(this,pn,null);y(this,gn,null);y(this,ci,!1);y(this,Wc,null);y(this,Vc,null);y(this,yi,null);y(this,Gc,"");y(this,In);y(this,xu,"");this.color=e.color||Ft._defaultColor,g(this,In,e.thickness||Ft._defaultThickness),this.opacity=e.opacity||Ft._defaultOpacity,g(this,br,e.boxes||null),g(this,xu,e.methodOfCreation||""),g(this,Gc,e.text||""),this._isDraggable=!1,this.defaultL10nId="pdfjs-editor-highlight-editor",e.highlightId>-1?(g(this,ci,!0),S(this,wt,jp).call(this,e),S(this,wt,gl).call(this)):s(this,br)&&(g(this,$c,e.anchorNode),g(this,wu,e.anchorOffset),g(this,Su,e.focusNode),g(this,Eu,e.focusOffset),S(this,wt,Cb).call(this),S(this,wt,gl).call(this),this.rotate(this.rotation)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-highlight-added-alert")}static get _keyboardManager(){const e=Ft.prototype;return gt(this,"_keyboardManager",new Ph([[["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:s(this,ci)?"free_highlight":"highlight",color:this._uiManager.getNonHCMColorName(this.color),thickness:s(this,In),methodOfCreation:s(this,xu)}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.getNonHCMColorName(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}static initialize(e,i){var n;le.initialize(e,i),Ft._defaultColor||(Ft._defaultColor=((n=i.highlightColors)==null?void 0:n.values().next().value)||"#fff066")}static updateDefaultParams(e,i){switch(e){case kt.HIGHLIGHT_COLOR:Ft._defaultColor=i;break;case kt.HIGHLIGHT_THICKNESS:Ft._defaultThickness=i;break}}translateInPage(e,i){}get toolbarPosition(){return s(this,Vc)}get commentButtonPosition(){return s(this,Wc)}updateParams(e,i){switch(e){case kt.HIGHLIGHT_COLOR:S(this,wt,Mw).call(this,i);break;case kt.HIGHLIGHT_THICKNESS:S(this,wt,Rw).call(this,i);break}}static get defaultPropertiesToUpdate(){return[[kt.HIGHLIGHT_COLOR,Ft._defaultColor],[kt.HIGHLIGHT_THICKNESS,Ft._defaultThickness]]}get propertiesToUpdate(){return[[kt.HIGHLIGHT_COLOR,this.color||Ft._defaultColor],[kt.HIGHLIGHT_THICKNESS,s(this,In)||Ft._defaultThickness],[kt.HIGHLIGHT_FREE,s(this,ci)]]}onUpdatedColor(){var e,i;(e=this.parent)==null||e.drawLayer.updateProperties(s(this,gn),{root:{fill:this.color,"fill-opacity":this.opacity}}),(i=s(this,Au))==null||i.updateColor(this.color),super.onUpdatedColor()}get toolbarButtons(){return this._uiManager.highlightColors?[["colorPicker",g(this,Au,new Of({editor:this}))]]:super.toolbarButtons}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(S(this,wt,Up).call(this))}getBaseTranslation(){return[0,0]}getRect(e,i){return super.getRect(e,i,S(this,wt,Up).call(this))}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){S(this,wt,_b).call(this),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(S(this,wt,gl).call(this),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let i=!1;this.parent&&!e?S(this,wt,_b).call(this):e&&(S(this,wt,gl).call(this,e),i=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),this.show(this._isVisible),i&&this.select()}rotate(e){var r,o,l;const{drawLayer:i}=this.parent;let n;s(this,ci)?(e=(e-this.rotation+360)%360,n=S(r=Ft,Ln,uh).call(r,s(this,pn).box,e)):n=S(o=Ft,Ln,uh).call(o,[this.x,this.y,this.width,this.height],e),i.updateProperties(s(this,gn),{bbox:n,root:{"data-main-rotation":e}}),i.updateProperties(s(this,yi),{bbox:S(l=Ft,Ln,uh).call(l,s(this,zi).box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();s(this,Gc)&&(e.setAttribute("aria-label",s(this,Gc)),e.setAttribute("role","mark")),s(this,ci)?e.classList.add("free"):this.div.addEventListener("keydown",S(this,wt,Ow).bind(this),{signal:this._uiManager._signal});const i=g(this,Xa,document.createElement("div"));return e.append(i),i.setAttribute("aria-hidden","true"),i.className="internal",i.style.clipPath=s(this,Ya),this.setDims(),v0(this,s(this,Xa),["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(s(this,yi),{rootClass:{hovered:!0}})}pointerleave(){var e;this.isSelected||(e=this.parent)==null||e.drawLayer.updateProperties(s(this,yi),{rootClass:{hovered:!1}})}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:S(this,wt,zp).call(this,!0);break;case 1:case 3:S(this,wt,zp).call(this,!1);break}}select(){var e;super.select(),s(this,yi)&&((e=this.parent)==null||e.drawLayer.updateProperties(s(this,yi),{rootClass:{hovered:!1,selected:!0}}))}unselect(){var e;super.unselect(),s(this,yi)&&((e=this.parent)==null||e.drawLayer.updateProperties(s(this,yi),{rootClass:{selected:!1}}),s(this,ci)||S(this,wt,zp).call(this,!1))}get _mustFixPosition(){return!s(this,ci)}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(s(this,gn),{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(s(this,yi),{rootClass:{hidden:!e}}))}static startHighlighting(e,i,{target:n,x:r,y:o}){const{x:l,y:c,width:h,height:d}=n.getBoundingClientRect(),u=new AbortController,f=e.combinedSignal(u),p=m=>{u.abort(),S(this,Ln,Fw).call(this,e,m)};window.addEventListener("blur",p,{signal:f}),window.addEventListener("pointerup",p,{signal:f}),window.addEventListener("pointerdown",Ee,{capture:!0,passive:!1,signal:f}),window.addEventListener("contextmenu",wn,{signal:f}),n.addEventListener("pointermove",S(this,Ln,Nw).bind(this,e),{signal:f}),this._freeHighlight=new mm({x:r,y:o},[l,c,h,d],e.scale,this._defaultThickness/2,i,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0)}static async deserialize(e,i,n){var b,v,w,_;let r=null;if(e instanceof rv){const{data:{quadPoints:A,rect:C,rotation:x,id:P,color:R,opacity:N,popupRef:z,richText:H,contentsObj:I,creationDate:ct,modificationDate:j},parent:{page:{pageNumber:K}}}=e;r=e={annotationType:mt.HIGHLIGHT,color:Array.from(R),opacity:N,quadPoints:A,boxes:null,pageIndex:K-1,rect:C.slice(0),rotation:x,annotationElementId:P,id:P,deleted:!1,popupRef:z,richText:H,comment:(I==null?void 0:I.str)||null,creationDate:ct,modificationDate:j}}else if(e instanceof um){const{data:{inkLists:A,rect:C,rotation:x,id:P,color:R,borderStyle:{rawWidth:N},popupRef:z,richText:H,contentsObj:I,creationDate:ct,modificationDate:j},parent:{page:{pageNumber:K}}}=e;r=e={annotationType:mt.HIGHLIGHT,color:Array.from(R),thickness:N,inkLists:A,boxes:null,pageIndex:K-1,rect:C.slice(0),rotation:x,annotationElementId:P,id:P,deleted:!1,popupRef:z,richText:H,comment:(I==null?void 0:I.str)||null,creationDate:ct,modificationDate:j}}const{color:o,quadPoints:l,inkLists:c,opacity:h}=e,d=await super.deserialize(e,i,n);d.color=Z.makeHexColor(...o),d.opacity=h||1,c&&g(d,In,e.thickness),d._initialData=r,e.comment&&d.setCommentData(e);const[u,f]=d.pageDimensions,[p,m]=d.pageTranslation;if(l){const A=g(d,br,[]);for(let C=0;C<l.length;C+=8)A.push({x:(l[C]-p)/u,y:1-(l[C+1]-m)/f,width:(l[C+2]-l[C])/u,height:(l[C+1]-l[C+5])/f});S(b=d,wt,Cb).call(b),S(v=d,wt,gl).call(v),d.rotate(d.rotation)}else if(c){g(d,ci,!0);const A=c[0],C={x:A[0]-p,y:f-(A[1]-m)},x=new mm(C,[0,0,u,f],1,s(d,In)/2,!0,.001);for(let N=0,z=A.length;N<z;N+=2)C.x=A[N]-p,C.y=f-(A[N+1]-m),x.add(C);const{id:P,clipPathId:R}=i.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:d.color,"fill-opacity":d._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:x.toSVGPath()}},!0,!0);S(w=d,wt,jp).call(w,{highlightOutlines:x.getOutlines(),highlightId:P,clipPathId:R}),S(_=d,wt,gl).call(_),d.rotate(d.parentRotation)}return d}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const i=le._colorManager.convert(this._uiManager.getNonHCMColor(this.color)),n=super.serialize(e);return Object.assign(n,{color:i,opacity:this.opacity,thickness:s(this,In),quadPoints:S(this,wt,Iw).call(this),outlines:S(this,wt,Lw).call(this,n.rect)}),this.addComment(n),this.annotationElementId&&!S(this,wt,Bw).call(this,n)?null:(n.id=this.annotationElementId,n)}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}static canCreateNewEmptyEditor(){return!1}};$c=new WeakMap,wu=new WeakMap,br=new WeakMap,Ya=new WeakMap,Au=new WeakMap,zi=new WeakMap,Su=new WeakMap,Eu=new WeakMap,Xa=new WeakMap,pn=new WeakMap,gn=new WeakMap,ci=new WeakMap,Wc=new WeakMap,Vc=new WeakMap,yi=new WeakMap,Gc=new WeakMap,In=new WeakMap,xu=new WeakMap,wt=new WeakSet,Cb=function(){const e=new gm(s(this,br),.001);g(this,pn,e.getOutlines()),[this.x,this.y,this.width,this.height]=s(this,pn).box;const i=new gm(s(this,br),.0025,.001,this._uiManager.direction==="ltr");g(this,zi,i.getOutlines());const{firstPoint:n}=s(this,pn);g(this,Wc,[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]);const{lastPoint:r}=s(this,zi);g(this,Vc,[(r[0]-this.x)/this.width,(r[1]-this.y)/this.height])},jp=function({highlightOutlines:e,highlightId:i,clipPathId:n}){var f,p;if(g(this,pn,e),g(this,zi,e.getNewOutline(s(this,In)/2+1.5,.0025)),i>=0)g(this,gn,i),g(this,Ya,n),this.parent.drawLayer.finalizeDraw(i,{bbox:e.box,path:{d:e.toSVGPath()}}),g(this,yi,this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:s(this,zi).box,path:{d:s(this,zi).toSVGPath()}},!0));else if(this.parent){const m=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(s(this,gn),{bbox:S(f=Ft,Ln,uh).call(f,s(this,pn).box,(m-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(s(this,yi),{bbox:S(p=Ft,Ln,uh).call(p,s(this,zi).box,m),path:{d:s(this,zi).toSVGPath()}})}const[o,l,c,h]=e.box;switch(this.rotation){case 0:this.x=o,this.y=l,this.width=c,this.height=h;break;case 90:{const[m,b]=this.parentDimensions;this.x=l,this.y=1-o,this.width=c*b/m,this.height=h*m/b;break}case 180:this.x=1-o,this.y=1-l,this.width=c,this.height=h;break;case 270:{const[m,b]=this.parentDimensions;this.x=1-l,this.y=o,this.width=c*b/m,this.height=h*m/b;break}}const{firstPoint:d}=e;g(this,Wc,[(d[0]-o)/c,(d[1]-l)/h]);const{lastPoint:u}=s(this,zi);g(this,Vc,[(u[0]-o)/c,(u[1]-l)/h])},Mw=function(e){const i=(o,l)=>{this.color=o,this.opacity=l,this.onUpdatedColor()},n=this.color,r=this.opacity;this.addCommands({cmd:i.bind(this,e,Ft._defaultOpacity),undo:i.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:kt.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.getNonHCMColorName(e)},!0)},Rw=function(e){const i=s(this,In),n=r=>{g(this,In,r),S(this,wt,Dw).call(this,r)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,i),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:kt.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)},Dw=function(e){s(this,ci)&&(S(this,wt,jp).call(this,{highlightOutlines:s(this,pn).getNewOutline(e/2)}),this.fixAndSetPosition(),this.setDims())},_b=function(){s(this,gn)===null||!this.parent||(this.parent.drawLayer.remove(s(this,gn)),g(this,gn,null),this.parent.drawLayer.remove(s(this,yi)),g(this,yi,null))},gl=function(e=this.parent){s(this,gn)===null&&({id:Ge(this,gn)._,clipPathId:Ge(this,Ya)._}=e.drawLayer.draw({bbox:s(this,pn).box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.opacity},rootClass:{highlight:!0,free:s(this,ci)},path:{d:s(this,pn).toSVGPath()}},!1,!0),g(this,yi,e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:s(this,ci)},bbox:s(this,zi).box,path:{d:s(this,zi).toSVGPath()}},s(this,ci))),s(this,Xa)&&(s(this,Xa).style.clipPath=s(this,Ya)))},Ln=new WeakSet,uh=function([e,i,n,r],o){switch(o){case 90:return[1-i-r,e,r,n];case 180:return[1-e-n,1-i-r,n,r];case 270:return[i,1-e-n,r,n]}return[e,i,n,r]},Ow=function(e){Ft._keyboardManager.exec(this,e)},zp=function(e){if(!s(this,$c))return;const i=window.getSelection();e?i.setPosition(s(this,$c),s(this,wu)):i.setPosition(s(this,Su),s(this,Eu))},Up=function(){return s(this,ci)?this.rotation:0},Iw=function(){if(s(this,ci))return null;const[e,i]=this.pageDimensions,[n,r]=this.pageTranslation,o=s(this,br),l=new Float32Array(o.length*8);let c=0;for(const{x:h,y:d,width:u,height:f}of o){const p=h*e+n,m=(1-d)*i+r;l[c]=l[c+4]=p,l[c+1]=l[c+3]=m,l[c+2]=l[c+6]=p+u*e,l[c+5]=l[c+7]=m-f*i,c+=8}return l},Lw=function(e){return s(this,pn).serialize(e,S(this,wt,Up).call(this))},Nw=function(e,i){this._freeHighlight.add(i)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})},Fw=function(e,i){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(i,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""},Bw=function(e){const{color:i}=this._initialData;return this.hasEditedComment||e.color.some((n,r)=>n!==i[r])},y(Ft,Ln),W(Ft,"_defaultColor",null),W(Ft,"_defaultOpacity",1),W(Ft,"_defaultThickness",12),W(Ft,"_type","highlight"),W(Ft,"_editorType",mt.HIGHLIGHT),W(Ft,"_freeHighlightId",-1),W(Ft,"_freeHighlight",null),W(Ft,"_freeHighlightClipId","");let Bf=Ft;class lv{constructor(){y(this,qa,Object.create(null))}updateProperty(t,e){this[t]=e,this.updateSVGProperty(t,e)}updateProperties(t){if(t)for(const[e,i]of Object.entries(t))e.startsWith("_")||this.updateProperty(e,i)}updateSVGProperty(t,e){s(this,qa)[t]=e}toSVGProperties(){const t=s(this,qa);return g(this,qa,Object.create(null)),{root:t}}reset(){g(this,qa,Object.create(null))}updateAll(t=this){this.updateProperties(t)}clone(){ne("Not implemented")}}qa=new WeakMap;const Pt=class Pt extends le{constructor(e){super(e);y(this,Dt);y(this,mn,null);y(this,Yc);W(this,"_colorPicker",null);W(this,"_drawId",null);g(this,Yc,e.mustBeCommitted||!1),this._addOutlines(e)}onUpdatedColor(){var e;(e=this._colorPicker)==null||e.update(this.color),super.onUpdatedColor()}_addOutlines(e){e.drawOutlines&&(S(this,Dt,Tb).call(this,e),S(this,Dt,qu).call(this))}static _mergeSVGProperties(e,i){const n=new Set(Object.keys(e));for(const[r,o]of Object.entries(i))n.has(r)?Object.assign(e[r],o):e[r]=o;return e}static getDefaultDrawingOptions(e){ne("Not implemented")}static get typesMap(){ne("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,i){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,i),this._currentParent&&(s(Pt,Ke).updateProperty(n,i),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,i){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,i)}static get defaultPropertiesToUpdate(){const e=[],i=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,i[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:i}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,i[r]]);return e}_updateProperty(e,i,n){const r=this._drawingOptions,o=r[i],l=c=>{var d;r.updateProperty(i,c);const h=s(this,mn).updateProperty(i,c);h&&S(this,Dt,Ku).call(this,h),(d=this.parent)==null||d.drawLayer.updateProperties(this._drawId,r.toSVGProperties()),e===this.colorType&&this.onUpdatedColor()};this.addCommands({cmd:l.bind(this,n),undo:l.bind(this,o),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Pt._mergeSVGProperties(s(this,mn).getPathResizingSVGProperties(S(this,Dt,Hp).call(this)),{bbox:S(this,Dt,fh).call(this)}))}_onResized(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Pt._mergeSVGProperties(s(this,mn).getPathResizedSVGProperties(S(this,Dt,Hp).call(this)),{bbox:S(this,Dt,fh).call(this)}))}_onTranslating(e,i){var n;(n=this.parent)==null||n.drawLayer.updateProperties(this._drawId,{bbox:S(this,Dt,fh).call(this)})}_onTranslated(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,Pt._mergeSVGProperties(s(this,mn).getPathTranslatedSVGProperties(S(this,Dt,Hp).call(this),this.parentDimensions),{bbox:S(this,Dt,fh).call(this)}))}_onStartDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){var e;(e=this.parent)==null||e.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,s(this,Yc)&&(g(this,Yc,!1),this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){S(this,Dt,kb).call(this),super.remove()}rebuild(){this.parent&&(super.rebuild(),this.div!==null&&(S(this,Dt,qu).call(this),S(this,Dt,Ku).call(this,s(this,mn).box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){var n;let i=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),S(this,Dt,kb).call(this)):e&&(this._uiManager.addShouldRescale(this),S(this,Dt,qu).call(this,e),i=!this.parent&&((n=this.div)==null?void 0:n.classList.contains("selectedEditor"))),super.setParent(e),i&&this.select()}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,Pt._mergeSVGProperties({bbox:S(this,Dt,fh).call(this)},s(this,mn).updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&S(this,Dt,Ku).call(this,s(this,mn).updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;let e,i;this._isCopy&&(e=this.x,i=this.y);const n=super.render();n.classList.add("draw");const r=document.createElement("div");return n.append(r),r.setAttribute("aria-hidden","true"),r.className="internal",this.setDims(),this._uiManager.addShouldRescale(this),this.disableEditing(),this._isCopy&&this._moveAfterPaste(e,i),n}static createDrawerInstance(e,i,n,r,o){ne("Not implemented")}static startDrawing(e,i,n,r){var v;const{target:o,offsetX:l,offsetY:c,pointerId:h,pointerType:d}=r;if(fi.isInitializedAndDifferentPointerType(d))return;const{viewport:{rotation:u}}=e,{width:f,height:p}=o.getBoundingClientRect(),m=g(Pt,Ka,new AbortController),b=e.combinedSignal(m);if(fi.setPointer(d,h),window.addEventListener("pointerup",w=>{fi.isSamePointerIdOrRemove(w.pointerId)&&this._endDraw(w)},{signal:b}),window.addEventListener("pointercancel",w=>{fi.isSamePointerIdOrRemove(w.pointerId)&&this._currentParent.endDrawingSession()},{signal:b}),window.addEventListener("pointerdown",w=>{fi.isSamePointerType(w.pointerType)&&(fi.initializeAndAddPointerId(w.pointerId),s(Pt,Ke).isCancellable()&&(s(Pt,Ke).removeLastElement(),s(Pt,Ke).isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))},{capture:!0,passive:!1,signal:b}),window.addEventListener("contextmenu",wn,{signal:b}),o.addEventListener("pointermove",this._drawMove.bind(this),{signal:b}),o.addEventListener("touchmove",w=>{fi.isSameTimeStamp(w.timeStamp)&&Ee(w)},{signal:b}),e.toggleDrawing(),(v=i._editorUndoBar)==null||v.hide(),s(Pt,Ke)){e.drawLayer.updateProperties(this._currentDrawId,s(Pt,Ke).startNew(l,c,f,p,u));return}i.updateUIForDefaultProperties(this),g(Pt,Ke,this.createDrawerInstance(l,c,f,p,u)),g(Pt,Ja,this.getDefaultDrawingOptions()),this._currentParent=e,{id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(s(Pt,Ja).toSVGProperties(),s(Pt,Ke).defaultSVGProperties),!0,!1)}static _drawMove(e){if(fi.isSameTimeStamp(e.timeStamp),!s(Pt,Ke))return;const{offsetX:i,offsetY:n,pointerId:r}=e;if(fi.isSamePointerId(r)){if(fi.isUsingMultiplePointers()){this._endDraw(e);return}this._currentParent.drawLayer.updateProperties(this._currentDrawId,s(Pt,Ke).add(i,n)),fi.setTimeStamp(e.timeStamp),Ee(e)}}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,g(Pt,Ke,null),g(Pt,Ja,null),fi.clearTimeStamp()),s(Pt,Ka)&&(s(Pt,Ka).abort(),g(Pt,Ka,null),fi.clearPointerIds())}static _endDraw(e){const i=this._currentParent;if(i){if(i.toggleDrawing(!0),this._cleanup(!1),(e==null?void 0:e.target)===i.div&&i.drawLayer.updateProperties(this._currentDrawId,s(Pt,Ke).end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const n=s(Pt,Ke),r=this._currentDrawId,o=n.getLastElement();i.addCommands({cmd:()=>{i.drawLayer.updateProperties(r,n.setLastElement(o))},undo:()=>{i.drawLayer.updateProperties(r,n.removeLastElement())},mustExec:!1,type:kt.DRAW_STEP});return}this.endDrawing(!1)}}static endDrawing(e){const i=this._currentParent;if(!i)return null;if(i.toggleDrawing(!0),i.cleanUndoStack(kt.DRAW_STEP),!s(Pt,Ke).isEmpty()){const{pageDimensions:[n,r],scale:o}=i,l=i.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:s(Pt,Ke).getOutlines(n*o,r*o,o,this._INNER_MARGIN),drawingOptions:s(Pt,Ja),mustBeCommitted:!e});return this._cleanup(!0),l}return i.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,i,n,r,o,l){ne("Not implemented")}static async deserialize(e,i,n){var u,f;const{rawDims:{pageWidth:r,pageHeight:o,pageX:l,pageY:c}}=i.viewport,h=this.deserializeDraw(l,c,r,o,this._INNER_MARGIN,e),d=await super.deserialize(e,i,n);return d.createDrawingOptions(e),S(u=d,Dt,Tb).call(u,{drawOutlines:h}),S(f=d,Dt,qu).call(f),d.onScaleChanging(),d.rotate(),d}serializeDraw(e){const[i,n]=this.pageTranslation,[r,o]=this.pageDimensions;return s(this,mn).serialize([i,n,r,o],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getPDFRect()}),null}static canCreateNewEmptyEditor(){return!1}};mn=new WeakMap,Yc=new WeakMap,Ke=new WeakMap,Ka=new WeakMap,Ja=new WeakMap,Dt=new WeakSet,Tb=function({drawOutlines:e,drawId:i,drawingOptions:n}){g(this,mn,e),this._drawingOptions||(this._drawingOptions=n),this.annotationElementId||this._uiManager.a11yAlert(`pdfjs-editor-${this.editorType}-added-alert`),i>=0?(this._drawId=i,this.parent.drawLayer.finalizeDraw(i,e.defaultProperties)):this._drawId=S(this,Dt,Pb).call(this,e,this.parent),S(this,Dt,Ku).call(this,e.box)},Pb=function(e,i){const{id:n}=i.drawLayer.draw(Pt._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n},kb=function(){this._drawId===null||!this.parent||(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())},qu=function(e=this.parent){if(!(this._drawId!==null&&this.parent===e)){if(this._drawId!==null){this.parent.drawLayer.updateParent(this._drawId,e.drawLayer);return}this._drawingOptions.updateAll(),this._drawId=S(this,Dt,Pb).call(this,s(this,mn),e)}},jw=function([e,i,n,r]){const{parentDimensions:[o,l],rotation:c}=this;switch(c){case 90:return[i,1-e,n*(l/o),r*(o/l)];case 180:return[1-e,1-i,n,r];case 270:return[1-i,e,n*(l/o),r*(o/l)];default:return[e,i,n,r]}},Hp=function(){const{x:e,y:i,width:n,height:r,parentDimensions:[o,l],rotation:c}=this;switch(c){case 90:return[1-i,e,n*(o/l),r*(l/o)];case 180:return[1-e,1-i,n,r];case 270:return[i,1-e,n*(o/l),r*(l/o)];default:return[e,i,n,r]}},Ku=function(e){[this.x,this.y,this.width,this.height]=S(this,Dt,jw).call(this,e),this.div&&(this.fixAndSetPosition(),this.setDims()),this._onResized()},fh=function(){const{x:e,y:i,width:n,height:r,rotation:o,parentRotation:l,parentDimensions:[c,h]}=this;switch((o*4+l)/90){case 1:return[1-i-r,e,r,n];case 2:return[1-e-n,1-i-r,n,r];case 3:return[i,1-e-n,r,n];case 4:return[e,i-n*(c/h),r*(h/c),n*(c/h)];case 5:return[1-i,e,n*(c/h),r*(h/c)];case 6:return[1-e-r*(h/c),1-i,r*(h/c),n*(c/h)];case 7:return[i-n*(c/h),1-e-r*(h/c),n*(c/h),r*(h/c)];case 8:return[e-n,i-r,n,r];case 9:return[1-i,e-n,r,n];case 10:return[1-e,1-i,n,r];case 11:return[i-r,1-e,r,n];case 12:return[e-r*(h/c),i,r*(h/c),n*(c/h)];case 13:return[1-i-n*(c/h),e-r*(h/c),n*(c/h),r*(h/c)];case 14:return[1-e,1-i-n*(c/h),r*(h/c),n*(c/h)];case 15:return[i,1-e,n*(c/h),r*(h/c)];default:return[e,i,n,r]}},W(Pt,"_currentDrawId",-1),W(Pt,"_currentParent",null),y(Pt,Ke,null),y(Pt,Ka,null),y(Pt,Ja,null),W(Pt,"_INNER_MARGIN",3);let jf=Pt;class Dx{constructor(t,e,i,n,r,o){y(this,qc);y(this,Es,new Float64Array(6));y(this,Je);y(this,Ze);y(this,Za);y(this,Xc);y(this,Ti);y(this,hi,"");y(this,Nn,0);y(this,Qa,new Nh);y(this,tl);y(this,el);g(this,tl,i),g(this,el,n),g(this,Za,r),g(this,Xc,o),[t,e]=S(this,qc,$p).call(this,t,e);const l=g(this,Je,[NaN,NaN,NaN,NaN,t,e]);g(this,Ti,[t,e]),g(this,Ze,[{line:l,points:s(this,Ti)}]),s(this,Es).set(l,0)}updateProperty(t,e){t==="stroke-width"&&g(this,Xc,e)}isEmpty(){return!s(this,Ze)||s(this,Ze).length===0}isCancellable(){return s(this,Ti).length<=10}add(t,e){[t,e]=S(this,qc,$p).call(this,t,e);const[i,n,r,o]=s(this,Es).subarray(2,6),l=t-r,c=e-o;return Math.hypot(s(this,tl)*l,s(this,el)*c)<=2?null:(s(this,Ti).push(t,e),isNaN(i)?(s(this,Es).set([r,o,t,e],2),s(this,Je).push(NaN,NaN,NaN,NaN,t,e),{path:{d:this.toSVGPath()}}):(isNaN(s(this,Es)[0])&&s(this,Je).splice(6,6),s(this,Es).set([i,n,r,o,t,e],0),s(this,Je).push(...nt.createBezierPoints(i,n,r,o,t,e)),{path:{d:this.toSVGPath()}}))}end(t,e){const i=this.add(t,e);return i||(s(this,Ti).length===2?{path:{d:this.toSVGPath()}}:null)}startNew(t,e,i,n,r){g(this,tl,i),g(this,el,n),g(this,Za,r),[t,e]=S(this,qc,$p).call(this,t,e);const o=g(this,Je,[NaN,NaN,NaN,NaN,t,e]);g(this,Ti,[t,e]);const l=s(this,Ze).at(-1);return l&&(l.line=new Float32Array(l.line),l.points=new Float32Array(l.points)),s(this,Ze).push({line:o,points:s(this,Ti)}),s(this,Es).set(o,0),g(this,Nn,0),this.toSVGPath(),null}getLastElement(){return s(this,Ze).at(-1)}setLastElement(t){return s(this,Ze)?(s(this,Ze).push(t),g(this,Je,t.line),g(this,Ti,t.points),g(this,Nn,0),{path:{d:this.toSVGPath()}}):s(this,Qa).setLastElement(t)}removeLastElement(){if(!s(this,Ze))return s(this,Qa).removeLastElement();s(this,Ze).pop(),g(this,hi,"");for(let t=0,e=s(this,Ze).length;t<e;t++){const{line:i,points:n}=s(this,Ze)[t];g(this,Je,i),g(this,Ti,n),g(this,Nn,0),this.toSVGPath()}return{path:{d:s(this,hi)}}}toSVGPath(){const t=nt.svgRound(s(this,Je)[4]),e=nt.svgRound(s(this,Je)[5]);if(s(this,Ti).length===2)return g(this,hi,`${s(this,hi)} M ${t} ${e} Z`),s(this,hi);if(s(this,Ti).length<=6){const n=s(this,hi).lastIndexOf("M");g(this,hi,`${s(this,hi).slice(0,n)} M ${t} ${e}`),g(this,Nn,6)}if(s(this,Ti).length===4){const n=nt.svgRound(s(this,Je)[10]),r=nt.svgRound(s(this,Je)[11]);return g(this,hi,`${s(this,hi)} L ${n} ${r}`),g(this,Nn,12),s(this,hi)}const i=[];s(this,Nn)===0&&(i.push(`M ${t} ${e}`),g(this,Nn,6));for(let n=s(this,Nn),r=s(this,Je).length;n<r;n+=6){const[o,l,c,h,d,u]=s(this,Je).slice(n,n+6).map(nt.svgRound);i.push(`C${o} ${l} ${c} ${h} ${d} ${u}`)}return g(this,hi,s(this,hi)+i.join(" ")),g(this,Nn,s(this,Je).length),s(this,hi)}getOutlines(t,e,i,n){const r=s(this,Ze).at(-1);return r.line=new Float32Array(r.line),r.points=new Float32Array(r.points),s(this,Qa).build(s(this,Ze),t,e,i,s(this,Za),s(this,Xc),n),g(this,Es,null),g(this,Je,null),g(this,Ze,null),g(this,hi,null),s(this,Qa)}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}Es=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Za=new WeakMap,Xc=new WeakMap,Ti=new WeakMap,hi=new WeakMap,Nn=new WeakMap,Qa=new WeakMap,tl=new WeakMap,el=new WeakMap,qc=new WeakSet,$p=function(t,e){return nt._normalizePoint(t,e,s(this,tl),s(this,el),s(this,Za))};class Nh extends nt{constructor(){super(...arguments);y(this,di);y(this,Pi);y(this,Cu,0);y(this,_u);y(this,bn);y(this,xs);y(this,Cs);y(this,Kc);y(this,Jc);y(this,il)}build(e,i,n,r,o,l,c){g(this,xs,i),g(this,Cs,n),g(this,Kc,r),g(this,Jc,o),g(this,il,l),g(this,_u,c??0),g(this,bn,e),S(this,di,Uw).call(this)}get thickness(){return s(this,il)}setLastElement(e){return s(this,bn).push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return s(this,bn).pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:i}of s(this,bn)){if(e.push(`M${nt.svgRound(i[4])} ${nt.svgRound(i[5])}`),i.length===6){e.push("Z");continue}if(i.length===12&&isNaN(i[6])){e.push(`L${nt.svgRound(i[10])} ${nt.svgRound(i[11])}`);continue}for(let n=6,r=i.length;n<r;n+=6){const[o,l,c,h,d,u]=i.subarray(n,n+6).map(nt.svgRound);e.push(`C${o} ${l} ${c} ${h} ${d} ${u}`)}}return e.join("")}serialize([e,i,n,r],o){const l=[],c=[],[h,d,u,f]=S(this,di,zw).call(this);let p,m,b,v,w,_,A,C,x;switch(s(this,Jc)){case 0:x=nt._rescale,p=e,m=i+r,b=n,v=-r,w=e+h*n,_=i+(1-d-f)*r,A=e+(h+u)*n,C=i+(1-d)*r;break;case 90:x=nt._rescaleAndSwap,p=e,m=i,b=n,v=r,w=e+d*n,_=i+h*r,A=e+(d+f)*n,C=i+(h+u)*r;break;case 180:x=nt._rescale,p=e+n,m=i,b=-n,v=r,w=e+(1-h-u)*n,_=i+d*r,A=e+(1-h)*n,C=i+(d+f)*r;break;case 270:x=nt._rescaleAndSwap,p=e+n,m=i+r,b=-n,v=-r,w=e+(1-d-f)*n,_=i+(1-h-u)*r,A=e+(1-d)*n,C=i+(1-h)*r;break}for(const{line:P,points:R}of s(this,bn))l.push(x(P,p,m,b,v,o?new Array(P.length):null)),c.push(x(R,p,m,b,v,o?new Array(R.length):null));return{lines:l,points:c,rect:[w,_,A,C]}}static deserialize(e,i,n,r,o,{paths:{lines:l,points:c},rotation:h,thickness:d}){const u=[];let f,p,m,b,v;switch(h){case 0:v=nt._rescale,f=-e/n,p=i/r+1,m=1/n,b=-1/r;break;case 90:v=nt._rescaleAndSwap,f=-i/r,p=-e/n,m=1/r,b=1/n;break;case 180:v=nt._rescale,f=e/n+1,p=-i/r,m=-1/n,b=1/r;break;case 270:v=nt._rescaleAndSwap,f=i/r+1,p=e/n+1,m=-1/r,b=-1/n;break}if(!l){l=[];for(const _ of c){const A=_.length;if(A===2){l.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1]]));continue}if(A===4){l.push(new Float32Array([NaN,NaN,NaN,NaN,_[0],_[1],NaN,NaN,NaN,NaN,_[2],_[3]]));continue}const C=new Float32Array(3*(A-2));l.push(C);let[x,P,R,N]=_.subarray(0,4);C.set([NaN,NaN,NaN,NaN,x,P],0);for(let z=4;z<A;z+=2){const H=_[z],I=_[z+1];C.set(nt.createBezierPoints(x,P,R,N,H,I),(z-2)*3),[x,P,R,N]=[R,N,H,I]}}}for(let _=0,A=l.length;_<A;_++)u.push({line:v(l[_].map(C=>C??NaN),f,p,m,b),points:v(c[_].map(C=>C??NaN),f,p,m,b)});const w=new this.prototype.constructor;return w.build(u,n,r,1,h,d,o),w}get box(){return s(this,Pi)}updateProperty(e,i){return e==="stroke-width"?S(this,di,Hw).call(this,i):null}updateParentDimensions([e,i],n){const[r,o]=S(this,di,Tr).call(this);g(this,xs,e),g(this,Cs,i),g(this,Kc,n);const[l,c]=S(this,di,Tr).call(this),h=l-r,d=c-o,u=s(this,Pi);return u[0]-=h,u[1]-=d,u[2]+=2*h,u[3]+=2*d,u}updateRotation(e){return g(this,Cu,e),{path:{transform:this.rotationTransform}}}get viewBox(){return s(this,Pi).map(nt.svgRound).join(" ")}get defaultProperties(){const[e,i]=s(this,Pi);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nt.svgRound(e)} ${nt.svgRound(i)}`}}}get rotationTransform(){const[,,e,i]=s(this,Pi);let n=0,r=0,o=0,l=0,c=0,h=0;switch(s(this,Cu)){case 90:r=i/e,o=-e/i,c=e;break;case 180:n=-1,l=-1,c=e,h=i;break;case 270:r=-i/e,o=e/i,h=i;break;default:return""}return`matrix(${n} ${r} ${o} ${l} ${nt.svgRound(c)} ${nt.svgRound(h)})`}getPathResizingSVGProperties([e,i,n,r]){const[o,l]=S(this,di,Tr).call(this),[c,h,d,u]=s(this,Pi);if(Math.abs(d-o)<=nt.PRECISION||Math.abs(u-l)<=nt.PRECISION){const v=e+n/2-(c+d/2),w=i+r/2-(h+u/2);return{path:{"transform-origin":`${nt.svgRound(e)} ${nt.svgRound(i)}`,transform:`${this.rotationTransform} translate(${v} ${w})`}}}const f=(n-2*o)/(d-2*o),p=(r-2*l)/(u-2*l),m=d/n,b=u/r;return{path:{"transform-origin":`${nt.svgRound(c)} ${nt.svgRound(h)}`,transform:`${this.rotationTransform} scale(${m} ${b}) translate(${nt.svgRound(o)} ${nt.svgRound(l)}) scale(${f} ${p}) translate(${nt.svgRound(-o)} ${nt.svgRound(-l)})`}}}getPathResizedSVGProperties([e,i,n,r]){const[o,l]=S(this,di,Tr).call(this),c=s(this,Pi),[h,d,u,f]=c;if(c[0]=e,c[1]=i,c[2]=n,c[3]=r,Math.abs(u-o)<=nt.PRECISION||Math.abs(f-l)<=nt.PRECISION){const w=e+n/2-(h+u/2),_=i+r/2-(d+f/2);for(const{line:A,points:C}of s(this,bn))nt._translate(A,w,_,A),nt._translate(C,w,_,C);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nt.svgRound(e)} ${nt.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const p=(n-2*o)/(u-2*o),m=(r-2*l)/(f-2*l),b=-p*(h+o)+e+o,v=-m*(d+l)+i+l;if(p!==1||m!==1||b!==0||v!==0)for(const{line:w,points:_}of s(this,bn))nt._rescale(w,b,v,p,m,w),nt._rescale(_,b,v,p,m,_);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${nt.svgRound(e)} ${nt.svgRound(i)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,i],n){const[r,o]=n,l=s(this,Pi),c=e-l[0],h=i-l[1];if(s(this,xs)===r&&s(this,Cs)===o)for(const{line:d,points:u}of s(this,bn))nt._translate(d,c,h,d),nt._translate(u,c,h,u);else{const d=s(this,xs)/r,u=s(this,Cs)/o;g(this,xs,r),g(this,Cs,o);for(const{line:f,points:p}of s(this,bn))nt._rescale(f,c,h,d,u,f),nt._rescale(p,c,h,d,u,p);l[2]*=d,l[3]*=u}return l[0]=e,l[1]=i,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${nt.svgRound(e)} ${nt.svgRound(i)}`}}}get defaultSVGProperties(){const e=s(this,Pi);return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${nt.svgRound(e[0])} ${nt.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}Pi=new WeakMap,Cu=new WeakMap,_u=new WeakMap,bn=new WeakMap,xs=new WeakMap,Cs=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,il=new WeakMap,di=new WeakSet,Tr=function(e=s(this,il)){const i=s(this,_u)+e/2*s(this,Kc);return s(this,Jc)%180===0?[i/s(this,xs),i/s(this,Cs)]:[i/s(this,Cs),i/s(this,xs)]},zw=function(){const[e,i,n,r]=s(this,Pi),[o,l]=S(this,di,Tr).call(this,0);return[e+o,i+l,n-2*o,r-2*l]},Uw=function(){const e=g(this,Pi,new Float32Array([1/0,1/0,-1/0,-1/0]));for(const{line:r}of s(this,bn)){if(r.length<=12){for(let c=4,h=r.length;c<h;c+=6)Z.pointBoundingBox(r[c],r[c+1],e);continue}let o=r[4],l=r[5];for(let c=6,h=r.length;c<h;c+=6){const[d,u,f,p,m,b]=r.subarray(c,c+6);Z.bezierBoundingBox(o,l,d,u,f,p,m,b,e),o=m,l=b}}const[i,n]=S(this,di,Tr).call(this);e[0]=Ei(e[0]-i,0,1),e[1]=Ei(e[1]-n,0,1),e[2]=Ei(e[2]+i,0,1),e[3]=Ei(e[3]+n,0,1),e[2]-=e[0],e[3]-=e[1]},Hw=function(e){const[i,n]=S(this,di,Tr).call(this);g(this,il,e);const[r,o]=S(this,di,Tr).call(this),[l,c]=[r-i,o-n],h=s(this,Pi);return h[0]-=l,h[1]-=c,h[2]+=2*l,h[3]+=2*c,h};class zf extends lv{constructor(t){super(),this._viewParameters=t,super.updateProperties({fill:"none",stroke:le._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(t,e){t==="stroke-width"&&(e??(e=this["stroke-width"]),e*=this._viewParameters.realScale),super.updateSVGProperty(t,e)}clone(){const t=new zf(this._viewParameters);return t.updateAll(this),t}}const Zc=class Zc extends jf{constructor(e){super({...e,name:"inkEditor"});y(this,rp);this._willKeepAspectRatio=!0,this.defaultL10nId="pdfjs-editor-ink-editor"}static initialize(e,i){le.initialize(e,i),this._defaultDrawingOptions=new zf(i.viewParameters)}static getDefaultDrawingOptions(e){const i=this._defaultDrawingOptions.clone();return i.updateProperties(e),i}static get supportMultipleDrawings(){return!0}static get typesMap(){return gt(this,"typesMap",new Map([[kt.INK_THICKNESS,"stroke-width"],[kt.INK_COLOR,"stroke"],[kt.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,i,n,r,o){return new Dx(e,i,n,r,o,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,i,n,r,o,l){return Nh.deserialize(e,i,n,r,o,l)}static async deserialize(e,i,n){let r=null;if(e instanceof um){const{data:{inkLists:l,rect:c,rotation:h,id:d,color:u,opacity:f,borderStyle:{rawWidth:p},popupRef:m,richText:b,contentsObj:v,creationDate:w,modificationDate:_},parent:{page:{pageNumber:A}}}=e;r=e={annotationType:mt.INK,color:Array.from(u),thickness:p,opacity:f,paths:{points:l},boxes:null,pageIndex:A-1,rect:c.slice(0),rotation:h,annotationElementId:d,id:d,deleted:!1,popupRef:m,richText:b,comment:(v==null?void 0:v.str)||null,creationDate:w,modificationDate:_}}const o=await super.deserialize(e,i,n);return o._initialData=r,e.comment&&o.setCommentData(e),o}get toolbarButtons(){return this._colorPicker||(this._colorPicker=new If(this)),[["colorPicker",this._colorPicker]]}get colorType(){return kt.INK_COLOR}get color(){return this._drawingOptions.stroke}get opacity(){return this._drawingOptions["stroke-opacity"]}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:i,parent:n}=this;i.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,i.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:i,opacity:n}){this._drawingOptions=Zc.getDefaultDrawingOptions({stroke:Z.makeHexColor(...e),"stroke-width":i,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:i,points:n}=this.serializeDraw(e),{_drawingOptions:{stroke:r,"stroke-opacity":o,"stroke-width":l}}=this,c=Object.assign(super.serialize(e),{color:le._colorManager.convert(r),opacity:o,thickness:l,paths:{lines:i,points:n}});return this.addComment(c),e?(c.isCopy=!0,c):this.annotationElementId&&!S(this,rp,$w).call(this,c)?null:(c.id=this.annotationElementId,c)}renderAnnotationElement(e){if(this.deleted)return e.hide(),null;const{points:i,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:i,popup:this.comment}),null}};rp=new WeakSet,$w=function(e){const{color:i,thickness:n,opacity:r,pageIndex:o}=this._initialData;return this.hasEditedComment||this._hasBeenMoved||this._hasBeenResized||e.color.some((l,c)=>l!==i[c])||e.thickness!==n||e.opacity!==r||e.pageIndex!==o},W(Zc,"_type","ink"),W(Zc,"_editorType",mt.INK),W(Zc,"_defaultDrawingOptions",null);let bm=Zc;class ym extends Nh{toSVGPath(){let t=super.toSVGPath();return t.endsWith("Z")||(t+="Z"),t}}const Uf=8,Fh=3;class Ls{static extractContoursFromText(t,{fontFamily:e,fontStyle:i,fontWeight:n},r,o,l,c){let h=new OffscreenCanvas(1,1),d=h.getContext("2d",{alpha:!1});const u=200,f=d.font=`${i} ${n} ${u}px ${e}`,{actualBoundingBoxLeft:p,actualBoundingBoxRight:m,actualBoundingBoxAscent:b,actualBoundingBoxDescent:v,fontBoundingBoxAscent:w,fontBoundingBoxDescent:_,width:A}=d.measureText(t),C=1.5,x=Math.ceil(Math.max(Math.abs(p)+Math.abs(m)||0,A)*C),P=Math.ceil(Math.max(Math.abs(b)+Math.abs(v)||u,Math.abs(w)+Math.abs(_)||u)*C);h=new OffscreenCanvas(x,P),d=h.getContext("2d",{alpha:!0,willReadFrequently:!0}),d.font=f,d.filter="grayscale(1)",d.fillStyle="white",d.fillRect(0,0,x,P),d.fillStyle="black",d.fillText(t,x*(C-1)/2,P*(3-C)/2);const R=S(this,Wt,Db).call(this,d.getImageData(0,0,x,P).data),N=S(this,Wt,Xw).call(this,R),z=S(this,Wt,Ob).call(this,N),H=S(this,Wt,Rb).call(this,R,x,P,z);return this.processDrawnLines({lines:{curves:H,width:x,height:P},pageWidth:r,pageHeight:o,rotation:l,innerMargin:c,mustSmooth:!0,areContours:!0})}static process(t,e,i,n,r){const[o,l,c]=S(this,Wt,qw).call(this,t),[h,d]=S(this,Wt,Yw).call(this,o,l,c,Math.hypot(l,c)*s(this,nl).sigmaSFactor,s(this,nl).sigmaR,s(this,nl).kernelSize),u=S(this,Wt,Ob).call(this,d),f=S(this,Wt,Rb).call(this,h,l,c,u);return this.processDrawnLines({lines:{curves:f,width:l,height:c},pageWidth:e,pageHeight:i,rotation:n,innerMargin:r,mustSmooth:!0,areContours:!0})}static processDrawnLines({lines:t,pageWidth:e,pageHeight:i,rotation:n,innerMargin:r,mustSmooth:o,areContours:l}){n%180!==0&&([e,i]=[i,e]);const{curves:c,width:h,height:d}=t,u=t.thickness??0,f=[],p=Math.min(e/h,i/d),m=p/e,b=p/i,v=[];for(const{points:_}of c){const A=o?S(this,Wt,Gw).call(this,_):_;if(!A)continue;v.push(A);const C=A.length,x=new Float32Array(C),P=new Float32Array(3*(C===2?2:C-2));if(f.push({line:P,points:x}),C===2){x[0]=A[0]*m,x[1]=A[1]*b,P.set([NaN,NaN,NaN,NaN,x[0],x[1]],0);continue}let[R,N,z,H]=A;R*=m,N*=b,z*=m,H*=b,x.set([R,N,z,H],0),P.set([NaN,NaN,NaN,NaN,R,N],0);for(let I=4;I<C;I+=2){const ct=x[I]=A[I]*m,j=x[I+1]=A[I+1]*b;P.set(nt.createBezierPoints(R,N,z,H,ct,j),(I-2)*3),[R,N,z,H]=[z,H,ct,j]}}if(f.length===0)return null;const w=l?new ym:new Nh;return w.build(f,e,i,1,n,l?0:u,r),{outline:w,newCurves:v,areContours:l,thickness:u,width:h,height:d}}static async compressSignature({outlines:t,areContours:e,thickness:i,width:n,height:r}){let o=1/0,l=-1/0,c=0;for(const A of t){c+=A.length;for(let C=2,x=A.length;C<x;C++){const P=A[C]-A[C-2];o=Math.min(o,P),l=Math.max(l,P)}}let h;o>=-128&&l<=127?h=Int8Array:o>=-32768&&l<=32767?h=Int16Array:h=Int32Array;const d=t.length,u=Uf+Fh*d,f=new Uint32Array(u);let p=0;f[p++]=u*Uint32Array.BYTES_PER_ELEMENT+(c-2*d)*h.BYTES_PER_ELEMENT,f[p++]=0,f[p++]=n,f[p++]=r,f[p++]=e?0:1,f[p++]=Math.max(0,Math.floor(i??0)),f[p++]=d,f[p++]=h.BYTES_PER_ELEMENT;for(const A of t)f[p++]=A.length-2,f[p++]=A[0],f[p++]=A[1];const m=new CompressionStream("deflate-raw"),b=m.writable.getWriter();await b.ready,b.write(f);const v=h.prototype.constructor;for(const A of t){const C=new v(A.length-2);for(let x=2,P=A.length;x<P;x++)C[x-2]=A[x]-A[x-2];b.write(C)}b.close();const w=await new Response(m.readable).arrayBuffer(),_=new Uint8Array(w);return h0(_)}static async decompressSignature(t){try{const e=XS(t),{readable:i,writable:n}=new DecompressionStream("deflate-raw"),r=n.getWriter();await r.ready,r.write(e).then(async()=>{await r.ready,await r.close()}).catch(()=>{});let o=null,l=0;for await(const A of i)o||(o=new Uint8Array(new Uint32Array(A.buffer,0,4)[0])),o.set(A,l),l+=A.length;const c=new Uint32Array(o.buffer,0,o.length>>2),h=c[1];if(h!==0)throw new Error(`Invalid version: ${h}`);const d=c[2],u=c[3],f=c[4]===0,p=c[5],m=c[6],b=c[7],v=[],w=(Uf+Fh*m)*Uint32Array.BYTES_PER_ELEMENT;let _;switch(b){case Int8Array.BYTES_PER_ELEMENT:_=new Int8Array(o.buffer,w);break;case Int16Array.BYTES_PER_ELEMENT:_=new Int16Array(o.buffer,w);break;case Int32Array.BYTES_PER_ELEMENT:_=new Int32Array(o.buffer,w);break}l=0;for(let A=0;A<m;A++){const C=c[Fh*A+Uf],x=new Float32Array(C+2);v.push(x);for(let P=0;P<Fh-1;P++)x[P]=c[Fh*A+Uf+P+1];for(let P=0;P<C;P++)x[P+2]=x[P]+_[l++]}return{areContours:f,thickness:p,outlines:v,width:d,height:u}}catch(e){return pt(`decompressSignature: ${e}`),null}}}nl=new WeakMap,Wt=new WeakSet,Mb=function(t,e,i,n){return i-=t,n-=e,i===0?n>0?0:4:i===1?n+6:2-n},qn=new WeakMap,Ww=function(t,e,i,n,r,o,l){const c=S(this,Wt,Mb).call(this,i,n,r,o);for(let h=0;h<8;h++){const d=(-h+c-l+16)%8,u=s(this,qn)[2*d],f=s(this,qn)[2*d+1];if(t[(i+u)*e+(n+f)]!==0)return d}return-1},Vw=function(t,e,i,n,r,o,l){const c=S(this,Wt,Mb).call(this,i,n,r,o);for(let h=0;h<8;h++){const d=(h+c+l+16)%8,u=s(this,qn)[2*d],f=s(this,qn)[2*d+1];if(t[(i+u)*e+(n+f)]!==0)return d}return-1},Rb=function(t,e,i,n){const r=t.length,o=new Int32Array(r);for(let d=0;d<r;d++)o[d]=t[d]<=n?1:0;for(let d=1;d<i-1;d++)o[d*e]=o[d*e+e-1]=0;for(let d=0;d<e;d++)o[d]=o[e*i-1-d]=0;let l=1,c;const h=[];for(let d=1;d<i-1;d++){c=1;for(let u=1;u<e-1;u++){const f=d*e+u,p=o[f];if(p===0)continue;let m=d,b=u;if(p===1&&o[f-1]===0)l+=1,b-=1;else if(p>=1&&o[f+1]===0)l+=1,b+=1,p>1&&(c=p);else{p!==1&&(c=Math.abs(p));continue}const v=[u,d],w=b===u+1,_={isHole:w,points:v,id:l,parent:0};h.push(_);let A;for(const I of h)if(I.id===c){A=I;break}A?A.isHole?_.parent=w?A.parent:c:_.parent=w?c:A.parent:_.parent=w?c:0;const C=S(this,Wt,Ww).call(this,o,e,d,u,m,b,0);if(C===-1){o[f]=-l,o[f]!==1&&(c=Math.abs(o[f]));continue}let x=s(this,qn)[2*C],P=s(this,qn)[2*C+1];const R=d+x,N=u+P;m=R,b=N;let z=d,H=u;for(;;){const I=S(this,Wt,Vw).call(this,o,e,z,H,m,b,1);x=s(this,qn)[2*I],P=s(this,qn)[2*I+1];const ct=z+x,j=H+P;v.push(j,ct);const K=z*e+H;if(o[K+1]===0?o[K]=-l:o[K]===1&&(o[K]=l),ct===d&&j===u&&z===R&&H===N){o[f]!==1&&(c=Math.abs(o[f]));break}else m=z,b=H,z=ct,H=j}}}return h},Wp=function(t,e,i,n){if(i-e<=4){for(let R=e;R<i-2;R+=2)n.push(t[R],t[R+1]);return}const r=t[e],o=t[e+1],l=t[i-4]-r,c=t[i-3]-o,h=Math.hypot(l,c),d=l/h,u=c/h,f=d*o-u*r,p=c/l,m=1/h,b=Math.atan(p),v=Math.cos(b),w=Math.sin(b),_=m*(Math.abs(v)+Math.abs(w)),A=m*(1-_+_**2),C=Math.max(Math.atan(Math.abs(w+v)*A),Math.atan(Math.abs(w-v)*A));let x=0,P=e;for(let R=e+2;R<i-2;R+=2){const N=Math.abs(f-d*t[R+1]+u*t[R]);N>x&&(P=R,x=N)}x>(h*C)**2?(S(this,Wt,Wp).call(this,t,e,P+2,n),S(this,Wt,Wp).call(this,t,P,i,n)):n.push(r,o)},Gw=function(t){const e=[],i=t.length;return S(this,Wt,Wp).call(this,t,0,i,e),e.push(t[i-2],t[i-1]),e.length<=4?null:e},Yw=function(t,e,i,n,r,o){const l=new Float32Array(o**2),c=-2*n**2,h=o>>1;for(let b=0;b<o;b++){const v=(b-h)**2;for(let w=0;w<o;w++)l[b*o+w]=Math.exp((v+(w-h)**2)/c)}const d=new Float32Array(256),u=-2*r**2;for(let b=0;b<256;b++)d[b]=Math.exp(b**2/u);const f=t.length,p=new Uint8Array(f),m=new Uint32Array(256);for(let b=0;b<i;b++)for(let v=0;v<e;v++){const w=b*e+v,_=t[w];let A=0,C=0;for(let P=0;P<o;P++){const R=b+P-h;if(!(R<0||R>=i))for(let N=0;N<o;N++){const z=v+N-h;if(z<0||z>=e)continue;const H=t[R*e+z],I=l[P*o+N]*d[Math.abs(H-_)];A+=H*I,C+=I}}const x=p[w]=Math.round(A/C);m[x]++}return[p,m]},Xw=function(t){const e=new Uint32Array(256);for(const i of t)e[i]++;return e},Db=function(t){const e=t.length,i=new Uint8ClampedArray(e>>2);let n=-1/0,r=1/0;for(let l=0,c=i.length;l<c;l++){const h=i[l]=t[l<<2];n=Math.max(n,h),r=Math.min(r,h)}const o=255/(n-r);for(let l=0,c=i.length;l<c;l++)i[l]=(i[l]-r)*o;return i},Ob=function(t){let e,i=-1/0,n=-1/0;const r=t.findIndex(c=>c!==0);let o=r,l=r;for(e=r;e<256;e++){const c=t[e];c>i&&(e-o>n&&(n=e-o,l=e-1),i=c,o=e)}for(e=l-1;e>=0&&!(t[e]>t[e+1]);e--);return e},qw=function(t){const e=t,{width:i,height:n}=t,{maxDim:r}=s(this,nl);let o=i,l=n;if(i>r||n>r){let f=i,p=n,m=Math.log2(Math.max(i,n)/r);const b=Math.floor(m);m=m===b?b-1:b;for(let w=0;w<m;w++){o=Math.ceil(f/2),l=Math.ceil(p/2);const _=new OffscreenCanvas(o,l);_.getContext("2d").drawImage(t,0,0,f,p,0,0,o,l),f=o,p=l,t!==e&&t.close(),t=_.transferToImageBitmap()}const v=Math.min(r/o,r/l);o=Math.round(o*v),l=Math.round(l*v)}const h=new OffscreenCanvas(o,l).getContext("2d",{willReadFrequently:!0});h.fillStyle="white",h.fillRect(0,0,o,l),h.filter="grayscale(1)",h.drawImage(t,0,0,t.width,t.height,0,0,o,l);const d=h.getImageData(0,0,o,l).data;return[S(this,Wt,Db).call(this,d),o,l]},y(Ls,Wt),y(Ls,nl,{maxDim:512,sigmaSFactor:.02,sigmaR:25,kernelSize:16}),y(Ls,qn,new Int32Array([0,1,-1,1,-1,0,-1,-1,0,-1,1,-1,1,0,1,1]));class vm extends lv{constructor(){super(),super.updateProperties({fill:le._defaultLineColor,"stroke-width":0})}clone(){const t=new vm;return t.updateAll(this),t}}class wm extends zf{constructor(t){super(t),super.updateProperties({stroke:le._defaultLineColor,"stroke-width":1})}clone(){const t=new wm(this._viewParameters);return t.updateAll(this),t}}const yn=class yn extends jf{constructor(e){super({...e,mustBeCommitted:!0,name:"signatureEditor"});y(this,Ao,!1);y(this,_s,null);y(this,So,null);y(this,sl,null);this._willKeepAspectRatio=!0,g(this,So,e.signatureData||null),g(this,_s,null),this.defaultL10nId="pdfjs-editor-signature-editor1"}static initialize(e,i){le.initialize(e,i),this._defaultDrawingOptions=new vm,this._defaultDrawnSignatureOptions=new wm(i.viewParameters)}static getDefaultDrawingOptions(e){const i=this._defaultDrawingOptions.clone();return i.updateProperties(e),i}static get supportMultipleDrawings(){return!1}static get typesMap(){return gt(this,"typesMap",new Map)}static get isDrawer(){return!1}get telemetryFinalData(){return{type:"signature",hasDescription:!!s(this,_s)}}static computeTelemetryFinalData(e){const i=e.get("hasDescription");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}get isResizable(){return!0}onScaleChanging(){this._drawId!==null&&super.onScaleChanging()}render(){if(this.div)return this.div;let e,i;const{_isCopy:n}=this;if(n&&(this._isCopy=!1,e=this.x,i=this.y),super.render(),this._drawId===null)if(s(this,So)){const{lines:r,mustSmooth:o,areContours:l,description:c,uuid:h,heightInPage:d}=s(this,So),{rawDims:{pageWidth:u,pageHeight:f},rotation:p}=this.parent.viewport,m=Ls.processDrawnLines({lines:r,pageWidth:u,pageHeight:f,rotation:p,innerMargin:yn._INNER_MARGIN,mustSmooth:o,areContours:l});this.addSignature(m,d,c,h)}else this.div.setAttribute("data-l10n-args",JSON.stringify({description:""})),this.div.hidden=!0,this._uiManager.getSignature(this);else this.div.setAttribute("data-l10n-args",JSON.stringify({description:s(this,_s)||""}));return n&&(this._isCopy=!0,this._moveAfterPaste(e,i)),this.div}setUuid(e){g(this,sl,e),this.addEditToolbar()}getUuid(){return s(this,sl)}get description(){return s(this,_s)}set description(e){g(this,_s,e),this.div&&(this.div.setAttribute("data-l10n-args",JSON.stringify({description:e})),super.addEditToolbar().then(i=>{i==null||i.updateEditSignatureButton(e)}))}getSignaturePreview(){const{newCurves:e,areContours:i,thickness:n,width:r,height:o}=s(this,So),l=Math.max(r,o),c=Ls.processDrawnLines({lines:{curves:e.map(h=>({points:h})),thickness:n,width:r,height:o},pageWidth:l,pageHeight:l,rotation:0,innerMargin:0,mustSmooth:!1,areContours:i});return{areContours:i,outline:c.outline}}get toolbarButtons(){return this._uiManager.signatureManager?[["editSignature",this._uiManager.signatureManager]]:super.toolbarButtons}addSignature(e,i,n,r){const{x:o,y:l}=this,{outline:c}=g(this,So,e);g(this,Ao,c instanceof ym),this.description=n;let h;s(this,Ao)?h=yn.getDefaultDrawingOptions():(h=yn._defaultDrawnSignatureOptions.clone(),h.updateProperties({"stroke-width":c.thickness})),this._addOutlines({drawOutlines:c,drawingOptions:h});const[,d]=this.pageDimensions;let u=i/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(),this.x=o,this.y=l,this.center(),this._onResized(),this.onScaleChanging(),this.rotate(),this._uiManager.addToAnnotationStorage(this),this.setUuid(r),this._reportTelemetry({action:"pdfjs.signature.inserted",data:{hasBeenSaved:!!r,hasDescription:!!n}}),this.div.hidden=!1}getFromImage(e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:r}=this.parent.viewport;return Ls.process(e,i,n,r,yn._INNER_MARGIN)}getFromText(e,i){const{rawDims:{pageWidth:n,pageHeight:r},rotation:o}=this.parent.viewport;return Ls.extractContoursFromText(e,i,n,r,o,yn._INNER_MARGIN)}getDrawnSignature(e){const{rawDims:{pageWidth:i,pageHeight:n},rotation:r}=this.parent.viewport;return Ls.processDrawnLines({lines:e,pageWidth:i,pageHeight:n,rotation:r,innerMargin:yn._INNER_MARGIN,mustSmooth:!1,areContours:!1})}createDrawingOptions({areContours:e,thickness:i}){e?this._drawingOptions=yn.getDefaultDrawingOptions():(this._drawingOptions=yn._defaultDrawnSignatureOptions.clone(),this._drawingOptions.updateProperties({"stroke-width":i}))}serialize(e=!1){if(this.isEmpty())return null;const{lines:i,points:n}=this.serializeDraw(e),{_drawingOptions:{"stroke-width":r}}=this,o=Object.assign(super.serialize(e),{isSignature:!0,areContours:s(this,Ao),color:[0,0,0],thickness:s(this,Ao)?0:r});return this.addComment(o),e?(o.paths={lines:i,points:n},o.uuid=s(this,sl),o.isCopy=!0):o.lines=i,s(this,_s)&&(o.accessibilityData={type:"Figure",alt:s(this,_s)}),o}static deserializeDraw(e,i,n,r,o,l){return l.areContours?ym.deserialize(e,i,n,r,o,l):Nh.deserialize(e,i,n,r,o,l)}static async deserialize(e,i,n){var o;const r=await super.deserialize(e,i,n);return g(r,Ao,e.areContours),r.description=((o=e.accessibilityData)==null?void 0:o.alt)||"",g(r,sl,e.uuid),r}};Ao=new WeakMap,_s=new WeakMap,So=new WeakMap,sl=new WeakMap,W(yn,"_type","signature"),W(yn,"_editorType",mt.SIGNATURE),W(yn,"_defaultDrawingOptions",null);let Am=yn;class Sm extends le{constructor(e){super({...e,name:"stampEditor"});y(this,Ot);y(this,be,null);y(this,Qe,null);y(this,Eo,null);y(this,yr,null);y(this,xo,null);y(this,Qc,"");y(this,vr,null);y(this,rl,!1);y(this,Ts,null);y(this,vn,!1);y(this,th,!1);g(this,yr,e.bitmapUrl),g(this,xo,e.bitmapFile),this.defaultL10nId="pdfjs-editor-stamp-editor"}static initialize(e,i){le.initialize(e,i)}static isHandlingMimeForPasting(e){return Hg.includes(e)}static paste(e,i){i.pasteEditor({mode:mt.STAMP},{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){var e;return{type:"stamp",hasAltText:!!((e=this.altTextData)!=null&&e.altText)}}static computeTelemetryFinalData(e){const i=e.get("hasAltText");return{hasAltText:i.get(!0)??0,hasNoAltText:i.get(!1)??0}}async mlGuessAltText(e=null,i=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:o,height:l}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:r,width:o,height:l,channels:r.length/(o*l)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const h=c.output;return await this.setGuessedAltText(h),i&&!this.hasAltTextData()&&(this.altTextData={alt:h,decorative:!1}),h}remove(){var e;s(this,Qe)&&(g(this,be,null),this._uiManager.imageManager.deleteId(s(this,Qe)),(e=s(this,vr))==null||e.remove(),g(this,vr,null),s(this,Ts)&&(clearTimeout(s(this,Ts)),g(this,Ts,null))),super.remove()}rebuild(){if(!this.parent){s(this,Qe)&&S(this,Ot,Vp).call(this);return}super.rebuild(),this.div!==null&&(s(this,Qe)&&s(this,vr)===null&&S(this,Ot,Vp).call(this),this.isAttachedToDOM||this.parent.add(this))}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(s(this,Eo)||s(this,be)||s(this,yr)||s(this,xo)||s(this,Qe)||s(this,rl))}get toolbarButtons(){return[["altText",this.createAltText()]]}get isResizable(){return!0}render(){if(this.div)return this.div;let e,i;return this._isCopy&&(e=this.x,i=this.y),super.render(),this.div.hidden=!0,this.createAltText(),s(this,rl)||(s(this,be)?S(this,Ot,Gp).call(this):S(this,Ot,Vp).call(this)),this._isCopy&&this._moveAfterPaste(e,i),this._uiManager.addShouldRescale(this),this.div}setCanvas(e,i){const{id:n,bitmap:r}=this._uiManager.imageManager.getFromCanvas(e,i);i.remove(),n&&this._uiManager.imageManager.isValidId(n)&&(g(this,Qe,n),r&&g(this,be,r),g(this,rl,!1),S(this,Ot,Gp).call(this))}_onResized(){this.onScaleChanging()}onScaleChanging(){if(!this.parent)return;s(this,Ts)!==null&&clearTimeout(s(this,Ts)),g(this,Ts,setTimeout(()=>{g(this,Ts,null),S(this,Ot,Ib).call(this)},200))}copyCanvas(e,i,n=!1){e||(e=224);const{width:r,height:o}=s(this,be),l=new ns;let c=s(this,be),h=r,d=o,u=null;if(i){if(r>i||o>i){const R=Math.min(i/r,i/o);h=Math.floor(r*R),d=Math.floor(o*R)}u=document.createElement("canvas");const p=u.width=Math.ceil(h*l.sx),m=u.height=Math.ceil(d*l.sy);s(this,vn)||(c=S(this,Ot,Yp).call(this,p,m));const b=u.getContext("2d");b.filter=this._uiManager.hcmFilter;let v="white",w="#cfcfd8";this._uiManager.hcmFilter!=="none"?w="black":tE.isDarkMode&&(v="#8f8f9d",w="#42414d");const _=15,A=_*l.sx,C=_*l.sy,x=new OffscreenCanvas(A*2,C*2),P=x.getContext("2d");P.fillStyle=v,P.fillRect(0,0,A*2,C*2),P.fillStyle=w,P.fillRect(0,0,A,C),P.fillRect(A,C,A,C),b.fillStyle=b.createPattern(x,"repeat"),b.fillRect(0,0,p,m),b.drawImage(c,0,0,c.width,c.height,0,0,p,m)}let f=null;if(n){let p,m;if(l.symmetric&&c.width<e&&c.height<e)p=c.width,m=c.height;else if(c=s(this,be),r>e||o>e){const w=Math.min(e/r,e/o);p=Math.floor(r*w),m=Math.floor(o*w),s(this,vn)||(c=S(this,Ot,Yp).call(this,p,m))}const v=new OffscreenCanvas(p,m).getContext("2d",{willReadFrequently:!0});v.drawImage(c,0,0,c.width,c.height,0,0,p,m),f={width:p,height:m,data:v.getImageData(0,0,p,m).data}}return{canvas:u,width:h,height:d,imageData:f}}static async deserialize(e,i,n){var v;let r=null,o=!1;if(e instanceof ov){const{data:{rect:w,rotation:_,id:A,structParent:C,popupRef:x,richText:P,contentsObj:R,creationDate:N,modificationDate:z},container:H,parent:{page:{pageNumber:I}},canvas:ct}=e;let j,K;ct?(delete e.canvas,{id:j,bitmap:K}=n.imageManager.getFromCanvas(H.id,ct),ct.remove()):(o=!0,e._hasNoCanvas=!0);const st=((v=await i._structTree.getAriaAttributes(`${xl}${A}`))==null?void 0:v.get("aria-label"))||"";r=e={annotationType:mt.STAMP,bitmapId:j,bitmap:K,pageIndex:I-1,rect:w.slice(0),rotation:_,annotationElementId:A,id:A,deleted:!1,accessibilityData:{decorative:!1,altText:st},isSvg:!1,structParent:C,popupRef:x,richText:P,comment:(R==null?void 0:R.str)||null,creationDate:N,modificationDate:z}}const l=await super.deserialize(e,i,n),{rect:c,bitmap:h,bitmapUrl:d,bitmapId:u,isSvg:f,accessibilityData:p}=e;o?(n.addMissingCanvas(e.id,l),g(l,rl,!0)):u&&n.imageManager.isValidId(u)?(g(l,Qe,u),h&&g(l,be,h)):g(l,yr,d),g(l,vn,f);const[m,b]=l.pageDimensions;return l.width=(c[2]-c[0])/m,l.height=(c[3]-c[1])/b,p&&(l.altTextData=p),l._initialData=r,e.comment&&l.setCommentData(e),g(l,th,!!r),l}serialize(e=!1,i=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n=Object.assign(super.serialize(e),{bitmapId:s(this,Qe),isSvg:s(this,vn)});if(this.addComment(n),e)return n.bitmapUrl=S(this,Ot,Xp).call(this,!0),n.accessibilityData=this.serializeAltText(!0),n.isCopy=!0,n;const{decorative:r,altText:o}=this.serializeAltText(!1);if(!r&&o&&(n.accessibilityData={type:"Figure",alt:o}),this.annotationElementId){const c=S(this,Ot,Kw).call(this,n);return c.isSame?null:(c.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1,n.id=this.annotationElementId,delete n.bitmapId,n)}if(i===null)return n;i.stamps||(i.stamps=new Map);const l=s(this,vn)?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(!i.stamps.has(s(this,Qe)))i.stamps.set(s(this,Qe),{area:l,serialized:n}),n.bitmap=S(this,Ot,Xp).call(this,!1);else if(s(this,vn)){const c=i.stamps.get(s(this,Qe));l>c.area&&(c.area=l,c.serialized.bitmap.close(),c.serialized.bitmap=S(this,Ot,Xp).call(this,!1))}return n}renderAnnotationElement(e){return this.deleted?(e.hide(),null):(e.updateEdited({rect:this.getPDFRect(),popup:this.comment}),null)}}be=new WeakMap,Qe=new WeakMap,Eo=new WeakMap,yr=new WeakMap,xo=new WeakMap,Qc=new WeakMap,vr=new WeakMap,rl=new WeakMap,Ts=new WeakMap,vn=new WeakMap,th=new WeakMap,Ot=new WeakSet,Ju=function(e,i=!1){if(!e){this.remove();return}g(this,be,e.bitmap),i||(g(this,Qe,e.id),g(this,vn,e.isSvg)),e.file&&g(this,Qc,e.file.name),S(this,Ot,Gp).call(this)},Zu=function(){if(g(this,Eo,null),this._uiManager.enableWaiting(!1),!!s(this,vr)){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&s(this,be)){this.addEditToolbar().then(()=>{this._editToolbar.hide(),this._uiManager.editAltText(this,!0)});return}if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&s(this,be)){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}},Vp=function(){if(s(this,Qe)){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(s(this,Qe)).then(n=>S(this,Ot,Ju).call(this,n,!0)).finally(()=>S(this,Ot,Zu).call(this));return}if(s(this,yr)){const n=s(this,yr);g(this,yr,null),this._uiManager.enableWaiting(!0),g(this,Eo,this._uiManager.imageManager.getFromUrl(n).then(r=>S(this,Ot,Ju).call(this,r)).finally(()=>S(this,Ot,Zu).call(this)));return}if(s(this,xo)){const n=s(this,xo);g(this,xo,null),this._uiManager.enableWaiting(!0),g(this,Eo,this._uiManager.imageManager.getFromFile(n).then(r=>S(this,Ot,Ju).call(this,r)).finally(()=>S(this,Ot,Zu).call(this)));return}const e=document.createElement("input");e.type="file",e.accept=Hg.join(",");const i=this._uiManager._signal;g(this,Eo,new Promise(n=>{e.addEventListener("change",async()=>{if(!e.files||e.files.length===0)this.remove();else{this._uiManager.enableWaiting(!0);const r=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),S(this,Ot,Ju).call(this,r)}n()},{signal:i}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:i})}).finally(()=>S(this,Ot,Zu).call(this))),e.click()},Gp=function(){var h;const{div:e}=this;let{width:i,height:n}=s(this,be);const[r,o]=this.pageDimensions,l=.75;if(this.width)i=this.width*r,n=this.height*o;else if(i>l*r||n>l*o){const d=Math.min(l*r/i,l*o/n);i*=d,n*=d}this._uiManager.enableWaiting(!1);const c=g(this,vr,document.createElement("canvas"));c.setAttribute("role","img"),this.addContainer(c),this.width=i/r,this.height=n/o,this.setDims(),(h=this._initialOptions)!=null&&h.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,(!this._uiManager.useNewAltTextWhenAddingImage||!this._uiManager.useNewAltTextFlow||this.annotationElementId)&&(e.hidden=!1),S(this,Ot,Ib).call(this),s(this,th)||(this.parent.addUndoableEditor(this),g(this,th,!0)),this._reportTelemetry({action:"inserted_image"}),s(this,Qc)&&this.div.setAttribute("aria-description",s(this,Qc)),this.annotationElementId||this._uiManager.a11yAlert("pdfjs-editor-stamp-added-alert")},Yp=function(e,i){const{width:n,height:r}=s(this,be);let o=n,l=r,c=s(this,be);for(;o>2*e||l>2*i;){const h=o,d=l;o>2*e&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2)),l>2*i&&(l=l>=16384?Math.floor(l/2)-1:Math.ceil(l/2));const u=new OffscreenCanvas(o,l);u.getContext("2d").drawImage(c,0,0,h,d,0,0,o,l),c=u.transferToImageBitmap()}return c},Ib=function(){const[e,i]=this.parentDimensions,{width:n,height:r}=this,o=new ns,l=Math.ceil(n*e*o.sx),c=Math.ceil(r*i*o.sy),h=s(this,vr);if(!h||h.width===l&&h.height===c)return;h.width=l,h.height=c;const d=s(this,vn)?s(this,be):S(this,Ot,Yp).call(this,l,c),u=h.getContext("2d");u.filter=this._uiManager.hcmFilter,u.drawImage(d,0,0,d.width,d.height,0,0,l,c)},Xp=function(e){if(e){if(s(this,vn)){const r=this._uiManager.imageManager.getSvgUrl(s(this,Qe));if(r)return r}const i=document.createElement("canvas");return{width:i.width,height:i.height}=s(this,be),i.getContext("2d").drawImage(s(this,be),0,0),i.toDataURL()}if(s(this,vn)){const[i,n]=this.pageDimensions,r=Math.round(this.width*i*Fr.PDF_TO_CSS_UNITS),o=Math.round(this.height*n*Fr.PDF_TO_CSS_UNITS),l=new OffscreenCanvas(r,o);return l.getContext("2d").drawImage(s(this,be),0,0,s(this,be).width,s(this,be).height,0,0,r,o),l.transferToImageBitmap()}return structuredClone(s(this,be))},Kw=function(e){var l;const{pageIndex:i,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===i,o=(((l=e.accessibilityData)==null?void 0:l.alt)||"")===n;return{isSame:!this.hasEditedComment&&!this._hasBeenMoved&&!this._hasBeenResized&&r&&o,isSameAltText:o}},W(Sm,"_type","stamp"),W(Sm,"_editorType",mt.STAMP);const Jn=class Jn{constructor({uiManager:t,pageIndex:e,div:i,structTreeLayer:n,accessibilityManager:r,annotationLayer:o,drawLayer:l,textLayer:c,viewport:h,l10n:d}){y(this,oe);y(this,ol);y(this,eh,!1);y(this,Co,null);y(this,_o,null);y(this,wr,null);y(this,Ui,new Map);y(this,To,!1);y(this,ih,!1);y(this,nh,!1);y(this,Kn,null);y(this,Ar,null);y(this,ti,null);y(this,Sr,null);y(this,Po,null);y(this,sh,-1);y(this,ot);const u=[...s(Jn,ko).values()];if(!Jn._initialized){Jn._initialized=!0;for(const f of u)f.initialize(d,t)}t.registerEditorTypes(u),g(this,ot,t),this.pageIndex=e,this.div=i,g(this,ol,r),g(this,Co,o),this.viewport=h,g(this,ti,c),this.drawLayer=l,this._structTree=n,s(this,ot).addLayer(this)}get isEmpty(){return s(this,Ui).size===0}get isInvisible(){return this.isEmpty&&s(this,ot).getMode()===mt.NONE}updateToolbar(t){s(this,ot).updateToolbar(t)}updateMode(t=s(this,ot).getMode()){switch(S(this,oe,qp).call(this),t){case mt.NONE:this.div.classList.toggle("nonEditing",!0),this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case mt.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case mt.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:e}=this.div;if(e.toggle("nonEditing",!1),t===mt.POPUP)e.toggle("commentEditing",!0);else{e.toggle("commentEditing",!1);for(const i of s(Jn,ko).values())e.toggle(`${i._type}Editing`,t===i._editorType)}this.div.hidden=!1}hasTextLayer(t){var e;return t===((e=s(this,ti))==null?void 0:e.div)}setEditingState(t){s(this,ot).setEditingState(t)}addCommands(t){s(this,ot).addCommands(t)}cleanUndoStack(t){s(this,ot).cleanUndoStack(t)}toggleDrawing(t=!1){this.div.classList.toggle("drawing",!t)}togglePointerEvents(t=!1){this.div.classList.toggle("disabled",!t)}toggleAnnotationLayerPointerEvents(t=!1){var e;(e=s(this,Co))==null||e.togglePointerEvents(t)}async enable(){var i;g(this,nh,!0),this.div.tabIndex=0,this.togglePointerEvents(!0),this.div.classList.toggle("nonEditing",!1),(i=s(this,Po))==null||i.abort(),g(this,Po,null);const t=new Set;for(const n of s(this,oe,Lb))n.enableEditing(),n.show(!0),n.annotationElementId&&(s(this,ot).removeChangedExistingAnnotation(n),t.add(n.annotationElementId));const e=s(this,Co);if(e)for(const n of e.getEditableAnnotations()){if(n.hide(),s(this,ot).isDeletedAnnotationElement(n.data.id)||t.has(n.data.id))continue;const r=await this.deserialize(n);r&&(this.addOrRebuild(r),r.enableEditing())}g(this,nh,!1),s(this,ot)._eventBus.dispatch("editorsrendered",{source:this,pageNumber:this.pageIndex+1})}disable(){var n;if(g(this,ih,!0),this.div.tabIndex=-1,this.togglePointerEvents(!1),this.div.classList.toggle("nonEditing",!0),s(this,ti)&&!s(this,Po)){g(this,Po,new AbortController);const r=s(this,ot).combinedSignal(s(this,Po));s(this,ti).div.addEventListener("pointerdown",o=>{const{clientX:c,clientY:h,timeStamp:d}=o,u=s(this,sh);if(d-u>500){g(this,sh,d);return}g(this,sh,-1);const{classList:f}=this.div;f.toggle("getElements",!0);const p=document.elementsFromPoint(c,h);if(f.toggle("getElements",!1),!this.div.contains(p[0]))return;let m;const b=new RegExp(`^${vh}[0-9]+$`);for(const w of p)if(b.test(w.id)){m=w.id;break}if(!m)return;const v=s(this,Ui).get(m);(v==null?void 0:v.annotationElementId)===null&&(o.stopPropagation(),o.preventDefault(),v.dblclick(o))},{signal:r,capture:!0})}const t=s(this,Co),e=[];if(t){const r=new Map,o=new Map;for(const c of s(this,oe,Lb)){if(c.disableEditing(),!c.annotationElementId){e.push(c);continue}if(c.serialize()!==null){r.set(c.annotationElementId,c);continue}else o.set(c.annotationElementId,c);(n=this.getEditableAnnotation(c.annotationElementId))==null||n.show(),c.remove()}const l=t.getEditableAnnotations();for(const c of l){const{id:h}=c.data;if(s(this,ot).isDeletedAnnotationElement(h)){c.updateEdited({deleted:!0});continue}let d=o.get(h);if(d){d.resetAnnotationElement(c),d.show(!1),c.show();continue}d=r.get(h),d&&(s(this,ot).addChangedExistingAnnotation(d),d.renderAnnotationElement(c)&&d.show(!1)),c.show()}}S(this,oe,qp).call(this),this.isEmpty&&(this.div.hidden=!0);const{classList:i}=this.div;for(const r of s(Jn,ko).values())i.remove(`${r._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),t==null||t.updateFakeAnnotations(e),g(this,ih,!1)}getEditableAnnotation(t){var e;return((e=s(this,Co))==null?void 0:e.getEditableAnnotation(t))||null}setActiveEditor(t){s(this,ot).getActive()!==t&&s(this,ot).setActiveEditor(t)}enableTextSelection(){var t;if(this.div.tabIndex=-1,(t=s(this,ti))!=null&&t.div&&!s(this,Sr)){g(this,Sr,new AbortController);const e=s(this,ot).combinedSignal(s(this,Sr));s(this,ti).div.addEventListener("pointerdown",S(this,oe,Jw).bind(this),{signal:e}),s(this,ti).div.classList.add("highlighting")}}disableTextSelection(){var t;this.div.tabIndex=0,(t=s(this,ti))!=null&&t.div&&s(this,Sr)&&(s(this,Sr).abort(),g(this,Sr,null),s(this,ti).div.classList.remove("highlighting"))}enableClick(){if(s(this,_o))return;g(this,_o,new AbortController);const t=s(this,ot).combinedSignal(s(this,_o));this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:t});const e=this.pointerup.bind(this);this.div.addEventListener("pointerup",e,{signal:t}),this.div.addEventListener("pointercancel",e,{signal:t})}disableClick(){var t;(t=s(this,_o))==null||t.abort(),g(this,_o,null)}attach(t){s(this,Ui).set(t.id,t);const{annotationElementId:e}=t;e&&s(this,ot).isDeletedAnnotationElement(e)&&s(this,ot).removeDeletedAnnotationElement(t)}detach(t){var e;s(this,Ui).delete(t.id),(e=s(this,ol))==null||e.removePointerInTextLayer(t.contentDiv),!s(this,ih)&&t.annotationElementId&&s(this,ot).addDeletedAnnotationElement(t)}remove(t){this.detach(t),s(this,ot).removeEditor(t),t.div.remove(),t.isAttachedToDOM=!1}changeParent(t){var e;t.parent!==this&&(t.parent&&t.annotationElementId&&(s(this,ot).addDeletedAnnotationElement(t),le.deleteAnnotationElement(t),t.annotationElementId=null),this.attach(t),(e=t.parent)==null||e.detach(t),t.setParent(this),t.div&&t.isAttachedToDOM&&(t.div.remove(),this.div.append(t.div)))}add(t){if(!(t.parent===this&&t.isAttachedToDOM)){if(this.changeParent(t),s(this,ot).addEditor(t),this.attach(t),!t.isAttachedToDOM){const e=t.render();this.div.append(e),t.isAttachedToDOM=!0}t.fixAndSetPosition(),t.onceAdded(!s(this,nh)),s(this,ot).addToAnnotationStorage(t),t._reportTelemetry(t.telemetryInitialData)}}moveEditorInDOM(t){var i;if(!t.isAttachedToDOM)return;const{activeElement:e}=document;t.div.contains(e)&&!s(this,wr)&&(t._focusEventsAllowed=!1,g(this,wr,setTimeout(()=>{g(this,wr,null),t.div.contains(document.activeElement)?t._focusEventsAllowed=!0:(t.div.addEventListener("focusin",()=>{t._focusEventsAllowed=!0},{once:!0,signal:s(this,ot)._signal}),e.focus())},0))),t._structTreeParentId=(i=s(this,ol))==null?void 0:i.moveElementInDOM(this.div,t.div,t.contentDiv,!0)}addOrRebuild(t){t.needsToBeRebuilt()?(t.parent||(t.parent=this),t.rebuild(),t.show()):this.add(t)}addUndoableEditor(t){const e=()=>t._uiManager.rebuild(t),i=()=>{t.remove()};this.addCommands({cmd:e,undo:i,mustExec:!1})}getEditorByUID(t){for(const e of s(this,Ui).values())if(e.uid===t)return e;return null}getNextId(){return s(this,ot).getId()}combinedSignal(t){return s(this,ot).combinedSignal(t)}canCreateNewEmptyEditor(){var t;return(t=s(this,oe,Ms))==null?void 0:t.canCreateNewEmptyEditor()}async pasteEditor(t,e){this.updateToolbar(t),await s(this,ot).updateMode(t.mode);const{offsetX:i,offsetY:n}=S(this,oe,Fb).call(this),r=this.getNextId(),o=S(this,oe,Nb).call(this,{parent:this,id:r,x:i,y:n,uiManager:s(this,ot),isCentered:!0,...e});o&&this.add(o)}async deserialize(t){var e;return await((e=s(Jn,ko).get(t.annotationType??t.annotationEditorType))==null?void 0:e.deserialize(t,this,s(this,ot)))||null}createAndAddNewEditor(t,e,i={}){const n=this.getNextId(),r=S(this,oe,Nb).call(this,{parent:this,id:n,x:t.offsetX,y:t.offsetY,uiManager:s(this,ot),isCentered:e,...i});return r&&this.add(r),r}get boundingClientRect(){return this.div.getBoundingClientRect()}addNewEditor(t={}){this.createAndAddNewEditor(S(this,oe,Fb).call(this),!0,t)}setSelected(t){s(this,ot).setSelected(t)}toggleSelected(t){s(this,ot).toggleSelected(t)}unselect(t){s(this,ot).unselect(t)}pointerup(t){var n;const{isMac:e}=je.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div||!s(this,To)||(g(this,To,!1),(n=s(this,oe,Ms))!=null&&n.isDrawer&&s(this,oe,Ms).supportMultipleDrawings))return;if(!s(this,eh)){g(this,eh,!0);return}const i=s(this,ot).getMode();if(i===mt.STAMP||i===mt.SIGNATURE){s(this,ot).unselectAll();return}this.createAndAddNewEditor(t,!1)}pointerdown(t){var n;if(s(this,ot).getMode()===mt.HIGHLIGHT&&this.enableTextSelection(),s(this,To)){g(this,To,!1);return}const{isMac:e}=je.platform;if(t.button!==0||t.ctrlKey&&e||t.target!==this.div)return;if(g(this,To,!0),(n=s(this,oe,Ms))!=null&&n.isDrawer){this.startDrawingSession(t);return}const i=s(this,ot).getActive();g(this,eh,!i||i.isEmpty())}startDrawingSession(t){if(this.div.focus({preventScroll:!0}),s(this,Kn)){s(this,oe,Ms).startDrawing(this,s(this,ot),!1,t);return}s(this,ot).setCurrentDrawingSession(this),g(this,Kn,new AbortController);const e=s(this,ot).combinedSignal(s(this,Kn));this.div.addEventListener("blur",({relatedTarget:i})=>{i&&!this.div.contains(i)&&(g(this,Ar,null),this.commitOrRemove())},{signal:e}),s(this,oe,Ms).startDrawing(this,s(this,ot),!1,t)}pause(t){if(t){const{activeElement:e}=document;this.div.contains(e)&&g(this,Ar,e);return}s(this,Ar)&&setTimeout(()=>{var e;(e=s(this,Ar))==null||e.focus(),g(this,Ar,null)},0)}endDrawingSession(t=!1){return s(this,Kn)?(s(this,ot).setCurrentDrawingSession(null),s(this,Kn).abort(),g(this,Kn,null),g(this,Ar,null),s(this,oe,Ms).endDrawing(t)):null}findNewParent(t,e,i){const n=s(this,ot).findParent(e,i);return n===null||n===this?!1:(n.changeParent(t),!0)}commitOrRemove(){return s(this,Kn)?(this.endDrawingSession(),!0):!1}onScaleChanging(){s(this,Kn)&&s(this,oe,Ms).onScaleChangingWhenDrawing(this)}destroy(){var t,e;this.commitOrRemove(),((t=s(this,ot).getActive())==null?void 0:t.parent)===this&&(s(this,ot).commitOrRemove(),s(this,ot).setActiveEditor(null)),s(this,wr)&&(clearTimeout(s(this,wr)),g(this,wr,null));for(const i of s(this,Ui).values())(e=s(this,ol))==null||e.removePointerInTextLayer(i.contentDiv),i.setParent(null),i.isAttachedToDOM=!1,i.div.remove();this.div=null,s(this,Ui).clear(),s(this,ot).removeLayer(this)}render({viewport:t}){this.viewport=t,zo(this.div,t);for(const e of s(this,ot).getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:t}){s(this,ot).commitOrRemove(),S(this,oe,qp).call(this);const e=this.viewport.rotation,i=t.rotation;if(this.viewport=t,zo(this.div,{rotation:i}),e!==i)for(const n of s(this,Ui).values())n.rotate(i)}get pageDimensions(){const{pageWidth:t,pageHeight:e}=this.viewport.rawDims;return[t,e]}get scale(){return s(this,ot).viewParameters.realScale}};ol=new WeakMap,eh=new WeakMap,Co=new WeakMap,_o=new WeakMap,wr=new WeakMap,Ui=new WeakMap,To=new WeakMap,ih=new WeakMap,nh=new WeakMap,Kn=new WeakMap,Ar=new WeakMap,ti=new WeakMap,Sr=new WeakMap,Po=new WeakMap,sh=new WeakMap,ot=new WeakMap,ko=new WeakMap,oe=new WeakSet,Lb=function(){return s(this,Ui).size!==0?s(this,Ui).values():s(this,ot).getEditors(this.pageIndex)},Jw=function(t){s(this,ot).unselectAll();const{target:e}=t;if(e===s(this,ti).div||(e.getAttribute("role")==="img"||e.classList.contains("endOfContent"))&&s(this,ti).div.contains(e)){const{isMac:i}=je.platform;if(t.button!==0||t.ctrlKey&&i)return;s(this,ot).showAllEditors("highlight",!0,!0),s(this,ti).div.classList.add("free"),this.toggleDrawing(),Bf.startHighlighting(this,s(this,ot).direction==="ltr",{target:s(this,ti).div,x:t.x,y:t.y}),s(this,ti).div.addEventListener("pointerup",()=>{s(this,ti).div.classList.remove("free"),this.toggleDrawing(!0)},{once:!0,signal:s(this,ot)._signal}),t.preventDefault()}},Ms=function(){return s(Jn,ko).get(s(this,ot).getMode())},Nb=function(t){const e=s(this,oe,Ms);return e?new e.prototype.constructor(t):null},Fb=function(){const{x:t,y:e,width:i,height:n}=this.boundingClientRect,r=Math.max(0,t),o=Math.max(0,e),l=Math.min(window.innerWidth,t+i),c=Math.min(window.innerHeight,e+n),h=(r+l)/2-t,d=(o+c)/2-e,[u,f]=this.viewport.rotation%180===0?[h,d]:[d,h];return{offsetX:u,offsetY:f}},qp=function(){for(const t of s(this,Ui).values())t.isEmpty()&&t.remove()},W(Jn,"_initialized",!1),y(Jn,ko,new Map([pm,bm,Sm,Bf,Am].map(t=>[t._editorType,t])));let Em=Jn;const $e=class $e{constructor({pageIndex:t}){y(this,Ps);y(this,Zn,null);y(this,ki,new Map);y(this,al,new Map);this.pageIndex=t}setParent(t){if(!s(this,Zn)){g(this,Zn,t);return}if(s(this,Zn)!==t){if(s(this,ki).size>0)for(const e of s(this,ki).values())e.remove(),t.append(e);g(this,Zn,t)}}static get _svgFactory(){return gt(this,"_svgFactory",new Lf)}draw(t,e=!1,i=!1){const n=Ge($e,Tu)._++,r=S(this,Ps,Bb).call(this),o=$e._svgFactory.createElement("defs");r.append(o);const l=$e._svgFactory.createElement("path");o.append(l);const c=`path_p${this.pageIndex}_${n}`;l.setAttribute("id",c),l.setAttribute("vector-effect","non-scaling-stroke"),e&&s(this,al).set(n,l);const h=i?S(this,Ps,Qw).call(this,o,c):null,d=$e._svgFactory.createElement("use");return r.append(d),d.setAttribute("href",`#${c}`),this.updateProperties(r,t),s(this,ki).set(n,r),{id:n,clipPathId:`url(#${h})`}}drawOutline(t,e){const i=Ge($e,Tu)._++,n=S(this,Ps,Bb).call(this),r=$e._svgFactory.createElement("defs");n.append(r);const o=$e._svgFactory.createElement("path");r.append(o);const l=`path_p${this.pageIndex}_${i}`;o.setAttribute("id",l),o.setAttribute("vector-effect","non-scaling-stroke");let c;if(e){const u=$e._svgFactory.createElement("mask");r.append(u),c=`mask_p${this.pageIndex}_${i}`,u.setAttribute("id",c),u.setAttribute("maskUnits","objectBoundingBox");const f=$e._svgFactory.createElement("rect");u.append(f),f.setAttribute("width","1"),f.setAttribute("height","1"),f.setAttribute("fill","white");const p=$e._svgFactory.createElement("use");u.append(p),p.setAttribute("href",`#${l}`),p.setAttribute("stroke","none"),p.setAttribute("fill","black"),p.setAttribute("fill-rule","nonzero"),p.classList.add("mask")}const h=$e._svgFactory.createElement("use");n.append(h),h.setAttribute("href",`#${l}`),c&&h.setAttribute("mask",`url(#${c})`);const d=h.cloneNode();return n.append(d),h.classList.add("mainOutline"),d.classList.add("secondaryOutline"),this.updateProperties(n,t),s(this,ki).set(i,n),i}finalizeDraw(t,e){s(this,al).delete(t),this.updateProperties(t,e)}updateProperties(t,e){var c;if(!e)return;const{root:i,bbox:n,rootClass:r,path:o}=e,l=typeof t=="number"?s(this,ki).get(t):t;if(l){if(i&&S(this,Ps,jb).call(this,l,i),n&&S(c=$e,op,Zw).call(c,l,n),r){const{classList:h}=l;for(const[d,u]of Object.entries(r))h.toggle(d,u)}if(o){const d=l.firstElementChild.firstElementChild;S(this,Ps,jb).call(this,d,o)}}}updateParent(t,e){if(e===this)return;const i=s(this,ki).get(t);i&&(s(e,Zn).append(i),s(this,ki).delete(t),s(e,ki).set(t,i))}remove(t){s(this,al).delete(t),s(this,Zn)!==null&&(s(this,ki).get(t).remove(),s(this,ki).delete(t))}destroy(){g(this,Zn,null);for(const t of s(this,ki).values())t.remove();s(this,ki).clear(),s(this,al).clear()}};Zn=new WeakMap,ki=new WeakMap,al=new WeakMap,Tu=new WeakMap,op=new WeakSet,Zw=function(t,[e,i,n,r]){const{style:o}=t;o.top=`${100*i}%`,o.left=`${100*e}%`,o.width=`${100*n}%`,o.height=`${100*r}%`},Ps=new WeakSet,Bb=function(){const t=$e._svgFactory.create(1,1,!0);return s(this,Zn).append(t),t.setAttribute("aria-hidden",!0),t},Qw=function(t,e){const i=$e._svgFactory.createElement("clipPath");t.append(i);const n=`clip_${e}`;i.setAttribute("id",n),i.setAttribute("clipPathUnits","objectBoundingBox");const r=$e._svgFactory.createElement("use");return i.append(r),r.setAttribute("href",`#${e}`),r.classList.add("clip"),n},jb=function(t,e){for(const[i,n]of Object.entries(e))n===null?t.removeAttribute(i):t.setAttribute(i,n)},y($e,op),y($e,Tu,0);let xm=$e;globalThis._pdfjsTestingUtils={HighlightOutliner:gm},globalThis.pdfjsLib={AbortException:Nr,AnnotationEditorLayer:Em,AnnotationEditorParamsType:kt,AnnotationEditorType:mt,AnnotationEditorUIManager:Uo,AnnotationLayer:fm,AnnotationMode:Lr,AnnotationType:Oe,applyOpacity:iE,build:cx,ColorPicker:Of,createValidAbsoluteUrl:s0,CSSConstants:eE,DOMSVGFactory:Lf,DrawLayer:xm,FeatureTest:je,fetchData:xh,findContrastColor:nE,getDocument:J0,getFilenameFromUrl:qS,getPdfFilenameFromUrl:KS,getRGB:Th,getUuid:c0,getXfaPageViewport:ZS,GlobalWorkerOptions:rs,ImageKind:ff,InvalidPDFException:Fg,isDataScheme:yf,isPdfFile:Ug,isValidExplicitDest:pE,MathClamp:Ei,noContextMenu:wn,normalizeUnicode:GS,OPS:wh,OutputScale:ns,PasswordResponses:FS,PDFDataRangeTransport:Z0,PDFDateString:vf,PDFWorker:Ih,PermissionFlag:NS,PixelsPerInch:Fr,RenderingCancelledException:zg,renderRichText:b0,ResponseException:bf,setLayerDimensions:zo,shadow:gt,SignatureExtractor:Ls,stopEvent:Ee,SupportedImageMimeTypes:Hg,TextLayer:Oh,TouchManager:Sf,updateUrlHash:r0,Util:Z,VerbosityLevel:pf,version:Q0,XfaLayer:d0},rs.workerSrc=`//unpkg.com/pdfjs-dist@${Q0}/build/pdf.worker.min.mjs`;const Cm=B.forwardRef(({watermark:a,isLocked:t,lockText:e,onLockChange:i,isWatermarkEnabled:n,watermarkText:r,mode:o,initialElements:l,onAfterMount:c,onImageUpload:h,onPdfUpload:d,allowPdfDownload:u=!1},f)=>{var yv;const p=B.useRef(null),m=og(),b=dy(),v=ii(E=>E.whiteboard.grid),w=ii(E=>E.whiteboard.toolbar.selectedTool),_=ii(E=>E.whiteboard.elements),A=ii(E=>E.whiteboard.viewport),C=ii(E=>E.whiteboard.toolProperties),x=ii(E=>E.whiteboard.selectedElementIds||[]),P=ii(E=>E.whiteboard.lock),R=P.isLocked,N=ii(E=>E.whiteboard.pdf),[z,H]=B.useState(!1),[I,ct]=B.useState({x:0,y:0}),[j,K]=B.useState({x:0,y:0}),[st,tt]=B.useState([]),[J,lt]=B.useState(!1),[It,Rt]=B.useState({}),[Bt,St]=B.useState(!1),[xt,ye]=B.useState(!1),[Lt,ee]=B.useState(!1),[Nt,Hi]=B.useState({x:0,y:0}),[ke,vi]=B.useState({x:0,y:0,initialZoom:1,initialPan:{x:0,y:0}}),[wi,it]=B.useState(!1),[$i,rt]=B.useState({x:0,y:0}),[We,Wi]=B.useState(""),[Vi,ks]=B.useState(null),ll=B.useRef(null),Mo=B.useRef(null),[Pu,ap]=B.useState(!1),[ei,ku]=B.useState(null),[Mu,lp]=B.useState(null),[cp,hp]=B.useState(null),[rh,dp]=B.useState(!1),[ae,cl]=B.useState(null),[Gi,Er]=B.useState(null),[Me,Ro]=B.useState([]),[Do,up]=B.useState(1),fp=50,Oo=B.useRef(null),Ru=B.useCallback(async E=>{try{if(Oo.current)try{Oo.current.destroy()}catch(F){console.warn("Error destroying previous PDF:",F)}const k=await J0(E).promise;Oo.current=k,Er(k);const O=[];let L=0;for(let F=1;F<=k.numPages;F++){const U=(await k.getPage(F)).getViewport({scale:1.5});O.push({pageIndex:F,x:L,y:0,width:U.width,height:U.height}),L+=U.width+fp}if(Ro(O),up(1),O.length>0){const F=O[0],$=p.current;if($){const at=($.height-80)/F.height,G=Math.min(at,1.2),X=F.width*G,ut=($.width-X)/2-F.x*G,ft=40;m(yh(G)),m(Bo({x:ut,y:ft}))}}}catch(T){console.error("Error loading PDF from URL:",T)}},[m]);B.useEffect(()=>{N!=null&&N.url?Ru(N.url):(Oo.current&&(Oo.current.destroy(),Oo.current=null),Er(null),Ro([]))},[N==null?void 0:N.url,Ru]);const oh=B.useCallback(async E=>{try{let T="";d?T=await d(E):h?T=await h(E):T=URL.createObjectURL(E),m(Rg(T)),m(bh())}catch(T){console.error("Error loading PDF:",T)}},[m,h,d]),Dm=B.useCallback(()=>{m(Rg(void 0)),m(bh())},[m]),Om=B.useCallback(()=>{if(N!=null&&N.url){const E=document.createElement("a");E.href=N.url,E.download="document.pdf",document.body.appendChild(E),E.click(),document.body.removeChild(E)}},[N]),Du=B.useCallback(async E=>{console.log("Rendering PDF page start:",E.pageIndex);try{const T=await Gi.getPage(E.pageIndex);console.log("Got page object:",E.pageIndex);const k=T.getViewport({scale:1.5}),O=document.createElement("canvas"),L=O.getContext("2d");return O.width=k.width,O.height=k.height,L&&(console.log("Starting render task:",E.pageIndex),await T.render({canvasContext:L,viewport:k}).promise,console.log("Finished render task:",E.pageIndex)),O}catch(T){return console.error("Error rendering PDF page:",T),null}},[Gi]),xr=B.useCallback(async E=>{console.log("ensurePageRendered called for:",E),Ro(k=>{const L=[...k].find(F=>F.pageIndex===E);return L&&!L.canvas&&console.log("Page needs rendering (in setter):",E),k});const T=E-1;if(Me[T])if(Me[T].canvas)console.log("Page already has canvas:",E);else{console.log("Triggering renderPdfPage for:",E);const k=await Du(Me[T]);k?(console.log("Setting canvas to state for:",E),Ro(O=>{const L=[...O];return L[T]={...L[T],canvas:k},L}),Mi.current&&(console.log("Forcing redrawRef"),Mi.current())):console.error("Render returned null for:",E)}else console.log("Page not found in pdfPages:",T)},[Me,Du]),pp=B.useCallback(E=>{if(E<1||!Gi||E>Gi.numPages)return;up(E);const T=Me.find(k=>k.pageIndex===E);if(T){const k=p.current;if(k){const O=-T.x+(k.width/A.zoom-T.width)/2;m(Bo({x:O*A.zoom,y:50*A.zoom}))}xr(E),E>1&&xr(E-1),E<Gi.numPages&&xr(E+1)}},[Me,Gi,A.zoom,m,xr]);B.useEffect(()=>{Me.length>0&&(xr(1),Me.length>1&&xr(2))},[Gi,Me.length,xr]);const Im=B.useCallback(E=>{Vi&&E.trim()&&(ll.current&&clearTimeout(ll.current),ll.current=setTimeout(()=>{Vi&&E!==Mo.current&&(Mo.current=E,m(hf({id:Vi,updates:{text:E}})))},150))},[m,Vi]);B.useEffect(()=>()=>{ll.current&&clearTimeout(ll.current)},[]),B.useImperativeHandle(f,()=>({canvas:p.current,applyAction:E=>{m({...E,meta:{...E.meta,fromRemote:!0}})},getElems:()=>b.getState().whiteboard.elements,getElements:()=>b.getState().whiteboard.elements,setElems:E=>{m({...Mg(E),meta:{fromRemote:!0}})},setElements:E=>{m({...Mg(E),meta:{fromRemote:!0}})},clearElems:()=>{m({...bh(),meta:{fromRemote:!0}})},clearElements:()=>{m({...bh(),meta:{fromRemote:!0}})},setPdf:E=>{m({...Rg(E),meta:{fromRemote:!0}})}})),B.useEffect(()=>{t!==void 0&&m(Ky(t))},[t,m]),B.useEffect(()=>{i&&i(R)},[R,i]);const hl=ii(E=>E.whiteboard.watermark);B.useEffect(()=>{n!==void 0&&n!==hl.visible&&m(H1(n))},[n,hl.visible,m]),B.useEffect(()=>{r!==void 0&&r!==hl.text&&m($1(r))},[r,hl.text,m]),B.useEffect(()=>{l&&l.length>0&&m(Mg(l))},[m]),B.useEffect(()=>{c&&setTimeout(()=>{c()},0)},[]);const D=B.useCallback((E,T,k)=>{const O=E.canvas,L=O.width,F=O.height,$=Math.floor(-A.panX/A.zoom/T)*T,U=Math.floor(-A.panY/A.zoom/T)*T,Y=Math.ceil((L/A.zoom-A.panX/A.zoom)/T)*T,at=Math.ceil((F/A.zoom-A.panY/A.zoom)/T)*T;E.strokeStyle=k,E.lineWidth=.5/A.zoom;for(let G=$;G<=Y;G+=T)E.beginPath(),E.moveTo(G,U),E.lineTo(G,at),E.stroke();for(let G=U;G<=at;G+=T)E.beginPath(),E.moveTo($,G),E.lineTo(Y,G),E.stroke()},[A]),V=B.useCallback((E,T,k)=>{const O=Math.min(T.x,k.x),L=Math.min(T.y,k.y),F=Math.abs(k.x-T.x),$=Math.abs(k.y-T.y);E.strokeStyle="#0066cc",E.lineWidth=1,E.setLineDash([5,5]),E.strokeRect(O,L,F,$),E.fillStyle="rgba(0, 102, 204, 0.1)",E.fillRect(O,L,F,$),E.setLineDash([])},[]),Q=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,fillColor:$="#000",strokeColor:U="#000",lineWidth:Y=2}=T;E.fillStyle=$,E.fillRect(k,O,L,F),E.strokeStyle=U,E.lineWidth=Y,E.strokeRect(k,O,L,F)},[]),dt=B.useCallback((E,T)=>{const{centerX:k=0,centerY:O=0,radius:L=0,fillColor:F="#000",strokeColor:$="#000",lineWidth:U=2}=T;E.beginPath(),E.arc(k,O,L,0,Math.PI*2),E.fillStyle=F,E.fill(),E.strokeStyle=$,E.lineWidth=U,E.stroke()},[]),jt=B.useCallback((E,T)=>{const{points:k=[],strokeColor:O="#000",lineWidth:L=2}=T;if(!(k.length<2)){E.strokeStyle=O,E.lineWidth=L,E.lineCap="round",E.lineJoin="round",E.beginPath(),E.moveTo(k[0].x,k[0].y);for(let F=1;F<k.length;F++)k[F]&&E.lineTo(k[F].x,k[F].y);E.stroke()}},[]),Vt=B.useCallback((E,T)=>{const{x:k=0,y:O=0,text:L="",fontSize:F=16,fontColor:$="#000"}=T;E.font=`${F}px sans-serif`,E.fillStyle=$,E.textBaseline="top",E.fillText(L,k,O)},[]),Tt=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,fillColor:$="#fff",strokeColor:U="#000",lineWidth:Y=2}=T;E.beginPath(),E.moveTo(k+L/2,O),E.lineTo(k+L,O+F),E.lineTo(k,O+F),E.closePath(),E.fillStyle=$,E.fill(),E.strokeStyle=U,E.lineWidth=Y,E.stroke()},[]),Et=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,fillColor:$="#fff",strokeColor:U="#000",lineWidth:Y=2}=T;E.beginPath(),E.moveTo(k+L/2,O),E.lineTo(k+L,O+F/2),E.lineTo(k+L/2,O+F),E.lineTo(k,O+F/2),E.closePath(),E.fillStyle=$,E.fill(),E.strokeStyle=U,E.lineWidth=Y,E.stroke()},[]),Fe=B.useCallback((E,T)=>{const{centerX:k=0,centerY:O=0,size:L=0,fillColor:F="#ffff00",strokeColor:$="#000",lineWidth:U=2}=T,Y=5,at=L,G=L/2;E.beginPath();for(let X=0;X<Y*2;X++){const ut=X%2===0?at:G,ft=Math.PI/Y*X-Math.PI/2,Ct=k+Math.cos(ft)*ut,Gt=O+Math.sin(ft)*ut;X===0?E.moveTo(Ct,Gt):E.lineTo(Ct,Gt)}E.closePath(),E.fillStyle=F,E.fill(),E.strokeStyle=$,E.lineWidth=U,E.stroke()},[]),de=B.useCallback((E,T)=>{const{centerX:k=0,centerY:O=0,size:L=0,fillColor:F="#ff6b6b",strokeColor:$="#000",lineWidth:U=2}=T;E.beginPath();const Y=O-L/2;E.moveTo(k,Y+L/4),E.bezierCurveTo(k-L/2,Y,k-L,Y+L/2,k,O+L/2),E.bezierCurveTo(k+L,Y+L/2,k+L/2,Y,k,Y+L/4),E.fillStyle=F,E.fill(),E.strokeStyle=$,E.lineWidth=U,E.stroke()},[]),fe=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,fillColor:$="#fff",strokeColor:U="#000",lineWidth:Y=2}=T,at=k+L/2,G=O+F/2,X=L/2,ut=F/2;E.beginPath();for(let ft=0;ft<6;ft++){const Ct=Math.PI/3*ft-Math.PI/2,Gt=at+Math.cos(Ct)*X,Ve=G+Math.sin(Ct)*ut;ft===0?E.moveTo(Gt,Ve):E.lineTo(Gt,Ve)}E.closePath(),E.fillStyle=$,E.fill(),E.strokeStyle=U,E.lineWidth=Y,E.stroke()},[]),Yi=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,fillColor:$="#fff",strokeColor:U="#000",lineWidth:Y=2}=T,at=k+L/2,G=O+F/2,X=L/2,ut=F/2;E.beginPath();for(let ft=0;ft<8;ft++){const Ct=Math.PI/4*ft-Math.PI/2,Gt=at+Math.cos(Ct)*X,Ve=G+Math.sin(Ct)*ut;ft===0?E.moveTo(Gt,Ve):E.lineTo(Gt,Ve)}E.closePath(),E.fillStyle=$,E.fill(),E.strokeStyle=U,E.lineWidth=Y,E.stroke()},[]),Qn=B.useCallback((E,T)=>{const{startX:k=0,startY:O=0,endX:L=0,endY:F=0,fillColor:$="#000",strokeColor:U="#000",lineWidth:Y=2}=T,at=15,G=Math.atan2(F-O,L-k);E.beginPath(),E.moveTo(k,O),E.lineTo(L,F),E.strokeStyle=U,E.lineWidth=Y,E.stroke(),E.beginPath(),E.moveTo(L,F),E.lineTo(L-at*Math.cos(G-Math.PI/6),F-at*Math.sin(G-Math.PI/6)),E.lineTo(L-at*Math.cos(G+Math.PI/6),F-at*Math.sin(G+Math.PI/6)),E.closePath(),E.fillStyle=$,E.fill()},[]),dl=B.useRef({}),Mi=B.useRef(null),dv=B.useCallback((E,T)=>{const{x:k=0,y:O=0,width:L=0,height:F=0,src:$=""}=T;try{if(dl.current[$]){const U=dl.current[$];if(U.complete&&U.naturalWidth>0)try{E.drawImage(U,k,O,L,F)}catch(Y){console.error("Failed to draw cached image:",Y)}}else{const U=new Image;U.onload=()=>{dl.current[$]=U,Mi.current&&Mi.current()},U.onerror=Y=>{console.error("Failed to load image:",$,Y)},U.src=$,dl.current[$]=U}}catch(U){console.error("Error in drawImage:",U)}},[]),gp=B.useCallback((E,T)=>{switch(T.type){case"rectangle":Q(E,T);break;case"circle":dt(E,T);break;case"pencil":jt(E,T);break;case"text":Vt(E,T);break;case"triangle":Tt(E,T);break;case"diamond":Et(E,T);break;case"star":Fe(E,T);break;case"heart":de(E,T);break;case"hexagon":fe(E,T);break;case"octagon":Yi(E,T);break;case"arrow":Qn(E,T);break;case"image":dv(E,T);break}},[Q,dt,jt,Vt,Tt,Et,Fe,de,fe,Yi,Qn,dv]),Ix=B.useCallback(()=>{const E=p.current;if(!E)return;const T=document.createElement("canvas");T.width=E.width,T.height=E.height;const k=T.getContext("2d");if(!k)return;k.fillStyle="#ffffff",k.fillRect(0,0,T.width,T.height),k.save(),k.translate(A.panX,A.panY),k.scale(A.zoom,A.zoom),Me.length>0&&Me.forEach(F=>{F.canvas&&k.drawImage(F.canvas,F.x,F.y,F.width,F.height)}),_.forEach(F=>{gp(k,F)}),k.restore();const O=T.toDataURL("image/png"),L=document.createElement("a");L.download=`whiteboard-${Date.now()}.png`,L.href=O,L.click()},[A,_,gp,Me]),Lx=B.useCallback(()=>{const E=p.current;if(E){if(Gi&&Me.length>0){const T=Me[Do-1];if(T){const O=E.width-100,L=E.height-100,F=O/T.width,$=L/T.height,U=Math.min(F,$,5),Y=T.x+T.width/2,at=T.y+T.height/2,G=E.width/2-Y*U,X=E.height/2-at*U;m(yh(Math.max(.1,U))),m(Bo({x:G,y:X}));return}}m(j1({canvasWidth:E.width,canvasHeight:E.height,padding:50}))}},[m,Gi,Me,Do]),Nx=B.useCallback(()=>{m(N1())},[m]),uv=(E,T,k,O,L,F)=>{const $=E-k,U=T-O,Y=L-k,at=F-O,G=$*Y+U*at,X=Y*Y+at*at;let ut=-1;X!==0&&(ut=G/X);let ft,Ct;ut<0?(ft=k,Ct=O):ut>1?(ft=L,Ct=F):(ft=k+ut*Y,Ct=O+ut*at);const Gt=E-ft,Ve=T-Ct;return Math.sqrt(Gt*Gt+Ve*Ve)},Lm=B.useCallback((E,T)=>{for(let k=_.length-1;k>=0;k--){const O=_[k],L=O.x??0,F=O.y??0,$=O.width??0,U=O.height??0,Y=O.centerX??0,at=O.centerY??0,G=O.radius??0;if(O.type==="rectangle"){if(E>=L&&E<=L+$&&T>=F&&T<=F+U)return O}else if(O.type==="circle"){if(Math.sqrt(Math.pow(E-Y,2)+Math.pow(T-at,2))<=G)return O}else if(O.type==="pencil"){const ut=O.points??[];for(let ft=1;ft<ut.length;ft++){const Ct=ut[ft-1],Gt=ut[ft];if(!Ct||!Gt)continue;if(uv(E,T,Ct.x,Ct.y,Gt.x,Gt.y)<=5)return O}}else if(O.type==="text"){const X=O.fontSize||16,ft=(O.text||"").length*X*.6,Ct=X;if(E>=L&&E<=L+ft&&T>=F&&T<=F+Ct)return O}else if(O.type==="triangle"||O.type==="diamond"||O.type==="hexagon"||O.type==="octagon"){if(E>=L&&E<=L+$&&T>=F&&T<=F+U)return O}else if(O.type==="star"||O.type==="heart"){const X=Math.sqrt(Math.pow(E-Y,2)+Math.pow(T-at,2)),ut=O.size??0;if(X<=ut)return O}else if(O.type==="arrow"){const ut=O.startX??0,ft=O.startY??0,Ct=O.endX??0,Gt=O.endY??0;if(uv(E,T,ut,ft,Ct,Gt)<=10)return O}else if(O.type==="image"&&E>=L&&E<=L+$&&T>=F&&T<=F+U)return O}return null},[_]),ah=B.useCallback(E=>{let T=0,k=0,O=0,L=0;if(E.type==="rectangle"||E.type==="image"||E.type==="text"||E.type==="triangle"||E.type==="diamond"||E.type==="hexagon"||E.type==="octagon")if(T=E.x??0,k=E.y??0,E.type==="text"){const F=E.fontSize||16;O=(E.text||"").length*F*.6,L=F}else O=E.width??0,L=E.height??0;else if(E.type==="circle"){const F=E.radius??0;T=(E.centerX??0)-F,k=(E.centerY??0)-F,O=F*2,L=F*2}else if(E.type==="star"||E.type==="heart"){const F=E.size??0;T=(E.centerX??0)-F,k=(E.centerY??0)-F,O=F*2,L=F*2}else if(E.type==="pencil"&&E.points&&E.points.length>0){const F=Math.min(...E.points.map(at=>at.x)),$=Math.max(...E.points.map(at=>at.x)),U=Math.min(...E.points.map(at=>at.y)),Y=Math.max(...E.points.map(at=>at.y));T=F,k=U,O=$-F,L=Y-U}else if(E.type==="arrow")return null;return{x:T,y:k,w:O,h:L}},[]),mp=B.useCallback(E=>{const T=[];if(E.type==="arrow")return T.push({type:"start",x:E.startX??0,y:E.startY??0}),T.push({type:"end",x:E.endX??0,y:E.endY??0}),T;const k=ah(E);if(!k)return[];const{x:O,y:L,w:F,h:$}=k;return T.push({type:"nw",x:O,y:L}),T.push({type:"ne",x:O+F,y:L}),T.push({type:"se",x:O+F,y:L+$}),T.push({type:"sw",x:O,y:L+$}),T.push({type:"n",x:O+F/2,y:L}),T.push({type:"s",x:O+F/2,y:L+$}),T.push({type:"e",x:O+F,y:L+$/2}),T.push({type:"w",x:O,y:L+$/2}),T},[ah]),fv=B.useCallback((E,T,k,O)=>{const L=mp(k),F=10/O;for(const $ of L)if(Math.abs(E-$.x)<=F&&Math.abs(T-$.y)<=F)return $.type;return null},[mp]),pv=B.useCallback((E,T)=>{E.strokeStyle="#0066cc",E.lineWidth=1/A.zoom,E.setLineDash([5/A.zoom,5/A.zoom]);const k=ah(T);k?E.strokeRect(k.x-4/A.zoom,k.y-4/A.zoom,k.w+8/A.zoom,k.h+8/A.zoom):T.type,E.setLineDash([]);const O=mp(T),L=8/A.zoom;E.fillStyle="#ffffff",E.strokeStyle="#0066cc",E.lineWidth=1/A.zoom;for(const F of O)E.fillRect(F.x-L/2,F.y-L/2,L,L),E.strokeRect(F.x-L/2,F.y-L/2,L,L)},[A.zoom,ah,mp]),Cr=B.useCallback(()=>{const E=p.current;if(!E)return;const T=E.getContext("2d");if(T)try{T.clearRect(0,0,E.width,E.height),T.save(),T.translate(A.panX,A.panY),T.scale(A.zoom,A.zoom),v.enabled&&D(T,v.size,v.color),Me.length>0&&Me.forEach(k=>{if(T.fillStyle="white",T.shadowColor="rgba(0,0,0,0.2)",T.shadowBlur=10,T.shadowOffsetX=2,T.shadowOffsetY=2,T.fillRect(k.x,k.y,k.width,k.height),T.shadowColor="transparent",T.shadowBlur=0,T.shadowOffsetX=0,T.shadowOffsetY=0,k.canvas)T.drawImage(k.canvas,k.x,k.y,k.width,k.height);else{T.fillStyle="#f5f5f5",T.fillRect(k.x,k.y,k.width,k.height),T.fillStyle="#999",T.font="20px sans-serif",T.fillText("Loading...",k.x+20,k.y+40);const O=-A.panX/A.zoom,L=T.canvas.width/A.zoom;k.x+k.width>O&&k.x<O+L}}),_.forEach(k=>{try{gp(T,k),x.includes(k.id)&&pv(T,k)}catch(O){console.error("Error drawing element:",k.id,O)}}),rh&&ae&&(T.fillStyle="rgba(0, 102, 204, 0.1)",T.strokeStyle="#0066cc",T.lineWidth=1/A.zoom,T.fillRect(ae.startX,ae.startY,ae.width,ae.height),T.strokeRect(ae.startX,ae.startY,ae.width,ae.height)),T.restore()}catch(k){console.error("Error redrawing canvas:",k);try{T.restore()}catch{}}},[v,D,_,gp,x,pv,A,rh,ae,Me]);B.useEffect(()=>{Mi.current=Cr},[Cr]),B.useEffect(()=>{const E=p.current;if(!E)return;const T=E.parentElement;if(!T)return;const k=()=>{const L=T.getBoundingClientRect();E.width=L.width,E.height=L.height,Cr()};k();const O=new ResizeObserver(()=>{k()});return O.observe(T),()=>{O.disconnect()}},[Cr]),B.useEffect(()=>{Cr()},[Cr]),B.useEffect(()=>{const E=k=>{k.target.tagName==="INPUT"||k.target.tagName==="TEXTAREA"||k.code==="Space"&&!k.repeat&&(k.preventDefault(),St(!0))},T=k=>{k.target.tagName==="INPUT"||k.target.tagName==="TEXTAREA"||k.code==="Space"&&(k.preventDefault(),St(!1),ye(!1),ee(!1))};return window.addEventListener("keydown",E),window.addEventListener("keyup",T),()=>{window.removeEventListener("keydown",E),window.removeEventListener("keyup",T)}},[]);const ul=B.useCallback((E,T)=>({x:(E-A.panX)/A.zoom,y:(T-A.panY)/A.zoom}),[A]);B.useEffect(()=>{const E=p.current;if(!E||!z)return;const T=E.getContext("2d");if(T){if(Cr(),T.save(),T.translate(A.panX,A.panY),T.scale(A.zoom,A.zoom),w==="pointer")V(T,I,j);else if(w==="rectangle"){const k=Math.min(I.x,j.x),O=Math.min(I.y,j.y),L=Math.abs(j.x-I.x),F=Math.abs(j.y-I.y);Q(T,{id:"preview",type:"rectangle",x:k,y:O,width:L,height:F,fillColor:C.rectangle.fillColor,lineWidth:C.rectangle.lineWidth})}else if(w==="circle"){const k=I.x,O=I.y,L=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));dt(T,{id:"preview",type:"circle",centerX:k,centerY:O,radius:L,strokeColor:C.circle.strokeColor,fillColor:C.circle.fillColor,lineWidth:C.circle.lineWidth})}else if(w==="pencil")jt(T,{id:"preview",type:"pencil",points:st,strokeColor:C.pencil.strokeColor,lineWidth:C.pencil.lineWidth});else if(w==="triangle"){const k=Math.min(I.x,j.x),O=Math.min(I.y,j.y),L=Math.abs(j.x-I.x),F=Math.abs(j.y-I.y);Tt(T,{id:"preview",type:"triangle",x:k,y:O,width:L,height:F,fillColor:C.triangle.fillColor,lineWidth:C.triangle.lineWidth})}else if(w==="diamond"){const k=Math.min(I.x,j.x),O=Math.min(I.y,j.y),L=Math.abs(j.x-I.x),F=Math.abs(j.y-I.y);Et(T,{id:"preview",type:"diamond",x:k,y:O,width:L,height:F,fillColor:C.diamond.fillColor,lineWidth:C.diamond.lineWidth})}else if(w==="star"){const k=I.x,O=I.y,L=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));Fe(T,{id:"preview",type:"star",centerX:k,centerY:O,size:L,fillColor:C.star.fillColor,lineWidth:C.star.lineWidth})}else if(w==="heart"){const k=I.x,O=I.y,L=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));de(T,{id:"preview",type:"heart",centerX:k,centerY:O,size:L,fillColor:C.heart.fillColor,lineWidth:C.heart.lineWidth})}else if(w==="hexagon"){const k=Math.min(I.x,j.x),O=Math.min(I.y,j.y),L=Math.abs(j.x-I.x),F=Math.abs(j.y-I.y);fe(T,{id:"preview",type:"hexagon",x:k,y:O,width:L,height:F,fillColor:C.hexagon.fillColor,lineWidth:C.hexagon.lineWidth})}else if(w==="octagon"){const k=Math.min(I.x,j.x),O=Math.min(I.y,j.y),L=Math.abs(j.x-I.x),F=Math.abs(j.y-I.y);Yi(T,{id:"preview",type:"octagon",x:k,y:O,width:L,height:F,fillColor:C.octagon.fillColor,lineWidth:C.octagon.lineWidth})}else w==="arrow"&&Qn(T,{id:"preview",type:"arrow",startX:I.x,startY:I.y,endX:j.x,endY:j.y,fillColor:C.arrow.fillColor,lineWidth:C.arrow.lineWidth});T.restore()}},[z,w,I,j,st,Cr,V,Q,dt,jt,Tt,Et,Fe,de,fe,Yi,Qn,A,C]);const Fx=E=>{const T=p.current;if(!T)return;const k=T.getBoundingClientRect(),O=E.clientX-k.left,L=E.clientY-k.top;if(wi)return;if(Bt){E.preventDefault(),E.button===0?(ye(!0),Hi({x:O-A.panX,y:L-A.panY})):E.button===2&&(ee(!0),vi({x:O,y:L,initialZoom:A.zoom,initialPan:{x:A.panX,y:A.panY}}));return}if(R)return;const{x:F,y:$}=ul(O,L);if(w==="pointer"){const U=Lm(F,$);let Y=null;if(x.length===1){const at=x[0],G=_.find(X=>X.id===at);if(G){const X=fv(F,$,G,A.zoom);X&&(Y={element:G,handle:X})}}if(Y){ap(!0),ku(Y.handle),lp({x:F,y:$}),hp(JSON.parse(JSON.stringify(Y.element)));return}if(U){const at=x.includes(U.id);let G=x;if(E.shiftKey?(at?G=x.filter(X=>X!==U.id):G=[...x,U.id],m(Os(G))):at||(G=[U.id],m(Os(G))),G.length>0){lt(!0),ct({x:F,y:$});const X={};G.forEach(ut=>{const ft=_.find(Ct=>Ct.id===ut);ft&&(X[ut]={...ft})}),Rt(X)}}else{E.shiftKey||m(Os([])),dp(!0);const{x:at,y:G}=ul(O,L);cl({startX:at,startY:G,width:0,height:0})}}else if(w==="text"){const U=Date.now().toString();m(Di({id:U,type:"text",x:F,y:$,text:"Text",fontSize:C.text.fontSize,fontColor:C.text.fontColor})),m(Fn("pointer")),m(Os([U])),ks(U),Wi("Text"),rt({x:F,y:$}),it(!0)}else if(w==="eraser"){const U=Lm(F,$);U&&m(B1(U.id))}else m(Os([])),H(!0),ct({x:F,y:$}),K({x:F,y:$}),w==="pencil"&&tt([{x:F,y:$}])},Bx=E=>{const T=p.current;if(!T)return;const k=T.getBoundingClientRect(),O=E.clientX-k.left,L=E.clientY-k.top;if(xt){m(Bo({x:O-Nt.x,y:L-Nt.y}));return}if(Lt){const U=ke.y-L,at=ke.initialZoom*(1+U*.005),G=Math.max(.1,Math.min(at,5)),X=(ke.x-ke.initialPan.x)/ke.initialZoom,ut=(ke.y-ke.initialPan.y)/ke.initialZoom,ft=ke.x-X*G,Ct=ke.y-ut*G;m(yh(G)),m(Bo({x:ft,y:Ct}));return}if(R)return;const{x:F,y:$}=ul(O,L);if(rh&&ae){const U=F-ae.startX,Y=$-ae.startY;cl({...ae,width:U,height:Y});return}if(J&&x.length>0){const U=F-I.x,Y=$-I.y,at=[];x.forEach(G=>{const X=It[G];if(!X)return;let ut={};if(X.type==="rectangle")ut={x:(X.x??0)+U,y:(X.y??0)+Y};else if(X.type==="circle")ut={centerX:(X.centerX??0)+U,centerY:(X.centerY??0)+Y};else if(X.type==="pencil"){const ft=X.points||[];if(ft.length===0)return;ut={points:ft.map(Ct=>({x:Ct.x+U,y:Ct.y+Y}))}}else X.type==="text"?ut={x:(X.x??0)+U,y:(X.y??0)+Y}:X.type==="triangle"||X.type==="diamond"||X.type==="hexagon"||X.type==="octagon"?ut={x:(X.x??0)+U,y:(X.y??0)+Y}:X.type==="star"||X.type==="heart"?ut={centerX:(X.centerX??0)+U,centerY:(X.centerY??0)+Y}:X.type==="arrow"?ut={startX:(X.startX??0)+U,startY:(X.startY??0)+Y,endX:(X.endX??0)+U,endY:(X.endY??0)+Y}:X.type==="image"&&(ut={x:(X.x??0)+U,y:(X.y??0)+Y});at.push({id:G,updates:ut})}),at.length>0&&m(qy(at));return}if(Pu&&cp&&Mu&&ei){let U={};const Y=F-Mu.x,at=$-Mu.y,G=cp;if(G.type==="arrow")ei==="start"?U={startX:(G.startX??0)+Y,startY:(G.startY??0)+at}:ei==="end"&&(U={endX:(G.endX??0)+Y,endY:(G.endY??0)+at});else if(G.type==="circle"||G.type==="star"||G.type==="heart"){const X=G.radius||G.size||0,ut=ei.includes("e"),ft=ei.includes("s"),Ct=ei.includes("w"),Gt=ei.includes("n");let Ve=0;ut&&(Ve+=Y),Ct&&(Ve-=Y),ft&&(Ve+=at),Gt&&(Ve-=at);const Ou=Math.max(5,X+Ve);G.type==="circle"?U={radius:Ou}:U={size:Ou}}else if(G.type==="pencil"&&G.points){const X=ah(G);if(X){const{x:ut,y:ft,w:Ct,h:Gt}=X;let Ve=ut,Ou=ft,Fm=Ct,Bm=Gt;ei.includes("e")&&(Fm=Math.max(5,Ct+Y)),ei.includes("w")&&(Fm=Math.max(5,Ct-Y),Ve=ut+Y),ei.includes("s")&&(Bm=Math.max(5,Gt+at)),ei.includes("n")&&(Bm=Math.max(5,Gt-at),Ou=ft+at);const Vx=Fm/Ct,Gx=Bm/Gt;U={points:G.points.map(vv=>({x:Ve+(vv.x-ut)*Vx,y:Ou+(vv.y-ft)*Gx}))}}}else{let X=G.x??0,ut=G.y??0,ft=G.width??0,Ct=G.height??0;if(ei.includes("e")&&(ft=Math.max(5,(G.width??0)+Y)),ei.includes("w")){const Gt=(G.width??0)-Y;Gt>5&&(ft=Gt,X=(G.x??0)+Y)}if(ei.includes("s")&&(Ct=Math.max(5,(G.height??0)+at)),ei.includes("n")){const Gt=(G.height??0)-at;Gt>5&&(Ct=Gt,ut=(G.y??0)+at)}U={x:X,y:ut,width:ft,height:Ct}}Object.keys(U).length>0&&m(hf({id:G.id,updates:U}));return}z&&(K({x:F,y:$}),w==="pencil"&&tt(U=>[...U,{x:F,y:$}]))},gv=()=>{if(xt||Lt){ye(!1),ee(!1);return}if(R){lt(!1),H(!1);return}if(J&&lt(!1),rh&&ae){const E=ae.width>0?ae.startX:ae.startX+ae.width,T=ae.height>0?ae.startY:ae.startY+ae.height,k=Math.abs(ae.width),O=Math.abs(ae.height),L=[];_.forEach(F=>{const $=ah(F);$&&$.x<E+k&&$.x+$.w>E&&$.y<T+O&&$.y+$.h>T&&L.push(F.id)}),L.length>0&&m(Os(L))}if(H(!1),lt(!1),ap(!1),dp(!1),cl(null),ku(null),hp(null),tt([]),ct({x:0,y:0}),Rt({}),lp(null),ye(!1),!!z){if(w==="pointer")Cr();else if(w==="rectangle"){const E=Math.min(I.x,j.x),T=Math.min(I.y,j.y),k=Math.abs(j.x-I.x),O=Math.abs(j.y-I.y);k>0&&O>0&&m(Di({id:Date.now().toString(),type:"rectangle",x:E,y:T,width:k,height:O,strokeColor:C.rectangle.strokeColor,fillColor:C.rectangle.fillColor,lineWidth:C.rectangle.lineWidth}))}else if(w==="circle"){const E=I.x,T=I.y,k=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));k>0&&m(Di({id:Date.now().toString(),type:"circle",centerX:E,centerY:T,radius:k,strokeColor:C.circle.strokeColor,fillColor:C.circle.fillColor,lineWidth:C.circle.lineWidth}))}else if(w==="pencil")st.length>1&&m(Di({id:Date.now().toString(),type:"pencil",points:[...st],strokeColor:C.pencil.strokeColor,lineWidth:C.pencil.lineWidth})),tt([]);else if(w==="triangle"){const E=Math.min(I.x,j.x),T=Math.min(I.y,j.y),k=Math.abs(j.x-I.x),O=Math.abs(j.y-I.y);k>0&&O>0&&m(Di({id:Date.now().toString(),type:"triangle",x:E,y:T,width:k,height:O,strokeColor:C.triangle.strokeColor,fillColor:C.triangle.fillColor,lineWidth:C.triangle.lineWidth}))}else if(w==="diamond"){const E=Math.min(I.x,j.x),T=Math.min(I.y,j.y),k=Math.abs(j.x-I.x),O=Math.abs(j.y-I.y);k>0&&O>0&&m(Di({id:Date.now().toString(),type:"diamond",x:E,y:T,width:k,height:O,strokeColor:C.diamond.strokeColor,fillColor:C.diamond.fillColor,lineWidth:C.diamond.lineWidth}))}else if(w==="star"){const E=I.x,T=I.y,k=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));k>0&&m(Di({id:Date.now().toString(),type:"star",centerX:E,centerY:T,size:k,strokeColor:C.star.strokeColor,fillColor:C.star.fillColor,lineWidth:C.star.lineWidth}))}else if(w==="heart"){const E=I.x,T=I.y,k=Math.sqrt(Math.pow(j.x-I.x,2)+Math.pow(j.y-I.y,2));k>0&&m(Di({id:Date.now().toString(),type:"heart",centerX:E,centerY:T,size:k,strokeColor:C.heart.strokeColor,fillColor:C.heart.fillColor,lineWidth:C.heart.lineWidth}))}else if(w==="hexagon"){const E=Math.min(I.x,j.x),T=Math.min(I.y,j.y),k=Math.abs(j.x-I.x),O=Math.abs(j.y-I.y);k>0&&O>0&&m(Di({id:Date.now().toString(),type:"hexagon",x:E,y:T,width:k,height:O,strokeColor:C.hexagon.strokeColor,fillColor:C.hexagon.fillColor,lineWidth:C.hexagon.lineWidth}))}else if(w==="octagon"){const E=Math.min(I.x,j.x),T=Math.min(I.y,j.y),k=Math.abs(j.x-I.x),O=Math.abs(j.y-I.y);k>0&&O>0&&m(Di({id:Date.now().toString(),type:"octagon",x:E,y:T,width:k,height:O,strokeColor:C.octagon.strokeColor,fillColor:C.octagon.fillColor,lineWidth:C.octagon.lineWidth}))}else if(w==="arrow"){const E=j.x-I.x,T=j.y-I.y;Math.sqrt(E*E+T*T)>5&&m(Di({id:Date.now().toString(),type:"arrow",startX:I.x,startY:I.y,endX:j.x,endY:j.y,strokeColor:C.arrow.strokeColor,fillColor:C.arrow.fillColor,lineWidth:C.arrow.lineWidth}))}H(!1)}},jx=E=>{if(E.ctrlKey||E.metaKey){E.preventDefault();const T=p.current;if(!T)return;const k=T.getBoundingClientRect(),O=E.clientX-k.left,L=E.clientY-k.top,F=(O-A.panX)/A.zoom,$=(L-A.panY)/A.zoom,U=-E.deltaY,Y=.1,at=U>0?A.zoom*(1+Y):A.zoom/(1+Y),G=Math.min(Math.max(at,.1),5),X=O-F*G,ut=L-$*G;m(yh(G)),m(Bo({x:X,y:ut}))}else{E.preventDefault();const T=p.current;if(!T)return;const k=T.getBoundingClientRect(),O=E.clientX-k.left,L=E.clientY-k.top,F=(O-A.panX)/A.zoom,$=(L-A.panY)/A.zoom,U=.001;let Y=1;E.deltaMode===1?Y=1-E.deltaY*.05:Y=1-E.deltaY*U;const at=A.zoom*Y,G=Math.min(Math.max(at,.1),5),X=O-F*G,ut=L-$*G;m(yh(G)),m(Bo({x:X,y:ut}))}},zx=E=>{Bt&&E.preventDefault()},Ux=(E,T,k)=>{ks(E.id),Wi(E.text||""),rt({x:E.x||T,y:E.y||k}),Mo.current=E.text||"",it(!0)},Hx=()=>{if(Bt)return xt?"grabbing":Lt?"ns-resize":"grab";if(R)return"default";if(x.length===1&&!z&&w==="pointer"){const E=_.find(T=>T.id===x[0]);if(E){const T=fv(j.x,j.y,E,A.zoom);if(T)return T==="n"||T==="s"?"ns-resize":T==="e"||T==="w"?"ew-resize":T==="ne"||T==="sw"?"nesw-resize":T==="nw"||T==="se"?"nwse-resize":"pointer"}}return"default"},[mv,bv]=B.useState({propTools:!1,lockIndicator:!1});B.useEffect(()=>{const E=()=>{if(window.innerWidth<=768){bv({propTools:!1,lockIndicator:!1});return}const T=document.getElementById("wb-canvas-container");if(!T)return;const k=T.querySelector(".wb-toolbar"),O=T.querySelector(".wb-prop-tools"),L=T.querySelector(".wb-lock-indicator");let F=!1,$=!1;if(k){const U=k.getBoundingClientRect();if(O){const Y=O.getBoundingClientRect();U.bottom>Y.top-10&&(F=!0)}if(L){const Y=L.getBoundingClientRect();U.top<Y.bottom+10&&($=!0)}}bv({propTools:F,lockIndicator:$})};return E(),window.addEventListener("resize",E),()=>{window.removeEventListener("resize",E)}},[w,R,x]);const Nm=B.useCallback(async(E,T,k)=>{if(E.type==="application/pdf"){await oh(E);return}if(!E.type.startsWith("image/")){console.warn("Unsupported image format:",E.type||E.name);return}try{let O="";h?O=await h(E):O=URL.createObjectURL(E);const L=new Image;L.onload=()=>{const F=L.width/L.height,$=200,U=$/F;m(Di({id:Date.now().toString(),type:"image",x:T-$/2,y:k-U/2,width:$,height:U,src:O}))},L.src=O}catch(O){console.error("Failed to upload image:",O)}},[oh,h,m]);B.useEffect(()=>{const E=T=>{if(!(T.target.tagName==="INPUT"||T.target.tagName==="TEXTAREA")&&!R&&T.clipboardData&&T.clipboardData.files.length>0){const k=T.clipboardData.files[0];if(k.type.startsWith("image/")||k.type==="application/pdf"){T.preventDefault();const O=p.current;if(O){const L=O.getBoundingClientRect(),F=L.width/2,$=L.height/2,{x:U,y:Y}=ul(F,$);Nm(k,U,Y)}}}};return window.addEventListener("paste",E),()=>window.removeEventListener("paste",E)},[R,ul,Nm]);const $x=E=>{E.preventDefault()},Wx=E=>{if(E.preventDefault(),!R&&E.dataTransfer.files&&E.dataTransfer.files.length>0){const T=E.dataTransfer.files[0];if(T.type.startsWith("image/")||T.type==="application/pdf"){const k=p.current;if(k){const O=k.getBoundingClientRect(),L=E.clientX-O.left,F=E.clientY-O.top,{x:$,y:U}=ul(L,F);Nm(T,$,U)}}}};return M.jsxs("div",{id:"wb-canvas-container",style:{backgroundColor:"#fff",position:"relative",width:"100%",height:"100%"},onDragOver:$x,onDrop:Wx,children:[M.jsx("canvas",{ref:p,onMouseDown:Fx,onMouseMove:Bx,onMouseUp:gv,onMouseLeave:gv,onWheel:jx,onDoubleClick:E=>{if(R)return;const T=p.current;if(!T)return;const k=T.getBoundingClientRect(),O=E.clientX-k.left,L=E.clientY-k.top,{x:F,y:$}=ul(O,L),U=Lm(F,$);U&&U.type==="text"&&Ux(U,F,$)},onContextMenu:zx,style:{cursor:Hx()}}),R&&M.jsx(SS,{text:e||a&&((yv=a.lock)==null?void 0:yv.text)||P.text,shifted:mv.lockIndicator}),wi&&M.jsx("input",{type:"text",value:We,onChange:E=>{const T=E.target.value;Wi(T),Im(T)},onKeyDown:E=>{E.key==="Enter"&&We.trim()?(Vi&&(m(hf({id:Vi,updates:{text:We}})),Mo.current=We),it(!1),Wi(""),ks(null)):E.key==="Escape"&&(it(!1),Wi(""),ks(null))},onBlur:()=>{We.trim()&&Vi&&(m(hf({id:Vi,updates:{text:We}})),Mo.current=We),it(!1),Wi(""),ks(null)},onMouseDown:E=>E.stopPropagation(),autoFocus:!0,style:{position:"absolute",left:$i.x*A.zoom+A.panX,top:$i.y*A.zoom+A.panY,fontSize:C.text.fontSize*A.zoom,color:C.text.fontColor,background:"white",border:"2px solid #0066cc",outline:"none",fontFamily:"sans-serif",minWidth:"150px",padding:"4px 8px",zIndex:1e3,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"}}),M.jsx(IS,{onFitToView:Lx,onExport:Ix,onToggleGrid:Nx}),M.jsx(DS,{mode:o,onImageUpload:h,onPdfSelected:oh}),Gi&&M.jsx(LS,{currentPage:Do,totalPages:Gi.numPages,onPrevPage:()=>pp(Do-1),onNextPage:()=>pp(Do+1),onDelete:Dm,onDownload:u?Om:void 0}),M.jsx(OS,{shifted:mv.propTools}),hl.visible&&M.jsx(K1,{})]})});Cm.displayName="InternalWhiteboard";class Ox extends B.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,e){console.error("Whiteboard Error:",t,e)}render(){return this.state.hasError?M.jsxs("div",{style:{padding:"20px",textAlign:"center",background:"#fff1f0",border:"1px solid #ffa39e",borderRadius:"4px",height:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center"},children:[M.jsx("h3",{children:"Something went wrong in Whiteboard"}),M.jsx("button",{onClick:()=>this.setState({hasError:!1}),style:{marginTop:"10px",padding:"8px 16px",cursor:"pointer",background:"#fff",border:"1px solid #d9d9d9",borderRadius:"2px"},children:"Try Again"})]}):this.props.children}}const cv=B.forwardRef((a,t)=>{const{store:e,onAction:i,...n}=a,r=B.useRef(i);B.useEffect(()=>{r.current=i},[i]);const o=B.useMemo(()=>e??Dg({actionHandlerRef:r}),[e]);return M.jsx(Ox,{children:M.jsx(_A,{store:o,children:M.jsx(RA,{children:M.jsx(Cm,{ref:t,...n})})})})});cv.displayName="Whiteboard",At.WhiteboardComponent=Cm,At.createWhiteboardStore=Dg,At.default=cv,At.store=q1,At.whiteboardActions=W1,At.whiteboardReducer=Jy,Object.defineProperties(At,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
111
111
  //# sourceMappingURL=whiteboard.umd.js.map